mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-30 23:21:38 +00:00
@@ -1485,6 +1485,35 @@ volatile __attribute__((weak)) const char *flatbuffer_version_string =
|
|||||||
|
|
||||||
#endif // !defined(_WIN32) && !defined(__CYGWIN__)
|
#endif // !defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
|
|
||||||
|
#define DEFINE_BITMASK_OPERATORS(E)\
|
||||||
|
inline E operator | (E lhs, E rhs){\
|
||||||
|
using T = std::underlying_type<E>::type;\
|
||||||
|
return E(T(lhs) | T(rhs));\
|
||||||
|
}\
|
||||||
|
inline E operator & (E lhs, E rhs){\
|
||||||
|
using T = std::underlying_type<E>::type;\
|
||||||
|
return E(T(lhs) & T(rhs));\
|
||||||
|
}\
|
||||||
|
inline E operator ^ (E lhs, E rhs){\
|
||||||
|
using T = std::underlying_type<E>::type;\
|
||||||
|
return E(T(lhs) ^ T(rhs));\
|
||||||
|
}\
|
||||||
|
inline E operator ~ (E lhs){\
|
||||||
|
using T = std::underlying_type<E>::type;\
|
||||||
|
return E(~T(lhs));\
|
||||||
|
}\
|
||||||
|
inline E operator |= (E &lhs, E rhs){\
|
||||||
|
lhs = lhs | rhs;\
|
||||||
|
return lhs;\
|
||||||
|
}\
|
||||||
|
inline E operator &= (E &lhs, E rhs){\
|
||||||
|
lhs = lhs & rhs;\
|
||||||
|
return lhs;\
|
||||||
|
}\
|
||||||
|
inline E operator ^= (E &lhs, E rhs){\
|
||||||
|
lhs = lhs ^ rhs;\
|
||||||
|
return lhs;\
|
||||||
|
}
|
||||||
/// @endcond
|
/// @endcond
|
||||||
} // namespace flatbuffers
|
} // namespace flatbuffers
|
||||||
|
|
||||||
|
|||||||
@@ -182,7 +182,10 @@ static void GenEnum(const Parser &parser, EnumDef &enum_def,
|
|||||||
code += GenEnumVal(enum_def, minv->name, parser.opts) + ",\n";
|
code += GenEnumVal(enum_def, minv->name, parser.opts) + ",\n";
|
||||||
code += " " + GenEnumVal(enum_def, "MAX", parser.opts) + " = ";
|
code += " " + GenEnumVal(enum_def, "MAX", parser.opts) + " = ";
|
||||||
code += GenEnumVal(enum_def, maxv->name, parser.opts) + "\n";
|
code += GenEnumVal(enum_def, maxv->name, parser.opts) + "\n";
|
||||||
code += "};\n\n";
|
code += "};\n";
|
||||||
|
if (parser.opts.scoped_enums && enum_def.attributes.Lookup("bit_flags"))
|
||||||
|
code += "DEFINE_BITMASK_OPERATORS(" + enum_def.name + ")\n";
|
||||||
|
code += "\n";
|
||||||
|
|
||||||
// Generate a generate string table for enum values.
|
// Generate a generate string table for enum values.
|
||||||
// Problem is, if values are very sparse that could generate really big
|
// Problem is, if values are very sparse that could generate really big
|
||||||
|
|||||||
Reference in New Issue
Block a user