]> git.saurik.com Git - apple/cf.git/blob - CFAvailability.h
CF-1152.14.tar.gz
[apple/cf.git] / CFAvailability.h
1 /*
2 * Copyright (c) 2015 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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
11 * file.
12 *
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.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 /* CFAvailability.h
25 Copyright (c) 2013-2014, Apple Inc. All rights reserved.
26 */
27
28 #if !defined(__COREFOUNDATION_CFAVAILABILITY__)
29 #define __COREFOUNDATION_CFAVAILABILITY__ 1
30
31 #include <TargetConditionals.h>
32 #include <Availability.h>
33
34 #if (TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_WIN32)
35 // Even if unused, these must remain here for compatibility, because projects rely on them being included.
36 #include <AvailabilityMacros.h>
37 #endif
38
39 #ifndef __has_feature
40 #define __has_feature(x) 0
41 #endif
42 #ifndef __has_attribute
43 #define __has_attribute(x) 0
44 #endif
45 #ifndef __has_extension
46 #define __has_extension(x) 0
47 #endif
48
49 // The arguments to these availability macros is a version number, e.g. 10_6, 3_0 or 'NA'
50 // To use a deprecation message with the macro, add a string as the last argument.
51 #if __has_feature(attribute_availability_with_message)
52
53 #define __NSi_2_0 introduced=2.0
54 #define __NSi_2_1 introduced=2.1
55 #define __NSi_2_2 introduced=2.2
56 #define __NSi_3_0 introduced=3.0
57 #define __NSi_3_1 introduced=3.1
58 #define __NSi_3_2 introduced=3.2
59 #define __NSi_4_0 introduced=4.0
60 #define __NSi_4_1 introduced=4.1
61 #define __NSi_4_2 introduced=4.2
62 #define __NSi_4_3 introduced=4.3
63 #define __NSi_5_0 introduced=5.0
64 #define __NSi_5_1 introduced=5.1
65 #define __NSi_6_0 introduced=6.0
66 #define __NSi_6_1 introduced=6.1
67 #define __NSi_7_0 introduced=7.0
68 #define __NSi_7_1 introduced=7.1
69 #define __NSi_8_0 introduced=8.0
70 #define __NSi_8_1 introduced=8.1
71 #define __NSi_9_0 introduced=9.0
72 #define __NSi_9_1 introduced=9.1
73 #define __NSi_10_0 introduced=10.0
74 #define __NSi_10_1 introduced=10.1
75 #define __NSi_10_2 introduced=10.2
76 #define __NSi_10_3 introduced=10.3
77 #define __NSi_10_4 introduced=10.4
78 #define __NSi_10_5 introduced=10.5
79 #define __NSi_10_6 introduced=10.6
80 #define __NSi_10_7 introduced=10.7
81 #define __NSi_10_8 introduced=10.8
82 #define __NSi_10_9 introduced=10.9
83 #define __NSi_10_10 introduced=10.10
84 #define __NSi_10_10_2 introduced=10.10.2
85
86 #define __NSd_2_0 ,deprecated=2.0
87 #define __NSd_2_1 ,deprecated=2.1
88 #define __NSd_2_2 ,deprecated=2.2
89 #define __NSd_3_0 ,deprecated=3.0
90 #define __NSd_3_1 ,deprecated=3.1
91 #define __NSd_3_2 ,deprecated=3.2
92 #define __NSd_4_0 ,deprecated=4.0
93 #define __NSd_4_1 ,deprecated=4.1
94 #define __NSd_4_2 ,deprecated=4.2
95 #define __NSd_4_3 ,deprecated=4.3
96 #define __NSd_5_0 ,deprecated=5.0
97 #define __NSd_5_1 ,deprecated=5.1
98 #define __NSd_6_0 ,deprecated=6.0
99 #define __NSd_6_1 ,deprecated=6.1
100 #define __NSd_7_0 ,deprecated=7.0
101 #define __NSd_7_1 ,deprecated=7.1
102 #define __NSd_8_0 ,deprecated=8.0
103 #define __NSd_8_1 ,deprecated=8.1
104 #define __NSd_9_0 ,deprecated=9.0
105 #define __NSd_9_1 ,deprecated=9.1
106 #define __NSd_10_0 ,deprecated=10.0
107 #define __NSd_10_1 ,deprecated=10.1
108 #define __NSd_10_2 ,deprecated=10.2
109 #define __NSd_10_3 ,deprecated=10.3
110 #define __NSd_10_4 ,deprecated=10.4
111 #define __NSd_10_5 ,deprecated=10.5
112 #define __NSd_10_6 ,deprecated=10.6
113 #define __NSd_10_7 ,deprecated=10.7
114 #define __NSd_10_8 ,deprecated=10.8
115 #define __NSd_10_9 ,deprecated=10.9
116 #define __NSd_10_10 ,deprecated=10.10
117 #define __NSd_10_10_2 ,deprecated=10.10.2
118
119 #define __NSi_NA unavailable
120 #define __NSd_NA
121
122 // Do not use TBD as an argument to NS_AVAILABLE
123 #define __NSi_TBD introduced=9876.5
124
125 #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE))
126 // This section is for compilers targeting OS X which support attribute_availability_with_message
127
128 #define CF_AVAILABLE(_mac, _ios) __attribute__((availability(macosx,__NSi_##_mac)))
129 #define CF_AVAILABLE_MAC(_mac) __attribute__((availability(macosx,__NSi_##_mac)))
130 #define CF_AVAILABLE_IOS(_ios) __attribute__((availability(macosx,unavailable)))
131 #define CF_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) __attribute__((availability(macosx,__NSi_##_macIntro __NSd_##_macDep,message="" __VA_ARGS__)))
132 #define CF_DEPRECATED_MAC(_macIntro, _macDep, ...) __attribute__((availability(macosx,__NSi_##_macIntro __NSd_##_macDep,message="" __VA_ARGS__)))
133 #define CF_DEPRECATED_IOS(_iosIntro, _iosDep, ...) __attribute__((availability(macosx,unavailable)))
134
135 #elif (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)
136 // This section is for compilers targeting iOS which support attribute_availability_with_message
137
138 #define CF_AVAILABLE(_mac, _ios) __attribute__((availability(ios,__NSi_##_ios)))
139 #define CF_AVAILABLE_MAC(_mac) __attribute__((availability(ios,unavailable)))
140 #define CF_AVAILABLE_IOS(_ios) __attribute__((availability(ios,__NSi_##_ios)))
141 #define CF_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) __attribute__((availability(ios,__NSi_##_iosIntro __NSd_##_iosDep,message="" __VA_ARGS__)))
142 #define CF_DEPRECATED_MAC(_macIntro, _macDep, ...) __attribute__((availability(ios,unavailable)))
143 #define CF_DEPRECATED_IOS(_iosIntro, _iosDep, ...) __attribute__((availability(ios,__NSi_##_iosIntro __NSd_##_iosDep,message="" __VA_ARGS__)))
144
145 #endif
146
147 #elif (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)
148 // This section is for OS X or iOS, and compilers without support for attribute_availability_with_message. We fall back to Availability.h.
149
150 #ifndef __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_0
151 #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_0 __AVAILABILITY_INTERNAL_DEPRECATED
152 #endif
153
154 #define CF_AVAILABLE(_mac, _ios) __OSX_AVAILABLE_STARTING(__MAC_##_mac, __IPHONE_##_ios)
155 #define CF_AVAILABLE_MAC(_mac) __OSX_AVAILABLE_STARTING(__MAC_##_mac, __IPHONE_NA)
156 #define CF_AVAILABLE_IOS(_ios) __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_##_ios)
157 #define CF_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_##_macIntro, __MAC_##_macDep, __IPHONE_##_iosIntro, __IPHONE_##_iosDep)
158 #define CF_DEPRECATED_MAC(_macIntro, _macDep, ...) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_##_macIntro, __MAC_##_macDep, __IPHONE_NA, __IPHONE_NA)
159 #define CF_DEPRECATED_IOS(_iosIntro, _iosDep, ...) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_NA, __MAC_NA, __IPHONE_##_iosIntro, __IPHONE_##_iosDep)
160
161 #endif // __has_feature(attribute_availability_with_message)
162
163 #ifndef CF_AVAILABLE
164 // This section is for platforms which do not support availability
165 #define CF_AVAILABLE(_mac, _ios)
166 #define CF_AVAILABLE_MAC(_mac)
167 #define CF_AVAILABLE_IOS(_ios)
168 #define CF_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...)
169 #define CF_DEPRECATED_MAC(_macIntro, _macDep, ...)
170 #define CF_DEPRECATED_IOS(_iosIntro, _iosDep, ...)
171 #endif
172
173 // Older versions of these macros; use iOS versions instead
174 #define CF_AVAILABLE_IPHONE(_ios) CF_AVAILABLE_IOS(_ios)
175 #define CF_DEPRECATED_IPHONE(_iosIntro, _iosDep) CF_DEPRECATED_IOS(_iosIntro, _iosDep)
176
177 // Enum availability macros
178 #if __has_feature(enumerator_attributes) && __has_attribute(availability)
179 #define CF_ENUM_AVAILABLE(_mac, _ios) CF_AVAILABLE(_mac, _ios)
180 #define CF_ENUM_AVAILABLE_MAC(_mac) CF_AVAILABLE_MAC(_mac)
181 #define CF_ENUM_AVAILABLE_IOS(_ios) CF_AVAILABLE_IOS(_ios)
182 #define CF_ENUM_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) CF_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, __VA_ARGS__)
183 #define CF_ENUM_DEPRECATED_MAC(_macIntro, _macDep, ...) CF_DEPRECATED_MAC(_macIntro, _macDep, __VA_ARGS__)
184 #define CF_ENUM_DEPRECATED_IOS(_iosIntro, _iosDep, ...) CF_DEPRECATED_IOS(_iosIntro, _iosDep, __VA_ARGS__)
185 #else
186 #define CF_ENUM_AVAILABLE(_mac, _ios)
187 #define CF_ENUM_AVAILABLE_MAC(_mac)
188 #define CF_ENUM_AVAILABLE_IOS(_ios)
189 #define CF_ENUM_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...)
190 #define CF_ENUM_DEPRECATED_MAC(_macIntro, _macDep, ...)
191 #define CF_ENUM_DEPRECATED_IOS(_iosIntro, _iosDep, ...)
192 #endif
193
194 // Enums and Options
195 #if (__cplusplus && __cplusplus >= 201103L && (__has_extension(cxx_strong_enums) || __has_feature(objc_fixed_enum))) || (!__cplusplus && __has_feature(objc_fixed_enum))
196 #define CF_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
197 #if (__cplusplus)
198 #define CF_OPTIONS(_type, _name) _type _name; enum : _type
199 #else
200 #define CF_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
201 #endif
202 #else
203 #define CF_ENUM(_type, _name) _type _name; enum
204 #define CF_OPTIONS(_type, _name) _type _name; enum
205 #endif
206
207 // Extension availability macros
208 #define CF_EXTENSION_UNAVAILABLE(_msg) __OS_EXTENSION_UNAVAILABLE(_msg)
209 #define CF_EXTENSION_UNAVAILABLE_MAC(_msg) __OSX_EXTENSION_UNAVAILABLE(_msg)
210 #define CF_EXTENSION_UNAVAILABLE_IOS(_msg) __IOS_EXTENSION_UNAVAILABLE(_msg)
211
212 #endif // __COREFOUNDATION_CFAVAILABILITY__