]> git.saurik.com Git - apple/objc4.git/blob - runtime/objc-exception.h
objc4-437.1.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 OBJC_EXPORT void objc_exception_try_enter(void *localExceptionData);
36 OBJC_EXPORT void objc_exception_try_exit(void *localExceptionData);
37 OBJC_EXPORT id objc_exception_extract(void *localExceptionData);
38 OBJC_EXPORT int objc_exception_match(Class exceptionClass, id exception);
39
40
41 typedef struct {
42 int version;
43 void (*throw_exc)(id); // version 0
44 void (*try_enter)(void *); // version 0
45 void (*try_exit)(void *); // version 0
46 id (*extract)(void *); // version 0
47 int (*match)(Class, id); // version 0
48 }
49 objc_exception_functions_t;
50
51 // get table; version tells how many
52 OBJC_EXPORT void objc_exception_get_functions(objc_exception_functions_t *table);
53
54 // set table
55 OBJC_EXPORT void objc_exception_set_functions(objc_exception_functions_t *table);
56
57
58 // !__OBJC2__
59 #else
60 // __OBJC2__
61
62 typedef id (*objc_exception_preprocessor)(id exception);
63 typedef int (*objc_exception_matcher)(Class catch_type, id exception);
64 typedef void (*objc_uncaught_exception_handler)(id exception);
65 typedef void (*objc_exception_handler)(id unused, void *context);
66
67 OBJC_EXPORT void objc_exception_throw(id exception);
68 OBJC_EXPORT void objc_exception_rethrow(void);
69 OBJC_EXPORT id objc_begin_catch(void *exc_buf);
70 OBJC_EXPORT void objc_end_catch(void);
71
72 OBJC_EXPORT objc_exception_preprocessor objc_setExceptionPreprocessor(objc_exception_preprocessor fn);
73 OBJC_EXPORT objc_exception_matcher objc_setExceptionMatcher(objc_exception_matcher fn);
74 OBJC_EXPORT objc_uncaught_exception_handler objc_setUncaughtExceptionHandler(objc_uncaught_exception_handler fn);
75
76 #ifndef __arm__
77 OBJC_EXPORT uintptr_t objc_addExceptionHandler(objc_exception_handler fn, void *context);
78 OBJC_EXPORT void objc_removeExceptionHandler(uintptr_t token);
79 #endif
80
81 // __OBJC2__
82 #endif
83
84 #endif // __OBJC_EXCEPTION_H_
85