diff --git a/rosidl_generator_py/resource/_msg.py.em b/rosidl_generator_py/resource/_msg.py.em index a8682df0..2bf2a439 100644 --- a/rosidl_generator_py/resource/_msg.py.em +++ b/rosidl_generator_py/resource/_msg.py.em @@ -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)]@ @@ -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]@ diff --git a/rosidl_generator_py/test/test_interfaces.py b/rosidl_generator_py/test/test_interfaces.py index 64225d9c..bcd30e8f 100644 --- a/rosidl_generator_py/test/test_interfaces.py +++ b/rosidl_generator_py/test/test_interfaces.py @@ -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, 10>', - 'ub_string_dynamic_array_value': 'sequence>', - 'string_dynamic_array_value': 'sequence', + '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', - 'def_string_dynamic_array_value': 'sequence', + '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', - 'def_various_quotes': 'sequence', - 'def_various_commas': 'sequence', + '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) @@ -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_sequence_unbounded': 'char[]', } assert len(builtin_sequence_slot_types_dict) == len(expected_builtin_sequence_slot_types_dict)