Skip to content

Commit 2ec0185

Browse files
committed
Add stubs for a few extra objc reference counting methods
1 parent fecb2e7 commit 2ec0185

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

src/rc/retained.rs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ impl<T> Retained<T> {
129129
}
130130
}
131131

132+
/// TODO
133+
#[doc(alias = "objc_retainAutoreleasedReturnValue")]
134+
pub unsafe fn retain_autoreleased_return(obj: &T) -> Self {
135+
todo!()
136+
}
137+
132138
/// Autoreleases the retained pointer, meaning that the object is not
133139
/// immediately released, but will be when the innermost / current
134140
/// autorelease pool is drained.
@@ -150,13 +156,46 @@ impl<T> Retained<T> {
150156
ptr
151157
}
152158

153-
#[cfg(test)]
159+
/// TODO
160+
#[doc(alias = "objc_autoreleaseReturnValue")]
161+
pub fn autorelease_return(self) -> *const T {
162+
todo!()
163+
}
164+
165+
/// TODO
166+
///
167+
/// Equivalent to `Retained::retain(&obj).autorelease()`, but slightly
168+
/// more efficient.
169+
#[doc(alias = "objc_retainAutorelease")]
170+
pub unsafe fn retain_and_autorelease(obj: &T) -> *const T {
171+
todo!()
172+
}
173+
174+
/// TODO
175+
///
176+
/// Equivalent to `Retained::retain(&obj).autorelease_return()`, but
177+
/// slightly more efficient.
178+
#[doc(alias = "objc_retainAutoreleaseReturnValue")]
179+
pub unsafe fn retain_and_autorelease_return(obj: &T) -> *const T {
180+
todo!()
181+
}
182+
183+
#[cfg(test)] // TODO
154184
#[doc(alias = "retainCount")]
155185
pub fn retain_count(&self) -> usize {
156186
unsafe { msg_send![self.ptr.as_ptr() as *mut Object, retainCount] }
157187
}
158188
}
159189

190+
// TODO: Consider something like this
191+
// #[cfg(block)]
192+
// impl<T: Block> Retained<T> {
193+
// #[doc(alias = "objc_retainBlock")]
194+
// pub unsafe fn retain_block(block: &T) -> Self {
195+
// todo!()
196+
// }
197+
// }
198+
160199
// TODO: #[may_dangle]
161200
// https://doc.rust-lang.org/nightly/nomicon/dropck.html
162201
impl<T> Drop for Retained<T> {

0 commit comments

Comments
 (0)