objc2-exception-handling 0.3.2

Bindings to the ExceptionHandling 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 objc2_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/exceptionhandling/nslogandhandleeveryexceptionmask?language=objc)
pub const NSLogAndHandleEveryExceptionMask: c_uint = NSLogUncaughtExceptionMask
    | NSLogUncaughtSystemExceptionMask
    | NSLogUncaughtRuntimeErrorMask
    | NSHandleUncaughtExceptionMask
    | NSHandleUncaughtSystemExceptionMask
    | NSHandleUncaughtRuntimeErrorMask
    | NSLogTopLevelExceptionMask
    | NSHandleTopLevelExceptionMask
    | NSLogOtherExceptionMask
    | NSHandleOtherExceptionMask;
/// [Apple's documentation](https://developer.apple.com/documentation/exceptionhandling/nshangoneveryexceptionmask?language=objc)
pub const NSHangOnEveryExceptionMask: c_uint = NSHangOnUncaughtExceptionMask
    | NSHangOnUncaughtSystemExceptionMask
    | NSHangOnUncaughtRuntimeErrorMask
    | NSHangOnTopLevelExceptionMask
    | NSHangOnOtherExceptionMask;
extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/exceptionhandling/nsuncaughtsystemexceptionexception?language=objc)
    pub static NSUncaughtSystemExceptionException: Option<&'static NSString>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/exceptionhandling/nsuncaughtruntimeerrorexception?language=objc)
    pub static NSUncaughtRuntimeErrorException: Option<&'static NSString>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/exceptionhandling/nsstacktracekey?language=objc)
    pub static NSStackTraceKey: Option<&'static NSString>;
}

impl NSExceptionHandler {
    #[doc(alias = "NSExceptionHandlerResume")]
    #[inline]
    pub unsafe fn resume() {
        extern "C-unwind" {
            fn NSExceptionHandlerResume();
        }
        unsafe { NSExceptionHandlerResume() }
    }
}

/// [Apple's documentation](https://developer.apple.com/documentation/exceptionhandling/nsloguncaughtexceptionmask?language=objc)
pub const NSLogUncaughtExceptionMask: c_uint = 1 << 0;
/// [Apple's documentation](https://developer.apple.com/documentation/exceptionhandling/nshandleuncaughtexceptionmask?language=objc)
pub const NSHandleUncaughtExceptionMask: c_uint = 1 << 1;
/// [Apple's documentation](https://developer.apple.com/documentation/exceptionhandling/nsloguncaughtsystemexceptionmask?language=objc)
pub const NSLogUncaughtSystemExceptionMask: c_uint = 1 << 2;
/// [Apple's documentation](https://developer.apple.com/documentation/exceptionhandling/nshandleuncaughtsystemexceptionmask?language=objc)
pub const NSHandleUncaughtSystemExceptionMask: c_uint = 1 << 3;
/// [Apple's documentation](https://developer.apple.com/documentation/exceptionhandling/nsloguncaughtruntimeerrormask?language=objc)
pub const NSLogUncaughtRuntimeErrorMask: c_uint = 1 << 4;
/// [Apple's documentation](https://developer.apple.com/documentation/exceptionhandling/nshandleuncaughtruntimeerrormask?language=objc)
pub const NSHandleUncaughtRuntimeErrorMask: c_uint = 1 << 5;
/// [Apple's documentation](https://developer.apple.com/documentation/exceptionhandling/nslogtoplevelexceptionmask?language=objc)
pub const NSLogTopLevelExceptionMask: c_uint = 1 << 6;
/// [Apple's documentation](https://developer.apple.com/documentation/exceptionhandling/nshandletoplevelexceptionmask?language=objc)
pub const NSHandleTopLevelExceptionMask: c_uint = 1 << 7;
/// [Apple's documentation](https://developer.apple.com/documentation/exceptionhandling/nslogotherexceptionmask?language=objc)
pub const NSLogOtherExceptionMask: c_uint = 1 << 8;
/// [Apple's documentation](https://developer.apple.com/documentation/exceptionhandling/nshandleotherexceptionmask?language=objc)
pub const NSHandleOtherExceptionMask: c_uint = 1 << 9;

