Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: size and alignment in type info #98

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
continue-on-error: ${{ matrix.config.toolchain == 'nightly' }}
with:
command: test
args: -- --nocapture

style:
name: Check Style
Expand Down
2 changes: 1 addition & 1 deletion crates/mun_abi/c
Submodule c updated 1 files
+11 −11 include/mun_abi.h
56 changes: 28 additions & 28 deletions crates/mun_abi/src/autogen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ pub struct TypeInfo {
pub guid: Guid,
#[doc = " Type name"]
pub name: *const ::std::os::raw::c_char,
#[doc = " The exact size of the type in bits without any padding"]
pub size_in_bits: u32,
#[doc = " The alignment of the type"]
pub alignment: u8,
#[doc = " Type group"]
pub group: TypeGroup,
}
Expand Down Expand Up @@ -82,8 +86,28 @@ fn bindgen_test_layout_TypeInfo() {
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<TypeInfo>())).group as *const _ as usize },
unsafe { &(*(::std::ptr::null::<TypeInfo>())).size_in_bits as *const _ as usize },
24usize,
concat!(
"Offset of field: ",
stringify!(TypeInfo),
"::",
stringify!(size_in_bits)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<TypeInfo>())).alignment as *const _ as usize },
28usize,
concat!(
"Offset of field: ",
stringify!(TypeInfo),
"::",
stringify!(alignment)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<TypeInfo>())).group as *const _ as usize },
29usize,
concat!(
"Offset of field: ",
stringify!(TypeInfo),
Expand Down Expand Up @@ -232,20 +256,16 @@ pub struct StructInfo {
pub field_types: *const *const TypeInfo,
#[doc = " Struct fields' offsets"]
pub field_offsets: *const u16,
#[doc = " Struct fields' sizes (in bytes)"]
pub field_sizes: *const u16,
#[doc = " Number of fields"]
pub num_fields: u16,
#[doc = " Struct memory alignment"]
pub alignment: u16,
#[doc = " Struct memory kind"]
pub memory_kind: StructMemoryKind,
}
#[test]
fn bindgen_test_layout_StructInfo() {
assert_eq!(
::std::mem::size_of::<StructInfo>(),
48usize,
40usize,
concat!("Size of: ", stringify!(StructInfo))
);
assert_eq!(
Expand Down Expand Up @@ -293,39 +313,19 @@ fn bindgen_test_layout_StructInfo() {
stringify!(field_offsets)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<StructInfo>())).field_sizes as *const _ as usize },
32usize,
concat!(
"Offset of field: ",
stringify!(StructInfo),
"::",
stringify!(field_sizes)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<StructInfo>())).num_fields as *const _ as usize },
40usize,
32usize,
concat!(
"Offset of field: ",
stringify!(StructInfo),
"::",
stringify!(num_fields)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<StructInfo>())).alignment as *const _ as usize },
42usize,
concat!(
"Offset of field: ",
stringify!(StructInfo),
"::",
stringify!(alignment)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<StructInfo>())).memory_kind as *const _ as usize },
44usize,
34usize,
concat!(
"Offset of field: ",
stringify!(StructInfo),
Expand Down
Loading