//! 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::*;

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsexpressiontype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSExpressionType(pub NSUInteger);
impl NSExpressionType {
    #[doc(alias = "NSConstantValueExpressionType")]
    pub const ConstantValueExpressionType: Self = Self(0);
    #[doc(alias = "NSEvaluatedObjectExpressionType")]
    pub const EvaluatedObjectExpressionType: Self = Self(1);
    #[doc(alias = "NSVariableExpressionType")]
    pub const VariableExpressionType: Self = Self(2);
    #[doc(alias = "NSKeyPathExpressionType")]
    pub const KeyPathExpressionType: Self = Self(3);
    #[doc(alias = "NSFunctionExpressionType")]
    pub const FunctionExpressionType: Self = Self(4);
    #[doc(alias = "NSUnionSetExpressionType")]
    pub const UnionSetExpressionType: Self = Self(5);
    #[doc(alias = "NSIntersectSetExpressionType")]
    pub const IntersectSetExpressionType: Self = Self(6);
    #[doc(alias = "NSMinusSetExpressionType")]
    pub const MinusSetExpressionType: Self = Self(7);
    #[doc(alias = "NSSubqueryExpressionType")]
    pub const SubqueryExpressionType: Self = Self(13);
    #[doc(alias = "NSAggregateExpressionType")]
    pub const AggregateExpressionType: Self = Self(14);
    #[doc(alias = "NSAnyKeyExpressionType")]
    pub const AnyKeyExpressionType: Self = Self(15);
    #[doc(alias = "NSBlockExpressionType")]
    pub const BlockExpressionType: Self = Self(19);
    #[doc(alias = "NSConditionalExpressionType")]
    pub const ConditionalExpressionType: Self = Self(20);
}

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

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

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

#[cfg(feature = "NSObject")]
unsafe impl NSCoding for NSExpression {}

#[cfg(feature = "NSObject")]
unsafe impl NSCopying for NSExpression {}

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

unsafe impl NSObjectProtocol for NSExpression {}

#[cfg(feature = "NSObject")]
unsafe impl NSSecureCoding for NSExpression {}

