]> git.saurik.com Git - apple/objc4.git/blame - runtime/objc-exception.h
objc4-371.2.tar.gz
[apple/objc4.git] / runtime / objc-exception.h
CommitLineData
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
34OBJC_EXPORT void objc_exception_throw(id exception);
35OBJC_EXPORT void objc_exception_try_enter(void *localExceptionData);
36OBJC_EXPORT void objc_exception_try_exit(void *localExceptionData);
37OBJC_EXPORT id objc_exception_extract(void *localExceptionData);
38OBJC_EXPORT int objc_exception_match(Class exceptionClass, id exception);
39
40
41typedef 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
52OBJC_EXPORT void objc_exception_get_functions(objc_exception_functions_t *table);
53
54// set table
55OBJC_EXPORT void objc_exception_set_functions(objc_exception_functions_t *table);
56
b3962a83
A
57
58// !__LP64__
59#else
60// __LP64__
61
62typedef id (*objc_exception_preprocessor)(id exception);
63typedef int (*objc_exception_matcher)(Class catch_type, id exception);
64typedef void (*objc_uncaught_exception_handler)(id exception);
65typedef void (*objc_exception_handler)(id unused, void *context);
66
67OBJC_EXPORT void objc_exception_throw(id exception);
68OBJC_EXPORT void objc_exception_rethrow(void);
69OBJC_EXPORT id objc_begin_catch(void *exc_buf);
70OBJC_EXPORT void objc_end_catch(void);
71
72OBJC_EXPORT uintptr_t objc_addExceptionHandler(objc_exception_handler fn, void *context);
73OBJC_EXPORT void objc_removeExceptionHandler(uintptr_t token);
74
75OBJC_EXPORT objc_exception_preprocessor objc_setExceptionPreprocessor(objc_exception_preprocessor fn);
76OBJC_EXPORT objc_exception_matcher objc_setExceptionMatcher(objc_exception_matcher fn);
77OBJC_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