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 the .proto files in this directory. | 5 // Keep this file in sync with the .proto files in this directory. |
6 | 6 |
7 #include "sync/protocol/proto_enum_conversions.h" | 7 #include "sync/protocol/proto_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 | 13 |
14 #define ASSERT_ENUM_BOUNDS(enum_parent, enum_type, enum_min, enum_max) \ | 14 #define ASSERT_ENUM_BOUNDS(enum_parent, enum_type, enum_min, enum_max) \ |
15 COMPILE_ASSERT(enum_parent::enum_type##_MIN == enum_parent::enum_min, \ | 15 static_assert(enum_parent::enum_type##_MIN == enum_parent::enum_min, \ |
16 enum_type##_MIN_not_##enum_min); \ | 16 #enum_type "_MIN should be " #enum_min); \ |
17 COMPILE_ASSERT(enum_parent::enum_type##_MAX == enum_parent::enum_max, \ | 17 static_assert(enum_parent::enum_type##_MAX == enum_parent::enum_max, \ |
18 enum_type##_MAX_not_##enum_max); | 18 #enum_type "_MAX should be " #enum_max); |
19 | 19 |
20 #define ENUM_CASE(enum_parent, enum_value) \ | 20 #define ENUM_CASE(enum_parent, enum_value) \ |
21 case enum_parent::enum_value: return #enum_value | 21 case enum_parent::enum_value: return #enum_value |
22 | 22 |
23 const char* GetAppListItemTypeString( | 23 const char* GetAppListItemTypeString( |
24 sync_pb::AppListSpecifics::AppListItemType item_type) { | 24 sync_pb::AppListSpecifics::AppListItemType item_type) { |
25 ASSERT_ENUM_BOUNDS(sync_pb::AppListSpecifics, AppListItemType, | 25 ASSERT_ENUM_BOUNDS(sync_pb::AppListSpecifics, AppListItemType, |
26 TYPE_APP, TYPE_URL); | 26 TYPE_APP, TYPE_URL); |
27 switch (item_type) { | 27 switch (item_type) { |
28 ENUM_CASE(sync_pb::AppListSpecifics, TYPE_APP); | 28 ENUM_CASE(sync_pb::AppListSpecifics, TYPE_APP); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 ENUM_CASE(sync_pb::TabNavigation, STATE_BLOCKED); | 273 ENUM_CASE(sync_pb::TabNavigation, STATE_BLOCKED); |
274 } | 274 } |
275 NOTREACHED(); | 275 NOTREACHED(); |
276 return ""; | 276 return ""; |
277 } | 277 } |
278 | 278 |
279 #undef ASSERT_ENUM_BOUNDS | 279 #undef ASSERT_ENUM_BOUNDS |
280 #undef ENUM_CASE | 280 #undef ENUM_CASE |
281 | 281 |
282 } // namespace syncer | 282 } // namespace syncer |
OLD | NEW |