diff options
author | Alexander Gallego <gallego.alexx@gmail.com> | 2018-02-15 17:58:06 -0500 |
---|---|---|
committer | Wouter van Oortmerssen <aardappel@gmail.com> | 2018-02-15 14:58:06 -0800 |
commit | 36f8564846d45589d14f84bfaec7131edcbe3184 (patch) | |
tree | 2a5d33e3b687fdba33589d6932d171a8dfb8a8b0 /samples/monster_generated.h | |
parent | daf0a420bec1a08444bd1ded99f5d7427ea74401 (diff) | |
download | flatbuffers-36f8564846d45589d14f84bfaec7131edcbe3184.tar.gz flatbuffers-36f8564846d45589d14f84bfaec7131edcbe3184.tar.bz2 flatbuffers-36f8564846d45589d14f84bfaec7131edcbe3184.zip |
C++: mini_reflect: Add DefaultTypeTable (#4614)
* mini_reflect: Add DefaultTypeTable
Currently it's very easy to make a mistake when it comes to
instantiating the TypeTable to print a buffer because it is not type
safe.
This will allow us to write safer cpp code:
flatbuffers::FlatBufferToString(reinterpret_cast<const uint8_t *>(&t),
decltype(t)::DefaultTypeTable());
* c++: mini_reflect: update generated code
* Ensure types and names are set for mini_reflect
* c++: mini_refelct: update unit tests with new typed TypeTable
* Adding PR feedback of sylte and naming convention
Diffstat (limited to 'samples/monster_generated.h')
-rw-r--r-- | samples/monster_generated.h | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/samples/monster_generated.h b/samples/monster_generated.h index baf3fe74..32d44d00 100644 --- a/samples/monster_generated.h +++ b/samples/monster_generated.h @@ -17,6 +17,12 @@ struct MonsterT; struct Weapon; struct WeaponT; +inline flatbuffers::TypeTable *Vec3TypeTable(); + +inline flatbuffers::TypeTable *MonsterTypeTable(); + +inline flatbuffers::TypeTable *WeaponTypeTable(); + enum Color { Color_Red = 0, Color_Green = 1, @@ -185,6 +191,9 @@ struct MonsterT : public flatbuffers::NativeTable { struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef MonsterT NativeTableType; + static flatbuffers::TypeTable *MiniReflectTypeTable() { + return MonsterTypeTable(); + } enum { VT_POS = 4, VT_MANA = 6, @@ -384,6 +393,9 @@ struct WeaponT : public flatbuffers::NativeTable { struct Weapon FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef WeaponT NativeTableType; + static flatbuffers::TypeTable *MiniReflectTypeTable() { + return WeaponTypeTable(); + } enum { VT_NAME = 4, VT_DAMAGE = 6 @@ -603,12 +615,6 @@ inline void EquipmentUnion::Reset() { type = Equipment_NONE; } -inline flatbuffers::TypeTable *Vec3TypeTable(); - -inline flatbuffers::TypeTable *MonsterTypeTable(); - -inline flatbuffers::TypeTable *WeaponTypeTable(); - inline flatbuffers::TypeTable *ColorTypeTable() { static flatbuffers::TypeCode type_codes[] = { { flatbuffers::ET_CHAR, 0, 0 }, |