Пример #1
0
 def subscribes(self):
     result = ""
     pool = self.component.idsl_pool
     for subscribes in self.component.subscribesTo:
         module = pool.module_providing_interface(subscribes.name)
         if module is None:
             raise ValueError('\nCan\'t find module providing %s\n' %
                              subscribes.name)
         for interface in module['interfaces']:
             if interface['name'] == subscribes.name:
                 for mname in interface['methods']:
                     method = interface['methods'][mname]
                     param_str_a = ''
                     body_code = self.body_code_from_name(method['name'])
                     if p_utils.communication_is_ice(subscribes):
                         param_str_a = utils.get_parameters_string(
                             method, module['name'],
                             self.component.language)
                         result += "//SUBSCRIPTION to " + method[
                             'name'] + " method from " + interface[
                                 'name'] + " interface\n"
                         result += method['return'] + ' SpecificWorker::' + interface[
                             'name'] + "_" + method[
                                 'name'] + '(' + param_str_a + ")\n{\n//subscribesToCODE\n" + body_code + "\n}\n\n"
                     else:
                         pass
     return result
Пример #2
0
 def subscribes_method_definitions(self):
     result = ""
     pool = self.component.idsl_pool
     for impa in self.component.subscribesTo:
         if type(impa) == str:
             imp = impa
         else:
             imp = impa.name
         module = pool.module_providing_interface(imp)
         for interface in module['interfaces']:
             if interface['name'] == imp:
                 for mname in interface['methods']:
                     method = interface['methods'][mname]
                     param_str_a = ''
                     if p_utils.communication_is_ice(impa):
                         param_str_a = utils.get_parameters_string(
                             method, module['name'],
                             self.component.language)
                         return_type = utils.get_type_string(
                             method['return'], module['name'])
                         result += return_type + ' ' + interface[
                             'name'] + "_" + method[
                                 'name'] + '(' + param_str_a + ");\n"
                     else:
                         pass
     return result
Пример #3
0
 def implements(self):
     result = ""
     pool = self.component.idsl_pool
     for impa in self.component.implements:
         if type(impa) == str:
             imp = impa
         else:
             imp = impa[0]
         module = pool.module_providing_interface(imp)
         for interface in module['interfaces']:
             if interface['name'] == imp:
                 for mname in interface['methods']:
                     method = interface['methods'][mname]
                     param_str_a = ''
                     body_code = self.body_code_from_name(method['name'])
                     if p_utils.communication_is_ice(impa):
                         param_str_a = utils.get_parameters_string(
                             method, module['name'],
                             self.component.language)
                         return_type = utils.get_type_string(
                             method['return'], module['name'])
                         result += return_type + ' SpecificWorker::' + interface[
                             'name'] + "_" + method[
                                 'name'] + '(' + param_str_a + ")\n{\n//implementCODE\n" + body_code + "\n}\n\n"
                     else:
                         pass
     return result
Пример #4
0
    def interface_methods_definition(self, module, interface_name):
        result = ""
        for interface in module['interfaces']:
            if interface['name'] == interface_name:
                for mname in interface['methods']:
                    method = interface['methods'][mname]

                    ret = utils.get_type_string(method['return'], module['name'])
                    name = method['name']

                    param_str = utils.get_parameters_string(method, module['name'], self.component.language)
                    if param_str:
                        param_str = f"{param_str}, const Ice::Current&"
                    else:
                        param_str = "const Ice::Current&"
                    result += ret + ' ' + name + '(' + param_str + ');\n'
        return result
Пример #5
0
 def implements(self):
     result = ""
     for iface in self.component.implements:
         pool = self.component.idsl_pool
         module = pool.module_providing_interface(iface.name)
         for interface in module['interfaces']:
             if interface['name'] == iface.name:
                 for mname in interface['methods']:
                     method = interface['methods'][mname]
                     param_str_a = ''
                     if communication_is_ice(iface):
                         param_str_a = utils.get_parameters_string(method, module['name'], self.component.language)
                         return_type = utils.get_type_string(method['return'], module['name'])
                         result += f"virtual {return_type} {interface['name']}_{method['name']}({param_str_a}) = 0;\n"
                     else:
                         pass
     return result
Пример #6
0
 def subscribes(self):
     result = ""
     for iface in self.component.subscribesTo:
         pool = self.component.idsl_pool
         module = pool.module_providing_interface(iface.name)
         if module is None:
             raise ValueError('\nCan\'t find module providing %s \n' % iface.name)
         for interface in module['interfaces']:
             if interface['name'] == iface.name:
                 for mname in interface['methods']:
                     method = interface['methods'][mname]
                     param_str_a = ''
                     if communication_is_ice(iface):
                         param_str_a = utils.get_parameters_string(method, module['name'], self.component.language)
                         return_type = utils.get_type_string(method['return'], module['name'])
                         result += f"virtual {return_type} {interface['name']}_{method['name']} ({param_str_a}) = 0;\n"
                     else:
                         pass
     return result
Пример #7
0
 def generate_interface_method_definition(self, interface):
     result = ""
     pool = self.component.idsl_pool
     if type(interface) == str:
         interface_name = interface
     else:
         interface_name = interface.name
     module = pool.module_providing_interface(interface_name)
     for idsl_interface in module['interfaces']:
         if idsl_interface['name'] == interface_name:
             for method_name, method in idsl_interface['methods'].items():
                 if p_utils.communication_is_ice(interface):
                     params_string = utils.get_parameters_string(
                         method, module['name'], self.component.language)
                     return_type = utils.get_type_string(
                         method['return'], module['name'])
                     result += return_type + ' ' + idsl_interface[
                         'name'] + "_" + method[
                             'name'] + '(' + params_string + ");\n"
                 else:
                     pass
     return result