mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 12:05:50 +00:00
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:
committed by
Wouter van Oortmerssen
parent
fb03f78fb4
commit
33932ceea4
@@ -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) + ">>";
|
||||
|
||||
Reference in New Issue
Block a user