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:))]
14 #[unsafe(method_family = none)]
15 unsafe fn encodeWithCoder(&self, coder: &NSCoder);
16
17 #[cfg(feature = "NSCoder")]
18 #[unsafe(method(initWithCoder:))]
19 #[unsafe(method_family = init)]
20 unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Option<Retained<Self>>;
21 }
22);
23
24extern_protocol!(
25 pub unsafe trait NSSecureCoding: NSCoding {
27 #[unsafe(method(supportsSecureCoding))]
28 #[unsafe(method_family = none)]
29 unsafe fn supportsSecureCoding() -> bool;
30 }
31);
32
33mod private_NSObjectNSCoderMethods {
34 pub trait Sealed {}
35}
36
37#[doc(alias = "NSCoderMethods")]
40pub unsafe trait NSObjectNSCoderMethods:
41 ClassType + Sized + private_NSObjectNSCoderMethods::Sealed
42{
43 extern_methods!(
44 #[unsafe(method(version))]
45 #[unsafe(method_family = none)]
46 unsafe fn version() -> NSInteger;
47
48 #[unsafe(method(setVersion:))]
49 #[unsafe(method_family = none)]
50 unsafe fn setVersion(a_version: NSInteger);
51
52 #[unsafe(method(classForCoder))]
53 #[unsafe(method_family = none)]
54 unsafe fn classForCoder(&self) -> &'static AnyClass;
55
56 #[cfg(feature = "NSCoder")]
57 #[unsafe(method(replacementObjectForCoder:))]
58 #[unsafe(method_family = none)]
59 unsafe fn replacementObjectForCoder(&self, coder: &NSCoder) -> Option<Retained<AnyObject>>;
60 );
61}
62
63impl private_NSObjectNSCoderMethods::Sealed for NSObject {}
64unsafe impl NSObjectNSCoderMethods for NSObject {}
65
66extern_protocol!(
67 pub unsafe trait NSDiscardableContent {
71 #[unsafe(method(beginContentAccess))]
72 #[unsafe(method_family = none)]
73 unsafe fn beginContentAccess(&self) -> bool;
74
75 #[unsafe(method(endContentAccess))]
76 #[unsafe(method_family = none)]
77 unsafe fn endContentAccess(&self);
78
79 #[unsafe(method(discardContentIfPossible))]
80 #[unsafe(method_family = none)]
81 unsafe fn discardContentIfPossible(&self);
82
83 #[unsafe(method(isContentDiscarded))]
84 #[unsafe(method_family = none)]
85 unsafe fn isContentDiscarded(&self) -> bool;
86 }
87);
88
89mod private_NSObjectNSDiscardableContentProxy {
90 pub trait Sealed {}
91}
92
93#[doc(alias = "NSDiscardableContentProxy")]
95pub unsafe trait NSObjectNSDiscardableContentProxy:
96 ClassType + Sized + private_NSObjectNSDiscardableContentProxy::Sealed
97{
98 extern_methods!(
99 #[unsafe(method(autoContentAccessingProxy))]
100 #[unsafe(method_family = none)]
101 unsafe fn autoContentAccessingProxy(&self) -> Retained<AnyObject>;
102 );
103}
104
105impl private_NSObjectNSDiscardableContentProxy::Sealed for NSObject {}
106unsafe impl NSObjectNSDiscardableContentProxy for NSObject {}
107
108#[cfg(feature = "NSZone")]
110#[inline]
111pub unsafe extern "C-unwind" fn NSAllocateObject(
112 a_class: &AnyClass,
113 extra_bytes: NSUInteger,
114 zone: *mut NSZone,
115) -> Retained<AnyObject> {
116 extern "C-unwind" {
117 fn NSAllocateObject(
118 a_class: &AnyClass,
119 extra_bytes: NSUInteger,
120 zone: *mut NSZone,
121 ) -> *mut AnyObject;
122 }
123 let ret = unsafe { NSAllocateObject(a_class, extra_bytes, zone) };
124 unsafe { Retained::retain_autoreleased(ret) }
125 .expect("function was marked as returning non-null, but actually returned NULL")
126}
127
128extern "C-unwind" {
129 pub fn NSDeallocateObject(object: &AnyObject);
130}
131
132#[cfg(feature = "NSZone")]
133#[deprecated = "Not supported"]
134#[inline]
135pub unsafe extern "C-unwind" fn NSCopyObject(
136 object: &AnyObject,
137 extra_bytes: NSUInteger,
138 zone: *mut NSZone,
139) -> Retained<AnyObject> {
140 extern "C-unwind" {
141 fn NSCopyObject(
142 object: &AnyObject,
143 extra_bytes: NSUInteger,
144 zone: *mut NSZone,
145 ) -> *mut AnyObject;
146 }
147 let ret = unsafe { NSCopyObject(object, extra_bytes, zone) };
148 unsafe { Retained::from_raw(ret) }
149 .expect("function was marked as returning non-null, but actually returned NULL")
150}
151
152#[cfg(feature = "NSZone")]
153#[inline]
154pub unsafe extern "C-unwind" fn NSShouldRetainWithZone(
155 an_object: &AnyObject,
156 requested_zone: *mut NSZone,
157) -> bool {
158 extern "C-unwind" {
159 fn NSShouldRetainWithZone(an_object: &AnyObject, requested_zone: *mut NSZone) -> Bool;
160 }
161 unsafe { NSShouldRetainWithZone(an_object, requested_zone) }.as_bool()
162}
163
164extern "C-unwind" {
165 pub fn NSIncrementExtraRefCount(object: &AnyObject);
166}
167
168#[inline]
169pub unsafe extern "C-unwind" fn NSDecrementExtraRefCountWasZero(object: &AnyObject) -> bool {
170 extern "C-unwind" {
171 fn NSDecrementExtraRefCountWasZero(object: &AnyObject) -> Bool;
172 }
173 unsafe { NSDecrementExtraRefCountWasZero(object) }.as_bool()
174}
175
176extern "C-unwind" {
177 pub fn NSExtraRefCount(object: &AnyObject) -> NSUInteger;
178}