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!(
    /// **********        Archiving: Writing    ***************
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsarchiver?language=objc)
    #[unsafe(super(NSCoder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "NSCoder")]
    #[deprecated = "Use NSKeyedArchiver instead"]
    pub struct NSArchiver;
);

#[cfg(feature = "NSCoder")]
extern_conformance!(
    unsafe impl NSObjectProtocol for NSArchiver {}
);

#[cfg(feature = "NSCoder")]
impl NSArchiver {
    extern_methods!(
        #[cfg(feature = "NSData")]
        #[deprecated = "Use NSKeyedArchiver instead"]
        #[unsafe(method(initForWritingWithMutableData:))]
        #[unsafe(method_family = init)]
        pub fn initForWritingWithMutableData(
            this: Allocated<Self>,
            mdata: &NSMutableData,
        ) -> Retained<Self>;

        #[cfg(feature = "NSData")]
        #[deprecated = "Use NSKeyedArchiver instead"]
        #[unsafe(method(archiverData))]
        #[unsafe(method_family = none)]
        pub fn archiverData(&self) -> Retained<NSMutableData>;

        /// # Safety
        ///
        /// `root_object` should be of the correct type.
        #[deprecated = "Use NSKeyedArchiver instead"]
        #[unsafe(method(encodeRootObject:))]
        #[unsafe(method_family = none)]
        pub unsafe fn encodeRootObject(&self, root_object: &AnyObject);

        /// # Safety
        ///
        /// `object` should be of the correct type.
        #[deprecated = "Use NSKeyedArchiver instead"]
        #[unsafe(method(encodeConditionalObject:))]
        #[unsafe(method_family = none)]
        pub unsafe fn encodeConditionalObject(&self, object: Option<&AnyObject>);

        #[cfg(feature = "NSData")]
        /// # Safety
        ///
        /// `root_object` should be of the correct type.
        #[deprecated = "Use NSKeyedArchiver instead"]
        #[unsafe(method(archivedDataWithRootObject:))]
        #[unsafe(method_family = none)]
        pub unsafe fn archivedDataWithRootObject(root_object: &AnyObject) -> Retained<NSData>;

        #[cfg(feature = "NSString")]
        /// # Safety
        ///
        /// `root_object` should be of the correct type.
        #[deprecated = "Use NSKeyedArchiver instead"]
        #[unsafe(method(archiveRootObject:toFile:))]
        #[unsafe(method_family = none)]
        pub unsafe fn archiveRootObject_toFile(root_object: &AnyObject, path: &NSString) -> bool;

        #[cfg(feature = "NSString")]
        #[deprecated = "Use NSKeyedArchiver instead"]
        #[unsafe(method(encodeClassName:intoClassName:))]
        #[unsafe(method_family = none)]
        pub fn encodeClassName_intoClassName(
            &self,
            true_name: &NSString,
            in_archive_name: &NSString,
        );

        #[cfg(feature = "NSString")]
        #[deprecated = "Use NSKeyedArchiver instead"]
        #[unsafe(method(classNameEncodedForTrueClassName:))]
        #[unsafe(method_family = none)]
        pub fn classNameEncodedForTrueClassName(
            &self,
            true_name: &NSString,
        ) -> Option<Retained<NSString>>;

        /// # Safety
        ///
        /// - `object` should be of the correct type.
        /// - `new_object` should be of the correct type.
        #[deprecated = "Use NSKeyedArchiver instead"]
        #[unsafe(method(replaceObject:withObject:))]
        #[unsafe(method_family = none)]
        pub unsafe fn replaceObject_withObject(&self, object: &AnyObject, new_object: &AnyObject);
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "NSCoder")]
impl NSArchiver {
    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>;
    );
}

#[cfg(feature = "NSCoder")]
impl DefaultRetained for NSArchiver {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

extern_class!(
    /// **********        Archiving: Reading        ***************
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsunarchiver?language=objc)
    #[unsafe(super(NSCoder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "NSCoder")]
    #[deprecated = "Use NSKeyedUnarchiver instead"]
    pub struct NSUnarchiver;
);

#[cfg(feature = "NSCoder")]
extern_conformance!(
    unsafe impl NSObjectProtocol for NSUnarchiver {}
);

#[cfg(feature = "NSCoder")]
impl NSUnarchiver {
    extern_methods!(
        #[cfg(feature = "NSData")]
        #[deprecated = "Use NSKeyedUnarchiver instead"]
        #[unsafe(method(initForReadingWithData:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initForReadingWithData(
            this: Allocated<Self>,
            data: &NSData,
        ) -> Option<Retained<Self>>;

