Fix issues with uint64 enums (#5265)

* Fix issues with uint64 enums

- hide the implementation of enums from code generators
- fix uint64 the issue in the cpp-generator
- fix #5108
- new tests
- enums with bit_flags attribute should be unsigned

* Refine objectives of EnumDef's FindByValue and ReverseLookup methods

- move EnumDef::ReverseLookup implementation to idl_parser.cpp
- fix typos

* Make the IsUInt64 method private
This commit is contained in:
Vladimir Glavnyy
2019-05-03 03:57:58 +07:00
committed by Wouter van Oortmerssen
parent 6cc30b3272
commit b8ef8c1521
16 changed files with 526 additions and 276 deletions

View File

@@ -242,9 +242,9 @@ class DartGenerator : public BaseGenerator {
// holes.
if (!is_bit_flags) {
code += " static const int minValue = " +
NumToString(enum_def.vals.vec.front()->value) + ";\n";
enum_def.ToString(*enum_def.MinValue()) + ";\n";
code += " static const int maxValue = " +
NumToString(enum_def.vals.vec.back()->value) + ";\n";
enum_def.ToString(*enum_def.MaxValue()) + ";\n";
}
code +=
@@ -259,13 +259,13 @@ class DartGenerator : public BaseGenerator {
GenDocComment(ev.doc_comment, &code, "", " ");
}
code += " static const " + name + " " + ev.name + " = ";
code += "const " + name + "._(" + NumToString(ev.value) + ");\n";
code += "const " + name + "._(" + enum_def.ToString(ev) + ");\n";
}
code += " static get values => {";
for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end(); ++it) {
auto &ev = **it;
code += NumToString(ev.value) + ": " + ev.name + ",";
code += enum_def.ToString(ev) + ": " + ev.name + ",";
}
code += "};\n\n";
@@ -507,7 +507,7 @@ class DartGenerator : public BaseGenerator {
auto &ev = **en_it;
auto enum_name = NamespaceAliasFromUnionType(ev.name);
code += " case " + NumToString(ev.value) + ": return " +
code += " case " + enum_def.ToString(ev) + ": return " +
enum_name + ".reader.vTableGet(_bc, _bcOffset, " +
NumToString(field.value.offset) + ", null);\n";
}