1/* 2 * Copyright (c) 2014 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-2013, Apple Inc. All rights reserved. 26*/ 27 28#if !defined(__COREFOUNDATION_CFAVAILABILITY__) 29#define __COREFOUNDATION_CFAVAILABILITY__ 1 30 31#include <TargetConditionals.h> 32 33#if (TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_WIN32) 34// Even if unused, these must remain here for compatibility, because projects rely on them being included. 35#include <Availability.h> 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_8_0 introduced=8.0 69#define __NSi_9_0 introduced=9.0 70#define __NSi_10_0 introduced=10.0 71#define __NSi_10_1 introduced=10.1 72#define __NSi_10_2 introduced=10.2 73#define __NSi_10_3 introduced=10.3 74#define __NSi_10_4 introduced=10.4 75#define __NSi_10_5 introduced=10.5 76#define __NSi_10_6 introduced=10.6 77#define __NSi_10_7 introduced=10.7 78#define __NSi_10_8 introduced=10.8 79#define __NSi_10_9 introduced=10.9 80 81#define __NSd_2_0 ,deprecated=2.0 82#define __NSd_2_1 ,deprecated=2.1 83#define __NSd_2_2 ,deprecated=2.2 84#define __NSd_3_0 ,deprecated=3.0 85#define __NSd_3_1 ,deprecated=3.1 86#define __NSd_3_2 ,deprecated=3.2 87#define __NSd_4_0 ,deprecated=4.0 88#define __NSd_4_1 ,deprecated=4.1 89#define __NSd_4_2 ,deprecated=4.2 90#define __NSd_4_3 ,deprecated=4.3 91#define __NSd_5_0 ,deprecated=5.0 92#define __NSd_5_1 ,deprecated=5.1 93#define __NSd_6_0 ,deprecated=6.0 94#define __NSd_6_1 ,deprecated=6.1 95#define __NSd_7_0 ,deprecated=7.0 96#define __NSd_8_0 ,deprecated=8.0 97#define __NSd_9_0 ,deprecated=9.0 98#define __NSd_10_0 ,deprecated=10.0 99#define __NSd_10_1 ,deprecated=10.1 100#define __NSd_10_2 ,deprecated=10.2 101#define __NSd_10_3 ,deprecated=10.3 102#define __NSd_10_4 ,deprecated=10.4 103#define __NSd_10_5 ,deprecated=10.5 104#define __NSd_10_6 ,deprecated=10.6 105#define __NSd_10_7 ,deprecated=10.7 106#define __NSd_10_8 ,deprecated=10.8 107#define __NSd_10_9 ,deprecated=10.9 108 109#define __NSi_NA unavailable 110#define __NSd_NA 111 112// Do not use TBD as an argument to NS_AVAILABLE 113#define __NSi_TBD introduced=9876.5 114 115#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) 116// This section is for compilers targeting OS X which support attribute_availability_with_message 117 118#define CF_AVAILABLE(_mac, _ios) __attribute__((availability(macosx,__NSi_##_mac))) 119#define CF_AVAILABLE_MAC(_mac) __attribute__((availability(macosx,__NSi_##_mac))) 120#define CF_AVAILABLE_IOS(_ios) __attribute__((availability(macosx,unavailable))) 121#define CF_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) __attribute__((availability(macosx,__NSi_##_macIntro __NSd_##_macDep,message="" __VA_ARGS__))) 122#define CF_DEPRECATED_MAC(_macIntro, _macDep, ...) __attribute__((availability(macosx,__NSi_##_macIntro __NSd_##_macDep,message="" __VA_ARGS__))) 123#define CF_DEPRECATED_IOS(_iosIntro, _iosDep, ...) __attribute__((availability(macosx,unavailable))) 124 125#elif (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) 126// This section is for compilers targeting iOS which support attribute_availability_with_message 127 128#define CF_AVAILABLE(_mac, _ios) __attribute__((availability(ios,__NSi_##_ios))) 129#define CF_AVAILABLE_MAC(_mac) __attribute__((availability(ios,unavailable))) 130#define CF_AVAILABLE_IOS(_ios) __attribute__((availability(ios,__NSi_##_ios))) 131#define CF_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) __attribute__((availability(ios,__NSi_##_iosIntro __NSd_##_iosDep,message="" __VA_ARGS__))) 132#define CF_DEPRECATED_MAC(_macIntro, _macDep, ...) __attribute__((availability(ios,unavailable))) 133#define CF_DEPRECATED_IOS(_iosIntro, _iosDep, ...) __attribute__((availability(ios,__NSi_##_iosIntro __NSd_##_iosDep,message="" __VA_ARGS__))) 134 135#endif 136 137#elif (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) 138// This section is for OS X or iOS, and compilers without support for attribute_availability_with_message. We fall back to Availability.h. 139 140#ifndef __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_0 141#define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_0 __AVAILABILITY_INTERNAL_DEPRECATED 142#endif 143 144#define CF_AVAILABLE(_mac, _ios) __OSX_AVAILABLE_STARTING(__MAC_##_mac, __IPHONE_##_ios) 145#define CF_AVAILABLE_MAC(_mac) __OSX_AVAILABLE_STARTING(__MAC_##_mac, __IPHONE_NA) 146#define CF_AVAILABLE_IOS(_ios) __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_##_ios) 147#define CF_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_##_macIntro, __MAC_##_macDep, __IPHONE_##_iosIntro, __IPHONE_##_iosDep) 148#define CF_DEPRECATED_MAC(_macIntro, _macDep, ...) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_##_macIntro, __MAC_##_macDep, __IPHONE_NA, __IPHONE_NA) 149#define CF_DEPRECATED_IOS(_iosIntro, _iosDep, ...) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_NA, __MAC_NA, __IPHONE_##_iosIntro, __IPHONE_##_iosDep) 150 151#endif // __has_feature(attribute_availability_with_message) 152 153#ifndef CF_AVAILABLE 154// This section is for platforms which do not support availability 155#define CF_AVAILABLE(_mac, _ios) 156#define CF_AVAILABLE_MAC(_mac) 157#define CF_AVAILABLE_IOS(_ios) 158#define CF_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) 159#define CF_DEPRECATED_MAC(_macIntro, _macDep, ...) 160#define CF_DEPRECATED_IOS(_iosIntro, _iosDep, ...) 161#endif 162 163// Older versions of these macros; use iOS versions instead 164#define CF_AVAILABLE_IPHONE(_ios) CF_AVAILABLE_IOS(_ios) 165#define CF_DEPRECATED_IPHONE(_iosIntro, _iosDep) CF_DEPRECATED_IOS(_iosIntro, _iosDep) 166 167// Enum availability macros 168#if __has_feature(enumerator_attributes) && __has_attribute(availability) 169#define CF_ENUM_AVAILABLE(_mac, _ios) CF_AVAILABLE(_mac, _ios) 170#define CF_ENUM_AVAILABLE_MAC(_mac) CF_AVAILABLE_MAC(_mac) 171#define CF_ENUM_AVAILABLE_IOS(_ios) CF_AVAILABLE_IOS(_ios) 172#define CF_ENUM_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) CF_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, __VA_ARGS__) 173#define CF_ENUM_DEPRECATED_MAC(_macIntro, _macDep, ...) CF_DEPRECATED_MAC(_macIntro, _macDep, __VA_ARGS__) 174#define CF_ENUM_DEPRECATED_IOS(_iosIntro, _iosDep, ...) CF_DEPRECATED_IOS(_iosIntro, _iosDep, __VA_ARGS__) 175#else 176#define CF_ENUM_AVAILABLE(_mac, _ios) 177#define CF_ENUM_AVAILABLE_MAC(_mac) 178#define CF_ENUM_AVAILABLE_IOS(_ios) 179#define CF_ENUM_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) 180#define CF_ENUM_DEPRECATED_MAC(_macIntro, _macDep, ...) 181#define CF_ENUM_DEPRECATED_IOS(_iosIntro, _iosDep, ...) 182#endif 183 184// Enums and Options 185#if (__cplusplus && __cplusplus >= 201103L && (__has_extension(cxx_strong_enums) || __has_feature(objc_fixed_enum))) || (!__cplusplus && __has_feature(objc_fixed_enum)) 186#define CF_ENUM(_type, _name) enum _name : _type _name; enum _name : _type 187#if (__cplusplus) 188#define CF_OPTIONS(_type, _name) _type _name; enum : _type 189#else 190#define CF_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type 191#endif 192#else 193#define CF_ENUM(_type, _name) _type _name; enum 194#define CF_OPTIONS(_type, _name) _type _name; enum 195#endif 196 197#endif // __COREFOUNDATION_CFAVAILABILITY__ 198