-
Notifications
You must be signed in to change notification settings - Fork 743
Reintroduce bitfield accessors #567
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
Tests are failing because the travis ci gcc doesn't seem to understand
|
beb460c
to
75e9a00
Compare
Updated with an attempt to pass |
Strange... my local Fedora gcc has support for |
This commit reintroduces accessor methods for bitfields in the generated bindings. Fixes rust-lang#519
75e9a00
to
50ee737
Compare
Alright, removed the |
Instead of that, I think compiling with a newer |
I tried that, and travis's gcc complained that it didn't understand |
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.
r=me, this is awesome, thanks for bringing them back, and for the tests! :)
4 => quote_ty!(ctx.ext_cx(), u32), | ||
2 => quote_ty!(ctx.ext_cx(), u16), | ||
1 => quote_ty!(ctx.ext_cx(), u8), | ||
_ => panic!("physical field containing bitfields should be sized \ |
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.
well, I guess someone could make bindgen panic with something like: __u128 foo: 128
or something? If so, maybe we just want to skip the getter/setter?
(Not a big deal landing as-is for now)
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.
Oh good catch, I didn't think of that. I'll make an E-Easy issue to fix it.
pub fn $getter_name(&self) -> $bitfield_ty { | ||
let mask = $mask as $field_int_ty; | ||
let field_val: $field_int_ty = unsafe { | ||
::$prefix::mem::transmute(self.$field_ident) |
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.
nice way to not having to care about the alignment ;)
Thanks for the review! :) @bors-servo r=emilio |
📌 Commit 50ee737 has been approved by |
☀️ Test successful - status-travis |
This commit reintroduces accessor methods for bitfields in the generated
bindings.
Fixes #519
r? @emilio