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

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nspointerfunctionsoptions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSPointerFunctionsOptions(pub NSUInteger);
bitflags::bitflags! {
    impl NSPointerFunctionsOptions: NSUInteger {
        #[doc(alias = "NSPointerFunctionsStrongMemory")]
        const StrongMemory = 0<<0;
        #[doc(alias = "NSPointerFunctionsZeroingWeakMemory")]
#[deprecated = "GC no longer supported"]
        const ZeroingWeakMemory = 1<<0;
        #[doc(alias = "NSPointerFunctionsOpaqueMemory")]
        const OpaqueMemory = 2<<0;
        #[doc(alias = "NSPointerFunctionsMallocMemory")]
        const MallocMemory = 3<<0;
        #[doc(alias = "NSPointerFunctionsMachVirtualMemory")]
        const MachVirtualMemory = 4<<0;
        #[doc(alias = "NSPointerFunctionsWeakMemory")]
        const WeakMemory = 5<<0;
        #[doc(alias = "NSPointerFunctionsObjectPersonality")]
        const ObjectPersonality = 0<<8;
        #[doc(alias = "NSPointerFunctionsOpaquePersonality")]
        const OpaquePersonality = 1<<8;
        #[doc(alias = "NSPointerFunctionsObjectPointerPersonality")]
        const ObjectPointerPersonality = 2<<8;
        #[doc(alias = "NSPointerFunctionsCStringPersonality")]
        const CStringPersonality = 3<<8;
        #[doc(alias = "NSPointerFunctionsStructPersonality")]
        const StructPersonality = 4<<8;
        #[doc(alias = "NSPointerFunctionsIntegerPersonality")]
        const IntegerPersonality = 5<<8;
        #[doc(alias = "NSPointerFunctionsCopyIn")]
        const CopyIn = 1<<16;
    }
}

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

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

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

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

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

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

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

        #[unsafe(method(pointerFunctionsWithOptions:))]
        #[unsafe(method_family = none)]
        pub fn pointerFunctionsWithOptions(
            options: NSPointerFunctionsOptions,
        ) -> Retained<NSPointerFunctions>;

        #[unsafe(method(hashFunction))]
        #[unsafe(method_family = none)]
        pub fn hashFunction(
            &self,
        ) -> Option<
            unsafe extern "C-unwind" fn(
                NonNull<c_void>,
                Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NSUInteger>,
            ) -> NSUInteger,
        >;

        /// Setter for [`hashFunction`][Self::hashFunction].
        ///
        /// # Safety
        ///
        /// `hash_function` must be implemented correctly.
        #[unsafe(method(setHashFunction:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setHashFunction(
            &self,
            hash_function: Option<
                unsafe extern "C-unwind" fn(
                    NonNull<c_void>,
                    Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NSUInteger>,
                ) -> NSUInteger,
            >,
        );

        #[unsafe(method(isEqualFunction))]
        #[unsafe(method_family = none)]
        pub fn isEqualFunction(
            &self,
        ) -> Option<
            unsafe extern "C-unwind" fn(
                NonNull<c_void>,
                NonNull<c_void>,
                Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NSUInteger>,
            ) -> Bool,
        >;

        /// Setter for [`isEqualFunction`][Self::isEqualFunction].
        ///
        /// # Safety
        ///
        /// `is_equal_function` must be implemented correctly.
        #[unsafe(method(setIsEqualFunction:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setIsEqualFunction(
            &self,
            is_equal_function: Option<
                unsafe extern "C-unwind" fn(
                    NonNull<c_void>,
                    NonNull<c_void>,
                    Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NSUInteger>,
                ) -> Bool,
            >,
        );

        #[unsafe(method(sizeFunction))]
        #[unsafe(method_family = none)]
        pub fn sizeFunction(
            &self,
        ) -> Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NSUInteger>;

        /// Setter for [`sizeFunction`][Self::sizeFunction].
        ///
        /// # Safety
        ///
        /// `size_function` must be implemented correctly.
        #[unsafe(method(setSizeFunction:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSizeFunction(
            &self,
            size_function: Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NSUInteger>,
        );

        #[cfg(feature = "NSString")]
        #[unsafe(method(descriptionFunction))]
        #[unsafe(method_family = none)]
        pub fn descriptionFunction(
            &self,
        ) -> Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> *mut NSString>;

        #[cfg(feature = "NSString")]
        /// Setter for [`descriptionFunction`][Self::descriptionFunction].
        ///
        /// # Safety
        ///
        /// `description_function` must be implemented correctly.
        #[unsafe(method(setDescriptionFunction:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDescriptionFunction(
            &self,
            description_function: Option<
                unsafe extern "C-unwind" fn(NonNull<c_void>) -> *mut NSString,
            >,
        );

        #[unsafe(method(relinquishFunction))]
        #[unsafe(method_family = none)]
        pub fn relinquishFunction(
            &self,
        ) -> Option<
            unsafe extern "C-unwind" fn(
                NonNull<c_void>,
                Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NSUInteger>,
            ),
        >;

        /// Setter for [`relinquishFunction`][Self::relinquishFunction].
        ///
        /// # Safety
        ///
        /// `relinquish_function` must be implemented correctly.
        #[unsafe(method(setRelinquishFunction:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setRelinquishFunction(
            &self,
            relinquish_function: Option<
                unsafe extern "C-unwind" fn(
                    NonNull<c_void>,
                    Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NSUInteger>,
                ),
            >,
        );

        #[unsafe(method(acquireFunction))]
        #[unsafe(method_family = none)]
        pub fn acquireFunction(
            &self,
        ) -> Option<
            unsafe extern "C-unwind" fn(
                NonNull<c_void>,
                Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NSUInteger>,
                Bool,
            ) -> NonNull<c_void>,
        >;

        /// Setter for [`acquireFunction`][Self::acquireFunction].
        ///
        /// # Safety
        ///
        /// `acquire_function` must be implemented correctly.
        #[unsafe(method(setAcquireFunction:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAcquireFunction(
            &self,
            acquire_function: Option<
                unsafe extern "C-unwind" fn(
                    NonNull<c_void>,
                    Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NSUInteger>,
                    Bool,
                ) -> NonNull<c_void>,
            >,
        );

        #[deprecated = "Garbage collection no longer supported"]
        #[unsafe(method(usesStrongWriteBarrier))]
        #[unsafe(method_family = none)]
        pub fn usesStrongWriteBarrier(&self) -> bool;

        /// Setter for [`usesStrongWriteBarrier`][Self::usesStrongWriteBarrier].
        #[deprecated = "Garbage collection no longer supported"]
        #[unsafe(method(setUsesStrongWriteBarrier:))]
        #[unsafe(method_family = none)]
        pub fn setUsesStrongWriteBarrier(&self, uses_strong_write_barrier: bool);

        #[deprecated = "Garbage collection no longer supported"]
        #[unsafe(method(usesWeakReadAndWriteBarriers))]
        #[unsafe(method_family = none)]
        pub fn usesWeakReadAndWriteBarriers(&self) -> bool;

        /// Setter for [`usesWeakReadAndWriteBarriers`][Self::usesWeakReadAndWriteBarriers].
        #[deprecated = "Garbage collection no longer supported"]
        #[unsafe(method(setUsesWeakReadAndWriteBarriers:))]
        #[unsafe(method_family = none)]
        pub fn setUsesWeakReadAndWriteBarriers(&self, uses_weak_read_and_write_barriers: bool);
    );
}

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