impl NSExpression {
    extern_methods!(
        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[unsafe(method(expressionWithFormat:argumentArray:))]
        #[unsafe(method_family = none)]
        pub unsafe fn expressionWithFormat_argumentArray(
            expression_format: &NSString,
            arguments: &NSArray,
        ) -> Retained<NSExpression>;

        #[unsafe(method(expressionForConstantValue:))]
        #[unsafe(method_family = none)]
        pub unsafe fn expressionForConstantValue(obj: Option<&AnyObject>)
            -> Retained<NSExpression>;

        #[unsafe(method(expressionForEvaluatedObject))]
        #[unsafe(method_family = none)]
        pub unsafe fn expressionForEvaluatedObject() -> Retained<NSExpression>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(expressionForVariable:))]
        #[unsafe(method_family = none)]
        pub unsafe fn expressionForVariable(string: &NSString) -> Retained<NSExpression>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(expressionForKeyPath:))]
        #[unsafe(method_family = none)]
        pub unsafe fn expressionForKeyPath(key_path: &NSString) -> Retained<NSExpression>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[unsafe(method(expressionForFunction:arguments:))]
        #[unsafe(method_family = none)]
        pub unsafe fn expressionForFunction_arguments(
            name: &NSString,
            parameters: &NSArray,
        ) -> Retained<NSExpression>;

        #[cfg(feature = "NSArray")]
        #[unsafe(method(expressionForAggregate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn expressionForAggregate(
            subexpressions: &NSArray<NSExpression>,
        ) -> Retained<NSExpression>;

        #[unsafe(method(expressionForUnionSet:with:))]
        #[unsafe(method_family = none)]
        pub unsafe fn expressionForUnionSet_with(
            left: &NSExpression,
            right: &NSExpression,
        ) -> Retained<NSExpression>;

        #[unsafe(method(expressionForIntersectSet:with:))]
        #[unsafe(method_family = none)]
        pub unsafe fn expressionForIntersectSet_with(
            left: &NSExpression,
            right: &NSExpression,
        ) -> Retained<NSExpression>;

        #[unsafe(method(expressionForMinusSet:with:))]
        #[unsafe(method_family = none)]
        pub unsafe fn expressionForMinusSet_with(
            left: &NSExpression,
            right: &NSExpression,
        ) -> Retained<NSExpression>;

        #[cfg(all(feature = "NSPredicate", feature = "NSString"))]
        #[unsafe(method(expressionForSubquery:usingIteratorVariable:predicate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn expressionForSubquery_usingIteratorVariable_predicate(
            expression: &NSExpression,
            variable: &NSString,
            predicate: &NSPredicate,
        ) -> Retained<NSExpression>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[unsafe(method(expressionForFunction:selectorName:arguments:))]
        #[unsafe(method_family = none)]
        pub unsafe fn expressionForFunction_selectorName_arguments(
            target: &NSExpression,
            name: &NSString,
            parameters: Option<&NSArray>,
        ) -> Retained<NSExpression>;

        #[unsafe(method(expressionForAnyKey))]
        #[unsafe(method_family = none)]
        pub unsafe fn expressionForAnyKey() -> Retained<NSExpression>;

        #[cfg(all(feature = "NSArray", feature = "NSDictionary", feature = "block2"))]
        #[unsafe(method(expressionForBlock:arguments:))]
        #[unsafe(method_family = none)]
        pub unsafe fn expressionForBlock_arguments(
            block: &block2::Block<
                dyn Fn(
                    *mut AnyObject,
                    NonNull<NSArray<NSExpression>>,
                    *mut NSMutableDictionary,
                ) -> NonNull<AnyObject>,
            >,
            arguments: Option<&NSArray<NSExpression>>,
        ) -> Retained<NSExpression>;

        #[cfg(feature = "NSPredicate")]
        #[unsafe(method(expressionForConditional:trueExpression:falseExpression:))]
        #[unsafe(method_family = none)]
        pub unsafe fn expressionForConditional_trueExpression_falseExpression(
            predicate: &NSPredicate,
            true_expression: &NSExpression,
            false_expression: &NSExpression,
        ) -> Retained<NSExpression>;

        #[unsafe(method(initWithExpressionType:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithExpressionType(
            this: Allocated<Self>,
            r#type: NSExpressionType,
        ) -> Retained<Self>;

        #[cfg(feature = "NSCoder")]
        #[unsafe(method(initWithCoder:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            coder: &NSCoder,
        ) -> Option<Retained<Self>>;

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

        #[unsafe(method(constantValue))]
        #[unsafe(method_family = none)]
        pub unsafe fn constantValue(&self) -> Option<Retained<AnyObject>>;

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

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

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

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

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

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

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

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

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

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

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

        #[cfg(all(feature = "NSArray", feature = "NSDictionary", feature = "block2"))]
        #[unsafe(method(expressionBlock))]
        #[unsafe(method_family = none)]
        pub unsafe fn expressionBlock(
            &self,
        ) -> NonNull<
            block2::Block<
                dyn Fn(
                    *mut AnyObject,
                    NonNull<NSArray<NSExpression>>,
                    *mut NSMutableDictionary,
                ) -> NonNull<AnyObject>,
            >,
        >;

        #[cfg(feature = "NSDictionary")]
        #[unsafe(method(expressionValueWithObject:context:))]
        #[unsafe(method_family = none)]
        pub unsafe fn expressionValueWithObject_context(
            &self,
            object: Option<&AnyObject>,
            context: Option<&NSMutableDictionary>,
        ) -> Option<Retained<AnyObject>>;

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

/// Methods declared on superclass `NSObject`.
impl NSExpression {
    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>;
    );
}
