Skip to content

Commit baff6f9

Browse files
committed
Add a few more TODOs and docs to Id
1 parent f6b341e commit baff6f9

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

objc2/src/rc/id.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ use crate::Message;
9797
#[repr(transparent)]
9898
// TODO: Figure out if `Message` bound on `T` would be better here?
9999
// TODO: Add `?Sized + ptr::Thin` bound on `T` to allow for extern types
100+
// TODO: Consider changing the name of Id -> Retain
100101
pub struct Id<T, O: Ownership> {
101102
/// A pointer to the contained object. The pointer is always retained.
102103
///
@@ -219,6 +220,12 @@ impl<T: Message, O: Ownership> Id<T, O> {
219220

220221
#[cfg_attr(debug_assertions, inline)]
221222
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+
222229
let ptr = ManuallyDrop::new(self).ptr.as_ptr() as *mut objc2_sys::objc_object;
223230
// SAFETY: The `ptr` is guaranteed to be valid and have at least one
224231
// retain count.
@@ -228,8 +235,24 @@ impl<T: Message, O: Ownership> Id<T, O> {
228235
debug_assert_eq!(res, ptr, "objc_autorelease did not return the same pointer");
229236
res as *mut T
230237
}
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
231245
}
232246

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+
233256
impl<T: Message> Id<T, Owned> {
234257
/// Autoreleases the owned [`Id`], returning a mutable reference bound to
235258
/// the pool.

0 commit comments

Comments
 (0)