objc2-app-kit 0.3.2

Bindings to the AppKit framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsaccessibilitycustomaction?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSAccessibilityCustomAction;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for NSAccessibilityCustomAction {}
);

impl NSAccessibilityCustomAction {
    extern_methods!(
        #[cfg(feature = "block2")]
        #[unsafe(method(initWithName:handler:))]
        #[unsafe(method_family = init)]
        pub fn initWithName_handler(
            this: Allocated<Self>,
            name: &NSString,
            handler: Option<&block2::DynBlock<dyn Fn() -> Bool>>,
        ) -> Retained<Self>;

        /// # Safety
        ///
        /// - `target` should be of the correct type.
        /// - `selector` must be a valid selector.
        #[unsafe(method(initWithName:target:selector:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithName_target_selector(
            this: Allocated<Self>,
            name: &NSString,
            target: &ProtocolObject<dyn NSObjectProtocol>,
            selector: Sel,
        ) -> Retained<Self>;

        #[unsafe(method(name))]
        #[unsafe(method_family = none)]
        pub fn name(&self) -> Retained<NSString>;

        /// Setter for [`name`][Self::name].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setName:))]
        #[unsafe(method_family = none)]
        pub fn setName(&self, name: &NSString);

        #[cfg(feature = "block2")]
        #[unsafe(method(handler))]
        #[unsafe(method_family = none)]
        pub fn handler(&self) -> *mut block2::DynBlock<dyn Fn() -> Bool>;

        #[cfg(feature = "block2")]
        /// Setter for [`handler`][Self::handler].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setHandler:))]
        #[unsafe(method_family = none)]
        pub fn setHandler(&self, handler: Option<&block2::DynBlock<dyn Fn() -> Bool>>);

        #[unsafe(method(target))]
        #[unsafe(method_family = none)]
        pub fn target(&self) -> Option<Retained<ProtocolObject<dyn NSObjectProtocol>>>;

        /// Setter for [`target`][Self::target].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        ///
        /// # Safety
        ///
        /// `target` should be of the correct type.
        #[unsafe(method(setTarget:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTarget(&self, target: Option<&ProtocolObject<dyn NSObjectProtocol>>);

        #[unsafe(method(selector))]
        #[unsafe(method_family = none)]
        pub fn selector(&self) -> Option<Sel>;

        /// Setter for [`selector`][Self::selector].
        ///
        /// # Safety
        ///
        /// `selector` must be a valid selector.
        #[unsafe(method(setSelector:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSelector(&self, selector: Option<Sel>);
    );
}

/// Methods declared on superclass `NSObject`.
impl NSAccessibilityCustomAction {
    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 NSAccessibilityCustomAction {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}