float z_;
public:
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return Vec3TypeTable();
+ }
Vec3() {
memset(static_cast<void *>(this), 0, sizeof(Vec3));
}
// Generate GetFullyQualifiedName
code_ += "";
code_ += " public:";
+
+ // Make TypeTable accessible via the generated struct.
+ if (parser_.opts.mini_reflect != IDLOptions::kNone) {
+ code_ +=
+ " static const flatbuffers::TypeTable *MiniReflectTypeTable() {";
+ code_ += " return {{STRUCT_NAME}}TypeTable();";
+ code_ += " }";
+ }
+
GenFullyQualifiedNameGetter(struct_def, Name(struct_def));
// Generate a default constructor.
int8_t padding0__;
public:
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return TestTypeTable();
+ }
Test() {
memset(static_cast<void *>(this), 0, sizeof(Test));
}
int16_t padding2__;
public:
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return Vec3TypeTable();
+ }
Vec3() {
memset(static_cast<void *>(this), 0, sizeof(Vec3));
}
uint32_t distance_;
public:
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return AbilityTypeTable();
+ }
Ability() {
memset(static_cast<void *>(this), 0, sizeof(Ability));
}
int32_t b_;
public:
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return StructInNestedNSTypeTable();
+ }
StructInNestedNS() {
memset(static_cast<void *>(this), 0, sizeof(StructInNestedNS));
}
"test5: [ { a: 10, b: 20 }, { a: 30, b: 40 } ], "
"vector_of_enums: [ Blue, Green ] "
"}");
+
+ Test test(16, 32);
+ Vec3 vec(1,2,3, 1.5, Color_Red, test);
+ flatbuffers::FlatBufferBuilder vec_builder;
+ vec_builder.Finish(vec_builder.CreateStruct(vec));
+ auto vec_buffer = vec_builder.Release();
+ auto vec_str = flatbuffers::FlatBufferToString(vec_buffer.data(),
+ Vec3::MiniReflectTypeTable());
+ TEST_EQ_STR(
+ vec_str.c_str(),
+ "{ x: 1.0, y: 2.0, z: 3.0, test1: 1.5, test2: Red, test3: { a: 16, b: 32 } }");
}
// Parse a .proto schema, output as .fbs
int32_t hair_length_;
public:
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return RapunzelTypeTable();
+ }
Rapunzel() {
memset(static_cast<void *>(this), 0, sizeof(Rapunzel));
}
int32_t books_read_;
public:
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return BookReaderTypeTable();
+ }
BookReader() {
memset(static_cast<void *>(this), 0, sizeof(BookReader));
}