forked from BigfootDev/flatbuffers
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a37f22f47 |
@@ -1,6 +0,0 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
@@ -197,7 +197,8 @@ jobs:
|
||||
configuration: [
|
||||
'',
|
||||
'-p:UnsafeByteBuffer=true',
|
||||
'-p:EnableSpanT=true,UnsafeByteBuffer=true'
|
||||
# Fails two tests currently.
|
||||
#'-p:EnableSpanT=true,UnsafeByteBuffer=true'
|
||||
]
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
@@ -208,7 +209,7 @@ jobs:
|
||||
- name: Build
|
||||
run: |
|
||||
cd tests\FlatBuffers.Test
|
||||
dotnet new sln --force --name FlatBuffers.Test --format sln
|
||||
dotnet new sln --force --name FlatBuffers.Test
|
||||
dotnet sln FlatBuffers.Test.sln add FlatBuffers.Test.csproj
|
||||
dotnet build -c Release ${{matrix.configuration}} FlatBuffers.Test.sln
|
||||
- name: Run net6.0
|
||||
@@ -591,16 +592,11 @@ 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
|
||||
|
||||
+24
-16
@@ -238,15 +238,8 @@ set(FlatBuffers_Tests_SRCS
|
||||
tests/util_test.cpp
|
||||
tests/vector_table_naked_ptr_test.h
|
||||
tests/vector_table_naked_ptr_test.cpp
|
||||
tests/test_vector_type.h
|
||||
tests/cpp_vector_type_test.h
|
||||
tests/cpp_vector_type_test.cpp
|
||||
tests/native_type_test_impl.h
|
||||
tests/native_type_test_impl.cpp
|
||||
tests/bigfoot_ref_test_impl.h
|
||||
tests/bigfoot_ref_test_impl.cpp
|
||||
tests/required_table_default_test.h
|
||||
tests/required_table_default_test.cpp
|
||||
tests/alignment_test.h
|
||||
tests/alignment_test.cpp
|
||||
tests/64bit/offset64_test.h
|
||||
@@ -522,13 +515,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}" "_generated" GEN_FILE)
|
||||
compile_schema("${SRC_FBS}" "${OPT}" ".fbs" GEN_FILE)
|
||||
target_sources(flattests PRIVATE ${GEN_FILE})
|
||||
endfunction()
|
||||
|
||||
function(compile_schema_for_test_fbsh SRC_FBS OPT)
|
||||
function(compile_schema_for_test_17 SRC_FBS OPT)
|
||||
compile_schema("${SRC_FBS}" "${OPT}" ".fbs" GEN_FILE)
|
||||
target_sources(flattests PRIVATE ${GEN_FILE})
|
||||
target_sources(flattests_cpp17 PRIVATE ${GEN_FILE})
|
||||
endfunction()
|
||||
|
||||
function(compile_schema_for_samples SRC_FBS OPT)
|
||||
@@ -555,21 +548,26 @@ 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_CPP_VECTOR_TYPE ${FLATC_OPT_COMP};--cpp-include;test_vector_type.h;--cpp-vector-type;::flatbuffers::tests::CustomVector)
|
||||
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_fbsh(tests/default_vectors_strings_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(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/bigfoot_ref_test.fbs "${FLATC_OPT_COMP}")
|
||||
compile_schema_for_test(tests/required_table_default_test.fbs "${FLATC_OPT_COMP}")
|
||||
compile_schema_for_test(tests/optional_scalars.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/cpp_vector_type.fbs "${FLATC_OPT_CPP_VECTOR_TYPE}")
|
||||
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})
|
||||
@@ -599,9 +597,19 @@ 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 src tests)
|
||||
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_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()
|
||||
|
||||
+3
-4
@@ -7,7 +7,7 @@ module(
|
||||
|
||||
bazel_dep(
|
||||
name = "aspect_bazel_lib",
|
||||
version = "2.14.0",
|
||||
version = "2.11.0",
|
||||
)
|
||||
bazel_dep(
|
||||
name = "aspect_rules_esbuild",
|
||||
@@ -28,11 +28,11 @@ bazel_dep(
|
||||
)
|
||||
bazel_dep(
|
||||
name = "platforms",
|
||||
version = "0.0.11",
|
||||
version = "0.0.10",
|
||||
)
|
||||
bazel_dep(
|
||||
name = "rules_cc",
|
||||
version = "0.1.1",
|
||||
version = "0.0.16",
|
||||
)
|
||||
bazel_dep(
|
||||
name = "rules_go",
|
||||
@@ -50,7 +50,6 @@ bazel_dep(
|
||||
bazel_dep(
|
||||
name = "rules_swift",
|
||||
version = "2.1.1",
|
||||
max_compatibility_level = 3,
|
||||
repo_name = "build_bazel_rules_swift",
|
||||
)
|
||||
bazel_dep(
|
||||
|
||||
@@ -1,174 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import Benchmark
|
||||
import FlexBuffers
|
||||
import Foundation
|
||||
|
||||
let benchmarks = {
|
||||
let data = {
|
||||
var array = [8888.88, 8888.88]
|
||||
var data = Data()
|
||||
array.withUnsafeBytes { ptr in
|
||||
data.append(contentsOf: ptr)
|
||||
}
|
||||
return data
|
||||
}()
|
||||
let ints: [Int32] = Array(repeating: 42, count: 100)
|
||||
let str10 = (0...9).map { _ -> String in "x" }.joined()
|
||||
let str100 = (0...99).map { _ -> String in "x" }.joined()
|
||||
|
||||
// A representative map: 50 keyed scalars, a keyed string and a keyed vector
|
||||
// of 100 scalars. Used for the realistic decode benchmarks.
|
||||
let mapBuffer: ByteBuffer = {
|
||||
var fbx = FlexBuffersWriter(initialSize: 1 << 16)
|
||||
fbx.map {
|
||||
for i in 0..<50 { $0.add(int: i, key: "i\(i)") }
|
||||
$0.add(string: "hello world", key: "s")
|
||||
$0.vector(key: "v") { v in
|
||||
for x in 0..<100 { v.add(int: x) }
|
||||
}
|
||||
}
|
||||
fbx.finish()
|
||||
return fbx.sizedByteBuffer
|
||||
}()
|
||||
|
||||
let metrics: [BenchmarkMetric] = [
|
||||
.cpuTotal,
|
||||
.wallClock,
|
||||
.mallocCountTotal,
|
||||
.releaseCount,
|
||||
.peakMemoryResident,
|
||||
]
|
||||
let maxIterations = 1_000_000
|
||||
let maxDuration: Duration = .seconds(3)
|
||||
let megaConfiguration: Benchmark.Configuration = .init(
|
||||
metrics: metrics,
|
||||
warmupIterations: 1,
|
||||
scalingFactor: .mega,
|
||||
maxDuration: maxDuration,
|
||||
maxIterations: maxIterations)
|
||||
|
||||
Benchmark.defaultConfiguration = megaConfiguration
|
||||
|
||||
// Decode (read path)
|
||||
|
||||
// Raw scalar read: isolates `read<T: BitwiseCopyable>` and the `let` blob.
|
||||
Benchmark("Reading Doubles") { benchmark in
|
||||
let byteBuffer = ByteBuffer(data: data)
|
||||
benchmark.startMeasurement()
|
||||
for _ in benchmark.scaledIterations {
|
||||
blackHole(byteBuffer.read(def: Double.self, position: 0))
|
||||
}
|
||||
benchmark.stopMeasurement()
|
||||
}
|
||||
|
||||
// Realistic decode: resolve root map and read a keyed scalar.
|
||||
Benchmark("Decode Map Scalar") { benchmark in
|
||||
benchmark.startMeasurement()
|
||||
for _ in benchmark.scaledIterations {
|
||||
let map = try! getRoot(buffer: mapBuffer)!.map!
|
||||
blackHole(map["i25"]?.int)
|
||||
}
|
||||
benchmark.stopMeasurement()
|
||||
}
|
||||
|
||||
// Realistic decode: resolve root map and read a keyed string.
|
||||
Benchmark("Decode Map String") { benchmark in
|
||||
benchmark.startMeasurement()
|
||||
for _ in benchmark.scaledIterations {
|
||||
let map = try! getRoot(buffer: mapBuffer)!.map!
|
||||
blackHole(map["s"]?.string())
|
||||
}
|
||||
benchmark.stopMeasurement()
|
||||
}
|
||||
|
||||
// Realistic decode: resolve a nested vector and sum its scalars.
|
||||
Benchmark("Decode Vector") { benchmark in
|
||||
benchmark.startMeasurement()
|
||||
for _ in benchmark.scaledIterations {
|
||||
let map = try! getRoot(buffer: mapBuffer)!.map!
|
||||
let vector = map["v"]!.vector!
|
||||
var sum: Int64 = 0
|
||||
for i in 0..<vector.count {
|
||||
sum &+= vector[i]?.int ?? 0
|
||||
}
|
||||
blackHole(sum)
|
||||
}
|
||||
benchmark.stopMeasurement()
|
||||
}
|
||||
|
||||
// Encode (write path)
|
||||
// Writers are reused with `reset(keepingCapacity:)` so per-iteration
|
||||
// allocation does not dominate and mask the write-path cost (which is what
|
||||
// the `@exclusivity(unchecked)` storage pointer affects).
|
||||
|
||||
Benchmark("Strings 10") { benchmark in
|
||||
var fbx = FlexBuffersWriter(initialSize: 1 << 20)
|
||||
benchmark.startMeasurement()
|
||||
for _ in benchmark.scaledIterations {
|
||||
fbx.add(string: str10)
|
||||
fbx.finish()
|
||||
blackHole(fbx.sizedByteBuffer)
|
||||
fbx.reset(keepingCapacity: true)
|
||||
}
|
||||
benchmark.stopMeasurement()
|
||||
}
|
||||
|
||||
Benchmark("Strings 100") { benchmark in
|
||||
var fbx = FlexBuffersWriter(initialSize: 1 << 20)
|
||||
benchmark.startMeasurement()
|
||||
for _ in benchmark.scaledIterations {
|
||||
fbx.add(string: str100)
|
||||
fbx.finish()
|
||||
blackHole(fbx.sizedByteBuffer)
|
||||
fbx.reset(keepingCapacity: true)
|
||||
}
|
||||
benchmark.stopMeasurement()
|
||||
}
|
||||
|
||||
Benchmark("Encoding Vector Of Ints") { benchmark in
|
||||
var fbx = FlexBuffersWriter(initialSize: 1 << 20)
|
||||
benchmark.startMeasurement()
|
||||
for _ in benchmark.scaledIterations {
|
||||
fbx.vector {
|
||||
$0.create(vector: ints)
|
||||
}
|
||||
fbx.finish()
|
||||
blackHole(fbx.sizedByteBuffer)
|
||||
fbx.reset(keepingCapacity: true)
|
||||
}
|
||||
benchmark.stopMeasurement()
|
||||
}
|
||||
|
||||
Benchmark("Encoding Map") { benchmark in
|
||||
var fbx = FlexBuffersWriter(initialSize: 1 << 20)
|
||||
benchmark.startMeasurement()
|
||||
for _ in benchmark.scaledIterations {
|
||||
fbx.map {
|
||||
for i in 0..<50 { $0.add(int: i, key: "i\(i)") }
|
||||
$0.add(string: "hello world", key: "s")
|
||||
$0.vector(key: "v") { v in
|
||||
for x in 0..<100 { v.add(int: x) }
|
||||
}
|
||||
}
|
||||
fbx.finish()
|
||||
blackHole(fbx.sizedByteBuffer)
|
||||
fbx.reset(keepingCapacity: true)
|
||||
}
|
||||
benchmark.stopMeasurement()
|
||||
}
|
||||
}
|
||||
+3
-10
@@ -79,12 +79,11 @@ 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. 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.
|
||||
This will generate a `mydata.json` file.
|
||||
|
||||
|
||||
### Additional options
|
||||
|
||||
@@ -168,12 +167,6 @@ list of `FILES...`.
|
||||
std::string from Flatbuffers, but (char* + length). This allows efficient
|
||||
construction of custom string types, including zero-copy construction.
|
||||
|
||||
- `--cpp-vector-type T` : Set object API vector type (default std::vector).
|
||||
T must be a template taking a single element type argument and support
|
||||
resize(), reserve(), size(), data(), operator[], emplace_back() and
|
||||
begin()/end(), matching the subset of std::vector's interface generated
|
||||
code relies on.
|
||||
|
||||
- `--no-cpp-direct-copy` : Don't generate direct copy methods for C++
|
||||
object-based API.
|
||||
|
||||
|
||||
@@ -242,42 +242,6 @@ provide the following functions to aide in the serialization process:
|
||||
}
|
||||
```
|
||||
|
||||
- `bigfoot_ref_wrapper("type")` (on a struct) together with `bigfoot_ref("type")`
|
||||
(on a field of that struct type): Bigfoot-specific sugar for a
|
||||
UUID-addressed reference to another native type. `bigfoot_ref_wrapper`
|
||||
marks a struct as a reference-wrapper template (e.g. Bigfoot's
|
||||
`HardReference`/`SoftReference`); `bigfoot_ref` on a field of that type
|
||||
names the referenced native type, e.g. `bigfoot_ref: "::Bigfoot::AssetA"`
|
||||
on a `HardReference`-typed field with `bigfoot_ref_wrapper:
|
||||
"::Bigfoot::HardReference"` produces the field's native type
|
||||
`::Bigfoot::HardReference<::Bigfoot::AssetA>` (auto-deriving a
|
||||
`native_type_pack_name` of `HardReferenceAssetA`, same short-name
|
||||
convention as `native_type_pack_name`). Unlike a hand-written
|
||||
`native_type`, `bigfoot_ref` also emits, directly into the generated
|
||||
header:
|
||||
- a forward declaration of the referenced type (so the referencing
|
||||
schema's generated header never needs that type's real definition -
|
||||
only the wrapper template's constructor and a `GetUUID()` accessor
|
||||
are used, and those don't require the referenced type to be
|
||||
complete), and
|
||||
- `inline` `Pack<Name>`/`UnPack<Name>` definitions for it (so no
|
||||
hand-written implementation is required anywhere).
|
||||
|
||||
```cpp
|
||||
struct HardReference (bigfoot_ref_wrapper: "::Bigfoot::HardReference") {
|
||||
uuid: UUID;
|
||||
}
|
||||
|
||||
table AssetB {
|
||||
ref_a: HardReference (bigfoot_ref: "::Bigfoot::AssetA");
|
||||
}
|
||||
```
|
||||
|
||||
is enough on its own - no forward declaration of `::Bigfoot::AssetA` and
|
||||
no `flatbuffers::Pack/UnPackHardReferenceAssetA` implementation need to
|
||||
be written by hand. `bigfoot_ref` is only valid on fields whose type is a
|
||||
struct (or vector of structs) that declares `bigfoot_ref_wrapper`.
|
||||
|
||||
- `native_type("type")` (on a table): Tables can also be represented with
|
||||
native types. For example, the following schema:
|
||||
|
||||
@@ -373,27 +337,6 @@ constructor in the following format: `custom_str_class(const char *, size_t)`.
|
||||
Please note that the character array is not guaranteed to be NULL terminated,
|
||||
you should always use the provided size to determine end of string.
|
||||
|
||||
## Using different vector type
|
||||
|
||||
By default the object tree's vector fields are built out of `std::vector`,
|
||||
but you can influence this either globally (using the `--cpp-vector-type`
|
||||
argument to `flatc`) or per field using the `cpp_vector_type` attribute, to
|
||||
use any other vector-like template type (e.g. `eastl::vector`).
|
||||
|
||||
The type must be a template taking a single element type argument
|
||||
(`my_vector<T>`), and must support the following member functions:
|
||||
`resize()`, `reserve()`, `size()`, `data()`, `operator[]`, `emplace_back()`,
|
||||
and `begin()`/`end()`. This matches the subset of `std::vector`'s interface
|
||||
that generated code relies on.
|
||||
|
||||
Note that unlike `std::vector<bool>`, the custom vector type must not use a
|
||||
bit-packed specialization for `bool` elements, since generated code accesses
|
||||
`data()` as a contiguous `bool` array.
|
||||
|
||||
As with custom string types, the header defining the custom vector type is
|
||||
not automatically included; use `--cpp-include` to add the necessary
|
||||
`#include`.
|
||||
|
||||
## Reflection (& Resizing)
|
||||
|
||||
There is experimental support for reflection in FlatBuffers, allowing you to
|
||||
|
||||
+15
-8
@@ -1134,8 +1134,12 @@ The Builder provides multiple ways to create `vectors`.
|
||||
=== "Python"
|
||||
|
||||
```py
|
||||
# Use the generated helper to create the weapons vector from offsets.
|
||||
weapons = MyGame.Sample.Monster.CreateWeaponsVector(builder, [sword, axe])
|
||||
# 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()
|
||||
```
|
||||
|
||||
=== "Rust"
|
||||
@@ -1348,13 +1352,16 @@ 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.
|
||||
inv = MyGame.Sample.Monster.CreateInventoryVector(builder, range(0, 10))
|
||||
# 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()
|
||||
|
||||
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)
|
||||
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()
|
||||
```
|
||||
|
||||
=== "Rust"
|
||||
|
||||
@@ -80,12 +80,6 @@ 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,16 +1,14 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// @generated
|
||||
|
||||
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)]
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
namespace models;
|
||||
|
||||
table HelloResponse {
|
||||
message:string;
|
||||
}
|
||||
|
||||
table HelloRequest {
|
||||
name:string;
|
||||
}
|
||||
|
||||
rpc_service Greeter {
|
||||
Get(HelloRequest):HelloResponse;
|
||||
Collect(HelloRequest):HelloResponse (streaming: "client");
|
||||
Expand(HelloRequest):HelloResponse (streaming: "server");
|
||||
Update(HelloRequest):HelloResponse (streaming: "bidi");
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import ArgumentParser
|
||||
|
||||
let port = 3000
|
||||
|
||||
@main
|
||||
struct GreeterCommand: AsyncParsableCommand {
|
||||
static let configuration = CommandConfiguration(
|
||||
commandName: "greeter",
|
||||
abstract: "A multi-tool to run an echo server and execute RPCs against it.",
|
||||
subcommands: [ServerCommand.self, ClientCommand.self])
|
||||
}
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import FlatBuffers
|
||||
import GRPCCore
|
||||
import Models
|
||||
|
||||
struct GreeterService: models_Greeter.SimpleServiceProtocol {
|
||||
func Get(
|
||||
request: GRPCMessage<models_HelloResponse>,
|
||||
context: GRPCCore
|
||||
.ServerContext) async throws -> GRPCMessage<models_HelloResponse>
|
||||
{
|
||||
let model = try request.decode()
|
||||
print("## GreeterService.Get: \(model.message)")
|
||||
|
||||
var builder = FlatBufferBuilder(initialSize: 128)
|
||||
let off = builder.create(string: "Hello \(model.message ?? "Unknown")")
|
||||
let root = models_HelloResponse.createHelloResponse(
|
||||
&builder,
|
||||
messageOffset: off)
|
||||
builder.finish(offset: root)
|
||||
return try GRPCMessage<models_HelloResponse>(builder: &builder)
|
||||
}
|
||||
|
||||
func Collect(
|
||||
request: GRPCCore.RPCAsyncSequence<
|
||||
GRPCMessage<models_HelloResponse>,
|
||||
any Swift.Error
|
||||
>,
|
||||
context: GRPCCore
|
||||
.ServerContext) async throws -> GRPCMessage<models_HelloResponse>
|
||||
{
|
||||
let messages: [String] = try await request
|
||||
.reduce(into: []) { array, message in
|
||||
let model = try message.decode()
|
||||
return array.append(model.message ?? "Unknown")
|
||||
}
|
||||
|
||||
let joined = messages.joined(separator: ", ")
|
||||
print("## GreeterService.Collect: \(joined)")
|
||||
|
||||
var builder = FlatBufferBuilder(initialSize: 128)
|
||||
let off = builder.create(string: "Hello \(joined)")
|
||||
let root = models_HelloResponse.createHelloResponse(
|
||||
&builder,
|
||||
messageOffset: off)
|
||||
builder.finish(offset: root)
|
||||
return try GRPCMessage<models_HelloResponse>(builder: &builder)
|
||||
}
|
||||
|
||||
func Expand(
|
||||
request: GRPCMessage<models_HelloResponse>,
|
||||
response: GRPCCore.RPCWriter<GRPCMessage<models_HelloResponse>>,
|
||||
context: GRPCCore.ServerContext) async throws
|
||||
{
|
||||
|
||||
let model = try request.decode()
|
||||
print("## GreeterService.Expand: \(model.message)")
|
||||
|
||||
let message = model.message ?? "Unknown"
|
||||
let stream = AsyncThrowingStream<
|
||||
GRPCMessage<models_HelloResponse>,
|
||||
Error
|
||||
> { continuation in
|
||||
var builder = FlatBufferBuilder(initialSize: 128)
|
||||
for char in message {
|
||||
let off = builder.create(string: "\(char)")
|
||||
let root = models_HelloResponse.createHelloResponse(
|
||||
&builder,
|
||||
messageOffset: off)
|
||||
builder.finish(offset: root)
|
||||
|
||||
do {
|
||||
continuation
|
||||
.yield(try GRPCMessage<models_HelloResponse>(builder: &builder))
|
||||
} catch {
|
||||
continuation.finish(throwing: error)
|
||||
}
|
||||
}
|
||||
|
||||
continuation.finish()
|
||||
}
|
||||
try await response.write(contentsOf: stream)
|
||||
}
|
||||
|
||||
func Update(
|
||||
request: GRPCCore.RPCAsyncSequence<
|
||||
GRPCMessage<models_HelloResponse>,
|
||||
any Swift.Error
|
||||
>,
|
||||
response: GRPCCore.RPCWriter<GRPCMessage<models_HelloResponse>>,
|
||||
context: GRPCCore.ServerContext) async throws
|
||||
{
|
||||
for try await message in request {
|
||||
let model = try message.decode()
|
||||
print("## GreeterService.Update: \(model.message)")
|
||||
var builder = FlatBufferBuilder(initialSize: 128)
|
||||
let off = builder.create(string: "Hello \(model.message ?? "Unknown")")
|
||||
let root = models_HelloResponse.createHelloResponse(
|
||||
&builder,
|
||||
messageOffset: off)
|
||||
builder.finish(offset: root)
|
||||
try await response
|
||||
.write(try GRPCMessage<models_HelloResponse>(builder: &builder))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import ArgumentParser
|
||||
import FlatBuffers
|
||||
import GRPCCore
|
||||
import GRPCNIOTransportHTTP2
|
||||
import Models
|
||||
|
||||
enum ClientRequest: String, ExpressibleByArgument {
|
||||
case get, expand, collect, update
|
||||
}
|
||||
|
||||
struct ClientCommand: AsyncParsableCommand {
|
||||
static let configuration = CommandConfiguration(
|
||||
commandName: "client")
|
||||
|
||||
@Option(help: "Name to send to the server")
|
||||
var name: String
|
||||
|
||||
@Option(help: "request type")
|
||||
var request: ClientRequest
|
||||
|
||||
func run() async throws {
|
||||
try await withGRPCClient(
|
||||
transport: .http2NIOPosix(
|
||||
target: .dns(host: "localhost", port: port),
|
||||
transportSecurity: .plaintext))
|
||||
{
|
||||
let client = models_Greeter.Client(wrapping: $0)
|
||||
|
||||
switch request {
|
||||
case .get: try await get(client: client)
|
||||
case .expand: try await expand(client: client)
|
||||
case .collect: try await collect(client: client)
|
||||
case .update: try await update(client: client)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func get(
|
||||
client: models_Greeter
|
||||
.Client<HTTP2ClientTransport.Posix>) async throws
|
||||
{
|
||||
for _ in 0..<3 {
|
||||
var builder = FlatBufferBuilder(initialSize: 64)
|
||||
let off = builder.create(string: name)
|
||||
let root = models_HelloRequest.createHelloRequest(
|
||||
&builder,
|
||||
nameOffset: off)
|
||||
builder.finish(offset: root)
|
||||
|
||||
let response = try await client
|
||||
.Get(GRPCMessage(builder: &builder))
|
||||
let message = try? response.decode().message
|
||||
print("get message: \(message ?? "nil")")
|
||||
}
|
||||
}
|
||||
|
||||
func expand(
|
||||
client: models_Greeter
|
||||
.Client<HTTP2ClientTransport.Posix>) async throws
|
||||
{
|
||||
for _ in 0..<3 {
|
||||
var builder = FlatBufferBuilder(initialSize: 64)
|
||||
let off = builder.create(string: name)
|
||||
let root = models_HelloRequest.createHelloRequest(
|
||||
&builder,
|
||||
nameOffset: off)
|
||||
builder.finish(offset: root)
|
||||
try await client.Expand(GRPCMessage(builder: &builder)) { response in
|
||||
for try await message in response.messages {
|
||||
let message = try? message.decode().message
|
||||
print("expand message: \(message ?? "nil")")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func collect(
|
||||
client: models_Greeter
|
||||
.Client<HTTP2ClientTransport.Posix>) async throws
|
||||
{
|
||||
for _ in 0..<3 {
|
||||
let response = try await client.Collect { writer in
|
||||
for part in name {
|
||||
print("collect sending: \(part)")
|
||||
var builder = FlatBufferBuilder(initialSize: 64)
|
||||
let off = builder.create(string: String(part))
|
||||
let root = models_HelloRequest.createHelloRequest(
|
||||
&builder,
|
||||
nameOffset: off)
|
||||
builder.finish(offset: root)
|
||||
try await writer.write(GRPCMessage(builder: &builder))
|
||||
}
|
||||
}
|
||||
|
||||
let message = try response.decode().message
|
||||
print("collect message: \(message ?? "nil")")
|
||||
}
|
||||
}
|
||||
|
||||
func update(
|
||||
client: models_Greeter
|
||||
.Client<HTTP2ClientTransport.Posix>) async throws
|
||||
{
|
||||
for _ in 0..<3 {
|
||||
try await client.Update { writer in
|
||||
for part in name {
|
||||
print("update sending: \(part)")
|
||||
var builder = FlatBufferBuilder(initialSize: 64)
|
||||
let off = builder.create(string: String(part))
|
||||
let root = models_HelloRequest.createHelloRequest(
|
||||
&builder,
|
||||
nameOffset: off)
|
||||
builder.finish(offset: root)
|
||||
try await writer.write(GRPCMessage(builder: &builder))
|
||||
}
|
||||
} onResponse: { response in
|
||||
for try await message in response.messages {
|
||||
let message = try message.decode().message
|
||||
print("collect message: \(message ?? "nil")")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import ArgumentParser
|
||||
import GRPCCore
|
||||
import GRPCNIOTransportHTTP2
|
||||
|
||||
struct ServerCommand: AsyncParsableCommand {
|
||||
static let configuration = CommandConfiguration(
|
||||
commandName: "serve")
|
||||
|
||||
func run() async throws {
|
||||
let server = GRPCServer(
|
||||
transport: .http2NIOPosix(
|
||||
address: .ipv4(host: "127.0.0.1", port: port),
|
||||
transportSecurity: .plaintext),
|
||||
services: [GreeterService()])
|
||||
|
||||
try await withThrowingDiscardingTaskGroup { group in
|
||||
group.addTask { try await server.serve() }
|
||||
if let address = try await server.listeningAddress {
|
||||
print("Echo listening on \(address)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,572 +0,0 @@
|
||||
// Generated GRPC code for FlatBuffers swift!
|
||||
/// The following code is generated by the Flatbuffers library which might not be in sync with grpc-swift
|
||||
/// in case of an issue please open github issue, though it would be maintained
|
||||
|
||||
// swiftlint:disable all
|
||||
// swiftformat:disable all
|
||||
|
||||
#if !os(Windows) && compiler(>=6.0)
|
||||
import FlatBuffers
|
||||
import Foundation
|
||||
import GRPCCore
|
||||
import GRPCNIOTransportCore
|
||||
|
||||
|
||||
/// Usage: instantiate models.GreeterServiceClient, then call methods of this protocol to make API calls.
|
||||
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
|
||||
extension FlatBuffersMessageSerializer: MessageSerializer {
|
||||
public func serialize<Bytes>(_ message: Message) throws -> Bytes where Bytes : GRPCCore.GRPCContiguousBytes {
|
||||
do {
|
||||
return try self.serialize(message: message) { GRPCNIOTransportBytes($0) } as! Bytes
|
||||
} catch let error {
|
||||
throw RPCError(
|
||||
code: .invalidArgument,
|
||||
message: "Can't serialize message",
|
||||
cause: error
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
|
||||
extension FlatBuffersMessageDeserializer: MessageDeserializer {
|
||||
public func deserialize<Bytes>(_ serializedMessageBytes: Bytes) throws -> Message where Bytes : GRPCCore.GRPCContiguousBytes {
|
||||
do {
|
||||
return try serializedMessageBytes.withUnsafeBytes {
|
||||
try self.deserialize(pointer: $0)
|
||||
}
|
||||
} catch let error {
|
||||
throw RPCError(
|
||||
code: .invalidArgument,
|
||||
message: "Can't Decode message of type \(Message.self)",
|
||||
cause: error
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
|
||||
public enum models_Greeter: Sendable {
|
||||
public static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "models.Greeter")
|
||||
public enum Method: Sendable {
|
||||
public enum Get: Sendable {
|
||||
public typealias Input = FlatBufferBuilder
|
||||
public typealias Output = models_HelloResponse
|
||||
public static let descriptor = GRPCCore.MethodDescriptor(
|
||||
service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "models.Greeter"),
|
||||
method: "Get"
|
||||
)
|
||||
}
|
||||
public enum Collect: Sendable {
|
||||
public typealias Input = FlatBufferBuilder
|
||||
public typealias Output = models_HelloResponse
|
||||
public static let descriptor = GRPCCore.MethodDescriptor(
|
||||
service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "models.Greeter"),
|
||||
method: "Collect"
|
||||
)
|
||||
}
|
||||
public enum Expand: Sendable {
|
||||
public typealias Input = FlatBufferBuilder
|
||||
public typealias Output = models_HelloResponse
|
||||
public static let descriptor = GRPCCore.MethodDescriptor(
|
||||
service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "models.Greeter"),
|
||||
method: "Expand"
|
||||
)
|
||||
}
|
||||
public enum Update: Sendable {
|
||||
public typealias Input = FlatBufferBuilder
|
||||
public typealias Output = models_HelloResponse
|
||||
public static let descriptor = GRPCCore.MethodDescriptor(
|
||||
service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "models.Greeter"),
|
||||
method: "Update"
|
||||
)
|
||||
}
|
||||
public static let descriptors: [GRPCCore.MethodDescriptor] = [
|
||||
Get.descriptor,
|
||||
Collect.descriptor,
|
||||
Expand.descriptor,
|
||||
Update.descriptor,
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
|
||||
extension GRPCCore.ServiceDescriptor {
|
||||
public static let models_Greeter = GRPCCore.ServiceDescriptor(fullyQualifiedService: "models.Greeter")
|
||||
}
|
||||
|
||||
// MARK: models.Greeter Server
|
||||
|
||||
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
|
||||
extension models_Greeter {
|
||||
public protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService {
|
||||
func Get(
|
||||
request: GRPCCore.StreamingServerRequest<GRPCMessage<models_HelloResponse>>,
|
||||
context: GRPCCore.ServerContext
|
||||
) async throws -> GRPCCore.StreamingServerResponse<GRPCMessage<models_HelloResponse>>
|
||||
|
||||
func Collect(
|
||||
request: GRPCCore.StreamingServerRequest<GRPCMessage<models_HelloResponse>>,
|
||||
context: GRPCCore.ServerContext
|
||||
) async throws -> GRPCCore.StreamingServerResponse<GRPCMessage<models_HelloResponse>>
|
||||
|
||||
func Expand(
|
||||
request: GRPCCore.StreamingServerRequest<GRPCMessage<models_HelloResponse>>,
|
||||
context: GRPCCore.ServerContext
|
||||
) async throws -> GRPCCore.StreamingServerResponse<GRPCMessage<models_HelloResponse>>
|
||||
|
||||
func Update(
|
||||
request: GRPCCore.StreamingServerRequest<GRPCMessage<models_HelloResponse>>,
|
||||
context: GRPCCore.ServerContext
|
||||
) async throws -> GRPCCore.StreamingServerResponse<GRPCMessage<models_HelloResponse>>
|
||||
|
||||
}
|
||||
|
||||
public protocol ServiceProtocol: models_Greeter.StreamingServiceProtocol {
|
||||
func Get(
|
||||
request: GRPCCore.ServerRequest<GRPCMessage<models_HelloResponse>>,
|
||||
context: GRPCCore.ServerContext
|
||||
) async throws -> GRPCCore.ServerResponse<GRPCMessage<models_HelloResponse>>
|
||||
|
||||
func Collect(
|
||||
request: GRPCCore.StreamingServerRequest<GRPCMessage<models_HelloResponse>>,
|
||||
context: GRPCCore.ServerContext
|
||||
) async throws -> GRPCCore.ServerResponse<GRPCMessage<models_HelloResponse>>
|
||||
|
||||
func Expand(
|
||||
request: GRPCCore.ServerRequest<GRPCMessage<models_HelloResponse>>,
|
||||
context: GRPCCore.ServerContext
|
||||
) async throws -> GRPCCore.StreamingServerResponse<GRPCMessage<models_HelloResponse>>
|
||||
|
||||
func Update(
|
||||
request: GRPCCore.StreamingServerRequest<GRPCMessage<models_HelloResponse>>,
|
||||
context: GRPCCore.ServerContext
|
||||
) async throws -> GRPCCore.StreamingServerResponse<GRPCMessage<models_HelloResponse>>
|
||||
|
||||
}
|
||||
|
||||
public protocol SimpleServiceProtocol: models_Greeter.ServiceProtocol {
|
||||
func Get(
|
||||
request: GRPCMessage<models_HelloResponse>,
|
||||
context: GRPCCore.ServerContext
|
||||
) async throws -> GRPCMessage<models_HelloResponse>
|
||||
|
||||
func Collect(
|
||||
request: GRPCCore.RPCAsyncSequence<GRPCMessage<models_HelloResponse>, any Swift.Error>,
|
||||
context: GRPCCore.ServerContext
|
||||
) async throws -> GRPCMessage<models_HelloResponse>
|
||||
|
||||
func Expand(
|
||||
request: GRPCMessage<models_HelloResponse>,
|
||||
response: GRPCCore.RPCWriter<GRPCMessage<models_HelloResponse>>,
|
||||
context: GRPCCore.ServerContext
|
||||
) async throws
|
||||
|
||||
func Update(
|
||||
request: GRPCCore.RPCAsyncSequence<GRPCMessage<models_HelloResponse>, any Swift.Error>,
|
||||
response: GRPCCore.RPCWriter<GRPCMessage<models_HelloResponse>>,
|
||||
context: GRPCCore.ServerContext
|
||||
) async throws
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
|
||||
extension models_Greeter.StreamingServiceProtocol {
|
||||
public func registerMethods<Transport>(with router: inout GRPCCore.RPCRouter<Transport>) where Transport: GRPCCore.ServerTransport {
|
||||
router.registerHandler(
|
||||
forMethod: models_Greeter.Method.Get.descriptor,
|
||||
deserializer: FlatBuffersMessageDeserializer<GRPCMessage<models_HelloResponse>>(),
|
||||
serializer: FlatBuffersMessageSerializer<GRPCMessage<models_HelloResponse>>(),
|
||||
handler: { request, context in
|
||||
try await self.Get(
|
||||
request: request,
|
||||
context: context
|
||||
)
|
||||
}
|
||||
)
|
||||
router.registerHandler(
|
||||
forMethod: models_Greeter.Method.Collect.descriptor,
|
||||
deserializer: FlatBuffersMessageDeserializer<GRPCMessage<models_HelloResponse>>(),
|
||||
serializer: FlatBuffersMessageSerializer<GRPCMessage<models_HelloResponse>>(),
|
||||
handler: { request, context in
|
||||
try await self.Collect(
|
||||
request: request,
|
||||
context: context
|
||||
)
|
||||
}
|
||||
)
|
||||
router.registerHandler(
|
||||
forMethod: models_Greeter.Method.Expand.descriptor,
|
||||
deserializer: FlatBuffersMessageDeserializer<GRPCMessage<models_HelloResponse>>(),
|
||||
serializer: FlatBuffersMessageSerializer<GRPCMessage<models_HelloResponse>>(),
|
||||
handler: { request, context in
|
||||
try await self.Expand(
|
||||
request: request,
|
||||
context: context
|
||||
)
|
||||
}
|
||||
)
|
||||
router.registerHandler(
|
||||
forMethod: models_Greeter.Method.Update.descriptor,
|
||||
deserializer: FlatBuffersMessageDeserializer<GRPCMessage<models_HelloResponse>>(),
|
||||
serializer: FlatBuffersMessageSerializer<GRPCMessage<models_HelloResponse>>(),
|
||||
handler: { request, context in
|
||||
try await self.Update(
|
||||
request: request,
|
||||
context: context
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
|
||||
extension models_Greeter.ServiceProtocol {
|
||||
public func Get(
|
||||
request: GRPCCore.StreamingServerRequest<GRPCMessage<models_HelloResponse>>,
|
||||
context: GRPCCore.ServerContext
|
||||
) async throws -> GRPCCore.StreamingServerResponse<GRPCMessage<models_HelloResponse>> {
|
||||
let response = try await self.Get(
|
||||
request: GRPCCore.ServerRequest(stream: request),
|
||||
context: context
|
||||
)
|
||||
return GRPCCore.StreamingServerResponse(single: response)
|
||||
}
|
||||
public func Collect(
|
||||
request: GRPCCore.StreamingServerRequest<GRPCMessage<models_HelloResponse>>,
|
||||
context: GRPCCore.ServerContext
|
||||
) async throws -> GRPCCore.StreamingServerResponse<GRPCMessage<models_HelloResponse>> {
|
||||
let response = try await self.Collect(
|
||||
request: request,
|
||||
context: context
|
||||
)
|
||||
return GRPCCore.StreamingServerResponse(single: response)
|
||||
}
|
||||
public func Expand(
|
||||
request: GRPCCore.StreamingServerRequest<GRPCMessage<models_HelloResponse>>,
|
||||
context: GRPCCore.ServerContext
|
||||
) async throws -> GRPCCore.StreamingServerResponse<GRPCMessage<models_HelloResponse>> {
|
||||
let response = try await self.Expand(
|
||||
request: GRPCCore.ServerRequest(stream: request),
|
||||
context: context
|
||||
)
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
|
||||
extension models_Greeter.SimpleServiceProtocol {
|
||||
public func Get(
|
||||
request: GRPCCore.ServerRequest<GRPCMessage<models_HelloResponse>>,
|
||||
context: GRPCCore.ServerContext
|
||||
) async throws -> GRPCCore.ServerResponse<GRPCMessage<models_HelloResponse>> {
|
||||
return GRPCCore.ServerResponse<GRPCMessage<models_HelloResponse>>(
|
||||
message: try await self.Get(
|
||||
request: request.message,
|
||||
context: context
|
||||
),
|
||||
metadata: [:]
|
||||
)
|
||||
}
|
||||
public func Collect(
|
||||
request: GRPCCore.StreamingServerRequest<GRPCMessage<models_HelloResponse>>,
|
||||
context: GRPCCore.ServerContext
|
||||
) async throws -> GRPCCore.ServerResponse<GRPCMessage<models_HelloResponse>> {
|
||||
return GRPCCore.ServerResponse<GRPCMessage<models_HelloResponse>>(
|
||||
message: try await self.Collect(
|
||||
request: request.messages,
|
||||
context: context
|
||||
),
|
||||
metadata: [:]
|
||||
)
|
||||
}
|
||||
public func Expand(
|
||||
request: GRPCCore.ServerRequest<GRPCMessage<models_HelloResponse>>,
|
||||
context: GRPCCore.ServerContext
|
||||
) async throws -> GRPCCore.StreamingServerResponse<GRPCMessage<models_HelloResponse>> {
|
||||
return GRPCCore.StreamingServerResponse<GRPCMessage<models_HelloResponse>>(
|
||||
metadata: [:],
|
||||
producer: { writer in
|
||||
try await self.Expand(
|
||||
request: request.message,
|
||||
response: writer,
|
||||
context: context
|
||||
)
|
||||
return [:]
|
||||
}
|
||||
)
|
||||
}
|
||||
public func Update(
|
||||
request: GRPCCore.StreamingServerRequest<GRPCMessage<models_HelloResponse>>,
|
||||
context: GRPCCore.ServerContext
|
||||
) async throws -> GRPCCore.StreamingServerResponse<GRPCMessage<models_HelloResponse>> {
|
||||
return GRPCCore.StreamingServerResponse<GRPCMessage<models_HelloResponse>>(
|
||||
metadata: [:],
|
||||
producer: { writer in
|
||||
try await self.Update(
|
||||
request: request.messages,
|
||||
response: writer,
|
||||
context: context
|
||||
)
|
||||
return [:]
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: models.Greeter Client
|
||||
|
||||
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
|
||||
extension models_Greeter {
|
||||
public protocol ClientProtocol: Sendable {
|
||||
func Get<Result>(
|
||||
request: GRPCCore.ClientRequest<GRPCMessage<models_HelloResponse>>,
|
||||
serializer: some GRPCCore.MessageSerializer<GRPCMessage<models_HelloResponse>>,
|
||||
deserializer: some GRPCCore.MessageDeserializer<GRPCMessage<models_HelloResponse>>,
|
||||
options: GRPCCore.CallOptions,
|
||||
onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result
|
||||
) async throws -> Result where Result: Sendable
|
||||
|
||||
func Collect<Result>(
|
||||
request: GRPCCore.StreamingClientRequest<GRPCMessage<models_HelloResponse>>,
|
||||
serializer: some GRPCCore.MessageSerializer<GRPCMessage<models_HelloResponse>>,
|
||||
deserializer: some GRPCCore.MessageDeserializer<GRPCMessage<models_HelloResponse>>,
|
||||
options: GRPCCore.CallOptions,
|
||||
onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result
|
||||
) async throws -> Result where Result: Sendable
|
||||
|
||||
func Expand<Result>(
|
||||
request: GRPCCore.ClientRequest<GRPCMessage<models_HelloResponse>>,
|
||||
serializer: some GRPCCore.MessageSerializer<GRPCMessage<models_HelloResponse>>,
|
||||
deserializer: some GRPCCore.MessageDeserializer<GRPCMessage<models_HelloResponse>>,
|
||||
options: GRPCCore.CallOptions,
|
||||
onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result
|
||||
) async throws -> Result where Result: Sendable
|
||||
|
||||
func Update<Result>(
|
||||
request: GRPCCore.StreamingClientRequest<GRPCMessage<models_HelloResponse>>,
|
||||
serializer: some GRPCCore.MessageSerializer<GRPCMessage<models_HelloResponse>>,
|
||||
deserializer: some GRPCCore.MessageDeserializer<GRPCMessage<models_HelloResponse>>,
|
||||
options: GRPCCore.CallOptions,
|
||||
onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result
|
||||
) async throws -> Result where Result: Sendable
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
|
||||
extension models_Greeter {
|
||||
public struct Client<Transport>: ClientProtocol where Transport: GRPCCore.ClientTransport {
|
||||
private let client: GRPCCore.GRPCClient<Transport>
|
||||
|
||||
public init(wrapping client: GRPCCore.GRPCClient<Transport>) {
|
||||
self.client = client
|
||||
}
|
||||
|
||||
public func Get<Result>(
|
||||
request: GRPCCore.ClientRequest<GRPCMessage<models_HelloResponse>>,
|
||||
serializer: some GRPCCore.MessageSerializer<GRPCMessage<models_HelloResponse>>,
|
||||
deserializer: some GRPCCore.MessageDeserializer<GRPCMessage<models_HelloResponse>>,
|
||||
options: GRPCCore.CallOptions = .defaults,
|
||||
onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result = { response in try response.message }
|
||||
) async throws -> Result where Result: Sendable {
|
||||
try await self.client.unary(
|
||||
request: request,
|
||||
descriptor: models_Greeter.Method.Get.descriptor,
|
||||
serializer: serializer,
|
||||
deserializer: deserializer,
|
||||
options: options,
|
||||
onResponse: handleResponse
|
||||
)
|
||||
}
|
||||
|
||||
public func Collect<Result>(
|
||||
request: GRPCCore.StreamingClientRequest<GRPCMessage<models_HelloResponse>>,
|
||||
serializer: some GRPCCore.MessageSerializer<GRPCMessage<models_HelloResponse>>,
|
||||
deserializer: some GRPCCore.MessageDeserializer<GRPCMessage<models_HelloResponse>>,
|
||||
options: GRPCCore.CallOptions = .defaults,
|
||||
onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result = { response in try response.message }
|
||||
) async throws -> Result where Result: Sendable {
|
||||
try await self.client.clientStreaming(
|
||||
request: request,
|
||||
descriptor: models_Greeter.Method.Collect.descriptor,
|
||||
serializer: serializer,
|
||||
deserializer: deserializer,
|
||||
options: options,
|
||||
onResponse: handleResponse
|
||||
)
|
||||
}
|
||||
|
||||
public func Expand<Result>(
|
||||
request: GRPCCore.ClientRequest<GRPCMessage<models_HelloResponse>>,
|
||||
serializer: some GRPCCore.MessageSerializer<GRPCMessage<models_HelloResponse>>,
|
||||
deserializer: some GRPCCore.MessageDeserializer<GRPCMessage<models_HelloResponse>>,
|
||||
options: GRPCCore.CallOptions = .defaults,
|
||||
onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result
|
||||
) async throws -> Result where Result: Sendable {
|
||||
try await self.client.serverStreaming(
|
||||
request: request,
|
||||
descriptor: models_Greeter.Method.Expand.descriptor,
|
||||
serializer: serializer,
|
||||
deserializer: deserializer,
|
||||
options: options,
|
||||
onResponse: handleResponse
|
||||
)
|
||||
}
|
||||
|
||||
public func Update<Result>(
|
||||
request: GRPCCore.StreamingClientRequest<GRPCMessage<models_HelloResponse>>,
|
||||
serializer: some GRPCCore.MessageSerializer<GRPCMessage<models_HelloResponse>>,
|
||||
deserializer: some GRPCCore.MessageDeserializer<GRPCMessage<models_HelloResponse>>,
|
||||
options: GRPCCore.CallOptions = .defaults,
|
||||
onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result
|
||||
) async throws -> Result where Result: Sendable {
|
||||
try await self.client.bidirectionalStreaming(
|
||||
request: request,
|
||||
descriptor: models_Greeter.Method.Update.descriptor,
|
||||
serializer: serializer,
|
||||
deserializer: deserializer,
|
||||
options: options,
|
||||
onResponse: handleResponse
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
|
||||
extension models_Greeter.ClientProtocol {
|
||||
public func Get<Result>(
|
||||
request: GRPCCore.ClientRequest<GRPCMessage<models_HelloResponse>>,
|
||||
options: GRPCCore.CallOptions = .defaults,
|
||||
onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result = { response in try response.message }
|
||||
) async throws -> Result where Result: Sendable {
|
||||
try await self.Get(
|
||||
request: request,
|
||||
serializer: FlatBuffersMessageSerializer<GRPCMessage<models_HelloResponse>>(),
|
||||
deserializer: FlatBuffersMessageDeserializer<GRPCMessage<models_HelloResponse>>(),
|
||||
options: options,
|
||||
onResponse: handleResponse
|
||||
)
|
||||
}
|
||||
|
||||
public func Collect<Result>(
|
||||
request: GRPCCore.StreamingClientRequest<GRPCMessage<models_HelloResponse>>,
|
||||
options: GRPCCore.CallOptions = .defaults,
|
||||
onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result = { response in try response.message }
|
||||
) async throws -> Result where Result: Sendable {
|
||||
try await self.Collect(
|
||||
request: request,
|
||||
serializer: FlatBuffersMessageSerializer<GRPCMessage<models_HelloResponse>>(),
|
||||
deserializer: FlatBuffersMessageDeserializer<GRPCMessage<models_HelloResponse>>(),
|
||||
options: options,
|
||||
onResponse: handleResponse
|
||||
)
|
||||
}
|
||||
|
||||
public func Expand<Result>(
|
||||
request: GRPCCore.ClientRequest<GRPCMessage<models_HelloResponse>>,
|
||||
options: GRPCCore.CallOptions = .defaults,
|
||||
onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result
|
||||
) async throws -> Result where Result: Sendable {
|
||||
try await self.Expand(
|
||||
request: request,
|
||||
serializer: FlatBuffersMessageSerializer<GRPCMessage<models_HelloResponse>>(),
|
||||
deserializer: FlatBuffersMessageDeserializer<GRPCMessage<models_HelloResponse>>(),
|
||||
options: options,
|
||||
onResponse: handleResponse
|
||||
)
|
||||
}
|
||||
|
||||
public func Update<Result>(
|
||||
request: GRPCCore.StreamingClientRequest<GRPCMessage<models_HelloResponse>>,
|
||||
options: GRPCCore.CallOptions = .defaults,
|
||||
onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result
|
||||
) async throws -> Result where Result: Sendable {
|
||||
try await self.Update(
|
||||
request: request,
|
||||
serializer: FlatBuffersMessageSerializer<GRPCMessage<models_HelloResponse>>(),
|
||||
deserializer: FlatBuffersMessageDeserializer<GRPCMessage<models_HelloResponse>>(),
|
||||
options: options,
|
||||
onResponse: handleResponse
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
|
||||
extension models_Greeter.ClientProtocol {
|
||||
public func Get<Result>(
|
||||
_ message: GRPCMessage<models_HelloResponse>,
|
||||
metadata: GRPCCore.Metadata = [:],
|
||||
options: GRPCCore.CallOptions = .defaults,
|
||||
onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result = { try $0.message }
|
||||
) async throws -> Result where Result: Sendable {
|
||||
let request = GRPCCore.ClientRequest<GRPCMessage<models_HelloResponse>>(
|
||||
message: message,
|
||||
metadata: metadata
|
||||
)
|
||||
return try await self.Get(
|
||||
request: request,
|
||||
options: options,
|
||||
onResponse: handleResponse
|
||||
)
|
||||
}
|
||||
|
||||
public func Collect<Result>(
|
||||
metadata: GRPCCore.Metadata = [:],
|
||||
options: GRPCCore.CallOptions = .defaults,
|
||||
requestProducer producer: @Sendable @escaping (GRPCCore.RPCWriter<GRPCMessage<models_HelloResponse>>) async throws -> Void,
|
||||
onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result = { try $0.message }
|
||||
) async throws -> Result where Result: Sendable {
|
||||
let request = GRPCCore.StreamingClientRequest<GRPCMessage<models_HelloResponse>>(
|
||||
metadata: metadata,
|
||||
producer: producer
|
||||
)
|
||||
return try await self.Collect(
|
||||
request: request,
|
||||
options: options,
|
||||
onResponse: handleResponse
|
||||
)
|
||||
}
|
||||
|
||||
public func Expand<Result>(
|
||||
_ message: GRPCMessage<models_HelloResponse>,
|
||||
metadata: GRPCCore.Metadata = [:],
|
||||
options: GRPCCore.CallOptions = .defaults,
|
||||
onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result
|
||||
) async throws -> Result where Result: Sendable {
|
||||
let request = GRPCCore.ClientRequest<GRPCMessage<models_HelloResponse>>(
|
||||
message: message,
|
||||
metadata: metadata
|
||||
)
|
||||
return try await self.Expand(
|
||||
request: request,
|
||||
options: options,
|
||||
onResponse: handleResponse
|
||||
)
|
||||
}
|
||||
|
||||
public func Update<Result>(
|
||||
metadata: GRPCCore.Metadata = [:],
|
||||
options: GRPCCore.CallOptions = .defaults,
|
||||
requestProducer producer: @Sendable @escaping (GRPCCore.RPCWriter<GRPCMessage<models_HelloResponse>>) async throws -> Void,
|
||||
onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result
|
||||
) async throws -> Result where Result: Sendable {
|
||||
let request = GRPCCore.StreamingClientRequest<GRPCMessage<models_HelloResponse>>(
|
||||
metadata: metadata,
|
||||
producer: producer
|
||||
)
|
||||
return try await self.Update(
|
||||
request: request,
|
||||
options: options,
|
||||
onResponse: handleResponse
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// swiftlint:disable all
|
||||
// swiftformat:disable all
|
||||
|
||||
#if canImport(Common)
|
||||
import Common
|
||||
#endif
|
||||
|
||||
import FlatBuffers
|
||||
|
||||
public struct models_HelloResponse: FlatBufferVerifiableTable, FlatbuffersVectorInitializable {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_25_12_19() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
private var _accessor: Table
|
||||
|
||||
private init(_ t: Table) { _accessor = t }
|
||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||
|
||||
private struct VT {
|
||||
static let message: VOffset = 4
|
||||
}
|
||||
|
||||
public var message: String? { let o = _accessor.offset(VT.message); return o == 0 ? nil : _accessor.string(at: o) }
|
||||
public var messageSegmentArray: [UInt8]? { return _accessor.getVector(at: VT.message) }
|
||||
public static func startHelloResponse(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
|
||||
public static func add(message: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: message, at: VT.message) }
|
||||
public static func endHelloResponse(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||
public static func createHelloResponse(
|
||||
_ fbb: inout FlatBufferBuilder,
|
||||
messageOffset message: Offset = Offset()
|
||||
) -> Offset {
|
||||
let __start = models_HelloResponse.startHelloResponse(&fbb)
|
||||
models_HelloResponse.add(message: message, &fbb)
|
||||
return models_HelloResponse.endHelloResponse(&fbb, start: __start)
|
||||
}
|
||||
|
||||
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
|
||||
var _v = try verifier.visitTable(at: position)
|
||||
try _v.visit(field: VT.message, fieldName: "message", required: false, type: ForwardOffset<String>.self)
|
||||
_v.finish()
|
||||
}
|
||||
}
|
||||
|
||||
extension models_HelloResponse: Encodable {
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case message = "message"
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(message, forKey: .message)
|
||||
}
|
||||
}
|
||||
|
||||
public struct models_HelloRequest: FlatBufferVerifiableTable, FlatbuffersVectorInitializable {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_25_12_19() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
private var _accessor: Table
|
||||
|
||||
private init(_ t: Table) { _accessor = t }
|
||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||
|
||||
private struct VT {
|
||||
static let name: VOffset = 4
|
||||
}
|
||||
|
||||
public var name: String? { let o = _accessor.offset(VT.name); return o == 0 ? nil : _accessor.string(at: o) }
|
||||
public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: VT.name) }
|
||||
public static func startHelloRequest(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
|
||||
public static func add(name: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: name, at: VT.name) }
|
||||
public static func endHelloRequest(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||
public static func createHelloRequest(
|
||||
_ fbb: inout FlatBufferBuilder,
|
||||
nameOffset name: Offset = Offset()
|
||||
) -> Offset {
|
||||
let __start = models_HelloRequest.startHelloRequest(&fbb)
|
||||
models_HelloRequest.add(name: name, &fbb)
|
||||
return models_HelloRequest.endHelloRequest(&fbb, start: __start)
|
||||
}
|
||||
|
||||
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
|
||||
var _v = try verifier.visitTable(at: position)
|
||||
try _v.visit(field: VT.name, fieldName: "name", required: false, type: ForwardOffset<String>.self)
|
||||
_v.finish()
|
||||
}
|
||||
}
|
||||
|
||||
extension models_HelloRequest: Encodable {
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case name = "name"
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(name, forKey: .name)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-17
@@ -91,14 +91,6 @@ 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.
|
||||
|
||||
@@ -212,16 +204,8 @@ 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(NormalizeKeywordCase(name)) == keywords_.end()) {
|
||||
if (keywords_.find(name) == keywords_.end()) {
|
||||
return name;
|
||||
} else {
|
||||
return config_.keyword_prefix + name + config_.keyword_suffix;
|
||||
|
||||
@@ -26,7 +26,6 @@ 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=*/"",
|
||||
@@ -50,7 +49,6 @@ 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=*/"",
|
||||
|
||||
@@ -142,19 +142,6 @@
|
||||
#define FLATBUFFERS_VERSION_MAJOR 25
|
||||
#define FLATBUFFERS_VERSION_MINOR 12
|
||||
#define FLATBUFFERS_VERSION_REVISION 19
|
||||
|
||||
// Identifies this header as Bigfoot's fork of flatbuffers, and versions the
|
||||
// fork's own generated-code-affecting changes independently of the upstream
|
||||
// FLATBUFFERS_VERSION_* triplet above (which just tracks the upstream
|
||||
// version this fork is based on, and would still match an unforked, stock
|
||||
// flatbuffers install of the same version). Generated headers assert on
|
||||
// this - see GenFlatbuffersVersionCheck() in idl_gen_cpp.cpp - so building
|
||||
// Bigfoot-generated code against stock flatbuffers, or a differently
|
||||
// versioned Bigfoot fork, fails to compile immediately instead of silently
|
||||
// miscompiling. Bump this whenever a change here affects what generated
|
||||
// code assumes about this header (e.g. adding bigfoot_ref/bigfoot_ref_wrapper).
|
||||
#define FLATBUFFERS_BIGFOOT_VERSION 1
|
||||
|
||||
#define FLATBUFFERS_STRING_EXPAND(X) #X
|
||||
#define FLATBUFFERS_STRING(X) FLATBUFFERS_STRING_EXPAND(X)
|
||||
namespace flatbuffers {
|
||||
|
||||
@@ -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_CPP14 E operator |= (E &lhs, E rhs){\
|
||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator |= (E &lhs, E rhs){\
|
||||
lhs = lhs | rhs;\
|
||||
return lhs;\
|
||||
}\
|
||||
inline FLATBUFFERS_CONSTEXPR_CPP14 E operator &= (E &lhs, E rhs){\
|
||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator &= (E &lhs, E rhs){\
|
||||
lhs = lhs & rhs;\
|
||||
return lhs;\
|
||||
}\
|
||||
inline FLATBUFFERS_CONSTEXPR_CPP14 E operator ^= (E &lhs, E rhs){\
|
||||
inline FLATBUFFERS_CONSTEXPR_CPP11 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, its type, and field offset.
|
||||
// Represents a parsed scalar value, it's type, and field offset.
|
||||
struct Value {
|
||||
Value()
|
||||
: constant("0"),
|
||||
@@ -395,20 +395,13 @@ 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),
|
||||
cycle_status{CycleStatus::NotChecked} {}
|
||||
bytesize(0) {}
|
||||
|
||||
void PadLastField(size_t min_align) {
|
||||
auto padding = PaddingBytes(bytesize, min_align);
|
||||
@@ -430,8 +423,6 @@ 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;
|
||||
};
|
||||
@@ -677,7 +668,6 @@ struct IDLOptions {
|
||||
std::string cpp_object_api_pointer_type;
|
||||
std::string cpp_object_api_string_type;
|
||||
bool cpp_object_api_string_flexible_constructor;
|
||||
std::string cpp_object_api_vector_type;
|
||||
CaseStyle cpp_object_api_field_case_style;
|
||||
bool cpp_direct_copy;
|
||||
bool gen_nullable;
|
||||
@@ -744,7 +734,6 @@ 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.
|
||||
@@ -871,7 +860,6 @@ 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),
|
||||
@@ -1013,13 +1001,10 @@ 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_vector_type"] = true;
|
||||
known_attributes_["native_inline"] = true;
|
||||
known_attributes_["native_custom_alloc"] = true;
|
||||
known_attributes_["native_type"] = true;
|
||||
known_attributes_["native_type_pack_name"] = true;
|
||||
known_attributes_["bigfoot_ref_wrapper"] = true;
|
||||
known_attributes_["bigfoot_ref"] = true;
|
||||
known_attributes_["native_default"] = true;
|
||||
known_attributes_["flexbuffer"] = true;
|
||||
known_attributes_["private"] = true;
|
||||
@@ -1114,8 +1099,6 @@ class Parser : public ParserState {
|
||||
// others includes.
|
||||
std::vector<IncludedFile> GetIncludedFiles() const;
|
||||
|
||||
bool HasCircularStructDependency();
|
||||
|
||||
private:
|
||||
class ParseDepthGuard;
|
||||
|
||||
|
||||
-3
@@ -14,12 +14,9 @@
|
||||
* 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,62 +296,25 @@ function mt:Slot(slotnum)
|
||||
self.currentVTable[slotnum + 1] = self:Offset()
|
||||
end
|
||||
|
||||
local function finish(self, rootTable, sizePrefix, fileIdentifier)
|
||||
local function finish(self, rootTable, sizePrefix)
|
||||
UOffsetT:EnforceNumber(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
|
||||
self:Prep(self.minalign, sizePrefix and 8 or 4)
|
||||
self:PrependUOffsetTRelative(rootTable)
|
||||
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, nil)
|
||||
return finish(self, rootTable, false)
|
||||
end
|
||||
|
||||
function mt:FinishSizePrefixed(rootTable)
|
||||
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)
|
||||
return finish(self, rootTable, true)
|
||||
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 * ByteBuffer.SizeOf<T>());
|
||||
return bb.ToArray<T>(pos, len);
|
||||
}
|
||||
|
||||
// Initialize any Table-derived type to point to the union at the given offset.
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
packages:
|
||||
- tests/ts
|
||||
@@ -422,6 +422,7 @@ 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.
|
||||
|
||||
@@ -437,6 +438,8 @@ 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."""
|
||||
|
||||
@@ -553,21 +556,6 @@ 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,12 +155,6 @@ 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)
|
||||
|
||||
@@ -185,12 +179,6 @@ 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)
|
||||
|
||||
@@ -203,12 +191,6 @@ 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,12 +134,6 @@ 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)
|
||||
|
||||
@@ -152,12 +146,6 @@ 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,12 +235,6 @@ 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)
|
||||
|
||||
@@ -253,12 +247,6 @@ 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,12 +158,6 @@ 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)
|
||||
|
||||
@@ -194,12 +188,6 @@ 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)
|
||||
|
||||
@@ -212,12 +200,6 @@ 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,12 +138,6 @@ 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)
|
||||
|
||||
@@ -156,12 +150,6 @@ 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,12 +180,6 @@ 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)
|
||||
|
||||
@@ -198,12 +192,6 @@ 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)
|
||||
|
||||
@@ -234,12 +222,6 @@ 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)
|
||||
|
||||
@@ -258,12 +240,6 @@ 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,12 +84,6 @@ 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,12 +137,6 @@ 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)
|
||||
|
||||
@@ -155,12 +149,6 @@ 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)
|
||||
|
||||
@@ -173,12 +161,6 @@ 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,8 +611,6 @@ 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,9 +421,6 @@ 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 scripts/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 script/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 scripts/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 script/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,11 +85,6 @@ 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",
|
||||
@@ -245,27 +240,6 @@ flatc(
|
||||
],
|
||||
)
|
||||
|
||||
flatc(
|
||||
BASE_OPTS + CPP_OPTS + ["--cpp-ptr-type", "naked"],
|
||||
prefix="vector_table_naked_ptr",
|
||||
schema="vector_table_naked_ptr.fbs",
|
||||
)
|
||||
|
||||
flatc(
|
||||
[
|
||||
"--cpp",
|
||||
"--gen-compare",
|
||||
"--gen-mutable",
|
||||
"--gen-object-api",
|
||||
"--reflect-names",
|
||||
"--cpp-include",
|
||||
"test_vector_type.h",
|
||||
"--cpp-vector-type",
|
||||
"::flatbuffers::tests::CustomVector",
|
||||
],
|
||||
schema="cpp_vector_type.fbs",
|
||||
)
|
||||
|
||||
flatc(
|
||||
BASE_OPTS + CPP_OPTS + CS_OPTS + JAVA_OPTS + KOTLIN_OPTS + PHP_OPTS,
|
||||
prefix="union_vector",
|
||||
@@ -308,12 +282,6 @@ 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",
|
||||
@@ -321,12 +289,6 @@ 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",
|
||||
@@ -394,7 +356,13 @@ 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",
|
||||
)
|
||||
|
||||
|
||||
@@ -61,7 +61,6 @@ Namer::Config LuaDefaultConfig() {
|
||||
/*object_suffix=*/"",
|
||||
/*keyword_prefix=*/"",
|
||||
/*keyword_suffix=*/"_",
|
||||
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||
/*filenames=*/Case::kKeep,
|
||||
/*directories=*/Case::kKeep,
|
||||
/*output_path=*/"",
|
||||
@@ -195,13 +194,6 @@ 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";
|
||||
@@ -462,34 +454,6 @@ 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,7 +70,6 @@ Namer::Config NimDefaultConfig() {
|
||||
/*object_suffix=*/"T",
|
||||
/*keyword_prefix=*/"",
|
||||
/*keyword_suffix=*/"_",
|
||||
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||
/*filenames=*/Case::kKeep,
|
||||
/*directories=*/Case::kKeep,
|
||||
/*output_path=*/"",
|
||||
|
||||
@@ -145,12 +145,6 @@ const static FlatCOption flatc_options[] = {
|
||||
{"", "cpp-str-flex-ctor", "",
|
||||
"Don't construct custom string types by passing std::string from "
|
||||
"Flatbuffers, but (char* + length)."},
|
||||
{"", "cpp-vector-type", "T",
|
||||
"Set object API vector type (default std::vector). T must be a "
|
||||
"template taking a single element type argument and support "
|
||||
"resize(), reserve(), size(), data(), operator[], emplace_back(), and "
|
||||
"begin()/end(). The custom type also needs its own header to be "
|
||||
"included via --cpp-include."},
|
||||
{"", "cpp-field-case-style", "STYLE",
|
||||
"Generate C++ fields using selected case style. Supported STYLE values: * "
|
||||
"'unchanged' - leave unchanged (default) * 'upper' - schema snake_case "
|
||||
@@ -271,9 +265,6 @@ 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",
|
||||
@@ -551,9 +542,6 @@ FlatCOptions FlatCompiler::ParseFromCommandLineArguments(int argc,
|
||||
opts.cpp_object_api_string_type = argv[argi];
|
||||
} else if (arg == "--cpp-str-flex-ctor") {
|
||||
opts.cpp_object_api_string_flexible_constructor = true;
|
||||
} else if (arg == "--cpp-vector-type") {
|
||||
if (++argi >= argc) Error("missing type following: " + arg, true);
|
||||
opts.cpp_object_api_vector_type = argv[argi];
|
||||
} else if (arg == "--no-cpp-direct-copy") {
|
||||
opts.cpp_direct_copy = false;
|
||||
} else if (arg == "--cpp-field-case-style") {
|
||||
@@ -722,8 +710,6 @@ 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") {
|
||||
@@ -936,9 +922,6 @@ 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();
|
||||
}
|
||||
|
||||
+27
-288
@@ -257,19 +257,6 @@ class CppGenerator : public BaseGenerator {
|
||||
code_ += " FLATBUFFERS_VERSION_REVISION == " +
|
||||
std::to_string(FLATBUFFERS_VERSION_REVISION) + ",";
|
||||
code_ += " \"Non-compatible flatbuffers version included\");";
|
||||
|
||||
code_ += "// Ensure the included flatbuffers.h is Bigfoot's fork - stock";
|
||||
code_ += "// flatbuffers (or a differently versioned Bigfoot fork) is not compatible.";
|
||||
code_ += "#ifndef FLATBUFFERS_BIGFOOT_VERSION";
|
||||
code_ +=
|
||||
"#error \"This file requires Bigfoot's flatbuffers fork - stock "
|
||||
"flatbuffers is not compatible\"";
|
||||
code_ += "#endif";
|
||||
code_ += "static_assert(FLATBUFFERS_BIGFOOT_VERSION == " +
|
||||
std::to_string(FLATBUFFERS_BIGFOOT_VERSION) + ",";
|
||||
code_ +=
|
||||
" \"Non-compatible Bigfoot flatbuffers fork version "
|
||||
"included\");";
|
||||
}
|
||||
|
||||
void GenIncludeDependencies() {
|
||||
@@ -542,8 +529,6 @@ class CppGenerator : public BaseGenerator {
|
||||
code_ += "";
|
||||
}
|
||||
|
||||
GenerateBigfootRefForwardDecls();
|
||||
|
||||
// Generate preablmle code for mini reflection.
|
||||
if (opts_.mini_reflect != IDLOptions::kNone) {
|
||||
// To break cyclic dependencies, first pre-declare all tables/structs.
|
||||
@@ -773,8 +758,6 @@ class CppGenerator : public BaseGenerator {
|
||||
|
||||
if (cur_name_space_) SetNameSpace(nullptr);
|
||||
|
||||
GenerateBigfootRefImpls();
|
||||
|
||||
// Close the include guard.
|
||||
code_ += "#endif // " + include_guard;
|
||||
|
||||
@@ -909,24 +892,6 @@ class CppGenerator : public BaseGenerator {
|
||||
return opts_.gen_nullable ? " _Nullable " : "";
|
||||
}
|
||||
|
||||
// A field's `native_type`/`native_type_pack_name` normally come from the
|
||||
// referenced struct's own declaration. A field can override both (see
|
||||
// `bigfoot_ref` in idl_parser.cpp, which synthesizes these two attributes
|
||||
// directly on the field) to instantiate a templated native type
|
||||
// differently per field.
|
||||
static const Value* EffectiveNativeType(const FieldDef& field,
|
||||
const StructDef& struct_def) {
|
||||
if (const auto v = field.attributes.Lookup("native_type")) return v;
|
||||
return struct_def.attributes.Lookup("native_type");
|
||||
}
|
||||
|
||||
static const Value* EffectiveNativeTypePackName(const FieldDef& field,
|
||||
const StructDef& struct_def) {
|
||||
if (const auto v = field.attributes.Lookup("native_type_pack_name"))
|
||||
return v;
|
||||
return struct_def.attributes.Lookup("native_type_pack_name");
|
||||
}
|
||||
|
||||
static std::string NativeName(const std::string& name, const StructDef* sd,
|
||||
const IDLOptions& opts) {
|
||||
// If the table is a native_type, return the native_type name.
|
||||
@@ -972,23 +937,6 @@ class CppGenerator : public BaseGenerator {
|
||||
"std::string"; // Only for custom string types.
|
||||
}
|
||||
|
||||
const std::string NativeVectorType(const FieldDef* field) {
|
||||
auto attr = field ? field->attributes.Lookup("cpp_vector_type") : nullptr;
|
||||
auto& ret = attr ? attr->constant : opts_.cpp_object_api_vector_type;
|
||||
if (ret.empty()) {
|
||||
return "std::vector";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// True if this field's native vector uses a custom (non-std::vector)
|
||||
// container, meaning generated Pack() code can't rely on the std::vector
|
||||
// specific CreateVector*() overloads and must fall back to data()/size()
|
||||
// or per-element construction instead.
|
||||
bool UsesCustomVectorType(const FieldDef* field) {
|
||||
return NativeVectorType(field) != "std::vector";
|
||||
}
|
||||
|
||||
std::string GenTypeNativePtr(const std::string& type, const FieldDef* field,
|
||||
bool is_constructor) {
|
||||
auto& ptr_type = PtrType(field);
|
||||
@@ -1026,21 +974,20 @@ class CppGenerator : public BaseGenerator {
|
||||
case BASE_TYPE_VECTOR64:
|
||||
case BASE_TYPE_VECTOR: {
|
||||
const auto type_name = GenTypeNative(type.VectorType(), true, field);
|
||||
const auto vector_type = NativeVectorType(&field);
|
||||
if (vector_type == "std::vector" && type.struct_def &&
|
||||
if (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 vector_type + "<" + type_name + ">";
|
||||
return "std::vector<" + type_name + ">";
|
||||
}
|
||||
}
|
||||
case BASE_TYPE_STRUCT: {
|
||||
auto type_name = WrapInNameSpace(*type.struct_def);
|
||||
if (IsStruct(type)) {
|
||||
auto native_type = EffectiveNativeType(field, *type.struct_def);
|
||||
auto native_type = type.struct_def->attributes.Lookup("native_type");
|
||||
if (native_type) {
|
||||
type_name = native_type->constant;
|
||||
}
|
||||
@@ -2032,7 +1979,7 @@ class CppGenerator : public BaseGenerator {
|
||||
const std::string& full_type =
|
||||
(cpp_type
|
||||
? (IsVector(field.value.type)
|
||||
? NativeVectorType(&field) + "<" +
|
||||
? "std::vector<" +
|
||||
GenTypeNativePtr(cpp_type->constant, &field,
|
||||
false) +
|
||||
"> "
|
||||
@@ -2049,19 +1996,8 @@ class CppGenerator : public BaseGenerator {
|
||||
" = " + (native_default ? std::string(native_default->constant)
|
||||
: GetDefaultScalarValue(field, true));
|
||||
} else if (field.value.type.base_type == BASE_TYPE_STRUCT) {
|
||||
if (IsStruct(field.value.type)) {
|
||||
if (native_default) {
|
||||
field_di = " = " + native_default->constant;
|
||||
}
|
||||
} else if (!cpp_type && !field.native_inline && field.IsRequired() &&
|
||||
PtrType(&field) != "naked") {
|
||||
// A required table field can never legally be absent once
|
||||
// Verify()/Pack() succeed, so default-construct it here instead
|
||||
// of leaving every hand-written native constructor to remember
|
||||
// to allocate it before the first Pack().
|
||||
const auto nn = WrapNativeNameInNameSpace(
|
||||
*field.value.type.struct_def, opts_);
|
||||
field_di = "{new " + nn + "()}";
|
||||
if (IsStruct(field.value.type) && native_default) {
|
||||
field_di = " = " + native_default->constant;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3579,11 +3515,11 @@ class CppGenerator : public BaseGenerator {
|
||||
}
|
||||
case BASE_TYPE_STRUCT: {
|
||||
if (IsStruct(type)) {
|
||||
const auto native_type = EffectiveNativeType(afield, *type.struct_def);
|
||||
const auto& struct_attrs = type.struct_def->attributes;
|
||||
const auto native_type = struct_attrs.Lookup("native_type");
|
||||
if (native_type) {
|
||||
std::string unpack_call = "::flatbuffers::UnPack";
|
||||
const auto pack_name =
|
||||
EffectiveNativeTypePackName(afield, *type.struct_def);
|
||||
const auto pack_name = struct_attrs.Lookup("native_type_pack_name");
|
||||
if (pack_name) {
|
||||
unpack_call += pack_name->constant;
|
||||
}
|
||||
@@ -3836,22 +3772,13 @@ class CppGenerator : public BaseGenerator {
|
||||
case BASE_TYPE_VECTOR64:
|
||||
case BASE_TYPE_VECTOR: {
|
||||
auto vector_type = field.value.type.VectorType();
|
||||
// If the field's native container isn't std::vector, the
|
||||
// std::vector-specific CreateVector*() overloads in
|
||||
// flatbuffer_builder.h can't be used directly. Fall back to
|
||||
// data()/size()-based overloads (which only require the container to
|
||||
// support those, like std::vector does) or, where no such overload
|
||||
// exists, to the same per-element lambda serialization already used
|
||||
// above for custom string/table/union element types.
|
||||
const bool custom_vector = UsesCustomVectorType(&field);
|
||||
switch (vector_type.base_type) {
|
||||
case BASE_TYPE_STRING: {
|
||||
if (!custom_vector && NativeString(&field) == "std::string") {
|
||||
if (NativeString(&field) == "std::string") {
|
||||
code += "_fbb.CreateVectorOfStrings(" + value + ")";
|
||||
} else {
|
||||
// Use by-function serialization to emulate
|
||||
// CreateVectorOfStrings(); this works also with non-std strings
|
||||
// and non-std::vector vector types.
|
||||
// CreateVectorOfStrings(); this works also with non-std strings.
|
||||
code +=
|
||||
"_fbb.CreateVector<::flatbuffers::Offset<::flatbuffers::"
|
||||
"String>>"
|
||||
@@ -3866,37 +3793,20 @@ class CppGenerator : public BaseGenerator {
|
||||
}
|
||||
case BASE_TYPE_STRUCT: {
|
||||
if (IsStruct(vector_type)) {
|
||||
const auto native_type =
|
||||
EffectiveNativeType(field, *field.value.type.struct_def);
|
||||
const auto& struct_attrs =
|
||||
field.value.type.struct_def->attributes;
|
||||
const auto native_type = struct_attrs.Lookup("native_type");
|
||||
if (native_type) {
|
||||
code += "_fbb.CreateVectorOfNativeStructs<";
|
||||
code += WrapInNameSpace(*vector_type.struct_def) + ", " +
|
||||
native_type->constant + ">";
|
||||
if (custom_vector) {
|
||||
code += "(" + value + ".data(), " + value + ".size()";
|
||||
} else {
|
||||
code += "(" + value;
|
||||
}
|
||||
const auto pack_name = EffectiveNativeTypePackName(
|
||||
field, *field.value.type.struct_def);
|
||||
code += "(" + value;
|
||||
const auto pack_name =
|
||||
struct_attrs.Lookup("native_type_pack_name");
|
||||
if (pack_name) {
|
||||
code += ", ::flatbuffers::Pack" + pack_name->constant;
|
||||
}
|
||||
code += ")";
|
||||
} else if (custom_vector &&
|
||||
(field.value.type.base_type == BASE_TYPE_VECTOR64 ||
|
||||
field.offset64)) {
|
||||
// CreateVectorOfStructs64() (and CreateVectorOfStructs64<V>()
|
||||
// for offset64) only accept a std::vector; use the
|
||||
// equivalent explicit-template raw pointer overload instead.
|
||||
const auto struct_type = WrapInNameSpace(*vector_type.struct_def);
|
||||
const auto vector_t = field.value.type.base_type ==
|
||||
BASE_TYPE_VECTOR64
|
||||
? "::flatbuffers::Vector64"
|
||||
: "::flatbuffers::Vector";
|
||||
code += "_fbb.CreateVectorOfStructs<" + struct_type +
|
||||
", ::flatbuffers::Offset64, " + vector_t + ">(" +
|
||||
value + ".data(), " + value + ".size())";
|
||||
} else {
|
||||
// If the field uses 64-bit addressing, create a 64-bit vector.
|
||||
if (field.value.type.base_type == BASE_TYPE_VECTOR64) {
|
||||
@@ -3908,11 +3818,7 @@ class CppGenerator : public BaseGenerator {
|
||||
code += "64<::flatbuffers::Vector>";
|
||||
}
|
||||
}
|
||||
if (custom_vector) {
|
||||
code += "(" + value + ".data(), " + value + ".size())";
|
||||
} else {
|
||||
code += "(" + value + ")";
|
||||
}
|
||||
code += "(" + value + ")";
|
||||
}
|
||||
} else {
|
||||
code += "_fbb.CreateVector<::flatbuffers::Offset<";
|
||||
@@ -3931,17 +3837,7 @@ class CppGenerator : public BaseGenerator {
|
||||
break;
|
||||
}
|
||||
case BASE_TYPE_BOOL: {
|
||||
if (custom_vector) {
|
||||
// Vectors of bool are always stored on the wire as uint8_t
|
||||
// (there is no Vector<bool>); CreateVectorScalarCast() does
|
||||
// the per-element bool->uint8_t cast from a raw data()/size()
|
||||
// pointer pair, avoiding any dependency on std::vector<bool>'s
|
||||
// bit-packed specialization.
|
||||
code += "_fbb.CreateVectorScalarCast<uint8_t>(" + value +
|
||||
".data(), " + value + ".size())";
|
||||
} else {
|
||||
code += "_fbb.CreateVector(" + value + ")";
|
||||
}
|
||||
code += "_fbb.CreateVector(" + value + ")";
|
||||
break;
|
||||
}
|
||||
case BASE_TYPE_UNION: {
|
||||
@@ -3977,11 +3873,9 @@ class CppGenerator : public BaseGenerator {
|
||||
// the underlying storage type (eg. uint8_t).
|
||||
const auto basetype = GenTypeBasic(
|
||||
field.value.type.enum_def->underlying_type, false);
|
||||
const std::string data_ptr =
|
||||
custom_vector ? value + ".data()"
|
||||
: "::flatbuffers::data(" + value + ")";
|
||||
code += "_fbb.CreateVectorScalarCast<" + basetype + ">(" +
|
||||
data_ptr + ", " + value + ".size())";
|
||||
code += "_fbb.CreateVectorScalarCast<" + basetype +
|
||||
">(::flatbuffers::data(" + value + "), " + value +
|
||||
".size())";
|
||||
} else if (field.attributes.Lookup("cpp_type")) {
|
||||
auto type = GenTypeBasic(vector_type, false);
|
||||
code += "_fbb.CreateVector<" + type + ">(" + value + ".size(), ";
|
||||
@@ -3990,27 +3884,6 @@ class CppGenerator : public BaseGenerator {
|
||||
code += "static_cast<" + type + ">((*__va->__rehasher)";
|
||||
code += "(__va->_" + value + "[i]" + GenPtrGet(field) + ")) : 0";
|
||||
code += "; }, &_va )";
|
||||
} else if (custom_vector) {
|
||||
// Explicitly specify the element type so it can be deduced
|
||||
// from a raw data()/size() pointer pair instead of relying on
|
||||
// the std::vector<T, Alloc>-specific CreateVector overloads.
|
||||
// Use the user-facing type (matches what GenTypeNative()
|
||||
// stores in the native vector, e.g. the enum type itself for
|
||||
// scoped-enum fields) so it matches data()'s pointee type.
|
||||
auto type = GenTypeBasic(vector_type, true);
|
||||
if (field.value.type.base_type == BASE_TYPE_VECTOR64) {
|
||||
code += "_fbb.CreateVector<" + type +
|
||||
", ::flatbuffers::Offset64, ::flatbuffers::Vector64>(" +
|
||||
value + ".data(), " + value + ".size())";
|
||||
} else if (field.offset64) {
|
||||
// This is normal 32-bit vector, with 64-bit addressing.
|
||||
code += "_fbb.CreateVector<" + type +
|
||||
", ::flatbuffers::Offset64, ::flatbuffers::Vector>(" +
|
||||
value + ".data(), " + value + ".size())";
|
||||
} else {
|
||||
code += "_fbb.CreateVector(" + value + ".data(), " + value +
|
||||
".size())";
|
||||
}
|
||||
} else {
|
||||
// If the field uses 64-bit addressing, create a 64-bit vector.
|
||||
if (field.value.type.base_type == BASE_TYPE_VECTOR64) {
|
||||
@@ -4044,12 +3917,12 @@ class CppGenerator : public BaseGenerator {
|
||||
}
|
||||
case BASE_TYPE_STRUCT: {
|
||||
if (IsStruct(field.value.type)) {
|
||||
const auto native_type =
|
||||
EffectiveNativeType(field, *field.value.type.struct_def);
|
||||
const auto& struct_attribs = field.value.type.struct_def->attributes;
|
||||
const auto native_type = struct_attribs.Lookup("native_type");
|
||||
if (native_type && field.native_inline) {
|
||||
code += "::flatbuffers::Pack";
|
||||
const auto pack_name =
|
||||
EffectiveNativeTypePackName(field, *field.value.type.struct_def);
|
||||
struct_attribs.Lookup("native_type_pack_name");
|
||||
if (pack_name) {
|
||||
code += pack_name->constant;
|
||||
}
|
||||
@@ -4214,7 +4087,8 @@ class CppGenerator : public BaseGenerator {
|
||||
if (field->value.type.base_type == BASE_TYPE_STRUCT) {
|
||||
if (IsStruct(field->value.type)) {
|
||||
auto native_type =
|
||||
EffectiveNativeType(*field, *field->value.type.struct_def);
|
||||
field->value.type.struct_def->attributes.Lookup(
|
||||
"native_type");
|
||||
auto native_inline = field->attributes.Lookup("native_inline");
|
||||
if (native_type) {
|
||||
pass_by_address = true;
|
||||
@@ -4569,141 +4443,6 @@ class CppGenerator : public BaseGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
// Split a "::"-qualified C++ name into namespace components + final name.
|
||||
static std::vector<std::string> SplitQualifiedName(const std::string& qualified) {
|
||||
std::vector<std::string> parts;
|
||||
size_t start = qualified.compare(0, 2, "::") == 0 ? 2 : 0;
|
||||
for (;;) {
|
||||
const auto pos = qualified.find("::", start);
|
||||
if (pos == std::string::npos) {
|
||||
parts.push_back(qualified.substr(start));
|
||||
break;
|
||||
}
|
||||
parts.push_back(qualified.substr(start, pos - start));
|
||||
start = pos + 2;
|
||||
}
|
||||
return parts;
|
||||
}
|
||||
|
||||
// Bigfoot: for every field annotated `bigfoot_ref: "::Ns::AssetX"` (see
|
||||
// idl_parser.cpp), forward-declare AssetX plus prototype the Pack/UnPack
|
||||
// functions for its reference wrapper. Called early (alongside the
|
||||
// regular struct/table forward declarations), since these prototypes -
|
||||
// unlike their definitions in GenerateBigfootRefImpls() - only need
|
||||
// AssetX and the wrapper struct forward-declared, not complete.
|
||||
void GenerateBigfootRefForwardDecls() {
|
||||
std::unordered_set<std::string> declared_assets;
|
||||
for (const auto& struct_def : parser_.structs_.vec) {
|
||||
if (struct_def->generated) continue;
|
||||
for (const auto& field : struct_def->fields.vec) {
|
||||
const auto* bigfoot_ref = field->attributes.Lookup("bigfoot_ref");
|
||||
if (!bigfoot_ref) continue;
|
||||
if (!declared_assets.insert(bigfoot_ref->constant).second) continue;
|
||||
|
||||
auto parts = SplitQualifiedName(bigfoot_ref->constant);
|
||||
const std::string class_name = parts.back();
|
||||
parts.pop_back();
|
||||
|
||||
SetNameSpace(nullptr);
|
||||
for (const auto& ns_part : parts) code_ += "namespace " + ns_part + " {";
|
||||
code_ += "class " + class_name + ";";
|
||||
for (auto it = parts.rbegin(); it != parts.rend(); ++it)
|
||||
code_ += "} // namespace " + *it;
|
||||
code_ += "";
|
||||
}
|
||||
}
|
||||
|
||||
std::unordered_set<std::string> declared_pairs;
|
||||
bool opened_flatbuffers_ns = false;
|
||||
for (const auto& struct_def : parser_.structs_.vec) {
|
||||
if (struct_def->generated) continue;
|
||||
for (const auto& field : struct_def->fields.vec) {
|
||||
const auto* bigfoot_ref = field->attributes.Lookup("bigfoot_ref");
|
||||
if (!bigfoot_ref) continue;
|
||||
|
||||
const auto* pack_name = field->attributes.Lookup("native_type_pack_name");
|
||||
if (!declared_pairs.insert(pack_name->constant).second) continue;
|
||||
|
||||
if (!opened_flatbuffers_ns) {
|
||||
SetNameSpace(nullptr);
|
||||
code_ += "namespace flatbuffers {";
|
||||
opened_flatbuffers_ns = true;
|
||||
}
|
||||
|
||||
const auto* native_type = field->attributes.Lookup("native_type");
|
||||
const std::string flat_wrapper =
|
||||
WrapInNameSpace(*field->value.type.struct_def);
|
||||
|
||||
code_ += flat_wrapper + " Pack" + pack_name->constant +
|
||||
"(const " + native_type->constant + "& p_asset);";
|
||||
code_ += native_type->constant + " UnPack" + pack_name->constant +
|
||||
"(const " + flat_wrapper + "& p_asset);";
|
||||
}
|
||||
}
|
||||
|
||||
if (opened_flatbuffers_ns) {
|
||||
code_ += "} // namespace flatbuffers";
|
||||
code_ += "";
|
||||
}
|
||||
}
|
||||
|
||||
// Bigfoot: defines the Pack/UnPack functions prototyped by
|
||||
// GenerateBigfootRefForwardDecls(). Called late (after every struct/table
|
||||
// in this file has been fully defined), since a wrapper struct (e.g.
|
||||
// HardReference/SoftReference) may be defined in this same generated file
|
||||
// rather than one it includes, and these definitions construct it by
|
||||
// value - they need it complete, unlike the earlier prototypes.
|
||||
void GenerateBigfootRefImpls() {
|
||||
std::unordered_set<std::string> declared_pairs;
|
||||
bool opened_flatbuffers_ns = false;
|
||||
for (const auto& struct_def : parser_.structs_.vec) {
|
||||
if (struct_def->generated) continue;
|
||||
for (const auto& field : struct_def->fields.vec) {
|
||||
const auto* bigfoot_ref = field->attributes.Lookup("bigfoot_ref");
|
||||
if (!bigfoot_ref) continue;
|
||||
|
||||
const auto* pack_name = field->attributes.Lookup("native_type_pack_name");
|
||||
if (!declared_pairs.insert(pack_name->constant).second) continue;
|
||||
|
||||
if (!opened_flatbuffers_ns) {
|
||||
SetNameSpace(nullptr);
|
||||
code_ += "namespace flatbuffers {";
|
||||
opened_flatbuffers_ns = true;
|
||||
}
|
||||
|
||||
const auto* native_type = field->attributes.Lookup("native_type");
|
||||
const std::string flat_wrapper =
|
||||
WrapInNameSpace(*field->value.type.struct_def);
|
||||
|
||||
// A single translation unit can end up including two different
|
||||
// generated headers that both reference the same asset type (e.g.
|
||||
// AssetB references AssetA, and some other TU includes both
|
||||
// AssetA_generated.hpp and AssetB_generated.hpp directly) - each
|
||||
// would otherwise emit an identical, independent definition of these
|
||||
// functions. `inline` only allows identical definitions to repeat
|
||||
// across *different* translation units, not twice within the same
|
||||
// one, so guard against that with a plain macro guard.
|
||||
std::string guard_name = pack_name->constant;
|
||||
std::transform(guard_name.begin(), guard_name.end(), guard_name.begin(), CharToUpper);
|
||||
const std::string guard = "FLATBUFFERS_BIGFOOT_REF_" + guard_name;
|
||||
code_ += "#ifndef " + guard;
|
||||
code_ += "#define " + guard;
|
||||
code_ += "inline " + flat_wrapper + " Pack" + pack_name->constant +
|
||||
"(const " + native_type->constant +
|
||||
"& p_asset) { return {Pack(p_asset.GetUUID())}; }";
|
||||
code_ += "inline " + native_type->constant + " UnPack" +
|
||||
pack_name->constant + "(const " + flat_wrapper +
|
||||
"& p_asset) { return {UnPack(p_asset.uuid())}; }";
|
||||
code_ += "#endif // " + guard;
|
||||
}
|
||||
}
|
||||
|
||||
if (opened_flatbuffers_ns) {
|
||||
code_ += "} // namespace flatbuffers";
|
||||
code_ += "";
|
||||
}
|
||||
}
|
||||
|
||||
// Set up the correct namespace. Only open a namespace if the existing one is
|
||||
// different (closing/opening only what is necessary).
|
||||
//
|
||||
|
||||
@@ -1243,58 +1243,6 @@ 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,7 +48,6 @@ 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,7 +75,6 @@ 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,7 +46,6 @@ 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,7 +64,6 @@ 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,7 +62,6 @@ 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=*/"",
|
||||
|
||||
+3
-69
@@ -593,18 +593,6 @@ 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";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1479,59 +1467,6 @@ 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.
|
||||
@@ -1682,8 +1617,8 @@ class PythonGenerator : public BaseGenerator {
|
||||
}
|
||||
|
||||
// Generate table constructors, conditioned on its members' types.
|
||||
void GenTableBuilders(const StructDef& struct_def, std::string* code_ptr,
|
||||
ImportMap& imports) const {
|
||||
void GenTableBuilders(const StructDef& struct_def,
|
||||
std::string* code_ptr) const {
|
||||
GetStartOfTable(struct_def, code_ptr);
|
||||
|
||||
for (auto it = struct_def.fields.vec.begin();
|
||||
@@ -1695,7 +1630,6 @@ 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);
|
||||
}
|
||||
}
|
||||
@@ -1762,7 +1696,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, imports);
|
||||
GenTableBuilders(struct_def, code_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,6 @@ 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=*/"",
|
||||
@@ -424,6 +423,7 @@ class RustGenerator : public BaseGenerator {
|
||||
code_.Clear();
|
||||
code_ += "// " + std::string(FlatBuffersGeneratedWarning());
|
||||
code_ += "// @generated";
|
||||
code_ += "extern crate alloc;";
|
||||
|
||||
assert(!cur_name_space_);
|
||||
|
||||
@@ -3005,7 +3005,6 @@ 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,7 +47,6 @@ 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=*/"",
|
||||
@@ -1963,7 +1962,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);
|
||||
}
|
||||
|
||||
|
||||
+43
-54
@@ -67,7 +67,6 @@ Namer::Config TypeScriptDefaultConfig() {
|
||||
/*object_suffix=*/"T",
|
||||
/*keyword_prefix=*/"",
|
||||
/*keyword_suffix=*/"_",
|
||||
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||
/*filenames=*/Case::kDasher,
|
||||
/*directories=*/Case::kDasher,
|
||||
/*output_path=*/"",
|
||||
@@ -87,7 +86,6 @@ 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
|
||||
};
|
||||
}
|
||||
|
||||
@@ -112,9 +110,7 @@ class TsGenerator : public BaseGenerator {
|
||||
const std::string& file_name)
|
||||
: BaseGenerator(parser, path, file_name, "", "_", "ts"),
|
||||
namer_(WithFlagOptions(TypeScriptDefaultConfig(), parser.opts, path),
|
||||
TypescriptKeywords()),
|
||||
null_keyword_(parser_.opts.ts_undefined_for_optionals ? "undefined"
|
||||
: "null") {}
|
||||
TypescriptKeywords()) {}
|
||||
|
||||
bool generate() {
|
||||
generateEnums();
|
||||
@@ -218,8 +214,6 @@ 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();
|
||||
@@ -473,7 +467,7 @@ class TsGenerator : public BaseGenerator {
|
||||
|
||||
std::string GenDefaultValue(const FieldDef& field, import_set& imports) {
|
||||
if (field.IsScalarOptional()) {
|
||||
return null_keyword_;
|
||||
return "null";
|
||||
}
|
||||
|
||||
const auto& value = field.value;
|
||||
@@ -524,7 +518,7 @@ class TsGenerator : public BaseGenerator {
|
||||
case BASE_TYPE_STRING:
|
||||
case BASE_TYPE_UNION:
|
||||
case BASE_TYPE_STRUCT: {
|
||||
return null_keyword_;
|
||||
return "null";
|
||||
}
|
||||
|
||||
case BASE_TYPE_ARRAY:
|
||||
@@ -560,16 +554,16 @@ class TsGenerator : public BaseGenerator {
|
||||
} else {
|
||||
name = AddImport(imports, owner, *type.struct_def).name;
|
||||
}
|
||||
return allowNull ? (name + "|" + null_keyword_) : name;
|
||||
return allowNull ? (name + "|null") : name;
|
||||
}
|
||||
}
|
||||
|
||||
switch (type.base_type) {
|
||||
case BASE_TYPE_BOOL:
|
||||
return allowNull ? ("boolean|" + null_keyword_) : "boolean";
|
||||
return allowNull ? "boolean|null" : "boolean";
|
||||
case BASE_TYPE_LONG:
|
||||
case BASE_TYPE_ULONG:
|
||||
return allowNull ? ("bigint|" + null_keyword_) : "bigint";
|
||||
return allowNull ? "bigint|null" : "bigint";
|
||||
case BASE_TYPE_ARRAY: {
|
||||
std::string name;
|
||||
if (type.element == BASE_TYPE_LONG || type.element == BASE_TYPE_ULONG) {
|
||||
@@ -584,16 +578,16 @@ class TsGenerator : public BaseGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
return name + (allowNull ? ("|" + null_keyword_) : "");
|
||||
return name + (allowNull ? "|null" : "");
|
||||
}
|
||||
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_keyword_) : enum_name;
|
||||
return allowNull ? (enum_name + "|null") : enum_name;
|
||||
}
|
||||
return allowNull ? ("number|" + null_keyword_) : "number";
|
||||
return allowNull ? "number|null" : "number";
|
||||
}
|
||||
return "flatbuffers.Offset";
|
||||
}
|
||||
@@ -1045,8 +1039,7 @@ 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_keyword_;
|
||||
const auto valid_union_type_with_null = valid_union_type + "|null";
|
||||
|
||||
auto ret = "\n\nexport function " + GenUnionConvFuncName(enum_def) +
|
||||
"(\n type: " + GetTypeName(enum_def) +
|
||||
@@ -1058,7 +1051,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_keyword_ + "; \n";
|
||||
ret += " case 'NONE': return null; \n";
|
||||
|
||||
for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end();
|
||||
++it) {
|
||||
@@ -1082,7 +1075,7 @@ class TsGenerator : public BaseGenerator {
|
||||
ret += "\n";
|
||||
}
|
||||
|
||||
ret += " default: return " + null_keyword_ + ";\n";
|
||||
ret += " default: return null;\n";
|
||||
ret += " }\n";
|
||||
};
|
||||
|
||||
@@ -1127,8 +1120,7 @@ class TsGenerator : public BaseGenerator {
|
||||
ret += " const temp = " + conversion_function + "(this." +
|
||||
namer_.Method(field_name, "Type") + "(), " +
|
||||
field_binded_method + ");\n";
|
||||
ret += " if(temp === " + null_keyword_ + ") { return " +
|
||||
null_keyword_ + "; }\n";
|
||||
ret += " if(temp === null) { return null; }\n";
|
||||
ret += union_has_string
|
||||
? " if(typeof temp === 'string') { return temp; }\n"
|
||||
: "";
|
||||
@@ -1148,12 +1140,12 @@ class TsGenerator : public BaseGenerator {
|
||||
"++targetEnumIndex) {\n";
|
||||
ret += " const targetEnum = this." +
|
||||
namer_.Method(field_name, "Type") + "(targetEnumIndex);\n";
|
||||
ret += " if(targetEnum === " + null_keyword_ + " || " + enum_type +
|
||||
ret += " if(targetEnum === null || " + enum_type +
|
||||
"[targetEnum!] === 'NONE') { "
|
||||
"continue; }\n\n";
|
||||
ret += " const temp = " + conversion_function + "(targetEnum, " +
|
||||
field_binded_method + ", targetEnumIndex);\n";
|
||||
ret += " if(temp === " + null_keyword_ + ") { continue; }\n";
|
||||
ret += " if(temp === null) { continue; }\n";
|
||||
ret += union_has_string ? " if(typeof temp === 'string') { "
|
||||
"ret.push(temp); continue; }\n"
|
||||
: "";
|
||||
@@ -1170,11 +1162,11 @@ class TsGenerator : public BaseGenerator {
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string GenNullCheckConditional(const std::string& nullCheckVar,
|
||||
const std::string& trueVal,
|
||||
const std::string& falseVal) {
|
||||
return "(" + nullCheckVar + " !== " + null_keyword_ + " ? " + trueVal +
|
||||
" : " + falseVal + ")";
|
||||
static std::string GenNullCheckConditional(
|
||||
const std::string& nullCheckVar, const std::string& trueVal,
|
||||
const std::string& falseVal = "null") {
|
||||
return "(" + nullCheckVar + " !== null ? " + trueVal + " : " + falseVal +
|
||||
")";
|
||||
}
|
||||
|
||||
std::string GenStructMemberValueTS(const StructDef& struct_def,
|
||||
@@ -1308,8 +1300,8 @@ class TsGenerator : public BaseGenerator {
|
||||
|
||||
const std::string field_accessor =
|
||||
"this." + namer_.Method(field) + "()";
|
||||
field_val = GenNullCheckConditional(
|
||||
field_accessor, field_accessor + "!.unpack()", null_keyword_);
|
||||
field_val = GenNullCheckConditional(field_accessor,
|
||||
field_accessor + "!.unpack()");
|
||||
auto packing = GenNullCheckConditional(
|
||||
"this." + field_field,
|
||||
"this." + field_field + "!.pack(builder)", "0");
|
||||
@@ -1517,8 +1509,8 @@ class TsGenerator : public BaseGenerator {
|
||||
break;
|
||||
}
|
||||
|
||||
// length 0 vector is simply empty instead of null/undefined.
|
||||
field_type += is_vector ? "" : ("|" + null_keyword_);
|
||||
// length 0 vector is simply empty instead of null
|
||||
field_type += is_vector ? "" : "|null";
|
||||
}
|
||||
|
||||
if (!field_offset_decl.empty()) {
|
||||
@@ -1547,7 +1539,7 @@ class TsGenerator : public BaseGenerator {
|
||||
} else {
|
||||
if (field.IsScalarOptional()) {
|
||||
pack_func_create_call +=
|
||||
" if (" + field_offset_val + " !== " + null_keyword_ + ")\n ";
|
||||
" if (" + field_offset_val + " !== null)\n ";
|
||||
}
|
||||
pack_func_create_call += " " + struct_name + "." +
|
||||
namer_.Method("add", field) + "(builder, " +
|
||||
@@ -1637,8 +1629,7 @@ class TsGenerator : public BaseGenerator {
|
||||
"> {\n";
|
||||
else
|
||||
code += " {\n";
|
||||
code += " bb: flatbuffers.ByteBuffer|" + null_keyword_ + " = " +
|
||||
null_keyword_ + ";\n";
|
||||
code += " bb: flatbuffers.ByteBuffer|null = null;\n";
|
||||
code += " bb_pos = 0;\n";
|
||||
|
||||
// Generate the __init method that sets the field in a pre-existing
|
||||
@@ -1690,7 +1681,7 @@ class TsGenerator : public BaseGenerator {
|
||||
GenDocComment(field.doc_comment, code_ptr);
|
||||
std::string prefix = namer_.Method(field) + "(";
|
||||
if (is_string) {
|
||||
code += prefix + "):string|" + null_keyword_ + "\n";
|
||||
code += prefix + "):string|null\n";
|
||||
code +=
|
||||
prefix + "optionalEncoding:flatbuffers.Encoding" + "):" +
|
||||
GenTypeName(imports, struct_def, field.value.type, false, true) +
|
||||
@@ -1740,8 +1731,7 @@ class TsGenerator : public BaseGenerator {
|
||||
.name;
|
||||
GenDocComment(field.doc_comment, code_ptr);
|
||||
code += namer_.Method(field);
|
||||
code +=
|
||||
"(obj?:" + type + "):" + type + "|" + null_keyword_ + " {\n";
|
||||
code += "(obj?:" + type + "):" + type + "|null {\n";
|
||||
|
||||
if (struct_def.fixed) {
|
||||
code += " return (obj || " + GenerateNewExpression(type);
|
||||
@@ -1754,7 +1744,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_keyword_ + ";\n";
|
||||
code += ", " + GenBBAccess() + ") : null;\n";
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -1807,7 +1797,7 @@ class TsGenerator : public BaseGenerator {
|
||||
} else {
|
||||
code += prefix;
|
||||
}
|
||||
code += "):" + vectortypename + "|" + null_keyword_ + " {\n";
|
||||
code += "):" + vectortypename + "|null {\n";
|
||||
|
||||
if (vectortype.base_type == BASE_TYPE_STRUCT) {
|
||||
code += offset_prefix + "(obj || " +
|
||||
@@ -1847,7 +1837,7 @@ class TsGenerator : public BaseGenerator {
|
||||
code += " : 0";
|
||||
}
|
||||
} else {
|
||||
code += ": " + null_keyword_;
|
||||
code += ": null";
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1905,7 +1895,7 @@ class TsGenerator : public BaseGenerator {
|
||||
} else {
|
||||
code += prefix;
|
||||
}
|
||||
code += "):" + vectortypename + "|" + null_keyword_ + " {\n";
|
||||
code += "):" + vectortypename + "|null {\n";
|
||||
|
||||
if (vectortype.base_type == BASE_TYPE_STRUCT) {
|
||||
code += offset_prefix + "(obj || " +
|
||||
@@ -1931,12 +1921,12 @@ class TsGenerator : public BaseGenerator {
|
||||
code += "BigInt(0)";
|
||||
} else if (IsScalar(field.value.type.element)) {
|
||||
if (field.value.type.enum_def) {
|
||||
code += null_keyword_;
|
||||
code += "null";
|
||||
} else {
|
||||
code += "0";
|
||||
}
|
||||
} else {
|
||||
code += null_keyword_;
|
||||
code += "null";
|
||||
}
|
||||
code += ";\n";
|
||||
break;
|
||||
@@ -1949,13 +1939,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_keyword_ +
|
||||
" "
|
||||
"):" + union_type +
|
||||
"|null "
|
||||
"{\n";
|
||||
|
||||
code += offset_prefix +
|
||||
GenGetter(field.value.type, "(obj, this.bb_pos + offset)") +
|
||||
" : " + null_keyword_ + ";\n";
|
||||
" : null;\n";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -2017,15 +2007,14 @@ class TsGenerator : public BaseGenerator {
|
||||
GenDocComment(code_ptr);
|
||||
|
||||
code += namer_.Method(field, "Array");
|
||||
code += "():" + GenType(vectorType) + "Array|" + null_keyword_ +
|
||||
" {\n" + offset_prefix;
|
||||
code +=
|
||||
"():" + GenType(vectorType) + "Array|null {\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_keyword_ +
|
||||
";\n}\n\n";
|
||||
".__vector_len(this.bb_pos + offset)) : null;\n}\n\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2095,7 +2084,7 @@ class TsGenerator : public BaseGenerator {
|
||||
if (!IsScalar(field.value.type.base_type)) {
|
||||
code += "0";
|
||||
} else if (HasNullDefault(field)) {
|
||||
code += null_keyword_;
|
||||
code += "null";
|
||||
} else {
|
||||
if (field.value.type.base_type == BASE_TYPE_BOOL) {
|
||||
code += "+";
|
||||
@@ -2212,7 +2201,7 @@ class TsGenerator : public BaseGenerator {
|
||||
const auto arg_name = GetArgName(field);
|
||||
|
||||
if (field.IsScalarOptional()) {
|
||||
code += " if (" + arg_name + " !== " + null_keyword_ + ")\n ";
|
||||
code += " if (" + arg_name + " !== null)\n ";
|
||||
}
|
||||
|
||||
code += " " + methodPrefix + "." + namer_.Method("add", field) + "(";
|
||||
@@ -2252,7 +2241,7 @@ class TsGenerator : public BaseGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
bool HasNullDefault(const FieldDef& field) {
|
||||
static bool HasNullDefault(const FieldDef& field) {
|
||||
return field.IsOptional() && field.value.constant == "null";
|
||||
}
|
||||
|
||||
|
||||
@@ -1286,55 +1286,6 @@ CheckedError Parser::ParseField(StructDef& struct_def) {
|
||||
"'native_inline' can only be defined on structs, vector of structs or "
|
||||
"vector of tables");
|
||||
|
||||
// `bigfoot_ref` is Bigfoot's single-purpose replacement for the old,
|
||||
// general-purpose `native_type_template`/`native_type_template_arg` pair:
|
||||
// a field typed as a `bigfoot_ref_wrapper`-tagged struct (HardReference or
|
||||
// SoftReference) and annotated `bigfoot_ref: "::Bigfoot::AssetX"` gets its
|
||||
// native type instantiated as `<wrapper><::Bigfoot::AssetX>`, plus (unlike
|
||||
// the old mechanism) a forward declaration of AssetX and inline Pack/UnPack
|
||||
// definitions are emitted directly into the generated header - see
|
||||
// GenerateBigfootRefDecls in idl_gen_cpp.cpp.
|
||||
auto bigfoot_ref = field->attributes.Lookup("bigfoot_ref");
|
||||
if (bigfoot_ref) {
|
||||
if (!IsStruct(field->value.type) && !IsVectorOfStruct(field->value.type))
|
||||
return Error(
|
||||
"'bigfoot_ref' can only be defined on struct-typed fields or "
|
||||
"vectors of structs");
|
||||
const auto* target_struct = field->value.type.struct_def;
|
||||
const auto* wrapper = target_struct->attributes.Lookup("bigfoot_ref_wrapper");
|
||||
if (!wrapper)
|
||||
return Error(
|
||||
"'bigfoot_ref' requires the field's type ('" + target_struct->name +
|
||||
"') to declare a 'bigfoot_ref_wrapper' attribute");
|
||||
if (field->attributes.Lookup("native_type"))
|
||||
return Error(
|
||||
"'bigfoot_ref' cannot be combined with an explicit 'native_type' "
|
||||
"on the same field");
|
||||
|
||||
const auto b = bigfoot_ref->constant.find_first_not_of(" \t");
|
||||
const auto e = bigfoot_ref->constant.find_last_not_of(" \t");
|
||||
const std::string asset_type =
|
||||
b == std::string::npos ? "" : bigfoot_ref->constant.substr(b, e - b + 1);
|
||||
if (asset_type.empty())
|
||||
return Error("'bigfoot_ref' cannot be empty");
|
||||
|
||||
auto native_type_val = new Value();
|
||||
native_type_val->type = bigfoot_ref->type;
|
||||
native_type_val->constant = wrapper->constant + "<" + asset_type + ">";
|
||||
field->attributes.Add("native_type", native_type_val);
|
||||
|
||||
if (!field->attributes.Lookup("native_type_pack_name")) {
|
||||
const auto last_colon = asset_type.find_last_of(':');
|
||||
const std::string asset_short_name =
|
||||
last_colon == std::string::npos ? asset_type
|
||||
: asset_type.substr(last_colon + 1);
|
||||
auto pack_name_val = new Value();
|
||||
pack_name_val->type = bigfoot_ref->type;
|
||||
pack_name_val->constant = target_struct->name + asset_short_name;
|
||||
field->attributes.Add("native_type_pack_name", pack_name_val);
|
||||
}
|
||||
}
|
||||
|
||||
auto nested = field->attributes.Lookup("nested_flatbuffer");
|
||||
if (nested) {
|
||||
if (nested->type.base_type != BASE_TYPE_STRING)
|
||||
@@ -2804,42 +2755,6 @@ 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 |
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
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",
|
||||
],
|
||||
)
|
||||
@@ -0,0 +1,29 @@
|
||||
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",
|
||||
],
|
||||
)
|
||||
@@ -1,222 +0,0 @@
|
||||
// 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_
|
||||
@@ -1,246 +0,0 @@
|
||||
// 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_generated.h"
|
||||
#include "tests/64bit/evolution/v2_generated.h"
|
||||
#include "tests/64bit/test_64bit_generated.h"
|
||||
#include "tests/64bit/evolution/v1.fbs.h"
|
||||
#include "tests/64bit/evolution/v2.fbs.h"
|
||||
#include "tests/64bit/test_64bit.fbs.h"
|
||||
#include "tests/test_assert.h"
|
||||
|
||||
namespace flatbuffers {
|
||||
|
||||
@@ -1,683 +0,0 @@
|
||||
// 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_
|
||||
+96
-50
@@ -24,21 +24,12 @@ 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",
|
||||
@@ -46,18 +37,13 @@ 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",
|
||||
@@ -71,16 +57,10 @@ 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/vector_table_naked_ptr_generated.h",
|
||||
"vector_table_naked_ptr_test.h",
|
||||
"vector_table_naked_ptr_test.cpp",
|
||||
"test_vector_type.h",
|
||||
"cpp_vector_type_test.h",
|
||||
"cpp_vector_type_test.cpp",
|
||||
"vector_table_naked_ptr_test.h",
|
||||
],
|
||||
copts = [
|
||||
"-DFLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE",
|
||||
@@ -90,13 +70,8 @@ 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",
|
||||
@@ -107,7 +82,6 @@ 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",
|
||||
@@ -129,8 +103,8 @@ cc_test(
|
||||
":prototest/twice-id.proto",
|
||||
":prototest/use-reserved-id.proto",
|
||||
":unicode_test.json",
|
||||
":union_vector/union_vector.fbs",
|
||||
":union_vector/union_vector.json",
|
||||
"//tests/evolution_test:test_data",
|
||||
"//tests/union_vector:test_data",
|
||||
],
|
||||
includes = [
|
||||
"",
|
||||
@@ -139,13 +113,21 @@ cc_test(
|
||||
deps = [
|
||||
":alignment_test_cc_fbs",
|
||||
":arrays_test_cc_fbs",
|
||||
":cpp_vector_type_cc_fbs",
|
||||
":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",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -155,7 +137,10 @@ cc_library(
|
||||
name = "test_assert",
|
||||
srcs = ["test_assert.cpp"],
|
||||
hdrs = ["test_assert.h"],
|
||||
visibility = ["//grpc/tests:__subpackages__"],
|
||||
visibility = [
|
||||
"//grpc/tests:__subpackages__",
|
||||
"//tests:__subpackages__",
|
||||
],
|
||||
deps = ["//:flatbuffers"],
|
||||
)
|
||||
|
||||
@@ -249,11 +234,20 @@ 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",
|
||||
@@ -262,40 +256,26 @@ 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",
|
||||
],
|
||||
)
|
||||
|
||||
flatbuffer_cc_library(
|
||||
name = "cpp_vector_type_cc_fbs",
|
||||
srcs = ["cpp_vector_type.fbs"],
|
||||
flatc_args = [
|
||||
"--gen-compare",
|
||||
"--gen-mutable",
|
||||
"--gen-object-api",
|
||||
"--reflect-names",
|
||||
"--cpp-include test_vector_type.h",
|
||||
"--cpp-vector-type ::flatbuffers::tests::CustomVector",
|
||||
"--filename-suffix .fbs",
|
||||
],
|
||||
)
|
||||
|
||||
flatbuffer_cc_library(
|
||||
name = "alignment_test_cc_fbs",
|
||||
srcs = ["alignment_test.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",
|
||||
@@ -303,5 +283,71 @@ flatbuffer_cc_library(
|
||||
"--reflect-names",
|
||||
"--filename-suffix .fbs",
|
||||
],
|
||||
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",
|
||||
"--gen-object-api",
|
||||
"--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",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright 2014 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -90,9 +90,6 @@ 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));
|
||||
@@ -105,8 +102,6 @@ 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)
|
||||
@@ -290,13 +285,6 @@ 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]
|
||||
|
||||
@@ -1,249 +0,0 @@
|
||||
/*
|
||||
* 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,12 +19,6 @@ 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); }
|
||||
@@ -32,12 +26,6 @@ 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) {
|
||||
|
||||
@@ -1,150 +0,0 @@
|
||||
// <auto-generated>
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// </auto-generated>
|
||||
|
||||
namespace MyGame.Example
|
||||
{
|
||||
|
||||
using global::System;
|
||||
using global::System.Collections.Generic;
|
||||
using global::Google.FlatBuffers;
|
||||
|
||||
public struct LargeArrayStruct : IFlatbufferObject
|
||||
{
|
||||
private Struct __p;
|
||||
public ByteBuffer ByteBuffer { get { return __p.bb; } }
|
||||
public void __init(int _i, ByteBuffer _bb) { __p = new Struct(_i, _bb); }
|
||||
public LargeArrayStruct __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
public byte D(int j) { return __p.bb.Get(__p.bb_pos + 0 + j * 1); }
|
||||
public const int DLength = 64;
|
||||
#if ENABLE_SPAN_T
|
||||
public Span<byte> GetDBytes() { return __p.bb.ToSpan(__p.bb_pos + 0, 64); }
|
||||
#else
|
||||
public ArraySegment<byte>? GetDBytes() { return __p.bb.ToArraySegment(__p.bb_pos + 0, 64);}
|
||||
#endif
|
||||
public void MutateD(int j, byte d) { __p.bb.Put(__p.bb_pos + 0 + j * 1, d); }
|
||||
public float E(int j) { return __p.bb.GetFloat(__p.bb_pos + 64 + j * 4); }
|
||||
public const int ELength = 64;
|
||||
#if ENABLE_SPAN_T
|
||||
public Span<float> GetEBytes() { return System.Runtime.InteropServices.MemoryMarshal.Cast<byte, float>(__p.bb.ToSpan(__p.bb_pos + 64, 256)); }
|
||||
#else
|
||||
public ArraySegment<byte>? GetEBytes() { return __p.bb.ToArraySegment(__p.bb_pos + 64, 256);}
|
||||
#endif
|
||||
public void MutateE(int j, float e) { __p.bb.PutFloat(__p.bb_pos + 64 + j * 4, e); }
|
||||
public bool F(int j) { return 0!=__p.bb.Get(__p.bb_pos + 320 + j * 1); }
|
||||
public const int FLength = 64;
|
||||
#if ENABLE_SPAN_T
|
||||
public Span<bool> GetFBytes() { return System.Runtime.InteropServices.MemoryMarshal.Cast<byte, bool>(__p.bb.ToSpan(__p.bb_pos + 320, 64)); }
|
||||
#else
|
||||
public ArraySegment<byte>? GetFBytes() { return __p.bb.ToArraySegment(__p.bb_pos + 320, 64);}
|
||||
#endif
|
||||
public void MutateF(int j, bool f) { __p.bb.Put(__p.bb_pos + 320 + j * 1, (byte)(f ? 1 : 0)); }
|
||||
public MyGame.Example.NestedStruct G(int j) { return (new MyGame.Example.NestedStruct()).__assign(__p.bb_pos + 384 + j * 32, __p.bb); }
|
||||
public MyGame.Example.TestEnum H(int j) { return (MyGame.Example.TestEnum)__p.bb.GetSbyte(__p.bb_pos + 2432 + j * 1); }
|
||||
public const int HLength = 64;
|
||||
#if ENABLE_SPAN_T
|
||||
public Span<MyGame.Example.TestEnum> GetHBytes() { return System.Runtime.InteropServices.MemoryMarshal.Cast<byte, MyGame.Example.TestEnum>(__p.bb.ToSpan(__p.bb_pos + 2432, 64)); }
|
||||
#else
|
||||
public ArraySegment<byte>? GetHBytes() { return __p.bb.ToArraySegment(__p.bb_pos + 2432, 64);}
|
||||
#endif
|
||||
public void MutateH(int j, MyGame.Example.TestEnum h) { __p.bb.PutSbyte(__p.bb_pos + 2432 + j * 1, (sbyte)h); }
|
||||
|
||||
public static Offset<MyGame.Example.LargeArrayStruct> CreateLargeArrayStruct(FlatBufferBuilder builder, byte[] D, float[] E, bool[] F, int[,] g_A, MyGame.Example.TestEnum[] g_B, MyGame.Example.TestEnum[,] g_C, long[,] g_D, MyGame.Example.TestEnum[] H) {
|
||||
builder.Prep(8, 2496);
|
||||
for (int _idx0 = 64; _idx0 > 0; _idx0--) {
|
||||
builder.PutSbyte((sbyte)H[_idx0-1]);
|
||||
}
|
||||
for (int _idx0 = 64; _idx0 > 0; _idx0--) {
|
||||
builder.Prep(8, 32);
|
||||
for (int _idx1 = 2; _idx1 > 0; _idx1--) {
|
||||
builder.PutLong(g_D[_idx0-1,_idx1-1]);
|
||||
}
|
||||
builder.Pad(5);
|
||||
for (int _idx1 = 2; _idx1 > 0; _idx1--) {
|
||||
builder.PutSbyte((sbyte)g_C[_idx0-1,_idx1-1]);
|
||||
}
|
||||
builder.PutSbyte((sbyte)g_B[_idx0-1]);
|
||||
for (int _idx1 = 2; _idx1 > 0; _idx1--) {
|
||||
builder.PutInt(g_A[_idx0-1,_idx1-1]);
|
||||
}
|
||||
}
|
||||
for (int _idx0 = 64; _idx0 > 0; _idx0--) {
|
||||
builder.PutBool(F[_idx0-1]);
|
||||
}
|
||||
for (int _idx0 = 64; _idx0 > 0; _idx0--) {
|
||||
builder.PutFloat(E[_idx0-1]);
|
||||
}
|
||||
for (int _idx0 = 64; _idx0 > 0; _idx0--) {
|
||||
builder.PutByte(D[_idx0-1]);
|
||||
}
|
||||
return new Offset<MyGame.Example.LargeArrayStruct>(builder.Offset);
|
||||
}
|
||||
public LargeArrayStructT UnPack() {
|
||||
var _o = new LargeArrayStructT();
|
||||
this.UnPackTo(_o);
|
||||
return _o;
|
||||
}
|
||||
public void UnPackTo(LargeArrayStructT _o) {
|
||||
_o.D = new byte[64];
|
||||
for (var _j = 0; _j < 64; ++_j) { _o.D[_j] = this.D(_j); }
|
||||
_o.E = new float[64];
|
||||
for (var _j = 0; _j < 64; ++_j) { _o.E[_j] = this.E(_j); }
|
||||
_o.F = new bool[64];
|
||||
for (var _j = 0; _j < 64; ++_j) { _o.F[_j] = this.F(_j); }
|
||||
_o.G = new MyGame.Example.NestedStructT[64];
|
||||
for (var _j = 0; _j < 64; ++_j) { _o.G[_j] = this.G(_j).UnPack(); }
|
||||
_o.H = new MyGame.Example.TestEnum[64];
|
||||
for (var _j = 0; _j < 64; ++_j) { _o.H[_j] = this.H(_j); }
|
||||
}
|
||||
public static Offset<MyGame.Example.LargeArrayStruct> Pack(FlatBufferBuilder builder, LargeArrayStructT _o) {
|
||||
if (_o == null) return default(Offset<MyGame.Example.LargeArrayStruct>);
|
||||
var _d = _o.D;
|
||||
var _e = _o.E;
|
||||
var _f = _o.F;
|
||||
var _g_a = new int[64,2];
|
||||
for (var idx0 = 0; idx0 < 64; ++idx0) {for (var idx1 = 0; idx1 < 2; ++idx1) {_g_a[idx0,idx1] = _o.G[idx0].A[idx1];}}
|
||||
var _g_b = new MyGame.Example.TestEnum[64];
|
||||
for (var idx0 = 0; idx0 < 64; ++idx0) {_g_b[idx0] = _o.G[idx0].B;}
|
||||
var _g_c = new MyGame.Example.TestEnum[64,2];
|
||||
for (var idx0 = 0; idx0 < 64; ++idx0) {for (var idx1 = 0; idx1 < 2; ++idx1) {_g_c[idx0,idx1] = _o.G[idx0].C[idx1];}}
|
||||
var _g_d = new long[64,2];
|
||||
for (var idx0 = 0; idx0 < 64; ++idx0) {for (var idx1 = 0; idx1 < 2; ++idx1) {_g_d[idx0,idx1] = _o.G[idx0].D[idx1];}}
|
||||
var _h = _o.H;
|
||||
return CreateLargeArrayStruct(
|
||||
builder,
|
||||
_d,
|
||||
_e,
|
||||
_f,
|
||||
_g_a,
|
||||
_g_b,
|
||||
_g_c,
|
||||
_g_d,
|
||||
_h);
|
||||
}
|
||||
}
|
||||
|
||||
public class LargeArrayStructT
|
||||
{
|
||||
[Newtonsoft.Json.JsonProperty("d")]
|
||||
public byte[] D { get; set; }
|
||||
[Newtonsoft.Json.JsonProperty("e")]
|
||||
public float[] E { get; set; }
|
||||
[Newtonsoft.Json.JsonProperty("f")]
|
||||
public bool[] F { get; set; }
|
||||
[Newtonsoft.Json.JsonProperty("g")]
|
||||
public MyGame.Example.NestedStructT[] G { get; set; }
|
||||
[Newtonsoft.Json.JsonProperty("h")]
|
||||
public MyGame.Example.TestEnum[] H { get; set; }
|
||||
|
||||
public LargeArrayStructT() {
|
||||
this.D = new byte[64];
|
||||
this.E = new float[64];
|
||||
this.F = new bool[64];
|
||||
this.G = new MyGame.Example.NestedStructT[64];
|
||||
this.H = new MyGame.Example.TestEnum[64];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package MyGame.Example;
|
||||
|
||||
import com.google.flatbuffers.BaseVector;
|
||||
import com.google.flatbuffers.BooleanVector;
|
||||
import com.google.flatbuffers.ByteVector;
|
||||
import com.google.flatbuffers.Constants;
|
||||
import com.google.flatbuffers.DoubleVector;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.google.flatbuffers.FloatVector;
|
||||
import com.google.flatbuffers.IntVector;
|
||||
import com.google.flatbuffers.LongVector;
|
||||
import com.google.flatbuffers.ShortVector;
|
||||
import com.google.flatbuffers.StringVector;
|
||||
import com.google.flatbuffers.Struct;
|
||||
import com.google.flatbuffers.UnionVector;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class LargeArrayStruct extends Struct {
|
||||
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||
public LargeArrayStruct __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
public int d(int j) { return bb.get(bb_pos + 0 + j * 1); }
|
||||
public void mutateD(int j, int d) { bb.put(bb_pos + 0 + j * 1, (byte) d); }
|
||||
public float e(int j) { return bb.getFloat(bb_pos + 64 + j * 4); }
|
||||
public void mutateE(int j, float e) { bb.putFloat(bb_pos + 64 + j * 4, e); }
|
||||
public boolean f(int j) { return 0!=bb.get(bb_pos + 320 + j * 1); }
|
||||
public void mutateF(int j, boolean f) { bb.put(bb_pos + 320 + j * 1, (byte)(f ? 1 : 0)); }
|
||||
public MyGame.Example.NestedStruct g(int j) { return g(new MyGame.Example.NestedStruct(), j); }
|
||||
public MyGame.Example.NestedStruct g(MyGame.Example.NestedStruct obj, int j) { return obj.__assign(bb_pos + 384 + j * 32, bb); }
|
||||
public byte h(int j) { return bb.get(bb_pos + 2432 + j * 1); }
|
||||
public void mutateH(int j, byte h) { bb.put(bb_pos + 2432 + j * 1, h); }
|
||||
|
||||
public static int createLargeArrayStruct(FlatBufferBuilder builder, int[] d, float[] e, boolean[] f, int[][] g_a, byte[] g_b, byte[][] g_c, long[][] g_d, byte[] h) {
|
||||
builder.prep(8, 2496);
|
||||
for (int _idx0 = 64; _idx0 > 0; _idx0--) {
|
||||
builder.putByte(h[_idx0-1]);
|
||||
}
|
||||
for (int _idx0 = 64; _idx0 > 0; _idx0--) {
|
||||
builder.prep(8, 32);
|
||||
for (int _idx1 = 2; _idx1 > 0; _idx1--) {
|
||||
builder.putLong(g_d[_idx0-1][_idx1-1]);
|
||||
}
|
||||
builder.pad(5);
|
||||
for (int _idx1 = 2; _idx1 > 0; _idx1--) {
|
||||
builder.putByte(g_c[_idx0-1][_idx1-1]);
|
||||
}
|
||||
builder.putByte(g_b[_idx0-1]);
|
||||
for (int _idx1 = 2; _idx1 > 0; _idx1--) {
|
||||
builder.putInt(g_a[_idx0-1][_idx1-1]);
|
||||
}
|
||||
}
|
||||
for (int _idx0 = 64; _idx0 > 0; _idx0--) {
|
||||
builder.putBoolean(f[_idx0-1]);
|
||||
}
|
||||
for (int _idx0 = 64; _idx0 > 0; _idx0--) {
|
||||
builder.putFloat(e[_idx0-1]);
|
||||
}
|
||||
for (int _idx0 = 64; _idx0 > 0; _idx0--) {
|
||||
builder.putByte((byte) d[_idx0-1]);
|
||||
}
|
||||
return builder.offset();
|
||||
}
|
||||
|
||||
public static final class Vector extends BaseVector {
|
||||
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
|
||||
|
||||
public LargeArrayStruct get(int j) { return get(new LargeArrayStruct(), j); }
|
||||
public LargeArrayStruct get(LargeArrayStruct obj, int j) { return obj.__assign(__element(j), bb); }
|
||||
}
|
||||
public LargeArrayStructT unpack() {
|
||||
LargeArrayStructT _o = new LargeArrayStructT();
|
||||
unpackTo(_o);
|
||||
return _o;
|
||||
}
|
||||
public void unpackTo(LargeArrayStructT _o) {
|
||||
int[] _oD = _o.getD();
|
||||
for (int _j = 0; _j < 64; ++_j) { _oD[_j] = d(_j); }
|
||||
float[] _oE = _o.getE();
|
||||
for (int _j = 0; _j < 64; ++_j) { _oE[_j] = e(_j); }
|
||||
boolean[] _oF = _o.getF();
|
||||
for (int _j = 0; _j < 64; ++_j) { _oF[_j] = f(_j); }
|
||||
MyGame.Example.NestedStructT[] _oG = _o.getG();
|
||||
for (int _j = 0; _j < 64; ++_j) { _oG[_j] = g(_j).unpack(); }
|
||||
byte[] _oH = _o.getH();
|
||||
for (int _j = 0; _j < 64; ++_j) { _oH[_j] = h(_j); }
|
||||
}
|
||||
public static int pack(FlatBufferBuilder builder, LargeArrayStructT _o) {
|
||||
if (_o == null) return 0;
|
||||
int[] _d = _o.getD();
|
||||
float[] _e = _o.getE();
|
||||
boolean[] _f = _o.getF();
|
||||
int[][] _g_a = new int[64][2];
|
||||
for (int idx0 = 0; idx0 < 64; ++idx0) {for (int idx1 = 0; idx1 < 2; ++idx1) {_g_a[idx0][idx1] = _o.getG()[idx0].getA()[idx1];}}
|
||||
byte[] _g_b = new byte[64];
|
||||
for (int idx0 = 0; idx0 < 64; ++idx0) {_g_b[idx0] = _o.getG()[idx0].getB();}
|
||||
byte[][] _g_c = new byte[64][2];
|
||||
for (int idx0 = 0; idx0 < 64; ++idx0) {for (int idx1 = 0; idx1 < 2; ++idx1) {_g_c[idx0][idx1] = _o.getG()[idx0].getC()[idx1];}}
|
||||
long[][] _g_d = new long[64][2];
|
||||
for (int idx0 = 0; idx0 < 64; ++idx0) {for (int idx1 = 0; idx1 < 2; ++idx1) {_g_d[idx0][idx1] = _o.getG()[idx0].getD()[idx1];}}
|
||||
byte[] _h = _o.getH();
|
||||
return createLargeArrayStruct(
|
||||
builder,
|
||||
_d,
|
||||
_e,
|
||||
_f,
|
||||
_g_a,
|
||||
_g_b,
|
||||
_g_c,
|
||||
_g_d,
|
||||
_h);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,226 +0,0 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: Example
|
||||
|
||||
import flatbuffers
|
||||
from flatbuffers.compat import import_numpy
|
||||
from typing import Any
|
||||
from MyGame.Example.NestedStruct import NestedStruct
|
||||
np = import_numpy()
|
||||
|
||||
class LargeArrayStruct(object):
|
||||
__slots__ = ['_tab']
|
||||
|
||||
@classmethod
|
||||
def SizeOf(cls) -> int:
|
||||
return 2496
|
||||
|
||||
# LargeArrayStruct
|
||||
def Init(self, buf: bytes, pos: int):
|
||||
self._tab = flatbuffers.table.Table(buf, pos)
|
||||
|
||||
# LargeArrayStruct
|
||||
def D(self, j = None):
|
||||
if j is None:
|
||||
return [self._tab.Get(flatbuffers.number_types.Uint8Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(0 + i * 1)) for i in range(self.DLength())]
|
||||
elif j >= 0 and j < self.DLength():
|
||||
return self._tab.Get(flatbuffers.number_types.Uint8Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(0 + j * 1))
|
||||
else:
|
||||
return None
|
||||
|
||||
# LargeArrayStruct
|
||||
def DAsNumpy(self):
|
||||
return self._tab.GetArrayAsNumpy(flatbuffers.number_types.Uint8Flags, self._tab.Pos + 0, self.DLength())
|
||||
|
||||
# LargeArrayStruct
|
||||
def DLength(self) -> int:
|
||||
return 64
|
||||
|
||||
# LargeArrayStruct
|
||||
def DIsNone(self) -> bool:
|
||||
return False
|
||||
|
||||
# LargeArrayStruct
|
||||
def E(self, j = None):
|
||||
if j is None:
|
||||
return [self._tab.Get(flatbuffers.number_types.Float32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(64 + i * 4)) for i in range(self.ELength())]
|
||||
elif j >= 0 and j < self.ELength():
|
||||
return self._tab.Get(flatbuffers.number_types.Float32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(64 + j * 4))
|
||||
else:
|
||||
return None
|
||||
|
||||
# LargeArrayStruct
|
||||
def EAsNumpy(self):
|
||||
return self._tab.GetArrayAsNumpy(flatbuffers.number_types.Float32Flags, self._tab.Pos + 64, self.ELength())
|
||||
|
||||
# LargeArrayStruct
|
||||
def ELength(self) -> int:
|
||||
return 64
|
||||
|
||||
# LargeArrayStruct
|
||||
def EIsNone(self) -> bool:
|
||||
return False
|
||||
|
||||
# LargeArrayStruct
|
||||
def F(self, j = None):
|
||||
if j is None:
|
||||
return [self._tab.Get(flatbuffers.number_types.BoolFlags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(320 + i * 1)) for i in range(self.FLength())]
|
||||
elif j >= 0 and j < self.FLength():
|
||||
return self._tab.Get(flatbuffers.number_types.BoolFlags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(320 + j * 1))
|
||||
else:
|
||||
return None
|
||||
|
||||
# LargeArrayStruct
|
||||
def FAsNumpy(self):
|
||||
return self._tab.GetArrayAsNumpy(flatbuffers.number_types.BoolFlags, self._tab.Pos + 320, self.FLength())
|
||||
|
||||
# LargeArrayStruct
|
||||
def FLength(self) -> int:
|
||||
return 64
|
||||
|
||||
# LargeArrayStruct
|
||||
def FIsNone(self) -> bool:
|
||||
return False
|
||||
|
||||
# LargeArrayStruct
|
||||
def G(self, i: int) -> NestedStruct:
|
||||
obj = NestedStruct()
|
||||
obj.Init(self._tab.Bytes, self._tab.Pos + 384 + i * 32)
|
||||
return obj
|
||||
|
||||
# LargeArrayStruct
|
||||
def GLength(self) -> int:
|
||||
return 64
|
||||
|
||||
# LargeArrayStruct
|
||||
def GIsNone(self) -> bool:
|
||||
return False
|
||||
|
||||
# LargeArrayStruct
|
||||
def H(self, j = None):
|
||||
if j is None:
|
||||
return [self._tab.Get(flatbuffers.number_types.Int8Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(2432 + i * 1)) for i in range(self.HLength())]
|
||||
elif j >= 0 and j < self.HLength():
|
||||
return self._tab.Get(flatbuffers.number_types.Int8Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(2432 + j * 1))
|
||||
else:
|
||||
return None
|
||||
|
||||
# LargeArrayStruct
|
||||
def HAsNumpy(self):
|
||||
return self._tab.GetArrayAsNumpy(flatbuffers.number_types.Int8Flags, self._tab.Pos + 2432, self.HLength())
|
||||
|
||||
# LargeArrayStruct
|
||||
def HLength(self) -> int:
|
||||
return 64
|
||||
|
||||
# LargeArrayStruct
|
||||
def HIsNone(self) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def CreateLargeArrayStruct(builder, d, e, f, g_a, g_b, g_c, g_d, h):
|
||||
builder.Prep(8, 2496)
|
||||
for _idx0 in range(64 , 0, -1):
|
||||
builder.PrependInt8(h[_idx0-1])
|
||||
for _idx0 in range(64 , 0, -1):
|
||||
builder.Prep(8, 32)
|
||||
for _idx1 in range(2 , 0, -1):
|
||||
builder.PrependInt64(g_d[_idx0-1][_idx1-1])
|
||||
builder.Pad(5)
|
||||
for _idx1 in range(2 , 0, -1):
|
||||
builder.PrependInt8(g_c[_idx0-1][_idx1-1])
|
||||
builder.PrependInt8(g_b[_idx0-1])
|
||||
for _idx1 in range(2 , 0, -1):
|
||||
builder.PrependInt32(g_a[_idx0-1][_idx1-1])
|
||||
for _idx0 in range(64 , 0, -1):
|
||||
builder.PrependBool(f[_idx0-1])
|
||||
for _idx0 in range(64 , 0, -1):
|
||||
builder.PrependFloat32(e[_idx0-1])
|
||||
for _idx0 in range(64 , 0, -1):
|
||||
builder.PrependUint8(d[_idx0-1])
|
||||
return builder.Offset()
|
||||
|
||||
import MyGame.Example.NestedStruct
|
||||
try:
|
||||
from typing import List
|
||||
except:
|
||||
pass
|
||||
|
||||
class LargeArrayStructT(object):
|
||||
|
||||
# LargeArrayStructT
|
||||
def __init__(
|
||||
self,
|
||||
d = None,
|
||||
e = None,
|
||||
f = None,
|
||||
g = None,
|
||||
h = None,
|
||||
):
|
||||
self.d = d # type: Optional[List[int]]
|
||||
self.e = e # type: Optional[List[float]]
|
||||
self.f = f # type: Optional[List[bool]]
|
||||
self.g = g # type: Optional[List[MyGame.Example.NestedStruct.NestedStructT]]
|
||||
self.h = h # type: Optional[List[int]]
|
||||
|
||||
@classmethod
|
||||
def InitFromBuf(cls, buf, pos):
|
||||
largeArrayStruct = LargeArrayStruct()
|
||||
largeArrayStruct.Init(buf, pos)
|
||||
return cls.InitFromObj(largeArrayStruct)
|
||||
|
||||
@classmethod
|
||||
def InitFromPackedBuf(cls, buf, pos=0):
|
||||
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
|
||||
return cls.InitFromBuf(buf, pos+n)
|
||||
|
||||
@classmethod
|
||||
def InitFromObj(cls, largeArrayStruct):
|
||||
x = LargeArrayStructT()
|
||||
x._UnPack(largeArrayStruct)
|
||||
return x
|
||||
|
||||
# LargeArrayStructT
|
||||
def _UnPack(self, largeArrayStruct):
|
||||
if largeArrayStruct is None:
|
||||
return
|
||||
if not largeArrayStruct.DIsNone():
|
||||
if np is None:
|
||||
self.d = []
|
||||
for i in range(largeArrayStruct.DLength()):
|
||||
self.d.append(largeArrayStruct.D(i))
|
||||
else:
|
||||
self.d = largeArrayStruct.DAsNumpy()
|
||||
if not largeArrayStruct.EIsNone():
|
||||
if np is None:
|
||||
self.e = []
|
||||
for i in range(largeArrayStruct.ELength()):
|
||||
self.e.append(largeArrayStruct.E(i))
|
||||
else:
|
||||
self.e = largeArrayStruct.EAsNumpy()
|
||||
if not largeArrayStruct.FIsNone():
|
||||
if np is None:
|
||||
self.f = []
|
||||
for i in range(largeArrayStruct.FLength()):
|
||||
self.f.append(largeArrayStruct.F(i))
|
||||
else:
|
||||
self.f = largeArrayStruct.FAsNumpy()
|
||||
if not largeArrayStruct.GIsNone():
|
||||
self.g = []
|
||||
for i in range(largeArrayStruct.GLength()):
|
||||
if largeArrayStruct.G(i) is None:
|
||||
self.g.append(None)
|
||||
else:
|
||||
nestedStruct_ = MyGame.Example.NestedStruct.NestedStructT.InitFromObj(largeArrayStruct.G(i))
|
||||
self.g.append(nestedStruct_)
|
||||
if not largeArrayStruct.HIsNone():
|
||||
if np is None:
|
||||
self.h = []
|
||||
for i in range(largeArrayStruct.HLength()):
|
||||
self.h.append(largeArrayStruct.H(i))
|
||||
else:
|
||||
self.h = largeArrayStruct.HAsNumpy()
|
||||
|
||||
# LargeArrayStructT
|
||||
def Pack(self, builder):
|
||||
return CreateLargeArrayStruct(builder, self.d, self.e, self.f, self.g.a, self.g.b, self.g.c, self.g.d, self.h)
|
||||
@@ -1,60 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import flatbuffers
|
||||
import numpy as np
|
||||
|
||||
import typing
|
||||
from MyGame.Example.NestedStruct import NestedStruct, NestedStructT
|
||||
from MyGame.Example.TestEnum import TestEnum
|
||||
|
||||
uoffset: typing.TypeAlias = flatbuffers.number_types.UOffsetTFlags.py_type
|
||||
|
||||
class LargeArrayStruct(object):
|
||||
@classmethod
|
||||
def SizeOf(cls) -> int: ...
|
||||
|
||||
def Init(self, buf: bytes, pos: int) -> None: ...
|
||||
def D(self, i: int) -> typing.List[int]: ...
|
||||
def DAsNumpy(self) -> np.ndarray: ...
|
||||
def DLength(self) -> int: ...
|
||||
def DIsNone(self) -> bool: ...
|
||||
def E(self, i: int) -> typing.List[float]: ...
|
||||
def EAsNumpy(self) -> np.ndarray: ...
|
||||
def ELength(self) -> int: ...
|
||||
def EIsNone(self) -> bool: ...
|
||||
def F(self, i: int) -> typing.List[bool]: ...
|
||||
def FAsNumpy(self) -> np.ndarray: ...
|
||||
def FLength(self) -> int: ...
|
||||
def FIsNone(self) -> bool: ...
|
||||
def G(self, i: int) -> NestedStruct | None: ...
|
||||
def GLength(self) -> int: ...
|
||||
def GIsNone(self) -> bool: ...
|
||||
def H(self, i: int) -> typing.Literal[TestEnum.A, TestEnum.B, TestEnum.C]: ...
|
||||
def HAsNumpy(self) -> np.ndarray: ...
|
||||
def HLength(self) -> int: ...
|
||||
def HIsNone(self) -> bool: ...
|
||||
class LargeArrayStructT(object):
|
||||
d: typing.List[int]
|
||||
e: typing.List[float]
|
||||
f: typing.List[bool]
|
||||
g: typing.List[NestedStructT]
|
||||
h: typing.List[typing.Literal[TestEnum.A, TestEnum.B, TestEnum.C]]
|
||||
def __init__(
|
||||
self,
|
||||
d: typing.List[int] | None = ...,
|
||||
e: typing.List[float] | None = ...,
|
||||
f: typing.List[bool] | None = ...,
|
||||
g: typing.List['NestedStructT'] | None = ...,
|
||||
h: typing.List[typing.Literal[TestEnum.A, TestEnum.B, TestEnum.C]] | None = ...,
|
||||
) -> None: ...
|
||||
@classmethod
|
||||
def InitFromBuf(cls, buf: bytes, pos: int) -> LargeArrayStructT: ...
|
||||
@classmethod
|
||||
def InitFromPackedBuf(cls, buf: bytes, pos: int = 0) -> LargeArrayStructT: ...
|
||||
@classmethod
|
||||
def InitFromObj(cls, largeArrayStruct: LargeArrayStruct) -> LargeArrayStructT: ...
|
||||
def _UnPack(self, largeArrayStruct: LargeArrayStruct) -> None: ...
|
||||
def Pack(self, builder: flatbuffers.Builder) -> None: ...
|
||||
|
||||
def CreateLargeArrayStruct(builder: flatbuffers.Builder, d: int, e: float, f: bool, g_a: int, g_b: typing.Literal[TestEnum.A, TestEnum.B, TestEnum.C], g_c: typing.Literal[TestEnum.A, TestEnum.B, TestEnum.C], g_d: int, h: typing.Literal[TestEnum.A, TestEnum.B, TestEnum.C]) -> uoffset: ...
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package MyGame.Example;
|
||||
|
||||
import com.google.flatbuffers.BaseVector;
|
||||
import com.google.flatbuffers.BooleanVector;
|
||||
import com.google.flatbuffers.ByteVector;
|
||||
import com.google.flatbuffers.Constants;
|
||||
import com.google.flatbuffers.DoubleVector;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.google.flatbuffers.FloatVector;
|
||||
import com.google.flatbuffers.IntVector;
|
||||
import com.google.flatbuffers.LongVector;
|
||||
import com.google.flatbuffers.ShortVector;
|
||||
import com.google.flatbuffers.StringVector;
|
||||
import com.google.flatbuffers.Struct;
|
||||
import com.google.flatbuffers.UnionVector;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
public class LargeArrayStructT {
|
||||
private int[] d;
|
||||
private float[] e;
|
||||
private boolean[] f;
|
||||
private MyGame.Example.NestedStructT[] g;
|
||||
private byte[] h;
|
||||
|
||||
public int[] getD() { return d; }
|
||||
|
||||
public void setD(int[] d) { if (d != null && d.length == 64) this.d = d; }
|
||||
|
||||
public float[] getE() { return e; }
|
||||
|
||||
public void setE(float[] e) { if (e != null && e.length == 64) this.e = e; }
|
||||
|
||||
public boolean[] getF() { return f; }
|
||||
|
||||
public void setF(boolean[] f) { if (f != null && f.length == 64) this.f = f; }
|
||||
|
||||
public MyGame.Example.NestedStructT[] getG() { return g; }
|
||||
|
||||
public void setG(MyGame.Example.NestedStructT[] g) { if (g != null && g.length == 64) this.g = g; }
|
||||
|
||||
public byte[] getH() { return h; }
|
||||
|
||||
public void setH(byte[] h) { if (h != null && h.length == 64) this.h = h; }
|
||||
|
||||
|
||||
public LargeArrayStructT() {
|
||||
this.d = new int[64];
|
||||
this.e = new float[64];
|
||||
this.f = new boolean[64];
|
||||
this.g = new MyGame.Example.NestedStructT[64];
|
||||
this.h = new byte[64];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +28,6 @@ function Monster.New()
|
||||
return o
|
||||
end
|
||||
|
||||
local FileIdentifier = "MONS"
|
||||
|
||||
function Monster.GetRootAsMonster(buf, offset)
|
||||
if type(buf) == "string" then
|
||||
buf = flatbuffers.binaryArray.New(buf)
|
||||
@@ -1101,12 +1099,4 @@ 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,16 +914,6 @@ 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)
|
||||
|
||||
@@ -954,16 +944,6 @@ 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)
|
||||
|
||||
@@ -976,12 +956,6 @@ 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)
|
||||
|
||||
@@ -994,12 +968,6 @@ 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)
|
||||
|
||||
@@ -1018,16 +986,6 @@ 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)
|
||||
@@ -1107,16 +1065,6 @@ 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)
|
||||
|
||||
@@ -1147,12 +1095,6 @@ 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)
|
||||
|
||||
@@ -1165,16 +1107,6 @@ 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)
|
||||
|
||||
@@ -1187,16 +1119,6 @@ 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)
|
||||
|
||||
@@ -1209,16 +1131,6 @@ 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)
|
||||
|
||||
@@ -1231,16 +1143,6 @@ 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)
|
||||
|
||||
@@ -1253,16 +1155,6 @@ 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)
|
||||
|
||||
@@ -1281,12 +1173,6 @@ 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)
|
||||
|
||||
@@ -1305,16 +1191,6 @@ 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)
|
||||
|
||||
@@ -1327,12 +1203,6 @@ 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)
|
||||
|
||||
@@ -1351,16 +1221,6 @@ 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)
|
||||
|
||||
@@ -1379,16 +1239,6 @@ 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)
|
||||
|
||||
@@ -1425,16 +1275,6 @@ 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)
|
||||
|
||||
@@ -1453,16 +1293,6 @@ 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)
|
||||
@@ -1482,12 +1312,6 @@ 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,30 +17,12 @@ 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,16 +230,6 @@ 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)
|
||||
|
||||
@@ -252,16 +242,6 @@ 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,7 +5,6 @@
|
||||
import flatbuffers
|
||||
from flatbuffers.compat import import_numpy
|
||||
from typing import Any
|
||||
from typing import Iterable
|
||||
np = import_numpy()
|
||||
|
||||
class MonsterExtra(object):
|
||||
@@ -206,16 +205,6 @@ 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)
|
||||
|
||||
@@ -228,16 +217,6 @@ 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,13 +77,9 @@ 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_generated.h"
|
||||
#include "tests/alignment_test.fbs.h"
|
||||
|
||||
namespace flatbuffers {
|
||||
namespace tests {
|
||||
|
||||
@@ -1,921 +0,0 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// @generated
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
#[allow(unused_imports, dead_code)]
|
||||
pub mod my_game {
|
||||
|
||||
extern crate alloc;
|
||||
#[allow(unused_imports, dead_code)]
|
||||
pub mod example {
|
||||
|
||||
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_TEST_ENUM: i8 = 0;
|
||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||
pub const ENUM_MAX_TEST_ENUM: i8 = 2;
|
||||
#[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_TEST_ENUM: [TestEnum; 3] = [
|
||||
TestEnum::A,
|
||||
TestEnum::B,
|
||||
TestEnum::C,
|
||||
];
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||
#[repr(transparent)]
|
||||
pub struct TestEnum(pub i8);
|
||||
#[allow(non_upper_case_globals)]
|
||||
impl TestEnum {
|
||||
pub const A: Self = Self(0);
|
||||
pub const B: Self = Self(1);
|
||||
pub const C: Self = Self(2);
|
||||
|
||||
pub const ENUM_MIN: i8 = 0;
|
||||
pub const ENUM_MAX: i8 = 2;
|
||||
pub const ENUM_VALUES: &'static [Self] = &[
|
||||
Self::A,
|
||||
Self::B,
|
||||
Self::C,
|
||||
];
|
||||
/// Returns the variant's name or "" if unknown.
|
||||
pub fn variant_name(self) -> Option<&'static str> {
|
||||
match self {
|
||||
Self::A => Some("A"),
|
||||
Self::B => Some("B"),
|
||||
Self::C => Some("C"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl ::core::fmt::Debug for TestEnum {
|
||||
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 TestEnum {
|
||||
type Inner = Self;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
|
||||
Self(b)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::flatbuffers::Push for TestEnum {
|
||||
type Output = TestEnum;
|
||||
#[inline]
|
||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||
unsafe { ::flatbuffers::emplace_scalar::<i8>(dst, self.0) };
|
||||
}
|
||||
}
|
||||
|
||||
impl ::flatbuffers::EndianScalar for TestEnum {
|
||||
type Scalar = i8;
|
||||
#[inline]
|
||||
fn to_little_endian(self) -> i8 {
|
||||
self.0.to_le()
|
||||
}
|
||||
#[inline]
|
||||
#[allow(clippy::wrong_self_convention)]
|
||||
fn from_little_endian(v: i8) -> Self {
|
||||
let b = i8::from_le(v);
|
||||
Self(b)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ::flatbuffers::Verifiable for TestEnum {
|
||||
#[inline]
|
||||
fn run_verifier(
|
||||
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||
i8::run_verifier(v, pos)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::flatbuffers::SimpleToVerifyInSlice for TestEnum {}
|
||||
// struct NestedStruct, aligned to 8
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
pub struct NestedStruct(pub [u8; 32]);
|
||||
impl Default for NestedStruct {
|
||||
fn default() -> Self {
|
||||
Self([0; 32])
|
||||
}
|
||||
}
|
||||
impl ::core::fmt::Debug for NestedStruct {
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||
f.debug_struct("NestedStruct")
|
||||
.field("a", &self.a())
|
||||
.field("b", &self.b())
|
||||
.field("c", &self.c())
|
||||
.field("d", &self.d())
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl ::flatbuffers::SimpleToVerifyInSlice for NestedStruct {}
|
||||
impl<'a> ::flatbuffers::Follow<'a> for NestedStruct {
|
||||
type Inner = &'a NestedStruct;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
unsafe { <&'a NestedStruct>::follow(buf, loc) }
|
||||
}
|
||||
}
|
||||
impl<'a> ::flatbuffers::Follow<'a> for &'a NestedStruct {
|
||||
type Inner = &'a NestedStruct;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
unsafe { ::flatbuffers::follow_cast_ref::<NestedStruct>(buf, loc) }
|
||||
}
|
||||
}
|
||||
impl<'b> ::flatbuffers::Push for NestedStruct {
|
||||
type Output = NestedStruct;
|
||||
#[inline]
|
||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||
let src = unsafe { ::core::slice::from_raw_parts(self as *const NestedStruct as *const u8, <Self as ::flatbuffers::Push>::size()) };
|
||||
dst.copy_from_slice(src);
|
||||
}
|
||||
#[inline]
|
||||
fn alignment() -> ::flatbuffers::PushAlignment {
|
||||
::flatbuffers::PushAlignment::new(8)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ::flatbuffers::Verifiable for NestedStruct {
|
||||
#[inline]
|
||||
fn run_verifier(
|
||||
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||
v.in_buffer::<Self>(pos)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> NestedStruct {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
a: &[i32; 2],
|
||||
b: TestEnum,
|
||||
c: &[TestEnum; 2],
|
||||
d: &[i64; 2],
|
||||
) -> Self {
|
||||
let mut s = Self([0; 32]);
|
||||
s.set_a(a);
|
||||
s.set_b(b);
|
||||
s.set_c(c);
|
||||
s.set_d(d);
|
||||
s
|
||||
}
|
||||
|
||||
pub fn a(&'a self) -> ::flatbuffers::Array<'a, i32, 2> {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
use ::flatbuffers::Follow;
|
||||
unsafe { ::flatbuffers::Array::follow(&self.0, 0) }
|
||||
}
|
||||
|
||||
pub fn set_a(&mut self, items: &[i32; 2]) {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 0, items) };
|
||||
}
|
||||
|
||||
pub fn b(&self) -> TestEnum {
|
||||
let mut mem = ::core::mem::MaybeUninit::<<TestEnum 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[8..].as_ptr(),
|
||||
mem.as_mut_ptr() as *mut u8,
|
||||
::core::mem::size_of::<<TestEnum as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||
);
|
||||
mem.assume_init()
|
||||
})
|
||||
}
|
||||
|
||||
pub fn set_b(&mut self, x: TestEnum) {
|
||||
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[8..].as_mut_ptr(),
|
||||
::core::mem::size_of::<<TestEnum as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn c(&'a self) -> ::flatbuffers::Array<'a, TestEnum, 2> {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
use ::flatbuffers::Follow;
|
||||
unsafe { ::flatbuffers::Array::follow(&self.0, 9) }
|
||||
}
|
||||
|
||||
pub fn set_c(&mut self, x: &[TestEnum; 2]) {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
unsafe {
|
||||
::core::ptr::copy(
|
||||
x.as_ptr() as *const u8,
|
||||
self.0.as_mut_ptr().add(9),
|
||||
2,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn d(&'a self) -> ::flatbuffers::Array<'a, i64, 2> {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
use ::flatbuffers::Follow;
|
||||
unsafe { ::flatbuffers::Array::follow(&self.0, 16) }
|
||||
}
|
||||
|
||||
pub fn set_d(&mut self, items: &[i64; 2]) {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 16, items) };
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> NestedStructT {
|
||||
NestedStructT {
|
||||
a: self.a().into(),
|
||||
b: self.b(),
|
||||
c: self.c().into(),
|
||||
d: self.d().into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct NestedStructT {
|
||||
pub a: [i32; 2],
|
||||
pub b: TestEnum,
|
||||
pub c: [TestEnum; 2],
|
||||
pub d: [i64; 2],
|
||||
}
|
||||
impl Default for NestedStructT {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
a: [0; 2],
|
||||
b: TestEnum::A,
|
||||
c: ::flatbuffers::array_init(|_| Default::default()),
|
||||
d: [0; 2],
|
||||
}
|
||||
}
|
||||
}
|
||||
impl NestedStructT {
|
||||
pub fn pack(&self) -> NestedStruct {
|
||||
NestedStruct::new(
|
||||
&self.a,
|
||||
self.b,
|
||||
&self.c,
|
||||
&self.d,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// struct ArrayStruct, aligned to 8
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
pub struct ArrayStruct(pub [u8; 160]);
|
||||
impl Default for ArrayStruct {
|
||||
fn default() -> Self {
|
||||
Self([0; 160])
|
||||
}
|
||||
}
|
||||
impl ::core::fmt::Debug for ArrayStruct {
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||
f.debug_struct("ArrayStruct")
|
||||
.field("a", &self.a())
|
||||
.field("b", &self.b())
|
||||
.field("c", &self.c())
|
||||
.field("d", &self.d())
|
||||
.field("e", &self.e())
|
||||
.field("f", &self.f())
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl ::flatbuffers::SimpleToVerifyInSlice for ArrayStruct {}
|
||||
impl<'a> ::flatbuffers::Follow<'a> for ArrayStruct {
|
||||
type Inner = &'a ArrayStruct;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
unsafe { <&'a ArrayStruct>::follow(buf, loc) }
|
||||
}
|
||||
}
|
||||
impl<'a> ::flatbuffers::Follow<'a> for &'a ArrayStruct {
|
||||
type Inner = &'a ArrayStruct;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
unsafe { ::flatbuffers::follow_cast_ref::<ArrayStruct>(buf, loc) }
|
||||
}
|
||||
}
|
||||
impl<'b> ::flatbuffers::Push for ArrayStruct {
|
||||
type Output = ArrayStruct;
|
||||
#[inline]
|
||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||
let src = unsafe { ::core::slice::from_raw_parts(self as *const ArrayStruct as *const u8, <Self as ::flatbuffers::Push>::size()) };
|
||||
dst.copy_from_slice(src);
|
||||
}
|
||||
#[inline]
|
||||
fn alignment() -> ::flatbuffers::PushAlignment {
|
||||
::flatbuffers::PushAlignment::new(8)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ::flatbuffers::Verifiable for ArrayStruct {
|
||||
#[inline]
|
||||
fn run_verifier(
|
||||
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||
v.in_buffer::<Self>(pos)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ArrayStruct {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
a: f32,
|
||||
b: &[i32; 15],
|
||||
c: i8,
|
||||
d: &[NestedStruct; 2],
|
||||
e: i32,
|
||||
f: &[i64; 2],
|
||||
) -> Self {
|
||||
let mut s = Self([0; 160]);
|
||||
s.set_a(a);
|
||||
s.set_b(b);
|
||||
s.set_c(c);
|
||||
s.set_d(d);
|
||||
s.set_e(e);
|
||||
s.set_f(f);
|
||||
s
|
||||
}
|
||||
|
||||
pub fn a(&self) -> f32 {
|
||||
let mut mem = ::core::mem::MaybeUninit::<<f32 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::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||
);
|
||||
mem.assume_init()
|
||||
})
|
||||
}
|
||||
|
||||
pub fn set_a(&mut self, x: f32) {
|
||||
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::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn b(&'a self) -> ::flatbuffers::Array<'a, i32, 15> {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
use ::flatbuffers::Follow;
|
||||
unsafe { ::flatbuffers::Array::follow(&self.0, 4) }
|
||||
}
|
||||
|
||||
pub fn set_b(&mut self, items: &[i32; 15]) {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 4, items) };
|
||||
}
|
||||
|
||||
pub fn c(&self) -> i8 {
|
||||
let mut mem = ::core::mem::MaybeUninit::<<i8 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[64..].as_ptr(),
|
||||
mem.as_mut_ptr() as *mut u8,
|
||||
::core::mem::size_of::<<i8 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||
);
|
||||
mem.assume_init()
|
||||
})
|
||||
}
|
||||
|
||||
pub fn set_c(&mut self, x: i8) {
|
||||
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[64..].as_mut_ptr(),
|
||||
::core::mem::size_of::<<i8 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn d(&'a self) -> ::flatbuffers::Array<'a, NestedStruct, 2> {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
use ::flatbuffers::Follow;
|
||||
unsafe { ::flatbuffers::Array::follow(&self.0, 72) }
|
||||
}
|
||||
|
||||
pub fn set_d(&mut self, x: &[NestedStruct; 2]) {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
unsafe {
|
||||
::core::ptr::copy(
|
||||
x.as_ptr() as *const u8,
|
||||
self.0.as_mut_ptr().add(72),
|
||||
64,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn e(&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[136..].as_ptr(),
|
||||
mem.as_mut_ptr() as *mut u8,
|
||||
::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||
);
|
||||
mem.assume_init()
|
||||
})
|
||||
}
|
||||
|
||||
pub fn set_e(&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[136..].as_mut_ptr(),
|
||||
::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn f(&'a self) -> ::flatbuffers::Array<'a, i64, 2> {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
use ::flatbuffers::Follow;
|
||||
unsafe { ::flatbuffers::Array::follow(&self.0, 144) }
|
||||
}
|
||||
|
||||
pub fn set_f(&mut self, items: &[i64; 2]) {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 144, items) };
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> ArrayStructT {
|
||||
ArrayStructT {
|
||||
a: self.a(),
|
||||
b: self.b().into(),
|
||||
c: self.c(),
|
||||
d: { let d = self.d(); ::flatbuffers::array_init(|i| d.get(i).unpack()) },
|
||||
e: self.e(),
|
||||
f: self.f().into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct ArrayStructT {
|
||||
pub a: f32,
|
||||
pub b: [i32; 15],
|
||||
pub c: i8,
|
||||
pub d: [NestedStructT; 2],
|
||||
pub e: i32,
|
||||
pub f: [i64; 2],
|
||||
}
|
||||
impl Default for ArrayStructT {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
a: 0.0,
|
||||
b: [0; 15],
|
||||
c: 0,
|
||||
d: ::flatbuffers::array_init(|_| Default::default()),
|
||||
e: 0,
|
||||
f: [0; 2],
|
||||
}
|
||||
}
|
||||
}
|
||||
impl ArrayStructT {
|
||||
pub fn pack(&self) -> ArrayStruct {
|
||||
ArrayStruct::new(
|
||||
self.a,
|
||||
&self.b,
|
||||
self.c,
|
||||
&::flatbuffers::array_init(|i| self.d[i].pack()),
|
||||
self.e,
|
||||
&self.f,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// struct LargeArrayStruct, aligned to 4
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
pub struct LargeArrayStruct(pub [u8; 384]);
|
||||
impl Default for LargeArrayStruct {
|
||||
fn default() -> Self {
|
||||
Self([0; 384])
|
||||
}
|
||||
}
|
||||
impl ::core::fmt::Debug for LargeArrayStruct {
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||
f.debug_struct("LargeArrayStruct")
|
||||
.field("d", &self.d())
|
||||
.field("e", &self.e())
|
||||
.field("f", &self.f())
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl ::flatbuffers::SimpleToVerifyInSlice for LargeArrayStruct {}
|
||||
impl<'a> ::flatbuffers::Follow<'a> for LargeArrayStruct {
|
||||
type Inner = &'a LargeArrayStruct;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
unsafe { <&'a LargeArrayStruct>::follow(buf, loc) }
|
||||
}
|
||||
}
|
||||
impl<'a> ::flatbuffers::Follow<'a> for &'a LargeArrayStruct {
|
||||
type Inner = &'a LargeArrayStruct;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
unsafe { ::flatbuffers::follow_cast_ref::<LargeArrayStruct>(buf, loc) }
|
||||
}
|
||||
}
|
||||
impl<'b> ::flatbuffers::Push for LargeArrayStruct {
|
||||
type Output = LargeArrayStruct;
|
||||
#[inline]
|
||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||
let src = unsafe { ::core::slice::from_raw_parts(self as *const LargeArrayStruct 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 LargeArrayStruct {
|
||||
#[inline]
|
||||
fn run_verifier(
|
||||
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||
v.in_buffer::<Self>(pos)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> LargeArrayStruct {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
d: &[u8; 64],
|
||||
e: &[f32; 64],
|
||||
f: &[bool; 64],
|
||||
) -> Self {
|
||||
let mut s = Self([0; 384]);
|
||||
s.set_d(d);
|
||||
s.set_e(e);
|
||||
s.set_f(f);
|
||||
s
|
||||
}
|
||||
|
||||
pub fn d(&'a self) -> ::flatbuffers::Array<'a, u8, 64> {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
use ::flatbuffers::Follow;
|
||||
unsafe { ::flatbuffers::Array::follow(&self.0, 0) }
|
||||
}
|
||||
|
||||
pub fn set_d(&mut self, items: &[u8; 64]) {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 0, items) };
|
||||
}
|
||||
|
||||
pub fn e(&'a self) -> ::flatbuffers::Array<'a, f32, 64> {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
use ::flatbuffers::Follow;
|
||||
unsafe { ::flatbuffers::Array::follow(&self.0, 64) }
|
||||
}
|
||||
|
||||
pub fn set_e(&mut self, items: &[f32; 64]) {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 64, items) };
|
||||
}
|
||||
|
||||
pub fn f(&'a self) -> ::flatbuffers::Array<'a, bool, 64> {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
use ::flatbuffers::Follow;
|
||||
unsafe { ::flatbuffers::Array::follow(&self.0, 320) }
|
||||
}
|
||||
|
||||
pub fn set_f(&mut self, items: &[bool; 64]) {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 320, items) };
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> LargeArrayStructT {
|
||||
LargeArrayStructT {
|
||||
d: self.d().into(),
|
||||
e: self.e().into(),
|
||||
f: self.f().into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct LargeArrayStructT {
|
||||
pub d: [u8; 64],
|
||||
pub e: [f32; 64],
|
||||
pub f: [bool; 64],
|
||||
}
|
||||
impl Default for LargeArrayStructT {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
d: [0; 64],
|
||||
e: [0.0; 64],
|
||||
f: [false; 64],
|
||||
}
|
||||
}
|
||||
}
|
||||
impl LargeArrayStructT {
|
||||
pub fn pack(&self) -> LargeArrayStruct {
|
||||
LargeArrayStruct::new(
|
||||
&self.d,
|
||||
&self.e,
|
||||
&self.f,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub enum ArrayTableOffset {}
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
|
||||
pub struct ArrayTable<'a> {
|
||||
pub _tab: ::flatbuffers::Table<'a>,
|
||||
}
|
||||
|
||||
impl<'a> ::flatbuffers::Follow<'a> for ArrayTable<'a> {
|
||||
type Inner = ArrayTable<'a>;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ArrayTable<'a> {
|
||||
pub const VT_A: ::flatbuffers::VOffsetT = 4;
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||
ArrayTable { _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 ArrayTableArgs<'args>
|
||||
) -> ::flatbuffers::WIPOffset<ArrayTable<'bldr>> {
|
||||
let mut builder = ArrayTableBuilder::new(_fbb);
|
||||
if let Some(x) = args.a { builder.add_a(x); }
|
||||
builder.finish()
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> ArrayTableT {
|
||||
let a = self.a().map(|x| {
|
||||
x.unpack()
|
||||
});
|
||||
ArrayTableT {
|
||||
a,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn a(&self) -> Option<&'a ArrayStruct> {
|
||||
// Safety:
|
||||
// Created from valid Table for this object
|
||||
// which contains a valid value in this slot
|
||||
unsafe { self._tab.get::<ArrayStruct>(ArrayTable::VT_A, None)}
|
||||
}
|
||||
}
|
||||
|
||||
impl ::flatbuffers::Verifiable for ArrayTable<'_> {
|
||||
#[inline]
|
||||
fn run_verifier(
|
||||
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||
v.visit_table(pos)?
|
||||
.visit_field::<ArrayStruct>("a", Self::VT_A, false)?
|
||||
.finish();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
pub struct ArrayTableArgs<'a> {
|
||||
pub a: Option<&'a ArrayStruct>,
|
||||
}
|
||||
impl<'a> Default for ArrayTableArgs<'a> {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
ArrayTableArgs {
|
||||
a: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ArrayTableBuilder<'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> ArrayTableBuilder<'a, 'b, A> {
|
||||
#[inline]
|
||||
pub fn add_a(&mut self, a: &ArrayStruct) {
|
||||
self.fbb_.push_slot_always::<&ArrayStruct>(ArrayTable::VT_A, a);
|
||||
}
|
||||
#[inline]
|
||||
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ArrayTableBuilder<'a, 'b, A> {
|
||||
let start = _fbb.start_table();
|
||||
ArrayTableBuilder {
|
||||
fbb_: _fbb,
|
||||
start_: start,
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn finish(self) -> ::flatbuffers::WIPOffset<ArrayTable<'a>> {
|
||||
let o = self.fbb_.end_table(self.start_);
|
||||
::flatbuffers::WIPOffset::new(o.value())
|
||||
}
|
||||
}
|
||||
|
||||
impl ::core::fmt::Debug for ArrayTable<'_> {
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
||||
let mut ds = f.debug_struct("ArrayTable");
|
||||
ds.field("a", &self.a());
|
||||
ds.finish()
|
||||
}
|
||||
}
|
||||
#[non_exhaustive]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct ArrayTableT {
|
||||
pub a: Option<ArrayStructT>,
|
||||
}
|
||||
impl Default for ArrayTableT {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
a: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl ArrayTableT {
|
||||
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
||||
&self,
|
||||
_fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
|
||||
) -> ::flatbuffers::WIPOffset<ArrayTable<'b>> {
|
||||
let a_tmp = self.a.as_ref().map(|x| x.pack());
|
||||
let a = a_tmp.as_ref();
|
||||
ArrayTable::create(_fbb, &ArrayTableArgs{
|
||||
a,
|
||||
})
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
/// Verifies that a buffer of bytes contains a `ArrayTable`
|
||||
/// and returns it.
|
||||
/// Note that verification is still experimental and may not
|
||||
/// catch every error, or be maximally performant. For the
|
||||
/// previous, unchecked, behavior use
|
||||
/// `root_as_array_table_unchecked`.
|
||||
pub fn root_as_array_table(buf: &[u8]) -> Result<ArrayTable<'_>, ::flatbuffers::InvalidFlatbuffer> {
|
||||
::flatbuffers::root::<ArrayTable>(buf)
|
||||
}
|
||||
#[inline]
|
||||
/// Verifies that a buffer of bytes contains a size prefixed
|
||||
/// `ArrayTable` and returns it.
|
||||
/// Note that verification is still experimental and may not
|
||||
/// catch every error, or be maximally performant. For the
|
||||
/// previous, unchecked, behavior use
|
||||
/// `size_prefixed_root_as_array_table_unchecked`.
|
||||
pub fn size_prefixed_root_as_array_table(buf: &[u8]) -> Result<ArrayTable<'_>, ::flatbuffers::InvalidFlatbuffer> {
|
||||
::flatbuffers::size_prefixed_root::<ArrayTable>(buf)
|
||||
}
|
||||
#[inline]
|
||||
/// Verifies, with the given options, that a buffer of bytes
|
||||
/// contains a `ArrayTable` and returns it.
|
||||
/// Note that verification is still experimental and may not
|
||||
/// catch every error, or be maximally performant. For the
|
||||
/// previous, unchecked, behavior use
|
||||
/// `root_as_array_table_unchecked`.
|
||||
pub fn root_as_array_table_with_opts<'b, 'o>(
|
||||
opts: &'o ::flatbuffers::VerifierOptions,
|
||||
buf: &'b [u8],
|
||||
) -> Result<ArrayTable<'b>, ::flatbuffers::InvalidFlatbuffer> {
|
||||
::flatbuffers::root_with_opts::<ArrayTable<'b>>(opts, buf)
|
||||
}
|
||||
#[inline]
|
||||
/// Verifies, with the given verifier options, that a buffer of
|
||||
/// bytes contains a size prefixed `ArrayTable` and returns
|
||||
/// it. Note that verification is still experimental and may not
|
||||
/// catch every error, or be maximally performant. For the
|
||||
/// previous, unchecked, behavior use
|
||||
/// `root_as_array_table_unchecked`.
|
||||
pub fn size_prefixed_root_as_array_table_with_opts<'b, 'o>(
|
||||
opts: &'o ::flatbuffers::VerifierOptions,
|
||||
buf: &'b [u8],
|
||||
) -> Result<ArrayTable<'b>, ::flatbuffers::InvalidFlatbuffer> {
|
||||
::flatbuffers::size_prefixed_root_with_opts::<ArrayTable<'b>>(opts, buf)
|
||||
}
|
||||
#[inline]
|
||||
/// Assumes, without verification, that a buffer of bytes contains a ArrayTable and returns it.
|
||||
/// # Safety
|
||||
/// Callers must trust the given bytes do indeed contain a valid `ArrayTable`.
|
||||
pub unsafe fn root_as_array_table_unchecked(buf: &[u8]) -> ArrayTable<'_> {
|
||||
unsafe { ::flatbuffers::root_unchecked::<ArrayTable>(buf) }
|
||||
}
|
||||
#[inline]
|
||||
/// Assumes, without verification, that a buffer of bytes contains a size prefixed ArrayTable and returns it.
|
||||
/// # Safety
|
||||
/// Callers must trust the given bytes do indeed contain a valid size prefixed `ArrayTable`.
|
||||
pub unsafe fn size_prefixed_root_as_array_table_unchecked(buf: &[u8]) -> ArrayTable<'_> {
|
||||
unsafe { ::flatbuffers::size_prefixed_root_unchecked::<ArrayTable>(buf) }
|
||||
}
|
||||
pub const ARRAY_TABLE_IDENTIFIER: &str = "ARRT";
|
||||
|
||||
#[inline]
|
||||
pub fn array_table_buffer_has_identifier(buf: &[u8]) -> bool {
|
||||
::flatbuffers::buffer_has_identifier(buf, ARRAY_TABLE_IDENTIFIER, false)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn array_table_size_prefixed_buffer_has_identifier(buf: &[u8]) -> bool {
|
||||
::flatbuffers::buffer_has_identifier(buf, ARRAY_TABLE_IDENTIFIER, true)
|
||||
}
|
||||
|
||||
pub const ARRAY_TABLE_EXTENSION: &str = "mon";
|
||||
|
||||
#[inline]
|
||||
pub fn finish_array_table_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
|
||||
fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||
root: ::flatbuffers::WIPOffset<ArrayTable<'a>>) {
|
||||
fbb.finish(root, Some(ARRAY_TABLE_IDENTIFIER));
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn finish_size_prefixed_array_table_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, root: ::flatbuffers::WIPOffset<ArrayTable<'a>>) {
|
||||
fbb.finish_size_prefixed(root, Some(ARRAY_TABLE_IDENTIFIER));
|
||||
}
|
||||
} // pub mod Example
|
||||
} // pub mod MyGame
|
||||
|
||||
@@ -1,223 +0,0 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// @generated
|
||||
extern crate alloc;
|
||||
use super::*;
|
||||
|
||||
// struct LargeArrayStruct, aligned to 8
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
pub struct LargeArrayStruct(pub [u8; 2496]);
|
||||
|
||||
impl Default for LargeArrayStruct {
|
||||
fn default() -> Self {
|
||||
Self([0; 2496])
|
||||
}
|
||||
}
|
||||
|
||||
impl ::core::fmt::Debug for LargeArrayStruct {
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||
f.debug_struct("LargeArrayStruct")
|
||||
.field("d", &self.d())
|
||||
.field("e", &self.e())
|
||||
.field("f", &self.f())
|
||||
.field("g", &self.g())
|
||||
.field("h", &self.h())
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl ::flatbuffers::SimpleToVerifyInSlice for LargeArrayStruct {}
|
||||
|
||||
impl<'a> ::flatbuffers::Follow<'a> for LargeArrayStruct {
|
||||
type Inner = &'a LargeArrayStruct;
|
||||
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
unsafe { <&'a LargeArrayStruct>::follow(buf, loc) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ::flatbuffers::Follow<'a> for &'a LargeArrayStruct {
|
||||
type Inner = &'a LargeArrayStruct;
|
||||
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
unsafe { ::flatbuffers::follow_cast_ref::<LargeArrayStruct>(buf, loc) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'b> ::flatbuffers::Push for LargeArrayStruct {
|
||||
type Output = LargeArrayStruct;
|
||||
|
||||
#[inline]
|
||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||
let src = unsafe { ::core::slice::from_raw_parts(self as *const LargeArrayStruct as *const u8, <Self as ::flatbuffers::Push>::size()) };
|
||||
dst.copy_from_slice(src);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn alignment() -> ::flatbuffers::PushAlignment {
|
||||
::flatbuffers::PushAlignment::new(8)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ::flatbuffers::Verifiable for LargeArrayStruct {
|
||||
#[inline]
|
||||
fn run_verifier(
|
||||
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||
v.in_buffer::<Self>(pos)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> LargeArrayStruct {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
d: &[u8; 64],
|
||||
e: &[f32; 64],
|
||||
f: &[bool; 64],
|
||||
g: &[NestedStruct; 64],
|
||||
h: &[TestEnum; 64],
|
||||
) -> Self {
|
||||
let mut s = Self([0; 2496]);
|
||||
s.set_d(d);
|
||||
s.set_e(e);
|
||||
s.set_f(f);
|
||||
s.set_g(g);
|
||||
s.set_h(h);
|
||||
s
|
||||
}
|
||||
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.LargeArrayStruct"
|
||||
}
|
||||
|
||||
pub fn d(&'a self) -> ::flatbuffers::Array<'a, u8, 64> {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
use ::flatbuffers::Follow;
|
||||
unsafe { ::flatbuffers::Array::follow(&self.0, 0) }
|
||||
}
|
||||
|
||||
pub fn set_d(&mut self, items: &[u8; 64]) {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 0, items) };
|
||||
}
|
||||
|
||||
pub fn e(&'a self) -> ::flatbuffers::Array<'a, f32, 64> {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
use ::flatbuffers::Follow;
|
||||
unsafe { ::flatbuffers::Array::follow(&self.0, 64) }
|
||||
}
|
||||
|
||||
pub fn set_e(&mut self, items: &[f32; 64]) {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 64, items) };
|
||||
}
|
||||
|
||||
pub fn f(&'a self) -> ::flatbuffers::Array<'a, bool, 64> {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
use ::flatbuffers::Follow;
|
||||
unsafe { ::flatbuffers::Array::follow(&self.0, 320) }
|
||||
}
|
||||
|
||||
pub fn set_f(&mut self, items: &[bool; 64]) {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 320, items) };
|
||||
}
|
||||
|
||||
pub fn g(&'a self) -> ::flatbuffers::Array<'a, NestedStruct, 64> {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
use ::flatbuffers::Follow;
|
||||
unsafe { ::flatbuffers::Array::follow(&self.0, 384) }
|
||||
}
|
||||
|
||||
pub fn set_g(&mut self, x: &[NestedStruct; 64]) {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
unsafe {
|
||||
::core::ptr::copy(
|
||||
x.as_ptr() as *const u8,
|
||||
self.0.as_mut_ptr().add(384),
|
||||
2048,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn h(&'a self) -> ::flatbuffers::Array<'a, TestEnum, 64> {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
use ::flatbuffers::Follow;
|
||||
unsafe { ::flatbuffers::Array::follow(&self.0, 2432) }
|
||||
}
|
||||
|
||||
pub fn set_h(&mut self, x: &[TestEnum; 64]) {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
unsafe {
|
||||
::core::ptr::copy(
|
||||
x.as_ptr() as *const u8,
|
||||
self.0.as_mut_ptr().add(2432),
|
||||
64,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> LargeArrayStructT {
|
||||
LargeArrayStructT {
|
||||
d: self.d().into(),
|
||||
e: self.e().into(),
|
||||
f: self.f().into(),
|
||||
g: { let g = self.g(); ::flatbuffers::array_init(|i| g.get(i).unpack()) },
|
||||
h: self.h().into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct LargeArrayStructT {
|
||||
pub d: [u8; 64],
|
||||
pub e: [f32; 64],
|
||||
pub f: [bool; 64],
|
||||
pub g: [NestedStructT; 64],
|
||||
pub h: [TestEnum; 64],
|
||||
}
|
||||
impl Default for LargeArrayStructT {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
d: [0; 64],
|
||||
e: [0.0; 64],
|
||||
f: [false; 64],
|
||||
g: ::flatbuffers::array_init(|_| Default::default()),
|
||||
h: ::flatbuffers::array_init(|_| Default::default()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl LargeArrayStructT {
|
||||
pub fn pack(&self) -> LargeArrayStruct {
|
||||
LargeArrayStruct::new(
|
||||
&self.d,
|
||||
&self.e,
|
||||
&self.f,
|
||||
&::flatbuffers::array_init(|i| self.g[i].pack()),
|
||||
&self.h,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
native_include "bigfoot_ref_test_impl.h";
|
||||
|
||||
namespace BigfootRefTestNS;
|
||||
|
||||
// Stands in for Bigfoot's real UUID - a `native_type` struct so RefId has a
|
||||
// distinct native/flat representation, matching the shape `bigfoot_ref`
|
||||
// requires of a wrapper's payload field.
|
||||
struct RefId (native_type: "Native::RefId") {
|
||||
value: uint64;
|
||||
}
|
||||
|
||||
// The reference-wrapper template itself. `bigfoot_ref_wrapper` marks Ref as
|
||||
// instantiable per referenced type via `bigfoot_ref` below.
|
||||
struct Ref (bigfoot_ref_wrapper: "Native::Ref") {
|
||||
uuid: RefId;
|
||||
}
|
||||
|
||||
// RefHolder references two distinct C++ types (Thing, OtherThing) that are
|
||||
// *never defined anywhere in this test* - only ever forward-declared, by
|
||||
// flatc itself, directly into the generated header. This is the property
|
||||
// `bigfoot_ref` exists to provide: a reference field never requires the
|
||||
// referenced type to be complete. It also references `Thing` twice (once as
|
||||
// a plain field, once in a vector), exercising the include-guard dedup for
|
||||
// two fields that resolve to the identical Pack/UnPack pair.
|
||||
table RefHolder {
|
||||
ref_a: Ref (native_inline, bigfoot_ref: "Native::Thing");
|
||||
ref_a_again: [Ref] (native_inline, bigfoot_ref: "Native::Thing");
|
||||
ref_b: Ref (native_inline, bigfoot_ref: "Native::OtherThing");
|
||||
}
|
||||
|
||||
root_type RefHolder;
|
||||
@@ -1,47 +0,0 @@
|
||||
#include "bigfoot_ref_test_impl.h"
|
||||
|
||||
#include "bigfoot_ref_test_generated.h"
|
||||
#include "test_assert.h"
|
||||
|
||||
namespace flatbuffers {
|
||||
BigfootRefTestNS::RefId Pack(const Native::RefId& obj) {
|
||||
return BigfootRefTestNS::RefId(obj.value);
|
||||
}
|
||||
|
||||
const Native::RefId UnPack(const BigfootRefTestNS::RefId& obj) {
|
||||
return Native::RefId(obj.value());
|
||||
}
|
||||
} // namespace flatbuffers
|
||||
|
||||
namespace flatbuffers {
|
||||
namespace tests {
|
||||
|
||||
// Exercises the --bigfoot_ref/--bigfoot_ref_wrapper flatc attributes (see
|
||||
// tests/bigfoot_ref_test.fbs): a reference field never requires the
|
||||
// referenced native type to be complete, and the generated header supplies
|
||||
// its own forward declaration plus inline Pack/UnPack definitions, with no
|
||||
// hand-written boilerplate anywhere in this file for `Thing`/`OtherThing`.
|
||||
void BigfootRefTest() {
|
||||
using BigfootRefTestNS::RefHolder;
|
||||
using BigfootRefTestNS::RefHolderT;
|
||||
|
||||
RefHolderT src;
|
||||
src.ref_a = Native::Ref<Native::Thing>(Native::RefId(1));
|
||||
src.ref_a_again.push_back(Native::Ref<Native::Thing>(Native::RefId(2)));
|
||||
src.ref_a_again.push_back(Native::Ref<Native::Thing>(Native::RefId(3)));
|
||||
src.ref_b = Native::Ref<Native::OtherThing>(Native::RefId(4));
|
||||
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
fbb.Finish(RefHolder::Pack(fbb, &src));
|
||||
|
||||
auto dst = BigfootRefTestNS::UnPackRefHolder(fbb.GetBufferPointer());
|
||||
|
||||
TEST_EQ(dst->ref_a.uuid.value, 1u);
|
||||
TEST_EQ(dst->ref_a_again.size(), 2u);
|
||||
TEST_EQ(dst->ref_a_again[0].uuid.value, 2u);
|
||||
TEST_EQ(dst->ref_a_again[1].uuid.value, 3u);
|
||||
TEST_EQ(dst->ref_b.uuid.value, 4u);
|
||||
}
|
||||
|
||||
} // namespace tests
|
||||
} // namespace flatbuffers
|
||||
@@ -1,55 +0,0 @@
|
||||
#ifndef BIGFOOT_REF_TEST_IMPL_H
|
||||
#define BIGFOOT_REF_TEST_IMPL_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace Native {
|
||||
// Stands in for Bigfoot's real UUID.
|
||||
struct RefId {
|
||||
uint64_t value;
|
||||
|
||||
RefId() : value(0) {}
|
||||
explicit RefId(uint64_t _value) : value(_value) {}
|
||||
|
||||
bool operator==(const RefId& other) const { return value == other.value; }
|
||||
};
|
||||
|
||||
// `Thing`/`OtherThing` are intentionally *never* defined anywhere in this
|
||||
// test (see bigfoot_ref_test.fbs) - Ref<T> must compile and round-trip
|
||||
// without T ever being a complete type, exactly like Bigfoot's
|
||||
// HardReference<T>/SoftReference<T>. Their forward declarations are emitted
|
||||
// automatically by flatc (GenerateBigfootRefForwardDecls in
|
||||
// idl_gen_cpp.cpp) directly into bigfoot_ref_test_generated.h - no manual
|
||||
// forward declaration belongs here.
|
||||
|
||||
// The reference-wrapper template `bigfoot_ref_wrapper`/`bigfoot_ref` (see
|
||||
// idl_parser.cpp/idl_gen_cpp.cpp) instantiate per referenced type. Only
|
||||
// needs a `GetUUID()` accessor and a constructor from RefId - never needs T
|
||||
// complete.
|
||||
template <typename T>
|
||||
struct Ref {
|
||||
RefId uuid;
|
||||
|
||||
Ref() : uuid() {}
|
||||
Ref(const RefId& _uuid) : uuid(_uuid) {}
|
||||
|
||||
const RefId& GetUUID() const { return uuid; }
|
||||
|
||||
bool operator==(const Ref& other) const { return uuid == other.uuid; }
|
||||
};
|
||||
} // namespace Native
|
||||
|
||||
namespace BigfootRefTestNS {
|
||||
struct RefId;
|
||||
} // namespace BigfootRefTestNS
|
||||
|
||||
namespace flatbuffers {
|
||||
BigfootRefTestNS::RefId Pack(const Native::RefId& obj);
|
||||
const Native::RefId UnPack(const BigfootRefTestNS::RefId& obj);
|
||||
|
||||
namespace tests {
|
||||
void BigfootRefTest();
|
||||
} // namespace tests
|
||||
} // namespace flatbuffers
|
||||
|
||||
#endif // BIGFOOT_REF_TEST_IMPL_H
|
||||
@@ -1,932 +0,0 @@
|
||||
// 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 "generated_cpp17/monster_test_generated.h"
|
||||
#include "generated_cpp17/optional_scalars_generated.h"
|
||||
#include "generated_cpp17/union_vector_generated.h"
|
||||
#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"
|
||||
} // namespace cpp17
|
||||
|
||||
namespace cpp11 {
|
||||
#include "../monster_test_generated.h"
|
||||
#include "../optional_scalars_generated.h"
|
||||
#include "tests/monster_test_generated.h"
|
||||
#include "tests/optional_scalars.fbs.h"
|
||||
} // namespace cpp11
|
||||
|
||||
using ::cpp17::MyGame::Example::Monster;
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
// Schema used to test the --cpp-vector-type flatc option, which lets the
|
||||
// generated Object API use a custom vector-like container (e.g.
|
||||
// eastl::vector) instead of std::vector. See tests/test_vector_type.h for
|
||||
// the stand-in container used by the test, and
|
||||
// tests/cpp_vector_type_test.cpp for the test itself.
|
||||
|
||||
namespace CppVectorTypeNS;
|
||||
|
||||
enum CppVectorTypeColor : byte { Red = 0, Green, Blue }
|
||||
|
||||
struct CppVectorTypeVec2 {
|
||||
x: float;
|
||||
y: float;
|
||||
}
|
||||
|
||||
table CppVectorTypeMonster {
|
||||
id: int32;
|
||||
}
|
||||
|
||||
table CppVectorTypeTest {
|
||||
ints: [int32];
|
||||
flags: [bool];
|
||||
colors: [CppVectorTypeColor];
|
||||
strings: [string];
|
||||
positions: [CppVectorTypeVec2];
|
||||
monsters: [CppVectorTypeMonster];
|
||||
}
|
||||
|
||||
root_type CppVectorTypeTest;
|
||||
@@ -1,143 +0,0 @@
|
||||
#include "cpp_vector_type_test.h"
|
||||
|
||||
#include "cpp_vector_type_generated.h"
|
||||
#include "test_assert.h"
|
||||
|
||||
namespace flatbuffers {
|
||||
namespace tests {
|
||||
|
||||
// Exercises the --cpp-vector-type flatc option (see
|
||||
// tests/cpp_vector_type.fbs and tests/test_vector_type.h), which replaces
|
||||
// std::vector with a custom vector-like container in the generated Object
|
||||
// API. This covers every CreateVector*-family code path in Pack(): plain
|
||||
// scalars, bool, enum-cast, vector-of-string, vector-of-struct and
|
||||
// vector-of-table, then round-trips everything back through UnPackTo().
|
||||
void CppVectorTypeTest() {
|
||||
using CppVectorTypeNS::CppVectorTypeColor_Blue;
|
||||
using CppVectorTypeNS::CppVectorTypeColor_Green;
|
||||
using CppVectorTypeNS::CppVectorTypeColor_Red;
|
||||
using CppVectorTypeNS::CppVectorTypeMonsterT;
|
||||
using CppVectorTypeNS::CppVectorTypeTest;
|
||||
using CppVectorTypeNS::CppVectorTypeTestT;
|
||||
using CppVectorTypeNS::CppVectorTypeVec2;
|
||||
|
||||
// ---------------------------------------
|
||||
// 1) Build a native object using the custom vector container for every
|
||||
// vector field (scalars, bools, enums, strings, structs and tables).
|
||||
// ---------------------------------------
|
||||
CppVectorTypeTestT src;
|
||||
src.ints.push_back(1);
|
||||
src.ints.push_back(2);
|
||||
src.ints.push_back(3);
|
||||
|
||||
src.flags.push_back(true);
|
||||
src.flags.push_back(false);
|
||||
src.flags.push_back(true);
|
||||
|
||||
src.colors.push_back(CppVectorTypeColor_Red);
|
||||
src.colors.push_back(CppVectorTypeColor_Green);
|
||||
src.colors.push_back(CppVectorTypeColor_Blue);
|
||||
|
||||
src.strings.push_back("hello");
|
||||
src.strings.push_back("world");
|
||||
|
||||
src.positions.push_back(CppVectorTypeVec2(1.0f, 2.0f));
|
||||
src.positions.push_back(CppVectorTypeVec2(3.0f, 4.0f));
|
||||
|
||||
src.monsters.emplace_back(new CppVectorTypeMonsterT());
|
||||
src.monsters[0]->id = 111;
|
||||
src.monsters.emplace_back(new CppVectorTypeMonsterT());
|
||||
src.monsters[1]->id = 222;
|
||||
|
||||
// ---------------------------------------
|
||||
// 2) Exercise the copy constructor / copy assignment operator generated
|
||||
// for object-API types (--gen-compare requires these too), which rely
|
||||
// on the custom vector's own copy ctor plus reserve()/emplace_back()
|
||||
// for the vector-of-pointer (table) field.
|
||||
// ---------------------------------------
|
||||
CppVectorTypeTestT copy_of_src(src);
|
||||
TEST_EQ(copy_of_src == src, true);
|
||||
TEST_ASSERT(copy_of_src.monsters[0].get() != src.monsters[0].get());
|
||||
TEST_EQ(copy_of_src.monsters[0]->id, 111);
|
||||
|
||||
// ---------------------------------------
|
||||
// 3) Pack into a FlatBuffer and verify the wire-format contents.
|
||||
// ---------------------------------------
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
fbb.Finish(CppVectorTypeTest::Pack(fbb, &src));
|
||||
|
||||
const auto* fb =
|
||||
flatbuffers::GetRoot<CppVectorTypeTest>(fbb.GetBufferPointer());
|
||||
|
||||
TEST_EQ(fb->ints()->size(), 3u);
|
||||
TEST_EQ(fb->ints()->Get(0), 1);
|
||||
TEST_EQ(fb->ints()->Get(1), 2);
|
||||
TEST_EQ(fb->ints()->Get(2), 3);
|
||||
|
||||
TEST_EQ(fb->flags()->size(), 3u);
|
||||
TEST_EQ(fb->flags()->Get(0) != 0, true);
|
||||
TEST_EQ(fb->flags()->Get(1) != 0, false);
|
||||
TEST_EQ(fb->flags()->Get(2) != 0, true);
|
||||
|
||||
TEST_EQ(fb->colors()->size(), 3u);
|
||||
TEST_EQ(fb->colors()->Get(0), CppVectorTypeColor_Red);
|
||||
TEST_EQ(fb->colors()->Get(1), CppVectorTypeColor_Green);
|
||||
TEST_EQ(fb->colors()->Get(2), CppVectorTypeColor_Blue);
|
||||
|
||||
TEST_EQ(fb->strings()->size(), 2u);
|
||||
TEST_EQ_STR(fb->strings()->Get(0)->c_str(), "hello");
|
||||
TEST_EQ_STR(fb->strings()->Get(1)->c_str(), "world");
|
||||
|
||||
TEST_EQ(fb->positions()->size(), 2u);
|
||||
TEST_EQ(fb->positions()->Get(0)->x(), 1.0f);
|
||||
TEST_EQ(fb->positions()->Get(0)->y(), 2.0f);
|
||||
TEST_EQ(fb->positions()->Get(1)->x(), 3.0f);
|
||||
TEST_EQ(fb->positions()->Get(1)->y(), 4.0f);
|
||||
|
||||
TEST_EQ(fb->monsters()->size(), 2u);
|
||||
TEST_EQ(fb->monsters()->Get(0)->id(), 111);
|
||||
TEST_EQ(fb->monsters()->Get(1)->id(), 222);
|
||||
|
||||
// ---------------------------------------
|
||||
// 4) Unpack back into a fresh native object and verify a full round-trip
|
||||
// through the custom vector container.
|
||||
// ---------------------------------------
|
||||
CppVectorTypeTestT dst;
|
||||
fb->UnPackTo(&dst);
|
||||
|
||||
TEST_EQ(dst == src, true);
|
||||
|
||||
TEST_EQ(dst.ints.size(), 3u);
|
||||
TEST_EQ(dst.ints[0], 1);
|
||||
TEST_EQ(dst.ints[1], 2);
|
||||
TEST_EQ(dst.ints[2], 3);
|
||||
|
||||
TEST_EQ(dst.flags.size(), 3u);
|
||||
TEST_EQ(dst.flags[0], true);
|
||||
TEST_EQ(dst.flags[1], false);
|
||||
TEST_EQ(dst.flags[2], true);
|
||||
|
||||
TEST_EQ(dst.colors.size(), 3u);
|
||||
TEST_EQ(dst.colors[0], CppVectorTypeColor_Red);
|
||||
TEST_EQ(dst.colors[1], CppVectorTypeColor_Green);
|
||||
TEST_EQ(dst.colors[2], CppVectorTypeColor_Blue);
|
||||
|
||||
TEST_EQ(dst.strings.size(), 2u);
|
||||
TEST_EQ_STR(dst.strings[0].c_str(), "hello");
|
||||
TEST_EQ_STR(dst.strings[1].c_str(), "world");
|
||||
|
||||
TEST_EQ(dst.positions.size(), 2u);
|
||||
TEST_EQ(dst.positions[0].x(), 1.0f);
|
||||
TEST_EQ(dst.positions[0].y(), 2.0f);
|
||||
TEST_EQ(dst.positions[1].x(), 3.0f);
|
||||
TEST_EQ(dst.positions[1].y(), 4.0f);
|
||||
|
||||
TEST_EQ(dst.monsters.size(), 2u);
|
||||
TEST_ASSERT(dst.monsters[0] != nullptr);
|
||||
TEST_ASSERT(dst.monsters[1] != nullptr);
|
||||
TEST_EQ(dst.monsters[0]->id, 111);
|
||||
TEST_EQ(dst.monsters[1]->id, 222);
|
||||
}
|
||||
|
||||
} // namespace tests
|
||||
} // namespace flatbuffers
|
||||
@@ -1,12 +0,0 @@
|
||||
#ifndef TESTS_CPP_VECTOR_TYPE_TEST_H
|
||||
#define TESTS_CPP_VECTOR_TYPE_TEST_H
|
||||
|
||||
namespace flatbuffers {
|
||||
namespace tests {
|
||||
|
||||
void CppVectorTypeTest();
|
||||
|
||||
} // namespace tests
|
||||
} // namespace flatbuffers
|
||||
|
||||
#endif // TESTS_CPP_VECTOR_TYPE_TEST_H
|
||||
@@ -1,18 +0,0 @@
|
||||
// Test for cross-namespace Pack() code generation (issue #8948).
|
||||
// Verifies that Create* calls in Pack() are properly namespace-qualified
|
||||
// when referencing tables from different namespaces.
|
||||
|
||||
namespace native;
|
||||
|
||||
table TableWithNative {
|
||||
value: int;
|
||||
}
|
||||
|
||||
namespace foo;
|
||||
|
||||
table Consumer {
|
||||
c1: native.TableWithNative;
|
||||
c2: [native.TableWithNative];
|
||||
}
|
||||
|
||||
root_type Consumer;
|
||||
@@ -1,23 +0,0 @@
|
||||
|
||||
enum ABC: int { A, B, C }
|
||||
|
||||
struct EvenMoreStruct {
|
||||
g:[int64:2];
|
||||
}
|
||||
|
||||
table EvenMoreDefaults {
|
||||
str: EvenMoreStruct;
|
||||
ints: [int] = [];
|
||||
floats: [float] = [ ];
|
||||
float_optional: [float];
|
||||
bytes_optional: [ubyte];
|
||||
floats_required: [float] (required);
|
||||
empty_string: string = "";
|
||||
some_string: string = "some";
|
||||
zero_string: string = "0";
|
||||
a_string:string (key);
|
||||
required_string: string (required);
|
||||
abcs: [ABC] = [];
|
||||
bools: [bool] = [];
|
||||
one_bool: bool = true;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "evolution_test.h"
|
||||
|
||||
#include "evolution_test/evolution_v1_generated.h"
|
||||
#include "evolution_test/evolution_v2_generated.h"
|
||||
#include "evolution_test/evolution_v1.fbs.h"
|
||||
#include "evolution_test/evolution_v2.fbs.h"
|
||||
#include "flatbuffers/idl.h"
|
||||
#include "test_assert.h"
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
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",
|
||||
],
|
||||
)
|
||||
@@ -1,533 +0,0 @@
|
||||
// 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_
|
||||
@@ -1,621 +0,0 @@
|
||||
// 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,12 +71,3 @@ 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_bfbs_generated.h"
|
||||
#include "64bit/test_64bit_generated.h"
|
||||
#include "64bit/test_64bit_bfbs_generated.h"
|
||||
#include "flatbuffers/base.h"
|
||||
#include "flatbuffers/flatbuffer_builder.h"
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
@@ -1,479 +0,0 @@
|
||||
// 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
|
||||
|
||||
@@ -1,479 +0,0 @@
|
||||
// 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
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
#include "flatbuffers/idl.h"
|
||||
#include "monster_test_bfbs_generated.h"
|
||||
#include "monster_test_generated.h"
|
||||
#include "optional_scalars_generated.h"
|
||||
#include "optional_scalars.fbs.h"
|
||||
#include "test_assert.h"
|
||||
|
||||
namespace flatbuffers {
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
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",
|
||||
],
|
||||
)
|
||||
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_generated.h"
|
||||
#include "key_field/key_field_sample.fbs.h"
|
||||
#include "test_assert.h"
|
||||
|
||||
namespace flatbuffers {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user