mirror of
https://github.com/google/flatbuffers.git
synced 2026-08-06 05:10:40 +00:00
bigfoot_ref
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
native_include "bigfoot_ref_test_impl.h";
|
||||
|
||||
namespace BigfootRefTestNS;
|
||||
|
||||
// Stands in for Bigfoot's real UUID - a `native_type` struct so RefId has a
|
||||
// distinct native/flat representation, matching the shape `bigfoot_ref`
|
||||
// requires of a wrapper's payload field.
|
||||
struct RefId (native_type: "Native::RefId") {
|
||||
value: uint64;
|
||||
}
|
||||
|
||||
// The reference-wrapper template itself. `bigfoot_ref_wrapper` marks Ref as
|
||||
// instantiable per referenced type via `bigfoot_ref` below.
|
||||
struct Ref (bigfoot_ref_wrapper: "Native::Ref") {
|
||||
uuid: RefId;
|
||||
}
|
||||
|
||||
// RefHolder references two distinct C++ types (Thing, OtherThing) that are
|
||||
// *never defined anywhere in this test* - only ever forward-declared, by
|
||||
// flatc itself, directly into the generated header. This is the property
|
||||
// `bigfoot_ref` exists to provide: a reference field never requires the
|
||||
// referenced type to be complete. It also references `Thing` twice (once as
|
||||
// a plain field, once in a vector), exercising the include-guard dedup for
|
||||
// two fields that resolve to the identical Pack/UnPack pair.
|
||||
table RefHolder {
|
||||
ref_a: Ref (native_inline, bigfoot_ref: "Native::Thing");
|
||||
ref_a_again: [Ref] (native_inline, bigfoot_ref: "Native::Thing");
|
||||
ref_b: Ref (native_inline, bigfoot_ref: "Native::OtherThing");
|
||||
}
|
||||
|
||||
root_type RefHolder;
|
||||
@@ -0,0 +1,47 @@
|
||||
#include "bigfoot_ref_test_impl.h"
|
||||
|
||||
#include "bigfoot_ref_test_generated.h"
|
||||
#include "test_assert.h"
|
||||
|
||||
namespace flatbuffers {
|
||||
BigfootRefTestNS::RefId Pack(const Native::RefId& obj) {
|
||||
return BigfootRefTestNS::RefId(obj.value);
|
||||
}
|
||||
|
||||
const Native::RefId UnPack(const BigfootRefTestNS::RefId& obj) {
|
||||
return Native::RefId(obj.value());
|
||||
}
|
||||
} // namespace flatbuffers
|
||||
|
||||
namespace flatbuffers {
|
||||
namespace tests {
|
||||
|
||||
// Exercises the --bigfoot_ref/--bigfoot_ref_wrapper flatc attributes (see
|
||||
// tests/bigfoot_ref_test.fbs): a reference field never requires the
|
||||
// referenced native type to be complete, and the generated header supplies
|
||||
// its own forward declaration plus inline Pack/UnPack definitions, with no
|
||||
// hand-written boilerplate anywhere in this file for `Thing`/`OtherThing`.
|
||||
void BigfootRefTest() {
|
||||
using BigfootRefTestNS::RefHolder;
|
||||
using BigfootRefTestNS::RefHolderT;
|
||||
|
||||
RefHolderT src;
|
||||
src.ref_a = Native::Ref<Native::Thing>(Native::RefId(1));
|
||||
src.ref_a_again.push_back(Native::Ref<Native::Thing>(Native::RefId(2)));
|
||||
src.ref_a_again.push_back(Native::Ref<Native::Thing>(Native::RefId(3)));
|
||||
src.ref_b = Native::Ref<Native::OtherThing>(Native::RefId(4));
|
||||
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
fbb.Finish(RefHolder::Pack(fbb, &src));
|
||||
|
||||
auto dst = BigfootRefTestNS::UnPackRefHolder(fbb.GetBufferPointer());
|
||||
|
||||
TEST_EQ(dst->ref_a.uuid.value, 1u);
|
||||
TEST_EQ(dst->ref_a_again.size(), 2u);
|
||||
TEST_EQ(dst->ref_a_again[0].uuid.value, 2u);
|
||||
TEST_EQ(dst->ref_a_again[1].uuid.value, 3u);
|
||||
TEST_EQ(dst->ref_b.uuid.value, 4u);
|
||||
}
|
||||
|
||||
} // namespace tests
|
||||
} // namespace flatbuffers
|
||||
@@ -0,0 +1,55 @@
|
||||
#ifndef BIGFOOT_REF_TEST_IMPL_H
|
||||
#define BIGFOOT_REF_TEST_IMPL_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace Native {
|
||||
// Stands in for Bigfoot's real UUID.
|
||||
struct RefId {
|
||||
uint64_t value;
|
||||
|
||||
RefId() : value(0) {}
|
||||
explicit RefId(uint64_t _value) : value(_value) {}
|
||||
|
||||
bool operator==(const RefId& other) const { return value == other.value; }
|
||||
};
|
||||
|
||||
// `Thing`/`OtherThing` are intentionally *never* defined anywhere in this
|
||||
// test (see bigfoot_ref_test.fbs) - Ref<T> must compile and round-trip
|
||||
// without T ever being a complete type, exactly like Bigfoot's
|
||||
// HardReference<T>/SoftReference<T>. Their forward declarations are emitted
|
||||
// automatically by flatc (GenerateBigfootRefForwardDecls in
|
||||
// idl_gen_cpp.cpp) directly into bigfoot_ref_test_generated.h - no manual
|
||||
// forward declaration belongs here.
|
||||
|
||||
// The reference-wrapper template `bigfoot_ref_wrapper`/`bigfoot_ref` (see
|
||||
// idl_parser.cpp/idl_gen_cpp.cpp) instantiate per referenced type. Only
|
||||
// needs a `GetUUID()` accessor and a constructor from RefId - never needs T
|
||||
// complete.
|
||||
template <typename T>
|
||||
struct Ref {
|
||||
RefId uuid;
|
||||
|
||||
Ref() : uuid() {}
|
||||
Ref(const RefId& _uuid) : uuid(_uuid) {}
|
||||
|
||||
const RefId& GetUUID() const { return uuid; }
|
||||
|
||||
bool operator==(const Ref& other) const { return uuid == other.uuid; }
|
||||
};
|
||||
} // namespace Native
|
||||
|
||||
namespace BigfootRefTestNS {
|
||||
struct RefId;
|
||||
} // namespace BigfootRefTestNS
|
||||
|
||||
namespace flatbuffers {
|
||||
BigfootRefTestNS::RefId Pack(const Native::RefId& obj);
|
||||
const Native::RefId UnPack(const BigfootRefTestNS::RefId& obj);
|
||||
|
||||
namespace tests {
|
||||
void BigfootRefTest();
|
||||
} // namespace tests
|
||||
} // namespace flatbuffers
|
||||
|
||||
#endif // BIGFOOT_REF_TEST_IMPL_H
|
||||
@@ -20,19 +20,6 @@ table Matrix (native_type:"Native::Matrix") {
|
||||
values:[float];
|
||||
}
|
||||
|
||||
// A struct whose native type is a template, instantiated differently per
|
||||
// field via `native_type_template_arg` instead of needing one flatbuffers
|
||||
// struct declaration per specialization (compare to Vector3D/Vector3DAlt
|
||||
// above).
|
||||
struct Tagged (native_type_template: "Native::Tagged") {
|
||||
value:int32;
|
||||
}
|
||||
|
||||
// A native type template that takes more than one argument.
|
||||
struct Pair (native_type_template: "Native::Pair") {
|
||||
value:int32;
|
||||
}
|
||||
|
||||
table ApplicationData {
|
||||
vectors:[Vector3D];
|
||||
vectors_alt:[Vector3DAlt];
|
||||
@@ -40,9 +27,6 @@ table ApplicationData {
|
||||
position_inline:Vector3D (native_inline);
|
||||
matrix:Matrix;
|
||||
matrices:[Matrix];
|
||||
tagged_a:Tagged (native_inline, native_type_template_arg: "Native::TagA");
|
||||
tagged_b:Tagged (native_inline, native_type_template_arg: "Native::TagB");
|
||||
pair_ab:Pair (native_inline, native_type_template_arg: "Native::TagA, Native::TagB");
|
||||
}
|
||||
|
||||
root_type ApplicationData;
|
||||
|
||||
@@ -24,33 +24,13 @@ struct Vector3DAlt;
|
||||
struct Matrix;
|
||||
struct MatrixBuilder;
|
||||
|
||||
struct Tagged;
|
||||
|
||||
struct Pair;
|
||||
|
||||
struct ApplicationData;
|
||||
struct ApplicationDataBuilder;
|
||||
struct ApplicationDataT;
|
||||
|
||||
bool operator==(const Tagged &lhs, const Tagged &rhs);
|
||||
bool operator!=(const Tagged &lhs, const Tagged &rhs);
|
||||
bool operator==(const Pair &lhs, const Pair &rhs);
|
||||
bool operator!=(const Pair &lhs, const Pair &rhs);
|
||||
bool operator==(const ApplicationDataT &lhs, const ApplicationDataT &rhs);
|
||||
bool operator!=(const ApplicationDataT &lhs, const ApplicationDataT &rhs);
|
||||
|
||||
inline const ::flatbuffers::TypeTable *Vector3DTypeTable();
|
||||
|
||||
inline const ::flatbuffers::TypeTable *Vector3DAltTypeTable();
|
||||
|
||||
inline const ::flatbuffers::TypeTable *MatrixTypeTable();
|
||||
|
||||
inline const ::flatbuffers::TypeTable *TaggedTypeTable();
|
||||
|
||||
inline const ::flatbuffers::TypeTable *PairTypeTable();
|
||||
|
||||
inline const ::flatbuffers::TypeTable *ApplicationDataTypeTable();
|
||||
|
||||
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Vector3D FLATBUFFERS_FINAL_CLASS {
|
||||
private:
|
||||
float x_;
|
||||
@@ -58,9 +38,7 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Vector3D FLATBUFFERS_FINAL_CLASS {
|
||||
float z_;
|
||||
|
||||
public:
|
||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return Vector3DTypeTable();
|
||||
}
|
||||
struct Traits;
|
||||
Vector3D()
|
||||
: x_(0),
|
||||
y_(0),
|
||||
@@ -74,24 +52,19 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Vector3D FLATBUFFERS_FINAL_CLASS {
|
||||
float x() const {
|
||||
return ::flatbuffers::EndianScalar(x_);
|
||||
}
|
||||
void mutate_x(float _x) {
|
||||
::flatbuffers::WriteScalar(&x_, _x);
|
||||
}
|
||||
float y() const {
|
||||
return ::flatbuffers::EndianScalar(y_);
|
||||
}
|
||||
void mutate_y(float _y) {
|
||||
::flatbuffers::WriteScalar(&y_, _y);
|
||||
}
|
||||
float z() const {
|
||||
return ::flatbuffers::EndianScalar(z_);
|
||||
}
|
||||
void mutate_z(float _z) {
|
||||
::flatbuffers::WriteScalar(&z_, _z);
|
||||
}
|
||||
};
|
||||
FLATBUFFERS_STRUCT_END(Vector3D, 12);
|
||||
|
||||
struct Vector3D::Traits {
|
||||
using type = Vector3D;
|
||||
};
|
||||
|
||||
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Vector3DAlt FLATBUFFERS_FINAL_CLASS {
|
||||
private:
|
||||
float a_;
|
||||
@@ -99,9 +72,7 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Vector3DAlt FLATBUFFERS_FINAL_CLASS {
|
||||
float c_;
|
||||
|
||||
public:
|
||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return Vector3DAltTypeTable();
|
||||
}
|
||||
struct Traits;
|
||||
Vector3DAlt()
|
||||
: a_(0),
|
||||
b_(0),
|
||||
@@ -115,96 +86,23 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Vector3DAlt FLATBUFFERS_FINAL_CLASS {
|
||||
float a() const {
|
||||
return ::flatbuffers::EndianScalar(a_);
|
||||
}
|
||||
void mutate_a(float _a) {
|
||||
::flatbuffers::WriteScalar(&a_, _a);
|
||||
}
|
||||
float b() const {
|
||||
return ::flatbuffers::EndianScalar(b_);
|
||||
}
|
||||
void mutate_b(float _b) {
|
||||
::flatbuffers::WriteScalar(&b_, _b);
|
||||
}
|
||||
float c() const {
|
||||
return ::flatbuffers::EndianScalar(c_);
|
||||
}
|
||||
void mutate_c(float _c) {
|
||||
::flatbuffers::WriteScalar(&c_, _c);
|
||||
}
|
||||
};
|
||||
FLATBUFFERS_STRUCT_END(Vector3DAlt, 12);
|
||||
|
||||
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Tagged FLATBUFFERS_FINAL_CLASS {
|
||||
private:
|
||||
int32_t value_;
|
||||
|
||||
public:
|
||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return TaggedTypeTable();
|
||||
}
|
||||
Tagged()
|
||||
: value_(0) {
|
||||
}
|
||||
Tagged(int32_t _value)
|
||||
: value_(::flatbuffers::EndianScalar(_value)) {
|
||||
}
|
||||
int32_t value() const {
|
||||
return ::flatbuffers::EndianScalar(value_);
|
||||
}
|
||||
void mutate_value(int32_t _value) {
|
||||
::flatbuffers::WriteScalar(&value_, _value);
|
||||
}
|
||||
struct Vector3DAlt::Traits {
|
||||
using type = Vector3DAlt;
|
||||
};
|
||||
FLATBUFFERS_STRUCT_END(Tagged, 4);
|
||||
|
||||
inline bool operator==(const Tagged &lhs, const Tagged &rhs) {
|
||||
return
|
||||
(lhs.value() == rhs.value());
|
||||
}
|
||||
|
||||
inline bool operator!=(const Tagged &lhs, const Tagged &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
|
||||
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Pair FLATBUFFERS_FINAL_CLASS {
|
||||
private:
|
||||
int32_t value_;
|
||||
|
||||
public:
|
||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return PairTypeTable();
|
||||
}
|
||||
Pair()
|
||||
: value_(0) {
|
||||
}
|
||||
Pair(int32_t _value)
|
||||
: value_(::flatbuffers::EndianScalar(_value)) {
|
||||
}
|
||||
int32_t value() const {
|
||||
return ::flatbuffers::EndianScalar(value_);
|
||||
}
|
||||
void mutate_value(int32_t _value) {
|
||||
::flatbuffers::WriteScalar(&value_, _value);
|
||||
}
|
||||
};
|
||||
FLATBUFFERS_STRUCT_END(Pair, 4);
|
||||
|
||||
inline bool operator==(const Pair &lhs, const Pair &rhs) {
|
||||
return
|
||||
(lhs.value() == rhs.value());
|
||||
}
|
||||
|
||||
inline bool operator!=(const Pair &lhs, const Pair &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
|
||||
struct Matrix FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef Native::Matrix NativeTableType;
|
||||
typedef MatrixBuilder Builder;
|
||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return MatrixTypeTable();
|
||||
}
|
||||
struct Traits;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_ROWS = 4,
|
||||
VT_COLUMNS = 6,
|
||||
@@ -213,21 +111,12 @@ struct Matrix FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
int32_t rows() const {
|
||||
return GetField<int32_t>(VT_ROWS, 0);
|
||||
}
|
||||
bool mutate_rows(int32_t _rows = 0) {
|
||||
return SetField<int32_t>(VT_ROWS, _rows, 0);
|
||||
}
|
||||
int32_t columns() const {
|
||||
return GetField<int32_t>(VT_COLUMNS, 0);
|
||||
}
|
||||
bool mutate_columns(int32_t _columns = 0) {
|
||||
return SetField<int32_t>(VT_COLUMNS, _columns, 0);
|
||||
}
|
||||
const ::flatbuffers::Vector<float> *values() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<float> *>(VT_VALUES);
|
||||
}
|
||||
::flatbuffers::Vector<float> *mutable_values() {
|
||||
return GetPointer<::flatbuffers::Vector<float> *>(VT_VALUES);
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
@@ -278,6 +167,11 @@ inline ::flatbuffers::Offset<Matrix> CreateMatrix(
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct Matrix::Traits {
|
||||
using type = Matrix;
|
||||
static auto constexpr Create = CreateMatrix;
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<Matrix> CreateMatrixDirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t rows = 0,
|
||||
@@ -301,9 +195,6 @@ struct ApplicationDataT : public ::flatbuffers::NativeTable {
|
||||
Native::Vector3D position_inline{};
|
||||
std::unique_ptr<Native::Matrix> matrix{};
|
||||
std::vector<std::unique_ptr<Native::Matrix>> matrices{};
|
||||
Native::Tagged<Native::TagA> tagged_a{};
|
||||
Native::Tagged<Native::TagB> tagged_b{};
|
||||
Native::Pair<Native::TagA, Native::TagB> pair_ab{};
|
||||
ApplicationDataT() = default;
|
||||
ApplicationDataT(const ApplicationDataT &o);
|
||||
ApplicationDataT(ApplicationDataT&&) FLATBUFFERS_NOEXCEPT = default;
|
||||
@@ -313,74 +204,33 @@ struct ApplicationDataT : public ::flatbuffers::NativeTable {
|
||||
struct ApplicationData FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef ApplicationDataT NativeTableType;
|
||||
typedef ApplicationDataBuilder Builder;
|
||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return ApplicationDataTypeTable();
|
||||
}
|
||||
struct Traits;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_VECTORS = 4,
|
||||
VT_VECTORS_ALT = 6,
|
||||
VT_POSITION = 8,
|
||||
VT_POSITION_INLINE = 10,
|
||||
VT_MATRIX = 12,
|
||||
VT_MATRICES = 14,
|
||||
VT_TAGGED_A = 16,
|
||||
VT_TAGGED_B = 18,
|
||||
VT_PAIR_AB = 20
|
||||
VT_MATRICES = 14
|
||||
};
|
||||
const ::flatbuffers::Vector<const Geometry::Vector3D *> *vectors() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<const Geometry::Vector3D *> *>(VT_VECTORS);
|
||||
}
|
||||
::flatbuffers::Vector<const Geometry::Vector3D *> *mutable_vectors() {
|
||||
return GetPointer<::flatbuffers::Vector<const Geometry::Vector3D *> *>(VT_VECTORS);
|
||||
}
|
||||
const ::flatbuffers::Vector<const Geometry::Vector3DAlt *> *vectors_alt() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<const Geometry::Vector3DAlt *> *>(VT_VECTORS_ALT);
|
||||
}
|
||||
::flatbuffers::Vector<const Geometry::Vector3DAlt *> *mutable_vectors_alt() {
|
||||
return GetPointer<::flatbuffers::Vector<const Geometry::Vector3DAlt *> *>(VT_VECTORS_ALT);
|
||||
}
|
||||
const Geometry::Vector3D *position() const {
|
||||
return GetStruct<const Geometry::Vector3D *>(VT_POSITION);
|
||||
}
|
||||
Geometry::Vector3D *mutable_position() {
|
||||
return GetStruct<Geometry::Vector3D *>(VT_POSITION);
|
||||
}
|
||||
const Geometry::Vector3D *position_inline() const {
|
||||
return GetStruct<const Geometry::Vector3D *>(VT_POSITION_INLINE);
|
||||
}
|
||||
Geometry::Vector3D *mutable_position_inline() {
|
||||
return GetStruct<Geometry::Vector3D *>(VT_POSITION_INLINE);
|
||||
}
|
||||
const Geometry::Matrix *matrix() const {
|
||||
return GetPointer<const Geometry::Matrix *>(VT_MATRIX);
|
||||
}
|
||||
Geometry::Matrix *mutable_matrix() {
|
||||
return GetPointer<Geometry::Matrix *>(VT_MATRIX);
|
||||
}
|
||||
const ::flatbuffers::Vector<::flatbuffers::Offset<Geometry::Matrix>> *matrices() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<Geometry::Matrix>> *>(VT_MATRICES);
|
||||
}
|
||||
::flatbuffers::Vector<::flatbuffers::Offset<Geometry::Matrix>> *mutable_matrices() {
|
||||
return GetPointer<::flatbuffers::Vector<::flatbuffers::Offset<Geometry::Matrix>> *>(VT_MATRICES);
|
||||
}
|
||||
const Geometry::Tagged *tagged_a() const {
|
||||
return GetStruct<const Geometry::Tagged *>(VT_TAGGED_A);
|
||||
}
|
||||
Geometry::Tagged *mutable_tagged_a() {
|
||||
return GetStruct<Geometry::Tagged *>(VT_TAGGED_A);
|
||||
}
|
||||
const Geometry::Tagged *tagged_b() const {
|
||||
return GetStruct<const Geometry::Tagged *>(VT_TAGGED_B);
|
||||
}
|
||||
Geometry::Tagged *mutable_tagged_b() {
|
||||
return GetStruct<Geometry::Tagged *>(VT_TAGGED_B);
|
||||
}
|
||||
const Geometry::Pair *pair_ab() const {
|
||||
return GetStruct<const Geometry::Pair *>(VT_PAIR_AB);
|
||||
}
|
||||
Geometry::Pair *mutable_pair_ab() {
|
||||
return GetStruct<Geometry::Pair *>(VT_PAIR_AB);
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
@@ -395,9 +245,6 @@ struct ApplicationData FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
VerifyOffset(verifier, VT_MATRICES) &&
|
||||
verifier.VerifyVector(matrices()) &&
|
||||
verifier.VerifyVectorOfTables(matrices()) &&
|
||||
VerifyField<Geometry::Tagged>(verifier, VT_TAGGED_A, 4) &&
|
||||
VerifyField<Geometry::Tagged>(verifier, VT_TAGGED_B, 4) &&
|
||||
VerifyField<Geometry::Pair>(verifier, VT_PAIR_AB, 4) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
ApplicationDataT *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
@@ -427,15 +274,6 @@ struct ApplicationDataBuilder {
|
||||
void add_matrices(::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<Geometry::Matrix>>> matrices) {
|
||||
fbb_.AddOffset(ApplicationData::VT_MATRICES, matrices);
|
||||
}
|
||||
void add_tagged_a(const Geometry::Tagged *tagged_a) {
|
||||
fbb_.AddStruct(ApplicationData::VT_TAGGED_A, tagged_a);
|
||||
}
|
||||
void add_tagged_b(const Geometry::Tagged *tagged_b) {
|
||||
fbb_.AddStruct(ApplicationData::VT_TAGGED_B, tagged_b);
|
||||
}
|
||||
void add_pair_ab(const Geometry::Pair *pair_ab) {
|
||||
fbb_.AddStruct(ApplicationData::VT_PAIR_AB, pair_ab);
|
||||
}
|
||||
explicit ApplicationDataBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
@@ -454,14 +292,8 @@ inline ::flatbuffers::Offset<ApplicationData> CreateApplicationData(
|
||||
const Geometry::Vector3D *position = nullptr,
|
||||
const Geometry::Vector3D *position_inline = nullptr,
|
||||
::flatbuffers::Offset<Geometry::Matrix> matrix = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<Geometry::Matrix>>> matrices = 0,
|
||||
const Geometry::Tagged *tagged_a = nullptr,
|
||||
const Geometry::Tagged *tagged_b = nullptr,
|
||||
const Geometry::Pair *pair_ab = nullptr) {
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<Geometry::Matrix>>> matrices = 0) {
|
||||
ApplicationDataBuilder builder_(_fbb);
|
||||
builder_.add_pair_ab(pair_ab);
|
||||
builder_.add_tagged_b(tagged_b);
|
||||
builder_.add_tagged_a(tagged_a);
|
||||
builder_.add_matrices(matrices);
|
||||
builder_.add_matrix(matrix);
|
||||
builder_.add_position_inline(position_inline);
|
||||
@@ -471,6 +303,11 @@ inline ::flatbuffers::Offset<ApplicationData> CreateApplicationData(
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct ApplicationData::Traits {
|
||||
using type = ApplicationData;
|
||||
static auto constexpr Create = CreateApplicationData;
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<ApplicationData> CreateApplicationDataDirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
const std::vector<Geometry::Vector3D> *vectors = nullptr,
|
||||
@@ -478,10 +315,7 @@ inline ::flatbuffers::Offset<ApplicationData> CreateApplicationDataDirect(
|
||||
const Geometry::Vector3D *position = nullptr,
|
||||
const Geometry::Vector3D *position_inline = nullptr,
|
||||
::flatbuffers::Offset<Geometry::Matrix> matrix = 0,
|
||||
const std::vector<::flatbuffers::Offset<Geometry::Matrix>> *matrices = nullptr,
|
||||
const Geometry::Tagged *tagged_a = nullptr,
|
||||
const Geometry::Tagged *tagged_b = nullptr,
|
||||
const Geometry::Pair *pair_ab = nullptr) {
|
||||
const std::vector<::flatbuffers::Offset<Geometry::Matrix>> *matrices = nullptr) {
|
||||
auto vectors__ = vectors ? _fbb.CreateVectorOfStructs<Geometry::Vector3D>(*vectors) : 0;
|
||||
auto vectors_alt__ = vectors_alt ? _fbb.CreateVectorOfStructs<Geometry::Vector3DAlt>(*vectors_alt) : 0;
|
||||
auto matrices__ = matrices ? _fbb.CreateVector<::flatbuffers::Offset<Geometry::Matrix>>(*matrices) : 0;
|
||||
@@ -492,16 +326,13 @@ inline ::flatbuffers::Offset<ApplicationData> CreateApplicationDataDirect(
|
||||
position,
|
||||
position_inline,
|
||||
matrix,
|
||||
matrices__,
|
||||
tagged_a,
|
||||
tagged_b,
|
||||
pair_ab);
|
||||
matrices__);
|
||||
}
|
||||
|
||||
::flatbuffers::Offset<ApplicationData> CreateApplicationData(::flatbuffers::FlatBufferBuilder &_fbb, const ApplicationDataT *_o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
|
||||
inline Native::Matrix *Matrix::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
auto _o = std::unique_ptr<Native::Matrix>(new Native::Matrix());
|
||||
auto _o = std::make_unique<Native::Matrix>();
|
||||
UnPackTo(_o.get(), _resolver);
|
||||
return _o.release();
|
||||
}
|
||||
@@ -518,10 +349,7 @@ inline bool operator==(const ApplicationDataT &lhs, const ApplicationDataT &rhs)
|
||||
((lhs.position == rhs.position) || (lhs.position && rhs.position && *lhs.position == *rhs.position)) &&
|
||||
(lhs.position_inline == rhs.position_inline) &&
|
||||
((lhs.matrix == rhs.matrix) || (lhs.matrix && rhs.matrix && *lhs.matrix == *rhs.matrix)) &&
|
||||
(lhs.matrices.size() == rhs.matrices.size() && std::equal(lhs.matrices.cbegin(), lhs.matrices.cend(), rhs.matrices.cbegin(), [](std::unique_ptr<Native::Matrix> const &a, std::unique_ptr<Native::Matrix> const &b) { return (a == b) || (a && b && *a == *b); })) &&
|
||||
(lhs.tagged_a == rhs.tagged_a) &&
|
||||
(lhs.tagged_b == rhs.tagged_b) &&
|
||||
(lhs.pair_ab == rhs.pair_ab);
|
||||
(lhs.matrices.size() == rhs.matrices.size() && std::equal(lhs.matrices.cbegin(), lhs.matrices.cend(), rhs.matrices.cbegin(), [](std::unique_ptr<Native::Matrix> const &a, std::unique_ptr<Native::Matrix> const &b) { return (a == b) || (a && b && *a == *b); }));
|
||||
}
|
||||
|
||||
inline bool operator!=(const ApplicationDataT &lhs, const ApplicationDataT &rhs) {
|
||||
@@ -534,10 +362,7 @@ inline ApplicationDataT::ApplicationDataT(const ApplicationDataT &o)
|
||||
vectors_alt(o.vectors_alt),
|
||||
position((o.position) ? new Native::Vector3D(*o.position) : nullptr),
|
||||
position_inline(o.position_inline),
|
||||
matrix((o.matrix) ? new Native::Matrix(*o.matrix) : nullptr),
|
||||
tagged_a(o.tagged_a),
|
||||
tagged_b(o.tagged_b),
|
||||
pair_ab(o.pair_ab) {
|
||||
matrix((o.matrix) ? new Native::Matrix(*o.matrix) : nullptr) {
|
||||
matrices.reserve(o.matrices.size());
|
||||
for (const auto &matrices_ : o.matrices) { matrices.emplace_back((matrices_) ? new Native::Matrix(*matrices_) : nullptr); }
|
||||
}
|
||||
@@ -549,14 +374,11 @@ inline ApplicationDataT &ApplicationDataT::operator=(ApplicationDataT o) FLATBUF
|
||||
std::swap(position_inline, o.position_inline);
|
||||
std::swap(matrix, o.matrix);
|
||||
std::swap(matrices, o.matrices);
|
||||
std::swap(tagged_a, o.tagged_a);
|
||||
std::swap(tagged_b, o.tagged_b);
|
||||
std::swap(pair_ab, o.pair_ab);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline ApplicationDataT *ApplicationData::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
auto _o = std::unique_ptr<ApplicationDataT>(new ApplicationDataT());
|
||||
auto _o = std::make_unique<ApplicationDataT>();
|
||||
UnPackTo(_o.get(), _resolver);
|
||||
return _o.release();
|
||||
}
|
||||
@@ -570,9 +392,6 @@ inline void ApplicationData::UnPackTo(ApplicationDataT *_o, const ::flatbuffers:
|
||||
{ auto _e = position_inline(); if (_e) _o->position_inline = ::flatbuffers::UnPack(*_e); }
|
||||
{ auto _e = matrix(); if (_e) { if(_o->matrix) { _e->UnPackTo(_o->matrix.get(), _resolver); } else { _o->matrix = std::unique_ptr<Native::Matrix>(_e->UnPack(_resolver)); } } else if (_o->matrix) { _o->matrix.reset(); } }
|
||||
{ auto _e = matrices(); if (_e) { _o->matrices.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->matrices[_i]) { _e->Get(_i)->UnPackTo(_o->matrices[_i].get(), _resolver); } else { _o->matrices[_i] = std::unique_ptr<Native::Matrix>(_e->Get(_i)->UnPack(_resolver)); } } } else { _o->matrices.resize(0); } }
|
||||
{ auto _e = tagged_a(); if (_e) _o->tagged_a = ::flatbuffers::UnPackTaggedTagA(*_e); }
|
||||
{ auto _e = tagged_b(); if (_e) _o->tagged_b = ::flatbuffers::UnPackTaggedTagB(*_e); }
|
||||
{ auto _e = pair_ab(); if (_e) _o->pair_ab = ::flatbuffers::UnPackPairTagATagB(*_e); }
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<ApplicationData> CreateApplicationData(::flatbuffers::FlatBufferBuilder &_fbb, const ApplicationDataT *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
@@ -589,9 +408,6 @@ inline ::flatbuffers::Offset<ApplicationData> ApplicationData::Pack(::flatbuffer
|
||||
auto _position_inline = ::flatbuffers::Pack(_o->position_inline);
|
||||
auto _matrix = _o->matrix ? CreateMatrix(_fbb, _o->matrix.get(), _rehasher) : 0;
|
||||
auto _matrices = _o->matrices.size() ? _fbb.CreateVector<::flatbuffers::Offset<Geometry::Matrix>> (_o->matrices.size(), [](size_t i, _VectorArgs *__va) { return CreateMatrix(*__va->__fbb, __va->__o->matrices[i].get(), __va->__rehasher); }, &_va ) : 0;
|
||||
auto _tagged_a = ::flatbuffers::PackTaggedTagA(_o->tagged_a);
|
||||
auto _tagged_b = ::flatbuffers::PackTaggedTagB(_o->tagged_b);
|
||||
auto _pair_ab = ::flatbuffers::PackPairTagATagB(_o->pair_ab);
|
||||
return Geometry::CreateApplicationData(
|
||||
_fbb,
|
||||
_vectors,
|
||||
@@ -599,127 +415,7 @@ inline ::flatbuffers::Offset<ApplicationData> ApplicationData::Pack(::flatbuffer
|
||||
_o->position ? &_position : nullptr,
|
||||
&_position_inline,
|
||||
_matrix,
|
||||
_matrices,
|
||||
&_tagged_a,
|
||||
&_tagged_b,
|
||||
&_pair_ab);
|
||||
}
|
||||
|
||||
inline const ::flatbuffers::TypeTable *Vector3DTypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_FLOAT, 0, -1 },
|
||||
{ ::flatbuffers::ET_FLOAT, 0, -1 },
|
||||
{ ::flatbuffers::ET_FLOAT, 0, -1 }
|
||||
};
|
||||
static const int64_t values[] = { 0, 4, 8, 12 };
|
||||
static const char * const names[] = {
|
||||
"x",
|
||||
"y",
|
||||
"z"
|
||||
};
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_STRUCT, 3, type_codes, nullptr, nullptr, values, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
inline const ::flatbuffers::TypeTable *Vector3DAltTypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_FLOAT, 0, -1 },
|
||||
{ ::flatbuffers::ET_FLOAT, 0, -1 },
|
||||
{ ::flatbuffers::ET_FLOAT, 0, -1 }
|
||||
};
|
||||
static const int64_t values[] = { 0, 4, 8, 12 };
|
||||
static const char * const names[] = {
|
||||
"a",
|
||||
"b",
|
||||
"c"
|
||||
};
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_STRUCT, 3, type_codes, nullptr, nullptr, values, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
inline const ::flatbuffers::TypeTable *MatrixTypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_INT, 0, -1 },
|
||||
{ ::flatbuffers::ET_INT, 0, -1 },
|
||||
{ ::flatbuffers::ET_FLOAT, 1, -1 }
|
||||
};
|
||||
static const char * const names[] = {
|
||||
"rows",
|
||||
"columns",
|
||||
"values"
|
||||
};
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_TABLE, 3, type_codes, nullptr, nullptr, nullptr, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
inline const ::flatbuffers::TypeTable *TaggedTypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_INT, 0, -1 }
|
||||
};
|
||||
static const int64_t values[] = { 0, 4 };
|
||||
static const char * const names[] = {
|
||||
"value"
|
||||
};
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_STRUCT, 1, type_codes, nullptr, nullptr, values, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
inline const ::flatbuffers::TypeTable *PairTypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_INT, 0, -1 }
|
||||
};
|
||||
static const int64_t values[] = { 0, 4 };
|
||||
static const char * const names[] = {
|
||||
"value"
|
||||
};
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_STRUCT, 1, type_codes, nullptr, nullptr, values, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
inline const ::flatbuffers::TypeTable *ApplicationDataTypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_SEQUENCE, 1, 0 },
|
||||
{ ::flatbuffers::ET_SEQUENCE, 1, 1 },
|
||||
{ ::flatbuffers::ET_SEQUENCE, 0, 0 },
|
||||
{ ::flatbuffers::ET_SEQUENCE, 0, 0 },
|
||||
{ ::flatbuffers::ET_SEQUENCE, 0, 2 },
|
||||
{ ::flatbuffers::ET_SEQUENCE, 1, 2 },
|
||||
{ ::flatbuffers::ET_SEQUENCE, 0, 3 },
|
||||
{ ::flatbuffers::ET_SEQUENCE, 0, 3 },
|
||||
{ ::flatbuffers::ET_SEQUENCE, 0, 4 }
|
||||
};
|
||||
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||
Geometry::Vector3DTypeTable,
|
||||
Geometry::Vector3DAltTypeTable,
|
||||
Geometry::MatrixTypeTable,
|
||||
Geometry::TaggedTypeTable,
|
||||
Geometry::PairTypeTable
|
||||
};
|
||||
static const char * const names[] = {
|
||||
"vectors",
|
||||
"vectors_alt",
|
||||
"position",
|
||||
"position_inline",
|
||||
"matrix",
|
||||
"matrices",
|
||||
"tagged_a",
|
||||
"tagged_b",
|
||||
"pair_ab"
|
||||
};
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_TABLE, 9, type_codes, type_refs, nullptr, nullptr, names
|
||||
};
|
||||
return &tt;
|
||||
_matrices);
|
||||
}
|
||||
|
||||
inline const Geometry::ApplicationData *GetApplicationData(const void *buf) {
|
||||
@@ -730,14 +426,6 @@ inline const Geometry::ApplicationData *GetSizePrefixedApplicationData(const voi
|
||||
return ::flatbuffers::GetSizePrefixedRoot<Geometry::ApplicationData>(buf);
|
||||
}
|
||||
|
||||
inline ApplicationData *GetMutableApplicationData(void *buf) {
|
||||
return ::flatbuffers::GetMutableRoot<ApplicationData>(buf);
|
||||
}
|
||||
|
||||
inline Geometry::ApplicationData *GetMutableSizePrefixedApplicationData(void *buf) {
|
||||
return ::flatbuffers::GetMutableSizePrefixedRoot<Geometry::ApplicationData>(buf);
|
||||
}
|
||||
|
||||
template <bool B = false>
|
||||
inline bool VerifyApplicationDataBuffer(
|
||||
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||
@@ -750,6 +438,10 @@ inline bool VerifySizePrefixedApplicationDataBuffer(
|
||||
return verifier.template VerifySizePrefixedBuffer<Geometry::ApplicationData>(nullptr);
|
||||
}
|
||||
|
||||
inline const char *ApplicationDataExtension() {
|
||||
return "bfbs";
|
||||
}
|
||||
|
||||
inline void FinishApplicationDataBuffer(
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<Geometry::ApplicationData> root) {
|
||||
|
||||
@@ -18,34 +18,6 @@ Geometry::Vector3DAlt PackVector3DAlt(const Native::Vector3D& obj) {
|
||||
const Native::Vector3D UnPackVector3DAlt(const Geometry::Vector3DAlt& obj) {
|
||||
return Native::Vector3D(obj.a(), obj.b(), obj.c());
|
||||
}
|
||||
|
||||
Geometry::Tagged PackTaggedTagA(const Native::Tagged<Native::TagA>& obj) {
|
||||
return Geometry::Tagged(obj.value);
|
||||
}
|
||||
|
||||
const Native::Tagged<Native::TagA> UnPackTaggedTagA(
|
||||
const Geometry::Tagged& obj) {
|
||||
return Native::Tagged<Native::TagA>(obj.value());
|
||||
}
|
||||
|
||||
Geometry::Tagged PackTaggedTagB(const Native::Tagged<Native::TagB>& obj) {
|
||||
return Geometry::Tagged(obj.value);
|
||||
}
|
||||
|
||||
const Native::Tagged<Native::TagB> UnPackTaggedTagB(
|
||||
const Geometry::Tagged& obj) {
|
||||
return Native::Tagged<Native::TagB>(obj.value());
|
||||
}
|
||||
|
||||
Geometry::Pair PackPairTagATagB(
|
||||
const Native::Pair<Native::TagA, Native::TagB>& obj) {
|
||||
return Geometry::Pair(obj.value);
|
||||
}
|
||||
|
||||
const Native::Pair<Native::TagA, Native::TagB> UnPackPairTagATagB(
|
||||
const Geometry::Pair& obj) {
|
||||
return Native::Pair<Native::TagA, Native::TagB>(obj.value());
|
||||
}
|
||||
} // namespace flatbuffers
|
||||
|
||||
namespace Geometry {
|
||||
|
||||
@@ -44,41 +44,11 @@ struct Matrix {
|
||||
}
|
||||
};
|
||||
|
||||
// Phantom tag types used purely to select a template specialization; they
|
||||
// carry no data of their own.
|
||||
struct TagA {};
|
||||
struct TagB {};
|
||||
|
||||
// A native type template, instantiated per-field in the schema via
|
||||
// `native_type_template_arg` rather than needing one flatbuffers struct
|
||||
// declaration per specialization.
|
||||
template <typename T>
|
||||
struct Tagged {
|
||||
int32_t value;
|
||||
|
||||
Tagged() : value(0) {}
|
||||
explicit Tagged(int32_t _value) : value(_value) {}
|
||||
|
||||
bool operator==(const Tagged& other) const { return value == other.value; }
|
||||
};
|
||||
|
||||
// A native type template taking more than one argument.
|
||||
template <typename T0, typename T1>
|
||||
struct Pair {
|
||||
int32_t value;
|
||||
|
||||
Pair() : value(0) {}
|
||||
explicit Pair(int32_t _value) : value(_value) {}
|
||||
|
||||
bool operator==(const Pair& other) const { return value == other.value; }
|
||||
};
|
||||
} // namespace Native
|
||||
|
||||
namespace Geometry {
|
||||
struct Vector3D;
|
||||
struct Vector3DAlt;
|
||||
struct Tagged;
|
||||
struct Pair;
|
||||
} // namespace Geometry
|
||||
|
||||
namespace flatbuffers {
|
||||
@@ -86,16 +56,6 @@ Geometry::Vector3D Pack(const Native::Vector3D& obj);
|
||||
const Native::Vector3D UnPack(const Geometry::Vector3D& obj);
|
||||
Geometry::Vector3DAlt PackVector3DAlt(const Native::Vector3D& obj);
|
||||
const Native::Vector3D UnPackVector3DAlt(const Geometry::Vector3DAlt& obj);
|
||||
|
||||
Geometry::Tagged PackTaggedTagA(const Native::Tagged<Native::TagA>& obj);
|
||||
const Native::Tagged<Native::TagA> UnPackTaggedTagA(const Geometry::Tagged& obj);
|
||||
Geometry::Tagged PackTaggedTagB(const Native::Tagged<Native::TagB>& obj);
|
||||
const Native::Tagged<Native::TagB> UnPackTaggedTagB(const Geometry::Tagged& obj);
|
||||
|
||||
Geometry::Pair PackPairTagATagB(
|
||||
const Native::Pair<Native::TagA, Native::TagB>& obj);
|
||||
const Native::Pair<Native::TagA, Native::TagB> UnPackPairTagATagB(
|
||||
const Geometry::Pair& obj);
|
||||
} // namespace flatbuffers
|
||||
|
||||
#endif // VECTOR3D_PACK_H
|
||||
|
||||
@@ -98,16 +98,16 @@ void ErrorTest() {
|
||||
TestError("struct X (force_align: 7) { Y:int; }", "force_align");
|
||||
TestError("struct X {}", "size 0");
|
||||
TestError(
|
||||
"struct X { Y:int; } table T { y:X (native_type_template_arg:\"int\"); "
|
||||
"struct X { Y:int; } table T { y:X (bigfoot_ref:\"::Foo::Bar\"); "
|
||||
"}",
|
||||
"'native_type_template' attribute");
|
||||
"'bigfoot_ref_wrapper' attribute");
|
||||
TestError(
|
||||
"table T { y:int (native_type_template_arg:\"int\"); }",
|
||||
"table T { y:int (bigfoot_ref:\"::Foo::Bar\"); }",
|
||||
"struct-typed fields");
|
||||
TestError(
|
||||
"struct X (native_type_template: \"Foo\") { Y:int; } "
|
||||
"table T { y:X (native_type_template_arg:\"\"); }",
|
||||
"empty template argument");
|
||||
"struct X (bigfoot_ref_wrapper: \"Foo\") { Y:int; } "
|
||||
"table T { y:X (bigfoot_ref:\"\"); }",
|
||||
"cannot be empty");
|
||||
TestError("{}", "no root");
|
||||
TestError("table X { Y:byte; } root_type X; { Y:1 } { Y:1 }", "end of file");
|
||||
TestError("table X { Y:byte; } root_type X; { Y:1 } table Y{ Z:int }",
|
||||
|
||||
+2
-8
@@ -67,6 +67,7 @@
|
||||
#include "test_assert.h"
|
||||
#include "util_test.h"
|
||||
#include "cpp_vector_type_test.h"
|
||||
#include "bigfoot_ref_test_impl.h"
|
||||
#include "vector_table_naked_ptr_test.h"
|
||||
|
||||
void FlatBufferBuilderTest();
|
||||
@@ -930,10 +931,6 @@ void NativeTypeTest() {
|
||||
Native::Vector3D(20 * i + 0.1f, 20 * i + 0.2f, 20 * i + 0.3f));
|
||||
}
|
||||
|
||||
src_data.tagged_a = Native::Tagged<Native::TagA>(7);
|
||||
src_data.tagged_b = Native::Tagged<Native::TagB>(8);
|
||||
src_data.pair_ab = Native::Pair<Native::TagA, Native::TagB>(9);
|
||||
|
||||
src_data.matrix = std::unique_ptr<Native::Matrix>(new Native::Matrix(1, 2));
|
||||
src_data.matrix->values = {3, 4};
|
||||
|
||||
@@ -955,10 +952,6 @@ void NativeTypeTest() {
|
||||
TEST_EQ(dstDataT->position_inline.x, 4.0f);
|
||||
TEST_EQ(dstDataT->position_inline.y, 5.0f);
|
||||
TEST_EQ(dstDataT->position_inline.z, 6.0f);
|
||||
TEST_EQ(dstDataT->tagged_a.value, 7);
|
||||
TEST_EQ(dstDataT->tagged_b.value, 8);
|
||||
TEST_EQ(dstDataT->pair_ab.value, 9);
|
||||
|
||||
for (int i = 0; i < N; ++i) {
|
||||
const Native::Vector3D& v = dstDataT->vectors[i];
|
||||
TEST_EQ(v.x, 10 * i + 0.1f);
|
||||
@@ -1823,6 +1816,7 @@ int FlatBufferTests(const std::string& tests_data_path) {
|
||||
InvalidFloatTest();
|
||||
FixedLengthArrayTest();
|
||||
NativeTypeTest();
|
||||
flatbuffers::tests::BigfootRefTest();
|
||||
OptionalScalarsTest();
|
||||
ParseFlexbuffersFromJsonWithNullTest();
|
||||
FlatbuffersSpanTest();
|
||||
|
||||
Reference in New Issue
Block a user