Skip to content

Commit 0674f60

Browse files
author
bors-servo
authored
Auto merge of #279 - emilio:mangle-bitfield, r=fitzgen
codegen: Properly mangle bitfield getters. r? @fitzgen Fixes #278
2 parents 5317392 + 4cc53ed commit 0674f60

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

libbindgen/src/codegen/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ impl<'a> Bitfield<'a> {
596596
let field_type = field_item.to_rust_ty(ctx);
597597
let int_type = BlobTyBuilder::new(field_ty_layout).build();
598598

599-
let getter_name = ctx.ext_cx().ident_of(&field_name);
599+
let getter_name = ctx.rust_ident(&field_name);
600600
let setter_name = ctx.ext_cx()
601601
.ident_of(&format!("set_{}", &field_name));
602602
let mask = ((1usize << width) - 1) << offset;
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/* automatically generated by rust-bindgen */
2+
3+
4+
#![allow(non_snake_case)]
5+
6+
7+
#[repr(C)]
8+
#[derive(Debug, Copy)]
9+
pub struct _bindgen_ty_1 {
10+
pub _bitfield_1: u32,
11+
}
12+
#[test]
13+
fn bindgen_test_layout__bindgen_ty_1() {
14+
assert_eq!(::std::mem::size_of::<_bindgen_ty_1>() , 4usize);
15+
assert_eq!(::std::mem::align_of::<_bindgen_ty_1>() , 4usize);
16+
}
17+
impl Clone for _bindgen_ty_1 {
18+
fn clone(&self) -> Self { *self }
19+
}
20+
impl _bindgen_ty_1 {
21+
#[inline]
22+
pub fn pad3(&self) -> ::std::os::raw::c_uint {
23+
unsafe {
24+
::std::mem::transmute(((self._bitfield_1 & (16777215usize as u32))
25+
>> 0u32) as u32)
26+
}
27+
}
28+
#[inline]
29+
pub fn set_pad3(&mut self, val: ::std::os::raw::c_uint) {
30+
self._bitfield_1 &= !(16777215usize as u32);
31+
self._bitfield_1 |=
32+
((val as u32 as u32) << 0u32) & (16777215usize as u32);
33+
}
34+
#[inline]
35+
pub fn type_(&self) -> ::std::os::raw::c_uint {
36+
unsafe {
37+
::std::mem::transmute(((self._bitfield_1 &
38+
(4278190080usize as u32)) >> 24u32) as
39+
u32)
40+
}
41+
}
42+
#[inline]
43+
pub fn set_type(&mut self, val: ::std::os::raw::c_uint) {
44+
self._bitfield_1 &= !(4278190080usize as u32);
45+
self._bitfield_1 |=
46+
((val as u32 as u32) << 24u32) & (4278190080usize as u32);
47+
}
48+
}
49+
pub type mach_msg_type_descriptor_t = _bindgen_ty_1;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
typedef struct
2+
{
3+
unsigned int pad3: 24;
4+
unsigned int type: 8;
5+
} mach_msg_type_descriptor_t;

0 commit comments

Comments
 (0)