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
34 OBJC_EXPORT
void objc_exception_throw(id exception
)
35 __OSX_AVAILABLE_STARTING(__MAC_10_3
, __IPHONE_NA
);
36 OBJC_EXPORT
void objc_exception_try_enter(void *localExceptionData
)
37 __OSX_AVAILABLE_STARTING(__MAC_10_3
, __IPHONE_NA
);
38 OBJC_EXPORT
void objc_exception_try_exit(void *localExceptionData
)
39 __OSX_AVAILABLE_STARTING(__MAC_10_3
, __IPHONE_NA
);
40 OBJC_EXPORT id
objc_exception_extract(void *localExceptionData
)
41 __OSX_AVAILABLE_STARTING(__MAC_10_3
, __IPHONE_NA
);
42 OBJC_EXPORT
int objc_exception_match(Class exceptionClass
, id exception
)
43 __OSX_AVAILABLE_STARTING(__MAC_10_3
, __IPHONE_NA
);
48 void (*throw_exc
)(id
); // version 0
49 void (*try_enter
)(void *); // version 0
50 void (*try_exit
)(void *); // version 0
51 id (*extract
)(void *); // version 0
52 int (*match
)(Class
, id
); // version 0
53 } objc_exception_functions_t
;
55 // get table; version tells how many
56 OBJC_EXPORT
void objc_exception_get_functions(objc_exception_functions_t
*table
)
57 __OSX_AVAILABLE_STARTING(__MAC_10_3
, __IPHONE_NA
);
60 OBJC_EXPORT
void objc_exception_set_functions(objc_exception_functions_t
*table
)
61 __OSX_AVAILABLE_STARTING(__MAC_10_3
, __IPHONE_NA
);
68 typedef id (*objc_exception_preprocessor
)(id exception
);
69 typedef int (*objc_exception_matcher
)(Class catch_type
, id exception
);
70 typedef void (*objc_uncaught_exception_handler
)(id exception
);
71 typedef void (*objc_exception_handler
)(id unused
, void *context
);
74 * Throw a runtime exception. This function is inserted by the compiler
75 * where \c @throw would otherwise be.
77 * @param exception The exception to be thrown.
79 OBJC_EXPORT
void objc_exception_throw(id exception
)
80 __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
81 OBJC_EXPORT
void objc_exception_rethrow(void)
82 __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
83 OBJC_EXPORT id
objc_begin_catch(void *exc_buf
)
84 __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
85 OBJC_EXPORT
void objc_end_catch(void)
86 __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
87 OBJC_EXPORT
void objc_terminate(void)
88 __OSX_AVAILABLE_STARTING(__MAC_10_8
, __IPHONE_6_0
);
90 OBJC_EXPORT objc_exception_preprocessor
objc_setExceptionPreprocessor(objc_exception_preprocessor fn
)
91 __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
92 OBJC_EXPORT objc_exception_matcher
objc_setExceptionMatcher(objc_exception_matcher fn
)
93 __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
94 OBJC_EXPORT objc_uncaught_exception_handler
objc_setUncaughtExceptionHandler(objc_uncaught_exception_handler fn
)
95 __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
98 OBJC_EXPORT
uintptr_t objc_addExceptionHandler(objc_exception_handler fn
, void *context
)
99 __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_NA
);
100 OBJC_EXPORT
void objc_removeExceptionHandler(uintptr_t token
)
101 __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_NA
);
106 #endif // __OBJC_EXCEPTION_H_