-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobjc-api.h
282 lines (246 loc) · 8.51 KB
/
objc-api.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
/*
* Copyright (c) 1999-2006 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@
*/
// Copyright 1988-1996 NeXT Software, Inc.
#ifndef _OBJC_OBJC_API_H_
#define _OBJC_OBJC_API_H_
#include <Availability.h>
#include <AvailabilityMacros.h>
#include <TargetConditionals.h>
#include <sys/types.h>
#ifndef __has_feature
# define __has_feature(x) 0
#endif
#ifndef __has_extension
# define __has_extension __has_feature
#endif
#ifndef __has_attribute
# define __has_attribute(x) 0
#endif
#if !__has_feature(nullability)
# ifndef _Nullable
# define _Nullable
# endif
# ifndef _Nonnull
# define _Nonnull
# endif
# ifndef _Null_unspecified
# define _Null_unspecified
# endif
#endif
#ifndef __APPLE_BLEACH_SDK__
# if __has_feature(attribute_availability_bridgeos)
# ifndef __BRIDGEOS_AVAILABLE
# define __BRIDGEOS_AVAILABLE(_vers) __OS_AVAILABILITY(bridgeos,introduced=_vers)
# endif
# ifndef __BRIDGEOS_DEPRECATED
# define __BRIDGEOS_DEPRECATED(_start, _dep, _msg) __BRIDGEOS_AVAILABLE(_start) __OS_AVAILABILITY_MSG(bridgeos,deprecated=_dep,_msg)
# endif
# ifndef __BRIDGEOS_UNAVAILABLE
# define __BRIDGEOS_UNAVAILABLE __OS_AVAILABILITY(bridgeos,unavailable)
# endif
# else
# ifndef __BRIDGEOS_AVAILABLE
# define __BRIDGEOS_AVAILABLE(_vers)
# endif
# ifndef __BRIDGEOS_DEPRECATED
# define __BRIDGEOS_DEPRECATED(_start, _dep, _msg)
# endif
# ifndef __BRIDGEOS_UNAVAILABLE
# define __BRIDGEOS_UNAVAILABLE
# endif
# endif
#endif
/*
* OBJC_API_VERSION 0 or undef: Tiger and earlier API only
* OBJC_API_VERSION 2: Leopard and later API available
*/
#if !defined(OBJC_API_VERSION)
# if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_5
# define OBJC_API_VERSION 0
# else
# define OBJC_API_VERSION 2
# endif
#endif
/*
* OBJC_NO_GC 1: GC is not supported
* OBJC_NO_GC undef: GC is supported. This SDK no longer supports this mode.
*
* OBJC_NO_GC_API undef: Libraries must export any symbols that
* dual-mode code may links to.
* OBJC_NO_GC_API 1: Libraries need not export GC-related symbols.
*/
#if defined(__OBJC_GC__)
# error Objective-C garbage collection is not supported.
#elif TARGET_OS_OSX
/* GC is unsupported. GC API symbols are exported. */
# define OBJC_NO_GC 1
# undef OBJC_NO_GC_API
#else
/* GC is unsupported. GC API symbols are not exported. */
# define OBJC_NO_GC 1
# define OBJC_NO_GC_API 1
#endif
/* NS_ENFORCE_NSOBJECT_DESIGNATED_INITIALIZER == 1
* marks -[NSObject init] as a designated initializer. */
#if !defined(NS_ENFORCE_NSOBJECT_DESIGNATED_INITIALIZER)
# define NS_ENFORCE_NSOBJECT_DESIGNATED_INITIALIZER 1
#endif
/* OBJC_OLD_DISPATCH_PROTOTYPES == 0 enforces the rule that the dispatch
* functions must be cast to an appropriate function pointer type. */
#if !defined(OBJC_OLD_DISPATCH_PROTOTYPES)
# if __swift__
// Existing Swift code expects IMP to be Comparable.
// Variadic IMP is comparable via OpaquePointer; non-variadic IMP isn't.
# define OBJC_OLD_DISPATCH_PROTOTYPES 1
# else
# define OBJC_OLD_DISPATCH_PROTOTYPES 1
# endif
#endif
/* OBJC_AVAILABLE: shorthand for all-OS availability */
#if !defined(OBJC_AVAILABLE)
# define OBJC_AVAILABLE(x, i, t, w, b) \
__OSX_AVAILABLE(x) __IOS_AVAILABLE(i) __TVOS_AVAILABLE(t) \
__WATCHOS_AVAILABLE(w) __BRIDGEOS_AVAILABLE(b)
#endif
/* OBJC_ISA_AVAILABILITY: `isa` will be deprecated or unavailable
* in the future */
#if !defined(OBJC_ISA_AVAILABILITY)
# if __OBJC2__
# define OBJC_ISA_AVAILABILITY __attribute__((deprecated))
# else
# define OBJC_ISA_AVAILABILITY /* still available */
# endif
#endif
/* OBJC2_UNAVAILABLE: unavailable in objc 2.0, deprecated in Leopard */
#if !defined(OBJC2_UNAVAILABLE)
# if __OBJC2__
# define OBJC2_UNAVAILABLE UNAVAILABLE_ATTRIBUTE
# else
/* plain C code also falls here, but this is close enough */
# define OBJC2_UNAVAILABLE \
__OSX_DEPRECATED(10.5, 10.5, "not available in __OBJC2__") \
__IOS_DEPRECATED(2.0, 2.0, "not available in __OBJC2__") \
__TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE __BRIDGEOS_UNAVAILABLE
# endif
#endif
/* OBJC_UNAVAILABLE: unavailable, with a message where supported */
#if !defined(OBJC_UNAVAILABLE)
# if __has_extension(attribute_unavailable_with_message)
# define OBJC_UNAVAILABLE(_msg) __attribute__((unavailable(_msg)))
# else
# define OBJC_UNAVAILABLE(_msg) __attribute__((unavailable))
# endif
#endif
/* OBJC_DEPRECATED: deprecated, with a message where supported */
#if !defined(OBJC_DEPRECATED)
# if __has_extension(attribute_deprecated_with_message)
# define OBJC_DEPRECATED(_msg) __attribute__((deprecated(_msg)))
# else
# define OBJC_DEPRECATED(_msg) __attribute__((deprecated))
# endif
#endif
/* OBJC_ARC_UNAVAILABLE: unavailable with -fobjc-arc */
#if !defined(OBJC_ARC_UNAVAILABLE)
# if __has_feature(objc_arc)
# define OBJC_ARC_UNAVAILABLE OBJC_UNAVAILABLE("not available in automatic reference counting mode")
# else
# define OBJC_ARC_UNAVAILABLE
# endif
#endif
/* OBJC_SWIFT_UNAVAILABLE: unavailable in Swift */
#if !defined(OBJC_SWIFT_UNAVAILABLE)
# if __has_feature(attribute_availability_swift)
# define OBJC_SWIFT_UNAVAILABLE(_msg) __attribute__((availability(swift, unavailable, message=_msg)))
# else
# define OBJC_SWIFT_UNAVAILABLE(_msg)
# endif
#endif
/* OBJC_ARM64_UNAVAILABLE: unavailable on arm64 (i.e. stret dispatch) */
#if !defined(OBJC_ARM64_UNAVAILABLE)
# if defined(__arm64__)
# define OBJC_ARM64_UNAVAILABLE OBJC_UNAVAILABLE("not available in arm64")
# else
# define OBJC_ARM64_UNAVAILABLE
# endif
#endif
/* OBJC_GC_UNAVAILABLE: unavailable with -fobjc-gc or -fobjc-gc-only */
#if !defined(OBJC_GC_UNAVAILABLE)
# define OBJC_GC_UNAVAILABLE
#endif
#if !defined(OBJC_EXTERN)
# if defined(__cplusplus)
# define OBJC_EXTERN extern "C"
# else
# define OBJC_EXTERN extern
# endif
#endif
#if !defined(OBJC_VISIBLE)
# if TARGET_OS_WIN32
# if defined(BUILDING_OBJC)
# define OBJC_VISIBLE __declspec(dllexport)
# else
# define OBJC_VISIBLE __declspec(dllimport)
# endif
# else
# define OBJC_VISIBLE __attribute__((visibility("default")))
# endif
#endif
#if !defined(OBJC_EXPORT)
# define OBJC_EXPORT OBJC_EXTERN OBJC_VISIBLE
#endif
#if !defined(OBJC_IMPORT)
# define OBJC_IMPORT extern
#endif
#if !defined(OBJC_ROOT_CLASS)
# if __has_attribute(objc_root_class)
# define OBJC_ROOT_CLASS __attribute__((objc_root_class))
# else
# define OBJC_ROOT_CLASS
# endif
#endif
#ifndef __DARWIN_NULL
#define __DARWIN_NULL NULL
#endif
#if !defined(OBJC_INLINE)
# define OBJC_INLINE __inline
#endif
// Declares an enum type or option bits type as appropriate for each language.
#if (__cplusplus && __cplusplus >= 201103L && (__has_extension(cxx_strong_enums) || __has_feature(objc_fixed_enum))) || (!__cplusplus && __has_feature(objc_fixed_enum))
#define OBJC_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
#if (__cplusplus)
#define OBJC_OPTIONS(_type, _name) _type _name; enum : _type
#else
#define OBJC_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
#endif
#else
#define OBJC_ENUM(_type, _name) _type _name; enum
#define OBJC_OPTIONS(_type, _name) _type _name; enum
#endif
#if !defined(OBJC_RETURNS_RETAINED)
# if __OBJC__ && __has_attribute(ns_returns_retained)
# define OBJC_RETURNS_RETAINED __attribute__((ns_returns_retained))
# else
# define OBJC_RETURNS_RETAINED
# endif
#endif
#endif