mirror of
https://github.com/google/flatbuffers.git
synced 2026-08-03 22:51:08 +00:00
Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5b7f602ea8 | |||
| a06c41f2c7 | |||
| 4f6ad45b0e | |||
| 81e5f093f9 | |||
| 03fffb25e2 | |||
| 1a7495a6dd | |||
| 3c1bb67ae1 | |||
| 5b9de8b6c0 | |||
| ea0a73d168 | |||
| 4623cfa4bc | |||
| 9c2c56dc6a | |||
| 429c28c783 | |||
| e5a9ff757f | |||
| e53732b9b9 | |||
| b84b676c89 | |||
| 3211f857d1 | |||
| 95ff1f1d80 | |||
| af8997b567 | |||
| 0d67abde45 | |||
| d74e2945f7 | |||
| 8914d06ab7 | |||
| 522f2379a6 | |||
| 7cb0bcb212 | |||
| b1e7868db6 | |||
| 68e3c839c3 | |||
| 0723245085 | |||
| 9d64b9c0c0 | |||
| d01f20f2fb |
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
# Default owner
|
# Default owner
|
||||||
* @aardappel @dbaileychess derekbailey@google.com
|
* @dbaileychess derekbailey@google.com
|
||||||
|
|
||||||
# Prevent modification of this file
|
# Prevent modification of this file
|
||||||
.github/CODEOWNERS @dbaileychess derekbailey@google.com
|
.github/CODEOWNERS @dbaileychess derekbailey@google.com
|
||||||
|
|||||||
@@ -197,8 +197,7 @@ jobs:
|
|||||||
configuration: [
|
configuration: [
|
||||||
'',
|
'',
|
||||||
'-p:UnsafeByteBuffer=true',
|
'-p:UnsafeByteBuffer=true',
|
||||||
# Fails two tests currently.
|
'-p:EnableSpanT=true,UnsafeByteBuffer=true'
|
||||||
#'-p:EnableSpanT=true,UnsafeByteBuffer=true'
|
|
||||||
]
|
]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
@@ -209,7 +208,7 @@ jobs:
|
|||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
cd tests\FlatBuffers.Test
|
cd tests\FlatBuffers.Test
|
||||||
dotnet new sln --force --name FlatBuffers.Test
|
dotnet new sln --force --name FlatBuffers.Test --format sln
|
||||||
dotnet sln FlatBuffers.Test.sln add FlatBuffers.Test.csproj
|
dotnet sln FlatBuffers.Test.sln add FlatBuffers.Test.csproj
|
||||||
dotnet build -c Release ${{matrix.configuration}} FlatBuffers.Test.sln
|
dotnet build -c Release ${{matrix.configuration}} FlatBuffers.Test.sln
|
||||||
- name: Run net6.0
|
- name: Run net6.0
|
||||||
@@ -592,11 +591,16 @@ jobs:
|
|||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- 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
|
- name: bazel build
|
||||||
run: >
|
run: >
|
||||||
bazel build
|
bazel build
|
||||||
//:flatc
|
//:flatc
|
||||||
//:flatbuffers
|
//:flatbuffers
|
||||||
|
//tests:flatbuffers_test
|
||||||
- name: bazel test
|
- name: bazel test
|
||||||
run: >
|
run: >
|
||||||
bazel test
|
bazel test
|
||||||
@@ -633,8 +637,7 @@ jobs:
|
|||||||
actions: read # To read the workflow path.
|
actions: read # To read the workflow path.
|
||||||
id-token: write # To sign the provenance.
|
id-token: write # To sign the provenance.
|
||||||
contents: write # To add assets to a release.
|
contents: write # To add assets to a release.
|
||||||
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.2.1
|
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.1.0
|
||||||
with:
|
with:
|
||||||
base64-subjects: "${{ needs.release-digests.outputs.digests }}"
|
base64-subjects: "${{ needs.release-digests.outputs.digests }}"
|
||||||
upload-assets: true # Optional: Upload to a new release
|
upload-assets: true # Optional: Upload to a new release
|
||||||
compile-generator: true # Workaround for https://github.com/slsa-framework/slsa-github-generator/issues/1163
|
|
||||||
|
|||||||
@@ -305,8 +305,7 @@ function(flatbuffers_generate_headers)
|
|||||||
${FLATBUFFERS_GENERATE_HEADERS_SCHEMAS})
|
${FLATBUFFERS_GENERATE_HEADERS_SCHEMAS})
|
||||||
add_dependencies(
|
add_dependencies(
|
||||||
${FLATBUFFERS_GENERATE_HEADERS_TARGET}
|
${FLATBUFFERS_GENERATE_HEADERS_TARGET}
|
||||||
${FLATC}
|
${FLATC_TARGET})
|
||||||
${FLATBUFFERS_GENERATE_HEADERS_SCHEMAS})
|
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
${FLATBUFFERS_GENERATE_HEADERS_TARGET}
|
${FLATBUFFERS_GENERATE_HEADERS_TARGET}
|
||||||
INTERFACE ${generated_target_dir})
|
INTERFACE ${generated_target_dir})
|
||||||
|
|||||||
@@ -238,8 +238,13 @@ set(FlatBuffers_Tests_SRCS
|
|||||||
tests/util_test.cpp
|
tests/util_test.cpp
|
||||||
tests/vector_table_naked_ptr_test.h
|
tests/vector_table_naked_ptr_test.h
|
||||||
tests/vector_table_naked_ptr_test.cpp
|
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.h
|
||||||
tests/native_type_test_impl.cpp
|
tests/native_type_test_impl.cpp
|
||||||
|
tests/bigfoot_ref_test_impl.h
|
||||||
|
tests/bigfoot_ref_test_impl.cpp
|
||||||
tests/alignment_test.h
|
tests/alignment_test.h
|
||||||
tests/alignment_test.cpp
|
tests/alignment_test.cpp
|
||||||
tests/64bit/offset64_test.h
|
tests/64bit/offset64_test.h
|
||||||
@@ -548,17 +553,20 @@ if(FLATBUFFERS_BUILD_TESTS)
|
|||||||
# The flattest target needs some generated files
|
# The flattest target needs some generated files
|
||||||
SET(FLATC_OPT_COMP --cpp --gen-compare --gen-mutable --gen-object-api --reflect-names)
|
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_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)
|
||||||
|
|
||||||
compile_schema_for_test(tests/alignment_test.fbs "${FLATC_OPT_COMP}")
|
compile_schema_for_test(tests/alignment_test.fbs "${FLATC_OPT_COMP}")
|
||||||
compile_schema_for_test_fbsh(tests/default_vectors_strings_test.fbs "${FLATC_OPT_COMP}")
|
compile_schema_for_test_fbsh(tests/default_vectors_strings_test.fbs "${FLATC_OPT_COMP}")
|
||||||
compile_schema_for_test(tests/arrays_test.fbs "${FLATC_OPT_SCOPED_ENUMS}")
|
compile_schema_for_test(tests/arrays_test.fbs "${FLATC_OPT_SCOPED_ENUMS}")
|
||||||
compile_schema_for_test(tests/native_inline_table_test.fbs "${FLATC_OPT_COMP}")
|
compile_schema_for_test(tests/native_inline_table_test.fbs "${FLATC_OPT_COMP}")
|
||||||
compile_schema_for_test(tests/native_type_test.fbs "${FLATC_OPT_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/key_field/key_field_sample.fbs "${FLATC_OPT_COMP}")
|
compile_schema_for_test(tests/key_field/key_field_sample.fbs "${FLATC_OPT_COMP}")
|
||||||
compile_schema_for_test(tests/64bit/test_64bit.fbs "${FLATC_OPT_COMP};--bfbs-gen-embed")
|
compile_schema_for_test(tests/64bit/test_64bit.fbs "${FLATC_OPT_COMP};--bfbs-gen-embed")
|
||||||
compile_schema_for_test(tests/64bit/evolution/v1.fbs "${FLATC_OPT_COMP}")
|
compile_schema_for_test(tests/64bit/evolution/v1.fbs "${FLATC_OPT_COMP}")
|
||||||
compile_schema_for_test(tests/64bit/evolution/v2.fbs "${FLATC_OPT_COMP}")
|
compile_schema_for_test(tests/64bit/evolution/v2.fbs "${FLATC_OPT_COMP}")
|
||||||
compile_schema_for_test(tests/union_underlying_type_test.fbs "${FLATC_OPT_SCOPED_ENUMS}")
|
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}")
|
||||||
|
|
||||||
if(FLATBUFFERS_CODE_SANITIZE)
|
if(FLATBUFFERS_CODE_SANITIZE)
|
||||||
add_fsanitize_to_target(flattests ${FLATBUFFERS_CODE_SANITIZE})
|
add_fsanitize_to_target(flattests ${FLATBUFFERS_CODE_SANITIZE})
|
||||||
|
|||||||
+4
-3
@@ -7,7 +7,7 @@ module(
|
|||||||
|
|
||||||
bazel_dep(
|
bazel_dep(
|
||||||
name = "aspect_bazel_lib",
|
name = "aspect_bazel_lib",
|
||||||
version = "2.11.0",
|
version = "2.14.0",
|
||||||
)
|
)
|
||||||
bazel_dep(
|
bazel_dep(
|
||||||
name = "aspect_rules_esbuild",
|
name = "aspect_rules_esbuild",
|
||||||
@@ -28,11 +28,11 @@ bazel_dep(
|
|||||||
)
|
)
|
||||||
bazel_dep(
|
bazel_dep(
|
||||||
name = "platforms",
|
name = "platforms",
|
||||||
version = "0.0.10",
|
version = "0.0.11",
|
||||||
)
|
)
|
||||||
bazel_dep(
|
bazel_dep(
|
||||||
name = "rules_cc",
|
name = "rules_cc",
|
||||||
version = "0.0.16",
|
version = "0.1.1",
|
||||||
)
|
)
|
||||||
bazel_dep(
|
bazel_dep(
|
||||||
name = "rules_go",
|
name = "rules_go",
|
||||||
@@ -50,6 +50,7 @@ bazel_dep(
|
|||||||
bazel_dep(
|
bazel_dep(
|
||||||
name = "rules_swift",
|
name = "rules_swift",
|
||||||
version = "2.1.1",
|
version = "2.1.1",
|
||||||
|
max_compatibility_level = 3,
|
||||||
repo_name = "build_bazel_rules_swift",
|
repo_name = "build_bazel_rules_swift",
|
||||||
)
|
)
|
||||||
bazel_dep(
|
bazel_dep(
|
||||||
|
|||||||
+10
-3
@@ -79,11 +79,12 @@ list of `FILES...`.
|
|||||||
`myschema.fbs` to JSON:
|
`myschema.fbs` to JSON:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
flatc --json myschema.fbs mydata.bin
|
flatc --json myschema.fbs -- mydata.bin
|
||||||
```
|
```
|
||||||
|
|
||||||
This will generate a `mydata.json` file.
|
This will generate a `mydata.json` file. If there is no
|
||||||
|
[`file_identifier`](schema.md/#file-identification-and-extension) defined
|
||||||
|
for this schema, you will need to use the `--raw-binary` option.
|
||||||
|
|
||||||
### Additional options
|
### Additional options
|
||||||
|
|
||||||
@@ -167,6 +168,12 @@ list of `FILES...`.
|
|||||||
std::string from Flatbuffers, but (char* + length). This allows efficient
|
std::string from Flatbuffers, but (char* + length). This allows efficient
|
||||||
construction of custom string types, including zero-copy construction.
|
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++
|
- `--no-cpp-direct-copy` : Don't generate direct copy methods for C++
|
||||||
object-based API.
|
object-based API.
|
||||||
|
|
||||||
|
|||||||
@@ -242,6 +242,42 @@ 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_type("type")` (on a table): Tables can also be represented with
|
||||||
native types. For example, the following schema:
|
native types. For example, the following schema:
|
||||||
|
|
||||||
@@ -337,6 +373,27 @@ 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,
|
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.
|
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)
|
## Reflection (& Resizing)
|
||||||
|
|
||||||
There is experimental support for reflection in FlatBuffers, allowing you to
|
There is experimental support for reflection in FlatBuffers, allowing you to
|
||||||
|
|||||||
+8
-15
@@ -1134,12 +1134,8 @@ The Builder provides multiple ways to create `vectors`.
|
|||||||
=== "Python"
|
=== "Python"
|
||||||
|
|
||||||
```py
|
```py
|
||||||
# Create a FlatBuffer vector and prepend the weapons.
|
# Use the generated helper to create the weapons vector from offsets.
|
||||||
# Note: Since we prepend the data, prepend them in reverse order.
|
weapons = MyGame.Sample.Monster.CreateWeaponsVector(builder, [sword, axe])
|
||||||
MyGame.Sample.Monster.StartWeaponsVector(builder, 2)
|
|
||||||
builder.PrependUOffsetTRelative(axe)
|
|
||||||
builder.PrependUOffsetTRelative(sword)
|
|
||||||
weapons = builder.EndVector()
|
|
||||||
```
|
```
|
||||||
|
|
||||||
=== "Rust"
|
=== "Rust"
|
||||||
@@ -1352,16 +1348,13 @@ bit more directly.
|
|||||||
```py
|
```py
|
||||||
# Create a `vector` representing the inventory of the Orc. Each number
|
# Create a `vector` representing the inventory of the Orc. Each number
|
||||||
# could correspond to an item that can be claimed after he is slain.
|
# could correspond to an item that can be claimed after he is slain.
|
||||||
# Note: Since we prepend the bytes, this loop iterates in reverse.
|
inv = MyGame.Sample.Monster.CreateInventoryVector(builder, range(0, 10))
|
||||||
MyGame.Sample.Monster.StartInventoryVector(builder, 10)
|
|
||||||
for i in reversed(range(0, 10)):
|
|
||||||
builder.PrependByte(i)
|
|
||||||
inv = builder.EndVector()
|
|
||||||
|
|
||||||
MyGame.Sample.Monster.StartPathVector(builder, 2)
|
path_points = [
|
||||||
MyGame.Sample.Vec3.CreateVec3(builder, 1.0, 2.0, 3.0)
|
MyGame.Sample.Vec3T(x=1.0, y=2.0, z=3.0),
|
||||||
MyGame.Sample.Vec3.CreateVec3(builder, 4.0, 5.0, 6.0)
|
MyGame.Sample.Vec3T(x=4.0, y=5.0, z=6.0),
|
||||||
path = builder.EndVector()
|
]
|
||||||
|
path = MyGame.Sample.Monster.CreatePathVector(builder, path_points)
|
||||||
```
|
```
|
||||||
|
|
||||||
=== "Rust"
|
=== "Rust"
|
||||||
|
|||||||
+15
@@ -31,10 +31,25 @@ func (t *Table) String(off UOffsetT) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ByteVector gets a byte slice from data stored inside the flatbuffer.
|
// ByteVector gets a byte slice from data stored inside the flatbuffer.
|
||||||
|
// If the offset is invalid or out of bounds, returns nil to prevent crashes.
|
||||||
func (t *Table) ByteVector(off UOffsetT) []byte {
|
func (t *Table) ByteVector(off UOffsetT) []byte {
|
||||||
|
n := UOffsetT(len(t.Bytes))
|
||||||
|
// Need at least SizeUOffsetT bytes to read the relative vector offset.
|
||||||
|
u := UOffsetT(SizeUOffsetT)
|
||||||
|
if n < u || off > n-u {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
off += GetUOffsetT(t.Bytes[off:])
|
off += GetUOffsetT(t.Bytes[off:])
|
||||||
|
// Need at least SizeUOffsetT bytes to read the vector length.
|
||||||
|
if n < u || off > n-u {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
start := off + UOffsetT(SizeUOffsetT)
|
start := off + UOffsetT(SizeUOffsetT)
|
||||||
length := GetUOffsetT(t.Bytes[off:])
|
length := GetUOffsetT(t.Bytes[off:])
|
||||||
|
// Avoid overflow by checking the length against the remaining buffer space.
|
||||||
|
if length > n-start {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return t.Bytes[start : start+length]
|
return t.Bytes[start : start+length]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,12 @@ def UniverseStartGalaxiesVector(builder, numElems):
|
|||||||
def StartGalaxiesVector(builder, numElems):
|
def StartGalaxiesVector(builder, numElems):
|
||||||
return UniverseStartGalaxiesVector(builder, numElems)
|
return UniverseStartGalaxiesVector(builder, numElems)
|
||||||
|
|
||||||
|
def UniverseCreateGalaxiesVector(builder, data):
|
||||||
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
|
def CreateGalaxiesVector(builder, data):
|
||||||
|
UniverseCreateGalaxiesVector(builder, data)
|
||||||
|
|
||||||
def UniverseEnd(builder):
|
def UniverseEnd(builder):
|
||||||
return builder.EndObject()
|
return builder.EndObject()
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
// automatically generated by the FlatBuffers compiler, do not modify
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
// @generated
|
// @generated
|
||||||
extern crate alloc;
|
|
||||||
|
|
||||||
|
extern crate alloc;
|
||||||
|
|
||||||
#[allow(unused_imports, dead_code)]
|
#[allow(unused_imports, dead_code)]
|
||||||
pub mod flatbuffers {
|
pub mod flatbuffers {
|
||||||
|
|
||||||
|
extern crate alloc;
|
||||||
#[allow(unused_imports, dead_code)]
|
#[allow(unused_imports, dead_code)]
|
||||||
pub mod goldens {
|
pub mod goldens {
|
||||||
|
|
||||||
|
extern crate alloc;
|
||||||
|
|
||||||
pub enum GalaxyOffset {}
|
pub enum GalaxyOffset {}
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
|
|||||||
+17
-1
@@ -91,6 +91,14 @@ class Namer {
|
|||||||
std::string keyword_prefix;
|
std::string keyword_prefix;
|
||||||
// Suffix used to escape keywords. It is usually "_".
|
// Suffix used to escape keywords. It is usually "_".
|
||||||
std::string keyword_suffix;
|
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.
|
// Files.
|
||||||
|
|
||||||
@@ -204,8 +212,16 @@ class Namer {
|
|||||||
return result;
|
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 {
|
virtual std::string EscapeKeyword(const std::string& name) const {
|
||||||
if (keywords_.find(name) == keywords_.end()) {
|
if (keywords_.find(NormalizeKeywordCase(name)) == keywords_.end()) {
|
||||||
return name;
|
return name;
|
||||||
} else {
|
} else {
|
||||||
return config_.keyword_prefix + name + config_.keyword_suffix;
|
return config_.keyword_prefix + name + config_.keyword_suffix;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ static const Namer::Config kConfig = {
|
|||||||
/*object_suffix=*/"T",
|
/*object_suffix=*/"T",
|
||||||
/*keyword_prefix=*/"",
|
/*keyword_prefix=*/"",
|
||||||
/*keyword_suffix=*/"_",
|
/*keyword_suffix=*/"_",
|
||||||
|
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||||
/*filenames=*/Case::kKeep,
|
/*filenames=*/Case::kKeep,
|
||||||
/*directories=*/Case::kKeep,
|
/*directories=*/Case::kKeep,
|
||||||
/*output_path=*/"",
|
/*output_path=*/"",
|
||||||
@@ -49,6 +50,7 @@ static const Namer::Config kStubConfig = {
|
|||||||
/*object_suffix=*/"T",
|
/*object_suffix=*/"T",
|
||||||
/*keyword_prefix=*/"",
|
/*keyword_prefix=*/"",
|
||||||
/*keyword_suffix=*/"_",
|
/*keyword_suffix=*/"_",
|
||||||
|
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||||
/*filenames=*/Case::kKeep,
|
/*filenames=*/Case::kKeep,
|
||||||
/*directories=*/Case::kKeep,
|
/*directories=*/Case::kKeep,
|
||||||
/*output_path=*/"",
|
/*output_path=*/"",
|
||||||
|
|||||||
@@ -142,6 +142,19 @@
|
|||||||
#define FLATBUFFERS_VERSION_MAJOR 25
|
#define FLATBUFFERS_VERSION_MAJOR 25
|
||||||
#define FLATBUFFERS_VERSION_MINOR 12
|
#define FLATBUFFERS_VERSION_MINOR 12
|
||||||
#define FLATBUFFERS_VERSION_REVISION 19
|
#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_EXPAND(X) #X
|
||||||
#define FLATBUFFERS_STRING(X) FLATBUFFERS_STRING_EXPAND(X)
|
#define FLATBUFFERS_STRING(X) FLATBUFFERS_STRING_EXPAND(X)
|
||||||
namespace flatbuffers {
|
namespace flatbuffers {
|
||||||
|
|||||||
@@ -260,15 +260,15 @@ inline const char* flatbuffers_version_string() {
|
|||||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator ~ (E lhs){\
|
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator ~ (E lhs){\
|
||||||
return E(~T(lhs));\
|
return E(~T(lhs));\
|
||||||
}\
|
}\
|
||||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator |= (E &lhs, E rhs){\
|
inline FLATBUFFERS_CONSTEXPR_CPP14 E operator |= (E &lhs, E rhs){\
|
||||||
lhs = lhs | rhs;\
|
lhs = lhs | rhs;\
|
||||||
return lhs;\
|
return lhs;\
|
||||||
}\
|
}\
|
||||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator &= (E &lhs, E rhs){\
|
inline FLATBUFFERS_CONSTEXPR_CPP14 E operator &= (E &lhs, E rhs){\
|
||||||
lhs = lhs & rhs;\
|
lhs = lhs & rhs;\
|
||||||
return lhs;\
|
return lhs;\
|
||||||
}\
|
}\
|
||||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator ^= (E &lhs, E rhs){\
|
inline FLATBUFFERS_CONSTEXPR_CPP14 E operator ^= (E &lhs, E rhs){\
|
||||||
lhs = lhs ^ rhs;\
|
lhs = lhs ^ rhs;\
|
||||||
return lhs;\
|
return lhs;\
|
||||||
}\
|
}\
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ struct Type {
|
|||||||
uint16_t fixed_length; // only set if t == BASE_TYPE_ARRAY
|
uint16_t fixed_length; // only set if t == BASE_TYPE_ARRAY
|
||||||
};
|
};
|
||||||
|
|
||||||
// Represents a parsed scalar value, it's type, and field offset.
|
// Represents a parsed scalar value, its type, and field offset.
|
||||||
struct Value {
|
struct Value {
|
||||||
Value()
|
Value()
|
||||||
: constant("0"),
|
: constant("0"),
|
||||||
@@ -395,13 +395,20 @@ struct FieldDef : public Definition {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct StructDef : public Definition {
|
struct StructDef : public Definition {
|
||||||
|
enum class CycleStatus {
|
||||||
|
NotChecked,
|
||||||
|
InProgress,
|
||||||
|
Checked,
|
||||||
|
};
|
||||||
|
|
||||||
StructDef()
|
StructDef()
|
||||||
: fixed(false),
|
: fixed(false),
|
||||||
predecl(true),
|
predecl(true),
|
||||||
sortbysize(true),
|
sortbysize(true),
|
||||||
has_key(false),
|
has_key(false),
|
||||||
minalign(1),
|
minalign(1),
|
||||||
bytesize(0) {}
|
bytesize(0),
|
||||||
|
cycle_status{CycleStatus::NotChecked} {}
|
||||||
|
|
||||||
void PadLastField(size_t min_align) {
|
void PadLastField(size_t min_align) {
|
||||||
auto padding = PaddingBytes(bytesize, min_align);
|
auto padding = PaddingBytes(bytesize, min_align);
|
||||||
@@ -423,6 +430,8 @@ struct StructDef : public Definition {
|
|||||||
size_t minalign; // What the whole object needs to be aligned to.
|
size_t minalign; // What the whole object needs to be aligned to.
|
||||||
size_t bytesize; // Size if fixed.
|
size_t bytesize; // Size if fixed.
|
||||||
|
|
||||||
|
CycleStatus cycle_status; // used for determining if we have circular references
|
||||||
|
|
||||||
flatbuffers::unique_ptr<std::string> original_location;
|
flatbuffers::unique_ptr<std::string> original_location;
|
||||||
std::vector<voffset_t> reserved_ids;
|
std::vector<voffset_t> reserved_ids;
|
||||||
};
|
};
|
||||||
@@ -668,6 +677,7 @@ struct IDLOptions {
|
|||||||
std::string cpp_object_api_pointer_type;
|
std::string cpp_object_api_pointer_type;
|
||||||
std::string cpp_object_api_string_type;
|
std::string cpp_object_api_string_type;
|
||||||
bool cpp_object_api_string_flexible_constructor;
|
bool cpp_object_api_string_flexible_constructor;
|
||||||
|
std::string cpp_object_api_vector_type;
|
||||||
CaseStyle cpp_object_api_field_case_style;
|
CaseStyle cpp_object_api_field_case_style;
|
||||||
bool cpp_direct_copy;
|
bool cpp_direct_copy;
|
||||||
bool gen_nullable;
|
bool gen_nullable;
|
||||||
@@ -734,6 +744,7 @@ struct IDLOptions {
|
|||||||
bool python_gen_numpy;
|
bool python_gen_numpy;
|
||||||
|
|
||||||
bool ts_omit_entrypoint;
|
bool ts_omit_entrypoint;
|
||||||
|
bool ts_undefined_for_optionals;
|
||||||
ProtoIdGapAction proto_id_gap_action;
|
ProtoIdGapAction proto_id_gap_action;
|
||||||
|
|
||||||
// Possible options for the more general generator below.
|
// Possible options for the more general generator below.
|
||||||
@@ -860,6 +871,7 @@ struct IDLOptions {
|
|||||||
python_typing(false),
|
python_typing(false),
|
||||||
python_gen_numpy(true),
|
python_gen_numpy(true),
|
||||||
ts_omit_entrypoint(false),
|
ts_omit_entrypoint(false),
|
||||||
|
ts_undefined_for_optionals(false),
|
||||||
proto_id_gap_action(ProtoIdGapAction::WARNING),
|
proto_id_gap_action(ProtoIdGapAction::WARNING),
|
||||||
mini_reflect(IDLOptions::kNone),
|
mini_reflect(IDLOptions::kNone),
|
||||||
require_explicit_ids(false),
|
require_explicit_ids(false),
|
||||||
@@ -1001,10 +1013,13 @@ class Parser : public ParserState {
|
|||||||
known_attributes_["cpp_ptr_type_get"] = true;
|
known_attributes_["cpp_ptr_type_get"] = true;
|
||||||
known_attributes_["cpp_str_type"] = true;
|
known_attributes_["cpp_str_type"] = true;
|
||||||
known_attributes_["cpp_str_flex_ctor"] = true;
|
known_attributes_["cpp_str_flex_ctor"] = true;
|
||||||
|
known_attributes_["cpp_vector_type"] = true;
|
||||||
known_attributes_["native_inline"] = true;
|
known_attributes_["native_inline"] = true;
|
||||||
known_attributes_["native_custom_alloc"] = true;
|
known_attributes_["native_custom_alloc"] = true;
|
||||||
known_attributes_["native_type"] = true;
|
known_attributes_["native_type"] = true;
|
||||||
known_attributes_["native_type_pack_name"] = 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_["native_default"] = true;
|
||||||
known_attributes_["flexbuffer"] = true;
|
known_attributes_["flexbuffer"] = true;
|
||||||
known_attributes_["private"] = true;
|
known_attributes_["private"] = true;
|
||||||
@@ -1099,6 +1114,8 @@ class Parser : public ParserState {
|
|||||||
// others includes.
|
// others includes.
|
||||||
std::vector<IncludedFile> GetIncludedFiles() const;
|
std::vector<IncludedFile> GetIncludedFiles() const;
|
||||||
|
|
||||||
|
bool HasCircularStructDependency();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class ParseDepthGuard;
|
class ParseDepthGuard;
|
||||||
|
|
||||||
|
|||||||
+3
@@ -14,9 +14,12 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
@file:Suppress("NOTHING_TO_INLINE")
|
@file:Suppress("NOTHING_TO_INLINE")
|
||||||
|
@file:OptIn(ExperimentalNativeApi::class)
|
||||||
|
|
||||||
package com.google.flatbuffers.kotlin
|
package com.google.flatbuffers.kotlin
|
||||||
|
|
||||||
|
import kotlin.experimental.ExperimentalNativeApi
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This implementation assumes that of native macOSX64 the byte order of the implementation is
|
* This implementation assumes that of native macOSX64 the byte order of the implementation is
|
||||||
* Little Endian.
|
* Little Endian.
|
||||||
|
|||||||
@@ -296,25 +296,62 @@ function mt:Slot(slotnum)
|
|||||||
self.currentVTable[slotnum + 1] = self:Offset()
|
self.currentVTable[slotnum + 1] = self:Offset()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function finish(self, rootTable, sizePrefix)
|
local function finish(self, rootTable, sizePrefix, fileIdentifier)
|
||||||
UOffsetT:EnforceNumber(rootTable)
|
UOffsetT:EnforceNumber(rootTable)
|
||||||
self:Prep(self.minalign, sizePrefix and 8 or 4)
|
local hasFid = fileIdentifier ~= nil
|
||||||
self:PrependUOffsetTRelative(rootTable)
|
if hasFid then
|
||||||
|
assert(#fileIdentifier == 4, "File identifier must be exactly 4 bytes")
|
||||||
|
end
|
||||||
|
|
||||||
|
local fid_byte_count = (hasFid and 4 or 0)
|
||||||
|
|
||||||
|
-- alignment:
|
||||||
|
-- root offset (4)
|
||||||
|
-- optional file id (4)
|
||||||
|
-- optional size prefix (4)
|
||||||
|
self:Prep(
|
||||||
|
self.minalign,
|
||||||
|
(sizePrefix and 4 or 0) +
|
||||||
|
4 +
|
||||||
|
fid_byte_count
|
||||||
|
)
|
||||||
|
|
||||||
|
-- root offset (points past file identifier if present)
|
||||||
|
self:PrependUOffsetTRelative(rootTable + fid_byte_count)
|
||||||
|
|
||||||
|
-- file identifier
|
||||||
|
if hasFid then
|
||||||
|
for i = 4, 1, -1 do
|
||||||
|
self:PrependByte(string.byte(fileIdentifier, i))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- size prefix
|
||||||
if sizePrefix then
|
if sizePrefix then
|
||||||
local size = self.bytes.size - self.head
|
local size = self.bytes.size - self.head
|
||||||
Int32:EnforceNumber(size)
|
Int32:EnforceNumber(size)
|
||||||
self:PrependInt32(size)
|
self:PrependInt32(size)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.finished = true
|
self.finished = true
|
||||||
return self.head
|
return self.head
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function mt:Finish(rootTable)
|
function mt:Finish(rootTable)
|
||||||
return finish(self, rootTable, false)
|
return finish(self, rootTable, false, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
function mt:FinishSizePrefixed(rootTable)
|
function mt:FinishSizePrefixed(rootTable)
|
||||||
return finish(self, rootTable, true)
|
return finish(self, rootTable, true, nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
function mt:FinishWithIdentifier(rootTable, fileIdentifier)
|
||||||
|
return finish(self, rootTable, false, fileIdentifier)
|
||||||
|
end
|
||||||
|
|
||||||
|
function mt:FinishSizePrefixedWithIdentifier(rootTable, fileIdentifier)
|
||||||
|
return finish(self, rootTable, true, fileIdentifier)
|
||||||
end
|
end
|
||||||
|
|
||||||
function mt:Prepend(flags, off)
|
function mt:Prepend(flags, off)
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ namespace Google.FlatBuffers
|
|||||||
|
|
||||||
var pos = this.__vector(o);
|
var pos = this.__vector(o);
|
||||||
var len = this.__vector_len(o);
|
var len = this.__vector_len(o);
|
||||||
return bb.ToArray<T>(pos, len);
|
return bb.ToArray<T>(pos, len * ByteBuffer.SizeOf<T>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize any Table-derived type to point to the union at the given offset.
|
// Initialize any Table-derived type to point to the union at the given offset.
|
||||||
|
|||||||
@@ -422,7 +422,6 @@ class Builder(object):
|
|||||||
off2 = self.Offset() - off + N.UOffsetTFlags.bytewidth
|
off2 = self.Offset() - off + N.UOffsetTFlags.bytewidth
|
||||||
self.PlaceUOffsetT(off2)
|
self.PlaceUOffsetT(off2)
|
||||||
|
|
||||||
## @cond FLATBUFFERS_INTERNAL
|
|
||||||
def StartVector(self, elemSize, numElems, alignment):
|
def StartVector(self, elemSize, numElems, alignment):
|
||||||
"""StartVector initializes bookkeeping for writing a new vector.
|
"""StartVector initializes bookkeeping for writing a new vector.
|
||||||
|
|
||||||
@@ -438,8 +437,6 @@ class Builder(object):
|
|||||||
self.Prep(alignment, elemSize * numElems) # In case alignment > int.
|
self.Prep(alignment, elemSize * numElems) # In case alignment > int.
|
||||||
return self.Offset()
|
return self.Offset()
|
||||||
|
|
||||||
## @endcond
|
|
||||||
|
|
||||||
def EndVector(self, numElems=None):
|
def EndVector(self, numElems=None):
|
||||||
"""EndVector writes data necessary to finish vector construction."""
|
"""EndVector writes data necessary to finish vector construction."""
|
||||||
|
|
||||||
@@ -556,6 +553,21 @@ class Builder(object):
|
|||||||
self.vectorNumElems = x.size
|
self.vectorNumElems = x.size
|
||||||
return self.EndVector()
|
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
|
## @cond FLATBUFFERS_INTERNAL
|
||||||
def assertNested(self):
|
def assertNested(self):
|
||||||
"""Check that we are in the process of building an object."""
|
"""Check that we are in the process of building an object."""
|
||||||
|
|||||||
@@ -155,6 +155,12 @@ def EnumStartValuesVector(builder, numElems):
|
|||||||
def StartValuesVector(builder, numElems):
|
def StartValuesVector(builder, numElems):
|
||||||
return EnumStartValuesVector(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):
|
def EnumAddIsUnion(builder, isUnion):
|
||||||
builder.PrependBoolSlot(2, isUnion, 0)
|
builder.PrependBoolSlot(2, isUnion, 0)
|
||||||
|
|
||||||
@@ -179,6 +185,12 @@ def EnumStartAttributesVector(builder, numElems):
|
|||||||
def StartAttributesVector(builder, numElems):
|
def StartAttributesVector(builder, numElems):
|
||||||
return EnumStartAttributesVector(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):
|
def EnumAddDocumentation(builder, documentation):
|
||||||
builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(documentation), 0)
|
builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(documentation), 0)
|
||||||
|
|
||||||
@@ -191,6 +203,12 @@ def EnumStartDocumentationVector(builder, numElems):
|
|||||||
def StartDocumentationVector(builder, numElems):
|
def StartDocumentationVector(builder, numElems):
|
||||||
return EnumStartDocumentationVector(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):
|
def EnumAddDeclarationFile(builder, declarationFile):
|
||||||
builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(declarationFile), 0)
|
builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(declarationFile), 0)
|
||||||
|
|
||||||
|
|||||||
@@ -134,6 +134,12 @@ def EnumValStartDocumentationVector(builder, numElems):
|
|||||||
def StartDocumentationVector(builder, numElems):
|
def StartDocumentationVector(builder, numElems):
|
||||||
return EnumValStartDocumentationVector(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):
|
def EnumValAddAttributes(builder, attributes):
|
||||||
builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(attributes), 0)
|
builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(attributes), 0)
|
||||||
|
|
||||||
@@ -146,6 +152,12 @@ def EnumValStartAttributesVector(builder, numElems):
|
|||||||
def StartAttributesVector(builder, numElems):
|
def StartAttributesVector(builder, numElems):
|
||||||
return EnumValStartAttributesVector(builder, numElems)
|
return EnumValStartAttributesVector(builder, numElems)
|
||||||
|
|
||||||
|
def EnumValCreateAttributesVector(builder, data):
|
||||||
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
|
def CreateAttributesVector(builder, data):
|
||||||
|
EnumValCreateAttributesVector(builder, data)
|
||||||
|
|
||||||
def EnumValEnd(builder):
|
def EnumValEnd(builder):
|
||||||
return builder.EndObject()
|
return builder.EndObject()
|
||||||
|
|
||||||
|
|||||||
@@ -235,6 +235,12 @@ def FieldStartAttributesVector(builder, numElems):
|
|||||||
def StartAttributesVector(builder, numElems):
|
def StartAttributesVector(builder, numElems):
|
||||||
return FieldStartAttributesVector(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):
|
def FieldAddDocumentation(builder, documentation):
|
||||||
builder.PrependUOffsetTRelativeSlot(10, flatbuffers.number_types.UOffsetTFlags.py_type(documentation), 0)
|
builder.PrependUOffsetTRelativeSlot(10, flatbuffers.number_types.UOffsetTFlags.py_type(documentation), 0)
|
||||||
|
|
||||||
@@ -247,6 +253,12 @@ def FieldStartDocumentationVector(builder, numElems):
|
|||||||
def StartDocumentationVector(builder, numElems):
|
def StartDocumentationVector(builder, numElems):
|
||||||
return FieldStartDocumentationVector(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):
|
def FieldAddOptional(builder, optional):
|
||||||
builder.PrependBoolSlot(11, optional, 0)
|
builder.PrependBoolSlot(11, optional, 0)
|
||||||
|
|
||||||
|
|||||||
@@ -158,6 +158,12 @@ def ObjectStartFieldsVector(builder, numElems):
|
|||||||
def StartFieldsVector(builder, numElems):
|
def StartFieldsVector(builder, numElems):
|
||||||
return ObjectStartFieldsVector(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):
|
def ObjectAddIsStruct(builder, isStruct):
|
||||||
builder.PrependBoolSlot(2, isStruct, 0)
|
builder.PrependBoolSlot(2, isStruct, 0)
|
||||||
|
|
||||||
@@ -188,6 +194,12 @@ def ObjectStartAttributesVector(builder, numElems):
|
|||||||
def StartAttributesVector(builder, numElems):
|
def StartAttributesVector(builder, numElems):
|
||||||
return ObjectStartAttributesVector(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):
|
def ObjectAddDocumentation(builder, documentation):
|
||||||
builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(documentation), 0)
|
builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(documentation), 0)
|
||||||
|
|
||||||
@@ -200,6 +212,12 @@ def ObjectStartDocumentationVector(builder, numElems):
|
|||||||
def StartDocumentationVector(builder, numElems):
|
def StartDocumentationVector(builder, numElems):
|
||||||
return ObjectStartDocumentationVector(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):
|
def ObjectAddDeclarationFile(builder, declarationFile):
|
||||||
builder.PrependUOffsetTRelativeSlot(7, flatbuffers.number_types.UOffsetTFlags.py_type(declarationFile), 0)
|
builder.PrependUOffsetTRelativeSlot(7, flatbuffers.number_types.UOffsetTFlags.py_type(declarationFile), 0)
|
||||||
|
|
||||||
|
|||||||
@@ -138,6 +138,12 @@ def RPCCallStartAttributesVector(builder, numElems):
|
|||||||
def StartAttributesVector(builder, numElems):
|
def StartAttributesVector(builder, numElems):
|
||||||
return RPCCallStartAttributesVector(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):
|
def RPCCallAddDocumentation(builder, documentation):
|
||||||
builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(documentation), 0)
|
builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(documentation), 0)
|
||||||
|
|
||||||
@@ -150,6 +156,12 @@ def RPCCallStartDocumentationVector(builder, numElems):
|
|||||||
def StartDocumentationVector(builder, numElems):
|
def StartDocumentationVector(builder, numElems):
|
||||||
return RPCCallStartDocumentationVector(builder, numElems)
|
return RPCCallStartDocumentationVector(builder, numElems)
|
||||||
|
|
||||||
|
def RPCCallCreateDocumentationVector(builder, data):
|
||||||
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
|
def CreateDocumentationVector(builder, data):
|
||||||
|
RPCCallCreateDocumentationVector(builder, data)
|
||||||
|
|
||||||
def RPCCallEnd(builder):
|
def RPCCallEnd(builder):
|
||||||
return builder.EndObject()
|
return builder.EndObject()
|
||||||
|
|
||||||
|
|||||||
@@ -180,6 +180,12 @@ def SchemaStartObjectsVector(builder, numElems):
|
|||||||
def StartObjectsVector(builder, numElems):
|
def StartObjectsVector(builder, numElems):
|
||||||
return SchemaStartObjectsVector(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):
|
def SchemaAddEnums(builder, enums):
|
||||||
builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(enums), 0)
|
builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(enums), 0)
|
||||||
|
|
||||||
@@ -192,6 +198,12 @@ def SchemaStartEnumsVector(builder, numElems):
|
|||||||
def StartEnumsVector(builder, numElems):
|
def StartEnumsVector(builder, numElems):
|
||||||
return SchemaStartEnumsVector(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):
|
def SchemaAddFileIdent(builder, fileIdent):
|
||||||
builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(fileIdent), 0)
|
builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(fileIdent), 0)
|
||||||
|
|
||||||
@@ -222,6 +234,12 @@ def SchemaStartServicesVector(builder, numElems):
|
|||||||
def StartServicesVector(builder, numElems):
|
def StartServicesVector(builder, numElems):
|
||||||
return SchemaStartServicesVector(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):
|
def SchemaAddAdvancedFeatures(builder, advancedFeatures):
|
||||||
builder.PrependUint64Slot(6, advancedFeatures, 0)
|
builder.PrependUint64Slot(6, advancedFeatures, 0)
|
||||||
|
|
||||||
@@ -240,6 +258,12 @@ def SchemaStartFbsFilesVector(builder, numElems):
|
|||||||
def StartFbsFilesVector(builder, numElems):
|
def StartFbsFilesVector(builder, numElems):
|
||||||
return SchemaStartFbsFilesVector(builder, numElems)
|
return SchemaStartFbsFilesVector(builder, numElems)
|
||||||
|
|
||||||
|
def SchemaCreateFbsFilesVector(builder, data):
|
||||||
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
|
def CreateFbsFilesVector(builder, data):
|
||||||
|
SchemaCreateFbsFilesVector(builder, data)
|
||||||
|
|
||||||
def SchemaEnd(builder):
|
def SchemaEnd(builder):
|
||||||
return builder.EndObject()
|
return builder.EndObject()
|
||||||
|
|
||||||
|
|||||||
@@ -84,6 +84,12 @@ def SchemaFileStartIncludedFilenamesVector(builder, numElems):
|
|||||||
def StartIncludedFilenamesVector(builder, numElems):
|
def StartIncludedFilenamesVector(builder, numElems):
|
||||||
return SchemaFileStartIncludedFilenamesVector(builder, numElems)
|
return SchemaFileStartIncludedFilenamesVector(builder, numElems)
|
||||||
|
|
||||||
|
def SchemaFileCreateIncludedFilenamesVector(builder, data):
|
||||||
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
|
def CreateIncludedFilenamesVector(builder, data):
|
||||||
|
SchemaFileCreateIncludedFilenamesVector(builder, data)
|
||||||
|
|
||||||
def SchemaFileEnd(builder):
|
def SchemaFileEnd(builder):
|
||||||
return builder.EndObject()
|
return builder.EndObject()
|
||||||
|
|
||||||
|
|||||||
@@ -137,6 +137,12 @@ def ServiceStartCallsVector(builder, numElems):
|
|||||||
def StartCallsVector(builder, numElems):
|
def StartCallsVector(builder, numElems):
|
||||||
return ServiceStartCallsVector(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):
|
def ServiceAddAttributes(builder, attributes):
|
||||||
builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(attributes), 0)
|
builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(attributes), 0)
|
||||||
|
|
||||||
@@ -149,6 +155,12 @@ def ServiceStartAttributesVector(builder, numElems):
|
|||||||
def StartAttributesVector(builder, numElems):
|
def StartAttributesVector(builder, numElems):
|
||||||
return ServiceStartAttributesVector(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):
|
def ServiceAddDocumentation(builder, documentation):
|
||||||
builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(documentation), 0)
|
builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(documentation), 0)
|
||||||
|
|
||||||
@@ -161,6 +173,12 @@ def ServiceStartDocumentationVector(builder, numElems):
|
|||||||
def StartDocumentationVector(builder, numElems):
|
def StartDocumentationVector(builder, numElems):
|
||||||
return ServiceStartDocumentationVector(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):
|
def ServiceAddDeclarationFile(builder, declarationFile):
|
||||||
builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(declarationFile), 0)
|
builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(declarationFile), 0)
|
||||||
|
|
||||||
|
|||||||
@@ -611,6 +611,8 @@ impl<'fbb, A: Allocator> FlatBufferBuilder<'fbb, A> {
|
|||||||
// Write the VTable (we may delete it afterwards, if it is a duplicate):
|
// Write the VTable (we may delete it afterwards, if it is a duplicate):
|
||||||
let vt_start_pos = self.head;
|
let vt_start_pos = self.head;
|
||||||
let vt_end_pos = self.head + vtable_byte_len;
|
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:
|
// write the vtable header:
|
||||||
let vtfw =
|
let vtfw =
|
||||||
|
|||||||
@@ -421,6 +421,9 @@ impl<'a> Serializer for MapKeySerializer<'a> {
|
|||||||
type SerializeStruct = Impossible<(), Error>;
|
type SerializeStruct = Impossible<(), Error>;
|
||||||
type SerializeStructVariant = 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> {
|
fn serialize_bool(self, _value: bool) -> Result<(), Error> {
|
||||||
key_must_be_a_string()
|
key_must_be_a_string()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -328,6 +328,10 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const MyGame::Sample::Weapon *equipped_as_Weapon() const {
|
const MyGame::Sample::Weapon *equipped_as_Weapon() const {
|
||||||
return equipped_type() == MyGame::Sample::Equipment_Weapon ? static_cast<const MyGame::Sample::Weapon *>(equipped()) : nullptr;
|
return equipped_type() == MyGame::Sample::Equipment_Weapon ? static_cast<const MyGame::Sample::Weapon *>(equipped()) : nullptr;
|
||||||
}
|
}
|
||||||
|
template<typename T> T *mutable_equipped_as();
|
||||||
|
MyGame::Sample::Weapon *mutable_equipped_as_Weapon() {
|
||||||
|
return equipped_type() == MyGame::Sample::Equipment_Weapon ? static_cast<MyGame::Sample::Weapon *>(mutable_equipped()) : nullptr;
|
||||||
|
}
|
||||||
void *mutable_equipped() {
|
void *mutable_equipped() {
|
||||||
return GetPointer<void *>(VT_EQUIPPED);
|
return GetPointer<void *>(VT_EQUIPPED);
|
||||||
}
|
}
|
||||||
@@ -367,6 +371,10 @@ template<> inline const MyGame::Sample::Weapon *Monster::equipped_as<MyGame::Sam
|
|||||||
return equipped_as_Weapon();
|
return equipped_as_Weapon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Sample::Weapon *Monster::mutable_equipped_as<MyGame::Sample::Weapon>() {
|
||||||
|
return mutable_equipped_as_Weapon();
|
||||||
|
}
|
||||||
|
|
||||||
struct MonsterBuilder {
|
struct MonsterBuilder {
|
||||||
typedef Monster Table;
|
typedef Monster Table;
|
||||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||||
|
|||||||
@@ -33,11 +33,11 @@ result = subprocess.run(
|
|||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
print(
|
print(
|
||||||
"\n"
|
"\n"
|
||||||
"ERROR: *********************************************************\n"
|
"ERROR: **********************************************************\n"
|
||||||
"ERROR: * The following differences were found after building. *\n"
|
"ERROR: * The following differences were found after building. *\n"
|
||||||
"ERROR: * Perhaps there is a difference in the flags for the. *\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: * CMakeLists.txt vs the scripts/generate_code.py script? *\n"
|
||||||
"ERROR: *********************************************************\n"
|
"ERROR: **********************************************************\n"
|
||||||
)
|
)
|
||||||
subprocess.run(["git", "diff", "--binary", "--exit-code"], cwd=root_path)
|
subprocess.run(["git", "diff", "--binary", "--exit-code"], cwd=root_path)
|
||||||
sys.exit(result.returncode)
|
sys.exit(result.returncode)
|
||||||
@@ -55,11 +55,11 @@ result = subprocess.run(
|
|||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
print(
|
print(
|
||||||
"\n"
|
"\n"
|
||||||
"ERROR: ********************************************************\n"
|
"ERROR: *********************************************************\n"
|
||||||
"ERROR: * The following differences were found after running *\n"
|
"ERROR: * The following differences were found after running *\n"
|
||||||
"ERROR: * the script/generate_code.py script. Maybe you forgot *\n"
|
"ERROR: * the scripts/generate_code.py script. Maybe you forgot *\n"
|
||||||
"ERROR: * to run it after making changes in a generator? *\n"
|
"ERROR: * to run it after making changes in a generator? *\n"
|
||||||
"ERROR: ********************************************************\n"
|
"ERROR: *********************************************************\n"
|
||||||
)
|
)
|
||||||
subprocess.run(["git", "diff", "--binary", "--exit-code"], cwd=root_path)
|
subprocess.run(["git", "diff", "--binary", "--exit-code"], cwd=root_path)
|
||||||
sys.exit(result.returncode)
|
sys.exit(result.returncode)
|
||||||
|
|||||||
@@ -85,6 +85,11 @@ RUST_OPTS = BASE_OPTS + [
|
|||||||
"--gen-name-strings",
|
"--gen-name-strings",
|
||||||
"--rust-module-root-file",
|
"--rust-module-root-file",
|
||||||
]
|
]
|
||||||
|
RUST_STANDALONE_OPTS = BASE_OPTS + [
|
||||||
|
"--rust",
|
||||||
|
"--gen-all",
|
||||||
|
"--gen-name-strings",
|
||||||
|
]
|
||||||
RUST_SERIALIZE_OPTS = BASE_OPTS + [
|
RUST_SERIALIZE_OPTS = BASE_OPTS + [
|
||||||
"--rust",
|
"--rust",
|
||||||
"--gen-all",
|
"--gen-all",
|
||||||
@@ -246,6 +251,21 @@ flatc(
|
|||||||
schema="vector_table_naked_ptr.fbs",
|
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(
|
flatc(
|
||||||
BASE_OPTS + CPP_OPTS + CS_OPTS + JAVA_OPTS + KOTLIN_OPTS + PHP_OPTS,
|
BASE_OPTS + CPP_OPTS + CS_OPTS + JAVA_OPTS + KOTLIN_OPTS + PHP_OPTS,
|
||||||
prefix="union_vector",
|
prefix="union_vector",
|
||||||
@@ -288,6 +308,12 @@ flatc(
|
|||||||
schema="include_test/include_test1.fbs",
|
schema="include_test/include_test1.fbs",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
flatc(
|
||||||
|
RUST_STANDALONE_OPTS,
|
||||||
|
include="include_test",
|
||||||
|
schema="include_test/include_test1.fbs",
|
||||||
|
)
|
||||||
|
|
||||||
flatc(
|
flatc(
|
||||||
RUST_OPTS,
|
RUST_OPTS,
|
||||||
prefix="include_test2",
|
prefix="include_test2",
|
||||||
@@ -295,6 +321,12 @@ flatc(
|
|||||||
schema="include_test/sub/include_test2.fbs",
|
schema="include_test/sub/include_test2.fbs",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
flatc(
|
||||||
|
RUST_STANDALONE_OPTS,
|
||||||
|
include="include_test",
|
||||||
|
schema="include_test/sub/include_test2.fbs",
|
||||||
|
)
|
||||||
|
|
||||||
flatc(
|
flatc(
|
||||||
BINARY_OPTS + ["--bfbs-filenames", str(tests_path)],
|
BINARY_OPTS + ["--bfbs-filenames", str(tests_path)],
|
||||||
include="include_test",
|
include="include_test",
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ Namer::Config LuaDefaultConfig() {
|
|||||||
/*object_suffix=*/"",
|
/*object_suffix=*/"",
|
||||||
/*keyword_prefix=*/"",
|
/*keyword_prefix=*/"",
|
||||||
/*keyword_suffix=*/"_",
|
/*keyword_suffix=*/"_",
|
||||||
|
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||||
/*filenames=*/Case::kKeep,
|
/*filenames=*/Case::kKeep,
|
||||||
/*directories=*/Case::kKeep,
|
/*directories=*/Case::kKeep,
|
||||||
/*output_path=*/"",
|
/*output_path=*/"",
|
||||||
@@ -194,6 +195,13 @@ class LuaBfbsGenerator : public BaseBfbsGenerator {
|
|||||||
code += "\n";
|
code += "\n";
|
||||||
|
|
||||||
if (object == root_object) {
|
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 +
|
code += "function " + object_name + ".GetRootAs" + object_name +
|
||||||
"(buf, offset)\n";
|
"(buf, offset)\n";
|
||||||
code += " if type(buf) == \"string\" then\n";
|
code += " if type(buf) == \"string\" then\n";
|
||||||
@@ -454,6 +462,34 @@ class LuaBfbsGenerator : public BaseBfbsGenerator {
|
|||||||
code += " return builder:EndObject()\n";
|
code += " return builder:EndObject()\n";
|
||||||
code += "end\n";
|
code += "end\n";
|
||||||
code += "\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());
|
EmitCodeBlock(code, object_name, ns, object->declaration_file()->str());
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ Namer::Config NimDefaultConfig() {
|
|||||||
/*object_suffix=*/"T",
|
/*object_suffix=*/"T",
|
||||||
/*keyword_prefix=*/"",
|
/*keyword_prefix=*/"",
|
||||||
/*keyword_suffix=*/"_",
|
/*keyword_suffix=*/"_",
|
||||||
|
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||||
/*filenames=*/Case::kKeep,
|
/*filenames=*/Case::kKeep,
|
||||||
/*directories=*/Case::kKeep,
|
/*directories=*/Case::kKeep,
|
||||||
/*output_path=*/"",
|
/*output_path=*/"",
|
||||||
|
|||||||
@@ -145,6 +145,12 @@ const static FlatCOption flatc_options[] = {
|
|||||||
{"", "cpp-str-flex-ctor", "",
|
{"", "cpp-str-flex-ctor", "",
|
||||||
"Don't construct custom string types by passing std::string from "
|
"Don't construct custom string types by passing std::string from "
|
||||||
"Flatbuffers, but (char* + length)."},
|
"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",
|
{"", "cpp-field-case-style", "STYLE",
|
||||||
"Generate C++ fields using selected case style. Supported STYLE values: * "
|
"Generate C++ fields using selected case style. Supported STYLE values: * "
|
||||||
"'unchanged' - leave unchanged (default) * 'upper' - schema snake_case "
|
"'unchanged' - leave unchanged (default) * 'upper' - schema snake_case "
|
||||||
@@ -265,6 +271,9 @@ const static FlatCOption flatc_options[] = {
|
|||||||
{"", "python-gen-numpy", "", "Whether to generate numpy helpers."},
|
{"", "python-gen-numpy", "", "Whether to generate numpy helpers."},
|
||||||
{"", "ts-omit-entrypoint", "",
|
{"", "ts-omit-entrypoint", "",
|
||||||
"Omit emission of namespace entrypoint file"},
|
"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", "",
|
{"", "file-names-only", "",
|
||||||
"Print out generated file names without writing to the files"},
|
"Print out generated file names without writing to the files"},
|
||||||
{"", "grpc-filename-suffix", "SUFFIX",
|
{"", "grpc-filename-suffix", "SUFFIX",
|
||||||
@@ -542,6 +551,9 @@ FlatCOptions FlatCompiler::ParseFromCommandLineArguments(int argc,
|
|||||||
opts.cpp_object_api_string_type = argv[argi];
|
opts.cpp_object_api_string_type = argv[argi];
|
||||||
} else if (arg == "--cpp-str-flex-ctor") {
|
} else if (arg == "--cpp-str-flex-ctor") {
|
||||||
opts.cpp_object_api_string_flexible_constructor = true;
|
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") {
|
} else if (arg == "--no-cpp-direct-copy") {
|
||||||
opts.cpp_direct_copy = false;
|
opts.cpp_direct_copy = false;
|
||||||
} else if (arg == "--cpp-field-case-style") {
|
} else if (arg == "--cpp-field-case-style") {
|
||||||
@@ -710,6 +722,8 @@ FlatCOptions FlatCompiler::ParseFromCommandLineArguments(int argc,
|
|||||||
opts.python_gen_numpy = false;
|
opts.python_gen_numpy = false;
|
||||||
} else if (arg == "--ts-omit-entrypoint") {
|
} else if (arg == "--ts-omit-entrypoint") {
|
||||||
opts.ts_omit_entrypoint = true;
|
opts.ts_omit_entrypoint = true;
|
||||||
|
} else if (arg == "--ts-undefined-for-optionals") {
|
||||||
|
opts.ts_undefined_for_optionals = true;
|
||||||
} else if (arg == "--annotate-sparse-vectors") {
|
} else if (arg == "--annotate-sparse-vectors") {
|
||||||
options.annotate_include_vector_contents = false;
|
options.annotate_include_vector_contents = false;
|
||||||
} else if (arg == "--annotate") {
|
} else if (arg == "--annotate") {
|
||||||
@@ -922,6 +936,9 @@ std::unique_ptr<Parser> FlatCompiler::GenerateCode(const FlatCOptions& options,
|
|||||||
auto err = parser->ConformTo(conform_parser);
|
auto err = parser->ConformTo(conform_parser);
|
||||||
if (!err.empty()) Error("schemas don\'t conform: " + err, false);
|
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) {
|
if (options.schema_binary || opts.binary_schema_gen_embed) {
|
||||||
parser->Serialize();
|
parser->Serialize();
|
||||||
}
|
}
|
||||||
|
|||||||
+311
-33
@@ -257,6 +257,19 @@ class CppGenerator : public BaseGenerator {
|
|||||||
code_ += " FLATBUFFERS_VERSION_REVISION == " +
|
code_ += " FLATBUFFERS_VERSION_REVISION == " +
|
||||||
std::to_string(FLATBUFFERS_VERSION_REVISION) + ",";
|
std::to_string(FLATBUFFERS_VERSION_REVISION) + ",";
|
||||||
code_ += " \"Non-compatible flatbuffers version included\");";
|
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() {
|
void GenIncludeDependencies() {
|
||||||
@@ -529,6 +542,8 @@ class CppGenerator : public BaseGenerator {
|
|||||||
code_ += "";
|
code_ += "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GenerateBigfootRefForwardDecls();
|
||||||
|
|
||||||
// Generate preablmle code for mini reflection.
|
// Generate preablmle code for mini reflection.
|
||||||
if (opts_.mini_reflect != IDLOptions::kNone) {
|
if (opts_.mini_reflect != IDLOptions::kNone) {
|
||||||
// To break cyclic dependencies, first pre-declare all tables/structs.
|
// To break cyclic dependencies, first pre-declare all tables/structs.
|
||||||
@@ -758,6 +773,8 @@ class CppGenerator : public BaseGenerator {
|
|||||||
|
|
||||||
if (cur_name_space_) SetNameSpace(nullptr);
|
if (cur_name_space_) SetNameSpace(nullptr);
|
||||||
|
|
||||||
|
GenerateBigfootRefImpls();
|
||||||
|
|
||||||
// Close the include guard.
|
// Close the include guard.
|
||||||
code_ += "#endif // " + include_guard;
|
code_ += "#endif // " + include_guard;
|
||||||
|
|
||||||
@@ -892,6 +909,24 @@ class CppGenerator : public BaseGenerator {
|
|||||||
return opts_.gen_nullable ? " _Nullable " : "";
|
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,
|
static std::string NativeName(const std::string& name, const StructDef* sd,
|
||||||
const IDLOptions& opts) {
|
const IDLOptions& opts) {
|
||||||
// If the table is a native_type, return the native_type name.
|
// If the table is a native_type, return the native_type name.
|
||||||
@@ -937,6 +972,23 @@ class CppGenerator : public BaseGenerator {
|
|||||||
"std::string"; // Only for custom string types.
|
"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,
|
std::string GenTypeNativePtr(const std::string& type, const FieldDef* field,
|
||||||
bool is_constructor) {
|
bool is_constructor) {
|
||||||
auto& ptr_type = PtrType(field);
|
auto& ptr_type = PtrType(field);
|
||||||
@@ -974,20 +1026,21 @@ class CppGenerator : public BaseGenerator {
|
|||||||
case BASE_TYPE_VECTOR64:
|
case BASE_TYPE_VECTOR64:
|
||||||
case BASE_TYPE_VECTOR: {
|
case BASE_TYPE_VECTOR: {
|
||||||
const auto type_name = GenTypeNative(type.VectorType(), true, field);
|
const auto type_name = GenTypeNative(type.VectorType(), true, field);
|
||||||
if (type.struct_def &&
|
const auto vector_type = NativeVectorType(&field);
|
||||||
|
if (vector_type == "std::vector" && type.struct_def &&
|
||||||
type.struct_def->attributes.Lookup("native_custom_alloc")) {
|
type.struct_def->attributes.Lookup("native_custom_alloc")) {
|
||||||
auto native_custom_alloc =
|
auto native_custom_alloc =
|
||||||
type.struct_def->attributes.Lookup("native_custom_alloc");
|
type.struct_def->attributes.Lookup("native_custom_alloc");
|
||||||
return "std::vector<" + type_name + "," +
|
return "std::vector<" + type_name + "," +
|
||||||
native_custom_alloc->constant + "<" + type_name + ">>";
|
native_custom_alloc->constant + "<" + type_name + ">>";
|
||||||
} else {
|
} else {
|
||||||
return "std::vector<" + type_name + ">";
|
return vector_type + "<" + type_name + ">";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case BASE_TYPE_STRUCT: {
|
case BASE_TYPE_STRUCT: {
|
||||||
auto type_name = WrapInNameSpace(*type.struct_def);
|
auto type_name = WrapInNameSpace(*type.struct_def);
|
||||||
if (IsStruct(type)) {
|
if (IsStruct(type)) {
|
||||||
auto native_type = type.struct_def->attributes.Lookup("native_type");
|
auto native_type = EffectiveNativeType(field, *type.struct_def);
|
||||||
if (native_type) {
|
if (native_type) {
|
||||||
type_name = native_type->constant;
|
type_name = native_type->constant;
|
||||||
}
|
}
|
||||||
@@ -1979,7 +2032,7 @@ class CppGenerator : public BaseGenerator {
|
|||||||
const std::string& full_type =
|
const std::string& full_type =
|
||||||
(cpp_type
|
(cpp_type
|
||||||
? (IsVector(field.value.type)
|
? (IsVector(field.value.type)
|
||||||
? "std::vector<" +
|
? NativeVectorType(&field) + "<" +
|
||||||
GenTypeNativePtr(cpp_type->constant, &field,
|
GenTypeNativePtr(cpp_type->constant, &field,
|
||||||
false) +
|
false) +
|
||||||
"> "
|
"> "
|
||||||
@@ -2685,14 +2738,18 @@ class CppGenerator : public BaseGenerator {
|
|||||||
code_ += " }";
|
code_ += " }";
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenTableUnionAsGetters(const FieldDef& field) {
|
void GenTableUnionAsGetters(const FieldDef& field, bool is_mutable) {
|
||||||
const auto& type = field.value.type;
|
const auto& type = field.value.type;
|
||||||
auto u = type.enum_def;
|
auto u = type.enum_def;
|
||||||
|
|
||||||
|
code_.SetValue("MUTABLE_EXT", is_mutable ? "" : " const");
|
||||||
|
code_.SetValue("MUTABLE", is_mutable ? "mutable_" : "");
|
||||||
|
|
||||||
if (!type.enum_def->uses_multiple_type_instances)
|
if (!type.enum_def->uses_multiple_type_instances)
|
||||||
code_ +=
|
code_ +=
|
||||||
" template<typename T> "
|
" template<typename T>"
|
||||||
"const T *{{NULLABLE_EXT}}{{FIELD_NAME}}_as() const;";
|
"{{MUTABLE_EXT}} T *{{MUTABLE}}{{NULLABLE_EXT}}{{FIELD_NAME}}_as()"
|
||||||
|
"{{MUTABLE_EXT}};";
|
||||||
|
|
||||||
for (auto u_it = u->Vals().begin(); u_it != u->Vals().end(); ++u_it) {
|
for (auto u_it = u->Vals().begin(); u_it != u->Vals().end(); ++u_it) {
|
||||||
auto& ev = **u_it;
|
auto& ev = **u_it;
|
||||||
@@ -2706,15 +2763,19 @@ class CppGenerator : public BaseGenerator {
|
|||||||
EscapeKeyword(Name(field) + UnionTypeFieldSuffix()));
|
EscapeKeyword(Name(field) + UnionTypeFieldSuffix()));
|
||||||
code_.SetValue("U_ELEMENT_TYPE", WrapInNameSpace(u->defined_namespace,
|
code_.SetValue("U_ELEMENT_TYPE", WrapInNameSpace(u->defined_namespace,
|
||||||
GetEnumValUse(*u, ev)));
|
GetEnumValUse(*u, ev)));
|
||||||
code_.SetValue("U_FIELD_TYPE", "const " + full_struct_name + " *");
|
code_.SetValue("U_FIELD_TYPE",
|
||||||
|
(is_mutable ? "" : "const ") + full_struct_name + " *");
|
||||||
code_.SetValue("U_FIELD_NAME", Name(field) + "_as_" + Name(ev));
|
code_.SetValue("U_FIELD_NAME", Name(field) + "_as_" + Name(ev));
|
||||||
code_.SetValue("U_NULLABLE", NullableExtension());
|
code_.SetValue("U_NULLABLE", NullableExtension());
|
||||||
|
|
||||||
// `const Type *union_name_asType() const` accessor.
|
// `const Type *union_name_asType() const` accessor.
|
||||||
code_ += " {{U_FIELD_TYPE}}{{U_NULLABLE}}{{U_FIELD_NAME}}() const {";
|
// and `Type *mutable_union_name_asType()` accessor.
|
||||||
|
code_ +=
|
||||||
|
" {{U_FIELD_TYPE}}{{U_NULLABLE}}{{MUTABLE}}{{U_FIELD_NAME}}()"
|
||||||
|
"{{MUTABLE_EXT}} {";
|
||||||
code_ +=
|
code_ +=
|
||||||
" return {{U_GET_TYPE}}() == {{U_ELEMENT_TYPE}} ? "
|
" return {{U_GET_TYPE}}() == {{U_ELEMENT_TYPE}} ? "
|
||||||
"static_cast<{{U_FIELD_TYPE}}>({{FIELD_NAME}}()) "
|
"static_cast<{{U_FIELD_TYPE}}>({{MUTABLE}}{{FIELD_NAME}}()) "
|
||||||
": nullptr;";
|
": nullptr;";
|
||||||
code_ += " }";
|
code_ += " }";
|
||||||
}
|
}
|
||||||
@@ -2755,7 +2816,7 @@ class CppGenerator : public BaseGenerator {
|
|||||||
code_.SetValue("FIELD_VALUE", GenUnderlyingCast(field, true, call));
|
code_.SetValue("FIELD_VALUE", GenUnderlyingCast(field, true, call));
|
||||||
code_.SetValue("NULLABLE_EXT", NullableExtension());
|
code_.SetValue("NULLABLE_EXT", NullableExtension());
|
||||||
code_ += " {{FIELD_TYPE}}{{FIELD_NAME}}() const {";
|
code_ += " {{FIELD_TYPE}}{{FIELD_NAME}}() const {";
|
||||||
if (IsVector(type) && field.value.constant == "[]") {
|
if (IsVector(type) && field.value.constant == "[]") {
|
||||||
const auto& vec_type = type.VectorType();
|
const auto& vec_type = type.VectorType();
|
||||||
const std::string vtype_wire = GenTypeWire(
|
const std::string vtype_wire = GenTypeWire(
|
||||||
vec_type, "", VectorElementUserFacing(vec_type), field.offset64);
|
vec_type, "", VectorElementUserFacing(vec_type), field.offset64);
|
||||||
@@ -2799,7 +2860,7 @@ class CppGenerator : public BaseGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type.base_type == BASE_TYPE_UNION) {
|
if (type.base_type == BASE_TYPE_UNION) {
|
||||||
GenTableUnionAsGetters(field);
|
GenTableUnionAsGetters(field, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2974,6 +3035,11 @@ class CppGenerator : public BaseGenerator {
|
|||||||
auto wire_type = GenTypeGet(type, " ", "", postptr.c_str(), true);
|
auto wire_type = GenTypeGet(type, " ", "", postptr.c_str(), true);
|
||||||
code_.SetValue("FIELD_TYPE", wire_type);
|
code_.SetValue("FIELD_TYPE", wire_type);
|
||||||
|
|
||||||
|
// mutable union accessors
|
||||||
|
if (type.base_type == BASE_TYPE_UNION) {
|
||||||
|
GenTableUnionAsGetters(field, true);
|
||||||
|
}
|
||||||
|
|
||||||
if (IsVector(type) && field.value.constant == "[]") {
|
if (IsVector(type) && field.value.constant == "[]") {
|
||||||
const auto& vec_type = type.VectorType();
|
const auto& vec_type = type.VectorType();
|
||||||
const std::string vtype_wire = GenTypeWire(
|
const std::string vtype_wire = GenTypeWire(
|
||||||
@@ -3185,6 +3251,7 @@ class CppGenerator : public BaseGenerator {
|
|||||||
code_.SetValue("U_FIELD_NAME", Name(*field) + "_as_" + Name(ev));
|
code_.SetValue("U_FIELD_NAME", Name(*field) + "_as_" + Name(ev));
|
||||||
|
|
||||||
// `template<> const T *union_name_as<T>() const` accessor.
|
// `template<> const T *union_name_as<T>() const` accessor.
|
||||||
|
// and `template<> T *mutable_union_name_as<T>()` accessor.
|
||||||
code_ +=
|
code_ +=
|
||||||
"template<> "
|
"template<> "
|
||||||
"inline {{U_FIELD_TYPE}}{{STRUCT_NAME}}::{{FIELD_NAME}}_as"
|
"inline {{U_FIELD_TYPE}}{{STRUCT_NAME}}::{{FIELD_NAME}}_as"
|
||||||
@@ -3192,6 +3259,20 @@ class CppGenerator : public BaseGenerator {
|
|||||||
code_ += " return {{U_FIELD_NAME}}();";
|
code_ += " return {{U_FIELD_NAME}}();";
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
code_ += "";
|
code_ += "";
|
||||||
|
|
||||||
|
if (opts_.mutable_buffer) {
|
||||||
|
code_.SetValue("U_FIELD_TYPE", full_struct_name + " *");
|
||||||
|
code_.SetValue("U_FIELD_NAME",
|
||||||
|
"mutable_" + Name(*field) + "_as_" + Name(ev));
|
||||||
|
code_ +=
|
||||||
|
"template<> "
|
||||||
|
"inline {{U_FIELD_TYPE}}"
|
||||||
|
"{{STRUCT_NAME}}::mutable_{{FIELD_NAME}}_as"
|
||||||
|
"<{{U_ELEMENT_NAME}}>() {";
|
||||||
|
code_ += " return {{U_FIELD_NAME}}();";
|
||||||
|
code_ += "}";
|
||||||
|
code_ += "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3487,11 +3568,11 @@ class CppGenerator : public BaseGenerator {
|
|||||||
}
|
}
|
||||||
case BASE_TYPE_STRUCT: {
|
case BASE_TYPE_STRUCT: {
|
||||||
if (IsStruct(type)) {
|
if (IsStruct(type)) {
|
||||||
const auto& struct_attrs = type.struct_def->attributes;
|
const auto native_type = EffectiveNativeType(afield, *type.struct_def);
|
||||||
const auto native_type = struct_attrs.Lookup("native_type");
|
|
||||||
if (native_type) {
|
if (native_type) {
|
||||||
std::string unpack_call = "::flatbuffers::UnPack";
|
std::string unpack_call = "::flatbuffers::UnPack";
|
||||||
const auto pack_name = struct_attrs.Lookup("native_type_pack_name");
|
const auto pack_name =
|
||||||
|
EffectiveNativeTypePackName(afield, *type.struct_def);
|
||||||
if (pack_name) {
|
if (pack_name) {
|
||||||
unpack_call += pack_name->constant;
|
unpack_call += pack_name->constant;
|
||||||
}
|
}
|
||||||
@@ -3744,13 +3825,22 @@ class CppGenerator : public BaseGenerator {
|
|||||||
case BASE_TYPE_VECTOR64:
|
case BASE_TYPE_VECTOR64:
|
||||||
case BASE_TYPE_VECTOR: {
|
case BASE_TYPE_VECTOR: {
|
||||||
auto vector_type = field.value.type.VectorType();
|
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) {
|
switch (vector_type.base_type) {
|
||||||
case BASE_TYPE_STRING: {
|
case BASE_TYPE_STRING: {
|
||||||
if (NativeString(&field) == "std::string") {
|
if (!custom_vector && NativeString(&field) == "std::string") {
|
||||||
code += "_fbb.CreateVectorOfStrings(" + value + ")";
|
code += "_fbb.CreateVectorOfStrings(" + value + ")";
|
||||||
} else {
|
} else {
|
||||||
// Use by-function serialization to emulate
|
// Use by-function serialization to emulate
|
||||||
// CreateVectorOfStrings(); this works also with non-std strings.
|
// CreateVectorOfStrings(); this works also with non-std strings
|
||||||
|
// and non-std::vector vector types.
|
||||||
code +=
|
code +=
|
||||||
"_fbb.CreateVector<::flatbuffers::Offset<::flatbuffers::"
|
"_fbb.CreateVector<::flatbuffers::Offset<::flatbuffers::"
|
||||||
"String>>"
|
"String>>"
|
||||||
@@ -3765,20 +3855,37 @@ class CppGenerator : public BaseGenerator {
|
|||||||
}
|
}
|
||||||
case BASE_TYPE_STRUCT: {
|
case BASE_TYPE_STRUCT: {
|
||||||
if (IsStruct(vector_type)) {
|
if (IsStruct(vector_type)) {
|
||||||
const auto& struct_attrs =
|
const auto native_type =
|
||||||
field.value.type.struct_def->attributes;
|
EffectiveNativeType(field, *field.value.type.struct_def);
|
||||||
const auto native_type = struct_attrs.Lookup("native_type");
|
|
||||||
if (native_type) {
|
if (native_type) {
|
||||||
code += "_fbb.CreateVectorOfNativeStructs<";
|
code += "_fbb.CreateVectorOfNativeStructs<";
|
||||||
code += WrapInNameSpace(*vector_type.struct_def) + ", " +
|
code += WrapInNameSpace(*vector_type.struct_def) + ", " +
|
||||||
native_type->constant + ">";
|
native_type->constant + ">";
|
||||||
code += "(" + value;
|
if (custom_vector) {
|
||||||
const auto pack_name =
|
code += "(" + value + ".data(), " + value + ".size()";
|
||||||
struct_attrs.Lookup("native_type_pack_name");
|
} else {
|
||||||
|
code += "(" + value;
|
||||||
|
}
|
||||||
|
const auto pack_name = EffectiveNativeTypePackName(
|
||||||
|
field, *field.value.type.struct_def);
|
||||||
if (pack_name) {
|
if (pack_name) {
|
||||||
code += ", ::flatbuffers::Pack" + pack_name->constant;
|
code += ", ::flatbuffers::Pack" + pack_name->constant;
|
||||||
}
|
}
|
||||||
code += ")";
|
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 {
|
} else {
|
||||||
// If the field uses 64-bit addressing, create a 64-bit vector.
|
// If the field uses 64-bit addressing, create a 64-bit vector.
|
||||||
if (field.value.type.base_type == BASE_TYPE_VECTOR64) {
|
if (field.value.type.base_type == BASE_TYPE_VECTOR64) {
|
||||||
@@ -3790,7 +3897,11 @@ class CppGenerator : public BaseGenerator {
|
|||||||
code += "64<::flatbuffers::Vector>";
|
code += "64<::flatbuffers::Vector>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
code += "(" + value + ")";
|
if (custom_vector) {
|
||||||
|
code += "(" + value + ".data(), " + value + ".size())";
|
||||||
|
} else {
|
||||||
|
code += "(" + value + ")";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
code += "_fbb.CreateVector<::flatbuffers::Offset<";
|
code += "_fbb.CreateVector<::flatbuffers::Offset<";
|
||||||
@@ -3809,7 +3920,17 @@ class CppGenerator : public BaseGenerator {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BASE_TYPE_BOOL: {
|
case BASE_TYPE_BOOL: {
|
||||||
code += "_fbb.CreateVector(" + value + ")";
|
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 + ")";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BASE_TYPE_UNION: {
|
case BASE_TYPE_UNION: {
|
||||||
@@ -3845,9 +3966,11 @@ class CppGenerator : public BaseGenerator {
|
|||||||
// the underlying storage type (eg. uint8_t).
|
// the underlying storage type (eg. uint8_t).
|
||||||
const auto basetype = GenTypeBasic(
|
const auto basetype = GenTypeBasic(
|
||||||
field.value.type.enum_def->underlying_type, false);
|
field.value.type.enum_def->underlying_type, false);
|
||||||
code += "_fbb.CreateVectorScalarCast<" + basetype +
|
const std::string data_ptr =
|
||||||
">(::flatbuffers::data(" + value + "), " + value +
|
custom_vector ? value + ".data()"
|
||||||
".size())";
|
: "::flatbuffers::data(" + value + ")";
|
||||||
|
code += "_fbb.CreateVectorScalarCast<" + basetype + ">(" +
|
||||||
|
data_ptr + ", " + value + ".size())";
|
||||||
} else if (field.attributes.Lookup("cpp_type")) {
|
} else if (field.attributes.Lookup("cpp_type")) {
|
||||||
auto type = GenTypeBasic(vector_type, false);
|
auto type = GenTypeBasic(vector_type, false);
|
||||||
code += "_fbb.CreateVector<" + type + ">(" + value + ".size(), ";
|
code += "_fbb.CreateVector<" + type + ">(" + value + ".size(), ";
|
||||||
@@ -3856,6 +3979,27 @@ class CppGenerator : public BaseGenerator {
|
|||||||
code += "static_cast<" + type + ">((*__va->__rehasher)";
|
code += "static_cast<" + type + ">((*__va->__rehasher)";
|
||||||
code += "(__va->_" + value + "[i]" + GenPtrGet(field) + ")) : 0";
|
code += "(__va->_" + value + "[i]" + GenPtrGet(field) + ")) : 0";
|
||||||
code += "; }, &_va )";
|
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 {
|
} else {
|
||||||
// If the field uses 64-bit addressing, create a 64-bit vector.
|
// If the field uses 64-bit addressing, create a 64-bit vector.
|
||||||
if (field.value.type.base_type == BASE_TYPE_VECTOR64) {
|
if (field.value.type.base_type == BASE_TYPE_VECTOR64) {
|
||||||
@@ -3889,12 +4033,12 @@ class CppGenerator : public BaseGenerator {
|
|||||||
}
|
}
|
||||||
case BASE_TYPE_STRUCT: {
|
case BASE_TYPE_STRUCT: {
|
||||||
if (IsStruct(field.value.type)) {
|
if (IsStruct(field.value.type)) {
|
||||||
const auto& struct_attribs = field.value.type.struct_def->attributes;
|
const auto native_type =
|
||||||
const auto native_type = struct_attribs.Lookup("native_type");
|
EffectiveNativeType(field, *field.value.type.struct_def);
|
||||||
if (native_type && field.native_inline) {
|
if (native_type && field.native_inline) {
|
||||||
code += "::flatbuffers::Pack";
|
code += "::flatbuffers::Pack";
|
||||||
const auto pack_name =
|
const auto pack_name =
|
||||||
struct_attribs.Lookup("native_type_pack_name");
|
EffectiveNativeTypePackName(field, *field.value.type.struct_def);
|
||||||
if (pack_name) {
|
if (pack_name) {
|
||||||
code += pack_name->constant;
|
code += pack_name->constant;
|
||||||
}
|
}
|
||||||
@@ -4059,8 +4203,7 @@ class CppGenerator : public BaseGenerator {
|
|||||||
if (field->value.type.base_type == BASE_TYPE_STRUCT) {
|
if (field->value.type.base_type == BASE_TYPE_STRUCT) {
|
||||||
if (IsStruct(field->value.type)) {
|
if (IsStruct(field->value.type)) {
|
||||||
auto native_type =
|
auto native_type =
|
||||||
field->value.type.struct_def->attributes.Lookup(
|
EffectiveNativeType(*field, *field->value.type.struct_def);
|
||||||
"native_type");
|
|
||||||
auto native_inline = field->attributes.Lookup("native_inline");
|
auto native_inline = field->attributes.Lookup("native_inline");
|
||||||
if (native_type) {
|
if (native_type) {
|
||||||
pass_by_address = true;
|
pass_by_address = true;
|
||||||
@@ -4415,6 +4558,141 @@ 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
|
// Set up the correct namespace. Only open a namespace if the existing one is
|
||||||
// different (closing/opening only what is necessary).
|
// different (closing/opening only what is necessary).
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1243,6 +1243,58 @@ class CSharpGenerator : public BaseGenerator {
|
|||||||
}
|
}
|
||||||
code += " }\n";
|
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
|
// generate object accessors if is nested_flatbuffer
|
||||||
if (field.nested_flatbuffer) {
|
if (field.nested_flatbuffer) {
|
||||||
auto nested_type_name = NamespacedName(*field.nested_flatbuffer);
|
auto nested_type_name = NamespacedName(*field.nested_flatbuffer);
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ static Namer::Config DartDefaultConfig() {
|
|||||||
/*object_suffix=*/"T",
|
/*object_suffix=*/"T",
|
||||||
/*keyword_prefix=*/"$",
|
/*keyword_prefix=*/"$",
|
||||||
/*keyword_suffix=*/"",
|
/*keyword_suffix=*/"",
|
||||||
|
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||||
/*filenames=*/Case::kKeep,
|
/*filenames=*/Case::kKeep,
|
||||||
/*directories=*/Case::kKeep,
|
/*directories=*/Case::kKeep,
|
||||||
/*output_path=*/"",
|
/*output_path=*/"",
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ static Namer::Config GoDefaultConfig() {
|
|||||||
/*object_suffix=*/"T",
|
/*object_suffix=*/"T",
|
||||||
/*keyword_prefix=*/"",
|
/*keyword_prefix=*/"",
|
||||||
/*keyword_suffix=*/"_",
|
/*keyword_suffix=*/"_",
|
||||||
|
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||||
/*filenames=*/Case::kKeep,
|
/*filenames=*/Case::kKeep,
|
||||||
/*directories=*/Case::kKeep,
|
/*directories=*/Case::kKeep,
|
||||||
/*output_path=*/"",
|
/*output_path=*/"",
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ static Namer::Config JavaDefaultConfig() {
|
|||||||
/*object_suffix=*/"T",
|
/*object_suffix=*/"T",
|
||||||
/*keyword_prefix=*/"",
|
/*keyword_prefix=*/"",
|
||||||
/*keyword_suffix=*/"_",
|
/*keyword_suffix=*/"_",
|
||||||
|
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||||
/*filenames=*/Case::kKeep,
|
/*filenames=*/Case::kKeep,
|
||||||
/*directories=*/Case::kKeep,
|
/*directories=*/Case::kKeep,
|
||||||
/*output_path=*/"",
|
/*output_path=*/"",
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ static Namer::Config KotlinDefaultConfig() {
|
|||||||
/*object_suffix=*/"T",
|
/*object_suffix=*/"T",
|
||||||
/*keyword_prefix=*/"",
|
/*keyword_prefix=*/"",
|
||||||
/*keyword_suffix=*/"_",
|
/*keyword_suffix=*/"_",
|
||||||
|
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||||
/*filenames=*/Case::kKeep,
|
/*filenames=*/Case::kKeep,
|
||||||
/*directories=*/Case::kKeep,
|
/*directories=*/Case::kKeep,
|
||||||
/*output_path=*/"",
|
/*output_path=*/"",
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ static Namer::Config KotlinDefaultConfig() {
|
|||||||
/*object_suffix=*/"T",
|
/*object_suffix=*/"T",
|
||||||
/*keyword_prefix=*/"",
|
/*keyword_prefix=*/"",
|
||||||
/*keyword_suffix=*/"E",
|
/*keyword_suffix=*/"E",
|
||||||
|
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||||
/*filenames=*/Case::kUpperCamel,
|
/*filenames=*/Case::kUpperCamel,
|
||||||
/*directories=*/Case::kLowerCamel,
|
/*directories=*/Case::kLowerCamel,
|
||||||
/*output_path=*/"",
|
/*output_path=*/"",
|
||||||
|
|||||||
+73
-4
@@ -593,6 +593,18 @@ class PythonStubGenerator {
|
|||||||
"bytes) -> uoffset: ...\n";
|
"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";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1201,12 +1213,15 @@ class PythonGenerator : public BaseGenerator {
|
|||||||
return;
|
return;
|
||||||
} // There is no nested flatbuffer.
|
} // There is no nested flatbuffer.
|
||||||
|
|
||||||
const std::string unqualified_name = nested->constant;
|
std::string unqualified_name = nested->constant;
|
||||||
std::string qualified_name = NestedFlatbufferType(unqualified_name);
|
std::string qualified_name = NestedFlatbufferType(unqualified_name);
|
||||||
if (qualified_name.empty()) {
|
if (qualified_name.empty()) {
|
||||||
qualified_name = nested->constant;
|
qualified_name = nested->constant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// name may be partially qualified -- need to get the true unqualified name
|
||||||
|
unqualified_name = namer_.Denamespace(qualified_name);
|
||||||
|
|
||||||
const ImportMapEntry import_entry = {qualified_name, unqualified_name};
|
const ImportMapEntry import_entry = {qualified_name, unqualified_name};
|
||||||
|
|
||||||
auto& code = *code_ptr;
|
auto& code = *code_ptr;
|
||||||
@@ -1464,6 +1479,59 @@ class PythonGenerator : public BaseGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BuildVectorCreationHelper(const StructDef& struct_def,
|
||||||
|
const FieldDef& field, std::string* code_ptr,
|
||||||
|
ImportMap& imports) const {
|
||||||
|
auto& code = *code_ptr;
|
||||||
|
const auto vector_type = field.value.type.VectorType();
|
||||||
|
const bool is_struct_vector = IsStruct(vector_type);
|
||||||
|
const bool is_scalar_vector =
|
||||||
|
IsScalar(vector_type.base_type) || vector_type.enum_def != nullptr;
|
||||||
|
const std::string struct_type = namer_.Type(struct_def);
|
||||||
|
const std::string field_method = namer_.Method(field);
|
||||||
|
const std::string helper_name =
|
||||||
|
parser_.opts.python_no_type_prefix_suffix
|
||||||
|
? "Create" + field_method + "Vector"
|
||||||
|
: struct_type + "Create" + field_method + "Vector";
|
||||||
|
|
||||||
|
if (parser_.opts.python_typing) {
|
||||||
|
imports.insert(ImportMapEntry{"typing", "Iterable"});
|
||||||
|
code += "def " + helper_name +
|
||||||
|
"(builder: flatbuffers.Builder, data: Iterable[Any]) -> int:\n";
|
||||||
|
} else {
|
||||||
|
code += "def " + helper_name + "(builder, data):\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_scalar_vector || is_struct_vector) {
|
||||||
|
auto alignment = InlineAlignment(vector_type);
|
||||||
|
auto elem_size = InlineSize(vector_type);
|
||||||
|
code += Indent + "data = list(data)\n";
|
||||||
|
code += Indent + "builder.StartVector(" + NumToString(elem_size) +
|
||||||
|
", len(data), " + NumToString(alignment) + ")\n";
|
||||||
|
code += Indent + "for item in reversed(data):\n";
|
||||||
|
if (is_struct_vector) {
|
||||||
|
code += Indent + Indent + "item.Pack(builder)\n";
|
||||||
|
} else {
|
||||||
|
code += Indent + Indent + "builder.Prepend" +
|
||||||
|
namer_.Method(GenTypeBasic(vector_type)) + "(item)\n";
|
||||||
|
}
|
||||||
|
code += Indent + "return builder.EndVector()\n\n";
|
||||||
|
} else {
|
||||||
|
code += Indent + "return builder.CreateVectorOfTables(data)\n\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!parser_.opts.one_file && !parser_.opts.python_no_type_prefix_suffix) {
|
||||||
|
if (parser_.opts.python_typing) {
|
||||||
|
code += "def Create" + field_method +
|
||||||
|
"Vector(builder: flatbuffers.Builder, data: Iterable[Any]) "
|
||||||
|
"-> int:\n";
|
||||||
|
} else {
|
||||||
|
code += "def Create" + field_method + "Vector(builder, data):\n";
|
||||||
|
}
|
||||||
|
code += Indent + helper_name + "(builder, data)\n\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Set the value of one of the members of a table's vector and fills in the
|
// 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
|
// elements from a bytearray. This is for simplifying the use of nested
|
||||||
// flatbuffers.
|
// flatbuffers.
|
||||||
@@ -1614,8 +1682,8 @@ class PythonGenerator : public BaseGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate table constructors, conditioned on its members' types.
|
// Generate table constructors, conditioned on its members' types.
|
||||||
void GenTableBuilders(const StructDef& struct_def,
|
void GenTableBuilders(const StructDef& struct_def, std::string* code_ptr,
|
||||||
std::string* code_ptr) const {
|
ImportMap& imports) const {
|
||||||
GetStartOfTable(struct_def, code_ptr);
|
GetStartOfTable(struct_def, code_ptr);
|
||||||
|
|
||||||
for (auto it = struct_def.fields.vec.begin();
|
for (auto it = struct_def.fields.vec.begin();
|
||||||
@@ -1627,6 +1695,7 @@ class PythonGenerator : public BaseGenerator {
|
|||||||
BuildFieldOfTable(struct_def, field, offset, code_ptr);
|
BuildFieldOfTable(struct_def, field, offset, code_ptr);
|
||||||
if (IsVector(field.value.type)) {
|
if (IsVector(field.value.type)) {
|
||||||
BuildVectorOfTable(struct_def, field, code_ptr);
|
BuildVectorOfTable(struct_def, field, code_ptr);
|
||||||
|
BuildVectorCreationHelper(struct_def, field, code_ptr, imports);
|
||||||
BuildVectorOfTableFromBytes(struct_def, field, code_ptr);
|
BuildVectorOfTableFromBytes(struct_def, field, code_ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1693,7 +1762,7 @@ class PythonGenerator : public BaseGenerator {
|
|||||||
GenStructBuilder(struct_def, code_ptr);
|
GenStructBuilder(struct_def, code_ptr);
|
||||||
} else {
|
} else {
|
||||||
// Creates a set of functions that allow table construction.
|
// Creates a set of functions that allow table construction.
|
||||||
GenTableBuilders(struct_def, code_ptr);
|
GenTableBuilders(struct_def, code_ptr, imports);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ static Namer::Config RustDefaultConfig() {
|
|||||||
/*object_suffix=*/"T",
|
/*object_suffix=*/"T",
|
||||||
/*keyword_prefix=*/"",
|
/*keyword_prefix=*/"",
|
||||||
/*keyword_suffix=*/"_",
|
/*keyword_suffix=*/"_",
|
||||||
|
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||||
/*filenames=*/Case::kSnake,
|
/*filenames=*/Case::kSnake,
|
||||||
/*directories=*/Case::kSnake,
|
/*directories=*/Case::kSnake,
|
||||||
/*output_path=*/"",
|
/*output_path=*/"",
|
||||||
@@ -423,7 +424,6 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_.Clear();
|
code_.Clear();
|
||||||
code_ += "// " + std::string(FlatBuffersGeneratedWarning());
|
code_ += "// " + std::string(FlatBuffersGeneratedWarning());
|
||||||
code_ += "// @generated";
|
code_ += "// @generated";
|
||||||
code_ += "extern crate alloc;";
|
|
||||||
|
|
||||||
assert(!cur_name_space_);
|
assert(!cur_name_space_);
|
||||||
|
|
||||||
@@ -3005,6 +3005,7 @@ class RustGenerator : public BaseGenerator {
|
|||||||
"use self::serde::ser::{Serialize, Serializer, SerializeStruct};";
|
"use self::serde::ser::{Serialize, Serializer, SerializeStruct};";
|
||||||
code_ += "";
|
code_ += "";
|
||||||
}
|
}
|
||||||
|
code_ += "extern crate alloc;";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up the correct namespace. This opens a namespace if the current
|
// Set up the correct namespace. This opens a namespace if the current
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ static Namer::Config SwiftDefaultConfig() {
|
|||||||
/*object_suffix=*/"T",
|
/*object_suffix=*/"T",
|
||||||
/*keyword_prefix=*/"",
|
/*keyword_prefix=*/"",
|
||||||
/*keyword_suffix=*/"_",
|
/*keyword_suffix=*/"_",
|
||||||
|
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||||
/*filenames=*/Case::kKeep,
|
/*filenames=*/Case::kKeep,
|
||||||
/*directories=*/Case::kKeep,
|
/*directories=*/Case::kKeep,
|
||||||
/*output_path=*/"",
|
/*output_path=*/"",
|
||||||
@@ -1962,7 +1963,7 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
std::string GenType(const Type& type,
|
std::string GenType(const Type& type,
|
||||||
const bool should_consider_suffix = false) const {
|
const bool should_consider_suffix = false) const {
|
||||||
return IsScalar(type.base_type) ? GenTypeBasic(type)
|
return IsScalar(type.base_type) ? GenTypeBasic(type)
|
||||||
: IsArray(type) ? GenType(type.VectorType())
|
: IsArray(type) ? GenType(type.VectorType())
|
||||||
: GenTypePointer(type, should_consider_suffix);
|
: GenTypePointer(type, should_consider_suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+54
-43
@@ -67,6 +67,7 @@ Namer::Config TypeScriptDefaultConfig() {
|
|||||||
/*object_suffix=*/"T",
|
/*object_suffix=*/"T",
|
||||||
/*keyword_prefix=*/"",
|
/*keyword_prefix=*/"",
|
||||||
/*keyword_suffix=*/"_",
|
/*keyword_suffix=*/"_",
|
||||||
|
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||||
/*filenames=*/Case::kDasher,
|
/*filenames=*/Case::kDasher,
|
||||||
/*directories=*/Case::kDasher,
|
/*directories=*/Case::kDasher,
|
||||||
/*output_path=*/"",
|
/*output_path=*/"",
|
||||||
@@ -86,6 +87,7 @@ std::set<std::string> TypescriptKeywords() {
|
|||||||
"throw", "true", "try", "typeof", "var", "void",
|
"throw", "true", "try", "typeof", "var", "void",
|
||||||
"while", "with", "as", "implements", "interface", "let",
|
"while", "with", "as", "implements", "interface", "let",
|
||||||
"package", "private", "protected", "public", "static", "yield",
|
"package", "private", "protected", "public", "static", "yield",
|
||||||
|
"undefined" // Used with --ts-undefined-for-optionals
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +112,9 @@ class TsGenerator : public BaseGenerator {
|
|||||||
const std::string& file_name)
|
const std::string& file_name)
|
||||||
: BaseGenerator(parser, path, file_name, "", "_", "ts"),
|
: BaseGenerator(parser, path, file_name, "", "_", "ts"),
|
||||||
namer_(WithFlagOptions(TypeScriptDefaultConfig(), parser.opts, path),
|
namer_(WithFlagOptions(TypeScriptDefaultConfig(), parser.opts, path),
|
||||||
TypescriptKeywords()) {}
|
TypescriptKeywords()),
|
||||||
|
null_keyword_(parser_.opts.ts_undefined_for_optionals ? "undefined"
|
||||||
|
: "null") {}
|
||||||
|
|
||||||
bool generate() {
|
bool generate() {
|
||||||
generateEnums();
|
generateEnums();
|
||||||
@@ -214,6 +218,8 @@ class TsGenerator : public BaseGenerator {
|
|||||||
|
|
||||||
std::map<std::string, NsDefinition> ns_defs_;
|
std::map<std::string, NsDefinition> ns_defs_;
|
||||||
|
|
||||||
|
std::string null_keyword_;
|
||||||
|
|
||||||
// Generate code for all enums.
|
// Generate code for all enums.
|
||||||
void generateEnums() {
|
void generateEnums() {
|
||||||
for (auto it = parser_.enums_.vec.begin(); it != parser_.enums_.vec.end();
|
for (auto it = parser_.enums_.vec.begin(); it != parser_.enums_.vec.end();
|
||||||
@@ -467,7 +473,7 @@ class TsGenerator : public BaseGenerator {
|
|||||||
|
|
||||||
std::string GenDefaultValue(const FieldDef& field, import_set& imports) {
|
std::string GenDefaultValue(const FieldDef& field, import_set& imports) {
|
||||||
if (field.IsScalarOptional()) {
|
if (field.IsScalarOptional()) {
|
||||||
return "null";
|
return null_keyword_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& value = field.value;
|
const auto& value = field.value;
|
||||||
@@ -518,7 +524,7 @@ class TsGenerator : public BaseGenerator {
|
|||||||
case BASE_TYPE_STRING:
|
case BASE_TYPE_STRING:
|
||||||
case BASE_TYPE_UNION:
|
case BASE_TYPE_UNION:
|
||||||
case BASE_TYPE_STRUCT: {
|
case BASE_TYPE_STRUCT: {
|
||||||
return "null";
|
return null_keyword_;
|
||||||
}
|
}
|
||||||
|
|
||||||
case BASE_TYPE_ARRAY:
|
case BASE_TYPE_ARRAY:
|
||||||
@@ -554,16 +560,16 @@ class TsGenerator : public BaseGenerator {
|
|||||||
} else {
|
} else {
|
||||||
name = AddImport(imports, owner, *type.struct_def).name;
|
name = AddImport(imports, owner, *type.struct_def).name;
|
||||||
}
|
}
|
||||||
return allowNull ? (name + "|null") : name;
|
return allowNull ? (name + "|" + null_keyword_) : name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type.base_type) {
|
switch (type.base_type) {
|
||||||
case BASE_TYPE_BOOL:
|
case BASE_TYPE_BOOL:
|
||||||
return allowNull ? "boolean|null" : "boolean";
|
return allowNull ? ("boolean|" + null_keyword_) : "boolean";
|
||||||
case BASE_TYPE_LONG:
|
case BASE_TYPE_LONG:
|
||||||
case BASE_TYPE_ULONG:
|
case BASE_TYPE_ULONG:
|
||||||
return allowNull ? "bigint|null" : "bigint";
|
return allowNull ? ("bigint|" + null_keyword_) : "bigint";
|
||||||
case BASE_TYPE_ARRAY: {
|
case BASE_TYPE_ARRAY: {
|
||||||
std::string name;
|
std::string name;
|
||||||
if (type.element == BASE_TYPE_LONG || type.element == BASE_TYPE_ULONG) {
|
if (type.element == BASE_TYPE_LONG || type.element == BASE_TYPE_ULONG) {
|
||||||
@@ -578,16 +584,16 @@ class TsGenerator : public BaseGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return name + (allowNull ? "|null" : "");
|
return name + (allowNull ? ("|" + null_keyword_) : "");
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
if (IsScalar(type.base_type)) {
|
if (IsScalar(type.base_type)) {
|
||||||
if (type.enum_def) {
|
if (type.enum_def) {
|
||||||
const auto enum_name =
|
const auto enum_name =
|
||||||
AddImport(imports, owner, *type.enum_def).name;
|
AddImport(imports, owner, *type.enum_def).name;
|
||||||
return allowNull ? (enum_name + "|null") : enum_name;
|
return allowNull ? (enum_name + "|" + null_keyword_) : enum_name;
|
||||||
}
|
}
|
||||||
return allowNull ? "number|null" : "number";
|
return allowNull ? ("number|" + null_keyword_) : "number";
|
||||||
}
|
}
|
||||||
return "flatbuffers.Offset";
|
return "flatbuffers.Offset";
|
||||||
}
|
}
|
||||||
@@ -1039,7 +1045,8 @@ class TsGenerator : public BaseGenerator {
|
|||||||
const auto& enum_def = *union_type.enum_def;
|
const auto& enum_def = *union_type.enum_def;
|
||||||
|
|
||||||
const auto valid_union_type = GenUnionTypeTS(enum_def, imports);
|
const auto valid_union_type = GenUnionTypeTS(enum_def, imports);
|
||||||
const auto valid_union_type_with_null = valid_union_type + "|null";
|
const auto valid_union_type_with_null =
|
||||||
|
valid_union_type + "|" + null_keyword_;
|
||||||
|
|
||||||
auto ret = "\n\nexport function " + GenUnionConvFuncName(enum_def) +
|
auto ret = "\n\nexport function " + GenUnionConvFuncName(enum_def) +
|
||||||
"(\n type: " + GetTypeName(enum_def) +
|
"(\n type: " + GetTypeName(enum_def) +
|
||||||
@@ -1051,7 +1058,7 @@ class TsGenerator : public BaseGenerator {
|
|||||||
|
|
||||||
const auto union_enum_loop = [&](const std::string& accessor_str) {
|
const auto union_enum_loop = [&](const std::string& accessor_str) {
|
||||||
ret += " switch(" + enum_type + "[type]) {\n";
|
ret += " switch(" + enum_type + "[type]) {\n";
|
||||||
ret += " case 'NONE': return null; \n";
|
ret += " case 'NONE': return " + null_keyword_ + "; \n";
|
||||||
|
|
||||||
for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end();
|
for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end();
|
||||||
++it) {
|
++it) {
|
||||||
@@ -1075,7 +1082,7 @@ class TsGenerator : public BaseGenerator {
|
|||||||
ret += "\n";
|
ret += "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
ret += " default: return null;\n";
|
ret += " default: return " + null_keyword_ + ";\n";
|
||||||
ret += " }\n";
|
ret += " }\n";
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1120,7 +1127,8 @@ class TsGenerator : public BaseGenerator {
|
|||||||
ret += " const temp = " + conversion_function + "(this." +
|
ret += " const temp = " + conversion_function + "(this." +
|
||||||
namer_.Method(field_name, "Type") + "(), " +
|
namer_.Method(field_name, "Type") + "(), " +
|
||||||
field_binded_method + ");\n";
|
field_binded_method + ");\n";
|
||||||
ret += " if(temp === null) { return null; }\n";
|
ret += " if(temp === " + null_keyword_ + ") { return " +
|
||||||
|
null_keyword_ + "; }\n";
|
||||||
ret += union_has_string
|
ret += union_has_string
|
||||||
? " if(typeof temp === 'string') { return temp; }\n"
|
? " if(typeof temp === 'string') { return temp; }\n"
|
||||||
: "";
|
: "";
|
||||||
@@ -1140,12 +1148,12 @@ class TsGenerator : public BaseGenerator {
|
|||||||
"++targetEnumIndex) {\n";
|
"++targetEnumIndex) {\n";
|
||||||
ret += " const targetEnum = this." +
|
ret += " const targetEnum = this." +
|
||||||
namer_.Method(field_name, "Type") + "(targetEnumIndex);\n";
|
namer_.Method(field_name, "Type") + "(targetEnumIndex);\n";
|
||||||
ret += " if(targetEnum === null || " + enum_type +
|
ret += " if(targetEnum === " + null_keyword_ + " || " + enum_type +
|
||||||
"[targetEnum!] === 'NONE') { "
|
"[targetEnum!] === 'NONE') { "
|
||||||
"continue; }\n\n";
|
"continue; }\n\n";
|
||||||
ret += " const temp = " + conversion_function + "(targetEnum, " +
|
ret += " const temp = " + conversion_function + "(targetEnum, " +
|
||||||
field_binded_method + ", targetEnumIndex);\n";
|
field_binded_method + ", targetEnumIndex);\n";
|
||||||
ret += " if(temp === null) { continue; }\n";
|
ret += " if(temp === " + null_keyword_ + ") { continue; }\n";
|
||||||
ret += union_has_string ? " if(typeof temp === 'string') { "
|
ret += union_has_string ? " if(typeof temp === 'string') { "
|
||||||
"ret.push(temp); continue; }\n"
|
"ret.push(temp); continue; }\n"
|
||||||
: "";
|
: "";
|
||||||
@@ -1162,11 +1170,11 @@ class TsGenerator : public BaseGenerator {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string GenNullCheckConditional(
|
std::string GenNullCheckConditional(const std::string& nullCheckVar,
|
||||||
const std::string& nullCheckVar, const std::string& trueVal,
|
const std::string& trueVal,
|
||||||
const std::string& falseVal = "null") {
|
const std::string& falseVal) {
|
||||||
return "(" + nullCheckVar + " !== null ? " + trueVal + " : " + falseVal +
|
return "(" + nullCheckVar + " !== " + null_keyword_ + " ? " + trueVal +
|
||||||
")";
|
" : " + falseVal + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GenStructMemberValueTS(const StructDef& struct_def,
|
std::string GenStructMemberValueTS(const StructDef& struct_def,
|
||||||
@@ -1300,8 +1308,8 @@ class TsGenerator : public BaseGenerator {
|
|||||||
|
|
||||||
const std::string field_accessor =
|
const std::string field_accessor =
|
||||||
"this." + namer_.Method(field) + "()";
|
"this." + namer_.Method(field) + "()";
|
||||||
field_val = GenNullCheckConditional(field_accessor,
|
field_val = GenNullCheckConditional(
|
||||||
field_accessor + "!.unpack()");
|
field_accessor, field_accessor + "!.unpack()", null_keyword_);
|
||||||
auto packing = GenNullCheckConditional(
|
auto packing = GenNullCheckConditional(
|
||||||
"this." + field_field,
|
"this." + field_field,
|
||||||
"this." + field_field + "!.pack(builder)", "0");
|
"this." + field_field + "!.pack(builder)", "0");
|
||||||
@@ -1509,8 +1517,8 @@ class TsGenerator : public BaseGenerator {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// length 0 vector is simply empty instead of null
|
// length 0 vector is simply empty instead of null/undefined.
|
||||||
field_type += is_vector ? "" : "|null";
|
field_type += is_vector ? "" : ("|" + null_keyword_);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!field_offset_decl.empty()) {
|
if (!field_offset_decl.empty()) {
|
||||||
@@ -1539,7 +1547,7 @@ class TsGenerator : public BaseGenerator {
|
|||||||
} else {
|
} else {
|
||||||
if (field.IsScalarOptional()) {
|
if (field.IsScalarOptional()) {
|
||||||
pack_func_create_call +=
|
pack_func_create_call +=
|
||||||
" if (" + field_offset_val + " !== null)\n ";
|
" if (" + field_offset_val + " !== " + null_keyword_ + ")\n ";
|
||||||
}
|
}
|
||||||
pack_func_create_call += " " + struct_name + "." +
|
pack_func_create_call += " " + struct_name + "." +
|
||||||
namer_.Method("add", field) + "(builder, " +
|
namer_.Method("add", field) + "(builder, " +
|
||||||
@@ -1629,7 +1637,8 @@ class TsGenerator : public BaseGenerator {
|
|||||||
"> {\n";
|
"> {\n";
|
||||||
else
|
else
|
||||||
code += " {\n";
|
code += " {\n";
|
||||||
code += " bb: flatbuffers.ByteBuffer|null = null;\n";
|
code += " bb: flatbuffers.ByteBuffer|" + null_keyword_ + " = " +
|
||||||
|
null_keyword_ + ";\n";
|
||||||
code += " bb_pos = 0;\n";
|
code += " bb_pos = 0;\n";
|
||||||
|
|
||||||
// Generate the __init method that sets the field in a pre-existing
|
// Generate the __init method that sets the field in a pre-existing
|
||||||
@@ -1681,7 +1690,7 @@ class TsGenerator : public BaseGenerator {
|
|||||||
GenDocComment(field.doc_comment, code_ptr);
|
GenDocComment(field.doc_comment, code_ptr);
|
||||||
std::string prefix = namer_.Method(field) + "(";
|
std::string prefix = namer_.Method(field) + "(";
|
||||||
if (is_string) {
|
if (is_string) {
|
||||||
code += prefix + "):string|null\n";
|
code += prefix + "):string|" + null_keyword_ + "\n";
|
||||||
code +=
|
code +=
|
||||||
prefix + "optionalEncoding:flatbuffers.Encoding" + "):" +
|
prefix + "optionalEncoding:flatbuffers.Encoding" + "):" +
|
||||||
GenTypeName(imports, struct_def, field.value.type, false, true) +
|
GenTypeName(imports, struct_def, field.value.type, false, true) +
|
||||||
@@ -1731,7 +1740,8 @@ class TsGenerator : public BaseGenerator {
|
|||||||
.name;
|
.name;
|
||||||
GenDocComment(field.doc_comment, code_ptr);
|
GenDocComment(field.doc_comment, code_ptr);
|
||||||
code += namer_.Method(field);
|
code += namer_.Method(field);
|
||||||
code += "(obj?:" + type + "):" + type + "|null {\n";
|
code +=
|
||||||
|
"(obj?:" + type + "):" + type + "|" + null_keyword_ + " {\n";
|
||||||
|
|
||||||
if (struct_def.fixed) {
|
if (struct_def.fixed) {
|
||||||
code += " return (obj || " + GenerateNewExpression(type);
|
code += " return (obj || " + GenerateNewExpression(type);
|
||||||
@@ -1744,7 +1754,7 @@ class TsGenerator : public BaseGenerator {
|
|||||||
code += field.value.type.struct_def->fixed
|
code += field.value.type.struct_def->fixed
|
||||||
? "this.bb_pos + offset"
|
? "this.bb_pos + offset"
|
||||||
: GenBBAccess() + ".__indirect(this.bb_pos + offset)";
|
: GenBBAccess() + ".__indirect(this.bb_pos + offset)";
|
||||||
code += ", " + GenBBAccess() + ") : null;\n";
|
code += ", " + GenBBAccess() + ") : " + null_keyword_ + ";\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -1797,7 +1807,7 @@ class TsGenerator : public BaseGenerator {
|
|||||||
} else {
|
} else {
|
||||||
code += prefix;
|
code += prefix;
|
||||||
}
|
}
|
||||||
code += "):" + vectortypename + "|null {\n";
|
code += "):" + vectortypename + "|" + null_keyword_ + " {\n";
|
||||||
|
|
||||||
if (vectortype.base_type == BASE_TYPE_STRUCT) {
|
if (vectortype.base_type == BASE_TYPE_STRUCT) {
|
||||||
code += offset_prefix + "(obj || " +
|
code += offset_prefix + "(obj || " +
|
||||||
@@ -1837,7 +1847,7 @@ class TsGenerator : public BaseGenerator {
|
|||||||
code += " : 0";
|
code += " : 0";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
code += ": null";
|
code += ": " + null_keyword_;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1895,7 +1905,7 @@ class TsGenerator : public BaseGenerator {
|
|||||||
} else {
|
} else {
|
||||||
code += prefix;
|
code += prefix;
|
||||||
}
|
}
|
||||||
code += "):" + vectortypename + "|null {\n";
|
code += "):" + vectortypename + "|" + null_keyword_ + " {\n";
|
||||||
|
|
||||||
if (vectortype.base_type == BASE_TYPE_STRUCT) {
|
if (vectortype.base_type == BASE_TYPE_STRUCT) {
|
||||||
code += offset_prefix + "(obj || " +
|
code += offset_prefix + "(obj || " +
|
||||||
@@ -1921,12 +1931,12 @@ class TsGenerator : public BaseGenerator {
|
|||||||
code += "BigInt(0)";
|
code += "BigInt(0)";
|
||||||
} else if (IsScalar(field.value.type.element)) {
|
} else if (IsScalar(field.value.type.element)) {
|
||||||
if (field.value.type.enum_def) {
|
if (field.value.type.enum_def) {
|
||||||
code += "null";
|
code += null_keyword_;
|
||||||
} else {
|
} else {
|
||||||
code += "0";
|
code += "0";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
code += "null";
|
code += null_keyword_;
|
||||||
}
|
}
|
||||||
code += ";\n";
|
code += ";\n";
|
||||||
break;
|
break;
|
||||||
@@ -1939,13 +1949,13 @@ class TsGenerator : public BaseGenerator {
|
|||||||
const auto& union_enum = *(field.value.type.enum_def);
|
const auto& union_enum = *(field.value.type.enum_def);
|
||||||
const auto union_type = GenUnionGenericTypeTS(union_enum);
|
const auto union_type = GenUnionGenericTypeTS(union_enum);
|
||||||
code += "<T extends flatbuffers.Table>(obj:" + union_type +
|
code += "<T extends flatbuffers.Table>(obj:" + union_type +
|
||||||
"):" + union_type +
|
"):" + union_type + "|" + null_keyword_ +
|
||||||
"|null "
|
" "
|
||||||
"{\n";
|
"{\n";
|
||||||
|
|
||||||
code += offset_prefix +
|
code += offset_prefix +
|
||||||
GenGetter(field.value.type, "(obj, this.bb_pos + offset)") +
|
GenGetter(field.value.type, "(obj, this.bb_pos + offset)") +
|
||||||
" : null;\n";
|
" : " + null_keyword_ + ";\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -2007,14 +2017,15 @@ class TsGenerator : public BaseGenerator {
|
|||||||
GenDocComment(code_ptr);
|
GenDocComment(code_ptr);
|
||||||
|
|
||||||
code += namer_.Method(field, "Array");
|
code += namer_.Method(field, "Array");
|
||||||
code +=
|
code += "():" + GenType(vectorType) + "Array|" + null_keyword_ +
|
||||||
"():" + GenType(vectorType) + "Array|null {\n" + offset_prefix;
|
" {\n" + offset_prefix;
|
||||||
|
|
||||||
code += "new " + GenType(vectorType) + "Array(" + GenBBAccess() +
|
code += "new " + GenType(vectorType) + "Array(" + GenBBAccess() +
|
||||||
".bytes().buffer, " + GenBBAccess() +
|
".bytes().buffer, " + GenBBAccess() +
|
||||||
".bytes().byteOffset + " + GenBBAccess() +
|
".bytes().byteOffset + " + GenBBAccess() +
|
||||||
".__vector(this.bb_pos + offset), " + GenBBAccess() +
|
".__vector(this.bb_pos + offset), " + GenBBAccess() +
|
||||||
".__vector_len(this.bb_pos + offset)) : null;\n}\n\n";
|
".__vector_len(this.bb_pos + offset)) : " + null_keyword_ +
|
||||||
|
";\n}\n\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2084,7 +2095,7 @@ class TsGenerator : public BaseGenerator {
|
|||||||
if (!IsScalar(field.value.type.base_type)) {
|
if (!IsScalar(field.value.type.base_type)) {
|
||||||
code += "0";
|
code += "0";
|
||||||
} else if (HasNullDefault(field)) {
|
} else if (HasNullDefault(field)) {
|
||||||
code += "null";
|
code += null_keyword_;
|
||||||
} else {
|
} else {
|
||||||
if (field.value.type.base_type == BASE_TYPE_BOOL) {
|
if (field.value.type.base_type == BASE_TYPE_BOOL) {
|
||||||
code += "+";
|
code += "+";
|
||||||
@@ -2201,7 +2212,7 @@ class TsGenerator : public BaseGenerator {
|
|||||||
const auto arg_name = GetArgName(field);
|
const auto arg_name = GetArgName(field);
|
||||||
|
|
||||||
if (field.IsScalarOptional()) {
|
if (field.IsScalarOptional()) {
|
||||||
code += " if (" + arg_name + " !== null)\n ";
|
code += " if (" + arg_name + " !== " + null_keyword_ + ")\n ";
|
||||||
}
|
}
|
||||||
|
|
||||||
code += " " + methodPrefix + "." + namer_.Method("add", field) + "(";
|
code += " " + methodPrefix + "." + namer_.Method("add", field) + "(";
|
||||||
@@ -2241,7 +2252,7 @@ class TsGenerator : public BaseGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool HasNullDefault(const FieldDef& field) {
|
bool HasNullDefault(const FieldDef& field) {
|
||||||
return field.IsOptional() && field.value.constant == "null";
|
return field.IsOptional() && field.value.constant == "null";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1286,6 +1286,55 @@ CheckedError Parser::ParseField(StructDef& struct_def) {
|
|||||||
"'native_inline' can only be defined on structs, vector of structs or "
|
"'native_inline' can only be defined on structs, vector of structs or "
|
||||||
"vector of tables");
|
"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");
|
auto nested = field->attributes.Lookup("nested_flatbuffer");
|
||||||
if (nested) {
|
if (nested) {
|
||||||
if (nested->type.base_type != BASE_TYPE_STRING)
|
if (nested->type.base_type != BASE_TYPE_STRING)
|
||||||
@@ -2755,6 +2804,42 @@ std::vector<IncludedFile> Parser::GetIncludedFiles() const {
|
|||||||
return {it->second.cbegin(), it->second.cend()};
|
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) {
|
bool Parser::SupportsOptionalScalars(const flatbuffers::IDLOptions& opts) {
|
||||||
static FLATBUFFERS_CONSTEXPR unsigned long supported_langs =
|
static FLATBUFFERS_CONSTEXPR unsigned long supported_langs =
|
||||||
IDLOptions::kRust | IDLOptions::kSwift | IDLOptions::kLobster |
|
IDLOptions::kRust | IDLOptions::kSwift | IDLOptions::kLobster |
|
||||||
|
|||||||
@@ -156,6 +156,7 @@ static bool VerifyVector(flatbuffers::Verifier& v,
|
|||||||
auto type_vec = table.GetPointer<Vector<uint8_t>*>(vec_field.offset() -
|
auto type_vec = table.GetPointer<Vector<uint8_t>*>(vec_field.offset() -
|
||||||
sizeof(voffset_t));
|
sizeof(voffset_t));
|
||||||
if (!v.VerifyVector(type_vec)) return false;
|
if (!v.VerifyVector(type_vec)) return false;
|
||||||
|
if (type_vec->size() != vec->size()) return false;
|
||||||
for (uoffset_t j = 0; j < vec->size(); j++) {
|
for (uoffset_t j = 0; j < vec->size(); j++) {
|
||||||
// get union type from the prev field
|
// get union type from the prev field
|
||||||
auto utype = type_vec->Get(j);
|
auto utype = type_vec->Get(j);
|
||||||
|
|||||||
+2
-1
@@ -14,7 +14,8 @@ swift_library(
|
|||||||
name = "swift",
|
name = "swift",
|
||||||
srcs = glob([
|
srcs = glob([
|
||||||
"Sources/FlatBuffers/*.swift",
|
"Sources/FlatBuffers/*.swift",
|
||||||
"Sources/Common/*.swift",
|
"Sources/FlatBuffers/Vectors/*.swift",
|
||||||
|
"Sources/Common/*.swift"
|
||||||
]),
|
]),
|
||||||
module_name = "FlatBuffers",
|
module_name = "FlatBuffers",
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
|
|||||||
@@ -78,6 +78,9 @@ cc_test(
|
|||||||
"vector_table_naked_ptr/vector_table_naked_ptr_generated.h",
|
"vector_table_naked_ptr/vector_table_naked_ptr_generated.h",
|
||||||
"vector_table_naked_ptr_test.h",
|
"vector_table_naked_ptr_test.h",
|
||||||
"vector_table_naked_ptr_test.cpp",
|
"vector_table_naked_ptr_test.cpp",
|
||||||
|
"test_vector_type.h",
|
||||||
|
"cpp_vector_type_test.h",
|
||||||
|
"cpp_vector_type_test.cpp",
|
||||||
],
|
],
|
||||||
copts = [
|
copts = [
|
||||||
"-DFLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE",
|
"-DFLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE",
|
||||||
@@ -136,6 +139,7 @@ cc_test(
|
|||||||
deps = [
|
deps = [
|
||||||
":alignment_test_cc_fbs",
|
":alignment_test_cc_fbs",
|
||||||
":arrays_test_cc_fbs",
|
":arrays_test_cc_fbs",
|
||||||
|
":cpp_vector_type_cc_fbs",
|
||||||
":default_vectors_strings_test_cc_fbs",
|
":default_vectors_strings_test_cc_fbs",
|
||||||
":monster_extra_cc_fbs",
|
":monster_extra_cc_fbs",
|
||||||
":monster_test_cc_fbs",
|
":monster_test_cc_fbs",
|
||||||
@@ -271,6 +275,19 @@ flatbuffer_cc_library(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
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",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
flatbuffer_cc_library(
|
flatbuffer_cc_library(
|
||||||
name = "alignment_test_cc_fbs",
|
name = "alignment_test_cc_fbs",
|
||||||
srcs = ["alignment_test.fbs"],
|
srcs = ["alignment_test.fbs"],
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 Google Inc. All rights reserved.
|
* Copyright 2014 Google Inc. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -90,6 +90,9 @@ namespace Google.FlatBuffers.Test
|
|||||||
fbb.AddOffset(test1.Value);
|
fbb.AddOffset(test1.Value);
|
||||||
var testArrayOfString = fbb.EndVector();
|
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.StartMonster(fbb);
|
||||||
Monster.AddPos(fbb, Vec3.CreateVec3(fbb, 1.0f, 2.0f, 3.0f, 3.0,
|
Monster.AddPos(fbb, Vec3.CreateVec3(fbb, 1.0f, 2.0f, 3.0f, 3.0,
|
||||||
Color.Green, (short)5, (sbyte)6));
|
Color.Green, (short)5, (sbyte)6));
|
||||||
@@ -102,6 +105,8 @@ namespace Google.FlatBuffers.Test
|
|||||||
Monster.AddTestarrayofstring(fbb, testArrayOfString);
|
Monster.AddTestarrayofstring(fbb, testArrayOfString);
|
||||||
Monster.AddTestbool(fbb, true);
|
Monster.AddTestbool(fbb, true);
|
||||||
Monster.AddTestarrayoftables(fbb, sortMons);
|
Monster.AddTestarrayoftables(fbb, sortMons);
|
||||||
|
Monster.AddVectorOfLongs(fbb, longsVector);
|
||||||
|
Monster.AddVectorOfDoubles(fbb, doublesVector);
|
||||||
var mon = Monster.EndMonster(fbb);
|
var mon = Monster.EndMonster(fbb);
|
||||||
|
|
||||||
if (sizePrefix)
|
if (sizePrefix)
|
||||||
@@ -285,6 +290,13 @@ namespace Google.FlatBuffers.Test
|
|||||||
Assert.IsTrue(monster.GetTestarrayofboolsBytes().HasValue);
|
Assert.IsTrue(monster.GetTestarrayofboolsBytes().HasValue);
|
||||||
}
|
}
|
||||||
#endif
|
#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]
|
[FlatBuffersTestMethod]
|
||||||
|
|||||||
@@ -0,0 +1,249 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2025 Google Inc. All rights reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using MyGame.Example;
|
||||||
|
|
||||||
|
namespace Google.FlatBuffers.Test
|
||||||
|
{
|
||||||
|
[FlatBuffersTestClass]
|
||||||
|
public class FlatBuffersFixedLengthArrayTests
|
||||||
|
{
|
||||||
|
[FlatBuffersTestMethod]
|
||||||
|
public void FixedLengthArray_LengthConstantsMatchSchema_ReturnTrue()
|
||||||
|
{
|
||||||
|
const int nestedALength = NestedStruct.ALength;
|
||||||
|
const int nestedCLength = NestedStruct.CLength;
|
||||||
|
const int nestedDLength = NestedStruct.DLength;
|
||||||
|
const int arrayBLength = ArrayStruct.BLength;
|
||||||
|
const int arrayFLength = ArrayStruct.FLength;
|
||||||
|
|
||||||
|
Assert.AreEqual(2, nestedALength);
|
||||||
|
Assert.AreEqual(2, nestedCLength);
|
||||||
|
Assert.AreEqual(2, nestedDLength);
|
||||||
|
Assert.AreEqual(15, arrayBLength);
|
||||||
|
Assert.AreEqual(2, arrayFLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if ENABLE_SPAN_T
|
||||||
|
[FlatBuffersTestMethod]
|
||||||
|
public void FixedLengthArray_GetBytesSpanLengthIsCorrect_ReturnTrue()
|
||||||
|
{
|
||||||
|
var builder = new FlatBufferBuilder(1024);
|
||||||
|
var ints = new int[] { 1, 2 };
|
||||||
|
var enumB = TestEnum.A;
|
||||||
|
var enums = new TestEnum[] { TestEnum.B, TestEnum.C };
|
||||||
|
var longs = new long[] { 10L, 20L };
|
||||||
|
|
||||||
|
var structOffset = NestedStruct.CreateNestedStruct(builder, ints, enumB, enums, longs);
|
||||||
|
builder.Finish(structOffset.Value);
|
||||||
|
|
||||||
|
var bb = builder.DataBuffer;
|
||||||
|
var nestedStruct = new NestedStruct();
|
||||||
|
nestedStruct.__assign(bb.Length - builder.Offset, bb);
|
||||||
|
|
||||||
|
Span<int> intSpan = nestedStruct.GetABytes();
|
||||||
|
Span<TestEnum> enumSpan = nestedStruct.GetCBytes();
|
||||||
|
Span<long> longSpan = nestedStruct.GetDBytes();
|
||||||
|
|
||||||
|
Assert.AreEqual(intSpan.Length, NestedStruct.ALength);
|
||||||
|
Assert.AreEqual(enumSpan.Length, NestedStruct.CLength);
|
||||||
|
Assert.AreEqual(longSpan.Length, NestedStruct.DLength);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !ENABLE_SPAN_T
|
||||||
|
[FlatBuffersTestMethod]
|
||||||
|
public void FixedLengthArray_GetBytesArraySegmentLengthIsCorrect_ReturnTrue()
|
||||||
|
{
|
||||||
|
var builder = new FlatBufferBuilder(1024);
|
||||||
|
var ints = new int[] { 1, 2 };
|
||||||
|
var enumB = TestEnum.A;
|
||||||
|
var enums = new TestEnum[] { TestEnum.B, TestEnum.C };
|
||||||
|
var longs = new long[] { 10L, 20L };
|
||||||
|
|
||||||
|
var structOffset = NestedStruct.CreateNestedStruct(builder, ints, enumB, enums, longs);
|
||||||
|
builder.Finish(structOffset.Value);
|
||||||
|
|
||||||
|
var buffer = builder.DataBuffer;
|
||||||
|
var nestedStruct = new NestedStruct();
|
||||||
|
nestedStruct.__assign(buffer.Length - builder.Offset, buffer);
|
||||||
|
|
||||||
|
Assert.IsTrue(nestedStruct.GetABytes().HasValue);
|
||||||
|
Assert.IsTrue(nestedStruct.GetCBytes().HasValue);
|
||||||
|
Assert.IsTrue(nestedStruct.GetDBytes().HasValue);
|
||||||
|
|
||||||
|
ArraySegment<byte> intSegment = nestedStruct.GetABytes().Value;
|
||||||
|
ArraySegment<byte> enumSegment = nestedStruct.GetCBytes().Value;
|
||||||
|
ArraySegment<byte> longSegment = nestedStruct.GetDBytes().Value;
|
||||||
|
|
||||||
|
Assert.AreEqual(intSegment.Count, NestedStruct.ALength * sizeof(int));
|
||||||
|
Assert.AreEqual(enumSegment.Count, NestedStruct.CLength * sizeof(sbyte));
|
||||||
|
Assert.AreEqual(longSegment.Count, NestedStruct.DLength * sizeof(long));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ENABLE_SPAN_T
|
||||||
|
[FlatBuffersTestMethod]
|
||||||
|
public void FixedLengthArray_GetBytesSpanEquality_ReturnTrue()
|
||||||
|
{
|
||||||
|
var builder = new FlatBufferBuilder(1024);
|
||||||
|
|
||||||
|
var floatA = 3.14f;
|
||||||
|
var intArray = Enumerable.Range(1, 15).ToArray();
|
||||||
|
var byteC = (sbyte)42;
|
||||||
|
var intE = 999;
|
||||||
|
var longArray = new long[] { 5000L, 6000L };
|
||||||
|
|
||||||
|
var nestedInts = new int[2, 2] { { 10, 20 }, { 30, 40 } };
|
||||||
|
var nestedEnumB = new TestEnum[] { TestEnum.A, TestEnum.B };
|
||||||
|
var nestedEnums = new TestEnum[2, 2] { { TestEnum.A, TestEnum.B }, { TestEnum.C, TestEnum.A } };
|
||||||
|
var nestedLongs = new long[2, 2] { { 100L, 200L }, { 300L, 400L } };
|
||||||
|
|
||||||
|
var structOffset = ArrayStruct.CreateArrayStruct(builder, floatA, intArray, byteC,
|
||||||
|
nestedInts, nestedEnumB, nestedEnums, nestedLongs, intE, longArray);
|
||||||
|
|
||||||
|
ArrayTable.StartArrayTable(builder);
|
||||||
|
ArrayTable.AddA(builder, structOffset);
|
||||||
|
var rootTable = ArrayTable.EndArrayTable(builder);
|
||||||
|
builder.Finish(rootTable.Value);
|
||||||
|
|
||||||
|
var finishedBytes = builder.SizedByteArray();
|
||||||
|
ByteBuffer bb = new ByteBuffer(finishedBytes);
|
||||||
|
ArrayTable arrayTable = ArrayTable.GetRootAsArrayTable(bb);
|
||||||
|
ArrayStruct arrayStruct = arrayTable.A.Value;
|
||||||
|
|
||||||
|
Assert.AreEqual(byteC, arrayStruct.C);
|
||||||
|
Assert.AreEqual(intE, arrayStruct.E);
|
||||||
|
|
||||||
|
Assert.IsTrue(arrayStruct.GetBBytes().SequenceEqual(intArray));
|
||||||
|
Assert.IsTrue(arrayStruct.GetFBytes().SequenceEqual(longArray));
|
||||||
|
|
||||||
|
// Test nested struct arrays
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
var nestedStruct = arrayStruct.D(i);
|
||||||
|
|
||||||
|
var nestedIntSpan = nestedStruct.GetABytes();
|
||||||
|
var expectedNestedInts = new int[] { nestedInts[i, 0], nestedInts[i, 1] };
|
||||||
|
Assert.IsTrue(nestedIntSpan.SequenceEqual(expectedNestedInts));
|
||||||
|
|
||||||
|
Assert.AreEqual(nestedEnumB[i], nestedStruct.B);
|
||||||
|
|
||||||
|
var nestedEnumSpan = nestedStruct.GetCBytes();
|
||||||
|
var expectedNestedEnums = new TestEnum[] { nestedEnums[i, 0], nestedEnums[i, 1] };
|
||||||
|
Assert.IsTrue(nestedEnumSpan.SequenceEqual(expectedNestedEnums));
|
||||||
|
|
||||||
|
var nestedLongSpan = nestedStruct.GetDBytes();
|
||||||
|
var expectedNestedLongs = new long[] { nestedLongs[i, 0], nestedLongs[i, 1] };
|
||||||
|
Assert.IsTrue(nestedLongSpan.SequenceEqual(expectedNestedLongs));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !ENABLE_SPAN_T
|
||||||
|
[FlatBuffersTestMethod]
|
||||||
|
public void FixedLengthArray_GetBytesArraySegmentEquality_ReturnTrue()
|
||||||
|
{
|
||||||
|
var builder = new FlatBufferBuilder(1024);
|
||||||
|
|
||||||
|
var floatA = 3.14f;
|
||||||
|
var intArray = Enumerable.Range(1, 15).ToArray();
|
||||||
|
var byteC = (sbyte)42;
|
||||||
|
var intE = 999;
|
||||||
|
var longArray = new long[] { 5000L, 6000L };
|
||||||
|
|
||||||
|
var nestedInts = new int[2, 2] { { 10, 20 }, { 30, 40 } };
|
||||||
|
var nestedEnumB = new TestEnum[] { TestEnum.A, TestEnum.B };
|
||||||
|
var nestedEnums = new TestEnum[2, 2] { { TestEnum.A, TestEnum.B }, { TestEnum.C, TestEnum.A } };
|
||||||
|
var nestedLongs = new long[2, 2] { { 100L, 200L }, { 300L, 400L } };
|
||||||
|
|
||||||
|
var structOffset = ArrayStruct.CreateArrayStruct(builder, floatA, intArray, byteC,
|
||||||
|
nestedInts, nestedEnumB, nestedEnums, nestedLongs, intE, longArray);
|
||||||
|
|
||||||
|
ArrayTable.StartArrayTable(builder);
|
||||||
|
ArrayTable.AddA(builder, structOffset);
|
||||||
|
var rootTable = ArrayTable.EndArrayTable(builder);
|
||||||
|
builder.Finish(rootTable.Value);
|
||||||
|
|
||||||
|
var finishedBytes = builder.SizedByteArray();
|
||||||
|
ByteBuffer bb = new ByteBuffer(finishedBytes);
|
||||||
|
ArrayTable arrayTable = ArrayTable.GetRootAsArrayTable(bb);
|
||||||
|
ArrayStruct arrayStruct = arrayTable.A.Value;
|
||||||
|
|
||||||
|
// Test that we can read basic scalars correctly
|
||||||
|
Assert.AreEqual(byteC, arrayStruct.C);
|
||||||
|
Assert.AreEqual(intE, arrayStruct.E);
|
||||||
|
|
||||||
|
Assert.IsTrue(arrayStruct.GetBBytes().HasValue);
|
||||||
|
var intSegment = arrayStruct.GetBBytes().Value;
|
||||||
|
for (int i = 0, offset = 0; i < intArray.Length; i++, offset += sizeof(int))
|
||||||
|
{
|
||||||
|
var segmentValue = BitConverter.ToInt32(intSegment.Array,
|
||||||
|
intSegment.Offset + offset);
|
||||||
|
Assert.AreEqual(intArray[i], segmentValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.IsTrue(arrayStruct.GetFBytes().HasValue);
|
||||||
|
var longSegment = arrayStruct.GetFBytes().Value;
|
||||||
|
for (int i = 0, offset = 0; i < longArray.Length; i++, offset += sizeof(long))
|
||||||
|
{
|
||||||
|
var segmentValue = BitConverter.ToInt64(longSegment.Array,
|
||||||
|
longSegment.Offset + offset);
|
||||||
|
Assert.AreEqual(longArray[i], segmentValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test nested struct arrays
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
var nestedStruct = arrayStruct.D(i);
|
||||||
|
|
||||||
|
Assert.IsTrue(nestedStruct.GetABytes().HasValue);
|
||||||
|
var nestedIntSegment = nestedStruct.GetABytes().Value;
|
||||||
|
var expectedNestedInts = new int[] { nestedInts[i, 0], nestedInts[i, 1] };
|
||||||
|
for (int ii = 0, offset = 0; ii < NestedStruct.ALength; ii++, offset += sizeof(int))
|
||||||
|
{
|
||||||
|
var segmentValue = BitConverter.ToInt32(nestedIntSegment.Array,
|
||||||
|
nestedIntSegment.Offset + offset);
|
||||||
|
Assert.AreEqual(expectedNestedInts[ii], segmentValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.AreEqual(nestedEnumB[i], nestedStruct.B);
|
||||||
|
|
||||||
|
Assert.IsTrue(nestedStruct.GetCBytes().HasValue);
|
||||||
|
var nestedEnumSegment = nestedStruct.GetCBytes().Value;
|
||||||
|
var expectedNestedEnums = new TestEnum[] { nestedEnums[i, 0], nestedEnums[i, 1] };
|
||||||
|
for (int ii = 0, offset = 0; ii < NestedStruct.CLength; ii++, offset += sizeof(sbyte))
|
||||||
|
{
|
||||||
|
var segmentValue = (TestEnum)nestedEnumSegment.Array[nestedEnumSegment.Offset + offset];
|
||||||
|
Assert.AreEqual(expectedNestedEnums[ii], segmentValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.IsTrue(nestedStruct.GetDBytes().HasValue);
|
||||||
|
var nestedLongSegment = nestedStruct.GetDBytes().Value;
|
||||||
|
var expectedNestedLongs = new long[] { nestedLongs[i, 0], nestedLongs[i, 1] };
|
||||||
|
for (int ii = 0, offset = 0; ii < NestedStruct.DLength; ii++, offset += sizeof(long))
|
||||||
|
{
|
||||||
|
var segmentValue = BitConverter.ToInt64(nestedLongSegment.Array,
|
||||||
|
nestedLongSegment.Offset + offset);
|
||||||
|
Assert.AreEqual(expectedNestedLongs[ii], segmentValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,6 +19,12 @@ public struct ArrayStruct : IFlatbufferObject
|
|||||||
public float A { get { return __p.bb.GetFloat(__p.bb_pos + 0); } }
|
public 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 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 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 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 sbyte C { get { return __p.bb.GetSbyte(__p.bb_pos + 64); } }
|
||||||
public void MutateC(sbyte c) { __p.bb.PutSbyte(__p.bb_pos + 64, c); }
|
public void MutateC(sbyte c) { __p.bb.PutSbyte(__p.bb_pos + 64, c); }
|
||||||
@@ -26,6 +32,12 @@ public struct ArrayStruct : IFlatbufferObject
|
|||||||
public int E { get { return __p.bb.GetInt(__p.bb_pos + 136); } }
|
public 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 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 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 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) {
|
public static Offset<MyGame.Example.ArrayStruct> CreateArrayStruct(FlatBufferBuilder builder, float A, int[] B, sbyte C, int[,] d_A, MyGame.Example.TestEnum[] d_B, MyGame.Example.TestEnum[,] d_C, long[,] d_D, int E, long[] F) {
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ function Monster.New()
|
|||||||
return o
|
return o
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local FileIdentifier = "MONS"
|
||||||
|
|
||||||
function Monster.GetRootAsMonster(buf, offset)
|
function Monster.GetRootAsMonster(buf, offset)
|
||||||
if type(buf) == "string" then
|
if type(buf) == "string" then
|
||||||
buf = flatbuffers.binaryArray.New(buf)
|
buf = flatbuffers.binaryArray.New(buf)
|
||||||
@@ -1099,4 +1101,12 @@ function Monster.End(builder)
|
|||||||
return builder:EndObject()
|
return builder:EndObject()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Monster.FinishMonsterBuffer(builder, offset)
|
||||||
|
builder:FinishWithIdentifier(offset, FileIdentifier)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Monster.FinishSizePrefixedMonsterBuffer(builder, offset)
|
||||||
|
builder:FinishSizePrefixedWithIdentifier(offset, FileIdentifier)
|
||||||
|
end
|
||||||
|
|
||||||
return Monster
|
return Monster
|
||||||
@@ -914,6 +914,16 @@ def MonsterStartInventoryVector(builder, numElems):
|
|||||||
def StartInventoryVector(builder, numElems):
|
def StartInventoryVector(builder, numElems):
|
||||||
return MonsterStartInventoryVector(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):
|
def MonsterAddColor(builder, color):
|
||||||
builder.PrependUint8Slot(6, color, 8)
|
builder.PrependUint8Slot(6, color, 8)
|
||||||
|
|
||||||
@@ -944,6 +954,16 @@ def MonsterStartTest4Vector(builder, numElems):
|
|||||||
def StartTest4Vector(builder, numElems):
|
def StartTest4Vector(builder, numElems):
|
||||||
return MonsterStartTest4Vector(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):
|
def MonsterAddTestarrayofstring(builder, testarrayofstring):
|
||||||
builder.PrependUOffsetTRelativeSlot(10, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayofstring), 0)
|
builder.PrependUOffsetTRelativeSlot(10, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayofstring), 0)
|
||||||
|
|
||||||
@@ -956,6 +976,12 @@ def MonsterStartTestarrayofstringVector(builder, numElems):
|
|||||||
def StartTestarrayofstringVector(builder, numElems):
|
def StartTestarrayofstringVector(builder, numElems):
|
||||||
return MonsterStartTestarrayofstringVector(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):
|
def MonsterAddTestarrayoftables(builder, testarrayoftables):
|
||||||
builder.PrependUOffsetTRelativeSlot(11, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayoftables), 0)
|
builder.PrependUOffsetTRelativeSlot(11, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayoftables), 0)
|
||||||
|
|
||||||
@@ -968,6 +994,12 @@ def MonsterStartTestarrayoftablesVector(builder, numElems):
|
|||||||
def StartTestarrayoftablesVector(builder, numElems):
|
def StartTestarrayoftablesVector(builder, numElems):
|
||||||
return MonsterStartTestarrayoftablesVector(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):
|
def MonsterAddEnemy(builder, enemy):
|
||||||
builder.PrependUOffsetTRelativeSlot(12, flatbuffers.number_types.UOffsetTFlags.py_type(enemy), 0)
|
builder.PrependUOffsetTRelativeSlot(12, flatbuffers.number_types.UOffsetTFlags.py_type(enemy), 0)
|
||||||
|
|
||||||
@@ -986,6 +1018,16 @@ def MonsterStartTestnestedflatbufferVector(builder, numElems):
|
|||||||
def StartTestnestedflatbufferVector(builder, numElems):
|
def StartTestnestedflatbufferVector(builder, numElems):
|
||||||
return MonsterStartTestnestedflatbufferVector(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):
|
def MonsterMakeTestnestedflatbufferVectorFromBytes(builder, bytes):
|
||||||
builder.StartVector(1, len(bytes), 1)
|
builder.StartVector(1, len(bytes), 1)
|
||||||
builder.head = builder.head - len(bytes)
|
builder.head = builder.head - len(bytes)
|
||||||
@@ -1065,6 +1107,16 @@ def MonsterStartTestarrayofboolsVector(builder, numElems):
|
|||||||
def StartTestarrayofboolsVector(builder, numElems):
|
def StartTestarrayofboolsVector(builder, numElems):
|
||||||
return MonsterStartTestarrayofboolsVector(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):
|
def MonsterAddTestf(builder, testf):
|
||||||
builder.PrependFloat32Slot(25, testf, 3.14159)
|
builder.PrependFloat32Slot(25, testf, 3.14159)
|
||||||
|
|
||||||
@@ -1095,6 +1147,12 @@ def MonsterStartTestarrayofstring2Vector(builder, numElems):
|
|||||||
def StartTestarrayofstring2Vector(builder, numElems):
|
def StartTestarrayofstring2Vector(builder, numElems):
|
||||||
return MonsterStartTestarrayofstring2Vector(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):
|
def MonsterAddTestarrayofsortedstruct(builder, testarrayofsortedstruct):
|
||||||
builder.PrependUOffsetTRelativeSlot(29, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayofsortedstruct), 0)
|
builder.PrependUOffsetTRelativeSlot(29, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayofsortedstruct), 0)
|
||||||
|
|
||||||
@@ -1107,6 +1165,16 @@ def MonsterStartTestarrayofsortedstructVector(builder, numElems):
|
|||||||
def StartTestarrayofsortedstructVector(builder, numElems):
|
def StartTestarrayofsortedstructVector(builder, numElems):
|
||||||
return MonsterStartTestarrayofsortedstructVector(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):
|
def MonsterAddFlex(builder, flex):
|
||||||
builder.PrependUOffsetTRelativeSlot(30, flatbuffers.number_types.UOffsetTFlags.py_type(flex), 0)
|
builder.PrependUOffsetTRelativeSlot(30, flatbuffers.number_types.UOffsetTFlags.py_type(flex), 0)
|
||||||
|
|
||||||
@@ -1119,6 +1187,16 @@ def MonsterStartFlexVector(builder, numElems):
|
|||||||
def StartFlexVector(builder, numElems):
|
def StartFlexVector(builder, numElems):
|
||||||
return MonsterStartFlexVector(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):
|
def MonsterAddTest5(builder, test5):
|
||||||
builder.PrependUOffsetTRelativeSlot(31, flatbuffers.number_types.UOffsetTFlags.py_type(test5), 0)
|
builder.PrependUOffsetTRelativeSlot(31, flatbuffers.number_types.UOffsetTFlags.py_type(test5), 0)
|
||||||
|
|
||||||
@@ -1131,6 +1209,16 @@ def MonsterStartTest5Vector(builder, numElems):
|
|||||||
def StartTest5Vector(builder, numElems):
|
def StartTest5Vector(builder, numElems):
|
||||||
return MonsterStartTest5Vector(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):
|
def MonsterAddVectorOfLongs(builder, vectorOfLongs):
|
||||||
builder.PrependUOffsetTRelativeSlot(32, flatbuffers.number_types.UOffsetTFlags.py_type(vectorOfLongs), 0)
|
builder.PrependUOffsetTRelativeSlot(32, flatbuffers.number_types.UOffsetTFlags.py_type(vectorOfLongs), 0)
|
||||||
|
|
||||||
@@ -1143,6 +1231,16 @@ def MonsterStartVectorOfLongsVector(builder, numElems):
|
|||||||
def StartVectorOfLongsVector(builder, numElems):
|
def StartVectorOfLongsVector(builder, numElems):
|
||||||
return MonsterStartVectorOfLongsVector(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):
|
def MonsterAddVectorOfDoubles(builder, vectorOfDoubles):
|
||||||
builder.PrependUOffsetTRelativeSlot(33, flatbuffers.number_types.UOffsetTFlags.py_type(vectorOfDoubles), 0)
|
builder.PrependUOffsetTRelativeSlot(33, flatbuffers.number_types.UOffsetTFlags.py_type(vectorOfDoubles), 0)
|
||||||
|
|
||||||
@@ -1155,6 +1253,16 @@ def MonsterStartVectorOfDoublesVector(builder, numElems):
|
|||||||
def StartVectorOfDoublesVector(builder, numElems):
|
def StartVectorOfDoublesVector(builder, numElems):
|
||||||
return MonsterStartVectorOfDoublesVector(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):
|
def MonsterAddParentNamespaceTest(builder, parentNamespaceTest):
|
||||||
builder.PrependUOffsetTRelativeSlot(34, flatbuffers.number_types.UOffsetTFlags.py_type(parentNamespaceTest), 0)
|
builder.PrependUOffsetTRelativeSlot(34, flatbuffers.number_types.UOffsetTFlags.py_type(parentNamespaceTest), 0)
|
||||||
|
|
||||||
@@ -1173,6 +1281,12 @@ def MonsterStartVectorOfReferrablesVector(builder, numElems):
|
|||||||
def StartVectorOfReferrablesVector(builder, numElems):
|
def StartVectorOfReferrablesVector(builder, numElems):
|
||||||
return MonsterStartVectorOfReferrablesVector(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):
|
def MonsterAddSingleWeakReference(builder, singleWeakReference):
|
||||||
builder.PrependUint64Slot(36, singleWeakReference, 0)
|
builder.PrependUint64Slot(36, singleWeakReference, 0)
|
||||||
|
|
||||||
@@ -1191,6 +1305,16 @@ def MonsterStartVectorOfWeakReferencesVector(builder, numElems):
|
|||||||
def StartVectorOfWeakReferencesVector(builder, numElems):
|
def StartVectorOfWeakReferencesVector(builder, numElems):
|
||||||
return MonsterStartVectorOfWeakReferencesVector(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):
|
def MonsterAddVectorOfStrongReferrables(builder, vectorOfStrongReferrables):
|
||||||
builder.PrependUOffsetTRelativeSlot(38, flatbuffers.number_types.UOffsetTFlags.py_type(vectorOfStrongReferrables), 0)
|
builder.PrependUOffsetTRelativeSlot(38, flatbuffers.number_types.UOffsetTFlags.py_type(vectorOfStrongReferrables), 0)
|
||||||
|
|
||||||
@@ -1203,6 +1327,12 @@ def MonsterStartVectorOfStrongReferrablesVector(builder, numElems):
|
|||||||
def StartVectorOfStrongReferrablesVector(builder, numElems):
|
def StartVectorOfStrongReferrablesVector(builder, numElems):
|
||||||
return MonsterStartVectorOfStrongReferrablesVector(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):
|
def MonsterAddCoOwningReference(builder, coOwningReference):
|
||||||
builder.PrependUint64Slot(39, coOwningReference, 0)
|
builder.PrependUint64Slot(39, coOwningReference, 0)
|
||||||
|
|
||||||
@@ -1221,6 +1351,16 @@ def MonsterStartVectorOfCoOwningReferencesVector(builder, numElems):
|
|||||||
def StartVectorOfCoOwningReferencesVector(builder, numElems):
|
def StartVectorOfCoOwningReferencesVector(builder, numElems):
|
||||||
return MonsterStartVectorOfCoOwningReferencesVector(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):
|
def MonsterAddNonOwningReference(builder, nonOwningReference):
|
||||||
builder.PrependUint64Slot(41, nonOwningReference, 0)
|
builder.PrependUint64Slot(41, nonOwningReference, 0)
|
||||||
|
|
||||||
@@ -1239,6 +1379,16 @@ def MonsterStartVectorOfNonOwningReferencesVector(builder, numElems):
|
|||||||
def StartVectorOfNonOwningReferencesVector(builder, numElems):
|
def StartVectorOfNonOwningReferencesVector(builder, numElems):
|
||||||
return MonsterStartVectorOfNonOwningReferencesVector(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):
|
def MonsterAddAnyUniqueType(builder, anyUniqueType):
|
||||||
builder.PrependUint8Slot(43, anyUniqueType, 0)
|
builder.PrependUint8Slot(43, anyUniqueType, 0)
|
||||||
|
|
||||||
@@ -1275,6 +1425,16 @@ def MonsterStartVectorOfEnumsVector(builder, numElems):
|
|||||||
def StartVectorOfEnumsVector(builder, numElems):
|
def StartVectorOfEnumsVector(builder, numElems):
|
||||||
return MonsterStartVectorOfEnumsVector(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):
|
def MonsterAddSignedEnum(builder, signedEnum):
|
||||||
builder.PrependInt8Slot(48, signedEnum, -1)
|
builder.PrependInt8Slot(48, signedEnum, -1)
|
||||||
|
|
||||||
@@ -1293,6 +1453,16 @@ def MonsterStartTestrequirednestedflatbufferVector(builder, numElems):
|
|||||||
def StartTestrequirednestedflatbufferVector(builder, numElems):
|
def StartTestrequirednestedflatbufferVector(builder, numElems):
|
||||||
return MonsterStartTestrequirednestedflatbufferVector(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):
|
def MonsterMakeTestrequirednestedflatbufferVectorFromBytes(builder, bytes):
|
||||||
builder.StartVector(1, len(bytes), 1)
|
builder.StartVector(1, len(bytes), 1)
|
||||||
builder.head = builder.head - len(bytes)
|
builder.head = builder.head - len(bytes)
|
||||||
@@ -1312,6 +1482,12 @@ def MonsterStartScalarKeySortedTablesVector(builder, numElems):
|
|||||||
def StartScalarKeySortedTablesVector(builder, numElems):
|
def StartScalarKeySortedTablesVector(builder, numElems):
|
||||||
return MonsterStartScalarKeySortedTablesVector(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):
|
def MonsterAddNativeInline(builder, nativeInline):
|
||||||
builder.PrependStructSlot(51, flatbuffers.number_types.UOffsetTFlags.py_type(nativeInline), 0)
|
builder.PrependStructSlot(51, flatbuffers.number_types.UOffsetTFlags.py_type(nativeInline), 0)
|
||||||
|
|
||||||
|
|||||||
@@ -17,12 +17,30 @@ public struct NestedStruct : IFlatbufferObject
|
|||||||
public NestedStruct __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
public 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 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 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 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 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 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 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 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 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) {
|
public static Offset<MyGame.Example.NestedStruct> CreateNestedStruct(FlatBufferBuilder builder, int[] A, MyGame.Example.TestEnum B, MyGame.Example.TestEnum[] C, long[] D) {
|
||||||
|
|||||||
@@ -230,6 +230,16 @@ def TypeAliasesStartV8Vector(builder, numElems):
|
|||||||
def StartV8Vector(builder, numElems):
|
def StartV8Vector(builder, numElems):
|
||||||
return TypeAliasesStartV8Vector(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):
|
def TypeAliasesAddVf64(builder, vf64):
|
||||||
builder.PrependUOffsetTRelativeSlot(11, flatbuffers.number_types.UOffsetTFlags.py_type(vf64), 0)
|
builder.PrependUOffsetTRelativeSlot(11, flatbuffers.number_types.UOffsetTFlags.py_type(vf64), 0)
|
||||||
|
|
||||||
@@ -242,6 +252,16 @@ def TypeAliasesStartVf64Vector(builder, numElems):
|
|||||||
def StartVf64Vector(builder, numElems):
|
def StartVf64Vector(builder, numElems):
|
||||||
return TypeAliasesStartVf64Vector(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):
|
def TypeAliasesEnd(builder):
|
||||||
return builder.EndObject()
|
return builder.EndObject()
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
import flatbuffers
|
import flatbuffers
|
||||||
from flatbuffers.compat import import_numpy
|
from flatbuffers.compat import import_numpy
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
from typing import Iterable
|
||||||
np = import_numpy()
|
np = import_numpy()
|
||||||
|
|
||||||
class MonsterExtra(object):
|
class MonsterExtra(object):
|
||||||
@@ -205,6 +206,16 @@ def MonsterExtraStartDvecVector(builder, numElems: int) -> int:
|
|||||||
def StartDvecVector(builder, numElems: int) -> int:
|
def StartDvecVector(builder, numElems: int) -> int:
|
||||||
return MonsterExtraStartDvecVector(builder, numElems)
|
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):
|
def MonsterExtraAddFvec(builder: flatbuffers.Builder, fvec: int):
|
||||||
builder.PrependUOffsetTRelativeSlot(9, flatbuffers.number_types.UOffsetTFlags.py_type(fvec), 0)
|
builder.PrependUOffsetTRelativeSlot(9, flatbuffers.number_types.UOffsetTFlags.py_type(fvec), 0)
|
||||||
|
|
||||||
@@ -217,6 +228,16 @@ def MonsterExtraStartFvecVector(builder, numElems: int) -> int:
|
|||||||
def StartFvecVector(builder, numElems: int) -> int:
|
def StartFvecVector(builder, numElems: int) -> int:
|
||||||
return MonsterExtraStartFvecVector(builder, numElems)
|
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:
|
def MonsterExtraEnd(builder: flatbuffers.Builder) -> int:
|
||||||
return builder.EndObject()
|
return builder.EndObject()
|
||||||
|
|
||||||
|
|||||||
@@ -77,9 +77,13 @@ def MonsterExtraAddF3(builder: flatbuffers.Builder, f3: float) -> None: ...
|
|||||||
def MonsterExtraAddDvec(builder: flatbuffers.Builder, dvec: uoffset) -> None: ...
|
def MonsterExtraAddDvec(builder: flatbuffers.Builder, dvec: uoffset) -> None: ...
|
||||||
def MonsterExtraStartDvecVector(builder: flatbuffers.Builder, num_elems: int) -> uoffset: ...
|
def MonsterExtraStartDvecVector(builder: flatbuffers.Builder, num_elems: int) -> uoffset: ...
|
||||||
def StartDvecVector(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 MonsterExtraAddFvec(builder: flatbuffers.Builder, fvec: uoffset) -> None: ...
|
||||||
def MonsterExtraStartFvecVector(builder: flatbuffers.Builder, num_elems: int) -> uoffset: ...
|
def MonsterExtraStartFvecVector(builder: flatbuffers.Builder, num_elems: int) -> uoffset: ...
|
||||||
def StartFvecVector(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 MonsterExtraEnd(builder: flatbuffers.Builder) -> uoffset: ...
|
||||||
def End(builder: flatbuffers.Builder) -> uoffset: ...
|
def End(builder: flatbuffers.Builder) -> uoffset: ...
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
native_include "bigfoot_ref_test_impl.h";
|
||||||
|
|
||||||
|
namespace BigfootRefTestNS;
|
||||||
|
|
||||||
|
// Stands in for Bigfoot's real UUID - a `native_type` struct so RefId has a
|
||||||
|
// distinct native/flat representation, matching the shape `bigfoot_ref`
|
||||||
|
// requires of a wrapper's payload field.
|
||||||
|
struct RefId (native_type: "Native::RefId") {
|
||||||
|
value: uint64;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The reference-wrapper template itself. `bigfoot_ref_wrapper` marks Ref as
|
||||||
|
// instantiable per referenced type via `bigfoot_ref` below.
|
||||||
|
struct Ref (bigfoot_ref_wrapper: "Native::Ref") {
|
||||||
|
uuid: RefId;
|
||||||
|
}
|
||||||
|
|
||||||
|
// RefHolder references two distinct C++ types (Thing, OtherThing) that are
|
||||||
|
// *never defined anywhere in this test* - only ever forward-declared, by
|
||||||
|
// flatc itself, directly into the generated header. This is the property
|
||||||
|
// `bigfoot_ref` exists to provide: a reference field never requires the
|
||||||
|
// referenced type to be complete. It also references `Thing` twice (once as
|
||||||
|
// a plain field, once in a vector), exercising the include-guard dedup for
|
||||||
|
// two fields that resolve to the identical Pack/UnPack pair.
|
||||||
|
table RefHolder {
|
||||||
|
ref_a: Ref (native_inline, bigfoot_ref: "Native::Thing");
|
||||||
|
ref_a_again: [Ref] (native_inline, bigfoot_ref: "Native::Thing");
|
||||||
|
ref_b: Ref (native_inline, bigfoot_ref: "Native::OtherThing");
|
||||||
|
}
|
||||||
|
|
||||||
|
root_type RefHolder;
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
#include "bigfoot_ref_test_impl.h"
|
||||||
|
|
||||||
|
#include "bigfoot_ref_test_generated.h"
|
||||||
|
#include "test_assert.h"
|
||||||
|
|
||||||
|
namespace flatbuffers {
|
||||||
|
BigfootRefTestNS::RefId Pack(const Native::RefId& obj) {
|
||||||
|
return BigfootRefTestNS::RefId(obj.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Native::RefId UnPack(const BigfootRefTestNS::RefId& obj) {
|
||||||
|
return Native::RefId(obj.value());
|
||||||
|
}
|
||||||
|
} // namespace flatbuffers
|
||||||
|
|
||||||
|
namespace flatbuffers {
|
||||||
|
namespace tests {
|
||||||
|
|
||||||
|
// Exercises the --bigfoot_ref/--bigfoot_ref_wrapper flatc attributes (see
|
||||||
|
// tests/bigfoot_ref_test.fbs): a reference field never requires the
|
||||||
|
// referenced native type to be complete, and the generated header supplies
|
||||||
|
// its own forward declaration plus inline Pack/UnPack definitions, with no
|
||||||
|
// hand-written boilerplate anywhere in this file for `Thing`/`OtherThing`.
|
||||||
|
void BigfootRefTest() {
|
||||||
|
using BigfootRefTestNS::RefHolder;
|
||||||
|
using BigfootRefTestNS::RefHolderT;
|
||||||
|
|
||||||
|
RefHolderT src;
|
||||||
|
src.ref_a = Native::Ref<Native::Thing>(Native::RefId(1));
|
||||||
|
src.ref_a_again.push_back(Native::Ref<Native::Thing>(Native::RefId(2)));
|
||||||
|
src.ref_a_again.push_back(Native::Ref<Native::Thing>(Native::RefId(3)));
|
||||||
|
src.ref_b = Native::Ref<Native::OtherThing>(Native::RefId(4));
|
||||||
|
|
||||||
|
flatbuffers::FlatBufferBuilder fbb;
|
||||||
|
fbb.Finish(RefHolder::Pack(fbb, &src));
|
||||||
|
|
||||||
|
auto dst = BigfootRefTestNS::UnPackRefHolder(fbb.GetBufferPointer());
|
||||||
|
|
||||||
|
TEST_EQ(dst->ref_a.uuid.value, 1u);
|
||||||
|
TEST_EQ(dst->ref_a_again.size(), 2u);
|
||||||
|
TEST_EQ(dst->ref_a_again[0].uuid.value, 2u);
|
||||||
|
TEST_EQ(dst->ref_a_again[1].uuid.value, 3u);
|
||||||
|
TEST_EQ(dst->ref_b.uuid.value, 4u);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace tests
|
||||||
|
} // namespace flatbuffers
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
#ifndef BIGFOOT_REF_TEST_IMPL_H
|
||||||
|
#define BIGFOOT_REF_TEST_IMPL_H
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace Native {
|
||||||
|
// Stands in for Bigfoot's real UUID.
|
||||||
|
struct RefId {
|
||||||
|
uint64_t value;
|
||||||
|
|
||||||
|
RefId() : value(0) {}
|
||||||
|
explicit RefId(uint64_t _value) : value(_value) {}
|
||||||
|
|
||||||
|
bool operator==(const RefId& other) const { return value == other.value; }
|
||||||
|
};
|
||||||
|
|
||||||
|
// `Thing`/`OtherThing` are intentionally *never* defined anywhere in this
|
||||||
|
// test (see bigfoot_ref_test.fbs) - Ref<T> must compile and round-trip
|
||||||
|
// without T ever being a complete type, exactly like Bigfoot's
|
||||||
|
// HardReference<T>/SoftReference<T>. Their forward declarations are emitted
|
||||||
|
// automatically by flatc (GenerateBigfootRefForwardDecls in
|
||||||
|
// idl_gen_cpp.cpp) directly into bigfoot_ref_test_generated.h - no manual
|
||||||
|
// forward declaration belongs here.
|
||||||
|
|
||||||
|
// The reference-wrapper template `bigfoot_ref_wrapper`/`bigfoot_ref` (see
|
||||||
|
// idl_parser.cpp/idl_gen_cpp.cpp) instantiate per referenced type. Only
|
||||||
|
// needs a `GetUUID()` accessor and a constructor from RefId - never needs T
|
||||||
|
// complete.
|
||||||
|
template <typename T>
|
||||||
|
struct Ref {
|
||||||
|
RefId uuid;
|
||||||
|
|
||||||
|
Ref() : uuid() {}
|
||||||
|
Ref(const RefId& _uuid) : uuid(_uuid) {}
|
||||||
|
|
||||||
|
const RefId& GetUUID() const { return uuid; }
|
||||||
|
|
||||||
|
bool operator==(const Ref& other) const { return uuid == other.uuid; }
|
||||||
|
};
|
||||||
|
} // namespace Native
|
||||||
|
|
||||||
|
namespace BigfootRefTestNS {
|
||||||
|
struct RefId;
|
||||||
|
} // namespace BigfootRefTestNS
|
||||||
|
|
||||||
|
namespace flatbuffers {
|
||||||
|
BigfootRefTestNS::RefId Pack(const Native::RefId& obj);
|
||||||
|
const Native::RefId UnPack(const BigfootRefTestNS::RefId& obj);
|
||||||
|
|
||||||
|
namespace tests {
|
||||||
|
void BigfootRefTest();
|
||||||
|
} // namespace tests
|
||||||
|
} // namespace flatbuffers
|
||||||
|
|
||||||
|
#endif // BIGFOOT_REF_TEST_IMPL_H
|
||||||
@@ -1481,6 +1481,16 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const MyGame::Example2::Monster *test_as_MyGame_Example2_Monster() const {
|
const MyGame::Example2::Monster *test_as_MyGame_Example2_Monster() const {
|
||||||
return test_type() == MyGame::Example::Any::MyGame_Example2_Monster ? static_cast<const MyGame::Example2::Monster *>(test()) : nullptr;
|
return test_type() == MyGame::Example::Any::MyGame_Example2_Monster ? static_cast<const MyGame::Example2::Monster *>(test()) : nullptr;
|
||||||
}
|
}
|
||||||
|
template<typename T> T *mutable_test_as();
|
||||||
|
MyGame::Example::Monster *mutable_test_as_Monster() {
|
||||||
|
return test_type() == MyGame::Example::Any::Monster ? static_cast<MyGame::Example::Monster *>(mutable_test()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example::TestSimpleTableWithEnum *mutable_test_as_TestSimpleTableWithEnum() {
|
||||||
|
return test_type() == MyGame::Example::Any::TestSimpleTableWithEnum ? static_cast<MyGame::Example::TestSimpleTableWithEnum *>(mutable_test()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example2::Monster *mutable_test_as_MyGame_Example2_Monster() {
|
||||||
|
return test_type() == MyGame::Example::Any::MyGame_Example2_Monster ? static_cast<MyGame::Example2::Monster *>(mutable_test()) : nullptr;
|
||||||
|
}
|
||||||
void *mutable_test() {
|
void *mutable_test() {
|
||||||
return GetPointer<void *>(VT_TEST);
|
return GetPointer<void *>(VT_TEST);
|
||||||
}
|
}
|
||||||
@@ -1716,6 +1726,16 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const MyGame::Example2::Monster *any_unique_as_M2() const {
|
const MyGame::Example2::Monster *any_unique_as_M2() const {
|
||||||
return any_unique_type() == MyGame::Example::AnyUniqueAliases::M2 ? static_cast<const MyGame::Example2::Monster *>(any_unique()) : nullptr;
|
return any_unique_type() == MyGame::Example::AnyUniqueAliases::M2 ? static_cast<const MyGame::Example2::Monster *>(any_unique()) : nullptr;
|
||||||
}
|
}
|
||||||
|
template<typename T> T *mutable_any_unique_as();
|
||||||
|
MyGame::Example::Monster *mutable_any_unique_as_M() {
|
||||||
|
return any_unique_type() == MyGame::Example::AnyUniqueAliases::M ? static_cast<MyGame::Example::Monster *>(mutable_any_unique()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example::TestSimpleTableWithEnum *mutable_any_unique_as_TS() {
|
||||||
|
return any_unique_type() == MyGame::Example::AnyUniqueAliases::TS ? static_cast<MyGame::Example::TestSimpleTableWithEnum *>(mutable_any_unique()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example2::Monster *mutable_any_unique_as_M2() {
|
||||||
|
return any_unique_type() == MyGame::Example::AnyUniqueAliases::M2 ? static_cast<MyGame::Example2::Monster *>(mutable_any_unique()) : nullptr;
|
||||||
|
}
|
||||||
void *mutable_any_unique() {
|
void *mutable_any_unique() {
|
||||||
return GetPointer<void *>(VT_ANY_UNIQUE);
|
return GetPointer<void *>(VT_ANY_UNIQUE);
|
||||||
}
|
}
|
||||||
@@ -1734,6 +1754,15 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const MyGame::Example::Monster *any_ambiguous_as_M3() const {
|
const MyGame::Example::Monster *any_ambiguous_as_M3() const {
|
||||||
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases::M3 ? static_cast<const MyGame::Example::Monster *>(any_ambiguous()) : nullptr;
|
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases::M3 ? static_cast<const MyGame::Example::Monster *>(any_ambiguous()) : nullptr;
|
||||||
}
|
}
|
||||||
|
MyGame::Example::Monster *mutable_any_ambiguous_as_M1() {
|
||||||
|
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases::M1 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example::Monster *mutable_any_ambiguous_as_M2() {
|
||||||
|
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases::M2 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example::Monster *mutable_any_ambiguous_as_M3() {
|
||||||
|
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases::M3 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
|
||||||
|
}
|
||||||
void *mutable_any_ambiguous() {
|
void *mutable_any_ambiguous() {
|
||||||
return GetPointer<void *>(VT_ANY_AMBIGUOUS);
|
return GetPointer<void *>(VT_ANY_AMBIGUOUS);
|
||||||
}
|
}
|
||||||
@@ -2008,26 +2037,50 @@ template<> inline const MyGame::Example::Monster *Monster::test_as<MyGame::Examp
|
|||||||
return test_as_Monster();
|
return test_as_Monster();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example::Monster *Monster::mutable_test_as<MyGame::Example::Monster>() {
|
||||||
|
return mutable_test_as_Monster();
|
||||||
|
}
|
||||||
|
|
||||||
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::test_as<MyGame::Example::TestSimpleTableWithEnum>() const {
|
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::test_as<MyGame::Example::TestSimpleTableWithEnum>() const {
|
||||||
return test_as_TestSimpleTableWithEnum();
|
return test_as_TestSimpleTableWithEnum();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example::TestSimpleTableWithEnum *Monster::mutable_test_as<MyGame::Example::TestSimpleTableWithEnum>() {
|
||||||
|
return mutable_test_as_TestSimpleTableWithEnum();
|
||||||
|
}
|
||||||
|
|
||||||
template<> inline const MyGame::Example2::Monster *Monster::test_as<MyGame::Example2::Monster>() const {
|
template<> inline const MyGame::Example2::Monster *Monster::test_as<MyGame::Example2::Monster>() const {
|
||||||
return test_as_MyGame_Example2_Monster();
|
return test_as_MyGame_Example2_Monster();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example2::Monster *Monster::mutable_test_as<MyGame::Example2::Monster>() {
|
||||||
|
return mutable_test_as_MyGame_Example2_Monster();
|
||||||
|
}
|
||||||
|
|
||||||
template<> inline const MyGame::Example::Monster *Monster::any_unique_as<MyGame::Example::Monster>() const {
|
template<> inline const MyGame::Example::Monster *Monster::any_unique_as<MyGame::Example::Monster>() const {
|
||||||
return any_unique_as_M();
|
return any_unique_as_M();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example::Monster *Monster::mutable_any_unique_as<MyGame::Example::Monster>() {
|
||||||
|
return mutable_any_unique_as_M();
|
||||||
|
}
|
||||||
|
|
||||||
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() const {
|
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() const {
|
||||||
return any_unique_as_TS();
|
return any_unique_as_TS();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example::TestSimpleTableWithEnum *Monster::mutable_any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() {
|
||||||
|
return mutable_any_unique_as_TS();
|
||||||
|
}
|
||||||
|
|
||||||
template<> inline const MyGame::Example2::Monster *Monster::any_unique_as<MyGame::Example2::Monster>() const {
|
template<> inline const MyGame::Example2::Monster *Monster::any_unique_as<MyGame::Example2::Monster>() const {
|
||||||
return any_unique_as_M2();
|
return any_unique_as_M2();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example2::Monster *Monster::mutable_any_unique_as<MyGame::Example2::Monster>() {
|
||||||
|
return mutable_any_unique_as_M2();
|
||||||
|
}
|
||||||
|
|
||||||
struct MonsterBuilder {
|
struct MonsterBuilder {
|
||||||
typedef Monster Table;
|
typedef Monster Table;
|
||||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||||
|
|||||||
@@ -595,6 +595,24 @@ struct Movie FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const ::flatbuffers::String *main_character_as_Unused() const {
|
const ::flatbuffers::String *main_character_as_Unused() const {
|
||||||
return main_character_type() == Character::Unused ? static_cast<const ::flatbuffers::String *>(main_character()) : nullptr;
|
return main_character_type() == Character::Unused ? static_cast<const ::flatbuffers::String *>(main_character()) : nullptr;
|
||||||
}
|
}
|
||||||
|
Attacker *mutable_main_character_as_MuLan() {
|
||||||
|
return main_character_type() == Character::MuLan ? static_cast<Attacker *>(mutable_main_character()) : nullptr;
|
||||||
|
}
|
||||||
|
Rapunzel *mutable_main_character_as_Rapunzel() {
|
||||||
|
return main_character_type() == Character::Rapunzel ? static_cast<Rapunzel *>(mutable_main_character()) : nullptr;
|
||||||
|
}
|
||||||
|
BookReader *mutable_main_character_as_Belle() {
|
||||||
|
return main_character_type() == Character::Belle ? static_cast<BookReader *>(mutable_main_character()) : nullptr;
|
||||||
|
}
|
||||||
|
BookReader *mutable_main_character_as_BookFan() {
|
||||||
|
return main_character_type() == Character::BookFan ? static_cast<BookReader *>(mutable_main_character()) : nullptr;
|
||||||
|
}
|
||||||
|
::flatbuffers::String *mutable_main_character_as_Other() {
|
||||||
|
return main_character_type() == Character::Other ? static_cast<::flatbuffers::String *>(mutable_main_character()) : nullptr;
|
||||||
|
}
|
||||||
|
::flatbuffers::String *mutable_main_character_as_Unused() {
|
||||||
|
return main_character_type() == Character::Unused ? static_cast<::flatbuffers::String *>(mutable_main_character()) : nullptr;
|
||||||
|
}
|
||||||
void *mutable_main_character() {
|
void *mutable_main_character() {
|
||||||
return GetPointer<void *>(VT_MAIN_CHARACTER);
|
return GetPointer<void *>(VT_MAIN_CHARACTER);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
// 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;
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
#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
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#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
|
||||||
@@ -71,3 +71,12 @@ class SchemaTests:
|
|||||||
schema_json["enums"][0]["values"][2]["attributes"][1]["value"]
|
schema_json["enums"][0]["values"][2]["attributes"][1]["value"]
|
||||||
== "Value 3 (deprecated)"
|
== "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"])
|
||||||
+51
-1
@@ -22,8 +22,8 @@ import (
|
|||||||
pizza "Pizza"
|
pizza "Pizza"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
optional_scalars "optional_scalars" // refers to generated code
|
optional_scalars "optional_scalars" // refers to generated code
|
||||||
required_strings "required_strings" // refers to generated code
|
|
||||||
order "order"
|
order "order"
|
||||||
|
required_strings "required_strings" // refers to generated code
|
||||||
|
|
||||||
"bytes"
|
"bytes"
|
||||||
"flag"
|
"flag"
|
||||||
@@ -132,6 +132,10 @@ func TestAll(t *testing.T) {
|
|||||||
CheckByteStringIsNestedError(t.Fatalf)
|
CheckByteStringIsNestedError(t.Fatalf)
|
||||||
CheckStructIsNotInlineError(t.Fatalf)
|
CheckStructIsNotInlineError(t.Fatalf)
|
||||||
CheckFinishedBytesError(t.Fatalf)
|
CheckFinishedBytesError(t.Fatalf)
|
||||||
|
|
||||||
|
// Verify bounds checking
|
||||||
|
CheckByteVectorBoundsChecking(t.Fatalf)
|
||||||
|
|
||||||
CheckSharedStrings(t.Fatalf)
|
CheckSharedStrings(t.Fatalf)
|
||||||
CheckEmptiedBuilder(t.Fatalf)
|
CheckEmptiedBuilder(t.Fatalf)
|
||||||
|
|
||||||
@@ -2471,6 +2475,52 @@ func CheckByKey(fail func(string, ...interface{})) {
|
|||||||
expectEq("Mana Count", mpStat.Count(), uint16(0))
|
expectEq("Mana Count", mpStat.Count(), uint16(0))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CheckByteVectorBoundsChecking ensures ByteVector handles malformed input safely.
|
||||||
|
func CheckByteVectorBoundsChecking(fail func(string, ...interface{})) {
|
||||||
|
// Test case 1: Offset beyond buffer size
|
||||||
|
table := &flatbuffers.Table{
|
||||||
|
Bytes: []byte{0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}, // Small buffer
|
||||||
|
Pos: 0,
|
||||||
|
}
|
||||||
|
result := table.ByteVector(100) // Offset way beyond buffer
|
||||||
|
if result != nil {
|
||||||
|
fail("ByteVector should return nil for offset beyond buffer")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test case 2: Malicious length field
|
||||||
|
// Construct: [relative offset: 4] [vector length: 0xFFFFFFFF] [data...]
|
||||||
|
maliciousBytes := make([]byte, 20)
|
||||||
|
// At position 0, set relative offset to point to position 4
|
||||||
|
maliciousBytes[0] = 4
|
||||||
|
maliciousBytes[1] = 0
|
||||||
|
maliciousBytes[2] = 0
|
||||||
|
maliciousBytes[3] = 0
|
||||||
|
// At position 4, set malicious vector length
|
||||||
|
maliciousBytes[4] = 0xFF
|
||||||
|
maliciousBytes[5] = 0xFF
|
||||||
|
maliciousBytes[6] = 0xFF
|
||||||
|
maliciousBytes[7] = 0xFF
|
||||||
|
|
||||||
|
table = &flatbuffers.Table{Bytes: maliciousBytes, Pos: 0}
|
||||||
|
result = table.ByteVector(0)
|
||||||
|
if result != nil {
|
||||||
|
fail("ByteVector should return nil for malicious length field")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test case 3: Valid case should still work
|
||||||
|
// Construct: [relative offset: 4] [vector length: 3] [data: 'a', 'b', 'c']
|
||||||
|
validBytes := []byte{
|
||||||
|
4, 0, 0, 0, // relative offset to vector data (at position 4)
|
||||||
|
3, 0, 0, 0, // vector length (3 bytes)
|
||||||
|
'a', 'b', 'c', // actual vector data
|
||||||
|
}
|
||||||
|
table = &flatbuffers.Table{Bytes: validBytes, Pos: 0}
|
||||||
|
result = table.ByteVector(0)
|
||||||
|
if result == nil || !bytes.Equal(result, []byte("abc")) {
|
||||||
|
fail("ByteVector should work correctly for valid data")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// BenchmarkVtableDeduplication measures the speed of vtable deduplication
|
// BenchmarkVtableDeduplication measures the speed of vtable deduplication
|
||||||
// by creating prePop vtables, then populating b.N objects with a
|
// by creating prePop vtables, then populating b.N objects with a
|
||||||
// different single vtable.
|
// different single vtable.
|
||||||
|
|||||||
@@ -0,0 +1,479 @@
|
|||||||
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
// @generated
|
||||||
|
|
||||||
|
extern crate alloc;
|
||||||
|
|
||||||
|
pub enum TableAOffset {}
|
||||||
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
|
|
||||||
|
pub struct TableA<'a> {
|
||||||
|
pub _tab: ::flatbuffers::Table<'a>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> ::flatbuffers::Follow<'a> for TableA<'a> {
|
||||||
|
type Inner = TableA<'a>;
|
||||||
|
#[inline]
|
||||||
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
|
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> TableA<'a> {
|
||||||
|
pub const VT_B: ::flatbuffers::VOffsetT = 4;
|
||||||
|
|
||||||
|
pub const fn get_fully_qualified_name() -> &'static str {
|
||||||
|
"TableA"
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||||
|
TableA { _tab: table }
|
||||||
|
}
|
||||||
|
#[allow(unused_mut)]
|
||||||
|
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||||
|
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||||
|
args: &'args TableAArgs<'args>
|
||||||
|
) -> ::flatbuffers::WIPOffset<TableA<'bldr>> {
|
||||||
|
let mut builder = TableABuilder::new(_fbb);
|
||||||
|
if let Some(x) = args.b { builder.add_b(x); }
|
||||||
|
builder.finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unpack(&self) -> TableAT {
|
||||||
|
let b = self.b().map(|x| {
|
||||||
|
alloc::boxed::Box::new(x.unpack())
|
||||||
|
});
|
||||||
|
TableAT {
|
||||||
|
b,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn b(&self) -> Option<my_game::other_name_space::TableB<'a>> {
|
||||||
|
// Safety:
|
||||||
|
// Created from valid Table for this object
|
||||||
|
// which contains a valid value in this slot
|
||||||
|
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>(TableA::VT_B, None)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::flatbuffers::Verifiable for TableA<'_> {
|
||||||
|
#[inline]
|
||||||
|
fn run_verifier(
|
||||||
|
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||||
|
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||||
|
v.visit_table(pos)?
|
||||||
|
.visit_field::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>("b", Self::VT_B, false)?
|
||||||
|
.finish();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub struct TableAArgs<'a> {
|
||||||
|
pub b: Option<::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'a>>>,
|
||||||
|
}
|
||||||
|
impl<'a> Default for TableAArgs<'a> {
|
||||||
|
#[inline]
|
||||||
|
fn default() -> Self {
|
||||||
|
TableAArgs {
|
||||||
|
b: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct TableABuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
|
||||||
|
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
|
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
||||||
|
}
|
||||||
|
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> {
|
||||||
|
#[inline]
|
||||||
|
pub fn add_b(&mut self, b: ::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'b >>) {
|
||||||
|
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<my_game::other_name_space::TableB>>(TableA::VT_B, b);
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> {
|
||||||
|
let start = _fbb.start_table();
|
||||||
|
TableABuilder {
|
||||||
|
fbb_: _fbb,
|
||||||
|
start_: start,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
|
||||||
|
let o = self.fbb_.end_table(self.start_);
|
||||||
|
::flatbuffers::WIPOffset::new(o.value())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::core::fmt::Debug for TableA<'_> {
|
||||||
|
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
||||||
|
let mut ds = f.debug_struct("TableA");
|
||||||
|
ds.field("b", &self.b());
|
||||||
|
ds.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[non_exhaustive]
|
||||||
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
pub struct TableAT {
|
||||||
|
pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
|
||||||
|
}
|
||||||
|
impl Default for TableAT {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
b: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl TableAT {
|
||||||
|
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
||||||
|
&self,
|
||||||
|
_fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
|
||||||
|
) -> ::flatbuffers::WIPOffset<TableA<'b>> {
|
||||||
|
let b = self.b.as_ref().map(|x|{
|
||||||
|
x.pack(_fbb)
|
||||||
|
});
|
||||||
|
TableA::create(_fbb, &TableAArgs{
|
||||||
|
b,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[allow(unused_imports, dead_code)]
|
||||||
|
pub mod my_game {
|
||||||
|
|
||||||
|
extern crate alloc;
|
||||||
|
#[allow(unused_imports, dead_code)]
|
||||||
|
pub mod other_name_space {
|
||||||
|
|
||||||
|
extern crate alloc;
|
||||||
|
|
||||||
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
|
pub const ENUM_MIN_FROM_INCLUDE: i64 = 0;
|
||||||
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
|
pub const ENUM_MAX_FROM_INCLUDE: i64 = 0;
|
||||||
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
|
||||||
|
FromInclude::IncludeVal,
|
||||||
|
];
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||||
|
#[repr(transparent)]
|
||||||
|
pub struct FromInclude(pub i64);
|
||||||
|
#[allow(non_upper_case_globals)]
|
||||||
|
impl FromInclude {
|
||||||
|
pub const IncludeVal: Self = Self(0);
|
||||||
|
|
||||||
|
pub const ENUM_MIN: i64 = 0;
|
||||||
|
pub const ENUM_MAX: i64 = 0;
|
||||||
|
pub const ENUM_VALUES: &'static [Self] = &[
|
||||||
|
Self::IncludeVal,
|
||||||
|
];
|
||||||
|
/// Returns the variant's name or "" if unknown.
|
||||||
|
pub fn variant_name(self) -> Option<&'static str> {
|
||||||
|
match self {
|
||||||
|
Self::IncludeVal => Some("IncludeVal"),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl ::core::fmt::Debug for FromInclude {
|
||||||
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
|
if let Some(name) = self.variant_name() {
|
||||||
|
f.write_str(name)
|
||||||
|
} else {
|
||||||
|
f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<'a> ::flatbuffers::Follow<'a> for FromInclude {
|
||||||
|
type Inner = Self;
|
||||||
|
#[inline]
|
||||||
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
|
let b = unsafe { ::flatbuffers::read_scalar_at::<i64>(buf, loc) };
|
||||||
|
Self(b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::flatbuffers::Push for FromInclude {
|
||||||
|
type Output = FromInclude;
|
||||||
|
#[inline]
|
||||||
|
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||||
|
unsafe { ::flatbuffers::emplace_scalar::<i64>(dst, self.0) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::flatbuffers::EndianScalar for FromInclude {
|
||||||
|
type Scalar = i64;
|
||||||
|
#[inline]
|
||||||
|
fn to_little_endian(self) -> i64 {
|
||||||
|
self.0.to_le()
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
#[allow(clippy::wrong_self_convention)]
|
||||||
|
fn from_little_endian(v: i64) -> Self {
|
||||||
|
let b = i64::from_le(v);
|
||||||
|
Self(b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> ::flatbuffers::Verifiable for FromInclude {
|
||||||
|
#[inline]
|
||||||
|
fn run_verifier(
|
||||||
|
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||||
|
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||||
|
i64::run_verifier(v, pos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::flatbuffers::SimpleToVerifyInSlice for FromInclude {}
|
||||||
|
// struct Unused, aligned to 4
|
||||||
|
#[repr(transparent)]
|
||||||
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
|
pub struct Unused(pub [u8; 4]);
|
||||||
|
impl Default for Unused {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self([0; 4])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl ::core::fmt::Debug for Unused {
|
||||||
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
|
f.debug_struct("Unused")
|
||||||
|
.field("a", &self.a())
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::flatbuffers::SimpleToVerifyInSlice for Unused {}
|
||||||
|
impl<'a> ::flatbuffers::Follow<'a> for Unused {
|
||||||
|
type Inner = &'a Unused;
|
||||||
|
#[inline]
|
||||||
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
|
unsafe { <&'a Unused>::follow(buf, loc) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<'a> ::flatbuffers::Follow<'a> for &'a Unused {
|
||||||
|
type Inner = &'a Unused;
|
||||||
|
#[inline]
|
||||||
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
|
unsafe { ::flatbuffers::follow_cast_ref::<Unused>(buf, loc) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<'b> ::flatbuffers::Push for Unused {
|
||||||
|
type Output = Unused;
|
||||||
|
#[inline]
|
||||||
|
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||||
|
let src = unsafe { ::core::slice::from_raw_parts(self as *const Unused as *const u8, <Self as ::flatbuffers::Push>::size()) };
|
||||||
|
dst.copy_from_slice(src);
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
fn alignment() -> ::flatbuffers::PushAlignment {
|
||||||
|
::flatbuffers::PushAlignment::new(4)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> ::flatbuffers::Verifiable for Unused {
|
||||||
|
#[inline]
|
||||||
|
fn run_verifier(
|
||||||
|
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||||
|
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||||
|
v.in_buffer::<Self>(pos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Unused {
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
pub fn new(
|
||||||
|
a: i32,
|
||||||
|
) -> Self {
|
||||||
|
let mut s = Self([0; 4]);
|
||||||
|
s.set_a(a);
|
||||||
|
s
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const fn get_fully_qualified_name() -> &'static str {
|
||||||
|
"MyGame.OtherNameSpace.Unused"
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn a(&self) -> i32 {
|
||||||
|
let mut mem = ::core::mem::MaybeUninit::<<i32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid value in this slot
|
||||||
|
::flatbuffers::EndianScalar::from_little_endian(unsafe {
|
||||||
|
::core::ptr::copy_nonoverlapping(
|
||||||
|
self.0[0..].as_ptr(),
|
||||||
|
mem.as_mut_ptr() as *mut u8,
|
||||||
|
::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||||
|
);
|
||||||
|
mem.assume_init()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_a(&mut self, x: i32) {
|
||||||
|
let x_le = ::flatbuffers::EndianScalar::to_little_endian(x);
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid value in this slot
|
||||||
|
unsafe {
|
||||||
|
::core::ptr::copy_nonoverlapping(
|
||||||
|
&x_le as *const _ as *const u8,
|
||||||
|
self.0[0..].as_mut_ptr(),
|
||||||
|
::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unpack(&self) -> UnusedT {
|
||||||
|
UnusedT {
|
||||||
|
a: self.a(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Default)]
|
||||||
|
pub struct UnusedT {
|
||||||
|
pub a: i32,
|
||||||
|
}
|
||||||
|
impl UnusedT {
|
||||||
|
pub fn pack(&self) -> Unused {
|
||||||
|
Unused::new(
|
||||||
|
self.a,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum TableBOffset {}
|
||||||
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
|
|
||||||
|
pub struct TableB<'a> {
|
||||||
|
pub _tab: ::flatbuffers::Table<'a>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> ::flatbuffers::Follow<'a> for TableB<'a> {
|
||||||
|
type Inner = TableB<'a>;
|
||||||
|
#[inline]
|
||||||
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
|
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> TableB<'a> {
|
||||||
|
pub const VT_A: ::flatbuffers::VOffsetT = 4;
|
||||||
|
|
||||||
|
pub const fn get_fully_qualified_name() -> &'static str {
|
||||||
|
"MyGame.OtherNameSpace.TableB"
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||||
|
TableB { _tab: table }
|
||||||
|
}
|
||||||
|
#[allow(unused_mut)]
|
||||||
|
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||||
|
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||||
|
args: &'args TableBArgs<'args>
|
||||||
|
) -> ::flatbuffers::WIPOffset<TableB<'bldr>> {
|
||||||
|
let mut builder = TableBBuilder::new(_fbb);
|
||||||
|
if let Some(x) = args.a { builder.add_a(x); }
|
||||||
|
builder.finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unpack(&self) -> TableBT {
|
||||||
|
let a = self.a().map(|x| {
|
||||||
|
alloc::boxed::Box::new(x.unpack())
|
||||||
|
});
|
||||||
|
TableBT {
|
||||||
|
a,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn a(&self) -> Option<super::super::TableA<'a>> {
|
||||||
|
// Safety:
|
||||||
|
// Created from valid Table for this object
|
||||||
|
// which contains a valid value in this slot
|
||||||
|
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<super::super::TableA>>(TableB::VT_A, None)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::flatbuffers::Verifiable for TableB<'_> {
|
||||||
|
#[inline]
|
||||||
|
fn run_verifier(
|
||||||
|
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||||
|
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||||
|
v.visit_table(pos)?
|
||||||
|
.visit_field::<::flatbuffers::ForwardsUOffset<super::super::TableA>>("a", Self::VT_A, false)?
|
||||||
|
.finish();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub struct TableBArgs<'a> {
|
||||||
|
pub a: Option<::flatbuffers::WIPOffset<super::super::TableA<'a>>>,
|
||||||
|
}
|
||||||
|
impl<'a> Default for TableBArgs<'a> {
|
||||||
|
#[inline]
|
||||||
|
fn default() -> Self {
|
||||||
|
TableBArgs {
|
||||||
|
a: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct TableBBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
|
||||||
|
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
|
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
||||||
|
}
|
||||||
|
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> {
|
||||||
|
#[inline]
|
||||||
|
pub fn add_a(&mut self, a: ::flatbuffers::WIPOffset<super::super::TableA<'b >>) {
|
||||||
|
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::super::TableA>>(TableB::VT_A, a);
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> {
|
||||||
|
let start = _fbb.start_table();
|
||||||
|
TableBBuilder {
|
||||||
|
fbb_: _fbb,
|
||||||
|
start_: start,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
|
||||||
|
let o = self.fbb_.end_table(self.start_);
|
||||||
|
::flatbuffers::WIPOffset::new(o.value())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::core::fmt::Debug for TableB<'_> {
|
||||||
|
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
||||||
|
let mut ds = f.debug_struct("TableB");
|
||||||
|
ds.field("a", &self.a());
|
||||||
|
ds.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[non_exhaustive]
|
||||||
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
pub struct TableBT {
|
||||||
|
pub a: Option<alloc::boxed::Box<super::super::TableAT>>,
|
||||||
|
}
|
||||||
|
impl Default for TableBT {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
a: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl TableBT {
|
||||||
|
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
||||||
|
&self,
|
||||||
|
_fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
|
||||||
|
) -> ::flatbuffers::WIPOffset<TableB<'b>> {
|
||||||
|
let a = self.a.as_ref().map(|x|{
|
||||||
|
x.pack(_fbb)
|
||||||
|
});
|
||||||
|
TableB::create(_fbb, &TableBArgs{
|
||||||
|
a,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // pub mod OtherNameSpace
|
||||||
|
} // pub mod MyGame
|
||||||
|
|
||||||
@@ -0,0 +1,479 @@
|
|||||||
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
// @generated
|
||||||
|
|
||||||
|
extern crate alloc;
|
||||||
|
|
||||||
|
pub enum TableAOffset {}
|
||||||
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
|
|
||||||
|
pub struct TableA<'a> {
|
||||||
|
pub _tab: ::flatbuffers::Table<'a>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> ::flatbuffers::Follow<'a> for TableA<'a> {
|
||||||
|
type Inner = TableA<'a>;
|
||||||
|
#[inline]
|
||||||
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
|
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> TableA<'a> {
|
||||||
|
pub const VT_B: ::flatbuffers::VOffsetT = 4;
|
||||||
|
|
||||||
|
pub const fn get_fully_qualified_name() -> &'static str {
|
||||||
|
"TableA"
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||||
|
TableA { _tab: table }
|
||||||
|
}
|
||||||
|
#[allow(unused_mut)]
|
||||||
|
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||||
|
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||||
|
args: &'args TableAArgs<'args>
|
||||||
|
) -> ::flatbuffers::WIPOffset<TableA<'bldr>> {
|
||||||
|
let mut builder = TableABuilder::new(_fbb);
|
||||||
|
if let Some(x) = args.b { builder.add_b(x); }
|
||||||
|
builder.finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unpack(&self) -> TableAT {
|
||||||
|
let b = self.b().map(|x| {
|
||||||
|
alloc::boxed::Box::new(x.unpack())
|
||||||
|
});
|
||||||
|
TableAT {
|
||||||
|
b,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn b(&self) -> Option<my_game::other_name_space::TableB<'a>> {
|
||||||
|
// Safety:
|
||||||
|
// Created from valid Table for this object
|
||||||
|
// which contains a valid value in this slot
|
||||||
|
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>(TableA::VT_B, None)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::flatbuffers::Verifiable for TableA<'_> {
|
||||||
|
#[inline]
|
||||||
|
fn run_verifier(
|
||||||
|
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||||
|
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||||
|
v.visit_table(pos)?
|
||||||
|
.visit_field::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>("b", Self::VT_B, false)?
|
||||||
|
.finish();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub struct TableAArgs<'a> {
|
||||||
|
pub b: Option<::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'a>>>,
|
||||||
|
}
|
||||||
|
impl<'a> Default for TableAArgs<'a> {
|
||||||
|
#[inline]
|
||||||
|
fn default() -> Self {
|
||||||
|
TableAArgs {
|
||||||
|
b: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct TableABuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
|
||||||
|
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
|
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
||||||
|
}
|
||||||
|
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> {
|
||||||
|
#[inline]
|
||||||
|
pub fn add_b(&mut self, b: ::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'b >>) {
|
||||||
|
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<my_game::other_name_space::TableB>>(TableA::VT_B, b);
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> {
|
||||||
|
let start = _fbb.start_table();
|
||||||
|
TableABuilder {
|
||||||
|
fbb_: _fbb,
|
||||||
|
start_: start,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
|
||||||
|
let o = self.fbb_.end_table(self.start_);
|
||||||
|
::flatbuffers::WIPOffset::new(o.value())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::core::fmt::Debug for TableA<'_> {
|
||||||
|
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
||||||
|
let mut ds = f.debug_struct("TableA");
|
||||||
|
ds.field("b", &self.b());
|
||||||
|
ds.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[non_exhaustive]
|
||||||
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
pub struct TableAT {
|
||||||
|
pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
|
||||||
|
}
|
||||||
|
impl Default for TableAT {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
b: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl TableAT {
|
||||||
|
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
||||||
|
&self,
|
||||||
|
_fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
|
||||||
|
) -> ::flatbuffers::WIPOffset<TableA<'b>> {
|
||||||
|
let b = self.b.as_ref().map(|x|{
|
||||||
|
x.pack(_fbb)
|
||||||
|
});
|
||||||
|
TableA::create(_fbb, &TableAArgs{
|
||||||
|
b,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[allow(unused_imports, dead_code)]
|
||||||
|
pub mod my_game {
|
||||||
|
|
||||||
|
extern crate alloc;
|
||||||
|
#[allow(unused_imports, dead_code)]
|
||||||
|
pub mod other_name_space {
|
||||||
|
|
||||||
|
extern crate alloc;
|
||||||
|
|
||||||
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
|
pub const ENUM_MIN_FROM_INCLUDE: i64 = 0;
|
||||||
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
|
pub const ENUM_MAX_FROM_INCLUDE: i64 = 0;
|
||||||
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
|
||||||
|
FromInclude::IncludeVal,
|
||||||
|
];
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||||
|
#[repr(transparent)]
|
||||||
|
pub struct FromInclude(pub i64);
|
||||||
|
#[allow(non_upper_case_globals)]
|
||||||
|
impl FromInclude {
|
||||||
|
pub const IncludeVal: Self = Self(0);
|
||||||
|
|
||||||
|
pub const ENUM_MIN: i64 = 0;
|
||||||
|
pub const ENUM_MAX: i64 = 0;
|
||||||
|
pub const ENUM_VALUES: &'static [Self] = &[
|
||||||
|
Self::IncludeVal,
|
||||||
|
];
|
||||||
|
/// Returns the variant's name or "" if unknown.
|
||||||
|
pub fn variant_name(self) -> Option<&'static str> {
|
||||||
|
match self {
|
||||||
|
Self::IncludeVal => Some("IncludeVal"),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl ::core::fmt::Debug for FromInclude {
|
||||||
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
|
if let Some(name) = self.variant_name() {
|
||||||
|
f.write_str(name)
|
||||||
|
} else {
|
||||||
|
f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<'a> ::flatbuffers::Follow<'a> for FromInclude {
|
||||||
|
type Inner = Self;
|
||||||
|
#[inline]
|
||||||
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
|
let b = unsafe { ::flatbuffers::read_scalar_at::<i64>(buf, loc) };
|
||||||
|
Self(b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::flatbuffers::Push for FromInclude {
|
||||||
|
type Output = FromInclude;
|
||||||
|
#[inline]
|
||||||
|
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||||
|
unsafe { ::flatbuffers::emplace_scalar::<i64>(dst, self.0) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::flatbuffers::EndianScalar for FromInclude {
|
||||||
|
type Scalar = i64;
|
||||||
|
#[inline]
|
||||||
|
fn to_little_endian(self) -> i64 {
|
||||||
|
self.0.to_le()
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
#[allow(clippy::wrong_self_convention)]
|
||||||
|
fn from_little_endian(v: i64) -> Self {
|
||||||
|
let b = i64::from_le(v);
|
||||||
|
Self(b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> ::flatbuffers::Verifiable for FromInclude {
|
||||||
|
#[inline]
|
||||||
|
fn run_verifier(
|
||||||
|
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||||
|
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||||
|
i64::run_verifier(v, pos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::flatbuffers::SimpleToVerifyInSlice for FromInclude {}
|
||||||
|
// struct Unused, aligned to 4
|
||||||
|
#[repr(transparent)]
|
||||||
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
|
pub struct Unused(pub [u8; 4]);
|
||||||
|
impl Default for Unused {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self([0; 4])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl ::core::fmt::Debug for Unused {
|
||||||
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
|
f.debug_struct("Unused")
|
||||||
|
.field("a", &self.a())
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::flatbuffers::SimpleToVerifyInSlice for Unused {}
|
||||||
|
impl<'a> ::flatbuffers::Follow<'a> for Unused {
|
||||||
|
type Inner = &'a Unused;
|
||||||
|
#[inline]
|
||||||
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
|
unsafe { <&'a Unused>::follow(buf, loc) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<'a> ::flatbuffers::Follow<'a> for &'a Unused {
|
||||||
|
type Inner = &'a Unused;
|
||||||
|
#[inline]
|
||||||
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
|
unsafe { ::flatbuffers::follow_cast_ref::<Unused>(buf, loc) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<'b> ::flatbuffers::Push for Unused {
|
||||||
|
type Output = Unused;
|
||||||
|
#[inline]
|
||||||
|
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||||
|
let src = unsafe { ::core::slice::from_raw_parts(self as *const Unused as *const u8, <Self as ::flatbuffers::Push>::size()) };
|
||||||
|
dst.copy_from_slice(src);
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
fn alignment() -> ::flatbuffers::PushAlignment {
|
||||||
|
::flatbuffers::PushAlignment::new(4)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> ::flatbuffers::Verifiable for Unused {
|
||||||
|
#[inline]
|
||||||
|
fn run_verifier(
|
||||||
|
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||||
|
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||||
|
v.in_buffer::<Self>(pos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Unused {
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
pub fn new(
|
||||||
|
a: i32,
|
||||||
|
) -> Self {
|
||||||
|
let mut s = Self([0; 4]);
|
||||||
|
s.set_a(a);
|
||||||
|
s
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const fn get_fully_qualified_name() -> &'static str {
|
||||||
|
"MyGame.OtherNameSpace.Unused"
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn a(&self) -> i32 {
|
||||||
|
let mut mem = ::core::mem::MaybeUninit::<<i32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid value in this slot
|
||||||
|
::flatbuffers::EndianScalar::from_little_endian(unsafe {
|
||||||
|
::core::ptr::copy_nonoverlapping(
|
||||||
|
self.0[0..].as_ptr(),
|
||||||
|
mem.as_mut_ptr() as *mut u8,
|
||||||
|
::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||||
|
);
|
||||||
|
mem.assume_init()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_a(&mut self, x: i32) {
|
||||||
|
let x_le = ::flatbuffers::EndianScalar::to_little_endian(x);
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid value in this slot
|
||||||
|
unsafe {
|
||||||
|
::core::ptr::copy_nonoverlapping(
|
||||||
|
&x_le as *const _ as *const u8,
|
||||||
|
self.0[0..].as_mut_ptr(),
|
||||||
|
::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unpack(&self) -> UnusedT {
|
||||||
|
UnusedT {
|
||||||
|
a: self.a(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Default)]
|
||||||
|
pub struct UnusedT {
|
||||||
|
pub a: i32,
|
||||||
|
}
|
||||||
|
impl UnusedT {
|
||||||
|
pub fn pack(&self) -> Unused {
|
||||||
|
Unused::new(
|
||||||
|
self.a,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum TableBOffset {}
|
||||||
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
|
|
||||||
|
pub struct TableB<'a> {
|
||||||
|
pub _tab: ::flatbuffers::Table<'a>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> ::flatbuffers::Follow<'a> for TableB<'a> {
|
||||||
|
type Inner = TableB<'a>;
|
||||||
|
#[inline]
|
||||||
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
|
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> TableB<'a> {
|
||||||
|
pub const VT_A: ::flatbuffers::VOffsetT = 4;
|
||||||
|
|
||||||
|
pub const fn get_fully_qualified_name() -> &'static str {
|
||||||
|
"MyGame.OtherNameSpace.TableB"
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||||
|
TableB { _tab: table }
|
||||||
|
}
|
||||||
|
#[allow(unused_mut)]
|
||||||
|
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||||
|
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||||
|
args: &'args TableBArgs<'args>
|
||||||
|
) -> ::flatbuffers::WIPOffset<TableB<'bldr>> {
|
||||||
|
let mut builder = TableBBuilder::new(_fbb);
|
||||||
|
if let Some(x) = args.a { builder.add_a(x); }
|
||||||
|
builder.finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unpack(&self) -> TableBT {
|
||||||
|
let a = self.a().map(|x| {
|
||||||
|
alloc::boxed::Box::new(x.unpack())
|
||||||
|
});
|
||||||
|
TableBT {
|
||||||
|
a,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn a(&self) -> Option<super::super::TableA<'a>> {
|
||||||
|
// Safety:
|
||||||
|
// Created from valid Table for this object
|
||||||
|
// which contains a valid value in this slot
|
||||||
|
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<super::super::TableA>>(TableB::VT_A, None)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::flatbuffers::Verifiable for TableB<'_> {
|
||||||
|
#[inline]
|
||||||
|
fn run_verifier(
|
||||||
|
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||||
|
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||||
|
v.visit_table(pos)?
|
||||||
|
.visit_field::<::flatbuffers::ForwardsUOffset<super::super::TableA>>("a", Self::VT_A, false)?
|
||||||
|
.finish();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub struct TableBArgs<'a> {
|
||||||
|
pub a: Option<::flatbuffers::WIPOffset<super::super::TableA<'a>>>,
|
||||||
|
}
|
||||||
|
impl<'a> Default for TableBArgs<'a> {
|
||||||
|
#[inline]
|
||||||
|
fn default() -> Self {
|
||||||
|
TableBArgs {
|
||||||
|
a: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct TableBBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
|
||||||
|
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
|
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
||||||
|
}
|
||||||
|
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> {
|
||||||
|
#[inline]
|
||||||
|
pub fn add_a(&mut self, a: ::flatbuffers::WIPOffset<super::super::TableA<'b >>) {
|
||||||
|
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::super::TableA>>(TableB::VT_A, a);
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> {
|
||||||
|
let start = _fbb.start_table();
|
||||||
|
TableBBuilder {
|
||||||
|
fbb_: _fbb,
|
||||||
|
start_: start,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
|
||||||
|
let o = self.fbb_.end_table(self.start_);
|
||||||
|
::flatbuffers::WIPOffset::new(o.value())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::core::fmt::Debug for TableB<'_> {
|
||||||
|
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
||||||
|
let mut ds = f.debug_struct("TableB");
|
||||||
|
ds.field("a", &self.a());
|
||||||
|
ds.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[non_exhaustive]
|
||||||
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
pub struct TableBT {
|
||||||
|
pub a: Option<alloc::boxed::Box<super::super::TableAT>>,
|
||||||
|
}
|
||||||
|
impl Default for TableBT {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
a: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl TableBT {
|
||||||
|
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
||||||
|
&self,
|
||||||
|
_fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
|
||||||
|
) -> ::flatbuffers::WIPOffset<TableB<'b>> {
|
||||||
|
let a = self.a.as_ref().map(|x|{
|
||||||
|
x.pack(_fbb)
|
||||||
|
});
|
||||||
|
TableB::create(_fbb, &TableBArgs{
|
||||||
|
a,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // pub mod OtherNameSpace
|
||||||
|
} // pub mod MyGame
|
||||||
|
|
||||||
@@ -1497,6 +1497,16 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const MyGame::Example2::Monster *test_as_MyGame_Example2_Monster() const {
|
const MyGame::Example2::Monster *test_as_MyGame_Example2_Monster() const {
|
||||||
return test_type() == MyGame::Example::Any_MyGame_Example2_Monster ? static_cast<const MyGame::Example2::Monster *>(test()) : nullptr;
|
return test_type() == MyGame::Example::Any_MyGame_Example2_Monster ? static_cast<const MyGame::Example2::Monster *>(test()) : nullptr;
|
||||||
}
|
}
|
||||||
|
template<typename T> T *mutable_test_as();
|
||||||
|
MyGame::Example::Monster *mutable_test_as_Monster() {
|
||||||
|
return test_type() == MyGame::Example::Any_Monster ? static_cast<MyGame::Example::Monster *>(mutable_test()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example::TestSimpleTableWithEnum *mutable_test_as_TestSimpleTableWithEnum() {
|
||||||
|
return test_type() == MyGame::Example::Any_TestSimpleTableWithEnum ? static_cast<MyGame::Example::TestSimpleTableWithEnum *>(mutable_test()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example2::Monster *mutable_test_as_MyGame_Example2_Monster() {
|
||||||
|
return test_type() == MyGame::Example::Any_MyGame_Example2_Monster ? static_cast<MyGame::Example2::Monster *>(mutable_test()) : nullptr;
|
||||||
|
}
|
||||||
void *mutable_test() {
|
void *mutable_test() {
|
||||||
return GetPointer<void *>(VT_TEST);
|
return GetPointer<void *>(VT_TEST);
|
||||||
}
|
}
|
||||||
@@ -1732,6 +1742,16 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const MyGame::Example2::Monster *any_unique_as_M2() const {
|
const MyGame::Example2::Monster *any_unique_as_M2() const {
|
||||||
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M2 ? static_cast<const MyGame::Example2::Monster *>(any_unique()) : nullptr;
|
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M2 ? static_cast<const MyGame::Example2::Monster *>(any_unique()) : nullptr;
|
||||||
}
|
}
|
||||||
|
template<typename T> T *mutable_any_unique_as();
|
||||||
|
MyGame::Example::Monster *mutable_any_unique_as_M() {
|
||||||
|
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M ? static_cast<MyGame::Example::Monster *>(mutable_any_unique()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example::TestSimpleTableWithEnum *mutable_any_unique_as_TS() {
|
||||||
|
return any_unique_type() == MyGame::Example::AnyUniqueAliases_TS ? static_cast<MyGame::Example::TestSimpleTableWithEnum *>(mutable_any_unique()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example2::Monster *mutable_any_unique_as_M2() {
|
||||||
|
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M2 ? static_cast<MyGame::Example2::Monster *>(mutable_any_unique()) : nullptr;
|
||||||
|
}
|
||||||
void *mutable_any_unique() {
|
void *mutable_any_unique() {
|
||||||
return GetPointer<void *>(VT_ANY_UNIQUE);
|
return GetPointer<void *>(VT_ANY_UNIQUE);
|
||||||
}
|
}
|
||||||
@@ -1750,6 +1770,15 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const MyGame::Example::Monster *any_ambiguous_as_M3() const {
|
const MyGame::Example::Monster *any_ambiguous_as_M3() const {
|
||||||
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M3 ? static_cast<const MyGame::Example::Monster *>(any_ambiguous()) : nullptr;
|
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M3 ? static_cast<const MyGame::Example::Monster *>(any_ambiguous()) : nullptr;
|
||||||
}
|
}
|
||||||
|
MyGame::Example::Monster *mutable_any_ambiguous_as_M1() {
|
||||||
|
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M1 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example::Monster *mutable_any_ambiguous_as_M2() {
|
||||||
|
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M2 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example::Monster *mutable_any_ambiguous_as_M3() {
|
||||||
|
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M3 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
|
||||||
|
}
|
||||||
void *mutable_any_ambiguous() {
|
void *mutable_any_ambiguous() {
|
||||||
return GetPointer<void *>(VT_ANY_AMBIGUOUS);
|
return GetPointer<void *>(VT_ANY_AMBIGUOUS);
|
||||||
}
|
}
|
||||||
@@ -1959,26 +1988,50 @@ template<> inline const MyGame::Example::Monster *Monster::test_as<MyGame::Examp
|
|||||||
return test_as_Monster();
|
return test_as_Monster();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example::Monster *Monster::mutable_test_as<MyGame::Example::Monster>() {
|
||||||
|
return mutable_test_as_Monster();
|
||||||
|
}
|
||||||
|
|
||||||
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::test_as<MyGame::Example::TestSimpleTableWithEnum>() const {
|
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::test_as<MyGame::Example::TestSimpleTableWithEnum>() const {
|
||||||
return test_as_TestSimpleTableWithEnum();
|
return test_as_TestSimpleTableWithEnum();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example::TestSimpleTableWithEnum *Monster::mutable_test_as<MyGame::Example::TestSimpleTableWithEnum>() {
|
||||||
|
return mutable_test_as_TestSimpleTableWithEnum();
|
||||||
|
}
|
||||||
|
|
||||||
template<> inline const MyGame::Example2::Monster *Monster::test_as<MyGame::Example2::Monster>() const {
|
template<> inline const MyGame::Example2::Monster *Monster::test_as<MyGame::Example2::Monster>() const {
|
||||||
return test_as_MyGame_Example2_Monster();
|
return test_as_MyGame_Example2_Monster();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example2::Monster *Monster::mutable_test_as<MyGame::Example2::Monster>() {
|
||||||
|
return mutable_test_as_MyGame_Example2_Monster();
|
||||||
|
}
|
||||||
|
|
||||||
template<> inline const MyGame::Example::Monster *Monster::any_unique_as<MyGame::Example::Monster>() const {
|
template<> inline const MyGame::Example::Monster *Monster::any_unique_as<MyGame::Example::Monster>() const {
|
||||||
return any_unique_as_M();
|
return any_unique_as_M();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example::Monster *Monster::mutable_any_unique_as<MyGame::Example::Monster>() {
|
||||||
|
return mutable_any_unique_as_M();
|
||||||
|
}
|
||||||
|
|
||||||
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() const {
|
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() const {
|
||||||
return any_unique_as_TS();
|
return any_unique_as_TS();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example::TestSimpleTableWithEnum *Monster::mutable_any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() {
|
||||||
|
return mutable_any_unique_as_TS();
|
||||||
|
}
|
||||||
|
|
||||||
template<> inline const MyGame::Example2::Monster *Monster::any_unique_as<MyGame::Example2::Monster>() const {
|
template<> inline const MyGame::Example2::Monster *Monster::any_unique_as<MyGame::Example2::Monster>() const {
|
||||||
return any_unique_as_M2();
|
return any_unique_as_M2();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example2::Monster *Monster::mutable_any_unique_as<MyGame::Example2::Monster>() {
|
||||||
|
return mutable_any_unique_as_M2();
|
||||||
|
}
|
||||||
|
|
||||||
struct MonsterBuilder {
|
struct MonsterBuilder {
|
||||||
typedef Monster Table;
|
typedef Monster Table;
|
||||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||||
|
|||||||
@@ -1761,6 +1761,13 @@ def MonsterAddInventory(builder, inventory):
|
|||||||
def MonsterStartInventoryVector(builder, numElems):
|
def MonsterStartInventoryVector(builder, numElems):
|
||||||
return builder.StartVector(1, numElems, 1)
|
return builder.StartVector(1, numElems, 1)
|
||||||
|
|
||||||
|
def MonsterCreateInventoryVector(builder, data):
|
||||||
|
data = list(data)
|
||||||
|
builder.StartVector(1, len(data), 1)
|
||||||
|
for item in reversed(data):
|
||||||
|
builder.PrependUint8(item)
|
||||||
|
return builder.EndVector()
|
||||||
|
|
||||||
def MonsterAddColor(builder, color):
|
def MonsterAddColor(builder, color):
|
||||||
builder.PrependUint8Slot(6, color, 8)
|
builder.PrependUint8Slot(6, color, 8)
|
||||||
|
|
||||||
@@ -1776,18 +1783,31 @@ def MonsterAddTest4(builder, test4):
|
|||||||
def MonsterStartTest4Vector(builder, numElems):
|
def MonsterStartTest4Vector(builder, numElems):
|
||||||
return builder.StartVector(4, numElems, 2)
|
return builder.StartVector(4, numElems, 2)
|
||||||
|
|
||||||
|
def MonsterCreateTest4Vector(builder, data):
|
||||||
|
data = list(data)
|
||||||
|
builder.StartVector(4, len(data), 2)
|
||||||
|
for item in reversed(data):
|
||||||
|
item.Pack(builder)
|
||||||
|
return builder.EndVector()
|
||||||
|
|
||||||
def MonsterAddTestarrayofstring(builder, testarrayofstring):
|
def MonsterAddTestarrayofstring(builder, testarrayofstring):
|
||||||
builder.PrependUOffsetTRelativeSlot(10, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayofstring), 0)
|
builder.PrependUOffsetTRelativeSlot(10, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayofstring), 0)
|
||||||
|
|
||||||
def MonsterStartTestarrayofstringVector(builder, numElems):
|
def MonsterStartTestarrayofstringVector(builder, numElems):
|
||||||
return builder.StartVector(4, numElems, 4)
|
return builder.StartVector(4, numElems, 4)
|
||||||
|
|
||||||
|
def MonsterCreateTestarrayofstringVector(builder, data):
|
||||||
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def MonsterAddTestarrayoftables(builder, testarrayoftables):
|
def MonsterAddTestarrayoftables(builder, testarrayoftables):
|
||||||
builder.PrependUOffsetTRelativeSlot(11, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayoftables), 0)
|
builder.PrependUOffsetTRelativeSlot(11, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayoftables), 0)
|
||||||
|
|
||||||
def MonsterStartTestarrayoftablesVector(builder, numElems):
|
def MonsterStartTestarrayoftablesVector(builder, numElems):
|
||||||
return builder.StartVector(4, numElems, 4)
|
return builder.StartVector(4, numElems, 4)
|
||||||
|
|
||||||
|
def MonsterCreateTestarrayoftablesVector(builder, data):
|
||||||
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def MonsterAddEnemy(builder, enemy):
|
def MonsterAddEnemy(builder, enemy):
|
||||||
builder.PrependUOffsetTRelativeSlot(12, flatbuffers.number_types.UOffsetTFlags.py_type(enemy), 0)
|
builder.PrependUOffsetTRelativeSlot(12, flatbuffers.number_types.UOffsetTFlags.py_type(enemy), 0)
|
||||||
|
|
||||||
@@ -1797,6 +1817,13 @@ def MonsterAddTestnestedflatbuffer(builder, testnestedflatbuffer):
|
|||||||
def MonsterStartTestnestedflatbufferVector(builder, numElems):
|
def MonsterStartTestnestedflatbufferVector(builder, numElems):
|
||||||
return builder.StartVector(1, numElems, 1)
|
return builder.StartVector(1, numElems, 1)
|
||||||
|
|
||||||
|
def MonsterCreateTestnestedflatbufferVector(builder, data):
|
||||||
|
data = list(data)
|
||||||
|
builder.StartVector(1, len(data), 1)
|
||||||
|
for item in reversed(data):
|
||||||
|
builder.PrependUint8(item)
|
||||||
|
return builder.EndVector()
|
||||||
|
|
||||||
def MonsterMakeTestnestedflatbufferVectorFromBytes(builder, bytes):
|
def MonsterMakeTestnestedflatbufferVectorFromBytes(builder, bytes):
|
||||||
builder.StartVector(1, len(bytes), 1)
|
builder.StartVector(1, len(bytes), 1)
|
||||||
builder.head = builder.head - len(bytes)
|
builder.head = builder.head - len(bytes)
|
||||||
@@ -1838,6 +1865,13 @@ def MonsterAddTestarrayofbools(builder, testarrayofbools):
|
|||||||
def MonsterStartTestarrayofboolsVector(builder, numElems):
|
def MonsterStartTestarrayofboolsVector(builder, numElems):
|
||||||
return builder.StartVector(1, numElems, 1)
|
return builder.StartVector(1, numElems, 1)
|
||||||
|
|
||||||
|
def MonsterCreateTestarrayofboolsVector(builder, data):
|
||||||
|
data = list(data)
|
||||||
|
builder.StartVector(1, len(data), 1)
|
||||||
|
for item in reversed(data):
|
||||||
|
builder.PrependBool(item)
|
||||||
|
return builder.EndVector()
|
||||||
|
|
||||||
def MonsterAddTestf(builder, testf):
|
def MonsterAddTestf(builder, testf):
|
||||||
builder.PrependFloat32Slot(25, testf, 3.14159)
|
builder.PrependFloat32Slot(25, testf, 3.14159)
|
||||||
|
|
||||||
@@ -1853,36 +1887,74 @@ def MonsterAddTestarrayofstring2(builder, testarrayofstring2):
|
|||||||
def MonsterStartTestarrayofstring2Vector(builder, numElems):
|
def MonsterStartTestarrayofstring2Vector(builder, numElems):
|
||||||
return builder.StartVector(4, numElems, 4)
|
return builder.StartVector(4, numElems, 4)
|
||||||
|
|
||||||
|
def MonsterCreateTestarrayofstring2Vector(builder, data):
|
||||||
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def MonsterAddTestarrayofsortedstruct(builder, testarrayofsortedstruct):
|
def MonsterAddTestarrayofsortedstruct(builder, testarrayofsortedstruct):
|
||||||
builder.PrependUOffsetTRelativeSlot(29, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayofsortedstruct), 0)
|
builder.PrependUOffsetTRelativeSlot(29, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayofsortedstruct), 0)
|
||||||
|
|
||||||
def MonsterStartTestarrayofsortedstructVector(builder, numElems):
|
def MonsterStartTestarrayofsortedstructVector(builder, numElems):
|
||||||
return builder.StartVector(8, numElems, 4)
|
return builder.StartVector(8, numElems, 4)
|
||||||
|
|
||||||
|
def MonsterCreateTestarrayofsortedstructVector(builder, data):
|
||||||
|
data = list(data)
|
||||||
|
builder.StartVector(8, len(data), 4)
|
||||||
|
for item in reversed(data):
|
||||||
|
item.Pack(builder)
|
||||||
|
return builder.EndVector()
|
||||||
|
|
||||||
def MonsterAddFlex(builder, flex):
|
def MonsterAddFlex(builder, flex):
|
||||||
builder.PrependUOffsetTRelativeSlot(30, flatbuffers.number_types.UOffsetTFlags.py_type(flex), 0)
|
builder.PrependUOffsetTRelativeSlot(30, flatbuffers.number_types.UOffsetTFlags.py_type(flex), 0)
|
||||||
|
|
||||||
def MonsterStartFlexVector(builder, numElems):
|
def MonsterStartFlexVector(builder, numElems):
|
||||||
return builder.StartVector(1, numElems, 1)
|
return builder.StartVector(1, numElems, 1)
|
||||||
|
|
||||||
|
def MonsterCreateFlexVector(builder, data):
|
||||||
|
data = list(data)
|
||||||
|
builder.StartVector(1, len(data), 1)
|
||||||
|
for item in reversed(data):
|
||||||
|
builder.PrependUint8(item)
|
||||||
|
return builder.EndVector()
|
||||||
|
|
||||||
def MonsterAddTest5(builder, test5):
|
def MonsterAddTest5(builder, test5):
|
||||||
builder.PrependUOffsetTRelativeSlot(31, flatbuffers.number_types.UOffsetTFlags.py_type(test5), 0)
|
builder.PrependUOffsetTRelativeSlot(31, flatbuffers.number_types.UOffsetTFlags.py_type(test5), 0)
|
||||||
|
|
||||||
def MonsterStartTest5Vector(builder, numElems):
|
def MonsterStartTest5Vector(builder, numElems):
|
||||||
return builder.StartVector(4, numElems, 2)
|
return builder.StartVector(4, numElems, 2)
|
||||||
|
|
||||||
|
def MonsterCreateTest5Vector(builder, data):
|
||||||
|
data = list(data)
|
||||||
|
builder.StartVector(4, len(data), 2)
|
||||||
|
for item in reversed(data):
|
||||||
|
item.Pack(builder)
|
||||||
|
return builder.EndVector()
|
||||||
|
|
||||||
def MonsterAddVectorOfLongs(builder, vectorOfLongs):
|
def MonsterAddVectorOfLongs(builder, vectorOfLongs):
|
||||||
builder.PrependUOffsetTRelativeSlot(32, flatbuffers.number_types.UOffsetTFlags.py_type(vectorOfLongs), 0)
|
builder.PrependUOffsetTRelativeSlot(32, flatbuffers.number_types.UOffsetTFlags.py_type(vectorOfLongs), 0)
|
||||||
|
|
||||||
def MonsterStartVectorOfLongsVector(builder, numElems):
|
def MonsterStartVectorOfLongsVector(builder, numElems):
|
||||||
return builder.StartVector(8, numElems, 8)
|
return builder.StartVector(8, numElems, 8)
|
||||||
|
|
||||||
|
def MonsterCreateVectorOfLongsVector(builder, data):
|
||||||
|
data = list(data)
|
||||||
|
builder.StartVector(8, len(data), 8)
|
||||||
|
for item in reversed(data):
|
||||||
|
builder.PrependInt64(item)
|
||||||
|
return builder.EndVector()
|
||||||
|
|
||||||
def MonsterAddVectorOfDoubles(builder, vectorOfDoubles):
|
def MonsterAddVectorOfDoubles(builder, vectorOfDoubles):
|
||||||
builder.PrependUOffsetTRelativeSlot(33, flatbuffers.number_types.UOffsetTFlags.py_type(vectorOfDoubles), 0)
|
builder.PrependUOffsetTRelativeSlot(33, flatbuffers.number_types.UOffsetTFlags.py_type(vectorOfDoubles), 0)
|
||||||
|
|
||||||
def MonsterStartVectorOfDoublesVector(builder, numElems):
|
def MonsterStartVectorOfDoublesVector(builder, numElems):
|
||||||
return builder.StartVector(8, numElems, 8)
|
return builder.StartVector(8, numElems, 8)
|
||||||
|
|
||||||
|
def MonsterCreateVectorOfDoublesVector(builder, data):
|
||||||
|
data = list(data)
|
||||||
|
builder.StartVector(8, len(data), 8)
|
||||||
|
for item in reversed(data):
|
||||||
|
builder.PrependFloat64(item)
|
||||||
|
return builder.EndVector()
|
||||||
|
|
||||||
def MonsterAddParentNamespaceTest(builder, parentNamespaceTest):
|
def MonsterAddParentNamespaceTest(builder, parentNamespaceTest):
|
||||||
builder.PrependUOffsetTRelativeSlot(34, flatbuffers.number_types.UOffsetTFlags.py_type(parentNamespaceTest), 0)
|
builder.PrependUOffsetTRelativeSlot(34, flatbuffers.number_types.UOffsetTFlags.py_type(parentNamespaceTest), 0)
|
||||||
|
|
||||||
@@ -1892,6 +1964,9 @@ def MonsterAddVectorOfReferrables(builder, vectorOfReferrables):
|
|||||||
def MonsterStartVectorOfReferrablesVector(builder, numElems):
|
def MonsterStartVectorOfReferrablesVector(builder, numElems):
|
||||||
return builder.StartVector(4, numElems, 4)
|
return builder.StartVector(4, numElems, 4)
|
||||||
|
|
||||||
|
def MonsterCreateVectorOfReferrablesVector(builder, data):
|
||||||
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def MonsterAddSingleWeakReference(builder, singleWeakReference):
|
def MonsterAddSingleWeakReference(builder, singleWeakReference):
|
||||||
builder.PrependUint64Slot(36, singleWeakReference, 0)
|
builder.PrependUint64Slot(36, singleWeakReference, 0)
|
||||||
|
|
||||||
@@ -1901,12 +1976,22 @@ def MonsterAddVectorOfWeakReferences(builder, vectorOfWeakReferences):
|
|||||||
def MonsterStartVectorOfWeakReferencesVector(builder, numElems):
|
def MonsterStartVectorOfWeakReferencesVector(builder, numElems):
|
||||||
return builder.StartVector(8, numElems, 8)
|
return builder.StartVector(8, numElems, 8)
|
||||||
|
|
||||||
|
def MonsterCreateVectorOfWeakReferencesVector(builder, data):
|
||||||
|
data = list(data)
|
||||||
|
builder.StartVector(8, len(data), 8)
|
||||||
|
for item in reversed(data):
|
||||||
|
builder.PrependUint64(item)
|
||||||
|
return builder.EndVector()
|
||||||
|
|
||||||
def MonsterAddVectorOfStrongReferrables(builder, vectorOfStrongReferrables):
|
def MonsterAddVectorOfStrongReferrables(builder, vectorOfStrongReferrables):
|
||||||
builder.PrependUOffsetTRelativeSlot(38, flatbuffers.number_types.UOffsetTFlags.py_type(vectorOfStrongReferrables), 0)
|
builder.PrependUOffsetTRelativeSlot(38, flatbuffers.number_types.UOffsetTFlags.py_type(vectorOfStrongReferrables), 0)
|
||||||
|
|
||||||
def MonsterStartVectorOfStrongReferrablesVector(builder, numElems):
|
def MonsterStartVectorOfStrongReferrablesVector(builder, numElems):
|
||||||
return builder.StartVector(4, numElems, 4)
|
return builder.StartVector(4, numElems, 4)
|
||||||
|
|
||||||
|
def MonsterCreateVectorOfStrongReferrablesVector(builder, data):
|
||||||
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def MonsterAddCoOwningReference(builder, coOwningReference):
|
def MonsterAddCoOwningReference(builder, coOwningReference):
|
||||||
builder.PrependUint64Slot(39, coOwningReference, 0)
|
builder.PrependUint64Slot(39, coOwningReference, 0)
|
||||||
|
|
||||||
@@ -1916,6 +2001,13 @@ def MonsterAddVectorOfCoOwningReferences(builder, vectorOfCoOwningReferences):
|
|||||||
def MonsterStartVectorOfCoOwningReferencesVector(builder, numElems):
|
def MonsterStartVectorOfCoOwningReferencesVector(builder, numElems):
|
||||||
return builder.StartVector(8, numElems, 8)
|
return builder.StartVector(8, numElems, 8)
|
||||||
|
|
||||||
|
def MonsterCreateVectorOfCoOwningReferencesVector(builder, data):
|
||||||
|
data = list(data)
|
||||||
|
builder.StartVector(8, len(data), 8)
|
||||||
|
for item in reversed(data):
|
||||||
|
builder.PrependUint64(item)
|
||||||
|
return builder.EndVector()
|
||||||
|
|
||||||
def MonsterAddNonOwningReference(builder, nonOwningReference):
|
def MonsterAddNonOwningReference(builder, nonOwningReference):
|
||||||
builder.PrependUint64Slot(41, nonOwningReference, 0)
|
builder.PrependUint64Slot(41, nonOwningReference, 0)
|
||||||
|
|
||||||
@@ -1925,6 +2017,13 @@ def MonsterAddVectorOfNonOwningReferences(builder, vectorOfNonOwningReferences):
|
|||||||
def MonsterStartVectorOfNonOwningReferencesVector(builder, numElems):
|
def MonsterStartVectorOfNonOwningReferencesVector(builder, numElems):
|
||||||
return builder.StartVector(8, numElems, 8)
|
return builder.StartVector(8, numElems, 8)
|
||||||
|
|
||||||
|
def MonsterCreateVectorOfNonOwningReferencesVector(builder, data):
|
||||||
|
data = list(data)
|
||||||
|
builder.StartVector(8, len(data), 8)
|
||||||
|
for item in reversed(data):
|
||||||
|
builder.PrependUint64(item)
|
||||||
|
return builder.EndVector()
|
||||||
|
|
||||||
def MonsterAddAnyUniqueType(builder, anyUniqueType):
|
def MonsterAddAnyUniqueType(builder, anyUniqueType):
|
||||||
builder.PrependUint8Slot(43, anyUniqueType, 0)
|
builder.PrependUint8Slot(43, anyUniqueType, 0)
|
||||||
|
|
||||||
@@ -1943,6 +2042,13 @@ def MonsterAddVectorOfEnums(builder, vectorOfEnums):
|
|||||||
def MonsterStartVectorOfEnumsVector(builder, numElems):
|
def MonsterStartVectorOfEnumsVector(builder, numElems):
|
||||||
return builder.StartVector(1, numElems, 1)
|
return builder.StartVector(1, numElems, 1)
|
||||||
|
|
||||||
|
def MonsterCreateVectorOfEnumsVector(builder, data):
|
||||||
|
data = list(data)
|
||||||
|
builder.StartVector(1, len(data), 1)
|
||||||
|
for item in reversed(data):
|
||||||
|
builder.PrependUint8(item)
|
||||||
|
return builder.EndVector()
|
||||||
|
|
||||||
def MonsterAddSignedEnum(builder, signedEnum):
|
def MonsterAddSignedEnum(builder, signedEnum):
|
||||||
builder.PrependInt8Slot(48, signedEnum, -1)
|
builder.PrependInt8Slot(48, signedEnum, -1)
|
||||||
|
|
||||||
@@ -1952,6 +2058,13 @@ def MonsterAddTestrequirednestedflatbuffer(builder, testrequirednestedflatbuffer
|
|||||||
def MonsterStartTestrequirednestedflatbufferVector(builder, numElems):
|
def MonsterStartTestrequirednestedflatbufferVector(builder, numElems):
|
||||||
return builder.StartVector(1, numElems, 1)
|
return builder.StartVector(1, numElems, 1)
|
||||||
|
|
||||||
|
def MonsterCreateTestrequirednestedflatbufferVector(builder, data):
|
||||||
|
data = list(data)
|
||||||
|
builder.StartVector(1, len(data), 1)
|
||||||
|
for item in reversed(data):
|
||||||
|
builder.PrependUint8(item)
|
||||||
|
return builder.EndVector()
|
||||||
|
|
||||||
def MonsterMakeTestrequirednestedflatbufferVectorFromBytes(builder, bytes):
|
def MonsterMakeTestrequirednestedflatbufferVectorFromBytes(builder, bytes):
|
||||||
builder.StartVector(1, len(bytes), 1)
|
builder.StartVector(1, len(bytes), 1)
|
||||||
builder.head = builder.head - len(bytes)
|
builder.head = builder.head - len(bytes)
|
||||||
@@ -1963,6 +2076,9 @@ def MonsterAddScalarKeySortedTables(builder, scalarKeySortedTables):
|
|||||||
def MonsterStartScalarKeySortedTablesVector(builder, numElems):
|
def MonsterStartScalarKeySortedTablesVector(builder, numElems):
|
||||||
return builder.StartVector(4, numElems, 4)
|
return builder.StartVector(4, numElems, 4)
|
||||||
|
|
||||||
|
def MonsterCreateScalarKeySortedTablesVector(builder, data):
|
||||||
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def MonsterAddNativeInline(builder, nativeInline):
|
def MonsterAddNativeInline(builder, nativeInline):
|
||||||
builder.PrependStructSlot(51, flatbuffers.number_types.UOffsetTFlags.py_type(nativeInline), 0)
|
builder.PrependStructSlot(51, flatbuffers.number_types.UOffsetTFlags.py_type(nativeInline), 0)
|
||||||
|
|
||||||
@@ -2792,12 +2908,26 @@ def TypeAliasesAddV8(builder, v8):
|
|||||||
def TypeAliasesStartV8Vector(builder, numElems):
|
def TypeAliasesStartV8Vector(builder, numElems):
|
||||||
return builder.StartVector(1, numElems, 1)
|
return builder.StartVector(1, numElems, 1)
|
||||||
|
|
||||||
|
def TypeAliasesCreateV8Vector(builder, data):
|
||||||
|
data = list(data)
|
||||||
|
builder.StartVector(1, len(data), 1)
|
||||||
|
for item in reversed(data):
|
||||||
|
builder.PrependInt8(item)
|
||||||
|
return builder.EndVector()
|
||||||
|
|
||||||
def TypeAliasesAddVf64(builder, vf64):
|
def TypeAliasesAddVf64(builder, vf64):
|
||||||
builder.PrependUOffsetTRelativeSlot(11, flatbuffers.number_types.UOffsetTFlags.py_type(vf64), 0)
|
builder.PrependUOffsetTRelativeSlot(11, flatbuffers.number_types.UOffsetTFlags.py_type(vf64), 0)
|
||||||
|
|
||||||
def TypeAliasesStartVf64Vector(builder, numElems):
|
def TypeAliasesStartVf64Vector(builder, numElems):
|
||||||
return builder.StartVector(8, numElems, 8)
|
return builder.StartVector(8, numElems, 8)
|
||||||
|
|
||||||
|
def TypeAliasesCreateVf64Vector(builder, data):
|
||||||
|
data = list(data)
|
||||||
|
builder.StartVector(8, len(data), 8)
|
||||||
|
for item in reversed(data):
|
||||||
|
builder.PrependFloat64(item)
|
||||||
|
return builder.EndVector()
|
||||||
|
|
||||||
def TypeAliasesEnd(builder):
|
def TypeAliasesEnd(builder):
|
||||||
return builder.EndObject()
|
return builder.EndObject()
|
||||||
|
|
||||||
|
|||||||
@@ -1488,6 +1488,16 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const MyGame::Example2::Monster *test_as_MyGame_Example2_Monster() const {
|
const MyGame::Example2::Monster *test_as_MyGame_Example2_Monster() const {
|
||||||
return test_type() == MyGame::Example::Any_MyGame_Example2_Monster ? static_cast<const MyGame::Example2::Monster *>(test()) : nullptr;
|
return test_type() == MyGame::Example::Any_MyGame_Example2_Monster ? static_cast<const MyGame::Example2::Monster *>(test()) : nullptr;
|
||||||
}
|
}
|
||||||
|
template<typename T> T *mutable_test_as();
|
||||||
|
MyGame::Example::Monster *mutable_test_as_Monster() {
|
||||||
|
return test_type() == MyGame::Example::Any_Monster ? static_cast<MyGame::Example::Monster *>(mutable_test()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example::TestSimpleTableWithEnum *mutable_test_as_TestSimpleTableWithEnum() {
|
||||||
|
return test_type() == MyGame::Example::Any_TestSimpleTableWithEnum ? static_cast<MyGame::Example::TestSimpleTableWithEnum *>(mutable_test()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example2::Monster *mutable_test_as_MyGame_Example2_Monster() {
|
||||||
|
return test_type() == MyGame::Example::Any_MyGame_Example2_Monster ? static_cast<MyGame::Example2::Monster *>(mutable_test()) : nullptr;
|
||||||
|
}
|
||||||
void *mutable_test() {
|
void *mutable_test() {
|
||||||
return GetPointer<void *>(VT_TEST);
|
return GetPointer<void *>(VT_TEST);
|
||||||
}
|
}
|
||||||
@@ -1723,6 +1733,16 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const MyGame::Example2::Monster *any_unique_as_M2() const {
|
const MyGame::Example2::Monster *any_unique_as_M2() const {
|
||||||
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M2 ? static_cast<const MyGame::Example2::Monster *>(any_unique()) : nullptr;
|
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M2 ? static_cast<const MyGame::Example2::Monster *>(any_unique()) : nullptr;
|
||||||
}
|
}
|
||||||
|
template<typename T> T *mutable_any_unique_as();
|
||||||
|
MyGame::Example::Monster *mutable_any_unique_as_M() {
|
||||||
|
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M ? static_cast<MyGame::Example::Monster *>(mutable_any_unique()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example::TestSimpleTableWithEnum *mutable_any_unique_as_TS() {
|
||||||
|
return any_unique_type() == MyGame::Example::AnyUniqueAliases_TS ? static_cast<MyGame::Example::TestSimpleTableWithEnum *>(mutable_any_unique()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example2::Monster *mutable_any_unique_as_M2() {
|
||||||
|
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M2 ? static_cast<MyGame::Example2::Monster *>(mutable_any_unique()) : nullptr;
|
||||||
|
}
|
||||||
void *mutable_any_unique() {
|
void *mutable_any_unique() {
|
||||||
return GetPointer<void *>(VT_ANY_UNIQUE);
|
return GetPointer<void *>(VT_ANY_UNIQUE);
|
||||||
}
|
}
|
||||||
@@ -1741,6 +1761,15 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const MyGame::Example::Monster *any_ambiguous_as_M3() const {
|
const MyGame::Example::Monster *any_ambiguous_as_M3() const {
|
||||||
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M3 ? static_cast<const MyGame::Example::Monster *>(any_ambiguous()) : nullptr;
|
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M3 ? static_cast<const MyGame::Example::Monster *>(any_ambiguous()) : nullptr;
|
||||||
}
|
}
|
||||||
|
MyGame::Example::Monster *mutable_any_ambiguous_as_M1() {
|
||||||
|
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M1 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example::Monster *mutable_any_ambiguous_as_M2() {
|
||||||
|
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M2 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example::Monster *mutable_any_ambiguous_as_M3() {
|
||||||
|
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M3 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
|
||||||
|
}
|
||||||
void *mutable_any_ambiguous() {
|
void *mutable_any_ambiguous() {
|
||||||
return GetPointer<void *>(VT_ANY_AMBIGUOUS);
|
return GetPointer<void *>(VT_ANY_AMBIGUOUS);
|
||||||
}
|
}
|
||||||
@@ -1950,26 +1979,50 @@ template<> inline const MyGame::Example::Monster *Monster::test_as<MyGame::Examp
|
|||||||
return test_as_Monster();
|
return test_as_Monster();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example::Monster *Monster::mutable_test_as<MyGame::Example::Monster>() {
|
||||||
|
return mutable_test_as_Monster();
|
||||||
|
}
|
||||||
|
|
||||||
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::test_as<MyGame::Example::TestSimpleTableWithEnum>() const {
|
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::test_as<MyGame::Example::TestSimpleTableWithEnum>() const {
|
||||||
return test_as_TestSimpleTableWithEnum();
|
return test_as_TestSimpleTableWithEnum();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example::TestSimpleTableWithEnum *Monster::mutable_test_as<MyGame::Example::TestSimpleTableWithEnum>() {
|
||||||
|
return mutable_test_as_TestSimpleTableWithEnum();
|
||||||
|
}
|
||||||
|
|
||||||
template<> inline const MyGame::Example2::Monster *Monster::test_as<MyGame::Example2::Monster>() const {
|
template<> inline const MyGame::Example2::Monster *Monster::test_as<MyGame::Example2::Monster>() const {
|
||||||
return test_as_MyGame_Example2_Monster();
|
return test_as_MyGame_Example2_Monster();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example2::Monster *Monster::mutable_test_as<MyGame::Example2::Monster>() {
|
||||||
|
return mutable_test_as_MyGame_Example2_Monster();
|
||||||
|
}
|
||||||
|
|
||||||
template<> inline const MyGame::Example::Monster *Monster::any_unique_as<MyGame::Example::Monster>() const {
|
template<> inline const MyGame::Example::Monster *Monster::any_unique_as<MyGame::Example::Monster>() const {
|
||||||
return any_unique_as_M();
|
return any_unique_as_M();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example::Monster *Monster::mutable_any_unique_as<MyGame::Example::Monster>() {
|
||||||
|
return mutable_any_unique_as_M();
|
||||||
|
}
|
||||||
|
|
||||||
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() const {
|
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() const {
|
||||||
return any_unique_as_TS();
|
return any_unique_as_TS();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example::TestSimpleTableWithEnum *Monster::mutable_any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() {
|
||||||
|
return mutable_any_unique_as_TS();
|
||||||
|
}
|
||||||
|
|
||||||
template<> inline const MyGame::Example2::Monster *Monster::any_unique_as<MyGame::Example2::Monster>() const {
|
template<> inline const MyGame::Example2::Monster *Monster::any_unique_as<MyGame::Example2::Monster>() const {
|
||||||
return any_unique_as_M2();
|
return any_unique_as_M2();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example2::Monster *Monster::mutable_any_unique_as<MyGame::Example2::Monster>() {
|
||||||
|
return mutable_any_unique_as_M2();
|
||||||
|
}
|
||||||
|
|
||||||
struct MonsterBuilder {
|
struct MonsterBuilder {
|
||||||
typedef Monster Table;
|
typedef Monster Table;
|
||||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||||
|
|||||||
@@ -1488,6 +1488,16 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const MyGame::Example2::Monster *test_as_MyGame_Example2_Monster() const {
|
const MyGame::Example2::Monster *test_as_MyGame_Example2_Monster() const {
|
||||||
return test_type() == MyGame::Example::Any_MyGame_Example2_Monster ? static_cast<const MyGame::Example2::Monster *>(test()) : nullptr;
|
return test_type() == MyGame::Example::Any_MyGame_Example2_Monster ? static_cast<const MyGame::Example2::Monster *>(test()) : nullptr;
|
||||||
}
|
}
|
||||||
|
template<typename T> T *mutable_test_as();
|
||||||
|
MyGame::Example::Monster *mutable_test_as_Monster() {
|
||||||
|
return test_type() == MyGame::Example::Any_Monster ? static_cast<MyGame::Example::Monster *>(mutable_test()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example::TestSimpleTableWithEnum *mutable_test_as_TestSimpleTableWithEnum() {
|
||||||
|
return test_type() == MyGame::Example::Any_TestSimpleTableWithEnum ? static_cast<MyGame::Example::TestSimpleTableWithEnum *>(mutable_test()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example2::Monster *mutable_test_as_MyGame_Example2_Monster() {
|
||||||
|
return test_type() == MyGame::Example::Any_MyGame_Example2_Monster ? static_cast<MyGame::Example2::Monster *>(mutable_test()) : nullptr;
|
||||||
|
}
|
||||||
void *mutable_test() {
|
void *mutable_test() {
|
||||||
return GetPointer<void *>(VT_TEST);
|
return GetPointer<void *>(VT_TEST);
|
||||||
}
|
}
|
||||||
@@ -1723,6 +1733,16 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const MyGame::Example2::Monster *any_unique_as_M2() const {
|
const MyGame::Example2::Monster *any_unique_as_M2() const {
|
||||||
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M2 ? static_cast<const MyGame::Example2::Monster *>(any_unique()) : nullptr;
|
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M2 ? static_cast<const MyGame::Example2::Monster *>(any_unique()) : nullptr;
|
||||||
}
|
}
|
||||||
|
template<typename T> T *mutable_any_unique_as();
|
||||||
|
MyGame::Example::Monster *mutable_any_unique_as_M() {
|
||||||
|
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M ? static_cast<MyGame::Example::Monster *>(mutable_any_unique()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example::TestSimpleTableWithEnum *mutable_any_unique_as_TS() {
|
||||||
|
return any_unique_type() == MyGame::Example::AnyUniqueAliases_TS ? static_cast<MyGame::Example::TestSimpleTableWithEnum *>(mutable_any_unique()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example2::Monster *mutable_any_unique_as_M2() {
|
||||||
|
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M2 ? static_cast<MyGame::Example2::Monster *>(mutable_any_unique()) : nullptr;
|
||||||
|
}
|
||||||
void *mutable_any_unique() {
|
void *mutable_any_unique() {
|
||||||
return GetPointer<void *>(VT_ANY_UNIQUE);
|
return GetPointer<void *>(VT_ANY_UNIQUE);
|
||||||
}
|
}
|
||||||
@@ -1741,6 +1761,15 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const MyGame::Example::Monster *any_ambiguous_as_M3() const {
|
const MyGame::Example::Monster *any_ambiguous_as_M3() const {
|
||||||
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M3 ? static_cast<const MyGame::Example::Monster *>(any_ambiguous()) : nullptr;
|
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M3 ? static_cast<const MyGame::Example::Monster *>(any_ambiguous()) : nullptr;
|
||||||
}
|
}
|
||||||
|
MyGame::Example::Monster *mutable_any_ambiguous_as_M1() {
|
||||||
|
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M1 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example::Monster *mutable_any_ambiguous_as_M2() {
|
||||||
|
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M2 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example::Monster *mutable_any_ambiguous_as_M3() {
|
||||||
|
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M3 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
|
||||||
|
}
|
||||||
void *mutable_any_ambiguous() {
|
void *mutable_any_ambiguous() {
|
||||||
return GetPointer<void *>(VT_ANY_AMBIGUOUS);
|
return GetPointer<void *>(VT_ANY_AMBIGUOUS);
|
||||||
}
|
}
|
||||||
@@ -1950,26 +1979,50 @@ template<> inline const MyGame::Example::Monster *Monster::test_as<MyGame::Examp
|
|||||||
return test_as_Monster();
|
return test_as_Monster();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example::Monster *Monster::mutable_test_as<MyGame::Example::Monster>() {
|
||||||
|
return mutable_test_as_Monster();
|
||||||
|
}
|
||||||
|
|
||||||
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::test_as<MyGame::Example::TestSimpleTableWithEnum>() const {
|
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::test_as<MyGame::Example::TestSimpleTableWithEnum>() const {
|
||||||
return test_as_TestSimpleTableWithEnum();
|
return test_as_TestSimpleTableWithEnum();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example::TestSimpleTableWithEnum *Monster::mutable_test_as<MyGame::Example::TestSimpleTableWithEnum>() {
|
||||||
|
return mutable_test_as_TestSimpleTableWithEnum();
|
||||||
|
}
|
||||||
|
|
||||||
template<> inline const MyGame::Example2::Monster *Monster::test_as<MyGame::Example2::Monster>() const {
|
template<> inline const MyGame::Example2::Monster *Monster::test_as<MyGame::Example2::Monster>() const {
|
||||||
return test_as_MyGame_Example2_Monster();
|
return test_as_MyGame_Example2_Monster();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example2::Monster *Monster::mutable_test_as<MyGame::Example2::Monster>() {
|
||||||
|
return mutable_test_as_MyGame_Example2_Monster();
|
||||||
|
}
|
||||||
|
|
||||||
template<> inline const MyGame::Example::Monster *Monster::any_unique_as<MyGame::Example::Monster>() const {
|
template<> inline const MyGame::Example::Monster *Monster::any_unique_as<MyGame::Example::Monster>() const {
|
||||||
return any_unique_as_M();
|
return any_unique_as_M();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example::Monster *Monster::mutable_any_unique_as<MyGame::Example::Monster>() {
|
||||||
|
return mutable_any_unique_as_M();
|
||||||
|
}
|
||||||
|
|
||||||
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() const {
|
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() const {
|
||||||
return any_unique_as_TS();
|
return any_unique_as_TS();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example::TestSimpleTableWithEnum *Monster::mutable_any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() {
|
||||||
|
return mutable_any_unique_as_TS();
|
||||||
|
}
|
||||||
|
|
||||||
template<> inline const MyGame::Example2::Monster *Monster::any_unique_as<MyGame::Example2::Monster>() const {
|
template<> inline const MyGame::Example2::Monster *Monster::any_unique_as<MyGame::Example2::Monster>() const {
|
||||||
return any_unique_as_M2();
|
return any_unique_as_M2();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example2::Monster *Monster::mutable_any_unique_as<MyGame::Example2::Monster>() {
|
||||||
|
return mutable_any_unique_as_M2();
|
||||||
|
}
|
||||||
|
|
||||||
struct MonsterBuilder {
|
struct MonsterBuilder {
|
||||||
typedef Monster Table;
|
typedef Monster Table;
|
||||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||||
|
|||||||
@@ -1488,6 +1488,16 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const MyGame::Example2::Monster *test_as_MyGame_Example2_Monster() const {
|
const MyGame::Example2::Monster *test_as_MyGame_Example2_Monster() const {
|
||||||
return test_type() == MyGame::Example::Any_MyGame_Example2_Monster ? static_cast<const MyGame::Example2::Monster *>(test()) : nullptr;
|
return test_type() == MyGame::Example::Any_MyGame_Example2_Monster ? static_cast<const MyGame::Example2::Monster *>(test()) : nullptr;
|
||||||
}
|
}
|
||||||
|
template<typename T> T *mutable_test_as();
|
||||||
|
MyGame::Example::Monster *mutable_test_as_Monster() {
|
||||||
|
return test_type() == MyGame::Example::Any_Monster ? static_cast<MyGame::Example::Monster *>(mutable_test()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example::TestSimpleTableWithEnum *mutable_test_as_TestSimpleTableWithEnum() {
|
||||||
|
return test_type() == MyGame::Example::Any_TestSimpleTableWithEnum ? static_cast<MyGame::Example::TestSimpleTableWithEnum *>(mutable_test()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example2::Monster *mutable_test_as_MyGame_Example2_Monster() {
|
||||||
|
return test_type() == MyGame::Example::Any_MyGame_Example2_Monster ? static_cast<MyGame::Example2::Monster *>(mutable_test()) : nullptr;
|
||||||
|
}
|
||||||
void *mutable_test() {
|
void *mutable_test() {
|
||||||
return GetPointer<void *>(VT_TEST);
|
return GetPointer<void *>(VT_TEST);
|
||||||
}
|
}
|
||||||
@@ -1723,6 +1733,16 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const MyGame::Example2::Monster *any_unique_as_M2() const {
|
const MyGame::Example2::Monster *any_unique_as_M2() const {
|
||||||
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M2 ? static_cast<const MyGame::Example2::Monster *>(any_unique()) : nullptr;
|
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M2 ? static_cast<const MyGame::Example2::Monster *>(any_unique()) : nullptr;
|
||||||
}
|
}
|
||||||
|
template<typename T> T *mutable_any_unique_as();
|
||||||
|
MyGame::Example::Monster *mutable_any_unique_as_M() {
|
||||||
|
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M ? static_cast<MyGame::Example::Monster *>(mutable_any_unique()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example::TestSimpleTableWithEnum *mutable_any_unique_as_TS() {
|
||||||
|
return any_unique_type() == MyGame::Example::AnyUniqueAliases_TS ? static_cast<MyGame::Example::TestSimpleTableWithEnum *>(mutable_any_unique()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example2::Monster *mutable_any_unique_as_M2() {
|
||||||
|
return any_unique_type() == MyGame::Example::AnyUniqueAliases_M2 ? static_cast<MyGame::Example2::Monster *>(mutable_any_unique()) : nullptr;
|
||||||
|
}
|
||||||
void *mutable_any_unique() {
|
void *mutable_any_unique() {
|
||||||
return GetPointer<void *>(VT_ANY_UNIQUE);
|
return GetPointer<void *>(VT_ANY_UNIQUE);
|
||||||
}
|
}
|
||||||
@@ -1741,6 +1761,15 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const MyGame::Example::Monster *any_ambiguous_as_M3() const {
|
const MyGame::Example::Monster *any_ambiguous_as_M3() const {
|
||||||
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M3 ? static_cast<const MyGame::Example::Monster *>(any_ambiguous()) : nullptr;
|
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M3 ? static_cast<const MyGame::Example::Monster *>(any_ambiguous()) : nullptr;
|
||||||
}
|
}
|
||||||
|
MyGame::Example::Monster *mutable_any_ambiguous_as_M1() {
|
||||||
|
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M1 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example::Monster *mutable_any_ambiguous_as_M2() {
|
||||||
|
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M2 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
|
||||||
|
}
|
||||||
|
MyGame::Example::Monster *mutable_any_ambiguous_as_M3() {
|
||||||
|
return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M3 ? static_cast<MyGame::Example::Monster *>(mutable_any_ambiguous()) : nullptr;
|
||||||
|
}
|
||||||
void *mutable_any_ambiguous() {
|
void *mutable_any_ambiguous() {
|
||||||
return GetPointer<void *>(VT_ANY_AMBIGUOUS);
|
return GetPointer<void *>(VT_ANY_AMBIGUOUS);
|
||||||
}
|
}
|
||||||
@@ -1950,26 +1979,50 @@ template<> inline const MyGame::Example::Monster *Monster::test_as<MyGame::Examp
|
|||||||
return test_as_Monster();
|
return test_as_Monster();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example::Monster *Monster::mutable_test_as<MyGame::Example::Monster>() {
|
||||||
|
return mutable_test_as_Monster();
|
||||||
|
}
|
||||||
|
|
||||||
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::test_as<MyGame::Example::TestSimpleTableWithEnum>() const {
|
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::test_as<MyGame::Example::TestSimpleTableWithEnum>() const {
|
||||||
return test_as_TestSimpleTableWithEnum();
|
return test_as_TestSimpleTableWithEnum();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example::TestSimpleTableWithEnum *Monster::mutable_test_as<MyGame::Example::TestSimpleTableWithEnum>() {
|
||||||
|
return mutable_test_as_TestSimpleTableWithEnum();
|
||||||
|
}
|
||||||
|
|
||||||
template<> inline const MyGame::Example2::Monster *Monster::test_as<MyGame::Example2::Monster>() const {
|
template<> inline const MyGame::Example2::Monster *Monster::test_as<MyGame::Example2::Monster>() const {
|
||||||
return test_as_MyGame_Example2_Monster();
|
return test_as_MyGame_Example2_Monster();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example2::Monster *Monster::mutable_test_as<MyGame::Example2::Monster>() {
|
||||||
|
return mutable_test_as_MyGame_Example2_Monster();
|
||||||
|
}
|
||||||
|
|
||||||
template<> inline const MyGame::Example::Monster *Monster::any_unique_as<MyGame::Example::Monster>() const {
|
template<> inline const MyGame::Example::Monster *Monster::any_unique_as<MyGame::Example::Monster>() const {
|
||||||
return any_unique_as_M();
|
return any_unique_as_M();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example::Monster *Monster::mutable_any_unique_as<MyGame::Example::Monster>() {
|
||||||
|
return mutable_any_unique_as_M();
|
||||||
|
}
|
||||||
|
|
||||||
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() const {
|
template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() const {
|
||||||
return any_unique_as_TS();
|
return any_unique_as_TS();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example::TestSimpleTableWithEnum *Monster::mutable_any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() {
|
||||||
|
return mutable_any_unique_as_TS();
|
||||||
|
}
|
||||||
|
|
||||||
template<> inline const MyGame::Example2::Monster *Monster::any_unique_as<MyGame::Example2::Monster>() const {
|
template<> inline const MyGame::Example2::Monster *Monster::any_unique_as<MyGame::Example2::Monster>() const {
|
||||||
return any_unique_as_M2();
|
return any_unique_as_M2();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline MyGame::Example2::Monster *Monster::mutable_any_unique_as<MyGame::Example2::Monster>() {
|
||||||
|
return mutable_any_unique_as_M2();
|
||||||
|
}
|
||||||
|
|
||||||
struct MonsterBuilder {
|
struct MonsterBuilder {
|
||||||
typedef Monster Table;
|
typedef Monster Table;
|
||||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||||
|
|||||||
@@ -117,6 +117,10 @@ struct TableInFirstNS FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const NamespaceA::NamespaceB::TableInNestedNS *foo_union_as_TableInNestedNS() const {
|
const NamespaceA::NamespaceB::TableInNestedNS *foo_union_as_TableInNestedNS() const {
|
||||||
return foo_union_type() == NamespaceA::NamespaceB::UnionInNestedNS_TableInNestedNS ? static_cast<const NamespaceA::NamespaceB::TableInNestedNS *>(foo_union()) : nullptr;
|
return foo_union_type() == NamespaceA::NamespaceB::UnionInNestedNS_TableInNestedNS ? static_cast<const NamespaceA::NamespaceB::TableInNestedNS *>(foo_union()) : nullptr;
|
||||||
}
|
}
|
||||||
|
template<typename T> T *mutable_foo_union_as();
|
||||||
|
NamespaceA::NamespaceB::TableInNestedNS *mutable_foo_union_as_TableInNestedNS() {
|
||||||
|
return foo_union_type() == NamespaceA::NamespaceB::UnionInNestedNS_TableInNestedNS ? static_cast<NamespaceA::NamespaceB::TableInNestedNS *>(mutable_foo_union()) : nullptr;
|
||||||
|
}
|
||||||
void *mutable_foo_union() {
|
void *mutable_foo_union() {
|
||||||
return GetPointer<void *>(VT_FOO_UNION);
|
return GetPointer<void *>(VT_FOO_UNION);
|
||||||
}
|
}
|
||||||
@@ -147,6 +151,10 @@ template<> inline const NamespaceA::NamespaceB::TableInNestedNS *TableInFirstNS:
|
|||||||
return foo_union_as_TableInNestedNS();
|
return foo_union_as_TableInNestedNS();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline NamespaceA::NamespaceB::TableInNestedNS *TableInFirstNS::mutable_foo_union_as<NamespaceA::NamespaceB::TableInNestedNS>() {
|
||||||
|
return mutable_foo_union_as_TableInNestedNS();
|
||||||
|
}
|
||||||
|
|
||||||
struct TableInFirstNSBuilder {
|
struct TableInFirstNSBuilder {
|
||||||
typedef TableInFirstNS Table;
|
typedef TableInFirstNS Table;
|
||||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||||
|
|||||||
@@ -31,14 +31,6 @@ struct ApplicationDataT;
|
|||||||
bool operator==(const ApplicationDataT &lhs, const ApplicationDataT &rhs);
|
bool operator==(const ApplicationDataT &lhs, const ApplicationDataT &rhs);
|
||||||
bool operator!=(const ApplicationDataT &lhs, const ApplicationDataT &rhs);
|
bool operator!=(const ApplicationDataT &lhs, const ApplicationDataT &rhs);
|
||||||
|
|
||||||
inline const ::flatbuffers::TypeTable *Vector3DTypeTable();
|
|
||||||
|
|
||||||
inline const ::flatbuffers::TypeTable *Vector3DAltTypeTable();
|
|
||||||
|
|
||||||
inline const ::flatbuffers::TypeTable *MatrixTypeTable();
|
|
||||||
|
|
||||||
inline const ::flatbuffers::TypeTable *ApplicationDataTypeTable();
|
|
||||||
|
|
||||||
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Vector3D FLATBUFFERS_FINAL_CLASS {
|
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Vector3D FLATBUFFERS_FINAL_CLASS {
|
||||||
private:
|
private:
|
||||||
float x_;
|
float x_;
|
||||||
@@ -46,9 +38,7 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Vector3D FLATBUFFERS_FINAL_CLASS {
|
|||||||
float z_;
|
float z_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
struct Traits;
|
||||||
return Vector3DTypeTable();
|
|
||||||
}
|
|
||||||
Vector3D()
|
Vector3D()
|
||||||
: x_(0),
|
: x_(0),
|
||||||
y_(0),
|
y_(0),
|
||||||
@@ -62,24 +52,19 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Vector3D FLATBUFFERS_FINAL_CLASS {
|
|||||||
float x() const {
|
float x() const {
|
||||||
return ::flatbuffers::EndianScalar(x_);
|
return ::flatbuffers::EndianScalar(x_);
|
||||||
}
|
}
|
||||||
void mutate_x(float _x) {
|
|
||||||
::flatbuffers::WriteScalar(&x_, _x);
|
|
||||||
}
|
|
||||||
float y() const {
|
float y() const {
|
||||||
return ::flatbuffers::EndianScalar(y_);
|
return ::flatbuffers::EndianScalar(y_);
|
||||||
}
|
}
|
||||||
void mutate_y(float _y) {
|
|
||||||
::flatbuffers::WriteScalar(&y_, _y);
|
|
||||||
}
|
|
||||||
float z() const {
|
float z() const {
|
||||||
return ::flatbuffers::EndianScalar(z_);
|
return ::flatbuffers::EndianScalar(z_);
|
||||||
}
|
}
|
||||||
void mutate_z(float _z) {
|
|
||||||
::flatbuffers::WriteScalar(&z_, _z);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
FLATBUFFERS_STRUCT_END(Vector3D, 12);
|
FLATBUFFERS_STRUCT_END(Vector3D, 12);
|
||||||
|
|
||||||
|
struct Vector3D::Traits {
|
||||||
|
using type = Vector3D;
|
||||||
|
};
|
||||||
|
|
||||||
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Vector3DAlt FLATBUFFERS_FINAL_CLASS {
|
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Vector3DAlt FLATBUFFERS_FINAL_CLASS {
|
||||||
private:
|
private:
|
||||||
float a_;
|
float a_;
|
||||||
@@ -87,9 +72,7 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Vector3DAlt FLATBUFFERS_FINAL_CLASS {
|
|||||||
float c_;
|
float c_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
struct Traits;
|
||||||
return Vector3DAltTypeTable();
|
|
||||||
}
|
|
||||||
Vector3DAlt()
|
Vector3DAlt()
|
||||||
: a_(0),
|
: a_(0),
|
||||||
b_(0),
|
b_(0),
|
||||||
@@ -103,30 +86,23 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Vector3DAlt FLATBUFFERS_FINAL_CLASS {
|
|||||||
float a() const {
|
float a() const {
|
||||||
return ::flatbuffers::EndianScalar(a_);
|
return ::flatbuffers::EndianScalar(a_);
|
||||||
}
|
}
|
||||||
void mutate_a(float _a) {
|
|
||||||
::flatbuffers::WriteScalar(&a_, _a);
|
|
||||||
}
|
|
||||||
float b() const {
|
float b() const {
|
||||||
return ::flatbuffers::EndianScalar(b_);
|
return ::flatbuffers::EndianScalar(b_);
|
||||||
}
|
}
|
||||||
void mutate_b(float _b) {
|
|
||||||
::flatbuffers::WriteScalar(&b_, _b);
|
|
||||||
}
|
|
||||||
float c() const {
|
float c() const {
|
||||||
return ::flatbuffers::EndianScalar(c_);
|
return ::flatbuffers::EndianScalar(c_);
|
||||||
}
|
}
|
||||||
void mutate_c(float _c) {
|
|
||||||
::flatbuffers::WriteScalar(&c_, _c);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
FLATBUFFERS_STRUCT_END(Vector3DAlt, 12);
|
FLATBUFFERS_STRUCT_END(Vector3DAlt, 12);
|
||||||
|
|
||||||
|
struct Vector3DAlt::Traits {
|
||||||
|
using type = Vector3DAlt;
|
||||||
|
};
|
||||||
|
|
||||||
struct Matrix FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
struct Matrix FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||||
typedef Native::Matrix NativeTableType;
|
typedef Native::Matrix NativeTableType;
|
||||||
typedef MatrixBuilder Builder;
|
typedef MatrixBuilder Builder;
|
||||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
struct Traits;
|
||||||
return MatrixTypeTable();
|
|
||||||
}
|
|
||||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||||
VT_ROWS = 4,
|
VT_ROWS = 4,
|
||||||
VT_COLUMNS = 6,
|
VT_COLUMNS = 6,
|
||||||
@@ -135,21 +111,12 @@ struct Matrix FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
int32_t rows() const {
|
int32_t rows() const {
|
||||||
return GetField<int32_t>(VT_ROWS, 0);
|
return GetField<int32_t>(VT_ROWS, 0);
|
||||||
}
|
}
|
||||||
bool mutate_rows(int32_t _rows = 0) {
|
|
||||||
return SetField<int32_t>(VT_ROWS, _rows, 0);
|
|
||||||
}
|
|
||||||
int32_t columns() const {
|
int32_t columns() const {
|
||||||
return GetField<int32_t>(VT_COLUMNS, 0);
|
return GetField<int32_t>(VT_COLUMNS, 0);
|
||||||
}
|
}
|
||||||
bool mutate_columns(int32_t _columns = 0) {
|
|
||||||
return SetField<int32_t>(VT_COLUMNS, _columns, 0);
|
|
||||||
}
|
|
||||||
const ::flatbuffers::Vector<float> *values() const {
|
const ::flatbuffers::Vector<float> *values() const {
|
||||||
return GetPointer<const ::flatbuffers::Vector<float> *>(VT_VALUES);
|
return GetPointer<const ::flatbuffers::Vector<float> *>(VT_VALUES);
|
||||||
}
|
}
|
||||||
::flatbuffers::Vector<float> *mutable_values() {
|
|
||||||
return GetPointer<::flatbuffers::Vector<float> *>(VT_VALUES);
|
|
||||||
}
|
|
||||||
template <bool B = false>
|
template <bool B = false>
|
||||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
return VerifyTableStart(verifier) &&
|
return VerifyTableStart(verifier) &&
|
||||||
@@ -200,6 +167,11 @@ inline ::flatbuffers::Offset<Matrix> CreateMatrix(
|
|||||||
return builder_.Finish();
|
return builder_.Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Matrix::Traits {
|
||||||
|
using type = Matrix;
|
||||||
|
static auto constexpr Create = CreateMatrix;
|
||||||
|
};
|
||||||
|
|
||||||
inline ::flatbuffers::Offset<Matrix> CreateMatrixDirect(
|
inline ::flatbuffers::Offset<Matrix> CreateMatrixDirect(
|
||||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
int32_t rows = 0,
|
int32_t rows = 0,
|
||||||
@@ -232,9 +204,7 @@ struct ApplicationDataT : public ::flatbuffers::NativeTable {
|
|||||||
struct ApplicationData FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
struct ApplicationData FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||||
typedef ApplicationDataT NativeTableType;
|
typedef ApplicationDataT NativeTableType;
|
||||||
typedef ApplicationDataBuilder Builder;
|
typedef ApplicationDataBuilder Builder;
|
||||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
struct Traits;
|
||||||
return ApplicationDataTypeTable();
|
|
||||||
}
|
|
||||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||||
VT_VECTORS = 4,
|
VT_VECTORS = 4,
|
||||||
VT_VECTORS_ALT = 6,
|
VT_VECTORS_ALT = 6,
|
||||||
@@ -246,39 +216,21 @@ struct ApplicationData FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const ::flatbuffers::Vector<const Geometry::Vector3D *> *vectors() const {
|
const ::flatbuffers::Vector<const Geometry::Vector3D *> *vectors() const {
|
||||||
return GetPointer<const ::flatbuffers::Vector<const Geometry::Vector3D *> *>(VT_VECTORS);
|
return GetPointer<const ::flatbuffers::Vector<const Geometry::Vector3D *> *>(VT_VECTORS);
|
||||||
}
|
}
|
||||||
::flatbuffers::Vector<const Geometry::Vector3D *> *mutable_vectors() {
|
|
||||||
return GetPointer<::flatbuffers::Vector<const Geometry::Vector3D *> *>(VT_VECTORS);
|
|
||||||
}
|
|
||||||
const ::flatbuffers::Vector<const Geometry::Vector3DAlt *> *vectors_alt() const {
|
const ::flatbuffers::Vector<const Geometry::Vector3DAlt *> *vectors_alt() const {
|
||||||
return GetPointer<const ::flatbuffers::Vector<const Geometry::Vector3DAlt *> *>(VT_VECTORS_ALT);
|
return GetPointer<const ::flatbuffers::Vector<const Geometry::Vector3DAlt *> *>(VT_VECTORS_ALT);
|
||||||
}
|
}
|
||||||
::flatbuffers::Vector<const Geometry::Vector3DAlt *> *mutable_vectors_alt() {
|
|
||||||
return GetPointer<::flatbuffers::Vector<const Geometry::Vector3DAlt *> *>(VT_VECTORS_ALT);
|
|
||||||
}
|
|
||||||
const Geometry::Vector3D *position() const {
|
const Geometry::Vector3D *position() const {
|
||||||
return GetStruct<const Geometry::Vector3D *>(VT_POSITION);
|
return GetStruct<const Geometry::Vector3D *>(VT_POSITION);
|
||||||
}
|
}
|
||||||
Geometry::Vector3D *mutable_position() {
|
|
||||||
return GetStruct<Geometry::Vector3D *>(VT_POSITION);
|
|
||||||
}
|
|
||||||
const Geometry::Vector3D *position_inline() const {
|
const Geometry::Vector3D *position_inline() const {
|
||||||
return GetStruct<const Geometry::Vector3D *>(VT_POSITION_INLINE);
|
return GetStruct<const Geometry::Vector3D *>(VT_POSITION_INLINE);
|
||||||
}
|
}
|
||||||
Geometry::Vector3D *mutable_position_inline() {
|
|
||||||
return GetStruct<Geometry::Vector3D *>(VT_POSITION_INLINE);
|
|
||||||
}
|
|
||||||
const Geometry::Matrix *matrix() const {
|
const Geometry::Matrix *matrix() const {
|
||||||
return GetPointer<const Geometry::Matrix *>(VT_MATRIX);
|
return GetPointer<const Geometry::Matrix *>(VT_MATRIX);
|
||||||
}
|
}
|
||||||
Geometry::Matrix *mutable_matrix() {
|
|
||||||
return GetPointer<Geometry::Matrix *>(VT_MATRIX);
|
|
||||||
}
|
|
||||||
const ::flatbuffers::Vector<::flatbuffers::Offset<Geometry::Matrix>> *matrices() const {
|
const ::flatbuffers::Vector<::flatbuffers::Offset<Geometry::Matrix>> *matrices() const {
|
||||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<Geometry::Matrix>> *>(VT_MATRICES);
|
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<Geometry::Matrix>> *>(VT_MATRICES);
|
||||||
}
|
}
|
||||||
::flatbuffers::Vector<::flatbuffers::Offset<Geometry::Matrix>> *mutable_matrices() {
|
|
||||||
return GetPointer<::flatbuffers::Vector<::flatbuffers::Offset<Geometry::Matrix>> *>(VT_MATRICES);
|
|
||||||
}
|
|
||||||
template <bool B = false>
|
template <bool B = false>
|
||||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
return VerifyTableStart(verifier) &&
|
return VerifyTableStart(verifier) &&
|
||||||
@@ -351,6 +303,11 @@ inline ::flatbuffers::Offset<ApplicationData> CreateApplicationData(
|
|||||||
return builder_.Finish();
|
return builder_.Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ApplicationData::Traits {
|
||||||
|
using type = ApplicationData;
|
||||||
|
static auto constexpr Create = CreateApplicationData;
|
||||||
|
};
|
||||||
|
|
||||||
inline ::flatbuffers::Offset<ApplicationData> CreateApplicationDataDirect(
|
inline ::flatbuffers::Offset<ApplicationData> CreateApplicationDataDirect(
|
||||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
const std::vector<Geometry::Vector3D> *vectors = nullptr,
|
const std::vector<Geometry::Vector3D> *vectors = nullptr,
|
||||||
@@ -375,7 +332,7 @@ inline ::flatbuffers::Offset<ApplicationData> CreateApplicationDataDirect(
|
|||||||
::flatbuffers::Offset<ApplicationData> CreateApplicationData(::flatbuffers::FlatBufferBuilder &_fbb, const ApplicationDataT *_o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
::flatbuffers::Offset<ApplicationData> CreateApplicationData(::flatbuffers::FlatBufferBuilder &_fbb, const ApplicationDataT *_o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||||
|
|
||||||
inline Native::Matrix *Matrix::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
inline Native::Matrix *Matrix::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||||
auto _o = std::unique_ptr<Native::Matrix>(new Native::Matrix());
|
auto _o = std::make_unique<Native::Matrix>();
|
||||||
UnPackTo(_o.get(), _resolver);
|
UnPackTo(_o.get(), _resolver);
|
||||||
return _o.release();
|
return _o.release();
|
||||||
}
|
}
|
||||||
@@ -421,7 +378,7 @@ inline ApplicationDataT &ApplicationDataT::operator=(ApplicationDataT o) FLATBUF
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline ApplicationDataT *ApplicationData::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
inline ApplicationDataT *ApplicationData::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||||
auto _o = std::unique_ptr<ApplicationDataT>(new ApplicationDataT());
|
auto _o = std::make_unique<ApplicationDataT>();
|
||||||
UnPackTo(_o.get(), _resolver);
|
UnPackTo(_o.get(), _resolver);
|
||||||
return _o.release();
|
return _o.release();
|
||||||
}
|
}
|
||||||
@@ -461,87 +418,6 @@ inline ::flatbuffers::Offset<ApplicationData> ApplicationData::Pack(::flatbuffer
|
|||||||
_matrices);
|
_matrices);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const ::flatbuffers::TypeTable *Vector3DTypeTable() {
|
|
||||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
|
||||||
{ ::flatbuffers::ET_FLOAT, 0, -1 },
|
|
||||||
{ ::flatbuffers::ET_FLOAT, 0, -1 },
|
|
||||||
{ ::flatbuffers::ET_FLOAT, 0, -1 }
|
|
||||||
};
|
|
||||||
static const int64_t values[] = { 0, 4, 8, 12 };
|
|
||||||
static const char * const names[] = {
|
|
||||||
"x",
|
|
||||||
"y",
|
|
||||||
"z"
|
|
||||||
};
|
|
||||||
static const ::flatbuffers::TypeTable tt = {
|
|
||||||
::flatbuffers::ST_STRUCT, 3, type_codes, nullptr, nullptr, values, names
|
|
||||||
};
|
|
||||||
return &tt;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const ::flatbuffers::TypeTable *Vector3DAltTypeTable() {
|
|
||||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
|
||||||
{ ::flatbuffers::ET_FLOAT, 0, -1 },
|
|
||||||
{ ::flatbuffers::ET_FLOAT, 0, -1 },
|
|
||||||
{ ::flatbuffers::ET_FLOAT, 0, -1 }
|
|
||||||
};
|
|
||||||
static const int64_t values[] = { 0, 4, 8, 12 };
|
|
||||||
static const char * const names[] = {
|
|
||||||
"a",
|
|
||||||
"b",
|
|
||||||
"c"
|
|
||||||
};
|
|
||||||
static const ::flatbuffers::TypeTable tt = {
|
|
||||||
::flatbuffers::ST_STRUCT, 3, type_codes, nullptr, nullptr, values, names
|
|
||||||
};
|
|
||||||
return &tt;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const ::flatbuffers::TypeTable *MatrixTypeTable() {
|
|
||||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
|
||||||
{ ::flatbuffers::ET_INT, 0, -1 },
|
|
||||||
{ ::flatbuffers::ET_INT, 0, -1 },
|
|
||||||
{ ::flatbuffers::ET_FLOAT, 1, -1 }
|
|
||||||
};
|
|
||||||
static const char * const names[] = {
|
|
||||||
"rows",
|
|
||||||
"columns",
|
|
||||||
"values"
|
|
||||||
};
|
|
||||||
static const ::flatbuffers::TypeTable tt = {
|
|
||||||
::flatbuffers::ST_TABLE, 3, type_codes, nullptr, nullptr, nullptr, names
|
|
||||||
};
|
|
||||||
return &tt;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const ::flatbuffers::TypeTable *ApplicationDataTypeTable() {
|
|
||||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
|
||||||
{ ::flatbuffers::ET_SEQUENCE, 1, 0 },
|
|
||||||
{ ::flatbuffers::ET_SEQUENCE, 1, 1 },
|
|
||||||
{ ::flatbuffers::ET_SEQUENCE, 0, 0 },
|
|
||||||
{ ::flatbuffers::ET_SEQUENCE, 0, 0 },
|
|
||||||
{ ::flatbuffers::ET_SEQUENCE, 0, 2 },
|
|
||||||
{ ::flatbuffers::ET_SEQUENCE, 1, 2 }
|
|
||||||
};
|
|
||||||
static const ::flatbuffers::TypeFunction type_refs[] = {
|
|
||||||
Geometry::Vector3DTypeTable,
|
|
||||||
Geometry::Vector3DAltTypeTable,
|
|
||||||
Geometry::MatrixTypeTable
|
|
||||||
};
|
|
||||||
static const char * const names[] = {
|
|
||||||
"vectors",
|
|
||||||
"vectors_alt",
|
|
||||||
"position",
|
|
||||||
"position_inline",
|
|
||||||
"matrix",
|
|
||||||
"matrices"
|
|
||||||
};
|
|
||||||
static const ::flatbuffers::TypeTable tt = {
|
|
||||||
::flatbuffers::ST_TABLE, 6, type_codes, type_refs, nullptr, nullptr, names
|
|
||||||
};
|
|
||||||
return &tt;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const Geometry::ApplicationData *GetApplicationData(const void *buf) {
|
inline const Geometry::ApplicationData *GetApplicationData(const void *buf) {
|
||||||
return ::flatbuffers::GetRoot<Geometry::ApplicationData>(buf);
|
return ::flatbuffers::GetRoot<Geometry::ApplicationData>(buf);
|
||||||
}
|
}
|
||||||
@@ -550,14 +426,6 @@ inline const Geometry::ApplicationData *GetSizePrefixedApplicationData(const voi
|
|||||||
return ::flatbuffers::GetSizePrefixedRoot<Geometry::ApplicationData>(buf);
|
return ::flatbuffers::GetSizePrefixedRoot<Geometry::ApplicationData>(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ApplicationData *GetMutableApplicationData(void *buf) {
|
|
||||||
return ::flatbuffers::GetMutableRoot<ApplicationData>(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Geometry::ApplicationData *GetMutableSizePrefixedApplicationData(void *buf) {
|
|
||||||
return ::flatbuffers::GetMutableSizePrefixedRoot<Geometry::ApplicationData>(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <bool B = false>
|
template <bool B = false>
|
||||||
inline bool VerifyApplicationDataBuffer(
|
inline bool VerifyApplicationDataBuffer(
|
||||||
::flatbuffers::VerifierTemplate<B> &verifier) {
|
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||||
@@ -570,6 +438,10 @@ inline bool VerifySizePrefixedApplicationDataBuffer(
|
|||||||
return verifier.template VerifySizePrefixedBuffer<Geometry::ApplicationData>(nullptr);
|
return verifier.template VerifySizePrefixedBuffer<Geometry::ApplicationData>(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline const char *ApplicationDataExtension() {
|
||||||
|
return "bfbs";
|
||||||
|
}
|
||||||
|
|
||||||
inline void FinishApplicationDataBuffer(
|
inline void FinishApplicationDataBuffer(
|
||||||
::flatbuffers::FlatBufferBuilder &fbb,
|
::flatbuffers::FlatBufferBuilder &fbb,
|
||||||
::flatbuffers::Offset<Geometry::ApplicationData> root) {
|
::flatbuffers::Offset<Geometry::ApplicationData> root) {
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ struct Matrix {
|
|||||||
(values == other.values);
|
(values == other.values);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Native
|
} // namespace Native
|
||||||
|
|
||||||
namespace Geometry {
|
namespace Geometry {
|
||||||
|
|||||||
@@ -97,6 +97,17 @@ void ErrorTest() {
|
|||||||
"datatype already");
|
"datatype already");
|
||||||
TestError("struct X (force_align: 7) { Y:int; }", "force_align");
|
TestError("struct X (force_align: 7) { Y:int; }", "force_align");
|
||||||
TestError("struct X {}", "size 0");
|
TestError("struct X {}", "size 0");
|
||||||
|
TestError(
|
||||||
|
"struct X { Y:int; } table T { y:X (bigfoot_ref:\"::Foo::Bar\"); "
|
||||||
|
"}",
|
||||||
|
"'bigfoot_ref_wrapper' attribute");
|
||||||
|
TestError(
|
||||||
|
"table T { y:int (bigfoot_ref:\"::Foo::Bar\"); }",
|
||||||
|
"struct-typed fields");
|
||||||
|
TestError(
|
||||||
|
"struct X (bigfoot_ref_wrapper: \"Foo\") { Y:int; } "
|
||||||
|
"table T { y:X (bigfoot_ref:\"\"); }",
|
||||||
|
"cannot be empty");
|
||||||
TestError("{}", "no root");
|
TestError("{}", "no root");
|
||||||
TestError("table X { Y:byte; } root_type X; { Y:1 } { Y:1 }", "end of file");
|
TestError("table X { Y:byte; } root_type X; { Y:1 } { Y:1 }", "end of file");
|
||||||
TestError("table X { Y:byte; } root_type X; { Y:1 } table Y{ Z:int }",
|
TestError("table X { Y:byte; } root_type X; { Y:1 } table Y{ Z:int }",
|
||||||
|
|||||||
+6
-15
@@ -2200,27 +2200,18 @@ def make_monster_from_generated_code(
|
|||||||
test2 = b.CreateString('test2')
|
test2 = b.CreateString('test2')
|
||||||
fred = b.CreateString('Fred')
|
fred = b.CreateString('Fred')
|
||||||
|
|
||||||
_MONSTER.MonsterStartInventoryVector(b, 5)
|
inv = _MONSTER.MonsterCreateInventoryVector(b, range(5))
|
||||||
b.PrependByte(4)
|
|
||||||
b.PrependByte(3)
|
|
||||||
b.PrependByte(2)
|
|
||||||
b.PrependByte(1)
|
|
||||||
b.PrependByte(0)
|
|
||||||
inv = b.EndVector()
|
|
||||||
|
|
||||||
_MONSTER.MonsterStart(b)
|
_MONSTER.MonsterStart(b)
|
||||||
_MONSTER.MonsterAddName(b, fred)
|
_MONSTER.MonsterAddName(b, fred)
|
||||||
mon2 = _MONSTER.MonsterEnd(b)
|
mon2 = _MONSTER.MonsterEnd(b)
|
||||||
|
|
||||||
_MONSTER.MonsterStartTest4Vector(b, 2)
|
test4_structs = (_TEST.TestT(10, 20), _TEST.TestT(30, 40))
|
||||||
_TEST.CreateTest(b, 10, 20)
|
test4 = _MONSTER.MonsterCreateTest4Vector(b, test4_structs)
|
||||||
_TEST.CreateTest(b, 30, 40)
|
|
||||||
test4 = b.EndVector()
|
|
||||||
|
|
||||||
_MONSTER.MonsterStartTestarrayofstringVector(b, 2)
|
testArrayOfString = _MONSTER.MonsterCreateTestarrayofstringVector(
|
||||||
b.PrependUOffsetTRelative(test2)
|
b, [test1, test2]
|
||||||
b.PrependUOffsetTRelative(test1)
|
)
|
||||||
testArrayOfString = b.EndVector()
|
|
||||||
|
|
||||||
_MONSTER.MonsterStartVectorOfLongsVector(b, 5)
|
_MONSTER.MonsterStartVectorOfLongsVector(b, 5)
|
||||||
b.PrependInt64(100000000)
|
b.PrependInt64(100000000)
|
||||||
|
|||||||
@@ -30,14 +30,6 @@ static A: TrackingAllocator = TrackingAllocator;
|
|||||||
// import the flatbuffers generated code:
|
// import the flatbuffers generated code:
|
||||||
extern crate flatbuffers;
|
extern crate flatbuffers;
|
||||||
|
|
||||||
#[allow(dead_code, unused_imports, clippy::all)]
|
|
||||||
#[path = "../../include_test1/mod.rs"]
|
|
||||||
pub mod include_test1_generated;
|
|
||||||
|
|
||||||
#[allow(dead_code, unused_imports, clippy::all)]
|
|
||||||
#[path = "../../include_test2/mod.rs"]
|
|
||||||
pub mod include_test2_generated;
|
|
||||||
|
|
||||||
#[allow(dead_code, unused_imports, clippy::all)]
|
#[allow(dead_code, unused_imports, clippy::all)]
|
||||||
#[path = "../../monster_test/mod.rs"]
|
#[path = "../../monster_test/mod.rs"]
|
||||||
mod monster_test_generated;
|
mod monster_test_generated;
|
||||||
|
|||||||
@@ -1,14 +1,6 @@
|
|||||||
#![allow(clippy::derivable_impls, clippy::all)]
|
#![allow(clippy::derivable_impls, clippy::all)]
|
||||||
extern crate flatbuffers;
|
extern crate flatbuffers;
|
||||||
|
|
||||||
#[allow(dead_code, unused_imports)]
|
|
||||||
#[path = "../../include_test1/mod.rs"]
|
|
||||||
pub mod include_test1_generated;
|
|
||||||
|
|
||||||
#[allow(dead_code, unused_imports)]
|
|
||||||
#[path = "../../include_test2/mod.rs"]
|
|
||||||
pub mod include_test2_generated;
|
|
||||||
|
|
||||||
#[allow(dead_code, unused_imports, clippy::approx_constant)]
|
#[allow(dead_code, unused_imports, clippy::approx_constant)]
|
||||||
#[path = "../../monster_test/mod.rs"]
|
#[path = "../../monster_test/mod.rs"]
|
||||||
mod monster_test_generated;
|
mod monster_test_generated;
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#[allow(dead_code, unused_imports, clippy::all)]
|
||||||
|
#[path = "../../include_test1/mod.rs"]
|
||||||
|
mod include_test1_generated;
|
||||||
|
|
||||||
|
#[allow(dead_code, unused_imports, clippy::all)]
|
||||||
|
#[path = "../../include_test2/mod.rs"]
|
||||||
|
mod include_test2_generated;
|
||||||
|
|
||||||
|
#[allow(dead_code, unused_imports, clippy::all)]
|
||||||
|
#[path = "../../include_test1_generated.rs"]
|
||||||
|
mod include_test1_standalone;
|
||||||
|
|
||||||
|
#[allow(dead_code, unused_imports, clippy::all)]
|
||||||
|
#[path = "../../include_test2_generated.rs"]
|
||||||
|
mod include_test2_standalone;
|
||||||
@@ -48,14 +48,6 @@ mod flexbuffers_tests;
|
|||||||
mod more_defaults_test;
|
mod more_defaults_test;
|
||||||
mod optional_scalars_test;
|
mod optional_scalars_test;
|
||||||
|
|
||||||
#[allow(dead_code, unused_imports, clippy::all)]
|
|
||||||
#[path = "../../include_test1/mod.rs"]
|
|
||||||
pub mod include_test1_generated;
|
|
||||||
|
|
||||||
#[allow(dead_code, unused_imports, clippy::all)]
|
|
||||||
#[path = "../../include_test2/mod.rs"]
|
|
||||||
pub mod include_test2_generated;
|
|
||||||
|
|
||||||
#[allow(dead_code, unused_imports, clippy::all)]
|
#[allow(dead_code, unused_imports, clippy::all)]
|
||||||
#[path = "../../namespace_test/mod.rs"]
|
#[path = "../../namespace_test/mod.rs"]
|
||||||
pub mod namespace_test_generated;
|
pub mod namespace_test_generated;
|
||||||
|
|||||||
@@ -0,0 +1,164 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2024 Google Inc. All rights reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! Regression test for https://github.com/google/flatbuffers/issues/8894
|
||||||
|
//!
|
||||||
|
//! Tests that vtable memory is properly zeroed when building FlatBuffers.
|
||||||
|
|
||||||
|
extern crate alloc;
|
||||||
|
extern crate flatbuffers;
|
||||||
|
|
||||||
|
use alloc::vec;
|
||||||
|
use alloc::vec::Vec;
|
||||||
|
use core::convert::Infallible;
|
||||||
|
use core::cmp::max;
|
||||||
|
use core::ops::{Deref, DerefMut};
|
||||||
|
use core::ptr::write_bytes;
|
||||||
|
|
||||||
|
use flatbuffers::{Allocator, FlatBufferBuilder};
|
||||||
|
|
||||||
|
/// Custom allocator that pre-fills buffer with garbage (0xAA) to detect
|
||||||
|
/// uninitialized memory bugs.
|
||||||
|
struct GarbageFilledAllocator(Vec<u8>);
|
||||||
|
|
||||||
|
impl GarbageFilledAllocator {
|
||||||
|
fn new(size: usize) -> Self {
|
||||||
|
Self(vec![0xAA; size])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Deref for GarbageFilledAllocator {
|
||||||
|
type Target = [u8];
|
||||||
|
fn deref(&self) -> &Self::Target {
|
||||||
|
&self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DerefMut for GarbageFilledAllocator {
|
||||||
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
|
&mut self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SAFETY: grow_downwards properly moves data and the new space is filled with garbage
|
||||||
|
// (intentionally, to detect bugs where code assumes zeroed memory)
|
||||||
|
unsafe impl Allocator for GarbageFilledAllocator {
|
||||||
|
type Error = Infallible;
|
||||||
|
|
||||||
|
fn grow_downwards(&mut self) -> Result<(), Self::Error> {
|
||||||
|
let old_len = self.0.len();
|
||||||
|
let new_len = max(1, old_len * 2);
|
||||||
|
|
||||||
|
// Resize and fill new space with garbage
|
||||||
|
self.0.resize(new_len, 0xAA);
|
||||||
|
|
||||||
|
if new_len == 1 {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move old data to the end
|
||||||
|
let middle = new_len / 2;
|
||||||
|
{
|
||||||
|
let (left, right) = &mut self.0[..].split_at_mut(middle);
|
||||||
|
right.copy_from_slice(left);
|
||||||
|
}
|
||||||
|
// Fill old space with garbage (NOT zeros)
|
||||||
|
{
|
||||||
|
let ptr = self.0[..middle].as_mut_ptr();
|
||||||
|
unsafe {
|
||||||
|
write_bytes(ptr, 0xAA, middle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn len(&self) -> usize {
|
||||||
|
self.0.len()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Regression test for https://github.com/google/flatbuffers/issues/8894
|
||||||
|
///
|
||||||
|
/// The bug: write_vtable() called make_space() which only reserves memory
|
||||||
|
/// but doesn't zero it. If the allocator's buffer contains garbage data,
|
||||||
|
/// vtable entries for fields with default values would contain garbage
|
||||||
|
/// instead of zero (which indicates "use default").
|
||||||
|
///
|
||||||
|
/// This test uses a garbage-filled allocator to detect if vtable memory
|
||||||
|
/// is properly zeroed before being written.
|
||||||
|
#[test]
|
||||||
|
fn test_vtable_zeroed_with_garbage_allocator() {
|
||||||
|
// Create a builder with garbage-filled allocator
|
||||||
|
let allocator = GarbageFilledAllocator::new(256);
|
||||||
|
let mut builder: FlatBufferBuilder<GarbageFilledAllocator> =
|
||||||
|
FlatBufferBuilder::new_in(allocator);
|
||||||
|
|
||||||
|
// Start a table
|
||||||
|
let table_start = builder.start_table();
|
||||||
|
|
||||||
|
// Set a field at a HIGH slot ID (14) to force a larger vtable.
|
||||||
|
// This leaves slots 4, 6, 8, 10, 12 unset (should be zero).
|
||||||
|
// VTable layout: [vtable_size:2][table_size:2][field0:2][field1:2][field2:2][field3:2][field4:2][field5:2]
|
||||||
|
// Offsets: 0 2 4 6 8 10 12 14
|
||||||
|
builder.push_slot::<u32>(14, 42, 0); // Set field 5 (at vtable offset 14) to 42
|
||||||
|
|
||||||
|
// End the table - this calls write_vtable()
|
||||||
|
let table_end = builder.end_table(table_start);
|
||||||
|
|
||||||
|
// Finish the buffer
|
||||||
|
builder.finish(table_end, None);
|
||||||
|
|
||||||
|
let data = builder.finished_data();
|
||||||
|
|
||||||
|
// Read the root table offset (first 4 bytes, little-endian)
|
||||||
|
let root_offset = u32::from_le_bytes([data[0], data[1], data[2], data[3]]) as usize;
|
||||||
|
let table_pos = root_offset;
|
||||||
|
|
||||||
|
// Read the vtable offset (signed, at table position)
|
||||||
|
let vtable_offset = i32::from_le_bytes([
|
||||||
|
data[table_pos],
|
||||||
|
data[table_pos + 1],
|
||||||
|
data[table_pos + 2],
|
||||||
|
data[table_pos + 3],
|
||||||
|
]);
|
||||||
|
let vtable_pos = (table_pos as i32 - vtable_offset) as usize;
|
||||||
|
|
||||||
|
// Read vtable size (first 2 bytes of vtable)
|
||||||
|
let vtable_size = u16::from_le_bytes([data[vtable_pos], data[vtable_pos + 1]]) as usize;
|
||||||
|
|
||||||
|
// Verify vtable structure is as expected (16 bytes total for 6 fields + header)
|
||||||
|
assert_eq!(
|
||||||
|
vtable_size, 16,
|
||||||
|
"VTable should be 16 bytes (4 header + 6*2 fields)"
|
||||||
|
);
|
||||||
|
|
||||||
|
// Check that unset fields (at offsets 4, 6, 8, 10, 12) are zero.
|
||||||
|
// Only field at offset 14 was set.
|
||||||
|
// If the bug exists, unset fields would be 0xAAAA instead of 0.
|
||||||
|
for i in [4_usize, 6, 8, 10, 12] {
|
||||||
|
let field_offset = u16::from_le_bytes([data[vtable_pos + i], data[vtable_pos + i + 1]]);
|
||||||
|
assert_eq!(
|
||||||
|
field_offset, 0,
|
||||||
|
"Vtable entry at offset {} should be 0 (default), but was 0x{:04X}. \
|
||||||
|
This indicates uninitialized vtable memory (issue #8894).",
|
||||||
|
i, field_offset
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify the field we DID set has a non-zero offset
|
||||||
|
let field5_offset = u16::from_le_bytes([data[vtable_pos + 14], data[vtable_pos + 14 + 1]]);
|
||||||
|
assert_ne!(field5_offset, 0, "Field 5 should have a non-zero offset");
|
||||||
|
}
|
||||||
@@ -2,61 +2,56 @@
|
|||||||
|
|
||||||
# namespace: example
|
# namespace: example
|
||||||
|
|
||||||
from typing import Any
|
|
||||||
import flatbuffers
|
import flatbuffers
|
||||||
|
|
||||||
|
|
||||||
class HelloRequest(object):
|
class HelloRequest(object):
|
||||||
__slots__ = ['_tab']
|
__slots__ = ['_tab']
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def GetRootAs(cls, buf, offset: int = 0):
|
def GetRootAs(cls, buf, offset=0):
|
||||||
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
|
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
|
||||||
x = HelloRequest()
|
x = HelloRequest()
|
||||||
x.Init(buf, n + offset)
|
x.Init(buf, n + offset)
|
||||||
return x
|
return x
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def GetRootAsHelloRequest(cls, buf, offset=0):
|
def GetRootAsHelloRequest(cls, buf, offset=0):
|
||||||
"""This method is deprecated. Please switch to GetRootAs."""
|
"""This method is deprecated. Please switch to GetRootAs."""
|
||||||
return cls.GetRootAs(buf, offset)
|
return cls.GetRootAs(buf, offset)
|
||||||
|
# HelloRequest
|
||||||
|
def Init(self, buf, pos):
|
||||||
|
self._tab = flatbuffers.table.Table(buf, pos)
|
||||||
|
|
||||||
# HelloRequest
|
def HelloRequestStart(builder):
|
||||||
def Init(self, buf: bytes, pos: int):
|
builder.StartObject(0)
|
||||||
self._tab = flatbuffers.table.Table(buf, pos)
|
|
||||||
|
|
||||||
|
def HelloRequestEnd(builder):
|
||||||
|
return builder.EndObject()
|
||||||
|
|
||||||
def HelloRequestStart(builder: flatbuffers.Builder):
|
|
||||||
builder.StartObject(0)
|
|
||||||
|
|
||||||
|
|
||||||
def HelloRequestEnd(builder: flatbuffers.Builder) -> int:
|
|
||||||
return builder.EndObject()
|
|
||||||
|
|
||||||
|
|
||||||
class HelloResponse(object):
|
class HelloResponse(object):
|
||||||
__slots__ = ['_tab']
|
__slots__ = ['_tab']
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def GetRootAs(cls, buf, offset: int = 0):
|
def GetRootAs(cls, buf, offset=0):
|
||||||
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
|
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
|
||||||
x = HelloResponse()
|
x = HelloResponse()
|
||||||
x.Init(buf, n + offset)
|
x.Init(buf, n + offset)
|
||||||
return x
|
return x
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def GetRootAsHelloResponse(cls, buf, offset=0):
|
def GetRootAsHelloResponse(cls, buf, offset=0):
|
||||||
"""This method is deprecated. Please switch to GetRootAs."""
|
"""This method is deprecated. Please switch to GetRootAs."""
|
||||||
return cls.GetRootAs(buf, offset)
|
return cls.GetRootAs(buf, offset)
|
||||||
|
# HelloResponse
|
||||||
|
def Init(self, buf, pos):
|
||||||
|
self._tab = flatbuffers.table.Table(buf, pos)
|
||||||
|
|
||||||
# HelloResponse
|
def HelloResponseStart(builder):
|
||||||
def Init(self, buf: bytes, pos: int):
|
builder.StartObject(0)
|
||||||
self._tab = flatbuffers.table.Table(buf, pos)
|
|
||||||
|
def HelloResponseEnd(builder):
|
||||||
|
return builder.EndObject()
|
||||||
|
|
||||||
|
|
||||||
def HelloResponseStart(builder: flatbuffers.Builder):
|
|
||||||
builder.StartObject(0)
|
|
||||||
|
|
||||||
|
|
||||||
def HelloResponseEnd(builder: flatbuffers.Builder) -> int:
|
|
||||||
return builder.EndObject()
|
|
||||||
|
|||||||
+5
-1
@@ -66,6 +66,8 @@
|
|||||||
#include "native_type_test_generated.h"
|
#include "native_type_test_generated.h"
|
||||||
#include "test_assert.h"
|
#include "test_assert.h"
|
||||||
#include "util_test.h"
|
#include "util_test.h"
|
||||||
|
#include "cpp_vector_type_test.h"
|
||||||
|
#include "bigfoot_ref_test_impl.h"
|
||||||
#include "vector_table_naked_ptr_test.h"
|
#include "vector_table_naked_ptr_test.h"
|
||||||
|
|
||||||
void FlatBufferBuilderTest();
|
void FlatBufferBuilderTest();
|
||||||
@@ -950,7 +952,6 @@ void NativeTypeTest() {
|
|||||||
TEST_EQ(dstDataT->position_inline.x, 4.0f);
|
TEST_EQ(dstDataT->position_inline.x, 4.0f);
|
||||||
TEST_EQ(dstDataT->position_inline.y, 5.0f);
|
TEST_EQ(dstDataT->position_inline.y, 5.0f);
|
||||||
TEST_EQ(dstDataT->position_inline.z, 6.0f);
|
TEST_EQ(dstDataT->position_inline.z, 6.0f);
|
||||||
|
|
||||||
for (int i = 0; i < N; ++i) {
|
for (int i = 0; i < N; ++i) {
|
||||||
const Native::Vector3D& v = dstDataT->vectors[i];
|
const Native::Vector3D& v = dstDataT->vectors[i];
|
||||||
TEST_EQ(v.x, 10 * i + 0.1f);
|
TEST_EQ(v.x, 10 * i + 0.1f);
|
||||||
@@ -1744,6 +1745,8 @@ int FlatBufferTests(const std::string& tests_data_path) {
|
|||||||
|
|
||||||
AlignmentTest();
|
AlignmentTest();
|
||||||
|
|
||||||
|
CppVectorTypeTest();
|
||||||
|
|
||||||
#ifndef FLATBUFFERS_NO_FILE_TESTS
|
#ifndef FLATBUFFERS_NO_FILE_TESTS
|
||||||
ParseAndGenerateTextTest(tests_data_path, false);
|
ParseAndGenerateTextTest(tests_data_path, false);
|
||||||
ParseAndGenerateTextTest(tests_data_path, true);
|
ParseAndGenerateTextTest(tests_data_path, true);
|
||||||
@@ -1813,6 +1816,7 @@ int FlatBufferTests(const std::string& tests_data_path) {
|
|||||||
InvalidFloatTest();
|
InvalidFloatTest();
|
||||||
FixedLengthArrayTest();
|
FixedLengthArrayTest();
|
||||||
NativeTypeTest();
|
NativeTypeTest();
|
||||||
|
flatbuffers::tests::BigfootRefTest();
|
||||||
OptionalScalarsTest();
|
OptionalScalarsTest();
|
||||||
ParseFlexbuffersFromJsonWithNullTest();
|
ParseFlexbuffersFromJsonWithNullTest();
|
||||||
FlatbuffersSpanTest();
|
FlatbuffersSpanTest();
|
||||||
|
|||||||
@@ -0,0 +1,152 @@
|
|||||||
|
#ifndef TESTS_TEST_VECTOR_TYPE_H_
|
||||||
|
#define TESTS_TEST_VECTOR_TYPE_H_
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include <new>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
namespace flatbuffers {
|
||||||
|
namespace tests {
|
||||||
|
|
||||||
|
// A minimal stand-in for a custom vector-like container (e.g.
|
||||||
|
// eastl::vector), used to exercise the --cpp-vector-type flatc option.
|
||||||
|
//
|
||||||
|
// This is deliberately its own contiguous container rather than a wrapper
|
||||||
|
// around std::vector, so that:
|
||||||
|
// - generated code can't silently keep depending on any of the
|
||||||
|
// std::vector-specific overloads in flatbuffer_builder.h (e.g.
|
||||||
|
// CreateVector(const std::vector<T,Alloc>&)), and
|
||||||
|
// - CustomVector<bool> stores plain contiguous bools accessible via
|
||||||
|
// data(), unlike std::vector<bool>'s bit-packed specialization, matching
|
||||||
|
// how real alternative containers such as eastl::vector behave.
|
||||||
|
template<typename T>
|
||||||
|
class CustomVector {
|
||||||
|
public:
|
||||||
|
using value_type = T;
|
||||||
|
using iterator = T*;
|
||||||
|
using const_iterator = const T*;
|
||||||
|
|
||||||
|
CustomVector() = default;
|
||||||
|
CustomVector(const CustomVector& o) { assign_copy(o); }
|
||||||
|
CustomVector(CustomVector&& o) noexcept { steal(o); }
|
||||||
|
|
||||||
|
CustomVector& operator=(const CustomVector& o) {
|
||||||
|
if (this != &o) {
|
||||||
|
destroy_all();
|
||||||
|
deallocate();
|
||||||
|
assign_copy(o);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomVector& operator=(CustomVector&& o) noexcept {
|
||||||
|
if (this != &o) {
|
||||||
|
destroy_all();
|
||||||
|
deallocate();
|
||||||
|
steal(o);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
~CustomVector() {
|
||||||
|
destroy_all();
|
||||||
|
deallocate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void reserve(size_t n) {
|
||||||
|
if (n > capacity_) grow_to(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
void resize(size_t n) {
|
||||||
|
if (n > capacity_) grow_to(n);
|
||||||
|
for (size_t i = n; i < size_; ++i) data_[i].~T();
|
||||||
|
for (size_t i = size_; i < n; ++i) new (&data_[i]) T();
|
||||||
|
size_ = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t size() const { return size_; }
|
||||||
|
bool empty() const { return size_ == 0; }
|
||||||
|
|
||||||
|
T* data() { return data_; }
|
||||||
|
const T* data() const { return data_; }
|
||||||
|
|
||||||
|
T& operator[](size_t i) { return data_[i]; }
|
||||||
|
const T& operator[](size_t i) const { return data_[i]; }
|
||||||
|
|
||||||
|
template<typename... Args>
|
||||||
|
void emplace_back(Args&&... args) {
|
||||||
|
if (size_ == capacity_) grow_to(capacity_ == 0 ? 1 : capacity_ * 2);
|
||||||
|
new (&data_[size_]) T(std::forward<Args>(args)...);
|
||||||
|
++size_;
|
||||||
|
}
|
||||||
|
void push_back(const T& v) { emplace_back(v); }
|
||||||
|
|
||||||
|
iterator begin() { return data_; }
|
||||||
|
iterator end() { return data_ + size_; }
|
||||||
|
const_iterator begin() const { return data_; }
|
||||||
|
const_iterator end() const { return data_ + size_; }
|
||||||
|
const_iterator cbegin() const { return data_; }
|
||||||
|
const_iterator cend() const { return data_ + size_; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
void grow_to(size_t n) {
|
||||||
|
T* new_data = static_cast<T*>(::operator new(n * sizeof(T)));
|
||||||
|
for (size_t i = 0; i < size_; ++i) {
|
||||||
|
new (&new_data[i]) T(std::move(data_[i]));
|
||||||
|
data_[i].~T();
|
||||||
|
}
|
||||||
|
::operator delete(data_);
|
||||||
|
data_ = new_data;
|
||||||
|
capacity_ = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
void assign_copy(const CustomVector& o) {
|
||||||
|
data_ = o.size_ ? static_cast<T*>(::operator new(o.size_ * sizeof(T)))
|
||||||
|
: nullptr;
|
||||||
|
capacity_ = o.size_;
|
||||||
|
for (size_t i = 0; i < o.size_; ++i) new (&data_[i]) T(o.data_[i]);
|
||||||
|
size_ = o.size_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void steal(CustomVector& o) {
|
||||||
|
data_ = o.data_;
|
||||||
|
size_ = o.size_;
|
||||||
|
capacity_ = o.capacity_;
|
||||||
|
o.data_ = nullptr;
|
||||||
|
o.size_ = o.capacity_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void destroy_all() {
|
||||||
|
for (size_t i = 0; i < size_; ++i) data_[i].~T();
|
||||||
|
size_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void deallocate() {
|
||||||
|
::operator delete(data_);
|
||||||
|
data_ = nullptr;
|
||||||
|
capacity_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
T* data_ = nullptr;
|
||||||
|
size_t size_ = 0;
|
||||||
|
size_t capacity_ = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
bool operator==(const CustomVector<T>& lhs, const CustomVector<T>& rhs) {
|
||||||
|
if (lhs.size() != rhs.size()) return false;
|
||||||
|
for (size_t i = 0; i < lhs.size(); ++i) {
|
||||||
|
if (!(lhs[i] == rhs[i])) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
bool operator!=(const CustomVector<T>& lhs, const CustomVector<T>& rhs) {
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace tests
|
||||||
|
} // namespace flatbuffers
|
||||||
|
|
||||||
|
#endif // TESTS_TEST_VECTOR_TYPE_H_
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
import assert from 'assert'
|
||||||
|
import * as flatbuffers from 'flatbuffers'
|
||||||
|
|
||||||
|
import optional_scalars from './ts-undefined-for-optionals/optional_scalars_generated.cjs'
|
||||||
|
|
||||||
|
const { ScalarStuff, ScalarStuffT } = optional_scalars.optional_scalars;
|
||||||
|
|
||||||
|
function testScalarStuffBuf(scalarStuff) {
|
||||||
|
assert.strictEqual(scalarStuff.justI8(), -1);
|
||||||
|
assert.strictEqual(scalarStuff.maybeI8(), undefined);
|
||||||
|
assert.strictEqual(scalarStuff.defaultI8(), 42);
|
||||||
|
assert.strictEqual(scalarStuff.justU8(), 1);
|
||||||
|
assert.strictEqual(scalarStuff.maybeU8(), undefined);
|
||||||
|
assert.strictEqual(scalarStuff.defaultU8(), 42);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testScalarStuffUnpack(scalarStuff) {
|
||||||
|
assert.strictEqual(scalarStuff.justI8, -1);
|
||||||
|
assert.strictEqual(scalarStuff.maybeI8, undefined);
|
||||||
|
assert.strictEqual(scalarStuff.defaultI8, 42);
|
||||||
|
assert.strictEqual(scalarStuff.justU8, 1);
|
||||||
|
assert.strictEqual(scalarStuff.maybeU8, undefined);
|
||||||
|
assert.strictEqual(scalarStuff.defaultU8, 42);
|
||||||
|
}
|
||||||
|
|
||||||
|
function createScalarStuff(fbb) {
|
||||||
|
ScalarStuff.startScalarStuff(fbb);
|
||||||
|
ScalarStuff.addJustI8(fbb, -1);
|
||||||
|
ScalarStuff.addJustU8(fbb, 1);
|
||||||
|
var offset = ScalarStuff.endScalarStuff(fbb);
|
||||||
|
ScalarStuff.finishScalarStuffBuffer(fbb, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
var fbb = new flatbuffers.Builder();
|
||||||
|
|
||||||
|
createScalarStuff(fbb);
|
||||||
|
|
||||||
|
var buf = new flatbuffers.ByteBuffer(fbb.asUint8Array());
|
||||||
|
var scalarStuff = ScalarStuff.getRootAsScalarStuff(buf);
|
||||||
|
|
||||||
|
testScalarStuffBuf(scalarStuff);
|
||||||
|
|
||||||
|
testScalarStuffUnpack(scalarStuff.unpack());
|
||||||
|
|
||||||
|
var scalarStuff_to = new ScalarStuffT();
|
||||||
|
scalarStuff.unpackTo(scalarStuff_to);
|
||||||
|
|
||||||
|
testScalarStuffUnpack(scalarStuff_to);
|
||||||
|
|
||||||
|
fbb.clear();
|
||||||
|
ScalarStuff.finishScalarStuffBuffer(fbb, scalarStuff_to.pack(fbb));
|
||||||
|
var unpackBuf = new flatbuffers.ByteBuffer(fbb.asUint8Array());
|
||||||
|
|
||||||
|
testScalarStuffBuf(ScalarStuff.getRootAsScalarStuff(unpackBuf));
|
||||||
|
|
||||||
|
console.log('FlatBuffers --ts-undefined-for-optionals test: completed successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
main();
|
||||||
@@ -99,6 +99,20 @@ flatc(
|
|||||||
schema="../non_zero_enum.fbs",
|
schema="../non_zero_enum.fbs",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
flatc(
|
||||||
|
options=[
|
||||||
|
"--ts",
|
||||||
|
"--gen-object-api",
|
||||||
|
"--ts-undefined-for-optionals",
|
||||||
|
],
|
||||||
|
schema="../optional_scalars.fbs",
|
||||||
|
prefix="ts-undefined-for-optionals",
|
||||||
|
)
|
||||||
|
esbuild(
|
||||||
|
"ts-undefined-for-optionals/optional_scalars.ts",
|
||||||
|
"ts-undefined-for-optionals/optional_scalars_generated.cjs",
|
||||||
|
)
|
||||||
|
|
||||||
flatc(
|
flatc(
|
||||||
options=[
|
options=[
|
||||||
"--ts",
|
"--ts",
|
||||||
@@ -201,6 +215,7 @@ check_call(NODE_CMD + ["JavaScriptUnionVectorTest"])
|
|||||||
check_call(NODE_CMD + ["JavaScriptFlexBuffersTest"])
|
check_call(NODE_CMD + ["JavaScriptFlexBuffersTest"])
|
||||||
check_call(NODE_CMD + ["JavaScriptComplexArraysTest"])
|
check_call(NODE_CMD + ["JavaScriptComplexArraysTest"])
|
||||||
check_call(NODE_CMD + ["JavaScriptUnionUnderlyingTypeTest"])
|
check_call(NODE_CMD + ["JavaScriptUnionUnderlyingTypeTest"])
|
||||||
|
check_call(NODE_CMD + ["JavaScriptUndefinedForOptionals"])
|
||||||
|
|
||||||
print("Running old v1 TypeScript Tests...")
|
print("Running old v1 TypeScript Tests...")
|
||||||
check_call(NODE_CMD + ["JavaScriptTestv1.cjs", "./monster_test_generated.cjs"])
|
check_call(NODE_CMD + ["JavaScriptTestv1.cjs", "./monster_test_generated.cjs"])
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
|
||||||
|
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||||
|
|
||||||
|
export { OptionalByte } from './optional-scalars/optional-byte.js';
|
||||||
|
export { ScalarStuff, ScalarStuffT } from './optional-scalars/scalar-stuff.js';
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
|
||||||
|
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||||
|
|
||||||
|
export enum OptionalByte {
|
||||||
|
None = 0,
|
||||||
|
One = 1,
|
||||||
|
Two = 2
|
||||||
|
}
|
||||||
@@ -0,0 +1,589 @@
|
|||||||
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
|
||||||
|
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||||
|
|
||||||
|
import * as flatbuffers from 'flatbuffers';
|
||||||
|
|
||||||
|
import { OptionalByte } from '../optional-scalars/optional-byte.js';
|
||||||
|
|
||||||
|
|
||||||
|
export class ScalarStuff implements flatbuffers.IUnpackableObject<ScalarStuffT> {
|
||||||
|
bb: flatbuffers.ByteBuffer|undefined = undefined;
|
||||||
|
bb_pos = 0;
|
||||||
|
__init(i:number, bb:flatbuffers.ByteBuffer):ScalarStuff {
|
||||||
|
this.bb_pos = i;
|
||||||
|
this.bb = bb;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
static getRootAsScalarStuff(bb:flatbuffers.ByteBuffer, obj?:ScalarStuff):ScalarStuff {
|
||||||
|
return (obj || new ScalarStuff()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||||
|
}
|
||||||
|
|
||||||
|
static getSizePrefixedRootAsScalarStuff(bb:flatbuffers.ByteBuffer, obj?:ScalarStuff):ScalarStuff {
|
||||||
|
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||||
|
return (obj || new ScalarStuff()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean {
|
||||||
|
return bb.__has_identifier('NULL');
|
||||||
|
}
|
||||||
|
|
||||||
|
justI8():number {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||||
|
return offset ? this.bb!.readInt8(this.bb_pos + offset) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
maybeI8():number|undefined {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 6);
|
||||||
|
return offset ? this.bb!.readInt8(this.bb_pos + offset) : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultI8():number {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 8);
|
||||||
|
return offset ? this.bb!.readInt8(this.bb_pos + offset) : 42;
|
||||||
|
}
|
||||||
|
|
||||||
|
justU8():number {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 10);
|
||||||
|
return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
maybeU8():number|undefined {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 12);
|
||||||
|
return offset ? this.bb!.readUint8(this.bb_pos + offset) : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultU8():number {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 14);
|
||||||
|
return offset ? this.bb!.readUint8(this.bb_pos + offset) : 42;
|
||||||
|
}
|
||||||
|
|
||||||
|
justI16():number {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 16);
|
||||||
|
return offset ? this.bb!.readInt16(this.bb_pos + offset) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
maybeI16():number|undefined {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 18);
|
||||||
|
return offset ? this.bb!.readInt16(this.bb_pos + offset) : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultI16():number {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 20);
|
||||||
|
return offset ? this.bb!.readInt16(this.bb_pos + offset) : 42;
|
||||||
|
}
|
||||||
|
|
||||||
|
justU16():number {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 22);
|
||||||
|
return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
maybeU16():number|undefined {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 24);
|
||||||
|
return offset ? this.bb!.readUint16(this.bb_pos + offset) : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultU16():number {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 26);
|
||||||
|
return offset ? this.bb!.readUint16(this.bb_pos + offset) : 42;
|
||||||
|
}
|
||||||
|
|
||||||
|
justI32():number {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 28);
|
||||||
|
return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
maybeI32():number|undefined {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 30);
|
||||||
|
return offset ? this.bb!.readInt32(this.bb_pos + offset) : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultI32():number {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 32);
|
||||||
|
return offset ? this.bb!.readInt32(this.bb_pos + offset) : 42;
|
||||||
|
}
|
||||||
|
|
||||||
|
justU32():number {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 34);
|
||||||
|
return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
maybeU32():number|undefined {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 36);
|
||||||
|
return offset ? this.bb!.readUint32(this.bb_pos + offset) : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultU32():number {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 38);
|
||||||
|
return offset ? this.bb!.readUint32(this.bb_pos + offset) : 42;
|
||||||
|
}
|
||||||
|
|
||||||
|
justI64():bigint {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 40);
|
||||||
|
return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
|
||||||
|
}
|
||||||
|
|
||||||
|
maybeI64():bigint|undefined {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 42);
|
||||||
|
return offset ? this.bb!.readInt64(this.bb_pos + offset) : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultI64():bigint {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 44);
|
||||||
|
return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('42');
|
||||||
|
}
|
||||||
|
|
||||||
|
justU64():bigint {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 46);
|
||||||
|
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
|
||||||
|
}
|
||||||
|
|
||||||
|
maybeU64():bigint|undefined {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 48);
|
||||||
|
return offset ? this.bb!.readUint64(this.bb_pos + offset) : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultU64():bigint {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 50);
|
||||||
|
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('42');
|
||||||
|
}
|
||||||
|
|
||||||
|
justF32():number {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 52);
|
||||||
|
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
maybeF32():number|undefined {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 54);
|
||||||
|
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultF32():number {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 56);
|
||||||
|
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 42.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
justF64():number {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 58);
|
||||||
|
return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
maybeF64():number|undefined {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 60);
|
||||||
|
return offset ? this.bb!.readFloat64(this.bb_pos + offset) : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultF64():number {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 62);
|
||||||
|
return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 42.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
justBool():boolean {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 64);
|
||||||
|
return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
maybeBool():boolean|undefined {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 66);
|
||||||
|
return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultBool():boolean {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 68);
|
||||||
|
return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : true;
|
||||||
|
}
|
||||||
|
|
||||||
|
justEnum():OptionalByte {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 70);
|
||||||
|
return offset ? this.bb!.readInt8(this.bb_pos + offset) : OptionalByte.None;
|
||||||
|
}
|
||||||
|
|
||||||
|
maybeEnum():OptionalByte|undefined {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 72);
|
||||||
|
return offset ? this.bb!.readInt8(this.bb_pos + offset) : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultEnum():OptionalByte {
|
||||||
|
const offset = this.bb!.__offset(this.bb_pos, 74);
|
||||||
|
return offset ? this.bb!.readInt8(this.bb_pos + offset) : OptionalByte.One;
|
||||||
|
}
|
||||||
|
|
||||||
|
static startScalarStuff(builder:flatbuffers.Builder) {
|
||||||
|
builder.startObject(36);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addJustI8(builder:flatbuffers.Builder, justI8:number) {
|
||||||
|
builder.addFieldInt8(0, justI8, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addMaybeI8(builder:flatbuffers.Builder, maybeI8:number) {
|
||||||
|
builder.addFieldInt8(1, maybeI8, undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addDefaultI8(builder:flatbuffers.Builder, defaultI8:number) {
|
||||||
|
builder.addFieldInt8(2, defaultI8, 42);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addJustU8(builder:flatbuffers.Builder, justU8:number) {
|
||||||
|
builder.addFieldInt8(3, justU8, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addMaybeU8(builder:flatbuffers.Builder, maybeU8:number) {
|
||||||
|
builder.addFieldInt8(4, maybeU8, undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addDefaultU8(builder:flatbuffers.Builder, defaultU8:number) {
|
||||||
|
builder.addFieldInt8(5, defaultU8, 42);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addJustI16(builder:flatbuffers.Builder, justI16:number) {
|
||||||
|
builder.addFieldInt16(6, justI16, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addMaybeI16(builder:flatbuffers.Builder, maybeI16:number) {
|
||||||
|
builder.addFieldInt16(7, maybeI16, undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addDefaultI16(builder:flatbuffers.Builder, defaultI16:number) {
|
||||||
|
builder.addFieldInt16(8, defaultI16, 42);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addJustU16(builder:flatbuffers.Builder, justU16:number) {
|
||||||
|
builder.addFieldInt16(9, justU16, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addMaybeU16(builder:flatbuffers.Builder, maybeU16:number) {
|
||||||
|
builder.addFieldInt16(10, maybeU16, undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addDefaultU16(builder:flatbuffers.Builder, defaultU16:number) {
|
||||||
|
builder.addFieldInt16(11, defaultU16, 42);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addJustI32(builder:flatbuffers.Builder, justI32:number) {
|
||||||
|
builder.addFieldInt32(12, justI32, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addMaybeI32(builder:flatbuffers.Builder, maybeI32:number) {
|
||||||
|
builder.addFieldInt32(13, maybeI32, undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addDefaultI32(builder:flatbuffers.Builder, defaultI32:number) {
|
||||||
|
builder.addFieldInt32(14, defaultI32, 42);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addJustU32(builder:flatbuffers.Builder, justU32:number) {
|
||||||
|
builder.addFieldInt32(15, justU32, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addMaybeU32(builder:flatbuffers.Builder, maybeU32:number) {
|
||||||
|
builder.addFieldInt32(16, maybeU32, undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addDefaultU32(builder:flatbuffers.Builder, defaultU32:number) {
|
||||||
|
builder.addFieldInt32(17, defaultU32, 42);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addJustI64(builder:flatbuffers.Builder, justI64:bigint) {
|
||||||
|
builder.addFieldInt64(18, justI64, BigInt('0'));
|
||||||
|
}
|
||||||
|
|
||||||
|
static addMaybeI64(builder:flatbuffers.Builder, maybeI64:bigint) {
|
||||||
|
builder.addFieldInt64(19, maybeI64, undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addDefaultI64(builder:flatbuffers.Builder, defaultI64:bigint) {
|
||||||
|
builder.addFieldInt64(20, defaultI64, BigInt('42'));
|
||||||
|
}
|
||||||
|
|
||||||
|
static addJustU64(builder:flatbuffers.Builder, justU64:bigint) {
|
||||||
|
builder.addFieldInt64(21, justU64, BigInt('0'));
|
||||||
|
}
|
||||||
|
|
||||||
|
static addMaybeU64(builder:flatbuffers.Builder, maybeU64:bigint) {
|
||||||
|
builder.addFieldInt64(22, maybeU64, undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addDefaultU64(builder:flatbuffers.Builder, defaultU64:bigint) {
|
||||||
|
builder.addFieldInt64(23, defaultU64, BigInt('42'));
|
||||||
|
}
|
||||||
|
|
||||||
|
static addJustF32(builder:flatbuffers.Builder, justF32:number) {
|
||||||
|
builder.addFieldFloat32(24, justF32, 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addMaybeF32(builder:flatbuffers.Builder, maybeF32:number) {
|
||||||
|
builder.addFieldFloat32(25, maybeF32, undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addDefaultF32(builder:flatbuffers.Builder, defaultF32:number) {
|
||||||
|
builder.addFieldFloat32(26, defaultF32, 42.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addJustF64(builder:flatbuffers.Builder, justF64:number) {
|
||||||
|
builder.addFieldFloat64(27, justF64, 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addMaybeF64(builder:flatbuffers.Builder, maybeF64:number) {
|
||||||
|
builder.addFieldFloat64(28, maybeF64, undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addDefaultF64(builder:flatbuffers.Builder, defaultF64:number) {
|
||||||
|
builder.addFieldFloat64(29, defaultF64, 42.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addJustBool(builder:flatbuffers.Builder, justBool:boolean) {
|
||||||
|
builder.addFieldInt8(30, +justBool, +false);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addMaybeBool(builder:flatbuffers.Builder, maybeBool:boolean) {
|
||||||
|
builder.addFieldInt8(31, +maybeBool, undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addDefaultBool(builder:flatbuffers.Builder, defaultBool:boolean) {
|
||||||
|
builder.addFieldInt8(32, +defaultBool, +true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addJustEnum(builder:flatbuffers.Builder, justEnum:OptionalByte) {
|
||||||
|
builder.addFieldInt8(33, justEnum, OptionalByte.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addMaybeEnum(builder:flatbuffers.Builder, maybeEnum:OptionalByte) {
|
||||||
|
builder.addFieldInt8(34, maybeEnum, undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addDefaultEnum(builder:flatbuffers.Builder, defaultEnum:OptionalByte) {
|
||||||
|
builder.addFieldInt8(35, defaultEnum, OptionalByte.One);
|
||||||
|
}
|
||||||
|
|
||||||
|
static endScalarStuff(builder:flatbuffers.Builder):flatbuffers.Offset {
|
||||||
|
const offset = builder.endObject();
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
static finishScalarStuffBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
|
||||||
|
builder.finish(offset, 'NULL');
|
||||||
|
}
|
||||||
|
|
||||||
|
static finishSizePrefixedScalarStuffBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
|
||||||
|
builder.finish(offset, 'NULL', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static createScalarStuff(builder:flatbuffers.Builder, justI8:number, maybeI8:number|undefined, defaultI8:number, justU8:number, maybeU8:number|undefined, defaultU8:number, justI16:number, maybeI16:number|undefined, defaultI16:number, justU16:number, maybeU16:number|undefined, defaultU16:number, justI32:number, maybeI32:number|undefined, defaultI32:number, justU32:number, maybeU32:number|undefined, defaultU32:number, justI64:bigint, maybeI64:bigint|undefined, defaultI64:bigint, justU64:bigint, maybeU64:bigint|undefined, defaultU64:bigint, justF32:number, maybeF32:number|undefined, defaultF32:number, justF64:number, maybeF64:number|undefined, defaultF64:number, justBool:boolean, maybeBool:boolean|undefined, defaultBool:boolean, justEnum:OptionalByte, maybeEnum:OptionalByte|undefined, defaultEnum:OptionalByte):flatbuffers.Offset {
|
||||||
|
ScalarStuff.startScalarStuff(builder);
|
||||||
|
ScalarStuff.addJustI8(builder, justI8);
|
||||||
|
if (maybeI8 !== undefined)
|
||||||
|
ScalarStuff.addMaybeI8(builder, maybeI8);
|
||||||
|
ScalarStuff.addDefaultI8(builder, defaultI8);
|
||||||
|
ScalarStuff.addJustU8(builder, justU8);
|
||||||
|
if (maybeU8 !== undefined)
|
||||||
|
ScalarStuff.addMaybeU8(builder, maybeU8);
|
||||||
|
ScalarStuff.addDefaultU8(builder, defaultU8);
|
||||||
|
ScalarStuff.addJustI16(builder, justI16);
|
||||||
|
if (maybeI16 !== undefined)
|
||||||
|
ScalarStuff.addMaybeI16(builder, maybeI16);
|
||||||
|
ScalarStuff.addDefaultI16(builder, defaultI16);
|
||||||
|
ScalarStuff.addJustU16(builder, justU16);
|
||||||
|
if (maybeU16 !== undefined)
|
||||||
|
ScalarStuff.addMaybeU16(builder, maybeU16);
|
||||||
|
ScalarStuff.addDefaultU16(builder, defaultU16);
|
||||||
|
ScalarStuff.addJustI32(builder, justI32);
|
||||||
|
if (maybeI32 !== undefined)
|
||||||
|
ScalarStuff.addMaybeI32(builder, maybeI32);
|
||||||
|
ScalarStuff.addDefaultI32(builder, defaultI32);
|
||||||
|
ScalarStuff.addJustU32(builder, justU32);
|
||||||
|
if (maybeU32 !== undefined)
|
||||||
|
ScalarStuff.addMaybeU32(builder, maybeU32);
|
||||||
|
ScalarStuff.addDefaultU32(builder, defaultU32);
|
||||||
|
ScalarStuff.addJustI64(builder, justI64);
|
||||||
|
if (maybeI64 !== undefined)
|
||||||
|
ScalarStuff.addMaybeI64(builder, maybeI64);
|
||||||
|
ScalarStuff.addDefaultI64(builder, defaultI64);
|
||||||
|
ScalarStuff.addJustU64(builder, justU64);
|
||||||
|
if (maybeU64 !== undefined)
|
||||||
|
ScalarStuff.addMaybeU64(builder, maybeU64);
|
||||||
|
ScalarStuff.addDefaultU64(builder, defaultU64);
|
||||||
|
ScalarStuff.addJustF32(builder, justF32);
|
||||||
|
if (maybeF32 !== undefined)
|
||||||
|
ScalarStuff.addMaybeF32(builder, maybeF32);
|
||||||
|
ScalarStuff.addDefaultF32(builder, defaultF32);
|
||||||
|
ScalarStuff.addJustF64(builder, justF64);
|
||||||
|
if (maybeF64 !== undefined)
|
||||||
|
ScalarStuff.addMaybeF64(builder, maybeF64);
|
||||||
|
ScalarStuff.addDefaultF64(builder, defaultF64);
|
||||||
|
ScalarStuff.addJustBool(builder, justBool);
|
||||||
|
if (maybeBool !== undefined)
|
||||||
|
ScalarStuff.addMaybeBool(builder, maybeBool);
|
||||||
|
ScalarStuff.addDefaultBool(builder, defaultBool);
|
||||||
|
ScalarStuff.addJustEnum(builder, justEnum);
|
||||||
|
if (maybeEnum !== undefined)
|
||||||
|
ScalarStuff.addMaybeEnum(builder, maybeEnum);
|
||||||
|
ScalarStuff.addDefaultEnum(builder, defaultEnum);
|
||||||
|
return ScalarStuff.endScalarStuff(builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
unpack(): ScalarStuffT {
|
||||||
|
return new ScalarStuffT(
|
||||||
|
this.justI8(),
|
||||||
|
this.maybeI8(),
|
||||||
|
this.defaultI8(),
|
||||||
|
this.justU8(),
|
||||||
|
this.maybeU8(),
|
||||||
|
this.defaultU8(),
|
||||||
|
this.justI16(),
|
||||||
|
this.maybeI16(),
|
||||||
|
this.defaultI16(),
|
||||||
|
this.justU16(),
|
||||||
|
this.maybeU16(),
|
||||||
|
this.defaultU16(),
|
||||||
|
this.justI32(),
|
||||||
|
this.maybeI32(),
|
||||||
|
this.defaultI32(),
|
||||||
|
this.justU32(),
|
||||||
|
this.maybeU32(),
|
||||||
|
this.defaultU32(),
|
||||||
|
this.justI64(),
|
||||||
|
this.maybeI64(),
|
||||||
|
this.defaultI64(),
|
||||||
|
this.justU64(),
|
||||||
|
this.maybeU64(),
|
||||||
|
this.defaultU64(),
|
||||||
|
this.justF32(),
|
||||||
|
this.maybeF32(),
|
||||||
|
this.defaultF32(),
|
||||||
|
this.justF64(),
|
||||||
|
this.maybeF64(),
|
||||||
|
this.defaultF64(),
|
||||||
|
this.justBool(),
|
||||||
|
this.maybeBool(),
|
||||||
|
this.defaultBool(),
|
||||||
|
this.justEnum(),
|
||||||
|
this.maybeEnum(),
|
||||||
|
this.defaultEnum()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unpackTo(_o: ScalarStuffT): void {
|
||||||
|
_o.justI8 = this.justI8();
|
||||||
|
_o.maybeI8 = this.maybeI8();
|
||||||
|
_o.defaultI8 = this.defaultI8();
|
||||||
|
_o.justU8 = this.justU8();
|
||||||
|
_o.maybeU8 = this.maybeU8();
|
||||||
|
_o.defaultU8 = this.defaultU8();
|
||||||
|
_o.justI16 = this.justI16();
|
||||||
|
_o.maybeI16 = this.maybeI16();
|
||||||
|
_o.defaultI16 = this.defaultI16();
|
||||||
|
_o.justU16 = this.justU16();
|
||||||
|
_o.maybeU16 = this.maybeU16();
|
||||||
|
_o.defaultU16 = this.defaultU16();
|
||||||
|
_o.justI32 = this.justI32();
|
||||||
|
_o.maybeI32 = this.maybeI32();
|
||||||
|
_o.defaultI32 = this.defaultI32();
|
||||||
|
_o.justU32 = this.justU32();
|
||||||
|
_o.maybeU32 = this.maybeU32();
|
||||||
|
_o.defaultU32 = this.defaultU32();
|
||||||
|
_o.justI64 = this.justI64();
|
||||||
|
_o.maybeI64 = this.maybeI64();
|
||||||
|
_o.defaultI64 = this.defaultI64();
|
||||||
|
_o.justU64 = this.justU64();
|
||||||
|
_o.maybeU64 = this.maybeU64();
|
||||||
|
_o.defaultU64 = this.defaultU64();
|
||||||
|
_o.justF32 = this.justF32();
|
||||||
|
_o.maybeF32 = this.maybeF32();
|
||||||
|
_o.defaultF32 = this.defaultF32();
|
||||||
|
_o.justF64 = this.justF64();
|
||||||
|
_o.maybeF64 = this.maybeF64();
|
||||||
|
_o.defaultF64 = this.defaultF64();
|
||||||
|
_o.justBool = this.justBool();
|
||||||
|
_o.maybeBool = this.maybeBool();
|
||||||
|
_o.defaultBool = this.defaultBool();
|
||||||
|
_o.justEnum = this.justEnum();
|
||||||
|
_o.maybeEnum = this.maybeEnum();
|
||||||
|
_o.defaultEnum = this.defaultEnum();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ScalarStuffT implements flatbuffers.IGeneratedObject {
|
||||||
|
constructor(
|
||||||
|
public justI8: number = 0,
|
||||||
|
public maybeI8: number|undefined = undefined,
|
||||||
|
public defaultI8: number = 42,
|
||||||
|
public justU8: number = 0,
|
||||||
|
public maybeU8: number|undefined = undefined,
|
||||||
|
public defaultU8: number = 42,
|
||||||
|
public justI16: number = 0,
|
||||||
|
public maybeI16: number|undefined = undefined,
|
||||||
|
public defaultI16: number = 42,
|
||||||
|
public justU16: number = 0,
|
||||||
|
public maybeU16: number|undefined = undefined,
|
||||||
|
public defaultU16: number = 42,
|
||||||
|
public justI32: number = 0,
|
||||||
|
public maybeI32: number|undefined = undefined,
|
||||||
|
public defaultI32: number = 42,
|
||||||
|
public justU32: number = 0,
|
||||||
|
public maybeU32: number|undefined = undefined,
|
||||||
|
public defaultU32: number = 42,
|
||||||
|
public justI64: bigint = BigInt('0'),
|
||||||
|
public maybeI64: bigint|undefined = undefined,
|
||||||
|
public defaultI64: bigint = BigInt('42'),
|
||||||
|
public justU64: bigint = BigInt('0'),
|
||||||
|
public maybeU64: bigint|undefined = undefined,
|
||||||
|
public defaultU64: bigint = BigInt('42'),
|
||||||
|
public justF32: number = 0.0,
|
||||||
|
public maybeF32: number|undefined = undefined,
|
||||||
|
public defaultF32: number = 42.0,
|
||||||
|
public justF64: number = 0.0,
|
||||||
|
public maybeF64: number|undefined = undefined,
|
||||||
|
public defaultF64: number = 42.0,
|
||||||
|
public justBool: boolean = false,
|
||||||
|
public maybeBool: boolean|undefined = undefined,
|
||||||
|
public defaultBool: boolean = true,
|
||||||
|
public justEnum: OptionalByte = OptionalByte.None,
|
||||||
|
public maybeEnum: OptionalByte|undefined = undefined,
|
||||||
|
public defaultEnum: OptionalByte = OptionalByte.One
|
||||||
|
){}
|
||||||
|
|
||||||
|
|
||||||
|
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
||||||
|
return ScalarStuff.createScalarStuff(builder,
|
||||||
|
this.justI8,
|
||||||
|
this.maybeI8,
|
||||||
|
this.defaultI8,
|
||||||
|
this.justU8,
|
||||||
|
this.maybeU8,
|
||||||
|
this.defaultU8,
|
||||||
|
this.justI16,
|
||||||
|
this.maybeI16,
|
||||||
|
this.defaultI16,
|
||||||
|
this.justU16,
|
||||||
|
this.maybeU16,
|
||||||
|
this.defaultU16,
|
||||||
|
this.justI32,
|
||||||
|
this.maybeI32,
|
||||||
|
this.defaultI32,
|
||||||
|
this.justU32,
|
||||||
|
this.maybeU32,
|
||||||
|
this.defaultU32,
|
||||||
|
this.justI64,
|
||||||
|
this.maybeI64,
|
||||||
|
this.defaultI64,
|
||||||
|
this.justU64,
|
||||||
|
this.maybeU64,
|
||||||
|
this.defaultU64,
|
||||||
|
this.justF32,
|
||||||
|
this.maybeF32,
|
||||||
|
this.defaultF32,
|
||||||
|
this.justF64,
|
||||||
|
this.maybeF64,
|
||||||
|
this.defaultF64,
|
||||||
|
this.justBool,
|
||||||
|
this.maybeBool,
|
||||||
|
this.defaultBool,
|
||||||
|
this.justEnum,
|
||||||
|
this.maybeEnum,
|
||||||
|
this.defaultEnum
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
|
||||||
|
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||||
|
|
||||||
|
export * as optional_scalars from './optional-scalars.js';
|
||||||
@@ -0,0 +1,551 @@
|
|||||||
|
"use strict";
|
||||||
|
var __create = Object.create;
|
||||||
|
var __defProp = Object.defineProperty;
|
||||||
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||||
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||||
|
var __getProtoOf = Object.getPrototypeOf;
|
||||||
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||||
|
var __export = (target, all) => {
|
||||||
|
for (var name in all)
|
||||||
|
__defProp(target, name, { get: all[name], enumerable: true });
|
||||||
|
};
|
||||||
|
var __copyProps = (to, from, except, desc) => {
|
||||||
|
if (from && typeof from === "object" || typeof from === "function") {
|
||||||
|
for (let key of __getOwnPropNames(from))
|
||||||
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||||
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||||
|
}
|
||||||
|
return to;
|
||||||
|
};
|
||||||
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||||
|
// If the importer is in node compatibility mode or this is not an ESM
|
||||||
|
// file that has been converted to a CommonJS file using a Babel-
|
||||||
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||||
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||||
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||||
|
mod
|
||||||
|
));
|
||||||
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||||
|
|
||||||
|
// ts-undefined-for-optionals/optional_scalars.ts
|
||||||
|
var optional_scalars_exports2 = {};
|
||||||
|
__export(optional_scalars_exports2, {
|
||||||
|
optional_scalars: () => optional_scalars_exports
|
||||||
|
});
|
||||||
|
module.exports = __toCommonJS(optional_scalars_exports2);
|
||||||
|
|
||||||
|
// ts-undefined-for-optionals/optional-scalars.ts
|
||||||
|
var optional_scalars_exports = {};
|
||||||
|
__export(optional_scalars_exports, {
|
||||||
|
OptionalByte: () => OptionalByte,
|
||||||
|
ScalarStuff: () => ScalarStuff,
|
||||||
|
ScalarStuffT: () => ScalarStuffT
|
||||||
|
});
|
||||||
|
|
||||||
|
// ts-undefined-for-optionals/optional-scalars/optional-byte.ts
|
||||||
|
var OptionalByte = /* @__PURE__ */ ((OptionalByte2) => {
|
||||||
|
OptionalByte2[OptionalByte2["None"] = 0] = "None";
|
||||||
|
OptionalByte2[OptionalByte2["One"] = 1] = "One";
|
||||||
|
OptionalByte2[OptionalByte2["Two"] = 2] = "Two";
|
||||||
|
return OptionalByte2;
|
||||||
|
})(OptionalByte || {});
|
||||||
|
|
||||||
|
// ts-undefined-for-optionals/optional-scalars/scalar-stuff.ts
|
||||||
|
var flatbuffers = __toESM(require("flatbuffers"), 1);
|
||||||
|
var ScalarStuff = class _ScalarStuff {
|
||||||
|
constructor() {
|
||||||
|
this.bb = void 0;
|
||||||
|
this.bb_pos = 0;
|
||||||
|
}
|
||||||
|
__init(i, bb) {
|
||||||
|
this.bb_pos = i;
|
||||||
|
this.bb = bb;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
static getRootAsScalarStuff(bb, obj) {
|
||||||
|
return (obj || new _ScalarStuff()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||||
|
}
|
||||||
|
static getSizePrefixedRootAsScalarStuff(bb, obj) {
|
||||||
|
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||||
|
return (obj || new _ScalarStuff()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||||
|
}
|
||||||
|
static bufferHasIdentifier(bb) {
|
||||||
|
return bb.__has_identifier("NULL");
|
||||||
|
}
|
||||||
|
justI8() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 4);
|
||||||
|
return offset ? this.bb.readInt8(this.bb_pos + offset) : 0;
|
||||||
|
}
|
||||||
|
maybeI8() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 6);
|
||||||
|
return offset ? this.bb.readInt8(this.bb_pos + offset) : void 0;
|
||||||
|
}
|
||||||
|
defaultI8() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 8);
|
||||||
|
return offset ? this.bb.readInt8(this.bb_pos + offset) : 42;
|
||||||
|
}
|
||||||
|
justU8() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 10);
|
||||||
|
return offset ? this.bb.readUint8(this.bb_pos + offset) : 0;
|
||||||
|
}
|
||||||
|
maybeU8() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 12);
|
||||||
|
return offset ? this.bb.readUint8(this.bb_pos + offset) : void 0;
|
||||||
|
}
|
||||||
|
defaultU8() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 14);
|
||||||
|
return offset ? this.bb.readUint8(this.bb_pos + offset) : 42;
|
||||||
|
}
|
||||||
|
justI16() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 16);
|
||||||
|
return offset ? this.bb.readInt16(this.bb_pos + offset) : 0;
|
||||||
|
}
|
||||||
|
maybeI16() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 18);
|
||||||
|
return offset ? this.bb.readInt16(this.bb_pos + offset) : void 0;
|
||||||
|
}
|
||||||
|
defaultI16() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 20);
|
||||||
|
return offset ? this.bb.readInt16(this.bb_pos + offset) : 42;
|
||||||
|
}
|
||||||
|
justU16() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 22);
|
||||||
|
return offset ? this.bb.readUint16(this.bb_pos + offset) : 0;
|
||||||
|
}
|
||||||
|
maybeU16() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 24);
|
||||||
|
return offset ? this.bb.readUint16(this.bb_pos + offset) : void 0;
|
||||||
|
}
|
||||||
|
defaultU16() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 26);
|
||||||
|
return offset ? this.bb.readUint16(this.bb_pos + offset) : 42;
|
||||||
|
}
|
||||||
|
justI32() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 28);
|
||||||
|
return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
|
||||||
|
}
|
||||||
|
maybeI32() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 30);
|
||||||
|
return offset ? this.bb.readInt32(this.bb_pos + offset) : void 0;
|
||||||
|
}
|
||||||
|
defaultI32() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 32);
|
||||||
|
return offset ? this.bb.readInt32(this.bb_pos + offset) : 42;
|
||||||
|
}
|
||||||
|
justU32() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 34);
|
||||||
|
return offset ? this.bb.readUint32(this.bb_pos + offset) : 0;
|
||||||
|
}
|
||||||
|
maybeU32() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 36);
|
||||||
|
return offset ? this.bb.readUint32(this.bb_pos + offset) : void 0;
|
||||||
|
}
|
||||||
|
defaultU32() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 38);
|
||||||
|
return offset ? this.bb.readUint32(this.bb_pos + offset) : 42;
|
||||||
|
}
|
||||||
|
justI64() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 40);
|
||||||
|
return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt("0");
|
||||||
|
}
|
||||||
|
maybeI64() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 42);
|
||||||
|
return offset ? this.bb.readInt64(this.bb_pos + offset) : void 0;
|
||||||
|
}
|
||||||
|
defaultI64() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 44);
|
||||||
|
return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt("42");
|
||||||
|
}
|
||||||
|
justU64() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 46);
|
||||||
|
return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt("0");
|
||||||
|
}
|
||||||
|
maybeU64() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 48);
|
||||||
|
return offset ? this.bb.readUint64(this.bb_pos + offset) : void 0;
|
||||||
|
}
|
||||||
|
defaultU64() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 50);
|
||||||
|
return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt("42");
|
||||||
|
}
|
||||||
|
justF32() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 52);
|
||||||
|
return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0;
|
||||||
|
}
|
||||||
|
maybeF32() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 54);
|
||||||
|
return offset ? this.bb.readFloat32(this.bb_pos + offset) : void 0;
|
||||||
|
}
|
||||||
|
defaultF32() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 56);
|
||||||
|
return offset ? this.bb.readFloat32(this.bb_pos + offset) : 42;
|
||||||
|
}
|
||||||
|
justF64() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 58);
|
||||||
|
return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0;
|
||||||
|
}
|
||||||
|
maybeF64() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 60);
|
||||||
|
return offset ? this.bb.readFloat64(this.bb_pos + offset) : void 0;
|
||||||
|
}
|
||||||
|
defaultF64() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 62);
|
||||||
|
return offset ? this.bb.readFloat64(this.bb_pos + offset) : 42;
|
||||||
|
}
|
||||||
|
justBool() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 64);
|
||||||
|
return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;
|
||||||
|
}
|
||||||
|
maybeBool() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 66);
|
||||||
|
return offset ? !!this.bb.readInt8(this.bb_pos + offset) : void 0;
|
||||||
|
}
|
||||||
|
defaultBool() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 68);
|
||||||
|
return offset ? !!this.bb.readInt8(this.bb_pos + offset) : true;
|
||||||
|
}
|
||||||
|
justEnum() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 70);
|
||||||
|
return offset ? this.bb.readInt8(this.bb_pos + offset) : 0 /* None */;
|
||||||
|
}
|
||||||
|
maybeEnum() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 72);
|
||||||
|
return offset ? this.bb.readInt8(this.bb_pos + offset) : void 0;
|
||||||
|
}
|
||||||
|
defaultEnum() {
|
||||||
|
const offset = this.bb.__offset(this.bb_pos, 74);
|
||||||
|
return offset ? this.bb.readInt8(this.bb_pos + offset) : 1 /* One */;
|
||||||
|
}
|
||||||
|
static startScalarStuff(builder) {
|
||||||
|
builder.startObject(36);
|
||||||
|
}
|
||||||
|
static addJustI8(builder, justI8) {
|
||||||
|
builder.addFieldInt8(0, justI8, 0);
|
||||||
|
}
|
||||||
|
static addMaybeI8(builder, maybeI8) {
|
||||||
|
builder.addFieldInt8(1, maybeI8, void 0);
|
||||||
|
}
|
||||||
|
static addDefaultI8(builder, defaultI8) {
|
||||||
|
builder.addFieldInt8(2, defaultI8, 42);
|
||||||
|
}
|
||||||
|
static addJustU8(builder, justU8) {
|
||||||
|
builder.addFieldInt8(3, justU8, 0);
|
||||||
|
}
|
||||||
|
static addMaybeU8(builder, maybeU8) {
|
||||||
|
builder.addFieldInt8(4, maybeU8, void 0);
|
||||||
|
}
|
||||||
|
static addDefaultU8(builder, defaultU8) {
|
||||||
|
builder.addFieldInt8(5, defaultU8, 42);
|
||||||
|
}
|
||||||
|
static addJustI16(builder, justI16) {
|
||||||
|
builder.addFieldInt16(6, justI16, 0);
|
||||||
|
}
|
||||||
|
static addMaybeI16(builder, maybeI16) {
|
||||||
|
builder.addFieldInt16(7, maybeI16, void 0);
|
||||||
|
}
|
||||||
|
static addDefaultI16(builder, defaultI16) {
|
||||||
|
builder.addFieldInt16(8, defaultI16, 42);
|
||||||
|
}
|
||||||
|
static addJustU16(builder, justU16) {
|
||||||
|
builder.addFieldInt16(9, justU16, 0);
|
||||||
|
}
|
||||||
|
static addMaybeU16(builder, maybeU16) {
|
||||||
|
builder.addFieldInt16(10, maybeU16, void 0);
|
||||||
|
}
|
||||||
|
static addDefaultU16(builder, defaultU16) {
|
||||||
|
builder.addFieldInt16(11, defaultU16, 42);
|
||||||
|
}
|
||||||
|
static addJustI32(builder, justI32) {
|
||||||
|
builder.addFieldInt32(12, justI32, 0);
|
||||||
|
}
|
||||||
|
static addMaybeI32(builder, maybeI32) {
|
||||||
|
builder.addFieldInt32(13, maybeI32, void 0);
|
||||||
|
}
|
||||||
|
static addDefaultI32(builder, defaultI32) {
|
||||||
|
builder.addFieldInt32(14, defaultI32, 42);
|
||||||
|
}
|
||||||
|
static addJustU32(builder, justU32) {
|
||||||
|
builder.addFieldInt32(15, justU32, 0);
|
||||||
|
}
|
||||||
|
static addMaybeU32(builder, maybeU32) {
|
||||||
|
builder.addFieldInt32(16, maybeU32, void 0);
|
||||||
|
}
|
||||||
|
static addDefaultU32(builder, defaultU32) {
|
||||||
|
builder.addFieldInt32(17, defaultU32, 42);
|
||||||
|
}
|
||||||
|
static addJustI64(builder, justI64) {
|
||||||
|
builder.addFieldInt64(18, justI64, BigInt("0"));
|
||||||
|
}
|
||||||
|
static addMaybeI64(builder, maybeI64) {
|
||||||
|
builder.addFieldInt64(19, maybeI64, void 0);
|
||||||
|
}
|
||||||
|
static addDefaultI64(builder, defaultI64) {
|
||||||
|
builder.addFieldInt64(20, defaultI64, BigInt("42"));
|
||||||
|
}
|
||||||
|
static addJustU64(builder, justU64) {
|
||||||
|
builder.addFieldInt64(21, justU64, BigInt("0"));
|
||||||
|
}
|
||||||
|
static addMaybeU64(builder, maybeU64) {
|
||||||
|
builder.addFieldInt64(22, maybeU64, void 0);
|
||||||
|
}
|
||||||
|
static addDefaultU64(builder, defaultU64) {
|
||||||
|
builder.addFieldInt64(23, defaultU64, BigInt("42"));
|
||||||
|
}
|
||||||
|
static addJustF32(builder, justF32) {
|
||||||
|
builder.addFieldFloat32(24, justF32, 0);
|
||||||
|
}
|
||||||
|
static addMaybeF32(builder, maybeF32) {
|
||||||
|
builder.addFieldFloat32(25, maybeF32, void 0);
|
||||||
|
}
|
||||||
|
static addDefaultF32(builder, defaultF32) {
|
||||||
|
builder.addFieldFloat32(26, defaultF32, 42);
|
||||||
|
}
|
||||||
|
static addJustF64(builder, justF64) {
|
||||||
|
builder.addFieldFloat64(27, justF64, 0);
|
||||||
|
}
|
||||||
|
static addMaybeF64(builder, maybeF64) {
|
||||||
|
builder.addFieldFloat64(28, maybeF64, void 0);
|
||||||
|
}
|
||||||
|
static addDefaultF64(builder, defaultF64) {
|
||||||
|
builder.addFieldFloat64(29, defaultF64, 42);
|
||||||
|
}
|
||||||
|
static addJustBool(builder, justBool) {
|
||||||
|
builder.addFieldInt8(30, +justBool, 0);
|
||||||
|
}
|
||||||
|
static addMaybeBool(builder, maybeBool) {
|
||||||
|
builder.addFieldInt8(31, +maybeBool, void 0);
|
||||||
|
}
|
||||||
|
static addDefaultBool(builder, defaultBool) {
|
||||||
|
builder.addFieldInt8(32, +defaultBool, 1);
|
||||||
|
}
|
||||||
|
static addJustEnum(builder, justEnum) {
|
||||||
|
builder.addFieldInt8(33, justEnum, 0 /* None */);
|
||||||
|
}
|
||||||
|
static addMaybeEnum(builder, maybeEnum) {
|
||||||
|
builder.addFieldInt8(34, maybeEnum, void 0);
|
||||||
|
}
|
||||||
|
static addDefaultEnum(builder, defaultEnum) {
|
||||||
|
builder.addFieldInt8(35, defaultEnum, 1 /* One */);
|
||||||
|
}
|
||||||
|
static endScalarStuff(builder) {
|
||||||
|
const offset = builder.endObject();
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
static finishScalarStuffBuffer(builder, offset) {
|
||||||
|
builder.finish(offset, "NULL");
|
||||||
|
}
|
||||||
|
static finishSizePrefixedScalarStuffBuffer(builder, offset) {
|
||||||
|
builder.finish(offset, "NULL", true);
|
||||||
|
}
|
||||||
|
static createScalarStuff(builder, justI8, maybeI8, defaultI8, justU8, maybeU8, defaultU8, justI16, maybeI16, defaultI16, justU16, maybeU16, defaultU16, justI32, maybeI32, defaultI32, justU32, maybeU32, defaultU32, justI64, maybeI64, defaultI64, justU64, maybeU64, defaultU64, justF32, maybeF32, defaultF32, justF64, maybeF64, defaultF64, justBool, maybeBool, defaultBool, justEnum, maybeEnum, defaultEnum) {
|
||||||
|
_ScalarStuff.startScalarStuff(builder);
|
||||||
|
_ScalarStuff.addJustI8(builder, justI8);
|
||||||
|
if (maybeI8 !== void 0)
|
||||||
|
_ScalarStuff.addMaybeI8(builder, maybeI8);
|
||||||
|
_ScalarStuff.addDefaultI8(builder, defaultI8);
|
||||||
|
_ScalarStuff.addJustU8(builder, justU8);
|
||||||
|
if (maybeU8 !== void 0)
|
||||||
|
_ScalarStuff.addMaybeU8(builder, maybeU8);
|
||||||
|
_ScalarStuff.addDefaultU8(builder, defaultU8);
|
||||||
|
_ScalarStuff.addJustI16(builder, justI16);
|
||||||
|
if (maybeI16 !== void 0)
|
||||||
|
_ScalarStuff.addMaybeI16(builder, maybeI16);
|
||||||
|
_ScalarStuff.addDefaultI16(builder, defaultI16);
|
||||||
|
_ScalarStuff.addJustU16(builder, justU16);
|
||||||
|
if (maybeU16 !== void 0)
|
||||||
|
_ScalarStuff.addMaybeU16(builder, maybeU16);
|
||||||
|
_ScalarStuff.addDefaultU16(builder, defaultU16);
|
||||||
|
_ScalarStuff.addJustI32(builder, justI32);
|
||||||
|
if (maybeI32 !== void 0)
|
||||||
|
_ScalarStuff.addMaybeI32(builder, maybeI32);
|
||||||
|
_ScalarStuff.addDefaultI32(builder, defaultI32);
|
||||||
|
_ScalarStuff.addJustU32(builder, justU32);
|
||||||
|
if (maybeU32 !== void 0)
|
||||||
|
_ScalarStuff.addMaybeU32(builder, maybeU32);
|
||||||
|
_ScalarStuff.addDefaultU32(builder, defaultU32);
|
||||||
|
_ScalarStuff.addJustI64(builder, justI64);
|
||||||
|
if (maybeI64 !== void 0)
|
||||||
|
_ScalarStuff.addMaybeI64(builder, maybeI64);
|
||||||
|
_ScalarStuff.addDefaultI64(builder, defaultI64);
|
||||||
|
_ScalarStuff.addJustU64(builder, justU64);
|
||||||
|
if (maybeU64 !== void 0)
|
||||||
|
_ScalarStuff.addMaybeU64(builder, maybeU64);
|
||||||
|
_ScalarStuff.addDefaultU64(builder, defaultU64);
|
||||||
|
_ScalarStuff.addJustF32(builder, justF32);
|
||||||
|
if (maybeF32 !== void 0)
|
||||||
|
_ScalarStuff.addMaybeF32(builder, maybeF32);
|
||||||
|
_ScalarStuff.addDefaultF32(builder, defaultF32);
|
||||||
|
_ScalarStuff.addJustF64(builder, justF64);
|
||||||
|
if (maybeF64 !== void 0)
|
||||||
|
_ScalarStuff.addMaybeF64(builder, maybeF64);
|
||||||
|
_ScalarStuff.addDefaultF64(builder, defaultF64);
|
||||||
|
_ScalarStuff.addJustBool(builder, justBool);
|
||||||
|
if (maybeBool !== void 0)
|
||||||
|
_ScalarStuff.addMaybeBool(builder, maybeBool);
|
||||||
|
_ScalarStuff.addDefaultBool(builder, defaultBool);
|
||||||
|
_ScalarStuff.addJustEnum(builder, justEnum);
|
||||||
|
if (maybeEnum !== void 0)
|
||||||
|
_ScalarStuff.addMaybeEnum(builder, maybeEnum);
|
||||||
|
_ScalarStuff.addDefaultEnum(builder, defaultEnum);
|
||||||
|
return _ScalarStuff.endScalarStuff(builder);
|
||||||
|
}
|
||||||
|
unpack() {
|
||||||
|
return new ScalarStuffT(
|
||||||
|
this.justI8(),
|
||||||
|
this.maybeI8(),
|
||||||
|
this.defaultI8(),
|
||||||
|
this.justU8(),
|
||||||
|
this.maybeU8(),
|
||||||
|
this.defaultU8(),
|
||||||
|
this.justI16(),
|
||||||
|
this.maybeI16(),
|
||||||
|
this.defaultI16(),
|
||||||
|
this.justU16(),
|
||||||
|
this.maybeU16(),
|
||||||
|
this.defaultU16(),
|
||||||
|
this.justI32(),
|
||||||
|
this.maybeI32(),
|
||||||
|
this.defaultI32(),
|
||||||
|
this.justU32(),
|
||||||
|
this.maybeU32(),
|
||||||
|
this.defaultU32(),
|
||||||
|
this.justI64(),
|
||||||
|
this.maybeI64(),
|
||||||
|
this.defaultI64(),
|
||||||
|
this.justU64(),
|
||||||
|
this.maybeU64(),
|
||||||
|
this.defaultU64(),
|
||||||
|
this.justF32(),
|
||||||
|
this.maybeF32(),
|
||||||
|
this.defaultF32(),
|
||||||
|
this.justF64(),
|
||||||
|
this.maybeF64(),
|
||||||
|
this.defaultF64(),
|
||||||
|
this.justBool(),
|
||||||
|
this.maybeBool(),
|
||||||
|
this.defaultBool(),
|
||||||
|
this.justEnum(),
|
||||||
|
this.maybeEnum(),
|
||||||
|
this.defaultEnum()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
unpackTo(_o) {
|
||||||
|
_o.justI8 = this.justI8();
|
||||||
|
_o.maybeI8 = this.maybeI8();
|
||||||
|
_o.defaultI8 = this.defaultI8();
|
||||||
|
_o.justU8 = this.justU8();
|
||||||
|
_o.maybeU8 = this.maybeU8();
|
||||||
|
_o.defaultU8 = this.defaultU8();
|
||||||
|
_o.justI16 = this.justI16();
|
||||||
|
_o.maybeI16 = this.maybeI16();
|
||||||
|
_o.defaultI16 = this.defaultI16();
|
||||||
|
_o.justU16 = this.justU16();
|
||||||
|
_o.maybeU16 = this.maybeU16();
|
||||||
|
_o.defaultU16 = this.defaultU16();
|
||||||
|
_o.justI32 = this.justI32();
|
||||||
|
_o.maybeI32 = this.maybeI32();
|
||||||
|
_o.defaultI32 = this.defaultI32();
|
||||||
|
_o.justU32 = this.justU32();
|
||||||
|
_o.maybeU32 = this.maybeU32();
|
||||||
|
_o.defaultU32 = this.defaultU32();
|
||||||
|
_o.justI64 = this.justI64();
|
||||||
|
_o.maybeI64 = this.maybeI64();
|
||||||
|
_o.defaultI64 = this.defaultI64();
|
||||||
|
_o.justU64 = this.justU64();
|
||||||
|
_o.maybeU64 = this.maybeU64();
|
||||||
|
_o.defaultU64 = this.defaultU64();
|
||||||
|
_o.justF32 = this.justF32();
|
||||||
|
_o.maybeF32 = this.maybeF32();
|
||||||
|
_o.defaultF32 = this.defaultF32();
|
||||||
|
_o.justF64 = this.justF64();
|
||||||
|
_o.maybeF64 = this.maybeF64();
|
||||||
|
_o.defaultF64 = this.defaultF64();
|
||||||
|
_o.justBool = this.justBool();
|
||||||
|
_o.maybeBool = this.maybeBool();
|
||||||
|
_o.defaultBool = this.defaultBool();
|
||||||
|
_o.justEnum = this.justEnum();
|
||||||
|
_o.maybeEnum = this.maybeEnum();
|
||||||
|
_o.defaultEnum = this.defaultEnum();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var ScalarStuffT = class {
|
||||||
|
constructor(justI8 = 0, maybeI8 = void 0, defaultI8 = 42, justU8 = 0, maybeU8 = void 0, defaultU8 = 42, justI16 = 0, maybeI16 = void 0, defaultI16 = 42, justU16 = 0, maybeU16 = void 0, defaultU16 = 42, justI32 = 0, maybeI32 = void 0, defaultI32 = 42, justU32 = 0, maybeU32 = void 0, defaultU32 = 42, justI64 = BigInt("0"), maybeI64 = void 0, defaultI64 = BigInt("42"), justU64 = BigInt("0"), maybeU64 = void 0, defaultU64 = BigInt("42"), justF32 = 0, maybeF32 = void 0, defaultF32 = 42, justF64 = 0, maybeF64 = void 0, defaultF64 = 42, justBool = false, maybeBool = void 0, defaultBool = true, justEnum = 0 /* None */, maybeEnum = void 0, defaultEnum = 1 /* One */) {
|
||||||
|
this.justI8 = justI8;
|
||||||
|
this.maybeI8 = maybeI8;
|
||||||
|
this.defaultI8 = defaultI8;
|
||||||
|
this.justU8 = justU8;
|
||||||
|
this.maybeU8 = maybeU8;
|
||||||
|
this.defaultU8 = defaultU8;
|
||||||
|
this.justI16 = justI16;
|
||||||
|
this.maybeI16 = maybeI16;
|
||||||
|
this.defaultI16 = defaultI16;
|
||||||
|
this.justU16 = justU16;
|
||||||
|
this.maybeU16 = maybeU16;
|
||||||
|
this.defaultU16 = defaultU16;
|
||||||
|
this.justI32 = justI32;
|
||||||
|
this.maybeI32 = maybeI32;
|
||||||
|
this.defaultI32 = defaultI32;
|
||||||
|
this.justU32 = justU32;
|
||||||
|
this.maybeU32 = maybeU32;
|
||||||
|
this.defaultU32 = defaultU32;
|
||||||
|
this.justI64 = justI64;
|
||||||
|
this.maybeI64 = maybeI64;
|
||||||
|
this.defaultI64 = defaultI64;
|
||||||
|
this.justU64 = justU64;
|
||||||
|
this.maybeU64 = maybeU64;
|
||||||
|
this.defaultU64 = defaultU64;
|
||||||
|
this.justF32 = justF32;
|
||||||
|
this.maybeF32 = maybeF32;
|
||||||
|
this.defaultF32 = defaultF32;
|
||||||
|
this.justF64 = justF64;
|
||||||
|
this.maybeF64 = maybeF64;
|
||||||
|
this.defaultF64 = defaultF64;
|
||||||
|
this.justBool = justBool;
|
||||||
|
this.maybeBool = maybeBool;
|
||||||
|
this.defaultBool = defaultBool;
|
||||||
|
this.justEnum = justEnum;
|
||||||
|
this.maybeEnum = maybeEnum;
|
||||||
|
this.defaultEnum = defaultEnum;
|
||||||
|
}
|
||||||
|
pack(builder) {
|
||||||
|
return ScalarStuff.createScalarStuff(
|
||||||
|
builder,
|
||||||
|
this.justI8,
|
||||||
|
this.maybeI8,
|
||||||
|
this.defaultI8,
|
||||||
|
this.justU8,
|
||||||
|
this.maybeU8,
|
||||||
|
this.defaultU8,
|
||||||
|
this.justI16,
|
||||||
|
this.maybeI16,
|
||||||
|
this.defaultI16,
|
||||||
|
this.justU16,
|
||||||
|
this.maybeU16,
|
||||||
|
this.defaultU16,
|
||||||
|
this.justI32,
|
||||||
|
this.maybeI32,
|
||||||
|
this.defaultI32,
|
||||||
|
this.justU32,
|
||||||
|
this.maybeU32,
|
||||||
|
this.defaultU32,
|
||||||
|
this.justI64,
|
||||||
|
this.maybeI64,
|
||||||
|
this.defaultI64,
|
||||||
|
this.justU64,
|
||||||
|
this.maybeU64,
|
||||||
|
this.defaultU64,
|
||||||
|
this.justF32,
|
||||||
|
this.maybeF32,
|
||||||
|
this.defaultF32,
|
||||||
|
this.justF64,
|
||||||
|
this.maybeF64,
|
||||||
|
this.defaultF64,
|
||||||
|
this.justBool,
|
||||||
|
this.maybeBool,
|
||||||
|
this.defaultBool,
|
||||||
|
this.justEnum,
|
||||||
|
this.maybeEnum,
|
||||||
|
this.defaultEnum
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -420,6 +420,16 @@ struct D FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const UnionUnderlyingType::C *test_union_as_C() const {
|
const UnionUnderlyingType::C *test_union_as_C() const {
|
||||||
return test_union_type() == UnionUnderlyingType::ABC::C ? static_cast<const UnionUnderlyingType::C *>(test_union()) : nullptr;
|
return test_union_type() == UnionUnderlyingType::ABC::C ? static_cast<const UnionUnderlyingType::C *>(test_union()) : nullptr;
|
||||||
}
|
}
|
||||||
|
template<typename T> T *mutable_test_union_as();
|
||||||
|
UnionUnderlyingType::A *mutable_test_union_as_A() {
|
||||||
|
return test_union_type() == UnionUnderlyingType::ABC::A ? static_cast<UnionUnderlyingType::A *>(mutable_test_union()) : nullptr;
|
||||||
|
}
|
||||||
|
UnionUnderlyingType::B *mutable_test_union_as_B() {
|
||||||
|
return test_union_type() == UnionUnderlyingType::ABC::B ? static_cast<UnionUnderlyingType::B *>(mutable_test_union()) : nullptr;
|
||||||
|
}
|
||||||
|
UnionUnderlyingType::C *mutable_test_union_as_C() {
|
||||||
|
return test_union_type() == UnionUnderlyingType::ABC::C ? static_cast<UnionUnderlyingType::C *>(mutable_test_union()) : nullptr;
|
||||||
|
}
|
||||||
void *mutable_test_union() {
|
void *mutable_test_union() {
|
||||||
return GetPointer<void *>(VT_TEST_UNION);
|
return GetPointer<void *>(VT_TEST_UNION);
|
||||||
}
|
}
|
||||||
@@ -457,14 +467,26 @@ template<> inline const UnionUnderlyingType::A *D::test_union_as<UnionUnderlying
|
|||||||
return test_union_as_A();
|
return test_union_as_A();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline UnionUnderlyingType::A *D::mutable_test_union_as<UnionUnderlyingType::A>() {
|
||||||
|
return mutable_test_union_as_A();
|
||||||
|
}
|
||||||
|
|
||||||
template<> inline const UnionUnderlyingType::B *D::test_union_as<UnionUnderlyingType::B>() const {
|
template<> inline const UnionUnderlyingType::B *D::test_union_as<UnionUnderlyingType::B>() const {
|
||||||
return test_union_as_B();
|
return test_union_as_B();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline UnionUnderlyingType::B *D::mutable_test_union_as<UnionUnderlyingType::B>() {
|
||||||
|
return mutable_test_union_as_B();
|
||||||
|
}
|
||||||
|
|
||||||
template<> inline const UnionUnderlyingType::C *D::test_union_as<UnionUnderlyingType::C>() const {
|
template<> inline const UnionUnderlyingType::C *D::test_union_as<UnionUnderlyingType::C>() const {
|
||||||
return test_union_as_C();
|
return test_union_as_C();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline UnionUnderlyingType::C *D::mutable_test_union_as<UnionUnderlyingType::C>() {
|
||||||
|
return mutable_test_union_as_C();
|
||||||
|
}
|
||||||
|
|
||||||
struct DBuilder {
|
struct DBuilder {
|
||||||
typedef D Table;
|
typedef D Table;
|
||||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||||
|
|||||||
@@ -623,6 +623,24 @@ struct Movie FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const ::flatbuffers::String *main_character_as_Unused() const {
|
const ::flatbuffers::String *main_character_as_Unused() const {
|
||||||
return main_character_type() == Character_Unused ? static_cast<const ::flatbuffers::String *>(main_character()) : nullptr;
|
return main_character_type() == Character_Unused ? static_cast<const ::flatbuffers::String *>(main_character()) : nullptr;
|
||||||
}
|
}
|
||||||
|
Attacker *mutable_main_character_as_MuLan() {
|
||||||
|
return main_character_type() == Character_MuLan ? static_cast<Attacker *>(mutable_main_character()) : nullptr;
|
||||||
|
}
|
||||||
|
Rapunzel *mutable_main_character_as_Rapunzel() {
|
||||||
|
return main_character_type() == Character_Rapunzel ? static_cast<Rapunzel *>(mutable_main_character()) : nullptr;
|
||||||
|
}
|
||||||
|
BookReader *mutable_main_character_as_Belle() {
|
||||||
|
return main_character_type() == Character_Belle ? static_cast<BookReader *>(mutable_main_character()) : nullptr;
|
||||||
|
}
|
||||||
|
BookReader *mutable_main_character_as_BookFan() {
|
||||||
|
return main_character_type() == Character_BookFan ? static_cast<BookReader *>(mutable_main_character()) : nullptr;
|
||||||
|
}
|
||||||
|
::flatbuffers::String *mutable_main_character_as_Other() {
|
||||||
|
return main_character_type() == Character_Other ? static_cast<::flatbuffers::String *>(mutable_main_character()) : nullptr;
|
||||||
|
}
|
||||||
|
::flatbuffers::String *mutable_main_character_as_Unused() {
|
||||||
|
return main_character_type() == Character_Unused ? static_cast<::flatbuffers::String *>(mutable_main_character()) : nullptr;
|
||||||
|
}
|
||||||
void *mutable_main_character() {
|
void *mutable_main_character() {
|
||||||
return GetPointer<void *>(VT_MAIN_CHARACTER);
|
return GetPointer<void *>(VT_MAIN_CHARACTER);
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-11
@@ -212,7 +212,7 @@ export class Builder {
|
|||||||
addFieldInt8(
|
addFieldInt8(
|
||||||
voffset: number,
|
voffset: number,
|
||||||
value: number,
|
value: number,
|
||||||
defaultValue: number | null,
|
defaultValue: number | null | undefined,
|
||||||
): void {
|
): void {
|
||||||
if (this.force_defaults || value != defaultValue) {
|
if (this.force_defaults || value != defaultValue) {
|
||||||
this.addInt8(value);
|
this.addInt8(value);
|
||||||
@@ -223,7 +223,7 @@ export class Builder {
|
|||||||
addFieldInt16(
|
addFieldInt16(
|
||||||
voffset: number,
|
voffset: number,
|
||||||
value: number,
|
value: number,
|
||||||
defaultValue: number | null,
|
defaultValue: number | null | undefined,
|
||||||
): void {
|
): void {
|
||||||
if (this.force_defaults || value != defaultValue) {
|
if (this.force_defaults || value != defaultValue) {
|
||||||
this.addInt16(value);
|
this.addInt16(value);
|
||||||
@@ -234,7 +234,7 @@ export class Builder {
|
|||||||
addFieldInt32(
|
addFieldInt32(
|
||||||
voffset: number,
|
voffset: number,
|
||||||
value: number,
|
value: number,
|
||||||
defaultValue: number | null,
|
defaultValue: number | null | undefined,
|
||||||
): void {
|
): void {
|
||||||
if (this.force_defaults || value != defaultValue) {
|
if (this.force_defaults || value != defaultValue) {
|
||||||
this.addInt32(value);
|
this.addInt32(value);
|
||||||
@@ -245,7 +245,7 @@ export class Builder {
|
|||||||
addFieldInt64(
|
addFieldInt64(
|
||||||
voffset: number,
|
voffset: number,
|
||||||
value: bigint,
|
value: bigint,
|
||||||
defaultValue: bigint | null,
|
defaultValue: bigint | null | undefined,
|
||||||
): void {
|
): void {
|
||||||
if (this.force_defaults || value !== defaultValue) {
|
if (this.force_defaults || value !== defaultValue) {
|
||||||
this.addInt64(value);
|
this.addInt64(value);
|
||||||
@@ -256,7 +256,7 @@ export class Builder {
|
|||||||
addFieldFloat32(
|
addFieldFloat32(
|
||||||
voffset: number,
|
voffset: number,
|
||||||
value: number,
|
value: number,
|
||||||
defaultValue: number | null,
|
defaultValue: number | null | undefined,
|
||||||
): void {
|
): void {
|
||||||
if (this.force_defaults || value != defaultValue) {
|
if (this.force_defaults || value != defaultValue) {
|
||||||
this.addFloat32(value);
|
this.addFloat32(value);
|
||||||
@@ -267,7 +267,7 @@ export class Builder {
|
|||||||
addFieldFloat64(
|
addFieldFloat64(
|
||||||
voffset: number,
|
voffset: number,
|
||||||
value: number,
|
value: number,
|
||||||
defaultValue: number | null,
|
defaultValue: number | null | undefined,
|
||||||
): void {
|
): void {
|
||||||
if (this.force_defaults || value != defaultValue) {
|
if (this.force_defaults || value != defaultValue) {
|
||||||
this.addFloat64(value);
|
this.addFloat64(value);
|
||||||
@@ -614,8 +614,8 @@ export class Builder {
|
|||||||
*
|
*
|
||||||
* @returns offset of obj
|
* @returns offset of obj
|
||||||
*/
|
*/
|
||||||
createObjectOffset(obj: string | IGeneratedObject | null): Offset {
|
createObjectOffset(obj: string | IGeneratedObject | null | undefined): Offset {
|
||||||
if (obj === null) {
|
if (obj === null || obj === undefined) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -629,7 +629,7 @@ export class Builder {
|
|||||||
/**
|
/**
|
||||||
* A helper function to pack a list of object
|
* A helper function to pack a list of object
|
||||||
*
|
*
|
||||||
* @returns list of offsets of each non null object
|
* @returns list of offsets of each non null/undefined object
|
||||||
*/
|
*/
|
||||||
createObjectOffsetList(list: (string | IGeneratedObject)[]): Offset[] {
|
createObjectOffsetList(list: (string | IGeneratedObject)[]): Offset[] {
|
||||||
const ret: number[] = [];
|
const ret: number[] = [];
|
||||||
@@ -637,11 +637,11 @@ export class Builder {
|
|||||||
for (let i = 0; i < list.length; ++i) {
|
for (let i = 0; i < list.length; ++i) {
|
||||||
const val = list[i];
|
const val = list[i];
|
||||||
|
|
||||||
if (val !== null) {
|
if (val !== null && val !== undefined) {
|
||||||
ret.push(this.createObjectOffset(val));
|
ret.push(this.createObjectOffset(val));
|
||||||
} else {
|
} else {
|
||||||
throw new TypeError(
|
throw new TypeError(
|
||||||
'FlatBuffers: Argument for createObjectOffsetList cannot contain null.',
|
'FlatBuffers: Argument for createObjectOffsetList cannot contain null or undefined.',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user