diff --git a/rosidl_adapter/CHANGELOG.rst b/rosidl_adapter/CHANGELOG.rst index 8071dd794..c10d6c5d5 100644 --- a/rosidl_adapter/CHANGELOG.rst +++ b/rosidl_adapter/CHANGELOG.rst @@ -2,6 +2,21 @@ Changelog for package rosidl_adapter ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +4.8.1 (2024-06-25) +------------------ + +4.8.0 (2024-06-17) +------------------ + +4.7.0 (2024-04-26) +------------------ + +4.6.0 (2024-04-16) +------------------ + +4.5.2 (2024-03-27) +------------------ + 4.5.1 (2024-02-07) ------------------ diff --git a/rosidl_adapter/package.xml b/rosidl_adapter/package.xml index 6f2d8f5bd..b94409496 100644 --- a/rosidl_adapter/package.xml +++ b/rosidl_adapter/package.xml @@ -2,7 +2,7 @@ rosidl_adapter - 4.5.1 + 4.8.1 API and scripts to parse .msg/.srv/.action files and convert them to .idl. diff --git a/rosidl_adapter/rosidl_adapter/resource/__init__.py b/rosidl_adapter/rosidl_adapter/resource/__init__.py index ce3335853..b629021a1 100644 --- a/rosidl_adapter/rosidl_adapter/resource/__init__.py +++ b/rosidl_adapter/rosidl_adapter/resource/__init__.py @@ -18,6 +18,12 @@ import em +try: + from em import Configuration + em_has_configuration = True +except ImportError: + em_has_configuration = False + def expand_template(template_name, data, output_file, encoding='utf-8'): content = evaluate_template(template_name, data) @@ -45,18 +51,31 @@ def evaluate_template(template_name, data): output = StringIO() try: - _interpreter = em.Interpreter( - output=output, - options={ - em.BUFFERED_OPT: True, - em.RAW_OPT: True, - }) - + if em_has_configuration: + config = Configuration( + defaultRoot=template_path, + defaultStdout=output, + deleteOnError=True, + rawErrors=True, + useProxy=True) + _interpreter = em.Interpreter( + config=config, + dispatcher=False) + else: + _interpreter = em.Interpreter( + output=output, + options={ + em.BUFFERED_OPT: True, + em.RAW_OPT: True, + }) with open(template_path, 'r') as h: content = h.read() _interpreter.invoke( 'beforeFile', name=template_name, file=h, locals=data) - _interpreter.string(content, template_path, locals=data) + if em_has_configuration: + _interpreter.string(content, locals=data) + else: + _interpreter.string(content, template_path, locals=data) _interpreter.invoke('afterFile') return output.getvalue() @@ -66,7 +85,8 @@ def evaluate_template(template_name, data): file=sys.stderr) raise finally: - _interpreter.shutdown() + if _interpreter is not None: + _interpreter.shutdown() _interpreter = None @@ -78,7 +98,10 @@ def _evaluate_template(template_name, **kwargs): 'beforeInclude', name=template_path, file=h, locals=kwargs) content = h.read() try: - _interpreter.string(content, template_path, kwargs) + if em_has_configuration: + _interpreter.string(content, locals=kwargs) + else: + _interpreter.string(content, template_path, kwargs) except Exception as e: # noqa: F841 print( f"{e.__class__.__name__} processing template '{template_name}': " diff --git a/rosidl_cli/CHANGELOG.rst b/rosidl_cli/CHANGELOG.rst index ebfd58a6d..615afe4b5 100644 --- a/rosidl_cli/CHANGELOG.rst +++ b/rosidl_cli/CHANGELOG.rst @@ -2,6 +2,21 @@ Changelog for package rosidl_cli ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +4.8.1 (2024-06-25) +------------------ + +4.8.0 (2024-06-17) +------------------ + +4.7.0 (2024-04-26) +------------------ + +4.6.0 (2024-04-16) +------------------ + +4.5.2 (2024-03-27) +------------------ + 4.5.1 (2024-02-07) ------------------ diff --git a/rosidl_cli/package.xml b/rosidl_cli/package.xml index eb0ce4bc1..591e702f3 100644 --- a/rosidl_cli/package.xml +++ b/rosidl_cli/package.xml @@ -2,7 +2,7 @@ rosidl_cli - 4.5.1 + 4.8.1 Command line tools for ROS interface generation. diff --git a/rosidl_cli/setup.py b/rosidl_cli/setup.py index aec16306a..fddf6e2b4 100644 --- a/rosidl_cli/setup.py +++ b/rosidl_cli/setup.py @@ -3,7 +3,7 @@ setup( name='rosidl_cli', - version='4.5.1', + version='4.8.1', packages=find_packages(exclude=['test']), extras_require={ 'completion': ['argcomplete'], diff --git a/rosidl_cmake/CHANGELOG.rst b/rosidl_cmake/CHANGELOG.rst index d5fa70561..34ee935fc 100644 --- a/rosidl_cmake/CHANGELOG.rst +++ b/rosidl_cmake/CHANGELOG.rst @@ -2,6 +2,23 @@ Changelog for package rosidl_cmake ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +4.8.1 (2024-06-25) +------------------ + +4.8.0 (2024-06-17) +------------------ + +4.7.0 (2024-04-26) +------------------ + +4.6.0 (2024-04-16) +------------------ + +4.5.2 (2024-03-27) +------------------ +* Improve deprecation notice of rosidl_target_interface to give a hint on how to update the code (`#788 `_) +* Contributors: Alexis Paques + 4.5.1 (2024-02-07) ------------------ diff --git a/rosidl_cmake/package.xml b/rosidl_cmake/package.xml index 0378e5a0a..bcff069f5 100644 --- a/rosidl_cmake/package.xml +++ b/rosidl_cmake/package.xml @@ -2,7 +2,7 @@ rosidl_cmake - 4.5.1 + 4.8.1 The CMake functionality to invoke code generation for ROS interface files. Aditya Pande diff --git a/rosidl_generator_c/CHANGELOG.rst b/rosidl_generator_c/CHANGELOG.rst index c583b762d..40bee3694 100644 --- a/rosidl_generator_c/CHANGELOG.rst +++ b/rosidl_generator_c/CHANGELOG.rst @@ -2,6 +2,25 @@ Changelog for package rosidl_generator_c ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +4.8.1 (2024-06-25) +------------------ + +4.8.0 (2024-06-17) +------------------ + +4.7.0 (2024-04-26) +------------------ +* Fixed warnings - strict-prototypes (`#800 `_) +* Contributors: Alejandro Hernández Cordero + +4.6.0 (2024-04-16) +------------------ + +4.5.2 (2024-03-27) +------------------ +* Set hints to find the python version we actually want. (`#785 `_) +* Contributors: Chris Lalancette + 4.5.1 (2024-02-07) ------------------ diff --git a/rosidl_generator_c/package.xml b/rosidl_generator_c/package.xml index 742eb1724..d1efb9680 100644 --- a/rosidl_generator_c/package.xml +++ b/rosidl_generator_c/package.xml @@ -2,7 +2,7 @@ rosidl_generator_c - 4.5.1 + 4.8.1 Generate the ROS interfaces in C. Aditya Pande diff --git a/rosidl_generator_c/resource/action__type_support.h.em b/rosidl_generator_c/resource/action__type_support.h.em index efab57097..a1747c6c0 100644 --- a/rosidl_generator_c/resource/action__type_support.h.em +++ b/rosidl_generator_c/resource/action__type_support.h.em @@ -14,7 +14,7 @@ const rosidl_action_type_support_t * ROSIDL_TYPESUPPORT_INTERFACE__ACTION_SYMBOL_NAME( rosidl_typesupport_c, @(',\n '.join(action.namespaced_type.namespaced_name())) -)(); +)(void); @{ TEMPLATE( diff --git a/rosidl_generator_c/resource/msg__functions.c.em b/rosidl_generator_c/resource/msg__functions.c.em index 0c15b7475..f7fe8d7f1 100644 --- a/rosidl_generator_c/resource/msg__functions.c.em +++ b/rosidl_generator_c/resource/msg__functions.c.em @@ -317,7 +317,7 @@ bool } @(message_typename) * -@(message_typename)__create() +@(message_typename)__create(void) { rcutils_allocator_t allocator = rcutils_get_default_allocator(); @(message_typename) * msg = (@(message_typename) *)allocator.allocate(sizeof(@(message_typename)), allocator.state); diff --git a/rosidl_generator_c/resource/msg__functions.h.em b/rosidl_generator_c/resource/msg__functions.h.em index af8b208c8..7fd27767f 100644 --- a/rosidl_generator_c/resource/msg__functions.h.em +++ b/rosidl_generator_c/resource/msg__functions.h.em @@ -50,7 +50,7 @@ void */ ROSIDL_GENERATOR_C_PUBLIC_@(package_name) @(message_typename) * -@(message_typename)__create(); +@(message_typename)__create(void); /// Destroy @(interface_path_to_string(interface_path)) message. /** diff --git a/rosidl_generator_c/resource/msg__type_support.h.em b/rosidl_generator_c/resource/msg__type_support.h.em index 9c0065cc8..785c4f55b 100644 --- a/rosidl_generator_c/resource/msg__type_support.h.em +++ b/rosidl_generator_c/resource/msg__type_support.h.em @@ -14,4 +14,4 @@ const rosidl_message_type_support_t * ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME( rosidl_typesupport_c, @(',\n '.join(message.structure.namespaced_type.namespaced_name())) -)(); +)(void); diff --git a/rosidl_generator_c/resource/srv__type_support.h.em b/rosidl_generator_c/resource/srv__type_support.h.em index af2621cfc..5cfbd883f 100644 --- a/rosidl_generator_c/resource/srv__type_support.h.em +++ b/rosidl_generator_c/resource/srv__type_support.h.em @@ -35,7 +35,7 @@ const rosidl_service_type_support_t * ROSIDL_TYPESUPPORT_INTERFACE__SERVICE_SYMBOL_NAME( rosidl_typesupport_c, @(',\n '.join(service.namespaced_type.namespaced_name())) -)(); +)(void); // Forward declare the function to create a service event message for this type. ROSIDL_GENERATOR_C_PUBLIC_@(package_name) diff --git a/rosidl_generator_cpp/CHANGELOG.rst b/rosidl_generator_cpp/CHANGELOG.rst index cf7533a6b..c681c6b26 100644 --- a/rosidl_generator_cpp/CHANGELOG.rst +++ b/rosidl_generator_cpp/CHANGELOG.rst @@ -2,6 +2,23 @@ Changelog for package rosidl_generator_cpp ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +4.8.1 (2024-06-25) +------------------ + +4.8.0 (2024-06-17) +------------------ + +4.7.0 (2024-04-26) +------------------ + +4.6.0 (2024-04-16) +------------------ + +4.5.2 (2024-03-27) +------------------ +* Set hints to find the python version we actually want. (`#785 `_) +* Contributors: Chris Lalancette + 4.5.1 (2024-02-07) ------------------ diff --git a/rosidl_generator_cpp/package.xml b/rosidl_generator_cpp/package.xml index 98ba8b8d1..cbeefc445 100644 --- a/rosidl_generator_cpp/package.xml +++ b/rosidl_generator_cpp/package.xml @@ -2,7 +2,7 @@ rosidl_generator_cpp - 4.5.1 + 4.8.1 Generate the ROS interfaces in C++. Aditya Pande diff --git a/rosidl_generator_tests/CHANGELOG.rst b/rosidl_generator_tests/CHANGELOG.rst index 1efd3fc3b..7da557061 100644 --- a/rosidl_generator_tests/CHANGELOG.rst +++ b/rosidl_generator_tests/CHANGELOG.rst @@ -2,6 +2,31 @@ Changelog for package rosidl_generator_tests ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +4.8.1 (2024-06-25) +------------------ +* Silence one more gcc false-positive. (`#814 `_) +* Contributors: Chris Lalancette + +4.8.0 (2024-06-17) +------------------ +* Switch to using fastjsonschema for schema validation. (`#809 `_) +* Contributors: Chris Lalancette + +4.7.0 (2024-04-26) +------------------ +* Fixed warnings - strict-prototypes (`#800 `_) +* Contributors: Alejandro Hernández Cordero + +4.6.0 (2024-04-16) +------------------ +* Increased the cpplint timeout to 300 seconds (`#797 `_) +* Contributors: Alejandro Hernández Cordero + +4.5.2 (2024-03-27) +------------------ +* Fixes for modern uncrustify. (`#793 `_) +* Contributors: Chris Lalancette + 4.5.1 (2024-02-07) ------------------ diff --git a/rosidl_generator_tests/CMakeLists.txt b/rosidl_generator_tests/CMakeLists.txt index f36054b70..b2b5d13fd 100644 --- a/rosidl_generator_tests/CMakeLists.txt +++ b/rosidl_generator_tests/CMakeLists.txt @@ -136,3 +136,8 @@ if(BUILD_TESTING) endif() ament_package() + +if(TEST cpplint) + # must set the property after ament_package() + set_tests_properties(cpplint PROPERTIES TIMEOUT 300) +endif() diff --git a/rosidl_generator_tests/package.xml b/rosidl_generator_tests/package.xml index 2726f15fa..af1275e7a 100644 --- a/rosidl_generator_tests/package.xml +++ b/rosidl_generator_tests/package.xml @@ -2,7 +2,7 @@ rosidl_generator_tests - 4.5.1 + 4.8.1 Integration tests for rosidl_generator_c and rosidl_generator_cpp packages. Aditya Pande @@ -24,7 +24,7 @@ ament_lint_auto ament_lint_common ament_index_python - python3-jsonschema + python3-fastjsonschema rosidl_cmake rosidl_generator_c rosidl_generator_cpp diff --git a/rosidl_generator_tests/test/rosidl_generator_c/separate_compilation.c b/rosidl_generator_tests/test/rosidl_generator_c/separate_compilation.c index 2aa2646f1..38dcae4f8 100644 --- a/rosidl_generator_tests/test/rosidl_generator_c/separate_compilation.c +++ b/rosidl_generator_tests/test/rosidl_generator_c/separate_compilation.c @@ -21,7 +21,7 @@ #include "rosidl_generator_tests/msg/detail/defaults__struct.h" #include "rosidl_generator_tests/msg/detail/defaults__functions.h" -int func() +int func(void) { rosidl_generator_tests__msg__Defaults * msg = rosidl_generator_tests__msg__Defaults__create(); if (!msg) { diff --git a/rosidl_generator_tests/test/rosidl_generator_c/separate_compilation.h b/rosidl_generator_tests/test/rosidl_generator_c/separate_compilation.h index 2520043df..c9ad7b9f9 100644 --- a/rosidl_generator_tests/test/rosidl_generator_c/separate_compilation.h +++ b/rosidl_generator_tests/test/rosidl_generator_c/separate_compilation.h @@ -15,6 +15,6 @@ #ifndef ROSIDL_GENERATOR_C__SEPARATE_COMPILATION_H_ #define ROSIDL_GENERATOR_C__SEPARATE_COMPILATION_H_ -int func(); +int func(void); #endif // ROSIDL_GENERATOR_C__SEPARATE_COMPILATION_H_ diff --git a/rosidl_generator_tests/test/rosidl_generator_c/test_descriptions.c b/rosidl_generator_tests/test/rosidl_generator_c/test_descriptions.c index 8e907b68a..d49fb04ab 100644 --- a/rosidl_generator_tests/test/rosidl_generator_c/test_descriptions.c +++ b/rosidl_generator_tests/test/rosidl_generator_c/test_descriptions.c @@ -66,10 +66,10 @@ bool string_char_equal(const rosidl_runtime_c__String * lhs, const char * rhs) return 0 == memcmp(lhs->data, rhs, rhs_len); } -int test_description_linkage(); -int test_copied_type_description_struct_hashes(); -int test_source_defined(); -int test_same_name_types(); +int test_description_linkage(void); +int test_copied_type_description_struct_hashes(void); +int test_source_defined(void); +int test_same_name_types(void); int main(void) { @@ -103,7 +103,7 @@ int main(void) return rc != 0; } -int test_description_linkage() +int test_description_linkage(void) { // Smoke test linkage and basic values for msg, srv, action // Message @@ -168,7 +168,7 @@ int test_description_linkage() return 0; } -int test_source_defined() +int test_source_defined(void) { // Smoke test that definitions are present for raw type sources // Message @@ -277,7 +277,7 @@ int test_source_defined() return 0; } -int test_copied_type_description_struct_hashes() +int test_copied_type_description_struct_hashes(void) { #define runtimehash(x) rosidl_runtime_c__type_description__ ## x ## __get_type_hash(NULL) #define msghash(x) type_description_interfaces__msg__ ## x ## __get_type_hash(NULL) @@ -313,7 +313,7 @@ int test_copied_type_description_struct_hashes() return rc; } -int test_same_name_types() +int test_same_name_types(void) { // Msg and srv with same name in this package // Regression check case, this was receiving "srv" encoding with Empty.srv sources diff --git a/rosidl_generator_tests/test/rosidl_generator_c/test_interfaces.c b/rosidl_generator_tests/test/rosidl_generator_c/test_interfaces.c index 5cb72ca20..94d5aa96b 100644 --- a/rosidl_generator_tests/test/rosidl_generator_c/test_interfaces.c +++ b/rosidl_generator_tests/test/rosidl_generator_c/test_interfaces.c @@ -45,21 +45,16 @@ u"Deep into that darkness peering, long I stood there wondering, fearing \u2122" #define ARR_SIZE 3 -#define STRINGIFY(x) _STRINGIFY(x) #define _STRINGIFY(x) #x +#define STRINGIFY(x) _STRINGIFY(x) -#define EXPECT_FALSE(arg) if (arg) { \ - fputs(STRINGIFY(arg) " is not false\n", stderr); \ - return 1; \ -} -#define EXPECT_TRUE(arg) if (!(arg)) { \ - fputs(STRINGIFY(arg) " is not true\n", stderr); \ - return 1; \ -} -#define EXPECT_EQ(arg1, arg2) if ((arg1) != (arg2)) { \ - fputs(STRINGIFY(arg1) " != " STRINGIFY(arg2) "\n", stderr); \ - return 1; \ -} +#define PUTS(arg, extra) fprintf(stderr, "%s%s\n", STRINGIFY(arg), extra) + +#define EXPECT_FALSE(arg) if (arg) {PUTS(arg, " is not false"); return 1;} +#define EXPECT_TRUE(arg) if (!(arg)) {PUTS(arg, " is not true"); return 1;} + +#define PUTS_NE(arg1, arg2) fprintf(stderr, "%s != %s\n", STRINGIFY(arg1), STRINGIFY(arg2)) +#define EXPECT_EQ(arg1, arg2) if ((arg1) != (arg2)) {PUTS_NE(arg1, arg2); return 1;} #define EXPECT_NE(arg1, arg2) if ((arg1) == (arg2)) return 1 static const uint8_t test_values_byte[ARR_SIZE] = {0, 57, 110}; @@ -429,7 +424,7 @@ static int test_bounded_sequences(void) return 0; } -int test_unbounded_sequences() +int test_unbounded_sequences(void) { rosidl_generator_tests__msg__UnboundedSequences * seq = NULL; seq = rosidl_generator_tests__msg__UnboundedSequences__create(); @@ -1004,7 +999,7 @@ static int test_multi_nested(void) return 0; } -int test_wstrings() +int test_wstrings(void) { rosidl_generator_tests__msg__WStrings * wstr = NULL; wstr = rosidl_generator_tests__msg__WStrings__create(); diff --git a/rosidl_generator_tests/test/rosidl_generator_cpp/test_interfaces.cpp b/rosidl_generator_tests/test/rosidl_generator_cpp/test_interfaces.cpp index e41230221..15bb4b7ef 100644 --- a/rosidl_generator_tests/test/rosidl_generator_cpp/test_interfaces.cpp +++ b/rosidl_generator_tests/test/rosidl_generator_cpp/test_interfaces.cpp @@ -12,7 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#pragma GCC diagnostic ignored "-Warray-bounds" +#endif #include +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif #include #include @@ -478,15 +486,7 @@ TEST(Test_messages, constants_assign) { // Defaults TEST(Test_messages, defaults) { rosidl_generator_tests::msg::Defaults message; -// workaround for https://github.com/google/googletest/issues/322 -#ifdef __linux__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion-null" -#endif TEST_BASIC_TYPE_FIELD_ASSIGNMENT(message, bool_value, true, false); -#ifdef __linux__ -#pragma GCC diagnostic pop -#endif TEST_BASIC_TYPE_FIELD_ASSIGNMENT(message, byte_value, 50, 255); TEST_BASIC_TYPE_FIELD_ASSIGNMENT(message, char_value, 100, UINT8_MAX); TEST_BASIC_TYPE_FIELD_ASSIGNMENT(message, float32_value, 1.125f, FLT_MAX); @@ -510,7 +510,6 @@ TEST(Test_messages, string_arrays_default) { ASSERT_EQ(3ul, message.string_values_default.size()); } -// TODO(mikaelarguedas) reenable this test when bounded strings enforce length TEST(Test_messages, DISABLED_Test_bounded_strings) { rosidl_generator_tests::msg::Strings message; TEST_STRING_FIELD_ASSIGNMENT(message, bounded_string_value, "", "Deep into") diff --git a/rosidl_generator_tests/test/rosidl_generator_type_description/test_type_hash.py b/rosidl_generator_tests/test/rosidl_generator_type_description/test_type_hash.py index 4fde93d05..1785d11b9 100644 --- a/rosidl_generator_tests/test/rosidl_generator_type_description/test_type_hash.py +++ b/rosidl_generator_tests/test/rosidl_generator_type_description/test_type_hash.py @@ -17,7 +17,7 @@ from pathlib import Path from ament_index_python import get_package_share_directory -import jsonschema +import fastjsonschema def test_type_hash(): @@ -25,8 +25,10 @@ def test_type_hash(): schema_path = ( Path(get_package_share_directory('rosidl_generator_type_description')) / 'resource' / 'HashedTypeDescription.schema.json') + with schema_path.open('r') as schema_file: schema = json.load(schema_file) + validator = fastjsonschema.compile(schema) generated_files_dir = Path(os.environ['GENERATED_TEST_FILE_DIR']) validated_files = 0 @@ -36,6 +38,6 @@ def test_type_hash(): assert p.suffix == '.json' with p.open('r') as f: instance = json.load(f) - jsonschema.validate(instance=instance, schema=schema) + validator(instance) validated_files += 1 assert validated_files, 'Needed to validate at least one JSON output.' diff --git a/rosidl_generator_type_description/CHANGELOG.rst b/rosidl_generator_type_description/CHANGELOG.rst index 816ea34f8..6d7b2281b 100644 --- a/rosidl_generator_type_description/CHANGELOG.rst +++ b/rosidl_generator_type_description/CHANGELOG.rst @@ -2,6 +2,23 @@ Changelog for package rosidl_generator_type_description ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +4.8.1 (2024-06-25) +------------------ + +4.8.0 (2024-06-17) +------------------ + +4.7.0 (2024-04-26) +------------------ + +4.6.0 (2024-04-16) +------------------ + +4.5.2 (2024-03-27) +------------------ +* Set hints to find the python version we actually want. (`#785 `_) +* Contributors: Chris Lalancette + 4.5.1 (2024-02-07) ------------------ * Remove unnecessary parentheses. (`#783 `_) diff --git a/rosidl_generator_type_description/package.xml b/rosidl_generator_type_description/package.xml index 4addfd4bc..fb9011e4f 100644 --- a/rosidl_generator_type_description/package.xml +++ b/rosidl_generator_type_description/package.xml @@ -2,7 +2,7 @@ rosidl_generator_type_description - 4.5.1 + 4.8.1 Generate hashes and descriptions of ROS 2 interface types, per REP-2011. Emerson Knapp diff --git a/rosidl_parser/CHANGELOG.rst b/rosidl_parser/CHANGELOG.rst index 412aa561b..9a8b9ddb5 100644 --- a/rosidl_parser/CHANGELOG.rst +++ b/rosidl_parser/CHANGELOG.rst @@ -2,6 +2,26 @@ Changelog for package rosidl_parser ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +4.8.1 (2024-06-25) +------------------ + +4.8.0 (2024-06-17) +------------------ + +4.7.0 (2024-04-26) +------------------ + +4.6.0 (2024-04-16) +------------------ +* Adding interfaces to support `@key` annotation (`#796 `_) + Co-authored-by: Mario Dominguez +* Contributors: Miguel Company + +4.5.2 (2024-03-27) +------------------ +* Small fix for newer flake8 compatibility. (`#792 `_) +* Contributors: Chris Lalancette + 4.5.1 (2024-02-07) ------------------ * Remove unnecessary parentheses. (`#783 `_) diff --git a/rosidl_parser/package.xml b/rosidl_parser/package.xml index 78a75832f..7e58fa970 100644 --- a/rosidl_parser/package.xml +++ b/rosidl_parser/package.xml @@ -2,7 +2,7 @@ rosidl_parser - 4.5.1 + 4.8.1 The parser for `.idl` ROS interface files. Aditya Pande diff --git a/rosidl_parser/rosidl_parser/definition.py b/rosidl_parser/rosidl_parser/definition.py index 1894a7165..26587b9b3 100644 --- a/rosidl_parser/rosidl_parser/definition.py +++ b/rosidl_parser/rosidl_parser/definition.py @@ -14,6 +14,7 @@ import pathlib from typing import Dict +from typing import Final from typing import Iterable from typing import List from typing import Optional @@ -21,70 +22,71 @@ from typing import Tuple from typing import Type from typing import TYPE_CHECKING +from typing import TypeVar from typing import Union # Basic types as defined by the IDL specification # 7.4.1.4.4.2 Basic Types -SIGNED_NONEXPLICIT_INTEGER_TYPES = ( # rules (26) +SIGNED_NONEXPLICIT_INTEGER_TYPES: Final = ( # rules (26) 'short', # rule (27) 'long', # rule (28) 'long long', # rule (29) ) -UNSIGNED_NONEXPLICIT_INTEGER_TYPES = ( # rules (30) +UNSIGNED_NONEXPLICIT_INTEGER_TYPES: Final = ( # rules (30) 'unsigned short', # rule (31) 'unsigned long', # rule (32) 'unsigned long long', # rule (33) ) -NONEXPLICIT_INTEGER_TYPES = ( +NONEXPLICIT_INTEGER_TYPES: Final = ( *SIGNED_NONEXPLICIT_INTEGER_TYPES, *UNSIGNED_NONEXPLICIT_INTEGER_TYPES, ) -FLOATING_POINT_TYPES = ( # rule (24) +FLOATING_POINT_TYPES: Final = ( # rule (24) 'float', 'double', 'long double', ) -CHARACTER_TYPES = ( +CHARACTER_TYPES: Final = ( 'char', # rule (34) 'wchar', # rule (35) ) -BOOLEAN_TYPE = 'boolean' # rule (36) -OCTET_TYPE = 'octet' # rule (37) +BOOLEAN_TYPE: Final = 'boolean' # rule (36) +OCTET_TYPE: Final = 'octet' # rule (37) # 7.4.13.4.4 Integers restricted to holding 8-bits of information # 7.4.13.4.5 Explicitly-named Integer Types -SIGNED_EXPLICIT_INTEGER_TYPES = ( +SIGNED_EXPLICIT_INTEGER_TYPES: Final = ( 'int8', # rule (208) 'int16', # rule (210) 'int32', # rule (211) 'int64', # rule (212) ) -UNSIGNED_EXPLICIT_INTEGER_TYPES = ( +UNSIGNED_EXPLICIT_INTEGER_TYPES: Final = ( 'uint8', # rule (209) 'uint16', # rule (213) 'uint32', # rule (214) 'uint64', # rule (215) ) -EXPLICIT_INTEGER_TYPES = ( +EXPLICIT_INTEGER_TYPES: Final = ( *SIGNED_EXPLICIT_INTEGER_TYPES, *UNSIGNED_EXPLICIT_INTEGER_TYPES, ) -SIGNED_INTEGER_TYPES = ( # rules (26) + (208) + (210-212) +SIGNED_INTEGER_TYPES: Final = ( # rules (26) + (208) + (210-212) *SIGNED_NONEXPLICIT_INTEGER_TYPES, *SIGNED_EXPLICIT_INTEGER_TYPES, ) -UNSIGNED_INTEGER_TYPES = ( # rules (30) + (209) + (213-215) +UNSIGNED_INTEGER_TYPES: Final = ( # rules (30) + (209) + (213-215) *UNSIGNED_NONEXPLICIT_INTEGER_TYPES, *UNSIGNED_EXPLICIT_INTEGER_TYPES, ) -INTEGER_TYPES = ( # rules (25) + (206-207) + (210-215) +INTEGER_TYPES: Final = ( # rules (25) + (206-207) + (210-215) *SIGNED_INTEGER_TYPES, *UNSIGNED_INTEGER_TYPES, ) """All basic types as defined by the IDL specification.""" -BASIC_TYPES = ( +BASIC_TYPES: Final = ( *INTEGER_TYPES, *FLOATING_POINT_TYPES, *CHARACTER_TYPES, @@ -93,7 +95,7 @@ ) if TYPE_CHECKING: - from typing import Literal + from typing import Literal, TypeAlias SignedNonexplicitIntegerTypeValues = Literal['short', 'long', 'long long'] UnsignedNonexplicitIntegerTypeValues = Literal['unsigned short', 'unsigned long', 'unsigned long long'] @@ -122,21 +124,21 @@ CharacterTypeValues, BooleanValue, OctetValue] -EMPTY_STRUCTURE_REQUIRED_MEMBER_NAME = 'structure_needs_at_least_one_member' +EMPTY_STRUCTURE_REQUIRED_MEMBER_NAME: Final = 'structure_needs_at_least_one_member' -CONSTANT_MODULE_SUFFIX = '_Constants' +CONSTANT_MODULE_SUFFIX: Final = '_Constants' -SERVICE_REQUEST_MESSAGE_SUFFIX = '_Request' -SERVICE_RESPONSE_MESSAGE_SUFFIX = '_Response' -SERVICE_EVENT_MESSAGE_SUFFIX = '_Event' +SERVICE_REQUEST_MESSAGE_SUFFIX: Final = '_Request' +SERVICE_RESPONSE_MESSAGE_SUFFIX: Final = '_Response' +SERVICE_EVENT_MESSAGE_SUFFIX: Final = '_Event' -ACTION_GOAL_SUFFIX = '_Goal' -ACTION_RESULT_SUFFIX = '_Result' -ACTION_FEEDBACK_SUFFIX = '_Feedback' +ACTION_GOAL_SUFFIX: Final = '_Goal' +ACTION_RESULT_SUFFIX: Final = '_Result' +ACTION_FEEDBACK_SUFFIX: Final = '_Feedback' -ACTION_GOAL_SERVICE_SUFFIX = '_SendGoal' -ACTION_RESULT_SERVICE_SUFFIX = '_GetResult' -ACTION_FEEDBACK_MESSAGE_SUFFIX = '_FeedbackMessage' +ACTION_GOAL_SERVICE_SUFFIX: Final = '_SendGoal' +ACTION_RESULT_SERVICE_SUFFIX: Final = '_GetResult' +ACTION_FEEDBACK_MESSAGE_SUFFIX: Final = '_FeedbackMessage' class AbstractType: @@ -145,7 +147,7 @@ class AbstractType: __slots__ = () def __eq__(self, other: object) -> bool: - return isinstance(other, type(self)) + return type(self) is type(other) class AbstractNestableType(AbstractType): @@ -566,6 +568,16 @@ def __init__(self, namespaced_type: NamespacedType, self.namespaced_type = namespaced_type self.members = members or [] + def has_any_member_with_annotation(self, name: str) -> bool: + """ + Check whether any member has a particular annotation. + + :param str name: the name of the annotation + :returns: True if there is at least one member with the annotation, False otherwise + """ + has_any = [member.name for member in self.members if member.has_annotation(name)] + return bool(has_any) + class Include: """An include statement.""" @@ -806,6 +818,10 @@ def get_absolute_path(self) -> pathlib.Path: return self.basepath / self.relative_path +IdlContentElement: 'TypeAlias' = Union[Include, Message, Service, Action] +IdlContentElementT = TypeVar('IdlContentElementT', bound=IdlContentElement) + + class IdlContent: """The content of an IDL file consisting of a list of elements.""" @@ -813,12 +829,12 @@ class IdlContent: def __init__(self) -> None: super().__init__() - self.elements: List[Union[Include, Message, Service, Action]] = [] + self.elements: List[IdlContentElement] = [] def get_elements_of_type( self, - type_: Type[Union[Include, Message, Service, Action]] - ) -> List[Union[Include, Message, Service, Action]]: + type_: Type[IdlContentElementT] + ) -> List[IdlContentElementT]: return [e for e in self.elements if isinstance(e, type_)] diff --git a/rosidl_parser/test/test_parser.py b/rosidl_parser/test/test_parser.py index 447655a17..b58f55721 100644 --- a/rosidl_parser/test/test_parser.py +++ b/rosidl_parser/test/test_parser.py @@ -203,16 +203,19 @@ def test_message_parser_annotations(message_idl_file): assert structure.annotations[1].value == 'SHMEM_REF' assert len(structure.members[2].annotations) == 1 + assert structure.has_any_member_with_annotation('autoid') is False assert structure.members[2].annotations[0].name == 'default' assert len(structure.members[2].annotations[0].value) == 1 assert 'value' in structure.members[2].annotations[0].value assert structure.members[2].annotations[0].value['value'] == 123 + assert structure.has_any_member_with_annotation('default') assert len(structure.members[3].annotations) == 2 assert structure.members[3].annotations[0].name == 'key' assert structure.members[3].annotations[0].value is None + assert structure.has_any_member_with_annotation('key') assert structure.members[3].annotations[1].name == 'range' assert len(structure.members[3].annotations[1].value) == 2 @@ -220,6 +223,7 @@ def test_message_parser_annotations(message_idl_file): assert structure.members[3].annotations[1].value['min'] == -10 assert 'max' in structure.members[3].annotations[1].value assert structure.members[3].annotations[1].value['max'] == 10 + assert structure.has_any_member_with_annotation('range') assert isinstance(structure.members[32].type, BasicType) assert structure.members[32].type.typename == 'float' diff --git a/rosidl_pycommon/CHANGELOG.rst b/rosidl_pycommon/CHANGELOG.rst index 55a6d9de9..73b43be89 100644 --- a/rosidl_pycommon/CHANGELOG.rst +++ b/rosidl_pycommon/CHANGELOG.rst @@ -2,6 +2,21 @@ Changelog for package rosidl_pycommon ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +4.8.1 (2024-06-25) +------------------ + +4.8.0 (2024-06-17) +------------------ + +4.7.0 (2024-04-26) +------------------ + +4.6.0 (2024-04-16) +------------------ + +4.5.2 (2024-03-27) +------------------ + 4.5.1 (2024-02-07) ------------------ * Remove unnecessary parentheses. (`#783 `_) diff --git a/rosidl_pycommon/package.xml b/rosidl_pycommon/package.xml index e47237266..9467b4a68 100644 --- a/rosidl_pycommon/package.xml +++ b/rosidl_pycommon/package.xml @@ -2,7 +2,7 @@ rosidl_pycommon - 4.5.1 + 4.8.1 Common Python functions used by rosidl packages. Aditya Pande diff --git a/rosidl_pycommon/rosidl_pycommon/__init__.py b/rosidl_pycommon/rosidl_pycommon/__init__.py index 3fecd8c72..36d887113 100644 --- a/rosidl_pycommon/rosidl_pycommon/__init__.py +++ b/rosidl_pycommon/rosidl_pycommon/__init__.py @@ -20,6 +20,13 @@ import sys import em + +try: + from em import Configuration + em_has_configuration = True +except ImportError: + em_has_configuration = False + from rosidl_parser.definition import IdlLocator from rosidl_parser.parser import parse_idl_file @@ -146,20 +153,31 @@ def expand_template( template_basepath = template_name.parent template_name = template_name.name - global interpreter - output = StringIO() - interpreter = em.Interpreter( - output=output, - options={ - em.BUFFERED_OPT: True, - em.RAW_OPT: True, - }, - ) - global template_prefix_path template_prefix_path.append(template_basepath) template_path = get_template_path(template_name) + global interpreter + output = StringIO() + if em_has_configuration: + config = Configuration( + defaultRoot=template_path, + defaultStdout=output, + deleteOnError=True, + rawErrors=True, + useProxy=True) + interpreter = em.Interpreter( + config=config, + dispatcher=False) + else: + interpreter = em.Interpreter( + output=output, + options={ + em.BUFFERED_OPT: True, + em.RAW_OPT: True, + }, + ) + # create copy before manipulating data = dict(data) _add_helper_functions(data) @@ -169,7 +187,10 @@ def expand_template( template_content = h.read() interpreter.invoke( 'beforeFile', name=template_name, file=h, locals=data) - interpreter.string(template_content, template_path, locals=data) + if em_has_configuration: + interpreter.string(template_content, locals=data) + else: + interpreter.string(template_content, template_path, locals=data) interpreter.invoke('afterFile') except Exception as e: # noqa: F841 if os.path.exists(output_file): @@ -218,7 +239,10 @@ def _expand_template(template_name, **kwargs): 'beforeInclude', name=str(template_path), file=h, locals=kwargs) content = h.read() try: - interpreter.string(content, str(template_path), kwargs) + if em_has_configuration: + interpreter.string(content, locals=kwargs) + else: + interpreter.string(content, template_path, locals=kwargs) except Exception as e: # noqa: F841 print(f"{e.__class__.__name__} in template '{template_path}': {e}", file=sys.stderr) diff --git a/rosidl_pycommon/setup.py b/rosidl_pycommon/setup.py index 39273fd06..497736123 100644 --- a/rosidl_pycommon/setup.py +++ b/rosidl_pycommon/setup.py @@ -5,7 +5,7 @@ setup( name=package_name, - version='4.5.1', + version='4.8.1', packages=find_packages(exclude=['test']), data_files=[ ('share/ament_index/resource_index/packages', diff --git a/rosidl_runtime_c/CHANGELOG.rst b/rosidl_runtime_c/CHANGELOG.rst index 086b747d4..4df7cb7de 100644 --- a/rosidl_runtime_c/CHANGELOG.rst +++ b/rosidl_runtime_c/CHANGELOG.rst @@ -2,6 +2,24 @@ Changelog for package rosidl_runtime_c ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +4.8.1 (2024-06-25) +------------------ + +4.8.0 (2024-06-17) +------------------ +* Implement `resize` function for String (`#806 `_) +* Fix u16 docs and improve docs formatting (`#805 `_) +* Contributors: Christophe Bedard, WATANABE Aoi + +4.7.0 (2024-04-26) +------------------ + +4.6.0 (2024-04-16) +------------------ + +4.5.2 (2024-03-27) +------------------ + 4.5.1 (2024-02-07) ------------------ diff --git a/rosidl_runtime_c/include/rosidl_runtime_c/action_type_support_struct.h b/rosidl_runtime_c/include/rosidl_runtime_c/action_type_support_struct.h index 62b45b036..007e098b0 100644 --- a/rosidl_runtime_c/include/rosidl_runtime_c/action_type_support_struct.h +++ b/rosidl_runtime_c/include/rosidl_runtime_c/action_type_support_struct.h @@ -38,7 +38,7 @@ typedef const rosidl_runtime_c__type_description__TypeSource__Sequence * (* rosidl_action_get_type_description_sources_function)(const rosidl_action_type_support_t *); /// Contains rosidl action type support data. -/* +/** * Actions are built based on services(goal, result and cancel) and message (feedback and status). */ struct rosidl_action_type_support_t @@ -57,7 +57,7 @@ struct rosidl_action_type_support_t }; /// Get the action type support given a provided action and package. -/* +/** * \param PkgName name of the package that contains the action * \param Name action name * \return a rosidl_action_type_support_t struct if found, otherwise NULL. diff --git a/rosidl_runtime_c/include/rosidl_runtime_c/message_type_support_struct.h b/rosidl_runtime_c/include/rosidl_runtime_c/message_type_support_struct.h index 071cac27d..6b95a97ef 100644 --- a/rosidl_runtime_c/include/rosidl_runtime_c/message_type_support_struct.h +++ b/rosidl_runtime_c/include/rosidl_runtime_c/message_type_support_struct.h @@ -89,7 +89,7 @@ const rosidl_message_type_support_t * get_message_typesupport_handle_function( const rosidl_message_type_support_t * handle, const char * identifier); /// Get the message type support given a provided action and package. -/* +/** * \param PkgName Name of the package that contains the message * \param MsgSubfolder name of the subfolder (for example: msg) * \param MsgName message name diff --git a/rosidl_runtime_c/include/rosidl_runtime_c/sequence_bound.h b/rosidl_runtime_c/include/rosidl_runtime_c/sequence_bound.h index bce6ab5d7..256337ef3 100644 --- a/rosidl_runtime_c/include/rosidl_runtime_c/sequence_bound.h +++ b/rosidl_runtime_c/include/rosidl_runtime_c/sequence_bound.h @@ -65,7 +65,7 @@ const rosidl_runtime_c__Sequence__bound * get_sequence_bound_handle_function( const rosidl_runtime_c__Sequence__bound * handle, const char * identifier); /// Get the sequence bounds given a provided action and package. -/* +/** * \param PkgName Name of the package that contains the message * \param MsgSubfolder name of the subfolder (foe example: msg) * \param MsgName message name diff --git a/rosidl_runtime_c/include/rosidl_runtime_c/service_type_support_struct.h b/rosidl_runtime_c/include/rosidl_runtime_c/service_type_support_struct.h index c6009ecd3..3088568be 100644 --- a/rosidl_runtime_c/include/rosidl_runtime_c/service_type_support_struct.h +++ b/rosidl_runtime_c/include/rosidl_runtime_c/service_type_support_struct.h @@ -137,7 +137,7 @@ const rosidl_service_type_support_t * get_service_typesupport_handle_function( const rosidl_service_type_support_t * handle, const char * identifier); /// Get the service type support given a provided action and package. -/* +/** * \param PkgName Name of the package that contains the service * \param SrvSubfolder name of the subfolder (for example: srv) * \param SrvName service name diff --git a/rosidl_runtime_c/include/rosidl_runtime_c/string_functions.h b/rosidl_runtime_c/include/rosidl_runtime_c/string_functions.h index ef553df33..6f233944e 100644 --- a/rosidl_runtime_c/include/rosidl_runtime_c/string_functions.h +++ b/rosidl_runtime_c/include/rosidl_runtime_c/string_functions.h @@ -26,7 +26,7 @@ extern "C" #endif /// Initialize a rosidl_runtime_c__String structure. -/* +/** * The contents of rosidl_runtime_c__String are initialized to a single null character ('\0'). * The string initially has size 0 and capacity 1. * Size represents the size of the contents of the string, while capacity represents the overall @@ -46,7 +46,7 @@ bool rosidl_runtime_c__String__init(rosidl_runtime_c__String * str); /// Deallocate the memory of the rosidl_runtime_c__String structure. -/* +/** * Calling the function with an already deallocated sequence is a no-op. * * \param[inout] str a pointer to a rosidl_runtime_c__String structure to be finalized @@ -86,7 +86,7 @@ rosidl_runtime_c__String__are_equal( const rosidl_runtime_c__String * lhs, const rosidl_runtime_c__String * rhs); /// Assign the c string pointer of n characters to the rosidl_runtime_c__String structure. -/* +/** * \param[inout] str a pointer to a string structure * \param[in] value c string pointer to be assigned * \param[in] n size of the value string @@ -100,8 +100,7 @@ rosidl_runtime_c__String__assignn( rosidl_runtime_c__String * str, const char * value, size_t n); /// Assign the c string pointer to the rosidl_runtime_c__String structure. -/* - * +/** * This function is identical to rosidl_runtime_c__String__assignn() except the length of the * c string does not have to be given and therefore the c string must be null terminated. * @@ -118,8 +117,22 @@ bool rosidl_runtime_c__String__assign( rosidl_runtime_c__String * str, const char * value); +/// Resize the char pointer. +/** + * This function resize the input value pointer. + * + * \param[inout] str a pointer to a rosidl_runtime_c__String structure + * \param[in] n the new size of the internal buffer + * \return true if successful, false if the passed string pointer is null + * or if the size is higher than SIZE_MAX or if the memory reallocation failed. + */ +ROSIDL_GENERATOR_C_PUBLIC +bool +rosidl_runtime_c__String__resize( + rosidl_runtime_c__String * str, size_t n); + /// Initialize a rosidl_runtime_c__String__Sequence__init structure. -/* +/** * The rosidl_runtime_c__String__Sequence is initialized with the size passed to the function. * The rosidl_runtime_c__String__Sequence structure should be deallocated using the given function * rosidl_runtime_c__String__Sequence__fini() when it is no longer needed. @@ -137,7 +150,7 @@ rosidl_runtime_c__String__Sequence__init( rosidl_runtime_c__String__Sequence * sequence, size_t size); /// Deallocate the memory of the string sequence structure. -/* +/** * Calling the function with an already deallocated sequence is a no-op. * * \param[inout] sequence a pointer to a string sequence to be finalized @@ -179,7 +192,7 @@ rosidl_runtime_c__String__Sequence__copy( rosidl_runtime_c__String__Sequence * output); /// Create a rosidl_runtime_c__String__Sequence structure with a specific size. -/* +/** * The string sequence initially has size and capacity equal to the size argument passed to the * function. * The rosidl_runtime_c__String__Sequence structure should be deallocated using the given function @@ -193,7 +206,7 @@ rosidl_runtime_c__String__Sequence * rosidl_runtime_c__String__Sequence__create(size_t size); /// Destroy a rosidl_runtime_c__String__Sequence structure. -/* +/** * Calling the function with an already deallocated sequence is a no-op. * * \param[inout] sequence a pointer to a string sequence to be finalized diff --git a/rosidl_runtime_c/include/rosidl_runtime_c/u16string_functions.h b/rosidl_runtime_c/include/rosidl_runtime_c/u16string_functions.h index c89afabfc..90a886ba1 100644 --- a/rosidl_runtime_c/include/rosidl_runtime_c/u16string_functions.h +++ b/rosidl_runtime_c/include/rosidl_runtime_c/u16string_functions.h @@ -26,7 +26,8 @@ extern "C" #endif /// Initialize a rosidl_runtime_c__U16String structure. -/* The contents of rosidl_runtime_c__U16String are initialized to a single null character. +/** + * The contents of rosidl_runtime_c__U16String are initialized to a single null character. * The string initially has size 0 and capacity 1. * Size represents the size of the contents of the string, while capacity represents the overall * storage of the string (counting the null terminator). @@ -45,7 +46,7 @@ bool rosidl_runtime_c__U16String__init(rosidl_runtime_c__U16String * str); /// Deallocate the memory of the rosidl_runtime_c__U16String structure. -/* +/** * Calling the function with an already deallocated sequence is a no-op. * * \param[inout] str a pointer to a U16 string structure to be finalized @@ -86,7 +87,7 @@ rosidl_runtime_c__U16String__copy( rosidl_runtime_c__U16String * output); /// Assign the uint16_t value of n characters to the rosidl_runtime_c__U16String structure. -/* +/** * This function returns `false` if memory cannot be allocated, * if the input uint16_t pointer is null or if the size is higher than SIZE_MAX. * In both cases no error message is set. @@ -104,17 +105,18 @@ rosidl_runtime_c__U16String__assignn( rosidl_runtime_c__U16String * str, const uint16_t * value, size_t n); /// Assign the c string pointer value of n characters to the rosidl_runtime_c__U16String structure. -/* +/** * This function is identical to rosidl_runtime_c__U16String__assignn() except the type of the - * value is c string pointer + * value is a c string pointer. * * \see rosidl_runtime_c__U16String__assignn() * * \param[inout] str a pointer to a U16 string structure - * \param[in] value points to a sequence of 16 bit chars - * \param[in] n size of the value string + * \param[in] value c string pointer to be assigned + * \param[in] n size of the value string as the number of 8 bit chars * \return true if successful, false if the passed string pointer is null - * or if the passed value pointer is null or if the size is higher than SIZE_MAX + * or if the passed value pointer is null + * or if the size is not even or is higher than SIZE_MAX * or if the memory reallocation failed. */ ROSIDL_GENERATOR_C_PUBLIC @@ -123,7 +125,7 @@ rosidl_runtime_c__U16String__assignn_from_char( rosidl_runtime_c__U16String * str, const char * value, size_t n); /// Assign the uint16_t pointer to the rosidl_runtime_c__U16String structure. -/* +/** * This function is identical to rosidl_runtime_c__U16String__assignn() except the length of the * uint16_t does not have to be given. * rosidl_runtime_c__U16String__len() is being used to determine the length of the passed string. @@ -142,7 +144,7 @@ rosidl_runtime_c__U16String__assign( rosidl_runtime_c__U16String * str, const uint16_t * value); /// Get the length of the uint16_t pointer. -/* +/** * This function returns the length of the input value pointer. * * \param[in] value points to a sequence of 16 bit chars for which the first null char is @@ -154,7 +156,7 @@ size_t rosidl_runtime_c__U16String__len(const uint16_t * value); /// Resize the uint16_t pointer. -/* +/** * This function resize the input value pointer. * * \param[in] n the new size of the internal buffer @@ -167,7 +169,7 @@ rosidl_runtime_c__U16String__resize( rosidl_runtime_c__U16String * str, size_t n); /// Initialize a U16 string sequence structure. -/* +/** * The rosidl_runtime_c__U16String__Sequence is initialized to the size passed to the function. * The U16 string sequence structure should be deallocated using the given * function rosidl_runtime_c__U16String__Sequence__fini() when it is no longer needed. @@ -175,7 +177,7 @@ rosidl_runtime_c__U16String__resize( * memory. * * \param[inout] sequence a pointer to a U16 string sequence structure - * \param[in] size represents the size of the U16 string + * \param[in] size represents the size of the U16 string sequence * \return true if successful, false if the passed string pointer is null * or the memory allocation failed */ @@ -185,7 +187,7 @@ rosidl_runtime_c__U16String__Sequence__init( rosidl_runtime_c__U16String__Sequence * sequence, size_t size); /// Deallocate the memory of the string sequence structure. -/* +/** * Calling the function with an already deallocated sequence is a no-op. * * \param[inout] sequence a pointer to a U16 string to be finalized @@ -227,13 +229,13 @@ rosidl_runtime_c__U16String__Sequence__copy( rosidl_runtime_c__U16String__Sequence * output); /// Create a U16 string sequence structure with a specific size. -/* +/** * The U16 string sequence initially has size and capacity equal to the size * argument. * The U16 string sequence structure should be deallocated using the given * function rosidl_runtime_c__U16String__Sequence__destroy() when it is no longer needed. * - * \param[in] size of the desired U16 string + * \param[in] size of the desired U16 string sequence * \return a U16 string sequence if initialization was successfully, otherwise NULL. */ ROSIDL_GENERATOR_C_PUBLIC @@ -241,7 +243,7 @@ rosidl_runtime_c__U16String__Sequence * rosidl_runtime_c__U16String__Sequence__create(size_t size); /// Destroy a U16 string sequence structure. -/* +/** * Calling the function with an already deallocated sequence is a no-op. * * \param[inout] sequence a pointer to a U16 string sequence to be finalized diff --git a/rosidl_runtime_c/package.xml b/rosidl_runtime_c/package.xml index 61ac9a30e..5e98e7cb7 100644 --- a/rosidl_runtime_c/package.xml +++ b/rosidl_runtime_c/package.xml @@ -2,7 +2,7 @@ rosidl_runtime_c - 4.5.1 + 4.8.1 Provides definitions, initialization and finalization functions, and macros for getting and working with rosidl typesupport types in C. Aditya Pande diff --git a/rosidl_runtime_c/src/string_functions.c b/rosidl_runtime_c/src/string_functions.c index ed44e6413..9bb6c60de 100644 --- a/rosidl_runtime_c/src/string_functions.c +++ b/rosidl_runtime_c/src/string_functions.c @@ -143,6 +143,29 @@ rosidl_runtime_c__String__copy( output, input->data, input->size); } +bool +rosidl_runtime_c__String__resize( + rosidl_runtime_c__String *str, size_t n) +{ + if(!str) { + return false; + } + // check valid range of n before allocating n + 1 characters + if(n > SIZE_MAX / sizeof(char) - 1) { + return false; + } + rcutils_allocator_t allocator = rcutils_get_default_allocator(); + char * data = allocator.reallocate(str->data, (n + 1) * sizeof(char), allocator.state); + if(!data) { + return false; + } + data[n] = 0; + str->data = data; + str->size = n; + str->capacity = n + 1; + return true; +} + bool rosidl_runtime_c__String__Sequence__init( rosidl_runtime_c__String__Sequence * sequence, size_t size) diff --git a/rosidl_runtime_c/test/test_string_functions.cpp b/rosidl_runtime_c/test/test_string_functions.cpp index f3da91c58..0065c8dea 100644 --- a/rosidl_runtime_c/test/test_string_functions.cpp +++ b/rosidl_runtime_c/test/test_string_functions.cpp @@ -78,6 +78,18 @@ TEST(string_functions, resize_assignn) { EXPECT_TRUE(rosidl_runtime_c__String__init(&s)); EXPECT_TRUE(rosidl_runtime_c__String__init(&t)); + EXPECT_FALSE(rosidl_runtime_c__String__resize(nullptr, s_size)); + + // If you're here because this test crashed your computer, it might be because it just tried + // to allocate SIZE_MAX * 2 bytes, which means someone removed an important check. + EXPECT_FALSE(rosidl_runtime_c__String__resize(nullptr, SIZE_MAX * 2)); + + EXPECT_TRUE(rosidl_runtime_c__String__resize(&s, s_size)); + EXPECT_EQ(s.size, s_size); + EXPECT_EQ(s.capacity, s_size + 1u); + EXPECT_NE(s.data, nullptr); + EXPECT_EQ(s.data[s_size], 0); + EXPECT_FALSE(rosidl_runtime_c__String__assign(nullptr, nullptr)); EXPECT_FALSE(rosidl_runtime_c__String__assignn(nullptr, nullptr, 0)); EXPECT_FALSE(rosidl_runtime_c__String__assignn(&s, nullptr, 0)); diff --git a/rosidl_runtime_cpp/CHANGELOG.rst b/rosidl_runtime_cpp/CHANGELOG.rst index 98024798a..3d39ce7c2 100644 --- a/rosidl_runtime_cpp/CHANGELOG.rst +++ b/rosidl_runtime_cpp/CHANGELOG.rst @@ -2,6 +2,30 @@ Changelog for package rosidl_runtime_cpp ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +4.8.1 (2024-06-25) +------------------ + +4.8.0 (2024-06-17) +------------------ +* Suppress warnings in the benchmarks for upstream GCC false positives. (`#810 `_) +* Contributors: Chris Lalancette + +4.7.0 (2024-04-26) +------------------ +* Global use of nodiscard (`#801 `_) + * Global use of nodiscard +* Suppress a warning around BoundedVector. (`#803 `_) + The comment has more explanation, but in short GCC 13 + has false positives around some warnings, so we suppress + it for BoundedVector. +* Contributors: Chris Lalancette, Lucas Wendland + +4.6.0 (2024-04-16) +------------------ + +4.5.2 (2024-03-27) +------------------ + 4.5.1 (2024-02-07) ------------------ diff --git a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/action_type_support_decl.hpp b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/action_type_support_decl.hpp index 193567855..11c8d98d7 100644 --- a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/action_type_support_decl.hpp +++ b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/action_type_support_decl.hpp @@ -27,6 +27,7 @@ namespace rosidl_runtime_cpp * \return Function handler for the action's typesupport. */ template +[[nodiscard]] const rosidl_action_type_support_t * get_action_type_support_handle(); } // namespace rosidl_runtime_cpp diff --git a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/bounded_vector.hpp b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/bounded_vector.hpp index f2fa3c0b5..fefcb290e 100644 --- a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/bounded_vector.hpp +++ b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/bounded_vector.hpp @@ -21,6 +21,16 @@ #include #include +// GCC 13 has false positive warnings around stringop-overflow and array-bounds. +// The layout of a BoundedVector triggers these warnings. Suppress them +// until this is fixed in upstream gcc. See +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114758 for more details. +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#pragma GCC diagnostic ignored "-Warray-bounds" +#endif + namespace rosidl_runtime_cpp { @@ -714,6 +724,7 @@ class BoundedVector * \param y A %BoundedVector of the same type as @a x * \return True if the size and elements of the vectors are equal */ + [[nodiscard]] friend bool operator==( const BoundedVector & x, @@ -734,6 +745,7 @@ class BoundedVector * \param y A %BoundedVector of the same type as @a x * @return True if @a x is lexicographically less than @a y */ + [[nodiscard]] friend bool operator<( const BoundedVector & x, @@ -743,6 +755,7 @@ class BoundedVector } /// Based on operator== + [[nodiscard]] friend bool operator!=( const BoundedVector & x, @@ -752,6 +765,7 @@ class BoundedVector } /// Based on operator< + [[nodiscard]] friend bool operator>( const BoundedVector & x, @@ -761,6 +775,7 @@ class BoundedVector } /// Based on operator< + [[nodiscard]] friend bool operator<=( const BoundedVector & x, @@ -770,6 +785,7 @@ class BoundedVector } /// Based on operator< + [[nodiscard]] friend bool operator>=( const BoundedVector & x, @@ -789,4 +805,8 @@ swap(BoundedVector & x, BoundedVector +[[nodiscard]] const rosidl_message_type_support_t * get_message_type_support_handle(); } // namespace rosidl_runtime_cpp diff --git a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/service_type_support_decl.hpp b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/service_type_support_decl.hpp index 80eeb79fd..0f024bb6c 100644 --- a/rosidl_runtime_cpp/include/rosidl_runtime_cpp/service_type_support_decl.hpp +++ b/rosidl_runtime_cpp/include/rosidl_runtime_cpp/service_type_support_decl.hpp @@ -27,6 +27,7 @@ namespace rosidl_runtime_cpp * \return Function handler for the service's typesupport. */ template +[[nodiscard]] const rosidl_service_type_support_t * get_service_type_support_handle(); } // namespace rosidl_runtime_cpp diff --git a/rosidl_runtime_cpp/include/rosidl_typesupport_cpp/action_type_support.hpp b/rosidl_runtime_cpp/include/rosidl_typesupport_cpp/action_type_support.hpp index e0befe2bc..2d0171a73 100644 --- a/rosidl_runtime_cpp/include/rosidl_typesupport_cpp/action_type_support.hpp +++ b/rosidl_runtime_cpp/include/rosidl_typesupport_cpp/action_type_support.hpp @@ -22,6 +22,7 @@ namespace rosidl_typesupport_cpp { template +[[nodiscard]] const rosidl_action_type_support_t * get_action_type_support_handle(); } // namespace rosidl_typesupport_cpp diff --git a/rosidl_runtime_cpp/include/rosidl_typesupport_cpp/message_type_support.hpp b/rosidl_runtime_cpp/include/rosidl_typesupport_cpp/message_type_support.hpp index 6fad1d7d5..af0064efd 100644 --- a/rosidl_runtime_cpp/include/rosidl_typesupport_cpp/message_type_support.hpp +++ b/rosidl_runtime_cpp/include/rosidl_typesupport_cpp/message_type_support.hpp @@ -22,6 +22,7 @@ namespace rosidl_typesupport_cpp { template +[[nodiscard]] const rosidl_message_type_support_t * get_message_type_support_handle(); } // namespace rosidl_typesupport_cpp diff --git a/rosidl_runtime_cpp/include/rosidl_typesupport_cpp/service_type_support.hpp b/rosidl_runtime_cpp/include/rosidl_typesupport_cpp/service_type_support.hpp index 2931b8736..23b3e8a45 100644 --- a/rosidl_runtime_cpp/include/rosidl_typesupport_cpp/service_type_support.hpp +++ b/rosidl_runtime_cpp/include/rosidl_typesupport_cpp/service_type_support.hpp @@ -25,6 +25,7 @@ namespace rosidl_typesupport_cpp { template +[[nodiscard]] const rosidl_service_type_support_t * get_service_type_support_handle(); template diff --git a/rosidl_runtime_cpp/package.xml b/rosidl_runtime_cpp/package.xml index e6365c7f1..9ffec3c73 100644 --- a/rosidl_runtime_cpp/package.xml +++ b/rosidl_runtime_cpp/package.xml @@ -2,7 +2,7 @@ rosidl_runtime_cpp - 4.5.1 + 4.8.1 Provides definitions and templated functions for getting and working with rosidl typesupport types in C++. Aditya Pande diff --git a/rosidl_runtime_cpp/test/benchmark/benchmark_bounded_vector.cpp b/rosidl_runtime_cpp/test/benchmark/benchmark_bounded_vector.cpp index 97942f701..b578aef08 100644 --- a/rosidl_runtime_cpp/test/benchmark/benchmark_bounded_vector.cpp +++ b/rosidl_runtime_cpp/test/benchmark/benchmark_bounded_vector.cpp @@ -67,7 +67,18 @@ BENCHMARK_F(PerformanceTest, bounded_vector_insert)(benchmark::State & st) for (auto _ : st) { (void)_; v.insert(v.begin(), v2.begin(), v2.end()); +// GCC 13 has false positive warnings around stringop-overflow and array-bounds. +// Suppress them until this is fixed in upstream gcc. See +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114758 for more details. +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#pragma GCC diagnostic ignored "-Warray-bounds" +#endif v.erase(v.begin()); +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif } } diff --git a/rosidl_typesupport_interface/CHANGELOG.rst b/rosidl_typesupport_interface/CHANGELOG.rst index cdf2f2f94..be0a79f07 100644 --- a/rosidl_typesupport_interface/CHANGELOG.rst +++ b/rosidl_typesupport_interface/CHANGELOG.rst @@ -2,6 +2,21 @@ Changelog for package rosidl_typesupport_interface ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +4.8.1 (2024-06-25) +------------------ + +4.8.0 (2024-06-17) +------------------ + +4.7.0 (2024-04-26) +------------------ + +4.6.0 (2024-04-16) +------------------ + +4.5.2 (2024-03-27) +------------------ + 4.5.1 (2024-02-07) ------------------ diff --git a/rosidl_typesupport_interface/package.xml b/rosidl_typesupport_interface/package.xml index 1cced6f6a..0688a1dd3 100644 --- a/rosidl_typesupport_interface/package.xml +++ b/rosidl_typesupport_interface/package.xml @@ -2,7 +2,7 @@ rosidl_typesupport_interface - 4.5.1 + 4.8.1 The interface for rosidl typesupport packages. diff --git a/rosidl_typesupport_introspection_c/CHANGELOG.rst b/rosidl_typesupport_introspection_c/CHANGELOG.rst index 13286edef..64e922eda 100644 --- a/rosidl_typesupport_introspection_c/CHANGELOG.rst +++ b/rosidl_typesupport_introspection_c/CHANGELOG.rst @@ -2,6 +2,28 @@ Changelog for package rosidl_typesupport_introspection_c ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +4.8.1 (2024-06-25) +------------------ + +4.8.0 (2024-06-17) +------------------ + +4.7.0 (2024-04-26) +------------------ +* Fixed warnings - strict-prototypes (`#800 `_) +* Contributors: Alejandro Hernández Cordero + +4.6.0 (2024-04-16) +------------------ +* Adding interfaces to support `@key` annotation (`#796 `_) + Co-authored-by: Mario Dominguez +* Contributors: Miguel Company + +4.5.2 (2024-03-27) +------------------ +* Set hints to find the python version we actually want. (`#785 `_) +* Contributors: Chris Lalancette + 4.5.1 (2024-02-07) ------------------ diff --git a/rosidl_typesupport_introspection_c/include/rosidl_typesupport_introspection_c/message_introspection.h b/rosidl_typesupport_introspection_c/include/rosidl_typesupport_introspection_c/message_introspection.h index 0d16e5923..63f3467d4 100644 --- a/rosidl_typesupport_introspection_c/include/rosidl_typesupport_introspection_c/message_introspection.h +++ b/rosidl_typesupport_introspection_c/include/rosidl_typesupport_introspection_c/message_introspection.h @@ -39,6 +39,8 @@ typedef struct rosidl_typesupport_introspection_c__MessageMember_s /// If the type_id_ value is rosidl_typesupport_introspection_c__ROS_TYPE_MESSAGE, /// this points to an array describing the fields of the sub-interface. const rosidl_message_type_support_t * members_; + /// True if this field is annotated as `@key`, false otherwise. + bool is_key_; /// True if this field is an array type, false if it is any other type. An /// array has the same value for / type_id_. bool is_array_; @@ -90,6 +92,8 @@ typedef struct rosidl_typesupport_introspection_c__MessageMembers_s uint32_t member_count_; /// The size of the interface structure in memory size_t size_of_; + /// A boolean value indicating if there are any members annotated as `@key` in the structure. + bool has_any_key_member_; /// A pointer to the array that describes each field of the interface const rosidl_typesupport_introspection_c__MessageMember * members_; /// The function used to initialise the interface's in-memory representation diff --git a/rosidl_typesupport_introspection_c/package.xml b/rosidl_typesupport_introspection_c/package.xml index 67c5dc8b1..1144c00c5 100644 --- a/rosidl_typesupport_introspection_c/package.xml +++ b/rosidl_typesupport_introspection_c/package.xml @@ -2,7 +2,7 @@ rosidl_typesupport_introspection_c - 4.5.1 + 4.8.1 Generate the message type support for dynamic message construction in C. diff --git a/rosidl_typesupport_introspection_c/resource/msg__type_support.c.em b/rosidl_typesupport_introspection_c/resource/msg__type_support.c.em index de392983f..19b00ebef 100644 --- a/rosidl_typesupport_introspection_c/resource/msg__type_support.c.em +++ b/rosidl_typesupport_introspection_c/resource/msg__type_support.c.em @@ -238,6 +238,8 @@ for index, member in enumerate(message.structure.members): print(' 0, // upper bound of string') # const rosidl_message_type_support_t * members_ print(' NULL, // members of sub message (initialized later)') + # bool is_key_ + print(' %s, // is key' % ('true' if member.has_annotation('key') else 'false')) # bool is_array_ print(' %s, // is array' % ('true' if isinstance(member.type, AbstractNestedType) else 'false')) # size_t array_size_ @@ -276,6 +278,11 @@ static const rosidl_typesupport_introspection_c__MessageMembers @(function_prefi "@(message.structure.namespaced_type.name)", // message name @(len(message.structure.members)), // number of fields sizeof(@('__'.join([package_name] + list(interface_path.parents[0].parts) + [message.structure.namespaced_type.name]))), +@[ if message.structure.has_any_member_with_annotation('key') ]@ + true, // has_any_key_member_ +@[ else]@ + false, // has_any_key_member_ +@[ end if]@ @(function_prefix)__@(message.structure.namespaced_type.name)_message_member_array, // message members @(function_prefix)__@(message.structure.namespaced_type.name)_init_function, // function to initialize message memory (memory has to be allocated) @(function_prefix)__@(message.structure.namespaced_type.name)_fini_function // function to terminate message instance (will not free memory) diff --git a/rosidl_typesupport_introspection_c/resource/srv__type_support.c.em b/rosidl_typesupport_introspection_c/resource/srv__type_support.c.em index ee71830f2..d218f670d 100644 --- a/rosidl_typesupport_introspection_c/resource/srv__type_support.c.em +++ b/rosidl_typesupport_introspection_c/resource/srv__type_support.c.em @@ -96,17 +96,17 @@ static rosidl_service_type_support_t @(function_prefix)__@(service.namespaced_ty // Forward declaration of message type support functions for service members const rosidl_message_type_support_t * -ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_introspection_c, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name + SERVICE_REQUEST_MESSAGE_SUFFIX))(); +ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_introspection_c, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name + SERVICE_REQUEST_MESSAGE_SUFFIX))(void); const rosidl_message_type_support_t * -ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_introspection_c, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name + SERVICE_RESPONSE_MESSAGE_SUFFIX))(); +ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_introspection_c, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name + SERVICE_RESPONSE_MESSAGE_SUFFIX))(void); const rosidl_message_type_support_t * -ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_introspection_c, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name + SERVICE_EVENT_MESSAGE_SUFFIX))(); +ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_introspection_c, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name + SERVICE_EVENT_MESSAGE_SUFFIX))(void); ROSIDL_TYPESUPPORT_INTROSPECTION_C_EXPORT_@(package_name) const rosidl_service_type_support_t * -ROSIDL_TYPESUPPORT_INTERFACE__SERVICE_SYMBOL_NAME(rosidl_typesupport_introspection_c, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name))() { +ROSIDL_TYPESUPPORT_INTERFACE__SERVICE_SYMBOL_NAME(rosidl_typesupport_introspection_c, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name))(void) { if (!@(function_prefix)__@(service.namespaced_type.name)_service_type_support_handle.typesupport_identifier) { @(function_prefix)__@(service.namespaced_type.name)_service_type_support_handle.typesupport_identifier = rosidl_typesupport_introspection_c__identifier; diff --git a/rosidl_typesupport_introspection_cpp/CHANGELOG.rst b/rosidl_typesupport_introspection_cpp/CHANGELOG.rst index 285950414..65b070472 100644 --- a/rosidl_typesupport_introspection_cpp/CHANGELOG.rst +++ b/rosidl_typesupport_introspection_cpp/CHANGELOG.rst @@ -2,6 +2,29 @@ Changelog for package rosidl_typesupport_introspection_cpp ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +4.8.1 (2024-06-25) +------------------ + +4.8.0 (2024-06-17) +------------------ + +4.7.0 (2024-04-26) +------------------ +* Global use of nodiscard (`#801 `_) + * Global use of nodiscard +* Contributors: Lucas Wendland + +4.6.0 (2024-04-16) +------------------ +* Adding interfaces to support `@key` annotation (`#796 `_) + Co-authored-by: Mario Dominguez +* Contributors: Miguel Company + +4.5.2 (2024-03-27) +------------------ +* Set hints to find the python version we actually want. (`#785 `_) +* Contributors: Chris Lalancette + 4.5.1 (2024-02-07) ------------------ diff --git a/rosidl_typesupport_introspection_cpp/include/rosidl_typesupport_introspection_cpp/message_introspection.hpp b/rosidl_typesupport_introspection_cpp/include/rosidl_typesupport_introspection_cpp/message_introspection.hpp index 6c01c2ce8..e89d2de30 100644 --- a/rosidl_typesupport_introspection_cpp/include/rosidl_typesupport_introspection_cpp/message_introspection.hpp +++ b/rosidl_typesupport_introspection_cpp/include/rosidl_typesupport_introspection_cpp/message_introspection.hpp @@ -41,6 +41,8 @@ typedef struct ROSIDL_TYPESUPPORT_INTROSPECTION_CPP_PUBLIC MessageMember_s /// If the type_id_ value is rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE /// this points to an array describing the fields of the sub-interface. const rosidl_message_type_support_t * members_; + /// True if this field is annotated as `@key`, false otherwise. + bool is_key_; /// True if this field is an array, false if it is a unary type. An array has the same value for /// type_id_. bool is_array_; @@ -97,6 +99,8 @@ typedef struct ROSIDL_TYPESUPPORT_INTROSPECTION_CPP_PUBLIC MessageMembers_s uint32_t member_count_; /// The size of the interface structure in memory size_t size_of_; + /// A boolean value indicating if there are any members annotated as `@key` in the structure. + bool has_any_key_member_; /// A pointer to the array that describes each field of the interface const MessageMember * members_; /// The function used to initialise the interface's in-memory representation diff --git a/rosidl_typesupport_introspection_cpp/include/rosidl_typesupport_introspection_cpp/message_type_support_decl.hpp b/rosidl_typesupport_introspection_cpp/include/rosidl_typesupport_introspection_cpp/message_type_support_decl.hpp index 97eece341..3666c49dd 100644 --- a/rosidl_typesupport_introspection_cpp/include/rosidl_typesupport_introspection_cpp/message_type_support_decl.hpp +++ b/rosidl_typesupport_introspection_cpp/include/rosidl_typesupport_introspection_cpp/message_type_support_decl.hpp @@ -28,6 +28,7 @@ namespace rosidl_typesupport_introspection_cpp /// the rosidl_generate_interfaces() macro. /// This is implemented in the shared library provided by this package. template +[[nodiscard]] ROSIDL_TYPESUPPORT_INTROSPECTION_CPP_PUBLIC const rosidl_message_type_support_t * get_message_type_support_handle(); diff --git a/rosidl_typesupport_introspection_cpp/include/rosidl_typesupport_introspection_cpp/service_type_support_decl.hpp b/rosidl_typesupport_introspection_cpp/include/rosidl_typesupport_introspection_cpp/service_type_support_decl.hpp index eaa3db906..bcc6ac858 100644 --- a/rosidl_typesupport_introspection_cpp/include/rosidl_typesupport_introspection_cpp/service_type_support_decl.hpp +++ b/rosidl_typesupport_introspection_cpp/include/rosidl_typesupport_introspection_cpp/service_type_support_decl.hpp @@ -27,6 +27,7 @@ namespace rosidl_typesupport_introspection_cpp /// services. /// This is implemented in the shared library provided by this package. template +[[nodiscard]] ROSIDL_TYPESUPPORT_INTROSPECTION_CPP_PUBLIC const rosidl_service_type_support_t * get_service_type_support_handle(); diff --git a/rosidl_typesupport_introspection_cpp/package.xml b/rosidl_typesupport_introspection_cpp/package.xml index 16f79eceb..d5f09d731 100644 --- a/rosidl_typesupport_introspection_cpp/package.xml +++ b/rosidl_typesupport_introspection_cpp/package.xml @@ -2,7 +2,7 @@ rosidl_typesupport_introspection_cpp - 4.5.1 + 4.8.1 Generate the message type support for dynamic message construction in C++. diff --git a/rosidl_typesupport_introspection_cpp/resource/msg__type_support.cpp.em b/rosidl_typesupport_introspection_cpp/resource/msg__type_support.cpp.em index 679907386..392fc8394 100644 --- a/rosidl_typesupport_introspection_cpp/resource/msg__type_support.cpp.em +++ b/rosidl_typesupport_introspection_cpp/resource/msg__type_support.cpp.em @@ -204,6 +204,8 @@ for index, member in enumerate(message.structure.members): print(' 0, // upper bound of string') # const rosidl_message_type_support_t * members_ print(' ::rosidl_typesupport_introspection_cpp::get_message_type_support_handle<%s>(), // members of sub message' % '::'.join(type_.namespaced_name())) + # bool is_key_ + print(' %s, // is key' % ('true' if member.has_annotation('key') else 'false')) # bool is_array_ print(' %s, // is array' % ('true' if isinstance(member.type, AbstractNestedType) else 'false')) # size_t array_size_ @@ -242,6 +244,11 @@ static const ::rosidl_typesupport_introspection_cpp::MessageMembers @(message.st "@(message.structure.namespaced_type.name)", // message name @(len(message.structure.members)), // number of fields sizeof(@('::'.join([package_name] + list(interface_path.parents[0].parts) + [message.structure.namespaced_type.name]))), +@[ if message.structure.has_any_member_with_annotation('key') ]@ + true, // has_any_key_member_ +@[ else]@ + false, // has_any_key_member_ +@[ end if]@ @(message.structure.namespaced_type.name)_message_member_array, // message members @(message.structure.namespaced_type.name)_init_function, // function to initialize message memory (memory has to be allocated) @(message.structure.namespaced_type.name)_fini_function // function to terminate message instance (will not free memory) diff --git a/rosidl_typesupport_introspection_tests/CHANGELOG.rst b/rosidl_typesupport_introspection_tests/CHANGELOG.rst index c3b8525fb..d74bc9286 100644 --- a/rosidl_typesupport_introspection_tests/CHANGELOG.rst +++ b/rosidl_typesupport_introspection_tests/CHANGELOG.rst @@ -2,6 +2,25 @@ Changelog for package rosidl_typesupport_introspection_tests ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +4.8.1 (2024-06-25) +------------------ + +4.8.0 (2024-06-17) +------------------ +* Suppress false positive warnings from gcc. (`#811 `_) +* Contributors: Chris Lalancette + +4.7.0 (2024-04-26) +------------------ + +4.6.0 (2024-04-16) +------------------ +* One last uncrustify fix for newer uncrustify. (`#795 `_) +* Contributors: Chris Lalancette + +4.5.2 (2024-03-27) +------------------ + 4.5.1 (2024-02-07) ------------------ diff --git a/rosidl_typesupport_introspection_tests/include/rosidl_typesupport_introspection_tests/helpers.hpp b/rosidl_typesupport_introspection_tests/include/rosidl_typesupport_introspection_tests/helpers.hpp index a2ecbc7ef..79d3762ed 100644 --- a/rosidl_typesupport_introspection_tests/include/rosidl_typesupport_introspection_tests/helpers.hpp +++ b/rosidl_typesupport_introspection_tests/include/rosidl_typesupport_introspection_tests/helpers.hpp @@ -186,6 +186,8 @@ getitem(const std::array & array, const size_t index) DEFINE_CXX_API_FOR_C_MESSAGE_SEQUENCE_MEMBER( \ RCUTILS_JOIN(C_INTERFACE_NAME(package_name, interface_type, message_name), __Sequence)) +// *INDENT-OFF* + /// Defines C++ helper API for a C service. #define DEFINE_CXX_API_FOR_C_SERVICE(package_name, interface_type, service_name) \ DEFINE_CXX_API_FOR_C_MESSAGE_MEMBER( \ @@ -201,6 +203,8 @@ getitem(const std::array & array, const size_t index) C_INTERFACE_NAME(package_name, interface_type, RCUTILS_JOIN(service_name, _Response)); \ }; +// *INDENT-ON* + // Extra C++ APIs to homogeneize access to rosidl_runtime_c primitives DEFINE_CXX_API_FOR_C_MESSAGE_MEMBER(rosidl_runtime_c__String) DEFINE_CXX_API_FOR_C_MESSAGE_MEMBER(rosidl_runtime_c__U16String) diff --git a/rosidl_typesupport_introspection_tests/package.xml b/rosidl_typesupport_introspection_tests/package.xml index 955d2c556..68e836738 100644 --- a/rosidl_typesupport_introspection_tests/package.xml +++ b/rosidl_typesupport_introspection_tests/package.xml @@ -2,7 +2,7 @@ rosidl_typesupport_introspection_tests - 4.5.1 + 4.8.1 Integration tests of the rosidl_typesupport_introspection_c/cpp packages. Aditya Pande diff --git a/rosidl_typesupport_introspection_tests/test/introspection_libraries_under_test.hpp b/rosidl_typesupport_introspection_tests/test/introspection_libraries_under_test.hpp index fbc755fb0..77b0e3a8c 100644 --- a/rosidl_typesupport_introspection_tests/test/introspection_libraries_under_test.hpp +++ b/rosidl_typesupport_introspection_tests/test/introspection_libraries_under_test.hpp @@ -47,15 +47,29 @@ #include "rosidl_typesupport_introspection_tests/msg/constants.hpp" #include "rosidl_typesupport_introspection_tests/msg/defaults.hpp" #include "rosidl_typesupport_introspection_tests/msg/empty.hpp" -#include "rosidl_typesupport_introspection_tests/msg/multi_nested.hpp" #include "rosidl_typesupport_introspection_tests/msg/nested.hpp" #include "rosidl_typesupport_introspection_tests/msg/strings.hpp" #include "rosidl_typesupport_introspection_tests/msg/w_strings.hpp" -#include "rosidl_typesupport_introspection_tests/msg/unbounded_sequences.hpp" #include "rosidl_typesupport_introspection_tests/srv/arrays.hpp" #include "rosidl_typesupport_introspection_tests/srv/basic_types.hpp" #include "rosidl_typesupport_introspection_tests/srv/empty.hpp" +// GCC 13 has false positive warnings around stringop-overflow and array-bounds. +// Suppress them until this is fixed in upstream gcc. See +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114758 for more details. +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#pragma GCC diagnostic ignored "-Warray-bounds" +#endif + +#include "rosidl_typesupport_introspection_tests/msg/multi_nested.hpp" +#include "rosidl_typesupport_introspection_tests/msg/unbounded_sequences.hpp" + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif + #include "rosidl_typesupport_introspection_tests/fixtures.hpp" #include "rosidl_typesupport_introspection_tests/helpers.hpp" #include "rosidl_typesupport_introspection_tests/libraries.hpp"