@@ -3512,6 +3512,14 @@ impl TryToRustTy for Type {
3512
3512
inner. into_resolver ( ) . through_type_refs ( ) . resolve ( ctx) ;
3513
3513
let inner_ty = inner. expect_type ( ) ;
3514
3514
3515
+ let is_objc_pointer =
3516
+ inner. kind ( ) . as_type ( ) . map_or ( false , |ty| {
3517
+ match ty. kind ( ) {
3518
+ TypeKind :: ObjCInterface ( ..) => true ,
3519
+ _ => false ,
3520
+ }
3521
+ } ) ;
3522
+
3515
3523
// Regardless if we can properly represent the inner type, we
3516
3524
// should always generate a proper pointer here, so use
3517
3525
// infallible conversion of the inner type.
@@ -3520,7 +3528,8 @@ impl TryToRustTy for Type {
3520
3528
3521
3529
// Avoid the first function pointer level, since it's already
3522
3530
// represented in Rust.
3523
- if inner_ty. canonical_type ( ctx) . is_function ( ) {
3531
+ if inner_ty. canonical_type ( ctx) . is_function ( ) || is_objc_pointer
3532
+ {
3524
3533
Ok ( ty)
3525
3534
} else {
3526
3535
Ok ( ty. to_ptr ( is_const) )
@@ -3539,9 +3548,12 @@ impl TryToRustTy for Type {
3539
3548
TypeKind :: ObjCId => Ok ( quote ! {
3540
3549
id
3541
3550
} ) ,
3542
- TypeKind :: ObjCInterface ( ..) => Ok ( quote ! {
3543
- objc:: runtime:: Object
3544
- } ) ,
3551
+ TypeKind :: ObjCInterface ( ref interface) => {
3552
+ let name = ctx. rust_ident ( interface. name ( ) ) ;
3553
+ Ok ( quote ! {
3554
+ #name
3555
+ } )
3556
+ }
3545
3557
ref u @ TypeKind :: UnresolvedTypeRef ( ..) => {
3546
3558
unreachable ! ( "Should have been resolved after parsing {:?}!" , u)
3547
3559
}
@@ -4395,11 +4407,12 @@ mod utils {
4395
4407
TypeKind :: Pointer ( inner) => {
4396
4408
let inner = ctx. resolve_item ( inner) ;
4397
4409
let inner_ty = inner. expect_type ( ) ;
4398
- if let TypeKind :: ObjCInterface ( _ ) =
4410
+ if let TypeKind :: ObjCInterface ( ref interface ) =
4399
4411
* inner_ty. canonical_type ( ctx) . kind ( )
4400
4412
{
4413
+ let name = ctx. rust_ident ( interface. name ( ) ) ;
4401
4414
quote ! {
4402
- id
4415
+ #name
4403
4416
}
4404
4417
} else {
4405
4418
arg_item. to_rust_ty_or_opaque ( ctx, & ( ) )
0 commit comments