-
Notifications
You must be signed in to change notification settings - Fork 151
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
Support pod
extern_cpp_types
#1193
Conversation
We now ensure that all extern_cpp_types are ingested by the ByValueChecker before it considers any structs.
quote! { | ||
|
||
extern_cpp_type!("VecThingy", crate::VecThingy) | ||
pod!("VecThingy") |
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.
Thinking about this a bit more: maybe this test should actually be failing, unless the target Rust type implements Copy
? IIUC, that's basically what pod!
expects?
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.
(as in, my example from the original issue should probably also fail because I forgot #[derive(Clopy, Copy)]
which is the only guarantee that the type is, in fact, trivial)
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.
Thoughts?
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.
Sorry, no time for autocxx at the moment - I will reply next time I get back to the project. (However your mental model of how pod!
works is wrong: I need to spend some time documenting exactly what are the expectations are for extern_cpp_type!
users in the POD and non-POD case.)
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 improved the documentation here in #1221.
TL;DR: deriving things in Rust is not material to whether things can be POD or non-POD; it's all about the nature of the pre-existing C++ constructors/destructors, and by the time we get as far as #[derive]
there's no way we can add extra C++ assertions.
Overall, this extern_cpp_type
facility was intended primarily for one set of autocxx bindings to refer to a type generated by some other autocxx/cxx bindings, i.e. cross-mod links, rather than for folks such as your good self to generate whole new fresh shiny Rust types. I've clarified that too.
For now added this to my project via |
Two questions. For example, I have a struct like this: struct RansacStats {
size_t refinements = 0;
size_t iterations = 0;
size_t num_inliers = 0;
double inlier_ratio = 0;
double model_score = std::numeric_limits<double>::max();
}; I generate it with
|
Wait... now I see at least generated |
On some classes it still doesn't exist, but that sounds like #1155. |
Test for #1192