From: Matt Corallo Date: Wed, 25 Nov 2020 18:20:15 +0000 (-0500) Subject: [bindings] Separate take_ptr and take_inner X-Git-Tag: v0.0.13~38^2~5 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=734c0a6236cdb24abe7b3fbd1d3dd999ee2a4831;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 746952e14..f427b5063 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 e85729481..4e84f1430 100644 --- a/c-bindings-gen/src/types.rs +++ b/c-bindings-gen/src/types.rs @@ -550,7 +550,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(""), @@ -1410,7 +1410,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(_) => {},