//! 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 "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsundefinedkeyexception?language=objc)
    #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
    pub static NSUndefinedKeyException: &'static NSExceptionName;
}

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nskeyvalueoperator?language=objc)
// NS_TYPED_ENUM
#[cfg(feature = "NSString")]
pub type NSKeyValueOperator = NSString;

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsaveragekeyvalueoperator?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSAverageKeyValueOperator: &'static NSKeyValueOperator;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscountkeyvalueoperator?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSCountKeyValueOperator: &'static NSKeyValueOperator;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsdistinctunionofarrayskeyvalueoperator?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSDistinctUnionOfArraysKeyValueOperator: &'static NSKeyValueOperator;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsdistinctunionofobjectskeyvalueoperator?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSDistinctUnionOfObjectsKeyValueOperator: &'static NSKeyValueOperator;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsdistinctunionofsetskeyvalueoperator?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSDistinctUnionOfSetsKeyValueOperator: &'static NSKeyValueOperator;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmaximumkeyvalueoperator?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSMaximumKeyValueOperator: &'static NSKeyValueOperator;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsminimumkeyvalueoperator?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSMinimumKeyValueOperator: &'static NSKeyValueOperator;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nssumkeyvalueoperator?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSSumKeyValueOperator: &'static NSKeyValueOperator;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsunionofarrayskeyvalueoperator?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSUnionOfArraysKeyValueOperator: &'static NSKeyValueOperator;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsunionofobjectskeyvalueoperator?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSUnionOfObjectsKeyValueOperator: &'static NSKeyValueOperator;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsunionofsetskeyvalueoperator?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSUnionOfSetsKeyValueOperator: &'static NSKeyValueOperator;
}

mod private_NSObjectNSKeyValueCoding {
    pub trait Sealed {}
}

/// Category "NSKeyValueCoding" on [`NSObject`].
#[doc(alias = "NSKeyValueCoding")]
pub unsafe trait NSObjectNSKeyValueCoding:
    ClassType + Sized + private_NSObjectNSKeyValueCoding::Sealed
{
    extern_methods!(
        #[unsafe(method(accessInstanceVariablesDirectly))]
        #[unsafe(method_family = none)]
        unsafe fn accessInstanceVariablesDirectly() -> bool;

        #[cfg(feature = "NSString")]
        #[unsafe(method(valueForKey:))]
        #[unsafe(method_family = none)]
        unsafe fn valueForKey(&self, key: &NSString) -> Option<Retained<AnyObject>>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(setValue:forKey:))]
        #[unsafe(method_family = none)]
        unsafe fn setValue_forKey(&self, value: Option<&AnyObject>, key: &NSString);

        #[cfg(all(feature = "NSError", feature = "NSString"))]
        #[unsafe(method(validateValue:forKey:error:_))]
        #[unsafe(method_family = none)]
        unsafe fn validateValue_forKey_error(
            &self,
            io_value: &mut Option<Retained<AnyObject>>,
            in_key: &NSString,
        ) -> Result<(), Retained<NSError>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[unsafe(method(mutableArrayValueForKey:))]
        #[unsafe(method_family = none)]
        unsafe fn mutableArrayValueForKey(&self, key: &NSString) -> Retained<NSMutableArray>;

        #[cfg(all(feature = "NSOrderedSet", feature = "NSString"))]
        #[unsafe(method(mutableOrderedSetValueForKey:))]
        #[unsafe(method_family = none)]
        unsafe fn mutableOrderedSetValueForKey(
            &self,
            key: &NSString,
        ) -> Retained<NSMutableOrderedSet>;

        #[cfg(all(feature = "NSSet", feature = "NSString"))]
        #[unsafe(method(mutableSetValueForKey:))]
        #[unsafe(method_family = none)]
        unsafe fn mutableSetValueForKey(&self, key: &NSString) -> Retained<NSMutableSet>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(valueForKeyPath:))]
        #[unsafe(method_family = none)]
        unsafe fn valueForKeyPath(&self, key_path: &NSString) -> Option<Retained<AnyObject>>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(setValue:forKeyPath:))]
        #[unsafe(method_family = none)]
        unsafe fn setValue_forKeyPath(&self, value: Option<&AnyObject>, key_path: &NSString);

        #[cfg(all(feature = "NSError", feature = "NSString"))]
        #[unsafe(method(validateValue:forKeyPath:error:_))]
        #[unsafe(method_family = none)]
        unsafe fn validateValue_forKeyPath_error(
            &self,
            io_value: &mut Option<Retained<AnyObject>>,
            in_key_path: &NSString,
        ) -> Result<(), Retained<NSError>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[unsafe(method(mutableArrayValueForKeyPath:))]
        #[unsafe(method_family = none)]
        unsafe fn mutableArrayValueForKeyPath(
            &self,
            key_path: &NSString,
        ) -> Retained<NSMutableArray>;

        #[cfg(all(feature = "NSOrderedSet", feature = "NSString"))]
        #[unsafe(method(mutableOrderedSetValueForKeyPath:))]
        #[unsafe(method_family = none)]
        unsafe fn mutableOrderedSetValueForKeyPath(
            &self,
            key_path: &NSString,
        ) -> Retained<NSMutableOrderedSet>;

        #[cfg(all(feature = "NSSet", feature = "NSString"))]
        #[unsafe(method(mutableSetValueForKeyPath:))]
        #[unsafe(method_family = none)]
        unsafe fn mutableSetValueForKeyPath(&self, key_path: &NSString) -> Retained<NSMutableSet>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(valueForUndefinedKey:))]
        #[unsafe(method_family = none)]
        unsafe fn valueForUndefinedKey(&self, key: &NSString) -> Option<Retained<AnyObject>>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(setValue:forUndefinedKey:))]
        #[unsafe(method_family = none)]
        unsafe fn setValue_forUndefinedKey(&self, value: Option<&AnyObject>, key: &NSString);

        #[cfg(feature = "NSString")]
        #[unsafe(method(setNilValueForKey:))]
        #[unsafe(method_family = none)]
        unsafe fn setNilValueForKey(&self, key: &NSString);

        #[cfg(all(feature = "NSArray", feature = "NSDictionary", feature = "NSString"))]
        #[unsafe(method(dictionaryWithValuesForKeys:))]
        #[unsafe(method_family = none)]
        unsafe fn dictionaryWithValuesForKeys(
            &self,
            keys: &NSArray<NSString>,
        ) -> Retained<NSDictionary<NSString, AnyObject>>;

        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
        #[unsafe(method(setValuesForKeysWithDictionary:))]
        #[unsafe(method_family = none)]
        unsafe fn setValuesForKeysWithDictionary(
            &self,
            keyed_values: &NSDictionary<NSString, AnyObject>,
        );
    );
}

