Skip to content

Expose type hash on typesupports (rep2011)#729

Merged
clalancette merged 7 commits intoros2:rollingfrom
emersonknapp:emersonknapp/hash-typesupport
Mar 24, 2023
Merged

Expose type hash on typesupports (rep2011)#729
clalancette merged 7 commits intoros2:rollingfrom
emersonknapp:emersonknapp/hash-typesupport

Conversation

@emersonknapp
Copy link
Collaborator

@emersonknapp emersonknapp commented Mar 22, 2023

No dependencies.
Followup to #722
Part of ros2/ros2#1159

Bundled with (must be merged together)

Changes:

  • Add rosidl_type_hash_t to message_type_support_t (and service_type_support_t, action_type_support_t)
  • Remove type hash from specific typesupport implementations, instead treating it as fully-generic information at the runtime level
  • Rename TYPE_VERSION_HASH consistently to TYPE_HASH before it's too late
  • Get rid of the __INIT workaround by using the type hashes as pointers elsewhere instead of static initializers

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
@emersonknapp emersonknapp force-pushed the emersonknapp/hash-typesupport branch from 5b9f0b6 to 3ee9e4c Compare March 22, 2023 06:12
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
@emersonknapp emersonknapp force-pushed the emersonknapp/hash-typesupport branch from 3ee9e4c to 1a8fce4 Compare March 22, 2023 06:21
Copy link
Collaborator Author

@emersonknapp emersonknapp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling out some key spots for reviewers

// 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']));
Copy link
Collaborator Author

@emersonknapp emersonknapp Mar 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am getting rid of the #define __INIT by using pointers in the other places this is used as an initializer. I think everything is nicer this way.


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)
Copy link
Collaborator Author

@emersonknapp emersonknapp Mar 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a concern? We've upgraded everything else to C++17 but the generated interface libraries themselves hadn't actually specified a standard version. This is needed for the static constexpr rosidl_type_hash_t in non-templated Service and Action classes, for the inline variable thing that's new in C++17

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a concern; we've specified in REP-2000 that we target C++17, and we've upgraded most of the packages at this point to C++17. So I'm fine with adding this here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with me too.

/// 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;
Copy link
Collaborator Author

@emersonknapp emersonknapp Mar 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These rosidl_message_type_support instances were not available in all contexts. rosidl_typesupport_fastrtps exposed them in its ServiceMembers, but rosidl_typesupport_introspection only exposes nested MessageMembers with no access to the message typesupport.

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
@emersonknapp emersonknapp marked this pull request as ready for review March 22, 2023 06:49
@emersonknapp
Copy link
Collaborator Author

emersonknapp commented Mar 22, 2023

Smoke check (one run with 3 PRs combined)
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/11647

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've left one question inline. Otherwise, this looks fine to me with green CI.

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
@emersonknapp
Copy link
Collaborator Author

Gist: https://gist.githubusercontent.com/emersonknapp/6f64e848cf178a828c180607a21fa967/raw/ba310891c24e6d45715e2fdd58d3a978b39d9442/ros2.repos
BUILD args:
TEST args:
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/11657

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@emersonknapp
Copy link
Collaborator Author

emersonknapp commented Mar 24, 2023

I'm just trying Windows rcl test on master for a sanity check - I have no idea how this changeset could affect this one logging test in rcl for connext only.

Windows: Build Status

@clalancette
Copy link
Contributor

I'm just trying Windows rcl test on master for a sanity check - I have no idea how this changeset could affect this one logging test in rcl for connext only.

It didn't, that's a flaky test. Everything else looks good there, so I'll go ahead and merge the three of them in this series.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants