objc2_core_foundation/generated/
CFNotificationCenter.rs1use 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
12#[cfg(feature = "CFBase")]
15pub type CFNotificationName = CFString;
16
17#[repr(C)]
19pub struct CFNotificationCenter {
20 inner: [u8; 0],
21 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
22}
23
24cf_type!(
25 #[encoding_name = "__CFNotificationCenter"]
26 unsafe impl CFNotificationCenter {}
27);
28
29#[cfg(all(feature = "CFBase", feature = "CFDictionary"))]
31pub type CFNotificationCallback = Option<
32 unsafe extern "C-unwind" fn(
33 *mut CFNotificationCenter,
34 *mut c_void,
35 *const CFNotificationName,
36 *const c_void,
37 *const CFDictionary,
38 ),
39>;
40
41#[cfg(feature = "CFBase")]
44#[repr(transparent)]
45#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
46pub struct CFNotificationSuspensionBehavior(pub CFIndex);
47#[cfg(feature = "CFBase")]
48impl CFNotificationSuspensionBehavior {
49 #[doc(alias = "CFNotificationSuspensionBehaviorDrop")]
50 pub const Drop: Self = Self(1);
51 #[doc(alias = "CFNotificationSuspensionBehaviorCoalesce")]
52 pub const Coalesce: Self = Self(2);
53 #[doc(alias = "CFNotificationSuspensionBehaviorHold")]
54 pub const Hold: Self = Self(3);
55 #[doc(alias = "CFNotificationSuspensionBehaviorDeliverImmediately")]
56 pub const DeliverImmediately: Self = Self(4);
57}
58
59#[cfg(all(feature = "CFBase", feature = "objc2"))]
60unsafe impl Encode for CFNotificationSuspensionBehavior {
61 const ENCODING: Encoding = CFIndex::ENCODING;
62}
63
64#[cfg(all(feature = "CFBase", feature = "objc2"))]
65unsafe impl RefEncode for CFNotificationSuspensionBehavior {
66 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
67}
68
69#[cfg(feature = "CFBase")]
70unsafe impl ConcreteType for CFNotificationCenter {
71 #[doc(alias = "CFNotificationCenterGetTypeID")]
72 #[inline]
73 fn type_id() -> CFTypeID {
74 extern "C-unwind" {
75 fn CFNotificationCenterGetTypeID() -> CFTypeID;
76 }
77 unsafe { CFNotificationCenterGetTypeID() }
78 }
79}
80
81#[inline]
82pub unsafe extern "C-unwind" fn CFNotificationCenterGetLocalCenter(
83) -> Option<CFRetained<CFNotificationCenter>> {
84 extern "C-unwind" {
85 fn CFNotificationCenterGetLocalCenter() -> Option<NonNull<CFNotificationCenter>>;
86 }
87 let ret = unsafe { CFNotificationCenterGetLocalCenter() };
88 ret.map(|ret| unsafe { CFRetained::retain(ret) })
89}
90
91#[inline]
92pub unsafe extern "C-unwind" fn CFNotificationCenterGetDistributedCenter(
93) -> Option<CFRetained<CFNotificationCenter>> {
94 extern "C-unwind" {
95 fn CFNotificationCenterGetDistributedCenter() -> Option<NonNull<CFNotificationCenter>>;
96 }
97 let ret = unsafe { CFNotificationCenterGetDistributedCenter() };
98 ret.map(|ret| unsafe { CFRetained::retain(ret) })
99}
100
101#[inline]
102pub unsafe extern "C-unwind" fn CFNotificationCenterGetDarwinNotifyCenter(
103) -> Option<CFRetained<CFNotificationCenter>> {
104 extern "C-unwind" {
105 fn CFNotificationCenterGetDarwinNotifyCenter() -> Option<NonNull<CFNotificationCenter>>;
106 }
107 let ret = unsafe { CFNotificationCenterGetDarwinNotifyCenter() };
108 ret.map(|ret| unsafe { CFRetained::retain(ret) })
109}
110
111extern "C-unwind" {
112 #[cfg(all(feature = "CFBase", feature = "CFDictionary"))]
113 pub fn CFNotificationCenterAddObserver(
114 center: &CFNotificationCenter,
115 observer: *const c_void,
116 call_back: CFNotificationCallback,
117 name: Option<&CFString>,
118 object: *const c_void,
119 suspension_behavior: CFNotificationSuspensionBehavior,
120 );
121}
122
123extern "C-unwind" {
124 #[cfg(feature = "CFBase")]
125 pub fn CFNotificationCenterRemoveObserver(
126 center: &CFNotificationCenter,
127 observer: *const c_void,
128 name: Option<&CFNotificationName>,
129 object: *const c_void,
130 );
131}
132
133extern "C-unwind" {
134 pub fn CFNotificationCenterRemoveEveryObserver(
135 center: &CFNotificationCenter,
136 observer: *const c_void,
137 );
138}
139
140#[cfg(all(feature = "CFBase", feature = "CFDictionary"))]
141#[inline]
142pub unsafe extern "C-unwind" fn CFNotificationCenterPostNotification(
143 center: &CFNotificationCenter,
144 name: Option<&CFNotificationName>,
145 object: *const c_void,
146 user_info: Option<&CFDictionary>,
147 deliver_immediately: bool,
148) {
149 extern "C-unwind" {
150 fn CFNotificationCenterPostNotification(
151 center: &CFNotificationCenter,
152 name: Option<&CFNotificationName>,
153 object: *const c_void,
154 user_info: Option<&CFDictionary>,
155 deliver_immediately: Boolean,
156 );
157 }
158 unsafe {
159 CFNotificationCenterPostNotification(
160 center,
161 name,
162 object,
163 user_info,
164 deliver_immediately as _,
165 )
166 }
167}
168
169#[cfg(feature = "CFBase")]
171pub const kCFNotificationDeliverImmediately: CFOptionFlags = 1 << 0;
172#[cfg(feature = "CFBase")]
174pub const kCFNotificationPostToAllSessions: CFOptionFlags = 1 << 1;
175
176extern "C-unwind" {
177 #[cfg(all(feature = "CFBase", feature = "CFDictionary"))]
178 pub fn CFNotificationCenterPostNotificationWithOptions(
179 center: &CFNotificationCenter,
180 name: Option<&CFNotificationName>,
181 object: *const c_void,
182 user_info: Option<&CFDictionary>,
183 options: CFOptionFlags,
184 );
185}