Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Keep this file in sync with entry_kernel.h. | 5 // Keep this file in sync with entry_kernel.h. |
| 6 | 6 |
| 7 #include "sync/syncable/syncable_enum_conversions.h" | 7 #include "sync/syncable/syncable_enum_conversions.h" |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 | 11 |
| 12 namespace syncer { | 12 namespace syncer { |
| 13 namespace syncable { | 13 namespace syncable { |
| 14 | 14 |
| 15 // We can't tokenize expected_min/expected_max since it can be a | 15 // We can't tokenize expected_min/expected_max since it can be a |
| 16 // general expression. | 16 // general expression. |
| 17 #define ASSERT_ENUM_BOUNDS(enum_min, enum_max, expected_min, expected_max) \ | 17 #define ASSERT_ENUM_BOUNDS(enum_min, enum_max, expected_min, expected_max) \ |
| 18 COMPILE_ASSERT(static_cast<int>(enum_min) == \ | 18 static_assert(static_cast<int>(enum_min) == \ |
| 19 static_cast<int>(expected_min), \ | 19 static_cast<int>(expected_min), \ |
| 20 enum_min##_not_expected_min); \ | 20 #enum_min " not " #expected_min); \ |
|
maniscalco
2015/01/07 18:22:50
nit: this trailing slash doesn't line up with the
Mostyn Bramley-Moore
2015/01/07 19:16:40
Done.
| |
| 21 COMPILE_ASSERT(static_cast<int>(enum_max) == \ | 21 static_assert(static_cast<int>(enum_max) == \ |
| 22 static_cast<int>(expected_max), \ | 22 static_cast<int>(expected_max), \ |
| 23 enum_max##_not_expected_max); | 23 #enum_max " not " #expected_max); |
| 24 | 24 |
| 25 #define ENUM_CASE(enum_value) case enum_value: return #enum_value | 25 #define ENUM_CASE(enum_value) case enum_value: return #enum_value |
| 26 | 26 |
| 27 const char* GetMetahandleFieldString(MetahandleField metahandle_field) { | 27 const char* GetMetahandleFieldString(MetahandleField metahandle_field) { |
| 28 ASSERT_ENUM_BOUNDS(META_HANDLE, META_HANDLE, | 28 ASSERT_ENUM_BOUNDS(META_HANDLE, META_HANDLE, |
| 29 INT64_FIELDS_BEGIN, BASE_VERSION - 1); | 29 INT64_FIELDS_BEGIN, BASE_VERSION - 1); |
| 30 switch (metahandle_field) { | 30 switch (metahandle_field) { |
| 31 ENUM_CASE(META_HANDLE); | 31 ENUM_CASE(META_HANDLE); |
| 32 } | 32 } |
| 33 NOTREACHED(); | 33 NOTREACHED(); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 } | 184 } |
| 185 NOTREACHED(); | 185 NOTREACHED(); |
| 186 return ""; | 186 return ""; |
| 187 } | 187 } |
| 188 | 188 |
| 189 #undef ENUM_CASE | 189 #undef ENUM_CASE |
| 190 #undef ASSERT_ENUM_BOUNDS | 190 #undef ASSERT_ENUM_BOUNDS |
| 191 | 191 |
| 192 } // namespace syncable | 192 } // namespace syncable |
| 193 } // namespace syncer | 193 } // namespace syncer |
| OLD | NEW |