[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>
Fri, 15 Jan 2021 00:49:14 +0000 (19:49 -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 a077d311b20afe647f669834686612e867a390d9..57b51edf0ade2a2732e1612bcd5f1021fc2755df 100644 (file)
@@ -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(_) => {},