Fixed Windows build errors.
Change-Id: I11548bfa3cfe307598eb59c56412974c349d614d
This commit is contained in:
parent
cf825b8819
commit
03ee3db240
|
@ -54,7 +54,7 @@ template<> struct EquipmentTraits<Weapon> {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct EquipmentUnion {
|
struct EquipmentUnion {
|
||||||
Equipment type = Equipment_NONE;
|
Equipment type;
|
||||||
|
|
||||||
flatbuffers::NativeTable *table = nullptr;
|
flatbuffers::NativeTable *table = nullptr;
|
||||||
EquipmentUnion() : type(Equipment_NONE), table(nullptr) {}
|
EquipmentUnion() : type(Equipment_NONE), table(nullptr) {}
|
||||||
|
|
|
@ -525,9 +525,7 @@ class CppGenerator : public BaseGenerator {
|
||||||
if (parser_.opts.generate_object_based_api && enum_def.is_union) {
|
if (parser_.opts.generate_object_based_api && enum_def.is_union) {
|
||||||
// Generate a union type
|
// Generate a union type
|
||||||
code += "struct " + enum_def.name + "Union {\n";
|
code += "struct " + enum_def.name + "Union {\n";
|
||||||
code += " " + enum_def.name + " type = ";
|
code += " " + enum_def.name + " type;\n\n";
|
||||||
code += GetEnumValUse(enum_def, *enum_def.vals.Lookup("NONE"), parser_.opts);
|
|
||||||
code += ";\n\n";
|
|
||||||
code += " flatbuffers::NativeTable *table = nullptr;\n";
|
code += " flatbuffers::NativeTable *table = nullptr;\n";
|
||||||
code += " " + enum_def.name + "Union() : type(";
|
code += " " + enum_def.name + "Union() : type(";
|
||||||
code += GetEnumValUse(enum_def, *enum_def.vals.Lookup("NONE"), parser_.opts);
|
code += GetEnumValUse(enum_def, *enum_def.vals.Lookup("NONE"), parser_.opts);
|
||||||
|
|
|
@ -520,34 +520,34 @@ bool VerifyVector(flatbuffers::Verifier &v,
|
||||||
const reflection::Schema &schema,
|
const reflection::Schema &schema,
|
||||||
const flatbuffers::Table &table,
|
const flatbuffers::Table &table,
|
||||||
const reflection::Field &vec_field) {
|
const reflection::Field &vec_field) {
|
||||||
assert(vec_field.type()->base_type() == reflection::BaseType::Vector);
|
assert(vec_field.type()->base_type() == reflection::Vector);
|
||||||
if (!table.VerifyField<uoffset_t>(v, vec_field.offset()))
|
if (!table.VerifyField<uoffset_t>(v, vec_field.offset()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
switch (vec_field.type()->element()) {
|
switch (vec_field.type()->element()) {
|
||||||
case reflection::BaseType::None:
|
case reflection::None:
|
||||||
assert(false);
|
assert(false);
|
||||||
break;
|
break;
|
||||||
case reflection::BaseType::UType:
|
case reflection::UType:
|
||||||
return v.Verify(flatbuffers::GetFieldV<uint8_t>(table, vec_field));
|
return v.Verify(flatbuffers::GetFieldV<uint8_t>(table, vec_field));
|
||||||
case reflection::BaseType::Bool:
|
case reflection::Bool:
|
||||||
case reflection::BaseType::Byte:
|
case reflection::Byte:
|
||||||
case reflection::BaseType::UByte:
|
case reflection::UByte:
|
||||||
return v.Verify(flatbuffers::GetFieldV<int8_t>(table, vec_field));
|
return v.Verify(flatbuffers::GetFieldV<int8_t>(table, vec_field));
|
||||||
case reflection::BaseType::Short:
|
case reflection::Short:
|
||||||
case reflection::BaseType::UShort:
|
case reflection::UShort:
|
||||||
return v.Verify(flatbuffers::GetFieldV<int16_t>(table, vec_field));
|
return v.Verify(flatbuffers::GetFieldV<int16_t>(table, vec_field));
|
||||||
case reflection::BaseType::Int:
|
case reflection::Int:
|
||||||
case reflection::BaseType::UInt:
|
case reflection::UInt:
|
||||||
return v.Verify(flatbuffers::GetFieldV<int32_t>(table, vec_field));
|
return v.Verify(flatbuffers::GetFieldV<int32_t>(table, vec_field));
|
||||||
case reflection::BaseType::Long:
|
case reflection::Long:
|
||||||
case reflection::BaseType::ULong:
|
case reflection::ULong:
|
||||||
return v.Verify(flatbuffers::GetFieldV<int64_t>(table, vec_field));
|
return v.Verify(flatbuffers::GetFieldV<int64_t>(table, vec_field));
|
||||||
case reflection::BaseType::Float:
|
case reflection::Float:
|
||||||
return v.Verify(flatbuffers::GetFieldV<float>(table, vec_field));
|
return v.Verify(flatbuffers::GetFieldV<float>(table, vec_field));
|
||||||
case reflection::BaseType::Double:
|
case reflection::Double:
|
||||||
return v.Verify(flatbuffers::GetFieldV<double>(table, vec_field));
|
return v.Verify(flatbuffers::GetFieldV<double>(table, vec_field));
|
||||||
case reflection::BaseType::String: {
|
case reflection::String: {
|
||||||
auto vecString =
|
auto vecString =
|
||||||
flatbuffers::GetFieldV<flatbuffers::
|
flatbuffers::GetFieldV<flatbuffers::
|
||||||
Offset<flatbuffers::String>>(table, vec_field);
|
Offset<flatbuffers::String>>(table, vec_field);
|
||||||
|
@ -557,10 +557,10 @@ bool VerifyVector(flatbuffers::Verifier &v,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case reflection::BaseType::Vector:
|
case reflection::Vector:
|
||||||
assert(false);
|
assert(false);
|
||||||
break;
|
break;
|
||||||
case reflection::BaseType::Obj: {
|
case reflection::Obj: {
|
||||||
auto obj = schema.objects()->Get(vec_field.type()->index());
|
auto obj = schema.objects()->Get(vec_field.type()->index());
|
||||||
if (obj->is_struct()) {
|
if (obj->is_struct()) {
|
||||||
if (!VerifyVectorOfStructs(v, table, vec_field.offset(), *obj,
|
if (!VerifyVectorOfStructs(v, table, vec_field.offset(), *obj,
|
||||||
|
@ -583,7 +583,7 @@ bool VerifyVector(flatbuffers::Verifier &v,
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case reflection::BaseType::Union:
|
case reflection::Union:
|
||||||
assert(false);
|
assert(false);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -612,53 +612,53 @@ bool VerifyObject(flatbuffers::Verifier &v,
|
||||||
for (size_t i = 0; i < obj.fields()->size(); i++) {
|
for (size_t i = 0; i < obj.fields()->size(); i++) {
|
||||||
auto field_def = obj.fields()->Get(i);
|
auto field_def = obj.fields()->Get(i);
|
||||||
switch (field_def->type()->base_type()) {
|
switch (field_def->type()->base_type()) {
|
||||||
case reflection::BaseType::None:
|
case reflection::None:
|
||||||
assert(false);
|
assert(false);
|
||||||
break;
|
break;
|
||||||
case reflection::BaseType::UType:
|
case reflection::UType:
|
||||||
if (!table->VerifyField<uint8_t>(v, field_def->offset()))
|
if (!table->VerifyField<uint8_t>(v, field_def->offset()))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case reflection::BaseType::Bool:
|
case reflection::Bool:
|
||||||
case reflection::BaseType::Byte:
|
case reflection::Byte:
|
||||||
case reflection::BaseType::UByte:
|
case reflection::UByte:
|
||||||
if (!table->VerifyField<int8_t>(v, field_def->offset()))
|
if (!table->VerifyField<int8_t>(v, field_def->offset()))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case reflection::BaseType::Short:
|
case reflection::Short:
|
||||||
case reflection::BaseType::UShort:
|
case reflection::UShort:
|
||||||
if (!table->VerifyField<int16_t>(v, field_def->offset()))
|
if (!table->VerifyField<int16_t>(v, field_def->offset()))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case reflection::BaseType::Int:
|
case reflection::Int:
|
||||||
case reflection::BaseType::UInt:
|
case reflection::UInt:
|
||||||
if (!table->VerifyField<int32_t>(v, field_def->offset()))
|
if (!table->VerifyField<int32_t>(v, field_def->offset()))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case reflection::BaseType::Long:
|
case reflection::Long:
|
||||||
case reflection::BaseType::ULong:
|
case reflection::ULong:
|
||||||
if (!table->VerifyField<int64_t>(v, field_def->offset()))
|
if (!table->VerifyField<int64_t>(v, field_def->offset()))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case reflection::BaseType::Float:
|
case reflection::Float:
|
||||||
if (!table->VerifyField<float>(v, field_def->offset()))
|
if (!table->VerifyField<float>(v, field_def->offset()))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case reflection::BaseType::Double:
|
case reflection::Double:
|
||||||
if (!table->VerifyField<double>(v, field_def->offset()))
|
if (!table->VerifyField<double>(v, field_def->offset()))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case reflection::BaseType::String:
|
case reflection::String:
|
||||||
if (!table->VerifyField<uoffset_t>(v, field_def->offset()) ||
|
if (!table->VerifyField<uoffset_t>(v, field_def->offset()) ||
|
||||||
!v.Verify(flatbuffers::GetFieldS(*table, *field_def))) {
|
!v.Verify(flatbuffers::GetFieldS(*table, *field_def))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case reflection::BaseType::Vector:
|
case reflection::Vector:
|
||||||
if (!VerifyVector(v, schema, *table, *field_def))
|
if (!VerifyVector(v, schema, *table, *field_def))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case reflection::BaseType::Obj: {
|
case reflection::Obj: {
|
||||||
auto child_obj = schema.objects()->Get(field_def->type()->index());
|
auto child_obj = schema.objects()->Get(field_def->type()->index());
|
||||||
if (child_obj->is_struct()) {
|
if (child_obj->is_struct()) {
|
||||||
if (!VerifyStruct(v, *table, field_def->offset(), *child_obj,
|
if (!VerifyStruct(v, *table, field_def->offset(), *child_obj,
|
||||||
|
@ -674,7 +674,7 @@ bool VerifyObject(flatbuffers::Verifier &v,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case reflection::BaseType::Union: {
|
case reflection::Union: {
|
||||||
// get union type from the prev field
|
// get union type from the prev field
|
||||||
voffset_t utype_offset = field_def->offset() - sizeof(voffset_t);
|
voffset_t utype_offset = field_def->offset() - sizeof(voffset_t);
|
||||||
auto utype = table->GetField<uint8_t>(utype_offset, 0);
|
auto utype = table->GetField<uint8_t>(utype_offset, 0);
|
||||||
|
|
|
@ -76,7 +76,7 @@ template<> struct AnyTraits<MyGame::Example2::Monster> {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AnyUnion {
|
struct AnyUnion {
|
||||||
Any type = Any_NONE;
|
Any type;
|
||||||
|
|
||||||
flatbuffers::NativeTable *table = nullptr;
|
flatbuffers::NativeTable *table = nullptr;
|
||||||
AnyUnion() : type(Any_NONE), table(nullptr) {}
|
AnyUnion() : type(Any_NONE), table(nullptr) {}
|
||||||
|
|
Loading…
Reference in New Issue