diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/codegen/mod.rs | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 5660b126..a8a7b076 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -4191,9 +4191,19 @@ impl CodeGenerator for Function { fn objc_method_codegen( ctx: &BindgenContext, method: &ObjCMethod, + methods: &mut Vec<proc_macro2::TokenStream>, class_name: Option<&str>, + rust_class_name: &str, prefix: &str, -) -> proc_macro2::TokenStream { +) { + // This would ideally resolve the method into an Item, and use + // Item::process_before_codegen; however, ObjC methods are not currently + // made into function items. + let name = format!("{}::{}{}", rust_class_name, prefix, method.rust_name()); + if ctx.options().blocklisted_items.matches(name) { + return; + } + let signature = method.signature(); let fn_args = utils::fnsig_arguments(ctx, signature); let fn_ret = utils::fnsig_return_ty(ctx, signature); @@ -4229,11 +4239,11 @@ fn objc_method_codegen( let method_name = ctx.rust_ident(format!("{}{}", prefix, method.rust_name())); - quote! { + methods.push(quote! { unsafe fn #method_name #sig where <Self as std::ops::Deref>::Target: objc::Message + Sized { #body } - } + }); } impl CodeGenerator for ObjCInterface { @@ -4249,10 +4259,17 @@ impl CodeGenerator for ObjCInterface { debug_assert!(item.is_enabled_for_codegen(ctx)); let mut impl_items = vec![]; + let rust_class_name = item.path_for_allowlisting(ctx)[1..].join("::"); for method in self.methods() { - let impl_item = objc_method_codegen(ctx, method, None, ""); - impl_items.push(impl_item); + objc_method_codegen( + ctx, + method, + &mut impl_items, + None, + &rust_class_name, + "", + ); } for class_method in self.class_methods() { @@ -4262,13 +4279,14 @@ impl CodeGenerator for ObjCInterface { .map(|m| m.rust_name()) .any(|x| x == class_method.rust_name()); let prefix = if ambiquity { "class_" } else { "" }; - let impl_item = objc_method_codegen( + objc_method_codegen( ctx, class_method, + &mut impl_items, Some(self.name()), + &rust_class_name, prefix, ); - impl_items.push(impl_item); } let trait_name = ctx.rust_ident(self.rust_name()); |