]>
git.saurik.com Git - apple/objc4.git/blob - runtime/objc-api.h
284f24f2b2d80de7262b145d0df036babb01abb2
2 * Copyright (c) 1999-2006 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@
23 // Copyright 1988-1996 NeXT Software, Inc.
25 #ifndef _OBJC_OBJC_API_H_
26 #define _OBJC_OBJC_API_H_
28 #include <Availability.h>
29 #include <AvailabilityMacros.h>
30 #include <TargetConditionals.h>
31 #include <sys/types.h>
34 # define __has_feature(x) 0
37 #ifndef __has_extension
38 # define __has_extension __has_feature
41 #ifndef __has_attribute
42 # define __has_attribute(x) 0
45 #if !__has_feature(nullability)
52 # ifndef _Null_unspecified
53 # define _Null_unspecified
57 #ifndef __APPLE_BLEACH_SDK__
58 # if __has_feature(attribute_availability_bridgeos)
59 # ifndef __BRIDGEOS_AVAILABLE
60 # define __BRIDGEOS_AVAILABLE(_vers) __OS_AVAILABILITY(bridgeos,introduced=_vers)
62 # ifndef __BRIDGEOS_DEPRECATED
63 # define __BRIDGEOS_DEPRECATED(_start, _dep, _msg) __BRIDGEOS_AVAILABLE(_start) __OS_AVAILABILITY_MSG(bridgeos,deprecated=_dep,_msg)
65 # ifndef __BRIDGEOS_UNAVAILABLE
66 # define __BRIDGEOS_UNAVAILABLE __OS_AVAILABILITY(bridgeos,unavailable)
69 # ifndef __BRIDGEOS_AVAILABLE
70 # define __BRIDGEOS_AVAILABLE(_vers)
72 # ifndef __BRIDGEOS_DEPRECATED
73 # define __BRIDGEOS_DEPRECATED(_start, _dep, _msg)
75 # ifndef __BRIDGEOS_UNAVAILABLE
76 # define __BRIDGEOS_UNAVAILABLE
82 * OBJC_API_VERSION 0 or undef: Tiger and earlier API only
83 * OBJC_API_VERSION 2: Leopard and later API available
85 #if !defined(OBJC_API_VERSION)
86 # if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_5
87 # define OBJC_API_VERSION 0
89 # define OBJC_API_VERSION 2
95 * OBJC_NO_GC 1: GC is not supported
96 * OBJC_NO_GC undef: GC is supported. This SDK no longer supports this mode.
98 * OBJC_NO_GC_API undef: Libraries must export any symbols that
99 * dual-mode code may links to.
100 * OBJC_NO_GC_API 1: Libraries need not export GC-related symbols.
102 #if defined(__OBJC_GC__)
103 # error Objective-C garbage collection is not supported.
105 /* GC is unsupported. GC API symbols are exported. */
106 # define OBJC_NO_GC 1
107 # undef OBJC_NO_GC_API
109 /* GC is unsupported. GC API symbols are not exported. */
110 # define OBJC_NO_GC 1
111 # define OBJC_NO_GC_API 1
115 /* NS_ENFORCE_NSOBJECT_DESIGNATED_INITIALIZER == 1
116 * marks -[NSObject init] as a designated initializer. */
117 #if !defined(NS_ENFORCE_NSOBJECT_DESIGNATED_INITIALIZER)
118 # define NS_ENFORCE_NSOBJECT_DESIGNATED_INITIALIZER 1
122 /* OBJC_OLD_DISPATCH_PROTOTYPES == 0 enforces the rule that the dispatch
123 * functions must be cast to an appropriate function pointer type. */
124 #if !defined(OBJC_OLD_DISPATCH_PROTOTYPES)
126 // Existing Swift code expects IMP to be Comparable.
127 // Variadic IMP is comparable via OpaquePointer; non-variadic IMP isn't.
128 # define OBJC_OLD_DISPATCH_PROTOTYPES 1
130 # define OBJC_OLD_DISPATCH_PROTOTYPES 0
135 /* OBJC_AVAILABLE: shorthand for all-OS availability */
136 #ifndef __APPLE_BLEACH_SDK__
137 # if !defined(OBJC_AVAILABLE)
138 # define OBJC_AVAILABLE(x, i, t, w, b) \
139 __OSX_AVAILABLE(x) __IOS_AVAILABLE(i) __TVOS_AVAILABLE(t) \
140 __WATCHOS_AVAILABLE(w) __BRIDGEOS_AVAILABLE(b)
143 # if !defined(OBJC_AVAILABLE)
144 # define OBJC_AVAILABLE(x, i, t, w, b) \
145 __OSX_AVAILABLE(x) __IOS_AVAILABLE(i) __TVOS_AVAILABLE(t) \
146 __WATCHOS_AVAILABLE(w)
151 /* OBJC_OSX_DEPRECATED_OTHERS_UNAVAILABLE: Deprecated on OS X,
152 * unavailable everywhere else. */
153 #ifndef __APPLE_BLEACH_SDK__
154 # if !defined(OBJC_OSX_DEPRECATED_OTHERS_UNAVAILABLE)
155 # define OBJC_OSX_DEPRECATED_OTHERS_UNAVAILABLE(_start, _dep, _msg) \
156 __OSX_DEPRECATED(_start, _dep, _msg) \
157 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE \
158 __WATCHOS_UNAVAILABLE __BRIDGEOS_UNAVAILABLE
161 # if !defined(OBJC_OSX_DEPRECATED_OTHERS_UNAVAILABLE)
162 # define OBJC_OSX_DEPRECATED_OTHERS_UNAVAILABLE(_start, _dep, _msg) \
163 __OSX_DEPRECATED(_start, _dep, _msg) \
164 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE \
165 __WATCHOS_UNAVAILABLE
170 /* OBJC_OSX_AVAILABLE_OTHERS_UNAVAILABLE: Available on OS X,
171 * unavailable everywhere else. */
172 #ifndef __APPLE_BLEACH_SDK__
173 # if !defined(OBJC_OSX_AVAILABLE_OTHERS_UNAVAILABLE)
174 # define OBJC_OSX_AVAILABLE_OTHERS_UNAVAILABLE(vers) \
175 __OSX_AVAILABLE(vers) \
176 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE \
177 __WATCHOS_UNAVAILABLE __BRIDGEOS_UNAVAILABLE
180 # if !defined(OBJC_OSX_AVAILABLE_OTHERS_UNAVAILABLE)
181 # define OBJC_OSX_AVAILABLE_OTHERS_UNAVAILABLE(vers) \
182 __OSX_AVAILABLE(vers) \
183 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE \
184 __WATCHOS_UNAVAILABLE
189 /* OBJC_ISA_AVAILABILITY: `isa` will be deprecated or unavailable
191 #if !defined(OBJC_ISA_AVAILABILITY)
193 # define OBJC_ISA_AVAILABILITY __attribute__((deprecated))
195 # define OBJC_ISA_AVAILABILITY /* still available */
200 /* OBJC2_UNAVAILABLE: unavailable in objc 2.0, deprecated in Leopard */
201 #if !defined(OBJC2_UNAVAILABLE)
203 # define OBJC2_UNAVAILABLE UNAVAILABLE_ATTRIBUTE
205 /* plain C code also falls here, but this is close enough */
206 # define OBJC2_UNAVAILABLE \
207 __OSX_DEPRECATED(10.5, 10.5, "not available in __OBJC2__") \
208 __IOS_DEPRECATED(2.0, 2.0, "not available in __OBJC2__") \
209 __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE __BRIDGEOS_UNAVAILABLE
213 /* OBJC_UNAVAILABLE: unavailable, with a message where supported */
214 #if !defined(OBJC_UNAVAILABLE)
215 # if __has_extension(attribute_unavailable_with_message)
216 # define OBJC_UNAVAILABLE(_msg) __attribute__((unavailable(_msg)))
218 # define OBJC_UNAVAILABLE(_msg) __attribute__((unavailable))
222 /* OBJC_DEPRECATED: deprecated, with a message where supported */
223 #if !defined(OBJC_DEPRECATED)
224 # if __has_extension(attribute_deprecated_with_message)
225 # define OBJC_DEPRECATED(_msg) __attribute__((deprecated(_msg)))
227 # define OBJC_DEPRECATED(_msg) __attribute__((deprecated))
231 /* OBJC_ARC_UNAVAILABLE: unavailable with -fobjc-arc */
232 #if !defined(OBJC_ARC_UNAVAILABLE)
233 # if __has_feature(objc_arc)
234 # define OBJC_ARC_UNAVAILABLE OBJC_UNAVAILABLE("not available in automatic reference counting mode")
236 # define OBJC_ARC_UNAVAILABLE
240 /* OBJC_SWIFT_UNAVAILABLE: unavailable in Swift */
241 #if !defined(OBJC_SWIFT_UNAVAILABLE)
242 # if __has_feature(attribute_availability_swift)
243 # define OBJC_SWIFT_UNAVAILABLE(_msg) __attribute__((availability(swift, unavailable, message=_msg)))
245 # define OBJC_SWIFT_UNAVAILABLE(_msg)
249 /* OBJC_ARM64_UNAVAILABLE: unavailable on arm64 (i.e. stret dispatch) */
250 #if !defined(OBJC_ARM64_UNAVAILABLE)
251 # if defined(__arm64__)
252 # define OBJC_ARM64_UNAVAILABLE OBJC_UNAVAILABLE("not available in arm64")
254 # define OBJC_ARM64_UNAVAILABLE
258 /* OBJC_GC_UNAVAILABLE: unavailable with -fobjc-gc or -fobjc-gc-only */
259 #if !defined(OBJC_GC_UNAVAILABLE)
260 # define OBJC_GC_UNAVAILABLE
263 #if !defined(OBJC_EXTERN)
264 # if defined(__cplusplus)
265 # define OBJC_EXTERN extern "C"
267 # define OBJC_EXTERN extern
271 #if !defined(OBJC_VISIBLE)
273 # if defined(BUILDING_OBJC)
274 # define OBJC_VISIBLE __declspec(dllexport)
276 # define OBJC_VISIBLE __declspec(dllimport)
279 # define OBJC_VISIBLE __attribute__((visibility("default")))
283 #if !defined(OBJC_EXPORT)
284 # define OBJC_EXPORT OBJC_EXTERN OBJC_VISIBLE
287 #if !defined(OBJC_IMPORT)
288 # define OBJC_IMPORT extern
291 #if !defined(OBJC_ROOT_CLASS)
292 # if __has_attribute(objc_root_class)
293 # define OBJC_ROOT_CLASS __attribute__((objc_root_class))
295 # define OBJC_ROOT_CLASS
299 #ifndef __DARWIN_NULL
300 #define __DARWIN_NULL NULL
303 #if !defined(OBJC_INLINE)
304 # define OBJC_INLINE __inline
307 // Declares an enum type or option bits type as appropriate for each language.
308 #if (__cplusplus && __cplusplus >= 201103L && (__has_extension(cxx_strong_enums) || __has_feature(objc_fixed_enum))) || (!__cplusplus && __has_feature(objc_fixed_enum))
309 #define OBJC_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
311 #define OBJC_OPTIONS(_type, _name) _type _name; enum : _type
313 #define OBJC_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
316 #define OBJC_ENUM(_type, _name) _type _name; enum
317 #define OBJC_OPTIONS(_type, _name) _type _name; enum
320 #if !defined(OBJC_RETURNS_RETAINED)
321 # if __OBJC__ && __has_attribute(ns_returns_retained)
322 # define OBJC_RETURNS_RETAINED __attribute__((ns_returns_retained))
324 # define OBJC_RETURNS_RETAINED