projects
/
rust-lightning
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove block_connected de-duplication logic
[rust-lightning]
/
c-bindings-gen
/
src
/
types.rs
diff --git
a/c-bindings-gen/src/types.rs
b/c-bindings-gen/src/types.rs
index 2b195e2dcb957d630bf4478e3204fc5d76a895c5..7fc7e4cd905cff8d1cc66cd39aba44988b38c535 100644
(file)
--- a/
c-bindings-gen/src/types.rs
+++ b/
c-bindings-gen/src/types.rs
@@
-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() {
/// 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,
}
}
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
}
}
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" {
/// 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!(); }
}
} else { unimplemented!(); }
}
@@
-963,7
+967,7
@@
impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
").into() }"))
},
"Vec" if !is_ref => {
").into() }"))
},
"Vec" if !is_ref => {
- Some(("Vec::new(); for item in ", vec![(format!(".drain(..) {{ local_{}.push(", var_name), "item".to_string())], "); }"))
+ Some(("Vec::new(); for
mut
item in ", vec![(format!(".drain(..) {{ local_{}.push(", var_name), "item".to_string())], "); }"))
},
"Slice" => {
Some(("Vec::new(); for item in ", vec![(format!(".iter() {{ local_{}.push(", var_name), "**item".to_string())], "); }"))
},
"Slice" => {
Some(("Vec::new(); for item in ", vec![(format!(".iter() {{ local_{}.push(", var_name), "**item".to_string())], "); }"))
@@
-1004,8
+1008,8
@@
impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
match full_path {
"Result" if !is_ref => {
Some(("match ",
match full_path {
"Result" if !is_ref => {
Some(("match ",
- vec![(".result_ok { true => Ok(".to_string(), format!("(*unsafe {{ Box::from_raw(<*mut _>::take_ptr(&mut {}.contents.result)) }})", var_
name
)),
- ("), false => Err(".to_string(), format!("(*unsafe {{ Box::from_raw(<*mut _>::take_ptr(&mut {}.contents.err)) }})", var_
name
))],
+ vec![(".result_ok { true => Ok(".to_string(), format!("(*unsafe {{ Box::from_raw(<*mut _>::take_ptr(&mut {}.contents.result)) }})", var_
access
)),
+ ("), false => Err(".to_string(), format!("(*unsafe {{ Box::from_raw(<*mut _>::take_ptr(&mut {}.contents.err)) }})", var_
access
))],
")}"))
},
"Vec"|"Slice" if !is_ref => {
")}"))
},
"Vec"|"Slice" if !is_ref => {
@@
-1018,9
+1022,9
@@
impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
if let Some(syn::Type::Path(p)) = single_contained {
if self.c_type_has_inner_from_path(&self.resolve_path(&p.path, generics)) {
if is_ref {
if let Some(syn::Type::Path(p)) = single_contained {
if self.c_type_has_inner_from_path(&self.resolve_path(&p.path, generics)) {
if is_ref {
- return Some(("if ", vec![(".inner.is_null() { None } else { Some((*".to_string(), format!("{}", var_
name
))], ").clone()) }"))
+ return Some(("if ", vec![(".inner.is_null() { None } else { Some((*".to_string(), format!("{}", var_
access
))], ").clone()) }"))
} else {
} else {
- return Some(("if ", vec![(".inner.is_null() { None } else { Some(".to_string(), format!("{}", var_
name
))], ") }"));
+ return Some(("if ", vec![(".inner.is_null() { None } else { Some(".to_string(), format!("{}", var_
access
))], ") }"));
}
}
}
}
}
}