]>
Commit | Line | Data |
---|---|---|
390d5862 | 1 | /* |
b3962a83 | 2 | * Copyright (c) 2002-2003, 2006-2007 Apple Inc. All Rights Reserved. |
390d5862 | 3 | * |
b3962a83 | 4 | * @APPLE_LICENSE_HEADER_START@ |
390d5862 A |
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 | */ | |
390d5862 A |
23 | |
24 | #ifndef __OBJC_EXCEPTION_H_ | |
25 | #define __OBJC_EXCEPTION_H_ | |
26 | ||
b3962a83 A |
27 | #import <objc/objc.h> |
28 | ||
29 | // ZEROCOST_SWITCH | |
30 | #if !__LP64__ || !OBJC_ZEROCOST_EXCEPTIONS | |
390d5862 A |
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 | ||
b3962a83 A |
57 | |
58 | // !__LP64__ | |
59 | #else | |
60 | // __LP64__ | |
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 uintptr_t objc_addExceptionHandler(objc_exception_handler fn, void *context); | |
73 | OBJC_EXPORT void objc_removeExceptionHandler(uintptr_t token); | |
74 | ||
75 | OBJC_EXPORT objc_exception_preprocessor objc_setExceptionPreprocessor(objc_exception_preprocessor fn); | |
76 | OBJC_EXPORT objc_exception_matcher objc_setExceptionMatcher(objc_exception_matcher fn); | |
77 | OBJC_EXPORT objc_uncaught_exception_handler objc_setUncaughtExceptionHandler(objc_uncaught_exception_handler fn); | |
78 | ||
79 | ||
80 | // __LP64__ | |
81 | #endif | |
82 | ||
390d5862 A |
83 | #endif // __OBJC_EXCEPTION_H_ |
84 |