[TS] Fix generation of struct members in object api (#7148)

* Fix C/C++ Create<Type>Direct with sorted vectors

If a struct has a key the vector has to be sorted. To sort the vector
you can't use "const".

* Changes due to code review

* Improve code readability

* Add generate of JSON schema to string to lib

* option indent_step is supported

* Remove unused variables

* Fix break in test

* Fix style to be consistent with rest of the code

* [TS] Fix reserved words as arguments (#6955)

* [TS] Fix generation of reserved words in object api (#7106)

* [TS] Fix generation of object api

* [TS] Fix MakeCamel -> ConvertCase

* [TS] Add test for struct of struct of struct

* Update generated files

* Add missing files

* [TS] Fix query of null/undefined fields in object api
This commit is contained in:
tira-misu
2022-03-24 05:40:11 +01:00
committed by GitHub
parent 4213d91054
commit 2ad408697f
27 changed files with 1490 additions and 344 deletions

View File

@@ -35,6 +35,8 @@ struct Ability;
struct StructOfStructs;
struct StructOfStructsOfStructs;
struct Stat;
struct StatBuilder;
struct StatT;
@@ -73,6 +75,8 @@ inline const flatbuffers::TypeTable *AbilityTypeTable();
inline const flatbuffers::TypeTable *StructOfStructsTypeTable();
inline const flatbuffers::TypeTable *StructOfStructsOfStructsTypeTable();
inline const flatbuffers::TypeTable *StatTypeTable();
inline const flatbuffers::TypeTable *ReferrableTypeTable();
@@ -815,6 +819,47 @@ struct StructOfStructs::Traits {
using FieldType = decltype(std::declval<type>().get_field<Index>());
};
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) StructOfStructsOfStructs FLATBUFFERS_FINAL_CLASS {
private:
MyGame::Example::StructOfStructs a_;
public:
struct Traits;
static const flatbuffers::TypeTable *MiniReflectTypeTable() {
return StructOfStructsOfStructsTypeTable();
}
StructOfStructsOfStructs()
: a_() {
}
StructOfStructsOfStructs(const MyGame::Example::StructOfStructs &_a)
: a_(_a) {
}
const MyGame::Example::StructOfStructs &a() const {
return a_;
}
MyGame::Example::StructOfStructs &mutable_a() {
return a_;
}
template<size_t Index>
auto get_field() const {
if constexpr (Index == 0) return a();
else static_assert(Index != Index, "Invalid Field Index");
}
};
FLATBUFFERS_STRUCT_END(StructOfStructsOfStructs, 20);
struct StructOfStructsOfStructs::Traits {
using type = StructOfStructsOfStructs;
static constexpr auto name = "StructOfStructsOfStructs";
static constexpr auto fully_qualified_name = "MyGame.Example.StructOfStructsOfStructs";
static constexpr size_t fields_number = 1;
static constexpr std::array<const char *, fields_number> field_names = {
"a"
};
template<size_t Index>
using FieldType = decltype(std::declval<type>().get_field<Index>());
};
} // namespace Example
struct InParentNamespaceT : public flatbuffers::NativeTable {
@@ -3737,6 +3782,23 @@ inline const flatbuffers::TypeTable *StructOfStructsTypeTable() {
return &tt;
}
inline const flatbuffers::TypeTable *StructOfStructsOfStructsTypeTable() {
static const flatbuffers::TypeCode type_codes[] = {
{ flatbuffers::ET_SEQUENCE, 0, 0 }
};
static const flatbuffers::TypeFunction type_refs[] = {
MyGame::Example::StructOfStructsTypeTable
};
static const int64_t values[] = { 0, 20 };
static const char * const names[] = {
"a"
};
static const flatbuffers::TypeTable tt = {
flatbuffers::ST_STRUCT, 1, type_codes, type_refs, nullptr, values, names
};
return &tt;
}
inline const flatbuffers::TypeTable *StatTypeTable() {
static const flatbuffers::TypeCode type_codes[] = {
{ flatbuffers::ET_STRING, 0, -1 },