Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[20310] Feature: topic keys with non breaking ABI #2

Open
wants to merge 25 commits into
base: vulcanexus
Choose a base branch
from

Conversation

Mario-DL
Copy link
Member

@Mario-DL Mario-DL commented Feb 8, 2024

This PR brings the changes in the rosidl_typesupport_fastrtps generator packages to support topic keys feature without breaking ABI.

Note: This branch starts from the previous work from #1

@Mario-DL Mario-DL changed the base branch from rolling to vulcanexus February 8, 2024 11:15
Comment on lines 32 to 35
/// Callback function for message serialization
/**
* \param[in] untyped_ros_message Type erased pointer to message instance.
* \param [in,out] Serialized FastCDR data object.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// Callback function for message serialization
/**
* \param[in] untyped_ros_message Type erased pointer to message instance.
* \param [in,out] Serialized FastCDR data object.
/// Callback function for key serialization
/**
* \param [in] untyped_ros_message Type erased pointer to message instance.
* \param [in,out] Serialized FastCDR data object.

Comment on lines 42 to 45
/// Callback function for message deserialization
/**
* \param [in] Serialized FastCDR data object.
* \param[out] untyped_ros_message Type erased pointer to message instance.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// Callback function for message deserialization
/**
* \param [in] Serialized FastCDR data object.
* \param[out] untyped_ros_message Type erased pointer to message instance.
/// Callback function for key deserialization
/**
* \param [in] Serialized FastCDR data object.
* \param [out] untyped_ros_message Type erased pointer to message instance.


/// Callback function to get size of the key data
/**
* \return The size of the serialized message in bytes.
Copy link
Member

Choose a reason for hiding this comment

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

Add corresponding \param descriptions here

Comment on lines 52 to 53

struct message_type_support_key_callbacks_t;
Copy link
Member

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 necessary

Suggested change
struct message_type_support_key_callbacks_t;

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch

@@ -90,6 +104,89 @@ namespace @(ns)
@{forward_declared_types.add(message.structure.namespaced_type.namespaced_name())}@
namespace typesupport_fastrtps_cpp
{
@{
def generate_member_for_cdr_serialize(member, suffix):
from rosidl_generator_cpp import msg_type_only_to_cpp
Copy link
Member

Choose a reason for hiding this comment

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

Add documentation of this python method

Comment on lines 616 to 694
static
size_t
_@(message.structure.namespaced_type.name)__get_serialized_size_key(
const void * untyped_ros_message,
size_t initial_alignment)
{
auto typed_message =
static_cast<const @('::'.join([package_name] + list(interface_path.parents[0].parts) + [message.structure.namespaced_type.name])) *>(
untyped_ros_message);

return static_cast<uint32_t>(get_serialized_size_key(*typed_message, initial_alignment));
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
static
size_t
_@(message.structure.namespaced_type.name)__get_serialized_size_key(
const void * untyped_ros_message,
size_t initial_alignment)
{
auto typed_message =
static_cast<const @('::'.join([package_name] + list(interface_path.parents[0].parts) + [message.structure.namespaced_type.name])) *>(
untyped_ros_message);
return static_cast<uint32_t>(get_serialized_size_key(*typed_message, initial_alignment));
}
static
size_t
_@(message.structure.namespaced_type.name)__get_serialized_size_key(
const void * untyped_ros_message)
{
auto typed_message =
static_cast<const @('::'.join([package_name] + list(interface_path.parents[0].parts) + [message.structure.namespaced_type.name])) *>(
untyped_ros_message);
return get_serialized_size_key(*typed_message, 0);
}

Comment on lines 629 to 639
static size_t _@(message.structure.namespaced_type.name)__max_serialized_size_key(
size_t current_alignment,
bool & is_unbounded)
{
bool full_bounded = true;
bool is_plain = true;

size_t ret_val = max_serialized_size_key_@(message.structure.namespaced_type.name)(
full_bounded,
is_plain,
current_alignment);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
static size_t _@(message.structure.namespaced_type.name)__max_serialized_size_key(
size_t current_alignment,
bool & is_unbounded)
{
bool full_bounded = true;
bool is_plain = true;
size_t ret_val = max_serialized_size_key_@(message.structure.namespaced_type.name)(
full_bounded,
is_plain,
current_alignment);
static size_t _@(message.structure.namespaced_type.name)__max_serialized_size_key(
bool & is_unbounded)
{
bool full_bounded = true;
bool is_plain = true;
size_t ret_val = max_serialized_size_key_@(message.structure.namespaced_type.name)(
full_bounded,
is_plain,
0);

Copy link
Member Author

Choose a reason for hiding this comment

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

I also changed it in the c interfaces

@@ -162,6 +177,134 @@ const rosidl_message_type_support_t *

using _@(message.structure.namespaced_type.name)__ros_msg_type = @('__'.join(message.structure.namespaced_type.namespaced_name()));

@{
def generate_member_for_cdr_serialize(member, suffix):
from rosidl_generator_cpp import msg_type_only_to_cpp
Copy link
Member

Choose a reason for hiding this comment

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

Add documentation for this python method

if suffix == '':
strlist.append(' if (!callbacks->cdr_serialize(')
else:
strlist.append(' if (!callbacks->%s_callbacks->cdr_serialize%s(' % ((''.join(c for c in suffix if c not in '(){}<>_*')), suffix))
Copy link
Member

Choose a reason for hiding this comment

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

Beware! callbacks->key_callbacks might be nullptr!

Copy link
Member

Choose a reason for hiding this comment

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

Applies elsewhere

return current_alignment - initial_alignment;
}

@[ if message.structure.has_any_member_with_annotation('key') ]@
Copy link
Member

Choose a reason for hiding this comment

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

I think we should follow the same approach we are using for the cpp type support, i.e. always declaring and exporting the type-aware implementations, and then generate the void * implementations when the type has a key annotation.

This would imply changing the way we call nested types and making it not rely on the callbacks structure

Copy link
Member Author

@Mario-DL Mario-DL Feb 27, 2024

Choose a reason for hiding this comment

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

Okay, lets give it a try. Then, not applying the former comment

…ods for supporting keys

Signed-off-by: Mario Dominguez <[email protected]>
…called from outside in headers

Signed-off-by: Mario Dominguez <[email protected]>
…ate_members_for_cdr_serialize

Signed-off-by: Mario Dominguez <[email protected]>
…ate_members_for_get_serialized_size

Signed-off-by: Mario Dominguez <[email protected]>
…ate_members_for_max_serialized_size

Signed-off-by: Mario Dominguez <[email protected]>
…alize_key and cdr_deserialize_key methods that are not going to be used nor exported if the type do not have keys

Signed-off-by: Mario Dominguez <[email protected]>
…e called from outside in headers

Signed-off-by: Mario Dominguez <[email protected]>
…erate_members_for_cdr_serialize. Also, generate proxy methods only when the type has a key

Signed-off-by: Mario Dominguez <[email protected]>
…erate_members_for_get_serialized_size adn proxy

Signed-off-by: Mario Dominguez <[email protected]>
…erate_members_for_max_serialized_size and proxy

Signed-off-by: Mario Dominguez <[email protected]>
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.

2 participants