From 53e91fd10d98313d2175470416f635d080e67e65 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sun, 1 Oct 2023 23:05:26 +0000 Subject: [PATCH] Include argument info docs on all-pub struct constructors Fixes https://github.com/lightningdevkit/ldk-garbagecollected/issues/129 --- c-bindings-gen/src/main.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/c-bindings-gen/src/main.rs b/c-bindings-gen/src/main.rs index 956420b..7c06687 100644 --- a/c-bindings-gen/src/main.rs +++ b/c-bindings-gen/src/main.rs @@ -812,6 +812,19 @@ fn writeln_struct<'a, 'b, W: std::io::Write>(w: &mut W, s: &'a syn::ItemStruct, if all_fields_settable { // Build a constructor! writeln!(w, "/// Constructs a new {} given each field", struct_name).unwrap(); + match &s.fields { + syn::Fields::Named(fields) => { + writeln_arg_docs(w, &[], "", types, Some(&gen_types), + fields.named.iter().map(|field| (format!("{}_arg", field.ident.as_ref().unwrap()), &field.ty)), + None); + }, + syn::Fields::Unnamed(fields) => { + writeln_arg_docs(w, &[], "", types, Some(&gen_types), + fields.unnamed.iter().enumerate().map(|(idx, field)| (format!("{}_arg", ('a' as u8 + idx as u8)), &field.ty)), + None); + }, + syn::Fields::Unit => {}, + } write!(w, "#[must_use]\n#[no_mangle]\npub extern \"C\" fn {}_new(", struct_name).unwrap(); match &s.fields { -- 2.39.5