mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-27 19:18:05 +00:00
various fixes (#7986)
This commit is contained in:
@@ -532,16 +532,17 @@ if(FLATBUFFERS_BUILD_TESTS)
|
|||||||
# The flattest target needs some generated files
|
# The flattest target needs some generated files
|
||||||
SET(FLATC_OPT --cpp --gen-mutable --gen-object-api --reflect-names)
|
SET(FLATC_OPT --cpp --gen-mutable --gen-object-api --reflect-names)
|
||||||
SET(FLATC_OPT_COMP ${FLATC_OPT};--gen-compare)
|
SET(FLATC_OPT_COMP ${FLATC_OPT};--gen-compare)
|
||||||
|
SET(FLATC_OPT_SCOPED_ENUMS ${FLATC_OPT_COMP};--scoped-enums)
|
||||||
|
|
||||||
compile_schema_for_test(tests/alignment_test.fbs "${FLATC_OPT_COMP}")
|
compile_schema_for_test(tests/alignment_test.fbs "${FLATC_OPT_COMP}")
|
||||||
compile_schema_for_test(tests/arrays_test.fbs "${FLATC_OPT_COMP};--scoped-enums")
|
compile_schema_for_test(tests/arrays_test.fbs "${FLATC_OPT_SCOPED_ENUMS}")
|
||||||
compile_schema_for_test(tests/native_inline_table_test.fbs "${FLATC_OPT_COMP}")
|
compile_schema_for_test(tests/native_inline_table_test.fbs "${FLATC_OPT_COMP}")
|
||||||
compile_schema_for_test(tests/native_type_test.fbs "${FLATC_OPT}")
|
compile_schema_for_test(tests/native_type_test.fbs "${FLATC_OPT}")
|
||||||
compile_schema_for_test(tests/key_field/key_field_sample.fbs "${FLATC_OPT_COMP}")
|
compile_schema_for_test(tests/key_field/key_field_sample.fbs "${FLATC_OPT_COMP}")
|
||||||
compile_schema_for_test(tests/64bit/test_64bit.fbs "${FLATC_OPT_COMP};--bfbs-gen-embed")
|
compile_schema_for_test(tests/64bit/test_64bit.fbs "${FLATC_OPT_COMP};--bfbs-gen-embed")
|
||||||
compile_schema_for_test(tests/64bit/evolution/v1.fbs "${FLATC_OPT_COMP}")
|
compile_schema_for_test(tests/64bit/evolution/v1.fbs "${FLATC_OPT_COMP}")
|
||||||
compile_schema_for_test(tests/64bit/evolution/v2.fbs "${FLATC_OPT_COMP}")
|
compile_schema_for_test(tests/64bit/evolution/v2.fbs "${FLATC_OPT_COMP}")
|
||||||
compile_schema_for_test(tests/union_underlying_type_test.fbs "${FLATC_OPT_COMP}")
|
compile_schema_for_test(tests/union_underlying_type_test.fbs "${FLATC_OPT_SCOPED_ENUMS}")
|
||||||
|
|
||||||
if(FLATBUFFERS_CODE_SANITIZE)
|
if(FLATBUFFERS_CODE_SANITIZE)
|
||||||
add_fsanitize_to_target(flattests ${FLATBUFFERS_CODE_SANITIZE})
|
add_fsanitize_to_target(flattests ${FLATBUFFERS_CODE_SANITIZE})
|
||||||
|
|||||||
@@ -1218,6 +1218,16 @@ class Parser : public ParserState {
|
|||||||
// These functions return nullptr on success, or an error string,
|
// These functions return nullptr on success, or an error string,
|
||||||
// which may happen if the flatbuffer cannot be encoded in JSON (e.g.,
|
// which may happen if the flatbuffer cannot be encoded in JSON (e.g.,
|
||||||
// it contains non-UTF-8 byte arrays in String values).
|
// it contains non-UTF-8 byte arrays in String values).
|
||||||
|
extern bool GenerateTextFromTable(const Parser &parser,
|
||||||
|
const void *table,
|
||||||
|
const std::string &tablename,
|
||||||
|
std::string *text);
|
||||||
|
extern const char *GenerateText(const Parser &parser, const void *flatbuffer,
|
||||||
|
std::string *text);
|
||||||
|
extern const char *GenerateTextFile(const Parser &parser,
|
||||||
|
const std::string &path,
|
||||||
|
const std::string &file_name);
|
||||||
|
|
||||||
extern const char *GenTextFromTable(const Parser &parser, const void *table,
|
extern const char *GenTextFromTable(const Parser &parser, const void *table,
|
||||||
const std::string &tablename,
|
const std::string &tablename,
|
||||||
std::string *text);
|
std::string *text);
|
||||||
|
|||||||
@@ -383,6 +383,14 @@ static const char *GenerateTextImpl(const Parser &parser, const Table *table,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Generate a text representation of a flatbuffer in JSON format.
|
||||||
|
// Deprecated: please use `GenTextFromTable`
|
||||||
|
bool GenerateTextFromTable(const Parser &parser, const void *table,
|
||||||
|
const std::string &table_name,
|
||||||
|
std::string *_text) {
|
||||||
|
return GenTextFromTable(parser, table, table_name, _text) != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
// Generate a text representation of a flatbuffer in JSON format.
|
// Generate a text representation of a flatbuffer in JSON format.
|
||||||
const char *GenTextFromTable(const Parser &parser, const void *table,
|
const char *GenTextFromTable(const Parser &parser, const void *table,
|
||||||
const std::string &table_name, std::string *_text) {
|
const std::string &table_name, std::string *_text) {
|
||||||
@@ -392,6 +400,12 @@ const char *GenTextFromTable(const Parser &parser, const void *table,
|
|||||||
return GenerateTextImpl(parser, root, *struct_def, _text);
|
return GenerateTextImpl(parser, root, *struct_def, _text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated: please use `GenText`
|
||||||
|
const char *GenerateText(const Parser &parser, const void *flatbuffer,
|
||||||
|
std::string *_text) {
|
||||||
|
return GenText(parser, flatbuffer, _text);
|
||||||
|
}
|
||||||
|
|
||||||
// Generate a text representation of a flatbuffer in JSON format.
|
// Generate a text representation of a flatbuffer in JSON format.
|
||||||
const char *GenText(const Parser &parser, const void *flatbuffer,
|
const char *GenText(const Parser &parser, const void *flatbuffer,
|
||||||
std::string *_text) {
|
std::string *_text) {
|
||||||
@@ -406,6 +420,12 @@ static std::string TextFileName(const std::string &path,
|
|||||||
return path + file_name + ".json";
|
return path + file_name + ".json";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated: please use `GenTextFile`
|
||||||
|
const char *GenerateTextFile(const Parser &parser, const std::string &path,
|
||||||
|
const std::string &file_name) {
|
||||||
|
return GenTextFile(parser, path, file_name);
|
||||||
|
}
|
||||||
|
|
||||||
const char *GenTextFile(const Parser &parser, const std::string &path,
|
const char *GenTextFile(const Parser &parser, const std::string &path,
|
||||||
const std::string &file_name) {
|
const std::string &file_name) {
|
||||||
if (parser.opts.use_flexbuffers) {
|
if (parser.opts.use_flexbuffers) {
|
||||||
|
|||||||
@@ -2719,7 +2719,8 @@ bool Parser::Supports64BitOffsets() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Parser::SupportsUnionUnderlyingType() const {
|
bool Parser::SupportsUnionUnderlyingType() const {
|
||||||
return (opts.lang_to_generate & ~(IDLOptions::kCpp | IDLOptions::kTs)) == 0;
|
return (opts.lang_to_generate & ~(IDLOptions::kCpp | IDLOptions::kTs |
|
||||||
|
IDLOptions::kBinary)) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Namespace *Parser::UniqueNamespace(Namespace *ns) {
|
Namespace *Parser::UniqueNamespace(Namespace *ns) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "alignment_test.h"
|
#include "alignment_test.h"
|
||||||
|
|
||||||
#include "alignment_test_generated.h"
|
#include "tests/alignment_test_generated.h"
|
||||||
#include "flatbuffers/flatbuffer_builder.h"
|
#include "flatbuffers/flatbuffer_builder.h"
|
||||||
#include "test_assert.h"
|
#include "test_assert.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "reflection_test.h"
|
#include "reflection_test.h"
|
||||||
|
|
||||||
#include "arrays_test_generated.h"
|
#include "tests/arrays_test_generated.h"
|
||||||
#include "flatbuffers/minireflect.h"
|
#include "flatbuffers/minireflect.h"
|
||||||
#include "flatbuffers/reflection.h"
|
#include "flatbuffers/reflection.h"
|
||||||
#include "flatbuffers/reflection_generated.h"
|
#include "flatbuffers/reflection_generated.h"
|
||||||
|
|||||||
@@ -20,6 +20,12 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#if defined(__ANDRIOD__)
|
||||||
|
#define INCLUDE_64_BIT_TESTS 0
|
||||||
|
#else
|
||||||
|
#define INCLUDE_64_BIT_TESTS 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "alignment_test.h"
|
#include "alignment_test.h"
|
||||||
#include "evolution_test.h"
|
#include "evolution_test.h"
|
||||||
#include "flatbuffers/flatbuffers.h"
|
#include "flatbuffers/flatbuffers.h"
|
||||||
@@ -38,12 +44,14 @@
|
|||||||
#include "parser_test.h"
|
#include "parser_test.h"
|
||||||
#include "proto_test.h"
|
#include "proto_test.h"
|
||||||
#include "reflection_test.h"
|
#include "reflection_test.h"
|
||||||
#include "union_vector/union_vector_generated.h"
|
#include "tests/union_vector/union_vector_generated.h"
|
||||||
#include "union_underlying_type_test_generated.h"
|
#include "union_underlying_type_test_generated.h"
|
||||||
#if !defined(_MSC_VER) || _MSC_VER >= 1700
|
#if !defined(_MSC_VER) || _MSC_VER >= 1700
|
||||||
# include "arrays_test_generated.h"
|
# include "tests/arrays_test_generated.h"
|
||||||
|
#endif
|
||||||
|
#if INCLUDE_64_BIT_TESTS
|
||||||
|
#include "tests/64bit/offset64_test.h"
|
||||||
#endif
|
#endif
|
||||||
#include "64bit/offset64_test.h"
|
|
||||||
#include "flexbuffers_test.h"
|
#include "flexbuffers_test.h"
|
||||||
#include "is_quiet_nan.h"
|
#include "is_quiet_nan.h"
|
||||||
#include "monster_test_bfbs_generated.h" // Generated using --bfbs-comments --bfbs-builtins --cpp --bfbs-gen-embed
|
#include "monster_test_bfbs_generated.h" // Generated using --bfbs-comments --bfbs-builtins --cpp --bfbs-gen-embed
|
||||||
@@ -1544,9 +1552,9 @@ void DoNotRequireEofTest(const std::string &tests_data_path) {
|
|||||||
void UnionUnderlyingTypeTest() {
|
void UnionUnderlyingTypeTest() {
|
||||||
using namespace UnionUnderlyingType;
|
using namespace UnionUnderlyingType;
|
||||||
TEST_ASSERT(sizeof(ABC) == sizeof(uint32_t));
|
TEST_ASSERT(sizeof(ABC) == sizeof(uint32_t));
|
||||||
TEST_ASSERT(ABC::ABC_A == 555);
|
TEST_ASSERT(static_cast<int32_t>(ABC::A) == 555);
|
||||||
TEST_ASSERT(ABC::ABC_B == 666);
|
TEST_ASSERT(static_cast<int32_t>(ABC::B) == 666);
|
||||||
TEST_ASSERT(ABC::ABC_C == 777);
|
TEST_ASSERT(static_cast<int32_t>(ABC::C) == 777);
|
||||||
|
|
||||||
DT buffer;
|
DT buffer;
|
||||||
AT a;
|
AT a;
|
||||||
@@ -1577,6 +1585,7 @@ void UnionUnderlyingTypeTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void Offset64Tests() {
|
static void Offset64Tests() {
|
||||||
|
#if INCLUDE_64_BIT_TESTS
|
||||||
Offset64Test();
|
Offset64Test();
|
||||||
Offset64SerializedFirst();
|
Offset64SerializedFirst();
|
||||||
Offset64NestedFlatBuffer();
|
Offset64NestedFlatBuffer();
|
||||||
@@ -1586,6 +1595,7 @@ static void Offset64Tests() {
|
|||||||
Offset64SizePrefix();
|
Offset64SizePrefix();
|
||||||
Offset64ManyVectors();
|
Offset64ManyVectors();
|
||||||
Offset64ForceAlign();
|
Offset64ForceAlign();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int FlatBufferTests(const std::string &tests_data_path) {
|
int FlatBufferTests(const std::string &tests_data_path) {
|
||||||
|
|||||||
@@ -48,74 +48,74 @@ inline const ::flatbuffers::TypeTable *CTypeTable();
|
|||||||
|
|
||||||
inline const ::flatbuffers::TypeTable *DTypeTable();
|
inline const ::flatbuffers::TypeTable *DTypeTable();
|
||||||
|
|
||||||
enum ABC : int32_t {
|
enum class ABC : int32_t {
|
||||||
ABC_NONE = 0,
|
NONE = 0,
|
||||||
ABC_A = 555,
|
A = 555,
|
||||||
ABC_B = 666,
|
B = 666,
|
||||||
ABC_C = 777,
|
C = 777,
|
||||||
ABC_MIN = ABC_NONE,
|
MIN = NONE,
|
||||||
ABC_MAX = ABC_C
|
MAX = C
|
||||||
};
|
};
|
||||||
|
|
||||||
inline const ABC (&EnumValuesABC())[4] {
|
inline const ABC (&EnumValuesABC())[4] {
|
||||||
static const ABC values[] = {
|
static const ABC values[] = {
|
||||||
ABC_NONE,
|
ABC::NONE,
|
||||||
ABC_A,
|
ABC::A,
|
||||||
ABC_B,
|
ABC::B,
|
||||||
ABC_C
|
ABC::C
|
||||||
};
|
};
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const char *EnumNameABC(ABC e) {
|
inline const char *EnumNameABC(ABC e) {
|
||||||
switch (e) {
|
switch (e) {
|
||||||
case ABC_NONE: return "NONE";
|
case ABC::NONE: return "NONE";
|
||||||
case ABC_A: return "A";
|
case ABC::A: return "A";
|
||||||
case ABC_B: return "B";
|
case ABC::B: return "B";
|
||||||
case ABC_C: return "C";
|
case ABC::C: return "C";
|
||||||
default: return "";
|
default: return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T> struct ABCTraits {
|
template<typename T> struct ABCTraits {
|
||||||
static const ABC enum_value = ABC_NONE;
|
static const ABC enum_value = ABC::NONE;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<> struct ABCTraits<UnionUnderlyingType::A> {
|
template<> struct ABCTraits<UnionUnderlyingType::A> {
|
||||||
static const ABC enum_value = ABC_A;
|
static const ABC enum_value = ABC::A;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<> struct ABCTraits<UnionUnderlyingType::B> {
|
template<> struct ABCTraits<UnionUnderlyingType::B> {
|
||||||
static const ABC enum_value = ABC_B;
|
static const ABC enum_value = ABC::B;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<> struct ABCTraits<UnionUnderlyingType::C> {
|
template<> struct ABCTraits<UnionUnderlyingType::C> {
|
||||||
static const ABC enum_value = ABC_C;
|
static const ABC enum_value = ABC::C;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T> struct ABCUnionTraits {
|
template<typename T> struct ABCUnionTraits {
|
||||||
static const ABC enum_value = ABC_NONE;
|
static const ABC enum_value = ABC::NONE;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<> struct ABCUnionTraits<UnionUnderlyingType::AT> {
|
template<> struct ABCUnionTraits<UnionUnderlyingType::AT> {
|
||||||
static const ABC enum_value = ABC_A;
|
static const ABC enum_value = ABC::A;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<> struct ABCUnionTraits<UnionUnderlyingType::BT> {
|
template<> struct ABCUnionTraits<UnionUnderlyingType::BT> {
|
||||||
static const ABC enum_value = ABC_B;
|
static const ABC enum_value = ABC::B;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<> struct ABCUnionTraits<UnionUnderlyingType::CT> {
|
template<> struct ABCUnionTraits<UnionUnderlyingType::CT> {
|
||||||
static const ABC enum_value = ABC_C;
|
static const ABC enum_value = ABC::C;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ABCUnion {
|
struct ABCUnion {
|
||||||
ABC type;
|
ABC type;
|
||||||
void *value;
|
void *value;
|
||||||
|
|
||||||
ABCUnion() : type(ABC_NONE), value(nullptr) {}
|
ABCUnion() : type(ABC::NONE), value(nullptr) {}
|
||||||
ABCUnion(ABCUnion&& u) FLATBUFFERS_NOEXCEPT :
|
ABCUnion(ABCUnion&& u) FLATBUFFERS_NOEXCEPT :
|
||||||
type(ABC_NONE), value(nullptr)
|
type(ABC::NONE), value(nullptr)
|
||||||
{ std::swap(type, u.type); std::swap(value, u.value); }
|
{ std::swap(type, u.type); std::swap(value, u.value); }
|
||||||
ABCUnion(const ABCUnion &);
|
ABCUnion(const ABCUnion &);
|
||||||
ABCUnion &operator=(const ABCUnion &u)
|
ABCUnion &operator=(const ABCUnion &u)
|
||||||
@@ -131,7 +131,7 @@ struct ABCUnion {
|
|||||||
typedef typename std::remove_reference<T>::type RT;
|
typedef typename std::remove_reference<T>::type RT;
|
||||||
Reset();
|
Reset();
|
||||||
type = ABCUnionTraits<RT>::enum_value;
|
type = ABCUnionTraits<RT>::enum_value;
|
||||||
if (type != ABC_NONE) {
|
if (type != ABC::NONE) {
|
||||||
value = new RT(std::forward<T>(val));
|
value = new RT(std::forward<T>(val));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -140,27 +140,27 @@ struct ABCUnion {
|
|||||||
::flatbuffers::Offset<void> Pack(::flatbuffers::FlatBufferBuilder &_fbb, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr) const;
|
::flatbuffers::Offset<void> Pack(::flatbuffers::FlatBufferBuilder &_fbb, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr) const;
|
||||||
|
|
||||||
UnionUnderlyingType::AT *AsA() {
|
UnionUnderlyingType::AT *AsA() {
|
||||||
return type == ABC_A ?
|
return type == ABC::A ?
|
||||||
reinterpret_cast<UnionUnderlyingType::AT *>(value) : nullptr;
|
reinterpret_cast<UnionUnderlyingType::AT *>(value) : nullptr;
|
||||||
}
|
}
|
||||||
const UnionUnderlyingType::AT *AsA() const {
|
const UnionUnderlyingType::AT *AsA() const {
|
||||||
return type == ABC_A ?
|
return type == ABC::A ?
|
||||||
reinterpret_cast<const UnionUnderlyingType::AT *>(value) : nullptr;
|
reinterpret_cast<const UnionUnderlyingType::AT *>(value) : nullptr;
|
||||||
}
|
}
|
||||||
UnionUnderlyingType::BT *AsB() {
|
UnionUnderlyingType::BT *AsB() {
|
||||||
return type == ABC_B ?
|
return type == ABC::B ?
|
||||||
reinterpret_cast<UnionUnderlyingType::BT *>(value) : nullptr;
|
reinterpret_cast<UnionUnderlyingType::BT *>(value) : nullptr;
|
||||||
}
|
}
|
||||||
const UnionUnderlyingType::BT *AsB() const {
|
const UnionUnderlyingType::BT *AsB() const {
|
||||||
return type == ABC_B ?
|
return type == ABC::B ?
|
||||||
reinterpret_cast<const UnionUnderlyingType::BT *>(value) : nullptr;
|
reinterpret_cast<const UnionUnderlyingType::BT *>(value) : nullptr;
|
||||||
}
|
}
|
||||||
UnionUnderlyingType::CT *AsC() {
|
UnionUnderlyingType::CT *AsC() {
|
||||||
return type == ABC_C ?
|
return type == ABC::C ?
|
||||||
reinterpret_cast<UnionUnderlyingType::CT *>(value) : nullptr;
|
reinterpret_cast<UnionUnderlyingType::CT *>(value) : nullptr;
|
||||||
}
|
}
|
||||||
const UnionUnderlyingType::CT *AsC() const {
|
const UnionUnderlyingType::CT *AsC() const {
|
||||||
return type == ABC_C ?
|
return type == ABC::C ?
|
||||||
reinterpret_cast<const UnionUnderlyingType::CT *>(value) : nullptr;
|
reinterpret_cast<const UnionUnderlyingType::CT *>(value) : nullptr;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -169,18 +169,18 @@ struct ABCUnion {
|
|||||||
inline bool operator==(const ABCUnion &lhs, const ABCUnion &rhs) {
|
inline bool operator==(const ABCUnion &lhs, const ABCUnion &rhs) {
|
||||||
if (lhs.type != rhs.type) return false;
|
if (lhs.type != rhs.type) return false;
|
||||||
switch (lhs.type) {
|
switch (lhs.type) {
|
||||||
case ABC_NONE: {
|
case ABC::NONE: {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case ABC_A: {
|
case ABC::A: {
|
||||||
return *(reinterpret_cast<const UnionUnderlyingType::AT *>(lhs.value)) ==
|
return *(reinterpret_cast<const UnionUnderlyingType::AT *>(lhs.value)) ==
|
||||||
*(reinterpret_cast<const UnionUnderlyingType::AT *>(rhs.value));
|
*(reinterpret_cast<const UnionUnderlyingType::AT *>(rhs.value));
|
||||||
}
|
}
|
||||||
case ABC_B: {
|
case ABC::B: {
|
||||||
return *(reinterpret_cast<const UnionUnderlyingType::BT *>(lhs.value)) ==
|
return *(reinterpret_cast<const UnionUnderlyingType::BT *>(lhs.value)) ==
|
||||||
*(reinterpret_cast<const UnionUnderlyingType::BT *>(rhs.value));
|
*(reinterpret_cast<const UnionUnderlyingType::BT *>(rhs.value));
|
||||||
}
|
}
|
||||||
case ABC_C: {
|
case ABC::C: {
|
||||||
return *(reinterpret_cast<const UnionUnderlyingType::CT *>(lhs.value)) ==
|
return *(reinterpret_cast<const UnionUnderlyingType::CT *>(lhs.value)) ==
|
||||||
*(reinterpret_cast<const UnionUnderlyingType::CT *>(rhs.value));
|
*(reinterpret_cast<const UnionUnderlyingType::CT *>(rhs.value));
|
||||||
}
|
}
|
||||||
@@ -195,7 +195,7 @@ inline bool operator!=(const ABCUnion &lhs, const ABCUnion &rhs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool VerifyABC(::flatbuffers::Verifier &verifier, const void *obj, ABC type);
|
bool VerifyABC(::flatbuffers::Verifier &verifier, const void *obj, ABC type);
|
||||||
bool VerifyABCVector(::flatbuffers::Verifier &verifier, const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *values, const ::flatbuffers::Vector<int32_t> *types);
|
bool VerifyABCVector(::flatbuffers::Verifier &verifier, const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *values, const ::flatbuffers::Vector<ABC> *types);
|
||||||
|
|
||||||
struct AT : public ::flatbuffers::NativeTable {
|
struct AT : public ::flatbuffers::NativeTable {
|
||||||
typedef A TableType;
|
typedef A TableType;
|
||||||
@@ -407,22 +407,22 @@ struct D FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
}
|
}
|
||||||
template<typename T> const T *test_union_as() const;
|
template<typename T> const T *test_union_as() const;
|
||||||
const UnionUnderlyingType::A *test_union_as_A() const {
|
const UnionUnderlyingType::A *test_union_as_A() const {
|
||||||
return test_union_type() == UnionUnderlyingType::ABC_A ? static_cast<const UnionUnderlyingType::A *>(test_union()) : nullptr;
|
return test_union_type() == UnionUnderlyingType::ABC::A ? static_cast<const UnionUnderlyingType::A *>(test_union()) : nullptr;
|
||||||
}
|
}
|
||||||
const UnionUnderlyingType::B *test_union_as_B() const {
|
const UnionUnderlyingType::B *test_union_as_B() const {
|
||||||
return test_union_type() == UnionUnderlyingType::ABC_B ? static_cast<const UnionUnderlyingType::B *>(test_union()) : nullptr;
|
return test_union_type() == UnionUnderlyingType::ABC::B ? static_cast<const UnionUnderlyingType::B *>(test_union()) : nullptr;
|
||||||
}
|
}
|
||||||
const UnionUnderlyingType::C *test_union_as_C() const {
|
const UnionUnderlyingType::C *test_union_as_C() const {
|
||||||
return test_union_type() == UnionUnderlyingType::ABC_C ? static_cast<const UnionUnderlyingType::C *>(test_union()) : nullptr;
|
return test_union_type() == UnionUnderlyingType::ABC::C ? static_cast<const UnionUnderlyingType::C *>(test_union()) : nullptr;
|
||||||
}
|
}
|
||||||
void *mutable_test_union() {
|
void *mutable_test_union() {
|
||||||
return GetPointer<void *>(VT_TEST_UNION);
|
return GetPointer<void *>(VT_TEST_UNION);
|
||||||
}
|
}
|
||||||
const ::flatbuffers::Vector<int32_t> *test_vector_of_union_type() const {
|
const ::flatbuffers::Vector<UnionUnderlyingType::ABC> *test_vector_of_union_type() const {
|
||||||
return GetPointer<const ::flatbuffers::Vector<int32_t> *>(VT_TEST_VECTOR_OF_UNION_TYPE);
|
return GetPointer<const ::flatbuffers::Vector<UnionUnderlyingType::ABC> *>(VT_TEST_VECTOR_OF_UNION_TYPE);
|
||||||
}
|
}
|
||||||
::flatbuffers::Vector<int32_t> *mutable_test_vector_of_union_type() {
|
::flatbuffers::Vector<UnionUnderlyingType::ABC> *mutable_test_vector_of_union_type() {
|
||||||
return GetPointer<::flatbuffers::Vector<int32_t> *>(VT_TEST_VECTOR_OF_UNION_TYPE);
|
return GetPointer<::flatbuffers::Vector<UnionUnderlyingType::ABC> *>(VT_TEST_VECTOR_OF_UNION_TYPE);
|
||||||
}
|
}
|
||||||
const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *test_vector_of_union() const {
|
const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *test_vector_of_union() const {
|
||||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *>(VT_TEST_VECTOR_OF_UNION);
|
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *>(VT_TEST_VECTOR_OF_UNION);
|
||||||
@@ -469,7 +469,7 @@ struct DBuilder {
|
|||||||
void add_test_union(::flatbuffers::Offset<void> test_union) {
|
void add_test_union(::flatbuffers::Offset<void> test_union) {
|
||||||
fbb_.AddOffset(D::VT_TEST_UNION, test_union);
|
fbb_.AddOffset(D::VT_TEST_UNION, test_union);
|
||||||
}
|
}
|
||||||
void add_test_vector_of_union_type(::flatbuffers::Offset<::flatbuffers::Vector<int32_t>> test_vector_of_union_type) {
|
void add_test_vector_of_union_type(::flatbuffers::Offset<::flatbuffers::Vector<UnionUnderlyingType::ABC>> test_vector_of_union_type) {
|
||||||
fbb_.AddOffset(D::VT_TEST_VECTOR_OF_UNION_TYPE, test_vector_of_union_type);
|
fbb_.AddOffset(D::VT_TEST_VECTOR_OF_UNION_TYPE, test_vector_of_union_type);
|
||||||
}
|
}
|
||||||
void add_test_vector_of_union(::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<void>>> test_vector_of_union) {
|
void add_test_vector_of_union(::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<void>>> test_vector_of_union) {
|
||||||
@@ -488,9 +488,9 @@ struct DBuilder {
|
|||||||
|
|
||||||
inline ::flatbuffers::Offset<D> CreateD(
|
inline ::flatbuffers::Offset<D> CreateD(
|
||||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
UnionUnderlyingType::ABC test_union_type = UnionUnderlyingType::ABC_NONE,
|
UnionUnderlyingType::ABC test_union_type = UnionUnderlyingType::ABC::NONE,
|
||||||
::flatbuffers::Offset<void> test_union = 0,
|
::flatbuffers::Offset<void> test_union = 0,
|
||||||
::flatbuffers::Offset<::flatbuffers::Vector<int32_t>> test_vector_of_union_type = 0,
|
::flatbuffers::Offset<::flatbuffers::Vector<UnionUnderlyingType::ABC>> test_vector_of_union_type = 0,
|
||||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<void>>> test_vector_of_union = 0) {
|
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<void>>> test_vector_of_union = 0) {
|
||||||
DBuilder builder_(_fbb);
|
DBuilder builder_(_fbb);
|
||||||
builder_.add_test_vector_of_union(test_vector_of_union);
|
builder_.add_test_vector_of_union(test_vector_of_union);
|
||||||
@@ -502,11 +502,11 @@ inline ::flatbuffers::Offset<D> CreateD(
|
|||||||
|
|
||||||
inline ::flatbuffers::Offset<D> CreateDDirect(
|
inline ::flatbuffers::Offset<D> CreateDDirect(
|
||||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
UnionUnderlyingType::ABC test_union_type = UnionUnderlyingType::ABC_NONE,
|
UnionUnderlyingType::ABC test_union_type = UnionUnderlyingType::ABC::NONE,
|
||||||
::flatbuffers::Offset<void> test_union = 0,
|
::flatbuffers::Offset<void> test_union = 0,
|
||||||
const std::vector<int32_t> *test_vector_of_union_type = nullptr,
|
const std::vector<UnionUnderlyingType::ABC> *test_vector_of_union_type = nullptr,
|
||||||
const std::vector<::flatbuffers::Offset<void>> *test_vector_of_union = nullptr) {
|
const std::vector<::flatbuffers::Offset<void>> *test_vector_of_union = nullptr) {
|
||||||
auto test_vector_of_union_type__ = test_vector_of_union_type ? _fbb.CreateVector<int32_t>(*test_vector_of_union_type) : 0;
|
auto test_vector_of_union_type__ = test_vector_of_union_type ? _fbb.CreateVector<UnionUnderlyingType::ABC>(*test_vector_of_union_type) : 0;
|
||||||
auto test_vector_of_union__ = test_vector_of_union ? _fbb.CreateVector<::flatbuffers::Offset<void>>(*test_vector_of_union) : 0;
|
auto test_vector_of_union__ = test_vector_of_union ? _fbb.CreateVector<::flatbuffers::Offset<void>>(*test_vector_of_union) : 0;
|
||||||
return UnionUnderlyingType::CreateD(
|
return UnionUnderlyingType::CreateD(
|
||||||
_fbb,
|
_fbb,
|
||||||
@@ -666,7 +666,7 @@ inline ::flatbuffers::Offset<D> CreateD(::flatbuffers::FlatBufferBuilder &_fbb,
|
|||||||
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const DT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const DT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||||
auto _test_union_type = _o->test_union.type;
|
auto _test_union_type = _o->test_union.type;
|
||||||
auto _test_union = _o->test_union.Pack(_fbb);
|
auto _test_union = _o->test_union.Pack(_fbb);
|
||||||
auto _test_vector_of_union_type = _o->test_vector_of_union.size() ? _fbb.CreateVector<int32_t>(_o->test_vector_of_union.size(), [](size_t i, _VectorArgs *__va) { return static_cast<int32_t>(__va->__o->test_vector_of_union[i].type); }, &_va) : 0;
|
auto _test_vector_of_union_type = _o->test_vector_of_union.size() ? _fbb.CreateVector<ABC>(_o->test_vector_of_union.size(), [](size_t i, _VectorArgs *__va) { return __va->__o->test_vector_of_union[i].type; }, &_va) : 0;
|
||||||
auto _test_vector_of_union = _o->test_vector_of_union.size() ? _fbb.CreateVector<::flatbuffers::Offset<void>>(_o->test_vector_of_union.size(), [](size_t i, _VectorArgs *__va) { return __va->__o->test_vector_of_union[i].Pack(*__va->__fbb, __va->__rehasher); }, &_va) : 0;
|
auto _test_vector_of_union = _o->test_vector_of_union.size() ? _fbb.CreateVector<::flatbuffers::Offset<void>>(_o->test_vector_of_union.size(), [](size_t i, _VectorArgs *__va) { return __va->__o->test_vector_of_union[i].Pack(*__va->__fbb, __va->__rehasher); }, &_va) : 0;
|
||||||
return UnionUnderlyingType::CreateD(
|
return UnionUnderlyingType::CreateD(
|
||||||
_fbb,
|
_fbb,
|
||||||
@@ -678,18 +678,18 @@ inline ::flatbuffers::Offset<D> CreateD(::flatbuffers::FlatBufferBuilder &_fbb,
|
|||||||
|
|
||||||
inline bool VerifyABC(::flatbuffers::Verifier &verifier, const void *obj, ABC type) {
|
inline bool VerifyABC(::flatbuffers::Verifier &verifier, const void *obj, ABC type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ABC_NONE: {
|
case ABC::NONE: {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case ABC_A: {
|
case ABC::A: {
|
||||||
auto ptr = reinterpret_cast<const UnionUnderlyingType::A *>(obj);
|
auto ptr = reinterpret_cast<const UnionUnderlyingType::A *>(obj);
|
||||||
return verifier.VerifyTable(ptr);
|
return verifier.VerifyTable(ptr);
|
||||||
}
|
}
|
||||||
case ABC_B: {
|
case ABC::B: {
|
||||||
auto ptr = reinterpret_cast<const UnionUnderlyingType::B *>(obj);
|
auto ptr = reinterpret_cast<const UnionUnderlyingType::B *>(obj);
|
||||||
return verifier.VerifyTable(ptr);
|
return verifier.VerifyTable(ptr);
|
||||||
}
|
}
|
||||||
case ABC_C: {
|
case ABC::C: {
|
||||||
auto ptr = reinterpret_cast<const UnionUnderlyingType::C *>(obj);
|
auto ptr = reinterpret_cast<const UnionUnderlyingType::C *>(obj);
|
||||||
return verifier.VerifyTable(ptr);
|
return verifier.VerifyTable(ptr);
|
||||||
}
|
}
|
||||||
@@ -697,7 +697,7 @@ inline bool VerifyABC(::flatbuffers::Verifier &verifier, const void *obj, ABC ty
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool VerifyABCVector(::flatbuffers::Verifier &verifier, const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *values, const ::flatbuffers::Vector<int32_t> *types) {
|
inline bool VerifyABCVector(::flatbuffers::Verifier &verifier, const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *values, const ::flatbuffers::Vector<ABC> *types) {
|
||||||
if (!values || !types) return !values && !types;
|
if (!values || !types) return !values && !types;
|
||||||
if (values->size() != types->size()) return false;
|
if (values->size() != types->size()) return false;
|
||||||
for (::flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
|
for (::flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
|
||||||
@@ -712,15 +712,15 @@ inline bool VerifyABCVector(::flatbuffers::Verifier &verifier, const ::flatbuffe
|
|||||||
inline void *ABCUnion::UnPack(const void *obj, ABC type, const ::flatbuffers::resolver_function_t *resolver) {
|
inline void *ABCUnion::UnPack(const void *obj, ABC type, const ::flatbuffers::resolver_function_t *resolver) {
|
||||||
(void)resolver;
|
(void)resolver;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ABC_A: {
|
case ABC::A: {
|
||||||
auto ptr = reinterpret_cast<const UnionUnderlyingType::A *>(obj);
|
auto ptr = reinterpret_cast<const UnionUnderlyingType::A *>(obj);
|
||||||
return ptr->UnPack(resolver);
|
return ptr->UnPack(resolver);
|
||||||
}
|
}
|
||||||
case ABC_B: {
|
case ABC::B: {
|
||||||
auto ptr = reinterpret_cast<const UnionUnderlyingType::B *>(obj);
|
auto ptr = reinterpret_cast<const UnionUnderlyingType::B *>(obj);
|
||||||
return ptr->UnPack(resolver);
|
return ptr->UnPack(resolver);
|
||||||
}
|
}
|
||||||
case ABC_C: {
|
case ABC::C: {
|
||||||
auto ptr = reinterpret_cast<const UnionUnderlyingType::C *>(obj);
|
auto ptr = reinterpret_cast<const UnionUnderlyingType::C *>(obj);
|
||||||
return ptr->UnPack(resolver);
|
return ptr->UnPack(resolver);
|
||||||
}
|
}
|
||||||
@@ -731,15 +731,15 @@ inline void *ABCUnion::UnPack(const void *obj, ABC type, const ::flatbuffers::re
|
|||||||
inline ::flatbuffers::Offset<void> ABCUnion::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const ::flatbuffers::rehasher_function_t *_rehasher) const {
|
inline ::flatbuffers::Offset<void> ABCUnion::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const ::flatbuffers::rehasher_function_t *_rehasher) const {
|
||||||
(void)_rehasher;
|
(void)_rehasher;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ABC_A: {
|
case ABC::A: {
|
||||||
auto ptr = reinterpret_cast<const UnionUnderlyingType::AT *>(value);
|
auto ptr = reinterpret_cast<const UnionUnderlyingType::AT *>(value);
|
||||||
return CreateA(_fbb, ptr, _rehasher).Union();
|
return CreateA(_fbb, ptr, _rehasher).Union();
|
||||||
}
|
}
|
||||||
case ABC_B: {
|
case ABC::B: {
|
||||||
auto ptr = reinterpret_cast<const UnionUnderlyingType::BT *>(value);
|
auto ptr = reinterpret_cast<const UnionUnderlyingType::BT *>(value);
|
||||||
return CreateB(_fbb, ptr, _rehasher).Union();
|
return CreateB(_fbb, ptr, _rehasher).Union();
|
||||||
}
|
}
|
||||||
case ABC_C: {
|
case ABC::C: {
|
||||||
auto ptr = reinterpret_cast<const UnionUnderlyingType::CT *>(value);
|
auto ptr = reinterpret_cast<const UnionUnderlyingType::CT *>(value);
|
||||||
return CreateC(_fbb, ptr, _rehasher).Union();
|
return CreateC(_fbb, ptr, _rehasher).Union();
|
||||||
}
|
}
|
||||||
@@ -749,15 +749,15 @@ inline ::flatbuffers::Offset<void> ABCUnion::Pack(::flatbuffers::FlatBufferBuild
|
|||||||
|
|
||||||
inline ABCUnion::ABCUnion(const ABCUnion &u) : type(u.type), value(nullptr) {
|
inline ABCUnion::ABCUnion(const ABCUnion &u) : type(u.type), value(nullptr) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ABC_A: {
|
case ABC::A: {
|
||||||
value = new UnionUnderlyingType::AT(*reinterpret_cast<UnionUnderlyingType::AT *>(u.value));
|
value = new UnionUnderlyingType::AT(*reinterpret_cast<UnionUnderlyingType::AT *>(u.value));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ABC_B: {
|
case ABC::B: {
|
||||||
value = new UnionUnderlyingType::BT(*reinterpret_cast<UnionUnderlyingType::BT *>(u.value));
|
value = new UnionUnderlyingType::BT(*reinterpret_cast<UnionUnderlyingType::BT *>(u.value));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ABC_C: {
|
case ABC::C: {
|
||||||
value = new UnionUnderlyingType::CT(*reinterpret_cast<UnionUnderlyingType::CT *>(u.value));
|
value = new UnionUnderlyingType::CT(*reinterpret_cast<UnionUnderlyingType::CT *>(u.value));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -768,17 +768,17 @@ inline ABCUnion::ABCUnion(const ABCUnion &u) : type(u.type), value(nullptr) {
|
|||||||
|
|
||||||
inline void ABCUnion::Reset() {
|
inline void ABCUnion::Reset() {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ABC_A: {
|
case ABC::A: {
|
||||||
auto ptr = reinterpret_cast<UnionUnderlyingType::AT *>(value);
|
auto ptr = reinterpret_cast<UnionUnderlyingType::AT *>(value);
|
||||||
delete ptr;
|
delete ptr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ABC_B: {
|
case ABC::B: {
|
||||||
auto ptr = reinterpret_cast<UnionUnderlyingType::BT *>(value);
|
auto ptr = reinterpret_cast<UnionUnderlyingType::BT *>(value);
|
||||||
delete ptr;
|
delete ptr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ABC_C: {
|
case ABC::C: {
|
||||||
auto ptr = reinterpret_cast<UnionUnderlyingType::CT *>(value);
|
auto ptr = reinterpret_cast<UnionUnderlyingType::CT *>(value);
|
||||||
delete ptr;
|
delete ptr;
|
||||||
break;
|
break;
|
||||||
@@ -786,7 +786,7 @@ inline void ABCUnion::Reset() {
|
|||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
value = nullptr;
|
value = nullptr;
|
||||||
type = ABC_NONE;
|
type = ABC::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const ::flatbuffers::TypeTable *ABCTypeTable() {
|
inline const ::flatbuffers::TypeTable *ABCTypeTable() {
|
||||||
|
|||||||
Reference in New Issue
Block a user