oxilean_codegen/ffi_bridge/
ffistructdef_traits.rs1use crate::lcnf::*;
12
13use super::types::FfiStructDef;
14use std::fmt;
15
16impl std::fmt::Display for FfiStructDef {
17 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
18 let kw = if self.is_union { "union" } else { "struct" };
19 let packed = if self.is_packed {
20 " __attribute__((packed))"
21 } else {
22 ""
23 };
24 let align = if let Some(a) = self.alignment {
25 format!(" __attribute__((aligned({})))", a)
26 } else {
27 String::new()
28 };
29 writeln!(f, "{} {}{}{} {{", kw, self.name, packed, align)?;
30 for fld in &self.fields {
31 writeln!(f, " {};", fld)?;
32 }
33 write!(f, "}};")
34 }
35}