diff --git a/rosidl_generator_c/resource/idl__struct.h.em b/rosidl_generator_c/resource/idl__struct.h.em index 9d6b2d1c4..701a94923 100644 --- a/rosidl_generator_c/resource/idl__struct.h.em +++ b/rosidl_generator_c/resource/idl__struct.h.em @@ -13,6 +13,7 @@ @{ from rosidl_generator_c import idl_structure_type_to_c_typename from rosidl_generator_c import type_hash_to_c_definition +from rosidl_generator_type_description import TYPE_HASH_VAR from rosidl_pycommon import convert_camel_case_to_lower_case_underscore include_parts = [package_name] + list(interface_path.parents[0].parts) + [ 'detail', convert_camel_case_to_lower_case_underscore(interface_path.stem)] @@ -60,10 +61,7 @@ from rosidl_parser.definition import Service }@ @[for service in content.get_elements_of_type(Service)]@ -@{ hash_var = idl_structure_type_to_c_typename(service.namespaced_type) + '__TYPE_VERSION_HASH' }@ -// Note: this define is for MSVC, where the static const var can't be used in downstream aggregate initializers -#define @(hash_var)__INIT @(type_hash_to_c_definition(type_hash['service'], line_final_backslash=True)) -static const rosidl_type_hash_t @(hash_var) = @(hash_var)__INIT; +static const rosidl_type_hash_t @(idl_structure_type_to_c_typename(service.namespaced_type))__@(TYPE_HASH_VAR) = @(type_hash_to_c_definition(type_hash['service'])); @{ TEMPLATE( @@ -99,9 +97,7 @@ from rosidl_parser.definition import Action }@ @[for action in content.get_elements_of_type(Action)]@ -@{ hash_var = idl_structure_type_to_c_typename(action.namespaced_type) + '__TYPE_VERSION_HASH' }@ -#define @(hash_var)__INIT @(type_hash_to_c_definition(type_hash['action'], line_final_backslash=True)) -static const rosidl_type_hash_t @(hash_var) = @(hash_var)__INIT; +static const rosidl_type_hash_t @(idl_structure_type_to_c_typename(action.namespaced_type))__@(TYPE_HASH_VAR) = @(type_hash_to_c_definition(type_hash['action'])); @{ TEMPLATE( @@ -127,10 +123,7 @@ TEMPLATE( type_hash=type_hash['feedback']) }@ -@{ hash_var = idl_structure_type_to_c_typename(action.send_goal_service.namespaced_type) + '__TYPE_VERSION_HASH' }@ -// Note: this define is for MSVC, where the static const var can't be used in downstream aggregate initializers -#define @(hash_var)__INIT @(type_hash_to_c_definition(type_hash['send_goal_service']['service'], line_final_backslash=True)) -static const rosidl_type_hash_t @(hash_var) = @(hash_var)__INIT; +static const rosidl_type_hash_t @(idl_structure_type_to_c_typename(action.send_goal_service.namespaced_type))__@(TYPE_HASH_VAR) = @(type_hash_to_c_definition(type_hash['send_goal_service']['service'])); @{ TEMPLATE( @@ -156,10 +149,7 @@ TEMPLATE( type_hash=type_hash['send_goal_service']['event_message']) }@ -@{ hash_var = idl_structure_type_to_c_typename(action.get_result_service.namespaced_type) + '__TYPE_VERSION_HASH' }@ -// Note: this define is for MSVC, where the static const var can't be used in downstream aggregate initializers -#define @(hash_var)__INIT @(type_hash_to_c_definition(type_hash['get_result_service']['service'], line_final_backslash=True)) -static const rosidl_type_hash_t @(hash_var) = @(hash_var)__INIT; +static const rosidl_type_hash_t @(idl_structure_type_to_c_typename(action.get_result_service.namespaced_type))__@(TYPE_HASH_VAR) = @(type_hash_to_c_definition(type_hash['get_result_service']['service'])); @{ TEMPLATE( diff --git a/rosidl_generator_c/resource/msg__struct.h.em b/rosidl_generator_c/resource/msg__struct.h.em index e75077af9..838eababf 100644 --- a/rosidl_generator_c/resource/msg__struct.h.em +++ b/rosidl_generator_c/resource/msg__struct.h.em @@ -23,6 +23,7 @@ from rosidl_generator_c import idl_structure_type_to_c_typename from rosidl_generator_c import interface_path_to_string from rosidl_generator_c import type_hash_to_c_definition from rosidl_generator_c import value_to_c +from rosidl_generator_type_description import TYPE_HASH_VAR }@ @#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @# Collect necessary include directives for all members @@ -63,11 +64,8 @@ for member in message.structure.members: @#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> @#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -// Type Version Hash for interface -@{ hash_var = idl_structure_type_to_c_typename(message.structure.namespaced_type) + '__TYPE_VERSION_HASH' }@ -// Note: this define is for MSVC, where the static const var can't be used in downstream aggregate initializers -#define @(hash_var)__INIT @(type_hash_to_c_definition(type_hash['message'], line_final_backslash=True)) -static const rosidl_type_hash_t @(hash_var) = @(hash_var)__INIT; +// Type Hash for interface +static const rosidl_type_hash_t @(idl_structure_type_to_c_typename(message.structure.namespaced_type))__@(TYPE_HASH_VAR) = @(type_hash_to_c_definition(type_hash['message'])); // Constants defined in the message @[for constant in message.constants]@ diff --git a/rosidl_generator_c/resource/srv__type_support.c.em b/rosidl_generator_c/resource/srv__type_support.c.em index 92bb4ae50..c3228a98d 100644 --- a/rosidl_generator_c/resource/srv__type_support.c.em +++ b/rosidl_generator_c/resource/srv__type_support.c.em @@ -1,9 +1,9 @@ @# Included from rosidl_generator_c/resource/srv__type_support.c.em @{ -from rosidl_pycommon import convert_camel_case_to_lower_case_underscore +from rosidl_parser.definition import SERVICE_EVENT_MESSAGE_SUFFIX from rosidl_parser.definition import SERVICE_REQUEST_MESSAGE_SUFFIX from rosidl_parser.definition import SERVICE_RESPONSE_MESSAGE_SUFFIX -from rosidl_parser.definition import SERVICE_EVENT_MESSAGE_SUFFIX +from rosidl_pycommon import convert_camel_case_to_lower_case_underscore event_type = '__'.join([package_name, *interface_path.parents[0].parts, service.namespaced_type.name]) + SERVICE_EVENT_MESSAGE_SUFFIX request_type = '__'.join([package_name, *interface_path.parents[0].parts, service.namespaced_type.name]) + SERVICE_REQUEST_MESSAGE_SUFFIX response_type = '__'.join([package_name, *interface_path.parents[0].parts, service.namespaced_type.name]) + SERVICE_RESPONSE_MESSAGE_SUFFIX diff --git a/rosidl_generator_c/rosidl_generator_c/__init__.py b/rosidl_generator_c/rosidl_generator_c/__init__.py index 9be5d720e..6fa0cd2cc 100644 --- a/rosidl_generator_c/rosidl_generator_c/__init__.py +++ b/rosidl_generator_c/rosidl_generator_c/__init__.py @@ -223,25 +223,20 @@ def escape_wstring(s): return escape_string(s) -def type_hash_to_c_definition(hash_string, *, line_final_backslash=False): +def type_hash_to_c_definition(hash_string, *, indent=2): """Generate empy for rosidl_type_hash_t instance with 8 bytes per line for readability.""" bytes_per_row = 8 rows = 4 assert bytes_per_row * rows == RIHS01_HASH_VALUE_SIZE, 'This function is outdated.' - indent = 4 # Uncrustify prefers this indentation version, value = parse_rihs_string(hash_string) assert version == 1, 'This function only knows how to generate RIHS01 definitions.' result = f'{{{version}, {{' - if line_final_backslash: - result += ' \\' result += '\n' for row in range(rows): result += ' ' * (indent + 1) for i in range(row * bytes_per_row, (row + 1) * bytes_per_row): result += f' 0x{value[i * 2]}{value[i * 2 + 1]},' - if line_final_backslash: - result += ' \\' result += '\n' result += ' ' * indent result += '}}' diff --git a/rosidl_generator_cpp/cmake/rosidl_generator_cpp_generate_interfaces.cmake b/rosidl_generator_cpp/cmake/rosidl_generator_cpp_generate_interfaces.cmake index 526ce76c2..151d54cf5 100644 --- a/rosidl_generator_cpp/cmake/rosidl_generator_cpp_generate_interfaces.cmake +++ b/rosidl_generator_cpp/cmake/rosidl_generator_cpp_generate_interfaces.cmake @@ -106,6 +106,7 @@ add_dependencies( set(_target_suffix "__rosidl_generator_cpp") add_library(${rosidl_generate_interfaces_TARGET}${_target_suffix} INTERFACE) +target_compile_features(${rosidl_generate_interfaces_TARGET}${_target_suffix} INTERFACE cxx_std_17) add_library(${PROJECT_NAME}::${rosidl_generate_interfaces_TARGET}${_target_suffix} ALIAS ${rosidl_generate_interfaces_TARGET}${_target_suffix}) target_include_directories(${rosidl_generate_interfaces_TARGET}${_target_suffix} diff --git a/rosidl_generator_cpp/resource/action__struct.hpp.em b/rosidl_generator_cpp/resource/action__struct.hpp.em index 9c89bbdc8..efb630496 100644 --- a/rosidl_generator_cpp/resource/action__struct.hpp.em +++ b/rosidl_generator_cpp/resource/action__struct.hpp.em @@ -1,6 +1,7 @@ @# Included from rosidl_generator_cpp/resource/idl__struct.hpp.em @{ from rosidl_generator_c import type_hash_to_c_definition +from rosidl_generator_type_description import TYPE_HASH_VAR from rosidl_parser.definition import ACTION_FEEDBACK_MESSAGE_SUFFIX from rosidl_parser.definition import ACTION_FEEDBACK_SUFFIX from rosidl_parser.definition import ACTION_GOAL_SERVICE_SUFFIX @@ -79,7 +80,7 @@ namespace @(ns) @[end for]@ struct @(action.namespaced_type.name) { - static constexpr const rosidl_type_hash_t TYPE_VERSION_HASH = @(type_hash_to_c_definition(type_hash['action'])); + static constexpr const rosidl_type_hash_t @(TYPE_HASH_VAR) = @(type_hash_to_c_definition(type_hash['action'], indent=4)); /// The goal message defined in the action definition. using Goal = @(action_name)@(ACTION_GOAL_SUFFIX); diff --git a/rosidl_generator_cpp/resource/msg__struct.hpp.em b/rosidl_generator_cpp/resource/msg__struct.hpp.em index e66a922d3..bea08a923 100644 --- a/rosidl_generator_cpp/resource/msg__struct.hpp.em +++ b/rosidl_generator_cpp/resource/msg__struct.hpp.em @@ -6,6 +6,7 @@ from rosidl_generator_cpp import escape_string from rosidl_generator_cpp import escape_wstring from rosidl_generator_cpp import msg_type_to_cpp from rosidl_generator_cpp import MSG_TYPE_TO_CPP +from rosidl_generator_type_description import TYPE_HASH_VAR from rosidl_parser.definition import AbstractNestedType from rosidl_parser.definition import AbstractString from rosidl_parser.definition import AbstractWString @@ -102,8 +103,7 @@ struct @(message.structure.namespaced_type.name)_ { using Type = @(message.structure.namespaced_type.name)_; - // Type Version Hash for interface - constexpr static const rosidl_type_hash_t TYPE_VERSION_HASH = @(type_hash_to_c_definition(type_hash['message'])); + constexpr static const rosidl_type_hash_t @(TYPE_HASH_VAR) = @(type_hash_to_c_definition(type_hash['message'], indent=4)); @{ # The creation of the constructors for messages is a bit complicated. The goal @@ -362,7 +362,7 @@ using @(message.structure.namespaced_type.name) = @(message_typename)_>; template -constexpr const rosidl_type_hash_t @(message.structure.namespaced_type.name)_::TYPE_VERSION_HASH; +constexpr const rosidl_type_hash_t @(message.structure.namespaced_type.name)_::@(TYPE_HASH_VAR); // constant definitions @[for c in message.constants]@ diff --git a/rosidl_generator_cpp/resource/srv__struct.hpp.em b/rosidl_generator_cpp/resource/srv__struct.hpp.em index 54bc65993..9a1f75644 100644 --- a/rosidl_generator_cpp/resource/srv__struct.hpp.em +++ b/rosidl_generator_cpp/resource/srv__struct.hpp.em @@ -1,6 +1,10 @@ @# Included from rosidl_generator_cpp/resource/idl__struct.hpp.em @{ from rosidl_generator_c import type_hash_to_c_definition +from rosidl_generator_type_description import TYPE_HASH_VAR +from rosidl_parser.definition import SERVICE_EVENT_MESSAGE_SUFFIX +from rosidl_parser.definition import SERVICE_REQUEST_MESSAGE_SUFFIX +from rosidl_parser.definition import SERVICE_RESPONSE_MESSAGE_SUFFIX }@ @{ TEMPLATE( @@ -37,11 +41,11 @@ struct @(service.namespaced_type.name) @{ service_typename = '::'.join(service.namespaced_type.namespaced_name()) }@ - static constexpr const rosidl_type_hash_t TYPE_VERSION_HASH = @(type_hash_to_c_definition(type_hash['service'])); + static constexpr const rosidl_type_hash_t @(TYPE_HASH_VAR) = @(type_hash_to_c_definition(type_hash['service'], indent=4)); - using Request = @(service_typename)_Request; - using Response = @(service_typename)_Response; - using Event = @(service_typename)_Event; + using Request = @(service_typename)@(SERVICE_REQUEST_MESSAGE_SUFFIX); + using Response = @(service_typename)@(SERVICE_RESPONSE_MESSAGE_SUFFIX); + using Event = @(service_typename)@(SERVICE_EVENT_MESSAGE_SUFFIX); }; @ @[for ns in reversed(service.namespaced_type.namespaces)]@ diff --git a/rosidl_generator_type_description/README.md b/rosidl_generator_type_description/README.md index 318d2a05d..4edbf5351 100644 --- a/rosidl_generator_type_description/README.md +++ b/rosidl_generator_type_description/README.md @@ -2,7 +2,7 @@ This generator serializes ROS 2 interface descriptions (message, service, action) to a common format and uses SHA256 to hash that representation into a unique hash for each type. -The SHA256 hashes generated by this package must match those generated by `rcl_calculate_type_version_hash`. The `.json` files generated must, therefore, match the result of `rcl_type_description_to_hashable_json`. +The SHA256 hashes generated by this package must match those generated by `rcl_calculate_type_hash`. The `.json` files generated must, therefore, match the result of `rcl_type_description_to_hashable_json`. ## Generated files diff --git a/rosidl_generator_type_description/rosidl_generator_type_description/__init__.py b/rosidl_generator_type_description/rosidl_generator_type_description/__init__.py index 117a6c951..13fed546e 100644 --- a/rosidl_generator_type_description/rosidl_generator_type_description/__init__.py +++ b/rosidl_generator_type_description/rosidl_generator_type_description/__init__.py @@ -31,6 +31,9 @@ RIHS01_HASH_VALUE_SIZE = 32 RIHS01_PATTERN = re.compile(r'RIHS([0-9a-f]{2})_([0-9a-f]{64})') +# Used by code generators to create type hash variable names +TYPE_HASH_VAR = 'TYPE_HASH' + def generate_type_hash(generator_arguments_file: str) -> List[str]: with open(generator_arguments_file, 'r') as f: @@ -461,7 +464,8 @@ def _calculate_hash_tree(self) -> dict: check_circular=True, allow_nan=False, indent=None, - separators=(',', ': '), + # note: libyaml in C doesn't allow for tweaking these separators, this is its builtin + separators=(', ', ': '), sort_keys=False ) sha = hashlib.sha256() 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 801a771ed..34fd23674 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 @@ -17,6 +17,7 @@ #include "rosidl_runtime_c/message_type_support_struct.h" #include "rosidl_runtime_c/service_type_support_struct.h" +#include "rosidl_runtime_c/type_hash.h" #include "rosidl_runtime_c/visibility_control.h" #include "rosidl_typesupport_interface/macros.h" @@ -38,6 +39,8 @@ struct rosidl_action_type_support_t const rosidl_service_type_support_t * cancel_service_type_support; const rosidl_message_type_support_t * feedback_message_type_support; const rosidl_message_type_support_t * status_message_type_support; + /// Hash of the action's description + const rosidl_type_hash_t * type_hash; }; /// Get the action type support given a provided action and package. 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 c587e673b..5628732f1 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 @@ -15,6 +15,7 @@ #ifndef ROSIDL_RUNTIME_C__MESSAGE_TYPE_SUPPORT_STRUCT_H_ #define ROSIDL_RUNTIME_C__MESSAGE_TYPE_SUPPORT_STRUCT_H_ +#include "rosidl_runtime_c/type_hash.h" #include "rosidl_runtime_c/visibility_control.h" #include "rosidl_typesupport_interface/macros.h" @@ -37,6 +38,8 @@ struct rosidl_message_type_support_t const void * data; /// Pointer to the message type support handler function rosidl_message_typesupport_handle_function func; + /// Hash of the message's description + const rosidl_type_hash_t * type_hash; }; /// Get the message type support handle specific to this identifier. 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 2039d819c..21fc79412 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 @@ -19,6 +19,7 @@ #include "rcutils/allocator.h" #include "rosidl_runtime_c/message_type_support_struct.h" +#include "rosidl_runtime_c/type_hash.h" #include "rosidl_runtime_c/visibility_control.h" #include "rosidl_typesupport_interface/macros.h" @@ -81,12 +82,18 @@ struct rosidl_service_type_support_t const void * data; /// Pointer to the service type support handler function rosidl_service_typesupport_handle_function func; + /// Service request message typesupport + const rosidl_message_type_support_t * request_typesupport; + /// Service response message typesupport + const rosidl_message_type_support_t * response_typesupport; + /// Service event message typesupport + const rosidl_message_type_support_t * event_typesupport; /// Pointer to function to create the introspection message rosidl_event_message_create_handle_function_function event_message_create_handle_function; /// Pointer to function to finalize the introspection message rosidl_event_message_destroy_handle_function_function event_message_destroy_handle_function; - /// Service event message typesupport - const rosidl_message_type_support_t * event_typesupport; + /// Hash of the service's description + const rosidl_type_hash_t * type_hash; }; /// Get the service type support handle specific to this identifier. 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 12fc4811a..0d16e5923 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 @@ -86,8 +86,6 @@ typedef struct rosidl_typesupport_introspection_c__MessageMembers_s const char * message_namespace_; /// The name of the interface, e.g. "Int16" const char * message_name_; - /// Hashed value of the interface description - const rosidl_type_hash_t type_hash_; /// The number of fields in the interface uint32_t member_count_; /// The size of the interface structure in memory 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 1e8beda4f..a14954a50 100644 --- a/rosidl_typesupport_introspection_c/resource/msg__type_support.c.em +++ b/rosidl_typesupport_introspection_c/resource/msg__type_support.c.em @@ -2,6 +2,8 @@ @{ from rosidl_pycommon import convert_camel_case_to_lower_case_underscore from rosidl_generator_c import idl_structure_type_to_c_include_prefix +from rosidl_generator_c import idl_structure_type_to_c_typename +from rosidl_generator_type_description import TYPE_HASH_VAR from rosidl_parser.definition import AbstractGenericString from rosidl_parser.definition import AbstractNestedType from rosidl_parser.definition import AbstractSequence @@ -270,7 +272,6 @@ for index, member in enumerate(message.structure.members): static const rosidl_typesupport_introspection_c__MessageMembers @(function_prefix)__@(message.structure.namespaced_type.name)_message_members = { "@('__'.join([package_name] + list(interface_path.parents[0].parts)))", // message namespace "@(message.structure.namespaced_type.name)", // message name - @('__'.join(message.structure.namespaced_type.namespaced_name()))__TYPE_VERSION_HASH__INIT, @(len(message.structure.members)), // number of fields sizeof(@('__'.join([package_name] + list(interface_path.parents[0].parts) + [message.structure.namespaced_type.name]))), @(function_prefix)__@(message.structure.namespaced_type.name)_message_member_array, // message members @@ -284,6 +285,7 @@ static rosidl_message_type_support_t @(function_prefix)__@(message.structure.nam 0, &@(function_prefix)__@(message.structure.namespaced_type.name)_message_members, get_message_typesupport_handle_function, + &@(idl_structure_type_to_c_typename(message.structure.namespaced_type))__@(TYPE_HASH_VAR), }; ROSIDL_TYPESUPPORT_INTROSPECTION_C_EXPORT_@(package_name) 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 1158d9f50..e21f5b46c 100644 --- a/rosidl_typesupport_introspection_c/resource/srv__type_support.c.em +++ b/rosidl_typesupport_introspection_c/resource/srv__type_support.c.em @@ -21,10 +21,12 @@ TEMPLATE( }@ @{ -from rosidl_pycommon import convert_camel_case_to_lower_case_underscore +from rosidl_generator_c import idl_structure_type_to_c_typename +from rosidl_generator_type_description import TYPE_HASH_VAR +from rosidl_parser.definition import SERVICE_EVENT_MESSAGE_SUFFIX from rosidl_parser.definition import SERVICE_REQUEST_MESSAGE_SUFFIX from rosidl_parser.definition import SERVICE_RESPONSE_MESSAGE_SUFFIX -from rosidl_parser.definition import SERVICE_EVENT_MESSAGE_SUFFIX +from rosidl_pycommon import convert_camel_case_to_lower_case_underscore include_parts = [package_name] + list(interface_path.parents[0].parts) + [ 'detail', convert_camel_case_to_lower_case_underscore(interface_path.stem)] include_base = '/'.join(include_parts) @@ -37,7 +39,10 @@ header_files = [ 'rosidl_typesupport_introspection_c/service_introspection.h', ] -message_function_prefix = '__'.join([package_name] + list(interface_path.parents[0].parts) + [service.namespaced_type.name]) + f'{SERVICE_EVENT_MESSAGE_SUFFIX}__rosidl_typesupport_introspection_c' +message_function_prefix = '__'.join([package_name] + list(interface_path.parents[0].parts) + [service.namespaced_type.name]) +request_message_function_prefix = message_function_prefix + f'{SERVICE_REQUEST_MESSAGE_SUFFIX}__rosidl_typesupport_introspection_c' +response_message_function_prefix = message_function_prefix + f'{SERVICE_RESPONSE_MESSAGE_SUFFIX}__rosidl_typesupport_introspection_c' +event_message_function_prefix = message_function_prefix + f'{SERVICE_EVENT_MESSAGE_SUFFIX}__rosidl_typesupport_introspection_c' function_prefix = '__'.join(include_parts) + '__rosidl_typesupport_introspection_c' }@ @[for header_file in header_files]@ @@ -71,6 +76,9 @@ static rosidl_service_type_support_t @(function_prefix)__@(service.namespaced_ty 0, &@(function_prefix)__@(service.namespaced_type.name)_service_members, get_service_typesupport_handle_function, + &@(request_message_function_prefix)__@(service.namespaced_type.name)@(SERVICE_REQUEST_MESSAGE_SUFFIX)_message_type_support_handle, + &@(response_message_function_prefix)__@(service.namespaced_type.name)@(SERVICE_RESPONSE_MESSAGE_SUFFIX)_message_type_support_handle, + &@(event_message_function_prefix)__@(service.namespaced_type.name)@(SERVICE_EVENT_MESSAGE_SUFFIX)_message_type_support_handle, ROSIDL_TYPESUPPORT_INTERFACE__SERVICE_CREATE_EVENT_MESSAGE_SYMBOL_NAME( rosidl_typesupport_c, @(',\n '.join(service.namespaced_type.namespaced_name())) @@ -79,7 +87,7 @@ static rosidl_service_type_support_t @(function_prefix)__@(service.namespaced_ty rosidl_typesupport_c, @(',\n '.join(service.namespaced_type.namespaced_name())) ), - &@(message_function_prefix)__@(service.namespaced_type.name)@(SERVICE_EVENT_MESSAGE_SUFFIX)_message_type_support_handle, + &@(idl_structure_type_to_c_typename(service.namespaced_type))__@(TYPE_HASH_VAR), }; // Forward declaration of request/response type support functions 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 cc60501f8..6c01c2ce8 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 @@ -93,8 +93,6 @@ typedef struct ROSIDL_TYPESUPPORT_INTROSPECTION_CPP_PUBLIC MessageMembers_s const char * message_namespace_; /// The name of the interface, e.g. "Int16" const char * message_name_; - /// Hashed value of the interface description - const rosidl_type_hash_t type_hash_; /// The number of fields in the interface uint32_t member_count_; /// The size of the interface structure in memory 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 7c1cc636b..585c93bb3 100644 --- a/rosidl_typesupport_introspection_cpp/resource/msg__type_support.cpp.em +++ b/rosidl_typesupport_introspection_cpp/resource/msg__type_support.cpp.em @@ -1,5 +1,6 @@ @# Included from rosidl_typesupport_introspection_cpp/resource/idl__type_support.cpp.em @{ +from rosidl_generator_type_description import TYPE_HASH_VAR from rosidl_parser.definition import AbstractGenericString from rosidl_parser.definition import AbstractNestedType from rosidl_parser.definition import AbstractSequence @@ -235,7 +236,6 @@ for index, member in enumerate(message.structure.members): static const ::rosidl_typesupport_introspection_cpp::MessageMembers @(message.structure.namespaced_type.name)_message_members = { "@('::'.join([package_name] + list(interface_path.parents[0].parts)))", // message namespace "@(message.structure.namespaced_type.name)", // message name - @('::'.join(message.structure.namespaced_type.namespaced_name()))::TYPE_VERSION_HASH, @(len(message.structure.members)), // number of fields sizeof(@('::'.join([package_name] + list(interface_path.parents[0].parts) + [message.structure.namespaced_type.name]))), @(message.structure.namespaced_type.name)_message_member_array, // message members @@ -247,6 +247,7 @@ static const rosidl_message_type_support_t @(message.structure.namespaced_type.n ::rosidl_typesupport_introspection_cpp::typesupport_identifier, &@(message.structure.namespaced_type.name)_message_members, get_message_typesupport_handle_function, + &@('::'.join(message.structure.namespaced_type.namespaced_name()))::@(TYPE_HASH_VAR), }; } // namespace rosidl_typesupport_introspection_cpp diff --git a/rosidl_typesupport_introspection_cpp/resource/srv__type_support.cpp.em b/rosidl_typesupport_introspection_cpp/resource/srv__type_support.cpp.em index bce36658a..c7be2f323 100644 --- a/rosidl_typesupport_introspection_cpp/resource/srv__type_support.cpp.em +++ b/rosidl_typesupport_introspection_cpp/resource/srv__type_support.cpp.em @@ -21,10 +21,11 @@ TEMPLATE( }@ @{ -from rosidl_pycommon import convert_camel_case_to_lower_case_underscore +from rosidl_generator_type_description import TYPE_HASH_VAR +from rosidl_parser.definition import SERVICE_EVENT_MESSAGE_SUFFIX from rosidl_parser.definition import SERVICE_REQUEST_MESSAGE_SUFFIX from rosidl_parser.definition import SERVICE_RESPONSE_MESSAGE_SUFFIX -from rosidl_parser.definition import SERVICE_EVENT_MESSAGE_SUFFIX +from rosidl_pycommon import convert_camel_case_to_lower_case_underscore include_parts = [package_name] + list(interface_path.parents[0].parts) + [ 'detail', convert_camel_case_to_lower_case_underscore(interface_path.stem)] include_base = '/'.join(include_parts) @@ -74,9 +75,12 @@ static const rosidl_service_type_support_t @(service.namespaced_type.name)_servi ::rosidl_typesupport_introspection_cpp::typesupport_identifier, &@(service.namespaced_type.name)_service_members, get_service_typesupport_handle_function, + ::rosidl_typesupport_introspection_cpp::get_message_type_support_handle<@('::'.join([package_name, *interface_path.parents[0].parts, service.namespaced_type.name]))@(SERVICE_REQUEST_MESSAGE_SUFFIX)>(), + ::rosidl_typesupport_introspection_cpp::get_message_type_support_handle<@('::'.join([package_name, *interface_path.parents[0].parts, service.namespaced_type.name]))@(SERVICE_RESPONSE_MESSAGE_SUFFIX)>(), + ::rosidl_typesupport_introspection_cpp::get_message_type_support_handle<@('::'.join([package_name, *interface_path.parents[0].parts, service.namespaced_type.name]))@(SERVICE_EVENT_MESSAGE_SUFFIX)>(), &::rosidl_typesupport_cpp::service_create_event_message<@('::'.join([package_name, *interface_path.parents[0].parts, service.namespaced_type.name]))>, &::rosidl_typesupport_cpp::service_destroy_event_message<@('::'.join([package_name, *interface_path.parents[0].parts, service.namespaced_type.name]))>, - ::rosidl_typesupport_introspection_cpp::get_message_type_support_handle<@('::'.join([package_name, *interface_path.parents[0].parts, service.namespaced_type.name]))_Event>(), + &@('::'.join(service.namespaced_type.namespaced_name()))::@(TYPE_HASH_VAR), }; } // namespace rosidl_typesupport_introspection_cpp