//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgerror?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CGError(pub i32);
impl CGError {
    #[doc(alias = "kCGErrorSuccess")]
    pub const Success: Self = Self(0);
    #[doc(alias = "kCGErrorFailure")]
    pub const Failure: Self = Self(1000);
    #[doc(alias = "kCGErrorIllegalArgument")]
    pub const IllegalArgument: Self = Self(1001);
    #[doc(alias = "kCGErrorInvalidConnection")]
    pub const InvalidConnection: Self = Self(1002);
    #[doc(alias = "kCGErrorInvalidContext")]
    pub const InvalidContext: Self = Self(1003);
    #[doc(alias = "kCGErrorCannotComplete")]
    pub const CannotComplete: Self = Self(1004);
    #[doc(alias = "kCGErrorNotImplemented")]
    pub const NotImplemented: Self = Self(1006);
    #[doc(alias = "kCGErrorRangeCheck")]
    pub const RangeCheck: Self = Self(1007);
    #[doc(alias = "kCGErrorTypeCheck")]
    pub const TypeCheck: Self = Self(1008);
    #[doc(alias = "kCGErrorInvalidOperation")]
    pub const InvalidOperation: Self = Self(1010);
    #[doc(alias = "kCGErrorNoneAvailable")]
    pub const NoneAvailable: Self = Self(1011);
}

#[cfg(feature = "objc2")]
unsafe impl Encode for CGError {
    const ENCODING: Encoding = i32::ENCODING;
}

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

/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgerrorcallback?language=objc)
pub type CGErrorCallback = Option<unsafe extern "C-unwind" fn()>;

impl CGError {
    /// # Safety
    ///
    /// `callback` must be implemented correctly.
    #[doc(alias = "CGErrorSetCallback")]
    #[inline]
    pub unsafe fn set_callback(callback: CGErrorCallback) {
        extern "C-unwind" {
            fn CGErrorSetCallback(callback: CGErrorCallback);
        }
        unsafe { CGErrorSetCallback(callback) }
    }
}

extern "C-unwind" {
    #[deprecated = "renamed to `CGError::set_callback`"]
    pub fn CGErrorSetCallback(callback: CGErrorCallback);
}
