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

[20156] Feature: topic keys #1

Draft
wants to merge 2 commits into
base: rolling
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions rosidl_parser/rosidl_parser/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,15 @@ def __init__(self, namespaced_type: NamespacedType, members=None):
self.namespaced_type = namespaced_type
self.members = members or []

def has_any_member_with_annotation(self, name: str):
"""
Returns whether any member has a particular annotation.

:param name: the annotation name
"""
has_any = [member.name for member in self.members if member.has_annotation(name)]
return bool(has_any)


class Include:
"""An include statement."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 a keyed field, 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_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 a keyed field, 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_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Expand Down