]> git.bitcoin.ninja Git - rust-lightning/commitdiff
[bindings] Resolve type aliases mapped as opaque types
authorMatt Corallo <git@bluematt.me>
Thu, 11 Feb 2021 16:39:21 +0000 (11:39 -0500)
committerMatt Corallo <git@bluematt.me>
Thu, 18 Feb 2021 17:28:25 +0000 (12:28 -0500)
We already map type aliases which alias private types as opaque,
but we don't resolve them like we would any other opaque type,
preventing conversion printing or type use.

c-bindings-gen/src/types.rs

index 4f5e4612c614eb04a17d791c0d60cabace742d09..ad9cd0497f9f5b4f147f9560ac7a95d7051e0c11 100644 (file)
@@ -383,6 +383,21 @@ impl<'mod_lifetime, 'crate_lft: 'mod_lifetime> ImportResolver<'mod_lifetime, 'cr
                                                }
                                        }
                                },
+                               syn::Item::Type(t) if export_status(&t.attrs) == ExportStatus::Export => {
+                                       if let syn::Visibility::Public(_) = t.vis {
+                                               let mut process_alias = true;
+                                               for tok in t.generics.params.iter() {
+                                                       if let syn::GenericParam::Lifetime(_) = tok {}
+                                                       else { process_alias = false; }
+                                               }
+                                               if process_alias {
+                                                       match &*t.ty {
+                                                               syn::Type::Path(_) => { declared.insert(t.ident.clone(), DeclType::StructImported); },
+                                                               _ => {},
+                                                       }
+                                               }
+                                       }
+                               },
                                syn::Item::Enum(e) => {
                                        if let syn::Visibility::Public(_) = e.vis {
                                                match export_status(&e.attrs) {