X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=c-bindings-gen%2Fsrc%2Fmain.rs;h=b08f2348002a1e9f1b9671d493b730756a210e48;hb=e5bc76faef879b3fc059263e445b03e6a9435bb9;hp=8bbbdf03765579e5636c49aa3dfd9e937cee8768;hpb=4e514def04a4aabea8261173311e6c747d4bd133;p=ldk-c-bindings diff --git a/c-bindings-gen/src/main.rs b/c-bindings-gen/src/main.rs index 8bbbdf0..b08f234 100644 --- a/c-bindings-gen/src/main.rs +++ b/c-bindings-gen/src/main.rs @@ -280,10 +280,9 @@ fn writeln_trait<'a, 'b, W: std::io::Write>(w: &mut W, t: &'a syn::ItemTrait, ty writeln!(w, "\tpub set_{}: Option,", m.sig.ident, trait_name).unwrap(); generated_fields.push((format!("set_{}", m.sig.ident), true)); // Note that cbindgen will now generate - // typedef struct Thing {..., set_thing: (const Thing*), ...} Thing; + // typedef struct Thing {..., set_thing: (const struct Thing*), ...} Thing; // which does not compile since Thing is not defined before it is used. writeln!(extra_headers, "struct LDK{};", trait_name).unwrap(); - writeln!(extra_headers, "typedef struct LDK{} LDK{};", trait_name, trait_name).unwrap(); continue; } // Sadly, this currently doesn't do what we want, but it should be easy to get @@ -317,7 +316,6 @@ fn writeln_trait<'a, 'b, W: std::io::Write>(w: &mut W, t: &'a syn::ItemTrait, ty ("std::cmp::Eq", _)|("core::cmp::Eq", _) => { writeln!(w, "\t/// Checks if two objects are equal given this object's this_arg pointer and another object.").unwrap(); writeln!(w, "\tpub eq: extern \"C\" fn (this_arg: *const c_void, other_arg: &{}) -> bool,", trait_name).unwrap(); - writeln!(extra_headers, "typedef struct LDK{} LDK{};", trait_name, trait_name).unwrap(); generated_fields.push(("eq".to_owned(), true)); }, ("std::hash::Hash", _)|("core::hash::Hash", _) => { @@ -429,7 +427,9 @@ fn writeln_trait<'a, 'b, W: std::io::Write>(w: &mut W, t: &'a syn::ItemTrait, ty } write_method_var_decl_body(w, &m.sig, "\t", $type_resolver, Some(&meth_gen_types), true); write!(w, "(self{}.{})(", $impl_accessor, m.sig.ident).unwrap(); - write_method_call_params(w, &m.sig, "\t", $type_resolver, Some(&meth_gen_types), "", true); + let mut args = Vec::new(); + write_method_call_params(&mut args, &m.sig, "\t", $type_resolver, Some(&meth_gen_types), "", true); + w.write_all(String::from_utf8(args).unwrap().replace("self", &format!("self{}", $impl_accessor)).as_bytes()).unwrap(); writeln!(w, "\n\t}}").unwrap(); },