|
1 | 1 | /* CFAvailability.h |
2 | | - Copyright (c) 2013-2017, Apple Inc. and the Swift project authors |
| 2 | + Copyright (c) 2013-2016, Apple Inc. and the Swift project authors |
3 | 3 | |
4 | | - Portions Copyright (c) 2014-2017, Apple Inc. and the Swift project authors |
| 4 | + Portions Copyright (c) 2014-2016 Apple Inc. and the Swift project authors |
5 | 5 | Licensed under Apache License v2.0 with Runtime Library Exception |
6 | 6 | See http://swift.org/LICENSE.txt for license information |
7 | 7 | See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
|
10 | 10 | #if !defined(__COREFOUNDATION_CFAVAILABILITY__) |
11 | 11 | #define __COREFOUNDATION_CFAVAILABILITY__ 1 |
12 | 12 |
|
13 | | -#if __has_include(<CoreFoundation/TargetConditionals.h>) |
| 13 | +#if DEPLOYMENT_RUNTIME_SWIFT |
14 | 14 | #include <CoreFoundation/TargetConditionals.h> |
15 | | -#elif __has_include(<TargetConditionals.h>) |
16 | | -#include <TargetConditionals.h> |
17 | 15 | #else |
18 | | -#error Missing header TargetConditionals.h |
| 16 | +#include <TargetConditionals.h> |
19 | 17 | #endif |
20 | 18 |
|
21 | | -#if __has_include(<Availability.h>) && __has_include(<os/Availability.h>) && __has_include(<AvailabilityMacros.h>) |
| 19 | +#if DEPLOYMENT_RUNTIME_SWIFT |
| 20 | +#define API_AVAILABLE(...) |
| 21 | +#define API_DEPRECATED(...) |
| 22 | +#else |
| 23 | +#if (TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_WIN32) |
22 | 24 | #include <Availability.h> |
23 | 25 | #include <os/availability.h> |
| 26 | + |
24 | 27 | // Even if unused, these must remain here for compatibility, because projects rely on them being included. |
25 | 28 | #include <AvailabilityMacros.h> |
26 | | -#else |
27 | | -#define API_AVAILABLE(...) |
28 | | -#define API_DEPRECATED(...) |
29 | | -#define API_UNAVAILABLE(...) |
| 29 | +#endif |
30 | 30 | #endif |
31 | 31 |
|
32 | 32 | #ifndef __has_feature |
|
112 | 112 | #endif |
113 | 113 |
|
114 | 114 | // Enums and Options |
115 | | -#if __has_attribute(enum_extensibility) |
116 | | -#define __CF_ENUM_ATTRIBUTES __attribute__((enum_extensibility(open))) |
117 | | -#define __CF_OPTIONS_ATTRIBUTES __attribute__((flag_enum,enum_extensibility(open))) |
118 | | -#else |
119 | | -#define __CF_ENUM_ATTRIBUTES |
120 | | -#define __CF_OPTIONS_ATTRIBUTES |
121 | | -#endif |
122 | | - |
123 | 115 | #define __CF_ENUM_GET_MACRO(_1, _2, NAME, ...) NAME |
124 | 116 | #if (__cplusplus && __cplusplus >= 201103L && (__has_extension(cxx_strong_enums) || __has_feature(objc_fixed_enum))) || (!__cplusplus && __has_feature(objc_fixed_enum)) |
125 | | -#define __CF_NAMED_ENUM(_type, _name) enum __CF_ENUM_ATTRIBUTES _name : _type _name; enum _name : _type |
126 | | -#define __CF_ANON_ENUM(_type) enum __CF_ENUM_ATTRIBUTES : _type |
| 117 | +#define __CF_NAMED_ENUM(_type, _name) enum _name : _type _name; enum _name : _type |
| 118 | +#define __CF_ANON_ENUM(_type) enum : _type |
127 | 119 | #if (__cplusplus) |
128 | | -#define CF_OPTIONS(_type, _name) _type _name; enum __CF_OPTIONS_ATTRIBUTES : _type |
| 120 | +#define CF_OPTIONS(_type, _name) _type _name; enum : _type |
129 | 121 | #else |
130 | | -#define CF_OPTIONS(_type, _name) enum __CF_OPTIONS_ATTRIBUTES _name : _type _name; enum _name : _type |
| 122 | +#define CF_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type |
131 | 123 | #endif |
132 | 124 | #else |
133 | 125 | #define __CF_NAMED_ENUM(_type, _name) _type _name; enum |
@@ -164,40 +156,11 @@ CF_ENUM(CFIndex) { |
164 | 156 | #if DEPLOYMENT_RUNTIME_SWIFT |
165 | 157 | #define CF_STRING_ENUM |
166 | 158 | #define CF_EXTENSIBLE_STRING_ENUM |
167 | | - |
168 | | -#define CF_TYPED_ENUM |
169 | | -#define CF_TYPED_EXTENSIBLE_ENUM |
170 | 159 | #else |
171 | 160 | #define CF_STRING_ENUM _CF_TYPED_ENUM |
172 | 161 | #define CF_EXTENSIBLE_STRING_ENUM _CF_TYPED_EXTENSIBLE_ENUM |
173 | | - |
174 | | -#define CF_TYPED_ENUM _CF_TYPED_ENUM |
175 | | -#define CF_TYPED_EXTENSIBLE_ENUM _CF_TYPED_EXTENSIBLE_ENUM |
176 | | -#endif |
177 | | - |
178 | | -#define __CF_ERROR_ENUM_GET_MACRO(_1, _2, NAME, ...) NAME |
179 | | -#if ((__cplusplus && __cplusplus >= 201103L && (__has_extension(cxx_strong_enums) || __has_feature(objc_fixed_enum))) || (!__cplusplus && __has_feature(objc_fixed_enum))) && __has_attribute(ns_error_domain) |
180 | | -#define __CF_NAMED_ERROR_ENUM(_domain, _name) enum __attribute__((ns_error_domain(_domain))) _name : CFIndex _name; enum _name : CFIndex |
181 | | -#define __CF_ANON_ERROR_ENUM(_domain) enum __attribute__((ns_error_domain(_domain))) : CFIndex |
182 | | -#else |
183 | | -#define __CF_NAMED_ERROR_ENUM(_domain, _name) __CF_NAMED_ENUM(CFIndex, _name) |
184 | | -#define __CF_ANON_ERROR_ENUM(_domain) __CF_ANON_ENUM(CFIndex) |
185 | 162 | #endif |
186 | 163 |
|
187 | | -/* CF_ERROR_ENUM supports the use of one or two arguments. The first argument is always the domain specifier for the enum. The second argument is an optional name of the typedef for the macro. When specifying a name for of the typedef, you must precede the macro with 'typedef' like so: |
188 | | - |
189 | | - typedef CF_ERROR_ENUM(kCFSomeErrorDomain, SomeErrorCodes) { |
190 | | - ... |
191 | | - }; |
192 | | - |
193 | | - If you do not specify a typedef name, do not use 'typedef', like so: |
194 | | - |
195 | | - CF_ERROR_ENUM(kCFSomeErrorDomain) { |
196 | | - ... |
197 | | - }; |
198 | | - */ |
199 | | -#define CF_ERROR_ENUM(...) __CF_ERROR_ENUM_GET_MACRO(__VA_ARGS__, __CF_NAMED_ERROR_ENUM, __CF_ANON_ERROR_ENUM)(__VA_ARGS__) |
200 | | - |
201 | 164 | // Extension availability macros |
202 | 165 | #define CF_EXTENSION_UNAVAILABLE(_msg) __OS_EXTENSION_UNAVAILABLE(_msg) |
203 | 166 | #define CF_EXTENSION_UNAVAILABLE_MAC(_msg) __OSX_EXTENSION_UNAVAILABLE(_msg) |
|
0 commit comments