Skip to content

Commit

Permalink
Merge pull request #98 from baszalmstra/feature/size_and_alignment_in…
Browse files Browse the repository at this point in the history
…_type_info

feat: size and alignment in type info
  • Loading branch information
Wodann authored Mar 21, 2020
2 parents dd8111c + e66cbbc commit 82fee48
Show file tree
Hide file tree
Showing 27 changed files with 760 additions and 529 deletions.
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

0 comments on commit 82fee48

Please sign in to comment.