]> git.bitcoin.ninja Git - ldk-c-bindings/commitdiff
Print the correct object names whem processing supertrait methods
authorMatt Corallo <git@bluematt.me>
Mon, 12 Apr 2021 02:19:21 +0000 (22:19 -0400)
committerMatt Corallo <git@bluematt.me>
Mon, 12 Apr 2021 02:40:36 +0000 (22:40 -0400)
c-bindings-gen/src/main.rs

index 06050c5c8e8b84d31c89460c81e5a3f5d2bc19de..3cf9f55ba4a98c85ddcc11c8350f89fe96641769 100644 (file)
@@ -837,12 +837,12 @@ fn writeln_impl<W: std::io::Write>(w: &mut W, i: &syn::ItemImpl, types: &mut Typ
                                                                        if let syn::Type::Reference(r) = &**rtype {
                                                                                write!(w, "\n\t\t{}{}: ", $indent, $m.sig.ident).unwrap();
                                                                                types.write_empty_rust_val(Some(&gen_types), w, &*r.elem);
-                                                                               writeln!(w, ",\n{}\t\tset_{}: Some({}_{}_set_{}),", $indent, $m.sig.ident, ident, trait_obj.ident, $m.sig.ident).unwrap();
+                                                                               writeln!(w, ",\n{}\t\tset_{}: Some({}_{}_set_{}),", $indent, $m.sig.ident, ident, $trait.ident, $m.sig.ident).unwrap();
                                                                                printed = true;
                                                                        }
                                                                }
                                                                if !printed {
-                                                                       write!(w, "{}\t\t{}: {}_{}_{},\n", $indent, $m.sig.ident, ident, trait_obj.ident, $m.sig.ident).unwrap();
+                                                                       write!(w, "{}\t\t{}: {}_{}_{},\n", $indent, $m.sig.ident, ident, $trait.ident, $m.sig.ident).unwrap();
                                                                }
                                                        }
                                                }
@@ -902,7 +902,7 @@ fn writeln_impl<W: std::io::Write>(w: &mut W, i: &syn::ItemImpl, types: &mut Typ
                                                                if let syn::ReturnType::Type(_, _) = &$m.sig.output {
                                                                        writeln!(w, "#[must_use]").unwrap();
                                                                }
-                                                               write!(w, "extern \"C\" fn {}_{}_{}(", ident, trait_obj.ident, $m.sig.ident).unwrap();
+                                                               write!(w, "extern \"C\" fn {}_{}_{}(", ident, $trait.ident, $m.sig.ident).unwrap();
                                                                gen_types.push_ctx();
                                                                assert!(gen_types.learn_generics(&$m.sig.generics, types));
                                                                write_method_params(w, &$m.sig, "c_void", types, Some(&gen_types), true, true);
@@ -943,13 +943,13 @@ fn writeln_impl<W: std::io::Write>(w: &mut W, i: &syn::ItemImpl, types: &mut Typ
                                                                if let syn::ReturnType::Type(_, rtype) = &$m.sig.output {
                                                                        if let syn::Type::Reference(r) = &**rtype {
                                                                                assert_eq!($m.sig.inputs.len(), 1); // Must only take self
-                                                                               writeln!(w, "extern \"C\" fn {}_{}_set_{}(trait_self_arg: &{}) {{", ident, trait_obj.ident, $m.sig.ident, trait_obj.ident).unwrap();
+                                                                               writeln!(w, "extern \"C\" fn {}_{}_set_{}(trait_self_arg: &{}) {{", ident, $trait.ident, $m.sig.ident, $trait.ident).unwrap();
                                                                                writeln!(w, "\t// This is a bit race-y in the general case, but for our specific use-cases today, we're safe").unwrap();
                                                                                writeln!(w, "\t// Specifically, we must ensure that the first time we're called it can never be in parallel").unwrap();
                                                                                write!(w, "\tif ").unwrap();
                                                                                types.write_empty_rust_val_check(Some(&gen_types), w, &*r.elem, &format!("trait_self_arg.{}", $m.sig.ident));
                                                                                writeln!(w, " {{").unwrap();
-                                                                               writeln!(w, "\t\tunsafe {{ &mut *(trait_self_arg as *const {}  as *mut {}) }}.{} = {}_{}_{}(trait_self_arg.this_arg);", trait_obj.ident, trait_obj.ident, $m.sig.ident, ident, trait_obj.ident, $m.sig.ident).unwrap();
+                                                                               writeln!(w, "\t\tunsafe {{ &mut *(trait_self_arg as *const {}  as *mut {}) }}.{} = {}_{}_{}(trait_self_arg.this_arg);", $trait.ident, $trait.ident, $m.sig.ident, ident, $trait.ident, $m.sig.ident).unwrap();
                                                                                writeln!(w, "\t}}").unwrap();
                                                                                writeln!(w, "}}").unwrap();
                                                                        }