objc2_foundation/generated/
NSObject.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9extern_protocol!(
10 pub unsafe trait NSCoding {
12 #[cfg(feature = "NSCoder")]
13 #[unsafe(method(encodeWithCoder:))]
17 #[unsafe(method_family = none)]
18 unsafe fn encodeWithCoder(&self, coder: &NSCoder);
19
20 #[cfg(feature = "NSCoder")]
21 #[unsafe(method(initWithCoder:))]
25 #[unsafe(method_family = init)]
26 unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Option<Retained<Self>>;
27 }
28);
29
30extern_protocol!(
31 pub unsafe trait NSSecureCoding: NSCoding {
33 #[unsafe(method(supportsSecureCoding))]
34 #[unsafe(method_family = none)]
35 fn supportsSecureCoding() -> bool;
36 }
37);
38
39mod private_NSObjectNSCoderMethods {
40 pub trait Sealed {}
41}
42
43#[doc(alias = "NSCoderMethods")]
47pub unsafe trait NSObjectNSCoderMethods:
48 ClassType + Sized + private_NSObjectNSCoderMethods::Sealed
49{
50 extern_methods!(
51 #[unsafe(method(version))]
52 #[unsafe(method_family = none)]
53 fn version() -> NSInteger;
54
55 #[unsafe(method(setVersion:))]
56 #[unsafe(method_family = none)]
57 unsafe fn setVersion(a_version: NSInteger);
58
59 #[unsafe(method(classForCoder))]
60 #[unsafe(method_family = none)]
61 fn classForCoder(&self) -> &'static AnyClass;
62
63 #[cfg(feature = "NSCoder")]
64 #[unsafe(method(replacementObjectForCoder:))]
68 #[unsafe(method_family = none)]
69 unsafe fn replacementObjectForCoder(&self, coder: &NSCoder) -> Option<Retained<AnyObject>>;
70 );
71}
72
73impl private_NSObjectNSCoderMethods::Sealed for NSObject {}
74unsafe impl NSObjectNSCoderMethods for NSObject {}
75
76extern_protocol!(
77 pub unsafe trait NSDiscardableContent {
81 #[unsafe(method(beginContentAccess))]
82 #[unsafe(method_family = none)]
83 fn beginContentAccess(&self) -> bool;
84
85 #[unsafe(method(endContentAccess))]
86 #[unsafe(method_family = none)]
87 fn endContentAccess(&self);
88
89 #[unsafe(method(discardContentIfPossible))]
90 #[unsafe(method_family = none)]
91 fn discardContentIfPossible(&self);
92
93 #[unsafe(method(isContentDiscarded))]
94 #[unsafe(method_family = none)]
95 fn isContentDiscarded(&self) -> bool;
96 }
97);
98
99mod private_NSObjectNSDiscardableContentProxy {
100 pub trait Sealed {}
101}
102
103#[doc(alias = "NSDiscardableContentProxy")]
105pub unsafe trait NSObjectNSDiscardableContentProxy:
106 ClassType + Sized + private_NSObjectNSDiscardableContentProxy::Sealed
107{
108 extern_methods!(
109 #[unsafe(method(autoContentAccessingProxy))]
110 #[unsafe(method_family = none)]
111 fn autoContentAccessingProxy(&self) -> Retained<AnyObject>;
112 );
113}
114
115impl private_NSObjectNSDiscardableContentProxy::Sealed for NSObject {}
116unsafe impl NSObjectNSDiscardableContentProxy for NSObject {}
117
118#[cfg(feature = "NSZone")]
125#[inline]
126pub unsafe extern "C-unwind" fn NSAllocateObject(
127 a_class: &AnyClass,
128 extra_bytes: NSUInteger,
129 zone: *mut NSZone,
130) -> Retained<AnyObject> {
131 extern "C-unwind" {
132 fn NSAllocateObject(
133 a_class: &AnyClass,
134 extra_bytes: NSUInteger,
135 zone: *mut NSZone,
136 ) -> *mut AnyObject;
137 }
138 let ret = unsafe { NSAllocateObject(a_class, extra_bytes, zone) };
139 unsafe { Retained::retain_autoreleased(ret) }
140 .expect("function was marked as returning non-null, but actually returned NULL")
141}
142
143extern "C-unwind" {
144 pub fn NSDeallocateObject(object: &AnyObject);
148}
149
150#[cfg(feature = "NSZone")]
155#[deprecated = "Not supported"]
156#[inline]
157pub unsafe extern "C-unwind" fn NSCopyObject(
158 object: &AnyObject,
159 extra_bytes: NSUInteger,
160 zone: *mut NSZone,
161) -> Retained<AnyObject> {
162 extern "C-unwind" {
163 fn NSCopyObject(
164 object: &AnyObject,
165 extra_bytes: NSUInteger,
166 zone: *mut NSZone,
167 ) -> *mut AnyObject;
168 }
169 let ret = unsafe { NSCopyObject(object, extra_bytes, zone) };
170 unsafe { Retained::from_raw(ret) }
171 .expect("function was marked as returning non-null, but actually returned NULL")
172}
173
174#[cfg(feature = "NSZone")]
179#[inline]
180pub unsafe extern "C-unwind" fn NSShouldRetainWithZone(
181 an_object: &AnyObject,
182 requested_zone: *mut NSZone,
183) -> bool {
184 extern "C-unwind" {
185 fn NSShouldRetainWithZone(an_object: &AnyObject, requested_zone: *mut NSZone) -> Bool;
186 }
187 unsafe { NSShouldRetainWithZone(an_object, requested_zone) }.as_bool()
188}
189
190extern "C-unwind" {
191 pub fn NSIncrementExtraRefCount(object: &AnyObject);
195}
196
197#[inline]
201pub unsafe extern "C-unwind" fn NSDecrementExtraRefCountWasZero(object: &AnyObject) -> bool {
202 extern "C-unwind" {
203 fn NSDecrementExtraRefCountWasZero(object: &AnyObject) -> Bool;
204 }
205 unsafe { NSDecrementExtraRefCountWasZero(object) }.as_bool()
206}
207
208extern "C-unwind" {
209 pub fn NSExtraRefCount(object: &AnyObject) -> NSUInteger;
213}