Skip to content

Commit

Permalink
icrate: Re-add out-parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Feb 1, 2023
1 parent 2306144 commit e13a6f6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
42 changes: 21 additions & 21 deletions crates/header-translator/src/rust_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1722,27 +1722,27 @@ impl fmt::Display for Ty {
is_const: false,
pointee,
} => match &**pointee {
// TODO: Re-enable once we can support it
// Inner::Id {
// ty,
// is_const: false,
// lifetime: Lifetime::Autoreleasing,
// nullability: inner_nullability,
// } if self.kind == TyKind::MethodArgument => {
// let tokens = if *inner_nullability == Nullability::NonNull {
// format!("Id<{ty}, Shared>")
// } else {
// format!("Option<Id<{ty}, Shared>>")
// };
// if *nullability == Nullability::NonNull {
// write!(f, "&mut {tokens}")
// } else {
// write!(f, "Option<&mut {tokens}>")
// }
// }
// Inner::Id { .. } => {
// unreachable!("there should be no id with other values: {self:?}")
// }
Inner::Id {
ty,
// Don't care about the const-ness of the id.
is_const: _,
lifetime: Lifetime::Autoreleasing,
nullability: inner_nullability,
} if self.kind == TyKind::MethodArgument => {
let tokens = if *inner_nullability == Nullability::NonNull {
format!("Id<{ty}, Shared>")
} else {
format!("Option<Id<{ty}, Shared>>")
};
if *nullability == Nullability::NonNull {
write!(f, "&mut {tokens}")
} else {
write!(f, "Option<&mut {tokens}>")
}
}
Inner::Id { .. } if self.kind == TyKind::MethodArgument => {
unreachable!("invalid out-pointer id {self:?}")
}
block @ Inner::Block { .. } => {
if *nullability == Nullability::NonNull {
write!(f, "&{block}")
Expand Down
1 change: 1 addition & 0 deletions crates/icrate/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
* Removed a few instances of `TodoProtocols`.
* Fixed type-encoding of a few `struct`s.
* Fixed `NSProxy` trait methods.
* **BREAKING**: Fixed type in methods that worked with out-parameters.


## icrate 0.0.1 - 2022-12-24
Expand Down
2 changes: 1 addition & 1 deletion crates/icrate/src/generated

0 comments on commit e13a6f6

Please sign in to comment.