1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;

use crate::*;

// NS_TYPED_EXTENSIBLE_ENUM
#[cfg(feature = "NSString")]
pub type NSDistributedNotificationCenterType = NSString;

extern "C" {
    #[cfg(feature = "NSString")]
    pub static NSLocalNotificationCenterType: &'static NSDistributedNotificationCenterType;
}

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSNotificationSuspensionBehavior(pub NSUInteger);
impl NSNotificationSuspensionBehavior {
    #[doc(alias = "NSNotificationSuspensionBehaviorDrop")]
    pub const Drop: Self = Self(1);
    #[doc(alias = "NSNotificationSuspensionBehaviorCoalesce")]
    pub const Coalesce: Self = Self(2);
    #[doc(alias = "NSNotificationSuspensionBehaviorHold")]
    pub const Hold: Self = Self(3);
    #[doc(alias = "NSNotificationSuspensionBehaviorDeliverImmediately")]
    pub const DeliverImmediately: Self = Self(4);
}

unsafe impl Encode for NSNotificationSuspensionBehavior {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NSNotificationSuspensionBehavior {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSDistributedNotificationOptions(pub NSUInteger);
bitflags::bitflags! {
    impl NSDistributedNotificationOptions: NSUInteger {
        const NSDistributedNotificationDeliverImmediately = 1<<0;
        const NSDistributedNotificationPostToAllSessions = 1<<1;
    }
}

unsafe impl Encode for NSDistributedNotificationOptions {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NSDistributedNotificationOptions {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

pub static NSNotificationDeliverImmediately: NSDistributedNotificationOptions =
    NSDistributedNotificationOptions(
        NSDistributedNotificationOptions::NSDistributedNotificationDeliverImmediately.0,
    );

pub static NSNotificationPostToAllSessions: NSDistributedNotificationOptions =
    NSDistributedNotificationOptions(
        NSDistributedNotificationOptions::NSDistributedNotificationPostToAllSessions.0,
    );

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "NSNotification")]
    pub struct NSDistributedNotificationCenter;

    #[cfg(feature = "NSNotification")]
    unsafe impl ClassType for NSDistributedNotificationCenter {
        #[inherits(NSObject)]
        type Super = NSNotificationCenter;
        type Mutability = InteriorMutable;
    }
);

#[cfg(feature = "NSNotification")]
unsafe impl NSObjectProtocol for NSDistributedNotificationCenter {}

extern_methods!(
    #[cfg(feature = "NSNotification")]
    unsafe impl NSDistributedNotificationCenter {
        #[cfg(feature = "NSString")]
        #[method_id(@__retain_semantics Other notificationCenterForType:)]
        pub unsafe fn notificationCenterForType(
            notification_center_type: &NSDistributedNotificationCenterType,
        ) -> Retained<NSDistributedNotificationCenter>;

        #[method_id(@__retain_semantics Other defaultCenter)]
        pub unsafe fn defaultCenter() -> Retained<NSDistributedNotificationCenter>;

        #[cfg(feature = "NSString")]
        #[method(addObserver:selector:name:object:suspensionBehavior:)]
        pub unsafe fn addObserver_selector_name_object_suspensionBehavior(
            &self,
            observer: &AnyObject,
            selector: Sel,
            name: Option<&NSNotificationName>,
            object: Option<&NSString>,
            suspension_behavior: NSNotificationSuspensionBehavior,
        );

        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
        #[method(postNotificationName:object:userInfo:deliverImmediately:)]
        pub unsafe fn postNotificationName_object_userInfo_deliverImmediately(
            &self,
            name: &NSNotificationName,
            object: Option<&NSString>,
            user_info: Option<&NSDictionary>,
            deliver_immediately: bool,
        );

        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
        #[method(postNotificationName:object:userInfo:options:)]
        pub unsafe fn postNotificationName_object_userInfo_options(
            &self,
            name: &NSNotificationName,
            object: Option<&NSString>,
            user_info: Option<&NSDictionary>,
            options: NSDistributedNotificationOptions,
        );

        #[method(suspended)]
        pub unsafe fn suspended(&self) -> bool;

        #[method(setSuspended:)]
        pub unsafe fn setSuspended(&self, suspended: bool);

        #[cfg(feature = "NSString")]
        #[method(addObserver:selector:name:object:)]
        pub unsafe fn addObserver_selector_name_object(
            &self,
            observer: &AnyObject,
            a_selector: Sel,
            a_name: Option<&NSNotificationName>,
            an_object: Option<&NSString>,
        );

        #[cfg(feature = "NSString")]
        #[method(postNotificationName:object:)]
        pub unsafe fn postNotificationName_object(
            &self,
            a_name: &NSNotificationName,
            an_object: Option<&NSString>,
        );

        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
        #[method(postNotificationName:object:userInfo:)]
        pub unsafe fn postNotificationName_object_userInfo(
            &self,
            a_name: &NSNotificationName,
            an_object: Option<&NSString>,
            a_user_info: Option<&NSDictionary>,
        );

        #[cfg(feature = "NSString")]
        #[method(removeObserver:name:object:)]
        pub unsafe fn removeObserver_name_object(
            &self,
            observer: &AnyObject,
            a_name: Option<&NSNotificationName>,
            an_object: Option<&NSString>,
        );
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    #[cfg(feature = "NSNotification")]
    unsafe impl NSDistributedNotificationCenter {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Retained<Self>;
    }
);