1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

extern "C" {
    pub static NSUncaughtSystemExceptionException: Option<&'static NSString>;
}

extern "C" {
    pub static NSUncaughtRuntimeErrorException: Option<&'static NSString>;
}

extern "C" {
    pub static NSStackTraceKey: Option<&'static NSString>;
}

extern "C" {
    pub fn NSExceptionHandlerResume();
}

pub const NSLogUncaughtExceptionMask: c_uint = 1 << 0;
pub const NSHandleUncaughtExceptionMask: c_uint = 1 << 1;
pub const NSLogUncaughtSystemExceptionMask: c_uint = 1 << 2;
pub const NSHandleUncaughtSystemExceptionMask: c_uint = 1 << 3;
pub const NSLogUncaughtRuntimeErrorMask: c_uint = 1 << 4;
pub const NSHandleUncaughtRuntimeErrorMask: c_uint = 1 << 5;
pub const NSLogTopLevelExceptionMask: c_uint = 1 << 6;
pub const NSHandleTopLevelExceptionMask: c_uint = 1 << 7;
pub const NSLogOtherExceptionMask: c_uint = 1 << 8;
pub const NSHandleOtherExceptionMask: c_uint = 1 << 9;

pub const NSHangOnUncaughtExceptionMask: c_uint = 1 << 0;
pub const NSHangOnUncaughtSystemExceptionMask: c_uint = 1 << 1;
pub const NSHangOnUncaughtRuntimeErrorMask: c_uint = 1 << 2;
pub const NSHangOnTopLevelExceptionMask: c_uint = 1 << 3;
pub const NSHangOnOtherExceptionMask: c_uint = 1 << 4;

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSExceptionHandler;

    unsafe impl ClassType for NSExceptionHandler {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

unsafe impl NSObjectProtocol for NSExceptionHandler {}

extern_methods!(
    unsafe impl NSExceptionHandler {
        #[method_id(@__retain_semantics Other defaultExceptionHandler)]
        pub unsafe fn defaultExceptionHandler() -> Option<Retained<NSExceptionHandler>>;

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

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

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

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

        #[method(setDelegate:)]
        pub unsafe fn setDelegate(&self, an_object: Option<&AnyObject>);

        #[method_id(@__retain_semantics Other delegate)]
        pub unsafe fn delegate(&self) -> Option<Retained<AnyObject>>;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl NSExceptionHandler {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Retained<Self>;
    }
);

extern_category!(
    /// Category "NSExceptionHandlerDelegate" on [`NSObject`].
    #[doc(alias = "NSExceptionHandlerDelegate")]
    pub unsafe trait NSObjectNSExceptionHandlerDelegate {
        #[method(exceptionHandler:shouldLogException:mask:)]
        unsafe fn exceptionHandler_shouldLogException_mask(
            &self,
            sender: Option<&NSExceptionHandler>,
            exception: Option<&NSException>,
            a_mask: NSUInteger,
        ) -> bool;

        #[method(exceptionHandler:shouldHandleException:mask:)]
        unsafe fn exceptionHandler_shouldHandleException_mask(
            &self,
            sender: Option<&NSExceptionHandler>,
            exception: Option<&NSException>,
            a_mask: NSUInteger,
        ) -> bool;
    }

    unsafe impl NSObjectNSExceptionHandlerDelegate for NSObject {}
);