objc2-foundation 0.3.1

Bindings to the Foundation 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 crate::*;

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

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

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

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

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

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

impl NSPredicate {
    extern_methods!(
        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[unsafe(method(predicateWithFormat:argumentArray:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateWithFormat_argumentArray(
            predicate_format: &NSString,
            arguments: Option<&NSArray>,
        ) -> Retained<NSPredicate>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(predicateFromMetadataQueryString:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateFromMetadataQueryString(
            query_string: &NSString,
        ) -> Option<Retained<NSPredicate>>;

        #[unsafe(method(predicateWithValue:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateWithValue(value: bool) -> Retained<NSPredicate>;

        #[cfg(all(feature = "NSDictionary", feature = "NSString", feature = "block2"))]
        #[unsafe(method(predicateWithBlock:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateWithBlock(
            block: &block2::DynBlock<
                dyn Fn(*mut AnyObject, *mut NSDictionary<NSString, AnyObject>) -> Bool,
            >,
        ) -> Retained<NSPredicate>;

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

        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
        #[unsafe(method(predicateWithSubstitutionVariables:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateWithSubstitutionVariables(
            &self,
            variables: &NSDictionary<NSString, AnyObject>,
        ) -> Retained<Self>;

        #[unsafe(method(evaluateWithObject:))]
        #[unsafe(method_family = none)]
        pub unsafe fn evaluateWithObject(&self, object: Option<&AnyObject>) -> bool;

        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
        #[unsafe(method(evaluateWithObject:substitutionVariables:))]
        #[unsafe(method_family = none)]
        pub unsafe fn evaluateWithObject_substitutionVariables(
            &self,
            object: Option<&AnyObject>,
            bindings: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> bool;

        #[unsafe(method(allowEvaluation))]
        #[unsafe(method_family = none)]
        pub unsafe fn allowEvaluation(&self);
    );
}

/// Methods declared on superclass `NSObject`.
impl NSPredicate {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

/// NSPredicateSupport.
#[cfg(feature = "NSArray")]
impl<ObjectType: Message> NSArray<ObjectType> {
    extern_methods!(
        #[unsafe(method(filteredArrayUsingPredicate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn filteredArrayUsingPredicate(
            &self,
            predicate: &NSPredicate,
        ) -> Retained<NSArray<ObjectType>>;
    );
}

/// NSPredicateSupport.
#[cfg(feature = "NSArray")]
impl<ObjectType: Message> NSMutableArray<ObjectType> {
    extern_methods!(
        #[unsafe(method(filterUsingPredicate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn filterUsingPredicate(&self, predicate: &NSPredicate);
    );
}

/// NSPredicateSupport.
#[cfg(feature = "NSSet")]
impl<ObjectType: Message> NSSet<ObjectType> {
    extern_methods!(
        #[unsafe(method(filteredSetUsingPredicate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn filteredSetUsingPredicate(
            &self,
            predicate: &NSPredicate,
        ) -> Retained<NSSet<ObjectType>>;
    );
}

/// NSPredicateSupport.
#[cfg(feature = "NSSet")]
impl<ObjectType: Message> NSMutableSet<ObjectType> {
    extern_methods!(
        #[unsafe(method(filterUsingPredicate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn filterUsingPredicate(&self, predicate: &NSPredicate);
    );
}

/// NSPredicateSupport.
#[cfg(feature = "NSOrderedSet")]
impl<ObjectType: Message> NSOrderedSet<ObjectType> {
    extern_methods!(
        #[unsafe(method(filteredOrderedSetUsingPredicate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn filteredOrderedSetUsingPredicate(
            &self,
            p: &NSPredicate,
        ) -> Retained<NSOrderedSet<ObjectType>>;
    );
}

/// NSPredicateSupport.
#[cfg(feature = "NSOrderedSet")]
impl<ObjectType: Message> NSMutableOrderedSet<ObjectType> {
    extern_methods!(
        #[unsafe(method(filterUsingPredicate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn filterUsingPredicate(&self, p: &NSPredicate);
    );
}