summaryrefslogtreecommitdiff
path: root/src/codegen/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/codegen/mod.rs')
-rw-r--r--src/codegen/mod.rs37
1 files changed, 28 insertions, 9 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index 8eb7b013..a8a7b076 100644
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -3,6 +3,7 @@ mod error;
mod helpers;
mod impl_debug;
mod impl_partialeq;
+mod postprocessing;
pub mod struct_layout;
#[cfg(test)]
@@ -4190,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);
@@ -4228,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 {
@@ -4248,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() {
@@ -4261,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());
@@ -4439,7 +4458,7 @@ impl CodeGenerator for ObjCInterface {
pub(crate) fn codegen(
context: BindgenContext,
-) -> (Vec<proc_macro2::TokenStream>, BindgenOptions, Vec<String>) {
+) -> (proc_macro2::TokenStream, BindgenOptions, Vec<String>) {
context.gen(|context| {
let _t = context.timer("codegen");
let counter = Cell::new(0);
@@ -4489,7 +4508,7 @@ pub(crate) fn codegen(
result.push(dynamic_items_tokens);
}
- result.items
+ postprocessing::postprocessing(result.items, context.options())
})
}