Skip to content

Commit

Permalink
sys: Add functions marked with OBJC_ARC_UNAVAILABLE
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Sep 4, 2021
1 parent c829698 commit 9c8738c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
4 changes: 3 additions & 1 deletion objc/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ use std::os::raw::c_uint;
use crate::Encode;

use objc_sys;
#[allow(deprecated)]
pub use objc_sys::object_dispose;
pub use objc_sys::{
class_addIvar, class_addMethod, class_addProtocol, class_conformsToProtocol,
class_copyIvarList, class_copyMethodList, class_copyProtocolList, class_createInstance,
Expand All @@ -25,7 +27,7 @@ pub use objc_sys::{
objc_autoreleasePoolPop, objc_autoreleasePoolPush, objc_copyClassList, objc_copyProtocolList,
objc_copyWeak, objc_destroyWeak, objc_disposeClassPair, objc_getClass, objc_getClassList,
objc_getProtocol, objc_initWeak, objc_loadWeakRetained, objc_registerClassPair,
objc_registerProtocol, objc_release, objc_retain, object_dispose, object_getClass,
objc_registerProtocol, objc_release, objc_retain, object_getClass,
protocol_addMethodDescription, protocol_addProtocol, protocol_conformsToProtocol,
protocol_copyProtocolList, protocol_getName, protocol_isEqual, sel_getName, sel_registerName,
};
Expand Down
1 change: 1 addition & 0 deletions objc/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ impl DerefMut for CustomObject {
impl Drop for CustomObject {
fn drop(&mut self) {
unsafe {
#[allow(deprecated)]
runtime::object_dispose(self.obj as _);
}
}
Expand Down
4 changes: 1 addition & 3 deletions objc_sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,4 @@ pub use various::*;
type OpaqueData = PhantomData<(UnsafeCell<*const ()>, PhantomPinned)>;

#[link(name = "objc", kind = "dylib")]
extern "C" {
pub fn object_dispose(obj: *mut objc_object) -> *mut objc_object;
}
extern "C" {}
29 changes: 29 additions & 0 deletions objc_sys/src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,33 @@ extern "C" {

pub fn object_setClass(obj: *mut objc_object, cls: *const objc_class) -> *const objc_class;
pub fn object_setIvar(obj: *mut objc_object, ivar: *const objc_ivar, value: *mut objc_object);

#[deprecated = "Not needed since ARC"]
pub fn object_copy(obj: *const objc_object, size: usize) -> *mut objc_object;
#[deprecated = "Not needed since ARC"]
pub fn object_dispose(obj: *mut objc_object) -> *mut objc_object;
#[deprecated = "Not needed since ARC"]
pub fn object_setInstanceVariable(
obj: *mut objc_object,
name: *const c_char,
value: *mut c_void,
) -> *const objc_ivar;
#[deprecated = "Not needed since ARC"]
pub fn object_setInstanceVariableWithStrongDefault(
obj: *mut objc_object,
name: *const c_char,
value: *mut c_void,
) -> *const objc_ivar;
#[deprecated = "Not needed since ARC"]
pub fn object_getInstanceVariable(
obj: *const objc_object,
name: *const c_char,
out_value: *mut *const c_void,
) -> *const objc_ivar;
#[deprecated = "Not needed since ARC"]
pub fn objc_getFutureClass(name: *const c_char) -> *const objc_class;
#[deprecated = "Not needed since ARC"]
pub fn objc_constructInstance(cls: *const objc_class, bytes: *mut c_void) -> *mut objc_object;
#[deprecated = "Not needed since ARC"]
pub fn objc_destructInstance(obj: *mut objc_object) -> *mut c_void;
}

0 comments on commit 9c8738c

Please sign in to comment.