forked from BigfootDev/flatbuffers
Compare commits
37 Commits
bigfoot
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
400711102f | ||
|
|
8396e00dd8 | ||
|
|
48babd417d | ||
|
|
22770f7e85 | ||
|
|
21b033227e | ||
|
|
93f587a6d3 | ||
|
|
8afb68f074 | ||
|
|
2e07f269b9 | ||
|
|
10c994155c | ||
|
|
fc9909c30a | ||
|
|
e35817577c | ||
|
|
9e3fe5d3f6 | ||
|
|
dc9217347e | ||
|
|
a7fed2ce67 | ||
|
|
de3b97355d | ||
|
|
8aa7084f01 | ||
|
|
0f469cad54 | ||
|
|
72e51c61f7 | ||
|
|
31590a8a3b | ||
|
|
24c2432d99 | ||
|
|
292870612c | ||
|
|
57659d9f38 | ||
|
|
2b8e4d3af0 | ||
|
|
08b6372a36 | ||
|
|
9c383559e0 | ||
|
|
c13c3bf956 | ||
|
|
47eeb8f4e9 | ||
|
|
e7c6874192 | ||
|
|
8d2c333b36 | ||
|
|
abc9bfebff | ||
|
|
94d6b8086b | ||
|
|
fa709636b4 | ||
|
|
60463e25a8 | ||
|
|
b8e3d215b8 | ||
|
|
d71c0ab4ac | ||
|
|
fcf75449b8 | ||
|
|
c21bda1649 |
6
.github/dependabot.yml
vendored
Normal file
6
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
26
.github/workflows/build.yml
vendored
26
.github/workflows/build.yml
vendored
@@ -42,7 +42,7 @@ jobs:
|
|||||||
chmod +x flatc
|
chmod +x flatc
|
||||||
./flatc --version
|
./flatc --version
|
||||||
- name: upload build artifacts
|
- name: upload build artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: Linux flatc binary ${{ matrix.cxx }}
|
name: Linux flatc binary ${{ matrix.cxx }}
|
||||||
path: flatc
|
path: flatc
|
||||||
@@ -137,7 +137,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
- name: Add msbuild to PATH
|
- name: Add msbuild to PATH
|
||||||
uses: microsoft/setup-msbuild@v2
|
uses: microsoft/setup-msbuild@v3
|
||||||
- name: cmake
|
- name: cmake
|
||||||
run: >
|
run: >
|
||||||
cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release
|
cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release
|
||||||
@@ -162,7 +162,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
- name: Add msbuild to PATH
|
- name: Add msbuild to PATH
|
||||||
uses: microsoft/setup-msbuild@v2
|
uses: microsoft/setup-msbuild@v3
|
||||||
- name: cmake
|
- name: cmake
|
||||||
run: cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_CPP17=ON -DFLATBUFFERS_STRICT_MODE=ON .
|
run: cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_CPP17=ON -DFLATBUFFERS_STRICT_MODE=ON .
|
||||||
- name: build
|
- name: build
|
||||||
@@ -170,7 +170,7 @@ jobs:
|
|||||||
- name: test
|
- name: test
|
||||||
run: Release\flattests.exe
|
run: Release\flattests.exe
|
||||||
- name: upload build artifacts
|
- name: upload build artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: Windows flatc binary
|
name: Windows flatc binary
|
||||||
path: Release\flatc.exe
|
path: Release\flatc.exe
|
||||||
@@ -191,7 +191,7 @@ jobs:
|
|||||||
|
|
||||||
build-dotnet-windows:
|
build-dotnet-windows:
|
||||||
name: Build .NET Windows
|
name: Build .NET Windows
|
||||||
runs-on: windows-2022-64core
|
runs-on: windows-2022
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
configuration: [
|
configuration: [
|
||||||
@@ -246,7 +246,7 @@ jobs:
|
|||||||
chmod +x Release/flatc
|
chmod +x Release/flatc
|
||||||
Release/flatc --version
|
Release/flatc --version
|
||||||
- name: upload build artifacts
|
- name: upload build artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: Mac flatc binary Intel
|
name: Mac flatc binary Intel
|
||||||
path: Release/flatc
|
path: Release/flatc
|
||||||
@@ -289,7 +289,7 @@ jobs:
|
|||||||
chmod +x Release/flatc
|
chmod +x Release/flatc
|
||||||
Release/flatc --version
|
Release/flatc --version
|
||||||
- name: upload build artifacts
|
- name: upload build artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: Mac flatc binary Universal
|
name: Mac flatc binary Universal
|
||||||
path: Release/flatc
|
path: Release/flatc
|
||||||
@@ -314,7 +314,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
- name: set up Java
|
- name: set up Java
|
||||||
uses: actions/setup-java@v4
|
uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17
|
java-version: 17
|
||||||
@@ -350,7 +350,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
- name: Add msbuild to PATH
|
- name: Add msbuild to PATH
|
||||||
uses: microsoft/setup-msbuild@v2
|
uses: microsoft/setup-msbuild@v3
|
||||||
- name: cmake
|
- name: cmake
|
||||||
run: cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_CPP17=ON -DFLATBUFFERS_STRICT_MODE=ON .
|
run: cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_CPP17=ON -DFLATBUFFERS_STRICT_MODE=ON .
|
||||||
- name: build
|
- name: build
|
||||||
@@ -373,7 +373,7 @@ jobs:
|
|||||||
- name: Run benchmarks
|
- name: Run benchmarks
|
||||||
run: ./flatbenchmark --benchmark_repetitions=5 --benchmark_display_aggregates_only=true --benchmark_out_format=console --benchmark_out=benchmarks/results_${{matrix.cxx}}
|
run: ./flatbenchmark --benchmark_repetitions=5 --benchmark_display_aggregates_only=true --benchmark_out_format=console --benchmark_out=benchmarks/results_${{matrix.cxx}}
|
||||||
- name: Upload benchmarks results
|
- name: Upload benchmarks results
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: Linux flatbenchmark results ${{matrix.cxx}}
|
name: Linux flatbenchmark results ${{matrix.cxx}}
|
||||||
path: benchmarks/results_${{matrix.cxx}}
|
path: benchmarks/results_${{matrix.cxx}}
|
||||||
@@ -394,7 +394,7 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
- name: set up Java
|
- name: set up Java
|
||||||
uses: actions/setup-java@v4
|
uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17
|
java-version: 17
|
||||||
@@ -417,7 +417,7 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
- name: set up Java
|
- name: set up Java
|
||||||
uses: actions/setup-java@v4
|
uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17
|
java-version: 17
|
||||||
@@ -446,7 +446,7 @@ jobs:
|
|||||||
|
|
||||||
build-rust-windows:
|
build-rust-windows:
|
||||||
name: Build Rust Windows
|
name: Build Rust Windows
|
||||||
runs-on: windows-2022-64core
|
runs-on: windows-2022
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
- name: test
|
- name: test
|
||||||
|
|||||||
4
.github/workflows/docs.yml
vendored
4
.github/workflows/docs.yml
vendored
@@ -21,11 +21,11 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
git config user.name github-actions[bot]
|
git config user.name github-actions[bot]
|
||||||
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
|
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
|
||||||
- uses: actions/setup-python@v5
|
- uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
python-version: 3.x
|
python-version: 3.x
|
||||||
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
|
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
|
||||||
- uses: actions/cache@v4
|
- uses: actions/cache@v5
|
||||||
with:
|
with:
|
||||||
key: mkdocs-material-${{ env.cache_id }}
|
key: mkdocs-material-${{ env.cache_id }}
|
||||||
path: .cache
|
path: .cache
|
||||||
|
|||||||
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@@ -27,7 +27,7 @@ jobs:
|
|||||||
language: c++
|
language: c++
|
||||||
fuzz-seconds: 60
|
fuzz-seconds: 60
|
||||||
- name: Upload Crash
|
- name: Upload Crash
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v7
|
||||||
if: failure() && steps.build.outcome == 'success'
|
if: failure() && steps.build.outcome == 'success'
|
||||||
with:
|
with:
|
||||||
name: artifacts
|
name: artifacts
|
||||||
|
|||||||
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: '20.x'
|
node-version: '20.x'
|
||||||
registry-url: 'https://registry.npmjs.org'
|
registry-url: 'https://registry.npmjs.org'
|
||||||
@@ -30,7 +30,7 @@ jobs:
|
|||||||
working-directory: ./python
|
working-directory: ./python
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
- uses: actions/setup-python@v4
|
- uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
python-version: '3.10'
|
python-version: '3.10'
|
||||||
|
|
||||||
|
|||||||
@@ -240,9 +240,6 @@ set(FlatBuffers_Tests_SRCS
|
|||||||
tests/vector_table_naked_ptr_test.cpp
|
tests/vector_table_naked_ptr_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/cpp_vec_type_test_impl.h
|
|
||||||
tests/cpp_vec_type_native_type_test_impl.h
|
|
||||||
tests/cpp_vec_type_native_type_test_impl.cpp
|
|
||||||
tests/alignment_test.h
|
tests/alignment_test.h
|
||||||
tests/alignment_test.cpp
|
tests/alignment_test.cpp
|
||||||
tests/64bit/offset64_test.h
|
tests/64bit/offset64_test.h
|
||||||
@@ -557,13 +554,12 @@ if(FLATBUFFERS_BUILD_TESTS)
|
|||||||
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/cpp_vec_type_test.fbs "${FLATC_OPT_COMP}")
|
|
||||||
compile_schema_for_test(tests/cpp_vec_type_native_type_test.fbs "${FLATC_OPT_COMP}")
|
|
||||||
compile_schema_for_test(tests/key_field/key_field_sample.fbs "${FLATC_OPT_COMP}")
|
compile_schema_for_test(tests/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/cross_namespace_pack_test.fbs "${FLATC_OPT_COMP}")
|
||||||
|
|
||||||
if(FLATBUFFERS_CODE_SANITIZE)
|
if(FLATBUFFERS_CODE_SANITIZE)
|
||||||
add_fsanitize_to_target(flattests ${FLATBUFFERS_CODE_SANITIZE})
|
add_fsanitize_to_target(flattests ${FLATBUFFERS_CODE_SANITIZE})
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ bazel_dep(
|
|||||||
)
|
)
|
||||||
bazel_dep(
|
bazel_dep(
|
||||||
name = "grpc",
|
name = "grpc",
|
||||||
version = "1.70.1",
|
version = "1.76.0",
|
||||||
repo_name = "com_github_grpc_grpc",
|
repo_name = "com_github_grpc_grpc",
|
||||||
)
|
)
|
||||||
bazel_dep(
|
bazel_dep(
|
||||||
@@ -49,7 +49,7 @@ bazel_dep(
|
|||||||
)
|
)
|
||||||
bazel_dep(
|
bazel_dep(
|
||||||
name = "rules_swift",
|
name = "rules_swift",
|
||||||
version = "2.1.1",
|
version = "3.1.2",
|
||||||
max_compatibility_level = 3,
|
max_compatibility_level = 3,
|
||||||
repo_name = "build_bazel_rules_swift",
|
repo_name = "build_bazel_rules_swift",
|
||||||
)
|
)
|
||||||
@@ -63,9 +63,6 @@ npm.npm_translate_lock(
|
|||||||
name = "flatbuffers_npm",
|
name = "flatbuffers_npm",
|
||||||
npmrc = "//:.npmrc",
|
npmrc = "//:.npmrc",
|
||||||
pnpm_lock = "//ts:pnpm-lock.yaml",
|
pnpm_lock = "//ts:pnpm-lock.yaml",
|
||||||
# Override the Bazel package where pnpm-lock.yaml is located and link
|
|
||||||
# to the specified package instead.
|
|
||||||
root_package = "ts",
|
|
||||||
verify_node_modules_ignored = "//:.bazelignore",
|
verify_node_modules_ignored = "//:.bazelignore",
|
||||||
)
|
)
|
||||||
use_repo(npm, "flatbuffers_npm")
|
use_repo(npm, "flatbuffers_npm")
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import 'types.dart';
|
|||||||
|
|
||||||
/// The main builder class for creation of a FlexBuffer.
|
/// The main builder class for creation of a FlexBuffer.
|
||||||
class Builder {
|
class Builder {
|
||||||
final ByteData _buffer;
|
ByteData _buffer;
|
||||||
List<_StackValue> _stack = [];
|
List<_StackValue> _stack = [];
|
||||||
List<_StackPointer> _stackPointers = [];
|
List<_StackPointer> _stackPointers = [];
|
||||||
int _offset = 0;
|
int _offset = 0;
|
||||||
@@ -506,6 +506,7 @@ class Builder {
|
|||||||
if (prevSize < size) {
|
if (prevSize < size) {
|
||||||
final newBuf = ByteData(size);
|
final newBuf = ByteData(size);
|
||||||
newBuf.buffer.asUint8List().setAll(0, _buffer.buffer.asUint8List());
|
newBuf.buffer.asUint8List().setAll(0, _buffer.buffer.asUint8List());
|
||||||
|
_buffer = newBuf;
|
||||||
}
|
}
|
||||||
return newOffset;
|
return newOffset;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -318,6 +318,21 @@ void main() {
|
|||||||
1,
|
1,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
// Default buffer is 2048 bytes, add 2300 bytes of strings that force it
|
||||||
|
// to grow.
|
||||||
|
final s1 = 'A' * 1000;
|
||||||
|
final s2 = 'B' * 800;
|
||||||
|
final s3 = 'C' * 500;
|
||||||
|
|
||||||
|
var flx = Builder()
|
||||||
|
..startVector()
|
||||||
|
..addString(s1)
|
||||||
|
..addString(s2)
|
||||||
|
..addString(s3)
|
||||||
|
..end();
|
||||||
|
expect(flx.finish().length, 2323);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('build map', () {
|
test('build map', () {
|
||||||
|
|||||||
@@ -205,6 +205,47 @@ And example of usage, for the time being, can be found in
|
|||||||
- Safe getters in [SafeBuffer](https://docs.rs/flatbuffers-reflection/latest/flatbuffers_reflection/struct.SafeBuffer.html),
|
- Safe getters in [SafeBuffer](https://docs.rs/flatbuffers-reflection/latest/flatbuffers_reflection/struct.SafeBuffer.html),
|
||||||
which does verification when constructed so you can use it for any data source
|
which does verification when constructed so you can use it for any data source
|
||||||
|
|
||||||
|
## Buffer pre allocation in a latency-sensitive context
|
||||||
|
|
||||||
|
In latency-sensitive applications, dynamic memory allocations can introduce unpredictable latency spikes. The `FlatBufferBuilder` internally uses several `Vec`s that may reallocate during serialization:
|
||||||
|
|
||||||
|
- The backing buffer for the FlatBuffer data
|
||||||
|
- `field_locs` for tracking field locations within tables
|
||||||
|
- `written_vtable_revpos` for deduplicating vtables
|
||||||
|
- `strings_pool` for shared string interning
|
||||||
|
|
||||||
|
To avoid allocations during serialization, you can preallocate all internal vectors upfront using the `with_internal_capacity` constructor:
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.rs}
|
||||||
|
// Preallocate: 1KB buffer, 8 field locations, 16 vtables, 32 shared strings
|
||||||
|
let mut builder = FlatBufferBuilder::with_internal_capacity(1024, 8, 16, 32);
|
||||||
|
|
||||||
|
// All subsequent operations will not allocate (if capacities are sufficient)
|
||||||
|
let name = builder.create_shared_string("MyMonster");
|
||||||
|
// ... build your FlatBuffer ...
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
There are three variants available:
|
||||||
|
|
||||||
|
- `with_internal_capacity(size, field_locs, vtables, strings)` - Creates a new builder with all capacities preallocated
|
||||||
|
- `from_vec_with_internal_capacity(buffer, field_locs, vtables, strings)` - Reuses an existing `Vec<u8>` as the backing buffer
|
||||||
|
- `new_in_with_internal_capacity(allocator, field_locs, vtables, strings)` - Uses a custom `Allocator` with preallocated internal vecs
|
||||||
|
|
||||||
|
When combined with `reset()`, you can reuse the same builder across multiple serializations without any allocations after the initial setup:
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.rs}
|
||||||
|
let mut builder = FlatBufferBuilder::with_internal_capacity(1024, 8, 16, 32);
|
||||||
|
|
||||||
|
loop {
|
||||||
|
// Build a FlatBuffer (allocation-free if capacities are sufficient)
|
||||||
|
let data = build_message(&mut builder);
|
||||||
|
send(data);
|
||||||
|
|
||||||
|
// Reset for reuse - clears state but retains allocated capacity
|
||||||
|
builder.reset();
|
||||||
|
}
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
## Useful tools created by others
|
## Useful tools created by others
|
||||||
|
|
||||||
* [flatc-rust](https://github.com/frol/flatc-rust) - FlatBuffers compiler
|
* [flatc-rust](https://github.com/frol/flatc-rust) - FlatBuffers compiler
|
||||||
|
|||||||
@@ -427,9 +427,6 @@ Current understood attributes:
|
|||||||
it won't be accessible anymore by newer code. Note that if you deprecate a
|
it won't be accessible anymore by newer code. Note that if you deprecate a
|
||||||
field that was previous required, old code may fail to validate new data (when
|
field that was previous required, old code may fail to validate new data (when
|
||||||
using the optional verifier).
|
using the optional verifier).
|
||||||
|
|
||||||
### `required`
|
|
||||||
|
|
||||||
- `required` (on a non-scalar table field): this field must always be set. By
|
- `required` (on a non-scalar table field): this field must always be set. By
|
||||||
default, fields do not need to be present in the binary. This is desirable, as
|
default, fields do not need to be present in the binary. This is desirable, as
|
||||||
it helps with forwards/backwards compatibility, and flexibility of data
|
it helps with forwards/backwards compatibility, and flexibility of data
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ Simple mutation | Yes | Yes | Yes | Yes | No | No
|
|||||||
Reflection | Yes | No | No | No | No | No | No | Basic | No | No | No | No | No
|
Reflection | Yes | No | No | No | No | No | No | Basic | No | No | No | No | No
|
||||||
Buffer verifier | Yes | No | No | No | No | No | No | Yes | No | No | No | No | Yes
|
Buffer verifier | Yes | No | No | No | No | No | No | Yes | No | No | No | No | Yes
|
||||||
Native Object API | Yes | No | Yes | Yes | Yes | Yes | Yes | No | No | Yes | No | No | Yes
|
Native Object API | Yes | No | Yes | Yes | Yes | Yes | Yes | No | No | Yes | No | No | Yes
|
||||||
Optional Scalars | Yes | Yes | Yes | No | No | Yes | Yes | Yes | No | No | Yes | Yes | Yes
|
Optional Scalars | Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | No | No | Yes | Yes | Yes
|
||||||
Flexbuffers | Yes | Yes | ? | ? | ? | ? | ? | ? | ? | ? | ? | Yes | Yes
|
Flexbuffers | Yes | Yes | ? | ? | ? | ? | ? | ? | ? | ? | ? | Yes | Yes
|
||||||
Testing: basic | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | ? | Yes | Yes | Yes | Yes
|
Testing: basic | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | ? | Yes | Yes | Yes | Yes
|
||||||
Testing: fuzz | Yes | No | No | Yes | Yes | No | No | No | ? | No | No | Yes | No
|
Testing: fuzz | Yes | No | No | Yes | Yes | No | No | No | ? | No | No | Yes | No
|
||||||
|
|||||||
@@ -1,26 +1,25 @@
|
|||||||
// 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;
|
extern crate alloc;
|
||||||
|
|
||||||
#[allow(unused_imports, dead_code)]
|
#[allow(unused_imports, dead_code)]
|
||||||
pub mod goldens {
|
pub mod goldens {
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
pub enum GalaxyOffset {}
|
pub enum GalaxyOffset {}
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
pub struct Galaxy<'a> {
|
pub struct Galaxy<'a> {
|
||||||
pub _tab: ::flatbuffers::Table<'a>,
|
pub _tab: ::flatbuffers::Table<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for Galaxy<'a> {
|
impl<'a> ::flatbuffers::Follow<'a> for Galaxy<'a> {
|
||||||
type Inner = Galaxy<'a>;
|
type Inner = Galaxy<'a>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||||
@@ -34,6 +33,7 @@ impl<'a> Galaxy<'a> {
|
|||||||
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||||
Galaxy { _tab: table }
|
Galaxy { _tab: table }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||||
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||||
@@ -65,9 +65,11 @@ impl ::flatbuffers::Verifiable for Galaxy<'_> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct GalaxyArgs {
|
pub struct GalaxyArgs {
|
||||||
pub num_stars: i64,
|
pub num_stars: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Default for GalaxyArgs {
|
impl<'a> Default for GalaxyArgs {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
@@ -81,11 +83,13 @@ pub struct GalaxyBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
|
|||||||
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> GalaxyBuilder<'a, 'b, A> {
|
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> GalaxyBuilder<'a, 'b, A> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_num_stars(&mut self, num_stars: i64) {
|
pub fn add_num_stars(&mut self, num_stars: i64) {
|
||||||
self.fbb_.push_slot::<i64>(Galaxy::VT_NUM_STARS, num_stars, 0);
|
self.fbb_.push_slot::<i64>(Galaxy::VT_NUM_STARS, num_stars, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> GalaxyBuilder<'a, 'b, A> {
|
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> GalaxyBuilder<'a, 'b, A> {
|
||||||
let start = _fbb.start_table();
|
let start = _fbb.start_table();
|
||||||
@@ -94,6 +98,7 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> GalaxyBuilder<'a, 'b, A> {
|
|||||||
start_: start,
|
start_: start,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn finish(self) -> ::flatbuffers::WIPOffset<Galaxy<'a>> {
|
pub fn finish(self) -> ::flatbuffers::WIPOffset<Galaxy<'a>> {
|
||||||
let o = self.fbb_.end_table(self.start_);
|
let o = self.fbb_.end_table(self.start_);
|
||||||
@@ -108,15 +113,17 @@ impl ::core::fmt::Debug for Galaxy<'_> {
|
|||||||
ds.finish()
|
ds.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub enum UniverseOffset {}
|
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
|
||||||
|
|
||||||
|
pub enum UniverseOffset {}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
pub struct Universe<'a> {
|
pub struct Universe<'a> {
|
||||||
pub _tab: ::flatbuffers::Table<'a>,
|
pub _tab: ::flatbuffers::Table<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for Universe<'a> {
|
impl<'a> ::flatbuffers::Follow<'a> for Universe<'a> {
|
||||||
type Inner = Universe<'a>;
|
type Inner = Universe<'a>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||||
@@ -131,6 +138,7 @@ impl<'a> Universe<'a> {
|
|||||||
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||||
Universe { _tab: table }
|
Universe { _tab: table }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||||
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||||
@@ -150,6 +158,7 @@ impl<'a> Universe<'a> {
|
|||||||
// which contains a valid value in this slot
|
// which contains a valid value in this slot
|
||||||
unsafe { self._tab.get::<f64>(Universe::VT_AGE, Some(0.0)).unwrap()}
|
unsafe { self._tab.get::<f64>(Universe::VT_AGE, Some(0.0)).unwrap()}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn galaxies(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Galaxy<'a>>>> {
|
pub fn galaxies(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Galaxy<'a>>>> {
|
||||||
// Safety:
|
// Safety:
|
||||||
@@ -171,10 +180,12 @@ impl ::flatbuffers::Verifiable for Universe<'_> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct UniverseArgs<'a> {
|
pub struct UniverseArgs<'a> {
|
||||||
pub age: f64,
|
pub age: f64,
|
||||||
pub galaxies: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Galaxy<'a>>>>>,
|
pub galaxies: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Galaxy<'a>>>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Default for UniverseArgs<'a> {
|
impl<'a> Default for UniverseArgs<'a> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
@@ -189,15 +200,18 @@ pub struct UniverseBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
|
|||||||
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> UniverseBuilder<'a, 'b, A> {
|
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> UniverseBuilder<'a, 'b, A> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_age(&mut self, age: f64) {
|
pub fn add_age(&mut self, age: f64) {
|
||||||
self.fbb_.push_slot::<f64>(Universe::VT_AGE, age, 0.0);
|
self.fbb_.push_slot::<f64>(Universe::VT_AGE, age, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_galaxies(&mut self, galaxies: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<Galaxy<'b >>>>) {
|
pub fn add_galaxies(&mut self, galaxies: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<Galaxy<'b >>>>) {
|
||||||
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Universe::VT_GALAXIES, galaxies);
|
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Universe::VT_GALAXIES, galaxies);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> UniverseBuilder<'a, 'b, A> {
|
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> UniverseBuilder<'a, 'b, A> {
|
||||||
let start = _fbb.start_table();
|
let start = _fbb.start_table();
|
||||||
@@ -206,6 +220,7 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> UniverseBuilder<'a, 'b, A> {
|
|||||||
start_: start,
|
start_: start,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn finish(self) -> ::flatbuffers::WIPOffset<Universe<'a>> {
|
pub fn finish(self) -> ::flatbuffers::WIPOffset<Universe<'a>> {
|
||||||
let o = self.fbb_.end_table(self.start_);
|
let o = self.fbb_.end_table(self.start_);
|
||||||
@@ -221,77 +236,87 @@ impl ::core::fmt::Debug for Universe<'_> {
|
|||||||
ds.finish()
|
ds.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[inline]
|
|
||||||
/// Verifies that a buffer of bytes contains a `Universe`
|
/// Verifies that a buffer of bytes contains a `Universe`
|
||||||
/// and returns it.
|
/// and returns it.
|
||||||
/// Note that verification is still experimental and may not
|
/// Note that verification is still experimental and may not
|
||||||
/// catch every error, or be maximally performant. For the
|
/// catch every error, or be maximally performant. For the
|
||||||
/// previous, unchecked, behavior use
|
/// previous, unchecked, behavior use
|
||||||
/// `root_as_universe_unchecked`.
|
/// `root_as_universe_unchecked`.
|
||||||
|
#[inline]
|
||||||
pub fn root_as_universe(buf: &[u8]) -> Result<Universe<'_>, ::flatbuffers::InvalidFlatbuffer> {
|
pub fn root_as_universe(buf: &[u8]) -> Result<Universe<'_>, ::flatbuffers::InvalidFlatbuffer> {
|
||||||
::flatbuffers::root::<Universe>(buf)
|
::flatbuffers::root::<Universe>(buf)
|
||||||
}
|
}
|
||||||
#[inline]
|
|
||||||
/// Verifies that a buffer of bytes contains a size prefixed
|
/// Verifies that a buffer of bytes contains a size prefixed
|
||||||
/// `Universe` and returns it.
|
/// `Universe` and returns it.
|
||||||
/// Note that verification is still experimental and may not
|
/// Note that verification is still experimental and may not
|
||||||
/// catch every error, or be maximally performant. For the
|
/// catch every error, or be maximally performant. For the
|
||||||
/// previous, unchecked, behavior use
|
/// previous, unchecked, behavior use
|
||||||
/// `size_prefixed_root_as_universe_unchecked`.
|
/// `size_prefixed_root_as_universe_unchecked`.
|
||||||
|
#[inline]
|
||||||
pub fn size_prefixed_root_as_universe(buf: &[u8]) -> Result<Universe<'_>, ::flatbuffers::InvalidFlatbuffer> {
|
pub fn size_prefixed_root_as_universe(buf: &[u8]) -> Result<Universe<'_>, ::flatbuffers::InvalidFlatbuffer> {
|
||||||
::flatbuffers::size_prefixed_root::<Universe>(buf)
|
::flatbuffers::size_prefixed_root::<Universe>(buf)
|
||||||
}
|
}
|
||||||
#[inline]
|
|
||||||
/// Verifies, with the given options, that a buffer of bytes
|
/// Verifies, with the given options, that a buffer of bytes
|
||||||
/// contains a `Universe` and returns it.
|
/// contains a `Universe` and returns it.
|
||||||
/// Note that verification is still experimental and may not
|
/// Note that verification is still experimental and may not
|
||||||
/// catch every error, or be maximally performant. For the
|
/// catch every error, or be maximally performant. For the
|
||||||
/// previous, unchecked, behavior use
|
/// previous, unchecked, behavior use
|
||||||
/// `root_as_universe_unchecked`.
|
/// `root_as_universe_unchecked`.
|
||||||
|
#[inline]
|
||||||
pub fn root_as_universe_with_opts<'b, 'o>(
|
pub fn root_as_universe_with_opts<'b, 'o>(
|
||||||
opts: &'o ::flatbuffers::VerifierOptions,
|
opts: &'o ::flatbuffers::VerifierOptions,
|
||||||
buf: &'b [u8],
|
buf: &'b [u8],
|
||||||
) -> Result<Universe<'b>, ::flatbuffers::InvalidFlatbuffer> {
|
) -> Result<Universe<'b>, ::flatbuffers::InvalidFlatbuffer> {
|
||||||
::flatbuffers::root_with_opts::<Universe<'b>>(opts, buf)
|
::flatbuffers::root_with_opts::<Universe<'b>>(opts, buf)
|
||||||
}
|
}
|
||||||
#[inline]
|
|
||||||
/// Verifies, with the given verifier options, that a buffer of
|
/// Verifies, with the given verifier options, that a buffer of
|
||||||
/// bytes contains a size prefixed `Universe` and returns
|
/// bytes contains a size prefixed `Universe` and returns
|
||||||
/// it. Note that verification is still experimental and may not
|
/// it. Note that verification is still experimental and may not
|
||||||
/// catch every error, or be maximally performant. For the
|
/// catch every error, or be maximally performant. For the
|
||||||
/// previous, unchecked, behavior use
|
/// previous, unchecked, behavior use
|
||||||
/// `root_as_universe_unchecked`.
|
/// `root_as_universe_unchecked`.
|
||||||
|
#[inline]
|
||||||
pub fn size_prefixed_root_as_universe_with_opts<'b, 'o>(
|
pub fn size_prefixed_root_as_universe_with_opts<'b, 'o>(
|
||||||
opts: &'o ::flatbuffers::VerifierOptions,
|
opts: &'o ::flatbuffers::VerifierOptions,
|
||||||
buf: &'b [u8],
|
buf: &'b [u8],
|
||||||
) -> Result<Universe<'b>, ::flatbuffers::InvalidFlatbuffer> {
|
) -> Result<Universe<'b>, ::flatbuffers::InvalidFlatbuffer> {
|
||||||
::flatbuffers::size_prefixed_root_with_opts::<Universe<'b>>(opts, buf)
|
::flatbuffers::size_prefixed_root_with_opts::<Universe<'b>>(opts, buf)
|
||||||
}
|
}
|
||||||
#[inline]
|
|
||||||
/// Assumes, without verification, that a buffer of bytes contains a Universe and returns it.
|
/// Assumes, without verification, that a buffer of bytes contains a Universe and returns it.
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// Callers must trust the given bytes do indeed contain a valid `Universe`.
|
/// Callers must trust the given bytes do indeed contain a valid `Universe`.
|
||||||
|
#[inline]
|
||||||
pub unsafe fn root_as_universe_unchecked(buf: &[u8]) -> Universe<'_> {
|
pub unsafe fn root_as_universe_unchecked(buf: &[u8]) -> Universe<'_> {
|
||||||
unsafe { ::flatbuffers::root_unchecked::<Universe>(buf) }
|
unsafe { ::flatbuffers::root_unchecked::<Universe>(buf) }
|
||||||
}
|
}
|
||||||
#[inline]
|
|
||||||
/// Assumes, without verification, that a buffer of bytes contains a size prefixed Universe and returns it.
|
/// Assumes, without verification, that a buffer of bytes contains a size prefixed Universe and returns it.
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// Callers must trust the given bytes do indeed contain a valid size prefixed `Universe`.
|
/// Callers must trust the given bytes do indeed contain a valid size prefixed `Universe`.
|
||||||
|
#[inline]
|
||||||
pub unsafe fn size_prefixed_root_as_universe_unchecked(buf: &[u8]) -> Universe<'_> {
|
pub unsafe fn size_prefixed_root_as_universe_unchecked(buf: &[u8]) -> Universe<'_> {
|
||||||
unsafe { ::flatbuffers::size_prefixed_root_unchecked::<Universe>(buf) }
|
unsafe { ::flatbuffers::size_prefixed_root_unchecked::<Universe>(buf) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn finish_universe_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
|
pub fn finish_universe_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
|
||||||
fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
root: ::flatbuffers::WIPOffset<Universe<'a>>) {
|
root: ::flatbuffers::WIPOffset<Universe<'a>>
|
||||||
|
) {
|
||||||
fbb.finish(root, None);
|
fbb.finish(root, None);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn finish_size_prefixed_universe_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, root: ::flatbuffers::WIPOffset<Universe<'a>>) {
|
pub fn finish_size_prefixed_universe_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
|
||||||
|
fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
|
root: ::flatbuffers::WIPOffset<Universe<'a>>
|
||||||
|
) {
|
||||||
fbb.finish_size_prefixed(root, None);
|
fbb.finish_size_prefixed(root, None);
|
||||||
}
|
}
|
||||||
} // pub mod goldens
|
} // pub mod goldens
|
||||||
} // pub mod flatbuffers
|
} // pub mod flatbuffers
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
import * as flatbuffers from 'flatbuffers';
|
import * as flatbuffers from 'flatbuffers';
|
||||||
|
|
||||||
import { Galaxy } from '../../flatbuffers/goldens/galaxy.js';
|
import { Galaxy } from './galaxy.js';
|
||||||
|
|
||||||
|
|
||||||
export class Universe {
|
export class Universe {
|
||||||
|
|||||||
@@ -17,16 +17,14 @@ public struct models_HelloReply: FlatBufferTable, FlatbuffersVectorInitializable
|
|||||||
private init(_ t: Table) { _accessor = t }
|
private init(_ t: Table) { _accessor = t }
|
||||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||||
|
|
||||||
private enum VTOFFSET: VOffset {
|
private struct VT {
|
||||||
case message = 4
|
static let message: VOffset = 4
|
||||||
var v: Int32 { Int32(self.rawValue) }
|
|
||||||
var p: VOffset { self.rawValue }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public var message: String? { let o = _accessor.offset(VTOFFSET.message.v); return o == 0 ? nil : _accessor.string(at: o) }
|
public var message: String? { let o = _accessor.offset(VT.message); return o == 0 ? nil : _accessor.string(at: o) }
|
||||||
public var messageSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.message.v) }
|
public var messageSegmentArray: [UInt8]? { return _accessor.getVector(at: VT.message) }
|
||||||
public static func startHelloReply(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
|
public static func startHelloReply(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
|
||||||
public static func add(message: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: message, at: VTOFFSET.message.p) }
|
public static func add(message: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: message, at: VT.message) }
|
||||||
public static func endHelloReply(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
public static func endHelloReply(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||||
public static func createHelloReply(
|
public static func createHelloReply(
|
||||||
_ fbb: inout FlatBufferBuilder,
|
_ fbb: inout FlatBufferBuilder,
|
||||||
@@ -39,16 +37,16 @@ public struct models_HelloReply: FlatBufferTable, FlatbuffersVectorInitializable
|
|||||||
|
|
||||||
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
|
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
|
||||||
var _v = try verifier.visitTable(at: position)
|
var _v = try verifier.visitTable(at: position)
|
||||||
try _v.visit(field: VTOFFSET.message.p, fieldName: "message", required: false, type: ForwardOffset<String>.self)
|
try _v.visit(field: VT.message, fieldName: "message", required: false, type: ForwardOffset<String>.self)
|
||||||
_v.finish()
|
_v.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension models_HelloReply: Encodable {
|
extension models_HelloReply: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case message = "message"
|
case message = "message"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encodeIfPresent(message, forKey: .message)
|
try container.encodeIfPresent(message, forKey: .message)
|
||||||
@@ -64,16 +62,14 @@ public struct models_HelloRequest: FlatBufferTable, FlatbuffersVectorInitializab
|
|||||||
private init(_ t: Table) { _accessor = t }
|
private init(_ t: Table) { _accessor = t }
|
||||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||||
|
|
||||||
private enum VTOFFSET: VOffset {
|
private struct VT {
|
||||||
case name = 4
|
static let name: VOffset = 4
|
||||||
var v: Int32 { Int32(self.rawValue) }
|
|
||||||
var p: VOffset { self.rawValue }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public var name: String? { let o = _accessor.offset(VTOFFSET.name.v); return o == 0 ? nil : _accessor.string(at: o) }
|
public var name: String? { let o = _accessor.offset(VT.name); return o == 0 ? nil : _accessor.string(at: o) }
|
||||||
public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.name.v) }
|
public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: VT.name) }
|
||||||
public static func startHelloRequest(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
|
public static func startHelloRequest(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
|
||||||
public static func add(name: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: name, at: VTOFFSET.name.p) }
|
public static func add(name: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: name, at: VT.name) }
|
||||||
public static func endHelloRequest(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
public static func endHelloRequest(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||||
public static func createHelloRequest(
|
public static func createHelloRequest(
|
||||||
_ fbb: inout FlatBufferBuilder,
|
_ fbb: inout FlatBufferBuilder,
|
||||||
@@ -86,16 +82,16 @@ public struct models_HelloRequest: FlatBufferTable, FlatbuffersVectorInitializab
|
|||||||
|
|
||||||
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
|
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
|
||||||
var _v = try verifier.visitTable(at: position)
|
var _v = try verifier.visitTable(at: position)
|
||||||
try _v.visit(field: VTOFFSET.name.p, fieldName: "name", required: false, type: ForwardOffset<String>.self)
|
try _v.visit(field: VT.name, fieldName: "name", required: false, type: ForwardOffset<String>.self)
|
||||||
_v.finish()
|
_v.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension models_HelloRequest: Encodable {
|
extension models_HelloRequest: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case name = "name"
|
case name = "name"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encodeIfPresent(name, forKey: .name)
|
try container.encodeIfPresent(name, forKey: .name)
|
||||||
|
|||||||
@@ -676,7 +676,6 @@ struct IDLOptions {
|
|||||||
bool gen_absl_hash;
|
bool gen_absl_hash;
|
||||||
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;
|
||||||
std::string cpp_object_api_vector_type;
|
|
||||||
bool cpp_object_api_string_flexible_constructor;
|
bool cpp_object_api_string_flexible_constructor;
|
||||||
CaseStyle cpp_object_api_field_case_style;
|
CaseStyle cpp_object_api_field_case_style;
|
||||||
bool cpp_direct_copy;
|
bool cpp_direct_copy;
|
||||||
@@ -1013,7 +1012,6 @@ 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_vec_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;
|
||||||
|
|||||||
@@ -30,23 +30,21 @@ namespace flatbuffers {
|
|||||||
|
|
||||||
// ------------------------- GETTERS -------------------------
|
// ------------------------- GETTERS -------------------------
|
||||||
|
|
||||||
inline bool IsScalar(reflection::BaseType t) {
|
constexpr bool IsScalar(reflection::BaseType t) {
|
||||||
return t >= reflection::UType && t <= reflection::Double;
|
return t >= reflection::UType && t <= reflection::Double;
|
||||||
}
|
}
|
||||||
inline bool IsInteger(reflection::BaseType t) {
|
constexpr bool IsInteger(reflection::BaseType t) {
|
||||||
return t >= reflection::UType && t <= reflection::ULong;
|
return t >= reflection::UType && t <= reflection::ULong;
|
||||||
}
|
}
|
||||||
inline bool IsFloat(reflection::BaseType t) {
|
constexpr bool IsFloat(reflection::BaseType t) {
|
||||||
return t == reflection::Float || t == reflection::Double;
|
return t == reflection::Float || t == reflection::Double;
|
||||||
}
|
}
|
||||||
inline bool IsLong(reflection::BaseType t) {
|
constexpr bool IsLong(reflection::BaseType t) {
|
||||||
return t == reflection::Long || t == reflection::ULong;
|
return t == reflection::Long || t == reflection::ULong;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Size of a basic type, don't use with structs.
|
|
||||||
inline size_t GetTypeSize(reflection::BaseType base_type) {
|
|
||||||
// This needs to correspond to the BaseType enum.
|
// This needs to correspond to the BaseType enum.
|
||||||
static size_t sizes[] = {
|
constexpr size_t kBaseTypeSize[] = {
|
||||||
0, // None
|
0, // None
|
||||||
1, // UType
|
1, // UType
|
||||||
1, // Bool
|
1, // Bool
|
||||||
@@ -70,10 +68,14 @@ inline size_t GetTypeSize(reflection::BaseType base_type) {
|
|||||||
|
|
||||||
0 // MaxBaseType. This must be kept the last entry in this array.
|
0 // MaxBaseType. This must be kept the last entry in this array.
|
||||||
};
|
};
|
||||||
static_assert(sizeof(sizes) / sizeof(size_t) == reflection::MaxBaseType + 1,
|
static_assert(sizeof(kBaseTypeSize) / sizeof(size_t) ==
|
||||||
|
reflection::MaxBaseType + 1,
|
||||||
"Size of sizes[] array does not match the count of BaseType "
|
"Size of sizes[] array does not match the count of BaseType "
|
||||||
"enum values.");
|
"enum values.");
|
||||||
return sizes[base_type];
|
|
||||||
|
// Size of a basic type, don't use with structs.
|
||||||
|
constexpr size_t GetTypeSize(reflection::BaseType base_type) {
|
||||||
|
return kBaseTypeSize[base_type];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Same as above, but now correctly returns the size of a struct if
|
// Same as above, but now correctly returns the size of a struct if
|
||||||
@@ -420,7 +422,7 @@ pointer_inside_vector<T, U> piv(T* ptr, std::vector<U>& vec) {
|
|||||||
return pointer_inside_vector<T, U>(ptr, vec);
|
return pointer_inside_vector<T, U>(ptr, vec);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const char* UnionTypeFieldSuffix() { return "_type"; }
|
constexpr const char* UnionTypeFieldSuffix() { return "_type"; }
|
||||||
|
|
||||||
// Helper to figure out the actual table type a union refers to.
|
// Helper to figure out the actual table type a union refers to.
|
||||||
inline const reflection::Object& GetUnionType(
|
inline const reflection::Object& GetUnionType(
|
||||||
|
|||||||
@@ -438,7 +438,6 @@ namespace Google.FlatBuffers
|
|||||||
if (off > Offset)
|
if (off > Offset)
|
||||||
throw new ArgumentException();
|
throw new ArgumentException();
|
||||||
|
|
||||||
if (off != 0)
|
|
||||||
off = Offset - off + sizeof(int);
|
off = Offset - off + sizeof(int);
|
||||||
PutInt(off);
|
PutInt(off);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,11 +65,7 @@ namespace Google.FlatBuffers
|
|||||||
// Create a .NET String from UTF-8 data stored inside the flatbuffer.
|
// Create a .NET String from UTF-8 data stored inside the flatbuffer.
|
||||||
public string __string(int offset)
|
public string __string(int offset)
|
||||||
{
|
{
|
||||||
int stringOffset = bb.GetInt(offset);
|
offset += bb.GetInt(offset);
|
||||||
if (stringOffset == 0)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
offset += stringOffset;
|
|
||||||
var len = bb.GetInt(offset);
|
var len = bb.GetInt(offset);
|
||||||
var startPos = offset + sizeof(int);
|
var startPos = offset + sizeof(int);
|
||||||
return bb.GetStringUTF8(startPos, len);
|
return bb.GetStringUTF8(startPos, len);
|
||||||
|
|||||||
38
pnpm-lock.yaml
generated
38
pnpm-lock.yaml
generated
@@ -343,8 +343,8 @@ packages:
|
|||||||
engines: {node: '>=0.4.0'}
|
engines: {node: '>=0.4.0'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
ajv@6.12.6:
|
ajv@6.14.0:
|
||||||
resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==}
|
resolution: {integrity: sha512-IWrosm/yrn43eiKqkfkHis7QioDleaXQHdDVPKg0FSwwd/DuvyX79TZnFOnYpB7dcsFAMmtFztZuXPDvSePkFw==}
|
||||||
|
|
||||||
ansi-styles@4.3.0:
|
ansi-styles@4.3.0:
|
||||||
resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==}
|
resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==}
|
||||||
@@ -483,8 +483,8 @@ packages:
|
|||||||
resolution: {integrity: sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==}
|
resolution: {integrity: sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==}
|
||||||
engines: {node: '>=16'}
|
engines: {node: '>=16'}
|
||||||
|
|
||||||
flatted@3.3.1:
|
flatted@3.4.2:
|
||||||
resolution: {integrity: sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==}
|
resolution: {integrity: sha512-PjDse7RzhcPkIJwy5t7KPWQSZ9cAbzQXcafsetQoD7sOJRQlGikNbx7yZp2OotDnJyrDcbyRq3Ttb18iYOqkxA==}
|
||||||
|
|
||||||
glob-parent@5.1.2:
|
glob-parent@5.1.2:
|
||||||
resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==}
|
resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==}
|
||||||
@@ -571,11 +571,11 @@ packages:
|
|||||||
resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==}
|
resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==}
|
||||||
engines: {node: '>=8.6'}
|
engines: {node: '>=8.6'}
|
||||||
|
|
||||||
minimatch@3.1.2:
|
minimatch@3.1.5:
|
||||||
resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==}
|
resolution: {integrity: sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==}
|
||||||
|
|
||||||
minimatch@9.0.5:
|
minimatch@9.0.9:
|
||||||
resolution: {integrity: sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==}
|
resolution: {integrity: sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==}
|
||||||
engines: {node: '>=16 || 14 >=14.17'}
|
engines: {node: '>=16 || 14 >=14.17'}
|
||||||
|
|
||||||
ms@2.1.3:
|
ms@2.1.3:
|
||||||
@@ -793,7 +793,7 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@eslint/object-schema': 2.1.6
|
'@eslint/object-schema': 2.1.6
|
||||||
debug: 4.3.7
|
debug: 4.3.7
|
||||||
minimatch: 3.1.2
|
minimatch: 3.1.5
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
@@ -809,14 +809,14 @@ snapshots:
|
|||||||
|
|
||||||
'@eslint/eslintrc@3.3.1':
|
'@eslint/eslintrc@3.3.1':
|
||||||
dependencies:
|
dependencies:
|
||||||
ajv: 6.12.6
|
ajv: 6.14.0
|
||||||
debug: 4.3.7
|
debug: 4.3.7
|
||||||
espree: 10.4.0
|
espree: 10.4.0
|
||||||
globals: 14.0.0
|
globals: 14.0.0
|
||||||
ignore: 5.3.2
|
ignore: 5.3.2
|
||||||
import-fresh: 3.3.0
|
import-fresh: 3.3.0
|
||||||
js-yaml: 4.1.1
|
js-yaml: 4.1.1
|
||||||
minimatch: 3.1.2
|
minimatch: 3.1.5
|
||||||
strip-json-comments: 3.1.1
|
strip-json-comments: 3.1.1
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
@@ -932,7 +932,7 @@ snapshots:
|
|||||||
debug: 4.3.7
|
debug: 4.3.7
|
||||||
fast-glob: 3.3.2
|
fast-glob: 3.3.2
|
||||||
is-glob: 4.0.3
|
is-glob: 4.0.3
|
||||||
minimatch: 9.0.5
|
minimatch: 9.0.9
|
||||||
semver: 7.6.3
|
semver: 7.6.3
|
||||||
ts-api-utils: 2.1.0(typescript@5.8.3)
|
ts-api-utils: 2.1.0(typescript@5.8.3)
|
||||||
typescript: 5.8.3
|
typescript: 5.8.3
|
||||||
@@ -961,7 +961,7 @@ snapshots:
|
|||||||
|
|
||||||
acorn@8.15.0: {}
|
acorn@8.15.0: {}
|
||||||
|
|
||||||
ajv@6.12.6:
|
ajv@6.14.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
fast-deep-equal: 3.1.3
|
fast-deep-equal: 3.1.3
|
||||||
fast-json-stable-stringify: 2.1.0
|
fast-json-stable-stringify: 2.1.0
|
||||||
@@ -1070,7 +1070,7 @@ snapshots:
|
|||||||
'@humanwhocodes/retry': 0.4.3
|
'@humanwhocodes/retry': 0.4.3
|
||||||
'@types/estree': 1.0.8
|
'@types/estree': 1.0.8
|
||||||
'@types/json-schema': 7.0.15
|
'@types/json-schema': 7.0.15
|
||||||
ajv: 6.12.6
|
ajv: 6.14.0
|
||||||
chalk: 4.1.2
|
chalk: 4.1.2
|
||||||
cross-spawn: 7.0.6
|
cross-spawn: 7.0.6
|
||||||
debug: 4.3.7
|
debug: 4.3.7
|
||||||
@@ -1089,7 +1089,7 @@ snapshots:
|
|||||||
is-glob: 4.0.3
|
is-glob: 4.0.3
|
||||||
json-stable-stringify-without-jsonify: 1.0.1
|
json-stable-stringify-without-jsonify: 1.0.1
|
||||||
lodash.merge: 4.6.2
|
lodash.merge: 4.6.2
|
||||||
minimatch: 3.1.2
|
minimatch: 3.1.5
|
||||||
natural-compare: 1.4.0
|
natural-compare: 1.4.0
|
||||||
optionator: 0.9.4
|
optionator: 0.9.4
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
@@ -1146,10 +1146,10 @@ snapshots:
|
|||||||
|
|
||||||
flat-cache@4.0.1:
|
flat-cache@4.0.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
flatted: 3.3.1
|
flatted: 3.4.2
|
||||||
keyv: 4.5.4
|
keyv: 4.5.4
|
||||||
|
|
||||||
flatted@3.3.1: {}
|
flatted@3.4.2: {}
|
||||||
|
|
||||||
glob-parent@5.1.2:
|
glob-parent@5.1.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -1218,11 +1218,11 @@ snapshots:
|
|||||||
braces: 3.0.3
|
braces: 3.0.3
|
||||||
picomatch: 2.3.1
|
picomatch: 2.3.1
|
||||||
|
|
||||||
minimatch@3.1.2:
|
minimatch@3.1.5:
|
||||||
dependencies:
|
dependencies:
|
||||||
brace-expansion: 1.1.12
|
brace-expansion: 1.1.12
|
||||||
|
|
||||||
minimatch@9.0.5:
|
minimatch@9.0.9:
|
||||||
dependencies:
|
dependencies:
|
||||||
brace-expansion: 2.0.2
|
brace-expansion: 2.0.2
|
||||||
|
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ def EnumCreateValuesVector(builder, data):
|
|||||||
return builder.CreateVectorOfTables(data)
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def CreateValuesVector(builder, data):
|
def CreateValuesVector(builder, data):
|
||||||
EnumCreateValuesVector(builder, data)
|
return EnumCreateValuesVector(builder, data)
|
||||||
|
|
||||||
def EnumAddIsUnion(builder, isUnion):
|
def EnumAddIsUnion(builder, isUnion):
|
||||||
builder.PrependBoolSlot(2, isUnion, 0)
|
builder.PrependBoolSlot(2, isUnion, 0)
|
||||||
@@ -189,7 +189,7 @@ def EnumCreateAttributesVector(builder, data):
|
|||||||
return builder.CreateVectorOfTables(data)
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def CreateAttributesVector(builder, data):
|
def CreateAttributesVector(builder, data):
|
||||||
EnumCreateAttributesVector(builder, data)
|
return 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)
|
||||||
@@ -207,7 +207,7 @@ def EnumCreateDocumentationVector(builder, data):
|
|||||||
return builder.CreateVectorOfTables(data)
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def CreateDocumentationVector(builder, data):
|
def CreateDocumentationVector(builder, data):
|
||||||
EnumCreateDocumentationVector(builder, data)
|
return 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)
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ def EnumValCreateDocumentationVector(builder, data):
|
|||||||
return builder.CreateVectorOfTables(data)
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def CreateDocumentationVector(builder, data):
|
def CreateDocumentationVector(builder, data):
|
||||||
EnumValCreateDocumentationVector(builder, data)
|
return 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)
|
||||||
@@ -156,7 +156,7 @@ def EnumValCreateAttributesVector(builder, data):
|
|||||||
return builder.CreateVectorOfTables(data)
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def CreateAttributesVector(builder, data):
|
def CreateAttributesVector(builder, data):
|
||||||
EnumValCreateAttributesVector(builder, data)
|
return EnumValCreateAttributesVector(builder, data)
|
||||||
|
|
||||||
def EnumValEnd(builder):
|
def EnumValEnd(builder):
|
||||||
return builder.EndObject()
|
return builder.EndObject()
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ def FieldCreateAttributesVector(builder, data):
|
|||||||
return builder.CreateVectorOfTables(data)
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def CreateAttributesVector(builder, data):
|
def CreateAttributesVector(builder, data):
|
||||||
FieldCreateAttributesVector(builder, data)
|
return 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)
|
||||||
@@ -257,7 +257,7 @@ def FieldCreateDocumentationVector(builder, data):
|
|||||||
return builder.CreateVectorOfTables(data)
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def CreateDocumentationVector(builder, data):
|
def CreateDocumentationVector(builder, data):
|
||||||
FieldCreateDocumentationVector(builder, data)
|
return FieldCreateDocumentationVector(builder, data)
|
||||||
|
|
||||||
def FieldAddOptional(builder, optional):
|
def FieldAddOptional(builder, optional):
|
||||||
builder.PrependBoolSlot(11, optional, 0)
|
builder.PrependBoolSlot(11, optional, 0)
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ def ObjectCreateFieldsVector(builder, data):
|
|||||||
return builder.CreateVectorOfTables(data)
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def CreateFieldsVector(builder, data):
|
def CreateFieldsVector(builder, data):
|
||||||
ObjectCreateFieldsVector(builder, data)
|
return ObjectCreateFieldsVector(builder, data)
|
||||||
|
|
||||||
def ObjectAddIsStruct(builder, isStruct):
|
def ObjectAddIsStruct(builder, isStruct):
|
||||||
builder.PrependBoolSlot(2, isStruct, 0)
|
builder.PrependBoolSlot(2, isStruct, 0)
|
||||||
@@ -198,7 +198,7 @@ def ObjectCreateAttributesVector(builder, data):
|
|||||||
return builder.CreateVectorOfTables(data)
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def CreateAttributesVector(builder, data):
|
def CreateAttributesVector(builder, data):
|
||||||
ObjectCreateAttributesVector(builder, data)
|
return 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)
|
||||||
@@ -216,7 +216,7 @@ def ObjectCreateDocumentationVector(builder, data):
|
|||||||
return builder.CreateVectorOfTables(data)
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def CreateDocumentationVector(builder, data):
|
def CreateDocumentationVector(builder, data):
|
||||||
ObjectCreateDocumentationVector(builder, data)
|
return 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)
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ def RPCCallCreateAttributesVector(builder, data):
|
|||||||
return builder.CreateVectorOfTables(data)
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def CreateAttributesVector(builder, data):
|
def CreateAttributesVector(builder, data):
|
||||||
RPCCallCreateAttributesVector(builder, data)
|
return 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)
|
||||||
@@ -160,7 +160,7 @@ def RPCCallCreateDocumentationVector(builder, data):
|
|||||||
return builder.CreateVectorOfTables(data)
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def CreateDocumentationVector(builder, data):
|
def CreateDocumentationVector(builder, data):
|
||||||
RPCCallCreateDocumentationVector(builder, data)
|
return RPCCallCreateDocumentationVector(builder, data)
|
||||||
|
|
||||||
def RPCCallEnd(builder):
|
def RPCCallEnd(builder):
|
||||||
return builder.EndObject()
|
return builder.EndObject()
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ def SchemaCreateObjectsVector(builder, data):
|
|||||||
return builder.CreateVectorOfTables(data)
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def CreateObjectsVector(builder, data):
|
def CreateObjectsVector(builder, data):
|
||||||
SchemaCreateObjectsVector(builder, data)
|
return 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)
|
||||||
@@ -202,7 +202,7 @@ def SchemaCreateEnumsVector(builder, data):
|
|||||||
return builder.CreateVectorOfTables(data)
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def CreateEnumsVector(builder, data):
|
def CreateEnumsVector(builder, data):
|
||||||
SchemaCreateEnumsVector(builder, data)
|
return 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)
|
||||||
@@ -238,7 +238,7 @@ def SchemaCreateServicesVector(builder, data):
|
|||||||
return builder.CreateVectorOfTables(data)
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def CreateServicesVector(builder, data):
|
def CreateServicesVector(builder, data):
|
||||||
SchemaCreateServicesVector(builder, data)
|
return SchemaCreateServicesVector(builder, data)
|
||||||
|
|
||||||
def SchemaAddAdvancedFeatures(builder, advancedFeatures):
|
def SchemaAddAdvancedFeatures(builder, advancedFeatures):
|
||||||
builder.PrependUint64Slot(6, advancedFeatures, 0)
|
builder.PrependUint64Slot(6, advancedFeatures, 0)
|
||||||
@@ -262,7 +262,7 @@ def SchemaCreateFbsFilesVector(builder, data):
|
|||||||
return builder.CreateVectorOfTables(data)
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def CreateFbsFilesVector(builder, data):
|
def CreateFbsFilesVector(builder, data):
|
||||||
SchemaCreateFbsFilesVector(builder, data)
|
return SchemaCreateFbsFilesVector(builder, data)
|
||||||
|
|
||||||
def SchemaEnd(builder):
|
def SchemaEnd(builder):
|
||||||
return builder.EndObject()
|
return builder.EndObject()
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ def SchemaFileCreateIncludedFilenamesVector(builder, data):
|
|||||||
return builder.CreateVectorOfTables(data)
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def CreateIncludedFilenamesVector(builder, data):
|
def CreateIncludedFilenamesVector(builder, data):
|
||||||
SchemaFileCreateIncludedFilenamesVector(builder, data)
|
return SchemaFileCreateIncludedFilenamesVector(builder, data)
|
||||||
|
|
||||||
def SchemaFileEnd(builder):
|
def SchemaFileEnd(builder):
|
||||||
return builder.EndObject()
|
return builder.EndObject()
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ def ServiceCreateCallsVector(builder, data):
|
|||||||
return builder.CreateVectorOfTables(data)
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def CreateCallsVector(builder, data):
|
def CreateCallsVector(builder, data):
|
||||||
ServiceCreateCallsVector(builder, data)
|
return 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)
|
||||||
@@ -159,7 +159,7 @@ def ServiceCreateAttributesVector(builder, data):
|
|||||||
return builder.CreateVectorOfTables(data)
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def CreateAttributesVector(builder, data):
|
def CreateAttributesVector(builder, data):
|
||||||
ServiceCreateAttributesVector(builder, data)
|
return 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)
|
||||||
@@ -177,7 +177,7 @@ def ServiceCreateDocumentationVector(builder, data):
|
|||||||
return builder.CreateVectorOfTables(data)
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def CreateDocumentationVector(builder, data):
|
def CreateDocumentationVector(builder, data):
|
||||||
ServiceCreateDocumentationVector(builder, data)
|
return 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)
|
||||||
|
|||||||
@@ -1,6 +1,2 @@
|
|||||||
[bdist_wheel]
|
|
||||||
universal=1
|
|
||||||
|
|
||||||
[metadata]
|
[metadata]
|
||||||
license_files =
|
license_files = LICENSE
|
||||||
../LICENSE
|
|
||||||
|
|||||||
@@ -32,10 +32,8 @@ setup(
|
|||||||
description='The FlatBuffers serialization format for Python',
|
description='The FlatBuffers serialization format for Python',
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Intended Audience :: Developers',
|
'Intended Audience :: Developers',
|
||||||
'License :: OSI Approved :: Apache Software License',
|
|
||||||
'Operating System :: OS Independent',
|
'Operating System :: OS Independent',
|
||||||
'Programming Language :: Python',
|
'Programming Language :: Python',
|
||||||
'Programming Language :: Python :: 2',
|
|
||||||
'Programming Language :: Python :: 3',
|
'Programming Language :: Python :: 3',
|
||||||
'Topic :: Software Development :: Libraries :: Python Modules',
|
'Topic :: Software Development :: Libraries :: Python Modules',
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ use core::marker::PhantomData;
|
|||||||
use core::ops::{Add, AddAssign, Deref, DerefMut, Index, IndexMut, Sub, SubAssign};
|
use core::ops::{Add, AddAssign, Deref, DerefMut, Index, IndexMut, Sub, SubAssign};
|
||||||
use core::ptr::write_bytes;
|
use core::ptr::write_bytes;
|
||||||
|
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::endian_scalar::emplace_scalar;
|
use crate::endian_scalar::emplace_scalar;
|
||||||
use crate::primitives::*;
|
use crate::primitives::*;
|
||||||
use crate::push::{Push, PushAlignment};
|
use crate::push::{Push, PushAlignment};
|
||||||
@@ -139,6 +142,9 @@ pub struct FlatBufferBuilder<'fbb, A: Allocator = DefaultAllocator> {
|
|||||||
|
|
||||||
min_align: usize,
|
min_align: usize,
|
||||||
force_defaults: bool,
|
force_defaults: bool,
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
strings_pool: HashMap<String, WIPOffset<&'fbb str>>,
|
||||||
|
#[cfg(not(feature = "std"))]
|
||||||
strings_pool: Vec<WIPOffset<&'fbb str>>,
|
strings_pool: Vec<WIPOffset<&'fbb str>>,
|
||||||
|
|
||||||
_phantom: PhantomData<&'fbb ()>,
|
_phantom: PhantomData<&'fbb ()>,
|
||||||
@@ -160,6 +166,60 @@ impl<'fbb> FlatBufferBuilder<'fbb, DefaultAllocator> {
|
|||||||
pub fn with_capacity(size: usize) -> Self {
|
pub fn with_capacity(size: usize) -> Self {
|
||||||
Self::from_vec(vec![0; size])
|
Self::from_vec(vec![0; size])
|
||||||
}
|
}
|
||||||
|
/// Create a FlatBufferBuilder that is ready for writing, with a
|
||||||
|
/// ready-to-use capacity of the provided size and preallocated internal vecs.
|
||||||
|
///
|
||||||
|
/// The maximum valid value for `size` is `FLATBUFFERS_MAX_BUFFER_SIZE`.
|
||||||
|
///
|
||||||
|
/// # Arguments
|
||||||
|
///
|
||||||
|
/// * `size` - The initial capacity of the backing buffer in bytes.
|
||||||
|
/// * `field_locs_capacity` - Preallocated capacity for the field locations vec.
|
||||||
|
/// * `written_vtable_revpos_capacity` - Preallocated capacity for the written vtable reverse positions vec.
|
||||||
|
/// * `strings_pool_capacity` - Preallocated capacity for the shared strings pool vec.
|
||||||
|
pub fn with_internal_capacity(
|
||||||
|
size: usize,
|
||||||
|
field_locs_capacity: usize,
|
||||||
|
written_vtable_revpos_capacity: usize,
|
||||||
|
strings_pool_capacity: usize,
|
||||||
|
) -> Self {
|
||||||
|
Self::from_vec_with_internal_capacity(
|
||||||
|
vec![0; size],
|
||||||
|
field_locs_capacity,
|
||||||
|
written_vtable_revpos_capacity,
|
||||||
|
strings_pool_capacity,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/// Create a FlatBufferBuilder that is ready for writing, reusing
|
||||||
|
/// an existing vector and preallocated internal vecs.
|
||||||
|
///
|
||||||
|
/// # Arguments
|
||||||
|
///
|
||||||
|
/// * `buffer` - An existing `Vec<u8>` to reuse as the backing buffer.
|
||||||
|
/// * `field_locs_capacity` - Preallocated capacity for the field locations vec.
|
||||||
|
/// * `written_vtable_revpos_capacity` - Preallocated capacity for the written vtable reverse positions vec.
|
||||||
|
/// * `strings_pool_capacity` - Preallocated capacity for the shared strings pool vec.
|
||||||
|
pub fn from_vec_with_internal_capacity(
|
||||||
|
buffer: Vec<u8>,
|
||||||
|
field_locs_capacity: usize,
|
||||||
|
written_vtable_revpos_capacity: usize,
|
||||||
|
strings_pool_capacity: usize,
|
||||||
|
) -> Self {
|
||||||
|
// we need to check the size here because we create the backing buffer
|
||||||
|
// directly, bypassing the typical way of using grow_allocator:
|
||||||
|
assert!(
|
||||||
|
buffer.len() <= FLATBUFFERS_MAX_BUFFER_SIZE,
|
||||||
|
"cannot initialize buffer bigger than 2 gigabytes"
|
||||||
|
);
|
||||||
|
let allocator = DefaultAllocator::from_vec(buffer);
|
||||||
|
Self::new_in_with_internal_capacity(
|
||||||
|
allocator,
|
||||||
|
field_locs_capacity,
|
||||||
|
written_vtable_revpos_capacity,
|
||||||
|
strings_pool_capacity,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/// Create a FlatBufferBuilder that is ready for writing, reusing
|
/// Create a FlatBufferBuilder that is ready for writing, reusing
|
||||||
/// an existing vector.
|
/// an existing vector.
|
||||||
pub fn from_vec(buffer: Vec<u8>) -> Self {
|
pub fn from_vec(buffer: Vec<u8>) -> Self {
|
||||||
@@ -197,12 +257,52 @@ impl<'fbb, A: Allocator> FlatBufferBuilder<'fbb, A> {
|
|||||||
|
|
||||||
min_align: 0,
|
min_align: 0,
|
||||||
force_defaults: false,
|
force_defaults: false,
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
strings_pool: HashMap::new(),
|
||||||
|
#[cfg(not(feature = "std"))]
|
||||||
strings_pool: Vec::new(),
|
strings_pool: Vec::new(),
|
||||||
|
|
||||||
_phantom: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create a [`FlatBufferBuilder`] that is ready for writing with a custom [`Allocator`]
|
||||||
|
/// and preallocated internal vecs.
|
||||||
|
///
|
||||||
|
/// # Arguments
|
||||||
|
///
|
||||||
|
/// * `allocator` - A custom [`Allocator`] to use as the backing buffer.
|
||||||
|
/// * `field_locs_capacity` - Preallocated capacity for the field locations vec.
|
||||||
|
/// * `written_vtable_revpos_capacity` - Preallocated capacity for the written vtable reverse positions vec.
|
||||||
|
/// * `strings_pool_capacity` - Preallocated capacity for the shared strings pool vec.
|
||||||
|
pub fn new_in_with_internal_capacity(
|
||||||
|
allocator: A,
|
||||||
|
field_locs_capacity: usize,
|
||||||
|
written_vtable_revpos_capacity: usize,
|
||||||
|
strings_pool_capacity: usize,
|
||||||
|
) -> Self {
|
||||||
|
let head = ReverseIndex::end();
|
||||||
|
FlatBufferBuilder {
|
||||||
|
allocator,
|
||||||
|
head,
|
||||||
|
|
||||||
|
field_locs: Vec::with_capacity(field_locs_capacity),
|
||||||
|
written_vtable_revpos: Vec::with_capacity(written_vtable_revpos_capacity),
|
||||||
|
|
||||||
|
nested: false,
|
||||||
|
finished: false,
|
||||||
|
|
||||||
|
min_align: 0,
|
||||||
|
force_defaults: false,
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
strings_pool: HashMap::with_capacity(strings_pool_capacity),
|
||||||
|
#[cfg(not(feature = "std"))]
|
||||||
|
strings_pool: Vec::with_capacity(strings_pool_capacity),
|
||||||
|
|
||||||
|
_phantom: PhantomData,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Destroy the [`FlatBufferBuilder`], returning its [`Allocator`] and the index
|
/// Destroy the [`FlatBufferBuilder`], returning its [`Allocator`] and the index
|
||||||
/// into it that represents the start of valid data.
|
/// into it that represents the start of valid data.
|
||||||
pub fn collapse_in(self) -> (A, usize) {
|
pub fn collapse_in(self) -> (A, usize) {
|
||||||
@@ -223,7 +323,9 @@ impl<'fbb, A: Allocator> FlatBufferBuilder<'fbb, A> {
|
|||||||
/// new object.
|
/// new object.
|
||||||
pub fn reset(&mut self) {
|
pub fn reset(&mut self) {
|
||||||
// memset only the part of the buffer that could be dirty:
|
// memset only the part of the buffer that could be dirty:
|
||||||
self.allocator[self.head.range_to_end()].iter_mut().for_each(|x| *x = 0);
|
self.allocator[self.head.range_to_end()]
|
||||||
|
.iter_mut()
|
||||||
|
.for_each(|x| *x = 0);
|
||||||
|
|
||||||
self.head = ReverseIndex::end();
|
self.head = ReverseIndex::end();
|
||||||
self.written_vtable_revpos.clear();
|
self.written_vtable_revpos.clear();
|
||||||
@@ -343,6 +445,31 @@ impl<'fbb, A: Allocator> FlatBufferBuilder<'fbb, A> {
|
|||||||
WIPOffset::new(o.value())
|
WIPOffset::new(o.value())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create a utf8 string, and de-duplicate if already created.
|
||||||
|
///
|
||||||
|
/// Uses a HashMap to track previously written strings, providing O(1)
|
||||||
|
/// amortized lookup and insertion.
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
#[inline]
|
||||||
|
pub fn create_shared_string<'a: 'b, 'b>(&'a mut self, s: &'b str) -> WIPOffset<&'fbb str> {
|
||||||
|
self.assert_not_nested(
|
||||||
|
"create_shared_string can not be called when a table or vector is under construction",
|
||||||
|
);
|
||||||
|
|
||||||
|
if let Some(&offset) = self.strings_pool.get(s) {
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
let address = WIPOffset::new(self.create_byte_string(s.as_bytes()).value());
|
||||||
|
self.strings_pool.insert(s.to_owned(), address);
|
||||||
|
address
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create a utf8 string, and de-duplicate if already created.
|
||||||
|
///
|
||||||
|
/// Uses a sorted Vec with binary search to track previously written
|
||||||
|
/// strings when in `no_std` mode.
|
||||||
|
#[cfg(not(feature = "std"))]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn create_shared_string<'a: 'b, 'b>(&'a mut self, s: &'b str) -> WIPOffset<&'fbb str> {
|
pub fn create_shared_string<'a: 'b, 'b>(&'a mut self, s: &'b str) -> WIPOffset<&'fbb str> {
|
||||||
self.assert_not_nested(
|
self.assert_not_nested(
|
||||||
@@ -355,19 +482,15 @@ impl<'fbb, A: Allocator> FlatBufferBuilder<'fbb, A> {
|
|||||||
|
|
||||||
let found = self.strings_pool.binary_search_by(|offset| {
|
let found = self.strings_pool.binary_search_by(|offset| {
|
||||||
let ptr = offset.value() as usize;
|
let ptr = offset.value() as usize;
|
||||||
// Gets The pointer to the size of the string
|
|
||||||
let str_memory = &buf[buf.len() - ptr..];
|
let str_memory = &buf[buf.len() - ptr..];
|
||||||
// Gets the size of the written string from buffer
|
let size = u32::from_le_bytes([
|
||||||
let size =
|
str_memory[0],
|
||||||
u32::from_le_bytes([str_memory[0], str_memory[1], str_memory[2], str_memory[3]])
|
str_memory[1],
|
||||||
as usize;
|
str_memory[2],
|
||||||
// Size of the string size
|
str_memory[3],
|
||||||
let string_size: usize = 4;
|
]) as usize;
|
||||||
// Fetches actual string bytes from index of string after string size
|
let stored = &str_memory[4..4 + size];
|
||||||
// to the size of string plus string size
|
stored.cmp(s.as_bytes())
|
||||||
let iter = str_memory[string_size..size + string_size].iter();
|
|
||||||
// Compares bytes of fetched string and current writable string
|
|
||||||
iter.cloned().cmp(s.bytes())
|
|
||||||
});
|
});
|
||||||
|
|
||||||
match found {
|
match found {
|
||||||
@@ -931,6 +1054,33 @@ impl<T> IndexMut<ReverseIndexRange> for [T] {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use core::sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
use std::alloc::{GlobalAlloc, Layout, System};
|
||||||
|
|
||||||
|
static ALLOC_COUNT: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
|
||||||
|
struct CountingAllocator;
|
||||||
|
|
||||||
|
unsafe impl GlobalAlloc for CountingAllocator {
|
||||||
|
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
|
||||||
|
ALLOC_COUNT.fetch_add(1, Ordering::Relaxed);
|
||||||
|
unsafe { System.alloc(layout) }
|
||||||
|
}
|
||||||
|
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
|
||||||
|
unsafe { System.dealloc(ptr, layout) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[global_allocator]
|
||||||
|
static GLOBAL: CountingAllocator = CountingAllocator;
|
||||||
|
|
||||||
|
fn reset_alloc_count() {
|
||||||
|
ALLOC_COUNT.store(0, Ordering::Relaxed);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn alloc_count() -> usize {
|
||||||
|
ALLOC_COUNT.load(Ordering::Relaxed)
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn reverse_index_test() {
|
fn reverse_index_test() {
|
||||||
@@ -940,4 +1090,43 @@ mod tests {
|
|||||||
assert_eq!(&buf[idx.range_to(idx + 1)], &[4]);
|
assert_eq!(&buf[idx.range_to(idx + 1)], &[4]);
|
||||||
assert_eq!(idx.to_forward_index(&buf), 4);
|
assert_eq!(idx.to_forward_index(&buf), 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn with_internal_capacity_preallocates_vecs() {
|
||||||
|
let mut builder = FlatBufferBuilder::with_internal_capacity(64, 8, 16, 32);
|
||||||
|
|
||||||
|
assert!(builder.allocator.len() >= 64);
|
||||||
|
assert!(builder.field_locs.capacity() >= 8);
|
||||||
|
assert!(builder.written_vtable_revpos.capacity() >= 16);
|
||||||
|
assert!(builder.strings_pool.capacity() >= 32);
|
||||||
|
|
||||||
|
assert!(builder.field_locs.is_empty());
|
||||||
|
assert!(builder.written_vtable_revpos.is_empty());
|
||||||
|
assert!(builder.strings_pool.is_empty());
|
||||||
|
|
||||||
|
// Reset the allocation counter after builder construction
|
||||||
|
reset_alloc_count();
|
||||||
|
|
||||||
|
// Add a shared string and verify it lands in the pool
|
||||||
|
let s1 = builder.create_shared_string("hello");
|
||||||
|
assert_eq!(builder.strings_pool.len(), 1);
|
||||||
|
|
||||||
|
// Adding the same string again should reuse the pooled entry
|
||||||
|
let s2 = builder.create_shared_string("hello");
|
||||||
|
assert_eq!(builder.strings_pool.len(), 1);
|
||||||
|
assert_eq!(s1.value(), s2.value());
|
||||||
|
|
||||||
|
// A different string should add a new entry
|
||||||
|
let _s3 = builder.create_shared_string("world");
|
||||||
|
assert_eq!(builder.strings_pool.len(), 2);
|
||||||
|
|
||||||
|
// With sufficient preallocated capacity, no additional allocations
|
||||||
|
// should have occurred for the internal vecs during the operations above
|
||||||
|
let allocs = alloc_count();
|
||||||
|
assert_eq!(
|
||||||
|
allocs, 0,
|
||||||
|
"expected 0 allocations after builder construction, got {}",
|
||||||
|
allocs
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,6 +107,20 @@ impl<'a, T: Follow<'a> + 'a> Vector<'a, T> {
|
|||||||
key: K,
|
key: K,
|
||||||
f: fn(&<T as Follow<'a>>::Inner, &K) -> Ordering,
|
f: fn(&<T as Follow<'a>>::Inner, &K) -> Ordering,
|
||||||
) -> Option<T::Inner> {
|
) -> Option<T::Inner> {
|
||||||
|
self.lookup_index_by_key(key, f).map(|idx| self.get(idx))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Binary search by key, returning the index of the matching element.
|
||||||
|
///
|
||||||
|
/// This is similar to `lookup_by_key`, but returns the index of the found
|
||||||
|
/// element rather than the element itself. This is useful when you need
|
||||||
|
/// to reference elements by their position in the vector.
|
||||||
|
#[inline(always)]
|
||||||
|
pub fn lookup_index_by_key<K: Ord>(
|
||||||
|
&self,
|
||||||
|
key: K,
|
||||||
|
f: fn(&<T as Follow<'a>>::Inner, &K) -> Ordering,
|
||||||
|
) -> Option<usize> {
|
||||||
if self.is_empty() {
|
if self.is_empty() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
@@ -118,7 +132,7 @@ impl<'a, T: Follow<'a> + 'a> Vector<'a, T> {
|
|||||||
let mid = (left + right) / 2;
|
let mid = (left + right) / 2;
|
||||||
let value = self.get(mid);
|
let value = self.get(mid);
|
||||||
match f(&value, &key) {
|
match f(&value, &key) {
|
||||||
Ordering::Equal => return Some(value),
|
Ordering::Equal => return Some(mid),
|
||||||
Ordering::Less => left = mid + 1,
|
Ordering::Less => left = mid + 1,
|
||||||
Ordering::Greater => {
|
Ordering::Greater => {
|
||||||
if mid == 0 {
|
if mid == 0 {
|
||||||
|
|||||||
@@ -643,7 +643,7 @@ inline ::flatbuffers::Offset<Monster> Monster::Pack(::flatbuffers::FlatBufferBui
|
|||||||
auto _name = _o->name.empty() ? 0 : _fbb.CreateString(_o->name);
|
auto _name = _o->name.empty() ? 0 : _fbb.CreateString(_o->name);
|
||||||
auto _inventory = _o->inventory.size() ? _fbb.CreateVector(_o->inventory) : 0;
|
auto _inventory = _o->inventory.size() ? _fbb.CreateVector(_o->inventory) : 0;
|
||||||
auto _color = _o->color;
|
auto _color = _o->color;
|
||||||
auto _weapons = _o->weapons.size() ? _fbb.CreateVector<::flatbuffers::Offset<MyGame::Sample::Weapon>> (_o->weapons.size(), [](size_t i, _VectorArgs *__va) { return CreateWeapon(*__va->__fbb, __va->__o->weapons[i].get(), __va->__rehasher); }, &_va ) : 0;
|
auto _weapons = _o->weapons.size() ? _fbb.CreateVector<::flatbuffers::Offset<MyGame::Sample::Weapon>> (_o->weapons.size(), [](size_t i, _VectorArgs *__va) { return MyGame::Sample::CreateWeapon(*__va->__fbb, __va->__o->weapons[i].get(), __va->__rehasher); }, &_va ) : 0;
|
||||||
auto _equipped_type = _o->equipped.type;
|
auto _equipped_type = _o->equipped.type;
|
||||||
auto _equipped = _o->equipped.Pack(_fbb);
|
auto _equipped = _o->equipped.Pack(_fbb);
|
||||||
auto _path = _o->path.size() ? _fbb.CreateVectorOfStructs(_o->path) : 0;
|
auto _path = _o->path.size() ? _fbb.CreateVectorOfStructs(_o->path) : 0;
|
||||||
|
|||||||
@@ -113,12 +113,12 @@ public struct MyGame_Sample_Vec3: NativeStruct, FlatbuffersVectorInitializable,
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension MyGame_Sample_Vec3: Encodable {
|
extension MyGame_Sample_Vec3: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case x = "x"
|
case x = "x"
|
||||||
case y = "y"
|
case y = "y"
|
||||||
case z = "z"
|
case z = "z"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
if x != 0.0 {
|
if x != 0.0 {
|
||||||
@@ -170,51 +170,49 @@ public struct MyGame_Sample_Monster: FlatBufferTable, FlatbuffersVectorInitializ
|
|||||||
private init(_ t: Table) { _accessor = t }
|
private init(_ t: Table) { _accessor = t }
|
||||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||||
|
|
||||||
private enum VTOFFSET: VOffset {
|
private struct VT {
|
||||||
case pos = 4
|
static let pos: VOffset = 4
|
||||||
case mana = 6
|
static let mana: VOffset = 6
|
||||||
case hp = 8
|
static let hp: VOffset = 8
|
||||||
case name = 10
|
static let name: VOffset = 10
|
||||||
case inventory = 14
|
static let inventory: VOffset = 14
|
||||||
case color = 16
|
static let color: VOffset = 16
|
||||||
case weapons = 18
|
static let weapons: VOffset = 18
|
||||||
case equippedType = 20
|
static let equippedType: VOffset = 20
|
||||||
case equipped = 22
|
static let equipped: VOffset = 22
|
||||||
case path = 24
|
static let path: VOffset = 24
|
||||||
var v: Int32 { Int32(self.rawValue) }
|
|
||||||
var p: VOffset { self.rawValue }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public var pos: MyGame_Sample_Vec3? { let o = _accessor.offset(VTOFFSET.pos.v); return o == 0 ? nil : _accessor.readBuffer(of: MyGame_Sample_Vec3.self, at: o) }
|
public var pos: MyGame_Sample_Vec3? { let o = _accessor.offset(VT.pos); return o == 0 ? nil : _accessor.readBuffer(of: MyGame_Sample_Vec3.self, at: o) }
|
||||||
public var mutablePos: MyGame_Sample_Vec3_Mutable? { let o = _accessor.offset(VTOFFSET.pos.v); return o == 0 ? nil : MyGame_Sample_Vec3_Mutable(_accessor.bb, o: o + _accessor.position) }
|
public var mutablePos: MyGame_Sample_Vec3_Mutable? { let o = _accessor.offset(VT.pos); return o == 0 ? nil : MyGame_Sample_Vec3_Mutable(_accessor.bb, o: o + _accessor.position) }
|
||||||
public var mana: Int16 { let o = _accessor.offset(VTOFFSET.mana.v); return o == 0 ? 150 : _accessor.readBuffer(of: Int16.self, at: o) }
|
public var mana: Int16 { let o = _accessor.offset(VT.mana); return o == 0 ? 150 : _accessor.readBuffer(of: Int16.self, at: o) }
|
||||||
@discardableResult public func mutate(mana: Int16) -> Bool {let o = _accessor.offset(VTOFFSET.mana.v); return _accessor.mutate(mana, index: o) }
|
@discardableResult public func mutate(mana: Int16) -> Bool {let o = _accessor.offset(VT.mana); return _accessor.mutate(mana, index: o) }
|
||||||
public var hp: Int16 { let o = _accessor.offset(VTOFFSET.hp.v); return o == 0 ? 100 : _accessor.readBuffer(of: Int16.self, at: o) }
|
public var hp: Int16 { let o = _accessor.offset(VT.hp); return o == 0 ? 100 : _accessor.readBuffer(of: Int16.self, at: o) }
|
||||||
@discardableResult public func mutate(hp: Int16) -> Bool {let o = _accessor.offset(VTOFFSET.hp.v); return _accessor.mutate(hp, index: o) }
|
@discardableResult public func mutate(hp: Int16) -> Bool {let o = _accessor.offset(VT.hp); return _accessor.mutate(hp, index: o) }
|
||||||
public var name: String? { let o = _accessor.offset(VTOFFSET.name.v); return o == 0 ? nil : _accessor.string(at: o) }
|
public var name: String? { let o = _accessor.offset(VT.name); return o == 0 ? nil : _accessor.string(at: o) }
|
||||||
public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.name.v) }
|
public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: VT.name) }
|
||||||
public var inventory: FlatbufferVector<UInt8> { return _accessor.vector(at: VTOFFSET.inventory.v, byteSize: 1) }
|
public var inventory: FlatbufferVector<UInt8> { return _accessor.vector(at: VT.inventory, byteSize: 1) }
|
||||||
public func mutate(inventory: UInt8, at index: Int32) -> Bool { let o = _accessor.offset(VTOFFSET.inventory.v); return _accessor.directMutate(inventory, index: _accessor.vector(at: o) + index * 1) }
|
public func mutate(inventory: UInt8, at index: Int32) -> Bool { let o = _accessor.offset(VT.inventory); return _accessor.directMutate(inventory, index: _accessor.vector(at: o) + index * 1) }
|
||||||
public func withUnsafePointerToInventory<T>(_ body: (UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T? { return try _accessor.withUnsafePointerToSlice(at: VTOFFSET.inventory.v, body: body) }
|
public func withUnsafePointerToInventory<T>(_ body: (UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T? { return try _accessor.withUnsafePointerToSlice(at: VT.inventory, body: body) }
|
||||||
public var color: MyGame_Sample_Color { let o = _accessor.offset(VTOFFSET.color.v); return o == 0 ? .blue : MyGame_Sample_Color(rawValue: _accessor.readBuffer(of: Int8.self, at: o)) ?? .blue }
|
public var color: MyGame_Sample_Color { let o = _accessor.offset(VT.color); return o == 0 ? .blue : MyGame_Sample_Color(rawValue: _accessor.readBuffer(of: Int8.self, at: o)) ?? .blue }
|
||||||
@discardableResult public func mutate(color: MyGame_Sample_Color) -> Bool {let o = _accessor.offset(VTOFFSET.color.v); return _accessor.mutate(color.rawValue, index: o) }
|
@discardableResult public func mutate(color: MyGame_Sample_Color) -> Bool {let o = _accessor.offset(VT.color); return _accessor.mutate(color.rawValue, index: o) }
|
||||||
public var weapons: FlatbufferVector<MyGame_Sample_Weapon> { return _accessor.vector(at: VTOFFSET.weapons.v, byteSize: 4) }
|
public var weapons: FlatbufferVector<MyGame_Sample_Weapon> { return _accessor.vector(at: VT.weapons, byteSize: 4) }
|
||||||
public var equippedType: MyGame_Sample_Equipment { let o = _accessor.offset(VTOFFSET.equippedType.v); return o == 0 ? .none_ : MyGame_Sample_Equipment(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) ?? .none_ }
|
public var equippedType: MyGame_Sample_Equipment { let o = _accessor.offset(VT.equippedType); return o == 0 ? .none_ : MyGame_Sample_Equipment(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) ?? .none_ }
|
||||||
public func equipped<T: FlatbuffersInitializable>(type: T.Type) -> T? { let o = _accessor.offset(VTOFFSET.equipped.v); return o == 0 ? nil : _accessor.union(o) }
|
public func equipped<T: FlatbuffersInitializable>(type: T.Type) -> T? { let o = _accessor.offset(VT.equipped); return o == 0 ? nil : _accessor.union(o) }
|
||||||
public var path: FlatbufferVector<MyGame_Sample_Vec3> { return _accessor.vector(at: VTOFFSET.path.v, byteSize: 12) }
|
public var path: FlatbufferVector<MyGame_Sample_Vec3> { return _accessor.vector(at: VT.path, byteSize: 12) }
|
||||||
public var mutablePath: FlatbufferVector<MyGame_Sample_Vec3_Mutable> { return _accessor.vector(at: VTOFFSET.path.v, byteSize: 12) }
|
public var mutablePath: FlatbufferVector<MyGame_Sample_Vec3_Mutable> { return _accessor.vector(at: VT.path, byteSize: 12) }
|
||||||
public func withUnsafePointerToPath<T>(_ body: (UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T? { return try _accessor.withUnsafePointerToSlice(at: VTOFFSET.path.v, body: body) }
|
public func withUnsafePointerToPath<T>(_ body: (UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T? { return try _accessor.withUnsafePointerToSlice(at: VT.path, body: body) }
|
||||||
public static func startMonster(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 11) }
|
public static func startMonster(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 11) }
|
||||||
public static func add(pos: MyGame_Sample_Vec3?, _ fbb: inout FlatBufferBuilder) { guard let pos = pos else { return }; fbb.create(struct: pos, position: VTOFFSET.pos.p) }
|
public static func add(pos: MyGame_Sample_Vec3?, _ fbb: inout FlatBufferBuilder) { guard let pos = pos else { return }; fbb.create(struct: pos, position: VT.pos) }
|
||||||
public static func add(mana: Int16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: mana, def: 150, at: VTOFFSET.mana.p) }
|
public static func add(mana: Int16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: mana, def: 150, at: VT.mana) }
|
||||||
public static func add(hp: Int16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: hp, def: 100, at: VTOFFSET.hp.p) }
|
public static func add(hp: Int16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: hp, def: 100, at: VT.hp) }
|
||||||
public static func add(name: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: name, at: VTOFFSET.name.p) }
|
public static func add(name: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: name, at: VT.name) }
|
||||||
public static func addVectorOf(inventory: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: inventory, at: VTOFFSET.inventory.p) }
|
public static func addVectorOf(inventory: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: inventory, at: VT.inventory) }
|
||||||
public static func add(color: MyGame_Sample_Color, _ fbb: inout FlatBufferBuilder) { fbb.add(element: color.rawValue, def: 2, at: VTOFFSET.color.p) }
|
public static func add(color: MyGame_Sample_Color, _ fbb: inout FlatBufferBuilder) { fbb.add(element: color.rawValue, def: 2, at: VT.color) }
|
||||||
public static func addVectorOf(weapons: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: weapons, at: VTOFFSET.weapons.p) }
|
public static func addVectorOf(weapons: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: weapons, at: VT.weapons) }
|
||||||
public static func add(equippedType: MyGame_Sample_Equipment, _ fbb: inout FlatBufferBuilder) { fbb.add(element: equippedType.rawValue, def: 0, at: VTOFFSET.equippedType.p) }
|
public static func add(equippedType: MyGame_Sample_Equipment, _ fbb: inout FlatBufferBuilder) { fbb.add(element: equippedType.rawValue, def: 0, at: VT.equippedType) }
|
||||||
public static func add(equipped: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: equipped, at: VTOFFSET.equipped.p) }
|
public static func add(equipped: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: equipped, at: VT.equipped) }
|
||||||
public static func addVectorOf(path: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: path, at: VTOFFSET.path.p) }
|
public static func addVectorOf(path: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: path, at: VT.path) }
|
||||||
public static func startVectorOfPath(_ size: Int, in builder: inout FlatBufferBuilder) {
|
public static func startVectorOfPath(_ size: Int, in builder: inout FlatBufferBuilder) {
|
||||||
builder.startVector(size * MemoryLayout<MyGame_Sample_Vec3>.size, elementSize: MemoryLayout<MyGame_Sample_Vec3>.alignment)
|
builder.startVector(size * MemoryLayout<MyGame_Sample_Vec3>.size, elementSize: MemoryLayout<MyGame_Sample_Vec3>.alignment)
|
||||||
}
|
}
|
||||||
@@ -293,14 +291,14 @@ public struct MyGame_Sample_Monster: FlatBufferTable, FlatbuffersVectorInitializ
|
|||||||
|
|
||||||
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
|
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
|
||||||
var _v = try verifier.visitTable(at: position)
|
var _v = try verifier.visitTable(at: position)
|
||||||
try _v.visit(field: VTOFFSET.pos.p, fieldName: "pos", required: false, type: MyGame_Sample_Vec3.self)
|
try _v.visit(field: VT.pos, fieldName: "pos", required: false, type: MyGame_Sample_Vec3.self)
|
||||||
try _v.visit(field: VTOFFSET.mana.p, fieldName: "mana", required: false, type: Int16.self)
|
try _v.visit(field: VT.mana, fieldName: "mana", required: false, type: Int16.self)
|
||||||
try _v.visit(field: VTOFFSET.hp.p, fieldName: "hp", required: false, type: Int16.self)
|
try _v.visit(field: VT.hp, fieldName: "hp", required: false, type: Int16.self)
|
||||||
try _v.visit(field: VTOFFSET.name.p, fieldName: "name", required: false, type: ForwardOffset<String>.self)
|
try _v.visit(field: VT.name, fieldName: "name", required: false, type: ForwardOffset<String>.self)
|
||||||
try _v.visit(field: VTOFFSET.inventory.p, fieldName: "inventory", required: false, type: ForwardOffset<Vector<UInt8, UInt8>>.self)
|
try _v.visit(field: VT.inventory, fieldName: "inventory", required: false, type: ForwardOffset<Vector<UInt8, UInt8>>.self)
|
||||||
try _v.visit(field: VTOFFSET.color.p, fieldName: "color", required: false, type: MyGame_Sample_Color.self)
|
try _v.visit(field: VT.color, fieldName: "color", required: false, type: MyGame_Sample_Color.self)
|
||||||
try _v.visit(field: VTOFFSET.weapons.p, fieldName: "weapons", required: false, type: ForwardOffset<Vector<ForwardOffset<MyGame_Sample_Weapon>, MyGame_Sample_Weapon>>.self)
|
try _v.visit(field: VT.weapons, fieldName: "weapons", required: false, type: ForwardOffset<Vector<ForwardOffset<MyGame_Sample_Weapon>, MyGame_Sample_Weapon>>.self)
|
||||||
try _v.visit(unionKey: VTOFFSET.equippedType.p, unionField: VTOFFSET.equipped.p, unionKeyName: "equippedType", fieldName: "equipped", required: false, completion: { (verifier, key: MyGame_Sample_Equipment, pos) in
|
try _v.visit(unionKey: VT.equippedType, unionField: VT.equipped, unionKeyName: "equippedType", fieldName: "equipped", required: false, completion: { (verifier, key: MyGame_Sample_Equipment, pos) in
|
||||||
switch key {
|
switch key {
|
||||||
case .none_:
|
case .none_:
|
||||||
break // NOTE - SWIFT doesnt support none
|
break // NOTE - SWIFT doesnt support none
|
||||||
@@ -308,13 +306,12 @@ public struct MyGame_Sample_Monster: FlatBufferTable, FlatbuffersVectorInitializ
|
|||||||
try ForwardOffset<MyGame_Sample_Weapon>.verify(&verifier, at: pos, of: MyGame_Sample_Weapon.self)
|
try ForwardOffset<MyGame_Sample_Weapon>.verify(&verifier, at: pos, of: MyGame_Sample_Weapon.self)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
try _v.visit(field: VTOFFSET.path.p, fieldName: "path", required: false, type: ForwardOffset<Vector<MyGame_Sample_Vec3, MyGame_Sample_Vec3>>.self)
|
try _v.visit(field: VT.path, fieldName: "path", required: false, type: ForwardOffset<Vector<MyGame_Sample_Vec3, MyGame_Sample_Vec3>>.self)
|
||||||
_v.finish()
|
_v.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension MyGame_Sample_Monster: Encodable {
|
extension MyGame_Sample_Monster: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case pos = "pos"
|
case pos = "pos"
|
||||||
case mana = "mana"
|
case mana = "mana"
|
||||||
@@ -327,6 +324,7 @@ extension MyGame_Sample_Monster: Encodable {
|
|||||||
case equipped = "equipped"
|
case equipped = "equipped"
|
||||||
case path = "path"
|
case path = "path"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encodeIfPresent(pos, forKey: .pos)
|
try container.encodeIfPresent(pos, forKey: .pos)
|
||||||
@@ -411,20 +409,18 @@ public struct MyGame_Sample_Weapon: FlatBufferTable, FlatbuffersVectorInitializa
|
|||||||
private init(_ t: Table) { _accessor = t }
|
private init(_ t: Table) { _accessor = t }
|
||||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||||
|
|
||||||
private enum VTOFFSET: VOffset {
|
private struct VT {
|
||||||
case name = 4
|
static let name: VOffset = 4
|
||||||
case damage = 6
|
static let damage: VOffset = 6
|
||||||
var v: Int32 { Int32(self.rawValue) }
|
|
||||||
var p: VOffset { self.rawValue }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public var name: String? { let o = _accessor.offset(VTOFFSET.name.v); return o == 0 ? nil : _accessor.string(at: o) }
|
public var name: String? { let o = _accessor.offset(VT.name); return o == 0 ? nil : _accessor.string(at: o) }
|
||||||
public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.name.v) }
|
public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: VT.name) }
|
||||||
public var damage: Int16 { let o = _accessor.offset(VTOFFSET.damage.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int16.self, at: o) }
|
public var damage: Int16 { let o = _accessor.offset(VT.damage); return o == 0 ? 0 : _accessor.readBuffer(of: Int16.self, at: o) }
|
||||||
@discardableResult public func mutate(damage: Int16) -> Bool {let o = _accessor.offset(VTOFFSET.damage.v); return _accessor.mutate(damage, index: o) }
|
@discardableResult public func mutate(damage: Int16) -> Bool {let o = _accessor.offset(VT.damage); return _accessor.mutate(damage, index: o) }
|
||||||
public static func startWeapon(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 2) }
|
public static func startWeapon(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 2) }
|
||||||
public static func add(name: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: name, at: VTOFFSET.name.p) }
|
public static func add(name: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: name, at: VT.name) }
|
||||||
public static func add(damage: Int16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: damage, def: 0, at: VTOFFSET.damage.p) }
|
public static func add(damage: Int16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: damage, def: 0, at: VT.damage) }
|
||||||
public static func endWeapon(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
public static func endWeapon(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||||
public static func createWeapon(
|
public static func createWeapon(
|
||||||
_ fbb: inout FlatBufferBuilder,
|
_ fbb: inout FlatBufferBuilder,
|
||||||
@@ -461,18 +457,18 @@ public struct MyGame_Sample_Weapon: FlatBufferTable, FlatbuffersVectorInitializa
|
|||||||
|
|
||||||
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
|
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
|
||||||
var _v = try verifier.visitTable(at: position)
|
var _v = try verifier.visitTable(at: position)
|
||||||
try _v.visit(field: VTOFFSET.name.p, fieldName: "name", required: false, type: ForwardOffset<String>.self)
|
try _v.visit(field: VT.name, fieldName: "name", required: false, type: ForwardOffset<String>.self)
|
||||||
try _v.visit(field: VTOFFSET.damage.p, fieldName: "damage", required: false, type: Int16.self)
|
try _v.visit(field: VT.damage, fieldName: "damage", required: false, type: Int16.self)
|
||||||
_v.finish()
|
_v.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension MyGame_Sample_Weapon: Encodable {
|
extension MyGame_Sample_Weapon: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case name = "name"
|
case name = "name"
|
||||||
case damage = "damage"
|
case damage = "damage"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encodeIfPresent(name, forKey: .name)
|
try container.encodeIfPresent(name, forKey: .name)
|
||||||
|
|||||||
@@ -2,10 +2,13 @@
|
|||||||
// @generated
|
// @generated
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
pub const ENUM_MIN_COLOR: i8 = 0;
|
pub const ENUM_MIN_COLOR: i8 = 0;
|
||||||
|
|
||||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
pub const ENUM_MAX_COLOR: i8 = 2;
|
pub const ENUM_MAX_COLOR: i8 = 2;
|
||||||
|
|
||||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub const ENUM_VALUES_COLOR: [Color; 3] = [
|
pub const ENUM_VALUES_COLOR: [Color; 3] = [
|
||||||
@@ -17,6 +20,7 @@ pub const ENUM_VALUES_COLOR: [Color; 3] = [
|
|||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct Color(pub i8);
|
pub struct Color(pub i8);
|
||||||
|
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
impl Color {
|
impl Color {
|
||||||
pub const Red: Self = Self(0);
|
pub const Red: Self = Self(0);
|
||||||
@@ -30,6 +34,7 @@ impl Color {
|
|||||||
Self::Green,
|
Self::Green,
|
||||||
Self::Blue,
|
Self::Blue,
|
||||||
];
|
];
|
||||||
|
|
||||||
/// Returns the variant's name or "" if unknown.
|
/// Returns the variant's name or "" if unknown.
|
||||||
pub fn variant_name(self) -> Option<&'static str> {
|
pub fn variant_name(self) -> Option<&'static str> {
|
||||||
match self {
|
match self {
|
||||||
@@ -40,6 +45,7 @@ impl Color {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::fmt::Debug for Color {
|
impl ::core::fmt::Debug for Color {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
if let Some(name) = self.variant_name() {
|
if let Some(name) = self.variant_name() {
|
||||||
@@ -49,8 +55,10 @@ impl ::core::fmt::Debug for Color {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for Color {
|
impl<'a> ::flatbuffers::Follow<'a> for Color {
|
||||||
type Inner = Self;
|
type Inner = Self;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
|
let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
|
||||||
@@ -60,6 +68,7 @@ impl<'a> ::flatbuffers::Follow<'a> for Color {
|
|||||||
|
|
||||||
impl ::flatbuffers::Push for Color {
|
impl ::flatbuffers::Push for Color {
|
||||||
type Output = Color;
|
type Output = Color;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||||
unsafe { ::flatbuffers::emplace_scalar::<i8>(dst, self.0) };
|
unsafe { ::flatbuffers::emplace_scalar::<i8>(dst, self.0) };
|
||||||
@@ -68,10 +77,12 @@ impl ::flatbuffers::Push for Color {
|
|||||||
|
|
||||||
impl ::flatbuffers::EndianScalar for Color {
|
impl ::flatbuffers::EndianScalar for Color {
|
||||||
type Scalar = i8;
|
type Scalar = i8;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_little_endian(self) -> i8 {
|
fn to_little_endian(self) -> i8 {
|
||||||
self.0.to_le()
|
self.0.to_le()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(clippy::wrong_self_convention)]
|
#[allow(clippy::wrong_self_convention)]
|
||||||
fn from_little_endian(v: i8) -> Self {
|
fn from_little_endian(v: i8) -> Self {
|
||||||
|
|||||||
@@ -2,10 +2,13 @@
|
|||||||
// @generated
|
// @generated
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
pub const ENUM_MIN_EQUIPMENT: u8 = 0;
|
pub const ENUM_MIN_EQUIPMENT: u8 = 0;
|
||||||
|
|
||||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
pub const ENUM_MAX_EQUIPMENT: u8 = 1;
|
pub const ENUM_MAX_EQUIPMENT: u8 = 1;
|
||||||
|
|
||||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub const ENUM_VALUES_EQUIPMENT: [Equipment; 2] = [
|
pub const ENUM_VALUES_EQUIPMENT: [Equipment; 2] = [
|
||||||
@@ -16,6 +19,7 @@ pub const ENUM_VALUES_EQUIPMENT: [Equipment; 2] = [
|
|||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct Equipment(pub u8);
|
pub struct Equipment(pub u8);
|
||||||
|
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
impl Equipment {
|
impl Equipment {
|
||||||
pub const NONE: Self = Self(0);
|
pub const NONE: Self = Self(0);
|
||||||
@@ -27,6 +31,7 @@ impl Equipment {
|
|||||||
Self::NONE,
|
Self::NONE,
|
||||||
Self::Weapon,
|
Self::Weapon,
|
||||||
];
|
];
|
||||||
|
|
||||||
/// Returns the variant's name or "" if unknown.
|
/// Returns the variant's name or "" if unknown.
|
||||||
pub fn variant_name(self) -> Option<&'static str> {
|
pub fn variant_name(self) -> Option<&'static str> {
|
||||||
match self {
|
match self {
|
||||||
@@ -36,6 +41,7 @@ impl Equipment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::fmt::Debug for Equipment {
|
impl ::core::fmt::Debug for Equipment {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
if let Some(name) = self.variant_name() {
|
if let Some(name) = self.variant_name() {
|
||||||
@@ -45,8 +51,10 @@ impl ::core::fmt::Debug for Equipment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for Equipment {
|
impl<'a> ::flatbuffers::Follow<'a> for Equipment {
|
||||||
type Inner = Self;
|
type Inner = Self;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
|
let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
|
||||||
@@ -56,6 +64,7 @@ impl<'a> ::flatbuffers::Follow<'a> for Equipment {
|
|||||||
|
|
||||||
impl ::flatbuffers::Push for Equipment {
|
impl ::flatbuffers::Push for Equipment {
|
||||||
type Output = Equipment;
|
type Output = Equipment;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||||
unsafe { ::flatbuffers::emplace_scalar::<u8>(dst, self.0) };
|
unsafe { ::flatbuffers::emplace_scalar::<u8>(dst, self.0) };
|
||||||
@@ -64,10 +73,12 @@ impl ::flatbuffers::Push for Equipment {
|
|||||||
|
|
||||||
impl ::flatbuffers::EndianScalar for Equipment {
|
impl ::flatbuffers::EndianScalar for Equipment {
|
||||||
type Scalar = u8;
|
type Scalar = u8;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_little_endian(self) -> u8 {
|
fn to_little_endian(self) -> u8 {
|
||||||
self.0.to_le()
|
self.0.to_le()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(clippy::wrong_self_convention)]
|
#[allow(clippy::wrong_self_convention)]
|
||||||
fn from_little_endian(v: u8) -> Self {
|
fn from_little_endian(v: u8) -> Self {
|
||||||
@@ -86,6 +97,7 @@ impl<'a> ::flatbuffers::Verifiable for Equipment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ::flatbuffers::SimpleToVerifyInSlice for Equipment {}
|
impl ::flatbuffers::SimpleToVerifyInSlice for Equipment {}
|
||||||
|
|
||||||
pub struct EquipmentUnionTableOffset {}
|
pub struct EquipmentUnionTableOffset {}
|
||||||
|
|
||||||
#[allow(clippy::upper_case_acronyms)]
|
#[allow(clippy::upper_case_acronyms)]
|
||||||
@@ -95,11 +107,13 @@ pub enum EquipmentT {
|
|||||||
NONE,
|
NONE,
|
||||||
Weapon(alloc::boxed::Box<WeaponT>),
|
Weapon(alloc::boxed::Box<WeaponT>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for EquipmentT {
|
impl Default for EquipmentT {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::NONE
|
Self::NONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EquipmentT {
|
impl EquipmentT {
|
||||||
pub fn equipment_type(&self) -> Equipment {
|
pub fn equipment_type(&self) -> Equipment {
|
||||||
match self {
|
match self {
|
||||||
@@ -107,12 +121,14 @@ impl EquipmentT {
|
|||||||
Self::Weapon(_) => Equipment::Weapon,
|
Self::Weapon(_) => Equipment::Weapon,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(&self, fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>) -> Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>> {
|
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(&self, fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>) -> Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>> {
|
||||||
match self {
|
match self {
|
||||||
Self::NONE => None,
|
Self::NONE => None,
|
||||||
Self::Weapon(v) => Some(v.pack(fbb).as_union_value()),
|
Self::Weapon(v) => Some(v.pack(fbb).as_union_value()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If the union variant matches, return the owned WeaponT, setting the union to NONE.
|
/// If the union variant matches, return the owned WeaponT, setting the union to NONE.
|
||||||
pub fn take_weapon(&mut self) -> Option<alloc::boxed::Box<WeaponT>> {
|
pub fn take_weapon(&mut self) -> Option<alloc::boxed::Box<WeaponT>> {
|
||||||
if let Self::Weapon(_) = self {
|
if let Self::Weapon(_) = self {
|
||||||
@@ -126,12 +142,15 @@ impl EquipmentT {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If the union variant matches, return a reference to the WeaponT.
|
/// If the union variant matches, return a reference to the WeaponT.
|
||||||
pub fn as_weapon(&self) -> Option<&WeaponT> {
|
pub fn as_weapon(&self) -> Option<&WeaponT> {
|
||||||
if let Self::Weapon(v) = self { Some(v.as_ref()) } else { None }
|
if let Self::Weapon(v) = self { Some(v.as_ref()) } else { None }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If the union variant matches, return a mutable reference to the WeaponT.
|
/// If the union variant matches, return a mutable reference to the WeaponT.
|
||||||
pub fn as_weapon_mut(&mut self) -> Option<&mut WeaponT> {
|
pub fn as_weapon_mut(&mut self) -> Option<&mut WeaponT> {
|
||||||
if let Self::Weapon(v) = self { Some(v.as_mut()) } else { None }
|
if let Self::Weapon(v) = self { Some(v.as_mut()) } else { None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,15 +2,17 @@
|
|||||||
// @generated
|
// @generated
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use super::*;
|
use super::*;
|
||||||
pub enum MonsterOffset {}
|
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
|
||||||
|
|
||||||
|
pub enum MonsterOffset {}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
pub struct Monster<'a> {
|
pub struct Monster<'a> {
|
||||||
pub _tab: ::flatbuffers::Table<'a>,
|
pub _tab: ::flatbuffers::Table<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for Monster<'a> {
|
impl<'a> ::flatbuffers::Follow<'a> for Monster<'a> {
|
||||||
type Inner = Monster<'a>;
|
type Inner = Monster<'a>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||||
@@ -37,6 +39,7 @@ impl<'a> Monster<'a> {
|
|||||||
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||||
Monster { _tab: table }
|
Monster { _tab: table }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||||
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||||
@@ -104,6 +107,7 @@ impl<'a> Monster<'a> {
|
|||||||
// which contains a valid value in this slot
|
// which contains a valid value in this slot
|
||||||
unsafe { self._tab.get::<Vec3>(Monster::VT_POS, None)}
|
unsafe { self._tab.get::<Vec3>(Monster::VT_POS, None)}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn mana(&self) -> i16 {
|
pub fn mana(&self) -> i16 {
|
||||||
// Safety:
|
// Safety:
|
||||||
@@ -111,6 +115,7 @@ impl<'a> Monster<'a> {
|
|||||||
// which contains a valid value in this slot
|
// which contains a valid value in this slot
|
||||||
unsafe { self._tab.get::<i16>(Monster::VT_MANA, Some(150)).unwrap()}
|
unsafe { self._tab.get::<i16>(Monster::VT_MANA, Some(150)).unwrap()}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn hp(&self) -> i16 {
|
pub fn hp(&self) -> i16 {
|
||||||
// Safety:
|
// Safety:
|
||||||
@@ -118,6 +123,7 @@ impl<'a> Monster<'a> {
|
|||||||
// which contains a valid value in this slot
|
// which contains a valid value in this slot
|
||||||
unsafe { self._tab.get::<i16>(Monster::VT_HP, Some(100)).unwrap()}
|
unsafe { self._tab.get::<i16>(Monster::VT_HP, Some(100)).unwrap()}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn name(&self) -> Option<&'a str> {
|
pub fn name(&self) -> Option<&'a str> {
|
||||||
// Safety:
|
// Safety:
|
||||||
@@ -125,6 +131,7 @@ impl<'a> Monster<'a> {
|
|||||||
// which contains a valid value in this slot
|
// which contains a valid value in this slot
|
||||||
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Monster::VT_NAME, None)}
|
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Monster::VT_NAME, None)}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn inventory(&self) -> Option<::flatbuffers::Vector<'a, u8>> {
|
pub fn inventory(&self) -> Option<::flatbuffers::Vector<'a, u8>> {
|
||||||
// Safety:
|
// Safety:
|
||||||
@@ -132,6 +139,7 @@ impl<'a> Monster<'a> {
|
|||||||
// which contains a valid value in this slot
|
// which contains a valid value in this slot
|
||||||
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_INVENTORY, None)}
|
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_INVENTORY, None)}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn color(&self) -> Color {
|
pub fn color(&self) -> Color {
|
||||||
// Safety:
|
// Safety:
|
||||||
@@ -139,6 +147,7 @@ impl<'a> Monster<'a> {
|
|||||||
// which contains a valid value in this slot
|
// which contains a valid value in this slot
|
||||||
unsafe { self._tab.get::<Color>(Monster::VT_COLOR, Some(Color::Blue)).unwrap()}
|
unsafe { self._tab.get::<Color>(Monster::VT_COLOR, Some(Color::Blue)).unwrap()}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn weapons(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Weapon<'a>>>> {
|
pub fn weapons(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Weapon<'a>>>> {
|
||||||
// Safety:
|
// Safety:
|
||||||
@@ -146,6 +155,7 @@ impl<'a> Monster<'a> {
|
|||||||
// which contains a valid value in this slot
|
// which contains a valid value in this slot
|
||||||
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Weapon>>>>(Monster::VT_WEAPONS, None)}
|
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Weapon>>>>(Monster::VT_WEAPONS, None)}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn equipped_type(&self) -> Equipment {
|
pub fn equipped_type(&self) -> Equipment {
|
||||||
// Safety:
|
// Safety:
|
||||||
@@ -153,6 +163,7 @@ impl<'a> Monster<'a> {
|
|||||||
// which contains a valid value in this slot
|
// which contains a valid value in this slot
|
||||||
unsafe { self._tab.get::<Equipment>(Monster::VT_EQUIPPED_TYPE, Some(Equipment::NONE)).unwrap()}
|
unsafe { self._tab.get::<Equipment>(Monster::VT_EQUIPPED_TYPE, Some(Equipment::NONE)).unwrap()}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn equipped(&self) -> Option<::flatbuffers::Table<'a>> {
|
pub fn equipped(&self) -> Option<::flatbuffers::Table<'a>> {
|
||||||
// Safety:
|
// Safety:
|
||||||
@@ -160,6 +171,7 @@ impl<'a> Monster<'a> {
|
|||||||
// which contains a valid value in this slot
|
// which contains a valid value in this slot
|
||||||
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Monster::VT_EQUIPPED, None)}
|
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Monster::VT_EQUIPPED, None)}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn path(&self) -> Option<::flatbuffers::Vector<'a, Vec3>> {
|
pub fn path(&self) -> Option<::flatbuffers::Vector<'a, Vec3>> {
|
||||||
// Safety:
|
// Safety:
|
||||||
@@ -167,6 +179,7 @@ impl<'a> Monster<'a> {
|
|||||||
// which contains a valid value in this slot
|
// which contains a valid value in this slot
|
||||||
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Vec3>>>(Monster::VT_PATH, None)}
|
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Vec3>>>(Monster::VT_PATH, None)}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn equipped_as_weapon(&self) -> Option<Weapon<'a>> {
|
pub fn equipped_as_weapon(&self) -> Option<Weapon<'a>> {
|
||||||
@@ -181,7 +194,6 @@ impl<'a> Monster<'a> {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::flatbuffers::Verifiable for Monster<'_> {
|
impl ::flatbuffers::Verifiable for Monster<'_> {
|
||||||
@@ -208,6 +220,7 @@ impl ::flatbuffers::Verifiable for Monster<'_> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct MonsterArgs<'a> {
|
pub struct MonsterArgs<'a> {
|
||||||
pub pos: Option<&'a Vec3>,
|
pub pos: Option<&'a Vec3>,
|
||||||
pub mana: i16,
|
pub mana: i16,
|
||||||
@@ -220,6 +233,7 @@ pub struct MonsterArgs<'a> {
|
|||||||
pub equipped: Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>,
|
pub equipped: Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>,
|
||||||
pub path: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, Vec3>>>,
|
pub path: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, Vec3>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Default for MonsterArgs<'a> {
|
impl<'a> Default for MonsterArgs<'a> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
@@ -242,47 +256,58 @@ pub struct MonsterBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
|
|||||||
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> MonsterBuilder<'a, 'b, A> {
|
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> MonsterBuilder<'a, 'b, A> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_pos(&mut self, pos: &Vec3) {
|
pub fn add_pos(&mut self, pos: &Vec3) {
|
||||||
self.fbb_.push_slot_always::<&Vec3>(Monster::VT_POS, pos);
|
self.fbb_.push_slot_always::<&Vec3>(Monster::VT_POS, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_mana(&mut self, mana: i16) {
|
pub fn add_mana(&mut self, mana: i16) {
|
||||||
self.fbb_.push_slot::<i16>(Monster::VT_MANA, mana, 150);
|
self.fbb_.push_slot::<i16>(Monster::VT_MANA, mana, 150);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_hp(&mut self, hp: i16) {
|
pub fn add_hp(&mut self, hp: i16) {
|
||||||
self.fbb_.push_slot::<i16>(Monster::VT_HP, hp, 100);
|
self.fbb_.push_slot::<i16>(Monster::VT_HP, hp, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_name(&mut self, name: ::flatbuffers::WIPOffset<&'b str>) {
|
pub fn add_name(&mut self, name: ::flatbuffers::WIPOffset<&'b str>) {
|
||||||
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_NAME, name);
|
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_NAME, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_inventory(&mut self, inventory: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) {
|
pub fn add_inventory(&mut self, inventory: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) {
|
||||||
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_INVENTORY, inventory);
|
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_INVENTORY, inventory);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_color(&mut self, color: Color) {
|
pub fn add_color(&mut self, color: Color) {
|
||||||
self.fbb_.push_slot::<Color>(Monster::VT_COLOR, color, Color::Blue);
|
self.fbb_.push_slot::<Color>(Monster::VT_COLOR, color, Color::Blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_weapons(&mut self, weapons: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<Weapon<'b >>>>) {
|
pub fn add_weapons(&mut self, weapons: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<Weapon<'b >>>>) {
|
||||||
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_WEAPONS, weapons);
|
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_WEAPONS, weapons);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_equipped_type(&mut self, equipped_type: Equipment) {
|
pub fn add_equipped_type(&mut self, equipped_type: Equipment) {
|
||||||
self.fbb_.push_slot::<Equipment>(Monster::VT_EQUIPPED_TYPE, equipped_type, Equipment::NONE);
|
self.fbb_.push_slot::<Equipment>(Monster::VT_EQUIPPED_TYPE, equipped_type, Equipment::NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_equipped(&mut self, equipped: ::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>) {
|
pub fn add_equipped(&mut self, equipped: ::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>) {
|
||||||
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_EQUIPPED, equipped);
|
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_EQUIPPED, equipped);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_path(&mut self, path: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , Vec3>>) {
|
pub fn add_path(&mut self, path: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , Vec3>>) {
|
||||||
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_PATH, path);
|
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_PATH, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> MonsterBuilder<'a, 'b, A> {
|
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> MonsterBuilder<'a, 'b, A> {
|
||||||
let start = _fbb.start_table();
|
let start = _fbb.start_table();
|
||||||
@@ -291,6 +316,7 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> MonsterBuilder<'a, 'b, A> {
|
|||||||
start_: start,
|
start_: start,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn finish(self) -> ::flatbuffers::WIPOffset<Monster<'a>> {
|
pub fn finish(self) -> ::flatbuffers::WIPOffset<Monster<'a>> {
|
||||||
let o = self.fbb_.end_table(self.start_);
|
let o = self.fbb_.end_table(self.start_);
|
||||||
@@ -326,6 +352,7 @@ impl ::core::fmt::Debug for Monster<'_> {
|
|||||||
ds.finish()
|
ds.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct MonsterT {
|
pub struct MonsterT {
|
||||||
@@ -339,6 +366,7 @@ pub struct MonsterT {
|
|||||||
pub equipped: EquipmentT,
|
pub equipped: EquipmentT,
|
||||||
pub path: Option<alloc::vec::Vec<Vec3T>>,
|
pub path: Option<alloc::vec::Vec<Vec3T>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for MonsterT {
|
impl Default for MonsterT {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
@@ -354,6 +382,7 @@ impl Default for MonsterT {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MonsterT {
|
impl MonsterT {
|
||||||
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
||||||
&self,
|
&self,
|
||||||
@@ -392,74 +421,85 @@ impl MonsterT {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[inline]
|
|
||||||
/// Verifies that a buffer of bytes contains a `Monster`
|
/// Verifies that a buffer of bytes contains a `Monster`
|
||||||
/// and returns it.
|
/// and returns it.
|
||||||
/// Note that verification is still experimental and may not
|
/// Note that verification is still experimental and may not
|
||||||
/// catch every error, or be maximally performant. For the
|
/// catch every error, or be maximally performant. For the
|
||||||
/// previous, unchecked, behavior use
|
/// previous, unchecked, behavior use
|
||||||
/// `root_as_monster_unchecked`.
|
/// `root_as_monster_unchecked`.
|
||||||
|
#[inline]
|
||||||
pub fn root_as_monster(buf: &[u8]) -> Result<Monster<'_>, ::flatbuffers::InvalidFlatbuffer> {
|
pub fn root_as_monster(buf: &[u8]) -> Result<Monster<'_>, ::flatbuffers::InvalidFlatbuffer> {
|
||||||
::flatbuffers::root::<Monster>(buf)
|
::flatbuffers::root::<Monster>(buf)
|
||||||
}
|
}
|
||||||
#[inline]
|
|
||||||
/// Verifies that a buffer of bytes contains a size prefixed
|
/// Verifies that a buffer of bytes contains a size prefixed
|
||||||
/// `Monster` and returns it.
|
/// `Monster` and returns it.
|
||||||
/// Note that verification is still experimental and may not
|
/// Note that verification is still experimental and may not
|
||||||
/// catch every error, or be maximally performant. For the
|
/// catch every error, or be maximally performant. For the
|
||||||
/// previous, unchecked, behavior use
|
/// previous, unchecked, behavior use
|
||||||
/// `size_prefixed_root_as_monster_unchecked`.
|
/// `size_prefixed_root_as_monster_unchecked`.
|
||||||
|
#[inline]
|
||||||
pub fn size_prefixed_root_as_monster(buf: &[u8]) -> Result<Monster<'_>, ::flatbuffers::InvalidFlatbuffer> {
|
pub fn size_prefixed_root_as_monster(buf: &[u8]) -> Result<Monster<'_>, ::flatbuffers::InvalidFlatbuffer> {
|
||||||
::flatbuffers::size_prefixed_root::<Monster>(buf)
|
::flatbuffers::size_prefixed_root::<Monster>(buf)
|
||||||
}
|
}
|
||||||
#[inline]
|
|
||||||
/// Verifies, with the given options, that a buffer of bytes
|
/// Verifies, with the given options, that a buffer of bytes
|
||||||
/// contains a `Monster` and returns it.
|
/// contains a `Monster` and returns it.
|
||||||
/// Note that verification is still experimental and may not
|
/// Note that verification is still experimental and may not
|
||||||
/// catch every error, or be maximally performant. For the
|
/// catch every error, or be maximally performant. For the
|
||||||
/// previous, unchecked, behavior use
|
/// previous, unchecked, behavior use
|
||||||
/// `root_as_monster_unchecked`.
|
/// `root_as_monster_unchecked`.
|
||||||
|
#[inline]
|
||||||
pub fn root_as_monster_with_opts<'b, 'o>(
|
pub fn root_as_monster_with_opts<'b, 'o>(
|
||||||
opts: &'o ::flatbuffers::VerifierOptions,
|
opts: &'o ::flatbuffers::VerifierOptions,
|
||||||
buf: &'b [u8],
|
buf: &'b [u8],
|
||||||
) -> Result<Monster<'b>, ::flatbuffers::InvalidFlatbuffer> {
|
) -> Result<Monster<'b>, ::flatbuffers::InvalidFlatbuffer> {
|
||||||
::flatbuffers::root_with_opts::<Monster<'b>>(opts, buf)
|
::flatbuffers::root_with_opts::<Monster<'b>>(opts, buf)
|
||||||
}
|
}
|
||||||
#[inline]
|
|
||||||
/// Verifies, with the given verifier options, that a buffer of
|
/// Verifies, with the given verifier options, that a buffer of
|
||||||
/// bytes contains a size prefixed `Monster` and returns
|
/// bytes contains a size prefixed `Monster` and returns
|
||||||
/// it. Note that verification is still experimental and may not
|
/// it. Note that verification is still experimental and may not
|
||||||
/// catch every error, or be maximally performant. For the
|
/// catch every error, or be maximally performant. For the
|
||||||
/// previous, unchecked, behavior use
|
/// previous, unchecked, behavior use
|
||||||
/// `root_as_monster_unchecked`.
|
/// `root_as_monster_unchecked`.
|
||||||
|
#[inline]
|
||||||
pub fn size_prefixed_root_as_monster_with_opts<'b, 'o>(
|
pub fn size_prefixed_root_as_monster_with_opts<'b, 'o>(
|
||||||
opts: &'o ::flatbuffers::VerifierOptions,
|
opts: &'o ::flatbuffers::VerifierOptions,
|
||||||
buf: &'b [u8],
|
buf: &'b [u8],
|
||||||
) -> Result<Monster<'b>, ::flatbuffers::InvalidFlatbuffer> {
|
) -> Result<Monster<'b>, ::flatbuffers::InvalidFlatbuffer> {
|
||||||
::flatbuffers::size_prefixed_root_with_opts::<Monster<'b>>(opts, buf)
|
::flatbuffers::size_prefixed_root_with_opts::<Monster<'b>>(opts, buf)
|
||||||
}
|
}
|
||||||
#[inline]
|
|
||||||
/// Assumes, without verification, that a buffer of bytes contains a Monster and returns it.
|
/// Assumes, without verification, that a buffer of bytes contains a Monster and returns it.
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// Callers must trust the given bytes do indeed contain a valid `Monster`.
|
/// Callers must trust the given bytes do indeed contain a valid `Monster`.
|
||||||
|
#[inline]
|
||||||
pub unsafe fn root_as_monster_unchecked(buf: &[u8]) -> Monster<'_> {
|
pub unsafe fn root_as_monster_unchecked(buf: &[u8]) -> Monster<'_> {
|
||||||
unsafe { ::flatbuffers::root_unchecked::<Monster>(buf) }
|
unsafe { ::flatbuffers::root_unchecked::<Monster>(buf) }
|
||||||
}
|
}
|
||||||
#[inline]
|
|
||||||
/// Assumes, without verification, that a buffer of bytes contains a size prefixed Monster and returns it.
|
/// Assumes, without verification, that a buffer of bytes contains a size prefixed Monster and returns it.
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// Callers must trust the given bytes do indeed contain a valid size prefixed `Monster`.
|
/// Callers must trust the given bytes do indeed contain a valid size prefixed `Monster`.
|
||||||
|
#[inline]
|
||||||
pub unsafe fn size_prefixed_root_as_monster_unchecked(buf: &[u8]) -> Monster<'_> {
|
pub unsafe fn size_prefixed_root_as_monster_unchecked(buf: &[u8]) -> Monster<'_> {
|
||||||
unsafe { ::flatbuffers::size_prefixed_root_unchecked::<Monster>(buf) }
|
unsafe { ::flatbuffers::size_prefixed_root_unchecked::<Monster>(buf) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn finish_monster_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
|
pub fn finish_monster_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
|
||||||
fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
root: ::flatbuffers::WIPOffset<Monster<'a>>) {
|
root: ::flatbuffers::WIPOffset<Monster<'a>>
|
||||||
|
) {
|
||||||
fbb.finish(root, None);
|
fbb.finish(root, None);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn finish_size_prefixed_monster_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, root: ::flatbuffers::WIPOffset<Monster<'a>>) {
|
pub fn finish_size_prefixed_monster_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
|
||||||
|
fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
|
root: ::flatbuffers::WIPOffset<Monster<'a>>
|
||||||
|
) {
|
||||||
fbb.finish_size_prefixed(root, None);
|
fbb.finish_size_prefixed(root, None);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,15 +2,18 @@
|
|||||||
// @generated
|
// @generated
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
// struct Vec3, aligned to 4
|
// struct Vec3, aligned to 4
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Clone, Copy, PartialEq)]
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
pub struct Vec3(pub [u8; 12]);
|
pub struct Vec3(pub [u8; 12]);
|
||||||
|
|
||||||
impl Default for Vec3 {
|
impl Default for Vec3 {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self([0; 12])
|
Self([0; 12])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::fmt::Debug for Vec3 {
|
impl ::core::fmt::Debug for Vec3 {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
f.debug_struct("Vec3")
|
f.debug_struct("Vec3")
|
||||||
@@ -22,27 +25,34 @@ impl ::core::fmt::Debug for Vec3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ::flatbuffers::SimpleToVerifyInSlice for Vec3 {}
|
impl ::flatbuffers::SimpleToVerifyInSlice for Vec3 {}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for Vec3 {
|
impl<'a> ::flatbuffers::Follow<'a> for Vec3 {
|
||||||
type Inner = &'a Vec3;
|
type Inner = &'a Vec3;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
unsafe { <&'a Vec3>::follow(buf, loc) }
|
unsafe { <&'a Vec3>::follow(buf, loc) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for &'a Vec3 {
|
impl<'a> ::flatbuffers::Follow<'a> for &'a Vec3 {
|
||||||
type Inner = &'a Vec3;
|
type Inner = &'a Vec3;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
unsafe { ::flatbuffers::follow_cast_ref::<Vec3>(buf, loc) }
|
unsafe { ::flatbuffers::follow_cast_ref::<Vec3>(buf, loc) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'b> ::flatbuffers::Push for Vec3 {
|
impl<'b> ::flatbuffers::Push for Vec3 {
|
||||||
type Output = Vec3;
|
type Output = Vec3;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||||
let src = unsafe { ::core::slice::from_raw_parts(self as *const Vec3 as *const u8, <Self as ::flatbuffers::Push>::size()) };
|
let src = unsafe { ::core::slice::from_raw_parts(self as *const Vec3 as *const u8, <Self as ::flatbuffers::Push>::size()) };
|
||||||
dst.copy_from_slice(src);
|
dst.copy_from_slice(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn alignment() -> ::flatbuffers::PushAlignment {
|
fn alignment() -> ::flatbuffers::PushAlignment {
|
||||||
::flatbuffers::PushAlignment::new(4)
|
::flatbuffers::PushAlignment::new(4)
|
||||||
@@ -172,12 +182,22 @@ impl<'a> Vec3 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct Vec3T {
|
pub struct Vec3T {
|
||||||
pub x: f32,
|
pub x: f32,
|
||||||
pub y: f32,
|
pub y: f32,
|
||||||
pub z: f32,
|
pub z: f32,
|
||||||
}
|
}
|
||||||
|
impl Default for Vec3T {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
x: 0.0,
|
||||||
|
y: 0.0,
|
||||||
|
z: 0.0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Vec3T {
|
impl Vec3T {
|
||||||
pub fn pack(&self) -> Vec3 {
|
pub fn pack(&self) -> Vec3 {
|
||||||
Vec3::new(
|
Vec3::new(
|
||||||
@@ -187,4 +207,3 @@ impl Vec3T {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,15 +2,17 @@
|
|||||||
// @generated
|
// @generated
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use super::*;
|
use super::*;
|
||||||
pub enum WeaponOffset {}
|
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
|
||||||
|
|
||||||
|
pub enum WeaponOffset {}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
pub struct Weapon<'a> {
|
pub struct Weapon<'a> {
|
||||||
pub _tab: ::flatbuffers::Table<'a>,
|
pub _tab: ::flatbuffers::Table<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for Weapon<'a> {
|
impl<'a> ::flatbuffers::Follow<'a> for Weapon<'a> {
|
||||||
type Inner = Weapon<'a>;
|
type Inner = Weapon<'a>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||||
@@ -29,6 +31,7 @@ impl<'a> Weapon<'a> {
|
|||||||
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||||
Weapon { _tab: table }
|
Weapon { _tab: table }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||||
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||||
@@ -58,6 +61,7 @@ impl<'a> Weapon<'a> {
|
|||||||
// which contains a valid value in this slot
|
// which contains a valid value in this slot
|
||||||
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Weapon::VT_NAME, None)}
|
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Weapon::VT_NAME, None)}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn damage(&self) -> i16 {
|
pub fn damage(&self) -> i16 {
|
||||||
// Safety:
|
// Safety:
|
||||||
@@ -79,10 +83,12 @@ impl ::flatbuffers::Verifiable for Weapon<'_> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct WeaponArgs<'a> {
|
pub struct WeaponArgs<'a> {
|
||||||
pub name: Option<::flatbuffers::WIPOffset<&'a str>>,
|
pub name: Option<::flatbuffers::WIPOffset<&'a str>>,
|
||||||
pub damage: i16,
|
pub damage: i16,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Default for WeaponArgs<'a> {
|
impl<'a> Default for WeaponArgs<'a> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
@@ -97,15 +103,18 @@ pub struct WeaponBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
|
|||||||
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> WeaponBuilder<'a, 'b, A> {
|
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> WeaponBuilder<'a, 'b, A> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_name(&mut self, name: ::flatbuffers::WIPOffset<&'b str>) {
|
pub fn add_name(&mut self, name: ::flatbuffers::WIPOffset<&'b str>) {
|
||||||
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Weapon::VT_NAME, name);
|
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Weapon::VT_NAME, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_damage(&mut self, damage: i16) {
|
pub fn add_damage(&mut self, damage: i16) {
|
||||||
self.fbb_.push_slot::<i16>(Weapon::VT_DAMAGE, damage, 0);
|
self.fbb_.push_slot::<i16>(Weapon::VT_DAMAGE, damage, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> WeaponBuilder<'a, 'b, A> {
|
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> WeaponBuilder<'a, 'b, A> {
|
||||||
let start = _fbb.start_table();
|
let start = _fbb.start_table();
|
||||||
@@ -114,6 +123,7 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> WeaponBuilder<'a, 'b, A> {
|
|||||||
start_: start,
|
start_: start,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn finish(self) -> ::flatbuffers::WIPOffset<Weapon<'a>> {
|
pub fn finish(self) -> ::flatbuffers::WIPOffset<Weapon<'a>> {
|
||||||
let o = self.fbb_.end_table(self.start_);
|
let o = self.fbb_.end_table(self.start_);
|
||||||
@@ -129,12 +139,14 @@ impl ::core::fmt::Debug for Weapon<'_> {
|
|||||||
ds.finish()
|
ds.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct WeaponT {
|
pub struct WeaponT {
|
||||||
pub name: Option<alloc::string::String>,
|
pub name: Option<alloc::string::String>,
|
||||||
pub damage: i16,
|
pub damage: i16,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for WeaponT {
|
impl Default for WeaponT {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
@@ -143,6 +155,7 @@ impl Default for WeaponT {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WeaponT {
|
impl WeaponT {
|
||||||
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
||||||
&self,
|
&self,
|
||||||
|
|||||||
@@ -383,11 +383,6 @@ flatc(
|
|||||||
schema="native_type_test.fbs",
|
schema="native_type_test.fbs",
|
||||||
)
|
)
|
||||||
|
|
||||||
flatc(
|
|
||||||
["--cpp", "--gen-compare", "--gen-mutable", "--gen-object-api", "--reflect-names"],
|
|
||||||
schema="cpp_vec_type_test.fbs",
|
|
||||||
)
|
|
||||||
|
|
||||||
flatc(
|
flatc(
|
||||||
[
|
[
|
||||||
"--cpp",
|
"--cpp",
|
||||||
@@ -399,6 +394,11 @@ flatc(
|
|||||||
schema="native_inline_table_test.fbs",
|
schema="native_inline_table_test.fbs",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
flatc(
|
||||||
|
["--cpp", "--gen-compare", "--gen-mutable", "--gen-object-api", "--reflect-names"],
|
||||||
|
schema="cross_namespace_pack_test.fbs",
|
||||||
|
)
|
||||||
|
|
||||||
flatc(
|
flatc(
|
||||||
RUST_OPTS,
|
RUST_OPTS,
|
||||||
prefix="arrays_test",
|
prefix="arrays_test",
|
||||||
@@ -422,6 +422,11 @@ flatc(
|
|||||||
schema="nested_union_test.fbs",
|
schema="nested_union_test.fbs",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
flatc(
|
||||||
|
["--python", "--gen-object-api"],
|
||||||
|
schema="union_name_test.fbs",
|
||||||
|
)
|
||||||
|
|
||||||
flatc(
|
flatc(
|
||||||
NO_INCL_OPTS + CPP_OPTS,
|
NO_INCL_OPTS + CPP_OPTS,
|
||||||
schema="default_vectors_strings_test.fbs",
|
schema="default_vectors_strings_test.fbs",
|
||||||
@@ -522,6 +527,13 @@ flatc(
|
|||||||
cwd=swift_code_gen,
|
cwd=swift_code_gen,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
flatc(
|
||||||
|
SWIFT_OPTS_CODE_GEN + BASE_OPTS,
|
||||||
|
schema="empty_vtable.fbs",
|
||||||
|
cwd=swift_code_gen,
|
||||||
|
prefix="../../Tests/Flatbuffers/",
|
||||||
|
)
|
||||||
|
|
||||||
# Swift Wasm Tests
|
# Swift Wasm Tests
|
||||||
swift_Wasm_prefix = "swift/Wasm.tests/Tests/FlatBuffers.Test.Swift.WasmTests"
|
swift_Wasm_prefix = "swift/Wasm.tests/Tests/FlatBuffers.Test.Swift.WasmTests"
|
||||||
flatc(
|
flatc(
|
||||||
|
|||||||
@@ -126,9 +126,7 @@ static BinarySection GenerateMissingSection(const uint64_t offset,
|
|||||||
std::map<uint64_t, BinarySection> BinaryAnnotator::Annotate() {
|
std::map<uint64_t, BinarySection> BinaryAnnotator::Annotate() {
|
||||||
if (bfbs_ != nullptr && bfbs_length_ != 0) {
|
if (bfbs_ != nullptr && bfbs_length_ != 0) {
|
||||||
flatbuffers::Verifier verifier(bfbs_, static_cast<size_t>(bfbs_length_));
|
flatbuffers::Verifier verifier(bfbs_, static_cast<size_t>(bfbs_length_));
|
||||||
if ((is_size_prefixed_ &&
|
if (!reflection::VerifySchemaBuffer(verifier)) {
|
||||||
!reflection::VerifySizePrefixedSchemaBuffer(verifier)) ||
|
|
||||||
!reflection::VerifySchemaBuffer(verifier)) {
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,10 +142,6 @@ const static FlatCOption flatc_options[] = {
|
|||||||
"and T::empty() must be supported. The custom type also needs to be "
|
"and T::empty() must be supported. The custom type also needs to be "
|
||||||
"constructible from std::string (see the --cpp-str-flex-ctor option to "
|
"constructible from std::string (see the --cpp-str-flex-ctor option to "
|
||||||
"change this behavior)"},
|
"change this behavior)"},
|
||||||
{"", "cpp-vec-type", "T",
|
|
||||||
"Set object API vector type (default std::vector). T must support the "
|
|
||||||
"same interface as std::vector: size(), resize(), reserve(), "
|
|
||||||
"emplace_back(), operator[], begin(), end(), and data()."},
|
|
||||||
{"", "cpp-str-flex-ctor", "",
|
{"", "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)."},
|
||||||
@@ -547,9 +543,6 @@ FlatCOptions FlatCompiler::ParseFromCommandLineArguments(int argc,
|
|||||||
} else if (arg == "--cpp-str-type") {
|
} else if (arg == "--cpp-str-type") {
|
||||||
if (++argi >= argc) Error("missing type following: " + arg, true);
|
if (++argi >= argc) Error("missing type following: " + arg, true);
|
||||||
opts.cpp_object_api_string_type = argv[argi];
|
opts.cpp_object_api_string_type = argv[argi];
|
||||||
} else if (arg == "--cpp-vec-type") {
|
|
||||||
if (++argi >= argc) Error("missing type following: " + arg, true);
|
|
||||||
opts.cpp_object_api_vector_type = argv[argi];
|
|
||||||
} else if (arg == "--cpp-str-flex-ctor") {
|
} 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 == "--no-cpp-direct-copy") {
|
} else if (arg == "--no-cpp-direct-copy") {
|
||||||
|
|||||||
@@ -929,15 +929,6 @@ class CppGenerator : public BaseGenerator {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string NativeVector(const FieldDef* field) {
|
|
||||||
auto attr = field ? field->attributes.Lookup("cpp_vec_type") : nullptr;
|
|
||||||
auto& ret = attr ? attr->constant : opts_.cpp_object_api_vector_type;
|
|
||||||
if (ret.empty()) {
|
|
||||||
return "std::vector";
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FlexibleStringConstructor(const FieldDef* field) {
|
bool FlexibleStringConstructor(const FieldDef* field) {
|
||||||
auto attr = field != nullptr &&
|
auto attr = field != nullptr &&
|
||||||
(field->attributes.Lookup("cpp_str_flex_ctor") != nullptr);
|
(field->attributes.Lookup("cpp_str_flex_ctor") != nullptr);
|
||||||
@@ -983,26 +974,20 @@ 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);
|
||||||
const auto vec_type = NativeVector(&field);
|
if (type.struct_def &&
|
||||||
if (vec_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 {
|
||||||
|
return "std::vector<" + type_name + ">";
|
||||||
}
|
}
|
||||||
return vec_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)) {
|
||||||
// Field-level native_type takes priority over struct-level
|
auto native_type = type.struct_def->attributes.Lookup("native_type");
|
||||||
// native_type
|
|
||||||
auto field_native_type = field.attributes.Lookup("native_type");
|
|
||||||
auto native_type =
|
|
||||||
field_native_type
|
|
||||||
? field_native_type
|
|
||||||
: type.struct_def->attributes.Lookup("native_type");
|
|
||||||
if (native_type) {
|
if (native_type) {
|
||||||
type_name = native_type->constant;
|
type_name = native_type->constant;
|
||||||
}
|
}
|
||||||
@@ -1966,10 +1951,9 @@ class CppGenerator : public BaseGenerator {
|
|||||||
field.offset64);
|
field.offset64);
|
||||||
}
|
}
|
||||||
if (TypeHasKey(vtype)) {
|
if (TypeHasKey(vtype)) {
|
||||||
code_.SetValue("PARAM_TYPE", NativeVector(&field) + "<" + type + "> *");
|
code_.SetValue("PARAM_TYPE", "std::vector<" + type + "> *");
|
||||||
} else {
|
} else {
|
||||||
code_.SetValue("PARAM_TYPE",
|
code_.SetValue("PARAM_TYPE", "const std::vector<" + type + "> *");
|
||||||
"const " + NativeVector(&field) + "<" + type + "> *");
|
|
||||||
}
|
}
|
||||||
code_.SetValue("PARAM_VALUE", "nullptr");
|
code_.SetValue("PARAM_VALUE", "nullptr");
|
||||||
} else {
|
} else {
|
||||||
@@ -1995,7 +1979,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)
|
||||||
? NativeVector(&field) + "<" +
|
? "std::vector<" +
|
||||||
GenTypeNativePtr(cpp_type->constant, &field,
|
GenTypeNativePtr(cpp_type->constant, &field,
|
||||||
false) +
|
false) +
|
||||||
"> "
|
"> "
|
||||||
@@ -2795,15 +2779,17 @@ class CppGenerator : public BaseGenerator {
|
|||||||
get_call += ">(" + offset_str + ");";
|
get_call += ">(" + offset_str + ");";
|
||||||
code_ += get_call;
|
code_ += get_call;
|
||||||
} else if (IsString(type) && field.value.constant != "0") {
|
} else if (IsString(type) && field.value.constant != "0") {
|
||||||
// TODO: Add logic to always convert the string to a valid C++ string
|
std::string escaped;
|
||||||
// literal by handling string escapes.
|
flatbuffers::EscapeString(field.value.constant.c_str(),
|
||||||
|
field.value.constant.length(), &escaped,
|
||||||
|
true, false);
|
||||||
code_ += " auto* ptr = {{FIELD_VALUE}};";
|
code_ += " auto* ptr = {{FIELD_VALUE}};";
|
||||||
code_ += " if (ptr) return ptr;";
|
code_ += " if (ptr) return ptr;";
|
||||||
code_ += " static const struct { uint32_t len; const char s[" +
|
code_ += " static const struct { uint32_t len; const char s[" +
|
||||||
NumToString(field.value.constant.length() + 1) +
|
NumToString(field.value.constant.length() + 1) +
|
||||||
"]; } bfbs_string = { " +
|
"]; } bfbs_string = { " +
|
||||||
NumToString(field.value.constant.length()) + ", \"" +
|
NumToString(field.value.constant.length()) + ", " +
|
||||||
field.value.constant + "\" };";
|
escaped + " };";
|
||||||
code_ +=
|
code_ +=
|
||||||
" return reinterpret_cast<const ::flatbuffers::String "
|
" return reinterpret_cast<const ::flatbuffers::String "
|
||||||
" *>(&bfbs_string);";
|
" *>(&bfbs_string);";
|
||||||
@@ -3433,11 +3419,15 @@ class CppGenerator : public BaseGenerator {
|
|||||||
code_.SetValue("CREATE_STRING", "CreateSharedString");
|
code_.SetValue("CREATE_STRING", "CreateSharedString");
|
||||||
}
|
}
|
||||||
if (field->value.constant != "0") {
|
if (field->value.constant != "0") {
|
||||||
|
std::string escaped;
|
||||||
|
flatbuffers::EscapeString(field->value.constant.c_str(),
|
||||||
|
field->value.constant.length(), &escaped,
|
||||||
|
true, false);
|
||||||
code_ +=
|
code_ +=
|
||||||
" auto {{FIELD_NAME}}__ = {{FIELD_NAME}} ? "
|
" auto {{FIELD_NAME}}__ = {{FIELD_NAME}} ? "
|
||||||
"_fbb.{{CREATE_STRING}}({{FIELD_NAME}}) : "
|
"_fbb.{{CREATE_STRING}}({{FIELD_NAME}}) : "
|
||||||
"_fbb.{{CREATE_STRING}}(\"" +
|
"_fbb.{{CREATE_STRING}}(" +
|
||||||
field->value.constant + "\");";
|
escaped + ");";
|
||||||
} else {
|
} else {
|
||||||
code_ +=
|
code_ +=
|
||||||
" auto {{FIELD_NAME}}__ = {{FIELD_NAME}} ? "
|
" auto {{FIELD_NAME}}__ = {{FIELD_NAME}} ? "
|
||||||
@@ -3532,21 +3522,10 @@ 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& struct_attrs = type.struct_def->attributes;
|
||||||
// Field-level native_type takes priority over struct-level
|
const auto native_type = struct_attrs.Lookup("native_type");
|
||||||
// native_type
|
|
||||||
auto field_native_type = afield.attributes.Lookup("native_type");
|
|
||||||
const auto native_type = field_native_type
|
|
||||||
? field_native_type
|
|
||||||
: struct_attrs.Lookup("native_type");
|
|
||||||
if (native_type) {
|
if (native_type) {
|
||||||
std::string unpack_call = "::flatbuffers::UnPack";
|
std::string unpack_call = "::flatbuffers::UnPack";
|
||||||
// Field-level native_type_pack_name takes priority over
|
const auto pack_name = struct_attrs.Lookup("native_type_pack_name");
|
||||||
// struct-level
|
|
||||||
auto field_pack_name =
|
|
||||||
afield.attributes.Lookup("native_type_pack_name");
|
|
||||||
const auto pack_name =
|
|
||||||
field_pack_name ? field_pack_name
|
|
||||||
: struct_attrs.Lookup("native_type_pack_name");
|
|
||||||
if (pack_name) {
|
if (pack_name) {
|
||||||
unpack_call += pack_name->constant;
|
unpack_call += pack_name->constant;
|
||||||
}
|
}
|
||||||
@@ -3801,8 +3780,7 @@ class CppGenerator : public BaseGenerator {
|
|||||||
auto vector_type = field.value.type.VectorType();
|
auto vector_type = field.value.type.VectorType();
|
||||||
switch (vector_type.base_type) {
|
switch (vector_type.base_type) {
|
||||||
case BASE_TYPE_STRING: {
|
case BASE_TYPE_STRING: {
|
||||||
if (NativeString(&field) == "std::string" &&
|
if (NativeString(&field) == "std::string") {
|
||||||
NativeVector(&field) == "std::vector") {
|
|
||||||
code += "_fbb.CreateVectorOfStrings(" + value + ")";
|
code += "_fbb.CreateVectorOfStrings(" + value + ")";
|
||||||
} else {
|
} else {
|
||||||
// Use by-function serialization to emulate
|
// Use by-function serialization to emulate
|
||||||
@@ -3823,59 +3801,39 @@ class CppGenerator : public BaseGenerator {
|
|||||||
if (IsStruct(vector_type)) {
|
if (IsStruct(vector_type)) {
|
||||||
const auto& struct_attrs =
|
const auto& struct_attrs =
|
||||||
field.value.type.struct_def->attributes;
|
field.value.type.struct_def->attributes;
|
||||||
// Field-level native_type takes priority over struct-level
|
const auto native_type = struct_attrs.Lookup("native_type");
|
||||||
// native_type
|
|
||||||
auto field_native_type = field.attributes.Lookup("native_type");
|
|
||||||
const auto native_type = field_native_type
|
|
||||||
? field_native_type
|
|
||||||
: struct_attrs.Lookup("native_type");
|
|
||||||
if (native_type) {
|
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 + ">";
|
||||||
// Field-level native_type_pack_name takes priority over
|
|
||||||
// struct-level
|
|
||||||
auto field_pack_name =
|
|
||||||
field.attributes.Lookup("native_type_pack_name");
|
|
||||||
const auto pack_name =
|
|
||||||
field_pack_name
|
|
||||||
? field_pack_name
|
|
||||||
: struct_attrs.Lookup("native_type_pack_name");
|
|
||||||
// Non-std vectors (e.g. eastl::vector) don't match the
|
|
||||||
// std::vector overload, so use the pointer+size overload.
|
|
||||||
const bool is_std_vec = NativeVector(&field) == "std::vector";
|
|
||||||
if (is_std_vec) {
|
|
||||||
code += "(" + value;
|
code += "(" + value;
|
||||||
} else {
|
const auto pack_name =
|
||||||
code += "(" + value + ".data(), " + value + ".size()";
|
struct_attrs.Lookup("native_type_pack_name");
|
||||||
}
|
|
||||||
if (pack_name) {
|
if (pack_name) {
|
||||||
code += ", ::flatbuffers::Pack" + pack_name->constant;
|
code += ", ::flatbuffers::Pack" + pack_name->constant;
|
||||||
}
|
}
|
||||||
code += ")";
|
code += ")";
|
||||||
} 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.
|
||||||
const bool is_std_vec = NativeVector(&field) == "std::vector";
|
|
||||||
const std::string vec_args =
|
|
||||||
is_std_vec ? ("(" + value + ")")
|
|
||||||
: ("(" + value + ".data(), " + value + ".size())");
|
|
||||||
if (field.value.type.base_type == BASE_TYPE_VECTOR64) {
|
if (field.value.type.base_type == BASE_TYPE_VECTOR64) {
|
||||||
code += "_fbb.CreateVectorOfStructs64" + vec_args;
|
code += "_fbb.CreateVectorOfStructs64";
|
||||||
} else {
|
} else {
|
||||||
code += "_fbb.CreateVectorOfStructs";
|
code += "_fbb.CreateVectorOfStructs";
|
||||||
if (field.offset64) {
|
if (field.offset64) {
|
||||||
// This is normal 32-bit vector, with 64-bit addressing.
|
// This is normal 32-bit vector, with 64-bit addressing.
|
||||||
code += "64<::flatbuffers::Vector>";
|
code += "64<::flatbuffers::Vector>";
|
||||||
}
|
}
|
||||||
code += vec_args;
|
|
||||||
}
|
}
|
||||||
|
code += "(" + value + ")";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
code += "_fbb.CreateVector<::flatbuffers::Offset<";
|
code += "_fbb.CreateVector<::flatbuffers::Offset<";
|
||||||
code += WrapInNameSpace(*vector_type.struct_def) + ">> ";
|
code += WrapInNameSpace(*vector_type.struct_def) + ">> ";
|
||||||
code += "(" + value + ".size(), ";
|
code += "(" + value + ".size(), ";
|
||||||
code += "[](size_t i, _VectorArgs *__va) { ";
|
code += "[](size_t i, _VectorArgs *__va) { ";
|
||||||
code += "return Create" + vector_type.struct_def->name;
|
code += "return " +
|
||||||
|
WrapInNameSpace(vector_type.struct_def->defined_namespace,
|
||||||
|
"Create" + vector_type.struct_def->name);
|
||||||
code += "(*__va->__fbb, ";
|
code += "(*__va->__fbb, ";
|
||||||
if (field.native_inline) {
|
if (field.native_inline) {
|
||||||
code += "&(__va->_" + value + "[i])";
|
code += "&(__va->_" + value + "[i])";
|
||||||
@@ -3887,12 +3845,7 @@ class CppGenerator : public BaseGenerator {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BASE_TYPE_BOOL: {
|
case BASE_TYPE_BOOL: {
|
||||||
if (NativeVector(&field) == "std::vector") {
|
|
||||||
code += "_fbb.CreateVector(" + value + ")";
|
code += "_fbb.CreateVector(" + value + ")";
|
||||||
} else {
|
|
||||||
code += "_fbb.CreateVector(" + value + ".data(), " + value +
|
|
||||||
".size())";
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BASE_TYPE_UNION: {
|
case BASE_TYPE_UNION: {
|
||||||
@@ -3941,19 +3894,15 @@ class CppGenerator : public BaseGenerator {
|
|||||||
code += "; }, &_va )";
|
code += "; }, &_va )";
|
||||||
} 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.
|
||||||
const bool is_std_vec = NativeVector(&field) == "std::vector";
|
|
||||||
const std::string vec_args =
|
|
||||||
is_std_vec ? ("(" + value + ")")
|
|
||||||
: ("(" + value + ".data(), " + value + ".size())");
|
|
||||||
if (field.value.type.base_type == BASE_TYPE_VECTOR64) {
|
if (field.value.type.base_type == BASE_TYPE_VECTOR64) {
|
||||||
code += "_fbb.CreateVector64" + vec_args;
|
code += "_fbb.CreateVector64(" + value + ")";
|
||||||
} else {
|
} else {
|
||||||
code += "_fbb.CreateVector";
|
code += "_fbb.CreateVector";
|
||||||
if (field.offset64) {
|
if (field.offset64) {
|
||||||
// This is normal 32-bit vector, with 64-bit addressing.
|
// This is normal 32-bit vector, with 64-bit addressing.
|
||||||
code += "64<::flatbuffers::Vector>";
|
code += "64<::flatbuffers::Vector>";
|
||||||
}
|
}
|
||||||
code += vec_args;
|
code += "(" + value + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -3977,22 +3926,11 @@ 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& struct_attribs = field.value.type.struct_def->attributes;
|
||||||
// Field-level native_type takes priority over struct-level
|
const auto native_type = struct_attribs.Lookup("native_type");
|
||||||
// native_type
|
|
||||||
auto field_native_type = field.attributes.Lookup("native_type");
|
|
||||||
const auto native_type = field_native_type
|
|
||||||
? field_native_type
|
|
||||||
: struct_attribs.Lookup("native_type");
|
|
||||||
if (native_type && field.native_inline) {
|
if (native_type && field.native_inline) {
|
||||||
code += "::flatbuffers::Pack";
|
code += "::flatbuffers::Pack";
|
||||||
// Field-level native_type_pack_name takes priority over
|
|
||||||
// struct-level
|
|
||||||
auto field_pack_name =
|
|
||||||
field.attributes.Lookup("native_type_pack_name");
|
|
||||||
const auto pack_name =
|
const auto pack_name =
|
||||||
field_pack_name
|
struct_attribs.Lookup("native_type_pack_name");
|
||||||
? field_pack_name
|
|
||||||
: struct_attribs.Lookup("native_type_pack_name");
|
|
||||||
if (pack_name) {
|
if (pack_name) {
|
||||||
code += pack_name->constant;
|
code += pack_name->constant;
|
||||||
}
|
}
|
||||||
@@ -4008,8 +3946,10 @@ class CppGenerator : public BaseGenerator {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// _o->field ? CreateT(_fbb, _o->field.get(), _rehasher);
|
// _o->field ? CreateT(_fbb, _o->field.get(), _rehasher);
|
||||||
const std::string& type = field.value.type.struct_def->name;
|
const auto& nested_struct = *field.value.type.struct_def;
|
||||||
code += value + " ? Create" + type;
|
code += value + " ? " +
|
||||||
|
WrapInNameSpace(nested_struct.defined_namespace,
|
||||||
|
"Create" + nested_struct.name);
|
||||||
code += "(_fbb, " + value;
|
code += "(_fbb, " + value;
|
||||||
if (!field.native_inline) code += GenPtrGet(field);
|
if (!field.native_inline) code += GenPtrGet(field);
|
||||||
code += ", _rehasher) : 0";
|
code += ", _rehasher) : 0";
|
||||||
@@ -4156,14 +4096,8 @@ class CppGenerator : public BaseGenerator {
|
|||||||
bool check_ptr = false;
|
bool check_ptr = false;
|
||||||
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)) {
|
||||||
// Field-level native_type takes priority over struct-level
|
|
||||||
// native_type
|
|
||||||
auto field_native_type =
|
|
||||||
field->attributes.Lookup("native_type");
|
|
||||||
auto native_type =
|
auto native_type =
|
||||||
field_native_type
|
field->value.type.struct_def->attributes.Lookup(
|
||||||
? field_native_type
|
|
||||||
: field->value.type.struct_def->attributes.Lookup(
|
|
||||||
"native_type");
|
"native_type");
|
||||||
auto native_inline = field->attributes.Lookup("native_inline");
|
auto native_inline = field->attributes.Lookup("native_inline");
|
||||||
if (native_type) {
|
if (native_type) {
|
||||||
|
|||||||
@@ -368,7 +368,17 @@ static std::string GenerateFBS(const Parser& parser,
|
|||||||
if (field.value.type.base_type != BASE_TYPE_UTYPE) {
|
if (field.value.type.base_type != BASE_TYPE_UTYPE) {
|
||||||
GenComment(field.doc_comment, &schema, nullptr, " ");
|
GenComment(field.doc_comment, &schema, nullptr, " ");
|
||||||
schema += " " + field.name + ":" + GenType(field.value.type);
|
schema += " " + field.name + ":" + GenType(field.value.type);
|
||||||
if (field.value.constant != "0") schema += " = " + field.value.constant;
|
if (field.value.constant != "0") {
|
||||||
|
if (IsString(field.value.type)) {
|
||||||
|
std::string escaped;
|
||||||
|
flatbuffers::EscapeString(field.value.constant.c_str(),
|
||||||
|
field.value.constant.length(), &escaped,
|
||||||
|
true, false);
|
||||||
|
schema += " = " + escaped;
|
||||||
|
} else {
|
||||||
|
schema += " = " + field.value.constant;
|
||||||
|
}
|
||||||
|
}
|
||||||
std::vector<std::string> attributes;
|
std::vector<std::string> attributes;
|
||||||
if (field.IsRequired()) attributes.push_back("required");
|
if (field.IsRequired()) attributes.push_back("required");
|
||||||
if (field.key) attributes.push_back("key");
|
if (field.key) attributes.push_back("key");
|
||||||
|
|||||||
@@ -1528,7 +1528,7 @@ class PythonGenerator : public BaseGenerator {
|
|||||||
} else {
|
} else {
|
||||||
code += "def Create" + field_method + "Vector(builder, data):\n";
|
code += "def Create" + field_method + "Vector(builder, data):\n";
|
||||||
}
|
}
|
||||||
code += Indent + helper_name + "(builder, data)\n\n";
|
code += Indent + "return " + helper_name + "(builder, data)\n\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2095,12 +2095,12 @@ class PythonGenerator : public BaseGenerator {
|
|||||||
const auto field_method = namer_.Method(field);
|
const auto field_method = namer_.Method(field);
|
||||||
const auto struct_var = namer_.Variable(struct_def);
|
const auto struct_var = namer_.Variable(struct_def);
|
||||||
const EnumDef& enum_def = *field.value.type.enum_def;
|
const EnumDef& enum_def = *field.value.type.enum_def;
|
||||||
auto union_type = namer_.Type(enum_def);
|
auto union_fn = namer_.Function(enum_def);
|
||||||
|
|
||||||
if (parser_.opts.include_dependence_headers) {
|
if (parser_.opts.include_dependence_headers) {
|
||||||
union_type = namer_.NamespacedType(enum_def) + "." + union_type;
|
union_fn = namer_.NamespacedType(enum_def) + "." + union_fn;
|
||||||
}
|
}
|
||||||
code += GenIndents(2) + "self." + field_field + " = " + union_type +
|
code += GenIndents(2) + "self." + field_field + " = " + union_fn +
|
||||||
"Creator(" + "self." + field_field + "Type, " + struct_var + "." +
|
"Creator(" + "self." + field_field + "Type, " + struct_var + "." +
|
||||||
field_method + "())";
|
field_method + "())";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -429,8 +429,7 @@ class RustGenerator : public BaseGenerator {
|
|||||||
|
|
||||||
// Generate imports for the global scope in case no namespace is used
|
// Generate imports for the global scope in case no namespace is used
|
||||||
// in the schema file.
|
// in the schema file.
|
||||||
GenNamespaceImports(0);
|
GenNamespaceImports();
|
||||||
code_ += "";
|
|
||||||
|
|
||||||
// Generate all code in their namespaces, once, because Rust does not
|
// Generate all code in their namespaces, once, because Rust does not
|
||||||
// permit re-opening modules.
|
// permit re-opening modules.
|
||||||
@@ -708,6 +707,8 @@ class RustGenerator : public BaseGenerator {
|
|||||||
// an enum match function,
|
// an enum match function,
|
||||||
// and an enum array of values
|
// and an enum array of values
|
||||||
void GenEnum(const EnumDef& enum_def) {
|
void GenEnum(const EnumDef& enum_def) {
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
const bool is_private = parser_.opts.no_leak_private_annotations &&
|
const bool is_private = parser_.opts.no_leak_private_annotations &&
|
||||||
(enum_def.attributes.Lookup("private") != nullptr);
|
(enum_def.attributes.Lookup("private") != nullptr);
|
||||||
code_.SetValue("ACCESS_TYPE", is_private ? "pub(crate)" : "pub");
|
code_.SetValue("ACCESS_TYPE", is_private ? "pub(crate)" : "pub");
|
||||||
@@ -739,6 +740,8 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_ += " }";
|
code_ += " }";
|
||||||
code_ += " }";
|
code_ += " }";
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
code_ += "pub use self::bitflags_{{ENUM_NAMESPACE}}::{{ENUM_TY}};";
|
code_ += "pub use self::bitflags_{{ENUM_NAMESPACE}}::{{ENUM_TY}};";
|
||||||
code_ += "";
|
code_ += "";
|
||||||
|
|
||||||
@@ -753,10 +756,14 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_ +=
|
code_ +=
|
||||||
"pub const ENUM_MIN_{{ENUM_CONSTANT}}: {{BASE_TYPE}}"
|
"pub const ENUM_MIN_{{ENUM_CONSTANT}}: {{BASE_TYPE}}"
|
||||||
" = {{ENUM_MIN_BASE_VALUE}};";
|
" = {{ENUM_MIN_BASE_VALUE}};";
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
code_ += deprecation_warning;
|
code_ += deprecation_warning;
|
||||||
code_ +=
|
code_ +=
|
||||||
"pub const ENUM_MAX_{{ENUM_CONSTANT}}: {{BASE_TYPE}}"
|
"pub const ENUM_MAX_{{ENUM_CONSTANT}}: {{BASE_TYPE}}"
|
||||||
" = {{ENUM_MAX_BASE_VALUE}};";
|
" = {{ENUM_MAX_BASE_VALUE}};";
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
auto num_fields = NumToString(enum_def.size());
|
auto num_fields = NumToString(enum_def.size());
|
||||||
code_ += deprecation_warning;
|
code_ += deprecation_warning;
|
||||||
code_ += "#[allow(non_camel_case_types)]";
|
code_ += "#[allow(non_camel_case_types)]";
|
||||||
@@ -777,6 +784,8 @@ class RustGenerator : public BaseGenerator {
|
|||||||
"Default)]";
|
"Default)]";
|
||||||
code_ += "#[repr(transparent)]";
|
code_ += "#[repr(transparent)]";
|
||||||
code_ += "{{ACCESS_TYPE}} struct {{ENUM_TY}}(pub {{BASE_TYPE}});";
|
code_ += "{{ACCESS_TYPE}} struct {{ENUM_TY}}(pub {{BASE_TYPE}});";
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
code_ += "#[allow(non_upper_case_globals)]";
|
code_ += "#[allow(non_upper_case_globals)]";
|
||||||
code_ += "impl {{ENUM_TY}} {";
|
code_ += "impl {{ENUM_TY}} {";
|
||||||
ForAllEnumValues1(enum_def, [&](const EnumVal& ev) {
|
ForAllEnumValues1(enum_def, [&](const EnumVal& ev) {
|
||||||
@@ -785,11 +794,15 @@ class RustGenerator : public BaseGenerator {
|
|||||||
});
|
});
|
||||||
code_ += "";
|
code_ += "";
|
||||||
// Generate Associated constants
|
// Generate Associated constants
|
||||||
code_ += " pub const ENUM_MIN: {{BASE_TYPE}} = {{ENUM_MIN_BASE_VALUE}};";
|
code_ +=
|
||||||
code_ += " pub const ENUM_MAX: {{BASE_TYPE}} = {{ENUM_MAX_BASE_VALUE}};";
|
" pub const ENUM_MIN: {{BASE_TYPE}} = {{ENUM_MIN_BASE_VALUE}};";
|
||||||
|
code_ +=
|
||||||
|
" pub const ENUM_MAX: {{BASE_TYPE}} = {{ENUM_MAX_BASE_VALUE}};";
|
||||||
code_ += " pub const ENUM_VALUES: &'static [Self] = &[";
|
code_ += " pub const ENUM_VALUES: &'static [Self] = &[";
|
||||||
ForAllEnumValues(enum_def, [&]() { code_ += " Self::{{VARIANT}},"; });
|
ForAllEnumValues(enum_def, [&]() { code_ += " Self::{{VARIANT}},"; });
|
||||||
code_ += " ];";
|
code_ += " ];";
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
code_ += " /// Returns the variant's name or \"\" if unknown.";
|
code_ += " /// Returns the variant's name or \"\" if unknown.";
|
||||||
code_ += " pub fn variant_name(self) -> Option<&'static str> {";
|
code_ += " pub fn variant_name(self) -> Option<&'static str> {";
|
||||||
code_ += " match self {";
|
code_ += " match self {";
|
||||||
@@ -800,6 +813,7 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_ += " }";
|
code_ += " }";
|
||||||
code_ += " }";
|
code_ += " }";
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
// Generate Debug. Unknown variants are printed like "<UNKNOWN 42>".
|
// Generate Debug. Unknown variants are printed like "<UNKNOWN 42>".
|
||||||
code_ += "impl ::core::fmt::Debug for {{ENUM_TY}} {";
|
code_ += "impl ::core::fmt::Debug for {{ENUM_TY}} {";
|
||||||
@@ -809,10 +823,12 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_ += " if let Some(name) = self.variant_name() {";
|
code_ += " if let Some(name) = self.variant_name() {";
|
||||||
code_ += " f.write_str(name)";
|
code_ += " f.write_str(name)";
|
||||||
code_ += " } else {";
|
code_ += " } else {";
|
||||||
code_ += " f.write_fmt(format_args!(\"<UNKNOWN {:?}>\", self.0))";
|
code_ +=
|
||||||
|
" f.write_fmt(format_args!(\"<UNKNOWN {:?}>\", self.0))";
|
||||||
code_ += " }";
|
code_ += " }";
|
||||||
code_ += " }";
|
code_ += " }";
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
code_.SetValue("INTO_BASE", "self.0");
|
code_.SetValue("INTO_BASE", "self.0");
|
||||||
}
|
}
|
||||||
@@ -821,7 +837,8 @@ class RustGenerator : public BaseGenerator {
|
|||||||
if (parser_.opts.rust_serialize) {
|
if (parser_.opts.rust_serialize) {
|
||||||
code_ += "impl Serialize for {{ENUM_TY}} {";
|
code_ += "impl Serialize for {{ENUM_TY}} {";
|
||||||
code_ +=
|
code_ +=
|
||||||
" fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>";
|
" fn serialize<S>(&self, serializer: S) -> Result<S::Ok, "
|
||||||
|
"S::Error>";
|
||||||
code_ += " where";
|
code_ += " where";
|
||||||
code_ += " S: Serializer,";
|
code_ += " S: Serializer,";
|
||||||
code_ += " {";
|
code_ += " {";
|
||||||
@@ -846,7 +863,9 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_ += " {";
|
code_ += " {";
|
||||||
code_ += " let s = String::deserialize(deserializer)?;";
|
code_ += " let s = String::deserialize(deserializer)?;";
|
||||||
code_ += " for item in {{ENUM_TY}}::ENUM_VALUES {";
|
code_ += " for item in {{ENUM_TY}}::ENUM_VALUES {";
|
||||||
code_ += " if let Some(item_name) = item.variant_name() {";
|
code_ +=
|
||||||
|
" if let Some(item_name) = "
|
||||||
|
"item.variant_name() {";
|
||||||
code_ += " if item_name == s {";
|
code_ += " if item_name == s {";
|
||||||
code_ += " return Ok(item.clone());";
|
code_ += " return Ok(item.clone());";
|
||||||
code_ += " }";
|
code_ += " }";
|
||||||
@@ -864,6 +883,7 @@ class RustGenerator : public BaseGenerator {
|
|||||||
// Generate Follow and Push so we can serialize and stuff.
|
// Generate Follow and Push so we can serialize and stuff.
|
||||||
code_ += "impl<'a> ::flatbuffers::Follow<'a> for {{ENUM_TY}} {";
|
code_ += "impl<'a> ::flatbuffers::Follow<'a> for {{ENUM_TY}} {";
|
||||||
code_ += " type Inner = Self;";
|
code_ += " type Inner = Self;";
|
||||||
|
code_ += "";
|
||||||
code_ += " #[inline]";
|
code_ += " #[inline]";
|
||||||
code_ += " unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {";
|
code_ += " unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {";
|
||||||
code_ +=
|
code_ +=
|
||||||
@@ -879,6 +899,7 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_ += "";
|
code_ += "";
|
||||||
code_ += "impl ::flatbuffers::Push for {{ENUM_TY}} {";
|
code_ += "impl ::flatbuffers::Push for {{ENUM_TY}} {";
|
||||||
code_ += " type Output = {{ENUM_TY}};";
|
code_ += " type Output = {{ENUM_TY}};";
|
||||||
|
code_ += "";
|
||||||
code_ += " #[inline]";
|
code_ += " #[inline]";
|
||||||
code_ += " unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {";
|
code_ += " unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {";
|
||||||
code_ +=
|
code_ +=
|
||||||
@@ -889,10 +910,12 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_ += "";
|
code_ += "";
|
||||||
code_ += "impl ::flatbuffers::EndianScalar for {{ENUM_TY}} {";
|
code_ += "impl ::flatbuffers::EndianScalar for {{ENUM_TY}} {";
|
||||||
code_ += " type Scalar = {{BASE_TYPE}};";
|
code_ += " type Scalar = {{BASE_TYPE}};";
|
||||||
|
code_ += "";
|
||||||
code_ += " #[inline]";
|
code_ += " #[inline]";
|
||||||
code_ += " fn to_little_endian(self) -> {{BASE_TYPE}} {";
|
code_ += " fn to_little_endian(self) -> {{BASE_TYPE}} {";
|
||||||
code_ += " {{INTO_BASE}}.to_le()";
|
code_ += " {{INTO_BASE}}.to_le()";
|
||||||
code_ += " }";
|
code_ += " }";
|
||||||
|
code_ += "";
|
||||||
code_ += " #[inline]";
|
code_ += " #[inline]";
|
||||||
code_ += " #[allow(clippy::wrong_self_convention)]";
|
code_ += " #[allow(clippy::wrong_self_convention)]";
|
||||||
code_ += " fn from_little_endian(v: {{BASE_TYPE}}) -> Self {";
|
code_ += " fn from_little_endian(v: {{BASE_TYPE}}) -> Self {";
|
||||||
@@ -922,8 +945,8 @@ class RustGenerator : public BaseGenerator {
|
|||||||
if (enum_def.is_union) {
|
if (enum_def.is_union) {
|
||||||
// Generate typesafe offset(s) for unions
|
// Generate typesafe offset(s) for unions
|
||||||
code_.SetValue("UNION_TYPE", namer_.Type(enum_def));
|
code_.SetValue("UNION_TYPE", namer_.Type(enum_def));
|
||||||
code_ += "{{ACCESS_TYPE}} struct {{UNION_TYPE}}UnionTableOffset {}";
|
|
||||||
code_ += "";
|
code_ += "";
|
||||||
|
code_ += "{{ACCESS_TYPE}} struct {{UNION_TYPE}}UnionTableOffset {}";
|
||||||
if (parser_.opts.generate_object_based_api) {
|
if (parser_.opts.generate_object_based_api) {
|
||||||
GenUnionObject(enum_def);
|
GenUnionObject(enum_def);
|
||||||
}
|
}
|
||||||
@@ -955,6 +978,7 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_.SetValue("ENUM_OTY", namer_.ObjectType(enum_def));
|
code_.SetValue("ENUM_OTY", namer_.ObjectType(enum_def));
|
||||||
|
|
||||||
// Generate native union.
|
// Generate native union.
|
||||||
|
code_ += "";
|
||||||
code_ += "#[allow(clippy::upper_case_acronyms)]"; // NONE's spelling is
|
code_ += "#[allow(clippy::upper_case_acronyms)]"; // NONE's spelling is
|
||||||
// intended.
|
// intended.
|
||||||
code_ += "#[non_exhaustive]";
|
code_ += "#[non_exhaustive]";
|
||||||
@@ -966,12 +990,15 @@ class RustGenerator : public BaseGenerator {
|
|||||||
"{{NATIVE_VARIANT}}(alloc::boxed::Box<{{U_ELEMENT_TABLE_TYPE}}>),";
|
"{{NATIVE_VARIANT}}(alloc::boxed::Box<{{U_ELEMENT_TABLE_TYPE}}>),";
|
||||||
});
|
});
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
// Generate Default (NONE).
|
// Generate Default (NONE).
|
||||||
code_ += "impl Default for {{ENUM_OTY}} {";
|
code_ += "impl Default for {{ENUM_OTY}} {";
|
||||||
code_ += " fn default() -> Self {";
|
code_ += " fn default() -> Self {";
|
||||||
code_ += " Self::NONE";
|
code_ += " Self::NONE";
|
||||||
code_ += " }";
|
code_ += " }";
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
// Generate native union methods.
|
// Generate native union methods.
|
||||||
code_ += "impl {{ENUM_OTY}} {";
|
code_ += "impl {{ENUM_OTY}} {";
|
||||||
@@ -988,9 +1015,12 @@ class RustGenerator : public BaseGenerator {
|
|||||||
});
|
});
|
||||||
code_ += " }";
|
code_ += " }";
|
||||||
code_ += " }";
|
code_ += " }";
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
// Pack flatbuffers union value
|
// Pack flatbuffers union value
|
||||||
code_ +=
|
code_ +=
|
||||||
" pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(&self, fbb: &mut "
|
" pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(&self, fbb: "
|
||||||
|
"&mut "
|
||||||
"::flatbuffers::FlatBufferBuilder<'b, A>)"
|
"::flatbuffers::FlatBufferBuilder<'b, A>)"
|
||||||
" -> Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>"
|
" -> Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>"
|
||||||
" {";
|
" {";
|
||||||
@@ -1006,6 +1036,7 @@ class RustGenerator : public BaseGenerator {
|
|||||||
// Generate some accessors;
|
// Generate some accessors;
|
||||||
ForAllUnionObjectVariantsBesidesNone(enum_def, [&] {
|
ForAllUnionObjectVariantsBesidesNone(enum_def, [&] {
|
||||||
// Move accessor.
|
// Move accessor.
|
||||||
|
code_ += "";
|
||||||
code_ +=
|
code_ +=
|
||||||
"/// If the union variant matches, return the owned "
|
"/// If the union variant matches, return the owned "
|
||||||
"{{U_ELEMENT_TABLE_TYPE}}, setting the union to NONE.";
|
"{{U_ELEMENT_TABLE_TYPE}}, setting the union to NONE.";
|
||||||
@@ -1023,7 +1054,9 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_ += " None";
|
code_ += " None";
|
||||||
code_ += " }";
|
code_ += " }";
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
|
|
||||||
// Immutable reference accessor.
|
// Immutable reference accessor.
|
||||||
|
code_ += "";
|
||||||
code_ +=
|
code_ +=
|
||||||
"/// If the union variant matches, return a reference to the "
|
"/// If the union variant matches, return a reference to the "
|
||||||
"{{U_ELEMENT_TABLE_TYPE}}.";
|
"{{U_ELEMENT_TABLE_TYPE}}.";
|
||||||
@@ -1034,7 +1067,9 @@ class RustGenerator : public BaseGenerator {
|
|||||||
" if let Self::{{NATIVE_VARIANT}}(v) = self "
|
" if let Self::{{NATIVE_VARIANT}}(v) = self "
|
||||||
"{ Some(v.as_ref()) } else { None }";
|
"{ Some(v.as_ref()) } else { None }";
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
|
|
||||||
// Mutable reference accessor.
|
// Mutable reference accessor.
|
||||||
|
code_ += "";
|
||||||
code_ +=
|
code_ +=
|
||||||
"/// If the union variant matches, return a mutable reference"
|
"/// If the union variant matches, return a mutable reference"
|
||||||
" to the {{U_ELEMENT_TABLE_TYPE}}.";
|
" to the {{U_ELEMENT_TABLE_TYPE}}.";
|
||||||
@@ -1046,7 +1081,9 @@ class RustGenerator : public BaseGenerator {
|
|||||||
"{ Some(v.as_mut()) } else { None }";
|
"{ Some(v.as_mut()) } else { None }";
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
});
|
});
|
||||||
|
|
||||||
code_ += "}"; // End union methods impl.
|
code_ += "}"; // End union methods impl.
|
||||||
|
code_ += "";
|
||||||
}
|
}
|
||||||
|
|
||||||
enum DefaultContext { kBuilder, kAccessor, kObject };
|
enum DefaultContext { kBuilder, kAccessor, kObject };
|
||||||
@@ -1101,9 +1138,14 @@ class RustGenerator : public BaseGenerator {
|
|||||||
// need one for Rust's Default trait so we use empty string. The usual
|
// need one for Rust's Default trait so we use empty string. The usual
|
||||||
// value of field.value.constant is `0`, which is non-sensical except
|
// value of field.value.constant is `0`, which is non-sensical except
|
||||||
// maybe to c++ (nullptr == 0).
|
// maybe to c++ (nullptr == 0).
|
||||||
// TODO: Escape strings?
|
std::string defval;
|
||||||
const std::string defval =
|
if (field.IsRequired()) {
|
||||||
field.IsRequired() ? "\"\"" : "\"" + field.value.constant + "\"";
|
defval = "\"\"";
|
||||||
|
} else {
|
||||||
|
flatbuffers::EscapeString(field.value.constant.c_str(),
|
||||||
|
field.value.constant.length(), &defval,
|
||||||
|
true, false);
|
||||||
|
}
|
||||||
if (context == kObject) {
|
if (context == kObject) {
|
||||||
return "alloc::string::ToString::to_string(" + defval + ")";
|
return "alloc::string::ToString::to_string(" + defval + ")";
|
||||||
}
|
}
|
||||||
@@ -1673,6 +1715,8 @@ class RustGenerator : public BaseGenerator {
|
|||||||
// Generate an accessor struct, builder struct, and create function for a
|
// Generate an accessor struct, builder struct, and create function for a
|
||||||
// table.
|
// table.
|
||||||
void GenTable(const StructDef& struct_def) {
|
void GenTable(const StructDef& struct_def) {
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
const bool is_private =
|
const bool is_private =
|
||||||
parser_.opts.no_leak_private_annotations &&
|
parser_.opts.no_leak_private_annotations &&
|
||||||
(struct_def.attributes.Lookup("private") != nullptr);
|
(struct_def.attributes.Lookup("private") != nullptr);
|
||||||
@@ -1683,17 +1727,18 @@ class RustGenerator : public BaseGenerator {
|
|||||||
// Generate an offset type, the base type, the Follow impl, and the
|
// Generate an offset type, the base type, the Follow impl, and the
|
||||||
// init_from_table impl.
|
// init_from_table impl.
|
||||||
code_ += "{{ACCESS_TYPE}} enum {{STRUCT_TY}}Offset {}";
|
code_ += "{{ACCESS_TYPE}} enum {{STRUCT_TY}}Offset {}";
|
||||||
code_ += "#[derive(Copy, Clone, PartialEq)]";
|
|
||||||
code_ += "";
|
code_ += "";
|
||||||
|
|
||||||
GenComment(struct_def.doc_comment);
|
GenComment(struct_def.doc_comment);
|
||||||
|
|
||||||
|
code_ += "#[derive(Copy, Clone, PartialEq)]";
|
||||||
code_ += "{{ACCESS_TYPE}} struct {{STRUCT_TY}}<'a> {";
|
code_ += "{{ACCESS_TYPE}} struct {{STRUCT_TY}}<'a> {";
|
||||||
code_ += " pub _tab: ::flatbuffers::Table<'a>,";
|
code_ += " pub _tab: ::flatbuffers::Table<'a>,";
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
code_ += "";
|
code_ += "";
|
||||||
code_ += "impl<'a> ::flatbuffers::Follow<'a> for {{STRUCT_TY}}<'a> {";
|
code_ += "impl<'a> ::flatbuffers::Follow<'a> for {{STRUCT_TY}}<'a> {";
|
||||||
code_ += " type Inner = {{STRUCT_TY}}<'a>;";
|
code_ += " type Inner = {{STRUCT_TY}}<'a>;";
|
||||||
|
code_ += "";
|
||||||
code_ += " #[inline]";
|
code_ += " #[inline]";
|
||||||
code_ += " unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {";
|
code_ += " unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {";
|
||||||
code_ +=
|
code_ +=
|
||||||
@@ -1710,7 +1755,8 @@ class RustGenerator : public BaseGenerator {
|
|||||||
"pub const {{OFFSET_NAME}}: ::flatbuffers::VOffsetT = "
|
"pub const {{OFFSET_NAME}}: ::flatbuffers::VOffsetT = "
|
||||||
"{{OFFSET_VALUE}};";
|
"{{OFFSET_VALUE}};";
|
||||||
});
|
});
|
||||||
code_ += "";
|
|
||||||
|
if (struct_def.fields.vec.size() > 0) { code_ += ""; }
|
||||||
|
|
||||||
if (parser_.opts.generate_name_strings) {
|
if (parser_.opts.generate_name_strings) {
|
||||||
GenFullyQualifiedNameGetter(struct_def, struct_def.name);
|
GenFullyQualifiedNameGetter(struct_def, struct_def.name);
|
||||||
@@ -1722,6 +1768,7 @@ class RustGenerator : public BaseGenerator {
|
|||||||
"Self {";
|
"Self {";
|
||||||
code_ += " {{STRUCT_TY}} { _tab: table }";
|
code_ += " {{STRUCT_TY}} { _tab: table }";
|
||||||
code_ += " }";
|
code_ += " }";
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
// Generate a convenient create* function that uses the above builder
|
// Generate a convenient create* function that uses the above builder
|
||||||
// to create a table in one function call.
|
// to create a table in one function call.
|
||||||
@@ -1733,7 +1780,8 @@ class RustGenerator : public BaseGenerator {
|
|||||||
" pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: "
|
" pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: "
|
||||||
"::flatbuffers::Allocator + 'bldr>(";
|
"::flatbuffers::Allocator + 'bldr>(";
|
||||||
code_ +=
|
code_ +=
|
||||||
" _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,";
|
" _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, "
|
||||||
|
"A>,";
|
||||||
code_ += " {{MAYBE_US}}args: &'args {{STRUCT_TY}}Args{{MAYBE_LT}}";
|
code_ += " {{MAYBE_US}}args: &'args {{STRUCT_TY}}Args{{MAYBE_LT}}";
|
||||||
code_ += " ) -> ::flatbuffers::WIPOffset<{{STRUCT_TY}}<'bldr>> {";
|
code_ += " ) -> ::flatbuffers::WIPOffset<{{STRUCT_TY}}<'bldr>> {";
|
||||||
|
|
||||||
@@ -1759,6 +1807,7 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_ += " builder.finish()";
|
code_ += " builder.finish()";
|
||||||
code_ += " }";
|
code_ += " }";
|
||||||
code_ += "";
|
code_ += "";
|
||||||
|
|
||||||
// Generate Object API Packer function.
|
// Generate Object API Packer function.
|
||||||
if (parser_.opts.generate_object_based_api) {
|
if (parser_.opts.generate_object_based_api) {
|
||||||
// TODO(cneo): Replace more for loops with ForAllX stuff.
|
// TODO(cneo): Replace more for loops with ForAllX stuff.
|
||||||
@@ -1858,6 +1907,7 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_ += " };";
|
code_ += " };";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
code_ += " {{STRUCT_OTY}} {";
|
code_ += " {{STRUCT_OTY}} {";
|
||||||
ForAllObjectTableFields(struct_def, [&](const FieldDef& field) {
|
ForAllObjectTableFields(struct_def, [&](const FieldDef& field) {
|
||||||
if (field.value.type.base_type == BASE_TYPE_UTYPE) return;
|
if (field.value.type.base_type == BASE_TYPE_UTYPE) return;
|
||||||
@@ -1867,8 +1917,6 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_ += " }";
|
code_ += " }";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (struct_def.fields.vec.size() > 0) code_ += "";
|
|
||||||
|
|
||||||
// Generate the accessors. Each has one of two forms:
|
// Generate the accessors. Each has one of two forms:
|
||||||
//
|
//
|
||||||
// If a value can be None:
|
// If a value can be None:
|
||||||
@@ -1881,6 +1929,7 @@ class RustGenerator : public BaseGenerator {
|
|||||||
// self._tab.get::<internal_type>(offset, defaultval).unwrap()
|
// self._tab.get::<internal_type>(offset, defaultval).unwrap()
|
||||||
// }
|
// }
|
||||||
ForAllTableFields(struct_def, [&](const FieldDef& field) {
|
ForAllTableFields(struct_def, [&](const FieldDef& field) {
|
||||||
|
code_ += "";
|
||||||
code_.SetValue("RETURN_TYPE",
|
code_.SetValue("RETURN_TYPE",
|
||||||
GenTableAccessorFuncReturnType(field, "'a"));
|
GenTableAccessorFuncReturnType(field, "'a"));
|
||||||
|
|
||||||
@@ -1911,6 +1960,7 @@ class RustGenerator : public BaseGenerator {
|
|||||||
FLATBUFFERS_ASSERT(nested_root); // Guaranteed to exist by parser.
|
FLATBUFFERS_ASSERT(nested_root); // Guaranteed to exist by parser.
|
||||||
|
|
||||||
code_.SetValue("NESTED", WrapInNameSpace(*nested_root));
|
code_.SetValue("NESTED", WrapInNameSpace(*nested_root));
|
||||||
|
code_ += "";
|
||||||
code_ += "pub fn {{FIELD}}_nested_flatbuffer(&'a self) -> \\";
|
code_ += "pub fn {{FIELD}}_nested_flatbuffer(&'a self) -> \\";
|
||||||
if (field.IsRequired()) {
|
if (field.IsRequired()) {
|
||||||
code_ += "{{NESTED}}<'a> {";
|
code_ += "{{NESTED}}<'a> {";
|
||||||
@@ -1930,7 +1980,8 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_ += " // Created from a valid Table for this object";
|
code_ += " // Created from a valid Table for this object";
|
||||||
code_ += " // Which contains a valid flatbuffer in this slot";
|
code_ += " // Which contains a valid flatbuffer in this slot";
|
||||||
code_ +=
|
code_ +=
|
||||||
" unsafe { <::flatbuffers::ForwardsUOffset<{{NESTED}}<'a>>>"
|
" unsafe { "
|
||||||
|
"<::flatbuffers::ForwardsUOffset<{{NESTED}}<'a>>>"
|
||||||
"::follow(data.bytes(), 0) }";
|
"::follow(data.bytes(), 0) }";
|
||||||
code_ += " })";
|
code_ += " })";
|
||||||
}
|
}
|
||||||
@@ -1944,6 +1995,7 @@ class RustGenerator : public BaseGenerator {
|
|||||||
ForAllUnionVariantsBesidesNone(
|
ForAllUnionVariantsBesidesNone(
|
||||||
*field.value.type.enum_def, [&](const EnumVal& unused) {
|
*field.value.type.enum_def, [&](const EnumVal& unused) {
|
||||||
(void)unused;
|
(void)unused;
|
||||||
|
code_ += "";
|
||||||
code_ += "#[inline]";
|
code_ += "#[inline]";
|
||||||
code_ += "#[allow(non_snake_case)]";
|
code_ += "#[allow(non_snake_case)]";
|
||||||
code_ +=
|
code_ +=
|
||||||
@@ -1976,10 +2028,13 @@ class RustGenerator : public BaseGenerator {
|
|||||||
} else {
|
} else {
|
||||||
code_ += " self.{{FIELD}}().map(|t| {";
|
code_ += " self.{{FIELD}}().map(|t| {";
|
||||||
code_ += " // Safety:";
|
code_ += " // Safety:";
|
||||||
code_ += " // Created from a valid Table for this object";
|
|
||||||
code_ += " // Which contains a valid union in this slot";
|
|
||||||
code_ +=
|
code_ +=
|
||||||
" unsafe { {{U_ELEMENT_TABLE_TYPE}}::init_from_table(t) "
|
" // Created from a valid Table for this object";
|
||||||
|
code_ +=
|
||||||
|
" // Which contains a valid union in this slot";
|
||||||
|
code_ +=
|
||||||
|
" unsafe { "
|
||||||
|
"{{U_ELEMENT_TABLE_TYPE}}::init_from_table(t) "
|
||||||
"}";
|
"}";
|
||||||
code_ += " })";
|
code_ += " })";
|
||||||
}
|
}
|
||||||
@@ -1987,7 +2042,6 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_ += " None";
|
code_ += " None";
|
||||||
code_ += " }";
|
code_ += " }";
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
code_ += "";
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
code_ += "}"; // End of table impl.
|
code_ += "}"; // End of table impl.
|
||||||
@@ -1999,7 +2053,7 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_ += " fn run_verifier(";
|
code_ += " fn run_verifier(";
|
||||||
code_ += " v: &mut ::flatbuffers::Verifier, pos: usize";
|
code_ += " v: &mut ::flatbuffers::Verifier, pos: usize";
|
||||||
code_ += " ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {";
|
code_ += " ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {";
|
||||||
code_ += " v.visit_table(pos)?\\";
|
code_ += " v.visit_table(pos)?";
|
||||||
// Escape newline and insert it onthe next line so we can end the builder
|
// Escape newline and insert it onthe next line so we can end the builder
|
||||||
// with a nice semicolon.
|
// with a nice semicolon.
|
||||||
ForAllTableFields(struct_def, [&](const FieldDef& field) {
|
ForAllTableFields(struct_def, [&](const FieldDef& field) {
|
||||||
@@ -2010,8 +2064,8 @@ class RustGenerator : public BaseGenerator {
|
|||||||
// All types besides unions.
|
// All types besides unions.
|
||||||
code_.SetValue("TY", FollowType(field.value.type, "'_"));
|
code_.SetValue("TY", FollowType(field.value.type, "'_"));
|
||||||
code_ +=
|
code_ +=
|
||||||
"\n .visit_field::<{{TY}}>(\"{{FIELD}}\", "
|
" .visit_field::<{{TY}}>(\"{{FIELD}}\", "
|
||||||
"Self::{{OFFSET_NAME}}, {{IS_REQ}})?\\";
|
"Self::{{OFFSET_NAME}}, {{IS_REQ}})?";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Unions.
|
// Unions.
|
||||||
@@ -2022,7 +2076,7 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_.SetValue("UNION_TYPE_METHOD",
|
code_.SetValue("UNION_TYPE_METHOD",
|
||||||
namer_.LegacyRustUnionTypeMethod(field));
|
namer_.LegacyRustUnionTypeMethod(field));
|
||||||
code_ +=
|
code_ +=
|
||||||
"\n .visit_union::<{{UNION_TYPE}}, _>("
|
" .visit_union::<{{UNION_TYPE}}, _>("
|
||||||
"\"{{UNION_TYPE_METHOD}}\", Self::{{UNION_TYPE_OFFSET_NAME}}, "
|
"\"{{UNION_TYPE_METHOD}}\", Self::{{UNION_TYPE_OFFSET_NAME}}, "
|
||||||
"\"{{FIELD}}\", Self::{{OFFSET_NAME}}, {{IS_REQ}}, "
|
"\"{{FIELD}}\", Self::{{OFFSET_NAME}}, {{IS_REQ}}, "
|
||||||
"|key, v, pos| {";
|
"|key, v, pos| {";
|
||||||
@@ -2030,18 +2084,20 @@ class RustGenerator : public BaseGenerator {
|
|||||||
ForAllUnionVariantsBesidesNone(union_def, [&](const EnumVal& unused) {
|
ForAllUnionVariantsBesidesNone(union_def, [&](const EnumVal& unused) {
|
||||||
(void)unused;
|
(void)unused;
|
||||||
code_ +=
|
code_ +=
|
||||||
" {{U_ELEMENT_ENUM_TYPE}} => v.verify_union_variant::"
|
" {{U_ELEMENT_ENUM_TYPE}} => "
|
||||||
|
"v.verify_union_variant::"
|
||||||
"<::flatbuffers::ForwardsUOffset<{{U_ELEMENT_TABLE_TYPE}}>>("
|
"<::flatbuffers::ForwardsUOffset<{{U_ELEMENT_TABLE_TYPE}}>>("
|
||||||
"\"{{U_ELEMENT_ENUM_TYPE}}\", pos),";
|
"\"{{U_ELEMENT_ENUM_TYPE}}\", pos),";
|
||||||
});
|
});
|
||||||
code_ += " _ => Ok(()),";
|
code_ += " _ => Ok(()),";
|
||||||
code_ += " }";
|
code_ += " }";
|
||||||
code_ += " })?\\";
|
code_ += " })?";
|
||||||
});
|
});
|
||||||
code_ += "\n .finish();";
|
code_ += " .finish();";
|
||||||
code_ += " Ok(())";
|
code_ += " Ok(())";
|
||||||
code_ += " }";
|
code_ += " }";
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
// Generate an args struct:
|
// Generate an args struct:
|
||||||
code_.SetValue("MAYBE_LT",
|
code_.SetValue("MAYBE_LT",
|
||||||
@@ -2052,6 +2108,7 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_ += "pub {{FIELD}}: {{PARAM_TYPE}},";
|
code_ += "pub {{FIELD}}: {{PARAM_TYPE}},";
|
||||||
});
|
});
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
// Generate an impl of Default for the *Args type:
|
// Generate an impl of Default for the *Args type:
|
||||||
code_ += "impl<'a> Default for {{STRUCT_TY}}Args{{MAYBE_LT}} {";
|
code_ += "impl<'a> Default for {{STRUCT_TY}}Args{{MAYBE_LT}} {";
|
||||||
@@ -2073,17 +2130,19 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_.SetValue("NUM_FIELDS", NumToString(numFields));
|
code_.SetValue("NUM_FIELDS", NumToString(numFields));
|
||||||
code_ += "impl Serialize for {{STRUCT_TY}}<'_> {";
|
code_ += "impl Serialize for {{STRUCT_TY}}<'_> {";
|
||||||
code_ +=
|
code_ +=
|
||||||
" fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>";
|
" fn serialize<S>(&self, serializer: S) -> Result<S::Ok, "
|
||||||
|
"S::Error>";
|
||||||
code_ += " where";
|
code_ += " where";
|
||||||
code_ += " S: Serializer,";
|
code_ += " S: Serializer,";
|
||||||
code_ += " {";
|
code_ += " {";
|
||||||
if (numFields == 0) {
|
if (numFields == 0) {
|
||||||
code_ +=
|
code_ +=
|
||||||
" let s = serializer.serialize_struct(\"{{STRUCT_TY}}\", 0)?;";
|
" let s = serializer.serialize_struct(\"{{STRUCT_TY}}\", "
|
||||||
|
"0)?;";
|
||||||
} else {
|
} else {
|
||||||
code_ +=
|
code_ +=
|
||||||
" let mut s = serializer.serialize_struct(\"{{STRUCT_TY}}\", "
|
" let mut s = "
|
||||||
"{{NUM_FIELDS}})?;";
|
"serializer.serialize_struct(\"{{STRUCT_TY}}\", {{NUM_FIELDS}})?;";
|
||||||
}
|
}
|
||||||
ForAllTableFields(struct_def, [&](const FieldDef& field) {
|
ForAllTableFields(struct_def, [&](const FieldDef& field) {
|
||||||
const Type& type = field.value.type;
|
const Type& type = field.value.type;
|
||||||
@@ -2145,6 +2204,7 @@ class RustGenerator : public BaseGenerator {
|
|||||||
" start_: ::flatbuffers::WIPOffset<"
|
" start_: ::flatbuffers::WIPOffset<"
|
||||||
"::flatbuffers::TableUnfinishedWIPOffset>,";
|
"::flatbuffers::TableUnfinishedWIPOffset>,";
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
// Generate builder functions:
|
// Generate builder functions:
|
||||||
code_ +=
|
code_ +=
|
||||||
@@ -2180,6 +2240,7 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_ += " {{FUNC_BODY}}({{FIELD_OFFSET}}, {{FIELD}});";
|
code_ += " {{FUNC_BODY}}({{FIELD_OFFSET}}, {{FIELD}});";
|
||||||
}
|
}
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
|
code_ += "";
|
||||||
});
|
});
|
||||||
|
|
||||||
// Struct initializer (all fields required);
|
// Struct initializer (all fields required);
|
||||||
@@ -2195,6 +2256,7 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_ += " start_: start,";
|
code_ += " start_: start,";
|
||||||
code_ += " }";
|
code_ += " }";
|
||||||
code_ += " }";
|
code_ += " }";
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
// finish() function.
|
// finish() function.
|
||||||
code_ += " #[inline]";
|
code_ += " #[inline]";
|
||||||
@@ -2258,6 +2320,8 @@ class RustGenerator : public BaseGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GenTableObject(const StructDef& table) {
|
void GenTableObject(const StructDef& table) {
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
code_.SetValue("STRUCT_OTY", namer_.ObjectType(table));
|
code_.SetValue("STRUCT_OTY", namer_.ObjectType(table));
|
||||||
code_.SetValue("STRUCT_TY", namer_.Type(table));
|
code_.SetValue("STRUCT_TY", namer_.Type(table));
|
||||||
|
|
||||||
@@ -2272,6 +2336,7 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_ += "pub {{FIELD}}: {{FIELD_OTY}},";
|
code_ += "pub {{FIELD}}: {{FIELD_OTY}},";
|
||||||
});
|
});
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
code_ += "impl Default for {{STRUCT_OTY}} {";
|
code_ += "impl Default for {{STRUCT_OTY}} {";
|
||||||
code_ += " fn default() -> Self {";
|
code_ += " fn default() -> Self {";
|
||||||
@@ -2284,6 +2349,7 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_ += " }";
|
code_ += " }";
|
||||||
code_ += " }";
|
code_ += " }";
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
// TODO(cneo): Generate defaults for Native tables. However, since structs
|
// TODO(cneo): Generate defaults for Native tables. However, since structs
|
||||||
// may be required, they, and therefore enums need defaults.
|
// may be required, they, and therefore enums need defaults.
|
||||||
@@ -2430,6 +2496,8 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_.SetValue("KEY_TYPE", GenTableAccessorFuncReturnType(field, ""));
|
code_.SetValue("KEY_TYPE", GenTableAccessorFuncReturnType(field, ""));
|
||||||
code_.SetValue("REF", IsString(field.value.type) ? "" : "&");
|
code_.SetValue("REF", IsString(field.value.type) ? "" : "&");
|
||||||
|
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
code_ += "#[inline]";
|
code_ += "#[inline]";
|
||||||
code_ +=
|
code_ +=
|
||||||
"pub fn key_compare_less_than(&self, o: &{{STRUCT_TY}}) -> "
|
"pub fn key_compare_less_than(&self, o: &{{STRUCT_TY}}) -> "
|
||||||
@@ -2437,6 +2505,7 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_ += " self.{{FIELD}}() < o.{{FIELD}}()";
|
code_ += " self.{{FIELD}}() < o.{{FIELD}}()";
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
code_ += "";
|
code_ += "";
|
||||||
|
|
||||||
code_ += "#[inline]";
|
code_ += "#[inline]";
|
||||||
code_ +=
|
code_ +=
|
||||||
"pub fn key_compare_with_value(&self, val: {{KEY_TYPE}}) -> "
|
"pub fn key_compare_with_value(&self, val: {{KEY_TYPE}}) -> "
|
||||||
@@ -2449,60 +2518,69 @@ class RustGenerator : public BaseGenerator {
|
|||||||
// Generate functions for accessing the root table object. This function
|
// Generate functions for accessing the root table object. This function
|
||||||
// must only be called if the root table is defined.
|
// must only be called if the root table is defined.
|
||||||
void GenRootTableFuncs(const StructDef& struct_def) {
|
void GenRootTableFuncs(const StructDef& struct_def) {
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
FLATBUFFERS_ASSERT(parser_.root_struct_def_ && "root table not defined");
|
FLATBUFFERS_ASSERT(parser_.root_struct_def_ && "root table not defined");
|
||||||
code_.SetValue("STRUCT_TY", namer_.Type(struct_def));
|
code_.SetValue("STRUCT_TY", namer_.Type(struct_def));
|
||||||
code_.SetValue("STRUCT_FN", namer_.Function(struct_def));
|
code_.SetValue("STRUCT_FN", namer_.Function(struct_def));
|
||||||
code_.SetValue("STRUCT_CONST", namer_.Constant(struct_def.name));
|
code_.SetValue("STRUCT_CONST", namer_.Constant(struct_def.name));
|
||||||
|
|
||||||
// Default verifier root fns.
|
// Default verifier root fns.
|
||||||
code_ += "#[inline]";
|
|
||||||
code_ += "/// Verifies that a buffer of bytes contains a `{{STRUCT_TY}}`";
|
code_ += "/// Verifies that a buffer of bytes contains a `{{STRUCT_TY}}`";
|
||||||
code_ += "/// and returns it.";
|
code_ += "/// and returns it.";
|
||||||
code_ += "/// Note that verification is still experimental and may not";
|
code_ += "/// Note that verification is still experimental and may not";
|
||||||
code_ += "/// catch every error, or be maximally performant. For the";
|
code_ += "/// catch every error, or be maximally performant. For the";
|
||||||
code_ += "/// previous, unchecked, behavior use";
|
code_ += "/// previous, unchecked, behavior use";
|
||||||
code_ += "/// `root_as_{{STRUCT_FN}}_unchecked`.";
|
code_ += "/// `root_as_{{STRUCT_FN}}_unchecked`.";
|
||||||
|
code_ += "#[inline]";
|
||||||
code_ +=
|
code_ +=
|
||||||
"pub fn root_as_{{STRUCT_FN}}(buf: &[u8]) "
|
"pub fn root_as_{{STRUCT_FN}}(buf: &[u8]) "
|
||||||
"-> Result<{{STRUCT_TY}}<'_>, ::flatbuffers::InvalidFlatbuffer> {";
|
"-> Result<{{STRUCT_TY}}<'_>, ::flatbuffers::InvalidFlatbuffer> {";
|
||||||
code_ += " ::flatbuffers::root::<{{STRUCT_TY}}>(buf)";
|
code_ += " ::flatbuffers::root::<{{STRUCT_TY}}>(buf)";
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
code_ += "#[inline]";
|
code_ += "";
|
||||||
|
|
||||||
code_ += "/// Verifies that a buffer of bytes contains a size prefixed";
|
code_ += "/// Verifies that a buffer of bytes contains a size prefixed";
|
||||||
code_ += "/// `{{STRUCT_TY}}` and returns it.";
|
code_ += "/// `{{STRUCT_TY}}` and returns it.";
|
||||||
code_ += "/// Note that verification is still experimental and may not";
|
code_ += "/// Note that verification is still experimental and may not";
|
||||||
code_ += "/// catch every error, or be maximally performant. For the";
|
code_ += "/// catch every error, or be maximally performant. For the";
|
||||||
code_ += "/// previous, unchecked, behavior use";
|
code_ += "/// previous, unchecked, behavior use";
|
||||||
code_ += "/// `size_prefixed_root_as_{{STRUCT_FN}}_unchecked`.";
|
code_ += "/// `size_prefixed_root_as_{{STRUCT_FN}}_unchecked`.";
|
||||||
|
code_ += "#[inline]";
|
||||||
code_ +=
|
code_ +=
|
||||||
"pub fn size_prefixed_root_as_{{STRUCT_FN}}"
|
"pub fn size_prefixed_root_as_{{STRUCT_FN}}"
|
||||||
"(buf: &[u8]) -> Result<{{STRUCT_TY}}<'_>, "
|
"(buf: &[u8]) -> Result<{{STRUCT_TY}}<'_>, "
|
||||||
"::flatbuffers::InvalidFlatbuffer> {";
|
"::flatbuffers::InvalidFlatbuffer> {";
|
||||||
code_ += " ::flatbuffers::size_prefixed_root::<{{STRUCT_TY}}>(buf)";
|
code_ += " ::flatbuffers::size_prefixed_root::<{{STRUCT_TY}}>(buf)";
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
// Verifier with options root fns.
|
// Verifier with options root fns.
|
||||||
code_ += "#[inline]";
|
|
||||||
code_ += "/// Verifies, with the given options, that a buffer of bytes";
|
code_ += "/// Verifies, with the given options, that a buffer of bytes";
|
||||||
code_ += "/// contains a `{{STRUCT_TY}}` and returns it.";
|
code_ += "/// contains a `{{STRUCT_TY}}` and returns it.";
|
||||||
code_ += "/// Note that verification is still experimental and may not";
|
code_ += "/// Note that verification is still experimental and may not";
|
||||||
code_ += "/// catch every error, or be maximally performant. For the";
|
code_ += "/// catch every error, or be maximally performant. For the";
|
||||||
code_ += "/// previous, unchecked, behavior use";
|
code_ += "/// previous, unchecked, behavior use";
|
||||||
code_ += "/// `root_as_{{STRUCT_FN}}_unchecked`.";
|
code_ += "/// `root_as_{{STRUCT_FN}}_unchecked`.";
|
||||||
|
code_ += "#[inline]";
|
||||||
code_ += "pub fn root_as_{{STRUCT_FN}}_with_opts<'b, 'o>(";
|
code_ += "pub fn root_as_{{STRUCT_FN}}_with_opts<'b, 'o>(";
|
||||||
code_ += " opts: &'o ::flatbuffers::VerifierOptions,";
|
code_ += " opts: &'o ::flatbuffers::VerifierOptions,";
|
||||||
code_ += " buf: &'b [u8],";
|
code_ += " buf: &'b [u8],";
|
||||||
code_ +=
|
code_ +=
|
||||||
") -> Result<{{STRUCT_TY}}<'b>, ::flatbuffers::InvalidFlatbuffer>"
|
") -> Result<{{STRUCT_TY}}<'b>, ::flatbuffers::InvalidFlatbuffer>"
|
||||||
" {";
|
" {";
|
||||||
code_ += " ::flatbuffers::root_with_opts::<{{STRUCT_TY}}<'b>>(opts, buf)";
|
code_ +=
|
||||||
|
" ::flatbuffers::root_with_opts::<{{STRUCT_TY}}<'b>>(opts, buf)";
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
code_ += "#[inline]";
|
code_ += "";
|
||||||
|
|
||||||
code_ += "/// Verifies, with the given verifier options, that a buffer of";
|
code_ += "/// Verifies, with the given verifier options, that a buffer of";
|
||||||
code_ += "/// bytes contains a size prefixed `{{STRUCT_TY}}` and returns";
|
code_ += "/// bytes contains a size prefixed `{{STRUCT_TY}}` and returns";
|
||||||
code_ += "/// it. Note that verification is still experimental and may not";
|
code_ += "/// it. Note that verification is still experimental and may not";
|
||||||
code_ += "/// catch every error, or be maximally performant. For the";
|
code_ += "/// catch every error, or be maximally performant. For the";
|
||||||
code_ += "/// previous, unchecked, behavior use";
|
code_ += "/// previous, unchecked, behavior use";
|
||||||
code_ += "/// `root_as_{{STRUCT_FN}}_unchecked`.";
|
code_ += "/// `root_as_{{STRUCT_FN}}_unchecked`.";
|
||||||
|
code_ += "#[inline]";
|
||||||
code_ +=
|
code_ +=
|
||||||
"pub fn size_prefixed_root_as_{{STRUCT_FN}}_with_opts"
|
"pub fn size_prefixed_root_as_{{STRUCT_FN}}_with_opts"
|
||||||
"<'b, 'o>(";
|
"<'b, 'o>(";
|
||||||
@@ -2515,8 +2593,9 @@ class RustGenerator : public BaseGenerator {
|
|||||||
" ::flatbuffers::size_prefixed_root_with_opts::<{{STRUCT_TY}}"
|
" ::flatbuffers::size_prefixed_root_with_opts::<{{STRUCT_TY}}"
|
||||||
"<'b>>(opts, buf)";
|
"<'b>>(opts, buf)";
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
// Unchecked root fns.
|
// Unchecked root fns.
|
||||||
code_ += "#[inline]";
|
|
||||||
code_ +=
|
code_ +=
|
||||||
"/// Assumes, without verification, that a buffer of bytes "
|
"/// Assumes, without verification, that a buffer of bytes "
|
||||||
"contains a {{STRUCT_TY}} and returns it.";
|
"contains a {{STRUCT_TY}} and returns it.";
|
||||||
@@ -2524,12 +2603,15 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_ +=
|
code_ +=
|
||||||
"/// Callers must trust the given bytes do indeed contain a valid"
|
"/// Callers must trust the given bytes do indeed contain a valid"
|
||||||
" `{{STRUCT_TY}}`.";
|
" `{{STRUCT_TY}}`.";
|
||||||
|
code_ += "#[inline]";
|
||||||
code_ +=
|
code_ +=
|
||||||
"pub unsafe fn root_as_{{STRUCT_FN}}_unchecked"
|
"pub unsafe fn root_as_{{STRUCT_FN}}_unchecked"
|
||||||
"(buf: &[u8]) -> {{STRUCT_TY}}<'_> {";
|
"(buf: &[u8]) -> {{STRUCT_TY}}<'_> {";
|
||||||
code_ += " unsafe { ::flatbuffers::root_unchecked::<{{STRUCT_TY}}>(buf) }";
|
code_ +=
|
||||||
|
" unsafe { ::flatbuffers::root_unchecked::<{{STRUCT_TY}}>(buf) }";
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
code_ += "#[inline]";
|
code_ += "";
|
||||||
|
|
||||||
code_ +=
|
code_ +=
|
||||||
"/// Assumes, without verification, that a buffer of bytes "
|
"/// Assumes, without verification, that a buffer of bytes "
|
||||||
"contains a size prefixed {{STRUCT_TY}} and returns it.";
|
"contains a size prefixed {{STRUCT_TY}} and returns it.";
|
||||||
@@ -2537,6 +2619,7 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_ +=
|
code_ +=
|
||||||
"/// Callers must trust the given bytes do indeed contain a valid"
|
"/// Callers must trust the given bytes do indeed contain a valid"
|
||||||
" size prefixed `{{STRUCT_TY}}`.";
|
" size prefixed `{{STRUCT_TY}}`.";
|
||||||
|
code_ += "#[inline]";
|
||||||
code_ +=
|
code_ +=
|
||||||
"pub unsafe fn size_prefixed_root_as_{{STRUCT_FN}}"
|
"pub unsafe fn size_prefixed_root_as_{{STRUCT_FN}}"
|
||||||
"_unchecked(buf: &[u8]) -> {{STRUCT_TY}}<'_> {";
|
"_unchecked(buf: &[u8]) -> {{STRUCT_TY}}<'_> {";
|
||||||
@@ -2545,6 +2628,7 @@ class RustGenerator : public BaseGenerator {
|
|||||||
"::flatbuffers::size_prefixed_root_unchecked::<{{STRUCT_TY}}>"
|
"::flatbuffers::size_prefixed_root_unchecked::<{{STRUCT_TY}}>"
|
||||||
"(buf) }";
|
"(buf) }";
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
if (parser_.file_identifier_.length()) {
|
if (parser_.file_identifier_.length()) {
|
||||||
// Declare the identifier
|
// Declare the identifier
|
||||||
@@ -2583,7 +2667,8 @@ class RustGenerator : public BaseGenerator {
|
|||||||
"pub fn finish_{{STRUCT_FN}}_buffer<'a, 'b, A: "
|
"pub fn finish_{{STRUCT_FN}}_buffer<'a, 'b, A: "
|
||||||
"::flatbuffers::Allocator + 'a>(";
|
"::flatbuffers::Allocator + 'a>(";
|
||||||
code_ += " fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,";
|
code_ += " fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,";
|
||||||
code_ += " root: ::flatbuffers::WIPOffset<{{STRUCT_TY}}<'a>>) {";
|
code_ += " root: ::flatbuffers::WIPOffset<{{STRUCT_TY}}<'a>>";
|
||||||
|
code_ += ") {";
|
||||||
if (parser_.file_identifier_.length()) {
|
if (parser_.file_identifier_.length()) {
|
||||||
code_ += " fbb.finish(root, Some({{STRUCT_CONST}}_IDENTIFIER));";
|
code_ += " fbb.finish(root, Some({{STRUCT_CONST}}_IDENTIFIER));";
|
||||||
} else {
|
} else {
|
||||||
@@ -2594,9 +2679,10 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_ += "#[inline]";
|
code_ += "#[inline]";
|
||||||
code_ +=
|
code_ +=
|
||||||
"pub fn finish_size_prefixed_{{STRUCT_FN}}_buffer"
|
"pub fn finish_size_prefixed_{{STRUCT_FN}}_buffer"
|
||||||
"<'a, 'b, A: ::flatbuffers::Allocator + 'a>("
|
"<'a, 'b, A: ::flatbuffers::Allocator + 'a>(";
|
||||||
"fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, "
|
code_ += " fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,";
|
||||||
"root: ::flatbuffers::WIPOffset<{{STRUCT_TY}}<'a>>) {";
|
code_ += " root: ::flatbuffers::WIPOffset<{{STRUCT_TY}}<'a>>";
|
||||||
|
code_ += ") {";
|
||||||
if (parser_.file_identifier_.length()) {
|
if (parser_.file_identifier_.length()) {
|
||||||
code_ +=
|
code_ +=
|
||||||
" fbb.finish_size_prefixed(root, "
|
" fbb.finish_size_prefixed(root, "
|
||||||
@@ -2652,6 +2738,8 @@ class RustGenerator : public BaseGenerator {
|
|||||||
}
|
}
|
||||||
// Generate an accessor struct with constructor for a flatbuffers struct.
|
// Generate an accessor struct with constructor for a flatbuffers struct.
|
||||||
void GenStruct(const StructDef& struct_def) {
|
void GenStruct(const StructDef& struct_def) {
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
const bool is_private =
|
const bool is_private =
|
||||||
parser_.opts.no_leak_private_annotations &&
|
parser_.opts.no_leak_private_annotations &&
|
||||||
(struct_def.attributes.Lookup("private") != nullptr);
|
(struct_def.attributes.Lookup("private") != nullptr);
|
||||||
@@ -2674,11 +2762,14 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_ += "#[repr(transparent)]";
|
code_ += "#[repr(transparent)]";
|
||||||
code_ += "#[derive(Clone, Copy, PartialEq)]";
|
code_ += "#[derive(Clone, Copy, PartialEq)]";
|
||||||
code_ += "{{ACCESS_TYPE}} struct {{STRUCT_TY}}(pub [u8; {{STRUCT_SIZE}}]);";
|
code_ += "{{ACCESS_TYPE}} struct {{STRUCT_TY}}(pub [u8; {{STRUCT_SIZE}}]);";
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
code_ += "impl Default for {{STRUCT_TY}} {";
|
code_ += "impl Default for {{STRUCT_TY}} {";
|
||||||
code_ += " fn default() -> Self {";
|
code_ += " fn default() -> Self {";
|
||||||
code_ += " Self([0; {{STRUCT_SIZE}}])";
|
code_ += " Self([0; {{STRUCT_SIZE}}])";
|
||||||
code_ += " }";
|
code_ += " }";
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
// Debug for structs.
|
// Debug for structs.
|
||||||
code_ += "impl ::core::fmt::Debug for {{STRUCT_TY}} {";
|
code_ += "impl ::core::fmt::Debug for {{STRUCT_TY}} {";
|
||||||
@@ -2699,15 +2790,21 @@ class RustGenerator : public BaseGenerator {
|
|||||||
// Follow for the value type, Follow for the reference type, Push for the
|
// Follow for the value type, Follow for the reference type, Push for the
|
||||||
// value type, and Push for the reference type.
|
// value type, and Push for the reference type.
|
||||||
code_ += "impl ::flatbuffers::SimpleToVerifyInSlice for {{STRUCT_TY}} {}";
|
code_ += "impl ::flatbuffers::SimpleToVerifyInSlice for {{STRUCT_TY}} {}";
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
code_ += "impl<'a> ::flatbuffers::Follow<'a> for {{STRUCT_TY}} {";
|
code_ += "impl<'a> ::flatbuffers::Follow<'a> for {{STRUCT_TY}} {";
|
||||||
code_ += " type Inner = &'a {{STRUCT_TY}};";
|
code_ += " type Inner = &'a {{STRUCT_TY}};";
|
||||||
|
code_ += "";
|
||||||
code_ += " #[inline]";
|
code_ += " #[inline]";
|
||||||
code_ += " unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {";
|
code_ += " unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {";
|
||||||
code_ += " unsafe { <&'a {{STRUCT_TY}}>::follow(buf, loc) }";
|
code_ += " unsafe { <&'a {{STRUCT_TY}}>::follow(buf, loc) }";
|
||||||
code_ += " }";
|
code_ += " }";
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
code_ += "impl<'a> ::flatbuffers::Follow<'a> for &'a {{STRUCT_TY}} {";
|
code_ += "impl<'a> ::flatbuffers::Follow<'a> for &'a {{STRUCT_TY}} {";
|
||||||
code_ += " type Inner = &'a {{STRUCT_TY}};";
|
code_ += " type Inner = &'a {{STRUCT_TY}};";
|
||||||
|
code_ += "";
|
||||||
code_ += " #[inline]";
|
code_ += " #[inline]";
|
||||||
code_ += " unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {";
|
code_ += " unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {";
|
||||||
code_ +=
|
code_ +=
|
||||||
@@ -2715,8 +2812,11 @@ class RustGenerator : public BaseGenerator {
|
|||||||
"loc) }";
|
"loc) }";
|
||||||
code_ += " }";
|
code_ += " }";
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
code_ += "impl<'b> ::flatbuffers::Push for {{STRUCT_TY}} {";
|
code_ += "impl<'b> ::flatbuffers::Push for {{STRUCT_TY}} {";
|
||||||
code_ += " type Output = {{STRUCT_TY}};";
|
code_ += " type Output = {{STRUCT_TY}};";
|
||||||
|
code_ += "";
|
||||||
code_ += " #[inline]";
|
code_ += " #[inline]";
|
||||||
code_ += " unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {";
|
code_ += " unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {";
|
||||||
code_ +=
|
code_ +=
|
||||||
@@ -2725,6 +2825,8 @@ class RustGenerator : public BaseGenerator {
|
|||||||
"{{STRUCT_TY}} as *const u8, <Self as ::flatbuffers::Push>::size()) };";
|
"{{STRUCT_TY}} as *const u8, <Self as ::flatbuffers::Push>::size()) };";
|
||||||
code_ += " dst.copy_from_slice(src);";
|
code_ += " dst.copy_from_slice(src);";
|
||||||
code_ += " }";
|
code_ += " }";
|
||||||
|
code_ += "";
|
||||||
|
|
||||||
code_ += " #[inline]";
|
code_ += " #[inline]";
|
||||||
code_ += " fn alignment() -> ::flatbuffers::PushAlignment {";
|
code_ += " fn alignment() -> ::flatbuffers::PushAlignment {";
|
||||||
code_ += " ::flatbuffers::PushAlignment::new({{ALIGN}})";
|
code_ += " ::flatbuffers::PushAlignment::new({{ALIGN}})";
|
||||||
@@ -2750,7 +2852,8 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_.SetValue("NUM_FIELDS", NumToString(numFields));
|
code_.SetValue("NUM_FIELDS", NumToString(numFields));
|
||||||
code_ += "impl Serialize for {{STRUCT_TY}} {";
|
code_ += "impl Serialize for {{STRUCT_TY}} {";
|
||||||
code_ +=
|
code_ +=
|
||||||
" fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>";
|
" fn serialize<S>(&self, serializer: S) -> Result<S::Ok, "
|
||||||
|
"S::Error>";
|
||||||
code_ += " where";
|
code_ += " where";
|
||||||
code_ += " S: Serializer,";
|
code_ += " S: Serializer,";
|
||||||
code_ += " {";
|
code_ += " {";
|
||||||
@@ -2934,18 +3037,61 @@ class RustGenerator : public BaseGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
code_ += "}"; // End impl Struct methods.
|
code_ += "}"; // End impl Struct methods.
|
||||||
code_ += "";
|
|
||||||
|
|
||||||
// Generate Struct Object.
|
// Generate Struct Object.
|
||||||
if (parser_.opts.generate_object_based_api) {
|
if (parser_.opts.generate_object_based_api) {
|
||||||
// Struct declaration
|
// Struct declaration
|
||||||
code_ += "#[derive(Debug, Clone, PartialEq, Default)]";
|
code_ += "";
|
||||||
|
code_ += "#[derive(Debug, Clone, PartialEq)]";
|
||||||
code_ += "{{ACCESS_TYPE}} struct {{STRUCT_OTY}} {";
|
code_ += "{{ACCESS_TYPE}} struct {{STRUCT_OTY}} {";
|
||||||
ForAllStructFields(struct_def, [&](const FieldDef& field) {
|
ForAllStructFields(struct_def, [&](const FieldDef& field) {
|
||||||
(void)field; // unused.
|
(void)field; // unused.
|
||||||
code_ += "pub {{FIELD}}: {{FIELD_OTY}},";
|
code_ += "pub {{FIELD}}: {{FIELD_OTY}},";
|
||||||
});
|
});
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
|
// Manual impl Default to avoid issues with arrays > 32 elements
|
||||||
|
// where #[derive(Default)] fails on older Rust versions.
|
||||||
|
code_ += "impl Default for {{STRUCT_OTY}} {";
|
||||||
|
code_ += " fn default() -> Self {";
|
||||||
|
code_ += " Self {";
|
||||||
|
ForAllStructFields(struct_def, [&](const FieldDef& field) {
|
||||||
|
const auto full_type = GetFullType(field.value.type);
|
||||||
|
switch (full_type) {
|
||||||
|
case ftArrayOfBuiltin: {
|
||||||
|
// Use the correct zero literal for each element type:
|
||||||
|
// bool -> false, float/double -> 0.0, integers -> 0
|
||||||
|
const auto elem_type = field.value.type.VectorType().base_type;
|
||||||
|
std::string zero;
|
||||||
|
if (elem_type == BASE_TYPE_BOOL) {
|
||||||
|
zero = "false";
|
||||||
|
} else if (IsFloat(elem_type)) {
|
||||||
|
zero = "0.0";
|
||||||
|
} else {
|
||||||
|
zero = "0";
|
||||||
|
}
|
||||||
|
code_ += " {{FIELD}}: [" + zero + "; " +
|
||||||
|
NumToString(field.value.type.fixed_length) + "],";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ftArrayOfEnum:
|
||||||
|
case ftArrayOfStruct: {
|
||||||
|
code_ +=
|
||||||
|
" {{FIELD}}: ::flatbuffers::array_init(|_| "
|
||||||
|
"Default::default()),";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
std::string default_value =
|
||||||
|
GetDefaultValue(field, kObject);
|
||||||
|
code_ += " {{FIELD}}: " + default_value + ",";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
code_ += " }";
|
||||||
|
code_ += " }";
|
||||||
|
code_ += "}";
|
||||||
|
code_ += "";
|
||||||
// The `pack` method that turns the native struct into its Flatbuffers
|
// The `pack` method that turns the native struct into its Flatbuffers
|
||||||
// counterpart.
|
// counterpart.
|
||||||
code_ += "impl {{STRUCT_OTY}} {";
|
code_ += "impl {{STRUCT_OTY}} {";
|
||||||
@@ -2969,16 +3115,13 @@ class RustGenerator : public BaseGenerator {
|
|||||||
code_ += " )";
|
code_ += " )";
|
||||||
code_ += " }";
|
code_ += " }";
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
code_ += "";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenNamespaceImports(const int white_spaces) {
|
void GenNamespaceImports() {
|
||||||
// DO not use global attributes (i.e. #![...]) since it interferes
|
// DO not use global attributes (i.e. #![...]) since it interferes
|
||||||
// with users who include! generated files.
|
// with users who include! generated files.
|
||||||
// See: https://github.com/google/flatbuffers/issues/6261
|
// See: https://github.com/google/flatbuffers/issues/6261
|
||||||
std::string indent = std::string(white_spaces, ' ');
|
|
||||||
code_ += "";
|
|
||||||
if (!parser_.opts.generate_all) {
|
if (!parser_.opts.generate_all) {
|
||||||
for (auto it = parser_.included_files_.begin();
|
for (auto it = parser_.included_files_.begin();
|
||||||
it != parser_.included_files_.end(); ++it) {
|
it != parser_.included_files_.end(); ++it) {
|
||||||
@@ -2987,23 +3130,22 @@ class RustGenerator : public BaseGenerator {
|
|||||||
auto basename = flatbuffers::StripPath(noext);
|
auto basename = flatbuffers::StripPath(noext);
|
||||||
|
|
||||||
if (parser_.opts.include_prefix.empty()) {
|
if (parser_.opts.include_prefix.empty()) {
|
||||||
code_ += indent + "use crate::" + basename +
|
code_ +=
|
||||||
parser_.opts.filename_suffix + "::*;";
|
"use crate::" + basename + parser_.opts.filename_suffix + "::*;";
|
||||||
} else {
|
} else {
|
||||||
auto prefix = parser_.opts.include_prefix;
|
auto prefix = parser_.opts.include_prefix;
|
||||||
prefix.pop_back();
|
prefix.pop_back();
|
||||||
|
|
||||||
code_ += indent + "use crate::" + prefix + "::" + basename +
|
code_ += "use crate::" + prefix + "::" + basename +
|
||||||
parser_.opts.filename_suffix + "::*;";
|
parser_.opts.filename_suffix + "::*;";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parser_.opts.rust_serialize) {
|
if (parser_.opts.rust_serialize) {
|
||||||
code_ += indent + "extern crate serde;";
|
code_ += "extern crate serde;";
|
||||||
code_ +=
|
code_ +=
|
||||||
indent +
|
|
||||||
"use self::serde::ser::{Serialize, Serializer, SerializeStruct};";
|
"use self::serde::ser::{Serialize, Serializer, SerializeStruct};";
|
||||||
code_ += "";
|
|
||||||
}
|
}
|
||||||
code_ += "extern crate alloc;";
|
code_ += "extern crate alloc;";
|
||||||
}
|
}
|
||||||
@@ -3036,22 +3178,18 @@ class RustGenerator : public BaseGenerator {
|
|||||||
// Close cur_name_space in reverse order to reach the common prefix.
|
// Close cur_name_space in reverse order to reach the common prefix.
|
||||||
// In the previous example, D then C are closed.
|
// In the previous example, D then C are closed.
|
||||||
for (size_t j = old_size; j > common_prefix_size; --j) {
|
for (size_t j = old_size; j > common_prefix_size; --j) {
|
||||||
|
code_.DecrementIdentLevel();
|
||||||
code_ += "} // pub mod " + cur_name_space_->components[j - 1];
|
code_ += "} // pub mod " + cur_name_space_->components[j - 1];
|
||||||
}
|
}
|
||||||
if (old_size != common_prefix_size) {
|
|
||||||
code_ += "";
|
|
||||||
}
|
|
||||||
|
|
||||||
// open namespace parts to reach the ns namespace
|
// open namespace parts to reach the ns namespace
|
||||||
// in the previous example, E, then F, then G are opened
|
// in the previous example, E, then F, then G are opened
|
||||||
for (auto j = common_prefix_size; j != new_size; ++j) {
|
for (auto j = common_prefix_size; j != new_size; ++j) {
|
||||||
|
code_ += "";
|
||||||
code_ += "#[allow(unused_imports, dead_code)]";
|
code_ += "#[allow(unused_imports, dead_code)]";
|
||||||
code_ += "pub mod " + namer_.Namespace(ns->components[j]) + " {";
|
code_ += "pub mod " + namer_.Namespace(ns->components[j]) + " {";
|
||||||
// Generate local namespace imports.
|
code_.IncrementIdentLevel();
|
||||||
GenNamespaceImports(2);
|
GenNamespaceImports();
|
||||||
}
|
|
||||||
if (new_size != common_prefix_size) {
|
|
||||||
code_ += "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_name_space_ = ns;
|
cur_name_space_ = ns;
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
bool generate() {
|
bool generate() {
|
||||||
code_.Clear();
|
code_.Clear();
|
||||||
code_.SetValue("ACCESS", "_accessor");
|
code_.SetValue("ACCESS", "_accessor");
|
||||||
code_.SetValue("TABLEOFFSET", "VTOFFSET");
|
code_.SetValue("TABLEOFFSET", "VT");
|
||||||
code_ += "// " + std::string(FlatBuffersGeneratedWarning());
|
code_ += "// " + std::string(FlatBuffersGeneratedWarning());
|
||||||
code_ += "// swiftlint:disable all";
|
code_ += "// swiftlint:disable all";
|
||||||
code_ += "// swiftformat:disable all\n";
|
code_ += "// swiftformat:disable all\n";
|
||||||
@@ -282,9 +282,16 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
NumToString(field.value.type.VectorType().fixed_length);
|
NumToString(field.value.type.VectorType().fixed_length);
|
||||||
code_.SetValue("FIXEDLENGTH", fixed_length);
|
code_.SetValue("FIXEDLENGTH", fixed_length);
|
||||||
|
|
||||||
const auto vector_base_type = IsStruct(field.value.type.VectorType())
|
std::string vector_base_type;
|
||||||
? (type + "()")
|
if (IsStruct(field.value.type.VectorType())) {
|
||||||
: SwiftConstant(field);
|
vector_base_type = type + "()";
|
||||||
|
} else if (IsBool(field.value.type.VectorType().base_type)) {
|
||||||
|
vector_base_type = "false";
|
||||||
|
} else if (IsFloat(field.value.type.VectorType().base_type)) {
|
||||||
|
vector_base_type = "0.0";
|
||||||
|
} else {
|
||||||
|
vector_base_type = SwiftConstant(field);
|
||||||
|
}
|
||||||
code_ += "private var _{{FIELDVAR}}: InlineArray<{{FIXEDLENGTH}}, " +
|
code_ += "private var _{{FIELDVAR}}: InlineArray<{{FIXEDLENGTH}}, " +
|
||||||
valueType + ">";
|
valueType + ">";
|
||||||
|
|
||||||
@@ -518,7 +525,7 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
void GenTableAccessors(const StructDef& struct_def) {
|
void GenTableAccessors(const StructDef& struct_def) {
|
||||||
// Generate field id constants.
|
// Generate field id constants.
|
||||||
if (struct_def.fields.vec.size() > 0) {
|
if (struct_def.fields.vec.size() > 0) {
|
||||||
code_ += "private enum {{TABLEOFFSET}}: VOffset {";
|
code_ += "private struct {{TABLEOFFSET}} {";
|
||||||
Indent();
|
Indent();
|
||||||
for (auto it = struct_def.fields.vec.begin();
|
for (auto it = struct_def.fields.vec.begin();
|
||||||
it != struct_def.fields.vec.end(); ++it) {
|
it != struct_def.fields.vec.end(); ++it) {
|
||||||
@@ -528,10 +535,8 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
}
|
}
|
||||||
code_.SetValue("OFFSET_NAME", namer_.Variable(field));
|
code_.SetValue("OFFSET_NAME", namer_.Variable(field));
|
||||||
code_.SetValue("OFFSET_VALUE", NumToString(field.value.offset));
|
code_.SetValue("OFFSET_VALUE", NumToString(field.value.offset));
|
||||||
code_ += "case {{OFFSET_NAME}} = {{OFFSET_VALUE}}";
|
code_ += "static let {{OFFSET_NAME}}: VOffset = {{OFFSET_VALUE}}";
|
||||||
}
|
}
|
||||||
code_ += "var v: Int32 { Int32(self.rawValue) }";
|
|
||||||
code_ += "var p: VOffset { self.rawValue }";
|
|
||||||
Outdent();
|
Outdent();
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
code_ += "";
|
code_ += "";
|
||||||
@@ -620,7 +625,8 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
if (should_generate_create) {
|
if (should_generate_create) {
|
||||||
code_ += "{{ACCESS_TYPE}} static func create{{SHORT_STRUCTNAME}}(";
|
code_ += "{{ACCESS_TYPE}} static func create{{SHORT_STRUCTNAME}}(";
|
||||||
Indent();
|
Indent();
|
||||||
code_ += "_ fbb: inout FlatBufferBuilder,";
|
code_ += "_ fbb: inout FlatBufferBuilder\\";
|
||||||
|
if (create_func_header.empty() == false) code_ += ",";
|
||||||
for (auto it = create_func_header.begin(); it < create_func_header.end();
|
for (auto it = create_func_header.begin(); it < create_func_header.end();
|
||||||
++it) {
|
++it) {
|
||||||
code_ += *it + "\\";
|
code_ += *it + "\\";
|
||||||
@@ -699,7 +705,7 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
code_ += field.IsOptional() ? (optional_enum + "\\")
|
code_ += field.IsOptional() ? (optional_enum + "\\")
|
||||||
: (is_enum + ", def: {{CONSTANT}}\\");
|
: (is_enum + ", def: {{CONSTANT}}\\");
|
||||||
|
|
||||||
code_ += ", at: {{TABLEOFFSET}}.{{OFFSET}}.p) }";
|
code_ += ", at: {{TABLEOFFSET}}.{{OFFSET}}) }";
|
||||||
|
|
||||||
const auto default_value =
|
const auto default_value =
|
||||||
IsEnum(field.value.type)
|
IsEnum(field.value.type)
|
||||||
@@ -719,7 +725,7 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
code_ +=
|
code_ +=
|
||||||
"{{VALUETYPE}}" + builder_string + "fbb.add(element: {{FIELDVAR}},\\";
|
"{{VALUETYPE}}" + builder_string + "fbb.add(element: {{FIELDVAR}},\\";
|
||||||
code_ += field.IsOptional() ? "\\" : " def: {{CONSTANT}},";
|
code_ += field.IsOptional() ? "\\" : " def: {{CONSTANT}},";
|
||||||
code_ += " at: {{TABLEOFFSET}}.{{OFFSET}}.p) }";
|
code_ += " at: {{TABLEOFFSET}}.{{OFFSET}}) }";
|
||||||
create_func_header.push_back(
|
create_func_header.push_back(
|
||||||
field_var + ": " + nullable_type + " = " +
|
field_var + ": " + nullable_type + " = " +
|
||||||
(field.IsOptional() ? "nil" : default_value));
|
(field.IsOptional() ? "nil" : default_value));
|
||||||
@@ -730,7 +736,7 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
const auto create_struct =
|
const auto create_struct =
|
||||||
"guard let {{FIELDVAR}} = {{FIELDVAR}} else { return };"
|
"guard let {{FIELDVAR}} = {{FIELDVAR}} else { return };"
|
||||||
" fbb.create(struct: {{FIELDVAR}}, position: "
|
" fbb.create(struct: {{FIELDVAR}}, position: "
|
||||||
"{{TABLEOFFSET}}.{{OFFSET}}.p) }";
|
"{{TABLEOFFSET}}.{{OFFSET}}) }";
|
||||||
code_ += type + "?" + builder_string + create_struct;
|
code_ += type + "?" + builder_string + create_struct;
|
||||||
/// Optional hard coded since structs are always optional
|
/// Optional hard coded since structs are always optional
|
||||||
create_func_header.push_back(field_var + ": " + type +
|
create_func_header.push_back(field_var + ": " + type +
|
||||||
@@ -747,8 +753,9 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
(field.IsRequired() ? "" : " = Offset()"));
|
(field.IsRequired() ? "" : " = Offset()"));
|
||||||
const auto reader_type =
|
const auto reader_type =
|
||||||
IsStruct(field.value.type) && field.value.type.struct_def->fixed
|
IsStruct(field.value.type) && field.value.type.struct_def->fixed
|
||||||
? "structOffset: {{TABLEOFFSET}}.{{OFFSET}}.p) }"
|
? "structOffset: {{TABLEOFFSET}}.{{OFFSET}}) }"
|
||||||
: "offset: {{FIELDVAR}}, at: {{TABLEOFFSET}}.{{OFFSET}}.p) }";
|
: "offset: {{FIELDVAR}}, at: {{TABLEOFFSET}}.{{OFFSET}}) "
|
||||||
|
"}";
|
||||||
code_ += "Offset" + builder_string + "fbb.add(" + reader_type;
|
code_ += "Offset" + builder_string + "fbb.add(" + reader_type;
|
||||||
|
|
||||||
const auto vectortype = field.value.type.VectorType();
|
const auto vectortype = field.value.type.VectorType();
|
||||||
@@ -852,7 +859,10 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BASE_TYPE_STRING: {
|
case BASE_TYPE_STRING: {
|
||||||
const auto default_string = "\"" + SwiftConstant(field) + "\"";
|
const auto sc = SwiftConstant(field);
|
||||||
|
std::string default_string;
|
||||||
|
flatbuffers::EscapeString(sc.c_str(), sc.length(), &default_string,
|
||||||
|
true, false);
|
||||||
code_.SetValue("VALUETYPE", GenType(field.value.type));
|
code_.SetValue("VALUETYPE", GenType(field.value.type));
|
||||||
code_.SetValue("CONSTANT", field.IsDefault() ? default_string : "nil");
|
code_.SetValue("CONSTANT", field.IsDefault() ? default_string : "nil");
|
||||||
code_ += GenReaderMainBody(is_required) + GenOffset() +
|
code_ += GenReaderMainBody(is_required) + GenOffset() +
|
||||||
@@ -860,7 +870,7 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
code_ += "{{ACCESS_TYPE}} var {{FIELDVAR}}SegmentArray: [UInt8]" +
|
code_ += "{{ACCESS_TYPE}} var {{FIELDVAR}}SegmentArray: [UInt8]" +
|
||||||
is_required +
|
is_required +
|
||||||
" { return "
|
" { return "
|
||||||
"{{ACCESS}}.getVector(at: {{TABLEOFFSET}}.{{OFFSET}}.v) }";
|
"{{ACCESS}}.getVector(at: {{TABLEOFFSET}}.{{OFFSET}}) }";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BASE_TYPE_ARRAY:
|
case BASE_TYPE_ARRAY:
|
||||||
@@ -894,7 +904,7 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
code_ +=
|
code_ +=
|
||||||
"{{ACCESS_TYPE}} var {{FIELDVAR}}: "
|
"{{ACCESS_TYPE}} var {{FIELDVAR}}: "
|
||||||
"FlatbufferVector<{{VALUETYPE}}> "
|
"FlatbufferVector<{{VALUETYPE}}> "
|
||||||
"{ return {{ACCESS}}.vector(at: {{TABLEOFFSET}}.{{OFFSET}}.v, "
|
"{ return {{ACCESS}}.vector(at: {{TABLEOFFSET}}.{{OFFSET}}, "
|
||||||
"byteSize: {{SIZE}}) }";
|
"byteSize: {{SIZE}}) }";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -911,7 +921,7 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
code_ +=
|
code_ +=
|
||||||
"{{ACCESS_TYPE}} var {{FIELDVAR}}: "
|
"{{ACCESS_TYPE}} var {{FIELDVAR}}: "
|
||||||
"FlatbufferVector<{{VALUETYPE}}_Mutable> "
|
"FlatbufferVector<{{VALUETYPE}}_Mutable> "
|
||||||
"{ return {{ACCESS}}.vector(at: {{TABLEOFFSET}}.{{OFFSET}}.v, "
|
"{ return {{ACCESS}}.vector(at: {{TABLEOFFSET}}.{{OFFSET}}, "
|
||||||
"byteSize: {{SIZE}}) }";
|
"byteSize: {{SIZE}}) }";
|
||||||
GenUnsafeBufferPointer(field);
|
GenUnsafeBufferPointer(field);
|
||||||
return;
|
return;
|
||||||
@@ -920,7 +930,8 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
if (vectortype.base_type == BASE_TYPE_UNION) {
|
if (vectortype.base_type == BASE_TYPE_UNION) {
|
||||||
code_ +=
|
code_ +=
|
||||||
"{{ACCESS_TYPE}} var {{FIELDVAR}}: UnionFlatbufferVector "
|
"{{ACCESS_TYPE}} var {{FIELDVAR}}: UnionFlatbufferVector "
|
||||||
"{ return {{ACCESS}}.unionVector(at: {{TABLEOFFSET}}.{{OFFSET}}.v, "
|
"{ return {{ACCESS}}.unionVector(at: "
|
||||||
|
"{{TABLEOFFSET}}.{{OFFSET}}, "
|
||||||
"byteSize: {{SIZE}}) }";
|
"byteSize: {{SIZE}}) }";
|
||||||
code_ +=
|
code_ +=
|
||||||
"{{ACCESS_TYPE}} func {{FIELDVAR}}<T: FlatbuffersInitializable>(at "
|
"{{ACCESS_TYPE}} func {{FIELDVAR}}<T: FlatbuffersInitializable>(at "
|
||||||
@@ -954,24 +965,21 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
"{{ACCESS_TYPE}} func {{functionName}}<T>(_ body: "
|
"{{ACCESS_TYPE}} func {{functionName}}<T>(_ body: "
|
||||||
"(UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T? { return "
|
"(UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T? { return "
|
||||||
"try "
|
"try "
|
||||||
"{{ACCESS}}.withUnsafePointerToSlice(at: {{TABLEOFFSET}}.{{OFFSET}}.v, "
|
"{{ACCESS}}.withUnsafePointerToSlice(at: "
|
||||||
|
"{{TABLEOFFSET}}.{{OFFSET}}, "
|
||||||
"body: body) }";
|
"body: body) }";
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenerateCodingKeys(const StructDef& struct_def) {
|
std::vector<std::string> GenerateCodingKeys(const StructDef& struct_def) {
|
||||||
code_ += "enum CodingKeys: String, CodingKey {";
|
std::vector<std::string> coding_keys;
|
||||||
Indent();
|
|
||||||
for (auto it = struct_def.fields.vec.begin();
|
for (auto it = struct_def.fields.vec.begin();
|
||||||
it != struct_def.fields.vec.end(); ++it) {
|
it != struct_def.fields.vec.end(); ++it) {
|
||||||
const auto& field = **it;
|
const auto& field = **it;
|
||||||
if (field.deprecated) continue;
|
if (field.deprecated) continue;
|
||||||
|
coding_keys.push_back("case " + namer_.Variable(field) + " = \"" +
|
||||||
code_.SetValue("RAWVALUENAME", field.name);
|
field.name + "\"");
|
||||||
code_.SetValue("FIELDVAR", namer_.Variable(field));
|
|
||||||
code_ += "case {{FIELDVAR}} = \"{{RAWVALUENAME}}\"";
|
|
||||||
}
|
}
|
||||||
Outdent();
|
return coding_keys;
|
||||||
code_ += "}";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenerateEncoderUnionBody(const FieldDef& field) {
|
void GenerateEncoderUnionBody(const FieldDef& field) {
|
||||||
@@ -1093,14 +1101,31 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
GenOSVersionChecks();
|
GenOSVersionChecks();
|
||||||
code_ += "extension {{STRUCTNAME}}: Encodable {";
|
code_ += "extension {{STRUCTNAME}}: Encodable {";
|
||||||
Indent();
|
Indent();
|
||||||
code_ += "";
|
auto coding_keys = GenerateCodingKeys(struct_def);
|
||||||
if (struct_def.fields.vec.empty() == false) GenerateCodingKeys(struct_def);
|
|
||||||
|
|
||||||
code_ += "{{ACCESS_TYPE}} func encode(to encoder: Encoder) throws {";
|
if (coding_keys.empty() == false) {
|
||||||
|
code_ += "enum CodingKeys: String, CodingKey {";
|
||||||
Indent();
|
Indent();
|
||||||
if (struct_def.fields.vec.empty() == false) GenerateEncoderBody(struct_def);
|
for (auto it = coding_keys.begin(); it != coding_keys.end(); ++it) {
|
||||||
|
const auto& field = *it;
|
||||||
|
code_ += field;
|
||||||
|
}
|
||||||
Outdent();
|
Outdent();
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
|
|
||||||
|
code_ += "";
|
||||||
|
}
|
||||||
|
|
||||||
|
code_ += "{{ACCESS_TYPE}} func encode(to encoder: Encoder) throws {";
|
||||||
|
|
||||||
|
if (coding_keys.empty() == false) {
|
||||||
|
Indent();
|
||||||
|
GenerateEncoderBody(struct_def);
|
||||||
|
Outdent();
|
||||||
|
}
|
||||||
|
|
||||||
|
code_ += "}";
|
||||||
|
|
||||||
Outdent();
|
Outdent();
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
code_ += "";
|
code_ += "";
|
||||||
@@ -1130,7 +1155,7 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
code_ +=
|
code_ +=
|
||||||
"try _v.visit(field: {{TABLEOFFSET}}.{{OFFSET}}.p, fieldName: "
|
"try _v.visit(field: {{TABLEOFFSET}}.{{OFFSET}}, fieldName: "
|
||||||
"\"{{FIELDVAR}}\", required: {{ISREQUIRED}}, type: "
|
"\"{{FIELDVAR}}\", required: {{ISREQUIRED}}, type: "
|
||||||
"{{VALUETYPE}}.self)";
|
"{{VALUETYPE}}.self)";
|
||||||
}
|
}
|
||||||
@@ -1150,8 +1175,9 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
code_.SetValue("VALUETYPE", namer_.NamespacedType(union_def));
|
code_.SetValue("VALUETYPE", namer_.NamespacedType(union_def));
|
||||||
code_.SetValue("FUNCTION_NAME", is_vector ? "visitUnionVector" : "visit");
|
code_.SetValue("FUNCTION_NAME", is_vector ? "visitUnionVector" : "visit");
|
||||||
code_ +=
|
code_ +=
|
||||||
"try _v.{{FUNCTION_NAME}}(unionKey: {{TABLEOFFSET}}.{{OFFSET}}Type.p, "
|
"try _v.{{FUNCTION_NAME}}(unionKey: "
|
||||||
"unionField: {{TABLEOFFSET}}.{{OFFSET}}.p, unionKeyName: "
|
"{{TABLEOFFSET}}.{{OFFSET}}Type, "
|
||||||
|
"unionField: {{TABLEOFFSET}}.{{OFFSET}}, unionKeyName: "
|
||||||
"\"{{FIELDVAR}}Type\", fieldName: \"{{FIELDVAR}}\", required: "
|
"\"{{FIELDVAR}}Type\", fieldName: \"{{FIELDVAR}}\", required: "
|
||||||
"{{ISREQUIRED}}, completion: { (verifier, key: {{VALUETYPE}}, pos) in";
|
"{{ISREQUIRED}}, completion: { (verifier, key: {{VALUETYPE}}, pos) in";
|
||||||
Indent();
|
Indent();
|
||||||
@@ -1626,15 +1652,23 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
buffer_constructor.push_back(field_var + " = _t." + field_field);
|
buffer_constructor.push_back(field_var + " = _t." + field_field);
|
||||||
|
|
||||||
if (field.IsRequired()) {
|
if (field.IsRequired()) {
|
||||||
std::string default_value =
|
std::string default_value;
|
||||||
field.IsDefault() ? SwiftConstant(field) : "";
|
if (field.IsDefault()) {
|
||||||
base_constructor.push_back(field_var + " = \"" + default_value +
|
const auto sc = SwiftConstant(field);
|
||||||
"\"");
|
flatbuffers::EscapeString(sc.c_str(), sc.length(), &default_value,
|
||||||
|
true, false);
|
||||||
|
} else {
|
||||||
|
default_value = "\"\"";
|
||||||
|
}
|
||||||
|
base_constructor.push_back(field_var + " = " + default_value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (field.IsDefault() && !field.IsRequired()) {
|
if (field.IsDefault() && !field.IsRequired()) {
|
||||||
std::string value = field.IsDefault() ? SwiftConstant(field) : "nil";
|
const auto sc = SwiftConstant(field);
|
||||||
base_constructor.push_back(field_var + " = \"" + value + "\"");
|
std::string value;
|
||||||
|
flatbuffers::EscapeString(sc.c_str(), sc.length(), &value,
|
||||||
|
true, false);
|
||||||
|
base_constructor.push_back(field_var + " = " + value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1893,7 +1927,7 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string GenOffset() {
|
std::string GenOffset() {
|
||||||
return "let o = {{ACCESS}}.offset({{TABLEOFFSET}}.{{OFFSET}}.v); ";
|
return "let o = {{ACCESS}}.offset({{TABLEOFFSET}}.{{OFFSET}}); ";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GenReaderMainBody(const std::string& optional = "") {
|
std::string GenReaderMainBody(const std::string& optional = "") {
|
||||||
|
|||||||
@@ -324,11 +324,12 @@ class TsGenerator : public BaseGenerator {
|
|||||||
export_counter++;
|
export_counter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (export_counter > 0)
|
if (export_counter > 0) {
|
||||||
parser_.opts.file_saver->SaveFile(it.second.filepath.c_str(), code,
|
parser_.opts.file_saver->SaveFile(it.second.filepath.c_str(), code,
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Generate a documentation comment, if available.
|
// Generate a documentation comment, if available.
|
||||||
static void GenDocComment(const std::vector<std::string>& dc,
|
static void GenDocComment(const std::vector<std::string>& dc,
|
||||||
@@ -521,7 +522,20 @@ class TsGenerator : public BaseGenerator {
|
|||||||
case BASE_TYPE_BOOL:
|
case BASE_TYPE_BOOL:
|
||||||
return value.constant == "0" ? "false" : "true";
|
return value.constant == "0" ? "false" : "true";
|
||||||
|
|
||||||
case BASE_TYPE_STRING:
|
case BASE_TYPE_STRING: {
|
||||||
|
// NOTE: Strings without a default value are parsed as "0" by
|
||||||
|
// the parser, so therefore we have to treat "0" as a null-signifying
|
||||||
|
// value.
|
||||||
|
if (value.constant == "0" || value.constant == "null") {
|
||||||
|
return "null";
|
||||||
|
} else {
|
||||||
|
std::string escaped;
|
||||||
|
flatbuffers::EscapeString(value.constant.c_str(),
|
||||||
|
value.constant.length(), &escaped,
|
||||||
|
true, false);
|
||||||
|
return escaped;
|
||||||
|
}
|
||||||
|
}
|
||||||
case BASE_TYPE_UNION:
|
case BASE_TYPE_UNION:
|
||||||
case BASE_TYPE_STRUCT: {
|
case BASE_TYPE_STRUCT: {
|
||||||
return null_keyword_;
|
return null_keyword_;
|
||||||
@@ -647,7 +661,8 @@ class TsGenerator : public BaseGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GenStructArgs(import_set& imports, const StructDef& struct_def,
|
void GenStructArgs(import_set& imports, const StructDef& struct_def,
|
||||||
std::string* arguments, const std::string& nameprefix) {
|
const Definition& owner, std::string* arguments,
|
||||||
|
const std::string& nameprefix) {
|
||||||
for (auto it = struct_def.fields.vec.begin();
|
for (auto it = struct_def.fields.vec.begin();
|
||||||
it != struct_def.fields.vec.end(); ++it) {
|
it != struct_def.fields.vec.end(); ++it) {
|
||||||
auto& field = **it;
|
auto& field = **it;
|
||||||
@@ -655,11 +670,11 @@ class TsGenerator : public BaseGenerator {
|
|||||||
// Generate arguments for a struct inside a struct. To ensure names
|
// Generate arguments for a struct inside a struct. To ensure names
|
||||||
// don't clash, and to make it obvious these arguments are constructing
|
// don't clash, and to make it obvious these arguments are constructing
|
||||||
// a nested struct, prefix the name with the field name.
|
// a nested struct, prefix the name with the field name.
|
||||||
GenStructArgs(imports, *field.value.type.struct_def, arguments,
|
GenStructArgs(imports, *field.value.type.struct_def, owner, arguments,
|
||||||
nameprefix + field.name + "_");
|
nameprefix + field.name + "_");
|
||||||
} else {
|
} else {
|
||||||
*arguments += ", " + nameprefix + field.name + ": " +
|
*arguments += ", " + nameprefix + field.name + ": " +
|
||||||
GenTypeName(imports, field, field.value.type, true,
|
GenTypeName(imports, owner, field.value.type, true,
|
||||||
field.IsOptional());
|
field.IsOptional());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -921,6 +936,48 @@ class TsGenerator : public BaseGenerator {
|
|||||||
return symbols_expression;
|
return symbols_expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> PathComponents(const std::string& path) const {
|
||||||
|
std::vector<std::string> components;
|
||||||
|
size_t start = 0;
|
||||||
|
while (start < path.size()) {
|
||||||
|
auto end = path.find(kPathSeparator, start);
|
||||||
|
if (end == std::string::npos) end = path.size();
|
||||||
|
if (end > start) {
|
||||||
|
components.emplace_back(path.substr(start, end - start));
|
||||||
|
}
|
||||||
|
if (end == path.size()) break;
|
||||||
|
start = end + 1;
|
||||||
|
}
|
||||||
|
return components;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string RelativeDirectory(const std::vector<std::string>& from,
|
||||||
|
const std::vector<std::string>& to) const {
|
||||||
|
size_t common = 0;
|
||||||
|
while (common < from.size() && common < to.size() &&
|
||||||
|
from[common] == to[common]) {
|
||||||
|
++common;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string rel;
|
||||||
|
const size_t ups = from.size() - common;
|
||||||
|
if (ups == 0) {
|
||||||
|
rel = ".";
|
||||||
|
} else {
|
||||||
|
for (size_t i = 0; i < ups; ++i) {
|
||||||
|
if (!rel.empty()) rel += kPathSeparator;
|
||||||
|
rel += "..";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = common; i < to.size(); ++i) {
|
||||||
|
if (!rel.empty()) rel += kPathSeparator;
|
||||||
|
rel += to[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return rel;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename DefinitionT>
|
template <typename DefinitionT>
|
||||||
ImportDefinition AddImport(import_set& imports, const Definition& dependent,
|
ImportDefinition AddImport(import_set& imports, const Definition& dependent,
|
||||||
const DefinitionT& dependency) {
|
const DefinitionT& dependency) {
|
||||||
@@ -948,26 +1005,32 @@ class TsGenerator : public BaseGenerator {
|
|||||||
const std::string symbols_expression = GenSymbolExpression(
|
const std::string symbols_expression = GenSymbolExpression(
|
||||||
dependency, has_name_clash, import_name, name, object_name);
|
dependency, has_name_clash, import_name, name, object_name);
|
||||||
|
|
||||||
std::string bare_file_path;
|
const Namespace* dependent_ns = dependent.defined_namespace
|
||||||
std::string rel_file_path;
|
? dependent.defined_namespace
|
||||||
if (dependent.defined_namespace) {
|
: parser_.empty_namespace_;
|
||||||
const auto& dep_comps = dependent.defined_namespace->components;
|
const Namespace* dependency_ns = dependency.defined_namespace
|
||||||
for (size_t i = 0; i < dep_comps.size(); i++) {
|
? dependency.defined_namespace
|
||||||
rel_file_path += i == 0 ? ".." : (kPathSeparator + std::string(".."));
|
: parser_.empty_namespace_;
|
||||||
}
|
|
||||||
if (dep_comps.size() == 0) {
|
|
||||||
rel_file_path += ".";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
rel_file_path += "..";
|
|
||||||
}
|
|
||||||
|
|
||||||
bare_file_path +=
|
const std::string dependent_dirs =
|
||||||
kPathSeparator +
|
namer_.Directories(*dependent_ns, SkipDir::OutputPath);
|
||||||
namer_.Directories(dependency.defined_namespace->components,
|
const std::string dependency_dirs =
|
||||||
SkipDir::OutputPath) +
|
namer_.Directories(*dependency_ns, SkipDir::OutputPath);
|
||||||
|
|
||||||
|
const auto dependent_components = PathComponents(dependent_dirs);
|
||||||
|
const auto dependency_components = PathComponents(dependency_dirs);
|
||||||
|
|
||||||
|
std::string rel_dir =
|
||||||
|
RelativeDirectory(dependent_components, dependency_components);
|
||||||
|
if (rel_dir.empty()) rel_dir = ".";
|
||||||
|
if (!rel_dir.empty()) rel_dir += kPathSeparator;
|
||||||
|
|
||||||
|
std::string rel_file_path =
|
||||||
|
rel_dir + namer_.File(dependency, SkipFile::SuffixAndExtension);
|
||||||
|
|
||||||
|
std::string bare_file_path =
|
||||||
|
kPathSeparator + dependency_dirs +
|
||||||
namer_.File(dependency, SkipFile::SuffixAndExtension);
|
namer_.File(dependency, SkipFile::SuffixAndExtension);
|
||||||
rel_file_path += bare_file_path;
|
|
||||||
|
|
||||||
ImportDefinition import;
|
ImportDefinition import;
|
||||||
import.name = name;
|
import.name = name;
|
||||||
@@ -1172,9 +1235,10 @@ class TsGenerator : public BaseGenerator {
|
|||||||
|
|
||||||
std::string GenNullCheckConditional(const std::string& nullCheckVar,
|
std::string GenNullCheckConditional(const std::string& nullCheckVar,
|
||||||
const std::string& trueVal,
|
const std::string& trueVal,
|
||||||
const std::string& falseVal) {
|
const std::string& falseVal = "") {
|
||||||
|
std::string false_val = falseVal.empty() ? null_keyword_ : falseVal;
|
||||||
return "(" + nullCheckVar + " !== " + null_keyword_ + " ? " + trueVal +
|
return "(" + nullCheckVar + " !== " + null_keyword_ + " ? " + trueVal +
|
||||||
" : " + falseVal + ")";
|
" : " + false_val + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GenStructMemberValueTS(const StructDef& struct_def,
|
std::string GenStructMemberValueTS(const StructDef& struct_def,
|
||||||
@@ -1283,10 +1347,9 @@ class TsGenerator : public BaseGenerator {
|
|||||||
// Emit a scalar field
|
// Emit a scalar field
|
||||||
const auto is_string = IsString(field.value.type);
|
const auto is_string = IsString(field.value.type);
|
||||||
if (IsScalar(field.value.type.base_type) || is_string) {
|
if (IsScalar(field.value.type.base_type) || is_string) {
|
||||||
const auto has_null_default = is_string || HasNullDefault(field);
|
field_type +=
|
||||||
|
GenTypeName(imports, field, field.value.type, false,
|
||||||
field_type += GenTypeName(imports, field, field.value.type, false,
|
!HasDefaultValue(field) || HasNullDefault(field));
|
||||||
has_null_default);
|
|
||||||
field_val = "this." + namer_.Method(field) + "()";
|
field_val = "this." + namer_.Method(field) + "()";
|
||||||
|
|
||||||
if (field.value.type.base_type != BASE_TYPE_STRING) {
|
if (field.value.type.base_type != BASE_TYPE_STRING) {
|
||||||
@@ -1632,11 +1695,12 @@ class TsGenerator : public BaseGenerator {
|
|||||||
GenDocComment(struct_def.doc_comment, code_ptr);
|
GenDocComment(struct_def.doc_comment, code_ptr);
|
||||||
code += "export class ";
|
code += "export class ";
|
||||||
code += object_name;
|
code += object_name;
|
||||||
if (parser.opts.generate_object_based_api)
|
if (parser.opts.generate_object_based_api) {
|
||||||
code += " implements flatbuffers.IUnpackableObject<" + object_api_name +
|
code += " implements flatbuffers.IUnpackableObject<" + object_api_name +
|
||||||
"> {\n";
|
"> {\n";
|
||||||
else
|
} else {
|
||||||
code += " {\n";
|
code += " {\n";
|
||||||
|
}
|
||||||
code += " bb: flatbuffers.ByteBuffer|" + null_keyword_ + " = " +
|
code += " bb: flatbuffers.ByteBuffer|" + null_keyword_ + " = " +
|
||||||
null_keyword_ + ";\n";
|
null_keyword_ + ";\n";
|
||||||
code += " bb_pos = 0;\n";
|
code += " bb_pos = 0;\n";
|
||||||
@@ -1679,21 +1743,22 @@ class TsGenerator : public BaseGenerator {
|
|||||||
offset_prefix = " const offset = " + GenBBAccess() +
|
offset_prefix = " const offset = " + GenBBAccess() +
|
||||||
".__offset(this.bb_pos, " +
|
".__offset(this.bb_pos, " +
|
||||||
NumToString(field.value.offset) + ");\n";
|
NumToString(field.value.offset) + ");\n";
|
||||||
offset_prefix += " return offset ? ";
|
offset_prefix += " return ";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit a scalar field
|
// Emit a scalar field
|
||||||
const auto is_string = IsString(field.value.type);
|
const auto is_string = IsString(field.value.type);
|
||||||
if (IsScalar(field.value.type.base_type) || is_string) {
|
if (IsScalar(field.value.type.base_type) || is_string) {
|
||||||
const auto has_null_default = is_string || HasNullDefault(field);
|
const auto has_null_default =
|
||||||
|
!field.IsRequired() && !HasDefaultValue(field);
|
||||||
|
|
||||||
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_keyword_ + "\n";
|
code += prefix + "):" + (has_null_default ? "string|" + null_keyword_ : "string") + "\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, has_null_default) +
|
||||||
"\n";
|
"\n";
|
||||||
code += prefix + "optionalEncoding?:any";
|
code += prefix + "optionalEncoding?:any";
|
||||||
} else {
|
} else {
|
||||||
@@ -1722,9 +1787,16 @@ class TsGenerator : public BaseGenerator {
|
|||||||
if (is_string) {
|
if (is_string) {
|
||||||
index += ", optionalEncoding";
|
index += ", optionalEncoding";
|
||||||
}
|
}
|
||||||
|
if (field.IsRequired()) {
|
||||||
code +=
|
code +=
|
||||||
offset_prefix + GenGetter(field.value.type, "(" + index + ")");
|
offset_prefix + GenGetter(field.value.type, "(" + index + ")");
|
||||||
if (field.value.type.base_type != BASE_TYPE_ARRAY) {
|
;
|
||||||
|
} else {
|
||||||
|
code += offset_prefix + "offset ? " +
|
||||||
|
GenGetter(field.value.type, "(" + index + ")");
|
||||||
|
}
|
||||||
|
if (field.value.type.base_type != BASE_TYPE_ARRAY &&
|
||||||
|
!field.IsRequired()) {
|
||||||
code += " : " + GenDefaultValue(field, imports);
|
code += " : " + GenDefaultValue(field, imports);
|
||||||
}
|
}
|
||||||
code += ";\n";
|
code += ";\n";
|
||||||
@@ -1749,8 +1821,8 @@ class TsGenerator : public BaseGenerator {
|
|||||||
code +=
|
code +=
|
||||||
MaybeAdd(field.value.offset) + ", " + GenBBAccess() + ");\n";
|
MaybeAdd(field.value.offset) + ", " + GenBBAccess() + ");\n";
|
||||||
} else {
|
} else {
|
||||||
code += offset_prefix + "(obj || " + GenerateNewExpression(type) +
|
code += offset_prefix + "offset ? (obj || " +
|
||||||
").__init(";
|
GenerateNewExpression(type) + ").__init(";
|
||||||
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)";
|
||||||
@@ -1908,7 +1980,7 @@ class TsGenerator : public BaseGenerator {
|
|||||||
code += "):" + vectortypename + "|" + null_keyword_ + " {\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 + "offset ? (obj || " +
|
||||||
GenerateNewExpression(vectortypename);
|
GenerateNewExpression(vectortypename);
|
||||||
code += ").__init(";
|
code += ").__init(";
|
||||||
code += vectortype.struct_def->fixed
|
code += vectortype.struct_def->fixed
|
||||||
@@ -1921,7 +1993,8 @@ class TsGenerator : public BaseGenerator {
|
|||||||
} else if (IsString(vectortype)) {
|
} else if (IsString(vectortype)) {
|
||||||
index += ", optionalEncoding";
|
index += ", optionalEncoding";
|
||||||
}
|
}
|
||||||
code += offset_prefix + GenGetter(vectortype, "(" + index + ")");
|
code += offset_prefix + "offset ? " +
|
||||||
|
GenGetter(vectortype, "(" + index + ")");
|
||||||
}
|
}
|
||||||
code += " : ";
|
code += " : ";
|
||||||
if (field.value.type.element == BASE_TYPE_BOOL) {
|
if (field.value.type.element == BASE_TYPE_BOOL) {
|
||||||
@@ -1953,7 +2026,7 @@ class TsGenerator : public BaseGenerator {
|
|||||||
" "
|
" "
|
||||||
"{\n";
|
"{\n";
|
||||||
|
|
||||||
code += offset_prefix +
|
code += offset_prefix + "offset ? " +
|
||||||
GenGetter(field.value.type, "(obj, this.bb_pos + offset)") +
|
GenGetter(field.value.type, "(obj, this.bb_pos + offset)") +
|
||||||
" : " + null_keyword_ + ";\n";
|
" : " + null_keyword_ + ";\n";
|
||||||
break;
|
break;
|
||||||
@@ -2006,7 +2079,7 @@ class TsGenerator : public BaseGenerator {
|
|||||||
// Emit a length helper
|
// Emit a length helper
|
||||||
GenDocComment(code_ptr);
|
GenDocComment(code_ptr);
|
||||||
code += namer_.Method(field, "Length");
|
code += namer_.Method(field, "Length");
|
||||||
code += "():number {\n" + offset_prefix;
|
code += "():number {\n" + offset_prefix + "offset ? ";
|
||||||
|
|
||||||
code +=
|
code +=
|
||||||
GenBBAccess() + ".__vector_len(this.bb_pos + offset) : 0;\n}\n\n";
|
GenBBAccess() + ".__vector_len(this.bb_pos + offset) : 0;\n}\n\n";
|
||||||
@@ -2017,18 +2090,33 @@ class TsGenerator : public BaseGenerator {
|
|||||||
GenDocComment(code_ptr);
|
GenDocComment(code_ptr);
|
||||||
|
|
||||||
code += namer_.Method(field, "Array");
|
code += namer_.Method(field, "Array");
|
||||||
code += "():" + GenType(vectorType) + "Array|" + null_keyword_ +
|
|
||||||
" {\n" + offset_prefix;
|
|
||||||
|
|
||||||
code += "new " + GenType(vectorType) + "Array(" + GenBBAccess() +
|
std::string return_type =
|
||||||
".bytes().buffer, " + GenBBAccess() +
|
(field.IsRequired() || HasDefaultValue(field))
|
||||||
|
? "Array"
|
||||||
|
: ("Array|" + null_keyword_);
|
||||||
|
if (field.IsRequired()) {
|
||||||
|
code += "():" + GenType(vectorType) + return_type + " {\n" +
|
||||||
|
offset_prefix + "new " + GenType(vectorType) + "Array(" +
|
||||||
|
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_keyword_ +
|
".__vector_len(this.bb_pos + offset));\n}\n\n";
|
||||||
|
} else {
|
||||||
|
std::string value = HasDefaultValue(field)
|
||||||
|
? "new " + GenType(vectorType) + "Array()"
|
||||||
|
: "null";
|
||||||
|
code += "():" + GenType(vectorType) + return_type + " {\n" +
|
||||||
|
offset_prefix + "offset ? new " + GenType(vectorType) +
|
||||||
|
"Array(" + GenBBAccess() + ".bytes().buffer, " +
|
||||||
|
GenBBAccess() + ".bytes().byteOffset + " + GenBBAccess() +
|
||||||
|
".__vector(this.bb_pos + offset), " + GenBBAccess() +
|
||||||
|
".__vector_len(this.bb_pos + offset)) : " + value +
|
||||||
";\n}\n\n";
|
";\n}\n\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Emit the fully qualified name
|
// Emit the fully qualified name
|
||||||
if (parser_.opts.generate_name_strings) {
|
if (parser_.opts.generate_name_strings) {
|
||||||
@@ -2054,7 +2142,7 @@ class TsGenerator : public BaseGenerator {
|
|||||||
// Emit a factory constructor
|
// Emit a factory constructor
|
||||||
if (struct_def.fixed) {
|
if (struct_def.fixed) {
|
||||||
std::string arguments;
|
std::string arguments;
|
||||||
GenStructArgs(imports, struct_def, &arguments, "");
|
GenStructArgs(imports, struct_def, struct_def, &arguments, "");
|
||||||
GenDocComment(code_ptr);
|
GenDocComment(code_ptr);
|
||||||
|
|
||||||
code += "static create" + GetPrefixedName(struct_def) +
|
code += "static create" + GetPrefixedName(struct_def) +
|
||||||
@@ -2256,6 +2344,34 @@ class TsGenerator : public BaseGenerator {
|
|||||||
return field.IsOptional() && field.value.constant == "null";
|
return field.IsOptional() && field.value.constant == "null";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool HasDefaultValue(const FieldDef& field) {
|
||||||
|
switch (field.value.type.base_type) {
|
||||||
|
// These types can't have defaults
|
||||||
|
case BASE_TYPE_UNION:
|
||||||
|
case BASE_TYPE_STRUCT: {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Arrays always have a default (empty array)
|
||||||
|
case BASE_TYPE_ARRAY:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// The only supported default for vectors is []
|
||||||
|
case BASE_TYPE_VECTOR:
|
||||||
|
return field.value.constant == "[]";
|
||||||
|
|
||||||
|
// Even strings are presumed to be null-default if the default value is
|
||||||
|
// "0", this is intended behavior.
|
||||||
|
case BASE_TYPE_STRING: {
|
||||||
|
return field.value.constant != "0" && field.value.constant != "null";
|
||||||
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
return field.value.constant != "null";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::string GetArgType(import_set& imports, const Definition& owner,
|
std::string GetArgType(import_set& imports, const Definition& owner,
|
||||||
const FieldDef& field, bool allowNull) {
|
const FieldDef& field, bool allowNull) {
|
||||||
return GenTypeName(imports, owner, field.value.type, true,
|
return GenTypeName(imports, owner, field.value.type, true,
|
||||||
|
|||||||
@@ -2809,7 +2809,8 @@ bool Parser::SupportsOptionalScalars() const {
|
|||||||
bool Parser::SupportsDefaultVectorsAndStrings() const {
|
bool Parser::SupportsDefaultVectorsAndStrings() const {
|
||||||
static FLATBUFFERS_CONSTEXPR unsigned long supported_langs =
|
static FLATBUFFERS_CONSTEXPR unsigned long supported_langs =
|
||||||
IDLOptions::kRust | IDLOptions::kSwift | IDLOptions::kNim |
|
IDLOptions::kRust | IDLOptions::kSwift | IDLOptions::kNim |
|
||||||
IDLOptions::kCpp | IDLOptions::kBinary | IDLOptions::kJson;
|
IDLOptions::kCpp | IDLOptions::kBinary | IDLOptions::kJson |
|
||||||
|
IDLOptions::kTs;
|
||||||
return !(opts.lang_to_generate & ~supported_langs);
|
return !(opts.lang_to_generate & ~supported_langs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3171,8 +3172,10 @@ CheckedError Parser::ParseProtoFields(StructDef* struct_def, bool isextend,
|
|||||||
return Error("Protobuf has non positive number in reserved ids");
|
return Error("Protobuf has non positive number in reserved ids");
|
||||||
|
|
||||||
if (range) {
|
if (range) {
|
||||||
for (voffset_t id = from + 1; id <= attribute; id++)
|
for (uint32_t id = static_cast<uint32_t>(from) + 1;
|
||||||
struct_def->reserved_ids.push_back(id);
|
id <= static_cast<uint32_t>(attribute); id++) {
|
||||||
|
struct_def->reserved_ids.push_back(static_cast<voffset_t>(id));
|
||||||
|
}
|
||||||
|
|
||||||
range = false;
|
range = false;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -641,7 +641,10 @@ const uint8_t* AddFlatBuffer(std::vector<uint8_t>& flatbuf,
|
|||||||
const uint8_t* newbuf, size_t newlen) {
|
const uint8_t* newbuf, size_t newlen) {
|
||||||
// Align to sizeof(uoffset_t) past sizeof(largest_scalar_t) since we're
|
// Align to sizeof(uoffset_t) past sizeof(largest_scalar_t) since we're
|
||||||
// going to chop off the root offset.
|
// going to chop off the root offset.
|
||||||
|
if (!newbuf || newlen < sizeof(uoffset_t)) return nullptr;
|
||||||
FLATBUFFERS_ASSERT(newlen >= sizeof(uoffset_t));
|
FLATBUFFERS_ASSERT(newlen >= sizeof(uoffset_t));
|
||||||
|
auto root = ReadScalar<uoffset_t>(newbuf);
|
||||||
|
if (root < sizeof(uoffset_t) || root >= newlen) return nullptr;
|
||||||
while ((flatbuf.size() & (sizeof(uoffset_t) - 1)) ||
|
while ((flatbuf.size() & (sizeof(uoffset_t) - 1)) ||
|
||||||
!(flatbuf.size() & (sizeof(largest_scalar_t) - 1))) {
|
!(flatbuf.size() & (sizeof(largest_scalar_t) - 1))) {
|
||||||
flatbuf.push_back(0);
|
flatbuf.push_back(0);
|
||||||
@@ -649,7 +652,7 @@ const uint8_t* AddFlatBuffer(std::vector<uint8_t>& flatbuf,
|
|||||||
auto insertion_point = static_cast<uoffset_t>(flatbuf.size());
|
auto insertion_point = static_cast<uoffset_t>(flatbuf.size());
|
||||||
// Insert the entire FlatBuffer minus the root pointer.
|
// Insert the entire FlatBuffer minus the root pointer.
|
||||||
flatbuf.insert(flatbuf.end(), newbuf + sizeof(uoffset_t), newbuf + newlen);
|
flatbuf.insert(flatbuf.end(), newbuf + sizeof(uoffset_t), newbuf + newlen);
|
||||||
auto root_offset = ReadScalar<uoffset_t>(newbuf) - sizeof(uoffset_t);
|
auto root_offset = root - sizeof(uoffset_t);
|
||||||
return flatbuf.data() + insertion_point + root_offset;
|
return flatbuf.data() + insertion_point + root_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public struct Table {
|
|||||||
/// the vtable
|
/// the vtable
|
||||||
/// - Parameter o: current offset
|
/// - Parameter o: current offset
|
||||||
/// - Returns: offset of field within buffer
|
/// - Returns: offset of field within buffer
|
||||||
public func offset(_ o: Int32) -> Int32 {
|
public func offset(_ o: VOffset) -> Int32 {
|
||||||
let vtable = position &- bb.read(def: Int32.self, position: Int(position))
|
let vtable = position &- bb.read(def: Int32.self, position: Int(position))
|
||||||
return o
|
return o
|
||||||
< bb
|
< bb
|
||||||
@@ -57,7 +57,7 @@ public struct Table {
|
|||||||
? Int32(
|
? Int32(
|
||||||
bb.read(
|
bb.read(
|
||||||
def: Int16.self,
|
def: Int16.self,
|
||||||
position: Int(vtable &+ o))) : 0
|
position: Int(vtable &+ Int32(o)))) : 0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the indirect offset of the current stored object
|
/// Gets the indirect offset of the current stored object
|
||||||
@@ -106,13 +106,13 @@ public struct Table {
|
|||||||
/// This should only be used by `Scalars`
|
/// This should only be used by `Scalars`
|
||||||
/// - Parameter off: Readable offset
|
/// - Parameter off: Readable offset
|
||||||
/// - Returns: Returns a vector of type [T]
|
/// - Returns: Returns a vector of type [T]
|
||||||
public func getVector<T>(at off: Int32) -> [T]? {
|
public func getVector<T>(at off: VOffset) -> [T]? {
|
||||||
let o = offset(off)
|
let o = offset(off)
|
||||||
guard o != 0 else { return nil }
|
guard o != 0 else { return nil }
|
||||||
return bb.readSlice(index: Int(vector(at: o)), count: Int(vector(count: o)))
|
return bb.readSlice(index: Int(vector(at: o)), count: Int(vector(count: o)))
|
||||||
}
|
}
|
||||||
|
|
||||||
public func vector<T>(at off: Int32, byteSize: Int) -> FlatbufferVector<T> {
|
public func vector<T>(at off: VOffset, byteSize: Int) -> FlatbufferVector<T> {
|
||||||
let off = offset(off)
|
let off = offset(off)
|
||||||
return FlatbufferVector(
|
return FlatbufferVector(
|
||||||
bb: bb,
|
bb: bb,
|
||||||
@@ -122,7 +122,7 @@ public struct Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func unionVector(
|
public func unionVector(
|
||||||
at off: Int32,
|
at off: VOffset,
|
||||||
byteSize: Int) -> UnionFlatbufferVector
|
byteSize: Int) -> UnionFlatbufferVector
|
||||||
{
|
{
|
||||||
let off = offset(off)
|
let off = offset(off)
|
||||||
@@ -146,7 +146,7 @@ public struct Table {
|
|||||||
/// - Returns: Returns a pointer to the underlying data
|
/// - Returns: Returns a pointer to the underlying data
|
||||||
@inline(__always)
|
@inline(__always)
|
||||||
public func withUnsafePointerToSlice<T>(
|
public func withUnsafePointerToSlice<T>(
|
||||||
at off: Int32,
|
at off: VOffset,
|
||||||
body: (UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T?
|
body: (UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T?
|
||||||
{
|
{
|
||||||
let o = offset(off)
|
let o = offset(off)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import Common
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
enum FlexBuffersErrors: Error {
|
enum FlexBuffersErrors: Error {
|
||||||
@@ -23,6 +24,10 @@ enum FlexBuffersErrors: Error {
|
|||||||
|
|
||||||
@inline(__always)
|
@inline(__always)
|
||||||
public func getRoot(buffer: ByteBuffer) throws -> Reference? {
|
public func getRoot(buffer: ByteBuffer) throws -> Reference? {
|
||||||
|
assert(
|
||||||
|
isLitteEndian,
|
||||||
|
"Swift FlexBuffers currently only supports little-endian systems")
|
||||||
|
|
||||||
let end = buffer.count
|
let end = buffer.count
|
||||||
if buffer.count < 3 {
|
if buffer.count < 3 {
|
||||||
throw FlexBuffersErrors.sizeOfBufferIsTooSmall
|
throw FlexBuffersErrors.sizeOfBufferIsTooSmall
|
||||||
|
|||||||
@@ -37,12 +37,15 @@ public struct FlexBuffersWriter {
|
|||||||
private var hasDuplicatedKeys = false
|
private var hasDuplicatedKeys = false
|
||||||
private var minBitWidth: BitWidth = .w8
|
private var minBitWidth: BitWidth = .w8
|
||||||
private var _bb: _InternalByteBuffer
|
private var _bb: _InternalByteBuffer
|
||||||
private var stack: [Value] = []
|
private var stack: Stack = Stack()
|
||||||
private var keyPool: [Int: UInt] = [:]
|
private var keyPool: [Int: UInt] = [:]
|
||||||
private var stringPool: [Int: UInt] = [:]
|
private var stringPool: [Int: UInt] = [:]
|
||||||
private var flags: BuilderFlag
|
private var flags: BuilderFlag
|
||||||
|
|
||||||
public init(initialSize: Int = 1024, flags: BuilderFlag = .shareKeys) {
|
public init(initialSize: Int = 1024, flags: BuilderFlag = .shareKeys) {
|
||||||
|
assert(
|
||||||
|
isLitteEndian,
|
||||||
|
"Swift FlexBuffers currently only supports little-endian systems")
|
||||||
_bb = _InternalByteBuffer(initialSize: initialSize)
|
_bb = _InternalByteBuffer(initialSize: initialSize)
|
||||||
self.flags = flags
|
self.flags = flags
|
||||||
}
|
}
|
||||||
@@ -148,7 +151,7 @@ public struct FlexBuffersWriter {
|
|||||||
typed: typed,
|
typed: typed,
|
||||||
fixed: fixed,
|
fixed: fixed,
|
||||||
keys: nil)
|
keys: nil)
|
||||||
stack = Array(stack[..<start])
|
stack.popLast(start)
|
||||||
stack.append(vec)
|
stack.append(vec)
|
||||||
return vec.u
|
return vec.u
|
||||||
}
|
}
|
||||||
@@ -217,7 +220,7 @@ public struct FlexBuffersWriter {
|
|||||||
typed: false,
|
typed: false,
|
||||||
fixed: false,
|
fixed: false,
|
||||||
keys: keys)
|
keys: keys)
|
||||||
stack = Array(stack[..<start])
|
stack.popLast(start)
|
||||||
stack.append(vec)
|
stack.append(vec)
|
||||||
return numericCast(vec.u)
|
return numericCast(vec.u)
|
||||||
}
|
}
|
||||||
@@ -757,7 +760,7 @@ public struct FlexBuffersWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !fixed {
|
if !fixed {
|
||||||
write(value: count, byteWidth: byteWidth)
|
write(value: UInt64(count), byteWidth: byteWidth)
|
||||||
}
|
}
|
||||||
|
|
||||||
let vloc = _bb.writerIndex
|
let vloc = _bb.writerIndex
|
||||||
@@ -830,13 +833,14 @@ public struct FlexBuffersWriter {
|
|||||||
let key, value: Value
|
let key, value: Value
|
||||||
}
|
}
|
||||||
|
|
||||||
stack[start...].withUnsafeMutableBytes { buffer in
|
stack.withUnsafeMutableBytes(start: start) { buffer in
|
||||||
var ptr = buffer.assumingMemoryBound(to: TwoValue.self)
|
var ptr = buffer.assumingMemoryBound(to: TwoValue.self)
|
||||||
ptr.sort { a, b in
|
ptr.sort { a, b in
|
||||||
let aMem = _bb.memory.advanced(by: numericCast(a.key.u))
|
let aMem = _bb.memory.advanced(by: numericCast(a.key.u))
|
||||||
.assumingMemoryBound(to: CChar.self)
|
.assumingMemoryBound(to: CChar.self)
|
||||||
let bMem = _bb.memory.advanced(by: numericCast(b.key.u))
|
let bMem = _bb.memory.advanced(by: numericCast(b.key.u))
|
||||||
.assumingMemoryBound(to: CChar.self)
|
.assumingMemoryBound(to: CChar.self)
|
||||||
|
|
||||||
let comp = strcmp(aMem, bMem)
|
let comp = strcmp(aMem, bMem)
|
||||||
if (comp == 0) && a != b { hasDuplicatedKeys = true }
|
if (comp == 0) && a != b { hasDuplicatedKeys = true }
|
||||||
return comp < 0
|
return comp < 0
|
||||||
@@ -897,3 +901,129 @@ extension FlexBuffersWriter {
|
|||||||
return endMap(start: start)
|
return endMap(start: start)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fileprivate struct Stack: RandomAccessCollection {
|
||||||
|
typealias Element = Value
|
||||||
|
typealias Index = Int
|
||||||
|
|
||||||
|
private final class Storage {
|
||||||
|
var memory: UnsafeMutableRawPointer
|
||||||
|
|
||||||
|
init(capacity: Int, alignment: Int) {
|
||||||
|
memory = .allocate(byteCount: capacity, alignment: alignment)
|
||||||
|
memset(memory, 0, capacity)
|
||||||
|
}
|
||||||
|
|
||||||
|
deinit {
|
||||||
|
memory.deallocate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static let initialCapacity = 10 &* MemoryLayout<Value>.stride
|
||||||
|
private let storage: Storage
|
||||||
|
private var capacity: Int
|
||||||
|
private(set) var count: Int
|
||||||
|
|
||||||
|
var startIndex: Int {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
|
||||||
|
var endIndex: Int {
|
||||||
|
count
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
count = 0
|
||||||
|
capacity = Self.initialCapacity
|
||||||
|
|
||||||
|
storage = Storage(
|
||||||
|
capacity: capacity,
|
||||||
|
alignment: MemoryLayout<Value>.alignment)
|
||||||
|
}
|
||||||
|
|
||||||
|
@inline(__always)
|
||||||
|
subscript(position: Int) -> Value {
|
||||||
|
get {
|
||||||
|
storage.memory.advanced(by: position &* MemoryLayout<Value>.stride)
|
||||||
|
.assumingMemoryBound(to: Value.self).pointee
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
storage.memory.advanced(by: position &* MemoryLayout<Value>.stride)
|
||||||
|
.assumingMemoryBound(to: Value.self).pointee = newValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@inline(__always)
|
||||||
|
mutating func popLast(_ val: Int) {
|
||||||
|
count = if val < 0 {
|
||||||
|
0
|
||||||
|
} else {
|
||||||
|
val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mutating func append(_ value: Value) {
|
||||||
|
let writePosition = count &* MemoryLayout<Value>.stride
|
||||||
|
if writePosition >= capacity {
|
||||||
|
reallocate(writePosition: writePosition)
|
||||||
|
}
|
||||||
|
|
||||||
|
storage.memory.advanced(by: writePosition).storeBytes(
|
||||||
|
of: value,
|
||||||
|
as: Value.self)
|
||||||
|
count += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
mutating func removeAll(keepingCapacity keepCapacity: Bool = false) {
|
||||||
|
count = 0
|
||||||
|
if !keepCapacity {
|
||||||
|
capacity = Self.initialCapacity
|
||||||
|
storage.memory = UnsafeMutableRawPointer.allocate(
|
||||||
|
byteCount: capacity,
|
||||||
|
alignment: MemoryLayout<Value>.alignment)
|
||||||
|
}
|
||||||
|
memset(storage.memory, 0, capacity)
|
||||||
|
}
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
mutating func withUnsafeMutableBytes<R>(
|
||||||
|
start: Int,
|
||||||
|
_ body: (UnsafeMutableRawBufferPointer) throws -> R) rethrows -> R
|
||||||
|
{
|
||||||
|
let startingPosition = start &* MemoryLayout<Value>.stride
|
||||||
|
let pointer = storage.memory.advanced(by: startingPosition)
|
||||||
|
return try body(UnsafeMutableRawBufferPointer(
|
||||||
|
start: pointer,
|
||||||
|
count: (count &* MemoryLayout<Value>.stride) &- startingPosition))
|
||||||
|
}
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
mutating func withUnsafeMutableBytes<R>(
|
||||||
|
_ body: (UnsafeMutableRawBufferPointer) throws
|
||||||
|
-> R) rethrows -> R
|
||||||
|
{
|
||||||
|
return try body(UnsafeMutableRawBufferPointer(
|
||||||
|
start: storage.memory,
|
||||||
|
count: count &* MemoryLayout<Value>.stride))
|
||||||
|
}
|
||||||
|
|
||||||
|
mutating private func reallocate(writePosition: Int) {
|
||||||
|
while capacity <= writePosition {
|
||||||
|
capacity = capacity << 1
|
||||||
|
}
|
||||||
|
|
||||||
|
/// solution take from Apple-NIO
|
||||||
|
capacity = capacity.convertToPowerofTwo
|
||||||
|
|
||||||
|
let newData = UnsafeMutableRawPointer.allocate(
|
||||||
|
byteCount: capacity,
|
||||||
|
alignment: MemoryLayout<Value>.alignment)
|
||||||
|
memset(newData, 0, capacity)
|
||||||
|
memcpy(
|
||||||
|
newData,
|
||||||
|
storage.memory,
|
||||||
|
writePosition)
|
||||||
|
storage.memory.deallocate()
|
||||||
|
storage.memory = newData
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ struct _InternalByteBuffer {
|
|||||||
let newData = UnsafeMutableRawPointer.allocate(
|
let newData = UnsafeMutableRawPointer.allocate(
|
||||||
byteCount: capacity,
|
byteCount: capacity,
|
||||||
alignment: alignment)
|
alignment: alignment)
|
||||||
memset(newData, 0, capacity &- writerSize)
|
memset(newData, 0, capacity)
|
||||||
memcpy(
|
memcpy(
|
||||||
newData,
|
newData,
|
||||||
memory,
|
memory,
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ cc_test(
|
|||||||
"monster_test.cpp",
|
"monster_test.cpp",
|
||||||
"monster_test.h",
|
"monster_test.h",
|
||||||
"monster_test_bfbs_generated.h",
|
"monster_test_bfbs_generated.h",
|
||||||
|
"cross_namespace_pack_test_generated.h",
|
||||||
"namespace_test/namespace_test1_generated.h",
|
"namespace_test/namespace_test1_generated.h",
|
||||||
"namespace_test/namespace_test2_generated.h",
|
"namespace_test/namespace_test2_generated.h",
|
||||||
"native_inline_table_test_generated.h",
|
"native_inline_table_test_generated.h",
|
||||||
@@ -136,6 +137,7 @@ cc_test(
|
|||||||
deps = [
|
deps = [
|
||||||
":alignment_test_cc_fbs",
|
":alignment_test_cc_fbs",
|
||||||
":arrays_test_cc_fbs",
|
":arrays_test_cc_fbs",
|
||||||
|
":cross_namespace_pack_test_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",
|
||||||
@@ -261,6 +263,17 @@ flatbuffer_cc_library(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
flatbuffer_cc_library(
|
||||||
|
name = "cross_namespace_pack_test_cc_fbs",
|
||||||
|
srcs = ["cross_namespace_pack_test.fbs"],
|
||||||
|
flatc_args = [
|
||||||
|
"--gen-object-api",
|
||||||
|
"--gen-mutable",
|
||||||
|
"--gen-compare",
|
||||||
|
"--reflect-names",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
flatbuffer_cc_library(
|
flatbuffer_cc_library(
|
||||||
name = "native_type_test_cc_fbs",
|
name = "native_type_test_cc_fbs",
|
||||||
srcs = ["native_type_test.fbs"],
|
srcs = ["native_type_test.fbs"],
|
||||||
|
|||||||
@@ -106,6 +106,9 @@
|
|||||||
<Compile Include="..\MyGame\Example\NestedStruct.cs">
|
<Compile Include="..\MyGame\Example\NestedStruct.cs">
|
||||||
<Link>MyGame\Example\NestedStruct.cs</Link>
|
<Link>MyGame\Example\NestedStruct.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="..\MyGame\Example\LargeArrayStruct.cs">
|
||||||
|
<Link>MyGame\Example\LargeArrayStruct.cs</Link>
|
||||||
|
</Compile>
|
||||||
<Compile Include="..\MyGame\Example\LongEnum.cs">
|
<Compile Include="..\MyGame\Example\LongEnum.cs">
|
||||||
<Link>MyGame\Example\LongEnum.cs</Link>
|
<Link>MyGame\Example\LongEnum.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|||||||
150
tests/MyGame/Example/LargeArrayStruct.cs
Normal file
150
tests/MyGame/Example/LargeArrayStruct.cs
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
// <auto-generated>
|
||||||
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
// </auto-generated>
|
||||||
|
|
||||||
|
namespace MyGame.Example
|
||||||
|
{
|
||||||
|
|
||||||
|
using global::System;
|
||||||
|
using global::System.Collections.Generic;
|
||||||
|
using global::Google.FlatBuffers;
|
||||||
|
|
||||||
|
public struct LargeArrayStruct : IFlatbufferObject
|
||||||
|
{
|
||||||
|
private Struct __p;
|
||||||
|
public ByteBuffer ByteBuffer { get { return __p.bb; } }
|
||||||
|
public void __init(int _i, ByteBuffer _bb) { __p = new Struct(_i, _bb); }
|
||||||
|
public LargeArrayStruct __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||||
|
|
||||||
|
public byte D(int j) { return __p.bb.Get(__p.bb_pos + 0 + j * 1); }
|
||||||
|
public const int DLength = 64;
|
||||||
|
#if ENABLE_SPAN_T
|
||||||
|
public Span<byte> GetDBytes() { return __p.bb.ToSpan(__p.bb_pos + 0, 64); }
|
||||||
|
#else
|
||||||
|
public ArraySegment<byte>? GetDBytes() { return __p.bb.ToArraySegment(__p.bb_pos + 0, 64);}
|
||||||
|
#endif
|
||||||
|
public void MutateD(int j, byte d) { __p.bb.Put(__p.bb_pos + 0 + j * 1, d); }
|
||||||
|
public float E(int j) { return __p.bb.GetFloat(__p.bb_pos + 64 + j * 4); }
|
||||||
|
public const int ELength = 64;
|
||||||
|
#if ENABLE_SPAN_T
|
||||||
|
public Span<float> GetEBytes() { return System.Runtime.InteropServices.MemoryMarshal.Cast<byte, float>(__p.bb.ToSpan(__p.bb_pos + 64, 256)); }
|
||||||
|
#else
|
||||||
|
public ArraySegment<byte>? GetEBytes() { return __p.bb.ToArraySegment(__p.bb_pos + 64, 256);}
|
||||||
|
#endif
|
||||||
|
public void MutateE(int j, float e) { __p.bb.PutFloat(__p.bb_pos + 64 + j * 4, e); }
|
||||||
|
public bool F(int j) { return 0!=__p.bb.Get(__p.bb_pos + 320 + j * 1); }
|
||||||
|
public const int FLength = 64;
|
||||||
|
#if ENABLE_SPAN_T
|
||||||
|
public Span<bool> GetFBytes() { return System.Runtime.InteropServices.MemoryMarshal.Cast<byte, bool>(__p.bb.ToSpan(__p.bb_pos + 320, 64)); }
|
||||||
|
#else
|
||||||
|
public ArraySegment<byte>? GetFBytes() { return __p.bb.ToArraySegment(__p.bb_pos + 320, 64);}
|
||||||
|
#endif
|
||||||
|
public void MutateF(int j, bool f) { __p.bb.Put(__p.bb_pos + 320 + j * 1, (byte)(f ? 1 : 0)); }
|
||||||
|
public MyGame.Example.NestedStruct G(int j) { return (new MyGame.Example.NestedStruct()).__assign(__p.bb_pos + 384 + j * 32, __p.bb); }
|
||||||
|
public MyGame.Example.TestEnum H(int j) { return (MyGame.Example.TestEnum)__p.bb.GetSbyte(__p.bb_pos + 2432 + j * 1); }
|
||||||
|
public const int HLength = 64;
|
||||||
|
#if ENABLE_SPAN_T
|
||||||
|
public Span<MyGame.Example.TestEnum> GetHBytes() { return System.Runtime.InteropServices.MemoryMarshal.Cast<byte, MyGame.Example.TestEnum>(__p.bb.ToSpan(__p.bb_pos + 2432, 64)); }
|
||||||
|
#else
|
||||||
|
public ArraySegment<byte>? GetHBytes() { return __p.bb.ToArraySegment(__p.bb_pos + 2432, 64);}
|
||||||
|
#endif
|
||||||
|
public void MutateH(int j, MyGame.Example.TestEnum h) { __p.bb.PutSbyte(__p.bb_pos + 2432 + j * 1, (sbyte)h); }
|
||||||
|
|
||||||
|
public static Offset<MyGame.Example.LargeArrayStruct> CreateLargeArrayStruct(FlatBufferBuilder builder, byte[] D, float[] E, bool[] F, int[,] g_A, MyGame.Example.TestEnum[] g_B, MyGame.Example.TestEnum[,] g_C, long[,] g_D, MyGame.Example.TestEnum[] H) {
|
||||||
|
builder.Prep(8, 2496);
|
||||||
|
for (int _idx0 = 64; _idx0 > 0; _idx0--) {
|
||||||
|
builder.PutSbyte((sbyte)H[_idx0-1]);
|
||||||
|
}
|
||||||
|
for (int _idx0 = 64; _idx0 > 0; _idx0--) {
|
||||||
|
builder.Prep(8, 32);
|
||||||
|
for (int _idx1 = 2; _idx1 > 0; _idx1--) {
|
||||||
|
builder.PutLong(g_D[_idx0-1,_idx1-1]);
|
||||||
|
}
|
||||||
|
builder.Pad(5);
|
||||||
|
for (int _idx1 = 2; _idx1 > 0; _idx1--) {
|
||||||
|
builder.PutSbyte((sbyte)g_C[_idx0-1,_idx1-1]);
|
||||||
|
}
|
||||||
|
builder.PutSbyte((sbyte)g_B[_idx0-1]);
|
||||||
|
for (int _idx1 = 2; _idx1 > 0; _idx1--) {
|
||||||
|
builder.PutInt(g_A[_idx0-1,_idx1-1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int _idx0 = 64; _idx0 > 0; _idx0--) {
|
||||||
|
builder.PutBool(F[_idx0-1]);
|
||||||
|
}
|
||||||
|
for (int _idx0 = 64; _idx0 > 0; _idx0--) {
|
||||||
|
builder.PutFloat(E[_idx0-1]);
|
||||||
|
}
|
||||||
|
for (int _idx0 = 64; _idx0 > 0; _idx0--) {
|
||||||
|
builder.PutByte(D[_idx0-1]);
|
||||||
|
}
|
||||||
|
return new Offset<MyGame.Example.LargeArrayStruct>(builder.Offset);
|
||||||
|
}
|
||||||
|
public LargeArrayStructT UnPack() {
|
||||||
|
var _o = new LargeArrayStructT();
|
||||||
|
this.UnPackTo(_o);
|
||||||
|
return _o;
|
||||||
|
}
|
||||||
|
public void UnPackTo(LargeArrayStructT _o) {
|
||||||
|
_o.D = new byte[64];
|
||||||
|
for (var _j = 0; _j < 64; ++_j) { _o.D[_j] = this.D(_j); }
|
||||||
|
_o.E = new float[64];
|
||||||
|
for (var _j = 0; _j < 64; ++_j) { _o.E[_j] = this.E(_j); }
|
||||||
|
_o.F = new bool[64];
|
||||||
|
for (var _j = 0; _j < 64; ++_j) { _o.F[_j] = this.F(_j); }
|
||||||
|
_o.G = new MyGame.Example.NestedStructT[64];
|
||||||
|
for (var _j = 0; _j < 64; ++_j) { _o.G[_j] = this.G(_j).UnPack(); }
|
||||||
|
_o.H = new MyGame.Example.TestEnum[64];
|
||||||
|
for (var _j = 0; _j < 64; ++_j) { _o.H[_j] = this.H(_j); }
|
||||||
|
}
|
||||||
|
public static Offset<MyGame.Example.LargeArrayStruct> Pack(FlatBufferBuilder builder, LargeArrayStructT _o) {
|
||||||
|
if (_o == null) return default(Offset<MyGame.Example.LargeArrayStruct>);
|
||||||
|
var _d = _o.D;
|
||||||
|
var _e = _o.E;
|
||||||
|
var _f = _o.F;
|
||||||
|
var _g_a = new int[64,2];
|
||||||
|
for (var idx0 = 0; idx0 < 64; ++idx0) {for (var idx1 = 0; idx1 < 2; ++idx1) {_g_a[idx0,idx1] = _o.G[idx0].A[idx1];}}
|
||||||
|
var _g_b = new MyGame.Example.TestEnum[64];
|
||||||
|
for (var idx0 = 0; idx0 < 64; ++idx0) {_g_b[idx0] = _o.G[idx0].B;}
|
||||||
|
var _g_c = new MyGame.Example.TestEnum[64,2];
|
||||||
|
for (var idx0 = 0; idx0 < 64; ++idx0) {for (var idx1 = 0; idx1 < 2; ++idx1) {_g_c[idx0,idx1] = _o.G[idx0].C[idx1];}}
|
||||||
|
var _g_d = new long[64,2];
|
||||||
|
for (var idx0 = 0; idx0 < 64; ++idx0) {for (var idx1 = 0; idx1 < 2; ++idx1) {_g_d[idx0,idx1] = _o.G[idx0].D[idx1];}}
|
||||||
|
var _h = _o.H;
|
||||||
|
return CreateLargeArrayStruct(
|
||||||
|
builder,
|
||||||
|
_d,
|
||||||
|
_e,
|
||||||
|
_f,
|
||||||
|
_g_a,
|
||||||
|
_g_b,
|
||||||
|
_g_c,
|
||||||
|
_g_d,
|
||||||
|
_h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class LargeArrayStructT
|
||||||
|
{
|
||||||
|
[Newtonsoft.Json.JsonProperty("d")]
|
||||||
|
public byte[] D { get; set; }
|
||||||
|
[Newtonsoft.Json.JsonProperty("e")]
|
||||||
|
public float[] E { get; set; }
|
||||||
|
[Newtonsoft.Json.JsonProperty("f")]
|
||||||
|
public bool[] F { get; set; }
|
||||||
|
[Newtonsoft.Json.JsonProperty("g")]
|
||||||
|
public MyGame.Example.NestedStructT[] G { get; set; }
|
||||||
|
[Newtonsoft.Json.JsonProperty("h")]
|
||||||
|
public MyGame.Example.TestEnum[] H { get; set; }
|
||||||
|
|
||||||
|
public LargeArrayStructT() {
|
||||||
|
this.D = new byte[64];
|
||||||
|
this.E = new float[64];
|
||||||
|
this.F = new bool[64];
|
||||||
|
this.G = new MyGame.Example.NestedStructT[64];
|
||||||
|
this.H = new MyGame.Example.TestEnum[64];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
117
tests/MyGame/Example/LargeArrayStruct.java
Normal file
117
tests/MyGame/Example/LargeArrayStruct.java
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
|
||||||
|
package MyGame.Example;
|
||||||
|
|
||||||
|
import com.google.flatbuffers.BaseVector;
|
||||||
|
import com.google.flatbuffers.BooleanVector;
|
||||||
|
import com.google.flatbuffers.ByteVector;
|
||||||
|
import com.google.flatbuffers.Constants;
|
||||||
|
import com.google.flatbuffers.DoubleVector;
|
||||||
|
import com.google.flatbuffers.FlatBufferBuilder;
|
||||||
|
import com.google.flatbuffers.FloatVector;
|
||||||
|
import com.google.flatbuffers.IntVector;
|
||||||
|
import com.google.flatbuffers.LongVector;
|
||||||
|
import com.google.flatbuffers.ShortVector;
|
||||||
|
import com.google.flatbuffers.StringVector;
|
||||||
|
import com.google.flatbuffers.Struct;
|
||||||
|
import com.google.flatbuffers.UnionVector;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.ByteOrder;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public final class LargeArrayStruct extends Struct {
|
||||||
|
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||||
|
public LargeArrayStruct __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||||
|
|
||||||
|
public int d(int j) { return bb.get(bb_pos + 0 + j * 1); }
|
||||||
|
public void mutateD(int j, int d) { bb.put(bb_pos + 0 + j * 1, (byte) d); }
|
||||||
|
public float e(int j) { return bb.getFloat(bb_pos + 64 + j * 4); }
|
||||||
|
public void mutateE(int j, float e) { bb.putFloat(bb_pos + 64 + j * 4, e); }
|
||||||
|
public boolean f(int j) { return 0!=bb.get(bb_pos + 320 + j * 1); }
|
||||||
|
public void mutateF(int j, boolean f) { bb.put(bb_pos + 320 + j * 1, (byte)(f ? 1 : 0)); }
|
||||||
|
public MyGame.Example.NestedStruct g(int j) { return g(new MyGame.Example.NestedStruct(), j); }
|
||||||
|
public MyGame.Example.NestedStruct g(MyGame.Example.NestedStruct obj, int j) { return obj.__assign(bb_pos + 384 + j * 32, bb); }
|
||||||
|
public byte h(int j) { return bb.get(bb_pos + 2432 + j * 1); }
|
||||||
|
public void mutateH(int j, byte h) { bb.put(bb_pos + 2432 + j * 1, h); }
|
||||||
|
|
||||||
|
public static int createLargeArrayStruct(FlatBufferBuilder builder, int[] d, float[] e, boolean[] f, int[][] g_a, byte[] g_b, byte[][] g_c, long[][] g_d, byte[] h) {
|
||||||
|
builder.prep(8, 2496);
|
||||||
|
for (int _idx0 = 64; _idx0 > 0; _idx0--) {
|
||||||
|
builder.putByte(h[_idx0-1]);
|
||||||
|
}
|
||||||
|
for (int _idx0 = 64; _idx0 > 0; _idx0--) {
|
||||||
|
builder.prep(8, 32);
|
||||||
|
for (int _idx1 = 2; _idx1 > 0; _idx1--) {
|
||||||
|
builder.putLong(g_d[_idx0-1][_idx1-1]);
|
||||||
|
}
|
||||||
|
builder.pad(5);
|
||||||
|
for (int _idx1 = 2; _idx1 > 0; _idx1--) {
|
||||||
|
builder.putByte(g_c[_idx0-1][_idx1-1]);
|
||||||
|
}
|
||||||
|
builder.putByte(g_b[_idx0-1]);
|
||||||
|
for (int _idx1 = 2; _idx1 > 0; _idx1--) {
|
||||||
|
builder.putInt(g_a[_idx0-1][_idx1-1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int _idx0 = 64; _idx0 > 0; _idx0--) {
|
||||||
|
builder.putBoolean(f[_idx0-1]);
|
||||||
|
}
|
||||||
|
for (int _idx0 = 64; _idx0 > 0; _idx0--) {
|
||||||
|
builder.putFloat(e[_idx0-1]);
|
||||||
|
}
|
||||||
|
for (int _idx0 = 64; _idx0 > 0; _idx0--) {
|
||||||
|
builder.putByte((byte) d[_idx0-1]);
|
||||||
|
}
|
||||||
|
return builder.offset();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Vector extends BaseVector {
|
||||||
|
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
|
||||||
|
|
||||||
|
public LargeArrayStruct get(int j) { return get(new LargeArrayStruct(), j); }
|
||||||
|
public LargeArrayStruct get(LargeArrayStruct obj, int j) { return obj.__assign(__element(j), bb); }
|
||||||
|
}
|
||||||
|
public LargeArrayStructT unpack() {
|
||||||
|
LargeArrayStructT _o = new LargeArrayStructT();
|
||||||
|
unpackTo(_o);
|
||||||
|
return _o;
|
||||||
|
}
|
||||||
|
public void unpackTo(LargeArrayStructT _o) {
|
||||||
|
int[] _oD = _o.getD();
|
||||||
|
for (int _j = 0; _j < 64; ++_j) { _oD[_j] = d(_j); }
|
||||||
|
float[] _oE = _o.getE();
|
||||||
|
for (int _j = 0; _j < 64; ++_j) { _oE[_j] = e(_j); }
|
||||||
|
boolean[] _oF = _o.getF();
|
||||||
|
for (int _j = 0; _j < 64; ++_j) { _oF[_j] = f(_j); }
|
||||||
|
MyGame.Example.NestedStructT[] _oG = _o.getG();
|
||||||
|
for (int _j = 0; _j < 64; ++_j) { _oG[_j] = g(_j).unpack(); }
|
||||||
|
byte[] _oH = _o.getH();
|
||||||
|
for (int _j = 0; _j < 64; ++_j) { _oH[_j] = h(_j); }
|
||||||
|
}
|
||||||
|
public static int pack(FlatBufferBuilder builder, LargeArrayStructT _o) {
|
||||||
|
if (_o == null) return 0;
|
||||||
|
int[] _d = _o.getD();
|
||||||
|
float[] _e = _o.getE();
|
||||||
|
boolean[] _f = _o.getF();
|
||||||
|
int[][] _g_a = new int[64][2];
|
||||||
|
for (int idx0 = 0; idx0 < 64; ++idx0) {for (int idx1 = 0; idx1 < 2; ++idx1) {_g_a[idx0][idx1] = _o.getG()[idx0].getA()[idx1];}}
|
||||||
|
byte[] _g_b = new byte[64];
|
||||||
|
for (int idx0 = 0; idx0 < 64; ++idx0) {_g_b[idx0] = _o.getG()[idx0].getB();}
|
||||||
|
byte[][] _g_c = new byte[64][2];
|
||||||
|
for (int idx0 = 0; idx0 < 64; ++idx0) {for (int idx1 = 0; idx1 < 2; ++idx1) {_g_c[idx0][idx1] = _o.getG()[idx0].getC()[idx1];}}
|
||||||
|
long[][] _g_d = new long[64][2];
|
||||||
|
for (int idx0 = 0; idx0 < 64; ++idx0) {for (int idx1 = 0; idx1 < 2; ++idx1) {_g_d[idx0][idx1] = _o.getG()[idx0].getD()[idx1];}}
|
||||||
|
byte[] _h = _o.getH();
|
||||||
|
return createLargeArrayStruct(
|
||||||
|
builder,
|
||||||
|
_d,
|
||||||
|
_e,
|
||||||
|
_f,
|
||||||
|
_g_a,
|
||||||
|
_g_b,
|
||||||
|
_g_c,
|
||||||
|
_g_d,
|
||||||
|
_h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
226
tests/MyGame/Example/LargeArrayStruct.py
Normal file
226
tests/MyGame/Example/LargeArrayStruct.py
Normal file
@@ -0,0 +1,226 @@
|
|||||||
|
# automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
|
||||||
|
# namespace: Example
|
||||||
|
|
||||||
|
import flatbuffers
|
||||||
|
from flatbuffers.compat import import_numpy
|
||||||
|
from typing import Any
|
||||||
|
from MyGame.Example.NestedStruct import NestedStruct
|
||||||
|
np = import_numpy()
|
||||||
|
|
||||||
|
class LargeArrayStruct(object):
|
||||||
|
__slots__ = ['_tab']
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def SizeOf(cls) -> int:
|
||||||
|
return 2496
|
||||||
|
|
||||||
|
# LargeArrayStruct
|
||||||
|
def Init(self, buf: bytes, pos: int):
|
||||||
|
self._tab = flatbuffers.table.Table(buf, pos)
|
||||||
|
|
||||||
|
# LargeArrayStruct
|
||||||
|
def D(self, j = None):
|
||||||
|
if j is None:
|
||||||
|
return [self._tab.Get(flatbuffers.number_types.Uint8Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(0 + i * 1)) for i in range(self.DLength())]
|
||||||
|
elif j >= 0 and j < self.DLength():
|
||||||
|
return self._tab.Get(flatbuffers.number_types.Uint8Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(0 + j * 1))
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
# LargeArrayStruct
|
||||||
|
def DAsNumpy(self):
|
||||||
|
return self._tab.GetArrayAsNumpy(flatbuffers.number_types.Uint8Flags, self._tab.Pos + 0, self.DLength())
|
||||||
|
|
||||||
|
# LargeArrayStruct
|
||||||
|
def DLength(self) -> int:
|
||||||
|
return 64
|
||||||
|
|
||||||
|
# LargeArrayStruct
|
||||||
|
def DIsNone(self) -> bool:
|
||||||
|
return False
|
||||||
|
|
||||||
|
# LargeArrayStruct
|
||||||
|
def E(self, j = None):
|
||||||
|
if j is None:
|
||||||
|
return [self._tab.Get(flatbuffers.number_types.Float32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(64 + i * 4)) for i in range(self.ELength())]
|
||||||
|
elif j >= 0 and j < self.ELength():
|
||||||
|
return self._tab.Get(flatbuffers.number_types.Float32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(64 + j * 4))
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
# LargeArrayStruct
|
||||||
|
def EAsNumpy(self):
|
||||||
|
return self._tab.GetArrayAsNumpy(flatbuffers.number_types.Float32Flags, self._tab.Pos + 64, self.ELength())
|
||||||
|
|
||||||
|
# LargeArrayStruct
|
||||||
|
def ELength(self) -> int:
|
||||||
|
return 64
|
||||||
|
|
||||||
|
# LargeArrayStruct
|
||||||
|
def EIsNone(self) -> bool:
|
||||||
|
return False
|
||||||
|
|
||||||
|
# LargeArrayStruct
|
||||||
|
def F(self, j = None):
|
||||||
|
if j is None:
|
||||||
|
return [self._tab.Get(flatbuffers.number_types.BoolFlags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(320 + i * 1)) for i in range(self.FLength())]
|
||||||
|
elif j >= 0 and j < self.FLength():
|
||||||
|
return self._tab.Get(flatbuffers.number_types.BoolFlags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(320 + j * 1))
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
# LargeArrayStruct
|
||||||
|
def FAsNumpy(self):
|
||||||
|
return self._tab.GetArrayAsNumpy(flatbuffers.number_types.BoolFlags, self._tab.Pos + 320, self.FLength())
|
||||||
|
|
||||||
|
# LargeArrayStruct
|
||||||
|
def FLength(self) -> int:
|
||||||
|
return 64
|
||||||
|
|
||||||
|
# LargeArrayStruct
|
||||||
|
def FIsNone(self) -> bool:
|
||||||
|
return False
|
||||||
|
|
||||||
|
# LargeArrayStruct
|
||||||
|
def G(self, i: int) -> NestedStruct:
|
||||||
|
obj = NestedStruct()
|
||||||
|
obj.Init(self._tab.Bytes, self._tab.Pos + 384 + i * 32)
|
||||||
|
return obj
|
||||||
|
|
||||||
|
# LargeArrayStruct
|
||||||
|
def GLength(self) -> int:
|
||||||
|
return 64
|
||||||
|
|
||||||
|
# LargeArrayStruct
|
||||||
|
def GIsNone(self) -> bool:
|
||||||
|
return False
|
||||||
|
|
||||||
|
# LargeArrayStruct
|
||||||
|
def H(self, j = None):
|
||||||
|
if j is None:
|
||||||
|
return [self._tab.Get(flatbuffers.number_types.Int8Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(2432 + i * 1)) for i in range(self.HLength())]
|
||||||
|
elif j >= 0 and j < self.HLength():
|
||||||
|
return self._tab.Get(flatbuffers.number_types.Int8Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(2432 + j * 1))
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
# LargeArrayStruct
|
||||||
|
def HAsNumpy(self):
|
||||||
|
return self._tab.GetArrayAsNumpy(flatbuffers.number_types.Int8Flags, self._tab.Pos + 2432, self.HLength())
|
||||||
|
|
||||||
|
# LargeArrayStruct
|
||||||
|
def HLength(self) -> int:
|
||||||
|
return 64
|
||||||
|
|
||||||
|
# LargeArrayStruct
|
||||||
|
def HIsNone(self) -> bool:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def CreateLargeArrayStruct(builder, d, e, f, g_a, g_b, g_c, g_d, h):
|
||||||
|
builder.Prep(8, 2496)
|
||||||
|
for _idx0 in range(64 , 0, -1):
|
||||||
|
builder.PrependInt8(h[_idx0-1])
|
||||||
|
for _idx0 in range(64 , 0, -1):
|
||||||
|
builder.Prep(8, 32)
|
||||||
|
for _idx1 in range(2 , 0, -1):
|
||||||
|
builder.PrependInt64(g_d[_idx0-1][_idx1-1])
|
||||||
|
builder.Pad(5)
|
||||||
|
for _idx1 in range(2 , 0, -1):
|
||||||
|
builder.PrependInt8(g_c[_idx0-1][_idx1-1])
|
||||||
|
builder.PrependInt8(g_b[_idx0-1])
|
||||||
|
for _idx1 in range(2 , 0, -1):
|
||||||
|
builder.PrependInt32(g_a[_idx0-1][_idx1-1])
|
||||||
|
for _idx0 in range(64 , 0, -1):
|
||||||
|
builder.PrependBool(f[_idx0-1])
|
||||||
|
for _idx0 in range(64 , 0, -1):
|
||||||
|
builder.PrependFloat32(e[_idx0-1])
|
||||||
|
for _idx0 in range(64 , 0, -1):
|
||||||
|
builder.PrependUint8(d[_idx0-1])
|
||||||
|
return builder.Offset()
|
||||||
|
|
||||||
|
import MyGame.Example.NestedStruct
|
||||||
|
try:
|
||||||
|
from typing import List
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
class LargeArrayStructT(object):
|
||||||
|
|
||||||
|
# LargeArrayStructT
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
d = None,
|
||||||
|
e = None,
|
||||||
|
f = None,
|
||||||
|
g = None,
|
||||||
|
h = None,
|
||||||
|
):
|
||||||
|
self.d = d # type: Optional[List[int]]
|
||||||
|
self.e = e # type: Optional[List[float]]
|
||||||
|
self.f = f # type: Optional[List[bool]]
|
||||||
|
self.g = g # type: Optional[List[MyGame.Example.NestedStruct.NestedStructT]]
|
||||||
|
self.h = h # type: Optional[List[int]]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def InitFromBuf(cls, buf, pos):
|
||||||
|
largeArrayStruct = LargeArrayStruct()
|
||||||
|
largeArrayStruct.Init(buf, pos)
|
||||||
|
return cls.InitFromObj(largeArrayStruct)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def InitFromPackedBuf(cls, buf, pos=0):
|
||||||
|
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
|
||||||
|
return cls.InitFromBuf(buf, pos+n)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def InitFromObj(cls, largeArrayStruct):
|
||||||
|
x = LargeArrayStructT()
|
||||||
|
x._UnPack(largeArrayStruct)
|
||||||
|
return x
|
||||||
|
|
||||||
|
# LargeArrayStructT
|
||||||
|
def _UnPack(self, largeArrayStruct):
|
||||||
|
if largeArrayStruct is None:
|
||||||
|
return
|
||||||
|
if not largeArrayStruct.DIsNone():
|
||||||
|
if np is None:
|
||||||
|
self.d = []
|
||||||
|
for i in range(largeArrayStruct.DLength()):
|
||||||
|
self.d.append(largeArrayStruct.D(i))
|
||||||
|
else:
|
||||||
|
self.d = largeArrayStruct.DAsNumpy()
|
||||||
|
if not largeArrayStruct.EIsNone():
|
||||||
|
if np is None:
|
||||||
|
self.e = []
|
||||||
|
for i in range(largeArrayStruct.ELength()):
|
||||||
|
self.e.append(largeArrayStruct.E(i))
|
||||||
|
else:
|
||||||
|
self.e = largeArrayStruct.EAsNumpy()
|
||||||
|
if not largeArrayStruct.FIsNone():
|
||||||
|
if np is None:
|
||||||
|
self.f = []
|
||||||
|
for i in range(largeArrayStruct.FLength()):
|
||||||
|
self.f.append(largeArrayStruct.F(i))
|
||||||
|
else:
|
||||||
|
self.f = largeArrayStruct.FAsNumpy()
|
||||||
|
if not largeArrayStruct.GIsNone():
|
||||||
|
self.g = []
|
||||||
|
for i in range(largeArrayStruct.GLength()):
|
||||||
|
if largeArrayStruct.G(i) is None:
|
||||||
|
self.g.append(None)
|
||||||
|
else:
|
||||||
|
nestedStruct_ = MyGame.Example.NestedStruct.NestedStructT.InitFromObj(largeArrayStruct.G(i))
|
||||||
|
self.g.append(nestedStruct_)
|
||||||
|
if not largeArrayStruct.HIsNone():
|
||||||
|
if np is None:
|
||||||
|
self.h = []
|
||||||
|
for i in range(largeArrayStruct.HLength()):
|
||||||
|
self.h.append(largeArrayStruct.H(i))
|
||||||
|
else:
|
||||||
|
self.h = largeArrayStruct.HAsNumpy()
|
||||||
|
|
||||||
|
# LargeArrayStructT
|
||||||
|
def Pack(self, builder):
|
||||||
|
return CreateLargeArrayStruct(builder, self.d, self.e, self.f, self.g.a, self.g.b, self.g.c, self.g.d, self.h)
|
||||||
60
tests/MyGame/Example/LargeArrayStruct.pyi
Normal file
60
tests/MyGame/Example/LargeArrayStruct.pyi
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import flatbuffers
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
import typing
|
||||||
|
from MyGame.Example.NestedStruct import NestedStruct, NestedStructT
|
||||||
|
from MyGame.Example.TestEnum import TestEnum
|
||||||
|
|
||||||
|
uoffset: typing.TypeAlias = flatbuffers.number_types.UOffsetTFlags.py_type
|
||||||
|
|
||||||
|
class LargeArrayStruct(object):
|
||||||
|
@classmethod
|
||||||
|
def SizeOf(cls) -> int: ...
|
||||||
|
|
||||||
|
def Init(self, buf: bytes, pos: int) -> None: ...
|
||||||
|
def D(self, i: int) -> typing.List[int]: ...
|
||||||
|
def DAsNumpy(self) -> np.ndarray: ...
|
||||||
|
def DLength(self) -> int: ...
|
||||||
|
def DIsNone(self) -> bool: ...
|
||||||
|
def E(self, i: int) -> typing.List[float]: ...
|
||||||
|
def EAsNumpy(self) -> np.ndarray: ...
|
||||||
|
def ELength(self) -> int: ...
|
||||||
|
def EIsNone(self) -> bool: ...
|
||||||
|
def F(self, i: int) -> typing.List[bool]: ...
|
||||||
|
def FAsNumpy(self) -> np.ndarray: ...
|
||||||
|
def FLength(self) -> int: ...
|
||||||
|
def FIsNone(self) -> bool: ...
|
||||||
|
def G(self, i: int) -> NestedStruct | None: ...
|
||||||
|
def GLength(self) -> int: ...
|
||||||
|
def GIsNone(self) -> bool: ...
|
||||||
|
def H(self, i: int) -> typing.Literal[TestEnum.A, TestEnum.B, TestEnum.C]: ...
|
||||||
|
def HAsNumpy(self) -> np.ndarray: ...
|
||||||
|
def HLength(self) -> int: ...
|
||||||
|
def HIsNone(self) -> bool: ...
|
||||||
|
class LargeArrayStructT(object):
|
||||||
|
d: typing.List[int]
|
||||||
|
e: typing.List[float]
|
||||||
|
f: typing.List[bool]
|
||||||
|
g: typing.List[NestedStructT]
|
||||||
|
h: typing.List[typing.Literal[TestEnum.A, TestEnum.B, TestEnum.C]]
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
d: typing.List[int] | None = ...,
|
||||||
|
e: typing.List[float] | None = ...,
|
||||||
|
f: typing.List[bool] | None = ...,
|
||||||
|
g: typing.List['NestedStructT'] | None = ...,
|
||||||
|
h: typing.List[typing.Literal[TestEnum.A, TestEnum.B, TestEnum.C]] | None = ...,
|
||||||
|
) -> None: ...
|
||||||
|
@classmethod
|
||||||
|
def InitFromBuf(cls, buf: bytes, pos: int) -> LargeArrayStructT: ...
|
||||||
|
@classmethod
|
||||||
|
def InitFromPackedBuf(cls, buf: bytes, pos: int = 0) -> LargeArrayStructT: ...
|
||||||
|
@classmethod
|
||||||
|
def InitFromObj(cls, largeArrayStruct: LargeArrayStruct) -> LargeArrayStructT: ...
|
||||||
|
def _UnPack(self, largeArrayStruct: LargeArrayStruct) -> None: ...
|
||||||
|
def Pack(self, builder: flatbuffers.Builder) -> None: ...
|
||||||
|
|
||||||
|
def CreateLargeArrayStruct(builder: flatbuffers.Builder, d: int, e: float, f: bool, g_a: int, g_b: typing.Literal[TestEnum.A, TestEnum.B, TestEnum.C], g_c: typing.Literal[TestEnum.A, TestEnum.B, TestEnum.C], g_d: int, h: typing.Literal[TestEnum.A, TestEnum.B, TestEnum.C]) -> uoffset: ...
|
||||||
|
|
||||||
57
tests/MyGame/Example/LargeArrayStructT.java
Normal file
57
tests/MyGame/Example/LargeArrayStructT.java
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
|
||||||
|
package MyGame.Example;
|
||||||
|
|
||||||
|
import com.google.flatbuffers.BaseVector;
|
||||||
|
import com.google.flatbuffers.BooleanVector;
|
||||||
|
import com.google.flatbuffers.ByteVector;
|
||||||
|
import com.google.flatbuffers.Constants;
|
||||||
|
import com.google.flatbuffers.DoubleVector;
|
||||||
|
import com.google.flatbuffers.FlatBufferBuilder;
|
||||||
|
import com.google.flatbuffers.FloatVector;
|
||||||
|
import com.google.flatbuffers.IntVector;
|
||||||
|
import com.google.flatbuffers.LongVector;
|
||||||
|
import com.google.flatbuffers.ShortVector;
|
||||||
|
import com.google.flatbuffers.StringVector;
|
||||||
|
import com.google.flatbuffers.Struct;
|
||||||
|
import com.google.flatbuffers.UnionVector;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.ByteOrder;
|
||||||
|
|
||||||
|
public class LargeArrayStructT {
|
||||||
|
private int[] d;
|
||||||
|
private float[] e;
|
||||||
|
private boolean[] f;
|
||||||
|
private MyGame.Example.NestedStructT[] g;
|
||||||
|
private byte[] h;
|
||||||
|
|
||||||
|
public int[] getD() { return d; }
|
||||||
|
|
||||||
|
public void setD(int[] d) { if (d != null && d.length == 64) this.d = d; }
|
||||||
|
|
||||||
|
public float[] getE() { return e; }
|
||||||
|
|
||||||
|
public void setE(float[] e) { if (e != null && e.length == 64) this.e = e; }
|
||||||
|
|
||||||
|
public boolean[] getF() { return f; }
|
||||||
|
|
||||||
|
public void setF(boolean[] f) { if (f != null && f.length == 64) this.f = f; }
|
||||||
|
|
||||||
|
public MyGame.Example.NestedStructT[] getG() { return g; }
|
||||||
|
|
||||||
|
public void setG(MyGame.Example.NestedStructT[] g) { if (g != null && g.length == 64) this.g = g; }
|
||||||
|
|
||||||
|
public byte[] getH() { return h; }
|
||||||
|
|
||||||
|
public void setH(byte[] h) { if (h != null && h.length == 64) this.h = h; }
|
||||||
|
|
||||||
|
|
||||||
|
public LargeArrayStructT() {
|
||||||
|
this.d = new int[64];
|
||||||
|
this.e = new float[64];
|
||||||
|
this.f = new boolean[64];
|
||||||
|
this.g = new MyGame.Example.NestedStructT[64];
|
||||||
|
this.h = new byte[64];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -922,7 +922,7 @@ def MonsterCreateInventoryVector(builder, data):
|
|||||||
return builder.EndVector()
|
return builder.EndVector()
|
||||||
|
|
||||||
def CreateInventoryVector(builder, data):
|
def CreateInventoryVector(builder, data):
|
||||||
MonsterCreateInventoryVector(builder, data)
|
return MonsterCreateInventoryVector(builder, data)
|
||||||
|
|
||||||
def MonsterAddColor(builder, color):
|
def MonsterAddColor(builder, color):
|
||||||
builder.PrependUint8Slot(6, color, 8)
|
builder.PrependUint8Slot(6, color, 8)
|
||||||
@@ -962,7 +962,7 @@ def MonsterCreateTest4Vector(builder, data):
|
|||||||
return builder.EndVector()
|
return builder.EndVector()
|
||||||
|
|
||||||
def CreateTest4Vector(builder, data):
|
def CreateTest4Vector(builder, data):
|
||||||
MonsterCreateTest4Vector(builder, data)
|
return 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)
|
||||||
@@ -980,7 +980,7 @@ def MonsterCreateTestarrayofstringVector(builder, data):
|
|||||||
return builder.CreateVectorOfTables(data)
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def CreateTestarrayofstringVector(builder, data):
|
def CreateTestarrayofstringVector(builder, data):
|
||||||
MonsterCreateTestarrayofstringVector(builder, data)
|
return 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)
|
||||||
@@ -998,7 +998,7 @@ def MonsterCreateTestarrayoftablesVector(builder, data):
|
|||||||
return builder.CreateVectorOfTables(data)
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def CreateTestarrayoftablesVector(builder, data):
|
def CreateTestarrayoftablesVector(builder, data):
|
||||||
MonsterCreateTestarrayoftablesVector(builder, data)
|
return 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)
|
||||||
@@ -1026,7 +1026,7 @@ def MonsterCreateTestnestedflatbufferVector(builder, data):
|
|||||||
return builder.EndVector()
|
return builder.EndVector()
|
||||||
|
|
||||||
def CreateTestnestedflatbufferVector(builder, data):
|
def CreateTestnestedflatbufferVector(builder, data):
|
||||||
MonsterCreateTestnestedflatbufferVector(builder, data)
|
return MonsterCreateTestnestedflatbufferVector(builder, data)
|
||||||
|
|
||||||
def MonsterMakeTestnestedflatbufferVectorFromBytes(builder, bytes):
|
def MonsterMakeTestnestedflatbufferVectorFromBytes(builder, bytes):
|
||||||
builder.StartVector(1, len(bytes), 1)
|
builder.StartVector(1, len(bytes), 1)
|
||||||
@@ -1115,7 +1115,7 @@ def MonsterCreateTestarrayofboolsVector(builder, data):
|
|||||||
return builder.EndVector()
|
return builder.EndVector()
|
||||||
|
|
||||||
def CreateTestarrayofboolsVector(builder, data):
|
def CreateTestarrayofboolsVector(builder, data):
|
||||||
MonsterCreateTestarrayofboolsVector(builder, data)
|
return MonsterCreateTestarrayofboolsVector(builder, data)
|
||||||
|
|
||||||
def MonsterAddTestf(builder, testf):
|
def MonsterAddTestf(builder, testf):
|
||||||
builder.PrependFloat32Slot(25, testf, 3.14159)
|
builder.PrependFloat32Slot(25, testf, 3.14159)
|
||||||
@@ -1151,7 +1151,7 @@ def MonsterCreateTestarrayofstring2Vector(builder, data):
|
|||||||
return builder.CreateVectorOfTables(data)
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def CreateTestarrayofstring2Vector(builder, data):
|
def CreateTestarrayofstring2Vector(builder, data):
|
||||||
MonsterCreateTestarrayofstring2Vector(builder, data)
|
return 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)
|
||||||
@@ -1173,7 +1173,7 @@ def MonsterCreateTestarrayofsortedstructVector(builder, data):
|
|||||||
return builder.EndVector()
|
return builder.EndVector()
|
||||||
|
|
||||||
def CreateTestarrayofsortedstructVector(builder, data):
|
def CreateTestarrayofsortedstructVector(builder, data):
|
||||||
MonsterCreateTestarrayofsortedstructVector(builder, data)
|
return 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)
|
||||||
@@ -1195,7 +1195,7 @@ def MonsterCreateFlexVector(builder, data):
|
|||||||
return builder.EndVector()
|
return builder.EndVector()
|
||||||
|
|
||||||
def CreateFlexVector(builder, data):
|
def CreateFlexVector(builder, data):
|
||||||
MonsterCreateFlexVector(builder, data)
|
return 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)
|
||||||
@@ -1217,7 +1217,7 @@ def MonsterCreateTest5Vector(builder, data):
|
|||||||
return builder.EndVector()
|
return builder.EndVector()
|
||||||
|
|
||||||
def CreateTest5Vector(builder, data):
|
def CreateTest5Vector(builder, data):
|
||||||
MonsterCreateTest5Vector(builder, data)
|
return 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)
|
||||||
@@ -1239,7 +1239,7 @@ def MonsterCreateVectorOfLongsVector(builder, data):
|
|||||||
return builder.EndVector()
|
return builder.EndVector()
|
||||||
|
|
||||||
def CreateVectorOfLongsVector(builder, data):
|
def CreateVectorOfLongsVector(builder, data):
|
||||||
MonsterCreateVectorOfLongsVector(builder, data)
|
return 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)
|
||||||
@@ -1261,7 +1261,7 @@ def MonsterCreateVectorOfDoublesVector(builder, data):
|
|||||||
return builder.EndVector()
|
return builder.EndVector()
|
||||||
|
|
||||||
def CreateVectorOfDoublesVector(builder, data):
|
def CreateVectorOfDoublesVector(builder, data):
|
||||||
MonsterCreateVectorOfDoublesVector(builder, data)
|
return 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)
|
||||||
@@ -1285,7 +1285,7 @@ def MonsterCreateVectorOfReferrablesVector(builder, data):
|
|||||||
return builder.CreateVectorOfTables(data)
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def CreateVectorOfReferrablesVector(builder, data):
|
def CreateVectorOfReferrablesVector(builder, data):
|
||||||
MonsterCreateVectorOfReferrablesVector(builder, data)
|
return MonsterCreateVectorOfReferrablesVector(builder, data)
|
||||||
|
|
||||||
def MonsterAddSingleWeakReference(builder, singleWeakReference):
|
def MonsterAddSingleWeakReference(builder, singleWeakReference):
|
||||||
builder.PrependUint64Slot(36, singleWeakReference, 0)
|
builder.PrependUint64Slot(36, singleWeakReference, 0)
|
||||||
@@ -1313,7 +1313,7 @@ def MonsterCreateVectorOfWeakReferencesVector(builder, data):
|
|||||||
return builder.EndVector()
|
return builder.EndVector()
|
||||||
|
|
||||||
def CreateVectorOfWeakReferencesVector(builder, data):
|
def CreateVectorOfWeakReferencesVector(builder, data):
|
||||||
MonsterCreateVectorOfWeakReferencesVector(builder, data)
|
return 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)
|
||||||
@@ -1331,7 +1331,7 @@ def MonsterCreateVectorOfStrongReferrablesVector(builder, data):
|
|||||||
return builder.CreateVectorOfTables(data)
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def CreateVectorOfStrongReferrablesVector(builder, data):
|
def CreateVectorOfStrongReferrablesVector(builder, data):
|
||||||
MonsterCreateVectorOfStrongReferrablesVector(builder, data)
|
return MonsterCreateVectorOfStrongReferrablesVector(builder, data)
|
||||||
|
|
||||||
def MonsterAddCoOwningReference(builder, coOwningReference):
|
def MonsterAddCoOwningReference(builder, coOwningReference):
|
||||||
builder.PrependUint64Slot(39, coOwningReference, 0)
|
builder.PrependUint64Slot(39, coOwningReference, 0)
|
||||||
@@ -1359,7 +1359,7 @@ def MonsterCreateVectorOfCoOwningReferencesVector(builder, data):
|
|||||||
return builder.EndVector()
|
return builder.EndVector()
|
||||||
|
|
||||||
def CreateVectorOfCoOwningReferencesVector(builder, data):
|
def CreateVectorOfCoOwningReferencesVector(builder, data):
|
||||||
MonsterCreateVectorOfCoOwningReferencesVector(builder, data)
|
return MonsterCreateVectorOfCoOwningReferencesVector(builder, data)
|
||||||
|
|
||||||
def MonsterAddNonOwningReference(builder, nonOwningReference):
|
def MonsterAddNonOwningReference(builder, nonOwningReference):
|
||||||
builder.PrependUint64Slot(41, nonOwningReference, 0)
|
builder.PrependUint64Slot(41, nonOwningReference, 0)
|
||||||
@@ -1387,7 +1387,7 @@ def MonsterCreateVectorOfNonOwningReferencesVector(builder, data):
|
|||||||
return builder.EndVector()
|
return builder.EndVector()
|
||||||
|
|
||||||
def CreateVectorOfNonOwningReferencesVector(builder, data):
|
def CreateVectorOfNonOwningReferencesVector(builder, data):
|
||||||
MonsterCreateVectorOfNonOwningReferencesVector(builder, data)
|
return MonsterCreateVectorOfNonOwningReferencesVector(builder, data)
|
||||||
|
|
||||||
def MonsterAddAnyUniqueType(builder, anyUniqueType):
|
def MonsterAddAnyUniqueType(builder, anyUniqueType):
|
||||||
builder.PrependUint8Slot(43, anyUniqueType, 0)
|
builder.PrependUint8Slot(43, anyUniqueType, 0)
|
||||||
@@ -1433,7 +1433,7 @@ def MonsterCreateVectorOfEnumsVector(builder, data):
|
|||||||
return builder.EndVector()
|
return builder.EndVector()
|
||||||
|
|
||||||
def CreateVectorOfEnumsVector(builder, data):
|
def CreateVectorOfEnumsVector(builder, data):
|
||||||
MonsterCreateVectorOfEnumsVector(builder, data)
|
return MonsterCreateVectorOfEnumsVector(builder, data)
|
||||||
|
|
||||||
def MonsterAddSignedEnum(builder, signedEnum):
|
def MonsterAddSignedEnum(builder, signedEnum):
|
||||||
builder.PrependInt8Slot(48, signedEnum, -1)
|
builder.PrependInt8Slot(48, signedEnum, -1)
|
||||||
@@ -1461,7 +1461,7 @@ def MonsterCreateTestrequirednestedflatbufferVector(builder, data):
|
|||||||
return builder.EndVector()
|
return builder.EndVector()
|
||||||
|
|
||||||
def CreateTestrequirednestedflatbufferVector(builder, data):
|
def CreateTestrequirednestedflatbufferVector(builder, data):
|
||||||
MonsterCreateTestrequirednestedflatbufferVector(builder, data)
|
return MonsterCreateTestrequirednestedflatbufferVector(builder, data)
|
||||||
|
|
||||||
def MonsterMakeTestrequirednestedflatbufferVectorFromBytes(builder, bytes):
|
def MonsterMakeTestrequirednestedflatbufferVectorFromBytes(builder, bytes):
|
||||||
builder.StartVector(1, len(bytes), 1)
|
builder.StartVector(1, len(bytes), 1)
|
||||||
@@ -1486,7 +1486,7 @@ def MonsterCreateScalarKeySortedTablesVector(builder, data):
|
|||||||
return builder.CreateVectorOfTables(data)
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
def CreateScalarKeySortedTablesVector(builder, data):
|
def CreateScalarKeySortedTablesVector(builder, data):
|
||||||
MonsterCreateScalarKeySortedTablesVector(builder, data)
|
return 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)
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ def TypeAliasesCreateV8Vector(builder, data):
|
|||||||
return builder.EndVector()
|
return builder.EndVector()
|
||||||
|
|
||||||
def CreateV8Vector(builder, data):
|
def CreateV8Vector(builder, data):
|
||||||
TypeAliasesCreateV8Vector(builder, data)
|
return 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)
|
||||||
@@ -260,7 +260,7 @@ def TypeAliasesCreateVf64Vector(builder, data):
|
|||||||
return builder.EndVector()
|
return builder.EndVector()
|
||||||
|
|
||||||
def CreateVf64Vector(builder, data):
|
def CreateVf64Vector(builder, data):
|
||||||
TypeAliasesCreateVf64Vector(builder, data)
|
return TypeAliasesCreateVf64Vector(builder, data)
|
||||||
|
|
||||||
def TypeAliasesEnd(builder):
|
def TypeAliasesEnd(builder):
|
||||||
return builder.EndObject()
|
return builder.EndObject()
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ def MonsterExtraCreateDvecVector(builder: flatbuffers.Builder, data: Iterable[An
|
|||||||
return builder.EndVector()
|
return builder.EndVector()
|
||||||
|
|
||||||
def CreateDvecVector(builder: flatbuffers.Builder, data: Iterable[Any]) -> int:
|
def CreateDvecVector(builder: flatbuffers.Builder, data: Iterable[Any]) -> int:
|
||||||
MonsterExtraCreateDvecVector(builder, data)
|
return 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)
|
||||||
@@ -236,7 +236,7 @@ def MonsterExtraCreateFvecVector(builder: flatbuffers.Builder, data: Iterable[An
|
|||||||
return builder.EndVector()
|
return builder.EndVector()
|
||||||
|
|
||||||
def CreateFvecVector(builder: flatbuffers.Builder, data: Iterable[Any]) -> int:
|
def CreateFvecVector(builder: flatbuffers.Builder, data: Iterable[Any]) -> int:
|
||||||
MonsterExtraCreateFvecVector(builder, data)
|
return MonsterExtraCreateFvecVector(builder, data)
|
||||||
|
|
||||||
def MonsterExtraEnd(builder: flatbuffers.Builder) -> int:
|
def MonsterExtraEnd(builder: flatbuffers.Builder) -> int:
|
||||||
return builder.EndObject()
|
return builder.EndObject()
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ ${test_dir}/../flatc -p -o ${gen_code_path} -I include_test monster_extra.fbs --
|
|||||||
${test_dir}/../flatc -p -o ${gen_code_path} -I include_test arrays_test.fbs --gen-object-api --python-typing
|
${test_dir}/../flatc -p -o ${gen_code_path} -I include_test arrays_test.fbs --gen-object-api --python-typing
|
||||||
${test_dir}/../flatc -p -o ${gen_code_path} -I include_test nested_union_test.fbs --gen-object-api --python-typing --python-decode-obj-api-strings
|
${test_dir}/../flatc -p -o ${gen_code_path} -I include_test nested_union_test.fbs --gen-object-api --python-typing --python-decode-obj-api-strings
|
||||||
${test_dir}/../flatc -p -o ${gen_code_path} -I include_test service_test.fbs --grpc --grpc-python-typed-handlers --python-typing --no-python-gen-numpy --gen-onefile
|
${test_dir}/../flatc -p -o ${gen_code_path} -I include_test service_test.fbs --grpc --grpc-python-typed-handlers --python-typing --no-python-gen-numpy --gen-onefile
|
||||||
|
${test_dir}/../flatc -p -o ${gen_code_path} union_name_test.fbs --gen-object-api
|
||||||
|
|
||||||
# Syntax: run_tests <interpreter> <benchmark vtable dedupes>
|
# Syntax: run_tests <interpreter> <benchmark vtable dedupes>
|
||||||
# <benchmark read count> <benchmark build count>
|
# <benchmark read count> <benchmark build count>
|
||||||
|
|||||||
Binary file not shown.
@@ -18,6 +18,14 @@ struct ArrayStruct{
|
|||||||
f:[int64:2];
|
f:[int64:2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct LargeArrayStruct {
|
||||||
|
d:[ubyte:64];
|
||||||
|
e:[float:64];
|
||||||
|
f:[bool:64];
|
||||||
|
g:[NestedStruct:64];
|
||||||
|
h:[TestEnum:64];
|
||||||
|
}
|
||||||
|
|
||||||
table ArrayTable{
|
table ArrayTable{
|
||||||
a:ArrayStruct;
|
a:ArrayStruct;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,6 +59,37 @@
|
|||||||
},
|
},
|
||||||
"additionalProperties" : false
|
"additionalProperties" : false
|
||||||
},
|
},
|
||||||
|
"MyGame_Example_LargeArrayStruct" : {
|
||||||
|
"type" : "object",
|
||||||
|
"properties" : {
|
||||||
|
"d" : {
|
||||||
|
"type" : "array", "items" : {"type" : "integer", "minimum" : 0, "maximum" :255},
|
||||||
|
"minItems": 64,
|
||||||
|
"maxItems": 64
|
||||||
|
},
|
||||||
|
"e" : {
|
||||||
|
"type" : "array", "items" : {"type" : "number"},
|
||||||
|
"minItems": 64,
|
||||||
|
"maxItems": 64
|
||||||
|
},
|
||||||
|
"f" : {
|
||||||
|
"type" : "array", "items" : {"type" : "boolean"},
|
||||||
|
"minItems": 64,
|
||||||
|
"maxItems": 64
|
||||||
|
},
|
||||||
|
"g" : {
|
||||||
|
"type" : "array", "items" : {"$ref" : "#/definitions/MyGame_Example_NestedStruct"},
|
||||||
|
"minItems": 64,
|
||||||
|
"maxItems": 64
|
||||||
|
},
|
||||||
|
"h" : {
|
||||||
|
"type" : "array", "items" : {"$ref" : "#/definitions/MyGame_Example_TestEnum"},
|
||||||
|
"minItems": 64,
|
||||||
|
"maxItems": 64
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties" : false
|
||||||
|
},
|
||||||
"MyGame_Example_ArrayTable" : {
|
"MyGame_Example_ArrayTable" : {
|
||||||
"type" : "object",
|
"type" : "object",
|
||||||
"properties" : {
|
"properties" : {
|
||||||
|
|||||||
921
tests/arrays_test/arrays_test_generated.rs
Normal file
921
tests/arrays_test/arrays_test_generated.rs
Normal file
@@ -0,0 +1,921 @@
|
|||||||
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
// @generated
|
||||||
|
|
||||||
|
extern crate alloc;
|
||||||
|
|
||||||
|
#[allow(unused_imports, dead_code)]
|
||||||
|
pub mod my_game {
|
||||||
|
|
||||||
|
extern crate alloc;
|
||||||
|
#[allow(unused_imports, dead_code)]
|
||||||
|
pub mod example {
|
||||||
|
|
||||||
|
extern crate alloc;
|
||||||
|
|
||||||
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
|
pub const ENUM_MIN_TEST_ENUM: i8 = 0;
|
||||||
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
|
pub const ENUM_MAX_TEST_ENUM: i8 = 2;
|
||||||
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
pub const ENUM_VALUES_TEST_ENUM: [TestEnum; 3] = [
|
||||||
|
TestEnum::A,
|
||||||
|
TestEnum::B,
|
||||||
|
TestEnum::C,
|
||||||
|
];
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||||
|
#[repr(transparent)]
|
||||||
|
pub struct TestEnum(pub i8);
|
||||||
|
#[allow(non_upper_case_globals)]
|
||||||
|
impl TestEnum {
|
||||||
|
pub const A: Self = Self(0);
|
||||||
|
pub const B: Self = Self(1);
|
||||||
|
pub const C: Self = Self(2);
|
||||||
|
|
||||||
|
pub const ENUM_MIN: i8 = 0;
|
||||||
|
pub const ENUM_MAX: i8 = 2;
|
||||||
|
pub const ENUM_VALUES: &'static [Self] = &[
|
||||||
|
Self::A,
|
||||||
|
Self::B,
|
||||||
|
Self::C,
|
||||||
|
];
|
||||||
|
/// Returns the variant's name or "" if unknown.
|
||||||
|
pub fn variant_name(self) -> Option<&'static str> {
|
||||||
|
match self {
|
||||||
|
Self::A => Some("A"),
|
||||||
|
Self::B => Some("B"),
|
||||||
|
Self::C => Some("C"),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl ::core::fmt::Debug for TestEnum {
|
||||||
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
|
if let Some(name) = self.variant_name() {
|
||||||
|
f.write_str(name)
|
||||||
|
} else {
|
||||||
|
f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<'a> ::flatbuffers::Follow<'a> for TestEnum {
|
||||||
|
type Inner = Self;
|
||||||
|
#[inline]
|
||||||
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
|
let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
|
||||||
|
Self(b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::flatbuffers::Push for TestEnum {
|
||||||
|
type Output = TestEnum;
|
||||||
|
#[inline]
|
||||||
|
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||||
|
unsafe { ::flatbuffers::emplace_scalar::<i8>(dst, self.0) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::flatbuffers::EndianScalar for TestEnum {
|
||||||
|
type Scalar = i8;
|
||||||
|
#[inline]
|
||||||
|
fn to_little_endian(self) -> i8 {
|
||||||
|
self.0.to_le()
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
#[allow(clippy::wrong_self_convention)]
|
||||||
|
fn from_little_endian(v: i8) -> Self {
|
||||||
|
let b = i8::from_le(v);
|
||||||
|
Self(b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> ::flatbuffers::Verifiable for TestEnum {
|
||||||
|
#[inline]
|
||||||
|
fn run_verifier(
|
||||||
|
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||||
|
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||||
|
i8::run_verifier(v, pos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::flatbuffers::SimpleToVerifyInSlice for TestEnum {}
|
||||||
|
// struct NestedStruct, aligned to 8
|
||||||
|
#[repr(transparent)]
|
||||||
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
|
pub struct NestedStruct(pub [u8; 32]);
|
||||||
|
impl Default for NestedStruct {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self([0; 32])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl ::core::fmt::Debug for NestedStruct {
|
||||||
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
|
f.debug_struct("NestedStruct")
|
||||||
|
.field("a", &self.a())
|
||||||
|
.field("b", &self.b())
|
||||||
|
.field("c", &self.c())
|
||||||
|
.field("d", &self.d())
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::flatbuffers::SimpleToVerifyInSlice for NestedStruct {}
|
||||||
|
impl<'a> ::flatbuffers::Follow<'a> for NestedStruct {
|
||||||
|
type Inner = &'a NestedStruct;
|
||||||
|
#[inline]
|
||||||
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
|
unsafe { <&'a NestedStruct>::follow(buf, loc) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<'a> ::flatbuffers::Follow<'a> for &'a NestedStruct {
|
||||||
|
type Inner = &'a NestedStruct;
|
||||||
|
#[inline]
|
||||||
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
|
unsafe { ::flatbuffers::follow_cast_ref::<NestedStruct>(buf, loc) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<'b> ::flatbuffers::Push for NestedStruct {
|
||||||
|
type Output = NestedStruct;
|
||||||
|
#[inline]
|
||||||
|
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||||
|
let src = unsafe { ::core::slice::from_raw_parts(self as *const NestedStruct as *const u8, <Self as ::flatbuffers::Push>::size()) };
|
||||||
|
dst.copy_from_slice(src);
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
fn alignment() -> ::flatbuffers::PushAlignment {
|
||||||
|
::flatbuffers::PushAlignment::new(8)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> ::flatbuffers::Verifiable for NestedStruct {
|
||||||
|
#[inline]
|
||||||
|
fn run_verifier(
|
||||||
|
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||||
|
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||||
|
v.in_buffer::<Self>(pos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> NestedStruct {
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
pub fn new(
|
||||||
|
a: &[i32; 2],
|
||||||
|
b: TestEnum,
|
||||||
|
c: &[TestEnum; 2],
|
||||||
|
d: &[i64; 2],
|
||||||
|
) -> Self {
|
||||||
|
let mut s = Self([0; 32]);
|
||||||
|
s.set_a(a);
|
||||||
|
s.set_b(b);
|
||||||
|
s.set_c(c);
|
||||||
|
s.set_d(d);
|
||||||
|
s
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn a(&'a self) -> ::flatbuffers::Array<'a, i32, 2> {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
use ::flatbuffers::Follow;
|
||||||
|
unsafe { ::flatbuffers::Array::follow(&self.0, 0) }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_a(&mut self, items: &[i32; 2]) {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 0, items) };
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn b(&self) -> TestEnum {
|
||||||
|
let mut mem = ::core::mem::MaybeUninit::<<TestEnum as ::flatbuffers::EndianScalar>::Scalar>::uninit();
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid value in this slot
|
||||||
|
::flatbuffers::EndianScalar::from_little_endian(unsafe {
|
||||||
|
::core::ptr::copy_nonoverlapping(
|
||||||
|
self.0[8..].as_ptr(),
|
||||||
|
mem.as_mut_ptr() as *mut u8,
|
||||||
|
::core::mem::size_of::<<TestEnum as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||||
|
);
|
||||||
|
mem.assume_init()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_b(&mut self, x: TestEnum) {
|
||||||
|
let x_le = ::flatbuffers::EndianScalar::to_little_endian(x);
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid value in this slot
|
||||||
|
unsafe {
|
||||||
|
::core::ptr::copy_nonoverlapping(
|
||||||
|
&x_le as *const _ as *const u8,
|
||||||
|
self.0[8..].as_mut_ptr(),
|
||||||
|
::core::mem::size_of::<<TestEnum as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn c(&'a self) -> ::flatbuffers::Array<'a, TestEnum, 2> {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
use ::flatbuffers::Follow;
|
||||||
|
unsafe { ::flatbuffers::Array::follow(&self.0, 9) }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_c(&mut self, x: &[TestEnum; 2]) {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
unsafe {
|
||||||
|
::core::ptr::copy(
|
||||||
|
x.as_ptr() as *const u8,
|
||||||
|
self.0.as_mut_ptr().add(9),
|
||||||
|
2,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn d(&'a self) -> ::flatbuffers::Array<'a, i64, 2> {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
use ::flatbuffers::Follow;
|
||||||
|
unsafe { ::flatbuffers::Array::follow(&self.0, 16) }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_d(&mut self, items: &[i64; 2]) {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 16, items) };
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unpack(&self) -> NestedStructT {
|
||||||
|
NestedStructT {
|
||||||
|
a: self.a().into(),
|
||||||
|
b: self.b(),
|
||||||
|
c: self.c().into(),
|
||||||
|
d: self.d().into(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
pub struct NestedStructT {
|
||||||
|
pub a: [i32; 2],
|
||||||
|
pub b: TestEnum,
|
||||||
|
pub c: [TestEnum; 2],
|
||||||
|
pub d: [i64; 2],
|
||||||
|
}
|
||||||
|
impl Default for NestedStructT {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
a: [0; 2],
|
||||||
|
b: TestEnum::A,
|
||||||
|
c: ::flatbuffers::array_init(|_| Default::default()),
|
||||||
|
d: [0; 2],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl NestedStructT {
|
||||||
|
pub fn pack(&self) -> NestedStruct {
|
||||||
|
NestedStruct::new(
|
||||||
|
&self.a,
|
||||||
|
self.b,
|
||||||
|
&self.c,
|
||||||
|
&self.d,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// struct ArrayStruct, aligned to 8
|
||||||
|
#[repr(transparent)]
|
||||||
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
|
pub struct ArrayStruct(pub [u8; 160]);
|
||||||
|
impl Default for ArrayStruct {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self([0; 160])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl ::core::fmt::Debug for ArrayStruct {
|
||||||
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
|
f.debug_struct("ArrayStruct")
|
||||||
|
.field("a", &self.a())
|
||||||
|
.field("b", &self.b())
|
||||||
|
.field("c", &self.c())
|
||||||
|
.field("d", &self.d())
|
||||||
|
.field("e", &self.e())
|
||||||
|
.field("f", &self.f())
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::flatbuffers::SimpleToVerifyInSlice for ArrayStruct {}
|
||||||
|
impl<'a> ::flatbuffers::Follow<'a> for ArrayStruct {
|
||||||
|
type Inner = &'a ArrayStruct;
|
||||||
|
#[inline]
|
||||||
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
|
unsafe { <&'a ArrayStruct>::follow(buf, loc) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<'a> ::flatbuffers::Follow<'a> for &'a ArrayStruct {
|
||||||
|
type Inner = &'a ArrayStruct;
|
||||||
|
#[inline]
|
||||||
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
|
unsafe { ::flatbuffers::follow_cast_ref::<ArrayStruct>(buf, loc) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<'b> ::flatbuffers::Push for ArrayStruct {
|
||||||
|
type Output = ArrayStruct;
|
||||||
|
#[inline]
|
||||||
|
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||||
|
let src = unsafe { ::core::slice::from_raw_parts(self as *const ArrayStruct as *const u8, <Self as ::flatbuffers::Push>::size()) };
|
||||||
|
dst.copy_from_slice(src);
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
fn alignment() -> ::flatbuffers::PushAlignment {
|
||||||
|
::flatbuffers::PushAlignment::new(8)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> ::flatbuffers::Verifiable for ArrayStruct {
|
||||||
|
#[inline]
|
||||||
|
fn run_verifier(
|
||||||
|
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||||
|
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||||
|
v.in_buffer::<Self>(pos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> ArrayStruct {
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
pub fn new(
|
||||||
|
a: f32,
|
||||||
|
b: &[i32; 15],
|
||||||
|
c: i8,
|
||||||
|
d: &[NestedStruct; 2],
|
||||||
|
e: i32,
|
||||||
|
f: &[i64; 2],
|
||||||
|
) -> Self {
|
||||||
|
let mut s = Self([0; 160]);
|
||||||
|
s.set_a(a);
|
||||||
|
s.set_b(b);
|
||||||
|
s.set_c(c);
|
||||||
|
s.set_d(d);
|
||||||
|
s.set_e(e);
|
||||||
|
s.set_f(f);
|
||||||
|
s
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn a(&self) -> f32 {
|
||||||
|
let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid value in this slot
|
||||||
|
::flatbuffers::EndianScalar::from_little_endian(unsafe {
|
||||||
|
::core::ptr::copy_nonoverlapping(
|
||||||
|
self.0[0..].as_ptr(),
|
||||||
|
mem.as_mut_ptr() as *mut u8,
|
||||||
|
::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||||
|
);
|
||||||
|
mem.assume_init()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_a(&mut self, x: f32) {
|
||||||
|
let x_le = ::flatbuffers::EndianScalar::to_little_endian(x);
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid value in this slot
|
||||||
|
unsafe {
|
||||||
|
::core::ptr::copy_nonoverlapping(
|
||||||
|
&x_le as *const _ as *const u8,
|
||||||
|
self.0[0..].as_mut_ptr(),
|
||||||
|
::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn b(&'a self) -> ::flatbuffers::Array<'a, i32, 15> {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
use ::flatbuffers::Follow;
|
||||||
|
unsafe { ::flatbuffers::Array::follow(&self.0, 4) }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_b(&mut self, items: &[i32; 15]) {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 4, items) };
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn c(&self) -> i8 {
|
||||||
|
let mut mem = ::core::mem::MaybeUninit::<<i8 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid value in this slot
|
||||||
|
::flatbuffers::EndianScalar::from_little_endian(unsafe {
|
||||||
|
::core::ptr::copy_nonoverlapping(
|
||||||
|
self.0[64..].as_ptr(),
|
||||||
|
mem.as_mut_ptr() as *mut u8,
|
||||||
|
::core::mem::size_of::<<i8 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||||
|
);
|
||||||
|
mem.assume_init()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_c(&mut self, x: i8) {
|
||||||
|
let x_le = ::flatbuffers::EndianScalar::to_little_endian(x);
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid value in this slot
|
||||||
|
unsafe {
|
||||||
|
::core::ptr::copy_nonoverlapping(
|
||||||
|
&x_le as *const _ as *const u8,
|
||||||
|
self.0[64..].as_mut_ptr(),
|
||||||
|
::core::mem::size_of::<<i8 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn d(&'a self) -> ::flatbuffers::Array<'a, NestedStruct, 2> {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
use ::flatbuffers::Follow;
|
||||||
|
unsafe { ::flatbuffers::Array::follow(&self.0, 72) }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_d(&mut self, x: &[NestedStruct; 2]) {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
unsafe {
|
||||||
|
::core::ptr::copy(
|
||||||
|
x.as_ptr() as *const u8,
|
||||||
|
self.0.as_mut_ptr().add(72),
|
||||||
|
64,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn e(&self) -> i32 {
|
||||||
|
let mut mem = ::core::mem::MaybeUninit::<<i32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid value in this slot
|
||||||
|
::flatbuffers::EndianScalar::from_little_endian(unsafe {
|
||||||
|
::core::ptr::copy_nonoverlapping(
|
||||||
|
self.0[136..].as_ptr(),
|
||||||
|
mem.as_mut_ptr() as *mut u8,
|
||||||
|
::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||||
|
);
|
||||||
|
mem.assume_init()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_e(&mut self, x: i32) {
|
||||||
|
let x_le = ::flatbuffers::EndianScalar::to_little_endian(x);
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid value in this slot
|
||||||
|
unsafe {
|
||||||
|
::core::ptr::copy_nonoverlapping(
|
||||||
|
&x_le as *const _ as *const u8,
|
||||||
|
self.0[136..].as_mut_ptr(),
|
||||||
|
::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn f(&'a self) -> ::flatbuffers::Array<'a, i64, 2> {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
use ::flatbuffers::Follow;
|
||||||
|
unsafe { ::flatbuffers::Array::follow(&self.0, 144) }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_f(&mut self, items: &[i64; 2]) {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 144, items) };
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unpack(&self) -> ArrayStructT {
|
||||||
|
ArrayStructT {
|
||||||
|
a: self.a(),
|
||||||
|
b: self.b().into(),
|
||||||
|
c: self.c(),
|
||||||
|
d: { let d = self.d(); ::flatbuffers::array_init(|i| d.get(i).unpack()) },
|
||||||
|
e: self.e(),
|
||||||
|
f: self.f().into(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
pub struct ArrayStructT {
|
||||||
|
pub a: f32,
|
||||||
|
pub b: [i32; 15],
|
||||||
|
pub c: i8,
|
||||||
|
pub d: [NestedStructT; 2],
|
||||||
|
pub e: i32,
|
||||||
|
pub f: [i64; 2],
|
||||||
|
}
|
||||||
|
impl Default for ArrayStructT {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
a: 0.0,
|
||||||
|
b: [0; 15],
|
||||||
|
c: 0,
|
||||||
|
d: ::flatbuffers::array_init(|_| Default::default()),
|
||||||
|
e: 0,
|
||||||
|
f: [0; 2],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl ArrayStructT {
|
||||||
|
pub fn pack(&self) -> ArrayStruct {
|
||||||
|
ArrayStruct::new(
|
||||||
|
self.a,
|
||||||
|
&self.b,
|
||||||
|
self.c,
|
||||||
|
&::flatbuffers::array_init(|i| self.d[i].pack()),
|
||||||
|
self.e,
|
||||||
|
&self.f,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// struct LargeArrayStruct, aligned to 4
|
||||||
|
#[repr(transparent)]
|
||||||
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
|
pub struct LargeArrayStruct(pub [u8; 384]);
|
||||||
|
impl Default for LargeArrayStruct {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self([0; 384])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl ::core::fmt::Debug for LargeArrayStruct {
|
||||||
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
|
f.debug_struct("LargeArrayStruct")
|
||||||
|
.field("d", &self.d())
|
||||||
|
.field("e", &self.e())
|
||||||
|
.field("f", &self.f())
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::flatbuffers::SimpleToVerifyInSlice for LargeArrayStruct {}
|
||||||
|
impl<'a> ::flatbuffers::Follow<'a> for LargeArrayStruct {
|
||||||
|
type Inner = &'a LargeArrayStruct;
|
||||||
|
#[inline]
|
||||||
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
|
unsafe { <&'a LargeArrayStruct>::follow(buf, loc) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<'a> ::flatbuffers::Follow<'a> for &'a LargeArrayStruct {
|
||||||
|
type Inner = &'a LargeArrayStruct;
|
||||||
|
#[inline]
|
||||||
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
|
unsafe { ::flatbuffers::follow_cast_ref::<LargeArrayStruct>(buf, loc) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<'b> ::flatbuffers::Push for LargeArrayStruct {
|
||||||
|
type Output = LargeArrayStruct;
|
||||||
|
#[inline]
|
||||||
|
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||||
|
let src = unsafe { ::core::slice::from_raw_parts(self as *const LargeArrayStruct as *const u8, <Self as ::flatbuffers::Push>::size()) };
|
||||||
|
dst.copy_from_slice(src);
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
fn alignment() -> ::flatbuffers::PushAlignment {
|
||||||
|
::flatbuffers::PushAlignment::new(4)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> ::flatbuffers::Verifiable for LargeArrayStruct {
|
||||||
|
#[inline]
|
||||||
|
fn run_verifier(
|
||||||
|
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||||
|
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||||
|
v.in_buffer::<Self>(pos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> LargeArrayStruct {
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
pub fn new(
|
||||||
|
d: &[u8; 64],
|
||||||
|
e: &[f32; 64],
|
||||||
|
f: &[bool; 64],
|
||||||
|
) -> Self {
|
||||||
|
let mut s = Self([0; 384]);
|
||||||
|
s.set_d(d);
|
||||||
|
s.set_e(e);
|
||||||
|
s.set_f(f);
|
||||||
|
s
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn d(&'a self) -> ::flatbuffers::Array<'a, u8, 64> {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
use ::flatbuffers::Follow;
|
||||||
|
unsafe { ::flatbuffers::Array::follow(&self.0, 0) }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_d(&mut self, items: &[u8; 64]) {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 0, items) };
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn e(&'a self) -> ::flatbuffers::Array<'a, f32, 64> {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
use ::flatbuffers::Follow;
|
||||||
|
unsafe { ::flatbuffers::Array::follow(&self.0, 64) }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_e(&mut self, items: &[f32; 64]) {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 64, items) };
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn f(&'a self) -> ::flatbuffers::Array<'a, bool, 64> {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
use ::flatbuffers::Follow;
|
||||||
|
unsafe { ::flatbuffers::Array::follow(&self.0, 320) }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_f(&mut self, items: &[bool; 64]) {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 320, items) };
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unpack(&self) -> LargeArrayStructT {
|
||||||
|
LargeArrayStructT {
|
||||||
|
d: self.d().into(),
|
||||||
|
e: self.e().into(),
|
||||||
|
f: self.f().into(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
pub struct LargeArrayStructT {
|
||||||
|
pub d: [u8; 64],
|
||||||
|
pub e: [f32; 64],
|
||||||
|
pub f: [bool; 64],
|
||||||
|
}
|
||||||
|
impl Default for LargeArrayStructT {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
d: [0; 64],
|
||||||
|
e: [0.0; 64],
|
||||||
|
f: [false; 64],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl LargeArrayStructT {
|
||||||
|
pub fn pack(&self) -> LargeArrayStruct {
|
||||||
|
LargeArrayStruct::new(
|
||||||
|
&self.d,
|
||||||
|
&self.e,
|
||||||
|
&self.f,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum ArrayTableOffset {}
|
||||||
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
|
|
||||||
|
pub struct ArrayTable<'a> {
|
||||||
|
pub _tab: ::flatbuffers::Table<'a>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> ::flatbuffers::Follow<'a> for ArrayTable<'a> {
|
||||||
|
type Inner = ArrayTable<'a>;
|
||||||
|
#[inline]
|
||||||
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
|
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> ArrayTable<'a> {
|
||||||
|
pub const VT_A: ::flatbuffers::VOffsetT = 4;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||||
|
ArrayTable { _tab: table }
|
||||||
|
}
|
||||||
|
#[allow(unused_mut)]
|
||||||
|
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||||
|
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||||
|
args: &'args ArrayTableArgs<'args>
|
||||||
|
) -> ::flatbuffers::WIPOffset<ArrayTable<'bldr>> {
|
||||||
|
let mut builder = ArrayTableBuilder::new(_fbb);
|
||||||
|
if let Some(x) = args.a { builder.add_a(x); }
|
||||||
|
builder.finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unpack(&self) -> ArrayTableT {
|
||||||
|
let a = self.a().map(|x| {
|
||||||
|
x.unpack()
|
||||||
|
});
|
||||||
|
ArrayTableT {
|
||||||
|
a,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn a(&self) -> Option<&'a ArrayStruct> {
|
||||||
|
// Safety:
|
||||||
|
// Created from valid Table for this object
|
||||||
|
// which contains a valid value in this slot
|
||||||
|
unsafe { self._tab.get::<ArrayStruct>(ArrayTable::VT_A, None)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::flatbuffers::Verifiable for ArrayTable<'_> {
|
||||||
|
#[inline]
|
||||||
|
fn run_verifier(
|
||||||
|
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||||
|
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||||
|
v.visit_table(pos)?
|
||||||
|
.visit_field::<ArrayStruct>("a", Self::VT_A, false)?
|
||||||
|
.finish();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub struct ArrayTableArgs<'a> {
|
||||||
|
pub a: Option<&'a ArrayStruct>,
|
||||||
|
}
|
||||||
|
impl<'a> Default for ArrayTableArgs<'a> {
|
||||||
|
#[inline]
|
||||||
|
fn default() -> Self {
|
||||||
|
ArrayTableArgs {
|
||||||
|
a: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct ArrayTableBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
|
||||||
|
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
|
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
||||||
|
}
|
||||||
|
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ArrayTableBuilder<'a, 'b, A> {
|
||||||
|
#[inline]
|
||||||
|
pub fn add_a(&mut self, a: &ArrayStruct) {
|
||||||
|
self.fbb_.push_slot_always::<&ArrayStruct>(ArrayTable::VT_A, a);
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ArrayTableBuilder<'a, 'b, A> {
|
||||||
|
let start = _fbb.start_table();
|
||||||
|
ArrayTableBuilder {
|
||||||
|
fbb_: _fbb,
|
||||||
|
start_: start,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn finish(self) -> ::flatbuffers::WIPOffset<ArrayTable<'a>> {
|
||||||
|
let o = self.fbb_.end_table(self.start_);
|
||||||
|
::flatbuffers::WIPOffset::new(o.value())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::core::fmt::Debug for ArrayTable<'_> {
|
||||||
|
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
||||||
|
let mut ds = f.debug_struct("ArrayTable");
|
||||||
|
ds.field("a", &self.a());
|
||||||
|
ds.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[non_exhaustive]
|
||||||
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
pub struct ArrayTableT {
|
||||||
|
pub a: Option<ArrayStructT>,
|
||||||
|
}
|
||||||
|
impl Default for ArrayTableT {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
a: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl ArrayTableT {
|
||||||
|
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
||||||
|
&self,
|
||||||
|
_fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
|
||||||
|
) -> ::flatbuffers::WIPOffset<ArrayTable<'b>> {
|
||||||
|
let a_tmp = self.a.as_ref().map(|x| x.pack());
|
||||||
|
let a = a_tmp.as_ref();
|
||||||
|
ArrayTable::create(_fbb, &ArrayTableArgs{
|
||||||
|
a,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
/// Verifies that a buffer of bytes contains a `ArrayTable`
|
||||||
|
/// and returns it.
|
||||||
|
/// Note that verification is still experimental and may not
|
||||||
|
/// catch every error, or be maximally performant. For the
|
||||||
|
/// previous, unchecked, behavior use
|
||||||
|
/// `root_as_array_table_unchecked`.
|
||||||
|
pub fn root_as_array_table(buf: &[u8]) -> Result<ArrayTable<'_>, ::flatbuffers::InvalidFlatbuffer> {
|
||||||
|
::flatbuffers::root::<ArrayTable>(buf)
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
/// Verifies that a buffer of bytes contains a size prefixed
|
||||||
|
/// `ArrayTable` and returns it.
|
||||||
|
/// Note that verification is still experimental and may not
|
||||||
|
/// catch every error, or be maximally performant. For the
|
||||||
|
/// previous, unchecked, behavior use
|
||||||
|
/// `size_prefixed_root_as_array_table_unchecked`.
|
||||||
|
pub fn size_prefixed_root_as_array_table(buf: &[u8]) -> Result<ArrayTable<'_>, ::flatbuffers::InvalidFlatbuffer> {
|
||||||
|
::flatbuffers::size_prefixed_root::<ArrayTable>(buf)
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
/// Verifies, with the given options, that a buffer of bytes
|
||||||
|
/// contains a `ArrayTable` and returns it.
|
||||||
|
/// Note that verification is still experimental and may not
|
||||||
|
/// catch every error, or be maximally performant. For the
|
||||||
|
/// previous, unchecked, behavior use
|
||||||
|
/// `root_as_array_table_unchecked`.
|
||||||
|
pub fn root_as_array_table_with_opts<'b, 'o>(
|
||||||
|
opts: &'o ::flatbuffers::VerifierOptions,
|
||||||
|
buf: &'b [u8],
|
||||||
|
) -> Result<ArrayTable<'b>, ::flatbuffers::InvalidFlatbuffer> {
|
||||||
|
::flatbuffers::root_with_opts::<ArrayTable<'b>>(opts, buf)
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
/// Verifies, with the given verifier options, that a buffer of
|
||||||
|
/// bytes contains a size prefixed `ArrayTable` and returns
|
||||||
|
/// it. Note that verification is still experimental and may not
|
||||||
|
/// catch every error, or be maximally performant. For the
|
||||||
|
/// previous, unchecked, behavior use
|
||||||
|
/// `root_as_array_table_unchecked`.
|
||||||
|
pub fn size_prefixed_root_as_array_table_with_opts<'b, 'o>(
|
||||||
|
opts: &'o ::flatbuffers::VerifierOptions,
|
||||||
|
buf: &'b [u8],
|
||||||
|
) -> Result<ArrayTable<'b>, ::flatbuffers::InvalidFlatbuffer> {
|
||||||
|
::flatbuffers::size_prefixed_root_with_opts::<ArrayTable<'b>>(opts, buf)
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
/// Assumes, without verification, that a buffer of bytes contains a ArrayTable and returns it.
|
||||||
|
/// # Safety
|
||||||
|
/// Callers must trust the given bytes do indeed contain a valid `ArrayTable`.
|
||||||
|
pub unsafe fn root_as_array_table_unchecked(buf: &[u8]) -> ArrayTable<'_> {
|
||||||
|
unsafe { ::flatbuffers::root_unchecked::<ArrayTable>(buf) }
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
/// Assumes, without verification, that a buffer of bytes contains a size prefixed ArrayTable and returns it.
|
||||||
|
/// # Safety
|
||||||
|
/// Callers must trust the given bytes do indeed contain a valid size prefixed `ArrayTable`.
|
||||||
|
pub unsafe fn size_prefixed_root_as_array_table_unchecked(buf: &[u8]) -> ArrayTable<'_> {
|
||||||
|
unsafe { ::flatbuffers::size_prefixed_root_unchecked::<ArrayTable>(buf) }
|
||||||
|
}
|
||||||
|
pub const ARRAY_TABLE_IDENTIFIER: &str = "ARRT";
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn array_table_buffer_has_identifier(buf: &[u8]) -> bool {
|
||||||
|
::flatbuffers::buffer_has_identifier(buf, ARRAY_TABLE_IDENTIFIER, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn array_table_size_prefixed_buffer_has_identifier(buf: &[u8]) -> bool {
|
||||||
|
::flatbuffers::buffer_has_identifier(buf, ARRAY_TABLE_IDENTIFIER, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const ARRAY_TABLE_EXTENSION: &str = "mon";
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn finish_array_table_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
|
||||||
|
fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
|
root: ::flatbuffers::WIPOffset<ArrayTable<'a>>) {
|
||||||
|
fbb.finish(root, Some(ARRAY_TABLE_IDENTIFIER));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn finish_size_prefixed_array_table_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, root: ::flatbuffers::WIPOffset<ArrayTable<'a>>) {
|
||||||
|
fbb.finish_size_prefixed(root, Some(ARRAY_TABLE_IDENTIFIER));
|
||||||
|
}
|
||||||
|
} // pub mod Example
|
||||||
|
} // pub mod MyGame
|
||||||
|
|
||||||
@@ -10,6 +10,8 @@ pub mod my_game {
|
|||||||
pub use self::nested_struct_generated::*;
|
pub use self::nested_struct_generated::*;
|
||||||
mod array_struct_generated;
|
mod array_struct_generated;
|
||||||
pub use self::array_struct_generated::*;
|
pub use self::array_struct_generated::*;
|
||||||
|
mod large_array_struct_generated;
|
||||||
|
pub use self::large_array_struct_generated::*;
|
||||||
mod array_table_generated;
|
mod array_table_generated;
|
||||||
pub use self::array_table_generated::*;
|
pub use self::array_table_generated::*;
|
||||||
} // example
|
} // example
|
||||||
|
|||||||
@@ -2,15 +2,18 @@
|
|||||||
// @generated
|
// @generated
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
// struct ArrayStruct, aligned to 8
|
// struct ArrayStruct, aligned to 8
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Clone, Copy, PartialEq)]
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
pub struct ArrayStruct(pub [u8; 160]);
|
pub struct ArrayStruct(pub [u8; 160]);
|
||||||
|
|
||||||
impl Default for ArrayStruct {
|
impl Default for ArrayStruct {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self([0; 160])
|
Self([0; 160])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::fmt::Debug for ArrayStruct {
|
impl ::core::fmt::Debug for ArrayStruct {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
f.debug_struct("ArrayStruct")
|
f.debug_struct("ArrayStruct")
|
||||||
@@ -25,27 +28,34 @@ impl ::core::fmt::Debug for ArrayStruct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ::flatbuffers::SimpleToVerifyInSlice for ArrayStruct {}
|
impl ::flatbuffers::SimpleToVerifyInSlice for ArrayStruct {}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for ArrayStruct {
|
impl<'a> ::flatbuffers::Follow<'a> for ArrayStruct {
|
||||||
type Inner = &'a ArrayStruct;
|
type Inner = &'a ArrayStruct;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
unsafe { <&'a ArrayStruct>::follow(buf, loc) }
|
unsafe { <&'a ArrayStruct>::follow(buf, loc) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for &'a ArrayStruct {
|
impl<'a> ::flatbuffers::Follow<'a> for &'a ArrayStruct {
|
||||||
type Inner = &'a ArrayStruct;
|
type Inner = &'a ArrayStruct;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
unsafe { ::flatbuffers::follow_cast_ref::<ArrayStruct>(buf, loc) }
|
unsafe { ::flatbuffers::follow_cast_ref::<ArrayStruct>(buf, loc) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'b> ::flatbuffers::Push for ArrayStruct {
|
impl<'b> ::flatbuffers::Push for ArrayStruct {
|
||||||
type Output = ArrayStruct;
|
type Output = ArrayStruct;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||||
let src = unsafe { ::core::slice::from_raw_parts(self as *const ArrayStruct as *const u8, <Self as ::flatbuffers::Push>::size()) };
|
let src = unsafe { ::core::slice::from_raw_parts(self as *const ArrayStruct as *const u8, <Self as ::flatbuffers::Push>::size()) };
|
||||||
dst.copy_from_slice(src);
|
dst.copy_from_slice(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn alignment() -> ::flatbuffers::PushAlignment {
|
fn alignment() -> ::flatbuffers::PushAlignment {
|
||||||
::flatbuffers::PushAlignment::new(8)
|
::flatbuffers::PushAlignment::new(8)
|
||||||
@@ -235,7 +245,7 @@ impl<'a> ArrayStruct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct ArrayStructT {
|
pub struct ArrayStructT {
|
||||||
pub a: f32,
|
pub a: f32,
|
||||||
pub b: [i32; 15],
|
pub b: [i32; 15],
|
||||||
@@ -244,6 +254,19 @@ pub struct ArrayStructT {
|
|||||||
pub e: i32,
|
pub e: i32,
|
||||||
pub f: [i64; 2],
|
pub f: [i64; 2],
|
||||||
}
|
}
|
||||||
|
impl Default for ArrayStructT {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
a: 0.0,
|
||||||
|
b: [0; 15],
|
||||||
|
c: 0,
|
||||||
|
d: ::flatbuffers::array_init(|_| Default::default()),
|
||||||
|
e: 0,
|
||||||
|
f: [0; 2],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl ArrayStructT {
|
impl ArrayStructT {
|
||||||
pub fn pack(&self) -> ArrayStruct {
|
pub fn pack(&self) -> ArrayStruct {
|
||||||
ArrayStruct::new(
|
ArrayStruct::new(
|
||||||
@@ -256,4 +279,3 @@ impl ArrayStructT {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,15 +2,17 @@
|
|||||||
// @generated
|
// @generated
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use super::*;
|
use super::*;
|
||||||
pub enum ArrayTableOffset {}
|
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
|
||||||
|
|
||||||
|
pub enum ArrayTableOffset {}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
pub struct ArrayTable<'a> {
|
pub struct ArrayTable<'a> {
|
||||||
pub _tab: ::flatbuffers::Table<'a>,
|
pub _tab: ::flatbuffers::Table<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for ArrayTable<'a> {
|
impl<'a> ::flatbuffers::Follow<'a> for ArrayTable<'a> {
|
||||||
type Inner = ArrayTable<'a>;
|
type Inner = ArrayTable<'a>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||||
@@ -28,6 +30,7 @@ impl<'a> ArrayTable<'a> {
|
|||||||
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||||
ArrayTable { _tab: table }
|
ArrayTable { _tab: table }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||||
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||||
@@ -67,9 +70,11 @@ impl ::flatbuffers::Verifiable for ArrayTable<'_> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ArrayTableArgs<'a> {
|
pub struct ArrayTableArgs<'a> {
|
||||||
pub a: Option<&'a ArrayStruct>,
|
pub a: Option<&'a ArrayStruct>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Default for ArrayTableArgs<'a> {
|
impl<'a> Default for ArrayTableArgs<'a> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
@@ -83,11 +88,13 @@ pub struct ArrayTableBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
|
|||||||
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ArrayTableBuilder<'a, 'b, A> {
|
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ArrayTableBuilder<'a, 'b, A> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_a(&mut self, a: &ArrayStruct) {
|
pub fn add_a(&mut self, a: &ArrayStruct) {
|
||||||
self.fbb_.push_slot_always::<&ArrayStruct>(ArrayTable::VT_A, a);
|
self.fbb_.push_slot_always::<&ArrayStruct>(ArrayTable::VT_A, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ArrayTableBuilder<'a, 'b, A> {
|
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ArrayTableBuilder<'a, 'b, A> {
|
||||||
let start = _fbb.start_table();
|
let start = _fbb.start_table();
|
||||||
@@ -96,6 +103,7 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ArrayTableBuilder<'a, 'b, A>
|
|||||||
start_: start,
|
start_: start,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn finish(self) -> ::flatbuffers::WIPOffset<ArrayTable<'a>> {
|
pub fn finish(self) -> ::flatbuffers::WIPOffset<ArrayTable<'a>> {
|
||||||
let o = self.fbb_.end_table(self.start_);
|
let o = self.fbb_.end_table(self.start_);
|
||||||
@@ -110,11 +118,13 @@ impl ::core::fmt::Debug for ArrayTable<'_> {
|
|||||||
ds.finish()
|
ds.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct ArrayTableT {
|
pub struct ArrayTableT {
|
||||||
pub a: Option<ArrayStructT>,
|
pub a: Option<ArrayStructT>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ArrayTableT {
|
impl Default for ArrayTableT {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
@@ -122,6 +132,7 @@ impl Default for ArrayTableT {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ArrayTableT {
|
impl ArrayTableT {
|
||||||
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
||||||
&self,
|
&self,
|
||||||
@@ -134,66 +145,73 @@ impl ArrayTableT {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[inline]
|
|
||||||
/// Verifies that a buffer of bytes contains a `ArrayTable`
|
/// Verifies that a buffer of bytes contains a `ArrayTable`
|
||||||
/// and returns it.
|
/// and returns it.
|
||||||
/// Note that verification is still experimental and may not
|
/// Note that verification is still experimental and may not
|
||||||
/// catch every error, or be maximally performant. For the
|
/// catch every error, or be maximally performant. For the
|
||||||
/// previous, unchecked, behavior use
|
/// previous, unchecked, behavior use
|
||||||
/// `root_as_array_table_unchecked`.
|
/// `root_as_array_table_unchecked`.
|
||||||
|
#[inline]
|
||||||
pub fn root_as_array_table(buf: &[u8]) -> Result<ArrayTable<'_>, ::flatbuffers::InvalidFlatbuffer> {
|
pub fn root_as_array_table(buf: &[u8]) -> Result<ArrayTable<'_>, ::flatbuffers::InvalidFlatbuffer> {
|
||||||
::flatbuffers::root::<ArrayTable>(buf)
|
::flatbuffers::root::<ArrayTable>(buf)
|
||||||
}
|
}
|
||||||
#[inline]
|
|
||||||
/// Verifies that a buffer of bytes contains a size prefixed
|
/// Verifies that a buffer of bytes contains a size prefixed
|
||||||
/// `ArrayTable` and returns it.
|
/// `ArrayTable` and returns it.
|
||||||
/// Note that verification is still experimental and may not
|
/// Note that verification is still experimental and may not
|
||||||
/// catch every error, or be maximally performant. For the
|
/// catch every error, or be maximally performant. For the
|
||||||
/// previous, unchecked, behavior use
|
/// previous, unchecked, behavior use
|
||||||
/// `size_prefixed_root_as_array_table_unchecked`.
|
/// `size_prefixed_root_as_array_table_unchecked`.
|
||||||
|
#[inline]
|
||||||
pub fn size_prefixed_root_as_array_table(buf: &[u8]) -> Result<ArrayTable<'_>, ::flatbuffers::InvalidFlatbuffer> {
|
pub fn size_prefixed_root_as_array_table(buf: &[u8]) -> Result<ArrayTable<'_>, ::flatbuffers::InvalidFlatbuffer> {
|
||||||
::flatbuffers::size_prefixed_root::<ArrayTable>(buf)
|
::flatbuffers::size_prefixed_root::<ArrayTable>(buf)
|
||||||
}
|
}
|
||||||
#[inline]
|
|
||||||
/// Verifies, with the given options, that a buffer of bytes
|
/// Verifies, with the given options, that a buffer of bytes
|
||||||
/// contains a `ArrayTable` and returns it.
|
/// contains a `ArrayTable` and returns it.
|
||||||
/// Note that verification is still experimental and may not
|
/// Note that verification is still experimental and may not
|
||||||
/// catch every error, or be maximally performant. For the
|
/// catch every error, or be maximally performant. For the
|
||||||
/// previous, unchecked, behavior use
|
/// previous, unchecked, behavior use
|
||||||
/// `root_as_array_table_unchecked`.
|
/// `root_as_array_table_unchecked`.
|
||||||
|
#[inline]
|
||||||
pub fn root_as_array_table_with_opts<'b, 'o>(
|
pub fn root_as_array_table_with_opts<'b, 'o>(
|
||||||
opts: &'o ::flatbuffers::VerifierOptions,
|
opts: &'o ::flatbuffers::VerifierOptions,
|
||||||
buf: &'b [u8],
|
buf: &'b [u8],
|
||||||
) -> Result<ArrayTable<'b>, ::flatbuffers::InvalidFlatbuffer> {
|
) -> Result<ArrayTable<'b>, ::flatbuffers::InvalidFlatbuffer> {
|
||||||
::flatbuffers::root_with_opts::<ArrayTable<'b>>(opts, buf)
|
::flatbuffers::root_with_opts::<ArrayTable<'b>>(opts, buf)
|
||||||
}
|
}
|
||||||
#[inline]
|
|
||||||
/// Verifies, with the given verifier options, that a buffer of
|
/// Verifies, with the given verifier options, that a buffer of
|
||||||
/// bytes contains a size prefixed `ArrayTable` and returns
|
/// bytes contains a size prefixed `ArrayTable` and returns
|
||||||
/// it. Note that verification is still experimental and may not
|
/// it. Note that verification is still experimental and may not
|
||||||
/// catch every error, or be maximally performant. For the
|
/// catch every error, or be maximally performant. For the
|
||||||
/// previous, unchecked, behavior use
|
/// previous, unchecked, behavior use
|
||||||
/// `root_as_array_table_unchecked`.
|
/// `root_as_array_table_unchecked`.
|
||||||
|
#[inline]
|
||||||
pub fn size_prefixed_root_as_array_table_with_opts<'b, 'o>(
|
pub fn size_prefixed_root_as_array_table_with_opts<'b, 'o>(
|
||||||
opts: &'o ::flatbuffers::VerifierOptions,
|
opts: &'o ::flatbuffers::VerifierOptions,
|
||||||
buf: &'b [u8],
|
buf: &'b [u8],
|
||||||
) -> Result<ArrayTable<'b>, ::flatbuffers::InvalidFlatbuffer> {
|
) -> Result<ArrayTable<'b>, ::flatbuffers::InvalidFlatbuffer> {
|
||||||
::flatbuffers::size_prefixed_root_with_opts::<ArrayTable<'b>>(opts, buf)
|
::flatbuffers::size_prefixed_root_with_opts::<ArrayTable<'b>>(opts, buf)
|
||||||
}
|
}
|
||||||
#[inline]
|
|
||||||
/// Assumes, without verification, that a buffer of bytes contains a ArrayTable and returns it.
|
/// Assumes, without verification, that a buffer of bytes contains a ArrayTable and returns it.
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// Callers must trust the given bytes do indeed contain a valid `ArrayTable`.
|
/// Callers must trust the given bytes do indeed contain a valid `ArrayTable`.
|
||||||
|
#[inline]
|
||||||
pub unsafe fn root_as_array_table_unchecked(buf: &[u8]) -> ArrayTable<'_> {
|
pub unsafe fn root_as_array_table_unchecked(buf: &[u8]) -> ArrayTable<'_> {
|
||||||
unsafe { ::flatbuffers::root_unchecked::<ArrayTable>(buf) }
|
unsafe { ::flatbuffers::root_unchecked::<ArrayTable>(buf) }
|
||||||
}
|
}
|
||||||
#[inline]
|
|
||||||
/// Assumes, without verification, that a buffer of bytes contains a size prefixed ArrayTable and returns it.
|
/// Assumes, without verification, that a buffer of bytes contains a size prefixed ArrayTable and returns it.
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// Callers must trust the given bytes do indeed contain a valid size prefixed `ArrayTable`.
|
/// Callers must trust the given bytes do indeed contain a valid size prefixed `ArrayTable`.
|
||||||
|
#[inline]
|
||||||
pub unsafe fn size_prefixed_root_as_array_table_unchecked(buf: &[u8]) -> ArrayTable<'_> {
|
pub unsafe fn size_prefixed_root_as_array_table_unchecked(buf: &[u8]) -> ArrayTable<'_> {
|
||||||
unsafe { ::flatbuffers::size_prefixed_root_unchecked::<ArrayTable>(buf) }
|
unsafe { ::flatbuffers::size_prefixed_root_unchecked::<ArrayTable>(buf) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const ARRAY_TABLE_IDENTIFIER: &str = "ARRT";
|
pub const ARRAY_TABLE_IDENTIFIER: &str = "ARRT";
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@@ -211,11 +229,15 @@ pub const ARRAY_TABLE_EXTENSION: &str = "mon";
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn finish_array_table_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
|
pub fn finish_array_table_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
|
||||||
fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
root: ::flatbuffers::WIPOffset<ArrayTable<'a>>) {
|
root: ::flatbuffers::WIPOffset<ArrayTable<'a>>
|
||||||
|
) {
|
||||||
fbb.finish(root, Some(ARRAY_TABLE_IDENTIFIER));
|
fbb.finish(root, Some(ARRAY_TABLE_IDENTIFIER));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn finish_size_prefixed_array_table_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, root: ::flatbuffers::WIPOffset<ArrayTable<'a>>) {
|
pub fn finish_size_prefixed_array_table_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
|
||||||
|
fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
|
root: ::flatbuffers::WIPOffset<ArrayTable<'a>>
|
||||||
|
) {
|
||||||
fbb.finish_size_prefixed(root, Some(ARRAY_TABLE_IDENTIFIER));
|
fbb.finish_size_prefixed(root, Some(ARRAY_TABLE_IDENTIFIER));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,223 @@
|
|||||||
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
// @generated
|
||||||
|
extern crate alloc;
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
// struct LargeArrayStruct, aligned to 8
|
||||||
|
#[repr(transparent)]
|
||||||
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
|
pub struct LargeArrayStruct(pub [u8; 2496]);
|
||||||
|
|
||||||
|
impl Default for LargeArrayStruct {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self([0; 2496])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::core::fmt::Debug for LargeArrayStruct {
|
||||||
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
|
f.debug_struct("LargeArrayStruct")
|
||||||
|
.field("d", &self.d())
|
||||||
|
.field("e", &self.e())
|
||||||
|
.field("f", &self.f())
|
||||||
|
.field("g", &self.g())
|
||||||
|
.field("h", &self.h())
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::flatbuffers::SimpleToVerifyInSlice for LargeArrayStruct {}
|
||||||
|
|
||||||
|
impl<'a> ::flatbuffers::Follow<'a> for LargeArrayStruct {
|
||||||
|
type Inner = &'a LargeArrayStruct;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
|
unsafe { <&'a LargeArrayStruct>::follow(buf, loc) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> ::flatbuffers::Follow<'a> for &'a LargeArrayStruct {
|
||||||
|
type Inner = &'a LargeArrayStruct;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
|
unsafe { ::flatbuffers::follow_cast_ref::<LargeArrayStruct>(buf, loc) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'b> ::flatbuffers::Push for LargeArrayStruct {
|
||||||
|
type Output = LargeArrayStruct;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||||
|
let src = unsafe { ::core::slice::from_raw_parts(self as *const LargeArrayStruct as *const u8, <Self as ::flatbuffers::Push>::size()) };
|
||||||
|
dst.copy_from_slice(src);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn alignment() -> ::flatbuffers::PushAlignment {
|
||||||
|
::flatbuffers::PushAlignment::new(8)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> ::flatbuffers::Verifiable for LargeArrayStruct {
|
||||||
|
#[inline]
|
||||||
|
fn run_verifier(
|
||||||
|
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||||
|
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||||
|
v.in_buffer::<Self>(pos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> LargeArrayStruct {
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
pub fn new(
|
||||||
|
d: &[u8; 64],
|
||||||
|
e: &[f32; 64],
|
||||||
|
f: &[bool; 64],
|
||||||
|
g: &[NestedStruct; 64],
|
||||||
|
h: &[TestEnum; 64],
|
||||||
|
) -> Self {
|
||||||
|
let mut s = Self([0; 2496]);
|
||||||
|
s.set_d(d);
|
||||||
|
s.set_e(e);
|
||||||
|
s.set_f(f);
|
||||||
|
s.set_g(g);
|
||||||
|
s.set_h(h);
|
||||||
|
s
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const fn get_fully_qualified_name() -> &'static str {
|
||||||
|
"MyGame.Example.LargeArrayStruct"
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn d(&'a self) -> ::flatbuffers::Array<'a, u8, 64> {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
use ::flatbuffers::Follow;
|
||||||
|
unsafe { ::flatbuffers::Array::follow(&self.0, 0) }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_d(&mut self, items: &[u8; 64]) {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 0, items) };
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn e(&'a self) -> ::flatbuffers::Array<'a, f32, 64> {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
use ::flatbuffers::Follow;
|
||||||
|
unsafe { ::flatbuffers::Array::follow(&self.0, 64) }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_e(&mut self, items: &[f32; 64]) {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 64, items) };
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn f(&'a self) -> ::flatbuffers::Array<'a, bool, 64> {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
use ::flatbuffers::Follow;
|
||||||
|
unsafe { ::flatbuffers::Array::follow(&self.0, 320) }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_f(&mut self, items: &[bool; 64]) {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 320, items) };
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn g(&'a self) -> ::flatbuffers::Array<'a, NestedStruct, 64> {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
use ::flatbuffers::Follow;
|
||||||
|
unsafe { ::flatbuffers::Array::follow(&self.0, 384) }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_g(&mut self, x: &[NestedStruct; 64]) {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
unsafe {
|
||||||
|
::core::ptr::copy(
|
||||||
|
x.as_ptr() as *const u8,
|
||||||
|
self.0.as_mut_ptr().add(384),
|
||||||
|
2048,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn h(&'a self) -> ::flatbuffers::Array<'a, TestEnum, 64> {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
use ::flatbuffers::Follow;
|
||||||
|
unsafe { ::flatbuffers::Array::follow(&self.0, 2432) }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_h(&mut self, x: &[TestEnum; 64]) {
|
||||||
|
// Safety:
|
||||||
|
// Created from a valid Table for this object
|
||||||
|
// Which contains a valid array in this slot
|
||||||
|
unsafe {
|
||||||
|
::core::ptr::copy(
|
||||||
|
x.as_ptr() as *const u8,
|
||||||
|
self.0.as_mut_ptr().add(2432),
|
||||||
|
64,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unpack(&self) -> LargeArrayStructT {
|
||||||
|
LargeArrayStructT {
|
||||||
|
d: self.d().into(),
|
||||||
|
e: self.e().into(),
|
||||||
|
f: self.f().into(),
|
||||||
|
g: { let g = self.g(); ::flatbuffers::array_init(|i| g.get(i).unpack()) },
|
||||||
|
h: self.h().into(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
pub struct LargeArrayStructT {
|
||||||
|
pub d: [u8; 64],
|
||||||
|
pub e: [f32; 64],
|
||||||
|
pub f: [bool; 64],
|
||||||
|
pub g: [NestedStructT; 64],
|
||||||
|
pub h: [TestEnum; 64],
|
||||||
|
}
|
||||||
|
impl Default for LargeArrayStructT {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
d: [0; 64],
|
||||||
|
e: [0.0; 64],
|
||||||
|
f: [false; 64],
|
||||||
|
g: ::flatbuffers::array_init(|_| Default::default()),
|
||||||
|
h: ::flatbuffers::array_init(|_| Default::default()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl LargeArrayStructT {
|
||||||
|
pub fn pack(&self) -> LargeArrayStruct {
|
||||||
|
LargeArrayStruct::new(
|
||||||
|
&self.d,
|
||||||
|
&self.e,
|
||||||
|
&self.f,
|
||||||
|
&::flatbuffers::array_init(|i| self.g[i].pack()),
|
||||||
|
&self.h,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,15 +2,18 @@
|
|||||||
// @generated
|
// @generated
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
// struct NestedStruct, aligned to 8
|
// struct NestedStruct, aligned to 8
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Clone, Copy, PartialEq)]
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
pub struct NestedStruct(pub [u8; 32]);
|
pub struct NestedStruct(pub [u8; 32]);
|
||||||
|
|
||||||
impl Default for NestedStruct {
|
impl Default for NestedStruct {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self([0; 32])
|
Self([0; 32])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::fmt::Debug for NestedStruct {
|
impl ::core::fmt::Debug for NestedStruct {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
f.debug_struct("NestedStruct")
|
f.debug_struct("NestedStruct")
|
||||||
@@ -23,27 +26,34 @@ impl ::core::fmt::Debug for NestedStruct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ::flatbuffers::SimpleToVerifyInSlice for NestedStruct {}
|
impl ::flatbuffers::SimpleToVerifyInSlice for NestedStruct {}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for NestedStruct {
|
impl<'a> ::flatbuffers::Follow<'a> for NestedStruct {
|
||||||
type Inner = &'a NestedStruct;
|
type Inner = &'a NestedStruct;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
unsafe { <&'a NestedStruct>::follow(buf, loc) }
|
unsafe { <&'a NestedStruct>::follow(buf, loc) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for &'a NestedStruct {
|
impl<'a> ::flatbuffers::Follow<'a> for &'a NestedStruct {
|
||||||
type Inner = &'a NestedStruct;
|
type Inner = &'a NestedStruct;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
unsafe { ::flatbuffers::follow_cast_ref::<NestedStruct>(buf, loc) }
|
unsafe { ::flatbuffers::follow_cast_ref::<NestedStruct>(buf, loc) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'b> ::flatbuffers::Push for NestedStruct {
|
impl<'b> ::flatbuffers::Push for NestedStruct {
|
||||||
type Output = NestedStruct;
|
type Output = NestedStruct;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||||
let src = unsafe { ::core::slice::from_raw_parts(self as *const NestedStruct as *const u8, <Self as ::flatbuffers::Push>::size()) };
|
let src = unsafe { ::core::slice::from_raw_parts(self as *const NestedStruct as *const u8, <Self as ::flatbuffers::Push>::size()) };
|
||||||
dst.copy_from_slice(src);
|
dst.copy_from_slice(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn alignment() -> ::flatbuffers::PushAlignment {
|
fn alignment() -> ::flatbuffers::PushAlignment {
|
||||||
::flatbuffers::PushAlignment::new(8)
|
::flatbuffers::PushAlignment::new(8)
|
||||||
@@ -169,13 +179,24 @@ impl<'a> NestedStruct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct NestedStructT {
|
pub struct NestedStructT {
|
||||||
pub a: [i32; 2],
|
pub a: [i32; 2],
|
||||||
pub b: TestEnum,
|
pub b: TestEnum,
|
||||||
pub c: [TestEnum; 2],
|
pub c: [TestEnum; 2],
|
||||||
pub d: [i64; 2],
|
pub d: [i64; 2],
|
||||||
}
|
}
|
||||||
|
impl Default for NestedStructT {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
a: [0; 2],
|
||||||
|
b: TestEnum::A,
|
||||||
|
c: ::flatbuffers::array_init(|_| Default::default()),
|
||||||
|
d: [0; 2],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl NestedStructT {
|
impl NestedStructT {
|
||||||
pub fn pack(&self) -> NestedStruct {
|
pub fn pack(&self) -> NestedStruct {
|
||||||
NestedStruct::new(
|
NestedStruct::new(
|
||||||
@@ -186,4 +207,3 @@ impl NestedStructT {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,13 @@
|
|||||||
// @generated
|
// @generated
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
pub const ENUM_MIN_TEST_ENUM: i8 = 0;
|
pub const ENUM_MIN_TEST_ENUM: i8 = 0;
|
||||||
|
|
||||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
pub const ENUM_MAX_TEST_ENUM: i8 = 2;
|
pub const ENUM_MAX_TEST_ENUM: i8 = 2;
|
||||||
|
|
||||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub const ENUM_VALUES_TEST_ENUM: [TestEnum; 3] = [
|
pub const ENUM_VALUES_TEST_ENUM: [TestEnum; 3] = [
|
||||||
@@ -17,6 +20,7 @@ pub const ENUM_VALUES_TEST_ENUM: [TestEnum; 3] = [
|
|||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct TestEnum(pub i8);
|
pub struct TestEnum(pub i8);
|
||||||
|
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
impl TestEnum {
|
impl TestEnum {
|
||||||
pub const A: Self = Self(0);
|
pub const A: Self = Self(0);
|
||||||
@@ -30,6 +34,7 @@ impl TestEnum {
|
|||||||
Self::B,
|
Self::B,
|
||||||
Self::C,
|
Self::C,
|
||||||
];
|
];
|
||||||
|
|
||||||
/// Returns the variant's name or "" if unknown.
|
/// Returns the variant's name or "" if unknown.
|
||||||
pub fn variant_name(self) -> Option<&'static str> {
|
pub fn variant_name(self) -> Option<&'static str> {
|
||||||
match self {
|
match self {
|
||||||
@@ -40,6 +45,7 @@ impl TestEnum {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::fmt::Debug for TestEnum {
|
impl ::core::fmt::Debug for TestEnum {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
if let Some(name) = self.variant_name() {
|
if let Some(name) = self.variant_name() {
|
||||||
@@ -49,8 +55,10 @@ impl ::core::fmt::Debug for TestEnum {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for TestEnum {
|
impl<'a> ::flatbuffers::Follow<'a> for TestEnum {
|
||||||
type Inner = Self;
|
type Inner = Self;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
|
let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
|
||||||
@@ -60,6 +68,7 @@ impl<'a> ::flatbuffers::Follow<'a> for TestEnum {
|
|||||||
|
|
||||||
impl ::flatbuffers::Push for TestEnum {
|
impl ::flatbuffers::Push for TestEnum {
|
||||||
type Output = TestEnum;
|
type Output = TestEnum;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||||
unsafe { ::flatbuffers::emplace_scalar::<i8>(dst, self.0) };
|
unsafe { ::flatbuffers::emplace_scalar::<i8>(dst, self.0) };
|
||||||
@@ -68,10 +77,12 @@ impl ::flatbuffers::Push for TestEnum {
|
|||||||
|
|
||||||
impl ::flatbuffers::EndianScalar for TestEnum {
|
impl ::flatbuffers::EndianScalar for TestEnum {
|
||||||
type Scalar = i8;
|
type Scalar = i8;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_little_endian(self) -> i8 {
|
fn to_little_endian(self) -> i8 {
|
||||||
self.0.to_le()
|
self.0.to_le()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(clippy::wrong_self_convention)]
|
#[allow(clippy::wrong_self_convention)]
|
||||||
fn from_little_endian(v: i8) -> Self {
|
fn from_little_endian(v: i8) -> Self {
|
||||||
|
|||||||
@@ -3276,10 +3276,10 @@ inline ::flatbuffers::Offset<Monster> Monster::Pack(::flatbuffers::FlatBufferBui
|
|||||||
auto _test = _o->test.Pack(_fbb);
|
auto _test = _o->test.Pack(_fbb);
|
||||||
auto _test4 = _o->test4.size() ? _fbb.CreateVectorOfStructs(_o->test4) : 0;
|
auto _test4 = _o->test4.size() ? _fbb.CreateVectorOfStructs(_o->test4) : 0;
|
||||||
auto _testarrayofstring = _o->testarrayofstring.size() ? _fbb.CreateVectorOfStrings(_o->testarrayofstring) : 0;
|
auto _testarrayofstring = _o->testarrayofstring.size() ? _fbb.CreateVectorOfStrings(_o->testarrayofstring) : 0;
|
||||||
auto _testarrayoftables = _o->testarrayoftables.size() ? _fbb.CreateVector<::flatbuffers::Offset<MyGame::Example::Monster>> (_o->testarrayoftables.size(), [](size_t i, _VectorArgs *__va) { return CreateMonster(*__va->__fbb, __va->__o->testarrayoftables[i].get(), __va->__rehasher); }, &_va ) : 0;
|
auto _testarrayoftables = _o->testarrayoftables.size() ? _fbb.CreateVector<::flatbuffers::Offset<MyGame::Example::Monster>> (_o->testarrayoftables.size(), [](size_t i, _VectorArgs *__va) { return MyGame::Example::CreateMonster(*__va->__fbb, __va->__o->testarrayoftables[i].get(), __va->__rehasher); }, &_va ) : 0;
|
||||||
auto _enemy = _o->enemy ? CreateMonster(_fbb, _o->enemy.get(), _rehasher) : 0;
|
auto _enemy = _o->enemy ? MyGame::Example::CreateMonster(_fbb, _o->enemy.get(), _rehasher) : 0;
|
||||||
auto _testnestedflatbuffer = _o->testnestedflatbuffer.size() ? _fbb.CreateVector(_o->testnestedflatbuffer) : 0;
|
auto _testnestedflatbuffer = _o->testnestedflatbuffer.size() ? _fbb.CreateVector(_o->testnestedflatbuffer) : 0;
|
||||||
auto _testempty = _o->testempty ? CreateStat(_fbb, _o->testempty.get(), _rehasher) : 0;
|
auto _testempty = _o->testempty ? MyGame::Example::CreateStat(_fbb, _o->testempty.get(), _rehasher) : 0;
|
||||||
auto _testbool = _o->testbool;
|
auto _testbool = _o->testbool;
|
||||||
auto _testhashs32_fnv1 = _o->testhashs32_fnv1;
|
auto _testhashs32_fnv1 = _o->testhashs32_fnv1;
|
||||||
auto _testhashu32_fnv1 = _o->testhashu32_fnv1;
|
auto _testhashu32_fnv1 = _o->testhashu32_fnv1;
|
||||||
@@ -3299,11 +3299,11 @@ inline ::flatbuffers::Offset<Monster> Monster::Pack(::flatbuffers::FlatBufferBui
|
|||||||
auto _test5 = _o->test5.size() ? _fbb.CreateVectorOfStructs(_o->test5) : 0;
|
auto _test5 = _o->test5.size() ? _fbb.CreateVectorOfStructs(_o->test5) : 0;
|
||||||
auto _vector_of_longs = _o->vector_of_longs.size() ? _fbb.CreateVector(_o->vector_of_longs) : 0;
|
auto _vector_of_longs = _o->vector_of_longs.size() ? _fbb.CreateVector(_o->vector_of_longs) : 0;
|
||||||
auto _vector_of_doubles = _o->vector_of_doubles.size() ? _fbb.CreateVector(_o->vector_of_doubles) : 0;
|
auto _vector_of_doubles = _o->vector_of_doubles.size() ? _fbb.CreateVector(_o->vector_of_doubles) : 0;
|
||||||
auto _parent_namespace_test = _o->parent_namespace_test ? CreateInParentNamespace(_fbb, _o->parent_namespace_test.get(), _rehasher) : 0;
|
auto _parent_namespace_test = _o->parent_namespace_test ? MyGame::CreateInParentNamespace(_fbb, _o->parent_namespace_test.get(), _rehasher) : 0;
|
||||||
auto _vector_of_referrables = _o->vector_of_referrables.size() ? _fbb.CreateVector<::flatbuffers::Offset<MyGame::Example::Referrable>> (_o->vector_of_referrables.size(), [](size_t i, _VectorArgs *__va) { return CreateReferrable(*__va->__fbb, __va->__o->vector_of_referrables[i].get(), __va->__rehasher); }, &_va ) : 0;
|
auto _vector_of_referrables = _o->vector_of_referrables.size() ? _fbb.CreateVector<::flatbuffers::Offset<MyGame::Example::Referrable>> (_o->vector_of_referrables.size(), [](size_t i, _VectorArgs *__va) { return MyGame::Example::CreateReferrable(*__va->__fbb, __va->__o->vector_of_referrables[i].get(), __va->__rehasher); }, &_va ) : 0;
|
||||||
auto _single_weak_reference = _rehasher ? static_cast<uint64_t>((*_rehasher)(_o->single_weak_reference)) : 0;
|
auto _single_weak_reference = _rehasher ? static_cast<uint64_t>((*_rehasher)(_o->single_weak_reference)) : 0;
|
||||||
auto _vector_of_weak_references = _o->vector_of_weak_references.size() ? _fbb.CreateVector<uint64_t>(_o->vector_of_weak_references.size(), [](size_t i, _VectorArgs *__va) { return __va->__rehasher ? static_cast<uint64_t>((*__va->__rehasher)(__va->__o->vector_of_weak_references[i])) : 0; }, &_va ) : 0;
|
auto _vector_of_weak_references = _o->vector_of_weak_references.size() ? _fbb.CreateVector<uint64_t>(_o->vector_of_weak_references.size(), [](size_t i, _VectorArgs *__va) { return __va->__rehasher ? static_cast<uint64_t>((*__va->__rehasher)(__va->__o->vector_of_weak_references[i])) : 0; }, &_va ) : 0;
|
||||||
auto _vector_of_strong_referrables = _o->vector_of_strong_referrables.size() ? _fbb.CreateVector<::flatbuffers::Offset<MyGame::Example::Referrable>> (_o->vector_of_strong_referrables.size(), [](size_t i, _VectorArgs *__va) { return CreateReferrable(*__va->__fbb, __va->__o->vector_of_strong_referrables[i].get(), __va->__rehasher); }, &_va ) : 0;
|
auto _vector_of_strong_referrables = _o->vector_of_strong_referrables.size() ? _fbb.CreateVector<::flatbuffers::Offset<MyGame::Example::Referrable>> (_o->vector_of_strong_referrables.size(), [](size_t i, _VectorArgs *__va) { return MyGame::Example::CreateReferrable(*__va->__fbb, __va->__o->vector_of_strong_referrables[i].get(), __va->__rehasher); }, &_va ) : 0;
|
||||||
auto _co_owning_reference = _rehasher ? static_cast<uint64_t>((*_rehasher)(_o->co_owning_reference)) : 0;
|
auto _co_owning_reference = _rehasher ? static_cast<uint64_t>((*_rehasher)(_o->co_owning_reference)) : 0;
|
||||||
auto _vector_of_co_owning_references = _o->vector_of_co_owning_references.size() ? _fbb.CreateVector<uint64_t>(_o->vector_of_co_owning_references.size(), [](size_t i, _VectorArgs *__va) { return __va->__rehasher ? static_cast<uint64_t>((*__va->__rehasher)(__va->__o->vector_of_co_owning_references[i].get())) : 0; }, &_va ) : 0;
|
auto _vector_of_co_owning_references = _o->vector_of_co_owning_references.size() ? _fbb.CreateVector<uint64_t>(_o->vector_of_co_owning_references.size(), [](size_t i, _VectorArgs *__va) { return __va->__rehasher ? static_cast<uint64_t>((*__va->__rehasher)(__va->__o->vector_of_co_owning_references[i].get())) : 0; }, &_va ) : 0;
|
||||||
auto _non_owning_reference = _rehasher ? static_cast<uint64_t>((*_rehasher)(_o->non_owning_reference)) : 0;
|
auto _non_owning_reference = _rehasher ? static_cast<uint64_t>((*_rehasher)(_o->non_owning_reference)) : 0;
|
||||||
@@ -3315,7 +3315,7 @@ inline ::flatbuffers::Offset<Monster> Monster::Pack(::flatbuffers::FlatBufferBui
|
|||||||
auto _vector_of_enums = _o->vector_of_enums.size() ? _fbb.CreateVector(_o->vector_of_enums) : 0;
|
auto _vector_of_enums = _o->vector_of_enums.size() ? _fbb.CreateVector(_o->vector_of_enums) : 0;
|
||||||
auto _signed_enum = _o->signed_enum;
|
auto _signed_enum = _o->signed_enum;
|
||||||
auto _testrequirednestedflatbuffer = _o->testrequirednestedflatbuffer.size() ? _fbb.CreateVector(_o->testrequirednestedflatbuffer) : 0;
|
auto _testrequirednestedflatbuffer = _o->testrequirednestedflatbuffer.size() ? _fbb.CreateVector(_o->testrequirednestedflatbuffer) : 0;
|
||||||
auto _scalar_key_sorted_tables = _o->scalar_key_sorted_tables.size() ? _fbb.CreateVector<::flatbuffers::Offset<MyGame::Example::Stat>> (_o->scalar_key_sorted_tables.size(), [](size_t i, _VectorArgs *__va) { return CreateStat(*__va->__fbb, __va->__o->scalar_key_sorted_tables[i].get(), __va->__rehasher); }, &_va ) : 0;
|
auto _scalar_key_sorted_tables = _o->scalar_key_sorted_tables.size() ? _fbb.CreateVector<::flatbuffers::Offset<MyGame::Example::Stat>> (_o->scalar_key_sorted_tables.size(), [](size_t i, _VectorArgs *__va) { return MyGame::Example::CreateStat(*__va->__fbb, __va->__o->scalar_key_sorted_tables[i].get(), __va->__rehasher); }, &_va ) : 0;
|
||||||
auto _native_inline = &_o->native_inline;
|
auto _native_inline = &_o->native_inline;
|
||||||
auto _long_enum_non_enum_default = _o->long_enum_non_enum_default;
|
auto _long_enum_non_enum_default = _o->long_enum_non_enum_default;
|
||||||
auto _long_enum_normal_default = _o->long_enum_normal_default;
|
auto _long_enum_normal_default = _o->long_enum_normal_default;
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
native_include "cpp_vec_type_native_type_test_impl.h";
|
|
||||||
|
|
||||||
namespace CppVecNativeTypeTest;
|
|
||||||
|
|
||||||
struct Vec3 (native_type: "CppVecNativeTypeTest::Native::Vec3") {
|
|
||||||
x: float;
|
|
||||||
y: float;
|
|
||||||
z: float;
|
|
||||||
}
|
|
||||||
|
|
||||||
table Container {
|
|
||||||
points: [Vec3] (cpp_vec_type: "CppVecNativeTypeTest::CustomVec");
|
|
||||||
bytes: [ubyte] (cpp_vec_type: "CppVecNativeTypeTest::CustomVec");
|
|
||||||
}
|
|
||||||
|
|
||||||
root_type Container;
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#include "cpp_vec_type_native_type_test_impl.h"
|
|
||||||
|
|
||||||
#include "cpp_vec_type_native_type_test_generated.h"
|
|
||||||
|
|
||||||
namespace flatbuffers {
|
|
||||||
CppVecNativeTypeTest::Vec3 Pack(
|
|
||||||
const CppVecNativeTypeTest::Native::Vec3& obj) {
|
|
||||||
return CppVecNativeTypeTest::Vec3(obj.x, obj.y, obj.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
const CppVecNativeTypeTest::Native::Vec3 UnPack(
|
|
||||||
const CppVecNativeTypeTest::Vec3& obj) {
|
|
||||||
return CppVecNativeTypeTest::Native::Vec3(obj.x(), obj.y(), obj.z());
|
|
||||||
}
|
|
||||||
} // namespace flatbuffers
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
#ifndef CPP_VEC_TYPE_NATIVE_TYPE_TEST_IMPL_H
|
|
||||||
#define CPP_VEC_TYPE_NATIVE_TYPE_TEST_IMPL_H
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace CppVecNativeTypeTest {
|
|
||||||
|
|
||||||
namespace Native {
|
|
||||||
struct Vec3 {
|
|
||||||
float x, y, z;
|
|
||||||
Vec3() : x(0), y(0), z(0) {}
|
|
||||||
Vec3(float x_, float y_, float z_) : x(x_), y(y_), z(z_) {}
|
|
||||||
bool operator==(const Vec3& o) const {
|
|
||||||
return x == o.x && y == o.y && z == o.z;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} // namespace Native
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct CustomVec : public std::vector<T> {
|
|
||||||
using std::vector<T>::vector;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Vec3; // flatbuffers-generated struct
|
|
||||||
|
|
||||||
} // namespace CppVecNativeTypeTest
|
|
||||||
|
|
||||||
namespace flatbuffers {
|
|
||||||
CppVecNativeTypeTest::Vec3 Pack(const CppVecNativeTypeTest::Native::Vec3& obj);
|
|
||||||
const CppVecNativeTypeTest::Native::Vec3 UnPack(
|
|
||||||
const CppVecNativeTypeTest::Vec3& obj);
|
|
||||||
} // namespace flatbuffers
|
|
||||||
|
|
||||||
#endif // CPP_VEC_TYPE_NATIVE_TYPE_TEST_IMPL_H
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
native_include "cpp_vec_type_test_impl.h";
|
|
||||||
|
|
||||||
namespace CppVecTest;
|
|
||||||
|
|
||||||
table Item {
|
|
||||||
id: int;
|
|
||||||
value: float;
|
|
||||||
}
|
|
||||||
|
|
||||||
table Data {
|
|
||||||
values: [int] (cpp_vec_type: "CppVecTest::CustomVec");
|
|
||||||
items: [Item] (cpp_vec_type: "CppVecTest::CustomVec");
|
|
||||||
strs: [string] (cpp_vec_type: "CppVecTest::CustomVec");
|
|
||||||
regular: [int];
|
|
||||||
}
|
|
||||||
|
|
||||||
root_type Data;
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#ifndef CPP_VEC_TYPE_TEST_IMPL_H
|
|
||||||
#define CPP_VEC_TYPE_TEST_IMPL_H
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace CppVecTest {
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct CustomVec : public std::vector<T> {
|
|
||||||
using std::vector<T>::vector;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace CppVecTest
|
|
||||||
|
|
||||||
#endif // CPP_VEC_TYPE_TEST_IMPL_H
|
|
||||||
18
tests/cross_namespace_pack_test.fbs
Normal file
18
tests/cross_namespace_pack_test.fbs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
// Test for cross-namespace Pack() code generation (issue #8948).
|
||||||
|
// Verifies that Create* calls in Pack() are properly namespace-qualified
|
||||||
|
// when referencing tables from different namespaces.
|
||||||
|
|
||||||
|
namespace native;
|
||||||
|
|
||||||
|
table TableWithNative {
|
||||||
|
value: int;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace foo;
|
||||||
|
|
||||||
|
table Consumer {
|
||||||
|
c1: native.TableWithNative;
|
||||||
|
c2: [native.TableWithNative];
|
||||||
|
}
|
||||||
|
|
||||||
|
root_type Consumer;
|
||||||
23
tests/even_more_defaults.fbs
Normal file
23
tests/even_more_defaults.fbs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
|
||||||
|
enum ABC: int { A, B, C }
|
||||||
|
|
||||||
|
struct EvenMoreStruct {
|
||||||
|
g:[int64:2];
|
||||||
|
}
|
||||||
|
|
||||||
|
table EvenMoreDefaults {
|
||||||
|
str: EvenMoreStruct;
|
||||||
|
ints: [int] = [];
|
||||||
|
floats: [float] = [ ];
|
||||||
|
float_optional: [float];
|
||||||
|
bytes_optional: [ubyte];
|
||||||
|
floats_required: [float] (required);
|
||||||
|
empty_string: string = "";
|
||||||
|
some_string: string = "some";
|
||||||
|
zero_string: string = "0";
|
||||||
|
a_string:string (key);
|
||||||
|
required_string: string (required);
|
||||||
|
abcs: [ABC] = [];
|
||||||
|
bools: [bool] = [];
|
||||||
|
one_bool: bool = true;
|
||||||
|
}
|
||||||
@@ -2,10 +2,13 @@
|
|||||||
// @generated
|
// @generated
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
#[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;
|
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.")]
|
#[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;
|
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.")]
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
|
pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
|
||||||
@@ -15,6 +18,7 @@ pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
|
|||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct FromInclude(pub i64);
|
pub struct FromInclude(pub i64);
|
||||||
|
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
impl FromInclude {
|
impl FromInclude {
|
||||||
pub const IncludeVal: Self = Self(0);
|
pub const IncludeVal: Self = Self(0);
|
||||||
@@ -24,6 +28,7 @@ impl FromInclude {
|
|||||||
pub const ENUM_VALUES: &'static [Self] = &[
|
pub const ENUM_VALUES: &'static [Self] = &[
|
||||||
Self::IncludeVal,
|
Self::IncludeVal,
|
||||||
];
|
];
|
||||||
|
|
||||||
/// Returns the variant's name or "" if unknown.
|
/// Returns the variant's name or "" if unknown.
|
||||||
pub fn variant_name(self) -> Option<&'static str> {
|
pub fn variant_name(self) -> Option<&'static str> {
|
||||||
match self {
|
match self {
|
||||||
@@ -32,6 +37,7 @@ impl FromInclude {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::fmt::Debug for FromInclude {
|
impl ::core::fmt::Debug for FromInclude {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
if let Some(name) = self.variant_name() {
|
if let Some(name) = self.variant_name() {
|
||||||
@@ -41,8 +47,10 @@ impl ::core::fmt::Debug for FromInclude {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for FromInclude {
|
impl<'a> ::flatbuffers::Follow<'a> for FromInclude {
|
||||||
type Inner = Self;
|
type Inner = Self;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
let b = unsafe { ::flatbuffers::read_scalar_at::<i64>(buf, loc) };
|
let b = unsafe { ::flatbuffers::read_scalar_at::<i64>(buf, loc) };
|
||||||
@@ -52,6 +60,7 @@ impl<'a> ::flatbuffers::Follow<'a> for FromInclude {
|
|||||||
|
|
||||||
impl ::flatbuffers::Push for FromInclude {
|
impl ::flatbuffers::Push for FromInclude {
|
||||||
type Output = FromInclude;
|
type Output = FromInclude;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||||
unsafe { ::flatbuffers::emplace_scalar::<i64>(dst, self.0) };
|
unsafe { ::flatbuffers::emplace_scalar::<i64>(dst, self.0) };
|
||||||
@@ -60,10 +69,12 @@ impl ::flatbuffers::Push for FromInclude {
|
|||||||
|
|
||||||
impl ::flatbuffers::EndianScalar for FromInclude {
|
impl ::flatbuffers::EndianScalar for FromInclude {
|
||||||
type Scalar = i64;
|
type Scalar = i64;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_little_endian(self) -> i64 {
|
fn to_little_endian(self) -> i64 {
|
||||||
self.0.to_le()
|
self.0.to_le()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(clippy::wrong_self_convention)]
|
#[allow(clippy::wrong_self_convention)]
|
||||||
fn from_little_endian(v: i64) -> Self {
|
fn from_little_endian(v: i64) -> Self {
|
||||||
|
|||||||
@@ -2,15 +2,17 @@
|
|||||||
// @generated
|
// @generated
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use super::*;
|
use super::*;
|
||||||
pub enum TableBOffset {}
|
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
|
||||||
|
|
||||||
|
pub enum TableBOffset {}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
pub struct TableB<'a> {
|
pub struct TableB<'a> {
|
||||||
pub _tab: ::flatbuffers::Table<'a>,
|
pub _tab: ::flatbuffers::Table<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for TableB<'a> {
|
impl<'a> ::flatbuffers::Follow<'a> for TableB<'a> {
|
||||||
type Inner = TableB<'a>;
|
type Inner = TableB<'a>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||||
@@ -28,6 +30,7 @@ impl<'a> TableB<'a> {
|
|||||||
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||||
TableB { _tab: table }
|
TableB { _tab: table }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||||
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||||
@@ -67,9 +70,11 @@ impl ::flatbuffers::Verifiable for TableB<'_> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct TableBArgs<'a> {
|
pub struct TableBArgs<'a> {
|
||||||
pub a: Option<::flatbuffers::WIPOffset<super::super::TableA<'a>>>,
|
pub a: Option<::flatbuffers::WIPOffset<super::super::TableA<'a>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Default for TableBArgs<'a> {
|
impl<'a> Default for TableBArgs<'a> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
@@ -83,11 +88,13 @@ pub struct TableBBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
|
|||||||
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> {
|
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_a(&mut self, a: ::flatbuffers::WIPOffset<super::super::TableA<'b >>) {
|
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);
|
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::super::TableA>>(TableB::VT_A, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> {
|
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> {
|
||||||
let start = _fbb.start_table();
|
let start = _fbb.start_table();
|
||||||
@@ -96,6 +103,7 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> {
|
|||||||
start_: start,
|
start_: start,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
|
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
|
||||||
let o = self.fbb_.end_table(self.start_);
|
let o = self.fbb_.end_table(self.start_);
|
||||||
@@ -110,11 +118,13 @@ impl ::core::fmt::Debug for TableB<'_> {
|
|||||||
ds.finish()
|
ds.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct TableBT {
|
pub struct TableBT {
|
||||||
pub a: Option<alloc::boxed::Box<super::super::TableAT>>,
|
pub a: Option<alloc::boxed::Box<super::super::TableAT>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for TableBT {
|
impl Default for TableBT {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
@@ -122,6 +132,7 @@ impl Default for TableBT {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TableBT {
|
impl TableBT {
|
||||||
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
||||||
&self,
|
&self,
|
||||||
|
|||||||
@@ -2,15 +2,18 @@
|
|||||||
// @generated
|
// @generated
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
// struct Unused, aligned to 4
|
// struct Unused, aligned to 4
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Clone, Copy, PartialEq)]
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
pub struct Unused(pub [u8; 4]);
|
pub struct Unused(pub [u8; 4]);
|
||||||
|
|
||||||
impl Default for Unused {
|
impl Default for Unused {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self([0; 4])
|
Self([0; 4])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::fmt::Debug for Unused {
|
impl ::core::fmt::Debug for Unused {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
f.debug_struct("Unused")
|
f.debug_struct("Unused")
|
||||||
@@ -20,27 +23,34 @@ impl ::core::fmt::Debug for Unused {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ::flatbuffers::SimpleToVerifyInSlice for Unused {}
|
impl ::flatbuffers::SimpleToVerifyInSlice for Unused {}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for Unused {
|
impl<'a> ::flatbuffers::Follow<'a> for Unused {
|
||||||
type Inner = &'a Unused;
|
type Inner = &'a Unused;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
unsafe { <&'a Unused>::follow(buf, loc) }
|
unsafe { <&'a Unused>::follow(buf, loc) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for &'a Unused {
|
impl<'a> ::flatbuffers::Follow<'a> for &'a Unused {
|
||||||
type Inner = &'a Unused;
|
type Inner = &'a Unused;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
unsafe { ::flatbuffers::follow_cast_ref::<Unused>(buf, loc) }
|
unsafe { ::flatbuffers::follow_cast_ref::<Unused>(buf, loc) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'b> ::flatbuffers::Push for Unused {
|
impl<'b> ::flatbuffers::Push for Unused {
|
||||||
type Output = Unused;
|
type Output = Unused;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
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()) };
|
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);
|
dst.copy_from_slice(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn alignment() -> ::flatbuffers::PushAlignment {
|
fn alignment() -> ::flatbuffers::PushAlignment {
|
||||||
::flatbuffers::PushAlignment::new(4)
|
::flatbuffers::PushAlignment::new(4)
|
||||||
@@ -106,10 +116,18 @@ impl<'a> Unused {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct UnusedT {
|
pub struct UnusedT {
|
||||||
pub a: i32,
|
pub a: i32,
|
||||||
}
|
}
|
||||||
|
impl Default for UnusedT {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
a: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl UnusedT {
|
impl UnusedT {
|
||||||
pub fn pack(&self) -> Unused {
|
pub fn pack(&self) -> Unused {
|
||||||
Unused::new(
|
Unused::new(
|
||||||
@@ -117,4 +135,3 @@ impl UnusedT {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,15 +2,17 @@
|
|||||||
// @generated
|
// @generated
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use super::*;
|
use super::*;
|
||||||
pub enum TableAOffset {}
|
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
|
||||||
|
|
||||||
|
pub enum TableAOffset {}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
pub struct TableA<'a> {
|
pub struct TableA<'a> {
|
||||||
pub _tab: ::flatbuffers::Table<'a>,
|
pub _tab: ::flatbuffers::Table<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for TableA<'a> {
|
impl<'a> ::flatbuffers::Follow<'a> for TableA<'a> {
|
||||||
type Inner = TableA<'a>;
|
type Inner = TableA<'a>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||||
@@ -28,6 +30,7 @@ impl<'a> TableA<'a> {
|
|||||||
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||||
TableA { _tab: table }
|
TableA { _tab: table }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||||
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||||
@@ -67,9 +70,11 @@ impl ::flatbuffers::Verifiable for TableA<'_> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct TableAArgs<'a> {
|
pub struct TableAArgs<'a> {
|
||||||
pub b: Option<::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'a>>>,
|
pub b: Option<::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'a>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Default for TableAArgs<'a> {
|
impl<'a> Default for TableAArgs<'a> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
@@ -83,11 +88,13 @@ pub struct TableABuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
|
|||||||
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> {
|
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_b(&mut self, b: ::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'b >>) {
|
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);
|
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<my_game::other_name_space::TableB>>(TableA::VT_B, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> {
|
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> {
|
||||||
let start = _fbb.start_table();
|
let start = _fbb.start_table();
|
||||||
@@ -96,6 +103,7 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> {
|
|||||||
start_: start,
|
start_: start,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
|
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
|
||||||
let o = self.fbb_.end_table(self.start_);
|
let o = self.fbb_.end_table(self.start_);
|
||||||
@@ -110,11 +118,13 @@ impl ::core::fmt::Debug for TableA<'_> {
|
|||||||
ds.finish()
|
ds.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct TableAT {
|
pub struct TableAT {
|
||||||
pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
|
pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for TableAT {
|
impl Default for TableAT {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
@@ -122,6 +132,7 @@ impl Default for TableAT {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TableAT {
|
impl TableAT {
|
||||||
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
||||||
&self,
|
&self,
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
// 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;
|
||||||
|
|
||||||
pub enum TableAOffset {}
|
pub enum TableAOffset {}
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
pub struct TableA<'a> {
|
pub struct TableA<'a> {
|
||||||
pub _tab: ::flatbuffers::Table<'a>,
|
pub _tab: ::flatbuffers::Table<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for TableA<'a> {
|
impl<'a> ::flatbuffers::Follow<'a> for TableA<'a> {
|
||||||
type Inner = TableA<'a>;
|
type Inner = TableA<'a>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||||
@@ -29,6 +29,7 @@ impl<'a> TableA<'a> {
|
|||||||
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||||
TableA { _tab: table }
|
TableA { _tab: table }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||||
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||||
@@ -68,9 +69,11 @@ impl ::flatbuffers::Verifiable for TableA<'_> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct TableAArgs<'a> {
|
pub struct TableAArgs<'a> {
|
||||||
pub b: Option<::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'a>>>,
|
pub b: Option<::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'a>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Default for TableAArgs<'a> {
|
impl<'a> Default for TableAArgs<'a> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
@@ -84,11 +87,13 @@ pub struct TableABuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
|
|||||||
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> {
|
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_b(&mut self, b: ::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'b >>) {
|
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);
|
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<my_game::other_name_space::TableB>>(TableA::VT_B, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> {
|
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> {
|
||||||
let start = _fbb.start_table();
|
let start = _fbb.start_table();
|
||||||
@@ -97,6 +102,7 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> {
|
|||||||
start_: start,
|
start_: start,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
|
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
|
||||||
let o = self.fbb_.end_table(self.start_);
|
let o = self.fbb_.end_table(self.start_);
|
||||||
@@ -111,11 +117,13 @@ impl ::core::fmt::Debug for TableA<'_> {
|
|||||||
ds.finish()
|
ds.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct TableAT {
|
pub struct TableAT {
|
||||||
pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
|
pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for TableAT {
|
impl Default for TableAT {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
@@ -123,6 +131,7 @@ impl Default for TableAT {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TableAT {
|
impl TableAT {
|
||||||
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
||||||
&self,
|
&self,
|
||||||
@@ -136,19 +145,21 @@ impl TableAT {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_imports, dead_code)]
|
#[allow(unused_imports, dead_code)]
|
||||||
pub mod my_game {
|
pub mod my_game {
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
#[allow(unused_imports, dead_code)]
|
#[allow(unused_imports, dead_code)]
|
||||||
pub mod other_name_space {
|
pub mod other_name_space {
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
#[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;
|
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.")]
|
#[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;
|
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.")]
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
|
pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
|
||||||
@@ -158,6 +169,7 @@ pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
|
|||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct FromInclude(pub i64);
|
pub struct FromInclude(pub i64);
|
||||||
|
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
impl FromInclude {
|
impl FromInclude {
|
||||||
pub const IncludeVal: Self = Self(0);
|
pub const IncludeVal: Self = Self(0);
|
||||||
@@ -167,6 +179,7 @@ impl FromInclude {
|
|||||||
pub const ENUM_VALUES: &'static [Self] = &[
|
pub const ENUM_VALUES: &'static [Self] = &[
|
||||||
Self::IncludeVal,
|
Self::IncludeVal,
|
||||||
];
|
];
|
||||||
|
|
||||||
/// Returns the variant's name or "" if unknown.
|
/// Returns the variant's name or "" if unknown.
|
||||||
pub fn variant_name(self) -> Option<&'static str> {
|
pub fn variant_name(self) -> Option<&'static str> {
|
||||||
match self {
|
match self {
|
||||||
@@ -175,6 +188,7 @@ impl FromInclude {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::fmt::Debug for FromInclude {
|
impl ::core::fmt::Debug for FromInclude {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
if let Some(name) = self.variant_name() {
|
if let Some(name) = self.variant_name() {
|
||||||
@@ -184,8 +198,10 @@ impl ::core::fmt::Debug for FromInclude {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for FromInclude {
|
impl<'a> ::flatbuffers::Follow<'a> for FromInclude {
|
||||||
type Inner = Self;
|
type Inner = Self;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
let b = unsafe { ::flatbuffers::read_scalar_at::<i64>(buf, loc) };
|
let b = unsafe { ::flatbuffers::read_scalar_at::<i64>(buf, loc) };
|
||||||
@@ -195,6 +211,7 @@ impl<'a> ::flatbuffers::Follow<'a> for FromInclude {
|
|||||||
|
|
||||||
impl ::flatbuffers::Push for FromInclude {
|
impl ::flatbuffers::Push for FromInclude {
|
||||||
type Output = FromInclude;
|
type Output = FromInclude;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||||
unsafe { ::flatbuffers::emplace_scalar::<i64>(dst, self.0) };
|
unsafe { ::flatbuffers::emplace_scalar::<i64>(dst, self.0) };
|
||||||
@@ -203,10 +220,12 @@ impl ::flatbuffers::Push for FromInclude {
|
|||||||
|
|
||||||
impl ::flatbuffers::EndianScalar for FromInclude {
|
impl ::flatbuffers::EndianScalar for FromInclude {
|
||||||
type Scalar = i64;
|
type Scalar = i64;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_little_endian(self) -> i64 {
|
fn to_little_endian(self) -> i64 {
|
||||||
self.0.to_le()
|
self.0.to_le()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(clippy::wrong_self_convention)]
|
#[allow(clippy::wrong_self_convention)]
|
||||||
fn from_little_endian(v: i64) -> Self {
|
fn from_little_endian(v: i64) -> Self {
|
||||||
@@ -225,15 +244,18 @@ impl<'a> ::flatbuffers::Verifiable for FromInclude {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ::flatbuffers::SimpleToVerifyInSlice for FromInclude {}
|
impl ::flatbuffers::SimpleToVerifyInSlice for FromInclude {}
|
||||||
|
|
||||||
// struct Unused, aligned to 4
|
// struct Unused, aligned to 4
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Clone, Copy, PartialEq)]
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
pub struct Unused(pub [u8; 4]);
|
pub struct Unused(pub [u8; 4]);
|
||||||
|
|
||||||
impl Default for Unused {
|
impl Default for Unused {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self([0; 4])
|
Self([0; 4])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::fmt::Debug for Unused {
|
impl ::core::fmt::Debug for Unused {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
f.debug_struct("Unused")
|
f.debug_struct("Unused")
|
||||||
@@ -243,27 +265,34 @@ impl ::core::fmt::Debug for Unused {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ::flatbuffers::SimpleToVerifyInSlice for Unused {}
|
impl ::flatbuffers::SimpleToVerifyInSlice for Unused {}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for Unused {
|
impl<'a> ::flatbuffers::Follow<'a> for Unused {
|
||||||
type Inner = &'a Unused;
|
type Inner = &'a Unused;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
unsafe { <&'a Unused>::follow(buf, loc) }
|
unsafe { <&'a Unused>::follow(buf, loc) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for &'a Unused {
|
impl<'a> ::flatbuffers::Follow<'a> for &'a Unused {
|
||||||
type Inner = &'a Unused;
|
type Inner = &'a Unused;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
unsafe { ::flatbuffers::follow_cast_ref::<Unused>(buf, loc) }
|
unsafe { ::flatbuffers::follow_cast_ref::<Unused>(buf, loc) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'b> ::flatbuffers::Push for Unused {
|
impl<'b> ::flatbuffers::Push for Unused {
|
||||||
type Output = Unused;
|
type Output = Unused;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
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()) };
|
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);
|
dst.copy_from_slice(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn alignment() -> ::flatbuffers::PushAlignment {
|
fn alignment() -> ::flatbuffers::PushAlignment {
|
||||||
::flatbuffers::PushAlignment::new(4)
|
::flatbuffers::PushAlignment::new(4)
|
||||||
@@ -329,10 +358,18 @@ impl<'a> Unused {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct UnusedT {
|
pub struct UnusedT {
|
||||||
pub a: i32,
|
pub a: i32,
|
||||||
}
|
}
|
||||||
|
impl Default for UnusedT {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
a: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl UnusedT {
|
impl UnusedT {
|
||||||
pub fn pack(&self) -> Unused {
|
pub fn pack(&self) -> Unused {
|
||||||
Unused::new(
|
Unused::new(
|
||||||
@@ -342,14 +379,15 @@ impl UnusedT {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub enum TableBOffset {}
|
pub enum TableBOffset {}
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
pub struct TableB<'a> {
|
pub struct TableB<'a> {
|
||||||
pub _tab: ::flatbuffers::Table<'a>,
|
pub _tab: ::flatbuffers::Table<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for TableB<'a> {
|
impl<'a> ::flatbuffers::Follow<'a> for TableB<'a> {
|
||||||
type Inner = TableB<'a>;
|
type Inner = TableB<'a>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||||
@@ -367,6 +405,7 @@ impl<'a> TableB<'a> {
|
|||||||
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||||
TableB { _tab: table }
|
TableB { _tab: table }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||||
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||||
@@ -406,9 +445,11 @@ impl ::flatbuffers::Verifiable for TableB<'_> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct TableBArgs<'a> {
|
pub struct TableBArgs<'a> {
|
||||||
pub a: Option<::flatbuffers::WIPOffset<super::super::TableA<'a>>>,
|
pub a: Option<::flatbuffers::WIPOffset<super::super::TableA<'a>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Default for TableBArgs<'a> {
|
impl<'a> Default for TableBArgs<'a> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
@@ -422,11 +463,13 @@ pub struct TableBBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
|
|||||||
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> {
|
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_a(&mut self, a: ::flatbuffers::WIPOffset<super::super::TableA<'b >>) {
|
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);
|
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::super::TableA>>(TableB::VT_A, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> {
|
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> {
|
||||||
let start = _fbb.start_table();
|
let start = _fbb.start_table();
|
||||||
@@ -435,6 +478,7 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> {
|
|||||||
start_: start,
|
start_: start,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
|
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
|
||||||
let o = self.fbb_.end_table(self.start_);
|
let o = self.fbb_.end_table(self.start_);
|
||||||
@@ -449,11 +493,13 @@ impl ::core::fmt::Debug for TableB<'_> {
|
|||||||
ds.finish()
|
ds.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct TableBT {
|
pub struct TableBT {
|
||||||
pub a: Option<alloc::boxed::Box<super::super::TableAT>>,
|
pub a: Option<alloc::boxed::Box<super::super::TableAT>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for TableBT {
|
impl Default for TableBT {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
@@ -461,6 +507,7 @@ impl Default for TableBT {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TableBT {
|
impl TableBT {
|
||||||
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
||||||
&self,
|
&self,
|
||||||
@@ -476,4 +523,3 @@ impl TableBT {
|
|||||||
}
|
}
|
||||||
} // pub mod OtherNameSpace
|
} // pub mod OtherNameSpace
|
||||||
} // pub mod MyGame
|
} // pub mod MyGame
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,13 @@
|
|||||||
// @generated
|
// @generated
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
#[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;
|
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.")]
|
#[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;
|
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.")]
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
|
pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
|
||||||
@@ -15,6 +18,7 @@ pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
|
|||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct FromInclude(pub i64);
|
pub struct FromInclude(pub i64);
|
||||||
|
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
impl FromInclude {
|
impl FromInclude {
|
||||||
pub const IncludeVal: Self = Self(0);
|
pub const IncludeVal: Self = Self(0);
|
||||||
@@ -24,6 +28,7 @@ impl FromInclude {
|
|||||||
pub const ENUM_VALUES: &'static [Self] = &[
|
pub const ENUM_VALUES: &'static [Self] = &[
|
||||||
Self::IncludeVal,
|
Self::IncludeVal,
|
||||||
];
|
];
|
||||||
|
|
||||||
/// Returns the variant's name or "" if unknown.
|
/// Returns the variant's name or "" if unknown.
|
||||||
pub fn variant_name(self) -> Option<&'static str> {
|
pub fn variant_name(self) -> Option<&'static str> {
|
||||||
match self {
|
match self {
|
||||||
@@ -32,6 +37,7 @@ impl FromInclude {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::fmt::Debug for FromInclude {
|
impl ::core::fmt::Debug for FromInclude {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
if let Some(name) = self.variant_name() {
|
if let Some(name) = self.variant_name() {
|
||||||
@@ -41,8 +47,10 @@ impl ::core::fmt::Debug for FromInclude {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for FromInclude {
|
impl<'a> ::flatbuffers::Follow<'a> for FromInclude {
|
||||||
type Inner = Self;
|
type Inner = Self;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
let b = unsafe { ::flatbuffers::read_scalar_at::<i64>(buf, loc) };
|
let b = unsafe { ::flatbuffers::read_scalar_at::<i64>(buf, loc) };
|
||||||
@@ -52,6 +60,7 @@ impl<'a> ::flatbuffers::Follow<'a> for FromInclude {
|
|||||||
|
|
||||||
impl ::flatbuffers::Push for FromInclude {
|
impl ::flatbuffers::Push for FromInclude {
|
||||||
type Output = FromInclude;
|
type Output = FromInclude;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||||
unsafe { ::flatbuffers::emplace_scalar::<i64>(dst, self.0) };
|
unsafe { ::flatbuffers::emplace_scalar::<i64>(dst, self.0) };
|
||||||
@@ -60,10 +69,12 @@ impl ::flatbuffers::Push for FromInclude {
|
|||||||
|
|
||||||
impl ::flatbuffers::EndianScalar for FromInclude {
|
impl ::flatbuffers::EndianScalar for FromInclude {
|
||||||
type Scalar = i64;
|
type Scalar = i64;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_little_endian(self) -> i64 {
|
fn to_little_endian(self) -> i64 {
|
||||||
self.0.to_le()
|
self.0.to_le()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(clippy::wrong_self_convention)]
|
#[allow(clippy::wrong_self_convention)]
|
||||||
fn from_little_endian(v: i64) -> Self {
|
fn from_little_endian(v: i64) -> Self {
|
||||||
|
|||||||
@@ -2,15 +2,17 @@
|
|||||||
// @generated
|
// @generated
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use super::*;
|
use super::*;
|
||||||
pub enum TableBOffset {}
|
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
|
||||||
|
|
||||||
|
pub enum TableBOffset {}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
pub struct TableB<'a> {
|
pub struct TableB<'a> {
|
||||||
pub _tab: ::flatbuffers::Table<'a>,
|
pub _tab: ::flatbuffers::Table<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for TableB<'a> {
|
impl<'a> ::flatbuffers::Follow<'a> for TableB<'a> {
|
||||||
type Inner = TableB<'a>;
|
type Inner = TableB<'a>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||||
@@ -28,6 +30,7 @@ impl<'a> TableB<'a> {
|
|||||||
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||||
TableB { _tab: table }
|
TableB { _tab: table }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||||
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||||
@@ -67,9 +70,11 @@ impl ::flatbuffers::Verifiable for TableB<'_> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct TableBArgs<'a> {
|
pub struct TableBArgs<'a> {
|
||||||
pub a: Option<::flatbuffers::WIPOffset<super::super::TableA<'a>>>,
|
pub a: Option<::flatbuffers::WIPOffset<super::super::TableA<'a>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Default for TableBArgs<'a> {
|
impl<'a> Default for TableBArgs<'a> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
@@ -83,11 +88,13 @@ pub struct TableBBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
|
|||||||
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> {
|
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_a(&mut self, a: ::flatbuffers::WIPOffset<super::super::TableA<'b >>) {
|
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);
|
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::super::TableA>>(TableB::VT_A, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> {
|
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> {
|
||||||
let start = _fbb.start_table();
|
let start = _fbb.start_table();
|
||||||
@@ -96,6 +103,7 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> {
|
|||||||
start_: start,
|
start_: start,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
|
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
|
||||||
let o = self.fbb_.end_table(self.start_);
|
let o = self.fbb_.end_table(self.start_);
|
||||||
@@ -110,11 +118,13 @@ impl ::core::fmt::Debug for TableB<'_> {
|
|||||||
ds.finish()
|
ds.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct TableBT {
|
pub struct TableBT {
|
||||||
pub a: Option<alloc::boxed::Box<super::super::TableAT>>,
|
pub a: Option<alloc::boxed::Box<super::super::TableAT>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for TableBT {
|
impl Default for TableBT {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
@@ -122,6 +132,7 @@ impl Default for TableBT {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TableBT {
|
impl TableBT {
|
||||||
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
||||||
&self,
|
&self,
|
||||||
|
|||||||
@@ -2,15 +2,18 @@
|
|||||||
// @generated
|
// @generated
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
// struct Unused, aligned to 4
|
// struct Unused, aligned to 4
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Clone, Copy, PartialEq)]
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
pub struct Unused(pub [u8; 4]);
|
pub struct Unused(pub [u8; 4]);
|
||||||
|
|
||||||
impl Default for Unused {
|
impl Default for Unused {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self([0; 4])
|
Self([0; 4])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::fmt::Debug for Unused {
|
impl ::core::fmt::Debug for Unused {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
f.debug_struct("Unused")
|
f.debug_struct("Unused")
|
||||||
@@ -20,27 +23,34 @@ impl ::core::fmt::Debug for Unused {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ::flatbuffers::SimpleToVerifyInSlice for Unused {}
|
impl ::flatbuffers::SimpleToVerifyInSlice for Unused {}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for Unused {
|
impl<'a> ::flatbuffers::Follow<'a> for Unused {
|
||||||
type Inner = &'a Unused;
|
type Inner = &'a Unused;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
unsafe { <&'a Unused>::follow(buf, loc) }
|
unsafe { <&'a Unused>::follow(buf, loc) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for &'a Unused {
|
impl<'a> ::flatbuffers::Follow<'a> for &'a Unused {
|
||||||
type Inner = &'a Unused;
|
type Inner = &'a Unused;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
unsafe { ::flatbuffers::follow_cast_ref::<Unused>(buf, loc) }
|
unsafe { ::flatbuffers::follow_cast_ref::<Unused>(buf, loc) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'b> ::flatbuffers::Push for Unused {
|
impl<'b> ::flatbuffers::Push for Unused {
|
||||||
type Output = Unused;
|
type Output = Unused;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
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()) };
|
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);
|
dst.copy_from_slice(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn alignment() -> ::flatbuffers::PushAlignment {
|
fn alignment() -> ::flatbuffers::PushAlignment {
|
||||||
::flatbuffers::PushAlignment::new(4)
|
::flatbuffers::PushAlignment::new(4)
|
||||||
@@ -106,10 +116,18 @@ impl<'a> Unused {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct UnusedT {
|
pub struct UnusedT {
|
||||||
pub a: i32,
|
pub a: i32,
|
||||||
}
|
}
|
||||||
|
impl Default for UnusedT {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
a: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl UnusedT {
|
impl UnusedT {
|
||||||
pub fn pack(&self) -> Unused {
|
pub fn pack(&self) -> Unused {
|
||||||
Unused::new(
|
Unused::new(
|
||||||
@@ -117,4 +135,3 @@ impl UnusedT {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,15 +2,17 @@
|
|||||||
// @generated
|
// @generated
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use super::*;
|
use super::*;
|
||||||
pub enum TableAOffset {}
|
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
|
||||||
|
|
||||||
|
pub enum TableAOffset {}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
pub struct TableA<'a> {
|
pub struct TableA<'a> {
|
||||||
pub _tab: ::flatbuffers::Table<'a>,
|
pub _tab: ::flatbuffers::Table<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for TableA<'a> {
|
impl<'a> ::flatbuffers::Follow<'a> for TableA<'a> {
|
||||||
type Inner = TableA<'a>;
|
type Inner = TableA<'a>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||||
@@ -28,6 +30,7 @@ impl<'a> TableA<'a> {
|
|||||||
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||||
TableA { _tab: table }
|
TableA { _tab: table }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||||
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||||
@@ -67,9 +70,11 @@ impl ::flatbuffers::Verifiable for TableA<'_> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct TableAArgs<'a> {
|
pub struct TableAArgs<'a> {
|
||||||
pub b: Option<::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'a>>>,
|
pub b: Option<::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'a>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Default for TableAArgs<'a> {
|
impl<'a> Default for TableAArgs<'a> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
@@ -83,11 +88,13 @@ pub struct TableABuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
|
|||||||
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> {
|
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_b(&mut self, b: ::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'b >>) {
|
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);
|
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<my_game::other_name_space::TableB>>(TableA::VT_B, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> {
|
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> {
|
||||||
let start = _fbb.start_table();
|
let start = _fbb.start_table();
|
||||||
@@ -96,6 +103,7 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> {
|
|||||||
start_: start,
|
start_: start,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
|
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
|
||||||
let o = self.fbb_.end_table(self.start_);
|
let o = self.fbb_.end_table(self.start_);
|
||||||
@@ -110,11 +118,13 @@ impl ::core::fmt::Debug for TableA<'_> {
|
|||||||
ds.finish()
|
ds.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct TableAT {
|
pub struct TableAT {
|
||||||
pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
|
pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for TableAT {
|
impl Default for TableAT {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
@@ -122,6 +132,7 @@ impl Default for TableAT {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TableAT {
|
impl TableAT {
|
||||||
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
||||||
&self,
|
&self,
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
// 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;
|
||||||
|
|
||||||
pub enum TableAOffset {}
|
pub enum TableAOffset {}
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
pub struct TableA<'a> {
|
pub struct TableA<'a> {
|
||||||
pub _tab: ::flatbuffers::Table<'a>,
|
pub _tab: ::flatbuffers::Table<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for TableA<'a> {
|
impl<'a> ::flatbuffers::Follow<'a> for TableA<'a> {
|
||||||
type Inner = TableA<'a>;
|
type Inner = TableA<'a>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||||
@@ -29,6 +29,7 @@ impl<'a> TableA<'a> {
|
|||||||
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||||
TableA { _tab: table }
|
TableA { _tab: table }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||||
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||||
@@ -68,9 +69,11 @@ impl ::flatbuffers::Verifiable for TableA<'_> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct TableAArgs<'a> {
|
pub struct TableAArgs<'a> {
|
||||||
pub b: Option<::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'a>>>,
|
pub b: Option<::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'a>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Default for TableAArgs<'a> {
|
impl<'a> Default for TableAArgs<'a> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
@@ -84,11 +87,13 @@ pub struct TableABuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
|
|||||||
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> {
|
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_b(&mut self, b: ::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'b >>) {
|
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);
|
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<my_game::other_name_space::TableB>>(TableA::VT_B, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> {
|
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> {
|
||||||
let start = _fbb.start_table();
|
let start = _fbb.start_table();
|
||||||
@@ -97,6 +102,7 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> {
|
|||||||
start_: start,
|
start_: start,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
|
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
|
||||||
let o = self.fbb_.end_table(self.start_);
|
let o = self.fbb_.end_table(self.start_);
|
||||||
@@ -111,11 +117,13 @@ impl ::core::fmt::Debug for TableA<'_> {
|
|||||||
ds.finish()
|
ds.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct TableAT {
|
pub struct TableAT {
|
||||||
pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
|
pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for TableAT {
|
impl Default for TableAT {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
@@ -123,6 +131,7 @@ impl Default for TableAT {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TableAT {
|
impl TableAT {
|
||||||
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
||||||
&self,
|
&self,
|
||||||
@@ -136,19 +145,21 @@ impl TableAT {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_imports, dead_code)]
|
#[allow(unused_imports, dead_code)]
|
||||||
pub mod my_game {
|
pub mod my_game {
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
#[allow(unused_imports, dead_code)]
|
#[allow(unused_imports, dead_code)]
|
||||||
pub mod other_name_space {
|
pub mod other_name_space {
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
#[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;
|
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.")]
|
#[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;
|
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.")]
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
|
pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
|
||||||
@@ -158,6 +169,7 @@ pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
|
|||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct FromInclude(pub i64);
|
pub struct FromInclude(pub i64);
|
||||||
|
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
impl FromInclude {
|
impl FromInclude {
|
||||||
pub const IncludeVal: Self = Self(0);
|
pub const IncludeVal: Self = Self(0);
|
||||||
@@ -167,6 +179,7 @@ impl FromInclude {
|
|||||||
pub const ENUM_VALUES: &'static [Self] = &[
|
pub const ENUM_VALUES: &'static [Self] = &[
|
||||||
Self::IncludeVal,
|
Self::IncludeVal,
|
||||||
];
|
];
|
||||||
|
|
||||||
/// Returns the variant's name or "" if unknown.
|
/// Returns the variant's name or "" if unknown.
|
||||||
pub fn variant_name(self) -> Option<&'static str> {
|
pub fn variant_name(self) -> Option<&'static str> {
|
||||||
match self {
|
match self {
|
||||||
@@ -175,6 +188,7 @@ impl FromInclude {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::fmt::Debug for FromInclude {
|
impl ::core::fmt::Debug for FromInclude {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
if let Some(name) = self.variant_name() {
|
if let Some(name) = self.variant_name() {
|
||||||
@@ -184,8 +198,10 @@ impl ::core::fmt::Debug for FromInclude {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for FromInclude {
|
impl<'a> ::flatbuffers::Follow<'a> for FromInclude {
|
||||||
type Inner = Self;
|
type Inner = Self;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
let b = unsafe { ::flatbuffers::read_scalar_at::<i64>(buf, loc) };
|
let b = unsafe { ::flatbuffers::read_scalar_at::<i64>(buf, loc) };
|
||||||
@@ -195,6 +211,7 @@ impl<'a> ::flatbuffers::Follow<'a> for FromInclude {
|
|||||||
|
|
||||||
impl ::flatbuffers::Push for FromInclude {
|
impl ::flatbuffers::Push for FromInclude {
|
||||||
type Output = FromInclude;
|
type Output = FromInclude;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||||
unsafe { ::flatbuffers::emplace_scalar::<i64>(dst, self.0) };
|
unsafe { ::flatbuffers::emplace_scalar::<i64>(dst, self.0) };
|
||||||
@@ -203,10 +220,12 @@ impl ::flatbuffers::Push for FromInclude {
|
|||||||
|
|
||||||
impl ::flatbuffers::EndianScalar for FromInclude {
|
impl ::flatbuffers::EndianScalar for FromInclude {
|
||||||
type Scalar = i64;
|
type Scalar = i64;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_little_endian(self) -> i64 {
|
fn to_little_endian(self) -> i64 {
|
||||||
self.0.to_le()
|
self.0.to_le()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(clippy::wrong_self_convention)]
|
#[allow(clippy::wrong_self_convention)]
|
||||||
fn from_little_endian(v: i64) -> Self {
|
fn from_little_endian(v: i64) -> Self {
|
||||||
@@ -225,15 +244,18 @@ impl<'a> ::flatbuffers::Verifiable for FromInclude {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ::flatbuffers::SimpleToVerifyInSlice for FromInclude {}
|
impl ::flatbuffers::SimpleToVerifyInSlice for FromInclude {}
|
||||||
|
|
||||||
// struct Unused, aligned to 4
|
// struct Unused, aligned to 4
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Clone, Copy, PartialEq)]
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
pub struct Unused(pub [u8; 4]);
|
pub struct Unused(pub [u8; 4]);
|
||||||
|
|
||||||
impl Default for Unused {
|
impl Default for Unused {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self([0; 4])
|
Self([0; 4])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::fmt::Debug for Unused {
|
impl ::core::fmt::Debug for Unused {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
f.debug_struct("Unused")
|
f.debug_struct("Unused")
|
||||||
@@ -243,27 +265,34 @@ impl ::core::fmt::Debug for Unused {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ::flatbuffers::SimpleToVerifyInSlice for Unused {}
|
impl ::flatbuffers::SimpleToVerifyInSlice for Unused {}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for Unused {
|
impl<'a> ::flatbuffers::Follow<'a> for Unused {
|
||||||
type Inner = &'a Unused;
|
type Inner = &'a Unused;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
unsafe { <&'a Unused>::follow(buf, loc) }
|
unsafe { <&'a Unused>::follow(buf, loc) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for &'a Unused {
|
impl<'a> ::flatbuffers::Follow<'a> for &'a Unused {
|
||||||
type Inner = &'a Unused;
|
type Inner = &'a Unused;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
unsafe { ::flatbuffers::follow_cast_ref::<Unused>(buf, loc) }
|
unsafe { ::flatbuffers::follow_cast_ref::<Unused>(buf, loc) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'b> ::flatbuffers::Push for Unused {
|
impl<'b> ::flatbuffers::Push for Unused {
|
||||||
type Output = Unused;
|
type Output = Unused;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
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()) };
|
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);
|
dst.copy_from_slice(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn alignment() -> ::flatbuffers::PushAlignment {
|
fn alignment() -> ::flatbuffers::PushAlignment {
|
||||||
::flatbuffers::PushAlignment::new(4)
|
::flatbuffers::PushAlignment::new(4)
|
||||||
@@ -329,10 +358,18 @@ impl<'a> Unused {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct UnusedT {
|
pub struct UnusedT {
|
||||||
pub a: i32,
|
pub a: i32,
|
||||||
}
|
}
|
||||||
|
impl Default for UnusedT {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
a: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl UnusedT {
|
impl UnusedT {
|
||||||
pub fn pack(&self) -> Unused {
|
pub fn pack(&self) -> Unused {
|
||||||
Unused::new(
|
Unused::new(
|
||||||
@@ -342,14 +379,15 @@ impl UnusedT {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub enum TableBOffset {}
|
pub enum TableBOffset {}
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
pub struct TableB<'a> {
|
pub struct TableB<'a> {
|
||||||
pub _tab: ::flatbuffers::Table<'a>,
|
pub _tab: ::flatbuffers::Table<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for TableB<'a> {
|
impl<'a> ::flatbuffers::Follow<'a> for TableB<'a> {
|
||||||
type Inner = TableB<'a>;
|
type Inner = TableB<'a>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||||
@@ -367,6 +405,7 @@ impl<'a> TableB<'a> {
|
|||||||
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||||
TableB { _tab: table }
|
TableB { _tab: table }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||||
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||||
@@ -406,9 +445,11 @@ impl ::flatbuffers::Verifiable for TableB<'_> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct TableBArgs<'a> {
|
pub struct TableBArgs<'a> {
|
||||||
pub a: Option<::flatbuffers::WIPOffset<super::super::TableA<'a>>>,
|
pub a: Option<::flatbuffers::WIPOffset<super::super::TableA<'a>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Default for TableBArgs<'a> {
|
impl<'a> Default for TableBArgs<'a> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
@@ -422,11 +463,13 @@ pub struct TableBBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
|
|||||||
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> {
|
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_a(&mut self, a: ::flatbuffers::WIPOffset<super::super::TableA<'b >>) {
|
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);
|
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::super::TableA>>(TableB::VT_A, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> {
|
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> {
|
||||||
let start = _fbb.start_table();
|
let start = _fbb.start_table();
|
||||||
@@ -435,6 +478,7 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> {
|
|||||||
start_: start,
|
start_: start,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
|
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
|
||||||
let o = self.fbb_.end_table(self.start_);
|
let o = self.fbb_.end_table(self.start_);
|
||||||
@@ -449,11 +493,13 @@ impl ::core::fmt::Debug for TableB<'_> {
|
|||||||
ds.finish()
|
ds.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct TableBT {
|
pub struct TableBT {
|
||||||
pub a: Option<alloc::boxed::Box<super::super::TableAT>>,
|
pub a: Option<alloc::boxed::Box<super::super::TableAT>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for TableBT {
|
impl Default for TableBT {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
@@ -461,6 +507,7 @@ impl Default for TableBT {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TableBT {
|
impl TableBT {
|
||||||
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
||||||
&self,
|
&self,
|
||||||
@@ -476,4 +523,3 @@ impl TableBT {
|
|||||||
}
|
}
|
||||||
} // pub mod OtherNameSpace
|
} // pub mod OtherNameSpace
|
||||||
} // pub mod MyGame
|
} // pub mod MyGame
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,13 @@
|
|||||||
// @generated
|
// @generated
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
pub const ENUM_MIN_ABC: i32 = 0;
|
pub const ENUM_MIN_ABC: i32 = 0;
|
||||||
|
|
||||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
pub const ENUM_MAX_ABC: i32 = 2;
|
pub const ENUM_MAX_ABC: i32 = 2;
|
||||||
|
|
||||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub const ENUM_VALUES_ABC: [ABC; 3] = [
|
pub const ENUM_VALUES_ABC: [ABC; 3] = [
|
||||||
@@ -17,6 +20,7 @@ pub const ENUM_VALUES_ABC: [ABC; 3] = [
|
|||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct ABC(pub i32);
|
pub struct ABC(pub i32);
|
||||||
|
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
impl ABC {
|
impl ABC {
|
||||||
pub const void: Self = Self(0);
|
pub const void: Self = Self(0);
|
||||||
@@ -30,6 +34,7 @@ impl ABC {
|
|||||||
Self::where_,
|
Self::where_,
|
||||||
Self::stackalloc,
|
Self::stackalloc,
|
||||||
];
|
];
|
||||||
|
|
||||||
/// Returns the variant's name or "" if unknown.
|
/// Returns the variant's name or "" if unknown.
|
||||||
pub fn variant_name(self) -> Option<&'static str> {
|
pub fn variant_name(self) -> Option<&'static str> {
|
||||||
match self {
|
match self {
|
||||||
@@ -40,6 +45,7 @@ impl ABC {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::fmt::Debug for ABC {
|
impl ::core::fmt::Debug for ABC {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
if let Some(name) = self.variant_name() {
|
if let Some(name) = self.variant_name() {
|
||||||
@@ -49,8 +55,10 @@ impl ::core::fmt::Debug for ABC {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for ABC {
|
impl<'a> ::flatbuffers::Follow<'a> for ABC {
|
||||||
type Inner = Self;
|
type Inner = Self;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
let b = unsafe { ::flatbuffers::read_scalar_at::<i32>(buf, loc) };
|
let b = unsafe { ::flatbuffers::read_scalar_at::<i32>(buf, loc) };
|
||||||
@@ -60,6 +68,7 @@ impl<'a> ::flatbuffers::Follow<'a> for ABC {
|
|||||||
|
|
||||||
impl ::flatbuffers::Push for ABC {
|
impl ::flatbuffers::Push for ABC {
|
||||||
type Output = ABC;
|
type Output = ABC;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||||
unsafe { ::flatbuffers::emplace_scalar::<i32>(dst, self.0) };
|
unsafe { ::flatbuffers::emplace_scalar::<i32>(dst, self.0) };
|
||||||
@@ -68,10 +77,12 @@ impl ::flatbuffers::Push for ABC {
|
|||||||
|
|
||||||
impl ::flatbuffers::EndianScalar for ABC {
|
impl ::flatbuffers::EndianScalar for ABC {
|
||||||
type Scalar = i32;
|
type Scalar = i32;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_little_endian(self) -> i32 {
|
fn to_little_endian(self) -> i32 {
|
||||||
self.0.to_le()
|
self.0.to_le()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(clippy::wrong_self_convention)]
|
#[allow(clippy::wrong_self_convention)]
|
||||||
fn from_little_endian(v: i32) -> Self {
|
fn from_little_endian(v: i32) -> Self {
|
||||||
|
|||||||
@@ -2,15 +2,17 @@
|
|||||||
// @generated
|
// @generated
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use super::*;
|
use super::*;
|
||||||
pub enum KeywordsInTableOffset {}
|
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
|
||||||
|
|
||||||
|
pub enum KeywordsInTableOffset {}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
pub struct KeywordsInTable<'a> {
|
pub struct KeywordsInTable<'a> {
|
||||||
pub _tab: ::flatbuffers::Table<'a>,
|
pub _tab: ::flatbuffers::Table<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for KeywordsInTable<'a> {
|
impl<'a> ::flatbuffers::Follow<'a> for KeywordsInTable<'a> {
|
||||||
type Inner = KeywordsInTable<'a>;
|
type Inner = KeywordsInTable<'a>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||||
@@ -31,6 +33,7 @@ impl<'a> KeywordsInTable<'a> {
|
|||||||
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||||
KeywordsInTable { _tab: table }
|
KeywordsInTable { _tab: table }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||||
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||||
@@ -64,6 +67,7 @@ impl<'a> KeywordsInTable<'a> {
|
|||||||
// which contains a valid value in this slot
|
// which contains a valid value in this slot
|
||||||
unsafe { self._tab.get::<ABC>(KeywordsInTable::VT_IS, Some(ABC::void)).unwrap()}
|
unsafe { self._tab.get::<ABC>(KeywordsInTable::VT_IS, Some(ABC::void)).unwrap()}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn private(&self) -> public {
|
pub fn private(&self) -> public {
|
||||||
// Safety:
|
// Safety:
|
||||||
@@ -71,6 +75,7 @@ impl<'a> KeywordsInTable<'a> {
|
|||||||
// which contains a valid value in this slot
|
// which contains a valid value in this slot
|
||||||
unsafe { self._tab.get::<public>(KeywordsInTable::VT_PRIVATE, Some(public::NONE)).unwrap()}
|
unsafe { self._tab.get::<public>(KeywordsInTable::VT_PRIVATE, Some(public::NONE)).unwrap()}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn type_(&self) -> i32 {
|
pub fn type_(&self) -> i32 {
|
||||||
// Safety:
|
// Safety:
|
||||||
@@ -78,6 +83,7 @@ impl<'a> KeywordsInTable<'a> {
|
|||||||
// which contains a valid value in this slot
|
// which contains a valid value in this slot
|
||||||
unsafe { self._tab.get::<i32>(KeywordsInTable::VT_TYPE_, Some(0)).unwrap()}
|
unsafe { self._tab.get::<i32>(KeywordsInTable::VT_TYPE_, Some(0)).unwrap()}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn default(&self) -> bool {
|
pub fn default(&self) -> bool {
|
||||||
// Safety:
|
// Safety:
|
||||||
@@ -101,12 +107,14 @@ impl ::flatbuffers::Verifiable for KeywordsInTable<'_> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct KeywordsInTableArgs {
|
pub struct KeywordsInTableArgs {
|
||||||
pub is: ABC,
|
pub is: ABC,
|
||||||
pub private: public,
|
pub private: public,
|
||||||
pub type_: i32,
|
pub type_: i32,
|
||||||
pub default: bool,
|
pub default: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Default for KeywordsInTableArgs {
|
impl<'a> Default for KeywordsInTableArgs {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
@@ -123,23 +131,28 @@ pub struct KeywordsInTableBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a>
|
|||||||
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> KeywordsInTableBuilder<'a, 'b, A> {
|
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> KeywordsInTableBuilder<'a, 'b, A> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_is(&mut self, is: ABC) {
|
pub fn add_is(&mut self, is: ABC) {
|
||||||
self.fbb_.push_slot::<ABC>(KeywordsInTable::VT_IS, is, ABC::void);
|
self.fbb_.push_slot::<ABC>(KeywordsInTable::VT_IS, is, ABC::void);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_private(&mut self, private: public) {
|
pub fn add_private(&mut self, private: public) {
|
||||||
self.fbb_.push_slot::<public>(KeywordsInTable::VT_PRIVATE, private, public::NONE);
|
self.fbb_.push_slot::<public>(KeywordsInTable::VT_PRIVATE, private, public::NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_type_(&mut self, type_: i32) {
|
pub fn add_type_(&mut self, type_: i32) {
|
||||||
self.fbb_.push_slot::<i32>(KeywordsInTable::VT_TYPE_, type_, 0);
|
self.fbb_.push_slot::<i32>(KeywordsInTable::VT_TYPE_, type_, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_default(&mut self, default: bool) {
|
pub fn add_default(&mut self, default: bool) {
|
||||||
self.fbb_.push_slot::<bool>(KeywordsInTable::VT_DEFAULT, default, false);
|
self.fbb_.push_slot::<bool>(KeywordsInTable::VT_DEFAULT, default, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> KeywordsInTableBuilder<'a, 'b, A> {
|
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> KeywordsInTableBuilder<'a, 'b, A> {
|
||||||
let start = _fbb.start_table();
|
let start = _fbb.start_table();
|
||||||
@@ -148,6 +161,7 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> KeywordsInTableBuilder<'a, 'b
|
|||||||
start_: start,
|
start_: start,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn finish(self) -> ::flatbuffers::WIPOffset<KeywordsInTable<'a>> {
|
pub fn finish(self) -> ::flatbuffers::WIPOffset<KeywordsInTable<'a>> {
|
||||||
let o = self.fbb_.end_table(self.start_);
|
let o = self.fbb_.end_table(self.start_);
|
||||||
@@ -165,6 +179,7 @@ impl ::core::fmt::Debug for KeywordsInTable<'_> {
|
|||||||
ds.finish()
|
ds.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct KeywordsInTableT {
|
pub struct KeywordsInTableT {
|
||||||
@@ -173,6 +188,7 @@ pub struct KeywordsInTableT {
|
|||||||
pub type_: i32,
|
pub type_: i32,
|
||||||
pub default: bool,
|
pub default: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for KeywordsInTableT {
|
impl Default for KeywordsInTableT {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
@@ -183,6 +199,7 @@ impl Default for KeywordsInTableT {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl KeywordsInTableT {
|
impl KeywordsInTableT {
|
||||||
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
||||||
&self,
|
&self,
|
||||||
|
|||||||
@@ -2,10 +2,13 @@
|
|||||||
// @generated
|
// @generated
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
pub const ENUM_MIN_KEYWORDS_IN_UNION: u8 = 0;
|
pub const ENUM_MIN_KEYWORDS_IN_UNION: u8 = 0;
|
||||||
|
|
||||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
pub const ENUM_MAX_KEYWORDS_IN_UNION: u8 = 2;
|
pub const ENUM_MAX_KEYWORDS_IN_UNION: u8 = 2;
|
||||||
|
|
||||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub const ENUM_VALUES_KEYWORDS_IN_UNION: [KeywordsInUnion; 3] = [
|
pub const ENUM_VALUES_KEYWORDS_IN_UNION: [KeywordsInUnion; 3] = [
|
||||||
@@ -17,6 +20,7 @@ pub const ENUM_VALUES_KEYWORDS_IN_UNION: [KeywordsInUnion; 3] = [
|
|||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct KeywordsInUnion(pub u8);
|
pub struct KeywordsInUnion(pub u8);
|
||||||
|
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
impl KeywordsInUnion {
|
impl KeywordsInUnion {
|
||||||
pub const NONE: Self = Self(0);
|
pub const NONE: Self = Self(0);
|
||||||
@@ -30,6 +34,7 @@ impl KeywordsInUnion {
|
|||||||
Self::static_,
|
Self::static_,
|
||||||
Self::internal,
|
Self::internal,
|
||||||
];
|
];
|
||||||
|
|
||||||
/// Returns the variant's name or "" if unknown.
|
/// Returns the variant's name or "" if unknown.
|
||||||
pub fn variant_name(self) -> Option<&'static str> {
|
pub fn variant_name(self) -> Option<&'static str> {
|
||||||
match self {
|
match self {
|
||||||
@@ -40,6 +45,7 @@ impl KeywordsInUnion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::fmt::Debug for KeywordsInUnion {
|
impl ::core::fmt::Debug for KeywordsInUnion {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
if let Some(name) = self.variant_name() {
|
if let Some(name) = self.variant_name() {
|
||||||
@@ -49,8 +55,10 @@ impl ::core::fmt::Debug for KeywordsInUnion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for KeywordsInUnion {
|
impl<'a> ::flatbuffers::Follow<'a> for KeywordsInUnion {
|
||||||
type Inner = Self;
|
type Inner = Self;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
|
let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
|
||||||
@@ -60,6 +68,7 @@ impl<'a> ::flatbuffers::Follow<'a> for KeywordsInUnion {
|
|||||||
|
|
||||||
impl ::flatbuffers::Push for KeywordsInUnion {
|
impl ::flatbuffers::Push for KeywordsInUnion {
|
||||||
type Output = KeywordsInUnion;
|
type Output = KeywordsInUnion;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||||
unsafe { ::flatbuffers::emplace_scalar::<u8>(dst, self.0) };
|
unsafe { ::flatbuffers::emplace_scalar::<u8>(dst, self.0) };
|
||||||
@@ -68,10 +77,12 @@ impl ::flatbuffers::Push for KeywordsInUnion {
|
|||||||
|
|
||||||
impl ::flatbuffers::EndianScalar for KeywordsInUnion {
|
impl ::flatbuffers::EndianScalar for KeywordsInUnion {
|
||||||
type Scalar = u8;
|
type Scalar = u8;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_little_endian(self) -> u8 {
|
fn to_little_endian(self) -> u8 {
|
||||||
self.0.to_le()
|
self.0.to_le()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(clippy::wrong_self_convention)]
|
#[allow(clippy::wrong_self_convention)]
|
||||||
fn from_little_endian(v: u8) -> Self {
|
fn from_little_endian(v: u8) -> Self {
|
||||||
@@ -90,6 +101,7 @@ impl<'a> ::flatbuffers::Verifiable for KeywordsInUnion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ::flatbuffers::SimpleToVerifyInSlice for KeywordsInUnion {}
|
impl ::flatbuffers::SimpleToVerifyInSlice for KeywordsInUnion {}
|
||||||
|
|
||||||
pub struct KeywordsInUnionUnionTableOffset {}
|
pub struct KeywordsInUnionUnionTableOffset {}
|
||||||
|
|
||||||
#[allow(clippy::upper_case_acronyms)]
|
#[allow(clippy::upper_case_acronyms)]
|
||||||
@@ -100,11 +112,13 @@ pub enum KeywordsInUnionT {
|
|||||||
Static_(alloc::boxed::Box<KeywordsInTableT>),
|
Static_(alloc::boxed::Box<KeywordsInTableT>),
|
||||||
Internal(alloc::boxed::Box<KeywordsInTableT>),
|
Internal(alloc::boxed::Box<KeywordsInTableT>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for KeywordsInUnionT {
|
impl Default for KeywordsInUnionT {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::NONE
|
Self::NONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl KeywordsInUnionT {
|
impl KeywordsInUnionT {
|
||||||
pub fn keywords_in_union_type(&self) -> KeywordsInUnion {
|
pub fn keywords_in_union_type(&self) -> KeywordsInUnion {
|
||||||
match self {
|
match self {
|
||||||
@@ -113,6 +127,7 @@ impl KeywordsInUnionT {
|
|||||||
Self::Internal(_) => KeywordsInUnion::internal,
|
Self::Internal(_) => KeywordsInUnion::internal,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(&self, fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>) -> Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>> {
|
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(&self, fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>) -> Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>> {
|
||||||
match self {
|
match self {
|
||||||
Self::NONE => None,
|
Self::NONE => None,
|
||||||
@@ -120,6 +135,7 @@ impl KeywordsInUnionT {
|
|||||||
Self::Internal(v) => Some(v.pack(fbb).as_union_value()),
|
Self::Internal(v) => Some(v.pack(fbb).as_union_value()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If the union variant matches, return the owned KeywordsInTableT, setting the union to NONE.
|
/// If the union variant matches, return the owned KeywordsInTableT, setting the union to NONE.
|
||||||
pub fn take_static_(&mut self) -> Option<alloc::boxed::Box<KeywordsInTableT>> {
|
pub fn take_static_(&mut self) -> Option<alloc::boxed::Box<KeywordsInTableT>> {
|
||||||
if let Self::Static_(_) = self {
|
if let Self::Static_(_) = self {
|
||||||
@@ -133,14 +149,17 @@ impl KeywordsInUnionT {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If the union variant matches, return a reference to the KeywordsInTableT.
|
/// If the union variant matches, return a reference to the KeywordsInTableT.
|
||||||
pub fn as_static_(&self) -> Option<&KeywordsInTableT> {
|
pub fn as_static_(&self) -> Option<&KeywordsInTableT> {
|
||||||
if let Self::Static_(v) = self { Some(v.as_ref()) } else { None }
|
if let Self::Static_(v) = self { Some(v.as_ref()) } else { None }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If the union variant matches, return a mutable reference to the KeywordsInTableT.
|
/// If the union variant matches, return a mutable reference to the KeywordsInTableT.
|
||||||
pub fn as_static__mut(&mut self) -> Option<&mut KeywordsInTableT> {
|
pub fn as_static__mut(&mut self) -> Option<&mut KeywordsInTableT> {
|
||||||
if let Self::Static_(v) = self { Some(v.as_mut()) } else { None }
|
if let Self::Static_(v) = self { Some(v.as_mut()) } else { None }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If the union variant matches, return the owned KeywordsInTableT, setting the union to NONE.
|
/// If the union variant matches, return the owned KeywordsInTableT, setting the union to NONE.
|
||||||
pub fn take_internal(&mut self) -> Option<alloc::boxed::Box<KeywordsInTableT>> {
|
pub fn take_internal(&mut self) -> Option<alloc::boxed::Box<KeywordsInTableT>> {
|
||||||
if let Self::Internal(_) = self {
|
if let Self::Internal(_) = self {
|
||||||
@@ -154,12 +173,15 @@ impl KeywordsInUnionT {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If the union variant matches, return a reference to the KeywordsInTableT.
|
/// If the union variant matches, return a reference to the KeywordsInTableT.
|
||||||
pub fn as_internal(&self) -> Option<&KeywordsInTableT> {
|
pub fn as_internal(&self) -> Option<&KeywordsInTableT> {
|
||||||
if let Self::Internal(v) = self { Some(v.as_ref()) } else { None }
|
if let Self::Internal(v) = self { Some(v.as_ref()) } else { None }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If the union variant matches, return a mutable reference to the KeywordsInTableT.
|
/// If the union variant matches, return a mutable reference to the KeywordsInTableT.
|
||||||
pub fn as_internal_mut(&mut self) -> Option<&mut KeywordsInTableT> {
|
pub fn as_internal_mut(&mut self) -> Option<&mut KeywordsInTableT> {
|
||||||
if let Self::Internal(v) = self { Some(v.as_mut()) } else { None }
|
if let Self::Internal(v) = self { Some(v.as_mut()) } else { None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,13 @@
|
|||||||
// @generated
|
// @generated
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
pub const ENUM_MIN_PUBLIC: i32 = 0;
|
pub const ENUM_MIN_PUBLIC: i32 = 0;
|
||||||
|
|
||||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
pub const ENUM_MAX_PUBLIC: i32 = 0;
|
pub const ENUM_MAX_PUBLIC: i32 = 0;
|
||||||
|
|
||||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub const ENUM_VALUES_PUBLIC: [public; 1] = [
|
pub const ENUM_VALUES_PUBLIC: [public; 1] = [
|
||||||
@@ -15,6 +18,7 @@ pub const ENUM_VALUES_PUBLIC: [public; 1] = [
|
|||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct public(pub i32);
|
pub struct public(pub i32);
|
||||||
|
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
impl public {
|
impl public {
|
||||||
pub const NONE: Self = Self(0);
|
pub const NONE: Self = Self(0);
|
||||||
@@ -24,6 +28,7 @@ impl public {
|
|||||||
pub const ENUM_VALUES: &'static [Self] = &[
|
pub const ENUM_VALUES: &'static [Self] = &[
|
||||||
Self::NONE,
|
Self::NONE,
|
||||||
];
|
];
|
||||||
|
|
||||||
/// Returns the variant's name or "" if unknown.
|
/// Returns the variant's name or "" if unknown.
|
||||||
pub fn variant_name(self) -> Option<&'static str> {
|
pub fn variant_name(self) -> Option<&'static str> {
|
||||||
match self {
|
match self {
|
||||||
@@ -32,6 +37,7 @@ impl public {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::fmt::Debug for public {
|
impl ::core::fmt::Debug for public {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
if let Some(name) = self.variant_name() {
|
if let Some(name) = self.variant_name() {
|
||||||
@@ -41,8 +47,10 @@ impl ::core::fmt::Debug for public {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for public {
|
impl<'a> ::flatbuffers::Follow<'a> for public {
|
||||||
type Inner = Self;
|
type Inner = Self;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
let b = unsafe { ::flatbuffers::read_scalar_at::<i32>(buf, loc) };
|
let b = unsafe { ::flatbuffers::read_scalar_at::<i32>(buf, loc) };
|
||||||
@@ -52,6 +60,7 @@ impl<'a> ::flatbuffers::Follow<'a> for public {
|
|||||||
|
|
||||||
impl ::flatbuffers::Push for public {
|
impl ::flatbuffers::Push for public {
|
||||||
type Output = public;
|
type Output = public;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||||
unsafe { ::flatbuffers::emplace_scalar::<i32>(dst, self.0) };
|
unsafe { ::flatbuffers::emplace_scalar::<i32>(dst, self.0) };
|
||||||
@@ -60,10 +69,12 @@ impl ::flatbuffers::Push for public {
|
|||||||
|
|
||||||
impl ::flatbuffers::EndianScalar for public {
|
impl ::flatbuffers::EndianScalar for public {
|
||||||
type Scalar = i32;
|
type Scalar = i32;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_little_endian(self) -> i32 {
|
fn to_little_endian(self) -> i32 {
|
||||||
self.0.to_le()
|
self.0.to_le()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(clippy::wrong_self_convention)]
|
#[allow(clippy::wrong_self_convention)]
|
||||||
fn from_little_endian(v: i32) -> Self {
|
fn from_little_endian(v: i32) -> Self {
|
||||||
|
|||||||
@@ -2,15 +2,17 @@
|
|||||||
// @generated
|
// @generated
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use super::*;
|
use super::*;
|
||||||
pub enum Table2Offset {}
|
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
|
||||||
|
|
||||||
|
pub enum Table2Offset {}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
pub struct Table2<'a> {
|
pub struct Table2<'a> {
|
||||||
pub _tab: ::flatbuffers::Table<'a>,
|
pub _tab: ::flatbuffers::Table<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for Table2<'a> {
|
impl<'a> ::flatbuffers::Follow<'a> for Table2<'a> {
|
||||||
type Inner = Table2<'a>;
|
type Inner = Table2<'a>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||||
@@ -29,6 +31,7 @@ impl<'a> Table2<'a> {
|
|||||||
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||||
Table2 { _tab: table }
|
Table2 { _tab: table }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||||
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||||
@@ -67,6 +70,7 @@ impl<'a> Table2<'a> {
|
|||||||
// which contains a valid value in this slot
|
// which contains a valid value in this slot
|
||||||
unsafe { self._tab.get::<KeywordsInUnion>(Table2::VT_TYPE_TYPE, Some(KeywordsInUnion::NONE)).unwrap()}
|
unsafe { self._tab.get::<KeywordsInUnion>(Table2::VT_TYPE_TYPE, Some(KeywordsInUnion::NONE)).unwrap()}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn type_(&self) -> Option<::flatbuffers::Table<'a>> {
|
pub fn type_(&self) -> Option<::flatbuffers::Table<'a>> {
|
||||||
// Safety:
|
// Safety:
|
||||||
@@ -74,6 +78,7 @@ impl<'a> Table2<'a> {
|
|||||||
// which contains a valid value in this slot
|
// which contains a valid value in this slot
|
||||||
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Table2::VT_TYPE_, None)}
|
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Table2::VT_TYPE_, None)}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn type__as_static_(&self) -> Option<KeywordsInTable<'a>> {
|
pub fn type__as_static_(&self) -> Option<KeywordsInTable<'a>> {
|
||||||
@@ -103,7 +108,6 @@ impl<'a> Table2<'a> {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::flatbuffers::Verifiable for Table2<'_> {
|
impl ::flatbuffers::Verifiable for Table2<'_> {
|
||||||
@@ -123,10 +127,12 @@ impl ::flatbuffers::Verifiable for Table2<'_> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Table2Args {
|
pub struct Table2Args {
|
||||||
pub type_type: KeywordsInUnion,
|
pub type_type: KeywordsInUnion,
|
||||||
pub type_: Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>,
|
pub type_: Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Default for Table2Args {
|
impl<'a> Default for Table2Args {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
@@ -141,15 +147,18 @@ pub struct Table2Builder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
|
|||||||
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> Table2Builder<'a, 'b, A> {
|
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> Table2Builder<'a, 'b, A> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_type_type(&mut self, type_type: KeywordsInUnion) {
|
pub fn add_type_type(&mut self, type_type: KeywordsInUnion) {
|
||||||
self.fbb_.push_slot::<KeywordsInUnion>(Table2::VT_TYPE_TYPE, type_type, KeywordsInUnion::NONE);
|
self.fbb_.push_slot::<KeywordsInUnion>(Table2::VT_TYPE_TYPE, type_type, KeywordsInUnion::NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_type_(&mut self, type_: ::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>) {
|
pub fn add_type_(&mut self, type_: ::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>) {
|
||||||
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Table2::VT_TYPE_, type_);
|
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Table2::VT_TYPE_, type_);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> Table2Builder<'a, 'b, A> {
|
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> Table2Builder<'a, 'b, A> {
|
||||||
let start = _fbb.start_table();
|
let start = _fbb.start_table();
|
||||||
@@ -158,6 +167,7 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> Table2Builder<'a, 'b, A> {
|
|||||||
start_: start,
|
start_: start,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn finish(self) -> ::flatbuffers::WIPOffset<Table2<'a>> {
|
pub fn finish(self) -> ::flatbuffers::WIPOffset<Table2<'a>> {
|
||||||
let o = self.fbb_.end_table(self.start_);
|
let o = self.fbb_.end_table(self.start_);
|
||||||
@@ -192,11 +202,13 @@ impl ::core::fmt::Debug for Table2<'_> {
|
|||||||
ds.finish()
|
ds.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct Table2T {
|
pub struct Table2T {
|
||||||
pub type_: KeywordsInUnionT,
|
pub type_: KeywordsInUnionT,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Table2T {
|
impl Default for Table2T {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
@@ -204,6 +216,7 @@ impl Default for Table2T {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Table2T {
|
impl Table2T {
|
||||||
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
||||||
&self,
|
&self,
|
||||||
|
|||||||
@@ -2,15 +2,18 @@
|
|||||||
// @generated
|
// @generated
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
// struct Ability, aligned to 4
|
// struct Ability, aligned to 4
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Clone, Copy, PartialEq)]
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
pub struct Ability(pub [u8; 8]);
|
pub struct Ability(pub [u8; 8]);
|
||||||
|
|
||||||
impl Default for Ability {
|
impl Default for Ability {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self([0; 8])
|
Self([0; 8])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::fmt::Debug for Ability {
|
impl ::core::fmt::Debug for Ability {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
f.debug_struct("Ability")
|
f.debug_struct("Ability")
|
||||||
@@ -21,27 +24,34 @@ impl ::core::fmt::Debug for Ability {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ::flatbuffers::SimpleToVerifyInSlice for Ability {}
|
impl ::flatbuffers::SimpleToVerifyInSlice for Ability {}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for Ability {
|
impl<'a> ::flatbuffers::Follow<'a> for Ability {
|
||||||
type Inner = &'a Ability;
|
type Inner = &'a Ability;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
unsafe { <&'a Ability>::follow(buf, loc) }
|
unsafe { <&'a Ability>::follow(buf, loc) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for &'a Ability {
|
impl<'a> ::flatbuffers::Follow<'a> for &'a Ability {
|
||||||
type Inner = &'a Ability;
|
type Inner = &'a Ability;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
unsafe { ::flatbuffers::follow_cast_ref::<Ability>(buf, loc) }
|
unsafe { ::flatbuffers::follow_cast_ref::<Ability>(buf, loc) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'b> ::flatbuffers::Push for Ability {
|
impl<'b> ::flatbuffers::Push for Ability {
|
||||||
type Output = Ability;
|
type Output = Ability;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||||
let src = unsafe { ::core::slice::from_raw_parts(self as *const Ability as *const u8, <Self as ::flatbuffers::Push>::size()) };
|
let src = unsafe { ::core::slice::from_raw_parts(self as *const Ability as *const u8, <Self as ::flatbuffers::Push>::size()) };
|
||||||
dst.copy_from_slice(src);
|
dst.copy_from_slice(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn alignment() -> ::flatbuffers::PushAlignment {
|
fn alignment() -> ::flatbuffers::PushAlignment {
|
||||||
::flatbuffers::PushAlignment::new(4)
|
::flatbuffers::PushAlignment::new(4)
|
||||||
@@ -102,6 +112,7 @@ impl<'a> Ability {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn key_compare_less_than(&self, o: &Ability) -> bool {
|
pub fn key_compare_less_than(&self, o: &Ability) -> bool {
|
||||||
self.id() < o.id()
|
self.id() < o.id()
|
||||||
@@ -149,11 +160,20 @@ impl<'a> Ability {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct AbilityT {
|
pub struct AbilityT {
|
||||||
pub id: u32,
|
pub id: u32,
|
||||||
pub distance: u32,
|
pub distance: u32,
|
||||||
}
|
}
|
||||||
|
impl Default for AbilityT {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
id: 0,
|
||||||
|
distance: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl AbilityT {
|
impl AbilityT {
|
||||||
pub fn pack(&self) -> Ability {
|
pub fn pack(&self) -> Ability {
|
||||||
Ability::new(
|
Ability::new(
|
||||||
@@ -162,4 +182,3 @@ impl AbilityT {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,13 @@
|
|||||||
// @generated
|
// @generated
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
pub const ENUM_MIN_ANY_AMBIGUOUS_ALIASES: u8 = 0;
|
pub const ENUM_MIN_ANY_AMBIGUOUS_ALIASES: u8 = 0;
|
||||||
|
|
||||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
pub const ENUM_MAX_ANY_AMBIGUOUS_ALIASES: u8 = 3;
|
pub const ENUM_MAX_ANY_AMBIGUOUS_ALIASES: u8 = 3;
|
||||||
|
|
||||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub const ENUM_VALUES_ANY_AMBIGUOUS_ALIASES: [AnyAmbiguousAliases; 4] = [
|
pub const ENUM_VALUES_ANY_AMBIGUOUS_ALIASES: [AnyAmbiguousAliases; 4] = [
|
||||||
@@ -18,6 +21,7 @@ pub const ENUM_VALUES_ANY_AMBIGUOUS_ALIASES: [AnyAmbiguousAliases; 4] = [
|
|||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct AnyAmbiguousAliases(pub u8);
|
pub struct AnyAmbiguousAliases(pub u8);
|
||||||
|
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
impl AnyAmbiguousAliases {
|
impl AnyAmbiguousAliases {
|
||||||
pub const NONE: Self = Self(0);
|
pub const NONE: Self = Self(0);
|
||||||
@@ -33,6 +37,7 @@ impl AnyAmbiguousAliases {
|
|||||||
Self::M2,
|
Self::M2,
|
||||||
Self::M3,
|
Self::M3,
|
||||||
];
|
];
|
||||||
|
|
||||||
/// Returns the variant's name or "" if unknown.
|
/// Returns the variant's name or "" if unknown.
|
||||||
pub fn variant_name(self) -> Option<&'static str> {
|
pub fn variant_name(self) -> Option<&'static str> {
|
||||||
match self {
|
match self {
|
||||||
@@ -44,6 +49,7 @@ impl AnyAmbiguousAliases {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::fmt::Debug for AnyAmbiguousAliases {
|
impl ::core::fmt::Debug for AnyAmbiguousAliases {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
if let Some(name) = self.variant_name() {
|
if let Some(name) = self.variant_name() {
|
||||||
@@ -53,8 +59,10 @@ impl ::core::fmt::Debug for AnyAmbiguousAliases {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::flatbuffers::Follow<'a> for AnyAmbiguousAliases {
|
impl<'a> ::flatbuffers::Follow<'a> for AnyAmbiguousAliases {
|
||||||
type Inner = Self;
|
type Inner = Self;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
|
let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
|
||||||
@@ -64,6 +72,7 @@ impl<'a> ::flatbuffers::Follow<'a> for AnyAmbiguousAliases {
|
|||||||
|
|
||||||
impl ::flatbuffers::Push for AnyAmbiguousAliases {
|
impl ::flatbuffers::Push for AnyAmbiguousAliases {
|
||||||
type Output = AnyAmbiguousAliases;
|
type Output = AnyAmbiguousAliases;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||||
unsafe { ::flatbuffers::emplace_scalar::<u8>(dst, self.0) };
|
unsafe { ::flatbuffers::emplace_scalar::<u8>(dst, self.0) };
|
||||||
@@ -72,10 +81,12 @@ impl ::flatbuffers::Push for AnyAmbiguousAliases {
|
|||||||
|
|
||||||
impl ::flatbuffers::EndianScalar for AnyAmbiguousAliases {
|
impl ::flatbuffers::EndianScalar for AnyAmbiguousAliases {
|
||||||
type Scalar = u8;
|
type Scalar = u8;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_little_endian(self) -> u8 {
|
fn to_little_endian(self) -> u8 {
|
||||||
self.0.to_le()
|
self.0.to_le()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(clippy::wrong_self_convention)]
|
#[allow(clippy::wrong_self_convention)]
|
||||||
fn from_little_endian(v: u8) -> Self {
|
fn from_little_endian(v: u8) -> Self {
|
||||||
@@ -94,6 +105,7 @@ impl<'a> ::flatbuffers::Verifiable for AnyAmbiguousAliases {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ::flatbuffers::SimpleToVerifyInSlice for AnyAmbiguousAliases {}
|
impl ::flatbuffers::SimpleToVerifyInSlice for AnyAmbiguousAliases {}
|
||||||
|
|
||||||
pub struct AnyAmbiguousAliasesUnionTableOffset {}
|
pub struct AnyAmbiguousAliasesUnionTableOffset {}
|
||||||
|
|
||||||
#[allow(clippy::upper_case_acronyms)]
|
#[allow(clippy::upper_case_acronyms)]
|
||||||
@@ -105,11 +117,13 @@ pub enum AnyAmbiguousAliasesT {
|
|||||||
M2(alloc::boxed::Box<MonsterT>),
|
M2(alloc::boxed::Box<MonsterT>),
|
||||||
M3(alloc::boxed::Box<MonsterT>),
|
M3(alloc::boxed::Box<MonsterT>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for AnyAmbiguousAliasesT {
|
impl Default for AnyAmbiguousAliasesT {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::NONE
|
Self::NONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AnyAmbiguousAliasesT {
|
impl AnyAmbiguousAliasesT {
|
||||||
pub fn any_ambiguous_aliases_type(&self) -> AnyAmbiguousAliases {
|
pub fn any_ambiguous_aliases_type(&self) -> AnyAmbiguousAliases {
|
||||||
match self {
|
match self {
|
||||||
@@ -119,6 +133,7 @@ impl AnyAmbiguousAliasesT {
|
|||||||
Self::M3(_) => AnyAmbiguousAliases::M3,
|
Self::M3(_) => AnyAmbiguousAliases::M3,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(&self, fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>) -> Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>> {
|
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(&self, fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>) -> Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>> {
|
||||||
match self {
|
match self {
|
||||||
Self::NONE => None,
|
Self::NONE => None,
|
||||||
@@ -127,6 +142,7 @@ impl AnyAmbiguousAliasesT {
|
|||||||
Self::M3(v) => Some(v.pack(fbb).as_union_value()),
|
Self::M3(v) => Some(v.pack(fbb).as_union_value()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If the union variant matches, return the owned MonsterT, setting the union to NONE.
|
/// If the union variant matches, return the owned MonsterT, setting the union to NONE.
|
||||||
pub fn take_m1(&mut self) -> Option<alloc::boxed::Box<MonsterT>> {
|
pub fn take_m1(&mut self) -> Option<alloc::boxed::Box<MonsterT>> {
|
||||||
if let Self::M1(_) = self {
|
if let Self::M1(_) = self {
|
||||||
@@ -140,14 +156,17 @@ impl AnyAmbiguousAliasesT {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If the union variant matches, return a reference to the MonsterT.
|
/// If the union variant matches, return a reference to the MonsterT.
|
||||||
pub fn as_m1(&self) -> Option<&MonsterT> {
|
pub fn as_m1(&self) -> Option<&MonsterT> {
|
||||||
if let Self::M1(v) = self { Some(v.as_ref()) } else { None }
|
if let Self::M1(v) = self { Some(v.as_ref()) } else { None }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If the union variant matches, return a mutable reference to the MonsterT.
|
/// If the union variant matches, return a mutable reference to the MonsterT.
|
||||||
pub fn as_m1_mut(&mut self) -> Option<&mut MonsterT> {
|
pub fn as_m1_mut(&mut self) -> Option<&mut MonsterT> {
|
||||||
if let Self::M1(v) = self { Some(v.as_mut()) } else { None }
|
if let Self::M1(v) = self { Some(v.as_mut()) } else { None }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If the union variant matches, return the owned MonsterT, setting the union to NONE.
|
/// If the union variant matches, return the owned MonsterT, setting the union to NONE.
|
||||||
pub fn take_m2(&mut self) -> Option<alloc::boxed::Box<MonsterT>> {
|
pub fn take_m2(&mut self) -> Option<alloc::boxed::Box<MonsterT>> {
|
||||||
if let Self::M2(_) = self {
|
if let Self::M2(_) = self {
|
||||||
@@ -161,14 +180,17 @@ impl AnyAmbiguousAliasesT {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If the union variant matches, return a reference to the MonsterT.
|
/// If the union variant matches, return a reference to the MonsterT.
|
||||||
pub fn as_m2(&self) -> Option<&MonsterT> {
|
pub fn as_m2(&self) -> Option<&MonsterT> {
|
||||||
if let Self::M2(v) = self { Some(v.as_ref()) } else { None }
|
if let Self::M2(v) = self { Some(v.as_ref()) } else { None }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If the union variant matches, return a mutable reference to the MonsterT.
|
/// If the union variant matches, return a mutable reference to the MonsterT.
|
||||||
pub fn as_m2_mut(&mut self) -> Option<&mut MonsterT> {
|
pub fn as_m2_mut(&mut self) -> Option<&mut MonsterT> {
|
||||||
if let Self::M2(v) = self { Some(v.as_mut()) } else { None }
|
if let Self::M2(v) = self { Some(v.as_mut()) } else { None }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If the union variant matches, return the owned MonsterT, setting the union to NONE.
|
/// If the union variant matches, return the owned MonsterT, setting the union to NONE.
|
||||||
pub fn take_m3(&mut self) -> Option<alloc::boxed::Box<MonsterT>> {
|
pub fn take_m3(&mut self) -> Option<alloc::boxed::Box<MonsterT>> {
|
||||||
if let Self::M3(_) = self {
|
if let Self::M3(_) = self {
|
||||||
@@ -182,12 +204,15 @@ impl AnyAmbiguousAliasesT {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If the union variant matches, return a reference to the MonsterT.
|
/// If the union variant matches, return a reference to the MonsterT.
|
||||||
pub fn as_m3(&self) -> Option<&MonsterT> {
|
pub fn as_m3(&self) -> Option<&MonsterT> {
|
||||||
if let Self::M3(v) = self { Some(v.as_ref()) } else { None }
|
if let Self::M3(v) = self { Some(v.as_ref()) } else { None }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If the union variant matches, return a mutable reference to the MonsterT.
|
/// If the union variant matches, return a mutable reference to the MonsterT.
|
||||||
pub fn as_m3_mut(&mut self) -> Option<&mut MonsterT> {
|
pub fn as_m3_mut(&mut self) -> Option<&mut MonsterT> {
|
||||||
if let Self::M3(v) = self { Some(v.as_mut()) } else { None }
|
if let Self::M3(v) = self { Some(v.as_mut()) } else { None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user