use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use crate::*;
#[cfg(feature = "NSString")]
pub type NSNotificationName = NSString;
extern_class!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct NSNotification;
);
#[cfg(feature = "NSObject")]
extern_conformance!(
unsafe impl NSCoding for NSNotification {}
);
#[cfg(feature = "NSObject")]
extern_conformance!(
unsafe impl NSCopying for NSNotification {}
);
#[cfg(feature = "NSObject")]
unsafe impl CopyingHelper for NSNotification {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for NSNotification {}
);
impl NSNotification {
extern_methods!(
#[cfg(feature = "NSString")]
#[unsafe(method(name))]
#[unsafe(method_family = none)]
pub fn name(&self) -> Retained<NSNotificationName>;
#[unsafe(method(object))]
#[unsafe(method_family = none)]
pub fn object(&self) -> Option<Retained<AnyObject>>;
#[cfg(feature = "NSDictionary")]
#[unsafe(method(userInfo))]
#[unsafe(method_family = none)]
pub fn userInfo(&self) -> Option<Retained<NSDictionary>>;
#[cfg(all(feature = "NSDictionary", feature = "NSString"))]
#[unsafe(method(initWithName:object:userInfo:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithName_object_userInfo(
this: Allocated<Self>,
name: &NSNotificationName,
object: Option<&AnyObject>,
user_info: Option<&NSDictionary>,
) -> Retained<Self>;
#[cfg(feature = "NSCoder")]
#[unsafe(method(initWithCoder:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithCoder(
this: Allocated<Self>,
coder: &NSCoder,
) -> Option<Retained<Self>>;
);
}
impl NSNotification {
extern_methods!(
#[cfg(feature = "NSString")]
#[unsafe(method(notificationWithName:object:))]
#[unsafe(method_family = none)]
pub unsafe fn notificationWithName_object(
a_name: &NSNotificationName,
an_object: Option<&AnyObject>,
) -> Retained<Self>;
#[cfg(all(feature = "NSDictionary", feature = "NSString"))]
#[unsafe(method(notificationWithName:object:userInfo:))]
#[unsafe(method_family = none)]
pub unsafe fn notificationWithName_object_userInfo(
a_name: &NSNotificationName,
an_object: Option<&AnyObject>,
a_user_info: Option<&NSDictionary>,
) -> Retained<Self>;
);
}
extern_class!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct NSNotificationCenter;
);
unsafe impl Send for NSNotificationCenter {}
unsafe impl Sync for NSNotificationCenter {}
extern_conformance!(
unsafe impl NSObjectProtocol for NSNotificationCenter {}
);
impl NSNotificationCenter {
extern_methods!(
#[unsafe(method(defaultCenter))]
#[unsafe(method_family = none)]
pub fn defaultCenter() -> Retained<NSNotificationCenter>;
#[cfg(feature = "NSString")]
#[unsafe(method(addObserver:selector:name:object:))]
#[unsafe(method_family = none)]
pub unsafe fn addObserver_selector_name_object(
&self,
observer: &AnyObject,
a_selector: Sel,
a_name: Option<&NSNotificationName>,
an_object: Option<&AnyObject>,
);
#[unsafe(method(postNotification:))]
#[unsafe(method_family = none)]
pub fn postNotification(&self, notification: &NSNotification);
#[cfg(feature = "NSString")]
#[unsafe(method(postNotificationName:object:))]
#[unsafe(method_family = none)]
pub unsafe fn postNotificationName_object(
&self,
a_name: &NSNotificationName,
an_object: Option<&AnyObject>,
);
#[cfg(all(feature = "NSDictionary", feature = "NSString"))]
#[unsafe(method(postNotificationName:object:userInfo:))]
#[unsafe(method_family = none)]
pub unsafe fn postNotificationName_object_userInfo(
&self,
a_name: &NSNotificationName,
an_object: Option<&AnyObject>,
a_user_info: Option<&NSDictionary>,
);
#[unsafe(method(removeObserver:))]
#[unsafe(method_family = none)]
pub unsafe fn removeObserver(&self, observer: &AnyObject);
#[cfg(feature = "NSString")]
#[unsafe(method(removeObserver:name:object:))]
#[unsafe(method_family = none)]
pub unsafe fn removeObserver_name_object(
&self,
observer: &AnyObject,
a_name: Option<&NSNotificationName>,
an_object: Option<&AnyObject>,
);
#[cfg(all(feature = "NSOperation", feature = "NSString", feature = "block2"))]
#[unsafe(method(addObserverForName:object:queue:usingBlock:))]
#[unsafe(method_family = none)]
pub unsafe fn addObserverForName_object_queue_usingBlock(
&self,
name: Option<&NSNotificationName>,
obj: Option<&AnyObject>,
queue: Option<&NSOperationQueue>,
block: &block2::DynBlock<dyn Fn(NonNull<NSNotification>)>,
) -> Retained<ProtocolObject<dyn NSObjectProtocol>>;
);
}
impl NSNotificationCenter {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new() -> Retained<Self>;
);
}
impl DefaultRetained for NSNotificationCenter {
#[inline]
fn default_retained() -> Retained<Self> {
Self::new()
}
}