aboutsummaryrefslogtreecommitdiff
path: root/GTMDefines.h
diff options
context:
space:
mode:
Diffstat (limited to 'GTMDefines.h')
-rw-r--r--GTMDefines.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/GTMDefines.h b/GTMDefines.h
index 5242e88..b41a6c8 100644
--- a/GTMDefines.h
+++ b/GTMDefines.h
@@ -155,6 +155,26 @@ GTM_EXTERN void _GTMUnitTestDevLog(NSString *format, ...);
typedef char _GTMCompileAssertSymbol(__LINE__, msg) [ ((test) ? 1 : -1) ]
#endif // _GTMCompileAssert
+// Macro to allow fast enumeration when building for 10.5 or later, and
+// reliance on NSEnumerator for 10.4. Remember, NSDictionary w/ FastEnumeration
+// does keys, so pick the right thing, nothing is done on the FastEnumeration
+// side to be sure you're getting what you wanted.
+#ifndef GTM_FOREACH_OBJECT
+ #if defined(TARGET_OS_IPHONE) || (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5)
+ #define GTM_FOREACH_OBJECT(element, collection) \
+ for (element in collection)
+ #define GTM_FOREACH_KEY(element, collection) \
+ for (element in collection)
+ #else
+ #define GTM_FOREACH_OBJECT(element, collection) \
+ for (NSEnumerator * _ ## element ## _enum = [collection objectEnumerator]; \
+ (element = [_ ## element ## _enum nextObject]) != nil; )
+ #define GTM_FOREACH_KEY(element, collection) \
+ for (NSEnumerator * _ ## element ## _enum = [collection keyEnumerator]; \
+ (element = [_ ## element ## _enum nextObject]) != nil; )
+ #endif
+#endif
+
// ============================================================================
// ----------------------------------------------------------------------------
@@ -179,6 +199,23 @@ GTM_EXTERN void _GTMUnitTestDevLog(NSString *format, ...);
#define GTM_MACOS_SDK 1
#endif
+// Provide a symbol to include/exclude extra code for GC support. (This mainly
+// just controls the inclusion of finalize methods).
+#ifndef GTM_SUPPORT_GC
+ #if GTM_IPHONE_SDK
+ // iPhone never needs GC
+ #define GTM_SUPPORT_GC 0
+ #else
+ // We can't find a symbol to tell if GC is supported/required, so best we
+ // do on Mac targets is include it if we're on 10.5 or later.
+ #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
+ #define GTM_SUPPORT_GC 0
+ #else
+ #define GTM_SUPPORT_GC 1
+ #endif
+ #endif
+#endif
+
// To simplify support for 64bit (and Leopard in general), we provide the type
// defines for non Leopard SDKs
#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4