From: Matt Corallo Date: Wed, 25 Nov 2020 18:20:15 +0000 (-0500) Subject: [bindings] Separate take_ptr and take_inner X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=9e02d0a1e07f3a258ce6e7769a4968e3bb4f423d;p=rust-lightning [bindings] Separate take_ptr and take_inner It is confusing to have two utility methods on different classes of types which do two different, but related, things with the same name. --- diff --git a/c-bindings-gen/src/main.rs b/c-bindings-gen/src/main.rs index 746952e1..f427b506 100644 --- a/c-bindings-gen/src/main.rs +++ b/c-bindings-gen/src/main.rs @@ -454,7 +454,7 @@ fn writeln_opaque(w: &mut W, ident: &syn::Ident, struct_name: writeln!(w, "#[allow(unused)]").unwrap(); writeln!(w, "/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy").unwrap(); writeln!(w, "impl {} {{", struct_name).unwrap(); - writeln!(w, "\tpub(crate) fn take_ptr(mut self) -> *mut native{} {{", struct_name).unwrap(); + writeln!(w, "\tpub(crate) fn take_inner(mut self) -> *mut native{} {{", struct_name).unwrap(); writeln!(w, "\t\tassert!(self.is_owned);").unwrap(); writeln!(w, "\t\tlet ret = self.inner;").unwrap(); writeln!(w, "\t\tself.inner = std::ptr::null_mut();").unwrap(); diff --git a/c-bindings-gen/src/types.rs b/c-bindings-gen/src/types.rs index a077d311..57b51edf 100644 --- a/c-bindings-gen/src/types.rs +++ b/c-bindings-gen/src/types.rs @@ -542,7 +542,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { // List of structs we map (possibly during processing of other files): "ln::features::InitFeatures" if is_ref => Some(".inner) }"), - "ln::features::InitFeatures" if !is_ref => Some(".take_ptr()) }"), + "ln::features::InitFeatures" if !is_ref => Some(".take_inner()) }"), // List of traits we map (possibly during processing of other files): "crate::util::logger::Logger" => Some(""), @@ -1402,7 +1402,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { |w, decl_type, _full_path, is_ref, _is_mut| match decl_type { DeclType::StructImported if is_ref && ptr_for_ref => write!(w, ").inner }}").unwrap(), DeclType::StructImported if is_ref => write!(w, ".inner }}").unwrap(), - DeclType::StructImported if !is_ref => write!(w, ".take_ptr()) }}").unwrap(), + DeclType::StructImported if !is_ref => write!(w, ".take_inner()) }}").unwrap(), DeclType::MirroredEnum if is_ref => write!(w, ".to_native()").unwrap(), DeclType::MirroredEnum => write!(w, ".into_native()").unwrap(), DeclType::Trait(_) => {},