Fixed vectors of enums in object API serialized incorrectly.

And also added tests for them.

Change-Id: I91af1904105435601287291412e82d5066f476a5
Tested: on Linux.
This commit is contained in:
Wouter van Oortmerssen
2018-11-05 14:33:36 -08:00
parent 21591916af
commit 980a6d66d3
18 changed files with 368 additions and 27 deletions

View File

@@ -1538,7 +1538,7 @@ class CppGenerator : public BaseGenerator {
cmp_rhs = "rhs";
compare_op = " return\n " + compare_op + ";";
}
code_.SetValue("CMP_OP", compare_op);
code_.SetValue("CMP_LHS", cmp_lhs);
code_.SetValue("CMP_RHS", cmp_rhs);
@@ -2363,7 +2363,7 @@ class CppGenerator : public BaseGenerator {
// the underlying storage type (eg. uint8_t).
const auto basetype = GenTypeBasic(
field.value.type.enum_def->underlying_type, false);
code += "_fbb.CreateVector((const " + basetype + "*)" + value +
code += "_fbb.CreateVectorScalarCast<" + basetype + ">(" + value +
".data(), " + value + ".size())";
} else if (field.attributes.Lookup("cpp_type")) {
auto type = GenTypeBasic(vector_type, false);