Color_MAX = Color_Blue
};
+inline Color (&EnumValuesColor())[3] {
+ static Color values[] = {
+ Color_Red,
+ Color_Green,
+ Color_Blue
+ };
+ return values;
+}
+
inline const char **EnumNamesColor() {
static const char *names[] = {
"Red",
Equipment_MAX = Equipment_Weapon
};
+inline Equipment (&EnumValuesEquipment())[2] {
+ static Equipment values[] = {
+ Equipment_NONE,
+ Equipment_Weapon
+ };
+ return values;
+}
+
inline const char **EnumNamesEquipment() {
static const char *names[] = {
"NONE",
(inclass ? " = nullptr" : "") + ") const";
}
- // Generate an enum declaration and an enum string lookup table.
+ // Generate an enum declaration,
+ // an enum string lookup table,
+ // and an enum array of values
void GenEnum(const EnumDef &enum_def) {
code_.SetValue("ENUM_NAME", enum_def.name);
code_.SetValue("BASE_TYPE", GenTypeBasic(enum_def.underlying_type, false));
}
code_ += "";
+ // Generate an array of all enumeration values
+ auto num_fields = NumToString(enum_def.vals.vec.size());
+ code_ += "inline {{ENUM_NAME}} (&EnumValues{{ENUM_NAME}}())[" + num_fields + "] {";
+ code_ += " static {{ENUM_NAME}} values[] = {";
+ for (auto it = enum_def.vals.vec.begin(); it != enum_def.vals.vec.end();
+ ++it) {
+ const auto &ev = **it;
+ auto value = GetEnumValUse(enum_def, ev);
+ auto suffix = *it != enum_def.vals.vec.back() ? "," : "";
+ code_ += " " + value + suffix;
+ }
+ code_ += " };";
+ code_ += " return values;";
+ code_ += "}";
+ code_ += "";
+
// Generate a generate string table for enum values.
// Problem is, if values are very sparse that could generate really big
// tables. Ideally in that case we generate a map lookup instead, but for
Color_ANY = 11
};
+inline Color (&EnumValuesColor())[3] {
+ static Color values[] = {
+ Color_Red,
+ Color_Green,
+ Color_Blue
+ };
+ return values;
+}
+
inline const char **EnumNamesColor() {
static const char *names[] = {
"Red",
Any_MAX = Any_MyGame_Example2_Monster
};
+inline Any (&EnumValuesAny())[4] {
+ static Any values[] = {
+ Any_NONE,
+ Any_Monster,
+ Any_TestSimpleTableWithEnum,
+ Any_MyGame_Example2_Monster
+ };
+ return values;
+}
+
inline const char **EnumNamesAny() {
static const char *names[] = {
"NONE",
EnumInNestedNS_MAX = EnumInNestedNS_C
};
+inline EnumInNestedNS (&EnumValuesEnumInNestedNS())[3] {
+ static EnumInNestedNS values[] = {
+ EnumInNestedNS_A,
+ EnumInNestedNS_B,
+ EnumInNestedNS_C
+ };
+ return values;
+}
+
inline const char **EnumNamesEnumInNestedNS() {
static const char *names[] = {
"A",
Character_MAX = Character_Unused
};
+inline Character (&EnumValuesCharacter())[7] {
+ static Character values[] = {
+ Character_NONE,
+ Character_MuLan,
+ Character_Rapunzel,
+ Character_Belle,
+ Character_BookFan,
+ Character_Other,
+ Character_Unused
+ };
+ return values;
+}
+
inline const char **EnumNamesCharacter() {
static const char *names[] = {
"NONE",