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::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;

use crate::*;

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

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

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

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

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

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

impl NSSortDescriptor {
    extern_methods!(
        #[cfg(feature = "NSString")]
        #[unsafe(method(sortDescriptorWithKey:ascending:))]
        #[unsafe(method_family = none)]
        pub fn sortDescriptorWithKey_ascending(
            key: Option<&NSString>,
            ascending: bool,
        ) -> Retained<Self>;

        #[cfg(feature = "NSString")]
        /// # Safety
        ///
        /// `selector` must be a valid selector.
        #[unsafe(method(sortDescriptorWithKey:ascending:selector:))]
        #[unsafe(method_family = none)]
        pub unsafe fn sortDescriptorWithKey_ascending_selector(
            key: Option<&NSString>,
            ascending: bool,
            selector: Option<Sel>,
        ) -> Retained<Self>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(initWithKey:ascending:))]
        #[unsafe(method_family = init)]
        pub fn initWithKey_ascending(
            this: Allocated<Self>,
            key: Option<&NSString>,
            ascending: bool,
        ) -> Retained<Self>;

        #[cfg(feature = "NSString")]
        /// # Safety
        ///
        /// `selector` must be a valid selector.
        #[unsafe(method(initWithKey:ascending:selector:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithKey_ascending_selector(
            this: Allocated<Self>,
            key: Option<&NSString>,
            ascending: bool,
            selector: Option<Sel>,
        ) -> 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>>;

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

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

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

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

        #[cfg(all(feature = "NSObjCRuntime", feature = "NSString", feature = "block2"))]
        /// # Safety
        ///
        /// `cmptr` must be a valid pointer.
        #[unsafe(method(sortDescriptorWithKey:ascending:comparator:))]
        #[unsafe(method_family = none)]
        pub unsafe fn sortDescriptorWithKey_ascending_comparator(
            key: Option<&NSString>,
            ascending: bool,
            cmptr: NSComparator,
        ) -> Retained<Self>;

        #[cfg(all(feature = "NSObjCRuntime", feature = "NSString", feature = "block2"))]
        /// # Safety
        ///
        /// `cmptr` must be a valid pointer.
        #[unsafe(method(initWithKey:ascending:comparator:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithKey_ascending_comparator(
            this: Allocated<Self>,
            key: Option<&NSString>,
            ascending: bool,
            cmptr: NSComparator,
        ) -> Retained<Self>;

        #[cfg(all(feature = "NSObjCRuntime", feature = "block2"))]
        /// # Safety
        ///
        /// - The returned block's argument 1 must be a valid pointer.
        /// - The returned block's argument 2 must be a valid pointer.
        #[unsafe(method(comparator))]
        #[unsafe(method_family = none)]
        pub unsafe fn comparator(&self) -> NSComparator;

        #[cfg(feature = "NSObjCRuntime")]
        /// # Safety
        ///
        /// - `object1` should be of the correct type.
        /// - `object2` should be of the correct type.
        #[unsafe(method(compareObject:toObject:))]
        #[unsafe(method_family = none)]
        pub unsafe fn compareObject_toObject(
            &self,
            object1: &AnyObject,
            object2: &AnyObject,
        ) -> NSComparisonResult;

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

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

/// NSSortDescriptorSorting.
#[cfg(feature = "NSSet")]
impl<ObjectType: Message> NSSet<ObjectType> {
    extern_methods!(
        #[cfg(feature = "NSArray")]
        #[unsafe(method(sortedArrayUsingDescriptors:))]
        #[unsafe(method_family = none)]
        pub fn sortedArrayUsingDescriptors(
            &self,
            sort_descriptors: &NSArray<NSSortDescriptor>,
        ) -> Retained<NSArray<ObjectType>>;
    );
}

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

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

/// NSKeyValueSorting.
#[cfg(feature = "NSOrderedSet")]
impl<ObjectType: Message> NSOrderedSet<ObjectType> {
    extern_methods!(
        #[cfg(feature = "NSArray")]
        #[unsafe(method(sortedArrayUsingDescriptors:))]
        #[unsafe(method_family = none)]
        pub fn sortedArrayUsingDescriptors(
            &self,
            sort_descriptors: &NSArray<NSSortDescriptor>,
        ) -> Retained<NSArray<ObjectType>>;
    );
}

/// NSKeyValueSorting.
#[cfg(feature = "NSOrderedSet")]
impl<ObjectType: Message> NSMutableOrderedSet<ObjectType> {
    extern_methods!(
        #[cfg(feature = "NSArray")]
        #[unsafe(method(sortUsingDescriptors:))]
        #[unsafe(method_family = none)]
        pub fn sortUsingDescriptors(&self, sort_descriptors: &NSArray<NSSortDescriptor>);
    );
}