mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-07 05:47:36 +00:00
Add ForceVectorAlignment64 and test (#7977)
This commit is contained in:
@@ -777,10 +777,10 @@ class CppGenerator : public BaseGenerator {
|
||||
if (type.enum_def) return WrapInNameSpace(*type.enum_def);
|
||||
if (type.base_type == BASE_TYPE_BOOL) return "bool";
|
||||
}
|
||||
// Get real underlying type for union type
|
||||
// Get real underlying type for union type
|
||||
auto base_type = type.base_type;
|
||||
if (type.base_type == BASE_TYPE_UTYPE && type.enum_def != nullptr) {
|
||||
base_type = type.enum_def->underlying_type.base_type;
|
||||
base_type = type.enum_def->underlying_type.base_type;
|
||||
}
|
||||
return StringOf(base_type);
|
||||
}
|
||||
@@ -1051,7 +1051,9 @@ class CppGenerator : public BaseGenerator {
|
||||
|
||||
std::string UnionVectorVerifySignature(const EnumDef &enum_def) {
|
||||
const std::string name = Name(enum_def);
|
||||
const std::string &type = opts_.scoped_enums ? name : GenTypeBasic(enum_def.underlying_type, false);
|
||||
const std::string &type =
|
||||
opts_.scoped_enums ? name
|
||||
: GenTypeBasic(enum_def.underlying_type, false);
|
||||
return "bool Verify" + name + "Vector" +
|
||||
"(::flatbuffers::Verifier &verifier, " +
|
||||
"const ::flatbuffers::Vector<::flatbuffers::Offset<void>> "
|
||||
@@ -2930,8 +2932,10 @@ class CppGenerator : public BaseGenerator {
|
||||
const std::string &type =
|
||||
IsStruct(vtype) ? WrapInNameSpace(*vtype.struct_def)
|
||||
: GenTypeWire(vtype, "", false, field.offset64);
|
||||
return "_fbb.ForceVectorAlignment(" + field_size + ", sizeof(" + type +
|
||||
"), " + std::to_string(static_cast<long long>(align)) + ");";
|
||||
return std::string("_fbb.ForceVectorAlignment") +
|
||||
(field.offset64 ? "64" : "") + "(" + field_size + ", sizeof(" +
|
||||
type + "), " + std::to_string(static_cast<long long>(align)) +
|
||||
");";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -3505,7 +3509,8 @@ class CppGenerator : public BaseGenerator {
|
||||
: underlying_type;
|
||||
auto enum_value = "__va->_" + value + "[i].type";
|
||||
if (!opts_.scoped_enums)
|
||||
enum_value = "static_cast<" + underlying_type + ">(" + enum_value + ")";
|
||||
enum_value =
|
||||
"static_cast<" + underlying_type + ">(" + enum_value + ")";
|
||||
|
||||
code += "_fbb.CreateVector<" + type + ">(" + value +
|
||||
".size(), [](size_t i, _VectorArgs *__va) { return " +
|
||||
|
||||
Reference in New Issue
Block a user