Skip to content

Commit 3c8ab3a

Browse files
committed
feat(libquickjs-sys): add JSRefCountHeader struct and layout tests
1 parent 75eb986 commit 3c8ab3a

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

libquickjs-sys/embed/bindings-32.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,36 @@ pub const JS_TAG_CATCH_OFFSET: _bindgen_ty_1 = 5;
105105
pub const JS_TAG_EXCEPTION: _bindgen_ty_1 = 6;
106106
pub const JS_TAG_FLOAT64: _bindgen_ty_1 = 7;
107107
pub type _bindgen_ty_1 = ::std::os::raw::c_int;
108+
#[repr(C)]
109+
#[derive(Debug, Copy, Clone)]
110+
pub struct JSRefCountHeader {
111+
pub ref_count: ::std::os::raw::c_int,
112+
}
113+
#[test]
114+
fn bindgen_test_layout_JSRefCountHeader() {
115+
const UNINIT: ::std::mem::MaybeUninit<JSRefCountHeader> = ::std::mem::MaybeUninit::uninit();
116+
let ptr = UNINIT.as_ptr();
117+
assert_eq!(
118+
::std::mem::size_of::<JSRefCountHeader>(),
119+
4usize,
120+
concat!("Size of: ", stringify!(JSRefCountHeader))
121+
);
122+
assert_eq!(
123+
::std::mem::align_of::<JSRefCountHeader>(),
124+
4usize,
125+
concat!("Alignment of ", stringify!(JSRefCountHeader))
126+
);
127+
assert_eq!(
128+
unsafe { ::std::ptr::addr_of!((*ptr).ref_count) as usize - ptr as usize },
129+
0usize,
130+
concat!(
131+
"Offset of field: ",
132+
stringify!(JSRefCountHeader),
133+
"::",
134+
stringify!(ref_count)
135+
)
136+
);
137+
}
108138
pub type JSValue = u64;
109139
pub type JSCFunction = ::std::option::Option<
110140
unsafe extern "C" fn(

0 commit comments

Comments
 (0)