objc2_foundation/generated/
NSException.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9extern "C" {
10    /// *************    Generic Exception names        **************
11    ///
12    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsgenericexception?language=objc)
13    #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
14    pub static NSGenericException: &'static NSExceptionName;
15}
16
17extern "C" {
18    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsrangeexception?language=objc)
19    #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
20    pub static NSRangeException: &'static NSExceptionName;
21}
22
23extern "C" {
24    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsinvalidargumentexception?language=objc)
25    #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
26    pub static NSInvalidArgumentException: &'static NSExceptionName;
27}
28
29extern "C" {
30    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsinternalinconsistencyexception?language=objc)
31    #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
32    pub static NSInternalInconsistencyException: &'static NSExceptionName;
33}
34
35extern "C" {
36    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmallocexception?language=objc)
37    #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
38    pub static NSMallocException: &'static NSExceptionName;
39}
40
41extern "C" {
42    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsobjectinaccessibleexception?language=objc)
43    #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
44    pub static NSObjectInaccessibleException: &'static NSExceptionName;
45}
46
47extern "C" {
48    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsobjectnotavailableexception?language=objc)
49    #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
50    pub static NSObjectNotAvailableException: &'static NSExceptionName;
51}
52
53extern "C" {
54    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsdestinationinvalidexception?language=objc)
55    #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
56    pub static NSDestinationInvalidException: &'static NSExceptionName;
57}
58
59extern "C" {
60    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsporttimeoutexception?language=objc)
61    #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
62    pub static NSPortTimeoutException: &'static NSExceptionName;
63}
64
65extern "C" {
66    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsinvalidsendportexception?language=objc)
67    #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
68    pub static NSInvalidSendPortException: &'static NSExceptionName;
69}
70
71extern "C" {
72    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsinvalidreceiveportexception?language=objc)
73    #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
74    pub static NSInvalidReceivePortException: &'static NSExceptionName;
75}
76
77extern "C" {
78    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsportsendexception?language=objc)
79    #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
80    pub static NSPortSendException: &'static NSExceptionName;
81}
82
83extern "C" {
84    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsportreceiveexception?language=objc)
85    #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
86    pub static NSPortReceiveException: &'static NSExceptionName;
87}
88
89extern "C" {
90    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsoldstyleexception?language=objc)
91    #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
92    pub static NSOldStyleException: &'static NSExceptionName;
93}
94
95extern "C" {
96    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsinconsistentarchiveexception?language=objc)
97    #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
98    pub static NSInconsistentArchiveException: &'static NSExceptionName;
99}
100
101extern_class!(
102    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsexception?language=objc)
103    #[unsafe(super(NSObject))]
104    #[derive(PartialEq, Eq, Hash)]
105    pub struct NSException;
106);
107
108#[cfg(feature = "NSObject")]
109extern_conformance!(
110    unsafe impl NSCoding for NSException {}
111);
112
113#[cfg(feature = "NSObject")]
114extern_conformance!(
115    unsafe impl NSCopying for NSException {}
116);
117
118#[cfg(feature = "NSObject")]
119unsafe impl CopyingHelper for NSException {
120    type Result = Self;
121}
122
123extern_conformance!(
124    unsafe impl NSObjectProtocol for NSException {}
125);
126
127#[cfg(feature = "NSObject")]
128extern_conformance!(
129    unsafe impl NSSecureCoding for NSException {}
130);
131
132impl NSException {
133    extern_methods!(
134        #[cfg(all(
135            feature = "NSDictionary",
136            feature = "NSObjCRuntime",
137            feature = "NSString"
138        ))]
139        /// # Safety
140        ///
141        /// `user_info` generic should be of the correct type.
142        #[unsafe(method(exceptionWithName:reason:userInfo:))]
143        #[unsafe(method_family = none)]
144        pub unsafe fn exceptionWithName_reason_userInfo(
145            name: &NSExceptionName,
146            reason: Option<&NSString>,
147            user_info: Option<&NSDictionary>,
148        ) -> Retained<NSException>;
149
150        #[cfg(all(
151            feature = "NSDictionary",
152            feature = "NSObjCRuntime",
153            feature = "NSString"
154        ))]
155        /// # Safety
156        ///
157        /// `a_user_info` generic should be of the correct type.
158        #[unsafe(method(initWithName:reason:userInfo:))]
159        #[unsafe(method_family = init)]
160        pub unsafe fn initWithName_reason_userInfo(
161            this: Allocated<Self>,
162            a_name: &NSExceptionName,
163            a_reason: Option<&NSString>,
164            a_user_info: Option<&NSDictionary>,
165        ) -> Retained<Self>;
166
167        #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
168        #[unsafe(method(name))]
169        #[unsafe(method_family = none)]
170        pub fn name(&self) -> Retained<NSExceptionName>;
171
172        #[cfg(feature = "NSString")]
173        #[unsafe(method(reason))]
174        #[unsafe(method_family = none)]
175        pub fn reason(&self) -> Option<Retained<NSString>>;
176
177        #[cfg(feature = "NSDictionary")]
178        #[unsafe(method(userInfo))]
179        #[unsafe(method_family = none)]
180        pub fn userInfo(&self) -> Option<Retained<NSDictionary>>;
181
182        #[cfg(all(feature = "NSArray", feature = "NSValue"))]
183        #[unsafe(method(callStackReturnAddresses))]
184        #[unsafe(method_family = none)]
185        pub fn callStackReturnAddresses(&self) -> Retained<NSArray<NSNumber>>;
186
187        #[cfg(all(feature = "NSArray", feature = "NSString"))]
188        #[unsafe(method(callStackSymbols))]
189        #[unsafe(method_family = none)]
190        pub fn callStackSymbols(&self) -> Retained<NSArray<NSString>>;
191    );
192}
193
194/// Methods declared on superclass `NSObject`.
195impl NSException {
196    extern_methods!(
197        #[unsafe(method(init))]
198        #[unsafe(method_family = init)]
199        pub fn init(this: Allocated<Self>) -> Retained<Self>;
200    );
201}
202
203/// NSExceptionRaisingConveniences.
204impl NSException {
205    extern_methods!();
206}
207
208/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsuncaughtexceptionhandler?language=objc)
209pub type NSUncaughtExceptionHandler = core::ffi::c_void;
210
211#[inline]
212pub extern "C-unwind" fn NSGetUncaughtExceptionHandler() -> *mut NSUncaughtExceptionHandler {
213    extern "C-unwind" {
214        fn NSGetUncaughtExceptionHandler() -> *mut NSUncaughtExceptionHandler;
215    }
216    unsafe { NSGetUncaughtExceptionHandler() }
217}
218
219extern "C-unwind" {
220    /// # Safety
221    ///
222    /// `_` must be a valid pointer or null.
223    pub fn NSSetUncaughtExceptionHandler(param1: *mut NSUncaughtExceptionHandler);
224}
225
226extern "C" {
227    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsassertionhandlerkey?language=objc)
228    #[cfg(feature = "NSString")]
229    pub static NSAssertionHandlerKey: &'static NSString;
230}
231
232extern_class!(
233    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsassertionhandler?language=objc)
234    #[unsafe(super(NSObject))]
235    #[derive(Debug, PartialEq, Eq, Hash)]
236    pub struct NSAssertionHandler;
237);
238
239extern_conformance!(
240    unsafe impl NSObjectProtocol for NSAssertionHandler {}
241);
242
243impl NSAssertionHandler {
244    extern_methods!(
245        #[unsafe(method(currentHandler))]
246        #[unsafe(method_family = none)]
247        pub fn currentHandler() -> Retained<NSAssertionHandler>;
248    );
249}
250
251/// Methods declared on superclass `NSObject`.
252impl NSAssertionHandler {
253    extern_methods!(
254        #[unsafe(method(init))]
255        #[unsafe(method_family = init)]
256        pub fn init(this: Allocated<Self>) -> Retained<Self>;
257
258        #[unsafe(method(new))]
259        #[unsafe(method_family = new)]
260        pub fn new() -> Retained<Self>;
261    );
262}
263
264impl DefaultRetained for NSAssertionHandler {
265    #[inline]
266    fn default_retained() -> Retained<Self> {
267        Self::new()
268    }
269}