Old:
enum Type {
ClipFirst
ClipLast
EndClipFirst
EndClipLast
FloatClipFirst
FloatClipLast
EndFloatClipFirst
EndFloatClipLast
ScrollFirst
ScrollLast
EndScrollFirst
EndScrollLast
New: |k| gets prepended to all the identifiers below.
Problem: This clashes with how macros try to reconstruct the identifiers below and requires the following patch after running the tool:
// See comments of enum Type for usage of the following macros.
#define DEFINE_CATEGORY_METHODS(Category) \
- static bool is##Category##Type(Type type) { return type >= Category##First && type <= Category##Last; } \
+ static bool is##Category##Type(Type type) { return type >= k##Category##First && type <= k##Category##Last; } \
bool is##Category() const { return is##Category##Type(GetType()); }
#define DEFINE_CONVERSION_METHODS(Category1, category1, Category2, category2) \
static Type category1##TypeTo##Category2##Type(Type type) \
{ \
- static_assert(Category1##Last - Category1##First == Category2##Last - Category2##First, \
+ static_assert(k##Category1##Last - k##Category1##First == k##Category2##Last - k##Category2##First, \
"Categories " #Category1 " and " #Category2 " should have same number of enum values. See comments of DisplayItem::Type"); \
ASSERT(is##Category1##Type(type)); \
- return static_cast<Type>(type - Category1##First + Category2##First); \
+ return static_cast<Type>(type - k##Category1##First + k##Category2##First); \
} \
static Type category2##TypeTo##Category1##Type(Type type) \
{ \
ASSERT(is##Category2##Type(type)); \
- return static_cast<Type>(type - Category2##First + Category1##First); \
+ return static_cast<Type>(type - k##Category2##First + k##Category1##First); \
}
#define DEFINE_PAIRED_CATEGORY_METHODS(Category, category) \
@@ -271,9 +271,9 @@ public:
#define DEFINE_PAINT_PHASE_CONVERSION_METHOD(Category) \
static Type paintPhaseTo##Category##Type(int paint_phase) \
{ \
- static_assert(Category##PaintPhaseLast - Category##PaintPhaseFirst == kPaintPhaseMax, \
+ static_assert(k##Category##PaintPhaseLast - k##Category##PaintPhaseFirst == kPaintPhaseMax, \
"Invalid paint-phase-based category " #Category ". See comments of DisplayItem::Type"); \
- return static_cast<Type>(paint_phase + Category##PaintPhaseFirst); \
+ return static_cast<Type>(paint_phase + k##Category##PaintPhaseFirst); \
}
Comment 1 by dcheng@chromium.org
, Aug 25 2016