123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398 |
- #include <AvailabilityMacros.h>
- #include <TargetConditionals.h>
- #ifdef __OBJC__
- #include <Foundation/NSObjCRuntime.h>
- #endif
- #if TARGET_OS_IPHONE
- #include <Availability.h>
- #endif
- #ifndef GTM_CONTAINERS_VALIDATION_FAILED_ASSERT
- #define GTM_CONTAINERS_VALIDATION_FAILED_ASSERT 0
- #endif
- #ifndef __has_feature
- #define __has_feature(x) 0
- #endif
- #ifndef __has_extension
- #define __has_extension __has_feature
- #endif
- #if !defined(GTM_INLINE)
- #if (defined (__GNUC__) && (__GNUC__ == 4)) || defined (__clang__)
- #define GTM_INLINE static __inline__ __attribute__((always_inline))
- #else
- #define GTM_INLINE static __inline__
- #endif
- #endif
- #if !defined (GTM_EXTERN)
- #if defined __cplusplus
- #define GTM_EXTERN extern "C"
- #define GTM_EXTERN_C_BEGIN extern "C" {
- #define GTM_EXTERN_C_END }
- #else
- #define GTM_EXTERN extern
- #define GTM_EXTERN_C_BEGIN
- #define GTM_EXTERN_C_END
- #endif
- #endif
- #if !defined (GTM_EXPORT)
- #define GTM_EXPORT __attribute__((visibility("default")))
- #endif
- #if !defined (GTM_UNUSED)
- #define GTM_UNUSED(x) ((void)(x))
- #endif
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wreserved-id-macro"
- #ifndef _GTMDevLog
- #ifdef DEBUG
- #define _GTMDevLog(...) NSLog(__VA_ARGS__)
- #else
- #define _GTMDevLog(...) do { } while (0)
- #endif
- #endif
- #ifndef _GTMDevAssert
- #if !defined(NS_BLOCK_ASSERTIONS)
- #define _GTMDevAssert(condition, ...) \
- do { \
- if (!(condition)) { \
- [[NSAssertionHandler currentHandler] \
- handleFailureInFunction:(NSString *) \
- [NSString stringWithUTF8String:__PRETTY_FUNCTION__] \
- file:(NSString *)[NSString stringWithUTF8String:__FILE__] \
- lineNumber:__LINE__ \
- description:__VA_ARGS__]
- } \
- } while(0)
- #else
- #define _GTMDevAssert(condition, ...) do { } while (0)
- #endif
- #endif
- #ifndef _GTMCompileAssert
- #if __has_feature(c_static_assert) || __has_extension(c_static_assert)
- #define _GTMCompileAssert(test, msg) _Static_assert((test), #msg)
- #else
-
-
-
-
- #define _GTMCompileAssertSymbolInner(line, msg) _GTMCOMPILEASSERT ## line ## __ ## msg
- #define _GTMCompileAssertSymbol(line, msg) _GTMCompileAssertSymbolInner(line, msg)
- #define _GTMCompileAssert(test, msg) \
- typedef char _GTMCompileAssertSymbol(__LINE__, msg) [ ((test) ? 1 : -1) ]
- #endif
- #endif
- #pragma clang diagnostic pop
- #if TARGET_OS_IPHONE
-
- #define GTM_IPHONE_SDK 1
- #if TARGET_IPHONE_SIMULATOR
- #define GTM_IPHONE_DEVICE 0
- #define GTM_IPHONE_SIMULATOR 1
- #else
- #define GTM_IPHONE_DEVICE 1
- #define GTM_IPHONE_SIMULATOR 0
- #endif
-
-
-
- #ifndef GTM_USING_XCTEST
- #define GTM_USING_XCTEST 0
- #endif
- #define GTM_MACOS_SDK 0
- #else
-
- #define GTM_MACOS_SDK 1
- #define GTM_IPHONE_SDK 0
- #define GTM_IPHONE_SIMULATOR 0
- #define GTM_IPHONE_DEVICE 0
- #ifndef GTM_USING_XCTEST
- #define GTM_USING_XCTEST 0
- #endif
- #endif
- #if GTM_MACOS_SDK
- #define GTM_AVAILABLE_ONLY_ON_IPHONE UNAVAILABLE_ATTRIBUTE
- #define GTM_AVAILABLE_ONLY_ON_MACOS
- #else
- #define GTM_AVAILABLE_ONLY_ON_IPHONE
- #define GTM_AVAILABLE_ONLY_ON_MACOS UNAVAILABLE_ATTRIBUTE
- #endif
- #ifndef GTM_SUPPORT_GC
- #define GTM_SUPPORT_GC 0
- #endif
- #ifndef NS_RETURNS_RETAINED
- #if __has_feature(attribute_ns_returns_retained)
- #define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
- #else
- #define NS_RETURNS_RETAINED
- #endif
- #endif
- #ifndef NS_RETURNS_NOT_RETAINED
- #if __has_feature(attribute_ns_returns_not_retained)
- #define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained))
- #else
- #define NS_RETURNS_NOT_RETAINED
- #endif
- #endif
- #ifndef CF_RETURNS_RETAINED
- #if __has_feature(attribute_cf_returns_retained)
- #define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
- #else
- #define CF_RETURNS_RETAINED
- #endif
- #endif
- #ifndef CF_RETURNS_NOT_RETAINED
- #if __has_feature(attribute_cf_returns_not_retained)
- #define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained))
- #else
- #define CF_RETURNS_NOT_RETAINED
- #endif
- #endif
- #ifndef NS_CONSUMED
- #if __has_feature(attribute_ns_consumed)
- #define NS_CONSUMED __attribute__((ns_consumed))
- #else
- #define NS_CONSUMED
- #endif
- #endif
- #ifndef CF_CONSUMED
- #if __has_feature(attribute_cf_consumed)
- #define CF_CONSUMED __attribute__((cf_consumed))
- #else
- #define CF_CONSUMED
- #endif
- #endif
- #ifndef NS_CONSUMES_SELF
- #if __has_feature(attribute_ns_consumes_self)
- #define NS_CONSUMES_SELF __attribute__((ns_consumes_self))
- #else
- #define NS_CONSUMES_SELF
- #endif
- #endif
- #ifndef GTM_NONNULL
- #if defined(__has_attribute)
- #if __has_attribute(nonnull)
- #define GTM_NONNULL(x) __attribute__((nonnull x))
- #else
- #define GTM_NONNULL(x)
- #endif
- #else
- #define GTM_NONNULL(x)
- #endif
- #endif
- #ifndef GTMInvalidateInitializer
- #if __has_feature(objc_arc)
- #define GTMInvalidateInitializer() \
- do { \
- [self class]
- _GTMDevAssert(NO, @"Invalid initializer.")
- return nil
- } while (0)
- #else
- #define GTMInvalidateInitializer() \
- do { \
- [self release]
- _GTMDevAssert(NO, @"Invalid initializer.")
- return nil
- } while (0)
- #endif
- #endif
- #ifndef GTMCFAutorelease
-
-
- #if __has_feature(objc_arc)
- #define GTMCFAutorelease(x) CFBridgingRelease(x)
- #else
- #define GTMCFAutorelease(x) ([(id)x autorelease])
- #endif
- #endif
- #ifdef __OBJC__
- #if !defined (GTM_NSSTRINGIFY)
- #define GTM_NSSTRINGIFY_INNER(x) @#x
- #define GTM_NSSTRINGIFY(x) GTM_NSSTRINGIFY_INNER(x)
- #endif
- #ifndef GTM_FOREACH_OBJECT
- #if TARGET_OS_IPHONE || !(MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5)
- #define GTM_FOREACH_ENUMEREE(element, enumeration) \
- for (element in enumeration)
- #define GTM_FOREACH_OBJECT(element, collection) \
- for (element in collection)
- #define GTM_FOREACH_KEY(element, collection) \
- for (element in collection)
- #else
- #define GTM_FOREACH_ENUMEREE(element, enumeration) \
- for (NSEnumerator *_ ## element ## _enum = enumeration; \
- (element = [_ ## element ## _enum nextObject]) != nil; )
- #define GTM_FOREACH_OBJECT(element, collection) \
- GTM_FOREACH_ENUMEREE(element, [collection objectEnumerator])
- #define GTM_FOREACH_KEY(element, collection) \
- GTM_FOREACH_ENUMEREE(element, [collection keyEnumerator])
- #endif
- #endif
- #ifndef GTM_SEL_STRING
- #ifdef DEBUG
- #define GTM_SEL_STRING(selName) NSStringFromSelector(@selector(selName))
- #else
- #define GTM_SEL_STRING(selName) @#selName
- #endif
- #endif
- #ifndef GTM_WEAK
- #if __has_feature(objc_arc_weak)
-
-
-
-
-
- #define GTM_WEAK __weak
- #elif __has_feature(objc_arc)
-
-
- #define GTM_WEAK __unsafe_unretained
- #else
-
-
-
-
- #define GTM_WEAK
- #endif
- #endif
- #endif
|