forked from BigfootDev/flatbuffers
Compare commits
21 Commits
push-qpplq
...
bigfoot
| Author | SHA1 | Date | |
|---|---|---|---|
| 505ec2fb6a | |||
| 19aa2ce420 | |||
| 35665b5ae7 | |||
| 9e9f5bbfcf | |||
| 4edfa03ffc | |||
|
|
03fffb25e2 | ||
|
|
1a7495a6dd | ||
|
|
3c1bb67ae1 | ||
|
|
5b9de8b6c0 | ||
|
|
ea0a73d168 | ||
|
|
4623cfa4bc | ||
|
|
9c2c56dc6a | ||
|
|
429c28c783 | ||
|
|
e5a9ff757f | ||
|
|
e53732b9b9 | ||
|
|
b84b676c89 | ||
|
|
3211f857d1 | ||
|
|
95ff1f1d80 | ||
|
|
af8997b567 | ||
|
|
0d67abde45 | ||
|
|
d74e2945f7 |
10
.github/workflows/build.yml
vendored
10
.github/workflows/build.yml
vendored
@@ -197,8 +197,7 @@ jobs:
|
||||
configuration: [
|
||||
'',
|
||||
'-p:UnsafeByteBuffer=true',
|
||||
# Fails two tests currently.
|
||||
#'-p:EnableSpanT=true,UnsafeByteBuffer=true'
|
||||
'-p:EnableSpanT=true,UnsafeByteBuffer=true'
|
||||
]
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
@@ -209,7 +208,7 @@ jobs:
|
||||
- name: Build
|
||||
run: |
|
||||
cd tests\FlatBuffers.Test
|
||||
dotnet new sln --force --name FlatBuffers.Test
|
||||
dotnet new sln --force --name FlatBuffers.Test --format sln
|
||||
dotnet sln FlatBuffers.Test.sln add FlatBuffers.Test.csproj
|
||||
dotnet build -c Release ${{matrix.configuration}} FlatBuffers.Test.sln
|
||||
- name: Run net6.0
|
||||
@@ -592,11 +591,16 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
# Explicitly use 8.5.1 until we can update or https://github.com/actions/runner-images/issues/13564 is fixed.
|
||||
- name: Set env
|
||||
run: >
|
||||
echo "USE_BAZEL_VERSION=8.5.1" >> $GITHUB_ENV
|
||||
- name: bazel build
|
||||
run: >
|
||||
bazel build
|
||||
//:flatc
|
||||
//:flatbuffers
|
||||
//tests:flatbuffers_test
|
||||
- name: bazel test
|
||||
run: >
|
||||
bazel test
|
||||
|
||||
@@ -240,6 +240,9 @@ set(FlatBuffers_Tests_SRCS
|
||||
tests/vector_table_naked_ptr_test.cpp
|
||||
tests/native_type_test_impl.h
|
||||
tests/native_type_test_impl.cpp
|
||||
tests/cpp_vec_type_test_impl.h
|
||||
tests/cpp_vec_type_native_type_test_impl.h
|
||||
tests/cpp_vec_type_native_type_test_impl.cpp
|
||||
tests/alignment_test.h
|
||||
tests/alignment_test.cpp
|
||||
tests/64bit/offset64_test.h
|
||||
@@ -515,13 +518,13 @@ function(compile_schema SRC_FBS OPT SUFFIX OUT_GEN_FILE)
|
||||
endfunction()
|
||||
|
||||
function(compile_schema_for_test SRC_FBS OPT)
|
||||
compile_schema("${SRC_FBS}" "${OPT}" ".fbs" GEN_FILE)
|
||||
compile_schema("${SRC_FBS}" "${OPT}" "_generated" GEN_FILE)
|
||||
target_sources(flattests PRIVATE ${GEN_FILE})
|
||||
endfunction()
|
||||
|
||||
function(compile_schema_for_test_17 SRC_FBS OPT)
|
||||
function(compile_schema_for_test_fbsh SRC_FBS OPT)
|
||||
compile_schema("${SRC_FBS}" "${OPT}" ".fbs" GEN_FILE)
|
||||
target_sources(flattests_cpp17 PRIVATE ${GEN_FILE})
|
||||
target_sources(flattests PRIVATE ${GEN_FILE})
|
||||
endfunction()
|
||||
|
||||
function(compile_schema_for_samples SRC_FBS OPT)
|
||||
@@ -548,26 +551,19 @@ if(FLATBUFFERS_BUILD_TESTS)
|
||||
# The flattest target needs some generated files
|
||||
SET(FLATC_OPT_COMP --cpp --gen-compare --gen-mutable --gen-object-api --reflect-names)
|
||||
SET(FLATC_OPT_SCOPED_ENUMS ${FLATC_OPT_COMP};--scoped-enums)
|
||||
SET(FLATC_OPT_NAKED_PTR ${FLATC_OPT_COMP} --cpp-ptr-type naked)
|
||||
|
||||
compile_schema_for_test(tests/alignment_test.fbs "${FLATC_OPT_COMP}")
|
||||
compile_schema_for_test(tests/default_vectors_strings_test.fbs "${FLATC_OPT_COMP}")
|
||||
compile_schema_for_test(tests/monster_extra.fbs "${FLATC_OPT_COMP}")
|
||||
compile_schema_for_test_fbsh(tests/default_vectors_strings_test.fbs "${FLATC_OPT_COMP}")
|
||||
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_type_test.fbs "${FLATC_OPT_COMP}")
|
||||
compile_schema_for_test(tests/optional_scalars.fbs "${FLATC_OPT_COMP}")
|
||||
compile_schema_for_test(tests/cpp_vec_type_test.fbs "${FLATC_OPT_COMP}")
|
||||
compile_schema_for_test(tests/cpp_vec_type_native_type_test.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/evolution/v1.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_SCOPED_ENUMS}")
|
||||
compile_schema_for_test(tests/evolution_test/evolution_v1.fbs "${FLATC_OPT_SCOPED_ENUMS}")
|
||||
compile_schema_for_test(tests/evolution_test/evolution_v2.fbs "${FLATC_OPT_SCOPED_ENUMS}")
|
||||
compile_schema_for_test(tests/vector_table_naked_ptr.fbs "${FLATC_OPT_NAKED_PTR}")
|
||||
compile_schema_for_test(tests/namespace_test/namespace_test1.fbs "${FLATC_OPT_SCOPED_ENUMS}")
|
||||
compile_schema_for_test(tests/namespace_test/namespace_test2.fbs "${FLATC_OPT_SCOPED_ENUMS}")
|
||||
compile_schema_for_test(tests/union_vector/union_vector.fbs "${FLATC_OPT_COMP}")
|
||||
|
||||
if(FLATBUFFERS_CODE_SANITIZE)
|
||||
add_fsanitize_to_target(flattests ${FLATBUFFERS_CODE_SANITIZE})
|
||||
@@ -597,19 +593,9 @@ if(FLATBUFFERS_BUILD_TESTS)
|
||||
if(FLATBUFFERS_BUILD_CPP17)
|
||||
add_executable(flattests_cpp17 ${FlatBuffers_Tests_CPP17_SRCS})
|
||||
target_link_libraries(flattests_cpp17 PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||
target_include_directories(flattests_cpp17 PUBLIC
|
||||
# Ideally everything is fully qualified from the root directories
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
# TODO(derekbailey): update includes to fully qualify src/ and tests/
|
||||
src
|
||||
tests
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests
|
||||
)
|
||||
target_include_directories(flattests_cpp17 PUBLIC src tests)
|
||||
target_compile_features(flattests_cpp17 PRIVATE cxx_std_17) # requires cmake 3.8
|
||||
|
||||
compile_schema_for_test_17(tests/optional_scalars.fbs "${FLATC_OPT_COMP}")
|
||||
|
||||
if(FLATBUFFERS_CODE_SANITIZE)
|
||||
add_fsanitize_to_target(flattests_cpp17 ${FLATBUFFERS_CODE_SANITIZE})
|
||||
endif()
|
||||
|
||||
@@ -7,7 +7,7 @@ module(
|
||||
|
||||
bazel_dep(
|
||||
name = "aspect_bazel_lib",
|
||||
version = "2.11.0",
|
||||
version = "2.14.0",
|
||||
)
|
||||
bazel_dep(
|
||||
name = "aspect_rules_esbuild",
|
||||
@@ -28,11 +28,11 @@ bazel_dep(
|
||||
)
|
||||
bazel_dep(
|
||||
name = "platforms",
|
||||
version = "0.0.10",
|
||||
version = "0.0.11",
|
||||
)
|
||||
bazel_dep(
|
||||
name = "rules_cc",
|
||||
version = "0.0.16",
|
||||
version = "0.1.1",
|
||||
)
|
||||
bazel_dep(
|
||||
name = "rules_go",
|
||||
@@ -50,6 +50,7 @@ bazel_dep(
|
||||
bazel_dep(
|
||||
name = "rules_swift",
|
||||
version = "2.1.1",
|
||||
max_compatibility_level = 3,
|
||||
repo_name = "build_bazel_rules_swift",
|
||||
)
|
||||
bazel_dep(
|
||||
|
||||
@@ -79,11 +79,12 @@ list of `FILES...`.
|
||||
`myschema.fbs` to JSON:
|
||||
|
||||
```sh
|
||||
flatc --json myschema.fbs mydata.bin
|
||||
flatc --json myschema.fbs -- mydata.bin
|
||||
```
|
||||
|
||||
This will generate a `mydata.json` file.
|
||||
|
||||
This will generate a `mydata.json` file. If there is no
|
||||
[`file_identifier`](schema.md/#file-identification-and-extension) defined
|
||||
for this schema, you will need to use the `--raw-binary` option.
|
||||
|
||||
### Additional options
|
||||
|
||||
|
||||
@@ -1134,12 +1134,8 @@ The Builder provides multiple ways to create `vectors`.
|
||||
=== "Python"
|
||||
|
||||
```py
|
||||
# Create a FlatBuffer vector and prepend the weapons.
|
||||
# Note: Since we prepend the data, prepend them in reverse order.
|
||||
MyGame.Sample.Monster.StartWeaponsVector(builder, 2)
|
||||
builder.PrependUOffsetTRelative(axe)
|
||||
builder.PrependUOffsetTRelative(sword)
|
||||
weapons = builder.EndVector()
|
||||
# Use the generated helper to create the weapons vector from offsets.
|
||||
weapons = MyGame.Sample.Monster.CreateWeaponsVector(builder, [sword, axe])
|
||||
```
|
||||
|
||||
=== "Rust"
|
||||
@@ -1352,16 +1348,13 @@ bit more directly.
|
||||
```py
|
||||
# Create a `vector` representing the inventory of the Orc. Each number
|
||||
# could correspond to an item that can be claimed after he is slain.
|
||||
# Note: Since we prepend the bytes, this loop iterates in reverse.
|
||||
MyGame.Sample.Monster.StartInventoryVector(builder, 10)
|
||||
for i in reversed(range(0, 10)):
|
||||
builder.PrependByte(i)
|
||||
inv = builder.EndVector()
|
||||
inv = MyGame.Sample.Monster.CreateInventoryVector(builder, range(0, 10))
|
||||
|
||||
MyGame.Sample.Monster.StartPathVector(builder, 2)
|
||||
MyGame.Sample.Vec3.CreateVec3(builder, 1.0, 2.0, 3.0)
|
||||
MyGame.Sample.Vec3.CreateVec3(builder, 4.0, 5.0, 6.0)
|
||||
path = builder.EndVector()
|
||||
path_points = [
|
||||
MyGame.Sample.Vec3T(x=1.0, y=2.0, z=3.0),
|
||||
MyGame.Sample.Vec3T(x=4.0, y=5.0, z=6.0),
|
||||
]
|
||||
path = MyGame.Sample.Monster.CreatePathVector(builder, path_points)
|
||||
```
|
||||
|
||||
=== "Rust"
|
||||
|
||||
@@ -80,6 +80,12 @@ def UniverseStartGalaxiesVector(builder, numElems):
|
||||
def StartGalaxiesVector(builder, numElems):
|
||||
return UniverseStartGalaxiesVector(builder, numElems)
|
||||
|
||||
def UniverseCreateGalaxiesVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def CreateGalaxiesVector(builder, data):
|
||||
UniverseCreateGalaxiesVector(builder, data)
|
||||
|
||||
def UniverseEnd(builder):
|
||||
return builder.EndObject()
|
||||
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// @generated
|
||||
extern crate alloc;
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
#[allow(unused_imports, dead_code)]
|
||||
pub mod flatbuffers {
|
||||
|
||||
extern crate alloc;
|
||||
#[allow(unused_imports, dead_code)]
|
||||
pub mod goldens {
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
pub enum GalaxyOffset {}
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
|
||||
@@ -91,6 +91,14 @@ class Namer {
|
||||
std::string keyword_prefix;
|
||||
// Suffix used to escape keywords. It is usually "_".
|
||||
std::string keyword_suffix;
|
||||
// The casing used for keywords when escaping. For most languages, keywords
|
||||
// are case sensitive. PHP is an instance where some keywords are case
|
||||
// insensitive.
|
||||
enum class KeywordsCasing {
|
||||
CaseSensitive,
|
||||
CaseInsensitive,
|
||||
};
|
||||
KeywordsCasing keywords_casing;
|
||||
|
||||
// Files.
|
||||
|
||||
@@ -204,8 +212,16 @@ class Namer {
|
||||
return result;
|
||||
}
|
||||
|
||||
virtual std::string NormalizeKeywordCase(const std::string& name) const {
|
||||
if (config_.keywords_casing == Config::KeywordsCasing::CaseInsensitive) {
|
||||
return ConvertCase(name, Case::kAllLower);
|
||||
} else {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
virtual std::string EscapeKeyword(const std::string& name) const {
|
||||
if (keywords_.find(name) == keywords_.end()) {
|
||||
if (keywords_.find(NormalizeKeywordCase(name)) == keywords_.end()) {
|
||||
return name;
|
||||
} else {
|
||||
return config_.keyword_prefix + name + config_.keyword_suffix;
|
||||
|
||||
@@ -26,6 +26,7 @@ static const Namer::Config kConfig = {
|
||||
/*object_suffix=*/"T",
|
||||
/*keyword_prefix=*/"",
|
||||
/*keyword_suffix=*/"_",
|
||||
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||
/*filenames=*/Case::kKeep,
|
||||
/*directories=*/Case::kKeep,
|
||||
/*output_path=*/"",
|
||||
@@ -49,6 +50,7 @@ static const Namer::Config kStubConfig = {
|
||||
/*object_suffix=*/"T",
|
||||
/*keyword_prefix=*/"",
|
||||
/*keyword_suffix=*/"_",
|
||||
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||
/*filenames=*/Case::kKeep,
|
||||
/*directories=*/Case::kKeep,
|
||||
/*output_path=*/"",
|
||||
|
||||
@@ -260,15 +260,15 @@ inline const char* flatbuffers_version_string() {
|
||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator ~ (E lhs){\
|
||||
return E(~T(lhs));\
|
||||
}\
|
||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator |= (E &lhs, E rhs){\
|
||||
inline FLATBUFFERS_CONSTEXPR_CPP14 E operator |= (E &lhs, E rhs){\
|
||||
lhs = lhs | rhs;\
|
||||
return lhs;\
|
||||
}\
|
||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator &= (E &lhs, E rhs){\
|
||||
inline FLATBUFFERS_CONSTEXPR_CPP14 E operator &= (E &lhs, E rhs){\
|
||||
lhs = lhs & rhs;\
|
||||
return lhs;\
|
||||
}\
|
||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator ^= (E &lhs, E rhs){\
|
||||
inline FLATBUFFERS_CONSTEXPR_CPP14 E operator ^= (E &lhs, E rhs){\
|
||||
lhs = lhs ^ rhs;\
|
||||
return lhs;\
|
||||
}\
|
||||
|
||||
@@ -223,7 +223,7 @@ struct Type {
|
||||
uint16_t fixed_length; // only set if t == BASE_TYPE_ARRAY
|
||||
};
|
||||
|
||||
// Represents a parsed scalar value, it's type, and field offset.
|
||||
// Represents a parsed scalar value, its type, and field offset.
|
||||
struct Value {
|
||||
Value()
|
||||
: constant("0"),
|
||||
@@ -395,13 +395,20 @@ struct FieldDef : public Definition {
|
||||
};
|
||||
|
||||
struct StructDef : public Definition {
|
||||
enum class CycleStatus {
|
||||
NotChecked,
|
||||
InProgress,
|
||||
Checked,
|
||||
};
|
||||
|
||||
StructDef()
|
||||
: fixed(false),
|
||||
predecl(true),
|
||||
sortbysize(true),
|
||||
has_key(false),
|
||||
minalign(1),
|
||||
bytesize(0) {}
|
||||
bytesize(0),
|
||||
cycle_status{CycleStatus::NotChecked} {}
|
||||
|
||||
void PadLastField(size_t min_align) {
|
||||
auto padding = PaddingBytes(bytesize, min_align);
|
||||
@@ -423,6 +430,8 @@ struct StructDef : public Definition {
|
||||
size_t minalign; // What the whole object needs to be aligned to.
|
||||
size_t bytesize; // Size if fixed.
|
||||
|
||||
CycleStatus cycle_status; // used for determining if we have circular references
|
||||
|
||||
flatbuffers::unique_ptr<std::string> original_location;
|
||||
std::vector<voffset_t> reserved_ids;
|
||||
};
|
||||
@@ -667,6 +676,7 @@ struct IDLOptions {
|
||||
bool gen_absl_hash;
|
||||
std::string cpp_object_api_pointer_type;
|
||||
std::string cpp_object_api_string_type;
|
||||
std::string cpp_object_api_vector_type;
|
||||
bool cpp_object_api_string_flexible_constructor;
|
||||
CaseStyle cpp_object_api_field_case_style;
|
||||
bool cpp_direct_copy;
|
||||
@@ -734,6 +744,7 @@ struct IDLOptions {
|
||||
bool python_gen_numpy;
|
||||
|
||||
bool ts_omit_entrypoint;
|
||||
bool ts_undefined_for_optionals;
|
||||
ProtoIdGapAction proto_id_gap_action;
|
||||
|
||||
// Possible options for the more general generator below.
|
||||
@@ -860,6 +871,7 @@ struct IDLOptions {
|
||||
python_typing(false),
|
||||
python_gen_numpy(true),
|
||||
ts_omit_entrypoint(false),
|
||||
ts_undefined_for_optionals(false),
|
||||
proto_id_gap_action(ProtoIdGapAction::WARNING),
|
||||
mini_reflect(IDLOptions::kNone),
|
||||
require_explicit_ids(false),
|
||||
@@ -1001,6 +1013,7 @@ class Parser : public ParserState {
|
||||
known_attributes_["cpp_ptr_type_get"] = true;
|
||||
known_attributes_["cpp_str_type"] = true;
|
||||
known_attributes_["cpp_str_flex_ctor"] = true;
|
||||
known_attributes_["cpp_vec_type"] = true;
|
||||
known_attributes_["native_inline"] = true;
|
||||
known_attributes_["native_custom_alloc"] = true;
|
||||
known_attributes_["native_type"] = true;
|
||||
@@ -1099,6 +1112,8 @@ class Parser : public ParserState {
|
||||
// others includes.
|
||||
std::vector<IncludedFile> GetIncludedFiles() const;
|
||||
|
||||
bool HasCircularStructDependency();
|
||||
|
||||
private:
|
||||
class ParseDepthGuard;
|
||||
|
||||
|
||||
@@ -14,9 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
@file:Suppress("NOTHING_TO_INLINE")
|
||||
@file:OptIn(ExperimentalNativeApi::class)
|
||||
|
||||
package com.google.flatbuffers.kotlin
|
||||
|
||||
import kotlin.experimental.ExperimentalNativeApi
|
||||
|
||||
/**
|
||||
* This implementation assumes that of native macOSX64 the byte order of the implementation is
|
||||
* Little Endian.
|
||||
|
||||
@@ -296,25 +296,62 @@ function mt:Slot(slotnum)
|
||||
self.currentVTable[slotnum + 1] = self:Offset()
|
||||
end
|
||||
|
||||
local function finish(self, rootTable, sizePrefix)
|
||||
local function finish(self, rootTable, sizePrefix, fileIdentifier)
|
||||
UOffsetT:EnforceNumber(rootTable)
|
||||
self:Prep(self.minalign, sizePrefix and 8 or 4)
|
||||
self:PrependUOffsetTRelative(rootTable)
|
||||
local hasFid = fileIdentifier ~= nil
|
||||
if hasFid then
|
||||
assert(#fileIdentifier == 4, "File identifier must be exactly 4 bytes")
|
||||
end
|
||||
|
||||
local fid_byte_count = (hasFid and 4 or 0)
|
||||
|
||||
-- alignment:
|
||||
-- root offset (4)
|
||||
-- optional file id (4)
|
||||
-- optional size prefix (4)
|
||||
self:Prep(
|
||||
self.minalign,
|
||||
(sizePrefix and 4 or 0) +
|
||||
4 +
|
||||
fid_byte_count
|
||||
)
|
||||
|
||||
-- root offset (points past file identifier if present)
|
||||
self:PrependUOffsetTRelative(rootTable + fid_byte_count)
|
||||
|
||||
-- file identifier
|
||||
if hasFid then
|
||||
for i = 4, 1, -1 do
|
||||
self:PrependByte(string.byte(fileIdentifier, i))
|
||||
end
|
||||
end
|
||||
|
||||
-- size prefix
|
||||
if sizePrefix then
|
||||
local size = self.bytes.size - self.head
|
||||
Int32:EnforceNumber(size)
|
||||
self:PrependInt32(size)
|
||||
end
|
||||
|
||||
self.finished = true
|
||||
return self.head
|
||||
end
|
||||
|
||||
|
||||
function mt:Finish(rootTable)
|
||||
return finish(self, rootTable, false)
|
||||
return finish(self, rootTable, false, nil)
|
||||
end
|
||||
|
||||
function mt:FinishSizePrefixed(rootTable)
|
||||
return finish(self, rootTable, true)
|
||||
return finish(self, rootTable, true, nil)
|
||||
end
|
||||
|
||||
function mt:FinishWithIdentifier(rootTable, fileIdentifier)
|
||||
return finish(self, rootTable, false, fileIdentifier)
|
||||
end
|
||||
|
||||
function mt:FinishSizePrefixedWithIdentifier(rootTable, fileIdentifier)
|
||||
return finish(self, rootTable, true, fileIdentifier)
|
||||
end
|
||||
|
||||
function mt:Prepend(flags, off)
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace Google.FlatBuffers
|
||||
|
||||
var pos = this.__vector(o);
|
||||
var len = this.__vector_len(o);
|
||||
return bb.ToArray<T>(pos, len);
|
||||
return bb.ToArray<T>(pos, len * ByteBuffer.SizeOf<T>());
|
||||
}
|
||||
|
||||
// Initialize any Table-derived type to point to the union at the given offset.
|
||||
|
||||
@@ -422,7 +422,6 @@ class Builder(object):
|
||||
off2 = self.Offset() - off + N.UOffsetTFlags.bytewidth
|
||||
self.PlaceUOffsetT(off2)
|
||||
|
||||
## @cond FLATBUFFERS_INTERNAL
|
||||
def StartVector(self, elemSize, numElems, alignment):
|
||||
"""StartVector initializes bookkeeping for writing a new vector.
|
||||
|
||||
@@ -438,8 +437,6 @@ class Builder(object):
|
||||
self.Prep(alignment, elemSize * numElems) # In case alignment > int.
|
||||
return self.Offset()
|
||||
|
||||
## @endcond
|
||||
|
||||
def EndVector(self, numElems=None):
|
||||
"""EndVector writes data necessary to finish vector construction."""
|
||||
|
||||
@@ -556,6 +553,21 @@ class Builder(object):
|
||||
self.vectorNumElems = x.size
|
||||
return self.EndVector()
|
||||
|
||||
def CreateVectorOfTables(self, offsets):
|
||||
"""CreateVectorOfTables writes a vector of offsets such as tables or strings.
|
||||
|
||||
Args:
|
||||
offsets: Iterable of offsets returned from previous builder operations.
|
||||
Each element should be an integer compatible with UOffsetT.
|
||||
"""
|
||||
|
||||
offsets = list(offsets)
|
||||
self.StartVector(N.UOffsetTFlags.bytewidth, len(offsets),
|
||||
N.UOffsetTFlags.bytewidth)
|
||||
for off in reversed(offsets):
|
||||
self.PrependUOffsetTRelative(off)
|
||||
return self.EndVector()
|
||||
|
||||
## @cond FLATBUFFERS_INTERNAL
|
||||
def assertNested(self):
|
||||
"""Check that we are in the process of building an object."""
|
||||
|
||||
@@ -155,6 +155,12 @@ def EnumStartValuesVector(builder, numElems):
|
||||
def StartValuesVector(builder, numElems):
|
||||
return EnumStartValuesVector(builder, numElems)
|
||||
|
||||
def EnumCreateValuesVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def CreateValuesVector(builder, data):
|
||||
EnumCreateValuesVector(builder, data)
|
||||
|
||||
def EnumAddIsUnion(builder, isUnion):
|
||||
builder.PrependBoolSlot(2, isUnion, 0)
|
||||
|
||||
@@ -179,6 +185,12 @@ def EnumStartAttributesVector(builder, numElems):
|
||||
def StartAttributesVector(builder, numElems):
|
||||
return EnumStartAttributesVector(builder, numElems)
|
||||
|
||||
def EnumCreateAttributesVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def CreateAttributesVector(builder, data):
|
||||
EnumCreateAttributesVector(builder, data)
|
||||
|
||||
def EnumAddDocumentation(builder, documentation):
|
||||
builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(documentation), 0)
|
||||
|
||||
@@ -191,6 +203,12 @@ def EnumStartDocumentationVector(builder, numElems):
|
||||
def StartDocumentationVector(builder, numElems):
|
||||
return EnumStartDocumentationVector(builder, numElems)
|
||||
|
||||
def EnumCreateDocumentationVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def CreateDocumentationVector(builder, data):
|
||||
EnumCreateDocumentationVector(builder, data)
|
||||
|
||||
def EnumAddDeclarationFile(builder, declarationFile):
|
||||
builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(declarationFile), 0)
|
||||
|
||||
|
||||
@@ -134,6 +134,12 @@ def EnumValStartDocumentationVector(builder, numElems):
|
||||
def StartDocumentationVector(builder, numElems):
|
||||
return EnumValStartDocumentationVector(builder, numElems)
|
||||
|
||||
def EnumValCreateDocumentationVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def CreateDocumentationVector(builder, data):
|
||||
EnumValCreateDocumentationVector(builder, data)
|
||||
|
||||
def EnumValAddAttributes(builder, attributes):
|
||||
builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(attributes), 0)
|
||||
|
||||
@@ -146,6 +152,12 @@ def EnumValStartAttributesVector(builder, numElems):
|
||||
def StartAttributesVector(builder, numElems):
|
||||
return EnumValStartAttributesVector(builder, numElems)
|
||||
|
||||
def EnumValCreateAttributesVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def CreateAttributesVector(builder, data):
|
||||
EnumValCreateAttributesVector(builder, data)
|
||||
|
||||
def EnumValEnd(builder):
|
||||
return builder.EndObject()
|
||||
|
||||
|
||||
@@ -235,6 +235,12 @@ def FieldStartAttributesVector(builder, numElems):
|
||||
def StartAttributesVector(builder, numElems):
|
||||
return FieldStartAttributesVector(builder, numElems)
|
||||
|
||||
def FieldCreateAttributesVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def CreateAttributesVector(builder, data):
|
||||
FieldCreateAttributesVector(builder, data)
|
||||
|
||||
def FieldAddDocumentation(builder, documentation):
|
||||
builder.PrependUOffsetTRelativeSlot(10, flatbuffers.number_types.UOffsetTFlags.py_type(documentation), 0)
|
||||
|
||||
@@ -247,6 +253,12 @@ def FieldStartDocumentationVector(builder, numElems):
|
||||
def StartDocumentationVector(builder, numElems):
|
||||
return FieldStartDocumentationVector(builder, numElems)
|
||||
|
||||
def FieldCreateDocumentationVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def CreateDocumentationVector(builder, data):
|
||||
FieldCreateDocumentationVector(builder, data)
|
||||
|
||||
def FieldAddOptional(builder, optional):
|
||||
builder.PrependBoolSlot(11, optional, 0)
|
||||
|
||||
|
||||
@@ -158,6 +158,12 @@ def ObjectStartFieldsVector(builder, numElems):
|
||||
def StartFieldsVector(builder, numElems):
|
||||
return ObjectStartFieldsVector(builder, numElems)
|
||||
|
||||
def ObjectCreateFieldsVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def CreateFieldsVector(builder, data):
|
||||
ObjectCreateFieldsVector(builder, data)
|
||||
|
||||
def ObjectAddIsStruct(builder, isStruct):
|
||||
builder.PrependBoolSlot(2, isStruct, 0)
|
||||
|
||||
@@ -188,6 +194,12 @@ def ObjectStartAttributesVector(builder, numElems):
|
||||
def StartAttributesVector(builder, numElems):
|
||||
return ObjectStartAttributesVector(builder, numElems)
|
||||
|
||||
def ObjectCreateAttributesVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def CreateAttributesVector(builder, data):
|
||||
ObjectCreateAttributesVector(builder, data)
|
||||
|
||||
def ObjectAddDocumentation(builder, documentation):
|
||||
builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(documentation), 0)
|
||||
|
||||
@@ -200,6 +212,12 @@ def ObjectStartDocumentationVector(builder, numElems):
|
||||
def StartDocumentationVector(builder, numElems):
|
||||
return ObjectStartDocumentationVector(builder, numElems)
|
||||
|
||||
def ObjectCreateDocumentationVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def CreateDocumentationVector(builder, data):
|
||||
ObjectCreateDocumentationVector(builder, data)
|
||||
|
||||
def ObjectAddDeclarationFile(builder, declarationFile):
|
||||
builder.PrependUOffsetTRelativeSlot(7, flatbuffers.number_types.UOffsetTFlags.py_type(declarationFile), 0)
|
||||
|
||||
|
||||
@@ -138,6 +138,12 @@ def RPCCallStartAttributesVector(builder, numElems):
|
||||
def StartAttributesVector(builder, numElems):
|
||||
return RPCCallStartAttributesVector(builder, numElems)
|
||||
|
||||
def RPCCallCreateAttributesVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def CreateAttributesVector(builder, data):
|
||||
RPCCallCreateAttributesVector(builder, data)
|
||||
|
||||
def RPCCallAddDocumentation(builder, documentation):
|
||||
builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(documentation), 0)
|
||||
|
||||
@@ -150,6 +156,12 @@ def RPCCallStartDocumentationVector(builder, numElems):
|
||||
def StartDocumentationVector(builder, numElems):
|
||||
return RPCCallStartDocumentationVector(builder, numElems)
|
||||
|
||||
def RPCCallCreateDocumentationVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def CreateDocumentationVector(builder, data):
|
||||
RPCCallCreateDocumentationVector(builder, data)
|
||||
|
||||
def RPCCallEnd(builder):
|
||||
return builder.EndObject()
|
||||
|
||||
|
||||
@@ -180,6 +180,12 @@ def SchemaStartObjectsVector(builder, numElems):
|
||||
def StartObjectsVector(builder, numElems):
|
||||
return SchemaStartObjectsVector(builder, numElems)
|
||||
|
||||
def SchemaCreateObjectsVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def CreateObjectsVector(builder, data):
|
||||
SchemaCreateObjectsVector(builder, data)
|
||||
|
||||
def SchemaAddEnums(builder, enums):
|
||||
builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(enums), 0)
|
||||
|
||||
@@ -192,6 +198,12 @@ def SchemaStartEnumsVector(builder, numElems):
|
||||
def StartEnumsVector(builder, numElems):
|
||||
return SchemaStartEnumsVector(builder, numElems)
|
||||
|
||||
def SchemaCreateEnumsVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def CreateEnumsVector(builder, data):
|
||||
SchemaCreateEnumsVector(builder, data)
|
||||
|
||||
def SchemaAddFileIdent(builder, fileIdent):
|
||||
builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(fileIdent), 0)
|
||||
|
||||
@@ -222,6 +234,12 @@ def SchemaStartServicesVector(builder, numElems):
|
||||
def StartServicesVector(builder, numElems):
|
||||
return SchemaStartServicesVector(builder, numElems)
|
||||
|
||||
def SchemaCreateServicesVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def CreateServicesVector(builder, data):
|
||||
SchemaCreateServicesVector(builder, data)
|
||||
|
||||
def SchemaAddAdvancedFeatures(builder, advancedFeatures):
|
||||
builder.PrependUint64Slot(6, advancedFeatures, 0)
|
||||
|
||||
@@ -240,6 +258,12 @@ def SchemaStartFbsFilesVector(builder, numElems):
|
||||
def StartFbsFilesVector(builder, numElems):
|
||||
return SchemaStartFbsFilesVector(builder, numElems)
|
||||
|
||||
def SchemaCreateFbsFilesVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def CreateFbsFilesVector(builder, data):
|
||||
SchemaCreateFbsFilesVector(builder, data)
|
||||
|
||||
def SchemaEnd(builder):
|
||||
return builder.EndObject()
|
||||
|
||||
|
||||
@@ -84,6 +84,12 @@ def SchemaFileStartIncludedFilenamesVector(builder, numElems):
|
||||
def StartIncludedFilenamesVector(builder, numElems):
|
||||
return SchemaFileStartIncludedFilenamesVector(builder, numElems)
|
||||
|
||||
def SchemaFileCreateIncludedFilenamesVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def CreateIncludedFilenamesVector(builder, data):
|
||||
SchemaFileCreateIncludedFilenamesVector(builder, data)
|
||||
|
||||
def SchemaFileEnd(builder):
|
||||
return builder.EndObject()
|
||||
|
||||
|
||||
@@ -137,6 +137,12 @@ def ServiceStartCallsVector(builder, numElems):
|
||||
def StartCallsVector(builder, numElems):
|
||||
return ServiceStartCallsVector(builder, numElems)
|
||||
|
||||
def ServiceCreateCallsVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def CreateCallsVector(builder, data):
|
||||
ServiceCreateCallsVector(builder, data)
|
||||
|
||||
def ServiceAddAttributes(builder, attributes):
|
||||
builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(attributes), 0)
|
||||
|
||||
@@ -149,6 +155,12 @@ def ServiceStartAttributesVector(builder, numElems):
|
||||
def StartAttributesVector(builder, numElems):
|
||||
return ServiceStartAttributesVector(builder, numElems)
|
||||
|
||||
def ServiceCreateAttributesVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def CreateAttributesVector(builder, data):
|
||||
ServiceCreateAttributesVector(builder, data)
|
||||
|
||||
def ServiceAddDocumentation(builder, documentation):
|
||||
builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(documentation), 0)
|
||||
|
||||
@@ -161,6 +173,12 @@ def ServiceStartDocumentationVector(builder, numElems):
|
||||
def StartDocumentationVector(builder, numElems):
|
||||
return ServiceStartDocumentationVector(builder, numElems)
|
||||
|
||||
def ServiceCreateDocumentationVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def CreateDocumentationVector(builder, data):
|
||||
ServiceCreateDocumentationVector(builder, data)
|
||||
|
||||
def ServiceAddDeclarationFile(builder, declarationFile):
|
||||
builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(declarationFile), 0)
|
||||
|
||||
|
||||
@@ -611,6 +611,8 @@ impl<'fbb, A: Allocator> FlatBufferBuilder<'fbb, A> {
|
||||
// Write the VTable (we may delete it afterwards, if it is a duplicate):
|
||||
let vt_start_pos = self.head;
|
||||
let vt_end_pos = self.head + vtable_byte_len;
|
||||
// Zero out the vtable space - make_space only reserves but doesn't initialize
|
||||
self.allocator[vt_start_pos.range_to(vt_end_pos)].fill(0);
|
||||
{
|
||||
// write the vtable header:
|
||||
let vtfw =
|
||||
|
||||
@@ -421,6 +421,9 @@ impl<'a> Serializer for MapKeySerializer<'a> {
|
||||
type SerializeStruct = Impossible<(), Error>;
|
||||
type SerializeStructVariant = Impossible<(), Error>;
|
||||
|
||||
fn is_human_readable(&self) -> bool {
|
||||
self.0.is_human_readable()
|
||||
}
|
||||
fn serialize_bool(self, _value: bool) -> Result<(), Error> {
|
||||
key_must_be_a_string()
|
||||
}
|
||||
|
||||
@@ -33,11 +33,11 @@ result = subprocess.run(
|
||||
if result.returncode != 0:
|
||||
print(
|
||||
"\n"
|
||||
"ERROR: *********************************************************\n"
|
||||
"ERROR: * The following differences were found after building. *\n"
|
||||
"ERROR: * Perhaps there is a difference in the flags for the. *\n"
|
||||
"ERROR: * CMakeLists.txt vs the script/generate_code.py script? *\n"
|
||||
"ERROR: *********************************************************\n"
|
||||
"ERROR: **********************************************************\n"
|
||||
"ERROR: * The following differences were found after building. *\n"
|
||||
"ERROR: * Perhaps there is a difference in the flags for the. *\n"
|
||||
"ERROR: * CMakeLists.txt vs the scripts/generate_code.py script? *\n"
|
||||
"ERROR: **********************************************************\n"
|
||||
)
|
||||
subprocess.run(["git", "diff", "--binary", "--exit-code"], cwd=root_path)
|
||||
sys.exit(result.returncode)
|
||||
@@ -55,11 +55,11 @@ result = subprocess.run(
|
||||
if result.returncode != 0:
|
||||
print(
|
||||
"\n"
|
||||
"ERROR: ********************************************************\n"
|
||||
"ERROR: * The following differences were found after running *\n"
|
||||
"ERROR: * the script/generate_code.py script. Maybe you forgot *\n"
|
||||
"ERROR: * to run it after making changes in a generator? *\n"
|
||||
"ERROR: ********************************************************\n"
|
||||
"ERROR: *********************************************************\n"
|
||||
"ERROR: * The following differences were found after running *\n"
|
||||
"ERROR: * the scripts/generate_code.py script. Maybe you forgot *\n"
|
||||
"ERROR: * to run it after making changes in a generator? *\n"
|
||||
"ERROR: *********************************************************\n"
|
||||
)
|
||||
subprocess.run(["git", "diff", "--binary", "--exit-code"], cwd=root_path)
|
||||
sys.exit(result.returncode)
|
||||
|
||||
@@ -85,6 +85,11 @@ RUST_OPTS = BASE_OPTS + [
|
||||
"--gen-name-strings",
|
||||
"--rust-module-root-file",
|
||||
]
|
||||
RUST_STANDALONE_OPTS = BASE_OPTS + [
|
||||
"--rust",
|
||||
"--gen-all",
|
||||
"--gen-name-strings",
|
||||
]
|
||||
RUST_SERIALIZE_OPTS = BASE_OPTS + [
|
||||
"--rust",
|
||||
"--gen-all",
|
||||
@@ -240,6 +245,12 @@ flatc(
|
||||
],
|
||||
)
|
||||
|
||||
flatc(
|
||||
BASE_OPTS + CPP_OPTS + ["--cpp-ptr-type", "naked"],
|
||||
prefix="vector_table_naked_ptr",
|
||||
schema="vector_table_naked_ptr.fbs",
|
||||
)
|
||||
|
||||
flatc(
|
||||
BASE_OPTS + CPP_OPTS + CS_OPTS + JAVA_OPTS + KOTLIN_OPTS + PHP_OPTS,
|
||||
prefix="union_vector",
|
||||
@@ -282,6 +293,12 @@ flatc(
|
||||
schema="include_test/include_test1.fbs",
|
||||
)
|
||||
|
||||
flatc(
|
||||
RUST_STANDALONE_OPTS,
|
||||
include="include_test",
|
||||
schema="include_test/include_test1.fbs",
|
||||
)
|
||||
|
||||
flatc(
|
||||
RUST_OPTS,
|
||||
prefix="include_test2",
|
||||
@@ -289,6 +306,12 @@ flatc(
|
||||
schema="include_test/sub/include_test2.fbs",
|
||||
)
|
||||
|
||||
flatc(
|
||||
RUST_STANDALONE_OPTS,
|
||||
include="include_test",
|
||||
schema="include_test/sub/include_test2.fbs",
|
||||
)
|
||||
|
||||
flatc(
|
||||
BINARY_OPTS + ["--bfbs-filenames", str(tests_path)],
|
||||
include="include_test",
|
||||
@@ -356,16 +379,15 @@ flatc(
|
||||
)
|
||||
|
||||
flatc(
|
||||
[
|
||||
"--cpp",
|
||||
"--gen-compare",
|
||||
"--gen-mutable",
|
||||
"--gen-object-api",
|
||||
"--reflect-names",
|
||||
],
|
||||
["--cpp", "--gen-compare", "--gen-mutable", "--gen-object-api", "--reflect-names"],
|
||||
schema="native_type_test.fbs",
|
||||
)
|
||||
|
||||
flatc(
|
||||
["--cpp", "--gen-compare", "--gen-mutable", "--gen-object-api", "--reflect-names"],
|
||||
schema="cpp_vec_type_test.fbs",
|
||||
)
|
||||
|
||||
flatc(
|
||||
[
|
||||
"--cpp",
|
||||
|
||||
@@ -61,6 +61,7 @@ Namer::Config LuaDefaultConfig() {
|
||||
/*object_suffix=*/"",
|
||||
/*keyword_prefix=*/"",
|
||||
/*keyword_suffix=*/"_",
|
||||
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||
/*filenames=*/Case::kKeep,
|
||||
/*directories=*/Case::kKeep,
|
||||
/*output_path=*/"",
|
||||
@@ -194,6 +195,13 @@ class LuaBfbsGenerator : public BaseBfbsGenerator {
|
||||
code += "\n";
|
||||
|
||||
if (object == root_object) {
|
||||
// emit file identifier if present
|
||||
const auto ident = schema_->file_ident();
|
||||
if (ident && ident->size() == 4) {
|
||||
code += "local FileIdentifier = \"" + ident->str() + "\"\n";
|
||||
code += "\n";
|
||||
}
|
||||
|
||||
code += "function " + object_name + ".GetRootAs" + object_name +
|
||||
"(buf, offset)\n";
|
||||
code += " if type(buf) == \"string\" then\n";
|
||||
@@ -454,6 +462,34 @@ class LuaBfbsGenerator : public BaseBfbsGenerator {
|
||||
code += " return builder:EndObject()\n";
|
||||
code += "end\n";
|
||||
code += "\n";
|
||||
|
||||
if (object == root_object) {
|
||||
code += "function " + object_name + ".Finish" + object_name +
|
||||
"Buffer(builder, offset)\n";
|
||||
// emit file identifier if present
|
||||
const auto ident = schema_->file_ident();
|
||||
if (ident && ident->size() == 4) {
|
||||
code += " builder:FinishWithIdentifier(offset, FileIdentifier)\n";
|
||||
} else {
|
||||
code += " builder:Finish(offset)\n";
|
||||
}
|
||||
code += "end\n";
|
||||
code += "\n";
|
||||
|
||||
// size prefixed option
|
||||
code += "function " + object_name + ".FinishSizePrefixed" +
|
||||
object_name + "Buffer(builder, offset)\n";
|
||||
// emit file identifier if present
|
||||
if (ident && ident->size() == 4) {
|
||||
code +=
|
||||
" builder:FinishSizePrefixedWithIdentifier(offset, "
|
||||
"FileIdentifier)\n";
|
||||
} else {
|
||||
code += " builder:FinishSizePrefixed(offset)\n";
|
||||
}
|
||||
code += "end\n";
|
||||
code += "\n";
|
||||
}
|
||||
}
|
||||
|
||||
EmitCodeBlock(code, object_name, ns, object->declaration_file()->str());
|
||||
|
||||
@@ -70,6 +70,7 @@ Namer::Config NimDefaultConfig() {
|
||||
/*object_suffix=*/"T",
|
||||
/*keyword_prefix=*/"",
|
||||
/*keyword_suffix=*/"_",
|
||||
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||
/*filenames=*/Case::kKeep,
|
||||
/*directories=*/Case::kKeep,
|
||||
/*output_path=*/"",
|
||||
|
||||
@@ -142,6 +142,10 @@ const static FlatCOption flatc_options[] = {
|
||||
"and T::empty() must be supported. The custom type also needs to be "
|
||||
"constructible from std::string (see the --cpp-str-flex-ctor option to "
|
||||
"change this behavior)"},
|
||||
{"", "cpp-vec-type", "T",
|
||||
"Set object API vector type (default std::vector). T must support the "
|
||||
"same interface as std::vector: size(), resize(), reserve(), "
|
||||
"emplace_back(), operator[], begin(), end(), and data()."},
|
||||
{"", "cpp-str-flex-ctor", "",
|
||||
"Don't construct custom string types by passing std::string from "
|
||||
"Flatbuffers, but (char* + length)."},
|
||||
@@ -265,6 +269,9 @@ const static FlatCOption flatc_options[] = {
|
||||
{"", "python-gen-numpy", "", "Whether to generate numpy helpers."},
|
||||
{"", "ts-omit-entrypoint", "",
|
||||
"Omit emission of namespace entrypoint file"},
|
||||
{"", "ts-undefined-for-optionals", "",
|
||||
"Whether to generate undefined values instead of null values for missing "
|
||||
"optional keys"},
|
||||
{"", "file-names-only", "",
|
||||
"Print out generated file names without writing to the files"},
|
||||
{"", "grpc-filename-suffix", "SUFFIX",
|
||||
@@ -540,6 +547,9 @@ FlatCOptions FlatCompiler::ParseFromCommandLineArguments(int argc,
|
||||
} else if (arg == "--cpp-str-type") {
|
||||
if (++argi >= argc) Error("missing type following: " + arg, true);
|
||||
opts.cpp_object_api_string_type = argv[argi];
|
||||
} else if (arg == "--cpp-vec-type") {
|
||||
if (++argi >= argc) Error("missing type following: " + arg, true);
|
||||
opts.cpp_object_api_vector_type = argv[argi];
|
||||
} else if (arg == "--cpp-str-flex-ctor") {
|
||||
opts.cpp_object_api_string_flexible_constructor = true;
|
||||
} else if (arg == "--no-cpp-direct-copy") {
|
||||
@@ -710,6 +720,8 @@ FlatCOptions FlatCompiler::ParseFromCommandLineArguments(int argc,
|
||||
opts.python_gen_numpy = false;
|
||||
} else if (arg == "--ts-omit-entrypoint") {
|
||||
opts.ts_omit_entrypoint = true;
|
||||
} else if (arg == "--ts-undefined-for-optionals") {
|
||||
opts.ts_undefined_for_optionals = true;
|
||||
} else if (arg == "--annotate-sparse-vectors") {
|
||||
options.annotate_include_vector_contents = false;
|
||||
} else if (arg == "--annotate") {
|
||||
@@ -922,6 +934,9 @@ std::unique_ptr<Parser> FlatCompiler::GenerateCode(const FlatCOptions& options,
|
||||
auto err = parser->ConformTo(conform_parser);
|
||||
if (!err.empty()) Error("schemas don\'t conform: " + err, false);
|
||||
}
|
||||
if (parser->HasCircularStructDependency()) {
|
||||
Error("schema has circular struct dependencies: " + filename, false);
|
||||
}
|
||||
if (options.schema_binary || opts.binary_schema_gen_embed) {
|
||||
parser->Serialize();
|
||||
}
|
||||
|
||||
@@ -929,6 +929,15 @@ class CppGenerator : public BaseGenerator {
|
||||
return ret;
|
||||
}
|
||||
|
||||
const std::string NativeVector(const FieldDef* field) {
|
||||
auto attr = field ? field->attributes.Lookup("cpp_vec_type") : nullptr;
|
||||
auto& ret = attr ? attr->constant : opts_.cpp_object_api_vector_type;
|
||||
if (ret.empty()) {
|
||||
return "std::vector";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool FlexibleStringConstructor(const FieldDef* field) {
|
||||
auto attr = field != nullptr &&
|
||||
(field->attributes.Lookup("cpp_str_flex_ctor") != nullptr);
|
||||
@@ -974,20 +983,26 @@ class CppGenerator : public BaseGenerator {
|
||||
case BASE_TYPE_VECTOR64:
|
||||
case BASE_TYPE_VECTOR: {
|
||||
const auto type_name = GenTypeNative(type.VectorType(), true, field);
|
||||
if (type.struct_def &&
|
||||
const auto vec_type = NativeVector(&field);
|
||||
if (vec_type == "std::vector" && type.struct_def &&
|
||||
type.struct_def->attributes.Lookup("native_custom_alloc")) {
|
||||
auto native_custom_alloc =
|
||||
type.struct_def->attributes.Lookup("native_custom_alloc");
|
||||
return "std::vector<" + type_name + "," +
|
||||
native_custom_alloc->constant + "<" + type_name + ">>";
|
||||
} else {
|
||||
return "std::vector<" + type_name + ">";
|
||||
}
|
||||
return vec_type + "<" + type_name + ">";
|
||||
}
|
||||
case BASE_TYPE_STRUCT: {
|
||||
auto type_name = WrapInNameSpace(*type.struct_def);
|
||||
if (IsStruct(type)) {
|
||||
auto native_type = type.struct_def->attributes.Lookup("native_type");
|
||||
// Field-level native_type takes priority over struct-level
|
||||
// native_type
|
||||
auto field_native_type = field.attributes.Lookup("native_type");
|
||||
auto native_type =
|
||||
field_native_type
|
||||
? field_native_type
|
||||
: type.struct_def->attributes.Lookup("native_type");
|
||||
if (native_type) {
|
||||
type_name = native_type->constant;
|
||||
}
|
||||
@@ -1951,9 +1966,10 @@ class CppGenerator : public BaseGenerator {
|
||||
field.offset64);
|
||||
}
|
||||
if (TypeHasKey(vtype)) {
|
||||
code_.SetValue("PARAM_TYPE", "std::vector<" + type + "> *");
|
||||
code_.SetValue("PARAM_TYPE", NativeVector(&field) + "<" + type + "> *");
|
||||
} else {
|
||||
code_.SetValue("PARAM_TYPE", "const std::vector<" + type + "> *");
|
||||
code_.SetValue("PARAM_TYPE",
|
||||
"const " + NativeVector(&field) + "<" + type + "> *");
|
||||
}
|
||||
code_.SetValue("PARAM_VALUE", "nullptr");
|
||||
} else {
|
||||
@@ -1979,7 +1995,7 @@ class CppGenerator : public BaseGenerator {
|
||||
const std::string& full_type =
|
||||
(cpp_type
|
||||
? (IsVector(field.value.type)
|
||||
? "std::vector<" +
|
||||
? NativeVector(&field) + "<" +
|
||||
GenTypeNativePtr(cpp_type->constant, &field,
|
||||
false) +
|
||||
"> "
|
||||
@@ -3516,10 +3532,21 @@ class CppGenerator : public BaseGenerator {
|
||||
case BASE_TYPE_STRUCT: {
|
||||
if (IsStruct(type)) {
|
||||
const auto& struct_attrs = type.struct_def->attributes;
|
||||
const auto native_type = struct_attrs.Lookup("native_type");
|
||||
// Field-level native_type takes priority over struct-level
|
||||
// native_type
|
||||
auto field_native_type = afield.attributes.Lookup("native_type");
|
||||
const auto native_type = field_native_type
|
||||
? field_native_type
|
||||
: struct_attrs.Lookup("native_type");
|
||||
if (native_type) {
|
||||
std::string unpack_call = "::flatbuffers::UnPack";
|
||||
const auto pack_name = struct_attrs.Lookup("native_type_pack_name");
|
||||
// Field-level native_type_pack_name takes priority over
|
||||
// struct-level
|
||||
auto field_pack_name =
|
||||
afield.attributes.Lookup("native_type_pack_name");
|
||||
const auto pack_name =
|
||||
field_pack_name ? field_pack_name
|
||||
: struct_attrs.Lookup("native_type_pack_name");
|
||||
if (pack_name) {
|
||||
unpack_call += pack_name->constant;
|
||||
}
|
||||
@@ -3774,7 +3801,8 @@ class CppGenerator : public BaseGenerator {
|
||||
auto vector_type = field.value.type.VectorType();
|
||||
switch (vector_type.base_type) {
|
||||
case BASE_TYPE_STRING: {
|
||||
if (NativeString(&field) == "std::string") {
|
||||
if (NativeString(&field) == "std::string" &&
|
||||
NativeVector(&field) == "std::vector") {
|
||||
code += "_fbb.CreateVectorOfStrings(" + value + ")";
|
||||
} else {
|
||||
// Use by-function serialization to emulate
|
||||
@@ -3795,30 +3823,52 @@ class CppGenerator : public BaseGenerator {
|
||||
if (IsStruct(vector_type)) {
|
||||
const auto& struct_attrs =
|
||||
field.value.type.struct_def->attributes;
|
||||
const auto native_type = struct_attrs.Lookup("native_type");
|
||||
// Field-level native_type takes priority over struct-level
|
||||
// native_type
|
||||
auto field_native_type = field.attributes.Lookup("native_type");
|
||||
const auto native_type = field_native_type
|
||||
? field_native_type
|
||||
: struct_attrs.Lookup("native_type");
|
||||
if (native_type) {
|
||||
code += "_fbb.CreateVectorOfNativeStructs<";
|
||||
code += WrapInNameSpace(*vector_type.struct_def) + ", " +
|
||||
native_type->constant + ">";
|
||||
code += "(" + value;
|
||||
// Field-level native_type_pack_name takes priority over
|
||||
// struct-level
|
||||
auto field_pack_name =
|
||||
field.attributes.Lookup("native_type_pack_name");
|
||||
const auto pack_name =
|
||||
struct_attrs.Lookup("native_type_pack_name");
|
||||
field_pack_name
|
||||
? field_pack_name
|
||||
: struct_attrs.Lookup("native_type_pack_name");
|
||||
// Non-std vectors (e.g. eastl::vector) don't match the
|
||||
// std::vector overload, so use the pointer+size overload.
|
||||
const bool is_std_vec = NativeVector(&field) == "std::vector";
|
||||
if (is_std_vec) {
|
||||
code += "(" + value;
|
||||
} else {
|
||||
code += "(" + value + ".data(), " + value + ".size()";
|
||||
}
|
||||
if (pack_name) {
|
||||
code += ", ::flatbuffers::Pack" + pack_name->constant;
|
||||
}
|
||||
code += ")";
|
||||
} else {
|
||||
// If the field uses 64-bit addressing, create a 64-bit vector.
|
||||
const bool is_std_vec = NativeVector(&field) == "std::vector";
|
||||
const std::string vec_args =
|
||||
is_std_vec ? ("(" + value + ")")
|
||||
: ("(" + value + ".data(), " + value + ".size())");
|
||||
if (field.value.type.base_type == BASE_TYPE_VECTOR64) {
|
||||
code += "_fbb.CreateVectorOfStructs64";
|
||||
code += "_fbb.CreateVectorOfStructs64" + vec_args;
|
||||
} else {
|
||||
code += "_fbb.CreateVectorOfStructs";
|
||||
if (field.offset64) {
|
||||
// This is normal 32-bit vector, with 64-bit addressing.
|
||||
code += "64<::flatbuffers::Vector>";
|
||||
}
|
||||
code += vec_args;
|
||||
}
|
||||
code += "(" + value + ")";
|
||||
}
|
||||
} else {
|
||||
code += "_fbb.CreateVector<::flatbuffers::Offset<";
|
||||
@@ -3837,7 +3887,12 @@ class CppGenerator : public BaseGenerator {
|
||||
break;
|
||||
}
|
||||
case BASE_TYPE_BOOL: {
|
||||
code += "_fbb.CreateVector(" + value + ")";
|
||||
if (NativeVector(&field) == "std::vector") {
|
||||
code += "_fbb.CreateVector(" + value + ")";
|
||||
} else {
|
||||
code += "_fbb.CreateVector(" + value + ".data(), " + value +
|
||||
".size())";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BASE_TYPE_UNION: {
|
||||
@@ -3886,15 +3941,19 @@ class CppGenerator : public BaseGenerator {
|
||||
code += "; }, &_va )";
|
||||
} else {
|
||||
// If the field uses 64-bit addressing, create a 64-bit vector.
|
||||
const bool is_std_vec = NativeVector(&field) == "std::vector";
|
||||
const std::string vec_args =
|
||||
is_std_vec ? ("(" + value + ")")
|
||||
: ("(" + value + ".data(), " + value + ".size())");
|
||||
if (field.value.type.base_type == BASE_TYPE_VECTOR64) {
|
||||
code += "_fbb.CreateVector64(" + value + ")";
|
||||
code += "_fbb.CreateVector64" + vec_args;
|
||||
} else {
|
||||
code += "_fbb.CreateVector";
|
||||
if (field.offset64) {
|
||||
// This is normal 32-bit vector, with 64-bit addressing.
|
||||
code += "64<::flatbuffers::Vector>";
|
||||
}
|
||||
code += "(" + value + ")";
|
||||
code += vec_args;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -3918,11 +3977,22 @@ class CppGenerator : public BaseGenerator {
|
||||
case BASE_TYPE_STRUCT: {
|
||||
if (IsStruct(field.value.type)) {
|
||||
const auto& struct_attribs = field.value.type.struct_def->attributes;
|
||||
const auto native_type = struct_attribs.Lookup("native_type");
|
||||
// Field-level native_type takes priority over struct-level
|
||||
// native_type
|
||||
auto field_native_type = field.attributes.Lookup("native_type");
|
||||
const auto native_type = field_native_type
|
||||
? field_native_type
|
||||
: struct_attribs.Lookup("native_type");
|
||||
if (native_type && field.native_inline) {
|
||||
code += "::flatbuffers::Pack";
|
||||
// Field-level native_type_pack_name takes priority over
|
||||
// struct-level
|
||||
auto field_pack_name =
|
||||
field.attributes.Lookup("native_type_pack_name");
|
||||
const auto pack_name =
|
||||
struct_attribs.Lookup("native_type_pack_name");
|
||||
field_pack_name
|
||||
? field_pack_name
|
||||
: struct_attribs.Lookup("native_type_pack_name");
|
||||
if (pack_name) {
|
||||
code += pack_name->constant;
|
||||
}
|
||||
@@ -4086,9 +4156,15 @@ class CppGenerator : public BaseGenerator {
|
||||
bool check_ptr = false;
|
||||
if (field->value.type.base_type == BASE_TYPE_STRUCT) {
|
||||
if (IsStruct(field->value.type)) {
|
||||
// Field-level native_type takes priority over struct-level
|
||||
// native_type
|
||||
auto field_native_type =
|
||||
field->attributes.Lookup("native_type");
|
||||
auto native_type =
|
||||
field->value.type.struct_def->attributes.Lookup(
|
||||
"native_type");
|
||||
field_native_type
|
||||
? field_native_type
|
||||
: field->value.type.struct_def->attributes.Lookup(
|
||||
"native_type");
|
||||
auto native_inline = field->attributes.Lookup("native_inline");
|
||||
if (native_type) {
|
||||
pass_by_address = true;
|
||||
|
||||
@@ -1243,6 +1243,58 @@ class CSharpGenerator : public BaseGenerator {
|
||||
}
|
||||
code += " }\n";
|
||||
}
|
||||
|
||||
// Generate Length property and ByteBuffer accessor for arrays in structs.
|
||||
if (IsArray(field.value.type) && struct_def.fixed &&
|
||||
IsScalar(field.value.type.VectorType().base_type)) {
|
||||
auto camel_name = Name(field);
|
||||
if (camel_name == struct_def.name) { camel_name += "_"; }
|
||||
|
||||
// Generate Length constant
|
||||
code += " public const int " + camel_name;
|
||||
code += "Length = ";
|
||||
code += NumToString(field.value.type.fixed_length);
|
||||
code += ";\n";
|
||||
|
||||
// Generate GetBytes methods for scalar arrays (similar to vector pattern)
|
||||
code += "#if ENABLE_SPAN_T\n";
|
||||
code += " public Span<" + GenTypeBasic(field.value.type.VectorType()) +
|
||||
"> Get";
|
||||
code += camel_name;
|
||||
code += "Bytes() { return ";
|
||||
|
||||
// For byte arrays, we can return the span directly
|
||||
if (field.value.type.VectorType().base_type == BASE_TYPE_UCHAR) {
|
||||
code += "__p.bb.ToSpan(__p.bb_pos + ";
|
||||
code += NumToString(field.value.offset);
|
||||
code += ", ";
|
||||
code += NumToString(field.value.type.fixed_length *
|
||||
SizeOf(field.value.type.VectorType().base_type));
|
||||
code += ")";
|
||||
} else {
|
||||
// For other types, we need to cast the byte span
|
||||
code += "System.Runtime.InteropServices.MemoryMarshal.Cast<byte, " +
|
||||
GenTypeBasic(field.value.type.VectorType()) + ">(__p.bb.ToSpan(__p.bb_pos + ";
|
||||
code += NumToString(field.value.offset);
|
||||
code += ", ";
|
||||
code += NumToString(field.value.type.fixed_length *
|
||||
SizeOf(field.value.type.VectorType().base_type));
|
||||
code += "))";
|
||||
}
|
||||
code += "; }\n";
|
||||
code += "#else\n";
|
||||
code += " public ArraySegment<byte>? Get";
|
||||
code += camel_name;
|
||||
code += "Bytes() { return ";
|
||||
code += "__p.bb.ToArraySegment(__p.bb_pos + ";
|
||||
code += NumToString(field.value.offset);
|
||||
code += ", ";
|
||||
code += NumToString(field.value.type.fixed_length *
|
||||
SizeOf(field.value.type.VectorType().base_type));
|
||||
code += ");}\n";
|
||||
code += "#endif\n";
|
||||
}
|
||||
|
||||
// generate object accessors if is nested_flatbuffer
|
||||
if (field.nested_flatbuffer) {
|
||||
auto nested_type_name = NamespacedName(*field.nested_flatbuffer);
|
||||
|
||||
@@ -48,6 +48,7 @@ static Namer::Config DartDefaultConfig() {
|
||||
/*object_suffix=*/"T",
|
||||
/*keyword_prefix=*/"$",
|
||||
/*keyword_suffix=*/"",
|
||||
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||
/*filenames=*/Case::kKeep,
|
||||
/*directories=*/Case::kKeep,
|
||||
/*output_path=*/"",
|
||||
|
||||
@@ -75,6 +75,7 @@ static Namer::Config GoDefaultConfig() {
|
||||
/*object_suffix=*/"T",
|
||||
/*keyword_prefix=*/"",
|
||||
/*keyword_suffix=*/"_",
|
||||
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||
/*filenames=*/Case::kKeep,
|
||||
/*directories=*/Case::kKeep,
|
||||
/*output_path=*/"",
|
||||
|
||||
@@ -46,6 +46,7 @@ static Namer::Config JavaDefaultConfig() {
|
||||
/*object_suffix=*/"T",
|
||||
/*keyword_prefix=*/"",
|
||||
/*keyword_suffix=*/"_",
|
||||
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||
/*filenames=*/Case::kKeep,
|
||||
/*directories=*/Case::kKeep,
|
||||
/*output_path=*/"",
|
||||
|
||||
@@ -64,6 +64,7 @@ static Namer::Config KotlinDefaultConfig() {
|
||||
/*object_suffix=*/"T",
|
||||
/*keyword_prefix=*/"",
|
||||
/*keyword_suffix=*/"_",
|
||||
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||
/*filenames=*/Case::kKeep,
|
||||
/*directories=*/Case::kKeep,
|
||||
/*output_path=*/"",
|
||||
|
||||
@@ -62,6 +62,7 @@ static Namer::Config KotlinDefaultConfig() {
|
||||
/*object_suffix=*/"T",
|
||||
/*keyword_prefix=*/"",
|
||||
/*keyword_suffix=*/"E",
|
||||
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||
/*filenames=*/Case::kUpperCamel,
|
||||
/*directories=*/Case::kLowerCamel,
|
||||
/*output_path=*/"",
|
||||
|
||||
@@ -593,6 +593,18 @@ class PythonStubGenerator {
|
||||
"bytes) -> uoffset: ...\n";
|
||||
}
|
||||
}
|
||||
|
||||
stub << "def ";
|
||||
if (!parser_.opts.python_no_type_prefix_suffix) stub << type;
|
||||
stub << "Create" << namer_.Method(*field)
|
||||
<< "Vector(builder: flatbuffers.Builder, data: typing.Iterable["
|
||||
"typing.Any]) -> uoffset: ...\n";
|
||||
if (!parser_.opts.one_file &&
|
||||
!parser_.opts.python_no_type_prefix_suffix) {
|
||||
stub << "def Create" << namer_.Method(*field)
|
||||
<< "Vector(builder: flatbuffers.Builder, data: "
|
||||
"typing.Iterable[typing.Any]) -> uoffset: ...\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1467,6 +1479,59 @@ class PythonGenerator : public BaseGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
void BuildVectorCreationHelper(const StructDef& struct_def,
|
||||
const FieldDef& field, std::string* code_ptr,
|
||||
ImportMap& imports) const {
|
||||
auto& code = *code_ptr;
|
||||
const auto vector_type = field.value.type.VectorType();
|
||||
const bool is_struct_vector = IsStruct(vector_type);
|
||||
const bool is_scalar_vector =
|
||||
IsScalar(vector_type.base_type) || vector_type.enum_def != nullptr;
|
||||
const std::string struct_type = namer_.Type(struct_def);
|
||||
const std::string field_method = namer_.Method(field);
|
||||
const std::string helper_name =
|
||||
parser_.opts.python_no_type_prefix_suffix
|
||||
? "Create" + field_method + "Vector"
|
||||
: struct_type + "Create" + field_method + "Vector";
|
||||
|
||||
if (parser_.opts.python_typing) {
|
||||
imports.insert(ImportMapEntry{"typing", "Iterable"});
|
||||
code += "def " + helper_name +
|
||||
"(builder: flatbuffers.Builder, data: Iterable[Any]) -> int:\n";
|
||||
} else {
|
||||
code += "def " + helper_name + "(builder, data):\n";
|
||||
}
|
||||
|
||||
if (is_scalar_vector || is_struct_vector) {
|
||||
auto alignment = InlineAlignment(vector_type);
|
||||
auto elem_size = InlineSize(vector_type);
|
||||
code += Indent + "data = list(data)\n";
|
||||
code += Indent + "builder.StartVector(" + NumToString(elem_size) +
|
||||
", len(data), " + NumToString(alignment) + ")\n";
|
||||
code += Indent + "for item in reversed(data):\n";
|
||||
if (is_struct_vector) {
|
||||
code += Indent + Indent + "item.Pack(builder)\n";
|
||||
} else {
|
||||
code += Indent + Indent + "builder.Prepend" +
|
||||
namer_.Method(GenTypeBasic(vector_type)) + "(item)\n";
|
||||
}
|
||||
code += Indent + "return builder.EndVector()\n\n";
|
||||
} else {
|
||||
code += Indent + "return builder.CreateVectorOfTables(data)\n\n";
|
||||
}
|
||||
|
||||
if (!parser_.opts.one_file && !parser_.opts.python_no_type_prefix_suffix) {
|
||||
if (parser_.opts.python_typing) {
|
||||
code += "def Create" + field_method +
|
||||
"Vector(builder: flatbuffers.Builder, data: Iterable[Any]) "
|
||||
"-> int:\n";
|
||||
} else {
|
||||
code += "def Create" + field_method + "Vector(builder, data):\n";
|
||||
}
|
||||
code += Indent + helper_name + "(builder, data)\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Set the value of one of the members of a table's vector and fills in the
|
||||
// elements from a bytearray. This is for simplifying the use of nested
|
||||
// flatbuffers.
|
||||
@@ -1617,8 +1682,8 @@ class PythonGenerator : public BaseGenerator {
|
||||
}
|
||||
|
||||
// Generate table constructors, conditioned on its members' types.
|
||||
void GenTableBuilders(const StructDef& struct_def,
|
||||
std::string* code_ptr) const {
|
||||
void GenTableBuilders(const StructDef& struct_def, std::string* code_ptr,
|
||||
ImportMap& imports) const {
|
||||
GetStartOfTable(struct_def, code_ptr);
|
||||
|
||||
for (auto it = struct_def.fields.vec.begin();
|
||||
@@ -1630,6 +1695,7 @@ class PythonGenerator : public BaseGenerator {
|
||||
BuildFieldOfTable(struct_def, field, offset, code_ptr);
|
||||
if (IsVector(field.value.type)) {
|
||||
BuildVectorOfTable(struct_def, field, code_ptr);
|
||||
BuildVectorCreationHelper(struct_def, field, code_ptr, imports);
|
||||
BuildVectorOfTableFromBytes(struct_def, field, code_ptr);
|
||||
}
|
||||
}
|
||||
@@ -1696,7 +1762,7 @@ class PythonGenerator : public BaseGenerator {
|
||||
GenStructBuilder(struct_def, code_ptr);
|
||||
} else {
|
||||
// Creates a set of functions that allow table construction.
|
||||
GenTableBuilders(struct_def, code_ptr);
|
||||
GenTableBuilders(struct_def, code_ptr, imports);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ static Namer::Config RustDefaultConfig() {
|
||||
/*object_suffix=*/"T",
|
||||
/*keyword_prefix=*/"",
|
||||
/*keyword_suffix=*/"_",
|
||||
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||
/*filenames=*/Case::kSnake,
|
||||
/*directories=*/Case::kSnake,
|
||||
/*output_path=*/"",
|
||||
@@ -423,7 +424,6 @@ class RustGenerator : public BaseGenerator {
|
||||
code_.Clear();
|
||||
code_ += "// " + std::string(FlatBuffersGeneratedWarning());
|
||||
code_ += "// @generated";
|
||||
code_ += "extern crate alloc;";
|
||||
|
||||
assert(!cur_name_space_);
|
||||
|
||||
@@ -3005,6 +3005,7 @@ class RustGenerator : public BaseGenerator {
|
||||
"use self::serde::ser::{Serialize, Serializer, SerializeStruct};";
|
||||
code_ += "";
|
||||
}
|
||||
code_ += "extern crate alloc;";
|
||||
}
|
||||
|
||||
// Set up the correct namespace. This opens a namespace if the current
|
||||
|
||||
@@ -47,6 +47,7 @@ static Namer::Config SwiftDefaultConfig() {
|
||||
/*object_suffix=*/"T",
|
||||
/*keyword_prefix=*/"",
|
||||
/*keyword_suffix=*/"_",
|
||||
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||
/*filenames=*/Case::kKeep,
|
||||
/*directories=*/Case::kKeep,
|
||||
/*output_path=*/"",
|
||||
@@ -1962,7 +1963,7 @@ class SwiftGenerator : public BaseGenerator {
|
||||
std::string GenType(const Type& type,
|
||||
const bool should_consider_suffix = false) const {
|
||||
return IsScalar(type.base_type) ? GenTypeBasic(type)
|
||||
: IsArray(type) ? GenType(type.VectorType())
|
||||
: IsArray(type) ? GenType(type.VectorType())
|
||||
: GenTypePointer(type, should_consider_suffix);
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ Namer::Config TypeScriptDefaultConfig() {
|
||||
/*object_suffix=*/"T",
|
||||
/*keyword_prefix=*/"",
|
||||
/*keyword_suffix=*/"_",
|
||||
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||
/*filenames=*/Case::kDasher,
|
||||
/*directories=*/Case::kDasher,
|
||||
/*output_path=*/"",
|
||||
@@ -86,6 +87,7 @@ std::set<std::string> TypescriptKeywords() {
|
||||
"throw", "true", "try", "typeof", "var", "void",
|
||||
"while", "with", "as", "implements", "interface", "let",
|
||||
"package", "private", "protected", "public", "static", "yield",
|
||||
"undefined" // Used with --ts-undefined-for-optionals
|
||||
};
|
||||
}
|
||||
|
||||
@@ -110,7 +112,9 @@ class TsGenerator : public BaseGenerator {
|
||||
const std::string& file_name)
|
||||
: BaseGenerator(parser, path, file_name, "", "_", "ts"),
|
||||
namer_(WithFlagOptions(TypeScriptDefaultConfig(), parser.opts, path),
|
||||
TypescriptKeywords()) {}
|
||||
TypescriptKeywords()),
|
||||
null_keyword_(parser_.opts.ts_undefined_for_optionals ? "undefined"
|
||||
: "null") {}
|
||||
|
||||
bool generate() {
|
||||
generateEnums();
|
||||
@@ -214,6 +218,8 @@ class TsGenerator : public BaseGenerator {
|
||||
|
||||
std::map<std::string, NsDefinition> ns_defs_;
|
||||
|
||||
std::string null_keyword_;
|
||||
|
||||
// Generate code for all enums.
|
||||
void generateEnums() {
|
||||
for (auto it = parser_.enums_.vec.begin(); it != parser_.enums_.vec.end();
|
||||
@@ -467,7 +473,7 @@ class TsGenerator : public BaseGenerator {
|
||||
|
||||
std::string GenDefaultValue(const FieldDef& field, import_set& imports) {
|
||||
if (field.IsScalarOptional()) {
|
||||
return "null";
|
||||
return null_keyword_;
|
||||
}
|
||||
|
||||
const auto& value = field.value;
|
||||
@@ -518,7 +524,7 @@ class TsGenerator : public BaseGenerator {
|
||||
case BASE_TYPE_STRING:
|
||||
case BASE_TYPE_UNION:
|
||||
case BASE_TYPE_STRUCT: {
|
||||
return "null";
|
||||
return null_keyword_;
|
||||
}
|
||||
|
||||
case BASE_TYPE_ARRAY:
|
||||
@@ -554,16 +560,16 @@ class TsGenerator : public BaseGenerator {
|
||||
} else {
|
||||
name = AddImport(imports, owner, *type.struct_def).name;
|
||||
}
|
||||
return allowNull ? (name + "|null") : name;
|
||||
return allowNull ? (name + "|" + null_keyword_) : name;
|
||||
}
|
||||
}
|
||||
|
||||
switch (type.base_type) {
|
||||
case BASE_TYPE_BOOL:
|
||||
return allowNull ? "boolean|null" : "boolean";
|
||||
return allowNull ? ("boolean|" + null_keyword_) : "boolean";
|
||||
case BASE_TYPE_LONG:
|
||||
case BASE_TYPE_ULONG:
|
||||
return allowNull ? "bigint|null" : "bigint";
|
||||
return allowNull ? ("bigint|" + null_keyword_) : "bigint";
|
||||
case BASE_TYPE_ARRAY: {
|
||||
std::string name;
|
||||
if (type.element == BASE_TYPE_LONG || type.element == BASE_TYPE_ULONG) {
|
||||
@@ -578,16 +584,16 @@ class TsGenerator : public BaseGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
return name + (allowNull ? "|null" : "");
|
||||
return name + (allowNull ? ("|" + null_keyword_) : "");
|
||||
}
|
||||
default:
|
||||
if (IsScalar(type.base_type)) {
|
||||
if (type.enum_def) {
|
||||
const auto enum_name =
|
||||
AddImport(imports, owner, *type.enum_def).name;
|
||||
return allowNull ? (enum_name + "|null") : enum_name;
|
||||
return allowNull ? (enum_name + "|" + null_keyword_) : enum_name;
|
||||
}
|
||||
return allowNull ? "number|null" : "number";
|
||||
return allowNull ? ("number|" + null_keyword_) : "number";
|
||||
}
|
||||
return "flatbuffers.Offset";
|
||||
}
|
||||
@@ -1039,7 +1045,8 @@ class TsGenerator : public BaseGenerator {
|
||||
const auto& enum_def = *union_type.enum_def;
|
||||
|
||||
const auto valid_union_type = GenUnionTypeTS(enum_def, imports);
|
||||
const auto valid_union_type_with_null = valid_union_type + "|null";
|
||||
const auto valid_union_type_with_null =
|
||||
valid_union_type + "|" + null_keyword_;
|
||||
|
||||
auto ret = "\n\nexport function " + GenUnionConvFuncName(enum_def) +
|
||||
"(\n type: " + GetTypeName(enum_def) +
|
||||
@@ -1051,7 +1058,7 @@ class TsGenerator : public BaseGenerator {
|
||||
|
||||
const auto union_enum_loop = [&](const std::string& accessor_str) {
|
||||
ret += " switch(" + enum_type + "[type]) {\n";
|
||||
ret += " case 'NONE': return null; \n";
|
||||
ret += " case 'NONE': return " + null_keyword_ + "; \n";
|
||||
|
||||
for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end();
|
||||
++it) {
|
||||
@@ -1075,7 +1082,7 @@ class TsGenerator : public BaseGenerator {
|
||||
ret += "\n";
|
||||
}
|
||||
|
||||
ret += " default: return null;\n";
|
||||
ret += " default: return " + null_keyword_ + ";\n";
|
||||
ret += " }\n";
|
||||
};
|
||||
|
||||
@@ -1120,7 +1127,8 @@ class TsGenerator : public BaseGenerator {
|
||||
ret += " const temp = " + conversion_function + "(this." +
|
||||
namer_.Method(field_name, "Type") + "(), " +
|
||||
field_binded_method + ");\n";
|
||||
ret += " if(temp === null) { return null; }\n";
|
||||
ret += " if(temp === " + null_keyword_ + ") { return " +
|
||||
null_keyword_ + "; }\n";
|
||||
ret += union_has_string
|
||||
? " if(typeof temp === 'string') { return temp; }\n"
|
||||
: "";
|
||||
@@ -1140,12 +1148,12 @@ class TsGenerator : public BaseGenerator {
|
||||
"++targetEnumIndex) {\n";
|
||||
ret += " const targetEnum = this." +
|
||||
namer_.Method(field_name, "Type") + "(targetEnumIndex);\n";
|
||||
ret += " if(targetEnum === null || " + enum_type +
|
||||
ret += " if(targetEnum === " + null_keyword_ + " || " + enum_type +
|
||||
"[targetEnum!] === 'NONE') { "
|
||||
"continue; }\n\n";
|
||||
ret += " const temp = " + conversion_function + "(targetEnum, " +
|
||||
field_binded_method + ", targetEnumIndex);\n";
|
||||
ret += " if(temp === null) { continue; }\n";
|
||||
ret += " if(temp === " + null_keyword_ + ") { continue; }\n";
|
||||
ret += union_has_string ? " if(typeof temp === 'string') { "
|
||||
"ret.push(temp); continue; }\n"
|
||||
: "";
|
||||
@@ -1162,11 +1170,11 @@ class TsGenerator : public BaseGenerator {
|
||||
return "";
|
||||
}
|
||||
|
||||
static std::string GenNullCheckConditional(
|
||||
const std::string& nullCheckVar, const std::string& trueVal,
|
||||
const std::string& falseVal = "null") {
|
||||
return "(" + nullCheckVar + " !== null ? " + trueVal + " : " + falseVal +
|
||||
")";
|
||||
std::string GenNullCheckConditional(const std::string& nullCheckVar,
|
||||
const std::string& trueVal,
|
||||
const std::string& falseVal) {
|
||||
return "(" + nullCheckVar + " !== " + null_keyword_ + " ? " + trueVal +
|
||||
" : " + falseVal + ")";
|
||||
}
|
||||
|
||||
std::string GenStructMemberValueTS(const StructDef& struct_def,
|
||||
@@ -1300,8 +1308,8 @@ class TsGenerator : public BaseGenerator {
|
||||
|
||||
const std::string field_accessor =
|
||||
"this." + namer_.Method(field) + "()";
|
||||
field_val = GenNullCheckConditional(field_accessor,
|
||||
field_accessor + "!.unpack()");
|
||||
field_val = GenNullCheckConditional(
|
||||
field_accessor, field_accessor + "!.unpack()", null_keyword_);
|
||||
auto packing = GenNullCheckConditional(
|
||||
"this." + field_field,
|
||||
"this." + field_field + "!.pack(builder)", "0");
|
||||
@@ -1509,8 +1517,8 @@ class TsGenerator : public BaseGenerator {
|
||||
break;
|
||||
}
|
||||
|
||||
// length 0 vector is simply empty instead of null
|
||||
field_type += is_vector ? "" : "|null";
|
||||
// length 0 vector is simply empty instead of null/undefined.
|
||||
field_type += is_vector ? "" : ("|" + null_keyword_);
|
||||
}
|
||||
|
||||
if (!field_offset_decl.empty()) {
|
||||
@@ -1539,7 +1547,7 @@ class TsGenerator : public BaseGenerator {
|
||||
} else {
|
||||
if (field.IsScalarOptional()) {
|
||||
pack_func_create_call +=
|
||||
" if (" + field_offset_val + " !== null)\n ";
|
||||
" if (" + field_offset_val + " !== " + null_keyword_ + ")\n ";
|
||||
}
|
||||
pack_func_create_call += " " + struct_name + "." +
|
||||
namer_.Method("add", field) + "(builder, " +
|
||||
@@ -1629,7 +1637,8 @@ class TsGenerator : public BaseGenerator {
|
||||
"> {\n";
|
||||
else
|
||||
code += " {\n";
|
||||
code += " bb: flatbuffers.ByteBuffer|null = null;\n";
|
||||
code += " bb: flatbuffers.ByteBuffer|" + null_keyword_ + " = " +
|
||||
null_keyword_ + ";\n";
|
||||
code += " bb_pos = 0;\n";
|
||||
|
||||
// Generate the __init method that sets the field in a pre-existing
|
||||
@@ -1681,7 +1690,7 @@ class TsGenerator : public BaseGenerator {
|
||||
GenDocComment(field.doc_comment, code_ptr);
|
||||
std::string prefix = namer_.Method(field) + "(";
|
||||
if (is_string) {
|
||||
code += prefix + "):string|null\n";
|
||||
code += prefix + "):string|" + null_keyword_ + "\n";
|
||||
code +=
|
||||
prefix + "optionalEncoding:flatbuffers.Encoding" + "):" +
|
||||
GenTypeName(imports, struct_def, field.value.type, false, true) +
|
||||
@@ -1731,7 +1740,8 @@ class TsGenerator : public BaseGenerator {
|
||||
.name;
|
||||
GenDocComment(field.doc_comment, code_ptr);
|
||||
code += namer_.Method(field);
|
||||
code += "(obj?:" + type + "):" + type + "|null {\n";
|
||||
code +=
|
||||
"(obj?:" + type + "):" + type + "|" + null_keyword_ + " {\n";
|
||||
|
||||
if (struct_def.fixed) {
|
||||
code += " return (obj || " + GenerateNewExpression(type);
|
||||
@@ -1744,7 +1754,7 @@ class TsGenerator : public BaseGenerator {
|
||||
code += field.value.type.struct_def->fixed
|
||||
? "this.bb_pos + offset"
|
||||
: GenBBAccess() + ".__indirect(this.bb_pos + offset)";
|
||||
code += ", " + GenBBAccess() + ") : null;\n";
|
||||
code += ", " + GenBBAccess() + ") : " + null_keyword_ + ";\n";
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -1797,7 +1807,7 @@ class TsGenerator : public BaseGenerator {
|
||||
} else {
|
||||
code += prefix;
|
||||
}
|
||||
code += "):" + vectortypename + "|null {\n";
|
||||
code += "):" + vectortypename + "|" + null_keyword_ + " {\n";
|
||||
|
||||
if (vectortype.base_type == BASE_TYPE_STRUCT) {
|
||||
code += offset_prefix + "(obj || " +
|
||||
@@ -1837,7 +1847,7 @@ class TsGenerator : public BaseGenerator {
|
||||
code += " : 0";
|
||||
}
|
||||
} else {
|
||||
code += ": null";
|
||||
code += ": " + null_keyword_;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1895,7 +1905,7 @@ class TsGenerator : public BaseGenerator {
|
||||
} else {
|
||||
code += prefix;
|
||||
}
|
||||
code += "):" + vectortypename + "|null {\n";
|
||||
code += "):" + vectortypename + "|" + null_keyword_ + " {\n";
|
||||
|
||||
if (vectortype.base_type == BASE_TYPE_STRUCT) {
|
||||
code += offset_prefix + "(obj || " +
|
||||
@@ -1921,12 +1931,12 @@ class TsGenerator : public BaseGenerator {
|
||||
code += "BigInt(0)";
|
||||
} else if (IsScalar(field.value.type.element)) {
|
||||
if (field.value.type.enum_def) {
|
||||
code += "null";
|
||||
code += null_keyword_;
|
||||
} else {
|
||||
code += "0";
|
||||
}
|
||||
} else {
|
||||
code += "null";
|
||||
code += null_keyword_;
|
||||
}
|
||||
code += ";\n";
|
||||
break;
|
||||
@@ -1939,13 +1949,13 @@ class TsGenerator : public BaseGenerator {
|
||||
const auto& union_enum = *(field.value.type.enum_def);
|
||||
const auto union_type = GenUnionGenericTypeTS(union_enum);
|
||||
code += "<T extends flatbuffers.Table>(obj:" + union_type +
|
||||
"):" + union_type +
|
||||
"|null "
|
||||
"):" + union_type + "|" + null_keyword_ +
|
||||
" "
|
||||
"{\n";
|
||||
|
||||
code += offset_prefix +
|
||||
GenGetter(field.value.type, "(obj, this.bb_pos + offset)") +
|
||||
" : null;\n";
|
||||
" : " + null_keyword_ + ";\n";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -2007,14 +2017,15 @@ class TsGenerator : public BaseGenerator {
|
||||
GenDocComment(code_ptr);
|
||||
|
||||
code += namer_.Method(field, "Array");
|
||||
code +=
|
||||
"():" + GenType(vectorType) + "Array|null {\n" + offset_prefix;
|
||||
code += "():" + GenType(vectorType) + "Array|" + null_keyword_ +
|
||||
" {\n" + offset_prefix;
|
||||
|
||||
code += "new " + GenType(vectorType) + "Array(" + GenBBAccess() +
|
||||
".bytes().buffer, " + GenBBAccess() +
|
||||
".bytes().byteOffset + " + GenBBAccess() +
|
||||
".__vector(this.bb_pos + offset), " + GenBBAccess() +
|
||||
".__vector_len(this.bb_pos + offset)) : null;\n}\n\n";
|
||||
".__vector_len(this.bb_pos + offset)) : " + null_keyword_ +
|
||||
";\n}\n\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2084,7 +2095,7 @@ class TsGenerator : public BaseGenerator {
|
||||
if (!IsScalar(field.value.type.base_type)) {
|
||||
code += "0";
|
||||
} else if (HasNullDefault(field)) {
|
||||
code += "null";
|
||||
code += null_keyword_;
|
||||
} else {
|
||||
if (field.value.type.base_type == BASE_TYPE_BOOL) {
|
||||
code += "+";
|
||||
@@ -2201,7 +2212,7 @@ class TsGenerator : public BaseGenerator {
|
||||
const auto arg_name = GetArgName(field);
|
||||
|
||||
if (field.IsScalarOptional()) {
|
||||
code += " if (" + arg_name + " !== null)\n ";
|
||||
code += " if (" + arg_name + " !== " + null_keyword_ + ")\n ";
|
||||
}
|
||||
|
||||
code += " " + methodPrefix + "." + namer_.Method("add", field) + "(";
|
||||
@@ -2241,7 +2252,7 @@ class TsGenerator : public BaseGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
static bool HasNullDefault(const FieldDef& field) {
|
||||
bool HasNullDefault(const FieldDef& field) {
|
||||
return field.IsOptional() && field.value.constant == "null";
|
||||
}
|
||||
|
||||
|
||||
@@ -2755,6 +2755,42 @@ std::vector<IncludedFile> Parser::GetIncludedFiles() const {
|
||||
return {it->second.cbegin(), it->second.cend()};
|
||||
}
|
||||
|
||||
bool Parser::HasCircularStructDependency() {
|
||||
std::function<bool(StructDef*)> visit =
|
||||
[&](StructDef* struct_def) {
|
||||
// Only consider fixed structs and structs we have yet to check
|
||||
if (!struct_def->fixed || struct_def->cycle_status == StructDef::CycleStatus::Checked) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (struct_def->cycle_status == StructDef::CycleStatus::InProgress) {
|
||||
// cycle found
|
||||
return true;
|
||||
}
|
||||
|
||||
struct_def->cycle_status = StructDef::CycleStatus::InProgress;
|
||||
|
||||
for (const auto& field : struct_def->fields.vec) {
|
||||
if (field->value.type.base_type == BASE_TYPE_STRUCT) {
|
||||
if (visit(field->value.type.struct_def)) {
|
||||
return true; // Cycle detected in recursion.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct_def->cycle_status = StructDef::CycleStatus::Checked;
|
||||
return false; // No cycle detected.
|
||||
};
|
||||
|
||||
for (const auto& struct_def : structs_.vec) {
|
||||
if (visit(struct_def)) {
|
||||
return true; // Cycle detected.
|
||||
}
|
||||
}
|
||||
|
||||
return false; // No cycle detected.
|
||||
}
|
||||
|
||||
bool Parser::SupportsOptionalScalars(const flatbuffers::IDLOptions& opts) {
|
||||
static FLATBUFFERS_CONSTEXPR unsigned long supported_langs =
|
||||
IDLOptions::kRust | IDLOptions::kSwift | IDLOptions::kLobster |
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library")
|
||||
load("//:build_defs.bzl", "flatbuffer_cc_library")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
cc_library(
|
||||
name = "offset64_test",
|
||||
testonly = 1,
|
||||
srcs = ["offset64_test.cpp"],
|
||||
hdrs = ["offset64_test.h"],
|
||||
deps = [
|
||||
":test_64bit_cc_fbs",
|
||||
"//tests:test_assert",
|
||||
"//tests/64bit/evolution:v1_cc_fbs",
|
||||
"//tests/64bit/evolution:v2_cc_fbs",
|
||||
],
|
||||
)
|
||||
|
||||
flatbuffer_cc_library(
|
||||
name = "test_64bit_cc_fbs",
|
||||
srcs = ["test_64bit.fbs"],
|
||||
filename_suffix = ".fbs",
|
||||
flatc_args = [
|
||||
"--gen-compare",
|
||||
"--gen-mutable",
|
||||
"--gen-object-api",
|
||||
"--reflect-names",
|
||||
"--filename-suffix .fbs",
|
||||
],
|
||||
)
|
||||
@@ -1,29 +0,0 @@
|
||||
load("//:build_defs.bzl", "flatbuffer_cc_library")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
flatbuffer_cc_library(
|
||||
name = "v1_cc_fbs",
|
||||
srcs = ["v1.fbs"],
|
||||
filename_suffix = ".fbs",
|
||||
flatc_args = [
|
||||
"--gen-compare",
|
||||
"--gen-mutable",
|
||||
"--gen-object-api",
|
||||
"--reflect-names",
|
||||
"--filename-suffix .fbs",
|
||||
],
|
||||
)
|
||||
|
||||
flatbuffer_cc_library(
|
||||
name = "v2_cc_fbs",
|
||||
srcs = ["v2.fbs"],
|
||||
filename_suffix = ".fbs",
|
||||
flatc_args = [
|
||||
"--gen-compare",
|
||||
"--gen-mutable",
|
||||
"--gen-object-api",
|
||||
"--reflect-names",
|
||||
"--filename-suffix .fbs",
|
||||
],
|
||||
)
|
||||
222
tests/64bit/evolution/v1_generated.h
Normal file
222
tests/64bit/evolution/v1_generated.h
Normal file
@@ -0,0 +1,222 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
|
||||
#ifndef FLATBUFFERS_GENERATED_V1_V1_H_
|
||||
#define FLATBUFFERS_GENERATED_V1_V1_H_
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||
// generated, otherwise it may not be compatible.
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 19,
|
||||
"Non-compatible flatbuffers version included");
|
||||
|
||||
namespace v1 {
|
||||
|
||||
struct RootTable;
|
||||
struct RootTableBuilder;
|
||||
struct RootTableT;
|
||||
|
||||
bool operator==(const RootTableT &lhs, const RootTableT &rhs);
|
||||
bool operator!=(const RootTableT &lhs, const RootTableT &rhs);
|
||||
|
||||
inline const ::flatbuffers::TypeTable *RootTableTypeTable();
|
||||
|
||||
struct RootTableT : public ::flatbuffers::NativeTable {
|
||||
typedef RootTable TableType;
|
||||
float a = 0.0f;
|
||||
std::vector<uint8_t> b{};
|
||||
};
|
||||
|
||||
struct RootTable FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef RootTableT NativeTableType;
|
||||
typedef RootTableBuilder Builder;
|
||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return RootTableTypeTable();
|
||||
}
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_A = 4,
|
||||
VT_B = 6
|
||||
};
|
||||
float a() const {
|
||||
return GetField<float>(VT_A, 0.0f);
|
||||
}
|
||||
bool mutate_a(float _a = 0.0f) {
|
||||
return SetField<float>(VT_A, _a, 0.0f);
|
||||
}
|
||||
const ::flatbuffers::Vector<uint8_t> *b() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<uint8_t> *>(VT_B);
|
||||
}
|
||||
::flatbuffers::Vector<uint8_t> *mutable_b() {
|
||||
return GetPointer<::flatbuffers::Vector<uint8_t> *>(VT_B);
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<float>(verifier, VT_A, 4) &&
|
||||
VerifyOffset(verifier, VT_B) &&
|
||||
verifier.VerifyVector(b()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
RootTableT *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
void UnPackTo(RootTableT *_o, const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
static ::flatbuffers::Offset<RootTable> Pack(::flatbuffers::FlatBufferBuilder &_fbb, const RootTableT* _o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
};
|
||||
|
||||
struct RootTableBuilder {
|
||||
typedef RootTable Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_a(float a) {
|
||||
fbb_.AddElement<float>(RootTable::VT_A, a, 0.0f);
|
||||
}
|
||||
void add_b(::flatbuffers::Offset<::flatbuffers::Vector<uint8_t>> b) {
|
||||
fbb_.AddOffset(RootTable::VT_B, b);
|
||||
}
|
||||
explicit RootTableBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<RootTable> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<RootTable>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<RootTable> CreateRootTable(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
float a = 0.0f,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<uint8_t>> b = 0) {
|
||||
RootTableBuilder builder_(_fbb);
|
||||
builder_.add_b(b);
|
||||
builder_.add_a(a);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<RootTable> CreateRootTableDirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
float a = 0.0f,
|
||||
const std::vector<uint8_t> *b = nullptr) {
|
||||
auto b__ = b ? _fbb.CreateVector<uint8_t>(*b) : 0;
|
||||
return v1::CreateRootTable(
|
||||
_fbb,
|
||||
a,
|
||||
b__);
|
||||
}
|
||||
|
||||
::flatbuffers::Offset<RootTable> CreateRootTable(::flatbuffers::FlatBufferBuilder &_fbb, const RootTableT *_o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
|
||||
|
||||
inline bool operator==(const RootTableT &lhs, const RootTableT &rhs) {
|
||||
return
|
||||
(lhs.a == rhs.a) &&
|
||||
(lhs.b == rhs.b);
|
||||
}
|
||||
|
||||
inline bool operator!=(const RootTableT &lhs, const RootTableT &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
|
||||
inline RootTableT *RootTable::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
auto _o = std::unique_ptr<RootTableT>(new RootTableT());
|
||||
UnPackTo(_o.get(), _resolver);
|
||||
return _o.release();
|
||||
}
|
||||
|
||||
inline void RootTable::UnPackTo(RootTableT *_o, const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
(void)_o;
|
||||
(void)_resolver;
|
||||
{ auto _e = a(); _o->a = _e; }
|
||||
{ auto _e = b(); if (_e) { _o->b.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->b.begin()); } }
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<RootTable> CreateRootTable(::flatbuffers::FlatBufferBuilder &_fbb, const RootTableT *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
return RootTable::Pack(_fbb, _o, _rehasher);
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<RootTable> RootTable::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const RootTableT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
(void)_rehasher;
|
||||
(void)_o;
|
||||
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const RootTableT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||
auto _a = _o->a;
|
||||
auto _b = _o->b.size() ? _fbb.CreateVector(_o->b) : 0;
|
||||
return v1::CreateRootTable(
|
||||
_fbb,
|
||||
_a,
|
||||
_b);
|
||||
}
|
||||
|
||||
inline const ::flatbuffers::TypeTable *RootTableTypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_FLOAT, 0, -1 },
|
||||
{ ::flatbuffers::ET_UCHAR, 1, -1 }
|
||||
};
|
||||
static const char * const names[] = {
|
||||
"a",
|
||||
"b"
|
||||
};
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_TABLE, 2, type_codes, nullptr, nullptr, nullptr, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
inline const v1::RootTable *GetRootTable(const void *buf) {
|
||||
return ::flatbuffers::GetRoot<v1::RootTable>(buf);
|
||||
}
|
||||
|
||||
inline const v1::RootTable *GetSizePrefixedRootTable(const void *buf) {
|
||||
return ::flatbuffers::GetSizePrefixedRoot<v1::RootTable>(buf);
|
||||
}
|
||||
|
||||
inline RootTable *GetMutableRootTable(void *buf) {
|
||||
return ::flatbuffers::GetMutableRoot<RootTable>(buf);
|
||||
}
|
||||
|
||||
inline v1::RootTable *GetMutableSizePrefixedRootTable(void *buf) {
|
||||
return ::flatbuffers::GetMutableSizePrefixedRoot<v1::RootTable>(buf);
|
||||
}
|
||||
|
||||
template <bool B = false>
|
||||
inline bool VerifyRootTableBuffer(
|
||||
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||
return verifier.template VerifyBuffer<v1::RootTable>(nullptr);
|
||||
}
|
||||
|
||||
template <bool B = false>
|
||||
inline bool VerifySizePrefixedRootTableBuffer(
|
||||
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||
return verifier.template VerifySizePrefixedBuffer<v1::RootTable>(nullptr);
|
||||
}
|
||||
|
||||
inline void FinishRootTableBuffer(
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<v1::RootTable> root) {
|
||||
fbb.Finish(root);
|
||||
}
|
||||
|
||||
inline void FinishSizePrefixedRootTableBuffer(
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<v1::RootTable> root) {
|
||||
fbb.FinishSizePrefixed(root);
|
||||
}
|
||||
|
||||
inline std::unique_ptr<v1::RootTableT> UnPackRootTable(
|
||||
const void *buf,
|
||||
const ::flatbuffers::resolver_function_t *res = nullptr) {
|
||||
return std::unique_ptr<v1::RootTableT>(GetRootTable(buf)->UnPack(res));
|
||||
}
|
||||
|
||||
inline std::unique_ptr<v1::RootTableT> UnPackSizePrefixedRootTable(
|
||||
const void *buf,
|
||||
const ::flatbuffers::resolver_function_t *res = nullptr) {
|
||||
return std::unique_ptr<v1::RootTableT>(GetSizePrefixedRootTable(buf)->UnPack(res));
|
||||
}
|
||||
|
||||
} // namespace v1
|
||||
|
||||
#endif // FLATBUFFERS_GENERATED_V1_V1_H_
|
||||
246
tests/64bit/evolution/v2_generated.h
Normal file
246
tests/64bit/evolution/v2_generated.h
Normal file
@@ -0,0 +1,246 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
|
||||
#ifndef FLATBUFFERS_GENERATED_V2_V2_H_
|
||||
#define FLATBUFFERS_GENERATED_V2_V2_H_
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||
// generated, otherwise it may not be compatible.
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 19,
|
||||
"Non-compatible flatbuffers version included");
|
||||
|
||||
namespace v2 {
|
||||
|
||||
struct RootTable;
|
||||
struct RootTableBuilder;
|
||||
struct RootTableT;
|
||||
|
||||
bool operator==(const RootTableT &lhs, const RootTableT &rhs);
|
||||
bool operator!=(const RootTableT &lhs, const RootTableT &rhs);
|
||||
|
||||
inline const ::flatbuffers::TypeTable *RootTableTypeTable();
|
||||
|
||||
struct RootTableT : public ::flatbuffers::NativeTable {
|
||||
typedef RootTable TableType;
|
||||
float a = 0.0f;
|
||||
std::vector<uint8_t> b{};
|
||||
std::vector<uint8_t> big_vector{};
|
||||
};
|
||||
|
||||
struct RootTable FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef RootTableT NativeTableType;
|
||||
typedef RootTableBuilder Builder;
|
||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return RootTableTypeTable();
|
||||
}
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_A = 4,
|
||||
VT_B = 6,
|
||||
VT_BIG_VECTOR = 8
|
||||
};
|
||||
float a() const {
|
||||
return GetField<float>(VT_A, 0.0f);
|
||||
}
|
||||
bool mutate_a(float _a = 0.0f) {
|
||||
return SetField<float>(VT_A, _a, 0.0f);
|
||||
}
|
||||
const ::flatbuffers::Vector<uint8_t> *b() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<uint8_t> *>(VT_B);
|
||||
}
|
||||
::flatbuffers::Vector<uint8_t> *mutable_b() {
|
||||
return GetPointer<::flatbuffers::Vector<uint8_t> *>(VT_B);
|
||||
}
|
||||
const ::flatbuffers::Vector64<uint8_t> *big_vector() const {
|
||||
return GetPointer64<const ::flatbuffers::Vector64<uint8_t> *>(VT_BIG_VECTOR);
|
||||
}
|
||||
::flatbuffers::Vector64<uint8_t> *mutable_big_vector() {
|
||||
return GetPointer64<::flatbuffers::Vector64<uint8_t> *>(VT_BIG_VECTOR);
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<float>(verifier, VT_A, 4) &&
|
||||
VerifyOffset(verifier, VT_B) &&
|
||||
verifier.VerifyVector(b()) &&
|
||||
VerifyOffset64(verifier, VT_BIG_VECTOR) &&
|
||||
verifier.VerifyVector(big_vector()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
RootTableT *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
void UnPackTo(RootTableT *_o, const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
static ::flatbuffers::Offset<RootTable> Pack(::flatbuffers::FlatBufferBuilder64 &_fbb, const RootTableT* _o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
};
|
||||
|
||||
struct RootTableBuilder {
|
||||
typedef RootTable Table;
|
||||
::flatbuffers::FlatBufferBuilder64 &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_a(float a) {
|
||||
fbb_.AddElement<float>(RootTable::VT_A, a, 0.0f);
|
||||
}
|
||||
void add_b(::flatbuffers::Offset<::flatbuffers::Vector<uint8_t>> b) {
|
||||
fbb_.AddOffset(RootTable::VT_B, b);
|
||||
}
|
||||
void add_big_vector(::flatbuffers::Offset64<::flatbuffers::Vector64<uint8_t>> big_vector) {
|
||||
fbb_.AddOffset(RootTable::VT_BIG_VECTOR, big_vector);
|
||||
}
|
||||
explicit RootTableBuilder(::flatbuffers::FlatBufferBuilder64 &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<RootTable> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<RootTable>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<RootTable> CreateRootTable(
|
||||
::flatbuffers::FlatBufferBuilder64 &_fbb,
|
||||
float a = 0.0f,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<uint8_t>> b = 0,
|
||||
::flatbuffers::Offset64<::flatbuffers::Vector64<uint8_t>> big_vector = 0) {
|
||||
RootTableBuilder builder_(_fbb);
|
||||
builder_.add_big_vector(big_vector);
|
||||
builder_.add_b(b);
|
||||
builder_.add_a(a);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<RootTable> CreateRootTableDirect(
|
||||
::flatbuffers::FlatBufferBuilder64 &_fbb,
|
||||
float a = 0.0f,
|
||||
const std::vector<uint8_t> *b = nullptr,
|
||||
const std::vector<uint8_t> *big_vector = nullptr) {
|
||||
auto big_vector__ = big_vector ? _fbb.CreateVector64(*big_vector) : 0;
|
||||
auto b__ = b ? _fbb.CreateVector<uint8_t>(*b) : 0;
|
||||
return v2::CreateRootTable(
|
||||
_fbb,
|
||||
a,
|
||||
b__,
|
||||
big_vector__);
|
||||
}
|
||||
|
||||
::flatbuffers::Offset<RootTable> CreateRootTable(::flatbuffers::FlatBufferBuilder64 &_fbb, const RootTableT *_o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
|
||||
|
||||
inline bool operator==(const RootTableT &lhs, const RootTableT &rhs) {
|
||||
return
|
||||
(lhs.a == rhs.a) &&
|
||||
(lhs.b == rhs.b) &&
|
||||
(lhs.big_vector == rhs.big_vector);
|
||||
}
|
||||
|
||||
inline bool operator!=(const RootTableT &lhs, const RootTableT &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
|
||||
inline RootTableT *RootTable::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
auto _o = std::unique_ptr<RootTableT>(new RootTableT());
|
||||
UnPackTo(_o.get(), _resolver);
|
||||
return _o.release();
|
||||
}
|
||||
|
||||
inline void RootTable::UnPackTo(RootTableT *_o, const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
(void)_o;
|
||||
(void)_resolver;
|
||||
{ auto _e = a(); _o->a = _e; }
|
||||
{ auto _e = b(); if (_e) { _o->b.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->b.begin()); } }
|
||||
{ auto _e = big_vector(); if (_e) { _o->big_vector.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->big_vector.begin()); } }
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<RootTable> CreateRootTable(::flatbuffers::FlatBufferBuilder64 &_fbb, const RootTableT *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
return RootTable::Pack(_fbb, _o, _rehasher);
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<RootTable> RootTable::Pack(::flatbuffers::FlatBufferBuilder64 &_fbb, const RootTableT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
(void)_rehasher;
|
||||
(void)_o;
|
||||
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder64 *__fbb; const RootTableT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||
auto _a = _o->a;
|
||||
auto _b = _o->b.size() ? _fbb.CreateVector(_o->b) : 0;
|
||||
auto _big_vector = _o->big_vector.size() ? _fbb.CreateVector64(_o->big_vector) : 0;
|
||||
return v2::CreateRootTable(
|
||||
_fbb,
|
||||
_a,
|
||||
_b,
|
||||
_big_vector);
|
||||
}
|
||||
|
||||
inline const ::flatbuffers::TypeTable *RootTableTypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_FLOAT, 0, -1 },
|
||||
{ ::flatbuffers::ET_UCHAR, 1, -1 },
|
||||
{ ::flatbuffers::ET_UCHAR, 1, -1 }
|
||||
};
|
||||
static const char * const names[] = {
|
||||
"a",
|
||||
"b",
|
||||
"big_vector"
|
||||
};
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_TABLE, 3, type_codes, nullptr, nullptr, nullptr, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
inline const v2::RootTable *GetRootTable(const void *buf) {
|
||||
return ::flatbuffers::GetRoot<v2::RootTable>(buf);
|
||||
}
|
||||
|
||||
inline const v2::RootTable *GetSizePrefixedRootTable(const void *buf) {
|
||||
return ::flatbuffers::GetSizePrefixedRoot<v2::RootTable,::flatbuffers::uoffset64_t>(buf);
|
||||
}
|
||||
|
||||
inline RootTable *GetMutableRootTable(void *buf) {
|
||||
return ::flatbuffers::GetMutableRoot<RootTable>(buf);
|
||||
}
|
||||
|
||||
inline v2::RootTable *GetMutableSizePrefixedRootTable(void *buf) {
|
||||
return ::flatbuffers::GetMutableSizePrefixedRoot<v2::RootTable,::flatbuffers::uoffset64_t>(buf);
|
||||
}
|
||||
|
||||
template <bool B = false>
|
||||
inline bool VerifyRootTableBuffer(
|
||||
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||
return verifier.template VerifyBuffer<v2::RootTable>(nullptr);
|
||||
}
|
||||
|
||||
template <bool B = false>
|
||||
inline bool VerifySizePrefixedRootTableBuffer(
|
||||
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||
return verifier.template VerifySizePrefixedBuffer<v2::RootTable,::flatbuffers::uoffset64_t>(nullptr);
|
||||
}
|
||||
|
||||
inline void FinishRootTableBuffer(
|
||||
::flatbuffers::FlatBufferBuilder64 &fbb,
|
||||
::flatbuffers::Offset<v2::RootTable> root) {
|
||||
fbb.Finish(root);
|
||||
}
|
||||
|
||||
inline void FinishSizePrefixedRootTableBuffer(
|
||||
::flatbuffers::FlatBufferBuilder64 &fbb,
|
||||
::flatbuffers::Offset<v2::RootTable> root) {
|
||||
fbb.FinishSizePrefixed(root);
|
||||
}
|
||||
|
||||
inline std::unique_ptr<v2::RootTableT> UnPackRootTable(
|
||||
const void *buf,
|
||||
const ::flatbuffers::resolver_function_t *res = nullptr) {
|
||||
return std::unique_ptr<v2::RootTableT>(GetRootTable(buf)->UnPack(res));
|
||||
}
|
||||
|
||||
inline std::unique_ptr<v2::RootTableT> UnPackSizePrefixedRootTable(
|
||||
const void *buf,
|
||||
const ::flatbuffers::resolver_function_t *res = nullptr) {
|
||||
return std::unique_ptr<v2::RootTableT>(GetSizePrefixedRootTable(buf)->UnPack(res));
|
||||
}
|
||||
|
||||
} // namespace v2
|
||||
|
||||
#endif // FLATBUFFERS_GENERATED_V2_V2_H_
|
||||
@@ -11,9 +11,9 @@
|
||||
#include "flatbuffers/buffer.h"
|
||||
#include "flatbuffers/flatbuffer_builder.h"
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
#include "tests/64bit/evolution/v1.fbs.h"
|
||||
#include "tests/64bit/evolution/v2.fbs.h"
|
||||
#include "tests/64bit/test_64bit.fbs.h"
|
||||
#include "tests/64bit/evolution/v1_generated.h"
|
||||
#include "tests/64bit/evolution/v2_generated.h"
|
||||
#include "tests/64bit/test_64bit_generated.h"
|
||||
#include "tests/test_assert.h"
|
||||
|
||||
namespace flatbuffers {
|
||||
|
||||
683
tests/64bit/test_64bit_generated.h
Normal file
683
tests/64bit/test_64bit_generated.h
Normal file
@@ -0,0 +1,683 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
|
||||
#ifndef FLATBUFFERS_GENERATED_TEST64BIT_H_
|
||||
#define FLATBUFFERS_GENERATED_TEST64BIT_H_
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||
// generated, otherwise it may not be compatible.
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 19,
|
||||
"Non-compatible flatbuffers version included");
|
||||
|
||||
// For access to the binary schema that produced this file.
|
||||
#include "test_64bit_bfbs_generated.h"
|
||||
|
||||
struct LeafStruct;
|
||||
|
||||
struct WrapperTable;
|
||||
struct WrapperTableBuilder;
|
||||
struct WrapperTableT;
|
||||
|
||||
struct RootTable;
|
||||
struct RootTableBuilder;
|
||||
struct RootTableT;
|
||||
|
||||
bool operator==(const LeafStruct &lhs, const LeafStruct &rhs);
|
||||
bool operator!=(const LeafStruct &lhs, const LeafStruct &rhs);
|
||||
bool operator==(const WrapperTableT &lhs, const WrapperTableT &rhs);
|
||||
bool operator!=(const WrapperTableT &lhs, const WrapperTableT &rhs);
|
||||
bool operator==(const RootTableT &lhs, const RootTableT &rhs);
|
||||
bool operator!=(const RootTableT &lhs, const RootTableT &rhs);
|
||||
|
||||
inline const ::flatbuffers::TypeTable *LeafStructTypeTable();
|
||||
|
||||
inline const ::flatbuffers::TypeTable *WrapperTableTypeTable();
|
||||
|
||||
inline const ::flatbuffers::TypeTable *RootTableTypeTable();
|
||||
|
||||
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) LeafStruct FLATBUFFERS_FINAL_CLASS {
|
||||
private:
|
||||
int32_t a_;
|
||||
int32_t padding0__;
|
||||
double b_;
|
||||
|
||||
public:
|
||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return LeafStructTypeTable();
|
||||
}
|
||||
LeafStruct()
|
||||
: a_(0),
|
||||
padding0__(0),
|
||||
b_(0) {
|
||||
(void)padding0__;
|
||||
}
|
||||
LeafStruct(int32_t _a, double _b)
|
||||
: a_(::flatbuffers::EndianScalar(_a)),
|
||||
padding0__(0),
|
||||
b_(::flatbuffers::EndianScalar(_b)) {
|
||||
(void)padding0__;
|
||||
}
|
||||
int32_t a() const {
|
||||
return ::flatbuffers::EndianScalar(a_);
|
||||
}
|
||||
void mutate_a(int32_t _a) {
|
||||
::flatbuffers::WriteScalar(&a_, _a);
|
||||
}
|
||||
double b() const {
|
||||
return ::flatbuffers::EndianScalar(b_);
|
||||
}
|
||||
void mutate_b(double _b) {
|
||||
::flatbuffers::WriteScalar(&b_, _b);
|
||||
}
|
||||
};
|
||||
FLATBUFFERS_STRUCT_END(LeafStruct, 16);
|
||||
|
||||
inline bool operator==(const LeafStruct &lhs, const LeafStruct &rhs) {
|
||||
return
|
||||
(lhs.a() == rhs.a()) &&
|
||||
(lhs.b() == rhs.b());
|
||||
}
|
||||
|
||||
inline bool operator!=(const LeafStruct &lhs, const LeafStruct &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
|
||||
struct WrapperTableT : public ::flatbuffers::NativeTable {
|
||||
typedef WrapperTable TableType;
|
||||
std::vector<int8_t> vector{};
|
||||
};
|
||||
|
||||
struct WrapperTable FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef WrapperTableT NativeTableType;
|
||||
typedef WrapperTableBuilder Builder;
|
||||
typedef RootTableBinarySchema BinarySchema;
|
||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return WrapperTableTypeTable();
|
||||
}
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_VECTOR = 4
|
||||
};
|
||||
const ::flatbuffers::Vector<int8_t> *vector() const {
|
||||
return GetPointer64<const ::flatbuffers::Vector<int8_t> *>(VT_VECTOR);
|
||||
}
|
||||
::flatbuffers::Vector<int8_t> *mutable_vector() {
|
||||
return GetPointer64<::flatbuffers::Vector<int8_t> *>(VT_VECTOR);
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyOffset64(verifier, VT_VECTOR) &&
|
||||
verifier.VerifyVector(vector()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
WrapperTableT *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
void UnPackTo(WrapperTableT *_o, const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
static ::flatbuffers::Offset<WrapperTable> Pack(::flatbuffers::FlatBufferBuilder64 &_fbb, const WrapperTableT* _o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
};
|
||||
|
||||
struct WrapperTableBuilder {
|
||||
typedef WrapperTable Table;
|
||||
::flatbuffers::FlatBufferBuilder64 &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_vector(::flatbuffers::Offset64<::flatbuffers::Vector<int8_t>> vector) {
|
||||
fbb_.AddOffset(WrapperTable::VT_VECTOR, vector);
|
||||
}
|
||||
explicit WrapperTableBuilder(::flatbuffers::FlatBufferBuilder64 &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<WrapperTable> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<WrapperTable>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<WrapperTable> CreateWrapperTable(
|
||||
::flatbuffers::FlatBufferBuilder64 &_fbb,
|
||||
::flatbuffers::Offset64<::flatbuffers::Vector<int8_t>> vector = 0) {
|
||||
WrapperTableBuilder builder_(_fbb);
|
||||
builder_.add_vector(vector);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<WrapperTable> CreateWrapperTableDirect(
|
||||
::flatbuffers::FlatBufferBuilder64 &_fbb,
|
||||
const std::vector<int8_t> *vector = nullptr) {
|
||||
auto vector__ = vector ? _fbb.CreateVector64<::flatbuffers::Vector>(*vector) : 0;
|
||||
return CreateWrapperTable(
|
||||
_fbb,
|
||||
vector__);
|
||||
}
|
||||
|
||||
::flatbuffers::Offset<WrapperTable> CreateWrapperTable(::flatbuffers::FlatBufferBuilder64 &_fbb, const WrapperTableT *_o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
|
||||
struct RootTableT : public ::flatbuffers::NativeTable {
|
||||
typedef RootTable TableType;
|
||||
std::vector<uint8_t> far_vector{};
|
||||
int32_t a = 0;
|
||||
std::string far_string{};
|
||||
std::vector<uint8_t> big_bool_vector{};
|
||||
std::vector<uint8_t> big_vector{};
|
||||
std::string near_string{};
|
||||
std::vector<uint8_t> nested_root{};
|
||||
std::vector<LeafStruct> far_struct_vector{};
|
||||
std::vector<LeafStruct> big_struct_vector{};
|
||||
std::vector<std::unique_ptr<WrapperTableT>> many_vectors{};
|
||||
std::vector<uint8_t> forced_aligned_vector{};
|
||||
RootTableT() = default;
|
||||
RootTableT(const RootTableT &o);
|
||||
RootTableT(RootTableT&&) FLATBUFFERS_NOEXCEPT = default;
|
||||
RootTableT &operator=(RootTableT o) FLATBUFFERS_NOEXCEPT;
|
||||
};
|
||||
|
||||
struct RootTable FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef RootTableT NativeTableType;
|
||||
typedef RootTableBuilder Builder;
|
||||
typedef RootTableBinarySchema BinarySchema;
|
||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return RootTableTypeTable();
|
||||
}
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_FAR_VECTOR = 4,
|
||||
VT_A = 6,
|
||||
VT_FAR_STRING = 8,
|
||||
VT_BIG_BOOL_VECTOR = 10,
|
||||
VT_BIG_VECTOR = 12,
|
||||
VT_NEAR_STRING = 14,
|
||||
VT_NESTED_ROOT = 16,
|
||||
VT_FAR_STRUCT_VECTOR = 18,
|
||||
VT_BIG_STRUCT_VECTOR = 20,
|
||||
VT_MANY_VECTORS = 22,
|
||||
VT_FORCED_ALIGNED_VECTOR = 24
|
||||
};
|
||||
const ::flatbuffers::Vector<uint8_t> *far_vector() const {
|
||||
return GetPointer64<const ::flatbuffers::Vector<uint8_t> *>(VT_FAR_VECTOR);
|
||||
}
|
||||
::flatbuffers::Vector<uint8_t> *mutable_far_vector() {
|
||||
return GetPointer64<::flatbuffers::Vector<uint8_t> *>(VT_FAR_VECTOR);
|
||||
}
|
||||
int32_t a() const {
|
||||
return GetField<int32_t>(VT_A, 0);
|
||||
}
|
||||
bool mutate_a(int32_t _a = 0) {
|
||||
return SetField<int32_t>(VT_A, _a, 0);
|
||||
}
|
||||
const ::flatbuffers::String *far_string() const {
|
||||
return GetPointer64<const ::flatbuffers::String *>(VT_FAR_STRING);
|
||||
}
|
||||
::flatbuffers::String *mutable_far_string() {
|
||||
return GetPointer64<::flatbuffers::String *>(VT_FAR_STRING);
|
||||
}
|
||||
const ::flatbuffers::Vector64<uint8_t> *big_bool_vector() const {
|
||||
return GetPointer64<const ::flatbuffers::Vector64<uint8_t> *>(VT_BIG_BOOL_VECTOR);
|
||||
}
|
||||
::flatbuffers::Vector64<uint8_t> *mutable_big_bool_vector() {
|
||||
return GetPointer64<::flatbuffers::Vector64<uint8_t> *>(VT_BIG_BOOL_VECTOR);
|
||||
}
|
||||
const ::flatbuffers::Vector64<uint8_t> *big_vector() const {
|
||||
return GetPointer64<const ::flatbuffers::Vector64<uint8_t> *>(VT_BIG_VECTOR);
|
||||
}
|
||||
::flatbuffers::Vector64<uint8_t> *mutable_big_vector() {
|
||||
return GetPointer64<::flatbuffers::Vector64<uint8_t> *>(VT_BIG_VECTOR);
|
||||
}
|
||||
const ::flatbuffers::String *near_string() const {
|
||||
return GetPointer<const ::flatbuffers::String *>(VT_NEAR_STRING);
|
||||
}
|
||||
::flatbuffers::String *mutable_near_string() {
|
||||
return GetPointer<::flatbuffers::String *>(VT_NEAR_STRING);
|
||||
}
|
||||
const ::flatbuffers::Vector64<uint8_t> *nested_root() const {
|
||||
return GetPointer64<const ::flatbuffers::Vector64<uint8_t> *>(VT_NESTED_ROOT);
|
||||
}
|
||||
::flatbuffers::Vector64<uint8_t> *mutable_nested_root() {
|
||||
return GetPointer64<::flatbuffers::Vector64<uint8_t> *>(VT_NESTED_ROOT);
|
||||
}
|
||||
const RootTable *nested_root_nested_root() const {
|
||||
const auto _f = nested_root();
|
||||
return _f ? ::flatbuffers::GetRoot<RootTable>(_f->Data())
|
||||
: nullptr;
|
||||
}
|
||||
const ::flatbuffers::Vector<const LeafStruct *> *far_struct_vector() const {
|
||||
return GetPointer64<const ::flatbuffers::Vector<const LeafStruct *> *>(VT_FAR_STRUCT_VECTOR);
|
||||
}
|
||||
::flatbuffers::Vector<const LeafStruct *> *mutable_far_struct_vector() {
|
||||
return GetPointer64<::flatbuffers::Vector<const LeafStruct *> *>(VT_FAR_STRUCT_VECTOR);
|
||||
}
|
||||
const ::flatbuffers::Vector64<const LeafStruct *> *big_struct_vector() const {
|
||||
return GetPointer64<const ::flatbuffers::Vector64<const LeafStruct *> *>(VT_BIG_STRUCT_VECTOR);
|
||||
}
|
||||
::flatbuffers::Vector64<const LeafStruct *> *mutable_big_struct_vector() {
|
||||
return GetPointer64<::flatbuffers::Vector64<const LeafStruct *> *>(VT_BIG_STRUCT_VECTOR);
|
||||
}
|
||||
const ::flatbuffers::Vector<::flatbuffers::Offset<WrapperTable>> *many_vectors() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<WrapperTable>> *>(VT_MANY_VECTORS);
|
||||
}
|
||||
::flatbuffers::Vector<::flatbuffers::Offset<WrapperTable>> *mutable_many_vectors() {
|
||||
return GetPointer<::flatbuffers::Vector<::flatbuffers::Offset<WrapperTable>> *>(VT_MANY_VECTORS);
|
||||
}
|
||||
const ::flatbuffers::Vector64<uint8_t> *forced_aligned_vector() const {
|
||||
return GetPointer64<const ::flatbuffers::Vector64<uint8_t> *>(VT_FORCED_ALIGNED_VECTOR);
|
||||
}
|
||||
::flatbuffers::Vector64<uint8_t> *mutable_forced_aligned_vector() {
|
||||
return GetPointer64<::flatbuffers::Vector64<uint8_t> *>(VT_FORCED_ALIGNED_VECTOR);
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyOffset64(verifier, VT_FAR_VECTOR) &&
|
||||
verifier.VerifyVector(far_vector()) &&
|
||||
VerifyField<int32_t>(verifier, VT_A, 4) &&
|
||||
VerifyOffset64(verifier, VT_FAR_STRING) &&
|
||||
verifier.VerifyString(far_string()) &&
|
||||
VerifyOffset64(verifier, VT_BIG_BOOL_VECTOR) &&
|
||||
verifier.VerifyVector(big_bool_vector()) &&
|
||||
VerifyOffset64(verifier, VT_BIG_VECTOR) &&
|
||||
verifier.VerifyVector(big_vector()) &&
|
||||
VerifyOffset(verifier, VT_NEAR_STRING) &&
|
||||
verifier.VerifyString(near_string()) &&
|
||||
VerifyOffset64(verifier, VT_NESTED_ROOT) &&
|
||||
verifier.VerifyVector(nested_root()) &&
|
||||
verifier.template VerifyNestedFlatBuffer<RootTable>(nested_root(), nullptr) &&
|
||||
VerifyOffset64(verifier, VT_FAR_STRUCT_VECTOR) &&
|
||||
verifier.VerifyVector(far_struct_vector()) &&
|
||||
VerifyOffset64(verifier, VT_BIG_STRUCT_VECTOR) &&
|
||||
verifier.VerifyVector(big_struct_vector()) &&
|
||||
VerifyOffset(verifier, VT_MANY_VECTORS) &&
|
||||
verifier.VerifyVector(many_vectors()) &&
|
||||
verifier.VerifyVectorOfTables(many_vectors()) &&
|
||||
VerifyOffset64(verifier, VT_FORCED_ALIGNED_VECTOR) &&
|
||||
verifier.VerifyVector(forced_aligned_vector()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
RootTableT *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
void UnPackTo(RootTableT *_o, const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
static ::flatbuffers::Offset<RootTable> Pack(::flatbuffers::FlatBufferBuilder64 &_fbb, const RootTableT* _o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
};
|
||||
|
||||
struct RootTableBuilder {
|
||||
typedef RootTable Table;
|
||||
::flatbuffers::FlatBufferBuilder64 &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_far_vector(::flatbuffers::Offset64<::flatbuffers::Vector<uint8_t>> far_vector) {
|
||||
fbb_.AddOffset(RootTable::VT_FAR_VECTOR, far_vector);
|
||||
}
|
||||
void add_a(int32_t a) {
|
||||
fbb_.AddElement<int32_t>(RootTable::VT_A, a, 0);
|
||||
}
|
||||
void add_far_string(::flatbuffers::Offset64<::flatbuffers::String> far_string) {
|
||||
fbb_.AddOffset(RootTable::VT_FAR_STRING, far_string);
|
||||
}
|
||||
void add_big_bool_vector(::flatbuffers::Offset64<::flatbuffers::Vector64<uint8_t>> big_bool_vector) {
|
||||
fbb_.AddOffset(RootTable::VT_BIG_BOOL_VECTOR, big_bool_vector);
|
||||
}
|
||||
void add_big_vector(::flatbuffers::Offset64<::flatbuffers::Vector64<uint8_t>> big_vector) {
|
||||
fbb_.AddOffset(RootTable::VT_BIG_VECTOR, big_vector);
|
||||
}
|
||||
void add_near_string(::flatbuffers::Offset<::flatbuffers::String> near_string) {
|
||||
fbb_.AddOffset(RootTable::VT_NEAR_STRING, near_string);
|
||||
}
|
||||
void add_nested_root(::flatbuffers::Offset64<::flatbuffers::Vector64<uint8_t>> nested_root) {
|
||||
fbb_.AddOffset(RootTable::VT_NESTED_ROOT, nested_root);
|
||||
}
|
||||
void add_far_struct_vector(::flatbuffers::Offset64<::flatbuffers::Vector<const LeafStruct *>> far_struct_vector) {
|
||||
fbb_.AddOffset(RootTable::VT_FAR_STRUCT_VECTOR, far_struct_vector);
|
||||
}
|
||||
void add_big_struct_vector(::flatbuffers::Offset64<::flatbuffers::Vector64<const LeafStruct *>> big_struct_vector) {
|
||||
fbb_.AddOffset(RootTable::VT_BIG_STRUCT_VECTOR, big_struct_vector);
|
||||
}
|
||||
void add_many_vectors(::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<WrapperTable>>> many_vectors) {
|
||||
fbb_.AddOffset(RootTable::VT_MANY_VECTORS, many_vectors);
|
||||
}
|
||||
void add_forced_aligned_vector(::flatbuffers::Offset64<::flatbuffers::Vector64<uint8_t>> forced_aligned_vector) {
|
||||
fbb_.AddOffset(RootTable::VT_FORCED_ALIGNED_VECTOR, forced_aligned_vector);
|
||||
}
|
||||
explicit RootTableBuilder(::flatbuffers::FlatBufferBuilder64 &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<RootTable> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<RootTable>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<RootTable> CreateRootTable(
|
||||
::flatbuffers::FlatBufferBuilder64 &_fbb,
|
||||
::flatbuffers::Offset64<::flatbuffers::Vector<uint8_t>> far_vector = 0,
|
||||
int32_t a = 0,
|
||||
::flatbuffers::Offset64<::flatbuffers::String> far_string = 0,
|
||||
::flatbuffers::Offset64<::flatbuffers::Vector64<uint8_t>> big_bool_vector = 0,
|
||||
::flatbuffers::Offset64<::flatbuffers::Vector64<uint8_t>> big_vector = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::String> near_string = 0,
|
||||
::flatbuffers::Offset64<::flatbuffers::Vector64<uint8_t>> nested_root = 0,
|
||||
::flatbuffers::Offset64<::flatbuffers::Vector<const LeafStruct *>> far_struct_vector = 0,
|
||||
::flatbuffers::Offset64<::flatbuffers::Vector64<const LeafStruct *>> big_struct_vector = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<WrapperTable>>> many_vectors = 0,
|
||||
::flatbuffers::Offset64<::flatbuffers::Vector64<uint8_t>> forced_aligned_vector = 0) {
|
||||
RootTableBuilder builder_(_fbb);
|
||||
builder_.add_forced_aligned_vector(forced_aligned_vector);
|
||||
builder_.add_big_struct_vector(big_struct_vector);
|
||||
builder_.add_nested_root(nested_root);
|
||||
builder_.add_big_vector(big_vector);
|
||||
builder_.add_big_bool_vector(big_bool_vector);
|
||||
builder_.add_many_vectors(many_vectors);
|
||||
builder_.add_far_struct_vector(far_struct_vector);
|
||||
builder_.add_near_string(near_string);
|
||||
builder_.add_far_string(far_string);
|
||||
builder_.add_a(a);
|
||||
builder_.add_far_vector(far_vector);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<RootTable> CreateRootTableDirect(
|
||||
::flatbuffers::FlatBufferBuilder64 &_fbb,
|
||||
const std::vector<uint8_t> *far_vector = nullptr,
|
||||
int32_t a = 0,
|
||||
const char *far_string = nullptr,
|
||||
const std::vector<uint8_t> *big_bool_vector = nullptr,
|
||||
const std::vector<uint8_t> *big_vector = nullptr,
|
||||
const char *near_string = nullptr,
|
||||
const std::vector<uint8_t> *nested_root = nullptr,
|
||||
const std::vector<LeafStruct> *far_struct_vector = nullptr,
|
||||
const std::vector<LeafStruct> *big_struct_vector = nullptr,
|
||||
const std::vector<::flatbuffers::Offset<WrapperTable>> *many_vectors = nullptr,
|
||||
const std::vector<uint8_t> *forced_aligned_vector = nullptr) {
|
||||
auto far_vector__ = far_vector ? _fbb.CreateVector64<::flatbuffers::Vector>(*far_vector) : 0;
|
||||
auto far_string__ = far_string ? _fbb.CreateString<::flatbuffers::Offset64>(far_string) : 0;
|
||||
auto big_bool_vector__ = big_bool_vector ? _fbb.CreateVector64(*big_bool_vector) : 0;
|
||||
auto big_vector__ = big_vector ? _fbb.CreateVector64(*big_vector) : 0;
|
||||
auto nested_root__ = nested_root ? _fbb.CreateVector64(*nested_root) : 0;
|
||||
auto far_struct_vector__ = far_struct_vector ? _fbb.CreateVectorOfStructs64<::flatbuffers::Vector>(*far_struct_vector) : 0;
|
||||
auto big_struct_vector__ = big_struct_vector ? _fbb.CreateVectorOfStructs64(*big_struct_vector) : 0;
|
||||
if (forced_aligned_vector) { _fbb.ForceVectorAlignment64(forced_aligned_vector->size(), sizeof(uint8_t), 32); }
|
||||
auto forced_aligned_vector__ = forced_aligned_vector ? _fbb.CreateVector64(*forced_aligned_vector) : 0;
|
||||
auto near_string__ = near_string ? _fbb.CreateString(near_string) : 0;
|
||||
auto many_vectors__ = many_vectors ? _fbb.CreateVector<::flatbuffers::Offset<WrapperTable>>(*many_vectors) : 0;
|
||||
return CreateRootTable(
|
||||
_fbb,
|
||||
far_vector__,
|
||||
a,
|
||||
far_string__,
|
||||
big_bool_vector__,
|
||||
big_vector__,
|
||||
near_string__,
|
||||
nested_root__,
|
||||
far_struct_vector__,
|
||||
big_struct_vector__,
|
||||
many_vectors__,
|
||||
forced_aligned_vector__);
|
||||
}
|
||||
|
||||
::flatbuffers::Offset<RootTable> CreateRootTable(::flatbuffers::FlatBufferBuilder64 &_fbb, const RootTableT *_o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
|
||||
|
||||
inline bool operator==(const WrapperTableT &lhs, const WrapperTableT &rhs) {
|
||||
return
|
||||
(lhs.vector == rhs.vector);
|
||||
}
|
||||
|
||||
inline bool operator!=(const WrapperTableT &lhs, const WrapperTableT &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
|
||||
inline WrapperTableT *WrapperTable::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
auto _o = std::unique_ptr<WrapperTableT>(new WrapperTableT());
|
||||
UnPackTo(_o.get(), _resolver);
|
||||
return _o.release();
|
||||
}
|
||||
|
||||
inline void WrapperTable::UnPackTo(WrapperTableT *_o, const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
(void)_o;
|
||||
(void)_resolver;
|
||||
{ auto _e = vector(); if (_e) { _o->vector.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->vector.begin()); } }
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<WrapperTable> CreateWrapperTable(::flatbuffers::FlatBufferBuilder64 &_fbb, const WrapperTableT *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
return WrapperTable::Pack(_fbb, _o, _rehasher);
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<WrapperTable> WrapperTable::Pack(::flatbuffers::FlatBufferBuilder64 &_fbb, const WrapperTableT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
(void)_rehasher;
|
||||
(void)_o;
|
||||
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder64 *__fbb; const WrapperTableT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||
auto _vector = _o->vector.size() ? _fbb.CreateVector64<::flatbuffers::Vector>(_o->vector) : 0;
|
||||
return CreateWrapperTable(
|
||||
_fbb,
|
||||
_vector);
|
||||
}
|
||||
|
||||
|
||||
inline bool operator==(const RootTableT &lhs, const RootTableT &rhs) {
|
||||
return
|
||||
(lhs.far_vector == rhs.far_vector) &&
|
||||
(lhs.a == rhs.a) &&
|
||||
(lhs.far_string == rhs.far_string) &&
|
||||
(lhs.big_bool_vector == rhs.big_bool_vector) &&
|
||||
(lhs.big_vector == rhs.big_vector) &&
|
||||
(lhs.near_string == rhs.near_string) &&
|
||||
(lhs.nested_root == rhs.nested_root) &&
|
||||
(lhs.far_struct_vector == rhs.far_struct_vector) &&
|
||||
(lhs.big_struct_vector == rhs.big_struct_vector) &&
|
||||
(lhs.many_vectors.size() == rhs.many_vectors.size() && std::equal(lhs.many_vectors.cbegin(), lhs.many_vectors.cend(), rhs.many_vectors.cbegin(), [](std::unique_ptr<WrapperTableT> const &a, std::unique_ptr<WrapperTableT> const &b) { return (a == b) || (a && b && *a == *b); })) &&
|
||||
(lhs.forced_aligned_vector == rhs.forced_aligned_vector);
|
||||
}
|
||||
|
||||
inline bool operator!=(const RootTableT &lhs, const RootTableT &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
|
||||
inline RootTableT::RootTableT(const RootTableT &o)
|
||||
: far_vector(o.far_vector),
|
||||
a(o.a),
|
||||
far_string(o.far_string),
|
||||
big_bool_vector(o.big_bool_vector),
|
||||
big_vector(o.big_vector),
|
||||
near_string(o.near_string),
|
||||
nested_root(o.nested_root),
|
||||
far_struct_vector(o.far_struct_vector),
|
||||
big_struct_vector(o.big_struct_vector),
|
||||
forced_aligned_vector(o.forced_aligned_vector) {
|
||||
many_vectors.reserve(o.many_vectors.size());
|
||||
for (const auto &many_vectors_ : o.many_vectors) { many_vectors.emplace_back((many_vectors_) ? new WrapperTableT(*many_vectors_) : nullptr); }
|
||||
}
|
||||
|
||||
inline RootTableT &RootTableT::operator=(RootTableT o) FLATBUFFERS_NOEXCEPT {
|
||||
std::swap(far_vector, o.far_vector);
|
||||
std::swap(a, o.a);
|
||||
std::swap(far_string, o.far_string);
|
||||
std::swap(big_bool_vector, o.big_bool_vector);
|
||||
std::swap(big_vector, o.big_vector);
|
||||
std::swap(near_string, o.near_string);
|
||||
std::swap(nested_root, o.nested_root);
|
||||
std::swap(far_struct_vector, o.far_struct_vector);
|
||||
std::swap(big_struct_vector, o.big_struct_vector);
|
||||
std::swap(many_vectors, o.many_vectors);
|
||||
std::swap(forced_aligned_vector, o.forced_aligned_vector);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline RootTableT *RootTable::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
auto _o = std::unique_ptr<RootTableT>(new RootTableT());
|
||||
UnPackTo(_o.get(), _resolver);
|
||||
return _o.release();
|
||||
}
|
||||
|
||||
inline void RootTable::UnPackTo(RootTableT *_o, const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
(void)_o;
|
||||
(void)_resolver;
|
||||
{ auto _e = far_vector(); if (_e) { _o->far_vector.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->far_vector.begin()); } }
|
||||
{ auto _e = a(); _o->a = _e; }
|
||||
{ auto _e = far_string(); if (_e) _o->far_string = _e->str(); }
|
||||
{ auto _e = big_bool_vector(); if (_e) { _o->big_bool_vector.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->big_bool_vector.begin()); } }
|
||||
{ auto _e = big_vector(); if (_e) { _o->big_vector.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->big_vector.begin()); } }
|
||||
{ auto _e = near_string(); if (_e) _o->near_string = _e->str(); }
|
||||
{ auto _e = nested_root(); if (_e) { _o->nested_root.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->nested_root.begin()); } }
|
||||
{ auto _e = far_struct_vector(); if (_e) { _o->far_struct_vector.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->far_struct_vector[_i] = *_e->Get(_i); } } else { _o->far_struct_vector.resize(0); } }
|
||||
{ auto _e = big_struct_vector(); if (_e) { _o->big_struct_vector.resize(_e->size()); for (::flatbuffers::uoffset64_t _i = 0; _i < _e->size(); _i++) { _o->big_struct_vector[_i] = *_e->Get(_i); } } else { _o->big_struct_vector.resize(0); } }
|
||||
{ auto _e = many_vectors(); if (_e) { _o->many_vectors.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->many_vectors[_i]) { _e->Get(_i)->UnPackTo(_o->many_vectors[_i].get(), _resolver); } else { _o->many_vectors[_i] = std::unique_ptr<WrapperTableT>(_e->Get(_i)->UnPack(_resolver)); } } } else { _o->many_vectors.resize(0); } }
|
||||
{ auto _e = forced_aligned_vector(); if (_e) { _o->forced_aligned_vector.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->forced_aligned_vector.begin()); } }
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<RootTable> CreateRootTable(::flatbuffers::FlatBufferBuilder64 &_fbb, const RootTableT *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
return RootTable::Pack(_fbb, _o, _rehasher);
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<RootTable> RootTable::Pack(::flatbuffers::FlatBufferBuilder64 &_fbb, const RootTableT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
(void)_rehasher;
|
||||
(void)_o;
|
||||
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder64 *__fbb; const RootTableT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||
auto _far_vector = _o->far_vector.size() ? _fbb.CreateVector64<::flatbuffers::Vector>(_o->far_vector) : 0;
|
||||
auto _a = _o->a;
|
||||
auto _far_string = _o->far_string.empty() ? 0 : _fbb.CreateString<::flatbuffers::Offset64>(_o->far_string);
|
||||
auto _big_bool_vector = _o->big_bool_vector.size() ? _fbb.CreateVector64(_o->big_bool_vector) : 0;
|
||||
auto _big_vector = _o->big_vector.size() ? _fbb.CreateVector64(_o->big_vector) : 0;
|
||||
auto _near_string = _o->near_string.empty() ? 0 : _fbb.CreateString(_o->near_string);
|
||||
auto _nested_root = _o->nested_root.size() ? _fbb.CreateVector64(_o->nested_root) : 0;
|
||||
auto _far_struct_vector = _o->far_struct_vector.size() ? _fbb.CreateVectorOfStructs64<::flatbuffers::Vector>(_o->far_struct_vector) : 0;
|
||||
auto _big_struct_vector = _o->big_struct_vector.size() ? _fbb.CreateVectorOfStructs64(_o->big_struct_vector) : 0;
|
||||
auto _many_vectors = _o->many_vectors.size() ? _fbb.CreateVector<::flatbuffers::Offset<WrapperTable>> (_o->many_vectors.size(), [](size_t i, _VectorArgs *__va) { return CreateWrapperTable(*__va->__fbb, __va->__o->many_vectors[i].get(), __va->__rehasher); }, &_va ) : 0;
|
||||
_fbb.ForceVectorAlignment64(_o->forced_aligned_vector.size(), sizeof(uint8_t), 32);
|
||||
auto _forced_aligned_vector = _o->forced_aligned_vector.size() ? _fbb.CreateVector64(_o->forced_aligned_vector) : 0;
|
||||
return CreateRootTable(
|
||||
_fbb,
|
||||
_far_vector,
|
||||
_a,
|
||||
_far_string,
|
||||
_big_bool_vector,
|
||||
_big_vector,
|
||||
_near_string,
|
||||
_nested_root,
|
||||
_far_struct_vector,
|
||||
_big_struct_vector,
|
||||
_many_vectors,
|
||||
_forced_aligned_vector);
|
||||
}
|
||||
|
||||
inline const ::flatbuffers::TypeTable *LeafStructTypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_INT, 0, -1 },
|
||||
{ ::flatbuffers::ET_DOUBLE, 0, -1 }
|
||||
};
|
||||
static const int64_t values[] = { 0, 8, 16 };
|
||||
static const char * const names[] = {
|
||||
"a",
|
||||
"b"
|
||||
};
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_STRUCT, 2, type_codes, nullptr, nullptr, values, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
inline const ::flatbuffers::TypeTable *WrapperTableTypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_CHAR, 1, -1 }
|
||||
};
|
||||
static const char * const names[] = {
|
||||
"vector"
|
||||
};
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_TABLE, 1, type_codes, nullptr, nullptr, nullptr, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
inline const ::flatbuffers::TypeTable *RootTableTypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_UCHAR, 1, -1 },
|
||||
{ ::flatbuffers::ET_INT, 0, -1 },
|
||||
{ ::flatbuffers::ET_STRING, 0, -1 },
|
||||
{ ::flatbuffers::ET_UCHAR, 1, -1 },
|
||||
{ ::flatbuffers::ET_UCHAR, 1, -1 },
|
||||
{ ::flatbuffers::ET_STRING, 0, -1 },
|
||||
{ ::flatbuffers::ET_UCHAR, 1, -1 },
|
||||
{ ::flatbuffers::ET_SEQUENCE, 1, 0 },
|
||||
{ ::flatbuffers::ET_SEQUENCE, 1, 0 },
|
||||
{ ::flatbuffers::ET_SEQUENCE, 1, 1 },
|
||||
{ ::flatbuffers::ET_UCHAR, 1, -1 }
|
||||
};
|
||||
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||
LeafStructTypeTable,
|
||||
WrapperTableTypeTable
|
||||
};
|
||||
static const char * const names[] = {
|
||||
"far_vector",
|
||||
"a",
|
||||
"far_string",
|
||||
"big_bool_vector",
|
||||
"big_vector",
|
||||
"near_string",
|
||||
"nested_root",
|
||||
"far_struct_vector",
|
||||
"big_struct_vector",
|
||||
"many_vectors",
|
||||
"forced_aligned_vector"
|
||||
};
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_TABLE, 11, type_codes, type_refs, nullptr, nullptr, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
inline const RootTable *GetRootTable(const void *buf) {
|
||||
return ::flatbuffers::GetRoot<RootTable>(buf);
|
||||
}
|
||||
|
||||
inline const RootTable *GetSizePrefixedRootTable(const void *buf) {
|
||||
return ::flatbuffers::GetSizePrefixedRoot<RootTable,::flatbuffers::uoffset64_t>(buf);
|
||||
}
|
||||
|
||||
inline RootTable *GetMutableRootTable(void *buf) {
|
||||
return ::flatbuffers::GetMutableRoot<RootTable>(buf);
|
||||
}
|
||||
|
||||
inline RootTable *GetMutableSizePrefixedRootTable(void *buf) {
|
||||
return ::flatbuffers::GetMutableSizePrefixedRoot<RootTable,::flatbuffers::uoffset64_t>(buf);
|
||||
}
|
||||
|
||||
template <bool B = false>
|
||||
inline bool VerifyRootTableBuffer(
|
||||
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||
return verifier.template VerifyBuffer<RootTable>(nullptr);
|
||||
}
|
||||
|
||||
template <bool B = false>
|
||||
inline bool VerifySizePrefixedRootTableBuffer(
|
||||
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||
return verifier.template VerifySizePrefixedBuffer<RootTable,::flatbuffers::uoffset64_t>(nullptr);
|
||||
}
|
||||
|
||||
inline void FinishRootTableBuffer(
|
||||
::flatbuffers::FlatBufferBuilder64 &fbb,
|
||||
::flatbuffers::Offset<RootTable> root) {
|
||||
fbb.Finish(root);
|
||||
}
|
||||
|
||||
inline void FinishSizePrefixedRootTableBuffer(
|
||||
::flatbuffers::FlatBufferBuilder64 &fbb,
|
||||
::flatbuffers::Offset<RootTable> root) {
|
||||
fbb.FinishSizePrefixed(root);
|
||||
}
|
||||
|
||||
inline std::unique_ptr<RootTableT> UnPackRootTable(
|
||||
const void *buf,
|
||||
const ::flatbuffers::resolver_function_t *res = nullptr) {
|
||||
return std::unique_ptr<RootTableT>(GetRootTable(buf)->UnPack(res));
|
||||
}
|
||||
|
||||
inline std::unique_ptr<RootTableT> UnPackSizePrefixedRootTable(
|
||||
const void *buf,
|
||||
const ::flatbuffers::resolver_function_t *res = nullptr) {
|
||||
return std::unique_ptr<RootTableT>(GetSizePrefixedRootTable(buf)->UnPack(res));
|
||||
}
|
||||
|
||||
#endif // FLATBUFFERS_GENERATED_TEST64BIT_H_
|
||||
@@ -24,12 +24,21 @@ cc_test(
|
||||
name = "flatbuffers_test",
|
||||
testonly = 1,
|
||||
srcs = [
|
||||
"64bit/evolution/v1_generated.h",
|
||||
"64bit/evolution/v2_generated.h",
|
||||
"64bit/offset64_test.cpp",
|
||||
"64bit/offset64_test.h",
|
||||
"64bit/test_64bit_bfbs_generated.h",
|
||||
"64bit/test_64bit_generated.h",
|
||||
"alignment_test.cpp",
|
||||
"alignment_test.h",
|
||||
"alignment_test_generated.h",
|
||||
"default_vectors_strings_test.cpp",
|
||||
"default_vectors_strings_test.h",
|
||||
"evolution_test.cpp",
|
||||
"evolution_test.h",
|
||||
"evolution_test/evolution_v1_generated.h",
|
||||
"evolution_test/evolution_v2_generated.h",
|
||||
"flexbuffers_test.cpp",
|
||||
"flexbuffers_test.h",
|
||||
"fuzz_test.cpp",
|
||||
@@ -37,13 +46,18 @@ cc_test(
|
||||
"is_quiet_nan.h",
|
||||
"json_test.cpp",
|
||||
"json_test.h",
|
||||
"key_field/key_field_sample_generated.h",
|
||||
"key_field_test.cpp",
|
||||
"key_field_test.h",
|
||||
"monster_test.cpp",
|
||||
"monster_test.h",
|
||||
"monster_test_bfbs_generated.h",
|
||||
"namespace_test/namespace_test1_generated.h",
|
||||
"namespace_test/namespace_test2_generated.h",
|
||||
"native_inline_table_test_generated.h",
|
||||
"native_type_test_impl.cpp",
|
||||
"native_type_test_impl.h",
|
||||
"optional_scalars_generated.h",
|
||||
"optional_scalars_test.cpp",
|
||||
"optional_scalars_test.h",
|
||||
"parser_test.cpp",
|
||||
@@ -57,10 +71,13 @@ cc_test(
|
||||
"test_assert.h",
|
||||
"test_builder.cpp",
|
||||
"test_builder.h",
|
||||
"union_underlying_type_test_generated.h",
|
||||
"union_vector/union_vector_generated.h",
|
||||
"util_test.cpp",
|
||||
"util_test.h",
|
||||
"vector_table_naked_ptr_test.cpp",
|
||||
"vector_table_naked_ptr/vector_table_naked_ptr_generated.h",
|
||||
"vector_table_naked_ptr_test.h",
|
||||
"vector_table_naked_ptr_test.cpp",
|
||||
],
|
||||
copts = [
|
||||
"-DFLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE",
|
||||
@@ -70,8 +87,13 @@ cc_test(
|
||||
":arrays_test.bfbs",
|
||||
":arrays_test.fbs",
|
||||
":arrays_test.golden",
|
||||
":evolution_test/evolution_v1.fbs",
|
||||
":evolution_test/evolution_v1.json",
|
||||
":evolution_test/evolution_v2.fbs",
|
||||
":evolution_test/evolution_v2.json",
|
||||
":include_test/include_test1.fbs",
|
||||
":include_test/sub/include_test2.fbs",
|
||||
":key_field/key_field_sample.fbs",
|
||||
":monster_extra.fbs",
|
||||
":monster_test.bfbs",
|
||||
":monster_test.fbs",
|
||||
@@ -82,6 +104,7 @@ cc_test(
|
||||
":name_clash_test/invalid_test2.fbs",
|
||||
":name_clash_test/valid_test1.fbs",
|
||||
":name_clash_test/valid_test2.fbs",
|
||||
":native_type_test.fbs",
|
||||
":optional_scalars.fbs",
|
||||
":optional_scalars.json",
|
||||
":optional_scalars_defaults.json",
|
||||
@@ -103,8 +126,8 @@ cc_test(
|
||||
":prototest/twice-id.proto",
|
||||
":prototest/use-reserved-id.proto",
|
||||
":unicode_test.json",
|
||||
"//tests/evolution_test:test_data",
|
||||
"//tests/union_vector:test_data",
|
||||
":union_vector/union_vector.fbs",
|
||||
":union_vector/union_vector.json",
|
||||
],
|
||||
includes = [
|
||||
"",
|
||||
@@ -116,18 +139,9 @@ cc_test(
|
||||
":default_vectors_strings_test_cc_fbs",
|
||||
":monster_extra_cc_fbs",
|
||||
":monster_test_cc_fbs",
|
||||
":native_inline_table_test_cc_fbs",
|
||||
":native_type_test_cc_fbs",
|
||||
":optional_scalars_cc_fbs",
|
||||
":union_underlying_type_test_cc_fbs",
|
||||
":vector_table_naked_ptr_cc_fbs",
|
||||
"//:flatbuffers",
|
||||
"//src:generate_fbs",
|
||||
"//tests/64bit:offset64_test",
|
||||
"//tests/evolution_test:evolution_v1_cc_fbs",
|
||||
"//tests/evolution_test:evolution_v2_cc_fbs",
|
||||
"//tests/key_field:key_field_sample_cc_fbs",
|
||||
"//tests/union_vector:union_vector_cc_fbs",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -137,10 +151,7 @@ cc_library(
|
||||
name = "test_assert",
|
||||
srcs = ["test_assert.cpp"],
|
||||
hdrs = ["test_assert.h"],
|
||||
visibility = [
|
||||
"//grpc/tests:__subpackages__",
|
||||
"//tests:__subpackages__",
|
||||
],
|
||||
visibility = ["//grpc/tests:__subpackages__"],
|
||||
deps = ["//:flatbuffers"],
|
||||
)
|
||||
|
||||
@@ -234,20 +245,11 @@ cc_library(
|
||||
flatbuffer_cc_library(
|
||||
name = "monster_extra_cc_fbs",
|
||||
srcs = ["monster_extra.fbs"],
|
||||
filename_suffix = ".fbs",
|
||||
flatc_args = [
|
||||
"--gen-compare",
|
||||
"--gen-mutable",
|
||||
"--gen-object-api",
|
||||
"--reflect-names",
|
||||
"--filename-suffix .fbs",
|
||||
],
|
||||
)
|
||||
|
||||
flatbuffer_cc_library(
|
||||
name = "arrays_test_cc_fbs",
|
||||
srcs = ["arrays_test.fbs"],
|
||||
filename_suffix = ".fbs",
|
||||
flatc_args = [
|
||||
"--gen-object-api",
|
||||
"--gen-compare",
|
||||
@@ -256,39 +258,27 @@ flatbuffer_cc_library(
|
||||
"--reflect-names",
|
||||
"--cpp-ptr-type flatbuffers::unique_ptr",
|
||||
"--scoped-enums",
|
||||
"--filename-suffix .fbs",
|
||||
],
|
||||
)
|
||||
|
||||
flatbuffer_cc_library(
|
||||
name = "native_type_test_cc_fbs",
|
||||
srcs = ["native_type_test.fbs"],
|
||||
filename_suffix = ".fbs",
|
||||
flatc_args = [
|
||||
"--gen-object-api",
|
||||
"--gen-mutable",
|
||||
"--cpp-ptr-type flatbuffers::unique_ptr",
|
||||
"--filename-suffix .fbs",
|
||||
],
|
||||
)
|
||||
|
||||
flatbuffer_cc_library(
|
||||
name = "alignment_test_cc_fbs",
|
||||
srcs = ["alignment_test.fbs"],
|
||||
filename_suffix = ".fbs",
|
||||
flatc_args = [
|
||||
"--gen-compare",
|
||||
"--gen-mutable",
|
||||
"--gen-object-api",
|
||||
"--reflect-names",
|
||||
"--filename-suffix .fbs",
|
||||
],
|
||||
)
|
||||
|
||||
flatbuffer_cc_library(
|
||||
name = "default_vectors_strings_test_cc_fbs",
|
||||
srcs = ["default_vectors_strings_test.fbs"],
|
||||
filename_suffix = ".fbs",
|
||||
flatc_args = [
|
||||
"--gen-compare",
|
||||
"--gen-mutable",
|
||||
@@ -296,58 +286,5 @@ flatbuffer_cc_library(
|
||||
"--reflect-names",
|
||||
"--filename-suffix .fbs",
|
||||
],
|
||||
)
|
||||
|
||||
flatbuffer_cc_library(
|
||||
name = "native_inline_table_test_cc_fbs",
|
||||
srcs = ["native_inline_table_test.fbs"],
|
||||
filename_suffix = ".fbs",
|
||||
flatc_args = [
|
||||
"--gen-compare",
|
||||
"--gen-mutable",
|
||||
"--gen-object-api",
|
||||
"--reflect-names",
|
||||
"--filename-suffix .fbs",
|
||||
],
|
||||
)
|
||||
|
||||
flatbuffer_cc_library(
|
||||
name = "optional_scalars_cc_fbs",
|
||||
srcs = ["optional_scalars.fbs"],
|
||||
filename_suffix = ".fbs",
|
||||
flatc_args = [
|
||||
"--gen-compare",
|
||||
"--gen-mutable",
|
||||
"--gen-object-api",
|
||||
"--reflect-names",
|
||||
"--filename-suffix .fbs",
|
||||
],
|
||||
)
|
||||
|
||||
flatbuffer_cc_library(
|
||||
name = "union_underlying_type_test_cc_fbs",
|
||||
srcs = ["union_underlying_type_test.fbs"],
|
||||
filename_suffix = ".fbs",
|
||||
flatc_args = [
|
||||
"--gen-compare",
|
||||
"--gen-mutable",
|
||||
"--gen-object-api",
|
||||
"--reflect-names",
|
||||
"--filename-suffix .fbs",
|
||||
"--scoped-enums",
|
||||
],
|
||||
)
|
||||
|
||||
flatbuffer_cc_library(
|
||||
name = "vector_table_naked_ptr_cc_fbs",
|
||||
srcs = ["vector_table_naked_ptr.fbs"],
|
||||
filename_suffix = ".fbs",
|
||||
flatc_args = [
|
||||
"--gen-compare",
|
||||
"--gen-mutable",
|
||||
"--gen-object-api",
|
||||
"--reflect-names",
|
||||
"--filename-suffix .fbs",
|
||||
"--cpp-ptr-type naked",
|
||||
],
|
||||
filename_suffix = ".fbs"
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright 2014 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -90,6 +90,9 @@ namespace Google.FlatBuffers.Test
|
||||
fbb.AddOffset(test1.Value);
|
||||
var testArrayOfString = fbb.EndVector();
|
||||
|
||||
var longsVector = Monster.CreateVectorOfLongsVector(fbb, new long[] { 1, 100, 10000, 1000000, 100000000 });
|
||||
var doublesVector = Monster.CreateVectorOfDoublesVector(fbb, new double[] { -1.7976931348623157e+308, 0, 1.7976931348623157e+308 });
|
||||
|
||||
Monster.StartMonster(fbb);
|
||||
Monster.AddPos(fbb, Vec3.CreateVec3(fbb, 1.0f, 2.0f, 3.0f, 3.0,
|
||||
Color.Green, (short)5, (sbyte)6));
|
||||
@@ -102,6 +105,8 @@ namespace Google.FlatBuffers.Test
|
||||
Monster.AddTestarrayofstring(fbb, testArrayOfString);
|
||||
Monster.AddTestbool(fbb, true);
|
||||
Monster.AddTestarrayoftables(fbb, sortMons);
|
||||
Monster.AddVectorOfLongs(fbb, longsVector);
|
||||
Monster.AddVectorOfDoubles(fbb, doublesVector);
|
||||
var mon = Monster.EndMonster(fbb);
|
||||
|
||||
if (sizePrefix)
|
||||
@@ -285,6 +290,13 @@ namespace Google.FlatBuffers.Test
|
||||
Assert.IsTrue(monster.GetTestarrayofboolsBytes().HasValue);
|
||||
}
|
||||
#endif
|
||||
|
||||
var longArray = monster.GetVectorOfLongsArray();
|
||||
Assert.AreEqual(5, longArray.Length);
|
||||
Assert.AreEqual(100, longArray[1]);
|
||||
|
||||
var doublesArray = monster.GetVectorOfDoublesArray();
|
||||
Assert.AreEqual(3, doublesArray.Length);
|
||||
}
|
||||
|
||||
[FlatBuffersTestMethod]
|
||||
|
||||
249
tests/FlatBuffers.Test/FlatBuffersFixedLengthArrayTests.cs
Normal file
249
tests/FlatBuffers.Test/FlatBuffersFixedLengthArrayTests.cs
Normal file
@@ -0,0 +1,249 @@
|
||||
/*
|
||||
* Copyright 2025 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using MyGame.Example;
|
||||
|
||||
namespace Google.FlatBuffers.Test
|
||||
{
|
||||
[FlatBuffersTestClass]
|
||||
public class FlatBuffersFixedLengthArrayTests
|
||||
{
|
||||
[FlatBuffersTestMethod]
|
||||
public void FixedLengthArray_LengthConstantsMatchSchema_ReturnTrue()
|
||||
{
|
||||
const int nestedALength = NestedStruct.ALength;
|
||||
const int nestedCLength = NestedStruct.CLength;
|
||||
const int nestedDLength = NestedStruct.DLength;
|
||||
const int arrayBLength = ArrayStruct.BLength;
|
||||
const int arrayFLength = ArrayStruct.FLength;
|
||||
|
||||
Assert.AreEqual(2, nestedALength);
|
||||
Assert.AreEqual(2, nestedCLength);
|
||||
Assert.AreEqual(2, nestedDLength);
|
||||
Assert.AreEqual(15, arrayBLength);
|
||||
Assert.AreEqual(2, arrayFLength);
|
||||
}
|
||||
|
||||
#if ENABLE_SPAN_T
|
||||
[FlatBuffersTestMethod]
|
||||
public void FixedLengthArray_GetBytesSpanLengthIsCorrect_ReturnTrue()
|
||||
{
|
||||
var builder = new FlatBufferBuilder(1024);
|
||||
var ints = new int[] { 1, 2 };
|
||||
var enumB = TestEnum.A;
|
||||
var enums = new TestEnum[] { TestEnum.B, TestEnum.C };
|
||||
var longs = new long[] { 10L, 20L };
|
||||
|
||||
var structOffset = NestedStruct.CreateNestedStruct(builder, ints, enumB, enums, longs);
|
||||
builder.Finish(structOffset.Value);
|
||||
|
||||
var bb = builder.DataBuffer;
|
||||
var nestedStruct = new NestedStruct();
|
||||
nestedStruct.__assign(bb.Length - builder.Offset, bb);
|
||||
|
||||
Span<int> intSpan = nestedStruct.GetABytes();
|
||||
Span<TestEnum> enumSpan = nestedStruct.GetCBytes();
|
||||
Span<long> longSpan = nestedStruct.GetDBytes();
|
||||
|
||||
Assert.AreEqual(intSpan.Length, NestedStruct.ALength);
|
||||
Assert.AreEqual(enumSpan.Length, NestedStruct.CLength);
|
||||
Assert.AreEqual(longSpan.Length, NestedStruct.DLength);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !ENABLE_SPAN_T
|
||||
[FlatBuffersTestMethod]
|
||||
public void FixedLengthArray_GetBytesArraySegmentLengthIsCorrect_ReturnTrue()
|
||||
{
|
||||
var builder = new FlatBufferBuilder(1024);
|
||||
var ints = new int[] { 1, 2 };
|
||||
var enumB = TestEnum.A;
|
||||
var enums = new TestEnum[] { TestEnum.B, TestEnum.C };
|
||||
var longs = new long[] { 10L, 20L };
|
||||
|
||||
var structOffset = NestedStruct.CreateNestedStruct(builder, ints, enumB, enums, longs);
|
||||
builder.Finish(structOffset.Value);
|
||||
|
||||
var buffer = builder.DataBuffer;
|
||||
var nestedStruct = new NestedStruct();
|
||||
nestedStruct.__assign(buffer.Length - builder.Offset, buffer);
|
||||
|
||||
Assert.IsTrue(nestedStruct.GetABytes().HasValue);
|
||||
Assert.IsTrue(nestedStruct.GetCBytes().HasValue);
|
||||
Assert.IsTrue(nestedStruct.GetDBytes().HasValue);
|
||||
|
||||
ArraySegment<byte> intSegment = nestedStruct.GetABytes().Value;
|
||||
ArraySegment<byte> enumSegment = nestedStruct.GetCBytes().Value;
|
||||
ArraySegment<byte> longSegment = nestedStruct.GetDBytes().Value;
|
||||
|
||||
Assert.AreEqual(intSegment.Count, NestedStruct.ALength * sizeof(int));
|
||||
Assert.AreEqual(enumSegment.Count, NestedStruct.CLength * sizeof(sbyte));
|
||||
Assert.AreEqual(longSegment.Count, NestedStruct.DLength * sizeof(long));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLE_SPAN_T
|
||||
[FlatBuffersTestMethod]
|
||||
public void FixedLengthArray_GetBytesSpanEquality_ReturnTrue()
|
||||
{
|
||||
var builder = new FlatBufferBuilder(1024);
|
||||
|
||||
var floatA = 3.14f;
|
||||
var intArray = Enumerable.Range(1, 15).ToArray();
|
||||
var byteC = (sbyte)42;
|
||||
var intE = 999;
|
||||
var longArray = new long[] { 5000L, 6000L };
|
||||
|
||||
var nestedInts = new int[2, 2] { { 10, 20 }, { 30, 40 } };
|
||||
var nestedEnumB = new TestEnum[] { TestEnum.A, TestEnum.B };
|
||||
var nestedEnums = new TestEnum[2, 2] { { TestEnum.A, TestEnum.B }, { TestEnum.C, TestEnum.A } };
|
||||
var nestedLongs = new long[2, 2] { { 100L, 200L }, { 300L, 400L } };
|
||||
|
||||
var structOffset = ArrayStruct.CreateArrayStruct(builder, floatA, intArray, byteC,
|
||||
nestedInts, nestedEnumB, nestedEnums, nestedLongs, intE, longArray);
|
||||
|
||||
ArrayTable.StartArrayTable(builder);
|
||||
ArrayTable.AddA(builder, structOffset);
|
||||
var rootTable = ArrayTable.EndArrayTable(builder);
|
||||
builder.Finish(rootTable.Value);
|
||||
|
||||
var finishedBytes = builder.SizedByteArray();
|
||||
ByteBuffer bb = new ByteBuffer(finishedBytes);
|
||||
ArrayTable arrayTable = ArrayTable.GetRootAsArrayTable(bb);
|
||||
ArrayStruct arrayStruct = arrayTable.A.Value;
|
||||
|
||||
Assert.AreEqual(byteC, arrayStruct.C);
|
||||
Assert.AreEqual(intE, arrayStruct.E);
|
||||
|
||||
Assert.IsTrue(arrayStruct.GetBBytes().SequenceEqual(intArray));
|
||||
Assert.IsTrue(arrayStruct.GetFBytes().SequenceEqual(longArray));
|
||||
|
||||
// Test nested struct arrays
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
var nestedStruct = arrayStruct.D(i);
|
||||
|
||||
var nestedIntSpan = nestedStruct.GetABytes();
|
||||
var expectedNestedInts = new int[] { nestedInts[i, 0], nestedInts[i, 1] };
|
||||
Assert.IsTrue(nestedIntSpan.SequenceEqual(expectedNestedInts));
|
||||
|
||||
Assert.AreEqual(nestedEnumB[i], nestedStruct.B);
|
||||
|
||||
var nestedEnumSpan = nestedStruct.GetCBytes();
|
||||
var expectedNestedEnums = new TestEnum[] { nestedEnums[i, 0], nestedEnums[i, 1] };
|
||||
Assert.IsTrue(nestedEnumSpan.SequenceEqual(expectedNestedEnums));
|
||||
|
||||
var nestedLongSpan = nestedStruct.GetDBytes();
|
||||
var expectedNestedLongs = new long[] { nestedLongs[i, 0], nestedLongs[i, 1] };
|
||||
Assert.IsTrue(nestedLongSpan.SequenceEqual(expectedNestedLongs));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !ENABLE_SPAN_T
|
||||
[FlatBuffersTestMethod]
|
||||
public void FixedLengthArray_GetBytesArraySegmentEquality_ReturnTrue()
|
||||
{
|
||||
var builder = new FlatBufferBuilder(1024);
|
||||
|
||||
var floatA = 3.14f;
|
||||
var intArray = Enumerable.Range(1, 15).ToArray();
|
||||
var byteC = (sbyte)42;
|
||||
var intE = 999;
|
||||
var longArray = new long[] { 5000L, 6000L };
|
||||
|
||||
var nestedInts = new int[2, 2] { { 10, 20 }, { 30, 40 } };
|
||||
var nestedEnumB = new TestEnum[] { TestEnum.A, TestEnum.B };
|
||||
var nestedEnums = new TestEnum[2, 2] { { TestEnum.A, TestEnum.B }, { TestEnum.C, TestEnum.A } };
|
||||
var nestedLongs = new long[2, 2] { { 100L, 200L }, { 300L, 400L } };
|
||||
|
||||
var structOffset = ArrayStruct.CreateArrayStruct(builder, floatA, intArray, byteC,
|
||||
nestedInts, nestedEnumB, nestedEnums, nestedLongs, intE, longArray);
|
||||
|
||||
ArrayTable.StartArrayTable(builder);
|
||||
ArrayTable.AddA(builder, structOffset);
|
||||
var rootTable = ArrayTable.EndArrayTable(builder);
|
||||
builder.Finish(rootTable.Value);
|
||||
|
||||
var finishedBytes = builder.SizedByteArray();
|
||||
ByteBuffer bb = new ByteBuffer(finishedBytes);
|
||||
ArrayTable arrayTable = ArrayTable.GetRootAsArrayTable(bb);
|
||||
ArrayStruct arrayStruct = arrayTable.A.Value;
|
||||
|
||||
// Test that we can read basic scalars correctly
|
||||
Assert.AreEqual(byteC, arrayStruct.C);
|
||||
Assert.AreEqual(intE, arrayStruct.E);
|
||||
|
||||
Assert.IsTrue(arrayStruct.GetBBytes().HasValue);
|
||||
var intSegment = arrayStruct.GetBBytes().Value;
|
||||
for (int i = 0, offset = 0; i < intArray.Length; i++, offset += sizeof(int))
|
||||
{
|
||||
var segmentValue = BitConverter.ToInt32(intSegment.Array,
|
||||
intSegment.Offset + offset);
|
||||
Assert.AreEqual(intArray[i], segmentValue);
|
||||
}
|
||||
|
||||
Assert.IsTrue(arrayStruct.GetFBytes().HasValue);
|
||||
var longSegment = arrayStruct.GetFBytes().Value;
|
||||
for (int i = 0, offset = 0; i < longArray.Length; i++, offset += sizeof(long))
|
||||
{
|
||||
var segmentValue = BitConverter.ToInt64(longSegment.Array,
|
||||
longSegment.Offset + offset);
|
||||
Assert.AreEqual(longArray[i], segmentValue);
|
||||
}
|
||||
|
||||
// Test nested struct arrays
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
var nestedStruct = arrayStruct.D(i);
|
||||
|
||||
Assert.IsTrue(nestedStruct.GetABytes().HasValue);
|
||||
var nestedIntSegment = nestedStruct.GetABytes().Value;
|
||||
var expectedNestedInts = new int[] { nestedInts[i, 0], nestedInts[i, 1] };
|
||||
for (int ii = 0, offset = 0; ii < NestedStruct.ALength; ii++, offset += sizeof(int))
|
||||
{
|
||||
var segmentValue = BitConverter.ToInt32(nestedIntSegment.Array,
|
||||
nestedIntSegment.Offset + offset);
|
||||
Assert.AreEqual(expectedNestedInts[ii], segmentValue);
|
||||
}
|
||||
|
||||
Assert.AreEqual(nestedEnumB[i], nestedStruct.B);
|
||||
|
||||
Assert.IsTrue(nestedStruct.GetCBytes().HasValue);
|
||||
var nestedEnumSegment = nestedStruct.GetCBytes().Value;
|
||||
var expectedNestedEnums = new TestEnum[] { nestedEnums[i, 0], nestedEnums[i, 1] };
|
||||
for (int ii = 0, offset = 0; ii < NestedStruct.CLength; ii++, offset += sizeof(sbyte))
|
||||
{
|
||||
var segmentValue = (TestEnum)nestedEnumSegment.Array[nestedEnumSegment.Offset + offset];
|
||||
Assert.AreEqual(expectedNestedEnums[ii], segmentValue);
|
||||
}
|
||||
|
||||
Assert.IsTrue(nestedStruct.GetDBytes().HasValue);
|
||||
var nestedLongSegment = nestedStruct.GetDBytes().Value;
|
||||
var expectedNestedLongs = new long[] { nestedLongs[i, 0], nestedLongs[i, 1] };
|
||||
for (int ii = 0, offset = 0; ii < NestedStruct.DLength; ii++, offset += sizeof(long))
|
||||
{
|
||||
var segmentValue = BitConverter.ToInt64(nestedLongSegment.Array,
|
||||
nestedLongSegment.Offset + offset);
|
||||
Assert.AreEqual(expectedNestedLongs[ii], segmentValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,12 @@ public struct ArrayStruct : IFlatbufferObject
|
||||
public float A { get { return __p.bb.GetFloat(__p.bb_pos + 0); } }
|
||||
public void MutateA(float a) { __p.bb.PutFloat(__p.bb_pos + 0, a); }
|
||||
public int B(int j) { return __p.bb.GetInt(__p.bb_pos + 4 + j * 4); }
|
||||
public const int BLength = 15;
|
||||
#if ENABLE_SPAN_T
|
||||
public Span<int> GetBBytes() { return System.Runtime.InteropServices.MemoryMarshal.Cast<byte, int>(__p.bb.ToSpan(__p.bb_pos + 4, 60)); }
|
||||
#else
|
||||
public ArraySegment<byte>? GetBBytes() { return __p.bb.ToArraySegment(__p.bb_pos + 4, 60);}
|
||||
#endif
|
||||
public void MutateB(int j, int b) { __p.bb.PutInt(__p.bb_pos + 4 + j * 4, b); }
|
||||
public sbyte C { get { return __p.bb.GetSbyte(__p.bb_pos + 64); } }
|
||||
public void MutateC(sbyte c) { __p.bb.PutSbyte(__p.bb_pos + 64, c); }
|
||||
@@ -26,6 +32,12 @@ public struct ArrayStruct : IFlatbufferObject
|
||||
public int E { get { return __p.bb.GetInt(__p.bb_pos + 136); } }
|
||||
public void MutateE(int e) { __p.bb.PutInt(__p.bb_pos + 136, e); }
|
||||
public long F(int j) { return __p.bb.GetLong(__p.bb_pos + 144 + j * 8); }
|
||||
public const int FLength = 2;
|
||||
#if ENABLE_SPAN_T
|
||||
public Span<long> GetFBytes() { return System.Runtime.InteropServices.MemoryMarshal.Cast<byte, long>(__p.bb.ToSpan(__p.bb_pos + 144, 16)); }
|
||||
#else
|
||||
public ArraySegment<byte>? GetFBytes() { return __p.bb.ToArraySegment(__p.bb_pos + 144, 16);}
|
||||
#endif
|
||||
public void MutateF(int j, long f) { __p.bb.PutLong(__p.bb_pos + 144 + j * 8, f); }
|
||||
|
||||
public static Offset<MyGame.Example.ArrayStruct> CreateArrayStruct(FlatBufferBuilder builder, float A, int[] B, sbyte C, int[,] d_A, MyGame.Example.TestEnum[] d_B, MyGame.Example.TestEnum[,] d_C, long[,] d_D, int E, long[] F) {
|
||||
|
||||
@@ -28,6 +28,8 @@ function Monster.New()
|
||||
return o
|
||||
end
|
||||
|
||||
local FileIdentifier = "MONS"
|
||||
|
||||
function Monster.GetRootAsMonster(buf, offset)
|
||||
if type(buf) == "string" then
|
||||
buf = flatbuffers.binaryArray.New(buf)
|
||||
@@ -1099,4 +1101,12 @@ function Monster.End(builder)
|
||||
return builder:EndObject()
|
||||
end
|
||||
|
||||
function Monster.FinishMonsterBuffer(builder, offset)
|
||||
builder:FinishWithIdentifier(offset, FileIdentifier)
|
||||
end
|
||||
|
||||
function Monster.FinishSizePrefixedMonsterBuffer(builder, offset)
|
||||
builder:FinishSizePrefixedWithIdentifier(offset, FileIdentifier)
|
||||
end
|
||||
|
||||
return Monster
|
||||
@@ -914,6 +914,16 @@ def MonsterStartInventoryVector(builder, numElems):
|
||||
def StartInventoryVector(builder, numElems):
|
||||
return MonsterStartInventoryVector(builder, numElems)
|
||||
|
||||
def MonsterCreateInventoryVector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(1, len(data), 1)
|
||||
for item in reversed(data):
|
||||
builder.PrependUint8(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def CreateInventoryVector(builder, data):
|
||||
MonsterCreateInventoryVector(builder, data)
|
||||
|
||||
def MonsterAddColor(builder, color):
|
||||
builder.PrependUint8Slot(6, color, 8)
|
||||
|
||||
@@ -944,6 +954,16 @@ def MonsterStartTest4Vector(builder, numElems):
|
||||
def StartTest4Vector(builder, numElems):
|
||||
return MonsterStartTest4Vector(builder, numElems)
|
||||
|
||||
def MonsterCreateTest4Vector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(4, len(data), 2)
|
||||
for item in reversed(data):
|
||||
item.Pack(builder)
|
||||
return builder.EndVector()
|
||||
|
||||
def CreateTest4Vector(builder, data):
|
||||
MonsterCreateTest4Vector(builder, data)
|
||||
|
||||
def MonsterAddTestarrayofstring(builder, testarrayofstring):
|
||||
builder.PrependUOffsetTRelativeSlot(10, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayofstring), 0)
|
||||
|
||||
@@ -956,6 +976,12 @@ def MonsterStartTestarrayofstringVector(builder, numElems):
|
||||
def StartTestarrayofstringVector(builder, numElems):
|
||||
return MonsterStartTestarrayofstringVector(builder, numElems)
|
||||
|
||||
def MonsterCreateTestarrayofstringVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def CreateTestarrayofstringVector(builder, data):
|
||||
MonsterCreateTestarrayofstringVector(builder, data)
|
||||
|
||||
def MonsterAddTestarrayoftables(builder, testarrayoftables):
|
||||
builder.PrependUOffsetTRelativeSlot(11, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayoftables), 0)
|
||||
|
||||
@@ -968,6 +994,12 @@ def MonsterStartTestarrayoftablesVector(builder, numElems):
|
||||
def StartTestarrayoftablesVector(builder, numElems):
|
||||
return MonsterStartTestarrayoftablesVector(builder, numElems)
|
||||
|
||||
def MonsterCreateTestarrayoftablesVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def CreateTestarrayoftablesVector(builder, data):
|
||||
MonsterCreateTestarrayoftablesVector(builder, data)
|
||||
|
||||
def MonsterAddEnemy(builder, enemy):
|
||||
builder.PrependUOffsetTRelativeSlot(12, flatbuffers.number_types.UOffsetTFlags.py_type(enemy), 0)
|
||||
|
||||
@@ -986,6 +1018,16 @@ def MonsterStartTestnestedflatbufferVector(builder, numElems):
|
||||
def StartTestnestedflatbufferVector(builder, numElems):
|
||||
return MonsterStartTestnestedflatbufferVector(builder, numElems)
|
||||
|
||||
def MonsterCreateTestnestedflatbufferVector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(1, len(data), 1)
|
||||
for item in reversed(data):
|
||||
builder.PrependUint8(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def CreateTestnestedflatbufferVector(builder, data):
|
||||
MonsterCreateTestnestedflatbufferVector(builder, data)
|
||||
|
||||
def MonsterMakeTestnestedflatbufferVectorFromBytes(builder, bytes):
|
||||
builder.StartVector(1, len(bytes), 1)
|
||||
builder.head = builder.head - len(bytes)
|
||||
@@ -1065,6 +1107,16 @@ def MonsterStartTestarrayofboolsVector(builder, numElems):
|
||||
def StartTestarrayofboolsVector(builder, numElems):
|
||||
return MonsterStartTestarrayofboolsVector(builder, numElems)
|
||||
|
||||
def MonsterCreateTestarrayofboolsVector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(1, len(data), 1)
|
||||
for item in reversed(data):
|
||||
builder.PrependBool(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def CreateTestarrayofboolsVector(builder, data):
|
||||
MonsterCreateTestarrayofboolsVector(builder, data)
|
||||
|
||||
def MonsterAddTestf(builder, testf):
|
||||
builder.PrependFloat32Slot(25, testf, 3.14159)
|
||||
|
||||
@@ -1095,6 +1147,12 @@ def MonsterStartTestarrayofstring2Vector(builder, numElems):
|
||||
def StartTestarrayofstring2Vector(builder, numElems):
|
||||
return MonsterStartTestarrayofstring2Vector(builder, numElems)
|
||||
|
||||
def MonsterCreateTestarrayofstring2Vector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def CreateTestarrayofstring2Vector(builder, data):
|
||||
MonsterCreateTestarrayofstring2Vector(builder, data)
|
||||
|
||||
def MonsterAddTestarrayofsortedstruct(builder, testarrayofsortedstruct):
|
||||
builder.PrependUOffsetTRelativeSlot(29, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayofsortedstruct), 0)
|
||||
|
||||
@@ -1107,6 +1165,16 @@ def MonsterStartTestarrayofsortedstructVector(builder, numElems):
|
||||
def StartTestarrayofsortedstructVector(builder, numElems):
|
||||
return MonsterStartTestarrayofsortedstructVector(builder, numElems)
|
||||
|
||||
def MonsterCreateTestarrayofsortedstructVector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(8, len(data), 4)
|
||||
for item in reversed(data):
|
||||
item.Pack(builder)
|
||||
return builder.EndVector()
|
||||
|
||||
def CreateTestarrayofsortedstructVector(builder, data):
|
||||
MonsterCreateTestarrayofsortedstructVector(builder, data)
|
||||
|
||||
def MonsterAddFlex(builder, flex):
|
||||
builder.PrependUOffsetTRelativeSlot(30, flatbuffers.number_types.UOffsetTFlags.py_type(flex), 0)
|
||||
|
||||
@@ -1119,6 +1187,16 @@ def MonsterStartFlexVector(builder, numElems):
|
||||
def StartFlexVector(builder, numElems):
|
||||
return MonsterStartFlexVector(builder, numElems)
|
||||
|
||||
def MonsterCreateFlexVector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(1, len(data), 1)
|
||||
for item in reversed(data):
|
||||
builder.PrependUint8(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def CreateFlexVector(builder, data):
|
||||
MonsterCreateFlexVector(builder, data)
|
||||
|
||||
def MonsterAddTest5(builder, test5):
|
||||
builder.PrependUOffsetTRelativeSlot(31, flatbuffers.number_types.UOffsetTFlags.py_type(test5), 0)
|
||||
|
||||
@@ -1131,6 +1209,16 @@ def MonsterStartTest5Vector(builder, numElems):
|
||||
def StartTest5Vector(builder, numElems):
|
||||
return MonsterStartTest5Vector(builder, numElems)
|
||||
|
||||
def MonsterCreateTest5Vector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(4, len(data), 2)
|
||||
for item in reversed(data):
|
||||
item.Pack(builder)
|
||||
return builder.EndVector()
|
||||
|
||||
def CreateTest5Vector(builder, data):
|
||||
MonsterCreateTest5Vector(builder, data)
|
||||
|
||||
def MonsterAddVectorOfLongs(builder, vectorOfLongs):
|
||||
builder.PrependUOffsetTRelativeSlot(32, flatbuffers.number_types.UOffsetTFlags.py_type(vectorOfLongs), 0)
|
||||
|
||||
@@ -1143,6 +1231,16 @@ def MonsterStartVectorOfLongsVector(builder, numElems):
|
||||
def StartVectorOfLongsVector(builder, numElems):
|
||||
return MonsterStartVectorOfLongsVector(builder, numElems)
|
||||
|
||||
def MonsterCreateVectorOfLongsVector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(8, len(data), 8)
|
||||
for item in reversed(data):
|
||||
builder.PrependInt64(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def CreateVectorOfLongsVector(builder, data):
|
||||
MonsterCreateVectorOfLongsVector(builder, data)
|
||||
|
||||
def MonsterAddVectorOfDoubles(builder, vectorOfDoubles):
|
||||
builder.PrependUOffsetTRelativeSlot(33, flatbuffers.number_types.UOffsetTFlags.py_type(vectorOfDoubles), 0)
|
||||
|
||||
@@ -1155,6 +1253,16 @@ def MonsterStartVectorOfDoublesVector(builder, numElems):
|
||||
def StartVectorOfDoublesVector(builder, numElems):
|
||||
return MonsterStartVectorOfDoublesVector(builder, numElems)
|
||||
|
||||
def MonsterCreateVectorOfDoublesVector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(8, len(data), 8)
|
||||
for item in reversed(data):
|
||||
builder.PrependFloat64(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def CreateVectorOfDoublesVector(builder, data):
|
||||
MonsterCreateVectorOfDoublesVector(builder, data)
|
||||
|
||||
def MonsterAddParentNamespaceTest(builder, parentNamespaceTest):
|
||||
builder.PrependUOffsetTRelativeSlot(34, flatbuffers.number_types.UOffsetTFlags.py_type(parentNamespaceTest), 0)
|
||||
|
||||
@@ -1173,6 +1281,12 @@ def MonsterStartVectorOfReferrablesVector(builder, numElems):
|
||||
def StartVectorOfReferrablesVector(builder, numElems):
|
||||
return MonsterStartVectorOfReferrablesVector(builder, numElems)
|
||||
|
||||
def MonsterCreateVectorOfReferrablesVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def CreateVectorOfReferrablesVector(builder, data):
|
||||
MonsterCreateVectorOfReferrablesVector(builder, data)
|
||||
|
||||
def MonsterAddSingleWeakReference(builder, singleWeakReference):
|
||||
builder.PrependUint64Slot(36, singleWeakReference, 0)
|
||||
|
||||
@@ -1191,6 +1305,16 @@ def MonsterStartVectorOfWeakReferencesVector(builder, numElems):
|
||||
def StartVectorOfWeakReferencesVector(builder, numElems):
|
||||
return MonsterStartVectorOfWeakReferencesVector(builder, numElems)
|
||||
|
||||
def MonsterCreateVectorOfWeakReferencesVector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(8, len(data), 8)
|
||||
for item in reversed(data):
|
||||
builder.PrependUint64(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def CreateVectorOfWeakReferencesVector(builder, data):
|
||||
MonsterCreateVectorOfWeakReferencesVector(builder, data)
|
||||
|
||||
def MonsterAddVectorOfStrongReferrables(builder, vectorOfStrongReferrables):
|
||||
builder.PrependUOffsetTRelativeSlot(38, flatbuffers.number_types.UOffsetTFlags.py_type(vectorOfStrongReferrables), 0)
|
||||
|
||||
@@ -1203,6 +1327,12 @@ def MonsterStartVectorOfStrongReferrablesVector(builder, numElems):
|
||||
def StartVectorOfStrongReferrablesVector(builder, numElems):
|
||||
return MonsterStartVectorOfStrongReferrablesVector(builder, numElems)
|
||||
|
||||
def MonsterCreateVectorOfStrongReferrablesVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def CreateVectorOfStrongReferrablesVector(builder, data):
|
||||
MonsterCreateVectorOfStrongReferrablesVector(builder, data)
|
||||
|
||||
def MonsterAddCoOwningReference(builder, coOwningReference):
|
||||
builder.PrependUint64Slot(39, coOwningReference, 0)
|
||||
|
||||
@@ -1221,6 +1351,16 @@ def MonsterStartVectorOfCoOwningReferencesVector(builder, numElems):
|
||||
def StartVectorOfCoOwningReferencesVector(builder, numElems):
|
||||
return MonsterStartVectorOfCoOwningReferencesVector(builder, numElems)
|
||||
|
||||
def MonsterCreateVectorOfCoOwningReferencesVector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(8, len(data), 8)
|
||||
for item in reversed(data):
|
||||
builder.PrependUint64(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def CreateVectorOfCoOwningReferencesVector(builder, data):
|
||||
MonsterCreateVectorOfCoOwningReferencesVector(builder, data)
|
||||
|
||||
def MonsterAddNonOwningReference(builder, nonOwningReference):
|
||||
builder.PrependUint64Slot(41, nonOwningReference, 0)
|
||||
|
||||
@@ -1239,6 +1379,16 @@ def MonsterStartVectorOfNonOwningReferencesVector(builder, numElems):
|
||||
def StartVectorOfNonOwningReferencesVector(builder, numElems):
|
||||
return MonsterStartVectorOfNonOwningReferencesVector(builder, numElems)
|
||||
|
||||
def MonsterCreateVectorOfNonOwningReferencesVector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(8, len(data), 8)
|
||||
for item in reversed(data):
|
||||
builder.PrependUint64(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def CreateVectorOfNonOwningReferencesVector(builder, data):
|
||||
MonsterCreateVectorOfNonOwningReferencesVector(builder, data)
|
||||
|
||||
def MonsterAddAnyUniqueType(builder, anyUniqueType):
|
||||
builder.PrependUint8Slot(43, anyUniqueType, 0)
|
||||
|
||||
@@ -1275,6 +1425,16 @@ def MonsterStartVectorOfEnumsVector(builder, numElems):
|
||||
def StartVectorOfEnumsVector(builder, numElems):
|
||||
return MonsterStartVectorOfEnumsVector(builder, numElems)
|
||||
|
||||
def MonsterCreateVectorOfEnumsVector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(1, len(data), 1)
|
||||
for item in reversed(data):
|
||||
builder.PrependUint8(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def CreateVectorOfEnumsVector(builder, data):
|
||||
MonsterCreateVectorOfEnumsVector(builder, data)
|
||||
|
||||
def MonsterAddSignedEnum(builder, signedEnum):
|
||||
builder.PrependInt8Slot(48, signedEnum, -1)
|
||||
|
||||
@@ -1293,6 +1453,16 @@ def MonsterStartTestrequirednestedflatbufferVector(builder, numElems):
|
||||
def StartTestrequirednestedflatbufferVector(builder, numElems):
|
||||
return MonsterStartTestrequirednestedflatbufferVector(builder, numElems)
|
||||
|
||||
def MonsterCreateTestrequirednestedflatbufferVector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(1, len(data), 1)
|
||||
for item in reversed(data):
|
||||
builder.PrependUint8(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def CreateTestrequirednestedflatbufferVector(builder, data):
|
||||
MonsterCreateTestrequirednestedflatbufferVector(builder, data)
|
||||
|
||||
def MonsterMakeTestrequirednestedflatbufferVectorFromBytes(builder, bytes):
|
||||
builder.StartVector(1, len(bytes), 1)
|
||||
builder.head = builder.head - len(bytes)
|
||||
@@ -1312,6 +1482,12 @@ def MonsterStartScalarKeySortedTablesVector(builder, numElems):
|
||||
def StartScalarKeySortedTablesVector(builder, numElems):
|
||||
return MonsterStartScalarKeySortedTablesVector(builder, numElems)
|
||||
|
||||
def MonsterCreateScalarKeySortedTablesVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def CreateScalarKeySortedTablesVector(builder, data):
|
||||
MonsterCreateScalarKeySortedTablesVector(builder, data)
|
||||
|
||||
def MonsterAddNativeInline(builder, nativeInline):
|
||||
builder.PrependStructSlot(51, flatbuffers.number_types.UOffsetTFlags.py_type(nativeInline), 0)
|
||||
|
||||
|
||||
@@ -17,12 +17,30 @@ public struct NestedStruct : IFlatbufferObject
|
||||
public NestedStruct __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
public int A(int j) { return __p.bb.GetInt(__p.bb_pos + 0 + j * 4); }
|
||||
public const int ALength = 2;
|
||||
#if ENABLE_SPAN_T
|
||||
public Span<int> GetABytes() { return System.Runtime.InteropServices.MemoryMarshal.Cast<byte, int>(__p.bb.ToSpan(__p.bb_pos + 0, 8)); }
|
||||
#else
|
||||
public ArraySegment<byte>? GetABytes() { return __p.bb.ToArraySegment(__p.bb_pos + 0, 8);}
|
||||
#endif
|
||||
public void MutateA(int j, int a) { __p.bb.PutInt(__p.bb_pos + 0 + j * 4, a); }
|
||||
public MyGame.Example.TestEnum B { get { return (MyGame.Example.TestEnum)__p.bb.GetSbyte(__p.bb_pos + 8); } }
|
||||
public void MutateB(MyGame.Example.TestEnum b) { __p.bb.PutSbyte(__p.bb_pos + 8, (sbyte)b); }
|
||||
public MyGame.Example.TestEnum C(int j) { return (MyGame.Example.TestEnum)__p.bb.GetSbyte(__p.bb_pos + 9 + j * 1); }
|
||||
public const int CLength = 2;
|
||||
#if ENABLE_SPAN_T
|
||||
public Span<MyGame.Example.TestEnum> GetCBytes() { return System.Runtime.InteropServices.MemoryMarshal.Cast<byte, MyGame.Example.TestEnum>(__p.bb.ToSpan(__p.bb_pos + 9, 2)); }
|
||||
#else
|
||||
public ArraySegment<byte>? GetCBytes() { return __p.bb.ToArraySegment(__p.bb_pos + 9, 2);}
|
||||
#endif
|
||||
public void MutateC(int j, MyGame.Example.TestEnum c) { __p.bb.PutSbyte(__p.bb_pos + 9 + j * 1, (sbyte)c); }
|
||||
public long D(int j) { return __p.bb.GetLong(__p.bb_pos + 16 + j * 8); }
|
||||
public const int DLength = 2;
|
||||
#if ENABLE_SPAN_T
|
||||
public Span<long> GetDBytes() { return System.Runtime.InteropServices.MemoryMarshal.Cast<byte, long>(__p.bb.ToSpan(__p.bb_pos + 16, 16)); }
|
||||
#else
|
||||
public ArraySegment<byte>? GetDBytes() { return __p.bb.ToArraySegment(__p.bb_pos + 16, 16);}
|
||||
#endif
|
||||
public void MutateD(int j, long d) { __p.bb.PutLong(__p.bb_pos + 16 + j * 8, d); }
|
||||
|
||||
public static Offset<MyGame.Example.NestedStruct> CreateNestedStruct(FlatBufferBuilder builder, int[] A, MyGame.Example.TestEnum B, MyGame.Example.TestEnum[] C, long[] D) {
|
||||
|
||||
@@ -230,6 +230,16 @@ def TypeAliasesStartV8Vector(builder, numElems):
|
||||
def StartV8Vector(builder, numElems):
|
||||
return TypeAliasesStartV8Vector(builder, numElems)
|
||||
|
||||
def TypeAliasesCreateV8Vector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(1, len(data), 1)
|
||||
for item in reversed(data):
|
||||
builder.PrependInt8(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def CreateV8Vector(builder, data):
|
||||
TypeAliasesCreateV8Vector(builder, data)
|
||||
|
||||
def TypeAliasesAddVf64(builder, vf64):
|
||||
builder.PrependUOffsetTRelativeSlot(11, flatbuffers.number_types.UOffsetTFlags.py_type(vf64), 0)
|
||||
|
||||
@@ -242,6 +252,16 @@ def TypeAliasesStartVf64Vector(builder, numElems):
|
||||
def StartVf64Vector(builder, numElems):
|
||||
return TypeAliasesStartVf64Vector(builder, numElems)
|
||||
|
||||
def TypeAliasesCreateVf64Vector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(8, len(data), 8)
|
||||
for item in reversed(data):
|
||||
builder.PrependFloat64(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def CreateVf64Vector(builder, data):
|
||||
TypeAliasesCreateVf64Vector(builder, data)
|
||||
|
||||
def TypeAliasesEnd(builder):
|
||||
return builder.EndObject()
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import flatbuffers
|
||||
from flatbuffers.compat import import_numpy
|
||||
from typing import Any
|
||||
from typing import Iterable
|
||||
np = import_numpy()
|
||||
|
||||
class MonsterExtra(object):
|
||||
@@ -205,6 +206,16 @@ def MonsterExtraStartDvecVector(builder, numElems: int) -> int:
|
||||
def StartDvecVector(builder, numElems: int) -> int:
|
||||
return MonsterExtraStartDvecVector(builder, numElems)
|
||||
|
||||
def MonsterExtraCreateDvecVector(builder: flatbuffers.Builder, data: Iterable[Any]) -> int:
|
||||
data = list(data)
|
||||
builder.StartVector(8, len(data), 8)
|
||||
for item in reversed(data):
|
||||
builder.PrependFloat64(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def CreateDvecVector(builder: flatbuffers.Builder, data: Iterable[Any]) -> int:
|
||||
MonsterExtraCreateDvecVector(builder, data)
|
||||
|
||||
def MonsterExtraAddFvec(builder: flatbuffers.Builder, fvec: int):
|
||||
builder.PrependUOffsetTRelativeSlot(9, flatbuffers.number_types.UOffsetTFlags.py_type(fvec), 0)
|
||||
|
||||
@@ -217,6 +228,16 @@ def MonsterExtraStartFvecVector(builder, numElems: int) -> int:
|
||||
def StartFvecVector(builder, numElems: int) -> int:
|
||||
return MonsterExtraStartFvecVector(builder, numElems)
|
||||
|
||||
def MonsterExtraCreateFvecVector(builder: flatbuffers.Builder, data: Iterable[Any]) -> int:
|
||||
data = list(data)
|
||||
builder.StartVector(4, len(data), 4)
|
||||
for item in reversed(data):
|
||||
builder.PrependFloat32(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def CreateFvecVector(builder: flatbuffers.Builder, data: Iterable[Any]) -> int:
|
||||
MonsterExtraCreateFvecVector(builder, data)
|
||||
|
||||
def MonsterExtraEnd(builder: flatbuffers.Builder) -> int:
|
||||
return builder.EndObject()
|
||||
|
||||
|
||||
@@ -77,9 +77,13 @@ def MonsterExtraAddF3(builder: flatbuffers.Builder, f3: float) -> None: ...
|
||||
def MonsterExtraAddDvec(builder: flatbuffers.Builder, dvec: uoffset) -> None: ...
|
||||
def MonsterExtraStartDvecVector(builder: flatbuffers.Builder, num_elems: int) -> uoffset: ...
|
||||
def StartDvecVector(builder: flatbuffers.Builder, num_elems: int) -> uoffset: ...
|
||||
def MonsterExtraCreateDvecVector(builder: flatbuffers.Builder, data: typing.Iterable[typing.Any]) -> uoffset: ...
|
||||
def CreateDvecVector(builder: flatbuffers.Builder, data: typing.Iterable[typing.Any]) -> uoffset: ...
|
||||
def MonsterExtraAddFvec(builder: flatbuffers.Builder, fvec: uoffset) -> None: ...
|
||||
def MonsterExtraStartFvecVector(builder: flatbuffers.Builder, num_elems: int) -> uoffset: ...
|
||||
def StartFvecVector(builder: flatbuffers.Builder, num_elems: int) -> uoffset: ...
|
||||
def MonsterExtraCreateFvecVector(builder: flatbuffers.Builder, data: typing.Iterable[typing.Any]) -> uoffset: ...
|
||||
def CreateFvecVector(builder: flatbuffers.Builder, data: typing.Iterable[typing.Any]) -> uoffset: ...
|
||||
def MonsterExtraEnd(builder: flatbuffers.Builder) -> uoffset: ...
|
||||
def End(builder: flatbuffers.Builder) -> uoffset: ...
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "flatbuffers/flatbuffer_builder.h"
|
||||
#include "flatbuffers/util.h"
|
||||
#include "test_assert.h"
|
||||
#include "tests/alignment_test.fbs.h"
|
||||
#include "tests/alignment_test_generated.h"
|
||||
|
||||
namespace flatbuffers {
|
||||
namespace tests {
|
||||
|
||||
932
tests/cpp17/generated_cpp17/optional_scalars2_generated.h
Normal file
932
tests/cpp17/generated_cpp17/optional_scalars2_generated.h
Normal file
@@ -0,0 +1,932 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
#ifndef FLATBUFFERS_GENERATED_OPTIONALSCALARS2_OPTIONAL_SCALARS_H_
|
||||
#define FLATBUFFERS_GENERATED_OPTIONALSCALARS2_OPTIONAL_SCALARS_H_
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
namespace optional_scalars {
|
||||
|
||||
struct ScalarStuff;
|
||||
struct ScalarStuffBuilder;
|
||||
struct ScalarStuffT;
|
||||
|
||||
inline const flatbuffers::TypeTable* ScalarStuffTypeTable();
|
||||
|
||||
enum class OptionalByte : int8_t {
|
||||
None = 0,
|
||||
One = 1,
|
||||
Two = 2,
|
||||
MIN = None,
|
||||
MAX = Two
|
||||
};
|
||||
|
||||
inline const OptionalByte (&EnumValuesOptionalByte())[3] {
|
||||
static const OptionalByte values[] = {OptionalByte::None, OptionalByte::One,
|
||||
OptionalByte::Two};
|
||||
return values;
|
||||
}
|
||||
|
||||
inline const char* const* EnumNamesOptionalByte() {
|
||||
static const char* const names[4] = {"None", "One", "Two", nullptr};
|
||||
return names;
|
||||
}
|
||||
|
||||
inline const char* EnumNameOptionalByte(OptionalByte e) {
|
||||
if (flatbuffers::IsOutRange(e, OptionalByte::None, OptionalByte::Two))
|
||||
return "";
|
||||
const size_t index = static_cast<size_t>(e);
|
||||
return EnumNamesOptionalByte()[index];
|
||||
}
|
||||
|
||||
struct ScalarStuffT : public flatbuffers::NativeTable {
|
||||
typedef ScalarStuff TableType;
|
||||
int8_t just_i8 = 0;
|
||||
flatbuffers::Optional<int8_t> maybe_i8 = flatbuffers::nullopt;
|
||||
int8_t default_i8 = 42;
|
||||
uint8_t just_u8 = 0;
|
||||
flatbuffers::Optional<uint8_t> maybe_u8 = flatbuffers::nullopt;
|
||||
uint8_t default_u8 = 42;
|
||||
int16_t just_i16 = 0;
|
||||
flatbuffers::Optional<int16_t> maybe_i16 = flatbuffers::nullopt;
|
||||
int16_t default_i16 = 42;
|
||||
uint16_t just_u16 = 0;
|
||||
flatbuffers::Optional<uint16_t> maybe_u16 = flatbuffers::nullopt;
|
||||
uint16_t default_u16 = 42;
|
||||
int32_t just_i32 = 0;
|
||||
flatbuffers::Optional<int32_t> maybe_i32 = flatbuffers::nullopt;
|
||||
int32_t default_i32 = 42;
|
||||
uint32_t just_u32 = 0;
|
||||
flatbuffers::Optional<uint32_t> maybe_u32 = flatbuffers::nullopt;
|
||||
uint32_t default_u32 = 42;
|
||||
int64_t just_i64 = 0;
|
||||
flatbuffers::Optional<int64_t> maybe_i64 = flatbuffers::nullopt;
|
||||
int64_t default_i64 = 42LL;
|
||||
uint64_t just_u64 = 0;
|
||||
flatbuffers::Optional<uint64_t> maybe_u64 = flatbuffers::nullopt;
|
||||
uint64_t default_u64 = 42ULL;
|
||||
float just_f32 = 0.0f;
|
||||
flatbuffers::Optional<float> maybe_f32 = flatbuffers::nullopt;
|
||||
float default_f32 = 42.0f;
|
||||
double just_f64 = 0.0;
|
||||
flatbuffers::Optional<double> maybe_f64 = flatbuffers::nullopt;
|
||||
double default_f64 = 42.0;
|
||||
bool just_bool = false;
|
||||
flatbuffers::Optional<bool> maybe_bool = flatbuffers::nullopt;
|
||||
bool default_bool = true;
|
||||
optional_scalars::OptionalByte just_enum =
|
||||
optional_scalars::OptionalByte::None;
|
||||
flatbuffers::Optional<optional_scalars::OptionalByte> maybe_enum =
|
||||
flatbuffers::nullopt;
|
||||
optional_scalars::OptionalByte default_enum =
|
||||
optional_scalars::OptionalByte::One;
|
||||
};
|
||||
|
||||
struct ScalarStuff FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
typedef ScalarStuffT NativeTableType;
|
||||
typedef ScalarStuffBuilder Builder;
|
||||
struct Traits;
|
||||
static const flatbuffers::TypeTable* MiniReflectTypeTable() {
|
||||
return ScalarStuffTypeTable();
|
||||
}
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_JUST_I8 = 4,
|
||||
VT_MAYBE_I8 = 6,
|
||||
VT_DEFAULT_I8 = 8,
|
||||
VT_JUST_U8 = 10,
|
||||
VT_MAYBE_U8 = 12,
|
||||
VT_DEFAULT_U8 = 14,
|
||||
VT_JUST_I16 = 16,
|
||||
VT_MAYBE_I16 = 18,
|
||||
VT_DEFAULT_I16 = 20,
|
||||
VT_JUST_U16 = 22,
|
||||
VT_MAYBE_U16 = 24,
|
||||
VT_DEFAULT_U16 = 26,
|
||||
VT_JUST_I32 = 28,
|
||||
VT_MAYBE_I32 = 30,
|
||||
VT_DEFAULT_I32 = 32,
|
||||
VT_JUST_U32 = 34,
|
||||
VT_MAYBE_U32 = 36,
|
||||
VT_DEFAULT_U32 = 38,
|
||||
VT_JUST_I64 = 40,
|
||||
VT_MAYBE_I64 = 42,
|
||||
VT_DEFAULT_I64 = 44,
|
||||
VT_JUST_U64 = 46,
|
||||
VT_MAYBE_U64 = 48,
|
||||
VT_DEFAULT_U64 = 50,
|
||||
VT_JUST_F32 = 52,
|
||||
VT_MAYBE_F32 = 54,
|
||||
VT_DEFAULT_F32 = 56,
|
||||
VT_JUST_F64 = 58,
|
||||
VT_MAYBE_F64 = 60,
|
||||
VT_DEFAULT_F64 = 62,
|
||||
VT_JUST_BOOL = 64,
|
||||
VT_MAYBE_BOOL = 66,
|
||||
VT_DEFAULT_BOOL = 68,
|
||||
VT_JUST_ENUM = 70,
|
||||
VT_MAYBE_ENUM = 72,
|
||||
VT_DEFAULT_ENUM = 74
|
||||
};
|
||||
int8_t just_i8() const { return GetField<int8_t>(VT_JUST_I8, 0); }
|
||||
bool mutate_just_i8(int8_t _just_i8) {
|
||||
return SetField<int8_t>(VT_JUST_I8, _just_i8, 0);
|
||||
}
|
||||
flatbuffers::Optional<int8_t> maybe_i8() const {
|
||||
return GetOptional<int8_t, int8_t>(VT_MAYBE_I8);
|
||||
}
|
||||
bool mutate_maybe_i8(int8_t _maybe_i8) {
|
||||
return SetField<int8_t>(VT_MAYBE_I8, _maybe_i8);
|
||||
}
|
||||
int8_t default_i8() const { return GetField<int8_t>(VT_DEFAULT_I8, 42); }
|
||||
bool mutate_default_i8(int8_t _default_i8) {
|
||||
return SetField<int8_t>(VT_DEFAULT_I8, _default_i8, 42);
|
||||
}
|
||||
uint8_t just_u8() const { return GetField<uint8_t>(VT_JUST_U8, 0); }
|
||||
bool mutate_just_u8(uint8_t _just_u8) {
|
||||
return SetField<uint8_t>(VT_JUST_U8, _just_u8, 0);
|
||||
}
|
||||
flatbuffers::Optional<uint8_t> maybe_u8() const {
|
||||
return GetOptional<uint8_t, uint8_t>(VT_MAYBE_U8);
|
||||
}
|
||||
bool mutate_maybe_u8(uint8_t _maybe_u8) {
|
||||
return SetField<uint8_t>(VT_MAYBE_U8, _maybe_u8);
|
||||
}
|
||||
uint8_t default_u8() const { return GetField<uint8_t>(VT_DEFAULT_U8, 42); }
|
||||
bool mutate_default_u8(uint8_t _default_u8) {
|
||||
return SetField<uint8_t>(VT_DEFAULT_U8, _default_u8, 42);
|
||||
}
|
||||
int16_t just_i16() const { return GetField<int16_t>(VT_JUST_I16, 0); }
|
||||
bool mutate_just_i16(int16_t _just_i16) {
|
||||
return SetField<int16_t>(VT_JUST_I16, _just_i16, 0);
|
||||
}
|
||||
flatbuffers::Optional<int16_t> maybe_i16() const {
|
||||
return GetOptional<int16_t, int16_t>(VT_MAYBE_I16);
|
||||
}
|
||||
bool mutate_maybe_i16(int16_t _maybe_i16) {
|
||||
return SetField<int16_t>(VT_MAYBE_I16, _maybe_i16);
|
||||
}
|
||||
int16_t default_i16() const { return GetField<int16_t>(VT_DEFAULT_I16, 42); }
|
||||
bool mutate_default_i16(int16_t _default_i16) {
|
||||
return SetField<int16_t>(VT_DEFAULT_I16, _default_i16, 42);
|
||||
}
|
||||
uint16_t just_u16() const { return GetField<uint16_t>(VT_JUST_U16, 0); }
|
||||
bool mutate_just_u16(uint16_t _just_u16) {
|
||||
return SetField<uint16_t>(VT_JUST_U16, _just_u16, 0);
|
||||
}
|
||||
flatbuffers::Optional<uint16_t> maybe_u16() const {
|
||||
return GetOptional<uint16_t, uint16_t>(VT_MAYBE_U16);
|
||||
}
|
||||
bool mutate_maybe_u16(uint16_t _maybe_u16) {
|
||||
return SetField<uint16_t>(VT_MAYBE_U16, _maybe_u16);
|
||||
}
|
||||
uint16_t default_u16() const {
|
||||
return GetField<uint16_t>(VT_DEFAULT_U16, 42);
|
||||
}
|
||||
bool mutate_default_u16(uint16_t _default_u16) {
|
||||
return SetField<uint16_t>(VT_DEFAULT_U16, _default_u16, 42);
|
||||
}
|
||||
int32_t just_i32() const { return GetField<int32_t>(VT_JUST_I32, 0); }
|
||||
bool mutate_just_i32(int32_t _just_i32) {
|
||||
return SetField<int32_t>(VT_JUST_I32, _just_i32, 0);
|
||||
}
|
||||
flatbuffers::Optional<int32_t> maybe_i32() const {
|
||||
return GetOptional<int32_t, int32_t>(VT_MAYBE_I32);
|
||||
}
|
||||
bool mutate_maybe_i32(int32_t _maybe_i32) {
|
||||
return SetField<int32_t>(VT_MAYBE_I32, _maybe_i32);
|
||||
}
|
||||
int32_t default_i32() const { return GetField<int32_t>(VT_DEFAULT_I32, 42); }
|
||||
bool mutate_default_i32(int32_t _default_i32) {
|
||||
return SetField<int32_t>(VT_DEFAULT_I32, _default_i32, 42);
|
||||
}
|
||||
uint32_t just_u32() const { return GetField<uint32_t>(VT_JUST_U32, 0); }
|
||||
bool mutate_just_u32(uint32_t _just_u32) {
|
||||
return SetField<uint32_t>(VT_JUST_U32, _just_u32, 0);
|
||||
}
|
||||
flatbuffers::Optional<uint32_t> maybe_u32() const {
|
||||
return GetOptional<uint32_t, uint32_t>(VT_MAYBE_U32);
|
||||
}
|
||||
bool mutate_maybe_u32(uint32_t _maybe_u32) {
|
||||
return SetField<uint32_t>(VT_MAYBE_U32, _maybe_u32);
|
||||
}
|
||||
uint32_t default_u32() const {
|
||||
return GetField<uint32_t>(VT_DEFAULT_U32, 42);
|
||||
}
|
||||
bool mutate_default_u32(uint32_t _default_u32) {
|
||||
return SetField<uint32_t>(VT_DEFAULT_U32, _default_u32, 42);
|
||||
}
|
||||
int64_t just_i64() const { return GetField<int64_t>(VT_JUST_I64, 0); }
|
||||
bool mutate_just_i64(int64_t _just_i64) {
|
||||
return SetField<int64_t>(VT_JUST_I64, _just_i64, 0);
|
||||
}
|
||||
flatbuffers::Optional<int64_t> maybe_i64() const {
|
||||
return GetOptional<int64_t, int64_t>(VT_MAYBE_I64);
|
||||
}
|
||||
bool mutate_maybe_i64(int64_t _maybe_i64) {
|
||||
return SetField<int64_t>(VT_MAYBE_I64, _maybe_i64);
|
||||
}
|
||||
int64_t default_i64() const {
|
||||
return GetField<int64_t>(VT_DEFAULT_I64, 42LL);
|
||||
}
|
||||
bool mutate_default_i64(int64_t _default_i64) {
|
||||
return SetField<int64_t>(VT_DEFAULT_I64, _default_i64, 42LL);
|
||||
}
|
||||
uint64_t just_u64() const { return GetField<uint64_t>(VT_JUST_U64, 0); }
|
||||
bool mutate_just_u64(uint64_t _just_u64) {
|
||||
return SetField<uint64_t>(VT_JUST_U64, _just_u64, 0);
|
||||
}
|
||||
flatbuffers::Optional<uint64_t> maybe_u64() const {
|
||||
return GetOptional<uint64_t, uint64_t>(VT_MAYBE_U64);
|
||||
}
|
||||
bool mutate_maybe_u64(uint64_t _maybe_u64) {
|
||||
return SetField<uint64_t>(VT_MAYBE_U64, _maybe_u64);
|
||||
}
|
||||
uint64_t default_u64() const {
|
||||
return GetField<uint64_t>(VT_DEFAULT_U64, 42ULL);
|
||||
}
|
||||
bool mutate_default_u64(uint64_t _default_u64) {
|
||||
return SetField<uint64_t>(VT_DEFAULT_U64, _default_u64, 42ULL);
|
||||
}
|
||||
float just_f32() const { return GetField<float>(VT_JUST_F32, 0.0f); }
|
||||
bool mutate_just_f32(float _just_f32) {
|
||||
return SetField<float>(VT_JUST_F32, _just_f32, 0.0f);
|
||||
}
|
||||
flatbuffers::Optional<float> maybe_f32() const {
|
||||
return GetOptional<float, float>(VT_MAYBE_F32);
|
||||
}
|
||||
bool mutate_maybe_f32(float _maybe_f32) {
|
||||
return SetField<float>(VT_MAYBE_F32, _maybe_f32);
|
||||
}
|
||||
float default_f32() const { return GetField<float>(VT_DEFAULT_F32, 42.0f); }
|
||||
bool mutate_default_f32(float _default_f32) {
|
||||
return SetField<float>(VT_DEFAULT_F32, _default_f32, 42.0f);
|
||||
}
|
||||
double just_f64() const { return GetField<double>(VT_JUST_F64, 0.0); }
|
||||
bool mutate_just_f64(double _just_f64) {
|
||||
return SetField<double>(VT_JUST_F64, _just_f64, 0.0);
|
||||
}
|
||||
flatbuffers::Optional<double> maybe_f64() const {
|
||||
return GetOptional<double, double>(VT_MAYBE_F64);
|
||||
}
|
||||
bool mutate_maybe_f64(double _maybe_f64) {
|
||||
return SetField<double>(VT_MAYBE_F64, _maybe_f64);
|
||||
}
|
||||
double default_f64() const { return GetField<double>(VT_DEFAULT_F64, 42.0); }
|
||||
bool mutate_default_f64(double _default_f64) {
|
||||
return SetField<double>(VT_DEFAULT_F64, _default_f64, 42.0);
|
||||
}
|
||||
bool just_bool() const { return GetField<uint8_t>(VT_JUST_BOOL, 0) != 0; }
|
||||
bool mutate_just_bool(bool _just_bool) {
|
||||
return SetField<uint8_t>(VT_JUST_BOOL, static_cast<uint8_t>(_just_bool), 0);
|
||||
}
|
||||
flatbuffers::Optional<bool> maybe_bool() const {
|
||||
return GetOptional<uint8_t, bool>(VT_MAYBE_BOOL);
|
||||
}
|
||||
bool mutate_maybe_bool(bool _maybe_bool) {
|
||||
return SetField<uint8_t>(VT_MAYBE_BOOL, static_cast<uint8_t>(_maybe_bool));
|
||||
}
|
||||
bool default_bool() const {
|
||||
return GetField<uint8_t>(VT_DEFAULT_BOOL, 1) != 0;
|
||||
}
|
||||
bool mutate_default_bool(bool _default_bool) {
|
||||
return SetField<uint8_t>(VT_DEFAULT_BOOL,
|
||||
static_cast<uint8_t>(_default_bool), 1);
|
||||
}
|
||||
optional_scalars::OptionalByte just_enum() const {
|
||||
return static_cast<optional_scalars::OptionalByte>(
|
||||
GetField<int8_t>(VT_JUST_ENUM, 0));
|
||||
}
|
||||
bool mutate_just_enum(optional_scalars::OptionalByte _just_enum) {
|
||||
return SetField<int8_t>(VT_JUST_ENUM, static_cast<int8_t>(_just_enum), 0);
|
||||
}
|
||||
flatbuffers::Optional<optional_scalars::OptionalByte> maybe_enum() const {
|
||||
return GetOptional<int8_t, optional_scalars::OptionalByte>(VT_MAYBE_ENUM);
|
||||
}
|
||||
bool mutate_maybe_enum(optional_scalars::OptionalByte _maybe_enum) {
|
||||
return SetField<int8_t>(VT_MAYBE_ENUM, static_cast<int8_t>(_maybe_enum));
|
||||
}
|
||||
optional_scalars::OptionalByte default_enum() const {
|
||||
return static_cast<optional_scalars::OptionalByte>(
|
||||
GetField<int8_t>(VT_DEFAULT_ENUM, 1));
|
||||
}
|
||||
bool mutate_default_enum(optional_scalars::OptionalByte _default_enum) {
|
||||
return SetField<int8_t>(VT_DEFAULT_ENUM, static_cast<int8_t>(_default_enum),
|
||||
1);
|
||||
}
|
||||
bool Verify(flatbuffers::Verifier& verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int8_t>(verifier, VT_JUST_I8) &&
|
||||
VerifyField<int8_t>(verifier, VT_MAYBE_I8) &&
|
||||
VerifyField<int8_t>(verifier, VT_DEFAULT_I8) &&
|
||||
VerifyField<uint8_t>(verifier, VT_JUST_U8) &&
|
||||
VerifyField<uint8_t>(verifier, VT_MAYBE_U8) &&
|
||||
VerifyField<uint8_t>(verifier, VT_DEFAULT_U8) &&
|
||||
VerifyField<int16_t>(verifier, VT_JUST_I16) &&
|
||||
VerifyField<int16_t>(verifier, VT_MAYBE_I16) &&
|
||||
VerifyField<int16_t>(verifier, VT_DEFAULT_I16) &&
|
||||
VerifyField<uint16_t>(verifier, VT_JUST_U16) &&
|
||||
VerifyField<uint16_t>(verifier, VT_MAYBE_U16) &&
|
||||
VerifyField<uint16_t>(verifier, VT_DEFAULT_U16) &&
|
||||
VerifyField<int32_t>(verifier, VT_JUST_I32) &&
|
||||
VerifyField<int32_t>(verifier, VT_MAYBE_I32) &&
|
||||
VerifyField<int32_t>(verifier, VT_DEFAULT_I32) &&
|
||||
VerifyField<uint32_t>(verifier, VT_JUST_U32) &&
|
||||
VerifyField<uint32_t>(verifier, VT_MAYBE_U32) &&
|
||||
VerifyField<uint32_t>(verifier, VT_DEFAULT_U32) &&
|
||||
VerifyField<int64_t>(verifier, VT_JUST_I64) &&
|
||||
VerifyField<int64_t>(verifier, VT_MAYBE_I64) &&
|
||||
VerifyField<int64_t>(verifier, VT_DEFAULT_I64) &&
|
||||
VerifyField<uint64_t>(verifier, VT_JUST_U64) &&
|
||||
VerifyField<uint64_t>(verifier, VT_MAYBE_U64) &&
|
||||
VerifyField<uint64_t>(verifier, VT_DEFAULT_U64) &&
|
||||
VerifyField<float>(verifier, VT_JUST_F32) &&
|
||||
VerifyField<float>(verifier, VT_MAYBE_F32) &&
|
||||
VerifyField<float>(verifier, VT_DEFAULT_F32) &&
|
||||
VerifyField<double>(verifier, VT_JUST_F64) &&
|
||||
VerifyField<double>(verifier, VT_MAYBE_F64) &&
|
||||
VerifyField<double>(verifier, VT_DEFAULT_F64) &&
|
||||
VerifyField<uint8_t>(verifier, VT_JUST_BOOL) &&
|
||||
VerifyField<uint8_t>(verifier, VT_MAYBE_BOOL) &&
|
||||
VerifyField<uint8_t>(verifier, VT_DEFAULT_BOOL) &&
|
||||
VerifyField<int8_t>(verifier, VT_JUST_ENUM) &&
|
||||
VerifyField<int8_t>(verifier, VT_MAYBE_ENUM) &&
|
||||
VerifyField<int8_t>(verifier, VT_DEFAULT_ENUM) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
ScalarStuffT* UnPack(
|
||||
const flatbuffers::resolver_function_t* _resolver = nullptr) const;
|
||||
void UnPackTo(
|
||||
ScalarStuffT* _o,
|
||||
const flatbuffers::resolver_function_t* _resolver = nullptr) const;
|
||||
static flatbuffers::Offset<ScalarStuff> Pack(
|
||||
flatbuffers::FlatBufferBuilder& _fbb, const ScalarStuffT* _o,
|
||||
const flatbuffers::rehasher_function_t* _rehasher = nullptr);
|
||||
};
|
||||
|
||||
struct ScalarStuffBuilder {
|
||||
typedef ScalarStuff Table;
|
||||
flatbuffers::FlatBufferBuilder& fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_just_i8(int8_t just_i8) {
|
||||
fbb_.AddElement<int8_t>(ScalarStuff::VT_JUST_I8, just_i8, 0);
|
||||
}
|
||||
void add_maybe_i8(int8_t maybe_i8) {
|
||||
fbb_.AddElement<int8_t>(ScalarStuff::VT_MAYBE_I8, maybe_i8);
|
||||
}
|
||||
void add_default_i8(int8_t default_i8) {
|
||||
fbb_.AddElement<int8_t>(ScalarStuff::VT_DEFAULT_I8, default_i8, 42);
|
||||
}
|
||||
void add_just_u8(uint8_t just_u8) {
|
||||
fbb_.AddElement<uint8_t>(ScalarStuff::VT_JUST_U8, just_u8, 0);
|
||||
}
|
||||
void add_maybe_u8(uint8_t maybe_u8) {
|
||||
fbb_.AddElement<uint8_t>(ScalarStuff::VT_MAYBE_U8, maybe_u8);
|
||||
}
|
||||
void add_default_u8(uint8_t default_u8) {
|
||||
fbb_.AddElement<uint8_t>(ScalarStuff::VT_DEFAULT_U8, default_u8, 42);
|
||||
}
|
||||
void add_just_i16(int16_t just_i16) {
|
||||
fbb_.AddElement<int16_t>(ScalarStuff::VT_JUST_I16, just_i16, 0);
|
||||
}
|
||||
void add_maybe_i16(int16_t maybe_i16) {
|
||||
fbb_.AddElement<int16_t>(ScalarStuff::VT_MAYBE_I16, maybe_i16);
|
||||
}
|
||||
void add_default_i16(int16_t default_i16) {
|
||||
fbb_.AddElement<int16_t>(ScalarStuff::VT_DEFAULT_I16, default_i16, 42);
|
||||
}
|
||||
void add_just_u16(uint16_t just_u16) {
|
||||
fbb_.AddElement<uint16_t>(ScalarStuff::VT_JUST_U16, just_u16, 0);
|
||||
}
|
||||
void add_maybe_u16(uint16_t maybe_u16) {
|
||||
fbb_.AddElement<uint16_t>(ScalarStuff::VT_MAYBE_U16, maybe_u16);
|
||||
}
|
||||
void add_default_u16(uint16_t default_u16) {
|
||||
fbb_.AddElement<uint16_t>(ScalarStuff::VT_DEFAULT_U16, default_u16, 42);
|
||||
}
|
||||
void add_just_i32(int32_t just_i32) {
|
||||
fbb_.AddElement<int32_t>(ScalarStuff::VT_JUST_I32, just_i32, 0);
|
||||
}
|
||||
void add_maybe_i32(int32_t maybe_i32) {
|
||||
fbb_.AddElement<int32_t>(ScalarStuff::VT_MAYBE_I32, maybe_i32);
|
||||
}
|
||||
void add_default_i32(int32_t default_i32) {
|
||||
fbb_.AddElement<int32_t>(ScalarStuff::VT_DEFAULT_I32, default_i32, 42);
|
||||
}
|
||||
void add_just_u32(uint32_t just_u32) {
|
||||
fbb_.AddElement<uint32_t>(ScalarStuff::VT_JUST_U32, just_u32, 0);
|
||||
}
|
||||
void add_maybe_u32(uint32_t maybe_u32) {
|
||||
fbb_.AddElement<uint32_t>(ScalarStuff::VT_MAYBE_U32, maybe_u32);
|
||||
}
|
||||
void add_default_u32(uint32_t default_u32) {
|
||||
fbb_.AddElement<uint32_t>(ScalarStuff::VT_DEFAULT_U32, default_u32, 42);
|
||||
}
|
||||
void add_just_i64(int64_t just_i64) {
|
||||
fbb_.AddElement<int64_t>(ScalarStuff::VT_JUST_I64, just_i64, 0);
|
||||
}
|
||||
void add_maybe_i64(int64_t maybe_i64) {
|
||||
fbb_.AddElement<int64_t>(ScalarStuff::VT_MAYBE_I64, maybe_i64);
|
||||
}
|
||||
void add_default_i64(int64_t default_i64) {
|
||||
fbb_.AddElement<int64_t>(ScalarStuff::VT_DEFAULT_I64, default_i64, 42LL);
|
||||
}
|
||||
void add_just_u64(uint64_t just_u64) {
|
||||
fbb_.AddElement<uint64_t>(ScalarStuff::VT_JUST_U64, just_u64, 0);
|
||||
}
|
||||
void add_maybe_u64(uint64_t maybe_u64) {
|
||||
fbb_.AddElement<uint64_t>(ScalarStuff::VT_MAYBE_U64, maybe_u64);
|
||||
}
|
||||
void add_default_u64(uint64_t default_u64) {
|
||||
fbb_.AddElement<uint64_t>(ScalarStuff::VT_DEFAULT_U64, default_u64, 42ULL);
|
||||
}
|
||||
void add_just_f32(float just_f32) {
|
||||
fbb_.AddElement<float>(ScalarStuff::VT_JUST_F32, just_f32, 0.0f);
|
||||
}
|
||||
void add_maybe_f32(float maybe_f32) {
|
||||
fbb_.AddElement<float>(ScalarStuff::VT_MAYBE_F32, maybe_f32);
|
||||
}
|
||||
void add_default_f32(float default_f32) {
|
||||
fbb_.AddElement<float>(ScalarStuff::VT_DEFAULT_F32, default_f32, 42.0f);
|
||||
}
|
||||
void add_just_f64(double just_f64) {
|
||||
fbb_.AddElement<double>(ScalarStuff::VT_JUST_F64, just_f64, 0.0);
|
||||
}
|
||||
void add_maybe_f64(double maybe_f64) {
|
||||
fbb_.AddElement<double>(ScalarStuff::VT_MAYBE_F64, maybe_f64);
|
||||
}
|
||||
void add_default_f64(double default_f64) {
|
||||
fbb_.AddElement<double>(ScalarStuff::VT_DEFAULT_F64, default_f64, 42.0);
|
||||
}
|
||||
void add_just_bool(bool just_bool) {
|
||||
fbb_.AddElement<uint8_t>(ScalarStuff::VT_JUST_BOOL,
|
||||
static_cast<uint8_t>(just_bool), 0);
|
||||
}
|
||||
void add_maybe_bool(bool maybe_bool) {
|
||||
fbb_.AddElement<uint8_t>(ScalarStuff::VT_MAYBE_BOOL,
|
||||
static_cast<uint8_t>(maybe_bool));
|
||||
}
|
||||
void add_default_bool(bool default_bool) {
|
||||
fbb_.AddElement<uint8_t>(ScalarStuff::VT_DEFAULT_BOOL,
|
||||
static_cast<uint8_t>(default_bool), 1);
|
||||
}
|
||||
void add_just_enum(optional_scalars::OptionalByte just_enum) {
|
||||
fbb_.AddElement<int8_t>(ScalarStuff::VT_JUST_ENUM,
|
||||
static_cast<int8_t>(just_enum), 0);
|
||||
}
|
||||
void add_maybe_enum(optional_scalars::OptionalByte maybe_enum) {
|
||||
fbb_.AddElement<int8_t>(ScalarStuff::VT_MAYBE_ENUM,
|
||||
static_cast<int8_t>(maybe_enum));
|
||||
}
|
||||
void add_default_enum(optional_scalars::OptionalByte default_enum) {
|
||||
fbb_.AddElement<int8_t>(ScalarStuff::VT_DEFAULT_ENUM,
|
||||
static_cast<int8_t>(default_enum), 1);
|
||||
}
|
||||
explicit ScalarStuffBuilder(flatbuffers::FlatBufferBuilder& _fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
flatbuffers::Offset<ScalarStuff> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = flatbuffers::Offset<ScalarStuff>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<ScalarStuff> CreateScalarStuff(
|
||||
flatbuffers::FlatBufferBuilder& _fbb, int8_t just_i8 = 0,
|
||||
flatbuffers::Optional<int8_t> maybe_i8 = flatbuffers::nullopt,
|
||||
int8_t default_i8 = 42, uint8_t just_u8 = 0,
|
||||
flatbuffers::Optional<uint8_t> maybe_u8 = flatbuffers::nullopt,
|
||||
uint8_t default_u8 = 42, int16_t just_i16 = 0,
|
||||
flatbuffers::Optional<int16_t> maybe_i16 = flatbuffers::nullopt,
|
||||
int16_t default_i16 = 42, uint16_t just_u16 = 0,
|
||||
flatbuffers::Optional<uint16_t> maybe_u16 = flatbuffers::nullopt,
|
||||
uint16_t default_u16 = 42, int32_t just_i32 = 0,
|
||||
flatbuffers::Optional<int32_t> maybe_i32 = flatbuffers::nullopt,
|
||||
int32_t default_i32 = 42, uint32_t just_u32 = 0,
|
||||
flatbuffers::Optional<uint32_t> maybe_u32 = flatbuffers::nullopt,
|
||||
uint32_t default_u32 = 42, int64_t just_i64 = 0,
|
||||
flatbuffers::Optional<int64_t> maybe_i64 = flatbuffers::nullopt,
|
||||
int64_t default_i64 = 42LL, uint64_t just_u64 = 0,
|
||||
flatbuffers::Optional<uint64_t> maybe_u64 = flatbuffers::nullopt,
|
||||
uint64_t default_u64 = 42ULL, float just_f32 = 0.0f,
|
||||
flatbuffers::Optional<float> maybe_f32 = flatbuffers::nullopt,
|
||||
float default_f32 = 42.0f, double just_f64 = 0.0,
|
||||
flatbuffers::Optional<double> maybe_f64 = flatbuffers::nullopt,
|
||||
double default_f64 = 42.0, bool just_bool = false,
|
||||
flatbuffers::Optional<bool> maybe_bool = flatbuffers::nullopt,
|
||||
bool default_bool = true,
|
||||
optional_scalars::OptionalByte just_enum =
|
||||
optional_scalars::OptionalByte::None,
|
||||
flatbuffers::Optional<optional_scalars::OptionalByte> maybe_enum =
|
||||
flatbuffers::nullopt,
|
||||
optional_scalars::OptionalByte default_enum =
|
||||
optional_scalars::OptionalByte::One) {
|
||||
ScalarStuffBuilder builder_(_fbb);
|
||||
builder_.add_default_f64(default_f64);
|
||||
if (maybe_f64) {
|
||||
builder_.add_maybe_f64(*maybe_f64);
|
||||
}
|
||||
builder_.add_just_f64(just_f64);
|
||||
builder_.add_default_u64(default_u64);
|
||||
if (maybe_u64) {
|
||||
builder_.add_maybe_u64(*maybe_u64);
|
||||
}
|
||||
builder_.add_just_u64(just_u64);
|
||||
builder_.add_default_i64(default_i64);
|
||||
if (maybe_i64) {
|
||||
builder_.add_maybe_i64(*maybe_i64);
|
||||
}
|
||||
builder_.add_just_i64(just_i64);
|
||||
builder_.add_default_f32(default_f32);
|
||||
if (maybe_f32) {
|
||||
builder_.add_maybe_f32(*maybe_f32);
|
||||
}
|
||||
builder_.add_just_f32(just_f32);
|
||||
builder_.add_default_u32(default_u32);
|
||||
if (maybe_u32) {
|
||||
builder_.add_maybe_u32(*maybe_u32);
|
||||
}
|
||||
builder_.add_just_u32(just_u32);
|
||||
builder_.add_default_i32(default_i32);
|
||||
if (maybe_i32) {
|
||||
builder_.add_maybe_i32(*maybe_i32);
|
||||
}
|
||||
builder_.add_just_i32(just_i32);
|
||||
builder_.add_default_u16(default_u16);
|
||||
if (maybe_u16) {
|
||||
builder_.add_maybe_u16(*maybe_u16);
|
||||
}
|
||||
builder_.add_just_u16(just_u16);
|
||||
builder_.add_default_i16(default_i16);
|
||||
if (maybe_i16) {
|
||||
builder_.add_maybe_i16(*maybe_i16);
|
||||
}
|
||||
builder_.add_just_i16(just_i16);
|
||||
builder_.add_default_enum(default_enum);
|
||||
if (maybe_enum) {
|
||||
builder_.add_maybe_enum(*maybe_enum);
|
||||
}
|
||||
builder_.add_just_enum(just_enum);
|
||||
builder_.add_default_bool(default_bool);
|
||||
if (maybe_bool) {
|
||||
builder_.add_maybe_bool(*maybe_bool);
|
||||
}
|
||||
builder_.add_just_bool(just_bool);
|
||||
builder_.add_default_u8(default_u8);
|
||||
if (maybe_u8) {
|
||||
builder_.add_maybe_u8(*maybe_u8);
|
||||
}
|
||||
builder_.add_just_u8(just_u8);
|
||||
builder_.add_default_i8(default_i8);
|
||||
if (maybe_i8) {
|
||||
builder_.add_maybe_i8(*maybe_i8);
|
||||
}
|
||||
builder_.add_just_i8(just_i8);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct ScalarStuff::Traits {
|
||||
using type = ScalarStuff;
|
||||
static auto constexpr Create = CreateScalarStuff;
|
||||
};
|
||||
|
||||
flatbuffers::Offset<ScalarStuff> CreateScalarStuff(
|
||||
flatbuffers::FlatBufferBuilder& _fbb, const ScalarStuffT* _o,
|
||||
const flatbuffers::rehasher_function_t* _rehasher = nullptr);
|
||||
|
||||
inline ScalarStuffT* ScalarStuff::UnPack(
|
||||
const flatbuffers::resolver_function_t* _resolver) const {
|
||||
auto _o = std::make_unique<ScalarStuffT>();
|
||||
UnPackTo(_o.get(), _resolver);
|
||||
return _o.release();
|
||||
}
|
||||
|
||||
inline void ScalarStuff::UnPackTo(
|
||||
ScalarStuffT* _o, const flatbuffers::resolver_function_t* _resolver) const {
|
||||
(void)_o;
|
||||
(void)_resolver;
|
||||
{
|
||||
auto _e = just_i8();
|
||||
_o->just_i8 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = maybe_i8();
|
||||
_o->maybe_i8 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = default_i8();
|
||||
_o->default_i8 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = just_u8();
|
||||
_o->just_u8 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = maybe_u8();
|
||||
_o->maybe_u8 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = default_u8();
|
||||
_o->default_u8 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = just_i16();
|
||||
_o->just_i16 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = maybe_i16();
|
||||
_o->maybe_i16 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = default_i16();
|
||||
_o->default_i16 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = just_u16();
|
||||
_o->just_u16 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = maybe_u16();
|
||||
_o->maybe_u16 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = default_u16();
|
||||
_o->default_u16 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = just_i32();
|
||||
_o->just_i32 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = maybe_i32();
|
||||
_o->maybe_i32 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = default_i32();
|
||||
_o->default_i32 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = just_u32();
|
||||
_o->just_u32 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = maybe_u32();
|
||||
_o->maybe_u32 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = default_u32();
|
||||
_o->default_u32 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = just_i64();
|
||||
_o->just_i64 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = maybe_i64();
|
||||
_o->maybe_i64 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = default_i64();
|
||||
_o->default_i64 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = just_u64();
|
||||
_o->just_u64 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = maybe_u64();
|
||||
_o->maybe_u64 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = default_u64();
|
||||
_o->default_u64 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = just_f32();
|
||||
_o->just_f32 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = maybe_f32();
|
||||
_o->maybe_f32 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = default_f32();
|
||||
_o->default_f32 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = just_f64();
|
||||
_o->just_f64 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = maybe_f64();
|
||||
_o->maybe_f64 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = default_f64();
|
||||
_o->default_f64 = _e;
|
||||
}
|
||||
{
|
||||
auto _e = just_bool();
|
||||
_o->just_bool = _e;
|
||||
}
|
||||
{
|
||||
auto _e = maybe_bool();
|
||||
_o->maybe_bool = _e;
|
||||
}
|
||||
{
|
||||
auto _e = default_bool();
|
||||
_o->default_bool = _e;
|
||||
}
|
||||
{
|
||||
auto _e = just_enum();
|
||||
_o->just_enum = _e;
|
||||
}
|
||||
{
|
||||
auto _e = maybe_enum();
|
||||
_o->maybe_enum = _e;
|
||||
}
|
||||
{
|
||||
auto _e = default_enum();
|
||||
_o->default_enum = _e;
|
||||
}
|
||||
}
|
||||
|
||||
inline flatbuffers::Offset<ScalarStuff> ScalarStuff::Pack(
|
||||
flatbuffers::FlatBufferBuilder& _fbb, const ScalarStuffT* _o,
|
||||
const flatbuffers::rehasher_function_t* _rehasher) {
|
||||
return CreateScalarStuff(_fbb, _o, _rehasher);
|
||||
}
|
||||
|
||||
inline flatbuffers::Offset<ScalarStuff> CreateScalarStuff(
|
||||
flatbuffers::FlatBufferBuilder& _fbb, const ScalarStuffT* _o,
|
||||
const flatbuffers::rehasher_function_t* _rehasher) {
|
||||
(void)_rehasher;
|
||||
(void)_o;
|
||||
struct _VectorArgs {
|
||||
flatbuffers::FlatBufferBuilder* __fbb;
|
||||
const ScalarStuffT* __o;
|
||||
const flatbuffers::rehasher_function_t* __rehasher;
|
||||
} _va = {&_fbb, _o, _rehasher};
|
||||
(void)_va;
|
||||
auto _just_i8 = _o->just_i8;
|
||||
auto _maybe_i8 = _o->maybe_i8;
|
||||
auto _default_i8 = _o->default_i8;
|
||||
auto _just_u8 = _o->just_u8;
|
||||
auto _maybe_u8 = _o->maybe_u8;
|
||||
auto _default_u8 = _o->default_u8;
|
||||
auto _just_i16 = _o->just_i16;
|
||||
auto _maybe_i16 = _o->maybe_i16;
|
||||
auto _default_i16 = _o->default_i16;
|
||||
auto _just_u16 = _o->just_u16;
|
||||
auto _maybe_u16 = _o->maybe_u16;
|
||||
auto _default_u16 = _o->default_u16;
|
||||
auto _just_i32 = _o->just_i32;
|
||||
auto _maybe_i32 = _o->maybe_i32;
|
||||
auto _default_i32 = _o->default_i32;
|
||||
auto _just_u32 = _o->just_u32;
|
||||
auto _maybe_u32 = _o->maybe_u32;
|
||||
auto _default_u32 = _o->default_u32;
|
||||
auto _just_i64 = _o->just_i64;
|
||||
auto _maybe_i64 = _o->maybe_i64;
|
||||
auto _default_i64 = _o->default_i64;
|
||||
auto _just_u64 = _o->just_u64;
|
||||
auto _maybe_u64 = _o->maybe_u64;
|
||||
auto _default_u64 = _o->default_u64;
|
||||
auto _just_f32 = _o->just_f32;
|
||||
auto _maybe_f32 = _o->maybe_f32;
|
||||
auto _default_f32 = _o->default_f32;
|
||||
auto _just_f64 = _o->just_f64;
|
||||
auto _maybe_f64 = _o->maybe_f64;
|
||||
auto _default_f64 = _o->default_f64;
|
||||
auto _just_bool = _o->just_bool;
|
||||
auto _maybe_bool = _o->maybe_bool;
|
||||
auto _default_bool = _o->default_bool;
|
||||
auto _just_enum = _o->just_enum;
|
||||
auto _maybe_enum = _o->maybe_enum;
|
||||
auto _default_enum = _o->default_enum;
|
||||
return optional_scalars::CreateScalarStuff(
|
||||
_fbb, _just_i8, _maybe_i8, _default_i8, _just_u8, _maybe_u8, _default_u8,
|
||||
_just_i16, _maybe_i16, _default_i16, _just_u16, _maybe_u16, _default_u16,
|
||||
_just_i32, _maybe_i32, _default_i32, _just_u32, _maybe_u32, _default_u32,
|
||||
_just_i64, _maybe_i64, _default_i64, _just_u64, _maybe_u64, _default_u64,
|
||||
_just_f32, _maybe_f32, _default_f32, _just_f64, _maybe_f64, _default_f64,
|
||||
_just_bool, _maybe_bool, _default_bool, _just_enum, _maybe_enum,
|
||||
_default_enum);
|
||||
}
|
||||
|
||||
inline const flatbuffers::TypeTable* OptionalByteTypeTable() {
|
||||
static const flatbuffers::TypeCode type_codes[] = {
|
||||
{flatbuffers::ET_CHAR, 0, 0},
|
||||
{flatbuffers::ET_CHAR, 0, 0},
|
||||
{flatbuffers::ET_CHAR, 0, 0}};
|
||||
static const flatbuffers::TypeFunction type_refs[] = {
|
||||
optional_scalars::OptionalByteTypeTable};
|
||||
static const char* const names[] = {"None", "One", "Two"};
|
||||
static const flatbuffers::TypeTable tt = {
|
||||
flatbuffers::ST_ENUM, 3, type_codes, type_refs, nullptr, nullptr, names};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
inline const flatbuffers::TypeTable* ScalarStuffTypeTable() {
|
||||
static const flatbuffers::TypeCode type_codes[] = {
|
||||
{flatbuffers::ET_CHAR, 0, -1}, {flatbuffers::ET_CHAR, 0, -1},
|
||||
{flatbuffers::ET_CHAR, 0, -1}, {flatbuffers::ET_UCHAR, 0, -1},
|
||||
{flatbuffers::ET_UCHAR, 0, -1}, {flatbuffers::ET_UCHAR, 0, -1},
|
||||
{flatbuffers::ET_SHORT, 0, -1}, {flatbuffers::ET_SHORT, 0, -1},
|
||||
{flatbuffers::ET_SHORT, 0, -1}, {flatbuffers::ET_USHORT, 0, -1},
|
||||
{flatbuffers::ET_USHORT, 0, -1}, {flatbuffers::ET_USHORT, 0, -1},
|
||||
{flatbuffers::ET_INT, 0, -1}, {flatbuffers::ET_INT, 0, -1},
|
||||
{flatbuffers::ET_INT, 0, -1}, {flatbuffers::ET_UINT, 0, -1},
|
||||
{flatbuffers::ET_UINT, 0, -1}, {flatbuffers::ET_UINT, 0, -1},
|
||||
{flatbuffers::ET_LONG, 0, -1}, {flatbuffers::ET_LONG, 0, -1},
|
||||
{flatbuffers::ET_LONG, 0, -1}, {flatbuffers::ET_ULONG, 0, -1},
|
||||
{flatbuffers::ET_ULONG, 0, -1}, {flatbuffers::ET_ULONG, 0, -1},
|
||||
{flatbuffers::ET_FLOAT, 0, -1}, {flatbuffers::ET_FLOAT, 0, -1},
|
||||
{flatbuffers::ET_FLOAT, 0, -1}, {flatbuffers::ET_DOUBLE, 0, -1},
|
||||
{flatbuffers::ET_DOUBLE, 0, -1}, {flatbuffers::ET_DOUBLE, 0, -1},
|
||||
{flatbuffers::ET_BOOL, 0, -1}, {flatbuffers::ET_BOOL, 0, -1},
|
||||
{flatbuffers::ET_BOOL, 0, -1}, {flatbuffers::ET_CHAR, 0, 0},
|
||||
{flatbuffers::ET_CHAR, 0, 0}, {flatbuffers::ET_CHAR, 0, 0}};
|
||||
static const flatbuffers::TypeFunction type_refs[] = {
|
||||
optional_scalars::OptionalByteTypeTable};
|
||||
static const char* const names[] = {
|
||||
"just_i8", "maybe_i8", "default_i8", "just_u8",
|
||||
"maybe_u8", "default_u8", "just_i16", "maybe_i16",
|
||||
"default_i16", "just_u16", "maybe_u16", "default_u16",
|
||||
"just_i32", "maybe_i32", "default_i32", "just_u32",
|
||||
"maybe_u32", "default_u32", "just_i64", "maybe_i64",
|
||||
"default_i64", "just_u64", "maybe_u64", "default_u64",
|
||||
"just_f32", "maybe_f32", "default_f32", "just_f64",
|
||||
"maybe_f64", "default_f64", "just_bool", "maybe_bool",
|
||||
"default_bool", "just_enum", "maybe_enum", "default_enum"};
|
||||
static const flatbuffers::TypeTable tt = {flatbuffers::ST_TABLE,
|
||||
36,
|
||||
type_codes,
|
||||
type_refs,
|
||||
nullptr,
|
||||
nullptr,
|
||||
names};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
inline const optional_scalars::ScalarStuff* GetScalarStuff(const void* buf) {
|
||||
return flatbuffers::GetRoot<optional_scalars::ScalarStuff>(buf);
|
||||
}
|
||||
|
||||
inline const optional_scalars::ScalarStuff* GetSizePrefixedScalarStuff(
|
||||
const void* buf) {
|
||||
return flatbuffers::GetSizePrefixedRoot<optional_scalars::ScalarStuff>(buf);
|
||||
}
|
||||
|
||||
inline ScalarStuff* GetMutableScalarStuff(void* buf) {
|
||||
return flatbuffers::GetMutableRoot<ScalarStuff>(buf);
|
||||
}
|
||||
|
||||
inline const char* ScalarStuffIdentifier() { return "NULL"; }
|
||||
|
||||
inline bool ScalarStuffBufferHasIdentifier(const void* buf) {
|
||||
return flatbuffers::BufferHasIdentifier(buf, ScalarStuffIdentifier());
|
||||
}
|
||||
|
||||
inline bool VerifyScalarStuffBuffer(flatbuffers::Verifier& verifier) {
|
||||
return verifier.VerifyBuffer<optional_scalars::ScalarStuff>(
|
||||
ScalarStuffIdentifier());
|
||||
}
|
||||
|
||||
inline bool VerifySizePrefixedScalarStuffBuffer(
|
||||
flatbuffers::Verifier& verifier) {
|
||||
return verifier.VerifySizePrefixedBuffer<optional_scalars::ScalarStuff>(
|
||||
ScalarStuffIdentifier());
|
||||
}
|
||||
|
||||
inline const char* ScalarStuffExtension() { return "mon"; }
|
||||
|
||||
inline void FinishScalarStuffBuffer(
|
||||
flatbuffers::FlatBufferBuilder& fbb,
|
||||
flatbuffers::Offset<optional_scalars::ScalarStuff> root) {
|
||||
fbb.Finish(root, ScalarStuffIdentifier());
|
||||
}
|
||||
|
||||
inline void FinishSizePrefixedScalarStuffBuffer(
|
||||
flatbuffers::FlatBufferBuilder& fbb,
|
||||
flatbuffers::Offset<optional_scalars::ScalarStuff> root) {
|
||||
fbb.FinishSizePrefixed(root, ScalarStuffIdentifier());
|
||||
}
|
||||
|
||||
inline std::unique_ptr<optional_scalars::ScalarStuffT> UnPackScalarStuff(
|
||||
const void* buf, const flatbuffers::resolver_function_t* res = nullptr) {
|
||||
return std::unique_ptr<optional_scalars::ScalarStuffT>(
|
||||
GetScalarStuff(buf)->UnPack(res));
|
||||
}
|
||||
|
||||
inline std::unique_ptr<optional_scalars::ScalarStuffT>
|
||||
UnPackSizePrefixedScalarStuff(
|
||||
const void* buf, const flatbuffers::resolver_function_t* res = nullptr) {
|
||||
return std::unique_ptr<optional_scalars::ScalarStuffT>(
|
||||
GetSizePrefixedScalarStuff(buf)->UnPack(res));
|
||||
}
|
||||
|
||||
} // namespace optional_scalars
|
||||
|
||||
#endif // FLATBUFFERS_GENERATED_OPTIONALSCALARS2_OPTIONAL_SCALARS_H_
|
||||
@@ -31,14 +31,14 @@
|
||||
|
||||
// Embed generated code into an isolated namespace.
|
||||
namespace cpp17 {
|
||||
#include "tests/cpp17/generated_cpp17/monster_test_generated.h"
|
||||
#include "tests/cpp17/generated_cpp17/optional_scalars_generated.h"
|
||||
#include "tests/cpp17/generated_cpp17/union_vector_generated.h"
|
||||
#include "generated_cpp17/monster_test_generated.h"
|
||||
#include "generated_cpp17/optional_scalars_generated.h"
|
||||
#include "generated_cpp17/union_vector_generated.h"
|
||||
} // namespace cpp17
|
||||
|
||||
namespace cpp11 {
|
||||
#include "tests/monster_test_generated.h"
|
||||
#include "tests/optional_scalars.fbs.h"
|
||||
#include "../monster_test_generated.h"
|
||||
#include "../optional_scalars_generated.h"
|
||||
} // namespace cpp11
|
||||
|
||||
using ::cpp17::MyGame::Example::Monster;
|
||||
|
||||
16
tests/cpp_vec_type_native_type_test.fbs
Normal file
16
tests/cpp_vec_type_native_type_test.fbs
Normal file
@@ -0,0 +1,16 @@
|
||||
native_include "cpp_vec_type_native_type_test_impl.h";
|
||||
|
||||
namespace CppVecNativeTypeTest;
|
||||
|
||||
struct Vec3 (native_type: "CppVecNativeTypeTest::Native::Vec3") {
|
||||
x: float;
|
||||
y: float;
|
||||
z: float;
|
||||
}
|
||||
|
||||
table Container {
|
||||
points: [Vec3] (cpp_vec_type: "CppVecNativeTypeTest::CustomVec");
|
||||
bytes: [ubyte] (cpp_vec_type: "CppVecNativeTypeTest::CustomVec");
|
||||
}
|
||||
|
||||
root_type Container;
|
||||
15
tests/cpp_vec_type_native_type_test_impl.cpp
Normal file
15
tests/cpp_vec_type_native_type_test_impl.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "cpp_vec_type_native_type_test_impl.h"
|
||||
|
||||
#include "cpp_vec_type_native_type_test_generated.h"
|
||||
|
||||
namespace flatbuffers {
|
||||
CppVecNativeTypeTest::Vec3 Pack(
|
||||
const CppVecNativeTypeTest::Native::Vec3& obj) {
|
||||
return CppVecNativeTypeTest::Vec3(obj.x, obj.y, obj.z);
|
||||
}
|
||||
|
||||
const CppVecNativeTypeTest::Native::Vec3 UnPack(
|
||||
const CppVecNativeTypeTest::Vec3& obj) {
|
||||
return CppVecNativeTypeTest::Native::Vec3(obj.x(), obj.y(), obj.z());
|
||||
}
|
||||
} // namespace flatbuffers
|
||||
34
tests/cpp_vec_type_native_type_test_impl.h
Normal file
34
tests/cpp_vec_type_native_type_test_impl.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef CPP_VEC_TYPE_NATIVE_TYPE_TEST_IMPL_H
|
||||
#define CPP_VEC_TYPE_NATIVE_TYPE_TEST_IMPL_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace CppVecNativeTypeTest {
|
||||
|
||||
namespace Native {
|
||||
struct Vec3 {
|
||||
float x, y, z;
|
||||
Vec3() : x(0), y(0), z(0) {}
|
||||
Vec3(float x_, float y_, float z_) : x(x_), y(y_), z(z_) {}
|
||||
bool operator==(const Vec3& o) const {
|
||||
return x == o.x && y == o.y && z == o.z;
|
||||
}
|
||||
};
|
||||
} // namespace Native
|
||||
|
||||
template <typename T>
|
||||
struct CustomVec : public std::vector<T> {
|
||||
using std::vector<T>::vector;
|
||||
};
|
||||
|
||||
struct Vec3; // flatbuffers-generated struct
|
||||
|
||||
} // namespace CppVecNativeTypeTest
|
||||
|
||||
namespace flatbuffers {
|
||||
CppVecNativeTypeTest::Vec3 Pack(const CppVecNativeTypeTest::Native::Vec3& obj);
|
||||
const CppVecNativeTypeTest::Native::Vec3 UnPack(
|
||||
const CppVecNativeTypeTest::Vec3& obj);
|
||||
} // namespace flatbuffers
|
||||
|
||||
#endif // CPP_VEC_TYPE_NATIVE_TYPE_TEST_IMPL_H
|
||||
17
tests/cpp_vec_type_test.fbs
Normal file
17
tests/cpp_vec_type_test.fbs
Normal file
@@ -0,0 +1,17 @@
|
||||
native_include "cpp_vec_type_test_impl.h";
|
||||
|
||||
namespace CppVecTest;
|
||||
|
||||
table Item {
|
||||
id: int;
|
||||
value: float;
|
||||
}
|
||||
|
||||
table Data {
|
||||
values: [int] (cpp_vec_type: "CppVecTest::CustomVec");
|
||||
items: [Item] (cpp_vec_type: "CppVecTest::CustomVec");
|
||||
strs: [string] (cpp_vec_type: "CppVecTest::CustomVec");
|
||||
regular: [int];
|
||||
}
|
||||
|
||||
root_type Data;
|
||||
15
tests/cpp_vec_type_test_impl.h
Normal file
15
tests/cpp_vec_type_test_impl.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef CPP_VEC_TYPE_TEST_IMPL_H
|
||||
#define CPP_VEC_TYPE_TEST_IMPL_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace CppVecTest {
|
||||
|
||||
template<typename T>
|
||||
struct CustomVec : public std::vector<T> {
|
||||
using std::vector<T>::vector;
|
||||
};
|
||||
|
||||
} // namespace CppVecTest
|
||||
|
||||
#endif // CPP_VEC_TYPE_TEST_IMPL_H
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "evolution_test.h"
|
||||
|
||||
#include "evolution_test/evolution_v1.fbs.h"
|
||||
#include "evolution_test/evolution_v2.fbs.h"
|
||||
#include "evolution_test/evolution_v1_generated.h"
|
||||
#include "evolution_test/evolution_v2_generated.h"
|
||||
#include "flatbuffers/idl.h"
|
||||
#include "test_assert.h"
|
||||
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
load("//:build_defs.bzl", "flatbuffer_cc_library")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
flatbuffer_cc_library(
|
||||
name = "evolution_v1_cc_fbs",
|
||||
srcs = ["evolution_v1.fbs"],
|
||||
filename_suffix = ".fbs",
|
||||
flatc_args = [
|
||||
"--gen-compare",
|
||||
"--gen-mutable",
|
||||
"--gen-object-api",
|
||||
"--reflect-names",
|
||||
"--filename-suffix .fbs",
|
||||
"--scoped-enums",
|
||||
],
|
||||
)
|
||||
|
||||
flatbuffer_cc_library(
|
||||
name = "evolution_v2_cc_fbs",
|
||||
srcs = ["evolution_v2.fbs"],
|
||||
filename_suffix = ".fbs",
|
||||
flatc_args = [
|
||||
"--gen-compare",
|
||||
"--gen-mutable",
|
||||
"--gen-object-api",
|
||||
"--reflect-names",
|
||||
"--filename-suffix .fbs",
|
||||
"--scoped-enums",
|
||||
],
|
||||
)
|
||||
|
||||
# Data needed by evolution_test.cpp to read at runtime.
|
||||
filegroup(
|
||||
name = "test_data",
|
||||
srcs = [
|
||||
"evolution_v1.fbs",
|
||||
"evolution_v1.json",
|
||||
"evolution_v2.fbs",
|
||||
"evolution_v2.json",
|
||||
],
|
||||
)
|
||||
533
tests/evolution_test/evolution_v1_generated.h
Normal file
533
tests/evolution_test/evolution_v1_generated.h
Normal file
@@ -0,0 +1,533 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
|
||||
#ifndef FLATBUFFERS_GENERATED_EVOLUTIONV1_EVOLUTION_V1_H_
|
||||
#define FLATBUFFERS_GENERATED_EVOLUTIONV1_EVOLUTION_V1_H_
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||
// generated, otherwise it may not be compatible.
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 19,
|
||||
"Non-compatible flatbuffers version included");
|
||||
|
||||
namespace Evolution {
|
||||
namespace V1 {
|
||||
|
||||
struct TableA;
|
||||
struct TableABuilder;
|
||||
|
||||
struct TableB;
|
||||
struct TableBBuilder;
|
||||
|
||||
struct Struct;
|
||||
|
||||
struct Root;
|
||||
struct RootBuilder;
|
||||
|
||||
enum class Enum : int8_t {
|
||||
King = 0,
|
||||
Queen = 1,
|
||||
MIN = King,
|
||||
MAX = Queen
|
||||
};
|
||||
|
||||
inline const Enum (&EnumValuesEnum())[2] {
|
||||
static const Enum values[] = {
|
||||
Enum::King,
|
||||
Enum::Queen
|
||||
};
|
||||
return values;
|
||||
}
|
||||
|
||||
inline const char * const *EnumNamesEnum() {
|
||||
static const char * const names[3] = {
|
||||
"King",
|
||||
"Queen",
|
||||
nullptr
|
||||
};
|
||||
return names;
|
||||
}
|
||||
|
||||
inline const char *EnumNameEnum(Enum e) {
|
||||
if (::flatbuffers::IsOutRange(e, Enum::King, Enum::Queen)) return "";
|
||||
const size_t index = static_cast<size_t>(e);
|
||||
return EnumNamesEnum()[index];
|
||||
}
|
||||
|
||||
enum class Union : uint8_t {
|
||||
NONE = 0,
|
||||
TableA = 1,
|
||||
TableB = 2,
|
||||
MIN = NONE,
|
||||
MAX = TableB
|
||||
};
|
||||
|
||||
inline const Union (&EnumValuesUnion())[3] {
|
||||
static const Union values[] = {
|
||||
Union::NONE,
|
||||
Union::TableA,
|
||||
Union::TableB
|
||||
};
|
||||
return values;
|
||||
}
|
||||
|
||||
inline const char * const *EnumNamesUnion() {
|
||||
static const char * const names[4] = {
|
||||
"NONE",
|
||||
"TableA",
|
||||
"TableB",
|
||||
nullptr
|
||||
};
|
||||
return names;
|
||||
}
|
||||
|
||||
inline const char *EnumNameUnion(Union e) {
|
||||
if (::flatbuffers::IsOutRange(e, Union::NONE, Union::TableB)) return "";
|
||||
const size_t index = static_cast<size_t>(e);
|
||||
return EnumNamesUnion()[index];
|
||||
}
|
||||
|
||||
template<typename T> struct UnionTraits {
|
||||
static const Union enum_value = Union::NONE;
|
||||
};
|
||||
|
||||
template<> struct UnionTraits<Evolution::V1::TableA> {
|
||||
static const Union enum_value = Union::TableA;
|
||||
};
|
||||
|
||||
template<> struct UnionTraits<Evolution::V1::TableB> {
|
||||
static const Union enum_value = Union::TableB;
|
||||
};
|
||||
|
||||
template <bool B = false>
|
||||
bool VerifyUnion(::flatbuffers::VerifierTemplate<B> &verifier, const void *obj, Union type);
|
||||
template <bool B = false>
|
||||
bool VerifyUnionVector(::flatbuffers::VerifierTemplate<B> &verifier, const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *values, const ::flatbuffers::Vector<Union> *types);
|
||||
|
||||
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) Struct FLATBUFFERS_FINAL_CLASS {
|
||||
private:
|
||||
int32_t a_;
|
||||
int32_t padding0__;
|
||||
double b_;
|
||||
|
||||
public:
|
||||
Struct()
|
||||
: a_(0),
|
||||
padding0__(0),
|
||||
b_(0) {
|
||||
(void)padding0__;
|
||||
}
|
||||
Struct(int32_t _a, double _b)
|
||||
: a_(::flatbuffers::EndianScalar(_a)),
|
||||
padding0__(0),
|
||||
b_(::flatbuffers::EndianScalar(_b)) {
|
||||
(void)padding0__;
|
||||
}
|
||||
int32_t a() const {
|
||||
return ::flatbuffers::EndianScalar(a_);
|
||||
}
|
||||
double b() const {
|
||||
return ::flatbuffers::EndianScalar(b_);
|
||||
}
|
||||
};
|
||||
FLATBUFFERS_STRUCT_END(Struct, 16);
|
||||
|
||||
inline bool operator==(const Struct &lhs, const Struct &rhs) {
|
||||
return
|
||||
(lhs.a() == rhs.a()) &&
|
||||
(lhs.b() == rhs.b());
|
||||
}
|
||||
|
||||
inline bool operator!=(const Struct &lhs, const Struct &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
template <typename H>
|
||||
inline H AbslHashValue(H h, const Struct &obj) {
|
||||
return H::combine(std::move(h), obj.a(), obj.b());
|
||||
}
|
||||
|
||||
struct TableA FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef TableABuilder Builder;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_A = 4,
|
||||
VT_B = 6
|
||||
};
|
||||
float a() const {
|
||||
return GetField<float>(VT_A, 0.0f);
|
||||
}
|
||||
int32_t b() const {
|
||||
return GetField<int32_t>(VT_B, 0);
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<float>(verifier, VT_A, 4) &&
|
||||
VerifyField<int32_t>(verifier, VT_B, 4) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct TableABuilder {
|
||||
typedef TableA Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_a(float a) {
|
||||
fbb_.AddElement<float>(TableA::VT_A, a, 0.0f);
|
||||
}
|
||||
void add_b(int32_t b) {
|
||||
fbb_.AddElement<int32_t>(TableA::VT_B, b, 0);
|
||||
}
|
||||
explicit TableABuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<TableA> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<TableA>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<TableA> CreateTableA(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
float a = 0.0f,
|
||||
int32_t b = 0) {
|
||||
TableABuilder builder_(_fbb);
|
||||
builder_.add_b(b);
|
||||
builder_.add_a(a);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct TableB FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef TableBBuilder Builder;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_A = 4
|
||||
};
|
||||
int32_t a() const {
|
||||
return GetField<int32_t>(VT_A, 0);
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int32_t>(verifier, VT_A, 4) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct TableBBuilder {
|
||||
typedef TableB Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_a(int32_t a) {
|
||||
fbb_.AddElement<int32_t>(TableB::VT_A, a, 0);
|
||||
}
|
||||
explicit TableBBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<TableB> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<TableB>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<TableB> CreateTableB(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t a = 0) {
|
||||
TableBBuilder builder_(_fbb);
|
||||
builder_.add_a(a);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct Root FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef RootBuilder Builder;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_A = 4,
|
||||
VT_B = 6,
|
||||
VT_C_TYPE = 8,
|
||||
VT_C = 10,
|
||||
VT_D = 12,
|
||||
VT_E = 14,
|
||||
VT_F = 16,
|
||||
VT_G = 18,
|
||||
VT_H = 20,
|
||||
VT_I = 22,
|
||||
VT_J_TYPE = 24,
|
||||
VT_J = 26
|
||||
};
|
||||
int32_t a() const {
|
||||
return GetField<int32_t>(VT_A, 0);
|
||||
}
|
||||
bool b() const {
|
||||
return GetField<uint8_t>(VT_B, 0) != 0;
|
||||
}
|
||||
Evolution::V1::Union c_type() const {
|
||||
return static_cast<Evolution::V1::Union>(GetField<uint8_t>(VT_C_TYPE, 0));
|
||||
}
|
||||
const void *c() const {
|
||||
return GetPointer<const void *>(VT_C);
|
||||
}
|
||||
template<typename T> const T *c_as() const;
|
||||
const Evolution::V1::TableA *c_as_TableA() const {
|
||||
return c_type() == Evolution::V1::Union::TableA ? static_cast<const Evolution::V1::TableA *>(c()) : nullptr;
|
||||
}
|
||||
const Evolution::V1::TableB *c_as_TableB() const {
|
||||
return c_type() == Evolution::V1::Union::TableB ? static_cast<const Evolution::V1::TableB *>(c()) : nullptr;
|
||||
}
|
||||
Evolution::V1::Enum d() const {
|
||||
return static_cast<Evolution::V1::Enum>(GetField<int8_t>(VT_D, 0));
|
||||
}
|
||||
const Evolution::V1::TableA *e() const {
|
||||
return GetPointer<const Evolution::V1::TableA *>(VT_E);
|
||||
}
|
||||
const Evolution::V1::Struct *f() const {
|
||||
return GetStruct<const Evolution::V1::Struct *>(VT_F);
|
||||
}
|
||||
const ::flatbuffers::Vector<int32_t> *g() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<int32_t> *>(VT_G);
|
||||
}
|
||||
const ::flatbuffers::Vector<::flatbuffers::Offset<Evolution::V1::TableB>> *h() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<Evolution::V1::TableB>> *>(VT_H);
|
||||
}
|
||||
int32_t i() const {
|
||||
return GetField<int32_t>(VT_I, 1234);
|
||||
}
|
||||
Evolution::V1::Union j_type() const {
|
||||
return static_cast<Evolution::V1::Union>(GetField<uint8_t>(VT_J_TYPE, 0));
|
||||
}
|
||||
const void *j() const {
|
||||
return GetPointer<const void *>(VT_J);
|
||||
}
|
||||
template<typename T> const T *j_as() const;
|
||||
const Evolution::V1::TableA *j_as_TableA() const {
|
||||
return j_type() == Evolution::V1::Union::TableA ? static_cast<const Evolution::V1::TableA *>(j()) : nullptr;
|
||||
}
|
||||
const Evolution::V1::TableB *j_as_TableB() const {
|
||||
return j_type() == Evolution::V1::Union::TableB ? static_cast<const Evolution::V1::TableB *>(j()) : nullptr;
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int32_t>(verifier, VT_A, 4) &&
|
||||
VerifyField<uint8_t>(verifier, VT_B, 1) &&
|
||||
VerifyField<uint8_t>(verifier, VT_C_TYPE, 1) &&
|
||||
VerifyOffset(verifier, VT_C) &&
|
||||
VerifyUnion(verifier, c(), c_type()) &&
|
||||
VerifyField<int8_t>(verifier, VT_D, 1) &&
|
||||
VerifyOffset(verifier, VT_E) &&
|
||||
verifier.VerifyTable(e()) &&
|
||||
VerifyField<Evolution::V1::Struct>(verifier, VT_F, 8) &&
|
||||
VerifyOffset(verifier, VT_G) &&
|
||||
verifier.VerifyVector(g()) &&
|
||||
VerifyOffset(verifier, VT_H) &&
|
||||
verifier.VerifyVector(h()) &&
|
||||
verifier.VerifyVectorOfTables(h()) &&
|
||||
VerifyField<int32_t>(verifier, VT_I, 4) &&
|
||||
VerifyField<uint8_t>(verifier, VT_J_TYPE, 1) &&
|
||||
VerifyOffset(verifier, VT_J) &&
|
||||
VerifyUnion(verifier, j(), j_type()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
template<> inline const Evolution::V1::TableA *Root::c_as<Evolution::V1::TableA>() const {
|
||||
return c_as_TableA();
|
||||
}
|
||||
|
||||
template<> inline const Evolution::V1::TableB *Root::c_as<Evolution::V1::TableB>() const {
|
||||
return c_as_TableB();
|
||||
}
|
||||
|
||||
template<> inline const Evolution::V1::TableA *Root::j_as<Evolution::V1::TableA>() const {
|
||||
return j_as_TableA();
|
||||
}
|
||||
|
||||
template<> inline const Evolution::V1::TableB *Root::j_as<Evolution::V1::TableB>() const {
|
||||
return j_as_TableB();
|
||||
}
|
||||
|
||||
struct RootBuilder {
|
||||
typedef Root Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_a(int32_t a) {
|
||||
fbb_.AddElement<int32_t>(Root::VT_A, a, 0);
|
||||
}
|
||||
void add_b(bool b) {
|
||||
fbb_.AddElement<uint8_t>(Root::VT_B, static_cast<uint8_t>(b), 0);
|
||||
}
|
||||
void add_c_type(Evolution::V1::Union c_type) {
|
||||
fbb_.AddElement<uint8_t>(Root::VT_C_TYPE, static_cast<uint8_t>(c_type), 0);
|
||||
}
|
||||
void add_c(::flatbuffers::Offset<void> c) {
|
||||
fbb_.AddOffset(Root::VT_C, c);
|
||||
}
|
||||
void add_d(Evolution::V1::Enum d) {
|
||||
fbb_.AddElement<int8_t>(Root::VT_D, static_cast<int8_t>(d), 0);
|
||||
}
|
||||
void add_e(::flatbuffers::Offset<Evolution::V1::TableA> e) {
|
||||
fbb_.AddOffset(Root::VT_E, e);
|
||||
}
|
||||
void add_f(const Evolution::V1::Struct *f) {
|
||||
fbb_.AddStruct(Root::VT_F, f);
|
||||
}
|
||||
void add_g(::flatbuffers::Offset<::flatbuffers::Vector<int32_t>> g) {
|
||||
fbb_.AddOffset(Root::VT_G, g);
|
||||
}
|
||||
void add_h(::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<Evolution::V1::TableB>>> h) {
|
||||
fbb_.AddOffset(Root::VT_H, h);
|
||||
}
|
||||
void add_i(int32_t i) {
|
||||
fbb_.AddElement<int32_t>(Root::VT_I, i, 1234);
|
||||
}
|
||||
void add_j_type(Evolution::V1::Union j_type) {
|
||||
fbb_.AddElement<uint8_t>(Root::VT_J_TYPE, static_cast<uint8_t>(j_type), 0);
|
||||
}
|
||||
void add_j(::flatbuffers::Offset<void> j) {
|
||||
fbb_.AddOffset(Root::VT_J, j);
|
||||
}
|
||||
explicit RootBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<Root> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<Root>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<Root> CreateRoot(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t a = 0,
|
||||
bool b = false,
|
||||
Evolution::V1::Union c_type = Evolution::V1::Union::NONE,
|
||||
::flatbuffers::Offset<void> c = 0,
|
||||
Evolution::V1::Enum d = Evolution::V1::Enum::King,
|
||||
::flatbuffers::Offset<Evolution::V1::TableA> e = 0,
|
||||
const Evolution::V1::Struct *f = nullptr,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<int32_t>> g = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<Evolution::V1::TableB>>> h = 0,
|
||||
int32_t i = 1234,
|
||||
Evolution::V1::Union j_type = Evolution::V1::Union::NONE,
|
||||
::flatbuffers::Offset<void> j = 0) {
|
||||
RootBuilder builder_(_fbb);
|
||||
builder_.add_j(j);
|
||||
builder_.add_i(i);
|
||||
builder_.add_h(h);
|
||||
builder_.add_g(g);
|
||||
builder_.add_f(f);
|
||||
builder_.add_e(e);
|
||||
builder_.add_c(c);
|
||||
builder_.add_a(a);
|
||||
builder_.add_j_type(j_type);
|
||||
builder_.add_d(d);
|
||||
builder_.add_c_type(c_type);
|
||||
builder_.add_b(b);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<Root> CreateRootDirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t a = 0,
|
||||
bool b = false,
|
||||
Evolution::V1::Union c_type = Evolution::V1::Union::NONE,
|
||||
::flatbuffers::Offset<void> c = 0,
|
||||
Evolution::V1::Enum d = Evolution::V1::Enum::King,
|
||||
::flatbuffers::Offset<Evolution::V1::TableA> e = 0,
|
||||
const Evolution::V1::Struct *f = nullptr,
|
||||
const std::vector<int32_t> *g = nullptr,
|
||||
const std::vector<::flatbuffers::Offset<Evolution::V1::TableB>> *h = nullptr,
|
||||
int32_t i = 1234,
|
||||
Evolution::V1::Union j_type = Evolution::V1::Union::NONE,
|
||||
::flatbuffers::Offset<void> j = 0) {
|
||||
auto g__ = g ? _fbb.CreateVector<int32_t>(*g) : 0;
|
||||
auto h__ = h ? _fbb.CreateVector<::flatbuffers::Offset<Evolution::V1::TableB>>(*h) : 0;
|
||||
return Evolution::V1::CreateRoot(
|
||||
_fbb,
|
||||
a,
|
||||
b,
|
||||
c_type,
|
||||
c,
|
||||
d,
|
||||
e,
|
||||
f,
|
||||
g__,
|
||||
h__,
|
||||
i,
|
||||
j_type,
|
||||
j);
|
||||
}
|
||||
|
||||
template <bool B>
|
||||
inline bool VerifyUnion(::flatbuffers::VerifierTemplate<B> &verifier, const void *obj, Union type) {
|
||||
switch (type) {
|
||||
case Union::NONE: {
|
||||
return true;
|
||||
}
|
||||
case Union::TableA: {
|
||||
auto ptr = reinterpret_cast<const Evolution::V1::TableA *>(obj);
|
||||
return verifier.VerifyTable(ptr);
|
||||
}
|
||||
case Union::TableB: {
|
||||
auto ptr = reinterpret_cast<const Evolution::V1::TableB *>(obj);
|
||||
return verifier.VerifyTable(ptr);
|
||||
}
|
||||
default: return true;
|
||||
}
|
||||
}
|
||||
|
||||
template <bool B>
|
||||
inline bool VerifyUnionVector(::flatbuffers::VerifierTemplate<B> &verifier, const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *values, const ::flatbuffers::Vector<Union> *types) {
|
||||
if (!values || !types) return !values && !types;
|
||||
if (values->size() != types->size()) return false;
|
||||
for (::flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
|
||||
if (!VerifyUnion(
|
||||
verifier, values->Get(i), types->GetEnum<Union>(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
inline const Evolution::V1::Root *GetRoot(const void *buf) {
|
||||
return ::flatbuffers::GetRoot<Evolution::V1::Root>(buf);
|
||||
}
|
||||
|
||||
inline const Evolution::V1::Root *GetSizePrefixedRoot(const void *buf) {
|
||||
return ::flatbuffers::GetSizePrefixedRoot<Evolution::V1::Root>(buf);
|
||||
}
|
||||
|
||||
template <bool B = false>
|
||||
inline bool VerifyRootBuffer(
|
||||
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||
return verifier.template VerifyBuffer<Evolution::V1::Root>(nullptr);
|
||||
}
|
||||
|
||||
template <bool B = false>
|
||||
inline bool VerifySizePrefixedRootBuffer(
|
||||
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||
return verifier.template VerifySizePrefixedBuffer<Evolution::V1::Root>(nullptr);
|
||||
}
|
||||
|
||||
inline void FinishRootBuffer(
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<Evolution::V1::Root> root) {
|
||||
fbb.Finish(root);
|
||||
}
|
||||
|
||||
inline void FinishSizePrefixedRootBuffer(
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<Evolution::V1::Root> root) {
|
||||
fbb.FinishSizePrefixed(root);
|
||||
}
|
||||
|
||||
} // namespace V1
|
||||
} // namespace Evolution
|
||||
|
||||
#endif // FLATBUFFERS_GENERATED_EVOLUTIONV1_EVOLUTION_V1_H_
|
||||
621
tests/evolution_test/evolution_v2_generated.h
Normal file
621
tests/evolution_test/evolution_v2_generated.h
Normal file
@@ -0,0 +1,621 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
|
||||
#ifndef FLATBUFFERS_GENERATED_EVOLUTIONV2_EVOLUTION_V2_H_
|
||||
#define FLATBUFFERS_GENERATED_EVOLUTIONV2_EVOLUTION_V2_H_
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||
// generated, otherwise it may not be compatible.
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 19,
|
||||
"Non-compatible flatbuffers version included");
|
||||
|
||||
namespace Evolution {
|
||||
namespace V2 {
|
||||
|
||||
struct TableA;
|
||||
struct TableABuilder;
|
||||
|
||||
struct TableB;
|
||||
struct TableBBuilder;
|
||||
|
||||
struct TableC;
|
||||
struct TableCBuilder;
|
||||
|
||||
struct Struct;
|
||||
|
||||
struct Root;
|
||||
struct RootBuilder;
|
||||
|
||||
enum class Enum : int8_t {
|
||||
King = 0,
|
||||
Queen = 1,
|
||||
Rook = 2,
|
||||
Bishop = 3,
|
||||
MIN = King,
|
||||
MAX = Bishop
|
||||
};
|
||||
|
||||
inline const Enum (&EnumValuesEnum())[4] {
|
||||
static const Enum values[] = {
|
||||
Enum::King,
|
||||
Enum::Queen,
|
||||
Enum::Rook,
|
||||
Enum::Bishop
|
||||
};
|
||||
return values;
|
||||
}
|
||||
|
||||
inline const char * const *EnumNamesEnum() {
|
||||
static const char * const names[5] = {
|
||||
"King",
|
||||
"Queen",
|
||||
"Rook",
|
||||
"Bishop",
|
||||
nullptr
|
||||
};
|
||||
return names;
|
||||
}
|
||||
|
||||
inline const char *EnumNameEnum(Enum e) {
|
||||
if (::flatbuffers::IsOutRange(e, Enum::King, Enum::Bishop)) return "";
|
||||
const size_t index = static_cast<size_t>(e);
|
||||
return EnumNamesEnum()[index];
|
||||
}
|
||||
|
||||
enum class Union : uint8_t {
|
||||
NONE = 0,
|
||||
TableA = 1,
|
||||
TableB = 2,
|
||||
TableC = 3,
|
||||
MIN = NONE,
|
||||
MAX = TableC
|
||||
};
|
||||
|
||||
inline const Union (&EnumValuesUnion())[4] {
|
||||
static const Union values[] = {
|
||||
Union::NONE,
|
||||
Union::TableA,
|
||||
Union::TableB,
|
||||
Union::TableC
|
||||
};
|
||||
return values;
|
||||
}
|
||||
|
||||
inline const char * const *EnumNamesUnion() {
|
||||
static const char * const names[5] = {
|
||||
"NONE",
|
||||
"TableA",
|
||||
"TableB",
|
||||
"TableC",
|
||||
nullptr
|
||||
};
|
||||
return names;
|
||||
}
|
||||
|
||||
inline const char *EnumNameUnion(Union e) {
|
||||
if (::flatbuffers::IsOutRange(e, Union::NONE, Union::TableC)) return "";
|
||||
const size_t index = static_cast<size_t>(e);
|
||||
return EnumNamesUnion()[index];
|
||||
}
|
||||
|
||||
template<typename T> struct UnionTraits {
|
||||
static const Union enum_value = Union::NONE;
|
||||
};
|
||||
|
||||
template<> struct UnionTraits<Evolution::V2::TableA> {
|
||||
static const Union enum_value = Union::TableA;
|
||||
};
|
||||
|
||||
template<> struct UnionTraits<Evolution::V2::TableB> {
|
||||
static const Union enum_value = Union::TableB;
|
||||
};
|
||||
|
||||
template<> struct UnionTraits<Evolution::V2::TableC> {
|
||||
static const Union enum_value = Union::TableC;
|
||||
};
|
||||
|
||||
template <bool B = false>
|
||||
bool VerifyUnion(::flatbuffers::VerifierTemplate<B> &verifier, const void *obj, Union type);
|
||||
template <bool B = false>
|
||||
bool VerifyUnionVector(::flatbuffers::VerifierTemplate<B> &verifier, const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *values, const ::flatbuffers::Vector<Union> *types);
|
||||
|
||||
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) Struct FLATBUFFERS_FINAL_CLASS {
|
||||
private:
|
||||
int32_t a_;
|
||||
int32_t padding0__;
|
||||
double b_;
|
||||
|
||||
public:
|
||||
Struct()
|
||||
: a_(0),
|
||||
padding0__(0),
|
||||
b_(0) {
|
||||
(void)padding0__;
|
||||
}
|
||||
Struct(int32_t _a, double _b)
|
||||
: a_(::flatbuffers::EndianScalar(_a)),
|
||||
padding0__(0),
|
||||
b_(::flatbuffers::EndianScalar(_b)) {
|
||||
(void)padding0__;
|
||||
}
|
||||
int32_t a() const {
|
||||
return ::flatbuffers::EndianScalar(a_);
|
||||
}
|
||||
double b() const {
|
||||
return ::flatbuffers::EndianScalar(b_);
|
||||
}
|
||||
};
|
||||
FLATBUFFERS_STRUCT_END(Struct, 16);
|
||||
|
||||
inline bool operator==(const Struct &lhs, const Struct &rhs) {
|
||||
return
|
||||
(lhs.a() == rhs.a()) &&
|
||||
(lhs.b() == rhs.b());
|
||||
}
|
||||
|
||||
inline bool operator!=(const Struct &lhs, const Struct &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
template <typename H>
|
||||
inline H AbslHashValue(H h, const Struct &obj) {
|
||||
return H::combine(std::move(h), obj.a(), obj.b());
|
||||
}
|
||||
|
||||
struct TableA FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef TableABuilder Builder;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_A = 4,
|
||||
VT_B = 6,
|
||||
VT_C = 8
|
||||
};
|
||||
float a() const {
|
||||
return GetField<float>(VT_A, 0.0f);
|
||||
}
|
||||
int32_t b() const {
|
||||
return GetField<int32_t>(VT_B, 0);
|
||||
}
|
||||
const ::flatbuffers::String *c() const {
|
||||
return GetPointer<const ::flatbuffers::String *>(VT_C);
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<float>(verifier, VT_A, 4) &&
|
||||
VerifyField<int32_t>(verifier, VT_B, 4) &&
|
||||
VerifyOffset(verifier, VT_C) &&
|
||||
verifier.VerifyString(c()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct TableABuilder {
|
||||
typedef TableA Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_a(float a) {
|
||||
fbb_.AddElement<float>(TableA::VT_A, a, 0.0f);
|
||||
}
|
||||
void add_b(int32_t b) {
|
||||
fbb_.AddElement<int32_t>(TableA::VT_B, b, 0);
|
||||
}
|
||||
void add_c(::flatbuffers::Offset<::flatbuffers::String> c) {
|
||||
fbb_.AddOffset(TableA::VT_C, c);
|
||||
}
|
||||
explicit TableABuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<TableA> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<TableA>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<TableA> CreateTableA(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
float a = 0.0f,
|
||||
int32_t b = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::String> c = 0) {
|
||||
TableABuilder builder_(_fbb);
|
||||
builder_.add_c(c);
|
||||
builder_.add_b(b);
|
||||
builder_.add_a(a);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<TableA> CreateTableADirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
float a = 0.0f,
|
||||
int32_t b = 0,
|
||||
const char *c = nullptr) {
|
||||
auto c__ = c ? _fbb.CreateString(c) : 0;
|
||||
return Evolution::V2::CreateTableA(
|
||||
_fbb,
|
||||
a,
|
||||
b,
|
||||
c__);
|
||||
}
|
||||
|
||||
struct TableB FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef TableBBuilder Builder;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_A = 4
|
||||
};
|
||||
int32_t a() const {
|
||||
return GetField<int32_t>(VT_A, 0);
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int32_t>(verifier, VT_A, 4) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct TableBBuilder {
|
||||
typedef TableB Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_a(int32_t a) {
|
||||
fbb_.AddElement<int32_t>(TableB::VT_A, a, 0);
|
||||
}
|
||||
explicit TableBBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<TableB> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<TableB>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<TableB> CreateTableB(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t a = 0) {
|
||||
TableBBuilder builder_(_fbb);
|
||||
builder_.add_a(a);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct TableC FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef TableCBuilder Builder;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_A = 4,
|
||||
VT_B = 6
|
||||
};
|
||||
double a() const {
|
||||
return GetField<double>(VT_A, 0.0);
|
||||
}
|
||||
const ::flatbuffers::String *b() const {
|
||||
return GetPointer<const ::flatbuffers::String *>(VT_B);
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<double>(verifier, VT_A, 8) &&
|
||||
VerifyOffset(verifier, VT_B) &&
|
||||
verifier.VerifyString(b()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct TableCBuilder {
|
||||
typedef TableC Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_a(double a) {
|
||||
fbb_.AddElement<double>(TableC::VT_A, a, 0.0);
|
||||
}
|
||||
void add_b(::flatbuffers::Offset<::flatbuffers::String> b) {
|
||||
fbb_.AddOffset(TableC::VT_B, b);
|
||||
}
|
||||
explicit TableCBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<TableC> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<TableC>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<TableC> CreateTableC(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
double a = 0.0,
|
||||
::flatbuffers::Offset<::flatbuffers::String> b = 0) {
|
||||
TableCBuilder builder_(_fbb);
|
||||
builder_.add_a(a);
|
||||
builder_.add_b(b);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<TableC> CreateTableCDirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
double a = 0.0,
|
||||
const char *b = nullptr) {
|
||||
auto b__ = b ? _fbb.CreateString(b) : 0;
|
||||
return Evolution::V2::CreateTableC(
|
||||
_fbb,
|
||||
a,
|
||||
b__);
|
||||
}
|
||||
|
||||
struct Root FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef RootBuilder Builder;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_B = 6,
|
||||
VT_C_TYPE = 8,
|
||||
VT_C = 10,
|
||||
VT_D = 12,
|
||||
VT_E = 14,
|
||||
VT_FF = 16,
|
||||
VT_G = 18,
|
||||
VT_H = 20,
|
||||
VT_I = 22,
|
||||
VT_K = 28,
|
||||
VT_L = 30
|
||||
};
|
||||
bool b() const {
|
||||
return GetField<uint8_t>(VT_B, 0) != 0;
|
||||
}
|
||||
Evolution::V2::Union c_type() const {
|
||||
return static_cast<Evolution::V2::Union>(GetField<uint8_t>(VT_C_TYPE, 0));
|
||||
}
|
||||
const void *c() const {
|
||||
return GetPointer<const void *>(VT_C);
|
||||
}
|
||||
template<typename T> const T *c_as() const;
|
||||
const Evolution::V2::TableA *c_as_TableA() const {
|
||||
return c_type() == Evolution::V2::Union::TableA ? static_cast<const Evolution::V2::TableA *>(c()) : nullptr;
|
||||
}
|
||||
const Evolution::V2::TableB *c_as_TableB() const {
|
||||
return c_type() == Evolution::V2::Union::TableB ? static_cast<const Evolution::V2::TableB *>(c()) : nullptr;
|
||||
}
|
||||
const Evolution::V2::TableC *c_as_TableC() const {
|
||||
return c_type() == Evolution::V2::Union::TableC ? static_cast<const Evolution::V2::TableC *>(c()) : nullptr;
|
||||
}
|
||||
Evolution::V2::Enum d() const {
|
||||
return static_cast<Evolution::V2::Enum>(GetField<int8_t>(VT_D, 0));
|
||||
}
|
||||
const Evolution::V2::TableA *e() const {
|
||||
return GetPointer<const Evolution::V2::TableA *>(VT_E);
|
||||
}
|
||||
const Evolution::V2::Struct *ff() const {
|
||||
return GetStruct<const Evolution::V2::Struct *>(VT_FF);
|
||||
}
|
||||
const ::flatbuffers::Vector<int32_t> *g() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<int32_t> *>(VT_G);
|
||||
}
|
||||
const ::flatbuffers::Vector<::flatbuffers::Offset<Evolution::V2::TableB>> *h() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<Evolution::V2::TableB>> *>(VT_H);
|
||||
}
|
||||
uint32_t i() const {
|
||||
return GetField<uint32_t>(VT_I, 1234);
|
||||
}
|
||||
const Evolution::V2::TableC *k() const {
|
||||
return GetPointer<const Evolution::V2::TableC *>(VT_K);
|
||||
}
|
||||
uint8_t l() const {
|
||||
return GetField<uint8_t>(VT_L, 56);
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<uint8_t>(verifier, VT_B, 1) &&
|
||||
VerifyField<uint8_t>(verifier, VT_C_TYPE, 1) &&
|
||||
VerifyOffset(verifier, VT_C) &&
|
||||
VerifyUnion(verifier, c(), c_type()) &&
|
||||
VerifyField<int8_t>(verifier, VT_D, 1) &&
|
||||
VerifyOffset(verifier, VT_E) &&
|
||||
verifier.VerifyTable(e()) &&
|
||||
VerifyField<Evolution::V2::Struct>(verifier, VT_FF, 8) &&
|
||||
VerifyOffset(verifier, VT_G) &&
|
||||
verifier.VerifyVector(g()) &&
|
||||
VerifyOffset(verifier, VT_H) &&
|
||||
verifier.VerifyVector(h()) &&
|
||||
verifier.VerifyVectorOfTables(h()) &&
|
||||
VerifyField<uint32_t>(verifier, VT_I, 4) &&
|
||||
VerifyOffset(verifier, VT_K) &&
|
||||
verifier.VerifyTable(k()) &&
|
||||
VerifyField<uint8_t>(verifier, VT_L, 1) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
template<> inline const Evolution::V2::TableA *Root::c_as<Evolution::V2::TableA>() const {
|
||||
return c_as_TableA();
|
||||
}
|
||||
|
||||
template<> inline const Evolution::V2::TableB *Root::c_as<Evolution::V2::TableB>() const {
|
||||
return c_as_TableB();
|
||||
}
|
||||
|
||||
template<> inline const Evolution::V2::TableC *Root::c_as<Evolution::V2::TableC>() const {
|
||||
return c_as_TableC();
|
||||
}
|
||||
|
||||
struct RootBuilder {
|
||||
typedef Root Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_b(bool b) {
|
||||
fbb_.AddElement<uint8_t>(Root::VT_B, static_cast<uint8_t>(b), 0);
|
||||
}
|
||||
void add_c_type(Evolution::V2::Union c_type) {
|
||||
fbb_.AddElement<uint8_t>(Root::VT_C_TYPE, static_cast<uint8_t>(c_type), 0);
|
||||
}
|
||||
void add_c(::flatbuffers::Offset<void> c) {
|
||||
fbb_.AddOffset(Root::VT_C, c);
|
||||
}
|
||||
void add_d(Evolution::V2::Enum d) {
|
||||
fbb_.AddElement<int8_t>(Root::VT_D, static_cast<int8_t>(d), 0);
|
||||
}
|
||||
void add_e(::flatbuffers::Offset<Evolution::V2::TableA> e) {
|
||||
fbb_.AddOffset(Root::VT_E, e);
|
||||
}
|
||||
void add_ff(const Evolution::V2::Struct *ff) {
|
||||
fbb_.AddStruct(Root::VT_FF, ff);
|
||||
}
|
||||
void add_g(::flatbuffers::Offset<::flatbuffers::Vector<int32_t>> g) {
|
||||
fbb_.AddOffset(Root::VT_G, g);
|
||||
}
|
||||
void add_h(::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<Evolution::V2::TableB>>> h) {
|
||||
fbb_.AddOffset(Root::VT_H, h);
|
||||
}
|
||||
void add_i(uint32_t i) {
|
||||
fbb_.AddElement<uint32_t>(Root::VT_I, i, 1234);
|
||||
}
|
||||
void add_k(::flatbuffers::Offset<Evolution::V2::TableC> k) {
|
||||
fbb_.AddOffset(Root::VT_K, k);
|
||||
}
|
||||
void add_l(uint8_t l) {
|
||||
fbb_.AddElement<uint8_t>(Root::VT_L, l, 56);
|
||||
}
|
||||
explicit RootBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<Root> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<Root>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<Root> CreateRoot(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
bool b = false,
|
||||
Evolution::V2::Union c_type = Evolution::V2::Union::NONE,
|
||||
::flatbuffers::Offset<void> c = 0,
|
||||
Evolution::V2::Enum d = Evolution::V2::Enum::King,
|
||||
::flatbuffers::Offset<Evolution::V2::TableA> e = 0,
|
||||
const Evolution::V2::Struct *ff = nullptr,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<int32_t>> g = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<Evolution::V2::TableB>>> h = 0,
|
||||
uint32_t i = 1234,
|
||||
::flatbuffers::Offset<Evolution::V2::TableC> k = 0,
|
||||
uint8_t l = 56) {
|
||||
RootBuilder builder_(_fbb);
|
||||
builder_.add_k(k);
|
||||
builder_.add_i(i);
|
||||
builder_.add_h(h);
|
||||
builder_.add_g(g);
|
||||
builder_.add_ff(ff);
|
||||
builder_.add_e(e);
|
||||
builder_.add_c(c);
|
||||
builder_.add_l(l);
|
||||
builder_.add_d(d);
|
||||
builder_.add_c_type(c_type);
|
||||
builder_.add_b(b);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<Root> CreateRootDirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
bool b = false,
|
||||
Evolution::V2::Union c_type = Evolution::V2::Union::NONE,
|
||||
::flatbuffers::Offset<void> c = 0,
|
||||
Evolution::V2::Enum d = Evolution::V2::Enum::King,
|
||||
::flatbuffers::Offset<Evolution::V2::TableA> e = 0,
|
||||
const Evolution::V2::Struct *ff = nullptr,
|
||||
const std::vector<int32_t> *g = nullptr,
|
||||
const std::vector<::flatbuffers::Offset<Evolution::V2::TableB>> *h = nullptr,
|
||||
uint32_t i = 1234,
|
||||
::flatbuffers::Offset<Evolution::V2::TableC> k = 0,
|
||||
uint8_t l = 56) {
|
||||
auto g__ = g ? _fbb.CreateVector<int32_t>(*g) : 0;
|
||||
auto h__ = h ? _fbb.CreateVector<::flatbuffers::Offset<Evolution::V2::TableB>>(*h) : 0;
|
||||
return Evolution::V2::CreateRoot(
|
||||
_fbb,
|
||||
b,
|
||||
c_type,
|
||||
c,
|
||||
d,
|
||||
e,
|
||||
ff,
|
||||
g__,
|
||||
h__,
|
||||
i,
|
||||
k,
|
||||
l);
|
||||
}
|
||||
|
||||
template <bool B>
|
||||
inline bool VerifyUnion(::flatbuffers::VerifierTemplate<B> &verifier, const void *obj, Union type) {
|
||||
switch (type) {
|
||||
case Union::NONE: {
|
||||
return true;
|
||||
}
|
||||
case Union::TableA: {
|
||||
auto ptr = reinterpret_cast<const Evolution::V2::TableA *>(obj);
|
||||
return verifier.VerifyTable(ptr);
|
||||
}
|
||||
case Union::TableB: {
|
||||
auto ptr = reinterpret_cast<const Evolution::V2::TableB *>(obj);
|
||||
return verifier.VerifyTable(ptr);
|
||||
}
|
||||
case Union::TableC: {
|
||||
auto ptr = reinterpret_cast<const Evolution::V2::TableC *>(obj);
|
||||
return verifier.VerifyTable(ptr);
|
||||
}
|
||||
default: return true;
|
||||
}
|
||||
}
|
||||
|
||||
template <bool B>
|
||||
inline bool VerifyUnionVector(::flatbuffers::VerifierTemplate<B> &verifier, const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *values, const ::flatbuffers::Vector<Union> *types) {
|
||||
if (!values || !types) return !values && !types;
|
||||
if (values->size() != types->size()) return false;
|
||||
for (::flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
|
||||
if (!VerifyUnion(
|
||||
verifier, values->Get(i), types->GetEnum<Union>(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
inline const Evolution::V2::Root *GetRoot(const void *buf) {
|
||||
return ::flatbuffers::GetRoot<Evolution::V2::Root>(buf);
|
||||
}
|
||||
|
||||
inline const Evolution::V2::Root *GetSizePrefixedRoot(const void *buf) {
|
||||
return ::flatbuffers::GetSizePrefixedRoot<Evolution::V2::Root>(buf);
|
||||
}
|
||||
|
||||
template <bool B = false>
|
||||
inline bool VerifyRootBuffer(
|
||||
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||
return verifier.template VerifyBuffer<Evolution::V2::Root>(nullptr);
|
||||
}
|
||||
|
||||
template <bool B = false>
|
||||
inline bool VerifySizePrefixedRootBuffer(
|
||||
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||
return verifier.template VerifySizePrefixedBuffer<Evolution::V2::Root>(nullptr);
|
||||
}
|
||||
|
||||
inline void FinishRootBuffer(
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<Evolution::V2::Root> root) {
|
||||
fbb.Finish(root);
|
||||
}
|
||||
|
||||
inline void FinishSizePrefixedRootBuffer(
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<Evolution::V2::Root> root) {
|
||||
fbb.FinishSizePrefixed(root);
|
||||
}
|
||||
|
||||
} // namespace V2
|
||||
} // namespace Evolution
|
||||
|
||||
#endif // FLATBUFFERS_GENERATED_EVOLUTIONV2_EVOLUTION_V2_H_
|
||||
@@ -71,3 +71,12 @@ class SchemaTests:
|
||||
schema_json["enums"][0]["values"][2]["attributes"][1]["value"]
|
||||
== "Value 3 (deprecated)"
|
||||
)
|
||||
|
||||
def CircularStructDependency(self):
|
||||
try:
|
||||
flatc(["-c", "circular_struct_dependency.fbs"])
|
||||
assert False, "Expected flatc to fail on circular struct dependency"
|
||||
except subprocess.CalledProcessError:
|
||||
pass
|
||||
|
||||
flatc(["-c", "circular_table.fbs"])
|
||||
@@ -2,8 +2,8 @@
|
||||
#include <filesystem>
|
||||
#include <type_traits>
|
||||
|
||||
#include "64bit/test_64bit_generated.h"
|
||||
#include "64bit/test_64bit_bfbs_generated.h"
|
||||
#include "64bit/test_64bit_generated.h"
|
||||
#include "flatbuffers/base.h"
|
||||
#include "flatbuffers/flatbuffer_builder.h"
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
479
tests/include_test1_generated.rs
Normal file
479
tests/include_test1_generated.rs
Normal file
@@ -0,0 +1,479 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// @generated
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
pub enum TableAOffset {}
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
|
||||
pub struct TableA<'a> {
|
||||
pub _tab: ::flatbuffers::Table<'a>,
|
||||
}
|
||||
|
||||
impl<'a> ::flatbuffers::Follow<'a> for TableA<'a> {
|
||||
type Inner = TableA<'a>;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TableA<'a> {
|
||||
pub const VT_B: ::flatbuffers::VOffsetT = 4;
|
||||
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"TableA"
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||
TableA { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||
args: &'args TableAArgs<'args>
|
||||
) -> ::flatbuffers::WIPOffset<TableA<'bldr>> {
|
||||
let mut builder = TableABuilder::new(_fbb);
|
||||
if let Some(x) = args.b { builder.add_b(x); }
|
||||
builder.finish()
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> TableAT {
|
||||
let b = self.b().map(|x| {
|
||||
alloc::boxed::Box::new(x.unpack())
|
||||
});
|
||||
TableAT {
|
||||
b,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn b(&self) -> Option<my_game::other_name_space::TableB<'a>> {
|
||||
// Safety:
|
||||
// Created from valid Table for this object
|
||||
// which contains a valid value in this slot
|
||||
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>(TableA::VT_B, None)}
|
||||
}
|
||||
}
|
||||
|
||||
impl ::flatbuffers::Verifiable for TableA<'_> {
|
||||
#[inline]
|
||||
fn run_verifier(
|
||||
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||
v.visit_table(pos)?
|
||||
.visit_field::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>("b", Self::VT_B, false)?
|
||||
.finish();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
pub struct TableAArgs<'a> {
|
||||
pub b: Option<::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'a>>>,
|
||||
}
|
||||
impl<'a> Default for TableAArgs<'a> {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
TableAArgs {
|
||||
b: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TableABuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
|
||||
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
||||
}
|
||||
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> {
|
||||
#[inline]
|
||||
pub fn add_b(&mut self, b: ::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'b >>) {
|
||||
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<my_game::other_name_space::TableB>>(TableA::VT_B, b);
|
||||
}
|
||||
#[inline]
|
||||
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> {
|
||||
let start = _fbb.start_table();
|
||||
TableABuilder {
|
||||
fbb_: _fbb,
|
||||
start_: start,
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
|
||||
let o = self.fbb_.end_table(self.start_);
|
||||
::flatbuffers::WIPOffset::new(o.value())
|
||||
}
|
||||
}
|
||||
|
||||
impl ::core::fmt::Debug for TableA<'_> {
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
||||
let mut ds = f.debug_struct("TableA");
|
||||
ds.field("b", &self.b());
|
||||
ds.finish()
|
||||
}
|
||||
}
|
||||
#[non_exhaustive]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct TableAT {
|
||||
pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
|
||||
}
|
||||
impl Default for TableAT {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
b: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl TableAT {
|
||||
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
||||
&self,
|
||||
_fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
|
||||
) -> ::flatbuffers::WIPOffset<TableA<'b>> {
|
||||
let b = self.b.as_ref().map(|x|{
|
||||
x.pack(_fbb)
|
||||
});
|
||||
TableA::create(_fbb, &TableAArgs{
|
||||
b,
|
||||
})
|
||||
}
|
||||
}
|
||||
#[allow(unused_imports, dead_code)]
|
||||
pub mod my_game {
|
||||
|
||||
extern crate alloc;
|
||||
#[allow(unused_imports, dead_code)]
|
||||
pub mod other_name_space {
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||
pub const ENUM_MIN_FROM_INCLUDE: i64 = 0;
|
||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||
pub const ENUM_MAX_FROM_INCLUDE: i64 = 0;
|
||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||
#[allow(non_camel_case_types)]
|
||||
pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
|
||||
FromInclude::IncludeVal,
|
||||
];
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||
#[repr(transparent)]
|
||||
pub struct FromInclude(pub i64);
|
||||
#[allow(non_upper_case_globals)]
|
||||
impl FromInclude {
|
||||
pub const IncludeVal: Self = Self(0);
|
||||
|
||||
pub const ENUM_MIN: i64 = 0;
|
||||
pub const ENUM_MAX: i64 = 0;
|
||||
pub const ENUM_VALUES: &'static [Self] = &[
|
||||
Self::IncludeVal,
|
||||
];
|
||||
/// Returns the variant's name or "" if unknown.
|
||||
pub fn variant_name(self) -> Option<&'static str> {
|
||||
match self {
|
||||
Self::IncludeVal => Some("IncludeVal"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl ::core::fmt::Debug for FromInclude {
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||
if let Some(name) = self.variant_name() {
|
||||
f.write_str(name)
|
||||
} else {
|
||||
f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
|
||||
}
|
||||
}
|
||||
}
|
||||
impl<'a> ::flatbuffers::Follow<'a> for FromInclude {
|
||||
type Inner = Self;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
let b = unsafe { ::flatbuffers::read_scalar_at::<i64>(buf, loc) };
|
||||
Self(b)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::flatbuffers::Push for FromInclude {
|
||||
type Output = FromInclude;
|
||||
#[inline]
|
||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||
unsafe { ::flatbuffers::emplace_scalar::<i64>(dst, self.0) };
|
||||
}
|
||||
}
|
||||
|
||||
impl ::flatbuffers::EndianScalar for FromInclude {
|
||||
type Scalar = i64;
|
||||
#[inline]
|
||||
fn to_little_endian(self) -> i64 {
|
||||
self.0.to_le()
|
||||
}
|
||||
#[inline]
|
||||
#[allow(clippy::wrong_self_convention)]
|
||||
fn from_little_endian(v: i64) -> Self {
|
||||
let b = i64::from_le(v);
|
||||
Self(b)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ::flatbuffers::Verifiable for FromInclude {
|
||||
#[inline]
|
||||
fn run_verifier(
|
||||
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||
i64::run_verifier(v, pos)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::flatbuffers::SimpleToVerifyInSlice for FromInclude {}
|
||||
// struct Unused, aligned to 4
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
pub struct Unused(pub [u8; 4]);
|
||||
impl Default for Unused {
|
||||
fn default() -> Self {
|
||||
Self([0; 4])
|
||||
}
|
||||
}
|
||||
impl ::core::fmt::Debug for Unused {
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||
f.debug_struct("Unused")
|
||||
.field("a", &self.a())
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl ::flatbuffers::SimpleToVerifyInSlice for Unused {}
|
||||
impl<'a> ::flatbuffers::Follow<'a> for Unused {
|
||||
type Inner = &'a Unused;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
unsafe { <&'a Unused>::follow(buf, loc) }
|
||||
}
|
||||
}
|
||||
impl<'a> ::flatbuffers::Follow<'a> for &'a Unused {
|
||||
type Inner = &'a Unused;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
unsafe { ::flatbuffers::follow_cast_ref::<Unused>(buf, loc) }
|
||||
}
|
||||
}
|
||||
impl<'b> ::flatbuffers::Push for Unused {
|
||||
type Output = Unused;
|
||||
#[inline]
|
||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||
let src = unsafe { ::core::slice::from_raw_parts(self as *const Unused as *const u8, <Self as ::flatbuffers::Push>::size()) };
|
||||
dst.copy_from_slice(src);
|
||||
}
|
||||
#[inline]
|
||||
fn alignment() -> ::flatbuffers::PushAlignment {
|
||||
::flatbuffers::PushAlignment::new(4)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ::flatbuffers::Verifiable for Unused {
|
||||
#[inline]
|
||||
fn run_verifier(
|
||||
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||
v.in_buffer::<Self>(pos)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Unused {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
a: i32,
|
||||
) -> Self {
|
||||
let mut s = Self([0; 4]);
|
||||
s.set_a(a);
|
||||
s
|
||||
}
|
||||
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.OtherNameSpace.Unused"
|
||||
}
|
||||
|
||||
pub fn a(&self) -> i32 {
|
||||
let mut mem = ::core::mem::MaybeUninit::<<i32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid value in this slot
|
||||
::flatbuffers::EndianScalar::from_little_endian(unsafe {
|
||||
::core::ptr::copy_nonoverlapping(
|
||||
self.0[0..].as_ptr(),
|
||||
mem.as_mut_ptr() as *mut u8,
|
||||
::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||
);
|
||||
mem.assume_init()
|
||||
})
|
||||
}
|
||||
|
||||
pub fn set_a(&mut self, x: i32) {
|
||||
let x_le = ::flatbuffers::EndianScalar::to_little_endian(x);
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid value in this slot
|
||||
unsafe {
|
||||
::core::ptr::copy_nonoverlapping(
|
||||
&x_le as *const _ as *const u8,
|
||||
self.0[0..].as_mut_ptr(),
|
||||
::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> UnusedT {
|
||||
UnusedT {
|
||||
a: self.a(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
pub struct UnusedT {
|
||||
pub a: i32,
|
||||
}
|
||||
impl UnusedT {
|
||||
pub fn pack(&self) -> Unused {
|
||||
Unused::new(
|
||||
self.a,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub enum TableBOffset {}
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
|
||||
pub struct TableB<'a> {
|
||||
pub _tab: ::flatbuffers::Table<'a>,
|
||||
}
|
||||
|
||||
impl<'a> ::flatbuffers::Follow<'a> for TableB<'a> {
|
||||
type Inner = TableB<'a>;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TableB<'a> {
|
||||
pub const VT_A: ::flatbuffers::VOffsetT = 4;
|
||||
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.OtherNameSpace.TableB"
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||
TableB { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||
args: &'args TableBArgs<'args>
|
||||
) -> ::flatbuffers::WIPOffset<TableB<'bldr>> {
|
||||
let mut builder = TableBBuilder::new(_fbb);
|
||||
if let Some(x) = args.a { builder.add_a(x); }
|
||||
builder.finish()
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> TableBT {
|
||||
let a = self.a().map(|x| {
|
||||
alloc::boxed::Box::new(x.unpack())
|
||||
});
|
||||
TableBT {
|
||||
a,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn a(&self) -> Option<super::super::TableA<'a>> {
|
||||
// Safety:
|
||||
// Created from valid Table for this object
|
||||
// which contains a valid value in this slot
|
||||
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<super::super::TableA>>(TableB::VT_A, None)}
|
||||
}
|
||||
}
|
||||
|
||||
impl ::flatbuffers::Verifiable for TableB<'_> {
|
||||
#[inline]
|
||||
fn run_verifier(
|
||||
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||
v.visit_table(pos)?
|
||||
.visit_field::<::flatbuffers::ForwardsUOffset<super::super::TableA>>("a", Self::VT_A, false)?
|
||||
.finish();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
pub struct TableBArgs<'a> {
|
||||
pub a: Option<::flatbuffers::WIPOffset<super::super::TableA<'a>>>,
|
||||
}
|
||||
impl<'a> Default for TableBArgs<'a> {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
TableBArgs {
|
||||
a: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TableBBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
|
||||
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
||||
}
|
||||
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> {
|
||||
#[inline]
|
||||
pub fn add_a(&mut self, a: ::flatbuffers::WIPOffset<super::super::TableA<'b >>) {
|
||||
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::super::TableA>>(TableB::VT_A, a);
|
||||
}
|
||||
#[inline]
|
||||
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> {
|
||||
let start = _fbb.start_table();
|
||||
TableBBuilder {
|
||||
fbb_: _fbb,
|
||||
start_: start,
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
|
||||
let o = self.fbb_.end_table(self.start_);
|
||||
::flatbuffers::WIPOffset::new(o.value())
|
||||
}
|
||||
}
|
||||
|
||||
impl ::core::fmt::Debug for TableB<'_> {
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
||||
let mut ds = f.debug_struct("TableB");
|
||||
ds.field("a", &self.a());
|
||||
ds.finish()
|
||||
}
|
||||
}
|
||||
#[non_exhaustive]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct TableBT {
|
||||
pub a: Option<alloc::boxed::Box<super::super::TableAT>>,
|
||||
}
|
||||
impl Default for TableBT {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
a: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl TableBT {
|
||||
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
||||
&self,
|
||||
_fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
|
||||
) -> ::flatbuffers::WIPOffset<TableB<'b>> {
|
||||
let a = self.a.as_ref().map(|x|{
|
||||
x.pack(_fbb)
|
||||
});
|
||||
TableB::create(_fbb, &TableBArgs{
|
||||
a,
|
||||
})
|
||||
}
|
||||
}
|
||||
} // pub mod OtherNameSpace
|
||||
} // pub mod MyGame
|
||||
|
||||
479
tests/include_test2_generated.rs
Normal file
479
tests/include_test2_generated.rs
Normal file
@@ -0,0 +1,479 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// @generated
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
pub enum TableAOffset {}
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
|
||||
pub struct TableA<'a> {
|
||||
pub _tab: ::flatbuffers::Table<'a>,
|
||||
}
|
||||
|
||||
impl<'a> ::flatbuffers::Follow<'a> for TableA<'a> {
|
||||
type Inner = TableA<'a>;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TableA<'a> {
|
||||
pub const VT_B: ::flatbuffers::VOffsetT = 4;
|
||||
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"TableA"
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||
TableA { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||
args: &'args TableAArgs<'args>
|
||||
) -> ::flatbuffers::WIPOffset<TableA<'bldr>> {
|
||||
let mut builder = TableABuilder::new(_fbb);
|
||||
if let Some(x) = args.b { builder.add_b(x); }
|
||||
builder.finish()
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> TableAT {
|
||||
let b = self.b().map(|x| {
|
||||
alloc::boxed::Box::new(x.unpack())
|
||||
});
|
||||
TableAT {
|
||||
b,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn b(&self) -> Option<my_game::other_name_space::TableB<'a>> {
|
||||
// Safety:
|
||||
// Created from valid Table for this object
|
||||
// which contains a valid value in this slot
|
||||
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>(TableA::VT_B, None)}
|
||||
}
|
||||
}
|
||||
|
||||
impl ::flatbuffers::Verifiable for TableA<'_> {
|
||||
#[inline]
|
||||
fn run_verifier(
|
||||
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||
v.visit_table(pos)?
|
||||
.visit_field::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>("b", Self::VT_B, false)?
|
||||
.finish();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
pub struct TableAArgs<'a> {
|
||||
pub b: Option<::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'a>>>,
|
||||
}
|
||||
impl<'a> Default for TableAArgs<'a> {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
TableAArgs {
|
||||
b: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TableABuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
|
||||
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
||||
}
|
||||
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> {
|
||||
#[inline]
|
||||
pub fn add_b(&mut self, b: ::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'b >>) {
|
||||
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<my_game::other_name_space::TableB>>(TableA::VT_B, b);
|
||||
}
|
||||
#[inline]
|
||||
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> {
|
||||
let start = _fbb.start_table();
|
||||
TableABuilder {
|
||||
fbb_: _fbb,
|
||||
start_: start,
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
|
||||
let o = self.fbb_.end_table(self.start_);
|
||||
::flatbuffers::WIPOffset::new(o.value())
|
||||
}
|
||||
}
|
||||
|
||||
impl ::core::fmt::Debug for TableA<'_> {
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
||||
let mut ds = f.debug_struct("TableA");
|
||||
ds.field("b", &self.b());
|
||||
ds.finish()
|
||||
}
|
||||
}
|
||||
#[non_exhaustive]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct TableAT {
|
||||
pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
|
||||
}
|
||||
impl Default for TableAT {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
b: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl TableAT {
|
||||
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
||||
&self,
|
||||
_fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
|
||||
) -> ::flatbuffers::WIPOffset<TableA<'b>> {
|
||||
let b = self.b.as_ref().map(|x|{
|
||||
x.pack(_fbb)
|
||||
});
|
||||
TableA::create(_fbb, &TableAArgs{
|
||||
b,
|
||||
})
|
||||
}
|
||||
}
|
||||
#[allow(unused_imports, dead_code)]
|
||||
pub mod my_game {
|
||||
|
||||
extern crate alloc;
|
||||
#[allow(unused_imports, dead_code)]
|
||||
pub mod other_name_space {
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||
pub const ENUM_MIN_FROM_INCLUDE: i64 = 0;
|
||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||
pub const ENUM_MAX_FROM_INCLUDE: i64 = 0;
|
||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||
#[allow(non_camel_case_types)]
|
||||
pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
|
||||
FromInclude::IncludeVal,
|
||||
];
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||
#[repr(transparent)]
|
||||
pub struct FromInclude(pub i64);
|
||||
#[allow(non_upper_case_globals)]
|
||||
impl FromInclude {
|
||||
pub const IncludeVal: Self = Self(0);
|
||||
|
||||
pub const ENUM_MIN: i64 = 0;
|
||||
pub const ENUM_MAX: i64 = 0;
|
||||
pub const ENUM_VALUES: &'static [Self] = &[
|
||||
Self::IncludeVal,
|
||||
];
|
||||
/// Returns the variant's name or "" if unknown.
|
||||
pub fn variant_name(self) -> Option<&'static str> {
|
||||
match self {
|
||||
Self::IncludeVal => Some("IncludeVal"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl ::core::fmt::Debug for FromInclude {
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||
if let Some(name) = self.variant_name() {
|
||||
f.write_str(name)
|
||||
} else {
|
||||
f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
|
||||
}
|
||||
}
|
||||
}
|
||||
impl<'a> ::flatbuffers::Follow<'a> for FromInclude {
|
||||
type Inner = Self;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
let b = unsafe { ::flatbuffers::read_scalar_at::<i64>(buf, loc) };
|
||||
Self(b)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::flatbuffers::Push for FromInclude {
|
||||
type Output = FromInclude;
|
||||
#[inline]
|
||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||
unsafe { ::flatbuffers::emplace_scalar::<i64>(dst, self.0) };
|
||||
}
|
||||
}
|
||||
|
||||
impl ::flatbuffers::EndianScalar for FromInclude {
|
||||
type Scalar = i64;
|
||||
#[inline]
|
||||
fn to_little_endian(self) -> i64 {
|
||||
self.0.to_le()
|
||||
}
|
||||
#[inline]
|
||||
#[allow(clippy::wrong_self_convention)]
|
||||
fn from_little_endian(v: i64) -> Self {
|
||||
let b = i64::from_le(v);
|
||||
Self(b)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ::flatbuffers::Verifiable for FromInclude {
|
||||
#[inline]
|
||||
fn run_verifier(
|
||||
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||
i64::run_verifier(v, pos)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::flatbuffers::SimpleToVerifyInSlice for FromInclude {}
|
||||
// struct Unused, aligned to 4
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
pub struct Unused(pub [u8; 4]);
|
||||
impl Default for Unused {
|
||||
fn default() -> Self {
|
||||
Self([0; 4])
|
||||
}
|
||||
}
|
||||
impl ::core::fmt::Debug for Unused {
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||
f.debug_struct("Unused")
|
||||
.field("a", &self.a())
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl ::flatbuffers::SimpleToVerifyInSlice for Unused {}
|
||||
impl<'a> ::flatbuffers::Follow<'a> for Unused {
|
||||
type Inner = &'a Unused;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
unsafe { <&'a Unused>::follow(buf, loc) }
|
||||
}
|
||||
}
|
||||
impl<'a> ::flatbuffers::Follow<'a> for &'a Unused {
|
||||
type Inner = &'a Unused;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
unsafe { ::flatbuffers::follow_cast_ref::<Unused>(buf, loc) }
|
||||
}
|
||||
}
|
||||
impl<'b> ::flatbuffers::Push for Unused {
|
||||
type Output = Unused;
|
||||
#[inline]
|
||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||
let src = unsafe { ::core::slice::from_raw_parts(self as *const Unused as *const u8, <Self as ::flatbuffers::Push>::size()) };
|
||||
dst.copy_from_slice(src);
|
||||
}
|
||||
#[inline]
|
||||
fn alignment() -> ::flatbuffers::PushAlignment {
|
||||
::flatbuffers::PushAlignment::new(4)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ::flatbuffers::Verifiable for Unused {
|
||||
#[inline]
|
||||
fn run_verifier(
|
||||
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||
v.in_buffer::<Self>(pos)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Unused {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
a: i32,
|
||||
) -> Self {
|
||||
let mut s = Self([0; 4]);
|
||||
s.set_a(a);
|
||||
s
|
||||
}
|
||||
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.OtherNameSpace.Unused"
|
||||
}
|
||||
|
||||
pub fn a(&self) -> i32 {
|
||||
let mut mem = ::core::mem::MaybeUninit::<<i32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid value in this slot
|
||||
::flatbuffers::EndianScalar::from_little_endian(unsafe {
|
||||
::core::ptr::copy_nonoverlapping(
|
||||
self.0[0..].as_ptr(),
|
||||
mem.as_mut_ptr() as *mut u8,
|
||||
::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||
);
|
||||
mem.assume_init()
|
||||
})
|
||||
}
|
||||
|
||||
pub fn set_a(&mut self, x: i32) {
|
||||
let x_le = ::flatbuffers::EndianScalar::to_little_endian(x);
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid value in this slot
|
||||
unsafe {
|
||||
::core::ptr::copy_nonoverlapping(
|
||||
&x_le as *const _ as *const u8,
|
||||
self.0[0..].as_mut_ptr(),
|
||||
::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> UnusedT {
|
||||
UnusedT {
|
||||
a: self.a(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
pub struct UnusedT {
|
||||
pub a: i32,
|
||||
}
|
||||
impl UnusedT {
|
||||
pub fn pack(&self) -> Unused {
|
||||
Unused::new(
|
||||
self.a,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub enum TableBOffset {}
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
|
||||
pub struct TableB<'a> {
|
||||
pub _tab: ::flatbuffers::Table<'a>,
|
||||
}
|
||||
|
||||
impl<'a> ::flatbuffers::Follow<'a> for TableB<'a> {
|
||||
type Inner = TableB<'a>;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TableB<'a> {
|
||||
pub const VT_A: ::flatbuffers::VOffsetT = 4;
|
||||
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.OtherNameSpace.TableB"
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||
TableB { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||
args: &'args TableBArgs<'args>
|
||||
) -> ::flatbuffers::WIPOffset<TableB<'bldr>> {
|
||||
let mut builder = TableBBuilder::new(_fbb);
|
||||
if let Some(x) = args.a { builder.add_a(x); }
|
||||
builder.finish()
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> TableBT {
|
||||
let a = self.a().map(|x| {
|
||||
alloc::boxed::Box::new(x.unpack())
|
||||
});
|
||||
TableBT {
|
||||
a,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn a(&self) -> Option<super::super::TableA<'a>> {
|
||||
// Safety:
|
||||
// Created from valid Table for this object
|
||||
// which contains a valid value in this slot
|
||||
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<super::super::TableA>>(TableB::VT_A, None)}
|
||||
}
|
||||
}
|
||||
|
||||
impl ::flatbuffers::Verifiable for TableB<'_> {
|
||||
#[inline]
|
||||
fn run_verifier(
|
||||
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||
v.visit_table(pos)?
|
||||
.visit_field::<::flatbuffers::ForwardsUOffset<super::super::TableA>>("a", Self::VT_A, false)?
|
||||
.finish();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
pub struct TableBArgs<'a> {
|
||||
pub a: Option<::flatbuffers::WIPOffset<super::super::TableA<'a>>>,
|
||||
}
|
||||
impl<'a> Default for TableBArgs<'a> {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
TableBArgs {
|
||||
a: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TableBBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
|
||||
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
||||
}
|
||||
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> {
|
||||
#[inline]
|
||||
pub fn add_a(&mut self, a: ::flatbuffers::WIPOffset<super::super::TableA<'b >>) {
|
||||
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::super::TableA>>(TableB::VT_A, a);
|
||||
}
|
||||
#[inline]
|
||||
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> {
|
||||
let start = _fbb.start_table();
|
||||
TableBBuilder {
|
||||
fbb_: _fbb,
|
||||
start_: start,
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
|
||||
let o = self.fbb_.end_table(self.start_);
|
||||
::flatbuffers::WIPOffset::new(o.value())
|
||||
}
|
||||
}
|
||||
|
||||
impl ::core::fmt::Debug for TableB<'_> {
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
||||
let mut ds = f.debug_struct("TableB");
|
||||
ds.field("a", &self.a());
|
||||
ds.finish()
|
||||
}
|
||||
}
|
||||
#[non_exhaustive]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct TableBT {
|
||||
pub a: Option<alloc::boxed::Box<super::super::TableAT>>,
|
||||
}
|
||||
impl Default for TableBT {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
a: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl TableBT {
|
||||
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
||||
&self,
|
||||
_fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
|
||||
) -> ::flatbuffers::WIPOffset<TableB<'b>> {
|
||||
let a = self.a.as_ref().map(|x|{
|
||||
x.pack(_fbb)
|
||||
});
|
||||
TableB::create(_fbb, &TableBArgs{
|
||||
a,
|
||||
})
|
||||
}
|
||||
}
|
||||
} // pub mod OtherNameSpace
|
||||
} // pub mod MyGame
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "flatbuffers/idl.h"
|
||||
#include "monster_test_bfbs_generated.h"
|
||||
#include "monster_test_generated.h"
|
||||
#include "optional_scalars.fbs.h"
|
||||
#include "optional_scalars_generated.h"
|
||||
#include "test_assert.h"
|
||||
|
||||
namespace flatbuffers {
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
load("//:build_defs.bzl", "flatbuffer_cc_library")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
flatbuffer_cc_library(
|
||||
name = "key_field_sample_cc_fbs",
|
||||
srcs = ["key_field_sample.fbs"],
|
||||
filename_suffix = ".fbs",
|
||||
flatc_args = [
|
||||
"--gen-compare",
|
||||
"--gen-mutable",
|
||||
"--gen-object-api",
|
||||
"--reflect-names",
|
||||
"--filename-suffix .fbs",
|
||||
],
|
||||
)
|
||||
1033
tests/key_field/key_field_sample_generated.h
Normal file
1033
tests/key_field/key_field_sample_generated.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
#include "flatbuffers/idl.h"
|
||||
#include "key_field/key_field_sample.fbs.h"
|
||||
#include "key_field/key_field_sample_generated.h"
|
||||
#include "test_assert.h"
|
||||
|
||||
namespace flatbuffers {
|
||||
|
||||
420
tests/monster_extra_generated.h
Normal file
420
tests/monster_extra_generated.h
Normal file
@@ -0,0 +1,420 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
|
||||
#ifndef FLATBUFFERS_GENERATED_MONSTEREXTRA_MYGAME_H_
|
||||
#define FLATBUFFERS_GENERATED_MONSTEREXTRA_MYGAME_H_
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||
// generated, otherwise it may not be compatible.
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 19,
|
||||
"Non-compatible flatbuffers version included");
|
||||
|
||||
namespace MyGame {
|
||||
|
||||
struct MonsterExtra;
|
||||
struct MonsterExtraBuilder;
|
||||
struct MonsterExtraT;
|
||||
|
||||
bool operator==(const MonsterExtraT &lhs, const MonsterExtraT &rhs);
|
||||
bool operator!=(const MonsterExtraT &lhs, const MonsterExtraT &rhs);
|
||||
|
||||
inline const ::flatbuffers::TypeTable *MonsterExtraTypeTable();
|
||||
|
||||
struct MonsterExtraT : public ::flatbuffers::NativeTable {
|
||||
typedef MonsterExtra TableType;
|
||||
double d0 = std::numeric_limits<double>::quiet_NaN();
|
||||
double d1 = std::numeric_limits<double>::quiet_NaN();
|
||||
double d2 = std::numeric_limits<double>::infinity();
|
||||
double d3 = -std::numeric_limits<double>::infinity();
|
||||
float f0 = std::numeric_limits<float>::quiet_NaN();
|
||||
float f1 = std::numeric_limits<float>::quiet_NaN();
|
||||
float f2 = std::numeric_limits<float>::infinity();
|
||||
float f3 = -std::numeric_limits<float>::infinity();
|
||||
std::vector<double> dvec{};
|
||||
std::vector<float> fvec{};
|
||||
};
|
||||
|
||||
struct MonsterExtra FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef MonsterExtraT NativeTableType;
|
||||
typedef MonsterExtraBuilder Builder;
|
||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return MonsterExtraTypeTable();
|
||||
}
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_D0 = 4,
|
||||
VT_D1 = 6,
|
||||
VT_D2 = 8,
|
||||
VT_D3 = 10,
|
||||
VT_F0 = 12,
|
||||
VT_F1 = 14,
|
||||
VT_F2 = 16,
|
||||
VT_F3 = 18,
|
||||
VT_DVEC = 20,
|
||||
VT_FVEC = 22
|
||||
};
|
||||
double d0() const {
|
||||
return GetField<double>(VT_D0, std::numeric_limits<double>::quiet_NaN());
|
||||
}
|
||||
bool mutate_d0(double _d0 = std::numeric_limits<double>::quiet_NaN()) {
|
||||
return SetField<double>(VT_D0, _d0, std::numeric_limits<double>::quiet_NaN());
|
||||
}
|
||||
double d1() const {
|
||||
return GetField<double>(VT_D1, std::numeric_limits<double>::quiet_NaN());
|
||||
}
|
||||
bool mutate_d1(double _d1 = std::numeric_limits<double>::quiet_NaN()) {
|
||||
return SetField<double>(VT_D1, _d1, std::numeric_limits<double>::quiet_NaN());
|
||||
}
|
||||
double d2() const {
|
||||
return GetField<double>(VT_D2, std::numeric_limits<double>::infinity());
|
||||
}
|
||||
bool mutate_d2(double _d2 = std::numeric_limits<double>::infinity()) {
|
||||
return SetField<double>(VT_D2, _d2, std::numeric_limits<double>::infinity());
|
||||
}
|
||||
double d3() const {
|
||||
return GetField<double>(VT_D3, -std::numeric_limits<double>::infinity());
|
||||
}
|
||||
bool mutate_d3(double _d3 = -std::numeric_limits<double>::infinity()) {
|
||||
return SetField<double>(VT_D3, _d3, -std::numeric_limits<double>::infinity());
|
||||
}
|
||||
float f0() const {
|
||||
return GetField<float>(VT_F0, std::numeric_limits<float>::quiet_NaN());
|
||||
}
|
||||
bool mutate_f0(float _f0 = std::numeric_limits<float>::quiet_NaN()) {
|
||||
return SetField<float>(VT_F0, _f0, std::numeric_limits<float>::quiet_NaN());
|
||||
}
|
||||
float f1() const {
|
||||
return GetField<float>(VT_F1, std::numeric_limits<float>::quiet_NaN());
|
||||
}
|
||||
bool mutate_f1(float _f1 = std::numeric_limits<float>::quiet_NaN()) {
|
||||
return SetField<float>(VT_F1, _f1, std::numeric_limits<float>::quiet_NaN());
|
||||
}
|
||||
float f2() const {
|
||||
return GetField<float>(VT_F2, std::numeric_limits<float>::infinity());
|
||||
}
|
||||
bool mutate_f2(float _f2 = std::numeric_limits<float>::infinity()) {
|
||||
return SetField<float>(VT_F2, _f2, std::numeric_limits<float>::infinity());
|
||||
}
|
||||
float f3() const {
|
||||
return GetField<float>(VT_F3, -std::numeric_limits<float>::infinity());
|
||||
}
|
||||
bool mutate_f3(float _f3 = -std::numeric_limits<float>::infinity()) {
|
||||
return SetField<float>(VT_F3, _f3, -std::numeric_limits<float>::infinity());
|
||||
}
|
||||
const ::flatbuffers::Vector<double> *dvec() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<double> *>(VT_DVEC);
|
||||
}
|
||||
::flatbuffers::Vector<double> *mutable_dvec() {
|
||||
return GetPointer<::flatbuffers::Vector<double> *>(VT_DVEC);
|
||||
}
|
||||
const ::flatbuffers::Vector<float> *fvec() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<float> *>(VT_FVEC);
|
||||
}
|
||||
::flatbuffers::Vector<float> *mutable_fvec() {
|
||||
return GetPointer<::flatbuffers::Vector<float> *>(VT_FVEC);
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<double>(verifier, VT_D0, 8) &&
|
||||
VerifyField<double>(verifier, VT_D1, 8) &&
|
||||
VerifyField<double>(verifier, VT_D2, 8) &&
|
||||
VerifyField<double>(verifier, VT_D3, 8) &&
|
||||
VerifyField<float>(verifier, VT_F0, 4) &&
|
||||
VerifyField<float>(verifier, VT_F1, 4) &&
|
||||
VerifyField<float>(verifier, VT_F2, 4) &&
|
||||
VerifyField<float>(verifier, VT_F3, 4) &&
|
||||
VerifyOffset(verifier, VT_DVEC) &&
|
||||
verifier.VerifyVector(dvec()) &&
|
||||
VerifyOffset(verifier, VT_FVEC) &&
|
||||
verifier.VerifyVector(fvec()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
MonsterExtraT *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
void UnPackTo(MonsterExtraT *_o, const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
static ::flatbuffers::Offset<MonsterExtra> Pack(::flatbuffers::FlatBufferBuilder &_fbb, const MonsterExtraT* _o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
};
|
||||
|
||||
struct MonsterExtraBuilder {
|
||||
typedef MonsterExtra Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_d0(double d0) {
|
||||
fbb_.AddElement<double>(MonsterExtra::VT_D0, d0, std::numeric_limits<double>::quiet_NaN());
|
||||
}
|
||||
void add_d1(double d1) {
|
||||
fbb_.AddElement<double>(MonsterExtra::VT_D1, d1, std::numeric_limits<double>::quiet_NaN());
|
||||
}
|
||||
void add_d2(double d2) {
|
||||
fbb_.AddElement<double>(MonsterExtra::VT_D2, d2, std::numeric_limits<double>::infinity());
|
||||
}
|
||||
void add_d3(double d3) {
|
||||
fbb_.AddElement<double>(MonsterExtra::VT_D3, d3, -std::numeric_limits<double>::infinity());
|
||||
}
|
||||
void add_f0(float f0) {
|
||||
fbb_.AddElement<float>(MonsterExtra::VT_F0, f0, std::numeric_limits<float>::quiet_NaN());
|
||||
}
|
||||
void add_f1(float f1) {
|
||||
fbb_.AddElement<float>(MonsterExtra::VT_F1, f1, std::numeric_limits<float>::quiet_NaN());
|
||||
}
|
||||
void add_f2(float f2) {
|
||||
fbb_.AddElement<float>(MonsterExtra::VT_F2, f2, std::numeric_limits<float>::infinity());
|
||||
}
|
||||
void add_f3(float f3) {
|
||||
fbb_.AddElement<float>(MonsterExtra::VT_F3, f3, -std::numeric_limits<float>::infinity());
|
||||
}
|
||||
void add_dvec(::flatbuffers::Offset<::flatbuffers::Vector<double>> dvec) {
|
||||
fbb_.AddOffset(MonsterExtra::VT_DVEC, dvec);
|
||||
}
|
||||
void add_fvec(::flatbuffers::Offset<::flatbuffers::Vector<float>> fvec) {
|
||||
fbb_.AddOffset(MonsterExtra::VT_FVEC, fvec);
|
||||
}
|
||||
explicit MonsterExtraBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<MonsterExtra> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<MonsterExtra>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<MonsterExtra> CreateMonsterExtra(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
double d0 = std::numeric_limits<double>::quiet_NaN(),
|
||||
double d1 = std::numeric_limits<double>::quiet_NaN(),
|
||||
double d2 = std::numeric_limits<double>::infinity(),
|
||||
double d3 = -std::numeric_limits<double>::infinity(),
|
||||
float f0 = std::numeric_limits<float>::quiet_NaN(),
|
||||
float f1 = std::numeric_limits<float>::quiet_NaN(),
|
||||
float f2 = std::numeric_limits<float>::infinity(),
|
||||
float f3 = -std::numeric_limits<float>::infinity(),
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<double>> dvec = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<float>> fvec = 0) {
|
||||
MonsterExtraBuilder builder_(_fbb);
|
||||
builder_.add_d3(d3);
|
||||
builder_.add_d2(d2);
|
||||
builder_.add_d1(d1);
|
||||
builder_.add_d0(d0);
|
||||
builder_.add_fvec(fvec);
|
||||
builder_.add_dvec(dvec);
|
||||
builder_.add_f3(f3);
|
||||
builder_.add_f2(f2);
|
||||
builder_.add_f1(f1);
|
||||
builder_.add_f0(f0);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<MonsterExtra> CreateMonsterExtraDirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
double d0 = std::numeric_limits<double>::quiet_NaN(),
|
||||
double d1 = std::numeric_limits<double>::quiet_NaN(),
|
||||
double d2 = std::numeric_limits<double>::infinity(),
|
||||
double d3 = -std::numeric_limits<double>::infinity(),
|
||||
float f0 = std::numeric_limits<float>::quiet_NaN(),
|
||||
float f1 = std::numeric_limits<float>::quiet_NaN(),
|
||||
float f2 = std::numeric_limits<float>::infinity(),
|
||||
float f3 = -std::numeric_limits<float>::infinity(),
|
||||
const std::vector<double> *dvec = nullptr,
|
||||
const std::vector<float> *fvec = nullptr) {
|
||||
auto dvec__ = dvec ? _fbb.CreateVector<double>(*dvec) : 0;
|
||||
auto fvec__ = fvec ? _fbb.CreateVector<float>(*fvec) : 0;
|
||||
return MyGame::CreateMonsterExtra(
|
||||
_fbb,
|
||||
d0,
|
||||
d1,
|
||||
d2,
|
||||
d3,
|
||||
f0,
|
||||
f1,
|
||||
f2,
|
||||
f3,
|
||||
dvec__,
|
||||
fvec__);
|
||||
}
|
||||
|
||||
::flatbuffers::Offset<MonsterExtra> CreateMonsterExtra(::flatbuffers::FlatBufferBuilder &_fbb, const MonsterExtraT *_o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
|
||||
|
||||
inline bool operator==(const MonsterExtraT &lhs, const MonsterExtraT &rhs) {
|
||||
return
|
||||
(lhs.d0 == rhs.d0) &&
|
||||
(lhs.d1 == rhs.d1) &&
|
||||
(lhs.d2 == rhs.d2) &&
|
||||
(lhs.d3 == rhs.d3) &&
|
||||
(lhs.f0 == rhs.f0) &&
|
||||
(lhs.f1 == rhs.f1) &&
|
||||
(lhs.f2 == rhs.f2) &&
|
||||
(lhs.f3 == rhs.f3) &&
|
||||
(lhs.dvec == rhs.dvec) &&
|
||||
(lhs.fvec == rhs.fvec);
|
||||
}
|
||||
|
||||
inline bool operator!=(const MonsterExtraT &lhs, const MonsterExtraT &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
|
||||
inline MonsterExtraT *MonsterExtra::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
auto _o = std::unique_ptr<MonsterExtraT>(new MonsterExtraT());
|
||||
UnPackTo(_o.get(), _resolver);
|
||||
return _o.release();
|
||||
}
|
||||
|
||||
inline void MonsterExtra::UnPackTo(MonsterExtraT *_o, const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
(void)_o;
|
||||
(void)_resolver;
|
||||
{ auto _e = d0(); _o->d0 = _e; }
|
||||
{ auto _e = d1(); _o->d1 = _e; }
|
||||
{ auto _e = d2(); _o->d2 = _e; }
|
||||
{ auto _e = d3(); _o->d3 = _e; }
|
||||
{ auto _e = f0(); _o->f0 = _e; }
|
||||
{ auto _e = f1(); _o->f1 = _e; }
|
||||
{ auto _e = f2(); _o->f2 = _e; }
|
||||
{ auto _e = f3(); _o->f3 = _e; }
|
||||
{ auto _e = dvec(); if (_e) { _o->dvec.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->dvec[_i] = _e->Get(_i); } } else { _o->dvec.resize(0); } }
|
||||
{ auto _e = fvec(); if (_e) { _o->fvec.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->fvec[_i] = _e->Get(_i); } } else { _o->fvec.resize(0); } }
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<MonsterExtra> CreateMonsterExtra(::flatbuffers::FlatBufferBuilder &_fbb, const MonsterExtraT *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
return MonsterExtra::Pack(_fbb, _o, _rehasher);
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<MonsterExtra> MonsterExtra::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const MonsterExtraT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
(void)_rehasher;
|
||||
(void)_o;
|
||||
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const MonsterExtraT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||
auto _d0 = _o->d0;
|
||||
auto _d1 = _o->d1;
|
||||
auto _d2 = _o->d2;
|
||||
auto _d3 = _o->d3;
|
||||
auto _f0 = _o->f0;
|
||||
auto _f1 = _o->f1;
|
||||
auto _f2 = _o->f2;
|
||||
auto _f3 = _o->f3;
|
||||
auto _dvec = _o->dvec.size() ? _fbb.CreateVector(_o->dvec) : 0;
|
||||
auto _fvec = _o->fvec.size() ? _fbb.CreateVector(_o->fvec) : 0;
|
||||
return MyGame::CreateMonsterExtra(
|
||||
_fbb,
|
||||
_d0,
|
||||
_d1,
|
||||
_d2,
|
||||
_d3,
|
||||
_f0,
|
||||
_f1,
|
||||
_f2,
|
||||
_f3,
|
||||
_dvec,
|
||||
_fvec);
|
||||
}
|
||||
|
||||
inline const ::flatbuffers::TypeTable *MonsterExtraTypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_DOUBLE, 0, -1 },
|
||||
{ ::flatbuffers::ET_DOUBLE, 0, -1 },
|
||||
{ ::flatbuffers::ET_DOUBLE, 0, -1 },
|
||||
{ ::flatbuffers::ET_DOUBLE, 0, -1 },
|
||||
{ ::flatbuffers::ET_FLOAT, 0, -1 },
|
||||
{ ::flatbuffers::ET_FLOAT, 0, -1 },
|
||||
{ ::flatbuffers::ET_FLOAT, 0, -1 },
|
||||
{ ::flatbuffers::ET_FLOAT, 0, -1 },
|
||||
{ ::flatbuffers::ET_DOUBLE, 1, -1 },
|
||||
{ ::flatbuffers::ET_FLOAT, 1, -1 },
|
||||
{ ::flatbuffers::ET_INT, 0, -1 }
|
||||
};
|
||||
static const char * const names[] = {
|
||||
"d0",
|
||||
"d1",
|
||||
"d2",
|
||||
"d3",
|
||||
"f0",
|
||||
"f1",
|
||||
"f2",
|
||||
"f3",
|
||||
"dvec",
|
||||
"fvec",
|
||||
"deprec"
|
||||
};
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_TABLE, 11, type_codes, nullptr, nullptr, nullptr, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
inline const MyGame::MonsterExtra *GetMonsterExtra(const void *buf) {
|
||||
return ::flatbuffers::GetRoot<MyGame::MonsterExtra>(buf);
|
||||
}
|
||||
|
||||
inline const MyGame::MonsterExtra *GetSizePrefixedMonsterExtra(const void *buf) {
|
||||
return ::flatbuffers::GetSizePrefixedRoot<MyGame::MonsterExtra>(buf);
|
||||
}
|
||||
|
||||
inline MonsterExtra *GetMutableMonsterExtra(void *buf) {
|
||||
return ::flatbuffers::GetMutableRoot<MonsterExtra>(buf);
|
||||
}
|
||||
|
||||
inline MyGame::MonsterExtra *GetMutableSizePrefixedMonsterExtra(void *buf) {
|
||||
return ::flatbuffers::GetMutableSizePrefixedRoot<MyGame::MonsterExtra>(buf);
|
||||
}
|
||||
|
||||
inline const char *MonsterExtraIdentifier() {
|
||||
return "MONE";
|
||||
}
|
||||
|
||||
inline bool MonsterExtraBufferHasIdentifier(const void *buf) {
|
||||
return ::flatbuffers::BufferHasIdentifier(
|
||||
buf, MonsterExtraIdentifier());
|
||||
}
|
||||
|
||||
inline bool SizePrefixedMonsterExtraBufferHasIdentifier(const void *buf) {
|
||||
return ::flatbuffers::BufferHasIdentifier(
|
||||
buf, MonsterExtraIdentifier(), true);
|
||||
}
|
||||
|
||||
template <bool B = false>
|
||||
inline bool VerifyMonsterExtraBuffer(
|
||||
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||
return verifier.template VerifyBuffer<MyGame::MonsterExtra>(MonsterExtraIdentifier());
|
||||
}
|
||||
|
||||
template <bool B = false>
|
||||
inline bool VerifySizePrefixedMonsterExtraBuffer(
|
||||
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||
return verifier.template VerifySizePrefixedBuffer<MyGame::MonsterExtra>(MonsterExtraIdentifier());
|
||||
}
|
||||
|
||||
inline const char *MonsterExtraExtension() {
|
||||
return "mon";
|
||||
}
|
||||
|
||||
inline void FinishMonsterExtraBuffer(
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<MyGame::MonsterExtra> root) {
|
||||
fbb.Finish(root, MonsterExtraIdentifier());
|
||||
}
|
||||
|
||||
inline void FinishSizePrefixedMonsterExtraBuffer(
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<MyGame::MonsterExtra> root) {
|
||||
fbb.FinishSizePrefixed(root, MonsterExtraIdentifier());
|
||||
}
|
||||
|
||||
inline std::unique_ptr<MyGame::MonsterExtraT> UnPackMonsterExtra(
|
||||
const void *buf,
|
||||
const ::flatbuffers::resolver_function_t *res = nullptr) {
|
||||
return std::unique_ptr<MyGame::MonsterExtraT>(GetMonsterExtra(buf)->UnPack(res));
|
||||
}
|
||||
|
||||
inline std::unique_ptr<MyGame::MonsterExtraT> UnPackSizePrefixedMonsterExtra(
|
||||
const void *buf,
|
||||
const ::flatbuffers::resolver_function_t *res = nullptr) {
|
||||
return std::unique_ptr<MyGame::MonsterExtraT>(GetSizePrefixedMonsterExtra(buf)->UnPack(res));
|
||||
}
|
||||
|
||||
} // namespace MyGame
|
||||
|
||||
#endif // FLATBUFFERS_GENERATED_MONSTEREXTRA_MYGAME_H_
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "flatbuffers/registry.h"
|
||||
#include "flatbuffers/verifier.h"
|
||||
#include "is_quiet_nan.h"
|
||||
#include "monster_extra.fbs.h"
|
||||
#include "monster_extra_generated.h"
|
||||
#include "monster_test_generated.h"
|
||||
#include "test_assert.h"
|
||||
|
||||
|
||||
@@ -1761,6 +1761,13 @@ def MonsterAddInventory(builder, inventory):
|
||||
def MonsterStartInventoryVector(builder, numElems):
|
||||
return builder.StartVector(1, numElems, 1)
|
||||
|
||||
def MonsterCreateInventoryVector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(1, len(data), 1)
|
||||
for item in reversed(data):
|
||||
builder.PrependUint8(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def MonsterAddColor(builder, color):
|
||||
builder.PrependUint8Slot(6, color, 8)
|
||||
|
||||
@@ -1776,18 +1783,31 @@ def MonsterAddTest4(builder, test4):
|
||||
def MonsterStartTest4Vector(builder, numElems):
|
||||
return builder.StartVector(4, numElems, 2)
|
||||
|
||||
def MonsterCreateTest4Vector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(4, len(data), 2)
|
||||
for item in reversed(data):
|
||||
item.Pack(builder)
|
||||
return builder.EndVector()
|
||||
|
||||
def MonsterAddTestarrayofstring(builder, testarrayofstring):
|
||||
builder.PrependUOffsetTRelativeSlot(10, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayofstring), 0)
|
||||
|
||||
def MonsterStartTestarrayofstringVector(builder, numElems):
|
||||
return builder.StartVector(4, numElems, 4)
|
||||
|
||||
def MonsterCreateTestarrayofstringVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def MonsterAddTestarrayoftables(builder, testarrayoftables):
|
||||
builder.PrependUOffsetTRelativeSlot(11, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayoftables), 0)
|
||||
|
||||
def MonsterStartTestarrayoftablesVector(builder, numElems):
|
||||
return builder.StartVector(4, numElems, 4)
|
||||
|
||||
def MonsterCreateTestarrayoftablesVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def MonsterAddEnemy(builder, enemy):
|
||||
builder.PrependUOffsetTRelativeSlot(12, flatbuffers.number_types.UOffsetTFlags.py_type(enemy), 0)
|
||||
|
||||
@@ -1797,6 +1817,13 @@ def MonsterAddTestnestedflatbuffer(builder, testnestedflatbuffer):
|
||||
def MonsterStartTestnestedflatbufferVector(builder, numElems):
|
||||
return builder.StartVector(1, numElems, 1)
|
||||
|
||||
def MonsterCreateTestnestedflatbufferVector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(1, len(data), 1)
|
||||
for item in reversed(data):
|
||||
builder.PrependUint8(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def MonsterMakeTestnestedflatbufferVectorFromBytes(builder, bytes):
|
||||
builder.StartVector(1, len(bytes), 1)
|
||||
builder.head = builder.head - len(bytes)
|
||||
@@ -1838,6 +1865,13 @@ def MonsterAddTestarrayofbools(builder, testarrayofbools):
|
||||
def MonsterStartTestarrayofboolsVector(builder, numElems):
|
||||
return builder.StartVector(1, numElems, 1)
|
||||
|
||||
def MonsterCreateTestarrayofboolsVector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(1, len(data), 1)
|
||||
for item in reversed(data):
|
||||
builder.PrependBool(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def MonsterAddTestf(builder, testf):
|
||||
builder.PrependFloat32Slot(25, testf, 3.14159)
|
||||
|
||||
@@ -1853,36 +1887,74 @@ def MonsterAddTestarrayofstring2(builder, testarrayofstring2):
|
||||
def MonsterStartTestarrayofstring2Vector(builder, numElems):
|
||||
return builder.StartVector(4, numElems, 4)
|
||||
|
||||
def MonsterCreateTestarrayofstring2Vector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def MonsterAddTestarrayofsortedstruct(builder, testarrayofsortedstruct):
|
||||
builder.PrependUOffsetTRelativeSlot(29, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayofsortedstruct), 0)
|
||||
|
||||
def MonsterStartTestarrayofsortedstructVector(builder, numElems):
|
||||
return builder.StartVector(8, numElems, 4)
|
||||
|
||||
def MonsterCreateTestarrayofsortedstructVector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(8, len(data), 4)
|
||||
for item in reversed(data):
|
||||
item.Pack(builder)
|
||||
return builder.EndVector()
|
||||
|
||||
def MonsterAddFlex(builder, flex):
|
||||
builder.PrependUOffsetTRelativeSlot(30, flatbuffers.number_types.UOffsetTFlags.py_type(flex), 0)
|
||||
|
||||
def MonsterStartFlexVector(builder, numElems):
|
||||
return builder.StartVector(1, numElems, 1)
|
||||
|
||||
def MonsterCreateFlexVector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(1, len(data), 1)
|
||||
for item in reversed(data):
|
||||
builder.PrependUint8(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def MonsterAddTest5(builder, test5):
|
||||
builder.PrependUOffsetTRelativeSlot(31, flatbuffers.number_types.UOffsetTFlags.py_type(test5), 0)
|
||||
|
||||
def MonsterStartTest5Vector(builder, numElems):
|
||||
return builder.StartVector(4, numElems, 2)
|
||||
|
||||
def MonsterCreateTest5Vector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(4, len(data), 2)
|
||||
for item in reversed(data):
|
||||
item.Pack(builder)
|
||||
return builder.EndVector()
|
||||
|
||||
def MonsterAddVectorOfLongs(builder, vectorOfLongs):
|
||||
builder.PrependUOffsetTRelativeSlot(32, flatbuffers.number_types.UOffsetTFlags.py_type(vectorOfLongs), 0)
|
||||
|
||||
def MonsterStartVectorOfLongsVector(builder, numElems):
|
||||
return builder.StartVector(8, numElems, 8)
|
||||
|
||||
def MonsterCreateVectorOfLongsVector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(8, len(data), 8)
|
||||
for item in reversed(data):
|
||||
builder.PrependInt64(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def MonsterAddVectorOfDoubles(builder, vectorOfDoubles):
|
||||
builder.PrependUOffsetTRelativeSlot(33, flatbuffers.number_types.UOffsetTFlags.py_type(vectorOfDoubles), 0)
|
||||
|
||||
def MonsterStartVectorOfDoublesVector(builder, numElems):
|
||||
return builder.StartVector(8, numElems, 8)
|
||||
|
||||
def MonsterCreateVectorOfDoublesVector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(8, len(data), 8)
|
||||
for item in reversed(data):
|
||||
builder.PrependFloat64(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def MonsterAddParentNamespaceTest(builder, parentNamespaceTest):
|
||||
builder.PrependUOffsetTRelativeSlot(34, flatbuffers.number_types.UOffsetTFlags.py_type(parentNamespaceTest), 0)
|
||||
|
||||
@@ -1892,6 +1964,9 @@ def MonsterAddVectorOfReferrables(builder, vectorOfReferrables):
|
||||
def MonsterStartVectorOfReferrablesVector(builder, numElems):
|
||||
return builder.StartVector(4, numElems, 4)
|
||||
|
||||
def MonsterCreateVectorOfReferrablesVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def MonsterAddSingleWeakReference(builder, singleWeakReference):
|
||||
builder.PrependUint64Slot(36, singleWeakReference, 0)
|
||||
|
||||
@@ -1901,12 +1976,22 @@ def MonsterAddVectorOfWeakReferences(builder, vectorOfWeakReferences):
|
||||
def MonsterStartVectorOfWeakReferencesVector(builder, numElems):
|
||||
return builder.StartVector(8, numElems, 8)
|
||||
|
||||
def MonsterCreateVectorOfWeakReferencesVector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(8, len(data), 8)
|
||||
for item in reversed(data):
|
||||
builder.PrependUint64(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def MonsterAddVectorOfStrongReferrables(builder, vectorOfStrongReferrables):
|
||||
builder.PrependUOffsetTRelativeSlot(38, flatbuffers.number_types.UOffsetTFlags.py_type(vectorOfStrongReferrables), 0)
|
||||
|
||||
def MonsterStartVectorOfStrongReferrablesVector(builder, numElems):
|
||||
return builder.StartVector(4, numElems, 4)
|
||||
|
||||
def MonsterCreateVectorOfStrongReferrablesVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def MonsterAddCoOwningReference(builder, coOwningReference):
|
||||
builder.PrependUint64Slot(39, coOwningReference, 0)
|
||||
|
||||
@@ -1916,6 +2001,13 @@ def MonsterAddVectorOfCoOwningReferences(builder, vectorOfCoOwningReferences):
|
||||
def MonsterStartVectorOfCoOwningReferencesVector(builder, numElems):
|
||||
return builder.StartVector(8, numElems, 8)
|
||||
|
||||
def MonsterCreateVectorOfCoOwningReferencesVector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(8, len(data), 8)
|
||||
for item in reversed(data):
|
||||
builder.PrependUint64(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def MonsterAddNonOwningReference(builder, nonOwningReference):
|
||||
builder.PrependUint64Slot(41, nonOwningReference, 0)
|
||||
|
||||
@@ -1925,6 +2017,13 @@ def MonsterAddVectorOfNonOwningReferences(builder, vectorOfNonOwningReferences):
|
||||
def MonsterStartVectorOfNonOwningReferencesVector(builder, numElems):
|
||||
return builder.StartVector(8, numElems, 8)
|
||||
|
||||
def MonsterCreateVectorOfNonOwningReferencesVector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(8, len(data), 8)
|
||||
for item in reversed(data):
|
||||
builder.PrependUint64(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def MonsterAddAnyUniqueType(builder, anyUniqueType):
|
||||
builder.PrependUint8Slot(43, anyUniqueType, 0)
|
||||
|
||||
@@ -1943,6 +2042,13 @@ def MonsterAddVectorOfEnums(builder, vectorOfEnums):
|
||||
def MonsterStartVectorOfEnumsVector(builder, numElems):
|
||||
return builder.StartVector(1, numElems, 1)
|
||||
|
||||
def MonsterCreateVectorOfEnumsVector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(1, len(data), 1)
|
||||
for item in reversed(data):
|
||||
builder.PrependUint8(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def MonsterAddSignedEnum(builder, signedEnum):
|
||||
builder.PrependInt8Slot(48, signedEnum, -1)
|
||||
|
||||
@@ -1952,6 +2058,13 @@ def MonsterAddTestrequirednestedflatbuffer(builder, testrequirednestedflatbuffer
|
||||
def MonsterStartTestrequirednestedflatbufferVector(builder, numElems):
|
||||
return builder.StartVector(1, numElems, 1)
|
||||
|
||||
def MonsterCreateTestrequirednestedflatbufferVector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(1, len(data), 1)
|
||||
for item in reversed(data):
|
||||
builder.PrependUint8(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def MonsterMakeTestrequirednestedflatbufferVectorFromBytes(builder, bytes):
|
||||
builder.StartVector(1, len(bytes), 1)
|
||||
builder.head = builder.head - len(bytes)
|
||||
@@ -1963,6 +2076,9 @@ def MonsterAddScalarKeySortedTables(builder, scalarKeySortedTables):
|
||||
def MonsterStartScalarKeySortedTablesVector(builder, numElems):
|
||||
return builder.StartVector(4, numElems, 4)
|
||||
|
||||
def MonsterCreateScalarKeySortedTablesVector(builder, data):
|
||||
return builder.CreateVectorOfTables(data)
|
||||
|
||||
def MonsterAddNativeInline(builder, nativeInline):
|
||||
builder.PrependStructSlot(51, flatbuffers.number_types.UOffsetTFlags.py_type(nativeInline), 0)
|
||||
|
||||
@@ -2792,12 +2908,26 @@ def TypeAliasesAddV8(builder, v8):
|
||||
def TypeAliasesStartV8Vector(builder, numElems):
|
||||
return builder.StartVector(1, numElems, 1)
|
||||
|
||||
def TypeAliasesCreateV8Vector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(1, len(data), 1)
|
||||
for item in reversed(data):
|
||||
builder.PrependInt8(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def TypeAliasesAddVf64(builder, vf64):
|
||||
builder.PrependUOffsetTRelativeSlot(11, flatbuffers.number_types.UOffsetTFlags.py_type(vf64), 0)
|
||||
|
||||
def TypeAliasesStartVf64Vector(builder, numElems):
|
||||
return builder.StartVector(8, numElems, 8)
|
||||
|
||||
def TypeAliasesCreateVf64Vector(builder, data):
|
||||
data = list(data)
|
||||
builder.StartVector(8, len(data), 8)
|
||||
for item in reversed(data):
|
||||
builder.PrependFloat64(item)
|
||||
return builder.EndVector()
|
||||
|
||||
def TypeAliasesEnd(builder):
|
||||
return builder.EndObject()
|
||||
|
||||
|
||||
470
tests/namespace_test/namespace_test1_generated.h
Normal file
470
tests/namespace_test/namespace_test1_generated.h
Normal file
@@ -0,0 +1,470 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
|
||||
#ifndef FLATBUFFERS_GENERATED_NAMESPACETEST1_NAMESPACEA_NAMESPACEB_H_
|
||||
#define FLATBUFFERS_GENERATED_NAMESPACETEST1_NAMESPACEA_NAMESPACEB_H_
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||
// generated, otherwise it may not be compatible.
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 19,
|
||||
"Non-compatible flatbuffers version included");
|
||||
|
||||
namespace NamespaceA {
|
||||
namespace NamespaceB {
|
||||
|
||||
struct TableInNestedNS;
|
||||
struct TableInNestedNSBuilder;
|
||||
struct TableInNestedNST;
|
||||
|
||||
struct StructInNestedNS;
|
||||
|
||||
bool operator==(const TableInNestedNST &lhs, const TableInNestedNST &rhs);
|
||||
bool operator!=(const TableInNestedNST &lhs, const TableInNestedNST &rhs);
|
||||
bool operator==(const StructInNestedNS &lhs, const StructInNestedNS &rhs);
|
||||
bool operator!=(const StructInNestedNS &lhs, const StructInNestedNS &rhs);
|
||||
|
||||
inline const ::flatbuffers::TypeTable *TableInNestedNSTypeTable();
|
||||
|
||||
inline const ::flatbuffers::TypeTable *StructInNestedNSTypeTable();
|
||||
|
||||
enum UnionInNestedNS : uint8_t {
|
||||
UnionInNestedNS_NONE = 0,
|
||||
UnionInNestedNS_TableInNestedNS = 1,
|
||||
UnionInNestedNS_MIN = UnionInNestedNS_NONE,
|
||||
UnionInNestedNS_MAX = UnionInNestedNS_TableInNestedNS
|
||||
};
|
||||
|
||||
inline const UnionInNestedNS (&EnumValuesUnionInNestedNS())[2] {
|
||||
static const UnionInNestedNS values[] = {
|
||||
UnionInNestedNS_NONE,
|
||||
UnionInNestedNS_TableInNestedNS
|
||||
};
|
||||
return values;
|
||||
}
|
||||
|
||||
inline const char * const *EnumNamesUnionInNestedNS() {
|
||||
static const char * const names[3] = {
|
||||
"NONE",
|
||||
"TableInNestedNS",
|
||||
nullptr
|
||||
};
|
||||
return names;
|
||||
}
|
||||
|
||||
inline const char *EnumNameUnionInNestedNS(UnionInNestedNS e) {
|
||||
if (::flatbuffers::IsOutRange(e, UnionInNestedNS_NONE, UnionInNestedNS_TableInNestedNS)) return "";
|
||||
const size_t index = static_cast<size_t>(e);
|
||||
return EnumNamesUnionInNestedNS()[index];
|
||||
}
|
||||
|
||||
template<typename T> struct UnionInNestedNSTraits {
|
||||
static const UnionInNestedNS enum_value = UnionInNestedNS_NONE;
|
||||
};
|
||||
|
||||
template<> struct UnionInNestedNSTraits<NamespaceA::NamespaceB::TableInNestedNS> {
|
||||
static const UnionInNestedNS enum_value = UnionInNestedNS_TableInNestedNS;
|
||||
};
|
||||
|
||||
template<typename T> struct UnionInNestedNSUnionTraits {
|
||||
static const UnionInNestedNS enum_value = UnionInNestedNS_NONE;
|
||||
};
|
||||
|
||||
template<> struct UnionInNestedNSUnionTraits<NamespaceA::NamespaceB::TableInNestedNST> {
|
||||
static const UnionInNestedNS enum_value = UnionInNestedNS_TableInNestedNS;
|
||||
};
|
||||
|
||||
struct UnionInNestedNSUnion {
|
||||
UnionInNestedNS type;
|
||||
void *value;
|
||||
|
||||
UnionInNestedNSUnion() : type(UnionInNestedNS_NONE), value(nullptr) {}
|
||||
UnionInNestedNSUnion(UnionInNestedNSUnion&& u) FLATBUFFERS_NOEXCEPT :
|
||||
type(UnionInNestedNS_NONE), value(nullptr)
|
||||
{ std::swap(type, u.type); std::swap(value, u.value); }
|
||||
UnionInNestedNSUnion(const UnionInNestedNSUnion &);
|
||||
UnionInNestedNSUnion &operator=(const UnionInNestedNSUnion &u)
|
||||
{ UnionInNestedNSUnion t(u); std::swap(type, t.type); std::swap(value, t.value); return *this; }
|
||||
UnionInNestedNSUnion &operator=(UnionInNestedNSUnion &&u) FLATBUFFERS_NOEXCEPT
|
||||
{ std::swap(type, u.type); std::swap(value, u.value); return *this; }
|
||||
~UnionInNestedNSUnion() { Reset(); }
|
||||
|
||||
void Reset();
|
||||
|
||||
template <typename T>
|
||||
void Set(T&& val) {
|
||||
typedef typename std::remove_reference<T>::type RT;
|
||||
Reset();
|
||||
type = UnionInNestedNSUnionTraits<RT>::enum_value;
|
||||
if (type != UnionInNestedNS_NONE) {
|
||||
value = new RT(std::forward<T>(val));
|
||||
}
|
||||
}
|
||||
|
||||
static void *UnPack(const void *obj, UnionInNestedNS type, const ::flatbuffers::resolver_function_t *resolver);
|
||||
::flatbuffers::Offset<void> Pack(::flatbuffers::FlatBufferBuilder &_fbb, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr) const;
|
||||
|
||||
NamespaceA::NamespaceB::TableInNestedNST *AsTableInNestedNS() {
|
||||
return type == UnionInNestedNS_TableInNestedNS ?
|
||||
reinterpret_cast<NamespaceA::NamespaceB::TableInNestedNST *>(value) : nullptr;
|
||||
}
|
||||
const NamespaceA::NamespaceB::TableInNestedNST *AsTableInNestedNS() const {
|
||||
return type == UnionInNestedNS_TableInNestedNS ?
|
||||
reinterpret_cast<const NamespaceA::NamespaceB::TableInNestedNST *>(value) : nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
inline bool operator==(const UnionInNestedNSUnion &lhs, const UnionInNestedNSUnion &rhs) {
|
||||
if (lhs.type != rhs.type) return false;
|
||||
switch (lhs.type) {
|
||||
case UnionInNestedNS_NONE: {
|
||||
return true;
|
||||
}
|
||||
case UnionInNestedNS_TableInNestedNS: {
|
||||
return *(reinterpret_cast<const NamespaceA::NamespaceB::TableInNestedNST *>(lhs.value)) ==
|
||||
*(reinterpret_cast<const NamespaceA::NamespaceB::TableInNestedNST *>(rhs.value));
|
||||
}
|
||||
default: {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline bool operator!=(const UnionInNestedNSUnion &lhs, const UnionInNestedNSUnion &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
template <bool B = false>
|
||||
bool VerifyUnionInNestedNS(::flatbuffers::VerifierTemplate<B> &verifier, const void *obj, UnionInNestedNS type);
|
||||
template <bool B = false>
|
||||
bool VerifyUnionInNestedNSVector(::flatbuffers::VerifierTemplate<B> &verifier, const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *values, const ::flatbuffers::Vector<uint8_t> *types);
|
||||
|
||||
enum EnumInNestedNS : int8_t {
|
||||
EnumInNestedNS_A = 0,
|
||||
EnumInNestedNS_B = 1,
|
||||
EnumInNestedNS_C = 2,
|
||||
EnumInNestedNS_MIN = EnumInNestedNS_A,
|
||||
EnumInNestedNS_MAX = EnumInNestedNS_C
|
||||
};
|
||||
|
||||
inline const EnumInNestedNS (&EnumValuesEnumInNestedNS())[3] {
|
||||
static const EnumInNestedNS values[] = {
|
||||
EnumInNestedNS_A,
|
||||
EnumInNestedNS_B,
|
||||
EnumInNestedNS_C
|
||||
};
|
||||
return values;
|
||||
}
|
||||
|
||||
inline const char * const *EnumNamesEnumInNestedNS() {
|
||||
static const char * const names[4] = {
|
||||
"A",
|
||||
"B",
|
||||
"C",
|
||||
nullptr
|
||||
};
|
||||
return names;
|
||||
}
|
||||
|
||||
inline const char *EnumNameEnumInNestedNS(EnumInNestedNS e) {
|
||||
if (::flatbuffers::IsOutRange(e, EnumInNestedNS_A, EnumInNestedNS_C)) return "";
|
||||
const size_t index = static_cast<size_t>(e);
|
||||
return EnumNamesEnumInNestedNS()[index];
|
||||
}
|
||||
|
||||
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) StructInNestedNS FLATBUFFERS_FINAL_CLASS {
|
||||
private:
|
||||
int32_t a_;
|
||||
int32_t b_;
|
||||
|
||||
public:
|
||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return StructInNestedNSTypeTable();
|
||||
}
|
||||
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||
return "NamespaceA.NamespaceB.StructInNestedNS";
|
||||
}
|
||||
StructInNestedNS()
|
||||
: a_(0),
|
||||
b_(0) {
|
||||
}
|
||||
StructInNestedNS(int32_t _a, int32_t _b)
|
||||
: a_(::flatbuffers::EndianScalar(_a)),
|
||||
b_(::flatbuffers::EndianScalar(_b)) {
|
||||
}
|
||||
int32_t a() const {
|
||||
return ::flatbuffers::EndianScalar(a_);
|
||||
}
|
||||
void mutate_a(int32_t _a) {
|
||||
::flatbuffers::WriteScalar(&a_, _a);
|
||||
}
|
||||
int32_t b() const {
|
||||
return ::flatbuffers::EndianScalar(b_);
|
||||
}
|
||||
void mutate_b(int32_t _b) {
|
||||
::flatbuffers::WriteScalar(&b_, _b);
|
||||
}
|
||||
};
|
||||
FLATBUFFERS_STRUCT_END(StructInNestedNS, 8);
|
||||
|
||||
inline bool operator==(const StructInNestedNS &lhs, const StructInNestedNS &rhs) {
|
||||
return
|
||||
(lhs.a() == rhs.a()) &&
|
||||
(lhs.b() == rhs.b());
|
||||
}
|
||||
|
||||
inline bool operator!=(const StructInNestedNS &lhs, const StructInNestedNS &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
|
||||
struct TableInNestedNST : public ::flatbuffers::NativeTable {
|
||||
typedef TableInNestedNS TableType;
|
||||
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||
return "NamespaceA.NamespaceB.TableInNestedNST";
|
||||
}
|
||||
int32_t foo = 0;
|
||||
};
|
||||
|
||||
struct TableInNestedNS FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef TableInNestedNST NativeTableType;
|
||||
typedef TableInNestedNSBuilder Builder;
|
||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return TableInNestedNSTypeTable();
|
||||
}
|
||||
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||
return "NamespaceA.NamespaceB.TableInNestedNS";
|
||||
}
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_FOO = 4
|
||||
};
|
||||
int32_t foo() const {
|
||||
return GetField<int32_t>(VT_FOO, 0);
|
||||
}
|
||||
bool mutate_foo(int32_t _foo = 0) {
|
||||
return SetField<int32_t>(VT_FOO, _foo, 0);
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int32_t>(verifier, VT_FOO, 4) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
TableInNestedNST *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
void UnPackTo(TableInNestedNST *_o, const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
static ::flatbuffers::Offset<TableInNestedNS> Pack(::flatbuffers::FlatBufferBuilder &_fbb, const TableInNestedNST* _o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
};
|
||||
|
||||
struct TableInNestedNSBuilder {
|
||||
typedef TableInNestedNS Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_foo(int32_t foo) {
|
||||
fbb_.AddElement<int32_t>(TableInNestedNS::VT_FOO, foo, 0);
|
||||
}
|
||||
explicit TableInNestedNSBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<TableInNestedNS> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<TableInNestedNS>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<TableInNestedNS> CreateTableInNestedNS(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t foo = 0) {
|
||||
TableInNestedNSBuilder builder_(_fbb);
|
||||
builder_.add_foo(foo);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
::flatbuffers::Offset<TableInNestedNS> CreateTableInNestedNS(::flatbuffers::FlatBufferBuilder &_fbb, const TableInNestedNST *_o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
|
||||
|
||||
inline bool operator==(const TableInNestedNST &lhs, const TableInNestedNST &rhs) {
|
||||
return
|
||||
(lhs.foo == rhs.foo);
|
||||
}
|
||||
|
||||
inline bool operator!=(const TableInNestedNST &lhs, const TableInNestedNST &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
|
||||
inline TableInNestedNST *TableInNestedNS::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
auto _o = std::unique_ptr<TableInNestedNST>(new TableInNestedNST());
|
||||
UnPackTo(_o.get(), _resolver);
|
||||
return _o.release();
|
||||
}
|
||||
|
||||
inline void TableInNestedNS::UnPackTo(TableInNestedNST *_o, const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
(void)_o;
|
||||
(void)_resolver;
|
||||
{ auto _e = foo(); _o->foo = _e; }
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<TableInNestedNS> CreateTableInNestedNS(::flatbuffers::FlatBufferBuilder &_fbb, const TableInNestedNST *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
return TableInNestedNS::Pack(_fbb, _o, _rehasher);
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<TableInNestedNS> TableInNestedNS::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const TableInNestedNST* _o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
(void)_rehasher;
|
||||
(void)_o;
|
||||
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const TableInNestedNST* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||
auto _foo = _o->foo;
|
||||
return NamespaceA::NamespaceB::CreateTableInNestedNS(
|
||||
_fbb,
|
||||
_foo);
|
||||
}
|
||||
|
||||
template <bool B>
|
||||
inline bool VerifyUnionInNestedNS(::flatbuffers::VerifierTemplate<B> &verifier, const void *obj, UnionInNestedNS type) {
|
||||
switch (type) {
|
||||
case UnionInNestedNS_NONE: {
|
||||
return true;
|
||||
}
|
||||
case UnionInNestedNS_TableInNestedNS: {
|
||||
auto ptr = reinterpret_cast<const NamespaceA::NamespaceB::TableInNestedNS *>(obj);
|
||||
return verifier.VerifyTable(ptr);
|
||||
}
|
||||
default: return true;
|
||||
}
|
||||
}
|
||||
|
||||
template <bool B>
|
||||
inline bool VerifyUnionInNestedNSVector(::flatbuffers::VerifierTemplate<B> &verifier, const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *values, const ::flatbuffers::Vector<uint8_t> *types) {
|
||||
if (!values || !types) return !values && !types;
|
||||
if (values->size() != types->size()) return false;
|
||||
for (::flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
|
||||
if (!VerifyUnionInNestedNS(
|
||||
verifier, values->Get(i), types->GetEnum<UnionInNestedNS>(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void *UnionInNestedNSUnion::UnPack(const void *obj, UnionInNestedNS type, const ::flatbuffers::resolver_function_t *resolver) {
|
||||
(void)resolver;
|
||||
switch (type) {
|
||||
case UnionInNestedNS_TableInNestedNS: {
|
||||
auto ptr = reinterpret_cast<const NamespaceA::NamespaceB::TableInNestedNS *>(obj);
|
||||
return ptr->UnPack(resolver);
|
||||
}
|
||||
default: return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<void> UnionInNestedNSUnion::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const ::flatbuffers::rehasher_function_t *_rehasher) const {
|
||||
(void)_rehasher;
|
||||
switch (type) {
|
||||
case UnionInNestedNS_TableInNestedNS: {
|
||||
auto ptr = reinterpret_cast<const NamespaceA::NamespaceB::TableInNestedNST *>(value);
|
||||
return CreateTableInNestedNS(_fbb, ptr, _rehasher).Union();
|
||||
}
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline UnionInNestedNSUnion::UnionInNestedNSUnion(const UnionInNestedNSUnion &u) : type(u.type), value(nullptr) {
|
||||
switch (type) {
|
||||
case UnionInNestedNS_TableInNestedNS: {
|
||||
value = new NamespaceA::NamespaceB::TableInNestedNST(*reinterpret_cast<NamespaceA::NamespaceB::TableInNestedNST *>(u.value));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
inline void UnionInNestedNSUnion::Reset() {
|
||||
switch (type) {
|
||||
case UnionInNestedNS_TableInNestedNS: {
|
||||
auto ptr = reinterpret_cast<NamespaceA::NamespaceB::TableInNestedNST *>(value);
|
||||
delete ptr;
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
value = nullptr;
|
||||
type = UnionInNestedNS_NONE;
|
||||
}
|
||||
|
||||
inline const ::flatbuffers::TypeTable *UnionInNestedNSTypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_SEQUENCE, 0, -1 },
|
||||
{ ::flatbuffers::ET_SEQUENCE, 0, 0 }
|
||||
};
|
||||
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||
NamespaceA::NamespaceB::TableInNestedNSTypeTable
|
||||
};
|
||||
static const char * const names[] = {
|
||||
"NONE",
|
||||
"TableInNestedNS"
|
||||
};
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_UNION, 2, type_codes, type_refs, nullptr, nullptr, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
inline const ::flatbuffers::TypeTable *EnumInNestedNSTypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_CHAR, 0, 0 },
|
||||
{ ::flatbuffers::ET_CHAR, 0, 0 },
|
||||
{ ::flatbuffers::ET_CHAR, 0, 0 }
|
||||
};
|
||||
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||
NamespaceA::NamespaceB::EnumInNestedNSTypeTable
|
||||
};
|
||||
static const char * const names[] = {
|
||||
"A",
|
||||
"B",
|
||||
"C"
|
||||
};
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_ENUM, 3, type_codes, type_refs, nullptr, nullptr, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
inline const ::flatbuffers::TypeTable *TableInNestedNSTypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_INT, 0, -1 }
|
||||
};
|
||||
static const char * const names[] = {
|
||||
"foo"
|
||||
};
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_TABLE, 1, type_codes, nullptr, nullptr, nullptr, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
inline const ::flatbuffers::TypeTable *StructInNestedNSTypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_INT, 0, -1 },
|
||||
{ ::flatbuffers::ET_INT, 0, -1 }
|
||||
};
|
||||
static const int64_t values[] = { 0, 4, 8 };
|
||||
static const char * const names[] = {
|
||||
"a",
|
||||
"b"
|
||||
};
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_STRUCT, 2, type_codes, nullptr, nullptr, values, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
} // namespace NamespaceB
|
||||
} // namespace NamespaceA
|
||||
|
||||
#endif // FLATBUFFERS_GENERATED_NAMESPACETEST1_NAMESPACEA_NAMESPACEB_H_
|
||||
614
tests/namespace_test/namespace_test2_generated.h
Normal file
614
tests/namespace_test/namespace_test2_generated.h
Normal file
@@ -0,0 +1,614 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
|
||||
#ifndef FLATBUFFERS_GENERATED_NAMESPACETEST2_NAMESPACEA_H_
|
||||
#define FLATBUFFERS_GENERATED_NAMESPACETEST2_NAMESPACEA_H_
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||
// generated, otherwise it may not be compatible.
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 19,
|
||||
"Non-compatible flatbuffers version included");
|
||||
|
||||
namespace NamespaceA {
|
||||
|
||||
struct TableInFirstNS;
|
||||
struct TableInFirstNSBuilder;
|
||||
struct TableInFirstNST;
|
||||
|
||||
} // namespace NamespaceA
|
||||
|
||||
namespace NamespaceC {
|
||||
|
||||
struct TableInC;
|
||||
struct TableInCBuilder;
|
||||
struct TableInCT;
|
||||
|
||||
} // namespace NamespaceC
|
||||
|
||||
namespace NamespaceA {
|
||||
|
||||
struct SecondTableInA;
|
||||
struct SecondTableInABuilder;
|
||||
struct SecondTableInAT;
|
||||
|
||||
bool operator==(const TableInFirstNST &lhs, const TableInFirstNST &rhs);
|
||||
bool operator!=(const TableInFirstNST &lhs, const TableInFirstNST &rhs);
|
||||
} // namespace NamespaceA
|
||||
|
||||
namespace NamespaceC {
|
||||
|
||||
bool operator==(const TableInCT &lhs, const TableInCT &rhs);
|
||||
bool operator!=(const TableInCT &lhs, const TableInCT &rhs);
|
||||
} // namespace NamespaceC
|
||||
|
||||
namespace NamespaceA {
|
||||
|
||||
bool operator==(const SecondTableInAT &lhs, const SecondTableInAT &rhs);
|
||||
bool operator!=(const SecondTableInAT &lhs, const SecondTableInAT &rhs);
|
||||
|
||||
inline const ::flatbuffers::TypeTable *TableInFirstNSTypeTable();
|
||||
|
||||
} // namespace NamespaceA
|
||||
|
||||
namespace NamespaceC {
|
||||
|
||||
inline const ::flatbuffers::TypeTable *TableInCTypeTable();
|
||||
|
||||
} // namespace NamespaceC
|
||||
|
||||
namespace NamespaceA {
|
||||
|
||||
inline const ::flatbuffers::TypeTable *SecondTableInATypeTable();
|
||||
|
||||
struct TableInFirstNST : public ::flatbuffers::NativeTable {
|
||||
typedef TableInFirstNS TableType;
|
||||
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||
return "NamespaceA.TableInFirstNST";
|
||||
}
|
||||
std::unique_ptr<NamespaceA::NamespaceB::TableInNestedNST> foo_table{};
|
||||
NamespaceA::NamespaceB::EnumInNestedNS foo_enum = NamespaceA::NamespaceB::EnumInNestedNS_A;
|
||||
NamespaceA::NamespaceB::UnionInNestedNSUnion foo_union{};
|
||||
std::unique_ptr<NamespaceA::NamespaceB::StructInNestedNS> foo_struct{};
|
||||
TableInFirstNST() = default;
|
||||
TableInFirstNST(const TableInFirstNST &o);
|
||||
TableInFirstNST(TableInFirstNST&&) FLATBUFFERS_NOEXCEPT = default;
|
||||
TableInFirstNST &operator=(TableInFirstNST o) FLATBUFFERS_NOEXCEPT;
|
||||
};
|
||||
|
||||
struct TableInFirstNS FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef TableInFirstNST NativeTableType;
|
||||
typedef TableInFirstNSBuilder Builder;
|
||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return TableInFirstNSTypeTable();
|
||||
}
|
||||
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||
return "NamespaceA.TableInFirstNS";
|
||||
}
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_FOO_TABLE = 4,
|
||||
VT_FOO_ENUM = 6,
|
||||
VT_FOO_UNION_TYPE = 8,
|
||||
VT_FOO_UNION = 10,
|
||||
VT_FOO_STRUCT = 12
|
||||
};
|
||||
const NamespaceA::NamespaceB::TableInNestedNS *foo_table() const {
|
||||
return GetPointer<const NamespaceA::NamespaceB::TableInNestedNS *>(VT_FOO_TABLE);
|
||||
}
|
||||
NamespaceA::NamespaceB::TableInNestedNS *mutable_foo_table() {
|
||||
return GetPointer<NamespaceA::NamespaceB::TableInNestedNS *>(VT_FOO_TABLE);
|
||||
}
|
||||
NamespaceA::NamespaceB::EnumInNestedNS foo_enum() const {
|
||||
return static_cast<NamespaceA::NamespaceB::EnumInNestedNS>(GetField<int8_t>(VT_FOO_ENUM, 0));
|
||||
}
|
||||
bool mutate_foo_enum(NamespaceA::NamespaceB::EnumInNestedNS _foo_enum = static_cast<NamespaceA::NamespaceB::EnumInNestedNS>(0)) {
|
||||
return SetField<int8_t>(VT_FOO_ENUM, static_cast<int8_t>(_foo_enum), 0);
|
||||
}
|
||||
NamespaceA::NamespaceB::UnionInNestedNS foo_union_type() const {
|
||||
return static_cast<NamespaceA::NamespaceB::UnionInNestedNS>(GetField<uint8_t>(VT_FOO_UNION_TYPE, 0));
|
||||
}
|
||||
const void *foo_union() const {
|
||||
return GetPointer<const void *>(VT_FOO_UNION);
|
||||
}
|
||||
template<typename T> const T *foo_union_as() const;
|
||||
const NamespaceA::NamespaceB::TableInNestedNS *foo_union_as_TableInNestedNS() const {
|
||||
return foo_union_type() == NamespaceA::NamespaceB::UnionInNestedNS_TableInNestedNS ? static_cast<const NamespaceA::NamespaceB::TableInNestedNS *>(foo_union()) : nullptr;
|
||||
}
|
||||
template<typename T> T *mutable_foo_union_as();
|
||||
NamespaceA::NamespaceB::TableInNestedNS *mutable_foo_union_as_TableInNestedNS() {
|
||||
return foo_union_type() == NamespaceA::NamespaceB::UnionInNestedNS_TableInNestedNS ? static_cast<NamespaceA::NamespaceB::TableInNestedNS *>(mutable_foo_union()) : nullptr;
|
||||
}
|
||||
void *mutable_foo_union() {
|
||||
return GetPointer<void *>(VT_FOO_UNION);
|
||||
}
|
||||
const NamespaceA::NamespaceB::StructInNestedNS *foo_struct() const {
|
||||
return GetStruct<const NamespaceA::NamespaceB::StructInNestedNS *>(VT_FOO_STRUCT);
|
||||
}
|
||||
NamespaceA::NamespaceB::StructInNestedNS *mutable_foo_struct() {
|
||||
return GetStruct<NamespaceA::NamespaceB::StructInNestedNS *>(VT_FOO_STRUCT);
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyOffset(verifier, VT_FOO_TABLE) &&
|
||||
verifier.VerifyTable(foo_table()) &&
|
||||
VerifyField<int8_t>(verifier, VT_FOO_ENUM, 1) &&
|
||||
VerifyField<uint8_t>(verifier, VT_FOO_UNION_TYPE, 1) &&
|
||||
VerifyOffset(verifier, VT_FOO_UNION) &&
|
||||
VerifyUnionInNestedNS(verifier, foo_union(), foo_union_type()) &&
|
||||
VerifyField<NamespaceA::NamespaceB::StructInNestedNS>(verifier, VT_FOO_STRUCT, 4) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
TableInFirstNST *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
void UnPackTo(TableInFirstNST *_o, const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
static ::flatbuffers::Offset<TableInFirstNS> Pack(::flatbuffers::FlatBufferBuilder &_fbb, const TableInFirstNST* _o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
};
|
||||
|
||||
template<> inline const NamespaceA::NamespaceB::TableInNestedNS *TableInFirstNS::foo_union_as<NamespaceA::NamespaceB::TableInNestedNS>() const {
|
||||
return foo_union_as_TableInNestedNS();
|
||||
}
|
||||
|
||||
template<> inline NamespaceA::NamespaceB::TableInNestedNS *TableInFirstNS::mutable_foo_union_as<NamespaceA::NamespaceB::TableInNestedNS>() {
|
||||
return mutable_foo_union_as_TableInNestedNS();
|
||||
}
|
||||
|
||||
struct TableInFirstNSBuilder {
|
||||
typedef TableInFirstNS Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_foo_table(::flatbuffers::Offset<NamespaceA::NamespaceB::TableInNestedNS> foo_table) {
|
||||
fbb_.AddOffset(TableInFirstNS::VT_FOO_TABLE, foo_table);
|
||||
}
|
||||
void add_foo_enum(NamespaceA::NamespaceB::EnumInNestedNS foo_enum) {
|
||||
fbb_.AddElement<int8_t>(TableInFirstNS::VT_FOO_ENUM, static_cast<int8_t>(foo_enum), 0);
|
||||
}
|
||||
void add_foo_union_type(NamespaceA::NamespaceB::UnionInNestedNS foo_union_type) {
|
||||
fbb_.AddElement<uint8_t>(TableInFirstNS::VT_FOO_UNION_TYPE, static_cast<uint8_t>(foo_union_type), 0);
|
||||
}
|
||||
void add_foo_union(::flatbuffers::Offset<void> foo_union) {
|
||||
fbb_.AddOffset(TableInFirstNS::VT_FOO_UNION, foo_union);
|
||||
}
|
||||
void add_foo_struct(const NamespaceA::NamespaceB::StructInNestedNS *foo_struct) {
|
||||
fbb_.AddStruct(TableInFirstNS::VT_FOO_STRUCT, foo_struct);
|
||||
}
|
||||
explicit TableInFirstNSBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<TableInFirstNS> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<TableInFirstNS>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<TableInFirstNS> CreateTableInFirstNS(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
::flatbuffers::Offset<NamespaceA::NamespaceB::TableInNestedNS> foo_table = 0,
|
||||
NamespaceA::NamespaceB::EnumInNestedNS foo_enum = NamespaceA::NamespaceB::EnumInNestedNS_A,
|
||||
NamespaceA::NamespaceB::UnionInNestedNS foo_union_type = NamespaceA::NamespaceB::UnionInNestedNS_NONE,
|
||||
::flatbuffers::Offset<void> foo_union = 0,
|
||||
const NamespaceA::NamespaceB::StructInNestedNS *foo_struct = nullptr) {
|
||||
TableInFirstNSBuilder builder_(_fbb);
|
||||
builder_.add_foo_struct(foo_struct);
|
||||
builder_.add_foo_union(foo_union);
|
||||
builder_.add_foo_table(foo_table);
|
||||
builder_.add_foo_union_type(foo_union_type);
|
||||
builder_.add_foo_enum(foo_enum);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
::flatbuffers::Offset<TableInFirstNS> CreateTableInFirstNS(::flatbuffers::FlatBufferBuilder &_fbb, const TableInFirstNST *_o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
|
||||
} // namespace NamespaceA
|
||||
|
||||
namespace NamespaceC {
|
||||
|
||||
struct TableInCT : public ::flatbuffers::NativeTable {
|
||||
typedef TableInC TableType;
|
||||
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||
return "NamespaceC.TableInCT";
|
||||
}
|
||||
std::unique_ptr<NamespaceA::TableInFirstNST> refer_to_a1{};
|
||||
std::unique_ptr<NamespaceA::SecondTableInAT> refer_to_a2{};
|
||||
TableInCT() = default;
|
||||
TableInCT(const TableInCT &o);
|
||||
TableInCT(TableInCT&&) FLATBUFFERS_NOEXCEPT = default;
|
||||
TableInCT &operator=(TableInCT o) FLATBUFFERS_NOEXCEPT;
|
||||
};
|
||||
|
||||
struct TableInC FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef TableInCT NativeTableType;
|
||||
typedef TableInCBuilder Builder;
|
||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return TableInCTypeTable();
|
||||
}
|
||||
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||
return "NamespaceC.TableInC";
|
||||
}
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_REFER_TO_A1 = 4,
|
||||
VT_REFER_TO_A2 = 6
|
||||
};
|
||||
const NamespaceA::TableInFirstNS *refer_to_a1() const {
|
||||
return GetPointer<const NamespaceA::TableInFirstNS *>(VT_REFER_TO_A1);
|
||||
}
|
||||
NamespaceA::TableInFirstNS *mutable_refer_to_a1() {
|
||||
return GetPointer<NamespaceA::TableInFirstNS *>(VT_REFER_TO_A1);
|
||||
}
|
||||
const NamespaceA::SecondTableInA *refer_to_a2() const {
|
||||
return GetPointer<const NamespaceA::SecondTableInA *>(VT_REFER_TO_A2);
|
||||
}
|
||||
NamespaceA::SecondTableInA *mutable_refer_to_a2() {
|
||||
return GetPointer<NamespaceA::SecondTableInA *>(VT_REFER_TO_A2);
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyOffset(verifier, VT_REFER_TO_A1) &&
|
||||
verifier.VerifyTable(refer_to_a1()) &&
|
||||
VerifyOffset(verifier, VT_REFER_TO_A2) &&
|
||||
verifier.VerifyTable(refer_to_a2()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
TableInCT *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
void UnPackTo(TableInCT *_o, const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
static ::flatbuffers::Offset<TableInC> Pack(::flatbuffers::FlatBufferBuilder &_fbb, const TableInCT* _o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
};
|
||||
|
||||
struct TableInCBuilder {
|
||||
typedef TableInC Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_refer_to_a1(::flatbuffers::Offset<NamespaceA::TableInFirstNS> refer_to_a1) {
|
||||
fbb_.AddOffset(TableInC::VT_REFER_TO_A1, refer_to_a1);
|
||||
}
|
||||
void add_refer_to_a2(::flatbuffers::Offset<NamespaceA::SecondTableInA> refer_to_a2) {
|
||||
fbb_.AddOffset(TableInC::VT_REFER_TO_A2, refer_to_a2);
|
||||
}
|
||||
explicit TableInCBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<TableInC> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<TableInC>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<TableInC> CreateTableInC(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
::flatbuffers::Offset<NamespaceA::TableInFirstNS> refer_to_a1 = 0,
|
||||
::flatbuffers::Offset<NamespaceA::SecondTableInA> refer_to_a2 = 0) {
|
||||
TableInCBuilder builder_(_fbb);
|
||||
builder_.add_refer_to_a2(refer_to_a2);
|
||||
builder_.add_refer_to_a1(refer_to_a1);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
::flatbuffers::Offset<TableInC> CreateTableInC(::flatbuffers::FlatBufferBuilder &_fbb, const TableInCT *_o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
|
||||
} // namespace NamespaceC
|
||||
|
||||
namespace NamespaceA {
|
||||
|
||||
struct SecondTableInAT : public ::flatbuffers::NativeTable {
|
||||
typedef SecondTableInA TableType;
|
||||
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||
return "NamespaceA.SecondTableInAT";
|
||||
}
|
||||
std::unique_ptr<NamespaceC::TableInCT> refer_to_c{};
|
||||
SecondTableInAT() = default;
|
||||
SecondTableInAT(const SecondTableInAT &o);
|
||||
SecondTableInAT(SecondTableInAT&&) FLATBUFFERS_NOEXCEPT = default;
|
||||
SecondTableInAT &operator=(SecondTableInAT o) FLATBUFFERS_NOEXCEPT;
|
||||
};
|
||||
|
||||
struct SecondTableInA FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef SecondTableInAT NativeTableType;
|
||||
typedef SecondTableInABuilder Builder;
|
||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return SecondTableInATypeTable();
|
||||
}
|
||||
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||
return "NamespaceA.SecondTableInA";
|
||||
}
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_REFER_TO_C = 4
|
||||
};
|
||||
const NamespaceC::TableInC *refer_to_c() const {
|
||||
return GetPointer<const NamespaceC::TableInC *>(VT_REFER_TO_C);
|
||||
}
|
||||
NamespaceC::TableInC *mutable_refer_to_c() {
|
||||
return GetPointer<NamespaceC::TableInC *>(VT_REFER_TO_C);
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyOffset(verifier, VT_REFER_TO_C) &&
|
||||
verifier.VerifyTable(refer_to_c()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
SecondTableInAT *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
void UnPackTo(SecondTableInAT *_o, const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
static ::flatbuffers::Offset<SecondTableInA> Pack(::flatbuffers::FlatBufferBuilder &_fbb, const SecondTableInAT* _o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
};
|
||||
|
||||
struct SecondTableInABuilder {
|
||||
typedef SecondTableInA Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_refer_to_c(::flatbuffers::Offset<NamespaceC::TableInC> refer_to_c) {
|
||||
fbb_.AddOffset(SecondTableInA::VT_REFER_TO_C, refer_to_c);
|
||||
}
|
||||
explicit SecondTableInABuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<SecondTableInA> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<SecondTableInA>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<SecondTableInA> CreateSecondTableInA(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
::flatbuffers::Offset<NamespaceC::TableInC> refer_to_c = 0) {
|
||||
SecondTableInABuilder builder_(_fbb);
|
||||
builder_.add_refer_to_c(refer_to_c);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
::flatbuffers::Offset<SecondTableInA> CreateSecondTableInA(::flatbuffers::FlatBufferBuilder &_fbb, const SecondTableInAT *_o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
|
||||
|
||||
inline bool operator==(const TableInFirstNST &lhs, const TableInFirstNST &rhs) {
|
||||
return
|
||||
((lhs.foo_table == rhs.foo_table) || (lhs.foo_table && rhs.foo_table && *lhs.foo_table == *rhs.foo_table)) &&
|
||||
(lhs.foo_enum == rhs.foo_enum) &&
|
||||
(lhs.foo_union == rhs.foo_union) &&
|
||||
((lhs.foo_struct == rhs.foo_struct) || (lhs.foo_struct && rhs.foo_struct && *lhs.foo_struct == *rhs.foo_struct));
|
||||
}
|
||||
|
||||
inline bool operator!=(const TableInFirstNST &lhs, const TableInFirstNST &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
|
||||
inline TableInFirstNST::TableInFirstNST(const TableInFirstNST &o)
|
||||
: foo_table((o.foo_table) ? new NamespaceA::NamespaceB::TableInNestedNST(*o.foo_table) : nullptr),
|
||||
foo_enum(o.foo_enum),
|
||||
foo_union(o.foo_union),
|
||||
foo_struct((o.foo_struct) ? new NamespaceA::NamespaceB::StructInNestedNS(*o.foo_struct) : nullptr) {
|
||||
}
|
||||
|
||||
inline TableInFirstNST &TableInFirstNST::operator=(TableInFirstNST o) FLATBUFFERS_NOEXCEPT {
|
||||
std::swap(foo_table, o.foo_table);
|
||||
std::swap(foo_enum, o.foo_enum);
|
||||
std::swap(foo_union, o.foo_union);
|
||||
std::swap(foo_struct, o.foo_struct);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline TableInFirstNST *TableInFirstNS::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
auto _o = std::unique_ptr<TableInFirstNST>(new TableInFirstNST());
|
||||
UnPackTo(_o.get(), _resolver);
|
||||
return _o.release();
|
||||
}
|
||||
|
||||
inline void TableInFirstNS::UnPackTo(TableInFirstNST *_o, const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
(void)_o;
|
||||
(void)_resolver;
|
||||
{ auto _e = foo_table(); if (_e) { if(_o->foo_table) { _e->UnPackTo(_o->foo_table.get(), _resolver); } else { _o->foo_table = std::unique_ptr<NamespaceA::NamespaceB::TableInNestedNST>(_e->UnPack(_resolver)); } } else if (_o->foo_table) { _o->foo_table.reset(); } }
|
||||
{ auto _e = foo_enum(); _o->foo_enum = _e; }
|
||||
{ auto _e = foo_union_type(); _o->foo_union.type = _e; }
|
||||
{ auto _e = foo_union(); if (_e) _o->foo_union.value = NamespaceA::NamespaceB::UnionInNestedNSUnion::UnPack(_e, foo_union_type(), _resolver); }
|
||||
{ auto _e = foo_struct(); if (_e) _o->foo_struct = std::unique_ptr<NamespaceA::NamespaceB::StructInNestedNS>(new NamespaceA::NamespaceB::StructInNestedNS(*_e)); }
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<TableInFirstNS> CreateTableInFirstNS(::flatbuffers::FlatBufferBuilder &_fbb, const TableInFirstNST *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
return TableInFirstNS::Pack(_fbb, _o, _rehasher);
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<TableInFirstNS> TableInFirstNS::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const TableInFirstNST* _o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
(void)_rehasher;
|
||||
(void)_o;
|
||||
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const TableInFirstNST* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||
auto _foo_table = _o->foo_table ? CreateTableInNestedNS(_fbb, _o->foo_table.get(), _rehasher) : 0;
|
||||
auto _foo_enum = _o->foo_enum;
|
||||
auto _foo_union_type = _o->foo_union.type;
|
||||
auto _foo_union = _o->foo_union.Pack(_fbb);
|
||||
auto _foo_struct = _o->foo_struct ? _o->foo_struct.get() : nullptr;
|
||||
return NamespaceA::CreateTableInFirstNS(
|
||||
_fbb,
|
||||
_foo_table,
|
||||
_foo_enum,
|
||||
_foo_union_type,
|
||||
_foo_union,
|
||||
_foo_struct);
|
||||
}
|
||||
|
||||
} // namespace NamespaceA
|
||||
|
||||
namespace NamespaceC {
|
||||
|
||||
|
||||
inline bool operator==(const TableInCT &lhs, const TableInCT &rhs) {
|
||||
return
|
||||
((lhs.refer_to_a1 == rhs.refer_to_a1) || (lhs.refer_to_a1 && rhs.refer_to_a1 && *lhs.refer_to_a1 == *rhs.refer_to_a1)) &&
|
||||
((lhs.refer_to_a2 == rhs.refer_to_a2) || (lhs.refer_to_a2 && rhs.refer_to_a2 && *lhs.refer_to_a2 == *rhs.refer_to_a2));
|
||||
}
|
||||
|
||||
inline bool operator!=(const TableInCT &lhs, const TableInCT &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
|
||||
inline TableInCT::TableInCT(const TableInCT &o)
|
||||
: refer_to_a1((o.refer_to_a1) ? new NamespaceA::TableInFirstNST(*o.refer_to_a1) : nullptr),
|
||||
refer_to_a2((o.refer_to_a2) ? new NamespaceA::SecondTableInAT(*o.refer_to_a2) : nullptr) {
|
||||
}
|
||||
|
||||
inline TableInCT &TableInCT::operator=(TableInCT o) FLATBUFFERS_NOEXCEPT {
|
||||
std::swap(refer_to_a1, o.refer_to_a1);
|
||||
std::swap(refer_to_a2, o.refer_to_a2);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline TableInCT *TableInC::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
auto _o = std::unique_ptr<TableInCT>(new TableInCT());
|
||||
UnPackTo(_o.get(), _resolver);
|
||||
return _o.release();
|
||||
}
|
||||
|
||||
inline void TableInC::UnPackTo(TableInCT *_o, const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
(void)_o;
|
||||
(void)_resolver;
|
||||
{ auto _e = refer_to_a1(); if (_e) { if(_o->refer_to_a1) { _e->UnPackTo(_o->refer_to_a1.get(), _resolver); } else { _o->refer_to_a1 = std::unique_ptr<NamespaceA::TableInFirstNST>(_e->UnPack(_resolver)); } } else if (_o->refer_to_a1) { _o->refer_to_a1.reset(); } }
|
||||
{ auto _e = refer_to_a2(); if (_e) { if(_o->refer_to_a2) { _e->UnPackTo(_o->refer_to_a2.get(), _resolver); } else { _o->refer_to_a2 = std::unique_ptr<NamespaceA::SecondTableInAT>(_e->UnPack(_resolver)); } } else if (_o->refer_to_a2) { _o->refer_to_a2.reset(); } }
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<TableInC> CreateTableInC(::flatbuffers::FlatBufferBuilder &_fbb, const TableInCT *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
return TableInC::Pack(_fbb, _o, _rehasher);
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<TableInC> TableInC::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const TableInCT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
(void)_rehasher;
|
||||
(void)_o;
|
||||
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const TableInCT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||
auto _refer_to_a1 = _o->refer_to_a1 ? CreateTableInFirstNS(_fbb, _o->refer_to_a1.get(), _rehasher) : 0;
|
||||
auto _refer_to_a2 = _o->refer_to_a2 ? CreateSecondTableInA(_fbb, _o->refer_to_a2.get(), _rehasher) : 0;
|
||||
return NamespaceC::CreateTableInC(
|
||||
_fbb,
|
||||
_refer_to_a1,
|
||||
_refer_to_a2);
|
||||
}
|
||||
|
||||
} // namespace NamespaceC
|
||||
|
||||
namespace NamespaceA {
|
||||
|
||||
|
||||
inline bool operator==(const SecondTableInAT &lhs, const SecondTableInAT &rhs) {
|
||||
return
|
||||
((lhs.refer_to_c == rhs.refer_to_c) || (lhs.refer_to_c && rhs.refer_to_c && *lhs.refer_to_c == *rhs.refer_to_c));
|
||||
}
|
||||
|
||||
inline bool operator!=(const SecondTableInAT &lhs, const SecondTableInAT &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
|
||||
inline SecondTableInAT::SecondTableInAT(const SecondTableInAT &o)
|
||||
: refer_to_c((o.refer_to_c) ? new NamespaceC::TableInCT(*o.refer_to_c) : nullptr) {
|
||||
}
|
||||
|
||||
inline SecondTableInAT &SecondTableInAT::operator=(SecondTableInAT o) FLATBUFFERS_NOEXCEPT {
|
||||
std::swap(refer_to_c, o.refer_to_c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline SecondTableInAT *SecondTableInA::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
auto _o = std::unique_ptr<SecondTableInAT>(new SecondTableInAT());
|
||||
UnPackTo(_o.get(), _resolver);
|
||||
return _o.release();
|
||||
}
|
||||
|
||||
inline void SecondTableInA::UnPackTo(SecondTableInAT *_o, const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
(void)_o;
|
||||
(void)_resolver;
|
||||
{ auto _e = refer_to_c(); if (_e) { if(_o->refer_to_c) { _e->UnPackTo(_o->refer_to_c.get(), _resolver); } else { _o->refer_to_c = std::unique_ptr<NamespaceC::TableInCT>(_e->UnPack(_resolver)); } } else if (_o->refer_to_c) { _o->refer_to_c.reset(); } }
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<SecondTableInA> CreateSecondTableInA(::flatbuffers::FlatBufferBuilder &_fbb, const SecondTableInAT *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
return SecondTableInA::Pack(_fbb, _o, _rehasher);
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<SecondTableInA> SecondTableInA::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const SecondTableInAT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
(void)_rehasher;
|
||||
(void)_o;
|
||||
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const SecondTableInAT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||
auto _refer_to_c = _o->refer_to_c ? CreateTableInC(_fbb, _o->refer_to_c.get(), _rehasher) : 0;
|
||||
return NamespaceA::CreateSecondTableInA(
|
||||
_fbb,
|
||||
_refer_to_c);
|
||||
}
|
||||
|
||||
inline const ::flatbuffers::TypeTable *TableInFirstNSTypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_SEQUENCE, 0, 0 },
|
||||
{ ::flatbuffers::ET_CHAR, 0, 1 },
|
||||
{ ::flatbuffers::ET_UTYPE, 0, 2 },
|
||||
{ ::flatbuffers::ET_SEQUENCE, 0, 2 },
|
||||
{ ::flatbuffers::ET_SEQUENCE, 0, 3 }
|
||||
};
|
||||
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||
NamespaceA::NamespaceB::TableInNestedNSTypeTable,
|
||||
NamespaceA::NamespaceB::EnumInNestedNSTypeTable,
|
||||
NamespaceA::NamespaceB::UnionInNestedNSTypeTable,
|
||||
NamespaceA::NamespaceB::StructInNestedNSTypeTable
|
||||
};
|
||||
static const char * const names[] = {
|
||||
"foo_table",
|
||||
"foo_enum",
|
||||
"foo_union_type",
|
||||
"foo_union",
|
||||
"foo_struct"
|
||||
};
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_TABLE, 5, type_codes, type_refs, nullptr, nullptr, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
} // namespace NamespaceA
|
||||
|
||||
namespace NamespaceC {
|
||||
|
||||
inline const ::flatbuffers::TypeTable *TableInCTypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_SEQUENCE, 0, 0 },
|
||||
{ ::flatbuffers::ET_SEQUENCE, 0, 1 }
|
||||
};
|
||||
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||
NamespaceA::TableInFirstNSTypeTable,
|
||||
NamespaceA::SecondTableInATypeTable
|
||||
};
|
||||
static const char * const names[] = {
|
||||
"refer_to_a1",
|
||||
"refer_to_a2"
|
||||
};
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_TABLE, 2, type_codes, type_refs, nullptr, nullptr, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
} // namespace NamespaceC
|
||||
|
||||
namespace NamespaceA {
|
||||
|
||||
inline const ::flatbuffers::TypeTable *SecondTableInATypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_SEQUENCE, 0, 0 }
|
||||
};
|
||||
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||
NamespaceC::TableInCTypeTable
|
||||
};
|
||||
static const char * const names[] = {
|
||||
"refer_to_c"
|
||||
};
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_TABLE, 1, type_codes, type_refs, nullptr, nullptr, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
} // namespace NamespaceA
|
||||
|
||||
#endif // FLATBUFFERS_GENERATED_NAMESPACETEST2_NAMESPACEA_H_
|
||||
265
tests/native_inline_table_test_generated.h
Normal file
265
tests/native_inline_table_test_generated.h
Normal file
@@ -0,0 +1,265 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
|
||||
#ifndef FLATBUFFERS_GENERATED_NATIVEINLINETABLETEST_H_
|
||||
#define FLATBUFFERS_GENERATED_NATIVEINLINETABLETEST_H_
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||
// generated, otherwise it may not be compatible.
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 19,
|
||||
"Non-compatible flatbuffers version included");
|
||||
|
||||
struct NativeInlineTable;
|
||||
struct NativeInlineTableBuilder;
|
||||
struct NativeInlineTableT;
|
||||
|
||||
struct TestNativeInlineTable;
|
||||
struct TestNativeInlineTableBuilder;
|
||||
struct TestNativeInlineTableT;
|
||||
|
||||
bool operator==(const NativeInlineTableT &lhs, const NativeInlineTableT &rhs);
|
||||
bool operator!=(const NativeInlineTableT &lhs, const NativeInlineTableT &rhs);
|
||||
bool operator==(const TestNativeInlineTableT &lhs, const TestNativeInlineTableT &rhs);
|
||||
bool operator!=(const TestNativeInlineTableT &lhs, const TestNativeInlineTableT &rhs);
|
||||
|
||||
inline const ::flatbuffers::TypeTable *NativeInlineTableTypeTable();
|
||||
|
||||
inline const ::flatbuffers::TypeTable *TestNativeInlineTableTypeTable();
|
||||
|
||||
struct NativeInlineTableT : public ::flatbuffers::NativeTable {
|
||||
typedef NativeInlineTable TableType;
|
||||
int32_t a = 0;
|
||||
};
|
||||
|
||||
struct NativeInlineTable FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef NativeInlineTableT NativeTableType;
|
||||
typedef NativeInlineTableBuilder Builder;
|
||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return NativeInlineTableTypeTable();
|
||||
}
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_A = 4
|
||||
};
|
||||
int32_t a() const {
|
||||
return GetField<int32_t>(VT_A, 0);
|
||||
}
|
||||
bool mutate_a(int32_t _a = 0) {
|
||||
return SetField<int32_t>(VT_A, _a, 0);
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int32_t>(verifier, VT_A, 4) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
NativeInlineTableT *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
void UnPackTo(NativeInlineTableT *_o, const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
static ::flatbuffers::Offset<NativeInlineTable> Pack(::flatbuffers::FlatBufferBuilder &_fbb, const NativeInlineTableT* _o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
};
|
||||
|
||||
struct NativeInlineTableBuilder {
|
||||
typedef NativeInlineTable Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_a(int32_t a) {
|
||||
fbb_.AddElement<int32_t>(NativeInlineTable::VT_A, a, 0);
|
||||
}
|
||||
explicit NativeInlineTableBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<NativeInlineTable> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<NativeInlineTable>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<NativeInlineTable> CreateNativeInlineTable(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t a = 0) {
|
||||
NativeInlineTableBuilder builder_(_fbb);
|
||||
builder_.add_a(a);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
::flatbuffers::Offset<NativeInlineTable> CreateNativeInlineTable(::flatbuffers::FlatBufferBuilder &_fbb, const NativeInlineTableT *_o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
|
||||
struct TestNativeInlineTableT : public ::flatbuffers::NativeTable {
|
||||
typedef TestNativeInlineTable TableType;
|
||||
std::vector<NativeInlineTableT> t{};
|
||||
};
|
||||
|
||||
struct TestNativeInlineTable FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef TestNativeInlineTableT NativeTableType;
|
||||
typedef TestNativeInlineTableBuilder Builder;
|
||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return TestNativeInlineTableTypeTable();
|
||||
}
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_T = 4
|
||||
};
|
||||
const ::flatbuffers::Vector<::flatbuffers::Offset<NativeInlineTable>> *t() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<NativeInlineTable>> *>(VT_T);
|
||||
}
|
||||
::flatbuffers::Vector<::flatbuffers::Offset<NativeInlineTable>> *mutable_t() {
|
||||
return GetPointer<::flatbuffers::Vector<::flatbuffers::Offset<NativeInlineTable>> *>(VT_T);
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyOffset(verifier, VT_T) &&
|
||||
verifier.VerifyVector(t()) &&
|
||||
verifier.VerifyVectorOfTables(t()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
TestNativeInlineTableT *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
void UnPackTo(TestNativeInlineTableT *_o, const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
static ::flatbuffers::Offset<TestNativeInlineTable> Pack(::flatbuffers::FlatBufferBuilder &_fbb, const TestNativeInlineTableT* _o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
};
|
||||
|
||||
struct TestNativeInlineTableBuilder {
|
||||
typedef TestNativeInlineTable Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_t(::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<NativeInlineTable>>> t) {
|
||||
fbb_.AddOffset(TestNativeInlineTable::VT_T, t);
|
||||
}
|
||||
explicit TestNativeInlineTableBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<TestNativeInlineTable> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<TestNativeInlineTable>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<TestNativeInlineTable> CreateTestNativeInlineTable(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<NativeInlineTable>>> t = 0) {
|
||||
TestNativeInlineTableBuilder builder_(_fbb);
|
||||
builder_.add_t(t);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<TestNativeInlineTable> CreateTestNativeInlineTableDirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
const std::vector<::flatbuffers::Offset<NativeInlineTable>> *t = nullptr) {
|
||||
auto t__ = t ? _fbb.CreateVector<::flatbuffers::Offset<NativeInlineTable>>(*t) : 0;
|
||||
return CreateTestNativeInlineTable(
|
||||
_fbb,
|
||||
t__);
|
||||
}
|
||||
|
||||
::flatbuffers::Offset<TestNativeInlineTable> CreateTestNativeInlineTable(::flatbuffers::FlatBufferBuilder &_fbb, const TestNativeInlineTableT *_o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
|
||||
|
||||
inline bool operator==(const NativeInlineTableT &lhs, const NativeInlineTableT &rhs) {
|
||||
return
|
||||
(lhs.a == rhs.a);
|
||||
}
|
||||
|
||||
inline bool operator!=(const NativeInlineTableT &lhs, const NativeInlineTableT &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
|
||||
inline NativeInlineTableT *NativeInlineTable::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
auto _o = std::unique_ptr<NativeInlineTableT>(new NativeInlineTableT());
|
||||
UnPackTo(_o.get(), _resolver);
|
||||
return _o.release();
|
||||
}
|
||||
|
||||
inline void NativeInlineTable::UnPackTo(NativeInlineTableT *_o, const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
(void)_o;
|
||||
(void)_resolver;
|
||||
{ auto _e = a(); _o->a = _e; }
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<NativeInlineTable> CreateNativeInlineTable(::flatbuffers::FlatBufferBuilder &_fbb, const NativeInlineTableT *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
return NativeInlineTable::Pack(_fbb, _o, _rehasher);
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<NativeInlineTable> NativeInlineTable::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const NativeInlineTableT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
(void)_rehasher;
|
||||
(void)_o;
|
||||
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const NativeInlineTableT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||
auto _a = _o->a;
|
||||
return CreateNativeInlineTable(
|
||||
_fbb,
|
||||
_a);
|
||||
}
|
||||
|
||||
|
||||
inline bool operator==(const TestNativeInlineTableT &lhs, const TestNativeInlineTableT &rhs) {
|
||||
return
|
||||
(lhs.t == rhs.t);
|
||||
}
|
||||
|
||||
inline bool operator!=(const TestNativeInlineTableT &lhs, const TestNativeInlineTableT &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
|
||||
inline TestNativeInlineTableT *TestNativeInlineTable::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
auto _o = std::unique_ptr<TestNativeInlineTableT>(new TestNativeInlineTableT());
|
||||
UnPackTo(_o.get(), _resolver);
|
||||
return _o.release();
|
||||
}
|
||||
|
||||
inline void TestNativeInlineTable::UnPackTo(TestNativeInlineTableT *_o, const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
(void)_o;
|
||||
(void)_resolver;
|
||||
{ auto _e = t(); if (_e) { _o->t.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->t[_i] = *std::unique_ptr<NativeInlineTableT>(_e->Get(_i)->UnPack(_resolver)); } } else { _o->t.resize(0); } }
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<TestNativeInlineTable> CreateTestNativeInlineTable(::flatbuffers::FlatBufferBuilder &_fbb, const TestNativeInlineTableT *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
return TestNativeInlineTable::Pack(_fbb, _o, _rehasher);
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<TestNativeInlineTable> TestNativeInlineTable::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const TestNativeInlineTableT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
(void)_rehasher;
|
||||
(void)_o;
|
||||
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const TestNativeInlineTableT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||
auto _t = _o->t.size() ? _fbb.CreateVector<::flatbuffers::Offset<NativeInlineTable>> (_o->t.size(), [](size_t i, _VectorArgs *__va) { return CreateNativeInlineTable(*__va->__fbb, &(__va->__o->t[i]), __va->__rehasher); }, &_va ) : 0;
|
||||
return CreateTestNativeInlineTable(
|
||||
_fbb,
|
||||
_t);
|
||||
}
|
||||
|
||||
inline const ::flatbuffers::TypeTable *NativeInlineTableTypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_INT, 0, -1 }
|
||||
};
|
||||
static const char * const names[] = {
|
||||
"a"
|
||||
};
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_TABLE, 1, type_codes, nullptr, nullptr, nullptr, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
inline const ::flatbuffers::TypeTable *TestNativeInlineTableTypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_SEQUENCE, 1, 0 }
|
||||
};
|
||||
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||
NativeInlineTableTypeTable
|
||||
};
|
||||
static const char * const names[] = {
|
||||
"t"
|
||||
};
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_TABLE, 1, type_codes, type_refs, nullptr, nullptr, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
#endif // FLATBUFFERS_GENERATED_NATIVEINLINETABLETEST_H_
|
||||
@@ -14,6 +14,12 @@ struct Vector3DAlt (native_type:"Native::Vector3D", native_type_pack_name:"Vecto
|
||||
c:float;
|
||||
}
|
||||
|
||||
struct Vector3DSimple {
|
||||
x:float;
|
||||
y:float;
|
||||
z:float;
|
||||
}
|
||||
|
||||
table Matrix (native_type:"Native::Matrix") {
|
||||
rows:int32;
|
||||
columns:int32;
|
||||
@@ -27,6 +33,8 @@ table ApplicationData {
|
||||
position_inline:Vector3D (native_inline);
|
||||
matrix:Matrix;
|
||||
matrices:[Matrix];
|
||||
simple_position:Vector3DSimple (native_type: "Native::Vector3D", native_inline, native_type_pack_name: "Vector3DSimple");
|
||||
simple_vectors:[Vector3DSimple] (native_type: "Native::Vector3D", native_type_pack_name: "Vector3DSimple");
|
||||
}
|
||||
|
||||
root_type ApplicationData;
|
||||
|
||||
727
tests/native_type_test_generated.h
Normal file
727
tests/native_type_test_generated.h
Normal file
@@ -0,0 +1,727 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
|
||||
#ifndef FLATBUFFERS_GENERATED_NATIVETYPETEST_GEOMETRY_H_
|
||||
#define FLATBUFFERS_GENERATED_NATIVETYPETEST_GEOMETRY_H_
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||
// generated, otherwise it may not be compatible.
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 19,
|
||||
"Non-compatible flatbuffers version included");
|
||||
|
||||
#include "native_type_test_impl.h"
|
||||
|
||||
namespace Geometry {
|
||||
|
||||
struct Vector3D;
|
||||
|
||||
struct Vector3DAlt;
|
||||
|
||||
struct Vector3DSimple;
|
||||
|
||||
struct Matrix;
|
||||
struct MatrixBuilder;
|
||||
|
||||
struct ApplicationData;
|
||||
struct ApplicationDataBuilder;
|
||||
struct ApplicationDataT;
|
||||
|
||||
bool operator==(const Vector3DSimple &lhs, const Vector3DSimple &rhs);
|
||||
bool operator!=(const Vector3DSimple &lhs, const Vector3DSimple &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 *Vector3DSimpleTypeTable();
|
||||
|
||||
inline const ::flatbuffers::TypeTable *MatrixTypeTable();
|
||||
|
||||
inline const ::flatbuffers::TypeTable *ApplicationDataTypeTable();
|
||||
|
||||
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Vector3D FLATBUFFERS_FINAL_CLASS {
|
||||
private:
|
||||
float x_;
|
||||
float y_;
|
||||
float z_;
|
||||
|
||||
public:
|
||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return Vector3DTypeTable();
|
||||
}
|
||||
Vector3D()
|
||||
: x_(0),
|
||||
y_(0),
|
||||
z_(0) {
|
||||
}
|
||||
Vector3D(float _x, float _y, float _z)
|
||||
: x_(::flatbuffers::EndianScalar(_x)),
|
||||
y_(::flatbuffers::EndianScalar(_y)),
|
||||
z_(::flatbuffers::EndianScalar(_z)) {
|
||||
}
|
||||
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);
|
||||
|
||||
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Vector3DAlt FLATBUFFERS_FINAL_CLASS {
|
||||
private:
|
||||
float a_;
|
||||
float b_;
|
||||
float c_;
|
||||
|
||||
public:
|
||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return Vector3DAltTypeTable();
|
||||
}
|
||||
Vector3DAlt()
|
||||
: a_(0),
|
||||
b_(0),
|
||||
c_(0) {
|
||||
}
|
||||
Vector3DAlt(float _a, float _b, float _c)
|
||||
: a_(::flatbuffers::EndianScalar(_a)),
|
||||
b_(::flatbuffers::EndianScalar(_b)),
|
||||
c_(::flatbuffers::EndianScalar(_c)) {
|
||||
}
|
||||
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) Vector3DSimple FLATBUFFERS_FINAL_CLASS {
|
||||
private:
|
||||
float x_;
|
||||
float y_;
|
||||
float z_;
|
||||
|
||||
public:
|
||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return Vector3DSimpleTypeTable();
|
||||
}
|
||||
Vector3DSimple()
|
||||
: x_(0),
|
||||
y_(0),
|
||||
z_(0) {
|
||||
}
|
||||
Vector3DSimple(float _x, float _y, float _z)
|
||||
: x_(::flatbuffers::EndianScalar(_x)),
|
||||
y_(::flatbuffers::EndianScalar(_y)),
|
||||
z_(::flatbuffers::EndianScalar(_z)) {
|
||||
}
|
||||
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(Vector3DSimple, 12);
|
||||
|
||||
inline bool operator==(const Vector3DSimple &lhs, const Vector3DSimple &rhs) {
|
||||
return
|
||||
(lhs.x() == rhs.x()) &&
|
||||
(lhs.y() == rhs.y()) &&
|
||||
(lhs.z() == rhs.z());
|
||||
}
|
||||
|
||||
inline bool operator!=(const Vector3DSimple &lhs, const Vector3DSimple &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();
|
||||
}
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_ROWS = 4,
|
||||
VT_COLUMNS = 6,
|
||||
VT_VALUES = 8
|
||||
};
|
||||
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) &&
|
||||
VerifyField<int32_t>(verifier, VT_ROWS, 4) &&
|
||||
VerifyField<int32_t>(verifier, VT_COLUMNS, 4) &&
|
||||
VerifyOffset(verifier, VT_VALUES) &&
|
||||
verifier.VerifyVector(values()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
Native::Matrix *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
void UnPackTo(Native::Matrix *_o, const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
static ::flatbuffers::Offset<Matrix> Pack(::flatbuffers::FlatBufferBuilder &_fbb, const Native::Matrix* _o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
};
|
||||
|
||||
struct MatrixBuilder {
|
||||
typedef Matrix Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_rows(int32_t rows) {
|
||||
fbb_.AddElement<int32_t>(Matrix::VT_ROWS, rows, 0);
|
||||
}
|
||||
void add_columns(int32_t columns) {
|
||||
fbb_.AddElement<int32_t>(Matrix::VT_COLUMNS, columns, 0);
|
||||
}
|
||||
void add_values(::flatbuffers::Offset<::flatbuffers::Vector<float>> values) {
|
||||
fbb_.AddOffset(Matrix::VT_VALUES, values);
|
||||
}
|
||||
explicit MatrixBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<Matrix> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<Matrix>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<Matrix> CreateMatrix(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t rows = 0,
|
||||
int32_t columns = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<float>> values = 0) {
|
||||
MatrixBuilder builder_(_fbb);
|
||||
builder_.add_values(values);
|
||||
builder_.add_columns(columns);
|
||||
builder_.add_rows(rows);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<Matrix> CreateMatrixDirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t rows = 0,
|
||||
int32_t columns = 0,
|
||||
const std::vector<float> *values = nullptr) {
|
||||
auto values__ = values ? _fbb.CreateVector<float>(*values) : 0;
|
||||
return Geometry::CreateMatrix(
|
||||
_fbb,
|
||||
rows,
|
||||
columns,
|
||||
values__);
|
||||
}
|
||||
|
||||
::flatbuffers::Offset<Matrix> CreateMatrix(::flatbuffers::FlatBufferBuilder &_fbb, const Native::Matrix *_o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
|
||||
struct ApplicationDataT : public ::flatbuffers::NativeTable {
|
||||
typedef ApplicationData TableType;
|
||||
std::vector<Native::Vector3D> vectors{};
|
||||
std::vector<Native::Vector3D> vectors_alt{};
|
||||
std::unique_ptr<Native::Vector3D> position{};
|
||||
Native::Vector3D position_inline{};
|
||||
std::unique_ptr<Native::Matrix> matrix{};
|
||||
std::vector<std::unique_ptr<Native::Matrix>> matrices{};
|
||||
Native::Vector3D simple_position{};
|
||||
std::vector<Native::Vector3D> simple_vectors{};
|
||||
ApplicationDataT() = default;
|
||||
ApplicationDataT(const ApplicationDataT &o);
|
||||
ApplicationDataT(ApplicationDataT&&) FLATBUFFERS_NOEXCEPT = default;
|
||||
ApplicationDataT &operator=(ApplicationDataT o) FLATBUFFERS_NOEXCEPT;
|
||||
};
|
||||
|
||||
struct ApplicationData FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef ApplicationDataT NativeTableType;
|
||||
typedef ApplicationDataBuilder Builder;
|
||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return ApplicationDataTypeTable();
|
||||
}
|
||||
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_SIMPLE_POSITION = 16,
|
||||
VT_SIMPLE_VECTORS = 18
|
||||
};
|
||||
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::Vector3DSimple *simple_position() const {
|
||||
return GetStruct<const Geometry::Vector3DSimple *>(VT_SIMPLE_POSITION);
|
||||
}
|
||||
Geometry::Vector3DSimple *mutable_simple_position() {
|
||||
return GetStruct<Geometry::Vector3DSimple *>(VT_SIMPLE_POSITION);
|
||||
}
|
||||
const ::flatbuffers::Vector<const Geometry::Vector3DSimple *> *simple_vectors() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<const Geometry::Vector3DSimple *> *>(VT_SIMPLE_VECTORS);
|
||||
}
|
||||
::flatbuffers::Vector<const Geometry::Vector3DSimple *> *mutable_simple_vectors() {
|
||||
return GetPointer<::flatbuffers::Vector<const Geometry::Vector3DSimple *> *>(VT_SIMPLE_VECTORS);
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyOffset(verifier, VT_VECTORS) &&
|
||||
verifier.VerifyVector(vectors()) &&
|
||||
VerifyOffset(verifier, VT_VECTORS_ALT) &&
|
||||
verifier.VerifyVector(vectors_alt()) &&
|
||||
VerifyField<Geometry::Vector3D>(verifier, VT_POSITION, 4) &&
|
||||
VerifyField<Geometry::Vector3D>(verifier, VT_POSITION_INLINE, 4) &&
|
||||
VerifyOffset(verifier, VT_MATRIX) &&
|
||||
verifier.VerifyTable(matrix()) &&
|
||||
VerifyOffset(verifier, VT_MATRICES) &&
|
||||
verifier.VerifyVector(matrices()) &&
|
||||
verifier.VerifyVectorOfTables(matrices()) &&
|
||||
VerifyField<Geometry::Vector3DSimple>(verifier, VT_SIMPLE_POSITION, 4) &&
|
||||
VerifyOffset(verifier, VT_SIMPLE_VECTORS) &&
|
||||
verifier.VerifyVector(simple_vectors()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
ApplicationDataT *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
void UnPackTo(ApplicationDataT *_o, const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
static ::flatbuffers::Offset<ApplicationData> Pack(::flatbuffers::FlatBufferBuilder &_fbb, const ApplicationDataT* _o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
};
|
||||
|
||||
struct ApplicationDataBuilder {
|
||||
typedef ApplicationData Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_vectors(::flatbuffers::Offset<::flatbuffers::Vector<const Geometry::Vector3D *>> vectors) {
|
||||
fbb_.AddOffset(ApplicationData::VT_VECTORS, vectors);
|
||||
}
|
||||
void add_vectors_alt(::flatbuffers::Offset<::flatbuffers::Vector<const Geometry::Vector3DAlt *>> vectors_alt) {
|
||||
fbb_.AddOffset(ApplicationData::VT_VECTORS_ALT, vectors_alt);
|
||||
}
|
||||
void add_position(const Geometry::Vector3D *position) {
|
||||
fbb_.AddStruct(ApplicationData::VT_POSITION, position);
|
||||
}
|
||||
void add_position_inline(const Geometry::Vector3D *position_inline) {
|
||||
fbb_.AddStruct(ApplicationData::VT_POSITION_INLINE, position_inline);
|
||||
}
|
||||
void add_matrix(::flatbuffers::Offset<Geometry::Matrix> matrix) {
|
||||
fbb_.AddOffset(ApplicationData::VT_MATRIX, matrix);
|
||||
}
|
||||
void add_matrices(::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<Geometry::Matrix>>> matrices) {
|
||||
fbb_.AddOffset(ApplicationData::VT_MATRICES, matrices);
|
||||
}
|
||||
void add_simple_position(const Geometry::Vector3DSimple *simple_position) {
|
||||
fbb_.AddStruct(ApplicationData::VT_SIMPLE_POSITION, simple_position);
|
||||
}
|
||||
void add_simple_vectors(::flatbuffers::Offset<::flatbuffers::Vector<const Geometry::Vector3DSimple *>> simple_vectors) {
|
||||
fbb_.AddOffset(ApplicationData::VT_SIMPLE_VECTORS, simple_vectors);
|
||||
}
|
||||
explicit ApplicationDataBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<ApplicationData> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<ApplicationData>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<ApplicationData> CreateApplicationData(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<const Geometry::Vector3D *>> vectors = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<const Geometry::Vector3DAlt *>> vectors_alt = 0,
|
||||
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::Vector3DSimple *simple_position = nullptr,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<const Geometry::Vector3DSimple *>> simple_vectors = 0) {
|
||||
ApplicationDataBuilder builder_(_fbb);
|
||||
builder_.add_simple_vectors(simple_vectors);
|
||||
builder_.add_simple_position(simple_position);
|
||||
builder_.add_matrices(matrices);
|
||||
builder_.add_matrix(matrix);
|
||||
builder_.add_position_inline(position_inline);
|
||||
builder_.add_position(position);
|
||||
builder_.add_vectors_alt(vectors_alt);
|
||||
builder_.add_vectors(vectors);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<ApplicationData> CreateApplicationDataDirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
const std::vector<Geometry::Vector3D> *vectors = nullptr,
|
||||
const std::vector<Geometry::Vector3DAlt> *vectors_alt = nullptr,
|
||||
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::Vector3DSimple *simple_position = nullptr,
|
||||
const std::vector<Geometry::Vector3DSimple> *simple_vectors = 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;
|
||||
auto simple_vectors__ = simple_vectors ? _fbb.CreateVectorOfStructs<Geometry::Vector3DSimple>(*simple_vectors) : 0;
|
||||
return Geometry::CreateApplicationData(
|
||||
_fbb,
|
||||
vectors__,
|
||||
vectors_alt__,
|
||||
position,
|
||||
position_inline,
|
||||
matrix,
|
||||
matrices__,
|
||||
simple_position,
|
||||
simple_vectors__);
|
||||
}
|
||||
|
||||
::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());
|
||||
UnPackTo(_o.get(), _resolver);
|
||||
return _o.release();
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<Matrix> CreateMatrix(::flatbuffers::FlatBufferBuilder &_fbb, const Native::Matrix *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
return Matrix::Pack(_fbb, _o, _rehasher);
|
||||
}
|
||||
|
||||
|
||||
inline bool operator==(const ApplicationDataT &lhs, const ApplicationDataT &rhs) {
|
||||
return
|
||||
(lhs.vectors == rhs.vectors) &&
|
||||
(lhs.vectors_alt == rhs.vectors_alt) &&
|
||||
((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.simple_position == rhs.simple_position) &&
|
||||
(lhs.simple_vectors == rhs.simple_vectors);
|
||||
}
|
||||
|
||||
inline bool operator!=(const ApplicationDataT &lhs, const ApplicationDataT &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
|
||||
inline ApplicationDataT::ApplicationDataT(const ApplicationDataT &o)
|
||||
: vectors(o.vectors),
|
||||
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),
|
||||
simple_position(o.simple_position),
|
||||
simple_vectors(o.simple_vectors) {
|
||||
matrices.reserve(o.matrices.size());
|
||||
for (const auto &matrices_ : o.matrices) { matrices.emplace_back((matrices_) ? new Native::Matrix(*matrices_) : nullptr); }
|
||||
}
|
||||
|
||||
inline ApplicationDataT &ApplicationDataT::operator=(ApplicationDataT o) FLATBUFFERS_NOEXCEPT {
|
||||
std::swap(vectors, o.vectors);
|
||||
std::swap(vectors_alt, o.vectors_alt);
|
||||
std::swap(position, o.position);
|
||||
std::swap(position_inline, o.position_inline);
|
||||
std::swap(matrix, o.matrix);
|
||||
std::swap(matrices, o.matrices);
|
||||
std::swap(simple_position, o.simple_position);
|
||||
std::swap(simple_vectors, o.simple_vectors);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline ApplicationDataT *ApplicationData::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
auto _o = std::unique_ptr<ApplicationDataT>(new ApplicationDataT());
|
||||
UnPackTo(_o.get(), _resolver);
|
||||
return _o.release();
|
||||
}
|
||||
|
||||
inline void ApplicationData::UnPackTo(ApplicationDataT *_o, const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
(void)_o;
|
||||
(void)_resolver;
|
||||
{ auto _e = vectors(); if (_e) { _o->vectors.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vectors[_i] = ::flatbuffers::UnPack(*_e->Get(_i)); } } else { _o->vectors.resize(0); } }
|
||||
{ auto _e = vectors_alt(); if (_e) { _o->vectors_alt.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vectors_alt[_i] = ::flatbuffers::UnPackVector3DAlt(*_e->Get(_i)); } } else { _o->vectors_alt.resize(0); } }
|
||||
{ auto _e = position(); if (_e) _o->position = std::unique_ptr<Native::Vector3D>(new Native::Vector3D(::flatbuffers::UnPack(*_e))); }
|
||||
{ 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 = simple_position(); if (_e) _o->simple_position = ::flatbuffers::UnPackVector3DSimple(*_e); }
|
||||
{ auto _e = simple_vectors(); if (_e) { _o->simple_vectors.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->simple_vectors[_i] = ::flatbuffers::UnPackVector3DSimple(*_e->Get(_i)); } } else { _o->simple_vectors.resize(0); } }
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<ApplicationData> CreateApplicationData(::flatbuffers::FlatBufferBuilder &_fbb, const ApplicationDataT *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
return ApplicationData::Pack(_fbb, _o, _rehasher);
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<ApplicationData> ApplicationData::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const ApplicationDataT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
(void)_rehasher;
|
||||
(void)_o;
|
||||
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const ApplicationDataT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||
auto _vectors = _o->vectors.size() ? _fbb.CreateVectorOfNativeStructs<Geometry::Vector3D, Native::Vector3D>(_o->vectors) : 0;
|
||||
auto _vectors_alt = _o->vectors_alt.size() ? _fbb.CreateVectorOfNativeStructs<Geometry::Vector3DAlt, Native::Vector3D>(_o->vectors_alt, ::flatbuffers::PackVector3DAlt) : 0;
|
||||
auto _position = Geometry::Vector3D{}; if (_o->position) _position = ::flatbuffers::Pack(*_o->position);
|
||||
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 _simple_position = ::flatbuffers::PackVector3DSimple(_o->simple_position);
|
||||
auto _simple_vectors = _o->simple_vectors.size() ? _fbb.CreateVectorOfNativeStructs<Geometry::Vector3DSimple, Native::Vector3D>(_o->simple_vectors, ::flatbuffers::PackVector3DSimple) : 0;
|
||||
return Geometry::CreateApplicationData(
|
||||
_fbb,
|
||||
_vectors,
|
||||
_vectors_alt,
|
||||
_o->position ? &_position : nullptr,
|
||||
&_position_inline,
|
||||
_matrix,
|
||||
_matrices,
|
||||
&_simple_position,
|
||||
_simple_vectors);
|
||||
}
|
||||
|
||||
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 *Vector3DSimpleTypeTable() {
|
||||
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 *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 *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, 1, 3 }
|
||||
};
|
||||
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||
Geometry::Vector3DTypeTable,
|
||||
Geometry::Vector3DAltTypeTable,
|
||||
Geometry::MatrixTypeTable,
|
||||
Geometry::Vector3DSimpleTypeTable
|
||||
};
|
||||
static const char * const names[] = {
|
||||
"vectors",
|
||||
"vectors_alt",
|
||||
"position",
|
||||
"position_inline",
|
||||
"matrix",
|
||||
"matrices",
|
||||
"simple_position",
|
||||
"simple_vectors"
|
||||
};
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_TABLE, 8, type_codes, type_refs, nullptr, nullptr, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
inline const Geometry::ApplicationData *GetApplicationData(const void *buf) {
|
||||
return ::flatbuffers::GetRoot<Geometry::ApplicationData>(buf);
|
||||
}
|
||||
|
||||
inline const Geometry::ApplicationData *GetSizePrefixedApplicationData(const void *buf) {
|
||||
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) {
|
||||
return verifier.template VerifyBuffer<Geometry::ApplicationData>(nullptr);
|
||||
}
|
||||
|
||||
template <bool B = false>
|
||||
inline bool VerifySizePrefixedApplicationDataBuffer(
|
||||
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||
return verifier.template VerifySizePrefixedBuffer<Geometry::ApplicationData>(nullptr);
|
||||
}
|
||||
|
||||
inline void FinishApplicationDataBuffer(
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<Geometry::ApplicationData> root) {
|
||||
fbb.Finish(root);
|
||||
}
|
||||
|
||||
inline void FinishSizePrefixedApplicationDataBuffer(
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<Geometry::ApplicationData> root) {
|
||||
fbb.FinishSizePrefixed(root);
|
||||
}
|
||||
|
||||
inline std::unique_ptr<Geometry::ApplicationDataT> UnPackApplicationData(
|
||||
const void *buf,
|
||||
const ::flatbuffers::resolver_function_t *res = nullptr) {
|
||||
return std::unique_ptr<Geometry::ApplicationDataT>(GetApplicationData(buf)->UnPack(res));
|
||||
}
|
||||
|
||||
inline std::unique_ptr<Geometry::ApplicationDataT> UnPackSizePrefixedApplicationData(
|
||||
const void *buf,
|
||||
const ::flatbuffers::resolver_function_t *res = nullptr) {
|
||||
return std::unique_ptr<Geometry::ApplicationDataT>(GetSizePrefixedApplicationData(buf)->UnPack(res));
|
||||
}
|
||||
|
||||
} // namespace Geometry
|
||||
|
||||
#endif // FLATBUFFERS_GENERATED_NATIVETYPETEST_GEOMETRY_H_
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "native_type_test_impl.h"
|
||||
|
||||
#include "native_type_test.fbs.h"
|
||||
#include "native_type_test_generated.h"
|
||||
|
||||
namespace flatbuffers {
|
||||
Geometry::Vector3D Pack(const Native::Vector3D& obj) {
|
||||
@@ -18,6 +18,15 @@ 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::Vector3DSimple PackVector3DSimple(const Native::Vector3D& obj) {
|
||||
return Geometry::Vector3DSimple(obj.x, obj.y, obj.z);
|
||||
}
|
||||
|
||||
const Native::Vector3D UnPackVector3DSimple(
|
||||
const Geometry::Vector3DSimple& obj) {
|
||||
return Native::Vector3D(obj.x(), obj.y(), obj.z());
|
||||
}
|
||||
} // namespace flatbuffers
|
||||
|
||||
namespace Geometry {
|
||||
|
||||
@@ -48,6 +48,7 @@ struct Matrix {
|
||||
namespace Geometry {
|
||||
struct Vector3D;
|
||||
struct Vector3DAlt;
|
||||
struct Vector3DSimple;
|
||||
} // namespace Geometry
|
||||
|
||||
namespace flatbuffers {
|
||||
@@ -55,6 +56,8 @@ 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::Vector3DSimple PackVector3DSimple(const Native::Vector3D& obj);
|
||||
const Native::Vector3D UnPackVector3DSimple(const Geometry::Vector3DSimple& obj);
|
||||
} // namespace flatbuffers
|
||||
|
||||
#endif // VECTOR3D_PACK_H
|
||||
|
||||
964
tests/optional_scalars_generated.h
Normal file
964
tests/optional_scalars_generated.h
Normal file
@@ -0,0 +1,964 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
|
||||
#ifndef FLATBUFFERS_GENERATED_OPTIONALSCALARS_OPTIONAL_SCALARS_H_
|
||||
#define FLATBUFFERS_GENERATED_OPTIONALSCALARS_OPTIONAL_SCALARS_H_
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||
// generated, otherwise it may not be compatible.
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 19,
|
||||
"Non-compatible flatbuffers version included");
|
||||
|
||||
namespace optional_scalars {
|
||||
|
||||
struct ScalarStuff;
|
||||
struct ScalarStuffBuilder;
|
||||
struct ScalarStuffT;
|
||||
|
||||
bool operator==(const ScalarStuffT &lhs, const ScalarStuffT &rhs);
|
||||
bool operator!=(const ScalarStuffT &lhs, const ScalarStuffT &rhs);
|
||||
|
||||
inline const ::flatbuffers::TypeTable *ScalarStuffTypeTable();
|
||||
|
||||
enum OptionalByte : int8_t {
|
||||
OptionalByte_None = 0,
|
||||
OptionalByte_One = 1,
|
||||
OptionalByte_Two = 2,
|
||||
OptionalByte_MIN = OptionalByte_None,
|
||||
OptionalByte_MAX = OptionalByte_Two
|
||||
};
|
||||
|
||||
inline const OptionalByte (&EnumValuesOptionalByte())[3] {
|
||||
static const OptionalByte values[] = {
|
||||
OptionalByte_None,
|
||||
OptionalByte_One,
|
||||
OptionalByte_Two
|
||||
};
|
||||
return values;
|
||||
}
|
||||
|
||||
inline const char * const *EnumNamesOptionalByte() {
|
||||
static const char * const names[4] = {
|
||||
"None",
|
||||
"One",
|
||||
"Two",
|
||||
nullptr
|
||||
};
|
||||
return names;
|
||||
}
|
||||
|
||||
inline const char *EnumNameOptionalByte(OptionalByte e) {
|
||||
if (::flatbuffers::IsOutRange(e, OptionalByte_None, OptionalByte_Two)) return "";
|
||||
const size_t index = static_cast<size_t>(e);
|
||||
return EnumNamesOptionalByte()[index];
|
||||
}
|
||||
|
||||
struct ScalarStuffT : public ::flatbuffers::NativeTable {
|
||||
typedef ScalarStuff TableType;
|
||||
int8_t just_i8 = 0;
|
||||
::flatbuffers::Optional<int8_t> maybe_i8 = ::flatbuffers::nullopt;
|
||||
int8_t default_i8 = 42;
|
||||
uint8_t just_u8 = 0;
|
||||
::flatbuffers::Optional<uint8_t> maybe_u8 = ::flatbuffers::nullopt;
|
||||
uint8_t default_u8 = 42;
|
||||
int16_t just_i16 = 0;
|
||||
::flatbuffers::Optional<int16_t> maybe_i16 = ::flatbuffers::nullopt;
|
||||
int16_t default_i16 = 42;
|
||||
uint16_t just_u16 = 0;
|
||||
::flatbuffers::Optional<uint16_t> maybe_u16 = ::flatbuffers::nullopt;
|
||||
uint16_t default_u16 = 42;
|
||||
int32_t just_i32 = 0;
|
||||
::flatbuffers::Optional<int32_t> maybe_i32 = ::flatbuffers::nullopt;
|
||||
int32_t default_i32 = 42;
|
||||
uint32_t just_u32 = 0;
|
||||
::flatbuffers::Optional<uint32_t> maybe_u32 = ::flatbuffers::nullopt;
|
||||
uint32_t default_u32 = 42;
|
||||
int64_t just_i64 = 0;
|
||||
::flatbuffers::Optional<int64_t> maybe_i64 = ::flatbuffers::nullopt;
|
||||
int64_t default_i64 = 42LL;
|
||||
uint64_t just_u64 = 0;
|
||||
::flatbuffers::Optional<uint64_t> maybe_u64 = ::flatbuffers::nullopt;
|
||||
uint64_t default_u64 = 42ULL;
|
||||
float just_f32 = 0.0f;
|
||||
::flatbuffers::Optional<float> maybe_f32 = ::flatbuffers::nullopt;
|
||||
float default_f32 = 42.0f;
|
||||
double just_f64 = 0.0;
|
||||
::flatbuffers::Optional<double> maybe_f64 = ::flatbuffers::nullopt;
|
||||
double default_f64 = 42.0;
|
||||
bool just_bool = false;
|
||||
::flatbuffers::Optional<bool> maybe_bool = ::flatbuffers::nullopt;
|
||||
bool default_bool = true;
|
||||
optional_scalars::OptionalByte just_enum = optional_scalars::OptionalByte_None;
|
||||
::flatbuffers::Optional<optional_scalars::OptionalByte> maybe_enum = ::flatbuffers::nullopt;
|
||||
optional_scalars::OptionalByte default_enum = optional_scalars::OptionalByte_One;
|
||||
};
|
||||
|
||||
struct ScalarStuff FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef ScalarStuffT NativeTableType;
|
||||
typedef ScalarStuffBuilder Builder;
|
||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return ScalarStuffTypeTable();
|
||||
}
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_JUST_I8 = 4,
|
||||
VT_MAYBE_I8 = 6,
|
||||
VT_DEFAULT_I8 = 8,
|
||||
VT_JUST_U8 = 10,
|
||||
VT_MAYBE_U8 = 12,
|
||||
VT_DEFAULT_U8 = 14,
|
||||
VT_JUST_I16 = 16,
|
||||
VT_MAYBE_I16 = 18,
|
||||
VT_DEFAULT_I16 = 20,
|
||||
VT_JUST_U16 = 22,
|
||||
VT_MAYBE_U16 = 24,
|
||||
VT_DEFAULT_U16 = 26,
|
||||
VT_JUST_I32 = 28,
|
||||
VT_MAYBE_I32 = 30,
|
||||
VT_DEFAULT_I32 = 32,
|
||||
VT_JUST_U32 = 34,
|
||||
VT_MAYBE_U32 = 36,
|
||||
VT_DEFAULT_U32 = 38,
|
||||
VT_JUST_I64 = 40,
|
||||
VT_MAYBE_I64 = 42,
|
||||
VT_DEFAULT_I64 = 44,
|
||||
VT_JUST_U64 = 46,
|
||||
VT_MAYBE_U64 = 48,
|
||||
VT_DEFAULT_U64 = 50,
|
||||
VT_JUST_F32 = 52,
|
||||
VT_MAYBE_F32 = 54,
|
||||
VT_DEFAULT_F32 = 56,
|
||||
VT_JUST_F64 = 58,
|
||||
VT_MAYBE_F64 = 60,
|
||||
VT_DEFAULT_F64 = 62,
|
||||
VT_JUST_BOOL = 64,
|
||||
VT_MAYBE_BOOL = 66,
|
||||
VT_DEFAULT_BOOL = 68,
|
||||
VT_JUST_ENUM = 70,
|
||||
VT_MAYBE_ENUM = 72,
|
||||
VT_DEFAULT_ENUM = 74
|
||||
};
|
||||
int8_t just_i8() const {
|
||||
return GetField<int8_t>(VT_JUST_I8, 0);
|
||||
}
|
||||
bool mutate_just_i8(int8_t _just_i8 = 0) {
|
||||
return SetField<int8_t>(VT_JUST_I8, _just_i8, 0);
|
||||
}
|
||||
::flatbuffers::Optional<int8_t> maybe_i8() const {
|
||||
return GetOptional<int8_t, int8_t>(VT_MAYBE_I8);
|
||||
}
|
||||
bool mutate_maybe_i8(int8_t _maybe_i8) {
|
||||
return SetField<int8_t>(VT_MAYBE_I8, _maybe_i8);
|
||||
}
|
||||
int8_t default_i8() const {
|
||||
return GetField<int8_t>(VT_DEFAULT_I8, 42);
|
||||
}
|
||||
bool mutate_default_i8(int8_t _default_i8 = 42) {
|
||||
return SetField<int8_t>(VT_DEFAULT_I8, _default_i8, 42);
|
||||
}
|
||||
uint8_t just_u8() const {
|
||||
return GetField<uint8_t>(VT_JUST_U8, 0);
|
||||
}
|
||||
bool mutate_just_u8(uint8_t _just_u8 = 0) {
|
||||
return SetField<uint8_t>(VT_JUST_U8, _just_u8, 0);
|
||||
}
|
||||
::flatbuffers::Optional<uint8_t> maybe_u8() const {
|
||||
return GetOptional<uint8_t, uint8_t>(VT_MAYBE_U8);
|
||||
}
|
||||
bool mutate_maybe_u8(uint8_t _maybe_u8) {
|
||||
return SetField<uint8_t>(VT_MAYBE_U8, _maybe_u8);
|
||||
}
|
||||
uint8_t default_u8() const {
|
||||
return GetField<uint8_t>(VT_DEFAULT_U8, 42);
|
||||
}
|
||||
bool mutate_default_u8(uint8_t _default_u8 = 42) {
|
||||
return SetField<uint8_t>(VT_DEFAULT_U8, _default_u8, 42);
|
||||
}
|
||||
int16_t just_i16() const {
|
||||
return GetField<int16_t>(VT_JUST_I16, 0);
|
||||
}
|
||||
bool mutate_just_i16(int16_t _just_i16 = 0) {
|
||||
return SetField<int16_t>(VT_JUST_I16, _just_i16, 0);
|
||||
}
|
||||
::flatbuffers::Optional<int16_t> maybe_i16() const {
|
||||
return GetOptional<int16_t, int16_t>(VT_MAYBE_I16);
|
||||
}
|
||||
bool mutate_maybe_i16(int16_t _maybe_i16) {
|
||||
return SetField<int16_t>(VT_MAYBE_I16, _maybe_i16);
|
||||
}
|
||||
int16_t default_i16() const {
|
||||
return GetField<int16_t>(VT_DEFAULT_I16, 42);
|
||||
}
|
||||
bool mutate_default_i16(int16_t _default_i16 = 42) {
|
||||
return SetField<int16_t>(VT_DEFAULT_I16, _default_i16, 42);
|
||||
}
|
||||
uint16_t just_u16() const {
|
||||
return GetField<uint16_t>(VT_JUST_U16, 0);
|
||||
}
|
||||
bool mutate_just_u16(uint16_t _just_u16 = 0) {
|
||||
return SetField<uint16_t>(VT_JUST_U16, _just_u16, 0);
|
||||
}
|
||||
::flatbuffers::Optional<uint16_t> maybe_u16() const {
|
||||
return GetOptional<uint16_t, uint16_t>(VT_MAYBE_U16);
|
||||
}
|
||||
bool mutate_maybe_u16(uint16_t _maybe_u16) {
|
||||
return SetField<uint16_t>(VT_MAYBE_U16, _maybe_u16);
|
||||
}
|
||||
uint16_t default_u16() const {
|
||||
return GetField<uint16_t>(VT_DEFAULT_U16, 42);
|
||||
}
|
||||
bool mutate_default_u16(uint16_t _default_u16 = 42) {
|
||||
return SetField<uint16_t>(VT_DEFAULT_U16, _default_u16, 42);
|
||||
}
|
||||
int32_t just_i32() const {
|
||||
return GetField<int32_t>(VT_JUST_I32, 0);
|
||||
}
|
||||
bool mutate_just_i32(int32_t _just_i32 = 0) {
|
||||
return SetField<int32_t>(VT_JUST_I32, _just_i32, 0);
|
||||
}
|
||||
::flatbuffers::Optional<int32_t> maybe_i32() const {
|
||||
return GetOptional<int32_t, int32_t>(VT_MAYBE_I32);
|
||||
}
|
||||
bool mutate_maybe_i32(int32_t _maybe_i32) {
|
||||
return SetField<int32_t>(VT_MAYBE_I32, _maybe_i32);
|
||||
}
|
||||
int32_t default_i32() const {
|
||||
return GetField<int32_t>(VT_DEFAULT_I32, 42);
|
||||
}
|
||||
bool mutate_default_i32(int32_t _default_i32 = 42) {
|
||||
return SetField<int32_t>(VT_DEFAULT_I32, _default_i32, 42);
|
||||
}
|
||||
uint32_t just_u32() const {
|
||||
return GetField<uint32_t>(VT_JUST_U32, 0);
|
||||
}
|
||||
bool mutate_just_u32(uint32_t _just_u32 = 0) {
|
||||
return SetField<uint32_t>(VT_JUST_U32, _just_u32, 0);
|
||||
}
|
||||
::flatbuffers::Optional<uint32_t> maybe_u32() const {
|
||||
return GetOptional<uint32_t, uint32_t>(VT_MAYBE_U32);
|
||||
}
|
||||
bool mutate_maybe_u32(uint32_t _maybe_u32) {
|
||||
return SetField<uint32_t>(VT_MAYBE_U32, _maybe_u32);
|
||||
}
|
||||
uint32_t default_u32() const {
|
||||
return GetField<uint32_t>(VT_DEFAULT_U32, 42);
|
||||
}
|
||||
bool mutate_default_u32(uint32_t _default_u32 = 42) {
|
||||
return SetField<uint32_t>(VT_DEFAULT_U32, _default_u32, 42);
|
||||
}
|
||||
int64_t just_i64() const {
|
||||
return GetField<int64_t>(VT_JUST_I64, 0);
|
||||
}
|
||||
bool mutate_just_i64(int64_t _just_i64 = 0) {
|
||||
return SetField<int64_t>(VT_JUST_I64, _just_i64, 0);
|
||||
}
|
||||
::flatbuffers::Optional<int64_t> maybe_i64() const {
|
||||
return GetOptional<int64_t, int64_t>(VT_MAYBE_I64);
|
||||
}
|
||||
bool mutate_maybe_i64(int64_t _maybe_i64) {
|
||||
return SetField<int64_t>(VT_MAYBE_I64, _maybe_i64);
|
||||
}
|
||||
int64_t default_i64() const {
|
||||
return GetField<int64_t>(VT_DEFAULT_I64, 42LL);
|
||||
}
|
||||
bool mutate_default_i64(int64_t _default_i64 = 42LL) {
|
||||
return SetField<int64_t>(VT_DEFAULT_I64, _default_i64, 42LL);
|
||||
}
|
||||
uint64_t just_u64() const {
|
||||
return GetField<uint64_t>(VT_JUST_U64, 0);
|
||||
}
|
||||
bool mutate_just_u64(uint64_t _just_u64 = 0) {
|
||||
return SetField<uint64_t>(VT_JUST_U64, _just_u64, 0);
|
||||
}
|
||||
::flatbuffers::Optional<uint64_t> maybe_u64() const {
|
||||
return GetOptional<uint64_t, uint64_t>(VT_MAYBE_U64);
|
||||
}
|
||||
bool mutate_maybe_u64(uint64_t _maybe_u64) {
|
||||
return SetField<uint64_t>(VT_MAYBE_U64, _maybe_u64);
|
||||
}
|
||||
uint64_t default_u64() const {
|
||||
return GetField<uint64_t>(VT_DEFAULT_U64, 42ULL);
|
||||
}
|
||||
bool mutate_default_u64(uint64_t _default_u64 = 42ULL) {
|
||||
return SetField<uint64_t>(VT_DEFAULT_U64, _default_u64, 42ULL);
|
||||
}
|
||||
float just_f32() const {
|
||||
return GetField<float>(VT_JUST_F32, 0.0f);
|
||||
}
|
||||
bool mutate_just_f32(float _just_f32 = 0.0f) {
|
||||
return SetField<float>(VT_JUST_F32, _just_f32, 0.0f);
|
||||
}
|
||||
::flatbuffers::Optional<float> maybe_f32() const {
|
||||
return GetOptional<float, float>(VT_MAYBE_F32);
|
||||
}
|
||||
bool mutate_maybe_f32(float _maybe_f32) {
|
||||
return SetField<float>(VT_MAYBE_F32, _maybe_f32);
|
||||
}
|
||||
float default_f32() const {
|
||||
return GetField<float>(VT_DEFAULT_F32, 42.0f);
|
||||
}
|
||||
bool mutate_default_f32(float _default_f32 = 42.0f) {
|
||||
return SetField<float>(VT_DEFAULT_F32, _default_f32, 42.0f);
|
||||
}
|
||||
double just_f64() const {
|
||||
return GetField<double>(VT_JUST_F64, 0.0);
|
||||
}
|
||||
bool mutate_just_f64(double _just_f64 = 0.0) {
|
||||
return SetField<double>(VT_JUST_F64, _just_f64, 0.0);
|
||||
}
|
||||
::flatbuffers::Optional<double> maybe_f64() const {
|
||||
return GetOptional<double, double>(VT_MAYBE_F64);
|
||||
}
|
||||
bool mutate_maybe_f64(double _maybe_f64) {
|
||||
return SetField<double>(VT_MAYBE_F64, _maybe_f64);
|
||||
}
|
||||
double default_f64() const {
|
||||
return GetField<double>(VT_DEFAULT_F64, 42.0);
|
||||
}
|
||||
bool mutate_default_f64(double _default_f64 = 42.0) {
|
||||
return SetField<double>(VT_DEFAULT_F64, _default_f64, 42.0);
|
||||
}
|
||||
bool just_bool() const {
|
||||
return GetField<uint8_t>(VT_JUST_BOOL, 0) != 0;
|
||||
}
|
||||
bool mutate_just_bool(bool _just_bool = 0) {
|
||||
return SetField<uint8_t>(VT_JUST_BOOL, static_cast<uint8_t>(_just_bool), 0);
|
||||
}
|
||||
::flatbuffers::Optional<bool> maybe_bool() const {
|
||||
return GetOptional<uint8_t, bool>(VT_MAYBE_BOOL);
|
||||
}
|
||||
bool mutate_maybe_bool(bool _maybe_bool) {
|
||||
return SetField<uint8_t>(VT_MAYBE_BOOL, static_cast<uint8_t>(_maybe_bool));
|
||||
}
|
||||
bool default_bool() const {
|
||||
return GetField<uint8_t>(VT_DEFAULT_BOOL, 1) != 0;
|
||||
}
|
||||
bool mutate_default_bool(bool _default_bool = 1) {
|
||||
return SetField<uint8_t>(VT_DEFAULT_BOOL, static_cast<uint8_t>(_default_bool), 1);
|
||||
}
|
||||
optional_scalars::OptionalByte just_enum() const {
|
||||
return static_cast<optional_scalars::OptionalByte>(GetField<int8_t>(VT_JUST_ENUM, 0));
|
||||
}
|
||||
bool mutate_just_enum(optional_scalars::OptionalByte _just_enum = static_cast<optional_scalars::OptionalByte>(0)) {
|
||||
return SetField<int8_t>(VT_JUST_ENUM, static_cast<int8_t>(_just_enum), 0);
|
||||
}
|
||||
::flatbuffers::Optional<optional_scalars::OptionalByte> maybe_enum() const {
|
||||
return GetOptional<int8_t, optional_scalars::OptionalByte>(VT_MAYBE_ENUM);
|
||||
}
|
||||
bool mutate_maybe_enum(optional_scalars::OptionalByte _maybe_enum) {
|
||||
return SetField<int8_t>(VT_MAYBE_ENUM, static_cast<int8_t>(_maybe_enum));
|
||||
}
|
||||
optional_scalars::OptionalByte default_enum() const {
|
||||
return static_cast<optional_scalars::OptionalByte>(GetField<int8_t>(VT_DEFAULT_ENUM, 1));
|
||||
}
|
||||
bool mutate_default_enum(optional_scalars::OptionalByte _default_enum = static_cast<optional_scalars::OptionalByte>(1)) {
|
||||
return SetField<int8_t>(VT_DEFAULT_ENUM, static_cast<int8_t>(_default_enum), 1);
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int8_t>(verifier, VT_JUST_I8, 1) &&
|
||||
VerifyField<int8_t>(verifier, VT_MAYBE_I8, 1) &&
|
||||
VerifyField<int8_t>(verifier, VT_DEFAULT_I8, 1) &&
|
||||
VerifyField<uint8_t>(verifier, VT_JUST_U8, 1) &&
|
||||
VerifyField<uint8_t>(verifier, VT_MAYBE_U8, 1) &&
|
||||
VerifyField<uint8_t>(verifier, VT_DEFAULT_U8, 1) &&
|
||||
VerifyField<int16_t>(verifier, VT_JUST_I16, 2) &&
|
||||
VerifyField<int16_t>(verifier, VT_MAYBE_I16, 2) &&
|
||||
VerifyField<int16_t>(verifier, VT_DEFAULT_I16, 2) &&
|
||||
VerifyField<uint16_t>(verifier, VT_JUST_U16, 2) &&
|
||||
VerifyField<uint16_t>(verifier, VT_MAYBE_U16, 2) &&
|
||||
VerifyField<uint16_t>(verifier, VT_DEFAULT_U16, 2) &&
|
||||
VerifyField<int32_t>(verifier, VT_JUST_I32, 4) &&
|
||||
VerifyField<int32_t>(verifier, VT_MAYBE_I32, 4) &&
|
||||
VerifyField<int32_t>(verifier, VT_DEFAULT_I32, 4) &&
|
||||
VerifyField<uint32_t>(verifier, VT_JUST_U32, 4) &&
|
||||
VerifyField<uint32_t>(verifier, VT_MAYBE_U32, 4) &&
|
||||
VerifyField<uint32_t>(verifier, VT_DEFAULT_U32, 4) &&
|
||||
VerifyField<int64_t>(verifier, VT_JUST_I64, 8) &&
|
||||
VerifyField<int64_t>(verifier, VT_MAYBE_I64, 8) &&
|
||||
VerifyField<int64_t>(verifier, VT_DEFAULT_I64, 8) &&
|
||||
VerifyField<uint64_t>(verifier, VT_JUST_U64, 8) &&
|
||||
VerifyField<uint64_t>(verifier, VT_MAYBE_U64, 8) &&
|
||||
VerifyField<uint64_t>(verifier, VT_DEFAULT_U64, 8) &&
|
||||
VerifyField<float>(verifier, VT_JUST_F32, 4) &&
|
||||
VerifyField<float>(verifier, VT_MAYBE_F32, 4) &&
|
||||
VerifyField<float>(verifier, VT_DEFAULT_F32, 4) &&
|
||||
VerifyField<double>(verifier, VT_JUST_F64, 8) &&
|
||||
VerifyField<double>(verifier, VT_MAYBE_F64, 8) &&
|
||||
VerifyField<double>(verifier, VT_DEFAULT_F64, 8) &&
|
||||
VerifyField<uint8_t>(verifier, VT_JUST_BOOL, 1) &&
|
||||
VerifyField<uint8_t>(verifier, VT_MAYBE_BOOL, 1) &&
|
||||
VerifyField<uint8_t>(verifier, VT_DEFAULT_BOOL, 1) &&
|
||||
VerifyField<int8_t>(verifier, VT_JUST_ENUM, 1) &&
|
||||
VerifyField<int8_t>(verifier, VT_MAYBE_ENUM, 1) &&
|
||||
VerifyField<int8_t>(verifier, VT_DEFAULT_ENUM, 1) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
ScalarStuffT *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
void UnPackTo(ScalarStuffT *_o, const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
static ::flatbuffers::Offset<ScalarStuff> Pack(::flatbuffers::FlatBufferBuilder &_fbb, const ScalarStuffT* _o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
};
|
||||
|
||||
struct ScalarStuffBuilder {
|
||||
typedef ScalarStuff Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_just_i8(int8_t just_i8) {
|
||||
fbb_.AddElement<int8_t>(ScalarStuff::VT_JUST_I8, just_i8, 0);
|
||||
}
|
||||
void add_maybe_i8(int8_t maybe_i8) {
|
||||
fbb_.AddElement<int8_t>(ScalarStuff::VT_MAYBE_I8, maybe_i8);
|
||||
}
|
||||
void add_default_i8(int8_t default_i8) {
|
||||
fbb_.AddElement<int8_t>(ScalarStuff::VT_DEFAULT_I8, default_i8, 42);
|
||||
}
|
||||
void add_just_u8(uint8_t just_u8) {
|
||||
fbb_.AddElement<uint8_t>(ScalarStuff::VT_JUST_U8, just_u8, 0);
|
||||
}
|
||||
void add_maybe_u8(uint8_t maybe_u8) {
|
||||
fbb_.AddElement<uint8_t>(ScalarStuff::VT_MAYBE_U8, maybe_u8);
|
||||
}
|
||||
void add_default_u8(uint8_t default_u8) {
|
||||
fbb_.AddElement<uint8_t>(ScalarStuff::VT_DEFAULT_U8, default_u8, 42);
|
||||
}
|
||||
void add_just_i16(int16_t just_i16) {
|
||||
fbb_.AddElement<int16_t>(ScalarStuff::VT_JUST_I16, just_i16, 0);
|
||||
}
|
||||
void add_maybe_i16(int16_t maybe_i16) {
|
||||
fbb_.AddElement<int16_t>(ScalarStuff::VT_MAYBE_I16, maybe_i16);
|
||||
}
|
||||
void add_default_i16(int16_t default_i16) {
|
||||
fbb_.AddElement<int16_t>(ScalarStuff::VT_DEFAULT_I16, default_i16, 42);
|
||||
}
|
||||
void add_just_u16(uint16_t just_u16) {
|
||||
fbb_.AddElement<uint16_t>(ScalarStuff::VT_JUST_U16, just_u16, 0);
|
||||
}
|
||||
void add_maybe_u16(uint16_t maybe_u16) {
|
||||
fbb_.AddElement<uint16_t>(ScalarStuff::VT_MAYBE_U16, maybe_u16);
|
||||
}
|
||||
void add_default_u16(uint16_t default_u16) {
|
||||
fbb_.AddElement<uint16_t>(ScalarStuff::VT_DEFAULT_U16, default_u16, 42);
|
||||
}
|
||||
void add_just_i32(int32_t just_i32) {
|
||||
fbb_.AddElement<int32_t>(ScalarStuff::VT_JUST_I32, just_i32, 0);
|
||||
}
|
||||
void add_maybe_i32(int32_t maybe_i32) {
|
||||
fbb_.AddElement<int32_t>(ScalarStuff::VT_MAYBE_I32, maybe_i32);
|
||||
}
|
||||
void add_default_i32(int32_t default_i32) {
|
||||
fbb_.AddElement<int32_t>(ScalarStuff::VT_DEFAULT_I32, default_i32, 42);
|
||||
}
|
||||
void add_just_u32(uint32_t just_u32) {
|
||||
fbb_.AddElement<uint32_t>(ScalarStuff::VT_JUST_U32, just_u32, 0);
|
||||
}
|
||||
void add_maybe_u32(uint32_t maybe_u32) {
|
||||
fbb_.AddElement<uint32_t>(ScalarStuff::VT_MAYBE_U32, maybe_u32);
|
||||
}
|
||||
void add_default_u32(uint32_t default_u32) {
|
||||
fbb_.AddElement<uint32_t>(ScalarStuff::VT_DEFAULT_U32, default_u32, 42);
|
||||
}
|
||||
void add_just_i64(int64_t just_i64) {
|
||||
fbb_.AddElement<int64_t>(ScalarStuff::VT_JUST_I64, just_i64, 0);
|
||||
}
|
||||
void add_maybe_i64(int64_t maybe_i64) {
|
||||
fbb_.AddElement<int64_t>(ScalarStuff::VT_MAYBE_I64, maybe_i64);
|
||||
}
|
||||
void add_default_i64(int64_t default_i64) {
|
||||
fbb_.AddElement<int64_t>(ScalarStuff::VT_DEFAULT_I64, default_i64, 42LL);
|
||||
}
|
||||
void add_just_u64(uint64_t just_u64) {
|
||||
fbb_.AddElement<uint64_t>(ScalarStuff::VT_JUST_U64, just_u64, 0);
|
||||
}
|
||||
void add_maybe_u64(uint64_t maybe_u64) {
|
||||
fbb_.AddElement<uint64_t>(ScalarStuff::VT_MAYBE_U64, maybe_u64);
|
||||
}
|
||||
void add_default_u64(uint64_t default_u64) {
|
||||
fbb_.AddElement<uint64_t>(ScalarStuff::VT_DEFAULT_U64, default_u64, 42ULL);
|
||||
}
|
||||
void add_just_f32(float just_f32) {
|
||||
fbb_.AddElement<float>(ScalarStuff::VT_JUST_F32, just_f32, 0.0f);
|
||||
}
|
||||
void add_maybe_f32(float maybe_f32) {
|
||||
fbb_.AddElement<float>(ScalarStuff::VT_MAYBE_F32, maybe_f32);
|
||||
}
|
||||
void add_default_f32(float default_f32) {
|
||||
fbb_.AddElement<float>(ScalarStuff::VT_DEFAULT_F32, default_f32, 42.0f);
|
||||
}
|
||||
void add_just_f64(double just_f64) {
|
||||
fbb_.AddElement<double>(ScalarStuff::VT_JUST_F64, just_f64, 0.0);
|
||||
}
|
||||
void add_maybe_f64(double maybe_f64) {
|
||||
fbb_.AddElement<double>(ScalarStuff::VT_MAYBE_F64, maybe_f64);
|
||||
}
|
||||
void add_default_f64(double default_f64) {
|
||||
fbb_.AddElement<double>(ScalarStuff::VT_DEFAULT_F64, default_f64, 42.0);
|
||||
}
|
||||
void add_just_bool(bool just_bool) {
|
||||
fbb_.AddElement<uint8_t>(ScalarStuff::VT_JUST_BOOL, static_cast<uint8_t>(just_bool), 0);
|
||||
}
|
||||
void add_maybe_bool(bool maybe_bool) {
|
||||
fbb_.AddElement<uint8_t>(ScalarStuff::VT_MAYBE_BOOL, static_cast<uint8_t>(maybe_bool));
|
||||
}
|
||||
void add_default_bool(bool default_bool) {
|
||||
fbb_.AddElement<uint8_t>(ScalarStuff::VT_DEFAULT_BOOL, static_cast<uint8_t>(default_bool), 1);
|
||||
}
|
||||
void add_just_enum(optional_scalars::OptionalByte just_enum) {
|
||||
fbb_.AddElement<int8_t>(ScalarStuff::VT_JUST_ENUM, static_cast<int8_t>(just_enum), 0);
|
||||
}
|
||||
void add_maybe_enum(optional_scalars::OptionalByte maybe_enum) {
|
||||
fbb_.AddElement<int8_t>(ScalarStuff::VT_MAYBE_ENUM, static_cast<int8_t>(maybe_enum));
|
||||
}
|
||||
void add_default_enum(optional_scalars::OptionalByte default_enum) {
|
||||
fbb_.AddElement<int8_t>(ScalarStuff::VT_DEFAULT_ENUM, static_cast<int8_t>(default_enum), 1);
|
||||
}
|
||||
explicit ScalarStuffBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<ScalarStuff> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<ScalarStuff>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<ScalarStuff> CreateScalarStuff(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int8_t just_i8 = 0,
|
||||
::flatbuffers::Optional<int8_t> maybe_i8 = ::flatbuffers::nullopt,
|
||||
int8_t default_i8 = 42,
|
||||
uint8_t just_u8 = 0,
|
||||
::flatbuffers::Optional<uint8_t> maybe_u8 = ::flatbuffers::nullopt,
|
||||
uint8_t default_u8 = 42,
|
||||
int16_t just_i16 = 0,
|
||||
::flatbuffers::Optional<int16_t> maybe_i16 = ::flatbuffers::nullopt,
|
||||
int16_t default_i16 = 42,
|
||||
uint16_t just_u16 = 0,
|
||||
::flatbuffers::Optional<uint16_t> maybe_u16 = ::flatbuffers::nullopt,
|
||||
uint16_t default_u16 = 42,
|
||||
int32_t just_i32 = 0,
|
||||
::flatbuffers::Optional<int32_t> maybe_i32 = ::flatbuffers::nullopt,
|
||||
int32_t default_i32 = 42,
|
||||
uint32_t just_u32 = 0,
|
||||
::flatbuffers::Optional<uint32_t> maybe_u32 = ::flatbuffers::nullopt,
|
||||
uint32_t default_u32 = 42,
|
||||
int64_t just_i64 = 0,
|
||||
::flatbuffers::Optional<int64_t> maybe_i64 = ::flatbuffers::nullopt,
|
||||
int64_t default_i64 = 42LL,
|
||||
uint64_t just_u64 = 0,
|
||||
::flatbuffers::Optional<uint64_t> maybe_u64 = ::flatbuffers::nullopt,
|
||||
uint64_t default_u64 = 42ULL,
|
||||
float just_f32 = 0.0f,
|
||||
::flatbuffers::Optional<float> maybe_f32 = ::flatbuffers::nullopt,
|
||||
float default_f32 = 42.0f,
|
||||
double just_f64 = 0.0,
|
||||
::flatbuffers::Optional<double> maybe_f64 = ::flatbuffers::nullopt,
|
||||
double default_f64 = 42.0,
|
||||
bool just_bool = false,
|
||||
::flatbuffers::Optional<bool> maybe_bool = ::flatbuffers::nullopt,
|
||||
bool default_bool = true,
|
||||
optional_scalars::OptionalByte just_enum = optional_scalars::OptionalByte_None,
|
||||
::flatbuffers::Optional<optional_scalars::OptionalByte> maybe_enum = ::flatbuffers::nullopt,
|
||||
optional_scalars::OptionalByte default_enum = optional_scalars::OptionalByte_One) {
|
||||
ScalarStuffBuilder builder_(_fbb);
|
||||
builder_.add_default_f64(default_f64);
|
||||
if(maybe_f64) { builder_.add_maybe_f64(*maybe_f64); }
|
||||
builder_.add_just_f64(just_f64);
|
||||
builder_.add_default_u64(default_u64);
|
||||
if(maybe_u64) { builder_.add_maybe_u64(*maybe_u64); }
|
||||
builder_.add_just_u64(just_u64);
|
||||
builder_.add_default_i64(default_i64);
|
||||
if(maybe_i64) { builder_.add_maybe_i64(*maybe_i64); }
|
||||
builder_.add_just_i64(just_i64);
|
||||
builder_.add_default_f32(default_f32);
|
||||
if(maybe_f32) { builder_.add_maybe_f32(*maybe_f32); }
|
||||
builder_.add_just_f32(just_f32);
|
||||
builder_.add_default_u32(default_u32);
|
||||
if(maybe_u32) { builder_.add_maybe_u32(*maybe_u32); }
|
||||
builder_.add_just_u32(just_u32);
|
||||
builder_.add_default_i32(default_i32);
|
||||
if(maybe_i32) { builder_.add_maybe_i32(*maybe_i32); }
|
||||
builder_.add_just_i32(just_i32);
|
||||
builder_.add_default_u16(default_u16);
|
||||
if(maybe_u16) { builder_.add_maybe_u16(*maybe_u16); }
|
||||
builder_.add_just_u16(just_u16);
|
||||
builder_.add_default_i16(default_i16);
|
||||
if(maybe_i16) { builder_.add_maybe_i16(*maybe_i16); }
|
||||
builder_.add_just_i16(just_i16);
|
||||
builder_.add_default_enum(default_enum);
|
||||
if(maybe_enum) { builder_.add_maybe_enum(*maybe_enum); }
|
||||
builder_.add_just_enum(just_enum);
|
||||
builder_.add_default_bool(default_bool);
|
||||
if(maybe_bool) { builder_.add_maybe_bool(*maybe_bool); }
|
||||
builder_.add_just_bool(just_bool);
|
||||
builder_.add_default_u8(default_u8);
|
||||
if(maybe_u8) { builder_.add_maybe_u8(*maybe_u8); }
|
||||
builder_.add_just_u8(just_u8);
|
||||
builder_.add_default_i8(default_i8);
|
||||
if(maybe_i8) { builder_.add_maybe_i8(*maybe_i8); }
|
||||
builder_.add_just_i8(just_i8);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
::flatbuffers::Offset<ScalarStuff> CreateScalarStuff(::flatbuffers::FlatBufferBuilder &_fbb, const ScalarStuffT *_o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
|
||||
|
||||
inline bool operator==(const ScalarStuffT &lhs, const ScalarStuffT &rhs) {
|
||||
return
|
||||
(lhs.just_i8 == rhs.just_i8) &&
|
||||
(lhs.maybe_i8 == rhs.maybe_i8) &&
|
||||
(lhs.default_i8 == rhs.default_i8) &&
|
||||
(lhs.just_u8 == rhs.just_u8) &&
|
||||
(lhs.maybe_u8 == rhs.maybe_u8) &&
|
||||
(lhs.default_u8 == rhs.default_u8) &&
|
||||
(lhs.just_i16 == rhs.just_i16) &&
|
||||
(lhs.maybe_i16 == rhs.maybe_i16) &&
|
||||
(lhs.default_i16 == rhs.default_i16) &&
|
||||
(lhs.just_u16 == rhs.just_u16) &&
|
||||
(lhs.maybe_u16 == rhs.maybe_u16) &&
|
||||
(lhs.default_u16 == rhs.default_u16) &&
|
||||
(lhs.just_i32 == rhs.just_i32) &&
|
||||
(lhs.maybe_i32 == rhs.maybe_i32) &&
|
||||
(lhs.default_i32 == rhs.default_i32) &&
|
||||
(lhs.just_u32 == rhs.just_u32) &&
|
||||
(lhs.maybe_u32 == rhs.maybe_u32) &&
|
||||
(lhs.default_u32 == rhs.default_u32) &&
|
||||
(lhs.just_i64 == rhs.just_i64) &&
|
||||
(lhs.maybe_i64 == rhs.maybe_i64) &&
|
||||
(lhs.default_i64 == rhs.default_i64) &&
|
||||
(lhs.just_u64 == rhs.just_u64) &&
|
||||
(lhs.maybe_u64 == rhs.maybe_u64) &&
|
||||
(lhs.default_u64 == rhs.default_u64) &&
|
||||
(lhs.just_f32 == rhs.just_f32) &&
|
||||
(lhs.maybe_f32 == rhs.maybe_f32) &&
|
||||
(lhs.default_f32 == rhs.default_f32) &&
|
||||
(lhs.just_f64 == rhs.just_f64) &&
|
||||
(lhs.maybe_f64 == rhs.maybe_f64) &&
|
||||
(lhs.default_f64 == rhs.default_f64) &&
|
||||
(lhs.just_bool == rhs.just_bool) &&
|
||||
(lhs.maybe_bool == rhs.maybe_bool) &&
|
||||
(lhs.default_bool == rhs.default_bool) &&
|
||||
(lhs.just_enum == rhs.just_enum) &&
|
||||
(lhs.maybe_enum == rhs.maybe_enum) &&
|
||||
(lhs.default_enum == rhs.default_enum);
|
||||
}
|
||||
|
||||
inline bool operator!=(const ScalarStuffT &lhs, const ScalarStuffT &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
|
||||
inline ScalarStuffT *ScalarStuff::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
auto _o = std::unique_ptr<ScalarStuffT>(new ScalarStuffT());
|
||||
UnPackTo(_o.get(), _resolver);
|
||||
return _o.release();
|
||||
}
|
||||
|
||||
inline void ScalarStuff::UnPackTo(ScalarStuffT *_o, const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
(void)_o;
|
||||
(void)_resolver;
|
||||
{ auto _e = just_i8(); _o->just_i8 = _e; }
|
||||
{ auto _e = maybe_i8(); _o->maybe_i8 = _e; }
|
||||
{ auto _e = default_i8(); _o->default_i8 = _e; }
|
||||
{ auto _e = just_u8(); _o->just_u8 = _e; }
|
||||
{ auto _e = maybe_u8(); _o->maybe_u8 = _e; }
|
||||
{ auto _e = default_u8(); _o->default_u8 = _e; }
|
||||
{ auto _e = just_i16(); _o->just_i16 = _e; }
|
||||
{ auto _e = maybe_i16(); _o->maybe_i16 = _e; }
|
||||
{ auto _e = default_i16(); _o->default_i16 = _e; }
|
||||
{ auto _e = just_u16(); _o->just_u16 = _e; }
|
||||
{ auto _e = maybe_u16(); _o->maybe_u16 = _e; }
|
||||
{ auto _e = default_u16(); _o->default_u16 = _e; }
|
||||
{ auto _e = just_i32(); _o->just_i32 = _e; }
|
||||
{ auto _e = maybe_i32(); _o->maybe_i32 = _e; }
|
||||
{ auto _e = default_i32(); _o->default_i32 = _e; }
|
||||
{ auto _e = just_u32(); _o->just_u32 = _e; }
|
||||
{ auto _e = maybe_u32(); _o->maybe_u32 = _e; }
|
||||
{ auto _e = default_u32(); _o->default_u32 = _e; }
|
||||
{ auto _e = just_i64(); _o->just_i64 = _e; }
|
||||
{ auto _e = maybe_i64(); _o->maybe_i64 = _e; }
|
||||
{ auto _e = default_i64(); _o->default_i64 = _e; }
|
||||
{ auto _e = just_u64(); _o->just_u64 = _e; }
|
||||
{ auto _e = maybe_u64(); _o->maybe_u64 = _e; }
|
||||
{ auto _e = default_u64(); _o->default_u64 = _e; }
|
||||
{ auto _e = just_f32(); _o->just_f32 = _e; }
|
||||
{ auto _e = maybe_f32(); _o->maybe_f32 = _e; }
|
||||
{ auto _e = default_f32(); _o->default_f32 = _e; }
|
||||
{ auto _e = just_f64(); _o->just_f64 = _e; }
|
||||
{ auto _e = maybe_f64(); _o->maybe_f64 = _e; }
|
||||
{ auto _e = default_f64(); _o->default_f64 = _e; }
|
||||
{ auto _e = just_bool(); _o->just_bool = _e; }
|
||||
{ auto _e = maybe_bool(); _o->maybe_bool = _e; }
|
||||
{ auto _e = default_bool(); _o->default_bool = _e; }
|
||||
{ auto _e = just_enum(); _o->just_enum = _e; }
|
||||
{ auto _e = maybe_enum(); _o->maybe_enum = _e; }
|
||||
{ auto _e = default_enum(); _o->default_enum = _e; }
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<ScalarStuff> CreateScalarStuff(::flatbuffers::FlatBufferBuilder &_fbb, const ScalarStuffT *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
return ScalarStuff::Pack(_fbb, _o, _rehasher);
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<ScalarStuff> ScalarStuff::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const ScalarStuffT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
(void)_rehasher;
|
||||
(void)_o;
|
||||
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const ScalarStuffT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||
auto _just_i8 = _o->just_i8;
|
||||
auto _maybe_i8 = _o->maybe_i8;
|
||||
auto _default_i8 = _o->default_i8;
|
||||
auto _just_u8 = _o->just_u8;
|
||||
auto _maybe_u8 = _o->maybe_u8;
|
||||
auto _default_u8 = _o->default_u8;
|
||||
auto _just_i16 = _o->just_i16;
|
||||
auto _maybe_i16 = _o->maybe_i16;
|
||||
auto _default_i16 = _o->default_i16;
|
||||
auto _just_u16 = _o->just_u16;
|
||||
auto _maybe_u16 = _o->maybe_u16;
|
||||
auto _default_u16 = _o->default_u16;
|
||||
auto _just_i32 = _o->just_i32;
|
||||
auto _maybe_i32 = _o->maybe_i32;
|
||||
auto _default_i32 = _o->default_i32;
|
||||
auto _just_u32 = _o->just_u32;
|
||||
auto _maybe_u32 = _o->maybe_u32;
|
||||
auto _default_u32 = _o->default_u32;
|
||||
auto _just_i64 = _o->just_i64;
|
||||
auto _maybe_i64 = _o->maybe_i64;
|
||||
auto _default_i64 = _o->default_i64;
|
||||
auto _just_u64 = _o->just_u64;
|
||||
auto _maybe_u64 = _o->maybe_u64;
|
||||
auto _default_u64 = _o->default_u64;
|
||||
auto _just_f32 = _o->just_f32;
|
||||
auto _maybe_f32 = _o->maybe_f32;
|
||||
auto _default_f32 = _o->default_f32;
|
||||
auto _just_f64 = _o->just_f64;
|
||||
auto _maybe_f64 = _o->maybe_f64;
|
||||
auto _default_f64 = _o->default_f64;
|
||||
auto _just_bool = _o->just_bool;
|
||||
auto _maybe_bool = _o->maybe_bool;
|
||||
auto _default_bool = _o->default_bool;
|
||||
auto _just_enum = _o->just_enum;
|
||||
auto _maybe_enum = _o->maybe_enum;
|
||||
auto _default_enum = _o->default_enum;
|
||||
return optional_scalars::CreateScalarStuff(
|
||||
_fbb,
|
||||
_just_i8,
|
||||
_maybe_i8,
|
||||
_default_i8,
|
||||
_just_u8,
|
||||
_maybe_u8,
|
||||
_default_u8,
|
||||
_just_i16,
|
||||
_maybe_i16,
|
||||
_default_i16,
|
||||
_just_u16,
|
||||
_maybe_u16,
|
||||
_default_u16,
|
||||
_just_i32,
|
||||
_maybe_i32,
|
||||
_default_i32,
|
||||
_just_u32,
|
||||
_maybe_u32,
|
||||
_default_u32,
|
||||
_just_i64,
|
||||
_maybe_i64,
|
||||
_default_i64,
|
||||
_just_u64,
|
||||
_maybe_u64,
|
||||
_default_u64,
|
||||
_just_f32,
|
||||
_maybe_f32,
|
||||
_default_f32,
|
||||
_just_f64,
|
||||
_maybe_f64,
|
||||
_default_f64,
|
||||
_just_bool,
|
||||
_maybe_bool,
|
||||
_default_bool,
|
||||
_just_enum,
|
||||
_maybe_enum,
|
||||
_default_enum);
|
||||
}
|
||||
|
||||
inline const ::flatbuffers::TypeTable *OptionalByteTypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_CHAR, 0, 0 },
|
||||
{ ::flatbuffers::ET_CHAR, 0, 0 },
|
||||
{ ::flatbuffers::ET_CHAR, 0, 0 }
|
||||
};
|
||||
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||
optional_scalars::OptionalByteTypeTable
|
||||
};
|
||||
static const char * const names[] = {
|
||||
"None",
|
||||
"One",
|
||||
"Two"
|
||||
};
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_ENUM, 3, type_codes, type_refs, nullptr, nullptr, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
inline const ::flatbuffers::TypeTable *ScalarStuffTypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_CHAR, 0, -1 },
|
||||
{ ::flatbuffers::ET_CHAR, 0, -1 },
|
||||
{ ::flatbuffers::ET_CHAR, 0, -1 },
|
||||
{ ::flatbuffers::ET_UCHAR, 0, -1 },
|
||||
{ ::flatbuffers::ET_UCHAR, 0, -1 },
|
||||
{ ::flatbuffers::ET_UCHAR, 0, -1 },
|
||||
{ ::flatbuffers::ET_SHORT, 0, -1 },
|
||||
{ ::flatbuffers::ET_SHORT, 0, -1 },
|
||||
{ ::flatbuffers::ET_SHORT, 0, -1 },
|
||||
{ ::flatbuffers::ET_USHORT, 0, -1 },
|
||||
{ ::flatbuffers::ET_USHORT, 0, -1 },
|
||||
{ ::flatbuffers::ET_USHORT, 0, -1 },
|
||||
{ ::flatbuffers::ET_INT, 0, -1 },
|
||||
{ ::flatbuffers::ET_INT, 0, -1 },
|
||||
{ ::flatbuffers::ET_INT, 0, -1 },
|
||||
{ ::flatbuffers::ET_UINT, 0, -1 },
|
||||
{ ::flatbuffers::ET_UINT, 0, -1 },
|
||||
{ ::flatbuffers::ET_UINT, 0, -1 },
|
||||
{ ::flatbuffers::ET_LONG, 0, -1 },
|
||||
{ ::flatbuffers::ET_LONG, 0, -1 },
|
||||
{ ::flatbuffers::ET_LONG, 0, -1 },
|
||||
{ ::flatbuffers::ET_ULONG, 0, -1 },
|
||||
{ ::flatbuffers::ET_ULONG, 0, -1 },
|
||||
{ ::flatbuffers::ET_ULONG, 0, -1 },
|
||||
{ ::flatbuffers::ET_FLOAT, 0, -1 },
|
||||
{ ::flatbuffers::ET_FLOAT, 0, -1 },
|
||||
{ ::flatbuffers::ET_FLOAT, 0, -1 },
|
||||
{ ::flatbuffers::ET_DOUBLE, 0, -1 },
|
||||
{ ::flatbuffers::ET_DOUBLE, 0, -1 },
|
||||
{ ::flatbuffers::ET_DOUBLE, 0, -1 },
|
||||
{ ::flatbuffers::ET_BOOL, 0, -1 },
|
||||
{ ::flatbuffers::ET_BOOL, 0, -1 },
|
||||
{ ::flatbuffers::ET_BOOL, 0, -1 },
|
||||
{ ::flatbuffers::ET_CHAR, 0, 0 },
|
||||
{ ::flatbuffers::ET_CHAR, 0, 0 },
|
||||
{ ::flatbuffers::ET_CHAR, 0, 0 }
|
||||
};
|
||||
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||
optional_scalars::OptionalByteTypeTable
|
||||
};
|
||||
static const char * const names[] = {
|
||||
"just_i8",
|
||||
"maybe_i8",
|
||||
"default_i8",
|
||||
"just_u8",
|
||||
"maybe_u8",
|
||||
"default_u8",
|
||||
"just_i16",
|
||||
"maybe_i16",
|
||||
"default_i16",
|
||||
"just_u16",
|
||||
"maybe_u16",
|
||||
"default_u16",
|
||||
"just_i32",
|
||||
"maybe_i32",
|
||||
"default_i32",
|
||||
"just_u32",
|
||||
"maybe_u32",
|
||||
"default_u32",
|
||||
"just_i64",
|
||||
"maybe_i64",
|
||||
"default_i64",
|
||||
"just_u64",
|
||||
"maybe_u64",
|
||||
"default_u64",
|
||||
"just_f32",
|
||||
"maybe_f32",
|
||||
"default_f32",
|
||||
"just_f64",
|
||||
"maybe_f64",
|
||||
"default_f64",
|
||||
"just_bool",
|
||||
"maybe_bool",
|
||||
"default_bool",
|
||||
"just_enum",
|
||||
"maybe_enum",
|
||||
"default_enum"
|
||||
};
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_TABLE, 36, type_codes, type_refs, nullptr, nullptr, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
inline const optional_scalars::ScalarStuff *GetScalarStuff(const void *buf) {
|
||||
return ::flatbuffers::GetRoot<optional_scalars::ScalarStuff>(buf);
|
||||
}
|
||||
|
||||
inline const optional_scalars::ScalarStuff *GetSizePrefixedScalarStuff(const void *buf) {
|
||||
return ::flatbuffers::GetSizePrefixedRoot<optional_scalars::ScalarStuff>(buf);
|
||||
}
|
||||
|
||||
inline ScalarStuff *GetMutableScalarStuff(void *buf) {
|
||||
return ::flatbuffers::GetMutableRoot<ScalarStuff>(buf);
|
||||
}
|
||||
|
||||
inline optional_scalars::ScalarStuff *GetMutableSizePrefixedScalarStuff(void *buf) {
|
||||
return ::flatbuffers::GetMutableSizePrefixedRoot<optional_scalars::ScalarStuff>(buf);
|
||||
}
|
||||
|
||||
inline const char *ScalarStuffIdentifier() {
|
||||
return "NULL";
|
||||
}
|
||||
|
||||
inline bool ScalarStuffBufferHasIdentifier(const void *buf) {
|
||||
return ::flatbuffers::BufferHasIdentifier(
|
||||
buf, ScalarStuffIdentifier());
|
||||
}
|
||||
|
||||
inline bool SizePrefixedScalarStuffBufferHasIdentifier(const void *buf) {
|
||||
return ::flatbuffers::BufferHasIdentifier(
|
||||
buf, ScalarStuffIdentifier(), true);
|
||||
}
|
||||
|
||||
template <bool B = false>
|
||||
inline bool VerifyScalarStuffBuffer(
|
||||
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||
return verifier.template VerifyBuffer<optional_scalars::ScalarStuff>(ScalarStuffIdentifier());
|
||||
}
|
||||
|
||||
template <bool B = false>
|
||||
inline bool VerifySizePrefixedScalarStuffBuffer(
|
||||
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||
return verifier.template VerifySizePrefixedBuffer<optional_scalars::ScalarStuff>(ScalarStuffIdentifier());
|
||||
}
|
||||
|
||||
inline const char *ScalarStuffExtension() {
|
||||
return "mon";
|
||||
}
|
||||
|
||||
inline void FinishScalarStuffBuffer(
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<optional_scalars::ScalarStuff> root) {
|
||||
fbb.Finish(root, ScalarStuffIdentifier());
|
||||
}
|
||||
|
||||
inline void FinishSizePrefixedScalarStuffBuffer(
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<optional_scalars::ScalarStuff> root) {
|
||||
fbb.FinishSizePrefixed(root, ScalarStuffIdentifier());
|
||||
}
|
||||
|
||||
inline std::unique_ptr<optional_scalars::ScalarStuffT> UnPackScalarStuff(
|
||||
const void *buf,
|
||||
const ::flatbuffers::resolver_function_t *res = nullptr) {
|
||||
return std::unique_ptr<optional_scalars::ScalarStuffT>(GetScalarStuff(buf)->UnPack(res));
|
||||
}
|
||||
|
||||
inline std::unique_ptr<optional_scalars::ScalarStuffT> UnPackSizePrefixedScalarStuff(
|
||||
const void *buf,
|
||||
const ::flatbuffers::resolver_function_t *res = nullptr) {
|
||||
return std::unique_ptr<optional_scalars::ScalarStuffT>(GetSizePrefixedScalarStuff(buf)->UnPack(res));
|
||||
}
|
||||
|
||||
} // namespace optional_scalars
|
||||
|
||||
#endif // FLATBUFFERS_GENERATED_OPTIONALSCALARS_OPTIONAL_SCALARS_H_
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "flatbuffers/idl.h"
|
||||
#include "optional_scalars.fbs.h"
|
||||
#include "optional_scalars_generated.h"
|
||||
#include "test_assert.h"
|
||||
|
||||
namespace flatbuffers {
|
||||
|
||||
@@ -2200,27 +2200,18 @@ def make_monster_from_generated_code(
|
||||
test2 = b.CreateString('test2')
|
||||
fred = b.CreateString('Fred')
|
||||
|
||||
_MONSTER.MonsterStartInventoryVector(b, 5)
|
||||
b.PrependByte(4)
|
||||
b.PrependByte(3)
|
||||
b.PrependByte(2)
|
||||
b.PrependByte(1)
|
||||
b.PrependByte(0)
|
||||
inv = b.EndVector()
|
||||
inv = _MONSTER.MonsterCreateInventoryVector(b, range(5))
|
||||
|
||||
_MONSTER.MonsterStart(b)
|
||||
_MONSTER.MonsterAddName(b, fred)
|
||||
mon2 = _MONSTER.MonsterEnd(b)
|
||||
|
||||
_MONSTER.MonsterStartTest4Vector(b, 2)
|
||||
_TEST.CreateTest(b, 10, 20)
|
||||
_TEST.CreateTest(b, 30, 40)
|
||||
test4 = b.EndVector()
|
||||
test4_structs = (_TEST.TestT(10, 20), _TEST.TestT(30, 40))
|
||||
test4 = _MONSTER.MonsterCreateTest4Vector(b, test4_structs)
|
||||
|
||||
_MONSTER.MonsterStartTestarrayofstringVector(b, 2)
|
||||
b.PrependUOffsetTRelative(test2)
|
||||
b.PrependUOffsetTRelative(test1)
|
||||
testArrayOfString = b.EndVector()
|
||||
testArrayOfString = _MONSTER.MonsterCreateTestarrayofstringVector(
|
||||
b, [test1, test2]
|
||||
)
|
||||
|
||||
_MONSTER.MonsterStartVectorOfLongsVector(b, 5)
|
||||
b.PrependInt64(100000000)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "monster_test.h"
|
||||
#include "monster_test_generated.h"
|
||||
#include "test_assert.h"
|
||||
#include "tests/arrays_test.fbs.h"
|
||||
#include "tests/arrays_test_generated.h"
|
||||
|
||||
namespace flatbuffers {
|
||||
namespace tests {
|
||||
|
||||
@@ -30,14 +30,6 @@ static A: TrackingAllocator = TrackingAllocator;
|
||||
// import the flatbuffers generated code:
|
||||
extern crate flatbuffers;
|
||||
|
||||
#[allow(dead_code, unused_imports, clippy::all)]
|
||||
#[path = "../../include_test1/mod.rs"]
|
||||
pub mod include_test1_generated;
|
||||
|
||||
#[allow(dead_code, unused_imports, clippy::all)]
|
||||
#[path = "../../include_test2/mod.rs"]
|
||||
pub mod include_test2_generated;
|
||||
|
||||
#[allow(dead_code, unused_imports, clippy::all)]
|
||||
#[path = "../../monster_test/mod.rs"]
|
||||
mod monster_test_generated;
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
#![allow(clippy::derivable_impls, clippy::all)]
|
||||
extern crate flatbuffers;
|
||||
|
||||
#[allow(dead_code, unused_imports)]
|
||||
#[path = "../../include_test1/mod.rs"]
|
||||
pub mod include_test1_generated;
|
||||
|
||||
#[allow(dead_code, unused_imports)]
|
||||
#[path = "../../include_test2/mod.rs"]
|
||||
pub mod include_test2_generated;
|
||||
|
||||
#[allow(dead_code, unused_imports, clippy::approx_constant)]
|
||||
#[path = "../../monster_test/mod.rs"]
|
||||
mod monster_test_generated;
|
||||
|
||||
15
tests/rust_usage_test/tests/include_test.rs
Normal file
15
tests/rust_usage_test/tests/include_test.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
#[allow(dead_code, unused_imports, clippy::all)]
|
||||
#[path = "../../include_test1/mod.rs"]
|
||||
mod include_test1_generated;
|
||||
|
||||
#[allow(dead_code, unused_imports, clippy::all)]
|
||||
#[path = "../../include_test2/mod.rs"]
|
||||
mod include_test2_generated;
|
||||
|
||||
#[allow(dead_code, unused_imports, clippy::all)]
|
||||
#[path = "../../include_test1_generated.rs"]
|
||||
mod include_test1_standalone;
|
||||
|
||||
#[allow(dead_code, unused_imports, clippy::all)]
|
||||
#[path = "../../include_test2_generated.rs"]
|
||||
mod include_test2_standalone;
|
||||
@@ -48,14 +48,6 @@ mod flexbuffers_tests;
|
||||
mod more_defaults_test;
|
||||
mod optional_scalars_test;
|
||||
|
||||
#[allow(dead_code, unused_imports, clippy::all)]
|
||||
#[path = "../../include_test1/mod.rs"]
|
||||
pub mod include_test1_generated;
|
||||
|
||||
#[allow(dead_code, unused_imports, clippy::all)]
|
||||
#[path = "../../include_test2/mod.rs"]
|
||||
pub mod include_test2_generated;
|
||||
|
||||
#[allow(dead_code, unused_imports, clippy::all)]
|
||||
#[path = "../../namespace_test/mod.rs"]
|
||||
pub mod namespace_test_generated;
|
||||
|
||||
164
tests/rust_usage_test/tests/vtable_zeroed_test.rs
Normal file
164
tests/rust_usage_test/tests/vtable_zeroed_test.rs
Normal file
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* Copyright 2024 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
//! Regression test for https://github.com/google/flatbuffers/issues/8894
|
||||
//!
|
||||
//! Tests that vtable memory is properly zeroed when building FlatBuffers.
|
||||
|
||||
extern crate alloc;
|
||||
extern crate flatbuffers;
|
||||
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
use core::convert::Infallible;
|
||||
use core::cmp::max;
|
||||
use core::ops::{Deref, DerefMut};
|
||||
use core::ptr::write_bytes;
|
||||
|
||||
use flatbuffers::{Allocator, FlatBufferBuilder};
|
||||
|
||||
/// Custom allocator that pre-fills buffer with garbage (0xAA) to detect
|
||||
/// uninitialized memory bugs.
|
||||
struct GarbageFilledAllocator(Vec<u8>);
|
||||
|
||||
impl GarbageFilledAllocator {
|
||||
fn new(size: usize) -> Self {
|
||||
Self(vec![0xAA; size])
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for GarbageFilledAllocator {
|
||||
type Target = [u8];
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for GarbageFilledAllocator {
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
&mut self.0
|
||||
}
|
||||
}
|
||||
|
||||
// SAFETY: grow_downwards properly moves data and the new space is filled with garbage
|
||||
// (intentionally, to detect bugs where code assumes zeroed memory)
|
||||
unsafe impl Allocator for GarbageFilledAllocator {
|
||||
type Error = Infallible;
|
||||
|
||||
fn grow_downwards(&mut self) -> Result<(), Self::Error> {
|
||||
let old_len = self.0.len();
|
||||
let new_len = max(1, old_len * 2);
|
||||
|
||||
// Resize and fill new space with garbage
|
||||
self.0.resize(new_len, 0xAA);
|
||||
|
||||
if new_len == 1 {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// Move old data to the end
|
||||
let middle = new_len / 2;
|
||||
{
|
||||
let (left, right) = &mut self.0[..].split_at_mut(middle);
|
||||
right.copy_from_slice(left);
|
||||
}
|
||||
// Fill old space with garbage (NOT zeros)
|
||||
{
|
||||
let ptr = self.0[..middle].as_mut_ptr();
|
||||
unsafe {
|
||||
write_bytes(ptr, 0xAA, middle);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn len(&self) -> usize {
|
||||
self.0.len()
|
||||
}
|
||||
}
|
||||
|
||||
/// Regression test for https://github.com/google/flatbuffers/issues/8894
|
||||
///
|
||||
/// The bug: write_vtable() called make_space() which only reserves memory
|
||||
/// but doesn't zero it. If the allocator's buffer contains garbage data,
|
||||
/// vtable entries for fields with default values would contain garbage
|
||||
/// instead of zero (which indicates "use default").
|
||||
///
|
||||
/// This test uses a garbage-filled allocator to detect if vtable memory
|
||||
/// is properly zeroed before being written.
|
||||
#[test]
|
||||
fn test_vtable_zeroed_with_garbage_allocator() {
|
||||
// Create a builder with garbage-filled allocator
|
||||
let allocator = GarbageFilledAllocator::new(256);
|
||||
let mut builder: FlatBufferBuilder<GarbageFilledAllocator> =
|
||||
FlatBufferBuilder::new_in(allocator);
|
||||
|
||||
// Start a table
|
||||
let table_start = builder.start_table();
|
||||
|
||||
// Set a field at a HIGH slot ID (14) to force a larger vtable.
|
||||
// This leaves slots 4, 6, 8, 10, 12 unset (should be zero).
|
||||
// VTable layout: [vtable_size:2][table_size:2][field0:2][field1:2][field2:2][field3:2][field4:2][field5:2]
|
||||
// Offsets: 0 2 4 6 8 10 12 14
|
||||
builder.push_slot::<u32>(14, 42, 0); // Set field 5 (at vtable offset 14) to 42
|
||||
|
||||
// End the table - this calls write_vtable()
|
||||
let table_end = builder.end_table(table_start);
|
||||
|
||||
// Finish the buffer
|
||||
builder.finish(table_end, None);
|
||||
|
||||
let data = builder.finished_data();
|
||||
|
||||
// Read the root table offset (first 4 bytes, little-endian)
|
||||
let root_offset = u32::from_le_bytes([data[0], data[1], data[2], data[3]]) as usize;
|
||||
let table_pos = root_offset;
|
||||
|
||||
// Read the vtable offset (signed, at table position)
|
||||
let vtable_offset = i32::from_le_bytes([
|
||||
data[table_pos],
|
||||
data[table_pos + 1],
|
||||
data[table_pos + 2],
|
||||
data[table_pos + 3],
|
||||
]);
|
||||
let vtable_pos = (table_pos as i32 - vtable_offset) as usize;
|
||||
|
||||
// Read vtable size (first 2 bytes of vtable)
|
||||
let vtable_size = u16::from_le_bytes([data[vtable_pos], data[vtable_pos + 1]]) as usize;
|
||||
|
||||
// Verify vtable structure is as expected (16 bytes total for 6 fields + header)
|
||||
assert_eq!(
|
||||
vtable_size, 16,
|
||||
"VTable should be 16 bytes (4 header + 6*2 fields)"
|
||||
);
|
||||
|
||||
// Check that unset fields (at offsets 4, 6, 8, 10, 12) are zero.
|
||||
// Only field at offset 14 was set.
|
||||
// If the bug exists, unset fields would be 0xAAAA instead of 0.
|
||||
for i in [4_usize, 6, 8, 10, 12] {
|
||||
let field_offset = u16::from_le_bytes([data[vtable_pos + i], data[vtable_pos + i + 1]]);
|
||||
assert_eq!(
|
||||
field_offset, 0,
|
||||
"Vtable entry at offset {} should be 0 (default), but was 0x{:04X}. \
|
||||
This indicates uninitialized vtable memory (issue #8894).",
|
||||
i, field_offset
|
||||
);
|
||||
}
|
||||
|
||||
// Verify the field we DID set has a non-zero offset
|
||||
let field5_offset = u16::from_le_bytes([data[vtable_pos + 14], data[vtable_pos + 14 + 1]]);
|
||||
assert_ne!(field5_offset, 0, "Field 5 should have a non-zero offset");
|
||||
}
|
||||
@@ -2,61 +2,56 @@
|
||||
|
||||
# namespace: example
|
||||
|
||||
from typing import Any
|
||||
import flatbuffers
|
||||
|
||||
|
||||
class HelloRequest(object):
|
||||
__slots__ = ['_tab']
|
||||
__slots__ = ['_tab']
|
||||
|
||||
@classmethod
|
||||
def GetRootAs(cls, buf, offset: int = 0):
|
||||
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
|
||||
x = HelloRequest()
|
||||
x.Init(buf, n + offset)
|
||||
return x
|
||||
@classmethod
|
||||
def GetRootAs(cls, buf, offset=0):
|
||||
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
|
||||
x = HelloRequest()
|
||||
x.Init(buf, n + offset)
|
||||
return x
|
||||
|
||||
@classmethod
|
||||
def GetRootAsHelloRequest(cls, buf, offset=0):
|
||||
"""This method is deprecated. Please switch to GetRootAs."""
|
||||
return cls.GetRootAs(buf, offset)
|
||||
@classmethod
|
||||
def GetRootAsHelloRequest(cls, buf, offset=0):
|
||||
"""This method is deprecated. Please switch to GetRootAs."""
|
||||
return cls.GetRootAs(buf, offset)
|
||||
# HelloRequest
|
||||
def Init(self, buf, pos):
|
||||
self._tab = flatbuffers.table.Table(buf, pos)
|
||||
|
||||
# HelloRequest
|
||||
def Init(self, buf: bytes, pos: int):
|
||||
self._tab = flatbuffers.table.Table(buf, pos)
|
||||
def HelloRequestStart(builder):
|
||||
builder.StartObject(0)
|
||||
|
||||
def HelloRequestEnd(builder):
|
||||
return builder.EndObject()
|
||||
|
||||
def HelloRequestStart(builder: flatbuffers.Builder):
|
||||
builder.StartObject(0)
|
||||
|
||||
|
||||
def HelloRequestEnd(builder: flatbuffers.Builder) -> int:
|
||||
return builder.EndObject()
|
||||
|
||||
|
||||
class HelloResponse(object):
|
||||
__slots__ = ['_tab']
|
||||
__slots__ = ['_tab']
|
||||
|
||||
@classmethod
|
||||
def GetRootAs(cls, buf, offset: int = 0):
|
||||
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
|
||||
x = HelloResponse()
|
||||
x.Init(buf, n + offset)
|
||||
return x
|
||||
@classmethod
|
||||
def GetRootAs(cls, buf, offset=0):
|
||||
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
|
||||
x = HelloResponse()
|
||||
x.Init(buf, n + offset)
|
||||
return x
|
||||
|
||||
@classmethod
|
||||
def GetRootAsHelloResponse(cls, buf, offset=0):
|
||||
"""This method is deprecated. Please switch to GetRootAs."""
|
||||
return cls.GetRootAs(buf, offset)
|
||||
@classmethod
|
||||
def GetRootAsHelloResponse(cls, buf, offset=0):
|
||||
"""This method is deprecated. Please switch to GetRootAs."""
|
||||
return cls.GetRootAs(buf, offset)
|
||||
# HelloResponse
|
||||
def Init(self, buf, pos):
|
||||
self._tab = flatbuffers.table.Table(buf, pos)
|
||||
|
||||
# HelloResponse
|
||||
def Init(self, buf: bytes, pos: int):
|
||||
self._tab = flatbuffers.table.Table(buf, pos)
|
||||
def HelloResponseStart(builder):
|
||||
builder.StartObject(0)
|
||||
|
||||
def HelloResponseEnd(builder):
|
||||
return builder.EndObject()
|
||||
|
||||
|
||||
def HelloResponseStart(builder: flatbuffers.Builder):
|
||||
builder.StartObject(0)
|
||||
|
||||
|
||||
def HelloResponseEnd(builder: flatbuffers.Builder) -> int:
|
||||
return builder.EndObject()
|
||||
|
||||
117
tests/test.cpp
117
tests/test.cpp
@@ -47,15 +47,15 @@
|
||||
#include "key_field_test.h"
|
||||
#include "monster_test.h"
|
||||
#include "monster_test_generated.h"
|
||||
#include "native_inline_table_test.fbs.h"
|
||||
#include "native_inline_table_test_generated.h"
|
||||
#include "optional_scalars_test.h"
|
||||
#include "parser_test.h"
|
||||
#include "proto_test.h"
|
||||
#include "reflection_test.h"
|
||||
#include "tests/union_vector/union_vector.fbs.h"
|
||||
#include "union_underlying_type_test.fbs.h"
|
||||
#include "tests/union_vector/union_vector_generated.h"
|
||||
#include "union_underlying_type_test_generated.h"
|
||||
#if !defined(_MSC_VER) || _MSC_VER >= 1700
|
||||
#include "tests/arrays_test.fbs.h"
|
||||
#include "tests/arrays_test_generated.h"
|
||||
#endif
|
||||
#if INCLUDE_64_BIT_TESTS
|
||||
#include "tests/64bit/offset64_test.h"
|
||||
@@ -63,7 +63,9 @@
|
||||
#include "flexbuffers_test.h"
|
||||
#include "is_quiet_nan.h"
|
||||
#include "monster_test_bfbs_generated.h" // Generated using --bfbs-comments --bfbs-builtins --cpp --bfbs-gen-embed
|
||||
#include "native_type_test.fbs.h"
|
||||
#include "cpp_vec_type_test_generated.h"
|
||||
#include "native_type_test_generated.h"
|
||||
#include "cpp_vec_type_native_type_test_generated.h"
|
||||
#include "test_assert.h"
|
||||
#include "util_test.h"
|
||||
#include "vector_table_naked_ptr_test.h"
|
||||
@@ -929,6 +931,12 @@ void NativeTypeTest() {
|
||||
Native::Vector3D(20 * i + 0.1f, 20 * i + 0.2f, 20 * i + 0.3f));
|
||||
}
|
||||
|
||||
src_data.simple_position = Native::Vector3D(7.0f, 8.0f, 9.0f);
|
||||
for (int i = 0; i < N; ++i) {
|
||||
src_data.simple_vectors.push_back(
|
||||
Native::Vector3D(30 * i + 0.1f, 30 * i + 0.2f, 30 * i + 0.3f));
|
||||
}
|
||||
|
||||
src_data.matrix = std::unique_ptr<Native::Matrix>(new Native::Matrix(1, 2));
|
||||
src_data.matrix->values = {3, 4};
|
||||
|
||||
@@ -963,6 +971,17 @@ void NativeTypeTest() {
|
||||
TEST_EQ(v2.z, 20 * i + 0.3f);
|
||||
}
|
||||
|
||||
TEST_EQ(dstDataT->simple_position.x, 7.0f);
|
||||
TEST_EQ(dstDataT->simple_position.y, 8.0f);
|
||||
TEST_EQ(dstDataT->simple_position.z, 9.0f);
|
||||
|
||||
for (int i = 0; i < N; ++i) {
|
||||
const Native::Vector3D& sv = dstDataT->simple_vectors[i];
|
||||
TEST_EQ(sv.x, 30 * i + 0.1f);
|
||||
TEST_EQ(sv.y, 30 * i + 0.2f);
|
||||
TEST_EQ(sv.z, 30 * i + 0.3f);
|
||||
}
|
||||
|
||||
TEST_EQ(dstDataT->matrix->rows, 1);
|
||||
TEST_EQ(dstDataT->matrix->columns, 2);
|
||||
TEST_EQ(dstDataT->matrix->values[0], 3);
|
||||
@@ -978,6 +997,92 @@ void NativeTypeTest() {
|
||||
}
|
||||
}
|
||||
|
||||
void CppVecTypeTest() {
|
||||
static_assert(
|
||||
std::is_same<decltype(CppVecTest::DataT{}.values),
|
||||
CppVecTest::CustomVec<int32_t>>::value,
|
||||
"values should be CustomVec<int32_t>");
|
||||
static_assert(
|
||||
std::is_same<decltype(CppVecTest::DataT{}.regular),
|
||||
std::vector<int32_t>>::value,
|
||||
"regular should be std::vector<int32_t>");
|
||||
|
||||
CppVecTest::DataT src;
|
||||
src.values.push_back(10);
|
||||
src.values.push_back(20);
|
||||
src.values.push_back(30);
|
||||
|
||||
auto item = flatbuffers::unique_ptr<CppVecTest::ItemT>(new CppVecTest::ItemT());
|
||||
item->id = 42;
|
||||
item->value = 1.5f;
|
||||
src.items.push_back(std::move(item));
|
||||
|
||||
src.strs.push_back("hello");
|
||||
src.strs.push_back("world");
|
||||
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
fbb.Finish(CppVecTest::Data::Pack(fbb, &src));
|
||||
|
||||
auto dst = CppVecTest::UnPackData(fbb.GetBufferPointer());
|
||||
|
||||
TEST_EQ(dst->values.size(), 3U);
|
||||
TEST_EQ(dst->values[0], 10);
|
||||
TEST_EQ(dst->values[1], 20);
|
||||
TEST_EQ(dst->values[2], 30);
|
||||
|
||||
TEST_EQ(dst->items.size(), 1U);
|
||||
TEST_EQ(dst->items[0]->id, 42);
|
||||
TEST_EQ(dst->items[0]->value, 1.5f);
|
||||
|
||||
TEST_EQ(dst->strs.size(), 2U);
|
||||
TEST_EQ(dst->strs[0], std::string("hello"));
|
||||
TEST_EQ(dst->strs[1], std::string("world"));
|
||||
|
||||
TEST_EQ(dst->regular.size(), 0U);
|
||||
TEST_ASSERT(*dst == *dst);
|
||||
}
|
||||
|
||||
void CppVecTypeNativeTypeTest() {
|
||||
// Verify that combining cpp_vec_type + native_type on a vector of structs
|
||||
// produces the correct container type in the NativeTable.
|
||||
static_assert(
|
||||
std::is_same<
|
||||
decltype(CppVecNativeTypeTest::ContainerT{}.points),
|
||||
CppVecNativeTypeTest::CustomVec<
|
||||
CppVecNativeTypeTest::Native::Vec3>>::value,
|
||||
"points should be CustomVec<Native::Vec3>");
|
||||
static_assert(
|
||||
std::is_same<decltype(CppVecNativeTypeTest::ContainerT{}.bytes),
|
||||
CppVecNativeTypeTest::CustomVec<uint8_t>>::value,
|
||||
"bytes should be CustomVec<uint8_t>");
|
||||
|
||||
const int N = 3;
|
||||
CppVecNativeTypeTest::ContainerT src;
|
||||
for (int i = 0; i < N; ++i) {
|
||||
src.points.push_back(
|
||||
CppVecNativeTypeTest::Native::Vec3(1.0f * i, 2.0f * i, 3.0f * i));
|
||||
src.bytes.push_back(static_cast<uint8_t>(i * 10));
|
||||
}
|
||||
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
fbb.Finish(CppVecNativeTypeTest::Container::Pack(fbb, &src));
|
||||
|
||||
auto dst =
|
||||
CppVecNativeTypeTest::UnPackContainer(fbb.GetBufferPointer());
|
||||
|
||||
TEST_EQ(dst->points.size(), static_cast<size_t>(N));
|
||||
for (int i = 0; i < N; ++i) {
|
||||
TEST_EQ(dst->points[i].x, 1.0f * i);
|
||||
TEST_EQ(dst->points[i].y, 2.0f * i);
|
||||
TEST_EQ(dst->points[i].z, 3.0f * i);
|
||||
}
|
||||
|
||||
TEST_EQ(dst->bytes.size(), static_cast<size_t>(N));
|
||||
for (int i = 0; i < N; ++i) {
|
||||
TEST_EQ(dst->bytes[i], static_cast<uint8_t>(i * 10));
|
||||
}
|
||||
}
|
||||
|
||||
// Guard against -Wunused-function on platforms without file tests.
|
||||
#ifndef FLATBUFFERS_NO_FILE_TESTS
|
||||
// VS10 does not support typed enums, exclude from tests
|
||||
@@ -1813,6 +1918,8 @@ int FlatBufferTests(const std::string& tests_data_path) {
|
||||
InvalidFloatTest();
|
||||
FixedLengthArrayTest();
|
||||
NativeTypeTest();
|
||||
CppVecTypeTest();
|
||||
CppVecTypeNativeTypeTest();
|
||||
OptionalScalarsTest();
|
||||
ParseFlexbuffersFromJsonWithNullTest();
|
||||
FlatbuffersSpanTest();
|
||||
|
||||
60
tests/ts/JavaScriptUndefinedForOptionals.js
Normal file
60
tests/ts/JavaScriptUndefinedForOptionals.js
Normal file
@@ -0,0 +1,60 @@
|
||||
import assert from 'assert'
|
||||
import * as flatbuffers from 'flatbuffers'
|
||||
|
||||
import optional_scalars from './ts-undefined-for-optionals/optional_scalars_generated.cjs'
|
||||
|
||||
const { ScalarStuff, ScalarStuffT } = optional_scalars.optional_scalars;
|
||||
|
||||
function testScalarStuffBuf(scalarStuff) {
|
||||
assert.strictEqual(scalarStuff.justI8(), -1);
|
||||
assert.strictEqual(scalarStuff.maybeI8(), undefined);
|
||||
assert.strictEqual(scalarStuff.defaultI8(), 42);
|
||||
assert.strictEqual(scalarStuff.justU8(), 1);
|
||||
assert.strictEqual(scalarStuff.maybeU8(), undefined);
|
||||
assert.strictEqual(scalarStuff.defaultU8(), 42);
|
||||
}
|
||||
|
||||
function testScalarStuffUnpack(scalarStuff) {
|
||||
assert.strictEqual(scalarStuff.justI8, -1);
|
||||
assert.strictEqual(scalarStuff.maybeI8, undefined);
|
||||
assert.strictEqual(scalarStuff.defaultI8, 42);
|
||||
assert.strictEqual(scalarStuff.justU8, 1);
|
||||
assert.strictEqual(scalarStuff.maybeU8, undefined);
|
||||
assert.strictEqual(scalarStuff.defaultU8, 42);
|
||||
}
|
||||
|
||||
function createScalarStuff(fbb) {
|
||||
ScalarStuff.startScalarStuff(fbb);
|
||||
ScalarStuff.addJustI8(fbb, -1);
|
||||
ScalarStuff.addJustU8(fbb, 1);
|
||||
var offset = ScalarStuff.endScalarStuff(fbb);
|
||||
ScalarStuff.finishScalarStuffBuffer(fbb, offset);
|
||||
}
|
||||
|
||||
function main() {
|
||||
var fbb = new flatbuffers.Builder();
|
||||
|
||||
createScalarStuff(fbb);
|
||||
|
||||
var buf = new flatbuffers.ByteBuffer(fbb.asUint8Array());
|
||||
var scalarStuff = ScalarStuff.getRootAsScalarStuff(buf);
|
||||
|
||||
testScalarStuffBuf(scalarStuff);
|
||||
|
||||
testScalarStuffUnpack(scalarStuff.unpack());
|
||||
|
||||
var scalarStuff_to = new ScalarStuffT();
|
||||
scalarStuff.unpackTo(scalarStuff_to);
|
||||
|
||||
testScalarStuffUnpack(scalarStuff_to);
|
||||
|
||||
fbb.clear();
|
||||
ScalarStuff.finishScalarStuffBuffer(fbb, scalarStuff_to.pack(fbb));
|
||||
var unpackBuf = new flatbuffers.ByteBuffer(fbb.asUint8Array());
|
||||
|
||||
testScalarStuffBuf(ScalarStuff.getRootAsScalarStuff(unpackBuf));
|
||||
|
||||
console.log('FlatBuffers --ts-undefined-for-optionals test: completed successfully');
|
||||
}
|
||||
|
||||
main();
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user