        #[cfg(feature = "NSZone")]
        /// # Safety
        ///
        /// `zone` must be a valid pointer or null.
        #[deprecated = "Use NSKeyedUnarchiver instead"]
        #[unsafe(method(setObjectZone:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setObjectZone(&self, zone: *mut NSZone);

        #[cfg(feature = "NSZone")]
        #[deprecated = "Use NSKeyedUnarchiver instead"]
        #[unsafe(method(objectZone))]
        #[unsafe(method_family = none)]
        pub unsafe fn objectZone(&self) -> *mut NSZone;

        #[deprecated = "Use NSKeyedUnarchiver instead"]
        #[unsafe(method(isAtEnd))]
        #[unsafe(method_family = none)]
        pub unsafe fn isAtEnd(&self) -> bool;

        #[deprecated = "Use NSKeyedUnarchiver instead"]
        #[unsafe(method(systemVersion))]
        #[unsafe(method_family = none)]
        pub unsafe fn systemVersion(&self) -> c_uint;

        #[cfg(feature = "NSData")]
        #[deprecated = "Use NSKeyedUnarchiver instead"]
        #[unsafe(method(unarchiveObjectWithData:))]
        #[unsafe(method_family = none)]
        pub unsafe fn unarchiveObjectWithData(data: &NSData) -> Option<Retained<AnyObject>>;

        #[cfg(feature = "NSString")]
        #[deprecated = "Use NSKeyedUnarchiver instead"]
        #[unsafe(method(unarchiveObjectWithFile:))]
        #[unsafe(method_family = none)]
        pub unsafe fn unarchiveObjectWithFile(path: &NSString) -> Option<Retained<AnyObject>>;

        #[cfg(feature = "NSString")]
        #[deprecated = "Use NSKeyedUnarchiver instead"]
        #[unsafe(method(decodeClassName:asClassName:))]
        #[unsafe(method_family = none)]
        pub unsafe fn decodeClassName_asClassName_class(
            in_archive_name: &NSString,
            true_name: &NSString,
        );

        #[cfg(feature = "NSString")]
        #[deprecated = "Use NSKeyedUnarchiver instead"]
        #[unsafe(method(decodeClassName:asClassName:))]
        #[unsafe(method_family = none)]
        pub unsafe fn decodeClassName_asClassName(
            &self,
            in_archive_name: &NSString,
            true_name: &NSString,
        );

        #[cfg(feature = "NSString")]
        #[deprecated = "Use NSKeyedUnarchiver instead"]
        #[unsafe(method(classNameDecodedForArchiveClassName:))]
        #[unsafe(method_family = none)]
        pub unsafe fn classNameDecodedForArchiveClassName_class(
            in_archive_name: &NSString,
        ) -> Retained<NSString>;

        #[cfg(feature = "NSString")]
        #[deprecated = "Use NSKeyedUnarchiver instead"]
        #[unsafe(method(classNameDecodedForArchiveClassName:))]
        #[unsafe(method_family = none)]
        pub unsafe fn classNameDecodedForArchiveClassName(
            &self,
            in_archive_name: &NSString,
        ) -> Retained<NSString>;

        /// # Safety
        ///
        /// - `object` should be of the correct type.
        /// - `new_object` should be of the correct type.
        #[deprecated = "Use NSKeyedUnarchiver instead"]
        #[unsafe(method(replaceObject:withObject:))]
        #[unsafe(method_family = none)]
        pub unsafe fn replaceObject_withObject(&self, object: &AnyObject, new_object: &AnyObject);
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "NSCoder")]
impl NSUnarchiver {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

mod private_NSObjectNSArchiverCallback {
    pub trait Sealed {}
}

/// Category "NSArchiverCallback" on [`NSObject`].
///
/// **********        Object call back        ***************
#[doc(alias = "NSArchiverCallback")]
pub unsafe trait NSObjectNSArchiverCallback:
    ClassType + Sized + private_NSObjectNSArchiverCallback::Sealed
{
    extern_methods!(
        #[unsafe(method(classForArchiver))]
        #[unsafe(method_family = none)]
        fn classForArchiver(&self) -> Option<&'static AnyClass>;

        #[cfg(feature = "NSCoder")]
        #[deprecated]
        #[unsafe(method(replacementObjectForArchiver:))]
        #[unsafe(method_family = none)]
        fn replacementObjectForArchiver(
            &self,
            archiver: &NSArchiver,
        ) -> Option<Retained<AnyObject>>;
    );
}

impl private_NSObjectNSArchiverCallback::Sealed for NSObject {}
unsafe impl NSObjectNSArchiverCallback for NSObject {}