2 * Copyright (c) 2002-2003, 2006-2007 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
24 #ifndef __OBJC_EXCEPTION_H_
25 #define __OBJC_EXCEPTION_H_
27 #include <objc/objc.h>
32 // compiler reserves a setjmp buffer + 4 words as localExceptionData
35 objc_exception_throw(id _Nonnull exception
)
37 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE
38 __WATCHOS_UNAVAILABLE __BRIDGEOS_UNAVAILABLE
;
41 objc_exception_try_enter(void * _Nonnull localExceptionData
)
43 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE
44 __WATCHOS_UNAVAILABLE __BRIDGEOS_UNAVAILABLE
;
47 objc_exception_try_exit(void * _Nonnull localExceptionData
)
49 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE
50 __WATCHOS_UNAVAILABLE __BRIDGEOS_UNAVAILABLE
;
52 OBJC_EXPORT id _Nonnull
53 objc_exception_extract(void * _Nonnull localExceptionData
)
55 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE
56 __WATCHOS_UNAVAILABLE __BRIDGEOS_UNAVAILABLE
;
58 OBJC_EXPORT
int objc_exception_match(Class _Nonnull exceptionClass
,
59 id _Nonnull exception
)
61 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE
62 __WATCHOS_UNAVAILABLE __BRIDGEOS_UNAVAILABLE
;
67 void (* _Nonnull throw_exc
)(id _Nonnull
); // version 0
68 void (* _Nonnull try_enter
)(void * _Nonnull
); // version 0
69 void (* _Nonnull try_exit
)(void * _Nonnull
); // version 0
70 id
_Nonnull (* _Nonnull extract
)(void * _Nonnull
); // version 0
71 int (* _Nonnull match
)(Class _Nonnull
, id _Nonnull
); // version 0
72 } objc_exception_functions_t
;
74 // get table; version tells how many
76 objc_exception_get_functions(objc_exception_functions_t
* _Nullable table
)
78 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE
79 __WATCHOS_UNAVAILABLE __BRIDGEOS_UNAVAILABLE
;
83 objc_exception_set_functions(objc_exception_functions_t
* _Nullable table
)
85 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE
86 __WATCHOS_UNAVAILABLE __BRIDGEOS_UNAVAILABLE
;
93 typedef id
_Nonnull (*objc_exception_preprocessor
)(id _Nonnull exception
);
94 typedef int (*objc_exception_matcher
)(Class _Nonnull catch_type
,
95 id _Nonnull exception
);
96 typedef void (*objc_uncaught_exception_handler
)(id _Null_unspecified
/* _Nonnull */ exception
);
97 typedef void (*objc_exception_handler
)(id _Nullable unused
,
98 void * _Nullable context
);
101 * Throw a runtime exception. This function is inserted by the compiler
102 * where \c @throw would otherwise be.
104 * @param exception The exception to be thrown.
107 objc_exception_throw(id _Nonnull exception
)
108 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
111 objc_exception_rethrow(void)
112 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
114 OBJC_EXPORT id _Nonnull
115 objc_begin_catch(void * _Nonnull exc_buf
)
116 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
120 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
124 OBJC_AVAILABLE(10.8, 6.0, 9.0, 1.0, 2.0);
126 OBJC_EXPORT objc_exception_preprocessor _Nonnull
127 objc_setExceptionPreprocessor(objc_exception_preprocessor _Nonnull fn
)
128 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
130 OBJC_EXPORT objc_exception_matcher _Nonnull
131 objc_setExceptionMatcher(objc_exception_matcher _Nonnull fn
)
132 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
134 OBJC_EXPORT objc_uncaught_exception_handler _Nonnull
135 objc_setUncaughtExceptionHandler(objc_uncaught_exception_handler _Nonnull fn
)
136 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
139 OBJC_EXPORT
uintptr_t
140 objc_addExceptionHandler(objc_exception_handler _Nonnull fn
,
141 void * _Nullable context
)
142 __OSX_AVAILABLE(10.5)
143 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE
144 __WATCHOS_UNAVAILABLE __BRIDGEOS_UNAVAILABLE
;
147 objc_removeExceptionHandler(uintptr_t token
)
148 __OSX_AVAILABLE(10.5)
149 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE
150 __WATCHOS_UNAVAILABLE __BRIDGEOS_UNAVAILABLE
;
155 #endif // __OBJC_EXCEPTION_H_