-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobjc-exception.h
156 lines (127 loc) · 5.08 KB
/
objc-exception.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
* Copyright (c) 2002-2003, 2006-2007 Apple Inc. All Rights Reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef __OBJC_EXCEPTION_H_
#define __OBJC_EXCEPTION_H_
#include <objc/objc.h>
#include <stdint.h>
#if !__OBJC2__
// compiler reserves a setjmp buffer + 4 words as localExceptionData
OBJC_EXPORT void
objc_exception_throw(id _Nonnull exception)
__OSX_AVAILABLE(10.3)
__IOS_UNAVAILABLE __TVOS_UNAVAILABLE
__WATCHOS_UNAVAILABLE __BRIDGEOS_UNAVAILABLE;
OBJC_EXPORT void
objc_exception_try_enter(void * _Nonnull localExceptionData)
__OSX_AVAILABLE(10.3)
__IOS_UNAVAILABLE __TVOS_UNAVAILABLE
__WATCHOS_UNAVAILABLE __BRIDGEOS_UNAVAILABLE;
OBJC_EXPORT void
objc_exception_try_exit(void * _Nonnull localExceptionData)
__OSX_AVAILABLE(10.3)
__IOS_UNAVAILABLE __TVOS_UNAVAILABLE
__WATCHOS_UNAVAILABLE __BRIDGEOS_UNAVAILABLE;
OBJC_EXPORT id _Nonnull
objc_exception_extract(void * _Nonnull localExceptionData)
__OSX_AVAILABLE(10.3)
__IOS_UNAVAILABLE __TVOS_UNAVAILABLE
__WATCHOS_UNAVAILABLE __BRIDGEOS_UNAVAILABLE;
OBJC_EXPORT int objc_exception_match(Class _Nonnull exceptionClass,
id _Nonnull exception)
__OSX_AVAILABLE(10.3)
__IOS_UNAVAILABLE __TVOS_UNAVAILABLE
__WATCHOS_UNAVAILABLE __BRIDGEOS_UNAVAILABLE;
typedef struct {
int version;
void (* _Nonnull throw_exc)(id _Nonnull); // version 0
void (* _Nonnull try_enter)(void * _Nonnull); // version 0
void (* _Nonnull try_exit)(void * _Nonnull); // version 0
id _Nonnull (* _Nonnull extract)(void * _Nonnull); // version 0
int (* _Nonnull match)(Class _Nonnull, id _Nonnull); // version 0
} objc_exception_functions_t;
// get table; version tells how many
OBJC_EXPORT void
objc_exception_get_functions(objc_exception_functions_t * _Nullable table)
__OSX_AVAILABLE(10.3)
__IOS_UNAVAILABLE __TVOS_UNAVAILABLE
__WATCHOS_UNAVAILABLE __BRIDGEOS_UNAVAILABLE;
// set table
OBJC_EXPORT void
objc_exception_set_functions(objc_exception_functions_t * _Nullable table)
__OSX_AVAILABLE(10.3)
__IOS_UNAVAILABLE __TVOS_UNAVAILABLE
__WATCHOS_UNAVAILABLE __BRIDGEOS_UNAVAILABLE;
// !__OBJC2__
#else
// __OBJC2__
typedef id _Nonnull (*objc_exception_preprocessor)(id _Nonnull exception);
typedef int (*objc_exception_matcher)(Class _Nonnull catch_type,
id _Nonnull exception);
typedef void (*objc_uncaught_exception_handler)(id _Null_unspecified /* _Nonnull */ exception);
typedef void (*objc_exception_handler)(id _Nullable unused,
void * _Nullable context);
/**
* Throw a runtime exception. This function is inserted by the compiler
* where \c @throw would otherwise be.
*
* @param exception The exception to be thrown.
*/
OBJC_EXPORT void
objc_exception_throw(id _Nonnull exception)
OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
OBJC_EXPORT void
objc_exception_rethrow(void)
OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
OBJC_EXPORT id _Nonnull
objc_begin_catch(void * _Nonnull exc_buf)
OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
OBJC_EXPORT void
objc_end_catch(void)
OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
OBJC_EXPORT void
objc_terminate(void)
OBJC_AVAILABLE(10.8, 6.0, 9.0, 1.0, 2.0);
OBJC_EXPORT objc_exception_preprocessor _Nonnull
objc_setExceptionPreprocessor(objc_exception_preprocessor _Nonnull fn)
OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
OBJC_EXPORT objc_exception_matcher _Nonnull
objc_setExceptionMatcher(objc_exception_matcher _Nonnull fn)
OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
OBJC_EXPORT objc_uncaught_exception_handler _Nonnull
objc_setUncaughtExceptionHandler(objc_uncaught_exception_handler _Nonnull fn)
OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
// Not for iOS.
OBJC_EXPORT uintptr_t
objc_addExceptionHandler(objc_exception_handler _Nonnull fn,
void * _Nullable context)
__OSX_AVAILABLE(10.5)
__IOS_UNAVAILABLE __TVOS_UNAVAILABLE
__WATCHOS_UNAVAILABLE __BRIDGEOS_UNAVAILABLE;
OBJC_EXPORT void
objc_removeExceptionHandler(uintptr_t token)
__OSX_AVAILABLE(10.5)
__IOS_UNAVAILABLE __TVOS_UNAVAILABLE
__WATCHOS_UNAVAILABLE __BRIDGEOS_UNAVAILABLE;
// __OBJC2__
#endif
#endif // __OBJC_EXCEPTION_H_