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 unsafe fn currentRunLoop() -> Retained<NSRunLoop>;
39
40        #[unsafe(method(mainRunLoop))]
41        #[unsafe(method_family = none)]
42        pub unsafe fn mainRunLoop() -> Retained<NSRunLoop>;
43
44        #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
45        #[unsafe(method(currentMode))]
46        #[unsafe(method_family = none)]
47        pub unsafe fn currentMode(&self) -> Option<Retained<NSRunLoopMode>>;
48
49        #[cfg(feature = "objc2-core-foundation")]
50        #[unsafe(method(getCFRunLoop))]
51        #[unsafe(method_family = none)]
52        pub unsafe 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 unsafe 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 unsafe fn acceptInputForMode_beforeDate(
78            &self,
79            mode: &NSRunLoopMode,
80            limit_date: &NSDate,
81        );
82    );
83}
84
85/// Methods declared on superclass `NSObject`.
86impl NSRunLoop {
87    extern_methods!(
88        #[unsafe(method(init))]
89        #[unsafe(method_family = init)]
90        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
91
92        #[unsafe(method(new))]
93        #[unsafe(method_family = new)]
94        pub unsafe fn new() -> Retained<Self>;
95    );
96}
97
98/// NSRunLoopConveniences.
99impl NSRunLoop {
100    extern_methods!(
101        #[unsafe(method(run))]
102        #[unsafe(method_family = none)]
103        pub unsafe fn run(&self);
104
105        #[cfg(feature = "NSDate")]
106        #[unsafe(method(runUntilDate:))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn runUntilDate(&self, limit_date: &NSDate);
109
110        #[cfg(all(feature = "NSDate", feature = "NSObjCRuntime", feature = "NSString"))]
111        #[unsafe(method(runMode:beforeDate:))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn runMode_beforeDate(&self, mode: &NSRunLoopMode, limit_date: &NSDate) -> bool;
114
115        #[deprecated = "Not supported"]
116        #[unsafe(method(configureAsServer))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn configureAsServer(&self);
119
120        #[cfg(all(
121            feature = "NSArray",
122            feature = "NSObjCRuntime",
123            feature = "NSString",
124            feature = "block2"
125        ))]
126        /// Schedules the execution of a block on the target run loop in given modes.
127        /// - parameter: modes   An array of input modes for which the block may be executed.
128        /// - parameter: block   The block to execute
129        #[unsafe(method(performInModes:block:))]
130        #[unsafe(method_family = none)]
131        pub unsafe fn performInModes_block(
132            &self,
133            modes: &NSArray<NSRunLoopMode>,
134            block: &block2::DynBlock<dyn Fn()>,
135        );
136
137        #[cfg(feature = "block2")]
138        /// Schedules the execution of a block on the target run loop.
139        /// - parameter: block   The block to execute
140        #[unsafe(method(performBlock:))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn performBlock(&self, block: &block2::DynBlock<dyn Fn()>);
143    );
144}
145
146mod private_NSObjectNSDelayedPerforming {
147    pub trait Sealed {}
148}
149
150/// Category "NSDelayedPerforming" on [`NSObject`].
151/// **************     Delayed perform     *****************
152#[doc(alias = "NSDelayedPerforming")]
153pub unsafe trait NSObjectNSDelayedPerforming:
154    ClassType + Sized + private_NSObjectNSDelayedPerforming::Sealed
155{
156    extern_methods!(
157        #[cfg(all(
158            feature = "NSArray",
159            feature = "NSDate",
160            feature = "NSObjCRuntime",
161            feature = "NSString"
162        ))]
163        #[unsafe(method(performSelector:withObject:afterDelay:inModes:))]
164        #[unsafe(method_family = none)]
165        unsafe fn performSelector_withObject_afterDelay_inModes(
166            &self,
167            a_selector: Sel,
168            an_argument: Option<&AnyObject>,
169            delay: NSTimeInterval,
170            modes: &NSArray<NSRunLoopMode>,
171        );
172
173        #[cfg(feature = "NSDate")]
174        #[unsafe(method(performSelector:withObject:afterDelay:))]
175        #[unsafe(method_family = none)]
176        unsafe fn performSelector_withObject_afterDelay(
177            &self,
178            a_selector: Sel,
179            an_argument: Option<&AnyObject>,
180            delay: NSTimeInterval,
181        );
182
183        #[unsafe(method(cancelPreviousPerformRequestsWithTarget:selector:object:))]
184        #[unsafe(method_family = none)]
185        unsafe fn cancelPreviousPerformRequestsWithTarget_selector_object(
186            a_target: &AnyObject,
187            a_selector: Sel,
188            an_argument: Option<&AnyObject>,
189        );
190
191        #[unsafe(method(cancelPreviousPerformRequestsWithTarget:))]
192        #[unsafe(method_family = none)]
193        unsafe fn cancelPreviousPerformRequestsWithTarget(a_target: &AnyObject);
194    );
195}
196
197impl private_NSObjectNSDelayedPerforming::Sealed for NSObject {}
198unsafe impl NSObjectNSDelayedPerforming for NSObject {}
199
200/// NSOrderedPerform.
201impl NSRunLoop {
202    extern_methods!(
203        #[cfg(all(feature = "NSArray", feature = "NSObjCRuntime", feature = "NSString"))]
204        #[unsafe(method(performSelector:target:argument:order:modes:))]
205        #[unsafe(method_family = none)]
206        pub unsafe fn performSelector_target_argument_order_modes(
207            &self,
208            a_selector: Sel,
209            target: &AnyObject,
210            arg: Option<&AnyObject>,
211            order: NSUInteger,
212            modes: &NSArray<NSRunLoopMode>,
213        );
214
215        #[unsafe(method(cancelPerformSelector:target:argument:))]
216        #[unsafe(method_family = none)]
217        pub unsafe fn cancelPerformSelector_target_argument(
218            &self,
219            a_selector: Sel,
220            target: &AnyObject,
221            arg: Option<&AnyObject>,
222        );
223
224        #[unsafe(method(cancelPerformSelectorsWithTarget:))]
225        #[unsafe(method_family = none)]
226        pub unsafe fn cancelPerformSelectorsWithTarget(&self, target: &AnyObject);
227    );
228}