objc2-foundation 0.3.2

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

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscompoundpredicatetype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSCompoundPredicateType(pub NSUInteger);
impl NSCompoundPredicateType {
    #[doc(alias = "NSNotPredicateType")]
    pub const NotPredicateType: Self = Self(0);
    #[doc(alias = "NSAndPredicateType")]
    pub const AndPredicateType: Self = Self(1);
    #[doc(alias = "NSOrPredicateType")]
    pub const OrPredicateType: Self = Self(2);
}

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

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

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscompoundpredicate?language=objc)
    #[unsafe(super(NSPredicate, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "NSPredicate")]
    pub struct NSCompoundPredicate;
);

#[cfg(all(feature = "NSObject", feature = "NSPredicate"))]
extern_conformance!(
    unsafe impl NSCoding for NSCompoundPredicate {}
);

#[cfg(all(feature = "NSObject", feature = "NSPredicate"))]
extern_conformance!(
    unsafe impl NSCopying for NSCompoundPredicate {}
);

#[cfg(all(feature = "NSObject", feature = "NSPredicate"))]
unsafe impl CopyingHelper for NSCompoundPredicate {
    type Result = Self;
}

#[cfg(feature = "NSPredicate")]
extern_conformance!(
    unsafe impl NSObjectProtocol for NSCompoundPredicate {}
);

#[cfg(all(feature = "NSObject", feature = "NSPredicate"))]
extern_conformance!(
    unsafe impl NSSecureCoding for NSCompoundPredicate {}
);

#[cfg(feature = "NSPredicate")]
impl NSCompoundPredicate {
    extern_methods!(
        #[cfg(feature = "NSArray")]
        #[unsafe(method(initWithType:subpredicates:))]
        #[unsafe(method_family = init)]
        pub fn initWithType_subpredicates(
            this: Allocated<Self>,
            r#type: NSCompoundPredicateType,
            subpredicates: &NSArray<NSPredicate>,
        ) -> Retained<Self>;

        #[cfg(feature = "NSCoder")]
        /// # Safety
        ///
        /// `coder` possibly has further requirements.
        #[unsafe(method(initWithCoder:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            coder: &NSCoder,
        ) -> Option<Retained<Self>>;

        #[unsafe(method(compoundPredicateType))]
        #[unsafe(method_family = none)]
        pub fn compoundPredicateType(&self) -> NSCompoundPredicateType;

        #[cfg(feature = "NSArray")]
        #[unsafe(method(subpredicates))]
        #[unsafe(method_family = none)]
        pub fn subpredicates(&self) -> Retained<NSArray>;

        #[cfg(feature = "NSArray")]
        /// * Convenience Methods **
        #[unsafe(method(andPredicateWithSubpredicates:))]
        #[unsafe(method_family = none)]
        pub fn andPredicateWithSubpredicates(
            subpredicates: &NSArray<NSPredicate>,
        ) -> Retained<NSCompoundPredicate>;

        #[cfg(feature = "NSArray")]
        #[unsafe(method(orPredicateWithSubpredicates:))]
        #[unsafe(method_family = none)]
        pub fn orPredicateWithSubpredicates(
            subpredicates: &NSArray<NSPredicate>,
        ) -> Retained<NSCompoundPredicate>;

        #[unsafe(method(notPredicateWithSubpredicate:))]
        #[unsafe(method_family = none)]
        pub fn notPredicateWithSubpredicate(
            predicate: &NSPredicate,
        ) -> Retained<NSCompoundPredicate>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "NSPredicate")]
impl NSCompoundPredicate {
    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>;
    );
}

#[cfg(feature = "NSPredicate")]
impl DefaultRetained for NSCompoundPredicate {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}