mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-27 09:52:19 +00:00
make flatbuffers::IsFieldPresent safer (#4988)
Give the vtable offset enum inside each table the name "FlatBuffersVTableOffset" and base type voffset_t so it can be used as a dependent type in IsFieldPresent. This makes that function slightly safer since it prevents calling it with arbitrary, non-table types. Now, the only way to use IsFieldPresent incorrectly is to create your own type which does not inherit from flatbuffers::Table but has a dependent voffset convertible type "FlatBuffersVTableOffset".
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
55b30827f2
commit
ca417426c7
@@ -235,7 +235,7 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
static const flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return MonsterTypeTable();
|
||||
}
|
||||
enum {
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_POS = 4,
|
||||
VT_MANA = 6,
|
||||
VT_HP = 8,
|
||||
@@ -443,7 +443,7 @@ struct Weapon FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
static const flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return WeaponTypeTable();
|
||||
}
|
||||
enum {
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_NAME = 4,
|
||||
VT_DAMAGE = 6
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user