-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add C++ conversion APIs to proto2ros
#118
Conversation
Signed-off-by: Michel Hidalgo <[email protected]>
{{ destination }}->Add(static_cast<{{ type_spec.annotations["proto-type"] | as_pb2_cpp_type }}>(item.value)); | ||
} | ||
{%- else -%} | ||
{{ destination | rreplace("mutable", "set", 1) | rreplace("()", "", 1) }}( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not super proud of this but the C++ API for Protobuf messages is so inconsistent across types that it hurts.
{%- set output_item = itemize_cpp_identifier(destination, "output_") -%} | ||
{%- if type_spec and type_spec.annotations.get("map-entry") -%}{#- Handle map case. -#} | ||
{{ destination }}->clear(); | ||
for (const auto& {{ input_item }} : {{ source }}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handling map fields was particularly hard. Python APIs for Protobuf messages expose the underlying sequence of key-value messages. C++ APIs hide them, and that forces all this special casing 🤦
LIBRARY DESTINATION lib | ||
RUNTIME DESTINATION bin | ||
) | ||
ament_export_targets(export_${target}_conversions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for myself: this is likely incomplete, and will need a revisit when we try to re-build https://github.com/bdaiinstitute/bosdyn_msgs with this.
Signed-off-by: Michel Hidalgo <[email protected]>
Signed-off-by: Michel Hidalgo <[email protected]>
Signed-off-by: Michel Hidalgo <[email protected]>
Signed-off-by: Michel Hidalgo <[email protected]>
Signed-off-by: Michel Hidalgo <[email protected]>
Signed-off-by: Michel Hidalgo <[email protected]>
Signed-off-by: Michel Hidalgo <[email protected]>
Hmm, something's off with generated Protobuf C++ code. It sometimes fails to preprocess some of it, but only in CI, I cannot reproduce it anywhere else 🤔 |
Follow-up to #118. This patch makes `proto2ros` packages' C++ code comply with stricter `clang-tidy` configurations. It liberally disables some opinionated checks where appropriate.
Precisely what the title says. We are almost there, I'm just missing the C++ test suite but conversion code compiles and looks correct on visual inspection. We can start the review.