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
)
36 OBJC_OSX_AVAILABLE_OTHERS_UNAVAILABLE(10.3);
39 objc_exception_try_enter(void * _Nonnull localExceptionData
)
40 OBJC_OSX_AVAILABLE_OTHERS_UNAVAILABLE(10.3);
43 objc_exception_try_exit(void * _Nonnull localExceptionData
)
44 OBJC_OSX_AVAILABLE_OTHERS_UNAVAILABLE(10.3);
46 OBJC_EXPORT id _Nonnull
47 objc_exception_extract(void * _Nonnull localExceptionData
)
48 OBJC_OSX_AVAILABLE_OTHERS_UNAVAILABLE(10.3);
50 OBJC_EXPORT
int objc_exception_match(Class _Nonnull exceptionClass
,
51 id _Nonnull exception
)
52 OBJC_OSX_AVAILABLE_OTHERS_UNAVAILABLE(10.3);
57 void (* _Nonnull throw_exc
)(id _Nonnull
); // version 0
58 void (* _Nonnull try_enter
)(void * _Nonnull
); // version 0
59 void (* _Nonnull try_exit
)(void * _Nonnull
); // version 0
60 id
_Nonnull (* _Nonnull extract
)(void * _Nonnull
); // version 0
61 int (* _Nonnull match
)(Class _Nonnull
, id _Nonnull
); // version 0
62 } objc_exception_functions_t
;
64 // get table; version tells how many
66 objc_exception_get_functions(objc_exception_functions_t
* _Nullable table
)
67 OBJC_OSX_AVAILABLE_OTHERS_UNAVAILABLE(10.3);
71 objc_exception_set_functions(objc_exception_functions_t
* _Nullable table
)
72 OBJC_OSX_AVAILABLE_OTHERS_UNAVAILABLE(10.3);
79 typedef id
_Nonnull (*objc_exception_preprocessor
)(id _Nonnull exception
);
80 typedef int (*objc_exception_matcher
)(Class _Nonnull catch_type
,
81 id _Nonnull exception
);
82 typedef void (*objc_uncaught_exception_handler
)(id _Null_unspecified
/* _Nonnull */ exception
);
83 typedef void (*objc_exception_handler
)(id _Nullable unused
,
84 void * _Nullable context
);
87 * Throw a runtime exception. This function is inserted by the compiler
88 * where \c @throw would otherwise be.
90 * @param exception The exception to be thrown.
93 objc_exception_throw(id _Nonnull exception
)
94 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
97 objc_exception_rethrow(void)
98 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
100 OBJC_EXPORT id _Nonnull
101 objc_begin_catch(void * _Nonnull exc_buf
)
102 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
106 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
110 OBJC_AVAILABLE(10.8, 6.0, 9.0, 1.0, 2.0);
112 OBJC_EXPORT objc_exception_preprocessor _Nonnull
113 objc_setExceptionPreprocessor(objc_exception_preprocessor _Nonnull fn
)
114 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
116 OBJC_EXPORT objc_exception_matcher _Nonnull
117 objc_setExceptionMatcher(objc_exception_matcher _Nonnull fn
)
118 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
120 OBJC_EXPORT objc_uncaught_exception_handler _Nonnull
121 objc_setUncaughtExceptionHandler(objc_uncaught_exception_handler _Nonnull fn
)
122 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
125 OBJC_EXPORT
uintptr_t
126 objc_addExceptionHandler(objc_exception_handler _Nonnull fn
,
127 void * _Nullable context
)
128 OBJC_OSX_AVAILABLE_OTHERS_UNAVAILABLE(10.5);
131 objc_removeExceptionHandler(uintptr_t token
)
132 OBJC_OSX_AVAILABLE_OTHERS_UNAVAILABLE(10.5);
137 #endif // __OBJC_EXCEPTION_H_