Skip to content

Commit

Permalink
Merge pull request #11 from robocomp/LucasBonilla26-patch-1
Browse files Browse the repository at this point in the history
fixed generating empty components in both languages
  • Loading branch information
LucasBonilla26 authored Jan 25, 2024
2 parents 96854c9 + 8681bbb commit 7812a60
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,18 @@ def interface_sources(self):

def wrap_ice(self):
interface_names = []
for im in sorted(self.component.recursiveImports + self.component.ice_interfaces_names):
name = im.split('/')[-1].split('.')[0]
interface_names.append(name)


if self.component.recursiveImports is not None and self.component.ice_interfaces_names is not None:
for im in sorted(self.component.recursiveImports + self.component.ice_interfaces_names):
name = im.split('/')[-1].split('.')[0]
interface_names.append(name)

result = "ROBOCOMP_IDSL_TO_ICE( CommonBehavior "
result += ' '.join(interface_names)
result += ")\n"
result += "ROBOCOMP_ICE_TO_SRC( CommonBehavior "
result += ' '.join(interface_names)
result += ")\n"

return result

Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def __init__(self, component):
def interfaces_includes(self):
result = ""
pool = self.component.idsl_pool

if self.component.recursiveImports is None or self.component.ice_interfaces_names is None:
return ""

for iface in sorted(list(set(self.component.recursiveImports + self.component.ice_interfaces_names))):
name = iface.split('/')[-1].split('.')[0]
result += '#include <' + name + '.h>\n'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ def __init__(self, component):
@staticmethod
def interface_includes(interfaces, suffix='', lower=False):
result = ""
if interfaces is None:
return ""

for interface in sorted(interfaces):
if communication_is_ice(interface):
name = interface if isinstance(interface, str) else interface.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ def __init__(self, component):
super(src_CMakeLists_txt, self).__init__()
self.component = component
interface_names = []
for im in sorted(self.component.recursiveImports + self.component.ice_interfaces_names):
name = im.split('/')[-1].split('.')[0]
interface_names.append(name)
if self.component.recursiveImports is not None and self.component.imports is not None:
for im in sorted(self.component.recursiveImports + self.component.ice_interfaces_names):
name = im.split('/')[-1].split('.')[0]
interface_names.append(name)
self['ifaces_list'] = ' '.join(interface_names)
self['component_name'] = self.component.name
Original file line number Diff line number Diff line change
Expand Up @@ -66,34 +66,37 @@ def __init__(self, component):
def load_slice_and_create_imports(self, includeDirectories=None):
result = ""
import os
logger.debug(f"Loading slice files: {self.component.recursiveImports + self.component.imports}")
for imp in sorted(set(self.component.recursiveImports + self.component.imports)):
file_name = os.path.basename(imp)
name = os.path.splitext(file_name)[0]
result += Template(SLICE_LOAD_STR).substitute(interface_name=name)
logger.debug(f"Loading slice file: {file_name} ({name})")
# module = DSLFactory().from_file(file_name, includeDirectories=includeDirectories)
module = self.component.idsl_pool[name]
logger.debug(f"Module: {module}")
result += f"import {module['name']}\n"
if self.component.recursiveImports is not None and self.component.imports is not None:
logger.debug(f"Loading slice files: {self.component.recursiveImports + self.component.imports}")
for imp in sorted(set(self.component.recursiveImports + self.component.imports)):
file_name = os.path.basename(imp)
name = os.path.splitext(file_name)[0]
result += Template(SLICE_LOAD_STR).substitute(interface_name=name)
logger.debug(f"Loading slice file: {file_name} ({name})")
# module = DSLFactory().from_file(file_name, includeDirectories=includeDirectories)
module = self.component.idsl_pool[name]
logger.debug(f"Module: {module}")
result += f"import {module['name']}\n"

return result

def create_lists_classes(self):
result = ""
for idsl in sorted(set(self.component.recursiveImports + self.component.imports)):
try:
module = self.component.idsl_pool.module_providing_interface(idsl.split('.')[0])
except Exception as e:
print(e.message)
exit(-1)

if module is not None: # For modules without interface
for sequence in module['sequences']:
item_type = utils.get_type_string(sequence['typeSequence'], module['name'])
if item_type == 'bytes': continue
result += Template(LIST_CLASSES_STR).substitute(list_type=sequence['name'].split('/')[1],
item_type=item_type,
module_name=module['name'])
if self.component.recursiveImports is not None and self.component.imports is not None:
for idsl in sorted(set(self.component.recursiveImports + self.component.imports)):
try:
module = self.component.idsl_pool.module_providing_interface(idsl.split('.')[0])
except Exception as e:
print(e.message)
exit(-1)

if module is not None: # For modules without interface
for sequence in module['sequences']:
item_type = utils.get_type_string(sequence['typeSequence'], module['name'])
if item_type == 'bytes': continue
result += Template(LIST_CLASSES_STR).substitute(list_type=sequence['name'].split('/')[1],
item_type=item_type,
module_name=module['name'])
return result

def implements_and_subscribes_imports(self):
Expand Down

0 comments on commit 7812a60

Please sign in to comment.