diff options
53 files changed, 2487 insertions, 0 deletions
diff --git a/tests/expectations/annotation_hide.rs b/tests/expectations/annotation_hide.rs new file mode 100644 index 00000000..755bbbe6 --- /dev/null +++ b/tests/expectations/annotation_hide.rs @@ -0,0 +1,27 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +pub enum Struct_C { } +#[repr(C)] +pub struct D { + pub _bindgen_opaque_blob: u32, +} +#[test] +fn bindgen_test_layout_D() { + assert_eq!(::std::mem::size_of::<D>() , 4usize); + assert_eq!(::std::mem::align_of::<D>() , 4usize); +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct 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); +} diff --git a/tests/expectations/class.rs b/tests/expectations/class.rs new file mode 100644 index 00000000..46d12160 --- /dev/null +++ b/tests/expectations/class.rs @@ -0,0 +1,84 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[derive(Copy, Debug)] +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() } +} +#[repr(C)] +#[derive(Copy)] +pub struct 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); +} +#[repr(C)] +#[derive(Debug)] +pub struct 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); +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Union_Union { + pub d: __BindgenUnionField<f32>, + pub i: __BindgenUnionField<::std::os::raw::c_int>, + pub _bindgen_data_: 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)) + } +} +impl ::std::clone::Clone for Union_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 } +} +#[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); +} diff --git a/tests/expectations/class_nested.rs b/tests/expectations/class_nested.rs new file mode 100644 index 00000000..e77a8147 --- /dev/null +++ b/tests/expectations/class_nested.rs @@ -0,0 +1,56 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_A { + pub member_a: ::std::os::raw::c_int, +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_A_B { + pub member_b: ::std::os::raw::c_int, +} +impl ::std::clone::Clone for Struct_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); +} +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); +} +#[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 } +} +#[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); +} +#[repr(C)] +#[derive(Debug)] +pub struct Struct_Templated<T> { + pub member: T, +} +#[repr(C)] +#[derive(Debug)] +pub struct 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 new file mode 100644 index 00000000..e18a30c9 --- /dev/null +++ b/tests/expectations/class_no_members.rs @@ -0,0 +1,34 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_whatever; +impl ::std::clone::Clone for Struct_whatever { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_whatever_child { + pub _base: Struct_whatever, +} +impl ::std::clone::Clone for Struct_whatever_child { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_whatever_child_with_member { + pub _base: Struct_whatever, + 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); +} diff --git a/tests/expectations/class_use_as.rs b/tests/expectations/class_use_as.rs new file mode 100644 index 00000000..87479f2f --- /dev/null +++ b/tests/expectations/class_use_as.rs @@ -0,0 +1,33 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +/** + * <div rustbindgen="true" replaces="whatever"></div> + */ +#[repr(C)] +#[derive(Debug, Copy)] +pub struct 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); +} +#[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 } +} +#[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); +} diff --git a/tests/expectations/class_with_dtor.rs b/tests/expectations/class_with_dtor.rs new file mode 100644 index 00000000..272e9121 --- /dev/null +++ b/tests/expectations/class_with_dtor.rs @@ -0,0 +1,20 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[repr(C)] +#[derive(Debug)] +pub struct Struct_HandleWithDtor<T> { + pub ptr: *mut T, +} +pub type HandleValue = Struct_HandleWithDtor<::std::os::raw::c_int>; +#[repr(C)] +#[derive(Debug)] +pub struct 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); +} diff --git a/tests/expectations/class_with_inner_struct.rs b/tests/expectations/class_with_inner_struct.rs new file mode 100644 index 00000000..013050a0 --- /dev/null +++ b/tests/expectations/class_with_inner_struct.rs @@ -0,0 +1,227 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[derive(Copy, Debug)] +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() } +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct 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, +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct 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); +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Union_A_class_with_inner_struct_hpp_unnamed_1 { + pub f: __BindgenUnionField<::std::os::raw::c_int>, + pub _bindgen_data_: 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)) + } +} +impl ::std::clone::Clone for Union_A_class_with_inner_struct_hpp_unnamed_1 { + 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 d: __BindgenUnionField<::std::os::raw::c_int>, + pub _bindgen_data_: 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)) + } +} +impl ::std::clone::Clone for Union_A_class_with_inner_struct_hpp_unnamed_2 { + 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); +} +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>() , 12usize); + assert_eq!(::std::mem::align_of::<Struct_A>() , 4usize); +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_B { + pub d: ::std::os::raw::c_uint, +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct 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); +} +impl ::std::clone::Clone for Struct_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); +} +#[repr(i32)] +#[derive(Debug, Copy, Clone)] +pub enum Enum_StepSyntax { + Keyword = 0, + FunctionalWithoutKeyword = 1, + FunctionalWithStartKeyword = 2, + FunctionalWithEndKeyword = 3, +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct 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, +} +#[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); +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_C_class_with_inner_struct_hpp_unnamed_3_class_with_inner_struct_hpp_unnamed_4 { + 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>() + , 16usize); + assert_eq!(::std::mem::align_of::<Struct_C_class_with_inner_struct_hpp_unnamed_3_class_with_inner_struct_hpp_unnamed_4>() + , 4usize); +} +#[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 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>() + , 8usize); + assert_eq!(::std::mem::align_of::<Struct_C_class_with_inner_struct_hpp_unnamed_3_class_with_inner_struct_hpp_unnamed_5>() + , 4usize); +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct 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); +} +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>() , 20usize); + assert_eq!(::std::mem::align_of::<Struct_C>() , 4usize); +} diff --git a/tests/expectations/class_with_typedef.rs b/tests/expectations/class_with_typedef.rs new file mode 100644 index 00000000..9ad99058 --- /dev/null +++ b/tests/expectations/class_with_typedef.rs @@ -0,0 +1,62 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +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 d: AnotherInt, + pub other_ptr: *mut AnotherInt, +} +impl ::std::clone::Clone for C { + fn clone(&self) -> Self { *self } +} +#[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); +} +impl C { + #[inline] + pub unsafe fn method(&mut self, c: ::std::os::raw::c_int) { + _ZN1C6methodEi(&mut *self, c) + } + #[inline] + pub unsafe fn methodRef(&mut self, c: *mut ::std::os::raw::c_int) { + _ZN1C9methodRefERi(&mut *self, c) + } + #[inline] + pub unsafe fn complexMethodRef(&mut self, + c: *mut *const ::std::os::raw::c_char) { + _ZN1C16complexMethodRefERPKc(&mut *self, c) + } + #[inline] + pub unsafe fn anotherMethod(&mut self, c: AnotherInt) { + _ZN1C13anotherMethodEi(&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 } +} +#[test] +fn bindgen_test_layout_D() { + assert_eq!(::std::mem::size_of::<D>() , 80usize); + assert_eq!(::std::mem::align_of::<D>() , 8usize); +} diff --git a/tests/expectations/decl_ptr_to_array.rs b/tests/expectations/decl_ptr_to_array.rs new file mode 100644 index 00000000..3a2c33e6 --- /dev/null +++ b/tests/expectations/decl_ptr_to_array.rs @@ -0,0 +1,7 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +extern "C" { + pub static mut foo: [::std::os::raw::c_int; 1usize]; +} diff --git a/tests/expectations/enum.rs b/tests/expectations/enum.rs new file mode 100644 index 00000000..09eed547 --- /dev/null +++ b/tests/expectations/enum.rs @@ -0,0 +1,10 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[repr(u32)] +#[derive(Debug, Copy, Clone)] +pub enum Enum_Foo { Bar = 0, Qux = 1, } +#[repr(i32)] +#[derive(Debug, Copy, Clone)] +pub enum Enum_Neg { MinusOne = -1, One = 1, } diff --git a/tests/expectations/enum_and_vtable_mangling.rs b/tests/expectations/enum_and_vtable_mangling.rs new file mode 100644 index 00000000..fe3f2ab2 --- /dev/null +++ b/tests/expectations/enum_and_vtable_mangling.rs @@ -0,0 +1,28 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[repr(u32)] +#[derive(Debug, Copy, Clone)] +pub enum Enum_enum_and_vtable_mangling_hpp_unnamed_1 { + match_ = 0, + whatever_else = 1, +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_C { + pub _vftable: *const _vftable_Struct_C, + 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), +} +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>() , 16usize); + assert_eq!(::std::mem::align_of::<Struct_C>() , 8usize); +} diff --git a/tests/expectations/enum_dupe.rs b/tests/expectations/enum_dupe.rs new file mode 100644 index 00000000..aa8c27e7 --- /dev/null +++ b/tests/expectations/enum_dupe.rs @@ -0,0 +1,8 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +pub const Dupe: Enum_Foo = Enum_Foo::Bar; +#[repr(u32)] +#[derive(Debug, Copy, Clone)] +pub enum Enum_Foo { Bar = 1, } diff --git a/tests/expectations/enum_explicit_type.rs b/tests/expectations/enum_explicit_type.rs new file mode 100644 index 00000000..c89488a3 --- /dev/null +++ b/tests/expectations/enum_explicit_type.rs @@ -0,0 +1,19 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[repr(u8)] +#[derive(Debug, Copy, Clone)] +pub enum Enum_Foo { Bar = 0, Qux = 1, } +#[repr(i8)] +#[derive(Debug, Copy, Clone)] +pub enum Enum_Neg { MinusOne = -1, One = 1, } +#[repr(u16)] +#[derive(Debug, Copy, Clone)] +pub enum Enum_Bigger { Much = 255, Larger = 256, } +#[repr(i64)] +#[derive(Debug, Copy, Clone)] +pub enum Enum_MuchLong { MuchLow = -4294967296, } +#[repr(u64)] +#[derive(Debug, Copy, Clone)] +pub enum Enum_MuchLongLong { MuchHigh = 4294967296, } diff --git a/tests/expectations/enum_negative.rs b/tests/expectations/enum_negative.rs new file mode 100644 index 00000000..9c4f5e4c --- /dev/null +++ b/tests/expectations/enum_negative.rs @@ -0,0 +1,7 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[repr(i32)] +#[derive(Debug, Copy, Clone)] +pub enum Enum_Foo { Bar = -2, Qux = 1, } diff --git a/tests/expectations/enum_packed.rs b/tests/expectations/enum_packed.rs new file mode 100644 index 00000000..bdc5d613 --- /dev/null +++ b/tests/expectations/enum_packed.rs @@ -0,0 +1,13 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[repr(u8)] +#[derive(Debug, Copy, Clone)] +pub enum Enum_Foo { Bar = 0, Qux = 1, } +#[repr(i8)] +#[derive(Debug, Copy, Clone)] +pub enum Enum_Neg { MinusOne = -1, One = 1, } +#[repr(u16)] +#[derive(Debug, Copy, Clone)] +pub enum Enum_Bigger { Much = 255, Larger = 256, } diff --git a/tests/expectations/extern.rs b/tests/expectations/extern.rs new file mode 100644 index 00000000..2925a223 --- /dev/null +++ b/tests/expectations/extern.rs @@ -0,0 +1,6 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +pub type foo = + 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 new file mode 100644 index 00000000..4a27698d --- /dev/null +++ b/tests/expectations/forward_declared_struct.rs @@ -0,0 +1,30 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct 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); +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct 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); +} diff --git a/tests/expectations/func_proto.rs b/tests/expectations/func_proto.rs new file mode 100644 index 00000000..2925a223 --- /dev/null +++ b/tests/expectations/func_proto.rs @@ -0,0 +1,6 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +pub type foo = + 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 new file mode 100644 index 00000000..02717fa3 --- /dev/null +++ b/tests/expectations/func_ptr.rs @@ -0,0 +1,12 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +extern "C" { + 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>; +} diff --git a/tests/expectations/func_ptr_in_struct.rs b/tests/expectations/func_ptr_in_struct.rs new file mode 100644 index 00000000..b997f5a6 --- /dev/null +++ b/tests/expectations/func_ptr_in_struct.rs @@ -0,0 +1,24 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[repr(i32)] +#[derive(Debug, Copy, Clone)] +pub enum Enum_baz { _BindgenOpaqueEnum = 0, } +#[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 } +} +#[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); +} diff --git a/tests/expectations/func_with_array_arg.rs b/tests/expectations/func_with_array_arg.rs new file mode 100644 index 00000000..4a6dcb80 --- /dev/null +++ b/tests/expectations/func_with_array_arg.rs @@ -0,0 +1,7 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +extern "C" { + pub fn f(x: *mut ::std::os::raw::c_int); +} diff --git a/tests/expectations/func_with_func_ptr_arg.rs b/tests/expectations/func_with_func_ptr_arg.rs new file mode 100644 index 00000000..90671132 --- /dev/null +++ b/tests/expectations/func_with_func_ptr_arg.rs @@ -0,0 +1,7 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +extern "C" { + pub fn foo(bar: ::std::option::Option<unsafe extern "C" fn()>); +} diff --git a/tests/expectations/jsval_layout_opaque.rs b/tests/expectations/jsval_layout_opaque.rs new file mode 100644 index 00000000..05f31115 --- /dev/null +++ b/tests/expectations/jsval_layout_opaque.rs @@ -0,0 +1,230 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[derive(Copy, Debug)] +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() } +} +pub const JSVAL_TAG_SHIFT: ::std::os::raw::c_uint = 47; +#[repr(u8)] +#[derive(Debug, Copy, Clone)] +pub enum JSValueType { + JSVAL_TYPE_DOUBLE = 0, + JSVAL_TYPE_INT32 = 1, + JSVAL_TYPE_UNDEFINED = 2, + JSVAL_TYPE_BOOLEAN = 3, + JSVAL_TYPE_MAGIC = 4, + JSVAL_TYPE_STRING = 5, + JSVAL_TYPE_SYMBOL = 6, + JSVAL_TYPE_NULL = 7, + JSVAL_TYPE_OBJECT = 8, + JSVAL_TYPE_UNKNOWN = 32, + JSVAL_TYPE_MISSING = 33, +} +#[repr(u32)] +#[derive(Debug, Copy, Clone)] +pub enum JSValueTag { + JSVAL_TAG_MAX_DOUBLE = 131056, + JSVAL_TAG_INT32 = 131057, + JSVAL_TAG_UNDEFINED = 131058, + JSVAL_TAG_STRING = 131061, + JSVAL_TAG_SYMBOL = 131062, + JSVAL_TAG_BOOLEAN = 131059, + JSVAL_TAG_MAGIC = 131060, + JSVAL_TAG_NULL = 131063, + JSVAL_TAG_OBJECT = 131064, +} +#[repr(u64)] +#[derive(Debug, Copy, Clone)] +pub enum JSValueShiftedTag { + JSVAL_SHIFTED_TAG_MAX_DOUBLE = 18444492278190833663, + JSVAL_SHIFTED_TAG_INT32 = 18444633011384221696, + JSVAL_SHIFTED_TAG_UNDEFINED = 18444773748872577024, + JSVAL_SHIFTED_TAG_STRING = 18445195961337643008, + JSVAL_SHIFTED_TAG_SYMBOL = 18445336698825998336, + JSVAL_SHIFTED_TAG_BOOLEAN = 18444914486360932352, + JSVAL_SHIFTED_TAG_MAGIC = 18445055223849287680, + JSVAL_SHIFTED_TAG_NULL = 18445477436314353664, + JSVAL_SHIFTED_TAG_OBJECT = 18445618173802708992, +} +#[repr(u32)] +#[derive(Debug, Copy, Clone)] +pub enum JSWhyMagic { + JS_ELEMENTS_HOLE = 0, + JS_NO_ITER_VALUE = 1, + JS_GENERATOR_CLOSING = 2, + JS_NO_CONSTANT = 3, + JS_THIS_POISON = 4, + JS_ARG_POISON = 5, + JS_SERIALIZE_NO_NODE = 6, + JS_LAZY_ARGUMENTS = 7, + JS_OPTIMIZED_ARGUMENTS = 8, + JS_IS_CONSTRUCTING = 9, + JS_OVERWRITTEN_CALLEE = 10, + JS_BLOCK_NEEDS_CLONE = 11, + JS_HASH_KEY_EMPTY = 12, + JS_ION_ERROR = 13, + JS_ION_BAILOUT = 14, + JS_OPTIMIZED_OUT = 15, + JS_UNINITIALIZED_LEXICAL = 16, + JS_GENERIC_MAGIC = 17, + JS_WHY_MAGIC_COUNT = 18, +} +#[repr(C)] +#[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 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); +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct jsval_layout_jsval_layout_opaque_hpp_unnamed_1 { + pub _bitfield_1: u64, +} +impl jsval_layout_jsval_layout_opaque_hpp_unnamed_1 { + pub fn set_payload47(&mut self, val: u32) { + self._bitfield_1 &= !(((1 << (47u32 as u64)) - 1) << 0usize); + self._bitfield_1 |= (val as u64) << 0usize; + } + pub fn set_tag(&mut self, val: u32) { + self._bitfield_1 &= !(((1 << (17u32 as u64)) - 1) << 47usize); + self._bitfield_1 |= (val as u64) << 47usize; + } + pub const fn new_bitfield_1(payload47: u32, tag: u32) -> u64 { + 0 | ((payload47 as u64) << 0u32) | ((tag as u64) << 47u32) + } +} +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, +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct jsval_layout_jsval_layout_opaque_hpp_unnamed_2_jsval_layout_opaque_hpp_unnamed_3 { + 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 } +} +#[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>() + , 4usize); + assert_eq!(::std::mem::align_of::<jsval_layout_jsval_layout_opaque_hpp_unnamed_2_jsval_layout_opaque_hpp_unnamed_3>() + , 4usize); +} +impl ::std::clone::Clone for jsval_layout_jsval_layout_opaque_hpp_unnamed_2 { + 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>() + , 4usize); + assert_eq!(::std::mem::align_of::<jsval_layout_jsval_layout_opaque_hpp_unnamed_2>() + , 4usize); +} +#[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); +} diff --git a/tests/expectations/namespace.rs b/tests/expectations/namespace.rs new file mode 100644 index 00000000..002d7516 --- /dev/null +++ b/tests/expectations/namespace.rs @@ -0,0 +1,46 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +pub type whatever_int_t = ::std::os::raw::c_int; +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_A { + pub b: 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); +} +#[repr(C)] +#[derive(Debug)] +pub struct Struct_C<T> { + pub _base: Struct_A, + pub m_c: T, + pub m_c_ptr: *mut T, + pub m_c_arr: [T; 10usize], +} +#[repr(C)] +#[derive(Debug)] +pub struct Struct_D<T> { + pub m_c: Struct_C<T>, + pub _phantom0: ::std::marker::PhantomData<T>, +} +extern "C" { + #[link_name = "_Z9top_levelv"] + pub fn top_level(); + #[link_name = "_ZN8whatever11in_whateverEv"] + pub fn in_whatever(); + #[link_name = "_ZN12_GLOBAL__N_13fooEv"] + pub fn foo(); + #[link_name = "_ZN1w3hehEv"] + pub fn heh() -> whatever_int_t; + #[link_name = "_ZN1w3fooEv"] + pub fn foo1() -> Struct_C<::std::os::raw::c_int>; + #[link_name = "_ZN1w4barrEv"] + pub fn barr() -> Struct_C<f32>; +} diff --git a/tests/expectations/nested.rs b/tests/expectations/nested.rs new file mode 100644 index 00000000..a29ad7a6 --- /dev/null +++ b/tests/expectations/nested.rs @@ -0,0 +1,50 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct 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); +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_Test; +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_Test_Size { + pub mWidth: Struct_Test_Size_Dimension, + pub mHeight: Struct_Test_Size_Dimension, +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_Test_Size_Dimension { + pub _base: Struct_Calc, +} +impl ::std::clone::Clone for Struct_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); +} +impl ::std::clone::Clone for Struct_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); +} +impl ::std::clone::Clone for Struct_Test { + fn clone(&self) -> Self { *self } +} diff --git a/tests/expectations/only_bitfields.rs b/tests/expectations/only_bitfields.rs new file mode 100644 index 00000000..c9314529 --- /dev/null +++ b/tests/expectations/only_bitfields.rs @@ -0,0 +1,30 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_C { + pub _bitfield_1: u8, +} +impl Struct_C { + pub fn set_a(&mut self, val: bool) { + self._bitfield_1 &= !(((1 << (1u32 as u8)) - 1) << 0usize); + self._bitfield_1 |= (val as u8) << 0usize; + } + pub fn set_b(&mut self, val: u8) { + self._bitfield_1 &= !(((1 << (7u32 as u8)) - 1) << 1usize); + self._bitfield_1 |= (val as u8) << 1usize; + } + pub const fn new_bitfield_1(a: bool, b: u8) -> u8 { + 0 | ((a as u8) << 0u32) | ((b as u8) << 1u32) + } +} +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 new file mode 100644 index 00000000..587b064b --- /dev/null +++ b/tests/expectations/opaque_in_struct.rs @@ -0,0 +1,22 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[repr(C)] +pub struct opaque { + pub _bindgen_opaque_blob: u32, +} +#[test] +fn bindgen_test_layout_opaque() { + assert_eq!(::std::mem::size_of::<opaque>() , 4usize); + assert_eq!(::std::mem::align_of::<opaque>() , 4usize); +} +#[repr(C)] +pub struct 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); +} diff --git a/tests/expectations/opaque_pointer.rs b/tests/expectations/opaque_pointer.rs new file mode 100644 index 00000000..e0cdf775 --- /dev/null +++ b/tests/expectations/opaque_pointer.rs @@ -0,0 +1,26 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[repr(C)] +pub struct OtherOpaque { + pub _bindgen_opaque_blob: u32, +} +#[test] +fn bindgen_test_layout_OtherOpaque() { + assert_eq!(::std::mem::size_of::<OtherOpaque>() , 4usize); + assert_eq!(::std::mem::align_of::<OtherOpaque>() , 4usize); +} +#[repr(C)] +pub struct Opaque; +#[repr(C)] +pub struct Struct_WithOpaquePtr { + pub whatever: u64, + 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); +} diff --git a/tests/expectations/overflowed_enum.rs b/tests/expectations/overflowed_enum.rs new file mode 100644 index 00000000..25861a7a --- /dev/null +++ b/tests/expectations/overflowed_enum.rs @@ -0,0 +1,14 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[repr(u32)] +#[derive(Debug, Copy, Clone)] +pub enum Enum_Foo { + BAP_ARM = 9698489, + BAP_X86 = 11960045, + BAP_X86_64 = 3128633167, +} +#[repr(u16)] +#[derive(Debug, Copy, Clone)] +pub enum Enum_Bar { One = 1, Big = 2, } diff --git a/tests/expectations/size_t_template.rs b/tests/expectations/size_t_template.rs new file mode 100644 index 00000000..4fa9c32b --- /dev/null +++ b/tests/expectations/size_t_template.rs @@ -0,0 +1,14 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[repr(C)] +#[derive(Debug)] +pub struct 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); +} diff --git a/tests/expectations/struct_containing_forward_declared_struct.rs b/tests/expectations/struct_containing_forward_declared_struct.rs new file mode 100644 index 00000000..79a7bd74 --- /dev/null +++ b/tests/expectations/struct_containing_forward_declared_struct.rs @@ -0,0 +1,30 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[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); +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_b { + pub val_b: ::std::os::raw::c_int, +} +impl ::std::clone::Clone for Struct_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); +} diff --git a/tests/expectations/struct_with_anon_struct.rs b/tests/expectations/struct_with_anon_struct.rs new file mode 100644 index 00000000..3516ad9c --- /dev/null +++ b/tests/expectations/struct_with_anon_struct.rs @@ -0,0 +1,33 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_foo { + pub bar: Struct_foo_struct_with_anon_struct_h_unnamed_1, +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_foo_struct_with_anon_struct_h_unnamed_1 { + 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); +} +impl ::std::clone::Clone for Struct_foo { + 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); +} diff --git a/tests/expectations/struct_with_anon_struct_array.rs b/tests/expectations/struct_with_anon_struct_array.rs new file mode 100644 index 00000000..a7912d02 --- /dev/null +++ b/tests/expectations/struct_with_anon_struct_array.rs @@ -0,0 +1,52 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[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], +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_foo_struct_with_anon_struct_array_h_unnamed_1 { + 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); +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_foo_struct_with_anon_struct_array_h_unnamed_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_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); +} +impl ::std::clone::Clone for Struct_foo { + 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); +} diff --git a/tests/expectations/struct_with_anon_struct_pointer.rs b/tests/expectations/struct_with_anon_struct_pointer.rs new file mode 100644 index 00000000..913412c5 --- /dev/null +++ b/tests/expectations/struct_with_anon_struct_pointer.rs @@ -0,0 +1,34 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_foo { + pub bar: *mut Struct_foo_struct_with_anon_struct_pointer_h_unnamed_1, +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_foo_struct_with_anon_struct_pointer_h_unnamed_1 { + 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); +} +impl ::std::clone::Clone for Struct_foo { + 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); +} diff --git a/tests/expectations/struct_with_anon_union.rs b/tests/expectations/struct_with_anon_union.rs new file mode 100644 index 00000000..84381c4a --- /dev/null +++ b/tests/expectations/struct_with_anon_union.rs @@ -0,0 +1,62 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[derive(Copy, Debug)] +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() } +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_foo { + pub bar: Union_foo_struct_with_anon_union_h_unnamed_1, +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Union_foo_struct_with_anon_union_h_unnamed_1 { + pub a: __BindgenUnionField<::std::os::raw::c_uint>, + pub b: __BindgenUnionField<::std::os::raw::c_ushort>, + pub _bindgen_data_: 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)) + } +} +impl ::std::clone::Clone for Union_foo_struct_with_anon_union_h_unnamed_1 { + 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); +} +impl ::std::clone::Clone for Struct_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 new file mode 100644 index 00000000..800b4e23 --- /dev/null +++ b/tests/expectations/struct_with_anon_unnamed_struct.rs @@ -0,0 +1,34 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[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, +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_foo_struct_with_anon_unnamed_struct_h_unnamed_1 { + 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); +} +impl ::std::clone::Clone for Struct_foo { + 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); +} diff --git a/tests/expectations/struct_with_anon_unnamed_union.rs b/tests/expectations/struct_with_anon_unnamed_union.rs new file mode 100644 index 00000000..5a20dca7 --- /dev/null +++ b/tests/expectations/struct_with_anon_unnamed_union.rs @@ -0,0 +1,63 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[derive(Copy, Debug)] +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() } +} +#[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, +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Union_foo_struct_with_anon_unnamed_union_h_unnamed_1 { + pub a: __BindgenUnionField<::std::os::raw::c_uint>, + pub b: __BindgenUnionField<::std::os::raw::c_ushort>, + pub _bindgen_data_: 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)) + } +} +impl ::std::clone::Clone for + Union_foo_struct_with_anon_unnamed_union_h_unnamed_1 { + 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); +} +impl ::std::clone::Clone for Struct_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 new file mode 100644 index 00000000..78ab9ddf --- /dev/null +++ b/tests/expectations/struct_with_bitfields.rs @@ -0,0 +1,79 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_bitfield { + pub _bitfield_1: ::std::os::raw::c_ushort, + pub e: ::std::os::raw::c_int, + pub _bitfield_2: ::std::os::raw::c_uint, + pub _bitfield_3: ::std::os::raw::c_uint, +} +impl Struct_bitfield { + pub fn set_a(&mut self, val: bool) { + self._bitfield_1 &= + !(((1 << (1u32 as ::std::os::raw::c_ushort)) - 1) << 0usize); + self._bitfield_1 |= (val as ::std::os::raw::c_ushort) << 0usize; + } + pub fn set_b(&mut self, val: bool) { + self._bitfield_1 &= + !(((1 << (1u32 as ::std::os::raw::c_ushort)) - 1) << 1usize); + self._bitfield_1 |= (val as ::std::os::raw::c_ushort) << 1usize; + } + pub fn set_c(&mut self, val: bool) { + self._bitfield_1 &= + !(((1 << (1u32 as ::std::os::raw::c_ushort)) - 1) << 2usize); + self._bitfield_1 |= (val as ::std::os::raw::c_ushort) << 2usize; + } + pub fn set_at_offset_3(&mut self, val: bool) { + self._bitfield_1 &= + !(((1 << (1u32 as ::std::os::raw::c_ushort)) - 1) << 3usize); + self._bitfield_1 |= (val as ::std::os::raw::c_ushort) << 3usize; + } + pub fn set_at_offset_4(&mut self, val: u8) { + self._bitfield_1 &= + !(((1 << (2u32 as ::std::os::raw::c_ushort)) - 1) << 4usize); + self._bitfield_1 |= (val as ::std::os::raw::c_ushort) << 4usize; + } + pub fn set_d(&mut self, val: u8) { + self._bitfield_1 &= + !(((1 << (2u32 as ::std::os::raw::c_ushort)) - 1) << 6usize); + self._bitfield_1 |= (val as ::std::os::raw::c_ushort) << 6usize; + } + pub const 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_f(&mut self, val: u8) { + self._bitfield_2 &= + !(((1 << (2u32 as ::std::os::raw::c_uint)) - 1) << 0usize); + self._bitfield_2 |= (val as ::std::os::raw::c_uint) << 0usize; + } + pub const fn new_bitfield_2(f: u8) -> ::std::os::raw::c_uint { + 0 | ((f as ::std::os::raw::c_uint) << 0u32) + } + pub fn set_g(&mut self, val: u32) { + self._bitfield_3 &= + !(((1 << (0u32 as ::std::os::raw::c_uint)) - 1) << 0usize); + self._bitfield_3 |= (val as ::std::os::raw::c_uint) << 0usize; + } + pub const fn new_bitfield_3(g: u32) -> ::std::os::raw::c_uint { + 0 | ((g as ::std::os::raw::c_uint) << 0u32) + } +} +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 new file mode 100644 index 00000000..a69c6807 --- /dev/null +++ b/tests/expectations/struct_with_derive_debug.rs @@ -0,0 +1,56 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct 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); +} +#[repr(C)] +#[derive(Copy)] +pub struct 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); +} +#[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 } +} +#[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, +} +impl ::std::clone::Clone for Struct_WithBigArray { + fn clone(&self) -> Self { *self } +} +#[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); +} diff --git a/tests/expectations/struct_with_nesting.rs b/tests/expectations/struct_with_nesting.rs new file mode 100644 index 00000000..fa1fdfff --- /dev/null +++ b/tests/expectations/struct_with_nesting.rs @@ -0,0 +1,108 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[derive(Copy, Debug)] +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() } +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct 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, +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Union_foo_struct_with_nesting_h_unnamed_1 { + 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); +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_foo_struct_with_nesting_h_unnamed_1_struct_with_nesting_h_unnamed_2 { + 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>() + , 4usize); + assert_eq!(::std::mem::align_of::<Struct_foo_struct_with_nesting_h_unnamed_1_struct_with_nesting_h_unnamed_2>() + , 2usize); +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_foo_struct_with_nesting_h_unnamed_1_struct_with_nesting_h_unnamed_3 { + 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>() + , 4usize); + assert_eq!(::std::mem::align_of::<Struct_foo_struct_with_nesting_h_unnamed_1_struct_with_nesting_h_unnamed_3>() + , 1usize); +} +impl ::std::clone::Clone for Struct_foo { + 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); +} diff --git a/tests/expectations/struct_with_packing.rs b/tests/expectations/struct_with_packing.rs new file mode 100644 index 00000000..bcf543cd --- /dev/null +++ b/tests/expectations/struct_with_packing.rs @@ -0,0 +1,18 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[repr(C, packed)] +#[derive(Debug, Copy)] +pub struct 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); +} diff --git a/tests/expectations/struct_with_struct.rs b/tests/expectations/struct_with_struct.rs new file mode 100644 index 00000000..d3d4daf5 --- /dev/null +++ b/tests/expectations/struct_with_struct.rs @@ -0,0 +1,33 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_foo { + pub bar: Struct_foo_struct_with_struct_h_unnamed_1, +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_foo_struct_with_struct_h_unnamed_1 { + 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); +} +impl ::std::clone::Clone for Struct_foo { + 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); +} diff --git a/tests/expectations/template.rs b/tests/expectations/template.rs new file mode 100644 index 00000000..cd269a66 --- /dev/null +++ b/tests/expectations/template.rs @@ -0,0 +1,30 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[repr(C)] +#[derive(Debug)] +pub struct 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>, +} +#[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>, +} +#[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 m_baz: Z, + 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>); +} diff --git a/tests/expectations/union_fields.rs b/tests/expectations/union_fields.rs new file mode 100644 index 00000000..40004b33 --- /dev/null +++ b/tests/expectations/union_fields.rs @@ -0,0 +1,55 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[derive(Copy, Debug)] +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() } +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Union_union_fields_hpp_unnamed_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, +} +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)) + } +} +impl ::std::clone::Clone for Union_union_fields_hpp_unnamed_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; diff --git a/tests/expectations/union_with_anon_struct.rs b/tests/expectations/union_with_anon_struct.rs new file mode 100644 index 00000000..c5fa755a --- /dev/null +++ b/tests/expectations/union_with_anon_struct.rs @@ -0,0 +1,59 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[derive(Copy, Debug)] +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() } +} +#[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); +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_foo_union_with_anon_struct_h_unnamed_1 { + 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 { + 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); +} diff --git a/tests/expectations/union_with_anon_struct_bitfield.rs b/tests/expectations/union_with_anon_struct_bitfield.rs new file mode 100644 index 00000000..c4038ee1 --- /dev/null +++ b/tests/expectations/union_with_anon_struct_bitfield.rs @@ -0,0 +1,80 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[derive(Copy, Debug)] +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() } +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Union_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, +} +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 } +} +#[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); +} +#[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 Struct_foo_union_with_anon_struct_bitfield_h_unnamed_1 { + pub fn set_b(&mut self, val: u8) { + self._bitfield_1 &= + !(((1 << (7u32 as ::std::os::raw::c_int)) - 1) << 0usize); + self._bitfield_1 |= (val as ::std::os::raw::c_int) << 0usize; + } + pub fn set_c(&mut self, val: u32) { + self._bitfield_1 &= + !(((1 << (25u32 as ::std::os::raw::c_int)) - 1) << 7usize); + self._bitfield_1 |= (val as ::std::os::raw::c_int) << 7usize; + } + pub const 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) + } +} +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); +} diff --git a/tests/expectations/union_with_anon_union.rs b/tests/expectations/union_with_anon_union.rs new file mode 100644 index 00000000..db8bfda8 --- /dev/null +++ b/tests/expectations/union_with_anon_union.rs @@ -0,0 +1,70 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[derive(Copy, Debug)] +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() } +} +#[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); +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Union_foo_union_with_anon_union_h_unnamed_1 { + pub a: __BindgenUnionField<::std::os::raw::c_uint>, + pub b: __BindgenUnionField<::std::os::raw::c_ushort>, + pub _bindgen_data_: 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)) + } +} +impl ::std::clone::Clone for Union_foo_union_with_anon_union_h_unnamed_1 { + 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); +} diff --git a/tests/expectations/union_with_anon_unnamed_struct.rs b/tests/expectations/union_with_anon_unnamed_struct.rs new file mode 100644 index 00000000..7b5955fe --- /dev/null +++ b/tests/expectations/union_with_anon_unnamed_struct.rs @@ -0,0 +1,67 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[derive(Copy, Debug)] +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() } +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Union_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); +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_pixel_union_with_anon_unnamed_struct_h_unnamed_1 { + 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 { + 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); +} diff --git a/tests/expectations/union_with_anon_unnamed_union.rs b/tests/expectations/union_with_anon_unnamed_union.rs new file mode 100644 index 00000000..22f1546d --- /dev/null +++ b/tests/expectations/union_with_anon_unnamed_union.rs @@ -0,0 +1,76 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[derive(Copy, Debug)] +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() } +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Union_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); +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Union_foo_union_with_anon_unnamed_union_h_unnamed_1 { + pub b: __BindgenUnionField<::std::os::raw::c_ushort>, + pub c: __BindgenUnionField<::std::os::raw::c_uchar>, + pub _bindgen_data_: 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)) + } +} +impl ::std::clone::Clone for + Union_foo_union_with_anon_unnamed_union_h_unnamed_1 { + 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); +} diff --git a/tests/expectations/union_with_big_member.rs b/tests/expectations/union_with_big_member.rs new file mode 100644 index 00000000..0513c5a6 --- /dev/null +++ b/tests/expectations/union_with_big_member.rs @@ -0,0 +1,72 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[derive(Copy, Debug)] +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() } +} +#[repr(C)] +#[derive(Copy)] +pub struct Union_WithBigArray { + pub a: __BindgenUnionField<::std::os::raw::c_int>, + pub b: __BindgenUnionField<[::std::os::raw::c_int; 33usize]>, + pub _bindgen_data_: [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)) + } +} +impl ::std::clone::Clone for Union_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 a: __BindgenUnionField<::std::os::raw::c_int>, + pub b: __BindgenUnionField<Union_WithBigArray>, + pub _bindgen_data_: [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)) + } +} +impl ::std::clone::Clone for Union_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 new file mode 100644 index 00000000..dc8ba470 --- /dev/null +++ b/tests/expectations/union_with_nesting.rs @@ -0,0 +1,120 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[derive(Copy, Debug)] +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() } +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Union_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); +} +#[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, +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Union_foo_union_with_nesting_h_unnamed_1_union_with_nesting_h_unnamed_2 { + 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 } +} +#[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>() + , 2usize); + assert_eq!(::std::mem::align_of::<Union_foo_union_with_nesting_h_unnamed_1_union_with_nesting_h_unnamed_2>() + , 2usize); +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Union_foo_union_with_nesting_h_unnamed_1_union_with_nesting_h_unnamed_3 { + pub c1: __BindgenUnionField<::std::os::raw::c_ushort>, + pub c2: __BindgenUnionField<::std::os::raw::c_ushort>, + pub _bindgen_data_: 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)) + } +} +impl ::std::clone::Clone for + Union_foo_union_with_nesting_h_unnamed_1_union_with_nesting_h_unnamed_3 { + 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); +} +impl ::std::clone::Clone for Struct_foo_union_with_nesting_h_unnamed_1 { + 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); +} diff --git a/tests/expectations/using.rs b/tests/expectations/using.rs new file mode 100644 index 00000000..77267324 --- /dev/null +++ b/tests/expectations/using.rs @@ -0,0 +1,12 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[repr(C)] +#[derive(Debug)] +pub struct 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>; diff --git a/tests/expectations/weird_bitfields.rs b/tests/expectations/weird_bitfields.rs new file mode 100644 index 00000000..9a7bc893 --- /dev/null +++ b/tests/expectations/weird_bitfields.rs @@ -0,0 +1,85 @@ +/* automatically generated by rust-bindgen */ + +#![feature(const_fn)] + +#[repr(u32)] +#[derive(Debug, Copy, Clone)] +pub enum Enum_nsStyleSVGOpacitySource { + eStyleSVGOpacitySource_Normal = 0, + eStyleSVGOpacitySource_ContextFillOpacity = 1, + eStyleSVGOpacitySource_ContextStrokeOpacity = 2, +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Struct_Weird { + pub mStrokeDasharrayLength: ::std::os::raw::c_uint, + pub _bitfield_1: ::std::os::raw::c_uint, + pub mClipRule: ::std::os::raw::c_uchar, + pub mColorInterpolation: ::std::os::raw::c_uchar, + pub mColorInterpolationFilters: ::std::os::raw::c_uchar, + pub mFillRule: ::std::os::raw::c_uchar, + pub mImageRendering: ::std::os::raw::c_uchar, + pub mPaintOrder: ::std::os::raw::c_uchar, + pub mShapeRendering: ::std::os::raw::c_uchar, + pub mStrokeLinecap: ::std::os::raw::c_uchar, + 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, +} +impl Struct_Weird { + pub fn set_bitTest(&mut self, val: u16) { + self._bitfield_1 &= + !(((1 << (16u32 as ::std::os::raw::c_uint)) - 1) << 0usize); + self._bitfield_1 |= (val as ::std::os::raw::c_uint) << 0usize; + } + pub fn set_bitTest2(&mut self, val: u16) { + self._bitfield_1 &= + !(((1 << (15u32 as ::std::os::raw::c_uint)) - 1) << 16usize); + self._bitfield_1 |= (val as ::std::os::raw::c_uint) << 16usize; + } + pub const 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) + } + pub fn set_mFillOpacitySource(&mut self, val: u8) { + self._bitfield_2 &= !(((1 << (3u32 as u32)) - 1) << 0usize); + self._bitfield_2 |= (val as u32) << 0usize; + } + pub fn set_mStrokeOpacitySource(&mut self, val: u8) { + self._bitfield_2 &= !(((1 << (3u32 as u32)) - 1) << 3usize); + self._bitfield_2 |= (val as u32) << 3usize; + } + pub fn set_mStrokeDasharrayFromObject(&mut self, val: bool) { + self._bitfield_2 &= !(((1 << (1u32 as u32)) - 1) << 6usize); + self._bitfield_2 |= (val as u32) << 6usize; + } + pub fn set_mStrokeDashoffsetFromObject(&mut self, val: bool) { + self._bitfield_2 &= !(((1 << (1u32 as u32)) - 1) << 7usize); + self._bitfield_2 |= (val as u32) << 7usize; + } + pub fn set_mStrokeWidthFromObject(&mut self, val: bool) { + self._bitfield_2 &= !(((1 << (1u32 as u32)) - 1) << 8usize); + self._bitfield_2 |= (val as u32) << 8usize; + } + pub const 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); +} |