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 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
);
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
49 objc_exception_functions_t
;
51 // get table; version tells how many
52 OBJC_EXPORT
void objc_exception_get_functions(objc_exception_functions_t
*table
);
55 OBJC_EXPORT
void objc_exception_set_functions(objc_exception_functions_t
*table
);
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
);
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);
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
);
77 OBJC_EXPORT
uintptr_t objc_addExceptionHandler(objc_exception_handler fn
, void *context
);
78 OBJC_EXPORT
void objc_removeExceptionHandler(uintptr_t token
);
84 #endif // __OBJC_EXCEPTION_H_