mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-06 21:37:36 +00:00
[C++] Using calculated fields_number for field_names size (#6769)
* using already defined "fields_number" in "field_names" size calculation * tests * forgotten test
This commit is contained in:
@@ -519,13 +519,13 @@ struct Test::Traits {
|
||||
using type = Test;
|
||||
static constexpr auto name = "Test";
|
||||
static constexpr auto fully_qualified_name = "MyGame.Example.Test";
|
||||
static constexpr std::array<const char *, 2> field_names = {
|
||||
static constexpr size_t fields_number = 2;
|
||||
static constexpr std::array<const char *, fields_number> field_names = {
|
||||
"a",
|
||||
"b"
|
||||
};
|
||||
template<size_t Index>
|
||||
using FieldType = decltype(std::declval<type>().get_field<Index>());
|
||||
static constexpr size_t fields_number = 2;
|
||||
};
|
||||
|
||||
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) Vec3 FLATBUFFERS_FINAL_CLASS {
|
||||
@@ -626,7 +626,8 @@ struct Vec3::Traits {
|
||||
using type = Vec3;
|
||||
static constexpr auto name = "Vec3";
|
||||
static constexpr auto fully_qualified_name = "MyGame.Example.Vec3";
|
||||
static constexpr std::array<const char *, 6> field_names = {
|
||||
static constexpr size_t fields_number = 6;
|
||||
static constexpr std::array<const char *, fields_number> field_names = {
|
||||
"x",
|
||||
"y",
|
||||
"z",
|
||||
@@ -636,7 +637,6 @@ struct Vec3::Traits {
|
||||
};
|
||||
template<size_t Index>
|
||||
using FieldType = decltype(std::declval<type>().get_field<Index>());
|
||||
static constexpr size_t fields_number = 6;
|
||||
};
|
||||
|
||||
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Ability FLATBUFFERS_FINAL_CLASS {
|
||||
@@ -688,13 +688,13 @@ struct Ability::Traits {
|
||||
using type = Ability;
|
||||
static constexpr auto name = "Ability";
|
||||
static constexpr auto fully_qualified_name = "MyGame.Example.Ability";
|
||||
static constexpr std::array<const char *, 2> field_names = {
|
||||
static constexpr size_t fields_number = 2;
|
||||
static constexpr std::array<const char *, fields_number> field_names = {
|
||||
"id",
|
||||
"distance"
|
||||
};
|
||||
template<size_t Index>
|
||||
using FieldType = decltype(std::declval<type>().get_field<Index>());
|
||||
static constexpr size_t fields_number = 2;
|
||||
};
|
||||
|
||||
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) StructOfStructs FLATBUFFERS_FINAL_CLASS {
|
||||
@@ -750,14 +750,14 @@ struct StructOfStructs::Traits {
|
||||
using type = StructOfStructs;
|
||||
static constexpr auto name = "StructOfStructs";
|
||||
static constexpr auto fully_qualified_name = "MyGame.Example.StructOfStructs";
|
||||
static constexpr std::array<const char *, 3> field_names = {
|
||||
static constexpr size_t fields_number = 3;
|
||||
static constexpr std::array<const char *, fields_number> field_names = {
|
||||
"a",
|
||||
"b",
|
||||
"c"
|
||||
};
|
||||
template<size_t Index>
|
||||
using FieldType = decltype(std::declval<type>().get_field<Index>());
|
||||
static constexpr size_t fields_number = 3;
|
||||
};
|
||||
|
||||
} // namespace Example
|
||||
@@ -808,8 +808,8 @@ struct InParentNamespace::Traits {
|
||||
static auto constexpr Create = CreateInParentNamespace;
|
||||
static constexpr auto name = "InParentNamespace";
|
||||
static constexpr auto fully_qualified_name = "MyGame.InParentNamespace";
|
||||
static constexpr std::array<const char *, 0> field_names = {};
|
||||
static constexpr size_t fields_number = 0;
|
||||
static constexpr std::array<const char *, fields_number> field_names = {};
|
||||
};
|
||||
|
||||
flatbuffers::Offset<InParentNamespace> CreateInParentNamespace(flatbuffers::FlatBufferBuilder &_fbb, const InParentNamespaceT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
@@ -862,8 +862,8 @@ struct Monster::Traits {
|
||||
static auto constexpr Create = CreateMonster;
|
||||
static constexpr auto name = "Monster";
|
||||
static constexpr auto fully_qualified_name = "MyGame.Example2.Monster";
|
||||
static constexpr std::array<const char *, 0> field_names = {};
|
||||
static constexpr size_t fields_number = 0;
|
||||
static constexpr std::array<const char *, fields_number> field_names = {};
|
||||
};
|
||||
|
||||
flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
@@ -939,12 +939,12 @@ struct TestSimpleTableWithEnum::Traits {
|
||||
static auto constexpr Create = CreateTestSimpleTableWithEnum;
|
||||
static constexpr auto name = "TestSimpleTableWithEnum";
|
||||
static constexpr auto fully_qualified_name = "MyGame.Example.TestSimpleTableWithEnum";
|
||||
static constexpr std::array<const char *, 1> field_names = {
|
||||
static constexpr size_t fields_number = 1;
|
||||
static constexpr std::array<const char *, fields_number> field_names = {
|
||||
"color"
|
||||
};
|
||||
template<size_t Index>
|
||||
using FieldType = decltype(std::declval<type>().get_field<Index>());
|
||||
static constexpr size_t fields_number = 1;
|
||||
};
|
||||
|
||||
flatbuffers::Offset<TestSimpleTableWithEnum> CreateTestSimpleTableWithEnum(flatbuffers::FlatBufferBuilder &_fbb, const TestSimpleTableWithEnumT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
@@ -1053,14 +1053,14 @@ struct Stat::Traits {
|
||||
static auto constexpr Create = CreateStat;
|
||||
static constexpr auto name = "Stat";
|
||||
static constexpr auto fully_qualified_name = "MyGame.Example.Stat";
|
||||
static constexpr std::array<const char *, 3> field_names = {
|
||||
static constexpr size_t fields_number = 3;
|
||||
static constexpr std::array<const char *, fields_number> field_names = {
|
||||
"id",
|
||||
"val",
|
||||
"count"
|
||||
};
|
||||
template<size_t Index>
|
||||
using FieldType = decltype(std::declval<type>().get_field<Index>());
|
||||
static constexpr size_t fields_number = 3;
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<Stat> CreateStatDirect(
|
||||
@@ -1151,12 +1151,12 @@ struct Referrable::Traits {
|
||||
static auto constexpr Create = CreateReferrable;
|
||||
static constexpr auto name = "Referrable";
|
||||
static constexpr auto fully_qualified_name = "MyGame.Example.Referrable";
|
||||
static constexpr std::array<const char *, 1> field_names = {
|
||||
static constexpr size_t fields_number = 1;
|
||||
static constexpr std::array<const char *, fields_number> field_names = {
|
||||
"id"
|
||||
};
|
||||
template<size_t Index>
|
||||
using FieldType = decltype(std::declval<type>().get_field<Index>());
|
||||
static constexpr size_t fields_number = 1;
|
||||
};
|
||||
|
||||
flatbuffers::Offset<Referrable> CreateReferrable(flatbuffers::FlatBufferBuilder &_fbb, const ReferrableT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
@@ -2056,7 +2056,8 @@ struct Monster::Traits {
|
||||
static auto constexpr Create = CreateMonster;
|
||||
static constexpr auto name = "Monster";
|
||||
static constexpr auto fully_qualified_name = "MyGame.Example.Monster";
|
||||
static constexpr std::array<const char *, 50> field_names = {
|
||||
static constexpr size_t fields_number = 50;
|
||||
static constexpr std::array<const char *, fields_number> field_names = {
|
||||
"pos",
|
||||
"mana",
|
||||
"hp",
|
||||
@@ -2110,7 +2111,6 @@ struct Monster::Traits {
|
||||
};
|
||||
template<size_t Index>
|
||||
using FieldType = decltype(std::declval<type>().get_field<Index>());
|
||||
static constexpr size_t fields_number = 50;
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<Monster> CreateMonsterDirect(
|
||||
@@ -2476,7 +2476,8 @@ struct TypeAliases::Traits {
|
||||
static auto constexpr Create = CreateTypeAliases;
|
||||
static constexpr auto name = "TypeAliases";
|
||||
static constexpr auto fully_qualified_name = "MyGame.Example.TypeAliases";
|
||||
static constexpr std::array<const char *, 12> field_names = {
|
||||
static constexpr size_t fields_number = 12;
|
||||
static constexpr std::array<const char *, fields_number> field_names = {
|
||||
"i8",
|
||||
"u8",
|
||||
"i16",
|
||||
@@ -2492,7 +2493,6 @@ struct TypeAliases::Traits {
|
||||
};
|
||||
template<size_t Index>
|
||||
using FieldType = decltype(std::declval<type>().get_field<Index>());
|
||||
static constexpr size_t fields_number = 12;
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<TypeAliases> CreateTypeAliasesDirect(
|
||||
|
||||
Reference in New Issue
Block a user