Fixed CreateVectorOfStructs for native_type (2nd try) (#4276)

* Added support for serializing native_type with CreateVectorOfNativeStructs

* Added support for serializing native_type with CreateVectorOfSortedNativeStructs

* Added C++ code generation for vectors of native_types
This commit is contained in:
Christian Helmich
2017-04-20 02:14:31 +09:00
committed by Wouter van Oortmerssen
parent fb03f78fb4
commit 33932ceea4
2 changed files with 71 additions and 1 deletions

View File

@@ -1753,7 +1753,15 @@ class CppGenerator : public BaseGenerator {
}
case BASE_TYPE_STRUCT: {
if (IsStruct(vector_type)) {
code += "_fbb.CreateVectorOfStructs(" + value + ")";
auto native_type =
field.value.type.struct_def->attributes.Lookup("native_type");
if (native_type) {
code += "_fbb.CreateVectorOfNativeStructs<";
code += WrapInNameSpace(*vector_type.struct_def) + ">";
} else {
code += "_fbb.CreateVectorOfStructs";
}
code += "(" + value + ")";
} else {
code += "_fbb.CreateVector<flatbuffers::Offset<";
code += WrapInNameSpace(*vector_type.struct_def) + ">>";