Skip to content

Commit

Permalink
Merge pull request #19 from spinpx/fix_opaque
Browse files Browse the repository at this point in the history
fix wrong implmentation in opaque decision
  • Loading branch information
spinpx committed Feb 22, 2024
2 parents b299523 + 62d7249 commit 8ce2a33
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 5 additions & 1 deletion hopper-derive-impl/src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<'a> FieldExt<'a> {
}

pub fn is_opaque(&self) -> bool {
self.named && ( self.ident.to_string().starts_with('_') || self.ident.to_string().starts_with("_bindgen_opaque"))
self.named && self.ident.to_string().starts_with("_bindgen_opaque")
}
}

Expand Down Expand Up @@ -269,6 +269,10 @@ pub fn struct_object_mutate_op_body(fields: &[FieldExt], unit: bool) -> TokenStr
}

pub fn struct_object_opaque_body(fields: &[FieldExt]) -> TokenStream {
let is_opaque = fields.iter().any(|f| f.is_opaque());
if is_opaque {
return my_quote!(true);
}
let mut check_opaque = fields.iter().map(|f| {
let ty = f.ty;
my_quote!(<#ty>::is_opaque())
Expand Down
1 change: 0 additions & 1 deletion hopper-derive-impl/src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pub fn object_trait_for_struct(
let mutate_op_body = field::struct_object_mutate_op_body(&fields, unit);
let ptr_body = field::struct_object_ptr_body(&fields, unit);
let layout_body = field::struct_object_layout_body(&fields, unit);
// let is_opaque = fields.iter().any(|f| f.is_opaque());
let is_opaque = field::struct_object_opaque_body(&fields);

let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
Expand Down

0 comments on commit 8ce2a33

Please sign in to comment.