forked from BigfootDev/flatbuffers
56 lines
1.6 KiB
C++
56 lines
1.6 KiB
C++
#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
|