impl private_NSObjectNSKeyValueCoding::Sealed for NSObject {}
unsafe impl NSObjectNSKeyValueCoding for NSObject {}

/// NSKeyValueCoding.
#[cfg(feature = "NSArray")]
impl<ObjectType: Message> NSArray<ObjectType> {
    extern_methods!(
        #[cfg(feature = "NSString")]
        #[unsafe(method(valueForKey:))]
        #[unsafe(method_family = none)]
        pub unsafe fn valueForKey(&self, key: &NSString) -> Retained<AnyObject>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(setValue:forKey:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setValue_forKey(&self, value: Option<&AnyObject>, key: &NSString);
    );
}

/// NSKeyValueCoding.
#[cfg(feature = "NSDictionary")]
impl<KeyType: Message, ObjectType: Message> NSDictionary<KeyType, ObjectType> {
    extern_methods!(
        #[cfg(feature = "NSString")]
        #[unsafe(method(valueForKey:))]
        #[unsafe(method_family = none)]
        pub unsafe fn valueForKey(&self, key: &NSString) -> Option<Retained<ObjectType>>;
    );
}

/// NSKeyValueCoding.
#[cfg(feature = "NSDictionary")]
impl<KeyType: Message, ObjectType: Message> NSMutableDictionary<KeyType, ObjectType> {
    extern_methods!(
        #[cfg(feature = "NSString")]
        #[unsafe(method(setValue:forKey:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setValue_forKey(&self, value: Option<&ObjectType>, key: &NSString);
    );
}

/// NSKeyValueCoding.
#[cfg(feature = "NSOrderedSet")]
impl<ObjectType: Message> NSOrderedSet<ObjectType> {
    extern_methods!(
        #[cfg(feature = "NSString")]
        #[unsafe(method(valueForKey:))]
        #[unsafe(method_family = none)]
        pub unsafe fn valueForKey(&self, key: &NSString) -> Retained<AnyObject>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(setValue:forKey:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setValue_forKey(&self, value: Option<&AnyObject>, key: &NSString);
    );
}

/// NSKeyValueCoding.
#[cfg(feature = "NSSet")]
impl<ObjectType: Message> NSSet<ObjectType> {
    extern_methods!(
        #[cfg(feature = "NSString")]
        #[unsafe(method(valueForKey:))]
        #[unsafe(method_family = none)]
        pub unsafe fn valueForKey(&self, key: &NSString) -> Retained<AnyObject>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(setValue:forKey:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setValue_forKey(&self, value: Option<&AnyObject>, key: &NSString);
    );
}
