1use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9
10use crate::*;
11
12pub type CFRunLoopMode = CFString;
15
16#[doc(alias = "CFRunLoopRef")]
18#[repr(C)]
19pub struct CFRunLoop {
20 inner: [u8; 0],
21 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
22}
23
24cf_type!(
25 unsafe impl CFRunLoop {}
26);
27#[cfg(feature = "objc2")]
28cf_objc2_type!(
29 unsafe impl RefEncode<"__CFRunLoop"> for CFRunLoop {}
30);
31
32#[doc(alias = "CFRunLoopSourceRef")]
34#[repr(C)]
35pub struct CFRunLoopSource {
36 inner: [u8; 0],
37 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
38}
39
40cf_type!(
41 unsafe impl CFRunLoopSource {}
42);
43#[cfg(feature = "objc2")]
44cf_objc2_type!(
45 unsafe impl RefEncode<"__CFRunLoopSource"> for CFRunLoopSource {}
46);
47
48#[doc(alias = "CFRunLoopObserverRef")]
50#[repr(C)]
51pub struct CFRunLoopObserver {
52 inner: [u8; 0],
53 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
54}
55
56cf_type!(
57 unsafe impl CFRunLoopObserver {}
58);
59#[cfg(feature = "objc2")]
60cf_objc2_type!(
61 unsafe impl RefEncode<"__CFRunLoopObserver"> for CFRunLoopObserver {}
62);
63
64#[doc(alias = "CFRunLoopTimerRef")]
68#[repr(C)]
69pub struct CFRunLoopTimer {
70 inner: [u8; 0],
71 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
72}
73
74cf_type!(
75 unsafe impl CFRunLoopTimer {}
76);
77#[cfg(feature = "objc2")]
78cf_objc2_type!(
79 unsafe impl RefEncode<"__CFRunLoopTimer"> for CFRunLoopTimer {}
80);
81
82#[repr(transparent)]
85#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
86pub struct CFRunLoopRunResult(pub i32);
87impl CFRunLoopRunResult {
88 #[doc(alias = "kCFRunLoopRunFinished")]
89 pub const Finished: Self = Self(1);
90 #[doc(alias = "kCFRunLoopRunStopped")]
91 pub const Stopped: Self = Self(2);
92 #[doc(alias = "kCFRunLoopRunTimedOut")]
93 pub const TimedOut: Self = Self(3);
94 #[doc(alias = "kCFRunLoopRunHandledSource")]
95 pub const HandledSource: Self = Self(4);
96}
97
98#[cfg(feature = "objc2")]
99unsafe impl Encode for CFRunLoopRunResult {
100 const ENCODING: Encoding = i32::ENCODING;
101}
102
103#[cfg(feature = "objc2")]
104unsafe impl RefEncode for CFRunLoopRunResult {
105 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
106}
107
108#[repr(transparent)]
111#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
112pub struct CFRunLoopActivity(pub CFOptionFlags);
113bitflags::bitflags! {
114 impl CFRunLoopActivity: CFOptionFlags {
115 #[doc(alias = "kCFRunLoopEntry")]
116 const Entry = 1<<0;
117 #[doc(alias = "kCFRunLoopBeforeTimers")]
118 const BeforeTimers = 1<<1;
119 #[doc(alias = "kCFRunLoopBeforeSources")]
120 const BeforeSources = 1<<2;
121 #[doc(alias = "kCFRunLoopBeforeWaiting")]
122 const BeforeWaiting = 1<<5;
123 #[doc(alias = "kCFRunLoopAfterWaiting")]
124 const AfterWaiting = 1<<6;
125 #[doc(alias = "kCFRunLoopExit")]
126 const Exit = 1<<7;
127 #[doc(alias = "kCFRunLoopAllActivities")]
128 const AllActivities = 0x0FFFFFFF;
129 }
130}
131
132#[cfg(feature = "objc2")]
133unsafe impl Encode for CFRunLoopActivity {
134 const ENCODING: Encoding = CFOptionFlags::ENCODING;
135}
136
137#[cfg(feature = "objc2")]
138unsafe impl RefEncode for CFRunLoopActivity {
139 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
140}
141
142extern "C" {
143 pub static kCFRunLoopDefaultMode: Option<&'static CFRunLoopMode>;
145}
146
147extern "C" {
148 pub static kCFRunLoopCommonModes: Option<&'static CFRunLoopMode>;
150}
151
152unsafe impl ConcreteType for CFRunLoop {
153 #[doc(alias = "CFRunLoopGetTypeID")]
154 #[inline]
155 fn type_id() -> CFTypeID {
156 extern "C-unwind" {
157 fn CFRunLoopGetTypeID() -> CFTypeID;
158 }
159 unsafe { CFRunLoopGetTypeID() }
160 }
161}
162
163impl CFRunLoop {
164 #[doc(alias = "CFRunLoopGetCurrent")]
165 #[inline]
166 pub fn current() -> Option<CFRetained<CFRunLoop>> {
167 extern "C-unwind" {
168 fn CFRunLoopGetCurrent() -> Option<NonNull<CFRunLoop>>;
169 }
170 let ret = unsafe { CFRunLoopGetCurrent() };
171 ret.map(|ret| unsafe { CFRetained::retain(ret) })
172 }
173
174 #[doc(alias = "CFRunLoopGetMain")]
175 #[inline]
176 pub fn main() -> Option<CFRetained<CFRunLoop>> {
177 extern "C-unwind" {
178 fn CFRunLoopGetMain() -> Option<NonNull<CFRunLoop>>;
179 }
180 let ret = unsafe { CFRunLoopGetMain() };
181 ret.map(|ret| unsafe { CFRetained::retain(ret) })
182 }
183
184 #[doc(alias = "CFRunLoopCopyCurrentMode")]
185 #[inline]
186 pub fn current_mode(&self) -> Option<CFRetained<CFRunLoopMode>> {
187 extern "C-unwind" {
188 fn CFRunLoopCopyCurrentMode(rl: &CFRunLoop) -> Option<NonNull<CFRunLoopMode>>;
189 }
190 let ret = unsafe { CFRunLoopCopyCurrentMode(self) };
191 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
192 }
193
194 #[doc(alias = "CFRunLoopCopyAllModes")]
195 #[cfg(feature = "CFArray")]
196 #[inline]
197 pub fn all_modes(&self) -> Option<CFRetained<CFArray>> {
198 extern "C-unwind" {
199 fn CFRunLoopCopyAllModes(rl: &CFRunLoop) -> Option<NonNull<CFArray>>;
200 }
201 let ret = unsafe { CFRunLoopCopyAllModes(self) };
202 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
203 }
204
205 #[doc(alias = "CFRunLoopAddCommonMode")]
206 #[inline]
207 pub fn add_common_mode(&self, mode: Option<&CFRunLoopMode>) {
208 extern "C-unwind" {
209 fn CFRunLoopAddCommonMode(rl: &CFRunLoop, mode: Option<&CFRunLoopMode>);
210 }
211 unsafe { CFRunLoopAddCommonMode(self, mode) }
212 }
213
214 #[doc(alias = "CFRunLoopGetNextTimerFireDate")]
215 #[cfg(feature = "CFDate")]
216 #[inline]
217 pub fn next_timer_fire_date(&self, mode: Option<&CFRunLoopMode>) -> CFAbsoluteTime {
218 extern "C-unwind" {
219 fn CFRunLoopGetNextTimerFireDate(
220 rl: &CFRunLoop,
221 mode: Option<&CFRunLoopMode>,
222 ) -> CFAbsoluteTime;
223 }
224 unsafe { CFRunLoopGetNextTimerFireDate(self, mode) }
225 }
226
227 #[doc(alias = "CFRunLoopRun")]
228 #[inline]
229 pub fn run() {
230 extern "C-unwind" {
231 fn CFRunLoopRun();
232 }
233 unsafe { CFRunLoopRun() }
234 }
235
236 #[doc(alias = "CFRunLoopRunInMode")]
237 #[cfg(feature = "CFDate")]
238 #[inline]
239 pub fn run_in_mode(
240 mode: Option<&CFRunLoopMode>,
241 seconds: CFTimeInterval,
242 return_after_source_handled: bool,
243 ) -> CFRunLoopRunResult {
244 extern "C-unwind" {
245 fn CFRunLoopRunInMode(
246 mode: Option<&CFRunLoopMode>,
247 seconds: CFTimeInterval,
248 return_after_source_handled: Boolean,
249 ) -> CFRunLoopRunResult;
250 }
251 unsafe { CFRunLoopRunInMode(mode, seconds, return_after_source_handled as _) }
252 }
253
254 #[doc(alias = "CFRunLoopIsWaiting")]
255 #[inline]
256 pub fn is_waiting(&self) -> bool {
257 extern "C-unwind" {
258 fn CFRunLoopIsWaiting(rl: &CFRunLoop) -> Boolean;
259 }
260 let ret = unsafe { CFRunLoopIsWaiting(self) };
261 ret != 0
262 }
263
264 #[doc(alias = "CFRunLoopWakeUp")]
265 #[inline]
266 pub fn wake_up(&self) {
267 extern "C-unwind" {
268 fn CFRunLoopWakeUp(rl: &CFRunLoop);
269 }
270 unsafe { CFRunLoopWakeUp(self) }
271 }
272
273 #[doc(alias = "CFRunLoopStop")]
274 #[inline]
275 pub fn stop(&self) {
276 extern "C-unwind" {
277 fn CFRunLoopStop(rl: &CFRunLoop);
278 }
279 unsafe { CFRunLoopStop(self) }
280 }
281
282 #[doc(alias = "CFRunLoopPerformBlock")]
289 #[cfg(feature = "block2")]
290 #[inline]
291 pub unsafe fn perform_block(
292 &self,
293 mode: Option<&CFType>,
294 block: Option<&block2::DynBlock<dyn Fn()>>,
295 ) {
296 extern "C-unwind" {
297 fn CFRunLoopPerformBlock(
298 rl: &CFRunLoop,
299 mode: Option<&CFType>,
300 block: Option<&block2::DynBlock<dyn Fn()>>,
301 );
302 }
303 unsafe { CFRunLoopPerformBlock(self, mode, block) }
304 }
305
306 #[doc(alias = "CFRunLoopContainsSource")]
307 #[inline]
308 pub fn contains_source(
309 &self,
310 source: Option<&CFRunLoopSource>,
311 mode: Option<&CFRunLoopMode>,
312 ) -> bool {
313 extern "C-unwind" {
314 fn CFRunLoopContainsSource(
315 rl: &CFRunLoop,
316 source: Option<&CFRunLoopSource>,
317 mode: Option<&CFRunLoopMode>,
318 ) -> Boolean;
319 }
320 let ret = unsafe { CFRunLoopContainsSource(self, source, mode) };
321 ret != 0
322 }
323
324 #[doc(alias = "CFRunLoopAddSource")]
325 #[inline]
326 pub fn add_source(&self, source: Option<&CFRunLoopSource>, mode: Option<&CFRunLoopMode>) {
327 extern "C-unwind" {
328 fn CFRunLoopAddSource(
329 rl: &CFRunLoop,
330 source: Option<&CFRunLoopSource>,
331 mode: Option<&CFRunLoopMode>,
332 );
333 }
334 unsafe { CFRunLoopAddSource(self, source, mode) }
335 }
336
337 #[doc(alias = "CFRunLoopRemoveSource")]
338 #[inline]
339 pub fn remove_source(&self, source: Option<&CFRunLoopSource>, mode: Option<&CFRunLoopMode>) {
340 extern "C-unwind" {
341 fn CFRunLoopRemoveSource(
342 rl: &CFRunLoop,
343 source: Option<&CFRunLoopSource>,
344 mode: Option<&CFRunLoopMode>,
345 );
346 }
347 unsafe { CFRunLoopRemoveSource(self, source, mode) }
348 }
349
350 #[doc(alias = "CFRunLoopContainsObserver")]
351 #[inline]
352 pub fn contains_observer(
353 &self,
354 observer: Option<&CFRunLoopObserver>,
355 mode: Option<&CFRunLoopMode>,
356 ) -> bool {
357 extern "C-unwind" {
358 fn CFRunLoopContainsObserver(
359 rl: &CFRunLoop,
360 observer: Option<&CFRunLoopObserver>,
361 mode: Option<&CFRunLoopMode>,
362 ) -> Boolean;
363 }
364 let ret = unsafe { CFRunLoopContainsObserver(self, observer, mode) };
365 ret != 0
366 }
367
368 #[doc(alias = "CFRunLoopAddObserver")]
369 #[inline]
370 pub fn add_observer(&self, observer: Option<&CFRunLoopObserver>, mode: Option<&CFRunLoopMode>) {
371 extern "C-unwind" {
372 fn CFRunLoopAddObserver(
373 rl: &CFRunLoop,
374 observer: Option<&CFRunLoopObserver>,
375 mode: Option<&CFRunLoopMode>,
376 );
377 }
378 unsafe { CFRunLoopAddObserver(self, observer, mode) }
379 }
380
381 #[doc(alias = "CFRunLoopRemoveObserver")]
382 #[inline]
383 pub fn remove_observer(
384 &self,
385 observer: Option<&CFRunLoopObserver>,
386 mode: Option<&CFRunLoopMode>,
387 ) {
388 extern "C-unwind" {
389 fn CFRunLoopRemoveObserver(
390 rl: &CFRunLoop,
391 observer: Option<&CFRunLoopObserver>,
392 mode: Option<&CFRunLoopMode>,
393 );
394 }
395 unsafe { CFRunLoopRemoveObserver(self, observer, mode) }
396 }
397
398 #[doc(alias = "CFRunLoopContainsTimer")]
399 #[inline]
400 pub fn contains_timer(
401 &self,
402 timer: Option<&CFRunLoopTimer>,
403 mode: Option<&CFRunLoopMode>,
404 ) -> bool {
405 extern "C-unwind" {
406 fn CFRunLoopContainsTimer(
407 rl: &CFRunLoop,
408 timer: Option<&CFRunLoopTimer>,
409 mode: Option<&CFRunLoopMode>,
410 ) -> Boolean;
411 }
412 let ret = unsafe { CFRunLoopContainsTimer(self, timer, mode) };
413 ret != 0
414 }
415
416 #[doc(alias = "CFRunLoopAddTimer")]
417 #[inline]
418 pub fn add_timer(&self, timer: Option<&CFRunLoopTimer>, mode: Option<&CFRunLoopMode>) {
419 extern "C-unwind" {
420 fn CFRunLoopAddTimer(
421 rl: &CFRunLoop,
422 timer: Option<&CFRunLoopTimer>,
423 mode: Option<&CFRunLoopMode>,
424 );
425 }
426 unsafe { CFRunLoopAddTimer(self, timer, mode) }
427 }
428
429 #[doc(alias = "CFRunLoopRemoveTimer")]
430 #[inline]
431 pub fn remove_timer(&self, timer: Option<&CFRunLoopTimer>, mode: Option<&CFRunLoopMode>) {
432 extern "C-unwind" {
433 fn CFRunLoopRemoveTimer(
434 rl: &CFRunLoop,
435 timer: Option<&CFRunLoopTimer>,
436 mode: Option<&CFRunLoopMode>,
437 );
438 }
439 unsafe { CFRunLoopRemoveTimer(self, timer, mode) }
440 }
441}
442
443#[repr(C)]
445#[allow(unpredictable_function_pointer_comparisons)]
446#[derive(Clone, Copy, Debug, PartialEq)]
447pub struct CFRunLoopSourceContext {
448 pub version: CFIndex,
449 pub info: *mut c_void,
450 pub retain: Option<unsafe extern "C-unwind" fn(*const c_void) -> *const c_void>,
451 pub release: Option<unsafe extern "C-unwind" fn(*const c_void)>,
452 pub copyDescription: Option<unsafe extern "C-unwind" fn(*const c_void) -> *const CFString>,
453 pub equal: Option<unsafe extern "C-unwind" fn(*const c_void, *const c_void) -> Boolean>,
454 pub hash: Option<unsafe extern "C-unwind" fn(*const c_void) -> CFHashCode>,
455 pub schedule:
456 Option<unsafe extern "C-unwind" fn(*mut c_void, *mut CFRunLoop, *const CFRunLoopMode)>,
457 pub cancel:
458 Option<unsafe extern "C-unwind" fn(*mut c_void, *mut CFRunLoop, *const CFRunLoopMode)>,
459 pub perform: Option<unsafe extern "C-unwind" fn(*mut c_void)>,
460}
461
462#[cfg(feature = "objc2")]
463unsafe impl Encode for CFRunLoopSourceContext {
464 const ENCODING: Encoding = Encoding::Struct("?", &[
465 <CFIndex>::ENCODING,
466 <*mut c_void>::ENCODING,
467 <Option<unsafe extern "C-unwind" fn(*const c_void,) -> *const c_void>>::ENCODING,
468 <Option<unsafe extern "C-unwind" fn(*const c_void,)>>::ENCODING,
469 <Option<unsafe extern "C-unwind" fn(*const c_void,) -> *const CFString>>::ENCODING,
470 <Option<unsafe extern "C-unwind" fn(*const c_void,*const c_void,) -> Boolean>>::ENCODING,
471 <Option<unsafe extern "C-unwind" fn(*const c_void,) -> CFHashCode>>::ENCODING,
472 <Option<unsafe extern "C-unwind" fn(*mut c_void,*mut CFRunLoop,*const CFRunLoopMode,)>>::ENCODING,
473 <Option<unsafe extern "C-unwind" fn(*mut c_void,*mut CFRunLoop,*const CFRunLoopMode,)>>::ENCODING,
474 <Option<unsafe extern "C-unwind" fn(*mut c_void,)>>::ENCODING,
475 ]);
476}
477
478#[cfg(feature = "objc2")]
479unsafe impl RefEncode for CFRunLoopSourceContext {
480 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
481}
482
483#[cfg(feature = "libc")]
485#[repr(C)]
486#[allow(unpredictable_function_pointer_comparisons)]
487#[derive(Clone, Copy, Debug, PartialEq)]
488pub struct CFRunLoopSourceContext1 {
489 pub version: CFIndex,
490 pub info: *mut c_void,
491 pub retain: Option<unsafe extern "C-unwind" fn(*const c_void) -> *const c_void>,
492 pub release: Option<unsafe extern "C-unwind" fn(*const c_void)>,
493 pub copyDescription: Option<unsafe extern "C-unwind" fn(*const c_void) -> *const CFString>,
494 pub equal: Option<unsafe extern "C-unwind" fn(*const c_void, *const c_void) -> Boolean>,
495 pub hash: Option<unsafe extern "C-unwind" fn(*const c_void) -> CFHashCode>,
496 pub getPort: Option<unsafe extern "C-unwind" fn(*mut c_void) -> libc::mach_port_t>,
497 pub perform: Option<
498 unsafe extern "C-unwind" fn(
499 *mut c_void,
500 CFIndex,
501 *const CFAllocator,
502 *mut c_void,
503 ) -> *mut c_void,
504 >,
505}
506
507#[cfg(all(feature = "libc", feature = "objc2"))]
508unsafe impl Encode for CFRunLoopSourceContext1 {
509 const ENCODING: Encoding = Encoding::Struct("?", &[
510 <CFIndex>::ENCODING,
511 <*mut c_void>::ENCODING,
512 <Option<unsafe extern "C-unwind" fn(*const c_void,) -> *const c_void>>::ENCODING,
513 <Option<unsafe extern "C-unwind" fn(*const c_void,)>>::ENCODING,
514 <Option<unsafe extern "C-unwind" fn(*const c_void,) -> *const CFString>>::ENCODING,
515 <Option<unsafe extern "C-unwind" fn(*const c_void,*const c_void,) -> Boolean>>::ENCODING,
516 <Option<unsafe extern "C-unwind" fn(*const c_void,) -> CFHashCode>>::ENCODING,
517 <Option<unsafe extern "C-unwind" fn(*mut c_void,) -> libc::mach_port_t>>::ENCODING,
518 <Option<unsafe extern "C-unwind" fn(*mut c_void,CFIndex,*const CFAllocator,*mut c_void,) -> *mut c_void>>::ENCODING,
519 ]);
520}
521
522#[cfg(all(feature = "libc", feature = "objc2"))]
523unsafe impl RefEncode for CFRunLoopSourceContext1 {
524 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
525}
526
527unsafe impl ConcreteType for CFRunLoopSource {
528 #[doc(alias = "CFRunLoopSourceGetTypeID")]
529 #[inline]
530 fn type_id() -> CFTypeID {
531 extern "C-unwind" {
532 fn CFRunLoopSourceGetTypeID() -> CFTypeID;
533 }
534 unsafe { CFRunLoopSourceGetTypeID() }
535 }
536}
537
538impl CFRunLoopSource {
539 #[doc(alias = "CFRunLoopSourceCreate")]
544 #[inline]
545 pub unsafe fn new(
546 allocator: Option<&CFAllocator>,
547 order: CFIndex,
548 context: *mut CFRunLoopSourceContext,
549 ) -> Option<CFRetained<CFRunLoopSource>> {
550 extern "C-unwind" {
551 fn CFRunLoopSourceCreate(
552 allocator: Option<&CFAllocator>,
553 order: CFIndex,
554 context: *mut CFRunLoopSourceContext,
555 ) -> Option<NonNull<CFRunLoopSource>>;
556 }
557 let ret = unsafe { CFRunLoopSourceCreate(allocator, order, context) };
558 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
559 }
560
561 #[doc(alias = "CFRunLoopSourceGetOrder")]
562 #[inline]
563 pub fn order(&self) -> CFIndex {
564 extern "C-unwind" {
565 fn CFRunLoopSourceGetOrder(source: &CFRunLoopSource) -> CFIndex;
566 }
567 unsafe { CFRunLoopSourceGetOrder(self) }
568 }
569
570 #[doc(alias = "CFRunLoopSourceInvalidate")]
571 #[inline]
572 pub fn invalidate(&self) {
573 extern "C-unwind" {
574 fn CFRunLoopSourceInvalidate(source: &CFRunLoopSource);
575 }
576 unsafe { CFRunLoopSourceInvalidate(self) }
577 }
578
579 #[doc(alias = "CFRunLoopSourceIsValid")]
580 #[inline]
581 pub fn is_valid(&self) -> bool {
582 extern "C-unwind" {
583 fn CFRunLoopSourceIsValid(source: &CFRunLoopSource) -> Boolean;
584 }
585 let ret = unsafe { CFRunLoopSourceIsValid(self) };
586 ret != 0
587 }
588
589 #[doc(alias = "CFRunLoopSourceGetContext")]
593 #[inline]
594 pub unsafe fn context(&self, context: *mut CFRunLoopSourceContext) {
595 extern "C-unwind" {
596 fn CFRunLoopSourceGetContext(
597 source: &CFRunLoopSource,
598 context: *mut CFRunLoopSourceContext,
599 );
600 }
601 unsafe { CFRunLoopSourceGetContext(self, context) }
602 }
603
604 #[doc(alias = "CFRunLoopSourceSignal")]
605 #[inline]
606 pub fn signal(&self) {
607 extern "C-unwind" {
608 fn CFRunLoopSourceSignal(source: &CFRunLoopSource);
609 }
610 unsafe { CFRunLoopSourceSignal(self) }
611 }
612}
613
614#[repr(C)]
616#[allow(unpredictable_function_pointer_comparisons)]
617#[derive(Clone, Copy, Debug, PartialEq)]
618pub struct CFRunLoopObserverContext {
619 pub version: CFIndex,
620 pub info: *mut c_void,
621 pub retain: Option<unsafe extern "C-unwind" fn(*const c_void) -> *const c_void>,
622 pub release: Option<unsafe extern "C-unwind" fn(*const c_void)>,
623 pub copyDescription: Option<unsafe extern "C-unwind" fn(*const c_void) -> *const CFString>,
624}
625
626#[cfg(feature = "objc2")]
627unsafe impl Encode for CFRunLoopObserverContext {
628 const ENCODING: Encoding = Encoding::Struct(
629 "?",
630 &[
631 <CFIndex>::ENCODING,
632 <*mut c_void>::ENCODING,
633 <Option<unsafe extern "C-unwind" fn(*const c_void) -> *const c_void>>::ENCODING,
634 <Option<unsafe extern "C-unwind" fn(*const c_void)>>::ENCODING,
635 <Option<unsafe extern "C-unwind" fn(*const c_void) -> *const CFString>>::ENCODING,
636 ],
637 );
638}
639
640#[cfg(feature = "objc2")]
641unsafe impl RefEncode for CFRunLoopObserverContext {
642 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
643}
644
645pub type CFRunLoopObserverCallBack =
647 Option<unsafe extern "C-unwind" fn(*mut CFRunLoopObserver, CFRunLoopActivity, *mut c_void)>;
648
649unsafe impl ConcreteType for CFRunLoopObserver {
650 #[doc(alias = "CFRunLoopObserverGetTypeID")]
651 #[inline]
652 fn type_id() -> CFTypeID {
653 extern "C-unwind" {
654 fn CFRunLoopObserverGetTypeID() -> CFTypeID;
655 }
656 unsafe { CFRunLoopObserverGetTypeID() }
657 }
658}
659
660impl CFRunLoopObserver {
661 #[doc(alias = "CFRunLoopObserverCreate")]
667 #[inline]
668 pub unsafe fn new(
669 allocator: Option<&CFAllocator>,
670 activities: CFOptionFlags,
671 repeats: bool,
672 order: CFIndex,
673 callout: CFRunLoopObserverCallBack,
674 context: *mut CFRunLoopObserverContext,
675 ) -> Option<CFRetained<CFRunLoopObserver>> {
676 extern "C-unwind" {
677 fn CFRunLoopObserverCreate(
678 allocator: Option<&CFAllocator>,
679 activities: CFOptionFlags,
680 repeats: Boolean,
681 order: CFIndex,
682 callout: CFRunLoopObserverCallBack,
683 context: *mut CFRunLoopObserverContext,
684 ) -> Option<NonNull<CFRunLoopObserver>>;
685 }
686 let ret = unsafe {
687 CFRunLoopObserverCreate(allocator, activities, repeats as _, order, callout, context)
688 };
689 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
690 }
691
692 #[doc(alias = "CFRunLoopObserverCreateWithHandler")]
697 #[cfg(feature = "block2")]
698 #[inline]
699 pub unsafe fn with_handler(
700 allocator: Option<&CFAllocator>,
701 activities: CFOptionFlags,
702 repeats: bool,
703 order: CFIndex,
704 block: Option<&block2::DynBlock<dyn Fn(*mut CFRunLoopObserver, CFRunLoopActivity)>>,
705 ) -> Option<CFRetained<CFRunLoopObserver>> {
706 extern "C-unwind" {
707 fn CFRunLoopObserverCreateWithHandler(
708 allocator: Option<&CFAllocator>,
709 activities: CFOptionFlags,
710 repeats: Boolean,
711 order: CFIndex,
712 block: Option<&block2::DynBlock<dyn Fn(*mut CFRunLoopObserver, CFRunLoopActivity)>>,
713 ) -> Option<NonNull<CFRunLoopObserver>>;
714 }
715 let ret = unsafe {
716 CFRunLoopObserverCreateWithHandler(allocator, activities, repeats as _, order, block)
717 };
718 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
719 }
720
721 #[doc(alias = "CFRunLoopObserverGetActivities")]
722 #[inline]
723 pub fn activities(&self) -> CFOptionFlags {
724 extern "C-unwind" {
725 fn CFRunLoopObserverGetActivities(observer: &CFRunLoopObserver) -> CFOptionFlags;
726 }
727 unsafe { CFRunLoopObserverGetActivities(self) }
728 }
729
730 #[doc(alias = "CFRunLoopObserverDoesRepeat")]
731 #[inline]
732 pub fn does_repeat(&self) -> bool {
733 extern "C-unwind" {
734 fn CFRunLoopObserverDoesRepeat(observer: &CFRunLoopObserver) -> Boolean;
735 }
736 let ret = unsafe { CFRunLoopObserverDoesRepeat(self) };
737 ret != 0
738 }
739
740 #[doc(alias = "CFRunLoopObserverGetOrder")]
741 #[inline]
742 pub fn order(&self) -> CFIndex {
743 extern "C-unwind" {
744 fn CFRunLoopObserverGetOrder(observer: &CFRunLoopObserver) -> CFIndex;
745 }
746 unsafe { CFRunLoopObserverGetOrder(self) }
747 }
748
749 #[doc(alias = "CFRunLoopObserverInvalidate")]
750 #[inline]
751 pub fn invalidate(&self) {
752 extern "C-unwind" {
753 fn CFRunLoopObserverInvalidate(observer: &CFRunLoopObserver);
754 }
755 unsafe { CFRunLoopObserverInvalidate(self) }
756 }
757
758 #[doc(alias = "CFRunLoopObserverIsValid")]
759 #[inline]
760 pub fn is_valid(&self) -> bool {
761 extern "C-unwind" {
762 fn CFRunLoopObserverIsValid(observer: &CFRunLoopObserver) -> Boolean;
763 }
764 let ret = unsafe { CFRunLoopObserverIsValid(self) };
765 ret != 0
766 }
767
768 #[doc(alias = "CFRunLoopObserverGetContext")]
772 #[inline]
773 pub unsafe fn context(&self, context: *mut CFRunLoopObserverContext) {
774 extern "C-unwind" {
775 fn CFRunLoopObserverGetContext(
776 observer: &CFRunLoopObserver,
777 context: *mut CFRunLoopObserverContext,
778 );
779 }
780 unsafe { CFRunLoopObserverGetContext(self, context) }
781 }
782}
783
784#[repr(C)]
786#[allow(unpredictable_function_pointer_comparisons)]
787#[derive(Clone, Copy, Debug, PartialEq)]
788pub struct CFRunLoopTimerContext {
789 pub version: CFIndex,
790 pub info: *mut c_void,
791 pub retain: Option<unsafe extern "C-unwind" fn(*const c_void) -> *const c_void>,
792 pub release: Option<unsafe extern "C-unwind" fn(*const c_void)>,
793 pub copyDescription: Option<unsafe extern "C-unwind" fn(*const c_void) -> *const CFString>,
794}
795
796#[cfg(feature = "objc2")]
797unsafe impl Encode for CFRunLoopTimerContext {
798 const ENCODING: Encoding = Encoding::Struct(
799 "?",
800 &[
801 <CFIndex>::ENCODING,
802 <*mut c_void>::ENCODING,
803 <Option<unsafe extern "C-unwind" fn(*const c_void) -> *const c_void>>::ENCODING,
804 <Option<unsafe extern "C-unwind" fn(*const c_void)>>::ENCODING,
805 <Option<unsafe extern "C-unwind" fn(*const c_void) -> *const CFString>>::ENCODING,
806 ],
807 );
808}
809
810#[cfg(feature = "objc2")]
811unsafe impl RefEncode for CFRunLoopTimerContext {
812 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
813}
814
815pub type CFRunLoopTimerCallBack =
817 Option<unsafe extern "C-unwind" fn(*mut CFRunLoopTimer, *mut c_void)>;
818
819unsafe impl ConcreteType for CFRunLoopTimer {
820 #[doc(alias = "CFRunLoopTimerGetTypeID")]
821 #[inline]
822 fn type_id() -> CFTypeID {
823 extern "C-unwind" {
824 fn CFRunLoopTimerGetTypeID() -> CFTypeID;
825 }
826 unsafe { CFRunLoopTimerGetTypeID() }
827 }
828}
829
830impl CFRunLoopTimer {
831 #[doc(alias = "CFRunLoopTimerCreate")]
837 #[cfg(feature = "CFDate")]
838 #[inline]
839 pub unsafe fn new(
840 allocator: Option<&CFAllocator>,
841 fire_date: CFAbsoluteTime,
842 interval: CFTimeInterval,
843 flags: CFOptionFlags,
844 order: CFIndex,
845 callout: CFRunLoopTimerCallBack,
846 context: *mut CFRunLoopTimerContext,
847 ) -> Option<CFRetained<CFRunLoopTimer>> {
848 extern "C-unwind" {
849 fn CFRunLoopTimerCreate(
850 allocator: Option<&CFAllocator>,
851 fire_date: CFAbsoluteTime,
852 interval: CFTimeInterval,
853 flags: CFOptionFlags,
854 order: CFIndex,
855 callout: CFRunLoopTimerCallBack,
856 context: *mut CFRunLoopTimerContext,
857 ) -> Option<NonNull<CFRunLoopTimer>>;
858 }
859 let ret = unsafe {
860 CFRunLoopTimerCreate(
861 allocator, fire_date, interval, flags, order, callout, context,
862 )
863 };
864 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
865 }
866
867 #[doc(alias = "CFRunLoopTimerCreateWithHandler")]
872 #[cfg(all(feature = "CFDate", feature = "block2"))]
873 #[inline]
874 pub unsafe fn with_handler(
875 allocator: Option<&CFAllocator>,
876 fire_date: CFAbsoluteTime,
877 interval: CFTimeInterval,
878 flags: CFOptionFlags,
879 order: CFIndex,
880 block: Option<&block2::DynBlock<dyn Fn(*mut CFRunLoopTimer)>>,
881 ) -> Option<CFRetained<CFRunLoopTimer>> {
882 extern "C-unwind" {
883 fn CFRunLoopTimerCreateWithHandler(
884 allocator: Option<&CFAllocator>,
885 fire_date: CFAbsoluteTime,
886 interval: CFTimeInterval,
887 flags: CFOptionFlags,
888 order: CFIndex,
889 block: Option<&block2::DynBlock<dyn Fn(*mut CFRunLoopTimer)>>,
890 ) -> Option<NonNull<CFRunLoopTimer>>;
891 }
892 let ret = unsafe {
893 CFRunLoopTimerCreateWithHandler(allocator, fire_date, interval, flags, order, block)
894 };
895 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
896 }
897
898 #[doc(alias = "CFRunLoopTimerGetNextFireDate")]
899 #[cfg(feature = "CFDate")]
900 #[inline]
901 pub fn next_fire_date(&self) -> CFAbsoluteTime {
902 extern "C-unwind" {
903 fn CFRunLoopTimerGetNextFireDate(timer: &CFRunLoopTimer) -> CFAbsoluteTime;
904 }
905 unsafe { CFRunLoopTimerGetNextFireDate(self) }
906 }
907
908 #[doc(alias = "CFRunLoopTimerSetNextFireDate")]
909 #[cfg(feature = "CFDate")]
910 #[inline]
911 pub fn set_next_fire_date(&self, fire_date: CFAbsoluteTime) {
912 extern "C-unwind" {
913 fn CFRunLoopTimerSetNextFireDate(timer: &CFRunLoopTimer, fire_date: CFAbsoluteTime);
914 }
915 unsafe { CFRunLoopTimerSetNextFireDate(self, fire_date) }
916 }
917
918 #[doc(alias = "CFRunLoopTimerGetInterval")]
919 #[cfg(feature = "CFDate")]
920 #[inline]
921 pub fn interval(&self) -> CFTimeInterval {
922 extern "C-unwind" {
923 fn CFRunLoopTimerGetInterval(timer: &CFRunLoopTimer) -> CFTimeInterval;
924 }
925 unsafe { CFRunLoopTimerGetInterval(self) }
926 }
927
928 #[doc(alias = "CFRunLoopTimerDoesRepeat")]
929 #[inline]
930 pub fn does_repeat(&self) -> bool {
931 extern "C-unwind" {
932 fn CFRunLoopTimerDoesRepeat(timer: &CFRunLoopTimer) -> Boolean;
933 }
934 let ret = unsafe { CFRunLoopTimerDoesRepeat(self) };
935 ret != 0
936 }
937
938 #[doc(alias = "CFRunLoopTimerGetOrder")]
939 #[inline]
940 pub fn order(&self) -> CFIndex {
941 extern "C-unwind" {
942 fn CFRunLoopTimerGetOrder(timer: &CFRunLoopTimer) -> CFIndex;
943 }
944 unsafe { CFRunLoopTimerGetOrder(self) }
945 }
946
947 #[doc(alias = "CFRunLoopTimerInvalidate")]
948 #[inline]
949 pub fn invalidate(&self) {
950 extern "C-unwind" {
951 fn CFRunLoopTimerInvalidate(timer: &CFRunLoopTimer);
952 }
953 unsafe { CFRunLoopTimerInvalidate(self) }
954 }
955
956 #[doc(alias = "CFRunLoopTimerIsValid")]
957 #[inline]
958 pub fn is_valid(&self) -> bool {
959 extern "C-unwind" {
960 fn CFRunLoopTimerIsValid(timer: &CFRunLoopTimer) -> Boolean;
961 }
962 let ret = unsafe { CFRunLoopTimerIsValid(self) };
963 ret != 0
964 }
965
966 #[doc(alias = "CFRunLoopTimerGetContext")]
970 #[inline]
971 pub unsafe fn context(&self, context: *mut CFRunLoopTimerContext) {
972 extern "C-unwind" {
973 fn CFRunLoopTimerGetContext(
974 timer: &CFRunLoopTimer,
975 context: *mut CFRunLoopTimerContext,
976 );
977 }
978 unsafe { CFRunLoopTimerGetContext(self, context) }
979 }
980
981 #[doc(alias = "CFRunLoopTimerGetTolerance")]
982 #[cfg(feature = "CFDate")]
983 #[inline]
984 pub fn tolerance(&self) -> CFTimeInterval {
985 extern "C-unwind" {
986 fn CFRunLoopTimerGetTolerance(timer: &CFRunLoopTimer) -> CFTimeInterval;
987 }
988 unsafe { CFRunLoopTimerGetTolerance(self) }
989 }
990
991 #[doc(alias = "CFRunLoopTimerSetTolerance")]
992 #[cfg(feature = "CFDate")]
993 #[inline]
994 pub unsafe fn set_tolerance(&self, tolerance: CFTimeInterval) {
995 extern "C-unwind" {
996 fn CFRunLoopTimerSetTolerance(timer: &CFRunLoopTimer, tolerance: CFTimeInterval);
997 }
998 unsafe { CFRunLoopTimerSetTolerance(self, tolerance) }
999 }
1000}
1001
1002#[deprecated = "renamed to `CFRunLoop::current`"]
1003#[inline]
1004pub extern "C-unwind" fn CFRunLoopGetCurrent() -> Option<CFRetained<CFRunLoop>> {
1005 extern "C-unwind" {
1006 fn CFRunLoopGetCurrent() -> Option<NonNull<CFRunLoop>>;
1007 }
1008 let ret = unsafe { CFRunLoopGetCurrent() };
1009 ret.map(|ret| unsafe { CFRetained::retain(ret) })
1010}
1011
1012#[deprecated = "renamed to `CFRunLoop::main`"]
1013#[inline]
1014pub extern "C-unwind" fn CFRunLoopGetMain() -> Option<CFRetained<CFRunLoop>> {
1015 extern "C-unwind" {
1016 fn CFRunLoopGetMain() -> Option<NonNull<CFRunLoop>>;
1017 }
1018 let ret = unsafe { CFRunLoopGetMain() };
1019 ret.map(|ret| unsafe { CFRetained::retain(ret) })
1020}
1021
1022#[deprecated = "renamed to `CFRunLoop::current_mode`"]
1023#[inline]
1024pub extern "C-unwind" fn CFRunLoopCopyCurrentMode(
1025 rl: &CFRunLoop,
1026) -> Option<CFRetained<CFRunLoopMode>> {
1027 extern "C-unwind" {
1028 fn CFRunLoopCopyCurrentMode(rl: &CFRunLoop) -> Option<NonNull<CFRunLoopMode>>;
1029 }
1030 let ret = unsafe { CFRunLoopCopyCurrentMode(rl) };
1031 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1032}
1033
1034#[cfg(feature = "CFArray")]
1035#[deprecated = "renamed to `CFRunLoop::all_modes`"]
1036#[inline]
1037pub extern "C-unwind" fn CFRunLoopCopyAllModes(rl: &CFRunLoop) -> Option<CFRetained<CFArray>> {
1038 extern "C-unwind" {
1039 fn CFRunLoopCopyAllModes(rl: &CFRunLoop) -> Option<NonNull<CFArray>>;
1040 }
1041 let ret = unsafe { CFRunLoopCopyAllModes(rl) };
1042 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1043}
1044
1045#[deprecated = "renamed to `CFRunLoop::add_common_mode`"]
1046#[inline]
1047pub extern "C-unwind" fn CFRunLoopAddCommonMode(rl: &CFRunLoop, mode: Option<&CFRunLoopMode>) {
1048 extern "C-unwind" {
1049 fn CFRunLoopAddCommonMode(rl: &CFRunLoop, mode: Option<&CFRunLoopMode>);
1050 }
1051 unsafe { CFRunLoopAddCommonMode(rl, mode) }
1052}
1053
1054#[cfg(feature = "CFDate")]
1055#[deprecated = "renamed to `CFRunLoop::next_timer_fire_date`"]
1056#[inline]
1057pub extern "C-unwind" fn CFRunLoopGetNextTimerFireDate(
1058 rl: &CFRunLoop,
1059 mode: Option<&CFRunLoopMode>,
1060) -> CFAbsoluteTime {
1061 extern "C-unwind" {
1062 fn CFRunLoopGetNextTimerFireDate(
1063 rl: &CFRunLoop,
1064 mode: Option<&CFRunLoopMode>,
1065 ) -> CFAbsoluteTime;
1066 }
1067 unsafe { CFRunLoopGetNextTimerFireDate(rl, mode) }
1068}
1069
1070#[deprecated = "renamed to `CFRunLoop::run`"]
1071#[inline]
1072pub extern "C-unwind" fn CFRunLoopRun() {
1073 extern "C-unwind" {
1074 fn CFRunLoopRun();
1075 }
1076 unsafe { CFRunLoopRun() }
1077}
1078
1079#[cfg(feature = "CFDate")]
1080#[deprecated = "renamed to `CFRunLoop::run_in_mode`"]
1081#[inline]
1082pub extern "C-unwind" fn CFRunLoopRunInMode(
1083 mode: Option<&CFRunLoopMode>,
1084 seconds: CFTimeInterval,
1085 return_after_source_handled: bool,
1086) -> CFRunLoopRunResult {
1087 extern "C-unwind" {
1088 fn CFRunLoopRunInMode(
1089 mode: Option<&CFRunLoopMode>,
1090 seconds: CFTimeInterval,
1091 return_after_source_handled: Boolean,
1092 ) -> CFRunLoopRunResult;
1093 }
1094 unsafe { CFRunLoopRunInMode(mode, seconds, return_after_source_handled as _) }
1095}
1096
1097#[deprecated = "renamed to `CFRunLoop::is_waiting`"]
1098#[inline]
1099pub extern "C-unwind" fn CFRunLoopIsWaiting(rl: &CFRunLoop) -> bool {
1100 extern "C-unwind" {
1101 fn CFRunLoopIsWaiting(rl: &CFRunLoop) -> Boolean;
1102 }
1103 let ret = unsafe { CFRunLoopIsWaiting(rl) };
1104 ret != 0
1105}
1106
1107#[deprecated = "renamed to `CFRunLoop::wake_up`"]
1108#[inline]
1109pub extern "C-unwind" fn CFRunLoopWakeUp(rl: &CFRunLoop) {
1110 extern "C-unwind" {
1111 fn CFRunLoopWakeUp(rl: &CFRunLoop);
1112 }
1113 unsafe { CFRunLoopWakeUp(rl) }
1114}
1115
1116#[deprecated = "renamed to `CFRunLoop::stop`"]
1117#[inline]
1118pub extern "C-unwind" fn CFRunLoopStop(rl: &CFRunLoop) {
1119 extern "C-unwind" {
1120 fn CFRunLoopStop(rl: &CFRunLoop);
1121 }
1122 unsafe { CFRunLoopStop(rl) }
1123}
1124
1125extern "C-unwind" {
1126 #[cfg(feature = "block2")]
1127 #[deprecated = "renamed to `CFRunLoop::perform_block`"]
1128 pub fn CFRunLoopPerformBlock(
1129 rl: &CFRunLoop,
1130 mode: Option<&CFType>,
1131 block: Option<&block2::DynBlock<dyn Fn()>>,
1132 );
1133}
1134
1135#[deprecated = "renamed to `CFRunLoop::contains_source`"]
1136#[inline]
1137pub extern "C-unwind" fn CFRunLoopContainsSource(
1138 rl: &CFRunLoop,
1139 source: Option<&CFRunLoopSource>,
1140 mode: Option<&CFRunLoopMode>,
1141) -> bool {
1142 extern "C-unwind" {
1143 fn CFRunLoopContainsSource(
1144 rl: &CFRunLoop,
1145 source: Option<&CFRunLoopSource>,
1146 mode: Option<&CFRunLoopMode>,
1147 ) -> Boolean;
1148 }
1149 let ret = unsafe { CFRunLoopContainsSource(rl, source, mode) };
1150 ret != 0
1151}
1152
1153#[deprecated = "renamed to `CFRunLoop::add_source`"]
1154#[inline]
1155pub extern "C-unwind" fn CFRunLoopAddSource(
1156 rl: &CFRunLoop,
1157 source: Option<&CFRunLoopSource>,
1158 mode: Option<&CFRunLoopMode>,
1159) {
1160 extern "C-unwind" {
1161 fn CFRunLoopAddSource(
1162 rl: &CFRunLoop,
1163 source: Option<&CFRunLoopSource>,
1164 mode: Option<&CFRunLoopMode>,
1165 );
1166 }
1167 unsafe { CFRunLoopAddSource(rl, source, mode) }
1168}
1169
1170#[deprecated = "renamed to `CFRunLoop::remove_source`"]
1171#[inline]
1172pub extern "C-unwind" fn CFRunLoopRemoveSource(
1173 rl: &CFRunLoop,
1174 source: Option<&CFRunLoopSource>,
1175 mode: Option<&CFRunLoopMode>,
1176) {
1177 extern "C-unwind" {
1178 fn CFRunLoopRemoveSource(
1179 rl: &CFRunLoop,
1180 source: Option<&CFRunLoopSource>,
1181 mode: Option<&CFRunLoopMode>,
1182 );
1183 }
1184 unsafe { CFRunLoopRemoveSource(rl, source, mode) }
1185}
1186
1187#[deprecated = "renamed to `CFRunLoop::contains_observer`"]
1188#[inline]
1189pub extern "C-unwind" fn CFRunLoopContainsObserver(
1190 rl: &CFRunLoop,
1191 observer: Option<&CFRunLoopObserver>,
1192 mode: Option<&CFRunLoopMode>,
1193) -> bool {
1194 extern "C-unwind" {
1195 fn CFRunLoopContainsObserver(
1196 rl: &CFRunLoop,
1197 observer: Option<&CFRunLoopObserver>,
1198 mode: Option<&CFRunLoopMode>,
1199 ) -> Boolean;
1200 }
1201 let ret = unsafe { CFRunLoopContainsObserver(rl, observer, mode) };
1202 ret != 0
1203}
1204
1205#[deprecated = "renamed to `CFRunLoop::add_observer`"]
1206#[inline]
1207pub extern "C-unwind" fn CFRunLoopAddObserver(
1208 rl: &CFRunLoop,
1209 observer: Option<&CFRunLoopObserver>,
1210 mode: Option<&CFRunLoopMode>,
1211) {
1212 extern "C-unwind" {
1213 fn CFRunLoopAddObserver(
1214 rl: &CFRunLoop,
1215 observer: Option<&CFRunLoopObserver>,
1216 mode: Option<&CFRunLoopMode>,
1217 );
1218 }
1219 unsafe { CFRunLoopAddObserver(rl, observer, mode) }
1220}
1221
1222#[deprecated = "renamed to `CFRunLoop::remove_observer`"]
1223#[inline]
1224pub extern "C-unwind" fn CFRunLoopRemoveObserver(
1225 rl: &CFRunLoop,
1226 observer: Option<&CFRunLoopObserver>,
1227 mode: Option<&CFRunLoopMode>,
1228) {
1229 extern "C-unwind" {
1230 fn CFRunLoopRemoveObserver(
1231 rl: &CFRunLoop,
1232 observer: Option<&CFRunLoopObserver>,
1233 mode: Option<&CFRunLoopMode>,
1234 );
1235 }
1236 unsafe { CFRunLoopRemoveObserver(rl, observer, mode) }
1237}
1238
1239#[deprecated = "renamed to `CFRunLoop::contains_timer`"]
1240#[inline]
1241pub extern "C-unwind" fn CFRunLoopContainsTimer(
1242 rl: &CFRunLoop,
1243 timer: Option<&CFRunLoopTimer>,
1244 mode: Option<&CFRunLoopMode>,
1245) -> bool {
1246 extern "C-unwind" {
1247 fn CFRunLoopContainsTimer(
1248 rl: &CFRunLoop,
1249 timer: Option<&CFRunLoopTimer>,
1250 mode: Option<&CFRunLoopMode>,
1251 ) -> Boolean;
1252 }
1253 let ret = unsafe { CFRunLoopContainsTimer(rl, timer, mode) };
1254 ret != 0
1255}
1256
1257#[deprecated = "renamed to `CFRunLoop::add_timer`"]
1258#[inline]
1259pub extern "C-unwind" fn CFRunLoopAddTimer(
1260 rl: &CFRunLoop,
1261 timer: Option<&CFRunLoopTimer>,
1262 mode: Option<&CFRunLoopMode>,
1263) {
1264 extern "C-unwind" {
1265 fn CFRunLoopAddTimer(
1266 rl: &CFRunLoop,
1267 timer: Option<&CFRunLoopTimer>,
1268 mode: Option<&CFRunLoopMode>,
1269 );
1270 }
1271 unsafe { CFRunLoopAddTimer(rl, timer, mode) }
1272}
1273
1274#[deprecated = "renamed to `CFRunLoop::remove_timer`"]
1275#[inline]
1276pub extern "C-unwind" fn CFRunLoopRemoveTimer(
1277 rl: &CFRunLoop,
1278 timer: Option<&CFRunLoopTimer>,
1279 mode: Option<&CFRunLoopMode>,
1280) {
1281 extern "C-unwind" {
1282 fn CFRunLoopRemoveTimer(
1283 rl: &CFRunLoop,
1284 timer: Option<&CFRunLoopTimer>,
1285 mode: Option<&CFRunLoopMode>,
1286 );
1287 }
1288 unsafe { CFRunLoopRemoveTimer(rl, timer, mode) }
1289}
1290
1291#[deprecated = "renamed to `CFRunLoopSource::new`"]
1292#[inline]
1293pub unsafe extern "C-unwind" fn CFRunLoopSourceCreate(
1294 allocator: Option<&CFAllocator>,
1295 order: CFIndex,
1296 context: *mut CFRunLoopSourceContext,
1297) -> Option<CFRetained<CFRunLoopSource>> {
1298 extern "C-unwind" {
1299 fn CFRunLoopSourceCreate(
1300 allocator: Option<&CFAllocator>,
1301 order: CFIndex,
1302 context: *mut CFRunLoopSourceContext,
1303 ) -> Option<NonNull<CFRunLoopSource>>;
1304 }
1305 let ret = unsafe { CFRunLoopSourceCreate(allocator, order, context) };
1306 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1307}
1308
1309#[deprecated = "renamed to `CFRunLoopSource::order`"]
1310#[inline]
1311pub extern "C-unwind" fn CFRunLoopSourceGetOrder(source: &CFRunLoopSource) -> CFIndex {
1312 extern "C-unwind" {
1313 fn CFRunLoopSourceGetOrder(source: &CFRunLoopSource) -> CFIndex;
1314 }
1315 unsafe { CFRunLoopSourceGetOrder(source) }
1316}
1317
1318#[deprecated = "renamed to `CFRunLoopSource::invalidate`"]
1319#[inline]
1320pub extern "C-unwind" fn CFRunLoopSourceInvalidate(source: &CFRunLoopSource) {
1321 extern "C-unwind" {
1322 fn CFRunLoopSourceInvalidate(source: &CFRunLoopSource);
1323 }
1324 unsafe { CFRunLoopSourceInvalidate(source) }
1325}
1326
1327#[deprecated = "renamed to `CFRunLoopSource::is_valid`"]
1328#[inline]
1329pub extern "C-unwind" fn CFRunLoopSourceIsValid(source: &CFRunLoopSource) -> bool {
1330 extern "C-unwind" {
1331 fn CFRunLoopSourceIsValid(source: &CFRunLoopSource) -> Boolean;
1332 }
1333 let ret = unsafe { CFRunLoopSourceIsValid(source) };
1334 ret != 0
1335}
1336
1337extern "C-unwind" {
1338 #[deprecated = "renamed to `CFRunLoopSource::context`"]
1339 pub fn CFRunLoopSourceGetContext(
1340 source: &CFRunLoopSource,
1341 context: *mut CFRunLoopSourceContext,
1342 );
1343}
1344
1345#[deprecated = "renamed to `CFRunLoopSource::signal`"]
1346#[inline]
1347pub extern "C-unwind" fn CFRunLoopSourceSignal(source: &CFRunLoopSource) {
1348 extern "C-unwind" {
1349 fn CFRunLoopSourceSignal(source: &CFRunLoopSource);
1350 }
1351 unsafe { CFRunLoopSourceSignal(source) }
1352}
1353
1354#[deprecated = "renamed to `CFRunLoopObserver::new`"]
1355#[inline]
1356pub unsafe extern "C-unwind" fn CFRunLoopObserverCreate(
1357 allocator: Option<&CFAllocator>,
1358 activities: CFOptionFlags,
1359 repeats: bool,
1360 order: CFIndex,
1361 callout: CFRunLoopObserverCallBack,
1362 context: *mut CFRunLoopObserverContext,
1363) -> Option<CFRetained<CFRunLoopObserver>> {
1364 extern "C-unwind" {
1365 fn CFRunLoopObserverCreate(
1366 allocator: Option<&CFAllocator>,
1367 activities: CFOptionFlags,
1368 repeats: Boolean,
1369 order: CFIndex,
1370 callout: CFRunLoopObserverCallBack,
1371 context: *mut CFRunLoopObserverContext,
1372 ) -> Option<NonNull<CFRunLoopObserver>>;
1373 }
1374 let ret = unsafe {
1375 CFRunLoopObserverCreate(allocator, activities, repeats as _, order, callout, context)
1376 };
1377 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1378}
1379
1380#[cfg(feature = "block2")]
1381#[deprecated = "renamed to `CFRunLoopObserver::with_handler`"]
1382#[inline]
1383pub unsafe extern "C-unwind" fn CFRunLoopObserverCreateWithHandler(
1384 allocator: Option<&CFAllocator>,
1385 activities: CFOptionFlags,
1386 repeats: bool,
1387 order: CFIndex,
1388 block: Option<&block2::DynBlock<dyn Fn(*mut CFRunLoopObserver, CFRunLoopActivity)>>,
1389) -> Option<CFRetained<CFRunLoopObserver>> {
1390 extern "C-unwind" {
1391 fn CFRunLoopObserverCreateWithHandler(
1392 allocator: Option<&CFAllocator>,
1393 activities: CFOptionFlags,
1394 repeats: Boolean,
1395 order: CFIndex,
1396 block: Option<&block2::DynBlock<dyn Fn(*mut CFRunLoopObserver, CFRunLoopActivity)>>,
1397 ) -> Option<NonNull<CFRunLoopObserver>>;
1398 }
1399 let ret = unsafe {
1400 CFRunLoopObserverCreateWithHandler(allocator, activities, repeats as _, order, block)
1401 };
1402 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1403}
1404
1405#[deprecated = "renamed to `CFRunLoopObserver::activities`"]
1406#[inline]
1407pub extern "C-unwind" fn CFRunLoopObserverGetActivities(
1408 observer: &CFRunLoopObserver,
1409) -> CFOptionFlags {
1410 extern "C-unwind" {
1411 fn CFRunLoopObserverGetActivities(observer: &CFRunLoopObserver) -> CFOptionFlags;
1412 }
1413 unsafe { CFRunLoopObserverGetActivities(observer) }
1414}
1415
1416#[deprecated = "renamed to `CFRunLoopObserver::does_repeat`"]
1417#[inline]
1418pub extern "C-unwind" fn CFRunLoopObserverDoesRepeat(observer: &CFRunLoopObserver) -> bool {
1419 extern "C-unwind" {
1420 fn CFRunLoopObserverDoesRepeat(observer: &CFRunLoopObserver) -> Boolean;
1421 }
1422 let ret = unsafe { CFRunLoopObserverDoesRepeat(observer) };
1423 ret != 0
1424}
1425
1426#[deprecated = "renamed to `CFRunLoopObserver::order`"]
1427#[inline]
1428pub extern "C-unwind" fn CFRunLoopObserverGetOrder(observer: &CFRunLoopObserver) -> CFIndex {
1429 extern "C-unwind" {
1430 fn CFRunLoopObserverGetOrder(observer: &CFRunLoopObserver) -> CFIndex;
1431 }
1432 unsafe { CFRunLoopObserverGetOrder(observer) }
1433}
1434
1435#[deprecated = "renamed to `CFRunLoopObserver::invalidate`"]
1436#[inline]
1437pub extern "C-unwind" fn CFRunLoopObserverInvalidate(observer: &CFRunLoopObserver) {
1438 extern "C-unwind" {
1439 fn CFRunLoopObserverInvalidate(observer: &CFRunLoopObserver);
1440 }
1441 unsafe { CFRunLoopObserverInvalidate(observer) }
1442}
1443
1444#[deprecated = "renamed to `CFRunLoopObserver::is_valid`"]
1445#[inline]
1446pub extern "C-unwind" fn CFRunLoopObserverIsValid(observer: &CFRunLoopObserver) -> bool {
1447 extern "C-unwind" {
1448 fn CFRunLoopObserverIsValid(observer: &CFRunLoopObserver) -> Boolean;
1449 }
1450 let ret = unsafe { CFRunLoopObserverIsValid(observer) };
1451 ret != 0
1452}
1453
1454extern "C-unwind" {
1455 #[deprecated = "renamed to `CFRunLoopObserver::context`"]
1456 pub fn CFRunLoopObserverGetContext(
1457 observer: &CFRunLoopObserver,
1458 context: *mut CFRunLoopObserverContext,
1459 );
1460}
1461
1462#[cfg(feature = "CFDate")]
1463#[deprecated = "renamed to `CFRunLoopTimer::new`"]
1464#[inline]
1465pub unsafe extern "C-unwind" fn CFRunLoopTimerCreate(
1466 allocator: Option<&CFAllocator>,
1467 fire_date: CFAbsoluteTime,
1468 interval: CFTimeInterval,
1469 flags: CFOptionFlags,
1470 order: CFIndex,
1471 callout: CFRunLoopTimerCallBack,
1472 context: *mut CFRunLoopTimerContext,
1473) -> Option<CFRetained<CFRunLoopTimer>> {
1474 extern "C-unwind" {
1475 fn CFRunLoopTimerCreate(
1476 allocator: Option<&CFAllocator>,
1477 fire_date: CFAbsoluteTime,
1478 interval: CFTimeInterval,
1479 flags: CFOptionFlags,
1480 order: CFIndex,
1481 callout: CFRunLoopTimerCallBack,
1482 context: *mut CFRunLoopTimerContext,
1483 ) -> Option<NonNull<CFRunLoopTimer>>;
1484 }
1485 let ret = unsafe {
1486 CFRunLoopTimerCreate(
1487 allocator, fire_date, interval, flags, order, callout, context,
1488 )
1489 };
1490 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1491}
1492
1493#[cfg(all(feature = "CFDate", feature = "block2"))]
1494#[deprecated = "renamed to `CFRunLoopTimer::with_handler`"]
1495#[inline]
1496pub unsafe extern "C-unwind" fn CFRunLoopTimerCreateWithHandler(
1497 allocator: Option<&CFAllocator>,
1498 fire_date: CFAbsoluteTime,
1499 interval: CFTimeInterval,
1500 flags: CFOptionFlags,
1501 order: CFIndex,
1502 block: Option<&block2::DynBlock<dyn Fn(*mut CFRunLoopTimer)>>,
1503) -> Option<CFRetained<CFRunLoopTimer>> {
1504 extern "C-unwind" {
1505 fn CFRunLoopTimerCreateWithHandler(
1506 allocator: Option<&CFAllocator>,
1507 fire_date: CFAbsoluteTime,
1508 interval: CFTimeInterval,
1509 flags: CFOptionFlags,
1510 order: CFIndex,
1511 block: Option<&block2::DynBlock<dyn Fn(*mut CFRunLoopTimer)>>,
1512 ) -> Option<NonNull<CFRunLoopTimer>>;
1513 }
1514 let ret = unsafe {
1515 CFRunLoopTimerCreateWithHandler(allocator, fire_date, interval, flags, order, block)
1516 };
1517 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1518}
1519
1520#[cfg(feature = "CFDate")]
1521#[deprecated = "renamed to `CFRunLoopTimer::next_fire_date`"]
1522#[inline]
1523pub extern "C-unwind" fn CFRunLoopTimerGetNextFireDate(timer: &CFRunLoopTimer) -> CFAbsoluteTime {
1524 extern "C-unwind" {
1525 fn CFRunLoopTimerGetNextFireDate(timer: &CFRunLoopTimer) -> CFAbsoluteTime;
1526 }
1527 unsafe { CFRunLoopTimerGetNextFireDate(timer) }
1528}
1529
1530#[cfg(feature = "CFDate")]
1531#[deprecated = "renamed to `CFRunLoopTimer::set_next_fire_date`"]
1532#[inline]
1533pub extern "C-unwind" fn CFRunLoopTimerSetNextFireDate(
1534 timer: &CFRunLoopTimer,
1535 fire_date: CFAbsoluteTime,
1536) {
1537 extern "C-unwind" {
1538 fn CFRunLoopTimerSetNextFireDate(timer: &CFRunLoopTimer, fire_date: CFAbsoluteTime);
1539 }
1540 unsafe { CFRunLoopTimerSetNextFireDate(timer, fire_date) }
1541}
1542
1543#[cfg(feature = "CFDate")]
1544#[deprecated = "renamed to `CFRunLoopTimer::interval`"]
1545#[inline]
1546pub extern "C-unwind" fn CFRunLoopTimerGetInterval(timer: &CFRunLoopTimer) -> CFTimeInterval {
1547 extern "C-unwind" {
1548 fn CFRunLoopTimerGetInterval(timer: &CFRunLoopTimer) -> CFTimeInterval;
1549 }
1550 unsafe { CFRunLoopTimerGetInterval(timer) }
1551}
1552
1553#[deprecated = "renamed to `CFRunLoopTimer::does_repeat`"]
1554#[inline]
1555pub extern "C-unwind" fn CFRunLoopTimerDoesRepeat(timer: &CFRunLoopTimer) -> bool {
1556 extern "C-unwind" {
1557 fn CFRunLoopTimerDoesRepeat(timer: &CFRunLoopTimer) -> Boolean;
1558 }
1559 let ret = unsafe { CFRunLoopTimerDoesRepeat(timer) };
1560 ret != 0
1561}
1562
1563#[deprecated = "renamed to `CFRunLoopTimer::order`"]
1564#[inline]
1565pub extern "C-unwind" fn CFRunLoopTimerGetOrder(timer: &CFRunLoopTimer) -> CFIndex {
1566 extern "C-unwind" {
1567 fn CFRunLoopTimerGetOrder(timer: &CFRunLoopTimer) -> CFIndex;
1568 }
1569 unsafe { CFRunLoopTimerGetOrder(timer) }
1570}
1571
1572#[deprecated = "renamed to `CFRunLoopTimer::invalidate`"]
1573#[inline]
1574pub extern "C-unwind" fn CFRunLoopTimerInvalidate(timer: &CFRunLoopTimer) {
1575 extern "C-unwind" {
1576 fn CFRunLoopTimerInvalidate(timer: &CFRunLoopTimer);
1577 }
1578 unsafe { CFRunLoopTimerInvalidate(timer) }
1579}
1580
1581#[deprecated = "renamed to `CFRunLoopTimer::is_valid`"]
1582#[inline]
1583pub extern "C-unwind" fn CFRunLoopTimerIsValid(timer: &CFRunLoopTimer) -> bool {
1584 extern "C-unwind" {
1585 fn CFRunLoopTimerIsValid(timer: &CFRunLoopTimer) -> Boolean;
1586 }
1587 let ret = unsafe { CFRunLoopTimerIsValid(timer) };
1588 ret != 0
1589}
1590
1591extern "C-unwind" {
1592 #[deprecated = "renamed to `CFRunLoopTimer::context`"]
1593 pub fn CFRunLoopTimerGetContext(timer: &CFRunLoopTimer, context: *mut CFRunLoopTimerContext);
1594}
1595
1596#[cfg(feature = "CFDate")]
1597#[deprecated = "renamed to `CFRunLoopTimer::tolerance`"]
1598#[inline]
1599pub extern "C-unwind" fn CFRunLoopTimerGetTolerance(timer: &CFRunLoopTimer) -> CFTimeInterval {
1600 extern "C-unwind" {
1601 fn CFRunLoopTimerGetTolerance(timer: &CFRunLoopTimer) -> CFTimeInterval;
1602 }
1603 unsafe { CFRunLoopTimerGetTolerance(timer) }
1604}
1605
1606extern "C-unwind" {
1607 #[cfg(feature = "CFDate")]
1608 #[deprecated = "renamed to `CFRunLoopTimer::set_tolerance`"]
1609 pub fn CFRunLoopTimerSetTolerance(timer: &CFRunLoopTimer, tolerance: CFTimeInterval);
1610}