Skip to content

Commit 6d75180

Browse files
committed
Properly emit protocol objects with multiple protocols
1 parent 076a745 commit 6d75180

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

crates/header-translator/src/rust_type.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,20 @@ impl fmt::Display for IdType {
367367
}
368368
Self::AnyObject { protocols } => match &**protocols {
369369
[] => write!(f, "AnyObject"),
370-
[id] if id.is_nsobject() => write!(f, "NSObject"),
371-
[id] => write!(f, "ProtocolObject<dyn {}>", id.path()),
372-
// TODO: Handle this better
373-
_ => write!(f, "TodoProtocols"),
370+
protocols => {
371+
write!(f, "ProtocolObject<dyn ")?;
372+
373+
let mut iter = protocols.iter();
374+
let protocol = iter.next().unwrap();
375+
write!(f, "{}", protocol.path())?;
376+
377+
for protocol in iter {
378+
write!(f, " + {}", protocol.path())?;
379+
}
380+
381+
write!(f, ">")?;
382+
Ok(())
383+
}
374384
},
375385
Self::TypeDef { id, .. } => write!(f, "{}", id.path()),
376386
Self::GenericParam { name } => write!(f, "{name}"),

crates/icrate/src/common.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ pub(crate) use block2::Block;
3636
pub(crate) type TodoFunction = *const c_void;
3737
#[cfg(feature = "objective-c")]
3838
pub(crate) type TodoClass = AnyObject;
39-
#[cfg(feature = "objective-c")]
40-
pub(crate) type TodoProtocols = AnyObject;
4139

4240
// MacTypes.h
4341
pub(crate) type Boolean = u8; // unsigned char

crates/icrate/src/generated

0 commit comments

Comments
 (0)