Index: base/mac/mac_util.h |
diff --git a/base/mac/mac_util.h b/base/mac/mac_util.h |
index 746c3da7a19a0bde1ce37d82363656b609e28617..dc5a6c75b289d1fe369f0584dc81226b2dab7957 100644 |
--- a/base/mac/mac_util.h |
+++ b/base/mac/mac_util.h |
@@ -120,56 +120,42 @@ BASE_EXPORT int MacOSXMinorVersion(); |
// "AtMost" variants to those that check for a specific version, unless you |
// know for sure that you need to check for a specific version. |
-#define _DEFINE_IS_OS_FUNCS(V, ID) \ |
- inline bool IsOS10_##V() { \ |
- return MAC_OS_X_VERSION_MIN_REQUIRED <= ID && \ |
- internal::MacOSXMinorVersion() == V; \ |
- } \ |
- inline bool IsAtLeastOS10_##V() { \ |
- return MAC_OS_X_VERSION_MIN_REQUIRED >= ID || \ |
- internal::MacOSXMinorVersion() >= V; \ |
- } \ |
- inline bool IsAtMostOS10_##V() { \ |
- return MAC_OS_X_VERSION_MIN_REQUIRED <= ID && \ |
- internal::MacOSXMinorVersion() <= V; \ |
+#define _DEFINE_IS_OS_FUNCS(V, CHECK_TARGET) \ |
Mark Mentovai
2016/08/30 16:08:15
This is just DEFINE_IS_OS_FUNCS now, there’s no “o
Sidney San Martín
2016/08/30 16:58:43
Since there are a few internal macros now, I was l
|
+ inline bool IsOS10_##V() { \ |
+ CHECK_TARGET(>, V, false) \ |
+ return internal::MacOSXMinorVersion() == V; \ |
+ } \ |
+ inline bool IsAtLeastOS10_##V() { \ |
+ CHECK_TARGET(>=, V, true) \ |
+ return internal::MacOSXMinorVersion() >= V; \ |
+ } \ |
+ inline bool IsAtMostOS10_##V() { \ |
+ CHECK_TARGET(>, V, false) \ |
+ return internal::MacOSXMinorVersion() <= V; \ |
} |
-// Apple adopted this format in 10.10: 10.11.0 becomes 101100 |
-#define OS_X_VERSION_ID(V) 10##V##00 |
-#define DEFINE_IS_OS_FUNCS(V) _DEFINE_IS_OS_FUNCS(V, OS_X_VERSION_ID(V)) |
+#define _CHECK_TARGET(OP, V, RET) \ |
+ if (MAC_OS_X_VERSION_MIN_REQUIRED OP MAC_OS_X_VERSION_10_##V) \ |
+ return RET; |
+#define _IGNORE_TARGET(OP, V, RET) |
-// Sanity check that our computed IDs match the SDK |
-#define STR(S) _STR(S) |
-#define _STR(S) #S |
-#define ASSERT_OS_ID_CONSTANT(V) \ |
- static_assert(OS_X_VERSION_ID(V) == MAC_OS_X_VERSION_10_##V, \ |
- "ID for macOS 10." #V \ |
- " (" STR(OS_X_VERSION_ID(V)) ") doesn't match the SDK (" STR( \ |
- MAC_OS_X_VERSION_10_##V) ")."); |
+_DEFINE_IS_OS_FUNCS(9, _CHECK_TARGET) |
+_DEFINE_IS_OS_FUNCS(10, _CHECK_TARGET) |
-// 10.9 uses an old format. |
-// TODO(sdy): Ditch, most callers are better served by !IsAtLeastOS10_10(). |
-_DEFINE_IS_OS_FUNCS(9, MAC_OS_X_VERSION_10_9) |
- |
-DEFINE_IS_OS_FUNCS(10) |
-ASSERT_OS_ID_CONSTANT(10) |
- |
-DEFINE_IS_OS_FUNCS(11) |
#ifdef MAC_OS_X_VERSION_10_11 |
-ASSERT_OS_ID_CONSTANT(11) |
+_DEFINE_IS_OS_FUNCS(11, _CHECK_TARGET) |
+#else |
+_DEFINE_IS_OS_FUNCS(11, _IGNORE_TARGET) |
#endif |
-DEFINE_IS_OS_FUNCS(12) |
#ifdef MAC_OS_X_VERSION_10_12 |
-ASSERT_OS_ID_CONSTANT(12) |
+_DEFINE_IS_OS_FUNCS(12, _CHECK_TARGET) |
+#else |
+_DEFINE_IS_OS_FUNCS(12, _IGNORE_TARGET) |
#endif |
-#undef ASSERT_OS_ID_CONSTANT |
-#undef _STR |
-#undef STR |
- |
-#undef DEFINE_IS_OS_FUNCS |
-#undef MAC_OS_X_VERISON_ID |
+#undef _IGNORE_TARGET |
+#undef _CHECK_TARGET |
#undef _DEFINE_IS_OS_FUNCS |
// This should be infrequently used. It only makes sense to use this to avoid |