Skip to content

Commit

Permalink
feat: added size and alignment to TypeInfo removed from StructInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
baszalmstra committed Mar 20, 2020
1 parent 9540c2e commit 4066cfd
Show file tree
Hide file tree
Showing 14 changed files with 158 additions and 211 deletions.
2 changes: 1 addition & 1 deletion crates/mun_abi/c
Submodule c updated 1 files
+11 −11 include/mun_abi.h
58 changes: 29 additions & 29 deletions crates/mun_abi/src/autogen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,18 @@ 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: u64,
#[doc = " The alignment of the type"]
pub alignment: u32,
#[doc = " Type group"]
pub group: TypeGroup,
}
#[test]
fn bindgen_test_layout_TypeInfo() {
assert_eq!(
::std::mem::size_of::<TypeInfo>(),
32usize,
40usize,
concat!("Size of: ", stringify!(TypeInfo))
);
assert_eq!(
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 },
32usize,
concat!(
"Offset of field: ",
stringify!(TypeInfo),
"::",
stringify!(alignment)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<TypeInfo>())).group as *const _ as usize },
36usize,
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 4066cfd

Please sign in to comment.