From: Matt Corallo Date: Sun, 1 Oct 2023 23:05:26 +0000 (+0000) Subject: Include argument info docs on all-pub struct constructors X-Git-Tag: v0.0.117.0^2~4 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=53e91fd10d98313d2175470416f635d080e67e65;p=ldk-c-bindings Include argument info docs on all-pub struct constructors Fixes https://github.com/lightningdevkit/ldk-garbagecollected/issues/129 --- 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 {