diff options
Diffstat (limited to 'tests')
114 files changed, 2202 insertions, 1546 deletions
diff --git a/tests/expectations/accessors.rs b/tests/expectations/accessors.rs index 8d314878..b721980c 100644 --- a/tests/expectations/accessors.rs +++ b/tests/expectations/accessors.rs @@ -6,7 +6,7 @@ #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_SomeAccessors { +pub struct SomeAccessors { pub mNoAccessor: ::std::os::raw::c_int, /** <div rustbindgen accessor></div> */ pub mBothAccessors: ::std::os::raw::c_int, @@ -15,11 +15,20 @@ pub struct Struct_SomeAccessors { /** <div rustbindgen accessor="immutable"></div> */ pub mImmutableAccessor: ::std::os::raw::c_int, } -impl Struct_SomeAccessors { +#[test] +fn bindgen_test_layout_SomeAccessors() { + assert_eq!(::std::mem::size_of::<SomeAccessors>() , 16usize); + assert_eq!(::std::mem::align_of::<SomeAccessors>() , 4usize); +} +impl Clone for SomeAccessors { + fn clone(&self) -> Self { *self } +} +impl SomeAccessors { #[inline] pub fn get_mBothAccessors(&self) -> &::std::os::raw::c_int { &self.mBothAccessors } + #[inline] pub fn get_mBothAccessors_mut(&mut self) -> &mut ::std::os::raw::c_int { &mut self.mBothAccessors } @@ -27,6 +36,7 @@ impl Struct_SomeAccessors { pub unsafe fn get_mUnsafeAccessors(&self) -> &::std::os::raw::c_int { &self.mUnsafeAccessors } + #[inline] pub unsafe fn get_mUnsafeAccessors_mut(&mut self) -> &mut ::std::os::raw::c_int { &mut self.mUnsafeAccessors @@ -36,26 +46,27 @@ impl Struct_SomeAccessors { &self.mImmutableAccessor } } -impl ::std::clone::Clone for Struct_SomeAccessors { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_Struct_SomeAccessors() { - assert_eq!(::std::mem::size_of::<Struct_SomeAccessors>() , 16usize); - assert_eq!(::std::mem::align_of::<Struct_SomeAccessors>() , 4usize); -} /** <div rustbindgen accessor></div> */ #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_AllAccessors { +pub struct AllAccessors { pub mBothAccessors: ::std::os::raw::c_int, pub mAlsoBothAccessors: ::std::os::raw::c_int, } -impl Struct_AllAccessors { +#[test] +fn bindgen_test_layout_AllAccessors() { + assert_eq!(::std::mem::size_of::<AllAccessors>() , 8usize); + assert_eq!(::std::mem::align_of::<AllAccessors>() , 4usize); +} +impl Clone for AllAccessors { + fn clone(&self) -> Self { *self } +} +impl AllAccessors { #[inline] pub fn get_mBothAccessors(&self) -> &::std::os::raw::c_int { &self.mBothAccessors } + #[inline] pub fn get_mBothAccessors_mut(&mut self) -> &mut ::std::os::raw::c_int { &mut self.mBothAccessors } @@ -63,31 +74,33 @@ impl Struct_AllAccessors { pub fn get_mAlsoBothAccessors(&self) -> &::std::os::raw::c_int { &self.mAlsoBothAccessors } + #[inline] pub fn get_mAlsoBothAccessors_mut(&mut self) -> &mut ::std::os::raw::c_int { &mut self.mAlsoBothAccessors } } -impl ::std::clone::Clone for Struct_AllAccessors { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_Struct_AllAccessors() { - assert_eq!(::std::mem::size_of::<Struct_AllAccessors>() , 8usize); - assert_eq!(::std::mem::align_of::<Struct_AllAccessors>() , 4usize); -} /** <div rustbindgen accessor="unsafe"></div> */ #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_AllUnsafeAccessors { +pub struct AllUnsafeAccessors { pub mBothAccessors: ::std::os::raw::c_int, pub mAlsoBothAccessors: ::std::os::raw::c_int, } -impl Struct_AllUnsafeAccessors { +#[test] +fn bindgen_test_layout_AllUnsafeAccessors() { + assert_eq!(::std::mem::size_of::<AllUnsafeAccessors>() , 8usize); + assert_eq!(::std::mem::align_of::<AllUnsafeAccessors>() , 4usize); +} +impl Clone for AllUnsafeAccessors { + fn clone(&self) -> Self { *self } +} +impl AllUnsafeAccessors { #[inline] pub unsafe fn get_mBothAccessors(&self) -> &::std::os::raw::c_int { &self.mBothAccessors } + #[inline] pub unsafe fn get_mBothAccessors_mut(&mut self) -> &mut ::std::os::raw::c_int { &mut self.mBothAccessors @@ -96,23 +109,16 @@ impl Struct_AllUnsafeAccessors { pub unsafe fn get_mAlsoBothAccessors(&self) -> &::std::os::raw::c_int { &self.mAlsoBothAccessors } + #[inline] pub unsafe fn get_mAlsoBothAccessors_mut(&mut self) -> &mut ::std::os::raw::c_int { &mut self.mAlsoBothAccessors } } -impl ::std::clone::Clone for Struct_AllUnsafeAccessors { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_Struct_AllUnsafeAccessors() { - assert_eq!(::std::mem::size_of::<Struct_AllUnsafeAccessors>() , 8usize); - assert_eq!(::std::mem::align_of::<Struct_AllUnsafeAccessors>() , 4usize); -} /** <div rustbindgen accessor></div> */ #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_ContradictAccessors { +pub struct ContradictAccessors { pub mBothAccessors: ::std::os::raw::c_int, /** <div rustbindgen accessor="false"></div> */ pub mNoAccessors: ::std::os::raw::c_int, @@ -121,11 +127,20 @@ pub struct Struct_ContradictAccessors { /** <div rustbindgen accessor="immutable"></div> */ pub mImmutableAccessor: ::std::os::raw::c_int, } -impl Struct_ContradictAccessors { +#[test] +fn bindgen_test_layout_ContradictAccessors() { + assert_eq!(::std::mem::size_of::<ContradictAccessors>() , 16usize); + assert_eq!(::std::mem::align_of::<ContradictAccessors>() , 4usize); +} +impl Clone for ContradictAccessors { + fn clone(&self) -> Self { *self } +} +impl ContradictAccessors { #[inline] pub fn get_mBothAccessors(&self) -> &::std::os::raw::c_int { &self.mBothAccessors } + #[inline] pub fn get_mBothAccessors_mut(&mut self) -> &mut ::std::os::raw::c_int { &mut self.mBothAccessors } @@ -133,6 +148,7 @@ impl Struct_ContradictAccessors { pub unsafe fn get_mUnsafeAccessors(&self) -> &::std::os::raw::c_int { &self.mUnsafeAccessors } + #[inline] pub unsafe fn get_mUnsafeAccessors_mut(&mut self) -> &mut ::std::os::raw::c_int { &mut self.mUnsafeAccessors @@ -142,53 +158,47 @@ impl Struct_ContradictAccessors { &self.mImmutableAccessor } } -impl ::std::clone::Clone for Struct_ContradictAccessors { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_Struct_ContradictAccessors() { - assert_eq!(::std::mem::size_of::<Struct_ContradictAccessors>() , 16usize); - assert_eq!(::std::mem::align_of::<Struct_ContradictAccessors>() , 4usize); -} /** <div rustbindgen accessor replaces="Replaced"></div> */ #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_Replaced { +pub struct Replaced { pub mAccessor: ::std::os::raw::c_int, } -impl Struct_Replaced { +#[test] +fn bindgen_test_layout_Replaced() { + assert_eq!(::std::mem::size_of::<Replaced>() , 4usize); + assert_eq!(::std::mem::align_of::<Replaced>() , 4usize); +} +impl Clone for Replaced { + fn clone(&self) -> Self { *self } +} +impl Replaced { #[inline] pub fn get_mAccessor(&self) -> &::std::os::raw::c_int { &self.mAccessor } + #[inline] pub fn get_mAccessor_mut(&mut self) -> &mut ::std::os::raw::c_int { &mut self.mAccessor } } -impl ::std::clone::Clone for Struct_Replaced { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_Struct_Replaced() { - assert_eq!(::std::mem::size_of::<Struct_Replaced>() , 4usize); - assert_eq!(::std::mem::align_of::<Struct_Replaced>() , 4usize); -} /** <div rustbindgen accessor></div> */ #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_Wrapper { - pub mReplaced: Struct_Replaced, +pub struct Wrapper { + pub mReplaced: Replaced, } -impl Struct_Wrapper { - #[inline] - pub fn get_mReplaced(&self) -> &Struct_Replaced { &self.mReplaced } - pub fn get_mReplaced_mut(&mut self) -> &mut Struct_Replaced { - &mut self.mReplaced - } +#[test] +fn bindgen_test_layout_Wrapper() { + assert_eq!(::std::mem::size_of::<Wrapper>() , 4usize); + assert_eq!(::std::mem::align_of::<Wrapper>() , 4usize); } -impl ::std::clone::Clone for Struct_Wrapper { +impl Clone for Wrapper { fn clone(&self) -> Self { *self } } -#[test] -fn bindgen_test_layout_Struct_Wrapper() { - assert_eq!(::std::mem::size_of::<Struct_Wrapper>() , 4usize); - assert_eq!(::std::mem::align_of::<Struct_Wrapper>() , 4usize); +impl Wrapper { + #[inline] + pub fn get_mReplaced(&self) -> &Replaced { &self.mReplaced } + #[inline] + pub fn get_mReplaced_mut(&mut self) -> &mut Replaced { + &mut self.mReplaced + } } diff --git a/tests/expectations/annotation_hide.rs b/tests/expectations/annotation_hide.rs index 14ba8310..dcaf7997 100644 --- a/tests/expectations/annotation_hide.rs +++ b/tests/expectations/annotation_hide.rs @@ -4,8 +4,11 @@ #![allow(non_snake_case)] -pub enum Struct_C { } +/** + * <div rustbindgen opaque></div> + */ #[repr(C)] +#[derive(Debug, Copy)] pub struct D { pub _bindgen_opaque_blob: u32, } @@ -14,16 +17,19 @@ fn bindgen_test_layout_D() { assert_eq!(::std::mem::size_of::<D>() , 4usize); assert_eq!(::std::mem::align_of::<D>() , 4usize); } +impl Clone for D { + fn clone(&self) -> Self { *self } +} #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_NotAnnotated { +pub struct NotAnnotated { pub f: ::std::os::raw::c_int, } -impl ::std::clone::Clone for Struct_NotAnnotated { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_NotAnnotated() { - assert_eq!(::std::mem::size_of::<Struct_NotAnnotated>() , 4usize); - assert_eq!(::std::mem::align_of::<Struct_NotAnnotated>() , 4usize); +fn bindgen_test_layout_NotAnnotated() { + assert_eq!(::std::mem::size_of::<NotAnnotated>() , 4usize); + assert_eq!(::std::mem::align_of::<NotAnnotated>() , 4usize); +} +impl Clone for NotAnnotated { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/anon_enum.rs b/tests/expectations/anon_enum.rs new file mode 100644 index 00000000..6b8688e1 --- /dev/null +++ b/tests/expectations/anon_enum.rs @@ -0,0 +1,23 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Test { + pub foo: ::std::os::raw::c_int, + pub bar: f32, +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum Test__bindgen_ty_bindgen_id_4 { T_NONE = 0, } +#[test] +fn bindgen_test_layout_Test() { + assert_eq!(::std::mem::size_of::<Test>() , 8usize); + assert_eq!(::std::mem::align_of::<Test>() , 4usize); +} +impl Clone for Test { + fn clone(&self) -> Self { *self } +} diff --git a/tests/expectations/anon_enum_whitelist.rs b/tests/expectations/anon_enum_whitelist.rs new file mode 100644 index 00000000..62c1f1a5 --- /dev/null +++ b/tests/expectations/anon_enum_whitelist.rs @@ -0,0 +1,13 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +pub const NODE_FLAG_FOO: _bindgen_ty_bindgen_id_1 = + _bindgen_ty_bindgen_id_1::NODE_FLAG_FOO; +pub const NODE_FLAG_BAR: _bindgen_ty_bindgen_id_1 = + _bindgen_ty_bindgen_id_1::NODE_FLAG_BAR; +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum _bindgen_ty_bindgen_id_1 { NODE_FLAG_FOO = 0, NODE_FLAG_BAR = 1, } diff --git a/tests/expectations/anon_union.rs b/tests/expectations/anon_union.rs new file mode 100644 index 00000000..66963f40 --- /dev/null +++ b/tests/expectations/anon_union.rs @@ -0,0 +1,73 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[derive(Debug)] +#[repr(C)] +pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>); +impl <T> __BindgenUnionField<T> { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } +} +impl <T> ::std::default::Default for __BindgenUnionField<T> { + #[inline] + fn default() -> Self { Self::new() } +} +impl <T> ::std::clone::Clone for __BindgenUnionField<T> { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl <T> ::std::marker::Copy for __BindgenUnionField<T> { } +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct TErrorResult<T> { + pub mResult: ::std::os::raw::c_int, + pub __bindgen_anon_1: TErrorResult__bindgen_ty_bindgen_id_9<T>, + pub mMightHaveUnreported: bool, + pub mUnionState: TErrorResult_UnionState, + pub _phantom_0: ::std::marker::PhantomData<T>, +} +pub const TErrorResult_UnionState_HasException: TErrorResult_UnionState = + TErrorResult_UnionState::HasMessage; +#[repr(i32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum TErrorResult_UnionState { HasMessage = 0, } +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct TErrorResult_Message<T> { + pub _address: u8, + pub _phantom_0: ::std::marker::PhantomData<T>, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct TErrorResult_DOMExceptionInfo<T> { + pub _address: u8, + pub _phantom_0: ::std::marker::PhantomData<T>, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct TErrorResult__bindgen_ty_bindgen_id_9<T> { + pub mMessage: __BindgenUnionField<*mut TErrorResult_Message<T>>, + pub mDOMExceptionInfo: __BindgenUnionField<*mut TErrorResult_DOMExceptionInfo<T>>, + pub bindgen_union_field: u64, + pub _phantom_0: ::std::marker::PhantomData<T>, +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct ErrorResult { + pub _base: TErrorResult<::std::os::raw::c_int>, +} +#[test] +fn bindgen_test_layout_ErrorResult() { + assert_eq!(::std::mem::size_of::<ErrorResult>() , 24usize); + assert_eq!(::std::mem::align_of::<ErrorResult>() , 8usize); +} +impl Clone for ErrorResult { + fn clone(&self) -> Self { *self } +} diff --git a/tests/expectations/arg_keyword.rs b/tests/expectations/arg_keyword.rs new file mode 100644 index 00000000..cb1cc432 --- /dev/null +++ b/tests/expectations/arg_keyword.rs @@ -0,0 +1,10 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +extern "C" { + #[link_name = "_Z3fooPKc"] + pub fn foo(type_: *const ::std::os::raw::c_char); +} diff --git a/tests/expectations/class.rs b/tests/expectations/class.rs index 450a57a6..5951e0e6 100644 --- a/tests/expectations/class.rs +++ b/tests/expectations/class.rs @@ -4,7 +4,7 @@ #![allow(non_snake_case)] -#[derive(Copy, Debug)] +#[derive(Debug)] #[repr(C)] pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>); impl <T> __BindgenUnionField<T> { @@ -23,65 +23,52 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> { #[inline] fn clone(&self) -> Self { Self::new() } } +impl <T> ::std::marker::Copy for __BindgenUnionField<T> { } #[repr(C)] -#[derive(Copy)] -pub struct Struct_C { +pub struct C { pub a: ::std::os::raw::c_int, pub big_array: [::std::os::raw::c_char; 33usize], } -impl ::std::clone::Clone for Struct_C { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_C() { - assert_eq!(::std::mem::size_of::<Struct_C>() , 40usize); - assert_eq!(::std::mem::align_of::<Struct_C>() , 4usize); +fn bindgen_test_layout_C() { + assert_eq!(::std::mem::size_of::<C>() , 40usize); + assert_eq!(::std::mem::align_of::<C>() , 4usize); } #[repr(C)] #[derive(Debug)] -pub struct Struct_WithDtor { +pub struct WithDtor { pub b: ::std::os::raw::c_int, } #[test] -fn bindgen_test_layout_Struct_WithDtor() { - assert_eq!(::std::mem::size_of::<Struct_WithDtor>() , 4usize); - assert_eq!(::std::mem::align_of::<Struct_WithDtor>() , 4usize); +fn bindgen_test_layout_WithDtor() { + assert_eq!(::std::mem::size_of::<WithDtor>() , 4usize); + assert_eq!(::std::mem::align_of::<WithDtor>() , 4usize); } #[repr(C)] #[derive(Debug, Copy)] -pub struct Union_Union { +pub struct Union { pub d: __BindgenUnionField<f32>, pub i: __BindgenUnionField<::std::os::raw::c_int>, - pub _bindgen_data_: u32, + pub bindgen_union_field: u32, } -impl Union_Union { - pub unsafe fn d(&mut self) -> *mut f32 { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn i(&mut self) -> *mut ::std::os::raw::c_int { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } +#[test] +fn bindgen_test_layout_Union() { + assert_eq!(::std::mem::size_of::<Union>() , 4usize); + assert_eq!(::std::mem::align_of::<Union>() , 4usize); } -impl ::std::clone::Clone for Union_Union { +impl Clone for Union { fn clone(&self) -> Self { *self } } -#[test] -fn bindgen_test_layout_Union_Union() { - assert_eq!(::std::mem::size_of::<Union_Union>() , 4usize); - assert_eq!(::std::mem::align_of::<Union_Union>() , 4usize); -} #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_WithUnion { - pub data: Union_Union, -} -impl ::std::clone::Clone for Struct_WithUnion { - fn clone(&self) -> Self { *self } +pub struct WithUnion { + pub data: Union, } #[test] -fn bindgen_test_layout_Struct_WithUnion() { - assert_eq!(::std::mem::size_of::<Struct_WithUnion>() , 4usize); - assert_eq!(::std::mem::align_of::<Struct_WithUnion>() , 4usize); +fn bindgen_test_layout_WithUnion() { + assert_eq!(::std::mem::size_of::<WithUnion>() , 4usize); + assert_eq!(::std::mem::align_of::<WithUnion>() , 4usize); +} +impl Clone for WithUnion { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/class_nested.rs b/tests/expectations/class_nested.rs index 22e72209..593e156d 100644 --- a/tests/expectations/class_nested.rs +++ b/tests/expectations/class_nested.rs @@ -6,53 +6,54 @@ #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_A { +pub struct A { pub member_a: ::std::os::raw::c_int, } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_A_B { +pub struct A_B { pub member_b: ::std::os::raw::c_int, } -impl ::std::clone::Clone for Struct_A_B { +#[test] +fn bindgen_test_layout_A_B() { + assert_eq!(::std::mem::size_of::<A_B>() , 4usize); + assert_eq!(::std::mem::align_of::<A_B>() , 4usize); +} +impl Clone for A_B { fn clone(&self) -> Self { *self } } #[test] -fn bindgen_test_layout_Struct_A_B() { - assert_eq!(::std::mem::size_of::<Struct_A_B>() , 4usize); - assert_eq!(::std::mem::align_of::<Struct_A_B>() , 4usize); +fn bindgen_test_layout_A() { + assert_eq!(::std::mem::size_of::<A>() , 4usize); + assert_eq!(::std::mem::align_of::<A>() , 4usize); } -impl ::std::clone::Clone for Struct_A { +impl Clone for A { fn clone(&self) -> Self { *self } } -#[test] -fn bindgen_test_layout_Struct_A() { - assert_eq!(::std::mem::size_of::<Struct_A>() , 4usize); - assert_eq!(::std::mem::align_of::<Struct_A>() , 4usize); +extern "C" { + #[link_name = "var"] + pub static mut var: A_B; } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_D { - pub member: Struct_A_B, -} -impl ::std::clone::Clone for Struct_D { - fn clone(&self) -> Self { *self } +pub struct D { + pub member: A_B, } #[test] -fn bindgen_test_layout_Struct_D() { - assert_eq!(::std::mem::size_of::<Struct_D>() , 4usize); - assert_eq!(::std::mem::align_of::<Struct_D>() , 4usize); +fn bindgen_test_layout_D() { + assert_eq!(::std::mem::size_of::<D>() , 4usize); + assert_eq!(::std::mem::align_of::<D>() , 4usize); +} +impl Clone for D { + fn clone(&self) -> Self { *self } } #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct Struct_Templated<T> { +pub struct Templated<T> { pub member: T, } #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct Struct_Templated_Templated_inner<T> { +pub struct Templated_Templated_inner<T> { pub member_ptr: *mut T, } -extern "C" { - pub static mut var: Struct_A_B; -} diff --git a/tests/expectations/class_no_members.rs b/tests/expectations/class_no_members.rs index 8468c02b..017f7c22 100644 --- a/tests/expectations/class_no_members.rs +++ b/tests/expectations/class_no_members.rs @@ -6,31 +6,40 @@ #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_whatever; -impl ::std::clone::Clone for Struct_whatever { +pub struct whatever { + pub _address: u8, +} +#[test] +fn bindgen_test_layout_whatever() { + assert_eq!(::std::mem::size_of::<whatever>() , 1usize); + assert_eq!(::std::mem::align_of::<whatever>() , 1usize); +} +impl Clone for whatever { fn clone(&self) -> Self { *self } } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_whatever_child { - pub _base: Struct_whatever, +pub struct whatever_child { + pub _address: u8, +} +#[test] +fn bindgen_test_layout_whatever_child() { + assert_eq!(::std::mem::size_of::<whatever_child>() , 1usize); + assert_eq!(::std::mem::align_of::<whatever_child>() , 1usize); } -impl ::std::clone::Clone for Struct_whatever_child { +impl Clone for whatever_child { fn clone(&self) -> Self { *self } } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_whatever_child_with_member { - pub _base: Struct_whatever, +pub struct whatever_child_with_member { pub m_member: ::std::os::raw::c_int, } -impl ::std::clone::Clone for Struct_whatever_child_with_member { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_whatever_child_with_member() { - assert_eq!(::std::mem::size_of::<Struct_whatever_child_with_member>() , - 4usize); - assert_eq!(::std::mem::align_of::<Struct_whatever_child_with_member>() , - 4usize); +fn bindgen_test_layout_whatever_child_with_member() { + assert_eq!(::std::mem::size_of::<whatever_child_with_member>() , 4usize); + assert_eq!(::std::mem::align_of::<whatever_child_with_member>() , 4usize); +} +impl Clone for whatever_child_with_member { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/class_static.rs b/tests/expectations/class_static.rs index 8aa156d8..8108be2d 100644 --- a/tests/expectations/class_static.rs +++ b/tests/expectations/class_static.rs @@ -6,15 +6,27 @@ #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_MyClass; -impl ::std::clone::Clone for Struct_MyClass { - fn clone(&self) -> Self { *self } +pub struct MyClass { + pub _address: u8, } extern "C" { #[link_name = "_ZN7MyClass7exampleE"] - pub static mut Struct_MyClass_consts_example: - *const ::std::os::raw::c_int; + pub static mut MyClass_example: *const ::std::os::raw::c_int; +} +extern "C" { #[link_name = "_ZN7MyClass26example_check_no_collisionE"] - pub static mut Struct_MyClass_consts_example_check_no_collision: + pub static mut MyClass_example_check_no_collision: *const ::std::os::raw::c_int; } +#[test] +fn bindgen_test_layout_MyClass() { + assert_eq!(::std::mem::size_of::<MyClass>() , 1usize); + assert_eq!(::std::mem::align_of::<MyClass>() , 1usize); +} +impl Clone for MyClass { + fn clone(&self) -> Self { *self } +} +extern "C" { + #[link_name = "_ZL26example_check_no_collision"] + pub static mut example_check_no_collision: *const ::std::os::raw::c_int; +} diff --git a/tests/expectations/class_use_as.rs b/tests/expectations/class_use_as.rs index 4d06feca..c3843b31 100644 --- a/tests/expectations/class_use_as.rs +++ b/tests/expectations/class_use_as.rs @@ -9,27 +9,27 @@ */ #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_whatever { +pub struct whatever { pub replacement: ::std::os::raw::c_int, } -impl ::std::clone::Clone for Struct_whatever { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_whatever() { - assert_eq!(::std::mem::size_of::<Struct_whatever>() , 4usize); - assert_eq!(::std::mem::align_of::<Struct_whatever>() , 4usize); +fn bindgen_test_layout_whatever() { + assert_eq!(::std::mem::size_of::<whatever>() , 4usize); + assert_eq!(::std::mem::align_of::<whatever>() , 4usize); +} +impl Clone for whatever { + fn clone(&self) -> Self { *self } } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_container { - pub c: Struct_whatever, -} -impl ::std::clone::Clone for Struct_container { - fn clone(&self) -> Self { *self } +pub struct container { + pub c: whatever, } #[test] -fn bindgen_test_layout_Struct_container() { - assert_eq!(::std::mem::size_of::<Struct_container>() , 4usize); - assert_eq!(::std::mem::align_of::<Struct_container>() , 4usize); +fn bindgen_test_layout_container() { + assert_eq!(::std::mem::size_of::<container>() , 4usize); + assert_eq!(::std::mem::align_of::<container>() , 4usize); +} +impl Clone for container { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/class_with_dtor.rs b/tests/expectations/class_with_dtor.rs index 3cc48dfb..8ed1ddf9 100644 --- a/tests/expectations/class_with_dtor.rs +++ b/tests/expectations/class_with_dtor.rs @@ -6,17 +6,17 @@ #[repr(C)] #[derive(Debug)] -pub struct Struct_HandleWithDtor<T> { +pub struct HandleWithDtor<T> { pub ptr: *mut T, } -pub type HandleValue = Struct_HandleWithDtor<::std::os::raw::c_int>; +pub type HandleValue = HandleWithDtor<::std::os::raw::c_int>; #[repr(C)] #[derive(Debug)] -pub struct Struct_WithoutDtor { +pub struct WithoutDtor { pub shouldBeWithDtor: HandleValue, } #[test] -fn bindgen_test_layout_Struct_WithoutDtor() { - assert_eq!(::std::mem::size_of::<Struct_WithoutDtor>() , 8usize); - assert_eq!(::std::mem::align_of::<Struct_WithoutDtor>() , 8usize); +fn bindgen_test_layout_WithoutDtor() { + assert_eq!(::std::mem::size_of::<WithoutDtor>() , 8usize); + assert_eq!(::std::mem::align_of::<WithoutDtor>() , 8usize); } diff --git a/tests/expectations/class_with_inner_struct.rs b/tests/expectations/class_with_inner_struct.rs index b465a183..464c622d 100644 --- a/tests/expectations/class_with_inner_struct.rs +++ b/tests/expectations/class_with_inner_struct.rs @@ -4,7 +4,7 @@ #![allow(non_snake_case)] -#[derive(Copy, Debug)] +#[derive(Debug)] #[repr(C)] pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>); impl <T> __BindgenUnionField<T> { @@ -23,109 +23,94 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> { #[inline] fn clone(&self) -> Self { Self::new() } } +impl <T> ::std::marker::Copy for __BindgenUnionField<T> { } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_A { +pub struct A { pub c: ::std::os::raw::c_uint, - pub named_union: Union_A_class_with_inner_struct_hpp_unnamed_1, - pub A_class_with_inner_struct_hpp_unnamed_2: Union_A_class_with_inner_struct_hpp_unnamed_2, + pub named_union: A__bindgen_ty_bindgen_id_6, + pub __bindgen_anon_1: A__bindgen_ty_bindgen_id_9, } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_A_Segment { +pub struct A_Segment { pub begin: ::std::os::raw::c_int, pub end: ::std::os::raw::c_int, } -impl ::std::clone::Clone for Struct_A_Segment { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_A_Segment() { - assert_eq!(::std::mem::size_of::<Struct_A_Segment>() , 8usize); - assert_eq!(::std::mem::align_of::<Struct_A_Segment>() , 4usize); +fn bindgen_test_layout_A_Segment() { + assert_eq!(::std::mem::size_of::<A_Segment>() , 8usize); + assert_eq!(::std::mem::align_of::<A_Segment>() , 4usize); +} +impl Clone for A_Segment { + fn clone(&self) -> Self { *self } } #[repr(C)] #[derive(Debug, Copy)] -pub struct Union_A_class_with_inner_struct_hpp_unnamed_1 { +pub struct A__bindgen_ty_bindgen_id_6 { pub f: __BindgenUnionField<::std::os::raw::c_int>, - pub _bindgen_data_: u32, + pub bindgen_union_field: u32, } -impl Union_A_class_with_inner_struct_hpp_unnamed_1 { - pub unsafe fn f(&mut self) -> *mut ::std::os::raw::c_int { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } +#[test] +fn bindgen_test_layout_A__bindgen_ty_bindgen_id_6() { + assert_eq!(::std::mem::size_of::<A__bindgen_ty_bindgen_id_6>() , 4usize); + assert_eq!(::std::mem::align_of::<A__bindgen_ty_bindgen_id_6>() , 4usize); } -impl ::std::clone::Clone for Union_A_class_with_inner_struct_hpp_unnamed_1 { +impl Clone for A__bindgen_ty_bindgen_id_6 { fn clone(&self) -> Self { *self } } -#[test] -fn bindgen_test_layout_Union_A_class_with_inner_struct_hpp_unnamed_1() { - assert_eq!(::std::mem::size_of::<Union_A_class_with_inner_struct_hpp_unnamed_1>() - , 4usize); - assert_eq!(::std::mem::align_of::<Union_A_class_with_inner_struct_hpp_unnamed_1>() - , 4usize); -} #[repr(C)] #[derive(Debug, Copy)] -pub struct Union_A_class_with_inner_struct_hpp_unnamed_2 { +pub struct A__bindgen_ty_bindgen_id_9 { pub d: __BindgenUnionField<::std::os::raw::c_int>, - pub _bindgen_data_: u32, + pub bindgen_union_field: u32, } -impl Union_A_class_with_inner_struct_hpp_unnamed_2 { - pub unsafe fn d(&mut self) -> *mut ::std::os::raw::c_int { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } +#[test] +fn bindgen_test_layout_A__bindgen_ty_bindgen_id_9() { + assert_eq!(::std::mem::size_of::<A__bindgen_ty_bindgen_id_9>() , 4usize); + assert_eq!(::std::mem::align_of::<A__bindgen_ty_bindgen_id_9>() , 4usize); } -impl ::std::clone::Clone for Union_A_class_with_inner_struct_hpp_unnamed_2 { +impl Clone for A__bindgen_ty_bindgen_id_9 { fn clone(&self) -> Self { *self } } #[test] -fn bindgen_test_layout_Union_A_class_with_inner_struct_hpp_unnamed_2() { - assert_eq!(::std::mem::size_of::<Union_A_class_with_inner_struct_hpp_unnamed_2>() - , 4usize); - assert_eq!(::std::mem::align_of::<Union_A_class_with_inner_struct_hpp_unnamed_2>() - , 4usize); +fn bindgen_test_layout_A() { + assert_eq!(::std::mem::size_of::<A>() , 12usize); + assert_eq!(::std::mem::align_of::<A>() , 4usize); } -impl ::std::clone::Clone for Struct_A { +impl Clone for A { fn clone(&self) -> Self { *self } } -#[test] -fn bindgen_test_layout_Struct_A() { - assert_eq!(::std::mem::size_of::<Struct_A>() , 12usize); - assert_eq!(::std::mem::align_of::<Struct_A>() , 4usize); -} #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_B { +pub struct B { pub d: ::std::os::raw::c_uint, } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_B_Segment { +pub struct B_Segment { pub begin: ::std::os::raw::c_int, pub end: ::std::os::raw::c_int, } -impl ::std::clone::Clone for Struct_B_Segment { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_B_Segment() { - assert_eq!(::std::mem::size_of::<Struct_B_Segment>() , 8usize); - assert_eq!(::std::mem::align_of::<Struct_B_Segment>() , 4usize); +fn bindgen_test_layout_B_Segment() { + assert_eq!(::std::mem::size_of::<B_Segment>() , 8usize); + assert_eq!(::std::mem::align_of::<B_Segment>() , 4usize); } -impl ::std::clone::Clone for Struct_B { +impl Clone for B_Segment { fn clone(&self) -> Self { *self } } #[test] -fn bindgen_test_layout_Struct_B() { - assert_eq!(::std::mem::size_of::<Struct_B>() , 4usize); - assert_eq!(::std::mem::align_of::<Struct_B>() , 4usize); +fn bindgen_test_layout_B() { + assert_eq!(::std::mem::size_of::<B>() , 4usize); + assert_eq!(::std::mem::align_of::<B>() , 4usize); +} +impl Clone for B { + fn clone(&self) -> Self { *self } } #[repr(i32)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -pub enum Enum_StepSyntax { +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum StepSyntax { Keyword = 0, FunctionalWithoutKeyword = 1, FunctionalWithStartKeyword = 2, @@ -133,98 +118,80 @@ pub enum Enum_StepSyntax { } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_C { +pub struct C { pub d: ::std::os::raw::c_uint, - pub C_class_with_inner_struct_hpp_unnamed_3: Union_C_class_with_inner_struct_hpp_unnamed_3, + pub __bindgen_anon_1: C__bindgen_ty_bindgen_id_21, } #[repr(C)] #[derive(Debug, Copy)] -pub struct Union_C_class_with_inner_struct_hpp_unnamed_3 { - pub mFunc: __BindgenUnionField<Struct_C_class_with_inner_struct_hpp_unnamed_3_class_with_inner_struct_hpp_unnamed_4>, - pub C_class_with_inner_struct_hpp_unnamed_3_class_with_inner_struct_hpp_unnamed_5: __BindgenUnionField<Struct_C_class_with_inner_struct_hpp_unnamed_3_class_with_inner_struct_hpp_unnamed_5>, - pub _bindgen_data_: [u32; 4usize], -} -impl Union_C_class_with_inner_struct_hpp_unnamed_3 { - pub unsafe fn mFunc(&mut self) - -> - *mut Struct_C_class_with_inner_struct_hpp_unnamed_3_class_with_inner_struct_hpp_unnamed_4 { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn C_class_with_inner_struct_hpp_unnamed_3_class_with_inner_struct_hpp_unnamed_5(&mut self) - -> - *mut Struct_C_class_with_inner_struct_hpp_unnamed_3_class_with_inner_struct_hpp_unnamed_5 { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } -} -impl ::std::clone::Clone for Union_C_class_with_inner_struct_hpp_unnamed_3 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_Union_C_class_with_inner_struct_hpp_unnamed_3() { - assert_eq!(::std::mem::size_of::<Union_C_class_with_inner_struct_hpp_unnamed_3>() - , 16usize); - assert_eq!(::std::mem::align_of::<Union_C_class_with_inner_struct_hpp_unnamed_3>() - , 4usize); +pub struct C__bindgen_ty_bindgen_id_21 { + pub mFunc: __BindgenUnionField<C__bindgen_ty_bindgen_id_21__bindgen_ty_bindgen_id_22>, + pub __bindgen_anon_1: __BindgenUnionField<C__bindgen_ty_bindgen_id_21__bindgen_ty_bindgen_id_28>, + pub bindgen_union_field: [u32; 4usize], } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_C_class_with_inner_struct_hpp_unnamed_3_class_with_inner_struct_hpp_unnamed_4 { +pub struct C__bindgen_ty_bindgen_id_21__bindgen_ty_bindgen_id_22 { pub mX1: f32, pub mY1: f32, pub mX2: f32, pub mY2: f32, } -impl ::std::clone::Clone for - Struct_C_class_with_inner_struct_hpp_unnamed_3_class_with_inner_struct_hpp_unnamed_4 - { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_C_class_with_inner_struct_hpp_unnamed_3_class_with_inner_struct_hpp_unnamed_4() { - assert_eq!(::std::mem::size_of::<Struct_C_class_with_inner_struct_hpp_unnamed_3_class_with_inner_struct_hpp_unnamed_4>() +fn bindgen_test_layout_C__bindgen_ty_bindgen_id_21__bindgen_ty_bindgen_id_22() { + assert_eq!(::std::mem::size_of::<C__bindgen_ty_bindgen_id_21__bindgen_ty_bindgen_id_22>() , 16usize); - assert_eq!(::std::mem::align_of::<Struct_C_class_with_inner_struct_hpp_unnamed_3_class_with_inner_struct_hpp_unnamed_4>() + assert_eq!(::std::mem::align_of::<C__bindgen_ty_bindgen_id_21__bindgen_ty_bindgen_id_22>() , 4usize); } +impl Clone for C__bindgen_ty_bindgen_id_21__bindgen_ty_bindgen_id_22 { + fn clone(&self) -> Self { *self } +} #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_C_class_with_inner_struct_hpp_unnamed_3_class_with_inner_struct_hpp_unnamed_5 { - pub mStepSyntax: Enum_StepSyntax, +pub struct C__bindgen_ty_bindgen_id_21__bindgen_ty_bindgen_id_28 { + pub mStepSyntax: StepSyntax, pub mSteps: ::std::os::raw::c_uint, } -impl ::std::clone::Clone for - Struct_C_class_with_inner_struct_hpp_unnamed_3_class_with_inner_struct_hpp_unnamed_5 - { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_C_class_with_inner_struct_hpp_unnamed_3_class_with_inner_struct_hpp_unnamed_5() { - assert_eq!(::std::mem::size_of::<Struct_C_class_with_inner_struct_hpp_unnamed_3_class_with_inner_struct_hpp_unnamed_5>() +fn bindgen_test_layout_C__bindgen_ty_bindgen_id_21__bindgen_ty_bindgen_id_28() { + assert_eq!(::std::mem::size_of::<C__bindgen_ty_bindgen_id_21__bindgen_ty_bindgen_id_28>() , 8usize); - assert_eq!(::std::mem::align_of::<Struct_C_class_with_inner_struct_hpp_unnamed_3_class_with_inner_struct_hpp_unnamed_5>() + assert_eq!(::std::mem::align_of::<C__bindgen_ty_bindgen_id_21__bindgen_ty_bindgen_id_28>() , 4usize); } +impl Clone for C__bindgen_ty_bindgen_id_21__bindgen_ty_bindgen_id_28 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_C__bindgen_ty_bindgen_id_21() { + assert_eq!(::std::mem::size_of::<C__bindgen_ty_bindgen_id_21>() , + 16usize); + assert_eq!(::std::mem::align_of::<C__bindgen_ty_bindgen_id_21>() , + 4usize); +} +impl Clone for C__bindgen_ty_bindgen_id_21 { + fn clone(&self) -> Self { *self } +} #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_C_Segment { +pub struct C_Segment { pub begin: ::std::os::raw::c_int, pub end: ::std::os::raw::c_int, } -impl ::std::clone::Clone for Struct_C_Segment { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_C_Segment() { - assert_eq!(::std::mem::size_of::<Struct_C_Segment>() , 8usize); - assert_eq!(::std::mem::align_of::<Struct_C_Segment>() , 4usize); +fn bindgen_test_layout_C_Segment() { + assert_eq!(::std::mem::size_of::<C_Segment>() , 8usize); + assert_eq!(::std::mem::align_of::<C_Segment>() , 4usize); } -impl ::std::clone::Clone for Struct_C { +impl Clone for C_Segment { fn clone(&self) -> Self { *self } } #[test] -fn bindgen_test_layout_Struct_C() { - assert_eq!(::std::mem::size_of::<Struct_C>() , 20usize); - assert_eq!(::std::mem::align_of::<Struct_C>() , 4usize); +fn bindgen_test_layout_C() { + assert_eq!(::std::mem::size_of::<C>() , 20usize); + assert_eq!(::std::mem::align_of::<C>() , 4usize); +} +impl Clone for C { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/class_with_typedef.rs b/tests/expectations/class_with_typedef.rs index 44bce6d7..bc19f2bd 100644 --- a/tests/expectations/class_with_typedef.rs +++ b/tests/expectations/class_with_typedef.rs @@ -8,57 +8,65 @@ pub type AnotherInt = ::std::os::raw::c_int; #[repr(C)] #[derive(Debug, Copy)] pub struct C { - pub c: ::std::os::raw::c_int, - pub ptr: *mut ::std::os::raw::c_int, - pub arr: [::std::os::raw::c_int; 10usize], + pub c: C_MyInt, + pub ptr: *mut C_MyInt, + pub arr: [C_MyInt; 10usize], pub d: AnotherInt, pub other_ptr: *mut AnotherInt, } -impl ::std::clone::Clone for C { - fn clone(&self) -> Self { *self } -} +pub type C_MyInt = ::std::os::raw::c_int; +pub type C_Lookup = *const ::std::os::raw::c_char; #[test] fn bindgen_test_layout_C() { assert_eq!(::std::mem::size_of::<C>() , 72usize); assert_eq!(::std::mem::align_of::<C>() , 8usize); } extern "C" { - fn _ZN1C6methodEi(this: *mut C, c: ::std::os::raw::c_int); - fn _ZN1C9methodRefERi(this: *mut C, c: *mut ::std::os::raw::c_int); - fn _ZN1C16complexMethodRefERPKc(this: *mut C, - c: *mut *const ::std::os::raw::c_char); - fn _ZN1C13anotherMethodEi(this: *mut C, c: AnotherInt); + #[link_name = "_ZN1C6methodEi"] + pub fn C_method(this: *mut C, c: C_MyInt); +} +extern "C" { + #[link_name = "_ZN1C9methodRefERi"] + pub fn C_methodRef(this: *mut C, c: *mut C_MyInt); +} +extern "C" { + #[link_name = "_ZN1C16complexMethodRefERPKc"] + pub fn C_complexMethodRef(this: *mut C, c: *mut C_Lookup); +} +extern "C" { + #[link_name = "_ZN1C13anotherMethodEi"] + pub fn C_anotherMethod(this: *mut C, c: AnotherInt); +} +impl Clone for C { + fn clone(&self) -> Self { *self } } impl C { #[inline] - pub unsafe fn method(&mut self, c: ::std::os::raw::c_int) { - _ZN1C6methodEi(&mut *self, c) - } + pub unsafe fn method(&mut self, c: C_MyInt) { C_method(&mut *self, c) } #[inline] - pub unsafe fn methodRef(&mut self, c: *mut ::std::os::raw::c_int) { - _ZN1C9methodRefERi(&mut *self, c) + pub unsafe fn methodRef(&mut self, c: *mut C_MyInt) { + C_methodRef(&mut *self, c) } #[inline] - pub unsafe fn complexMethodRef(&mut self, - c: *mut *const ::std::os::raw::c_char) { - _ZN1C16complexMethodRefERPKc(&mut *self, c) + pub unsafe fn complexMethodRef(&mut self, c: *mut C_Lookup) { + C_complexMethodRef(&mut *self, c) } #[inline] pub unsafe fn anotherMethod(&mut self, c: AnotherInt) { - _ZN1C13anotherMethodEi(&mut *self, c) + C_anotherMethod(&mut *self, c) } } #[repr(C)] #[derive(Debug, Copy)] pub struct D { pub _base: C, - pub ptr: *mut ::std::os::raw::c_int, -} -impl ::std::clone::Clone for D { - fn clone(&self) -> Self { *self } + pub ptr: *mut C_MyInt, } #[test] fn bindgen_test_layout_D() { assert_eq!(::std::mem::size_of::<D>() , 80usize); assert_eq!(::std::mem::align_of::<D>() , 8usize); } +impl Clone for D { + fn clone(&self) -> Self { *self } +} diff --git a/tests/expectations/const_ptr.rs b/tests/expectations/const_ptr.rs new file mode 100644 index 00000000..89400df1 --- /dev/null +++ b/tests/expectations/const_ptr.rs @@ -0,0 +1,9 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +extern "C" { + pub fn foo(bar: *const ::std::os::raw::c_void); +} diff --git a/tests/expectations/const_resolved_ty.rs b/tests/expectations/const_resolved_ty.rs new file mode 100644 index 00000000..77d8f438 --- /dev/null +++ b/tests/expectations/const_resolved_ty.rs @@ -0,0 +1,9 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +extern "C" { + pub fn foo(foo: *const u8); +} diff --git a/tests/expectations/const_tparam.rs b/tests/expectations/const_tparam.rs new file mode 100644 index 00000000..59649626 --- /dev/null +++ b/tests/expectations/const_tparam.rs @@ -0,0 +1,11 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct C<T> { + pub foo: *mut T, +} diff --git a/tests/expectations/crtp.rs b/tests/expectations/crtp.rs index c6964524..e4a86b24 100644 --- a/tests/expectations/crtp.rs +++ b/tests/expectations/crtp.rs @@ -7,23 +7,37 @@ #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct Base<T> { - pub _phantom0: ::std::marker::PhantomData<T>, + pub _address: u8, + pub _phantom_0: ::std::marker::PhantomData<T>, } #[repr(C)] #[derive(Debug, Copy)] pub struct Derived { - pub _base: Base<Derived>, + pub _address: u8, } -impl ::std::clone::Clone for Derived { +#[test] +fn bindgen_test_layout_Derived() { + assert_eq!(::std::mem::size_of::<Derived>() , 1usize); + assert_eq!(::std::mem::align_of::<Derived>() , 1usize); +} +impl Clone for Derived { fn clone(&self) -> Self { *self } } #[repr(C)] #[derive(Debug)] pub struct BaseWithDestructor<T> { - pub _phantom0: ::std::marker::PhantomData<T>, + pub _address: u8, + pub _phantom_0: ::std::marker::PhantomData<T>, } #[repr(C)] #[derive(Debug)] pub struct DerivedFromBaseWithDestructor { - pub _base: BaseWithDestructor<DerivedFromBaseWithDestructor>, + pub _address: u8, +} +#[test] +fn bindgen_test_layout_DerivedFromBaseWithDestructor() { + assert_eq!(::std::mem::size_of::<DerivedFromBaseWithDestructor>() , + 1usize); + assert_eq!(::std::mem::align_of::<DerivedFromBaseWithDestructor>() , + 1usize); } diff --git a/tests/expectations/decl_ptr_to_array.rs b/tests/expectations/decl_ptr_to_array.rs index e7dabeee..b8abedb5 100644 --- a/tests/expectations/decl_ptr_to_array.rs +++ b/tests/expectations/decl_ptr_to_array.rs @@ -5,5 +5,6 @@ extern "C" { - pub static mut foo: [::std::os::raw::c_int; 1usize]; + #[link_name = "foo"] + pub static mut foo: *mut [::std::os::raw::c_int; 1usize]; } diff --git a/tests/expectations/duplicated_constants_in_ns.rs b/tests/expectations/duplicated_constants_in_ns.rs index b4b7b2bc..cb69890c 100644 --- a/tests/expectations/duplicated_constants_in_ns.rs +++ b/tests/expectations/duplicated_constants_in_ns.rs @@ -4,4 +4,14 @@ #![allow(non_snake_case)] - +pub mod root { + use root; + pub mod foo { + use root; + pub const FOO: ::std::os::raw::c_int = 4; + } + pub mod bar { + use root; + pub const FOO: ::std::os::raw::c_int = 5; + } +} diff --git a/tests/expectations/empty_template_param_name.rs b/tests/expectations/empty_template_param_name.rs new file mode 100644 index 00000000..d165df80 --- /dev/null +++ b/tests/expectations/empty_template_param_name.rs @@ -0,0 +1,12 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __iterator_traits<_Iterator> { + pub _address: u8, + pub _phantom_0: ::std::marker::PhantomData<_Iterator>, +} diff --git a/tests/expectations/enum.rs b/tests/expectations/enum.rs index f6f510dd..8138d697 100644 --- a/tests/expectations/enum.rs +++ b/tests/expectations/enum.rs @@ -5,8 +5,8 @@ #[repr(u32)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -pub enum Enum_Foo { Bar = 0, Qux = 1, } +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum Foo { Bar = 0, Qux = 1, } #[repr(i32)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -pub enum Enum_Neg { MinusOne = -1, One = 1, } +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum Neg { MinusOne = -1, One = 1, } diff --git a/tests/expectations/enum_alias.rs b/tests/expectations/enum_alias.rs new file mode 100644 index 00000000..7ea85598 --- /dev/null +++ b/tests/expectations/enum_alias.rs @@ -0,0 +1,9 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[repr(u8)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum Bar { VAL = 0, } diff --git a/tests/expectations/enum_and_vtable_mangling.rs b/tests/expectations/enum_and_vtable_mangling.rs index c68dc102..3c7d5370 100644 --- a/tests/expectations/enum_and_vtable_mangling.rs +++ b/tests/expectations/enum_and_vtable_mangling.rs @@ -4,27 +4,26 @@ #![allow(non_snake_case)] +pub const match_: _bindgen_ty_bindgen_id_1 = _bindgen_ty_bindgen_id_1::match_; +pub const whatever_else: _bindgen_ty_bindgen_id_1 = + _bindgen_ty_bindgen_id_1::whatever_else; #[repr(u32)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -pub enum Enum_enum_and_vtable_mangling_hpp_unnamed_1 { - match_ = 0, - whatever_else = 1, +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum _bindgen_ty_bindgen_id_1 { match_ = 0, whatever_else = 1, } +#[repr(C)] +pub struct bindgen_vtable__bindgen_id_4 { } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_C { - pub _vftable: *const _vftable_Struct_C, +pub struct C { + pub vtable_: *const bindgen_vtable__bindgen_id_4, pub i: ::std::os::raw::c_int, } -#[repr(C)] -pub struct _vftable_Struct_C { - pub match_: unsafe extern "C" fn(this: *mut ::std::os::raw::c_void), +#[test] +fn bindgen_test_layout_C() { + assert_eq!(::std::mem::size_of::<C>() , 16usize); + assert_eq!(::std::mem::align_of::<C>() , 8usize); } -impl ::std::clone::Clone for Struct_C { +impl Clone for C { fn clone(&self) -> Self { *self } } -#[test] -fn bindgen_test_layout_Struct_C() { - assert_eq!(::std::mem::size_of::<Struct_C>() , 16usize); - assert_eq!(::std::mem::align_of::<Struct_C>() , 8usize); -} diff --git a/tests/expectations/enum_dupe.rs b/tests/expectations/enum_dupe.rs index 10464881..322b89fc 100644 --- a/tests/expectations/enum_dupe.rs +++ b/tests/expectations/enum_dupe.rs @@ -4,7 +4,7 @@ #![allow(non_snake_case)] -pub const Dupe: Enum_Foo = Enum_Foo::Bar; +pub const Foo_Dupe: Foo = Foo::Bar; #[repr(u32)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -pub enum Enum_Foo { Bar = 1, } +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum Foo { Bar = 1, } diff --git a/tests/expectations/enum_explicit_type.rs b/tests/expectations/enum_explicit_type.rs index 1b94c284..352f4ea9 100644 --- a/tests/expectations/enum_explicit_type.rs +++ b/tests/expectations/enum_explicit_type.rs @@ -5,17 +5,17 @@ #[repr(u8)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -pub enum Enum_Foo { Bar = 0, Qux = 1, } +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum Foo { Bar = 0, Qux = 1, } #[repr(i8)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -pub enum Enum_Neg { MinusOne = -1, One = 1, } +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum Neg { MinusOne = -1, One = 1, } #[repr(u16)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -pub enum Enum_Bigger { Much = 255, Larger = 256, } +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum Bigger { Much = 255, Larger = 256, } #[repr(i64)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -pub enum Enum_MuchLong { MuchLow = -4294967296, } +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum MuchLong { MuchLow = -4294967296, } #[repr(u64)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -pub enum Enum_MuchLongLong { MuchHigh = 4294967296, } +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum MuchLongLong { MuchHigh = 4294967296, } diff --git a/tests/expectations/enum_negative.rs b/tests/expectations/enum_negative.rs index 03db5709..74cf4f16 100644 --- a/tests/expectations/enum_negative.rs +++ b/tests/expectations/enum_negative.rs @@ -5,5 +5,5 @@ #[repr(i32)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -pub enum Enum_Foo { Bar = -2, Qux = 1, } +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum Foo { Bar = -2, Qux = 1, } diff --git a/tests/expectations/enum_packed.rs b/tests/expectations/enum_packed.rs index 7684a26d..963763e1 100644 --- a/tests/expectations/enum_packed.rs +++ b/tests/expectations/enum_packed.rs @@ -5,11 +5,11 @@ #[repr(u8)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -pub enum Enum_Foo { Bar = 0, Qux = 1, } +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum Foo { Bar = 0, Qux = 1, } #[repr(i8)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -pub enum Enum_Neg { MinusOne = -1, One = 1, } +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum Neg { MinusOne = -1, One = 1, } #[repr(u16)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -pub enum Enum_Bigger { Much = 255, Larger = 256, } +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum Bigger { Much = 255, Larger = 256, } diff --git a/tests/expectations/extern.rs b/tests/expectations/extern.rs index 8f122341..e7ac7504 100644 --- a/tests/expectations/extern.rs +++ b/tests/expectations/extern.rs @@ -5,4 +5,5 @@ pub type foo = - unsafe extern "C" fn(bar: ::std::os::raw::c_int) -> ::std::os::raw::c_int; + ::std::option::Option<unsafe extern "C" fn(bar: ::std::os::raw::c_int) + -> ::std::os::raw::c_int>; diff --git a/tests/expectations/forward_declared_struct.rs b/tests/expectations/forward_declared_struct.rs index 3a812c0d..5c2764e1 100644 --- a/tests/expectations/forward_declared_struct.rs +++ b/tests/expectations/forward_declared_struct.rs @@ -6,27 +6,27 @@ #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_a { +pub struct a { pub b: ::std::os::raw::c_int, } -impl ::std::clone::Clone for Struct_a { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_a() { - assert_eq!(::std::mem::size_of::<Struct_a>() , 4usize); - assert_eq!(::std::mem::align_of::<Struct_a>() , 4usize); +fn bindgen_test_layout_a() { + assert_eq!(::std::mem::size_of::<a>() , 4usize); + assert_eq!(::std::mem::align_of::<a>() , 4usize); +} +impl Clone for a { + fn clone(&self) -> Self { *self } } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_c { +pub struct c { pub d: ::std::os::raw::c_int, } -impl ::std::clone::Clone for Struct_c { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_c() { - assert_eq!(::std::mem::size_of::<Struct_c>() , 4usize); - assert_eq!(::std::mem::align_of::<Struct_c>() , 4usize); +fn bindgen_test_layout_c() { + assert_eq!(::std::mem::size_of::<c>() , 4usize); + assert_eq!(::std::mem::align_of::<c>() , 4usize); +} +impl Clone for c { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/func_proto.rs b/tests/expectations/func_proto.rs index 8f122341..e7ac7504 100644 --- a/tests/expectations/func_proto.rs +++ b/tests/expectations/func_proto.rs @@ -5,4 +5,5 @@ pub type foo = - unsafe extern "C" fn(bar: ::std::os::raw::c_int) -> ::std::os::raw::c_int; + ::std::option::Option<unsafe extern "C" fn(bar: ::std::os::raw::c_int) + -> ::std::os::raw::c_int>; diff --git a/tests/expectations/func_ptr.rs b/tests/expectations/func_ptr.rs index 01e413a6..c62e532d 100644 --- a/tests/expectations/func_ptr.rs +++ b/tests/expectations/func_ptr.rs @@ -5,10 +5,8 @@ extern "C" { + #[link_name = "foo"] pub static mut foo: - ::std::option::Option<unsafe extern "C" fn(x: - ::std::os::raw::c_int, - y: - ::std::os::raw::c_int) - -> ::std::os::raw::c_int>; + *mut ::std::option::Option<unsafe extern "C" fn() + -> ::std::os::raw::c_int>; } diff --git a/tests/expectations/func_ptr_in_struct.rs b/tests/expectations/func_ptr_in_struct.rs index 3d7b5f68..0d4ccdbf 100644 --- a/tests/expectations/func_ptr_in_struct.rs +++ b/tests/expectations/func_ptr_in_struct.rs @@ -4,23 +4,18 @@ #![allow(non_snake_case)] -#[repr(i32)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -pub enum Enum_baz { _BindgenOpaqueEnum = 0, } +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum baz { } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_Foo { - pub bar: ::std::option::Option<unsafe extern "C" fn(x: - ::std::os::raw::c_int, - y: - ::std::os::raw::c_int) - -> Enum_baz>, -} -impl ::std::clone::Clone for Struct_Foo { - fn clone(&self) -> Self { *self } +pub struct Foo { + pub bar: *mut ::std::option::Option<unsafe extern "C" fn() -> baz>, } #[test] -fn bindgen_test_layout_Struct_Foo() { - assert_eq!(::std::mem::size_of::<Struct_Foo>() , 8usize); - assert_eq!(::std::mem::align_of::<Struct_Foo>() , 8usize); +fn bindgen_test_layout_Foo() { + assert_eq!(::std::mem::size_of::<Foo>() , 8usize); + assert_eq!(::std::mem::align_of::<Foo>() , 8usize); +} +impl Clone for Foo { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/func_with_func_ptr_arg.rs b/tests/expectations/func_with_func_ptr_arg.rs index 4ac25286..b6e345f6 100644 --- a/tests/expectations/func_with_func_ptr_arg.rs +++ b/tests/expectations/func_with_func_ptr_arg.rs @@ -5,5 +5,5 @@ extern "C" { - pub fn foo(bar: ::std::option::Option<unsafe extern "C" fn()>); + pub fn foo(bar: *mut ::std::option::Option<unsafe extern "C" fn()>); } diff --git a/tests/expectations/in_class_typedef.rs b/tests/expectations/in_class_typedef.rs new file mode 100644 index 00000000..4e95ca8c --- /dev/null +++ b/tests/expectations/in_class_typedef.rs @@ -0,0 +1,21 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Foo<T> { + pub _address: u8, + pub _phantom_0: ::std::marker::PhantomData<T>, +} +pub type Foo_elem_type<T> = T; +pub type Foo_ptr_type<T> = *mut T; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Foo_Bar<T> { + pub x: ::std::os::raw::c_int, + pub y: ::std::os::raw::c_int, + pub _phantom_0: ::std::marker::PhantomData<T>, +} diff --git a/tests/expectations/inherit_named.rs b/tests/expectations/inherit_named.rs new file mode 100644 index 00000000..8081c649 --- /dev/null +++ b/tests/expectations/inherit_named.rs @@ -0,0 +1,17 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Wohoo<T> { + pub _address: u8, + pub _phantom_0: ::std::marker::PhantomData<T>, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Weeee<T> { + pub _base: T, +} diff --git a/tests/expectations/inherit_typedef.rs b/tests/expectations/inherit_typedef.rs new file mode 100644 index 00000000..ca9041e2 --- /dev/null +++ b/tests/expectations/inherit_typedef.rs @@ -0,0 +1,33 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Foo { + pub _address: u8, +} +#[test] +fn bindgen_test_layout_Foo() { + assert_eq!(::std::mem::size_of::<Foo>() , 1usize); + assert_eq!(::std::mem::align_of::<Foo>() , 1usize); +} +impl Clone for Foo { + fn clone(&self) -> Self { *self } +} +pub type TypedefedFoo = Foo; +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Bar { + pub _address: u8, +} +#[test] +fn bindgen_test_layout_Bar() { + assert_eq!(::std::mem::size_of::<Bar>() , 1usize); + assert_eq!(::std::mem::align_of::<Bar>() , 1usize); +} +impl Clone for Bar { + fn clone(&self) -> Self { *self } +} diff --git a/tests/expectations/inner_const.rs b/tests/expectations/inner_const.rs new file mode 100644 index 00000000..666b8ce2 --- /dev/null +++ b/tests/expectations/inner_const.rs @@ -0,0 +1,27 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Foo { + pub bar: ::std::os::raw::c_int, +} +extern "C" { + #[link_name = "_ZN3Foo3BOOE"] + pub static mut Foo_BOO: ::std::os::raw::c_int; +} +extern "C" { + #[link_name = "_ZN3Foo8whateverE"] + pub static mut Foo_whatever: Foo; +} +#[test] +fn bindgen_test_layout_Foo() { + assert_eq!(::std::mem::size_of::<Foo>() , 4usize); + assert_eq!(::std::mem::align_of::<Foo>() , 4usize); +} +impl Clone for Foo { + fn clone(&self) -> Self { *self } +} diff --git a/tests/expectations/inner_template_self.rs b/tests/expectations/inner_template_self.rs index 60af23ee..b965b92d 100644 --- a/tests/expectations/inner_template_self.rs +++ b/tests/expectations/inner_template_self.rs @@ -6,20 +6,20 @@ #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct Struct_LinkedList<T> { - pub next: *mut Struct_LinkedList<T>, - pub prev: *mut Struct_LinkedList<T>, +pub struct LinkedList<T> { + pub next: *mut LinkedList<T>, + pub prev: *mut LinkedList<T>, } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_InstantiateIt { - pub m_list: Struct_LinkedList<::std::os::raw::c_int>, -} -impl ::std::clone::Clone for Struct_InstantiateIt { - fn clone(&self) -> Self { *self } +pub struct InstantiateIt { + pub m_list: LinkedList<::std::os::raw::c_int>, } #[test] -fn bindgen_test_layout_Struct_InstantiateIt() { - assert_eq!(::std::mem::size_of::<Struct_InstantiateIt>() , 16usize); - assert_eq!(::std::mem::align_of::<Struct_InstantiateIt>() , 8usize); +fn bindgen_test_layout_InstantiateIt() { + assert_eq!(::std::mem::size_of::<InstantiateIt>() , 16usize); + assert_eq!(::std::mem::align_of::<InstantiateIt>() , 8usize); +} +impl Clone for InstantiateIt { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/jsval_layout_opaque.rs b/tests/expectations/jsval_layout_opaque.rs index fa9b89b9..69fe54dc 100644 --- a/tests/expectations/jsval_layout_opaque.rs +++ b/tests/expectations/jsval_layout_opaque.rs @@ -4,7 +4,7 @@ #![allow(non_snake_case)] -#[derive(Copy, Debug)] +#[derive(Debug)] #[repr(C)] pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>); impl <T> __BindgenUnionField<T> { @@ -23,9 +23,10 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> { #[inline] fn clone(&self) -> Self { Self::new() } } +impl <T> ::std::marker::Copy for __BindgenUnionField<T> { } pub const JSVAL_TAG_SHIFT: ::std::os::raw::c_uint = 47; #[repr(u8)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum JSValueType { JSVAL_TYPE_DOUBLE = 0, JSVAL_TYPE_INT32 = 1, @@ -40,7 +41,7 @@ pub enum JSValueType { JSVAL_TYPE_MISSING = 33, } #[repr(u32)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum JSValueTag { JSVAL_TAG_MAX_DOUBLE = 131056, JSVAL_TAG_INT32 = 131057, @@ -53,7 +54,7 @@ pub enum JSValueTag { JSVAL_TAG_OBJECT = 131064, } #[repr(u64)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum JSValueShiftedTag { JSVAL_SHIFTED_TAG_MAX_DOUBLE = 18444492278190833663, JSVAL_SHIFTED_TAG_INT32 = 18444633011384221696, @@ -66,7 +67,7 @@ pub enum JSValueShiftedTag { JSVAL_SHIFTED_TAG_OBJECT = 18445618173802708992, } #[repr(u32)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum JSWhyMagic { JS_ELEMENTS_HOLE = 0, JS_NO_ITER_VALUE = 1, @@ -92,155 +93,107 @@ pub enum JSWhyMagic { #[derive(Debug, Copy)] pub struct jsval_layout { pub asBits: __BindgenUnionField<u64>, - pub debugView: __BindgenUnionField<jsval_layout_jsval_layout_opaque_hpp_unnamed_1>, - pub s: __BindgenUnionField<jsval_layout_jsval_layout_opaque_hpp_unnamed_2>, + pub debugView: __BindgenUnionField<jsval_layout__bindgen_ty_bindgen_id_81>, + pub s: __BindgenUnionField<jsval_layout__bindgen_ty_bindgen_id_85>, pub asDouble: __BindgenUnionField<f64>, pub asPtr: __BindgenUnionField<*mut ::std::os::raw::c_void>, pub asWord: __BindgenUnionField<usize>, pub asUIntPtr: __BindgenUnionField<usize>, - pub _bindgen_data_: u64, -} -impl jsval_layout { - pub unsafe fn asBits(&mut self) -> *mut u64 { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn debugView(&mut self) - -> *mut jsval_layout_jsval_layout_opaque_hpp_unnamed_1 { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn s(&mut self) - -> *mut jsval_layout_jsval_layout_opaque_hpp_unnamed_2 { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn asDouble(&mut self) -> *mut f64 { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn asPtr(&mut self) -> *mut *mut ::std::os::raw::c_void { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn asWord(&mut self) -> *mut usize { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn asUIntPtr(&mut self) -> *mut usize { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } -} -impl ::std::clone::Clone for jsval_layout { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_jsval_layout() { - assert_eq!(::std::mem::size_of::<jsval_layout>() , 8usize); - assert_eq!(::std::mem::align_of::<jsval_layout>() , 8usize); + pub bindgen_union_field: u64, } #[repr(C)] #[derive(Debug, Copy)] -pub struct jsval_layout_jsval_layout_opaque_hpp_unnamed_1 { +pub struct jsval_layout__bindgen_ty_bindgen_id_81 { pub _bitfield_1: u64, } -impl jsval_layout_jsval_layout_opaque_hpp_unnamed_1 { +#[test] +fn bindgen_test_layout_jsval_layout__bindgen_ty_bindgen_id_81() { + assert_eq!(::std::mem::size_of::<jsval_layout__bindgen_ty_bindgen_id_81>() + , 8usize); + assert_eq!(::std::mem::align_of::<jsval_layout__bindgen_ty_bindgen_id_81>() + , 8usize); +} +impl Clone for jsval_layout__bindgen_ty_bindgen_id_81 { + fn clone(&self) -> Self { *self } +} +impl jsval_layout__bindgen_ty_bindgen_id_81 { #[inline] pub fn payload47(&self) -> u64 { - (self._bitfield_1 & (140737488355327usize as u64)) >> 0usize + unsafe { + ::std::mem::transmute(((self._bitfield_1 & + (140737488355327usize as u64)) >> + 0u32) as u64) + } } #[inline] - pub fn set_payload47(&mut self, val: u32) { + pub fn set_payload47(&mut self, val: u64) { self._bitfield_1 &= !(140737488355327usize as u64); self._bitfield_1 |= - ((val as u64) << 0usize) & (140737488355327usize as u64); + ((val as u64 as u64) << 0u32) & (140737488355327usize as u64); } #[inline] - pub fn tag(&self) -> u64 { - (self._bitfield_1 & (18446603336221196288usize as u64)) >> 47usize + pub fn tag(&self) -> JSValueTag { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & + (18446603336221196288usize as u64)) >> + 47u32) as u32) + } } #[inline] - pub fn set_tag(&mut self, val: u32) { + pub fn set_tag(&mut self, val: JSValueTag) { self._bitfield_1 &= !(18446603336221196288usize as u64); self._bitfield_1 |= - ((val as u64) << 47usize) & (18446603336221196288usize as u64); - } - #[inline] - pub fn new_bitfield_1(payload47: u32, tag: u32) -> u64 { - 0 | ((payload47 as u64) << 0u32) | ((tag as u64) << 47u32) + ((val as u32 as u64) << 47u32) & + (18446603336221196288usize as u64); } } -impl ::std::clone::Clone for jsval_layout_jsval_layout_opaque_hpp_unnamed_1 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_jsval_layout_jsval_layout_opaque_hpp_unnamed_1() { - assert_eq!(::std::mem::size_of::<jsval_layout_jsval_layout_opaque_hpp_unnamed_1>() - , 8usize); - assert_eq!(::std::mem::align_of::<jsval_layout_jsval_layout_opaque_hpp_unnamed_1>() - , 8usize); -} #[repr(C)] #[derive(Debug, Copy)] -pub struct jsval_layout_jsval_layout_opaque_hpp_unnamed_2 { - pub payload: jsval_layout_jsval_layout_opaque_hpp_unnamed_2_jsval_layout_opaque_hpp_unnamed_3, +pub struct jsval_layout__bindgen_ty_bindgen_id_85 { + pub payload: jsval_layout__bindgen_ty_bindgen_id_85__bindgen_ty_bindgen_id_86, } #[repr(C)] #[derive(Debug, Copy)] -pub struct jsval_layout_jsval_layout_opaque_hpp_unnamed_2_jsval_layout_opaque_hpp_unnamed_3 { +pub struct jsval_layout__bindgen_ty_bindgen_id_85__bindgen_ty_bindgen_id_86 { pub i32: __BindgenUnionField<i32>, pub u32: __BindgenUnionField<u32>, pub why: __BindgenUnionField<JSWhyMagic>, - pub _bindgen_data_: u32, -} -impl jsval_layout_jsval_layout_opaque_hpp_unnamed_2_jsval_layout_opaque_hpp_unnamed_3 - { - pub unsafe fn i32(&mut self) -> *mut i32 { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn u32(&mut self) -> *mut u32 { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn why(&mut self) -> *mut JSWhyMagic { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } -} -impl ::std::clone::Clone for - jsval_layout_jsval_layout_opaque_hpp_unnamed_2_jsval_layout_opaque_hpp_unnamed_3 - { - fn clone(&self) -> Self { *self } + pub bindgen_union_field: u32, } #[test] -fn bindgen_test_layout_jsval_layout_jsval_layout_opaque_hpp_unnamed_2_jsval_layout_opaque_hpp_unnamed_3() { - assert_eq!(::std::mem::size_of::<jsval_layout_jsval_layout_opaque_hpp_unnamed_2_jsval_layout_opaque_hpp_unnamed_3>() +fn bindgen_test_layout_jsval_layout__bindgen_ty_bindgen_id_85__bindgen_ty_bindgen_id_86() { + assert_eq!(::std::mem::size_of::<jsval_layout__bindgen_ty_bindgen_id_85__bindgen_ty_bindgen_id_86>() , 4usize); - assert_eq!(::std::mem::align_of::<jsval_layout_jsval_layout_opaque_hpp_unnamed_2_jsval_layout_opaque_hpp_unnamed_3>() + assert_eq!(::std::mem::align_of::<jsval_layout__bindgen_ty_bindgen_id_85__bindgen_ty_bindgen_id_86>() , 4usize); } -impl ::std::clone::Clone for jsval_layout_jsval_layout_opaque_hpp_unnamed_2 { +impl Clone for + jsval_layout__bindgen_ty_bindgen_id_85__bindgen_ty_bindgen_id_86 { fn clone(&self) -> Self { *self } } #[test] -fn bindgen_test_layout_jsval_layout_jsval_layout_opaque_hpp_unnamed_2() { - assert_eq!(::std::mem::size_of::<jsval_layout_jsval_layout_opaque_hpp_unnamed_2>() +fn bindgen_test_layout_jsval_layout__bindgen_ty_bindgen_id_85() { + assert_eq!(::std::mem::size_of::<jsval_layout__bindgen_ty_bindgen_id_85>() , 4usize); - assert_eq!(::std::mem::align_of::<jsval_layout_jsval_layout_opaque_hpp_unnamed_2>() + assert_eq!(::std::mem::align_of::<jsval_layout__bindgen_ty_bindgen_id_85>() , 4usize); } +impl Clone for jsval_layout__bindgen_ty_bindgen_id_85 { + fn clone(&self) -> Self { *self } +} +impl Clone for jsval_layout { + fn clone(&self) -> Self { *self } +} #[repr(C)] #[derive(Debug, Copy)] pub struct Value { pub data: jsval_layout, } -impl ::std::clone::Clone for Value { - fn clone(&self) -> Self { *self } -} #[test] fn bindgen_test_layout_Value() { assert_eq!(::std::mem::size_of::<Value>() , 8usize); assert_eq!(::std::mem::align_of::<Value>() , 8usize); } +impl Clone for Value { + fn clone(&self) -> Self { *self } +} diff --git a/tests/expectations/keywords.rs b/tests/expectations/keywords.rs index 12e9b5c2..5b75389e 100644 --- a/tests/expectations/keywords.rs +++ b/tests/expectations/keywords.rs @@ -5,90 +5,198 @@ extern "C" { + #[link_name = "u8"] pub static mut u8: ::std::os::raw::c_int; +} +extern "C" { + #[link_name = "u16"] pub static mut u16: ::std::os::raw::c_int; +} +extern "C" { + #[link_name = "u32"] pub static mut u32: ::std::os::raw::c_int; +} +extern "C" { + #[link_name = "u64"] pub static mut u64: ::std::os::raw::c_int; +} +extern "C" { + #[link_name = "i8"] pub static mut i8: ::std::os::raw::c_int; +} +extern "C" { + #[link_name = "i16"] pub static mut i16: ::std::os::raw::c_int; +} +extern "C" { + #[link_name = "i32"] pub static mut i32: ::std::os::raw::c_int; +} +extern "C" { + #[link_name = "i64"] pub static mut i64: ::std::os::raw::c_int; +} +extern "C" { + #[link_name = "f32"] pub static mut f32: ::std::os::raw::c_int; +} +extern "C" { + #[link_name = "f64"] pub static mut f64: ::std::os::raw::c_int; +} +extern "C" { + #[link_name = "usize"] pub static mut usize: ::std::os::raw::c_int; +} +extern "C" { + #[link_name = "isize"] pub static mut isize: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "as"] pub static mut as_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "box"] pub static mut box_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "crate"] pub static mut crate_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "false"] pub static mut false_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "fn"] pub static mut fn_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "impl"] pub static mut impl_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "in"] pub static mut in_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "let"] pub static mut let_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "loop"] pub static mut loop_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "match"] pub static mut match_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "mod"] pub static mut mod_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "move"] pub static mut move_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "mut"] pub static mut mut_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "pub"] pub static mut pub_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "ref"] pub static mut ref_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "self"] pub static mut self_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "Self"] pub static mut Self_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "super"] pub static mut super_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "trait"] pub static mut trait_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "true"] pub static mut true_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "type"] pub static mut type_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "unsafe"] pub static mut unsafe_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "use"] pub static mut use_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "where"] pub static mut where_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "abstract"] pub static mut abstract_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "alignof"] pub static mut alignof_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "become"] pub static mut become_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "final"] pub static mut final_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "macro"] pub static mut macro_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "offsetof"] pub static mut offsetof_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "override"] pub static mut override_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "priv"] pub static mut priv_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "proc"] pub static mut proc_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "pure"] pub static mut pure_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "unsized"] pub static mut unsized_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "virtual"] pub static mut virtual_: ::std::os::raw::c_int; +} +extern "C" { #[link_name = "yield"] pub static mut yield_: ::std::os::raw::c_int; } diff --git a/tests/expectations/moar_bitfields.rs b/tests/expectations/moar_bitfields.rs new file mode 100644 index 00000000..7c034120 --- /dev/null +++ b/tests/expectations/moar_bitfields.rs @@ -0,0 +1,48 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[repr(u32)] +pub enum WhenToScroll { + SCROLL_ALWAYS = 0, + SCROLL_IF_NOT_VISIBLE = 1, + SCROLL_IF_NOT_FULLY_VISIBLE = 2, +} +#[repr(C)] +pub struct ScrollAxis { + pub mWhereToScroll: ::std::os::raw::c_short, + pub _bitfield_1: u16, +} +#[test] +fn bindgen_test_layout_ScrollAxis() { + assert_eq!(::std::mem::size_of::<ScrollAxis>() , 4usize); + assert_eq!(::std::mem::align_of::<ScrollAxis>() , 4usize); +} +impl ScrollAxis { + #[inline] + pub fn mWhenToScroll(&self) -> WhenToScroll { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (255usize as u16)) >> + 0u32) as u32) + } + } + #[inline] + pub fn set_mWhenToScroll(&mut self, val: WhenToScroll) { + self._bitfield_1 &= !(255usize as u16); + self._bitfield_1 |= ((val as u32 as u16) << 0u32) & (255usize as u16); + } + #[inline] + pub fn mOnlyIfPerceivedScrollableDirection(&self) -> bool { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (256usize as u16)) >> + 8u32) as u8) + } + } + #[inline] + pub fn set_mOnlyIfPerceivedScrollableDirection(&mut self, val: bool) { + self._bitfield_1 &= !(256usize as u16); + self._bitfield_1 |= ((val as u8 as u16) << 8u32) & (256usize as u16); + } +} diff --git a/tests/expectations/mutable.rs b/tests/expectations/mutable.rs index cf2c5937..0d0d6ea3 100644 --- a/tests/expectations/mutable.rs +++ b/tests/expectations/mutable.rs @@ -6,37 +6,37 @@ #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_C { +pub struct C { pub m_member: ::std::os::raw::c_int, pub m_other: ::std::os::raw::c_int, } -impl ::std::clone::Clone for Struct_C { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_C() { - assert_eq!(::std::mem::size_of::<Struct_C>() , 8usize); - assert_eq!(::std::mem::align_of::<Struct_C>() , 4usize); +fn bindgen_test_layout_C() { + assert_eq!(::std::mem::size_of::<C>() , 8usize); + assert_eq!(::std::mem::align_of::<C>() , 4usize); +} +impl Clone for C { + fn clone(&self) -> Self { *self } } #[repr(C)] #[derive(Debug)] -pub struct Struct_NonCopiable { - pub m_member: ::std::cell::Cell<::std::os::raw::c_int>, +pub struct NonCopiable { + pub m_member: ::std::os::raw::c_int, } #[test] -fn bindgen_test_layout_Struct_NonCopiable() { - assert_eq!(::std::mem::size_of::<Struct_NonCopiable>() , 4usize); - assert_eq!(::std::mem::align_of::<Struct_NonCopiable>() , 4usize); +fn bindgen_test_layout_NonCopiable() { + assert_eq!(::std::mem::size_of::<NonCopiable>() , 4usize); + assert_eq!(::std::mem::align_of::<NonCopiable>() , 4usize); } #[repr(C)] #[derive(Debug)] -pub struct Struct_NonCopiableWithNonCopiableMutableMember { - pub m_member: ::std::cell::UnsafeCell<Struct_NonCopiable>, +pub struct NonCopiableWithNonCopiableMutableMember { + pub m_member: NonCopiable, } #[test] -fn bindgen_test_layout_Struct_NonCopiableWithNonCopiableMutableMember() { - assert_eq!(::std::mem::size_of::<Struct_NonCopiableWithNonCopiableMutableMember>() +fn bindgen_test_layout_NonCopiableWithNonCopiableMutableMember() { + assert_eq!(::std::mem::size_of::<NonCopiableWithNonCopiableMutableMember>() , 4usize); - assert_eq!(::std::mem::align_of::<Struct_NonCopiableWithNonCopiableMutableMember>() + assert_eq!(::std::mem::align_of::<NonCopiableWithNonCopiableMutableMember>() , 4usize); } diff --git a/tests/expectations/namespace.rs b/tests/expectations/namespace.rs index 36113536..0bd6e8e0 100644 --- a/tests/expectations/namespace.rs +++ b/tests/expectations/namespace.rs @@ -4,17 +4,8 @@ #![allow(non_snake_case)] -pub use root::*; pub mod root { - #[repr(C)] - #[derive(Debug)] - pub struct Struct_C<T> { - pub _base: __anonymous1::Struct_A, - pub m_c: T, - pub m_c_ptr: *mut T, - pub m_c_arr: [T; 10usize], - pub _phantom0: ::std::marker::PhantomData<T>, - } + use root; extern "C" { #[link_name = "_Z9top_levelv"] pub fn top_level(); @@ -27,44 +18,68 @@ pub mod root { pub fn in_whatever(); } } - pub mod __anonymous1 { + pub mod _bindgen_mod_bindgen_id_12 { use root; + pub mod empty { + use root; + } + extern "C" { + #[link_name = "_ZN12_GLOBAL__N_13fooEv"] + pub fn foo(); + } #[repr(C)] #[derive(Debug, Copy)] - pub struct Struct_A { + pub struct A { pub b: root::whatever::whatever_int_t, } - impl ::std::clone::Clone for Struct_A { - fn clone(&self) -> Self { *self } - } #[test] - fn bindgen_test_layout_Struct_A() { - assert_eq!(::std::mem::size_of::<Struct_A>() , 4usize); - assert_eq!(::std::mem::align_of::<Struct_A>() , 4usize); - } - extern "C" { - #[link_name = "_ZN12_GLOBAL__N_13fooEv"] - pub fn foo(); + fn bindgen_test_layout_A() { + assert_eq!(::std::mem::size_of::<A>() , 4usize); + assert_eq!(::std::mem::align_of::<A>() , 4usize); } - pub mod empty { - use root; + impl Clone for A { + fn clone(&self) -> Self { *self } } } + #[repr(C)] + #[derive(Debug)] + pub struct C<T> { + pub _base: root::_bindgen_mod_bindgen_id_12::A, + pub m_c: T, + pub m_c_ptr: *mut T, + pub m_c_arr: [T; 10usize], + } pub mod w { use root; pub type whatever_int_t = ::std::os::raw::c_uint; #[repr(C)] #[derive(Debug)] - pub struct Struct_D<T> { - pub m_c: root::Struct_C<T>, + pub struct D<T> { + pub m_c: root::C<T>, } extern "C" { #[link_name = "_ZN1w3hehEv"] pub fn heh() -> root::w::whatever_int_t; + } + extern "C" { #[link_name = "_ZN1w3fooEv"] - pub fn foo() -> root::Struct_C<::std::os::raw::c_int>; + pub fn foo() -> root::C<::std::os::raw::c_int>; + } + extern "C" { #[link_name = "_ZN1w4barrEv"] - pub fn barr() -> root::Struct_C<f32>; + pub fn barr() -> root::C<f32>; } } } +extern "C" { + #[link_name = "_Z9top_levelv"] + pub fn top_level(); +} +#[repr(C)] +#[derive(Debug)] +pub struct C<T> { + pub _base: root::_bindgen_mod_bindgen_id_12::A, + pub m_c: T, + pub m_c_ptr: *mut T, + pub m_c_arr: [T; 10usize], +} diff --git a/tests/expectations/nested.rs b/tests/expectations/nested.rs index 2f7fae9a..fdd435aa 100644 --- a/tests/expectations/nested.rs +++ b/tests/expectations/nested.rs @@ -6,47 +6,54 @@ #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_Calc { +pub struct Calc { pub w: ::std::os::raw::c_int, } -impl ::std::clone::Clone for Struct_Calc { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_Calc() { - assert_eq!(::std::mem::size_of::<Struct_Calc>() , 4usize); - assert_eq!(::std::mem::align_of::<Struct_Calc>() , 4usize); +fn bindgen_test_layout_Calc() { + assert_eq!(::std::mem::size_of::<Calc>() , 4usize); + assert_eq!(::std::mem::align_of::<Calc>() , 4usize); +} +impl Clone for Calc { + fn clone(&self) -> Self { *self } } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_Test; +pub struct Test { + pub _address: u8, +} #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_Test_Size { - pub mWidth: Struct_Test_Size_Dimension, - pub mHeight: Struct_Test_Size_Dimension, +pub struct Test_Size { + pub mWidth: Test_Size_Dimension, + pub mHeight: Test_Size_Dimension, } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_Test_Size_Dimension { - pub _base: Struct_Calc, +pub struct Test_Size_Dimension { + pub _base: Calc, +} +#[test] +fn bindgen_test_layout_Test_Size_Dimension() { + assert_eq!(::std::mem::size_of::<Test_Size_Dimension>() , 4usize); + assert_eq!(::std::mem::align_of::<Test_Size_Dimension>() , 4usize); } -impl ::std::clone::Clone for Struct_Test_Size_Dimension { +impl Clone for Test_Size_Dimension { fn clone(&self) -> Self { *self } } #[test] -fn bindgen_test_layout_Struct_Test_Size_Dimension() { - assert_eq!(::std::mem::size_of::<Struct_Test_Size_Dimension>() , 4usize); - assert_eq!(::std::mem::align_of::<Struct_Test_Size_Dimension>() , 4usize); +fn bindgen_test_layout_Test_Size() { + assert_eq!(::std::mem::size_of::<Test_Size>() , 8usize); + assert_eq!(::std::mem::align_of::<Test_Size>() , 4usize); } -impl ::std::clone::Clone for Struct_Test_Size { +impl Clone for Test_Size { fn clone(&self) -> Self { *self } } #[test] -fn bindgen_test_layout_Struct_Test_Size() { - assert_eq!(::std::mem::size_of::<Struct_Test_Size>() , 8usize); - assert_eq!(::std::mem::align_of::<Struct_Test_Size>() , 4usize); +fn bindgen_test_layout_Test() { + assert_eq!(::std::mem::size_of::<Test>() , 1usize); + assert_eq!(::std::mem::align_of::<Test>() , 1usize); } -impl ::std::clone::Clone for Struct_Test { +impl Clone for Test { fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/nested_vtable.rs b/tests/expectations/nested_vtable.rs new file mode 100644 index 00000000..0c4f7dbe --- /dev/null +++ b/tests/expectations/nested_vtable.rs @@ -0,0 +1,48 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[repr(C)] +pub struct bindgen_vtable__bindgen_id_1 { +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct nsISupports { + pub vtable_: *const bindgen_vtable__bindgen_id_1, +} +#[test] +fn bindgen_test_layout_nsISupports() { + assert_eq!(::std::mem::size_of::<nsISupports>() , 8usize); + assert_eq!(::std::mem::align_of::<nsISupports>() , 8usize); +} +impl Clone for nsISupports { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct nsIRunnable { + pub _base: nsISupports, +} +#[test] +fn bindgen_test_layout_nsIRunnable() { + assert_eq!(::std::mem::size_of::<nsIRunnable>() , 8usize); + assert_eq!(::std::mem::align_of::<nsIRunnable>() , 8usize); +} +impl Clone for nsIRunnable { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Runnable { + pub _base: nsIRunnable, +} +#[test] +fn bindgen_test_layout_Runnable() { + assert_eq!(::std::mem::size_of::<Runnable>() , 8usize); + assert_eq!(::std::mem::align_of::<Runnable>() , 8usize); +} +impl Clone for Runnable { + fn clone(&self) -> Self { *self } +} diff --git a/tests/expectations/no_copy.rs b/tests/expectations/no_copy.rs index 601b65c8..53ab9677 100644 --- a/tests/expectations/no_copy.rs +++ b/tests/expectations/no_copy.rs @@ -7,7 +7,7 @@ /** <div rustbindgen nocopy></div> */ #[repr(C)] #[derive(Debug)] -pub struct Struct_CopiableButWait<T> { +pub struct CopiableButWait<T> { pub whatever: ::std::os::raw::c_int, - pub _phantom0: ::std::marker::PhantomData<T>, + pub _phantom_0: ::std::marker::PhantomData<T>, } diff --git a/tests/expectations/nsStyleAutoArray.rs b/tests/expectations/nsStyleAutoArray.rs index 8acfa150..c150ec46 100644 --- a/tests/expectations/nsStyleAutoArray.rs +++ b/tests/expectations/nsStyleAutoArray.rs @@ -6,17 +6,17 @@ #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct Struct_nsTArray<T> { +pub struct nsTArray<T> { pub mBuff: *mut T, } #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct Struct_nsStyleAutoArray<T> { +pub struct nsStyleAutoArray<T> { pub mFirstElement: T, - pub mOtherElements: Struct_nsTArray<T>, + pub mOtherElements: nsTArray<T>, } #[repr(i32)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum nsStyleAutoArray_WithSingleInitialElement { WITH_SINGLE_INITIAL_ELEMENT = 0, } diff --git a/tests/expectations/only_bitfields.rs b/tests/expectations/only_bitfields.rs index d46a1f83..68968826 100644 --- a/tests/expectations/only_bitfields.rs +++ b/tests/expectations/only_bitfields.rs @@ -6,34 +6,40 @@ #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_C { +pub struct C { pub _bitfield_1: u8, } -impl Struct_C { +#[test] +fn bindgen_test_layout_C() { + assert_eq!(::std::mem::size_of::<C>() , 1usize); + assert_eq!(::std::mem::align_of::<C>() , 1usize); +} +impl Clone for C { + fn clone(&self) -> Self { *self } +} +impl C { #[inline] - pub fn a(&self) -> u8 { (self._bitfield_1 & (1usize as u8)) >> 0usize } + pub fn a(&self) -> bool { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (1usize as u8)) >> + 0u32) as u8) + } + } #[inline] pub fn set_a(&mut self, val: bool) { self._bitfield_1 &= !(1usize as u8); - self._bitfield_1 |= ((val as u8) << 0usize) & (1usize as u8); + self._bitfield_1 |= ((val as u8 as u8) << 0u32) & (1usize as u8); } #[inline] - pub fn b(&self) -> u8 { (self._bitfield_1 & (254usize as u8)) >> 1usize } - #[inline] - pub fn set_b(&mut self, val: u8) { - self._bitfield_1 &= !(254usize as u8); - self._bitfield_1 |= ((val as u8) << 1usize) & (254usize as u8); + pub fn b(&self) -> bool { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (254usize as u8)) >> + 1u32) as u8) + } } #[inline] - pub fn new_bitfield_1(a: bool, b: u8) -> u8 { - 0 | ((a as u8) << 0u32) | ((b as u8) << 1u32) + pub fn set_b(&mut self, val: bool) { + self._bitfield_1 &= !(254usize as u8); + self._bitfield_1 |= ((val as u8 as u8) << 1u32) & (254usize as u8); } } -impl ::std::clone::Clone for Struct_C { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_Struct_C() { - assert_eq!(::std::mem::size_of::<Struct_C>() , 1usize); - assert_eq!(::std::mem::align_of::<Struct_C>() , 1usize); -} diff --git a/tests/expectations/opaque_in_struct.rs b/tests/expectations/opaque_in_struct.rs index a5e3dff6..d537f5c7 100644 --- a/tests/expectations/opaque_in_struct.rs +++ b/tests/expectations/opaque_in_struct.rs @@ -4,7 +4,9 @@ #![allow(non_snake_case)] +/** <div rustbindgen opaque> */ #[repr(C)] +#[derive(Debug, Copy)] pub struct opaque { pub _bindgen_opaque_blob: u32, } @@ -13,12 +15,19 @@ fn bindgen_test_layout_opaque() { assert_eq!(::std::mem::size_of::<opaque>() , 4usize); assert_eq!(::std::mem::align_of::<opaque>() , 4usize); } +impl Clone for opaque { + fn clone(&self) -> Self { *self } +} #[repr(C)] -pub struct Struct_container { +#[derive(Debug, Copy)] +pub struct container { pub contained: u32, } #[test] -fn bindgen_test_layout_Struct_container() { - assert_eq!(::std::mem::size_of::<Struct_container>() , 4usize); - assert_eq!(::std::mem::align_of::<Struct_container>() , 4usize); +fn bindgen_test_layout_container() { + assert_eq!(::std::mem::size_of::<container>() , 4usize); + assert_eq!(::std::mem::align_of::<container>() , 4usize); +} +impl Clone for container { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/opaque_pointer.rs b/tests/expectations/opaque_pointer.rs index eb5f09cd..067f55bd 100644 --- a/tests/expectations/opaque_pointer.rs +++ b/tests/expectations/opaque_pointer.rs @@ -4,7 +4,11 @@ #![allow(non_snake_case)] +/** + * <div rustbindgen opaque></div> + */ #[repr(C)] +#[derive(Debug, Copy)] pub struct OtherOpaque { pub _bindgen_opaque_blob: u32, } @@ -13,16 +17,29 @@ fn bindgen_test_layout_OtherOpaque() { assert_eq!(::std::mem::size_of::<OtherOpaque>() , 4usize); assert_eq!(::std::mem::align_of::<OtherOpaque>() , 4usize); } +impl Clone for OtherOpaque { + fn clone(&self) -> Self { *self } +} +/** + * <div rustbindgen opaque></div> + */ #[repr(C)] -pub struct Opaque; +#[derive(Debug, Copy, Clone)] +pub struct Opaque<T> { + pub _phantom_0: ::std::marker::PhantomData<T>, +} #[repr(C)] -pub struct Struct_WithOpaquePtr { - pub whatever: u64, +#[derive(Debug, Copy)] +pub struct WithOpaquePtr { + pub whatever: *mut Opaque<::std::os::raw::c_int>, pub other: u32, pub t: u32, } #[test] -fn bindgen_test_layout_Struct_WithOpaquePtr() { - assert_eq!(::std::mem::size_of::<Struct_WithOpaquePtr>() , 16usize); - assert_eq!(::std::mem::align_of::<Struct_WithOpaquePtr>() , 8usize); +fn bindgen_test_layout_WithOpaquePtr() { + assert_eq!(::std::mem::size_of::<WithOpaquePtr>() , 16usize); + assert_eq!(::std::mem::align_of::<WithOpaquePtr>() , 8usize); +} +impl Clone for WithOpaquePtr { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/opaque_typedef.rs b/tests/expectations/opaque_typedef.rs index a54ac881..c45cbc6f 100644 --- a/tests/expectations/opaque_typedef.rs +++ b/tests/expectations/opaque_typedef.rs @@ -6,11 +6,10 @@ #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct Struct_RandomTemplate<T> { - pub _phantom0: ::std::marker::PhantomData<T>, +pub struct RandomTemplate<T> { + pub _address: u8, + pub _phantom_0: ::std::marker::PhantomData<T>, } -pub enum Struct_Wat { } -pub enum Struct_Wat3 { } -#[repr(C)] -pub struct ShouldBeOpaque; -pub type ShouldNotBeOpaque = Struct_RandomTemplate<::std::os::raw::c_int>; +/** <div rustbindgen opaque></div> */ +pub type ShouldBeOpaque = [u8; 0usize]; +pub type ShouldNotBeOpaque = RandomTemplate<f32>; diff --git a/tests/expectations/overflowed_enum.rs b/tests/expectations/overflowed_enum.rs index 2228e44b..9e1f8a7f 100644 --- a/tests/expectations/overflowed_enum.rs +++ b/tests/expectations/overflowed_enum.rs @@ -5,12 +5,12 @@ #[repr(u32)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -pub enum Enum_Foo { +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum Foo { BAP_ARM = 9698489, BAP_X86 = 11960045, BAP_X86_64 = 3128633167, } #[repr(u16)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -pub enum Enum_Bar { One = 1, Big = 2, } +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum Bar { One = 1, Big = 2, } diff --git a/tests/expectations/private.rs b/tests/expectations/private.rs index 7263e3ee..c4ac37d1 100644 --- a/tests/expectations/private.rs +++ b/tests/expectations/private.rs @@ -6,47 +6,47 @@ #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_HasPrivate { +pub struct HasPrivate { pub mNotPrivate: ::std::os::raw::c_int, /** <div rustbindgen private></div> */ mIsPrivate: ::std::os::raw::c_int, } -impl ::std::clone::Clone for Struct_HasPrivate { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_HasPrivate() { - assert_eq!(::std::mem::size_of::<Struct_HasPrivate>() , 8usize); - assert_eq!(::std::mem::align_of::<Struct_HasPrivate>() , 4usize); +fn bindgen_test_layout_HasPrivate() { + assert_eq!(::std::mem::size_of::<HasPrivate>() , 8usize); + assert_eq!(::std::mem::align_of::<HasPrivate>() , 4usize); +} +impl Clone for HasPrivate { + fn clone(&self) -> Self { *self } } /** <div rustbindgen private></div> */ #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_VeryPrivate { +pub struct VeryPrivate { mIsPrivate: ::std::os::raw::c_int, mIsAlsoPrivate: ::std::os::raw::c_int, } -impl ::std::clone::Clone for Struct_VeryPrivate { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_VeryPrivate() { - assert_eq!(::std::mem::size_of::<Struct_VeryPrivate>() , 8usize); - assert_eq!(::std::mem::align_of::<Struct_VeryPrivate>() , 4usize); +fn bindgen_test_layout_VeryPrivate() { + assert_eq!(::std::mem::size_of::<VeryPrivate>() , 8usize); + assert_eq!(::std::mem::align_of::<VeryPrivate>() , 4usize); +} +impl Clone for VeryPrivate { + fn clone(&self) -> Self { *self } } /** <div rustbindgen private></div> */ #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_ContradictPrivate { - /** <div rustbindgen private=false></div> */ - mNotPrivate: ::std::os::raw::c_int, +pub struct ContradictPrivate { + /** <div rustbindgen private="false"></div> */ + pub mNotPrivate: ::std::os::raw::c_int, mIsPrivate: ::std::os::raw::c_int, } -impl ::std::clone::Clone for Struct_ContradictPrivate { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_ContradictPrivate() { - assert_eq!(::std::mem::size_of::<Struct_ContradictPrivate>() , 8usize); - assert_eq!(::std::mem::align_of::<Struct_ContradictPrivate>() , 4usize); +fn bindgen_test_layout_ContradictPrivate() { + assert_eq!(::std::mem::size_of::<ContradictPrivate>() , 8usize); + assert_eq!(::std::mem::align_of::<ContradictPrivate>() , 4usize); +} +impl Clone for ContradictPrivate { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/redeclaration.rs b/tests/expectations/redeclaration.rs new file mode 100644 index 00000000..0d7e585c --- /dev/null +++ b/tests/expectations/redeclaration.rs @@ -0,0 +1,9 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +extern "C" { + pub fn foo(); +} diff --git a/tests/expectations/ref_argument_array.rs b/tests/expectations/ref_argument_array.rs index 9660fbf2..5cfac9d8 100644 --- a/tests/expectations/ref_argument_array.rs +++ b/tests/expectations/ref_argument_array.rs @@ -6,22 +6,18 @@ pub const NSID_LENGTH: ::std::os::raw::c_uint = 10; #[repr(C)] -#[derive(Debug, Copy)] -pub struct Struct_nsID { - pub _vftable: *const _vftable_Struct_nsID, +pub struct bindgen_vtable__bindgen_id_4 { } #[repr(C)] -pub struct _vftable_Struct_nsID { - pub ToProvidedString: unsafe extern "C" fn(this: - *mut ::std::os::raw::c_void, - aDest: - *mut [::std::os::raw::c_char; 10usize]), -} -impl ::std::clone::Clone for Struct_nsID { - fn clone(&self) -> Self { *self } +#[derive(Debug, Copy)] +pub struct nsID { + pub vtable_: *const bindgen_vtable__bindgen_id_4, } #[test] -fn bindgen_test_layout_Struct_nsID() { - assert_eq!(::std::mem::size_of::<Struct_nsID>() , 8usize); - assert_eq!(::std::mem::align_of::<Struct_nsID>() , 8usize); +fn bindgen_test_layout_nsID() { + assert_eq!(::std::mem::size_of::<nsID>() , 8usize); + assert_eq!(::std::mem::align_of::<nsID>() , 8usize); +} +impl Clone for nsID { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/size_t_template.rs b/tests/expectations/size_t_template.rs index 6f249ae5..78351ecc 100644 --- a/tests/expectations/size_t_template.rs +++ b/tests/expectations/size_t_template.rs @@ -5,12 +5,15 @@ #[repr(C)] -#[derive(Debug)] -pub struct Struct_C { +#[derive(Debug, Copy)] +pub struct C { pub arr: [u32; 3usize], } #[test] -fn bindgen_test_layout_Struct_C() { - assert_eq!(::std::mem::size_of::<Struct_C>() , 12usize); - assert_eq!(::std::mem::align_of::<Struct_C>() , 4usize); +fn bindgen_test_layout_C() { + assert_eq!(::std::mem::size_of::<C>() , 12usize); + assert_eq!(::std::mem::align_of::<C>() , 4usize); +} +impl Clone for C { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/struct_containing_forward_declared_struct.rs b/tests/expectations/struct_containing_forward_declared_struct.rs index 11ca55b8..388cc595 100644 --- a/tests/expectations/struct_containing_forward_declared_struct.rs +++ b/tests/expectations/struct_containing_forward_declared_struct.rs @@ -6,27 +6,27 @@ #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_a { - pub val_a: *mut Struct_b, -} -impl ::std::clone::Clone for Struct_a { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_Struct_a() { - assert_eq!(::std::mem::size_of::<Struct_a>() , 8usize); - assert_eq!(::std::mem::align_of::<Struct_a>() , 8usize); +pub struct a { + pub val_a: *mut a_b, } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_b { +pub struct a_b { pub val_b: ::std::os::raw::c_int, } -impl ::std::clone::Clone for Struct_b { +#[test] +fn bindgen_test_layout_a_b() { + assert_eq!(::std::mem::size_of::<a_b>() , 4usize); + assert_eq!(::std::mem::align_of::<a_b>() , 4usize); +} +impl Clone for a_b { fn clone(&self) -> Self { *self } } #[test] -fn bindgen_test_layout_Struct_b() { - assert_eq!(::std::mem::size_of::<Struct_b>() , 4usize); - assert_eq!(::std::mem::align_of::<Struct_b>() , 4usize); +fn bindgen_test_layout_a() { + assert_eq!(::std::mem::size_of::<a>() , 8usize); + assert_eq!(::std::mem::align_of::<a>() , 8usize); +} +impl Clone for a { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/struct_with_anon_struct.rs b/tests/expectations/struct_with_anon_struct.rs index 52495279..e28c4fc0 100644 --- a/tests/expectations/struct_with_anon_struct.rs +++ b/tests/expectations/struct_with_anon_struct.rs @@ -6,30 +6,30 @@ #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_foo { - pub bar: Struct_foo_struct_with_anon_struct_h_unnamed_1, +pub struct foo { + pub bar: foo__bindgen_ty_bindgen_id_2, } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_foo_struct_with_anon_struct_h_unnamed_1 { +pub struct foo__bindgen_ty_bindgen_id_2 { pub a: ::std::os::raw::c_int, pub b: ::std::os::raw::c_int, } -impl ::std::clone::Clone for Struct_foo_struct_with_anon_struct_h_unnamed_1 { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_foo_struct_with_anon_struct_h_unnamed_1() { - assert_eq!(::std::mem::size_of::<Struct_foo_struct_with_anon_struct_h_unnamed_1>() - , 8usize); - assert_eq!(::std::mem::align_of::<Struct_foo_struct_with_anon_struct_h_unnamed_1>() - , 4usize); +fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_2() { + assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_2>() , + 8usize); + assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_2>() , + 4usize); } -impl ::std::clone::Clone for Struct_foo { +impl Clone for foo__bindgen_ty_bindgen_id_2 { fn clone(&self) -> Self { *self } } #[test] -fn bindgen_test_layout_Struct_foo() { - assert_eq!(::std::mem::size_of::<Struct_foo>() , 8usize); - assert_eq!(::std::mem::align_of::<Struct_foo>() , 4usize); +fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::<foo>() , 8usize); + assert_eq!(::std::mem::align_of::<foo>() , 4usize); +} +impl Clone for foo { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/struct_with_anon_struct_array.rs b/tests/expectations/struct_with_anon_struct_array.rs index 19a16cd6..48cc71d2 100644 --- a/tests/expectations/struct_with_anon_struct_array.rs +++ b/tests/expectations/struct_with_anon_struct_array.rs @@ -6,49 +6,47 @@ #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_foo { - pub bar: [Struct_foo_struct_with_anon_struct_array_h_unnamed_1; 2usize], - pub baz: [[[Struct_foo_struct_with_anon_struct_array_h_unnamed_2; 4usize]; 3usize]; 2usize], +pub struct foo { + pub bar: [foo__bindgen_ty_bindgen_id_2; 2usize], + pub baz: [[[foo__bindgen_ty_bindgen_id_6; 4usize]; 3usize]; 2usize], } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_foo_struct_with_anon_struct_array_h_unnamed_1 { +pub struct foo__bindgen_ty_bindgen_id_2 { pub a: ::std::os::raw::c_int, pub b: ::std::os::raw::c_int, } -impl ::std::clone::Clone for - Struct_foo_struct_with_anon_struct_array_h_unnamed_1 { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_foo_struct_with_anon_struct_array_h_unnamed_1() { - assert_eq!(::std::mem::size_of::<Struct_foo_struct_with_anon_struct_array_h_unnamed_1>() - , 8usize); - assert_eq!(::std::mem::align_of::<Struct_foo_struct_with_anon_struct_array_h_unnamed_1>() - , 4usize); +fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_2() { + assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_2>() , + 8usize); + assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_2>() , + 4usize); +} +impl Clone for foo__bindgen_ty_bindgen_id_2 { + fn clone(&self) -> Self { *self } } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_foo_struct_with_anon_struct_array_h_unnamed_2 { +pub struct foo__bindgen_ty_bindgen_id_6 { pub a: ::std::os::raw::c_int, pub b: ::std::os::raw::c_int, } -impl ::std::clone::Clone for - Struct_foo_struct_with_anon_struct_array_h_unnamed_2 { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_foo_struct_with_anon_struct_array_h_unnamed_2() { - assert_eq!(::std::mem::size_of::<Struct_foo_struct_with_anon_struct_array_h_unnamed_2>() - , 8usize); - assert_eq!(::std::mem::align_of::<Struct_foo_struct_with_anon_struct_array_h_unnamed_2>() - , 4usize); +fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_6() { + assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_6>() , + 8usize); + assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_6>() , + 4usize); } -impl ::std::clone::Clone for Struct_foo { +impl Clone for foo__bindgen_ty_bindgen_id_6 { fn clone(&self) -> Self { *self } } #[test] -fn bindgen_test_layout_Struct_foo() { - assert_eq!(::std::mem::size_of::<Struct_foo>() , 208usize); - assert_eq!(::std::mem::align_of::<Struct_foo>() , 4usize); +fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::<foo>() , 208usize); + assert_eq!(::std::mem::align_of::<foo>() , 4usize); +} +impl Clone for foo { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/struct_with_anon_struct_pointer.rs b/tests/expectations/struct_with_anon_struct_pointer.rs index 84aa0f15..a4b693a7 100644 --- a/tests/expectations/struct_with_anon_struct_pointer.rs +++ b/tests/expectations/struct_with_anon_struct_pointer.rs @@ -6,31 +6,30 @@ #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_foo { - pub bar: *mut Struct_foo_struct_with_anon_struct_pointer_h_unnamed_1, +pub struct foo { + pub bar: *mut foo__bindgen_ty_bindgen_id_2, } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_foo_struct_with_anon_struct_pointer_h_unnamed_1 { +pub struct foo__bindgen_ty_bindgen_id_2 { pub a: ::std::os::raw::c_int, pub b: ::std::os::raw::c_int, } -impl ::std::clone::Clone for - Struct_foo_struct_with_anon_struct_pointer_h_unnamed_1 { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_foo_struct_with_anon_struct_pointer_h_unnamed_1() { - assert_eq!(::std::mem::size_of::<Struct_foo_struct_with_anon_struct_pointer_h_unnamed_1>() - , 8usize); - assert_eq!(::std::mem::align_of::<Struct_foo_struct_with_anon_struct_pointer_h_unnamed_1>() - , 4usize); +fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_2() { + assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_2>() , + 8usize); + assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_2>() , + 4usize); } -impl ::std::clone::Clone for Struct_foo { +impl Clone for foo__bindgen_ty_bindgen_id_2 { fn clone(&self) -> Self { *self } } #[test] -fn bindgen_test_layout_Struct_foo() { - assert_eq!(::std::mem::size_of::<Struct_foo>() , 8usize); - assert_eq!(::std::mem::align_of::<Struct_foo>() , 8usize); +fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::<foo>() , 8usize); + assert_eq!(::std::mem::align_of::<foo>() , 8usize); +} +impl Clone for foo { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/struct_with_anon_union.rs b/tests/expectations/struct_with_anon_union.rs index 04883f78..889bccf7 100644 --- a/tests/expectations/struct_with_anon_union.rs +++ b/tests/expectations/struct_with_anon_union.rs @@ -4,7 +4,7 @@ #![allow(non_snake_case)] -#[derive(Copy, Debug)] +#[derive(Debug)] #[repr(C)] pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>); impl <T> __BindgenUnionField<T> { @@ -23,43 +23,34 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> { #[inline] fn clone(&self) -> Self { Self::new() } } +impl <T> ::std::marker::Copy for __BindgenUnionField<T> { } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_foo { - pub bar: Union_foo_struct_with_anon_union_h_unnamed_1, +pub struct foo { + pub bar: foo__bindgen_ty_bindgen_id_2, } #[repr(C)] #[derive(Debug, Copy)] -pub struct Union_foo_struct_with_anon_union_h_unnamed_1 { +pub struct foo__bindgen_ty_bindgen_id_2 { pub a: __BindgenUnionField<::std::os::raw::c_uint>, pub b: __BindgenUnionField<::std::os::raw::c_ushort>, - pub _bindgen_data_: u32, + pub bindgen_union_field: u32, } -impl Union_foo_struct_with_anon_union_h_unnamed_1 { - pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_uint { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn b(&mut self) -> *mut ::std::os::raw::c_ushort { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } +#[test] +fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_2() { + assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_2>() , + 4usize); + assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_2>() , + 4usize); } -impl ::std::clone::Clone for Union_foo_struct_with_anon_union_h_unnamed_1 { +impl Clone for foo__bindgen_ty_bindgen_id_2 { fn clone(&self) -> Self { *self } } #[test] -fn bindgen_test_layout_Union_foo_struct_with_anon_union_h_unnamed_1() { - assert_eq!(::std::mem::size_of::<Union_foo_struct_with_anon_union_h_unnamed_1>() - , 4usize); - assert_eq!(::std::mem::align_of::<Union_foo_struct_with_anon_union_h_unnamed_1>() - , 4usize); +fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::<foo>() , 4usize); + assert_eq!(::std::mem::align_of::<foo>() , 4usize); } -impl ::std::clone::Clone for Struct_foo { +impl Clone for foo { fn clone(&self) -> Self { *self } } -#[test] -fn bindgen_test_layout_Struct_foo() { - assert_eq!(::std::mem::size_of::<Struct_foo>() , 4usize); - assert_eq!(::std::mem::align_of::<Struct_foo>() , 4usize); -} diff --git a/tests/expectations/struct_with_anon_unnamed_struct.rs b/tests/expectations/struct_with_anon_unnamed_struct.rs index 6f7afeae..ca590b1b 100644 --- a/tests/expectations/struct_with_anon_unnamed_struct.rs +++ b/tests/expectations/struct_with_anon_unnamed_struct.rs @@ -6,31 +6,30 @@ #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_foo { - pub foo_struct_with_anon_unnamed_struct_h_unnamed_1: Struct_foo_struct_with_anon_unnamed_struct_h_unnamed_1, +pub struct foo { + pub __bindgen_anon_1: foo__bindgen_ty_bindgen_id_2, } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_foo_struct_with_anon_unnamed_struct_h_unnamed_1 { +pub struct foo__bindgen_ty_bindgen_id_2 { pub a: ::std::os::raw::c_uint, pub b: ::std::os::raw::c_uint, } -impl ::std::clone::Clone for - Struct_foo_struct_with_anon_unnamed_struct_h_unnamed_1 { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_foo_struct_with_anon_unnamed_struct_h_unnamed_1() { - assert_eq!(::std::mem::size_of::<Struct_foo_struct_with_anon_unnamed_struct_h_unnamed_1>() - , 8usize); - assert_eq!(::std::mem::align_of::<Struct_foo_struct_with_anon_unnamed_struct_h_unnamed_1>() - , 4usize); +fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_2() { + assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_2>() , + 8usize); + assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_2>() , + 4usize); } -impl ::std::clone::Clone for Struct_foo { +impl Clone for foo__bindgen_ty_bindgen_id_2 { fn clone(&self) -> Self { *self } } #[test] -fn bindgen_test_layout_Struct_foo() { - assert_eq!(::std::mem::size_of::<Struct_foo>() , 8usize); - assert_eq!(::std::mem::align_of::<Struct_foo>() , 4usize); +fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::<foo>() , 8usize); + assert_eq!(::std::mem::align_of::<foo>() , 4usize); +} +impl Clone for foo { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/struct_with_anon_unnamed_union.rs b/tests/expectations/struct_with_anon_unnamed_union.rs index 73bd0111..013a9184 100644 --- a/tests/expectations/struct_with_anon_unnamed_union.rs +++ b/tests/expectations/struct_with_anon_unnamed_union.rs @@ -4,7 +4,7 @@ #![allow(non_snake_case)] -#[derive(Copy, Debug)] +#[derive(Debug)] #[repr(C)] pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>); impl <T> __BindgenUnionField<T> { @@ -23,44 +23,34 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> { #[inline] fn clone(&self) -> Self { Self::new() } } +impl <T> ::std::marker::Copy for __BindgenUnionField<T> { } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_foo { - pub foo_struct_with_anon_unnamed_union_h_unnamed_1: Union_foo_struct_with_anon_unnamed_union_h_unnamed_1, +pub struct foo { + pub __bindgen_anon_1: foo__bindgen_ty_bindgen_id_2, } #[repr(C)] #[derive(Debug, Copy)] -pub struct Union_foo_struct_with_anon_unnamed_union_h_unnamed_1 { +pub struct foo__bindgen_ty_bindgen_id_2 { pub a: __BindgenUnionField<::std::os::raw::c_uint>, pub b: __BindgenUnionField<::std::os::raw::c_ushort>, - pub _bindgen_data_: u32, + pub bindgen_union_field: u32, } -impl Union_foo_struct_with_anon_unnamed_union_h_unnamed_1 { - pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_uint { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn b(&mut self) -> *mut ::std::os::raw::c_ushort { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } +#[test] +fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_2() { + assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_2>() , + 4usize); + assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_2>() , + 4usize); } -impl ::std::clone::Clone for - Union_foo_struct_with_anon_unnamed_union_h_unnamed_1 { +impl Clone for foo__bindgen_ty_bindgen_id_2 { fn clone(&self) -> Self { *self } } #[test] -fn bindgen_test_layout_Union_foo_struct_with_anon_unnamed_union_h_unnamed_1() { - assert_eq!(::std::mem::size_of::<Union_foo_struct_with_anon_unnamed_union_h_unnamed_1>() - , 4usize); - assert_eq!(::std::mem::align_of::<Union_foo_struct_with_anon_unnamed_union_h_unnamed_1>() - , 4usize); +fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::<foo>() , 4usize); + assert_eq!(::std::mem::align_of::<foo>() , 4usize); } -impl ::std::clone::Clone for Struct_foo { +impl Clone for foo { fn clone(&self) -> Self { *self } } -#[test] -fn bindgen_test_layout_Struct_foo() { - assert_eq!(::std::mem::size_of::<Struct_foo>() , 4usize); - assert_eq!(::std::mem::align_of::<Struct_foo>() , 4usize); -} diff --git a/tests/expectations/struct_with_bitfields.rs b/tests/expectations/struct_with_bitfields.rs index c2bfc543..3fb83a47 100644 --- a/tests/expectations/struct_with_bitfields.rs +++ b/tests/expectations/struct_with_bitfields.rs @@ -6,127 +6,117 @@ #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_bitfield { - pub _bitfield_1: ::std::os::raw::c_ushort, +pub struct bitfield { + pub _bitfield_1: u8, pub e: ::std::os::raw::c_int, - pub _bitfield_2: ::std::os::raw::c_uint, - pub _bitfield_3: ::std::os::raw::c_uint, + pub _bitfield_2: u8, + pub _bitfield_3: u32, } -impl Struct_bitfield { +#[test] +fn bindgen_test_layout_bitfield() { + assert_eq!(::std::mem::size_of::<bitfield>() , 16usize); + assert_eq!(::std::mem::align_of::<bitfield>() , 4usize); +} +impl Clone for bitfield { + fn clone(&self) -> Self { *self } +} +impl bitfield { #[inline] pub fn a(&self) -> ::std::os::raw::c_ushort { - (self._bitfield_1 & (1usize as ::std::os::raw::c_ushort)) >> 0usize + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (1usize as u8)) >> + 0u32) as u16) + } } #[inline] - pub fn set_a(&mut self, val: bool) { - self._bitfield_1 &= !(1usize as ::std::os::raw::c_ushort); - self._bitfield_1 |= - ((val as ::std::os::raw::c_ushort) << 0usize) & - (1usize as ::std::os::raw::c_ushort); + pub fn set_a(&mut self, val: ::std::os::raw::c_ushort) { + self._bitfield_1 &= !(1usize as u8); + self._bitfield_1 |= ((val as u16 as u8) << 0u32) & (1usize as u8); } #[inline] pub fn b(&self) -> ::std::os::raw::c_ushort { - (self._bitfield_1 & (2usize as ::std::os::raw::c_ushort)) >> 1usize + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (2usize as u8)) >> + 1u32) as u16) + } } #[inline] - pub fn set_b(&mut self, val: bool) { - self._bitfield_1 &= !(2usize as ::std::os::raw::c_ushort); - self._bitfield_1 |= - ((val as ::std::os::raw::c_ushort) << 1usize) & - (2usize as ::std::os::raw::c_ushort); + pub fn set_b(&mut self, val: ::std::os::raw::c_ushort) { + self._bitfield_1 &= !(2usize as u8); + self._bitfield_1 |= ((val as u16 as u8) << 1u32) & (2usize as u8); } #[inline] pub fn c(&self) -> ::std::os::raw::c_ushort { - (self._bitfield_1 & (4usize as ::std::os::raw::c_ushort)) >> 2usize + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (4usize as u8)) >> + 2u32) as u16) + } } #[inline] - pub fn set_c(&mut self, val: bool) { - self._bitfield_1 &= !(4usize as ::std::os::raw::c_ushort); - self._bitfield_1 |= - ((val as ::std::os::raw::c_ushort) << 2usize) & - (4usize as ::std::os::raw::c_ushort); + pub fn set_c(&mut self, val: ::std::os::raw::c_ushort) { + self._bitfield_1 &= !(4usize as u8); + self._bitfield_1 |= ((val as u16 as u8) << 2u32) & (4usize as u8); } #[inline] pub fn at_offset_3(&self) -> ::std::os::raw::c_ushort { - (self._bitfield_1 & (8usize as ::std::os::raw::c_ushort)) >> 3usize + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (8usize as u8)) >> + 3u32) as u16) + } } #[inline] - pub fn set_at_offset_3(&mut self, val: bool) { - self._bitfield_1 &= !(8usize as ::std::os::raw::c_ushort); - self._bitfield_1 |= - ((val as ::std::os::raw::c_ushort) << 3usize) & - (8usize as ::std::os::raw::c_ushort); + pub fn set_at_offset_3(&mut self, val: ::std::os::raw::c_ushort) { + self._bitfield_1 &= !(8usize as u8); + self._bitfield_1 |= ((val as u16 as u8) << 3u32) & (8usize as u8); } #[inline] pub fn at_offset_4(&self) -> ::std::os::raw::c_ushort { - (self._bitfield_1 & (48usize as ::std::os::raw::c_ushort)) >> 4usize + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (48usize as u8)) >> + 4u32) as u16) + } } #[inline] - pub fn set_at_offset_4(&mut self, val: u8) { - self._bitfield_1 &= !(48usize as ::std::os::raw::c_ushort); - self._bitfield_1 |= - ((val as ::std::os::raw::c_ushort) << 4usize) & - (48usize as ::std::os::raw::c_ushort); + pub fn set_at_offset_4(&mut self, val: ::std::os::raw::c_ushort) { + self._bitfield_1 &= !(48usize as u8); + self._bitfield_1 |= ((val as u16 as u8) << 4u32) & (48usize as u8); } #[inline] pub fn d(&self) -> ::std::os::raw::c_ushort { - (self._bitfield_1 & (192usize as ::std::os::raw::c_ushort)) >> 6usize + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (192usize as u8)) >> + 6u32) as u16) + } } #[inline] - pub fn set_d(&mut self, val: u8) { - self._bitfield_1 &= !(192usize as ::std::os::raw::c_ushort); - self._bitfield_1 |= - ((val as ::std::os::raw::c_ushort) << 6usize) & - (192usize as ::std::os::raw::c_ushort); - } - #[inline] - pub fn new_bitfield_1(a: bool, b: bool, c: bool, unnamed_bitfield1: bool, - unnamed_bitfield2: u8, d: u8) - -> ::std::os::raw::c_ushort { - 0 | ((a as ::std::os::raw::c_ushort) << 0u32) | - ((b as ::std::os::raw::c_ushort) << 1u32) | - ((c as ::std::os::raw::c_ushort) << 2u32) | - ((unnamed_bitfield1 as ::std::os::raw::c_ushort) << 3u32) | - ((unnamed_bitfield2 as ::std::os::raw::c_ushort) << 4u32) | - ((d as ::std::os::raw::c_ushort) << 6u32) + pub fn set_d(&mut self, val: ::std::os::raw::c_ushort) { + self._bitfield_1 &= !(192usize as u8); + self._bitfield_1 |= ((val as u16 as u8) << 6u32) & (192usize as u8); } #[inline] pub fn f(&self) -> ::std::os::raw::c_uint { - (self._bitfield_2 & (3usize as ::std::os::raw::c_uint)) >> 0usize - } - #[inline] - pub fn set_f(&mut self, val: u8) { - self._bitfield_2 &= !(3usize as ::std::os::raw::c_uint); - self._bitfield_2 |= - ((val as ::std::os::raw::c_uint) << 0usize) & - (3usize as ::std::os::raw::c_uint); + unsafe { + ::std::mem::transmute(((self._bitfield_2 & (3usize as u8)) >> + 0u32) as u32) + } } #[inline] - pub fn new_bitfield_2(f: u8) -> ::std::os::raw::c_uint { - 0 | ((f as ::std::os::raw::c_uint) << 0u32) + pub fn set_f(&mut self, val: ::std::os::raw::c_uint) { + self._bitfield_2 &= !(3usize as u8); + self._bitfield_2 |= ((val as u32 as u8) << 0u32) & (3usize as u8); } #[inline] pub fn g(&self) -> ::std::os::raw::c_uint { - (self._bitfield_3 & (4294967295usize as ::std::os::raw::c_uint)) >> - 0usize + unsafe { + ::std::mem::transmute(((self._bitfield_3 & + (4294967295usize as u32)) >> 0u32) as + u32) + } } #[inline] - pub fn set_g(&mut self, val: u32) { - self._bitfield_3 &= !(4294967295usize as ::std::os::raw::c_uint); + pub fn set_g(&mut self, val: ::std::os::raw::c_uint) { + self._bitfield_3 &= !(4294967295usize as u32); self._bitfield_3 |= - ((val as ::std::os::raw::c_uint) << 0usize) & - (4294967295usize as ::std::os::raw::c_uint); - } - #[inline] - pub fn new_bitfield_3(g: u32) -> ::std::os::raw::c_uint { - 0 | ((g as ::std::os::raw::c_uint) << 0u32) + ((val as u32 as u32) << 0u32) & (4294967295usize as u32); } } -impl ::std::clone::Clone for Struct_bitfield { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_Struct_bitfield() { - assert_eq!(::std::mem::size_of::<Struct_bitfield>() , 16usize); - assert_eq!(::std::mem::align_of::<Struct_bitfield>() , 4usize); -} diff --git a/tests/expectations/struct_with_derive_debug.rs b/tests/expectations/struct_with_derive_debug.rs index f89d9d72..52906a81 100644 --- a/tests/expectations/struct_with_derive_debug.rs +++ b/tests/expectations/struct_with_derive_debug.rs @@ -6,53 +6,45 @@ #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_LittleArray { +pub struct LittleArray { pub a: [::std::os::raw::c_int; 32usize], } -impl ::std::clone::Clone for Struct_LittleArray { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_LittleArray() { - assert_eq!(::std::mem::size_of::<Struct_LittleArray>() , 128usize); - assert_eq!(::std::mem::align_of::<Struct_LittleArray>() , 4usize); +fn bindgen_test_layout_LittleArray() { + assert_eq!(::std::mem::size_of::<LittleArray>() , 128usize); + assert_eq!(::std::mem::align_of::<LittleArray>() , 4usize); +} +impl Clone for LittleArray { + fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Copy)] -pub struct Struct_BigArray { +pub struct BigArray { pub a: [::std::os::raw::c_int; 33usize], } -impl ::std::clone::Clone for Struct_BigArray { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_BigArray() { - assert_eq!(::std::mem::size_of::<Struct_BigArray>() , 132usize); - assert_eq!(::std::mem::align_of::<Struct_BigArray>() , 4usize); +fn bindgen_test_layout_BigArray() { + assert_eq!(::std::mem::size_of::<BigArray>() , 132usize); + assert_eq!(::std::mem::align_of::<BigArray>() , 4usize); } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_WithLittleArray { - pub a: Struct_LittleArray, -} -impl ::std::clone::Clone for Struct_WithLittleArray { - fn clone(&self) -> Self { *self } +pub struct WithLittleArray { + pub a: LittleArray, } #[test] -fn bindgen_test_layout_Struct_WithLittleArray() { - assert_eq!(::std::mem::size_of::<Struct_WithLittleArray>() , 128usize); - assert_eq!(::std::mem::align_of::<Struct_WithLittleArray>() , 4usize); -} -#[repr(C)] -#[derive(Copy)] -pub struct Struct_WithBigArray { - pub a: Struct_BigArray, +fn bindgen_test_layout_WithLittleArray() { + assert_eq!(::std::mem::size_of::<WithLittleArray>() , 128usize); + assert_eq!(::std::mem::align_of::<WithLittleArray>() , 4usize); } -impl ::std::clone::Clone for Struct_WithBigArray { +impl Clone for WithLittleArray { fn clone(&self) -> Self { *self } } +#[repr(C)] +pub struct WithBigArray { + pub a: BigArray, +} #[test] -fn bindgen_test_layout_Struct_WithBigArray() { - assert_eq!(::std::mem::size_of::<Struct_WithBigArray>() , 132usize); - assert_eq!(::std::mem::align_of::<Struct_WithBigArray>() , 4usize); +fn bindgen_test_layout_WithBigArray() { + assert_eq!(::std::mem::size_of::<WithBigArray>() , 132usize); + assert_eq!(::std::mem::align_of::<WithBigArray>() , 4usize); } diff --git a/tests/expectations/struct_with_nesting.rs b/tests/expectations/struct_with_nesting.rs index 2de481ea..ca5ec09e 100644 --- a/tests/expectations/struct_with_nesting.rs +++ b/tests/expectations/struct_with_nesting.rs @@ -4,7 +4,7 @@ #![allow(non_snake_case)] -#[derive(Copy, Debug)] +#[derive(Debug)] #[repr(C)] pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>); impl <T> __BindgenUnionField<T> { @@ -23,89 +23,70 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> { #[inline] fn clone(&self) -> Self { Self::new() } } +impl <T> ::std::marker::Copy for __BindgenUnionField<T> { } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_foo { +pub struct foo { pub a: ::std::os::raw::c_uint, - pub foo_struct_with_nesting_h_unnamed_1: Union_foo_struct_with_nesting_h_unnamed_1, + pub __bindgen_anon_1: foo__bindgen_ty_bindgen_id_3, } #[repr(C)] #[derive(Debug, Copy)] -pub struct Union_foo_struct_with_nesting_h_unnamed_1 { +pub struct foo__bindgen_ty_bindgen_id_3 { pub b: __BindgenUnionField<::std::os::raw::c_uint>, - pub foo_struct_with_nesting_h_unnamed_1_struct_with_nesting_h_unnamed_2: __BindgenUnionField<Struct_foo_struct_with_nesting_h_unnamed_1_struct_with_nesting_h_unnamed_2>, - pub foo_struct_with_nesting_h_unnamed_1_struct_with_nesting_h_unnamed_3: __BindgenUnionField<Struct_foo_struct_with_nesting_h_unnamed_1_struct_with_nesting_h_unnamed_3>, - pub _bindgen_data_: u32, -} -impl Union_foo_struct_with_nesting_h_unnamed_1 { - pub unsafe fn b(&mut self) -> *mut ::std::os::raw::c_uint { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn foo_struct_with_nesting_h_unnamed_1_struct_with_nesting_h_unnamed_2(&mut self) - -> - *mut Struct_foo_struct_with_nesting_h_unnamed_1_struct_with_nesting_h_unnamed_2 { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn foo_struct_with_nesting_h_unnamed_1_struct_with_nesting_h_unnamed_3(&mut self) - -> - *mut Struct_foo_struct_with_nesting_h_unnamed_1_struct_with_nesting_h_unnamed_3 { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } -} -impl ::std::clone::Clone for Union_foo_struct_with_nesting_h_unnamed_1 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_Union_foo_struct_with_nesting_h_unnamed_1() { - assert_eq!(::std::mem::size_of::<Union_foo_struct_with_nesting_h_unnamed_1>() - , 4usize); - assert_eq!(::std::mem::align_of::<Union_foo_struct_with_nesting_h_unnamed_1>() - , 4usize); + pub __bindgen_anon_1: __BindgenUnionField<foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_5>, + pub __bindgen_anon_2: __BindgenUnionField<foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_8>, + pub bindgen_union_field: u32, } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_foo_struct_with_nesting_h_unnamed_1_struct_with_nesting_h_unnamed_2 { +pub struct foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_5 { pub c1: ::std::os::raw::c_ushort, pub c2: ::std::os::raw::c_ushort, } -impl ::std::clone::Clone for - Struct_foo_struct_with_nesting_h_unnamed_1_struct_with_nesting_h_unnamed_2 { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_foo_struct_with_nesting_h_unnamed_1_struct_with_nesting_h_unnamed_2() { - assert_eq!(::std::mem::size_of::<Struct_foo_struct_with_nesting_h_unnamed_1_struct_with_nesting_h_unnamed_2>() +fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_5() { + assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_5>() , 4usize); - assert_eq!(::std::mem::align_of::<Struct_foo_struct_with_nesting_h_unnamed_1_struct_with_nesting_h_unnamed_2>() + assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_5>() , 2usize); } +impl Clone for foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_5 { + fn clone(&self) -> Self { *self } +} #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_foo_struct_with_nesting_h_unnamed_1_struct_with_nesting_h_unnamed_3 { +pub struct foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_8 { pub d1: ::std::os::raw::c_uchar, pub d2: ::std::os::raw::c_uchar, pub d3: ::std::os::raw::c_uchar, pub d4: ::std::os::raw::c_uchar, } -impl ::std::clone::Clone for - Struct_foo_struct_with_nesting_h_unnamed_1_struct_with_nesting_h_unnamed_3 { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_foo_struct_with_nesting_h_unnamed_1_struct_with_nesting_h_unnamed_3() { - assert_eq!(::std::mem::size_of::<Struct_foo_struct_with_nesting_h_unnamed_1_struct_with_nesting_h_unnamed_3>() +fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_8() { + assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_8>() , 4usize); - assert_eq!(::std::mem::align_of::<Struct_foo_struct_with_nesting_h_unnamed_1_struct_with_nesting_h_unnamed_3>() + assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_8>() , 1usize); } -impl ::std::clone::Clone for Struct_foo { +impl Clone for foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_8 { fn clone(&self) -> Self { *self } } #[test] -fn bindgen_test_layout_Struct_foo() { - assert_eq!(::std::mem::size_of::<Struct_foo>() , 8usize); - assert_eq!(::std::mem::align_of::<Struct_foo>() , 4usize); +fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_3() { + assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_3>() , + 4usize); + assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_3>() , + 4usize); +} +impl Clone for foo__bindgen_ty_bindgen_id_3 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::<foo>() , 8usize); + assert_eq!(::std::mem::align_of::<foo>() , 4usize); +} +impl Clone for foo { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/struct_with_packing.rs b/tests/expectations/struct_with_packing.rs index 9f997435..93fc3f11 100644 --- a/tests/expectations/struct_with_packing.rs +++ b/tests/expectations/struct_with_packing.rs @@ -6,15 +6,15 @@ #[repr(C, packed)] #[derive(Debug, Copy)] -pub struct Struct_a { +pub struct a { pub b: ::std::os::raw::c_char, pub c: ::std::os::raw::c_short, } -impl ::std::clone::Clone for Struct_a { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_a() { - assert_eq!(::std::mem::size_of::<Struct_a>() , 3usize); - assert_eq!(::std::mem::align_of::<Struct_a>() , 1usize); +fn bindgen_test_layout_a() { + assert_eq!(::std::mem::size_of::<a>() , 3usize); + assert_eq!(::std::mem::align_of::<a>() , 1usize); +} +impl Clone for a { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/struct_with_struct.rs b/tests/expectations/struct_with_struct.rs index 0c6ab122..27ff4795 100644 --- a/tests/expectations/struct_with_struct.rs +++ b/tests/expectations/struct_with_struct.rs @@ -6,30 +6,30 @@ #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_foo { - pub bar: Struct_foo_struct_with_struct_h_unnamed_1, +pub struct foo { + pub bar: foo__bindgen_ty_bindgen_id_2, } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_foo_struct_with_struct_h_unnamed_1 { +pub struct foo__bindgen_ty_bindgen_id_2 { pub x: ::std::os::raw::c_uint, pub y: ::std::os::raw::c_uint, } -impl ::std::clone::Clone for Struct_foo_struct_with_struct_h_unnamed_1 { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_foo_struct_with_struct_h_unnamed_1() { - assert_eq!(::std::mem::size_of::<Struct_foo_struct_with_struct_h_unnamed_1>() - , 8usize); - assert_eq!(::std::mem::align_of::<Struct_foo_struct_with_struct_h_unnamed_1>() - , 4usize); +fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_2() { + assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_2>() , + 8usize); + assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_2>() , + 4usize); } -impl ::std::clone::Clone for Struct_foo { +impl Clone for foo__bindgen_ty_bindgen_id_2 { fn clone(&self) -> Self { *self } } #[test] -fn bindgen_test_layout_Struct_foo() { - assert_eq!(::std::mem::size_of::<Struct_foo>() , 8usize); - assert_eq!(::std::mem::align_of::<Struct_foo>() , 4usize); +fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::<foo>() , 8usize); + assert_eq!(::std::mem::align_of::<foo>() , 4usize); +} +impl Clone for foo { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/template.rs b/tests/expectations/template.rs index 2f3f9a21..76afc879 100644 --- a/tests/expectations/template.rs +++ b/tests/expectations/template.rs @@ -6,110 +6,129 @@ #[repr(C)] #[derive(Debug)] -pub struct Struct_Foo<T, U> { +pub struct Foo<T, U> { pub m_member: T, pub m_member_ptr: *mut T, pub m_member_arr: [T; 1usize], - pub _phantom0: ::std::marker::PhantomData<U>, + pub _phantom_1: ::std::marker::PhantomData<U>, +} +extern "C" { + #[link_name = "_Z3bar3FooIiiE"] + pub fn bar(foo: Foo<::std::os::raw::c_int, ::std::os::raw::c_int>); } #[repr(C)] #[derive(Debug)] -pub struct Struct_D<T> { - pub m_foo: Struct_Foo<::std::os::raw::c_int, ::std::os::raw::c_int>, - pub _phantom0: ::std::marker::PhantomData<T>, +pub struct D<T> { + pub m_foo: D_MyFoo, + pub _phantom_0: ::std::marker::PhantomData<T>, } +pub type D_MyFoo = Foo<::std::os::raw::c_int, ::std::os::raw::c_int>; #[repr(C)] #[derive(Debug)] -pub struct Struct_D_U<T, Z> { - pub m_nested_foo: Struct_Foo<::std::os::raw::c_int, - ::std::os::raw::c_int>, +pub struct D_U<T, Z> { + pub m_nested_foo: D_MyFoo, pub m_baz: Z, - pub _phantom0: ::std::marker::PhantomData<T>, + pub _phantom_0: ::std::marker::PhantomData<T>, } #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct Struct_Rooted<T> { +pub struct Rooted<T> { pub prev: *mut T, - pub next: *mut Struct_Rooted<*mut ::std::os::raw::c_void>, + pub next: *mut Rooted<*mut ::std::os::raw::c_void>, pub ptr: T, } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_RootedContainer { - pub root: Struct_Rooted<*mut ::std::os::raw::c_void>, -} -impl ::std::clone::Clone for Struct_RootedContainer { - fn clone(&self) -> Self { *self } +pub struct RootedContainer { + pub root: Rooted<*mut ::std::os::raw::c_void>, } #[test] -fn bindgen_test_layout_Struct_RootedContainer() { - assert_eq!(::std::mem::size_of::<Struct_RootedContainer>() , 24usize); - assert_eq!(::std::mem::align_of::<Struct_RootedContainer>() , 8usize); +fn bindgen_test_layout_RootedContainer() { + assert_eq!(::std::mem::size_of::<RootedContainer>() , 24usize); + assert_eq!(::std::mem::align_of::<RootedContainer>() , 8usize); +} +impl Clone for RootedContainer { + fn clone(&self) -> Self { *self } } -pub type WithDtorIntFwd = Struct_WithDtor<::std::os::raw::c_int>; #[repr(C)] #[derive(Debug)] -pub struct Struct_WithDtor<T> { +pub struct WithDtor<T> { pub member: T, } +pub type WithDtorIntFwd = WithDtor<::std::os::raw::c_int>; #[repr(C)] #[derive(Debug)] -pub struct Struct_PODButContainsDtor { +pub struct PODButContainsDtor { pub member: WithDtorIntFwd, } #[test] -fn bindgen_test_layout_Struct_PODButContainsDtor() { - assert_eq!(::std::mem::size_of::<Struct_PODButContainsDtor>() , 4usize); - assert_eq!(::std::mem::align_of::<Struct_PODButContainsDtor>() , 4usize); +fn bindgen_test_layout_PODButContainsDtor() { + assert_eq!(::std::mem::size_of::<PODButContainsDtor>() , 4usize); + assert_eq!(::std::mem::align_of::<PODButContainsDtor>() , 4usize); } +/** <div rustbindgen opaque> */ #[repr(C)] -pub struct Opaque; +#[derive(Debug, Copy, Clone)] +pub struct Opaque<T> { + pub _phantom_0: ::std::marker::PhantomData<T>, +} #[repr(C)] -pub struct Struct_POD { +#[derive(Debug, Copy)] +pub struct POD { pub opaque_member: u32, } #[test] -fn bindgen_test_layout_Struct_POD() { - assert_eq!(::std::mem::size_of::<Struct_POD>() , 4usize); - assert_eq!(::std::mem::align_of::<Struct_POD>() , 4usize); +fn bindgen_test_layout_POD() { + assert_eq!(::std::mem::size_of::<POD>() , 4usize); + assert_eq!(::std::mem::align_of::<POD>() , 4usize); } -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Struct_NestedBase<T, U> { - pub buff: *mut T, - pub _phantom0: ::std::marker::PhantomData<U>, +impl Clone for POD { + fn clone(&self) -> Self { *self } } /** * <div rustbindgen replaces="NestedReplaced"></div> */ #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct Struct_NestedReplaced<T> { +pub struct NestedReplaced<T> { pub buff: *mut T, } #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct Struct_NestedContainer<T> { - pub c: T, - pub nested: Struct_NestedReplaced<T>, - pub inc: Struct_Incomplete<T>, +pub struct NestedBase<T, U> { + pub buff: *mut T, + pub _phantom_1: ::std::marker::PhantomData<U>, } #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct Struct_Incomplete<T> { +pub struct Incomplete<T> { pub d: T, } #[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct NestedContainer<T> { + pub c: T, + pub nested: NestedReplaced<T>, + pub inc: Incomplete<T>, +} +#[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_Untemplated; -impl ::std::clone::Clone for Struct_Untemplated { +pub struct Untemplated { + pub _address: u8, +} +#[test] +fn bindgen_test_layout_Untemplated() { + assert_eq!(::std::mem::size_of::<Untemplated>() , 1usize); + assert_eq!(::std::mem::align_of::<Untemplated>() , 1usize); +} +impl Clone for Untemplated { fn clone(&self) -> Self { *self } } #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct Struct_Templated<T> { - pub m_untemplated: Struct_Untemplated, - pub _phantom0: ::std::marker::PhantomData<T>, +pub struct Templated<T> { + pub m_untemplated: Untemplated, + pub _phantom_0: ::std::marker::PhantomData<T>, } /** * If the replacement doesn't happen at the parse level the container would be @@ -119,9 +138,19 @@ pub struct Struct_Templated<T> { */ #[repr(C)] #[derive(Debug)] -pub struct Struct_ReplacedWithoutDestructor<T> { +pub struct ReplacedWithoutDestructor<T> { pub buff: *mut T, } +#[repr(C)] +#[derive(Debug)] +pub struct ShouldNotBeCopiable<T> { + pub m_member: ReplacedWithoutDestructor<T>, +} +#[repr(C)] +#[derive(Debug)] +pub struct ShouldNotBeCopiableAsWell<U> { + pub m_member: ReplacedWithoutDestructorFwd<U>, +} /** * If the replacement doesn't happen at the parse level the container would be * copy and the replacement wouldn't, so this wouldn't compile. @@ -130,25 +159,12 @@ pub struct Struct_ReplacedWithoutDestructor<T> { */ #[repr(C)] #[derive(Debug)] -pub struct Struct_ReplacedWithoutDestructorFwd<T> { +pub struct ReplacedWithoutDestructorFwd<T> { pub buff: *mut T, } #[repr(C)] -#[derive(Debug)] -pub struct Struct_ShouldNotBeCopiable<T> { - pub m_member: Struct_ReplacedWithoutDestructor<T>, -} -#[repr(C)] -#[derive(Debug)] -pub struct Struct_ShouldNotBeCopiableAsWell<U> { - pub m_member: Struct_ReplacedWithoutDestructorFwd<U>, -} -#[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct Struct_TemplateWithVar<T> { - pub _phantom0: ::std::marker::PhantomData<T>, -} -extern "C" { - #[link_name = "_Z3bar3FooIiiE"] - pub fn bar(foo: Struct_Foo<::std::os::raw::c_int, ::std::os::raw::c_int>); +pub struct TemplateWithVar<T> { + pub _address: u8, + pub _phantom_0: ::std::marker::PhantomData<T>, } diff --git a/tests/expectations/typeref.rs b/tests/expectations/typeref.rs new file mode 100644 index 00000000..35a873c9 --- /dev/null +++ b/tests/expectations/typeref.rs @@ -0,0 +1,92 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[derive(Debug)] +#[repr(C)] +pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>); +impl <T> __BindgenUnionField<T> { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } +} +impl <T> ::std::default::Default for __BindgenUnionField<T> { + #[inline] + fn default() -> Self { Self::new() } +} +impl <T> ::std::clone::Clone for __BindgenUnionField<T> { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl <T> ::std::marker::Copy for __BindgenUnionField<T> { } +#[repr(C)] +#[derive(Debug, Copy)] +pub struct nsFoo { + pub mBar: StyleShapeSource<::std::os::raw::c_int>, +} +#[test] +fn bindgen_test_layout_nsFoo() { + assert_eq!(::std::mem::size_of::<nsFoo>() , 8usize); + assert_eq!(::std::mem::align_of::<nsFoo>() , 8usize); +} +impl Clone for nsFoo { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct FragmentOrURL { + pub mIsLocalRef: bool, +} +#[test] +fn bindgen_test_layout_FragmentOrURL() { + assert_eq!(::std::mem::size_of::<FragmentOrURL>() , 1usize); + assert_eq!(::std::mem::align_of::<FragmentOrURL>() , 1usize); +} +impl Clone for FragmentOrURL { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Position { + pub _address: u8, +} +#[test] +fn bindgen_test_layout_Position() { + assert_eq!(::std::mem::size_of::<Position>() , 1usize); + assert_eq!(::std::mem::align_of::<Position>() , 1usize); +} +impl Clone for Position { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Bar { + pub mFoo: *mut nsFoo, +} +#[test] +fn bindgen_test_layout_Bar() { + assert_eq!(::std::mem::size_of::<Bar>() , 8usize); + assert_eq!(::std::mem::align_of::<Bar>() , 8usize); +} +impl Clone for Bar { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct StyleShapeSource<ReferenceBox> { + pub __bindgen_anon_1: StyleShapeSource__bindgen_ty_bindgen_id_13<ReferenceBox>, + pub _phantom_0: ::std::marker::PhantomData<ReferenceBox>, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct StyleShapeSource__bindgen_ty_bindgen_id_13<ReferenceBox> { + pub mPosition: __BindgenUnionField<*mut Position>, + pub mFragmentOrURL: __BindgenUnionField<*mut FragmentOrURL>, + pub bindgen_union_field: u64, + pub _phantom_0: ::std::marker::PhantomData<ReferenceBox>, +} diff --git a/tests/expectations/union_dtor.rs b/tests/expectations/union_dtor.rs index c1e260da..4d1fa25a 100644 --- a/tests/expectations/union_dtor.rs +++ b/tests/expectations/union_dtor.rs @@ -4,7 +4,7 @@ #![allow(non_snake_case)] -#[derive(Copy, Debug)] +#[derive(Debug)] #[repr(C)] pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>); impl <T> __BindgenUnionField<T> { @@ -23,25 +23,16 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> { #[inline] fn clone(&self) -> Self { Self::new() } } +impl <T> ::std::marker::Copy for __BindgenUnionField<T> { } #[repr(C)] #[derive(Debug)] -pub struct Union_UnionWithDtor { +pub struct UnionWithDtor { pub mFoo: __BindgenUnionField<::std::os::raw::c_int>, pub mBar: __BindgenUnionField<*mut ::std::os::raw::c_void>, - pub _bindgen_data_: u64, -} -impl Union_UnionWithDtor { - pub unsafe fn mFoo(&mut self) -> *mut ::std::os::raw::c_int { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn mBar(&mut self) -> *mut *mut ::std::os::raw::c_void { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } + pub bindgen_union_field: u64, } #[test] -fn bindgen_test_layout_Union_UnionWithDtor() { - assert_eq!(::std::mem::size_of::<Union_UnionWithDtor>() , 8usize); - assert_eq!(::std::mem::align_of::<Union_UnionWithDtor>() , 8usize); +fn bindgen_test_layout_UnionWithDtor() { + assert_eq!(::std::mem::size_of::<UnionWithDtor>() , 8usize); + assert_eq!(::std::mem::align_of::<UnionWithDtor>() , 8usize); } diff --git a/tests/expectations/union_fields.rs b/tests/expectations/union_fields.rs index 1a957eaa..684a9e04 100644 --- a/tests/expectations/union_fields.rs +++ b/tests/expectations/union_fields.rs @@ -4,7 +4,7 @@ #![allow(non_snake_case)] -#[derive(Copy, Debug)] +#[derive(Debug)] #[repr(C)] pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>); impl <T> __BindgenUnionField<T> { @@ -23,36 +23,21 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> { #[inline] fn clone(&self) -> Self { Self::new() } } +impl <T> ::std::marker::Copy for __BindgenUnionField<T> { } #[repr(C)] #[derive(Debug, Copy)] -pub struct Union_union_fields_hpp_unnamed_1 { +pub struct _bindgen_ty_bindgen_id_1 { pub mInt: __BindgenUnionField<::std::os::raw::c_int>, pub mFloat: __BindgenUnionField<f32>, pub mPointer: __BindgenUnionField<*mut ::std::os::raw::c_void>, - pub _bindgen_data_: u64, + pub bindgen_union_field: u64, } -impl Union_union_fields_hpp_unnamed_1 { - pub unsafe fn mInt(&mut self) -> *mut ::std::os::raw::c_int { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn mFloat(&mut self) -> *mut f32 { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn mPointer(&mut self) -> *mut *mut ::std::os::raw::c_void { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } +#[test] +fn bindgen_test_layout__bindgen_ty_bindgen_id_1() { + assert_eq!(::std::mem::size_of::<_bindgen_ty_bindgen_id_1>() , 8usize); + assert_eq!(::std::mem::align_of::<_bindgen_ty_bindgen_id_1>() , 8usize); } -impl ::std::clone::Clone for Union_union_fields_hpp_unnamed_1 { +impl Clone for _bindgen_ty_bindgen_id_1 { fn clone(&self) -> Self { *self } } -#[test] -fn bindgen_test_layout_Union_union_fields_hpp_unnamed_1() { - assert_eq!(::std::mem::size_of::<Union_union_fields_hpp_unnamed_1>() , - 8usize); - assert_eq!(::std::mem::align_of::<Union_union_fields_hpp_unnamed_1>() , - 8usize); -} -pub type nsStyleUnion = Union_union_fields_hpp_unnamed_1; +pub type nsStyleUnion = _bindgen_ty_bindgen_id_1; diff --git a/tests/expectations/union_template.rs b/tests/expectations/union_template.rs index eb6705f0..f07087de 100644 --- a/tests/expectations/union_template.rs +++ b/tests/expectations/union_template.rs @@ -4,7 +4,7 @@ #![allow(non_snake_case)] -#[derive(Copy, Debug)] +#[derive(Debug)] #[repr(C)] pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>); impl <T> __BindgenUnionField<T> { @@ -23,64 +23,36 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> { #[inline] fn clone(&self) -> Self { Self::new() } } +impl <T> ::std::marker::Copy for __BindgenUnionField<T> { } #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct Struct_NastyStruct<T> { +pub struct NastyStruct<T> { pub mIsSome: bool, - pub mStorage: Union_NastyStruct_union_template_hpp_unnamed_1<T>, - pub NastyStruct_union_template_hpp_unnamed_2: Union_NastyStruct_union_template_hpp_unnamed_2<T>, + pub mStorage: NastyStruct__bindgen_ty_bindgen_id_5<T>, + pub __bindgen_anon_1: NastyStruct__bindgen_ty_bindgen_id_9<T>, + pub _phantom_0: ::std::marker::PhantomData<T>, } #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct Union_NastyStruct_union_template_hpp_unnamed_1<T> { +pub struct NastyStruct__bindgen_ty_bindgen_id_5<T> { pub mFoo: __BindgenUnionField<*mut ::std::os::raw::c_void>, pub mDummy: __BindgenUnionField<::std::os::raw::c_ulong>, - pub _bindgen_data_: u64, - pub _phantom0: ::std::marker::PhantomData<T>, -} -impl <T> Union_NastyStruct_union_template_hpp_unnamed_1<T> { - pub unsafe fn mFoo(&mut self) -> *mut *mut ::std::os::raw::c_void { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn mDummy(&mut self) -> *mut ::std::os::raw::c_ulong { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } + pub bindgen_union_field: u64, + pub _phantom_0: ::std::marker::PhantomData<T>, } #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct Union_NastyStruct_union_template_hpp_unnamed_2<T> { +pub struct NastyStruct__bindgen_ty_bindgen_id_9<T> { pub wat: __BindgenUnionField<::std::os::raw::c_short>, pub wut: __BindgenUnionField<*mut ::std::os::raw::c_int>, - pub _bindgen_data_: u64, - pub _phantom0: ::std::marker::PhantomData<T>, -} -impl <T> Union_NastyStruct_union_template_hpp_unnamed_2<T> { - pub unsafe fn wat(&mut self) -> *mut ::std::os::raw::c_short { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn wut(&mut self) -> *mut *mut ::std::os::raw::c_int { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } + pub bindgen_union_field: u64, + pub _phantom_0: ::std::marker::PhantomData<T>, } #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct Union_Whatever<T> { +pub struct Whatever<T> { pub mTPtr: __BindgenUnionField<*mut ::std::os::raw::c_void>, pub mInt: __BindgenUnionField<::std::os::raw::c_int>, - pub _bindgen_data_: u64, - pub _phantom0: ::std::marker::PhantomData<T>, -} -impl <T> Union_Whatever<T> { - pub unsafe fn mTPtr(&mut self) -> *mut *mut ::std::os::raw::c_void { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn mInt(&mut self) -> *mut ::std::os::raw::c_int { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } + pub bindgen_union_field: u64, + pub _phantom_0: ::std::marker::PhantomData<T>, } diff --git a/tests/expectations/union_with_anon_struct.rs b/tests/expectations/union_with_anon_struct.rs index 850f39bc..f216b0bf 100644 --- a/tests/expectations/union_with_anon_struct.rs +++ b/tests/expectations/union_with_anon_struct.rs @@ -4,7 +4,7 @@ #![allow(non_snake_case)] -#[derive(Copy, Debug)] +#[derive(Debug)] #[repr(C)] pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>); impl <T> __BindgenUnionField<T> { @@ -23,40 +23,34 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> { #[inline] fn clone(&self) -> Self { Self::new() } } +impl <T> ::std::marker::Copy for __BindgenUnionField<T> { } #[repr(C)] #[derive(Debug, Copy)] -pub struct Union_foo { - pub bar: __BindgenUnionField<Struct_foo_union_with_anon_struct_h_unnamed_1>, - pub _bindgen_data_: [u32; 2usize], -} -impl Union_foo { - pub unsafe fn bar(&mut self) - -> *mut Struct_foo_union_with_anon_struct_h_unnamed_1 { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } -} -impl ::std::clone::Clone for Union_foo { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_Union_foo() { - assert_eq!(::std::mem::size_of::<Union_foo>() , 8usize); - assert_eq!(::std::mem::align_of::<Union_foo>() , 4usize); +pub struct foo { + pub bar: __BindgenUnionField<foo__bindgen_ty_bindgen_id_2>, + pub bindgen_union_field: [u32; 2usize], } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_foo_union_with_anon_struct_h_unnamed_1 { +pub struct foo__bindgen_ty_bindgen_id_2 { pub a: ::std::os::raw::c_uint, pub b: ::std::os::raw::c_uint, } -impl ::std::clone::Clone for Struct_foo_union_with_anon_struct_h_unnamed_1 { +#[test] +fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_2() { + assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_2>() , + 8usize); + assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_2>() , + 4usize); +} +impl Clone for foo__bindgen_ty_bindgen_id_2 { fn clone(&self) -> Self { *self } } #[test] -fn bindgen_test_layout_Struct_foo_union_with_anon_struct_h_unnamed_1() { - assert_eq!(::std::mem::size_of::<Struct_foo_union_with_anon_struct_h_unnamed_1>() - , 8usize); - assert_eq!(::std::mem::align_of::<Struct_foo_union_with_anon_struct_h_unnamed_1>() - , 4usize); +fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::<foo>() , 8usize); + assert_eq!(::std::mem::align_of::<foo>() , 4usize); +} +impl Clone for foo { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/union_with_anon_struct_bitfield.rs b/tests/expectations/union_with_anon_struct_bitfield.rs index ce59836e..80be0e55 100644 --- a/tests/expectations/union_with_anon_struct_bitfield.rs +++ b/tests/expectations/union_with_anon_struct_bitfield.rs @@ -4,7 +4,7 @@ #![allow(non_snake_case)] -#[derive(Copy, Debug)] +#[derive(Debug)] #[repr(C)] pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>); impl <T> __BindgenUnionField<T> { @@ -23,75 +23,62 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> { #[inline] fn clone(&self) -> Self { Self::new() } } +impl <T> ::std::marker::Copy for __BindgenUnionField<T> { } #[repr(C)] #[derive(Debug, Copy)] -pub struct Union_foo { +pub struct foo { pub a: __BindgenUnionField<::std::os::raw::c_int>, - pub foo_union_with_anon_struct_bitfield_h_unnamed_1: __BindgenUnionField<Struct_foo_union_with_anon_struct_bitfield_h_unnamed_1>, - pub _bindgen_data_: u32, + pub __bindgen_anon_1: __BindgenUnionField<foo__bindgen_ty_bindgen_id_3>, + pub bindgen_union_field: u32, } -impl Union_foo { - pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_int { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn foo_union_with_anon_struct_bitfield_h_unnamed_1(&mut self) - -> *mut Struct_foo_union_with_anon_struct_bitfield_h_unnamed_1 { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } -} -impl ::std::clone::Clone for Union_foo { - fn clone(&self) -> Self { *self } +#[repr(C)] +#[derive(Debug, Copy)] +pub struct foo__bindgen_ty_bindgen_id_3 { + pub _bitfield_1: u32, } #[test] -fn bindgen_test_layout_Union_foo() { - assert_eq!(::std::mem::size_of::<Union_foo>() , 4usize); - assert_eq!(::std::mem::align_of::<Union_foo>() , 4usize); +fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_3() { + assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_3>() , + 4usize); + assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_3>() , + 4usize); } -#[repr(C)] -#[derive(Debug, Copy)] -pub struct Struct_foo_union_with_anon_struct_bitfield_h_unnamed_1 { - pub _bitfield_1: ::std::os::raw::c_int, +impl Clone for foo__bindgen_ty_bindgen_id_3 { + fn clone(&self) -> Self { *self } } -impl Struct_foo_union_with_anon_struct_bitfield_h_unnamed_1 { +impl foo__bindgen_ty_bindgen_id_3 { #[inline] pub fn b(&self) -> ::std::os::raw::c_int { - (self._bitfield_1 & (127usize as ::std::os::raw::c_int)) >> 0usize + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (127usize as u32)) >> + 0u32) as u32) + } } #[inline] - pub fn set_b(&mut self, val: u8) { - self._bitfield_1 &= !(127usize as ::std::os::raw::c_int); - self._bitfield_1 |= - ((val as ::std::os::raw::c_int) << 0usize) & - (127usize as ::std::os::raw::c_int); + pub fn set_b(&mut self, val: ::std::os::raw::c_int) { + self._bitfield_1 &= !(127usize as u32); + self._bitfield_1 |= ((val as u32 as u32) << 0u32) & (127usize as u32); } #[inline] pub fn c(&self) -> ::std::os::raw::c_int { - (self._bitfield_1 & (4294967168usize as ::std::os::raw::c_int)) >> - 7usize + unsafe { + ::std::mem::transmute(((self._bitfield_1 & + (4294967168usize as u32)) >> 7u32) as + u32) + } } #[inline] - pub fn set_c(&mut self, val: u32) { - self._bitfield_1 &= !(4294967168usize as ::std::os::raw::c_int); + pub fn set_c(&mut self, val: ::std::os::raw::c_int) { + self._bitfield_1 &= !(4294967168usize as u32); self._bitfield_1 |= - ((val as ::std::os::raw::c_int) << 7usize) & - (4294967168usize as ::std::os::raw::c_int); - } - #[inline] - pub fn new_bitfield_1(b: u8, c: u32) -> ::std::os::raw::c_int { - 0 | ((b as ::std::os::raw::c_int) << 0u32) | - ((c as ::std::os::raw::c_int) << 7u32) + ((val as u32 as u32) << 7u32) & (4294967168usize as u32); } } -impl ::std::clone::Clone for - Struct_foo_union_with_anon_struct_bitfield_h_unnamed_1 { - fn clone(&self) -> Self { *self } -} #[test] -fn bindgen_test_layout_Struct_foo_union_with_anon_struct_bitfield_h_unnamed_1() { - assert_eq!(::std::mem::size_of::<Struct_foo_union_with_anon_struct_bitfield_h_unnamed_1>() - , 4usize); - assert_eq!(::std::mem::align_of::<Struct_foo_union_with_anon_struct_bitfield_h_unnamed_1>() - , 4usize); +fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::<foo>() , 4usize); + assert_eq!(::std::mem::align_of::<foo>() , 4usize); +} +impl Clone for foo { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/union_with_anon_union.rs b/tests/expectations/union_with_anon_union.rs index f610342d..e7f43cbe 100644 --- a/tests/expectations/union_with_anon_union.rs +++ b/tests/expectations/union_with_anon_union.rs @@ -4,7 +4,7 @@ #![allow(non_snake_case)] -#[derive(Copy, Debug)] +#[derive(Debug)] #[repr(C)] pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>); impl <T> __BindgenUnionField<T> { @@ -23,51 +23,35 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> { #[inline] fn clone(&self) -> Self { Self::new() } } +impl <T> ::std::marker::Copy for __BindgenUnionField<T> { } #[repr(C)] #[derive(Debug, Copy)] -pub struct Union_foo { - pub bar: __BindgenUnionField<Union_foo_union_with_anon_union_h_unnamed_1>, - pub _bindgen_data_: u32, -} -impl Union_foo { - pub unsafe fn bar(&mut self) - -> *mut Union_foo_union_with_anon_union_h_unnamed_1 { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } -} -impl ::std::clone::Clone for Union_foo { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_Union_foo() { - assert_eq!(::std::mem::size_of::<Union_foo>() , 4usize); - assert_eq!(::std::mem::align_of::<Union_foo>() , 4usize); +pub struct foo { + pub bar: __BindgenUnionField<foo__bindgen_ty_bindgen_id_2>, + pub bindgen_union_field: u32, } #[repr(C)] #[derive(Debug, Copy)] -pub struct Union_foo_union_with_anon_union_h_unnamed_1 { +pub struct foo__bindgen_ty_bindgen_id_2 { pub a: __BindgenUnionField<::std::os::raw::c_uint>, pub b: __BindgenUnionField<::std::os::raw::c_ushort>, - pub _bindgen_data_: u32, + pub bindgen_union_field: u32, } -impl Union_foo_union_with_anon_union_h_unnamed_1 { - pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_uint { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn b(&mut self) -> *mut ::std::os::raw::c_ushort { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } +#[test] +fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_2() { + assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_2>() , + 4usize); + assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_2>() , + 4usize); } -impl ::std::clone::Clone for Union_foo_union_with_anon_union_h_unnamed_1 { +impl Clone for foo__bindgen_ty_bindgen_id_2 { fn clone(&self) -> Self { *self } } #[test] -fn bindgen_test_layout_Union_foo_union_with_anon_union_h_unnamed_1() { - assert_eq!(::std::mem::size_of::<Union_foo_union_with_anon_union_h_unnamed_1>() - , 4usize); - assert_eq!(::std::mem::align_of::<Union_foo_union_with_anon_union_h_unnamed_1>() - , 4usize); +fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::<foo>() , 4usize); + assert_eq!(::std::mem::align_of::<foo>() , 4usize); +} +impl Clone for foo { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/union_with_anon_unnamed_struct.rs b/tests/expectations/union_with_anon_unnamed_struct.rs index cdc760c4..80b3e97a 100644 --- a/tests/expectations/union_with_anon_unnamed_struct.rs +++ b/tests/expectations/union_with_anon_unnamed_struct.rs @@ -4,7 +4,7 @@ #![allow(non_snake_case)] -#[derive(Copy, Debug)] +#[derive(Debug)] #[repr(C)] pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>); impl <T> __BindgenUnionField<T> { @@ -23,48 +23,37 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> { #[inline] fn clone(&self) -> Self { Self::new() } } +impl <T> ::std::marker::Copy for __BindgenUnionField<T> { } #[repr(C)] #[derive(Debug, Copy)] -pub struct Union_pixel { +pub struct pixel { pub rgba: __BindgenUnionField<::std::os::raw::c_uint>, - pub pixel_union_with_anon_unnamed_struct_h_unnamed_1: __BindgenUnionField<Struct_pixel_union_with_anon_unnamed_struct_h_unnamed_1>, - pub _bindgen_data_: u32, -} -impl Union_pixel { - pub unsafe fn rgba(&mut self) -> *mut ::std::os::raw::c_uint { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn pixel_union_with_anon_unnamed_struct_h_unnamed_1(&mut self) - -> *mut Struct_pixel_union_with_anon_unnamed_struct_h_unnamed_1 { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } -} -impl ::std::clone::Clone for Union_pixel { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_Union_pixel() { - assert_eq!(::std::mem::size_of::<Union_pixel>() , 4usize); - assert_eq!(::std::mem::align_of::<Union_pixel>() , 4usize); + pub __bindgen_anon_1: __BindgenUnionField<pixel__bindgen_ty_bindgen_id_3>, + pub bindgen_union_field: u32, } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_pixel_union_with_anon_unnamed_struct_h_unnamed_1 { +pub struct pixel__bindgen_ty_bindgen_id_3 { pub r: ::std::os::raw::c_uchar, pub g: ::std::os::raw::c_uchar, pub b: ::std::os::raw::c_uchar, pub a: ::std::os::raw::c_uchar, } -impl ::std::clone::Clone for - Struct_pixel_union_with_anon_unnamed_struct_h_unnamed_1 { +#[test] +fn bindgen_test_layout_pixel__bindgen_ty_bindgen_id_3() { + assert_eq!(::std::mem::size_of::<pixel__bindgen_ty_bindgen_id_3>() , + 4usize); + assert_eq!(::std::mem::align_of::<pixel__bindgen_ty_bindgen_id_3>() , + 1usize); +} +impl Clone for pixel__bindgen_ty_bindgen_id_3 { fn clone(&self) -> Self { *self } } #[test] -fn bindgen_test_layout_Struct_pixel_union_with_anon_unnamed_struct_h_unnamed_1() { - assert_eq!(::std::mem::size_of::<Struct_pixel_union_with_anon_unnamed_struct_h_unnamed_1>() - , 4usize); - assert_eq!(::std::mem::align_of::<Struct_pixel_union_with_anon_unnamed_struct_h_unnamed_1>() - , 1usize); +fn bindgen_test_layout_pixel() { + assert_eq!(::std::mem::size_of::<pixel>() , 4usize); + assert_eq!(::std::mem::align_of::<pixel>() , 4usize); +} +impl Clone for pixel { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/union_with_anon_unnamed_union.rs b/tests/expectations/union_with_anon_unnamed_union.rs index 50dfc8d0..3ddea69e 100644 --- a/tests/expectations/union_with_anon_unnamed_union.rs +++ b/tests/expectations/union_with_anon_unnamed_union.rs @@ -4,7 +4,7 @@ #![allow(non_snake_case)] -#[derive(Copy, Debug)] +#[derive(Debug)] #[repr(C)] pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>); impl <T> __BindgenUnionField<T> { @@ -23,57 +23,36 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> { #[inline] fn clone(&self) -> Self { Self::new() } } +impl <T> ::std::marker::Copy for __BindgenUnionField<T> { } #[repr(C)] #[derive(Debug, Copy)] -pub struct Union_foo { +pub struct foo { pub a: __BindgenUnionField<::std::os::raw::c_uint>, - pub foo_union_with_anon_unnamed_union_h_unnamed_1: __BindgenUnionField<Union_foo_union_with_anon_unnamed_union_h_unnamed_1>, - pub _bindgen_data_: u32, -} -impl Union_foo { - pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_uint { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn foo_union_with_anon_unnamed_union_h_unnamed_1(&mut self) - -> *mut Union_foo_union_with_anon_unnamed_union_h_unnamed_1 { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } -} -impl ::std::clone::Clone for Union_foo { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_Union_foo() { - assert_eq!(::std::mem::size_of::<Union_foo>() , 4usize); - assert_eq!(::std::mem::align_of::<Union_foo>() , 4usize); + pub __bindgen_anon_1: __BindgenUnionField<foo__bindgen_ty_bindgen_id_3>, + pub bindgen_union_field: u32, } #[repr(C)] #[derive(Debug, Copy)] -pub struct Union_foo_union_with_anon_unnamed_union_h_unnamed_1 { +pub struct foo__bindgen_ty_bindgen_id_3 { pub b: __BindgenUnionField<::std::os::raw::c_ushort>, pub c: __BindgenUnionField<::std::os::raw::c_uchar>, - pub _bindgen_data_: u16, + pub bindgen_union_field: u16, } -impl Union_foo_union_with_anon_unnamed_union_h_unnamed_1 { - pub unsafe fn b(&mut self) -> *mut ::std::os::raw::c_ushort { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn c(&mut self) -> *mut ::std::os::raw::c_uchar { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } +#[test] +fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_3() { + assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_3>() , + 2usize); + assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_3>() , + 2usize); } -impl ::std::clone::Clone for - Union_foo_union_with_anon_unnamed_union_h_unnamed_1 { +impl Clone for foo__bindgen_ty_bindgen_id_3 { fn clone(&self) -> Self { *self } } #[test] -fn bindgen_test_layout_Union_foo_union_with_anon_unnamed_union_h_unnamed_1() { - assert_eq!(::std::mem::size_of::<Union_foo_union_with_anon_unnamed_union_h_unnamed_1>() - , 2usize); - assert_eq!(::std::mem::align_of::<Union_foo_union_with_anon_unnamed_union_h_unnamed_1>() - , 2usize); +fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::<foo>() , 4usize); + assert_eq!(::std::mem::align_of::<foo>() , 4usize); +} +impl Clone for foo { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/union_with_big_member.rs b/tests/expectations/union_with_big_member.rs index d1cd63d4..521a5ff4 100644 --- a/tests/expectations/union_with_big_member.rs +++ b/tests/expectations/union_with_big_member.rs @@ -4,7 +4,7 @@ #![allow(non_snake_case)] -#[derive(Copy, Debug)] +#[derive(Debug)] #[repr(C)] pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>); impl <T> __BindgenUnionField<T> { @@ -23,53 +23,34 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> { #[inline] fn clone(&self) -> Self { Self::new() } } +impl <T> ::std::marker::Copy for __BindgenUnionField<T> { } #[repr(C)] #[derive(Copy)] -pub struct Union_WithBigArray { +pub struct WithBigArray { pub a: __BindgenUnionField<::std::os::raw::c_int>, pub b: __BindgenUnionField<[::std::os::raw::c_int; 33usize]>, - pub _bindgen_data_: [u32; 33usize], + pub bindgen_union_field: [u32; 33usize], } -impl Union_WithBigArray { - pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_int { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn b(&mut self) -> *mut [::std::os::raw::c_int; 33usize] { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } +#[test] +fn bindgen_test_layout_WithBigArray() { + assert_eq!(::std::mem::size_of::<WithBigArray>() , 132usize); + assert_eq!(::std::mem::align_of::<WithBigArray>() , 4usize); } -impl ::std::clone::Clone for Union_WithBigArray { +impl Clone for WithBigArray { fn clone(&self) -> Self { *self } } -#[test] -fn bindgen_test_layout_Union_WithBigArray() { - assert_eq!(::std::mem::size_of::<Union_WithBigArray>() , 132usize); - assert_eq!(::std::mem::align_of::<Union_WithBigArray>() , 4usize); -} #[repr(C)] #[derive(Copy)] -pub struct Union_WithBigMember { +pub struct WithBigMember { pub a: __BindgenUnionField<::std::os::raw::c_int>, - pub b: __BindgenUnionField<Union_WithBigArray>, - pub _bindgen_data_: [u32; 33usize], + pub b: __BindgenUnionField<WithBigArray>, + pub bindgen_union_field: [u32; 33usize], } -impl Union_WithBigMember { - pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_int { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn b(&mut self) -> *mut Union_WithBigArray { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } +#[test] +fn bindgen_test_layout_WithBigMember() { + assert_eq!(::std::mem::size_of::<WithBigMember>() , 132usize); + assert_eq!(::std::mem::align_of::<WithBigMember>() , 4usize); } -impl ::std::clone::Clone for Union_WithBigMember { +impl Clone for WithBigMember { fn clone(&self) -> Self { *self } } -#[test] -fn bindgen_test_layout_Union_WithBigMember() { - assert_eq!(::std::mem::size_of::<Union_WithBigMember>() , 132usize); - assert_eq!(::std::mem::align_of::<Union_WithBigMember>() , 4usize); -} diff --git a/tests/expectations/union_with_nesting.rs b/tests/expectations/union_with_nesting.rs index 4117786d..6b8d318d 100644 --- a/tests/expectations/union_with_nesting.rs +++ b/tests/expectations/union_with_nesting.rs @@ -4,7 +4,7 @@ #![allow(non_snake_case)] -#[derive(Copy, Debug)] +#[derive(Debug)] #[repr(C)] pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>); impl <T> __BindgenUnionField<T> { @@ -23,101 +23,69 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> { #[inline] fn clone(&self) -> Self { Self::new() } } +impl <T> ::std::marker::Copy for __BindgenUnionField<T> { } #[repr(C)] #[derive(Debug, Copy)] -pub struct Union_foo { +pub struct foo { pub a: __BindgenUnionField<::std::os::raw::c_uint>, - pub foo_union_with_nesting_h_unnamed_1: __BindgenUnionField<Struct_foo_union_with_nesting_h_unnamed_1>, - pub _bindgen_data_: u32, -} -impl Union_foo { - pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_uint { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn foo_union_with_nesting_h_unnamed_1(&mut self) - -> *mut Struct_foo_union_with_nesting_h_unnamed_1 { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } -} -impl ::std::clone::Clone for Union_foo { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_Union_foo() { - assert_eq!(::std::mem::size_of::<Union_foo>() , 4usize); - assert_eq!(::std::mem::align_of::<Union_foo>() , 4usize); + pub __bindgen_anon_1: __BindgenUnionField<foo__bindgen_ty_bindgen_id_3>, + pub bindgen_union_field: u32, } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_foo_union_with_nesting_h_unnamed_1 { - pub foo_union_with_nesting_h_unnamed_1_union_with_nesting_h_unnamed_2: Union_foo_union_with_nesting_h_unnamed_1_union_with_nesting_h_unnamed_2, - pub foo_union_with_nesting_h_unnamed_1_union_with_nesting_h_unnamed_3: Union_foo_union_with_nesting_h_unnamed_1_union_with_nesting_h_unnamed_3, +pub struct foo__bindgen_ty_bindgen_id_3 { + pub __bindgen_anon_1: foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_4, + pub __bindgen_anon_2: foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_7, } #[repr(C)] #[derive(Debug, Copy)] -pub struct Union_foo_union_with_nesting_h_unnamed_1_union_with_nesting_h_unnamed_2 { +pub struct foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_4 { pub b1: __BindgenUnionField<::std::os::raw::c_ushort>, pub b2: __BindgenUnionField<::std::os::raw::c_ushort>, - pub _bindgen_data_: u16, -} -impl Union_foo_union_with_nesting_h_unnamed_1_union_with_nesting_h_unnamed_2 { - pub unsafe fn b1(&mut self) -> *mut ::std::os::raw::c_ushort { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn b2(&mut self) -> *mut ::std::os::raw::c_ushort { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } -} -impl ::std::clone::Clone for - Union_foo_union_with_nesting_h_unnamed_1_union_with_nesting_h_unnamed_2 { - fn clone(&self) -> Self { *self } + pub bindgen_union_field: u16, } #[test] -fn bindgen_test_layout_Union_foo_union_with_nesting_h_unnamed_1_union_with_nesting_h_unnamed_2() { - assert_eq!(::std::mem::size_of::<Union_foo_union_with_nesting_h_unnamed_1_union_with_nesting_h_unnamed_2>() +fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_4() { + assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_4>() , 2usize); - assert_eq!(::std::mem::align_of::<Union_foo_union_with_nesting_h_unnamed_1_union_with_nesting_h_unnamed_2>() + assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_4>() , 2usize); } +impl Clone for foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_4 { + fn clone(&self) -> Self { *self } +} #[repr(C)] #[derive(Debug, Copy)] -pub struct Union_foo_union_with_nesting_h_unnamed_1_union_with_nesting_h_unnamed_3 { +pub struct foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_7 { pub c1: __BindgenUnionField<::std::os::raw::c_ushort>, pub c2: __BindgenUnionField<::std::os::raw::c_ushort>, - pub _bindgen_data_: u16, + pub bindgen_union_field: u16, } -impl Union_foo_union_with_nesting_h_unnamed_1_union_with_nesting_h_unnamed_3 { - pub unsafe fn c1(&mut self) -> *mut ::std::os::raw::c_ushort { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } - pub unsafe fn c2(&mut self) -> *mut ::std::os::raw::c_ushort { - let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); - ::std::mem::transmute(raw.offset(0)) - } +#[test] +fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_7() { + assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_7>() + , 2usize); + assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_7>() + , 2usize); } -impl ::std::clone::Clone for - Union_foo_union_with_nesting_h_unnamed_1_union_with_nesting_h_unnamed_3 { +impl Clone for foo__bindgen_ty_bindgen_id_3__bindgen_ty_bindgen_id_7 { fn clone(&self) -> Self { *self } } #[test] -fn bindgen_test_layout_Union_foo_union_with_nesting_h_unnamed_1_union_with_nesting_h_unnamed_3() { - assert_eq!(::std::mem::size_of::<Union_foo_union_with_nesting_h_unnamed_1_union_with_nesting_h_unnamed_3>() - , 2usize); - assert_eq!(::std::mem::align_of::<Union_foo_union_with_nesting_h_unnamed_1_union_with_nesting_h_unnamed_3>() - , 2usize); +fn bindgen_test_layout_foo__bindgen_ty_bindgen_id_3() { + assert_eq!(::std::mem::size_of::<foo__bindgen_ty_bindgen_id_3>() , + 4usize); + assert_eq!(::std::mem::align_of::<foo__bindgen_ty_bindgen_id_3>() , + 2usize); } -impl ::std::clone::Clone for Struct_foo_union_with_nesting_h_unnamed_1 { +impl Clone for foo__bindgen_ty_bindgen_id_3 { fn clone(&self) -> Self { *self } } #[test] -fn bindgen_test_layout_Struct_foo_union_with_nesting_h_unnamed_1() { - assert_eq!(::std::mem::size_of::<Struct_foo_union_with_nesting_h_unnamed_1>() - , 4usize); - assert_eq!(::std::mem::align_of::<Struct_foo_union_with_nesting_h_unnamed_1>() - , 2usize); +fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::<foo>() , 4usize); + assert_eq!(::std::mem::align_of::<foo>() , 4usize); +} +impl Clone for foo { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/unknown_attr.rs b/tests/expectations/unknown_attr.rs new file mode 100644 index 00000000..06da6a3c --- /dev/null +++ b/tests/expectations/unknown_attr.rs @@ -0,0 +1,16 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct _bindgen_ty_bindgen_id_1 { + pub __clang_max_align_nonce1: ::std::os::raw::c_longlong, + pub __clang_max_align_nonce2: f64, +} +impl Clone for _bindgen_ty_bindgen_id_1 { + fn clone(&self) -> Self { *self } +} +pub type max_align_t = _bindgen_ty_bindgen_id_1; diff --git a/tests/expectations/using.rs b/tests/expectations/using.rs index adc1e61b..dbb6c84f 100644 --- a/tests/expectations/using.rs +++ b/tests/expectations/using.rs @@ -6,9 +6,9 @@ #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct Struct_Point<T> { +pub struct Point<T> { pub x: T, pub y: T, } -pub type IntPoint2D = Struct_Point<::std::os::raw::c_int>; -pub type IntVec2D = Struct_Point<::std::os::raw::c_int>; +pub type IntPoint2D = Point<::std::os::raw::c_int>; +pub type IntVec2D = Point<::std::os::raw::c_int>; diff --git a/tests/expectations/variadic_template_args.rs b/tests/expectations/variadic_template_args.rs new file mode 100644 index 00000000..f0c68106 --- /dev/null +++ b/tests/expectations/variadic_template_args.rs @@ -0,0 +1,21 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[repr(C)] +pub struct RefPtr<T> { + pub _address: u8, + pub _phantom_0: ::std::marker::PhantomData<T>, +} +#[repr(C)] +pub struct RefPtr_Proxy<T, R, Args> { + pub _address: u8, + pub _phantom_0: ::std::marker::PhantomData<T>, + pub _phantom_1: ::std::marker::PhantomData<R>, + pub _phantom_2: ::std::marker::PhantomData<Args>, +} +pub type RefPtr_Proxy_member_function = + *mut ::std::option::Option<unsafe extern "C" fn(arg1: Args) + -> type-parameter-1-0>; diff --git a/tests/expectations/virtual_dtor.rs b/tests/expectations/virtual_dtor.rs new file mode 100644 index 00000000..99e0a535 --- /dev/null +++ b/tests/expectations/virtual_dtor.rs @@ -0,0 +1,19 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[repr(C)] +pub struct bindgen_vtable__bindgen_id_1 { +} +#[repr(C)] +#[derive(Debug)] +pub struct nsSlots { + pub vtable_: *const bindgen_vtable__bindgen_id_1, +} +#[test] +fn bindgen_test_layout_nsSlots() { + assert_eq!(::std::mem::size_of::<nsSlots>() , 8usize); + assert_eq!(::std::mem::align_of::<nsSlots>() , 8usize); +} diff --git a/tests/expectations/virtual_overloaded.rs b/tests/expectations/virtual_overloaded.rs index a59f9c27..d395fed0 100644 --- a/tests/expectations/virtual_overloaded.rs +++ b/tests/expectations/virtual_overloaded.rs @@ -5,22 +5,18 @@ #[repr(C)] -#[derive(Debug, Copy)] -pub struct Struct_C { - pub _vftable: *const _vftable_Struct_C, +pub struct bindgen_vtable__bindgen_id_1 { } #[repr(C)] -pub struct _vftable_Struct_C { - pub do_thing: unsafe extern "C" fn(this: *mut ::std::os::raw::c_void, - arg1: ::std::os::raw::c_char), - pub do_thing1: unsafe extern "C" fn(this: *mut ::std::os::raw::c_void, - arg1: ::std::os::raw::c_int), -} -impl ::std::clone::Clone for Struct_C { - fn clone(&self) -> Self { *self } +#[derive(Debug, Copy)] +pub struct C { + pub vtable_: *const bindgen_vtable__bindgen_id_1, } #[test] -fn bindgen_test_layout_Struct_C() { - assert_eq!(::std::mem::size_of::<Struct_C>() , 8usize); - assert_eq!(::std::mem::align_of::<Struct_C>() , 8usize); +fn bindgen_test_layout_C() { + assert_eq!(::std::mem::size_of::<C>() , 8usize); + assert_eq!(::std::mem::align_of::<C>() , 8usize); +} +impl Clone for C { + fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/vtable_recursive_sig.rs b/tests/expectations/vtable_recursive_sig.rs index 8f972e92..1044c4e4 100644 --- a/tests/expectations/vtable_recursive_sig.rs +++ b/tests/expectations/vtable_recursive_sig.rs @@ -6,31 +6,30 @@ #[repr(C)] #[derive(Debug, Copy)] -pub struct Base { - pub _vftable: *const _vftable_Base, +pub struct Derived { + pub _base: Base, } -#[repr(C)] -pub struct _vftable_Base { - pub AsDerived: unsafe extern "C" fn(this: *mut ::std::os::raw::c_void) - -> *mut Derived, +#[test] +fn bindgen_test_layout_Derived() { + assert_eq!(::std::mem::size_of::<Derived>() , 8usize); + assert_eq!(::std::mem::align_of::<Derived>() , 8usize); } -impl ::std::clone::Clone for Base { +impl Clone for Derived { fn clone(&self) -> Self { *self } } -#[test] -fn bindgen_test_layout_Base() { - assert_eq!(::std::mem::size_of::<Base>() , 8usize); - assert_eq!(::std::mem::align_of::<Base>() , 8usize); +#[repr(C)] +pub struct bindgen_vtable__bindgen_id_2 { } #[repr(C)] #[derive(Debug, Copy)] -pub struct Derived { - pub _base: Base, +pub struct Base { + pub vtable_: *const bindgen_vtable__bindgen_id_2, } -#[repr(C)] -pub struct _vftable_Derived { - pub _base: _vftable_Base, +#[test] +fn bindgen_test_layout_Base() { + assert_eq!(::std::mem::size_of::<Base>() , 8usize); + assert_eq!(::std::mem::align_of::<Base>() , 8usize); } -impl ::std::clone::Clone for Derived { +impl Clone for Base { fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/weird_bitfields.rs b/tests/expectations/weird_bitfields.rs index 6166a60f..56ee76a5 100644 --- a/tests/expectations/weird_bitfields.rs +++ b/tests/expectations/weird_bitfields.rs @@ -5,17 +5,17 @@ #[repr(u32)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -pub enum Enum_nsStyleSVGOpacitySource { +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum nsStyleSVGOpacitySource { eStyleSVGOpacitySource_Normal = 0, eStyleSVGOpacitySource_ContextFillOpacity = 1, eStyleSVGOpacitySource_ContextStrokeOpacity = 2, } #[repr(C)] #[derive(Debug, Copy)] -pub struct Struct_Weird { +pub struct Weird { pub mStrokeDasharrayLength: ::std::os::raw::c_uint, - pub _bitfield_1: ::std::os::raw::c_uint, + pub _bitfield_1: u32, pub mClipRule: ::std::os::raw::c_uchar, pub mColorInterpolation: ::std::os::raw::c_uchar, pub mColorInterpolationFilters: ::std::os::raw::c_uchar, @@ -27,100 +27,102 @@ pub struct Struct_Weird { pub mStrokeLinejoin: ::std::os::raw::c_uchar, pub mTextAnchor: ::std::os::raw::c_uchar, pub mTextRendering: ::std::os::raw::c_uchar, - pub _bitfield_2: u32, + pub _bitfield_2: u16, } -impl Struct_Weird { +#[test] +fn bindgen_test_layout_Weird() { + assert_eq!(::std::mem::size_of::<Weird>() , 24usize); + assert_eq!(::std::mem::align_of::<Weird>() , 4usize); +} +impl Clone for Weird { + fn clone(&self) -> Self { *self } +} +impl Weird { #[inline] pub fn bitTest(&self) -> ::std::os::raw::c_uint { - (self._bitfield_1 & (65535usize as ::std::os::raw::c_uint)) >> 0usize + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (65535usize as u32)) >> + 0u32) as u32) + } } #[inline] - pub fn set_bitTest(&mut self, val: u16) { - self._bitfield_1 &= !(65535usize as ::std::os::raw::c_uint); + pub fn set_bitTest(&mut self, val: ::std::os::raw::c_uint) { + self._bitfield_1 &= !(65535usize as u32); self._bitfield_1 |= - ((val as ::std::os::raw::c_uint) << 0usize) & - (65535usize as ::std::os::raw::c_uint); + ((val as u32 as u32) << 0u32) & (65535usize as u32); } #[inline] pub fn bitTest2(&self) -> ::std::os::raw::c_uint { - (self._bitfield_1 & (2147418112usize as ::std::os::raw::c_uint)) >> - 16usize + unsafe { + ::std::mem::transmute(((self._bitfield_1 & + (2147418112usize as u32)) >> 16u32) as + u32) + } } #[inline] - pub fn set_bitTest2(&mut self, val: u16) { - self._bitfield_1 &= !(2147418112usize as ::std::os::raw::c_uint); + pub fn set_bitTest2(&mut self, val: ::std::os::raw::c_uint) { + self._bitfield_1 &= !(2147418112usize as u32); self._bitfield_1 |= - ((val as ::std::os::raw::c_uint) << 16usize) & - (2147418112usize as ::std::os::raw::c_uint); - } - #[inline] - pub fn new_bitfield_1(bitTest: u16, bitTest2: u16) - -> ::std::os::raw::c_uint { - 0 | ((bitTest as ::std::os::raw::c_uint) << 0u32) | - ((bitTest2 as ::std::os::raw::c_uint) << 16u32) + ((val as u32 as u32) << 16u32) & (2147418112usize as u32); } #[inline] - pub fn mFillOpacitySource(&self) -> u32 { - (self._bitfield_2 & (7usize as u32)) >> 0usize + pub fn mFillOpacitySource(&self) -> nsStyleSVGOpacitySource { + unsafe { + ::std::mem::transmute(((self._bitfield_2 & (7usize as u16)) >> + 0u32) as u32) + } } #[inline] - pub fn set_mFillOpacitySource(&mut self, val: u8) { - self._bitfield_2 &= !(7usize as u32); - self._bitfield_2 |= ((val as u32) << 0usize) & (7usize as u32); + pub fn set_mFillOpacitySource(&mut self, val: nsStyleSVGOpacitySource) { + self._bitfield_2 &= !(7usize as u16); + self._bitfield_2 |= ((val as u32 as u16) << 0u32) & (7usize as u16); } #[inline] - pub fn mStrokeOpacitySource(&self) -> u32 { - (self._bitfield_2 & (56usize as u32)) >> 3usize + pub fn mStrokeOpacitySource(&self) -> nsStyleSVGOpacitySource { + unsafe { + ::std::mem::transmute(((self._bitfield_2 & (56usize as u16)) >> + 3u32) as u32) + } } #[inline] - pub fn set_mStrokeOpacitySource(&mut self, val: u8) { - self._bitfield_2 &= !(56usize as u32); - self._bitfield_2 |= ((val as u32) << 3usize) & (56usize as u32); + pub fn set_mStrokeOpacitySource(&mut self, val: nsStyleSVGOpacitySource) { + self._bitfield_2 &= !(56usize as u16); + self._bitfield_2 |= ((val as u32 as u16) << 3u32) & (56usize as u16); } #[inline] - pub fn mStrokeDasharrayFromObject(&self) -> u32 { - (self._bitfield_2 & (64usize as u32)) >> 6usize + pub fn mStrokeDasharrayFromObject(&self) -> bool { + unsafe { + ::std::mem::transmute(((self._bitfield_2 & (64usize as u16)) >> + 6u32) as u8) + } } #[inline] pub fn set_mStrokeDasharrayFromObject(&mut self, val: bool) { - self._bitfield_2 &= !(64usize as u32); - self._bitfield_2 |= ((val as u32) << 6usize) & (64usize as u32); + self._bitfield_2 &= !(64usize as u16); + self._bitfield_2 |= ((val as u8 as u16) << 6u32) & (64usize as u16); } #[inline] - pub fn mStrokeDashoffsetFromObject(&self) -> u32 { - (self._bitfield_2 & (128usize as u32)) >> 7usize + pub fn mStrokeDashoffsetFromObject(&self) -> bool { + unsafe { + ::std::mem::transmute(((self._bitfield_2 & (128usize as u16)) >> + 7u32) as u8) + } } #[inline] pub fn set_mStrokeDashoffsetFromObject(&mut self, val: bool) { - self._bitfield_2 &= !(128usize as u32); - self._bitfield_2 |= ((val as u32) << 7usize) & (128usize as u32); + self._bitfield_2 &= !(128usize as u16); + self._bitfield_2 |= ((val as u8 as u16) << 7u32) & (128usize as u16); } #[inline] - pub fn mStrokeWidthFromObject(&self) -> u32 { - (self._bitfield_2 & (256usize as u32)) >> 8usize + pub fn mStrokeWidthFromObject(&self) -> bool { + unsafe { + ::std::mem::transmute(((self._bitfield_2 & (256usize as u16)) >> + 8u32) as u8) + } } #[inline] pub fn set_mStrokeWidthFromObject(&mut self, val: bool) { - self._bitfield_2 &= !(256usize as u32); - self._bitfield_2 |= ((val as u32) << 8usize) & (256usize as u32); + self._bitfield_2 &= !(256usize as u16); + self._bitfield_2 |= ((val as u8 as u16) << 8u32) & (256usize as u16); } - #[inline] - pub fn new_bitfield_2(mFillOpacitySource: u8, mStrokeOpacitySource: u8, - mStrokeDasharrayFromObject: bool, - mStrokeDashoffsetFromObject: bool, - mStrokeWidthFromObject: bool) -> u32 { - 0 | ((mFillOpacitySource as u32) << 0u32) | - ((mStrokeOpacitySource as u32) << 3u32) | - ((mStrokeDasharrayFromObject as u32) << 6u32) | - ((mStrokeDashoffsetFromObject as u32) << 7u32) | - ((mStrokeWidthFromObject as u32) << 8u32) - } -} -impl ::std::clone::Clone for Struct_Weird { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_Struct_Weird() { - assert_eq!(::std::mem::size_of::<Struct_Weird>() , 24usize); - assert_eq!(::std::mem::align_of::<Struct_Weird>() , 4usize); } diff --git a/tests/expectations/what_is_going_on.rs b/tests/expectations/what_is_going_on.rs new file mode 100644 index 00000000..b6a5c86a --- /dev/null +++ b/tests/expectations/what_is_going_on.rs @@ -0,0 +1,29 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct UnknownUnits { + pub _address: u8, +} +#[test] +fn bindgen_test_layout_UnknownUnits() { + assert_eq!(::std::mem::size_of::<UnknownUnits>() , 1usize); + assert_eq!(::std::mem::align_of::<UnknownUnits>() , 1usize); +} +impl Clone for UnknownUnits { + fn clone(&self) -> Self { *self } +} +pub type Float = f32; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct PointTyped<units, F> { + pub x: Float, + pub y: Float, + pub _phantom_0: ::std::marker::PhantomData<units>, + pub _phantom_1: ::std::marker::PhantomData<F>, +} +pub type IntPoint = PointTyped<UnknownUnits, f32>; diff --git a/tests/expectations/whitelist_basic.rs b/tests/expectations/whitelist_basic.rs new file mode 100644 index 00000000..0104f049 --- /dev/null +++ b/tests/expectations/whitelist_basic.rs @@ -0,0 +1,18 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct WhitelistMe<T> { + pub foo: ::std::os::raw::c_int, + pub bar: WhitelistMe_Inner<T>, + pub _phantom_0: ::std::marker::PhantomData<T>, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct WhitelistMe_Inner<T> { + pub bar: T, +} diff --git a/tests/headers/anon_enum.hpp b/tests/headers/anon_enum.hpp new file mode 100644 index 00000000..c7405202 --- /dev/null +++ b/tests/headers/anon_enum.hpp @@ -0,0 +1,5 @@ +struct Test { + int foo; + float bar; + enum { T_NONE }; +}; diff --git a/tests/headers/anon_enum_whitelist.h b/tests/headers/anon_enum_whitelist.h new file mode 100644 index 00000000..15cda6b1 --- /dev/null +++ b/tests/headers/anon_enum_whitelist.h @@ -0,0 +1,6 @@ +// bindgen-flags: --whitelist-var NODE_.* + +enum { + NODE_FLAG_FOO, + NODE_FLAG_BAR, +}; diff --git a/tests/headers/anon_union.hpp b/tests/headers/anon_union.hpp new file mode 100644 index 00000000..126f6a6e --- /dev/null +++ b/tests/headers/anon_union.hpp @@ -0,0 +1,20 @@ +template<typename T> +struct TErrorResult { + enum UnionState { + HasMessage, + HasException, + }; + int mResult; + struct Message; + struct DOMExceptionInfo; + union { + Message* mMessage; + DOMExceptionInfo* mDOMExceptionInfo; + }; + + bool mMightHaveUnreported; + UnionState mUnionState; +}; + +struct ErrorResult : public TErrorResult<int> { +}; diff --git a/tests/headers/arg_keyword.hpp b/tests/headers/arg_keyword.hpp new file mode 100644 index 00000000..9f0af850 --- /dev/null +++ b/tests/headers/arg_keyword.hpp @@ -0,0 +1 @@ +void foo(const char* type); diff --git a/tests/headers/const_ptr.hpp b/tests/headers/const_ptr.hpp new file mode 100644 index 00000000..66744f8b --- /dev/null +++ b/tests/headers/const_ptr.hpp @@ -0,0 +1,3 @@ +extern "C" { + void foo(const void* bar); +} diff --git a/tests/headers/const_resolved_ty.h b/tests/headers/const_resolved_ty.h new file mode 100644 index 00000000..2521e61c --- /dev/null +++ b/tests/headers/const_resolved_ty.h @@ -0,0 +1,3 @@ +typedef unsigned char uint8_t; + +void foo(const uint8_t* foo); diff --git a/tests/headers/const_tparam.hpp b/tests/headers/const_tparam.hpp new file mode 100644 index 00000000..a2db574c --- /dev/null +++ b/tests/headers/const_tparam.hpp @@ -0,0 +1,4 @@ +template<typename T> +class C { + const T* const foo; +}; diff --git a/tests/headers/duplicated_constants_in_ns.hpp b/tests/headers/duplicated_constants_in_ns.hpp index 42197a16..bb343641 100644 --- a/tests/headers/duplicated_constants_in_ns.hpp +++ b/tests/headers/duplicated_constants_in_ns.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --no-namespaced-constants +// bindgen-flags: --enable-cxx-namespaces namespace foo { const int FOO = 4; } diff --git a/tests/headers/empty_template_param_name.hpp b/tests/headers/empty_template_param_name.hpp new file mode 100644 index 00000000..b3360bc9 --- /dev/null +++ b/tests/headers/empty_template_param_name.hpp @@ -0,0 +1,4 @@ +template<typename...> using __void_t = void; + +template<typename _Iterator, typename = __void_t<>> + struct __iterator_traits { }; diff --git a/tests/headers/enum_alias.hpp b/tests/headers/enum_alias.hpp new file mode 100644 index 00000000..658f8fde --- /dev/null +++ b/tests/headers/enum_alias.hpp @@ -0,0 +1,7 @@ +// bindgen-flags: -- -std=c++11 + +typedef unsigned char uint8_t; + +enum Bar : uint8_t { + VAL +}; diff --git a/tests/headers/in_class_typedef.hpp b/tests/headers/in_class_typedef.hpp new file mode 100644 index 00000000..dda7472d --- /dev/null +++ b/tests/headers/in_class_typedef.hpp @@ -0,0 +1,10 @@ + +template<typename T> +class Foo { + typedef T elem_type; + typedef T* ptr_type; + + typedef struct Bar { + int x, y; + } Bar; +}; diff --git a/tests/headers/inherit_named.hpp b/tests/headers/inherit_named.hpp new file mode 100644 index 00000000..9881d1b6 --- /dev/null +++ b/tests/headers/inherit_named.hpp @@ -0,0 +1,5 @@ +template<typename T> +class Wohoo {}; + +template<typename T> +class Weeee : public T {}; diff --git a/tests/headers/inherit_typedef.hpp b/tests/headers/inherit_typedef.hpp new file mode 100644 index 00000000..8d699e82 --- /dev/null +++ b/tests/headers/inherit_typedef.hpp @@ -0,0 +1,5 @@ +struct Foo {}; + +typedef Foo TypedefedFoo; + +struct Bar: public TypedefedFoo {}; diff --git a/tests/headers/inner_const.hpp b/tests/headers/inner_const.hpp new file mode 100644 index 00000000..25c2e603 --- /dev/null +++ b/tests/headers/inner_const.hpp @@ -0,0 +1,6 @@ + +class Foo { + static int BOO; + static Foo whatever; + int bar; +}; diff --git a/tests/headers/jsval_layout_opaque.hpp b/tests/headers/jsval_layout_opaque.hpp index d432d8d3..85c5be63 100644 --- a/tests/headers/jsval_layout_opaque.hpp +++ b/tests/headers/jsval_layout_opaque.hpp @@ -1,7 +1,16 @@ -// bindgen-flags: --match jsval_layout_opaque.hpp --no-type-renaming --no-unstable-rust -- -std=c++11 +// bindgen-flags: --no-unstable-rust -- -std=c++11 + +/** + * These typedefs are hacky, but keep our tests consistent across 64-bit + * platforms, otherwise the id's change and our CI is unhappy. + */ +typedef unsigned char uint8_t; +typedef int int32_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; +typedef unsigned long long size_t; +typedef unsigned long long uintptr_t; -#include <stdint.h> -#include <stddef.h> #define JS_PUNBOX64 #define IS_LITTLE_ENDIAN diff --git a/tests/headers/nested_vtable.hpp b/tests/headers/nested_vtable.hpp new file mode 100644 index 00000000..87d6ce1f --- /dev/null +++ b/tests/headers/nested_vtable.hpp @@ -0,0 +1,8 @@ +class nsISupports { +public: + virtual nsISupports* QueryInterface(); +}; + +class nsIRunnable : public nsISupports {}; + +class Runnable : public nsIRunnable {}; diff --git a/tests/headers/opaque_typedef.hpp b/tests/headers/opaque_typedef.hpp index 2d9a5781..25640738 100644 --- a/tests/headers/opaque_typedef.hpp +++ b/tests/headers/opaque_typedef.hpp @@ -14,4 +14,4 @@ class Wat3<3>; /** <div rustbindgen opaque></div> */ typedef RandomTemplate<int> ShouldBeOpaque; -typedef RandomTemplate<int> ShouldNotBeOpaque; +typedef RandomTemplate<float> ShouldNotBeOpaque; diff --git a/tests/headers/private.hpp b/tests/headers/private.hpp index 070bdddc..c0f3ce7f 100644 --- a/tests/headers/private.hpp +++ b/tests/headers/private.hpp @@ -15,7 +15,7 @@ struct VeryPrivate { /** <div rustbindgen private></div> */ struct ContradictPrivate { - /** <div rustbindgen private=false></div> */ + /** <div rustbindgen private="false"></div> */ int mNotPrivate; int mIsPrivate; }; diff --git a/tests/headers/redeclaration.hpp b/tests/headers/redeclaration.hpp new file mode 100644 index 00000000..d536b158 --- /dev/null +++ b/tests/headers/redeclaration.hpp @@ -0,0 +1,7 @@ +extern "C" { + void foo(); +} + +extern "C" { + void foo(); +} diff --git a/tests/headers/typeref.hpp b/tests/headers/typeref.hpp new file mode 100644 index 00000000..b94c98ef --- /dev/null +++ b/tests/headers/typeref.hpp @@ -0,0 +1,28 @@ +struct nsFoo; + +namespace mozilla { + +struct FragmentOrURL { bool mIsLocalRef; }; +struct Position { }; + +} // namespace mozilla + +class Bar { + nsFoo* mFoo; +}; + +namespace mozilla { + +template<typename ReferenceBox> +struct StyleShapeSource { + union { + Position* mPosition; + FragmentOrURL* mFragmentOrURL; + }; +}; + +} // namespace mozilla + +struct nsFoo { + mozilla::StyleShapeSource<int> mBar; +}; diff --git a/tests/headers/unknown_attr.h b/tests/headers/unknown_attr.h new file mode 100644 index 00000000..f87e9f0b --- /dev/null +++ b/tests/headers/unknown_attr.h @@ -0,0 +1,6 @@ +typedef struct { + long long __clang_max_align_nonce1 + __attribute__((__aligned__(__alignof__(long long)))); + long double __clang_max_align_nonce2 + __attribute__((__aligned__(__alignof__(long double)))); +} max_align_t; diff --git a/tests/headers/virtual_dtor.hpp b/tests/headers/virtual_dtor.hpp new file mode 100644 index 00000000..c35dcab1 --- /dev/null +++ b/tests/headers/virtual_dtor.hpp @@ -0,0 +1,3 @@ +struct nsSlots { + virtual ~nsSlots(); +}; diff --git a/tests/headers/what_is_going_on.hpp b/tests/headers/what_is_going_on.hpp new file mode 100644 index 00000000..078c1ad5 --- /dev/null +++ b/tests/headers/what_is_going_on.hpp @@ -0,0 +1,19 @@ + +struct UnknownUnits {}; +typedef float Float; + +template<class units, class F = Float> +struct PointTyped { + F x; + F y; + + static PointTyped<units, F> FromUnknownPoint(const PointTyped<UnknownUnits, F>& aPoint) { + return PointTyped<units, F>(aPoint.x, aPoint.y); + } + + PointTyped<UnknownUnits, F> ToUnknownPoint() const { + return PointTyped<UnknownUnits, F>(this->x, this->y); + } +}; + +typedef PointTyped<UnknownUnits> IntPoint; diff --git a/tests/headers/whitelist_basic.hpp b/tests/headers/whitelist_basic.hpp new file mode 100644 index 00000000..661528ba --- /dev/null +++ b/tests/headers/whitelist_basic.hpp @@ -0,0 +1,15 @@ +// bindgen-flags: --whitelist-type WhitelistMe + +template<typename T> +class WhitelistMe { + class Inner { + T bar; + }; + + int foo; + Inner bar; +}; + +struct DontWhitelistMe { + void* foo; +}; |