use objc2::__framework_prelude::*;
use crate::*;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSPointerFunctionsOptions(pub NSUInteger);
impl NSPointerFunctionsOptions {
pub const NSPointerFunctionsStrongMemory: Self = Self(0 << 0);
#[deprecated = "GC no longer supported"]
pub const NSPointerFunctionsZeroingWeakMemory: Self = Self(1 << 0);
pub const NSPointerFunctionsOpaqueMemory: Self = Self(2 << 0);
pub const NSPointerFunctionsMallocMemory: Self = Self(3 << 0);
pub const NSPointerFunctionsMachVirtualMemory: Self = Self(4 << 0);
pub const NSPointerFunctionsWeakMemory: Self = Self(5 << 0);
pub const NSPointerFunctionsObjectPersonality: Self = Self(0 << 8);
pub const NSPointerFunctionsOpaquePersonality: Self = Self(1 << 8);
pub const NSPointerFunctionsObjectPointerPersonality: Self = Self(2 << 8);
pub const NSPointerFunctionsCStringPersonality: Self = Self(3 << 8);
pub const NSPointerFunctionsStructPersonality: Self = Self(4 << 8);
pub const NSPointerFunctionsIntegerPersonality: Self = Self(5 << 8);
pub const NSPointerFunctionsCopyIn: Self = Self(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!(
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct NSPointerFunctions;
unsafe impl ClassType for NSPointerFunctions {
type Super = NSObject;
type Mutability = InteriorMutable;
}
);
#[cfg(feature = "NSObject")]
unsafe impl NSCopying for NSPointerFunctions {}
unsafe impl NSObjectProtocol for NSPointerFunctions {}
extern_methods!(
unsafe impl NSPointerFunctions {
#[method_id(@__retain_semantics Init initWithOptions:)]
pub unsafe fn initWithOptions(
this: Allocated<Self>,
options: NSPointerFunctionsOptions,
) -> Id<Self>;
#[method_id(@__retain_semantics Other pointerFunctionsWithOptions:)]
pub unsafe fn pointerFunctionsWithOptions(
options: NSPointerFunctionsOptions,
) -> Id<NSPointerFunctions>;
#[method(hashFunction)]
pub unsafe fn hashFunction(
&self,
) -> Option<
unsafe extern "C" fn(
NonNull<c_void>,
Option<unsafe extern "C" fn(NonNull<c_void>) -> NSUInteger>,
) -> NSUInteger,
>;
#[method(setHashFunction:)]
pub unsafe fn setHashFunction(
&self,
hash_function: Option<
unsafe extern "C" fn(
NonNull<c_void>,
Option<unsafe extern "C" fn(NonNull<c_void>) -> NSUInteger>,
) -> NSUInteger,
>,
);
#[method(isEqualFunction)]
pub unsafe fn isEqualFunction(
&self,
) -> Option<
unsafe extern "C" fn(
NonNull<c_void>,
NonNull<c_void>,
Option<unsafe extern "C" fn(NonNull<c_void>) -> NSUInteger>,
) -> Bool,
>;
#[method(setIsEqualFunction:)]
pub unsafe fn setIsEqualFunction(
&self,
is_equal_function: Option<
unsafe extern "C" fn(
NonNull<c_void>,
NonNull<c_void>,
Option<unsafe extern "C" fn(NonNull<c_void>) -> NSUInteger>,
) -> Bool,
>,
);
#[method(sizeFunction)]
pub unsafe fn sizeFunction(
&self,
) -> Option<unsafe extern "C" fn(NonNull<c_void>) -> NSUInteger>;
#[method(setSizeFunction:)]
pub unsafe fn setSizeFunction(
&self,
size_function: Option<unsafe extern "C" fn(NonNull<c_void>) -> NSUInteger>,
);
#[cfg(feature = "NSString")]
#[method(descriptionFunction)]
pub unsafe fn descriptionFunction(
&self,
) -> Option<unsafe extern "C" fn(NonNull<c_void>) -> *mut NSString>;
#[cfg(feature = "NSString")]
#[method(setDescriptionFunction:)]
pub unsafe fn setDescriptionFunction(
&self,
description_function: Option<unsafe extern "C" fn(NonNull<c_void>) -> *mut NSString>,
);
#[method(relinquishFunction)]
pub unsafe fn relinquishFunction(
&self,
) -> Option<
unsafe extern "C" fn(
NonNull<c_void>,
Option<unsafe extern "C" fn(NonNull<c_void>) -> NSUInteger>,
),
>;
#[method(setRelinquishFunction:)]
pub unsafe fn setRelinquishFunction(
&self,
relinquish_function: Option<
unsafe extern "C" fn(
NonNull<c_void>,
Option<unsafe extern "C" fn(NonNull<c_void>) -> NSUInteger>,
),
>,
);
#[method(acquireFunction)]
pub unsafe fn acquireFunction(
&self,
) -> Option<
unsafe extern "C" fn(
NonNull<c_void>,
Option<unsafe extern "C" fn(NonNull<c_void>) -> NSUInteger>,
Bool,
) -> NonNull<c_void>,
>;
#[method(setAcquireFunction:)]
pub unsafe fn setAcquireFunction(
&self,
acquire_function: Option<
unsafe extern "C" fn(
NonNull<c_void>,
Option<unsafe extern "C" fn(NonNull<c_void>) -> NSUInteger>,
Bool,
) -> NonNull<c_void>,
>,
);
#[deprecated = "Garbage collection no longer supported"]
#[method(usesStrongWriteBarrier)]
pub unsafe fn usesStrongWriteBarrier(&self) -> bool;
#[deprecated = "Garbage collection no longer supported"]
#[method(setUsesStrongWriteBarrier:)]
pub unsafe fn setUsesStrongWriteBarrier(&self, uses_strong_write_barrier: bool);
#[deprecated = "Garbage collection no longer supported"]
#[method(usesWeakReadAndWriteBarriers)]
pub unsafe fn usesWeakReadAndWriteBarriers(&self) -> bool;
#[deprecated = "Garbage collection no longer supported"]
#[method(setUsesWeakReadAndWriteBarriers:)]
pub unsafe fn setUsesWeakReadAndWriteBarriers(
&self,
uses_weak_read_and_write_barriers: bool,
);
}
);
extern_methods!(
unsafe impl NSPointerFunctions {
#[method_id(@__retain_semantics Init init)]
pub unsafe fn init(this: Allocated<Self>) -> Id<Self>;
#[method_id(@__retain_semantics New new)]
pub unsafe fn new() -> Id<Self>;
}
);