Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix wrong implmentation in opaque decision #19

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix wrong implmentation
  • Loading branch information
spinpx committed Feb 22, 2024
commit 62d7249630f266b9d8b6b14dfd341b43344ae59c
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