-
Notifications
You must be signed in to change notification settings - Fork 162
Add the DynamicMessage type itself #292
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
Conversation
f169bff
to
3ddd682
Compare
If ROS 2 itself supports Do we know what alignment the ROS 2 standard uses, itself? Do different messages have different alignments depending on contents, or do they just make everything aligned to 16 bytes? Or is that a silly question? |
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.
Only saw a single area where I had questions, otherwise this looks pretty good to me!
// SAFETY: The pointer returned by get_type_support_handle() is always valid. | ||
let type_support = unsafe { &*self.type_support_ptr }; | ||
let message_members: &rosidl_message_members_t = | ||
// SAFETY: The data pointer is supposed to be always valid. |
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.
The "supposed to be" wording makes this sound like there are instances where the data pointer may not be valid. Is that correct? Is there anything that we can do to detect or defend against that?
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.
Someone could always create a shared library containing invalid pointers – but there's no way of protecting against that, I think it's just out of scope for Rust's safety guarantees. The same already holds for any of the other libraries that we link against, like rcl
– if we can't trust those, then it's game over anyway.
I don't know, but you know what, I'll just make it 16 bytes, it doesn't cost us anything really.
There is no prescribed alignment, it depends on the contents. So a message containing only |
@nnmm do you want to merge this one or shall we wait? |
As well as conversion from/to concrete message types.
It's clear logically that the alignment has to be 8, since C messages only contain pointers and primitive types of alignment less than or equal to 8 – with the exception of
long double
. Should we require dynamic messages to be aligned to 16 bytes to supportlong double
? Eventest_msgs
doesn't uselong double
.