/// [Apple's documentation](https://developer.apple.com/documentation/exceptionhandling/nshangonuncaughtexceptionmask?language=objc)
pub const NSHangOnUncaughtExceptionMask: c_uint = 1 << 0;
/// [Apple's documentation](https://developer.apple.com/documentation/exceptionhandling/nshangonuncaughtsystemexceptionmask?language=objc)
pub const NSHangOnUncaughtSystemExceptionMask: c_uint = 1 << 1;
/// [Apple's documentation](https://developer.apple.com/documentation/exceptionhandling/nshangonuncaughtruntimeerrormask?language=objc)
pub const NSHangOnUncaughtRuntimeErrorMask: c_uint = 1 << 2;
/// [Apple's documentation](https://developer.apple.com/documentation/exceptionhandling/nshangontoplevelexceptionmask?language=objc)
pub const NSHangOnTopLevelExceptionMask: c_uint = 1 << 3;
/// [Apple's documentation](https://developer.apple.com/documentation/exceptionhandling/nshangonotherexceptionmask?language=objc)
pub const NSHangOnOtherExceptionMask: c_uint = 1 << 4;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/exceptionhandling/nsexceptionhandler?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSExceptionHandler;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for NSExceptionHandler {}
);

impl NSExceptionHandler {
    extern_methods!(
        #[unsafe(method(defaultExceptionHandler))]
        #[unsafe(method_family = none)]
        pub unsafe fn defaultExceptionHandler() -> Option<Retained<NSExceptionHandler>>;

        #[unsafe(method(setExceptionHandlingMask:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setExceptionHandlingMask(&self, a_mask: NSUInteger);

        #[unsafe(method(exceptionHandlingMask))]
        #[unsafe(method_family = none)]
        pub unsafe fn exceptionHandlingMask(&self) -> NSUInteger;

        #[unsafe(method(setExceptionHangingMask:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setExceptionHangingMask(&self, a_mask: NSUInteger);

        #[unsafe(method(exceptionHangingMask))]
        #[unsafe(method_family = none)]
        pub unsafe fn exceptionHangingMask(&self) -> NSUInteger;

        /// # Safety
        ///
        /// - `an_object` should be of the correct type.
        /// - `an_object` might not allow `None`.
        #[unsafe(method(setDelegate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDelegate(&self, an_object: Option<&AnyObject>);

        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(&self) -> Option<Retained<AnyObject>>;
    );
}

/// Methods declared on superclass `NSObject`.
impl NSExceptionHandler {
    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_NSObjectNSExceptionHandlerDelegate {
    pub trait Sealed {}
}

/// Category "NSExceptionHandlerDelegate" on [`NSObject`].
#[doc(alias = "NSExceptionHandlerDelegate")]
pub unsafe trait NSObjectNSExceptionHandlerDelegate:
    ClassType + Sized + private_NSObjectNSExceptionHandlerDelegate::Sealed
{
    extern_methods!(
        /// # Safety
        ///
        /// - `sender` might not allow `None`.
        /// - `exception` might not allow `None`.
        #[unsafe(method(exceptionHandler:shouldLogException:mask:))]
        #[unsafe(method_family = none)]
        unsafe fn exceptionHandler_shouldLogException_mask(
            &self,
            sender: Option<&NSExceptionHandler>,
            exception: Option<&NSException>,
            a_mask: NSUInteger,
        ) -> bool;

        /// # Safety
        ///
        /// - `sender` might not allow `None`.
        /// - `exception` might not allow `None`.
        #[unsafe(method(exceptionHandler:shouldHandleException:mask:))]
        #[unsafe(method_family = none)]
        unsafe fn exceptionHandler_shouldHandleException_mask(
            &self,
            sender: Option<&NSExceptionHandler>,
            exception: Option<&NSException>,
            a_mask: NSUInteger,
        ) -> bool;
    );
}

impl private_NSObjectNSExceptionHandlerDelegate::Sealed for NSObject {}
unsafe impl NSObjectNSExceptionHandlerDelegate for NSObject {}

extern "C-unwind" {
    #[deprecated = "renamed to `NSExceptionHandler::resume`"]
    pub fn NSExceptionHandlerResume();
}