@@ -97,6 +97,7 @@ use crate::Message;
97
97
#[ repr( transparent) ]
98
98
// TODO: Figure out if `Message` bound on `T` would be better here?
99
99
// TODO: Add `?Sized + ptr::Thin` bound on `T` to allow for extern types
100
+ // TODO: Consider changing the name of Id -> Retain
100
101
pub struct Id < T , O : Ownership > {
101
102
/// A pointer to the contained object. The pointer is always retained.
102
103
///
@@ -219,6 +220,12 @@ impl<T: Message, O: Ownership> Id<T, O> {
219
220
220
221
#[ cfg_attr( debug_assertions, inline) ]
221
222
fn autorelease_inner ( self ) -> * mut T {
223
+ // Note that this (and the actual `autorelease`) is not an associated
224
+ // function. This breaks the guideline that smart pointers shouldn't
225
+ // add inherent methods, but since autoreleasing only works on already
226
+ // retained objects it is hard to imagine a case where the inner type
227
+ // has a method with the same name.
228
+
222
229
let ptr = ManuallyDrop :: new ( self ) . ptr . as_ptr ( ) as * mut objc2_sys:: objc_object ;
223
230
// SAFETY: The `ptr` is guaranteed to be valid and have at least one
224
231
// retain count.
@@ -228,8 +235,24 @@ impl<T: Message, O: Ownership> Id<T, O> {
228
235
debug_assert_eq ! ( res, ptr, "objc_autorelease did not return the same pointer" ) ;
229
236
res as * mut T
230
237
}
238
+
239
+ // TODO: objc_retainAutoreleasedReturnValue
240
+ // TODO: objc_autoreleaseReturnValue
241
+ // TODO: objc_retainAutorelease
242
+ // TODO: objc_retainAutoreleaseReturnValue
243
+ // TODO: objc_autoreleaseReturnValue
244
+ // TODO: objc_autoreleaseReturnValue
231
245
}
232
246
247
+ // TODO: Consider something like this
248
+ // #[cfg(block)]
249
+ // impl<T: Block, O> Id<T, O> {
250
+ // #[doc(alias = "objc_retainBlock")]
251
+ // pub unsafe fn retain_block(block: NonNull<T>) -> Self {
252
+ // todo!()
253
+ // }
254
+ // }
255
+
233
256
impl < T : Message > Id < T , Owned > {
234
257
/// Autoreleases the owned [`Id`], returning a mutable reference bound to
235
258
/// the pool.
0 commit comments