From 197e7ff159a8c2b879c1d40bcf39ff1d1060dc46 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Fri, 5 Jul 2024 11:41:40 -0700 Subject: [PATCH] Add FieldInfo::field_type_name --- bindgen/callbacks.rs | 2 ++ bindgen/codegen/mod.rs | 3 +++ 2 files changed, 5 insertions(+) diff --git a/bindgen/callbacks.rs b/bindgen/callbacks.rs index 0f16c4c0bf..56cd97b9c8 100644 --- a/bindgen/callbacks.rs +++ b/bindgen/callbacks.rs @@ -205,4 +205,6 @@ pub struct FieldInfo<'a> { pub type_name: &'a str, /// The name of the field. pub field_name: &'a str, + /// The name of the type of the field. + pub field_type_name: Option<&'a str>, } diff --git a/bindgen/codegen/mod.rs b/bindgen/codegen/mod.rs index e2aaee9820..192b74ba4f 100644 --- a/bindgen/codegen/mod.rs +++ b/bindgen/codegen/mod.rs @@ -1515,6 +1515,7 @@ impl<'a> FieldCodegen<'a> for FieldData { cb.field_visibility(FieldInfo { type_name: &parent_item.canonical_name(ctx), field_name, + field_type_name: field_ty.name(), }) }), self.annotations(), @@ -1889,6 +1890,7 @@ impl<'a> FieldCodegen<'a> for Bitfield { let bitfield_ty_item = ctx.resolve_item(self.ty()); let bitfield_ty = bitfield_ty_item.expect_type(); + let bitfield_ty_ident = bitfield_ty.name(); let bitfield_ty_layout = bitfield_ty .layout(ctx) @@ -1916,6 +1918,7 @@ impl<'a> FieldCodegen<'a> for Bitfield { cb.field_visibility(FieldInfo { type_name: &parent_item.canonical_name(ctx), field_name, + field_type_name: bitfield_ty_ident, }) }) });