@@ -4191,9 +4191,19 @@ impl CodeGenerator for Function {
4191
4191
fn objc_method_codegen (
4192
4192
ctx : & BindgenContext ,
4193
4193
method : & ObjCMethod ,
4194
+ methods : & mut Vec < proc_macro2:: TokenStream > ,
4194
4195
class_name : Option < & str > ,
4196
+ rust_class_name : & str ,
4195
4197
prefix : & str ,
4196
- ) -> proc_macro2:: TokenStream {
4198
+ ) {
4199
+ // This would ideally resolve the method into an Item, and use
4200
+ // Item::process_before_codegen; however, ObjC methods are not currently
4201
+ // made into function items.
4202
+ let name = format ! ( "{}::{}{}" , rust_class_name, prefix, method. rust_name( ) ) ;
4203
+ if ctx. options ( ) . blocklisted_items . matches ( name) {
4204
+ return ;
4205
+ }
4206
+
4197
4207
let signature = method. signature ( ) ;
4198
4208
let fn_args = utils:: fnsig_arguments ( ctx, signature) ;
4199
4209
let fn_ret = utils:: fnsig_return_ty ( ctx, signature) ;
@@ -4229,11 +4239,11 @@ fn objc_method_codegen(
4229
4239
let method_name =
4230
4240
ctx. rust_ident ( format ! ( "{}{}" , prefix, method. rust_name( ) ) ) ;
4231
4241
4232
- quote ! {
4242
+ methods . push ( quote ! {
4233
4243
unsafe fn #method_name #sig where <Self as std:: ops:: Deref >:: Target : objc:: Message + Sized {
4234
4244
#body
4235
4245
}
4236
- }
4246
+ } ) ;
4237
4247
}
4238
4248
4239
4249
impl CodeGenerator for ObjCInterface {
@@ -4249,10 +4259,17 @@ impl CodeGenerator for ObjCInterface {
4249
4259
debug_assert ! ( item. is_enabled_for_codegen( ctx) ) ;
4250
4260
4251
4261
let mut impl_items = vec ! [ ] ;
4262
+ let rust_class_name = item. path_for_allowlisting ( ctx) [ 1 ..] . join ( "::" ) ;
4252
4263
4253
4264
for method in self . methods ( ) {
4254
- let impl_item = objc_method_codegen ( ctx, method, None , "" ) ;
4255
- impl_items. push ( impl_item) ;
4265
+ objc_method_codegen (
4266
+ ctx,
4267
+ method,
4268
+ & mut impl_items,
4269
+ None ,
4270
+ & rust_class_name,
4271
+ "" ,
4272
+ ) ;
4256
4273
}
4257
4274
4258
4275
for class_method in self . class_methods ( ) {
@@ -4262,13 +4279,14 @@ impl CodeGenerator for ObjCInterface {
4262
4279
. map ( |m| m. rust_name ( ) )
4263
4280
. any ( |x| x == class_method. rust_name ( ) ) ;
4264
4281
let prefix = if ambiquity { "class_" } else { "" } ;
4265
- let impl_item = objc_method_codegen (
4282
+ objc_method_codegen (
4266
4283
ctx,
4267
4284
class_method,
4285
+ & mut impl_items,
4268
4286
Some ( self . name ( ) ) ,
4287
+ & rust_class_name,
4269
4288
prefix,
4270
4289
) ;
4271
- impl_items. push ( impl_item) ;
4272
4290
}
4273
4291
4274
4292
let trait_name = ctx. rust_ident ( self . rust_name ( ) ) ;
0 commit comments