1 #![allow(
2     dead_code,
3     non_snake_case,
4     non_camel_case_types,
5     non_upper_case_globals
6 )]
7 
8 #[repr(C)]
9 pub struct BaseWithVtable__bindgen_vtable {}
10 /// This should have an explicit vtable.
11 #[repr(C)]
12 #[derive(Debug, Copy, Clone)]
13 pub struct BaseWithVtable<T> {
14     pub vtable_: *const BaseWithVtable__bindgen_vtable,
15     pub t: T,
16     pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
17 }
18 impl<T> Default for BaseWithVtable<T> {
defaultnull19     fn default() -> Self {
20         let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
21         unsafe {
22             ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
23             s.assume_init()
24         }
25     }
26 }
27 /// This should not have an explicit vtable.
28 #[repr(C)]
29 #[derive(Debug, Copy, Clone)]
30 pub struct DerivedWithNoVirtualMethods {
31     pub _base: BaseWithVtable<*mut ::std::os::raw::c_char>,
32 }
33 #[test]
bindgen_test_layout_DerivedWithNoVirtualMethodsnull34 fn bindgen_test_layout_DerivedWithNoVirtualMethods() {
35     assert_eq!(
36         ::std::mem::size_of::<DerivedWithNoVirtualMethods>(),
37         16usize,
38         concat!("Size of: ", stringify!(DerivedWithNoVirtualMethods))
39     );
40     assert_eq!(
41         ::std::mem::align_of::<DerivedWithNoVirtualMethods>(),
42         8usize,
43         concat!("Alignment of ", stringify!(DerivedWithNoVirtualMethods))
44     );
45 }
46 impl Default for DerivedWithNoVirtualMethods {
defaultnull47     fn default() -> Self {
48         let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
49         unsafe {
50             ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
51             s.assume_init()
52         }
53     }
54 }
55 /// This should not have an explicit vtable.
56 #[repr(C)]
57 #[derive(Debug, Copy, Clone)]
58 pub struct DerivedWithVirtualMethods {
59     pub _base: BaseWithVtable<*mut ::std::os::raw::c_char>,
60 }
61 #[test]
bindgen_test_layout_DerivedWithVirtualMethodsnull62 fn bindgen_test_layout_DerivedWithVirtualMethods() {
63     assert_eq!(
64         ::std::mem::size_of::<DerivedWithVirtualMethods>(),
65         16usize,
66         concat!("Size of: ", stringify!(DerivedWithVirtualMethods))
67     );
68     assert_eq!(
69         ::std::mem::align_of::<DerivedWithVirtualMethods>(),
70         8usize,
71         concat!("Alignment of ", stringify!(DerivedWithVirtualMethods))
72     );
73 }
74 impl Default for DerivedWithVirtualMethods {
defaultnull75     fn default() -> Self {
76         let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
77         unsafe {
78             ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
79             s.assume_init()
80         }
81     }
82 }
83 /// This should not have any vtable.
84 #[repr(C)]
85 #[derive(Debug, Copy, Clone)]
86 pub struct BaseWithoutVtable<U> {
87     pub u: U,
88     pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<U>>,
89 }
90 impl<U> Default for BaseWithoutVtable<U> {
defaultnull91     fn default() -> Self {
92         let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
93         unsafe {
94             ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
95             s.assume_init()
96         }
97     }
98 }
99 #[repr(C)]
100 pub struct DerivedWithVtable__bindgen_vtable(::std::os::raw::c_void);
101 /// This should have an explicit vtable.
102 #[repr(C)]
103 #[derive(Debug, Copy, Clone)]
104 pub struct DerivedWithVtable {
105     pub vtable_: *const DerivedWithVtable__bindgen_vtable,
106     pub _base: BaseWithoutVtable<*mut ::std::os::raw::c_char>,
107 }
108 #[test]
bindgen_test_layout_DerivedWithVtablenull109 fn bindgen_test_layout_DerivedWithVtable() {
110     assert_eq!(
111         ::std::mem::size_of::<DerivedWithVtable>(),
112         16usize,
113         concat!("Size of: ", stringify!(DerivedWithVtable))
114     );
115     assert_eq!(
116         ::std::mem::align_of::<DerivedWithVtable>(),
117         8usize,
118         concat!("Alignment of ", stringify!(DerivedWithVtable))
119     );
120 }
121 impl Default for DerivedWithVtable {
defaultnull122     fn default() -> Self {
123         let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
124         unsafe {
125             ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
126             s.assume_init()
127         }
128     }
129 }
130 /// This should not have any vtable.
131 #[repr(C)]
132 #[derive(Debug, Copy, Clone)]
133 pub struct DerivedWithoutVtable {
134     pub _base: BaseWithoutVtable<*mut ::std::os::raw::c_char>,
135 }
136 #[test]
bindgen_test_layout_DerivedWithoutVtablenull137 fn bindgen_test_layout_DerivedWithoutVtable() {
138     assert_eq!(
139         ::std::mem::size_of::<DerivedWithoutVtable>(),
140         8usize,
141         concat!("Size of: ", stringify!(DerivedWithoutVtable))
142     );
143     assert_eq!(
144         ::std::mem::align_of::<DerivedWithoutVtable>(),
145         8usize,
146         concat!("Alignment of ", stringify!(DerivedWithoutVtable))
147     );
148 }
149 impl Default for DerivedWithoutVtable {
defaultnull150     fn default() -> Self {
151         let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
152         unsafe {
153             ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
154             s.assume_init()
155         }
156     }
157 }
158 #[test]
__bindgen_test_layout_BaseWithVtable_open0_ptr_char_close0_instantiationnull159 fn __bindgen_test_layout_BaseWithVtable_open0_ptr_char_close0_instantiation() {
160     assert_eq!(
161         ::std::mem::size_of::<BaseWithVtable<*mut ::std::os::raw::c_char>>(),
162         16usize,
163         concat!(
164             "Size of template specialization: ",
165             stringify!(BaseWithVtable<*mut ::std::os::raw::c_char>)
166         )
167     );
168     assert_eq!(
169         ::std::mem::align_of::<BaseWithVtable<*mut ::std::os::raw::c_char>>(),
170         8usize,
171         concat!(
172             "Alignment of template specialization: ",
173             stringify!(BaseWithVtable<*mut ::std::os::raw::c_char>)
174         )
175     );
176 }
177 #[test]
__bindgen_test_layout_BaseWithVtable_open0_ptr_char_close0_instantiation_1null178 fn __bindgen_test_layout_BaseWithVtable_open0_ptr_char_close0_instantiation_1()
179 {
180     assert_eq!(
181         ::std::mem::size_of::<BaseWithVtable<*mut ::std::os::raw::c_char>>(),
182         16usize,
183         concat!(
184             "Size of template specialization: ",
185             stringify!(BaseWithVtable<*mut ::std::os::raw::c_char>)
186         )
187     );
188     assert_eq!(
189         ::std::mem::align_of::<BaseWithVtable<*mut ::std::os::raw::c_char>>(),
190         8usize,
191         concat!(
192             "Alignment of template specialization: ",
193             stringify!(BaseWithVtable<*mut ::std::os::raw::c_char>)
194         )
195     );
196 }
197 #[test]
__bindgen_test_layout_BaseWithoutVtable_open0_ptr_char_close0_instantiationnull198 fn __bindgen_test_layout_BaseWithoutVtable_open0_ptr_char_close0_instantiation()
199 {
200     assert_eq!(
201         ::std::mem::size_of::<BaseWithoutVtable<*mut ::std::os::raw::c_char>>(),
202         8usize,
203         concat!(
204             "Size of template specialization: ",
205             stringify!(BaseWithoutVtable<*mut ::std::os::raw::c_char>)
206         )
207     );
208     assert_eq!(
209         ::std::mem::align_of::<BaseWithoutVtable<*mut ::std::os::raw::c_char>>(
210         ),
211         8usize,
212         concat!(
213             "Alignment of template specialization: ",
214             stringify!(BaseWithoutVtable<*mut ::std::os::raw::c_char>)
215         )
216     );
217 }
218 #[test]
__bindgen_test_layout_BaseWithoutVtable_open0_ptr_char_close0_instantiation_1null219 fn __bindgen_test_layout_BaseWithoutVtable_open0_ptr_char_close0_instantiation_1(
220 ) {
221     assert_eq!(
222         ::std::mem::size_of::<BaseWithoutVtable<*mut ::std::os::raw::c_char>>(),
223         8usize,
224         concat!(
225             "Size of template specialization: ",
226             stringify!(BaseWithoutVtable<*mut ::std::os::raw::c_char>)
227         )
228     );
229     assert_eq!(
230         ::std::mem::align_of::<BaseWithoutVtable<*mut ::std::os::raw::c_char>>(
231         ),
232         8usize,
233         concat!(
234             "Alignment of template specialization: ",
235             stringify!(BaseWithoutVtable<*mut ::std::os::raw::c_char>)
236         )
237     );
238 }
239