Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions rosidl_generator_py/resource/_msg.py.em
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,7 @@ if isinstance(type_, AbstractNestedType):
type_ = type_.value_type
}@
'@(member.name)': '@
@# the prefix for nested types
@[ if isinstance(member.type, AbstractSequence)]@
sequence<@
@[ end if]@
@# the typename of the non-nested type or the nested basetype
@# the typename of the non-nested type or the nested basetype (.msg syntax)
@[ if isinstance(type_, BasicType)]@
@(type_.typename)@
@[ elif isinstance(type_, AbstractGenericString)]@
Expand All @@ -282,17 +278,16 @@ w@
@[ end if]@
string@
@[ if type_.has_maximum_size()]@
<@(type_.maximum_size)>@
<=@(type_.maximum_size)@
@[ end if]@
@[ elif isinstance(type_, NamespacedType)]@
@('/'.join([type_.namespaces[0], type_.name]))@
@[ end if]@
@# the suffix for nested types
@[ if isinstance(member.type, AbstractSequence)]@
@[ if isinstance(member.type, BoundedSequence)]@
, @(member.type.maximum_size)@
@[ end if]@
>@
@# array/sequence suffix in .msg syntax
@[ if isinstance(member.type, BoundedSequence)]@
[<=@(member.type.maximum_size)]@
@[ elif isinstance(member.type, UnboundedSequence)]@
[]@
@[ elif isinstance(member.type, Array)]@
[@(member.type.size)]@
@[ end if]@
Expand Down
20 changes: 10 additions & 10 deletions rosidl_generator_py/test/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,17 +939,17 @@ def test_string_slot_attributes() -> None:
assert hasattr(msg, '__slots__')
string_slot_types_dict = getattr(msg, 'get_fields_and_field_types')()
expected_string_slot_types_dict = {
'ub_string_static_array_value': 'string<5>[3]',
'ub_string_ub_array_value': 'sequence<string<5>, 10>',
'ub_string_dynamic_array_value': 'sequence<string<5>>',
'string_dynamic_array_value': 'sequence<string>',
'ub_string_static_array_value': 'string<=5[3]',
'ub_string_ub_array_value': 'string<=5[<=10]',
'ub_string_dynamic_array_value': 'string<=5[]',
'string_dynamic_array_value': 'string[]',
'string_static_array_value': 'string[3]',
'string_bounded_array_value': 'sequence<string, 10>',
'def_string_dynamic_array_value': 'sequence<string>',
'string_bounded_array_value': 'string[<=10]',
'def_string_dynamic_array_value': 'string[]',
'def_string_static_array_value': 'string[3]',
'def_string_bounded_array_value': 'sequence<string, 10>',
'def_various_quotes': 'sequence<string>',
'def_various_commas': 'sequence<string>',
'def_string_bounded_array_value': 'string[<=10]',
'def_various_quotes': 'string[]',
'def_various_commas': 'string[]',
}

assert len(string_slot_types_dict) == len(expected_string_slot_types_dict)
Expand Down Expand Up @@ -1012,7 +1012,7 @@ def test_builtin_sequence_slot_attributes() -> None:
assert hasattr(msg, '__slots__')
builtin_sequence_slot_types_dict = getattr(msg, 'get_fields_and_field_types')()
expected_builtin_sequence_slot_types_dict = {
'char_sequence_unbounded': 'sequence<char>',
'char_sequence_unbounded': 'char[]',
}

assert len(builtin_sequence_slot_types_dict) == len(expected_builtin_sequence_slot_types_dict)