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        ///
60        /// This is [copied][crate::NSCopying::copy] when set.
61        #[unsafe(method(setName:))]
62        #[unsafe(method_family = none)]
63        pub fn setName(&self, name: Option<&NSString>);
64    );
65}
66
67/// Methods declared on superclass `NSObject`.
68impl NSLock {
69    extern_methods!(
70        #[unsafe(method(init))]
71        #[unsafe(method_family = init)]
72        pub fn init(this: Allocated<Self>) -> Retained<Self>;
73
74        #[unsafe(method(new))]
75        #[unsafe(method_family = new)]
76        pub fn new() -> Retained<Self>;
77    );
78}
79
80impl DefaultRetained for NSLock {
81    #[inline]
82    fn default_retained() -> Retained<Self> {
83        Self::new()
84    }
85}
86
87extern_class!(
88    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsconditionlock?language=objc)
89    #[unsafe(super(NSObject))]
90    #[derive(Debug, PartialEq, Eq, Hash)]
91    pub struct NSConditionLock;
92);
93
94unsafe impl Send for NSConditionLock {}
95
96unsafe impl Sync for NSConditionLock {}
97
98extern_conformance!(
99    unsafe impl NSLocking for NSConditionLock {}
100);
101
102extern_conformance!(
103    unsafe impl NSObjectProtocol for NSConditionLock {}
104);
105
106impl NSConditionLock {
107    extern_methods!(
108        #[unsafe(method(initWithCondition:))]
109        #[unsafe(method_family = init)]
110        pub unsafe fn initWithCondition(
111            this: Allocated<Self>,
112            condition: NSInteger,
113        ) -> Retained<Self>;
114
115        #[unsafe(method(condition))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn condition(&self) -> NSInteger;
118
119        #[unsafe(method(lockWhenCondition:))]
120        #[unsafe(method_family = none)]
121        pub unsafe fn lockWhenCondition(&self, condition: NSInteger);
122
123        #[unsafe(method(tryLock))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn tryLock(&self) -> bool;
126
127        #[unsafe(method(tryLockWhenCondition:))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn tryLockWhenCondition(&self, condition: NSInteger) -> bool;
130
131        #[unsafe(method(unlockWithCondition:))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn unlockWithCondition(&self, condition: NSInteger);
134
135        #[cfg(feature = "NSDate")]
136        #[unsafe(method(lockBeforeDate:))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn lockBeforeDate(&self, limit: &NSDate) -> bool;
139
140        #[cfg(feature = "NSDate")]
141        #[unsafe(method(lockWhenCondition:beforeDate:))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn lockWhenCondition_beforeDate(
144            &self,
145            condition: NSInteger,
146            limit: &NSDate,
147        ) -> bool;
148
149        #[cfg(feature = "NSString")]
150        #[unsafe(method(name))]
151        #[unsafe(method_family = none)]
152        pub unsafe fn name(&self) -> Option<Retained<NSString>>;
153
154        #[cfg(feature = "NSString")]
155        /// Setter for [`name`][Self::name].
156        ///
157        /// This is [copied][crate::NSCopying::copy] when set.
158        #[unsafe(method(setName:))]
159        #[unsafe(method_family = none)]
160        pub unsafe fn setName(&self, name: Option<&NSString>);
161    );
162}
163
164/// Methods declared on superclass `NSObject`.
165impl NSConditionLock {
166    extern_methods!(
167        #[unsafe(method(init))]
168        #[unsafe(method_family = init)]
169        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
170
171        #[unsafe(method(new))]
172        #[unsafe(method_family = new)]
173        pub unsafe fn new() -> Retained<Self>;
174    );
175}
176
177extern_class!(
178    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsrecursivelock?language=objc)
179    #[unsafe(super(NSObject))]
180    #[derive(Debug, PartialEq, Eq, Hash)]
181    pub struct NSRecursiveLock;
182);
183
184unsafe impl Send for NSRecursiveLock {}
185
186unsafe impl Sync for NSRecursiveLock {}
187
188extern_conformance!(
189    unsafe impl NSLocking for NSRecursiveLock {}
190);
191
192extern_conformance!(
193    unsafe impl NSObjectProtocol for NSRecursiveLock {}
194);
195
196impl NSRecursiveLock {
197    extern_methods!(
198        #[unsafe(method(tryLock))]
199        #[unsafe(method_family = none)]
200        pub unsafe fn tryLock(&self) -> bool;
201
202        #[cfg(feature = "NSDate")]
203        #[unsafe(method(lockBeforeDate:))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn lockBeforeDate(&self, limit: &NSDate) -> bool;
206
207        #[cfg(feature = "NSString")]
208        #[unsafe(method(name))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn name(&self) -> Option<Retained<NSString>>;
211
212        #[cfg(feature = "NSString")]
213        /// Setter for [`name`][Self::name].
214        ///
215        /// This is [copied][crate::NSCopying::copy] when set.
216        #[unsafe(method(setName:))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn setName(&self, name: Option<&NSString>);
219    );
220}
221
222/// Methods declared on superclass `NSObject`.
223impl NSRecursiveLock {
224    extern_methods!(
225        #[unsafe(method(init))]
226        #[unsafe(method_family = init)]
227        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
228
229        #[unsafe(method(new))]
230        #[unsafe(method_family = new)]
231        pub unsafe fn new() -> Retained<Self>;
232    );
233}
234
235extern_class!(
236    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscondition?language=objc)
237    #[unsafe(super(NSObject))]
238    #[derive(Debug, PartialEq, Eq, Hash)]
239    pub struct NSCondition;
240);
241
242unsafe impl Send for NSCondition {}
243
244unsafe impl Sync for NSCondition {}
245
246extern_conformance!(
247    unsafe impl NSLocking for NSCondition {}
248);
249
250extern_conformance!(
251    unsafe impl NSObjectProtocol for NSCondition {}
252);
253
254impl NSCondition {
255    extern_methods!(
256        #[unsafe(method(wait))]
257        #[unsafe(method_family = none)]
258        pub unsafe fn wait(&self);
259
260        #[cfg(feature = "NSDate")]
261        #[unsafe(method(waitUntilDate:))]
262        #[unsafe(method_family = none)]
263        pub unsafe fn waitUntilDate(&self, limit: &NSDate) -> bool;
264
265        #[unsafe(method(signal))]
266        #[unsafe(method_family = none)]
267        pub unsafe fn signal(&self);
268
269        #[unsafe(method(broadcast))]
270        #[unsafe(method_family = none)]
271        pub unsafe fn broadcast(&self);
272
273        #[cfg(feature = "NSString")]
274        #[unsafe(method(name))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn name(&self) -> Option<Retained<NSString>>;
277
278        #[cfg(feature = "NSString")]
279        /// Setter for [`name`][Self::name].
280        ///
281        /// This is [copied][crate::NSCopying::copy] when set.
282        #[unsafe(method(setName:))]
283        #[unsafe(method_family = none)]
284        pub unsafe fn setName(&self, name: Option<&NSString>);
285    );
286}
287
288/// Methods declared on superclass `NSObject`.
289impl NSCondition {
290    extern_methods!(
291        #[unsafe(method(init))]
292        #[unsafe(method_family = init)]
293        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
294
295        #[unsafe(method(new))]
296        #[unsafe(method_family = new)]
297        pub unsafe fn new() -> Retained<Self>;
298    );
299}