[bindings] Separate take_ptr and take_inner
authorMatt Corallo <git@bluematt.me>
Wed, 25 Nov 2020 18:20:15 +0000 (13:20 -0500)
committerMatt Corallo <git@bluematt.me>
Tue, 2 Feb 2021 22:04:31 +0000 (17:04 -0500)
It is confusing to have two utility methods on different classes
of types which do two different, but related, things with the same
name.

c-bindings-gen/src/main.rs
c-bindings-gen/src/types.rs

index 746952e14200da595dcbbe00b663210754396750..f427b5063c5165e90f4a0a92574ac70e1395742f 100644 (file)
@@ -454,7 +454,7 @@ fn writeln_opaque<W: std::io::Write>(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();
index e85729481a39841daf9a6159b3bd51c26e02e818..4e84f1430648bbc6e44f9b1cc33d56b2cf1c3bad 100644 (file)
@@ -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(_) => {},