aboutsummaryrefslogtreecommitdiff
path: root/ir/layout.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ir/layout.rs')
-rw-r--r--ir/layout.rs24
1 files changed, 13 insertions, 11 deletions
diff --git a/ir/layout.rs b/ir/layout.rs
index 17ca66e..85a553d 100644
--- a/ir/layout.rs
+++ b/ir/layout.rs
@@ -8,13 +8,13 @@ use std::cmp;
/// A type that represents the struct layout of a type.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
-pub struct Layout {
+pub(crate) struct Layout {
/// The size (in bytes) of this layout.
- pub size: usize,
+ pub(crate) size: usize,
/// The alignment (in bytes) of this layout.
- pub align: usize,
+ pub(crate) align: usize,
/// Whether this layout's members are packed or not.
- pub packed: bool,
+ pub(crate) packed: bool,
}
#[test]
@@ -37,13 +37,15 @@ impl Layout {
pub(crate) fn known_type_for_size(
ctx: &BindgenContext,
size: usize,
- ) -> Option<&'static str> {
+ ) -> Option<syn::Type> {
Some(match size {
- 16 if ctx.options().rust_features.i128_and_u128 => "u128",
- 8 => "u64",
- 4 => "u32",
- 2 => "u16",
- 1 => "u8",
+ 16 if ctx.options().rust_features.i128_and_u128 => {
+ syn::parse_quote! { u128 }
+ }
+ 8 => syn::parse_quote! { u64 },
+ 4 => syn::parse_quote! { u32 },
+ 2 => syn::parse_quote! { u16 },
+ 1 => syn::parse_quote! { u8 },
_ => return None,
})
}
@@ -103,7 +105,7 @@ impl Opaque {
pub(crate) fn known_rust_type_for_array(
&self,
ctx: &BindgenContext,
- ) -> Option<&'static str> {
+ ) -> Option<syn::Type> {
Layout::known_type_for_size(ctx, self.0.align)
}