//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::cell::UnsafeCell;
use core::marker::{PhantomData, PhantomPinned};
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfuuid?language=objc)
#[repr(C)]
pub struct CFUUID {
    inner: [u8; 0],
    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}

cf_type!(
    #[encoding_name = "__CFUUID"]
    unsafe impl CFUUID {}
);

/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfuuidbytes?language=objc)
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct CFUUIDBytes {
    pub byte0: u8,
    pub byte1: u8,
    pub byte2: u8,
    pub byte3: u8,
    pub byte4: u8,
    pub byte5: u8,
    pub byte6: u8,
    pub byte7: u8,
    pub byte8: u8,
    pub byte9: u8,
    pub byte10: u8,
    pub byte11: u8,
    pub byte12: u8,
    pub byte13: u8,
    pub byte14: u8,
    pub byte15: u8,
}

#[cfg(feature = "objc2")]
unsafe impl Encode for CFUUIDBytes {
    const ENCODING: Encoding = Encoding::Struct(
        "?",
        &[
            <u8>::ENCODING,
            <u8>::ENCODING,
            <u8>::ENCODING,
            <u8>::ENCODING,
            <u8>::ENCODING,
            <u8>::ENCODING,
            <u8>::ENCODING,
            <u8>::ENCODING,
            <u8>::ENCODING,
            <u8>::ENCODING,
            <u8>::ENCODING,
            <u8>::ENCODING,
            <u8>::ENCODING,
            <u8>::ENCODING,
            <u8>::ENCODING,
            <u8>::ENCODING,
        ],
    );
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for CFUUIDBytes {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

#[cfg(feature = "CFBase")]
unsafe impl ConcreteType for CFUUID {
    #[doc(alias = "CFUUIDGetTypeID")]
    #[inline]
    fn type_id() -> CFTypeID {
        extern "C-unwind" {
            fn CFUUIDGetTypeID() -> CFTypeID;
        }
        unsafe { CFUUIDGetTypeID() }
    }
}

#[cfg(feature = "CFBase")]
#[inline]
pub unsafe extern "C-unwind" fn CFUUIDCreate(
    alloc: Option<&CFAllocator>,
) -> Option<CFRetained<CFUUID>> {
    extern "C-unwind" {
        fn CFUUIDCreate(alloc: Option<&CFAllocator>) -> Option<NonNull<CFUUID>>;
    }
    let ret = unsafe { CFUUIDCreate(alloc) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[cfg(feature = "CFBase")]
#[inline]
pub unsafe extern "C-unwind" fn CFUUIDCreateWithBytes(
    alloc: Option<&CFAllocator>,
    byte0: u8,
    byte1: u8,
    byte2: u8,
    byte3: u8,
    byte4: u8,
    byte5: u8,
    byte6: u8,
    byte7: u8,
    byte8: u8,
    byte9: u8,
    byte10: u8,
    byte11: u8,
    byte12: u8,
    byte13: u8,
    byte14: u8,
    byte15: u8,
) -> Option<CFRetained<CFUUID>> {
    extern "C-unwind" {
        fn CFUUIDCreateWithBytes(
            alloc: Option<&CFAllocator>,
            byte0: u8,
            byte1: u8,
            byte2: u8,
            byte3: u8,
            byte4: u8,
            byte5: u8,
            byte6: u8,
            byte7: u8,
            byte8: u8,
            byte9: u8,
            byte10: u8,
            byte11: u8,
            byte12: u8,
            byte13: u8,
            byte14: u8,
            byte15: u8,
        ) -> Option<NonNull<CFUUID>>;
    }
    let ret = unsafe {
        CFUUIDCreateWithBytes(
            alloc, byte0, byte1, byte2, byte3, byte4, byte5, byte6, byte7, byte8, byte9, byte10,
            byte11, byte12, byte13, byte14, byte15,
        )
    };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[cfg(feature = "CFBase")]
#[inline]
pub unsafe extern "C-unwind" fn CFUUIDCreateFromString(
    alloc: Option<&CFAllocator>,
    uuid_str: Option<&CFString>,
) -> Option<CFRetained<CFUUID>> {
    extern "C-unwind" {
        fn CFUUIDCreateFromString(
            alloc: Option<&CFAllocator>,
            uuid_str: Option<&CFString>,
        ) -> Option<NonNull<CFUUID>>;
    }
    let ret = unsafe { CFUUIDCreateFromString(alloc, uuid_str) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[cfg(feature = "CFBase")]
#[inline]
pub unsafe extern "C-unwind" fn CFUUIDCreateString(
    alloc: Option<&CFAllocator>,
    uuid: Option<&CFUUID>,
) -> Option<CFRetained<CFString>> {
    extern "C-unwind" {
        fn CFUUIDCreateString(
            alloc: Option<&CFAllocator>,
            uuid: Option<&CFUUID>,
        ) -> Option<NonNull<CFString>>;
    }
    let ret = unsafe { CFUUIDCreateString(alloc, uuid) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[cfg(feature = "CFBase")]
#[inline]
pub unsafe extern "C-unwind" fn CFUUIDGetConstantUUIDWithBytes(
    alloc: Option<&CFAllocator>,
    byte0: u8,
    byte1: u8,
    byte2: u8,
    byte3: u8,
    byte4: u8,
    byte5: u8,
    byte6: u8,
    byte7: u8,
    byte8: u8,
    byte9: u8,
    byte10: u8,
    byte11: u8,
    byte12: u8,
    byte13: u8,
    byte14: u8,
    byte15: u8,
) -> Option<CFRetained<CFUUID>> {
    extern "C-unwind" {
        fn CFUUIDGetConstantUUIDWithBytes(
            alloc: Option<&CFAllocator>,
            byte0: u8,
            byte1: u8,
            byte2: u8,
            byte3: u8,
            byte4: u8,
            byte5: u8,
            byte6: u8,
            byte7: u8,
            byte8: u8,
            byte9: u8,
            byte10: u8,
            byte11: u8,
            byte12: u8,
            byte13: u8,
            byte14: u8,
            byte15: u8,
        ) -> Option<NonNull<CFUUID>>;
    }
    let ret = unsafe {
        CFUUIDGetConstantUUIDWithBytes(
            alloc, byte0, byte1, byte2, byte3, byte4, byte5, byte6, byte7, byte8, byte9, byte10,
            byte11, byte12, byte13, byte14, byte15,
        )
    };
    ret.map(|ret| unsafe { CFRetained::retain(ret) })
}

extern "C-unwind" {
    pub fn CFUUIDGetUUIDBytes(uuid: &CFUUID) -> CFUUIDBytes;
}

#[cfg(feature = "CFBase")]
#[inline]
pub unsafe extern "C-unwind" fn CFUUIDCreateFromUUIDBytes(
    alloc: Option<&CFAllocator>,
    bytes: CFUUIDBytes,
) -> Option<CFRetained<CFUUID>> {
    extern "C-unwind" {
        fn CFUUIDCreateFromUUIDBytes(
            alloc: Option<&CFAllocator>,
            bytes: CFUUIDBytes,
        ) -> Option<NonNull<CFUUID>>;
    }
    let ret = unsafe { CFUUIDCreateFromUUIDBytes(alloc, bytes) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
