mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-16 17:22:21 +00:00
Generate type traits for unions to map a type to the corresponding u… (#4032)
* Generate type traits for unions to map a type to the corresponding union enum value. * Fixed break with union enum type traits when type is in a namespace. * Fixed spacing and variable names in type traits generation to match style guidelines. * Fixed spacing in type traits generation to match style guidelines. * Regenerated test schema header.
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
f6c1a1ebcf
commit
b075b8c49d
Binary file not shown.
@@ -76,6 +76,22 @@ inline const char **EnumNamesAny() {
|
||||
|
||||
inline const char *EnumNameAny(Any e) { return EnumNamesAny()[static_cast<int>(e)]; }
|
||||
|
||||
template<typename T> struct AnyTraits {
|
||||
static const Any enum_value = Any_NONE;
|
||||
};
|
||||
|
||||
template<> struct AnyTraits<Monster> {
|
||||
static const Any enum_value = Any_Monster;
|
||||
};
|
||||
|
||||
template<> struct AnyTraits<TestSimpleTableWithEnum> {
|
||||
static const Any enum_value = Any_TestSimpleTableWithEnum;
|
||||
};
|
||||
|
||||
template<> struct AnyTraits<MyGame::Example2::Monster> {
|
||||
static const Any enum_value = Any_MyGame_Example2_Monster;
|
||||
};
|
||||
|
||||
inline bool VerifyAny(flatbuffers::Verifier &verifier, const void *union_obj, Any type);
|
||||
|
||||
MANUALLY_ALIGNED_STRUCT(2) Test FLATBUFFERS_FINAL_CLASS {
|
||||
|
||||
Reference in New Issue
Block a user