use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use crate::*;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSOrderedCollectionDifferenceCalculationOptions(pub NSUInteger);
bitflags::bitflags! {
impl NSOrderedCollectionDifferenceCalculationOptions: NSUInteger {
#[doc(alias = "NSOrderedCollectionDifferenceCalculationOmitInsertedObjects")]
const OmitInsertedObjects = 1<<0;
#[doc(alias = "NSOrderedCollectionDifferenceCalculationOmitRemovedObjects")]
const OmitRemovedObjects = 1<<1;
#[doc(alias = "NSOrderedCollectionDifferenceCalculationInferMoves")]
const InferMoves = 1<<2;
}
}
unsafe impl Encode for NSOrderedCollectionDifferenceCalculationOptions {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for NSOrderedCollectionDifferenceCalculationOptions {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct NSOrderedCollectionDifference<ObjectType: ?Sized = AnyObject>;
);
impl<ObjectType: ?Sized + Message> NSOrderedCollectionDifference<ObjectType> {
#[inline]
pub unsafe fn cast_unchecked<NewObjectType: ?Sized + Message>(
&self,
) -> &NSOrderedCollectionDifference<NewObjectType> {
unsafe { &*((self as *const Self).cast()) }
}
}
#[cfg(feature = "NSEnumerator")]
extern_conformance!(
unsafe impl<ObjectType: ?Sized> NSFastEnumeration for NSOrderedCollectionDifference<ObjectType> {}
);
extern_conformance!(
unsafe impl<ObjectType: ?Sized> NSObjectProtocol for NSOrderedCollectionDifference<ObjectType> {}
);
impl<ObjectType: Message> NSOrderedCollectionDifference<ObjectType> {
extern_methods!(
#[cfg(all(feature = "NSArray", feature = "NSOrderedCollectionChange"))]
#[unsafe(method(initWithChanges:))]
#[unsafe(method_family = init)]
pub fn initWithChanges(
this: Allocated<Self>,
changes: &NSArray<NSOrderedCollectionChange<ObjectType>>,
) -> Retained<Self>;
#[cfg(all(
feature = "NSArray",
feature = "NSIndexSet",
feature = "NSOrderedCollectionChange"
))]
#[unsafe(method(initWithInsertIndexes:insertedObjects:removeIndexes:removedObjects:additionalChanges:))]
#[unsafe(method_family = init)]
pub fn initWithInsertIndexes_insertedObjects_removeIndexes_removedObjects_additionalChanges(
this: Allocated<Self>,
inserts: &NSIndexSet,
inserted_objects: Option<&NSArray<ObjectType>>,
removes: &NSIndexSet,
removed_objects: Option<&NSArray<ObjectType>>,
changes: &NSArray<NSOrderedCollectionChange<ObjectType>>,
) -> Retained<Self>;
#[cfg(all(feature = "NSArray", feature = "NSIndexSet"))]
#[unsafe(method(initWithInsertIndexes:insertedObjects:removeIndexes:removedObjects:))]
#[unsafe(method_family = init)]
pub fn initWithInsertIndexes_insertedObjects_removeIndexes_removedObjects(
this: Allocated<Self>,
inserts: &NSIndexSet,
inserted_objects: Option<&NSArray<ObjectType>>,
removes: &NSIndexSet,
removed_objects: Option<&NSArray<ObjectType>>,
) -> Retained<Self>;
#[cfg(all(feature = "NSArray", feature = "NSOrderedCollectionChange"))]
#[unsafe(method(insertions))]
#[unsafe(method_family = none)]
pub fn insertions(&self) -> Retained<NSArray<NSOrderedCollectionChange<ObjectType>>>;
#[cfg(all(feature = "NSArray", feature = "NSOrderedCollectionChange"))]
#[unsafe(method(removals))]
#[unsafe(method_family = none)]
pub fn removals(&self) -> Retained<NSArray<NSOrderedCollectionChange<ObjectType>>>;
#[unsafe(method(hasChanges))]
#[unsafe(method_family = none)]
pub fn hasChanges(&self) -> bool;
#[cfg(all(feature = "NSOrderedCollectionChange", feature = "block2"))]
#[unsafe(method(differenceByTransformingChangesWithBlock:))]
#[unsafe(method_family = none)]
pub unsafe fn differenceByTransformingChangesWithBlock(
&self,
block: &block2::DynBlock<
dyn Fn(
NonNull<NSOrderedCollectionChange<ObjectType>>,
) -> NonNull<NSOrderedCollectionChange<AnyObject>>
+ '_,
>,
) -> Retained<NSOrderedCollectionDifference<AnyObject>>;
#[unsafe(method(inverseDifference))]
#[unsafe(method_family = none)]
pub fn inverseDifference(&self) -> Retained<Self>;
);
}
impl<ObjectType: Message> NSOrderedCollectionDifference<ObjectType> {
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<ObjectType: Message> DefaultRetained for NSOrderedCollectionDifference<ObjectType> {
#[inline]
fn default_retained() -> Retained<Self> {
Self::new()
}
}