[bindings] Use global context for secp256k1
[rust-lightning] / c-bindings-gen / src / types.rs
index 0c570bff7d5f5f73564d96c1e70374c263884af6..7fc7e4cd905cff8d1cc66cd39aba44988b38c535 100644 (file)
@@ -114,16 +114,20 @@ pub fn assert_simple_bound(bound: &syn::TraitBound) {
 /// type), otherwise it is mapped into a transparent, C-compatible version of itself.
 pub fn is_enum_opaque(e: &syn::ItemEnum) -> bool {
        for var in e.variants.iter() {
-               if let syn::Fields::Unit = var.fields {
-               } else if let syn::Fields::Named(fields) = &var.fields {
+               if let syn::Fields::Named(fields) = &var.fields {
                        for field in fields.named.iter() {
                                match export_status(&field.attrs) {
                                        ExportStatus::Export|ExportStatus::TestOnly => {},
                                        ExportStatus::NoExport => return true,
                                }
                        }
-               } else {
-                       return true;
+               } else if let syn::Fields::Unnamed(fields) = &var.fields {
+                       for field in fields.unnamed.iter() {
+                               match export_status(&field.attrs) {
+                                       ExportStatus::Export|ExportStatus::TestOnly => {},
+                                       ExportStatus::NoExport => return true,
+                               }
+                       }
                }
        }
        false
@@ -583,7 +587,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
        /// Returns true we if can just skip passing this to C entirely
        fn no_arg_path_to_rust(&self, full_path: &str) -> &str {
                if full_path == "bitcoin::secp256k1::Secp256k1" {
-                       "&bitcoin::secp256k1::Secp256k1::new()"
+                       "secp256k1::SECP256K1"
                } else { unimplemented!(); }
        }