]> git.saurik.com Git - apple/objc4.git/blob - runtime/objc-exception.h
objc4-706.tar.gz
[apple/objc4.git] / runtime / objc-exception.h
1 /*
2 * Copyright (c) 2002-2003, 2006-2007 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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
11 * file.
12 *
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.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 #ifndef __OBJC_EXCEPTION_H_
25 #define __OBJC_EXCEPTION_H_
26
27 #include <objc/objc.h>
28 #include <stdint.h>
29
30 #if !__OBJC2__
31
32 // compiler reserves a setjmp buffer + 4 words as localExceptionData
33
34 OBJC_EXPORT void objc_exception_throw(id exception)
35 __OSX_AVAILABLE(10.3)
36 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE;
37 OBJC_EXPORT void objc_exception_try_enter(void *localExceptionData)
38 __OSX_AVAILABLE(10.3)
39 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE;
40 OBJC_EXPORT void objc_exception_try_exit(void *localExceptionData)
41 __OSX_AVAILABLE(10.3)
42 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE;
43 OBJC_EXPORT id objc_exception_extract(void *localExceptionData)
44 __OSX_AVAILABLE(10.3)
45 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE;
46 OBJC_EXPORT int objc_exception_match(Class exceptionClass, id exception)
47 __OSX_AVAILABLE(10.3)
48 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE;
49
50
51 typedef struct {
52 int version;
53 void (*throw_exc)(id); // version 0
54 void (*try_enter)(void *); // version 0
55 void (*try_exit)(void *); // version 0
56 id (*extract)(void *); // version 0
57 int (*match)(Class, id); // version 0
58 } objc_exception_functions_t;
59
60 // get table; version tells how many
61 OBJC_EXPORT void objc_exception_get_functions(objc_exception_functions_t *table)
62 __OSX_AVAILABLE(10.3)
63 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE;
64
65 // set table
66 OBJC_EXPORT void objc_exception_set_functions(objc_exception_functions_t *table)
67 __OSX_AVAILABLE(10.3)
68 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE;
69
70
71 // !__OBJC2__
72 #else
73 // __OBJC2__
74
75 typedef id (*objc_exception_preprocessor)(id exception);
76 typedef int (*objc_exception_matcher)(Class catch_type, id exception);
77 typedef void (*objc_uncaught_exception_handler)(id exception);
78 typedef void (*objc_exception_handler)(id unused, void *context);
79
80 /**
81 * Throw a runtime exception. This function is inserted by the compiler
82 * where \c @throw would otherwise be.
83 *
84 * @param exception The exception to be thrown.
85 */
86 OBJC_EXPORT void objc_exception_throw(id exception)
87 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
88 OBJC_EXPORT void objc_exception_rethrow(void)
89 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
90 OBJC_EXPORT id objc_begin_catch(void *exc_buf)
91 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
92 OBJC_EXPORT void objc_end_catch(void)
93 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
94 OBJC_EXPORT void objc_terminate(void)
95 OBJC_AVAILABLE(10.8, 6.0, 9.0, 1.0);
96
97 OBJC_EXPORT objc_exception_preprocessor objc_setExceptionPreprocessor(objc_exception_preprocessor fn)
98 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
99 OBJC_EXPORT objc_exception_matcher objc_setExceptionMatcher(objc_exception_matcher fn)
100 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
101 OBJC_EXPORT objc_uncaught_exception_handler objc_setUncaughtExceptionHandler(objc_uncaught_exception_handler fn)
102 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
103
104 // Not for iOS.
105 OBJC_EXPORT uintptr_t objc_addExceptionHandler(objc_exception_handler fn, void *context)
106 __OSX_AVAILABLE(10.5)
107 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE;
108 OBJC_EXPORT void objc_removeExceptionHandler(uintptr_t token)
109 __OSX_AVAILABLE(10.5)
110 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE;
111
112 // __OBJC2__
113 #endif
114
115 #endif // __OBJC_EXCEPTION_H_
116