objc2_foundation/generated/
NSRunLoop.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#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8
9use crate::*;
10
11extern "C" {
12    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsdefaultrunloopmode?language=objc)
13    #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
14    pub static NSDefaultRunLoopMode: &'static NSRunLoopMode;
15}
16
17extern "C" {
18    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsrunloopcommonmodes?language=objc)
19    #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
20    pub static NSRunLoopCommonModes: &'static NSRunLoopMode;
21}
22
23extern_class!(
24    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsrunloop?language=objc)
25    #[unsafe(super(NSObject))]
26    #[derive(Debug, PartialEq, Eq, Hash)]
27    pub struct NSRunLoop;
28);
29
30extern_conformance!(
31    unsafe impl NSObjectProtocol for NSRunLoop {}
32);
33
34impl NSRunLoop {
35    extern_methods!(
36        #[unsafe(method(currentRunLoop))]
37        #[unsafe(method_family = none)]
38        pub fn currentRunLoop() -> Retained<NSRunLoop>;
39
40        #[unsafe(method(mainRunLoop))]
41        #[unsafe(method_family = none)]
42        pub fn mainRunLoop() -> Retained<NSRunLoop>;
43
44        #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
45        #[unsafe(method(currentMode))]
46        #[unsafe(method_family = none)]
47        pub fn currentMode(&self) -> Option<Retained<NSRunLoopMode>>;
48
49        #[cfg(feature = "objc2-core-foundation")]
50        #[unsafe(method(getCFRunLoop))]
51        #[unsafe(method_family = none)]
52        pub fn getCFRunLoop(&self) -> Retained<CFRunLoop>;
53
54        #[cfg(all(feature = "NSObjCRuntime", feature = "NSString", feature = "NSTimer"))]
55        #[unsafe(method(addTimer:forMode:))]
56        #[unsafe(method_family = none)]
57        pub unsafe fn addTimer_forMode(&self, timer: &NSTimer, mode: &NSRunLoopMode);
58
59        #[cfg(all(feature = "NSObjCRuntime", feature = "NSPort", feature = "NSString"))]
60        #[unsafe(method(addPort:forMode:))]
61        #[unsafe(method_family = none)]
62        pub unsafe fn addPort_forMode(&self, a_port: &NSPort, mode: &NSRunLoopMode);
63
64        #[cfg(all(feature = "NSObjCRuntime", feature = "NSPort", feature = "NSString"))]
65        #[unsafe(method(removePort:forMode:))]
66        #[unsafe(method_family = none)]
67        pub unsafe fn removePort_forMode(&self, a_port: &NSPort, mode: &NSRunLoopMode);
68
69        #[cfg(all(feature = "NSDate", feature = "NSObjCRuntime", feature = "NSString"))]
70        #[unsafe(method(limitDateForMode:))]
71        #[unsafe(method_family = none)]
72        pub fn limitDateForMode(&self, mode: &NSRunLoopMode) -> Option<Retained<NSDate>>;
73
74        #[cfg(all(feature = "NSDate", feature = "NSObjCRuntime", feature = "NSString"))]
75        #[unsafe(method(acceptInputForMode:beforeDate:))]
76        #[unsafe(method_family = none)]
77        pub fn acceptInputForMode_beforeDate(&self, mode: &NSRunLoopMode, limit_date: &NSDate);
78    );
79}
80
81/// Methods declared on superclass `NSObject`.
82impl NSRunLoop {
83    extern_methods!(
84        #[unsafe(method(init))]
85        #[unsafe(method_family = init)]
86        pub fn init(this: Allocated<Self>) -> Retained<Self>;
87
88        #[unsafe(method(new))]
89        #[unsafe(method_family = new)]
90        pub fn new() -> Retained<Self>;
91    );
92}
93
94impl DefaultRetained for NSRunLoop {
95    #[inline]
96    fn default_retained() -> Retained<Self> {
97        Self::new()
98    }
99}
100
101/// NSRunLoopConveniences.
102impl NSRunLoop {
103    extern_methods!(
104        #[unsafe(method(run))]
105        #[unsafe(method_family = none)]
106        pub fn run(&self);
107
108        #[cfg(feature = "NSDate")]
109        #[unsafe(method(runUntilDate:))]
110        #[unsafe(method_family = none)]
111        pub fn runUntilDate(&self, limit_date: &NSDate);
112
113        #[cfg(all(feature = "NSDate", feature = "NSObjCRuntime", feature = "NSString"))]
114        #[unsafe(method(runMode:beforeDate:))]
115        #[unsafe(method_family = none)]
116        pub fn runMode_beforeDate(&self, mode: &NSRunLoopMode, limit_date: &NSDate) -> bool;
117
118        #[deprecated = "Not supported"]
119        #[unsafe(method(configureAsServer))]
120        #[unsafe(method_family = none)]
121        pub fn configureAsServer(&self);
122
123        #[cfg(all(
124            feature = "NSArray",
125            feature = "NSObjCRuntime",
126            feature = "NSString",
127            feature = "block2"
128        ))]
129        /// Schedules the execution of a block on the target run loop in given modes.
130        /// - parameter: modes   An array of input modes for which the block may be executed.
131        /// - parameter: block   The block to execute
132        ///
133        /// # Safety
134        ///
135        /// `block` block must be sendable.
136        #[unsafe(method(performInModes:block:))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn performInModes_block(
139            &self,
140            modes: &NSArray<NSRunLoopMode>,
141            block: &block2::DynBlock<dyn Fn()>,
142        );
143
144        #[cfg(feature = "block2")]
145        /// Schedules the execution of a block on the target run loop.
146        /// - parameter: block   The block to execute
147        ///
148        /// # Safety
149        ///
150        /// `block` block must be sendable.
151        #[unsafe(method(performBlock:))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn performBlock(&self, block: &block2::DynBlock<dyn Fn()>);
154    );
155}
156
157mod private_NSObjectNSDelayedPerforming {
158    pub trait Sealed {}
159}
160
161/// Category "NSDelayedPerforming" on [`NSObject`].
162///
163/// **************     Delayed perform     *****************
164#[doc(alias = "NSDelayedPerforming")]
165pub unsafe trait NSObjectNSDelayedPerforming:
166    ClassType + Sized + private_NSObjectNSDelayedPerforming::Sealed
167{
168    extern_methods!(
169        #[cfg(all(
170            feature = "NSArray",
171            feature = "NSDate",
172            feature = "NSObjCRuntime",
173            feature = "NSString"
174        ))]
175        /// # Safety
176        ///
177        /// - `a_selector` must be a valid selector.
178        /// - `an_argument` should be of the correct type.
179        #[unsafe(method(performSelector:withObject:afterDelay:inModes:))]
180        #[unsafe(method_family = none)]
181        unsafe fn performSelector_withObject_afterDelay_inModes(
182            &self,
183            a_selector: Sel,
184            an_argument: Option<&AnyObject>,
185            delay: NSTimeInterval,
186            modes: &NSArray<NSRunLoopMode>,
187        );
188
189        #[cfg(feature = "NSDate")]
190        /// # Safety
191        ///
192        /// - `a_selector` must be a valid selector.
193        /// - `an_argument` should be of the correct type.
194        #[unsafe(method(performSelector:withObject:afterDelay:))]
195        #[unsafe(method_family = none)]
196        unsafe fn performSelector_withObject_afterDelay(
197            &self,
198            a_selector: Sel,
199            an_argument: Option<&AnyObject>,
200            delay: NSTimeInterval,
201        );
202
203        /// # Safety
204        ///
205        /// - `a_target` should be of the correct type.
206        /// - `a_selector` must be a valid selector.
207        /// - `an_argument` should be of the correct type.
208        #[unsafe(method(cancelPreviousPerformRequestsWithTarget:selector:object:))]
209        #[unsafe(method_family = none)]
210        unsafe fn cancelPreviousPerformRequestsWithTarget_selector_object(
211            a_target: &AnyObject,
212            a_selector: Sel,
213            an_argument: Option<&AnyObject>,
214        );
215
216        /// # Safety
217        ///
218        /// `a_target` should be of the correct type.
219        #[unsafe(method(cancelPreviousPerformRequestsWithTarget:))]
220        #[unsafe(method_family = none)]
221        unsafe fn cancelPreviousPerformRequestsWithTarget(a_target: &AnyObject);
222    );
223}
224
225impl private_NSObjectNSDelayedPerforming::Sealed for NSObject {}
226unsafe impl NSObjectNSDelayedPerforming for NSObject {}
227
228/// NSOrderedPerform.
229impl NSRunLoop {
230    extern_methods!(
231        #[cfg(all(feature = "NSArray", feature = "NSObjCRuntime", feature = "NSString"))]
232        /// # Safety
233        ///
234        /// - `a_selector` must be a valid selector.
235        /// - `target` should be of the correct type.
236        /// - `arg` should be of the correct type.
237        #[unsafe(method(performSelector:target:argument:order:modes:))]
238        #[unsafe(method_family = none)]
239        pub unsafe fn performSelector_target_argument_order_modes(
240            &self,
241            a_selector: Sel,
242            target: &AnyObject,
243            arg: Option<&AnyObject>,
244            order: NSUInteger,
245            modes: &NSArray<NSRunLoopMode>,
246        );
247
248        /// # Safety
249        ///
250        /// - `a_selector` must be a valid selector.
251        /// - `target` should be of the correct type.
252        /// - `arg` should be of the correct type.
253        #[unsafe(method(cancelPerformSelector:target:argument:))]
254        #[unsafe(method_family = none)]
255        pub unsafe fn cancelPerformSelector_target_argument(
256            &self,
257            a_selector: Sel,
258            target: &AnyObject,
259            arg: Option<&AnyObject>,
260        );
261
262        /// # Safety
263        ///
264        /// `target` should be of the correct type.
265        #[unsafe(method(cancelPerformSelectorsWithTarget:))]
266        #[unsafe(method_family = none)]
267        pub unsafe fn cancelPerformSelectorsWithTarget(&self, target: &AnyObject);
268    );
269}