objc2_foundation/generated/
NSLock.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9extern_protocol!(
10    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nslocking?language=objc)
11    pub unsafe trait NSLocking {
12        #[unsafe(method(lock))]
13        #[unsafe(method_family = none)]
14        unsafe fn lock(&self);
15
16        #[unsafe(method(unlock))]
17        #[unsafe(method_family = none)]
18        unsafe fn unlock(&self);
19    }
20);
21
22extern_class!(
23    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nslock?language=objc)
24    #[unsafe(super(NSObject))]
25    #[derive(Debug, PartialEq, Eq, Hash)]
26    pub struct NSLock;
27);
28
29unsafe impl Send for NSLock {}
30
31unsafe impl Sync for NSLock {}
32
33extern_conformance!(
34    unsafe impl NSLocking for NSLock {}
35);
36
37extern_conformance!(
38    unsafe impl NSObjectProtocol for NSLock {}
39);
40
41impl NSLock {
42    extern_methods!(
43        #[unsafe(method(tryLock))]
44        #[unsafe(method_family = none)]
45        pub unsafe fn tryLock(&self) -> bool;
46
47        #[cfg(feature = "NSDate")]
48        #[unsafe(method(lockBeforeDate:))]
49        #[unsafe(method_family = none)]
50        pub unsafe fn lockBeforeDate(&self, limit: &NSDate) -> bool;
51
52        #[cfg(feature = "NSString")]
53        #[unsafe(method(name))]
54        #[unsafe(method_family = none)]
55        pub fn name(&self) -> Option<Retained<NSString>>;
56
57        #[cfg(feature = "NSString")]
58        /// Setter for [`name`][Self::name].
59        #[unsafe(method(setName:))]
60        #[unsafe(method_family = none)]
61        pub fn setName(&self, name: Option<&NSString>);
62    );
63}
64
65/// Methods declared on superclass `NSObject`.
66impl NSLock {
67    extern_methods!(
68        #[unsafe(method(init))]
69        #[unsafe(method_family = init)]
70        pub fn init(this: Allocated<Self>) -> Retained<Self>;
71
72        #[unsafe(method(new))]
73        #[unsafe(method_family = new)]
74        pub fn new() -> Retained<Self>;
75    );
76}
77
78impl DefaultRetained for NSLock {
79    #[inline]
80    fn default_retained() -> Retained<Self> {
81        Self::new()
82    }
83}
84
85extern_class!(
86    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsconditionlock?language=objc)
87    #[unsafe(super(NSObject))]
88    #[derive(Debug, PartialEq, Eq, Hash)]
89    pub struct NSConditionLock;
90);
91
92unsafe impl Send for NSConditionLock {}
93
94unsafe impl Sync for NSConditionLock {}
95
96extern_conformance!(
97    unsafe impl NSLocking for NSConditionLock {}
98);
99
100extern_conformance!(
101    unsafe impl NSObjectProtocol for NSConditionLock {}
102);
103
104impl NSConditionLock {
105    extern_methods!(
106        #[unsafe(method(initWithCondition:))]
107        #[unsafe(method_family = init)]
108        pub unsafe fn initWithCondition(
109            this: Allocated<Self>,
110            condition: NSInteger,
111        ) -> Retained<Self>;
112
113        #[unsafe(method(condition))]
114        #[unsafe(method_family = none)]
115        pub unsafe fn condition(&self) -> NSInteger;
116
117        #[unsafe(method(lockWhenCondition:))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn lockWhenCondition(&self, condition: NSInteger);
120
121        #[unsafe(method(tryLock))]
122        #[unsafe(method_family = none)]
123        pub unsafe fn tryLock(&self) -> bool;
124
125        #[unsafe(method(tryLockWhenCondition:))]
126        #[unsafe(method_family = none)]
127        pub unsafe fn tryLockWhenCondition(&self, condition: NSInteger) -> bool;
128
129        #[unsafe(method(unlockWithCondition:))]
130        #[unsafe(method_family = none)]
131        pub unsafe fn unlockWithCondition(&self, condition: NSInteger);
132
133        #[cfg(feature = "NSDate")]
134        #[unsafe(method(lockBeforeDate:))]
135        #[unsafe(method_family = none)]
136        pub unsafe fn lockBeforeDate(&self, limit: &NSDate) -> bool;
137
138        #[cfg(feature = "NSDate")]
139        #[unsafe(method(lockWhenCondition:beforeDate:))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn lockWhenCondition_beforeDate(
142            &self,
143            condition: NSInteger,
144            limit: &NSDate,
145        ) -> bool;
146
147        #[cfg(feature = "NSString")]
148        #[unsafe(method(name))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn name(&self) -> Option<Retained<NSString>>;
151
152        #[cfg(feature = "NSString")]
153        /// Setter for [`name`][Self::name].
154        #[unsafe(method(setName:))]
155        #[unsafe(method_family = none)]
156        pub unsafe fn setName(&self, name: Option<&NSString>);
157    );
158}
159
160/// Methods declared on superclass `NSObject`.
161impl NSConditionLock {
162    extern_methods!(
163        #[unsafe(method(init))]
164        #[unsafe(method_family = init)]
165        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
166
167        #[unsafe(method(new))]
168        #[unsafe(method_family = new)]
169        pub unsafe fn new() -> Retained<Self>;
170    );
171}
172
173extern_class!(
174    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsrecursivelock?language=objc)
175    #[unsafe(super(NSObject))]
176    #[derive(Debug, PartialEq, Eq, Hash)]
177    pub struct NSRecursiveLock;
178);
179
180unsafe impl Send for NSRecursiveLock {}
181
182unsafe impl Sync for NSRecursiveLock {}
183
184extern_conformance!(
185    unsafe impl NSLocking for NSRecursiveLock {}
186);
187
188extern_conformance!(
189    unsafe impl NSObjectProtocol for NSRecursiveLock {}
190);
191
192impl NSRecursiveLock {
193    extern_methods!(
194        #[unsafe(method(tryLock))]
195        #[unsafe(method_family = none)]
196        pub unsafe fn tryLock(&self) -> bool;
197
198        #[cfg(feature = "NSDate")]
199        #[unsafe(method(lockBeforeDate:))]
200        #[unsafe(method_family = none)]
201        pub unsafe fn lockBeforeDate(&self, limit: &NSDate) -> bool;
202
203        #[cfg(feature = "NSString")]
204        #[unsafe(method(name))]
205        #[unsafe(method_family = none)]
206        pub unsafe fn name(&self) -> Option<Retained<NSString>>;
207
208        #[cfg(feature = "NSString")]
209        /// Setter for [`name`][Self::name].
210        #[unsafe(method(setName:))]
211        #[unsafe(method_family = none)]
212        pub unsafe fn setName(&self, name: Option<&NSString>);
213    );
214}
215
216/// Methods declared on superclass `NSObject`.
217impl NSRecursiveLock {
218    extern_methods!(
219        #[unsafe(method(init))]
220        #[unsafe(method_family = init)]
221        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
222
223        #[unsafe(method(new))]
224        #[unsafe(method_family = new)]
225        pub unsafe fn new() -> Retained<Self>;
226    );
227}
228
229extern_class!(
230    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscondition?language=objc)
231    #[unsafe(super(NSObject))]
232    #[derive(Debug, PartialEq, Eq, Hash)]
233    pub struct NSCondition;
234);
235
236unsafe impl Send for NSCondition {}
237
238unsafe impl Sync for NSCondition {}
239
240extern_conformance!(
241    unsafe impl NSLocking for NSCondition {}
242);
243
244extern_conformance!(
245    unsafe impl NSObjectProtocol for NSCondition {}
246);
247
248impl NSCondition {
249    extern_methods!(
250        #[unsafe(method(wait))]
251        #[unsafe(method_family = none)]
252        pub unsafe fn wait(&self);
253
254        #[cfg(feature = "NSDate")]
255        #[unsafe(method(waitUntilDate:))]
256        #[unsafe(method_family = none)]
257        pub unsafe fn waitUntilDate(&self, limit: &NSDate) -> bool;
258
259        #[unsafe(method(signal))]
260        #[unsafe(method_family = none)]
261        pub unsafe fn signal(&self);
262
263        #[unsafe(method(broadcast))]
264        #[unsafe(method_family = none)]
265        pub unsafe fn broadcast(&self);
266
267        #[cfg(feature = "NSString")]
268        #[unsafe(method(name))]
269        #[unsafe(method_family = none)]
270        pub unsafe fn name(&self) -> Option<Retained<NSString>>;
271
272        #[cfg(feature = "NSString")]
273        /// Setter for [`name`][Self::name].
274        #[unsafe(method(setName:))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn setName(&self, name: Option<&NSString>);
277    );
278}
279
280/// Methods declared on superclass `NSObject`.
281impl NSCondition {
282    extern_methods!(
283        #[unsafe(method(init))]
284        #[unsafe(method_family = init)]
285        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
286
287        #[unsafe(method(new))]
288        #[unsafe(method_family = new)]
289        pub unsafe fn new() -> Retained<Self>;
290    );
291}