//! 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/nspointerarray?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSPointerArray;
);

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

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

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

#[cfg(feature = "NSEnumerator")]
extern_conformance!(
    unsafe impl NSFastEnumeration for NSPointerArray {}
);

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

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

impl NSPointerArray {
    extern_methods!(
        #[cfg(feature = "NSPointerFunctions")]
        #[unsafe(method(initWithOptions:))]
        #[unsafe(method_family = init)]
        pub fn initWithOptions(
            this: Allocated<Self>,
            options: NSPointerFunctionsOptions,
        ) -> Retained<Self>;

        #[cfg(feature = "NSPointerFunctions")]
        #[unsafe(method(initWithPointerFunctions:))]
        #[unsafe(method_family = init)]
        pub fn initWithPointerFunctions(
            this: Allocated<Self>,
            functions: &NSPointerFunctions,
        ) -> Retained<Self>;

        #[cfg(feature = "NSPointerFunctions")]
        #[unsafe(method(pointerArrayWithOptions:))]
        #[unsafe(method_family = none)]
        pub fn pointerArrayWithOptions(
            options: NSPointerFunctionsOptions,
        ) -> Retained<NSPointerArray>;

        #[cfg(feature = "NSPointerFunctions")]
        #[unsafe(method(pointerArrayWithPointerFunctions:))]
        #[unsafe(method_family = none)]
        pub fn pointerArrayWithPointerFunctions(
            functions: &NSPointerFunctions,
        ) -> Retained<NSPointerArray>;

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

        #[unsafe(method(pointerAtIndex:))]
        #[unsafe(method_family = none)]
        pub fn pointerAtIndex(&self, index: NSUInteger) -> *mut c_void;

        /// # Safety
        ///
        /// `pointer` must be a valid pointer or null.
        #[unsafe(method(addPointer:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addPointer(&self, pointer: *mut c_void);

        #[unsafe(method(removePointerAtIndex:))]
        #[unsafe(method_family = none)]
        pub fn removePointerAtIndex(&self, index: NSUInteger);

        /// # Safety
        ///
        /// `item` must be a valid pointer or null.
        #[unsafe(method(insertPointer:atIndex:))]
        #[unsafe(method_family = none)]
        pub unsafe fn insertPointer_atIndex(&self, item: *mut c_void, index: NSUInteger);

        /// # Safety
        ///
        /// `item` must be a valid pointer or null.
        #[unsafe(method(replacePointerAtIndex:withPointer:))]
        #[unsafe(method_family = none)]
        pub unsafe fn replacePointerAtIndex_withPointer(
            &self,
            index: NSUInteger,
            item: *mut c_void,
        );

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

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

        /// Setter for [`count`][Self::count].
        #[unsafe(method(setCount:))]
        #[unsafe(method_family = none)]
        pub fn setCount(&self, count: NSUInteger);
    );
}

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

/// NSPointerArrayConveniences.
impl NSPointerArray {
    extern_methods!(
        #[deprecated = "GC no longer supported"]
        #[unsafe(method(pointerArrayWithStrongObjects))]
        #[unsafe(method_family = none)]
        pub fn pointerArrayWithStrongObjects() -> Retained<AnyObject>;

        #[deprecated = "GC no longer supported"]
        #[unsafe(method(pointerArrayWithWeakObjects))]
        #[unsafe(method_family = none)]
        pub fn pointerArrayWithWeakObjects() -> Retained<AnyObject>;

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

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

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