From 7795c5f5205195a3163a3e8482251ffda05584e7 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Wed, 1 Feb 2023 00:52:43 +0100 Subject: [PATCH] icrate: Re-add out-parameters --- crates/header-translator/src/rust_type.rs | 42 +++++++++++------------ crates/icrate/CHANGELOG.md | 1 + crates/icrate/src/generated | 2 +- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/crates/header-translator/src/rust_type.rs b/crates/header-translator/src/rust_type.rs index 9a3281a70..d9d52b965 100644 --- a/crates/header-translator/src/rust_type.rs +++ b/crates/header-translator/src/rust_type.rs @@ -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>") - // }; - // 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>") + }; + 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}") diff --git a/crates/icrate/CHANGELOG.md b/crates/icrate/CHANGELOG.md index ecfcbb035..f2eaad139 100644 --- a/crates/icrate/CHANGELOG.md +++ b/crates/icrate/CHANGELOG.md @@ -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 diff --git a/crates/icrate/src/generated b/crates/icrate/src/generated index 975605f98..d59e0a6b8 160000 --- a/crates/icrate/src/generated +++ b/crates/icrate/src/generated @@ -1 +1 @@ -Subproject commit 975605f9801e4441425a86c3e525ac8717dc50ff +Subproject commit d59e0a6b88addce7aa0997b2f389b1d10e657449