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