Squashed 'third_party/flatbuffers/' changes from e5f331db9..bc44fad35
bc44fad35 UnPackTo disable merge by default (#7527)
4fca4dc60 [TS/JS] Move TS tests to dedicated folder and deps upgrade (#7508)
036032373 Bump junit from 4.13 to 4.13.1 in /java (#7526)
89dfb43f3 Replace `bash JavaTest.sh` with `mvn test` (#7500)
c49aff4b6 enabled cpp17 tests in CI (#7524)
56e60223c prevent force_align attribute on enums (#7523)
89b1f5aa1 remove travis config (#7522)
b90159823 [Java][Flexbuffers] Add API to add nullables into the buffer. (#7521)
8cdc6a288 Install BuildFlatBuffers.cmake (#7519)
a67e35aff Moves all of the swift test code into tests/swift (#7509)
f124e41ae Updated Readme
4c954181c [Java][FlexBuffers] throwing exception for untyped fixed vectors (#7507)
7f7547737 [Android] Remove maven dependency of flatbuffers and use source folder (#7503)
a79d61ea8 Fixes issue with cocoapods failing to be published because of docc (#7505)
d465b39c3 [CMake]: fix breaking find_package change (#7499) (#7502)
c5a609dc2 [C#] Prepares for official Nuget release (#7496)
5634dc3d0 [ISSUE-6268] returns NaN insteadof nan (#7498)
37e37b8ca Updates cocoapods version (#7497)
8fd4534fb update android multidex setting (#7495)
d5427da52 Disable Android Build (#7494)
06c5c7ed0 FlatBuffers Version 2.0.8 (#7492)
b190ce11b Verifier Refinements (#7490)
bf5d23230 Namer applied to Typescript generator (#7488)
ce382d6dd [TS/JS] Add rollup and config to generate iife flatbuffers bundle (#7449)
41d9add7e C++: Add option to skip verifying nested flatbuffers (#7489)
6a8742754 [C++] support native_inline attribute for vector of tables (#7479)
694add668 Refactor test.cpp (#7487)
7edf8c908 Update scorecard to 1.1.2
b86387442 Fix typos (#7483)
e2eb5ee67 Include <array> head in stl_emulation.h (#7480)
994502b6d Version number in file package.json updated to 2.0.7 (#7476)
fa41e8367 [C++] Fixed crash when copying table with empty shared strings (#7477)
799cc8f7b Use type traits for specialization (#7475)
b7eb44147 Disable RTTI and rework use in idl_gen_ts.cpp (#7474)
8d01c5859 CMake project version detection made more robust (#7473)
237e8b71f Moved compiler warnings around (#7471)
eeb8fd60d Include builder.addOffset for vector of structs (#7470)
fef2ffc4d Use schema include name for keep-prefix (#7469)
8367664f1 Flatbuffers Version 2.0.7 (#7462)
d6f06c33f Reworked keep prefix (#7456)
627e8bf36 update grpc version (#7457)
883c42b7d disabling unpackto optimization (#7459)
7aae0af30 Remove old GRPC bash script and convert to python3 (#7454)
b057aa917 Grouped anonymous namespaces together, (#7455)
f1b26ff7f Change to GetTypeName (#7453)
9610a666b Generate SLSA signatures for Released zip files (#7450)
1e0f75a64 [WIP] speedup (#7452)
82b75407a Wrap types in namespace for --ts-flat-files and --gen-all (#7451)
f7c511957 Audit and fixups for GCC and Clang (#7212)
a66de58af Partial support for --ts-flat-files and --gen-all (#7446)
a3508f36d [Kotlin] Make sure namespace path exist for code generation (#7357)
137fec716 Stop using __has_trivial_copy on recent clang versions. (#7443)
214125e41 [C#] Rework how sorted vectors are looked up (#7441)
44a7dc999 Define minimum buffer size (#7440)
3cc2daa78 make_span overloads for pointer to vector (#7374) (#7435)
fa1174aa7 [TypeScript] Fix namespaceless schema generation (#7432)
83d4e2a10 Add checks to verifier (#7438)
8a09f3fb0 Fix FlexBuffers JS/TS bug https://github.com/google/flatbuffers/issues/6934 (#7434)
9dbe819ef Add flatc python tests to CI (#7437)
67c414958 Update TypeScriptTest.py to work better cross platform (#7436)
8b8c7dbdf Update gitingore to reflect name change (#7431)
2ee20a5f3 Remove auto including locale functions (#7430)
4be605604 [C++] Set StructDef::has_key property when deserializing from binary schema (#7386) (#7428)
fc5d86f1e [C++] Make template parameter in stl_emulation.h more explicit to avoid conflicts with cpprestsdk U macro (#7424)
9dce287ad Issue#6959 :Updated Automatically generated rust files. (#7425)
7798be3bb avoid zero-as-null-pointer warning (#7423)
966362e07 [C++] Vector of Tables equality (#7415)
a89c279ed [golang] Perform keyword escaping after case conversion (#7421)
a212b3c03 Turn of fail fast for C++ CI
9230f600d Remove stringop-overflow from error (#7422)
c79362156 [golang] Add support for text parsing with json struct tags (#7353)
ee2ced236 Moved TypeScriptTests to python script (#7411)
468c00a3f Rebased: grpc/compiler: Respect filename suffix and extension during code generation (#7414)
47c757f71 Add tests for flatc (#7405)
9a5ff8900 Add FLATBUFFERS_STRICT_MODE (#7408)
950444a34 [TS] Use TextEncoder and TextDecoder (#7400)
30d76198c Compilation issue msys2 #7399 (#7409)
cce3a66f0 Delete .travis directory
8d1cc6ac7 Revert "Compilation issue msys2 (#7403)" (#7407)
5b207639a Update readme.md
359e0f9d6 Revert "grpc/compiler: Respect filename suffix and extension during code generation (#7343)" (#7406)
ebbed0513 Delete cpp-linter.yml
aa395e5a5 (#7323) Rename CMake files according to project name (#7378)
32328075d Fix error msg format when generate GRPC failed (#7350)
97e89c5ac grpc/compiler: Respect filename suffix and extension during code generation (#7343)
5f6672be4 Fix Clang-Cl compile on Windows (#7308)
28e858c85 [TS/Bazel] Minor improvements to typescript.bzl (#7300)
987bebe67 [TS] fix incorrect reverse when writting array of structs (#7271)
ec0129369 Fix FlexBuffers Verifier tracking vectors reuse at wrong offset
50dd385b3 Add missing const (#7401)
da702cfd8 Compilation issue msys2 (#7403)
6e2791640 keep-prefix keeps relative pathing (#7394)
52fce5e53 fix(#7360): grpc used deprecated functions (#7361)
b7f13cd8e cpp_generator: comment out unused parameter to avoid warnings (#7381)
e42985e5a Updated Newtonsoft.Json to 13.0.1 (#7393)
0a8064637 Fix references to LICENSE file (#7377)
b9eea76a8 [Dart] Implement putBool to fix errors when serializing structs with bools (#7359)
1b9030015 Bump Newtonsoft.Json from 12.0.3 to 13.0.1 in /tests/FlatBuffers.Test (#7363)
83a43fc79 Reenable optional json (#7352)
5f0137602 Only include direct included filed (#7348)
9a1913a87 Revert "Implement optional scalars for JSON (#7322)" (#7351)
b4647beb8 Revert "Move reflection_ts_fbs into a separate directory (#7342)" (#7349)
d6060977a Remove asserting in verifier for flattests
987aa5b5e move -Wextra-semi to GCC 8.0+
42acdb63c [TS] Don't generate self-imports with --ts-flat-file (#7340)
0cc1aeb8c [golang] Create missing namespace directory structure (#7324) (#7325)
ba6c67170 [Kotlin] Remove download benchmark files dependency (#7314)
d2f33fc45 Disable Android on Linux CI build
0d1b72cbc [TS] fix ts import path issue (#7298)
9fce2fbf2 replace io/ioutil to os (#7281)
a18ea40d6 Implement optional scalars for JSON (#7322)
090caa280 Move reflection_ts_fbs into a separate directory (#7342)
49e1ea333 Implement optional scalars for Python (#7318)
11a198870 Started implementation for private flags in rust (#7269)
967df08b1 Adds full supposed for Wasm in the swift lib (#7328)
9aa08a429 Use keep case for Rust union discriminant type. (#7321)
9e8c758f5 Add explicit return types to lobster generated code (#7312)
74a25536b Add size check to fix out of bounds read risk (#7304)
12917af8a Update Rust docs page (#7296)
1ea2472f7 [swift] add had<ArrayName> property for arrays to check presence in a message (#7280)
0fe13cb28 Remove span ConstIterator/cbegin()/cend(). (#7295)
385dddc66 Namerkot (#7245)
750dde766 Make `flatc` generate Rust files not requiring `std` (#7273)
9917a168c [swift] Make swift module public (#7274)
76d3cca19 Rust: fix a name conflict when building with "no_std" feature (#7268)
c86e6d0e3 json inf parsing
d34dc32c2 fix include order
234d86c92 fixed off-by-one in parser
746c73b91 Add Annotations for Monster schema and example buffer
0bbfd4b2e fixes for annotator
716521953 Update readme.md (#7257)
a45f564cf [performance] Add aggressive systematic inlining in ByteBuffer and FlatBufferBuilder (#7253)
9d45a6403 more google merge fixes
ccfb4c20b Handle +/-inf in protos (#7256)
7bcd857b8 Specialize CreateVector with std::initializer_list (#7254)
23c8ab34c Swift update performance benchmark infrastructure (#7255)
70002dc5c various fixes for google merge
6e0e79f24 Add test for nested buffer verifier (#7252)
b856368d7 Turn off go modules temporary until we get a proper fix (#7251)
e37156a30 Keep the underlying storage capacity when clearing the FlatBufferBuilder. Gives a significant performance boost for serialisation of many small messages. (#7250)
a10b0e546 Java namer variable keep case (#7249)
275b73994 allow overriding FLATBUFFERS_MAX_ALIGNMENT
9d1ce9a10 Add parameter back to EndVector (#7246)
79afe6c3d Make Java namespaces keep case by default (#7243)
c6dbb2230 Add write permissions for labeller
18bacd3ea Expand test to make sure {}-initializers are properly understood by template. (#7242)
a2c913aec Add -Wnon-virtual-dtor
67b33b294 set workflows permissions to read-only (#7239)
7b5fd2bd0 [Kotlin] Fix key lookup returning null clashing with default value (#7237)
7181d7770 [Java] Fix key lookup returning null clashing with default value (#7236)
7f663b120 Allow CreateVectorOfStrings() to work with any string-type. (#7238)
173ebb694 Fixes a bug where the create function doesnt optional + required items (#7228)
d65823948 [Kotlin] Update gradle to 7.4.1 and simplify config files. (#7231)
ab4bf59e8 remove toascii (#7234)
eee44bbb2 disable cpp-linter (#7229)
a63fa51a1 Create cpp-linter.yml (#7208)
2049e5210 Adds a way to verify/exposes Entities ids (#7221)
832c618f5 Adds implementation flag for swift (#7202)
14615699f Started to migrate to target_compile_options (#7222)
20aad0c41 [C++] stl_emulation span::count_ is not const anymore (#7226) (#7227)
f083b33f2 code gen flexbuffer verifier (#7207)
bf17df346 [C++] generate sorted #include directives (#7213)
35281dedb Fix for [C++] flatc generates invalid Code in the default constructor for structs, when --cpp-field-case-style is used #7209 (#7211)
c9651b742 Add overloads for C# ByteBuffer/FlatBufferBuilder to allow adding vector blocks from ArraySegments or IntPtr (#7193)
26c3b3ada Update codeql.yml
da6e1b985 Update codeql.yml
ad27d751e Added Oss fuzz badge
0aab623cb Create codeql.yml
6a446bdd8 maximize parallel builds in CI (#7206)
21fb5cbbc Create scorecards.yml
0da6f9486 [C++] Static assert on Flatbuffers Version (#7203)
59e971308 reduce fuzzing time to 1 minute in CI
40866a892 fixed padding in struct for annotated binary (#7199)
b71d968fa Apply Namer prefix/suffix to other generators (#7197)
fac0d7be0 Apply Namer to Java. (#7194)
6c5603fd9 [C#] Fix collision of field name and type name (#7149)
2d21853a7 monster fuzzer fix for json default scalars
fec1a8d01 [swift] Add bazel configuration for Swift (#7195)
7fd857623 structured comments (#7192)
a4cb1599d Namerdart (#7187)
ae4ce7265 fuzzed binary annotator (#7188)
e2be0c0b0 Handle root offset and root table vtable invalidation (#7177)
2ad408697 [TS] Fix generation of struct members in object api (#7148)
4213d9105 VerifySizePrefixed (reflection::Schema) and GetAnySizePrefixedRoot added (#7181)
5a13f622c Correctly parse lists of enums in Dart generated code (#7157)
23a7e4e0b Adds no-includes flags to the swift code generator (#7182)
eeb49c275 Move flatbuffer_ts_library to typescript.bzl (#7183)
824763b31 Typo in flatc options (warning-as-errors instead of warnings-as-errors) (#7180)
d3aeee32b Annotated Flatbuffer Binary (#7174)
0bceba24d [Lua] Apply Namer to Lua (#7171)
b8c77d404 Make inclusion of header <optional> opt-out via macro (#7168)
8468eab83 Namersw (#7167)
2b2e8d4ae Nameroverloads (#7164)
b80b32bfa Use DESCRIPTION only if CMake version >= 3.9 (#7166)
Change-Id: Ic2681dabb1a798b7515e62753ee06aecb9933260
git-subtree-dir: third_party/flatbuffers
git-subtree-split: bc44fad35271e43fd7a79b4d691ac9e41708797f
Signed-off-by: Austin Schuh <austin.schuh@bluerivertech.com>
diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml
index 33cb7c2..df480cc 100644
--- a/.bazelci/presubmit.yml
+++ b/.bazelci/presubmit.yml
@@ -2,11 +2,29 @@
buildifier: latest
platforms:
ubuntu1804:
+ environment:
+ CC: clang
+ SWIFT_VERSION: "5.5.3"
+ SWIFT_HOME: "$HOME/swift-$SWIFT_VERSION"
+ PATH: "$PATH:$SWIFT_HOME/usr/bin"
+ shell_commands:
+ - "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME"
+ - "mkdir $SWIFT_HOME"
+ - "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu1804/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu18.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME"
build_targets:
- "//..."
test_targets:
- "//..."
ubuntu2004:
+ environment:
+ CC: clang
+ SWIFT_VERSION: "5.5.3"
+ SWIFT_HOME: "$HOME/swift-$SWIFT_VERSION"
+ PATH: "$PATH:$SWIFT_HOME/usr/bin"
+ shell_commands:
+ - "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME"
+ - "mkdir $SWIFT_HOME"
+ - "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu2004/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu20.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME"
build_targets:
- "//..."
test_targets:
diff --git a/.github/labeler.yml b/.github/labeler.yml
index 5de0c3a..eb1d7fd 100644
--- a/.github/labeler.yml
+++ b/.github/labeler.yml
@@ -15,9 +15,7 @@
swift:
- '**/*.swift'
- swift/**/*
- - tests/FlatBuffers.GRPC.Swift/**/*
- - tests/FlatBuffers.Benchmarks.swift/**/*
- - tests/FlatBuffers.Test.Swift/**/*
+ - tests/swift/**
- src/idl_gen_swift.cpp
javascript:
@@ -86,9 +84,7 @@
CI:
- '.github/**/*'
- - '.travis/**/*'
- '.bazelci/**/*'
- - .travis.yml
grpc:
- grpc/**/*
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 925e86a..cb4e1f3 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -1,7 +1,12 @@
name: CI
+permissions: read-all
on:
+ # For manual tests.
+ workflow_dispatch:
push:
+ tags:
+ - "*" # new tag version, like `0.8.4` or else
branches:
- master
pull_request:
@@ -10,30 +15,112 @@
jobs:
build-linux:
+ permissions:
+ contents: write
+ outputs:
+ digests-gcc: ${{ steps.hash-gcc.outputs.hashes }}
+ digests-clang: ${{ steps.hash-clang.outputs.hashes }}
name: Build Linux
runs-on: ubuntu-latest
strategy:
matrix:
cxx: [g++-10, clang++-12]
+ fail-fast: false
steps:
- uses: actions/checkout@v2
- name: cmake
- run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release .
+ run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON .
- name: build
- run: make -j4
+ run: make -j
- name: test
run: ./flattests
- name: make flatc executable
run: |
chmod +x flatc
./flatc --version
+ - name: flatc tests
+ run: python3 tests/flatc/main.py
- name: upload build artifacts
uses: actions/upload-artifact@v1
with:
name: Linux flatc binary ${{ matrix.cxx }}
path: flatc
+ # Below if only for release.
+ - name: Zip file
+ if: startsWith(github.ref, 'refs/tags/')
+ run: zip Linux.flatc.binary.${{ matrix.cxx }}.zip flatc
+ - name: Release zip file
+ uses: softprops/action-gh-release@v1
+ if: startsWith(github.ref, 'refs/tags/')
+ with:
+ files: Linux.flatc.binary.${{ matrix.cxx }}.zip
+ - name: Generate SLSA subjects - clang
+ if: matrix.cxx == 'clang++-12' && startsWith(github.ref, 'refs/tags/')
+ id: hash-clang
+ run: echo "::set-output name=hashes::$(sha256sum Linux.flatc.binary.${{ matrix.cxx }}.zip | base64 -w0)"
+ - name: Generate SLSA subjects - gcc
+ if: matrix.cxx == 'g++-10' && startsWith(github.ref, 'refs/tags/')
+ id: hash-gcc
+ run: echo "::set-output name=hashes::$(sha256sum Linux.flatc.binary.${{ matrix.cxx }}.zip | base64 -w0)"
+
+ build-linux-cpp-std:
+ name: Build Linux C++
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ std: [11, 14, 17, 20, 23]
+ cxx: [g++-10, clang++-12]
+ exclude:
+ # GCC 10.3.0 doesn't support std 23
+ - cxx: g++-10
+ std: 23
+ steps:
+ - uses: actions/checkout@v2
+ - name: cmake
+ run: >
+ CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles"
+ -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON
+ -DFLATBUFFERS_CPP_STD=${{ matrix.std }}
+ -DFLATBUFFERS_BUILD_CPP17=${{ matrix.std >= 17 && 'On' || 'Off'}}
+ - name: build
+ run: make -j
+ - name: test
+ run: ./flattests
+ - name: test C++17
+ if: matrix.std >= 17
+ run: ./flattests_cpp17
+
+ build-windows-cpp-std:
+ name: Build Windows C++
+ runs-on: windows-2019
+ strategy:
+ matrix:
+ std: [11, 14, 17, 20, 23]
+ fail-fast: false
+ steps:
+ - uses: actions/checkout@v2
+ - name: Add msbuild to PATH
+ uses: microsoft/setup-msbuild@v1.1
+ - name: cmake
+ run: >
+ cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release
+ -DFLATBUFFERS_STRICT_MODE=ON
+ -DFLATBUFFERS_CPP_STD=${{ matrix.std }}
+ -DFLATBUFFERS_BUILD_CPP17=${{ matrix.std >= 17 && 'On' || 'Off'}}
+ - name: build
+ run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64
+ - name: test
+ run: Release\flattests.exe
+ - name: test C++17
+ if: matrix.std >= 17
+ run: Release\flattests_cpp17.exe
build-windows:
+ permissions:
+ contents: write
+ outputs:
+ digests: ${{ steps.hash.outputs.hashes }}
name: Build Windows 2019
runs-on: windows-2019
steps:
@@ -41,16 +128,32 @@
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
- name: cmake
- run: cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_CPP17=ON .
+ run: cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_CPP17=ON -DFLATBUFFERS_STRICT_MODE=ON .
- name: build
run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64
- name: test
run: Release\flattests.exe
+ - name: flatc tests
+ run: python3 tests/flatc/main.py --flatc Release\flatc.exe
- name: upload build artifacts
uses: actions/upload-artifact@v1
with:
name: Windows flatc binary
path: Release\flatc.exe
+ # Below if only for release.
+ - name: Zip file
+ if: startsWith(github.ref, 'refs/tags/')
+ run: move Release/flatc.exe . && Compress-Archive flatc.exe Windows.flatc.binary.zip
+ - name: Release binary
+ uses: softprops/action-gh-release@v1
+ if: startsWith(github.ref, 'refs/tags/')
+ with:
+ files: Windows.flatc.binary.zip
+ - name: Generate SLSA subjects
+ if: startsWith(github.ref, 'refs/tags/')
+ id: hash
+ shell: bash
+ run: echo "::set-output name=hashes::$(sha256sum Windows.flatc.binary.zip | base64 -w0)"
build-windows-2017:
name: Build Windows 2017
@@ -60,7 +163,7 @@
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
- name: cmake
- run: cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release .
+ run: cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON .
- name: build tool version 15 (VS 2017)
run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64 /p:VisualStudioVersion=15.0
- name: test
@@ -74,7 +177,7 @@
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
- name: cmake
- run: cmake -G "Visual Studio 14 2015" -A x64 -DCMAKE_BUILD_TYPE=Release .
+ run: cmake -G "Visual Studio 14 2015" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON .
- name: build tool version 14 (VS 2015)
run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64 /p:VisualStudioVersion=14.0
- name: test
@@ -108,13 +211,63 @@
cd tests\FlatBuffers.Test
out\FlatBuffers.Core.Test.exe
- build-mac:
- name: Build Mac
+ build-mac-intel:
+ permissions:
+ contents: write
+ outputs:
+ digests: ${{ steps.hash.outputs.hashes }}
+ name: Build Mac (for Intel)
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: cmake
- run: cmake -G "Xcode" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_FLATC_EXECUTABLE=_build/Release/flatc .
+ run: cmake -G "Xcode" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_FLATC_EXECUTABLE=_build/Release/flatc -DFLATBUFFERS_STRICT_MODE=ON .
+ - name: build
+ # NOTE: we need this _build dir to not have xcodebuild's default ./build dir clash with the BUILD file.
+ run: xcodebuild -toolchain clang -configuration Release -target flattests SYMROOT=$(PWD)/_build
+ - name: check that the binary is x86_64
+ run: |
+ info=$(file _build/Release/flatc)
+ echo $info
+ echo $info | grep "Mach-O 64-bit executable x86_64"
+ - name: test
+ run: _build/Release/flattests
+ - name: make flatc executable
+ run: |
+ chmod +x _build/Release/flatc
+ ./_build/Release/flatc --version
+ - name: flatc tests
+ run: python3 tests/flatc/main.py --flatc ./_build/Release/flatc
+ - name: upload build artifacts
+ uses: actions/upload-artifact@v1
+ with:
+ name: Mac flatc binary
+ path: _build/Release/flatc
+ # Below if only for release.
+ - name: Zip file
+ if: startsWith(github.ref, 'refs/tags/')
+ run: mv _build/Release/flatc . && zip MacIntel.flatc.binary.zip flatc
+ - name: Release binary
+ uses: softprops/action-gh-release@v1
+ if: startsWith(github.ref, 'refs/tags/')
+ with:
+ files: MacIntel.flatc.binary.zip
+ - name: Generate SLSA subjects
+ if: startsWith(github.ref, 'refs/tags/')
+ id: hash
+ run: echo "::set-output name=hashes::$(shasum -a 256 MacIntel.flatc.binary.zip | base64)"
+
+ build-mac-universal:
+ permissions:
+ contents: write
+ outputs:
+ digests: ${{ steps.hash.outputs.hashes }}
+ name: Build Mac (universal build)
+ runs-on: macos-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: cmake
+ run: cmake -G "Xcode" -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_FLATC_EXECUTABLE=_build/Release/flatc -DFLATBUFFERS_STRICT_MODE=ON .
- name: build
# NOTE: we need this _build dir to not have xcodebuild's default ./build dir clash with the BUILD file.
run: xcodebuild -toolchain clang -configuration Release -target flattests SYMROOT=$(PWD)/_build
@@ -122,7 +275,7 @@
run: |
info=$(file _build/Release/flatc)
echo $info
- echo $info | grep "universal binary with 2 architectures"
+ echo $info | grep "Mach-O universal binary with 2 architectures"
- name: test
run: _build/Release/flattests
- name: make flatc executable
@@ -134,6 +287,19 @@
with:
name: Mac flatc binary
path: _build/Release/flatc
+ # Below if only for release.
+ - name: Zip file
+ if: startsWith(github.ref, 'refs/tags/')
+ run: mv _build/Release/flatc . && zip Mac.flatc.binary.zip flatc
+ - name: Release binary
+ uses: softprops/action-gh-release@v1
+ if: startsWith(github.ref, 'refs/tags/')
+ with:
+ files: Mac.flatc.binary.zip
+ - name: Generate SLSA subjects
+ if: startsWith(github.ref, 'refs/tags/')
+ id: hash
+ run: echo "::set-output name=hashes::$(shasum -a 256 Mac.flatc.binary.zip | base64)"
build-android:
name: Build Android (on Linux)
@@ -146,12 +312,12 @@
java-version: 1.8
- name: set up flatc
run: |
- cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF .
- make
+ cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_STRICT_MODE=ON .
+ make -j
echo "${PWD}" >> $GITHUB_PATH
- name: build
working-directory: android
- run: bash ./gradlew clean build
+ run: gradle clean build
build-generator:
name: Check Generated Code
@@ -162,11 +328,11 @@
steps:
- uses: actions/checkout@v2
- name: cmake
- run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release . && make -j4
+ run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON . && make -j
- name: Generate
run: scripts/check_generate_code.py
- name: Generate gRPC
- run: bash scripts/check-grpc-generated-code.sh
+ run: scripts/check-grpc-generated-code.py
build-benchmarks:
name: Build Benchmarks (on Linux)
@@ -177,7 +343,7 @@
steps:
- uses: actions/checkout@v2
- name: cmake
- run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DFLATBUFFERS_CXX_FLAGS="-Wno-unused-parameter -fno-aligned-new" -DFLATBUFFERS_BUILD_BENCHMARKS=ON -DCMAKE_BUILD_TYPE=Release . && make -j4
+ run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DFLATBUFFERS_CXX_FLAGS="-Wno-unused-parameter -fno-aligned-new" -DFLATBUFFERS_BUILD_BENCHMARKS=ON -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON . && make -j
- name: Run benchmarks
run: ./flatbenchmark --benchmark_repetitions=5 --benchmark_display_aggregates_only=true --benchmark_out_format=console --benchmark_out=benchmarks/results_${{matrix.cxx}}
- name: Upload benchmarks results
@@ -192,8 +358,8 @@
steps:
- uses: actions/checkout@v2
- name: test
- working-directory: tests
- run: bash JavaTest.sh
+ working-directory: java
+ run: mvn test
build-kotlin-macos:
name: Build Kotlin MacOS
@@ -201,13 +367,14 @@
steps:
- name: Checkout
uses: actions/checkout@v2
+ - uses: gradle/wrapper-validation-action@v1
- uses: actions/setup-java@v2
with:
distribution: 'adopt-hotspot'
java-version: '11'
- name: Build
working-directory: kotlin
- run: ./gradlew clean iosX64Test macosX64Test jsTest jsBrowserTest
+ run: ./gradlew clean iosX64Test macosX64Test
build-kotlin-linux:
name: Build Kotlin Linux
@@ -218,23 +385,14 @@
- uses: actions/setup-java@v2
with:
distribution: 'adopt-hotspot'
- java-version: '8'
+ java-version: '11'
+ - uses: gradle/wrapper-validation-action@v1
- name: Build
working-directory: kotlin
- run: ./gradlew jvmMainClasses jvmTest
- - name: Run Benchmark
- working-directory: kotlin
- run: ./gradlew jvmBenchmark
- - name: Generate Benchmark Report
- working-directory: kotlin
- run: |
- ./gradlew jmhReport;
- mv benchmark/build/reports/benchmarks/main/* benchmark_latest
- - name: Archive benchmark report
- uses: actions/upload-artifact@v1
- with:
- name: Kotlin Benchmark Report
- path: kotlin/benchmark_latest
+ # we are using docker's version of gradle
+ # so no need for wrapper validadation or user
+ # gradlew
+ run: gradle jvmMainClasses jvmTest jsTest jsBrowserTest
build-rust:
name: Build Rust
@@ -261,7 +419,7 @@
- uses: actions/checkout@v2
- name: flatc
# FIXME: make test script not rely on flatc
- run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF . && make -j4
+ run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_STRICT_MODE=ON . && make -j
- name: test
working-directory: tests
run: bash GoTest.sh
@@ -272,19 +430,37 @@
steps:
- uses: actions/checkout@v2
- name: test
- working-directory: tests/FlatBuffers.Test.Swift
+ working-directory: tests/swift/tests
run: sh SwiftTest.sh
+ build-swift-wasm:
+ name: Build Swift Wasm
+ runs-on: ubuntu-latest
+ container:
+ image: ghcr.io/swiftwasm/carton:0.15.3
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup Wasmer
+ uses: wasmerio/setup-wasmer@v1
+ - name: Test
+ working-directory: tests/swift/Wasm.tests
+ run: carton test
+
build-ts:
name: Build TS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
+ - name: flatc
+ # FIXME: make test script not rely on flatc
+ run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF . && make -j
+ - name: deps
+ run: yarn
- name: compile
- run: npm run compile
+ run: yarn compile
- name: test
- working-directory: tests
- run: sh TypeScriptTest.sh
+ working-directory: tests/ts
+ run: python3 TypeScriptTest.py
build-dart:
name: Build Dart
@@ -296,7 +472,43 @@
sdk: stable
- name: flatc
# FIXME: make test script not rely on flatc
- run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF . && make -j4
+ run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_STRICT_MODE=ON . && make -j
- name: test
working-directory: tests
run: bash DartTest.sh
+
+ release-digests:
+ if: startsWith(github.ref, 'refs/tags/')
+ needs: [build-linux, build-windows, build-mac-intel, build-mac-universal]
+ outputs:
+ digests: ${{ steps.hash.outputs.digests }}
+ runs-on: ubuntu-latest
+ steps:
+ - name: Merge results
+ id: hash
+ env:
+ LINUXGCC_DIGESTS: "${{ needs.build-linux.outputs.digests-gcc }}"
+ LINUXCLANG_DIGESTS: "${{ needs.build-linux.outputs.digests-clang }}"
+ MAC_DIGESTS: "${{ needs.build-mac-universal.outputs.digests }}"
+ MACINTEL_DIGESTS: "${{ needs.build-mac-intel.outputs.digests }}"
+ WINDOWS_DIGESTS: "${{ needs.build-windows.outputs.digests }}"
+ run: |
+ set -euo pipefail
+ echo "$LINUXGCC_DIGESTS" | base64 -d > checksums.txt
+ echo "$LINUXCLANG_DIGESTS" | base64 -d >> checksums.txt
+ echo "$MAC_DIGESTS" | base64 -d >> checksums.txt
+ echo "$MACINTEL_DIGESTS" | base64 -d >> checksums.txt
+ echo "$WINDOWS_DIGESTS" | base64 -d >> checksums.txt
+ echo "::set-output name=digests::$(cat checksums.txt | base64 -w0)"
+
+ provenance:
+ if: startsWith(github.ref, 'refs/tags/')
+ needs: [release-digests]
+ permissions:
+ actions: read # To read the workflow path.
+ id-token: write # To sign the provenance.
+ contents: write # To add assets to a release.
+ uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.2.0
+ with:
+ base64-subjects: "${{ needs.release-digests.outputs.digests }}"
+ upload-assets: true # Optional: Upload to a new release
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
new file mode 100644
index 0000000..8dcbab8
--- /dev/null
+++ b/.github/workflows/codeql.yml
@@ -0,0 +1,71 @@
+# For most projects, this workflow file will not need changing; you simply need
+# to commit it to your repository.
+#
+# You may wish to alter this file to override the set of languages analyzed,
+# or to provide custom queries or build logic.
+#
+# ******** NOTE ********
+# We have attempted to detect the languages in your repository. Please check
+# the `language` matrix defined below to confirm you have the correct set of
+# supported CodeQL languages.
+#
+name: "CodeQL"
+permissions: read-all
+
+on:
+ push:
+ branches: [ master ]
+ pull_request:
+ # The branches below must be a subset of the branches above
+ branches: [ master ]
+ schedule:
+ - cron: '16 20 * * 0'
+
+jobs:
+ analyze:
+ name: Analyze
+ runs-on: ubuntu-latest
+ permissions:
+ actions: read
+ contents: read
+ security-events: write
+
+ strategy:
+ fail-fast: false
+ matrix:
+ language: [ 'cpp' ]
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
+ # Learn more about CodeQL language support at https://git.io/codeql-language-support
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v3
+
+ # Initializes the CodeQL tools for scanning.
+ - name: Initialize CodeQL
+ uses: github/codeql-action/init@v2
+ with:
+ languages: ${{ matrix.language }}
+ # If you wish to specify custom queries, you can do so here or in a config file.
+ # By default, queries listed here will override any specified in a config file.
+ # Prefix the list here with "+" to use these queries and those in the config file.
+ # queries: ./path/to/local/query, your-org/your-repo/queries@main
+
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
+ # If this step fails, then you should remove it and run the build manually (see below)
+ # - name: Autobuild
+ # uses: github/codeql-action/autobuild@v2
+
+ # âšī¸ Command-line programs to run using the OS shell.
+ # đ https://git.io/JvXDl
+
+ # âī¸ If the Autobuild fails above, remove it and uncomment the following three lines
+ # and modify them (or add more) to build your code if your project
+ # uses a compiled language
+
+ - run: |
+ cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON .
+ make -j
+
+ - name: Perform CodeQL Analysis
+ uses: github/codeql-action/analyze@v2
diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml
index 53dd472..42a9615 100644
--- a/.github/workflows/label.yml
+++ b/.github/workflows/label.yml
@@ -6,11 +6,16 @@
# https://github.com/actions/labeler
name: Labeler
+permissions: read-all
+
on: [pull_request_target]
jobs:
label:
-
+ permissions:
+ contents: read
+ pull-requests: write
+
runs-on: ubuntu-latest
steps:
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 4ec5ad4..7394617 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -1,4 +1,6 @@
-name: CIFuzz
+name: OSS-Fuzz
+permissions: read-all
+
on:
pull_request:
branches:
@@ -23,7 +25,7 @@
with:
oss-fuzz-project-name: 'flatbuffers'
language: c++
- fuzz-seconds: 600
+ fuzz-seconds: 60
- name: Upload Crash
uses: actions/upload-artifact@v1
if: failure() && steps.build.outcome == 'success'
diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml
new file mode 100644
index 0000000..8b2be94
--- /dev/null
+++ b/.github/workflows/scorecards.yml
@@ -0,0 +1,55 @@
+name: Scorecards supply-chain security
+on:
+ # Only the default branch is supported.
+ branch_protection_rule:
+ schedule:
+ - cron: '21 2 * * 5'
+ push:
+ branches: [ master ]
+
+# Declare default permissions as read only.
+permissions: read-all
+
+jobs:
+ analysis:
+ name: Scorecards analysis
+ runs-on: ubuntu-latest
+ permissions:
+ # Needed to upload the results to code-scanning dashboard.
+ security-events: write
+ actions: read
+ contents: read
+
+ steps:
+ - name: "Checkout code"
+ uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # v3.0.0
+ with:
+ persist-credentials: false
+
+ - name: "Run analysis"
+ uses: ossf/scorecard-action@ce330fde6b1a5c9c75b417e7efc510b822a35564 # v1.1.2
+ with:
+ results_file: results.sarif
+ results_format: sarif
+ # Read-only PAT token. To create it,
+ # follow the steps in https://github.com/ossf/scorecard-action#pat-token-creation.
+ repo_token: ${{ secrets.SCORECARD_READ_TOKEN }}
+ # Publish the results to enable scorecard badges. For more details, see
+ # https://github.com/ossf/scorecard-action#publishing-results.
+ # For private repositories, `publish_results` will automatically be set to `false`,
+ # regardless of the value entered here.
+ publish_results: true
+
+ # Upload the results as artifacts (optional).
+ - name: "Upload artifact"
+ uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # v3.0.0
+ with:
+ name: SARIF file
+ path: results.sarif
+ retention-days: 5
+
+ # Upload the results to GitHub's code scanning dashboard.
+ - name: "Upload to code-scanning"
+ uses: github/codeql-action/upload-sarif@5f532563584d71fdef14ee64d17bafb34f751ce5 # v1.0.26
+ with:
+ sarif_file: results.sarif
diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml
index b322b74..45f0119 100644
--- a/.github/workflows/stale.yml
+++ b/.github/workflows/stale.yml
@@ -1,4 +1,5 @@
name: Mark stale issues and pull requests
+permissions: read-all
on:
schedule:
diff --git a/.gitignore b/.gitignore
index c4bfbc9..08daee1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -54,6 +54,8 @@
flathash.exe
flattests
flattests.exe
+flattests_cpp17
+flattests_cpp17.exe
flatsamplebinary
flatsamplebinary.exe
flatsampletext
@@ -76,7 +78,7 @@
CMakeLists.txt.user
CMakeScripts/**
CTestTestfile.cmake
-FlatbuffersConfigVersion.cmake
+flatbuffers-config-version.cmake
FlatBuffers.cbp
build/Xcode/FlatBuffers.xcodeproj/project.xcworkspace/**
build/Xcode/FlatBuffers.xcodeproj/xcuserdata/**
@@ -86,6 +88,7 @@
.idea
*.iml
target
+java/target
**/*.pyc
build/VS2010/FlatBuffers.sdf
build/VS2010/FlatBuffers.opensdf
@@ -146,4 +149,4 @@
**/html/**
**/latex/**
# https://cmake.org/cmake/help/latest/module/FetchContent.html#variable:FETCHCONTENT_BASE_DIR
-_deps/
\ No newline at end of file
+_deps/
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 2e95109..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,215 +0,0 @@
-env:
- global:
- # Set at the root level as this is ignored when set under matrix.env.
- - GCC_VERSION="4.9"
- # Fail on first error if UBSAN or ASAN enabled for a target
- - UBSAN_OPTIONS=halt_on_error=1
- - ASAN_OPTIONS=halt_on_error=1
- # Travis machines have 2 cores
- - JOBS=2
- - MAKEFLAGS="-j 2"
-
-conan-linux: &conan-linux
- os: linux
- dist: xenial
- language: python
- python: "3.7"
- services:
- - docker
- install:
- - ./conan/travis/install.sh
- script:
- - ./conan/travis/build.sh
- if: tag IS present
-
-conan-linux-master: &conan-linux-master
- os: linux
- dist: xenial
- language: python
- python: "3.7"
- services:
- - docker
- install:
- - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash ./conan/travis/install.sh; fi'
- script:
- - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash ./conan/travis/build.sh; fi'
- branches:
- only:
- - master
-
-conan-osx: &conan-osx
- os: osx
- language: generic
- install:
- - ./conan/travis/install.sh
- script:
- - ./conan/travis/build.sh
- if: tag IS present
-
-matrix:
- include:
- #- language: python
- # python: "2.7"
- # install:
- # - "pip install wheel twine"
- # script:
- # - "cd python/"
- # - 'VERSION="$TRAVIS_TAG" python setup.py sdist bdist_wheel'
- # - "cd ../"
- # deploy:
- # # Checkpointed release builds.
- # - provider: script
- # script: .travis/deploy-python.sh
- # skip_cleanup: true
- # on:
- # tags: true
- # # all_branches must be set with tags: true. See below post:
- # # https://stackoverflow.com/a/27775257/1076585
- # all_branches: true
- # # Produce a new build for the cutting edge when master changes.
- # - provider: script
- # script: .travis/deploy-python.sh
- # skip_cleanup: true
- # on:
- # branch: master
- - language: cpp
- os:
- - linux
-
- addons:
- apt:
- packages:
- - docker-ce
- script:
- - bash .travis/build-and-run-docker-test-containers.sh
-
- - language: cpp
- os:
- - linux
-
- compiler:
- - gcc
-
- env:
- matrix:
- - BUILD_TYPE=Debug
- - BUILD_TYPE=Release
-
- before_install:
- - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test; fi
- - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get update -qq; fi
- - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -qq g++-$GCC_VERSION; fi
- - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -qq gcc-$GCC_VERSION; fi
- - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo ln -s -v -f $(which g++-$GCC_VERSION) /usr/bin/g++; fi
- - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo ln -s -v -f $(which gcc-$GCC_VERSION) /usr/bin/gcc; fi
-
- script:
- - pip install cmake
- - bash .travis/check-sources.sh
- - bash grpc/build_grpc.sh
- - cmake .
- -DCMAKE_BUILD_TYPE=$BUILD_TYPE
- -DFLATBUFFERS_BUILD_GRPCTEST=ON
- -DGRPC_INSTALL_PATH=$TRAVIS_BUILD_DIR/google/grpc/install
- -DPROTOBUF_DOWNLOAD_PATH=$TRAVIS_BUILD_DIR/google/grpc/third_party/protobuf
- -DFLATBUFFERS_CODE_SANITIZE=ON
- - cmake --build . --target all --clean-first -- -j${JOBS}
- - LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/google/grpc/install/lib ctest --extra-verbose --output-on-failure
-
- - language: cpp
- os: osx
- osx_image: xcode9.3
- env:
- matrix:
- - BUILD_TYPE=Debug
- - BUILD_TYPE=Release
-
- script:
- - pip install --user cmake
- - mkdir ~/cmake_path
- - ln -s $(find ~/Library/Python -name cmake -type f | head -n 1) ~/cmake_path/cmake
- - ln -s $(find ~/Library/Python -name ctest -type f | head -n 1) ~/cmake_path/ctest
- - export PATH=~/cmake_path:${PATH}
- - bash grpc/build_grpc.sh
- - cmake .
- -DCMAKE_BUILD_TYPE=$BUILD_TYPE
- -DFLATBUFFERS_BUILD_GRPCTEST=ON
- -DGRPC_INSTALL_PATH=$TRAVIS_BUILD_DIR/google/grpc/install
- -DPROTOBUF_DOWNLOAD_PATH=$TRAVIS_BUILD_DIR/google/grpc/third_party/protobuf
- -DFLATBUFFERS_CODE_SANITIZE=ON
- - cmake --build . -- -j${JOBS}
- - DYLD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/google/grpc/install/lib ctest --extra-verbose --output-on-failure
-
- - <<: *conan-linux-master
- env: CONAN_GCC_VERSIONS=8 CONAN_DOCKER_IMAGE=conanio/gcc8
- - <<: *conan-linux
- env: CONAN_GCC_VERSIONS=4.9 CONAN_DOCKER_IMAGE=conanio/gcc49
- - <<: *conan-linux
- env: CONAN_GCC_VERSIONS=5 CONAN_DOCKER_IMAGE=conanio/gcc5
- - <<: *conan-linux
- env: CONAN_GCC_VERSIONS=6 CONAN_DOCKER_IMAGE=conanio/gcc6
- - <<: *conan-linux
- env: CONAN_GCC_VERSIONS=7 CONAN_DOCKER_IMAGE=conanio/gcc7
- - <<: *conan-linux
- env: CONAN_GCC_VERSIONS=8 CONAN_DOCKER_IMAGE=conanio/gcc8
- - <<: *conan-linux
- env: CONAN_GCC_VERSIONS=9 CONAN_DOCKER_IMAGE=conanio/gcc9
- - <<: *conan-linux
- env: CONAN_CLANG_VERSIONS=3.9 CONAN_DOCKER_IMAGE=conanio/clang39
- - <<: *conan-linux
- env: CONAN_CLANG_VERSIONS=4.0 CONAN_DOCKER_IMAGE=conanio/clang40
- - <<: *conan-linux
- env: CONAN_CLANG_VERSIONS=5.0 CONAN_DOCKER_IMAGE=conanio/clang50
- - <<: *conan-linux
- env: CONAN_CLANG_VERSIONS=6.0 CONAN_DOCKER_IMAGE=conanio/clang60
- - <<: *conan-linux
- env: CONAN_CLANG_VERSIONS=7.0 CONAN_DOCKER_IMAGE=conanio/clang7
- - <<: *conan-linux
- env: CONAN_CLANG_VERSIONS=8 CONAN_DOCKER_IMAGE=conanio/clang8
- - <<: *conan-osx
- osx_image: xcode7.3
- env: CONAN_APPLE_CLANG_VERSIONS=7.3
- - <<: *conan-osx
- osx_image: xcode8.3
- env: CONAN_APPLE_CLANG_VERSIONS=8.1
- - <<: *conan-osx
- osx_image: xcode9
- env: CONAN_APPLE_CLANG_VERSIONS=9.0
- - <<: *conan-osx
- osx_image: xcode9.4
- env: CONAN_APPLE_CLANG_VERSIONS=9.1
- - <<: *conan-osx
- osx_image: xcode10.2
- env: CONAN_APPLE_CLANG_VERSIONS=10.0
-
- - language: android
- sudo: true
- dist: trusty
- android:
- components:
- - tools
- - platform-tools
- - extra-android-m2repository
- licenses:
- - 'android-sdk-preview-license-52d11cd2'
- - 'android-sdk-license-.+'
- - 'google-gdk-license-.+'
- compiler:
- - gcc
- before_install:
- - echo y | sdkmanager "platforms;android-30"
- - echo y | sdkmanager "build-tools;30.0.2"
- - echo y | sdkmanager "ndk-bundle"
- - echo y | sdkmanager "cmake;3.6.4111459"
- script:
- - cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF .; make; export PATH="$PATH:${PWD}"
- - cd android; ./gradlew clean build
-
- - language: generic
- if: type IN (pull_request)
- os: linux
- install:
- - bash .travis/format_install.sh
-
- script:
- - bash .travis/format_check.sh
diff --git a/.travis/build-and-run-docker-test-containers.sh b/.travis/build-and-run-docker-test-containers.sh
deleted file mode 100755
index d377ba8..0000000
--- a/.travis/build-and-run-docker-test-containers.sh
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2018 Google Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-set -e
-
-docker build -t build_cpp_image -f tests/docker/Dockerfile.testing.cpp.debian_buster .
-# Run tests with sanitizers (--cap-add SYS_PTRACE), both GCC and Clang.
-cpp_test_args="--cap-add SYS_PTRACE build_cpp_image sh ./tests/docker/cpp_test.run.sh Debug"
-docker run --rm $cpp_test_args
-docker run --rm --env CC=/usr/bin/clang --env CXX=/usr/bin/clang++ $cpp_test_args
-# Build flatc on debian once to speed up the test loop below.
-docker run --name flatc_container build_cpp_image sh ./tests/docker/build_flatc.run.sh Debug
-# All dependent dockers refer to 'flatc_debian_stretch'.
-docker cp flatc_container:/flatbuffers/flatc flatc_debian_stretch
-
-for f in $(ls tests/docker/languages | sort)
-do
- # docker pull sometimes fails for unknown reasons, probably travisci-related. this retries the pull we need a few times.
- REQUIRED_BASE_IMAGE=$(cat tests/docker/languages/${f} | head -n 1 | awk ' { print $2 } ')
-
- set +e
- n=0
- until [ $n -ge 5 ]
- do
- docker pull $REQUIRED_BASE_IMAGE && break
- n=$[$n+1]
- sleep 1
- done
- set -e
-
- docker build -t $(echo ${f} | cut -f 3- -d .) -f tests/docker/languages/${f} .
- echo "TEST OK: ${f}"
-done
diff --git a/.travis/check-sources.sh b/.travis/check-sources.sh
deleted file mode 100644
index 3e6dbf1..0000000
--- a/.travis/check-sources.sh
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2018 Google Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-set -e
-
-if [ -n "$1" ]; then
- scan_dir="$1"
-else
- scan_dir="$( pwd )"
-fi
-
-py_checker="$0.py"
-
-echo "scan root directory = '$scan_dir'"
-python3 --version
-# Scan recursively and search all *.cpp and *.h files using regex patterns.
-# Assume that script running from a root of Flatbuffers working dir.
-python3 $py_checker "ascii" "$scan_dir/include" "\.h$"
-python3 $py_checker "ascii" "$scan_dir/src" "\.cpp$"
-python3 $py_checker "ascii" "$scan_dir/tests" "\.h$"
-python3 $py_checker "utf-8" "$scan_dir/tests" "\.cpp$"
diff --git a/.travis/check-sources.sh.py b/.travis/check-sources.sh.py
deleted file mode 100644
index 2b001d7..0000000
--- a/.travis/check-sources.sh.py
+++ /dev/null
@@ -1,35 +0,0 @@
-import os
-import re
-import sys
-
-def check_encoding(encoding, scan_dir, regex_pattern):
- fname = None
- try:
- assert encoding in ['ascii', 'utf-8'], "unexpected encoding"
- cmp = re.compile(regex_pattern)
- for root, dirs, files in os.walk(scan_dir):
- fname = root
- cmp_list = [f for f in files if cmp.search(f) is not None]
- for f in cmp_list:
- fname = os.path.join(root, f)
- with open(fname, mode='rb') as test_file:
- btext = test_file.read()
- # check encoding
- btext.decode(encoding=encoding, errors="strict")
- if encoding == "utf-8" and btext.startswith(b'\xEF\xBB\xBF'):
- raise ValueError("unexpected BOM in file")
- # check LF line endings
- LF = btext.count(b'\n')
- CR = btext.count(b'\r')
- if CR!=0:
- raise ValueError("invalid line endings: LF({})/CR({})".format(LF, CR))
- except Exception as err:
- print("ERROR with [{}]: {}".format(fname, err))
- return -1
- else:
- return 0
-
-if __name__ == "__main__":
- # python check-sources.sh.py 'ascii' '.' '.*\.(cpp|h)$'
- res = check_encoding(sys.argv[1], sys.argv[2], sys.argv[3])
- sys.exit(0 if res == 0 else -1)
diff --git a/.travis/deploy-python.sh b/.travis/deploy-python.sh
deleted file mode 100755
index 4cc0346..0000000
--- a/.travis/deploy-python.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/bash
-
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-PROD_REPOSITORY="https://upload.pypi.org/legacy/"
-TEST_REPOSITORY="https://test.pypi.org/legacy/"
-
-twine upload \
- --username "$PYPI_USERNAME" \
- --password "$PYPI_PASSWORD" \
- --repository-url "$PROD_REPOSITORY" \
- "$DIR/../python/dist/"*
-
diff --git a/.travis/format_check.sh b/.travis/format_check.sh
deleted file mode 100644
index cbd1d9b..0000000
--- a/.travis/format_check.sh
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2021 Google Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-set -e
-
-# HACKY solution to make nodejs work.
-source ~/.nvm/nvm.sh
-nvm alias default node
-nvm use default
-
-sh scripts/clang-format-git.sh
-
-# Check formatting for go lang
-
-cd go
-gofmt -w .
-cd ..
-cd grpc/examples/go
-sh format.sh
-cd ../../..
-
-node_modules/.bin/eslint ts/** --ext .ts --quiet --fix
-
-#PYTHON IS DISABLED UNTIL WE CREATE A .pylintrc FILE FOR IT
-pylint python/** --disable=all
-
-swiftformat --config swift.swiftformat .
-
-
-if ! git diff --quiet; then
- echo >&2
- echo "ERROR: ********************************************************" >&2
- echo "ERROR: The following differences were found after running" >&2
- echo "ERROR: .travis/format_check.sh script. Maybe you forgot to format" >&2
- echo "ERROR: the code after making changes? please check Formatters.md" >&2
- echo "ERROR: ********************************************************" >&2
- echo >&2
- git diff --binary --exit-code
-fi
\ No newline at end of file
diff --git a/.travis/format_install.sh b/.travis/format_install.sh
deleted file mode 100644
index 74908d5..0000000
--- a/.travis/format_install.sh
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2020 Google Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-set -e
-set -x
-
-# install devtools
-install_languages() {
- sudo apt update
-
- # Install nodeJS and yarn
- wget https://raw.githubusercontent.com/creationix/nvm/v0.31.0/nvm.sh -O ~/.nvm/nvm.sh
- source ~/.nvm/nvm.sh
- nvm install node
- node --version
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH="$HOME/.yarn/bin:$PATH"
- yarn config set prefix ~/.yarn -g
- export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
-
- # Install swift
- sudo apt-get install \
- binutils \
- git \
- libc6-dev \
- libcurl3 \
- libedit2 \
- libgcc-5-dev \
- libpython2.7 \
- libsqlite3-0 \
- libstdc++-5-dev \
- libxml2 \
- pkg-config \
- tzdata \
- zlib1g-dev
-
- SWIFT_URL=https://swift.org/builds/swift-5.3.1-release/ubuntu1604/swift-5.3.1-RELEASE/swift-5.3.1-RELEASE-ubuntu16.04.tar.gz
- curl -fSsL "$SWIFT_URL" -o swift.tar.gz
-
- mkdir ~/swiftbuild
- tar -xvzf swift.tar.gz -C ~/swiftbuild
-
- export PATH="~/swiftbuild/swift-5.3.1-RELEASE-ubuntu16.04/usr/bin:$PATH"
-
-
- mkdir ~/gobuild
- wget -c https://golang.org/dl/go1.15.2.linux-amd64.tar.gz
- tar -xvzf go1.15.2.linux-amd64.tar.gz -C ~/gobuild
-
- export PATH="~/gobuild/go/bin:$PATH"
-
- swift --version
- go version
- yarn -v
- node -v
-}
-
-install_formatters() {
- # installing swift formatter
- git clone --depth 1 --branch 0.47.4 https://github.com/nicklockwood/SwiftFormat.git
- cd SwiftFormat
- swift build -c release
- sudo cp .build/release/swiftformat /usr/local/bin/swiftformat
- cd ..
-
- which yarn
- which node
- yarn -v
- node -v
-
- yarn install
- pip install pylint
-}
-
-install_languages
-export PATH="~/swift/swift/usr/bin:$PATH"
-install_formatters
\ No newline at end of file
diff --git a/BUILD.bazel b/BUILD.bazel
index 7d47143..f2aac0a 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -49,6 +49,7 @@
"include/flatbuffers/detached_buffer.h",
"include/flatbuffers/flatbuffer_builder.h",
"include/flatbuffers/flatbuffers.h",
+ "include/flatbuffers/flex_flat_util.h",
"include/flatbuffers/flexbuffers.h",
"include/flatbuffers/grpc.h",
"include/flatbuffers/hash.h",
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..b4c32d4
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,36 @@
+# Flatbuffers Change Log
+
+All major or breaking changes will be documented in this file, as well as any
+new features that should be highlighted. Minor fixes or improvements are not
+necessarily listed.
+
+## 2.0.8 (Aug 29 2022)
+
+* Fix for `--keep-prefix` the was generating the wrong include statements for
+C++ (#7469). The bug was introduced in 2.0.7.
+
+* Added the `Verifier::Options` option struct to allow specifying runtime
+configuration settings for the verifier (#7489). This allows to skip verifying
+nested flatbuffers, a on-by-default change that was introduced in 2.0.7. This
+deprecates the existing `Verifier` constructor, which may be removed in a future
+version.
+
+* Refactor of `tests/test.cpp` that lead to ~10% speedup in compilation of the
+entire project (#7487).
+
+## 2.0.7 (Aug 22 2022)
+
+* This is the first version with an explicit change log, so all the previous
+features will not be listed.
+
+* Verifier now checks that buffers are at least the minimum size required to be
+a flatbuffers (12 bytes). This includes nested flatbuffers, which previously
+could be declared valid at size 0.
+
+* Annotated binaries. Given a flatbuffer binary and a schema (or binary schema)
+one can generate an annotated flatbuffer (.afb) to describe each byte in the
+binary with schema metadata and value.
+
+* First binary schema generator (Lua) to generate Lua code via a .bfbs file.
+This is mostly an implementation detail of flatc internals, but will be slowly
+applied to the other language generators.
\ No newline at end of file
diff --git a/CMake/CMakeLists_legacy.cmake.in b/CMake/CMakeLists_legacy.cmake.in
index 0a0efd3..9e1af2b 100644
--- a/CMake/CMakeLists_legacy.cmake.in
+++ b/CMake/CMakeLists_legacy.cmake.in
@@ -8,10 +8,16 @@
if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
- project(FlatBuffers
- DESCRIPTION "Flatbuffers serialization library"
- VERSION 2.0.0
- LANGUAGES CXX)
+ if(CMAKE_VERSION VERSION_LESS 3.9)
+ project(FlatBuffers
+ VERSION 2.0.0
+ LANGUAGES CXX)
+ else()
+ project(FlatBuffers
+ DESCRIPTION "Flatbuffers serialization library"
+ VERSION 2.0.0
+ LANGUAGES CXX)
+ endif()
else()
project(FlatBuffers)
endif (POLICY CMP0048)
@@ -648,28 +654,28 @@
set(FB_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/flatbuffers")
- configure_file(CMake/FlatbuffersConfigVersion.cmake.in FlatbuffersConfigVersion.cmake @ONLY)
+ configure_file(CMake/flatbuffers-config-version.cmake.in flatbuffers-config-version.cmake @ONLY)
install(
- FILES "CMake/FlatbuffersConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/FlatbuffersConfigVersion.cmake"
+ FILES "CMake/flatbuffers-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/flatbuffers-config-version.cmake"
DESTINATION ${FB_CMAKE_DIR}
)
if(FLATBUFFERS_BUILD_FLATLIB)
if(CMAKE_VERSION VERSION_LESS 3.0)
install(
- TARGETS flatbuffers EXPORT FlatbuffersTargets
+ TARGETS flatbuffers EXPORT FlatBuffersTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
else()
install(
- TARGETS flatbuffers EXPORT FlatbuffersTargets
+ TARGETS flatbuffers EXPORT FlatBuffersTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
endif()
- install(EXPORT FlatbuffersTargets
- FILE FlatbuffersTargets.cmake
+ install(EXPORT FlatBuffersTargets
+ FILE FlatBuffersTargets.cmake
NAMESPACE flatbuffers::
DESTINATION ${FB_CMAKE_DIR}
)
@@ -692,14 +698,14 @@
if(FLATBUFFERS_BUILD_SHAREDLIB)
if(CMAKE_VERSION VERSION_LESS 3.0)
install(
- TARGETS flatbuffers_shared EXPORT FlatbuffersSharedTargets
+ TARGETS flatbuffers_shared EXPORT FlatBuffersSharedTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
else()
install(
- TARGETS flatbuffers_shared EXPORT FlatbuffersSharedTargets
+ TARGETS flatbuffers_shared EXPORT FlatBuffersSharedTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
@@ -708,8 +714,8 @@
endif()
install(
- EXPORT FlatbuffersSharedTargets
- FILE FlatbuffersSharedTargets.cmake
+ EXPORT FlatBuffersSharedTargets
+ FILE FlatBuffersSharedTargets.cmake
NAMESPACE flatbuffers::
DESTINATION ${FB_CMAKE_DIR}
)
@@ -771,4 +777,4 @@
target_include_directories(
FlatBuffers
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
- $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/include>)
\ No newline at end of file
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/include>)
diff --git a/CMake/FlatbuffersConfig.cmake b/CMake/FlatbuffersConfig.cmake
deleted file mode 100644
index 107d78e..0000000
--- a/CMake/FlatbuffersConfig.cmake
+++ /dev/null
@@ -1,4 +0,0 @@
-include("${CMAKE_CURRENT_LIST_DIR}/FlatbuffersTargets.cmake" OPTIONAL)
-include("${CMAKE_CURRENT_LIST_DIR}/FlatcTargets.cmake" OPTIONAL)
-include("${CMAKE_CURRENT_LIST_DIR}/FlatbuffersSharedTargets.cmake" OPTIONAL)
-
diff --git a/CMake/Version.cmake b/CMake/Version.cmake
index 4825d18..e6f4b4c 100644
--- a/CMake/Version.cmake
+++ b/CMake/Version.cmake
@@ -1,6 +1,6 @@
set(VERSION_MAJOR 2)
set(VERSION_MINOR 0)
-set(VERSION_PATCH 6)
+set(VERSION_PATCH 8)
set(VERSION_COMMIT 0)
find_program(GIT git)
@@ -14,10 +14,19 @@
)
if(GIT_DESCRIBE_RESULT EQUAL 0)
- string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${GIT_DESCRIBE_DIRTY}")
- string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${GIT_DESCRIBE_DIRTY}")
- string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${GIT_DESCRIBE_DIRTY}")
- string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+).*" "\\1" VERSION_COMMIT "${GIT_DESCRIBE_DIRTY}")
+ # Test if the most recent Git tag matches the pattern "v<major>.<minor>.<patch>*"
+ if(GIT_DESCRIBE_DIRTY MATCHES "^v[0-9]+\\.[0-9]+\\.[0-9]+.*")
+ string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${GIT_DESCRIBE_DIRTY}")
+ string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${GIT_DESCRIBE_DIRTY}")
+ string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${GIT_DESCRIBE_DIRTY}")
+ string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+).*" "\\1" VERSION_COMMIT "${GIT_DESCRIBE_DIRTY}")
+ # If the tag points to the commit, then only the tag is shown in "git describe"
+ if(VERSION_COMMIT STREQUAL GIT_DESCRIBE_DIRTY)
+ set(VERSION_COMMIT 0)
+ endif()
+ else()
+ message(WARNING "\"${GIT_DESCRIBE_DIRTY}\" does not match pattern v<major>.<minor>.<patch>-<commit>")
+ endif()
else()
message(WARNING "git describe failed with exit code: ${GIT_DESCRIBE_RESULT}")
endif()
diff --git a/CMake/FlatbuffersConfigVersion.cmake.in b/CMake/flatbuffers-config-version.cmake.in
similarity index 100%
rename from CMake/FlatbuffersConfigVersion.cmake.in
rename to CMake/flatbuffers-config-version.cmake.in
diff --git a/CMake/flatbuffers-config.cmake b/CMake/flatbuffers-config.cmake
new file mode 100644
index 0000000..592fc79
--- /dev/null
+++ b/CMake/flatbuffers-config.cmake
@@ -0,0 +1,3 @@
+include("${CMAKE_CURRENT_LIST_DIR}/FlatBuffersTargets.cmake" OPTIONAL)
+include("${CMAKE_CURRENT_LIST_DIR}/FlatcTargets.cmake" OPTIONAL)
+include("${CMAKE_CURRENT_LIST_DIR}/FlatBuffersSharedTargets.cmake" OPTIONAL)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9bf07fe..f5ae5ac 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -74,9 +74,26 @@
option(FLATBUFFERS_SKIP_MONSTER_EXTRA
"Skip generating monster_extra.fbs that contains non-supported numerical\"
types." OFF)
-option(FLATBUFFERS_OSX_BUILD_UNIVERSAL
- "Enable the build for multiple architectures on OS X (arm64, x86_64)."
- ON)
+option(FLATBUFFERS_STRICT_MODE
+ "Build flatbuffers with all warnings as errors (-Werror or /WX)."
+ OFF)
+
+if(NOT DEFINED FLATBUFFERS_CPP_STD)
+ set(FLATBUFFERS_CPP_STD 11)
+endif()
+
+set(MSVC_LIKE OFF)
+if(MSVC OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
+ set(MSVC_LIKE ON)
+endif()
+
+if(DEFINED FLATBUFFERS_COMPILATION_TIMINGS)
+ message("Recording Compilation Timings to ${FLATBUFFERS_COMPILATION_TIMINGS}")
+ file(REMOVE ${FLATBUFFERS_COMPILATION_TIMINGS})
+ set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "time -f 'Wall: %E User: %U Sys: %S | %C' -q -a -o ${FLATBUFFERS_COMPILATION_TIMINGS}")
+ set_property(GLOBAL PROPERTY RULE_LAUNCH_CUSTOM "time -f 'Wall: %E User: %U Sys: %S | %C' -q -a -o ${FLATBUFFERS_COMPILATION_TIMINGS}")
+ set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "time -f 'Wall: %E User: %U Sys: %S | %C' -q -a -o ${FLATBUFFERS_COMPILATION_TIMINGS}")
+endif()
if(NOT FLATBUFFERS_BUILD_FLATC AND FLATBUFFERS_BUILD_TESTS)
message(WARNING
@@ -95,7 +112,7 @@
include(CheckCXXSymbolExists)
set(FLATBUFFERS_LOCALE_INDEPENDENT 0)
- if(MSVC)
+ if(MSVC_LIKE)
check_cxx_symbol_exists(_strtof_l stdlib.h FLATBUFFERS_HAS_STRTOF_L)
check_cxx_symbol_exists(_strtoui64_l stdlib.h FLATBUFFERS_HAS_STRTOULL_L)
else()
@@ -120,6 +137,7 @@
include/flatbuffers/flatbuffer_builder.h
include/flatbuffers/flatbuffers.h
include/flatbuffers/flexbuffers.h
+ include/flatbuffers/flex_flat_util.h
include/flatbuffers/hash.h
include/flatbuffers/idl.h
include/flatbuffers/minireflect.h
@@ -158,11 +176,18 @@
src/idl_gen_grpc.cpp
src/idl_gen_json_schema.cpp
src/idl_gen_swift.cpp
+ src/idl_namer.h
+ src/namer.h
src/flatc.cpp
src/flatc_main.cpp
src/bfbs_gen.h
src/bfbs_gen_lua.h
+ src/bfbs_namer.h
include/flatbuffers/code_generators.h
+ src/binary_annotator.h
+ src/binary_annotator.cpp
+ src/annotated_binary_text_gen.h
+ src/annotated_binary_text_gen.cpp
src/bfbs_gen_lua.cpp
src/code_generators.cpp
grpc/src/compiler/schema_interface.h
@@ -188,11 +213,21 @@
set(FlatBuffers_Tests_SRCS
${FlatBuffers_Library_SRCS}
src/idl_gen_fbs.cpp
+ tests/evolution_test.cpp
+ tests/flexbuffers_test.cpp
+ tests/fuzz_test.cpp
+ tests/json_test.cpp
+ tests/monster_test.cpp
+ tests/optional_scalars_test.cpp
+ tests/parser_test.cpp
+ tests/proto_test.cpp
+ tests/reflection_test.cpp
tests/test.cpp
tests/test_assert.h
tests/test_assert.cpp
tests/test_builder.h
tests/test_builder.cpp
+ tests/util_test.cpp
tests/native_type_test_impl.h
tests/native_type_test_impl.cpp
include/flatbuffers/code_generators.h
@@ -214,6 +249,8 @@
${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_bfbs_generated.h
# file generate by running compiler on tests/optional_scalars.fbs
${CMAKE_CURRENT_BINARY_DIR}/tests/optional_scalars_generated.h
+ # file generate by running compiler on tests/native_inline_table_test.fbs
+ ${CMAKE_CURRENT_BINARY_DIR}/tests/native_inline_table_test_generated.h
)
set(FlatBuffers_Tests_CPP17_SRCS
@@ -266,75 +303,8 @@
${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_generated.h
)
-# source_group(Compiler FILES ${FlatBuffers_Compiler_SRCS})
-# source_group(Tests FILES ${FlatBuffers_Tests_SRCS})
-
-if(EXISTS "${CMAKE_TOOLCHAIN_FILE}")
- # do not apply any global settings if the toolchain
- # is being configured externally
- message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.")
-elseif(CMAKE_COMPILER_IS_GNUCXX)
- set(CMAKE_CXX_FLAGS
- "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Werror=shadow")
- set(FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wold-style-cast")
- if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.4)
- if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
- set(CMAKE_CXX_FLAGS
- "${CMAKE_CXX_FLAGS} -faligned-new -Werror=implicit-fallthrough=2")
- endif()
- set(CMAKE_CXX_FLAGS
- "${CMAKE_CXX_FLAGS} -Wunused-result -Werror=unused-result -Wunused-parameter -Werror=unused-parameter")
- endif()
-
- # Certain platforms such as ARM do not use signed chars by default
- # which causes issues with certain bounds checks.
- set(CMAKE_CXX_FLAGS
- "${CMAKE_CXX_FLAGS} -fsigned-char")
-
-# MSVC **MUST** come before the Clang check, as clang-cl is flagged by CMake as "MSVC", but it still textually
-# matches as Clang in its Compiler Id :)
-# Note: in CMake >= 3.14 we can check CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU" or "MSVC" to differentiate...
-elseif(MSVC)
- # Visual Studio pedantic build settings
- # warning C4512: assignment operator could not be generated
- # warning C4316: object allocated on the heap may not be aligned
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX /wd4512 /wd4316")
-
- if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_WARNINGS")
- endif()
-
-elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
- if(APPLE)
- if(FLATBUFFERS_OSX_BUILD_UNIVERSAL)
- set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
- endif()
- endif()
-
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Wno-unused-parameter")
- set(FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wold-style-cast")
- if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.8)
- list(APPEND FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wimplicit-fallthrough" "-Wextra-semi" "-Werror=unused-private-field") # enable warning
- endif()
- if(FLATBUFFERS_LIBCXX_WITH_CLANG)
- if(NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
- set(CMAKE_CXX_FLAGS
- "${CMAKE_CXX_FLAGS} -stdlib=libc++")
- endif()
- if(NOT ("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD" OR
- "${CMAKE_SYSTEM_NAME}" MATCHES "Linux"))
- set(CMAKE_EXE_LINKER_FLAGS
- "${CMAKE_EXE_LINKER_FLAGS} -lc++abi")
- endif()
- endif()
-
- # Certain platforms such as ARM do not use signed chars by default
- # which causes issues with certain bounds checks.
- set(CMAKE_CXX_FLAGS
- "${CMAKE_CXX_FLAGS} -fsigned-char")
-
-endif()
-
+# TODO(dbaileychess): Figure out how this would now work. I posted a question on
+# https://stackoverflow.com/questions/71772330/override-target-compile-options-via-cmake-command-line.
# Append FLATBUFFERS_CXX_FLAGS to CMAKE_CXX_FLAGS.
if(DEFINED FLATBUFFERS_CXX_FLAGS AND NOT EXISTS "${CMAKE_TOOLCHAIN_FILE}")
message(STATUS "extend CXX_FLAGS with ${FLATBUFFERS_CXX_FLAGS}")
@@ -342,12 +312,6 @@
endif()
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
-if(FLATBUFFERS_CODE_COVERAGE)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fprofile-arcs -ftest-coverage")
- set(CMAKE_EXE_LINKER_FLAGS
- "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
-endif()
-
function(add_fsanitize_to_target _target _sanitizer)
if(WIN32)
target_compile_definitions(${_target} PRIVATE FLATBUFFERS_MEMORY_LEAK_TRACKING)
@@ -386,13 +350,125 @@
include_directories(include)
include_directories(grpc)
+# Creates an interface library that stores the configuration settings that each
+# target links too. This is a compromise between setting configuration globally
+# with add_compile_options() and the more targetted target_compile_options().
+# This way each target in this file can share settings and override them if
+# needed.
+add_library(ProjectConfig INTERFACE)
+target_compile_features(ProjectConfig
+ INTERFACE
+ cxx_std_${FLATBUFFERS_CPP_STD}
+)
+
+# Force the standard to be met.
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
+# We shouldn't rely on any compiler-extensions to make things work.
+set(CMAKE_CXX_EXTENSIONS OFF)
+
+if(MSVC_LIKE)
+ target_compile_options(ProjectConfig
+ INTERFACE
+ /W4
+ $<$<BOOL:${FLATBUFFERS_STRICT_MODE}>:
+ /WX # Treat all compiler warnings as errors
+ >
+ /wd4512 # C4512: assignment operator could not be generated
+ /wd4316 # C4316: object allocated on the heap may not be aligned
+ /wd4456 # C4456: hides previous local declaration
+ $<$<CXX_COMPILER_ID:Clang>:
+ /D_CRT_SECURE_NO_WARNINGS
+ >
+ )
+else()
+ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
+ set(IS_CLANG ON)
+ else()
+ set(IS_CLANG OFF)
+ endif()
+ target_compile_options(ProjectConfig
+ INTERFACE
+ -Wall
+ $<$<BOOL:${FLATBUFFERS_STRICT_MODE}>:
+ -Werror # Treat all compiler warnings as errors
+
+ -fno-rtti # Disable runtime type information
+
+ $<$<CXX_COMPILER_ID:GNU>:
+ # False positive string overflow
+ # https://github.com/google/flatbuffers/issues/7366
+ -Wno-error=stringop-overflow
+ >
+ >
+ -pedantic
+ -Wextra
+ -Wno-unused-parameter
+ -Wold-style-cast
+ -fsigned-char
+ -Wnon-virtual-dtor
+
+ # This isn't working for some reason: $<$<CXX_COMPILER_ID:CLANG>:
+ $<$<BOOL:${IS_CLANG}>:
+ -Wno-unknown-warning-option
+ -Wmissing-declarations
+ -Wzero-as-null-pointer-constant
+ $<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,3.8>:
+ -Wimplicit-fallthrough
+ -Wextra-semi
+ $<$<BOOL:${FLATBUFFERS_STRICT_MODE}>:
+ -Werror=unused-private-field
+ >
+ >
+ >
+
+ $<$<CXX_COMPILER_ID:GNU>:
+ $<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,4.4>:
+ -Wunused-result
+ -Wunused-parameter
+ -Werror=unused-parameter
+ -Wmissing-declarations
+ >
+ $<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,4.7>:
+ -Wzero-as-null-pointer-constant
+ >
+ $<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,7.0>:
+ -faligned-new
+ $<$<BOOL:${FLATBUFFERS_STRICT_MODE}>:
+ -Werror=implicit-fallthrough=2
+ >
+ >
+ $<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,8.0>:
+ -Wextra-semi
+ >
+ >
+
+ $<$<BOOL:${FLATBUFFERS_CODE_COVERAGE}>:
+ -g
+ -fprofile-arcs
+ -ftest-coverage
+ >
+ )
+
+ if(FLATBUFFERS_CODE_COVERAGE)
+ target_link_options(ProjectConfig
+ INTERFACE
+ -fprofile-arcs
+ -ftest-coverage
+ )
+ endif()
+endif()
+
if(FLATBUFFERS_BUILD_FLATLIB)
add_library(flatbuffers STATIC ${FlatBuffers_Library_SRCS})
+
# Attach header directory for when build via add_subdirectory().
- target_include_directories(flatbuffers INTERFACE
- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
- target_compile_options(flatbuffers PRIVATE "${FLATBUFFERS_PRIVATE_CXX_FLAGS}")
- target_compile_features(flatbuffers PUBLIC cxx_std_11)
+ target_include_directories(flatbuffers
+ INTERFACE
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
+ )
+ target_link_libraries(flatbuffers PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
+
if(FLATBUFFERS_ENABLE_PCH)
add_pch_to_target(flatbuffers include/flatbuffers/pch/pch.h)
endif()
@@ -403,18 +479,21 @@
if(FLATBUFFERS_ENABLE_PCH)
add_pch_to_target(flatc include/flatbuffers/pch/flatc_pch.h)
endif()
- target_compile_options(flatc PRIVATE "${FLATBUFFERS_PRIVATE_CXX_FLAGS}")
- target_compile_features(flatc PUBLIC cxx_std_11)
+
+ target_link_libraries(flatc PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
+ target_compile_options(flatc
+ PUBLIC
+ $<$<AND:$<BOOL:${MSVC_LIKE}>,$<CONFIG:Release>>:
+ /MT
+ >
+ )
+
if(FLATBUFFERS_CODE_SANITIZE AND NOT WIN32)
add_fsanitize_to_target(flatc ${FLATBUFFERS_CODE_SANITIZE})
endif()
if(NOT FLATBUFFERS_FLATC_EXECUTABLE)
set(FLATBUFFERS_FLATC_EXECUTABLE $<TARGET_FILE:flatc>)
endif()
- if(MSVC)
- # Make flatc.exe not depend on runtime dlls for easy distribution.
- target_compile_options(flatc PUBLIC $<$<CONFIG:Release>:/MT>)
- endif()
if(FLATBUFFERS_STATIC_FLATC AND NOT MSVC)
target_link_libraries(flatc PRIVATE -static)
endif()
@@ -422,12 +501,12 @@
if(FLATBUFFERS_BUILD_FLATHASH)
add_executable(flathash ${FlatHash_SRCS})
- target_compile_features(flathash PUBLIC cxx_std_11)
+ target_link_libraries(flathash PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
endif()
if(FLATBUFFERS_BUILD_SHAREDLIB)
add_library(flatbuffers_shared SHARED ${FlatBuffers_Library_SRCS})
- target_compile_features(flatbuffers_shared PUBLIC cxx_std_11)
+ target_link_libraries(flatbuffers_shared PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
# Shared object version: "major.minor.micro"
# - micro updated every release when there is no API/ABI changes
# - minor updated when there are additions in API/ABI
@@ -543,16 +622,16 @@
compile_flatbuffers_schema_to_cpp_opt(tests/arrays_test.fbs "--scoped-enums;--gen-compare")
compile_flatbuffers_schema_to_binary(tests/arrays_test.fbs)
compile_flatbuffers_schema_to_embedded_binary(tests/monster_test.fbs "--no-includes;--gen-compare")
+ compile_flatbuffers_schema_to_cpp(tests/native_inline_table_test.fbs "--gen-compare")
if(NOT (MSVC AND (MSVC_VERSION LESS 1900)))
compile_flatbuffers_schema_to_cpp(tests/monster_extra.fbs) # Test floating-point NAN/INF.
endif()
include_directories(${CMAKE_CURRENT_BINARY_DIR}/tests)
add_executable(flattests ${FlatBuffers_Tests_SRCS})
- target_compile_features(flattests PUBLIC cxx_std_11)
+ target_link_libraries(flattests PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
+
add_dependencies(flattests generated_code)
- set_property(TARGET flattests
- PROPERTY COMPILE_DEFINITIONS FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
- FLATBUFFERS_DEBUG_VERIFICATION_FAILURE=1)
+
if(FLATBUFFERS_CODE_SANITIZE)
add_fsanitize_to_target(flattests ${FLATBUFFERS_CODE_SANITIZE})
endif()
@@ -560,27 +639,27 @@
compile_flatbuffers_schema_to_cpp(samples/monster.fbs)
compile_flatbuffers_schema_to_binary(samples/monster.fbs)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/samples)
+
add_executable(flatsamplebinary ${FlatBuffers_Sample_Binary_SRCS})
- target_compile_features(flatsamplebinary PUBLIC cxx_std_11)
+ target_link_libraries(flatsamplebinary PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
add_dependencies(flatsamplebinary generated_code)
+
add_executable(flatsampletext ${FlatBuffers_Sample_Text_SRCS})
- target_compile_features(flatsampletext PUBLIC cxx_std_11)
+ target_link_libraries(flatsampletext PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
add_dependencies(flatsampletext generated_code)
+
add_executable(flatsamplebfbs ${FlatBuffers_Sample_BFBS_SRCS})
- target_compile_features(flatsamplebfbs PUBLIC cxx_std_11)
+ target_link_libraries(flatsamplebfbs PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
add_dependencies(flatsamplebfbs generated_code)
if(FLATBUFFERS_BUILD_CPP17)
# Don't generate header for flattests_cpp17 target.
# This target uses "generated_cpp17/monster_test_generated.h"
- # produced by direct call of generate_code.py script.
add_executable(flattests_cpp17 ${FlatBuffers_Tests_CPP17_SRCS})
add_dependencies(flattests_cpp17 generated_code)
+ target_link_libraries(flattests_cpp17 PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
target_compile_features(flattests_cpp17 PRIVATE cxx_std_17)
- target_compile_definitions(flattests_cpp17 PRIVATE
- FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
- FLATBUFFERS_DEBUG_VERIFICATION_FAILURE=1
- )
+
if(FLATBUFFERS_CODE_SANITIZE)
add_fsanitize_to_target(flattests_cpp17 ${FLATBUFFERS_CODE_SANITIZE})
endif()
@@ -588,9 +667,6 @@
endif()
if(FLATBUFFERS_BUILD_GRPCTEST)
- if(CMAKE_COMPILER_IS_GNUCXX)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter -Wno-shadow")
- endif()
if(NOT GRPC_INSTALL_PATH)
message(SEND_ERROR "GRPC_INSTALL_PATH variable is not defined. See grpc/README.md")
endif()
@@ -606,15 +682,16 @@
find_package(gRPC CONFIG REQUIRED)
add_executable(grpctest ${FlatBuffers_GRPCTest_SRCS})
add_dependencies(grpctest generated_code)
- target_compile_features(grpctest PRIVATE cxx_std_11)
- target_link_libraries(grpctest PRIVATE gRPC::grpc++_unsecure gRPC::grpc_unsecure gRPC::gpr pthread dl)
- if(FLATBUFFERS_CODE_SANITIZE AND NOT WIN32)
- # GRPC test has problems with alignment and will fail under ASAN/UBSAN.
- # add_fsanitize_to_target(grpctest ${FLATBUFFERS_CODE_SANITIZE})
- endif()
+ target_link_libraries(grpctext
+ PRIVATE
+ $<BUILD_INTERFACE:ProjectConfig>
+ gRPC::grpc++_unsecure
+ gRPC::gpr
+ pthread
+ dl
+ )
endif()
-
if(FLATBUFFERS_INSTALL)
include(GNUInstallDirs)
@@ -622,21 +699,24 @@
set(FB_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/flatbuffers")
- configure_file(CMake/FlatbuffersConfigVersion.cmake.in FlatbuffersConfigVersion.cmake @ONLY)
+ configure_file(CMake/flatbuffers-config-version.cmake.in flatbuffers-config-version.cmake @ONLY)
install(
- FILES "CMake/FlatbuffersConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/FlatbuffersConfigVersion.cmake"
+ FILES
+ "CMake/flatbuffers-config.cmake"
+ "CMake/BuildFlatBuffers.cmake"
+ "${CMAKE_CURRENT_BINARY_DIR}/flatbuffers-config-version.cmake"
DESTINATION ${FB_CMAKE_DIR}
)
if(FLATBUFFERS_BUILD_FLATLIB)
install(
- TARGETS flatbuffers EXPORT FlatbuffersTargets
+ TARGETS flatbuffers EXPORT FlatBuffersTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
- install(EXPORT FlatbuffersTargets
- FILE FlatbuffersTargets.cmake
+ install(EXPORT FlatBuffersTargets
+ FILE FlatBuffersTargets.cmake
NAMESPACE flatbuffers::
DESTINATION ${FB_CMAKE_DIR}
)
@@ -658,7 +738,7 @@
if(FLATBUFFERS_BUILD_SHAREDLIB)
install(
- TARGETS flatbuffers_shared EXPORT FlatbuffersSharedTargets
+ TARGETS flatbuffers_shared EXPORT FlatBuffersSharedTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
@@ -666,8 +746,8 @@
)
install(
- EXPORT FlatbuffersSharedTargets
- FILE FlatbuffersSharedTargets.cmake
+ EXPORT FlatBuffersSharedTargets
+ FILE FlatBuffersSharedTargets.cmake
NAMESPACE flatbuffers::
DESTINATION ${FB_CMAKE_DIR}
)
@@ -729,4 +809,4 @@
target_include_directories(
FlatBuffers
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
- $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/include>)
\ No newline at end of file
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/include>)
diff --git a/WORKSPACE b/WORKSPACE
index f030e86..b707857 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -3,20 +3,47 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
- name = "io_bazel_rules_go",
- sha256 = "d1ffd055969c8f8d431e2d439813e42326961d0942bdf734d2c95dc30c369566",
+ name = "platforms",
+ sha256 = "379113459b0feaf6bfbb584a91874c065078aa673222846ac765f86661c27407",
urls = [
- "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.5/rules_go-v0.24.5.tar.gz",
- "https://github.com/bazelbuild/rules_go/releases/download/v0.24.5/rules_go-v0.24.5.tar.gz",
+ "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.5/platforms-0.0.5.tar.gz",
+ "https://github.com/bazelbuild/platforms/releases/download/0.0.5/platforms-0.0.5.tar.gz",
],
)
-load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
+http_archive(
+ name = "build_bazel_rules_swift",
+ sha256 = "a2fd565e527f83fb3f9eb07eb9737240e668c9242d3bc318712efa54a7deda97",
+ url = "https://github.com/bazelbuild/rules_swift/releases/download/0.27.0/rules_swift.0.27.0.tar.gz",
+)
+
+load(
+ "@build_bazel_rules_swift//swift:repositories.bzl",
+ "swift_rules_dependencies",
+)
+
+swift_rules_dependencies()
+
+load(
+ "@build_bazel_rules_swift//swift:extras.bzl",
+ "swift_rules_extra_dependencies",
+)
+
+swift_rules_extra_dependencies()
+
+http_archive(
+ name = "io_bazel_rules_go",
+ sha256 = "16e9fca53ed6bd4ff4ad76facc9b7b651a89db1689a2877d6fd7b82aa824e366",
+ urls = [
+ "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.34.0/rules_go-v0.34.0.zip",
+ "https://github.com/bazelbuild/rules_go/releases/download/v0.34.0/rules_go-v0.34.0.zip",
+ ],
+)
+
+load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies")
go_rules_dependencies()
-go_register_toolchains()
-
##### Protobuf
_PROTOBUF_VERSION = "3.15.2"
@@ -29,12 +56,12 @@
)
##### GRPC
-_GRPC_VERSION = "1.42.0"
+_GRPC_VERSION = "1.48.0" # https://github.com/grpc/grpc/releases/tag/v1.48.0
http_archive(
name = "com_github_grpc_grpc",
strip_prefix = "grpc-" + _GRPC_VERSION,
- urls = ["https://github.com/grpc/grpc/archive/v" + _GRPC_VERSION + ".tar.gz"],
+ urls = ["https://github.com/grpc/grpc/archive/refs/tags/v" + _GRPC_VERSION + ".tar.gz"],
)
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
@@ -45,6 +72,7 @@
grpc_extra_deps()
+# rules_go from https://github.com/bazelbuild/rules_go/releases/tag/v0.34.0
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "965ee2492a2b087cf9e0f2ca472aeaf1be2eb650e0cfbddf514b9a7d3ea4b02a",
diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml
index c755e6d..65ce643 100644
--- a/android/AndroidManifest.xml
+++ b/android/AndroidManifest.xml
@@ -6,7 +6,8 @@
<uses-feature android:glEsVersion="0x00020000"></uses-feature>
<!-- This .apk has no Java code itself, so set hasCode to false. -->
- <application android:label="@string/app_name"
+ <application android:name="android.support.multidex.MultiDexApplication"
+ android:label="@string/app_name"
android:hasCode="false"
android:allowBackup="false">
<!-- Our activity is the built-in NativeActivity framework class.
diff --git a/android/app/build.gradle b/android/app/build.gradle
index dba6624..1b035ba 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -8,7 +8,7 @@
defaultConfig {
applicationId "com.flatbuffers.app"
- minSdkVersion 16
+ minSdkVersion 26
targetSdkVersion 30
versionCode 1
versionName "1.0"
@@ -18,6 +18,18 @@
targetCompatibility JavaVersion.VERSION_1_8
}
+ sourceSets {
+ main {
+ java {
+ srcDir '../../java/src/main/java/'
+ }
+ }
+ }
+
+ ndk {
+ abiFilters 'arm64-v8a', 'armeabi-v7a'
+ }
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
@@ -33,7 +45,6 @@
}
}
- ndkVersion "21.3.6528147"
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
@@ -52,16 +63,17 @@
fbsFiles.forEach{
commandLineArgs.add(it.path)
}
+
commandLine commandLineArgs
doFirst {
delete "$outputCppDir/"
mkdir "$outputCppDir/"
}
+
doLast {
- if (execResult.getExitValue() != 0) {
- println(standardOutput.toString())
- throw new GradleException("flatc command line failed")
+ if (executionResult.get().exitValue != 0) {
+ throw new GradleException("flatc failed with: ${executionResult.get().toString()}")
}
}
}
@@ -74,6 +86,10 @@
standardOutput = new ByteArrayOutputStream()
errorOutput = new ByteArrayOutputStream()
+
+ setErrorOutput(errorOutput)
+ setStandardOutput(standardOutput)
+
def commandLineArgs = ['flatc', '-o', outputKotlinDir, '--kotlin']
fbsFiles.forEach{
commandLineArgs.add(it.path)
@@ -85,41 +101,16 @@
mkdir "$outputKotlinDir/"
}
doLast {
- if (execResult.getExitValue() != 0) {
- println(standardOutput.toString())
- throw new GradleException("flatc command line failed")
+ if (executionResult.get().exitValue != 0) {
+ throw new GradleException("flatc failed with: ${executionResult.get().toString()}")
}
}
}
afterEvaluate {
- android.applicationVariants.all { variant ->
- variant.javaCompiler.dependsOn(generateFbsKotlin)
- variant.javaCompiler.dependsOn(generateFbsCpp)
- }
- }
-
- flavorDimensions "stl-variant"
- productFlavors {
- gnustl {
- dimension "stl-variant"
- applicationIdSuffix ".gnustl"
- versionNameSuffix "-gnustl"
- externalNativeBuild {
- ndkBuild {
- arguments "APP_STL=gnustl_static"
- }
- }
- }
- libcpp {
- dimension "stl-variant"
- applicationIdSuffix ".libcpp"
- versionNameSuffix "-libcpp"
- externalNativeBuild {
- ndkBuild {
- arguments "APP_STL=c++_static"
- }
- }
+ tasks.named("preBuild") {
+ dependsOn(generateFbsKotlin)
+ dependsOn(generateFbsCpp)
}
}
}
@@ -129,6 +120,8 @@
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
- implementation 'com.google.flatbuffers:flatbuffers-java:2.0.0'
+
+ // If you using java runtime you can add its dependency as the example below
+ // implementation 'com.google.flatbuffers:flatbuffers-java:$latest_version'
}
diff --git a/android/app/src/main/cpp/flatbuffers/CMakeLists.txt b/android/app/src/main/cpp/flatbuffers/CMakeLists.txt
index 0e5f3e9..e1dd1e8 100644
--- a/android/app/src/main/cpp/flatbuffers/CMakeLists.txt
+++ b/android/app/src/main/cpp/flatbuffers/CMakeLists.txt
@@ -26,6 +26,7 @@
${FLATBUFFERS_SRC}/include/flatbuffers/flatbuffer_builder.h
${FLATBUFFERS_SRC}/include/flatbuffers/flatbuffers.h
${FLATBUFFERS_SRC}/include/flatbuffers/flexbuffers.h
+ ${FLATBUFFERS_SRC}/include/flatbuffers/flex_flat_util.h
${FLATBUFFERS_SRC}/include/flatbuffers/hash.h
${FLATBUFFERS_SRC}/include/flatbuffers/idl.h
${FLATBUFFERS_SRC}/include/flatbuffers/minireflect.h
diff --git a/android/app/src/main/cpp/generated/animal_generated.h b/android/app/src/main/cpp/generated/animal_generated.h
index 1ba9b09..5253f67 100644
--- a/android/app/src/main/cpp/generated/animal_generated.h
+++ b/android/app/src/main/cpp/generated/animal_generated.h
@@ -6,6 +6,13 @@
#include "flatbuffers/flatbuffers.h"
+// Ensure the included flatbuffers.h is the same version as when this file was
+// generated, otherwise it may not be compatible.
+static_assert(FLATBUFFERS_VERSION_MAJOR == 2 &&
+ FLATBUFFERS_VERSION_MINOR == 0 &&
+ FLATBUFFERS_VERSION_REVISION == 8,
+ "Non-compatible flatbuffers version included");
+
namespace com {
namespace fbs {
namespace app {
@@ -35,7 +42,7 @@
verifier.VerifyString(name()) &&
VerifyOffset(verifier, VT_SOUND) &&
verifier.VerifyString(sound()) &&
- VerifyField<uint16_t>(verifier, VT_WEIGHT) &&
+ VerifyField<uint16_t>(verifier, VT_WEIGHT, 2) &&
verifier.EndTable();
}
};
@@ -57,7 +64,6 @@
: fbb_(_fbb) {
start_ = fbb_.StartTable();
}
- AnimalBuilder &operator=(const AnimalBuilder &);
flatbuffers::Offset<Animal> Finish() {
const auto end = fbb_.EndTable(start_);
auto o = flatbuffers::Offset<Animal>(end);
diff --git a/android/app/src/main/java/generated/com/fbs/app/Animal.kt b/android/app/src/main/java/generated/com/fbs/app/Animal.kt
index 89da646..f647fef 100644
--- a/android/app/src/main/java/generated/com/fbs/app/Animal.kt
+++ b/android/app/src/main/java/generated/com/fbs/app/Animal.kt
@@ -7,7 +7,6 @@
import com.google.flatbuffers.*
@Suppress("unused")
-@ExperimentalUnsignedTypes
class Animal : Table() {
fun __init(_i: Int, _bb: ByteBuffer) {
@@ -37,7 +36,7 @@
return if(o != 0) bb.getShort(o + bb_pos).toUShort() else 0u
}
companion object {
- fun validateVersion() = Constants.FLATBUFFERS_2_0_0()
+ fun validateVersion() = Constants.FLATBUFFERS_2_0_8()
fun getRootAsAnimal(_bb: ByteBuffer): Animal = getRootAsAnimal(_bb, Animal())
fun getRootAsAnimal(_bb: ByteBuffer, obj: Animal): Animal {
_bb.order(ByteOrder.LITTLE_ENDIAN)
diff --git a/android/gradle.properties b/android/gradle.properties
index 9bb1cb2..bf3068d 100644
--- a/android/gradle.properties
+++ b/android/gradle.properties
@@ -19,3 +19,5 @@
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
+# Use parallel builds
+org.gradle.parallel=true
\ No newline at end of file
diff --git a/android/gradle/wrapper/gradle-wrapper.jar b/android/gradle/wrapper/gradle-wrapper.jar
index b4163b8..41d9927 100644
--- a/android/gradle/wrapper/gradle-wrapper.jar
+++ b/android/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties
index 416f23c..aa991fc 100644
--- a/android/gradle/wrapper/gradle-wrapper.properties
+++ b/android/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Thu Oct 29 19:47:23 CET 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt
index 8d49c35..272a2b7 100644
--- a/benchmarks/CMakeLists.txt
+++ b/benchmarks/CMakeLists.txt
@@ -16,7 +16,7 @@
FetchContent_Declare(
googlebenchmark
GIT_REPOSITORY https://github.com/google/benchmark.git
- GIT_TAG f91b6b42b1b9854772a90ae9501464a161707d1e # v1.6.0
+ GIT_TAG 0d98dba29d66e93259db7daa53a9327df767a415 # v1.6.1
)
# For Windows: Prevent overriding the parent project's compiler/linker
@@ -66,6 +66,12 @@
cxx_std_11
)
+target_compile_options(flatbenchmark
+ PRIVATE
+ -fno-aligned-new
+ -Wno-deprecated-declarations
+)
+
# Set the output directory to the root binary directory
set_target_properties(flatbenchmark
PROPERTIES RUNTIME_OUTPUT_DIRECTORY
diff --git a/benchmarks/cpp/flatbuffers/bench_generated.h b/benchmarks/cpp/flatbuffers/bench_generated.h
index 9d207c5..8293759 100644
--- a/benchmarks/cpp/flatbuffers/bench_generated.h
+++ b/benchmarks/cpp/flatbuffers/bench_generated.h
@@ -6,6 +6,13 @@
#include "flatbuffers/flatbuffers.h"
+// Ensure the included flatbuffers.h is the same version as when this file was
+// generated, otherwise it may not be compatible.
+static_assert(FLATBUFFERS_VERSION_MAJOR == 2 &&
+ FLATBUFFERS_VERSION_MINOR == 0 &&
+ FLATBUFFERS_VERSION_REVISION == 6,
+ "Non-compatible flatbuffers version included");
+
namespace benchmarks_flatbuffers {
struct Foo;
@@ -157,11 +164,11 @@
}
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
- VerifyField<benchmarks_flatbuffers::Bar>(verifier, VT_SIBLING) &&
+ VerifyField<benchmarks_flatbuffers::Bar>(verifier, VT_SIBLING, 8) &&
VerifyOffset(verifier, VT_NAME) &&
verifier.VerifyString(name()) &&
- VerifyField<double>(verifier, VT_RATING) &&
- VerifyField<uint8_t>(verifier, VT_POSTFIX) &&
+ VerifyField<double>(verifier, VT_RATING, 8) &&
+ VerifyField<uint8_t>(verifier, VT_POSTFIX, 1) &&
verifier.EndTable();
}
};
@@ -247,8 +254,8 @@
VerifyOffset(verifier, VT_LIST) &&
verifier.VerifyVector(list()) &&
verifier.VerifyVectorOfTables(list()) &&
- VerifyField<uint8_t>(verifier, VT_INITIALIZED) &&
- VerifyField<int16_t>(verifier, VT_FRUIT) &&
+ VerifyField<uint8_t>(verifier, VT_INITIALIZED, 1) &&
+ VerifyField<int16_t>(verifier, VT_FRUIT, 2) &&
VerifyOffset(verifier, VT_LOCATION) &&
verifier.VerifyString(location()) &&
verifier.EndTable();
diff --git a/benchmarks/cpp/flatbuffers/fb_bench.cpp b/benchmarks/cpp/flatbuffers/fb_bench.cpp
index 2bbb9a5..9351667 100644
--- a/benchmarks/cpp/flatbuffers/fb_bench.cpp
+++ b/benchmarks/cpp/flatbuffers/fb_bench.cpp
@@ -16,7 +16,7 @@
explicit FlatBufferBench(int64_t initial_size, Allocator *allocator)
: fbb(initial_size, allocator, false) {}
- uint8_t *Encode(void *, int64_t &len) {
+ uint8_t *Encode(void *, int64_t &len) override {
fbb.Clear();
const int kVectorLength = 3;
@@ -40,7 +40,7 @@
return fbb.GetBufferPointer();
}
- int64_t Use(void *decoded) {
+ int64_t Use(void *decoded) override {
sum = 0;
auto foobarcontainer = GetFooBarContainer(decoded);
sum = 0;
@@ -65,8 +65,8 @@
return sum;
}
- void *Decode(void *buffer, int64_t) { return buffer; }
- void Dealloc(void *) override{};
+ void *Decode(void *buffer, int64_t) override { return buffer; }
+ void Dealloc(void *) override {};
FlatBufferBuilder fbb;
};
diff --git a/benchmarks/cpp/raw/raw_bench.cpp b/benchmarks/cpp/raw/raw_bench.cpp
index 810cb1f..c65bca7 100644
--- a/benchmarks/cpp/raw/raw_bench.cpp
+++ b/benchmarks/cpp/raw/raw_bench.cpp
@@ -45,7 +45,7 @@
};
struct RawBench : Bench {
- uint8_t *Encode(void *buf, int64_t &len) {
+ uint8_t *Encode(void *buf, int64_t &len) override {
FooBarContainer *fbc = new (buf) FooBarContainer;
strcpy(fbc->location, "http://google.com/flatbuffers/"); // Unsafe eek!
fbc->location_len = (int)strlen(fbc->location);
@@ -74,7 +74,7 @@
return reinterpret_cast<uint8_t *>(fbc);
};
- int64_t Use(void *decoded) {
+ int64_t Use(void *decoded) override {
auto foobarcontainer = reinterpret_cast<FooBarContainer *>(decoded);
sum = 0;
Add(foobarcontainer->initialized);
@@ -98,7 +98,7 @@
return sum;
}
- void *Decode(void *buf, int64_t) { return buf; }
+ void *Decode(void *buf, int64_t) override { return buf; }
void Dealloc(void *) override{};
};
diff --git a/build_defs.bzl b/build_defs.bzl
index d27da1f..22949b9 100644
--- a/build_defs.bzl
+++ b/build_defs.bzl
@@ -5,8 +5,6 @@
Rules for building C++ flatbuffers with Bazel.
"""
-load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
-load("@npm//@bazel/typescript:index.bzl", "ts_project")
load("@rules_cc//cc:defs.bzl", "cc_library")
flatc_path = "@com_github_google_flatbuffers//:flatc"
@@ -27,15 +25,6 @@
"--cpp-ptr-type flatbuffers::unique_ptr",
]
-DEFAULT_FLATC_TS_ARGS = [
- "--gen-object-api",
- "--gen-mutable",
- "--reflect-names",
- "--gen-name-strings",
- "--ts-flat-files",
- "--keep-prefix",
-]
-
def flatbuffer_library_public(
name,
srcs,
@@ -264,91 +253,3 @@
restricted_to = restricted_to,
visibility = srcs_filegroup_visibility if srcs_filegroup_visibility != None else visibility,
)
-
-def flatbuffer_ts_library(
- name,
- srcs,
- compatible_with = None,
- target_compatible_with = None,
- deps = [],
- include_paths = DEFAULT_INCLUDE_PATHS,
- flatc_args = DEFAULT_FLATC_TS_ARGS,
- visibility = None,
- restricted_to = None,
- include_reflection = True):
- """Generates a ts_library rule for a given flatbuffer definition.
-
- Args:
- name: Name of the generated ts_library rule.
- srcs: Source .fbs file(s).
- deps: Other flatbuffer_ts_library's to depend on. Note that currently
- you must specify all your transitive dependencies manually.
- include_paths: Optional, list of paths the includes files can be found in.
- flatc_args: Optional list of additional arguments to pass to flatc
- (e.g. --gen-mutable).
- visibility: The visibility of the generated cc_library. By default, use the
- default visibility of the project.
- compatible_with: Optional, The list of environments this rule can be built
- for, in addition to default-supported environments.
- restricted_to: Optional, The list of environments this rule can be built
- for, instead of default-supported environments.
- target_compatible_with: Optional, The list of target platform constraints
- to use.
- include_reflection: Optional, Whether to depend on the flatbuffer
- reflection library automatically. Only really relevant for the
- target that builds the reflection library itself.
- """
- srcs_lib = "%s_srcs" % (name)
- outs = ["%s_generated.ts" % (s.replace(".fbs", "").split("/")[-1]) for s in srcs]
- includes = [d + "_includes" for d in deps]
- flatbuffer_library_public(
- name = srcs_lib,
- srcs = srcs,
- outs = outs,
- language_flag = "--ts",
- includes = includes,
- include_paths = include_paths,
- flatc_args = flatc_args,
- compatible_with = compatible_with,
- restricted_to = restricted_to,
- target_compatible_with = target_compatible_with,
- )
- ts_project(
- name = name + "_ts",
- srcs = outs,
- declaration = True,
- visibility = visibility,
- compatible_with = compatible_with,
- restricted_to = restricted_to,
- target_compatible_with = target_compatible_with,
- tsconfig = {
- "compilerOptions": {
- "declaration": True,
- "lib": [
- "ES2015",
- "ES2020.BigInt",
- "DOM",
- ],
- "module": "commonjs",
- "moduleResolution": "node",
- "strict": True,
- "types": ["node"],
- },
- },
- deps = deps + ["//ts:flatbuffers"] + (["//reflection:reflection_ts_fbs"] if include_reflection else []),
- )
- js_library(
- name = name,
- visibility = visibility,
- compatible_with = compatible_with,
- restricted_to = restricted_to,
- target_compatible_with = target_compatible_with,
- deps = [name + "_ts"],
- )
- native.filegroup(
- name = "%s_includes" % (name),
- srcs = srcs + includes,
- compatible_with = compatible_with,
- restricted_to = restricted_to,
- visibility = visibility,
- )
diff --git a/conan/CMakeLists.txt b/conan/CMakeLists.txt
index d32a013..65f9028 100644
--- a/conan/CMakeLists.txt
+++ b/conan/CMakeLists.txt
@@ -5,8 +5,8 @@
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
-if (WIN32 AND MSVC AND FLATBUFFERS_BUILD_SHAREDLIB)
+if (WIN32 AND MSVC_LIKE AND FLATBUFFERS_BUILD_SHAREDLIB)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
-endif(WIN32 AND MSVC AND FLATBUFFERS_BUILD_SHAREDLIB)
+endif(WIN32 AND MSVC_LIKE AND FLATBUFFERS_BUILD_SHAREDLIB)
include(${CMAKE_SOURCE_DIR}/CMakeListsOriginal.txt)
diff --git a/conan/appveyor/build.py b/conan/appveyor/build.py
deleted file mode 100644
index 9bac46d..0000000
--- a/conan/appveyor/build.py
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-import os
-
-if os.getenv("APPVEYOR_REPO_TAG") != "true":
- print("Skip build step. It's not TAG")
-else:
- os.system("python conan/build.py")
diff --git a/conan/appveyor/install.py b/conan/appveyor/install.py
deleted file mode 100644
index 962c7da..0000000
--- a/conan/appveyor/install.py
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-import os
-
-if os.getenv("APPVEYOR_REPO_TAG") != "true":
- print("Skip step. It's not TAG")
-else:
- os.system("pip install conan conan-package-tools")
diff --git a/conan/build.py b/conan/build.py
index 9a85718..62a3799 100644
--- a/conan/build.py
+++ b/conan/build.py
@@ -21,14 +21,6 @@
def get_version():
version = get_branch()
- if os.getenv("TRAVIS", False):
- version = os.getenv("TRAVIS_BRANCH")
-
- if os.getenv("APPVEYOR", False):
- version = os.getenv("APPVEYOR_REPO_BRANCH")
- if os.getenv("APPVEYOR_REPO_TAG") == "true":
- version = os.getenv("APPVEYOR_REPO_TAG_NAME")
-
match = re.search(r"v(\d+\.\d+\.\d+.*)", version)
if match:
return match.group(1)
diff --git a/conan/travis/build.sh b/conan/travis/build.sh
deleted file mode 100755
index 069ced2..0000000
--- a/conan/travis/build.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-set -e
-set -x
-
-if [[ "$(uname -s)" == 'Darwin' ]]; then
- if which pyenv > /dev/null; then
- eval "$(pyenv init -)"
- fi
- pyenv activate conan
-fi
-
-conan user
-python conan/build.py
diff --git a/conan/travis/install.sh b/conan/travis/install.sh
deleted file mode 100755
index f4208d8..0000000
--- a/conan/travis/install.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/bash
-
-set -e
-set -x
-
-if [[ "$(uname -s)" == 'Darwin' ]]; then
- brew update || brew update
- brew outdated pyenv || brew upgrade pyenv
- brew install pyenv-virtualenv
- brew install cmake || true
-
- if which pyenv > /dev/null; then
- eval "$(pyenv init -)"
- fi
-
- pyenv install 2.7.10
- pyenv virtualenv 2.7.10 conan
- pyenv rehash
- pyenv activate conan
-fi
-
-pip install -U conan_package_tools conan
diff --git a/dart/lib/flat_buffers.dart b/dart/lib/flat_buffers.dart
index d27d4bf..8ce1ab9 100644
--- a/dart/lib/flat_buffers.dart
+++ b/dart/lib/flat_buffers.dart
@@ -1,7 +1,3 @@
-// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
import 'dart:collection';
import 'dart:convert';
import 'dart:math';
@@ -401,6 +397,15 @@
_setFloat32AtTail(_tail, value);
}
+ /// Writes a bool to the tail of the buffer after preparing space for it.
+ /// Bools are represented as a Uint8, with the value set to '1' for true, and '0' for false
+ ///
+ /// Updates the [offset] pointer. This method is intended for use when writing structs to the buffer.
+ void putBool(bool value) {
+ _prepare(_sizeofUint8, 1);
+ _buf.setInt8(_buf.lengthInBytes - _tail, value ? 1 : 0);
+ }
+
/// Writes a Int64 to the tail of the buffer after preparing space for it.
///
/// Updates the [offset] pointer. This method is intended for use when writing structs to the buffer.
diff --git a/dart/lib/src/builder.dart b/dart/lib/src/builder.dart
index a0d47ed..82681e7 100644
--- a/dart/lib/src/builder.dart
+++ b/dart/lib/src/builder.dart
@@ -17,7 +17,7 @@
final Map<double, _StackValue> _indirectDoubleCache = {};
/// Instantiate the builder if you intent to gradually build up the buffer by calling
- /// add... methods and calling [finish] to receive the the resulting byte array.
+ /// add... methods and calling [finish] to receive the resulting byte array.
///
/// The default size of internal buffer is set to 2048. Provide a different value in order to avoid buffer copies.
Builder({int size = 2048}) : _buffer = ByteData(size);
diff --git a/dart/lib/src/reference.dart b/dart/lib/src/reference.dart
index e52d0b7..66195c1 100644
--- a/dart/lib/src/reference.dart
+++ b/dart/lib/src/reference.dart
@@ -199,7 +199,7 @@
return _MapValueIterator(this);
}
- /// Returns the length of the the underlying FlexBuffer value.
+ /// Returns the length of the underlying FlexBuffer value.
/// If the underlying value is [null] the length is 0.
/// If the underlying value is a number, or a bool, the length is 1.
/// If the underlying value is a vector, or map, the length reflects number of elements / element pairs.
diff --git a/dart/pubspec.yaml b/dart/pubspec.yaml
index ae86570..a19bf6f 100644
--- a/dart/pubspec.yaml
+++ b/dart/pubspec.yaml
@@ -1,5 +1,5 @@
name: flat_buffers
-version: 2.0.5
+version: 2.0.8
description: FlatBuffers reading and writing library for Dart. Based on original work by Konstantin Scheglov and Paul Berry of the Dart SDK team.
homepage: https://github.com/google/flatbuffers
documentation: https://google.github.io/flatbuffers/index.html
diff --git a/dart/test/bool_structs.fbs b/dart/test/bool_structs.fbs
new file mode 100644
index 0000000..47b26b5
--- /dev/null
+++ b/dart/test/bool_structs.fbs
@@ -0,0 +1,10 @@
+// Test for #7355
+table Foo {
+ my_foo : foo_properties;
+}
+
+struct foo_properties
+{
+ a : bool;
+ b : bool;
+}
diff --git a/dart/test/flat_buffers_test.dart b/dart/test/flat_buffers_test.dart
index 8cee6b2..5298b17 100644
--- a/dart/test/flat_buffers_test.dart
+++ b/dart/test/flat_buffers_test.dart
@@ -1,7 +1,3 @@
-// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
import 'dart:typed_data';
import 'dart:io' as io;
@@ -13,6 +9,9 @@
import './monster_test_my_game.example_generated.dart' as example;
import './monster_test_my_game.example2_generated.dart' as example2;
+import './list_of_enums_generated.dart' as example3;
+import './bool_structs_generated.dart' as example4;
+import './keyword_test_keyword_test_generated.dart' as keyword_test;
main() {
defineReflectiveSuite(() {
@@ -20,6 +19,7 @@
defineReflectiveTests(ObjectAPITest);
defineReflectiveTests(CheckOtherLangaugesData);
defineReflectiveTests(GeneratorTest);
+ defineReflectiveTests(ListOfEnumsTest);
});
}
@@ -902,3 +902,32 @@
same(example.AnyAmbiguousAliasesTypeId.values));
}
}
+
+// See #6869
+@reflectiveTest
+class ListOfEnumsTest {
+ void test_listOfEnums() async {
+ var mytable = example3.MyTableObjectBuilder(options: [
+ example3.OptionsEnum.A,
+ example3.OptionsEnum.B,
+ example3.OptionsEnum.C
+ ]);
+ var bytes = mytable.toBytes();
+ var mytable_read = example3.MyTable(bytes);
+ expect(mytable_read.options![0].value, example3.OptionsEnum.A.value);
+ expect(mytable_read.options![1].value, example3.OptionsEnum.B.value);
+ expect(mytable_read.options![2].value, example3.OptionsEnum.C.value);
+ }
+}
+
+@reflectiveTest
+class BoolInStructTest {
+ void test_boolInStruct() async {
+ var mystruct = example4.FooObjectBuilder(
+ myFoo: example4.FooPropertiesObjectBuilder(a: true, b: false));
+ var bytes = mystruct.toBytes();
+ var mystruct_read = example4.Foo(bytes);
+ expect(mystruct_read.myFoo!.a, true);
+ expect(mystruct_read.myFoo!.b, false);
+ }
+}
diff --git a/dart/test/keyword_test_keyword_test_generated.dart b/dart/test/keyword_test_keyword_test_generated.dart
new file mode 100644
index 0000000..6cfc233
--- /dev/null
+++ b/dart/test/keyword_test_keyword_test_generated.dart
@@ -0,0 +1,280 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable
+
+library keyword_test;
+
+import 'dart:typed_data' show Uint8List;
+import 'package:flat_buffers/flat_buffers.dart' as fb;
+
+
+class Abc {
+ final int value;
+ const Abc._(this.value);
+
+ factory Abc.fromValue(int value) {
+ final result = values[value];
+ if (result == null) {
+ throw StateError('Invalid value $value for bit flag enum Abc');
+ }
+ return result;
+ }
+
+ static Abc? _createOrNull(int? value) =>
+ value == null ? null : Abc.fromValue(value);
+
+ static const int minValue = 0;
+ static const int maxValue = 2;
+ static bool containsValue(int value) => values.containsKey(value);
+
+ static const Abc $void = Abc._(0);
+ static const Abc where = Abc._(1);
+ static const Abc stackalloc = Abc._(2);
+ static const Map<int, Abc> values = {
+ 0: $void,
+ 1: where,
+ 2: stackalloc};
+
+ static const fb.Reader<Abc> reader = _AbcReader();
+
+ @override
+ String toString() {
+ return 'Abc{value: $value}';
+ }
+}
+
+class _AbcReader extends fb.Reader<Abc> {
+ const _AbcReader();
+
+ @override
+ int get size => 4;
+
+ @override
+ Abc read(fb.BufferContext bc, int offset) =>
+ Abc.fromValue(const fb.Int32Reader().read(bc, offset));
+}
+
+class Public {
+ final int value;
+ const Public._(this.value);
+
+ factory Public.fromValue(int value) {
+ final result = values[value];
+ if (result == null) {
+ throw StateError('Invalid value $value for bit flag enum Public');
+ }
+ return result;
+ }
+
+ static Public? _createOrNull(int? value) =>
+ value == null ? null : Public.fromValue(value);
+
+ static const int minValue = 0;
+ static const int maxValue = 0;
+ static bool containsValue(int value) => values.containsKey(value);
+
+ static const Public NONE = Public._(0);
+ static const Map<int, Public> values = {
+ 0: NONE};
+
+ static const fb.Reader<Public> reader = _PublicReader();
+
+ @override
+ String toString() {
+ return 'Public{value: $value}';
+ }
+}
+
+class _PublicReader extends fb.Reader<Public> {
+ const _PublicReader();
+
+ @override
+ int get size => 4;
+
+ @override
+ Public read(fb.BufferContext bc, int offset) =>
+ Public.fromValue(const fb.Int32Reader().read(bc, offset));
+}
+
+class KeywordsInUnionTypeId {
+ final int value;
+ const KeywordsInUnionTypeId._(this.value);
+
+ factory KeywordsInUnionTypeId.fromValue(int value) {
+ final result = values[value];
+ if (result == null) {
+ throw StateError('Invalid value $value for bit flag enum KeywordsInUnionTypeId');
+ }
+ return result;
+ }
+
+ static KeywordsInUnionTypeId? _createOrNull(int? value) =>
+ value == null ? null : KeywordsInUnionTypeId.fromValue(value);
+
+ static const int minValue = 0;
+ static const int maxValue = 2;
+ static bool containsValue(int value) => values.containsKey(value);
+
+ static const KeywordsInUnionTypeId NONE = KeywordsInUnionTypeId._(0);
+ static const KeywordsInUnionTypeId $static = KeywordsInUnionTypeId._(1);
+ static const KeywordsInUnionTypeId internal = KeywordsInUnionTypeId._(2);
+ static const Map<int, KeywordsInUnionTypeId> values = {
+ 0: NONE,
+ 1: $static,
+ 2: internal};
+
+ static const fb.Reader<KeywordsInUnionTypeId> reader = _KeywordsInUnionTypeIdReader();
+
+ @override
+ String toString() {
+ return 'KeywordsInUnionTypeId{value: $value}';
+ }
+}
+
+class _KeywordsInUnionTypeIdReader extends fb.Reader<KeywordsInUnionTypeId> {
+ const _KeywordsInUnionTypeIdReader();
+
+ @override
+ int get size => 1;
+
+ @override
+ KeywordsInUnionTypeId read(fb.BufferContext bc, int offset) =>
+ KeywordsInUnionTypeId.fromValue(const fb.Uint8Reader().read(bc, offset));
+}
+
+class KeywordsInTable {
+ KeywordsInTable._(this._bc, this._bcOffset);
+ factory KeywordsInTable(List<int> bytes) {
+ final rootRef = fb.BufferContext.fromBytes(bytes);
+ return reader.read(rootRef, 0);
+ }
+
+ static const fb.Reader<KeywordsInTable> reader = _KeywordsInTableReader();
+
+ final fb.BufferContext _bc;
+ final int _bcOffset;
+
+ Abc get $is => Abc.fromValue(const fb.Int32Reader().vTableGet(_bc, _bcOffset, 4, 0));
+ Public get private => Public.fromValue(const fb.Int32Reader().vTableGet(_bc, _bcOffset, 6, 0));
+ int get type => const fb.Int32Reader().vTableGet(_bc, _bcOffset, 8, 0);
+ bool get $default => const fb.BoolReader().vTableGet(_bc, _bcOffset, 10, false);
+
+ @override
+ String toString() {
+ return 'KeywordsInTable{\$is: ${$is}, private: ${private}, type: ${type}, \$default: ${$default}}';
+ }
+
+ KeywordsInTableT unpack() => KeywordsInTableT(
+ $is: $is,
+ private: private,
+ type: type,
+ $default: $default);
+
+ static int pack(fb.Builder fbBuilder, KeywordsInTableT? object) {
+ if (object == null) return 0;
+ return object.pack(fbBuilder);
+ }
+}
+
+class KeywordsInTableT implements fb.Packable {
+ Abc $is;
+ Public private;
+ int type;
+ bool $default;
+
+ KeywordsInTableT({
+ this.$is = Abc.$void,
+ this.private = Public.NONE,
+ this.type = 0,
+ this.$default = false});
+
+ @override
+ int pack(fb.Builder fbBuilder) {
+ fbBuilder.startTable(4);
+ fbBuilder.addInt32(0, $is.value);
+ fbBuilder.addInt32(1, private.value);
+ fbBuilder.addInt32(2, type);
+ fbBuilder.addBool(3, $default);
+ return fbBuilder.endTable();
+ }
+
+ @override
+ String toString() {
+ return 'KeywordsInTableT{\$is: ${$is}, private: ${private}, type: ${type}, \$default: ${$default}}';
+ }
+}
+
+class _KeywordsInTableReader extends fb.TableReader<KeywordsInTable> {
+ const _KeywordsInTableReader();
+
+ @override
+ KeywordsInTable createObject(fb.BufferContext bc, int offset) =>
+ KeywordsInTable._(bc, offset);
+}
+
+class KeywordsInTableBuilder {
+ KeywordsInTableBuilder(this.fbBuilder);
+
+ final fb.Builder fbBuilder;
+
+ void begin() {
+ fbBuilder.startTable(4);
+ }
+
+ int addIs(Abc? $is) {
+ fbBuilder.addInt32(0, $is?.value);
+ return fbBuilder.offset;
+ }
+ int addPrivate(Public? private) {
+ fbBuilder.addInt32(1, private?.value);
+ return fbBuilder.offset;
+ }
+ int addType(int? type) {
+ fbBuilder.addInt32(2, type);
+ return fbBuilder.offset;
+ }
+ int addDefault(bool? $default) {
+ fbBuilder.addBool(3, $default);
+ return fbBuilder.offset;
+ }
+
+ int finish() {
+ return fbBuilder.endTable();
+ }
+}
+
+class KeywordsInTableObjectBuilder extends fb.ObjectBuilder {
+ final Abc? _$is;
+ final Public? _private;
+ final int? _type;
+ final bool? _$default;
+
+ KeywordsInTableObjectBuilder({
+ Abc? $is,
+ Public? private,
+ int? type,
+ bool? $default,
+ })
+ : _$is = $is,
+ _private = private,
+ _type = type,
+ _$default = $default;
+
+ /// Finish building, and store into the [fbBuilder].
+ @override
+ int finish(fb.Builder fbBuilder) {
+ fbBuilder.startTable(4);
+ fbBuilder.addInt32(0, _$is?.value);
+ fbBuilder.addInt32(1, _private?.value);
+ fbBuilder.addInt32(2, _type);
+ fbBuilder.addBool(3, _$default);
+ return fbBuilder.endTable();
+ }
+
+ /// Convenience method to serialize to byte list.
+ @override
+ Uint8List toBytes([String? fileIdentifier]) {
+ final fbBuilder = fb.Builder(deduplicateTables: false);
+ fbBuilder.finish(finish(fbBuilder), fileIdentifier);
+ return fbBuilder.buffer;
+ }
+}
diff --git a/dart/test/list_of_enums.fbs b/dart/test/list_of_enums.fbs
new file mode 100644
index 0000000..a4272a4
--- /dev/null
+++ b/dart/test/list_of_enums.fbs
@@ -0,0 +1,10 @@
+enum OptionsEnum : uint32
+{
+ A = 1,
+ B = 2,
+ C = 3
+}
+
+table MyTable {
+ options : [OptionsEnum];
+}
diff --git a/docs/source/Building.md b/docs/source/Building.md
index d7e9ca3..a12abac 100644
--- a/docs/source/Building.md
+++ b/docs/source/Building.md
@@ -31,24 +31,22 @@
### Make all warnings into errors
-By default all Flatbuffers `cmake` targets are build with `-Werror` flag.
-With this flag (or `/WX` for MSVC) C++ compiler will treat all warnings as errors.
-Additionally `-Wall -pedantic -Wextra` (or `/W4` form MSVC) flags are set.
-These flags minimize the number of possible defects in code and keep code highly portable.
-Using these flags is considered good practice but sometimes it can break dependent projects
-if a compiler is upgraded or a toolset is changed.
-Usually, newer compiler versions add new compile-time diagnostics that were unavailable before.
-These new diagnostic warnings could stop the build process if `-Werror` flag is set.
+By default all Flatbuffers `cmake` targets are **not** built with the `-Werror`
+(or `/WX` for MSVC) flag that treats any warning as an error. This allows more
+flexibility for users of Flatbuffers to use newer compilers and toolsets that
+may add new warnings that would cause a build failure.
-It is possible to cancel `warnings as errors` flag at `cmake` configuration stage using
-`FLATBUFFERS_CXX_FLAGS` option. Compilation flags declared in `FLATBUFFERS_CXX_FLAGS` will be
-appended to the project-level `CMAKE_CXX_FLAGS` variable.
-Examples:
+To enable a stricter build that does treat warnings as errors, set the
+`FLATBUFFERS_STRICT_MODE` `cmake` compliation flag to `ON`.
-- GCC and Clang: `cmake . -D FLATBUFFERS_CXX_FLAGS="-Wno-error"`
-- MSVC: `cmake . -D FLATBUFFERS_CXX_FLAGS="/WX-"`
-- MSVC: `cmake . -D FLATBUFFERS_CXX_FLAGS="/Wv <compiler.version>"`
+```
+cmake . -DFLATBUFFERS_STRICT_MODE=ON
+```
+Our CI builds run with strict mode on, ensuring the code that is committed to
+the project is as portable and warning free as possible. Thus developers
+contributing to the project should enable strict mode locally before making a
+PR.
## Building with VCPKG
@@ -63,6 +61,18 @@
The flatbuffers port in vcpkg is kept up to date by Microsoft team members and community contributors.
If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
+## Downloading binaries
+You can download the binaries from the
+[GitHub release page](https://github.com/google/flatbuffers/releases).
+
+We generate [SLSA3 signatures](slsa.dev) using the OpenSSF's [slsa-framework/slsa-github-generator](https://github.com/slsa-framework/slsa-github-generator). To verify the binaries:
+1. Install the verification tool from [slsa-framework/slsa-verifier#installation](https://github.com/slsa-framework/slsa-verifier#installation)
+1. Download the file named `attestation.intoto.jsonl` from the GitHub release
+1. Run:
+```shell
+$ slsa-verifier -artifact-path <downloaded.zip> -provenance attestation.intoto.jsonl -source github.com/google/flatbuffers -tag <version>
+ PASSED: Verified SLSA provenance
+
## Building for Android
There is a `flatbuffers/android` directory that contains all you need to build
diff --git a/docs/source/GoUsage.md b/docs/source/GoUsage.md
index ab6ddbd..e2aa115 100644
--- a/docs/source/GoUsage.md
+++ b/docs/source/GoUsage.md
@@ -52,10 +52,10 @@
example "MyGame/Example"
flatbuffers "github.com/google/flatbuffers/go"
- io/ioutil
+ "os"
)
- buf, err := ioutil.ReadFile("monster.dat")
+ buf, err := os.ReadFile("monster.dat")
// handle err
monster := example.GetRootAsMonster(buf, 0)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/docs/source/RustUsage.md b/docs/source/RustUsage.md
index 9e959a9..2a16258 100644
--- a/docs/source/RustUsage.md
+++ b/docs/source/RustUsage.md
@@ -58,7 +58,7 @@
For example, here is how you would read a FlatBuffer binary file in Rust:
First, include the library and generated code. Then read the file into
-a `u8` vector, which you pass, as a byte slice, to `get_root_as_monster()`.
+a `u8` vector, which you pass, as a byte slice, to `root_as_monster()`.
This full example program is available in the Rust test suite:
[monster_example.rs](https://github.com/google/flatbuffers/blob/master/tests/rust_usage_test/bin/monster_example.rs)
@@ -80,7 +80,7 @@
let mut buf = Vec::new();
f.read_to_end(&mut buf).expect("file reading failed");
- let monster = my_game::example::get_root_as_monster(&buf[..]);
+ let monster = my_game::example::root_as_monster(&buf[..]);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
`monster` is of type `Monster`, and points to somewhere *inside* your
@@ -108,7 +108,7 @@
For structs, layout is deterministic and guaranteed to be the same
across platforms (scalars are aligned to their
own size, and structs themselves to their largest member), and you
-are allowed to access this memory directly by using `safe_slice` and
+are allowed to access this memory directly by using `safe_slice`
on the reference to a struct, or even an array of structs.
To compute offsets to sub-elements of a struct, make sure they
@@ -118,9 +118,10 @@
in OpenGL or similar APIs.
It is important to note is that structs are still little endian on all
-machines, so only use tricks like this if you can guarantee you're not
-shipping on a big endian machine (using an `#[cfg(target_endian = "little")]`
-attribute would be wise).
+machines, so the functions to enable tricks like this are only exposed on little
+endian machines. If you also ship on big endian machines, using an
+`#[cfg(target_endian = "little")]` attribute would be wise or your code will not
+compile.
The special function `safe_slice` is implemented on Vector objects that are
represented in memory the same way as they are represented on the wire. This
@@ -134,22 +135,22 @@
## Access of untrusted buffers
+The safe Rust functions to interpret a slice as a table (`root`,
+`size_prefixed_root`, `root_with_opts`, and `size_prefixed_root_with_opts`)
+verify the data first. This has some performance cost, but is intended to be
+safe for use on flatbuffers from untrusted sources. There are corresponding
+`unsafe` versions with names ending in `_unchecked` which skip this
+verification, and may access arbitrary memory.
+
The generated accessor functions access fields over offsets, which is
-very quick. These offsets are used to index into Rust slices, so they are
-bounds-checked by the Rust runtime. However, our Rust implementation may
-change: we may convert access functions to use direct pointer dereferencing, to
-improve lookup speed. As a result, users should not rely on the aforementioned
-bounds-checking behavior.
+very quick. The current implementation uses these to access memory without any
+further bounds checking. All of the safe Rust APIs ensure the verifier is run
+over these flatbuffers before accessing them.
When you're processing large amounts of data from a source you know (e.g.
-your own generated data on disk), this is acceptable, but when reading
-data from the network that can potentially have been modified by an
-attacker, this is undesirable.
-
-The C++ port provides a buffer verifier. At this time, Rust does not. Rust may
-provide a verifier in a future version. In the meantime, Rust users can access
-the buffer verifier generated by the C++ port through a foreign function
-interface (FFI).
+your own generated data on disk), the `_unchecked` versions are acceptable, but
+when reading data from the network that can potentially have been modified by an
+attacker, it is desirable to use the safe versions which use the verifier.
## Threading
@@ -165,6 +166,17 @@
accomplish this, by design, as we feel multithreaded construction
of a single buffer will be rare, and synchronisation overhead would be costly.
+Unlike most other languages, in Rust these properties are exposed to and
+enforced by the type system. `flatbuffers::Table` and the generated table types
+are `Send + Sync`, indicating they may be freely shared across threads and data
+may be accessed from any thread which receives a const (aka shared) reference.
+There are no functions which require a mutable (aka exclusive) reference, which
+means all the available functions may be called like this.
+`flatbuffers::FlatBufferBuilder` is also `Send + Sync`, but all of the mutating
+functions require a mutable (aka exclusive) reference which can only be created
+when no other references to the `FlatBufferBuilder` exist, and may not be copied
+within the same thread, let alone to a second thread.
+
## Useful tools created by others
* [flatc-rust](https://github.com/frol/flatc-rust) - FlatBuffers compiler
diff --git a/docs/source/SwiftUsage.md b/docs/source/SwiftUsage.md
index 1c438f2..b10375e 100644
--- a/docs/source/SwiftUsage.md
+++ b/docs/source/SwiftUsage.md
@@ -22,10 +22,10 @@
## Testing the FlatBuffers Swift library
-The code to test the Swift library can be found at `flatbuffers/Flatbuffers.Test.Swift`.
-The test code itself is located in [Flatbuffers.Test.Swift](https://github.com/google/flatbuffers/blob/master/tests/FlatBuffers.Test.Swift).
+The code to test the Swift library can be found at `flatbuffers/tests/swift/tests`.
+The test code itself is located in [flatbuffers/tests/swift/tests](https://github.com/google/flatbuffers/blob/master/tests/swift/tests).
-To run the tests, use the [SwiftTest.sh](https://github.com/google/flatbuffers/blob/master/tests/FlatBuffers.Test.Swift/SwiftTest.sh) shell script.
+To run the tests, use the [SwiftTest.sh](https://github.com/google/flatbuffers/blob/master/tests/swift/tests/SwiftTest.sh) shell script.
*Note: The shell script requires [Swift](https://swift.org) to
be installed.*
diff --git a/docs/source/TypeScriptUsage.md b/docs/source/TypeScriptUsage.md
index a1acaeb..0dd1da2 100644
--- a/docs/source/TypeScriptUsage.md
+++ b/docs/source/TypeScriptUsage.md
@@ -21,8 +21,8 @@
## Testing the FlatBuffers TypeScript library
-To run the tests, use the [TypeScriptTest.sh](https://github.com/google/
-flatbuffers/blob/master/tests/TypeScriptTest.sh) shell script.
+To run the tests, use the [TypeScriptTest.py](https://github.com/google/
+flatbuffers/blob/master/tests/TypeScriptTest.py) Python3 script.
*Note: The TypeScript test file requires [Node.js](https://nodejs.org/en/).*
diff --git a/grpc/examples/generate.sh b/grpc/examples/generate.sh
deleted file mode 100755
index 0f051da..0000000
--- a/grpc/examples/generate.sh
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2021 Google Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-set -e
-
-current_dir=`pwd`
-
-cd ../..
-
-main_dir=`pwd`
-
-cd ${current_dir}
-
-# Looks for flatc within the root dir & debug
-if [ -e ${main_dir}/flatc ]; then
- alias fbc='${main_dir}/flatc'
-elif [ -e ${main_dir}/Debug/flatc ]; then
- alias fbc='${main_dir}/Debug/flatc'
-else
- echo 'flatc' could not be found. Make sure to build FlatBuffers from the \
- $rootdir directory.
- exit 1
-fi
-
-generator="--grpc $current_dir/greeter.fbs"
-
-# Regenerate Go lang code
-cd go
-
-cd greeter
-fbc --bfbs-filenames ../.. --go ${generator}
-
-cd ${current_dir}
-
-# Regenerate Python code
-cd python
-
-cd greeter
-
-fbc --bfbs-filenames ../.. --python ${generator}
-
-cd ${current_dir}
-
-# Regenerate Swift code
-cd swift
-
-cd Greeter/Sources/Model
-fbc --bfbs-filenames ../../../.. --swift --gen-json-emit ${generator}
-
-cd ${current_dir}
-
-# Regenerate Typescript code
-cd ts
-
-cd greeter/src
-fbc --bfbs-filenames ../../.. --ts ${generator}
-
-cd ${current_dir}
diff --git a/grpc/examples/go/greeter/client/main.go b/grpc/examples/go/greeter/client/main.go
index 4993576..a764912 100644
--- a/grpc/examples/go/greeter/client/main.go
+++ b/grpc/examples/go/greeter/client/main.go
@@ -9,8 +9,10 @@
"time"
flatbuffers "github.com/google/flatbuffers/go"
- models "github.com/google/flatbuffers/grpc/examples/go/greeter/models"
"google.golang.org/grpc"
+ "google.golang.org/grpc/credentials/insecure"
+
+ models "github.com/google/flatbuffers/grpc/examples/go/greeter/models"
)
var (
@@ -63,7 +65,9 @@
func main() {
flag.Parse()
- conn, err := grpc.Dial(fmt.Sprintf("localhost:%d", 3000), grpc.WithInsecure(), grpc.WithCodec(flatbuffers.FlatbuffersCodec{}))
+ conn, err := grpc.Dial(fmt.Sprintf("localhost:%d", 3000),
+ grpc.WithTransportCredentials(insecure.NewCredentials()),
+ grpc.WithDefaultCallOptions(grpc.ForceCodec(flatbuffers.FlatbuffersCodec{})))
if err != nil {
log.Fatalf("fail to dial: %v", err)
}
diff --git a/grpc/examples/swift/Greeter/Sources/Model/greeter_generated.swift b/grpc/examples/swift/Greeter/Sources/Model/greeter_generated.swift
index a7c420b..17cf38f 100644
--- a/grpc/examples/swift/Greeter/Sources/Model/greeter_generated.swift
+++ b/grpc/examples/swift/Greeter/Sources/Model/greeter_generated.swift
@@ -6,7 +6,7 @@
public struct models_HelloReply: FlatBufferObject, Verifiable {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
@@ -55,7 +55,7 @@
public struct models_HelloRequest: FlatBufferObject, Verifiable {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
diff --git a/grpc/examples/ts/greeter/src/greeter_generated.ts b/grpc/examples/ts/greeter/src/greeter_generated.ts
new file mode 100644
index 0000000..c48afe5
--- /dev/null
+++ b/grpc/examples/ts/greeter/src/greeter_generated.ts
@@ -0,0 +1,4 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+export { HelloReply } from './models/hello-reply.js';
+export { HelloRequest } from './models/hello-request.js';
diff --git a/grpc/examples/ts/greeter/src/models/hello-reply.ts b/grpc/examples/ts/greeter/src/models/hello-reply.ts
index e68f7a4..b041a7e 100644
--- a/grpc/examples/ts/greeter/src/models/hello-reply.ts
+++ b/grpc/examples/ts/greeter/src/models/hello-reply.ts
@@ -7,7 +7,7 @@
export class HelloReply {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
-__init(i:number, bb:flatbuffers.ByteBuffer):HelloReply {
+ __init(i:number, bb:flatbuffers.ByteBuffer):HelloReply {
this.bb_pos = i;
this.bb = bb;
return this;
diff --git a/grpc/examples/ts/greeter/src/models/hello-request.ts b/grpc/examples/ts/greeter/src/models/hello-request.ts
index 3718167..d943e45 100644
--- a/grpc/examples/ts/greeter/src/models/hello-request.ts
+++ b/grpc/examples/ts/greeter/src/models/hello-request.ts
@@ -7,7 +7,7 @@
export class HelloRequest {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
-__init(i:number, bb:flatbuffers.ByteBuffer):HelloRequest {
+ __init(i:number, bb:flatbuffers.ByteBuffer):HelloRequest {
this.bb_pos = i;
this.bb = bb;
return this;
diff --git a/grpc/src/compiler/cpp_generator.cc b/grpc/src/compiler/cpp_generator.cc
index 69dcf59..fd635f2 100644
--- a/grpc/src/compiler/cpp_generator.cc
+++ b/grpc/src/compiler/cpp_generator.cc
@@ -8,24 +8,24 @@
namespace grpc_cpp_generator {
namespace {
-grpc::string message_header_ext() { return "_generated.h"; }
-grpc::string service_header_ext() { return ".grpc.fb.h"; }
+static grpc::string service_header_ext() { return ".grpc.fb.h"; }
-template<class T> grpc::string as_string(T x) {
+template<class T>
+static grpc::string as_string(T x) {
std::ostringstream out;
out << x;
return out.str();
}
-inline bool ClientOnlyStreaming(const grpc_generator::Method *method) {
+static inline bool ClientOnlyStreaming(const grpc_generator::Method *method) {
return method->ClientStreaming() && !method->ServerStreaming();
}
-inline bool ServerOnlyStreaming(const grpc_generator::Method *method) {
+static inline bool ServerOnlyStreaming(const grpc_generator::Method *method) {
return !method->ClientStreaming() && method->ServerStreaming();
}
-grpc::string FilenameIdentifier(const grpc::string &filename) {
+static grpc::string FilenameIdentifier(const grpc::string &filename) {
grpc::string result;
for (unsigned i = 0; i < filename.size(); i++) {
char c = filename[i];
@@ -40,11 +40,11 @@
}
return result;
}
-} // namespace
-template<class T, size_t N> T *array_end(T (&array)[N]) { return array + N; }
+template<class T, size_t N>
+static T *array_end(T (&array)[N]) { return array + N; }
-void PrintIncludes(grpc_generator::Printer *printer,
+static void PrintIncludes(grpc_generator::Printer *printer,
const std::vector<grpc::string> &headers,
const Parameters ¶ms) {
std::map<grpc::string, grpc::string> vars;
@@ -64,8 +64,10 @@
}
}
+} // namespace
+
grpc::string GetHeaderPrologue(grpc_generator::File *file,
- const Parameters & /*params*/) {
+ const Parameters ¶ms) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -75,7 +77,7 @@
vars["filename"] = file->filename();
vars["filename_identifier"] = FilenameIdentifier(file->filename());
vars["filename_base"] = file->filename_without_ext();
- vars["message_header_ext"] = file->message_header_ext();
+ vars["message_header_ext"] = params.message_header_extension;
printer->Print(vars, "// Generated by the gRPC C++ plugin.\n");
printer->Print(vars,
@@ -138,7 +140,10 @@
return output;
}
-void PrintHeaderClientMethodInterfaces(
+
+namespace {
+
+static void PrintHeaderClientMethodInterfaces(
grpc_generator::Printer *printer, const grpc_generator::Method *method,
std::map<grpc::string, grpc::string> *vars, bool is_public) {
(*vars)["Method"] = method->name();
@@ -352,7 +357,9 @@
}
}
-void PrintHeaderClientMethod(grpc_generator::Printer *printer,
+
+
+static void PrintHeaderClientMethod(grpc_generator::Printer *printer,
const grpc_generator::Method *method,
std::map<grpc::string, grpc::string> *vars,
bool is_public) {
@@ -555,7 +562,7 @@
}
}
-void PrintHeaderClientMethodData(grpc_generator::Printer *printer,
+static void PrintHeaderClientMethodData(grpc_generator::Printer *printer,
const grpc_generator::Method *method,
std::map<grpc::string, grpc::string> *vars) {
(*vars)["Method"] = method->name();
@@ -563,7 +570,7 @@
"const ::grpc::internal::RpcMethod rpcmethod_$Method$_;\n");
}
-void PrintHeaderServerMethodSync(grpc_generator::Printer *printer,
+static void PrintHeaderServerMethodSync(grpc_generator::Printer *printer,
const grpc_generator::Method *method,
std::map<grpc::string, grpc::string> *vars) {
(*vars)["Method"] = method->name();
@@ -597,7 +604,7 @@
printer->Print(method->GetTrailingComments("//").c_str());
}
-void PrintHeaderServerMethodAsync(grpc_generator::Printer *printer,
+static void PrintHeaderServerMethodAsync(grpc_generator::Printer *printer,
const grpc_generator::Method *method,
std::map<grpc::string, grpc::string> *vars) {
(*vars)["Method"] = method->name();
@@ -648,7 +655,7 @@
"::grpc::Status $Method$("
"::grpc::ServerContext* /*context*/, "
"::grpc::ServerReader< $Request$>* /*reader*/, "
- "$Response$* response) final override {\n"
+ "$Response$* /*response*/) final override {\n"
" abort();\n"
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
"}\n");
@@ -713,7 +720,7 @@
printer->Print(*vars, "};\n");
}
-void PrintHeaderServerMethodStreamedUnary(
+static void PrintHeaderServerMethodStreamedUnary(
grpc_generator::Printer *printer, const grpc_generator::Method *method,
std::map<grpc::string, grpc::string> *vars) {
(*vars)["Method"] = method->name();
@@ -764,7 +771,7 @@
}
}
-void PrintHeaderServerMethodSplitStreaming(
+static void PrintHeaderServerMethodSplitStreaming(
grpc_generator::Printer *printer, const grpc_generator::Method *method,
std::map<grpc::string, grpc::string> *vars) {
(*vars)["Method"] = method->name();
@@ -817,7 +824,7 @@
}
}
-void PrintHeaderServerMethodGeneric(
+static void PrintHeaderServerMethodGeneric(
grpc_generator::Printer *printer, const grpc_generator::Method *method,
std::map<grpc::string, grpc::string> *vars) {
(*vars)["Method"] = method->name();
@@ -888,7 +895,7 @@
printer->Print(*vars, "};\n");
}
-void PrintHeaderService(grpc_generator::Printer *printer,
+static void PrintHeaderService(grpc_generator::Printer *printer,
const grpc_generator::Service *service,
std::map<grpc::string, grpc::string> *vars) {
(*vars)["Service"] = service->name();
@@ -1059,6 +1066,8 @@
printer->Print(service->GetTrailingComments("//").c_str());
}
+} // namespace
+
grpc::string GetHeaderServices(grpc_generator::File *file,
const Parameters ¶ms) {
grpc::string output;
@@ -1118,7 +1127,7 @@
}
grpc::string GetSourcePrologue(grpc_generator::File *file,
- const Parameters & /*params*/) {
+ const Parameters ¶ms) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -1127,8 +1136,8 @@
vars["filename"] = file->filename();
vars["filename_base"] = file->filename_without_ext();
- vars["message_header_ext"] = file->message_header_ext();
- vars["service_header_ext"] = file->service_header_ext();
+ vars["message_header_ext"] = params.message_header_extension;
+ vars["service_header_ext"] = service_header_ext();
printer->Print(vars, "// Generated by the gRPC C++ plugin.\n");
printer->Print(vars,
@@ -1177,7 +1186,10 @@
return output;
}
-void PrintSourceClientMethod(grpc_generator::Printer *printer,
+
+namespace {
+
+static void PrintSourceClientMethod(grpc_generator::Printer *printer,
const grpc_generator::Method *method,
std::map<grpc::string, grpc::string> *vars) {
(*vars)["Method"] = method->name();
@@ -1321,7 +1333,7 @@
}
}
-void PrintSourceServerMethod(grpc_generator::Printer *printer,
+static void PrintSourceServerMethod(grpc_generator::Printer *printer,
const grpc_generator::Method *method,
std::map<grpc::string, grpc::string> *vars) {
(*vars)["Method"] = method->name();
@@ -1370,7 +1382,7 @@
}
}
-void PrintSourceService(grpc_generator::Printer *printer,
+static void PrintSourceService(grpc_generator::Printer *printer,
const grpc_generator::Service *service,
std::map<grpc::string, grpc::string> *vars) {
(*vars)["Service"] = service->name();
@@ -1487,6 +1499,8 @@
}
}
+} // namespace
+
grpc::string GetSourceServices(grpc_generator::File *file,
const Parameters ¶ms) {
grpc::string output;
@@ -1532,9 +1546,8 @@
return temp;
}
-// TODO(mmukhi): Make sure we need parameters or not.
grpc::string GetMockPrologue(grpc_generator::File *file,
- const Parameters & /*params*/) {
+ const Parameters ¶ms) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -1543,7 +1556,7 @@
vars["filename"] = file->filename();
vars["filename_base"] = file->filename_without_ext();
- vars["message_header_ext"] = message_header_ext();
+ vars["message_header_ext"] = params.message_header_extension;
vars["service_header_ext"] = service_header_ext();
printer->Print(vars, "// Generated by the gRPC C++ plugin.\n");
@@ -1590,7 +1603,10 @@
return output;
}
-void PrintMockClientMethods(grpc_generator::Printer *printer,
+
+namespace {
+
+static void PrintMockClientMethods(grpc_generator::Printer *printer,
const grpc_generator::Method *method,
std::map<grpc::string, grpc::string> *vars) {
(*vars)["Method"] = method->name();
@@ -1682,7 +1698,7 @@
}
}
-void PrintMockService(grpc_generator::Printer *printer,
+static void PrintMockService(grpc_generator::Printer *printer,
const grpc_generator::Service *service,
std::map<grpc::string, grpc::string> *vars) {
(*vars)["Service"] = service->name();
@@ -1698,6 +1714,8 @@
printer->Print("};\n");
}
+} // namespace
+
grpc::string GetMockServices(grpc_generator::File *file,
const Parameters ¶ms) {
grpc::string output;
diff --git a/grpc/src/compiler/cpp_generator.h b/grpc/src/compiler/cpp_generator.h
index 16aa97a..a9af1a6 100644
--- a/grpc/src/compiler/cpp_generator.h
+++ b/grpc/src/compiler/cpp_generator.h
@@ -33,6 +33,8 @@
grpc::string grpc_search_path;
// Generate GMOCK code to facilitate unit testing.
bool generate_mock_code;
+ // By default, use "_generated.h"
+ std::string message_header_extension;
};
// Return the prologue of the generated header file.
diff --git a/grpc/src/compiler/go_generator.cc b/grpc/src/compiler/go_generator.cc
index 9ba2e65..ad4694b 100644
--- a/grpc/src/compiler/go_generator.cc
+++ b/grpc/src/compiler/go_generator.cc
@@ -19,22 +19,23 @@
}
namespace grpc_go_generator {
+namespace {
// Returns string with first letter to lowerCase
-grpc::string unexportName(grpc::string s) {
+static grpc::string unexportName(grpc::string s) {
if (s.empty()) return s;
s[0] = static_cast<char>(std::tolower(s[0]));
return s;
}
// Returns string with first letter to uppercase
-grpc::string exportName(grpc::string s) {
+static grpc::string exportName(grpc::string s) {
if (s.empty()) return s;
s[0] = static_cast<char>(std::toupper(s[0]));
return s;
}
-void GenerateError(grpc_generator::Printer *printer,
+static void GenerateError(grpc_generator::Printer *printer,
std::map<grpc::string, grpc::string> vars,
const bool multiple_return = true) {
printer->Print(vars, "if $Error_Check$ {\n");
@@ -46,7 +47,7 @@
}
// Generates imports for the service
-void GenerateImports(grpc_generator::File *file,
+static void GenerateImports(grpc_generator::File *file,
grpc_generator::Printer *printer,
std::map<grpc::string, grpc::string> vars) {
vars["filename"] = file->filename();
@@ -66,7 +67,7 @@
}
// Generates Server method signature source
-void GenerateServerMethodSignature(const grpc_generator::Method *method,
+static void GenerateServerMethodSignature(const grpc_generator::Method *method,
grpc_generator::Printer *printer,
std::map<grpc::string, grpc::string> vars) {
vars["Method"] = exportName(method->name());
@@ -86,7 +87,7 @@
}
}
-void GenerateServerMethod(const grpc_generator::Method *method,
+static void GenerateServerMethod(const grpc_generator::Method *method,
grpc_generator::Printer *printer,
std::map<grpc::string, grpc::string> vars) {
vars["Method"] = exportName(method->name());
@@ -204,7 +205,7 @@
}
// Generates Client method signature source
-void GenerateClientMethodSignature(const grpc_generator::Method *method,
+static void GenerateClientMethodSignature(const grpc_generator::Method *method,
grpc_generator::Printer *printer,
std::map<grpc::string, grpc::string> vars) {
vars["Method"] = exportName(method->name());
@@ -225,7 +226,7 @@
}
// Generates Client method source
-void GenerateClientMethod(const grpc_generator::Method *method,
+static void GenerateClientMethod(const grpc_generator::Method *method,
grpc_generator::Printer *printer,
std::map<grpc::string, grpc::string> vars) {
printer->Print(vars, "func (c *$ServiceUnexported$Client) ");
@@ -480,6 +481,7 @@
printer->Outdent();
printer->Print("}\n");
}
+} // namespace
// Returns source for the service
grpc::string GenerateServiceSource(grpc_generator::File *file,
diff --git a/grpc/src/compiler/java_generator.cc b/grpc/src/compiler/java_generator.cc
index 98f8788..bfe2b11 100644
--- a/grpc/src/compiler/java_generator.cc
+++ b/grpc/src/compiler/java_generator.cc
@@ -44,8 +44,9 @@
namespace grpc_java_generator {
typedef std::string string;
+namespace {
// Generates imports for the service
-void GenerateImports(grpc_generator::File *file,
+static void GenerateImports(grpc_generator::File *file,
grpc_generator::Printer *printer, VARS &vars) {
vars["filename"] = file->filename();
printer->Print(vars,
@@ -287,7 +288,7 @@
printer->Print(" */\n");
}
-void GrpcWriteMethodDocComment(Printer *printer, VARS &vars,
+static void GrpcWriteMethodDocComment(Printer *printer, VARS &vars,
const MethodDescriptor *method) {
printer->Print("/**\n");
std::vector<string> lines = GrpcGetDocLinesForDescriptor(method);
@@ -1029,7 +1030,7 @@
p->Print("}\n");
}
-void PrintStaticImports(Printer *p) {
+static void PrintStaticImports(Printer *p) {
p->Print(
"import java.nio.ByteBuffer;\n"
"import static "
@@ -1062,7 +1063,7 @@
"io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;\n\n");
}
-void GenerateService(const grpc_generator::Service *service,
+static void GenerateService(const grpc_generator::Service *service,
grpc_generator::Printer *printer, VARS &vars,
bool disable_version) {
// All non-generated classes must be referred by fully qualified names to
@@ -1097,6 +1098,7 @@
PrintService(printer, vars, service, disable_version);
}
+} // namespace
grpc::string GenerateServiceSource(
grpc_generator::File *file, const grpc_generator::Service *service,
diff --git a/grpc/src/compiler/python_generator.cc b/grpc/src/compiler/python_generator.cc
index 8108db4..d5f69e2 100644
--- a/grpc/src/compiler/python_generator.cc
+++ b/grpc/src/compiler/python_generator.cc
@@ -23,8 +23,9 @@
#include "src/compiler/python_generator.h"
namespace grpc_python_generator {
+namespace {
-grpc::string GenerateMethodType(const grpc_generator::Method *method) {
+static grpc::string GenerateMethodType(const grpc_generator::Method *method) {
if (method->NoStreaming())
return "unary_unary";
@@ -131,6 +132,7 @@
printer->Outdent();
printer->Print("\n");
}
+} // namespace
grpc::string Generate(grpc_generator::File *file,
const grpc_generator::Service *service) {
diff --git a/grpc/src/compiler/schema_interface.h b/grpc/src/compiler/schema_interface.h
index e42e3e3..f89288d 100644
--- a/grpc/src/compiler/schema_interface.h
+++ b/grpc/src/compiler/schema_interface.h
@@ -107,8 +107,6 @@
virtual grpc::string package() const = 0;
virtual std::vector<grpc::string> package_parts() const = 0;
virtual grpc::string additional_headers() const = 0;
- virtual std::string message_header_ext() const = 0;
- virtual std::string service_header_ext() const = 0;
virtual int service_count() const = 0;
virtual std::unique_ptr<const Service> service(int i) const = 0;
diff --git a/grpc/src/compiler/swift_generator.cc b/grpc/src/compiler/swift_generator.cc
index 403a803..b0a96d8 100644
--- a/grpc/src/compiler/swift_generator.cc
+++ b/grpc/src/compiler/swift_generator.cc
@@ -28,8 +28,9 @@
#include "src/compiler/swift_generator.h"
namespace grpc_swift_generator {
+namespace {
-std::string WrapInNameSpace(const std::vector<std::string> &components,
+static std::string WrapInNameSpace(const std::vector<std::string> &components,
const grpc::string &name) {
std::string qualified_name;
for (auto it = components.begin(); it != components.end(); ++it)
@@ -37,14 +38,14 @@
return qualified_name + name;
}
-grpc::string GenerateMessage(const std::vector<std::string> &components,
+static grpc::string GenerateMessage(const std::vector<std::string> &components,
const grpc::string &name) {
return "Message<" + WrapInNameSpace(components, name) + ">";
}
// MARK: - Client
-void GenerateClientFuncName(const grpc_generator::Method *method,
+static void GenerateClientFuncName(const grpc_generator::Method *method,
grpc_generator::Printer *printer,
std::map<grpc::string, grpc::string> *dictonary) {
auto vars = *dictonary;
@@ -82,7 +83,7 @@
" ) -> BidirectionalStreamingCall<$Input$, $Output$>");
}
-void GenerateClientFuncBody(const grpc_generator::Method *method,
+static void GenerateClientFuncBody(const grpc_generator::Method *method,
grpc_generator::Printer *printer,
std::map<grpc::string, grpc::string> *dictonary) {
auto vars = *dictonary;
@@ -372,6 +373,7 @@
}
printer->Print("}");
}
+} // namespace
grpc::string Generate(grpc_generator::File *file,
const grpc_generator::Service *service) {
diff --git a/grpc/src/compiler/ts_generator.cc b/grpc/src/compiler/ts_generator.cc
index 3c3daf0..ff362b7 100644
--- a/grpc/src/compiler/ts_generator.cc
+++ b/grpc/src/compiler/ts_generator.cc
@@ -30,8 +30,9 @@
#include "src/compiler/schema_interface.h"
namespace grpc_ts_generator {
+namespace {
-grpc::string GenerateNamespace(const std::vector<std::string> ns,
+static grpc::string GenerateNamespace(const std::vector<std::string> ns,
const std::string filename,
const bool include_separator) {
grpc::string path = "";
@@ -55,7 +56,7 @@
// MARK: - Shared code
-void GenerateImports(const grpc_generator::Service *service,
+static void GenerateImports(const grpc_generator::Service *service,
grpc_generator::Printer *printer,
std::map<grpc::string, grpc::string> *dictonary,
const bool grpc_var_import) {
@@ -104,7 +105,7 @@
// MARK: - Generate Main GRPC Code
-void GetStreamType(grpc_generator::Printer *printer,
+static void GetStreamType(grpc_generator::Printer *printer,
const grpc_generator::Method *method,
std::map<grpc::string, grpc::string> *dictonary) {
auto vars = *dictonary;
@@ -116,7 +117,7 @@
printer->Print(vars, "responseStream: $ServerStreaming$,\n");
}
-void GenerateSerializeMethod(grpc_generator::Printer *printer,
+static void GenerateSerializeMethod(grpc_generator::Printer *printer,
std::map<grpc::string, grpc::string> *dictonary) {
auto vars = *dictonary;
printer->Print(vars, "function serialize_$Type$(buffer_args) {\n");
@@ -132,7 +133,7 @@
printer->Print("}\n\n");
}
-void GenerateDeserializeMethod(
+static void GenerateDeserializeMethod(
grpc_generator::Printer *printer,
std::map<grpc::string, grpc::string> *dictonary) {
auto vars = *dictonary;
@@ -145,7 +146,7 @@
printer->Print("}\n\n");
}
-void GenerateMethods(const grpc_generator::Service *service,
+static void GenerateMethods(const grpc_generator::Service *service,
grpc_generator::Printer *printer,
std::map<grpc::string, grpc::string> *dictonary) {
auto vars = *dictonary;
@@ -177,7 +178,7 @@
}
}
-void GenerateService(const grpc_generator::Service *service,
+static void GenerateService(const grpc_generator::Service *service,
grpc_generator::Printer *printer,
std::map<grpc::string, grpc::string> *dictonary) {
auto vars = *dictonary;
@@ -212,6 +213,8 @@
"grpc.makeGenericClientConstructor($NAME$);");
}
+} // namespace
+
grpc::string Generate(grpc_generator::File *file,
const grpc_generator::Service *service,
const grpc::string &filename) {
@@ -233,9 +236,11 @@
return output;
}
+namespace {
+
// MARK: - Generate Interface
-void FillInterface(grpc_generator::Printer *printer,
+static void FillInterface(grpc_generator::Printer *printer,
std::map<grpc::string, grpc::string> *dictonary) {
auto vars = *dictonary;
printer->Print(vars,
@@ -253,7 +258,7 @@
printer->Print("}\n");
}
-void GenerateInterfaces(const grpc_generator::Service *service,
+static void GenerateInterfaces(const grpc_generator::Service *service,
grpc_generator::Printer *printer,
std::map<grpc::string, grpc::string> *dictonary) {
auto vars = *dictonary;
@@ -275,7 +280,7 @@
}
}
-void GenerateExportedInterface(
+static void GenerateExportedInterface(
const grpc_generator::Service *service, grpc_generator::Printer *printer,
std::map<grpc::string, grpc::string> *dictonary) {
auto vars = *dictonary;
@@ -319,7 +324,7 @@
printer->Print("}\n");
}
-void GenerateMainInterface(const grpc_generator::Service *service,
+static void GenerateMainInterface(const grpc_generator::Service *service,
grpc_generator::Printer *printer,
std::map<grpc::string, grpc::string> *dictonary) {
auto vars = *dictonary;
@@ -344,11 +349,11 @@
GenerateExportedInterface(service, printer, &vars);
}
-grpc::string GenerateMetaData() { return "metadata: grpc.Metadata"; }
+static grpc::string GenerateMetaData() { return "metadata: grpc.Metadata"; }
-grpc::string GenerateOptions() { return "options: Partial<grpc.CallOptions>"; }
+static grpc::string GenerateOptions() { return "options: Partial<grpc.CallOptions>"; }
-void GenerateUnaryClientInterface(
+static void GenerateUnaryClientInterface(
grpc_generator::Printer *printer,
std::map<grpc::string, grpc::string> *dictonary) {
auto vars = *dictonary;
@@ -363,7 +368,7 @@
printer->Print(vars, (main + meta_data + options + callback).c_str());
}
-void GenerateClientWriteStreamInterface(
+static void GenerateClientWriteStreamInterface(
grpc_generator::Printer *printer,
std::map<grpc::string, grpc::string> *dictonary) {
auto vars = *dictonary;
@@ -380,7 +385,7 @@
printer->Print(vars, (main + meta_data + options + callback).c_str());
}
-void GenerateClientReadableStreamInterface(
+static void GenerateClientReadableStreamInterface(
grpc_generator::Printer *printer,
std::map<grpc::string, grpc::string> *dictonary) {
auto vars = *dictonary;
@@ -392,7 +397,7 @@
printer->Print(vars, (main + options + end_function).c_str());
}
-void GenerateDepluxStreamInterface(
+static void GenerateDepluxStreamInterface(
grpc_generator::Printer *printer,
std::map<grpc::string, grpc::string> *dictonary) {
auto vars = *dictonary;
@@ -408,7 +413,7 @@
.c_str());
}
-void GenerateClientInterface(const grpc_generator::Service *service,
+static void GenerateClientInterface(const grpc_generator::Service *service,
grpc_generator::Printer *printer,
std::map<grpc::string, grpc::string> *dictonary) {
auto vars = *dictonary;
@@ -446,7 +451,7 @@
printer->Print("}\n");
}
-void GenerateClientClassInterface(
+static void GenerateClientClassInterface(
const grpc_generator::Service *service, grpc_generator::Printer *printer,
std::map<grpc::string, grpc::string> *dictonary) {
auto vars = *dictonary;
@@ -487,6 +492,8 @@
printer->Outdent();
printer->Print("}\n");
}
+} // namespace
+
grpc::string GenerateInterface(grpc_generator::File *file,
const grpc_generator::Service *service,
diff --git a/include/flatbuffers/base.h b/include/flatbuffers/base.h
index 458ac3f..870a811 100644
--- a/include/flatbuffers/base.h
+++ b/include/flatbuffers/base.h
@@ -140,7 +140,7 @@
#define FLATBUFFERS_VERSION_MAJOR 2
#define FLATBUFFERS_VERSION_MINOR 0
-#define FLATBUFFERS_VERSION_REVISION 6
+#define FLATBUFFERS_VERSION_REVISION 8
#define FLATBUFFERS_STRING_EXPAND(X) #X
#define FLATBUFFERS_STRING(X) FLATBUFFERS_STRING_EXPAND(X)
namespace flatbuffers {
@@ -260,9 +260,12 @@
#endif // !FLATBUFFERS_HAS_NEW_STRTOD
#ifndef FLATBUFFERS_LOCALE_INDEPENDENT
- // Enable locale independent functions {strtof_l, strtod_l,strtoll_l, strtoull_l}.
- #if ((defined(_MSC_VER) && _MSC_VER >= 1800) || \
- (defined(_XOPEN_VERSION) && (_XOPEN_VERSION>=700)) && (!defined(__ANDROID_API__) || (defined(__ANDROID_API__) && (__ANDROID_API__>=21))))
+ // Enable locale independent functions {strtof_l, strtod_l,strtoll_l,
+ // strtoull_l}.
+ #if (defined(_MSC_VER) && _MSC_VER >= 1800) || \
+ (defined(__ANDROID_API__) && __ANDROID_API__>= 21) || \
+ (defined(_XOPEN_VERSION) && (_XOPEN_VERSION >= 700)) && \
+ (!defined(__Fuchsia__) && !defined(__ANDROID_API__))
#define FLATBUFFERS_LOCALE_INDEPENDENT 1
#else
#define FLATBUFFERS_LOCALE_INDEPENDENT 0
@@ -270,14 +273,14 @@
#endif // !FLATBUFFERS_LOCALE_INDEPENDENT
// Suppress Undefined Behavior Sanitizer (recoverable only). Usage:
-// - __supress_ubsan__("undefined")
-// - __supress_ubsan__("signed-integer-overflow")
+// - __suppress_ubsan__("undefined")
+// - __suppress_ubsan__("signed-integer-overflow")
#if defined(__clang__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >=7))
- #define __supress_ubsan__(type) __attribute__((no_sanitize(type)))
+ #define __suppress_ubsan__(type) __attribute__((no_sanitize(type)))
#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 409)
- #define __supress_ubsan__(type) __attribute__((no_sanitize_undefined))
+ #define __suppress_ubsan__(type) __attribute__((no_sanitize_undefined))
#else
- #define __supress_ubsan__(type)
+ #define __suppress_ubsan__(type)
#endif
// This is constexpr function used for checking compile-time constants.
@@ -328,8 +331,17 @@
// In 32bits, this evaluates to 2GB - 1
#define FLATBUFFERS_MAX_BUFFER_SIZE ((1ULL << (sizeof(::flatbuffers::soffset_t) * 8 - 1)) - 1)
+// The minimum size buffer that can be a valid flatbuffer.
+// Includes the offset to the root table (uoffset_t), the offset to the vtable
+// of the root table (soffset_t), the size of the vtable (uint16_t), and the
+// size of the referring table (uint16_t).
+#define FLATBUFFERS_MIN_BUFFER_SIZE sizeof(uoffset_t) + sizeof(soffset_t) + \
+ sizeof(uint16_t) + sizeof(uint16_t)
+
// We support aligning the contents of buffers up to this size.
-#define FLATBUFFERS_MAX_ALIGNMENT 16
+#ifndef FLATBUFFERS_MAX_ALIGNMENT
+ #define FLATBUFFERS_MAX_ALIGNMENT 32
+#endif
/// @brief The length of a FlatBuffer file header.
static const size_t kFileIdentifierLength = 4;
@@ -401,7 +413,7 @@
template<typename T>
// UBSAN: C++ aliasing type rules, see std::bit_cast<> for details.
-__supress_ubsan__("alignment")
+__suppress_ubsan__("alignment")
T ReadScalar(const void *p) {
return EndianScalar(*reinterpret_cast<const T *>(p));
}
@@ -415,13 +427,13 @@
template<typename T>
// UBSAN: C++ aliasing type rules, see std::bit_cast<> for details.
-__supress_ubsan__("alignment")
+__suppress_ubsan__("alignment")
void WriteScalar(void *p, T t) {
*reinterpret_cast<T *>(p) = EndianScalar(t);
}
template<typename T> struct Offset;
-template<typename T> __supress_ubsan__("alignment") void WriteScalar(void *p, Offset<T> t) {
+template<typename T> __suppress_ubsan__("alignment") void WriteScalar(void *p, Offset<T> t) {
*reinterpret_cast<uoffset_t *>(p) = EndianScalar(t.o);
}
@@ -432,7 +444,7 @@
// Computes how many bytes you'd have to pad to be able to write an
// "scalar_size" scalar if the buffer had grown to "buf_size" (downwards in
// memory).
-__supress_ubsan__("unsigned-integer-overflow")
+__suppress_ubsan__("unsigned-integer-overflow")
inline size_t PaddingBytes(size_t buf_size, size_t scalar_size) {
return ((~buf_size) + 1) & (scalar_size - 1);
}
diff --git a/include/flatbuffers/buffer.h b/include/flatbuffers/buffer.h
index e8d2ce9..ca005f7 100644
--- a/include/flatbuffers/buffer.h
+++ b/include/flatbuffers/buffer.h
@@ -95,7 +95,7 @@
}
};
-/// @brief Get a pointer to the the file_identifier section of the buffer.
+/// @brief Get a pointer to the file_identifier section of the buffer.
/// @return Returns a const char pointer to the start of the file_identifier
/// characters in the buffer. The returned char * has length
/// 'flatbuffers::FlatBufferBuilder::kFileIdentifierLength'.
diff --git a/include/flatbuffers/code_generators.h b/include/flatbuffers/code_generators.h
index 71ad0df..7275521 100644
--- a/include/flatbuffers/code_generators.h
+++ b/include/flatbuffers/code_generators.h
@@ -138,7 +138,8 @@
std::string WrapInNameSpace(const Namespace *ns,
const std::string &name) const;
- std::string WrapInNameSpace(const Definition &def) const;
+ std::string WrapInNameSpace(const Definition &def,
+ const std::string &suffix = "") const;
std::string GetNameSpace(const Definition &def) const;
diff --git a/include/flatbuffers/flatbuffer_builder.h b/include/flatbuffers/flatbuffer_builder.h
index 9994193..f943233 100644
--- a/include/flatbuffers/flatbuffer_builder.h
+++ b/include/flatbuffers/flatbuffer_builder.h
@@ -18,6 +18,7 @@
#define FLATBUFFERS_FLATBUFFER_BUILDER_H_
#include <functional>
+#include <initializer_list>
#include "flatbuffers/allocator.h"
#include "flatbuffers/array.h"
@@ -357,7 +358,7 @@
// If you get this assert, a corresponding StartTable wasn't called.
FLATBUFFERS_ASSERT(nested);
// Write the vtable offset, which is the start of any Table.
- // We fill it's value later.
+ // We fill its value later.
auto vtableoffsetloc = PushElement<soffset_t>(0);
// Write a vtable, which consists entirely of voffset_t elements.
// It starts with the number of offsets, followed by a type id, followed
@@ -442,6 +443,7 @@
// Aligns such that when "len" bytes are written, an object can be written
// after it with "alignment" without padding.
void PreAlign(size_t len, size_t alignment) {
+ if (len == 0) return;
TrackMinAlign(alignment);
buf_.fill(PaddingBytes(GetSize() + len, alignment));
}
@@ -577,7 +579,7 @@
/// @param[in] str A const pointer to a `String` struct to add to the buffer.
/// @return Returns the offset in the buffer where the string starts
Offset<String> CreateSharedString(const String *str) {
- return CreateSharedString(str->c_str(), str->size());
+ return str ? CreateSharedString(str->c_str(), str->size()) : 0;
}
/// @cond FLATBUFFERS_INTERNAL
@@ -600,12 +602,14 @@
// This is useful when storing a nested_flatbuffer in a vector of bytes,
// or when storing SIMD floats, etc.
void ForceVectorAlignment(size_t len, size_t elemsize, size_t alignment) {
+ if (len == 0) return;
FLATBUFFERS_ASSERT(VerifyAlignmentRequirements(alignment));
PreAlign(len * elemsize, alignment);
}
// Similar to ForceVectorAlignment but for String fields.
void ForceStringAlignment(size_t len, size_t alignment) {
+ if (len == 0) return;
FLATBUFFERS_ASSERT(VerifyAlignmentRequirements(alignment));
PreAlign((len + 1) * sizeof(char), alignment);
}
@@ -652,6 +656,16 @@
return CreateVector(array.data(), array.size());
}
+ /// @brief Serialize an initializer list into a FlatBuffer `vector`.
+ /// @tparam T The data type of the initializer list elements.
+ /// @param[in] v The value of the initializer list.
+ /// @return Returns a typed `Offset` into the serialized data indicating
+ /// where the vector is stored.
+ template<typename T>
+ Offset<Vector<T>> CreateVector(std::initializer_list<T> v) {
+ return CreateVector(v.begin(), v.size());
+ }
+
template<typename T>
Offset<Vector<Offset<T>>> CreateVector(const Offset<T> *v, size_t len) {
StartVector(len, sizeof(Offset<T>));
@@ -716,21 +730,24 @@
return CreateVector(elems);
}
- /// @brief Serialize a `std::vector<std::string>` into a FlatBuffer `vector`.
+ /// @brief Serialize a `std::vector<StringType>` into a FlatBuffer `vector`.
+ /// whereas StringType is any type that is accepted by the CreateString()
+ /// overloads.
/// This is a convenience function for a common case.
/// @param v A const reference to the `std::vector` to serialize into the
/// buffer as a `vector`.
/// @return Returns a typed `Offset` into the serialized data indicating
/// where the vector is stored.
- template<typename Alloc = std::allocator<std::string>>
+ template<typename StringType = std::string,
+ typename Alloc = std::allocator<StringType>>
Offset<Vector<Offset<String>>> CreateVectorOfStrings(
- const std::vector<std::string, Alloc> &v) {
+ const std::vector<StringType, Alloc> &v) {
return CreateVectorOfStrings(v.cbegin(), v.cend());
}
/// @brief Serialize a collection of Strings into a FlatBuffer `vector`.
/// This is a convenience function for a common case.
- /// @param begin The begining iterator of the collection
+ /// @param begin The beginning iterator of the collection
/// @param end The ending iterator of the collection
/// @return Returns a typed `Offset` into the serialized data indicating
/// where the vector is stored.
@@ -740,7 +757,7 @@
auto scratch_buffer_usage = size * sizeof(Offset<String>);
// If there is not enough space to store the offsets, there definitely won't
// be enough space to store all the strings. So ensuring space for the
- // scratch region is OK, for it it fails, it would have failed later.
+ // scratch region is OK, for if it fails, it would have failed later.
buf_.ensure_space(scratch_buffer_usage);
for (auto it = begin; it != end; ++it) {
buf_.scratch_push_small(CreateString(*it));
diff --git a/include/flatbuffers/flatc.h b/include/flatbuffers/flatc.h
index 3dba5e1..af4ccae 100644
--- a/include/flatbuffers/flatc.h
+++ b/include/flatbuffers/flatc.h
@@ -103,6 +103,11 @@
void Error(const std::string &err, bool usage = true,
bool show_exe_name = true) const;
+ void AnnotateBinaries(const uint8_t *binary_schema,
+ uint64_t binary_schema_size,
+ const std::string & schema_filename,
+ const std::vector<std::string> &binary_files);
+
InitParams params_;
};
diff --git a/include/flatbuffers/flex_flat_util.h b/include/flatbuffers/flex_flat_util.h
new file mode 100644
index 0000000..020957e
--- /dev/null
+++ b/include/flatbuffers/flex_flat_util.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2022 Google Inc. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FLATBUFFERS_FLEX_FLAT_UTIL_H_
+#define FLATBUFFERS_FLEX_FLAT_UTIL_H_
+
+#include "flatbuffers/flatbuffers.h"
+#include "flatbuffers/flexbuffers.h"
+
+namespace flexbuffers {
+
+// Verifies the `nested` flexbuffer within a flatbuffer vector is valid.
+inline bool VerifyNestedFlexBuffer(
+ const flatbuffers::Vector<uint8_t> *const nested,
+ flatbuffers::Verifier &verifier) {
+ if (!nested) return true;
+ return verifier.Check(flexbuffers::VerifyBuffer(
+ nested->data(), nested->size(), verifier.GetFlexReuseTracker()));
+}
+
+} // namespace flexbuffers
+
+#endif // FLATBUFFERS_FLEX_FLAT_UTIL_H_
diff --git a/include/flatbuffers/flexbuffers.h b/include/flatbuffers/flexbuffers.h
index b4b0332..7bf8430 100644
--- a/include/flatbuffers/flexbuffers.h
+++ b/include/flatbuffers/flexbuffers.h
@@ -156,6 +156,7 @@
// TODO: GCC apparently replaces memcpy by a rep movsb, but only if count is a
// constant, which here it isn't. Test if memcpy is still faster than
// the conditionals in ReadSizedScalar. Can also use inline asm.
+
// clang-format off
#if defined(_MSC_VER) && defined(_M_X64) && !defined(_M_ARM64EC)
// This is 64-bit Windows only, __movsb does not work on 32-bit Windows.
@@ -578,7 +579,7 @@
// unquoted if it looks like an "identifier":
const char *p = keys[i].AsKey();
if (!flatbuffers::is_alpha(*p) && *p != '_') {
- kq = true;
+ kq = true;
} else {
while (*++p) {
if (!flatbuffers::is_alnum(*p) && *p != '_') {
@@ -1422,10 +1423,12 @@
template<typename T> static Type GetScalarType() {
static_assert(flatbuffers::is_scalar<T>::value, "Unrelated types");
- return flatbuffers::is_floating_point<T>::value ? FBT_FLOAT
- : flatbuffers::is_same<T, bool>::value
- ? FBT_BOOL
- : (flatbuffers::is_unsigned<T>::value ? FBT_UINT : FBT_INT);
+ return flatbuffers::is_floating_point<T>::value
+ ? FBT_FLOAT
+ : flatbuffers::is_same<T, bool>::value
+ ? FBT_BOOL
+ : (flatbuffers::is_unsigned<T>::value ? FBT_UINT
+ : FBT_INT);
}
public:
@@ -1737,9 +1740,9 @@
if (!Check(depth_ <= max_depth_ && num_vectors_ <= max_vectors_))
return false;
auto size_byte_width = r.byte_width_;
- FLEX_CHECK_VERIFIED(p,
- PackedType(Builder::WidthB(size_byte_width), r.type_));
if (!VerifyBeforePointer(p, size_byte_width)) return false;
+ FLEX_CHECK_VERIFIED(p - size_byte_width,
+ PackedType(Builder::WidthB(size_byte_width), r.type_));
auto sized = Sized(p, size_byte_width);
auto num_elems = sized.size();
auto elem_byte_width = r.type_ == FBT_STRING || r.type_ == FBT_BLOB
@@ -1868,7 +1871,7 @@
std::vector<uint8_t> *reuse_tracker_;
};
-// Utility function that contructs the Verifier for you, see above for
+// Utility function that constructs the Verifier for you, see above for
// parameters.
inline bool VerifyBuffer(const uint8_t *buf, size_t buf_len,
std::vector<uint8_t> *reuse_tracker = nullptr) {
@@ -1876,18 +1879,6 @@
return verifier.VerifyBuffer();
}
-#ifdef FLATBUFFERS_H_
-// This is a verifier utility function that works together with the
-// FlatBuffers verifier, which should only be present if flatbuffer.h
-// has been included (which it typically is in generated code).
-inline bool VerifyNestedFlexBuffer(const flatbuffers::Vector<uint8_t> *nv,
- flatbuffers::Verifier &verifier) {
- if (!nv) return true;
- return verifier.Check(flexbuffers::VerifyBuffer(
- nv->data(), nv->size(), verifier.GetFlexReuseTracker()));
-}
-#endif
-
} // namespace flexbuffers
#if defined(_MSC_VER)
diff --git a/include/flatbuffers/idl.h b/include/flatbuffers/idl.h
index 260061f..4cfd7eb 100644
--- a/include/flatbuffers/idl.h
+++ b/include/flatbuffers/idl.h
@@ -164,7 +164,7 @@
enum_def(_ed),
fixed_length(_fixed_length) {}
- bool operator==(const Type &o) {
+ bool operator==(const Type &o) const {
return base_type == o.base_type && element == o.element &&
struct_def == o.struct_def && enum_def == o.enum_def;
}
@@ -295,7 +295,7 @@
native_inline(false),
flexbuffer(false),
presence(kDefault),
- nested_flatbuffer(NULL),
+ nested_flatbuffer(nullptr),
padding(0) {}
Offset<reflection::Field> Serialize(FlatBufferBuilder *builder, uint16_t id,
@@ -464,6 +464,10 @@
return type.base_type == BASE_TYPE_STRUCT && type.struct_def->fixed;
}
+inline bool IsTable(const Type &type) {
+ return type.base_type == BASE_TYPE_STRUCT && !type.struct_def->fixed;
+}
+
inline bool IsUnion(const Type &type) {
return type.enum_def != nullptr && type.enum_def->is_union;
}
@@ -476,6 +480,14 @@
return type.base_type == BASE_TYPE_VECTOR;
}
+inline bool IsVectorOfStruct(const Type& type) {
+ return IsVector(type) && IsStruct(type.VectorType());
+}
+
+inline bool IsVectorOfTable(const Type& type) {
+ return IsVector(type) && IsTable(type.VectorType());
+}
+
inline bool IsArray(const Type &type) {
return type.base_type == BASE_TYPE_ARRAY;
}
@@ -537,6 +549,24 @@
SymbolTable<RPCCall> calls;
};
+struct IncludedFile {
+ // The name of the schema file being included, as defined in the .fbs file.
+ // This includes the prefix (e.g., include "foo/bar/baz.fbs" would mean this
+ // value is "foo/bar/baz.fbs").
+ std::string schema_name;
+
+ // The filename of where the included file was found, after searching the
+ // relative paths plus any other paths included with `flatc -I ...`. Note,
+ // while this is sometimes the same as schema_name, it is not always, since it
+ // can be defined relative to where flatc was invoked.
+ std::string filename;
+};
+
+// Since IncludedFile is contained within a std::set, need to provide ordering.
+inline bool operator<(const IncludedFile &a, const IncludedFile &b) {
+ return a.filename < b.filename;
+}
+
// Container of options that may apply to any of the source/text generators.
struct IDLOptions {
// field case style options for C++
@@ -551,6 +581,7 @@
bool output_enum_identifiers;
bool prefixed_enums;
bool scoped_enums;
+ bool swift_implementation_only;
bool include_dependence_headers;
bool mutable_buffer;
bool one_file;
@@ -576,7 +607,7 @@
bool allow_non_utf8;
bool natural_utf8;
std::string include_prefix;
- bool keep_include_path;
+ bool keep_prefix;
bool binary_schema_comments;
bool binary_schema_builtins;
bool binary_schema_gen_embed;
@@ -602,6 +633,7 @@
bool json_nested_flexbuffers;
bool json_nested_legacy_flatbuffers;
bool ts_flat_file;
+ bool no_leak_private_annotations;
// Possible options for the more general generator below.
enum Language {
@@ -658,6 +690,7 @@
output_enum_identifiers(true),
prefixed_enums(true),
scoped_enums(false),
+ swift_implementation_only(false),
include_dependence_headers(true),
mutable_buffer(false),
one_file(false),
@@ -680,7 +713,7 @@
union_value_namespacing(true),
allow_non_utf8(false),
natural_utf8(false),
- keep_include_path(false),
+ keep_prefix(false),
binary_schema_comments(false),
binary_schema_builtins(false),
binary_schema_gen_embed(false),
@@ -700,6 +733,7 @@
json_nested_flexbuffers(true),
json_nested_legacy_flatbuffers(false),
ts_flat_file(false),
+ no_leak_private_annotations(false),
mini_reflect(IDLOptions::kNone),
require_explicit_ids(false),
rust_serialize(false),
@@ -907,6 +941,11 @@
// @param opts Options used to parce a schema and generate code.
static bool SupportsOptionalScalars(const flatbuffers::IDLOptions &opts);
+ // Get the set of included files that are directly referenced by the file
+ // being parsed. This does not include files that are transitively included by
+ // others includes.
+ std::vector<IncludedFile> GetIncludedFiles() const;
+
private:
class ParseDepthGuard;
@@ -991,6 +1030,9 @@
FLATBUFFERS_CHECKED_ERROR ParseRoot(const char *_source,
const char **include_paths,
const char *source_filename);
+ FLATBUFFERS_CHECKED_ERROR CheckPrivateLeak();
+ FLATBUFFERS_CHECKED_ERROR CheckPrivatelyLeakedFields(
+ const Definition &def, const Definition &value_type);
FLATBUFFERS_CHECKED_ERROR DoParse(const char *_source,
const char **include_paths,
const char *source_filename,
@@ -1031,7 +1073,7 @@
std::string file_extension_;
std::map<uint64_t, std::string> included_files_;
- std::map<std::string, std::set<std::string>> files_included_per_file_;
+ std::map<std::string, std::set<IncludedFile>> files_included_per_file_;
std::vector<std::string> native_included_files_;
std::map<std::string, bool> known_attributes_;
@@ -1042,11 +1084,11 @@
uint64_t advanced_features_;
+ std::string file_being_parsed_;
+
private:
const char *source_;
- std::string file_being_parsed_;
-
std::vector<std::pair<Value, FieldDef *>> field_stack_;
// TODO(cneo): Refactor parser to use string_cache more often to save
diff --git a/include/flatbuffers/reflection.h b/include/flatbuffers/reflection.h
index 8e700f0..e445d79 100644
--- a/include/flatbuffers/reflection.h
+++ b/include/flatbuffers/reflection.h
@@ -88,13 +88,22 @@
}
// Get the root, regardless of what type it is.
-inline Table *GetAnyRoot(uint8_t *flatbuf) {
+inline Table *GetAnyRoot(uint8_t *const flatbuf) {
return GetMutableRoot<Table>(flatbuf);
}
-inline const Table *GetAnyRoot(const uint8_t *flatbuf) {
+
+inline const Table *GetAnyRoot(const uint8_t *const flatbuf) {
return GetRoot<Table>(flatbuf);
}
+inline Table *GetAnySizePrefixedRoot(uint8_t *const flatbuf) {
+ return GetMutableSizePrefixedRoot<Table>(flatbuf);
+}
+
+inline const Table *GetAnySizePrefixedRoot(const uint8_t *const flatbuf) {
+ return GetSizePrefixedRoot<Table>(flatbuf);
+}
+
// Get a field's default, if you know it's an integer, and its exact type.
template<typename T> T GetFieldDefaultI(const reflection::Field &field) {
FLATBUFFERS_ASSERT(sizeof(T) == GetTypeSize(field.type()->base_type()));
@@ -279,6 +288,12 @@
return reinterpret_cast<T *>(st.GetAddressOf(field.offset()));
}
+// Loop over all the fields of the provided `object` and call `func` on each one
+// in increasing order by their field->id(). If `reverse` is true, `func` is
+// called in descending order
+void ForAllFields(const reflection::Object *object, bool reverse,
+ std::function<void(const reflection::Field *)> func);
+
// ------------------------- SETTERS -------------------------
// Set any scalar field, if you know its exact type.
@@ -497,6 +512,11 @@
const uint8_t *buf, size_t length, uoffset_t max_depth = 64,
uoffset_t max_tables = 1000000);
+bool VerifySizePrefixed(const reflection::Schema &schema,
+ const reflection::Object &root, const uint8_t *buf,
+ size_t length, uoffset_t max_depth = 64,
+ uoffset_t max_tables = 1000000);
+
} // namespace flatbuffers
#endif // FLATBUFFERS_REFLECTION_H_
diff --git a/include/flatbuffers/reflection_generated.h b/include/flatbuffers/reflection_generated.h
index dcb0f7e..78674db 100644
--- a/include/flatbuffers/reflection_generated.h
+++ b/include/flatbuffers/reflection_generated.h
@@ -6,6 +6,13 @@
#include "flatbuffers/flatbuffers.h"
+// Ensure the included flatbuffers.h is the same version as when this file was
+// generated, otherwise it may not be compatible.
+static_assert(FLATBUFFERS_VERSION_MAJOR == 2 &&
+ FLATBUFFERS_VERSION_MINOR == 0 &&
+ FLATBUFFERS_VERSION_REVISION == 8,
+ "Non-compatible flatbuffers version included");
+
namespace reflection {
struct Type;
diff --git a/include/flatbuffers/stl_emulation.h b/include/flatbuffers/stl_emulation.h
index 75d13b2..452ddb8 100644
--- a/include/flatbuffers/stl_emulation.h
+++ b/include/flatbuffers/stl_emulation.h
@@ -26,22 +26,27 @@
#include <memory>
#include <limits>
-// Detect C++17 compatible compiler.
-// __cplusplus >= 201703L - a compiler has support of 'static inline' variables.
-#if defined(FLATBUFFERS_USE_STD_OPTIONAL) \
- || (defined(__cplusplus) && __cplusplus >= 201703L) \
- || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L))
+#ifndef FLATBUFFERS_USE_STD_OPTIONAL
+ // Detect C++17 compatible compiler.
+ // __cplusplus >= 201703L - a compiler has support of 'static inline' variables.
+ #if (defined(__cplusplus) && __cplusplus >= 201703L) \
+ || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
+ #define FLATBUFFERS_USE_STD_OPTIONAL 1
+ #else
+ #define FLATBUFFERS_USE_STD_OPTIONAL 0
+ #endif // (defined(__cplusplus) && __cplusplus >= 201703L) ...
+#endif // FLATBUFFERS_USE_STD_OPTIONAL
+
+#if FLATBUFFERS_USE_STD_OPTIONAL
#include <optional>
- #ifndef FLATBUFFERS_USE_STD_OPTIONAL
- #define FLATBUFFERS_USE_STD_OPTIONAL
- #endif
-#endif // defined(FLATBUFFERS_USE_STD_OPTIONAL) ...
+#endif
// The __cpp_lib_span is the predefined feature macro.
#if defined(FLATBUFFERS_USE_STD_SPAN)
#include <span>
#elif defined(__cpp_lib_span) && defined(__has_include)
#if __has_include(<span>)
+ #include <array>
#include <span>
#define FLATBUFFERS_USE_STD_SPAN
#endif
@@ -128,7 +133,7 @@
};
#endif // defined(FLATBUFFERS_TEMPLATES_ALIASES)
-#ifdef FLATBUFFERS_USE_STD_OPTIONAL
+#if FLATBUFFERS_USE_STD_OPTIONAL
template<class T>
using Optional = std::optional<T>;
using nullopt_t = std::nullopt_t;
@@ -284,13 +289,13 @@
namespace internal {
// This is SFINAE helper class for checking of a common condition:
// > This overload only participates in overload resolution
- // > Check whether a pointer to an array of U can be converted
- // > to a pointer to an array of E.
- // This helper is used for checking of 'U -> const U'.
- template<class E, std::size_t Extent, class U, std::size_t N>
- struct is_span_convertable {
+ // > Check whether a pointer to an array of From can be converted
+ // > to a pointer to an array of To.
+ // This helper is used for checking of 'From -> const From'.
+ template<class To, std::size_t Extent, class From, std::size_t N>
+ struct is_span_convertible {
using type =
- typename std::conditional<std::is_convertible<U (*)[], E (*)[]>::value
+ typename std::conditional<std::is_convertible<From (*)[], To (*)[]>::value
&& (Extent == dynamic_extent || N == Extent),
int, void>::type;
};
@@ -362,13 +367,9 @@
#if !defined(FLATBUFFERS_SPAN_MINIMAL)
using Iterator = internal::SpanIterator<T>;
- using ConstIterator = internal::SpanIterator<const T>;
Iterator begin() const { return Iterator(data()); }
Iterator end() const { return Iterator(data() + size()); }
-
- ConstIterator cbegin() const { return ConstIterator(data()); }
- ConstIterator cend() const { return ConstIterator(data() + size()); }
#endif
// Returns a reference to the idx-th element of the sequence.
@@ -414,7 +415,7 @@
// extent == 0 || extent == flatbuffers::dynamic_extent.
// A dummy template argument N is need dependency for SFINAE.
template<std::size_t N = 0,
- typename internal::is_span_convertable<element_type, Extent, element_type, (N - N)>::type = 0>
+ typename internal::is_span_convertible<element_type, Extent, element_type, (N - N)>::type = 0>
FLATBUFFERS_CONSTEXPR_CPP11 span() FLATBUFFERS_NOEXCEPT : data_(nullptr),
count_(0) {
static_assert(extent == 0 || extent == dynamic_extent, "invalid span");
@@ -427,12 +428,12 @@
// std::remove_pointer_t<decltype(std::data(arr))>(*)[]
// is convertible to element_type (*)[].
template<std::size_t N,
- typename internal::is_span_convertable<element_type, Extent, element_type, N>::type = 0>
+ typename internal::is_span_convertible<element_type, Extent, element_type, N>::type = 0>
FLATBUFFERS_CONSTEXPR_CPP11 span(element_type (&arr)[N]) FLATBUFFERS_NOEXCEPT
: data_(arr), count_(N) {}
template<class U, std::size_t N,
- typename internal::is_span_convertable<element_type, Extent, U, N>::type = 0>
+ typename internal::is_span_convertible<element_type, Extent, U, N>::type = 0>
FLATBUFFERS_CONSTEXPR_CPP11 span(std::array<U, N> &arr) FLATBUFFERS_NOEXCEPT
: data_(arr.data()), count_(N) {}
@@ -442,7 +443,7 @@
// : data_(arr.data()), count_(N) {}
template<class U, std::size_t N,
- typename internal::is_span_convertable<element_type, Extent, U, N>::type = 0>
+ typename internal::is_span_convertible<element_type, Extent, U, N>::type = 0>
FLATBUFFERS_CONSTEXPR_CPP11 span(const std::array<U, N> &arr) FLATBUFFERS_NOEXCEPT
: data_(arr.data()), count_(N) {}
@@ -452,7 +453,7 @@
// if extent == std::dynamic_extent || N == extent is true and U (*)[]
// is convertible to element_type (*)[].
template<class U, std::size_t N,
- typename internal::is_span_convertable<element_type, Extent, U, N>::type = 0>
+ typename internal::is_span_convertible<element_type, Extent, U, N>::type = 0>
FLATBUFFERS_CONSTEXPR_CPP11 span(const flatbuffers::span<U, N> &s) FLATBUFFERS_NOEXCEPT
: span(s.data(), s.size()) {
}
@@ -462,45 +463,45 @@
private:
// This is a naive implementation with 'count_' member even if (Extent != dynamic_extent).
pointer const data_;
- const size_type count_;
+ size_type count_;
};
#endif // defined(FLATBUFFERS_USE_STD_SPAN)
#if !defined(FLATBUFFERS_SPAN_MINIMAL)
-template<class U, std::size_t N>
+template<class ElementType, std::size_t Extent>
FLATBUFFERS_CONSTEXPR_CPP11
-flatbuffers::span<U, N> make_span(U(&arr)[N]) FLATBUFFERS_NOEXCEPT {
- return span<U, N>(arr);
+flatbuffers::span<ElementType, Extent> make_span(ElementType(&arr)[Extent]) FLATBUFFERS_NOEXCEPT {
+ return span<ElementType, Extent>(arr);
}
-template<class U, std::size_t N>
+template<class ElementType, std::size_t Extent>
FLATBUFFERS_CONSTEXPR_CPP11
-flatbuffers::span<const U, N> make_span(const U(&arr)[N]) FLATBUFFERS_NOEXCEPT {
- return span<const U, N>(arr);
+flatbuffers::span<const ElementType, Extent> make_span(const ElementType(&arr)[Extent]) FLATBUFFERS_NOEXCEPT {
+ return span<const ElementType, Extent>(arr);
}
-template<class U, std::size_t N>
+template<class ElementType, std::size_t Extent>
FLATBUFFERS_CONSTEXPR_CPP11
-flatbuffers::span<U, N> make_span(std::array<U, N> &arr) FLATBUFFERS_NOEXCEPT {
- return span<U, N>(arr);
+flatbuffers::span<ElementType, Extent> make_span(std::array<ElementType, Extent> &arr) FLATBUFFERS_NOEXCEPT {
+ return span<ElementType, Extent>(arr);
}
-template<class U, std::size_t N>
+template<class ElementType, std::size_t Extent>
FLATBUFFERS_CONSTEXPR_CPP11
-flatbuffers::span<const U, N> make_span(const std::array<U, N> &arr) FLATBUFFERS_NOEXCEPT {
- return span<const U, N>(arr);
+flatbuffers::span<const ElementType, Extent> make_span(const std::array<ElementType, Extent> &arr) FLATBUFFERS_NOEXCEPT {
+ return span<const ElementType, Extent>(arr);
}
-template<class U, std::size_t N>
+template<class ElementType, std::size_t Extent>
FLATBUFFERS_CONSTEXPR_CPP11
-flatbuffers::span<U, dynamic_extent> make_span(U *first, std::size_t count) FLATBUFFERS_NOEXCEPT {
- return span<U, dynamic_extent>(first, count);
+flatbuffers::span<ElementType, dynamic_extent> make_span(ElementType *first, std::size_t count) FLATBUFFERS_NOEXCEPT {
+ return span<ElementType, dynamic_extent>(first, count);
}
-template<class U, std::size_t N>
+template<class ElementType, std::size_t Extent>
FLATBUFFERS_CONSTEXPR_CPP11
-flatbuffers::span<const U, dynamic_extent> make_span(const U *first, std::size_t count) FLATBUFFERS_NOEXCEPT {
- return span<const U, dynamic_extent>(first, count);
+flatbuffers::span<const ElementType, dynamic_extent> make_span(const ElementType *first, std::size_t count) FLATBUFFERS_NOEXCEPT {
+ return span<const ElementType, dynamic_extent>(first, count);
}
#endif // !defined(FLATBUFFERS_SPAN_MINIMAL)
diff --git a/include/flatbuffers/util.h b/include/flatbuffers/util.h
index 2e0ce73..73a3ab7 100644
--- a/include/flatbuffers/util.h
+++ b/include/flatbuffers/util.h
@@ -255,7 +255,7 @@
}
// UBSAN: double to float is safe if numeric_limits<float>::is_iec559 is true.
-__supress_ubsan__("float-cast-overflow")
+__suppress_ubsan__("float-cast-overflow")
inline void strtoval_impl(float *val, const char *str, char **endptr) {
*val = __strtof_impl(str, endptr);
}
@@ -448,6 +448,9 @@
// Strip the last component of the path + separator.
std::string StripFileName(const std::string &filepath);
+std::string StripPrefix(const std::string &filepath,
+ const std::string &prefix_to_remove);
+
// Concatenates a path with a filename, regardless of whether the path
// ends in a separator or not.
std::string ConCatPathFileName(const std::string &path,
@@ -682,9 +685,6 @@
bool ReadEnvironmentVariable(const char *var_name,
std::string *_value = nullptr);
-// MSVC specific: Send all assert reports to STDOUT to prevent CI hangs.
-void SetupDefaultCRTReportMode();
-
enum class Case {
kUnknown = 0,
// TheQuickBrownFox
@@ -703,6 +703,8 @@
kDasher = 7,
// THEQuiCKBr_ownFox (or whatever you want, we won't change it)
kKeep = 8,
+ // the_quick_brown_fox123 (as opposed to the_quick_brown_fox_123)
+ kSnake2 = 9,
};
// Convert the `input` string of case `input_case` to the specified `output_case`.
diff --git a/include/flatbuffers/vector.h b/include/flatbuffers/vector.h
index f8a5d88..6bcdfe2 100644
--- a/include/flatbuffers/vector.h
+++ b/include/flatbuffers/vector.h
@@ -19,6 +19,7 @@
#include "flatbuffers/base.h"
#include "flatbuffers/buffer.h"
+#include "flatbuffers/stl_emulation.h"
namespace flatbuffers {
@@ -326,6 +327,24 @@
return span<const uint8_t>(vec.Data(), vec.size() * sizeof(U));
}
+// Convenient helper functions to get a span of any vector, regardless
+// of whether it is null or not (the field is not set).
+template<class U>
+FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<U> make_span(Vector<U> *ptr)
+ FLATBUFFERS_NOEXCEPT {
+ static_assert(Vector<U>::is_span_observable,
+ "wrong type U, only LE-scalar, or byte types are allowed");
+ return ptr ? make_span(*ptr) : span<U>();
+}
+
+template<class U>
+FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<const U> make_span(
+ const Vector<U> *ptr) FLATBUFFERS_NOEXCEPT {
+ static_assert(Vector<U>::is_span_observable,
+ "wrong type U, only LE-scalar, or byte types are allowed");
+ return ptr ? make_span(*ptr) : span<const U>();
+}
+
// Represent a vector much like the template above, but in this case we
// don't know what the element types are (used with reflection.h).
class VectorOfAny {
diff --git a/include/flatbuffers/vector_downward.h b/include/flatbuffers/vector_downward.h
index 3391391..d25e544 100644
--- a/include/flatbuffers/vector_downward.h
+++ b/include/flatbuffers/vector_downward.h
@@ -24,7 +24,7 @@
namespace flatbuffers {
// This is a minimal replication of std::vector<uint8_t> functionality,
-// except growing from higher to lower addresses. i.e push_back() inserts data
+// except growing from higher to lower addresses. i.e. push_back() inserts data
// in the lowest address in the vector.
// Since this vector leaves the lower part unused, we support a "scratch-pad"
// that can be stored there for temporary data, to share the allocated space.
diff --git a/include/flatbuffers/verifier.h b/include/flatbuffers/verifier.h
index 4512d45..87d3f54 100644
--- a/include/flatbuffers/verifier.h
+++ b/include/flatbuffers/verifier.h
@@ -18,7 +18,6 @@
#define FLATBUFFERS_VERIFIER_H_
#include "flatbuffers/base.h"
-#include "flatbuffers/util.h"
#include "flatbuffers/vector.h"
namespace flatbuffers {
@@ -26,22 +25,37 @@
// Helper class to verify the integrity of a FlatBuffer
class Verifier FLATBUFFERS_FINAL_CLASS {
public:
- Verifier(const uint8_t *buf, size_t buf_len, uoffset_t _max_depth = 64,
- uoffset_t _max_tables = 1000000, bool _check_alignment = true)
- : buf_(buf),
- size_(buf_len),
- depth_(0),
- max_depth_(_max_depth),
- num_tables_(0),
- max_tables_(_max_tables),
- upper_bound_(0),
- check_alignment_(_check_alignment),
- flex_reuse_tracker_(nullptr) {
+ struct Options {
+ // The maximum nesting of tables and vectors before we call it invalid.
+ uoffset_t max_depth = 64;
+ // The maximum number of tables we will verify before we call it invalid.
+ uoffset_t max_tables = 1000000;
+ // If true, verify all data is aligned.
+ bool check_alignment = true;
+ // If true, run verifier on nested flatbuffers
+ bool check_nested_flatbuffers = true;
+ };
+
+ explicit Verifier(const uint8_t *const buf, const size_t buf_len,
+ const Options &opts)
+ : buf_(buf), size_(buf_len), opts_(opts) {
FLATBUFFERS_ASSERT(size_ < FLATBUFFERS_MAX_BUFFER_SIZE);
}
+ // Deprecated API, please construct with Verifier::Options.
+ Verifier(const uint8_t *const buf, const size_t buf_len,
+ const uoffset_t max_depth = 64, const uoffset_t max_tables = 1000000,
+ const bool check_alignment = true)
+ : Verifier(buf, buf_len, [&] {
+ Options opts;
+ opts.max_depth = max_depth;
+ opts.max_tables = max_tables;
+ opts.check_alignment = check_alignment;
+ return opts;
+ }()) {}
+
// Central location where any verification failures register.
- bool Check(bool ok) const {
+ bool Check(const bool ok) const {
// clang-format off
#ifdef FLATBUFFERS_DEBUG_VERIFICATION_FAILURE
FLATBUFFERS_ASSERT(ok);
@@ -55,7 +69,7 @@
}
// Verify any range within the buffer.
- bool Verify(size_t elem, size_t elem_len) const {
+ bool Verify(const size_t elem, const size_t elem_len) const {
// clang-format off
#ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
auto upper_bound = elem + elem_len;
@@ -66,52 +80,52 @@
return Check(elem_len < size_ && elem <= size_ - elem_len);
}
- bool VerifyAlignment(size_t elem, size_t align) const {
- return Check((elem & (align - 1)) == 0 || !check_alignment_);
+ bool VerifyAlignment(const size_t elem, const size_t align) const {
+ return Check((elem & (align - 1)) == 0 || !opts_.check_alignment);
}
// Verify a range indicated by sizeof(T).
- template<typename T> bool Verify(size_t elem) const {
+ template<typename T> bool Verify(const size_t elem) const {
return VerifyAlignment(elem, sizeof(T)) && Verify(elem, sizeof(T));
}
- bool VerifyFromPointer(const uint8_t *p, size_t len) {
- auto o = static_cast<size_t>(p - buf_);
- return Verify(o, len);
+ bool VerifyFromPointer(const uint8_t *const p, const size_t len) {
+ return Verify(static_cast<size_t>(p - buf_), len);
}
// Verify relative to a known-good base pointer.
- bool VerifyFieldStruct(const uint8_t *base, voffset_t elem_off,
- size_t elem_len, size_t align) const {
- auto f = static_cast<size_t>(base - buf_) + elem_off;
+ bool VerifyFieldStruct(const uint8_t *const base, const voffset_t elem_off,
+ const size_t elem_len, const size_t align) const {
+ const auto f = static_cast<size_t>(base - buf_) + elem_off;
return VerifyAlignment(f, align) && Verify(f, elem_len);
}
template<typename T>
- bool VerifyField(const uint8_t *base, voffset_t elem_off,
- size_t align) const {
- auto f = static_cast<size_t>(base - buf_) + elem_off;
+ bool VerifyField(const uint8_t *const base, const voffset_t elem_off,
+ const size_t align) const {
+ const auto f = static_cast<size_t>(base - buf_) + elem_off;
return VerifyAlignment(f, align) && Verify(f, sizeof(T));
}
// Verify a pointer (may be NULL) of a table type.
- template<typename T> bool VerifyTable(const T *table) {
+ template<typename T> bool VerifyTable(const T *const table) {
return !table || table->Verify(*this);
}
// Verify a pointer (may be NULL) of any vector type.
- template<typename T> bool VerifyVector(const Vector<T> *vec) const {
+ template<typename T> bool VerifyVector(const Vector<T> *const vec) const {
return !vec || VerifyVectorOrString(reinterpret_cast<const uint8_t *>(vec),
sizeof(T));
}
// Verify a pointer (may be NULL) of a vector to struct.
- template<typename T> bool VerifyVector(const Vector<const T *> *vec) const {
+ template<typename T>
+ bool VerifyVector(const Vector<const T *> *const vec) const {
return VerifyVector(reinterpret_cast<const Vector<T> *>(vec));
}
// Verify a pointer (may be NULL) to string.
- bool VerifyString(const String *str) const {
+ bool VerifyString(const String *const str) const {
size_t end;
return !str || (VerifyVectorOrString(reinterpret_cast<const uint8_t *>(str),
1, &end) &&
@@ -120,24 +134,24 @@
}
// Common code between vectors and strings.
- bool VerifyVectorOrString(const uint8_t *vec, size_t elem_size,
- size_t *end = nullptr) const {
- auto veco = static_cast<size_t>(vec - buf_);
+ bool VerifyVectorOrString(const uint8_t *const vec, const size_t elem_size,
+ size_t *const end = nullptr) const {
+ const auto veco = static_cast<size_t>(vec - buf_);
// Check we can read the size field.
if (!Verify<uoffset_t>(veco)) return false;
- // Check the whole array. If this is a string, the byte past the array
- // must be 0.
- auto size = ReadScalar<uoffset_t>(vec);
- auto max_elems = FLATBUFFERS_MAX_BUFFER_SIZE / elem_size;
+ // Check the whole array. If this is a string, the byte past the array must
+ // be 0.
+ const auto size = ReadScalar<uoffset_t>(vec);
+ const auto max_elems = FLATBUFFERS_MAX_BUFFER_SIZE / elem_size;
if (!Check(size < max_elems))
return false; // Protect against byte_size overflowing.
- auto byte_size = sizeof(size) + elem_size * size;
+ const auto byte_size = sizeof(size) + elem_size * size;
if (end) *end = veco + byte_size;
return Verify(veco, byte_size);
}
// Special case for string contents, after the above has been called.
- bool VerifyVectorOfStrings(const Vector<Offset<String>> *vec) const {
+ bool VerifyVectorOfStrings(const Vector<Offset<String>> *const vec) const {
if (vec) {
for (uoffset_t i = 0; i < vec->size(); i++) {
if (!VerifyString(vec->Get(i))) return false;
@@ -147,7 +161,8 @@
}
// Special case for table contents, after the above has been called.
- template<typename T> bool VerifyVectorOfTables(const Vector<Offset<T>> *vec) {
+ template<typename T>
+ bool VerifyVectorOfTables(const Vector<Offset<T>> *const vec) {
if (vec) {
for (uoffset_t i = 0; i < vec->size(); i++) {
if (!vec->Get(i)->Verify(*this)) return false;
@@ -156,31 +171,41 @@
return true;
}
- __supress_ubsan__("unsigned-integer-overflow") bool VerifyTableStart(
- const uint8_t *table) {
+ __suppress_ubsan__("unsigned-integer-overflow") bool VerifyTableStart(
+ const uint8_t *const table) {
// Check the vtable offset.
- auto tableo = static_cast<size_t>(table - buf_);
+ const auto tableo = static_cast<size_t>(table - buf_);
if (!Verify<soffset_t>(tableo)) return false;
// This offset may be signed, but doing the subtraction unsigned always
// gives the result we want.
- auto vtableo = tableo - static_cast<size_t>(ReadScalar<soffset_t>(table));
+ const auto vtableo =
+ tableo - static_cast<size_t>(ReadScalar<soffset_t>(table));
// Check the vtable size field, then check vtable fits in its entirety.
- return VerifyComplexity() && Verify<voffset_t>(vtableo) &&
- VerifyAlignment(ReadScalar<voffset_t>(buf_ + vtableo),
- sizeof(voffset_t)) &&
- Verify(vtableo, ReadScalar<voffset_t>(buf_ + vtableo));
+ if (!(VerifyComplexity() && Verify<voffset_t>(vtableo) &&
+ VerifyAlignment(ReadScalar<voffset_t>(buf_ + vtableo),
+ sizeof(voffset_t))))
+ return false;
+ const auto vsize = ReadScalar<voffset_t>(buf_ + vtableo);
+ return Check((vsize & 1) == 0) && Verify(vtableo, vsize);
}
template<typename T>
- bool VerifyBufferFromStart(const char *identifier, size_t start) {
+ bool VerifyBufferFromStart(const char *const identifier, const size_t start) {
+ // Buffers have to be of some size to be valid. The reason it is a runtime
+ // check instead of static_assert, is that nested flatbuffers go through
+ // this call and their size is determined at runtime.
+ if (!Check(size_ >= FLATBUFFERS_MIN_BUFFER_SIZE)) return false;
+
+ // If an identifier is provided, check that we have a buffer
if (identifier && !Check((size_ >= 2 * sizeof(flatbuffers::uoffset_t) &&
BufferHasIdentifier(buf_ + start, identifier)))) {
return false;
}
// Call T::Verify, which must be in the generated code for this type.
- auto o = VerifyOffset(start);
- return o && reinterpret_cast<const T *>(buf_ + start + o)->Verify(*this)
+ const auto o = VerifyOffset(start);
+ return Check(o != 0) &&
+ reinterpret_cast<const T *>(buf_ + start + o)->Verify(*this)
// clang-format off
#ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
&& GetComputedSize()
@@ -190,9 +215,17 @@
}
template<typename T>
- bool VerifyNestedFlatBuffer(const Vector<uint8_t> *buf,
- const char *identifier) {
+ bool VerifyNestedFlatBuffer(const Vector<uint8_t> *const buf,
+ const char *const identifier) {
+ // Caller opted out of this.
+ if (!opts_.check_nested_flatbuffers) return true;
+
+ // An empty buffer is OK as it indicates not present.
if (!buf) return true;
+
+ // If there is a nested buffer, it must be greater than the min size.
+ if (!Check(buf->size() >= FLATBUFFERS_MIN_BUFFER_SIZE)) return false;
+
Verifier nested_verifier(buf->data(), buf->size());
return nested_verifier.VerifyBuffer<T>(identifier);
}
@@ -200,19 +233,20 @@
// Verify this whole buffer, starting with root type T.
template<typename T> bool VerifyBuffer() { return VerifyBuffer<T>(nullptr); }
- template<typename T> bool VerifyBuffer(const char *identifier) {
+ template<typename T> bool VerifyBuffer(const char *const identifier) {
return VerifyBufferFromStart<T>(identifier, 0);
}
- template<typename T> bool VerifySizePrefixedBuffer(const char *identifier) {
+ template<typename T>
+ bool VerifySizePrefixedBuffer(const char *const identifier) {
return Verify<uoffset_t>(0U) &&
- ReadScalar<uoffset_t>(buf_) == size_ - sizeof(uoffset_t) &&
+ Check(ReadScalar<uoffset_t>(buf_) == size_ - sizeof(uoffset_t)) &&
VerifyBufferFromStart<T>(identifier, sizeof(uoffset_t));
}
- uoffset_t VerifyOffset(size_t start) const {
+ uoffset_t VerifyOffset(const size_t start) const {
if (!Verify<uoffset_t>(start)) return 0;
- auto o = ReadScalar<uoffset_t>(buf_ + start);
+ const auto o = ReadScalar<uoffset_t>(buf_ + start);
// May not point to itself.
if (!Check(o != 0)) return 0;
// Can't wrap around / buffers are max 2GB.
@@ -223,18 +257,18 @@
return o;
}
- uoffset_t VerifyOffset(const uint8_t *base, voffset_t start) const {
+ uoffset_t VerifyOffset(const uint8_t *const base,
+ const voffset_t start) const {
return VerifyOffset(static_cast<size_t>(base - buf_) + start);
}
// Called at the start of a table to increase counters measuring data
- // structure depth and amount, and possibly bails out with false if
- // limits set by the constructor have been hit. Needs to be balanced
- // with EndTable().
+ // structure depth and amount, and possibly bails out with false if limits set
+ // by the constructor have been hit. Needs to be balanced with EndTable().
bool VerifyComplexity() {
depth_++;
num_tables_++;
- return Check(depth_ <= max_depth_ && num_tables_ <= max_tables_);
+ return Check(depth_ <= opts_.max_depth && num_tables_ <= opts_.max_tables);
}
// Called at the end of a table to pop the depth count.
@@ -262,20 +296,20 @@
std::vector<uint8_t> *GetFlexReuseTracker() { return flex_reuse_tracker_; }
- void SetFlexReuseTracker(std::vector<uint8_t> *rt) {
+ void SetFlexReuseTracker(std::vector<uint8_t> *const rt) {
flex_reuse_tracker_ = rt;
}
private:
const uint8_t *buf_;
- size_t size_;
- uoffset_t depth_;
- uoffset_t max_depth_;
- uoffset_t num_tables_;
- uoffset_t max_tables_;
- mutable size_t upper_bound_;
- bool check_alignment_;
- std::vector<uint8_t> *flex_reuse_tracker_;
+ const size_t size_;
+ const Options opts_;
+
+ mutable size_t upper_bound_ = 0;
+
+ uoffset_t depth_ = 0;
+ uoffset_t num_tables_ = 0;
+ std::vector<uint8_t> *flex_reuse_tracker_ = nullptr;
};
} // namespace flatbuffers
diff --git a/pom.xml b/java/pom.xml
similarity index 82%
rename from pom.xml
rename to java/pom.xml
index aa318d0..34f154a 100644
--- a/pom.xml
+++ b/java/pom.xml
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.flatbuffers</groupId>
<artifactId>flatbuffers-java</artifactId>
- <version>2.0.3</version>
+ <version>2.0.8</version>
<packaging>bundle</packaging>
<name>FlatBuffers Java API</name>
<description>
@@ -13,6 +13,10 @@
<developer>
<name>Wouter van Oortmerssen</name>
</developer>
+ <developer>
+ <name>Derek Bailey</name>
+ <email>dbaileychess@gmail.com</email>
+ </developer>
</developers>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -33,6 +37,18 @@
<tag>HEAD</tag>
</scm>
<dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.13.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.truth</groupId>
+ <artifactId>truth</artifactId>
+ <version>1.1.3</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<distributionManagement>
<snapshotRepository>
@@ -41,7 +57,21 @@
</snapshotRepository>
</distributionManagement>
<build>
- <sourceDirectory>java</sourceDirectory>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <release>8</release>
+ <testExcludes>
+ <testExclude>**/LongEnum.java</testExclude>
+ <testExclude>MyGame/Example/MonsterStorageGrpc.java</testExclude>
+ <testExclude>MyGame/Example/StructOfStructs**</testExclude>
+ <testExclude>MyGame/OtherNameSpace/TableBT.java</testExclude>
+ </testExcludes>
+ </configuration>
+ <version>3.8.1</version>
+ </plugin>
+ </plugins>
</build>
<profiles>
<profile>
@@ -52,13 +82,6 @@
<build>
<plugins>
<plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <release>8</release>
- </configuration>
- <version>3.8.1</version>
- </plugin>
- <plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
diff --git a/java/com/google/flatbuffers/ArrayReadWriteBuf.java b/java/src/main/java/com/google/flatbuffers/ArrayReadWriteBuf.java
similarity index 100%
rename from java/com/google/flatbuffers/ArrayReadWriteBuf.java
rename to java/src/main/java/com/google/flatbuffers/ArrayReadWriteBuf.java
diff --git a/java/com/google/flatbuffers/BaseVector.java b/java/src/main/java/com/google/flatbuffers/BaseVector.java
similarity index 100%
rename from java/com/google/flatbuffers/BaseVector.java
rename to java/src/main/java/com/google/flatbuffers/BaseVector.java
diff --git a/java/com/google/flatbuffers/BooleanVector.java b/java/src/main/java/com/google/flatbuffers/BooleanVector.java
similarity index 100%
rename from java/com/google/flatbuffers/BooleanVector.java
rename to java/src/main/java/com/google/flatbuffers/BooleanVector.java
diff --git a/java/com/google/flatbuffers/ByteBufferReadWriteBuf.java b/java/src/main/java/com/google/flatbuffers/ByteBufferReadWriteBuf.java
similarity index 100%
rename from java/com/google/flatbuffers/ByteBufferReadWriteBuf.java
rename to java/src/main/java/com/google/flatbuffers/ByteBufferReadWriteBuf.java
diff --git a/java/com/google/flatbuffers/ByteBufferUtil.java b/java/src/main/java/com/google/flatbuffers/ByteBufferUtil.java
similarity index 100%
rename from java/com/google/flatbuffers/ByteBufferUtil.java
rename to java/src/main/java/com/google/flatbuffers/ByteBufferUtil.java
diff --git a/java/com/google/flatbuffers/ByteVector.java b/java/src/main/java/com/google/flatbuffers/ByteVector.java
similarity index 100%
rename from java/com/google/flatbuffers/ByteVector.java
rename to java/src/main/java/com/google/flatbuffers/ByteVector.java
diff --git a/java/com/google/flatbuffers/Constants.java b/java/src/main/java/com/google/flatbuffers/Constants.java
similarity index 97%
rename from java/com/google/flatbuffers/Constants.java
rename to java/src/main/java/com/google/flatbuffers/Constants.java
index 0c0920f..b9cb8f2 100644
--- a/java/com/google/flatbuffers/Constants.java
+++ b/java/src/main/java/com/google/flatbuffers/Constants.java
@@ -46,7 +46,7 @@
Changes to the Java implementation need to be sure to change
the version here and in the code generator on every possible
incompatible change */
- public static void FLATBUFFERS_2_0_0() {}
+ public static void FLATBUFFERS_2_0_8() {}
}
/// @endcond
diff --git a/java/com/google/flatbuffers/DoubleVector.java b/java/src/main/java/com/google/flatbuffers/DoubleVector.java
similarity index 100%
rename from java/com/google/flatbuffers/DoubleVector.java
rename to java/src/main/java/com/google/flatbuffers/DoubleVector.java
diff --git a/java/com/google/flatbuffers/FlatBufferBuilder.java b/java/src/main/java/com/google/flatbuffers/FlatBufferBuilder.java
similarity index 100%
rename from java/com/google/flatbuffers/FlatBufferBuilder.java
rename to java/src/main/java/com/google/flatbuffers/FlatBufferBuilder.java
diff --git a/java/com/google/flatbuffers/FlexBuffers.java b/java/src/main/java/com/google/flatbuffers/FlexBuffers.java
similarity index 100%
rename from java/com/google/flatbuffers/FlexBuffers.java
rename to java/src/main/java/com/google/flatbuffers/FlexBuffers.java
diff --git a/java/com/google/flatbuffers/FlexBuffersBuilder.java b/java/src/main/java/com/google/flatbuffers/FlexBuffersBuilder.java
similarity index 97%
rename from java/com/google/flatbuffers/FlexBuffersBuilder.java
rename to java/src/main/java/com/google/flatbuffers/FlexBuffersBuilder.java
index 7f41bb6..60ab535 100644
--- a/java/com/google/flatbuffers/FlexBuffersBuilder.java
+++ b/java/src/main/java/com/google/flatbuffers/FlexBuffersBuilder.java
@@ -174,6 +174,21 @@
}
/**
+ * Insert a null value into the buffer
+ */
+ public void putNull() {
+ putNull(null);
+ }
+
+ /**
+ * Insert a null value into the buffer
+ * @param key key used to store element in map
+ */
+ public void putNull(String key) {
+ stack.add(Value.nullValue(putKey(key)));
+ }
+
+ /**
* Insert a single boolean into the buffer
* @param val true or false
*/
@@ -451,7 +466,7 @@
/**
* Finishes a vector, but writing the information in the buffer
* @param key key used to store element in map
- * @param start reference for begining of the vector. Returned by {@link startVector()}
+ * @param start reference for beginning of the vector. Returned by {@link startVector()}
* @param typed boolean indicating whether vector is typed
* @param fixed boolean indicating whether vector is fixed
* @return Reference to the vector
@@ -502,7 +517,9 @@
* @return Value representing the created vector
*/
private Value createVector(int key, int start, int length, boolean typed, boolean fixed, Value keys) {
- assert (!fixed || typed); // typed=false, fixed=true combination is not supported.
+ if (fixed & !typed)
+ throw new UnsupportedOperationException("Untyped fixed vector is not supported");
+
// Figure out smallest bit width we can store this vector with.
int bitWidth = Math.max(WIDTH_8, widthUInBits(length));
int prefixElems = 1;
@@ -602,7 +619,7 @@
/**
* Finishes a map, but writing the information in the buffer
* @param key key used to store element in map
- * @param start reference for begining of the map. Returned by {@link startMap()}
+ * @param start reference for beginning of the map. Returned by {@link startMap()}
* @return Reference to the map
*/
public int endMap(String key, int start) {
@@ -673,6 +690,10 @@
this.iValue = Long.MIN_VALUE;
}
+ static Value nullValue(int key) {
+ return new Value(key, FBT_NULL, WIDTH_8, 0);
+ }
+
static Value bool(int key, boolean b) {
return new Value(key, FBT_BOOL, WIDTH_8, b ? 1 : 0);
}
diff --git a/java/com/google/flatbuffers/FloatVector.java b/java/src/main/java/com/google/flatbuffers/FloatVector.java
similarity index 100%
rename from java/com/google/flatbuffers/FloatVector.java
rename to java/src/main/java/com/google/flatbuffers/FloatVector.java
diff --git a/java/com/google/flatbuffers/IntVector.java b/java/src/main/java/com/google/flatbuffers/IntVector.java
similarity index 100%
rename from java/com/google/flatbuffers/IntVector.java
rename to java/src/main/java/com/google/flatbuffers/IntVector.java
diff --git a/java/com/google/flatbuffers/LongVector.java b/java/src/main/java/com/google/flatbuffers/LongVector.java
similarity index 100%
rename from java/com/google/flatbuffers/LongVector.java
rename to java/src/main/java/com/google/flatbuffers/LongVector.java
diff --git a/java/com/google/flatbuffers/ReadBuf.java b/java/src/main/java/com/google/flatbuffers/ReadBuf.java
similarity index 100%
rename from java/com/google/flatbuffers/ReadBuf.java
rename to java/src/main/java/com/google/flatbuffers/ReadBuf.java
diff --git a/java/com/google/flatbuffers/ReadWriteBuf.java b/java/src/main/java/com/google/flatbuffers/ReadWriteBuf.java
similarity index 100%
rename from java/com/google/flatbuffers/ReadWriteBuf.java
rename to java/src/main/java/com/google/flatbuffers/ReadWriteBuf.java
diff --git a/java/com/google/flatbuffers/ShortVector.java b/java/src/main/java/com/google/flatbuffers/ShortVector.java
similarity index 100%
rename from java/com/google/flatbuffers/ShortVector.java
rename to java/src/main/java/com/google/flatbuffers/ShortVector.java
diff --git a/java/com/google/flatbuffers/StringVector.java b/java/src/main/java/com/google/flatbuffers/StringVector.java
similarity index 100%
rename from java/com/google/flatbuffers/StringVector.java
rename to java/src/main/java/com/google/flatbuffers/StringVector.java
diff --git a/java/com/google/flatbuffers/Struct.java b/java/src/main/java/com/google/flatbuffers/Struct.java
similarity index 100%
rename from java/com/google/flatbuffers/Struct.java
rename to java/src/main/java/com/google/flatbuffers/Struct.java
diff --git a/java/com/google/flatbuffers/Table.java b/java/src/main/java/com/google/flatbuffers/Table.java
similarity index 100%
rename from java/com/google/flatbuffers/Table.java
rename to java/src/main/java/com/google/flatbuffers/Table.java
diff --git a/java/com/google/flatbuffers/UnionVector.java b/java/src/main/java/com/google/flatbuffers/UnionVector.java
similarity index 100%
rename from java/com/google/flatbuffers/UnionVector.java
rename to java/src/main/java/com/google/flatbuffers/UnionVector.java
diff --git a/java/com/google/flatbuffers/Utf8.java b/java/src/main/java/com/google/flatbuffers/Utf8.java
similarity index 100%
rename from java/com/google/flatbuffers/Utf8.java
rename to java/src/main/java/com/google/flatbuffers/Utf8.java
diff --git a/java/com/google/flatbuffers/Utf8Old.java b/java/src/main/java/com/google/flatbuffers/Utf8Old.java
similarity index 100%
rename from java/com/google/flatbuffers/Utf8Old.java
rename to java/src/main/java/com/google/flatbuffers/Utf8Old.java
diff --git a/java/com/google/flatbuffers/Utf8Safe.java b/java/src/main/java/com/google/flatbuffers/Utf8Safe.java
similarity index 100%
rename from java/com/google/flatbuffers/Utf8Safe.java
rename to java/src/main/java/com/google/flatbuffers/Utf8Safe.java
diff --git a/java/src/test/java/DictionaryLookup b/java/src/test/java/DictionaryLookup
new file mode 120000
index 0000000..231bcd8
--- /dev/null
+++ b/java/src/test/java/DictionaryLookup
@@ -0,0 +1 @@
+../../../../tests/DictionaryLookup
\ No newline at end of file
diff --git a/java/src/test/java/JavaTest.java b/java/src/test/java/JavaTest.java
new file mode 100644
index 0000000..c392e04
--- /dev/null
+++ b/java/src/test/java/JavaTest.java
@@ -0,0 +1,1533 @@
+
+import static com.google.flatbuffers.Constants.*;
+import static com.google.common.truth.Truth.assertThat;
+
+import DictionaryLookup.*;
+import MyGame.Example.*;
+import com.google.common.io.ByteStreams;
+import optional_scalars.ScalarStuff;
+import optional_scalars.OptionalByte;
+import NamespaceA.*;
+import NamespaceA.NamespaceB.*;
+import com.google.flatbuffers.ByteBufferUtil;
+import com.google.flatbuffers.ByteVector;
+import com.google.flatbuffers.FlatBufferBuilder;
+import com.google.flatbuffers.FlexBuffers;
+import com.google.flatbuffers.FlexBuffersBuilder;
+import com.google.flatbuffers.StringVector;
+import com.google.flatbuffers.UnionVector;
+
+import com.google.flatbuffers.FlexBuffers.FlexBufferException;
+import com.google.flatbuffers.FlexBuffers.Reference;
+import com.google.flatbuffers.FlexBuffers.Vector;
+import com.google.flatbuffers.ArrayReadWriteBuf;
+import com.google.flatbuffers.FlexBuffers.KeyVector;
+
+import java.io.*;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.channels.FileChannel;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.Rule;
+import org.junit.rules.TemporaryFolder;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+
+/*
+ * Copyright 2014 Google Inc. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@RunWith(JUnit4.class)
+public class JavaTest {
+
+ @Rule
+ public TemporaryFolder tempFolder = new TemporaryFolder();
+
+ @org.junit.Test
+ public void mainTest() throws IOException {
+ // First, let's test reading a FlatBuffer generated by C++ code:
+ // This file was generated from monsterdata_test.json
+ byte[] data = ByteStreams.toByteArray(
+ JavaTest.class.getClassLoader().getResourceAsStream("monsterdata_test.mon"));
+
+ // Now test it:
+ ByteBuffer bb = ByteBuffer.wrap(data);
+ TestBuffer(bb);
+ TestPackUnpack(bb);
+ }
+
+ @org.junit.Test
+ public void testFlatBufferBuilder() {
+ // We use an initial size of 1 to exercise the reallocation algorithm,
+ // normally a size larger than the typical FlatBuffer you generate would be
+ // better for performance.
+ FlatBufferBuilder fbb = new FlatBufferBuilder(1);
+ TestBuilderBasics(fbb, true);
+ TestBuilderBasics(fbb, false);
+ TestExtendedBuffer(fbb.dataBuffer().asReadOnlyBuffer());
+ }
+
+ @org.junit.Test
+ public void TestEnums() {
+ assertThat(Color.name(Color.Red)).isEqualTo("Red");
+ assertThat(Color.name(Color.Blue)).isEqualTo("Blue");
+ assertThat(Any.name(Any.NONE)).isEqualTo("NONE");
+ assertThat(Any.name(Any.Monster)).isEqualTo("Monster");
+ }
+
+ static void TestBuffer(ByteBuffer bb) {
+ assertThat(Monster.MonsterBufferHasIdentifier(bb)).isEqualTo(true);
+
+ Monster monster = Monster.getRootAsMonster(bb);
+
+ assertThat(monster.hp()).isEqualTo((short) 80);
+ // default
+ assertThat(monster.mana()).isEqualTo((short) 150);
+
+ assertThat(monster.name()).isEqualTo("MyMonster");
+ // monster.friendly() // can't access, deprecated
+
+ Vec3 pos = monster.pos();
+ assertThat(pos.x()).isEqualTo(1.0f);
+ assertThat(pos.y()).isEqualTo(2.0f);
+ assertThat(pos.z()).isEqualTo(3.0f);
+ assertThat(pos.test1()).isEqualTo(3.0);
+ // issue: int != byte
+ assertThat(pos.test2()).isEqualTo((int) Color.Green);
+ Test t = pos.test3();
+ assertThat(t.a()).isEqualTo((short) 5);
+ assertThat(t.b()).isEqualTo((byte) 6);
+
+ assertThat(monster.testType()).isEqualTo((byte) Any.Monster);
+ Monster monster2 = new Monster();
+ assertThat(monster.test(monster2) != null).isTrue();
+ assertThat(monster2.name()).isEqualTo("Fred");
+
+ assertThat(monster.inventoryLength()).isEqualTo(5);
+ int invsum = 0;
+ for (int i = 0; i < monster.inventoryLength(); i++)
+ invsum += monster.inventory(i);
+ assertThat(invsum).isEqualTo(10);
+
+ // Method using a vector access object:
+ ByteVector inventoryVector = monster.inventoryVector();
+ assertThat(inventoryVector.length()).isEqualTo(5);
+ invsum = 0;
+ for (int i = 0; i < inventoryVector.length(); i++)
+ invsum += inventoryVector.getAsUnsigned(i);
+ assertThat(invsum).isEqualTo(10);
+
+ // Alternative way of accessing a vector:
+ ByteBuffer ibb = monster.inventoryAsByteBuffer();
+ invsum = 0;
+ while (ibb.position() < ibb.limit())
+ invsum += ibb.get();
+ assertThat(invsum).isEqualTo(10);
+
+ Test test_0 = monster.test4(0);
+ Test test_1 = monster.test4(1);
+ assertThat(monster.test4Length()).isEqualTo(2);
+ assertThat(test_0.a() + test_0.b() + test_1.a() + test_1.b()).isEqualTo((Integer) 100);
+
+ Test.Vector test4Vector = monster.test4Vector();
+ test_0 = test4Vector.get(0);
+ test_1 = test4Vector.get(1);
+ assertThat(test4Vector.length()).isEqualTo(2);
+ assertThat(test_0.a() + test_0.b() + test_1.a() + test_1.b()).isEqualTo((Integer) 100);
+
+ assertThat(monster.testarrayofstringLength()).isEqualTo(2);
+ assertThat(monster.testarrayofstring(0)).isEqualTo("test1");
+ assertThat(monster.testarrayofstring(1)).isEqualTo("test2");
+
+ // Method using a vector access object:
+ StringVector testarrayofstringVector = monster.testarrayofstringVector();
+ assertThat(testarrayofstringVector.length()).isEqualTo(2);
+ assertThat(testarrayofstringVector.get(0)).isEqualTo("test1");
+ assertThat(testarrayofstringVector.get(1)).isEqualTo("test2");
+
+ assertThat(monster.testbool()).isEqualTo(true);
+ }
+
+ // this method checks additional fields not present in the binary buffer read from file
+ // these new tests are performed on top of the regular tests
+ static void TestExtendedBuffer(ByteBuffer bb) {
+ TestBuffer(bb);
+
+ Monster monster = Monster.getRootAsMonster(bb);
+
+ assertThat(monster.testhashu32Fnv1()).isEqualTo((Integer.MAX_VALUE + 1L));
+ }
+
+
+ @org.junit.Test public void TestNamespaceNesting() {
+ // reference / manipulate these to verify compilation
+ FlatBufferBuilder fbb = new FlatBufferBuilder(1);
+
+ TableInNestedNS.startTableInNestedNS(fbb);
+ TableInNestedNS.addFoo(fbb, 1234);
+ int nestedTableOff = TableInNestedNS.endTableInNestedNS(fbb);
+
+ TableInFirstNS.startTableInFirstNS(fbb);
+ TableInFirstNS.addFooTable(fbb, nestedTableOff);
+ int off = TableInFirstNS.endTableInFirstNS(fbb);
+ }
+
+ @org.junit.Test public void TestNestedFlatBuffer() {
+ final String nestedMonsterName = "NestedMonsterName";
+ final short nestedMonsterHp = 600;
+ final short nestedMonsterMana = 1024;
+
+ FlatBufferBuilder fbb1 = new FlatBufferBuilder(16);
+ int str1 = fbb1.createString(nestedMonsterName);
+ Monster.startMonster(fbb1);
+ Monster.addName(fbb1, str1);
+ Monster.addHp(fbb1, nestedMonsterHp);
+ Monster.addMana(fbb1, nestedMonsterMana);
+ int monster1 = Monster.endMonster(fbb1);
+ Monster.finishMonsterBuffer(fbb1, monster1);
+ byte[] fbb1Bytes = fbb1.sizedByteArray();
+ fbb1 = null;
+
+ FlatBufferBuilder fbb2 = new FlatBufferBuilder(16);
+ int str2 = fbb2.createString("My Monster");
+ int nestedBuffer = Monster.createTestnestedflatbufferVector(fbb2, fbb1Bytes);
+ Monster.startMonster(fbb2);
+ Monster.addName(fbb2, str2);
+ Monster.addHp(fbb2, (short)50);
+ Monster.addMana(fbb2, (short)32);
+ Monster.addTestnestedflatbuffer(fbb2, nestedBuffer);
+ int monster = Monster.endMonster(fbb2);
+ Monster.finishMonsterBuffer(fbb2, monster);
+
+ // Now test the data extracted from the nested buffer
+ Monster mons = Monster.getRootAsMonster(fbb2.dataBuffer());
+ Monster nestedMonster = mons.testnestedflatbufferAsMonster();
+
+ assertThat(nestedMonsterMana).isEqualTo(nestedMonster.mana());
+ assertThat(nestedMonsterHp).isEqualTo(nestedMonster.hp());
+ assertThat(nestedMonsterName).isEqualTo(nestedMonster.name());
+ }
+
+ @org.junit.Test public void TestCreateByteVector() {
+ FlatBufferBuilder fbb = new FlatBufferBuilder(16);
+ int str = fbb.createString("MyMonster");
+ byte[] inventory = new byte[] { 0, 1, 2, 3, 4 };
+ int vec = fbb.createByteVector(inventory);
+ Monster.startMonster(fbb);
+ Monster.addInventory(fbb, vec);
+ Monster.addName(fbb, str);
+ int monster1 = Monster.endMonster(fbb);
+ Monster.finishMonsterBuffer(fbb, monster1);
+ Monster monsterObject = Monster.getRootAsMonster(fbb.dataBuffer());
+
+ assertThat((Integer) monsterObject.inventory(1)).isEqualTo((int)inventory[1]);
+ assertThat(monsterObject.inventoryLength()).isEqualTo(inventory.length);
+ ByteVector inventoryVector = monsterObject.inventoryVector();
+ assertThat(inventoryVector.getAsUnsigned(1)).isEqualTo((int)inventory[1]);
+ assertThat(inventoryVector.length()).isEqualTo(inventory.length);
+
+ assertThat(ByteBuffer.wrap(inventory)).isEqualTo(
+ monsterObject.inventoryAsByteBuffer());
+ }
+
+ @org.junit.Test public void TestCreateUninitializedVector() {
+ FlatBufferBuilder fbb = new FlatBufferBuilder(16);
+ int str = fbb.createString("MyMonster");
+ byte[] inventory = new byte[] { 0, 1, 2, 3, 4 };
+ ByteBuffer bb = fbb.createUnintializedVector(1, inventory.length, 1);
+ for (byte i:inventory) {
+ bb.put(i);
+ }
+ int vec = fbb.endVector();
+ Monster.startMonster(fbb);
+ Monster.addInventory(fbb, vec);
+ Monster.addName(fbb, str);
+ int monster1 = Monster.endMonster(fbb);
+ Monster.finishMonsterBuffer(fbb, monster1);
+ Monster monsterObject = Monster.getRootAsMonster(fbb.dataBuffer());
+
+ assertThat((Integer) monsterObject.inventory(1)).isEqualTo((int)inventory[1]);
+ assertThat(monsterObject.inventoryLength()).isEqualTo(inventory.length);
+ ByteVector inventoryVector = monsterObject.inventoryVector();
+ assertThat(inventoryVector.getAsUnsigned(1)).isEqualTo((int)inventory[1]);
+ assertThat(inventoryVector.length()).isEqualTo(inventory.length);
+ assertThat(ByteBuffer.wrap(inventory)).isEqualTo(
+ monsterObject.inventoryAsByteBuffer());
+ }
+
+ @org.junit.Test public void TestByteBufferFactory() throws IOException {
+ File file = tempFolder.newFile("javatest.bin");
+ final class MappedByteBufferFactory extends FlatBufferBuilder.ByteBufferFactory {
+ @Override
+ public ByteBuffer newByteBuffer(int capacity) {
+ ByteBuffer bb;
+ try {
+ RandomAccessFile f = new RandomAccessFile(file, "rw");
+ bb = f.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, capacity).order(ByteOrder.LITTLE_ENDIAN);
+ f.close();
+ } catch(Throwable e) {
+ System.out.println("FlatBuffers test: couldn't map ByteBuffer to a file");
+ bb = null;
+ }
+ return bb;
+ }
+ }
+
+ FlatBufferBuilder fbb = new FlatBufferBuilder(1, new MappedByteBufferFactory());
+
+ TestBuilderBasics(fbb, false);
+ }
+
+ @org.junit.Test public void TestSizedInputStream() {
+ // Test on default FlatBufferBuilder that uses HeapByteBuffer
+ FlatBufferBuilder fbb = new FlatBufferBuilder(1);
+
+ TestBuilderBasics(fbb, false);
+
+ InputStream in = fbb.sizedInputStream();
+ byte[] array = fbb.sizedByteArray();
+ int count = 0;
+ int currentVal = 0;
+
+ while (currentVal != -1 && count < array.length) {
+ try {
+ currentVal = in.read();
+ } catch(java.io.IOException e) {
+ System.out.println("FlatBuffers test: couldn't read from InputStream");
+ return;
+ }
+ assertThat((byte)currentVal).isEqualTo(array[count]);
+ count++;
+ }
+ assertThat(count).isEqualTo(array.length);
+ }
+
+ void TestBuilderBasics(FlatBufferBuilder fbb, boolean sizePrefix) {
+ int[] names = {fbb.createString("Frodo"), fbb.createString("Barney"), fbb.createString("Wilma")};
+ int[] off = new int[3];
+ Monster.startMonster(fbb);
+ Monster.addName(fbb, names[0]);
+ off[0] = Monster.endMonster(fbb);
+ Monster.startMonster(fbb);
+ Monster.addName(fbb, names[1]);
+ off[1] = Monster.endMonster(fbb);
+ Monster.startMonster(fbb);
+ Monster.addName(fbb, names[2]);
+ off[2] = Monster.endMonster(fbb);
+ int sortMons = fbb.createSortedVectorOfTables(new Monster(), off);
+
+ // We set up the same values as monsterdata.json:
+
+ int str = fbb.createString("MyMonster");
+
+ int inv = Monster.createInventoryVector(fbb, new byte[] { 0, 1, 2, 3, 4 });
+
+ int fred = fbb.createString("Fred");
+ Monster.startMonster(fbb);
+ Monster.addName(fbb, fred);
+ int mon2 = Monster.endMonster(fbb);
+
+ Monster.startTest4Vector(fbb, 2);
+ Test.createTest(fbb, (short)10, (byte)20);
+ Test.createTest(fbb, (short)30, (byte)40);
+ int test4 = fbb.endVector();
+
+ int testArrayOfString = Monster.createTestarrayofstringVector(fbb, new int[] {
+ fbb.createString("test1"),
+ fbb.createString("test2")
+ });
+
+ Monster.startMonster(fbb);
+ Monster.addPos(fbb, Vec3.createVec3(fbb, 1.0f, 2.0f, 3.0f, 3.0,
+ Color.Green, (short)5, (byte)6));
+ Monster.addHp(fbb, (short)80);
+ Monster.addName(fbb, str);
+ Monster.addInventory(fbb, inv);
+ Monster.addTestType(fbb, (byte)Any.Monster);
+ Monster.addTest(fbb, mon2);
+ Monster.addTest4(fbb, test4);
+ Monster.addTestarrayofstring(fbb, testArrayOfString);
+ Monster.addTestbool(fbb, true);
+ Monster.addTesthashu32Fnv1(fbb, Integer.MAX_VALUE + 1L);
+ Monster.addTestarrayoftables(fbb, sortMons);
+ int mon = Monster.endMonster(fbb);
+
+ if (sizePrefix) {
+ Monster.finishSizePrefixedMonsterBuffer(fbb, mon);
+ } else {
+ Monster.finishMonsterBuffer(fbb, mon);
+ }
+
+ // Write the result to a file for debugging purposes:
+ // Note that the binaries are not necessarily identical, since the JSON
+ // parser may serialize in a slightly different order than the above
+ // Java code. They are functionally equivalent though.
+
+ try {
+ String filename = "monsterdata_java_wire" + (sizePrefix ? "_sp" : "") + ".mon";
+ FileChannel fc = new FileOutputStream(tempFolder.newFile(filename)).getChannel();
+ fc.write(fbb.dataBuffer().duplicate());
+ fc.close();
+ } catch(java.io.IOException e) {
+ System.out.println("FlatBuffers test: couldn't write file");
+ return;
+ }
+
+ // Test it:
+ ByteBuffer dataBuffer = fbb.dataBuffer();
+ if (sizePrefix) {
+ assertThat(ByteBufferUtil.getSizePrefix(dataBuffer) + SIZE_PREFIX_LENGTH).isEqualTo(
+ dataBuffer.remaining());
+ dataBuffer = ByteBufferUtil.removeSizePrefix(dataBuffer);
+ }
+ TestExtendedBuffer(dataBuffer);
+
+ // Make sure it also works with read only ByteBuffers. This is slower,
+ // since creating strings incurs an additional copy
+ // (see Table.__string).
+ TestExtendedBuffer(dataBuffer.asReadOnlyBuffer());
+
+ //Attempt to mutate Monster fields and check whether the buffer has been mutated properly
+ // revert to original values after testing
+ Monster monster = Monster.getRootAsMonster(dataBuffer);
+
+ // mana is optional and does not exist in the buffer so the mutation should fail
+ // the mana field should retain its default value
+ assertThat(monster.mutateMana((short)10)).isFalse();
+ assertThat(monster.mana()).isEqualTo((short) 150);
+
+ // Accessing a vector of sorted by the key tables
+ assertThat(monster.testarrayoftables(0).name()).isEqualTo("Barney");
+ assertThat(monster.testarrayoftables(1).name()).isEqualTo("Frodo");
+ assertThat(monster.testarrayoftables(2).name()).isEqualTo("Wilma");
+ Monster.Vector testarrayoftablesVector = monster.testarrayoftablesVector();
+ assertThat(testarrayoftablesVector.get(0).name()).isEqualTo("Barney");
+ assertThat(testarrayoftablesVector.get(1).name()).isEqualTo("Frodo");
+ assertThat(testarrayoftablesVector.get(2).name()).isEqualTo("Wilma");
+
+ // Example of searching for a table by the key
+ assertThat(monster.testarrayoftablesByKey("Frodo").name()).isEqualTo("Frodo");
+ assertThat(monster.testarrayoftablesByKey("Barney").name()).isEqualTo("Barney");
+ assertThat(monster.testarrayoftablesByKey("Wilma").name()).isEqualTo("Wilma");
+ assertThat(testarrayoftablesVector.getByKey("Frodo").name()).isEqualTo("Frodo");
+ assertThat(testarrayoftablesVector.getByKey("Barney").name()).isEqualTo("Barney");
+ assertThat(testarrayoftablesVector.getByKey("Wilma").name()).isEqualTo("Wilma");
+
+ // testType is an existing field and mutating it should succeed
+ assertThat(monster.testType()).isEqualTo((byte) Any.Monster);
+
+ //mutate the inventory vector
+ assertThat(monster.mutateInventory(0, 1)).isTrue();
+ assertThat(monster.mutateInventory(1, 2)).isTrue();
+ assertThat(monster.mutateInventory(2, 3)).isTrue();
+ assertThat(monster.mutateInventory(3, 4)).isTrue();
+ assertThat(monster.mutateInventory(4, 5)).isTrue();
+
+ for (int i = 0; i < monster.inventoryLength(); i++) {
+ assertThat((Integer) monster.inventory(i)).isEqualTo(i + 1);
+ }
+ ByteVector inventoryVector = monster.inventoryVector();
+ for (int i = 0; i < inventoryVector.length(); i++) {
+ assertThat((int)inventoryVector.get(i)).isEqualTo(i + 1);
+ }
+
+ //reverse mutation
+ assertThat(monster.mutateInventory(0, 0)).isTrue();
+ assertThat(monster.mutateInventory(1, 1)).isTrue();
+ assertThat(monster.mutateInventory(2, 2)).isTrue();
+ assertThat(monster.mutateInventory(3, 3)).isTrue();
+ assertThat(monster.mutateInventory(4, 4)).isTrue();
+
+ // get a struct field and edit one of its fields
+ Vec3 pos = monster.pos();
+ assertThat(pos.x()).isEqualTo(1.0f);
+ pos.mutateX(55.0f);
+ assertThat(pos.x()).isEqualTo(55.0f);
+ pos.mutateX(1.0f);
+ assertThat(pos.x()).isEqualTo(1.0f);
+ }
+
+ @org.junit.Test public void TestVectorOfUnions() {
+ final FlatBufferBuilder fbb = new FlatBufferBuilder();
+
+ final int swordAttackDamage = 1;
+
+ final int[] characterVector = new int[] {
+ Attacker.createAttacker(fbb, swordAttackDamage),
+ };
+
+ final byte[] characterTypeVector = new byte[]{
+ Character.MuLan,
+ };
+
+ Movie.finishMovieBuffer(
+ fbb,
+ Movie.createMovie(
+ fbb,
+ (byte)0,
+ (byte)0,
+ Movie.createCharactersTypeVector(fbb, characterTypeVector),
+ Movie.createCharactersVector(fbb, characterVector)
+ )
+ );
+
+ final Movie movie = Movie.getRootAsMovie(fbb.dataBuffer());
+ ByteVector charactersTypeByteVector = movie.charactersTypeVector();
+ UnionVector charactersVector = movie.charactersVector();
+
+ assertThat(movie.charactersTypeLength()).isEqualTo(characterTypeVector.length);
+ assertThat(charactersTypeByteVector.length()).isEqualTo(characterTypeVector.length);
+ assertThat(movie.charactersLength()).isEqualTo(characterVector.length);
+ assertThat(charactersVector.length()).isEqualTo(characterVector.length);
+
+ assertThat((Byte) movie.charactersType(0)).isEqualTo(characterTypeVector[0]);
+ assertThat(charactersTypeByteVector.get(0)).isEqualTo(characterTypeVector[0]);
+
+ assertThat(((Attacker)movie.characters(new Attacker(), 0)).swordAttackDamage()).isEqualTo(
+ swordAttackDamage);
+ }
+
+ @org.junit.Test public void TestFixedLengthArrays() {
+ FlatBufferBuilder builder = new FlatBufferBuilder(0);
+
+ float a;
+ int[] b = new int[15];
+ byte c;
+ int[][] d_a = new int[2][2];
+ byte[] d_b = new byte[2];
+ byte[][] d_c = new byte[2][2];
+ long[][] d_d = new long[2][2];
+ int e;
+ long[] f = new long[2];
+
+ a = 0.5f;
+ for (int i = 0; i < 15; i++) b[i] = i;
+ c = 1;
+ d_a[0][0] = 1;
+ d_a[0][1] = 2;
+ d_a[1][0] = 3;
+ d_a[1][1] = 4;
+ d_b[0] = TestEnum.B;
+ d_b[1] = TestEnum.C;
+ d_c[0][0] = TestEnum.A;
+ d_c[0][1] = TestEnum.B;
+ d_c[1][0] = TestEnum.C;
+ d_c[1][1] = TestEnum.B;
+ d_d[0][0] = -1;
+ d_d[0][1] = 1;
+ d_d[1][0] = -2;
+ d_d[1][1] = 2;
+ e = 2;
+ f[0] = -1;
+ f[1] = 1;
+
+ int arrayOffset = ArrayStruct.createArrayStruct(builder,
+ a, b, c, d_a, d_b, d_c, d_d, e, f);
+
+ // Create a table with the ArrayStruct.
+ ArrayTable.startArrayTable(builder);
+ ArrayTable.addA(builder, arrayOffset);
+ int tableOffset = ArrayTable.endArrayTable(builder);
+
+ ArrayTable.finishArrayTableBuffer(builder, tableOffset);
+
+ ArrayTable table = ArrayTable.getRootAsArrayTable(builder.dataBuffer());
+ NestedStruct nested = new NestedStruct();
+
+ assertThat(table.a().a()).isEqualTo(0.5f);
+ for (int i = 0; i < 15; i++)
+ assertThat(table.a().b(i)).isEqualTo(i);
+ assertThat(table.a().c()).isEqualTo((byte)1);
+ assertThat(table.a().d(nested, 0).a(0)).isEqualTo(1);
+ assertThat(table.a().d(nested, 0).a(1)).isEqualTo(2);
+ assertThat(table.a().d(nested, 1).a(0)).isEqualTo(3);
+ assertThat(table.a().d(nested, 1).a(1)).isEqualTo(4);
+ assertThat(table.a().d(nested, 0).b()).isEqualTo(TestEnum.B);
+ assertThat(table.a().d(nested, 1).b()).isEqualTo(TestEnum.C);
+ assertThat(table.a().d(nested, 0).c(0)).isEqualTo(TestEnum.A);
+ assertThat(table.a().d(nested, 0).c(1)).isEqualTo(TestEnum.B);
+ assertThat(table.a().d(nested, 1).c(0)).isEqualTo(TestEnum.C);
+ assertThat(table.a().d(nested, 1).c(1)).isEqualTo(TestEnum.B);
+ assertThat(table.a().d(nested, 0).d(0)).isEqualTo((long)-1);
+ assertThat(table.a().d(nested, 0).d(1)).isEqualTo((long)1);
+ assertThat(table.a().d(nested, 1).d(0)).isEqualTo((long)-2);
+ assertThat(table.a().d(nested, 1).d(1)).isEqualTo((long)2);
+ assertThat(table.a().e()).isEqualTo(2);
+ assertThat(table.a().f(0)).isEqualTo((long)-1);
+ assertThat(table.a().f(1)).isEqualTo((long)1);
+ }
+
+ @org.junit.Test public void testFlexBuffersTest() {
+ FlexBuffersBuilder builder = new FlexBuffersBuilder(ByteBuffer.allocate(512),
+ FlexBuffersBuilder.BUILDER_FLAG_SHARE_KEYS_AND_STRINGS);
+ testFlexBuffersTest(builder);
+ int bufferLimit1 = ((ArrayReadWriteBuf) builder.getBuffer()).limit();
+
+ // Repeat after clearing the builder to ensure the builder is reusable
+ builder.clear();
+ testFlexBuffersTest(builder);
+ int bufferLimit2 = ((ArrayReadWriteBuf) builder.getBuffer()).limit();
+ assertThat(bufferLimit1).isEqualTo(bufferLimit2);
+ }
+
+ public static void testFlexBuffersTest(FlexBuffersBuilder builder) {
+ // Write the equivalent of:
+ // { vec: [ -100, "Fred", 4.0, false ], bar: [ 1, 2, 3 ], bar3: [ 1, 2, 3 ],
+ // foo: 100, bool: true, mymap: { foo: "Fred" } }
+ // It's possible to do this without std::function support as well.
+ int map1 = builder.startMap();
+
+ int vec1 = builder.startVector();
+ builder.putInt(-100);
+ builder.putString("Fred");
+ builder.putBlob(new byte[]{(byte) 77});
+ builder.putBoolean(false);
+ builder.putInt(Long.MAX_VALUE);
+
+ int map2 = builder.startMap();
+ builder.putInt("test", 200);
+ builder.endMap(null, map2);
+
+ builder.putFloat(150.9);
+ builder.putFloat(150.9999998);
+ builder.endVector("vec", vec1, false, false);
+
+ vec1 = builder.startVector();
+ builder.putInt(1);
+ builder.putInt(2);
+ builder.putInt(3);
+ builder.endVector("bar", vec1, true, false);
+
+ vec1 = builder.startVector();
+ builder.putBoolean(true);
+ builder.putBoolean(false);
+ builder.putBoolean(true);
+ builder.putBoolean(false);
+ builder.endVector("bools", vec1, true, false);
+
+ builder.putBoolean("bool", true);
+ builder.putFloat("foo", 100);
+
+ map2 = builder.startMap();
+ builder.putString("bar", "Fred"); // Testing key and string reuse.
+ builder.putInt("int", -120);
+ builder.putFloat("float", -123.0f);
+ builder.putBlob("blob", new byte[]{ 65, 67 });
+ builder.endMap("mymap", map2);
+
+ builder.endMap(null, map1);
+ builder.finish();
+
+ FlexBuffers.Map m = FlexBuffers.getRoot(builder.getBuffer()).asMap();
+
+ assertThat(m.size()).isEqualTo(6);
+
+ // test empty (an null)
+ // empty if fail
+ assertThat(m.get("no_key").asString()).isEqualTo("");
+ // empty if fail
+ assertThat(m.get("no_key").asMap()).isEqualTo(FlexBuffers.Map.empty());
+ // empty if fail
+ assertThat(m.get("no_key").asKey()).isEqualTo(FlexBuffers.Key.empty());
+ // empty if fail
+ assertThat(m.get("no_key").asVector()).isEqualTo(Vector.empty());
+ // empty if fail
+ assertThat(m.get("no_key").asBlob()).isEqualTo(FlexBuffers.Blob.empty());
+ assert(m.get("no_key").asVector().isEmpty()); // empty if fail
+
+ // testing "vec" field
+ FlexBuffers.Vector vec = m.get("vec").asVector();
+ assertThat(vec.size()).isEqualTo(8);
+ assertThat(vec.get(0).asLong()).isEqualTo((long) -100);
+ assertThat(vec.get(1).asString()).isEqualTo("Fred");
+ assertThat(vec.get(2).isBlob()).isTrue();
+ assertThat(vec.get(2).asBlob().size()).isEqualTo(1);
+ assertThat(vec.get(2).asBlob().data().get(0)).isEqualTo((byte) 77);
+ // Check if type is a bool
+ assertThat(vec.get(3).isBoolean()).isTrue();
+ // Check if value is false
+ assertThat(vec.get(3).asBoolean()).isFalse();
+ assertThat(vec.get(4).asLong()).isEqualTo(Long.MAX_VALUE);
+ assertThat(vec.get(5).isMap()).isTrue();
+ assertThat(vec.get(5).asMap().get("test").asInt()).isEqualTo(200);
+ assertThat(Float.compare((float)vec.get(6).asFloat(), 150.9f)).isEqualTo(0);
+ assertThat(Double.compare(vec.get(7).asFloat(), 150.9999998)).isEqualTo(0);
+ //conversion fail returns 0 as C++
+ assertThat((long)0).isEqualTo((long)vec.get(1).asLong());
+
+ // bar vector
+ FlexBuffers.Vector tvec = m.get("bar").asVector();
+ assertThat(tvec.size()).isEqualTo(3);
+ assertThat(tvec.get(0).asInt()).isEqualTo(1);
+ assertThat(tvec.get(1).asInt()).isEqualTo(2);
+ assertThat(tvec.get(2).asInt()).isEqualTo(3);
+ assertThat(((FlexBuffers.TypedVector) tvec).getElemType()).isEqualTo(FlexBuffers.FBT_INT);
+
+ // bools vector
+ FlexBuffers.Vector bvec = m.get("bools").asVector();
+ assertThat(bvec.size()).isEqualTo(4);
+ assertThat(bvec.get(0).asBoolean()).isTrue();
+ assertThat(bvec.get(1).asBoolean()).isFalse();
+ assertThat(bvec.get(2).asBoolean()).isTrue();
+ assertThat(bvec.get(3).asBoolean()).isFalse();
+ assertThat(((FlexBuffers.TypedVector) bvec).getElemType()).isEqualTo(FlexBuffers.FBT_BOOL);
+
+ assertThat((float)m.get("foo").asFloat()).isEqualTo((float) 100);
+ assertThat(m.get("unknown").isNull()).isTrue();
+
+ // mymap vector
+ FlexBuffers.Map mymap = m.get("mymap").asMap();
+ // These should be equal by pointer equality, since key and value are shared.
+ assertThat(mymap.keys().get(0)).isEqualTo(m.keys().get(0));
+ assertThat(mymap.keys().get(0).toString()).isEqualTo("bar");
+ assertThat(mymap.values().get(0).asString()).isEqualTo(vec.get(1).asString());
+ assertThat(mymap.get("int").asInt()).isEqualTo(-120);
+ assertThat((float)mymap.get("float").asFloat()).isEqualTo(-123.0f);
+ assertThat(Arrays.equals(mymap.get("blob").asBlob().getBytes(), new byte[]{ 65, 67 })).isEqualTo(
+ true);
+ assertThat(mymap.get("blob").asBlob().toString()).isEqualTo("AC");
+ assertThat(mymap.get("blob").toString()).isEqualTo("\"AC\"");
+ }
+
+ @org.junit.Test public void testFlexBufferVectorStrings() {
+ FlexBuffersBuilder builder = new FlexBuffersBuilder(ByteBuffer.allocate(10000000));
+
+ int size = 3000;
+ StringBuilder sb = new StringBuilder();
+ for (int i=0; i< size; i++) {
+ sb.append("a");
+ }
+
+ String text = sb.toString();
+ assertThat(text.length()).isEqualTo(size);
+
+ int pos = builder.startVector();
+
+ for (int i=0; i<size; i++) {
+ builder.putString(text);
+ }
+
+ try {
+ builder.endVector(null, pos, true, false);
+ // this should raise an exception as
+ // typed vector of string was deprecated
+ assert false;
+ } catch(FlexBufferException fb) {
+ // no op
+ }
+ // we finish the vector again as non-typed
+ builder.endVector(null, pos, false, false);
+
+ ByteBuffer b = builder.finish();
+ Vector v = FlexBuffers.getRoot(b).asVector();
+
+ assertThat(v.size()).isEqualTo(size);
+ for (int i=0; i<size; i++) {
+ assertThat(v.get(i).asString().length()).isEqualTo(size);
+ assertThat(v.get(i).asString()).isEqualTo(text);
+ }
+ }
+
+ @org.junit.Test public void testDeprecatedTypedVectorString() {
+ // tests whether we are able to support reading deprecated typed vector string
+ // data is equivalent to [ "abc", "abc", "abc", "abc"]
+ byte[] data = new byte[] {0x03, 0x61, 0x62, 0x63, 0x00, 0x03, 0x61, 0x62, 0x63, 0x00,
+ 0x03, 0x61, 0x62, 0x63, 0x00, 0x03, 0x61, 0x62, 0x63, 0x00, 0x04, 0x14, 0x10,
+ 0x0c, 0x08, 0x04, 0x3c, 0x01};
+ Reference ref = FlexBuffers.getRoot(ByteBuffer.wrap(data));
+ assertThat(ref.getType()).isEqualTo(FlexBuffers.FBT_VECTOR_STRING_DEPRECATED);
+ assertThat(ref.isTypedVector()).isTrue();
+ Vector vec = ref.asVector();
+ for (int i=0; i< vec.size(); i++) {
+ assertThat("abc").isEqualTo(vec.get(i).asString());
+ }
+ }
+
+ @org.junit.Test public void testSingleElementBoolean() {
+ FlexBuffersBuilder builder = new FlexBuffersBuilder(ByteBuffer.allocate(100));
+ builder.putBoolean(true);
+ ByteBuffer b = builder.finish();
+ assertThat(FlexBuffers.getRoot(b).asBoolean()).isTrue();
+ }
+
+ @org.junit.Test public void testSingleElementByte() {
+ FlexBuffersBuilder builder = new FlexBuffersBuilder();
+ builder.putInt(10);
+ ByteBuffer b = builder.finish();
+ assertThat(10).isEqualTo(FlexBuffers.getRoot(b).asInt());
+ }
+
+ @org.junit.Test public void testSingleElementShort() {
+ FlexBuffersBuilder builder = new FlexBuffersBuilder();
+ builder.putInt(Short.MAX_VALUE);
+ ByteBuffer b = builder.finish();
+ assertThat(Short.MAX_VALUE).isEqualTo((short) FlexBuffers.getRoot(b).asInt());
+ }
+
+ @org.junit.Test public void testSingleElementInt() {
+ FlexBuffersBuilder builder = new FlexBuffersBuilder();
+ builder.putInt(Integer.MIN_VALUE);
+ ByteBuffer b = builder.finish();
+ assertThat(Integer.MIN_VALUE).isEqualTo(FlexBuffers.getRoot(b).asInt());
+ }
+
+ @org.junit.Test public void testSingleElementLong() {
+ FlexBuffersBuilder builder = new FlexBuffersBuilder();
+ builder.putInt(Long.MAX_VALUE);
+ ByteBuffer b = builder.finish();
+ assertThat(Long.MAX_VALUE).isEqualTo(FlexBuffers.getRoot(b).asLong());
+ }
+
+ @org.junit.Test public void testSingleElementFloat() {
+ FlexBuffersBuilder builder = new FlexBuffersBuilder();
+ builder.putFloat(Float.MAX_VALUE);
+ ByteBuffer b = builder.finish();
+ assertThat(Float.compare(Float.MAX_VALUE, (float) FlexBuffers.getRoot(b).asFloat())).isEqualTo(
+ 0);
+ }
+
+ @org.junit.Test public void testSingleElementDouble() {
+ FlexBuffersBuilder builder = new FlexBuffersBuilder();
+ builder.putFloat(Double.MAX_VALUE);
+ ByteBuffer b = builder.finish();
+ assertThat(Double.compare(Double.MAX_VALUE, FlexBuffers.getRoot(b).asFloat())).isEqualTo(0);
+ }
+
+ @org.junit.Test public void testSingleElementBigString() {
+ FlexBuffersBuilder builder = new FlexBuffersBuilder(ByteBuffer.allocate(10000));
+ StringBuilder sb = new StringBuilder();
+
+ for (int i=0; i< 3000; i++) {
+ sb.append("a");
+ }
+
+ builder.putString(sb.toString());
+ ByteBuffer b = builder.finish();
+
+ FlexBuffers.Reference r = FlexBuffers.getRoot(b);
+
+ assertThat(FlexBuffers.FBT_STRING).isEqualTo(r.getType());
+ assertThat(sb.toString()).isEqualTo(r.asString());
+ }
+
+ @org.junit.Test public void testSingleElementSmallString() {
+ FlexBuffersBuilder builder = new FlexBuffersBuilder(ByteBuffer.allocate(10000));
+
+ builder.putString("aa");
+ ByteBuffer b = builder.finish();
+ FlexBuffers.Reference r = FlexBuffers.getRoot(b);
+
+ assertThat(FlexBuffers.FBT_STRING).isEqualTo(r.getType());
+ assertThat("aa").isEqualTo(r.asString());
+ }
+
+ @org.junit.Test public void testSingleElementBlob() {
+ FlexBuffersBuilder builder = new FlexBuffersBuilder();
+ builder.putBlob(new byte[]{5, 124, 118, -1});
+ ByteBuffer b = builder.finish();
+ FlexBuffers.Reference r = FlexBuffers.getRoot(b);
+ byte[] result = r.asBlob().getBytes();
+ assertThat((byte)5).isEqualTo(result[0]);
+ assertThat((byte)124).isEqualTo(result[1]);
+ assertThat((byte)118).isEqualTo(result[2]);
+ assertThat((byte)-1).isEqualTo(result[3]);
+ }
+
+ @org.junit.Test public void testSingleElementLongBlob() {
+
+ // verifies blobs of up to 2^16 in length
+ for (int i = 2; i <= 1<<16; i = i<<1) {
+ byte[] input = new byte[i-1];
+ for (int index = 0; index < input.length; index++) {
+ input[index] = (byte)(index % 64);
+ }
+
+ FlexBuffersBuilder builder = new FlexBuffersBuilder();
+ builder.putBlob(input);
+ ByteBuffer b = builder.finish();
+ FlexBuffers.Reference r = FlexBuffers.getRoot(b);
+ byte[] result = r.asBlob().getBytes();
+
+ for (int index = 0; index < input.length; index++) {
+ assertThat((byte)(index % 64)).isEqualTo(result[index]);
+ }
+ }
+ }
+
+ @org.junit.Test public void testSingleElementUByte() {
+ FlexBuffersBuilder builder = new FlexBuffersBuilder();
+ builder.putUInt(0xFF);
+ ByteBuffer b = builder.finish();
+ FlexBuffers.Reference r = FlexBuffers.getRoot(b);
+ assertThat(255).isEqualTo((int)r.asUInt());
+ }
+
+ @org.junit.Test public void testSingleElementUShort() {
+ FlexBuffersBuilder builder = new FlexBuffersBuilder();
+ builder.putUInt(0xFFFF);
+ ByteBuffer b = builder.finish();
+ FlexBuffers.Reference r = FlexBuffers.getRoot(b);
+ assertThat(65535).isEqualTo((int)r.asUInt());
+ }
+
+ @org.junit.Test public void testSingleElementUInt() {
+ FlexBuffersBuilder builder = new FlexBuffersBuilder();
+ builder.putUInt(0xFFFF_FFFFL);
+ ByteBuffer b = builder.finish();
+ FlexBuffers.Reference r = FlexBuffers.getRoot(b);
+ assertThat(4294967295L).isEqualTo(r.asUInt());
+ }
+
+ @org.junit.Test public void testSingleFixedTypeVector() {
+
+ int[] ints = new int[]{5, 124, 118, -1};
+ float[] floats = new float[]{5.5f, 124.124f, 118.118f, -1.1f};
+ String[] strings = new String[]{"This", "is", "a", "typed", "array"};
+ boolean[] booleans = new boolean[]{false, true, true, false};
+
+
+ FlexBuffersBuilder builder = new FlexBuffersBuilder(ByteBuffer.allocate(512),
+ FlexBuffersBuilder.BUILDER_FLAG_NONE);
+
+ int mapPos = builder.startMap();
+
+ int vecPos = builder.startVector();
+ for (final int i : ints) {
+ builder.putInt(i);
+ }
+ builder.endVector("ints", vecPos, true, false);
+
+ vecPos = builder.startVector();
+ for (final float i : floats) {
+ builder.putFloat(i);
+ }
+ builder.endVector("floats", vecPos, true, false);
+
+ vecPos = builder.startVector();
+ for (final boolean i : booleans) {
+ builder.putBoolean(i);
+ }
+ builder.endVector("booleans", vecPos, true, false);
+
+ builder.endMap(null, mapPos);
+
+
+ ByteBuffer b = builder.finish();
+ FlexBuffers.Reference r = FlexBuffers.getRoot(b);
+ assert(r.asMap().get("ints").isTypedVector());
+ assert(r.asMap().get("floats").isTypedVector());
+ assert(r.asMap().get("booleans").isTypedVector());
+ }
+
+ @org.junit.Test public void testSingleElementVector() {
+ FlexBuffersBuilder b = new FlexBuffersBuilder();
+
+ int vecPos = b.startVector();
+ b.putInt(99);
+ b.putString("wow");
+ b.putNull();
+ int vecpos2 = b.startVector();
+ b.putInt(99);
+ b.putString("wow");
+ b.putNull();
+ b.endVector(null, vecpos2, false, false);
+ b.endVector(null, vecPos, false, false);
+ b.finish();
+
+ FlexBuffers.Reference r = FlexBuffers.getRoot(b.getBuffer());
+ assertThat(FlexBuffers.FBT_VECTOR).isEqualTo(r.getType());
+ FlexBuffers.Vector vec = FlexBuffers.getRoot(b.getBuffer()).asVector();
+ assertThat(4).isEqualTo(vec.size());
+ assertThat(99).isEqualTo(vec.get(0).asInt());
+ assertThat("wow").isEqualTo(vec.get(1).asString());
+ assertThat(true).isEqualTo(vec.get(2).isNull());
+ assertThat("[ 99, \"wow\", null ]").isEqualTo(vec.get(3).toString());
+ assertThat("[ 99, \"wow\", null, [ 99, \"wow\", null ] ]").isEqualTo(
+ FlexBuffers.getRoot(b.getBuffer()).toString());
+ }
+
+ @org.junit.Test public void testSingleElementMap() {
+ FlexBuffersBuilder b = new FlexBuffersBuilder();
+
+ int mapPost = b.startMap();
+ b.putInt("myInt", 0x7fffffbbbfffffffL);
+ b.putString("myString", "wow");
+ b.putString("myString2", "incredible");
+ b.putNull("myNull");
+ int start = b.startVector();
+ b.putInt(99);
+ b.putString("wow");
+ b.endVector("myVec", start, false, false);
+
+ b.putFloat("double", 0x1.ffffbbbffffffP+1023);
+ b.endMap(null, mapPost);
+ b.finish();
+
+ FlexBuffers.Reference r = FlexBuffers.getRoot(b.getBuffer());
+ assertThat(FlexBuffers.FBT_MAP).isEqualTo(r.getType());
+ FlexBuffers.Map map = FlexBuffers.getRoot(b.getBuffer()).asMap();
+ assertThat(6).isEqualTo(map.size());
+ assertThat(0x7fffffbbbfffffffL).isEqualTo(map.get("myInt").asLong());
+ assertThat("wow").isEqualTo(map.get("myString").asString());
+ assertThat("incredible").isEqualTo(map.get("myString2").asString());
+ assertThat(true).isEqualTo(map.get("myNull").isNull());
+ assertThat(99).isEqualTo(map.get("myVec").asVector().get(0).asInt());
+ assertThat("wow").isEqualTo(map.get("myVec").asVector().get(1).asString());
+ assertThat(Double.compare(0x1.ffffbbbffffffP+1023, map.get("double").asFloat())).isEqualTo(0);
+ assertThat(
+ "{ \"double\" : 1.7976894783391937E308, \"myInt\" : 9223371743723257855, \"myNull\" : null, \"myString\" : \"wow\", \"myString2\" : \"incredible\", \"myVec\" : [ 99, \"wow\" ] }").isEqualTo(
+ FlexBuffers.getRoot(b.getBuffer()).toString());
+ }
+
+ @org.junit.Test public void testFlexBuferEmpty() {
+ FlexBuffers.Blob blob = FlexBuffers.Blob.empty();
+ FlexBuffers.Map ary = FlexBuffers.Map.empty();
+ FlexBuffers.Vector map = FlexBuffers.Vector.empty();
+ FlexBuffers.TypedVector typedAry = FlexBuffers.TypedVector.empty();
+ assertThat(blob.size()).isEqualTo(0);
+ assertThat(map.size()).isEqualTo(0);
+ assertThat(ary.size()).isEqualTo(0);
+ assertThat(typedAry.size()).isEqualTo(0);
+ }
+
+ @org.junit.Test public void testHashMapToMap() {
+ int entriesCount = 12;
+
+ HashMap<String, String> source = new HashMap<>();
+ for (int i = 0; i < entriesCount; i++) {
+ source.put("foo_param_" + i, "foo_value_" + i);
+ }
+
+ FlexBuffersBuilder builder = new FlexBuffersBuilder(1000);
+ int mapStart = builder.startMap();
+ for (Map.Entry<String, String> entry : source.entrySet()) {
+ builder.putString(entry.getKey(), entry.getValue());
+ }
+ builder.endMap(null, mapStart);
+ ByteBuffer bb = builder.finish();
+ bb.rewind();
+
+ FlexBuffers.Reference rootReference = FlexBuffers.getRoot(bb);
+
+ assertThat(rootReference.isMap()).isTrue();
+
+ FlexBuffers.Map flexMap = rootReference.asMap();
+
+ FlexBuffers.KeyVector keys = flexMap.keys();
+ FlexBuffers.Vector values = flexMap.values();
+
+ assertThat(entriesCount).isEqualTo(keys.size());
+ assertThat(entriesCount).isEqualTo(values.size());
+
+ HashMap<String, String> result = new HashMap<>();
+ for (int i = 0; i < keys.size(); i++) {
+ result.put(keys.get(i).toString(), values.get(i).asString());
+ }
+
+ assertThat(source).isEqualTo(result);
+ }
+
+ @org.junit.Test public void testBuilderGrowth() {
+ FlexBuffersBuilder builder = new FlexBuffersBuilder();
+ String someString = "This is a small string";
+ builder.putString(someString);
+ ByteBuffer b = builder.finish();
+ assertThat(someString).isEqualTo(FlexBuffers.getRoot(b).asString());
+
+ FlexBuffersBuilder failBuilder = new FlexBuffersBuilder(ByteBuffer.allocate(1));
+ failBuilder.putString(someString);
+ }
+
+ @org.junit.Test
+ public void testFlexBuffersUtf8Map() {
+ FlexBuffersBuilder builder = new FlexBuffersBuilder(ByteBuffer.allocate(512),
+ FlexBuffersBuilder.BUILDER_FLAG_SHARE_KEYS_AND_STRINGS);
+
+ String key0 = "đ¨ face1";
+ String key1 = "đŠ face2";
+ String key2 = "đ¨ face3";
+ String key3 = "trademark ®";
+ String key4 = "€ euro";
+ String utf8keys[] = { "đ¨ face1", "đŠ face2", "đ¨ face3", "trademark ®", "€ euro"};
+
+ int map = builder.startMap();
+
+ for (int i=0; i< utf8keys.length; i++) {
+ builder.putString(utf8keys[i], utf8keys[i]); // Testing key and string reuse.
+ }
+ builder.endMap(null, map);
+ builder.finish();
+
+ FlexBuffers.Map m = FlexBuffers.getRoot(builder.getBuffer()).asMap();
+
+ assertThat(m.size()).isEqualTo(5);
+
+ KeyVector kv = m.keys();
+ for (int i=0; i< utf8keys.length; i++) {
+ assertThat(kv.get(i).toString()).isEqualTo(m.get(i).asString());
+ }
+
+ assertThat(m.get(key0).asString()).isEqualTo(utf8keys[0]);
+ assertThat(m.get(key1).asString()).isEqualTo(utf8keys[1]);
+ assertThat(m.get(key2).asString()).isEqualTo(utf8keys[2]);
+ assertThat(m.get(key3).asString()).isEqualTo(utf8keys[3]);
+ assertThat(m.get(key4).asString()).isEqualTo(utf8keys[4]);
+ }
+
+ @org.junit.Test public void testFlexBuffersMapLookup() {
+ FlexBuffersBuilder builder = new FlexBuffersBuilder(ByteBuffer.allocate(512),
+ FlexBuffersBuilder.BUILDER_FLAG_SHARE_KEYS_AND_STRINGS);
+
+ String key0 = "123";
+ String key1 = "1234";
+ String key2 = "12345";
+ String[] keys = new String[]{key0, key1, key2};
+
+ int map = builder.startMap();
+
+ for (int i=0; i< keys.length; i++) {
+ builder.putString(keys[i], keys[i]); // Testing key and string reuse.
+ }
+ builder.endMap(null, map);
+ builder.finish();
+
+ FlexBuffers.Map m = FlexBuffers.getRoot(builder.getBuffer()).asMap();
+ for (int i=0; i< keys.length; i++) {
+ assertThat(m.get(keys[i]).asString()).isEqualTo(keys[i]);
+ assertThat(m.get(keys[i].getBytes(StandardCharsets.UTF_8)).asString()).isEqualTo(keys[i]);
+ }
+ }
+
+ @org.junit.Test public void TestDictionaryLookup() {
+ FlatBufferBuilder fbb = new FlatBufferBuilder(16);
+ int lfIndex = LongFloatEntry.createLongFloatEntry(fbb, 0, 99);
+ int vectorEntriesIdx = LongFloatMap.createEntriesVector(fbb, new int[] { lfIndex });
+ int rootIdx = LongFloatMap.createLongFloatMap(fbb, vectorEntriesIdx);
+
+ LongFloatMap.finishLongFloatMapBuffer(fbb, rootIdx);
+ LongFloatMap map = LongFloatMap.getRootAsLongFloatMap(fbb.dataBuffer());
+ assertThat(map.entriesLength()).isEqualTo(1);
+
+ LongFloatEntry e = map.entries(0);
+ assertThat(e.key()).isEqualTo(0L);
+ assertThat(e.value()).isEqualTo(99.0f);
+
+ LongFloatEntry e2 = map.entriesByKey(0);
+ assertThat(e2.key()).isEqualTo(0L);
+ assertThat(e2.value()).isEqualTo(99.0f);
+ }
+
+ @org.junit.Test public void TestVectorOfBytes() {
+ FlatBufferBuilder fbb = new FlatBufferBuilder(16);
+ int str = fbb.createString("ByteMonster");
+ byte[] data = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ int offset = Monster.createInventoryVector(fbb, data);
+ Monster.startMonster(fbb);
+ Monster.addName(fbb, str);
+ Monster.addInventory(fbb, offset);
+ int monster1 = Monster.endMonster(fbb);
+ Monster.finishMonsterBuffer(fbb, monster1);
+ Monster monsterObject = Monster.getRootAsMonster(fbb.dataBuffer());
+
+ assertThat(monsterObject.inventoryLength()).isEqualTo(data.length);
+ assertThat((Integer) monsterObject.inventory(4)).isEqualTo((int) data[4]);
+ assertThat(ByteBuffer.wrap(data)).isEqualTo(monsterObject.inventoryAsByteBuffer());
+
+ fbb.clear();
+ ByteBuffer bb = ByteBuffer.wrap(data);
+ offset = fbb.createByteVector(bb);
+ str = fbb.createString("ByteMonster");
+ Monster.startMonster(fbb);
+ Monster.addName(fbb, str);
+ Monster.addInventory(fbb, offset);
+ monster1 = Monster.endMonster(fbb);
+ Monster.finishMonsterBuffer(fbb, monster1);
+ Monster monsterObject2 = Monster.getRootAsMonster(fbb.dataBuffer());
+
+ assertThat(monsterObject2.inventoryLength()).isEqualTo(data.length);
+ for (int i = 0; i < data.length; i++) {
+ assertThat((Integer) monsterObject2.inventory(i)).isEqualTo((int) bb.get(i));
+ }
+
+ fbb.clear();
+ offset = fbb.createByteVector(data, 3, 4);
+ str = fbb.createString("ByteMonster");
+ Monster.startMonster(fbb);
+ Monster.addName(fbb, str);
+ Monster.addInventory(fbb, offset);
+ monster1 = Monster.endMonster(fbb);
+ Monster.finishMonsterBuffer(fbb, monster1);
+ Monster monsterObject3 = Monster.getRootAsMonster(fbb.dataBuffer());
+
+ assertThat(monsterObject3.inventoryLength()).isEqualTo(4);
+ assertThat((Integer) monsterObject3.inventory(0)).isEqualTo((int) data[3]);
+
+ fbb.clear();
+ bb = ByteBuffer.wrap(data);
+ offset = Monster.createInventoryVector(fbb, bb);
+ str = fbb.createString("ByteMonster");
+ Monster.startMonster(fbb);
+ Monster.addName(fbb, str);
+ Monster.addInventory(fbb, offset);
+ monster1 = Monster.endMonster(fbb);
+ Monster.finishMonsterBuffer(fbb, monster1);
+ Monster monsterObject4 = Monster.getRootAsMonster(fbb.dataBuffer());
+
+ assertThat(monsterObject4.inventoryLength()).isEqualTo(data.length);
+ assertThat((Integer) monsterObject4.inventory(8)).isEqualTo((int) 8);
+
+ fbb.clear();
+ byte[] largeData = new byte[1024];
+ offset = fbb.createByteVector(largeData);
+ str = fbb.createString("ByteMonster");
+ Monster.startMonster(fbb);
+ Monster.addName(fbb, str);
+ Monster.addInventory(fbb, offset);
+ monster1 = Monster.endMonster(fbb);
+ Monster.finishMonsterBuffer(fbb, monster1);
+ Monster monsterObject5 = Monster.getRootAsMonster(fbb.dataBuffer());
+
+ assertThat(monsterObject5.inventoryLength()).isEqualTo(largeData.length);
+ assertThat((Integer) monsterObject5.inventory(25)).isEqualTo((int) largeData[25]);
+
+ fbb.clear();
+ bb = ByteBuffer.wrap(largeData);
+ bb.position(512);
+ ByteBuffer bb2 = bb.slice();
+ assertThat(bb2.arrayOffset()).isEqualTo(512);
+ offset = fbb.createByteVector(bb2);
+ str = fbb.createString("ByteMonster");
+ Monster.startMonster(fbb);
+ Monster.addName(fbb, str);
+ Monster.addInventory(fbb, offset);
+ monster1 = Monster.endMonster(fbb);
+ Monster.finishMonsterBuffer(fbb, monster1);
+ Monster monsterObject6 = Monster.getRootAsMonster(fbb.dataBuffer());
+
+ assertThat(monsterObject6.inventoryLength()).isEqualTo(512);
+ assertThat((Integer) monsterObject6.inventory(0)).isEqualTo((int) largeData[512]);
+
+ fbb.clear();
+ bb = ByteBuffer.wrap(largeData);
+ bb.limit(256);
+ offset = fbb.createByteVector(bb);
+ str = fbb.createString("ByteMonster");
+ Monster.startMonster(fbb);
+ Monster.addName(fbb, str);
+ Monster.addInventory(fbb, offset);
+ monster1 = Monster.endMonster(fbb);
+ Monster.finishMonsterBuffer(fbb, monster1);
+ Monster monsterObject7 = Monster.getRootAsMonster(fbb.dataBuffer());
+
+ assertThat(monsterObject7.inventoryLength()).isEqualTo(256);
+
+ fbb.clear();
+ bb = ByteBuffer.allocateDirect(2048);
+ offset = fbb.createByteVector(bb);
+ str = fbb.createString("ByteMonster");
+ Monster.startMonster(fbb);
+ Monster.addName(fbb, str);
+ Monster.addInventory(fbb, offset);
+ monster1 = Monster.endMonster(fbb);
+ Monster.finishMonsterBuffer(fbb, monster1);
+ Monster monsterObject8 = Monster.getRootAsMonster(fbb.dataBuffer());
+
+ assertThat(monsterObject8.inventoryLength()).isEqualTo(2048);
+ }
+
+ @org.junit.Test public void TestSharedStringPool() {
+ FlatBufferBuilder fb = new FlatBufferBuilder(1);
+ String testString = "My string";
+ int offset = fb.createSharedString(testString);
+ for (int i=0; i< 10; i++) {
+ assertThat(offset).isEqualTo(fb.createSharedString(testString));
+ }
+ }
+
+ @org.junit.Test public void TestScalarOptional() {
+ FlatBufferBuilder fbb = new FlatBufferBuilder(1);
+ ScalarStuff.startScalarStuff(fbb);
+ int pos = ScalarStuff.endScalarStuff(fbb);
+ fbb.finish(pos);
+
+ ScalarStuff scalarStuff = ScalarStuff.getRootAsScalarStuff(fbb.dataBuffer());
+ assertThat(scalarStuff.justI8()).isEqualTo((byte)0);
+ assertThat(scalarStuff.maybeI8()).isEqualTo((byte)0);
+ assertThat(scalarStuff.defaultI8()).isEqualTo((byte)42);
+ assertThat(scalarStuff.justU8()).isEqualTo(0);
+ assertThat(scalarStuff.maybeU8()).isEqualTo(0);
+ assertThat(scalarStuff.defaultU8()).isEqualTo(42);
+ assertThat(scalarStuff.justI16()).isEqualTo((short)0);
+ assertThat(scalarStuff.maybeI16()).isEqualTo((short)0);
+ assertThat(scalarStuff.defaultI16()).isEqualTo((short)42);
+ assertThat(scalarStuff.justU16()).isEqualTo(0);
+ assertThat(scalarStuff.maybeU16()).isEqualTo(0);
+ assertThat(scalarStuff.defaultU16()).isEqualTo(42);
+ assertThat(scalarStuff.justI32()).isEqualTo(0);
+ assertThat(scalarStuff.maybeI32()).isEqualTo(0);
+ assertThat(scalarStuff.defaultI32()).isEqualTo(42);
+ assertThat(scalarStuff.justU32()).isEqualTo(0L);
+ assertThat(scalarStuff.maybeU32()).isEqualTo(0L);
+ assertThat(scalarStuff.defaultU32()).isEqualTo(42L);
+ assertThat(scalarStuff.justI64()).isEqualTo(0L);
+ assertThat(scalarStuff.maybeI64()).isEqualTo(0L);
+ assertThat(scalarStuff.defaultI64()).isEqualTo(42L);
+ assertThat(scalarStuff.justU64()).isEqualTo(0L);
+ assertThat(scalarStuff.maybeU64()).isEqualTo(0L);
+ assertThat(scalarStuff.defaultU64()).isEqualTo(42L);
+ assertThat(scalarStuff.justF32()).isEqualTo(0.0f);
+ assertThat(scalarStuff.maybeF32()).isEqualTo(0f);
+ assertThat(scalarStuff.defaultF32()).isEqualTo(42.0f);
+ assertThat(scalarStuff.justF64()).isEqualTo(0.0);
+ assertThat(scalarStuff.maybeF64()).isEqualTo(0.0);
+ assertThat(scalarStuff.defaultF64()).isEqualTo(42.0);
+ assertThat(scalarStuff.justBool()).isFalse();
+ assertThat(scalarStuff.maybeBool()).isFalse();
+ assertThat(scalarStuff.defaultBool()).isTrue();
+ assertThat(scalarStuff.justEnum()).isEqualTo(OptionalByte.None);
+ assertThat(scalarStuff.maybeEnum()).isEqualTo(OptionalByte.None);
+ assertThat(scalarStuff.defaultEnum()).isEqualTo(OptionalByte.One);
+
+ assertThat(scalarStuff.hasMaybeI8()).isFalse();
+ assertThat(scalarStuff.hasMaybeI16()).isFalse();
+ assertThat(scalarStuff.hasMaybeI32()).isFalse();
+ assertThat(scalarStuff.hasMaybeI64()).isFalse();
+ assertThat(scalarStuff.hasMaybeU8()).isFalse();
+ assertThat(scalarStuff.hasMaybeU16()).isFalse();
+ assertThat(scalarStuff.hasMaybeU32()).isFalse();
+ assertThat(scalarStuff.hasMaybeU64()).isFalse();
+ assertThat(scalarStuff.hasMaybeF32()).isFalse();
+ assertThat(scalarStuff.hasMaybeF64()).isFalse();
+ assertThat(scalarStuff.hasMaybeBool()).isFalse();
+ assertThat(scalarStuff.hasMaybeEnum()).isFalse();
+
+ fbb.clear();
+
+ ScalarStuff.startScalarStuff(fbb);
+ ScalarStuff.addJustI8(fbb, (byte)5);
+ ScalarStuff.addMaybeI8(fbb, (byte)5);
+ ScalarStuff.addDefaultI8(fbb, (byte)5);
+ ScalarStuff.addJustU8(fbb, 6);
+ ScalarStuff.addMaybeU8(fbb, 6);
+ ScalarStuff.addDefaultU8(fbb, 6);
+ ScalarStuff.addJustI16(fbb, (short)7);
+ ScalarStuff.addMaybeI16(fbb, (short)7);
+ ScalarStuff.addDefaultI16(fbb, (short)7);
+ ScalarStuff.addJustU16(fbb, 8);
+ ScalarStuff.addMaybeU16(fbb, 8);
+ ScalarStuff.addDefaultU16(fbb, 8);
+ ScalarStuff.addJustI32(fbb, 9);
+ ScalarStuff.addMaybeI32(fbb, 9);
+ ScalarStuff.addDefaultI32(fbb, 9);
+ ScalarStuff.addJustU32(fbb, (long)10);
+ ScalarStuff.addMaybeU32(fbb, (long)10);
+ ScalarStuff.addDefaultU32(fbb, (long)10);
+ ScalarStuff.addJustI64(fbb, 11L);
+ ScalarStuff.addMaybeI64(fbb, 11L);
+ ScalarStuff.addDefaultI64(fbb, 11L);
+ ScalarStuff.addJustU64(fbb, 12L);
+ ScalarStuff.addMaybeU64(fbb, 12L);
+ ScalarStuff.addDefaultU64(fbb, 12L);
+ ScalarStuff.addJustF32(fbb, 13.0f);
+ ScalarStuff.addMaybeF32(fbb, 13.0f);
+ ScalarStuff.addDefaultF32(fbb, 13.0f);
+ ScalarStuff.addJustF64(fbb, 14.0);
+ ScalarStuff.addMaybeF64(fbb, 14.0);
+ ScalarStuff.addDefaultF64(fbb, 14.0);
+ ScalarStuff.addJustBool(fbb, true);
+ ScalarStuff.addMaybeBool(fbb, true);
+ ScalarStuff.addDefaultBool(fbb, true);
+ ScalarStuff.addJustEnum(fbb, OptionalByte.Two);
+ ScalarStuff.addMaybeEnum(fbb, OptionalByte.Two);
+ ScalarStuff.addDefaultEnum(fbb, OptionalByte.Two);
+
+ pos = ScalarStuff.endScalarStuff(fbb);
+
+ fbb.finish(pos);
+
+ scalarStuff = ScalarStuff.getRootAsScalarStuff(fbb.dataBuffer());
+
+ assertThat(scalarStuff.justI8()).isEqualTo((byte)5);
+ assertThat(scalarStuff.maybeI8()).isEqualTo((byte)5);
+ assertThat(scalarStuff.defaultI8()).isEqualTo((byte)5);
+ assertThat(scalarStuff.justU8()).isEqualTo(6);
+ assertThat(scalarStuff.maybeU8()).isEqualTo(6);
+ assertThat(scalarStuff.defaultU8()).isEqualTo(6);
+ assertThat(scalarStuff.justI16()).isEqualTo((short)7);
+ assertThat(scalarStuff.maybeI16()).isEqualTo((short)7);
+ assertThat(scalarStuff.defaultI16()).isEqualTo((short)7);
+ assertThat(scalarStuff.justU16()).isEqualTo(8);
+ assertThat(scalarStuff.maybeU16()).isEqualTo(8);
+ assertThat(scalarStuff.defaultU16()).isEqualTo(8);
+ assertThat(scalarStuff.justI32()).isEqualTo(9);
+ assertThat(scalarStuff.maybeI32()).isEqualTo(9);
+ assertThat(scalarStuff.defaultI32()).isEqualTo(9);
+ assertThat(scalarStuff.justU32()).isEqualTo(10L);
+ assertThat(scalarStuff.maybeU32()).isEqualTo(10L);
+ assertThat(scalarStuff.defaultU32()).isEqualTo(10L);
+ assertThat(scalarStuff.justI64()).isEqualTo(11L);
+ assertThat(scalarStuff.maybeI64()).isEqualTo(11L);
+ assertThat(scalarStuff.defaultI64()).isEqualTo(11L);
+ assertThat(scalarStuff.justU64()).isEqualTo(12L);
+ assertThat(scalarStuff.maybeU64()).isEqualTo(12L);
+ assertThat(scalarStuff.defaultU64()).isEqualTo(12L);
+ assertThat(scalarStuff.justF32()).isEqualTo(13.0f);
+ assertThat(scalarStuff.maybeF32()).isEqualTo(13.0f);
+ assertThat(scalarStuff.defaultF32()).isEqualTo(13.0f);
+ assertThat(scalarStuff.justF64()).isEqualTo(14.0);
+ assertThat(scalarStuff.maybeF64()).isEqualTo(14.0);
+ assertThat(scalarStuff.defaultF64()).isEqualTo(14.0);
+ assertThat(scalarStuff.justBool()).isTrue();
+ assertThat(scalarStuff.maybeBool()).isTrue();
+ assertThat(scalarStuff.defaultBool()).isTrue();
+ assertThat(scalarStuff.justEnum()).isEqualTo(OptionalByte.Two);
+ assertThat(scalarStuff.maybeEnum()).isEqualTo(OptionalByte.Two);
+ assertThat(scalarStuff.defaultEnum()).isEqualTo(OptionalByte.Two);
+
+ assertThat(scalarStuff.hasMaybeI8()).isTrue();
+ assertThat(scalarStuff.hasMaybeI16()).isTrue();
+ assertThat(scalarStuff.hasMaybeI32()).isTrue();
+ assertThat(scalarStuff.hasMaybeI64()).isTrue();
+ assertThat(scalarStuff.hasMaybeU8()).isTrue();
+ assertThat(scalarStuff.hasMaybeU16()).isTrue();
+ assertThat(scalarStuff.hasMaybeU32()).isTrue();
+ assertThat(scalarStuff.hasMaybeU64()).isTrue();
+ assertThat(scalarStuff.hasMaybeF32()).isTrue();
+ assertThat(scalarStuff.hasMaybeF64()).isTrue();
+ assertThat(scalarStuff.hasMaybeBool()).isTrue();
+ assertThat(scalarStuff.hasMaybeEnum()).isTrue();
+ }
+
+ static void TestObject(MonsterT monster) {
+ assertThat(monster.getHp()).isEqualTo((short) 80);
+ // default
+ assertThat(monster.getMana()).isEqualTo((short) 150);
+
+ assertThat(monster.getName()).isEqualTo("MyMonster");
+ assertThat(monster.getColor()).isEqualTo((Integer) Color.Blue);
+ // monster.friendly() // can't access, deprecated
+
+ Vec3T pos = monster.getPos();
+ assertThat(pos.getX()).isEqualTo(1.0f);
+ assertThat(pos.getY()).isEqualTo(2.0f);
+ assertThat(pos.getZ()).isEqualTo(3.0f);
+ assertThat(pos.getTest1()).isEqualTo(3.0);
+ // issue: int != byte
+ assertThat(pos.getTest2()).isEqualTo((int) Color.Green);
+ TestT t = pos.getTest3();
+ assertThat(t.getA()).isEqualTo((short) 5);
+ assertThat(t.getB()).isEqualTo((byte) 6);
+
+ assertThat(monster.getTest().getType()).isEqualTo((byte) Any.Monster);
+ MonsterT monster2 = (MonsterT) monster.getTest().getValue();
+ assertThat(monster2 != null).isTrue();
+ assertThat(monster2.getName()).isEqualTo("Fred");
+
+ int[] inv = monster.getInventory();
+ assertThat(inv.length).isEqualTo(5);
+ int[] expInv = {0, 1, 2, 3, 4};
+ for (int i = 0; i < inv.length; i++)
+ assertThat(expInv[i]).isEqualTo(inv[i]);
+
+ TestT[] test4 = monster.getTest4();
+ TestT test_0 = test4[0];
+ TestT test_1 = test4[1];
+ assertThat(test4.length).isEqualTo(2);
+ assertThat(test_0.getA()).isEqualTo((short) 10);
+ assertThat(test_0.getB()).isEqualTo((byte) 20);
+ assertThat(test_1.getA()).isEqualTo((short) 30);
+ assertThat(test_1.getB()).isEqualTo((byte) 40);
+
+ String[] testarrayofstring = monster.getTestarrayofstring();
+ assertThat(testarrayofstring.length).isEqualTo(2);
+ assertThat(testarrayofstring[0]).isEqualTo("test1");
+ assertThat(testarrayofstring[1]).isEqualTo("test2");
+
+ MonsterT[] testarrayoftables = monster.getTestarrayoftables();
+ assertThat(testarrayoftables.length).isEqualTo(0);
+
+ MonsterT enemy = monster.getEnemy();
+ assertThat(enemy != null).isTrue();
+ assertThat(enemy.getName()).isEqualTo("Fred");
+
+ int[] testnestedflatbuffer = monster.getTestnestedflatbuffer();
+ assertThat(testnestedflatbuffer.length).isEqualTo(0);
+
+ assertThat(monster.getTestempty() == null).isTrue();
+
+ assertThat(monster.getTestbool()).isTrue();
+
+ boolean[] testarrayofbools = monster.getTestarrayofbools();
+ assertThat(testarrayofbools.length).isEqualTo(3);
+ assertThat(testarrayofbools[0]).isTrue();
+ assertThat(testarrayofbools[1]).isFalse();
+ assertThat(testarrayofbools[2]).isTrue();
+
+ assertThat(monster.getTestf()).isEqualTo(3.14159f);
+ assertThat(monster.getTestf2()).isEqualTo(3.0f);
+ assertThat(monster.getTestf3()).isEqualTo(0.0f);
+ assertThat(monster.getTestf3()).isEqualTo(0.0f);
+
+ AbilityT[] testarrayofsortedstruct = monster.getTestarrayofsortedstruct();
+ assertThat(testarrayofsortedstruct.length).isEqualTo(3);
+ assertThat(testarrayofsortedstruct[0].getId()).isEqualTo((long) 0);
+ assertThat(testarrayofsortedstruct[1].getId()).isEqualTo((long) 1);
+ assertThat(testarrayofsortedstruct[2].getId()).isEqualTo((long) 5);
+ assertThat(testarrayofsortedstruct[0].getDistance()).isEqualTo((long) 45);
+ assertThat(testarrayofsortedstruct[1].getDistance()).isEqualTo((long) 21);
+ assertThat(testarrayofsortedstruct[2].getDistance()).isEqualTo((long) 12);
+
+ int[] flex = monster.getFlex();
+ assertThat(flex.length).isEqualTo(0);
+
+ long[] vectorOfLongs = monster.getVectorOfLongs();
+ assertThat(vectorOfLongs.length).isEqualTo(5);
+ long l = 1;
+ for (int i = 0; i < vectorOfLongs.length; i++) {
+ assertThat(vectorOfLongs[i]).isEqualTo(l);
+ l *= 100;
+ }
+
+ double[] vectorOfDoubles = monster.getVectorOfDoubles();
+ assertThat(vectorOfDoubles.length).isEqualTo(3);
+ assertThat(vectorOfDoubles[0]).isEqualTo(-1.7976931348623157E308);
+ assertThat(vectorOfDoubles[1]).isEqualTo(0.0);
+ assertThat(vectorOfDoubles[2]).isEqualTo(1.7976931348623157E308);
+
+ assertThat(monster.getParentNamespaceTest() == null).isTrue();
+ ReferrableT[] vectorOfReferrables = monster.getVectorOfReferrables();
+ assertThat(vectorOfReferrables.length).isEqualTo(0);
+
+ assertThat(monster.getSignedEnum()).isEqualTo((byte) -1);
+ }
+
+ static void TestPackUnpack(ByteBuffer bb) {
+ Monster m = Monster.getRootAsMonster(bb);
+ MonsterT mObject = m.unpack();
+ TestObject(mObject);
+ FlatBufferBuilder fbb = new FlatBufferBuilder();
+ int monster = Monster.pack(fbb, mObject);
+ Monster.finishMonsterBuffer(fbb, monster);
+ TestBuffer(fbb.dataBuffer());
+
+ byte[] bytes = mObject.serializeToBinary();
+ MonsterT newMonsterT = MonsterT.deserializeFromBinary(bytes);
+ TestObject(newMonsterT);
+ }
+}
diff --git a/java/src/test/java/MyGame b/java/src/test/java/MyGame
new file mode 120000
index 0000000..0ba918e
--- /dev/null
+++ b/java/src/test/java/MyGame
@@ -0,0 +1 @@
+../../../../tests/MyGame
\ No newline at end of file
diff --git a/java/src/test/java/NamespaceA b/java/src/test/java/NamespaceA
new file mode 120000
index 0000000..37a8d89
--- /dev/null
+++ b/java/src/test/java/NamespaceA
@@ -0,0 +1 @@
+../../../../tests/namespace_test/NamespaceA
\ No newline at end of file
diff --git a/java/src/test/java/NamespaceC b/java/src/test/java/NamespaceC
new file mode 120000
index 0000000..c1e44a8
--- /dev/null
+++ b/java/src/test/java/NamespaceC
@@ -0,0 +1 @@
+../../../../tests/namespace_test/NamespaceC
\ No newline at end of file
diff --git a/java/src/test/java/optional_scalars b/java/src/test/java/optional_scalars
new file mode 120000
index 0000000..44a35f9
--- /dev/null
+++ b/java/src/test/java/optional_scalars
@@ -0,0 +1 @@
+../../../../tests/optional_scalars
\ No newline at end of file
diff --git a/java/src/test/java/union_vector b/java/src/test/java/union_vector
new file mode 120000
index 0000000..cc82221
--- /dev/null
+++ b/java/src/test/java/union_vector
@@ -0,0 +1 @@
+../../../../tests/union_vector
\ No newline at end of file
diff --git a/java/src/test/resources/monsterdata_test.mon b/java/src/test/resources/monsterdata_test.mon
new file mode 100644
index 0000000..da0ed86
--- /dev/null
+++ b/java/src/test/resources/monsterdata_test.mon
Binary files differ
diff --git a/kotlin/benchmark/build.gradle.kts b/kotlin/benchmark/build.gradle.kts
index 2294e4c..8595c02 100644
--- a/kotlin/benchmark/build.gradle.kts
+++ b/kotlin/benchmark/build.gradle.kts
@@ -1,15 +1,15 @@
import org.jetbrains.kotlin.ir.backend.js.compile
plugins {
- kotlin("multiplatform") version "1.4.20"
+ kotlin("multiplatform")
id("org.jetbrains.kotlin.plugin.allopen") version "1.4.20"
- id("org.jetbrains.kotlinx.benchmark") version "0.3.0"
+ id("org.jetbrains.kotlinx.benchmark") version "0.4.2"
id("io.morethan.jmhreport") version "0.9.0"
- id("de.undercouch.download") version "4.1.1"
+ id("de.undercouch.download")
}
// allOpen plugin is needed for the benchmark annotations.
-// for more infomation, see https://github.com/Kotlin/kotlinx-benchmark#gradle-plugin
+// for more information, see https://github.com/Kotlin/kotlinx-benchmark#gradle-plugin
allOpen {
annotation("org.openjdk.jmh.annotations.State")
}
@@ -45,54 +45,25 @@
kotlin {
jvm {
withJava()
- compilations.all {
- kotlinOptions {
- jvmTarget = JavaVersion.VERSION_1_8.toString()
- }
- }
}
sourceSets {
all {
languageSettings.enableLanguageFeature("InlineClasses")
- languageSettings.useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
}
- val commonTest by getting {
- dependencies {
- implementation(kotlin("test-common"))
- implementation(kotlin("test-annotations-common"))
- }
- }
- val jvmTest by getting {
- dependencies {
- implementation(kotlin("test-junit"))
- }
- }
val jvmMain by getting {
dependencies {
- implementation("org.jetbrains.kotlinx:kotlinx-benchmark-runtime:0.3.0")
implementation(kotlin("stdlib-common"))
implementation(project(":flatbuffers-kotlin"))
- implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
- implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.4.1")
+ implementation(libs.kotlinx.benchmark.runtime)
- //moshi
- implementation("com.squareup.moshi:moshi-kotlin:1.11.0")
-
- //gson
- implementation("com.google.code.gson:gson:2.8.5")
+ // json serializers
+ implementation(libs.moshi.kotlin)
+ implementation(libs.gson)
}
}
-
- /* Targets configuration omitted.
- * To find out how to configure the targets, please follow the link:
- * https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#setting-up-targets
- */
- targets {
- targetFromPreset(presets.getAt("jvm"))
- }
}
}
@@ -105,7 +76,3 @@
dest(File("${project.projectDir.absolutePath}/src/jvmMain/resources"))
overwrite(false)
}
-
-project.tasks.named("compileKotlinJvm") {
- dependsOn("downloadMultipleFiles")
-}
diff --git a/kotlin/benchmark/src/jvmMain/java b/kotlin/benchmark/src/jvmMain/java
index 2260196..fd62a87 120000
--- a/kotlin/benchmark/src/jvmMain/java
+++ b/kotlin/benchmark/src/jvmMain/java
@@ -1 +1 @@
-../../../../java/
\ No newline at end of file
+../../../../java/src/main/java
\ No newline at end of file
diff --git a/kotlin/build.gradle.kts b/kotlin/build.gradle.kts
index 455ee0d..b189075 100644
--- a/kotlin/build.gradle.kts
+++ b/kotlin/build.gradle.kts
@@ -1,22 +1,24 @@
plugins {
- id("com.diffplug.spotless") version "5.8.2"
+ id("com.diffplug.spotless") version "6.3.0"
}
group = "com.google.flatbuffers"
version = "2.0.0-SNAPSHOT"
-subprojects {
-
+buildscript {
repositories {
- maven { setUrl("https://plugins.gradle.org/m2/") }
+ gradlePluginPortal()
+ google()
mavenCentral()
}
+ dependencies {
+ classpath(libs.bundles.plugins)
+ }
}
-buildscript {
+allprojects {
repositories {
- maven { setUrl("https://plugins.gradle.org/m2/") }
- gradlePluginPortal()
+ google()
mavenCentral()
}
}
diff --git a/kotlin/flatbuffers-kotlin/build.gradle.kts b/kotlin/flatbuffers-kotlin/build.gradle.kts
index b74807e..f384320 100644
--- a/kotlin/flatbuffers-kotlin/build.gradle.kts
+++ b/kotlin/flatbuffers-kotlin/build.gradle.kts
@@ -1,5 +1,5 @@
plugins {
- kotlin("multiplatform") version "1.4.20"
+ kotlin("multiplatform")
}
group = "com.google.flatbuffers.kotlin"
@@ -10,13 +10,13 @@
jvm()
js {
browser {
- binaries.executable()
- testTask {
+ testTask {
useKarma {
useChromeHeadless()
}
}
}
+ binaries.executable()
}
macosX64()
iosArm32()
@@ -32,8 +32,7 @@
val commonTest by getting {
dependencies {
- implementation(kotlin("test-common"))
- implementation(kotlin("test-annotations-common"))
+ implementation(kotlin("test"))
}
}
val jvmTest by getting {
@@ -43,9 +42,6 @@
}
val jvmMain by getting {
kotlin.srcDir("java")
- dependencies {
- implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.4.1")
- }
}
val jsMain by getting {
@@ -79,19 +75,12 @@
all {
languageSettings.enableLanguageFeature("InlineClasses")
- languageSettings.useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
+ languageSettings.optIn("kotlin.ExperimentalUnsignedTypes")
}
}
+}
- /* Targets configuration omitted.
- * To find out how to configure the targets, please follow the link:
- * https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#setting-up-targets */
- targets {
- targetFromPreset(presets.getAt("jvm"))
- targetFromPreset(presets.getAt("js"))
- targetFromPreset(presets.getAt("macosX64"))
- targetFromPreset(presets.getAt("iosArm32"))
- targetFromPreset(presets.getAt("iosArm64"))
- targetFromPreset(presets.getAt("iosX64"))
- }
+// Fixes JS issue: https://youtrack.jetbrains.com/issue/KT-49109
+rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin> {
+ rootProject.the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().nodeVersion = "16.0.0"
}
diff --git a/kotlin/gradle.properties b/kotlin/gradle.properties
new file mode 100644
index 0000000..5cb42e3
--- /dev/null
+++ b/kotlin/gradle.properties
@@ -0,0 +1,14 @@
+#Gradle
+
+org.gradle.parallel=true
+org.gradle.caching=true
+
+#Kotlin
+kotlin.code.style=official
+
+#MPP
+kotlin.mpp.enableGranularSourceSetsMetadata=true
+kotlin.native.enableDependencyPropagation=false
+kotlin.mpp.enableCompatibilityMetadataVariant=true
+kotlin.mpp.stability.nowarn=true
+kotlin.incremental.multiplatform=true
diff --git a/kotlin/gradle/libs.versions.toml b/kotlin/gradle/libs.versions.toml
new file mode 100644
index 0000000..089f7e7
--- /dev/null
+++ b/kotlin/gradle/libs.versions.toml
@@ -0,0 +1,20 @@
+[versions]
+plugin-kotlin = "1.6.10"
+plugin-gver = "0.42.0"
+kotlinx-benchmark-runtime = "0.4.2"
+junit = "4.12"
+gson = "2.8.5"
+moshi-kotlin = "1.11.0"
+
+[libraries]
+moshi-kotlin = { module = "com.squareup.moshi:moshi-kotlin", version.ref = "moshi-kotlin" }
+gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
+kotlinx-benchmark-runtime = { module = "org.jetbrains.kotlinx:kotlinx-benchmark-runtime", version.ref = "kotlinx-benchmark-runtime" }
+plugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "plugin-kotlin" }
+plugin-kotlin-serialization = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "plugin-kotlin" }
+plugin-gver = { module = "com.github.ben-manes:gradle-versions-plugin", version.ref = "plugin-gver" }
+
+junit = { module="junit:junit", version.ref="junit"}
+
+[bundles]
+plugins = ["plugin-kotlin", "plugin-kotlin-serialization", "plugin-gver"]
diff --git a/kotlin/gradle/wrapper/gradle-wrapper.jar b/kotlin/gradle/wrapper/gradle-wrapper.jar
index 62d4c05..41d9927 100644
--- a/kotlin/gradle/wrapper/gradle-wrapper.jar
+++ b/kotlin/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/kotlin/gradle/wrapper/gradle-wrapper.properties b/kotlin/gradle/wrapper/gradle-wrapper.properties
index 8faf39d..aa991fc 100644
--- a/kotlin/gradle/wrapper/gradle-wrapper.properties
+++ b/kotlin/gradle/wrapper/gradle-wrapper.properties
@@ -1,9 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-# Remove kotlin MPP warning
-kotlin.mpp.stability.nowarn=true
-# Needed to share source among different targets
-kotlin.mpp.enableGranularSourceSetsMetadata=true
diff --git a/kotlin/gradlew b/kotlin/gradlew
index fbd7c51..1b6c787 100755
--- a/kotlin/gradlew
+++ b/kotlin/gradlew
@@ -1,7 +1,7 @@
-#!/usr/bin/env sh
+#!/bin/sh
#
-# Copyright 2015 the original author or authors.
+# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -17,67 +17,101 @@
#
##############################################################################
-##
-## Gradle start up script for UN*X
-##
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
##############################################################################
# Attempt to set APP_HOME
+
# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
+
+APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
+APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
+MAX_FD=maximum
warn () {
echo "$*"
-}
+} >&2
die () {
echo
echo "$*"
echo
exit 1
-}
+} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
@@ -87,9 +121,9 @@
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
+ JAVACMD=$JAVA_HOME/jre/sh/java
else
- JAVACMD="$JAVA_HOME/bin/java"
+ JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@@ -98,7 +132,7 @@
location of your Java installation."
fi
else
- JAVACMD="java"
+ JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
@@ -106,80 +140,95 @@
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin or MSYS, switch paths to Windows format before running java
-if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
-
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=`expr $i + 1`
- done
- case $i in
- 0) set -- ;;
- 1) set -- "$args0" ;;
- 2) set -- "$args0" "$args1" ;;
- 3) set -- "$args0" "$args1" "$args2" ;;
- 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
-}
-APP_ARGS=`save "$@"`
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+# Collect all arguments for the java command;
+# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
+# shell script including quotes and variable substitutions, so put them in
+# double quotes to make sure that they get re-expanded; and
+# * put everything else in single quotes, so that it's not re-expanded.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
exec "$JAVACMD" "$@"
diff --git a/kotlin/gradlew.bat b/kotlin/gradlew.bat
index 5093609..107acd3 100644
--- a/kotlin/gradlew.bat
+++ b/kotlin/gradlew.bat
@@ -40,7 +40,7 @@
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
+if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -54,7 +54,7 @@
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-if exist "%JAVA_EXE%" goto init
+if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -64,21 +64,6 @@
goto fail
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
:execute
@rem Setup the command line
@@ -86,7 +71,7 @@
@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
diff --git a/kotlin/settings.gradle b/kotlin/settings.gradle
deleted file mode 100644
index a30971c..0000000
--- a/kotlin/settings.gradle
+++ /dev/null
@@ -1,10 +0,0 @@
-pluginManagement {
- repositories {
- mavenCentral()
- gradlePluginPortal()
- }
-}
-
-
-rootProject.name = 'flatbuffers-kotlin'
-include 'flatbuffers-kotlin', "benchmark"
diff --git a/kotlin/settings.gradle.kts b/kotlin/settings.gradle.kts
new file mode 100644
index 0000000..0fd19c4
--- /dev/null
+++ b/kotlin/settings.gradle.kts
@@ -0,0 +1,3 @@
+rootProject.name = "flatbuffers-kotlin"
+include("flatbuffers-kotlin")
+include("benchmark")
diff --git a/net/FlatBuffers/ByteBuffer.cs b/net/FlatBuffers/ByteBuffer.cs
index 6e0fe35..4c0d000 100644
--- a/net/FlatBuffers/ByteBuffer.cs
+++ b/net/FlatBuffers/ByteBuffer.cs
@@ -51,7 +51,7 @@
#warning ENABLE_SPAN_T requires UNSAFE_BYTEBUFFER to also be defined
#endif
-namespace FlatBuffers
+namespace Google.FlatBuffers
{
public abstract class ByteBufferAllocator
{
@@ -225,6 +225,18 @@
return SizeOf<T>() * x.Length;
}
+ /// <summary>
+ /// Get the wire-size (in bytes) of an typed array segment, taking only the
+ /// range specified by <paramref name="x"/> into account.
+ /// </summary>
+ /// <typeparam name="T">The type of the array</typeparam>
+ /// <param name="x">The array segment to get the size of</param>
+ /// <returns>The number of bytes the array segment takes on wire</returns>
+ public static int ArraySize<T>(ArraySegment<T> x)
+ {
+ return SizeOf<T>() * x.Count;
+ }
+
#if ENABLE_SPAN_T && (UNSAFE_BYTEBUFFER || NETSTANDARD2_1)
public static int ArraySize<T>(Span<T> x)
{
@@ -869,7 +881,30 @@
throw new ArgumentNullException("Cannot put a null array");
}
- if (x.Length == 0)
+ return Put(offset, new ArraySegment<T>(x));
+ }
+
+ /// <summary>
+ /// Copies an array segment of type T into this buffer, ending at the
+ /// given offset into this buffer. The starting offset is calculated
+ /// based on the count of the array segment and is the value returned.
+ /// </summary>
+ /// <typeparam name="T">The type of the input data (must be a struct)
+ /// </typeparam>
+ /// <param name="offset">The offset into this buffer where the copy
+ /// will end</param>
+ /// <param name="x">The array segment to copy data from</param>
+ /// <returns>The 'start' location of this buffer now, after the copy
+ /// completed</returns>
+ public int Put<T>(int offset, ArraySegment<T> x)
+ where T : struct
+ {
+ if (x.Equals(default(ArraySegment<T>)))
+ {
+ throw new ArgumentNullException("Cannot put a uninitialized array segment");
+ }
+
+ if (x.Count == 0)
{
throw new ArgumentException("Cannot put an empty array");
}
@@ -889,7 +924,68 @@
#if ENABLE_SPAN_T && (UNSAFE_BYTEBUFFER || NETSTANDARD2_1)
MemoryMarshal.Cast<T, byte>(x).CopyTo(_buffer.Span.Slice(offset, numBytes));
#else
- Buffer.BlockCopy(x, 0, _buffer.Buffer, offset, numBytes);
+ var srcOffset = ByteBuffer.SizeOf<T>() * x.Offset;
+ Buffer.BlockCopy(x.Array, srcOffset, _buffer.Buffer, offset, numBytes);
+#endif
+ }
+ else
+ {
+ throw new NotImplementedException("Big Endian Support not implemented yet " +
+ "for putting typed arrays");
+ // if we are BE, we have to swap each element by itself
+ //for(int i = x.Length - 1; i >= 0; i--)
+ //{
+ // todo: low priority, but need to genericize the Put<T>() functions
+ //}
+ }
+ return offset;
+ }
+
+ /// <summary>
+ /// Copies an array segment of type T into this buffer, ending at the
+ /// given offset into this buffer. The starting offset is calculated
+ /// based on the count of the array segment and is the value returned.
+ /// </summary>
+ /// <typeparam name="T">The type of the input data (must be a struct)
+ /// </typeparam>
+ /// <param name="offset">The offset into this buffer where the copy
+ /// will end</param>
+ /// <param name="ptr">The pointer to copy data from</param>
+ /// <param name="sizeInBytes">The number of bytes to copy</param>
+ /// <returns>The 'start' location of this buffer now, after the copy
+ /// completed</returns>
+ public int Put<T>(int offset, IntPtr ptr, int sizeInBytes)
+ where T : struct
+ {
+ if (ptr == IntPtr.Zero)
+ {
+ throw new ArgumentNullException("Cannot add a null pointer");
+ }
+
+ if(sizeInBytes <= 0)
+ {
+ throw new ArgumentException("Cannot put an empty array");
+ }
+
+ if (!IsSupportedType<T>())
+ {
+ throw new ArgumentException("Cannot put an array of type "
+ + typeof(T) + " into this buffer");
+ }
+
+ if (BitConverter.IsLittleEndian)
+ {
+ offset -= sizeInBytes;
+ AssertOffsetAndLength(offset, sizeInBytes);
+ // if we are LE, just do a block copy
+#if ENABLE_SPAN_T && UNSAFE_BYTEBUFFER
+ unsafe
+ {
+ var span = new Span<byte>(ptr.ToPointer(), sizeInBytes);
+ span.CopyTo(_buffer.Span.Slice(offset, sizeInBytes));
+ }
+#else
+ Marshal.Copy(ptr, _buffer.Buffer, offset, sizeInBytes);
#endif
}
else
diff --git a/net/FlatBuffers/ByteBufferUtil.cs b/net/FlatBuffers/ByteBufferUtil.cs
index 66e8266..a5f2fb9 100644
--- a/net/FlatBuffers/ByteBufferUtil.cs
+++ b/net/FlatBuffers/ByteBufferUtil.cs
@@ -16,7 +16,7 @@
using System;
-namespace FlatBuffers
+namespace Google.FlatBuffers
{
/// <summary>
/// Class that collects utility functions around `ByteBuffer`.
diff --git a/net/FlatBuffers/FlatBufferBuilder.cs b/net/FlatBuffers/FlatBufferBuilder.cs
index c72b624..e550f90 100644
--- a/net/FlatBuffers/FlatBufferBuilder.cs
+++ b/net/FlatBuffers/FlatBufferBuilder.cs
@@ -23,7 +23,7 @@
/// @addtogroup flatbuffers_csharp_api
/// @{
-namespace FlatBuffers
+namespace Google.FlatBuffers
{
/// <summary>
/// Responsible for building up and accessing a FlatBuffer formatted byte
@@ -210,6 +210,31 @@
_space = _bb.Put(_space, x);
}
+ /// <summary>
+ /// Puts an array of type T into this builder at the
+ /// current offset
+ /// </summary>
+ /// <typeparam name="T">The type of the input data </typeparam>
+ /// <param name="x">The array segment to copy data from</param>
+ public void Put<T>(ArraySegment<T> x)
+ where T : struct
+ {
+ _space = _bb.Put(_space, x);
+ }
+
+ /// <summary>
+ /// Puts data of type T into this builder at the
+ /// current offset
+ /// </summary>
+ /// <typeparam name="T">The type of the input data </typeparam>
+ /// <param name="ptr">The pointer to copy data from</param>
+ /// <param name="sizeInBytes">The length of the data in bytes</param>
+ public void Put<T>(IntPtr ptr, int sizeInBytes)
+ where T : struct
+ {
+ _space = _bb.Put<T>(_space, ptr, sizeInBytes);
+ }
+
#if ENABLE_SPAN_T && (UNSAFE_BYTEBUFFER || NETSTANDARD2_1)
/// <summary>
/// Puts a span of type T into this builder at the
@@ -298,12 +323,23 @@
public void Add<T>(T[] x)
where T : struct
{
+ Add(new ArraySegment<T>(x));
+ }
+
+ /// <summary>
+ /// Add an array of type T to the buffer (aligns the data and grows if necessary).
+ /// </summary>
+ /// <typeparam name="T">The type of the input data</typeparam>
+ /// <param name="x">The array segment to copy data from</param>
+ public void Add<T>(ArraySegment<T> x)
+ where T : struct
+ {
if (x == null)
{
throw new ArgumentNullException("Cannot add a null array");
}
- if( x.Length == 0)
+ if( x.Count == 0)
{
// don't do anything if the array is empty
return;
@@ -317,10 +353,52 @@
int size = ByteBuffer.SizeOf<T>();
// Need to prep on size (for data alignment) and then we pass the
// rest of the length (minus 1) as additional bytes
- Prep(size, size * (x.Length - 1));
+ Prep(size, size * (x.Count - 1));
Put(x);
}
+ /// <summary>
+ /// Adds the data of type T pointed to by the given pointer to the buffer (aligns the data and grows if necessary).
+ /// </summary>
+ /// <typeparam name="T">The type of the input data</typeparam>
+ /// <param name="ptr">The pointer to copy data from</param>
+ /// <param name="sizeInBytes">The data size in bytes</param>
+ public void Add<T>(IntPtr ptr, int sizeInBytes)
+ where T : struct
+ {
+ if(sizeInBytes == 0)
+ {
+ // don't do anything if the array is empty
+ return;
+ }
+
+ if (ptr == IntPtr.Zero)
+ {
+ throw new ArgumentNullException("Cannot add a null pointer");
+ }
+
+ if(sizeInBytes < 0)
+ {
+ throw new ArgumentOutOfRangeException("sizeInBytes", "sizeInBytes cannot be negative");
+ }
+
+ if(!ByteBuffer.IsSupportedType<T>())
+ {
+ throw new ArgumentException("Cannot add this Type array to the builder");
+ }
+
+ int size = ByteBuffer.SizeOf<T>();
+ if((sizeInBytes % size) != 0)
+ {
+ throw new ArgumentException("The given size in bytes " + sizeInBytes + " doesn't match the element size of T ( " + size + ")", "sizeInBytes");
+ }
+
+ // Need to prep on size (for data alignment) and then we pass the
+ // rest of the length (minus 1) as additional bytes
+ Prep(size, sizeInBytes - size);
+ Put<T>(ptr, sizeInBytes);
+ }
+
#if ENABLE_SPAN_T && (UNSAFE_BYTEBUFFER || NETSTANDARD2_1)
/// <summary>
/// Add a span of type T to the buffer (aligns the data and grows if necessary).
diff --git a/net/FlatBuffers/FlatBufferConstants.cs b/net/FlatBuffers/FlatBufferConstants.cs
index 473f79a..e3f0f89 100644
--- a/net/FlatBuffers/FlatBufferConstants.cs
+++ b/net/FlatBuffers/FlatBufferConstants.cs
@@ -19,7 +19,7 @@
using System.Linq;
using System.Text;
-namespace FlatBuffers
+namespace Google.FlatBuffers
{
public static class FlatBufferConstants
{
@@ -32,6 +32,6 @@
Changes to the C# implementation need to be sure to change
the version here and in the code generator on every possible
incompatible change */
- public static void FLATBUFFERS_2_0_0() {}
+ public static void FLATBUFFERS_2_0_8() {}
}
}
diff --git a/net/FlatBuffers/FlatBuffers.csproj b/net/FlatBuffers/FlatBuffers.csproj
deleted file mode 100644
index a2b8bfb..0000000
--- a/net/FlatBuffers/FlatBuffers.csproj
+++ /dev/null
@@ -1,23 +0,0 @@
-īģŋ<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-
- <PropertyGroup>
- <TargetFrameworks>netstandard2.1;netstandard2.0;net46</TargetFrameworks>
- <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
- </PropertyGroup>
-
- <PropertyGroup Condition="'$(UNSAFE_BYTEBUFFER)' == 'true'">
- <DefineConstants>$(DefineConstants);UNSAFE_BYTEBUFFER</DefineConstants>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- </PropertyGroup>
- <PropertyGroup Condition="'$(BYTEBUFFER_NO_BOUNDS_CHECK)' == 'true'">
- <DefineConstants>$(DefineConstants);BYTEBUFFER_NO_BOUNDS_CHECK</DefineConstants>
- </PropertyGroup>
- <PropertyGroup Condition="'$(ENABLE_SPAN_T)' == 'true'">
- <DefineConstants>$(DefineConstants);ENABLE_SPAN_T</DefineConstants>
- </PropertyGroup>
-
- <ItemGroup Condition="('$(ENABLE_SPAN_T)' == 'true') And (('$(TargetFramework)' == 'netstandard2.0') Or ('$(TargetFramework)' == 'net46'))">
- <PackageReference Include="System.Memory" Version="4.5.4" />
- </ItemGroup>
-
-</Project>
diff --git a/net/FlatBuffers/Google.FlatBuffers.csproj b/net/FlatBuffers/Google.FlatBuffers.csproj
new file mode 100644
index 0000000..107ba7c
--- /dev/null
+++ b/net/FlatBuffers/Google.FlatBuffers.csproj
@@ -0,0 +1,46 @@
+īģŋ<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+
+ <PropertyGroup>
+ <TargetFrameworks>netstandard2.1;netstandard2.0;net46</TargetFrameworks>
+ <Description>A cross-platform memory efficient serialization library</Description>
+ <PackageVersion>2.0.8-beta.1</PackageVersion>
+ <Authors>Google LLC</Authors>
+ <PackageProjectUrl>https://github.com/google/flatbuffers</PackageProjectUrl>
+ <RepositoryUrl>https://github.com/google/flatbuffers</RepositoryUrl>
+ <PublishRepositoryUrl>true</PublishRepositoryUrl>
+ <PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
+ <PackageIcon>flatbuffers.png</PackageIcon>
+ <PackageTags>Google;FlatBuffers;Serialization;Buffer;Binary;zero copy</PackageTags>
+ <Copyright>Copyright 2022 Google LLC</Copyright>
+ <IncludeSymbols>true</IncludeSymbols>
+ <SymbolPackageFormat>snupkg</SymbolPackageFormat>
+ <SignAssembly>true</SignAssembly>
+ <AssemblyOriginatorKeyFile>flatbuffers.snk</AssemblyOriginatorKeyFile>
+ <DelaySign>false</DelaySign>
+ </PropertyGroup>
+
+ <PropertyGroup Condition="'$(UNSAFE_BYTEBUFFER)' == 'true'">
+ <DefineConstants>$(DefineConstants);UNSAFE_BYTEBUFFER</DefineConstants>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(BYTEBUFFER_NO_BOUNDS_CHECK)' == 'true'">
+ <DefineConstants>$(DefineConstants);BYTEBUFFER_NO_BOUNDS_CHECK</DefineConstants>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(ENABLE_SPAN_T)' == 'true'">
+ <DefineConstants>$(DefineConstants);ENABLE_SPAN_T</DefineConstants>
+ </PropertyGroup>
+
+ <ItemGroup Condition="('$(ENABLE_SPAN_T)' == 'true') And (('$(TargetFramework)' == 'netstandard2.0') Or ('$(TargetFramework)' == 'net46'))">
+ <PackageReference Include="System.Memory" Version="4.5.4" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="..\..\LICENSE.txt" Pack="true" PackagePath="" />
+ <None Include="flatbuffers.png" Pack="true" PackagePath="" />
+ </ItemGroup>
+
+</Project>
diff --git a/net/FlatBuffers/IFlatbufferObject.cs b/net/FlatBuffers/IFlatbufferObject.cs
index 6a15aba..c1d106c 100644
--- a/net/FlatBuffers/IFlatbufferObject.cs
+++ b/net/FlatBuffers/IFlatbufferObject.cs
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-namespace FlatBuffers
+namespace Google.FlatBuffers
{
/// <summary>
/// This is the base for both structs and tables.
diff --git a/net/FlatBuffers/Offset.cs b/net/FlatBuffers/Offset.cs
index 2b17cec..d2dd628 100644
--- a/net/FlatBuffers/Offset.cs
+++ b/net/FlatBuffers/Offset.cs
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-namespace FlatBuffers
+namespace Google.FlatBuffers
{
/// <summary>
/// Offset class for typesafe assignments.
diff --git a/net/FlatBuffers/Properties/AssemblyInfo.cs b/net/FlatBuffers/Properties/AssemblyInfo.cs
deleted file mode 100644
index 1edfac4..0000000
--- a/net/FlatBuffers/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2014 Google Inc. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("FlatBuffers")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("FlatBuffers")]
-[assembly: AssemblyCopyright("Copyright (c) 2015 Google Inc")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("91c32e64-ef20-47df-9c9f-cec9207bc6df")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/net/FlatBuffers/Struct.cs b/net/FlatBuffers/Struct.cs
index 4832cda..b4539bf 100644
--- a/net/FlatBuffers/Struct.cs
+++ b/net/FlatBuffers/Struct.cs
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-namespace FlatBuffers
+namespace Google.FlatBuffers
{
/// <summary>
/// All structs in the generated code derive from this class, and add their own accessors.
diff --git a/net/FlatBuffers/Table.cs b/net/FlatBuffers/Table.cs
index d888de5..21ef7dc 100644
--- a/net/FlatBuffers/Table.cs
+++ b/net/FlatBuffers/Table.cs
@@ -18,7 +18,7 @@
using System.Text;
using System.Runtime.InteropServices;
-namespace FlatBuffers
+namespace Google.FlatBuffers
{
/// <summary>
/// All tables in the generated code derive from this struct, and add their own accessors.
diff --git a/net/FlatBuffers/flatbuffers.png b/net/FlatBuffers/flatbuffers.png
new file mode 100644
index 0000000..2c728f3
--- /dev/null
+++ b/net/FlatBuffers/flatbuffers.png
Binary files differ
diff --git a/net/FlatBuffers/flatbuffers.snk b/net/FlatBuffers/flatbuffers.snk
new file mode 100644
index 0000000..70a2146
--- /dev/null
+++ b/net/FlatBuffers/flatbuffers.snk
Binary files differ
diff --git a/package.json b/package.json
index 41bc51b..26e0841 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "flatbuffers",
- "version": "2.0.6",
+ "version": "2.0.8",
"description": "Memory Efficient Serialization Library",
"files": [
"js/**/*.js",
@@ -16,8 +16,8 @@
"test": "tests"
},
"scripts": {
- "test": "npm run compile && cd tests && ./TypeScriptTest.sh",
- "compile": "tsc && tsc -p tsconfig.mjs.json",
+ "test": "npm run compile && cd tests/ts && python3 ./TypeScriptTest.py",
+ "compile": "tsc && tsc -p tsconfig.mjs.json && rollup -c",
"prepublishOnly": "npm install --only=dev && npm run compile"
},
"repository": {
@@ -35,11 +35,12 @@
"homepage": "https://google.github.io/flatbuffers/",
"dependencies": {},
"devDependencies": {
- "@bazel/typescript": "^5.2.0",
- "@types/node": "17.0.21",
- "@typescript-eslint/eslint-plugin": "^4.12.0",
- "@typescript-eslint/parser": "^4.12.0",
- "eslint": "^7.17.0",
- "typescript": "^4.5.5"
+ "@bazel/typescript": "5.2.0",
+ "@types/node": "18.7.16",
+ "@typescript-eslint/eslint-plugin": "^5.36.2",
+ "@typescript-eslint/parser": "^5.36.2",
+ "eslint": "^8.23.1",
+ "rollup": "^2.79.0",
+ "typescript": "^4.8.3"
}
}
diff --git a/python/flatbuffers/_version.py b/python/flatbuffers/_version.py
index a44e900..7812791 100644
--- a/python/flatbuffers/_version.py
+++ b/python/flatbuffers/_version.py
@@ -14,4 +14,4 @@
# Placeholder, to be updated during the release process
# by the setup.py
-__version__ = u"latest"
+__version__ = u"2.0.8"
diff --git a/python/flatbuffers/builder.py b/python/flatbuffers/builder.py
index 3f0cf4e..9bdf116 100644
--- a/python/flatbuffers/builder.py
+++ b/python/flatbuffers/builder.py
@@ -23,6 +23,8 @@
from .compat import memoryview_type
from .compat import import_numpy, NumpyRequiredForThisFeature
+import warnings
+
np = import_numpy()
## @file
## @addtogroup flatbuffers_python_api
@@ -75,6 +77,13 @@
"""
pass
+class EndVectorLengthMismatched(RuntimeError):
+ """
+ The number of elements passed to EndVector does not match the number
+ specified in StartVector.
+ """
+ pass
+
# VtableMetadataFields is the count of metadata fields in each vtable.
VtableMetadataFields = 2
@@ -377,13 +386,20 @@
return self.Offset()
## @endcond
- def EndVector(self):
+ def EndVector(self, numElems = None):
"""EndVector writes data necessary to finish vector construction."""
self.assertNested()
## @cond FLATBUFFERS_INTERNAL
self.nested = False
## @endcond
+
+ if numElems:
+ warnings.warn("numElems is deprecated.",
+ DeprecationWarning, stacklevel=2)
+ if numElems != self.vectorNumElems:
+ raise EndVectorLengthMismatched();
+
# we already made space for this, so write without PrependUint32
self.PlaceUOffsetT(self.vectorNumElems)
self.vectorNumElems = None
@@ -562,9 +578,11 @@
self.Place(off, flags)
def PrependSlot(self, flags, o, x, d):
- N.enforce_number(x, flags)
- N.enforce_number(d, flags)
- if x != d or self.forceDefaults:
+ if x is not None:
+ N.enforce_number(x, flags)
+ if d is not None:
+ N.enforce_number(d, flags)
+ if x != d or (self.forceDefaults and d is not None):
self.Prepend(flags, x)
self.Slot(o)
diff --git a/readme.md b/readme.md
index 649cf24..5056a64 100644
--- a/readme.md
+++ b/readme.md
@@ -2,6 +2,8 @@
===========

+[](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:flatbuffers)
+[](https://api.securityscorecards.dev/projects/github.com/google/flatbuffers)
[](https://gitter.im/google/flatbuffers?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[](https:///discord.gg/6qgKs3R)
[](https://twitter.com/wvo)
@@ -18,32 +20,46 @@
* MacOS X
* Linux
* Android
-* And any others with a recent C++ compiler.
+* And any others with a recent C++ compiler (C++ 11 and newer)
## Supported programming languages
-* C++
-* C#
-* C
-* Dart
-* Go
-* Java
-* JavaScript
-* Lobster
-* Lua
-* PHP
-* Python
-* Rust
-* TypeScript
+
+Code generation and runtime libraries for many popular languages.
+
+1. C
+1. C++ - [snapcraft.io](https://snapcraft.io/flatbuffers)
+1. C# - [nuget.org](https://www.nuget.org/packages/Google.FlatBuffers)
+1. Dart - [pub.dev](https://pub.dev/packages/flat_buffers)
+1. Go - [go.dev](https://pkg.go.dev/github.com/google/flatbuffers/go)
+1. Java - [Maven](https://search.maven.org/artifact/com.google.flatbuffers/flatbuffers-java)
+1. JavaScript - [NPM](https://www.npmjs.com/package/flatbuffers)
+1. Kotlin
+1. Lobster
+1. Lua
+1. PHP
+1. Python - [PyPi](https://pypi.org/project/flatbuffers/)
+1. Rust - [crates.io](https://crates.io/crates/flatbuffers)
+1. Swift
+1. TypeScript - [NPM](https://www.npmjs.com/package/flatbuffers)
*and more in progress...*
+1. [Nim](https://github.com/google/flatbuffers/pull/7362)
+
## Contribution
-* [FlatBuffers Google Group][] to discuss FlatBuffers with other developers and users.
+
* [FlatBuffers Issues Tracker][] to submit an issue.
* [stackoverflow.com][] with [`flatbuffers` tag][] for any questions regarding FlatBuffers.
*To contribute to this project,* see [CONTRIBUTING][].
+## Community
+
+* [FlatBuffers Google Group][] to discuss FlatBuffers with other developers and users.
+* [Discord Server](https:///discord.gg/6qgKs3R)
+* [Gitter](https://gitter.im/google/flatbuffers)
+
+
## Security
Please see our [Security Policy](SECURITY.md) for reporting vulnerabilities.
diff --git a/reflection/BUILD.bazel b/reflection/BUILD.bazel
index 7948e12..f276093 100644
--- a/reflection/BUILD.bazel
+++ b/reflection/BUILD.bazel
@@ -1,14 +1,5 @@
-load("//:build_defs.bzl", "flatbuffer_ts_library")
-
filegroup(
name = "reflection_fbs_schema",
srcs = ["reflection.fbs"],
visibility = ["//visibility:public"],
)
-
-flatbuffer_ts_library(
- name = "reflection_ts_fbs",
- srcs = ["reflection.fbs"],
- include_reflection = False,
- visibility = ["//visibility:public"],
-)
diff --git a/reflection/reflection.fbs b/reflection/reflection.fbs
index c3665eb..6dfeff6 100644
--- a/reflection/reflection.fbs
+++ b/reflection/reflection.fbs
@@ -37,6 +37,7 @@
index:int = -1; // If base_type == Object, index into "objects" below.
// If base_type == Union, UnionType, or integral derived
// from an enum, index into "enums" below.
+ // If base_type == Vector && element == Union or UnionType.
fixed_length:uint16 = 0; // Only if base_type == Array.
/// The size (octets) of the `base_type` field.
base_size:uint = 4; // 4 Is a common size due to offsets being that size.
diff --git a/reflection/ts/BUILD.bazel b/reflection/ts/BUILD.bazel
new file mode 100644
index 0000000..3f8a418
--- /dev/null
+++ b/reflection/ts/BUILD.bazel
@@ -0,0 +1,16 @@
+load("//:typescript.bzl", "flatbuffer_ts_library")
+
+genrule(
+ name = "copy_schema_to_folder",
+ srcs = ["//reflection:reflection_fbs_schema"],
+ outs = ["reflection.fbs"],
+ cmd = "cp $< $@",
+)
+
+flatbuffer_ts_library(
+ name = "reflection_ts_fbs",
+ package_name = "flatbuffers_reflection",
+ srcs = [":reflection.fbs"],
+ include_reflection = False,
+ visibility = ["//visibility:public"],
+)
diff --git a/rollup.config.js b/rollup.config.js
new file mode 100644
index 0000000..9369655
--- /dev/null
+++ b/rollup.config.js
@@ -0,0 +1,8 @@
+export default {
+ input: 'mjs/index.js',
+ output: {
+ file: 'flatbuffers.js',
+ format: 'iife',
+ name: 'flatbuffers'
+ }
+}
\ No newline at end of file
diff --git a/rust/flatbuffers/Cargo.toml b/rust/flatbuffers/Cargo.toml
index 8bf8c08..b3276c0 100644
--- a/rust/flatbuffers/Cargo.toml
+++ b/rust/flatbuffers/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "flatbuffers"
-version = "2.1.1"
+version = "2.1.2"
edition = "2018"
authors = ["Robert Winslow <hello@rwinslow.com>", "FlatBuffers Maintainers"]
license = "Apache-2.0"
diff --git a/rust/flatbuffers/src/verifier.rs b/rust/flatbuffers/src/verifier.rs
index d5e31df..36a5775 100644
--- a/rust/flatbuffers/src/verifier.rs
+++ b/rust/flatbuffers/src/verifier.rs
@@ -6,7 +6,8 @@
use crate::{ForwardsUOffset, SOffsetT, SkipSizePrefix, UOffsetT, VOffsetT, Vector, SIZE_UOFFSET};
#[cfg(feature="no_std")]
-extern crate thiserror_core2 as thiserror;
+use thiserror_core2::Error;
+#[cfg(not(feature="no_std"))]
use thiserror::Error;
/// Traces the location of data errors. Not populated for Dos detecting errors.
diff --git a/samples/monster_generated.h b/samples/monster_generated.h
index 5eef0f2..8c24d17 100644
--- a/samples/monster_generated.h
+++ b/samples/monster_generated.h
@@ -6,6 +6,13 @@
#include "flatbuffers/flatbuffers.h"
+// Ensure the included flatbuffers.h is the same version as when this file was
+// generated, otherwise it may not be compatible.
+static_assert(FLATBUFFERS_VERSION_MAJOR == 2 &&
+ FLATBUFFERS_VERSION_MINOR == 0 &&
+ FLATBUFFERS_VERSION_REVISION == 8,
+ "Non-compatible flatbuffers version included");
+
namespace MyGame {
namespace Sample {
@@ -549,7 +556,7 @@
(lhs.name == rhs.name) &&
(lhs.inventory == rhs.inventory) &&
(lhs.color == rhs.color) &&
- (lhs.weapons == rhs.weapons) &&
+ (lhs.weapons.size() == rhs.weapons.size() && std::equal(lhs.weapons.cbegin(), lhs.weapons.cend(), rhs.weapons.cbegin(), [](flatbuffers::unique_ptr<MyGame::Sample::WeaponT> const &a, flatbuffers::unique_ptr<MyGame::Sample::WeaponT> const &b) { return (a == b) || (a && b && *a == *b); })) &&
(lhs.equipped == rhs.equipped) &&
(lhs.path == rhs.path);
}
@@ -600,10 +607,10 @@
{ auto _e = name(); if (_e) _o->name = _e->str(); }
{ auto _e = inventory(); if (_e) { _o->inventory.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->inventory.begin()); } }
{ auto _e = color(); _o->color = _e; }
- { auto _e = weapons(); if (_e) { _o->weapons.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->weapons[_i]) { _e->Get(_i)->UnPackTo(_o->weapons[_i].get(), _resolver); } else { _o->weapons[_i] = flatbuffers::unique_ptr<MyGame::Sample::WeaponT>(_e->Get(_i)->UnPack(_resolver)); }; } } }
+ { auto _e = weapons(); if (_e) { _o->weapons.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->weapons[_i]) { _e->Get(_i)->UnPackTo(_o->weapons[_i].get(), _resolver); } else { _o->weapons[_i] = flatbuffers::unique_ptr<MyGame::Sample::WeaponT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->weapons.resize(0); } }
{ auto _e = equipped_type(); _o->equipped.type = _e; }
{ auto _e = equipped(); if (_e) _o->equipped.value = MyGame::Sample::EquipmentUnion::UnPack(_e, equipped_type(), _resolver); }
- { auto _e = path(); if (_e) { _o->path.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->path[_i] = *_e->Get(_i); } } }
+ { auto _e = path(); if (_e) { _o->path.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->path[_i] = *_e->Get(_i); } } else { _o->path.resize(0); } }
}
inline flatbuffers::Offset<Monster> Monster::Pack(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
@@ -614,7 +621,7 @@
(void)_rehasher;
(void)_o;
struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const MonsterT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
- auto _pos = _o->pos ? _o->pos.get() : 0;
+ auto _pos = _o->pos ? _o->pos.get() : nullptr;
auto _mana = _o->mana;
auto _hp = _o->hp;
auto _name = _o->name.empty() ? 0 : _fbb.CreateString(_o->name);
diff --git a/samples/monster_generated.lobster b/samples/monster_generated.lobster
index 310f74d..e283e53 100644
--- a/samples/monster_generated.lobster
+++ b/samples/monster_generated.lobster
@@ -19,11 +19,11 @@
class Weapon
class Vec3 : flatbuffers_handle
- def x():
+ def x() -> float:
return buf_.read_float32_le(pos_ + 0)
- def y():
+ def y() -> float:
return buf_.read_float32_le(pos_ + 4)
- def z():
+ def z() -> float:
return buf_.read_float32_le(pos_ + 8)
def CreateVec3(b_:flatbuffers_builder, x:float, y:float, z:float):
@@ -34,32 +34,32 @@
return b_.Offset()
class Monster : flatbuffers_handle
- def pos():
+ def pos() -> MyGame_Sample_Vec3?:
let o = buf_.flatbuffers_field_struct(pos_, 4)
return if o: MyGame_Sample_Vec3 { buf_, o } else: nil
- def mana():
+ def mana() -> int:
return buf_.flatbuffers_field_int16(pos_, 6, 150)
- def hp():
+ def hp() -> int:
return buf_.flatbuffers_field_int16(pos_, 8, 100)
- def name():
+ def name() -> string:
return buf_.flatbuffers_field_string(pos_, 10)
- def inventory(i:int):
+ def inventory(i:int) -> int:
return buf_.read_uint8_le(buf_.flatbuffers_field_vector(pos_, 14) + i * 1)
- def inventory_length():
+ def inventory_length() -> int:
return buf_.flatbuffers_field_vector_len(pos_, 14)
- def color():
+ def color() -> Color:
return Color(buf_.flatbuffers_field_int8(pos_, 16, 2))
- def weapons(i:int):
+ def weapons(i:int) -> MyGame_Sample_Weapon:
return MyGame_Sample_Weapon { buf_, buf_.flatbuffers_indirect(buf_.flatbuffers_field_vector(pos_, 18) + i * 4) }
- def weapons_length():
+ def weapons_length() -> int:
return buf_.flatbuffers_field_vector_len(pos_, 18)
- def equipped_type():
+ def equipped_type() -> Equipment:
return Equipment(buf_.flatbuffers_field_uint8(pos_, 20, 0))
def equipped_as_Weapon():
return MyGame_Sample_Weapon { buf_, buf_.flatbuffers_field_table(pos_, 22) }
- def path(i:int):
+ def path(i:int) -> MyGame_Sample_Vec3:
return MyGame_Sample_Vec3 { buf_, buf_.flatbuffers_field_vector(pos_, 24) + i * 12 }
- def path_length():
+ def path_length() -> int:
return buf_.flatbuffers_field_vector_len(pos_, 24)
def GetRootAsMonster(buf:string): return Monster { buf, buf.flatbuffers_indirect(0) }
@@ -120,9 +120,9 @@
b_.StartVector(12, n_, 4)
class Weapon : flatbuffers_handle
- def name():
+ def name() -> string:
return buf_.flatbuffers_field_string(pos_, 4)
- def damage():
+ def damage() -> int:
return buf_.flatbuffers_field_int16(pos_, 6, 0)
def GetRootAsWeapon(buf:string): return Weapon { buf, buf.flatbuffers_indirect(0) }
diff --git a/samples/monster_generated.swift b/samples/monster_generated.swift
index b3b6f05..173bacb 100644
--- a/samples/monster_generated.swift
+++ b/samples/monster_generated.swift
@@ -31,7 +31,7 @@
public struct MyGame_Sample_Vec3: NativeStruct {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _x: Float32
private var _y: Float32
@@ -56,7 +56,7 @@
public struct MyGame_Sample_Vec3_Mutable: FlatBufferObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -72,7 +72,7 @@
public struct MyGame_Sample_Monster: FlatBufferObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
@@ -162,7 +162,7 @@
public struct MyGame_Sample_Weapon: FlatBufferObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
diff --git a/samples/rust_generated/mod.rs b/samples/rust_generated/mod.rs
index 8560153..5f7e924 100644
--- a/samples/rust_generated/mod.rs
+++ b/samples/rust_generated/mod.rs
@@ -1,4 +1,5 @@
// Automatically generated by the Flatbuffers compiler. Do not modify.
+// @generated
pub mod my_game {
use super::*;
pub mod sample {
diff --git a/samples/rust_generated/my_game/sample/color_generated.rs b/samples/rust_generated/my_game/sample/color_generated.rs
index 1ef1d31..7a7d1d5 100644
--- a/samples/rust_generated/my_game/sample/color_generated.rs
+++ b/samples/rust_generated/my_game/sample/color_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -42,8 +47,8 @@
}
}
}
-impl std::fmt::Debug for Color {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Color {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
if let Some(name) = self.variant_name() {
f.write_str(name)
} else {
diff --git a/samples/rust_generated/my_game/sample/equipment_generated.rs b/samples/rust_generated/my_game/sample/equipment_generated.rs
index 919958a..9898c8d 100644
--- a/samples/rust_generated/my_game/sample/equipment_generated.rs
+++ b/samples/rust_generated/my_game/sample/equipment_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -38,8 +43,8 @@
}
}
}
-impl std::fmt::Debug for Equipment {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Equipment {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
if let Some(name) = self.variant_name() {
f.write_str(name)
} else {
@@ -121,7 +126,7 @@
/// If the union variant matches, return the owned WeaponT, setting the union to NONE.
pub fn take_weapon(&mut self) -> Option<Box<WeaponT>> {
if let Self::Weapon(_) = self {
- let v = std::mem::replace(self, Self::NONE);
+ let v = core::mem::replace(self, Self::NONE);
if let Self::Weapon(w) = v {
Some(w)
} else {
diff --git a/samples/rust_generated/my_game/sample/monster_generated.rs b/samples/rust_generated/my_game/sample/monster_generated.rs
index c156225..273212f 100644
--- a/samples/rust_generated/my_game/sample/monster_generated.rs
+++ b/samples/rust_generated/my_game/sample/monster_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum MonsterOffset {}
@@ -266,8 +271,8 @@
}
}
-impl std::fmt::Debug for Monster<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for Monster<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("Monster");
ds.field("pos", &self.pos());
ds.field("mana", &self.mana());
diff --git a/samples/rust_generated/my_game/sample/vec_3_generated.rs b/samples/rust_generated/my_game/sample/vec_3_generated.rs
index a1647d5..894186b 100644
--- a/samples/rust_generated/my_game/sample/vec_3_generated.rs
+++ b/samples/rust_generated/my_game/sample/vec_3_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
// struct Vec3, aligned to 4
@@ -13,8 +18,8 @@
Self([0; 12])
}
}
-impl std::fmt::Debug for Vec3 {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Vec3 {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Vec3")
.field("x", &self.x())
.field("y", &self.y())
@@ -44,7 +49,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(self as *const Vec3 as *const u8, Self::size())
+ ::core::slice::from_raw_parts(self as *const Vec3 as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
@@ -55,7 +60,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(*self as *const Vec3 as *const u8, Self::size())
+ ::core::slice::from_raw_parts(*self as *const Vec3 as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
diff --git a/samples/rust_generated/my_game/sample/weapon_generated.rs b/samples/rust_generated/my_game/sample/weapon_generated.rs
index 50a678b..f0a709d 100644
--- a/samples/rust_generated/my_game/sample/weapon_generated.rs
+++ b/samples/rust_generated/my_game/sample/weapon_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum WeaponOffset {}
@@ -118,8 +123,8 @@
}
}
-impl std::fmt::Debug for Weapon<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for Weapon<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("Weapon");
ds.field("name", &self.name());
ds.field("damage", &self.damage());
diff --git a/samples/sample_bfbs.cpp b/samples/sample_bfbs.cpp
index 0e17690..560de70 100644
--- a/samples/sample_bfbs.cpp
+++ b/samples/sample_bfbs.cpp
@@ -46,7 +46,8 @@
// inizialize parser by deserializing bfbs schema
flatbuffers::Parser parser2;
- ok = parser2.Deserialize((uint8_t *)bfbs_file.c_str(), bfbs_file.length());
+ ok = parser2.Deserialize(reinterpret_cast<const uint8_t *>(bfbs_file.c_str()),
+ bfbs_file.length());
assert(ok);
// parse json in parser from fbs and bfbs
diff --git a/scripts/check-grpc-generated-code.py b/scripts/check-grpc-generated-code.py
new file mode 100755
index 0000000..c9a4383
--- /dev/null
+++ b/scripts/check-grpc-generated-code.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python3
+#
+# Copyright 2022 Google Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import subprocess
+import sys
+import generate_grpc_examples
+from pathlib import Path
+
+# Get the path where this script is located so we can invoke the script from
+# any directory and have the paths work correctly.
+script_path = Path(__file__).parent.resolve()
+
+# Get the root path as an absolute path, so all derived paths are absolute.
+root_path = script_path.parent.absolute()
+
+print("Generating GRPC code...")
+generate_grpc_examples.GenerateGRPCExamples()
+
+result = subprocess.run(["git", "diff", "--quiet"], cwd=root_path)
+
+if result.returncode != 0:
+ print(
+ "\n"
+ "ERROR: ********************************************************\n"
+ "ERROR: * The following differences were found after running *\n"
+ "ERROR: * the script/generate_grpc_examples.py script. Maybe *\n"
+ "ERROR: * you forgot to run it after making changes in a *\n"
+ "ERROR: * generator or schema? *\n"
+ "ERROR: ********************************************************\n"
+ )
+ subprocess.run(["git", "diff", "--binary", "--exit-code"], cwd=root_path)
+ sys.exit(result.returncode)
diff --git a/scripts/check-grpc-generated-code.sh b/scripts/check-grpc-generated-code.sh
deleted file mode 100755
index 4541be1..0000000
--- a/scripts/check-grpc-generated-code.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2021 Google Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-set -e
-
-echo "Checks generated grpc code"
-cd grpc/examples
-sh generate.sh
-cd ..
-
-if ! git diff --quiet; then
- echo >&2
- echo "ERROR: ********************************************************" >&2
- echo "ERROR: The following differences were found after running the" >&2
- echo "ERROR: grpc/example/generate.sh script. Maybe you forgot to run" >&2
- echo "ERROR: it after making changes in a generator or schema?" >&2
- echo "ERROR: ********************************************************" >&2
- echo >&2
- git diff --binary --exit-code
-fi
diff --git a/scripts/generate_code.py b/scripts/generate_code.py
index 9871c0d..7111d8d 100755
--- a/scripts/generate_code.py
+++ b/scripts/generate_code.py
@@ -20,7 +20,7 @@
import platform
import shutil
import subprocess
-import sys
+import generate_grpc_examples
from pathlib import Path
parser = argparse.ArgumentParser()
@@ -64,13 +64,12 @@
# Specify the other paths that will be referenced
tests_path = Path(root_path, "tests")
+swift_code_gen = Path(root_path, "tests/swift/tests/CodeGenerationTests")
samples_path = Path(root_path, "samples")
reflection_path = Path(root_path, "reflection")
# Execute the flatc compiler with the specified parameters
-def flatc(
- options, schema, prefix=None, include=None, data=None, cwd=tests_path
-):
+def flatc(options, schema, prefix=None, include=None, data=None, cwd=tests_path):
cmd = [str(flatc_path)] + options
if prefix:
cmd += ["-o"] + [prefix]
@@ -95,10 +94,16 @@
new_reflection_path = Path(reflection_path, temp_dir, target)
original_reflection_path = Path(root_path, location, target)
if not filecmp.cmp(str(new_reflection_path), str(original_reflection_path)):
- shutil.rmtree(str(original_reflection_path))
+ shutil.rmtree(str(original_reflection_path), ignore_errors=True)
shutil.move(str(new_reflection_path), str(original_reflection_path))
shutil.rmtree(str(Path(reflection_path, temp_dir)))
+def flatc_annotate(schema, file, include=None, cwd=tests_path):
+ cmd = [str(flatc_path)]
+ if include:
+ cmd += ["-I"] + [include]
+ cmd += ["--annotate", schema, file]
+ result = subprocess.run(cmd, cwd=str(cwd), check=True)
# Glob a pattern relative to file path
def glob(path, pattern):
@@ -125,7 +130,12 @@
"--cpp-static-reflection",
"--gen-object-api",
]
-RUST_OPTS = BASE_OPTS + ["--rust", "--gen-all", "--gen-name-strings", "--rust-module-root-file"]
+RUST_OPTS = BASE_OPTS + [
+ "--rust",
+ "--gen-all",
+ "--gen-name-strings",
+ "--rust-module-root-file",
+]
RUST_SERIALIZE_OPTS = BASE_OPTS + [
"--rust",
"--gen-all",
@@ -136,6 +146,12 @@
TS_OPTS = ["--ts", "--gen-name-strings"]
LOBSTER_OPTS = ["--lobster"]
SWIFT_OPTS = ["--swift", "--gen-json-emit", "--bfbs-filenames", str(tests_path)]
+SWIFT_OPTS_CODE_GEN = [
+ "--swift",
+ "--gen-json-emit",
+ "--bfbs-filenames",
+ swift_code_gen
+]
JAVA_OPTS = ["--java"]
KOTLIN_OPTS = ["--kotlin"]
PHP_OPTS = ["--php"]
@@ -149,7 +165,6 @@
NO_INCL_OPTS
+ CPP_OPTS
+ CS_OPTS
- + TS_OPTS
+ [
"--binary",
"--java",
@@ -165,6 +180,15 @@
)
flatc(
+ NO_INCL_OPTS
+ + TS_OPTS,
+ schema="monster_test.fbs",
+ prefix="ts",
+ include="include_test",
+ data="monsterdata_test.json",
+)
+
+flatc(
["--lua", "--bfbs-filenames", str(tests_path)],
schema="monster_test.fbs",
include="include_test",
@@ -210,7 +234,7 @@
# For Rust we currently generate two independent schemas, with namespace_test2
# duplicating the types in namespace_test1
flatc(
- RUST_OPTS,
+ RUST_OPTS + CS_OPTS,
prefix="namespace_test",
schema=[
"namespace_test/namespace_test1.fbs",
@@ -219,33 +243,43 @@
)
flatc(
- BASE_OPTS
- + CPP_OPTS
- + CS_OPTS
- + TS_OPTS
- + JAVA_OPTS
- + KOTLIN_OPTS
- + PHP_OPTS,
+ BASE_OPTS + CPP_OPTS + CS_OPTS + JAVA_OPTS + KOTLIN_OPTS + PHP_OPTS,
prefix="union_vector",
schema="union_vector/union_vector.fbs",
)
flatc(
+ BASE_OPTS + TS_OPTS,
+ prefix="ts/union_vector",
+ schema="union_vector/union_vector.fbs",
+)
+
+flatc(
BASE_OPTS + TS_OPTS + ["--gen-name-strings", "--gen-mutable"],
include="include_test",
+ prefix="ts",
schema="monster_test.fbs",
)
+# Generate the complete flat file TS of monster.
+flatc(
+ ["--ts", "--gen-all", "--ts-flat-files"],
+ include="include_test",
+ schema="monster_test.fbs",
+ prefix="ts/ts-flat-files"
+)
+
flatc(
BASE_OPTS + TS_OPTS + ["-b"],
include="include_test",
+ prefix="ts",
schema="monster_test.fbs",
data="unicode_test.json",
)
flatc(
BASE_OPTS + TS_OPTS + ["--gen-name-strings"],
- prefix="union_vector",
+ prefix="ts/union_vector",
schema="union_vector/union_vector.fbs",
)
@@ -269,6 +303,19 @@
schema="monster_test.fbs",
)
+# Generate the annotated binary of the monster_test binary schema.
+flatc_annotate(
+ schema="../reflection/reflection.fbs",
+ file="monster_test.bfbs",
+ include="include_test"
+)
+
+flatc_annotate(
+ schema="monster_test.fbs",
+ file="monsterdata_test.mon",
+ include="include_test"
+)
+
flatc(
CPP_OPTS
+ NO_INCL_OPTS
@@ -297,12 +344,7 @@
if not args.skip_monster_extra:
flatc(
- CPP_OPTS
- + CS_OPTS
- + NO_INCL_OPTS
- + JAVA_OPTS
- + KOTLIN_OPTS
- + PYTHON_OPTS,
+ CPP_OPTS + CS_OPTS + NO_INCL_OPTS + JAVA_OPTS + KOTLIN_OPTS + PYTHON_OPTS,
schema="monster_extra.fbs",
data="monsterdata_extra.json",
)
@@ -313,11 +355,7 @@
)
flatc(
- CPP_OPTS
- + CS_OPTS
- + NO_INCL_OPTS
- + JAVA_OPTS
- + ["--jsonschema", "--scoped-enums"],
+ CPP_OPTS + CS_OPTS + NO_INCL_OPTS + JAVA_OPTS + ["--jsonschema", "--scoped-enums"],
schema="arrays_test.fbs",
)
@@ -335,16 +373,20 @@
# Optional Scalars
optional_scalars_schema = "optional_scalars.fbs"
-flatc(
- ["--java", "--kotlin", "--lobster", "--ts"], schema=optional_scalars_schema
-)
+flatc(["--java", "--kotlin", "--lobster"], schema=optional_scalars_schema)
+flatc(TS_OPTS, schema=optional_scalars_schema, prefix="ts")
-flatc(["--csharp", "--gen-object-api"], schema=optional_scalars_schema)
+flatc(["--csharp", "--python", "--gen-object-api"], schema=optional_scalars_schema)
flatc(RUST_OPTS, prefix="optional_scalars", schema=optional_scalars_schema)
flatc(NO_INCL_OPTS + CPP_OPTS, schema=optional_scalars_schema)
+# Type / field collsion
+type_field_collsion_schema = "type_field_collsion.fbs"
+
+flatc(["--csharp", "--gen-object-api"], schema=type_field_collsion_schema)
+
# Generate string/vector default code for tests
flatc(RUST_OPTS, prefix="more_defaults", schema="more_defaults.fbs")
@@ -363,11 +405,16 @@
prefix="nested_namespace_test",
schema=glob(tests_path, "nested_namespace_test/nested_namespace_test*.fbs"),
)
+flatc(BASE_OPTS + DART_OPTS, prefix="../dart/test/", schema="keyword_test.fbs")
+
+# Field key lookup with default value test
+dictionary_lookup_schema = "dictionary_lookup.fbs"
+flatc(["--java", "--kotlin"], schema=dictionary_lookup_schema)
# Swift Tests
-swift_prefix = "FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests"
+swift_prefix = "swift/tests/Tests/FlatBuffers.Test.SwiftTests"
flatc(
- SWIFT_OPTS + NO_INCL_OPTS + ["--grpc"],
+ SWIFT_OPTS + BASE_OPTS + ["--grpc"],
schema="monster_test.fbs",
include="include_test",
prefix=swift_prefix,
@@ -378,6 +425,7 @@
prefix=swift_prefix,
)
flatc(SWIFT_OPTS, schema="optional_scalars.fbs", prefix=swift_prefix)
+flatc(SWIFT_OPTS, schema="vector_has_test.fbs", prefix=swift_prefix)
flatc(
SWIFT_OPTS + ["--gen-object-api"],
schema="more_defaults.fbs",
@@ -389,23 +437,37 @@
prefix=swift_prefix,
)
+flatc(
+ SWIFT_OPTS_CODE_GEN + BASE_OPTS + ["--grpc", "--swift-implementation-only"],
+ schema="test_import.fbs",
+ cwd=swift_code_gen
+)
+
+flatc(
+ SWIFT_OPTS_CODE_GEN + NO_INCL_OPTS + ["--grpc"],
+ schema="test_no_include.fbs",
+ cwd=swift_code_gen
+)
+
# --filename-suffix and --filename-ext tests
flatc(
- CPP_OPTS
- + NO_INCL_OPTS
- + ["--filename-suffix", "_suffix", "--filename-ext", "hpp"],
+ CPP_OPTS + NO_INCL_OPTS + ["--grpc", "--filename-ext", "hpp"],
include="include_test",
+ prefix="monster_test_suffix/ext_only",
schema="monster_test.fbs",
)
-orig_monster_file = Path(tests_path, "monster_test_generated.h")
-new_monster_file = Path(tests_path, "monster_test_suffix.hpp")
-assert (
- new_monster_file.exists()
-), "filename suffix option did not produce a file"
-assert filecmp.cmp(
- str(orig_monster_file), str(new_monster_file)
-), "filename suffix option did not produce identical results"
-new_monster_file.unlink()
+flatc(
+ CPP_OPTS + NO_INCL_OPTS + ["--grpc", "--filename-suffix", "_suffix"],
+ include="include_test",
+ prefix="monster_test_suffix/filesuffix_only",
+ schema="monster_test.fbs",
+)
+flatc(
+ CPP_OPTS + NO_INCL_OPTS + ["--grpc", "--filename-suffix", "_suffix", "--filename-ext", "hpp"],
+ include="include_test",
+ prefix="monster_test_suffix",
+ schema="monster_test.fbs",
+)
# Flag c++17 requires Clang6, GCC7, MSVC2017 (_MSC_VER >= 1914) or higher.
cpp_17_prefix = "cpp17/generated_cpp17"
@@ -426,14 +488,15 @@
prefix=cpp_17_prefix,
)
+# Private annotations
+annotations_test_schema = "private_annotation_test.fbs"
+
+flatc(RUST_OPTS + ["--no-leak-private-annotation", "--gen-object-api"], prefix="private_annotation_test", schema=annotations_test_schema)
+
# Sample files
samples_schema = "monster.fbs"
-flatc(
- BASE_OPTS + CPP_OPTS + LOBSTER_OPTS, schema=samples_schema, cwd=samples_path
-)
-flatc(
- RUST_OPTS, prefix="rust_generated", schema=samples_schema, cwd=samples_path
-)
+flatc(BASE_OPTS + CPP_OPTS + LOBSTER_OPTS, schema=samples_schema, cwd=samples_path)
+flatc(RUST_OPTS, prefix="rust_generated", schema=samples_schema, cwd=samples_path)
flatc(
BINARY_OPTS + ["--bfbs-filenames", str(samples_path)],
schema=samples_schema,
@@ -445,9 +508,30 @@
# Skip generating the reflection if told too, as we run this script after
# building flatc which uses the reflection_generated.h itself.
if not args.skip_gen_reflection:
- # C++ Reflection
- flatc_reflection(["-c", "--cpp-std", "c++0x"], "include/flatbuffers",
- "reflection_generated.h")
+ # C++ Reflection
+ flatc_reflection(
+ ["-c", "--cpp-std", "c++0x"], "include/flatbuffers", "reflection_generated.h"
+ )
# Python Reflection
flatc_reflection(["-p"], "python/flatbuffers", "reflection")
+
+# Annotation
+
+
+def flatc_annotate(schema, include=None, data=None, cwd=tests_path):
+ cmd = [str(flatc_path)]
+ if include:
+ cmd += ["-I"] + [include]
+ cmd += ["--annotate", schema]
+ if data:
+ cmd += [data] if isinstance(data, str) else data
+ subprocess.run(cmd, cwd=str(cwd), check=True)
+
+
+flatc_annotate(
+ schema="monster_test.fbs", include="include_test", data="monsterdata_test.mon"
+)
+
+# Run the generate_grpc_examples script
+generate_grpc_examples.GenerateGRPCExamples()
diff --git a/scripts/generate_grpc_examples.py b/scripts/generate_grpc_examples.py
new file mode 100755
index 0000000..c5dbba5
--- /dev/null
+++ b/scripts/generate_grpc_examples.py
@@ -0,0 +1,70 @@
+#!/usr/bin/env python3
+#
+# Copyright 2022 Google Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from util import flatc, root_path
+from pathlib import Path
+
+grpc_examples_path = Path(root_path, "grpc/examples")
+
+greeter_schema = Path(grpc_examples_path, "greeter.fbs")
+
+COMMON_ARGS = [
+ "--grpc",
+ "--bfbs-filenames",
+ str(grpc_examples_path),
+]
+
+def GenerateGRPCExamples():
+
+ flatc(
+ COMMON_ARGS
+ + [
+ "--go",
+ ],
+ schema=greeter_schema,
+ cwd=Path(grpc_examples_path, "go/greeter"),
+ )
+
+ flatc(
+ COMMON_ARGS
+ + [
+ "--python",
+ ],
+ schema=greeter_schema,
+ cwd=Path(grpc_examples_path, "python/greeter"),
+ )
+
+ flatc(
+ COMMON_ARGS
+ + [
+ "--swift",
+ "--gen-json-emit",
+ ],
+ schema=greeter_schema,
+ cwd=Path(grpc_examples_path, "swift/Greeter/Sources/Model"),
+ )
+
+ flatc(
+ COMMON_ARGS
+ + [
+ "--ts",
+ ],
+ schema=greeter_schema,
+ cwd=Path(grpc_examples_path, "ts/greeter/src"),
+ )
+
+if __name__ == "__main__":
+ GenerateGRPCExamples()
diff --git a/scripts/util.py b/scripts/util.py
new file mode 100644
index 0000000..365ba2d
--- /dev/null
+++ b/scripts/util.py
@@ -0,0 +1,51 @@
+# Copyright 2022 Google Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import platform
+import subprocess
+from pathlib import Path
+
+# Get the path where this script is located so we can invoke the script from
+# any directory and have the paths work correctly.
+script_path = Path(__file__).parent.resolve()
+
+# Get the root path as an absolute path, so all derived paths are absolute.
+root_path = script_path.parent.absolute()
+
+# Get the location of the flatc executable, reading from the first command line
+# argument or defaulting to default names.
+flatc_exe = Path("flatc" if not platform.system() == "Windows" else "flatc.exe")
+
+# Find and assert flatc compiler is present.
+if root_path in flatc_exe.parents:
+ flatc_exe = flatc_exe.relative_to(root_path)
+flatc_path = Path(root_path, flatc_exe)
+assert flatc_path.exists(), "Cannot find the flatc compiler " + str(flatc_path)
+
+# Execute the flatc compiler with the specified parameters
+def flatc(options, schema, prefix=None, include=None, data=None, cwd=root_path):
+ cmd = [str(flatc_path)] + options
+ if prefix:
+ cmd += ["-o"] + [prefix]
+ if include:
+ cmd += ["-I"] + [include]
+ if isinstance(schema, Path):
+ cmd += [str(schema)]
+ elif isinstance(schema, str):
+ cmd += [schema]
+ else:
+ cmd += schema
+ if data:
+ cmd += [data] if isinstance(data, str) else data
+ return subprocess.check_call(cmd, cwd=str(cwd))
diff --git a/src/BUILD.bazel b/src/BUILD.bazel
index d8bbfcd..b01551d 100644
--- a/src/BUILD.bazel
+++ b/src/BUILD.bazel
@@ -34,10 +34,16 @@
cc_library(
name = "flatc_library",
srcs = [
+ "annotated_binary_text_gen.cpp",
+ "annotated_binary_text_gen.h",
"bfbs_gen.h",
"bfbs_gen_lua.cpp",
"bfbs_gen_lua.h",
+ "bfbs_namer.h",
+ "binary_annotator.cpp",
+ "binary_annotator.h",
"flatc.cpp",
+ "namer.h",
],
hdrs = [
"//:flatc_headers",
@@ -56,6 +62,7 @@
"bfbs_gen.h",
"bfbs_gen_lua.cpp",
"bfbs_gen_lua.h",
+ "bfbs_namer.h",
"flatc_main.cpp",
"idl_gen_cpp.cpp",
"idl_gen_csharp.cpp",
@@ -73,6 +80,7 @@
"idl_gen_swift.cpp",
"idl_gen_text.cpp",
"idl_gen_ts.cpp",
+ "idl_namer.h",
"namer.h",
"util.cpp",
],
diff --git a/src/annotated_binary_text_gen.cpp b/src/annotated_binary_text_gen.cpp
new file mode 100644
index 0000000..ec30b1d
--- /dev/null
+++ b/src/annotated_binary_text_gen.cpp
@@ -0,0 +1,439 @@
+#include "annotated_binary_text_gen.h"
+
+#include <sstream>
+#include <string>
+
+#include "binary_annotator.h"
+#include "flatbuffers/base.h"
+#include "flatbuffers/util.h"
+
+namespace flatbuffers {
+namespace {
+
+struct OutputConfig {
+ size_t largest_type_string = 10;
+
+ size_t largest_value_string = 20;
+
+ size_t max_bytes_per_line = 8;
+
+ size_t offset_max_char = 4;
+
+ char delimiter = '|';
+};
+
+static std::string ToString(const BinarySectionType type) {
+ switch (type) {
+ case BinarySectionType::Header: return "header";
+ case BinarySectionType::Table: return "table";
+ case BinarySectionType::RootTable: return "root_table";
+ case BinarySectionType::VTable: return "vtable";
+ case BinarySectionType::Struct: return "struct";
+ case BinarySectionType::String: return "string";
+ case BinarySectionType::Vector: return "vector";
+ case BinarySectionType::Unknown: return "unknown";
+ case BinarySectionType::Union: return "union";
+ case BinarySectionType::Padding: return "padding";
+ default: return "todo";
+ }
+}
+
+static bool IsOffset(const BinaryRegionType type) {
+ return type == BinaryRegionType::UOffset || type == BinaryRegionType::SOffset;
+}
+
+template<typename T> std::string ToString(T value) {
+ if (std::is_floating_point<T>::value) {
+ std::stringstream ss;
+ ss << value;
+ return ss.str();
+ } else {
+ return std::to_string(value);
+ }
+}
+
+template<typename T>
+std::string ToValueString(const BinaryRegion ®ion, const uint8_t *binary) {
+ std::string s;
+ s += "0x";
+ const T val = ReadScalar<T>(binary + region.offset);
+ const uint64_t start_index = region.offset + region.length - 1;
+ for (uint64_t i = 0; i < region.length; ++i) {
+ s += ToHex(binary[start_index - i]);
+ }
+ s += " (";
+ s += ToString(val);
+ s += ")";
+ return s;
+}
+
+template<>
+std::string ToValueString<std::string>(const BinaryRegion ®ion,
+ const uint8_t *binary) {
+ return std::string(reinterpret_cast<const char *>(binary + region.offset),
+ static_cast<size_t>(region.array_length));
+}
+
+static std::string ToValueString(const BinaryRegion ®ion,
+ const uint8_t *binary,
+ const OutputConfig &output_config) {
+ std::string s;
+
+ if (region.array_length) {
+ if (region.type == BinaryRegionType::Uint8 ||
+ region.type == BinaryRegionType::Unknown) {
+ // Interpet each value as a ASCII to aid debugging
+ for (uint64_t i = 0; i < region.array_length; ++i) {
+ const uint8_t c = *(binary + region.offset + i);
+ s += isprint(c) ? static_cast<char>(c & 0x7F) : '.';
+ }
+ return s;
+ } else if (region.type == BinaryRegionType::Char) {
+ // string value
+ return ToValueString<std::string>(region, binary);
+ }
+ }
+
+ switch (region.type) {
+ case BinaryRegionType::Uint32:
+ return ToValueString<uint32_t>(region, binary);
+ case BinaryRegionType::Int32: return ToValueString<int32_t>(region, binary);
+ case BinaryRegionType::Uint16:
+ return ToValueString<uint16_t>(region, binary);
+ case BinaryRegionType::Int16: return ToValueString<int16_t>(region, binary);
+ case BinaryRegionType::Bool: return ToValueString<bool>(region, binary);
+ case BinaryRegionType::Uint8: return ToValueString<uint8_t>(region, binary);
+ case BinaryRegionType::Char: return ToValueString<char>(region, binary);
+ case BinaryRegionType::Byte:
+ case BinaryRegionType::Int8: return ToValueString<int8_t>(region, binary);
+ case BinaryRegionType::Int64: return ToValueString<int64_t>(region, binary);
+ case BinaryRegionType::Uint64:
+ return ToValueString<uint64_t>(region, binary);
+ case BinaryRegionType::Double: return ToValueString<double>(region, binary);
+ case BinaryRegionType::Float: return ToValueString<float>(region, binary);
+ case BinaryRegionType::UType: return ToValueString<uint8_t>(region, binary);
+
+ // Handle Offsets separately, incase they add additional details.
+ case BinaryRegionType::UOffset:
+ s += ToValueString<uint32_t>(region, binary);
+ break;
+ case BinaryRegionType::SOffset:
+ s += ToValueString<int32_t>(region, binary);
+ break;
+ case BinaryRegionType::VOffset:
+ s += ToValueString<uint16_t>(region, binary);
+ break;
+
+ default: break;
+ }
+ // If this is an offset type, include the calculated offset location in the
+ // value.
+ // TODO(dbaileychess): It might be nicer to put this in the comment field.
+ if (IsOffset(region.type)) {
+ s += " Loc: +0x";
+ s += ToHex(region.points_to_offset, output_config.offset_max_char);
+ }
+ return s;
+}
+
+struct DocContinuation {
+ // The start column where the value text first starts
+ size_t value_start_column = 0;
+
+ // The remaining part of the doc to print.
+ std::string value;
+};
+
+static std::string GenerateTypeString(const BinaryRegion ®ion) {
+ return ToString(region.type) +
+ ((region.array_length)
+ ? "[" + std::to_string(region.array_length) + "]"
+ : "");
+}
+
+static std::string GenerateComment(const BinaryRegionComment &comment,
+ const BinarySection &) {
+ std::string s;
+ switch (comment.type) {
+ case BinaryRegionCommentType::Unknown: s = "unknown"; break;
+ case BinaryRegionCommentType::SizePrefix: s = "size prefix"; break;
+ case BinaryRegionCommentType::RootTableOffset:
+ s = "offset to root table `" + comment.name + "`";
+ break;
+ // TODO(dbaileychess): make this lowercase to follow the convention.
+ case BinaryRegionCommentType::FileIdentifier: s = "File Identifier"; break;
+ case BinaryRegionCommentType::Padding: s = "padding"; break;
+ case BinaryRegionCommentType::VTableSize: s = "size of this vtable"; break;
+ case BinaryRegionCommentType::VTableRefferingTableLength:
+ s = "size of referring table";
+ break;
+ case BinaryRegionCommentType::VTableFieldOffset:
+ s = "offset to field `" + comment.name;
+ break;
+ case BinaryRegionCommentType::VTableUnknownFieldOffset:
+ s = "offset to unknown field (id: " + std::to_string(comment.index) + ")";
+ break;
+
+ case BinaryRegionCommentType::TableVTableOffset:
+ s = "offset to vtable";
+ break;
+ case BinaryRegionCommentType::TableField:
+ s = "table field `" + comment.name;
+ break;
+ case BinaryRegionCommentType::TableUnknownField: s = "unknown field"; break;
+ case BinaryRegionCommentType::TableOffsetField:
+ s = "offset to field `" + comment.name + "`";
+ break;
+ case BinaryRegionCommentType::StructField:
+ s = "struct field `" + comment.name + "`";
+ break;
+ case BinaryRegionCommentType::ArrayField:
+ s = "array field `" + comment.name + "`[" +
+ std::to_string(comment.index) + "]";
+ break;
+ case BinaryRegionCommentType::StringLength: s = "length of string"; break;
+ case BinaryRegionCommentType::StringValue: s = "string literal"; break;
+ case BinaryRegionCommentType::StringTerminator:
+ s = "string terminator";
+ break;
+ case BinaryRegionCommentType::VectorLength:
+ s = "length of vector (# items)";
+ break;
+ case BinaryRegionCommentType::VectorValue:
+ s = "value[" + std::to_string(comment.index) + "]";
+ break;
+ case BinaryRegionCommentType::VectorTableValue:
+ s = "offset to table[" + std::to_string(comment.index) + "]";
+ break;
+ case BinaryRegionCommentType::VectorStringValue:
+ s = "offset to string[" + std::to_string(comment.index) + "]";
+ break;
+ case BinaryRegionCommentType::VectorUnionValue:
+ s = "offset to union[" + std::to_string(comment.index) + "]";
+ break;
+
+ default: break;
+ }
+ if (!comment.default_value.empty()) { s += " " + comment.default_value; }
+
+ switch (comment.status) {
+ case BinaryRegionStatus::OK: break; // no-op
+ case BinaryRegionStatus::WARN: s = "WARN: " + s; break;
+ case BinaryRegionStatus::WARN_NO_REFERENCES:
+ s = "WARN: nothing refers to this section.";
+ break;
+ case BinaryRegionStatus::WARN_CORRUPTED_PADDING:
+ s = "WARN: could be corrupted padding region.";
+ break;
+ case BinaryRegionStatus::WARN_PADDING_LENGTH:
+ s = "WARN: padding is longer than expected.";
+ break;
+ case BinaryRegionStatus::ERROR: s = "ERROR: " + s; break;
+ case BinaryRegionStatus::ERROR_OFFSET_OUT_OF_BINARY:
+ s = "ERROR: " + s + ". Invalid offset, points outside the binary.";
+ break;
+ case BinaryRegionStatus::ERROR_INCOMPLETE_BINARY:
+ s = "ERROR: " + s + ". Incomplete binary, expected to read " +
+ comment.status_message + " bytes.";
+ break;
+ case BinaryRegionStatus::ERROR_LENGTH_TOO_LONG:
+ s = "ERROR: " + s + ". Longer than the binary.";
+ break;
+ case BinaryRegionStatus::ERROR_LENGTH_TOO_SHORT:
+ s = "ERROR: " + s + ". Shorter than the minimum length: ";
+ break;
+ case BinaryRegionStatus::ERROR_REQUIRED_FIELD_NOT_PRESENT:
+ s = "ERROR: " + s + ". Required field is not present.";
+ break;
+ case BinaryRegionStatus::ERROR_INVALID_UNION_TYPE:
+ s = "ERROR: " + s + ". Invalid union type value.";
+ break;
+ case BinaryRegionStatus::ERROR_CYCLE_DETECTED:
+ s = "ERROR: " + s + ". Invalid offset, cycle detected.";
+ break;
+ }
+
+ return s;
+}
+
+static std::string GenerateDocumentation(const BinaryRegion ®ion,
+ const BinarySection §ion,
+ const uint8_t *binary,
+ DocContinuation &continuation,
+ const OutputConfig &output_config) {
+ std::string s;
+
+ // Check if there is a doc continuation that should be prioritized.
+ if (continuation.value_start_column) {
+ s += std::string(continuation.value_start_column - 2, ' ');
+ s += output_config.delimiter;
+ s += " ";
+
+ s += continuation.value.substr(0, output_config.max_bytes_per_line);
+ continuation.value = continuation.value.substr(
+ std::min(output_config.max_bytes_per_line, continuation.value.size()));
+ return s;
+ }
+
+ {
+ std::stringstream ss;
+ ss << std::setw(output_config.largest_type_string) << std::left;
+ ss << GenerateTypeString(region);
+ s += ss.str();
+ }
+ s += " ";
+ s += output_config.delimiter;
+ s += " ";
+ if (region.array_length) {
+ // Record where the value is first being outputted.
+ continuation.value_start_column = s.size();
+
+ // Get the full-length value, which we will chunk below.
+ const std::string value = ToValueString(region, binary, output_config);
+
+ std::stringstream ss;
+ ss << std::setw(output_config.largest_value_string) << std::left;
+ ss << value.substr(0, output_config.max_bytes_per_line);
+ s += ss.str();
+
+ continuation.value =
+ value.substr(std::min(output_config.max_bytes_per_line, value.size()));
+ } else {
+ std::stringstream ss;
+ ss << std::setw(output_config.largest_value_string) << std::left;
+ ss << ToValueString(region, binary, output_config);
+ s += ss.str();
+ }
+
+ s += " ";
+ s += output_config.delimiter;
+ s += " ";
+ s += GenerateComment(region.comment, section);
+
+ return s;
+}
+
+static std::string GenerateRegion(const BinaryRegion ®ion,
+ const BinarySection §ion,
+ const uint8_t *binary,
+ const OutputConfig &output_config) {
+ std::string s;
+ bool doc_generated = false;
+ DocContinuation doc_continuation;
+ for (uint64_t i = 0; i < region.length; ++i) {
+ if ((i % output_config.max_bytes_per_line) == 0) {
+ // Start a new line of output
+ s += '\n';
+ s += " ";
+ s += "+0x";
+ s += ToHex(region.offset + i, output_config.offset_max_char);
+ s += " ";
+ s += output_config.delimiter;
+ }
+
+ // Add each byte
+ s += " ";
+ s += ToHex(binary[region.offset + i]);
+
+ // Check for end of line or end of region conditions.
+ if (((i + 1) % output_config.max_bytes_per_line == 0) ||
+ i + 1 == region.length) {
+ if (i + 1 == region.length) {
+ // We are out of bytes but haven't the kMaxBytesPerLine, so we need to
+ // zero those out to align everything globally.
+ for (uint64_t j = i + 1; (j % output_config.max_bytes_per_line) != 0;
+ ++j) {
+ s += " ";
+ }
+ }
+ s += " ";
+ s += output_config.delimiter;
+ // This is the end of the first line or its the last byte of the region,
+ // generate the end-of-line documentation.
+ if (!doc_generated) {
+ s += " ";
+ s += GenerateDocumentation(region, section, binary, doc_continuation,
+ output_config);
+
+ // If we have a value in the doc continuation, that means the doc is
+ // being printed on multiple lines.
+ doc_generated = doc_continuation.value.empty();
+ }
+ }
+ }
+
+ return s;
+}
+
+static std::string GenerateSection(const BinarySection §ion,
+ const uint8_t *binary,
+ const OutputConfig &output_config) {
+ std::string s;
+ s += "\n";
+ s += ToString(section.type);
+ if (!section.name.empty()) { s += " (" + section.name + ")"; }
+ s += ":";
+ for (const BinaryRegion ®ion : section.regions) {
+ s += GenerateRegion(region, section, binary, output_config);
+ }
+ return s;
+}
+} // namespace
+
+bool AnnotatedBinaryTextGenerator::Generate(
+ const std::string &filename, const std::string &schema_filename) {
+ OutputConfig output_config;
+ output_config.max_bytes_per_line = options_.max_bytes_per_line;
+
+ // Given the length of the binary, we can calculate the maximum number of
+ // characters to display in the offset hex: (i.e. 2 would lead to 0XFF being
+ // the max output).
+ output_config.offset_max_char =
+ binary_length_ > 0xFFFFFF
+ ? 8
+ : (binary_length_ > 0xFFFF ? 6 : (binary_length_ > 0xFF ? 4 : 2));
+
+ // Find the largest type string of all the regions in this file, so we can
+ // align the output nicely.
+ output_config.largest_type_string = 0;
+ for (const auto §ion : annotations_) {
+ for (const auto ®ion : section.second.regions) {
+ std::string s = GenerateTypeString(region);
+ if (s.size() > output_config.largest_type_string) {
+ output_config.largest_type_string = s.size();
+ }
+
+ // Don't consider array regions, as they will be split to multiple lines.
+ if (!region.array_length) {
+ s = ToValueString(region, binary_, output_config);
+ if (s.size() > output_config.largest_value_string) {
+ output_config.largest_value_string = s.size();
+ }
+ }
+ }
+ }
+
+ // Generate each of the binary sections
+ std::string s;
+
+ s += "// Annotated Flatbuffer Binary\n";
+ s += "//\n";
+ s += "// Schema file: " + schema_filename + "\n";
+ s += "// Binary file: " + filename + "\n";
+
+ for (const auto §ion : annotations_) {
+ s += GenerateSection(section.second, binary_, output_config);
+ s += "\n";
+ }
+
+ // Modify the output filename.
+ std::string output_filename = StripExtension(filename);
+ output_filename += options_.output_postfix;
+ output_filename +=
+ "." + (options_.output_extension.empty() ? GetExtension(filename)
+ : options_.output_extension);
+
+ return SaveFile(output_filename.c_str(), s, false);
+}
+
+} // namespace flatbuffers
diff --git a/src/annotated_binary_text_gen.h b/src/annotated_binary_text_gen.h
new file mode 100644
index 0000000..712c452
--- /dev/null
+++ b/src/annotated_binary_text_gen.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2021 Google Inc. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FLATBUFFERS_ANNOTATED_BINARY_TEXT_GEN_H_
+#define FLATBUFFERS_ANNOTATED_BINARY_TEXT_GEN_H_
+
+#include <map>
+#include <memory>
+#include <string>
+
+#include "binary_annotator.h"
+
+namespace flatbuffers {
+
+class AnnotatedBinaryTextGenerator {
+ public:
+ struct Options {
+ // The maximum number of raw bytes to print per line in the output. 8 is a
+ // good default due to the largest type (double) being 8 bytes long.
+ size_t max_bytes_per_line = 8;
+
+ // The output file postfix, appended between the filename and the extension.
+ // Example binary1.bin -> binary1_annotated.bin
+ std::string output_postfix = "";
+
+ // The output file extension, replacing any extension given. If empty, don't
+ // change the provided extension. AFB = Annotated Flatbuffer Binary
+ //
+ // Example: binary1.bin -> binary1.afb
+ std::string output_extension = "afb";
+ };
+
+ explicit AnnotatedBinaryTextGenerator(
+ const Options &options, std::map<uint64_t, BinarySection> annotations,
+ const uint8_t *const binary, const int64_t binary_length)
+ : annotations_(std::move(annotations)),
+ binary_(binary),
+ binary_length_(binary_length),
+ options_(options) {}
+
+ // Generate the annotated binary for the given `filename`. Returns true if the
+ // annotated binary was successfully saved.
+ bool Generate(const std::string &filename,
+ const std::string &schema_filename);
+
+ private:
+ const std::map<uint64_t, BinarySection> annotations_;
+
+ // The binary data itself.
+ const uint8_t *binary_;
+ const int64_t binary_length_;
+
+ // Output configuration
+ const Options options_;
+};
+
+} // namespace flatbuffers
+
+#endif // FLATBUFFERS_ANNOTATED_BINARY_TEXT_GEN_H_
diff --git a/src/bfbs_gen.h b/src/bfbs_gen.h
index 12aafb3..e706ece 100644
--- a/src/bfbs_gen.h
+++ b/src/bfbs_gen.h
@@ -24,19 +24,21 @@
namespace flatbuffers {
-void ForAllEnums(
+namespace {
+
+static void ForAllEnums(
const flatbuffers::Vector<flatbuffers::Offset<reflection::Enum>> *enums,
std::function<void(const reflection::Enum *)> func) {
for (auto it = enums->cbegin(); it != enums->cend(); ++it) { func(*it); }
}
-void ForAllObjects(
+static void ForAllObjects(
const flatbuffers::Vector<flatbuffers::Offset<reflection::Object>> *objects,
std::function<void(const reflection::Object *)> func) {
for (auto it = objects->cbegin(); it != objects->cend(); ++it) { func(*it); }
}
-void ForAllEnumValues(const reflection::Enum *enum_def,
+static void ForAllEnumValues(const reflection::Enum *enum_def,
std::function<void(const reflection::EnumVal *)> func) {
for (auto it = enum_def->values()->cbegin(); it != enum_def->values()->cend();
++it) {
@@ -44,7 +46,7 @@
}
}
-void ForAllDocumentation(
+static void ForAllDocumentation(
const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>
*documentation,
std::function<void(const flatbuffers::String *)> func) {
@@ -73,10 +75,6 @@
return base_type == reflection::Obj;
}
-static bool IsScalar(const reflection::BaseType base_type) {
- return base_type >= reflection::UType && base_type <= reflection::Double;
-}
-
static bool IsFloatingPoint(const reflection::BaseType base_type) {
return base_type == reflection::Float || base_type == reflection::Double;
}
@@ -93,21 +91,7 @@
return base_type == reflection::Vector;
}
-static std::string Denamespace(const flatbuffers::String *name,
- std::string &ns) {
- const size_t pos = name->str().find_last_of('.');
- if (pos == std::string::npos) {
- ns = "";
- return name->str();
- }
- ns = name->str().substr(0, pos);
- return name->str().substr(pos + 1);
-}
-
-static std::string Denamespace(const flatbuffers::String *name) {
- std::string ns;
- return Denamespace(name, ns);
-}
+} // namespace
// A concrete base Flatbuffer Generator that specific language generators can
// derive from.
@@ -207,4 +191,4 @@
} // namespace flatbuffers
-#endif // FLATBUFFERS_BFBS_GEN_H_
\ No newline at end of file
+#endif // FLATBUFFERS_BFBS_GEN_H_
diff --git a/src/bfbs_gen_lua.cpp b/src/bfbs_gen_lua.cpp
index 868bb14..586f8ad 100644
--- a/src/bfbs_gen_lua.cpp
+++ b/src/bfbs_gen_lua.cpp
@@ -25,9 +25,11 @@
// Ensure no includes to flatc internals. bfbs_gen.h and generator.h are OK.
#include "bfbs_gen.h"
+#include "bfbs_namer.h"
#include "flatbuffers/bfbs_generator.h"
// The intermediate representation schema.
+#include "flatbuffers/reflection.h"
#include "flatbuffers/reflection_generated.h"
namespace flatbuffers {
@@ -36,6 +38,36 @@
// To reduce typing
namespace r = ::reflection;
+std::set<std::string> LuaKeywords() {
+ return { "and", "break", "do", "else", "elseif", "end",
+ "false", "for", "function", "goto", "if", "in",
+ "local", "nil", "not", "or", "repeat", "return",
+ "then", "true", "until", "while" };
+}
+
+Namer::Config LuaDefaultConfig() {
+ return { /*types=*/Case::kUpperCamel,
+ /*constants=*/Case::kUnknown,
+ /*methods=*/Case::kUpperCamel,
+ /*functions=*/Case::kUpperCamel,
+ /*fields=*/Case::kUpperCamel,
+ /*variables=*/Case::kLowerCamel,
+ /*variants=*/Case::kKeep,
+ /*enum_variant_seperator=*/"",
+ /*escape_keywords=*/Namer::Config::Escape::AfterConvertingCase,
+ /*namespaces=*/Case::kKeep,
+ /*namespace_seperator=*/"__",
+ /*object_prefix=*/"",
+ /*object_suffix=*/"",
+ /*keyword_prefix=*/"",
+ /*keyword_suffix=*/"_",
+ /*filenames=*/Case::kKeep,
+ /*directories=*/Case::kKeep,
+ /*output_path=*/"",
+ /*filename_suffix=*/"",
+ /*filename_extension=*/".lua" };
+}
+
class LuaBfbsGenerator : public BaseBfbsGenerator {
public:
explicit LuaBfbsGenerator(const std::string &flatc_version)
@@ -44,14 +76,8 @@
requires_(),
current_obj_(nullptr),
current_enum_(nullptr),
- flatc_version_(flatc_version) {
- static const char *const keywords[] = {
- "and", "break", "do", "else", "elseif", "end", "false", "for",
- "function", "goto", "if", "in", "local", "nil", "not", "or",
- "repeat", "return", "then", "true", "until", "while"
- };
- keywords_.insert(std::begin(keywords), std::end(keywords));
- }
+ flatc_version_(flatc_version),
+ namer_(LuaDefaultConfig(), LuaKeywords()) {}
GeneratorStatus GenerateFromSchema(const r::Schema *schema)
FLATBUFFERS_OVERRIDE {
@@ -76,14 +102,14 @@
std::string ns;
const std::string enum_name =
- NormalizeName(Denamespace(enum_def->name(), ns));
+ namer_.Type(namer_.Denamespace(enum_def, ns));
GenerateDocumentation(enum_def->documentation(), "", code);
code += "local " + enum_name + " = {\n";
ForAllEnumValues(enum_def, [&](const reflection::EnumVal *enum_val) {
GenerateDocumentation(enum_val->documentation(), " ", code);
- code += " " + NormalizeName(enum_val->name()) + " = " +
+ code += " " + namer_.Variant(enum_val->name()->str()) + " = " +
NumToString(enum_val->value()) + ",\n";
});
code += "}\n";
@@ -107,7 +133,7 @@
std::string ns;
const std::string object_name =
- NormalizeName(Denamespace(object->name(), ns));
+ namer_.Type(namer_.Denamespace(object, ns));
GenerateDocumentation(object->documentation(), "", code);
@@ -149,14 +175,12 @@
// Skip writing deprecated fields altogether.
if (field->deprecated()) { return; }
- const std::string field_name = NormalizeName(field->name());
- const std::string field_name_camel_case =
- ConvertCase(field_name, Case::kUpperCamel);
+ const std::string field_name = namer_.Field(field->name()->str());
const r::BaseType base_type = field->type()->base_type();
// Generate some fixed strings so we don't repeat outselves later.
const std::string getter_signature =
- "function mt:" + field_name_camel_case + "()\n";
+ "function mt:" + field_name + "()\n";
const std::string offset_prefix = "local o = self.view:Offset(" +
NumToString(field->offset()) + ")\n";
const std::string offset_prefix_2 = "if o ~= 0 then\n";
@@ -201,7 +225,7 @@
}
case r::Obj: {
if (object->is_struct()) {
- code += "function mt:" + field_name_camel_case + "(obj)\n";
+ code += "function mt:" + field_name + "(obj)\n";
code += " obj:Init(self.view.bytes, self.view.pos + " +
NumToString(field->offset()) + ")\n";
code += " return obj\n";
@@ -252,7 +276,7 @@
case r::Vector: {
const r::BaseType vector_base_type = field->type()->element();
int32_t element_size = field->type()->element_size();
- code += "function mt:" + field_name_camel_case + "(j)\n";
+ code += "function mt:" + field_name + "(j)\n";
code += " " + offset_prefix;
code += " " + offset_prefix_2;
@@ -297,8 +321,7 @@
// generate a helper function to get it as a byte string in
// Lua.
if (IsSingleByte(vector_base_type)) {
- code += "function mt:" + field_name_camel_case +
- "AsString(start, stop)\n";
+ code += "function mt:" + field_name + "AsString(start, stop)\n";
code += " return self.view:VectorAsString(" +
NumToString(field->offset()) + ", start, stop)\n";
code += "end\n";
@@ -307,7 +330,7 @@
// We also make a new accessor to query just the length of the
// vector.
- code += "function mt:" + field_name_camel_case + "Length()\n";
+ code += "function mt:" + field_name + "Length()\n";
code += " " + offset_prefix;
code += " " + offset_prefix_2;
code += " return self.view:VectorLen(o)\n";
@@ -344,21 +367,20 @@
ForAllFields(object, /*reverse=*/false, [&](const r::Field *field) {
if (field->deprecated()) { return; }
- const std::string field_name = NormalizeName(field->name());
+ const std::string field_name = namer_.Field(field->name()->str());
+ const std::string variable_name =
+ namer_.Variable(field->name()->str());
- code += "function " + object_name + ".Add" +
- ConvertCase(field_name, Case::kUpperCamel) + "(builder, " +
- ConvertCase(field_name, Case::kLowerCamel) + ")\n";
+ code += "function " + object_name + ".Add" + field_name +
+ "(builder, " + variable_name + ")\n";
code += " builder:Prepend" + GenerateMethod(field) + "Slot(" +
- NumToString(field->id()) + ", " +
- ConvertCase(field_name, Case::kLowerCamel) + ", " +
+ NumToString(field->id()) + ", " + variable_name + ", " +
DefaultValue(field) + ")\n";
code += "end\n";
code += "\n";
if (IsVector(field->type()->base_type())) {
- code += "function " + object_name + ".Start" +
- ConvertCase(field_name, Case::kUpperCamel) +
+ code += "function " + object_name + ".Start" + field_name +
"Vector(builder, numElems)\n";
const int32_t element_size = field->type()->element_size();
@@ -406,11 +428,9 @@
if (IsStructOrTable(field->type()->base_type())) {
const r::Object *field_object = GetObject(field->type());
signature += GenerateStructBuilderArgs(
- field_object, prefix + NormalizeName(field->name()) + "_");
+ field_object, prefix + namer_.Variable(field->name()->str()) + "_");
} else {
- signature +=
- ", " + prefix +
- ConvertCase(NormalizeName(field->name()), Case::kLowerCamel);
+ signature += ", " + prefix + namer_.Variable(field->name()->str());
}
});
return signature;
@@ -432,11 +452,10 @@
if (IsStructOrTable(field->type()->base_type())) {
const r::Object *field_object = GetObject(field->type());
code += AppendStructBuilderBody(
- field_object, prefix + NormalizeName(field->name()) + "_");
+ field_object, prefix + namer_.Variable(field->name()->str()) + "_");
} else {
code += " builder:Prepend" + GenerateMethod(field) + "(" + prefix +
- ConvertCase(NormalizeName(field->name()), Case::kLowerCamel) +
- ")\n";
+ namer_.Variable(field->name()->str()) + ")\n";
}
});
@@ -445,9 +464,7 @@
std::string GenerateMethod(const r::Field *field) const {
const r::BaseType base_type = field->type()->base_type();
- if (IsScalar(base_type)) {
- return ConvertCase(GenerateType(base_type), Case::kUpperCamel);
- }
+ if (IsScalar(base_type)) { return namer_.Type(GenerateType(base_type)); }
if (IsStructOrTable(base_type)) { return "Struct"; }
return "UOffsetTRelative";
}
@@ -460,9 +477,7 @@
case r::Vector: return GenerateGetter(type, true);
default:
return "self.view:Get(flatbuffers.N." +
- ConvertCase(GenerateType(type, element_type),
- Case::kUpperCamel) +
- ", ";
+ namer_.Type(GenerateType(type, element_type)) + ", ";
}
}
@@ -474,10 +489,8 @@
switch (base_type) {
case r::String: return "string";
case r::Vector: return GenerateGetter(type, true);
- case r::Obj: {
- const r::Object *obj = GetObject(type);
- return NormalizeName(Denamespace(obj->name()));
- };
+ case r::Obj: return namer_.Type(namer_.Denamespace(GetObject(type)));
+
default: return "*flatbuffers.Table";
}
}
@@ -515,14 +528,6 @@
return "0";
}
- std::string NormalizeName(const std::string name) const {
- return keywords_.find(name) == keywords_.end() ? name : "_" + name;
- }
-
- std::string NormalizeName(const flatbuffers::String *name) const {
- return NormalizeName(name->str());
- }
-
void StartCodeBlock(const reflection::Enum *enum_def) {
current_enum_ = enum_def;
current_obj_ = nullptr;
@@ -544,11 +549,11 @@
if (IsStructOrTable(type)) {
const r::Object *object = GetObjectByIndex(field->type()->index());
- if (object == current_obj_) { return Denamespace(object->name()); }
+ if (object == current_obj_) { return namer_.Denamespace(object); }
type_name = object->name()->str();
} else {
const r::Enum *enum_def = GetEnumByIndex(field->type()->index());
- if (enum_def == current_enum_) { return Denamespace(enum_def->name()); }
+ if (enum_def == current_enum_) { return namer_.Denamespace(enum_def); }
type_name = enum_def->name()->str();
}
@@ -600,7 +605,7 @@
// Namespaces are '.' deliminted, so replace it with the path separator.
std::string path = ns;
- if (path.empty()) {
+ if (ns.empty()) {
path = ".";
} else {
std::replace(path.begin(), path.end(), '.', '/');
@@ -608,7 +613,7 @@
// TODO(derekbailey): figure out a save file without depending on util.h
EnsureDirExists(path);
- const std::string file_name = path + "/" + name + ".lua";
+ const std::string file_name = path + "/" + namer_.File(name);
SaveFile(file_name.c_str(), code, false);
}
@@ -617,6 +622,7 @@
const r::Object *current_obj_;
const r::Enum *current_enum_;
const std::string flatc_version_;
+ const BfbsNamer namer_;
};
} // namespace
diff --git a/src/bfbs_namer.h b/src/bfbs_namer.h
new file mode 100644
index 0000000..2c6e724
--- /dev/null
+++ b/src/bfbs_namer.h
@@ -0,0 +1,43 @@
+#ifndef FLATBUFFERS_BFBS_NAMER
+#define FLATBUFFERS_BFBS_NAMER
+
+#include "flatbuffers/reflection.h"
+#include "namer.h"
+
+namespace flatbuffers {
+
+// Provides Namer capabilities to types defined in the flatbuffers reflection.
+class BfbsNamer : public Namer {
+ public:
+ explicit BfbsNamer(Config config, std::set<std::string> keywords)
+ : Namer(config, std::move(keywords)) {}
+
+ using Namer::Constant;
+ using Namer::Denamespace;
+ using Namer::Directories;
+ using Namer::Field;
+ using Namer::File;
+ using Namer::Function;
+ using Namer::Method;
+ using Namer::Namespace;
+ using Namer::NamespacedType;
+ using Namer::ObjectType;
+ using Namer::Type;
+ using Namer::Variable;
+ using Namer::Variant;
+
+ template<typename T>
+ std::string Denamespace(T t, std::string &namespace_prefix,
+ const char delimiter = '.') const {
+ return Namer::Denamespace(t->name()->c_str(), namespace_prefix, delimiter);
+ }
+
+ template<typename T>
+ std::string Denamespace(T t, const char delimiter = '.') const {
+ return Namer::Denamespace(t->name()->c_str(), delimiter);
+ }
+};
+
+} // namespace flatbuffers
+
+#endif // FLATBUFFERS_BFBS_NAMER
\ No newline at end of file
diff --git a/src/binary_annotator.cpp b/src/binary_annotator.cpp
new file mode 100644
index 0000000..dd0b454
--- /dev/null
+++ b/src/binary_annotator.cpp
@@ -0,0 +1,1419 @@
+#include "binary_annotator.h"
+
+#include <limits>
+#include <string>
+#include <vector>
+
+#include "flatbuffers/reflection.h"
+#include "flatbuffers/verifier.h"
+
+namespace flatbuffers {
+namespace {
+
+static bool BinaryRegionSort(const BinaryRegion &a, const BinaryRegion &b) {
+ return a.offset < b.offset;
+}
+
+static void SetError(BinaryRegionComment &comment, BinaryRegionStatus status,
+ std::string message = "") {
+ comment.status = status;
+ comment.status_message = message;
+}
+
+static BinaryRegion MakeBinaryRegion(
+ const uint64_t offset = 0, const uint64_t length = 0,
+ const BinaryRegionType type = BinaryRegionType::Unknown,
+ const uint64_t array_length = 0, const uint64_t points_to_offset = 0,
+ const BinaryRegionComment comment = {}) {
+ BinaryRegion region;
+ region.offset = offset;
+ region.length = length;
+ region.type = type;
+ region.array_length = array_length;
+ region.points_to_offset = points_to_offset;
+ region.comment = std::move(comment);
+ return region;
+}
+
+static BinarySection MakeBinarySection(
+ const std::string &name, const BinarySectionType type,
+ const std::vector<BinaryRegion> regions) {
+ BinarySection section;
+ section.name = name;
+ section.type = type;
+ section.regions = std::move(regions);
+ return section;
+}
+
+static BinarySection MakeSingleRegionBinarySection(const std::string &name,
+ const BinarySectionType type,
+ const BinaryRegion ®ion) {
+ std::vector<BinaryRegion> regions;
+ regions.push_back(region);
+ return MakeBinarySection(name, type, std::move(regions));
+}
+
+static bool IsNonZeroRegion(const uint64_t offset, const uint64_t length,
+ const uint8_t *const binary) {
+ for (uint64_t i = offset; i < offset + length; ++i) {
+ if (binary[i] != 0) { return true; }
+ }
+ return false;
+}
+
+static bool IsPrintableRegion(const uint64_t offset, const uint64_t length,
+ const uint8_t *const binary) {
+ for (uint64_t i = offset; i < offset + length; ++i) {
+ if (!isprint(binary[i])) { return false; }
+ }
+ return true;
+}
+
+static BinarySection GenerateMissingSection(const uint64_t offset,
+ const uint64_t length,
+ const uint8_t *const binary) {
+ std::vector<BinaryRegion> regions;
+
+ // Check if the region is all zeros or not, as that can tell us if it is
+ // padding or not.
+ if (IsNonZeroRegion(offset, length, binary)) {
+ // Some of the padding bytes are non-zero, so this might be an unknown
+ // section of the binary.
+ // TODO(dbaileychess): We could be a bit smarter with different sized
+ // alignments. For now, the 8 byte check encompasses all the smaller
+ // alignments.
+ BinaryRegionComment comment;
+ comment.type = BinaryRegionCommentType::Unknown;
+ if (length >= 8) {
+ SetError(comment, BinaryRegionStatus::WARN_NO_REFERENCES);
+ } else {
+ SetError(comment, BinaryRegionStatus::WARN_CORRUPTED_PADDING);
+ }
+
+ regions.push_back(MakeBinaryRegion(offset, length * sizeof(uint8_t),
+ BinaryRegionType::Unknown, length, 0,
+ comment));
+
+ return MakeBinarySection("no known references", BinarySectionType::Unknown,
+ std::move(regions));
+ }
+
+ BinaryRegionComment comment;
+ comment.type = BinaryRegionCommentType::Padding;
+ if (length >= 8) {
+ SetError(comment, BinaryRegionStatus::WARN_PADDING_LENGTH);
+ }
+
+ // This region is most likely padding.
+ regions.push_back(MakeBinaryRegion(offset, length * sizeof(uint8_t),
+ BinaryRegionType::Uint8, length, 0,
+ comment));
+
+ return MakeBinarySection("", BinarySectionType::Padding, std::move(regions));
+}
+
+} // namespace
+
+std::map<uint64_t, BinarySection> BinaryAnnotator::Annotate() {
+ flatbuffers::Verifier verifier(bfbs_, static_cast<size_t>(bfbs_length_));
+ if (!reflection::VerifySchemaBuffer(verifier)) { return {}; }
+
+ // The binary is too short to read as a flatbuffers.
+ // TODO(dbaileychess): We could spit out the annotated buffer sections, but
+ // I'm not sure if it is worth it.
+ if (binary_length_ < 4) { return {}; }
+
+ // Make sure we start with a clean slate.
+ vtables_.clear();
+ sections_.clear();
+
+ // First parse the header region which always start at offset 0.
+ // The returned offset will point to the root_table location.
+ const uint64_t root_table_offset = BuildHeader(0);
+
+ if (IsValidOffset(root_table_offset)) {
+ // Build the root table, and all else will be referenced from it.
+ BuildTable(root_table_offset, BinarySectionType::RootTable,
+ schema_->root_table());
+ }
+
+ // Now that all the sections are built, make sure the binary sections are
+ // contiguous.
+ FixMissingRegions();
+
+ // Then scan the area between BinarySections insert padding sections that are
+ // implied.
+ FixMissingSections();
+
+ return sections_;
+}
+
+uint64_t BinaryAnnotator::BuildHeader(const uint64_t header_offset) {
+ const auto root_table_offset = ReadScalar<uint32_t>(header_offset);
+
+ if (!root_table_offset.has_value()) {
+ // This shouldn't occur, since we validate the min size of the buffer
+ // before. But for completion sake, we shouldn't read passed the binary end.
+ return std::numeric_limits<uint64_t>::max();
+ }
+
+ std::vector<BinaryRegion> regions;
+ uint64_t offset = header_offset;
+ // TODO(dbaileychess): sized prefixed value
+
+ BinaryRegionComment root_offset_comment;
+ root_offset_comment.type = BinaryRegionCommentType::RootTableOffset;
+ root_offset_comment.name = schema_->root_table()->name()->str();
+
+ if (!IsValidOffset(root_table_offset.value())) {
+ SetError(root_offset_comment,
+ BinaryRegionStatus::ERROR_OFFSET_OUT_OF_BINARY);
+ }
+
+ regions.push_back(
+ MakeBinaryRegion(offset, sizeof(uint32_t), BinaryRegionType::UOffset, 0,
+ root_table_offset.value(), root_offset_comment));
+ offset += sizeof(uint32_t);
+
+ if (IsValidRead(offset, flatbuffers::kFileIdentifierLength) &&
+ IsPrintableRegion(offset, flatbuffers::kFileIdentifierLength, binary_)) {
+ BinaryRegionComment comment;
+ comment.type = BinaryRegionCommentType::FileIdentifier;
+ // Check if the file identifier region has non-zero data, and assume its
+ // the file identifier. Otherwise, it will get filled in with padding
+ // later.
+ regions.push_back(MakeBinaryRegion(
+ offset, flatbuffers::kFileIdentifierLength * sizeof(uint8_t),
+ BinaryRegionType::Char, flatbuffers::kFileIdentifierLength, 0,
+ comment));
+ }
+
+ AddSection(header_offset, MakeBinarySection("", BinarySectionType::Header,
+ std::move(regions)));
+
+ return root_table_offset.value();
+}
+
+void BinaryAnnotator::BuildVTable(const uint64_t vtable_offset,
+ const reflection::Object *const table,
+ const uint64_t offset_of_referring_table) {
+ // First see if we have used this vtable before, if so skip building it again.
+ auto it = vtables_.find(vtable_offset);
+ if (it != vtables_.end()) { return; }
+
+ if (ContainsSection(vtable_offset)) { return; }
+
+ BinaryRegionComment vtable_size_comment;
+ vtable_size_comment.type = BinaryRegionCommentType::VTableSize;
+
+ const auto vtable_length = ReadScalar<uint16_t>(vtable_offset);
+ if (!vtable_length.has_value()) {
+ const uint64_t remaining = RemainingBytes(vtable_offset);
+
+ SetError(vtable_size_comment, BinaryRegionStatus::ERROR_INCOMPLETE_BINARY,
+ "2");
+
+ AddSection(vtable_offset,
+ MakeSingleRegionBinarySection(
+ table->name()->str(), BinarySectionType::VTable,
+ MakeBinaryRegion(vtable_offset, remaining,
+ BinaryRegionType::Unknown, remaining, 0,
+ vtable_size_comment)));
+ return;
+ }
+
+ // Vtables start with the size of the vtable
+ const uint16_t vtable_size = vtable_length.value();
+
+ if (!IsValidOffset(vtable_offset + vtable_size - 1)) {
+ SetError(vtable_size_comment, BinaryRegionStatus::ERROR_LENGTH_TOO_LONG);
+ // The vtable_size points to off the end of the binary.
+ AddSection(vtable_offset,
+ MakeSingleRegionBinarySection(
+ table->name()->str(), BinarySectionType::VTable,
+ MakeBinaryRegion(vtable_offset, sizeof(uint16_t),
+ BinaryRegionType::Uint16, 0, 0,
+ vtable_size_comment)));
+
+ return;
+ } else if (vtable_size < 2 * sizeof(uint16_t)) {
+ SetError(vtable_size_comment, BinaryRegionStatus::ERROR_LENGTH_TOO_SHORT,
+ "4");
+ // The size includes itself and the table size which are both uint16_t.
+ AddSection(vtable_offset,
+ MakeSingleRegionBinarySection(
+ table->name()->str(), BinarySectionType::VTable,
+ MakeBinaryRegion(vtable_offset, sizeof(uint16_t),
+ BinaryRegionType::Uint16, 0, 0,
+ vtable_size_comment)));
+ return;
+ }
+
+ std::vector<BinaryRegion> regions;
+
+ regions.push_back(MakeBinaryRegion(vtable_offset, sizeof(uint16_t),
+ BinaryRegionType::Uint16, 0, 0,
+ vtable_size_comment));
+ uint64_t offset = vtable_offset + sizeof(uint16_t);
+
+ BinaryRegionComment ref_table_len_comment;
+ ref_table_len_comment.type =
+ BinaryRegionCommentType::VTableRefferingTableLength;
+
+ // Ensure we can read the next uint16_t field, which is the size of the
+ // referring table.
+ const auto table_length = ReadScalar<uint16_t>(offset);
+
+ if (!table_length.has_value()) {
+ const uint64_t remaining = RemainingBytes(offset);
+ SetError(ref_table_len_comment, BinaryRegionStatus::ERROR_INCOMPLETE_BINARY,
+ "2");
+
+ AddSection(offset, MakeSingleRegionBinarySection(
+ table->name()->str(), BinarySectionType::VTable,
+ MakeBinaryRegion(
+ offset, remaining, BinaryRegionType::Unknown,
+ remaining, 0, ref_table_len_comment)));
+ return;
+ }
+
+ // Then they have the size of the table they reference.
+ const uint16_t table_size = table_length.value();
+
+ if (!IsValidOffset(offset_of_referring_table + table_size - 1)) {
+ SetError(ref_table_len_comment, BinaryRegionStatus::ERROR_LENGTH_TOO_LONG);
+ } else if (table_size < 4) {
+ SetError(ref_table_len_comment, BinaryRegionStatus::ERROR_LENGTH_TOO_SHORT,
+ "4");
+ }
+
+ regions.push_back(MakeBinaryRegion(offset, sizeof(uint16_t),
+ BinaryRegionType::Uint16, 0, 0,
+ ref_table_len_comment));
+ offset += sizeof(uint16_t);
+
+ const uint64_t offset_start = offset;
+
+ // A mapping between field (and its id) to the relative offset (uin16_t) from
+ // the start of the table.
+ std::map<uint16_t, VTable::Entry> fields;
+
+ // Counter for determining if the binary has more vtable entries than the
+ // schema provided. This can occur if the binary was created at a newer schema
+ // version and is being processed with an older one.
+ uint16_t fields_processed = 0;
+
+ // Loop over all the fields.
+ ForAllFields(table, /*reverse=*/false, [&](const reflection::Field *field) {
+ const uint64_t field_offset = offset_start + field->id() * sizeof(uint16_t);
+
+ if (field_offset >= vtable_offset + vtable_size) {
+ // This field_offset is too large for this vtable, so it must come from a
+ // newer schema than the binary was create with or the binary writer did
+ // not write it. For either case, it is safe to ignore.
+
+ // TODO(dbaileychess): We could show which fields are not set an their
+ // default values if we want. We just need a way to make it obvious that
+ // it isn't part of the buffer.
+ return;
+ }
+
+ BinaryRegionComment field_comment;
+ field_comment.type = BinaryRegionCommentType::VTableFieldOffset;
+ field_comment.name = std::string(field->name()->c_str()) +
+ "` (id: " + std::to_string(field->id()) + ")";
+
+ const auto offset_from_table = ReadScalar<uint16_t>(field_offset);
+
+ if (!offset_from_table.has_value()) {
+ const uint64_t remaining = RemainingBytes(field_offset);
+
+ SetError(field_comment, BinaryRegionStatus::ERROR_INCOMPLETE_BINARY, "2");
+ regions.push_back(MakeBinaryRegion(field_offset, remaining,
+ BinaryRegionType::Unknown, remaining,
+ 0, field_comment));
+
+ return;
+ }
+
+ if (!IsValidOffset(offset_of_referring_table + offset_from_table.value() -
+ 1)) {
+ SetError(field_comment, BinaryRegionStatus::ERROR_OFFSET_OUT_OF_BINARY);
+ regions.push_back(MakeBinaryRegion(field_offset, sizeof(uint16_t),
+ BinaryRegionType::VOffset, 0, 0,
+ field_comment));
+ return;
+ }
+
+ VTable::Entry entry;
+ entry.field = field;
+ entry.offset_from_table = offset_from_table.value();
+ fields.insert(std::make_pair(field->id(), entry));
+
+ std::string default_label;
+ if (offset_from_table.value() == 0) {
+ // Not present, so could be default or be optional.
+ if (field->required()) {
+ SetError(field_comment,
+ BinaryRegionStatus::ERROR_REQUIRED_FIELD_NOT_PRESENT);
+ // If this is a required field, make it known this is an error.
+ regions.push_back(MakeBinaryRegion(field_offset, sizeof(uint16_t),
+ BinaryRegionType::VOffset, 0, 0,
+ field_comment));
+ return;
+ } else {
+ // Its an optional field, so get the default value and interpret and
+ // provided an annotation for it.
+ if (IsScalar(field->type()->base_type())) {
+ default_label += "<defaults to ";
+ default_label += IsFloat(field->type()->base_type())
+ ? std::to_string(field->default_real())
+ : std::to_string(field->default_integer());
+ default_label += "> (";
+ } else {
+ default_label += "<null> (";
+ }
+ default_label +=
+ reflection::EnumNameBaseType(field->type()->base_type());
+ default_label += ")";
+ }
+ }
+ field_comment.default_value = default_label;
+
+ regions.push_back(MakeBinaryRegion(field_offset, sizeof(uint16_t),
+ BinaryRegionType::VOffset, 0, 0,
+ field_comment));
+
+ fields_processed++;
+ });
+
+ // Check if we covered all the expectant fields. If not, we need to add them
+ // as unknown fields.
+ uint16_t expectant_vtable_fields =
+ (vtable_size - sizeof(uint16_t) - sizeof(uint16_t)) / sizeof(uint16_t);
+
+ // Prevent a bad binary from declaring a really large vtable_size, that we can
+ // not indpendently verify.
+ expectant_vtable_fields = std::min(
+ static_cast<uint16_t>(fields_processed * 3), expectant_vtable_fields);
+
+ for (uint16_t id = fields_processed; id < expectant_vtable_fields; ++id) {
+ const uint64_t field_offset = offset_start + id * sizeof(uint16_t);
+
+ const auto offset_from_table = ReadScalar<uint16_t>(field_offset);
+
+ BinaryRegionComment field_comment;
+ field_comment.type = BinaryRegionCommentType::VTableUnknownFieldOffset;
+ field_comment.index = id;
+
+ if (!offset_from_table.has_value()) {
+ const uint64_t remaining = RemainingBytes(field_offset);
+ SetError(field_comment, BinaryRegionStatus::ERROR_INCOMPLETE_BINARY, "2");
+ regions.push_back(MakeBinaryRegion(field_offset, remaining,
+ BinaryRegionType::Unknown, remaining,
+ 0, field_comment));
+ continue;
+ }
+
+ VTable::Entry entry;
+ entry.field = nullptr; // No field to reference.
+ entry.offset_from_table = offset_from_table.value();
+ fields.insert(std::make_pair(id, entry));
+
+ regions.push_back(MakeBinaryRegion(field_offset, sizeof(uint16_t),
+ BinaryRegionType::VOffset, 0, 0,
+ field_comment));
+ }
+
+ sections_[vtable_offset] = MakeBinarySection(
+ table->name()->str(), BinarySectionType::VTable, std::move(regions));
+
+ VTable vtable;
+ vtable.fields = std::move(fields);
+ vtable.table_size = table_size;
+ vtable.vtable_size = vtable_size;
+
+ vtables_[vtable_offset] = vtable;
+}
+
+void BinaryAnnotator::BuildTable(const uint64_t table_offset,
+ const BinarySectionType type,
+ const reflection::Object *const table) {
+ if (ContainsSection(table_offset)) { return; }
+
+ BinaryRegionComment vtable_offset_comment;
+ vtable_offset_comment.type = BinaryRegionCommentType::TableVTableOffset;
+
+ const auto vtable_soffset = ReadScalar<int32_t>(table_offset);
+
+ if (!vtable_soffset.has_value()) {
+ const uint64_t remaining = RemainingBytes(table_offset);
+ SetError(vtable_offset_comment, BinaryRegionStatus::ERROR_INCOMPLETE_BINARY,
+ "4");
+
+ AddSection(
+ table_offset,
+ MakeSingleRegionBinarySection(
+ table->name()->str(), type,
+ MakeBinaryRegion(table_offset, remaining, BinaryRegionType::Unknown,
+ remaining, 0, vtable_offset_comment)));
+
+ // If there aren't enough bytes left to read the vtable offset, there is
+ // nothing we can do.
+ return;
+ }
+
+ // Tables start with the vtable
+ const uint64_t vtable_offset = table_offset - vtable_soffset.value();
+
+ if (!IsValidOffset(vtable_offset)) {
+ SetError(vtable_offset_comment,
+ BinaryRegionStatus::ERROR_OFFSET_OUT_OF_BINARY);
+
+ AddSection(table_offset,
+ MakeSingleRegionBinarySection(
+ table->name()->str(), type,
+ MakeBinaryRegion(table_offset, sizeof(int32_t),
+ BinaryRegionType::SOffset, 0, vtable_offset,
+ vtable_offset_comment)));
+
+ // There isn't much to do with an invalid vtable offset, as we won't be able
+ // to intepret the rest of the table fields.
+ return;
+ }
+
+ std::vector<BinaryRegion> regions;
+ regions.push_back(MakeBinaryRegion(table_offset, sizeof(int32_t),
+ BinaryRegionType::SOffset, 0,
+ vtable_offset, vtable_offset_comment));
+
+ // Parse the vtable first so we know what the rest of the fields in the table
+ // are.
+ BuildVTable(vtable_offset, table, table_offset);
+
+ auto vtable_entry = vtables_.find(vtable_offset);
+ if (vtable_entry == vtables_.end()) {
+ // There is no valid vtable for this table, so we cannot process the rest of
+ // the table entries.
+ return;
+ }
+
+ const VTable &vtable = vtable_entry->second;
+
+ // This is the size and length of this table.
+ const uint16_t table_size = vtable.table_size;
+ uint64_t table_end_offset = table_offset + table_size;
+
+ if (!IsValidOffset(table_end_offset - 1)) {
+ // We already validated the table size in BuildVTable, but we have to make
+ // sure we don't use a bad value here.
+ table_end_offset = binary_length_;
+ }
+
+ // We need to iterate over the vtable fields by their offset in the binary,
+ // not by their IDs. So copy them over to another vector that we can sort on
+ // the offset_from_table property.
+ std::vector<VTable::Entry> fields;
+ for (const auto &vtable_field : vtable.fields) {
+ fields.push_back(vtable_field.second);
+ }
+
+ std::stable_sort(fields.begin(), fields.end(),
+ [](const VTable::Entry &a, const VTable::Entry &b) {
+ return a.offset_from_table < b.offset_from_table;
+ });
+
+ // Iterate over all the fields by order of their offset.
+ for (size_t i = 0; i < fields.size(); ++i) {
+ const reflection::Field *field = fields[i].field;
+ const uint16_t offset_from_table = fields[i].offset_from_table;
+
+ if (offset_from_table == 0) {
+ // Skip non-present fields.
+ continue;
+ }
+
+ // The field offsets are relative to the start of the table.
+ const uint64_t field_offset = table_offset + offset_from_table;
+
+ if (!IsValidOffset(field_offset)) {
+ // The field offset is larger than the binary, nothing we can do.
+ continue;
+ }
+
+ // We have a vtable entry for a non-existant field, that means its a binary
+ // generated by a newer schema than we are currently processing.
+ if (field == nullptr) {
+ // Calculate the length of this unknown field.
+ const uint64_t unknown_field_length =
+ // Check if there is another unknown field after this one.
+ ((i + 1 < fields.size())
+ ? table_offset + fields[i + 1].offset_from_table
+ // Otherwise use the known end of the table.
+ : table_end_offset) -
+ field_offset;
+
+ if (unknown_field_length == 0) { continue; }
+
+ std::string hint;
+
+ if (unknown_field_length == 4) {
+ const auto relative_offset = ReadScalar<uint32_t>(field_offset);
+ if (relative_offset.has_value()) {
+ // The field is 4 in length, so it could be an offset? Provide a hint.
+ hint += "<possibly an offset? Check Loc: +0x";
+ hint += ToHex(field_offset + relative_offset.value());
+ hint += ">";
+ }
+ }
+
+ BinaryRegionComment unknown_field_comment;
+ unknown_field_comment.type = BinaryRegionCommentType::TableUnknownField;
+
+ if (!IsValidRead(field_offset, unknown_field_length)) {
+ const uint64_t remaining = RemainingBytes(field_offset);
+
+ SetError(unknown_field_comment,
+ BinaryRegionStatus::ERROR_INCOMPLETE_BINARY,
+ std::to_string(unknown_field_length));
+
+ regions.push_back(MakeBinaryRegion(field_offset, remaining,
+ BinaryRegionType::Unknown, remaining,
+ 0, unknown_field_comment));
+ continue;
+ }
+
+ unknown_field_comment.default_value = hint;
+
+ regions.push_back(MakeBinaryRegion(
+ field_offset, unknown_field_length, BinaryRegionType::Unknown,
+ unknown_field_length, 0, unknown_field_comment));
+ continue;
+ }
+
+ if (IsScalar(field->type()->base_type())) {
+ // These are the raw values store in the table.
+ const uint64_t type_size = GetTypeSize(field->type()->base_type());
+ const BinaryRegionType region_type =
+ GetRegionType(field->type()->base_type());
+
+ BinaryRegionComment scalar_field_comment;
+ scalar_field_comment.type = BinaryRegionCommentType::TableField;
+ scalar_field_comment.name =
+ std::string(field->name()->c_str()) + "` (" +
+ reflection::EnumNameBaseType(field->type()->base_type()) + ")";
+
+ if (!IsValidRead(field_offset, type_size)) {
+ const uint64_t remaining = RemainingBytes(field_offset);
+ SetError(scalar_field_comment,
+ BinaryRegionStatus::ERROR_INCOMPLETE_BINARY,
+ std::to_string(type_size));
+
+ regions.push_back(MakeBinaryRegion(field_offset, remaining,
+ BinaryRegionType::Unknown, remaining,
+ 0, scalar_field_comment));
+ continue;
+ }
+
+ if (IsUnionType(field)) {
+ // This is a type for a union. Validate the value
+ const auto enum_value = ReadScalar<uint8_t>(field_offset);
+
+ // This should always have a value, due to the IsValidRead check above.
+ if (!IsValidUnionValue(field, enum_value.value())) {
+ SetError(scalar_field_comment,
+ BinaryRegionStatus::ERROR_INVALID_UNION_TYPE);
+
+ regions.push_back(MakeBinaryRegion(field_offset, type_size,
+ region_type, 0, 0,
+ scalar_field_comment));
+ continue;
+ }
+ }
+
+ regions.push_back(MakeBinaryRegion(field_offset, type_size, region_type,
+ 0, 0, scalar_field_comment));
+ continue;
+ }
+
+ // Read the offset
+ const auto offset_from_field = ReadScalar<uint32_t>(field_offset);
+ uint64_t offset_of_next_item = 0;
+ BinaryRegionComment offset_field_comment;
+ offset_field_comment.type = BinaryRegionCommentType::TableOffsetField;
+ offset_field_comment.name = field->name()->c_str();
+ const std::string offset_prefix =
+ "offset to field `" + std::string(field->name()->c_str()) + "`";
+
+ // Validate any field that isn't inline (i.e., non-structs).
+ if (!IsInlineField(field)) {
+ if (!offset_from_field.has_value()) {
+ const uint64_t remaining = RemainingBytes(field_offset);
+
+ SetError(offset_field_comment,
+ BinaryRegionStatus::ERROR_INCOMPLETE_BINARY, "4");
+
+ regions.push_back(MakeBinaryRegion(field_offset, remaining,
+ BinaryRegionType::Unknown, remaining,
+ 0, offset_field_comment));
+ continue;
+ }
+
+ offset_of_next_item = field_offset + offset_from_field.value();
+
+ if (!IsValidOffset(offset_of_next_item)) {
+ SetError(offset_field_comment,
+ BinaryRegionStatus::ERROR_OFFSET_OUT_OF_BINARY);
+ regions.push_back(MakeBinaryRegion(
+ field_offset, sizeof(uint32_t), BinaryRegionType::UOffset, 0,
+ offset_of_next_item, offset_field_comment));
+ continue;
+ }
+ }
+
+ switch (field->type()->base_type()) {
+ case reflection::BaseType::Obj: {
+ const reflection::Object *next_object =
+ schema_->objects()->Get(field->type()->index());
+
+ if (next_object->is_struct()) {
+ // Structs are stored inline.
+ BuildStruct(field_offset, regions, next_object);
+ } else {
+ offset_field_comment.default_value = "(table)";
+
+ regions.push_back(MakeBinaryRegion(
+ field_offset, sizeof(uint32_t), BinaryRegionType::UOffset, 0,
+ offset_of_next_item, offset_field_comment));
+
+ BuildTable(offset_of_next_item, BinarySectionType::Table,
+ next_object);
+ }
+ } break;
+
+ case reflection::BaseType::String: {
+ offset_field_comment.default_value = "(string)";
+ regions.push_back(MakeBinaryRegion(
+ field_offset, sizeof(uint32_t), BinaryRegionType::UOffset, 0,
+ offset_of_next_item, offset_field_comment));
+ BuildString(offset_of_next_item, table, field);
+ } break;
+
+ case reflection::BaseType::Vector: {
+ offset_field_comment.default_value = "(vector)";
+ regions.push_back(MakeBinaryRegion(
+ field_offset, sizeof(uint32_t), BinaryRegionType::UOffset, 0,
+ offset_of_next_item, offset_field_comment));
+ BuildVector(offset_of_next_item, table, field, table_offset, vtable);
+ } break;
+
+ case reflection::BaseType::Union: {
+ const uint64_t union_offset = offset_of_next_item;
+
+ // The union type field is always one less than the union itself.
+ const uint16_t union_type_id = field->id() - 1;
+
+ auto vtable_field = vtable.fields.find(union_type_id);
+ if (vtable_field == vtable.fields.end()) {
+ // TODO(dbaileychess): need to capture this error condition.
+ break;
+ }
+ offset_field_comment.default_value = "(union)";
+
+ const uint64_t type_offset =
+ table_offset + vtable_field->second.offset_from_table;
+
+ const auto realized_type = ReadScalar<uint8_t>(type_offset);
+ if (!realized_type.has_value()) {
+ const uint64_t remaining = RemainingBytes(type_offset);
+ SetError(offset_field_comment,
+ BinaryRegionStatus::ERROR_INCOMPLETE_BINARY, "1");
+ regions.push_back(MakeBinaryRegion(
+ type_offset, remaining, BinaryRegionType::Unknown, remaining, 0,
+ offset_field_comment));
+ continue;
+ }
+
+ if (!IsValidUnionValue(field, realized_type.value())) {
+ // We already export an error in the union type field, so just skip
+ // building the union itself and it will default to an unreference
+ // Binary section.
+ continue;
+ }
+
+ const std::string enum_type =
+ BuildUnion(union_offset, realized_type.value(), field);
+
+ offset_field_comment.default_value =
+ "(union of type `" + enum_type + "`)";
+
+ regions.push_back(MakeBinaryRegion(field_offset, sizeof(uint32_t),
+ BinaryRegionType::UOffset, 0,
+ union_offset, offset_field_comment));
+
+ } break;
+
+ default: break;
+ }
+ }
+
+ // Handle the case where there is padding after the last known binary
+ // region. Calculate where we left off towards the expected end of the
+ // table.
+ const uint64_t i = regions.back().offset + regions.back().length + 1;
+
+ if (i < table_end_offset) {
+ const uint64_t pad_bytes = table_end_offset - i + 1;
+
+ BinaryRegionComment padding_comment;
+ padding_comment.type = BinaryRegionCommentType::Padding;
+
+ regions.push_back(MakeBinaryRegion(i - 1, pad_bytes * sizeof(uint8_t),
+ BinaryRegionType::Uint8, pad_bytes, 0,
+ padding_comment));
+ }
+
+ AddSection(table_offset,
+ MakeBinarySection(table->name()->str(), type, std::move(regions)));
+}
+
+uint64_t BinaryAnnotator::BuildStruct(const uint64_t struct_offset,
+ std::vector<BinaryRegion> ®ions,
+ const reflection::Object *const object) {
+ if (!object->is_struct()) { return struct_offset; }
+ uint64_t offset = struct_offset;
+
+ // Loop over all the fields in increasing order
+ ForAllFields(object, /*reverse=*/false, [&](const reflection::Field *field) {
+ if (IsScalar(field->type()->base_type())) {
+ // Structure Field value
+ const uint64_t type_size = GetTypeSize(field->type()->base_type());
+ const BinaryRegionType region_type =
+ GetRegionType(field->type()->base_type());
+
+ BinaryRegionComment comment;
+ comment.type = BinaryRegionCommentType::StructField;
+ comment.name =
+ std::string(object->name()->c_str()) + "." + field->name()->c_str();
+ comment.default_value = "(" +
+ std::string(reflection::EnumNameBaseType(
+ field->type()->base_type())) +
+ ")";
+
+ if (!IsValidRead(offset, type_size)) {
+ const uint64_t remaining = RemainingBytes(offset);
+ SetError(comment, BinaryRegionStatus::ERROR_INCOMPLETE_BINARY,
+ std::to_string(type_size));
+ regions.push_back(MakeBinaryRegion(offset, remaining,
+ BinaryRegionType::Unknown, remaining,
+ 0, comment));
+
+ // TODO(dbaileychess): Should I bail out here? This sets offset to the
+ // end of the binary. So all other reads in the loop should fail.
+ offset += remaining;
+ return;
+ }
+
+ regions.push_back(
+ MakeBinaryRegion(offset, type_size, region_type, 0, 0, comment));
+ offset += type_size;
+ } else if (field->type()->base_type() == reflection::BaseType::Obj) {
+ // Structs are stored inline, even when nested.
+ offset = BuildStruct(offset, regions,
+ schema_->objects()->Get(field->type()->index()));
+ } else if (field->type()->base_type() == reflection::BaseType::Array) {
+ const bool is_scalar = IsScalar(field->type()->element());
+ const uint64_t type_size = GetTypeSize(field->type()->element());
+ const BinaryRegionType region_type =
+ GetRegionType(field->type()->element());
+
+ // Arrays are just repeated structures.
+ for (uint16_t i = 0; i < field->type()->fixed_length(); ++i) {
+ if (is_scalar) {
+ BinaryRegionComment array_comment;
+ array_comment.type = BinaryRegionCommentType::ArrayField;
+ array_comment.name = std::string(object->name()->c_str()) + "." +
+ field->name()->c_str();
+ array_comment.index = i;
+ array_comment.default_value =
+ "(" +
+ std::string(
+ reflection::EnumNameBaseType(field->type()->element())) +
+ ")";
+
+ if (!IsValidRead(offset, type_size)) {
+ const uint64_t remaining = RemainingBytes(offset);
+
+ SetError(array_comment, BinaryRegionStatus::ERROR_INCOMPLETE_BINARY,
+ std::to_string(type_size));
+
+ regions.push_back(MakeBinaryRegion(offset, remaining,
+ BinaryRegionType::Unknown,
+ remaining, 0, array_comment));
+
+ // TODO(dbaileychess): Should I bail out here? This sets offset to
+ // the end of the binary. So all other reads in the loop should
+ // fail.
+ offset += remaining;
+ break;
+ }
+
+ regions.push_back(MakeBinaryRegion(offset, type_size, region_type, 0,
+ 0, array_comment));
+
+ offset += type_size;
+ } else {
+ // Array of Structs.
+ //
+ // TODO(dbaileychess): This works, but the comments on the fields lose
+ // some context. Need to figure a way how to plumb the nested arrays
+ // comments together that isn't too confusing.
+ offset = BuildStruct(offset, regions,
+ schema_->objects()->Get(field->type()->index()));
+ }
+ }
+ }
+
+ // Insert any padding after this field.
+ const uint16_t padding = field->padding();
+ if (padding > 0 && IsValidOffset(offset + padding)) {
+ BinaryRegionComment padding_comment;
+ padding_comment.type = BinaryRegionCommentType::Padding;
+
+ regions.push_back(MakeBinaryRegion(offset, padding,
+ BinaryRegionType::Uint8, padding, 0,
+ padding_comment));
+ offset += padding;
+ }
+ });
+
+ return offset;
+}
+
+void BinaryAnnotator::BuildString(const uint64_t string_offset,
+ const reflection::Object *const table,
+ const reflection::Field *const field) {
+ // Check if we have already generated this string section, and this is a
+ // shared string instance.
+ if (ContainsSection(string_offset)) { return; }
+
+ std::vector<BinaryRegion> regions;
+ const auto string_length = ReadScalar<uint32_t>(string_offset);
+
+ BinaryRegionComment string_length_comment;
+ string_length_comment.type = BinaryRegionCommentType::StringLength;
+
+ if (!string_length.has_value()) {
+ const uint64_t remaining = RemainingBytes(string_offset);
+
+ SetError(string_length_comment, BinaryRegionStatus::ERROR_INCOMPLETE_BINARY,
+ "4");
+
+ regions.push_back(MakeBinaryRegion(string_offset, remaining,
+ BinaryRegionType::Unknown, remaining, 0,
+ string_length_comment));
+
+ } else {
+ const uint32_t string_size = string_length.value();
+ const uint64_t string_end =
+ string_offset + sizeof(uint32_t) + string_size + sizeof(char);
+
+ if (!IsValidOffset(string_end - 1)) {
+ SetError(string_length_comment,
+ BinaryRegionStatus::ERROR_LENGTH_TOO_LONG);
+
+ regions.push_back(MakeBinaryRegion(string_offset, sizeof(uint32_t),
+ BinaryRegionType::Uint32, 0, 0,
+ string_length_comment));
+ } else {
+ regions.push_back(MakeBinaryRegion(string_offset, sizeof(uint32_t),
+ BinaryRegionType::Uint32, 0, 0,
+ string_length_comment));
+
+ BinaryRegionComment string_comment;
+ string_comment.type = BinaryRegionCommentType::StringValue;
+
+ regions.push_back(MakeBinaryRegion(string_offset + sizeof(uint32_t),
+ string_size, BinaryRegionType::Char,
+ string_size, 0, string_comment));
+
+ BinaryRegionComment string_terminator_comment;
+ string_terminator_comment.type =
+ BinaryRegionCommentType::StringTerminator;
+
+ regions.push_back(MakeBinaryRegion(
+ string_offset + sizeof(uint32_t) + string_size, sizeof(char),
+ BinaryRegionType::Char, 0, 0, string_terminator_comment));
+ }
+ }
+
+ AddSection(string_offset,
+ MakeBinarySection(std::string(table->name()->c_str()) + "." +
+ field->name()->c_str(),
+ BinarySectionType::String, std::move(regions)));
+}
+
+void BinaryAnnotator::BuildVector(const uint64_t vector_offset,
+ const reflection::Object *const table,
+ const reflection::Field *const field,
+ const uint64_t parent_table_offset,
+ const VTable &vtable) {
+ if (ContainsSection(vector_offset)) { return; }
+
+ BinaryRegionComment vector_length_comment;
+ vector_length_comment.type = BinaryRegionCommentType::VectorLength;
+
+ const auto vector_length = ReadScalar<uint32_t>(vector_offset);
+ if (!vector_length.has_value()) {
+ const uint64_t remaining = RemainingBytes(vector_offset);
+ SetError(vector_length_comment, BinaryRegionStatus::ERROR_INCOMPLETE_BINARY,
+ "4");
+
+ AddSection(
+ vector_offset,
+ MakeSingleRegionBinarySection(
+ std::string(table->name()->c_str()) + "." + field->name()->c_str(),
+ BinarySectionType::Vector,
+ MakeBinaryRegion(vector_offset, remaining,
+ BinaryRegionType::Unknown, remaining, 0,
+ vector_length_comment)));
+ return;
+ }
+
+ // Validate there are enough bytes left in the binary to process all the
+ // items.
+ const uint64_t last_item_offset =
+ vector_offset + sizeof(uint32_t) +
+ vector_length.value() * GetElementSize(field);
+
+ if (!IsValidOffset(last_item_offset - 1)) {
+ SetError(vector_length_comment, BinaryRegionStatus::ERROR_LENGTH_TOO_LONG);
+ AddSection(
+ vector_offset,
+ MakeSingleRegionBinarySection(
+ std::string(table->name()->c_str()) + "." + field->name()->c_str(),
+ BinarySectionType::Vector,
+ MakeBinaryRegion(vector_offset, sizeof(uint32_t),
+ BinaryRegionType::Uint32, 0, 0,
+ vector_length_comment)));
+
+ return;
+ }
+
+ std::vector<BinaryRegion> regions;
+
+ regions.push_back(MakeBinaryRegion(vector_offset, sizeof(uint32_t),
+ BinaryRegionType::Uint32, 0, 0,
+ vector_length_comment));
+
+ uint64_t offset = vector_offset + sizeof(uint32_t);
+
+ switch (field->type()->element()) {
+ case reflection::BaseType::Obj: {
+ const reflection::Object *object =
+ schema_->objects()->Get(field->type()->index());
+
+ if (object->is_struct()) {
+ // Vector of structs
+ for (size_t i = 0; i < vector_length.value(); ++i) {
+ // Structs are inline to the vector.
+ const uint64_t next_offset = BuildStruct(offset, regions, object);
+ if (next_offset == offset) { break; }
+ offset = next_offset;
+ }
+ } else {
+ // Vector of objects
+ for (size_t i = 0; i < vector_length.value(); ++i) {
+ BinaryRegionComment vector_object_comment;
+ vector_object_comment.type =
+ BinaryRegionCommentType::VectorTableValue;
+ vector_object_comment.index = i;
+
+ const auto table_relative_offset = ReadScalar<uint32_t>(offset);
+ if (!table_relative_offset.has_value()) {
+ const uint64_t remaining = RemainingBytes(offset);
+ SetError(vector_object_comment,
+ BinaryRegionStatus::ERROR_INCOMPLETE_BINARY, "4");
+
+ regions.push_back(
+ MakeBinaryRegion(offset, remaining, BinaryRegionType::Unknown,
+ remaining, 0, vector_object_comment));
+ break;
+ }
+
+ // The table offset is relative from the offset location itself.
+ const uint64_t table_offset = offset + table_relative_offset.value();
+
+ if (!IsValidOffset(table_offset)) {
+ SetError(vector_object_comment,
+ BinaryRegionStatus::ERROR_OFFSET_OUT_OF_BINARY);
+ regions.push_back(MakeBinaryRegion(
+ offset, sizeof(uint32_t), BinaryRegionType::UOffset, 0,
+ table_offset, vector_object_comment));
+
+ offset += sizeof(uint32_t);
+ continue;
+ }
+
+ if (table_offset == parent_table_offset) {
+ SetError(vector_object_comment,
+ BinaryRegionStatus::ERROR_CYCLE_DETECTED);
+ // A cycle detected where a table vector field is pointing to
+ // itself. This should only happen in corrupted files.
+ regions.push_back(MakeBinaryRegion(
+ offset, sizeof(uint32_t), BinaryRegionType::UOffset, 0,
+ table_offset, vector_object_comment));
+
+ offset += sizeof(uint32_t);
+ continue;
+ }
+
+ regions.push_back(MakeBinaryRegion(
+ offset, sizeof(uint32_t), BinaryRegionType::UOffset, 0,
+ table_offset, vector_object_comment));
+
+ offset += sizeof(uint32_t);
+
+ BuildTable(table_offset, BinarySectionType::Table, object);
+ }
+ }
+ } break;
+ case reflection::BaseType::String: {
+ // Vector of strings
+ for (size_t i = 0; i < vector_length.value(); ++i) {
+ BinaryRegionComment vector_object_comment;
+ vector_object_comment.type = BinaryRegionCommentType::VectorStringValue;
+ vector_object_comment.index = i;
+
+ const auto string_relative_offset = ReadScalar<uint32_t>(offset);
+ if (!string_relative_offset.has_value()) {
+ const uint64_t remaining = RemainingBytes(offset);
+
+ SetError(vector_object_comment,
+ BinaryRegionStatus::ERROR_INCOMPLETE_BINARY, "4");
+
+ regions.push_back(
+ MakeBinaryRegion(offset, remaining, BinaryRegionType::Unknown,
+ remaining, 0, vector_object_comment));
+ break;
+ }
+
+ // The string offset is relative from the offset location itself.
+ const uint64_t string_offset = offset + string_relative_offset.value();
+
+ if (!IsValidOffset(string_offset)) {
+ SetError(vector_object_comment,
+ BinaryRegionStatus::ERROR_OFFSET_OUT_OF_BINARY);
+ regions.push_back(MakeBinaryRegion(
+ offset, sizeof(uint32_t), BinaryRegionType::UOffset, 0,
+ string_offset, vector_object_comment));
+
+ offset += sizeof(uint32_t);
+ continue;
+ }
+
+ regions.push_back(MakeBinaryRegion(
+ offset, sizeof(uint32_t), BinaryRegionType::UOffset, 0,
+ string_offset, vector_object_comment));
+
+ BuildString(string_offset, table, field);
+
+ offset += sizeof(uint32_t);
+ }
+ } break;
+ case reflection::BaseType::Union: {
+ // Vector of unions
+ // Unions have both their realized type (uint8_t for now) that are
+ // stored separately. These are stored in the field->index() - 1
+ // location.
+ const uint16_t union_type_vector_id = field->id() - 1;
+
+ auto vtable_entry = vtable.fields.find(union_type_vector_id);
+ if (vtable_entry == vtable.fields.end()) {
+ // TODO(dbaileychess): need to capture this error condition.
+ break;
+ }
+
+ const uint64_t union_type_vector_field_offset =
+ parent_table_offset + vtable_entry->second.offset_from_table;
+
+ const auto union_type_vector_field_relative_offset =
+ ReadScalar<uint16_t>(union_type_vector_field_offset);
+
+ if (!union_type_vector_field_relative_offset.has_value()) {
+ const uint64_t remaining = RemainingBytes(offset);
+ BinaryRegionComment vector_union_comment;
+ vector_union_comment.type = BinaryRegionCommentType::VectorUnionValue;
+ SetError(vector_union_comment,
+ BinaryRegionStatus::ERROR_INCOMPLETE_BINARY, "2");
+
+ regions.push_back(MakeBinaryRegion(offset, remaining,
+ BinaryRegionType::Unknown, remaining,
+ 0, vector_union_comment));
+
+ break;
+ }
+
+ // Get the offset to the first type (the + sizeof(uint32_t) is to skip
+ // over the vector length which we already know). Validation happens
+ // within the loop below.
+ const uint64_t union_type_vector_data_offset =
+ union_type_vector_field_offset +
+ union_type_vector_field_relative_offset.value() + sizeof(uint32_t);
+
+ for (size_t i = 0; i < vector_length.value(); ++i) {
+ BinaryRegionComment comment;
+ comment.type = BinaryRegionCommentType::VectorUnionValue;
+ comment.index = i;
+
+ const auto union_relative_offset = ReadScalar<uint32_t>(offset);
+ if (!union_relative_offset.has_value()) {
+ const uint64_t remaining = RemainingBytes(offset);
+
+ SetError(comment, BinaryRegionStatus::ERROR_INCOMPLETE_BINARY, "4");
+
+ regions.push_back(MakeBinaryRegion(offset, remaining,
+ BinaryRegionType::Unknown,
+ remaining, 0, comment));
+
+ break;
+ }
+
+ // The union offset is relative from the offset location itself.
+ const uint64_t union_offset = offset + union_relative_offset.value();
+
+ if (!IsValidOffset(union_offset)) {
+ SetError(comment, BinaryRegionStatus::ERROR_OFFSET_OUT_OF_BINARY);
+
+ regions.push_back(MakeBinaryRegion(offset, sizeof(uint32_t),
+ BinaryRegionType::UOffset, 0,
+ union_offset, comment));
+ continue;
+ }
+
+ const auto realized_type =
+ ReadScalar<uint8_t>(union_type_vector_data_offset + i);
+
+ if (!realized_type.has_value()) {
+ SetError(comment, BinaryRegionStatus::ERROR_INCOMPLETE_BINARY, "1");
+ regions.push_back(MakeBinaryRegion(
+ offset, 0, BinaryRegionType::Unknown, 0, 0, comment));
+ continue;
+ }
+
+ if (!IsValidUnionValue(vtable_entry->second.field->type()->index(),
+ realized_type.value())) {
+ // We already export an error in the union type field, so just skip
+ // building the union itself and it will default to an unreference
+ // Binary section.
+ offset += sizeof(uint32_t);
+ continue;
+ }
+
+ const std::string enum_type =
+ BuildUnion(union_offset, realized_type.value(), field);
+
+ comment.default_value = "(`" + enum_type + "`)";
+ regions.push_back(MakeBinaryRegion(offset, sizeof(uint32_t),
+ BinaryRegionType::UOffset, 0,
+ union_offset, comment));
+
+ offset += sizeof(uint32_t);
+ }
+ } break;
+ default: {
+ if (IsScalar(field->type()->element())) {
+ const BinaryRegionType binary_region_type =
+ GetRegionType(field->type()->element());
+
+ const uint64_t type_size = GetTypeSize(field->type()->element());
+
+ // TODO(dbaileychess): It might be nicer to user the
+ // BinaryRegion.array_length field to indicate this.
+ for (size_t i = 0; i < vector_length.value(); ++i) {
+ BinaryRegionComment vector_scalar_comment;
+ vector_scalar_comment.type = BinaryRegionCommentType::VectorValue;
+ vector_scalar_comment.index = i;
+
+ if (!IsValidRead(offset, type_size)) {
+ const uint64_t remaining = RemainingBytes(offset);
+
+ SetError(vector_scalar_comment,
+ BinaryRegionStatus::ERROR_INCOMPLETE_BINARY,
+ std::to_string(type_size));
+
+ regions.push_back(
+ MakeBinaryRegion(offset, remaining, BinaryRegionType::Unknown,
+ remaining, 0, vector_scalar_comment));
+ break;
+ }
+
+ if (IsUnionType(field->type()->element())) {
+ // This is a type for a union. Validate the value
+ const auto enum_value = ReadScalar<uint8_t>(offset);
+
+ // This should always have a value, due to the IsValidRead check
+ // above.
+ if (!IsValidUnionValue(field->type()->index(),
+ enum_value.value())) {
+ SetError(vector_scalar_comment,
+ BinaryRegionStatus::ERROR_INVALID_UNION_TYPE);
+ regions.push_back(MakeBinaryRegion(offset, type_size,
+ binary_region_type, 0, 0,
+ vector_scalar_comment));
+ offset += type_size;
+ continue;
+ }
+ }
+
+ regions.push_back(MakeBinaryRegion(offset, type_size,
+ binary_region_type, 0, 0,
+ vector_scalar_comment));
+ offset += type_size;
+ }
+ }
+ } break;
+ }
+ AddSection(vector_offset,
+ MakeBinarySection(std::string(table->name()->c_str()) + "." +
+ field->name()->c_str(),
+ BinarySectionType::Vector, std::move(regions)));
+}
+
+std::string BinaryAnnotator::BuildUnion(const uint64_t union_offset,
+ const uint8_t realized_type,
+ const reflection::Field *const field) {
+ const reflection::Enum *next_enum =
+ schema_->enums()->Get(field->type()->index());
+
+ const reflection::EnumVal *enum_val = next_enum->values()->Get(realized_type);
+
+ if (ContainsSection(union_offset)) { return enum_val->name()->c_str(); }
+
+ const reflection::Type *union_type = enum_val->union_type();
+
+ if (union_type->base_type() == reflection::BaseType::Obj) {
+ const reflection::Object *object =
+ schema_->objects()->Get(union_type->index());
+
+ if (object->is_struct()) {
+ // Union of vectors point to a new Binary section
+ std::vector<BinaryRegion> regions;
+
+ BuildStruct(union_offset, regions, object);
+
+ AddSection(
+ union_offset,
+ MakeBinarySection(std::string(object->name()->c_str()) + "." +
+ field->name()->c_str(),
+ BinarySectionType::Union, std::move(regions)));
+ } else {
+ BuildTable(union_offset, BinarySectionType::Table, object);
+ }
+ }
+ // TODO(dbaileychess): handle the other union types.
+
+ return enum_val->name()->c_str();
+}
+
+void BinaryAnnotator::FixMissingRegions() {
+ std::vector<BinaryRegion> regions_to_insert;
+ for (auto ¤t_section : sections_) {
+ BinarySection §ion = current_section.second;
+ if (section.regions.empty()) {
+ // TODO(dbaileychess): is this possible?
+ continue;
+ }
+
+ uint64_t offset = section.regions[0].offset + section.regions[0].length;
+ for (size_t i = 1; i < section.regions.size(); ++i) {
+ BinaryRegion ®ion = section.regions[i];
+
+ const uint64_t next_offset = region.offset;
+ if (!IsValidOffset(next_offset)) {
+ // TODO(dbaileychess): figure out how we get into this situation.
+ continue;
+ }
+
+ if (offset < next_offset) {
+ const uint64_t padding_bytes = next_offset - offset;
+
+ BinaryRegionComment comment;
+ comment.type = BinaryRegionCommentType::Padding;
+
+ if (IsNonZeroRegion(offset, padding_bytes, binary_)) {
+ SetError(comment, BinaryRegionStatus::WARN_NO_REFERENCES);
+ regions_to_insert.push_back(
+ MakeBinaryRegion(offset, padding_bytes, BinaryRegionType::Unknown,
+ padding_bytes, 0, comment));
+ } else {
+ regions_to_insert.push_back(
+ MakeBinaryRegion(offset, padding_bytes, BinaryRegionType::Uint8,
+ padding_bytes, 0, comment));
+ }
+ }
+ offset = next_offset + region.length;
+ }
+
+ if (!regions_to_insert.empty()) {
+ section.regions.insert(section.regions.end(), regions_to_insert.begin(),
+ regions_to_insert.end());
+ std::stable_sort(section.regions.begin(), section.regions.end(),
+ BinaryRegionSort);
+ regions_to_insert.clear();
+ }
+ }
+}
+
+void BinaryAnnotator::FixMissingSections() {
+ uint64_t offset = 0;
+
+ std::vector<BinarySection> sections_to_insert;
+
+ for (auto ¤t_section : sections_) {
+ BinarySection §ion = current_section.second;
+ const uint64_t section_start_offset = current_section.first;
+ const uint64_t section_end_offset =
+ section.regions.back().offset + section.regions.back().length;
+
+ if (offset < section_start_offset) {
+ // We are at an offset that is less then the current section.
+ const uint64_t pad_bytes = section_start_offset - offset + 1;
+
+ sections_to_insert.push_back(
+ GenerateMissingSection(offset - 1, pad_bytes, binary_));
+ }
+ offset = section_end_offset + 1;
+ }
+
+ // Handle the case where there are still bytes left in the binary that are
+ // unaccounted for.
+ if (offset < binary_length_) {
+ const uint64_t pad_bytes = binary_length_ - offset + 1;
+ sections_to_insert.push_back(
+ GenerateMissingSection(offset - 1, pad_bytes, binary_));
+ }
+
+ for (const BinarySection §ion_to_insert : sections_to_insert) {
+ AddSection(section_to_insert.regions[0].offset, section_to_insert);
+ }
+}
+
+bool BinaryAnnotator::ContainsSection(const uint64_t offset) {
+ auto it = sections_.lower_bound(offset);
+ // If the section is found, check that it is exactly equal its offset.
+ if (it != sections_.end() && it->first == offset) { return true; }
+
+ // If this was the first section, there are no other previous sections to
+ // check.
+ if (it == sections_.begin()) { return false; }
+
+ // Go back one section.
+ --it;
+
+ // And check that if the offset is covered by the section.
+ return offset >= it->first && offset < it->second.regions.back().offset +
+ it->second.regions.back().length;
+}
+
+} // namespace flatbuffers
\ No newline at end of file
diff --git a/src/binary_annotator.h b/src/binary_annotator.h
new file mode 100644
index 0000000..f89d0a9
--- /dev/null
+++ b/src/binary_annotator.h
@@ -0,0 +1,392 @@
+/*
+ * Copyright 2021 Google Inc. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FLATBUFFERS_BINARY_ANNOTATOR_H_
+#define FLATBUFFERS_BINARY_ANNOTATOR_H_
+
+#include <map>
+#include <string>
+#include <vector>
+
+#include "flatbuffers/base.h"
+#include "flatbuffers/reflection.h"
+#include "flatbuffers/stl_emulation.h"
+#include "flatbuffers/util.h"
+
+namespace flatbuffers {
+
+enum class BinaryRegionType {
+ Unknown = 0,
+ UOffset = 1,
+ SOffset = 2,
+ VOffset = 3,
+ Bool = 4,
+ Byte = 5,
+ Char = 6,
+ Uint8 = 7,
+ Int8 = 8,
+ Uint16 = 9,
+ Int16 = 10,
+ Uint32 = 11,
+ Int32 = 12,
+ Uint64 = 13,
+ Int64 = 14,
+ Float = 15,
+ Double = 16,
+ UType = 17,
+};
+
+template<typename T>
+static inline std::string ToHex(T i, size_t width = sizeof(T)) {
+ std::stringstream stream;
+ stream << std::hex << std::uppercase << std::setfill('0') << std::setw(width)
+ << i;
+ return stream.str();
+}
+
+// Specialized version for uint8_t that don't work well with std::hex.
+static inline std::string ToHex(uint8_t i) {
+ return ToHex(static_cast<int>(i), 2);
+}
+
+enum class BinaryRegionStatus {
+ OK = 0,
+ WARN = 100,
+ WARN_NO_REFERENCES,
+ WARN_CORRUPTED_PADDING,
+ WARN_PADDING_LENGTH,
+ ERROR = 200,
+ // An offset is pointing outside the binary bounds.
+ ERROR_OFFSET_OUT_OF_BINARY,
+ // Expecting to read N bytes but not enough remain in the binary.
+ ERROR_INCOMPLETE_BINARY,
+ // When a length of a vtable/vector is longer than possible.
+ ERROR_LENGTH_TOO_LONG,
+ // When a length of a vtable/vector is shorter than possible.
+ ERROR_LENGTH_TOO_SHORT,
+ // A field mark required is not present in the vtable.
+ ERROR_REQUIRED_FIELD_NOT_PRESENT,
+ // A realized union type is not within the enum bounds.
+ ERROR_INVALID_UNION_TYPE,
+ // Occurs when there is a cycle in offsets.
+ ERROR_CYCLE_DETECTED,
+};
+
+enum class BinaryRegionCommentType {
+ Unknown = 0,
+ SizePrefix,
+ // The offset to the root table.
+ RootTableOffset,
+ // The optional 4-char file identifier.
+ FileIdentifier,
+ // Generic 0-filled padding
+ Padding,
+ // The size of the vtable.
+ VTableSize,
+ // The size of the referring table.
+ VTableRefferingTableLength,
+ // Offsets to vtable fields.
+ VTableFieldOffset,
+ // Offsets to unknown vtable fields.
+ VTableUnknownFieldOffset,
+ // The vtable offset of a table.
+ TableVTableOffset,
+ // A "inline" table field value.
+ TableField,
+ // A table field that is unknown.
+ TableUnknownField,
+ // A table field value that points to another section.
+ TableOffsetField,
+ // A struct field value.
+ StructField,
+ // A array field value.
+ ArrayField,
+ // The length of the string.
+ StringLength,
+ // The string contents.
+ StringValue,
+ // The explicit string terminator.
+ StringTerminator,
+ // The length of the vector (# of items).
+ VectorLength,
+ // A "inline" value of a vector.
+ VectorValue,
+ // A vector value that points to another section.
+ VectorTableValue,
+ VectorStringValue,
+ VectorUnionValue,
+};
+
+struct BinaryRegionComment {
+ BinaryRegionStatus status = BinaryRegionStatus::OK;
+
+ // If status is non OK, this may be filled in with additional details.
+ std::string status_message;
+
+ BinaryRegionCommentType type = BinaryRegionCommentType::Unknown;
+
+ std::string name;
+
+ std::string default_value;
+
+ size_t index = 0;
+};
+
+struct BinaryRegion {
+ // Offset into the binary where this region begins.
+ uint64_t offset = 0;
+
+ // The length of this region in bytes.
+ uint64_t length = 0;
+
+ // The underlying datatype of this region
+ BinaryRegionType type = BinaryRegionType::Unknown;
+
+ // If `type` is an array/vector, this is the number of those types this region
+ // encompasses.
+ uint64_t array_length = 0;
+
+ // If the is an offset to some other region, this is what it points to. The
+ // offset is relative to overall binary, not to this region.
+ uint64_t points_to_offset = 0;
+
+ // The comment on the region.
+ BinaryRegionComment comment;
+};
+
+enum class BinarySectionType {
+ Unknown = 0,
+ Header = 1,
+ Table = 2,
+ RootTable = 3,
+ VTable = 4,
+ Struct = 5,
+ String = 6,
+ Vector = 7,
+ Union = 8,
+ Padding = 9,
+};
+
+// A section of the binary that is grouped together in some logical manner, and
+// often is pointed too by some other offset BinaryRegion. Sections include
+// `tables`, `vtables`, `strings`, `vectors`, etc..
+struct BinarySection {
+ // User-specified name of the section, if applicable.
+ std::string name;
+
+ // The type of this section.
+ BinarySectionType type = BinarySectionType::Unknown;
+
+ // The binary regions that make up this section, in order of their offsets.
+ std::vector<BinaryRegion> regions;
+};
+
+inline static BinaryRegionType GetRegionType(reflection::BaseType base_type) {
+ switch (base_type) {
+ case reflection::UType: return BinaryRegionType::UType;
+ case reflection::Bool: return BinaryRegionType::Uint8;
+ case reflection::Byte: return BinaryRegionType::Uint8;
+ case reflection::UByte: return BinaryRegionType::Uint8;
+ case reflection::Short: return BinaryRegionType::Int16;
+ case reflection::UShort: return BinaryRegionType::Uint16;
+ case reflection::Int: return BinaryRegionType::Uint32;
+ case reflection::UInt: return BinaryRegionType::Uint32;
+ case reflection::Long: return BinaryRegionType::Int64;
+ case reflection::ULong: return BinaryRegionType::Uint64;
+ case reflection::Float: return BinaryRegionType::Float;
+ case reflection::Double: return BinaryRegionType::Double;
+ default: return BinaryRegionType::Unknown;
+ }
+}
+
+inline static std::string ToString(const BinaryRegionType type) {
+ switch (type) {
+ case BinaryRegionType::UOffset: return "UOffset32";
+ case BinaryRegionType::SOffset: return "SOffset32";
+ case BinaryRegionType::VOffset: return "VOffset16";
+ case BinaryRegionType::Bool: return "bool";
+ case BinaryRegionType::Char: return "char";
+ case BinaryRegionType::Byte: return "int8_t";
+ case BinaryRegionType::Uint8: return "uint8_t";
+ case BinaryRegionType::Uint16: return "uint16_t";
+ case BinaryRegionType::Uint32: return "uint32_t";
+ case BinaryRegionType::Uint64: return "uint64_t"; ;
+ case BinaryRegionType::Int8: return "int8_t";
+ case BinaryRegionType::Int16: return "int16_t";
+ case BinaryRegionType::Int32: return "int32_t";
+ case BinaryRegionType::Int64: return "int64_t";
+ case BinaryRegionType::Double: return "double";
+ case BinaryRegionType::Float: return "float";
+ case BinaryRegionType::UType: return "UType8";
+ case BinaryRegionType::Unknown: return "?uint8_t";
+ default: return "todo";
+ }
+}
+
+class BinaryAnnotator {
+ public:
+ explicit BinaryAnnotator(const uint8_t *const bfbs,
+ const uint64_t bfbs_length,
+ const uint8_t *const binary,
+ const uint64_t binary_length)
+ : bfbs_(bfbs),
+ bfbs_length_(bfbs_length),
+ schema_(reflection::GetSchema(bfbs)),
+ binary_(binary),
+ binary_length_(binary_length) {}
+
+ std::map<uint64_t, BinarySection> Annotate();
+
+ private:
+ struct VTable {
+ struct Entry {
+ const reflection::Field *field = nullptr;
+ uint16_t offset_from_table = 0;
+ };
+
+ // Field ID -> {field def, offset from table}
+ std::map<uint16_t, Entry> fields;
+
+ uint16_t vtable_size = 0;
+ uint16_t table_size = 0;
+ };
+
+ uint64_t BuildHeader(uint64_t offset);
+
+ void BuildVTable(uint64_t offset, const reflection::Object *table,
+ uint64_t offset_of_referring_table);
+
+ void BuildTable(uint64_t offset, const BinarySectionType type,
+ const reflection::Object *table);
+
+ uint64_t BuildStruct(uint64_t offset, std::vector<BinaryRegion> ®ions,
+ const reflection::Object *structure);
+
+ void BuildString(uint64_t offset, const reflection::Object *table,
+ const reflection::Field *field);
+
+ void BuildVector(uint64_t offset, const reflection::Object *table,
+ const reflection::Field *field, uint64_t parent_table_offset,
+ const VTable &vtable);
+
+ std::string BuildUnion(uint64_t offset, uint8_t realized_type,
+ const reflection::Field *field);
+
+ void FixMissingRegions();
+ void FixMissingSections();
+
+ inline bool IsValidOffset(const uint64_t offset) const {
+ return offset < binary_length_;
+ }
+
+ // Determines if performing a GetScalar request for `T` at `offset` would read
+ // passed the end of the binary.
+ template<typename T> inline bool IsValidRead(const uint64_t offset) const {
+ return IsValidRead(offset, sizeof(T));
+ }
+
+ inline bool IsValidRead(const uint64_t offset, const uint64_t length) const {
+ return length < binary_length_ && IsValidOffset(offset + length - 1);
+ }
+
+ // Calculate the number of bytes remaining from the given offset. If offset is
+ // > binary_length, 0 is returned.
+ uint64_t RemainingBytes(const uint64_t offset) const {
+ return IsValidOffset(offset) ? binary_length_ - offset : 0;
+ }
+
+ template<typename T>
+ flatbuffers::Optional<T> ReadScalar(const uint64_t offset) const {
+ if (!IsValidRead<T>(offset)) { return flatbuffers::nullopt; }
+
+ return flatbuffers::ReadScalar<T>(binary_ + offset);
+ }
+
+ // Adds the provided `section` keyed by the `offset` it occurs at. If a
+ // section is already added at that offset, it doesn't replace the exisiting
+ // one.
+ void AddSection(const uint64_t offset, const BinarySection §ion) {
+ sections_.insert(std::make_pair(offset, section));
+ }
+
+ bool IsInlineField(const reflection::Field *const field) {
+ if (field->type()->base_type() == reflection::BaseType::Obj) {
+ return schema_->objects()->Get(field->type()->index())->is_struct();
+ }
+ return IsScalar(field->type()->base_type());
+ }
+
+ bool IsUnionType(const reflection::BaseType type) {
+ return (type == reflection::BaseType::UType ||
+ type == reflection::BaseType::Union);
+ }
+
+ bool IsUnionType(const reflection::Field *const field) {
+ return IsUnionType(field->type()->base_type()) &&
+ field->type()->index() >= 0;
+ }
+
+ bool IsValidUnionValue(const reflection::Field *const field,
+ const uint8_t value) {
+ return IsUnionType(field) &&
+ IsValidUnionValue(field->type()->index(), value);
+ }
+
+ bool IsValidUnionValue(const uint32_t enum_id, const uint8_t value) {
+ if (enum_id >= schema_->enums()->size()) { return false; }
+
+ const reflection::Enum *enum_def = schema_->enums()->Get(enum_id);
+
+ if (enum_def == nullptr) { return false; }
+
+ return value < enum_def->values()->size();
+ }
+
+ uint64_t GetElementSize(const reflection::Field *const field) {
+ if (IsScalar(field->type()->element())) {
+ return GetTypeSize(field->type()->element());
+ }
+
+ switch (field->type()->element()) {
+ case reflection::BaseType::Obj: {
+ auto obj = schema_->objects()->Get(field->type()->index());
+ return obj->is_struct() ? obj->bytesize() : sizeof(uint32_t);
+ }
+ default: return sizeof(uint32_t);
+ }
+ }
+
+ bool ContainsSection(const uint64_t offset);
+
+ // The schema for the binary file
+ const uint8_t *bfbs_;
+ const uint64_t bfbs_length_;
+ const reflection::Schema *schema_;
+
+ // The binary data itself.
+ const uint8_t *binary_;
+ const uint64_t binary_length_;
+
+ // Map of binary offset to vtables, to dedupe vtables.
+ std::map<uint64_t, VTable> vtables_;
+
+ // The annotated binary sections, index by their absolute offset.
+ std::map<uint64_t, BinarySection> sections_;
+};
+
+} // namespace flatbuffers
+
+#endif // FLATBUFFERS_BINARY_ANNOTATOR_H_
\ No newline at end of file
diff --git a/src/code_generators.cpp b/src/code_generators.cpp
index 269687d..c5efb22 100644
--- a/src/code_generators.cpp
+++ b/src/code_generators.cpp
@@ -30,6 +30,52 @@
namespace flatbuffers {
+namespace {
+
+static std::string JavaCSharpMakeRule(const bool java, const Parser &parser,
+ const std::string &path,
+ const std::string &file_name) {
+ const std::string file_extension = java ? ".java" : ".cs";
+ std::string make_rule;
+
+ for (auto it = parser.enums_.vec.begin(); it != parser.enums_.vec.end();
+ ++it) {
+ auto &enum_def = **it;
+ if (!make_rule.empty()) make_rule += " ";
+ std::string directory =
+ BaseGenerator::NamespaceDir(parser, path, *enum_def.defined_namespace);
+ make_rule += directory + enum_def.name + file_extension;
+ }
+
+ for (auto it = parser.structs_.vec.begin(); it != parser.structs_.vec.end();
+ ++it) {
+ auto &struct_def = **it;
+ if (!make_rule.empty()) make_rule += " ";
+ std::string directory = BaseGenerator::NamespaceDir(
+ parser, path, *struct_def.defined_namespace);
+ make_rule += directory + struct_def.name + file_extension;
+ }
+
+ make_rule += ": ";
+ auto included_files = parser.GetIncludedFilesRecursive(file_name);
+ for (auto it = included_files.begin(); it != included_files.end(); ++it) {
+ make_rule += " " + *it;
+ }
+ return make_rule;
+}
+
+
+static std::string BinaryFileName(const Parser &parser, const std::string &path,
+ const std::string &file_name) {
+ auto ext = parser.file_extension_.length() ? parser.file_extension_ : "bin";
+ return path + file_name + "." + ext;
+}
+
+} // namespace
+
+
+
+
void CodeWriter::operator+=(std::string text) {
if (!ignore_ident_ && !text.empty()) AppendIdent(stream_);
@@ -131,8 +177,9 @@
return qualified_name + name;
}
-std::string BaseGenerator::WrapInNameSpace(const Definition &def) const {
- return WrapInNameSpace(def.defined_namespace, def.name);
+std::string BaseGenerator::WrapInNameSpace(const Definition &def,
+ const std::string &suffix) const {
+ return WrapInNameSpace(def.defined_namespace, def.name + suffix);
}
std::string BaseGenerator::GetNameSpace(const Definition &def) const {
@@ -299,37 +346,6 @@
return this->NaN(static_cast<double>(v));
}
-std::string JavaCSharpMakeRule(const bool java, const Parser &parser,
- const std::string &path,
- const std::string &file_name) {
- const std::string file_extension = java ? ".java" : ".cs";
- std::string make_rule;
-
- for (auto it = parser.enums_.vec.begin(); it != parser.enums_.vec.end();
- ++it) {
- auto &enum_def = **it;
- if (!make_rule.empty()) make_rule += " ";
- std::string directory =
- BaseGenerator::NamespaceDir(parser, path, *enum_def.defined_namespace);
- make_rule += directory + enum_def.name + file_extension;
- }
-
- for (auto it = parser.structs_.vec.begin(); it != parser.structs_.vec.end();
- ++it) {
- auto &struct_def = **it;
- if (!make_rule.empty()) make_rule += " ";
- std::string directory = BaseGenerator::NamespaceDir(
- parser, path, *struct_def.defined_namespace);
- make_rule += directory + struct_def.name + file_extension;
- }
-
- make_rule += ": ";
- auto included_files = parser.GetIncludedFilesRecursive(file_name);
- for (auto it = included_files.begin(); it != included_files.end(); ++it) {
- make_rule += " " + *it;
- }
- return make_rule;
-}
std::string JavaMakeRule(const Parser &parser, const std::string &path,
const std::string &file_name) {
@@ -340,12 +356,6 @@
return JavaCSharpMakeRule(false, parser, path, file_name);
}
-std::string BinaryFileName(const Parser &parser, const std::string &path,
- const std::string &file_name) {
- auto ext = parser.file_extension_.length() ? parser.file_extension_ : "bin";
- return path + file_name + "." + ext;
-}
-
bool GenerateBinary(const Parser &parser, const std::string &path,
const std::string &file_name) {
if (parser.opts.use_flexbuffers) {
diff --git a/src/flatc.cpp b/src/flatc.cpp
index 3b2ef9f..1d12a17 100644
--- a/src/flatc.cpp
+++ b/src/flatc.cpp
@@ -19,11 +19,13 @@
#include <list>
#include <sstream>
+#include "annotated_binary_text_gen.h"
+#include "binary_annotator.h"
#include "flatbuffers/util.h"
namespace flatbuffers {
-const char *FLATC_VERSION() { return FLATBUFFERS_VERSION(); }
+static const char *FLATC_VERSION() { return FLATBUFFERS_VERSION(); }
void FlatCompiler::ParseFile(
flatbuffers::Parser &parser, const std::string &filename,
@@ -84,6 +86,8 @@
{ "", "scoped-enums", "",
"Use C++11 style scoped and strongly typed enums. Also implies "
"--no-prefix." },
+ { "", "swift-implementation-only", "",
+ "Adds a @_implementationOnly to swift imports" },
{ "", "gen-inclues", "",
"(deprecated), this is the default behavior. If the original behavior is "
"required (no include statements) use --no-includes." },
@@ -203,7 +207,7 @@
"Used with \"binary\" and \"json\" options, it generates data using "
"schema-less FlexBuffers." },
{ "", "no-warnings", "", "Inhibit all warnings messages." },
- { "", "warning-as-errors", "", "Treat all warnings as errors." },
+ { "", "warnings-as-errors", "", "Treat all warnings as errors." },
{ "", "cs-global-alias", "",
"Prepend \"global::\" to all user generated csharp classes and "
"structs." },
@@ -215,6 +219,11 @@
"in JSON, which is unsafe unless checked by a verifier afterwards." },
{ "", "ts-flat-files", "",
"Only generated one typescript file per .fbs file." },
+ { "", "annotate", "SCHEMA",
+ "Annotate the provided BINARY_FILE with the specified SCHEMA file." },
+ { "", "no-leak-private-annotation", "",
+ "Prevents multiple type of annotations within a Fbs SCHEMA file."
+ "Currently this is required to generate private types in Rust" },
};
static void AppendTextWrappedString(std::stringstream &ss, std::string &text,
@@ -297,7 +306,7 @@
ss << ", ";
}
ss.seekp(-2, ss.cur);
- ss << "]... FILE... [-- FILE...]";
+ ss << "]... FILE... [-- BINARY_FILE...]";
std::string help = ss.str();
std::stringstream ss_textwrap;
AppendTextWrappedString(ss_textwrap, help, 80, 0);
@@ -306,7 +315,8 @@
std::string FlatCompiler::GetUsageString(const char *program_name) const {
std::stringstream ss;
- ss << "Usage: " << program_name << " [OPTION]... FILE... [-- FILE...]\n";
+ ss << "Usage: " << program_name
+ << " [OPTION]... FILE... [-- BINARY_FILE...]\n";
for (size_t i = 0; i < params_.num_generators; ++i) {
const Generator &g = params_.generators[i];
AppendOption(ss, g.option, 80, 25);
@@ -320,16 +330,48 @@
std::string files_description =
"FILEs may be schemas (must end in .fbs), binary schemas (must end in "
- ".bfbs) or JSON files (conforming to preceding schema). FILEs after the "
- "-- must be binary flatbuffer format files. Output files are named using "
- "the base file name of the input, and written to the current directory "
- "or the path given by -o. example: " +
+ ".bfbs) or JSON files (conforming to preceding schema). BINARY_FILEs "
+ "after the -- must be binary flatbuffer format files. Output files are "
+ "named using the base file name of the input, and written to the current "
+ "directory or the path given by -o. example: " +
std::string(program_name) + " -c -b schema1.fbs schema2.fbs data.json";
AppendTextWrappedString(ss, files_description, 80, 0);
ss << "\n";
return ss.str();
}
+void FlatCompiler::AnnotateBinaries(
+ const uint8_t *binary_schema, const uint64_t binary_schema_size,
+ const std::string &schema_filename,
+ const std::vector<std::string> &binary_files) {
+ for (const std::string &filename : binary_files) {
+ std::string binary_contents;
+ if (!flatbuffers::LoadFile(filename.c_str(), true, &binary_contents)) {
+ Warn("unable to load binary file: " + filename);
+ continue;
+ }
+
+ const uint8_t *binary =
+ reinterpret_cast<const uint8_t *>(binary_contents.c_str());
+ const size_t binary_size = binary_contents.size();
+
+ flatbuffers::BinaryAnnotator binary_annotator(
+ binary_schema, binary_schema_size, binary, binary_size);
+
+ auto annotations = binary_annotator.Annotate();
+
+ // TODO(dbaileychess): Right now we just support a single text-based
+ // output of the annotated binary schema, which we generate here. We
+ // could output the raw annotations instead and have third-party tools
+ // use them to generate their own output.
+ flatbuffers::AnnotatedBinaryTextGenerator text_generator(
+ flatbuffers::AnnotatedBinaryTextGenerator::Options{}, annotations,
+ binary, binary_size);
+
+ text_generator.Generate(filename, schema_filename);
+ }
+}
+
int FlatCompiler::Compile(int argc, const char **argv) {
if (params_.generators == nullptr || params_.num_generators == 0) {
return 0;
@@ -353,6 +395,7 @@
std::vector<bool> generator_enabled(params_.num_generators, false);
size_t binary_files_from = std::numeric_limits<size_t>::max();
std::string conform_to_schema;
+ std::string annotate_schema;
const char *program_name = argv[0];
@@ -390,7 +433,7 @@
opts.include_prefix = flatbuffers::ConCatPathFileName(
flatbuffers::PosixPath(argv[argi]), "");
} else if (arg == "--keep-prefix") {
- opts.keep_include_path = true;
+ opts.keep_prefix = true;
} else if (arg == "--strict-json") {
opts.strict_json = true;
} else if (arg == "--allow-non-utf8") {
@@ -452,6 +495,8 @@
opts.java_checkerframework = true;
} else if (arg == "--gen-generated") {
opts.gen_generated = true;
+ } else if (arg == "--swift-implementation-only") {
+ opts.swift_implementation_only = true;
} else if (arg == "--gen-json-emit") {
opts.gen_json_coders = true;
} else if (arg == "--object-prefix") {
@@ -554,6 +599,11 @@
opts.json_nested_legacy_flatbuffers = true;
} else if (arg == "--ts-flat-files") {
opts.ts_flat_file = true;
+ } else if (arg == "--no-leak-private-annotation") {
+ opts.no_leak_private_annotations = true;
+ } else if (arg == "--annotate") {
+ if (++argi >= argc) Error("missing path following: " + arg, true);
+ annotate_schema = flatbuffers::PosixPath(argv[argi]);
} else {
for (size_t i = 0; i < params_.num_generators; ++i) {
if (arg == "--" + params_.generators[i].option.long_opt ||
@@ -582,7 +632,8 @@
if (opts.proto_mode) {
if (any_generator)
Error("cannot generate code directly from .proto files", true);
- } else if (!any_generator && conform_to_schema.empty()) {
+ } else if (!any_generator && conform_to_schema.empty() &&
+ annotate_schema.empty()) {
Error("no options: specify at least one generator.", true);
}
@@ -592,10 +643,6 @@
"well.");
}
- if (opts.ts_flat_file && opts.generate_all) {
- Error("Combining --ts-flat-file and --gen-all is not supported.");
- }
-
flatbuffers::Parser conform_parser;
if (!conform_to_schema.empty()) {
std::string contents;
@@ -611,6 +658,53 @@
}
}
+ if (!annotate_schema.empty()) {
+ const std::string ext = flatbuffers::GetExtension(annotate_schema);
+ if (!(ext == reflection::SchemaExtension() || ext == "fbs")) {
+ Error("Expected a `.bfbs` or `.fbs` schema, got: " + annotate_schema);
+ }
+
+ const bool is_binary_schema = ext == reflection::SchemaExtension();
+
+ std::string schema_contents;
+ if (!flatbuffers::LoadFile(annotate_schema.c_str(),
+ /*binary=*/is_binary_schema, &schema_contents)) {
+ Error("unable to load schema: " + annotate_schema);
+ }
+
+ const uint8_t *binary_schema = nullptr;
+ uint64_t binary_schema_size = 0;
+
+ IDLOptions binary_opts;
+ binary_opts.lang_to_generate |= flatbuffers::IDLOptions::kBinary;
+ flatbuffers::Parser parser(binary_opts);
+
+ if (is_binary_schema) {
+ binary_schema =
+ reinterpret_cast<const uint8_t *>(schema_contents.c_str());
+ binary_schema_size = schema_contents.size();
+ } else {
+ // If we need to generate the .bfbs file from the provided schema file
+ // (.fbs)
+ ParseFile(parser, annotate_schema, schema_contents, include_directories);
+ parser.Serialize();
+
+ binary_schema = parser.builder_.GetBufferPointer();
+ binary_schema_size = parser.builder_.GetSize();
+ }
+
+ if (binary_schema == nullptr || !binary_schema_size) {
+ Error("could not parse a value binary schema from: " + annotate_schema);
+ }
+
+ // Annotate the provided files with the binary_schema.
+ AnnotateBinaries(binary_schema, binary_schema_size, annotate_schema,
+ filenames);
+
+ // We don't support doing anything else after annotating a binary.
+ return 0;
+ }
+
std::unique_ptr<flatbuffers::Parser> parser(new flatbuffers::Parser(opts));
for (auto file_it = filenames.begin(); file_it != filenames.end();
@@ -755,7 +849,7 @@
if (params_.generators[i].generateGRPC != nullptr) {
if (!params_.generators[i].generateGRPC(*parser.get(), output_path,
filebase)) {
- Error(std::string("Unable to generate GRPC interface for") +
+ Error(std::string("Unable to generate GRPC interface for ") +
params_.generators[i].lang_name);
}
} else {
diff --git a/src/flatc_main.cpp b/src/flatc_main.cpp
index abcab24..b4c4251 100644
--- a/src/flatc_main.cpp
+++ b/src/flatc_main.cpp
@@ -52,9 +52,6 @@
} // namespace flatbuffers
int main(int argc, const char *argv[]) {
- // Prevent Appveyor-CI hangs.
- flatbuffers::SetupDefaultCRTReportMode();
-
const std::string flatbuffers_version(flatbuffers::FLATBUFFERS_VERSION());
std::unique_ptr<flatbuffers::BfbsGenerator> bfbs_gen_lua =
diff --git a/src/idl_gen_cpp.cpp b/src/idl_gen_cpp.cpp
index dfd9525..dfe55e0 100644
--- a/src/idl_gen_cpp.cpp
+++ b/src/idl_gen_cpp.cpp
@@ -16,8 +16,10 @@
// independent from idl_parser, since this code is not needed for most clients
+#include <string>
#include <unordered_set>
+#include "flatbuffers/base.h"
#include "flatbuffers/code_generators.h"
#include "flatbuffers/flatbuffers.h"
#include "flatbuffers/flatc.h"
@@ -68,6 +70,19 @@
return guard;
}
+static bool IsVectorOfPointers(const FieldDef &field) {
+ const auto &type = field.value.type;
+ const auto &vector_type = type.VectorType();
+ return type.base_type == BASE_TYPE_VECTOR &&
+ vector_type.base_type == BASE_TYPE_STRUCT &&
+ !vector_type.struct_def->fixed && !field.native_inline;
+}
+
+static bool IsPointer(const FieldDef &field) {
+ return field.value.type.base_type == BASE_TYPE_STRUCT &&
+ !IsStruct(field.value.type);
+}
+
namespace cpp {
enum CppStandard { CPP_STD_X0 = 0, CPP_STD_11, CPP_STD_17 };
@@ -199,27 +214,60 @@
for (auto kw = keywords; *kw; kw++) keywords_.insert(*kw);
}
+ // Adds code to check that the included flatbuffers.h is of the same version
+ // as the generated code. This check currently looks for exact version match,
+ // as we would guarantee that they are compatible, but in theory a newer
+ // version of flatbuffers.h should work with a old code gen if we do proper
+ // backwards support.
+ void GenFlatbuffersVersionCheck() {
+ code_ +=
+ "// Ensure the included flatbuffers.h is the same version as when this "
+ "file was";
+ code_ += "// generated, otherwise it may not be compatible.";
+ code_ += "static_assert(FLATBUFFERS_VERSION_MAJOR == " +
+ std::to_string(FLATBUFFERS_VERSION_MAJOR) + " &&";
+ code_ += " FLATBUFFERS_VERSION_MINOR == " +
+ std::to_string(FLATBUFFERS_VERSION_MINOR) + " &&";
+ code_ += " FLATBUFFERS_VERSION_REVISION == " +
+ std::to_string(FLATBUFFERS_VERSION_REVISION) + ",";
+ code_ += " \"Non-compatible flatbuffers version included\");";
+ }
+
void GenIncludeDependencies() {
- int num_includes = 0;
if (opts_.generate_object_based_api) {
for (auto it = parser_.native_included_files_.begin();
it != parser_.native_included_files_.end(); ++it) {
code_ += "#include \"" + *it + "\"";
- num_includes++;
}
}
- for (auto it = parser_.included_files_.begin();
- it != parser_.included_files_.end(); ++it) {
- if (it->second.empty()) continue;
- auto noext = flatbuffers::StripExtension(it->second);
- auto basename = flatbuffers::StripPath(noext);
- auto includeName =
- GeneratedFileName(opts_.include_prefix,
- opts_.keep_include_path ? noext : basename, opts_);
- code_ += "#include \"" + includeName + "\"";
- num_includes++;
+
+ // Get the directly included file of the file being parsed.
+ std::vector<IncludedFile> included_files(parser_.GetIncludedFiles());
+
+ // We are safe to sort them alphabetically, since there shouldn't be any
+ // interdependence between them.
+ std::stable_sort(included_files.begin(), included_files.end());
+
+ for (const IncludedFile &included_file : included_files) {
+ // Get the name of the included file as defined by the schema, and strip
+ // the .fbs extension.
+ const std::string name_without_ext =
+ flatbuffers::StripExtension(included_file.schema_name);
+
+ // If we are told to keep the prefix of the included schema, leave it
+ // unchanged, otherwise strip the leading path off so just the "basename"
+ // of the include is retained.
+ const std::string basename =
+ opts_.keep_prefix ? name_without_ext
+ : flatbuffers::StripPath(name_without_ext);
+
+ code_ += "#include \"" +
+ GeneratedFileName(opts_.include_prefix, basename, opts_) + "\"";
}
- if (num_includes) code_ += "";
+
+ if (!parser_.native_included_files_.empty() || !included_files.empty()) {
+ code_ += "";
+ }
}
void GenExtraIncludes() {
@@ -285,6 +333,8 @@
code_ += "#include \"flatbuffers/flatbuffers.h\"";
code_ += "";
+ GenFlatbuffersVersionCheck();
+ code_ += "";
SetNameSpace(struct_def.defined_namespace);
auto name = Name(struct_def);
@@ -347,8 +397,11 @@
code_ += "#include \"flatbuffers/flatbuffers.h\"";
if (parser_.uses_flexbuffers_) {
code_ += "#include \"flatbuffers/flexbuffers.h\"";
+ code_ += "#include \"flatbuffers/flex_flat_util.h\"";
}
code_ += "";
+ GenFlatbuffersVersionCheck();
+ code_ += "";
if (opts_.include_dependence_headers) { GenIncludeDependencies(); }
GenExtraIncludes();
@@ -841,7 +894,9 @@
}
} else {
const auto nn = WrapNativeNameInNameSpace(*type.struct_def, opts_);
- return forcopy ? nn : GenTypeNativePtr(nn, &field, false);
+ return (forcopy || field.native_inline)
+ ? nn
+ : GenTypeNativePtr(nn, &field, false);
}
}
case BASE_TYPE_UNION: {
@@ -1827,9 +1882,8 @@
if (vec_type.base_type == BASE_TYPE_UTYPE) continue;
const auto cpp_type = field.attributes.Lookup("cpp_type");
const auto cpp_ptr_type = field.attributes.Lookup("cpp_ptr_type");
- const bool is_ptr =
- (vec_type.base_type == BASE_TYPE_STRUCT && !IsStruct(vec_type)) ||
- (cpp_type && cpp_ptr_type->constant != "naked");
+ const bool is_ptr = IsVectorOfPointers(field) ||
+ (cpp_type && cpp_ptr_type->constant != "naked");
if (is_ptr) { return true; }
}
}
@@ -1953,9 +2007,8 @@
? cpp_type->constant
: GenTypeNative(vec_type, /*invector*/ true,
field, /*forcopy*/ true);
- const bool is_ptr =
- (vec_type.base_type == BASE_TYPE_STRUCT && !IsStruct(vec_type)) ||
- (cpp_type && cpp_ptr_type->constant != "naked");
+ const bool is_ptr = IsVectorOfPointers(field) ||
+ (cpp_type && cpp_ptr_type->constant != "naked");
CodeWriter cw(" ");
cw.SetValue("FIELD", Name(field));
cw.SetValue("TYPE", type_name);
@@ -2020,19 +2073,39 @@
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
const auto &field = **it;
+ const auto accessor = Name(field) + accessSuffix;
+ const auto lhs_accessor = "lhs." + accessor;
+ const auto rhs_accessor = "rhs." + accessor;
+
if (!field.deprecated && // Deprecated fields won't be accessible.
field.value.type.base_type != BASE_TYPE_UTYPE &&
(field.value.type.base_type != BASE_TYPE_VECTOR ||
field.value.type.element != BASE_TYPE_UTYPE)) {
if (!compare_op.empty()) { compare_op += " &&\n "; }
- auto accessor = Name(field) + accessSuffix;
if (struct_def.fixed || field.native_inline ||
field.value.type.base_type != BASE_TYPE_STRUCT) {
- compare_op += "(lhs." + accessor + " == rhs." + accessor + ")";
+ // If the field is a vector of tables, the table need to be compared
+ // by value, instead of by the default unique_ptr == operator which
+ // compares by address.
+ if (IsVectorOfPointers(field)) {
+ const auto type =
+ GenTypeNative(field.value.type.VectorType(), true, field);
+ const auto equal_length =
+ lhs_accessor + ".size() == " + rhs_accessor + ".size()";
+ const auto elements_equal =
+ "std::equal(" + lhs_accessor + ".cbegin(), " + lhs_accessor +
+ ".cend(), " + rhs_accessor + ".cbegin(), [](" + type +
+ " const &a, " + type +
+ " const &b) { return (a == b) || (a && b && *a == *b); })";
+
+ compare_op += "(" + equal_length + " && " + elements_equal + ")";
+ } else {
+ compare_op += "(" + lhs_accessor + " == " + rhs_accessor + ")";
+ }
} else {
// Deep compare of std::unique_ptr. Null is not equal to empty.
std::string both_null =
- "(lhs." + accessor + " == rhs." + accessor + ")";
+ "(" + lhs_accessor + " == " + rhs_accessor + ")";
std::string not_null_and_equal = "(lhs." + accessor + " && rhs." +
accessor + " && *lhs." + accessor +
" == *rhs." + accessor + ")";
@@ -2248,7 +2321,7 @@
// @TODO: Mby make this decisions more universal? How?
code_.SetValue("U_GET_TYPE",
- EscapeKeyword(field.name + UnionTypeFieldSuffix()));
+ EscapeKeyword(Name(field) + UnionTypeFieldSuffix()));
code_.SetValue("U_ELEMENT_TYPE", WrapInNameSpace(u->defined_namespace,
GetEnumValUse(*u, ev)));
code_.SetValue("U_FIELD_TYPE", "const " + full_struct_name + " *");
@@ -2913,7 +2986,8 @@
return ptype + "(new " + name + "(*" + val + "))";
}
} else {
- const auto ptype = GenTypeNativePtr(
+ std::string ptype = afield.native_inline ? "*" : "";
+ ptype += GenTypeNativePtr(
WrapNativeNameInNameSpace(*type.struct_def, opts_), &afield,
true);
return ptype + "(" + val + "->UnPack(_resolver))";
@@ -2941,7 +3015,8 @@
if (field.value.type.element == BASE_TYPE_UTYPE) {
name = StripUnionType(Name(field));
}
- code += "{ _o->" + name + ".resize(_e->size()); ";
+ const std::string vector_field = "_o->" + name;
+ code += "{ " + vector_field + ".resize(_e->size()); ";
if (!field.value.type.enum_def && !IsBool(field.value.type.element) &&
IsOneByte(field.value.type.element)) {
// For vectors of bytes, std::copy is used to improve performance.
@@ -2981,7 +3056,7 @@
// (*resolver)(&_o->field, (hash_value_t)(_e));
// else
// _o->field = nullptr;
- code += "//vector resolver, " + PtrType(&field) + "\n";
+ code += "/*vector resolver, " + PtrType(&field) + "*/ ";
code += "if (_resolver) ";
code += "(*_resolver)";
code += "(reinterpret_cast<void **>(&_o->" + name + "[_i]" +
@@ -2998,9 +3073,7 @@
code += "/* else do nothing */";
}
} else {
- const bool is_pointer =
- field.value.type.VectorType().base_type == BASE_TYPE_STRUCT &&
- !IsStruct(field.value.type.VectorType());
+ const bool is_pointer = IsVectorOfPointers(field);
if (is_pointer) {
code += "if(_o->" + name + "[_i]" + ") { ";
code += indexing + "->UnPackTo(_o->" + name +
@@ -3012,7 +3085,7 @@
field);
if (is_pointer) { code += "; }"; }
}
- code += "; } }";
+ code += "; } } else { " + vector_field + ".resize(0); }";
}
break;
}
@@ -3040,7 +3113,7 @@
// (*resolver)(&_o->field, (hash_value_t)(_e));
// else
// _o->field = nullptr;
- code += "//scalar resolver, " + PtrType(&field) + " \n";
+ code += "/*scalar resolver, " + PtrType(&field) + "*/ ";
code += "if (_resolver) ";
code += "(*_resolver)";
code += "(reinterpret_cast<void **>(&_o->" + Name(field) + "), ";
@@ -3057,17 +3130,21 @@
} else {
// Generate code for assigning the value, of the form:
// _o->field = value;
- const bool is_pointer =
- field.value.type.base_type == BASE_TYPE_STRUCT &&
- !IsStruct(field.value.type);
+ const bool is_pointer = IsPointer(field);
+
+ const std::string out_field = "_o->" + Name(field);
+
if (is_pointer) {
- code += "{ if(_o->" + Name(field) + ") { ";
- code += "_e->UnPackTo(_o->" + Name(field) + ".get(), _resolver);";
+ code += "{ if(" + out_field + ") { ";
+ code += "_e->UnPackTo(" + out_field + ".get(), _resolver);";
code += " } else { ";
}
- code += "_o->" + Name(field) + " = ";
+ code += out_field + " = ";
code += GenUnpackVal(field.value.type, "_e", false, field) + ";";
- if (is_pointer) { code += " } }"; }
+ if (is_pointer) {
+ code += " } } else if (" + out_field + ") { " + out_field +
+ ".reset(); }";
+ }
}
break;
}
@@ -3173,9 +3250,13 @@
code += "(" + value + ".size(), ";
code += "[](size_t i, _VectorArgs *__va) { ";
code += "return Create" + vector_type.struct_def->name;
- code += "(*__va->__fbb, __va->_" + value + "[i]" +
- GenPtrGet(field) + ", ";
- code += "__va->__rehasher); }, &_va )";
+ code += "(*__va->__fbb, ";
+ if (field.native_inline) {
+ code += "&(__va->_" + value + "[i])";
+ } else {
+ code += "__va->_" + value + "[i]" + GenPtrGet(field);
+ }
+ code += ", __va->__rehasher); }, &_va )";
}
break;
}
@@ -3234,7 +3315,8 @@
// If set_empty_vectors_to_null option is enabled, for optional fields,
// check to see if there actually is any data in _o->field before
// attempting to access it.
- if (opts_.set_empty_vectors_to_null && !field.IsRequired()) {
+ if (field.attributes.Lookup("nested_flatbuffer") ||
+ (opts_.set_empty_vectors_to_null && !field.IsRequired())) {
code = value + ".size() ? " + code + " : 0";
}
break;
@@ -3257,14 +3339,15 @@
} else if (field.native_inline) {
code += "&" + value;
} else {
- code += value + " ? " + value + GenPtrGet(field) + " : 0";
+ code += value + " ? " + value + GenPtrGet(field) + " : nullptr";
}
} else {
// _o->field ? CreateT(_fbb, _o->field.get(), _rehasher);
const auto type = field.value.type.struct_def->name;
code += value + " ? Create" + type;
- code += "(_fbb, " + value + GenPtrGet(field) + ", _rehasher)";
- code += " : 0";
+ code += "(_fbb, " + value;
+ if (!field.native_inline) code += GenPtrGet(field);
+ code += ", _rehasher) : 0";
}
break;
}
@@ -3441,7 +3524,7 @@
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
const auto field = *it;
- const auto field_name = field->name + "_";
+ const auto field_name = Name(*field) + "_";
if (first_in_init_list) {
first_in_init_list = false;
diff --git a/src/idl_gen_csharp.cpp b/src/idl_gen_csharp.cpp
index cb605de..fa67eaf 100644
--- a/src/idl_gen_csharp.cpp
+++ b/src/idl_gen_csharp.cpp
@@ -226,7 +226,7 @@
if (needs_includes) {
code += "using global::System;\n";
code += "using global::System.Collections.Generic;\n";
- code += "using global::FlatBuffers;\n\n";
+ code += "using global::Google.FlatBuffers;\n\n";
}
code += classcode;
if (!namespace_name.empty()) { code += "\n}\n"; }
@@ -459,20 +459,24 @@
}
}
+ std::string GetObjectConstructor(flatbuffers::StructDef &struct_def,
+ const std::string &data_buffer,
+ const std::string &offset) const {
+ // Use the generated type directly, to properly handle default values that
+ // might not be written to the buffer.
+ return "new " + Name(struct_def) + "().__assign(" + offset + ", " +
+ data_buffer + ")";
+ }
+
// Returns the function name that is able to read a value of the given type.
- std::string GenGetterForLookupByKey(flatbuffers::FieldDef *key_field,
+ std::string GenGetterForLookupByKey(flatbuffers::StructDef &struct_def,
+ flatbuffers::FieldDef *key_field,
const std::string &data_buffer,
- const char *num = nullptr) const {
- auto type = key_field->value.type;
- auto dest_mask = "";
- auto dest_cast = DestinationCast(type);
- auto getter = data_buffer + ".Get";
- if (GenTypeBasic(type, false) != "byte") {
- getter += ConvertCase(GenTypeBasic(type, false), Case::kUpperCamel);
- }
- getter = dest_cast + getter + "(" + GenOffsetGetter(key_field, num) + ")" +
- dest_mask;
- return getter;
+ const std::string &offset) const {
+ // Use the generated type directly, to properly handle default values that
+ // might not be written to the buffer.
+ return GetObjectConstructor(struct_def, data_buffer, offset) + "." +
+ Name(*key_field);
}
// Direct mutation is only allowed for scalar fields.
@@ -605,37 +609,15 @@
return key_offset;
}
- std::string GenLookupKeyGetter(flatbuffers::FieldDef *key_field) const {
- std::string key_getter = " ";
- key_getter += "int tableOffset = Table.";
- key_getter += "__indirect(vectorLocation + 4 * (start + middle)";
- key_getter += ", bb);\n ";
- if (IsString(key_field->value.type)) {
- key_getter += "int comp = Table.";
- key_getter += "CompareStrings(";
- key_getter += GenOffsetGetter(key_field);
- key_getter += ", byteKey, bb);\n";
- } else {
- auto get_val = GenGetterForLookupByKey(key_field, "bb");
- key_getter += "int comp = " + get_val + ".CompareTo(key);\n";
- }
- return key_getter;
- }
-
- std::string GenKeyGetter(flatbuffers::FieldDef *key_field) const {
- std::string key_getter = "";
- auto data_buffer = "builder.DataBuffer";
- if (IsString(key_field->value.type)) {
- key_getter += "Table.CompareStrings(";
- key_getter += GenOffsetGetter(key_field, "o1") + ", ";
- key_getter += GenOffsetGetter(key_field, "o2") + ", " + data_buffer + ")";
- } else {
- auto field_getter = GenGetterForLookupByKey(key_field, data_buffer, "o1");
- key_getter += field_getter;
- field_getter = GenGetterForLookupByKey(key_field, data_buffer, "o2");
- key_getter += ".CompareTo(" + field_getter + ")";
- }
- return key_getter;
+ std::string GenKeyGetter(flatbuffers::StructDef &struct_def,
+ flatbuffers::FieldDef *key_field) const {
+ // Get the getter for the key of the struct.
+ return GenGetterForLookupByKey(struct_def, key_field, "builder.DataBuffer",
+ "builder.DataBuffer.Length - o1.Value") +
+ ".CompareTo(" +
+ GenGetterForLookupByKey(struct_def, key_field, "builder.DataBuffer",
+ "builder.DataBuffer.Length - o2.Value") +
+ ")";
}
void GenStruct(StructDef &struct_def, std::string *code_ptr,
@@ -669,11 +651,11 @@
code += " public ByteBuffer ByteBuffer { get { return __p.bb; } }\n";
if (!struct_def.fixed) {
- // Generate verson check method.
+ // Generate version check method.
// Force compile time error if not using the same version runtime.
code += " public static void ValidateVersion() {";
code += " FlatBufferConstants.";
- code += "FLATBUFFERS_2_0_0(); ";
+ code += "FLATBUFFERS_2_0_8(); ";
code += "}\n";
// Generate a special accessor for the table that when used as the root
@@ -914,7 +896,9 @@
code += member_suffix;
code += "}\n";
if (IsVector(field.value.type)) {
- code += " public int " + Name(field);
+ auto camel_name = Name(field);
+ if (camel_name == struct_def.name) { camel_name += "_"; }
+ code += " public int " + camel_name;
code += "Length";
code += " { get";
code += offset_prefix;
@@ -1238,6 +1222,8 @@
code += "); return ";
code += "builder.EndVector(); }\n";
+ // add Create...VectorBlock() overloads for T[], ArraySegment<T> and
+ // IntPtr
code += " public static VectorOffset ";
code += "Create";
code += Name(field);
@@ -1248,6 +1234,26 @@
code += ", data.Length, ";
code += NumToString(alignment);
code += "); builder.Add(data); return builder.EndVector(); }\n";
+
+ code += " public static VectorOffset ";
+ code += "Create";
+ code += Name(field);
+ code += "VectorBlock(FlatBufferBuilder builder, ";
+ code += "ArraySegment<" + GenTypeBasic(vector_type) + "> data) ";
+ code += "{ builder.StartVector(";
+ code += NumToString(elem_size);
+ code += ", data.Count, ";
+ code += NumToString(alignment);
+ code += "); builder.Add(data); return builder.EndVector(); }\n";
+
+ code += " public static VectorOffset ";
+ code += "Create";
+ code += Name(field);
+ code += "VectorBlock(FlatBufferBuilder builder, ";
+ code += "IntPtr dataPtr, int sizeInBytes) ";
+ code += "{ builder.StartVector(1, sizeInBytes, 1); ";
+ code += "builder.Add<" + GenTypeBasic(vector_type) +
+ ">(dataPtr, sizeInBytes); return builder.EndVector(); }\n";
}
// Generate a method to start a vector, data to be added manually
// after.
@@ -1300,9 +1306,10 @@
code += "(FlatBufferBuilder builder, ";
code += "Offset<" + struct_def.name + ">";
code += "[] offsets) {\n";
- code += " Array.Sort(offsets, (Offset<" + struct_def.name +
- "> o1, Offset<" + struct_def.name + "> o2) => " +
- GenKeyGetter(key_field);
+ code += " Array.Sort(offsets,\n";
+ code += " (Offset<" + struct_def.name + "> o1, Offset<" +
+ struct_def.name + "> o2) =>\n";
+ code += " " + GenKeyGetter(struct_def, key_field);
code += ");\n";
code += " return builder.CreateVectorOfTables(offsets);\n }\n";
@@ -1311,16 +1318,20 @@
code += "int vectorLocation, ";
code += GenTypeGet(key_field->value.type);
code += " key, ByteBuffer bb) {\n";
- if (IsString(key_field->value.type)) {
- code += " byte[] byteKey = ";
- code += "System.Text.Encoding.UTF8.GetBytes(key);\n";
- }
+ code +=
+ " " + struct_def.name + " obj_ = new " + struct_def.name + "();\n";
code += " int span = ";
code += "bb.GetInt(vectorLocation - 4);\n";
code += " int start = 0;\n";
code += " while (span != 0) {\n";
code += " int middle = span / 2;\n";
- code += GenLookupKeyGetter(key_field);
+ code +=
+ " int tableOffset = Table.__indirect(vectorLocation + 4 * "
+ "(start + middle), bb);\n";
+
+ code += " obj_.__assign(tableOffset, bb);\n";
+ code +=
+ " int comp = obj_." + Name(*key_field) + ".CompareTo(key);\n";
code += " if (comp > 0) {\n";
code += " span = middle;\n";
code += " } else if (comp < 0) {\n";
@@ -1328,9 +1339,7 @@
code += " start += middle;\n";
code += " span -= middle;\n";
code += " } else {\n";
- code += " return ";
- code += "new " + struct_def.name + "()";
- code += ".__assign(tableOffset, bb);\n";
+ code += " return obj_;\n";
code += " }\n }\n";
code += " return null;\n";
code += " }\n";
@@ -1454,8 +1463,10 @@
}
code += "\n";
// Pack()
- code += " public static int Pack(FlatBuffers.FlatBufferBuilder builder, " +
- union_name + " _o) {\n";
+ code +=
+ " public static int Pack(Google.FlatBuffers.FlatBufferBuilder "
+ "builder, " +
+ union_name + " _o) {\n";
code += " switch (_o.Type) {\n";
for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end(); ++it) {
auto &ev = **it;
@@ -1566,6 +1577,7 @@
void GenUnionUnPack_ObjectAPI(const EnumDef &enum_def, std::string *code_ptr,
const std::string &camel_name,
+ const std::string &camel_name_short,
bool is_vector) const {
auto &code = *code_ptr;
std::string varialbe_name = "_o." + camel_name;
@@ -1584,10 +1596,10 @@
code += indent + varialbe_name + " = new ";
}
code += NamespacedName(enum_def) + "Union();\n";
- code += indent + varialbe_name + ".Type = this." + camel_name + "Type" +
- type_suffix + ";\n";
- code +=
- indent + "switch (this." + camel_name + "Type" + type_suffix + ") {\n";
+ code += indent + varialbe_name + ".Type = this." + camel_name_short +
+ "Type" + type_suffix + ";\n";
+ code += indent + "switch (this." + camel_name_short + "Type" + type_suffix +
+ ") {\n";
for (auto eit = enum_def.Vals().begin(); eit != enum_def.Vals().end();
++eit) {
auto &ev = **eit;
@@ -1633,6 +1645,8 @@
auto &field = **it;
if (field.deprecated) continue;
auto camel_name = Name(field);
+ if (camel_name == struct_def.name) { camel_name += "_"; }
+ auto camel_name_short = Name(field);
auto start = " _o." + camel_name + " = ";
switch (field.value.type.base_type) {
case BASE_TYPE_STRUCT: {
@@ -1666,7 +1680,7 @@
code += " for (var _j = 0; _j < this." + camel_name +
"Length; ++_j) {\n";
GenUnionUnPack_ObjectAPI(*field.value.type.enum_def, code_ptr,
- camel_name, true);
+ camel_name, camel_name_short, true);
code += " }\n";
} else if (field.value.type.element != BASE_TYPE_UTYPE) {
auto fixed = field.value.type.struct_def == nullptr;
@@ -1687,7 +1701,7 @@
case BASE_TYPE_UTYPE: break;
case BASE_TYPE_UNION: {
GenUnionUnPack_ObjectAPI(*field.value.type.enum_def, code_ptr,
- camel_name, false);
+ camel_name, camel_name_short, false);
break;
}
default: {
@@ -1707,6 +1721,8 @@
auto &field = **it;
if (field.deprecated) continue;
auto camel_name = Name(field);
+ if (camel_name == struct_def.name) { camel_name += "_"; }
+ auto camel_name_short = Name(field);
// pre
switch (field.value.type.base_type) {
case BASE_TYPE_STRUCT: {
@@ -1782,7 +1798,7 @@
code += " var " + array_name + " = _o." + property_name +
".ToArray();\n";
}
- code += " _" + field.name + " = Create" + camel_name +
+ code += " _" + field.name + " = Create" + camel_name_short +
"Vector(builder, " + array_name + ");\n";
code += " }\n";
} else {
@@ -1794,7 +1810,7 @@
camel_name + "[_j]);";
code += " var _" + field.name + " = default(VectorOffset);\n";
code += " if (_o." + camel_name + " != null) {\n";
- code += " Start" + camel_name + "Vector(builder, _o." +
+ code += " Start" + camel_name_short + "Vector(builder, _o." +
camel_name + ".Count);\n";
code += " for (var _j = _o." + camel_name +
".Count - 1; _j >= 0; --_j) { " + pack_method + " }\n";
@@ -1840,6 +1856,7 @@
auto &field = **it;
if (field.deprecated) continue;
auto camel_name = Name(field);
+ if (camel_name == struct_def.name) { camel_name += "_"; }
switch (field.value.type.base_type) {
case BASE_TYPE_STRUCT: {
if (struct_def.fixed) {
@@ -2094,6 +2111,7 @@
auto type_name = GenTypeGet_ObjectAPI(field.value.type, opts);
if (field.IsScalarOptional()) type_name += "?";
auto camel_name = Name(field);
+ if (camel_name == struct_def.name) { camel_name += "_"; }
if (opts.cs_gen_json_serializer) {
if (IsUnion(field.value.type)) {
auto utype_name = NamespacedName(*field.value.type.enum_def);
@@ -2159,7 +2177,9 @@
if (field.deprecated) continue;
if (field.value.type.base_type == BASE_TYPE_UTYPE) continue;
if (field.value.type.element == BASE_TYPE_UTYPE) continue;
- code += " this." + Name(field) + " = ";
+ auto camel_name = Name(field);
+ if (camel_name == struct_def.name) { camel_name += "_"; }
+ code += " this." + camel_name + " = ";
auto type_name = GenTypeGet_ObjectAPI(field.value.type, opts);
if (IsScalar(field.value.type.base_type)) {
code += GenDefaultValue(field) + ";\n";
diff --git a/src/idl_gen_dart.cpp b/src/idl_gen_dart.cpp
index ff2c1a5..0bf230d 100644
--- a/src/idl_gen_dart.cpp
+++ b/src/idl_gen_dart.cpp
@@ -21,26 +21,57 @@
#include "flatbuffers/flatbuffers.h"
#include "flatbuffers/idl.h"
#include "flatbuffers/util.h"
+#include "idl_namer.h"
namespace flatbuffers {
namespace dart {
+namespace {
+
+static Namer::Config DartDefaultConfig() {
+ return { /*types=*/Case::kUpperCamel,
+ /*constants=*/Case::kScreamingSnake,
+ /*methods=*/Case::kLowerCamel,
+ /*functions=*/Case::kUnknown, // unused.
+ /*fields=*/Case::kLowerCamel,
+ /*variables=*/Case::kLowerCamel,
+ /*variants=*/Case::kKeep,
+ /*enum_variant_seperator=*/".",
+ /*escape_keywords=*/Namer::Config::Escape::AfterConvertingCase,
+ /*namespaces=*/Case::kSnake2,
+ /*namespace_seperator=*/".",
+ /*object_prefix=*/"",
+ /*object_suffix=*/"T",
+ /*keyword_prefix=*/"$",
+ /*keyword_suffix=*/"",
+ /*filenames=*/Case::kKeep,
+ /*directories=*/Case::kKeep,
+ /*output_path=*/"",
+ /*filename_suffix=*/"_generated",
+ /*filename_extension=*/".dart" };
+}
+
+static std::set<std::string> DartKeywords() {
+ // see https://www.dartlang.org/guides/language/language-tour#keywords
+ // yield*, async*, and sync* shouldn't be proble
+ return {
+ "abstract", "else", "import", "show", "as", "enum",
+ "in", "static", "assert", "export", "interface", "super",
+ "async", "extends", "is", "switch", "await", "extension",
+ "late", "sync", "break", "external", "library", "this",
+ "case", "factory", "mixin", "throw", "catch", "false",
+ "new", "true", "class", "final", "null", "try",
+ "const", "finally", "on", "typedef", "continue", "for",
+ "operator", "var", "covariant", "Function", "part", "void",
+ "default", "get", "required", "while", "deferred", "hide",
+ "rethrow", "with", "do", "if", "return", "yield",
+ "dynamic", "implements", "set",
+ };
+}
+} // namespace
+
const std::string _kFb = "fb";
-// see https://www.dartlang.org/guides/language/language-tour#keywords
-// yeild*, async*, and sync* shouldn't be problems anyway but keeping them in
-static const char *keywords[] = {
- "abstract", "deferred", "if", "super", "as", "do",
- "implements", "switch", "assert", "dynamic", "import", "sync*",
- "async", "else", "in", "this", "async*", "enum",
- "is", "throw", "await", "export", "library", "true",
- "break", "external", "new", "try", "case", "extends",
- "null", "typedef", "catch", "factory", "operator", "var",
- "class", "false", "part", "void", "const", "final",
- "rethrow", "while", "continue", "finally", "return", "with",
- "covariant", "for", "set", "yield", "default", "get",
- "static", "yield*"
-};
// Iterate through all definitions we haven't generate code for (enums, structs,
// and tables) and output them to a single file.
@@ -50,14 +81,16 @@
DartGenerator(const Parser &parser, const std::string &path,
const std::string &file_name)
- : BaseGenerator(parser, path, file_name, "", ".", "dart") {}
+ : BaseGenerator(parser, path, file_name, "", ".", "dart"),
+ namer_(WithFlagOptions(DartDefaultConfig(), parser.opts, path),
+ DartKeywords()) {}
// Iterate through all definitions we haven't generate code for (enums,
// structs, and tables) and output them to a single file.
bool generate() {
std::string code;
namespace_code_map namespace_code;
- GenerateEnums(&namespace_code);
- GenerateStructs(&namespace_code);
+ GenerateEnums(namespace_code);
+ GenerateStructs(namespace_code);
for (auto kv = namespace_code.begin(); kv != namespace_code.end(); ++kv) {
code.clear();
@@ -75,31 +108,23 @@
for (auto kv2 = namespace_code.begin(); kv2 != namespace_code.end();
++kv2) {
if (kv2->first != kv->first) {
- code +=
- "import '" +
- GeneratedFileName(
- "./",
- file_name_ + (!kv2->first.empty() ? "_" + kv2->first : ""),
- parser_.opts) +
- "' as " + ImportAliasName(kv2->first) + ";\n";
+ code += "import './" + Filename(kv2->first, /*path=*/false) +
+ "' as " + ImportAliasName(kv2->first) + ";\n";
}
}
code += "\n";
code += kv->second;
- if (!SaveFile(
- GeneratedFileName(
- path_,
- file_name_ + (!kv->first.empty() ? "_" + kv->first : ""),
- parser_.opts)
- .c_str(),
- code, false)) {
- return false;
- }
+ if (!SaveFile(Filename(kv->first).c_str(), code, false)) { return false; }
}
return true;
}
+ std::string Filename(const std::string &suffix, bool path = true) const {
+ return (path ? path_ : "") +
+ namer_.File(file_name_ + (suffix.empty() ? "" : "_" + suffix));
+ }
+
private:
static std::string ImportAliasName(const std::string &ns) {
std::string ret;
@@ -113,64 +138,15 @@
return ret;
}
- static std::string BuildNamespaceName(const Namespace &ns) {
- if (ns.components.empty()) { return ""; }
- std::stringstream sstream;
- std::copy(ns.components.begin(), ns.components.end() - 1,
- std::ostream_iterator<std::string>(sstream, "."));
-
- auto ret = sstream.str() + ns.components.back();
- for (size_t i = 0; i < ret.size(); i++) {
- auto lower = CharToLower(ret[i]);
- if (lower != ret[i]) {
- ret[i] = lower;
- if (i != 0 && ret[i - 1] != '.') {
- ret.insert(i, "_");
- i++;
- }
- }
- }
- // std::transform(ret.begin(), ret.end(), ret.begin(), CharToLower);
- return ret;
- }
-
- void GenIncludeDependencies(std::string *code,
- const std::string &the_namespace) {
- for (auto it = parser_.included_files_.begin();
- it != parser_.included_files_.end(); ++it) {
- if (it->second.empty()) continue;
-
- auto noext = flatbuffers::StripExtension(it->second);
- auto basename = flatbuffers::StripPath(noext);
-
- *code +=
- "import '" +
- GeneratedFileName(
- "", basename + (the_namespace == "" ? "" : "_" + the_namespace),
- parser_.opts) +
- "';\n";
- }
- }
-
- static std::string EscapeKeyword(const std::string &name) {
- for (size_t i = 0; i < sizeof(keywords) / sizeof(keywords[0]); i++) {
- if (name == keywords[i]) {
- return ConvertCase(name + "_", Case::kLowerCamel);
- }
- }
-
- return ConvertCase(name, Case::kLowerCamel);
- }
-
- void GenerateEnums(namespace_code_map *namespace_code) {
+ void GenerateEnums(namespace_code_map &namespace_code) {
for (auto it = parser_.enums_.vec.begin(); it != parser_.enums_.vec.end();
++it) {
auto &enum_def = **it;
- GenEnum(enum_def, namespace_code); // enum_code_ptr);
+ GenEnum(enum_def, namespace_code);
}
}
- void GenerateStructs(namespace_code_map *namespace_code) {
+ void GenerateStructs(namespace_code_map &namespace_code) {
for (auto it = parser_.structs_.vec.begin();
it != parser_.structs_.vec.end(); ++it) {
auto &struct_def = **it;
@@ -180,80 +156,50 @@
// Generate a documentation comment, if available.
static void GenDocComment(const std::vector<std::string> &dc,
- std::string *code_ptr,
- const std::string &extra_lines,
- const char *indent = nullptr) {
- if (dc.empty() && extra_lines.empty()) {
- // Don't output empty comment blocks with 0 lines of comment content.
- return;
- }
-
- auto &code = *code_ptr;
-
+ const char *indent, std::string &code) {
for (auto it = dc.begin(); it != dc.end(); ++it) {
if (indent) code += indent;
code += "/// " + *it + "\n";
}
- if (!extra_lines.empty()) {
- if (!dc.empty()) {
- if (indent) code += indent;
- code += "///\n";
- }
- if (indent) code += indent;
- std::string::size_type start = 0;
- for (;;) {
- auto end = extra_lines.find('\n', start);
- if (end != std::string::npos) {
- code += "/// " + extra_lines.substr(start, end - start) + "\n";
- start = end + 1;
- } else {
- code += "/// " + extra_lines.substr(start) + "\n";
- break;
- }
- }
- }
- }
-
- static void GenDocComment(std::string *code_ptr,
- const std::string &extra_lines) {
- GenDocComment(std::vector<std::string>(), code_ptr, extra_lines);
}
// Generate an enum declaration and an enum string lookup table.
- void GenEnum(EnumDef &enum_def, namespace_code_map *namespace_code) {
+ void GenEnum(EnumDef &enum_def, namespace_code_map &namespace_code) {
if (enum_def.generated) return;
- auto ns = BuildNamespaceName(*enum_def.defined_namespace);
- std::string code;
- GenDocComment(enum_def.doc_comment, &code, "");
+ std::string &code =
+ namespace_code[namer_.Namespace(*enum_def.defined_namespace)];
+ GenDocComment(enum_def.doc_comment, "", code);
- auto name = enum_def.is_union ? enum_def.name + "TypeId" : enum_def.name;
+ const std::string enum_type =
+ namer_.Type(enum_def) + (enum_def.is_union ? "TypeId" : "");
const bool is_bit_flags =
enum_def.attributes.Lookup("bit_flags") != nullptr;
// The flatbuffer schema language allows bit flag enums to potentially have
// a default value of zero, even if it's not a valid enum value...
const bool permit_zero = is_bit_flags;
- code += "class " + name + " {\n";
+ code += "class " + enum_type + " {\n";
code += " final int value;\n";
- code += " const " + name + "._(this.value);\n\n";
- code += " factory " + name + ".fromValue(int value) {\n";
+ code += " const " + enum_type + "._(this.value);\n\n";
+ code += " factory " + enum_type + ".fromValue(int value) {\n";
code += " final result = values[value];\n";
code += " if (result == null) {\n";
if (permit_zero) {
code += " if (value == 0) {\n";
- code += " return " + name + "._(0);\n";
+ code += " return " + enum_type + "._(0);\n";
code += " } else {\n";
}
code += " throw StateError('Invalid value $value for bit flag enum ";
- code += name + "');\n";
+ code += enum_type + "');\n";
if (permit_zero) { code += " }\n"; }
code += " }\n";
code += " return result;\n";
code += " }\n\n";
- code += " static " + name + "? _createOrNull(int? value) => \n";
- code += " value == null ? null : " + name + ".fromValue(value);\n\n";
+ code += " static " + enum_type + "? _createOrNull(int? value) => \n";
+ code +=
+ " value == null ? null : " + enum_type + ".fromValue(value);\n\n";
// this is meaningless for bit_flags
// however, note that unlike "regular" dart enums this enum can still have
@@ -271,53 +217,52 @@
for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end(); ++it) {
auto &ev = **it;
+ const auto enum_var = namer_.Variant(ev);
if (!ev.doc_comment.empty()) {
if (it != enum_def.Vals().begin()) { code += '\n'; }
- GenDocComment(ev.doc_comment, &code, "", " ");
+ GenDocComment(ev.doc_comment, " ", code);
}
- code += " static const " + name + " " + ev.name + " = " + name + "._(" +
- enum_def.ToString(ev) + ");\n";
+ code += " static const " + enum_type + " " + enum_var + " = " +
+ enum_type + "._(" + enum_def.ToString(ev) + ");\n";
}
- code += " static const Map<int, " + name + "> values = {\n";
+ code += " static const Map<int, " + enum_type + "> values = {\n";
for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end(); ++it) {
auto &ev = **it;
+ const auto enum_var = namer_.Variant(ev);
if (it != enum_def.Vals().begin()) code += ",\n";
- code += " " + enum_def.ToString(ev) + ": " + ev.name;
+ code += " " + enum_def.ToString(ev) + ": " + enum_var;
}
code += "};\n\n";
- code += " static const " + _kFb + ".Reader<" + name + "> reader = _" +
- name + "Reader();\n\n";
+ code += " static const " + _kFb + ".Reader<" + enum_type + "> reader = _" +
+ enum_type + "Reader();\n\n";
code += " @override\n";
code += " String toString() {\n";
- code += " return '" + name + "{value: $value}';\n";
+ code += " return '" + enum_type + "{value: $value}';\n";
code += " }\n";
code += "}\n\n";
- GenEnumReader(enum_def, name, &code);
- (*namespace_code)[ns] += code;
+ GenEnumReader(enum_def, enum_type, code);
}
- void GenEnumReader(EnumDef &enum_def, const std::string &name,
- std::string *code_ptr) {
- auto &code = *code_ptr;
-
- code += "class _" + name + "Reader extends " + _kFb + ".Reader<" + name +
- "> {\n";
- code += " const _" + name + "Reader();\n\n";
+ void GenEnumReader(EnumDef &enum_def, const std::string &enum_type,
+ std::string &code) {
+ code += "class _" + enum_type + "Reader extends " + _kFb + ".Reader<" +
+ enum_type + "> {\n";
+ code += " const _" + enum_type + "Reader();\n\n";
code += " @override\n";
- code += " int get size => 1;\n\n";
+ code += " int get size => " + EnumSize(enum_def.underlying_type) + ";\n\n";
code += " @override\n";
- code +=
- " " + name + " read(" + _kFb + ".BufferContext bc, int offset) =>\n";
- code += " " + name + ".fromValue(const " + _kFb + "." +
+ code += " " + enum_type + " read(" + _kFb +
+ ".BufferContext bc, int offset) =>\n";
+ code += " " + enum_type + ".fromValue(const " + _kFb + "." +
GenType(enum_def.underlying_type) + "Reader().read(bc, offset));\n";
code += "}\n\n";
}
- static std::string GenType(const Type &type) {
+ std::string GenType(const Type &type) {
switch (type.base_type) {
case BASE_TYPE_BOOL: return "Bool";
case BASE_TYPE_CHAR: return "Int8";
@@ -333,12 +278,30 @@
case BASE_TYPE_DOUBLE: return "Float64";
case BASE_TYPE_STRING: return "String";
case BASE_TYPE_VECTOR: return GenType(type.VectorType());
- case BASE_TYPE_STRUCT: return type.struct_def->name;
- case BASE_TYPE_UNION: return type.enum_def->name + "TypeId";
+ case BASE_TYPE_STRUCT: return namer_.Type(*type.struct_def);
+ case BASE_TYPE_UNION: return namer_.Type(*type.enum_def) + "TypeId";
default: return "Table";
}
}
+ static std::string EnumSize(const Type &type) {
+ switch (type.base_type) {
+ case BASE_TYPE_BOOL:
+ case BASE_TYPE_CHAR:
+ case BASE_TYPE_UTYPE:
+ case BASE_TYPE_UCHAR: return "1";
+ case BASE_TYPE_SHORT:
+ case BASE_TYPE_USHORT: return "2";
+ case BASE_TYPE_INT:
+ case BASE_TYPE_UINT:
+ case BASE_TYPE_FLOAT: return "4";
+ case BASE_TYPE_LONG:
+ case BASE_TYPE_ULONG:
+ case BASE_TYPE_DOUBLE: return "8";
+ default: return "1";
+ }
+ }
+
std::string GenReaderTypeName(const Type &type, Namespace *current_namespace,
const FieldDef &def,
bool parent_is_vector = false, bool lazy = true,
@@ -378,11 +341,11 @@
std::string struct_type_suffix = "") {
if (type.enum_def) {
if (type.enum_def->is_union && type.base_type != BASE_TYPE_UNION) {
- return type.enum_def->name + "TypeId";
+ return namer_.Type(*type.enum_def) + "TypeId";
} else if (type.enum_def->is_union) {
return "dynamic";
} else if (type.base_type != BASE_TYPE_VECTOR) {
- return type.enum_def->name;
+ return namer_.Type(*type.enum_def);
}
}
@@ -400,8 +363,9 @@
case BASE_TYPE_DOUBLE: return "double";
case BASE_TYPE_STRING: return "String";
case BASE_TYPE_STRUCT:
- return MaybeWrapNamespace(type.struct_def->name + struct_type_suffix,
- current_namespace, def);
+ return MaybeWrapNamespace(
+ namer_.Type(*type.struct_def) + struct_type_suffix,
+ current_namespace, def);
case BASE_TYPE_VECTOR:
return "List<" +
GenDartTypeName(type.VectorType(), current_namespace, def,
@@ -420,21 +384,19 @@
return typeName;
}
- static const std::string MaybeWrapNamespace(const std::string &type_name,
- Namespace *current_ns,
- const FieldDef &field) {
- auto curr_ns_str = BuildNamespaceName(*current_ns);
- std::string field_ns_str = "";
- if (field.value.type.struct_def) {
- field_ns_str +=
- BuildNamespaceName(*field.value.type.struct_def->defined_namespace);
- } else if (field.value.type.enum_def) {
- field_ns_str +=
- BuildNamespaceName(*field.value.type.enum_def->defined_namespace);
- }
+ std::string MaybeWrapNamespace(const std::string &type_name,
+ Namespace *current_ns,
+ const FieldDef &field) const {
+ const std::string current_namespace = namer_.Namespace(*current_ns);
+ const std::string field_namespace =
+ field.value.type.struct_def
+ ? namer_.Namespace(*field.value.type.struct_def->defined_namespace)
+ : field.value.type.enum_def
+ ? namer_.Namespace(*field.value.type.enum_def->defined_namespace)
+ : "";
- if (field_ns_str != "" && field_ns_str != curr_ns_str) {
- return ImportAliasName(field_ns_str) + "." + type_name;
+ if (field_namespace != "" && field_namespace != current_namespace) {
+ return ImportAliasName(field_namespace) + "." + type_name;
} else {
return type_name;
}
@@ -442,29 +404,29 @@
// Generate an accessor struct with constructor for a flatbuffers struct.
void GenStruct(const StructDef &struct_def,
- namespace_code_map *namespace_code) {
+ namespace_code_map &namespace_code) {
if (struct_def.generated) return;
- auto object_namespace = BuildNamespaceName(*struct_def.defined_namespace);
- std::string code;
+ std::string &code =
+ namespace_code[namer_.Namespace(*struct_def.defined_namespace)];
- const auto &object_name = struct_def.name;
+ const auto &struct_type = namer_.Type(struct_def);
// Emit constructor
- GenDocComment(struct_def.doc_comment, &code, "");
+ GenDocComment(struct_def.doc_comment, "", code);
- auto reader_name = "_" + object_name + "Reader";
- auto builder_name = object_name + "Builder";
- auto object_builder_name = object_name + "ObjectBuilder";
+ auto reader_name = "_" + struct_type + "Reader";
+ auto builder_name = struct_type + "Builder";
+ auto object_builder_name = struct_type + "ObjectBuilder";
std::string reader_code, builder_code;
- code += "class " + object_name + " {\n";
+ code += "class " + struct_type + " {\n";
- code += " " + object_name + "._(this._bc, this._bcOffset);\n";
+ code += " " + struct_type + "._(this._bc, this._bcOffset);\n";
if (!struct_def.fixed) {
- code += " factory " + object_name + "(List<int> bytes) {\n";
+ code += " factory " + struct_type + "(List<int> bytes) {\n";
code +=
" final rootRef = " + _kFb + ".BufferContext.fromBytes(bytes);\n";
code += " return reader.read(rootRef, 0);\n";
@@ -472,7 +434,7 @@
}
code += "\n";
- code += " static const " + _kFb + ".Reader<" + object_name +
+ code += " static const " + _kFb + ".Reader<" + struct_type +
"> reader = " + reader_name + "();\n\n";
code += " final " + _kFb + ".BufferContext _bc;\n";
@@ -481,20 +443,20 @@
std::vector<std::pair<int, FieldDef *>> non_deprecated_fields;
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
- auto &field = **it;
+ FieldDef &field = **it;
if (field.deprecated) continue;
auto offset = static_cast<int>(it - struct_def.fields.vec.begin());
non_deprecated_fields.push_back(std::make_pair(offset, &field));
}
- GenImplementationGetters(struct_def, non_deprecated_fields, &code);
+ GenImplementationGetters(struct_def, non_deprecated_fields, code);
if (parser_.opts.generate_object_based_api) {
code +=
"\n" + GenStructObjectAPIUnpack(struct_def, non_deprecated_fields);
- code += "\n static int pack(fb.Builder fbBuilder, " + struct_def.name +
- "T? object) {\n";
+ code += "\n static int pack(fb.Builder fbBuilder, " +
+ namer_.ObjectType(struct_def) + "? object) {\n";
code += " if (object == null) return 0;\n";
code += " return object.pack(fbBuilder);\n";
code += " }\n";
@@ -506,15 +468,13 @@
code += GenStructObjectAPI(struct_def, non_deprecated_fields);
}
- GenReader(struct_def, &reader_name, &reader_code);
- GenBuilder(struct_def, non_deprecated_fields, &builder_name, &builder_code);
- GenObjectBuilder(struct_def, non_deprecated_fields, &object_builder_name,
- &builder_code);
+ GenReader(struct_def, reader_name, reader_code);
+ GenBuilder(struct_def, non_deprecated_fields, builder_name, builder_code);
+ GenObjectBuilder(struct_def, non_deprecated_fields, object_builder_name,
+ builder_code);
code += reader_code;
code += builder_code;
-
- (*namespace_code)[object_namespace] += code;
}
// Generate an accessor struct with constructor for a flatbuffers struct.
@@ -522,23 +482,23 @@
const StructDef &struct_def,
const std::vector<std::pair<int, FieldDef *>> &non_deprecated_fields) {
std::string code;
- GenDocComment(struct_def.doc_comment, &code, "");
+ GenDocComment(struct_def.doc_comment, "", code);
- std::string class_name = struct_def.name + "T";
- code += "class " + class_name + " implements " + _kFb + ".Packable {\n";
+ std::string object_type = namer_.ObjectType(struct_def);
+ code += "class " + object_type + " implements " + _kFb + ".Packable {\n";
std::string constructor_args;
for (auto it = non_deprecated_fields.begin();
it != non_deprecated_fields.end(); ++it) {
const FieldDef &field = *it->second;
- std::string field_name = ConvertCase(field.name, Case::kLowerCamel);
- std::string defaultValue = getDefaultValue(field.value);
- std::string type_name =
+ const std::string field_name = namer_.Field(field);
+ const std::string defaultValue = getDefaultValue(field.value);
+ const std::string type_name =
GenDartTypeName(field.value.type, struct_def.defined_namespace, field,
defaultValue.empty() && !struct_def.fixed, "T");
- GenDocComment(field.doc_comment, &code, "", " ");
+ GenDocComment(field.doc_comment, " ", code);
code += " " + type_name + " " + field_name + ";\n";
if (!constructor_args.empty()) constructor_args += ",\n";
@@ -549,10 +509,10 @@
if (IsEnum(field.value.type)) {
auto &enum_def = *field.value.type.enum_def;
if (auto val = enum_def.FindByValue(defaultValue)) {
- constructor_args += " = " + enum_def.name + "." + val->name;
+ constructor_args += " = " + namer_.EnumVariant(enum_def, *val);
} else {
- constructor_args +=
- " = const " + enum_def.name + "._(" + defaultValue + ")";
+ constructor_args += " = const " + namer_.Type(enum_def) + "._(" +
+ defaultValue + ")";
}
} else {
constructor_args += " = " + defaultValue;
@@ -561,12 +521,12 @@
}
if (!constructor_args.empty()) {
- code += "\n " + class_name + "({\n" + constructor_args + "});\n\n";
+ code += "\n " + object_type + "({\n" + constructor_args + "});\n\n";
}
code += GenStructObjectAPIPack(struct_def, non_deprecated_fields);
code += "\n";
- code += GenToString(class_name, non_deprecated_fields);
+ code += GenToString(object_type, non_deprecated_fields);
code += "}\n\n";
return code;
@@ -581,7 +541,7 @@
it != non_deprecated_fields.end(); ++it) {
const FieldDef &field = *it->second;
- std::string field_name = ConvertCase(field.name, Case::kLowerCamel);
+ const std::string field_name = namer_.Field(field);
if (!constructor_args.empty()) constructor_args += ",\n";
constructor_args += " " + field_name + ": ";
@@ -612,8 +572,8 @@
}
}
- std::string class_name = struct_def.name + "T";
- std::string code = " " + class_name + " unpack() => " + class_name + "(";
+ const std::string object_type = namer_.ObjectType(struct_def);
+ std::string code = " " + object_type + " unpack() => " + object_type + "(";
if (!constructor_args.empty()) code += "\n" + constructor_args;
code += ");\n";
return code;
@@ -640,7 +600,7 @@
if (std::equal(root_namespace->components.begin(),
root_namespace->components.end(),
qualified_name_parts.begin())) {
- return type.struct_def->name;
+ return namer_.Type(*type.struct_def);
}
std::string ns;
@@ -660,39 +620,35 @@
if (it != qualified_name_parts.end() - 1) { ns += "_"; }
}
- return ns + "." + type.struct_def->name;
+ return ns + "." + namer_.Type(*type.struct_def);
}
void GenImplementationGetters(
const StructDef &struct_def,
- std::vector<std::pair<int, FieldDef *>> non_deprecated_fields,
- std::string *code_ptr) {
- auto &code = *code_ptr;
-
+ const std::vector<std::pair<int, FieldDef *>> &non_deprecated_fields,
+ std::string &code) {
for (auto it = non_deprecated_fields.begin();
it != non_deprecated_fields.end(); ++it) {
- auto pair = *it;
- auto &field = *pair.second;
+ const FieldDef &field = *it->second;
- std::string field_name = ConvertCase(field.name, Case::kLowerCamel);
- std::string defaultValue = getDefaultValue(field.value);
- bool isNullable = defaultValue.empty() && !struct_def.fixed;
- std::string type_name =
+ const std::string field_name = namer_.Field(field);
+ const std::string defaultValue = getDefaultValue(field.value);
+ const bool isNullable = defaultValue.empty() && !struct_def.fixed;
+ const std::string type_name =
GenDartTypeName(field.value.type, struct_def.defined_namespace, field,
isNullable, "");
- GenDocComment(field.doc_comment, &code, "", " ");
+ GenDocComment(field.doc_comment, " ", code);
code += " " + type_name + " get " + field_name;
if (field.value.type.base_type == BASE_TYPE_UNION) {
code += " {\n";
code += " switch (" + field_name + "Type?.value) {\n";
- auto &enum_def = *field.value.type.enum_def;
+ const auto &enum_def = *field.value.type.enum_def;
for (auto en_it = enum_def.Vals().begin() + 1;
en_it != enum_def.Vals().end(); ++en_it) {
- auto &ev = **en_it;
-
- auto enum_name = NamespaceAliasFromUnionType(
+ const auto &ev = **en_it;
+ const auto enum_name = NamespaceAliasFromUnionType(
enum_def.defined_namespace, ev.union_type);
code += " case " + enum_def.ToString(ev) + ": return " +
enum_name + ".reader.vTableGetNullable(_bc, _bcOffset, " +
@@ -733,7 +689,7 @@
}
code += "\n";
- code += GenToString(struct_def.name, non_deprecated_fields);
+ code += GenToString(namer_.Type(struct_def), non_deprecated_fields);
}
std::string GenToString(
@@ -745,10 +701,15 @@
code += " return '" + object_name + "{";
for (auto it = non_deprecated_fields.begin();
it != non_deprecated_fields.end(); ++it) {
- auto pair = *it;
- auto &field = *pair.second;
- code += ConvertCase(field.name, Case::kLowerCamel) + ": $" +
- ConvertCase(field.name, Case::kLowerCamel);
+ const std::string field = namer_.Field(*it->second);
+ // We need to escape the fact that some fields have $ in the name which is
+ // also used in symbol/string substitution.
+ std::string escaped_field;
+ for (size_t i = 0; i < field.size(); i++) {
+ if (field[i] == '$') escaped_field.push_back('\\');
+ escaped_field.push_back(field[i]);
+ }
+ code += escaped_field + ": ${" + field + "}";
if (it != non_deprecated_fields.end() - 1) { code += ", "; }
}
code += "}';\n";
@@ -779,11 +740,9 @@
}
}
- void GenReader(const StructDef &struct_def, std::string *reader_name_ptr,
- std::string *code_ptr) {
- auto &code = *code_ptr;
- auto &reader_name = *reader_name_ptr;
- auto &impl_name = struct_def.name;
+ void GenReader(const StructDef &struct_def, const std::string &reader_name,
+ std::string &code) {
+ const auto struct_type = namer_.Type(struct_def);
code += "class " + reader_name + " extends " + _kFb;
if (struct_def.fixed) {
@@ -791,7 +750,7 @@
} else {
code += ".TableReader<";
}
- code += impl_name + "> {\n";
+ code += struct_type + "> {\n";
code += " const " + reader_name + "();\n\n";
if (struct_def.fixed) {
@@ -799,27 +758,26 @@
code += " int get size => " + NumToString(struct_def.bytesize) + ";\n\n";
}
code += " @override\n";
- code += " " + impl_name +
+ code += " " + struct_type +
" createObject(fb.BufferContext bc, int offset) => \n " +
- impl_name + "._(bc, offset);\n";
+ struct_type + "._(bc, offset);\n";
code += "}\n\n";
}
- void GenBuilder(const StructDef &struct_def,
- std::vector<std::pair<int, FieldDef *>> non_deprecated_fields,
- std::string *builder_name_ptr, std::string *code_ptr) {
+ void GenBuilder(
+ const StructDef &struct_def,
+ const std::vector<std::pair<int, FieldDef *>> &non_deprecated_fields,
+ const std::string &builder_name, std::string &code) {
if (non_deprecated_fields.size() == 0) { return; }
- auto &code = *code_ptr;
- auto &builder_name = *builder_name_ptr;
code += "class " + builder_name + " {\n";
code += " " + builder_name + "(this.fbBuilder);\n\n";
code += " final " + _kFb + ".Builder fbBuilder;\n\n";
if (struct_def.fixed) {
- StructBuilderBody(struct_def, non_deprecated_fields, code_ptr);
+ StructBuilderBody(struct_def, non_deprecated_fields, code);
} else {
- TableBuilderBody(struct_def, non_deprecated_fields, code_ptr);
+ TableBuilderBody(struct_def, non_deprecated_fields, code);
}
code += "}\n\n";
@@ -827,15 +785,13 @@
void StructBuilderBody(
const StructDef &struct_def,
- std::vector<std::pair<int, FieldDef *>> non_deprecated_fields,
- std::string *code_ptr) {
- auto &code = *code_ptr;
-
+ const std::vector<std::pair<int, FieldDef *>> &non_deprecated_fields,
+ std::string &code) {
code += " int finish(";
for (auto it = non_deprecated_fields.begin();
it != non_deprecated_fields.end(); ++it) {
- auto pair = *it;
- auto &field = *pair.second;
+ const FieldDef &field = *it->second;
+ const std::string field_name = namer_.Field(field);
if (IsStruct(field.value.type)) {
code += "fb.StructBuilder";
@@ -843,25 +799,25 @@
code += GenDartTypeName(field.value.type, struct_def.defined_namespace,
field);
}
- code += " " + field.name;
+ code += " " + field_name;
if (it != non_deprecated_fields.end() - 1) { code += ", "; }
}
code += ") {\n";
for (auto it = non_deprecated_fields.rbegin();
it != non_deprecated_fields.rend(); ++it) {
- auto pair = *it;
- auto &field = *pair.second;
+ const FieldDef &field = *it->second;
+ const std::string field_name = namer_.Field(field);
if (field.padding) {
code += " fbBuilder.pad(" + NumToString(field.padding) + ");\n";
}
if (IsStruct(field.value.type)) {
- code += " " + field.name + "();\n";
+ code += " " + field_name + "();\n";
} else {
code += " fbBuilder.put" + GenType(field.value.type) + "(";
- code += field.name;
+ code += field_name;
if (field.value.type.enum_def) { code += ".value"; }
code += ");\n";
}
@@ -872,10 +828,8 @@
void TableBuilderBody(
const StructDef &struct_def,
- std::vector<std::pair<int, FieldDef *>> non_deprecated_fields,
- std::string *code_ptr) {
- auto &code = *code_ptr;
-
+ const std::vector<std::pair<int, FieldDef *>> &non_deprecated_fields,
+ std::string &code) {
code += " void begin() {\n";
code += " fbBuilder.startTable(" +
NumToString(struct_def.fields.vec.size()) + ");\n";
@@ -883,28 +837,27 @@
for (auto it = non_deprecated_fields.begin();
it != non_deprecated_fields.end(); ++it) {
- auto pair = *it;
- auto &field = *pair.second;
- auto offset = pair.first;
+ const auto &field = *it->second;
+ const auto offset = it->first;
+ const std::string add_field = namer_.Method("add", field);
+ const std::string field_var = namer_.Variable(field);
if (IsScalar(field.value.type.base_type)) {
- code += " int add" + ConvertCase(field.name, Case::kUpperCamel) + "(";
+ code += " int " + add_field + "(";
code += GenDartTypeName(field.value.type, struct_def.defined_namespace,
field);
- code += "? " + ConvertCase(field.name, Case::kLowerCamel) + ") {\n";
+ code += "? " + field_var + ") {\n";
code += " fbBuilder.add" + GenType(field.value.type) + "(" +
NumToString(offset) + ", ";
- code += ConvertCase(field.name, Case::kLowerCamel);
+ code += field_var;
if (field.value.type.enum_def) { code += "?.value"; }
code += ");\n";
} else if (IsStruct(field.value.type)) {
- code += " int add" + ConvertCase(field.name, Case::kUpperCamel) +
- "(int offset) {\n";
+ code += " int " + add_field + "(int offset) {\n";
code +=
" fbBuilder.addStruct(" + NumToString(offset) + ", offset);\n";
} else {
- code += " int add" + ConvertCase(field.name, Case::kUpperCamel) +
- "Offset(int? offset) {\n";
+ code += " int " + add_field + "Offset(int? offset) {\n";
code +=
" fbBuilder.addOffset(" + NumToString(offset) + ", offset);\n";
}
@@ -920,21 +873,17 @@
void GenObjectBuilder(
const StructDef &struct_def,
- std::vector<std::pair<int, FieldDef *>> non_deprecated_fields,
- std::string *builder_name_ptr, std::string *code_ptr) {
- auto &code = *code_ptr;
- auto &builder_name = *builder_name_ptr;
-
+ const std::vector<std::pair<int, FieldDef *>> &non_deprecated_fields,
+ const std::string &builder_name, std::string &code) {
code += "class " + builder_name + " extends " + _kFb + ".ObjectBuilder {\n";
for (auto it = non_deprecated_fields.begin();
it != non_deprecated_fields.end(); ++it) {
- auto pair = *it;
- auto &field = *pair.second;
+ const FieldDef &field = *it->second;
code += " final " +
GenDartTypeName(field.value.type, struct_def.defined_namespace,
field, !struct_def.fixed, "ObjectBuilder") +
- " _" + ConvertCase(field.name, Case::kLowerCamel) + ";\n";
+ " _" + namer_.Variable(field) + ";\n";
}
code += "\n";
code += " " + builder_name + "(";
@@ -943,24 +892,21 @@
code += "{\n";
for (auto it = non_deprecated_fields.begin();
it != non_deprecated_fields.end(); ++it) {
- auto pair = *it;
- auto &field = *pair.second;
+ const FieldDef &field = *it->second;
code += " ";
code += (struct_def.fixed ? "required " : "") +
GenDartTypeName(field.value.type, struct_def.defined_namespace,
field, !struct_def.fixed, "ObjectBuilder") +
- " " + ConvertCase(field.name, Case::kLowerCamel) + ",\n";
+ " " + namer_.Variable(field) + ",\n";
}
code += " })\n";
code += " : ";
for (auto it = non_deprecated_fields.begin();
it != non_deprecated_fields.end(); ++it) {
- auto pair = *it;
- auto &field = *pair.second;
+ const FieldDef &field = *it->second;
- code += "_" + ConvertCase(field.name, Case::kLowerCamel) + " = " +
- ConvertCase(field.name, Case::kLowerCamel);
+ code += "_" + namer_.Variable(field) + " = " + namer_.Variable(field);
if (it == non_deprecated_fields.end() - 1) {
code += ";\n\n";
} else {
@@ -1000,11 +946,9 @@
if (IsScalar(field.value.type.base_type) || IsStruct(field.value.type))
continue;
- std::string offset_name =
- ConvertCase(field.name, Case::kLowerCamel) + "Offset";
- std::string field_name = (prependUnderscore ? "_" : "") +
- ConvertCase(field.name, Case::kLowerCamel);
-
+ std::string offset_name = namer_.Variable(field) + "Offset";
+ std::string field_name =
+ (prependUnderscore ? "_" : "") + namer_.Variable(field);
// custom handling for fixed-sized struct in pack()
if (pack && IsVector(field.value.type) &&
field.value.type.VectorType().base_type == BASE_TYPE_STRUCT &&
@@ -1013,7 +957,7 @@
code += " if (" + field_name + " != null) {\n";
code +=
" for (var e in " + field_name + "!) { e.pack(fbBuilder); }\n";
- code += " " + ConvertCase(field.name, Case::kLowerCamel) +
+ code += " " + namer_.Variable(field) +
"Offset = fbBuilder.endStructVector(" + field_name +
"!.length);\n";
code += " }\n";
@@ -1072,8 +1016,8 @@
for (auto it = non_deprecated_fields.rbegin();
it != non_deprecated_fields.rend(); ++it) {
- auto pair = *it;
- auto &field = *pair.second;
+ const FieldDef &field = *it->second;
+ const std::string field_name = namer_.Field(field);
if (field.padding) {
code += " fbBuilder.pad(" + NumToString(field.padding) + ");\n";
@@ -1082,11 +1026,11 @@
if (IsStruct(field.value.type)) {
code += " ";
if (prependUnderscore) { code += "_"; }
- code += field.name + (pack ? ".pack" : ".finish") + "(fbBuilder);\n";
+ code += field_name + (pack ? ".pack" : ".finish") + "(fbBuilder);\n";
} else {
code += " fbBuilder.put" + GenType(field.value.type) + "(";
if (prependUnderscore) { code += "_"; }
- code += field.name;
+ code += field_name;
if (field.value.type.enum_def) { code += ".value"; }
code += ");\n";
}
@@ -1106,34 +1050,35 @@
for (auto it = non_deprecated_fields.begin();
it != non_deprecated_fields.end(); ++it) {
- auto pair = *it;
- auto &field = *pair.second;
- auto offset = pair.first;
+ const FieldDef &field = *it->second;
+ auto offset = it->first;
- std::string field_name = (prependUnderscore ? "_" : "") +
- ConvertCase(field.name, Case::kLowerCamel);
+ std::string field_var =
+ (prependUnderscore ? "_" : "") + namer_.Variable(field);
if (IsScalar(field.value.type.base_type)) {
code += " fbBuilder.add" + GenType(field.value.type) + "(" +
- NumToString(offset) + ", " + field_name;
+ NumToString(offset) + ", " + field_var;
if (field.value.type.enum_def) {
bool isNullable = getDefaultValue(field.value).empty();
code += (isNullable || !pack) ? "?.value" : ".value";
}
code += ");\n";
} else if (IsStruct(field.value.type)) {
- code += " if (" + field_name + " != null) {\n";
+ code += " if (" + field_var + " != null) {\n";
code += " fbBuilder.addStruct(" + NumToString(offset) + ", " +
- field_name + (pack ? "!.pack" : "!.finish") + "(fbBuilder));\n";
+ field_var + (pack ? "!.pack" : "!.finish") + "(fbBuilder));\n";
code += " }\n";
} else {
code += " fbBuilder.addOffset(" + NumToString(offset) + ", " +
- ConvertCase(field.name, Case::kLowerCamel) + "Offset);\n";
+ namer_.Variable(field) + "Offset);\n";
}
}
code += " return fbBuilder.endTable();\n";
return code;
}
+
+ const IdlNamer namer_;
};
} // namespace dart
@@ -1148,8 +1093,7 @@
auto filebase =
flatbuffers::StripPath(flatbuffers::StripExtension(file_name));
dart::DartGenerator generator(parser, path, file_name);
- auto make_rule =
- generator.GeneratedFileName(path, file_name, parser.opts) + ": ";
+ auto make_rule = generator.Filename("") + ": ";
auto included_files = parser.GetIncludedFilesRecursive(file_name);
for (auto it = included_files.begin(); it != included_files.end(); ++it) {
diff --git a/src/idl_gen_fbs.cpp b/src/idl_gen_fbs.cpp
index 35c1a7d..782557f 100644
--- a/src/idl_gen_fbs.cpp
+++ b/src/idl_gen_fbs.cpp
@@ -82,7 +82,7 @@
if (it->second.empty())
continue;
std::string basename;
- if(parser.opts.keep_include_path) {
+ if(parser.opts.keep_prefix) {
basename = flatbuffers::StripExtension(it->second);
} else {
basename = flatbuffers::StripPath(
diff --git a/src/idl_gen_go.cpp b/src/idl_gen_go.cpp
index 306a022..51e018a 100644
--- a/src/idl_gen_go.cpp
+++ b/src/idl_gen_go.cpp
@@ -23,7 +23,7 @@
#include "flatbuffers/flatbuffers.h"
#include "flatbuffers/idl.h"
#include "flatbuffers/util.h"
-#include "namer.h"
+#include "idl_namer.h"
#ifdef _WIN32
# include <direct.h>
@@ -38,8 +38,10 @@
namespace go {
+namespace {
+
// see https://golang.org/ref/spec#Keywords
-std::set<std::string> GoKeywords() {
+static std::set<std::string> GoKeywords() {
return {
"break", "default", "func", "interface", "select",
"case", "defer", "go", "map", "struct",
@@ -49,7 +51,7 @@
};
}
-Namer::Config GoDefaultConfig() {
+static Namer::Config GoDefaultConfig() {
// Note that the functions with user defined types in the name use
// upper camel case for all but the user defined type itself, which is keep
// cased. Despite being a function, we interpret it as a Type.
@@ -61,6 +63,7 @@
/*variables=*/Case::kLowerCamel,
/*variants=*/Case::kKeep,
/*enum_variant_seperator=*/"", // I.e. Concatenate.
+ /*escape_keywords=*/Namer::Config::Escape::AfterConvertingCase,
/*namespaces=*/Case::kKeep,
/*namespace_seperator=*/"__",
/*object_prefix=*/"",
@@ -74,6 +77,8 @@
/*filename_extension=*/".go" };
}
+} // namespace
+
class GoGenerator : public BaseGenerator {
public:
GoGenerator(const Parser &parser, const std::string &path,
@@ -81,8 +86,8 @@
: BaseGenerator(parser, path, file_name, "" /* not used*/,
"" /* not used */, "go"),
cur_name_space_(nullptr),
- namer_({ GoDefaultConfig().WithFlagOptions(parser.opts, path),
- GoKeywords() }) {
+ namer_(WithFlagOptions(GoDefaultConfig(), parser.opts, path),
+ GoKeywords()) {
std::istringstream iss(go_namespace);
std::string component;
while (std::getline(iss, component, '.')) {
@@ -140,7 +145,7 @@
private:
Namespace go_namespace_;
Namespace *cur_name_space_;
- const Namer namer_;
+ const IdlNamer namer_;
struct NamespacePtrLess {
bool operator()(const Namespace *a, const Namespace *b) const {
@@ -160,7 +165,7 @@
void BeginClass(const StructDef &struct_def, std::string *code_ptr) {
std::string &code = *code_ptr;
- code += "type " + namer_.Type(struct_def.name) + " struct {\n\t";
+ code += "type " + namer_.Type(struct_def) + " struct {\n\t";
// _ is reserved in flatbuffers field names, so no chance of name conflict:
code += "_tab ";
@@ -171,7 +176,7 @@
// Construct the name of the type for this enum.
std::string GetEnumTypeName(const EnumDef &enum_def) {
return WrapInNameSpaceAndTrack(enum_def.defined_namespace,
- namer_.Type(enum_def.name));
+ namer_.Type(enum_def));
}
// Create a type for the enum values.
@@ -192,7 +197,7 @@
size_t max_name_length, std::string *code_ptr) {
std::string &code = *code_ptr;
code += "\t";
- code += namer_.EnumVariant(enum_def.name, ev.name);
+ code += namer_.EnumVariant(enum_def, ev);
code += " ";
code += std::string(max_name_length - ev.name.length(), ' ');
code += GetEnumTypeName(enum_def);
@@ -219,7 +224,7 @@
size_t max_name_length, std::string *code_ptr) {
std::string &code = *code_ptr;
code += "\t";
- code += namer_.EnumVariant(enum_def.name, ev.name);
+ code += namer_.EnumVariant(enum_def, ev);
code += ": ";
code += std::string(max_name_length - ev.name.length(), ' ');
code += "\"";
@@ -236,7 +241,7 @@
// Generate String() method on enum type.
void EnumStringer(const EnumDef &enum_def, std::string *code_ptr) {
std::string &code = *code_ptr;
- const std::string enum_type = namer_.Type(enum_def.name);
+ const std::string enum_type = namer_.Type(enum_def);
code += "func (v " + enum_type + ") String() string {\n";
code += "\tif s, ok := EnumNames" + enum_type + "[v]; ok {\n";
code += "\t\treturn s\n";
@@ -250,7 +255,7 @@
void BeginEnumValues(const EnumDef &enum_def, std::string *code_ptr) {
std::string &code = *code_ptr;
code += "var EnumValues";
- code += namer_.Type(enum_def.name);
+ code += namer_.Type(enum_def);
code += " = map[string]" + GetEnumTypeName(enum_def) + "{\n";
}
@@ -262,7 +267,7 @@
code += ev.name;
code += "\": ";
code += std::string(max_name_length - ev.name.length(), ' ');
- code += namer_.EnumVariant(enum_def.name, ev.name);
+ code += namer_.EnumVariant(enum_def, ev);
code += ",\n";
}
@@ -277,7 +282,7 @@
std::string *code_ptr) {
std::string &code = *code_ptr;
const std::string size_prefix[] = { "", "SizePrefixed" };
- const std::string struct_type = namer_.Type(struct_def.name);
+ const std::string struct_type = namer_.Type(struct_def);
for (int i = 0; i < 2; i++) {
code += "func Get" + size_prefix[i] + "RootAs" + struct_type;
@@ -336,7 +341,7 @@
std::string &code = *code_ptr;
GenReceiver(struct_def, code_ptr);
- code += " " + namer_.Function(field.name) + "Length(";
+ code += " " + namer_.Function(field) + "Length(";
code += ") int " + OffsetPrefix(field);
code += "\t\treturn rcv._tab.VectorLen(o)\n\t}\n";
code += "\treturn 0\n}\n\n";
@@ -348,7 +353,7 @@
std::string &code = *code_ptr;
GenReceiver(struct_def, code_ptr);
- code += " " + namer_.Function(field.name) + "Bytes(";
+ code += " " + namer_.Function(field) + "Bytes(";
code += ") []byte " + OffsetPrefix(field);
code += "\t\treturn rcv._tab.ByteVector(o + rcv._tab.Pos)\n\t}\n";
code += "\treturn nil\n}\n\n";
@@ -360,7 +365,7 @@
std::string &code = *code_ptr;
std::string getter = GenGetter(field.value.type);
GenReceiver(struct_def, code_ptr);
- code += " " + namer_.Function(field.name);
+ code += " " + namer_.Function(field);
code += "() " + TypeName(field) + " {\n";
code += "\treturn " +
CastToEnum(field.value.type,
@@ -375,7 +380,7 @@
std::string &code = *code_ptr;
std::string getter = GenGetter(field.value.type);
GenReceiver(struct_def, code_ptr);
- code += " " + namer_.Function(field.name);
+ code += " " + namer_.Function(field);
code += "() " + TypeName(field) + " ";
code += OffsetPrefix(field);
if (field.IsScalarOptional()) {
@@ -384,9 +389,7 @@
code += "\t\treturn ";
}
code += CastToEnum(field.value.type, getter + "(o + rcv._tab.Pos)");
- if (field.IsScalarOptional()) {
- code += "\n\t\treturn &v";
- }
+ if (field.IsScalarOptional()) { code += "\n\t\treturn &v"; }
code += "\n\t}\n";
code += "\treturn " + GenConstant(field) + "\n";
code += "}\n\n";
@@ -398,7 +401,7 @@
const FieldDef &field, std::string *code_ptr) {
std::string &code = *code_ptr;
GenReceiver(struct_def, code_ptr);
- code += " " + namer_.Function(field.name);
+ code += " " + namer_.Function(field);
code += "(obj *" + TypeName(field);
code += ") *" + TypeName(field);
code += " {\n";
@@ -417,7 +420,7 @@
std::string *code_ptr) {
std::string &code = *code_ptr;
GenReceiver(struct_def, code_ptr);
- code += " " + namer_.Function(field.name);
+ code += " " + namer_.Function(field);
code += "(obj *";
code += TypeName(field);
code += ") *" + TypeName(field) + " " + OffsetPrefix(field);
@@ -439,7 +442,7 @@
std::string *code_ptr) {
std::string &code = *code_ptr;
GenReceiver(struct_def, code_ptr);
- code += " " + namer_.Function(field.name);
+ code += " " + namer_.Function(field);
code += "() " + TypeName(field) + " ";
code += OffsetPrefix(field) + "\t\treturn " + GenGetter(field.value.type);
code += "(o + rcv._tab.Pos)\n\t}\n\treturn nil\n";
@@ -451,7 +454,7 @@
std::string *code_ptr) {
std::string &code = *code_ptr;
GenReceiver(struct_def, code_ptr);
- code += " " + namer_.Function(field.name) + "(";
+ code += " " + namer_.Function(field) + "(";
code += "obj " + GenTypePointer(field.value.type) + ") bool ";
code += OffsetPrefix(field);
code += "\t\t" + GenGetter(field.value.type);
@@ -467,7 +470,7 @@
auto vectortype = field.value.type.VectorType();
GenReceiver(struct_def, code_ptr);
- code += " " + namer_.Function(field.name);
+ code += " " + namer_.Function(field);
code += "(obj *" + TypeName(field);
code += ", j int) bool " + OffsetPrefix(field);
code += "\t\tx := rcv._tab.Vector(o)\n";
@@ -490,7 +493,7 @@
auto vectortype = field.value.type.VectorType();
GenReceiver(struct_def, code_ptr);
- code += " " + namer_.Function(field.name);
+ code += " " + namer_.Function(field);
code += "(j int) " + TypeName(field) + " ";
code += OffsetPrefix(field);
code += "\t\ta := rcv._tab.Vector(o)\n";
@@ -538,7 +541,7 @@
} else {
std::string &code = *code_ptr;
code += std::string(", ") + nameprefix;
- code += namer_.Variable(field.name);
+ code += namer_.Variable(field);
code += " " + TypeName(field);
}
}
@@ -568,7 +571,7 @@
} else {
code += "\tbuilder.Prepend" + GenMethod(field) + "(";
code += CastToBaseType(field.value.type,
- nameprefix + namer_.Variable(field.name)) +
+ nameprefix + namer_.Variable(field)) +
")\n";
}
}
@@ -583,7 +586,7 @@
// Get the value of a table's starting offset.
void GetStartOfTable(const StructDef &struct_def, std::string *code_ptr) {
std::string &code = *code_ptr;
- code += "func " + namer_.Type(struct_def.name) + "Start";
+ code += "func " + namer_.Type(struct_def) + "Start";
code += "(builder *flatbuffers.Builder) {\n";
code += "\tbuilder.StartObject(";
code += NumToString(struct_def.fields.vec.size());
@@ -594,9 +597,8 @@
void BuildFieldOfTable(const StructDef &struct_def, const FieldDef &field,
const size_t offset, std::string *code_ptr) {
std::string &code = *code_ptr;
- const std::string field_var = namer_.Variable(field.name);
- code += "func " + namer_.Type(struct_def.name) + "Add" +
- namer_.Function(field.name);
+ const std::string field_var = namer_.Variable(field);
+ code += "func " + namer_.Type(struct_def) + "Add" + namer_.Function(field);
code += "(builder *flatbuffers.Builder, ";
code += field_var + " ";
if (!IsScalar(field.value.type.base_type) && (!struct_def.fixed)) {
@@ -632,8 +634,8 @@
void BuildVectorOfTable(const StructDef &struct_def, const FieldDef &field,
std::string *code_ptr) {
std::string &code = *code_ptr;
- code += "func " + namer_.Type(struct_def.name) + "Start";
- code += namer_.Function(field.name);
+ code += "func " + namer_.Type(struct_def) + "Start";
+ code += namer_.Function(field);
code += "Vector(builder *flatbuffers.Builder, numElems int) ";
code += "flatbuffers.UOffsetT {\n\treturn builder.StartVector(";
auto vector_type = field.value.type.VectorType();
@@ -647,7 +649,7 @@
// Get the offset of the end of a table.
void GetEndOffsetOnTable(const StructDef &struct_def, std::string *code_ptr) {
std::string &code = *code_ptr;
- code += "func " + namer_.Type(struct_def.name) + "End";
+ code += "func " + namer_.Type(struct_def) + "End";
code += "(builder *flatbuffers.Builder) flatbuffers.UOffsetT ";
code += "{\n\treturn builder.EndObject()\n}\n";
}
@@ -655,7 +657,7 @@
// Generate the receiver for function signatures.
void GenReceiver(const StructDef &struct_def, std::string *code_ptr) {
std::string &code = *code_ptr;
- code += "func (rcv *" + namer_.Type(struct_def.name) + ")";
+ code += "func (rcv *" + namer_.Type(struct_def) + ")";
}
// Generate a struct field getter, conditioned on its child type(s).
@@ -708,8 +710,9 @@
std::string setter =
"rcv._tab.Mutate" + namer_.Method(GenTypeBasic(field.value.type));
GenReceiver(struct_def, code_ptr);
- code += " Mutate" + namer_.Function(field.name);
- code += "(n " + GenTypeGet(field.value.type) + ") bool {\n\treturn " + setter;
+ code += " Mutate" + namer_.Function(field);
+ code +=
+ "(n " + GenTypeGet(field.value.type) + ") bool {\n\treturn " + setter;
code += "(rcv._tab.Pos+flatbuffers.UOffsetT(";
code += NumToString(field.value.offset) + "), ";
code += CastToBaseType(field.value.type, "n") + ")\n}\n\n";
@@ -722,7 +725,7 @@
std::string setter = "rcv._tab.Mutate" +
namer_.Method(GenTypeBasic(field.value.type)) + "Slot";
GenReceiver(struct_def, code_ptr);
- code += " Mutate" + namer_.Function(field.name);
+ code += " Mutate" + namer_.Function(field);
code += "(n " + GenTypeGet(field.value.type) + ") bool {\n\treturn ";
code += setter + "(" + NumToString(field.value.offset) + ", ";
code += CastToBaseType(field.value.type, "n") + ")\n";
@@ -738,7 +741,7 @@
std::string setter =
"rcv._tab.Mutate" + namer_.Method(GenTypeBasic(vectortype));
GenReceiver(struct_def, code_ptr);
- code += " Mutate" + namer_.Function(field.name);
+ code += " Mutate" + namer_.Function(field);
code += "(j int, n " + TypeName(field) + ") bool ";
code += OffsetPrefix(field);
code += "\t\ta := rcv._tab.Vector(o)\n";
@@ -841,11 +844,10 @@
field.value.type.enum_def != nullptr &&
field.value.type.enum_def->is_union)
continue;
- code += "\t" + namer_.Field(field.name) + " ";
- if (field.IsScalarOptional()) {
- code += "*";
- }
- code += NativeType(field.value.type) + "\n";
+ code += "\t" + namer_.Field(field) + " ";
+ if (field.IsScalarOptional()) { code += "*"; }
+ code += NativeType(field.value.type) + " `json:\"" + field.name + "\"`" +
+ "\n";
}
code += "}\n\n";
@@ -861,7 +863,7 @@
void GenNativeUnion(const EnumDef &enum_def, std::string *code_ptr) {
std::string &code = *code_ptr;
code += "type " + NativeName(enum_def) + " struct {\n";
- code += "\tType " + namer_.Type(enum_def.name) + "\n";
+ code += "\tType " + namer_.Type(enum_def) + "\n";
code += "\tValue interface{}\n";
code += "}\n\n";
}
@@ -877,7 +879,7 @@
++it2) {
const EnumVal &ev = **it2;
if (ev.IsZero()) continue;
- code += "\tcase " + namer_.EnumVariant(enum_def.name, ev.name) + ":\n";
+ code += "\tcase " + namer_.EnumVariant(enum_def, ev) + ":\n";
code += "\t\treturn t.Value.(" + NativeType(ev.union_type) +
").Pack(builder)\n";
}
@@ -889,7 +891,7 @@
void GenNativeUnionUnPack(const EnumDef &enum_def, std::string *code_ptr) {
std::string &code = *code_ptr;
- code += "func (rcv " + namer_.Type(enum_def.name) +
+ code += "func (rcv " + namer_.Type(enum_def) +
") UnPack(table flatbuffers.Table) *" + NativeName(enum_def) +
" {\n";
code += "\tswitch rcv {\n";
@@ -898,13 +900,13 @@
++it2) {
const EnumVal &ev = **it2;
if (ev.IsZero()) continue;
- code += "\tcase " + namer_.EnumVariant(enum_def.name, ev.name) + ":\n";
+ code += "\tcase " + namer_.EnumVariant(enum_def, ev) + ":\n";
code += "\t\tx := " + ev.union_type.struct_def->name + "{_tab: table}\n";
code += "\t\treturn &" +
WrapInNameSpaceAndTrack(enum_def.defined_namespace,
NativeName(enum_def)) +
- "{ Type: " + namer_.EnumVariant(enum_def.name, ev.name) +
+ "{ Type: " + namer_.EnumVariant(enum_def, ev) +
", Value: x.UnPack() }\n";
}
code += "\t}\n";
@@ -914,7 +916,7 @@
void GenNativeTablePack(const StructDef &struct_def, std::string *code_ptr) {
std::string &code = *code_ptr;
- const std::string struct_type = namer_.Type(struct_def.name);
+ const std::string struct_type = namer_.Type(struct_def);
code += "func (t *" + NativeName(struct_def) +
") Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {\n";
@@ -925,8 +927,8 @@
if (field.deprecated) continue;
if (IsScalar(field.value.type.base_type)) continue;
- const std::string field_field = namer_.Field(field.name);
- const std::string field_var = namer_.Variable(field.name);
+ const std::string field_field = namer_.Field(field);
+ const std::string field_var = namer_.Variable(field);
const std::string offset = field_var + "Offset";
if (IsString(field.value.type)) {
@@ -962,7 +964,7 @@
"[j].Pack(builder)\n";
code += "\t\t}\n";
}
- code += "\t\t" + struct_type + "Start" + namer_.Function(field.name) +
+ code += "\t\t" + struct_type + "Start" + namer_.Function(field) +
"Vector(builder, " + length + ")\n";
code += "\t\tfor j := " + length + " - 1; j >= 0; j-- {\n";
if (IsScalar(field.value.type.element)) {
@@ -996,9 +998,9 @@
it != struct_def.fields.vec.end(); ++it) {
const FieldDef &field = **it;
if (field.deprecated) continue;
- const std::string field_field = namer_.Field(field.name);
- const std::string field_fn = namer_.Function(field.name);
- const std::string offset = namer_.Variable(field.name) + "Offset";
+ const std::string field_field = namer_.Field(field);
+ const std::string field_fn = namer_.Function(field);
+ const std::string offset = namer_.Variable(field) + "Offset";
if (IsScalar(field.value.type.base_type)) {
std::string prefix;
@@ -1011,9 +1013,7 @@
code += "\t" + struct_type + "Add" + field_fn + "(builder, " +
prefix + "t." + field_field + ")\n";
}
- if (field.IsScalarOptional()) {
- code += "\t}\n";
- }
+ if (field.IsScalarOptional()) { code += "\t}\n"; }
} else {
if (field.value.type.base_type == BASE_TYPE_STRUCT &&
field.value.type.struct_def->fixed) {
@@ -1037,7 +1037,7 @@
void GenNativeTableUnPack(const StructDef &struct_def,
std::string *code_ptr) {
std::string &code = *code_ptr;
- const std::string struct_type = namer_.Type(struct_def.name);
+ const std::string struct_type = namer_.Type(struct_def);
code += "func (rcv *" + struct_type + ") UnPackTo(t *" +
NativeName(struct_def) + ") {\n";
@@ -1045,8 +1045,8 @@
it != struct_def.fields.vec.end(); ++it) {
const FieldDef &field = **it;
if (field.deprecated) continue;
- const std::string field_field = namer_.Field(field.name);
- const std::string field_var = namer_.Variable(field.name);
+ const std::string field_field = namer_.Field(field);
+ const std::string field_var = namer_.Variable(field);
const std::string length = field_var + "Length";
if (IsScalar(field.value.type.base_type)) {
if (field.value.type.enum_def != nullptr &&
@@ -1089,8 +1089,8 @@
} else if (field.value.type.base_type == BASE_TYPE_UNION) {
const std::string field_table = field_var + "Table";
code += "\t" + field_table + " := flatbuffers.Table{}\n";
- code += "\tif rcv." + namer_.Method(field.name) + "(&" + field_table +
- ") {\n";
+ code +=
+ "\tif rcv." + namer_.Method(field) + "(&" + field_table + ") {\n";
code += "\t\tt." + field_field + " = rcv." +
namer_.Method(field.name + UnionTypeFieldSuffix()) +
"().UnPack(" + field_table + ")\n";
@@ -1116,7 +1116,7 @@
code += "func (t *" + NativeName(struct_def) +
") Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {\n";
code += "\tif t == nil { return 0 }\n";
- code += "\treturn Create" + namer_.Type(struct_def.name) + "(builder";
+ code += "\treturn Create" + namer_.Type(struct_def) + "(builder";
StructPackArgs(struct_def, "", code_ptr);
code += ")\n";
code += "}\n";
@@ -1130,10 +1130,10 @@
const FieldDef &field = **it;
if (field.value.type.base_type == BASE_TYPE_STRUCT) {
StructPackArgs(*field.value.type.struct_def,
- (nameprefix + namer_.Field(field.name) + ".").c_str(),
+ (nameprefix + namer_.Field(field) + ".").c_str(),
code_ptr);
} else {
- code += std::string(", t.") + nameprefix + namer_.Field(field.name);
+ code += std::string(", t.") + nameprefix + namer_.Field(field);
}
}
}
@@ -1142,22 +1142,22 @@
std::string *code_ptr) {
std::string &code = *code_ptr;
- code += "func (rcv *" + namer_.Type(struct_def.name) + ") UnPackTo(t *" +
+ code += "func (rcv *" + namer_.Type(struct_def) + ") UnPackTo(t *" +
NativeName(struct_def) + ") {\n";
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
const FieldDef &field = **it;
if (field.value.type.base_type == BASE_TYPE_STRUCT) {
- code += "\tt." + namer_.Field(field.name) + " = rcv." +
- namer_.Method(field.name) + "(nil).UnPack()\n";
+ code += "\tt." + namer_.Field(field) + " = rcv." +
+ namer_.Method(field) + "(nil).UnPack()\n";
} else {
- code += "\tt." + namer_.Field(field.name) + " = rcv." +
- namer_.Method(field.name) + "()\n";
+ code += "\tt." + namer_.Field(field) + " = rcv." +
+ namer_.Method(field) + "()\n";
}
}
code += "}\n\n";
- code += "func (rcv *" + namer_.Type(struct_def.name) + ") UnPack() *" +
+ code += "func (rcv *" + namer_.Type(struct_def) + ") UnPack() *" +
NativeName(struct_def) + " {\n";
code += "\tif rcv == nil { return nil }\n";
code += "\tt := &" + NativeName(struct_def) + "{}\n";
@@ -1247,9 +1247,7 @@
std::string TypeName(const FieldDef &field) {
std::string prefix;
- if (field.IsScalarOptional()) {
- prefix = "*";
- }
+ if (field.IsScalarOptional()) { prefix = "*"; }
return prefix + GenTypeGet(field.value.type);
}
@@ -1274,9 +1272,7 @@
}
std::string GenConstant(const FieldDef &field) {
- if (field.IsScalarOptional()) {
- return "nil";
- }
+ if (field.IsScalarOptional()) { return "nil"; }
switch (field.value.type.base_type) {
case BASE_TYPE_BOOL:
return field.value.constant == "0" ? "false" : "true";
@@ -1285,11 +1281,11 @@
}
std::string NativeName(const StructDef &struct_def) const {
- return namer_.ObjectType(struct_def.name);
+ return namer_.ObjectType(struct_def);
}
std::string NativeName(const EnumDef &enum_def) const {
- return namer_.ObjectType(enum_def.name);
+ return namer_.ObjectType(enum_def);
}
std::string NativeType(const Type &type) {
@@ -1366,20 +1362,21 @@
while (code.length() > 2 && code.substr(code.length() - 2) == "\n\n") {
code.pop_back();
}
- std::string filename = namer_.Directories(ns.components) +
- namer_.File(def.name, SkipFile::Suffix);
+ std::string directory = namer_.Directories(ns);
+ std::string file = namer_.File(def, SkipFile::Suffix);
+ EnsureDirExists(directory);
+ std::string filename = directory + file;
return SaveFile(filename.c_str(), code, false);
}
// Create the full name of the imported namespace (format: A__B__C).
std::string NamespaceImportName(const Namespace *ns) const {
- return namer_.Namespace(ns->components);
+ return namer_.Namespace(*ns);
}
// Create the full path for the imported namespace (format: A/B/C).
std::string NamespaceImportPath(const Namespace *ns) const {
- return namer_.Directories(ns->components,
- SkipDir::OutputPathAndTrailingPathSeparator);
+ return namer_.Directories(*ns, SkipDir::OutputPathAndTrailingPathSeparator);
}
// Ensure that a type is prefixed with its go package import name if it is
diff --git a/src/idl_gen_grpc.cpp b/src/idl_gen_grpc.cpp
index 6894ffb..2be24e7 100644
--- a/src/idl_gen_grpc.cpp
+++ b/src/idl_gen_grpc.cpp
@@ -242,12 +242,6 @@
return StripExtension(file_name_);
}
- std::string message_header_ext() const {
- return parser_.opts.filename_suffix + ".h";
- }
-
- std::string service_header_ext() const { return ".grpc.fb.h"; }
-
std::string package() const {
return parser_.current_namespace_->GetFullyQualifiedName("");
}
@@ -347,6 +341,7 @@
bool GenerateCppGRPC(const Parser &parser, const std::string &path,
const std::string &file_name) {
+ const auto &opts = parser.opts;
int nservices = 0;
for (auto it = parser.services_.vec.begin(); it != parser.services_.vec.end();
++it) {
@@ -354,9 +349,15 @@
}
if (!nservices) return true;
+ std::string suffix = "";
+ suffix += opts.filename_suffix.empty() ? "_generated" : opts.filename_suffix;
+ suffix += ".";
+ suffix += opts.filename_extension.empty() ? "h" : opts.filename_extension;
+
grpc_cpp_generator::Parameters generator_parameters;
// TODO(wvo): make the other parameters in this struct configurable.
generator_parameters.use_system_headers = true;
+ generator_parameters.message_header_extension = suffix;
FlatBufFile fbfile(parser, file_name, FlatBufFile::kLanguageCpp);
diff --git a/src/idl_gen_java.cpp b/src/idl_gen_java.cpp
index ee09391..6ee97aa 100644
--- a/src/idl_gen_java.cpp
+++ b/src/idl_gen_java.cpp
@@ -20,20 +20,65 @@
#include "flatbuffers/flatbuffers.h"
#include "flatbuffers/idl.h"
#include "flatbuffers/util.h"
+#include "idl_namer.h"
namespace flatbuffers {
namespace java {
-static TypedFloatConstantGenerator JavaFloatGen("Double.", "Float.", "NaN",
+namespace {
+
+static Namer::Config JavaDefaultConfig() {
+ return {
+ /*types=*/Case::kKeep,
+ /*constants=*/Case::kScreamingSnake,
+ /*methods=*/Case::kLowerCamel,
+ /*functions=*/Case::kLowerCamel,
+ /*fields=*/Case::kLowerCamel,
+ /*variables=*/Case::kLowerCamel,
+ /*variants=*/Case::kKeep,
+ /*enum_variant_seperator=*/".",
+ /*escape_keywords=*/Namer::Config::Escape::AfterConvertingCase,
+ /*namespaces=*/Case::kKeep,
+ /*namespace_seperator=*/".",
+ /*object_prefix=*/"",
+ /*object_suffix=*/"T",
+ /*keyword_prefix=*/"",
+ /*keyword_suffix=*/"_",
+ /*filenames=*/Case::kKeep,
+ /*directories=*/Case::kKeep,
+ /*output_path=*/"",
+ /*filename_suffix=*/"_generated",
+ /*filename_extension=*/".java",
+ };
+}
+
+static std::set<std::string> JavaKeywords() {
+ return {
+ "abstract", "continue", "for", "new", "switch",
+ "assert", "default", "goto", "package", "synchronized",
+ "boolean", "do", "if", "private", "this",
+ "break", "double", "implements", "protected", "throw",
+ "byte", "else", "import", "public", "throws",
+ "case", "enum", "instanceof", "return", "transient",
+ "catch", "extends", "int", "short", "try",
+ "char", "final", "interface", "static", "void",
+ "class", "finally", "long", "strictfp", "volatile",
+ "const", "float", "native", "super", "while",
+ };
+}
+
+static const TypedFloatConstantGenerator JavaFloatGen("Double.", "Float.", "NaN",
"POSITIVE_INFINITY",
"NEGATIVE_INFINITY");
-static CommentConfig comment_config = {
+static const CommentConfig comment_config = {
"/**",
" *",
" */",
};
+} // namespace
+
class JavaGenerator : public BaseGenerator {
struct FieldArrayLength {
std::string name;
@@ -44,7 +89,9 @@
JavaGenerator(const Parser &parser, const std::string &path,
const std::string &file_name)
: BaseGenerator(parser, path, file_name, "", ".", "java"),
- cur_name_space_(nullptr) {}
+ cur_name_space_(nullptr),
+ namer_(WithFlagOptions(JavaDefaultConfig(), parser.opts, path),
+ JavaKeywords()) {}
JavaGenerator &operator=(const JavaGenerator &);
bool generate() {
@@ -56,7 +103,7 @@
std::string enumcode;
auto &enum_def = **it;
if (!parser_.opts.one_file) cur_name_space_ = enum_def.defined_namespace;
- GenEnum(enum_def, &enumcode);
+ GenEnum(enum_def, enumcode);
if (parser_.opts.one_file) {
one_file_code += enumcode;
} else {
@@ -67,8 +114,8 @@
if (parser_.opts.generate_object_based_api && enum_def.is_union) {
enumcode = "";
- GenEnum_ObjectAPI(enum_def, &enumcode, parser_.opts);
- auto class_name = enum_def.name + "Union";
+ GenEnum_ObjectAPI(enum_def, enumcode);
+ auto class_name = namer_.Type(enum_def) + "Union";
if (parser_.opts.one_file) {
one_file_code += enumcode;
} else {
@@ -85,7 +132,7 @@
auto &struct_def = **it;
if (!parser_.opts.one_file)
cur_name_space_ = struct_def.defined_namespace;
- GenStruct(struct_def, &declcode, parser_.opts);
+ GenStruct(struct_def, declcode, parser_.opts);
if (parser_.opts.one_file) {
one_file_code += declcode;
} else {
@@ -96,8 +143,8 @@
if (parser_.opts.generate_object_based_api) {
declcode = "";
- GenStruct_ObjectAPI(struct_def, &declcode, parser_.opts);
- auto class_name = GenTypeName_ObjectAPI(struct_def.name, parser_.opts);
+ GenStruct_ObjectAPI(struct_def, declcode);
+ auto class_name = namer_.ObjectType(struct_def);
if (parser_.opts.one_file) {
one_file_code += declcode;
} else {
@@ -124,7 +171,7 @@
std::string code;
code = "// " + std::string(FlatBuffersGeneratedWarning()) + "\n\n";
- std::string namespace_name = FullNamespace(".", ns);
+ const std::string namespace_name = FullNamespace(".", ns);
if (!namespace_name.empty()) {
code += "package " + namespace_name + ";";
code += "\n\n";
@@ -144,7 +191,10 @@
code += classcode;
if (!namespace_name.empty()) code += "";
- auto filename = NamespaceDir(ns) + defname + ".java";
+ const std::string dirs = namer_.Directories(ns);
+ EnsureDirExists(dirs);
+ const std::string filename =
+ dirs + namer_.File(defname, /*skips=*/SkipFile::Suffix);
return SaveFile(filename.c_str(), code, false);
}
@@ -181,7 +231,7 @@
switch (type.base_type) {
case BASE_TYPE_STRING: return "String";
case BASE_TYPE_VECTOR: return GenTypeGet(type.VectorType());
- case BASE_TYPE_STRUCT: return WrapInNameSpace(*type.struct_def);
+ case BASE_TYPE_STRUCT: return namer_.NamespacedType(*type.struct_def);
case BASE_TYPE_UNION: FLATBUFFERS_FALLTHROUGH(); // else fall thru
default: return "Table";
}
@@ -285,7 +335,7 @@
FLATBUFFERS_ASSERT(value.type.enum_def);
auto &enum_def = *value.type.enum_def;
auto enum_val = enum_def.FindByValue(value.constant);
- return enum_val ? (WrapInNameSpace(enum_def) + "." + enum_val->name)
+ return enum_val ? namer_.NamespacedEnumVariant(enum_def, *enum_val)
: value.constant;
}
@@ -320,8 +370,7 @@
return GenDefaultValue(field);
}
- void GenEnum(EnumDef &enum_def, std::string *code_ptr) const {
- std::string &code = *code_ptr;
+ void GenEnum(EnumDef &enum_def, std::string &code) const {
if (enum_def.generated) return;
// Generate enum definitions of the form:
@@ -329,7 +378,7 @@
// In Java, we use ints rather than the Enum feature, because we want them
// to map directly to how they're used in C/C++ and file formats.
// That, and Java Enums are expensive, and not universally liked.
- GenComment(enum_def.doc_comment, code_ptr, &comment_config);
+ GenComment(enum_def.doc_comment, &code, &comment_config);
code += "@SuppressWarnings(\"unused\")\n";
if (enum_def.attributes.Lookup("private")) {
@@ -337,16 +386,16 @@
} else {
code += "public ";
}
- code += "final class " + enum_def.name;
+ code += "final class " + namer_.Type(enum_def);
code += " {\n";
- code += " private " + enum_def.name + "() { }\n";
+ code += " private " + namer_.Type(enum_def) + "() { }\n";
for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end(); ++it) {
auto &ev = **it;
- GenComment(ev.doc_comment, code_ptr, &comment_config, " ");
+ GenComment(ev.doc_comment, &code, &comment_config, " ");
code += " public static final ";
code += GenTypeBasic(DestinationType(enum_def.underlying_type, false));
code += " ";
- code += ev.name + " = ";
+ code += namer_.Variant(ev) + " = ";
code += enum_def.ToString(ev);
code += ";\n";
}
@@ -364,13 +413,14 @@
"long") {
code += "\n public static final String";
code += "[] names = { ";
- auto val = enum_def.Vals().front();
+ const EnumVal *prev = enum_def.Vals().front();
for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end();
++it) {
- auto ev = *it;
- for (auto k = enum_def.Distance(val, ev); k > 1; --k) code += "\"\", ";
- val = ev;
- code += "\"" + (*it)->name + "\", ";
+ const EnumVal &ev = **it;
+ for (auto k = enum_def.Distance(prev, &ev); k > 1; --k)
+ code += "\"\", ";
+ prev = &ev;
+ code += "\"" + namer_.Variant(ev) + "\", ";
}
code += "};\n\n";
code += " public static ";
@@ -378,7 +428,7 @@
code += " name";
code += "(int e) { return names[e";
if (enum_def.MinValue()->IsNonZero())
- code += " - " + enum_def.MinValue()->name;
+ code += " - " + namer_.Variant(enum_def.MinValue()->name);
code += "]; }\n";
}
@@ -445,9 +495,8 @@
// Recursively generate arguments for a constructor, to deal with nested
// structs.
- void GenStructArgs(const StructDef &struct_def, std::string *code_ptr,
+ void GenStructArgs(const StructDef &struct_def, std::string &code,
const char *nameprefix, size_t array_count = 0) const {
- std::string &code = *code_ptr;
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
auto &field = **it;
@@ -460,7 +509,7 @@
// Generate arguments for a struct inside a struct. To ensure names
// don't clash, and to make it obvious these arguments are constructing
// a nested struct, prefix the name with the field name.
- GenStructArgs(*field_type.struct_def, code_ptr,
+ GenStructArgs(*field_type.struct_def, code,
(nameprefix + (field.name + "_")).c_str(), array_cnt);
} else {
code += ", ";
@@ -468,7 +517,7 @@
for (size_t i = 0; i < array_cnt; i++) code += "[]";
code += " ";
code += nameprefix;
- code += ConvertCase(field.name, Case::kLowerCamel);
+ code += namer_.Field(field);
}
}
}
@@ -476,10 +525,9 @@
// Recusively generate struct construction statements of the form:
// builder.putType(name);
// and insert manual padding.
- void GenStructBody(const StructDef &struct_def, std::string *code_ptr,
+ void GenStructBody(const StructDef &struct_def, std::string &code,
const char *nameprefix, size_t index = 0,
bool in_array = false) const {
- std::string &code = *code_ptr;
std::string indent((index + 1) * 2, ' ');
code += indent + " builder.prep(";
code += NumToString(struct_def.minalign) + ", ";
@@ -493,7 +541,7 @@
code += NumToString(field.padding) + ");\n";
}
if (IsStruct(field_type)) {
- GenStructBody(*field_type.struct_def, code_ptr,
+ GenStructBody(*field_type.struct_def, code,
(nameprefix + (field.name + "_")).c_str(), index,
in_array);
} else {
@@ -507,7 +555,7 @@
in_array = true;
}
if (IsStruct(type)) {
- GenStructBody(*field_type.struct_def, code_ptr,
+ GenStructBody(*field_type.struct_def, code,
(nameprefix + (field.name + "_")).c_str(), index + 1,
in_array);
} else {
@@ -515,8 +563,7 @@
code += indent + " builder.put";
code += GenMethod(type) + "(";
code += SourceCast(type);
- auto argname =
- nameprefix + ConvertCase(field.name, Case::kLowerCamel);
+ auto argname = nameprefix + namer_.Variable(field);
code += argname;
size_t array_cnt = index + (IsArray(field_type) ? 1 : 0);
for (size_t i = 0; in_array && i < array_cnt; i++) {
@@ -529,12 +576,6 @@
}
}
- std::string GenByteBufferLength(const char *bb_name) const {
- std::string bb_len = bb_name;
- bb_len += ".capacity()";
- return bb_len;
- }
-
std::string GenOffsetGetter(flatbuffers::FieldDef *key_field,
const char *num = nullptr) const {
std::string key_offset = "";
@@ -543,7 +584,7 @@
key_offset += num;
key_offset += ", _bb)";
} else {
- key_offset += GenByteBufferLength("bb");
+ key_offset += "bb.capacity()";
key_offset += " - tableOffset, bb)";
}
return key_offset;
@@ -592,10 +633,9 @@
return key_getter;
}
- void GenStruct(StructDef &struct_def, std::string *code_ptr,
+ void GenStruct(StructDef &struct_def, std::string &code,
const IDLOptions &opts) const {
if (struct_def.generated) return;
- std::string &code = *code_ptr;
// Generate a struct accessor class, with methods of the form:
// public type name() { return bb.getType(i + offset); }
@@ -603,7 +643,7 @@
// public type name() {
// int o = __offset(offset); return o != 0 ? bb.getType(o + i) : default;
// }
- GenComment(struct_def.doc_comment, code_ptr, &comment_config);
+ GenComment(struct_def.doc_comment, &code, &comment_config);
if (parser_.opts.gen_generated) {
code += "@javax.annotation.Generated(value=\"flatc\")\n";
@@ -614,33 +654,35 @@
} else {
code += "public ";
}
- code += "final class " + struct_def.name;
+ const auto struct_class = namer_.Type(struct_def);
+ code += "final class " + struct_class;
code += " extends ";
code += struct_def.fixed ? "Struct" : "Table";
code += " {\n";
if (!struct_def.fixed) {
- // Generate verson check method.
+ // Generate version check method.
// Force compile time error if not using the same version runtime.
code += " public static void ValidateVersion() {";
code += " Constants.";
- code += "FLATBUFFERS_2_0_0(); ";
+ code += "FLATBUFFERS_2_0_8(); ";
code += "}\n";
// Generate a special accessor for the table that when used as the root
// of a FlatBuffer
- std::string method_name = "getRootAs" + struct_def.name;
- std::string method_signature =
- " public static " + struct_def.name + " " + method_name;
+ const std::string method_name =
+ namer_.LegacyJavaMethod2("getRootAs", struct_def, "");
+ const std::string method_signature =
+ " public static " + struct_class + " " + method_name;
// create convenience method that doesn't require an existing object
code += method_signature + "(ByteBuffer _bb) ";
- code += "{ return " + method_name + "(_bb, new " + struct_def.name +
- "()); }\n";
+ code +=
+ "{ return " + method_name + "(_bb, new " + struct_class + "()); }\n";
// create method that allows object reuse
code +=
- method_signature + "(ByteBuffer _bb, " + struct_def.name + " obj) { ";
+ method_signature + "(ByteBuffer _bb, " + struct_class + " obj) { ";
code += "_bb.order(ByteOrder.LITTLE_ENDIAN); ";
code += "return (obj.__assign(_bb.getInt(_bb.";
code += "position()";
@@ -651,8 +693,10 @@
if (parser_.file_identifier_.length()) {
// Check if a buffer has the identifier.
code += " public static ";
- code += "boolean " + struct_def.name;
- code += "BufferHasIdentifier(ByteBuffer _bb) { return ";
+ code += "boolean " +
+ namer_.LegacyJavaMethod2(
+ "", struct_def, "BufferHasIdentifier(ByteBuffer _bb)") +
+ " { return ";
code += "__has_identifier(_bb, \"";
code += parser_.file_identifier_;
code += "\"); }\n";
@@ -665,27 +709,24 @@
code += "{ ";
code += "__reset(_i, _bb); ";
code += "}\n";
- code +=
- " public " + struct_def.name + " __assign(int _i, ByteBuffer _bb) ";
+ code += " public " + struct_class + " __assign(int _i, ByteBuffer _bb) ";
code += "{ __init(_i, _bb); return this; }\n\n";
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
auto &field = **it;
if (field.deprecated) continue;
- GenComment(field.doc_comment, code_ptr, &comment_config, " ");
- std::string type_name = GenTypeGet(field.value.type);
- std::string type_name_dest = GenTypeNameDest(field.value.type);
- std::string conditional_cast = "";
- std::string optional = "";
- std::string dest_mask = DestinationMask(field.value.type, true);
- std::string dest_cast = DestinationCast(field.value.type);
- std::string src_cast = SourceCast(field.value.type);
- std::string method_start =
+ GenComment(field.doc_comment, &code, &comment_config, " ");
+ const std::string type_name = GenTypeGet(field.value.type);
+ const std::string type_name_dest = GenTypeNameDest(field.value.type);
+ const std::string dest_mask = DestinationMask(field.value.type, true);
+ const std::string dest_cast = DestinationCast(field.value.type);
+ const std::string src_cast = SourceCast(field.value.type);
+ const std::string method_start =
" public " +
(field.IsRequired() ? "" : GenNullableAnnotation(field.value.type)) +
- GenPureAnnotation(field.value.type) + type_name_dest + optional +
- " " + ConvertCase(field.name, Case::kLowerCamel);
- std::string obj = "obj";
+ GenPureAnnotation(field.value.type) + type_name_dest + " " +
+ namer_.Field(field);
+ const std::string obj = "obj";
// Most field accessors need to retrieve and test the field offset first,
// this is the prefix code for that:
@@ -698,7 +739,7 @@
if (field.value.type.base_type == BASE_TYPE_STRUCT) {
// Calls the accessor that takes an accessor object with a new object.
code += method_start + "() { return ";
- code += ConvertCase(field.name, Case::kLowerCamel);
+ code += namer_.Field(field);
code += "(new ";
code += type_name + "()); }\n";
} else if (IsSeries(field.value.type) &&
@@ -706,14 +747,13 @@
// Accessors for vectors of structs also take accessor objects, this
// generates a variant without that argument.
code += method_start + "(int j) { return ";
- code += ConvertCase(field.name, Case::kLowerCamel);
+ code += namer_.Field(field);
code += "(new " + type_name + "(), j); }\n";
}
if (field.IsScalarOptional()) { code += GenOptionalScalarCheck(field); }
std::string getter = dest_cast + GenGetter(field.value.type);
code += method_start;
- std::string default_cast = "";
std::string member_suffix = "; ";
if (IsScalar(field.value.type.base_type)) {
code += "()";
@@ -726,7 +766,7 @@
} else {
code += offset_prefix + getter;
code += "(o + bb_pos)" + dest_mask;
- code += " : " + default_cast;
+ code += " : ";
code += GenDefaultValue(field);
}
} else {
@@ -738,7 +778,7 @@
code += "bb_pos + " + NumToString(field.value.offset) + ", ";
code += "bb)";
} else {
- code += offset_prefix + conditional_cast;
+ code += offset_prefix;
code += obj + ".__assign(";
code += field.value.type.struct_def->fixed
? "o + bb_pos"
@@ -763,7 +803,7 @@
code += type_name + " obj, ";
}
code += "int j)";
- const auto body = offset_prefix + conditional_cast + getter + "(";
+ const auto body = offset_prefix + getter + "(";
if (vectortype.base_type == BASE_TYPE_UNION) {
code += body + "obj, ";
} else {
@@ -787,11 +827,9 @@
code += ")" + dest_mask;
if (!IsArray(field.value.type)) {
code += " : ";
- code +=
- field.value.type.element == BASE_TYPE_BOOL
- ? "false"
- : (IsScalar(field.value.type.element) ? default_cast + "0"
- : "null");
+ code += field.value.type.element == BASE_TYPE_BOOL
+ ? "false"
+ : (IsScalar(field.value.type.element) ? "0" : "null");
}
break;
@@ -806,7 +844,7 @@
code += member_suffix;
code += "}\n";
if (IsVector(field.value.type)) {
- code += " public int " + ConvertCase(field.name, Case::kLowerCamel);
+ code += " public int " + namer_.Field(field);
code += "Length";
code += "()";
code += offset_prefix;
@@ -821,9 +859,9 @@
for (auto kit = fields.begin(); kit != fields.end(); ++kit) {
auto &key_field = **kit;
if (key_field.key) {
- auto qualified_name = WrapInNameSpace(sd);
+ auto qualified_name = namer_.NamespacedType(sd);
code += " public " + qualified_name + " ";
- code += ConvertCase(field.name, Case::kLowerCamel) + "ByKey(";
+ code += namer_.Method(field) + "ByKey(";
code += GenTypeNameDest(key_field.value.type) + " key)";
code += offset_prefix;
code += qualified_name + ".__lookup_by_key(";
@@ -832,7 +870,7 @@
code += "bb) : null; ";
code += "}\n";
code += " public " + qualified_name + " ";
- code += ConvertCase(field.name, Case::kLowerCamel) + "ByKey(";
+ code += namer_.Method(field) + "ByKey(";
code += qualified_name + " obj, ";
code += GenTypeNameDest(key_field.value.type) + " key)";
code += offset_prefix;
@@ -859,15 +897,14 @@
} else {
vector_type_name = type_name + ".Vector";
}
- auto vector_method_start =
- GenNullableAnnotation(field.value.type) + " public " +
- vector_type_name + optional + " " +
- ConvertCase(field.name, Case::kLowerCamel) + "Vector";
+ auto vector_method_start = GenNullableAnnotation(field.value.type) +
+ " public " + vector_type_name + " " +
+ namer_.Field(field, "vector");
code += vector_method_start + "() { return ";
- code += ConvertCase(field.name, Case::kLowerCamel) + "Vector";
+ code += namer_.Field(field, "vector");
code += "(new " + vector_type_name + "()); }\n";
code += vector_method_start + "(" + vector_type_name + " obj)";
- code += offset_prefix + conditional_cast + obj + ".__assign(";
+ code += offset_prefix + obj + ".__assign(";
code += "__vector(o), ";
if (!IsScalar(element_base_type)) {
auto vectortype = field.value.type.VectorType();
@@ -880,7 +917,7 @@
IsScalar(field.value.type.VectorType().base_type)) ||
IsString(field.value.type)) {
code += " public ByteBuffer ";
- code += ConvertCase(field.name, Case::kLowerCamel);
+ code += namer_.Field(field);
code += "AsByteBuffer() { return ";
code += "__vector_as_bytebuffer(";
code += NumToString(field.value.offset) + ", ";
@@ -889,7 +926,7 @@
: InlineSize(field.value.type.VectorType()));
code += "); }\n";
code += " public ByteBuffer ";
- code += ConvertCase(field.name, Case::kLowerCamel);
+ code += namer_.Field(field);
code += "InByteBuffer(ByteBuffer _bb) { return ";
code += "__vector_in_bytebuffer(_bb, ";
code += NumToString(field.value.offset) + ", ";
@@ -900,9 +937,9 @@
}
// generate object accessors if is nested_flatbuffer
if (field.nested_flatbuffer) {
- auto nested_type_name = WrapInNameSpace(*field.nested_flatbuffer);
- auto nested_method_name = ConvertCase(field.name, Case::kLowerCamel) +
- "As" + field.nested_flatbuffer->name;
+ auto nested_type_name = namer_.NamespacedType(*field.nested_flatbuffer);
+ auto nested_method_name =
+ namer_.Field(field) + "As" + field.nested_flatbuffer->name;
auto get_nested_method_name = nested_method_name;
code += " public " + nested_type_name + " ";
code += nested_method_name + "() { return ";
@@ -913,7 +950,7 @@
code += nested_type_name + " obj";
code += ") { int o = __offset(";
code += NumToString(field.value.offset) + "); ";
- code += "return o != 0 ? " + conditional_cast + obj + ".__assign(";
+ code += "return o != 0 ? " + obj + ".__assign(";
code += "";
code += "__indirect(__vector(o)), ";
code += "bb) : null; }\n";
@@ -928,7 +965,6 @@
auto setter_parameter = underlying_type.base_type == BASE_TYPE_BOOL
? "(byte)(" + field.name + " ? 1 : 0)"
: field.name;
- auto mutator_prefix = "mutate";
// A vector mutator also needs the index of the vector element it should
// mutate.
auto mutator_params = (is_series ? "(int j, " : "(") +
@@ -946,7 +982,7 @@
if (IsScalar(underlying_type.base_type) && !IsUnion(field.value.type)) {
code += " public ";
code += struct_def.fixed ? "void " : "boolean ";
- code += mutator_prefix + ConvertCase(field.name, Case::kUpperCamel);
+ code += namer_.Method("mutate", field);
code += mutator_params;
if (struct_def.fixed) {
code += GenSetter(underlying_type) + "(" + setter_index + ", ";
@@ -962,10 +998,9 @@
}
if (parser_.opts.java_primitive_has_method &&
IsScalar(field.value.type.base_type) && !struct_def.fixed) {
- auto vt_offset_constant =
- " public static final int VT_" +
- ConvertCase(field.name, Case::kScreamingSnake) + " = " +
- NumToString(field.value.offset) + ";";
+ auto vt_offset_constant = " public static final int VT_" +
+ namer_.Constant(field) + " = " +
+ NumToString(field.value.offset) + ";";
code += vt_offset_constant;
code += "\n";
@@ -980,10 +1015,10 @@
// create a struct constructor function
code += " public static " + GenOffsetType() + " ";
code += "create";
- code += struct_def.name + "(FlatBufferBuilder builder";
- GenStructArgs(struct_def, code_ptr, "");
+ code += struct_class + "(FlatBufferBuilder builder";
+ GenStructArgs(struct_def, code, "");
code += ") {\n";
- GenStructBody(struct_def, code_ptr, "");
+ GenStructBody(struct_def, code, "");
code += " return ";
code += GenOffsetConstruct("builder." + std::string("offset()"));
code += ";\n }\n";
@@ -1010,12 +1045,12 @@
// Generate a table constructor of the form:
// public static int createName(FlatBufferBuilder builder, args...)
code += " public static " + GenOffsetType() + " ";
- code += "create" + struct_def.name;
+ code += namer_.LegacyJavaMethod2("create", struct_def, "");
code += "(FlatBufferBuilder builder";
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
auto &field = **it;
- auto field_name = ConvertCase(field.name, Case::kLowerCamel);
+ auto field_name = namer_.Field(field);
if (field.deprecated) continue;
code += ",\n ";
code += GenTypeBasic(DestinationType(field.value.type, false));
@@ -1031,21 +1066,19 @@
for (auto it = struct_def.fields.vec.rbegin();
it != struct_def.fields.vec.rend(); ++it) {
auto &field = **it;
- auto field_name = ConvertCase(field.name, Case::kLowerCamel);
- auto method_name = ConvertCase(field.name, Case::kUpperCamel);
+ auto field_name = namer_.Field(field);
if (!field.deprecated &&
(!struct_def.sortbysize ||
size == SizeOf(field.value.type.base_type))) {
- code += " " + struct_def.name + ".";
- code += "add";
- code += method_name + "(builder, " + field_name;
+ code += " " + struct_class + ".";
+ code += namer_.Method("add", field) + "(builder, " + field_name;
if (!IsScalar(field.value.type.base_type)) code += "Offset";
code += ");\n";
}
}
}
- code += " return " + struct_def.name + ".";
- code += "end" + struct_def.name;
+ code += " return " + struct_class + ".";
+ code += namer_.LegacyJavaMethod2("end", struct_def, "");
code += "(builder);\n }\n\n";
}
// Generate a set of static methods that allow table construction,
@@ -1054,7 +1087,7 @@
// { builder.addShort(id, name, default); }
// Unlike the Create function, these always work.
code += " public static void start";
- code += struct_def.name;
+ code += struct_class;
code += "(FlatBufferBuilder builder) { builder.";
code += "startTable(";
code += NumToString(struct_def.fields.vec.size()) + "); }\n";
@@ -1062,22 +1095,34 @@
it != struct_def.fields.vec.end(); ++it) {
auto &field = **it;
if (field.deprecated) continue;
- if (field.key) key_field = &field;
- code += " public static void add";
- code += ConvertCase(field.name, Case::kUpperCamel);
+
+ code += " public static void " + namer_.Method("add", field);
code += "(FlatBufferBuilder builder, ";
code += GenTypeBasic(DestinationType(field.value.type, false));
- auto argname = ConvertCase(field.name, Case::kLowerCamel);
+ auto argname = namer_.Field(field);
if (!IsScalar(field.value.type.base_type)) argname += "Offset";
code += " " + argname + ") { builder.add";
code += GenMethod(field.value.type) + "(";
- code += NumToString(it - struct_def.fields.vec.begin()) + ", ";
- code += SourceCastBasic(field.value.type);
- code += argname;
- code += ", ";
- code += SourceCastBasic(field.value.type);
- code += GenDefaultValue(field);
- code += "); }\n";
+
+ if (field.key) {
+ // field has key attribute, so always need to exist
+ // even if its value is equal to default.
+ // Generated code will bypass default checking
+ // resulting in { builder.addShort(name); slot(id); }
+ key_field = &field;
+ code += SourceCastBasic(field.value.type);
+ code += argname;
+ code += "); builder.slot(" +
+ NumToString(it - struct_def.fields.vec.begin()) + "); }\n";
+ } else {
+ code += NumToString(it - struct_def.fields.vec.begin()) + ", ";
+ code += SourceCastBasic(field.value.type);
+ code += argname;
+ code += ", ";
+ code += SourceCastBasic(field.value.type);
+ code += GenDefaultValue(field);
+ code += "); }\n";
+ }
if (IsVector(field.value.type)) {
auto vector_type = field.value.type.VectorType();
auto alignment = InlineAlignment(vector_type);
@@ -1089,20 +1134,17 @@
vector_type.base_type == BASE_TYPE_UCHAR)) {
// Handle byte[] and ByteBuffers separately for Java
code += " public static " + GenVectorOffsetType() + " ";
- code += "create";
- code += ConvertCase(field.name, Case::kUpperCamel);
+ code += namer_.Method("create", field);
code += "Vector(FlatBufferBuilder builder, byte[] data) ";
code += "{ return builder.createByteVector(data); }\n";
code += " public static " + GenVectorOffsetType() + " ";
- code += "create";
- code += ConvertCase(field.name, Case::kUpperCamel);
+ code += namer_.Method("create", field);
code += "Vector(FlatBufferBuilder builder, ByteBuffer data) ";
code += "{ return builder.createByteVector(data); }\n";
} else {
code += " public static " + GenVectorOffsetType() + " ";
- code += "create";
- code += ConvertCase(field.name, Case::kUpperCamel);
+ code += namer_.Method("create", field);
code += "Vector(FlatBufferBuilder builder, ";
code += GenTypeBasic(DestinationType(vector_type, false)) +
"[] data) ";
@@ -1123,8 +1165,7 @@
}
// Generate a method to start a vector, data to be added manually
// after.
- code += " public static void start";
- code += ConvertCase(field.name, Case::kUpperCamel);
+ code += " public static void " + namer_.Method("start", field);
code += "Vector(FlatBufferBuilder builder, int numElems) ";
code += "{ builder.startVector(";
code += NumToString(elem_size);
@@ -1133,7 +1174,7 @@
}
}
code += " public static " + GenOffsetType() + " ";
- code += "end" + struct_def.name;
+ code += namer_.LegacyJavaMethod2("end", struct_def, "");
code += "(FlatBufferBuilder builder) {\n int o = builder.";
code += "endTable();\n";
for (auto it = struct_def.fields.vec.begin();
@@ -1150,8 +1191,9 @@
std::string size_prefix[] = { "", "SizePrefixed" };
for (int i = 0; i < 2; ++i) {
code += " public static void ";
- code += "finish" + size_prefix[i] + struct_def.name;
- code += "Buffer(FlatBufferBuilder builder, " + GenOffsetType();
+ code += namer_.LegacyJavaMethod2("finish" + size_prefix[i],
+ struct_def, "Buffer");
+ code += "(FlatBufferBuilder builder, " + GenOffsetType();
code += " offset) {";
code += " builder.finish" + size_prefix[i] + "(offset";
@@ -1170,9 +1212,9 @@
code += GenKeyGetter(key_field);
code += " }\n";
- code += "\n public static " + struct_def.name;
+ code += "\n public static " + struct_class;
code += " __lookup_by_key(";
- code += struct_def.name + " obj, ";
+ code += struct_class + " obj, ";
code += "int vectorLocation, ";
code += GenTypeNameDest(key_field->value.type);
code += " key, ByteBuffer bb) {\n";
@@ -1194,15 +1236,15 @@
code += " span -= middle;\n";
code += " } else {\n";
code += " return ";
- code += "(obj == null ? new " + struct_def.name + "() : obj)";
+ code += "(obj == null ? new " + struct_class + "() : obj)";
code += ".__assign(tableOffset, bb);\n";
code += " }\n }\n";
code += " return null;\n";
code += " }\n";
}
- GenVectorAccessObject(struct_def, code_ptr);
+ GenVectorAccessObject(struct_def, code);
if (opts.generate_object_based_api) {
- GenPackUnPack_ObjectAPI(struct_def, code_ptr, opts, struct_has_create,
+ GenPackUnPack_ObjectAPI(struct_def, code, opts, struct_has_create,
field_has_create_set);
}
code += "}\n\n";
@@ -1210,14 +1252,12 @@
std::string GenOptionalScalarCheck(FieldDef &field) const {
if (!field.IsScalarOptional()) return "";
- return " public boolean has" + ConvertCase(field.name, Case::kUpperCamel) +
+ return " public boolean " + namer_.Method("has", field) +
"() { return 0 != __offset(" + NumToString(field.value.offset) +
"); }\n";
}
- void GenVectorAccessObject(StructDef &struct_def,
- std::string *code_ptr) const {
- auto &code = *code_ptr;
+ void GenVectorAccessObject(StructDef &struct_def, std::string &code) const {
// Generate a vector of structs accessor class.
code += "\n";
code += " ";
@@ -1234,7 +1274,7 @@
code += "__assign(int _vector, int _element_size, ByteBuffer _bb) { ";
code += "__reset(_vector, _element_size, _bb); return this; }\n\n";
- auto type_name = struct_def.name;
+ auto type_name = namer_.Type(struct_def);
auto method_start = method_indent + "public " + type_name + " get";
// Generate the accessors that don't do object reuse.
code += method_start + "(int j) { return get";
@@ -1276,18 +1316,12 @@
code += " }\n";
}
- std::string GenGetterFuncName_ObjectAPI(const std::string &field_name) const {
- return "get" + ConvertCase(field_name, Case::kUpperCamel);
- }
-
- void GenEnum_ObjectAPI(EnumDef &enum_def, std::string *code_ptr,
- const IDLOptions &opts) const {
- auto &code = *code_ptr;
+ void GenEnum_ObjectAPI(EnumDef &enum_def, std::string &code) const {
if (enum_def.generated) return;
code += "import com.google.flatbuffers.FlatBufferBuilder;\n\n";
if (!enum_def.attributes.Lookup("private")) { code += "public "; }
- auto union_name = enum_def.name + "Union";
+ auto union_name = namer_.Type(enum_def) + "Union";
auto union_type =
GenTypeBasic(DestinationType(enum_def.underlying_type, false));
code += "class " + union_name + " {\n";
@@ -1304,15 +1338,16 @@
code += " public void setValue(Object value) { this.value = value; }\n\n";
// Constructor
code += " public " + union_name + "() {\n";
- code += " this.type = " + enum_def.name + "." +
- enum_def.Vals()[0]->name + ";\n";
+ code +=
+ " this.type = " + namer_.EnumVariant(enum_def, *enum_def.Vals()[0]) +
+ ";\n";
code += " this.value = null;\n";
code += " }\n\n";
// As
for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end(); ++it) {
auto &ev = **it;
if (ev.union_type.base_type == BASE_TYPE_NONE) continue;
- auto type_name = GenTypeGet_ObjectAPI(ev.union_type, opts, false, true);
+ auto type_name = GenTypeGet_ObjectAPI(ev.union_type, false, true);
if (ev.union_type.base_type == BASE_TYPE_STRUCT &&
ev.union_type.struct_def->attributes.Lookup("private")) {
code += " ";
@@ -1332,7 +1367,7 @@
if (ev.union_type.base_type == BASE_TYPE_NONE) {
continue;
} else {
- code += " case " + enum_def.name + "." + ev.name + ": return ";
+ code += " case " + namer_.EnumVariant(enum_def, ev) + ": return ";
if (IsString(ev.union_type)) {
code += "builder.createString(_o.as" + ev.name + "());\n";
} else {
@@ -1347,41 +1382,23 @@
code += "}\n\n";
}
- std::string GenSetterFuncName_ObjectAPI(const std::string &field_name) const {
- return "set" + ConvertCase(field_name, Case::kUpperCamel);
- }
-
- std::string GenTypeName_ObjectAPI(const std::string &name,
- const IDLOptions &opts) const {
- return opts.object_prefix + name + opts.object_suffix;
- }
-
- void GenUnionUnPack_ObjectAPI(const EnumDef &enum_def, std::string *code_ptr,
+ void GenUnionUnPack_ObjectAPI(const EnumDef &enum_def, std::string &code,
const std::string &type_name,
- const std::string &camel_name,
+ const std::string &field_name,
bool is_vector) const {
- auto &code = *code_ptr;
+ const std::string variable_type =
+ is_vector ? type_name.substr(0, type_name.length() - 2) : type_name;
+ const std::string variable_name =
+ "_" + namer_.Variable("o", field_name) + (is_vector ? "Element" : "");
+ const std::string type_params = is_vector ? "_j" : "";
+ const std::string value_params = is_vector ? ", _j" : "";
+ const std::string indent = (is_vector ? " " : " ");
- std::string variable_type = type_name;
- std::string variable_name =
- "_o" + ConvertCase(camel_name, Case::kUpperCamel);
- std::string type_params = "";
- std::string value_params = "";
- std::string func_suffix = "()";
- std::string indent = " ";
- if (is_vector) {
- variable_type = type_name.substr(0, type_name.length() - 2);
- variable_name += "Element";
- type_params = "_j";
- value_params = ", _j";
- func_suffix = "(_j)";
- indent = " ";
- }
code += indent + variable_type + " " + variable_name + " = new " +
variable_type + "();\n";
code += indent +
GenTypeBasic(DestinationType(enum_def.underlying_type, false)) +
- " " + variable_name + "Type = " + camel_name + "Type(" +
+ " " + variable_name + "Type = " + field_name + "Type(" +
type_params + ");\n";
code += indent + variable_name + ".setType(" + variable_name + "Type);\n";
code += indent + "Table " + variable_name + "Value;\n";
@@ -1399,10 +1416,10 @@
// Java which doesn't handle non Table types. Should be
// deleted when issue #6561 is fixed.
}
- code += indent + " case " + WrapInNameSpace(enum_def) + "." + ev.name +
- ":\n";
+ code += indent + " case " +
+ namer_.NamespacedEnumVariant(enum_def, ev) + ":\n";
auto actual_type = GenTypeGet(ev.union_type);
- code += indent + " " + variable_name + "Value = " + camel_name +
+ code += indent + " " + variable_name + "Value = " + field_name +
"(new " + actual_type + "()" + value_params + ");\n";
code += indent + " " + variable_name + ".setValue(" + variable_name +
"Value != null ? ((" + actual_type + ") " + variable_name +
@@ -1413,17 +1430,16 @@
code += indent + " default: break;\n";
code += indent + "}\n";
if (is_vector) {
- code += indent + "_o" + ConvertCase(camel_name, Case::kUpperCamel) +
+ code += indent + "_" + namer_.Variable("o", field_name) +
"[_j] = " + variable_name + ";\n";
}
}
void GenPackUnPack_ObjectAPI(
- StructDef &struct_def, std::string *code_ptr, const IDLOptions &opts,
+ StructDef &struct_def, std::string &code, const IDLOptions &opts,
bool struct_has_create,
const std::set<FieldDef *> &field_has_create) const {
- auto &code = *code_ptr;
- auto struct_name = GenTypeName_ObjectAPI(struct_def.name, opts);
+ auto struct_name = namer_.ObjectType(struct_def);
// unpack()
code += " public " + struct_name + " unpack() {\n";
code += " " + struct_name + " _o = new " + struct_name + "();\n";
@@ -1434,35 +1450,34 @@
code += " public void unpackTo(" + struct_name + " _o) {\n";
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
- auto &field = **it;
+ const auto &field = **it;
if (field.deprecated) continue;
if (field.value.type.base_type == BASE_TYPE_UTYPE) continue;
if (field.value.type.element == BASE_TYPE_UTYPE) continue;
- auto camel_name = ConvertCase(field.name, Case::kLowerCamel);
- auto camel_name_with_first = ConvertCase(field.name, Case::kUpperCamel);
- auto type_name =
- GenTypeGet_ObjectAPI(field.value.type, opts, false, true);
+ const auto accessor = namer_.Method(field);
+ const auto variable = "_" + namer_.Variable("o", field);
+ const auto get_field = namer_.Method("get", field);
+ const auto set_field = namer_.Method("set", field);
+
+ auto type_name = GenTypeGet_ObjectAPI(field.value.type, false, true);
if (field.IsScalarOptional())
type_name = ConvertPrimitiveTypeToObjectWrapper_ObjectAPI(type_name);
- auto start = " " + type_name + " _o" + camel_name_with_first + " = ";
+ auto start = " " + type_name + " " + variable + " = ";
auto call_setter = true;
switch (field.value.type.base_type) {
case BASE_TYPE_STRUCT: {
auto fixed = struct_def.fixed && field.value.type.struct_def->fixed;
if (fixed) {
- code += " " + camel_name + "().unpackTo(_o.get" +
- camel_name_with_first + "());\n";
+ code +=
+ " " + accessor + "().unpackTo(_o." + get_field + "());\n";
} else {
- code += " if (" + camel_name + "() != null) ";
+ code += " if (" + accessor + "() != null) ";
if (field.value.type.struct_def->fixed) {
- code += camel_name + "().unpackTo(_o.get" +
- camel_name_with_first + "());\n";
+ code += accessor + "().unpackTo(_o." + get_field + "());\n";
} else {
- code += "_o." + GenSetterFuncName_ObjectAPI(field.name) + "(" +
- camel_name + "().unpack());\n";
+ code += "_o." + set_field + "(" + accessor + "().unpack());\n";
}
- code += " else _o." + GenSetterFuncName_ObjectAPI(field.name) +
- "(null);\n";
+ code += " else _o." + set_field + "(null);\n";
}
call_setter = false;
break;
@@ -1471,38 +1486,38 @@
auto length_str = NumToString(field.value.type.fixed_length);
auto unpack_method =
field.value.type.struct_def == nullptr ? "" : ".unpack()";
- code +=
- start + "_o." + GenGetterFuncName_ObjectAPI(field.name) + "();\n";
- code += " for (int _j = 0; _j < " + length_str + "; ++_j) { _o" +
- camel_name_with_first + "[_j] = " + camel_name + "(_j)" +
- unpack_method + "; }\n";
+ code += start + "_o." + get_field + "();\n";
+ code += " for (int _j = 0; _j < " + length_str + "; ++_j) { " +
+ variable + "[_j] = " + accessor + "(_j)" + unpack_method +
+ "; }\n";
call_setter = false;
break;
}
case BASE_TYPE_VECTOR:
if (field.value.type.element == BASE_TYPE_UNION) {
code += start + "new " +
- GenConcreteTypeGet_ObjectAPI(field.value.type, opts)
+ GenConcreteTypeGet_ObjectAPI(field.value.type)
.substr(0, type_name.length() - 1) +
- camel_name + "Length()];\n";
- code += " for (int _j = 0; _j < " + camel_name +
- "Length(); ++_j) {\n";
- GenUnionUnPack_ObjectAPI(*field.value.type.enum_def, code_ptr,
- type_name, camel_name, true);
+ accessor + "Length()];\n";
+ code +=
+ " for (int _j = 0; _j < " + accessor + "Length(); ++_j) {\n";
+ GenUnionUnPack_ObjectAPI(*field.value.type.enum_def, code,
+ type_name, accessor, true);
code += " }\n";
} else if (field.value.type.element != BASE_TYPE_UTYPE) {
auto fixed = field.value.type.struct_def == nullptr;
+ const auto length_accessor = namer_.Method(field, "length");
code += start + "new " +
- GenConcreteTypeGet_ObjectAPI(field.value.type, opts)
+ GenConcreteTypeGet_ObjectAPI(field.value.type)
.substr(0, type_name.length() - 1) +
- camel_name + "Length()];\n";
+ length_accessor + "()];\n";
code +=
- " for (int _j = 0; _j < " + camel_name + "Length(); ++_j) {";
- code += "_o" + camel_name_with_first + "[_j] = ";
+ " for (int _j = 0; _j < " + length_accessor + "(); ++_j) {";
+ code += variable + "[_j] = ";
if (fixed) {
- code += camel_name + "(_j)";
+ code += accessor + "(_j)";
} else {
- code += "(" + camel_name + "(_j) != null ? " + camel_name +
+ code += "(" + accessor + "(_j) != null ? " + accessor +
"(_j).unpack() : null)";
}
code += ";}\n";
@@ -1510,23 +1525,22 @@
break;
case BASE_TYPE_UTYPE: break;
case BASE_TYPE_UNION: {
- GenUnionUnPack_ObjectAPI(*field.value.type.enum_def, code_ptr,
- type_name, camel_name, false);
+ GenUnionUnPack_ObjectAPI(*field.value.type.enum_def, code, type_name,
+ accessor, false);
break;
}
default: {
if (field.IsScalarOptional()) {
- code += start + "has" + camel_name_with_first + "() ? " +
- camel_name + "() : null;\n";
+ code += start + namer_.Method("has", field) + "() ? " + accessor +
+ "() : null;\n";
} else {
- code += start + camel_name + "();\n";
+ code += start + accessor + "();\n";
}
break;
}
}
if (call_setter) {
- code += " _o." + GenSetterFuncName_ObjectAPI(field.name) + "(_o" +
- camel_name_with_first + ");\n";
+ code += " _o." + set_field + "(" + variable + ");\n";
}
}
code += " }\n";
@@ -1538,17 +1552,17 @@
it != struct_def.fields.vec.end(); ++it) {
auto &field = **it;
if (field.deprecated) continue;
- auto camel_name = ConvertCase(field.name, Case::kLowerCamel);
- auto camel_name_with_first = ConvertCase(field.name, Case::kUpperCamel);
+ const auto field_name = namer_.Field(field);
+ const auto variable = "_" + namer_.Variable("o", field);
+ const auto get_field = namer_.Method("get", field);
// pre
switch (field.value.type.base_type) {
case BASE_TYPE_STRUCT: {
if (!field.value.type.struct_def->fixed) {
- code += " " + GenOffsetType() + " _" + field.name + " = _o." +
- GenGetterFuncName_ObjectAPI(field.name) +
+ code += " " + GenOffsetType() + " _" + namer_.Variable(field) +
+ " = _o." + get_field +
"() == null ? 0 : " + GenTypeGet(field.value.type) +
- ".pack(builder, _o." +
- GenGetterFuncName_ObjectAPI(field.name) + "());\n";
+ ".pack(builder, _o." + get_field + "());\n";
} else if (struct_def.fixed && struct_has_create) {
std::vector<FieldArrayLength> array_lengths;
FieldArrayLength tmp_array_length = {
@@ -1556,60 +1570,54 @@
field.value.type.fixed_length,
};
array_lengths.push_back(tmp_array_length);
- GenStructPackDecl_ObjectAPI(*field.value.type.struct_def, code_ptr,
- array_lengths);
+ GenStructPackDecl_ObjectAPI(*field.value.type.struct_def,
+ array_lengths, code);
}
break;
}
case BASE_TYPE_STRING: {
- std::string create_string = "createString";
- code += " int _" + camel_name + " = _o." +
- GenGetterFuncName_ObjectAPI(field.name) +
+ code += " int _" + field_name + " = _o." + get_field +
"() == null ? 0 : "
- "builder." +
- create_string + "(_o." +
- GenGetterFuncName_ObjectAPI(field.name) + "());\n";
+ "builder.createString(_o." +
+ get_field + "());\n";
break;
}
case BASE_TYPE_VECTOR: {
if (field_has_create.find(&field) != field_has_create.end()) {
- auto property_name = camel_name;
+ auto property_name = field_name;
auto gen_for_loop = true;
- std::string array_name = "__" + camel_name;
+ std::string array_name = "__" + field_name;
std::string array_type = "";
std::string element_type = "";
std::string to_array = "";
switch (field.value.type.element) {
case BASE_TYPE_STRING: {
- std::string create_string = "createString";
array_type = "int";
element_type = "String";
- to_array += "builder." + create_string + "(_e)";
+ to_array = "builder.createString(_e)";
break;
}
case BASE_TYPE_STRUCT:
array_type = "int";
element_type =
- GenTypeGet_ObjectAPI(field.value.type, opts, true, true);
+ GenTypeGet_ObjectAPI(field.value.type, true, true);
;
to_array = GenTypeGet(field.value.type) + ".pack(builder, _e)";
break;
case BASE_TYPE_UTYPE:
- property_name = camel_name.substr(0, camel_name.size() - 4);
+ property_name = field_name.substr(0, field_name.size() - 4);
array_type = GenTypeBasic(DestinationType(
field.value.type.enum_def->underlying_type, false));
element_type = field.value.type.enum_def->name + "Union";
- to_array = "_o." + GenGetterFuncName_ObjectAPI(property_name) +
+ to_array = "_o." + namer_.Method("get", property_name) +
"()[_j].getType()";
break;
case BASE_TYPE_UNION:
array_type = "int";
element_type =
- WrapInNameSpace(*field.value.type.enum_def) + "Union";
- to_array = WrapInNameSpace(*field.value.type.enum_def) +
- "Union.pack(builder, _o." +
- GenGetterFuncName_ObjectAPI(property_name) +
- "()[_j])";
+ namer_.NamespacedType(*field.value.type.enum_def) + "Union";
+ to_array = element_type + ".pack(builder, _o." +
+ namer_.Method("get", property_name) + "()[_j])";
break;
case BASE_TYPE_UCHAR: // TODO this branch of the switch is due to
// inconsistent behavior in unsigned byte.
@@ -1620,52 +1628,51 @@
break;
default:
gen_for_loop = false;
- array_name =
- "_o." + GenGetterFuncName_ObjectAPI(property_name) + "()";
+ array_name = "_o." + namer_.Method("get", property_name) + "()";
array_type = GenTypeNameDest(field.value.type);
element_type = array_type;
to_array = "_e";
break;
}
- code += " int _" + camel_name + " = 0;\n";
- code += " if (_o." + GenGetterFuncName_ObjectAPI(property_name) +
+ code += " int _" + field_name + " = 0;\n";
+ code += " if (_o." + namer_.Method("get", property_name) +
"() != null) {\n";
if (gen_for_loop) {
code += " " + array_type + "[] " + array_name + " = new " +
array_type + "[_o." +
- GenGetterFuncName_ObjectAPI(property_name) +
- "().length];\n";
+ namer_.Method("get", property_name) + "().length];\n";
code += " int _j = 0;\n";
code += " for (" + element_type + " _e : _o." +
- GenGetterFuncName_ObjectAPI(property_name) + "()) { ";
+ namer_.Method("get", property_name) + "()) { ";
code += array_name + "[_j] = " + to_array + "; _j++;}\n";
}
- code += " _" + camel_name + " = create" +
- camel_name_with_first + "Vector(builder, " + array_name +
- ");\n";
+ code += " _" + field_name + " = " +
+ namer_.Method("create", field) + "Vector(builder, " +
+ array_name + ");\n";
code += " }\n";
} else {
auto type_name = GenTypeGet(field.value.type);
auto element_type_name =
- GenTypeGet_ObjectAPI(field.value.type, opts, true, true);
+ GenTypeGet_ObjectAPI(field.value.type, true, true);
auto pack_method =
field.value.type.struct_def == nullptr
? "builder.add" + GenMethod(field.value.type.VectorType()) +
- "(_o" + camel_name_with_first + "[_j]);"
- : type_name + ".pack(builder, _o" + camel_name_with_first +
- "[_j]);";
- code += " int _" + camel_name + " = 0;\n";
- code += " " + element_type_name + "[] _o" +
- camel_name_with_first + " = _o." +
- GenGetterFuncName_ObjectAPI(field.name) + "();\n";
- code += " if (_o" + camel_name_with_first + " != null) {\n";
- code += " start" + camel_name_with_first +
- "Vector(builder, _o" + camel_name_with_first +
- ".length);\n";
- code += " for (int _j = _o" + camel_name_with_first +
+ "(" + variable + "[_j]);"
+ : "_unused_offset = " + type_name + ".pack(builder, " +
+ variable + "[_j]);";
+ code += " int _" + field_name + " = 0;\n";
+ code += " " + element_type_name + "[] " + variable + " = _o." +
+ get_field + "();\n";
+ code += " if (" + variable + " != null) {\n";
+ if (field.value.type.struct_def != nullptr) {
+ code += " int _unused_offset = 0;\n";
+ }
+ code += " " + namer_.Method("start", field) +
+ "Vector(builder, " + variable + ".length);\n";
+ code += " for (int _j = " + variable +
".length - 1; _j >=0; _j--) { ";
code += pack_method + "}\n";
- code += " _" + camel_name + " = builder.endVector();\n";
+ code += " _" + field_name + " = builder.endVector();\n";
code += " }\n";
}
break;
@@ -1678,29 +1685,27 @@
field.value.type.fixed_length,
};
array_lengths.push_back(tmp_array_length);
- GenStructPackDecl_ObjectAPI(*field.value.type.struct_def, code_ptr,
- array_lengths);
+ GenStructPackDecl_ObjectAPI(*field.value.type.struct_def,
+ array_lengths, code);
} else {
code += " " +
- GenTypeGet_ObjectAPI(field.value.type, opts, false, true) +
- " _" + camel_name + " = _o." +
- GenGetterFuncName_ObjectAPI(field.name) + "();\n";
+ GenTypeGet_ObjectAPI(field.value.type, false, true) + " _" +
+ field_name + " = _o." + get_field + "();\n";
}
break;
}
case BASE_TYPE_UNION: {
- code +=
- " " +
- GenTypeBasic(DestinationType(
- field.value.type.enum_def->underlying_type, false)) +
- " _" + camel_name + "Type = _o.get" + camel_name_with_first +
- "() == null ? " + WrapInNameSpace(*field.value.type.enum_def) +
- ".NONE : " + "_o.get" + camel_name_with_first + "().getType();\n";
- code += " " + GenOffsetType() + " _" + camel_name + " = _o.get" +
- camel_name_with_first + "() == null ? 0 : " +
- WrapInNameSpace(*field.value.type.enum_def) +
- "Union.pack(builder, _o.get" + camel_name_with_first +
- "());\n";
+ code += " " +
+ GenTypeBasic(DestinationType(
+ field.value.type.enum_def->underlying_type, false)) +
+ " _" + field_name + "Type = _o." + get_field +
+ "() == null ? " +
+ namer_.NamespacedType(*field.value.type.enum_def) +
+ ".NONE : " + "_o." + get_field + "().getType();\n";
+ code += " " + GenOffsetType() + " _" + field_name + " = _o." +
+ get_field + "() == null ? 0 : " +
+ namer_.NamespacedType(*field.value.type.enum_def) +
+ "Union.pack(builder, _o." + get_field + "());\n";
break;
}
default: break;
@@ -1708,42 +1713,42 @@
}
if (struct_has_create) {
// Create
- code += " return create" + struct_def.name + "(\n";
+ code += " return " +
+ namer_.LegacyJavaMethod2("create", struct_def, "") + "(\n";
code += " builder";
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
auto &field = **it;
if (field.deprecated) continue;
- auto camel_name = ConvertCase(field.name, Case::kLowerCamel);
+ const auto field_name = namer_.Field(field);
+ const auto get_field = namer_.Method("get", field);
switch (field.value.type.base_type) {
case BASE_TYPE_STRUCT: {
if (struct_def.fixed) {
- GenStructPackCall_ObjectAPI(*field.value.type.struct_def,
- code_ptr,
- " _" + camel_name + "_");
+ GenStructPackCall_ObjectAPI(*field.value.type.struct_def, code,
+ " _" + field_name + "_");
} else {
code += ",\n";
if (field.value.type.struct_def->fixed) {
if (opts.generate_object_based_api)
- code += " _o." + camel_name;
+ code += " _o." + field_name;
else
// Seems like unreachable code
code += " " + GenTypeGet(field.value.type) +
- ".Pack(builder, _o." + camel_name + ")";
+ ".Pack(builder, _o." + field_name + ")";
} else {
- code += " _" + field.name;
+ code += " _" + field_name;
}
}
break;
}
case BASE_TYPE_ARRAY: {
if (field.value.type.struct_def != nullptr) {
- GenStructPackCall_ObjectAPI(*field.value.type.struct_def,
- code_ptr,
- " _" + camel_name + "_");
+ GenStructPackCall_ObjectAPI(*field.value.type.struct_def, code,
+ " _" + field_name + "_");
} else {
code += ",\n";
- code += " _" + camel_name;
+ code += " _" + field_name;
}
break;
}
@@ -1752,82 +1757,78 @@
case BASE_TYPE_STRING: FLATBUFFERS_FALLTHROUGH(); // fall thru
case BASE_TYPE_VECTOR: {
code += ",\n";
- code += " _" + camel_name;
+ code += " _" + field_name;
break;
}
default: // scalar
code += ",\n";
- code +=
- " _o." + GenGetterFuncName_ObjectAPI(field.name) + "()";
+ code += " _o." + get_field + "()";
break;
}
}
code += ");\n";
} else {
// Start, End
- code += " start" + struct_def.name + "(builder);\n";
+ code += " " + namer_.LegacyJavaMethod2("start", struct_def, "") +
+ "(builder);\n";
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
auto &field = **it;
if (field.deprecated) continue;
- auto camel_name = ConvertCase(field.name, Case::kLowerCamel);
- auto camel_name_with_first = ConvertCase(field.name, Case::kUpperCamel);
+ const auto arg = "_" + namer_.Variable(field);
+ const auto get_field = namer_.Method("get", field);
+ const auto add_field = namer_.Method("add", field);
+
switch (field.value.type.base_type) {
case BASE_TYPE_STRUCT: {
if (field.value.type.struct_def->fixed) {
- code += " add" + camel_name_with_first + "(builder, " +
+ code += " " + add_field + "(builder, " +
GenTypeGet(field.value.type) + ".pack(builder, _o." +
- GenGetterFuncName_ObjectAPI(field.name) + "()));\n";
+ get_field + "()));\n";
} else {
- code += " add" + camel_name_with_first + "(builder, _" +
- field.name + ");\n";
+ code += " " + add_field + "(builder, " + arg + ");\n";
}
break;
}
case BASE_TYPE_STRING: FLATBUFFERS_FALLTHROUGH(); // fall thru
case BASE_TYPE_ARRAY: FLATBUFFERS_FALLTHROUGH(); // fall thru
case BASE_TYPE_VECTOR: {
- code += " add" + camel_name_with_first + "(builder, _" +
- camel_name + ");\n";
+ code += " " + add_field + "(builder, " + arg + ");\n";
break;
}
case BASE_TYPE_UTYPE: break;
case BASE_TYPE_UNION: {
- code += " add" + camel_name_with_first + "Type(builder, _" +
- camel_name + "Type);\n";
- code += " add" + camel_name_with_first + "(builder, _" +
- camel_name + ");\n";
+ code += " " + add_field + "Type(builder, " + arg + "Type);\n";
+ code += " " + add_field + "(builder, " + arg + ");\n";
break;
}
// scalar
default: {
if (field.IsScalarOptional()) {
- code += " if (_o." + GenGetterFuncName_ObjectAPI(field.name) +
- "() != null) { add" + camel_name_with_first +
- "(builder, _o." +
- GenGetterFuncName_ObjectAPI(field.name) + "()); }\n";
+ code += " if (_o." + get_field + "() != null) { " + add_field +
+ "(builder, _o." + get_field + "()); }\n";
} else {
- code += " add" + camel_name_with_first + "(builder, _o." +
- GenGetterFuncName_ObjectAPI(field.name) + "());\n";
+ code +=
+ " " + add_field + "(builder, _o." + get_field + "());\n";
}
break;
}
}
}
- code += " return end" + struct_def.name + "(builder);\n";
+ code += " return " + namer_.LegacyJavaMethod2("end", struct_def, "") +
+ "(builder);\n";
}
code += " }\n";
}
- void GenStructPackDecl_ObjectAPI(
- const StructDef &struct_def, std::string *code_ptr,
- std::vector<FieldArrayLength> &array_lengths) const {
- auto &code = *code_ptr;
+ void GenStructPackDecl_ObjectAPI(const StructDef &struct_def,
+ std::vector<FieldArrayLength> &array_lengths,
+ std::string &code) const {
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
- auto &field = **it;
- auto is_array = IsArray(field.value.type);
- const auto &field_type =
+ const FieldDef &field = **it;
+ const bool is_array = IsArray(field.value.type);
+ const Type &field_type =
is_array ? field.value.type.VectorType() : field.value.type;
FieldArrayLength tmp_array_length = {
field.name,
@@ -1835,8 +1836,8 @@
};
array_lengths.push_back(tmp_array_length);
if (field_type.struct_def != nullptr) {
- GenStructPackDecl_ObjectAPI(*field_type.struct_def, code_ptr,
- array_lengths);
+ GenStructPackDecl_ObjectAPI(*field_type.struct_def, array_lengths,
+ code);
} else {
std::vector<FieldArrayLength> array_only_lengths;
for (size_t i = 0; i < array_lengths.size(); ++i) {
@@ -1846,7 +1847,7 @@
}
std::string name;
for (size_t i = 0; i < array_lengths.size(); ++i) {
- name += "_" + ConvertCase(array_lengths[i].name, Case::kLowerCamel);
+ name += "_" + namer_.Variable(array_lengths[i].name);
}
code += " " + GenTypeBasic(field_type);
if (array_only_lengths.size() > 0) {
@@ -1878,8 +1879,7 @@
}
code += "] = _o";
for (size_t i = 0, j = 0; i < array_lengths.size(); ++i) {
- code +=
- "." + GenGetterFuncName_ObjectAPI(array_lengths[i].name) + "()";
+ code += "." + namer_.Method("get", array_lengths[i].name) + "()";
if (array_lengths[i].length <= 0) continue;
code += "[idx" + NumToString(j++) + "]";
}
@@ -1891,8 +1891,7 @@
code += " " + name + " = ";
code += "_o";
for (size_t i = 0; i < array_lengths.size(); ++i) {
- code +=
- "." + GenGetterFuncName_ObjectAPI(array_lengths[i].name) + "()";
+ code += "." + namer_.Method("get", array_lengths[i].name) + "()";
}
code += ";";
}
@@ -1903,26 +1902,24 @@
}
void GenStructPackCall_ObjectAPI(const StructDef &struct_def,
- std::string *code_ptr,
+ std::string &code,
std::string prefix) const {
- auto &code = *code_ptr;
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
auto &field = **it;
const auto &field_type = field.value.type;
if (field_type.struct_def != nullptr) {
- GenStructPackCall_ObjectAPI(
- *field_type.struct_def, code_ptr,
- prefix + ConvertCase(field.name, Case::kLowerCamel) + "_");
+ GenStructPackCall_ObjectAPI(*field_type.struct_def, code,
+ prefix + namer_.Field(field) + "_");
} else {
code += ",\n";
- code += prefix + ConvertCase(field.name, Case::kLowerCamel);
+ code += prefix + namer_.Field(field);
}
}
}
std::string ConvertPrimitiveTypeToObjectWrapper_ObjectAPI(
- std::string type_name) const {
+ const std::string &type_name) const {
if (type_name == "boolean")
return "Boolean";
else if (type_name == "byte")
@@ -1942,8 +1939,8 @@
return type_name;
}
- std::string GenTypeGet_ObjectAPI(flatbuffers::Type type,
- const IDLOptions &opts, bool vectorelem,
+ std::string GenTypeGet_ObjectAPI(const flatbuffers::Type &type,
+ bool vectorelem,
bool wrap_in_namespace) const {
auto type_name = GenTypeNameDest(type);
// Replace to ObjectBaseAPI Type Name
@@ -1953,15 +1950,14 @@
case BASE_TYPE_VECTOR: {
if (type.struct_def != nullptr) {
auto type_name_length = type.struct_def->name.length();
- auto new_type_name =
- GenTypeName_ObjectAPI(type.struct_def->name, opts);
+ auto new_type_name = namer_.ObjectType(*type.struct_def);
type_name.replace(type_name.length() - type_name_length,
type_name_length, new_type_name);
} else if (type.element == BASE_TYPE_UNION) {
if (wrap_in_namespace) {
- type_name = WrapInNameSpace(*type.enum_def) + "Union";
+ type_name = namer_.NamespacedType(*type.enum_def) + "Union";
} else {
- type_name = type.enum_def->name + "Union";
+ type_name = namer_.Type(*type.enum_def) + "Union";
}
}
break;
@@ -1969,9 +1965,9 @@
case BASE_TYPE_UNION: {
if (wrap_in_namespace) {
- type_name = WrapInNameSpace(*type.enum_def) + "Union";
+ type_name = namer_.NamespacedType(*type.enum_def) + "Union";
} else {
- type_name = type.enum_def->name + "Union";
+ type_name = namer_.Type(*type.enum_def) + "Union";
}
break;
}
@@ -1989,8 +1985,8 @@
return type_name;
}
- std::string GenConcreteTypeGet_ObjectAPI(flatbuffers::Type type,
- const IDLOptions &opts) const {
+ std::string GenConcreteTypeGet_ObjectAPI(
+ const flatbuffers::Type &type) const {
auto type_name = GenTypeNameDest(type);
// Replace to ObjectBaseAPI Type Name
switch (type.base_type) {
@@ -1999,18 +1995,17 @@
case BASE_TYPE_VECTOR: {
if (type.struct_def != nullptr) {
auto type_name_length = type.struct_def->name.length();
- auto new_type_name =
- GenTypeName_ObjectAPI(type.struct_def->name, opts);
+ auto new_type_name = namer_.ObjectType(*type.struct_def);
type_name.replace(type_name.length() - type_name_length,
type_name_length, new_type_name);
} else if (type.element == BASE_TYPE_UNION) {
- type_name = WrapInNameSpace(*type.enum_def) + "Union";
+ type_name = namer_.NamespacedType(*type.enum_def) + "Union";
}
break;
}
case BASE_TYPE_UNION: {
- type_name = WrapInNameSpace(*type.enum_def) + "Union";
+ type_name = namer_.NamespacedType(*type.enum_def) + "Union";
break;
}
default: break;
@@ -2027,71 +2022,71 @@
return type_name;
}
- void GenStruct_ObjectAPI(StructDef &struct_def, std::string *code_ptr,
- const IDLOptions &opts) const {
+ void GenStruct_ObjectAPI(const StructDef &struct_def,
+ std::string &code) const {
if (struct_def.generated) return;
- auto &code = *code_ptr;
if (struct_def.attributes.Lookup("private")) {
// For Java, we leave the enum unmarked to indicate package-private
} else {
code += "public ";
}
- auto class_name = GenTypeName_ObjectAPI(struct_def.name, opts);
+ const auto class_name = namer_.ObjectType(struct_def);
code += "class " + class_name;
code += " {\n";
// Generate Properties
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
- auto &field = **it;
+ const auto &field = **it;
if (field.deprecated) continue;
if (field.value.type.base_type == BASE_TYPE_UTYPE) continue;
if (field.value.type.element == BASE_TYPE_UTYPE) continue;
- auto type_name =
- GenTypeGet_ObjectAPI(field.value.type, opts, false, true);
+ auto type_name = GenTypeGet_ObjectAPI(field.value.type, false, true);
if (field.IsScalarOptional())
type_name = ConvertPrimitiveTypeToObjectWrapper_ObjectAPI(type_name);
- auto camel_name = ConvertCase(field.name, Case::kLowerCamel);
- code += " private " + type_name + " " + camel_name + ";\n";
+ const auto field_name = namer_.Field(field);
+ code += " private " + type_name + " " + field_name + ";\n";
}
// Generate Java getters and setters
code += "\n";
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
- auto &field = **it;
+ const auto &field = **it;
if (field.deprecated) continue;
if (field.value.type.base_type == BASE_TYPE_UTYPE) continue;
if (field.value.type.element == BASE_TYPE_UTYPE) continue;
- auto type_name =
- GenTypeGet_ObjectAPI(field.value.type, opts, false, true);
+ const auto field_name = namer_.Field(field);
+ const auto get_field = namer_.Method("get", field);
+ auto type_name = GenTypeGet_ObjectAPI(field.value.type, false, true);
if (field.IsScalarOptional())
type_name = ConvertPrimitiveTypeToObjectWrapper_ObjectAPI(type_name);
- auto camel_name = ConvertCase(field.name, Case::kLowerCamel);
- code += " public " + type_name + " " +
- GenGetterFuncName_ObjectAPI(field.name) + "() { return " +
- camel_name + "; }\n\n";
+
+ code += " public " + type_name + " " + get_field + "() { return " +
+ field_name + "; }\n\n";
std::string array_validation = "";
if (field.value.type.base_type == BASE_TYPE_ARRAY) {
array_validation =
- "if (" + camel_name + " != null && " + camel_name +
+ "if (" + field_name + " != null && " + field_name +
".length == " + NumToString(field.value.type.fixed_length) + ") ";
}
- code += " public void " + GenSetterFuncName_ObjectAPI(field.name) + "(" +
- type_name + " " + camel_name + ") { " + array_validation +
- "this." + camel_name + " = " + camel_name + "; }\n\n";
+ code += " public void " + namer_.Method("set", field) + "(" + type_name +
+ " " + field_name + ") { " + array_validation + "this." +
+ field_name + " = " + field_name + "; }\n\n";
}
// Generate Constructor
code += "\n";
code += " public " + class_name + "() {\n";
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
- auto &field = **it;
+ const auto &field = **it;
if (field.deprecated) continue;
if (field.value.type.base_type == BASE_TYPE_UTYPE) continue;
if (field.value.type.element == BASE_TYPE_UTYPE) continue;
- code += " this." + ConvertCase(field.name, Case::kLowerCamel) + " = ";
- auto type_name =
- GenTypeGet_ObjectAPI(field.value.type, opts, false, true);
+ const auto get_field = namer_.Method("get", field);
+
+ code += " this." + namer_.Field(field) + " = ";
+ const auto type_name =
+ GenTypeGet_ObjectAPI(field.value.type, false, true);
if (IsScalar(field.value.type.base_type)) {
if (field.IsScalarOptional()) {
code += "null;\n";
@@ -2122,15 +2117,18 @@
}
code += " }\n";
if (parser_.root_struct_def_ == &struct_def) {
+ const std::string struct_type = namer_.Type(struct_def);
code += " public static " + class_name +
" deserializeFromBinary(byte[] fbBuffer) {\n";
- code += " return " + struct_def.name + ".getRootAs" + struct_def.name +
+ code += " return " + struct_type + "." +
+ namer_.LegacyJavaMethod2("getRootAs", struct_def, "") +
"(ByteBuffer.wrap(fbBuffer)).unpack();\n";
code += " }\n";
code += " public byte[] serializeToBinary() {\n";
code += " FlatBufferBuilder fbb = new FlatBufferBuilder();\n";
- code += " " + struct_def.name + ".finish" + struct_def.name +
- "Buffer(fbb, " + struct_def.name + ".pack(fbb, this));\n";
+ code += " " + struct_type + "." +
+ namer_.LegacyJavaMethod2("finish", struct_def, "Buffer") +
+ "(fbb, " + struct_type + ".pack(fbb, this));\n";
code += " return fbb.sizedByteArray();\n";
code += " }\n";
}
@@ -2140,6 +2138,7 @@
// This tracks the current namespace used to determine if a type need to be
// prefixed by its namespace
const Namespace *cur_name_space_;
+ const IdlNamer namer_;
};
} // namespace java
diff --git a/src/idl_gen_json_schema.cpp b/src/idl_gen_json_schema.cpp
index 9ea37ae..5cb6a9d 100644
--- a/src/idl_gen_json_schema.cpp
+++ b/src/idl_gen_json_schema.cpp
@@ -24,7 +24,10 @@
namespace jsons {
-template<class T> std::string GenFullName(const T *enum_def) {
+namespace {
+
+template<class T>
+static std::string GenFullName(const T *enum_def) {
std::string full_name;
const auto &name_spaces = enum_def->defined_namespace->components;
for (auto ns = name_spaces.cbegin(); ns != name_spaces.cend(); ++ns) {
@@ -34,15 +37,16 @@
return full_name;
}
-template<class T> std::string GenTypeRef(const T *enum_def) {
+template<class T>
+static std::string GenTypeRef(const T *enum_def) {
return "\"$ref\" : \"#/definitions/" + GenFullName(enum_def) + "\"";
}
-std::string GenType(const std::string &name) {
+static std::string GenType(const std::string &name) {
return "\"type\" : \"" + name + "\"";
}
-std::string GenType(BaseType type) {
+static std::string GenType(BaseType type) {
switch (type) {
case BASE_TYPE_BOOL: return "\"type\" : \"boolean\"";
case BASE_TYPE_CHAR:
@@ -84,13 +88,13 @@
}
}
-std::string GenBaseType(const Type &type) {
+static std::string GenBaseType(const Type &type) {
if (type.struct_def != nullptr) { return GenTypeRef(type.struct_def); }
if (type.enum_def != nullptr) { return GenTypeRef(type.enum_def); }
return GenType(type.base_type);
}
-std::string GenArrayType(const Type &type) {
+static std::string GenArrayType(const Type &type) {
std::string element_type;
if (type.struct_def != nullptr) {
element_type = GenTypeRef(type.struct_def);
@@ -103,7 +107,7 @@
return "\"type\" : \"array\", \"items\" : {" + element_type + "}";
}
-std::string GenType(const Type &type) {
+static std::string GenType(const Type &type) {
switch (type.base_type) {
case BASE_TYPE_ARRAY: FLATBUFFERS_FALLTHROUGH(); // fall thru
case BASE_TYPE_VECTOR: {
@@ -136,6 +140,8 @@
}
}
+} // namespace
+
class JsonSchemaGenerator : public BaseGenerator {
private:
std::string code_;
diff --git a/src/idl_gen_kotlin.cpp b/src/idl_gen_kotlin.cpp
index fc55aeb..102e24d 100644
--- a/src/idl_gen_kotlin.cpp
+++ b/src/idl_gen_kotlin.cpp
@@ -23,11 +23,14 @@
#include "flatbuffers/flatbuffers.h"
#include "flatbuffers/idl.h"
#include "flatbuffers/util.h"
+#include "idl_namer.h"
namespace flatbuffers {
namespace kotlin {
+namespace {
+
typedef std::map<std::string, std::pair<std::string, std::string> > FbbParamMap;
static TypedFloatConstantGenerator KotlinFloatGen("Double.", "Float.", "NaN",
"POSITIVE_INFINITY",
@@ -35,42 +38,54 @@
static const CommentConfig comment_config = { "/**", " *", " */" };
static const std::string ident_pad = " ";
-static const char *keywords[] = {
- "package", "as", "typealias", "class", "this", "super",
- "val", "var", "fun", "for", "null", "true",
- "false", "is", "in", "throw", "return", "break",
- "continue", "object", "if", "try", "else", "while",
- "do", "when", "interface", "typeof", "Any", "Character"
-};
-
-// Escape Keywords
-static std::string Esc(const std::string &name) {
- for (size_t i = 0; i < sizeof(keywords) / sizeof(keywords[0]); i++) {
- if (name == keywords[i]) {
- return ConvertCase(name + "_", Case::kLowerCamel);
- }
- }
-
- return ConvertCase(name, Case::kLowerCamel);
+static std::set<std::string> KotlinKeywords() {
+ return { "package", "as", "typealias", "class", "this", "super",
+ "val", "var", "fun", "for", "null", "true",
+ "false", "is", "in", "throw", "return", "break",
+ "continue", "object", "if", "try", "else", "while",
+ "do", "when", "interface", "typeof", "Any", "Character" };
}
+static Namer::Config KotlinDefaultConfig() {
+ return { /*types=*/Case::kKeep,
+ /*constants=*/Case::kKeep,
+ /*methods=*/Case::kLowerCamel,
+ /*functions=*/Case::kKeep,
+ /*fields=*/Case::kLowerCamel,
+ /*variables=*/Case::kLowerCamel,
+ /*variants=*/Case::kLowerCamel,
+ /*enum_variant_seperator=*/"", // I.e. Concatenate.
+ /*escape_keywords=*/Namer::Config::Escape::BeforeConvertingCase,
+ /*namespaces=*/Case::kKeep,
+ /*namespace_seperator=*/"__",
+ /*object_prefix=*/"",
+ /*object_suffix=*/"T",
+ /*keyword_prefix=*/"",
+ /*keyword_suffix=*/"_",
+ /*filenames=*/Case::kKeep,
+ /*directories=*/Case::kKeep,
+ /*output_path=*/"",
+ /*filename_suffix=*/"",
+ /*filename_extension=*/".kt" };
+}
+} // namespace
+
class KotlinGenerator : public BaseGenerator {
public:
KotlinGenerator(const Parser &parser, const std::string &path,
const std::string &file_name)
: BaseGenerator(parser, path, file_name, "", ".", "kt"),
- cur_name_space_(nullptr) {}
+ namer_(WithFlagOptions(KotlinDefaultConfig(), parser.opts, path),
+ KotlinKeywords()) {}
KotlinGenerator &operator=(const KotlinGenerator &);
bool generate() FLATBUFFERS_OVERRIDE {
std::string one_file_code;
- cur_name_space_ = parser_.current_namespace_;
for (auto it = parser_.enums_.vec.begin(); it != parser_.enums_.vec.end();
++it) {
CodeWriter enumWriter(ident_pad);
auto &enum_def = **it;
- if (!parser_.opts.one_file) cur_name_space_ = enum_def.defined_namespace;
GenEnum(enum_def, enumWriter);
if (parser_.opts.one_file) {
one_file_code += enumWriter.ToString();
@@ -85,8 +100,6 @@
it != parser_.structs_.vec.end(); ++it) {
CodeWriter structWriter(ident_pad);
auto &struct_def = **it;
- if (!parser_.opts.one_file)
- cur_name_space_ = struct_def.defined_namespace;
GenStruct(struct_def, structWriter, parser_.opts);
if (parser_.opts.one_file) {
one_file_code += structWriter.ToString();
@@ -124,14 +137,13 @@
code += "import com.google.flatbuffers.*\n\n";
}
code += classcode;
- auto filename = NamespaceDir(ns) + defname + ".kt";
+ const std::string dirs = namer_.Directories(ns);
+ EnsureDirExists(dirs);
+ const std::string filename =
+ dirs + namer_.File(defname, /*skips=*/SkipFile::Suffix);
return SaveFile(filename.c_str(), code, false);
}
- const Namespace *CurrentNameSpace() const FLATBUFFERS_OVERRIDE {
- return cur_name_space_;
- }
-
static bool IsEnum(const Type &type) {
return type.enum_def != nullptr && IsInteger(type.base_type);
}
@@ -261,7 +273,7 @@
GenerateComment(enum_def.doc_comment, writer, &comment_config);
writer += "@Suppress(\"unused\")";
- writer += "class " + Esc(enum_def.name) + " private constructor() {";
+ writer += "class " + namer_.Type(enum_def) + " private constructor() {";
writer.IncrementIdentLevel();
GenerateCompanionObject(writer, [&]() {
@@ -272,7 +284,7 @@
auto field_type = GenTypeBasic(enum_def.underlying_type.base_type);
auto val = enum_def.ToString(ev);
auto suffix = LiteralSuffix(enum_def.underlying_type.base_type);
- writer.SetValue("name", Esc(ev.name));
+ writer.SetValue("name", namer_.LegacyKotlinVariant(ev));
writer.SetValue("type", field_type);
writer.SetValue("val", val + suffix);
GenerateComment(ev.doc_comment, writer, &comment_config);
@@ -339,8 +351,8 @@
case BASE_TYPE_UTYPE: return bb_var_name + ".get";
case BASE_TYPE_BOOL: return "0.toByte() != " + bb_var_name + ".get";
default:
- return bb_var_name + ".get" +
- ConvertCase(GenTypeBasic(type.base_type), Case::kUpperCamel);
+ return bb_var_name + "." +
+ namer_.Method("get", GenTypeBasic(type.base_type));
}
}
@@ -361,8 +373,7 @@
case BASE_TYPE_NONE:
case BASE_TYPE_UTYPE: return "bb.put";
default:
- return "bb.put" +
- ConvertCase(GenTypeBasic(type.base_type), Case::kUpperCamel);
+ return "bb." + namer_.Method("put", GenTypeBasic(type.base_type));
}
}
return "";
@@ -385,8 +396,8 @@
// Recursively generate arguments for a constructor, to deal with nested
// structs.
- static void GenStructArgs(const StructDef &struct_def, CodeWriter &writer,
- const char *nameprefix) {
+ void GenStructArgs(const StructDef &struct_def, CodeWriter &writer,
+ const char *nameprefix) const {
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
auto &field = **it;
@@ -399,7 +410,7 @@
(nameprefix + (field.name + "_")).c_str());
} else {
writer += std::string(", ") + nameprefix + "\\";
- writer += ConvertCase(field.name, Case::kUpperCamel) + ": \\";
+ writer += namer_.Field(field) + ": \\";
writer += GenTypeBasic(field.value.type.base_type) + "\\";
}
}
@@ -408,8 +419,8 @@
// Recusively generate struct construction statements of the form:
// builder.putType(name);
// and insert manual padding.
- static void GenStructBody(const StructDef &struct_def, CodeWriter &writer,
- const char *nameprefix) {
+ void GenStructBody(const StructDef &struct_def, CodeWriter &writer,
+ const char *nameprefix) const {
writer.SetValue("align", NumToString(struct_def.minalign));
writer.SetValue("size", NumToString(struct_def.bytesize));
writer += "builder.prep({{align}}, {{size}})";
@@ -426,8 +437,7 @@
(nameprefix + (field.name + "_")).c_str());
} else {
writer.SetValue("type", GenMethod(field.value.type));
- writer.SetValue("argname", nameprefix + ConvertCase(Esc(field.name),
- Case::kLowerCamel));
+ writer.SetValue("argname", nameprefix + namer_.Variable(field));
writer.SetValue("cast", CastToSigned(field.value.type));
writer += "builder.put{{type}}({{argname}}{{cast}})";
}
@@ -461,7 +471,7 @@
GenerateComment(struct_def.doc_comment, writer, &comment_config);
auto fixed = struct_def.fixed;
- writer.SetValue("struct_name", Esc(struct_def.name));
+ writer.SetValue("struct_name", namer_.Type(struct_def));
writer.SetValue("superclass", fixed ? "Struct" : "Table");
writer += "@Suppress(\"unused\")";
@@ -477,7 +487,7 @@
// Generate assign method
GenerateFun(writer, "__assign", "_i: Int, _bb: ByteBuffer",
- Esc(struct_def.name), [&]() {
+ namer_.Type(struct_def), [&]() {
writer += "__init(_i, _bb)";
writer += "return this";
});
@@ -490,15 +500,15 @@
if (!struct_def.fixed) {
FieldDef *key_field = nullptr;
- // Generate verson check method.
+ // Generate version check method.
// Force compile time error if not using the same version
// runtime.
GenerateFunOneLine(
writer, "validateVersion", "", "",
- [&]() { writer += "Constants.FLATBUFFERS_2_0_0()"; },
+ [&]() { writer += "Constants.FLATBUFFERS_2_0_8()"; },
options.gen_jvmstatic);
- GenerateGetRootAsAccessors(Esc(struct_def.name), writer, options);
+ GenerateGetRootAsAccessors(namer_.Type(struct_def), writer, options);
GenerateBufferHasIdentifier(struct_def, writer, options);
GenerateTableCreator(struct_def, writer, options);
@@ -550,7 +560,7 @@
void GenerateLookupByKey(FieldDef *key_field, StructDef &struct_def,
CodeWriter &writer, const IDLOptions options) const {
std::stringstream params;
- params << "obj: " << Esc(struct_def.name) << "?"
+ params << "obj: " << namer_.Type(struct_def) << "?"
<< ", ";
params << "vectorLocation: Int, ";
params << "key: " << GenTypeGet(key_field->value.type) << ", ";
@@ -558,7 +568,7 @@
auto statements = [&]() {
auto base_type = key_field->value.type.base_type;
- writer.SetValue("struct_name", Esc(struct_def.name));
+ writer.SetValue("struct_name", namer_.Type(struct_def));
if (base_type == BASE_TYPE_STRING) {
writer +=
"val byteKey = key."
@@ -604,7 +614,8 @@
writer += "return null";
};
GenerateFun(writer, "__lookup_by_key", params.str(),
- Esc(struct_def.name) + "?", statements, options.gen_jvmstatic);
+ namer_.Type(struct_def) + "?", statements,
+ options.gen_jvmstatic);
}
void GenerateFinishSizePrefixed(StructDef &struct_def,
@@ -613,7 +624,8 @@
const IDLOptions options) const {
auto id = identifier.length() > 0 ? ", \"" + identifier + "\"" : "";
auto params = "builder: FlatBufferBuilder, offset: Int";
- auto method_name = "finishSizePrefixed" + Esc(struct_def.name) + "Buffer";
+ auto method_name =
+ namer_.LegacyJavaMethod2("finishSizePrefixed", struct_def, "Buffer");
GenerateFunOneLine(
writer, method_name, params, "",
[&]() { writer += "builder.finishSizePrefixed(offset" + id + ")"; },
@@ -625,7 +637,8 @@
const IDLOptions options) const {
auto id = identifier.length() > 0 ? ", \"" + identifier + "\"" : "";
auto params = "builder: FlatBufferBuilder, offset: Int";
- auto method_name = "finish" + Esc(struct_def.name) + "Buffer";
+ auto method_name =
+ namer_.LegacyKotlinMethod("finish", struct_def, "Buffer");
GenerateFunOneLine(
writer, method_name, params, "",
[&]() { writer += "builder.finish(offset" + id + ")"; },
@@ -635,7 +648,7 @@
void GenerateEndStructMethod(StructDef &struct_def, CodeWriter &writer,
const IDLOptions options) const {
// Generate end{{TableName}}(builder: FlatBufferBuilder) method
- auto name = "end" + Esc(struct_def.name);
+ auto name = namer_.LegacyJavaMethod2("end", struct_def, "");
auto params = "builder: FlatBufferBuilder";
auto returns = "Int";
auto field_vec = struct_def.fields.vec;
@@ -661,8 +674,7 @@
void GenerateCreateVectorField(FieldDef &field, CodeWriter &writer,
const IDLOptions options) const {
auto vector_type = field.value.type.VectorType();
- auto method_name =
- "create" + ConvertCase(Esc(field.name), Case::kUpperCamel) + "Vector";
+ auto method_name = namer_.Method("create", field, "vector");
auto params = "builder: FlatBufferBuilder, data: " +
GenTypeBasic(vector_type.base_type) + "Array";
writer.SetValue("size", NumToString(InlineSize(vector_type)));
@@ -694,9 +706,7 @@
writer.SetValue("align", NumToString(InlineAlignment(vector_type)));
GenerateFunOneLine(
- writer,
- "start" + ConvertCase(Esc(field.name) + "Vector", Case::kUpperCamel),
- params, "",
+ writer, namer_.Method("start", field, "Vector"), params, "",
[&]() {
writer += "builder.startVector({{size}}, numElems, {{align}})";
},
@@ -706,25 +716,36 @@
void GenerateAddField(std::string field_pos, FieldDef &field,
CodeWriter &writer, const IDLOptions options) const {
auto field_type = GenTypeBasic(field.value.type.base_type);
- auto secondArg =
- ConvertCase(Esc(field.name), Case::kLowerCamel) + ": " + field_type;
+ auto secondArg = namer_.Variable(field.name) + ": " + field_type;
- GenerateFunOneLine(
- writer, "add" + ConvertCase(Esc(field.name), Case::kUpperCamel),
- "builder: FlatBufferBuilder, " + secondArg, "",
- [&]() {
- auto method = GenMethod(field.value.type);
- writer.SetValue("field_name",
- ConvertCase(Esc(field.name), Case::kLowerCamel));
- writer.SetValue("method_name", method);
- writer.SetValue("pos", field_pos);
- writer.SetValue("default", GenFBBDefaultValue(field));
- writer.SetValue("cast", GenFBBValueCast(field));
-
- writer += "builder.add{{method_name}}({{pos}}, \\";
- writer += "{{field_name}}{{cast}}, {{default}})";
- },
- options.gen_jvmstatic);
+ auto content = [&]() {
+ auto method = GenMethod(field.value.type);
+ writer.SetValue("field_name", namer_.Field(field));
+ writer.SetValue("method_name", method);
+ writer.SetValue("pos", field_pos);
+ writer.SetValue("default", GenFBBDefaultValue(field));
+ writer.SetValue("cast", GenFBBValueCast(field));
+ if (field.key) {
+ // field has key attribute, so always need to exist
+ // even if its value is equal to default.
+ // Generated code will bypass default checking
+ // resulting in { builder.addShort(name); slot(id); }
+ writer += "builder.add{{method_name}}({{field_name}}{{cast}})";
+ writer += "builder.slot({{pos}})";
+ } else {
+ writer += "builder.add{{method_name}}({{pos}}, \\";
+ writer += "{{field_name}}{{cast}}, {{default}})";
+ }
+ };
+ auto signature = namer_.LegacyKotlinMethod("add", field, "");
+ auto params = "builder: FlatBufferBuilder, " + secondArg;
+ if (field.key) {
+ GenerateFun(writer, signature, params, "", content,
+ options.gen_jvmstatic);
+ } else {
+ GenerateFunOneLine(writer, signature, params, "", content,
+ options.gen_jvmstatic);
+ }
}
static std::string ToSignedType(const Type &type) {
@@ -768,7 +789,8 @@
void GenerateStartStructMethod(StructDef &struct_def, CodeWriter &code,
const IDLOptions options) const {
GenerateFunOneLine(
- code, "start" + Esc(struct_def.name), "builder: FlatBufferBuilder", "",
+ code, namer_.LegacyJavaMethod2("start", struct_def, ""),
+ "builder: FlatBufferBuilder", "",
[&]() {
code += "builder.startTable(" +
NumToString(struct_def.fields.vec.size()) + ")";
@@ -800,13 +822,13 @@
// Generate a table constructor of the form:
// public static int createName(FlatBufferBuilder builder, args...)
- auto name = "create" + Esc(struct_def.name);
+ auto name = namer_.LegacyJavaMethod2("create", struct_def, "");
std::stringstream params;
params << "builder: FlatBufferBuilder";
for (auto it = fields_vec.begin(); it != fields_vec.end(); ++it) {
auto &field = **it;
if (field.deprecated) continue;
- params << ", " << ConvertCase(Esc(field.name), Case::kLowerCamel);
+ params << ", " << namer_.Variable(field);
if (!IsScalar(field.value.type.base_type)) {
params << "Offset: ";
} else {
@@ -832,18 +854,15 @@
auto base_type_size = SizeOf(field.value.type.base_type);
if (!field.deprecated &&
(!sortbysize || size == base_type_size)) {
- writer.SetValue(
- "camel_field_name",
- ConvertCase(Esc(field.name), Case::kUpperCamel));
- writer.SetValue("field_name", ConvertCase(Esc(field.name),
- Case::kLowerCamel));
+ writer.SetValue("field_name", namer_.Field(field));
// we wrap on null check for scalar optionals
writer += field.IsScalarOptional()
? "{{field_name}}?.run { \\"
: "\\";
- writer += "add{{camel_field_name}}(builder, {{field_name}}\\";
+ writer += namer_.LegacyKotlinMethod("add", field, "") +
+ "(builder, {{field_name}}\\";
if (!IsScalar(field.value.type.base_type)) {
writer += "Offset\\";
}
@@ -863,7 +882,7 @@
// Check if a buffer has the identifier.
if (parser_.root_struct_def_ != &struct_def || !file_identifier.length())
return;
- auto name = ConvertCase(Esc(struct_def.name), Case::kLowerCamel);
+ auto name = namer_.Function(struct_def);
GenerateFunOneLine(
writer, name + "BufferHasIdentifier", "_bb: ByteBuffer", "Boolean",
[&]() {
@@ -882,7 +901,7 @@
GenerateComment(field.doc_comment, writer, &comment_config);
- auto field_name = ConvertCase(Esc(field.name), Case::kLowerCamel);
+ auto field_name = namer_.Field(field);
auto field_type = GenTypeGet(field.value.type);
auto field_default_value = GenDefaultValue(field);
auto return_type = GetterReturnType(field);
@@ -1053,8 +1072,7 @@
auto &kfield = **kit;
if (kfield.key) {
auto qualified_name = WrapInNameSpace(sd);
- auto name =
- ConvertCase(Esc(field.name), Case::kLowerCamel) + "ByKey";
+ auto name = namer_.Method(field, "ByKey");
auto params = "key: " + GenTypeGet(kfield.value.type);
auto rtype = qualified_name + "?";
GenerateFun(writer, name, params, rtype, [&]() {
@@ -1147,9 +1165,9 @@
auto underlying_type = value_base_type == BASE_TYPE_VECTOR
? value_type.VectorType()
: value_type;
- auto name = "mutate" + ConvertCase(Esc(field.name), Case::kUpperCamel);
+ auto name = namer_.LegacyKotlinMethod("mutate", field, "");
auto size = NumToString(InlineSize(underlying_type));
- auto params = Esc(field.name) + ": " + GenTypeGet(underlying_type);
+ auto params = namer_.Field(field) + ": " + GenTypeGet(underlying_type);
// A vector mutator also needs the index of the vector element it should
// mutate.
if (value_base_type == BASE_TYPE_VECTOR) params.insert(0, "j: Int, ");
@@ -1158,8 +1176,8 @@
// representation.
auto setter_parameter =
underlying_type.base_type == BASE_TYPE_BOOL
- ? "(if(" + Esc(field.name) + ") 1 else 0).toByte()"
- : Esc(field.name);
+ ? "(if(" + namer_.Field(field) + ") 1 else 0).toByte()"
+ : namer_.Field(field);
auto setter_index =
value_base_type == BASE_TYPE_VECTOR
@@ -1292,9 +1310,9 @@
}
}
- static void GenerateGetRootAsAccessors(const std::string &struct_name,
- CodeWriter &writer,
- IDLOptions options) {
+ void GenerateGetRootAsAccessors(const std::string &struct_name,
+ CodeWriter &writer,
+ IDLOptions options) const {
// Generate a special accessor for the table that when used as the root
// ex: fun getRootAsMonster(_bb: ByteBuffer): Monster {...}
writer.SetValue("gr_name", struct_name);
@@ -1320,13 +1338,12 @@
writer += "}";
}
- static void GenerateStaticConstructor(const StructDef &struct_def,
- CodeWriter &code,
- const IDLOptions options) {
+ void GenerateStaticConstructor(const StructDef &struct_def, CodeWriter &code,
+ const IDLOptions options) const {
// create a struct constructor function
auto params = StructConstructorParams(struct_def);
GenerateFun(
- code, "create" + Esc(struct_def.name), params, "Int",
+ code, namer_.LegacyJavaMethod2("create", struct_def, ""), params, "Int",
[&]() {
GenStructBody(struct_def, code, "");
code += "return builder.offset()";
@@ -1334,8 +1351,8 @@
options.gen_jvmstatic);
}
- static std::string StructConstructorParams(const StructDef &struct_def,
- const std::string &prefix = "") {
+ std::string StructConstructorParams(const StructDef &struct_def,
+ const std::string &prefix = "") const {
// builder: FlatBufferBuilder
std::stringstream out;
auto field_vec = struct_def.fields.vec;
@@ -1348,10 +1365,10 @@
// constructing a nested struct, prefix the name with the field
// name.
out << StructConstructorParams(*field.value.type.struct_def,
- prefix + (Esc(field.name) + "_"));
+ prefix + (namer_.Variable(field) + "_"));
} else {
- out << ", " << prefix << ConvertCase(Esc(field.name), Case::kLowerCamel)
- << ": " << GenTypeBasic(field.value.type.base_type);
+ out << ", " << prefix << namer_.Variable(field) << ": "
+ << GenTypeBasic(field.value.type.base_type);
}
}
return out.str();
@@ -1520,9 +1537,7 @@
if (gen_jvmstatic) { code += "@JvmStatic"; }
}
- // This tracks the current namespace used to determine if a type need to be
- // prefixed by its namespace
- const Namespace *cur_name_space_;
+ const IdlNamer namer_;
};
} // namespace kotlin
diff --git a/src/idl_gen_lobster.cpp b/src/idl_gen_lobster.cpp
index c1e78ad..67830f3 100644
--- a/src/idl_gen_lobster.cpp
+++ b/src/idl_gen_lobster.cpp
@@ -72,9 +72,11 @@
std::string LobsterType(const Type &type) {
if (IsFloat(type.base_type)) return "float";
+ if (IsBool(type.base_type)) return "bool";
if (IsScalar(type.base_type) && type.enum_def)
return NormalizedName(*type.enum_def);
if (!IsScalar(type.base_type)) return "flatbuffers_offset";
+ if (IsString(type)) return "string";
return "int";
}
@@ -116,21 +118,27 @@
auto defval = field.IsOptional() ? "0" : field.value.constant;
acc = "buf_.flatbuffers_field_" + GenTypeName(field.value.type) +
"(pos_, " + offsets + ", " + defval + ")";
+ if (IsBool(field.value.type.base_type))
+ acc = "bool(" + acc + ")";
}
if (field.value.type.enum_def)
acc = NormalizedName(*field.value.type.enum_def) + "(" + acc + ")";
- if (field.IsOptional())
+ if (field.IsOptional()) {
acc += ", buf_.flatbuffers_field_present(pos_, " + offsets + ")";
- code += def + "():\n return " + acc + "\n";
+ code += def + "() -> " + LobsterType(field.value.type) + ", bool:\n return " + acc + "\n";
+ } else {
+ code += def + "() -> " + LobsterType(field.value.type) + ":\n return " + acc + "\n";
+ }
return;
}
switch (field.value.type.base_type) {
case BASE_TYPE_STRUCT: {
auto name = NamespacedName(*field.value.type.struct_def);
- code += def + "():\n ";
if (struct_def.fixed) {
+ code += def + "() -> " + name + ":\n ";
code += "return " + name + "{ buf_, pos_ + " + offsets + " }\n";
} else {
+ code += def + "() -> " + name + "?:\n ";
code += std::string("let o = buf_.flatbuffers_field_") +
(field.value.type.struct_def->fixed ? "struct" : "table") +
"(pos_, " + offsets + ")\n return if o: " + name +
@@ -140,25 +148,28 @@
}
case BASE_TYPE_STRING:
code += def +
- "():\n return buf_.flatbuffers_field_string(pos_, " +
+ "() -> string:\n return buf_.flatbuffers_field_string(pos_, " +
offsets + ")\n";
break;
case BASE_TYPE_VECTOR: {
auto vectortype = field.value.type.VectorType();
- code += def + "(i:int):\n return ";
if (vectortype.base_type == BASE_TYPE_STRUCT) {
auto start = "buf_.flatbuffers_field_vector(pos_, " + offsets +
") + i * " + NumToString(InlineSize(vectortype));
if (!(vectortype.struct_def->fixed)) {
start = "buf_.flatbuffers_indirect(" + start + ")";
}
+ code += def + "(i:int) -> " + NamespacedName(*field.value.type.struct_def) + ":\n return ";
code += NamespacedName(*field.value.type.struct_def) + " { buf_, " +
start + " }\n";
} else {
- if (IsString(vectortype))
+ if (IsString(vectortype)) {
+ code += def + "(i:int) -> string:\n return ";
code += "buf_.flatbuffers_string";
- else
+ } else {
+ code += def + "(i:int) -> " + LobsterType(vectortype) + ":\n return ";
code += "buf_.read_" + GenTypeName(vectortype) + "_le";
+ }
code += "(buf_.flatbuffers_field_vector(pos_, " + offsets +
") + i * " + NumToString(InlineSize(vectortype)) + ")\n";
}
@@ -181,7 +192,7 @@
}
if (IsVector(field.value.type)) {
code += def +
- "_length():\n return "
+ "_length() -> int:\n return "
"buf_.flatbuffers_field_vector_len(pos_, " +
offsets + ")\n";
}
diff --git a/src/idl_gen_python.cpp b/src/idl_gen_python.cpp
index 8426b6e..0b8ffa8 100644
--- a/src/idl_gen_python.cpp
+++ b/src/idl_gen_python.cpp
@@ -26,12 +26,14 @@
#include "flatbuffers/flatbuffers.h"
#include "flatbuffers/idl.h"
#include "flatbuffers/util.h"
-#include "namer.h"
+#include "idl_namer.h"
namespace flatbuffers {
namespace python {
-std::set<std::string> PythonKeywords() {
+namespace {
+
+static std::set<std::string> PythonKeywords() {
return { "False", "None", "True", "and", "as", "assert",
"break", "class", "continue", "def", "del", "elif",
"else", "except", "finally", "for", "from", "global",
@@ -40,7 +42,7 @@
"while", "with", "yield" };
}
-Namer::Config PythonDefaultConfig() {
+static Namer::Config PythonDefaultConfig() {
return { /*types=*/Case::kKeep,
/*constants=*/Case::kScreamingSnake,
/*methods=*/Case::kUpperCamel,
@@ -49,6 +51,7 @@
/*variable=*/Case::kLowerCamel,
/*variants=*/Case::kKeep,
/*enum_variant_seperator=*/".",
+ /*escape_keywords=*/Namer::Config::Escape::BeforeConvertingCase,
/*namespaces=*/Case::kKeep, // Packages in python.
/*namespace_seperator=*/".",
/*object_prefix=*/"",
@@ -63,8 +66,10 @@
}
// Hardcode spaces per indentation.
-const CommentConfig def_comment = { nullptr, "#", nullptr };
-const std::string Indent = " ";
+static const CommentConfig def_comment = { nullptr, "#", nullptr };
+static const std::string Indent = " ";
+
+} // namespace
class PythonGenerator : public BaseGenerator {
public:
@@ -73,8 +78,8 @@
: BaseGenerator(parser, path, file_name, "" /* not used */,
"" /* not used */, "py"),
float_const_gen_("float('nan')", "float('inf')", "float('-inf')"),
- namer_({ PythonDefaultConfig().WithFlagOptions(parser.opts, path),
- PythonKeywords() }) {}
+ namer_(WithFlagOptions(PythonDefaultConfig(), parser.opts, path),
+ PythonKeywords()) {}
// Most field accessors need to retrieve and test the field offset first,
// this is the prefix code for that.
@@ -88,7 +93,7 @@
// Begin a class declaration.
void BeginClass(const StructDef &struct_def, std::string *code_ptr) const {
auto &code = *code_ptr;
- code += "class " + namer_.Type(struct_def.name) + "(object):\n";
+ code += "class " + namer_.Type(struct_def) + "(object):\n";
code += Indent + "__slots__ = ['_tab']";
code += "\n\n";
}
@@ -96,7 +101,7 @@
// Begin enum code with a class declaration.
void BeginEnum(const EnumDef &enum_def, std::string *code_ptr) const {
auto &code = *code_ptr;
- code += "class " + namer_.Type(enum_def.name) + "(object):\n";
+ code += "class " + namer_.Type(enum_def) + "(object):\n";
}
// Starts a new line and then indents.
@@ -109,7 +114,7 @@
std::string *code_ptr) const {
auto &code = *code_ptr;
code += Indent;
- code += namer_.Variant(ev.name);
+ code += namer_.Variant(ev);
code += " = ";
code += enum_def.ToString(ev) + "\n";
}
@@ -118,7 +123,7 @@
void NewRootTypeFromBuffer(const StructDef &struct_def,
std::string *code_ptr) const {
auto &code = *code_ptr;
- const std::string struct_type = namer_.Type(struct_def.name);
+ const std::string struct_type = namer_.Type(struct_def);
code += Indent + "@classmethod\n";
code += Indent + "def GetRootAs";
@@ -158,7 +163,7 @@
auto &code = *code_ptr;
GenReceiver(struct_def, code_ptr);
- code += namer_.Method(field.name) + "Length(self";
+ code += namer_.Method(field) + "Length(self";
code += "):" + OffsetPrefix(field);
code += Indent + Indent + Indent + "return self._tab.VectorLen(o)\n";
code += Indent + Indent + "return 0\n\n";
@@ -170,7 +175,7 @@
auto &code = *code_ptr;
GenReceiver(struct_def, code_ptr);
- code += namer_.Method(field.name) + "IsNone(self";
+ code += namer_.Method(field) + "IsNone(self";
code += "):";
code += GenIndents(2) +
"o = flatbuffers.number_types.UOffsetTFlags.py_type" +
@@ -186,7 +191,7 @@
auto &code = *code_ptr;
std::string getter = GenGetter(field.value.type);
GenReceiver(struct_def, code_ptr);
- code += namer_.Method(field.name);
+ code += namer_.Method(field);
code += "(self): return " + getter;
code += "self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(";
code += NumToString(field.value.offset) + "))\n";
@@ -198,7 +203,7 @@
auto &code = *code_ptr;
std::string getter = GenGetter(field.value.type);
GenReceiver(struct_def, code_ptr);
- code += namer_.Method(field.name);
+ code += namer_.Method(field);
code += "(self):";
code += OffsetPrefix(field);
getter += "o + self._tab.Pos)";
@@ -206,7 +211,9 @@
if (is_bool) { getter = "bool(" + getter + ")"; }
code += Indent + Indent + Indent + "return " + getter + "\n";
std::string default_value;
- if (is_bool) {
+ if (field.IsScalarOptional()) {
+ default_value = "None";
+ } else if (is_bool) {
default_value = field.value.constant == "0" ? "False" : "True";
} else {
default_value = IsFloat(field.value.type.base_type)
@@ -223,7 +230,7 @@
std::string *code_ptr) const {
auto &code = *code_ptr;
GenReceiver(struct_def, code_ptr);
- code += namer_.Method(field.name);
+ code += namer_.Method(field);
code += "(self, obj):\n";
code += Indent + Indent + "obj.Init(self._tab.Bytes, self._tab.Pos + ";
code += NumToString(field.value.offset) + ")";
@@ -236,7 +243,7 @@
auto &code = *code_ptr;
const auto vec_type = field.value.type.VectorType();
GenReceiver(struct_def, code_ptr);
- code += namer_.Method(field.name);
+ code += namer_.Method(field);
if (IsStruct(vec_type)) {
code += "(self, obj, i):\n";
code += Indent + Indent + "obj.Init(self._tab.Bytes, self._tab.Pos + ";
@@ -260,7 +267,7 @@
std::string *code_ptr) const {
auto &code = *code_ptr;
GenReceiver(struct_def, code_ptr);
- code += namer_.Method(field.name);
+ code += namer_.Method(field);
code += "(self):";
code += OffsetPrefix(field);
if (field.value.type.struct_def->fixed) {
@@ -285,7 +292,7 @@
std::string *code_ptr) const {
auto &code = *code_ptr;
GenReceiver(struct_def, code_ptr);
- code += namer_.Method(field.name);
+ code += namer_.Method(field);
code += "(self):";
code += OffsetPrefix(field);
code += Indent + Indent + Indent + "return " + GenGetter(field.value.type);
@@ -298,7 +305,7 @@
std::string *code_ptr) const {
auto &code = *code_ptr;
GenReceiver(struct_def, code_ptr);
- code += namer_.Method(field.name) + "(self):";
+ code += namer_.Method(field) + "(self):";
code += OffsetPrefix(field);
// TODO(rw): this works and is not the good way to it:
@@ -321,21 +328,13 @@
// module.
std::string GenPackageReference(const Type &type) const {
if (type.struct_def) {
- return GenPackageReference(*type.struct_def);
+ return namer_.NamespacedType(*type.struct_def);
} else if (type.enum_def) {
- return GenPackageReference(*type.enum_def);
+ return namer_.NamespacedType(*type.enum_def);
} else {
return "." + GenTypeGet(type);
}
}
- std::string GenPackageReference(const EnumDef &enum_def) const {
- return namer_.NamespacedType(enum_def.defined_namespace->components,
- enum_def.name);
- }
- std::string GenPackageReference(const StructDef &struct_def) const {
- return namer_.NamespacedType(struct_def.defined_namespace->components,
- struct_def.name);
- }
// Get the value of a vector's struct member.
void GetMemberOfVectorOfStruct(const StructDef &struct_def,
@@ -345,7 +344,7 @@
auto vectortype = field.value.type.VectorType();
GenReceiver(struct_def, code_ptr);
- code += namer_.Method(field.name);
+ code += namer_.Method(field);
code += "(self, j):" + OffsetPrefix(field);
code += Indent + Indent + Indent + "x = self._tab.Vector(o)\n";
code += Indent + Indent + Indent;
@@ -374,7 +373,7 @@
auto vectortype = field.value.type.VectorType();
GenReceiver(struct_def, code_ptr);
- code += namer_.Method(field.name);
+ code += namer_.Method(field);
code += "(self, j):";
code += OffsetPrefix(field);
code += Indent + Indent + Indent + "a = self._tab.Vector(o)\n";
@@ -403,7 +402,7 @@
if (!(IsScalar(vectortype.base_type))) { return; }
GenReceiver(struct_def, code_ptr);
- code += namer_.Method(field.name) + "AsNumpy(self):";
+ code += namer_.Method(field) + "AsNumpy(self):";
code += OffsetPrefix(field);
code += Indent + Indent + Indent;
@@ -421,7 +420,7 @@
}
std::string NestedFlatbufferType(std::string unqualified_name) const {
- StructDef* nested_root = parser_.LookupStruct(unqualified_name);
+ StructDef *nested_root = parser_.LookupStruct(unqualified_name);
std::string qualified_name;
if (nested_root == nullptr) {
qualified_name = namer_.NamespacedType(
@@ -445,7 +444,7 @@
auto &code = *code_ptr;
GenReceiver(struct_def, code_ptr);
- code += namer_.Method(field.name) + "NestedRoot(self):";
+ code += namer_.Method(field) + "NestedRoot(self):";
code += OffsetPrefix(field);
@@ -464,7 +463,7 @@
auto &code = *code_ptr;
code += "\n";
- code += "def Create" + namer_.Type(struct_def.name);
+ code += "def Create" + namer_.Type(struct_def);
code += "(builder";
}
@@ -487,14 +486,14 @@
// a nested struct, prefix the name with the field name.
auto subprefix = nameprefix;
if (has_field_name) {
- subprefix += namer_.Field(field.name) + fieldname_suffix;
+ subprefix += namer_.Field(field) + fieldname_suffix;
}
StructBuilderArgs(*field.value.type.struct_def, subprefix, namesuffix,
has_field_name, fieldname_suffix, code_ptr);
} else {
auto &code = *code_ptr;
code += std::string(", ") + nameprefix;
- if (has_field_name) { code += namer_.Field(field.name); }
+ if (has_field_name) { code += namer_.Field(field); }
code += namesuffix;
}
}
@@ -526,10 +525,9 @@
code +=
indent + " builder.Pad(" + NumToString(field.padding) + ")\n";
if (IsStruct(field_type)) {
- StructBuilderBody(
- *field_type.struct_def,
- (nameprefix + (namer_.Field(field.name) + "_")).c_str(), code_ptr,
- index, in_array);
+ StructBuilderBody(*field_type.struct_def,
+ (nameprefix + (namer_.Field(field) + "_")).c_str(),
+ code_ptr, index, in_array);
} else {
const auto index_var = "_idx" + NumToString(index);
if (IsArray(field_type)) {
@@ -539,14 +537,13 @@
in_array = true;
}
if (IsStruct(type)) {
- StructBuilderBody(
- *field_type.struct_def,
- (nameprefix + (namer_.Field(field.name) + "_")).c_str(), code_ptr,
- index + 1, in_array);
+ StructBuilderBody(*field_type.struct_def,
+ (nameprefix + (namer_.Field(field) + "_")).c_str(),
+ code_ptr, index + 1, in_array);
} else {
code += IsArray(field_type) ? " " : "";
code += indent + " builder.Prepend" + GenMethod(field) + "(";
- code += nameprefix + namer_.Variable(field.name);
+ code += nameprefix + namer_.Variable(field);
size_t array_cnt = index + (IsArray(field_type) ? 1 : 0);
for (size_t i = 0; in_array && i < array_cnt; i++) {
code += "[_idx" + NumToString(i) + "-1]";
@@ -566,7 +563,7 @@
void GetStartOfTable(const StructDef &struct_def,
std::string *code_ptr) const {
auto &code = *code_ptr;
- const auto struct_type = namer_.Type(struct_def.name);
+ const auto struct_type = namer_.Type(struct_def);
// Generate method with struct name.
code += "def " + struct_type + "Start(builder): ";
code += "builder.StartObject(";
@@ -584,11 +581,11 @@
void BuildFieldOfTable(const StructDef &struct_def, const FieldDef &field,
const size_t offset, std::string *code_ptr) const {
auto &code = *code_ptr;
- const std::string field_var = namer_.Variable(field.name);
- const std::string field_method = namer_.Method(field.name);
+ const std::string field_var = namer_.Variable(field);
+ const std::string field_method = namer_.Method(field);
// Generate method with struct name.
- code += "def " + namer_.Type(struct_def.name) + "Add" + field_method;
+ code += "def " + namer_.Type(struct_def) + "Add" + field_method;
code += "(builder, ";
code += field_var;
code += "): ";
@@ -602,16 +599,20 @@
code += field_var;
}
code += ", ";
- code += IsFloat(field.value.type.base_type)
- ? float_const_gen_.GenFloatConstant(field)
- : field.value.constant;
+ if (field.IsScalarOptional()) {
+ code += "None";
+ } else if (IsFloat(field.value.type.base_type)) {
+ code += float_const_gen_.GenFloatConstant(field);
+ } else {
+ code += field.value.constant;
+ }
code += ")\n";
if (!parser_.opts.one_file) {
// Generate method without struct name.
code += "def Add" + field_method + "(builder, " + field_var + "):\n";
- code += Indent + "return " + namer_.Type(struct_def.name) + "Add" +
- field_method;
+ code +=
+ Indent + "return " + namer_.Type(struct_def) + "Add" + field_method;
code += "(builder, ";
code += field_var;
code += ")\n";
@@ -622,8 +623,8 @@
void BuildVectorOfTable(const StructDef &struct_def, const FieldDef &field,
std::string *code_ptr) const {
auto &code = *code_ptr;
- const std::string struct_type = namer_.Type(struct_def.name);
- const std::string field_method = namer_.Method(field.name);
+ const std::string struct_type = namer_.Type(struct_def);
+ const std::string field_method = namer_.Method(field);
// Generate method with struct name.
code += "def " + struct_type + "Start" + field_method;
@@ -653,8 +654,8 @@
if (!nested) { return; } // There is no nested flatbuffer.
auto &code = *code_ptr;
- const std::string field_method = namer_.Method(field.name);
- const std::string struct_type = namer_.Type(struct_def.name);
+ const std::string field_method = namer_.Method(field);
+ const std::string struct_type = namer_.Type(struct_def);
// Generate method with struct and field name.
code += "def " + struct_type + "Make" + field_method;
@@ -685,22 +686,21 @@
auto &code = *code_ptr;
// Generate method with struct name.
- code += "def " + namer_.Type(struct_def.name) + "End";
+ code += "def " + namer_.Type(struct_def) + "End";
code += "(builder): ";
code += "return builder.EndObject()\n";
if (!parser_.opts.one_file) {
// Generate method without struct name.
code += "def End(builder):\n";
- code +=
- Indent + "return " + namer_.Type(struct_def.name) + "End(builder)";
+ code += Indent + "return " + namer_.Type(struct_def) + "End(builder)";
}
}
// Generate the receiver for function signatures.
void GenReceiver(const StructDef &struct_def, std::string *code_ptr) const {
auto &code = *code_ptr;
- code += Indent + "# " + namer_.Type(struct_def.name) + "\n";
+ code += Indent + "# " + namer_.Type(struct_def) + "\n";
code += Indent + "def ";
}
@@ -795,7 +795,7 @@
}
code += Indent + "@classmethod\n";
- code += Indent + "def " + namer_.Type(struct_def.name);
+ code += Indent + "def " + namer_.Type(struct_def);
code += "BufferHasIdentifier(cls, buf, offset, size_prefixed=False):";
code += "\n";
code += Indent + Indent;
@@ -846,7 +846,7 @@
void GenReceiverForObjectAPI(const StructDef &struct_def,
std::string *code_ptr) const {
auto &code = *code_ptr;
- code += GenIndents(1) + "# " + namer_.ObjectType(struct_def.name);
+ code += GenIndents(1) + "# " + namer_.ObjectType(struct_def);
code += GenIndents(1) + "def ";
}
@@ -854,7 +854,7 @@
std::string *code_ptr) const {
auto &code = *code_ptr;
code += "\n";
- code += "class " + namer_.ObjectType(struct_def.name) + "(object):";
+ code += "class " + namer_.ObjectType(struct_def) + "(object):";
code += "\n";
}
@@ -878,7 +878,9 @@
std::string GetDefaultValue(const FieldDef &field) const {
BaseType base_type = field.value.type.base_type;
- if (IsBool(base_type)) {
+ if (field.IsScalarOptional()) {
+ return "None";
+ } else if (IsBool(base_type)) {
return field.value.constant == "0" ? "False" : "True";
} else if (IsFloat(base_type)) {
return float_const_gen_.GenFloatConstant(field);
@@ -907,7 +909,7 @@
std::string field_type;
switch (ev.union_type.base_type) {
case BASE_TYPE_STRUCT:
- field_type = namer_.ObjectType(ev.union_type.struct_def->name);
+ field_type = namer_.ObjectType(*ev.union_type.struct_def);
if (parser_.opts.include_dependence_headers) {
auto package_reference = GenPackageReference(ev.union_type);
field_type = package_reference + "." + field_type;
@@ -927,8 +929,7 @@
// Gets the import lists for the union.
if (parser_.opts.include_dependence_headers) {
- const auto package_reference =
- GenPackageReference(*field.value.type.enum_def);
+ const auto package_reference = GenPackageReference(field.value.type);
import_list->insert("import " + package_reference);
}
}
@@ -939,7 +940,7 @@
import_typing_list->insert("Optional");
auto &output = *out_ptr;
const Type &type = field.value.type;
- const std::string object_type = namer_.ObjectType(type.struct_def->name);
+ const std::string object_type = namer_.ObjectType(*type.struct_def);
if (parser_.opts.include_dependence_headers) {
auto package_reference = GenPackageReference(type);
output = package_reference + "." + object_type + "]";
@@ -959,7 +960,7 @@
const BaseType base_type = vector_type.base_type;
if (base_type == BASE_TYPE_STRUCT) {
const std::string object_type =
- namer_.ObjectType(GenTypeGet(vector_type));
+ namer_.ObjectType(*vector_type.struct_def);
field_type = object_type + "]";
if (parser_.opts.include_dependence_headers) {
auto package_reference = GenPackageReference(vector_type);
@@ -1002,12 +1003,15 @@
default:
// Scalar or sting fields.
field_type = GetBasePythonTypeForScalarAndString(base_type);
+ if (field.IsScalarOptional()) {
+ field_type = "Optional[" + field_type + "]";
+ }
break;
}
const auto default_value = GetDefaultValue(field);
// Wrties the init statement.
- const auto field_field = namer_.Field(field.name);
+ const auto field_field = namer_.Field(field);
code += GenIndents(2) + "self." + field_field + " = " + default_value +
" # type: " + field_type;
}
@@ -1045,15 +1049,15 @@
}
// Removes the import of the struct itself, if applied.
- auto struct_import = "import " + GenPackageReference(struct_def);
+ auto struct_import = "import " + namer_.NamespacedType(struct_def);
import_list->erase(struct_import);
}
void InitializeFromBuf(const StructDef &struct_def,
std::string *code_ptr) const {
auto &code = *code_ptr;
- const auto struct_var = namer_.Variable(struct_def.name);
- const auto struct_type = namer_.Type(struct_def.name);
+ const auto struct_var = namer_.Variable(struct_def);
+ const auto struct_type = namer_.Type(struct_def);
code += GenIndents(1) + "@classmethod";
code += GenIndents(1) + "def InitFromBuf(cls, buf, pos):";
@@ -1066,8 +1070,8 @@
void InitializeFromObjForObject(const StructDef &struct_def,
std::string *code_ptr) const {
auto &code = *code_ptr;
- const auto struct_var = namer_.Variable(struct_def.name);
- const auto struct_object = namer_.ObjectType(struct_def.name);
+ const auto struct_var = namer_.Variable(struct_def);
+ const auto struct_object = namer_.ObjectType(struct_def);
code += GenIndents(1) + "@classmethod";
code += GenIndents(1) + "def InitFromObj(cls, " + struct_var + "):";
@@ -1080,9 +1084,9 @@
void GenUnPackForStruct(const StructDef &struct_def, const FieldDef &field,
std::string *code_ptr) const {
auto &code = *code_ptr;
- const auto struct_var = namer_.Variable(struct_def.name);
- const auto field_field = namer_.Field(field.name);
- const auto field_method = namer_.Method(field.name);
+ const auto struct_var = namer_.Variable(struct_def);
+ const auto field_field = namer_.Field(field);
+ const auto field_method = namer_.Method(field);
auto field_type = TypeName(field);
if (parser_.opts.include_dependence_headers) {
@@ -1108,14 +1112,14 @@
void GenUnPackForUnion(const StructDef &struct_def, const FieldDef &field,
std::string *code_ptr) const {
auto &code = *code_ptr;
- const auto field_field = namer_.Field(field.name);
- const auto field_method = namer_.Method(field.name);
- const auto struct_var = namer_.Variable(struct_def.name);
+ const auto field_field = namer_.Field(field);
+ const auto field_method = namer_.Method(field);
+ const auto struct_var = namer_.Variable(struct_def);
const EnumDef &enum_def = *field.value.type.enum_def;
- auto union_type = namer_.Namespace(enum_def.name);
+ auto union_type = namer_.Type(enum_def);
if (parser_.opts.include_dependence_headers) {
- union_type = GenPackageReference(enum_def) + "." + union_type;
+ union_type = namer_.NamespacedType(enum_def) + "." + union_type;
}
code += GenIndents(2) + "self." + field_field + " = " + union_type +
"Creator(" + "self." + field_field + "Type, " + struct_var + "." +
@@ -1126,9 +1130,9 @@
const FieldDef &field,
std::string *code_ptr) const {
auto &code = *code_ptr;
- const auto field_field = namer_.Field(field.name);
- const auto field_method = namer_.Method(field.name);
- const auto struct_var = namer_.Variable(struct_def.name);
+ const auto field_field = namer_.Field(field);
+ const auto field_method = namer_.Method(field);
+ const auto struct_var = namer_.Variable(struct_def);
code += GenIndents(2) + "if not " + struct_var + "." + field_method +
"IsNone():";
@@ -1160,9 +1164,9 @@
std::string *code_ptr,
int indents) const {
auto &code = *code_ptr;
- const auto field_field = namer_.Field(field.name);
- const auto field_method = namer_.Method(field.name);
- const auto struct_var = namer_.Variable(struct_def.name);
+ const auto field_field = namer_.Field(field);
+ const auto field_method = namer_.Method(field);
+ const auto struct_var = namer_.Variable(struct_def);
code += GenIndents(indents) + "self." + field_field + " = []";
code += GenIndents(indents) + "for i in range(" + struct_var + "." +
@@ -1175,9 +1179,9 @@
const FieldDef &field,
std::string *code_ptr) const {
auto &code = *code_ptr;
- const auto field_field = namer_.Field(field.name);
- const auto field_method = namer_.Method(field.name);
- const auto struct_var = namer_.Variable(struct_def.name);
+ const auto field_field = namer_.Field(field);
+ const auto field_method = namer_.Method(field);
+ const auto struct_var = namer_.Variable(struct_def);
code += GenIndents(2) + "if not " + struct_var + "." + field_method +
"IsNone():";
@@ -1200,9 +1204,9 @@
void GenUnPackForScalar(const StructDef &struct_def, const FieldDef &field,
std::string *code_ptr) const {
auto &code = *code_ptr;
- const auto field_field = namer_.Field(field.name);
- const auto field_method = namer_.Method(field.name);
- const auto struct_var = namer_.Variable(struct_def.name);
+ const auto field_field = namer_.Field(field);
+ const auto field_method = namer_.Method(field);
+ const auto struct_var = namer_.Variable(struct_def);
code += GenIndents(2) + "self." + field_field + " = " + struct_var + "." +
field_method + "()";
@@ -1248,7 +1252,7 @@
// Writes import statements and code into the generated file.
auto &code_base = *code_ptr;
- const auto struct_var = namer_.Variable(struct_def.name);
+ const auto struct_var = namer_.Variable(struct_def);
GenReceiverForObjectAPI(struct_def, code_ptr);
code_base += "_UnPack(self, " + struct_var + "):";
@@ -1269,7 +1273,7 @@
void GenPackForStruct(const StructDef &struct_def,
std::string *code_ptr) const {
auto &code = *code_ptr;
- const auto struct_fn = namer_.Function(struct_def.name);
+ const auto struct_fn = namer_.Function(struct_def);
GenReceiverForObjectAPI(struct_def, code_ptr);
code += "Pack(self, builder):";
@@ -1289,9 +1293,9 @@
std::string *code_ptr) const {
auto &code_prefix = *code_prefix_ptr;
auto &code = *code_ptr;
- const auto field_field = namer_.Field(field.name);
- const auto struct_type = namer_.Type(struct_def.name);
- const auto field_method = namer_.Method(field.name);
+ const auto field_field = namer_.Field(field);
+ const auto struct_type = namer_.Type(struct_def);
+ const auto field_method = namer_.Method(field);
// Creates the field.
code_prefix += GenIndents(2) + "if self." + field_field + " is not None:";
@@ -1332,9 +1336,9 @@
std::string *code_ptr,
int indents) const {
auto &code = *code_ptr;
- const auto field_field = namer_.Field(field.name);
- const auto field_method = namer_.Method(field.name);
- const auto struct_type = namer_.Type(struct_def.name);
+ const auto field_field = namer_.Field(field);
+ const auto field_method = namer_.Method(field);
+ const auto struct_type = namer_.Type(struct_def);
const auto vectortype = field.value.type.VectorType();
code += GenIndents(indents) + struct_type + "Start" + field_method +
@@ -1368,9 +1372,9 @@
std::string *code_ptr) const {
auto &code = *code_ptr;
auto &code_prefix = *code_prefix_ptr;
- const auto field_field = namer_.Field(field.name);
- const auto field_method = namer_.Method(field.name);
- const auto struct_type = namer_.Type(struct_def.name);
+ const auto field_field = namer_.Field(field);
+ const auto field_method = namer_.Method(field);
+ const auto struct_type = namer_.Type(struct_def);
// Adds the field into the struct.
code += GenIndents(2) + "if self." + field_field + " is not None:";
@@ -1411,9 +1415,9 @@
std::string *code_ptr) const {
auto &code_prefix = *code_prefix_ptr;
auto &code = *code_ptr;
- const auto field_field = namer_.Field(field.name);
- const auto field_method = namer_.Method(field.name);
- const auto struct_type = namer_.Type(struct_def.name);
+ const auto field_field = namer_.Field(field);
+ const auto field_method = namer_.Method(field);
+ const auto struct_type = namer_.Type(struct_def);
if (field.value.type.struct_def->fixed) {
// Pure struct fields need to be created along with their parent
@@ -1438,9 +1442,9 @@
std::string *code_ptr) const {
auto &code_prefix = *code_prefix_ptr;
auto &code = *code_ptr;
- const auto field_field = namer_.Field(field.name);
- const auto field_method = namer_.Method(field.name);
- const auto struct_type = namer_.Type(struct_def.name);
+ const auto field_field = namer_.Field(field);
+ const auto field_method = namer_.Method(field);
+ const auto struct_type = namer_.Type(struct_def);
// TODO(luwa): TypeT should be moved under the None check as well.
code_prefix += GenIndents(2) + "if self." + field_field + " is not None:";
@@ -1455,8 +1459,8 @@
std::string *code_ptr) const {
auto &code_base = *code_ptr;
std::string code, code_prefix;
- const auto struct_var = namer_.Variable(struct_def.name);
- const auto struct_type = namer_.Type(struct_def.name);
+ const auto struct_var = namer_.Variable(struct_def);
+ const auto struct_type = namer_.Type(struct_def);
GenReceiverForObjectAPI(struct_def, code_ptr);
code_base += "Pack(self, builder):";
@@ -1466,8 +1470,8 @@
auto &field = **it;
if (field.deprecated) continue;
- const auto field_method = namer_.Method(field.name);
- const auto field_field = namer_.Field(field.name);
+ const auto field_method = namer_.Method(field);
+ const auto field_field = namer_.Field(field);
switch (field.value.type.base_type) {
case BASE_TYPE_STRUCT: {
@@ -1555,12 +1559,12 @@
void GenUnionCreatorForStruct(const EnumDef &enum_def, const EnumVal &ev,
std::string *code_ptr) const {
auto &code = *code_ptr;
- const auto union_type = namer_.Type(enum_def.name);
- const auto variant = namer_.Variant(ev.name);
- auto field_type = namer_.ObjectType(GenTypeGet(ev.union_type));
+ const auto union_type = namer_.Type(enum_def);
+ const auto variant = namer_.Variant(ev);
+ auto field_type = namer_.ObjectType(*ev.union_type.struct_def);
- code += GenIndents(1) + "if unionType == " + union_type + "()." +
- variant + ":";
+ code +=
+ GenIndents(1) + "if unionType == " + union_type + "()." + variant + ":";
if (parser_.opts.include_dependence_headers) {
auto package_reference = GenPackageReference(ev.union_type);
code += GenIndents(2) + "import " + package_reference;
@@ -1573,11 +1577,11 @@
void GenUnionCreatorForString(const EnumDef &enum_def, const EnumVal &ev,
std::string *code_ptr) const {
auto &code = *code_ptr;
- const auto union_type = namer_.Type(enum_def.name);
- const auto variant = namer_.Variant(ev.name);
+ const auto union_type = namer_.Type(enum_def);
+ const auto variant = namer_.Variant(ev);
- code += GenIndents(1) + "if unionType == " + union_type + "()." +
- variant + ":";
+ code +=
+ GenIndents(1) + "if unionType == " + union_type + "()." + variant + ":";
code += GenIndents(2) + "tab = Table(table.Bytes, table.Pos)";
code += GenIndents(2) + "union = tab.String(table.Pos)";
code += GenIndents(2) + "return union";
@@ -1588,7 +1592,7 @@
if (enum_def.generated) return;
auto &code = *code_ptr;
- const auto enum_fn = namer_.Function(enum_def.name);
+ const auto enum_fn = namer_.Function(enum_def);
code += "\n";
code += "def " + enum_fn + "Creator(unionType, table):";
@@ -1721,7 +1725,7 @@
if (parser_.opts.one_file && !enumcode.empty()) {
*one_file_code += enumcode + "\n\n";
} else {
- if (!SaveType(namer_.File(enum_def.name, SkipFile::Suffix),
+ if (!SaveType(namer_.File(enum_def, SkipFile::Suffix),
*enum_def.defined_namespace, enumcode, false))
return false;
}
@@ -1742,7 +1746,7 @@
if (parser_.opts.one_file && !declcode.empty()) {
*one_file_code += declcode + "\n\n";
} else {
- if (!SaveType(namer_.File(struct_def.name, SkipFile::Suffix),
+ if (!SaveType(namer_.File(struct_def, SkipFile::Suffix),
*struct_def.defined_namespace, declcode, true))
return false;
}
@@ -1789,7 +1793,7 @@
private:
const SimpleFloatConstantGenerator float_const_gen_;
- const Namer namer_;
+ const IdlNamer namer_;
};
} // namespace python
diff --git a/src/idl_gen_rust.cpp b/src/idl_gen_rust.cpp
index 17853a0..a5ce2f7 100644
--- a/src/idl_gen_rust.cpp
+++ b/src/idl_gen_rust.cpp
@@ -20,11 +20,12 @@
#include "flatbuffers/flatbuffers.h"
#include "flatbuffers/idl.h"
#include "flatbuffers/util.h"
-#include "namer.h"
+#include "idl_namer.h"
namespace flatbuffers {
+namespace {
-Namer::Config RustDefaultConfig() {
+static Namer::Config RustDefaultConfig() {
// Historical note: We've been using "keep" casing since the original
// implementation, presumably because Flatbuffers schema style and Rust style
// roughly align. We are not going to enforce proper casing since its an
@@ -37,6 +38,7 @@
/*variables=*/Case::kUnknown, // Unused.
/*variants=*/Case::kKeep,
/*enum_variant_seperator=*/"::",
+ /*escape_keywords=*/Namer::Config::Escape::BeforeConvertingCase,
/*namespaces=*/Case::kSnake,
/*namespace_seperator=*/"::",
/*object_prefix=*/"",
@@ -50,7 +52,7 @@
/*filename_extension=*/".rs" };
}
-std::set<std::string> RustKeywords() {
+static std::set<std::string> RustKeywords() {
return {
// https://doc.rust-lang.org/book/second-edition/appendix-01-keywords.html
"as",
@@ -172,7 +174,7 @@
};
// Convert a Type to a FullType (exhaustive).
-FullType GetFullType(const Type &type) {
+static FullType GetFullType(const Type &type) {
// N.B. The order of these conditionals matters for some types.
if (IsString(type)) {
@@ -262,15 +264,16 @@
return ftBool;
}
-bool IsBitFlagsEnum(const EnumDef &enum_def) {
+static bool IsBitFlagsEnum(const EnumDef &enum_def) {
return enum_def.attributes.Lookup("bit_flags") != nullptr;
}
// TableArgs make required non-scalars "Option<_>".
// TODO(cneo): Rework how we do defaults and stuff.
-bool IsOptionalToBuilder(const FieldDef &field) {
+static bool IsOptionalToBuilder(const FieldDef &field) {
return field.IsOptional() || !IsScalar(field.value.type.base_type);
}
+} // namespace
bool GenerateRustModuleRootFile(const Parser &parser,
const std::string &output_dir) {
@@ -279,7 +282,7 @@
// so return true.
return true;
}
- Namer namer(RustDefaultConfig().WithFlagOptions(parser.opts, output_dir),
+ Namer namer(WithFlagOptions(RustDefaultConfig(), parser.opts, output_dir),
RustKeywords());
// We gather the symbols into a tree of namespaces (which are rust mods) and
// generate a file that gathers them all.
@@ -329,6 +332,7 @@
code +=
"// Automatically generated by the Flatbuffers compiler. "
"Do not modify.";
+ code += "// @generated";
root_module.GenerateImports(code);
const bool success =
SaveFile((output_dir + "mod.rs").c_str(), code.ToString(), false);
@@ -344,8 +348,8 @@
const std::string &file_name)
: BaseGenerator(parser, path, file_name, "", "::", "rs"),
cur_name_space_(nullptr),
- namer_({ RustDefaultConfig().WithFlagOptions(parser.opts, path),
- RustKeywords() }) {
+ namer_(WithFlagOptions(RustDefaultConfig(), parser.opts, path),
+ RustKeywords()) {
// TODO: Namer flag overrides should be in flatc or flatc_main.
code_.SetPadding(" ");
}
@@ -366,9 +370,14 @@
if (symbol.generated) continue;
code_.Clear();
code_ += "// " + std::string(FlatBuffersGeneratedWarning());
+ code_ += "// @generated";
+ code_ += "extern crate alloc;";
code_ += "extern crate flatbuffers;";
- code_ += "use std::mem;";
- code_ += "use std::cmp::Ordering;";
+ code_ += "use alloc::boxed::Box;";
+ code_ += "use alloc::string::{String, ToString};";
+ code_ += "use alloc::vec::Vec;";
+ code_ += "use core::mem;";
+ code_ += "use core::cmp::Ordering;";
if (parser_.opts.rust_serialize) {
code_ += "extern crate serde;";
code_ +=
@@ -380,9 +389,9 @@
gen_symbol(symbol);
const std::string directories =
- namer_.Directories(symbol.defined_namespace->components);
+ namer_.Directories(*symbol.defined_namespace);
EnsureDirExists(directories);
- const std::string file_path = directories + namer_.File(symbol.name);
+ const std::string file_path = directories + namer_.File(symbol);
const bool save_success =
SaveFile(file_path.c_str(), code_.ToString(), /*binary=*/false);
if (!save_success) return false;
@@ -418,6 +427,7 @@
bool GenerateOneFile() {
code_.Clear();
code_ += "// " + std::string(FlatBuffersGeneratedWarning()) + "\n\n";
+ code_ += "// @generated";
assert(!cur_name_space_);
@@ -526,8 +536,11 @@
return false;
}
- std::string NamespacedNativeName(const Definition &def) {
- return WrapInNameSpace(def.defined_namespace, namer_.ObjectType(def.name));
+ std::string NamespacedNativeName(const EnumDef &def) {
+ return WrapInNameSpace(def.defined_namespace, namer_.ObjectType(def));
+ }
+ std::string NamespacedNativeName(const StructDef &def) {
+ return WrapInNameSpace(def.defined_namespace, namer_.ObjectType(def));
}
std::string WrapInNameSpace(const Definition &def) const {
@@ -663,7 +676,7 @@
std::string GetEnumValue(const EnumDef &enum_def,
const EnumVal &enum_val) const {
- return namer_.EnumVariant(enum_def.name, enum_val.name);
+ return namer_.EnumVariant(enum_def, enum_val);
}
// 1 suffix since old C++ can't figure out the overload.
@@ -671,7 +684,7 @@
std::function<void(const EnumVal &)> cb) {
for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end(); ++it) {
const auto &ev = **it;
- code_.SetValue("VARIANT", namer_.Variant(ev.name));
+ code_.SetValue("VARIANT", namer_.Variant(ev));
code_.SetValue("VALUE", enum_def.ToString(ev));
code_.IncrementIdentLevel();
cb(ev);
@@ -690,7 +703,10 @@
// an enum match function,
// and an enum array of values
void GenEnum(const EnumDef &enum_def) {
- code_.SetValue("ENUM_TY", namer_.Type(enum_def.name));
+ const bool is_private = parser_.opts.no_leak_private_annotations &&
+ (enum_def.attributes.Lookup("private") != nullptr);
+ code_.SetValue("ACCESS_TYPE", is_private ? "pub(crate)" : "pub");
+ code_.SetValue("ENUM_TY", namer_.Type(enum_def));
code_.SetValue("BASE_TYPE", GetEnumTypeForDecl(enum_def.underlying_type));
code_.SetValue("ENUM_NAMESPACE", namer_.Namespace(enum_def.name));
code_.SetValue("ENUM_CONSTANT", namer_.Constant(enum_def.name));
@@ -710,7 +726,7 @@
code_ += " flatbuffers::bitflags::bitflags! {";
GenComment(enum_def.doc_comment, " ");
code_ += " #[derive(Default)]";
- code_ += " pub struct {{ENUM_TY}}: {{BASE_TYPE}} {";
+ code_ += " {{ACCESS_TYPE}} struct {{ENUM_TY}}: {{BASE_TYPE}} {";
ForAllEnumValues1(enum_def, [&](const EnumVal &ev) {
this->GenComment(ev.doc_comment, " ");
code_ += " const {{VARIANT}} = {{VALUE}};";
@@ -743,7 +759,7 @@
code_ += "pub const ENUM_VALUES_{{ENUM_CONSTANT}}: [{{ENUM_TY}}; " +
num_fields + "] = [";
ForAllEnumValues1(enum_def, [&](const EnumVal &ev) {
- code_ += namer_.EnumVariant(enum_def.name, ev.name) + ",";
+ code_ += namer_.EnumVariant(enum_def, ev) + ",";
});
code_ += "];";
code_ += "";
@@ -756,7 +772,7 @@
"#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, "
"Default)]";
code_ += "#[repr(transparent)]";
- code_ += "pub struct {{ENUM_TY}}(pub {{BASE_TYPE}});";
+ code_ += "{{ACCESS_TYPE}} struct {{ENUM_TY}}(pub {{BASE_TYPE}});";
code_ += "#[allow(non_upper_case_globals)]";
code_ += "impl {{ENUM_TY}} {";
ForAllEnumValues1(enum_def, [&](const EnumVal &ev) {
@@ -782,10 +798,10 @@
code_ += "}";
// Generate Debug. Unknown variants are printed like "<UNKNOWN 42>".
- code_ += "impl std::fmt::Debug for {{ENUM_TY}} {";
+ code_ += "impl core::fmt::Debug for {{ENUM_TY}} {";
code_ +=
- " fn fmt(&self, f: &mut std::fmt::Formatter) ->"
- " std::fmt::Result {";
+ " fn fmt(&self, f: &mut core::fmt::Formatter) ->"
+ " core::fmt::Result {";
code_ += " if let Some(name) = self.variant_name() {";
code_ += " f.write_str(name)";
code_ += " } else {";
@@ -872,8 +888,8 @@
if (enum_def.is_union) {
// Generate typesafe offset(s) for unions
- code_.SetValue("UNION_TYPE", namer_.Type(enum_def.name));
- code_ += "pub struct {{UNION_TYPE}}UnionTableOffset {}";
+ code_.SetValue("UNION_TYPE", namer_.Type(enum_def));
+ code_ += "{{ACCESS_TYPE}} struct {{UNION_TYPE}}UnionTableOffset {}";
code_ += "";
if (parser_.opts.generate_object_based_api) { GenUnionObject(enum_def); }
}
@@ -885,13 +901,12 @@
for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end(); ++it) {
auto &enum_val = **it;
if (enum_val.union_type.base_type == BASE_TYPE_NONE) continue;
- code_.SetValue("VARIANT_NAME", namer_.Variant(enum_val.name));
+ code_.SetValue("VARIANT_NAME", namer_.Variant(enum_val));
// For legacy reasons, enum variants are Keep case while enum native
// variants are UpperCamel case.
- code_.SetValue(
- "NATIVE_VARIANT",
- ConvertCase(namer_.EscapeKeyword(enum_val.name), Case::kUpperCamel));
- code_.SetValue("U_ELEMENT_NAME", namer_.Method(enum_val.name));
+ code_.SetValue("NATIVE_VARIANT",
+ namer_.LegacyRustNativeVariant(enum_val));
+ code_.SetValue("U_ELEMENT_NAME", namer_.Method(enum_val));
code_.SetValue("U_ELEMENT_TABLE_TYPE",
NamespacedNativeName(*enum_val.union_type.struct_def));
code_.IncrementIdentLevel();
@@ -900,16 +915,16 @@
}
}
void GenUnionObject(const EnumDef &enum_def) {
- code_.SetValue("ENUM_TY", namer_.Type(enum_def.name));
- code_.SetValue("ENUM_FN", namer_.Function(enum_def.name));
- code_.SetValue("ENUM_OTY", namer_.ObjectType(enum_def.name));
+ code_.SetValue("ENUM_TY", namer_.Type(enum_def));
+ code_.SetValue("ENUM_FN", namer_.Function(enum_def));
+ code_.SetValue("ENUM_OTY", namer_.ObjectType(enum_def));
// Generate native union.
code_ += "#[allow(clippy::upper_case_acronyms)]"; // NONE's spelling is
// intended.
code_ += "#[non_exhaustive]";
code_ += "#[derive(Debug, Clone, PartialEq)]";
- code_ += "pub enum {{ENUM_OTY}} {";
+ code_ += "{{ACCESS_TYPE}} enum {{ENUM_OTY}} {";
code_ += " NONE,";
ForAllUnionObjectVariantsBesidesNone(enum_def, [&] {
code_ += "{{NATIVE_VARIANT}}(Box<{{U_ELEMENT_TABLE_TYPE}}>),";
@@ -961,7 +976,7 @@
"pub fn take_{{U_ELEMENT_NAME}}(&mut self) -> "
"Option<Box<{{U_ELEMENT_TABLE_TYPE}}>> {";
code_ += " if let Self::{{NATIVE_VARIANT}}(_) = self {";
- code_ += " let v = std::mem::replace(self, Self::NONE);";
+ code_ += " let v = core::mem::replace(self, Self::NONE);";
code_ += " if let Self::{{NATIVE_VARIANT}}(w) = v {";
code_ += " Some(w)";
code_ += " } else {";
@@ -997,13 +1012,6 @@
code_ += "}"; // End union methods impl.
}
- std::string GetFieldOffsetName(const FieldDef &field) {
- // FIXME: VT_FIELD_NAME is not screaming snake case by legacy mistake.
- // but changing this is probably a breaking change.
- return "VT_" +
- ConvertCase(namer_.EscapeKeyword(field.name), Case::kAllUpper);
- }
-
enum DefaultContext { kBuilder, kAccessor, kObject };
std::string GetDefaultValue(const FieldDef &field,
const DefaultContext context) {
@@ -1033,7 +1041,7 @@
if (!ev) return "Default::default()"; // Bitflags enum.
return WrapInNameSpace(
field.value.type.enum_def->defined_namespace,
- namer_.EnumVariant(field.value.type.enum_def->name, ev->name));
+ namer_.EnumVariant(*field.value.type.enum_def, *ev));
}
case ftUnionValue: {
return ObjectFieldType(field, true) + "::NONE";
@@ -1539,7 +1547,7 @@
std::string GenTableAccessorFuncBody(const FieldDef &field,
const std::string &lifetime) {
- const std::string vt_offset = GetFieldOffsetName(field);
+ const std::string vt_offset = namer_.LegacyRustFieldOffsetName(field);
const std::string typname = FollowType(field.value.type, lifetime);
// Default-y fields (scalars so far) are neither optional nor required.
const std::string default_value =
@@ -1582,9 +1590,9 @@
const EnumVal &ev = **it;
// TODO(cneo): Can variants be deprecated, should we skip them?
if (ev.union_type.base_type == BASE_TYPE_NONE) { continue; }
- code_.SetValue("U_ELEMENT_ENUM_TYPE",
- WrapInNameSpace(def.defined_namespace,
- namer_.EnumVariant(def.name, ev.name)));
+ code_.SetValue(
+ "U_ELEMENT_ENUM_TYPE",
+ WrapInNameSpace(def.defined_namespace, namer_.EnumVariant(def, ev)));
code_.SetValue(
"U_ELEMENT_TABLE_TYPE",
WrapInNameSpace(ev.union_type.struct_def->defined_namespace,
@@ -1601,11 +1609,11 @@
// diff when refactoring to the `ForAllX` helper functions.
auto go = [&](const FieldDef &field) {
if (field.deprecated) return;
- code_.SetValue("OFFSET_NAME", GetFieldOffsetName(field));
+ code_.SetValue("OFFSET_NAME", namer_.LegacyRustFieldOffsetName(field));
code_.SetValue("OFFSET_VALUE", NumToString(field.value.offset));
- code_.SetValue("FIELD", namer_.Field(field.name));
+ code_.SetValue("FIELD", namer_.Field(field));
code_.SetValue("BLDR_DEF_VAL", GetDefaultValue(field, kBuilder));
- code_.SetValue("DISCRIMINANT", namer_.Method(field.name) + "_type");
+ code_.SetValue("DISCRIMINANT", namer_.Field(field) + "_type");
code_.IncrementIdentLevel();
cb(field);
code_.DecrementIdentLevel();
@@ -1620,18 +1628,22 @@
// Generate an accessor struct, builder struct, and create function for a
// table.
void GenTable(const StructDef &struct_def) {
- code_.SetValue("STRUCT_TY", namer_.Type(struct_def.name));
- code_.SetValue("STRUCT_FN", namer_.Function(struct_def.name));
+
+ const bool is_private = parser_.opts.no_leak_private_annotations &&
+ (struct_def.attributes.Lookup("private") != nullptr);
+ code_.SetValue("ACCESS_TYPE", is_private ? "pub(crate)" : "pub");
+ code_.SetValue("STRUCT_TY", namer_.Type(struct_def));
+ code_.SetValue("STRUCT_FN", namer_.Function(struct_def));
// Generate an offset type, the base type, the Follow impl, and the
// init_from_table impl.
- code_ += "pub enum {{STRUCT_TY}}Offset {}";
+ code_ += "{{ACCESS_TYPE}} enum {{STRUCT_TY}}Offset {}";
code_ += "#[derive(Copy, Clone, PartialEq)]";
code_ += "";
GenComment(struct_def.doc_comment);
- code_ += "pub struct {{STRUCT_TY}}<'a> {";
+ code_ += "{{ACCESS_TYPE}} struct {{STRUCT_TY}}<'a> {";
code_ += " pub _tab: flatbuffers::Table<'a>,";
code_ += "}";
code_ += "";
@@ -1702,7 +1714,7 @@
if (parser_.opts.generate_object_based_api) {
// TODO(cneo): Replace more for loops with ForAllX stuff.
// TODO(cneo): Manage indentation with IncrementIdentLevel?
- code_.SetValue("STRUCT_OTY", namer_.ObjectType(struct_def.name));
+ code_.SetValue("STRUCT_OTY", namer_.ObjectType(struct_def));
code_ += " pub fn unpack(&self) -> {{STRUCT_OTY}} {";
ForAllObjectTableFields(struct_def, [&](const FieldDef &field) {
const Type &type = field.value.type;
@@ -1939,7 +1951,7 @@
const EnumDef &union_def = *field.value.type.enum_def;
code_.SetValue("UNION_TYPE", WrapInNameSpace(union_def));
code_.SetValue("UNION_TYPE_OFFSET_NAME",
- GetFieldOffsetName(field) + "_TYPE");
+ namer_.LegacyRustFieldOffsetName(field) + "_TYPE");
code_ +=
"\n .visit_union::<{{UNION_TYPE}}, _>("
"\"{{FIELD}}_type\", Self::{{UNION_TYPE_OFFSET_NAME}}, "
@@ -1965,7 +1977,7 @@
// Generate an args struct:
code_.SetValue("MAYBE_LT",
TableBuilderArgsNeedsLifetime(struct_def) ? "<'a>" : "");
- code_ += "pub struct {{STRUCT_TY}}Args{{MAYBE_LT}} {";
+ code_ += "{{ACCESS_TYPE}} struct {{STRUCT_TY}}Args{{MAYBE_LT}} {";
ForAllTableFields(struct_def, [&](const FieldDef &field) {
code_.SetValue("PARAM_TYPE", TableBuilderArgsDefnType(field, "'a"));
code_ += " pub {{FIELD}}: {{PARAM_TYPE}},";
@@ -2010,12 +2022,12 @@
if (type.base_type == BASE_TYPE_UNION) {
const auto &enum_def = *type.enum_def;
code_.SetValue("ENUM_TY", WrapInNameSpace(enum_def));
- code_.SetValue("FIELD", namer_.Field(field.name));
+ code_.SetValue("FIELD", namer_.Field(field));
code_ += " match self.{{FIELD}}_type() {";
code_ += " {{ENUM_TY}}::NONE => (),";
ForAllUnionObjectVariantsBesidesNone(enum_def, [&] {
- code_.SetValue("FIELD", namer_.Field(field.name));
+ code_.SetValue("FIELD", namer_.Field(field));
code_ += " {{ENUM_TY}}::{{VARIANT_NAME}} => {";
code_ +=
" let f = "
@@ -2054,7 +2066,7 @@
}
// Generate a builder struct:
- code_ += "pub struct {{STRUCT_TY}}Builder<'a: 'b, 'b> {";
+ code_ += "{{ACCESS_TYPE}} struct {{STRUCT_TY}}Builder<'a: 'b, 'b> {";
code_ += " fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,";
code_ +=
" start_: flatbuffers::WIPOffset<"
@@ -2065,7 +2077,7 @@
code_ += "impl<'a: 'b, 'b> {{STRUCT_TY}}Builder<'a, 'b> {";
ForAllTableFields(struct_def, [&](const FieldDef &field) {
const bool is_scalar = IsScalar(field.value.type.base_type);
- std::string offset = GetFieldOffsetName(field);
+ std::string offset = namer_.LegacyRustFieldOffsetName(field);
// Generate functions to add data, which take one of two forms.
//
// If a value has a default:
@@ -2077,8 +2089,7 @@
// fn add_x(x_: type) {
// fbb_.push_slot_always::<type>(offset, x_);
// }
- code_.SetValue("FIELD_OFFSET",
- namer_.Type(struct_def.name) + "::" + offset);
+ code_.SetValue("FIELD_OFFSET", namer_.Type(struct_def) + "::" + offset);
code_.SetValue("FIELD_TYPE", TableBuilderArgsAddFuncType(field, "'b "));
code_.SetValue("FUNC_BODY", TableBuilderArgsAddFuncBody(field));
code_ += "#[inline]";
@@ -2126,10 +2137,10 @@
code_ += "}";
code_ += "";
- code_ += "impl std::fmt::Debug for {{STRUCT_TY}}<'_> {";
+ code_ += "impl core::fmt::Debug for {{STRUCT_TY}}<'_> {";
code_ +=
- " fn fmt(&self, f: &mut std::fmt::Formatter<'_>"
- ") -> std::fmt::Result {";
+ " fn fmt(&self, f: &mut core::fmt::Formatter<'_>"
+ ") -> core::fmt::Result {";
code_ += " let mut ds = f.debug_struct(\"{{STRUCT_TY}}\");";
ForAllTableFields(struct_def, [&](const FieldDef &field) {
if (GetFullType(field.value.type) == ftUnionValue) {
@@ -2170,13 +2181,13 @@
}
void GenTableObject(const StructDef &table) {
- code_.SetValue("STRUCT_OTY", namer_.ObjectType(table.name));
- code_.SetValue("STRUCT_TY", namer_.Type(table.name));
+ code_.SetValue("STRUCT_OTY", namer_.ObjectType(table));
+ code_.SetValue("STRUCT_TY", namer_.Type(table));
// Generate the native object.
code_ += "#[non_exhaustive]";
code_ += "#[derive(Debug, Clone, PartialEq)]";
- code_ += "pub struct {{STRUCT_OTY}} {";
+ code_ += "{{ACCESS_TYPE}} struct {{STRUCT_OTY}} {";
ForAllObjectTableFields(table, [&](const FieldDef &field) {
// Union objects combine both the union discriminant and value, so we
// skip making a field for the discriminant.
@@ -2221,7 +2232,7 @@
case ftUnionKey: return; // Generate union type with union value.
case ftUnionValue: {
code_.SetValue("ENUM_METHOD",
- namer_.Method(field.value.type.enum_def->name));
+ namer_.Method(*field.value.type.enum_def));
code_ +=
" let {{FIELD}}_type = "
"self.{{FIELD}}.{{ENUM_METHOD}}_type();";
@@ -2309,7 +2320,7 @@
for (auto it = v.begin(); it != v.end(); it++) {
const FieldDef &field = **it;
if (field.deprecated) continue;
- code_.SetValue("FIELD", namer_.Field(field.name));
+ code_.SetValue("FIELD", namer_.Field(field));
code_.SetValue("FIELD_OTY", ObjectFieldType(field, true));
code_.IncrementIdentLevel();
cb(field);
@@ -2349,7 +2360,7 @@
code_ += "#[inline]";
code_ +=
"pub fn key_compare_with_value(&self, val: {{KEY_TYPE}}) -> "
- "::std::cmp::Ordering {";
+ "::core::cmp::Ordering {";
code_ += " let key = self.{{FIELD}}();";
code_ += " key.cmp({{REF}}val)";
code_ += "}";
@@ -2359,8 +2370,8 @@
// must only be called if the root table is defined.
void GenRootTableFuncs(const StructDef &struct_def) {
FLATBUFFERS_ASSERT(parser_.root_struct_def_ && "root table not defined");
- code_.SetValue("STRUCT_TY", namer_.Type(struct_def.name));
- code_.SetValue("STRUCT_FN", namer_.Function(struct_def.name));
+ code_.SetValue("STRUCT_TY", namer_.Type(struct_def));
+ code_.SetValue("STRUCT_FN", namer_.Function(struct_def));
code_.SetValue("STRUCT_CONST", namer_.Constant(struct_def.name));
// The root datatype accessors:
@@ -2570,7 +2581,7 @@
const auto &field = **it;
code_.SetValue("FIELD_TYPE", GetTypeGet(field.value.type));
code_.SetValue("FIELD_OTY", ObjectFieldType(field, false));
- code_.SetValue("FIELD", namer_.Field(field.name));
+ code_.SetValue("FIELD", namer_.Field(field));
code_.SetValue("FIELD_OFFSET", NumToString(offset_to_field));
code_.SetValue(
"REF",
@@ -2584,12 +2595,15 @@
}
// Generate an accessor struct with constructor for a flatbuffers struct.
void GenStruct(const StructDef &struct_def) {
+ const bool is_private = parser_.opts.no_leak_private_annotations &&
+ (struct_def.attributes.Lookup("private") != nullptr);
+ code_.SetValue("ACCESS_TYPE", is_private ? "pub(crate)" : "pub");
// Generates manual padding and alignment.
// Variables are private because they contain little endian data on all
// platforms.
GenComment(struct_def.doc_comment);
code_.SetValue("ALIGN", NumToString(struct_def.minalign));
- code_.SetValue("STRUCT_TY", namer_.Type(struct_def.name));
+ code_.SetValue("STRUCT_TY", namer_.Type(struct_def));
code_.SetValue("STRUCT_SIZE", NumToString(struct_def.bytesize));
// We represent Flatbuffers-structs in Rust-u8-arrays since the data may be
@@ -2601,7 +2615,7 @@
code_ += "// struct {{STRUCT_TY}}, aligned to {{ALIGN}}";
code_ += "#[repr(transparent)]";
code_ += "#[derive(Clone, Copy, PartialEq)]";
- code_ += "pub struct {{STRUCT_TY}}(pub [u8; {{STRUCT_SIZE}}]);";
+ code_ += "{{ACCESS_TYPE}} struct {{STRUCT_TY}}(pub [u8; {{STRUCT_SIZE}}]);";
code_ += "impl Default for {{STRUCT_TY}} { ";
code_ += " fn default() -> Self { ";
code_ += " Self([0; {{STRUCT_SIZE}}])";
@@ -2609,10 +2623,10 @@
code_ += "}";
// Debug for structs.
- code_ += "impl std::fmt::Debug for {{STRUCT_TY}} {";
+ code_ += "impl core::fmt::Debug for {{STRUCT_TY}} {";
code_ +=
- " fn fmt(&self, f: &mut std::fmt::Formatter"
- ") -> std::fmt::Result {";
+ " fn fmt(&self, f: &mut core::fmt::Formatter"
+ ") -> core::fmt::Result {";
code_ += " f.debug_struct(\"{{STRUCT_TY}}\")";
ForAllStructFields(struct_def, [&](const FieldDef &unused) {
(void)unused;
@@ -2648,7 +2662,7 @@
code_ += " fn push(&self, dst: &mut [u8], _rest: &[u8]) {";
code_ += " let src = unsafe {";
code_ +=
- " ::std::slice::from_raw_parts("
+ " ::core::slice::from_raw_parts("
"self as *const {{STRUCT_TY}} as *const u8, Self::size())";
code_ += " };";
code_ += " dst.copy_from_slice(src);";
@@ -2661,7 +2675,7 @@
code_ += " fn push(&self, dst: &mut [u8], _rest: &[u8]) {";
code_ += " let src = unsafe {";
code_ +=
- " ::std::slice::from_raw_parts("
+ " ::core::slice::from_raw_parts("
"*self as *const {{STRUCT_TY}} as *const u8, Self::size())";
code_ += " };";
code_ += " dst.copy_from_slice(src);";
@@ -2793,7 +2807,7 @@
NumToString(InlineSize(field.value.type)));
code_ += "pub fn set_{{FIELD}}(&mut self, x: &{{FIELD_TYPE}}) {";
code_ += " unsafe {";
- code_ += " std::ptr::copy(";
+ code_ += " core::ptr::copy(";
code_ += " x.as_ptr() as *const u8,";
code_ += " self.0.as_mut_ptr().add({{FIELD_OFFSET}}),";
code_ += " {{FIELD_SIZE}},";
@@ -2819,7 +2833,7 @@
// Generate Object API unpack method.
if (parser_.opts.generate_object_based_api) {
- code_.SetValue("STRUCT_OTY", namer_.ObjectType(struct_def.name));
+ code_.SetValue("STRUCT_OTY", namer_.ObjectType(struct_def));
code_ += " pub fn unpack(&self) -> {{STRUCT_OTY}} {";
code_ += " {{STRUCT_OTY}} {";
ForAllStructFields(struct_def, [&](const FieldDef &field) {
@@ -2848,7 +2862,7 @@
if (parser_.opts.generate_object_based_api) {
// Struct declaration
code_ += "#[derive(Debug, Clone, PartialEq, Default)]";
- code_ += "pub struct {{STRUCT_OTY}} {";
+ code_ += "{{ACCESS_TYPE}} struct {{STRUCT_OTY}} {";
ForAllStructFields(struct_def, [&](const FieldDef &field) {
(void)field; // unused.
code_ += "pub {{FIELD}}: {{FIELD_OTY}},";
@@ -2906,8 +2920,8 @@
}
}
}
- code_ += indent + "use std::mem;";
- code_ += indent + "use std::cmp::Ordering;";
+ code_ += indent + "use core::mem;";
+ code_ += indent + "use core::cmp::Ordering;";
code_ += "";
if (parser_.opts.rust_serialize) {
code_ += indent + "extern crate serde;";
@@ -2964,7 +2978,7 @@
}
private:
- Namer namer_;
+ IdlNamer namer_;
};
} // namespace rust
diff --git a/src/idl_gen_swift.cpp b/src/idl_gen_swift.cpp
index c3c322f..b3baa28 100644
--- a/src/idl_gen_swift.cpp
+++ b/src/idl_gen_swift.cpp
@@ -21,21 +21,133 @@
#include "flatbuffers/flatbuffers.h"
#include "flatbuffers/idl.h"
#include "flatbuffers/util.h"
+#include "idl_namer.h"
namespace flatbuffers {
namespace swift {
-inline std::string GenIndirect(const std::string &reading) {
+namespace {
+
+static Namer::Config SwiftDefaultConfig() {
+ return { /*types=*/Case::kKeep,
+ /*constants=*/Case::kLowerCamel,
+ /*methods=*/Case::kLowerCamel,
+ /*functions=*/Case::kLowerCamel,
+ /*fields=*/Case::kLowerCamel,
+ /*variables=*/Case::kLowerCamel,
+ /*variants=*/Case::kLowerCamel,
+ /*enum_variant_seperator=*/".",
+ /*escape_keywords=*/Namer::Config::Escape::AfterConvertingCase,
+ /*namespaces=*/Case::kKeep,
+ /*namespace_seperator=*/"_",
+ /*object_prefix=*/"",
+ /*object_suffix=*/"T",
+ /*keyword_prefix=*/"",
+ /*keyword_suffix=*/"_",
+ /*filenames=*/Case::kKeep,
+ /*directories=*/Case::kKeep,
+ /*output_path=*/"",
+ /*filename_suffix=*/"_generated",
+ /*filename_extension=*/".swift" };
+}
+
+static std::set<std::string> SwiftKeywords() {
+ return {
+ "associatedtype",
+ "class",
+ "deinit",
+ "enum",
+ "extension",
+ "fileprivate",
+ "func",
+ "import",
+ "init",
+ "inout",
+ "internal",
+ "let",
+ "open",
+ "operator",
+ "private",
+ "protocol",
+ "public",
+ "rethrows",
+ "static",
+ "struct",
+ "subscript",
+ "typealias",
+ "var",
+ "break",
+ "case",
+ "continue",
+ "default",
+ "defer",
+ "do",
+ "else",
+ "fallthrough",
+ "for",
+ "guard",
+ "if",
+ "in",
+ "repeat",
+ "return",
+ "switch",
+ "where",
+ "while",
+ "Any",
+ "catch",
+ "false",
+ "is",
+ "nil",
+ "super",
+ "self",
+ "Self",
+ "throw",
+ "throws",
+ "true",
+ "try",
+ "associativity",
+ "convenience",
+ "dynamic",
+ "didSet",
+ "final",
+ "get",
+ "infix",
+ "indirect",
+ "lazy",
+ "left",
+ "mutating",
+ "none",
+ "nonmutating",
+ "optional",
+ "override",
+ "postfix",
+ "precedence",
+ "prefix",
+ "Protocol",
+ "required",
+ "right",
+ "set",
+ "Type",
+ "unowned",
+ "weak",
+ "willSet",
+ "Void",
+ };
+}
+
+static std::string GenIndirect(const std::string &reading) {
return "{{ACCESS}}.indirect(" + reading + ")";
}
-inline std::string GenArrayMainBody(const std::string &optional) {
- return "{{ACCESS_TYPE}} func {{VALUENAME}}(at index: Int32) -> "
+static std::string GenArrayMainBody(const std::string &optional) {
+ return "{{ACCESS_TYPE}} func {{FIELDMETHOD}}(at index: Int32) -> "
"{{VALUETYPE}}" +
optional + " { ";
}
+} // namespace
+
class SwiftGenerator : public BaseGenerator {
private:
CodeWriter code_;
@@ -45,92 +157,11 @@
public:
SwiftGenerator(const Parser &parser, const std::string &path,
const std::string &file_name)
- : BaseGenerator(parser, path, file_name, "", "_", "swift") {
+ : BaseGenerator(parser, path, file_name, "", "_", "swift"),
+ namer_(WithFlagOptions(SwiftDefaultConfig(), parser.opts, path),
+ SwiftKeywords()) {
namespace_depth = 0;
code_.SetPadding(" ");
- static const char *const keywords[] = {
- "associatedtype",
- "class",
- "deinit",
- "enum",
- "extension",
- "fileprivate",
- "func",
- "import",
- "init",
- "inout",
- "internal",
- "let",
- "open",
- "operator",
- "private",
- "protocol",
- "public",
- "rethrows",
- "static",
- "struct",
- "subscript",
- "typealias",
- "var",
- "break",
- "case",
- "continue",
- "default",
- "defer",
- "do",
- "else",
- "fallthrough",
- "for",
- "guard",
- "if",
- "in",
- "repeat",
- "return",
- "switch",
- "where",
- "while",
- "Any",
- "catch",
- "false",
- "is",
- "nil",
- "super",
- "self",
- "Self",
- "throw",
- "throws",
- "true",
- "try",
- "associativity",
- "convenience",
- "dynamic",
- "didSet",
- "final",
- "get",
- "infix",
- "indirect",
- "lazy",
- "left",
- "mutating",
- "none",
- "nonmutating",
- "optional",
- "override",
- "postfix",
- "precedence",
- "prefix",
- "Protocol",
- "required",
- "right",
- "set",
- "Type",
- "unowned",
- "weak",
- "willSet",
- "Void",
- nullptr,
- };
- for (auto kw = keywords; *kw; kw++) keywords_.insert(*kw);
}
bool generate() {
@@ -140,9 +171,14 @@
code_ += "// " + std::string(FlatBuffersGeneratedWarning());
code_ += "// swiftlint:disable all";
code_ += "// swiftformat:disable all\n";
- code_ += "import FlatBuffers\n";
- // Generate code for all the enum declarations.
+ if (parser_.opts.include_dependence_headers || parser_.opts.generate_all) {
+ if (parser_.opts.swift_implementation_only)
+ code_ += "@_implementationOnly \\";
+ code_ += "import FlatBuffers\n";
+ }
+
+ // Generate code for all the enum declarations.
for (auto it = parser_.enums_.vec.begin(); it != parser_.enums_.vec.end();
++it) {
const auto &enum_def = **it;
@@ -183,10 +219,12 @@
// Generates the reader for swift
void GenStructReader(const StructDef &struct_def) {
- auto is_private_access = struct_def.attributes.Lookup("private");
+ const bool is_private_access =
+ parser_.opts.swift_implementation_only ||
+ struct_def.attributes.Lookup("private") != nullptr;
code_.SetValue("ACCESS_TYPE", is_private_access ? "internal" : "public");
GenComment(struct_def.doc_comment);
- code_.SetValue("STRUCTNAME", NameWrappedInNameSpace(struct_def));
+ code_.SetValue("STRUCTNAME", namer_.NamespacedType(struct_def));
code_ +=
"{{ACCESS_TYPE}} struct {{STRUCTNAME}}: NativeStruct, Verifiable, "
"FlatbuffersInitializable\\";
@@ -203,14 +241,14 @@
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
- auto &field = **it;
+ const auto &field = **it;
if (field.deprecated) continue;
if (!constructor.empty()) constructor += ", ";
- auto name = Name(field);
- auto type = GenType(field.value.type);
- code_.SetValue("VALUENAME", name);
+ const auto field_var = namer_.Variable(field);
+ const auto type = GenType(field.value.type);
+ code_.SetValue("FIELDVAR", field_var);
if (IsEnum(field.value.type)) {
code_.SetValue("BASEVALUE", GenTypeBasic(field.value.type, false));
}
@@ -218,18 +256,20 @@
GenComment(field.doc_comment);
std::string valueType =
IsEnum(field.value.type) ? "{{BASEVALUE}}" : "{{VALUETYPE}}";
- code_ += "private var _{{VALUENAME}}: " + valueType;
- auto accessing_value = IsEnum(field.value.type) ? ".value" : "";
- auto is_bool = IsBool(field.value.type.base_type);
- auto base_value = IsStruct(field.value.type) ? (type + "()")
- : is_bool ? ("0" == field.value.constant ? "false" : "true")
- : field.value.constant;
+ code_ += "private var _{{FIELDVAR}}: " + valueType;
+ const auto accessing_value = IsEnum(field.value.type) ? ".value" : "";
+ const auto is_bool = IsBool(field.value.type.base_type);
+ const auto base_value =
+ IsStruct(field.value.type) ? (type + "()")
+ : is_bool ? ("0" == field.value.constant ? "false" : "true")
+ : field.value.constant;
- main_constructor.push_back("_" + name + " = " + name + accessing_value);
- base_constructor.push_back("_" + name + " = " + base_value);
+ main_constructor.push_back("_" + field_var + " = " + field_var +
+ accessing_value);
+ base_constructor.push_back("_" + field_var + " = " + base_value);
if (field.padding) { GenPadding(field, &padding_id); }
- constructor += name + ": " + type;
+ constructor += field_var + ": " + type;
}
code_ += "";
BuildStructConstructor(struct_def);
@@ -241,23 +281,22 @@
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
- auto &field = **it;
+ const auto &field = **it;
if (field.deprecated) continue;
- auto name = Name(field);
- auto type = GenType(field.value.type);
- code_.SetValue("VALUENAME", name);
- code_.SetValue("VALUETYPE", type);
+ code_.SetValue("FIELDVAR", namer_.Variable(field));
+ code_.SetValue("VALUETYPE", GenType(field.value.type));
GenComment(field.doc_comment);
if (!IsEnum(field.value.type)) {
- code_ += GenReaderMainBody() + "_{{VALUENAME}} }";
+ code_ += GenReaderMainBody() + "_{{FIELDVAR}} }";
} else if (IsEnum(field.value.type)) {
code_ +=
- GenReaderMainBody() + "{{VALUETYPE}}(rawValue: _{{VALUENAME}})! }";
+ GenReaderMainBody() + "{{VALUETYPE}}(rawValue: _{{FIELDVAR}})! }";
}
}
code_ += "";
code_ +=
- "public static func verify<T>(_ verifier: inout Verifier, at position: "
+ "{{ACCESS_TYPE}} static func verify<T>(_ verifier: inout Verifier, at "
+ "position: "
"Int, of type: T.Type) throws where T: Verifiable {";
Indent();
code_ +=
@@ -275,22 +314,21 @@
code_ += "let {{ACCESS}} = Struct(bb: bb, position: o)";
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
- auto &field = **it;
+ const auto &field = **it;
if (field.deprecated) continue;
- auto name = Name(field);
- auto type = field.value.type;
- code_.SetValue("VALUENAME", name);
+ const auto type = field.value.type;
+ code_.SetValue("FIELDVAR", namer_.Variable(field));
code_.SetValue("VALUETYPE", GenType(type));
code_.SetValue("OFFSET", NumToString(field.value.offset));
if (IsScalar(type.base_type)) {
if (IsEnum(type))
code_.SetValue("VALUETYPE", GenTypeBasic(field.value.type, false));
code_ +=
- "_{{VALUENAME}} = {{ACCESS}}.readBuffer(of: {{VALUETYPE}}.self, "
+ "_{{FIELDVAR}} = {{ACCESS}}.readBuffer(of: {{VALUETYPE}}.self, "
"at: {{OFFSET}})";
} else {
code_ +=
- "_{{VALUENAME}} = {{VALUETYPE}}({{ACCESS}}.bb, o: "
+ "_{{FIELDVAR}} = {{VALUETYPE}}({{ACCESS}}.bb, o: "
"{{ACCESS}}.postion + {{OFFSET}})";
}
}
@@ -303,12 +341,11 @@
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
- auto &field = **it;
+ const auto &field = **it;
if (field.deprecated) continue;
- auto offset = NumToString(field.value.offset);
- auto name = Name(field);
- auto type = GenType(field.value.type);
- code_.SetValue("VALUENAME", name);
+ const auto offset = NumToString(field.value.offset);
+ const auto type = GenType(field.value.type);
+ code_.SetValue("FIELDVAR", namer_.Variable(field));
if (IsEnum(field.value.type)) {
code_.SetValue("BASEVALUE", GenTypeBasic(field.value.type, false));
}
@@ -332,7 +369,7 @@
}
if (parser_.opts.generate_object_based_api) {
- GenerateObjectAPIExtensionHeader(NameWrappedInNameSpace(struct_def));
+ GenerateObjectAPIExtensionHeader(namer_.NamespacedType(struct_def));
code_ += "return builder.create(struct: obj)";
Outdent();
code_ += "}";
@@ -343,10 +380,12 @@
// Generates the create function for swift
void GenStructWriter(const StructDef &struct_def) {
- auto is_private_access = struct_def.attributes.Lookup("private");
+ const bool is_private_access =
+ parser_.opts.swift_implementation_only ||
+ struct_def.attributes.Lookup("private") != nullptr;
code_.SetValue("ACCESS_TYPE", is_private_access ? "internal" : "public");
- code_.SetValue("STRUCTNAME", NameWrappedInNameSpace(struct_def));
- code_.SetValue("SHORT_STRUCTNAME", Name(struct_def));
+ code_.SetValue("STRUCTNAME", namer_.NamespacedType(struct_def));
+ code_.SetValue("SHORT_STRUCTNAME", namer_.Method(struct_def));
code_ += "extension {{STRUCTNAME}} {";
Indent();
code_ += "@discardableResult";
@@ -376,7 +415,7 @@
auto &code = *code_ptr;
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
- auto &field = **it;
+ const auto &field = **it;
if (field.deprecated) continue;
const auto &field_type = field.value.type;
if (IsStruct(field.value.type)) {
@@ -384,14 +423,15 @@
*field_type.struct_def, code_ptr, (nameprefix + field.name),
(object_name + "." + field.name), obj_api_named, is_obj_api);
} else {
- auto name = Name(field);
- auto type = GenType(field.value.type);
+ const auto field_var = namer_.Variable(field);
+ const auto field_field = namer_.Field(field);
+ const auto type = GenType(field.value.type);
if (!is_obj_api) {
- code += nameprefix + name + ": " + type;
+ code += nameprefix + field_var + ": " + type;
if (!IsEnum(field.value.type)) {
code += " = ";
- auto is_bool = IsBool(field.value.type.base_type);
- auto constant =
+ const auto is_bool = IsBool(field.value.type.base_type);
+ const auto constant =
is_bool ? ("0" == field.value.constant ? "false" : "true")
: field.value.constant;
code += constant;
@@ -399,8 +439,8 @@
code += ", ";
continue;
}
- code +=
- nameprefix + name + ": " + obj_api_named + object_name + "." + name;
+ code += nameprefix + field_var + ": " + obj_api_named + object_name +
+ "." + field_field;
code += ", ";
}
}
@@ -410,7 +450,9 @@
// Generates the reader for swift
void GenTable(const StructDef &struct_def) {
- auto is_private_access = struct_def.attributes.Lookup("private");
+ const bool is_private_access =
+ parser_.opts.swift_implementation_only ||
+ struct_def.attributes.Lookup("private") != nullptr;
code_.SetValue("ACCESS_TYPE", is_private_access ? "internal" : "public");
GenObjectHeader(struct_def);
GenTableAccessors(struct_def);
@@ -435,7 +477,7 @@
it != struct_def.fields.vec.end(); ++it) {
const auto &field = **it;
if (field.deprecated) { continue; }
- code_.SetValue("OFFSET_NAME", Name(field));
+ code_.SetValue("OFFSET_NAME", namer_.Variable(field));
code_.SetValue("OFFSET_VALUE", NumToString(field.value.offset));
code_ += "case {{OFFSET_NAME}} = {{OFFSET_VALUE}}";
}
@@ -450,8 +492,8 @@
void GenObjectHeader(const StructDef &struct_def) {
GenComment(struct_def.doc_comment);
- code_.SetValue("SHORT_STRUCTNAME", Name(struct_def));
- code_.SetValue("STRUCTNAME", NameWrappedInNameSpace(struct_def));
+ code_.SetValue("SHORT_STRUCTNAME", namer_.Type(struct_def));
+ code_.SetValue("STRUCTNAME", namer_.NamespacedType(struct_def));
code_.SetValue("OBJECTTYPE", struct_def.fixed ? "Struct" : "Table");
code_.SetValue("MUTABLE", struct_def.fixed ? Mutable() : "");
code_ +=
@@ -468,12 +510,13 @@
if (!struct_def.fixed) {
if (parser_.file_identifier_.length()) {
code_.SetValue("FILENAME", parser_.file_identifier_);
+ code_ += "{{ACCESS_TYPE}} static var id: String { \"{{FILENAME}}\" } ";
code_ +=
"{{ACCESS_TYPE}} static func finish(_ fbb: inout "
"FlatBufferBuilder, end: "
"Offset, prefix: Bool = false) { fbb.finish(offset: end, "
"fileId: "
- "\"{{FILENAME}}\", addPrefix: prefix) }";
+ "{{STRUCTNAME}}.id, addPrefix: prefix) }";
}
code_ +=
"{{ACCESS_TYPE}} static func getRootAs{{SHORT_STRUCTNAME}}(bb: "
@@ -495,7 +538,7 @@
std::vector<std::string> require_fields;
std::vector<std::string> create_func_body;
std::vector<std::string> create_func_header;
- auto should_generate_create = struct_def.fields.vec.size() != 0;
+ const auto should_generate_create = struct_def.fields.vec.size() != 0;
code_.SetValue("NUMBEROFFIELDS", NumToString(struct_def.fields.vec.size()));
code_ +=
@@ -555,14 +598,12 @@
std::string spacing = "";
if (key_field != nullptr && !struct_def.fixed && struct_def.has_key) {
- code_.SetValue("VALUENAME", NameWrappedInNameSpace(struct_def));
- code_.SetValue("SHORT_VALUENAME", Name(struct_def));
code_.SetValue("VOFFSET", NumToString(key_field->value.offset));
- code_ +=
- "{{ACCESS_TYPE}} static func "
- "sortVectorOf{{SHORT_VALUENAME}}(offsets:[Offset], "
- "_ fbb: inout FlatBufferBuilder) -> Offset {";
+ code_ += "{{ACCESS_TYPE}} static func " +
+ namer_.Method("sort_vector_of", struct_def) +
+ "(offsets:[Offset], "
+ "_ fbb: inout FlatBufferBuilder) -> Offset {";
Indent();
code_ += spacing + "var off = offsets";
code_ +=
@@ -573,7 +614,7 @@
code_ += spacing + "return fbb.createVector(ofOffsets: off)";
Outdent();
code_ += "}";
- GenLookup(*key_field);
+ GenLookup(*key_field, namer_.NamespacedType(struct_def));
}
}
@@ -583,42 +624,44 @@
std::string builder_string = ", _ fbb: inout FlatBufferBuilder) { ";
auto &create_func_body = *create_body;
auto &create_func_header = *create_header;
- auto name = Name(field);
- auto type = GenType(field.value.type);
- auto opt_scalar =
+ const auto field_field = namer_.Field(field);
+ const auto field_var = namer_.Variable(field);
+ const auto type = GenType(field.value.type);
+ const auto opt_scalar =
field.IsOptional() && IsScalar(field.value.type.base_type);
- auto nullable_type = opt_scalar ? type + "?" : type;
- code_.SetValue("VALUENAME", name);
+ const auto nullable_type = opt_scalar ? type + "?" : type;
+ code_.SetValue("FIELDVAR", namer_.Variable(field));
code_.SetValue("VALUETYPE", nullable_type);
- code_.SetValue("OFFSET", name);
+ code_.SetValue("OFFSET", namer_.Field(field));
code_.SetValue("CONSTANT", field.value.constant);
std::string check_if_vector =
(IsVector(field.value.type) || IsArray(field.value.type)) ? "VectorOf("
: "(";
- auto body = "add" + check_if_vector + name + ": ";
+ const auto body = "add" + check_if_vector + field_field + ": ";
code_ += "{{ACCESS_TYPE}} static func " + body + "\\";
- create_func_body.push_back("{{STRUCTNAME}}." + body + name + ", &fbb)");
+ create_func_body.push_back("{{STRUCTNAME}}." + body + field_field +
+ ", &fbb)");
if (IsScalar(field.value.type.base_type) &&
!IsBool(field.value.type.base_type)) {
- std::string is_enum = IsEnum(field.value.type) ? ".rawValue" : "";
- std::string optional_enum =
+ const std::string is_enum = IsEnum(field.value.type) ? ".rawValue" : "";
+ const std::string optional_enum =
IsEnum(field.value.type) ? ("?" + is_enum) : "";
code_ +=
- "{{VALUETYPE}}" + builder_string + "fbb.add(element: {{VALUENAME}}\\";
+ "{{VALUETYPE}}" + builder_string + "fbb.add(element: {{FIELDVAR}}\\";
code_ += field.IsOptional() ? (optional_enum + "\\")
: (is_enum + ", def: {{CONSTANT}}\\");
code_ += ", at: {{TABLEOFFSET}}.{{OFFSET}}.p) }";
- auto default_value =
+ const auto default_value =
IsEnum(field.value.type)
? (field.IsOptional() ? "nil" : GenEnumDefaultValue(field))
: field.value.constant;
create_func_header.push_back(
- "" + name + ": " + nullable_type + " = " +
+ "" + field_field + ": " + nullable_type + " = " +
(field.IsOptional() ? "nil" : default_value));
return;
}
@@ -629,48 +672,49 @@
code_.SetValue("CONSTANT", default_value);
code_.SetValue("VALUETYPE", field.IsOptional() ? "Bool?" : "Bool");
- code_ += "{{VALUETYPE}}" + builder_string +
- "fbb.add(element: {{VALUENAME}},\\";
+ code_ +=
+ "{{VALUETYPE}}" + builder_string + "fbb.add(element: {{FIELDVAR}},\\";
code_ += field.IsOptional() ? "\\" : " def: {{CONSTANT}},";
code_ += " at: {{TABLEOFFSET}}.{{OFFSET}}.p) }";
create_func_header.push_back(
- name + ": " + nullable_type + " = " +
+ field_var + ": " + nullable_type + " = " +
(field.IsOptional() ? "nil" : default_value));
return;
}
if (IsStruct(field.value.type)) {
- auto create_struct =
- "guard let {{VALUENAME}} = {{VALUENAME}} else { return };"
- " fbb.create(struct: {{VALUENAME}}, position: "
+ const auto create_struct =
+ "guard let {{FIELDVAR}} = {{FIELDVAR}} else { return };"
+ " fbb.create(struct: {{FIELDVAR}}, position: "
"{{TABLEOFFSET}}.{{OFFSET}}.p) }";
code_ += type + "?" + builder_string + create_struct;
/// Optional hard coded since structs are always optional
- create_func_header.push_back(name + ": " + type + "? = nil");
+ create_func_header.push_back(field_var + ": " + type +
+ (field.IsOptional() ? "? = nil" : ""));
return;
}
- auto camel_case_name =
- ConvertCase(name, Case::kLowerCamel) +
+ const auto arg_label =
+ namer_.Variable(field) +
(IsVector(field.value.type) || IsArray(field.value.type)
? "VectorOffset"
: "Offset");
- create_func_header.push_back(camel_case_name + " " + name + ": " +
- "Offset = Offset()");
- auto reader_type =
+ create_func_header.push_back(arg_label + " " + field_var + ": " + "Offset" +
+ (field.IsRequired() ? "" : " = Offset()"));
+ const auto reader_type =
IsStruct(field.value.type) && field.value.type.struct_def->fixed
? "structOffset: {{TABLEOFFSET}}.{{OFFSET}}.p) }"
- : "offset: {{VALUENAME}}, at: {{TABLEOFFSET}}.{{OFFSET}}.p) }";
+ : "offset: {{FIELDVAR}}, at: {{TABLEOFFSET}}.{{OFFSET}}.p) }";
code_ += "Offset" + builder_string + "fbb.add(" + reader_type;
- auto vectortype = field.value.type.VectorType();
+ const auto vectortype = field.value.type.VectorType();
if ((vectortype.base_type == BASE_TYPE_STRUCT &&
field.value.type.struct_def->fixed) &&
(IsVector(field.value.type) || IsArray(field.value.type))) {
- auto field_name = NameWrappedInNameSpace(*vectortype.struct_def);
- code_ += "public static func startVectorOf" +
- ConvertCase(name, Case::kUpperCamel) +
+ const auto field_name = namer_.NamespacedType(*vectortype.struct_def);
+ code_ += "{{ACCESS_TYPE}} static func " +
+ namer_.Method("start_vector_of", field_var) +
"(_ size: Int, in builder: inout "
"FlatBufferBuilder) {";
Indent();
@@ -685,25 +729,26 @@
void GenTableReader(const StructDef &struct_def) {
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
- auto &field = **it;
+ const auto &field = **it;
if (field.deprecated) continue;
GenTableReaderFields(field);
}
}
void GenTableReaderFields(const FieldDef &field) {
- auto offset = NumToString(field.value.offset);
- auto name = Name(field);
- auto type = GenType(field.value.type);
- code_.SetValue("VALUENAME", name);
+ const auto offset = NumToString(field.value.offset);
+ const auto field_field = namer_.Field(field);
+ const auto type = GenType(field.value.type);
+ code_.SetValue("FIELDVAR", namer_.Variable(field));
+ code_.SetValue("FIELDMETHOD", namer_.Method(field));
code_.SetValue("VALUETYPE", type);
- code_.SetValue("OFFSET", name);
+ code_.SetValue("OFFSET", namer_.Constant(field.name));
code_.SetValue("CONSTANT", field.value.constant);
bool opt_scalar =
field.IsOptional() && IsScalar(field.value.type.base_type);
std::string def_Val = opt_scalar ? "nil" : "{{CONSTANT}}";
std::string optional = opt_scalar ? "?" : "";
- auto const_string = "return o == 0 ? " + def_Val + " : ";
+ const auto const_string = "return o == 0 ? " + def_Val + " : ";
GenComment(field.doc_comment);
if (IsScalar(field.value.type.base_type) && !IsEnum(field.value.type) &&
!IsBool(field.value.type.base_type)) {
@@ -728,7 +773,7 @@
}
if (IsEnum(field.value.type)) {
- auto default_value =
+ const auto default_value =
field.IsOptional() ? "nil" : GenEnumDefaultValue(field);
code_.SetValue("BASEVALUE", GenTypeBasic(field.value.type, false));
code_ += GenReaderMainBody(optional) + "\\";
@@ -739,16 +784,15 @@
return;
}
- std::string is_required = field.IsRequired() ? "!" : "?";
- auto required_reader = field.IsRequired() ? "return " : const_string;
+ const std::string is_required = field.IsRequired() ? "!" : "?";
+ const auto required_reader = field.IsRequired() ? "return " : const_string;
if (IsStruct(field.value.type) && field.value.type.struct_def->fixed) {
code_.SetValue("VALUETYPE", GenType(field.value.type));
code_.SetValue("CONSTANT", "nil");
code_ += GenReaderMainBody(is_required) + GenOffset() + required_reader +
"{{ACCESS}}.readBuffer(of: {{VALUETYPE}}.self, at: o) }";
- code_.SetValue("VALUENAME",
- "mutable" + ConvertCase(name, Case::kUpperCamel));
+ code_.SetValue("FIELDVAR", namer_.Variable("mutable", field_field));
code_.SetValue("VALUETYPE", GenType(field.value.type) + Mutable());
code_.SetValue("CONSTANT", "nil");
code_ += GenReaderMainBody(is_required) + GenOffset() + required_reader +
@@ -765,12 +809,12 @@
break;
case BASE_TYPE_STRING: {
- auto default_string = "\"" + field.value.constant + "\"";
+ const auto default_string = "\"" + field.value.constant + "\"";
code_.SetValue("VALUETYPE", GenType(field.value.type));
code_.SetValue("CONSTANT", field.IsDefault() ? default_string : "nil");
code_ += GenReaderMainBody(is_required) + GenOffset() +
required_reader + "{{ACCESS}}.string(at: o) }";
- code_ += "{{ACCESS_TYPE}} var {{VALUENAME}}SegmentArray: [UInt8]" +
+ code_ += "{{ACCESS_TYPE}} var {{FIELDVAR}}SegmentArray: [UInt8]" +
is_required +
" { return "
"{{ACCESS}}.getVector(at: {{TABLEOFFSET}}.{{OFFSET}}.v) }";
@@ -781,7 +825,7 @@
case BASE_TYPE_UNION:
code_.SetValue("CONSTANT", "nil");
code_ +=
- "{{ACCESS_TYPE}} func {{VALUENAME}}<T: "
+ "{{ACCESS_TYPE}} func {{FIELDVAR}}<T: "
"FlatbuffersInitializable>(type: "
"T.Type) -> T" +
is_required + " { " + GenOffset() + required_reader +
@@ -793,20 +837,22 @@
void GenTableReaderVectorFields(const FieldDef &field) {
std::string const_string = "return o == 0 ? {{CONSTANT}} : ";
- auto vectortype = field.value.type.VectorType();
+ const auto vectortype = field.value.type.VectorType();
code_.SetValue("SIZE", NumToString(InlineSize(vectortype)));
- code_ += "{{ACCESS_TYPE}} var {{VALUENAME}}Count: Int32 { " + GenOffset() +
+ code_.SetValue("HAS_FIELDVAR", namer_.Variable("has", field));
+ code_ += "{{ACCESS_TYPE}} var {{HAS_FIELDVAR}}: Bool { " + GenOffset() +
+ "return o == 0 ? false : true }";
+ code_ += "{{ACCESS_TYPE}} var {{FIELDVAR}}Count: Int32 { " + GenOffset() +
"return o == 0 ? 0 : {{ACCESS}}.vector(count: o) }";
- code_.SetValue("CONSTANT",
- IsScalar(vectortype.base_type) == true ? "0" : "nil");
- auto nullable = IsScalar(vectortype.base_type) == true ? "" : "?";
- nullable = IsEnum(vectortype) == true ? "?" : nullable;
+ code_.SetValue("CONSTANT", IsScalar(vectortype.base_type) ? "0" : "nil");
+ const auto nullable =
+ IsScalar(vectortype.base_type) && !IsEnum(vectortype) ? "" : "?";
if (vectortype.base_type != BASE_TYPE_UNION) {
code_ += GenArrayMainBody(nullable) + GenOffset() + "\\";
} else {
code_ +=
- "{{ACCESS_TYPE}} func {{VALUENAME}}<T: FlatbuffersInitializable>(at "
+ "{{ACCESS_TYPE}} func {{FIELDVAR}}<T: FlatbuffersInitializable>(at "
"index: "
"Int32, type: T.Type) -> T? { " +
GenOffset() + "\\";
@@ -825,7 +871,7 @@
"{{ACCESS}}.directRead(of: {{VALUETYPE}}.self, offset: "
"{{ACCESS}}.vector(at: o) + index * {{SIZE}}) }";
code_ +=
- "{{ACCESS_TYPE}} var {{VALUENAME}}: [{{VALUETYPE}}] { return "
+ "{{ACCESS_TYPE}} var {{FIELDVAR}}: [{{VALUETYPE}}] { return "
"{{ACCESS}}.getVector(at: {{TABLEOFFSET}}.{{OFFSET}}.v) ?? [] }";
if (parser_.opts.mutable_buffer) code_ += GenMutateArray();
return;
@@ -836,8 +882,7 @@
code_ +=
"{{ACCESS}}.directRead(of: {{VALUETYPE}}.self, offset: "
"{{ACCESS}}.vector(at: o) + index * {{SIZE}}) }";
- code_.SetValue("VALUENAME",
- "mutable" + ConvertCase(Name(field), Case::kUpperCamel));
+ code_.SetValue("FIELDMETHOD", namer_.Method("mutable", field));
code_.SetValue("VALUETYPE", GenType(field.value.type) + Mutable());
code_ += GenArrayMainBody(nullable) + GenOffset() + const_string +
GenConstructor("{{ACCESS}}.vector(at: o) + index * {{SIZE}}");
@@ -872,10 +917,10 @@
code_ += GenConstructor(
"{{ACCESS}}.indirect({{ACCESS}}.vector(at: o) + index * "
"{{SIZE}})");
- auto &sd = *field.value.type.struct_def;
- auto &fields = sd.fields.vec;
+ const auto &sd = *field.value.type.struct_def;
+ const auto &fields = sd.fields.vec;
for (auto kit = fields.begin(); kit != fields.end(); ++kit) {
- auto &key_field = **kit;
+ const auto &key_field = **kit;
if (key_field.key) {
GenByKeyFunctions(key_field);
break;
@@ -889,13 +934,12 @@
Indent();
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
- auto &field = **it;
+ const auto &field = **it;
if (field.deprecated) continue;
- auto name = Name(field);
code_.SetValue("RAWVALUENAME", field.name);
- code_.SetValue("VALUENAME", name);
- code_ += "case {{VALUENAME}} = \"{{RAWVALUENAME}}\"";
+ code_.SetValue("FIELDVAR", namer_.Variable(field));
+ code_ += "case {{FIELDVAR}} = \"{{RAWVALUENAME}}\"";
}
Outdent();
code_ += "}";
@@ -903,8 +947,8 @@
void GenerateEncoderUnionBody(const FieldDef &field) {
EnumDef &union_def = *field.value.type.enum_def;
- auto is_vector = field.value.type.base_type == BASE_TYPE_VECTOR ||
- field.value.type.base_type == BASE_TYPE_ARRAY;
+ const auto is_vector = field.value.type.base_type == BASE_TYPE_VECTOR ||
+ field.value.type.base_type == BASE_TYPE_ARRAY;
if (field.value.type.base_type == BASE_TYPE_UTYPE ||
(is_vector &&
field.value.type.VectorType().base_type == BASE_TYPE_UTYPE))
@@ -912,28 +956,25 @@
if (is_vector) {
code_ +=
"var enumsEncoder = container.nestedUnkeyedContainer(forKey: "
- ".{{VALUENAME}}Type)";
+ ".{{FIELDVAR}}Type)";
code_ +=
"var contentEncoder = container.nestedUnkeyedContainer(forKey: "
- ".{{VALUENAME}})";
- code_ += "for index in 0..<{{VALUENAME}}Count {";
+ ".{{FIELDVAR}})";
+ code_ += "for index in 0..<{{FIELDVAR}}Count {";
Indent();
- code_ +=
- "guard let type = {{VALUENAME}}Type(at: index) else { continue }";
+ code_ += "guard let type = {{FIELDVAR}}Type(at: index) else { continue }";
code_ += "try enumsEncoder.encode(type)";
code_ += "switch type {";
for (auto it = union_def.Vals().begin(); it != union_def.Vals().end();
++it) {
const auto &ev = **it;
-
- auto name = Name(ev);
- auto type = GenType(ev.union_type);
- code_.SetValue("KEY", name);
+ const auto type = GenType(ev.union_type);
+ code_.SetValue("KEY", namer_.LegacySwiftVariant(ev));
code_.SetValue("VALUETYPE", type);
if (ev.union_type.base_type == BASE_TYPE_NONE) { continue; }
code_ += "case .{{KEY}}:";
Indent();
- code_ += "let _v = {{VALUENAME}}(at: index, type: {{VALUETYPE}}.self)";
+ code_ += "let _v = {{FIELDVAR}}(at: index, type: {{VALUETYPE}}.self)";
code_ += "try contentEncoder.encode(_v)";
Outdent();
}
@@ -944,20 +985,18 @@
return;
}
- code_ += "switch {{VALUENAME}}Type {";
+ code_ += "switch {{FIELDVAR}}Type {";
for (auto it = union_def.Vals().begin(); it != union_def.Vals().end();
++it) {
const auto &ev = **it;
-
- auto name = Name(ev);
- auto type = GenType(ev.union_type);
- code_.SetValue("KEY", name);
+ const auto type = GenType(ev.union_type);
+ code_.SetValue("KEY", namer_.LegacySwiftVariant(ev));
code_.SetValue("VALUETYPE", type);
if (ev.union_type.base_type == BASE_TYPE_NONE) { continue; }
code_ += "case .{{KEY}}:";
Indent();
- code_ += "let _v = {{VALUENAME}}(type: {{VALUETYPE}}.self)";
- code_ += "try container.encodeIfPresent(_v, forKey: .{{VALUENAME}})";
+ code_ += "let _v = {{FIELDVAR}}(type: {{VALUETYPE}}.self)";
+ code_ += "try container.encodeIfPresent(_v, forKey: .{{FIELDVAR}})";
Outdent();
}
code_ += "default: break;";
@@ -968,33 +1007,31 @@
code_ += "var container = encoder.container(keyedBy: CodingKeys.self)";
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
- auto &field = **it;
+ const auto &field = **it;
if (field.deprecated) continue;
- auto name = Name(field);
- auto type = field.value.type;
+ const auto type = field.value.type;
- auto is_non_union_vector =
+ const auto is_non_union_vector =
(field.value.type.base_type == BASE_TYPE_ARRAY ||
field.value.type.base_type == BASE_TYPE_VECTOR) &&
field.value.type.VectorType().base_type != BASE_TYPE_UTYPE;
- code_.SetValue("RAWVALUENAME", field.name);
- code_.SetValue("VALUENAME", name);
+ code_.SetValue("FIELDVAR", namer_.Variable(field));
code_.SetValue("CONSTANT", field.value.constant);
bool should_indent = true;
if (is_non_union_vector) {
- code_ += "if {{VALUENAME}}Count > 0 {";
+ code_ += "if {{FIELDVAR}}Count > 0 {";
} else if (IsEnum(type) && !field.IsOptional()) {
code_.SetValue("CONSTANT", GenEnumDefaultValue(field));
- code_ += "if {{VALUENAME}} != {{CONSTANT}} {";
+ code_ += "if {{FIELDVAR}} != {{CONSTANT}} {";
} else if (IsScalar(type.base_type) && !IsEnum(type) &&
!IsBool(type.base_type) && !field.IsOptional()) {
- code_ += "if {{VALUENAME}} != {{CONSTANT}} {";
+ code_ += "if {{FIELDVAR}} != {{CONSTANT}} {";
} else if (IsBool(type.base_type) && !field.IsOptional()) {
std::string default_value =
"0" == field.value.constant ? "false" : "true";
code_.SetValue("CONSTANT", default_value);
- code_ += "if {{VALUENAME}} != {{CONSTANT}} {";
+ code_ += "if {{FIELDVAR}} != {{CONSTANT}} {";
} else {
should_indent = false;
}
@@ -1007,17 +1044,17 @@
IsEnum(type.VectorType()))) {
code_ +=
"var contentEncoder = container.nestedUnkeyedContainer(forKey: "
- ".{{VALUENAME}})";
- code_ += "for index in 0..<{{VALUENAME}}Count {";
+ ".{{FIELDVAR}})";
+ code_ += "for index in 0..<{{FIELDVAR}}Count {";
Indent();
- code_ += "guard let type = {{VALUENAME}}(at: index) else { continue }";
+ code_ += "guard let type = {{FIELDVAR}}(at: index) else { continue }";
code_ += "try contentEncoder.encode(type)";
Outdent();
code_ += "}";
} else {
code_ +=
- "try container.encodeIfPresent({{VALUENAME}}, forKey: "
- ".{{VALUENAME}})";
+ "try container.encodeIfPresent({{FIELDVAR}}, forKey: "
+ ".{{FIELDVAR}})";
}
if (should_indent) Outdent();
@@ -1034,7 +1071,7 @@
code_ += "";
if (struct_def.fields.vec.empty() == false) GenerateCodingKeys(struct_def);
- code_ += "public func encode(to encoder: Encoder) throws {";
+ code_ += "{{ACCESS_TYPE}} func encode(to encoder: Encoder) throws {";
Indent();
if (struct_def.fields.vec.empty() == false) GenerateEncoderBody(struct_def);
Outdent();
@@ -1046,20 +1083,20 @@
void GenerateVerifier(const StructDef &struct_def) {
code_ +=
- "public static func verify<T>(_ verifier: inout Verifier, at position: "
+ "{{ACCESS_TYPE}} static func verify<T>(_ verifier: inout Verifier, at "
+ "position: "
"Int, of type: T.Type) throws where T: Verifiable {";
Indent();
code_ += "var _v = try verifier.visitTable(at: position)";
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
- auto &field = **it;
+ const auto &field = **it;
if (field.deprecated) continue;
- auto offset = NumToString(field.value.offset);
- auto name = Name(field);
+ const auto offset = NumToString(field.value.offset);
- code_.SetValue("VALUENAME", name);
+ code_.SetValue("FIELDVAR", namer_.Variable(field));
code_.SetValue("VALUETYPE", GenerateVerifierType(field));
- code_.SetValue("OFFSET", name);
+ code_.SetValue("OFFSET", namer_.Field(field));
code_.SetValue("ISREQUIRED", field.IsRequired() ? "true" : "false");
if (IsUnion(field.value.type)) {
@@ -1069,7 +1106,7 @@
code_ +=
"try _v.visit(field: {{TABLEOFFSET}}.{{OFFSET}}.p, fieldName: "
- "\"{{VALUENAME}}\", required: {{ISREQUIRED}}, type: "
+ "\"{{FIELDVAR}}\", required: {{ISREQUIRED}}, type: "
"{{VALUETYPE}}.self)";
}
code_ += "_v.finish()";
@@ -1078,28 +1115,27 @@
}
void GenerateUnionTypeVerifier(const FieldDef &field) {
- auto is_vector = IsVector(field.value.type) || IsArray(field.value.type);
+ const auto is_vector =
+ IsVector(field.value.type) || IsArray(field.value.type);
if (field.value.type.base_type == BASE_TYPE_UTYPE ||
(is_vector &&
field.value.type.VectorType().base_type == BASE_TYPE_UTYPE))
return;
EnumDef &union_def = *field.value.type.enum_def;
- code_.SetValue("VALUETYPE", NameWrappedInNameSpace(union_def));
+ code_.SetValue("VALUETYPE", namer_.NamespacedType(union_def));
code_.SetValue("FUNCTION_NAME", is_vector ? "visitUnionVector" : "visit");
code_ +=
"try _v.{{FUNCTION_NAME}}(unionKey: {{TABLEOFFSET}}.{{OFFSET}}Type.p, "
"unionField: {{TABLEOFFSET}}.{{OFFSET}}.p, unionKeyName: "
- "\"{{VALUENAME}}Type\", fieldName: \"{{VALUENAME}}\", required: "
+ "\"{{FIELDVAR}}Type\", fieldName: \"{{FIELDVAR}}\", required: "
"{{ISREQUIRED}}, completion: { (verifier, key: {{VALUETYPE}}, pos) in";
Indent();
code_ += "switch key {";
for (auto it = union_def.Vals().begin(); it != union_def.Vals().end();
++it) {
const auto &ev = **it;
-
- auto name = Name(ev);
- auto type = GenType(ev.union_type);
- code_.SetValue("KEY", name);
+ const auto type = GenType(ev.union_type);
+ code_.SetValue("KEY", namer_.LegacySwiftVariant(ev));
code_.SetValue("VALUETYPE", type);
code_ += "case .{{KEY}}:";
Indent();
@@ -1125,11 +1161,11 @@
}
std::string GenerateVerifierType(const FieldDef &field) {
- auto type = field.value.type;
- auto is_vector = IsVector(type) || IsArray(type);
+ const auto type = field.value.type;
+ const auto is_vector = IsVector(type) || IsArray(type);
if (is_vector) {
- auto vector_type = field.value.type.VectorType();
+ const auto vector_type = field.value.type.VectorType();
return "ForwardOffset<Vector<" +
GenerateNestedVerifierTypes(vector_type) + ", " +
GenType(vector_type) + ">>";
@@ -1139,7 +1175,7 @@
}
std::string GenerateNestedVerifierTypes(const Type &type) {
- auto string_type = GenType(type);
+ const auto string_type = GenType(type);
if (IsScalar(type.base_type)) { return string_type; }
@@ -1153,7 +1189,7 @@
void GenByKeyFunctions(const FieldDef &key_field) {
code_.SetValue("TYPE", GenType(key_field.value.type));
code_ +=
- "{{ACCESS_TYPE}} func {{VALUENAME}}By(key: {{TYPE}}) -> {{VALUETYPE}}? "
+ "{{ACCESS_TYPE}} func {{FIELDVAR}}By(key: {{TYPE}}) -> {{VALUETYPE}}? "
"{ \\";
code_ += GenOffset() +
"return o == 0 ? nil : {{VALUETYPE}}.lookupByKey(vector: "
@@ -1162,11 +1198,11 @@
void GenEnum(const EnumDef &enum_def) {
if (enum_def.generated) return;
- auto is_private_access = enum_def.attributes.Lookup("private");
+ const auto is_private_access = enum_def.attributes.Lookup("private");
code_.SetValue("ENUM_TYPE",
enum_def.is_union ? "UnionEnum" : "Enum, Verifiable");
code_.SetValue("ACCESS_TYPE", is_private_access ? "internal" : "public");
- code_.SetValue("ENUM_NAME", NameWrappedInNameSpace(enum_def));
+ code_.SetValue("ENUM_NAME", namer_.NamespacedType(enum_def));
code_.SetValue("BASE_TYPE", GenTypeBasic(enum_def.underlying_type, false));
GenComment(enum_def.doc_comment);
code_ +=
@@ -1189,15 +1225,16 @@
"{{ACCESS_TYPE}} var value: {{BASE_TYPE}} { return self.rawValue }";
for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end(); ++it) {
const auto &ev = **it;
- auto name = Name(ev);
- code_.SetValue("KEY", name);
+ code_.SetValue("KEY", namer_.LegacySwiftVariant(ev));
code_.SetValue("VALUE", enum_def.ToString(ev));
GenComment(ev.doc_comment);
code_ += "case {{KEY}} = {{VALUE}}";
}
code_ += "";
- AddMinOrMaxEnumValue(Name(*enum_def.MaxValue()), "max");
- AddMinOrMaxEnumValue(Name(*enum_def.MinValue()), "min");
+ AddMinOrMaxEnumValue(namer_.LegacySwiftVariant(*enum_def.MaxValue()),
+ "max");
+ AddMinOrMaxEnumValue(namer_.LegacySwiftVariant(*enum_def.MinValue()),
+ "min");
Outdent();
code_ += "}\n";
if (parser_.opts.gen_json_coders) EnumEncoder(enum_def);
@@ -1235,8 +1272,7 @@
code_ += "switch self {";
for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end(); ++it) {
const auto &ev = **it;
- auto name = Name(ev);
- code_.SetValue("KEY", name);
+ code_.SetValue("KEY", namer_.LegacySwiftVariant(ev));
code_.SetValue("RAWKEY", ev.name);
code_ += "case .{{KEY}}: try container.encode(\"{{RAWKEY}}\")";
}
@@ -1249,18 +1285,18 @@
// MARK: - Object API
- void GenerateObjectAPIExtensionHeader(std::string name) {
+ void GenerateObjectAPIExtensionHeader(std::string type_name) {
code_ += "\n";
- code_ += "{{ACCESS_TYPE}} mutating func unpack() -> " + name + " {";
+ code_ += "{{ACCESS_TYPE}} mutating func unpack() -> " + type_name + " {";
Indent();
- code_ += "return " + name + "(&self)";
+ code_ += "return " + type_name + "(&self)";
Outdent();
code_ += "}";
code_ +=
"{{ACCESS_TYPE}} static func pack(_ builder: inout FlatBufferBuilder, "
"obj: "
"inout " +
- name + "?) -> Offset {";
+ type_name + "?) -> Offset {";
Indent();
code_ += "guard var obj = obj else { return Offset() }";
code_ += "return pack(&builder, obj: &obj)";
@@ -1271,7 +1307,7 @@
"{{ACCESS_TYPE}} static func pack(_ builder: inout FlatBufferBuilder, "
"obj: "
"inout " +
- name + ") -> Offset {";
+ type_name + ") -> Offset {";
Indent();
}
@@ -1281,40 +1317,39 @@
Indent();
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
- auto &field = **it;
+ const auto &field = **it;
if (field.deprecated) continue;
- auto name = Name(field);
- auto type = GenType(field.value.type);
- code_.SetValue("VALUENAME", name);
+ const auto type = GenType(field.value.type);
+ code_.SetValue("FIELDVAR", namer_.Variable(field));
if (IsStruct(field.value.type)) {
- code_ += "var _v{{VALUENAME}} = _t.{{VALUENAME}}";
- code_ += "_{{VALUENAME}} = _v{{VALUENAME}}.unpack()";
+ code_ += "var _v{{FIELDVAR}} = _t.{{FIELDVAR}}";
+ code_ += "_{{FIELDVAR}} = _v{{FIELDVAR}}.unpack()";
continue;
}
std::string is_enum = IsEnum(field.value.type) ? ".value" : "";
- code_ += "_{{VALUENAME}} = _t.{{VALUENAME}}" + is_enum;
+ code_ += "_{{FIELDVAR}} = _t.{{FIELDVAR}}" + is_enum;
}
Outdent();
code_ += "}\n";
}
void GenObjectAPI(const StructDef &struct_def) {
- code_ += "{{ACCESS_TYPE}} class " + ObjectAPIName("{{STRUCTNAME}}") +
- ": NativeObject {\n";
+ code_ += "{{ACCESS_TYPE}} class " +
+ namer_.NamespacedObjectType(struct_def) + ": NativeObject {\n";
std::vector<std::string> buffer_constructor;
std::vector<std::string> base_constructor;
Indent();
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
- auto &field = **it;
+ const auto &field = **it;
if (field.deprecated) continue;
BuildObjectAPIConstructorBody(field, struct_def.fixed, buffer_constructor,
base_constructor);
}
code_ += "";
BuildObjectConstructor(buffer_constructor,
- "_ _t: inout " + NameWrappedInNameSpace(struct_def));
+ "_ _t: inout " + namer_.NamespacedType(struct_def));
BuildObjectConstructor(base_constructor);
if (!struct_def.fixed)
code_ +=
@@ -1326,35 +1361,37 @@
}
void GenerateObjectAPITableExtension(const StructDef &struct_def) {
- GenerateObjectAPIExtensionHeader(ObjectAPIName("{{STRUCTNAME}}"));
+ GenerateObjectAPIExtensionHeader(namer_.NamespacedObjectType(struct_def));
std::vector<std::string> unpack_body;
std::string builder = ", &builder)";
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
- auto &field = **it;
+ const auto &field = **it;
if (field.deprecated) continue;
- auto name = Name(field);
- auto type = GenType(field.value.type);
+ const auto field_var = namer_.Variable(field);
+ const auto field_field = namer_.Field(field);
+ const auto field_method = namer_.Method(field);
+ const auto type = GenType(field.value.type);
std::string check_if_vector =
(IsVector(field.value.type) || IsArray(field.value.type))
? "VectorOf("
: "(";
- std::string body = "add" + check_if_vector + name + ": ";
+ std::string body = "add" + check_if_vector + field_method + ": ";
switch (field.value.type.base_type) {
case BASE_TYPE_ARRAY: FLATBUFFERS_FALLTHROUGH();
case BASE_TYPE_VECTOR: {
- GenerateVectorObjectAPITableExtension(field, name, type);
- unpack_body.push_back("{{STRUCTNAME}}." + body + "__" + name +
+ GenerateVectorObjectAPITableExtension(field);
+ unpack_body.push_back("{{STRUCTNAME}}." + body + "__" + field_var +
builder);
break;
}
case BASE_TYPE_UNION: {
- code_ += "let __" + name + " = obj." + name +
+ code_ += "let __" + field_var + " = obj." + field_var +
"?.pack(builder: &builder) ?? Offset()";
- unpack_body.push_back("if let o = obj." + name + "?.type {");
- unpack_body.push_back(" {{STRUCTNAME}}.add(" + name + "Type: o" +
- builder);
- unpack_body.push_back(" {{STRUCTNAME}}." + body + "__" + name +
+ unpack_body.push_back("if let o = obj." + field_var + "?.type {");
+ unpack_body.push_back(" {{STRUCTNAME}}.add(" + field_var +
+ "Type: o" + builder);
+ unpack_body.push_back(" {{STRUCTNAME}}." + body + "__" + field_var +
builder);
unpack_body.push_back("}\n");
break;
@@ -1368,31 +1405,31 @@
GenerateStructArgs(*field.value.type.struct_def, &code, "", "",
"$0", true);
code = code.substr(0, code.size() - 2);
- unpack_body.push_back("{{STRUCTNAME}}." + body + "obj." + name +
- builder);
+ unpack_body.push_back("{{STRUCTNAME}}." + body + "obj." +
+ field_field + builder);
} else {
- code_ += "let __" + name + " = " + type +
- ".pack(&builder, obj: &obj." + name + ")";
- unpack_body.push_back("{{STRUCTNAME}}." + body + "__" + name +
+ code_ += "let __" + field_var + " = " + type +
+ ".pack(&builder, obj: &obj." + field_field + ")";
+ unpack_body.push_back("{{STRUCTNAME}}." + body + "__" + field_var +
builder);
}
break;
}
case BASE_TYPE_STRING: {
- unpack_body.push_back("{{STRUCTNAME}}." + body + "__" + name +
+ unpack_body.push_back("{{STRUCTNAME}}." + body + "__" + field_var +
builder);
if (field.IsRequired()) {
- code_ +=
- "let __" + name + " = builder.create(string: obj." + name + ")";
+ code_ += "let __" + field_var + " = builder.create(string: obj." +
+ field_field + ")";
} else {
- BuildingOptionalObjects(name, "builder.create(string: s)");
+ BuildingOptionalObjects(field_field, "builder.create(string: s)");
}
break;
}
case BASE_TYPE_UTYPE: break;
default:
- unpack_body.push_back("{{STRUCTNAME}}." + body + "obj." + name +
- builder);
+ unpack_body.push_back("{{STRUCTNAME}}." + body + "obj." +
+ field_field + builder);
}
}
code_ += "let __root = {{STRUCTNAME}}.start{{SHORT_STRUCTNAME}}(&builder)";
@@ -1405,79 +1442,79 @@
code_ += "}";
}
- void GenerateVectorObjectAPITableExtension(const FieldDef &field,
- const std::string &name,
- const std::string &type) {
- auto vectortype = field.value.type.VectorType();
+ void GenerateVectorObjectAPITableExtension(const FieldDef &field_def) {
+ const Type &field_type = field_def.value.type;
+ const auto type = GenType(field_type);
+ const auto var = namer_.Variable(field_def);
+ const auto field = namer_.Field(field_def);
+
+ const auto vectortype = field_type.VectorType();
switch (vectortype.base_type) {
case BASE_TYPE_UNION: {
- code_ += "var __" + name + "__: [Offset] = []";
- code_ += "for i in obj." + name + " {";
+ code_ += "var __" + var + "__: [Offset] = []";
+ code_ += "for i in obj." + var + " {";
Indent();
code_ += "guard let off = i?.pack(builder: &builder) else { continue }";
- code_ += "__" + name + "__.append(off)";
+ code_ += "__" + var + "__.append(off)";
Outdent();
code_ += "}";
- code_ += "let __" + name + " = builder.createVector(ofOffsets: __" +
- name + "__)";
- code_ += "let __" + name + "Type = builder.createVector(obj." + name +
+ code_ += "let __" + var + " = builder.createVector(ofOffsets: __" +
+ var + "__)";
+ code_ += "let __" + var + "Type = builder.createVector(obj." + field +
".compactMap { $0?.type })";
break;
}
case BASE_TYPE_UTYPE: break;
case BASE_TYPE_STRUCT: {
- if (field.value.type.struct_def &&
- !field.value.type.struct_def->fixed) {
- code_ += "var __" + name + "__: [Offset] = []";
- code_ += "for var i in obj." + name + " {";
+ if (field_type.struct_def && !field_type.struct_def->fixed) {
+ code_ += "var __" + var + "__: [Offset] = []";
+ code_ += "for var i in obj." + var + " {";
Indent();
code_ +=
- "__" + name + "__.append(" + type + ".pack(&builder, obj: &i))";
+ "__" + var + "__.append(" + type + ".pack(&builder, obj: &i))";
Outdent();
code_ += "}";
- code_ += "let __" + name + " = builder.createVector(ofOffsets: __" +
- name + "__)";
+ code_ += "let __" + var + " = builder.createVector(ofOffsets: __" +
+ var + "__)";
} else {
- code_ += "{{STRUCTNAME}}.startVectorOf" +
- ConvertCase(name, Case::kUpperCamel) + "(obj." + name +
- ".count, in: &builder)";
+ code_ += "{{STRUCTNAME}}." + namer_.Method("start_vector_of", var) +
+ "(obj." + field + ".count, in: &builder)";
std::string code;
- GenerateStructArgs(*field.value.type.struct_def, &code, "", "", "_o",
- true);
+ GenerateStructArgs(*field_type.struct_def, &code, "", "", "_o", true);
code = code.substr(0, code.size() - 2);
- code_ += "for i in obj." + name + " {";
+ code_ += "for i in obj." + field + " {";
Indent();
code_ += "guard let _o = i else { continue }";
code_ += "builder.create(struct: _o)";
Outdent();
code_ += "}";
- code_ += "let __" + name + " = builder.endVector(len: obj." + name +
+ code_ += "let __" + var + " = builder.endVector(len: obj." + field +
".count)";
}
break;
}
case BASE_TYPE_STRING: {
- code_ += "let __" + name + " = builder.createVector(ofStrings: obj." +
- name + ".compactMap({ $0 }) )";
+ code_ += "let __" + var + " = builder.createVector(ofStrings: obj." +
+ var + ".compactMap({ $0 }) )";
break;
}
default: {
- code_ += "let __" + name + " = builder.createVector(obj." + name + ")";
+ code_ += "let __" + var + " = builder.createVector(obj." + field + ")";
break;
}
}
}
- void BuildingOptionalObjects(const std::string &name,
+ void BuildingOptionalObjects(const std::string &var,
const std::string &body_front) {
- code_ += "let __" + name + ": Offset";
- code_ += "if let s = obj." + name + " {";
+ code_ += "let __" + var + ": Offset";
+ code_ += "if let s = obj." + var + " {";
Indent();
- code_ += "__" + name + " = " + body_front;
+ code_ += "__" + var + " = " + body_front;
Outdent();
code_ += "} else {";
Indent();
- code_ += "__" + name + " = Offset()";
+ code_ += "__" + var + " = Offset()";
Outdent();
code_ += "}";
code_ += "";
@@ -1497,120 +1534,125 @@
const FieldDef &field, bool is_fixed,
std::vector<std::string> &buffer_constructor,
std::vector<std::string> &base_constructor) {
- auto name = Name(field);
- auto type = GenType(field.value.type);
- code_.SetValue("VALUENAME", name);
+ const auto field_field = namer_.Field(field);
+ const auto field_var = namer_.Variable(field);
+ const auto type = GenType(field.value.type);
+ code_.SetValue("FIELDVAR", field_field);
code_.SetValue("VALUETYPE", type);
std::string is_required = field.IsRequired() ? "" : "?";
switch (field.value.type.base_type) {
case BASE_TYPE_STRUCT: {
- type = GenType(field.value.type, true);
- code_.SetValue("VALUETYPE", type);
- auto optional =
+ const auto objtype = GenType(field.value.type, true);
+ code_.SetValue("VALUETYPE", objtype);
+ const auto optional =
(field.value.type.struct_def && field.value.type.struct_def->fixed);
std::string question_mark =
(field.IsRequired() || (optional && is_fixed) ? "" : "?");
code_ +=
- "{{ACCESS_TYPE}} var {{VALUENAME}}: {{VALUETYPE}}" + question_mark;
- base_constructor.push_back("" + name + " = " + type + "()");
+ "{{ACCESS_TYPE}} var {{FIELDVAR}}: {{VALUETYPE}}" + question_mark;
+ base_constructor.push_back("" + field_var + " = " + objtype + "()");
if (field.value.type.struct_def->fixed) {
- buffer_constructor.push_back("" + name + " = _t." + name);
+ buffer_constructor.push_back("" + field_var + " = _t." + field_field);
} else {
- buffer_constructor.push_back("var __" + name + " = _t." + name);
+ buffer_constructor.push_back("var __" + field_var + " = _t." +
+ field_field);
buffer_constructor.push_back(
- "" + name + " = __" + name +
+ "" + field_var + " = __" + field_var +
(field.IsRequired() ? "!" : question_mark) + ".unpack()");
}
break;
}
case BASE_TYPE_ARRAY: FLATBUFFERS_FALLTHROUGH();
case BASE_TYPE_VECTOR: {
- BuildObjectAPIConstructorBodyVectors(field, name, buffer_constructor,
+ BuildObjectAPIConstructorBodyVectors(field, buffer_constructor,
base_constructor, " ");
break;
}
case BASE_TYPE_STRING: {
- code_ += "{{ACCESS_TYPE}} var {{VALUENAME}}: String" + is_required;
- buffer_constructor.push_back(name + " = _t." + name);
+ code_ += "{{ACCESS_TYPE}} var {{FIELDVAR}}: String" + is_required;
+ buffer_constructor.push_back(field_var + " = _t." + field_field);
if (field.IsRequired()) {
std::string default_value =
field.IsDefault() ? field.value.constant : "";
- base_constructor.push_back(name + " = \"" + default_value + "\"");
+ base_constructor.push_back(field_var + " = \"" + default_value +
+ "\"");
break;
}
if (field.IsDefault() && !field.IsRequired()) {
std::string value = field.IsDefault() ? field.value.constant : "nil";
- base_constructor.push_back(name + " = \"" + value + "\"");
+ base_constructor.push_back(field_var + " = \"" + value + "\"");
}
break;
}
case BASE_TYPE_UTYPE: break;
case BASE_TYPE_UNION: {
- BuildUnionEnumSwitchCase(*field.value.type.enum_def, name,
+ BuildUnionEnumSwitchCase(*field.value.type.enum_def, field_var,
buffer_constructor);
break;
}
default: {
- buffer_constructor.push_back(name + " = _t." + name);
+ buffer_constructor.push_back(field_var + " = _t." + field_field);
std::string nullable = field.IsOptional() ? "?" : "";
if (IsScalar(field.value.type.base_type) &&
!IsBool(field.value.type.base_type) && !IsEnum(field.value.type)) {
- code_ +=
- "{{ACCESS_TYPE}} var {{VALUENAME}}: {{VALUETYPE}}" + nullable;
+ code_ += "{{ACCESS_TYPE}} var {{FIELDVAR}}: {{VALUETYPE}}" + nullable;
if (!field.IsOptional())
- base_constructor.push_back(name + " = " + field.value.constant);
+ base_constructor.push_back(field_var + " = " +
+ field.value.constant);
break;
}
if (IsEnum(field.value.type)) {
- auto default_value = IsEnum(field.value.type)
- ? GenEnumDefaultValue(field)
- : field.value.constant;
- code_ += "{{ACCESS_TYPE}} var {{VALUENAME}}: {{VALUETYPE}}";
- base_constructor.push_back(name + " = " + default_value);
+ const auto default_value = IsEnum(field.value.type)
+ ? GenEnumDefaultValue(field)
+ : field.value.constant;
+ code_ += "{{ACCESS_TYPE}} var {{FIELDVAR}}: {{VALUETYPE}}";
+ base_constructor.push_back(field_var + " = " + default_value);
break;
}
if (IsBool(field.value.type.base_type)) {
- code_ += "{{ACCESS_TYPE}} var {{VALUENAME}}: Bool" + nullable;
+ code_ += "{{ACCESS_TYPE}} var {{FIELDVAR}}: Bool" + nullable;
std::string default_value =
"0" == field.value.constant ? "false" : "true";
if (!field.IsOptional())
- base_constructor.push_back(name + " = " + default_value);
+ base_constructor.push_back(field_var + " = " + default_value);
}
}
}
}
void BuildObjectAPIConstructorBodyVectors(
- const FieldDef &field, const std::string &name,
- std::vector<std::string> &buffer_constructor,
+ const FieldDef &field, std::vector<std::string> &buffer_constructor,
std::vector<std::string> &base_constructor,
const std::string &indentation) {
- auto vectortype = field.value.type.VectorType();
+ const auto vectortype = field.value.type.VectorType();
+ const auto field_var = namer_.Field(field);
+ const auto field_field = namer_.Field(field);
if (vectortype.base_type != BASE_TYPE_UTYPE) {
- buffer_constructor.push_back(name + " = []");
- buffer_constructor.push_back("for index in 0..<_t." + name + "Count {");
- base_constructor.push_back(name + " = []");
+ buffer_constructor.push_back(field_var + " = []");
+ buffer_constructor.push_back("for index in 0..<_t." + field_field +
+ "Count {");
+ base_constructor.push_back(field_var + " = []");
}
switch (vectortype.base_type) {
case BASE_TYPE_STRUCT: {
code_.SetValue("VALUETYPE", GenType(vectortype, true));
- code_ += "{{ACCESS_TYPE}} var {{VALUENAME}}: [{{VALUETYPE}}?]";
+ code_ += "{{ACCESS_TYPE}} var {{FIELDVAR}}: [{{VALUETYPE}}?]";
if (!vectortype.struct_def->fixed) {
- buffer_constructor.push_back(indentation + "var __v_ = _t." + name +
- "(at: index)");
- buffer_constructor.push_back(indentation + name +
+ buffer_constructor.push_back(indentation + "var __v_ = _t." +
+ field_field + "(at: index)");
+ buffer_constructor.push_back(indentation + field_var +
".append(__v_?.unpack())");
} else {
- buffer_constructor.push_back(indentation + name + ".append(_t." +
- name + "(at: index))");
+ buffer_constructor.push_back(indentation + field_var + ".append(_t." +
+ field_var + "(at: index))");
}
break;
}
@@ -1619,7 +1661,7 @@
break;
}
case BASE_TYPE_UNION: {
- BuildUnionEnumSwitchCase(*field.value.type.enum_def, name,
+ BuildUnionEnumSwitchCase(*field.value.type.enum_def, field_var,
buffer_constructor, indentation, true);
break;
}
@@ -1628,18 +1670,18 @@
code_.SetValue(
"VALUETYPE",
(IsString(vectortype) ? "String?" : GenType(vectortype)));
- code_ += "{{ACCESS_TYPE}} var {{VALUENAME}}: [{{VALUETYPE}}]";
+ code_ += "{{ACCESS_TYPE}} var {{FIELDVAR}}: [{{VALUETYPE}}]";
if (IsEnum(vectortype) && vectortype.base_type != BASE_TYPE_UNION) {
- auto default_value = IsEnum(field.value.type)
- ? GenEnumDefaultValue(field)
- : field.value.constant;
- buffer_constructor.push_back(indentation + name + ".append(_t." +
- name + "(at: index)!)");
+ const auto default_value = IsEnum(field.value.type)
+ ? GenEnumDefaultValue(field)
+ : field.value.constant;
+ buffer_constructor.push_back(indentation + field_var + ".append(_t." +
+ field_field + "(at: index)!)");
break;
}
- buffer_constructor.push_back(indentation + name + ".append(_t." + name +
- "(at: index))");
+ buffer_constructor.push_back(indentation + field_var + ".append(_t." +
+ field_field + "(at: index))");
break;
}
}
@@ -1647,19 +1689,17 @@
buffer_constructor.push_back("}");
}
- void BuildUnionEnumSwitchCaseWritter(const EnumDef &ev) {
- auto field_name = Name(ev);
- code_.SetValue("VALUETYPE", field_name);
+ void BuildUnionEnumSwitchCaseWritter(const EnumDef &ed) {
code_ += "switch type {";
- for (auto it = ev.Vals().begin(); it < ev.Vals().end(); ++it) {
- auto field = **it;
- auto ev_name = Name(field);
- auto type = GenType(field.union_type);
- auto is_struct = IsStruct(field.union_type) ? type + Mutable() : type;
- if (field.union_type.base_type == BASE_TYPE_NONE) { continue; }
- code_ += "case ." + ev_name + ":";
+ for (auto it = ed.Vals().begin(); it < ed.Vals().end(); ++it) {
+ const auto ev = **it;
+ const auto variant = namer_.LegacySwiftVariant(ev);
+ const auto type = GenType(ev.union_type);
+ const auto is_struct = IsStruct(ev.union_type) ? type + Mutable() : type;
+ if (ev.union_type.base_type == BASE_TYPE_NONE) { continue; }
+ code_ += "case ." + variant + ":";
Indent();
- code_ += "var __obj = value as? " + GenType(field.union_type, true);
+ code_ += "var __obj = value as? " + GenType(ev.union_type, true);
code_ += "return " + is_struct + ".pack(&builder, obj: &__obj)";
Outdent();
}
@@ -1667,34 +1707,34 @@
code_ += "}";
}
- void BuildUnionEnumSwitchCase(const EnumDef &ev, const std::string &name,
+ void BuildUnionEnumSwitchCase(const EnumDef &ed, const std::string &field,
std::vector<std::string> &buffer_constructor,
const std::string &indentation = "",
const bool is_vector = false) {
- auto field_name = NameWrappedInNameSpace(ev);
- code_.SetValue("VALUETYPE", field_name);
- code_ += "{{ACCESS_TYPE}} var {{VALUENAME}}: \\";
+ const auto ns_type = namer_.NamespacedType(ed);
+ code_.SetValue("VALUETYPE", ns_type);
+ code_ += "{{ACCESS_TYPE}} var {{FIELDVAR}}: \\";
code_ += is_vector ? "[{{VALUETYPE}}Union?]" : "{{VALUETYPE}}Union?";
- auto vector_reader = is_vector ? "(at: index" : "";
- buffer_constructor.push_back(indentation + "switch _t." + name + "Type" +
+ const auto vector_reader = is_vector ? "(at: index" : "";
+ buffer_constructor.push_back(indentation + "switch _t." + field + "Type" +
vector_reader + (is_vector ? ")" : "") + " {");
- for (auto it = ev.Vals().begin(); it < ev.Vals().end(); ++it) {
- auto field = **it;
- auto ev_name = Name(field);
- if (field.union_type.base_type == BASE_TYPE_NONE) { continue; }
- auto type = IsStruct(field.union_type)
- ? GenType(field.union_type) + Mutable()
- : GenType(field.union_type);
- buffer_constructor.push_back(indentation + "case ." + ev_name + ":");
+ for (auto it = ed.Vals().begin(); it < ed.Vals().end(); ++it) {
+ const auto ev = **it;
+ const auto variant = namer_.LegacySwiftVariant(ev);
+ if (ev.union_type.base_type == BASE_TYPE_NONE) { continue; }
+ const auto type = IsStruct(ev.union_type)
+ ? GenType(ev.union_type) + Mutable()
+ : GenType(ev.union_type);
+ buffer_constructor.push_back(indentation + "case ." + variant + ":");
buffer_constructor.push_back(
- indentation + " var _v = _t." + name + (is_vector ? "" : "(") +
+ indentation + " var _v = _t." + field + (is_vector ? "" : "(") +
vector_reader + (is_vector ? ", " : "") + "type: " + type + ".self)");
- auto constructor =
- field_name + "Union(_v?.unpack(), type: ." + ev_name + ")";
+ const auto constructor =
+ ns_type + "Union(_v?.unpack(), type: ." + variant + ")";
buffer_constructor.push_back(
- indentation + " " + name +
+ indentation + " " + field +
(is_vector ? ".append(" + constructor + ")" : " = " + constructor));
}
buffer_constructor.push_back(indentation + "default: break");
@@ -1702,13 +1742,14 @@
}
void AddMinOrMaxEnumValue(const std::string &str, const std::string &type) {
- auto current_value = str;
+ const auto current_value = str;
code_.SetValue(type, current_value);
code_ += "{{ACCESS_TYPE}} static var " + type +
": {{ENUM_NAME}} { return .{{" + type + "}} }";
}
- void GenLookup(const FieldDef &key_field) {
+ void GenLookup(const FieldDef &key_field, const std::string &struct_type) {
+ code_.SetValue("STRUCTTYPE", struct_type);
code_.SetValue("OFFSET", NumToString(key_field.value.offset));
std::string offset_reader =
"Table.offset(Int32(fbb.capacity) - tableOffset, vOffset: {{OFFSET}}, "
@@ -1718,7 +1759,7 @@
code_ +=
"fileprivate static func lookupByKey(vector: Int32, key: {{TYPE}}, "
"fbb: "
- "ByteBuffer) -> {{VALUENAME}}? {";
+ "ByteBuffer) -> {{STRUCTTYPE}}? {";
Indent();
if (IsString(key_field.value.type))
code_ += "let key = key.utf8.map { $0 }";
@@ -1748,7 +1789,7 @@
Outdent();
code_ += "} else {";
Indent();
- code_ += "return {{VALUENAME}}(fbb, o: tableOffset)";
+ code_ += "return {{STRUCTTYPE}}(fbb, o: tableOffset)";
Outdent();
code_ += "}";
Outdent();
@@ -1762,7 +1803,7 @@
if (field.padding) {
for (int i = 0; i < 4; i++) {
if (static_cast<int>(field.padding) & (1 << i)) {
- auto bits = (1 << i) * 8;
+ const auto bits = (1 << i) * 8;
code_ += "private let padding" + NumToString((*id)++) + "__: UInt" +
NumToString(bits) + " = 0";
}
@@ -1784,8 +1825,7 @@
}
std::string GenReaderMainBody(const std::string &optional = "") {
- return "{{ACCESS_TYPE}} var {{VALUENAME}}: {{VALUETYPE}}" + optional +
- " { ";
+ return "{{ACCESS_TYPE}} var {{FIELDVAR}}: {{VALUETYPE}}" + optional + " { ";
}
std::string GenReader(const std::string &type,
@@ -1799,36 +1839,33 @@
std::string GenMutate(const std::string &offset,
const std::string &get_offset, bool isRaw = false) {
- return "@discardableResult {{ACCESS_TYPE}} func mutate({{VALUENAME}}: "
+ return "@discardableResult {{ACCESS_TYPE}} func mutate({{FIELDVAR}}: "
"{{VALUETYPE}}) -> Bool {" +
- get_offset + " return {{ACCESS}}.mutate({{VALUENAME}}" +
+ get_offset + " return {{ACCESS}}.mutate({{FIELDVAR}}" +
(isRaw ? ".rawValue" : "") + ", index: " + offset + ") }";
}
std::string GenMutateArray() {
- return "{{ACCESS_TYPE}} func mutate({{VALUENAME}}: {{VALUETYPE}}, at "
- "index: "
- "Int32) -> Bool { " +
+ return "{{ACCESS_TYPE}} func mutate({{FIELDVAR}}: {{VALUETYPE}}, at "
+ "index: Int32) -> Bool { " +
GenOffset() +
- "return {{ACCESS}}.directMutate({{VALUENAME}}, index: "
+ "return {{ACCESS}}.directMutate({{FIELDVAR}}, index: "
"{{ACCESS}}.vector(at: o) + index * {{SIZE}}) }";
}
std::string GenEnumDefaultValue(const FieldDef &field) {
- auto &value = field.value;
+ const auto &value = field.value;
FLATBUFFERS_ASSERT(value.type.enum_def);
- auto &enum_def = *value.type.enum_def;
+ const auto &enum_def = *value.type.enum_def;
// Vector of enum defaults are always "[]" which never works.
const std::string constant = IsVector(value.type) ? "0" : value.constant;
- auto enum_val = enum_def.FindByValue(constant);
- std::string name;
+ const auto enum_val = enum_def.FindByValue(constant);
if (enum_val) {
- name = Name(*enum_val);
+ return "." + namer_.LegacySwiftVariant(*enum_val);
} else {
const auto &ev = **enum_def.Vals().begin();
- name = Name(ev);
+ return "." + namer_.LegacySwiftVariant(ev);
}
- return "." + name;
}
std::string GenEnumConstructor(const std::string &at) {
@@ -1836,15 +1873,14 @@
}
std::string ValidateFunc() {
- return "static func validateVersion() { FlatBuffersVersion_2_0_0() }";
+ return "static func validateVersion() { FlatBuffersVersion_2_0_8() }";
}
std::string GenType(const Type &type,
const bool should_consider_suffix = false) const {
- return IsScalar(type.base_type)
- ? GenTypeBasic(type)
- : (IsArray(type) ? GenType(type.VectorType())
- : GenTypePointer(type, should_consider_suffix));
+ return IsScalar(type.base_type) ? GenTypeBasic(type)
+ : IsArray(type) ? GenType(type.VectorType())
+ : GenTypePointer(type, should_consider_suffix);
}
std::string GenTypePointer(const Type &type,
@@ -1853,12 +1889,11 @@
case BASE_TYPE_STRING: return "String";
case BASE_TYPE_VECTOR: return GenType(type.VectorType());
case BASE_TYPE_STRUCT: {
- auto &struct_ = *type.struct_def;
- if (should_consider_suffix && !struct_.fixed) {
- return WrapInNameSpace(struct_.defined_namespace,
- ObjectAPIName(Name(struct_)));
+ const auto &sd = *type.struct_def;
+ if (should_consider_suffix && !sd.fixed) {
+ return namer_.NamespacedObjectType(sd);
}
- return WrapInNameSpace(struct_.defined_namespace, Name(struct_));
+ return namer_.NamespacedType(sd);
}
case BASE_TYPE_UNION:
default: return "FlatbuffersInitializable";
@@ -1869,22 +1904,10 @@
return GenTypeBasic(type, true);
}
- std::string ObjectAPIName(const std::string &name) const {
- return parser_.opts.object_prefix + name + parser_.opts.object_suffix;
- }
-
void Indent() { code_.IncrementIdentLevel(); }
void Outdent() { code_.DecrementIdentLevel(); }
- std::string NameWrappedInNameSpace(const EnumDef &enum_def) const {
- return WrapInNameSpace(enum_def.defined_namespace, Name(enum_def));
- }
-
- std::string NameWrappedInNameSpace(const StructDef &struct_def) const {
- return WrapInNameSpace(struct_def.defined_namespace, Name(struct_def));
- }
-
std::string GenTypeBasic(const Type &type, bool can_override) const {
// clang-format off
static const char * const swift_type[] = {
@@ -1896,29 +1919,15 @@
};
// clang-format on
if (can_override) {
- if (type.enum_def) return NameWrappedInNameSpace(*type.enum_def);
+ if (type.enum_def) return namer_.NamespacedType(*type.enum_def);
if (type.base_type == BASE_TYPE_BOOL) return "Bool";
}
return swift_type[static_cast<int>(type.base_type)];
}
- std::string EscapeKeyword(const std::string &name) const {
- return keywords_.find(name) == keywords_.end() ? name : name + "_";
- }
-
std::string Mutable() const { return "_Mutable"; }
- std::string Name(const EnumVal &ev) const {
- auto name = ev.name;
- if (isupper(name.front())) {
- std::transform(name.begin(), name.end(), name.begin(), CharToLower);
- }
- return EscapeKeyword(ConvertCase(name, Case::kLowerCamel));
- }
-
- std::string Name(const Definition &def) const {
- return EscapeKeyword(ConvertCase(def.name, Case::kLowerCamel));
- }
+ IdlNamer namer_;
};
} // namespace swift
bool GenerateSwift(const Parser &parser, const std::string &path,
diff --git a/src/idl_gen_text.cpp b/src/idl_gen_text.cpp
index 805e934..3b69c95 100644
--- a/src/idl_gen_text.cpp
+++ b/src/idl_gen_text.cpp
@@ -248,11 +248,23 @@
template<typename T>
bool GenField(const FieldDef &fd, const Table *table, bool fixed,
int indent) {
- return PrintScalar(
- fixed ? reinterpret_cast<const Struct *>(table)->GetField<T>(
- fd.value.offset)
- : table->GetField<T>(fd.value.offset, GetFieldDefault<T>(fd)),
- fd.value.type, indent);
+ if (fixed) {
+ return PrintScalar(
+ reinterpret_cast<const Struct *>(table)->GetField<T>(fd.value.offset),
+ fd.value.type, indent);
+ } else if (fd.IsOptional()) {
+ auto opt = table->GetOptional<T, T>(fd.value.offset);
+ if (opt) {
+ return PrintScalar(*opt, fd.value.type, indent);
+ } else {
+ text += "null";
+ return true;
+ }
+ } else {
+ return PrintScalar(
+ table->GetField<T>(fd.value.offset, GetFieldDefault<T>(fd)),
+ fd.value.type, indent);
+ }
}
// Generate text for non-scalar field.
diff --git a/src/idl_gen_ts.cpp b/src/idl_gen_ts.cpp
index faf4345..32ab863 100644
--- a/src/idl_gen_ts.cpp
+++ b/src/idl_gen_ts.cpp
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-// independent from idl_parser, since this code is not needed for most clients
#include <algorithm>
#include <cassert>
#include <unordered_map>
@@ -24,21 +23,67 @@
#include "flatbuffers/flatbuffers.h"
#include "flatbuffers/idl.h"
#include "flatbuffers/util.h"
+#include "idl_namer.h"
namespace flatbuffers {
-
+namespace {
struct ImportDefinition {
std::string name;
std::string import_statement;
std::string export_statement;
std::string bare_file_path;
std::string rel_file_path;
+ std::string object_name;
const Definition *dependent = nullptr;
const Definition *dependency = nullptr;
};
+Namer::Config TypeScriptDefaultConfig() {
+ return { /*types=*/Case::kKeep,
+ /*constants=*/Case::kUnknown,
+ /*methods=*/Case::kLowerCamel,
+ /*functions=*/Case::kLowerCamel,
+ /*fields=*/Case::kLowerCamel,
+ /*variables=*/Case::kLowerCamel,
+ /*variants=*/Case::kKeep,
+ /*enum_variant_seperator=*/"::",
+ /*escape_keywords=*/Namer::Config::Escape::AfterConvertingCase,
+ /*namespaces=*/Case::kKeep,
+ /*namespace_seperator=*/"_",
+ /*object_prefix=*/"",
+ /*object_suffix=*/"T",
+ /*keyword_prefix=*/"",
+ /*keyword_suffix=*/"_",
+ /*filenames=*/Case::kDasher,
+ /*directories=*/Case::kDasher,
+ /*output_path=*/"",
+ /*filename_suffix=*/"_generated",
+ /*filename_extension=*/".ts" };
+}
+
+std::set<std::string> TypescriptKeywords() {
+ // List of keywords retrieved from here:
+ // https://github.com/microsoft/TypeScript/issues/2536
+ return {
+ "arguments", "break", "case", "catch", "class", "const",
+ "continue", "debugger", "default", "delete", "do", "else",
+ "enum", "export", "extends", "false", "finally", "for",
+ "function", "if", "import", "in", "instanceof", "new",
+ "null", "Object", "return", "super", "switch", "this",
+ "throw", "true", "try", "typeof", "var", "void",
+ "while", "with", "as", "implements", "interface", "let",
+ "package", "private", "protected", "public", "static", "yield",
+ };
+}
+
enum AnnotationType { kParam = 0, kType = 1, kReturns = 2 };
+template<typename T> struct SupportsObjectAPI : std::false_type {};
+
+template<> struct SupportsObjectAPI<StructDef> : std::true_type {};
+
+} // namespace
+
namespace ts {
// Iterate through all definitions we haven't generate code for (enums, structs,
// and tables) and output them to a single file.
@@ -48,83 +93,53 @@
TsGenerator(const Parser &parser, const std::string &path,
const std::string &file_name)
- : BaseGenerator(parser, path, file_name, "", ".", "ts") {
- // clang-format off
+ : BaseGenerator(parser, path, file_name, "", "_", "ts"),
+ namer_(WithFlagOptions(TypeScriptDefaultConfig(), parser.opts, path),
+ TypescriptKeywords()) {}
- // List of keywords retrieved from here:
- // https://github.com/microsoft/TypeScript/issues/2536
- // One per line to ease comparisons to that list are easier
- static const char *const keywords[] = {
- "argument",
- "break",
- "case",
- "catch",
- "class",
- "const",
- "continue",
- "debugger",
- "default",
- "delete",
- "do",
- "else",
- "enum",
- "export",
- "extends",
- "false",
- "finally",
- "for",
- "function",
- "if",
- "import",
- "in",
- "instanceof",
- "new",
- "null",
- "Object",
- "return",
- "super",
- "switch",
- "this",
- "throw",
- "true",
- "try",
- "typeof",
- "var",
- "void",
- "while",
- "with",
- "as",
- "implements",
- "interface",
- "let",
- "package",
- "private",
- "protected",
- "public",
- "static",
- "yield",
- nullptr,
- // clang-format on
- };
-
- for (auto kw = keywords; *kw; kw++) keywords_.insert(*kw);
- }
bool generate() {
- if (parser_.opts.ts_flat_file && parser_.opts.generate_all) {
- // Not implemented; warning message should have beem emitted by flatc.
- return false;
- }
generateEnums();
generateStructs();
generateEntry();
return true;
}
+ bool IncludeNamespace() const {
+ // When generating a single flat file and all its includes, namespaces are
+ // important to avoid type name clashes.
+ return parser_.opts.ts_flat_file && parser_.opts.generate_all;
+ }
+
+ std::string GetTypeName(const EnumDef &def, const bool = false,
+ const bool force_ns_wrap = false) {
+ if (IncludeNamespace() || force_ns_wrap) {
+ return namer_.NamespacedType(def);
+ }
+ return namer_.Type(def);
+ }
+
+ std::string GetTypeName(const StructDef &def, const bool object_api = false,
+ const bool force_ns_wrap = false) {
+ if (object_api && parser_.opts.generate_object_based_api) {
+ if (IncludeNamespace() || force_ns_wrap) {
+ return namer_.NamespacedObjectType(def);
+ } else {
+ return namer_.ObjectType(def);
+ }
+ } else {
+ if (IncludeNamespace() || force_ns_wrap) {
+ return namer_.NamespacedType(def);
+ } else {
+ return namer_.Type(def);
+ }
+ }
+ }
+
// Save out the generated code for a single class while adding
// declaration boilerplate.
- bool SaveType(const Definition &definition, const std::string &classcode,
+ bool SaveType(const Definition &definition, const std::string &class_code,
import_set &imports, import_set &bare_imports) {
- if (!classcode.length()) return true;
+ if (!class_code.length()) return true;
std::string code;
@@ -144,25 +159,24 @@
if (!imports.empty()) code += "\n\n";
}
- code += classcode;
- auto filename =
- NamespaceDir(*definition.defined_namespace, true) +
- ConvertCase(definition.name, Case::kDasher, Case::kUpperCamel) + ".ts";
+ code += class_code;
+
if (parser_.opts.ts_flat_file) {
flat_file_ += code;
+ flat_file_ += "\n";
flat_file_definitions_.insert(&definition);
return true;
} else {
- return SaveFile(filename.c_str(), code, false);
+ auto dirs = namer_.Directories(*definition.defined_namespace);
+ EnsureDirExists(dirs);
+ auto basename = dirs + namer_.File(definition, SkipFile::Suffix);
+
+ return SaveFile(basename.c_str(), code, false);
}
}
private:
- std::unordered_set<std::string> keywords_;
-
- std::string EscapeKeyword(const std::string &name) const {
- return keywords_.find(name) == keywords_.end() ? name : name + "_";
- }
+ IdlNamer namer_;
import_set imports_all_;
@@ -177,6 +191,10 @@
// This maps from import names to types to import.
std::map<std::string, std::map<std::string, std::string>>
flat_file_import_declarations_;
+ // For flat file codegen, tracks whether we need to import the flatbuffers
+ // library itself (not necessary for files that solely consist of enum
+ // definitions).
+ bool import_flatbuffers_lib_ = false;
// Generate code for all enums.
void generateEnums() {
@@ -200,6 +218,7 @@
import_set bare_imports;
import_set imports;
AddImport(bare_imports, "* as flatbuffers", "flatbuffers");
+ import_flatbuffers_lib_ = true;
auto &struct_def = **it;
std::string declcode;
GenStruct(parser_, struct_def, &declcode, imports);
@@ -210,38 +229,45 @@
// Generate code for a single entry point module.
void generateEntry() {
- std::string code;
+ std::string code =
+ "// " + std::string(FlatBuffersGeneratedWarning()) + "\n\n";
if (parser_.opts.ts_flat_file) {
- code += "import * as flatbuffers from 'flatbuffers';\n";
- for (const auto &it : flat_file_import_declarations_) {
- // Note that we do end up generating an import for ourselves, which
- // should generally be harmless.
- // TODO: Make it so we don't generate a self-import; this will also
- // require modifying AddImport to ensure that we don't use
- // namespace-prefixed names anywhere...
- std::string file = it.first;
- if (file.empty()) {
- continue;
- }
- std::string noext = flatbuffers::StripExtension(file);
- std::string basename = flatbuffers::StripPath(noext);
- std::string include_file = GeneratedFileName(
- parser_.opts.include_prefix,
- parser_.opts.keep_include_path ? noext : basename, parser_.opts);
- // TODO: what is the right behavior when different include flags are
- // specified here? Should we always be adding the "./" for a relative
- // path or turn it off if --include-prefix is specified, or something
- // else?
- std::string include_name = "./" + flatbuffers::StripExtension(include_file);
- code += "import {";
- for (const auto &pair : it.second) {
- code += EscapeKeyword(pair.first) + " as " +
- EscapeKeyword(pair.second) + ", ";
- }
- code.resize(code.size() - 2);
- code += "} from '" + include_name + "';\n";
+ if (import_flatbuffers_lib_) {
+ code += "import * as flatbuffers from 'flatbuffers';\n";
+ code += "\n";
}
- code += "\n\n";
+ // Only include import statements when not generating all.
+ if (!parser_.opts.generate_all) {
+ for (const auto &it : flat_file_import_declarations_) {
+ // Note that we do end up generating an import for ourselves, which
+ // should generally be harmless.
+ // TODO: Make it so we don't generate a self-import; this will also
+ // require modifying AddImport to ensure that we don't use
+ // namespace-prefixed names anywhere...
+ std::string file = it.first;
+ if (file.empty()) { continue; }
+ std::string noext = flatbuffers::StripExtension(file);
+ std::string basename = flatbuffers::StripPath(noext);
+ std::string include_file = GeneratedFileName(
+ parser_.opts.include_prefix,
+ parser_.opts.keep_prefix ? noext : basename, parser_.opts);
+ // TODO: what is the right behavior when different include flags are
+ // specified here? Should we always be adding the "./" for a relative
+ // path or turn it off if --include-prefix is specified, or something
+ // else?
+ std::string include_name =
+ "./" + flatbuffers::StripExtension(include_file);
+ code += "import {";
+ for (const auto &pair : it.second) {
+ code += namer_.EscapeKeyword(pair.first) + " as " +
+ namer_.EscapeKeyword(pair.second) + ", ";
+ }
+ code.resize(code.size() - 2);
+ code += "} from '" + include_name + ".js';\n";
+ }
+ code += "\n";
+ }
+
code += flat_file_;
const std::string filename =
GeneratedFileName(path_, file_name_, parser_.opts);
@@ -250,7 +276,8 @@
for (auto it = imports_all_.begin(); it != imports_all_.end(); it++) {
code += it->second.export_statement + "\n";
}
- std::string path = "./" + path_ + file_name_ + ".ts";
+ const std::string path =
+ GeneratedFileName(path_, file_name_, parser_.opts);
SaveFile(path.c_str(), code, false);
}
}
@@ -286,7 +313,9 @@
if (reverse) return; // FIXME.
std::string &code = *code_ptr;
GenDocComment(enum_def.doc_comment, code_ptr);
- code += "export enum " + EscapeKeyword(enum_def.name) + "{\n";
+ code += "export enum ";
+ code += GetTypeName(enum_def);
+ code += " {\n";
for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end(); ++it) {
auto &ev = **it;
if (!ev.doc_comment.empty()) {
@@ -294,15 +323,13 @@
GenDocComment(ev.doc_comment, code_ptr, " ");
}
- const std::string escaped_name = EscapeKeyword(ev.name);
-
// Generate mapping between EnumName: EnumValue(int)
if (reverse) {
code += " '" + enum_def.ToString(ev) + "'";
code += " = ";
- code += "'" + escaped_name + "'";
+ code += "'" + namer_.Variant(ev) + "'";
} else {
- code += " " + escaped_name;
+ code += " " + namer_.Variant(ev);
code += " = ";
// Unfortunately, because typescript does not support bigint enums,
// for 64-bit enums, we instead map the enum names to strings.
@@ -324,7 +351,7 @@
code += GenUnionConvFunc(enum_def.underlying_type, imports);
}
- code += "\n\n";
+ code += "\n";
}
static std::string GenType(const Type &type) {
@@ -359,8 +386,8 @@
return GenBBAccess() + ".__union_with_string" + arguments;
case BASE_TYPE_VECTOR: return GenGetter(type.VectorType(), arguments);
default: {
- auto getter = GenBBAccess() + ".read" +
- ConvertCase(GenType(type), Case::kUpperCamel) + arguments;
+ auto getter = GenBBAccess() + "." +
+ namer_.Method("read_" + GenType(type)) + arguments;
if (type.base_type == BASE_TYPE_BOOL) { getter = "!!" + getter; }
return getter;
}
@@ -385,9 +412,10 @@
}
default: {
if (auto val = value.type.enum_def->FindByValue(value.constant)) {
- return EscapeKeyword(AddImport(imports, *value.type.enum_def,
- *value.type.enum_def)) +
- "." + EscapeKeyword(val->name);
+ return AddImport(imports, *value.type.enum_def,
+ *value.type.enum_def)
+ .name +
+ "." + namer_.Variant(*val);
} else {
return value.constant;
}
@@ -411,7 +439,9 @@
return "BigInt('" + value.constant + "')";
}
- default: return value.constant;
+ default:
+ if (value.constant == "nan") { return "NaN"; }
+ return value.constant;
}
}
@@ -424,7 +454,7 @@
if (IsString(type)) {
name = "string|Uint8Array";
} else {
- name = EscapeKeyword(AddImport(imports, owner, *type.struct_def));
+ name = AddImport(imports, owner, *type.struct_def).name;
}
return allowNull ? (name + "|null") : name;
}
@@ -437,7 +467,8 @@
default:
if (IsScalar(type.base_type)) {
if (type.enum_def) {
- const auto enum_name = AddImport(imports, owner, *type.enum_def);
+ const auto enum_name =
+ AddImport(imports, owner, *type.enum_def).name;
return allowNull ? (enum_name + "|null") : enum_name;
}
return allowNull ? "number|null" : "number";
@@ -447,7 +478,7 @@
}
// Returns the method name for use with add/put calls.
- static std::string GenWriteMethod(const Type &type) {
+ std::string GenWriteMethod(const Type &type) {
// Forward to signed versions since unsigned versions don't exist
switch (type.base_type) {
case BASE_TYPE_UTYPE:
@@ -458,9 +489,8 @@
default: break;
}
- return IsScalar(type.base_type)
- ? ConvertCase(GenType(type), Case::kUpperCamel)
- : (IsStruct(type) ? "Struct" : "Offset");
+ return IsScalar(type.base_type) ? namer_.Type(GenType(type))
+ : (IsStruct(type) ? "Struct" : "Offset");
}
template<typename T> static std::string MaybeAdd(T value) {
@@ -490,8 +520,8 @@
}
}
- static void GenStructBody(const StructDef &struct_def, std::string *body,
- const std::string &nameprefix) {
+ void GenStructBody(const StructDef &struct_def, std::string *body,
+ const std::string &nameprefix) {
*body += " builder.prep(";
*body += NumToString(struct_def.minalign) + ", ";
*body += NumToString(struct_def.bytesize) + ");\n";
@@ -517,7 +547,7 @@
}
std::string GenerateNewExpression(const std::string &object_name) {
- return "new " + EscapeKeyword(object_name) + "()";
+ return "new " + namer_.Type(object_name) + "()";
}
void GenerateRootAccessor(StructDef &struct_def, std::string *code_ptr,
@@ -563,16 +593,6 @@
}
}
- static std::string GetObjApiClassName(const StructDef &sd,
- const IDLOptions &opts) {
- return GetObjApiClassName(sd.name, opts);
- }
-
- static std::string GetObjApiClassName(const std::string &name,
- const IDLOptions &opts) {
- return opts.object_prefix + name + opts.object_suffix;
- }
-
bool UnionHasStringType(const EnumDef &union_enum) {
return std::any_of(union_enum.Vals().begin(), union_enum.Vals().end(),
[](const EnumVal *ev) {
@@ -601,7 +621,7 @@
if (IsString(ev.union_type)) {
type = "string"; // no need to wrap string type in namespace
} else if (ev.union_type.base_type == BASE_TYPE_STRUCT) {
- type = AddImport(imports, union_enum, *ev.union_type.struct_def);
+ type = AddImport(imports, union_enum, *ev.union_type.struct_def).name;
} else {
FLATBUFFERS_ASSERT(false);
}
@@ -615,156 +635,140 @@
return ret;
}
- std::string AddImport(import_set &imports, const Definition &dependent,
- const StructDef &dependency) {
- std::string ns;
- const auto &depc_comps = dependency.defined_namespace->components;
- for (auto it = depc_comps.begin(); it != depc_comps.end(); it++) {
- ns += *it;
- }
- std::string unique_name = ns + dependency.name;
- std::string import_name = dependency.name;
- std::string long_import_name;
- if (imports.find(unique_name) != imports.end())
- return imports.find(unique_name)->second.name;
+ static bool CheckIfNameClashes(const import_set &imports,
+ const std::string &name) {
+ // TODO: this would be better as a hashset.
for (auto it = imports.begin(); it != imports.end(); it++) {
- if (it->second.name == import_name) {
- long_import_name = ns + import_name;
- break;
- }
+ if (it->second.name == name) { return true; }
}
-
- if (parser_.opts.ts_flat_file) {
- std::string file = dependency.declaration_file == nullptr
- ? dependency.file
- : dependency.declaration_file->substr(2);
- file = RelativeToRootPath(StripFileName(AbsolutePath(dependent.file)),
- dependency.file).substr(2);
- long_import_name = ns + import_name;
- flat_file_import_declarations_[file][import_name] = long_import_name;
- if (parser_.opts.generate_object_based_api) {
- flat_file_import_declarations_[file][import_name + "T"] = long_import_name + "T";
- }
- }
-
- std::string import_statement;
- std::string export_statement;
- import_statement += "import { ";
- export_statement += "export { ";
- std::string symbols_expression;
- if (long_import_name.empty()) {
- symbols_expression += EscapeKeyword(import_name);
- if (parser_.opts.generate_object_based_api)
- symbols_expression += ", " + import_name + "T";
- } else {
- symbols_expression += EscapeKeyword(dependency.name) + " as " +
- EscapeKeyword(long_import_name);
- if (parser_.opts.generate_object_based_api)
- symbols_expression +=
- ", " + dependency.name + "T as " + long_import_name + "T";
- }
- import_statement += symbols_expression + " } from '";
- export_statement += symbols_expression + " } from '";
- std::string bare_file_path;
- std::string rel_file_path;
- const auto &dep_comps = dependent.defined_namespace->components;
- for (size_t i = 0; i < dep_comps.size(); i++)
- rel_file_path += i == 0 ? ".." : (kPathSeparator + std::string(".."));
- if (dep_comps.size() == 0) rel_file_path += ".";
- for (auto it = depc_comps.begin(); it != depc_comps.end(); it++)
- bare_file_path +=
- kPathSeparator + ConvertCase(*it, Case::kDasher, Case::kUpperCamel);
- bare_file_path +=
- kPathSeparator +
- ConvertCase(dependency.name, Case::kDasher, Case::kUpperCamel);
- rel_file_path += bare_file_path;
- import_statement += rel_file_path + "';";
- export_statement += "." + bare_file_path + "';";
- ImportDefinition import;
- import.name = long_import_name.empty() ? import_name : long_import_name;
- import.bare_file_path = bare_file_path;
- import.rel_file_path = rel_file_path;
- import.import_statement = import_statement;
- import.export_statement = export_statement;
- import.dependency = &dependency;
- import.dependent = &dependent;
- imports.insert(std::make_pair(unique_name, import));
- return import.name;
+ return false;
}
- // TODO: largely (but not identical) duplicated code from above couln't find a
- // good way to refactor
- std::string AddImport(import_set &imports, const Definition &dependent,
- const EnumDef &dependency) {
- std::string ns;
- const auto &depc_comps = dependency.defined_namespace->components;
- for (auto it = depc_comps.begin(); it != depc_comps.end(); it++) {
- ns += *it;
- }
- std::string unique_name = ns + dependency.name;
- std::string import_name = EscapeKeyword(dependency.name);
- std::string long_import_name;
- if (imports.find(unique_name) != imports.end()) {
- return imports.find(unique_name)->second.name;
- }
- for (auto it = imports.begin(); it != imports.end(); it++) {
- if (it->second.name == import_name) {
- long_import_name = ns + import_name;
- break;
+ std::string GenSymbolExpression(const StructDef &struct_def,
+ const bool has_name_clash,
+ const std::string &import_name,
+ const std::string &name,
+ const std::string &object_name) {
+ std::string symbols_expression;
+
+ if (has_name_clash) {
+ // We have a name clash
+ symbols_expression += import_name + " as " + name;
+
+ if (parser_.opts.generate_object_based_api) {
+ symbols_expression += ", " +
+ GetTypeName(struct_def, /*object_api =*/true) +
+ " as " + object_name;
+ }
+ } else {
+ // No name clash, use the provided name
+ symbols_expression += name;
+
+ if (parser_.opts.generate_object_based_api) {
+ symbols_expression += ", " + object_name;
}
}
- if (parser_.opts.ts_flat_file) {
- std::string file = dependency.declaration_file == nullptr
- ? dependency.file
- : dependency.declaration_file->substr(2);
- file = RelativeToRootPath(StripFileName(AbsolutePath(dependent.file)),
- dependency.file).substr(2);
- long_import_name = ns + import_name;
- flat_file_import_declarations_[file][import_name] = long_import_name;
+ return symbols_expression;
+ }
+
+ std::string GenSymbolExpression(const EnumDef &enum_def,
+ const bool has_name_clash,
+ const std::string &import_name,
+ const std::string &name,
+ const std::string &) {
+ std::string symbols_expression;
+ if (has_name_clash) {
+ symbols_expression += import_name + " as " + name;
+ } else {
+ symbols_expression += name;
}
- std::string import_statement;
- std::string export_statement;
- import_statement += "import { ";
- export_statement += "export { ";
- std::string symbols_expression;
- if (long_import_name.empty())
- symbols_expression += import_name;
- else
- symbols_expression += EscapeKeyword(dependency.name) + " as " +
- EscapeKeyword(long_import_name);
- if (dependency.is_union) {
- symbols_expression += ", unionTo" + import_name;
- symbols_expression += ", unionListTo" + import_name;
+ if (enum_def.is_union) {
+ symbols_expression += ", unionTo" + name;
+ symbols_expression += ", unionListTo" + name;
}
- import_statement += symbols_expression + " } from '";
- export_statement += symbols_expression + " } from '";
+
+ return symbols_expression;
+ }
+
+ template<typename DefinitionT>
+ ImportDefinition AddImport(import_set &imports, const Definition &dependent,
+ const DefinitionT &dependency) {
+ // The unique name of the dependency, fully qualified in its namespace.
+ const std::string unique_name = GetTypeName(
+ dependency, /*object_api = */ false, /*force_ns_wrap=*/true);
+
+ // Look if we have already added this import and return its name if found.
+ const auto import_pair = imports.find(unique_name);
+ if (import_pair != imports.end()) { return import_pair->second; }
+
+ // Check if this name would have a name clash with another type. Just use
+ // the "base" name (properly escaped) without any namespacing applied.
+ const std::string import_name = GetTypeName(dependency);
+ const bool has_name_clash = CheckIfNameClashes(imports, import_name);
+
+ // If we have a name clash, use the unique name, otherwise use simple name.
+ std::string name = has_name_clash ? unique_name : import_name;
+
+ const std::string object_name =
+ GetTypeName(dependency, /*object_api=*/true, has_name_clash);
+
+ if (parser_.opts.ts_flat_file) {
+ // In flat-file generation, do not attempt to import things from ourselves
+ // *and* do not wrap namespaces (note that this does override the logic
+ // above, but since we force all non-self-imports to use namespace-based
+ // names in flat file generation, it's fine).
+ if (dependent.file == dependency.file) {
+ name = import_name;
+ } else {
+ const std::string file =
+ RelativeToRootPath(StripFileName(AbsolutePath(dependent.file)),
+ dependency.file)
+ // Strip the leading //
+ .substr(2);
+ flat_file_import_declarations_[file][import_name] = name;
+
+ if (parser_.opts.generate_object_based_api &&
+ SupportsObjectAPI<DefinitionT>::value) {
+ flat_file_import_declarations_[file][import_name + "T"] = object_name;
+ }
+ }
+ }
+
+ const std::string symbols_expression = GenSymbolExpression(
+ dependency, has_name_clash, import_name, name, object_name);
+
std::string bare_file_path;
std::string rel_file_path;
const auto &dep_comps = dependent.defined_namespace->components;
- for (size_t i = 0; i < dep_comps.size(); i++)
+ for (size_t i = 0; i < dep_comps.size(); i++) {
rel_file_path += i == 0 ? ".." : (kPathSeparator + std::string(".."));
- if (dep_comps.size() == 0) rel_file_path += ".";
- for (auto it = depc_comps.begin(); it != depc_comps.end(); it++)
- bare_file_path +=
- kPathSeparator + ConvertCase(*it, Case::kDasher, Case::kUpperCamel);
+ }
+ if (dep_comps.size() == 0) { rel_file_path += "."; }
+
bare_file_path +=
kPathSeparator +
- ConvertCase(dependency.name, Case::kDasher, Case::kUpperCamel);
+ namer_.Directories(dependency.defined_namespace->components,
+ SkipDir::OutputPath) +
+ namer_.File(dependency, SkipFile::SuffixAndExtension);
rel_file_path += bare_file_path;
- import_statement += rel_file_path + "';";
- export_statement += "." + bare_file_path + "';";
+
ImportDefinition import;
- import.name = long_import_name.empty() ? import_name : long_import_name;
+ import.name = name;
+ import.object_name = object_name;
import.bare_file_path = bare_file_path;
import.rel_file_path = rel_file_path;
- import.import_statement = import_statement;
- import.export_statement = export_statement;
+ import.import_statement =
+ "import { " + symbols_expression + " } from '" + rel_file_path + ".js';";
+ import.export_statement =
+ "export { " + symbols_expression + " } from '." + bare_file_path + ".js';";
import.dependency = &dependency;
import.dependent = &dependent;
+
imports.insert(std::make_pair(unique_name, import));
- return import.name;
+
+ return import;
}
void AddImport(import_set &imports, std::string import_name,
@@ -777,7 +781,9 @@
}
// Generate a TS union type based on a union's enum
- std::string GenObjApiUnionTypeTS(import_set &imports, const IDLOptions &opts,
+ std::string GenObjApiUnionTypeTS(import_set &imports,
+ const StructDef &dependent,
+ const IDLOptions &,
const EnumDef &union_enum) {
std::string ret = "";
std::set<std::string> type_list;
@@ -791,8 +797,8 @@
if (IsString(ev.union_type)) {
type = "string"; // no need to wrap string type in namespace
} else if (ev.union_type.base_type == BASE_TYPE_STRUCT) {
- type = GetObjApiClassName(
- AddImport(imports, union_enum, *ev.union_type.struct_def), opts);
+ type = AddImport(imports, dependent, *ev.union_type.struct_def)
+ .object_name;
} else {
FLATBUFFERS_ASSERT(false);
}
@@ -809,11 +815,11 @@
}
std::string GenUnionConvFuncName(const EnumDef &enum_def) {
- return "unionTo" + enum_def.name;
+ return namer_.Function("unionTo", enum_def);
}
std::string GenUnionListConvFuncName(const EnumDef &enum_def) {
- return "unionListTo" + enum_def.name;
+ return namer_.Function("unionListTo", enum_def);
}
std::string GenUnionConvFunc(const Type &union_type, import_set &imports) {
@@ -824,12 +830,12 @@
const auto valid_union_type_with_null = valid_union_type + "|null";
auto ret = "\n\nexport function " + GenUnionConvFuncName(enum_def) +
- "(\n type: " + enum_def.name +
+ "(\n type: " + GetTypeName(enum_def) +
",\n accessor: (obj:" + valid_union_type + ") => " +
valid_union_type_with_null +
"\n): " + valid_union_type_with_null + " {\n";
- const auto enum_type = AddImport(imports, enum_def, enum_def);
+ const auto enum_type = AddImport(imports, enum_def, enum_def).name;
const auto union_enum_loop = [&](const std::string &accessor_str) {
ret += " switch(" + enum_type + "[type]) {\n";
@@ -840,13 +846,13 @@
const auto &ev = **it;
if (ev.IsZero()) { continue; }
- ret += " case '" + ev.name + "': ";
+ ret += " case '" + namer_.Variant(ev) + "': ";
if (IsString(ev.union_type)) {
ret += "return " + accessor_str + "'') as string;";
} else if (ev.union_type.base_type == BASE_TYPE_STRUCT) {
const auto type =
- AddImport(imports, enum_def, *ev.union_type.struct_def);
+ AddImport(imports, enum_def, *ev.union_type.struct_def).name;
ret += "return " + accessor_str + "new " + type + "())! as " +
type + ";";
} else {
@@ -863,7 +869,7 @@
ret += "}";
ret += "\n\nexport function " + GenUnionListConvFuncName(enum_def) +
- "(\n type: " + enum_def.name +
+ "(\n type: " + GetTypeName(enum_def) +
", \n accessor: (index: number, obj:" + valid_union_type +
") => " + valid_union_type_with_null +
", \n index: number\n): " + valid_union_type_with_null + " {\n";
@@ -879,12 +885,13 @@
// Used for generating a short function that returns the correct class
// based on union enum type. Assume the context is inside the non object api
// type
- std::string GenUnionValTS(import_set &imports, const std::string &field_name,
+ std::string GenUnionValTS(import_set &imports, const StructDef &dependent,
+ const std::string &field_name,
const Type &union_type,
const bool is_array = false) {
if (union_type.enum_def) {
const auto &enum_def = *union_type.enum_def;
- const auto enum_type = AddImport(imports, enum_def, enum_def);
+ const auto enum_type = AddImport(imports, dependent, enum_def).name;
const std::string union_accessor = "this." + field_name;
const auto union_has_string = UnionHasStringType(enum_def);
@@ -894,11 +901,11 @@
if (!is_array) {
const auto conversion_function = GenUnionConvFuncName(enum_def);
- const auto target_enum = "this." + field_name + "Type()";
ret = "(() => {\n";
- ret += " let temp = " + conversion_function + "(" + target_enum +
- ", " + field_binded_method + ");\n";
+ ret += " let temp = " + conversion_function + "(this." +
+ namer_.Method(field_name, "Type") + "(), " +
+ field_binded_method + ");\n";
ret += " if(temp === null) { return null; }\n";
ret += union_has_string
? " if(typeof temp === 'string') { return temp; }\n"
@@ -907,17 +914,15 @@
ret += " })()";
} else {
const auto conversion_function = GenUnionListConvFuncName(enum_def);
- const auto target_enum_accesor = "this." + field_name + "Type";
- const auto target_enum_length = target_enum_accesor + "Length()";
ret = "(() => {\n";
ret += " let ret = [];\n";
- ret += " for(let targetEnumIndex = 0; targetEnumIndex < " +
- target_enum_length +
+ ret += " for(let targetEnumIndex = 0; targetEnumIndex < this." +
+ namer_.Method(field_name, "TypeLength") + "()" +
"; "
"++targetEnumIndex) {\n";
- ret += " let targetEnum = " + target_enum_accesor +
- "(targetEnumIndex);\n";
+ ret += " let targetEnum = this." +
+ namer_.Method(field_name, "Type") + "(targetEnumIndex);\n";
ret += " if(targetEnum === null || " + enum_type +
"[targetEnum!] === 'NONE') { "
"continue; }\n\n";
@@ -956,15 +961,20 @@
it != struct_def.fields.vec.end(); ++it) {
auto &field = **it;
- const auto curr_member_accessor =
- prefix + "." + ConvertCase(field.name, Case::kLowerCamel);
+ auto curr_member_accessor = prefix + "." + namer_.Method(field);
+ if (prefix != "this") {
+ curr_member_accessor = prefix + "?." + namer_.Method(field);
+ }
if (IsStruct(field.value.type)) {
ret += GenStructMemberValueTS(*field.value.type.struct_def,
curr_member_accessor, delimiter);
} else {
if (nullCheck) {
- ret +=
- "(" + prefix + " === null ? 0 : " + curr_member_accessor + "!)";
+ std::string nullValue = "0";
+ if (field.value.type.base_type == BASE_TYPE_BOOL) {
+ nullValue = "false";
+ }
+ ret += "(" + curr_member_accessor + " ?? " + nullValue + ")";
} else {
ret += curr_member_accessor;
}
@@ -979,7 +989,7 @@
void GenObjApi(const Parser &parser, StructDef &struct_def,
std::string &obj_api_unpack_func, std::string &obj_api_class,
import_set &imports) {
- const auto class_name = GetObjApiClassName(struct_def, parser.opts);
+ const auto class_name = GetTypeName(struct_def, /*object_api=*/true);
std::string unpack_func = "\nunpack(): " + class_name +
" {\n return new " + class_name + "(" +
@@ -999,8 +1009,7 @@
std::string pack_func_offset_decl;
std::string pack_func_create_call;
- const auto struct_name =
- EscapeKeyword(AddImport(imports, struct_def, struct_def));
+ const auto struct_name = AddImport(imports, struct_def, struct_def).name;
if (has_create) {
pack_func_create_call = " return " + struct_name + ".create" +
@@ -1023,10 +1032,10 @@
auto &field = **it;
if (field.deprecated) continue;
- const auto field_name = ConvertCase(field.name, Case::kLowerCamel);
- const auto field_name_escaped = EscapeKeyword(field_name);
+ const auto field_method = namer_.Method(field);
+ const auto field_field = namer_.Field(field);
const std::string field_binded_method =
- "this." + field_name + ".bind(this)";
+ "this." + field_method + ".bind(this)";
std::string field_val;
std::string field_type;
@@ -1046,14 +1055,14 @@
field_type += GenTypeName(imports, field, field.value.type, false,
has_null_default);
- field_val = "this." + field_name + "()";
+ field_val = "this." + namer_.Method(field) + "()";
if (field.value.type.base_type != BASE_TYPE_STRING) {
- field_offset_val = "this." + field_name_escaped;
+ field_offset_val = "this." + namer_.Field(field);
} else {
field_offset_decl = GenNullCheckConditional(
- "this." + field_name_escaped,
- "builder.createString(this." + field_name_escaped + "!)", "0");
+ "this." + namer_.Field(field),
+ "builder.createString(this." + field_field + "!)", "0");
}
}
@@ -1063,17 +1072,15 @@
switch (field.value.type.base_type) {
case BASE_TYPE_STRUCT: {
const auto &sd = *field.value.type.struct_def;
- field_type += GetObjApiClassName(AddImport(imports, struct_def, sd),
- parser.opts);
+ field_type += AddImport(imports, struct_def, sd).object_name;
const std::string field_accessor =
- "this." + field_name_escaped + "()";
+ "this." + namer_.Method(field) + "()";
field_val = GenNullCheckConditional(field_accessor,
field_accessor + "!.unpack()");
auto packing = GenNullCheckConditional(
- "this." + field_name_escaped,
- "this." + field_name_escaped + "!.pack(builder)",
- "0");
+ "this." + field_field,
+ "this." + field_field + "!.pack(builder)", "0");
if (sd.fixed) {
field_offset_val = std::move(packing);
@@ -1095,28 +1102,25 @@
switch (vectortype.base_type) {
case BASE_TYPE_STRUCT: {
const auto &sd = *field.value.type.struct_def;
- field_type += GetObjApiClassName(sd, parser.opts);
+ field_type += GetTypeName(sd, /*object_api=*/true);
+ ;
field_type += ")[]";
field_val = GenBBAccess() + ".createObjList(" +
- field_binded_method + ", this." + field_name +
- "Length())";
+ field_binded_method + ", this." +
+ namer_.Method(field, "Length") + "())";
if (sd.fixed) {
field_offset_decl =
- "builder.createStructOffsetList(this." +
- field_name_escaped + ", " +
- EscapeKeyword(
- AddImport(imports, struct_def, struct_def)) +
- ".start" + ConvertCase(field_name, Case::kUpperCamel) +
- "Vector)";
+ "builder.createStructOffsetList(this." + field_field +
+ ", " + AddImport(imports, struct_def, struct_def).name +
+ "." + namer_.Method("start", field, "Vector") + ")";
} else {
field_offset_decl =
- EscapeKeyword(
- AddImport(imports, struct_def, struct_def)) +
- ".create" + ConvertCase(field_name, Case::kUpperCamel) +
- "Vector(builder, builder.createObjectOffsetList(" +
- "this." + field_name_escaped + "))";
+ AddImport(imports, struct_def, struct_def).name + "." +
+ namer_.Method("create", field, "Vector") +
+ "(builder, builder.createObjectOffsetList(" + "this." +
+ field_field + "))";
}
break;
@@ -1125,28 +1129,28 @@
case BASE_TYPE_STRING: {
field_type += "string)[]";
field_val = GenBBAccess() + ".createScalarList(" +
- field_binded_method + ", this." + field_name +
- "Length())";
+ field_binded_method + ", this." +
+ namer_.Field(field, "Length") + "())";
field_offset_decl =
- EscapeKeyword(AddImport(imports, struct_def, struct_def)) +
- ".create" + ConvertCase(field_name, Case::kUpperCamel) +
- "Vector(builder, builder.createObjectOffsetList(" +
- "this." + field_name_escaped + "))";
+ AddImport(imports, struct_def, struct_def).name + "." +
+ namer_.Method("create", field, "Vector") +
+ "(builder, builder.createObjectOffsetList(" + "this." +
+ namer_.Field(field) + "))";
break;
}
case BASE_TYPE_UNION: {
- field_type += GenObjApiUnionTypeTS(imports, parser.opts,
- *(vectortype.enum_def));
+ field_type += GenObjApiUnionTypeTS(
+ imports, struct_def, parser.opts, *(vectortype.enum_def));
field_type += ")[]";
- field_val =
- GenUnionValTS(imports, field_name, vectortype, true);
+ field_val = GenUnionValTS(imports, struct_def, field_method,
+ vectortype, true);
field_offset_decl =
- EscapeKeyword(AddImport(imports, struct_def, struct_def)) +
- ".create" + ConvertCase(field_name, Case::kUpperCamel) +
- "Vector(builder, builder.createObjectOffsetList(" +
- "this." + field_name_escaped + "))";
+ AddImport(imports, struct_def, struct_def).name + "." +
+ namer_.Method("create", field, "Vector") +
+ "(builder, builder.createObjectOffsetList(" + "this." +
+ namer_.Field(field) + "))";
break;
}
@@ -1159,13 +1163,13 @@
}
field_type += ")[]";
field_val = GenBBAccess() + ".createScalarList(" +
- field_binded_method + ", this." + field_name +
- "Length())";
+ field_binded_method + ", this." +
+ namer_.Method(field, "Length") + "())";
field_offset_decl =
- EscapeKeyword(AddImport(imports, struct_def, struct_def)) +
- ".create" + ConvertCase(field_name, Case::kUpperCamel) +
- "Vector(builder, this." + field_name_escaped + ")";
+ AddImport(imports, struct_def, struct_def).name + "." +
+ namer_.Method("create", field, "Vector") +
+ "(builder, this." + field_field + ")";
break;
}
@@ -1175,12 +1179,13 @@
}
case BASE_TYPE_UNION: {
- field_type += GenObjApiUnionTypeTS(imports, parser.opts,
+ field_type += GenObjApiUnionTypeTS(imports, struct_def, parser.opts,
*(field.value.type.enum_def));
- field_val = GenUnionValTS(imports, field_name, field.value.type);
+ field_val = GenUnionValTS(imports, struct_def, field_method,
+ field.value.type);
field_offset_decl =
- "builder.createObjectOffset(this." + field_name_escaped + ")";
+ "builder.createObjectOffset(this." + field_field + ")";
break;
}
@@ -1193,18 +1198,17 @@
if (!field_offset_decl.empty()) {
field_offset_decl =
- " const " + field_name_escaped + " = " + field_offset_decl + ";";
+ " const " + field_field + " = " + field_offset_decl + ";";
}
- if (field_offset_val.empty()) { field_offset_val = field_name_escaped; }
+ if (field_offset_val.empty()) { field_offset_val = field_field; }
unpack_func += " " + field_val;
- unpack_to_func += " _o." + field_name_escaped + " = " + field_val + ";";
+ unpack_to_func += " _o." + field_field + " = " + field_val + ";";
- // FIXME: if field_type and field_name_escaped are identical, then
+ // FIXME: if field_type and field_field are identical, then
// this generates invalid typescript.
- constructor_func += " public " + field_name_escaped + ": " + field_type +
- " = " +
- field_default_val;
+ constructor_func += " public " + field_field + ": " + field_type +
+ " = " + field_default_val;
if (!struct_def.fixed) {
if (!field_offset_decl.empty()) {
@@ -1215,11 +1219,12 @@
pack_func_create_call += field_offset_val;
} else {
if (field.IsScalarOptional()) {
- pack_func_create_call += " if (" + field_offset_val + " !== null)\n ";
+ pack_func_create_call +=
+ " if (" + field_offset_val + " !== null)\n ";
}
- pack_func_create_call += " " + struct_name + ".add" +
- ConvertCase(field.name, Case::kUpperCamel) +
- "(builder, " + field_offset_val + ");\n";
+ pack_func_create_call += " " + struct_name + "." +
+ namer_.Method("add", field) + "(builder, " +
+ field_offset_val + ");\n";
}
}
@@ -1252,10 +1257,10 @@
pack_func_create_call += "return " + struct_name + ".end" +
GetPrefixedName(struct_def) + "(builder);";
}
-
- obj_api_class = "\nexport class " +
- GetObjApiClassName(struct_def, parser.opts) + " {\n";
-
+ obj_api_class = "\n";
+ obj_api_class += "export class ";
+ obj_api_class += GetTypeName(struct_def, /*object_api=*/true);
+ obj_api_class += " {\n";
obj_api_class += constructor_func;
obj_api_class += pack_func_prototype + pack_func_offset_decl +
pack_func_create_call + "\n}";
@@ -1286,13 +1291,18 @@
if (struct_def.generated) return;
std::string &code = *code_ptr;
- std::string object_name;
- std::string object_namespace = GetNameSpace(struct_def);
+ // Special case for the root struct, since no one will necessarily reference
+ // it, we have to explicitly add it to the import list.
+ if (&struct_def == parser_.root_struct_def_) {
+ AddImport(imports, struct_def, struct_def);
+ }
+
+ const std::string object_name = GetTypeName(struct_def);
// Emit constructor
- object_name = EscapeKeyword(struct_def.name);
GenDocComment(struct_def.doc_comment, code_ptr);
- code += "export class " + object_name;
+ code += "export class ";
+ code += object_name;
code += " {\n";
code += " bb: flatbuffers.ByteBuffer|null = null;\n";
code += " bb_pos = 0;\n";
@@ -1300,7 +1310,7 @@
// Generate the __init method that sets the field in a pre-existing
// accessor object. This is to allow object reuse.
code +=
- "__init(i:number, bb:flatbuffers.ByteBuffer):" + object_name + " {\n";
+ " __init(i:number, bb:flatbuffers.ByteBuffer):" + object_name + " {\n";
code += " this.bb_pos = i;\n";
code += " this.bb = bb;\n";
code += " return this;\n";
@@ -1337,7 +1347,7 @@
const auto has_null_default = is_string || HasNullDefault(field);
GenDocComment(field.doc_comment, code_ptr);
- std::string prefix = ConvertCase(field.name, Case::kLowerCamel) + "(";
+ std::string prefix = namer_.Method(field) + "(";
if (is_string) {
code += prefix + "):string|null\n";
code +=
@@ -1380,10 +1390,11 @@
else {
switch (field.value.type.base_type) {
case BASE_TYPE_STRUCT: {
- const auto type = EscapeKeyword(
- AddImport(imports, struct_def, *field.value.type.struct_def));
+ const auto type =
+ AddImport(imports, struct_def, *field.value.type.struct_def)
+ .name;
GenDocComment(field.doc_comment, code_ptr);
- code += ConvertCase(field.name, Case::kLowerCamel);
+ code += namer_.Method(field);
code += "(obj?:" + type + "):" + type + "|null {\n";
if (struct_def.fixed) {
@@ -1423,7 +1434,7 @@
default: ret_type = vectortypename;
}
GenDocComment(field.doc_comment, code_ptr);
- std::string prefix = ConvertCase(field.name, Case::kLowerCamel);
+ std::string prefix = namer_.Method(field);
// TODO: make it work without any
// if (is_union) { prefix += "<T extends flatbuffers.Table>"; }
if (is_union) { prefix += ""; }
@@ -1483,7 +1494,7 @@
case BASE_TYPE_UNION: {
GenDocComment(field.doc_comment, code_ptr);
- code += ConvertCase(field.name, Case::kLowerCamel);
+ code += namer_.Method(field);
const auto &union_enum = *(field.value.type.enum_def);
const auto union_type = GenUnionGenericTypeTS(union_enum);
@@ -1508,12 +1519,15 @@
std::string type =
GenTypeName(imports, struct_def, field.value.type, true);
- code += "mutate_" + field.name + "(value:" + type + "):boolean {\n";
+ code += namer_.LegacyTsMutateMethod(field) + "(value:" + type +
+ "):boolean {\n";
+
+ const std::string write_method =
+ "." + namer_.Method("write", GenType(field.value.type));
if (struct_def.fixed) {
- code += " " + GenBBAccess() + ".write" +
- ConvertCase(GenType(field.value.type), Case::kUpperCamel) +
- "(this.bb_pos + " + NumToString(field.value.offset) + ", ";
+ code += " " + GenBBAccess() + write_method + "(this.bb_pos + " +
+ NumToString(field.value.offset) + ", ";
} else {
code += " const offset = " + GenBBAccess() +
".__offset(this.bb_pos, " + NumToString(field.value.offset) +
@@ -1523,9 +1537,8 @@
code += " }\n\n";
// special case for bools, which are treated as uint8
- code += " " + GenBBAccess() + ".write" +
- ConvertCase(GenType(field.value.type), Case::kUpperCamel) +
- "(this.bb_pos + offset, ";
+ code +=
+ " " + GenBBAccess() + write_method + "(this.bb_pos + offset, ";
if (field.value.type.base_type == BASE_TYPE_BOOL) { code += "+"; }
}
@@ -1538,8 +1551,8 @@
if (IsVector(field.value.type)) {
// Emit a length helper
GenDocComment(code_ptr);
- code += ConvertCase(field.name, Case::kLowerCamel);
- code += "Length():number {\n" + offset_prefix;
+ code += namer_.Method(field, "Length");
+ code += "():number {\n" + offset_prefix;
code +=
GenBBAccess() + ".__vector_len(this.bb_pos + offset) : 0;\n}\n\n";
@@ -1549,9 +1562,9 @@
if (IsScalar(vectorType.base_type) && !IsLong(vectorType.base_type)) {
GenDocComment(code_ptr);
- code += ConvertCase(field.name, Case::kLowerCamel);
- code += "Array():" + GenType(vectorType) + "Array|null {\n" +
- offset_prefix;
+ code += namer_.Method(field, "Array");
+ code +=
+ "():" + GenType(vectorType) + "Array|null {\n" + offset_prefix;
code += "new " + GenType(vectorType) + "Array(" + GenBBAccess() +
".bytes().buffer, " + GenBBAccess() +
@@ -1610,7 +1623,7 @@
// Generate the field insertion method
GenDocComment(code_ptr);
- code += "static add" + ConvertCase(field.name, Case::kUpperCamel);
+ code += "static " + namer_.Method("add", field);
code += "(builder:flatbuffers.Builder, " + argname + ":" +
GetArgType(imports, struct_def, field, false) + ") {\n";
code += " builder.addField" + GenWriteMethod(field.value.type) + "(";
@@ -1641,8 +1654,8 @@
GenDocComment(code_ptr);
const std::string sig_begin =
- "static create" + ConvertCase(field.name, Case::kUpperCamel) +
- "Vector(builder:flatbuffers.Builder, data:";
+ "static " + namer_.Method("create", field, "Vector") +
+ "(builder:flatbuffers.Builder, data:";
const std::string sig_end = "):flatbuffers.Offset";
std::string type =
GenTypeName(imports, struct_def, vector_type, true) + "[]";
@@ -1679,8 +1692,9 @@
// after
GenDocComment(code_ptr);
- code += "static start" + ConvertCase(field.name, Case::kUpperCamel);
- code += "Vector(builder:flatbuffers.Builder, numElems:number) {\n";
+ code += "static ";
+ code += namer_.Method("start", field, "Vector");
+ code += "(builder:flatbuffers.Builder, numElems:number) {\n";
code += " builder.startVector(" + NumToString(elem_size);
code += ", numElems, " + NumToString(alignment) + ");\n";
code += "}\n\n";
@@ -1723,8 +1737,8 @@
}
code += "):flatbuffers.Offset {\n";
- code += " " + object_name + ".start" +
- GetPrefixedName(struct_def) + "(builder);\n";
+ code += " " + object_name + ".start" + GetPrefixedName(struct_def) +
+ "(builder);\n";
std::string methodPrefix = object_name;
for (auto it = struct_def.fields.vec.begin();
@@ -1738,8 +1752,7 @@
code += " if (" + arg_name + " !== null)\n ";
}
- code += " " + methodPrefix + ".add" +
- ConvertCase(field.name, Case::kUpperCamel) + "(";
+ code += " " + methodPrefix + "." + namer_.Method("add", field) + "(";
code += "builder, " + arg_name + ");\n";
}
@@ -1757,10 +1770,9 @@
code += "}\n";
code += "\n";
- code += "static deserialize(buffer: Uint8Array):" + EscapeKeyword(name) +
- " {\n";
- code += " return " +
- EscapeKeyword(AddImport(imports, struct_def, struct_def)) +
+ code += "static deserialize(buffer: Uint8Array):" +
+ namer_.EscapeKeyword(name) + " {\n";
+ code += " return " + AddImport(imports, struct_def, struct_def).name +
".getRootAs" + name + "(new flatbuffers.ByteBuffer(buffer))\n";
code += "}\n";
}
@@ -1788,12 +1800,8 @@
}
std::string GetArgName(const FieldDef &field) {
- auto argname = ConvertCase(field.name, Case::kLowerCamel);
- if (!IsScalar(field.value.type.base_type)) {
- argname += "Offset";
- } else {
- argname = EscapeKeyword(argname);
- }
+ auto argname = namer_.Variable(field);
+ if (!IsScalar(field.value.type.base_type)) { argname += "Offset"; }
return argname;
}
diff --git a/src/idl_namer.h b/src/idl_namer.h
new file mode 100644
index 0000000..f60e30c
--- /dev/null
+++ b/src/idl_namer.h
@@ -0,0 +1,168 @@
+#ifndef FLATBUFFERS_IDL_NAMER
+#define FLATBUFFERS_IDL_NAMER
+
+#include "flatbuffers/idl.h"
+#include "namer.h"
+
+namespace flatbuffers {
+
+// Provides Namer capabilities to types defined in the flatbuffers IDL.
+class IdlNamer : public Namer {
+ public:
+ explicit IdlNamer(Config config, std::set<std::string> keywords)
+ : Namer(config, std::move(keywords)) {}
+
+ using Namer::Constant;
+ using Namer::Directories;
+ using Namer::Field;
+ using Namer::File;
+ using Namer::Function;
+ using Namer::Method;
+ using Namer::Namespace;
+ using Namer::NamespacedType;
+ using Namer::ObjectType;
+ using Namer::Type;
+ using Namer::Variable;
+ using Namer::Variant;
+
+ std::string Constant(const FieldDef &d) const { return Constant(d.name); }
+
+ // Types are always structs or enums so we can only expose these two
+ // overloads.
+ std::string Type(const StructDef &d) const { return Type(d.name); }
+ std::string Type(const EnumDef &d) const { return Type(d.name); }
+
+ std::string Function(const Definition &s) const { return Function(s.name); }
+ std::string Function(const std::string& prefix, const Definition &s) const {
+ return Function(prefix + s.name);
+ }
+
+ std::string Field(const FieldDef &s) const { return Field(s.name); }
+ std::string Field(const FieldDef &d, const std::string &s) const {
+ return Field(d.name + "_" + s);
+ }
+
+ std::string Variable(const FieldDef &s) const { return Variable(s.name); }
+
+ std::string Variable(const StructDef &s) const { return Variable(s.name); }
+
+ std::string Variant(const EnumVal &s) const { return Variant(s.name); }
+
+ std::string EnumVariant(const EnumDef &e, const EnumVal &v) const {
+ return Type(e) + config_.enum_variant_seperator + Variant(v);
+ }
+
+ std::string ObjectType(const StructDef &d) const {
+ return ObjectType(d.name);
+ }
+ std::string ObjectType(const EnumDef &d) const { return ObjectType(d.name); }
+
+ std::string Method(const FieldDef &d, const std::string &suffix) const {
+ return Method(d.name, suffix);
+ }
+ std::string Method(const std::string &prefix, const StructDef &d) const {
+ return Method(prefix, d.name);
+ }
+ std::string Method(const std::string &prefix, const FieldDef &d) const {
+ return Method(prefix, d.name);
+ }
+ std::string Method(const std::string &prefix, const FieldDef &d,
+ const std::string &suffix) const {
+ return Method(prefix, d.name, suffix);
+ }
+
+ std::string Namespace(const struct Namespace &ns) const {
+ return Namespace(ns.components);
+ }
+
+ std::string NamespacedEnumVariant(const EnumDef &e, const EnumVal &v) const {
+ return NamespacedString(e.defined_namespace, EnumVariant(e, v));
+ }
+
+ std::string NamespacedType(const Definition &def) const {
+ return NamespacedString(def.defined_namespace, Type(def.name));
+ }
+
+ std::string NamespacedObjectType(const Definition &def) const {
+ return NamespacedString(def.defined_namespace, ObjectType(def.name));
+ }
+
+ std::string Directories(const struct Namespace &ns,
+ SkipDir skips = SkipDir::None) const {
+ return Directories(ns.components, skips);
+ }
+
+ // Legacy fields do not really follow the usual config and should be
+ // considered for deprecation.
+
+ std::string LegacyRustNativeVariant(const EnumVal &v) const {
+ return ConvertCase(EscapeKeyword(v.name), Case::kUpperCamel);
+ }
+
+ std::string LegacyRustFieldOffsetName(const FieldDef &field) const {
+ return "VT_" + ConvertCase(EscapeKeyword(field.name), Case::kAllUpper);
+ }
+
+ std::string LegacySwiftVariant(const EnumVal &ev) const {
+ auto name = ev.name;
+ if (isupper(name.front())) {
+ std::transform(name.begin(), name.end(), name.begin(), CharToLower);
+ }
+ return EscapeKeyword(ConvertCase(name, Case::kLowerCamel));
+ }
+
+ // Also used by Kotlin, lol.
+ std::string LegacyJavaMethod2(const std::string &prefix, const StructDef &sd,
+ const std::string &suffix) const {
+ return prefix + sd.name + suffix;
+ }
+
+ std::string LegacyKotlinVariant(EnumVal &ev) const {
+ // Namer assumes the input case is snake case which is wrong...
+ return ConvertCase(EscapeKeyword(ev.name), Case::kLowerCamel);
+ }
+ // Kotlin methods escapes keywords after case conversion but before
+ // prefixing and suffixing.
+ std::string LegacyKotlinMethod(const std::string &prefix, const FieldDef &d,
+ const std::string &suffix) const {
+ return prefix + ConvertCase(EscapeKeyword(d.name), Case::kUpperCamel) +
+ suffix;
+ }
+ std::string LegacyKotlinMethod(const std::string &prefix, const StructDef &d,
+ const std::string &suffix) const {
+ return prefix + ConvertCase(EscapeKeyword(d.name), Case::kUpperCamel) +
+ suffix;
+ }
+
+ // This is a mix of snake case and keep casing, when Ts should be using
+ // lower camel case.
+ std::string LegacyTsMutateMethod(const FieldDef& d) {
+ return "mutate_" + d.name;
+ }
+
+ private:
+ std::string NamespacedString(const struct Namespace *ns,
+ const std::string &str) const {
+ std::string ret;
+ if (ns != nullptr) { ret += Namespace(ns->components); }
+ if (!ret.empty()) ret += config_.namespace_seperator;
+ return ret + str;
+ }
+};
+
+// This is a temporary helper function for code generators to call until all
+// flag-overriding logic into flatc.cpp
+inline Namer::Config WithFlagOptions(const Namer::Config &input,
+ const IDLOptions &opts,
+ const std::string &path) {
+ Namer::Config result = input;
+ result.object_prefix = opts.object_prefix;
+ result.object_suffix = opts.object_suffix;
+ result.output_path = path;
+ result.filename_suffix = opts.filename_suffix;
+ return result;
+}
+
+} // namespace flatbuffers
+
+#endif // FLATBUFFERS_IDL_NAMER
diff --git a/src/idl_parser.cpp b/src/idl_parser.cpp
index dd106df..2d961b2 100644
--- a/src/idl_parser.cpp
+++ b/src/idl_parser.cpp
@@ -36,24 +36,9 @@
// clang-format on
}
-const double kPi = 3.14159265358979323846;
+namespace {
-// clang-format off
-const char *const kTypeNames[] = {
- #define FLATBUFFERS_TD(ENUM, IDLTYPE, ...) \
- IDLTYPE,
- FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD)
- #undef FLATBUFFERS_TD
- nullptr
-};
-
-const char kTypeSizes[] = {
- #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, ...) \
- sizeof(CTYPE),
- FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD)
- #undef FLATBUFFERS_TD
-};
-// clang-format on
+static const double kPi = 3.14159265358979323846;
// The enums in the reflection schema should match the ones we use internally.
// Compare the last element to check if these go out of sync.
@@ -93,97 +78,36 @@
return true;
}
-void DeserializeDoc(std::vector<std::string> &doc,
- const Vector<Offset<String>> *documentation) {
+static void DeserializeDoc(std::vector<std::string> &doc,
+ const Vector<Offset<String>> *documentation) {
if (documentation == nullptr) return;
for (uoffset_t index = 0; index < documentation->size(); index++)
doc.push_back(documentation->Get(index)->str());
}
-void Parser::Message(const std::string &msg) {
- if (!error_.empty()) error_ += "\n"; // log all warnings and errors
- error_ += file_being_parsed_.length() ? AbsolutePath(file_being_parsed_) : "";
- // clang-format off
+static CheckedError NoError() { return CheckedError(false); }
- #ifdef _WIN32 // MSVC alike
- error_ +=
- "(" + NumToString(line_) + ", " + NumToString(CursorPosition()) + ")";
- #else // gcc alike
- if (file_being_parsed_.length()) error_ += ":";
- error_ += NumToString(line_) + ": " + NumToString(CursorPosition());
- #endif
- // clang-format on
- error_ += ": " + msg;
-}
-
-void Parser::Warning(const std::string &msg) {
- if (!opts.no_warnings) {
- Message("warning: " + msg);
- has_warning_ = true; // for opts.warnings_as_errors
- }
-}
-
-CheckedError Parser::Error(const std::string &msg) {
- Message("error: " + msg);
- return CheckedError(true);
-}
-
-inline CheckedError NoError() { return CheckedError(false); }
-
-CheckedError Parser::RecurseError() {
- return Error("maximum parsing depth " + NumToString(parse_depth_counter_) +
- " reached");
-}
-
-const std::string &Parser::GetPooledString(const std::string &s) const {
- return *(string_cache_.insert(s).first);
-}
-
-class Parser::ParseDepthGuard {
- public:
- explicit ParseDepthGuard(Parser *parser_not_null)
- : parser_(*parser_not_null), caller_depth_(parser_.parse_depth_counter_) {
- FLATBUFFERS_ASSERT(caller_depth_ <= (FLATBUFFERS_MAX_PARSING_DEPTH) &&
- "Check() must be called to prevent stack overflow");
- parser_.parse_depth_counter_ += 1;
- }
-
- ~ParseDepthGuard() { parser_.parse_depth_counter_ -= 1; }
-
- CheckedError Check() {
- return caller_depth_ >= (FLATBUFFERS_MAX_PARSING_DEPTH)
- ? parser_.RecurseError()
- : CheckedError(false);
- }
-
- FLATBUFFERS_DELETE_FUNC(ParseDepthGuard(const ParseDepthGuard &));
- FLATBUFFERS_DELETE_FUNC(ParseDepthGuard &operator=(const ParseDepthGuard &));
-
- private:
- Parser &parser_;
- const int caller_depth_;
-};
-
-template<typename T> std::string TypeToIntervalString() {
+template<typename T> static std::string TypeToIntervalString() {
return "[" + NumToString((flatbuffers::numeric_limits<T>::lowest)()) + "; " +
NumToString((flatbuffers::numeric_limits<T>::max)()) + "]";
}
// atot: template version of atoi/atof: convert a string to an instance of T.
template<typename T>
-bool atot_scalar(const char *s, T *val, bool_constant<false>) {
+static bool atot_scalar(const char *s, T *val, bool_constant<false>) {
return StringToNumber(s, val);
}
template<typename T>
-bool atot_scalar(const char *s, T *val, bool_constant<true>) {
+static bool atot_scalar(const char *s, T *val, bool_constant<true>) {
// Normalize NaN parsed from fbs or json to unsigned NaN.
if (false == StringToNumber(s, val)) return false;
*val = (*val != *val) ? std::fabs(*val) : *val;
return true;
}
-template<typename T> CheckedError atot(const char *s, Parser &parser, T *val) {
+template<typename T>
+static CheckedError atot(const char *s, Parser &parser, T *val) {
auto done = atot_scalar(s, val, bool_constant<is_floating_point<T>::value>());
if (done) return NoError();
if (0 == *val)
@@ -193,33 +117,18 @@
", constant does not fit " + TypeToIntervalString<T>());
}
template<>
-inline CheckedError atot<Offset<void>>(const char *s, Parser &parser,
- Offset<void> *val) {
+CheckedError atot<Offset<void>>(const char *s, Parser &parser,
+ Offset<void> *val) {
(void)parser;
*val = Offset<void>(atoi(s));
return NoError();
}
-std::string Namespace::GetFullyQualifiedName(const std::string &name,
- size_t max_components) const {
- // Early exit if we don't have a defined namespace.
- if (components.empty() || !max_components) { return name; }
- std::string stream_str;
- for (size_t i = 0; i < std::min(components.size(), max_components); i++) {
- stream_str += components[i];
- stream_str += '.';
- }
- if (!stream_str.empty()) stream_str.pop_back();
- if (name.length()) {
- stream_str += '.';
- stream_str += name;
- }
- return stream_str;
-}
-
template<typename T>
-T *LookupTableByName(const SymbolTable<T> &table, const std::string &name,
- const Namespace ¤t_namespace, size_t skip_top) {
+static T *LookupTableByName(const SymbolTable<T> &table,
+ const std::string &name,
+ const Namespace ¤t_namespace,
+ size_t skip_top) {
const auto &components = current_namespace.components;
if (table.dict.empty()) return nullptr;
if (components.size() < skip_top) return nullptr;
@@ -278,6 +187,271 @@
}
// clang-format on
+static bool IsIdentifierStart(char c) { return is_alpha(c) || (c == '_'); }
+
+static bool CompareSerializedScalars(const uint8_t *a, const uint8_t *b,
+ const FieldDef &key) {
+ switch (key.value.type.base_type) {
+#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, ...) \
+ case BASE_TYPE_##ENUM: { \
+ CTYPE def = static_cast<CTYPE>(0); \
+ if (!a || !b) { StringToNumber(key.value.constant.c_str(), &def); } \
+ const auto av = a ? ReadScalar<CTYPE>(a) : def; \
+ const auto bv = b ? ReadScalar<CTYPE>(b) : def; \
+ return av < bv; \
+ }
+ FLATBUFFERS_GEN_TYPES_SCALAR(FLATBUFFERS_TD)
+#undef FLATBUFFERS_TD
+ default: {
+ FLATBUFFERS_ASSERT(false && "scalar type expected");
+ return false;
+ }
+ }
+}
+
+static bool CompareTablesByScalarKey(const Offset<Table> *_a,
+ const Offset<Table> *_b,
+ const FieldDef &key) {
+ const voffset_t offset = key.value.offset;
+ // Indirect offset pointer to table pointer.
+ auto a = reinterpret_cast<const uint8_t *>(_a) + ReadScalar<uoffset_t>(_a);
+ auto b = reinterpret_cast<const uint8_t *>(_b) + ReadScalar<uoffset_t>(_b);
+ // Fetch field address from table.
+ a = reinterpret_cast<const Table *>(a)->GetAddressOf(offset);
+ b = reinterpret_cast<const Table *>(b)->GetAddressOf(offset);
+ return CompareSerializedScalars(a, b, key);
+}
+
+static bool CompareTablesByStringKey(const Offset<Table> *_a,
+ const Offset<Table> *_b,
+ const FieldDef &key) {
+ const voffset_t offset = key.value.offset;
+ // Indirect offset pointer to table pointer.
+ auto a = reinterpret_cast<const uint8_t *>(_a) + ReadScalar<uoffset_t>(_a);
+ auto b = reinterpret_cast<const uint8_t *>(_b) + ReadScalar<uoffset_t>(_b);
+ // Fetch field address from table.
+ a = reinterpret_cast<const Table *>(a)->GetAddressOf(offset);
+ b = reinterpret_cast<const Table *>(b)->GetAddressOf(offset);
+ if (a && b) {
+ // Indirect offset pointer to string pointer.
+ a += ReadScalar<uoffset_t>(a);
+ b += ReadScalar<uoffset_t>(b);
+ return *reinterpret_cast<const String *>(a) <
+ *reinterpret_cast<const String *>(b);
+ } else {
+ return a ? true : false;
+ }
+}
+
+static void SwapSerializedTables(Offset<Table> *a, Offset<Table> *b) {
+ // These are serialized offsets, so are relative where they are
+ // stored in memory, so compute the distance between these pointers:
+ ptrdiff_t diff = (b - a) * sizeof(Offset<Table>);
+ FLATBUFFERS_ASSERT(diff >= 0); // Guaranteed by SimpleQsort.
+ auto udiff = static_cast<uoffset_t>(diff);
+ a->o = EndianScalar(ReadScalar<uoffset_t>(a) - udiff);
+ b->o = EndianScalar(ReadScalar<uoffset_t>(b) + udiff);
+ std::swap(*a, *b);
+}
+
+// See below for why we need our own sort :(
+template<typename T, typename F, typename S>
+static void SimpleQsort(T *begin, T *end, size_t width, F comparator,
+ S swapper) {
+ if (end - begin <= static_cast<ptrdiff_t>(width)) return;
+ auto l = begin + width;
+ auto r = end;
+ while (l < r) {
+ if (comparator(begin, l)) {
+ r -= width;
+ swapper(l, r);
+ } else {
+ l += width;
+ }
+ }
+ l -= width;
+ swapper(begin, l);
+ SimpleQsort(begin, l, width, comparator, swapper);
+ SimpleQsort(r, end, width, comparator, swapper);
+}
+
+template<typename T> static inline void SingleValueRepack(Value &e, T val) {
+ // Remove leading zeros.
+ if (IsInteger(e.type.base_type)) { e.constant = NumToString(val); }
+}
+
+#if defined(FLATBUFFERS_HAS_NEW_STRTOD) && (FLATBUFFERS_HAS_NEW_STRTOD > 0)
+// Normalize defaults NaN to unsigned quiet-NaN(0) if value was parsed from
+// hex-float literal.
+static void SingleValueRepack(Value &e, float val) {
+ if (val != val) e.constant = "nan";
+}
+static void SingleValueRepack(Value &e, double val) {
+ if (val != val) e.constant = "nan";
+}
+#endif
+
+template<typename T> static uint64_t EnumDistanceImpl(T e1, T e2) {
+ if (e1 < e2) { std::swap(e1, e2); } // use std for scalars
+ // Signed overflow may occur, use unsigned calculation.
+ // The unsigned overflow is well-defined by C++ standard (modulo 2^n).
+ return static_cast<uint64_t>(e1) - static_cast<uint64_t>(e2);
+}
+
+static bool compareFieldDefs(const FieldDef *a, const FieldDef *b) {
+ auto a_id = atoi(a->attributes.Lookup("id")->constant.c_str());
+ auto b_id = atoi(b->attributes.Lookup("id")->constant.c_str());
+ return a_id < b_id;
+}
+
+static Namespace *GetNamespace(
+ const std::string &qualified_name, std::vector<Namespace *> &namespaces,
+ std::map<std::string, Namespace *> &namespaces_index) {
+ size_t dot = qualified_name.find_last_of('.');
+ std::string namespace_name = (dot != std::string::npos)
+ ? std::string(qualified_name.c_str(), dot)
+ : "";
+ Namespace *&ns = namespaces_index[namespace_name];
+
+ if (!ns) {
+ ns = new Namespace();
+ namespaces.push_back(ns);
+
+ size_t pos = 0;
+
+ for (;;) {
+ dot = qualified_name.find('.', pos);
+ if (dot == std::string::npos) { break; }
+ ns->components.push_back(qualified_name.substr(pos, dot - pos));
+ pos = dot + 1;
+ }
+ }
+
+ return ns;
+}
+
+// Generate a unique hash for a file based on its name and contents (if any).
+static uint64_t HashFile(const char *source_filename, const char *source) {
+ uint64_t hash = 0;
+
+ if (source_filename)
+ hash = HashFnv1a<uint64_t>(StripPath(source_filename).c_str());
+
+ if (source && *source) hash ^= HashFnv1a<uint64_t>(source);
+
+ return hash;
+}
+
+template<typename T> static bool compareName(const T *a, const T *b) {
+ return a->defined_namespace->GetFullyQualifiedName(a->name) <
+ b->defined_namespace->GetFullyQualifiedName(b->name);
+}
+
+template<typename T> static void AssignIndices(const std::vector<T *> &defvec) {
+ // Pre-sort these vectors, such that we can set the correct indices for them.
+ auto vec = defvec;
+ std::sort(vec.begin(), vec.end(), compareName<T>);
+ for (int i = 0; i < static_cast<int>(vec.size()); i++) vec[i]->index = i;
+}
+
+} // namespace
+
+// clang-format off
+const char *const kTypeNames[] = {
+ #define FLATBUFFERS_TD(ENUM, IDLTYPE, ...) \
+ IDLTYPE,
+ FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD)
+ #undef FLATBUFFERS_TD
+ nullptr
+};
+
+const char kTypeSizes[] = {
+ #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, ...) \
+ sizeof(CTYPE),
+ FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD)
+ #undef FLATBUFFERS_TD
+};
+// clang-format on
+
+void Parser::Message(const std::string &msg) {
+ if (!error_.empty()) error_ += "\n"; // log all warnings and errors
+ error_ += file_being_parsed_.length() ? AbsolutePath(file_being_parsed_) : "";
+ // clang-format off
+
+ #ifdef _WIN32 // MSVC alike
+ error_ +=
+ "(" + NumToString(line_) + ", " + NumToString(CursorPosition()) + ")";
+ #else // gcc alike
+ if (file_being_parsed_.length()) error_ += ":";
+ error_ += NumToString(line_) + ": " + NumToString(CursorPosition());
+ #endif
+ // clang-format on
+ error_ += ": " + msg;
+}
+
+void Parser::Warning(const std::string &msg) {
+ if (!opts.no_warnings) {
+ Message("warning: " + msg);
+ has_warning_ = true; // for opts.warnings_as_errors
+ }
+}
+
+CheckedError Parser::Error(const std::string &msg) {
+ Message("error: " + msg);
+ return CheckedError(true);
+}
+
+CheckedError Parser::RecurseError() {
+ return Error("maximum parsing depth " + NumToString(parse_depth_counter_) +
+ " reached");
+}
+
+const std::string &Parser::GetPooledString(const std::string &s) const {
+ return *(string_cache_.insert(s).first);
+}
+
+class Parser::ParseDepthGuard {
+ public:
+ explicit ParseDepthGuard(Parser *parser_not_null)
+ : parser_(*parser_not_null), caller_depth_(parser_.parse_depth_counter_) {
+ FLATBUFFERS_ASSERT(caller_depth_ <= (FLATBUFFERS_MAX_PARSING_DEPTH) &&
+ "Check() must be called to prevent stack overflow");
+ parser_.parse_depth_counter_ += 1;
+ }
+
+ ~ParseDepthGuard() { parser_.parse_depth_counter_ -= 1; }
+
+ CheckedError Check() {
+ return caller_depth_ >= (FLATBUFFERS_MAX_PARSING_DEPTH)
+ ? parser_.RecurseError()
+ : CheckedError(false);
+ }
+
+ FLATBUFFERS_DELETE_FUNC(ParseDepthGuard(const ParseDepthGuard &));
+ FLATBUFFERS_DELETE_FUNC(ParseDepthGuard &operator=(const ParseDepthGuard &));
+
+ private:
+ Parser &parser_;
+ const int caller_depth_;
+};
+
+std::string Namespace::GetFullyQualifiedName(const std::string &name,
+ size_t max_components) const {
+ // Early exit if we don't have a defined namespace.
+ if (components.empty() || !max_components) { return name; }
+ std::string stream_str;
+ for (size_t i = 0; i < std::min(components.size(), max_components); i++) {
+ stream_str += components[i];
+ stream_str += '.';
+ }
+ if (!stream_str.empty()) stream_str.pop_back();
+ if (name.length()) {
+ stream_str += '.';
+ stream_str += name;
+ }
+ return stream_str;
+}
+
std::string Parser::TokenToStringId(int t) const {
return t == kTokenIdentifier ? attribute_ : TokenToString(t);
}
@@ -307,10 +481,6 @@
return NoError();
}
-static inline bool IsIdentifierStart(char c) {
- return is_alpha(c) || (c == '_');
-}
-
CheckedError Parser::Next() {
doc_comment_.clear();
bool seen_newline = cursor_ == source_;
@@ -489,10 +659,21 @@
}
const auto has_sign = (c == '+') || (c == '-');
- if (has_sign && IsIdentifierStart(*cursor_)) {
- // '-'/'+' and following identifier - it could be a predefined
- // constant. Return the sign in token_, see ParseSingleValue.
- return NoError();
+ if (has_sign) {
+ // Check for +/-inf which is considered a float constant.
+ if (strncmp(cursor_, "inf", 3) == 0 &&
+ !(IsIdentifierStart(cursor_[3]) || is_digit(cursor_[3]))) {
+ attribute_.assign(cursor_ - 1, cursor_ + 3);
+ token_ = kTokenFloatConstant;
+ cursor_ += 3;
+ return NoError();
+ }
+
+ if (IsIdentifierStart(*cursor_)) {
+ // '-'/'+' and following identifier - it could be a predefined
+ // constant. Return the sign in token_, see ParseSingleValue.
+ return NoError();
+ }
}
auto dot_lvl =
@@ -958,8 +1139,12 @@
"definition");
field->native_inline = field->attributes.Lookup("native_inline") != nullptr;
- if (field->native_inline && !IsStruct(field->value.type))
- return Error("native_inline can only be defined on structs");
+ if (field->native_inline && !IsStruct(field->value.type) &&
+ !IsVectorOfStruct(field->value.type) &&
+ !IsVectorOfTable(field->value.type))
+ return Error(
+ "'native_inline' can only be defined on structs, vector of structs or "
+ "vector of tables");
auto nested = field->attributes.Lookup("nested_flatbuffer");
if (nested) {
@@ -1102,8 +1287,9 @@
uint8_t enum_idx;
if (vector_of_union_types) {
if (vector_of_union_types->size() <= count)
- return Error("union types vector smaller than union values vector"
- " for: " + field->name);
+ return Error(
+ "union types vector smaller than union values vector for: " +
+ field->name);
enum_idx = vector_of_union_types->Get(count);
} else {
ECHECK(atot(constant.c_str(), *this, &enum_idx));
@@ -1323,10 +1509,18 @@
ECHECK(atot(field_value.constant.c_str(), *this, &val)); \
builder_.PushElement(val); \
} else { \
- CTYPE val, valdef; \
- ECHECK(atot(field_value.constant.c_str(), *this, &val)); \
- ECHECK(atot(field->value.constant.c_str(), *this, &valdef)); \
- builder_.AddElement(field_value.offset, val, valdef); \
+ if (field->IsScalarOptional()) { \
+ if (field_value.constant != "null") { \
+ CTYPE val; \
+ ECHECK(atot(field_value.constant.c_str(), *this, &val)); \
+ builder_.AddElement(field_value.offset, val); \
+ } \
+ } else { \
+ CTYPE val, valdef; \
+ ECHECK(atot(field_value.constant.c_str(), *this, &val)); \
+ ECHECK(atot(field->value.constant.c_str(), *this, &valdef)); \
+ builder_.AddElement(field_value.offset, val, valdef); \
+ } \
} \
break;
FLATBUFFERS_GEN_TYPES_SCALAR(FLATBUFFERS_TD)
@@ -1390,90 +1584,6 @@
return NoError();
}
-static bool CompareSerializedScalars(const uint8_t *a, const uint8_t *b,
- const FieldDef &key) {
- switch (key.value.type.base_type) {
-#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, ...) \
- case BASE_TYPE_##ENUM: { \
- CTYPE def = static_cast<CTYPE>(0); \
- if (!a || !b) { StringToNumber(key.value.constant.c_str(), &def); } \
- const auto av = a ? ReadScalar<CTYPE>(a) : def; \
- const auto bv = b ? ReadScalar<CTYPE>(b) : def; \
- return av < bv; \
- }
- FLATBUFFERS_GEN_TYPES_SCALAR(FLATBUFFERS_TD)
-#undef FLATBUFFERS_TD
- default: {
- FLATBUFFERS_ASSERT(false && "scalar type expected");
- return false;
- }
- }
-}
-
-static bool CompareTablesByScalarKey(const Offset<Table> *_a,
- const Offset<Table> *_b,
- const FieldDef &key) {
- const voffset_t offset = key.value.offset;
- // Indirect offset pointer to table pointer.
- auto a = reinterpret_cast<const uint8_t *>(_a) + ReadScalar<uoffset_t>(_a);
- auto b = reinterpret_cast<const uint8_t *>(_b) + ReadScalar<uoffset_t>(_b);
- // Fetch field address from table.
- a = reinterpret_cast<const Table *>(a)->GetAddressOf(offset);
- b = reinterpret_cast<const Table *>(b)->GetAddressOf(offset);
- return CompareSerializedScalars(a, b, key);
-}
-
-static bool CompareTablesByStringKey(const Offset<Table> *_a,
- const Offset<Table> *_b,
- const FieldDef &key) {
- const voffset_t offset = key.value.offset;
- // Indirect offset pointer to table pointer.
- auto a = reinterpret_cast<const uint8_t *>(_a) + ReadScalar<uoffset_t>(_a);
- auto b = reinterpret_cast<const uint8_t *>(_b) + ReadScalar<uoffset_t>(_b);
- // Fetch field address from table.
- a = reinterpret_cast<const Table *>(a)->GetAddressOf(offset);
- b = reinterpret_cast<const Table *>(b)->GetAddressOf(offset);
- if (a && b) {
- // Indirect offset pointer to string pointer.
- a += ReadScalar<uoffset_t>(a);
- b += ReadScalar<uoffset_t>(b);
- return *reinterpret_cast<const String *>(a) <
- *reinterpret_cast<const String *>(b);
- } else {
- return a ? true : false;
- }
-}
-
-static void SwapSerializedTables(Offset<Table> *a, Offset<Table> *b) {
- // These are serialized offsets, so are relative where they are
- // stored in memory, so compute the distance between these pointers:
- ptrdiff_t diff = (b - a) * sizeof(Offset<Table>);
- FLATBUFFERS_ASSERT(diff >= 0); // Guaranteed by SimpleQsort.
- auto udiff = static_cast<uoffset_t>(diff);
- a->o = EndianScalar(ReadScalar<uoffset_t>(a) - udiff);
- b->o = EndianScalar(ReadScalar<uoffset_t>(b) + udiff);
- std::swap(*a, *b);
-}
-
-// See below for why we need our own sort :(
-template<typename T, typename F, typename S>
-void SimpleQsort(T *begin, T *end, size_t width, F comparator, S swapper) {
- if (end - begin <= static_cast<ptrdiff_t>(width)) return;
- auto l = begin + width;
- auto r = end;
- while (l < r) {
- if (comparator(begin, l)) {
- r -= width;
- swapper(l, r);
- } else {
- l += width;
- }
- }
- l -= width;
- swapper(begin, l);
- SimpleQsort(begin, l, width, comparator, swapper);
- SimpleQsort(r, end, width, comparator, swapper);
-}
CheckedError Parser::ParseAlignAttribute(const std::string &align_constant,
size_t min_align, size_t *align) {
@@ -1801,22 +1911,6 @@
return Error("cannot parse value starting with: " + TokenToStringId(token_));
}
-// Re-pack helper (ParseSingleValue) to normalize defaults of scalars.
-template<typename T> inline void SingleValueRepack(Value &e, T val) {
- // Remove leading zeros.
- if (IsInteger(e.type.base_type)) { e.constant = NumToString(val); }
-}
-#if defined(FLATBUFFERS_HAS_NEW_STRTOD) && (FLATBUFFERS_HAS_NEW_STRTOD > 0)
-// Normalize defaults NaN to unsigned quiet-NaN(0) if value was parsed from
-// hex-float literal.
-static inline void SingleValueRepack(Value &e, float val) {
- if (val != val) e.constant = "nan";
-}
-static inline void SingleValueRepack(Value &e, double val) {
- if (val != val) e.constant = "nan";
-}
-#endif
-
CheckedError Parser::ParseFunction(const std::string *name, Value &e) {
ParseDepthGuard depth_guard(this);
ECHECK(depth_guard.Check());
@@ -2088,13 +2182,6 @@
return vals.vec.empty() ? nullptr : vals.vec.back();
}
-template<typename T> static uint64_t EnumDistanceImpl(T e1, T e2) {
- if (e1 < e2) { std::swap(e1, e2); } // use std for scalars
- // Signed overflow may occur, use unsigned calculation.
- // The unsigned overflow is well-defined by C++ standard (modulo 2^n).
- return static_cast<uint64_t>(e1) - static_cast<uint64_t>(e2);
-}
-
uint64_t EnumDef::Distance(const EnumVal *v1, const EnumVal *v2) const {
return IsUInt64() ? EnumDistanceImpl(v1->GetAsUInt64(), v2->GetAsUInt64())
: EnumDistanceImpl(v1->GetAsInt64(), v2->GetAsInt64());
@@ -2312,6 +2399,9 @@
// todo: Convert to the Error in the future?
Warning("underlying type of bit_flags enum must be unsigned");
}
+ if (enum_def->attributes.Lookup("force_align")) {
+ return Error("`force_align` is not a valid attribute for Enums. ");
+ }
EnumValBuilder evb(*this, *enum_def);
EXPECT('{');
// A lot of code generatos expect that an enum is not-empty.
@@ -2448,12 +2538,19 @@
return NoError();
}
+std::vector<IncludedFile> Parser::GetIncludedFiles() const {
+ const auto it = files_included_per_file_.find(file_being_parsed_);
+ if (it == files_included_per_file_.end()) { return {}; }
+
+ return { it->second.cbegin(), it->second.cend() };
+}
+
bool Parser::SupportsOptionalScalars(const flatbuffers::IDLOptions &opts) {
static FLATBUFFERS_CONSTEXPR unsigned long supported_langs =
IDLOptions::kRust | IDLOptions::kSwift | IDLOptions::kLobster |
IDLOptions::kKotlin | IDLOptions::kCpp | IDLOptions::kJava |
IDLOptions::kCSharp | IDLOptions::kTs | IDLOptions::kBinary |
- IDLOptions::kGo;
+ IDLOptions::kGo | IDLOptions::kPython | IDLOptions::kJson;
unsigned long langs = opts.lang_to_generate;
return (langs > 0 && langs < IDLOptions::kMAX) && !(langs & ~supported_langs);
}
@@ -2508,12 +2605,6 @@
return full_qualified_name.substr(previous, current - previous);
}
-static bool compareFieldDefs(const FieldDef *a, const FieldDef *b) {
- auto a_id = atoi(a->attributes.Lookup("id")->constant.c_str());
- auto b_id = atoi(b->attributes.Lookup("id")->constant.c_str());
- return a_id < b_id;
-}
-
CheckedError Parser::ParseDecl(const char *filename) {
std::vector<std::string> dc = doc_comment_;
bool fixed = IsIdent("struct");
@@ -2884,7 +2975,11 @@
if (key == "default") {
// Temp: skip non-numeric and non-boolean defaults (enums).
auto numeric = strpbrk(val.c_str(), "0123456789-+.");
- if (IsScalar(type.base_type) && numeric == val.c_str()) {
+ if (IsFloat(type.base_type) &&
+ (val == "inf" || val == "+inf" || val == "-inf")) {
+ // Prefer to be explicit with +inf.
+ field->value.constant = val == "inf" ? "+inf" : val;
+ } else if (IsScalar(type.base_type) && numeric == val.c_str()) {
field->value.constant = val;
} else if (val == "true") {
field->value.constant = val;
@@ -3032,7 +3127,8 @@
case kTokenIntegerConstant:
case kTokenFloatConstant: NEXT(); break;
default:
- if (IsIdent("true") || IsIdent("false") || IsIdent("null")) {
+ if (IsIdent("true") || IsIdent("false") || IsIdent("null") ||
+ IsIdent("inf")) {
NEXT();
} else
return TokenError();
@@ -3245,32 +3341,79 @@
for (auto val_it = enum_def.Vals().begin();
val_it != enum_def.Vals().end(); ++val_it) {
auto &val = **val_it;
+
if (!(opts.lang_to_generate != 0 && SupportsAdvancedUnionFeatures()) &&
(IsStruct(val.union_type) || IsString(val.union_type)))
+
return Error(
"only tables can be union elements in the generated language: " +
val.name);
}
}
}
+
+ auto err = CheckPrivateLeak();
+ if (err.Check()) return err;
+
// Parse JSON object only if the scheme has been parsed.
if (token_ == '{') { ECHECK(DoParseJson()); }
- EXPECT(kTokenEof);
return NoError();
}
-// Generate a unique hash for a file based on its name and contents (if any).
-static uint64_t HashFile(const char *source_filename, const char *source) {
- uint64_t hash = 0;
+CheckedError Parser::CheckPrivateLeak() {
+ if (!opts.no_leak_private_annotations) return NoError();
+ // Iterate over all structs/tables to validate we arent leaking
+ // any private (structs/tables/enums)
+ for (auto it = structs_.vec.begin(); it != structs_.vec.end(); it++) {
+ auto &struct_def = **it;
+ for (auto fld_it = struct_def.fields.vec.begin();
+ fld_it != struct_def.fields.vec.end(); ++fld_it) {
+ auto &field = **fld_it;
- if (source_filename)
- hash = HashFnv1a<uint64_t>(StripPath(source_filename).c_str());
-
- if (source && *source) hash ^= HashFnv1a<uint64_t>(source);
-
- return hash;
+ if (field.value.type.enum_def) {
+ auto err =
+ CheckPrivatelyLeakedFields(struct_def, *field.value.type.enum_def);
+ if (err.Check()) { return err; }
+ } else if (field.value.type.struct_def) {
+ auto err = CheckPrivatelyLeakedFields(struct_def,
+ *field.value.type.struct_def);
+ if (err.Check()) { return err; }
+ }
+ }
+ }
+ // Iterate over all enums to validate we arent leaking
+ // any private (structs/tables)
+ for (auto it = enums_.vec.begin(); it != enums_.vec.end(); ++it) {
+ auto &enum_def = **it;
+ if (enum_def.is_union) {
+ for (auto val_it = enum_def.Vals().begin();
+ val_it != enum_def.Vals().end(); ++val_it) {
+ auto &val = **val_it;
+ if (val.union_type.struct_def) {
+ auto err =
+ CheckPrivatelyLeakedFields(enum_def, *val.union_type.struct_def);
+ if (err.Check()) { return err; }
+ }
+ }
+ }
+ }
+ return NoError();
}
+CheckedError Parser::CheckPrivatelyLeakedFields(const Definition &def,
+ const Definition &value_type) {
+ if (!opts.no_leak_private_annotations) return NoError();
+ const auto is_private = def.attributes.Lookup("private");
+ const auto is_field_private = value_type.attributes.Lookup("private");
+ if (!is_private && is_field_private) {
+ return Error(
+ "Leaking private implementation, verify all objects have similar "
+ "annotations");
+ }
+ return NoError();
+}
+
+
CheckedError Parser::DoParse(const char *source, const char **include_paths,
const char *source_filename,
const char *include_filename) {
@@ -3285,7 +3428,7 @@
if (included_files_.find(source_hash) == included_files_.end()) {
included_files_[source_hash] = include_filename ? include_filename : "";
- files_included_per_file_[source_filename] = std::set<std::string>();
+ files_included_per_file_[source_filename] = std::set<IncludedFile>();
} else {
return NoError();
}
@@ -3333,8 +3476,12 @@
}
if (filepath.empty())
return Error("unable to locate include file: " + name);
- if (source_filename)
- files_included_per_file_[source_filename].insert(filepath);
+ if (source_filename) {
+ IncludedFile included_file;
+ included_file.filename = filepath;
+ included_file.schema_name = name;
+ files_included_per_file_[source_filename].insert(included_file);
+ }
std::string contents;
bool file_loaded = LoadFile(filepath.c_str(), true, &contents);
@@ -3423,6 +3570,7 @@
ECHECK(ParseDecl(source_filename));
}
}
+ EXPECT(kTokenEof);
if (opts.warnings_as_errors && has_warning_) {
return Error("treating warnings as errors, failed due to above warnings");
}
@@ -3470,11 +3618,11 @@
// Workaround the lack of const accessor in C++98 maps.
auto &new_files =
- (*const_cast<std::map<std::string, std::set<std::string>> *>(
+ (*const_cast<std::map<std::string, std::set<IncludedFile>> *>(
&files_included_per_file_))[current];
for (auto it = new_files.begin(); it != new_files.end(); ++it) {
- if (included_files.find(*it) == included_files.end())
- to_process.push_back(*it);
+ if (included_files.find(it->filename) == included_files.end())
+ to_process.push_back(it->filename);
}
}
@@ -3483,18 +3631,6 @@
// Schema serialization functionality:
-template<typename T> bool compareName(const T *a, const T *b) {
- return a->defined_namespace->GetFullyQualifiedName(a->name) <
- b->defined_namespace->GetFullyQualifiedName(b->name);
-}
-
-template<typename T> void AssignIndices(const std::vector<T *> &defvec) {
- // Pre-sort these vectors, such that we can set the correct indices for them.
- auto vec = defvec;
- std::sort(vec.begin(), vec.end(), compareName<T>);
- for (int i = 0; i < static_cast<int>(vec.size()); i++) vec[i]->index = i;
-}
-
void Parser::Serialize() {
builder_.Clear();
AssignIndices(structs_.vec);
@@ -3536,7 +3672,7 @@
RelativeToRootPath(opts.project_root, f->first));
for (auto i = f->second.begin(); i != f->second.end(); i++) {
included_files.push_back(builder_.CreateSharedString(
- RelativeToRootPath(opts.project_root, *i)));
+ RelativeToRootPath(opts.project_root, i->filename)));
}
const auto included_files__ = builder_.CreateVector(included_files);
included_files.clear();
@@ -3564,32 +3700,6 @@
}
}
-static Namespace *GetNamespace(
- const std::string &qualified_name, std::vector<Namespace *> &namespaces,
- std::map<std::string, Namespace *> &namespaces_index) {
- size_t dot = qualified_name.find_last_of('.');
- std::string namespace_name = (dot != std::string::npos)
- ? std::string(qualified_name.c_str(), dot)
- : "";
- Namespace *&ns = namespaces_index[namespace_name];
-
- if (!ns) {
- ns = new Namespace();
- namespaces.push_back(ns);
-
- size_t pos = 0;
-
- for (;;) {
- dot = qualified_name.find('.', pos);
- if (dot == std::string::npos) { break; }
- ns->components.push_back(qualified_name.substr(pos, dot - pos));
- pos = dot + 1;
- }
- }
-
- return ns;
-}
-
Offset<reflection::Object> StructDef::Serialize(FlatBufferBuilder *builder,
const Parser &parser) const {
std::vector<Offset<reflection::Field>> field_offsets;
@@ -3629,6 +3739,14 @@
delete field_def;
return false;
}
+ if (field_def->key) {
+ if (has_key) {
+ // only one field may be set as key
+ delete field_def;
+ return false;
+ }
+ has_key = true;
+ }
if (fixed) {
// Recompute padding since that's currently not serialized.
auto size = InlineSize(field_def->value.type);
@@ -3986,7 +4104,9 @@
++s) {
for (auto f = s->included_filenames()->begin();
f != s->included_filenames()->end(); ++f) {
- files_included_per_file_[s->filename()->str()].insert(f->str());
+ IncludedFile included_file;
+ included_file.filename = f->str();
+ files_included_per_file_[s->filename()->str()].insert(included_file);
}
}
diff --git a/src/namer.h b/src/namer.h
index 6c539cb..8fd8354 100644
--- a/src/namer.h
+++ b/src/namer.h
@@ -1,7 +1,6 @@
#ifndef FLATBUFFERS_NAMER
#define FLATBUFFERS_NAMER
-#include "flatbuffers/idl.h"
#include "flatbuffers/util.h"
namespace flatbuffers {
@@ -62,6 +61,16 @@
// e.g. `Enum::MyVariant` uses `::`.
std::string enum_variant_seperator;
+ // Configures, when formatting code, whether symbols are checked against
+ // keywords and escaped before or after case conversion. It does not make
+ // sense to do so before, but its legacy behavior. :shrug:
+ // TODO(caspern): Deprecate.
+ enum class Escape {
+ BeforeConvertingCase,
+ AfterConvertingCase,
+ };
+ Escape escape_keywords;
+
// Namespaces
// e.g. `namespace my_namespace {}`
@@ -95,64 +104,55 @@
std::string filename_suffix;
// Extension for generated files, e.g. ".cpp" or ".rs".
std::string filename_extension;
-
- // This is a temporary helper function for code generators to call until all
- // code generators are using `Namer`. After that point, we can centralize
- // flag-overriding logic into flatc.cpp
- Config WithFlagOptions(const IDLOptions &opts,
- const std::string &path) const {
- Config result = *this;
- result.object_prefix = opts.object_prefix;
- result.object_suffix = opts.object_suffix;
- result.output_path = path;
- result.filename_suffix = opts.filename_suffix;
- return result;
- }
};
Namer(Config config, std::set<std::string> keywords)
: config_(config), keywords_(std::move(keywords)) {}
- std::string Type(const std::string &s) const {
- return Format(s, config_.types);
+ virtual ~Namer() {}
+
+ template<typename T> std::string Method(const T &s) const {
+ return Method(s.name);
}
- std::string Method(const std::string &s) const {
+ virtual std::string Method(const std::string &pre,
+ const std::string &mid,
+ const std::string &suf) const {
+ return Format(pre + "_" + mid + "_" + suf, config_.methods);
+ }
+ virtual std::string Method(const std::string &pre,
+ const std::string &suf) const {
+ return Format(pre + "_" + suf, config_.methods);
+ }
+ virtual std::string Method(const std::string &s) const {
return Format(s, config_.methods);
}
- std::string Constant(const std::string &s) const {
+ virtual std::string Constant(const std::string &s) const {
return Format(s, config_.constants);
}
- std::string Function(const std::string &s) const {
+ virtual std::string Function(const std::string &s) const {
return Format(s, config_.functions);
}
- std::string Field(const std::string &s) const {
- return Format(s, config_.fields);
- }
-
- std::string Variable(const std::string &s) const {
+ virtual std::string Variable(const std::string &s) const {
return Format(s, config_.variables);
}
- std::string Variant(const std::string &s) const {
- return Format(s, config_.variants);
+ template<typename T>
+ std::string Variable(const std::string &p, const T &s) const {
+ return Format(p + "_" + s.name, config_.variables);
+ }
+ virtual std::string Variable(const std::string &p,
+ const std::string &s) const {
+ return Format(p + "_" + s, config_.variables);
}
- std::string EnumVariant(const std::string &e, const std::string v) const {
- return Type(e) + config_.enum_variant_seperator + Variant(v);
- }
-
- std::string ObjectType(const std::string &s) const {
- return config_.object_prefix + Type(s) + config_.object_suffix;
- }
-
- std::string Namespace(const std::string &s) const {
+ virtual std::string Namespace(const std::string &s) const {
return Format(s, config_.namespaces);
}
- std::string Namespace(const std::vector<std::string> &ns) const {
+ virtual std::string Namespace(const std::vector<std::string> &ns) const {
std::string result;
for (auto it = ns.begin(); it != ns.end(); it++) {
if (it != ns.begin()) result += config_.namespace_seperator;
@@ -161,26 +161,32 @@
return result;
}
- std::string NamespacedType(const std::vector<std::string> &ns,
- const std::string &s) const {
- return Namespace(ns) + config_.namespace_seperator + Type(s);
+ virtual std::string NamespacedType(const std::vector<std::string> &ns,
+ const std::string &s) const {
+ return (ns.empty() ? "" : (Namespace(ns) + config_.namespace_seperator)) +
+ Type(s);
}
// Returns `filename` with the right casing, suffix, and extension.
- std::string File(const std::string &filename,
- SkipFile skips = SkipFile::None) const {
+ virtual std::string File(const std::string &filename,
+ SkipFile skips = SkipFile::None) const {
const bool skip_suffix = (skips & SkipFile::Suffix) != SkipFile::None;
const bool skip_ext = (skips & SkipFile::Extension) != SkipFile::None;
return ConvertCase(filename, config_.filenames, Case::kUpperCamel) +
(skip_suffix ? "" : config_.filename_suffix) +
(skip_ext ? "" : config_.filename_extension);
}
+ template<typename T>
+ std::string File(const T &f, SkipFile skips = SkipFile::None) const {
+ return File(f.name, skips);
+ }
+
// Formats `directories` prefixed with the output_path and joined with the
// right seperator. Output path prefixing and the trailing separator may be
// skiped using `skips`.
// Callers may want to use `EnsureDirExists` with the result.
- std::string Directories(const std::vector<std::string> &directories,
- SkipDir skips = SkipDir::None) const {
+ virtual std::string Directories(const std::vector<std::string> &directories,
+ SkipDir skips = SkipDir::None) const {
const bool skip_output_path =
(skips & SkipDir::OutputPath) != SkipDir::None;
const bool skip_trailing_seperator =
@@ -194,7 +200,7 @@
return result;
}
- std::string EscapeKeyword(const std::string &name) const {
+ virtual std::string EscapeKeyword(const std::string &name) const {
if (keywords_.find(name) == keywords_.end()) {
return name;
} else {
@@ -202,12 +208,55 @@
}
}
- private:
- std::string Format(const std::string &s, Case casing) const {
- // NOTE: If you need to escape keywords after converting case, which would
- // make more sense than this, make it a config option.
- return ConvertCase(EscapeKeyword(s), casing, Case::kLowerCamel);
+ virtual std::string Type(const std::string &s) const {
+ return Format(s, config_.types);
}
+ virtual std::string Type(const std::string &t, const std::string &s) const {
+ return Format(t + "_" + s, config_.types);
+ }
+
+ virtual std::string ObjectType(const std::string &s) const {
+ return config_.object_prefix + Type(s) + config_.object_suffix;
+ }
+
+ virtual std::string Field(const std::string &s) const {
+ return Format(s, config_.fields);
+ }
+
+ virtual std::string Variant(const std::string &s) const {
+ return Format(s, config_.variants);
+ }
+
+ virtual std::string Format(const std::string &s, Case casing) const {
+ if (config_.escape_keywords == Config::Escape::BeforeConvertingCase) {
+ return ConvertCase(EscapeKeyword(s), casing, Case::kLowerCamel);
+ } else {
+ return EscapeKeyword(ConvertCase(s, casing, Case::kLowerCamel));
+ }
+ }
+
+ // Denamespaces a string (e.g. The.Quick.Brown.Fox) by returning the last part
+ // after the `delimiter` (Fox) and placing the rest in `namespace_prefix`
+ // (The.Quick.Brown).
+ virtual std::string Denamespace(const std::string &s,
+ std::string &namespace_prefix,
+ const char delimiter = '.') const {
+ const size_t pos = s.find_last_of(delimiter);
+ if (pos == std::string::npos) {
+ namespace_prefix = "";
+ return s;
+ }
+ namespace_prefix = s.substr(0, pos);
+ return s.substr(pos + 1);
+ }
+
+ // Same as above, but disregards the prefix.
+ virtual std::string Denamespace(const std::string &s,
+ const char delimiter = '.') const {
+ std::string prefix;
+ return Denamespace(s, prefix, delimiter);
+ }
+
const Config config_;
const std::set<std::string> keywords_;
};
diff --git a/src/reflection.cpp b/src/reflection.cpp
index 6bba28c..9abfd9f 100644
--- a/src/reflection.cpp
+++ b/src/reflection.cpp
@@ -22,6 +22,238 @@
namespace flatbuffers {
+namespace {
+
+static void CopyInline(FlatBufferBuilder &fbb, const reflection::Field &fielddef,
+ const Table &table, size_t align, size_t size) {
+ fbb.Align(align);
+ fbb.PushBytes(table.GetStruct<const uint8_t *>(fielddef.offset()), size);
+ fbb.TrackField(fielddef.offset(), fbb.GetSize());
+}
+
+static bool VerifyStruct(flatbuffers::Verifier &v,
+ const flatbuffers::Table &parent_table,
+ voffset_t field_offset, const reflection::Object &obj,
+ bool required) {
+ auto offset = parent_table.GetOptionalFieldOffset(field_offset);
+ if (required && !offset) { return false; }
+
+ return !offset ||
+ v.VerifyFieldStruct(reinterpret_cast<const uint8_t *>(&parent_table),
+ offset, obj.bytesize(), obj.minalign());
+}
+
+static bool VerifyVectorOfStructs(flatbuffers::Verifier &v,
+ const flatbuffers::Table &parent_table,
+ voffset_t field_offset,
+ const reflection::Object &obj, bool required) {
+ auto p = parent_table.GetPointer<const uint8_t *>(field_offset);
+ if (required && !p) { return false; }
+
+ return !p || v.VerifyVectorOrString(p, obj.bytesize());
+}
+
+// forward declare to resolve cyclic deps between VerifyObject and VerifyVector
+static bool VerifyObject(flatbuffers::Verifier &v, const reflection::Schema &schema,
+ const reflection::Object &obj,
+ const flatbuffers::Table *table, bool required);
+
+static bool VerifyUnion(flatbuffers::Verifier &v, const reflection::Schema &schema,
+ uint8_t utype, const uint8_t *elem,
+ const reflection::Field &union_field) {
+ if (!utype) return true; // Not present.
+ auto fb_enum = schema.enums()->Get(union_field.type()->index());
+ if (utype >= fb_enum->values()->size()) return false;
+ auto elem_type = fb_enum->values()->Get(utype)->union_type();
+ switch (elem_type->base_type()) {
+ case reflection::Obj: {
+ auto elem_obj = schema.objects()->Get(elem_type->index());
+ if (elem_obj->is_struct()) {
+ return v.VerifyFromPointer(elem, elem_obj->bytesize());
+ } else {
+ return VerifyObject(v, schema, *elem_obj,
+ reinterpret_cast<const flatbuffers::Table *>(elem),
+ true);
+ }
+ }
+ case reflection::String:
+ return v.VerifyString(
+ reinterpret_cast<const flatbuffers::String *>(elem));
+ default: return false;
+ }
+}
+
+static bool VerifyVector(flatbuffers::Verifier &v, const reflection::Schema &schema,
+ const flatbuffers::Table &table,
+ const reflection::Field &vec_field) {
+ FLATBUFFERS_ASSERT(vec_field.type()->base_type() == reflection::Vector);
+ if (!table.VerifyField<uoffset_t>(v, vec_field.offset(), sizeof(uoffset_t)))
+ return false;
+
+ switch (vec_field.type()->element()) {
+ case reflection::UType:
+ return v.VerifyVector(flatbuffers::GetFieldV<uint8_t>(table, vec_field));
+ case reflection::Bool:
+ case reflection::Byte:
+ case reflection::UByte:
+ return v.VerifyVector(flatbuffers::GetFieldV<int8_t>(table, vec_field));
+ case reflection::Short:
+ case reflection::UShort:
+ return v.VerifyVector(flatbuffers::GetFieldV<int16_t>(table, vec_field));
+ case reflection::Int:
+ case reflection::UInt:
+ return v.VerifyVector(flatbuffers::GetFieldV<int32_t>(table, vec_field));
+ case reflection::Long:
+ case reflection::ULong:
+ return v.VerifyVector(flatbuffers::GetFieldV<int64_t>(table, vec_field));
+ case reflection::Float:
+ return v.VerifyVector(flatbuffers::GetFieldV<float>(table, vec_field));
+ case reflection::Double:
+ return v.VerifyVector(flatbuffers::GetFieldV<double>(table, vec_field));
+ case reflection::String: {
+ auto vec_string =
+ flatbuffers::GetFieldV<flatbuffers::Offset<flatbuffers::String>>(
+ table, vec_field);
+ if (v.VerifyVector(vec_string) && v.VerifyVectorOfStrings(vec_string)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ case reflection::Obj: {
+ auto obj = schema.objects()->Get(vec_field.type()->index());
+ if (obj->is_struct()) {
+ return VerifyVectorOfStructs(v, table, vec_field.offset(), *obj,
+ vec_field.required());
+ } else {
+ auto vec =
+ flatbuffers::GetFieldV<flatbuffers::Offset<flatbuffers::Table>>(
+ table, vec_field);
+ if (!v.VerifyVector(vec)) return false;
+ if (!vec) return true;
+ for (uoffset_t j = 0; j < vec->size(); j++) {
+ if (!VerifyObject(v, schema, *obj, vec->Get(j), true)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ case reflection::Union: {
+ auto vec = flatbuffers::GetFieldV<flatbuffers::Offset<uint8_t>>(
+ table, vec_field);
+ if (!v.VerifyVector(vec)) return false;
+ if (!vec) return true;
+ auto type_vec = table.GetPointer<Vector<uint8_t> *>(vec_field.offset() -
+ sizeof(voffset_t));
+ if (!v.VerifyVector(type_vec)) return false;
+ for (uoffset_t j = 0; j < vec->size(); j++) {
+ // get union type from the prev field
+ auto utype = type_vec->Get(j);
+ auto elem = vec->Get(j);
+ if (!VerifyUnion(v, schema, utype, elem, vec_field)) return false;
+ }
+ return true;
+ }
+ case reflection::Vector:
+ case reflection::None:
+ default: FLATBUFFERS_ASSERT(false); return false;
+ }
+}
+
+static bool VerifyObject(flatbuffers::Verifier &v, const reflection::Schema &schema,
+ const reflection::Object &obj,
+ const flatbuffers::Table *table, bool required) {
+ if (!table) return !required;
+ if (!table->VerifyTableStart(v)) return false;
+ for (uoffset_t i = 0; i < obj.fields()->size(); i++) {
+ auto field_def = obj.fields()->Get(i);
+ switch (field_def->type()->base_type()) {
+ case reflection::None: FLATBUFFERS_ASSERT(false); break;
+ case reflection::UType:
+ if (!table->VerifyField<uint8_t>(v, field_def->offset(),
+ sizeof(uint8_t)))
+ return false;
+ break;
+ case reflection::Bool:
+ case reflection::Byte:
+ case reflection::UByte:
+ if (!table->VerifyField<int8_t>(v, field_def->offset(), sizeof(int8_t)))
+ return false;
+ break;
+ case reflection::Short:
+ case reflection::UShort:
+ if (!table->VerifyField<int16_t>(v, field_def->offset(),
+ sizeof(int16_t)))
+ return false;
+ break;
+ case reflection::Int:
+ case reflection::UInt:
+ if (!table->VerifyField<int32_t>(v, field_def->offset(),
+ sizeof(int32_t)))
+ return false;
+ break;
+ case reflection::Long:
+ case reflection::ULong:
+ if (!table->VerifyField<int64_t>(v, field_def->offset(),
+ sizeof(int64_t)))
+ return false;
+ break;
+ case reflection::Float:
+ if (!table->VerifyField<float>(v, field_def->offset(), sizeof(float)))
+ return false;
+ break;
+ case reflection::Double:
+ if (!table->VerifyField<double>(v, field_def->offset(), sizeof(double)))
+ return false;
+ break;
+ case reflection::String:
+ if (!table->VerifyField<uoffset_t>(v, field_def->offset(),
+ sizeof(uoffset_t)) ||
+ !v.VerifyString(flatbuffers::GetFieldS(*table, *field_def))) {
+ return false;
+ }
+ break;
+ case reflection::Vector:
+ if (!VerifyVector(v, schema, *table, *field_def)) return false;
+ break;
+ case reflection::Obj: {
+ auto child_obj = schema.objects()->Get(field_def->type()->index());
+ if (child_obj->is_struct()) {
+ if (!VerifyStruct(v, *table, field_def->offset(), *child_obj,
+ field_def->required())) {
+ return false;
+ }
+ } else {
+ if (!VerifyObject(v, schema, *child_obj,
+ flatbuffers::GetFieldT(*table, *field_def),
+ field_def->required())) {
+ return false;
+ }
+ }
+ break;
+ }
+ case reflection::Union: {
+ // get union type from the prev field
+ voffset_t utype_offset = field_def->offset() - sizeof(voffset_t);
+ auto utype = table->GetField<uint8_t>(utype_offset, 0);
+ auto uval = reinterpret_cast<const uint8_t *>(
+ flatbuffers::GetFieldT(*table, *field_def));
+ if (!VerifyUnion(v, schema, utype, uval, *field_def)) { return false; }
+ break;
+ }
+ default: FLATBUFFERS_ASSERT(false); break;
+ }
+ }
+
+ if (!v.EndTable()) return false;
+
+ return true;
+}
+
+
+} // namespace
+
int64_t GetAnyValueI(reflection::BaseType type, const uint8_t *data) {
// clang-format off
#define FLATBUFFERS_GET(T) static_cast<int64_t>(ReadScalar<T>(data))
@@ -120,6 +352,23 @@
}
}
+void ForAllFields(const reflection::Object *object, bool reverse,
+ std::function<void(const reflection::Field *)> func) {
+ std::vector<uint32_t> field_to_id_map;
+ field_to_id_map.resize(object->fields()->size());
+
+ // Create the mapping of field ID to the index into the vector.
+ for (uint32_t i = 0; i < object->fields()->size(); ++i) {
+ auto field = object->fields()->Get(i);
+ field_to_id_map[field->id()] = i;
+ }
+
+ for (size_t i = 0; i < field_to_id_map.size(); ++i) {
+ func(object->fields()->Get(
+ field_to_id_map[reverse ? field_to_id_map.size() - i + 1 : i]));
+ }
+}
+
void SetAnyValueI(reflection::BaseType type, uint8_t *data, int64_t val) {
// clang-format off
#define FLATBUFFERS_SET(T) WriteScalar(data, static_cast<T>(val))
@@ -367,12 +616,8 @@
return flatbuf.data() + insertion_point + root_offset;
}
-void CopyInline(FlatBufferBuilder &fbb, const reflection::Field &fielddef,
- const Table &table, size_t align, size_t size) {
- fbb.Align(align);
- fbb.PushBytes(table.GetStruct<const uint8_t *>(fielddef.offset()), size);
- fbb.TrackField(fielddef.offset(), fbb.GetSize());
-}
+
+
Offset<const Table *> CopyTable(FlatBufferBuilder &fbb,
const reflection::Schema &schema,
@@ -498,231 +743,22 @@
}
}
-bool VerifyStruct(flatbuffers::Verifier &v,
- const flatbuffers::Table &parent_table,
- voffset_t field_offset, const reflection::Object &obj,
- bool required) {
- auto offset = parent_table.GetOptionalFieldOffset(field_offset);
- if (required && !offset) { return false; }
-
- return !offset ||
- v.VerifyFieldStruct(reinterpret_cast<const uint8_t *>(&parent_table),
- offset, obj.bytesize(), obj.minalign());
-}
-
-bool VerifyVectorOfStructs(flatbuffers::Verifier &v,
- const flatbuffers::Table &parent_table,
- voffset_t field_offset,
- const reflection::Object &obj, bool required) {
- auto p = parent_table.GetPointer<const uint8_t *>(field_offset);
- if (required && !p) { return false; }
-
- return !p || v.VerifyVectorOrString(p, obj.bytesize());
-}
-
-// forward declare to resolve cyclic deps between VerifyObject and VerifyVector
-bool VerifyObject(flatbuffers::Verifier &v, const reflection::Schema &schema,
- const reflection::Object &obj,
- const flatbuffers::Table *table, bool required);
-
-bool VerifyUnion(flatbuffers::Verifier &v, const reflection::Schema &schema,
- uint8_t utype, const uint8_t *elem,
- const reflection::Field &union_field) {
- if (!utype) return true; // Not present.
- auto fb_enum = schema.enums()->Get(union_field.type()->index());
- if (utype >= fb_enum->values()->size()) return false;
- auto elem_type = fb_enum->values()->Get(utype)->union_type();
- switch (elem_type->base_type()) {
- case reflection::Obj: {
- auto elem_obj = schema.objects()->Get(elem_type->index());
- if (elem_obj->is_struct()) {
- return v.VerifyFromPointer(elem, elem_obj->bytesize());
- } else {
- return VerifyObject(v, schema, *elem_obj,
- reinterpret_cast<const flatbuffers::Table *>(elem),
- true);
- }
- }
- case reflection::String:
- return v.VerifyString(
- reinterpret_cast<const flatbuffers::String *>(elem));
- default: return false;
- }
-}
-
-bool VerifyVector(flatbuffers::Verifier &v, const reflection::Schema &schema,
- const flatbuffers::Table &table,
- const reflection::Field &vec_field) {
- FLATBUFFERS_ASSERT(vec_field.type()->base_type() == reflection::Vector);
- if (!table.VerifyField<uoffset_t>(v, vec_field.offset(), sizeof(uoffset_t)))
- return false;
-
- switch (vec_field.type()->element()) {
- case reflection::UType:
- return v.VerifyVector(flatbuffers::GetFieldV<uint8_t>(table, vec_field));
- case reflection::Bool:
- case reflection::Byte:
- case reflection::UByte:
- return v.VerifyVector(flatbuffers::GetFieldV<int8_t>(table, vec_field));
- case reflection::Short:
- case reflection::UShort:
- return v.VerifyVector(flatbuffers::GetFieldV<int16_t>(table, vec_field));
- case reflection::Int:
- case reflection::UInt:
- return v.VerifyVector(flatbuffers::GetFieldV<int32_t>(table, vec_field));
- case reflection::Long:
- case reflection::ULong:
- return v.VerifyVector(flatbuffers::GetFieldV<int64_t>(table, vec_field));
- case reflection::Float:
- return v.VerifyVector(flatbuffers::GetFieldV<float>(table, vec_field));
- case reflection::Double:
- return v.VerifyVector(flatbuffers::GetFieldV<double>(table, vec_field));
- case reflection::String: {
- auto vec_string =
- flatbuffers::GetFieldV<flatbuffers::Offset<flatbuffers::String>>(
- table, vec_field);
- if (v.VerifyVector(vec_string) && v.VerifyVectorOfStrings(vec_string)) {
- return true;
- } else {
- return false;
- }
- }
- case reflection::Obj: {
- auto obj = schema.objects()->Get(vec_field.type()->index());
- if (obj->is_struct()) {
- return VerifyVectorOfStructs(v, table, vec_field.offset(), *obj,
- vec_field.required());
- } else {
- auto vec =
- flatbuffers::GetFieldV<flatbuffers::Offset<flatbuffers::Table>>(
- table, vec_field);
- if (!v.VerifyVector(vec)) return false;
- if (!vec) return true;
- for (uoffset_t j = 0; j < vec->size(); j++) {
- if (!VerifyObject(v, schema, *obj, vec->Get(j), true)) {
- return false;
- }
- }
- return true;
- }
- }
- case reflection::Union: {
- auto vec = flatbuffers::GetFieldV<flatbuffers::Offset<uint8_t>>(
- table, vec_field);
- if (!v.VerifyVector(vec)) return false;
- if (!vec) return true;
- auto type_vec = table.GetPointer<Vector<uint8_t> *>(vec_field.offset() -
- sizeof(voffset_t));
- if (!v.VerifyVector(type_vec)) return false;
- for (uoffset_t j = 0; j < vec->size(); j++) {
- // get union type from the prev field
- auto utype = type_vec->Get(j);
- auto elem = vec->Get(j);
- if (!VerifyUnion(v, schema, utype, elem, vec_field)) return false;
- }
- return true;
- }
- case reflection::Vector:
- case reflection::None:
- default: FLATBUFFERS_ASSERT(false); return false;
- }
-}
-
-bool VerifyObject(flatbuffers::Verifier &v, const reflection::Schema &schema,
- const reflection::Object &obj,
- const flatbuffers::Table *table, bool required) {
- if (!table) return !required;
- if (!table->VerifyTableStart(v)) return false;
- for (uoffset_t i = 0; i < obj.fields()->size(); i++) {
- auto field_def = obj.fields()->Get(i);
- switch (field_def->type()->base_type()) {
- case reflection::None: FLATBUFFERS_ASSERT(false); break;
- case reflection::UType:
- if (!table->VerifyField<uint8_t>(v, field_def->offset(),
- sizeof(uint8_t)))
- return false;
- break;
- case reflection::Bool:
- case reflection::Byte:
- case reflection::UByte:
- if (!table->VerifyField<int8_t>(v, field_def->offset(), sizeof(int8_t)))
- return false;
- break;
- case reflection::Short:
- case reflection::UShort:
- if (!table->VerifyField<int16_t>(v, field_def->offset(),
- sizeof(int16_t)))
- return false;
- break;
- case reflection::Int:
- case reflection::UInt:
- if (!table->VerifyField<int32_t>(v, field_def->offset(),
- sizeof(int32_t)))
- return false;
- break;
- case reflection::Long:
- case reflection::ULong:
- if (!table->VerifyField<int64_t>(v, field_def->offset(),
- sizeof(int64_t)))
- return false;
- break;
- case reflection::Float:
- if (!table->VerifyField<float>(v, field_def->offset(), sizeof(float)))
- return false;
- break;
- case reflection::Double:
- if (!table->VerifyField<double>(v, field_def->offset(), sizeof(double)))
- return false;
- break;
- case reflection::String:
- if (!table->VerifyField<uoffset_t>(v, field_def->offset(),
- sizeof(uoffset_t)) ||
- !v.VerifyString(flatbuffers::GetFieldS(*table, *field_def))) {
- return false;
- }
- break;
- case reflection::Vector:
- if (!VerifyVector(v, schema, *table, *field_def)) return false;
- break;
- case reflection::Obj: {
- auto child_obj = schema.objects()->Get(field_def->type()->index());
- if (child_obj->is_struct()) {
- if (!VerifyStruct(v, *table, field_def->offset(), *child_obj,
- field_def->required())) {
- return false;
- }
- } else {
- if (!VerifyObject(v, schema, *child_obj,
- flatbuffers::GetFieldT(*table, *field_def),
- field_def->required())) {
- return false;
- }
- }
- break;
- }
- case reflection::Union: {
- // get union type from the prev field
- voffset_t utype_offset = field_def->offset() - sizeof(voffset_t);
- auto utype = table->GetField<uint8_t>(utype_offset, 0);
- auto uval = reinterpret_cast<const uint8_t *>(
- flatbuffers::GetFieldT(*table, *field_def));
- if (!VerifyUnion(v, schema, utype, uval, *field_def)) { return false; }
- break;
- }
- default: FLATBUFFERS_ASSERT(false); break;
- }
- }
-
- if (!v.EndTable()) return false;
-
- return true;
-}
bool Verify(const reflection::Schema &schema, const reflection::Object &root,
- const uint8_t *buf, size_t length, uoffset_t max_depth /*= 64*/,
- uoffset_t max_tables /*= 1000000*/) {
+ const uint8_t *const buf, const size_t length,
+ const uoffset_t max_depth, const uoffset_t max_tables) {
Verifier v(buf, length, max_depth, max_tables);
- return VerifyObject(v, schema, root, flatbuffers::GetAnyRoot(buf), true);
+ return VerifyObject(v, schema, root, flatbuffers::GetAnyRoot(buf),
+ /*required=*/true);
+}
+
+bool VerifySizePrefixed(const reflection::Schema &schema,
+ const reflection::Object &root,
+ const uint8_t *const buf, const size_t length,
+ const uoffset_t max_depth, const uoffset_t max_tables) {
+ Verifier v(buf, length, max_depth, max_tables);
+ return VerifyObject(v, schema, root, flatbuffers::GetAnySizePrefixedRoot(buf),
+ /*required=*/true);
}
} // namespace flatbuffers
diff --git a/src/util.cpp b/src/util.cpp
index a1ed6c1..df324e8 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -17,13 +17,14 @@
// clang-format off
// Dont't remove `format off`, it prevent reordering of win-includes.
+#include <cstring>
#if defined(__MINGW32__) || defined(__MINGW64__) || defined(__CYGWIN__) || \
defined(__QNXNTO__)
# define _POSIX_C_SOURCE 200809L
# define _XOPEN_SOURCE 700L
#endif
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__MINGW32__) || defined(__MINGW64__) || defined(__CYGWIN__)
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
@@ -34,7 +35,9 @@
# include <crtdbg.h>
# endif
# include <windows.h> // Must be included before <direct.h>
-# include <direct.h>
+# ifndef __CYGWIN__
+# include <direct.h>
+# endif
# include <winbase.h>
# undef interface // This is also important because of reasons
#endif
@@ -46,19 +49,21 @@
#include <clocale>
#include <cstdlib>
-#include <functional>
#include <fstream>
+#include <functional>
#include "flatbuffers/base.h"
namespace flatbuffers {
-bool FileExistsRaw(const char *name) {
+namespace {
+
+static bool FileExistsRaw(const char *name) {
std::ifstream ifs(name);
return ifs.good();
}
-bool LoadFileRaw(const char *name, bool binary, std::string *buf) {
+static bool LoadFileRaw(const char *name, bool binary, std::string *buf) {
if (DirExists(name)) return false;
std::ifstream ifs(name, binary ? std::ifstream::binary : std::ifstream::in);
if (!ifs.is_open()) return false;
@@ -78,8 +83,124 @@
return !ifs.bad();
}
-static LoadFileFunction g_load_file_function = LoadFileRaw;
-static FileExistsFunction g_file_exists_function = FileExistsRaw;
+LoadFileFunction g_load_file_function = LoadFileRaw;
+FileExistsFunction g_file_exists_function = FileExistsRaw;
+
+static std::string ToCamelCase(const std::string &input, bool first) {
+ std::string s;
+ for (size_t i = 0; i < input.length(); i++) {
+ if (!i && first)
+ s += CharToUpper(input[i]);
+ else if (input[i] == '_' && i + 1 < input.length())
+ s += CharToUpper(input[++i]);
+ else
+ s += input[i];
+ }
+ return s;
+}
+
+static std::string ToSnakeCase(const std::string &input, bool screaming) {
+ std::string s;
+ for (size_t i = 0; i < input.length(); i++) {
+ if (i == 0) {
+ s += screaming ? CharToUpper(input[i]) : CharToLower(input[i]);
+ } else if (input[i] == '_') {
+ s += '_';
+ } else if (!islower(input[i])) {
+ // Prevent duplicate underscores for Upper_Snake_Case strings
+ // and UPPERCASE strings.
+ if (islower(input[i - 1])) { s += '_'; }
+ s += screaming ? CharToUpper(input[i]) : CharToLower(input[i]);
+ } else {
+ s += screaming ? CharToUpper(input[i]) : input[i];
+ }
+ }
+ return s;
+}
+
+std::string ToAll(const std::string &input,
+ std::function<char(const char)> transform) {
+ std::string s;
+ for (size_t i = 0; i < input.length(); i++) { s += transform(input[i]); }
+ return s;
+}
+
+std::string CamelToSnake(const std::string &input) {
+ std::string s;
+ for (size_t i = 0; i < input.length(); i++) {
+ if (i == 0) {
+ s += CharToLower(input[i]);
+ } else if (input[i] == '_') {
+ s += '_';
+ } else if (!islower(input[i])) {
+ // Prevent duplicate underscores for Upper_Snake_Case strings
+ // and UPPERCASE strings.
+ if (islower(input[i - 1])) { s += '_'; }
+ s += CharToLower(input[i]);
+ } else {
+ s += input[i];
+ }
+ }
+ return s;
+}
+
+std::string DasherToSnake(const std::string &input) {
+ std::string s;
+ for (size_t i = 0; i < input.length(); i++) {
+ if (input[i] == '-') {
+ s += "_";
+ } else {
+ s += input[i];
+ }
+ }
+ return s;
+}
+
+std::string ToDasher(const std::string &input) {
+ std::string s;
+ char p = 0;
+ for (size_t i = 0; i < input.length(); i++) {
+ char const &c = input[i];
+ if (c == '_') {
+ if (i > 0 && p != kPathSeparator &&
+ // The following is a special case to ignore digits after a _. This is
+ // because ThisExample3 would be converted to this_example_3 in the
+ // CamelToSnake conversion, and then dasher would do this-example-3,
+ // but it expects this-example3.
+ !(i + 1 < input.length() && isdigit(input[i + 1])))
+ s += "-";
+ } else {
+ s += c;
+ }
+ p = c;
+ }
+ return s;
+}
+
+
+// Converts foo_bar_123baz_456 to foo_bar123_baz456
+std::string SnakeToSnake2(const std::string &s) {
+ if (s.length() <= 1) return s;
+ std::string result;
+ result.reserve(s.size());
+ for (size_t i = 0; i < s.length() - 1; i++) {
+ if (s[i] == '_' && isdigit(s[i + 1])) {
+ continue; // Move the `_` until after the digits.
+ }
+
+ result.push_back(s[i]);
+
+ if (isdigit(s[i]) && isalpha(s[i + 1]) && islower(s[i + 1])) {
+ result.push_back('_');
+ }
+ }
+ result.push_back(s.back());
+
+ return result;
+}
+
+} // namespace
+
bool LoadFile(const char *name, bool binary, std::string *buf) {
FLATBUFFERS_ASSERT(g_load_file_function);
@@ -155,6 +276,15 @@
return i != std::string::npos ? filepath.substr(0, i) : "";
}
+std::string StripPrefix(const std::string &filepath,
+ const std::string &prefix_to_remove) {
+ if (!strncmp(filepath.c_str(), prefix_to_remove.c_str(),
+ prefix_to_remove.size())) {
+ return filepath.substr(prefix_to_remove.size());
+ }
+ return filepath;
+}
+
std::string ConCatPathFileName(const std::string &path,
const std::string &filename) {
std::string filepath = path;
@@ -202,7 +332,7 @@
#ifdef FLATBUFFERS_NO_ABSOLUTE_PATH_RESOLUTION
return filepath;
#else
- #ifdef _WIN32
+ #if defined(_WIN32) || defined(__MINGW32__) || defined(__MINGW64__) || defined(__CYGWIN__)
char abs_path[MAX_PATH];
return GetFullPathNameA(filepath.c_str(), MAX_PATH, abs_path, nullptr)
#else
@@ -296,124 +426,6 @@
return true;
}
-void SetupDefaultCRTReportMode() {
- // clang-format off
-
- #ifdef _MSC_VER
- // By default, send all reports to STDOUT to prevent CI hangs.
- // Enable assert report box [Abort|Retry|Ignore] if a debugger is present.
- const int dbg_mode = (_CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG) |
- (IsDebuggerPresent() ? _CRTDBG_MODE_WNDW : 0);
- (void)dbg_mode; // release mode fix
- // CrtDebug reports to _CRT_WARN channel.
- _CrtSetReportMode(_CRT_WARN, dbg_mode);
- _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT);
- // The assert from <assert.h> reports to _CRT_ERROR channel
- _CrtSetReportMode(_CRT_ERROR, dbg_mode);
- _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDOUT);
- // Internal CRT assert channel?
- _CrtSetReportMode(_CRT_ASSERT, dbg_mode);
- _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDOUT);
- #endif
-
- // clang-format on
-}
-
-namespace {
-
-static std::string ToCamelCase(const std::string &input, bool first) {
- std::string s;
- for (size_t i = 0; i < input.length(); i++) {
- if (!i && first)
- s += CharToUpper(input[i]);
- else if (input[i] == '_' && i + 1 < input.length())
- s += CharToUpper(input[++i]);
- else
- s += input[i];
- }
- return s;
-}
-
-static std::string ToSnakeCase(const std::string &input, bool screaming) {
- std::string s;
- for (size_t i = 0; i < input.length(); i++) {
- if (i == 0) {
- s += screaming ? CharToUpper(input[i]) : CharToLower(input[i]);
- } else if (input[i] == '_') {
- s += '_';
- } else if (!islower(input[i])) {
- // Prevent duplicate underscores for Upper_Snake_Case strings
- // and UPPERCASE strings.
- if (islower(input[i - 1])) { s += '_'; }
- s += screaming ? CharToUpper(input[i]) : CharToLower(input[i]);
- } else {
- s += screaming ? CharToUpper(input[i]) : input[i];
- }
- }
- return s;
-}
-
-static std::string ToAll(const std::string &input,
- std::function<char(const char)> transform) {
- std::string s;
- for (size_t i = 0; i < input.length(); i++) { s += transform(input[i]); }
- return s;
-}
-
-static std::string CamelToSnake(const std::string &input) {
- std::string s;
- for (size_t i = 0; i < input.length(); i++) {
- if (i == 0) {
- s += CharToLower(input[i]);
- } else if (input[i] == '_') {
- s += '_';
- } else if (!islower(input[i])) {
- // Prevent duplicate underscores for Upper_Snake_Case strings
- // and UPPERCASE strings.
- if (islower(input[i - 1])) { s += '_'; }
- s += CharToLower(input[i]);
- } else {
- s += input[i];
- }
- }
- return s;
-}
-
-static std::string DasherToSnake(const std::string &input) {
- std::string s;
- for (size_t i = 0; i < input.length(); i++) {
- if (input[i] == '-') {
- s += "_";
- } else {
- s += input[i];
- }
- }
- return s;
-}
-
-static std::string ToDasher(const std::string &input) {
- std::string s;
- char p = 0;
- for (size_t i = 0; i < input.length(); i++) {
- char const &c = input[i];
- if (c == '_') {
- if (i > 0 && p != kPathSeparator &&
- // The following is a special case to ignore digits after a _. This is
- // because ThisExample3 would be converted to this_example_3 in the
- // CamelToSnake conversion, and then dasher would do this-example-3,
- // but it expects this-example3.
- !(i + 1 < input.length() && isdigit(input[i + 1])))
- s += "-";
- } else {
- s += c;
- }
- p = c;
- }
- return s;
-}
-
-} // namespace
-
std::string ConvertCase(const std::string &input, Case output_case,
Case input_case) {
if (output_case == Case::kKeep) return input;
@@ -440,6 +452,7 @@
case Case::kAllUpper: return ToAll(input, CharToUpper);
case Case::kAllLower: return ToAll(input, CharToLower);
case Case::kDasher: return ToDasher(input);
+ case Case::kSnake2: return SnakeToSnake2(input);
default:
case Case::kUnknown: return input;
}
diff --git a/swift/BUILD.bazel b/swift/BUILD.bazel
new file mode 100644
index 0000000..7bbf298
--- /dev/null
+++ b/swift/BUILD.bazel
@@ -0,0 +1,8 @@
+load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
+
+swift_library(
+ name = "swift",
+ srcs = glob(["Sources/FlatBuffers/*.swift"]),
+ module_name = "FlatBuffers",
+ visibility = ["//visibility:public"],
+)
diff --git a/swift/FlatBuffers.podspec b/swift/FlatBuffers.podspec
index 0119529..c26d1a2 100644
--- a/swift/FlatBuffers.podspec
+++ b/swift/FlatBuffers.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'FlatBuffers'
- s.version = '2.0.0'
+ s.version = '2.0.8'
s.summary = 'FlatBuffers: Memory Efficient Serialization Library'
s.description = "FlatBuffers is a cross platform serialization library architected for
@@ -17,5 +17,5 @@
s.osx.deployment_target = '10.14'
s.swift_version = '5.0'
- s.source_files = 'Sources/**/*'
+ s.source_files = 'Sources/Flatbuffers/*.swift'
end
diff --git a/swift/Sources/FlatBuffers/ByteBuffer.swift b/swift/Sources/FlatBuffers/ByteBuffer.swift
index a07f66a..fead65e 100644
--- a/swift/Sources/FlatBuffers/ByteBuffer.swift
+++ b/swift/Sources/FlatBuffers/ByteBuffer.swift
@@ -14,7 +14,11 @@
* limitations under the License.
*/
+#if !os(WASI)
import Foundation
+#else
+import SwiftOverlayShims
+#endif
/// `ByteBuffer` is the interface that stores the data for a `Flatbuffers` object
/// it allows users to write and read data directly from memory thus the use of its
@@ -125,6 +129,7 @@
}
}
+ #if !os(WASI)
/// Constructor that creates a Flatbuffer from the Swift Data type object
/// - Parameter data: Swift data Object
public init(data: Data) {
@@ -135,6 +140,7 @@
self._storage.copy(from: bufferPointer.baseAddress!, count: data.count)
}
}
+ #endif
/// Constructor that creates a Flatbuffer instance with a size
/// - Parameter size: Length of the buffer
@@ -144,7 +150,7 @@
_storage.initialize(for: size)
}
- #if swift(>=5.0)
+ #if swift(>=5.0) && !os(WASI)
/// Constructor that creates a Flatbuffer object from a ContiguousBytes
/// - Parameters:
/// - contiguousBytes: Binary stripe to use as the buffer
@@ -199,6 +205,7 @@
/// Fills the buffer with padding by adding to the writersize
/// - Parameter padding: Amount of padding between two to be serialized objects
+ @inline(__always)
@usableFromInline
mutating func fill(padding: Int) {
assert(padding >= 0, "Fill should be larger than or equal to zero")
@@ -208,6 +215,7 @@
/// Adds an array of type Scalar to the buffer memory
/// - Parameter elements: An array of Scalars
+ @inline(__always)
@usableFromInline
mutating func push<T: Scalar>(elements: [T]) {
let size = elements.count &* MemoryLayout<T>.size
@@ -221,6 +229,7 @@
/// - Parameters:
/// - value: Object that will be written to the buffer
/// - size: size to subtract from the WriterIndex
+ @usableFromInline
@inline(__always)
mutating func push<T: NativeStruct>(struct value: T, size: Int) {
ensureSpace(size: size)
@@ -233,6 +242,7 @@
/// - Parameters:
/// - value: Object that will be written to the buffer
/// - len: Offset to subtract from the WriterIndex
+ @inline(__always)
@usableFromInline
mutating func push<T: Scalar>(value: T, len: Int) {
ensureSpace(size: len)
@@ -244,6 +254,7 @@
/// Adds a string to the buffer using swift.utf8 object
/// - Parameter str: String that will be added to the buffer
/// - Parameter len: length of the string
+ @inline(__always)
@usableFromInline
mutating func push(string str: String, len: Int) {
ensureSpace(size: len)
@@ -263,6 +274,7 @@
/// - Parameters:
/// - bytes: Pointer to the view
/// - len: Size of string
+ @usableFromInline
@inline(__always)
mutating func push(
bytes: UnsafeBufferPointer<String.UTF8View.Element>,
@@ -284,6 +296,7 @@
/// - value: Value that needs to be written to the buffer
/// - index: index to write to
/// - direct: Should take into consideration the capacity of the buffer
+ @inline(__always)
func write<T>(value: T, index: Int, direct: Bool = false) {
var index = index
if !direct {
@@ -297,6 +310,7 @@
/// Makes sure that buffer has enouch space for each of the objects that will be written into it
/// - Parameter size: size of object
@discardableResult
+ @usableFromInline
@inline(__always)
mutating func ensureSpace(size: Int) -> Int {
if size &+ _writerSize > _storage.capacity {
@@ -308,6 +322,7 @@
/// pops the written VTable if it's already written into the buffer
/// - Parameter size: size of the `VTable`
+ @usableFromInline
@inline(__always)
mutating func pop(_ size: Int) {
assert(
@@ -318,11 +333,13 @@
}
/// Clears the current size of the buffer
+ @inline(__always)
mutating public func clearSize() {
_writerSize = 0
}
/// Clears the current instance of the buffer, replacing it with new memory
+ @inline(__always)
mutating public func clear() {
_writerSize = 0
alignment = 1
@@ -333,6 +350,7 @@
/// - Parameters:
/// - def: Type of the object
/// - position: the index of the object in the buffer
+ @inline(__always)
public func read<T>(def: T.Type, position: Int) -> T {
_storage.memory.advanced(by: position).load(as: T.self)
}
@@ -355,11 +373,13 @@
return Array(array)
}
+ #if !os(WASI)
/// Reads a string from the buffer and encodes it to a swift string
/// - Parameters:
/// - index: index of the string in the buffer
/// - count: length of the string
/// - type: Encoding of the string
+ @inline(__always)
public func readString(
at index: Int,
count: Int,
@@ -373,9 +393,30 @@
let bufprt = UnsafeBufferPointer(start: start, count: count)
return String(bytes: Array(bufprt), encoding: type)
}
+ #else
+ /// Reads a string from the buffer and encodes it to a swift string
+ /// - Parameters:
+ /// - index: index of the string in the buffer
+ /// - count: length of the string
+ /// - type: Encoding of the string
+ @inline(__always)
+ public func readString(
+ at index: Int,
+ count: Int) -> String?
+ {
+ assert(
+ index + count <= _storage.capacity,
+ "Reading out of bounds is illegal")
+ let start = _storage.memory.advanced(by: index)
+ .assumingMemoryBound(to: UInt8.self)
+ let bufprt = UnsafeBufferPointer(start: start, count: count)
+ return String(cString: bufprt.baseAddress!)
+ }
+ #endif
/// Creates a new Flatbuffer object that's duplicated from the current one
/// - Parameter removeBytes: the amount of bytes to remove from the current Size
+ @inline(__always)
public func duplicate(removing removeBytes: Int = 0) -> ByteBuffer {
assert(removeBytes > 0, "Can NOT remove negative bytes")
assert(
@@ -400,10 +441,14 @@
/// SkipPrefix Skips the first 4 bytes in case one of the following
/// functions are called `getPrefixedSizeCheckedRoot` & `getPrefixedSizeRoot`
/// which allows us to skip the first 4 bytes instead of recreating the buffer
+ @discardableResult
@usableFromInline
- mutating func skipPrefix() {
+ @inline(__always)
+ mutating func skipPrefix() -> Int32 {
_writerSize = _writerSize &- MemoryLayout<Int32>.size
+ return read(def: Int32.self, position: 0)
}
+
}
extension ByteBuffer: CustomDebugStringConvertible {
diff --git a/swift/Sources/FlatBuffers/Constants.swift b/swift/Sources/FlatBuffers/Constants.swift
index 8e643fd..a2a1082 100644
--- a/swift/Sources/FlatBuffers/Constants.swift
+++ b/swift/Sources/FlatBuffers/Constants.swift
@@ -14,15 +14,21 @@
* limitations under the License.
*/
-#if os(Linux)
-import CoreFoundation
+#if !os(WASI)
+ #if os(Linux)
+ import CoreFoundation
+ #else
+ import Foundation
+ #endif
#else
-import Foundation
+import SwiftOverlayShims
#endif
/// A boolean to see if the system is littleEndian
-let isLitteEndian = CFByteOrderGetCurrent() ==
- Int(CFByteOrderLittleEndian.rawValue)
+let isLitteEndian: Bool = {
+ let number: UInt32 = 0x12345678
+ return number == number.littleEndian
+}()
/// Constant for the file id length
let FileIdLength = 4
/// Type aliases
@@ -113,4 +119,4 @@
public typealias NumericValue = UInt64
}
-public func FlatBuffersVersion_2_0_0() {}
+public func FlatBuffersVersion_2_0_8() {}
diff --git a/swift/Sources/FlatBuffers/Enum.swift b/swift/Sources/FlatBuffers/Enum.swift
index efb698b..f0e99f3 100644
--- a/swift/Sources/FlatBuffers/Enum.swift
+++ b/swift/Sources/FlatBuffers/Enum.swift
@@ -14,7 +14,11 @@
* limitations under the License.
*/
+#if !os(WASI)
import Foundation
+#else
+import SwiftOverlayShims
+#endif
/// Enum is a protocol that all flatbuffers enums should conform to
/// Since it allows us to get the actual `ByteSize` and `Value` from
diff --git a/swift/Sources/FlatBuffers/FlatBufferBuilder.swift b/swift/Sources/FlatBuffers/FlatBufferBuilder.swift
index 5ccc7e4..bfe3615 100644
--- a/swift/Sources/FlatBuffers/FlatBufferBuilder.swift
+++ b/swift/Sources/FlatBuffers/FlatBufferBuilder.swift
@@ -14,7 +14,11 @@
* limitations under the License.
*/
+#if !os(WASI)
import Foundation
+#else
+import SwiftOverlayShims
+#endif
/// ``FlatBufferBuilder`` builds a `FlatBuffer` through manipulating its internal state.
///
@@ -55,6 +59,7 @@
/// Gives a read access to the buffer's size
public var size: UOffset { _bb.size }
+ #if !os(WASI)
/// Data representation of the buffer
///
/// Should only be used after ``finish(offset:addPrefix:)`` is called
@@ -64,6 +69,7 @@
bytes: _bb.memory.advanced(by: _bb.writerIndex),
count: _bb.capacity &- _bb.writerIndex)
}
+ #endif
/// Returns the underlying bytes in the ``ByteBuffer``
///
@@ -127,8 +133,8 @@
mutating public func clear() {
_minAlignment = 0
isNested = false
- stringOffsetMap = [:]
- _vtables = []
+ stringOffsetMap.removeAll(keepingCapacity: true)
+ _vtables.removeAll(keepingCapacity: true)
_vtableStorage.clear()
_bb.clear()
}
@@ -142,6 +148,7 @@
///
/// *NOTE: Never call this function, this is only supposed to be called
/// by the generated code*
+ @inline(__always)
mutating public func require(table: Offset, fields: [Int32]) {
for field in fields {
let start = _bb.capacity &- Int(table.o)
@@ -228,6 +235,7 @@
/// ```
/// - Parameter numOfFields: Number of elements to be written to the buffer
/// - Returns: Offset of the newly started table
+ @inline(__always)
mutating public func startTable(with numOfFields: Int) -> UOffset {
notNested()
isNested = true
@@ -307,6 +315,7 @@
// MARK: - Builds Buffer
/// Asserts to see if the object is not nested
+ @inline(__always)
@usableFromInline
mutating internal func notNested() {
assert(!isNested, "Object serialization must not be nested")
@@ -315,6 +324,7 @@
/// Changes the minimuim alignment of the buffer
/// - Parameter size: size of the current alignment
@inline(__always)
+ @usableFromInline
mutating internal func minAlignment(size: Int) {
if size > _minAlignment {
_minAlignment = size
@@ -326,6 +336,7 @@
/// - bufSize: Current size of the buffer + the offset of the object to be written
/// - elementSize: Element size
@inline(__always)
+ @usableFromInline
mutating internal func padding(
bufSize: UInt32,
elementSize: UInt32) -> UInt32
@@ -337,6 +348,7 @@
/// - Parameters:
/// - len:Length of the object
/// - alignment: Alignment type
+ @inline(__always)
@usableFromInline
mutating internal func preAlign(len: Int, alignment: Int) {
minAlignment(size: alignment)
@@ -349,6 +361,7 @@
/// - Parameters:
/// - len: Length of the object
/// - type: Type of the object to be written
+ @inline(__always)
@usableFromInline
mutating internal func preAlign<T: Scalar>(len: Int, type: T.Type) {
preAlign(len: len, alignment: MemoryLayout<T>.size)
@@ -356,6 +369,7 @@
/// Refers to an object that's written in the buffer
/// - Parameter off: the objects index value
+ @inline(__always)
@usableFromInline
mutating internal func refer(to off: UOffset) -> UOffset {
let size = MemoryLayout<UOffset>.size
@@ -367,6 +381,7 @@
/// - Parameters:
/// - offset: The offset of the element witten
/// - position: The position of the element
+ @inline(__always)
@usableFromInline
mutating internal func track(offset: UOffset, at position: VOffset) {
_vtableStorage.add(loc: FieldLoc(offset: offset, position: position))
@@ -386,6 +401,7 @@
/// - Parameters:
/// - len: Length of vector to be created
/// - elementSize: Size of object type to be written
+ @inline(__always)
mutating public func startVector(_ len: Int, elementSize: Int) {
notNested()
isNested = true
@@ -407,6 +423,7 @@
///
/// - Parameter len: Length of the buffer
/// - Returns: Returns the current ``Offset`` in the ``ByteBuffer``
+ @inline(__always)
mutating public func endVector(len: Int) -> Offset {
assert(isNested, "Calling endVector without calling startVector")
isNested = false
@@ -427,6 +444,7 @@
///
/// - Parameter elements: elements to be written into the buffer
/// - returns: ``Offset`` of the vector
+ @inline(__always)
mutating public func createVector<T: Scalar>(_ elements: [T]) -> Offset {
createVector(elements, size: elements.count)
}
@@ -444,6 +462,7 @@
/// - Parameter elements: Elements to be written into the buffer
/// - Parameter size: Count of elements
/// - returns: ``Offset`` of the vector
+ @inline(__always)
mutating public func createVector<T: Scalar>(
_ elements: [T],
size: Int) -> Offset
@@ -468,6 +487,7 @@
///
/// - Parameter elements: elements to be written into the buffer
/// - returns: ``Offset`` of the vector
+ @inline(__always)
mutating public func createVector<T: Enum>(_ elements: [T]) -> Offset {
createVector(elements, size: elements.count)
}
@@ -485,6 +505,7 @@
/// - Parameter elements: Elements to be written into the buffer
/// - Parameter size: Count of elements
/// - returns: ``Offset`` of the vector
+ @inline(__always)
mutating public func createVector<T: Enum>(
_ elements: [T],
size: Int) -> Offset
@@ -511,6 +532,7 @@
/// ```
/// - Parameter offsets: Array of offsets of type ``Offset``
/// - returns: ``Offset`` of the vector
+ @inline(__always)
mutating public func createVector(ofOffsets offsets: [Offset]) -> Offset {
createVector(ofOffsets: offsets, len: offsets.count)
}
@@ -529,6 +551,7 @@
/// - Parameter offsets: Array of offsets of type ``Offset``
/// - Parameter size: Count of elements
/// - returns: ``Offset`` of the vector
+ @inline(__always)
mutating public func createVector(
ofOffsets offsets: [Offset],
len: Int) -> Offset
@@ -555,6 +578,7 @@
///
/// - Parameter str: Array of string
/// - returns: ``Offset`` of the vector
+ @inline(__always)
mutating public func createVector(ofStrings str: [String]) -> Offset {
var offsets: [Offset] = []
for s in str {
@@ -576,6 +600,7 @@
///
/// - Parameter structs: A vector of ``NativeStruct``
/// - Returns: ``Offset`` of the vector
+ @inline(__always)
mutating public func createVector<T: NativeStruct>(ofStructs structs: [T])
-> Offset
{
@@ -605,6 +630,7 @@
/// - s: ``NativeStruct`` to be inserted into the ``ByteBuffer``
/// - position: The predefined position of the object
/// - Returns: ``Offset`` of written struct
+ @inline(__always)
@discardableResult
mutating public func create<T: NativeStruct>(
struct s: T, position: VOffset) -> Offset
@@ -630,6 +656,7 @@
/// - Parameters:
/// - s: ``NativeStruct`` to be inserted into the ``ByteBuffer``
/// - Returns: ``Offset`` of written struct
+ @inline(__always)
@discardableResult
mutating public func create<T: NativeStruct>(
struct s: T) -> Offset
@@ -654,6 +681,7 @@
///
/// - Parameter str: String to be serialized
/// - returns: ``Offset`` of inserted string
+ @inline(__always)
mutating public func create(string str: String?) -> Offset {
guard let str = str else { return Offset() }
let len = str.utf8.count
@@ -684,6 +712,7 @@
///
/// - Parameter str: String to be serialized
/// - returns: ``Offset`` of inserted string
+ @inline(__always)
mutating public func createShared(string str: String?) -> Offset {
guard let str = str else { return Offset() }
if let offset = stringOffsetMap[str] {
@@ -704,6 +733,7 @@
/// - Parameters:
/// - offset: ``Offset`` of another object to be written
/// - position: The predefined position of the object
+ @inline(__always)
mutating public func add(offset: Offset, at position: VOffset) {
if offset.isEmpty { return }
add(element: refer(to: offset.o), def: 0, at: position)
@@ -712,6 +742,7 @@
/// Pushes a value of type ``Offset`` into the ``ByteBuffer``
/// - Parameter o: ``Offset``
/// - returns: Current position of the ``Offset``
+ @inline(__always)
@discardableResult
mutating public func push(element o: Offset) -> UOffset {
push(element: refer(to: o.o))
@@ -740,6 +771,7 @@
/// - element: Element to insert
/// - def: Default value for that element
/// - position: The predefined position of the element
+ @inline(__always)
mutating public func add<T: Scalar>(
element: T,
def: T,
@@ -758,6 +790,7 @@
/// - Parameters:
/// - element: Optional element of type scalar
/// - position: The predefined position of the element
+ @inline(__always)
mutating public func add<T: Scalar>(element: T?, at position: VOffset) {
guard let element = element else { return }
track(offset: push(element: element), at: position)
@@ -769,6 +802,7 @@
///
/// - Parameter element: Element to insert
/// - returns: Postion of the Element
+ @inline(__always)
@discardableResult
mutating public func push<T: Scalar>(element: T) -> UOffset {
let size = MemoryLayout<T>.size
@@ -814,12 +848,14 @@
/// Creates the memory to store the buffer in
@usableFromInline
+ @inline(__always)
init() {
memory = UnsafeMutableRawBufferPointer.allocate(
byteCount: 0,
alignment: 0)
}
+ @inline(__always)
deinit {
memory.deallocate()
}
@@ -836,6 +872,7 @@
/// Adds a FieldLoc into the buffer, which would track how many have been written,
/// and max offset
/// - Parameter loc: Location of encoded element
+ @inline(__always)
func add(loc: FieldLoc) {
memory.baseAddress?.advanced(by: writtenIndex).storeBytes(
of: loc,
@@ -846,6 +883,7 @@
}
/// Clears the data stored related to the encoded buffer
+ @inline(__always)
func clear() {
maxOffset = 0
numOfFields = 0
diff --git a/swift/Sources/FlatBuffers/FlatBufferObject.swift b/swift/Sources/FlatBuffers/FlatBufferObject.swift
index df8ad8d..520cb1d 100644
--- a/swift/Sources/FlatBuffers/FlatBufferObject.swift
+++ b/swift/Sources/FlatBuffers/FlatBufferObject.swift
@@ -14,7 +14,11 @@
* limitations under the License.
*/
+#if !os(WASI)
import Foundation
+#else
+import SwiftOverlayShims
+#endif
/// NativeStruct is a protocol that indicates if the struct is a native `swift` struct
/// since now we will be serializing native structs into the buffer.
diff --git a/swift/Sources/FlatBuffers/FlatBuffersUtils.swift b/swift/Sources/FlatBuffers/FlatBuffersUtils.swift
index dc5f785..9941bd2 100644
--- a/swift/Sources/FlatBuffers/FlatBuffersUtils.swift
+++ b/swift/Sources/FlatBuffers/FlatBuffersUtils.swift
@@ -14,7 +14,11 @@
* limitations under the License.
*/
+#if !os(WASI)
import Foundation
+#else
+import SwiftOverlayShims
+#endif
/// FlatBuffersUtils hosts some utility functions that might be useful
public enum FlatBuffersUtils {
diff --git a/swift/Sources/FlatBuffers/FlatbuffersErrors.swift b/swift/Sources/FlatBuffers/FlatbuffersErrors.swift
index 74c06b9..77e2f2b 100644
--- a/swift/Sources/FlatBuffers/FlatbuffersErrors.swift
+++ b/swift/Sources/FlatBuffers/FlatbuffersErrors.swift
@@ -14,11 +14,19 @@
* limitations under the License.
*/
+#if !os(WASI)
import Foundation
+#else
+import SwiftOverlayShims
+#endif
/// Collection of thrown from the Flatbuffer verifier
public enum FlatbuffersErrors: Error, Equatable {
+ /// Thrown when verifying a file id that doesnt match buffer id
+ case bufferIdDidntMatchPassedId
+ /// Prefixed size doesnt match the current (readable) buffer size
+ case prefixedSizeNotEqualToBufferSize
/// Thrown when buffer is bigger than the allowed 2GiB
case exceedsMaxSizeAllowed
/// Thrown when there is an missaligned pointer at position
@@ -53,10 +61,17 @@
fieldName: String)
case apparentSizeTooLarge
- public static func == (
- lhs: FlatbuffersErrors,
- rhs: FlatbuffersErrors) -> Bool
- {
- lhs.localizedDescription == rhs.localizedDescription
- }
}
+
+#if !os(WASI)
+
+extension FlatbuffersErrors {
+ public static func == (
+ lhs: FlatbuffersErrors,
+ rhs: FlatbuffersErrors) -> Bool
+ {
+ lhs.localizedDescription == rhs.localizedDescription
+ }
+}
+
+#endif
diff --git a/swift/Sources/FlatBuffers/Int+extension.swift b/swift/Sources/FlatBuffers/Int+extension.swift
index 76977ba..f1c261e 100644
--- a/swift/Sources/FlatBuffers/Int+extension.swift
+++ b/swift/Sources/FlatBuffers/Int+extension.swift
@@ -14,7 +14,11 @@
* limitations under the License.
*/
+#if !os(WASI)
import Foundation
+#else
+import SwiftOverlayShims
+#endif
extension Int {
diff --git a/swift/Sources/FlatBuffers/Message.swift b/swift/Sources/FlatBuffers/Message.swift
index eb0bad9..e9739de 100644
--- a/swift/Sources/FlatBuffers/Message.swift
+++ b/swift/Sources/FlatBuffers/Message.swift
@@ -14,7 +14,11 @@
* limitations under the License.
*/
+#if !os(WASI)
import Foundation
+#else
+import SwiftOverlayShims
+#endif
/// FlatBufferGRPCMessage protocol that should allow us to invoke
/// initializers directly from the GRPC generated code
diff --git a/swift/Sources/FlatBuffers/Mutable.swift b/swift/Sources/FlatBuffers/Mutable.swift
index f77945c..9763c3f 100644
--- a/swift/Sources/FlatBuffers/Mutable.swift
+++ b/swift/Sources/FlatBuffers/Mutable.swift
@@ -14,7 +14,11 @@
* limitations under the License.
*/
+#if !os(WASI)
import Foundation
+#else
+import SwiftOverlayShims
+#endif
/// Mutable is a protocol that allows us to mutate Scalar values within a ``ByteBuffer``
public protocol Mutable {
diff --git a/swift/Sources/FlatBuffers/NativeObject.swift b/swift/Sources/FlatBuffers/NativeObject.swift
index bc896e6..5829338 100644
--- a/swift/Sources/FlatBuffers/NativeObject.swift
+++ b/swift/Sources/FlatBuffers/NativeObject.swift
@@ -14,7 +14,11 @@
* limitations under the License.
*/
+#if !os(WASI)
import Foundation
+#else
+import SwiftOverlayShims
+#endif
/// NativeObject is a protocol that all of the `Object-API` generated code should be
/// conforming to since it allows developers the ease of use to pack and unpack their
diff --git a/swift/Sources/FlatBuffers/Offset.swift b/swift/Sources/FlatBuffers/Offset.swift
index bd3f8a8..5adb572 100644
--- a/swift/Sources/FlatBuffers/Offset.swift
+++ b/swift/Sources/FlatBuffers/Offset.swift
@@ -14,7 +14,11 @@
* limitations under the License.
*/
+#if !os(WASI)
import Foundation
+#else
+import SwiftOverlayShims
+#endif
/// Offset object for all the Objects that are written into the buffer
public struct Offset {
diff --git a/swift/Sources/FlatBuffers/Root.swift b/swift/Sources/FlatBuffers/Root.swift
index 4d883b7..0c593dc 100644
--- a/swift/Sources/FlatBuffers/Root.swift
+++ b/swift/Sources/FlatBuffers/Root.swift
@@ -14,7 +14,11 @@
* limitations under the License.
*/
+#if !os(WASI)
import Foundation
+#else
+import SwiftOverlayShims
+#endif
/// Takes in a prefixed sized buffer, where the prefixed size would be skipped.
/// And would verify that the buffer passed is a valid `Flatbuffers` Object.
@@ -28,10 +32,39 @@
/// the ``ByteBuffer`` and verifies the buffer by calling ``getCheckedRoot(byteBuffer:options:)``
public func getPrefixedSizeCheckedRoot<T: FlatBufferObject & Verifiable>(
byteBuffer: inout ByteBuffer,
+ fileId: String? = nil,
options: VerifierOptions = .init()) throws -> T
{
byteBuffer.skipPrefix()
- return try getCheckedRoot(byteBuffer: &byteBuffer, options: options)
+ return try getCheckedRoot(
+ byteBuffer: &byteBuffer,
+ fileId: fileId,
+ options: options)
+}
+
+/// Takes in a prefixed sized buffer, where we check if the sized buffer is equal to prefix size.
+/// And would verify that the buffer passed is a valid `Flatbuffers` Object.
+/// - Parameters:
+/// - byteBuffer: Buffer that needs to be checked and read
+/// - options: Verifier options
+/// - Throws: FlatbuffersErrors
+/// - Returns: Returns a valid, checked Flatbuffers object
+///
+/// ``getPrefixedSizeCheckedRoot(byteBuffer:options:)`` would skip the first Bytes in
+/// the ``ByteBuffer`` and verifies the buffer by calling ``getCheckedRoot(byteBuffer:options:)``
+public func getCheckedPrefixedSizeRoot<T: FlatBufferObject & Verifiable>(
+ byteBuffer: inout ByteBuffer,
+ fileId: String? = nil,
+ options: VerifierOptions = .init()) throws -> T
+{
+ let prefix = byteBuffer.skipPrefix()
+ if prefix != byteBuffer.size {
+ throw FlatbuffersErrors.prefixedSizeNotEqualToBufferSize
+ }
+ return try getCheckedRoot(
+ byteBuffer: &byteBuffer,
+ fileId: fileId,
+ options: options)
}
/// Takes in a prefixed sized buffer, where the prefixed size would be skipped.
@@ -61,9 +94,13 @@
/// and within the ``ByteBuffer`` range.
public func getCheckedRoot<T: FlatBufferObject & Verifiable>(
byteBuffer: inout ByteBuffer,
+ fileId: String? = nil,
options: VerifierOptions = .init()) throws -> T
{
var verifier = try Verifier(buffer: &byteBuffer, options: options)
+ if let fileId = fileId {
+ try verifier.verify(id: fileId)
+ }
try ForwardOffset<T>.verify(&verifier, at: 0, of: T.self)
return T.init(
byteBuffer,
diff --git a/swift/Sources/FlatBuffers/String+extension.swift b/swift/Sources/FlatBuffers/String+extension.swift
index 2f3168d..cd92f7f 100644
--- a/swift/Sources/FlatBuffers/String+extension.swift
+++ b/swift/Sources/FlatBuffers/String+extension.swift
@@ -14,7 +14,11 @@
* limitations under the License.
*/
+#if !os(WASI)
import Foundation
+#else
+import SwiftOverlayShims
+#endif
extension String: Verifiable {
diff --git a/swift/Sources/FlatBuffers/Struct.swift b/swift/Sources/FlatBuffers/Struct.swift
index ac701d4..9996f44 100644
--- a/swift/Sources/FlatBuffers/Struct.swift
+++ b/swift/Sources/FlatBuffers/Struct.swift
@@ -14,7 +14,11 @@
* limitations under the License.
*/
+#if !os(WASI)
import Foundation
+#else
+import SwiftOverlayShims
+#endif
/// Struct is a representation of a mutable `Flatbuffers` struct
/// since native structs are value types and cant be mutated
diff --git a/swift/Sources/FlatBuffers/Table.swift b/swift/Sources/FlatBuffers/Table.swift
index ff501fc..5c78224 100644
--- a/swift/Sources/FlatBuffers/Table.swift
+++ b/swift/Sources/FlatBuffers/Table.swift
@@ -14,7 +14,11 @@
* limitations under the License.
*/
+#if !os(WASI)
import Foundation
+#else
+import SwiftOverlayShims
+#endif
/// `Table` is a Flatbuffers object that can read,
/// mutate scalar fields within a valid flatbuffers buffer
diff --git a/swift/Sources/FlatBuffers/TableVerifier.swift b/swift/Sources/FlatBuffers/TableVerifier.swift
index 42a37f2..0338f0d 100644
--- a/swift/Sources/FlatBuffers/TableVerifier.swift
+++ b/swift/Sources/FlatBuffers/TableVerifier.swift
@@ -14,7 +14,11 @@
* limitations under the License.
*/
+#if !os(WASI)
import Foundation
+#else
+import SwiftOverlayShims
+#endif
/// `TableVerifier` verifies a table object is within a provided memory.
/// It checks if all the objects for a specific generated table, are within
diff --git a/swift/Sources/FlatBuffers/VeriferOptions.swift b/swift/Sources/FlatBuffers/VeriferOptions.swift
index 454dd51..bd88ba6 100644
--- a/swift/Sources/FlatBuffers/VeriferOptions.swift
+++ b/swift/Sources/FlatBuffers/VeriferOptions.swift
@@ -14,7 +14,11 @@
* limitations under the License.
*/
+#if !os(WASI)
import Foundation
+#else
+import SwiftOverlayShims
+#endif
/// `VerifierOptions` is a set of options to verify a flatbuffer
public struct VerifierOptions {
diff --git a/swift/Sources/FlatBuffers/Verifiable.swift b/swift/Sources/FlatBuffers/Verifiable.swift
index e601cfc..7ecb454 100644
--- a/swift/Sources/FlatBuffers/Verifiable.swift
+++ b/swift/Sources/FlatBuffers/Verifiable.swift
@@ -14,7 +14,11 @@
* limitations under the License.
*/
+#if !os(WASI)
import Foundation
+#else
+import SwiftOverlayShims
+#endif
/// Verifiable is a protocol all swift flatbuffers object should conform to,
/// since swift is similar to `cpp` and `rust` where the data is read directly
diff --git a/swift/Sources/FlatBuffers/Verifier.swift b/swift/Sources/FlatBuffers/Verifier.swift
index 6f65ce7..9ac3974 100644
--- a/swift/Sources/FlatBuffers/Verifier.swift
+++ b/swift/Sources/FlatBuffers/Verifier.swift
@@ -14,7 +14,11 @@
* limitations under the License.
*/
+#if !os(WASI)
import Foundation
+#else
+import SwiftOverlayShims
+#endif
/// Verifier that check if the buffer passed into it is a valid,
/// safe, aligned Flatbuffers object since swift read from `unsafeMemory`
@@ -200,4 +204,14 @@
internal mutating func finish() {
_depth -= 1
}
+
+ mutating func verify(id: String) throws {
+ let size = MemoryLayout<Int32>.size
+ let str = _buffer.readString(at: size, count: size)
+ if id == str {
+ return
+ }
+ throw FlatbuffersErrors.bufferIdDidntMatchPassedId
+ }
+
}
diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel
index 11af9b4..3330bfc 100644
--- a/tests/BUILD.bazel
+++ b/tests/BUILD.bazel
@@ -1,5 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_test")
-load("//:build_defs.bzl", "flatbuffer_cc_library", "flatbuffer_ts_library")
+load("//:build_defs.bzl", "flatbuffer_cc_library")
package(default_visibility = ["//visibility:private"])
@@ -8,20 +8,42 @@
name = "flatbuffers_test",
testonly = 1,
srcs = [
+ "evolution_test.cpp",
+ "evolution_test.h",
"evolution_test/evolution_v1_generated.h",
"evolution_test/evolution_v2_generated.h",
+ "flexbuffers_test.cpp",
+ "flexbuffers_test.h",
+ "fuzz_test.cpp",
+ "fuzz_test.h",
+ "is_quiet_nan.h",
+ "json_test.cpp",
+ "json_test.h",
+ "monster_test.cpp",
+ "monster_test.h",
"monster_test_bfbs_generated.h",
"namespace_test/namespace_test1_generated.h",
"namespace_test/namespace_test2_generated.h",
+ "native_inline_table_test_generated.h",
"native_type_test_impl.cpp",
"native_type_test_impl.h",
"optional_scalars_generated.h",
+ "optional_scalars_test.cpp",
+ "optional_scalars_test.h",
+ "parser_test.cpp",
+ "parser_test.h",
+ "proto_test.cpp",
+ "proto_test.h",
+ "reflection_test.cpp",
+ "reflection_test.h",
"test.cpp",
"test_assert.cpp",
"test_assert.h",
"test_builder.cpp",
"test_builder.h",
"union_vector/union_vector_generated.h",
+ "util_test.cpp",
+ "util_test.h",
],
copts = [
"-DFLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE",
@@ -49,6 +71,8 @@
":name_clash_test/valid_test2.fbs",
":native_type_test.fbs",
":optional_scalars.fbs",
+ ":optional_scalars.json",
+ ":optional_scalars_defaults.json",
":prototest/imported.proto",
":prototest/test.golden",
":prototest/test.proto",
@@ -190,12 +214,3 @@
"--cpp-ptr-type flatbuffers::unique_ptr",
],
)
-
-flatbuffer_ts_library(
- name = "typescript_ts_fbs",
- srcs = ["typescript_keywords.fbs"],
- deps = [
- "//tests/test_dir:include_ts_fbs",
- "//tests/test_dir:typescript_transitive_ts_fbs",
- ],
-)
diff --git a/tests/DartTest.sh b/tests/DartTest.sh
index 36d1b14..e2ac6c7 100755
--- a/tests/DartTest.sh
+++ b/tests/DartTest.sh
@@ -25,6 +25,9 @@
cd ../dart
+../flatc --dart --gen-object-api -o ./test ./test/list_of_enums.fbs
+../flatc --dart --gen-object-api -o ./test ./test/bool_structs.fbs
+
# update packages
dart pub get
# Execute the sample.
diff --git a/tests/DictionaryLookup/LongFloatEntry.java b/tests/DictionaryLookup/LongFloatEntry.java
new file mode 100644
index 0000000..0419f79
--- /dev/null
+++ b/tests/DictionaryLookup/LongFloatEntry.java
@@ -0,0 +1,75 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+package DictionaryLookup;
+
+import java.nio.*;
+import java.lang.*;
+import java.util.*;
+import com.google.flatbuffers.*;
+
+@SuppressWarnings("unused")
+public final class LongFloatEntry extends Table {
+ public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
+ public static LongFloatEntry getRootAsLongFloatEntry(ByteBuffer _bb) { return getRootAsLongFloatEntry(_bb, new LongFloatEntry()); }
+ public static LongFloatEntry getRootAsLongFloatEntry(ByteBuffer _bb, LongFloatEntry obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
+ public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
+ public LongFloatEntry __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
+
+ public long key() { int o = __offset(4); return o != 0 ? bb.getLong(o + bb_pos) : 0L; }
+ public float value() { int o = __offset(6); return o != 0 ? bb.getFloat(o + bb_pos) : 0.0f; }
+
+ public static int createLongFloatEntry(FlatBufferBuilder builder,
+ long key,
+ float value) {
+ builder.startTable(2);
+ LongFloatEntry.addKey(builder, key);
+ LongFloatEntry.addValue(builder, value);
+ return LongFloatEntry.endLongFloatEntry(builder);
+ }
+
+ public static void startLongFloatEntry(FlatBufferBuilder builder) { builder.startTable(2); }
+ public static void addKey(FlatBufferBuilder builder, long key) { builder.addLong(key); builder.slot(0); }
+ public static void addValue(FlatBufferBuilder builder, float value) { builder.addFloat(1, value, 0.0f); }
+ public static int endLongFloatEntry(FlatBufferBuilder builder) {
+ int o = builder.endTable();
+ return o;
+ }
+
+ @Override
+ protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) {
+ long val_1 = _bb.getLong(__offset(4, o1, _bb));
+ long val_2 = _bb.getLong(__offset(4, o2, _bb));
+ return val_1 > val_2 ? 1 : val_1 < val_2 ? -1 : 0;
+ }
+
+ public static LongFloatEntry __lookup_by_key(LongFloatEntry obj, int vectorLocation, long key, ByteBuffer bb) {
+ int span = bb.getInt(vectorLocation - 4);
+ int start = 0;
+ while (span != 0) {
+ int middle = span / 2;
+ int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb);
+ long val = bb.getLong(__offset(4, bb.capacity() - tableOffset, bb));
+ int comp = val > key ? 1 : val < key ? -1 : 0;
+ if (comp > 0) {
+ span = middle;
+ } else if (comp < 0) {
+ middle++;
+ start += middle;
+ span -= middle;
+ } else {
+ return (obj == null ? new LongFloatEntry() : obj).__assign(tableOffset, bb);
+ }
+ }
+ return null;
+ }
+
+ 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 LongFloatEntry get(int j) { return get(new LongFloatEntry(), j); }
+ public LongFloatEntry get(LongFloatEntry obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
+ public LongFloatEntry getByKey(long key) { return __lookup_by_key(null, __vector(), key, bb); }
+ public LongFloatEntry getByKey(LongFloatEntry obj, long key) { return __lookup_by_key(obj, __vector(), key, bb); }
+ }
+}
+
diff --git a/tests/DictionaryLookup/LongFloatEntry.kt b/tests/DictionaryLookup/LongFloatEntry.kt
new file mode 100644
index 0000000..6b1e500
--- /dev/null
+++ b/tests/DictionaryLookup/LongFloatEntry.kt
@@ -0,0 +1,80 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+package DictionaryLookup
+
+import java.nio.*
+import kotlin.math.sign
+import com.google.flatbuffers.*
+
+@Suppress("unused")
+class LongFloatEntry : Table() {
+
+ fun __init(_i: Int, _bb: ByteBuffer) {
+ __reset(_i, _bb)
+ }
+ fun __assign(_i: Int, _bb: ByteBuffer) : LongFloatEntry {
+ __init(_i, _bb)
+ return this
+ }
+ val key : Long
+ get() {
+ val o = __offset(4)
+ return if(o != 0) bb.getLong(o + bb_pos) else 0L
+ }
+ val value : Float
+ get() {
+ val o = __offset(6)
+ return if(o != 0) bb.getFloat(o + bb_pos) else 0.0f
+ }
+ override fun keysCompare(o1: Int, o2: Int, _bb: ByteBuffer) : Int {
+ val val_1 = _bb.getLong(__offset(4, o1, _bb))
+ val val_2 = _bb.getLong(__offset(4, o2, _bb))
+ return (val_1 - val_2).sign
+ }
+ companion object {
+ fun validateVersion() = Constants.FLATBUFFERS_2_0_8()
+ fun getRootAsLongFloatEntry(_bb: ByteBuffer): LongFloatEntry = getRootAsLongFloatEntry(_bb, LongFloatEntry())
+ fun getRootAsLongFloatEntry(_bb: ByteBuffer, obj: LongFloatEntry): LongFloatEntry {
+ _bb.order(ByteOrder.LITTLE_ENDIAN)
+ return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb))
+ }
+ fun createLongFloatEntry(builder: FlatBufferBuilder, key: Long, value: Float) : Int {
+ builder.startTable(2)
+ addKey(builder, key)
+ addValue(builder, value)
+ return endLongFloatEntry(builder)
+ }
+ fun startLongFloatEntry(builder: FlatBufferBuilder) = builder.startTable(2)
+ fun addKey(builder: FlatBufferBuilder, key: Long) {
+ builder.addLong(key)
+ builder.slot(0)
+ }
+ fun addValue(builder: FlatBufferBuilder, value: Float) = builder.addFloat(1, value, 0.0)
+ fun endLongFloatEntry(builder: FlatBufferBuilder) : Int {
+ val o = builder.endTable()
+ return o
+ }
+ fun __lookup_by_key(obj: LongFloatEntry?, vectorLocation: Int, key: Long, bb: ByteBuffer) : LongFloatEntry? {
+ var span = bb.getInt(vectorLocation - 4)
+ var start = 0
+ while (span != 0) {
+ var middle = span / 2
+ val tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb)
+ val value = bb.getLong(__offset(4, bb.capacity() - tableOffset, bb))
+ val comp = value.compareTo(key)
+ when {
+ comp > 0 -> span = middle
+ comp < 0 -> {
+ middle++
+ start += middle
+ span -= middle
+ }
+ else -> {
+ return (obj ?: LongFloatEntry()).__assign(tableOffset, bb)
+ }
+ }
+ }
+ return null
+ }
+ }
+}
diff --git a/tests/DictionaryLookup/LongFloatMap.java b/tests/DictionaryLookup/LongFloatMap.java
new file mode 100644
index 0000000..9cc3500
--- /dev/null
+++ b/tests/DictionaryLookup/LongFloatMap.java
@@ -0,0 +1,51 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+package DictionaryLookup;
+
+import java.nio.*;
+import java.lang.*;
+import java.util.*;
+import com.google.flatbuffers.*;
+
+@SuppressWarnings("unused")
+public final class LongFloatMap extends Table {
+ public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
+ public static LongFloatMap getRootAsLongFloatMap(ByteBuffer _bb) { return getRootAsLongFloatMap(_bb, new LongFloatMap()); }
+ public static LongFloatMap getRootAsLongFloatMap(ByteBuffer _bb, LongFloatMap obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
+ public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
+ public LongFloatMap __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
+
+ public DictionaryLookup.LongFloatEntry entries(int j) { return entries(new DictionaryLookup.LongFloatEntry(), j); }
+ public DictionaryLookup.LongFloatEntry entries(DictionaryLookup.LongFloatEntry obj, int j) { int o = __offset(4); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
+ public int entriesLength() { int o = __offset(4); return o != 0 ? __vector_len(o) : 0; }
+ public DictionaryLookup.LongFloatEntry entriesByKey(long key) { int o = __offset(4); return o != 0 ? DictionaryLookup.LongFloatEntry.__lookup_by_key(null, __vector(o), key, bb) : null; }
+ public DictionaryLookup.LongFloatEntry entriesByKey(DictionaryLookup.LongFloatEntry obj, long key) { int o = __offset(4); return o != 0 ? DictionaryLookup.LongFloatEntry.__lookup_by_key(obj, __vector(o), key, bb) : null; }
+ public DictionaryLookup.LongFloatEntry.Vector entriesVector() { return entriesVector(new DictionaryLookup.LongFloatEntry.Vector()); }
+ public DictionaryLookup.LongFloatEntry.Vector entriesVector(DictionaryLookup.LongFloatEntry.Vector obj) { int o = __offset(4); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
+
+ public static int createLongFloatMap(FlatBufferBuilder builder,
+ int entriesOffset) {
+ builder.startTable(1);
+ LongFloatMap.addEntries(builder, entriesOffset);
+ return LongFloatMap.endLongFloatMap(builder);
+ }
+
+ public static void startLongFloatMap(FlatBufferBuilder builder) { builder.startTable(1); }
+ public static void addEntries(FlatBufferBuilder builder, int entriesOffset) { builder.addOffset(0, entriesOffset, 0); }
+ public static int createEntriesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
+ public static void startEntriesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
+ public static int endLongFloatMap(FlatBufferBuilder builder) {
+ int o = builder.endTable();
+ return o;
+ }
+ public static void finishLongFloatMapBuffer(FlatBufferBuilder builder, int offset) { builder.finish(offset); }
+ public static void finishSizePrefixedLongFloatMapBuffer(FlatBufferBuilder builder, int offset) { builder.finishSizePrefixed(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 LongFloatMap get(int j) { return get(new LongFloatMap(), j); }
+ public LongFloatMap get(LongFloatMap obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
+ }
+}
+
diff --git a/tests/DictionaryLookup/LongFloatMap.kt b/tests/DictionaryLookup/LongFloatMap.kt
new file mode 100644
index 0000000..3ac15aa
--- /dev/null
+++ b/tests/DictionaryLookup/LongFloatMap.kt
@@ -0,0 +1,77 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+package DictionaryLookup
+
+import java.nio.*
+import kotlin.math.sign
+import com.google.flatbuffers.*
+
+@Suppress("unused")
+class LongFloatMap : Table() {
+
+ fun __init(_i: Int, _bb: ByteBuffer) {
+ __reset(_i, _bb)
+ }
+ fun __assign(_i: Int, _bb: ByteBuffer) : LongFloatMap {
+ __init(_i, _bb)
+ return this
+ }
+ fun entries(j: Int) : DictionaryLookup.LongFloatEntry? = entries(DictionaryLookup.LongFloatEntry(), j)
+ fun entries(obj: DictionaryLookup.LongFloatEntry, j: Int) : DictionaryLookup.LongFloatEntry? {
+ val o = __offset(4)
+ return if (o != 0) {
+ obj.__assign(__indirect(__vector(o) + j * 4), bb)
+ } else {
+ null
+ }
+ }
+ val entriesLength : Int
+ get() {
+ val o = __offset(4); return if (o != 0) __vector_len(o) else 0
+ }
+ fun entriesByKey(key: Long) : DictionaryLookup.LongFloatEntry? {
+ val o = __offset(4)
+ return if (o != 0) {
+ DictionaryLookup.LongFloatEntry.__lookup_by_key(null, __vector(o), key, bb)
+ } else {
+ null
+ }
+ }
+ fun entriesByKey(obj: DictionaryLookup.LongFloatEntry, key: Long) : DictionaryLookup.LongFloatEntry? {
+ val o = __offset(4)
+ return if (o != 0) {
+ DictionaryLookup.LongFloatEntry.__lookup_by_key(obj, __vector(o), key, bb)
+ } else {
+ null
+ }
+ }
+ companion object {
+ fun validateVersion() = Constants.FLATBUFFERS_2_0_8()
+ fun getRootAsLongFloatMap(_bb: ByteBuffer): LongFloatMap = getRootAsLongFloatMap(_bb, LongFloatMap())
+ fun getRootAsLongFloatMap(_bb: ByteBuffer, obj: LongFloatMap): LongFloatMap {
+ _bb.order(ByteOrder.LITTLE_ENDIAN)
+ return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb))
+ }
+ fun createLongFloatMap(builder: FlatBufferBuilder, entriesOffset: Int) : Int {
+ builder.startTable(1)
+ addEntries(builder, entriesOffset)
+ return endLongFloatMap(builder)
+ }
+ fun startLongFloatMap(builder: FlatBufferBuilder) = builder.startTable(1)
+ fun addEntries(builder: FlatBufferBuilder, entries: Int) = builder.addOffset(0, entries, 0)
+ fun createEntriesVector(builder: FlatBufferBuilder, data: IntArray) : Int {
+ builder.startVector(4, data.size, 4)
+ for (i in data.size - 1 downTo 0) {
+ builder.addOffset(data[i])
+ }
+ return builder.endVector()
+ }
+ fun startEntriesVector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(4, numElems, 4)
+ fun endLongFloatMap(builder: FlatBufferBuilder) : Int {
+ val o = builder.endTable()
+ return o
+ }
+ fun finishLongFloatMapBuffer(builder: FlatBufferBuilder, offset: Int) = builder.finish(offset)
+ fun finishSizePrefixedLongFloatMapBuffer(builder: FlatBufferBuilder, offset: Int) = builder.finishSizePrefixed(offset)
+ }
+}
diff --git a/tests/FlatBuffers.Benchmarks.swift/Sources/FlatBuffers.Benchmarks.swift/main.swift b/tests/FlatBuffers.Benchmarks.swift/Sources/FlatBuffers.Benchmarks.swift/main.swift
deleted file mode 100644
index 4949004..0000000
--- a/tests/FlatBuffers.Benchmarks.swift/Sources/FlatBuffers.Benchmarks.swift/main.swift
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright 2021 Google Inc. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import CoreFoundation
-import FlatBuffers
-
-struct Benchmark {
- var name: String
- var value: Double
-
- var description: String {
- "\(String(format: "|\t%@\t\t|\t\t%fs\t|", name, value))"}
-}
-
-func run(name: String, runs: Int, action: () -> Void) -> Benchmark {
- action()
- let start = CFAbsoluteTimeGetCurrent()
- for _ in 0..<runs {
- action()
- }
- let ends = CFAbsoluteTimeGetCurrent()
- let value = Double(ends - start) / Double(runs)
- print("done \(name): in \(value)")
- return Benchmark(name: name, value: value)
-}
-
-
-func createDocument(Benchmarks: [Benchmark]) -> String {
- let separator = "-------------------------------------"
- var document = "\(separator)\n"
- document += "\(String(format: "|\t%@\t\t |\t\t%@\t\t|", "Name", "Scores"))\n"
- document += "\(separator)\n"
- for i in Benchmarks {
- document += "\(i.description) \n"
- document += "\(separator)\n"
- }
- return document
-}
-
-@inlinable
-func create10Strings() {
- var fb = FlatBufferBuilder(initialSize: 1<<20)
- for _ in 0..<10_000 {
- _ = fb.create(string: "foobarbaz")
- }
-}
-
-@inlinable
-func create100Strings(str: String) {
- var fb = FlatBufferBuilder(initialSize: 1<<20)
- for _ in 0..<10_000 {
- _ = fb.create(string: str)
- }
-}
-
-@inlinable
-func benchmarkFiveHundredAdds() {
- var fb = FlatBufferBuilder(initialSize: 1024 * 1024 * 32)
- for _ in 0..<500_000 {
- let off = fb.create(string: "T")
- let s = fb.startTable(with: 4)
- fb.add(element: 3.2, def: 0, at: 2)
- fb.add(element: 4.2, def: 0, at: 4)
- fb.add(element: 5.2, def: 0, at: 6)
- fb.add(offset: off, at: 8)
- _ = fb.endTable(at: s)
- }
-}
-
-@inlinable
-func benchmarkThreeMillionStructs() {
- let structCount = 3_000_000
-
- let rawSize = ((16 * 5) * structCount) / 1024
-
- var fb = FlatBufferBuilder(initialSize: Int32(rawSize * 1600))
-
- var offsets: [Offset] = []
- for _ in 0..<structCount {
- fb.startVector(
- 5 * MemoryLayout<AA>.size,
- elementSize: MemoryLayout<AA>.alignment)
- for _ in 0..<5 {
- _ = fb.create(struct: AA(a: 2.4, b: 2.4))
- }
- let vector = fb.endVector(len: 5)
- let start = fb.startTable(with: 1)
- fb.add(offset: vector, at: 4)
- offsets.append(Offset(offset: fb.endTable(at: start)))
- }
- let vector = fb.createVector(ofOffsets: offsets)
- let start = fb.startTable(with: 1)
- fb.add(offset: vector, at: 4)
- let root = Offset(offset: fb.endTable(at: start))
- fb.finish(offset: root)
-}
-
-@usableFromInline
-struct AA: NativeStruct {
- public init(a: Double, b: Double) {
- self.a = a
- self.b = b
- }
- var a: Double
- var b: Double
-
-}
-
-func benchmark(numberOfRuns runs: Int) {
- var benchmarks: [Benchmark] = []
- let str = (0...99).map { _ -> String in "x" }.joined()
- benchmarks.append(run(
- name: "500_000",
- runs: runs,
- action: benchmarkFiveHundredAdds))
- benchmarks.append(run(name: "10 str", runs: runs, action: create10Strings))
- let hundredStr = run(name: "100 str", runs: runs) {
- create100Strings(str: str)
- }
- benchmarks.append(run(
- name: "3M strc",
- runs: 1,
- action: benchmarkThreeMillionStructs))
- benchmarks.append(hundredStr)
- print(createDocument(Benchmarks: benchmarks))
-}
-
-benchmark(numberOfRuns: 20)
diff --git a/tests/FlatBuffers.Benchmarks/FlatBufferBuilderBenchmark.cs b/tests/FlatBuffers.Benchmarks/FlatBufferBuilderBenchmark.cs
index 1df5ac3..b385885 100644
--- a/tests/FlatBuffers.Benchmarks/FlatBufferBuilderBenchmark.cs
+++ b/tests/FlatBuffers.Benchmarks/FlatBufferBuilderBenchmark.cs
@@ -17,7 +17,7 @@
using BenchmarkDotNet.Attributes;
using MyGame.Example;
-namespace FlatBuffers.Benchmarks
+namespace Google.FlatBuffers.Benchmarks
{
//[EtwProfiler] - needs elevated privileges
[MemoryDiagnoser]
diff --git a/tests/FlatBuffers.Benchmarks/Program.cs b/tests/FlatBuffers.Benchmarks/Program.cs
index 9e63b4b..fa152ca 100644
--- a/tests/FlatBuffers.Benchmarks/Program.cs
+++ b/tests/FlatBuffers.Benchmarks/Program.cs
@@ -16,7 +16,7 @@
using BenchmarkDotNet.Running;
-namespace FlatBuffers.Benchmarks
+namespace Google.FlatBuffers.Benchmarks
{
public static class Program
{
diff --git a/tests/FlatBuffers.Test.Swift/SwiftTest.sh b/tests/FlatBuffers.Test.Swift/SwiftTest.sh
deleted file mode 100755
index 99ab1f1..0000000
--- a/tests/FlatBuffers.Test.Swift/SwiftTest.sh
+++ /dev/null
@@ -1,26 +0,0 @@
-swift_dir=`pwd`
-cd ..
-test_dir=`pwd`
-alias fbc='${test_dir}/../flatc'
-shopt -s expand_aliases
-
-cd ${swift_dir}/Tests/FlatBuffers.Test.SwiftTests
-fbc --swift --gen-mutable --grpc --gen-json-emit --gen-object-api -I ${test_dir}/include_test ${test_dir}/monster_test.fbs ${test_dir}/union_vector/union_vector.fbs
-fbc --swift --gen-json-emit ${test_dir}/optional_scalars.fbs
-fbc --swift --gen-json-emit --gen-object-api ${test_dir}/more_defaults.fbs
-fbc --swift --gen-json-emit --gen-mutable --gen-object-api ${test_dir}/MutatingBool.fbs
-cd ${swift_dir}
-
-cd ${swift_dir}/Sources/SwiftFlatBuffers
-# create better fuzzing test file
-fbc --swift --gen-json-emit fuzzer.fbs
-cd ${swift_dir}
-
-swift build --build-tests
-swift test
-
-if [ $(uname -s) != Darwin ]; then
- echo fuzzing
- swift build -c debug -Xswiftc -sanitize=fuzzer,address -Xswiftc -parse-as-library
- swift build -c release -Xswiftc -sanitize=fuzzer,address -Xswiftc -parse-as-library
-fi
diff --git a/tests/FlatBuffers.Test/Assert.cs b/tests/FlatBuffers.Test/Assert.cs
index 488c338..7bb8004 100644
--- a/tests/FlatBuffers.Test/Assert.cs
+++ b/tests/FlatBuffers.Test/Assert.cs
@@ -19,7 +19,7 @@
using System.Linq;
using System.Text;
-namespace FlatBuffers.Test
+namespace Google.FlatBuffers.Test
{
public class AssertFailedException : Exception
diff --git a/tests/FlatBuffers.Test/ByteBufferTests.cs b/tests/FlatBuffers.Test/ByteBufferTests.cs
index 98e917c..6bff2ac 100644
--- a/tests/FlatBuffers.Test/ByteBufferTests.cs
+++ b/tests/FlatBuffers.Test/ByteBufferTests.cs
@@ -15,8 +15,9 @@
*/
using System;
+using System.Runtime.InteropServices;
-namespace FlatBuffers.Test
+namespace Google.FlatBuffers.Test
{
[FlatBuffersTestClass]
public class ByteBufferTests
@@ -408,6 +409,60 @@
Assert.ArrayEqual(data, bbArray);
}
+ public void ByteBuffer_Put_ArraySegment_Helper<T>(ArraySegment<T> data, int typeSize)
+ where T : struct
+ {
+ // Create the Byte Buffer
+ var uut = new ByteBuffer(1024);
+
+ // Put the data into the buffer and make sure the offset is
+ // calculated correctly
+ int nOffset = uut.Put(1024, data);
+ Assert.AreEqual(1024 - typeSize * data.Count, nOffset);
+
+ // Get the full array back out and ensure they are equivalent
+ var bbArray = uut.ToArray<T>(nOffset, data.Count);
+ Assert.ArrayEqual(data.ToArray(), bbArray);
+ }
+
+ public unsafe void ByteBuffer_Put_IntPtr_Helper<T>(T[] data, int typeSize)
+ where T : struct
+ {
+ GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);
+ try
+ {
+ var dataPtr = handle.AddrOfPinnedObject();
+ var sizeInBytes = data.Length * typeSize;
+
+ // Create the Byte Buffer
+ var uut = new ByteBuffer(1024);
+
+ // Put the data into the buffer and make sure the offset is
+ // calculated correctly
+ int nOffset = uut.Put<T>(1024, dataPtr, sizeInBytes);
+ Assert.AreEqual(1024 - sizeInBytes, nOffset);
+
+ // Get the full array back out and ensure they are equivalent
+ var bbArray = uut.ToArray<T>(nOffset, data.Length);
+ Assert.ArrayEqual(data, bbArray);
+ }
+ finally
+ {
+ handle.Free();
+ }
+ }
+
+ public void ByteBuffer_Put_ArrayTypes_Helper<T>(T[] data, int typeSize)
+ where T : struct
+ {
+ ByteBuffer_Put_Array_Helper(data, typeSize);
+
+ var arraySegment = CreateArraySegment(data);
+ ByteBuffer_Put_ArraySegment_Helper(arraySegment, typeSize);
+
+ ByteBuffer_Put_IntPtr_Helper(data, typeSize);
+ }
+
[FlatBuffersTestMethod]
public void ByteBuffer_Put_Array_Float()
{
@@ -425,7 +480,7 @@
data[7] = 15.9994F;
data[8] = 18.9984F;
- ByteBuffer_Put_Array_Helper(data, sizeof(float));
+ ByteBuffer_Put_ArrayTypes_Helper(data, sizeof(float));
}
[FlatBuffersTestMethod]
@@ -445,7 +500,7 @@
data[7] = 15.9994;
data[8] = 18.9984;
- ByteBuffer_Put_Array_Helper(data, sizeof(double));
+ ByteBuffer_Put_ArrayTypes_Helper(data, sizeof(double));
}
[FlatBuffersTestMethod]
@@ -465,7 +520,7 @@
data[7] = 15;
data[8] = 18;
- ByteBuffer_Put_Array_Helper(data, sizeof(int));
+ ByteBuffer_Put_ArrayTypes_Helper(data, sizeof(int));
}
@@ -486,7 +541,7 @@
data[7] = 15;
data[8] = 18;
- ByteBuffer_Put_Array_Helper(data, sizeof(uint));
+ ByteBuffer_Put_ArrayTypes_Helper(data, sizeof(uint));
}
[FlatBuffersTestMethod]
@@ -506,7 +561,7 @@
data[7] = true;
data[8] = false;
- ByteBuffer_Put_Array_Helper(data, sizeof(bool));
+ ByteBuffer_Put_ArrayTypes_Helper(data, sizeof(bool));
}
[FlatBuffersTestMethod]
@@ -526,7 +581,7 @@
data[7] = 15;
data[8] = 18;
- ByteBuffer_Put_Array_Helper(data, sizeof(long));
+ ByteBuffer_Put_ArrayTypes_Helper(data, sizeof(long));
}
[FlatBuffersTestMethod]
@@ -546,7 +601,7 @@
data[7] = 15;
data[8] = 18;
- ByteBuffer_Put_Array_Helper(data, sizeof(byte));
+ ByteBuffer_Put_ArrayTypes_Helper(data, sizeof(byte));
}
[FlatBuffersTestMethod]
@@ -566,7 +621,16 @@
data[7] = 15;
data[8] = 18;
- ByteBuffer_Put_Array_Helper(data, sizeof(sbyte));
+ ByteBuffer_Put_ArrayTypes_Helper(data, sizeof(sbyte));
+ }
+
+ private static ArraySegment<T> CreateArraySegment<T>(T[] data)
+ where T : struct
+ {
+ const int arraySegmentPadding = 7;
+ var newData = new T[data.Length + 2 * arraySegmentPadding];
+ Array.Copy(data, 0, newData, arraySegmentPadding, data.Length);
+ return new ArraySegment<T>(newData, arraySegmentPadding, data.Length);
}
[FlatBuffersTestMethod]
@@ -578,10 +642,17 @@
// create a null array and try to put it into the buffer
float[] data = null;
Assert.Throws<ArgumentNullException>(() => uut.Put(1024, data));
+
+ ArraySegment<float> dataArraySegment = default;
+ Assert.Throws<ArgumentNullException>(() => uut.Put(1024, dataArraySegment));
+
+ IntPtr dataPtr = IntPtr.Zero;
+ int dataPtrLength = 100;
+ Assert.Throws<ArgumentNullException>(() => uut.Put<float>(1024, dataPtr, dataPtrLength));
}
[FlatBuffersTestMethod]
- public void ByteBuffer_Put_Array_Empty_Throws()
+ public unsafe void ByteBuffer_Put_Array_Empty_Throws()
{
// Create the Byte Buffer
var uut = new ByteBuffer(1024);
@@ -589,6 +660,32 @@
// create an array of length == 0, and try to put it into the buffer
float[] data = new float[0];
Assert.Throws<ArgumentException>(() => uut.Put(1024, data));
+
+ var dataArraySegment = new ArraySegment<float>(new float[10], 5, 0);
+ Assert.Throws<ArgumentException>(() => uut.Put(1024, dataArraySegment));
+
+ fixed(float* floatPtr = data)
+ {
+ var dataPtr = (IntPtr)floatPtr;
+ var dataPtrLength = 0;
+ Assert.Throws<ArgumentException>(() => uut.Put<float>(1024, dataPtr, dataPtrLength));
+ }
+ }
+
+ [FlatBuffersTestMethod]
+ public unsafe void ByteBuffer_Put_IntPtr_NegativeSize_Throws()
+ {
+ // Create the Byte Buffer
+ var uut = new ByteBuffer(1024);
+
+ // create an array of length == 0, and try to put it into the buffer
+ float[] data = new float[10];
+ fixed(float* floatPtr = data)
+ {
+ var dataPtr = (IntPtr)floatPtr;
+ var dataPtrLength = -1;
+ Assert.Throws<ArgumentException>(() => uut.Put<float>(1024, dataPtr, dataPtrLength));
+ }
}
#pragma warning disable 0169
@@ -601,7 +698,7 @@
#pragma warning restore 0169
[FlatBuffersTestMethod]
- public void ByteBuffer_Put_Array_IncorrectType_Throws()
+ public unsafe void ByteBuffer_Put_Array_IncorrectType_Throws()
{
// Create the Byte Buffer
var uut = new ByteBuffer(1024);
@@ -610,6 +707,16 @@
// able to be put into the buffer
var data = new dummyStruct[10];
Assert.Throws<ArgumentException>(() => uut.Put(1024, data));
+
+ var dataArraySegment = new ArraySegment<dummyStruct>(data);
+ Assert.Throws<ArgumentException>(() => uut.Put(1024, dataArraySegment));
+
+ fixed(dummyStruct* floatPtr = data)
+ {
+ var dataPtr = (IntPtr)floatPtr;
+ var dataPtrLength = data.Length * sizeof(dummyStruct);
+ Assert.Throws<ArgumentException>(() => uut.Put<dummyStruct>(1024, dataPtr, dataPtrLength));
+ }
}
[FlatBuffersTestMethod]
diff --git a/tests/FlatBuffers.Test/FlatBufferBuilderTests.cs b/tests/FlatBuffers.Test/FlatBufferBuilderTests.cs
index e2b72c7..7fe9740 100644
--- a/tests/FlatBuffers.Test/FlatBufferBuilderTests.cs
+++ b/tests/FlatBuffers.Test/FlatBufferBuilderTests.cs
@@ -16,7 +16,7 @@
using System;
-namespace FlatBuffers.Test
+namespace Google.FlatBuffers.Test
{
[FlatBuffersTestClass]
public class FlatBufferBuilderTests
@@ -553,6 +553,18 @@
Assert.Throws<ArgumentNullException>(() => fbb.Add(data));
}
+
+ [FlatBuffersTestMethod]
+ public unsafe void FlatBufferBuilder_Add_Array_UnsupportedType_Throws()
+ {
+ var fbb = CreateBuffer(false);
+
+ var storedOffset = fbb.Offset;
+
+ // Construct the data array
+ var data = new DummyStruct[10];
+ Assert.Throws<ArgumentException>(() => fbb.Add(data));
+ }
[FlatBuffersTestMethod]
public void FlatBufferBuilder_Add_Array_Empty_Noop()
@@ -570,6 +582,159 @@
var endOffset = fbb.Offset;
Assert.AreEqual(endOffset, storedOffset);
}
+
+ [FlatBuffersTestMethod]
+ public void FlatBufferBuilder_Add_ArraySegment_Default_Throws()
+ {
+ var fbb = CreateBuffer(false);
+
+ // Construct the data array
+ ArraySegment<float> data = default;
+
+ Assert.Throws<ArgumentNullException>(() => fbb.Add(data));
+ }
+
+ [FlatBuffersTestMethod]
+ public unsafe void FlatBufferBuilder_Add_ArraySegment_UnsupportedType_Throws()
+ {
+ var fbb = CreateBuffer(false);
+
+ var storedOffset = fbb.Offset;
+
+ // Construct the data array
+ var array = new DummyStruct[10];
+ var data = new ArraySegment<DummyStruct>(array);
+ Assert.Throws<ArgumentException>(() => fbb.Add(data));
+ }
+
+ [FlatBuffersTestMethod]
+ public void FlatBufferBuilder_Add_ArraySegment_Empty_Noop()
+ {
+ var fbb = CreateBuffer(false);
+
+ var storedOffset = fbb.Offset;
+
+ // Construct the data array
+ var array = new float[10];
+ var data = new ArraySegment<float>(array, 5, 0);
+ fbb.Add(data);
+
+ // Make sure the offset didn't change since nothing
+ // was really added
+ var endOffset = fbb.Offset;
+ Assert.AreEqual(endOffset, storedOffset);
+ }
+
+ [FlatBuffersTestMethod]
+ public void FlatBufferBuilder_Add_IntPtr_Zero_Throws()
+ {
+ var fbb = CreateBuffer(false);
+
+ // Construct the data array
+ var data = IntPtr.Zero;
+ var length = 100;
+
+ Assert.Throws<ArgumentNullException>(() => fbb.Add<float>(data, length));
+ }
+
+ [FlatBuffersTestMethod]
+ public unsafe void FlatBufferBuilder_Add_IntPtr_SizeNegative_Throws()
+ {
+ var fbb = CreateBuffer(false);
+
+ // Construct the data array
+ var array = new float[10];
+ fixed(float* ptr = array)
+ {
+ var data = (IntPtr)ptr;
+ var length = -1;
+ Assert.Throws<ArgumentOutOfRangeException>(() => fbb.Add<float>(data, length));
+ }
+ }
+
+ [FlatBuffersTestMethod]
+ public void FlatBufferBuilder_Add_IntPtr_Zero_Empty_Noop()
+ {
+ var fbb = CreateBuffer(false);
+
+ var storedOffset = fbb.Offset;
+
+ // Construct the data array
+ var data = IntPtr.Zero;
+ var length = 0;
+
+ fbb.Add<float>(data, length);
+
+ // make sure that a length of 0 doesn't throw also if ptr is Zero as well
+ // and that nothing was really added
+ var endOffset = fbb.Offset;
+ Assert.AreEqual(endOffset, storedOffset);
+ }
+
+ [FlatBuffersTestMethod]
+ public unsafe void FlatBufferBuilder_Add_IntPtr_Empty_Noop()
+ {
+ var fbb = CreateBuffer(false);
+
+ var storedOffset = fbb.Offset;
+
+ // Construct the data array
+ var array = new float[10];
+ fixed(float* ptr = array)
+ {
+ var data = (IntPtr)ptr;
+ var length = 0;
+ fbb.Add<float>(data, length);
+ }
+
+ // Make sure the offset didn't change since nothing
+ // was really added
+ var endOffset = fbb.Offset;
+ Assert.AreEqual(endOffset, storedOffset);
+ }
+
+ [FlatBuffersTestMethod]
+ public unsafe void FlatBufferBuilder_Add_IntPtr_SizeInBytesNotMatchingDataType_Throws()
+ {
+ var fbb = CreateBuffer(false);
+
+ var storedOffset = fbb.Offset;
+
+ // Construct the data array
+ var array = new float[10];
+ fixed(float* ptr = array)
+ {
+ const int invalidBytes = 1;
+ var data = (IntPtr)ptr;
+ // add some invalid bytes to the length
+ var length = 2 * sizeof(float) + invalidBytes;
+
+ Assert.Throws<ArgumentException>(() => fbb.Add<float>(data, length));
+ }
+ }
+
+ [FlatBuffersTestMethod]
+ public unsafe void FlatBufferBuilder_Add_IntPtr_UnsupportedType_Throws()
+ {
+ var fbb = CreateBuffer(false);
+
+ var storedOffset = fbb.Offset;
+
+ // Construct the data array
+ var array = new DummyStruct[10];
+ fixed(DummyStruct* ptr = array)
+ {
+ var data = (IntPtr)ptr;
+ var length = 10 * sizeof(DummyStruct);
+
+ Assert.Throws<ArgumentException>(() => fbb.Add<DummyStruct>(data, length));
+ }
+ }
+
+ private struct DummyStruct
+ {
+ int value;
+ }
[FlatBuffersTestMethod]
public void FlatBufferBuilder_Add_null_String()
diff --git a/tests/FlatBuffers.Test/FlatBuffers.Core.Test.csproj b/tests/FlatBuffers.Test/FlatBuffers.Core.Test.csproj
index 6cd4e78..a769785 100644
--- a/tests/FlatBuffers.Test/FlatBuffers.Core.Test.csproj
+++ b/tests/FlatBuffers.Test/FlatBuffers.Core.Test.csproj
@@ -19,6 +19,14 @@
<DefineConstants>$(DefineConstants);ENABLE_SPAN_T</DefineConstants>
</PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ </PropertyGroup>
+
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ </PropertyGroup>
+
<ItemGroup>
<Compile Include="..\..\net\FlatBuffers\ByteBuffer.cs">
<Link>FlatBuffers\ByteBuffer.cs</Link>
@@ -183,7 +191,7 @@
</ItemGroup>
<ItemGroup>
- <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
+ <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
</Project>
diff --git a/tests/FlatBuffers.Test/FlatBuffers.Test.csproj b/tests/FlatBuffers.Test/FlatBuffers.Test.csproj
index 1247599..0f683cb 100644
--- a/tests/FlatBuffers.Test/FlatBuffers.Test.csproj
+++ b/tests/FlatBuffers.Test/FlatBuffers.Test.csproj
@@ -21,6 +21,7 @@
<DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -29,6 +30,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
@@ -38,14 +40,9 @@
<DefineConstants>$(DefineConstants);UNSAFE_BYTEBUFFER</DefineConstants>
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="Newtonsoft.Json">
- <Version>12.0.3</Version>
- </PackageReference>
+ <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
<ItemGroup>
- <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
- <HintPath>packages\Newtonsoft.Json.12.0.3\lib\net35\Newtonsoft.Json.dll</HintPath>
- </Reference>
<Reference Include="System" />
<Reference Include="System.Core">
</Reference>
diff --git a/tests/FlatBuffers.Test/FlatBuffersExampleTests.cs b/tests/FlatBuffers.Test/FlatBuffersExampleTests.cs
index ec3b2ea..6c9e309 100644
--- a/tests/FlatBuffers.Test/FlatBuffersExampleTests.cs
+++ b/tests/FlatBuffers.Test/FlatBuffersExampleTests.cs
@@ -21,7 +21,7 @@
using optional_scalars;
using KeywordTest;
-namespace FlatBuffers.Test
+namespace Google.FlatBuffers.Test
{
[FlatBuffersTestClass]
public class FlatBuffersExampleTests
@@ -156,8 +156,11 @@
// Example of searching for a table by the key
Assert.IsTrue(monster.TestarrayoftablesByKey("Frodo") != null);
+ Assert.AreEqual(monster.TestarrayoftablesByKey("Frodo").Value.Name, "Frodo");
Assert.IsTrue(monster.TestarrayoftablesByKey("Barney") != null);
+ Assert.AreEqual(monster.TestarrayoftablesByKey("Barney").Value.Name, "Barney");
Assert.IsTrue(monster.TestarrayoftablesByKey("Wilma") != null);
+ Assert.AreEqual(monster.TestarrayoftablesByKey("Wilma").Value.Name, "Wilma");
// testType is an existing field
Assert.AreEqual(monster.TestType, Any.Monster);
@@ -1152,5 +1155,41 @@
ScalarStuff scalarStuff = ScalarStuff.GetRootAsScalarStuff(fbb.DataBuffer);
Assert.AreEqual(null, scalarStuff.MaybeEnum);
}
+
+
+ [FlatBuffersTestMethod]
+ public void SortKey_WithDefaultedValue_IsFindable() {
+ // This checks if using the `key` attribute that includes the
+ // default value (e.g., 0) is still searchable. This is a regression
+ // test for https://github.com/google/flatbuffers/issues/7380.
+ var fbb = new FlatBufferBuilder(1);
+
+ // Create a vector of Stat objects, with Count being the key.
+ var stat_offsets = new Offset<Stat>[4];
+ for(ushort i = 0; i < stat_offsets.Length; i++) {
+ Stat.StartStat(fbb);
+ Stat.AddCount(fbb, i);
+ stat_offsets[stat_offsets.Length - 1 - i] = Stat.EndStat(fbb);
+ }
+
+ // Ensure the sort works.
+ var sort = Stat.CreateSortedVectorOfStat(fbb, stat_offsets);
+
+ // Create the monster with the sorted vector of Stat objects.
+ var str = fbb.CreateString("MyMonster");
+ Monster.StartMonster(fbb);
+ Monster.AddName(fbb, str);
+ Monster.AddScalarKeySortedTables(fbb, sort);
+ fbb.Finish(Monster.EndMonster(fbb).Value);
+
+ // Get the monster.
+ var monster = Monster.GetRootAsMonster(fbb.DataBuffer);
+
+ // Ensure each key is findable.
+ for(ushort i =0 ; i < stat_offsets.Length; i++) {
+ Assert.IsTrue(monster.ScalarKeySortedTablesByKey(i) != null);
+ Assert.AreEqual(monster.ScalarKeySortedTablesByKey(i).Value.Count, i);
+ }
+ }
}
}
diff --git a/tests/FlatBuffers.Test/FlatBuffersFuzzTests.cs b/tests/FlatBuffers.Test/FlatBuffersFuzzTests.cs
index b6c60ea..0377a7b 100644
--- a/tests/FlatBuffers.Test/FlatBuffersFuzzTests.cs
+++ b/tests/FlatBuffers.Test/FlatBuffersFuzzTests.cs
@@ -16,7 +16,7 @@
using System;
-namespace FlatBuffers.Test
+namespace Google.FlatBuffers.Test
{
[FlatBuffersTestClass]
public class FlatBuffersFuzzTests
diff --git a/tests/FlatBuffers.Test/FlatBuffersTestClassAttribute.cs b/tests/FlatBuffers.Test/FlatBuffersTestClassAttribute.cs
index f31e38b..7ad7df6 100644
--- a/tests/FlatBuffers.Test/FlatBuffersTestClassAttribute.cs
+++ b/tests/FlatBuffers.Test/FlatBuffersTestClassAttribute.cs
@@ -19,7 +19,7 @@
using System.Linq;
using System.Text;
-namespace FlatBuffers.Test
+namespace Google.FlatBuffers.Test
{
[AttributeUsage(AttributeTargets.Class)]
public class FlatBuffersTestClassAttribute : Attribute
diff --git a/tests/FlatBuffers.Test/FlatBuffersTestMethodAttribute.cs b/tests/FlatBuffers.Test/FlatBuffersTestMethodAttribute.cs
index 989dae5..4276b74 100644
--- a/tests/FlatBuffers.Test/FlatBuffersTestMethodAttribute.cs
+++ b/tests/FlatBuffers.Test/FlatBuffersTestMethodAttribute.cs
@@ -16,7 +16,7 @@
using System;
-namespace FlatBuffers.Test
+namespace Google.FlatBuffers.Test
{
[AttributeUsage(AttributeTargets.Method)]
public class FlatBuffersTestMethodAttribute : Attribute
diff --git a/tests/FlatBuffers.Test/FuzzTestData.cs b/tests/FlatBuffers.Test/FuzzTestData.cs
index 119e44e..186e312 100644
--- a/tests/FlatBuffers.Test/FuzzTestData.cs
+++ b/tests/FlatBuffers.Test/FuzzTestData.cs
@@ -16,7 +16,7 @@
using System;
-namespace FlatBuffers.Test
+namespace Google.FlatBuffers.Test
{
internal static class FuzzTestData
{
diff --git a/tests/FlatBuffers.Test/Lcg.cs b/tests/FlatBuffers.Test/Lcg.cs
index c329ed8..c6322d5 100644
--- a/tests/FlatBuffers.Test/Lcg.cs
+++ b/tests/FlatBuffers.Test/Lcg.cs
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-namespace FlatBuffers.Test
+namespace Google.FlatBuffers.Test
{
/// <summary>
/// Lcg Pseudo RNG
diff --git a/tests/FlatBuffers.Test/Program.cs b/tests/FlatBuffers.Test/Program.cs
index f8cec4e..cd04d25 100644
--- a/tests/FlatBuffers.Test/Program.cs
+++ b/tests/FlatBuffers.Test/Program.cs
@@ -19,7 +19,7 @@
using System.Linq;
using System.Reflection;
-namespace FlatBuffers.Test
+namespace Google.FlatBuffers.Test
{
static class Program
{
diff --git a/tests/FlatBuffers.Test/TestTable.cs b/tests/FlatBuffers.Test/TestTable.cs
index 4f663f0..659ac8f 100644
--- a/tests/FlatBuffers.Test/TestTable.cs
+++ b/tests/FlatBuffers.Test/TestTable.cs
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-namespace FlatBuffers.Test
+namespace Google.FlatBuffers.Test
{
/// <summary>
/// A test Table object that gives easy access to the slot data
diff --git a/tests/FlatBuffers.Test/packages.config b/tests/FlatBuffers.Test/packages.config
index d766d04..1d41d8e 100644
--- a/tests/FlatBuffers.Test/packages.config
+++ b/tests/FlatBuffers.Test/packages.config
@@ -1,4 +1,4 @@
īģŋ<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Newtonsoft.Json" version="12.0.3" targetFramework="net35" />
+ <package id="Newtonsoft.Json" version="13.0.1" targetFramework="net35" />
</packages>
\ No newline at end of file
diff --git a/tests/GoTest.sh b/tests/GoTest.sh
index 9f7ad76..85253c1 100755
--- a/tests/GoTest.sh
+++ b/tests/GoTest.sh
@@ -41,6 +41,11 @@
cp -a ./go_test.go ./go_gen/src/flatbuffers_test/
cp -a optional_scalars/*.go ./go_gen/src/optional_scalars
+# https://stackoverflow.com/a/63545857/7024978
+# We need to turn off go modules for this script
+# to work.
+go env -w GO111MODULE=off
+
# Run tests with necessary flags.
# Developers may wish to see more detail by appending the verbosity flag
# -test.v to arguments for this command, as in:
diff --git a/tests/JavaTest.bat b/tests/JavaTest.bat
deleted file mode 100644
index 921815a..0000000
--- a/tests/JavaTest.bat
+++ /dev/null
@@ -1,21 +0,0 @@
-@echo off
-rem Copyright 2014 Google Inc. All rights reserved.
-rem
-rem Licensed under the Apache License, Version 2.0 (the "License");
-rem you may not use this file except in compliance with the License.
-rem You may obtain a copy of the License at
-rem
-rem http://www.apache.org/licenses/LICENSE-2.0
-rem
-rem Unless required by applicable law or agreed to in writing, software
-rem distributed under the License is distributed on an "AS IS" BASIS,
-rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-rem See the License for the specific language governing permissions and
-rem limitations under the License.
-
-rem Compile then run the Java test.
-
-set batch_file_dir=%~d0%~p0
-
-javac -g -classpath %batch_file_dir%\..\java;%batch_file_dir%;%batch_file_dir%\namespace_test;%batch_file_dir%\union_vector JavaTest.java
-java -classpath %batch_file_dir%\..\java;%batch_file_dir%;%batch_file_dir%\namespace_test;%batch_file_dir%\union_vector JavaTest
diff --git a/tests/JavaTest.java b/tests/JavaTest.java
deleted file mode 100644
index 0f2ad12..0000000
--- a/tests/JavaTest.java
+++ /dev/null
@@ -1,1558 +0,0 @@
-
-import static com.google.flatbuffers.Constants.*;
-
-import MyGame.Example.*;
-import optional_scalars.ScalarStuff;
-import optional_scalars.OptionalByte;
-import MyGame.MonsterExtra;
-import NamespaceA.*;
-import NamespaceA.NamespaceB.*;
-import com.google.flatbuffers.ByteBufferUtil;
-import com.google.flatbuffers.ByteVector;
-import com.google.flatbuffers.FlatBufferBuilder;
-import com.google.flatbuffers.FlexBuffers;
-import com.google.flatbuffers.FlexBuffersBuilder;
-import com.google.flatbuffers.StringVector;
-import com.google.flatbuffers.UnionVector;
-
-import com.google.flatbuffers.FlexBuffers.FlexBufferException;
-import com.google.flatbuffers.FlexBuffers.Reference;
-import com.google.flatbuffers.FlexBuffers.Vector;
-import com.google.flatbuffers.ArrayReadWriteBuf;
-import com.google.flatbuffers.FlexBuffers.KeyVector;
-
-import java.io.*;
-import java.math.BigInteger;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.CharBuffer;
-import java.nio.channels.FileChannel;
-import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-
-/*
- * Copyright 2014 Google Inc. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-class JavaTest {
- public static void main(String[] args) {
-
- // First, let's test reading a FlatBuffer generated by C++ code:
- // This file was generated from monsterdata_test.json
-
- byte[] data = null;
- File file = new File("monsterdata_test.mon");
- RandomAccessFile f = null;
- try {
- f = new RandomAccessFile(file, "r");
- data = new byte[(int)f.length()];
- f.readFully(data);
- f.close();
- } catch(java.io.IOException e) {
- System.out.println("FlatBuffers test: couldn't read file");
- return;
- }
-
- // Now test it:
-
- ByteBuffer bb = ByteBuffer.wrap(data);
- TestBuffer(bb);
-
- // Second, let's create a FlatBuffer from scratch in Java, and test it also.
- // We use an initial size of 1 to exercise the reallocation algorithm,
- // normally a size larger than the typical FlatBuffer you generate would be
- // better for performance.
- FlatBufferBuilder fbb = new FlatBufferBuilder(1);
-
- TestBuilderBasics(fbb, true);
- TestBuilderBasics(fbb, false);
-
- TestExtendedBuffer(fbb.dataBuffer().asReadOnlyBuffer());
-
- TestNamespaceNesting();
-
- TestNestedFlatBuffer();
-
- TestCreateByteVector();
-
- TestCreateUninitializedVector();
-
- TestByteBufferFactory();
-
- TestSizedInputStream();
-
- TestVectorOfUnions();
-
- TestFixedLengthArrays();
-
- TestFlexBuffers();
-
- TestVectorOfBytes();
-
- TestSharedStringPool();
-
- TestScalarOptional();
-
- TestPackUnpack(bb);
-
- System.out.println("FlatBuffers test: completed successfully");
- }
-
- static void TestEnums() {
- TestEq(Color.name(Color.Red), "Red");
- TestEq(Color.name(Color.Blue), "Blue");
- TestEq(Any.name(Any.NONE), "NONE");
- TestEq(Any.name(Any.Monster), "Monster");
- }
-
- static void TestBuffer(ByteBuffer bb) {
- TestEq(Monster.MonsterBufferHasIdentifier(bb), true);
-
- Monster monster = Monster.getRootAsMonster(bb);
-
- TestEq(monster.hp(), (short)80);
- TestEq(monster.mana(), (short)150); // default
-
- TestEq(monster.name(), "MyMonster");
- // monster.friendly() // can't access, deprecated
-
- Vec3 pos = monster.pos();
- TestEq(pos.x(), 1.0f);
- TestEq(pos.y(), 2.0f);
- TestEq(pos.z(), 3.0f);
- TestEq(pos.test1(), 3.0);
- // issue: int != byte
- TestEq(pos.test2(), (int) Color.Green);
- Test t = pos.test3();
- TestEq(t.a(), (short)5);
- TestEq(t.b(), (byte)6);
-
- TestEq(monster.testType(), (byte)Any.Monster);
- Monster monster2 = new Monster();
- TestEq(monster.test(monster2) != null, true);
- TestEq(monster2.name(), "Fred");
-
- TestEq(monster.inventoryLength(), 5);
- int invsum = 0;
- for (int i = 0; i < monster.inventoryLength(); i++)
- invsum += monster.inventory(i);
- TestEq(invsum, 10);
-
- // Method using a vector access object:
- ByteVector inventoryVector = monster.inventoryVector();
- TestEq(inventoryVector.length(), 5);
- invsum = 0;
- for (int i = 0; i < inventoryVector.length(); i++)
- invsum += inventoryVector.getAsUnsigned(i);
- TestEq(invsum, 10);
-
- // Alternative way of accessing a vector:
- ByteBuffer ibb = monster.inventoryAsByteBuffer();
- invsum = 0;
- while (ibb.position() < ibb.limit())
- invsum += ibb.get();
- TestEq(invsum, 10);
-
- Test test_0 = monster.test4(0);
- Test test_1 = monster.test4(1);
- TestEq(monster.test4Length(), 2);
- TestEq(test_0.a() + test_0.b() + test_1.a() + test_1.b(), 100);
-
- Test.Vector test4Vector = monster.test4Vector();
- test_0 = test4Vector.get(0);
- test_1 = test4Vector.get(1);
- TestEq(test4Vector.length(), 2);
- TestEq(test_0.a() + test_0.b() + test_1.a() + test_1.b(), 100);
-
- TestEq(monster.testarrayofstringLength(), 2);
- TestEq(monster.testarrayofstring(0),"test1");
- TestEq(monster.testarrayofstring(1),"test2");
-
- // Method using a vector access object:
- StringVector testarrayofstringVector = monster.testarrayofstringVector();
- TestEq(testarrayofstringVector.length(), 2);
- TestEq(testarrayofstringVector.get(0),"test1");
- TestEq(testarrayofstringVector.get(1),"test2");
-
- TestEq(monster.testbool(), true);
- }
-
- // this method checks additional fields not present in the binary buffer read from file
- // these new tests are performed on top of the regular tests
- static void TestExtendedBuffer(ByteBuffer bb) {
- TestBuffer(bb);
-
- Monster monster = Monster.getRootAsMonster(bb);
-
- TestEq(monster.testhashu32Fnv1(), Integer.MAX_VALUE + 1L);
- }
-
- static void TestNamespaceNesting() {
- // reference / manipulate these to verify compilation
- FlatBufferBuilder fbb = new FlatBufferBuilder(1);
-
- TableInNestedNS.startTableInNestedNS(fbb);
- TableInNestedNS.addFoo(fbb, 1234);
- int nestedTableOff = TableInNestedNS.endTableInNestedNS(fbb);
-
- TableInFirstNS.startTableInFirstNS(fbb);
- TableInFirstNS.addFooTable(fbb, nestedTableOff);
- int off = TableInFirstNS.endTableInFirstNS(fbb);
- }
-
- static void TestNestedFlatBuffer() {
- final String nestedMonsterName = "NestedMonsterName";
- final short nestedMonsterHp = 600;
- final short nestedMonsterMana = 1024;
-
- FlatBufferBuilder fbb1 = new FlatBufferBuilder(16);
- int str1 = fbb1.createString(nestedMonsterName);
- Monster.startMonster(fbb1);
- Monster.addName(fbb1, str1);
- Monster.addHp(fbb1, nestedMonsterHp);
- Monster.addMana(fbb1, nestedMonsterMana);
- int monster1 = Monster.endMonster(fbb1);
- Monster.finishMonsterBuffer(fbb1, monster1);
- byte[] fbb1Bytes = fbb1.sizedByteArray();
- fbb1 = null;
-
- FlatBufferBuilder fbb2 = new FlatBufferBuilder(16);
- int str2 = fbb2.createString("My Monster");
- int nestedBuffer = Monster.createTestnestedflatbufferVector(fbb2, fbb1Bytes);
- Monster.startMonster(fbb2);
- Monster.addName(fbb2, str2);
- Monster.addHp(fbb2, (short)50);
- Monster.addMana(fbb2, (short)32);
- Monster.addTestnestedflatbuffer(fbb2, nestedBuffer);
- int monster = Monster.endMonster(fbb2);
- Monster.finishMonsterBuffer(fbb2, monster);
-
- // Now test the data extracted from the nested buffer
- Monster mons = Monster.getRootAsMonster(fbb2.dataBuffer());
- Monster nestedMonster = mons.testnestedflatbufferAsMonster();
-
- TestEq(nestedMonsterMana, nestedMonster.mana());
- TestEq(nestedMonsterHp, nestedMonster.hp());
- TestEq(nestedMonsterName, nestedMonster.name());
- }
-
- static void TestCreateByteVector() {
- FlatBufferBuilder fbb = new FlatBufferBuilder(16);
- int str = fbb.createString("MyMonster");
- byte[] inventory = new byte[] { 0, 1, 2, 3, 4 };
- int vec = fbb.createByteVector(inventory);
- Monster.startMonster(fbb);
- Monster.addInventory(fbb, vec);
- Monster.addName(fbb, str);
- int monster1 = Monster.endMonster(fbb);
- Monster.finishMonsterBuffer(fbb, monster1);
- Monster monsterObject = Monster.getRootAsMonster(fbb.dataBuffer());
-
- TestEq(monsterObject.inventory(1), (int)inventory[1]);
- TestEq(monsterObject.inventoryLength(), inventory.length);
- ByteVector inventoryVector = monsterObject.inventoryVector();
- TestEq(inventoryVector.getAsUnsigned(1), (int)inventory[1]);
- TestEq(inventoryVector.length(), inventory.length);
-
- TestEq(ByteBuffer.wrap(inventory), monsterObject.inventoryAsByteBuffer());
- }
-
- static void TestCreateUninitializedVector() {
- FlatBufferBuilder fbb = new FlatBufferBuilder(16);
- int str = fbb.createString("MyMonster");
- byte[] inventory = new byte[] { 0, 1, 2, 3, 4 };
- ByteBuffer bb = fbb.createUnintializedVector(1, inventory.length, 1);
- for (byte i:inventory) {
- bb.put(i);
- }
- int vec = fbb.endVector();
- Monster.startMonster(fbb);
- Monster.addInventory(fbb, vec);
- Monster.addName(fbb, str);
- int monster1 = Monster.endMonster(fbb);
- Monster.finishMonsterBuffer(fbb, monster1);
- Monster monsterObject = Monster.getRootAsMonster(fbb.dataBuffer());
-
- TestEq(monsterObject.inventory(1), (int)inventory[1]);
- TestEq(monsterObject.inventoryLength(), inventory.length);
- ByteVector inventoryVector = monsterObject.inventoryVector();
- TestEq(inventoryVector.getAsUnsigned(1), (int)inventory[1]);
- TestEq(inventoryVector.length(), inventory.length);
- TestEq(ByteBuffer.wrap(inventory), monsterObject.inventoryAsByteBuffer());
- }
-
- static void TestByteBufferFactory() {
- final class MappedByteBufferFactory extends FlatBufferBuilder.ByteBufferFactory {
- @Override
- public ByteBuffer newByteBuffer(int capacity) {
- ByteBuffer bb;
- try {
- RandomAccessFile f = new RandomAccessFile("javatest.bin", "rw");
- bb = f.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, capacity).order(ByteOrder.LITTLE_ENDIAN);
- f.close();
- } catch(Throwable e) {
- System.out.println("FlatBuffers test: couldn't map ByteBuffer to a file");
- bb = null;
- }
- return bb;
- }
- }
-
- FlatBufferBuilder fbb = new FlatBufferBuilder(1, new MappedByteBufferFactory());
-
- TestBuilderBasics(fbb, false);
- }
-
- static void TestSizedInputStream() {
- // Test on default FlatBufferBuilder that uses HeapByteBuffer
- FlatBufferBuilder fbb = new FlatBufferBuilder(1);
-
- TestBuilderBasics(fbb, false);
-
- InputStream in = fbb.sizedInputStream();
- byte[] array = fbb.sizedByteArray();
- int count = 0;
- int currentVal = 0;
-
- while (currentVal != -1 && count < array.length) {
- try {
- currentVal = in.read();
- } catch(java.io.IOException e) {
- System.out.println("FlatBuffers test: couldn't read from InputStream");
- return;
- }
- TestEq((byte)currentVal, array[count]);
- count++;
- }
- TestEq(count, array.length);
- }
-
- static void TestBuilderBasics(FlatBufferBuilder fbb, boolean sizePrefix) {
- int[] names = {fbb.createString("Frodo"), fbb.createString("Barney"), fbb.createString("Wilma")};
- int[] off = new int[3];
- Monster.startMonster(fbb);
- Monster.addName(fbb, names[0]);
- off[0] = Monster.endMonster(fbb);
- Monster.startMonster(fbb);
- Monster.addName(fbb, names[1]);
- off[1] = Monster.endMonster(fbb);
- Monster.startMonster(fbb);
- Monster.addName(fbb, names[2]);
- off[2] = Monster.endMonster(fbb);
- int sortMons = fbb.createSortedVectorOfTables(new Monster(), off);
-
- // We set up the same values as monsterdata.json:
-
- int str = fbb.createString("MyMonster");
-
- int inv = Monster.createInventoryVector(fbb, new byte[] { 0, 1, 2, 3, 4 });
-
- int fred = fbb.createString("Fred");
- Monster.startMonster(fbb);
- Monster.addName(fbb, fred);
- int mon2 = Monster.endMonster(fbb);
-
- Monster.startTest4Vector(fbb, 2);
- Test.createTest(fbb, (short)10, (byte)20);
- Test.createTest(fbb, (short)30, (byte)40);
- int test4 = fbb.endVector();
-
- int testArrayOfString = Monster.createTestarrayofstringVector(fbb, new int[] {
- fbb.createString("test1"),
- fbb.createString("test2")
- });
-
- Monster.startMonster(fbb);
- Monster.addPos(fbb, Vec3.createVec3(fbb, 1.0f, 2.0f, 3.0f, 3.0,
- Color.Green, (short)5, (byte)6));
- Monster.addHp(fbb, (short)80);
- Monster.addName(fbb, str);
- Monster.addInventory(fbb, inv);
- Monster.addTestType(fbb, (byte)Any.Monster);
- Monster.addTest(fbb, mon2);
- Monster.addTest4(fbb, test4);
- Monster.addTestarrayofstring(fbb, testArrayOfString);
- Monster.addTestbool(fbb, true);
- Monster.addTesthashu32Fnv1(fbb, Integer.MAX_VALUE + 1L);
- Monster.addTestarrayoftables(fbb, sortMons);
- int mon = Monster.endMonster(fbb);
-
- if (sizePrefix) {
- Monster.finishSizePrefixedMonsterBuffer(fbb, mon);
- } else {
- Monster.finishMonsterBuffer(fbb, mon);
- }
-
- // Write the result to a file for debugging purposes:
- // Note that the binaries are not necessarily identical, since the JSON
- // parser may serialize in a slightly different order than the above
- // Java code. They are functionally equivalent though.
-
- try {
- String filename = "monsterdata_java_wire" + (sizePrefix ? "_sp" : "") + ".mon";
- FileChannel fc = new FileOutputStream(filename).getChannel();
- fc.write(fbb.dataBuffer().duplicate());
- fc.close();
- } catch(java.io.IOException e) {
- System.out.println("FlatBuffers test: couldn't write file");
- return;
- }
-
- // Test it:
- ByteBuffer dataBuffer = fbb.dataBuffer();
- if (sizePrefix) {
- TestEq(ByteBufferUtil.getSizePrefix(dataBuffer) + SIZE_PREFIX_LENGTH,
- dataBuffer.remaining());
- dataBuffer = ByteBufferUtil.removeSizePrefix(dataBuffer);
- }
- TestExtendedBuffer(dataBuffer);
-
- // Make sure it also works with read only ByteBuffers. This is slower,
- // since creating strings incurs an additional copy
- // (see Table.__string).
- TestExtendedBuffer(dataBuffer.asReadOnlyBuffer());
-
- TestEnums();
-
- //Attempt to mutate Monster fields and check whether the buffer has been mutated properly
- // revert to original values after testing
- Monster monster = Monster.getRootAsMonster(dataBuffer);
-
- // mana is optional and does not exist in the buffer so the mutation should fail
- // the mana field should retain its default value
- TestEq(monster.mutateMana((short)10), false);
- TestEq(monster.mana(), (short)150);
-
- // Accessing a vector of sorted by the key tables
- TestEq(monster.testarrayoftables(0).name(), "Barney");
- TestEq(monster.testarrayoftables(1).name(), "Frodo");
- TestEq(monster.testarrayoftables(2).name(), "Wilma");
- Monster.Vector testarrayoftablesVector = monster.testarrayoftablesVector();
- TestEq(testarrayoftablesVector.get(0).name(), "Barney");
- TestEq(testarrayoftablesVector.get(1).name(), "Frodo");
- TestEq(testarrayoftablesVector.get(2).name(), "Wilma");
-
- // Example of searching for a table by the key
- TestEq(monster.testarrayoftablesByKey("Frodo").name(), "Frodo");
- TestEq(monster.testarrayoftablesByKey("Barney").name(), "Barney");
- TestEq(monster.testarrayoftablesByKey("Wilma").name(), "Wilma");
- TestEq(testarrayoftablesVector.getByKey("Frodo").name(), "Frodo");
- TestEq(testarrayoftablesVector.getByKey("Barney").name(), "Barney");
- TestEq(testarrayoftablesVector.getByKey("Wilma").name(), "Wilma");
-
- // testType is an existing field and mutating it should succeed
- TestEq(monster.testType(), (byte)Any.Monster);
-
- //mutate the inventory vector
- TestEq(monster.mutateInventory(0, 1), true);
- TestEq(monster.mutateInventory(1, 2), true);
- TestEq(monster.mutateInventory(2, 3), true);
- TestEq(monster.mutateInventory(3, 4), true);
- TestEq(monster.mutateInventory(4, 5), true);
-
- for (int i = 0; i < monster.inventoryLength(); i++) {
- TestEq(monster.inventory(i), i + 1);
- }
- ByteVector inventoryVector = monster.inventoryVector();
- for (int i = 0; i < inventoryVector.length(); i++) {
- TestEq((int)inventoryVector.get(i), i + 1);
- }
-
- //reverse mutation
- TestEq(monster.mutateInventory(0, 0), true);
- TestEq(monster.mutateInventory(1, 1), true);
- TestEq(monster.mutateInventory(2, 2), true);
- TestEq(monster.mutateInventory(3, 3), true);
- TestEq(monster.mutateInventory(4, 4), true);
-
- // get a struct field and edit one of its fields
- Vec3 pos = monster.pos();
- TestEq(pos.x(), 1.0f);
- pos.mutateX(55.0f);
- TestEq(pos.x(), 55.0f);
- pos.mutateX(1.0f);
- TestEq(pos.x(), 1.0f);
- }
-
- static void TestVectorOfUnions() {
- final FlatBufferBuilder fbb = new FlatBufferBuilder();
-
- final int swordAttackDamage = 1;
-
- final int[] characterVector = new int[] {
- Attacker.createAttacker(fbb, swordAttackDamage),
- };
-
- final byte[] characterTypeVector = new byte[]{
- Character.MuLan,
- };
-
- Movie.finishMovieBuffer(
- fbb,
- Movie.createMovie(
- fbb,
- (byte)0,
- (byte)0,
- Movie.createCharactersTypeVector(fbb, characterTypeVector),
- Movie.createCharactersVector(fbb, characterVector)
- )
- );
-
- final Movie movie = Movie.getRootAsMovie(fbb.dataBuffer());
- ByteVector charactersTypeByteVector = movie.charactersTypeVector();
- UnionVector charactersVector = movie.charactersVector();
-
- TestEq(movie.charactersTypeLength(), characterTypeVector.length);
- TestEq(charactersTypeByteVector.length(), characterTypeVector.length);
- TestEq(movie.charactersLength(), characterVector.length);
- TestEq(charactersVector.length(), characterVector.length);
-
- TestEq(movie.charactersType(0), characterTypeVector[0]);
- TestEq(charactersTypeByteVector.get(0), characterTypeVector[0]);
-
- TestEq(((Attacker)movie.characters(new Attacker(), 0)).swordAttackDamage(), swordAttackDamage);
- }
-
- static void TestFixedLengthArrays() {
- FlatBufferBuilder builder = new FlatBufferBuilder(0);
-
- float a;
- int[] b = new int[15];
- byte c;
- int[][] d_a = new int[2][2];
- byte[] d_b = new byte[2];
- byte[][] d_c = new byte[2][2];
- long[][] d_d = new long[2][2];
- int e;
- long[] f = new long[2];
-
- a = 0.5f;
- for (int i = 0; i < 15; i++) b[i] = i;
- c = 1;
- d_a[0][0] = 1;
- d_a[0][1] = 2;
- d_a[1][0] = 3;
- d_a[1][1] = 4;
- d_b[0] = TestEnum.B;
- d_b[1] = TestEnum.C;
- d_c[0][0] = TestEnum.A;
- d_c[0][1] = TestEnum.B;
- d_c[1][0] = TestEnum.C;
- d_c[1][1] = TestEnum.B;
- d_d[0][0] = -1;
- d_d[0][1] = 1;
- d_d[1][0] = -2;
- d_d[1][1] = 2;
- e = 2;
- f[0] = -1;
- f[1] = 1;
-
- int arrayOffset = ArrayStruct.createArrayStruct(builder,
- a, b, c, d_a, d_b, d_c, d_d, e, f);
-
- // Create a table with the ArrayStruct.
- ArrayTable.startArrayTable(builder);
- ArrayTable.addA(builder, arrayOffset);
- int tableOffset = ArrayTable.endArrayTable(builder);
-
- ArrayTable.finishArrayTableBuffer(builder, tableOffset);
-
- ArrayTable table = ArrayTable.getRootAsArrayTable(builder.dataBuffer());
- NestedStruct nested = new NestedStruct();
-
- TestEq(table.a().a(), 0.5f);
- for (int i = 0; i < 15; i++) TestEq(table.a().b(i), i);
- TestEq(table.a().c(), (byte)1);
- TestEq(table.a().d(nested, 0).a(0), 1);
- TestEq(table.a().d(nested, 0).a(1), 2);
- TestEq(table.a().d(nested, 1).a(0), 3);
- TestEq(table.a().d(nested, 1).a(1), 4);
- TestEq(table.a().d(nested, 0).b(), TestEnum.B);
- TestEq(table.a().d(nested, 1).b(), TestEnum.C);
- TestEq(table.a().d(nested, 0).c(0), TestEnum.A);
- TestEq(table.a().d(nested, 0).c(1), TestEnum.B);
- TestEq(table.a().d(nested, 1).c(0), TestEnum.C);
- TestEq(table.a().d(nested, 1).c(1), TestEnum.B);
- TestEq(table.a().d(nested, 0).d(0), (long)-1);
- TestEq(table.a().d(nested, 0).d(1), (long)1);
- TestEq(table.a().d(nested, 1).d(0), (long)-2);
- TestEq(table.a().d(nested, 1).d(1), (long)2);
- TestEq(table.a().e(), 2);
- TestEq(table.a().f(0), (long)-1);
- TestEq(table.a().f(1), (long)1);
- }
-
- public static void testFlexBuffersTest() {
- FlexBuffersBuilder builder = new FlexBuffersBuilder(ByteBuffer.allocate(512),
- FlexBuffersBuilder.BUILDER_FLAG_SHARE_KEYS_AND_STRINGS);
- testFlexBuffersTest(builder);
- int bufferLimit1 = ((ArrayReadWriteBuf) builder.getBuffer()).limit();
-
- // Repeat after clearing the builder to ensure the builder is reusable
- builder.clear();
- testFlexBuffersTest(builder);
- int bufferLimit2 = ((ArrayReadWriteBuf) builder.getBuffer()).limit();
- TestEq(bufferLimit1, bufferLimit2);
- }
-
- public static void testFlexBuffersTest(FlexBuffersBuilder builder) {
- // Write the equivalent of:
- // { vec: [ -100, "Fred", 4.0, false ], bar: [ 1, 2, 3 ], bar3: [ 1, 2, 3 ],
- // foo: 100, bool: true, mymap: { foo: "Fred" } }
- // It's possible to do this without std::function support as well.
- int map1 = builder.startMap();
-
- int vec1 = builder.startVector();
- builder.putInt(-100);
- builder.putString("Fred");
- builder.putBlob(new byte[]{(byte) 77});
- builder.putBoolean(false);
- builder.putInt(Long.MAX_VALUE);
-
- int map2 = builder.startMap();
- builder.putInt("test", 200);
- builder.endMap(null, map2);
-
- builder.putFloat(150.9);
- builder.putFloat(150.9999998);
- builder.endVector("vec", vec1, false, false);
-
- vec1 = builder.startVector();
- builder.putInt(1);
- builder.putInt(2);
- builder.putInt(3);
- builder.endVector("bar", vec1, true, false);
-
- vec1 = builder.startVector();
- builder.putBoolean(true);
- builder.putBoolean(false);
- builder.putBoolean(true);
- builder.putBoolean(false);
- builder.endVector("bools", vec1, true, false);
-
- builder.putBoolean("bool", true);
- builder.putFloat("foo", 100);
-
- map2 = builder.startMap();
- builder.putString("bar", "Fred"); // Testing key and string reuse.
- builder.putInt("int", -120);
- builder.putFloat("float", -123.0f);
- builder.putBlob("blob", new byte[]{ 65, 67 });
- builder.endMap("mymap", map2);
-
- builder.endMap(null, map1);
- builder.finish();
-
- FlexBuffers.Map m = FlexBuffers.getRoot(builder.getBuffer()).asMap();
-
- TestEq(m.size(), 6);
-
- // test empty (an null)
- TestEq(m.get("no_key").asString(), ""); // empty if fail
- TestEq(m.get("no_key").asMap(), FlexBuffers.Map.empty()); // empty if fail
- TestEq(m.get("no_key").asKey(), FlexBuffers.Key.empty()); // empty if fail
- TestEq(m.get("no_key").asVector(), FlexBuffers.Vector.empty()); // empty if fail
- TestEq(m.get("no_key").asBlob(), FlexBuffers.Blob.empty()); // empty if fail
- assert(m.get("no_key").asVector().isEmpty()); // empty if fail
-
- // testing "vec" field
- FlexBuffers.Vector vec = m.get("vec").asVector();
- TestEq(vec.size(), 8);
- TestEq(vec.get(0).asLong(), (long) -100);
- TestEq(vec.get(1).asString(), "Fred");
- TestEq(vec.get(2).isBlob(), true);
- TestEq(vec.get(2).asBlob().size(), 1);
- TestEq(vec.get(2).asBlob().data().get(0), (byte) 77);
- TestEq(vec.get(3).isBoolean(), true); // Check if type is a bool
- TestEq(vec.get(3).asBoolean(), false); // Check if value is false
- TestEq(vec.get(4).asLong(), Long.MAX_VALUE);
- TestEq(vec.get(5).isMap(), true);
- TestEq(vec.get(5).asMap().get("test").asInt(), 200);
- TestEq(Float.compare((float)vec.get(6).asFloat(), 150.9f), 0);
- TestEq(Double.compare(vec.get(7).asFloat(), 150.9999998), 0);
- TestEq((long)0, (long)vec.get(1).asLong()); //conversion fail returns 0 as C++
-
- // bar vector
- FlexBuffers.Vector tvec = m.get("bar").asVector();
- TestEq(tvec.size(), 3);
- TestEq(tvec.get(0).asInt(), 1);
- TestEq(tvec.get(1).asInt(), 2);
- TestEq(tvec.get(2).asInt(), 3);
- TestEq(((FlexBuffers.TypedVector) tvec).getElemType(), FlexBuffers.FBT_INT);
-
- // bools vector
- FlexBuffers.Vector bvec = m.get("bools").asVector();
- TestEq(bvec.size(), 4);
- TestEq(bvec.get(0).asBoolean(), true);
- TestEq(bvec.get(1).asBoolean(), false);
- TestEq(bvec.get(2).asBoolean(), true);
- TestEq(bvec.get(3).asBoolean(), false);
- TestEq(((FlexBuffers.TypedVector) bvec).getElemType(), FlexBuffers.FBT_BOOL);
-
-
- TestEq((float)m.get("foo").asFloat(), (float) 100);
- TestEq(m.get("unknown").isNull(), true);
-
- // mymap vector
- FlexBuffers.Map mymap = m.get("mymap").asMap();
- TestEq(mymap.keys().get(0), m.keys().get(0)); // These should be equal by pointer equality, since key and value are shared.
- TestEq(mymap.keys().get(0).toString(), "bar");
- TestEq(mymap.values().get(0).asString(), vec.get(1).asString());
- TestEq(mymap.get("int").asInt(), -120);
- TestEq((float)mymap.get("float").asFloat(), -123.0f);
- TestEq(Arrays.equals(mymap.get("blob").asBlob().getBytes(), new byte[]{ 65, 67 }), true);
- TestEq(mymap.get("blob").asBlob().toString(), "AC");
- TestEq(mymap.get("blob").toString(), "\"AC\"");
- }
-
- public static void testFlexBufferVectorStrings() {
- FlexBuffersBuilder builder = new FlexBuffersBuilder(ByteBuffer.allocate(10000000));
-
- int size = 3000;
- StringBuilder sb = new StringBuilder();
- for (int i=0; i< size; i++) {
- sb.append("a");
- }
-
- String text = sb.toString();
- TestEq(text.length(), size);
-
- int pos = builder.startVector();
-
- for (int i=0; i<size; i++) {
- builder.putString(text);
- }
-
- try {
- builder.endVector(null, pos, true, false);
- // this should raise an exception as
- // typed vector of string was deprecated
- assert false;
- } catch(FlexBufferException fb) {
- // no op
- }
- // we finish the vector again as non-typed
- builder.endVector(null, pos, false, false);
-
- ByteBuffer b = builder.finish();
- Vector v = FlexBuffers.getRoot(b).asVector();
-
- TestEq(v.size(), size);
- for (int i=0; i<size; i++) {
- TestEq(v.get(i).asString().length(), size);
- TestEq(v.get(i).asString(), text);
- }
- }
-
- public static void testDeprecatedTypedVectorString() {
- // tests whether we are able to support reading deprecated typed vector string
- // data is equivalent to [ "abc", "abc", "abc", "abc"]
- byte[] data = new byte[] {0x03, 0x61, 0x62, 0x63, 0x00, 0x03, 0x61, 0x62, 0x63, 0x00,
- 0x03, 0x61, 0x62, 0x63, 0x00, 0x03, 0x61, 0x62, 0x63, 0x00, 0x04, 0x14, 0x10,
- 0x0c, 0x08, 0x04, 0x3c, 0x01};
- Reference ref = FlexBuffers.getRoot(ByteBuffer.wrap(data));
- TestEq(ref.getType(), FlexBuffers.FBT_VECTOR_STRING_DEPRECATED);
- TestEq(ref.isTypedVector(), true);
- Vector vec = ref.asVector();
- for (int i=0; i< vec.size(); i++) {
- TestEq("abc", vec.get(i).asString());
- }
- }
-
- public static void testSingleElementBoolean() {
- FlexBuffersBuilder builder = new FlexBuffersBuilder(ByteBuffer.allocate(100));
- builder.putBoolean(true);
- ByteBuffer b = builder.finish();
- assert(FlexBuffers.getRoot(b).asBoolean());
- }
-
- public static void testSingleElementByte() {
- FlexBuffersBuilder builder = new FlexBuffersBuilder();
- builder.putInt(10);
- ByteBuffer b = builder.finish();
- TestEq(10, FlexBuffers.getRoot(b).asInt());
- }
-
- public static void testSingleElementShort() {
- FlexBuffersBuilder builder = new FlexBuffersBuilder();
- builder.putInt(Short.MAX_VALUE);
- ByteBuffer b = builder.finish();
- TestEq(Short.MAX_VALUE, (short)FlexBuffers.getRoot(b).asInt());
- }
-
- public static void testSingleElementInt() {
- FlexBuffersBuilder builder = new FlexBuffersBuilder();
- builder.putInt(Integer.MIN_VALUE);
- ByteBuffer b = builder.finish();
- TestEq(Integer.MIN_VALUE, FlexBuffers.getRoot(b).asInt());
- }
-
- public static void testSingleElementLong() {
- FlexBuffersBuilder builder = new FlexBuffersBuilder();
- builder.putInt(Long.MAX_VALUE);
- ByteBuffer b = builder.finish();
- TestEq(Long.MAX_VALUE, FlexBuffers.getRoot(b).asLong());
- }
-
- public static void testSingleElementFloat() {
- FlexBuffersBuilder builder = new FlexBuffersBuilder();
- builder.putFloat(Float.MAX_VALUE);
- ByteBuffer b = builder.finish();
- TestEq(Float.compare(Float.MAX_VALUE, (float) FlexBuffers.getRoot(b).asFloat()), 0);
- }
-
- public static void testSingleElementDouble() {
- FlexBuffersBuilder builder = new FlexBuffersBuilder();
- builder.putFloat(Double.MAX_VALUE);
- ByteBuffer b = builder.finish();
- TestEq(Double.compare(Double.MAX_VALUE, FlexBuffers.getRoot(b).asFloat()), 0);
- }
-
- public static void testSingleElementBigString() {
- FlexBuffersBuilder builder = new FlexBuffersBuilder(ByteBuffer.allocate(10000));
- StringBuilder sb = new StringBuilder();
-
- for (int i=0; i< 3000; i++) {
- sb.append("a");
- }
-
- builder.putString(sb.toString());
- ByteBuffer b = builder.finish();
-
- FlexBuffers.Reference r = FlexBuffers.getRoot(b);
-
- TestEq(FlexBuffers.FBT_STRING, r.getType());
- TestEq(sb.toString(), r.asString());
- }
-
- public static void testSingleElementSmallString() {
- FlexBuffersBuilder builder = new FlexBuffersBuilder(ByteBuffer.allocate(10000));
-
- builder.putString("aa");
- ByteBuffer b = builder.finish();
- FlexBuffers.Reference r = FlexBuffers.getRoot(b);
-
- TestEq(FlexBuffers.FBT_STRING, r.getType());
- TestEq("aa", r.asString());
- }
-
- public static void testSingleElementBlob() {
- FlexBuffersBuilder builder = new FlexBuffersBuilder();
- builder.putBlob(new byte[]{5, 124, 118, -1});
- ByteBuffer b = builder.finish();
- FlexBuffers.Reference r = FlexBuffers.getRoot(b);
- byte[] result = r.asBlob().getBytes();
- TestEq((byte)5, result[0]);
- TestEq((byte)124, result[1]);
- TestEq((byte)118, result[2]);
- TestEq((byte)-1, result[3]);
- }
-
- public static void testSingleElementLongBlob() {
-
- // verifies blobs of up to 2^16 in length
- for (int i = 2; i <= 1<<16; i = i<<1) {
- byte[] input = new byte[i-1];
- for (int index = 0; index < input.length; index++) {
- input[index] = (byte)(index % 64);
- }
-
- FlexBuffersBuilder builder = new FlexBuffersBuilder();
- builder.putBlob(input);
- ByteBuffer b = builder.finish();
- FlexBuffers.Reference r = FlexBuffers.getRoot(b);
- byte[] result = r.asBlob().getBytes();
-
- for (int index = 0; index < input.length; index++) {
- TestEq((byte)(index % 64), result[index]);
- }
- }
- }
-
- public static void testSingleElementUByte() {
- FlexBuffersBuilder builder = new FlexBuffersBuilder();
- builder.putUInt(0xFF);
- ByteBuffer b = builder.finish();
- FlexBuffers.Reference r = FlexBuffers.getRoot(b);
- TestEq(255, (int)r.asUInt());
- }
-
- public static void testSingleElementUShort() {
- FlexBuffersBuilder builder = new FlexBuffersBuilder();
- builder.putUInt(0xFFFF);
- ByteBuffer b = builder.finish();
- FlexBuffers.Reference r = FlexBuffers.getRoot(b);
- TestEq(65535, (int)r.asUInt());
- }
-
- public static void testSingleElementUInt() {
- FlexBuffersBuilder builder = new FlexBuffersBuilder();
- builder.putUInt(0xFFFF_FFFFL);
- ByteBuffer b = builder.finish();
- FlexBuffers.Reference r = FlexBuffers.getRoot(b);
- TestEq(4294967295L, r.asUInt());
- }
-
- public static void testSingleFixedTypeVector() {
-
- int[] ints = new int[]{5, 124, 118, -1};
- float[] floats = new float[]{5.5f, 124.124f, 118.118f, -1.1f};
- String[] strings = new String[]{"This", "is", "a", "typed", "array"};
- boolean[] booleans = new boolean[]{false, true, true, false};
-
-
- FlexBuffersBuilder builder = new FlexBuffersBuilder(ByteBuffer.allocate(512),
- FlexBuffersBuilder.BUILDER_FLAG_NONE);
-
- int mapPos = builder.startMap();
-
- int vecPos = builder.startVector();
- for (final int i : ints) {
- builder.putInt(i);
- }
- builder.endVector("ints", vecPos, true, false);
-
- vecPos = builder.startVector();
- for (final float i : floats) {
- builder.putFloat(i);
- }
- builder.endVector("floats", vecPos, true, false);
-
- vecPos = builder.startVector();
- for (final boolean i : booleans) {
- builder.putBoolean(i);
- }
- builder.endVector("booleans", vecPos, true, false);
-
- builder.endMap(null, mapPos);
-
-
- ByteBuffer b = builder.finish();
- FlexBuffers.Reference r = FlexBuffers.getRoot(b);
- assert(r.asMap().get("ints").isTypedVector());
- assert(r.asMap().get("floats").isTypedVector());
- assert(r.asMap().get("booleans").isTypedVector());
- }
-
- public static void testSingleElementVector() {
- FlexBuffersBuilder b = new FlexBuffersBuilder();
-
- int vecPos = b.startVector();
- b.putInt(99);
- b.putString("wow");
- int vecpos2 = b.startVector();
- b.putInt(99);
- b.putString("wow");
- b.endVector(null, vecpos2, false, false);
- b.endVector(null, vecPos, false, false);
- b.finish();
-
- FlexBuffers.Reference r = FlexBuffers.getRoot(b.getBuffer());
- TestEq(FlexBuffers.FBT_VECTOR, r.getType());
- FlexBuffers.Vector vec = FlexBuffers.getRoot(b.getBuffer()).asVector();
- TestEq(3, vec.size());
- TestEq(99, vec.get(0).asInt());
- TestEq("wow", vec.get(1).asString());
- TestEq("[ 99, \"wow\" ]", vec.get(2).toString());
- TestEq("[ 99, \"wow\", [ 99, \"wow\" ] ]", FlexBuffers.getRoot(b.getBuffer()).toString());
- }
-
- public static void testSingleElementMap() {
- FlexBuffersBuilder b = new FlexBuffersBuilder();
-
- int mapPost = b.startMap();
- b.putInt("myInt", 0x7fffffbbbfffffffL);
- b.putString("myString", "wow");
- b.putString("myString2", "incredible");
- int start = b.startVector();
- b.putInt(99);
- b.putString("wow");
- b.endVector("myVec", start, false, false);
-
- b.putFloat("double", 0x1.ffffbbbffffffP+1023);
- b.endMap(null, mapPost);
- b.finish();
-
- FlexBuffers.Reference r = FlexBuffers.getRoot(b.getBuffer());
- TestEq(FlexBuffers.FBT_MAP, r.getType());
- FlexBuffers.Map map = FlexBuffers.getRoot(b.getBuffer()).asMap();
- TestEq(5, map.size());
- TestEq(0x7fffffbbbfffffffL, map.get("myInt").asLong());
- TestEq("wow", map.get("myString").asString());
- TestEq("incredible", map.get("myString2").asString());
- TestEq(99, map.get("myVec").asVector().get(0).asInt());
- TestEq("wow", map.get("myVec").asVector().get(1).asString());
- TestEq(Double.compare(0x1.ffffbbbffffffP+1023, map.get("double").asFloat()), 0);
- TestEq("{ \"double\" : 1.7976894783391937E308, \"myInt\" : 9223371743723257855, \"myString\" : \"wow\", \"myString2\" : \"incredible\", \"myVec\" : [ 99, \"wow\" ] }",
- FlexBuffers.getRoot(b.getBuffer()).toString());
- }
-
- public static void testFlexBuferEmpty() {
- FlexBuffers.Blob blob = FlexBuffers.Blob.empty();
- FlexBuffers.Map ary = FlexBuffers.Map.empty();
- FlexBuffers.Vector map = FlexBuffers.Vector.empty();
- FlexBuffers.TypedVector typedAry = FlexBuffers.TypedVector.empty();
- TestEq(blob.size(), 0);
- TestEq(map.size(), 0);
- TestEq(ary.size(), 0);
- TestEq(typedAry.size(), 0);
- }
-
- public static void testHashMapToMap() {
- int entriesCount = 12;
-
- HashMap<String, String> source = new HashMap<>();
- for (int i = 0; i < entriesCount; i++) {
- source.put("foo_param_" + i, "foo_value_" + i);
- }
-
- FlexBuffersBuilder builder = new FlexBuffersBuilder(1000);
- int mapStart = builder.startMap();
- for (Map.Entry<String, String> entry : source.entrySet()) {
- builder.putString(entry.getKey(), entry.getValue());
- }
- builder.endMap(null, mapStart);
- ByteBuffer bb = builder.finish();
- bb.rewind();
-
- FlexBuffers.Reference rootReference = FlexBuffers.getRoot(bb);
-
- TestEq(rootReference.isMap(), true);
-
- FlexBuffers.Map flexMap = rootReference.asMap();
-
- FlexBuffers.KeyVector keys = flexMap.keys();
- FlexBuffers.Vector values = flexMap.values();
-
- TestEq(entriesCount, keys.size());
- TestEq(entriesCount, values.size());
-
- HashMap<String, String> result = new HashMap<>();
- for (int i = 0; i < keys.size(); i++) {
- result.put(keys.get(i).toString(), values.get(i).asString());
- }
-
- TestEq(source, result);
- }
-
- public static void testBuilderGrowth() {
- FlexBuffersBuilder builder = new FlexBuffersBuilder();
- String someString = "This is a small string";
- builder.putString(someString);
- ByteBuffer b = builder.finish();
- TestEq(someString, FlexBuffers.getRoot(b).asString());
-
- FlexBuffersBuilder failBuilder = new FlexBuffersBuilder(ByteBuffer.allocate(1));
- failBuilder.putString(someString);
- }
-
- public static void testFlexBuffersUtf8Map() {
- FlexBuffersBuilder builder = new FlexBuffersBuilder(ByteBuffer.allocate(512),
- FlexBuffersBuilder.BUILDER_FLAG_SHARE_KEYS_AND_STRINGS);
-
- String key0 = "đ¨ face1";
- String key1 = "đŠ face2";
- String key2 = "đ¨ face3";
- String key3 = "trademark ®";
- String key4 = "€ euro";
- String utf8keys[] = { "đ¨ face1", "đŠ face2", "đ¨ face3", "trademark ®", "€ euro"};
-
- int map = builder.startMap();
-
- for (int i=0; i< utf8keys.length; i++) {
- builder.putString(utf8keys[i], utf8keys[i]); // Testing key and string reuse.
- }
- builder.endMap(null, map);
- builder.finish();
-
- FlexBuffers.Map m = FlexBuffers.getRoot(builder.getBuffer()).asMap();
-
- TestEq(m.size(), 5);
-
- KeyVector kv = m.keys();
- for (int i=0; i< utf8keys.length; i++) {
- TestEq(kv.get(i).toString(), m.get(i).asString());
- }
-
- TestEq(m.get(key0).asString(), utf8keys[0]);
- TestEq(m.get(key1).asString(), utf8keys[1]);
- TestEq(m.get(key2).asString(), utf8keys[2]);
- TestEq(m.get(key3).asString(), utf8keys[3]);
- TestEq(m.get(key4).asString(), utf8keys[4]);
- }
-
- public static void testFlexBuffersMapLookup() {
- FlexBuffersBuilder builder = new FlexBuffersBuilder(ByteBuffer.allocate(512),
- FlexBuffersBuilder.BUILDER_FLAG_SHARE_KEYS_AND_STRINGS);
-
- String key0 = "123";
- String key1 = "1234";
- String key2 = "12345";
- String[] keys = new String[]{key0, key1, key2};
-
- int map = builder.startMap();
-
- for (int i=0; i< keys.length; i++) {
- builder.putString(keys[i], keys[i]); // Testing key and string reuse.
- }
- builder.endMap(null, map);
- builder.finish();
-
- FlexBuffers.Map m = FlexBuffers.getRoot(builder.getBuffer()).asMap();
- for (int i=0; i< keys.length; i++) {
- TestEq(m.get(keys[i]).asString(), keys[i]);
- TestEq(m.get(keys[i].getBytes(StandardCharsets.UTF_8)).asString(), keys[i]);
- }
- }
-
- public static void TestFlexBuffers() {
- testSingleElementByte();
- testSingleElementShort();
- testSingleElementInt();
- testSingleElementLong();
- testSingleElementFloat();
- testSingleElementDouble();
- testSingleElementSmallString();
- testSingleElementBigString();
- testSingleElementBlob();
- testSingleElementLongBlob();
- testSingleElementVector();
- testSingleFixedTypeVector();
- testSingleElementUShort();
- testSingleElementUInt();
- testSingleElementUByte();
- testSingleElementMap();
- testFlexBuffersTest();
- testHashMapToMap();
- testFlexBuferEmpty();
- testFlexBufferVectorStrings();
- testDeprecatedTypedVectorString();
- testBuilderGrowth();
- testFlexBuffersUtf8Map();
- testFlexBuffersMapLookup();
- }
-
- static void TestVectorOfBytes() {
- FlatBufferBuilder fbb = new FlatBufferBuilder(16);
- int str = fbb.createString("ByteMonster");
- byte[] data = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
- int offset = Monster.createInventoryVector(fbb, data);
- Monster.startMonster(fbb);
- Monster.addName(fbb, str);
- Monster.addInventory(fbb, offset);
- int monster1 = Monster.endMonster(fbb);
- Monster.finishMonsterBuffer(fbb, monster1);
- Monster monsterObject = Monster.getRootAsMonster(fbb.dataBuffer());
-
- TestEq(monsterObject.inventoryLength(), data.length);
- TestEq(monsterObject.inventory(4), (int) data[4]);
- TestEq(ByteBuffer.wrap(data), monsterObject.inventoryAsByteBuffer());
-
- fbb.clear();
- ByteBuffer bb = ByteBuffer.wrap(data);
- offset = fbb.createByteVector(bb);
- str = fbb.createString("ByteMonster");
- Monster.startMonster(fbb);
- Monster.addName(fbb, str);
- Monster.addInventory(fbb, offset);
- monster1 = Monster.endMonster(fbb);
- Monster.finishMonsterBuffer(fbb, monster1);
- Monster monsterObject2 = Monster.getRootAsMonster(fbb.dataBuffer());
-
- TestEq(monsterObject2.inventoryLength(), data.length);
- for (int i = 0; i < data.length; i++) {
- TestEq(monsterObject2.inventory(i), (int) bb.get(i));
- }
-
- fbb.clear();
- offset = fbb.createByteVector(data, 3, 4);
- str = fbb.createString("ByteMonster");
- Monster.startMonster(fbb);
- Monster.addName(fbb, str);
- Monster.addInventory(fbb, offset);
- monster1 = Monster.endMonster(fbb);
- Monster.finishMonsterBuffer(fbb, monster1);
- Monster monsterObject3 = Monster.getRootAsMonster(fbb.dataBuffer());
-
- TestEq(monsterObject3.inventoryLength(), 4);
- TestEq(monsterObject3.inventory(0), (int) data[3]);
-
- fbb.clear();
- bb = ByteBuffer.wrap(data);
- offset = Monster.createInventoryVector(fbb, bb);
- str = fbb.createString("ByteMonster");
- Monster.startMonster(fbb);
- Monster.addName(fbb, str);
- Monster.addInventory(fbb, offset);
- monster1 = Monster.endMonster(fbb);
- Monster.finishMonsterBuffer(fbb, monster1);
- Monster monsterObject4 = Monster.getRootAsMonster(fbb.dataBuffer());
-
- TestEq(monsterObject4.inventoryLength(), data.length);
- TestEq(monsterObject4.inventory(8), (int) 8);
-
- fbb.clear();
- byte[] largeData = new byte[1024];
- offset = fbb.createByteVector(largeData);
- str = fbb.createString("ByteMonster");
- Monster.startMonster(fbb);
- Monster.addName(fbb, str);
- Monster.addInventory(fbb, offset);
- monster1 = Monster.endMonster(fbb);
- Monster.finishMonsterBuffer(fbb, monster1);
- Monster monsterObject5 = Monster.getRootAsMonster(fbb.dataBuffer());
-
- TestEq(monsterObject5.inventoryLength(), largeData.length);
- TestEq(monsterObject5.inventory(25), (int) largeData[25]);
-
- fbb.clear();
- bb = ByteBuffer.wrap(largeData);
- bb.position(512);
- ByteBuffer bb2 = bb.slice();
- TestEq(bb2.arrayOffset(), 512);
- offset = fbb.createByteVector(bb2);
- str = fbb.createString("ByteMonster");
- Monster.startMonster(fbb);
- Monster.addName(fbb, str);
- Monster.addInventory(fbb, offset);
- monster1 = Monster.endMonster(fbb);
- Monster.finishMonsterBuffer(fbb, monster1);
- Monster monsterObject6 = Monster.getRootAsMonster(fbb.dataBuffer());
-
- TestEq(monsterObject6.inventoryLength(), 512);
- TestEq(monsterObject6.inventory(0), (int) largeData[512]);
-
- fbb.clear();
- bb = ByteBuffer.wrap(largeData);
- bb.limit(256);
- offset = fbb.createByteVector(bb);
- str = fbb.createString("ByteMonster");
- Monster.startMonster(fbb);
- Monster.addName(fbb, str);
- Monster.addInventory(fbb, offset);
- monster1 = Monster.endMonster(fbb);
- Monster.finishMonsterBuffer(fbb, monster1);
- Monster monsterObject7 = Monster.getRootAsMonster(fbb.dataBuffer());
-
- TestEq(monsterObject7.inventoryLength(), 256);
-
- fbb.clear();
- bb = ByteBuffer.allocateDirect(2048);
- offset = fbb.createByteVector(bb);
- str = fbb.createString("ByteMonster");
- Monster.startMonster(fbb);
- Monster.addName(fbb, str);
- Monster.addInventory(fbb, offset);
- monster1 = Monster.endMonster(fbb);
- Monster.finishMonsterBuffer(fbb, monster1);
- Monster monsterObject8 = Monster.getRootAsMonster(fbb.dataBuffer());
-
- TestEq(monsterObject8.inventoryLength(), 2048);
- }
-
- static void TestSharedStringPool() {
- FlatBufferBuilder fb = new FlatBufferBuilder(1);
- String testString = "My string";
- int offset = fb.createSharedString(testString);
- for (int i=0; i< 10; i++) {
- TestEq(offset, fb.createSharedString(testString));
- }
- }
-
- static void TestScalarOptional() {
- FlatBufferBuilder fbb = new FlatBufferBuilder(1);
- ScalarStuff.startScalarStuff(fbb);
- int pos = ScalarStuff.endScalarStuff(fbb);
- fbb.finish(pos);
-
- ScalarStuff scalarStuff = ScalarStuff.getRootAsScalarStuff(fbb.dataBuffer());
- TestEq(scalarStuff.justI8(), (byte)0);
- TestEq(scalarStuff.maybeI8(), (byte)0);
- TestEq(scalarStuff.defaultI8(), (byte)42);
- TestEq(scalarStuff.justU8(), 0);
- TestEq(scalarStuff.maybeU8(), 0);
- TestEq(scalarStuff.defaultU8(), 42);
- TestEq(scalarStuff.justI16(), (short)0);
- TestEq(scalarStuff.maybeI16(), (short)0);
- TestEq(scalarStuff.defaultI16(), (short)42);
- TestEq(scalarStuff.justU16(), 0);
- TestEq(scalarStuff.maybeU16(), 0);
- TestEq(scalarStuff.defaultU16(), 42);
- TestEq(scalarStuff.justI32(), 0);
- TestEq(scalarStuff.maybeI32(), 0);
- TestEq(scalarStuff.defaultI32(), 42);
- TestEq(scalarStuff.justU32(), 0L);
- TestEq(scalarStuff.maybeU32(), 0L);
- TestEq(scalarStuff.defaultU32(), 42L);
- TestEq(scalarStuff.justI64(), 0L);
- TestEq(scalarStuff.maybeI64(), 0L);
- TestEq(scalarStuff.defaultI64(), 42L);
- TestEq(scalarStuff.justU64(), 0L);
- TestEq(scalarStuff.maybeU64(), 0L);
- TestEq(scalarStuff.defaultU64(), 42L);
- TestEq(scalarStuff.justF32(), 0.0f);
- TestEq(scalarStuff.maybeF32(), 0f);
- TestEq(scalarStuff.defaultF32(), 42.0f);
- TestEq(scalarStuff.justF64(), 0.0);
- TestEq(scalarStuff.maybeF64(), 0.0);
- TestEq(scalarStuff.defaultF64(), 42.0);
- TestEq(scalarStuff.justBool(), false);
- TestEq(scalarStuff.maybeBool(), false);
- TestEq(scalarStuff.defaultBool(), true);
- TestEq(scalarStuff.justEnum(), OptionalByte.None);
- TestEq(scalarStuff.maybeEnum(), OptionalByte.None);
- TestEq(scalarStuff.defaultEnum(), OptionalByte.One);
-
- TestEq(scalarStuff.hasMaybeI8(), false);
- TestEq(scalarStuff.hasMaybeI16(), false);
- TestEq(scalarStuff.hasMaybeI32(), false);
- TestEq(scalarStuff.hasMaybeI64(), false);
- TestEq(scalarStuff.hasMaybeU8(), false);
- TestEq(scalarStuff.hasMaybeU16(), false);
- TestEq(scalarStuff.hasMaybeU32(), false);
- TestEq(scalarStuff.hasMaybeU64(), false);
- TestEq(scalarStuff.hasMaybeF32(), false);
- TestEq(scalarStuff.hasMaybeF64(), false);
- TestEq(scalarStuff.hasMaybeBool(), false);
- TestEq(scalarStuff.hasMaybeEnum(), false);
-
- fbb.clear();
-
- ScalarStuff.startScalarStuff(fbb);
- ScalarStuff.addJustI8(fbb, (byte)5);
- ScalarStuff.addMaybeI8(fbb, (byte)5);
- ScalarStuff.addDefaultI8(fbb, (byte)5);
- ScalarStuff.addJustU8(fbb, 6);
- ScalarStuff.addMaybeU8(fbb, 6);
- ScalarStuff.addDefaultU8(fbb, 6);
- ScalarStuff.addJustI16(fbb, (short)7);
- ScalarStuff.addMaybeI16(fbb, (short)7);
- ScalarStuff.addDefaultI16(fbb, (short)7);
- ScalarStuff.addJustU16(fbb, 8);
- ScalarStuff.addMaybeU16(fbb, 8);
- ScalarStuff.addDefaultU16(fbb, 8);
- ScalarStuff.addJustI32(fbb, 9);
- ScalarStuff.addMaybeI32(fbb, 9);
- ScalarStuff.addDefaultI32(fbb, 9);
- ScalarStuff.addJustU32(fbb, (long)10);
- ScalarStuff.addMaybeU32(fbb, (long)10);
- ScalarStuff.addDefaultU32(fbb, (long)10);
- ScalarStuff.addJustI64(fbb, 11L);
- ScalarStuff.addMaybeI64(fbb, 11L);
- ScalarStuff.addDefaultI64(fbb, 11L);
- ScalarStuff.addJustU64(fbb, 12L);
- ScalarStuff.addMaybeU64(fbb, 12L);
- ScalarStuff.addDefaultU64(fbb, 12L);
- ScalarStuff.addJustF32(fbb, 13.0f);
- ScalarStuff.addMaybeF32(fbb, 13.0f);
- ScalarStuff.addDefaultF32(fbb, 13.0f);
- ScalarStuff.addJustF64(fbb, 14.0);
- ScalarStuff.addMaybeF64(fbb, 14.0);
- ScalarStuff.addDefaultF64(fbb, 14.0);
- ScalarStuff.addJustBool(fbb, true);
- ScalarStuff.addMaybeBool(fbb, true);
- ScalarStuff.addDefaultBool(fbb, true);
- ScalarStuff.addJustEnum(fbb, OptionalByte.Two);
- ScalarStuff.addMaybeEnum(fbb, OptionalByte.Two);
- ScalarStuff.addDefaultEnum(fbb, OptionalByte.Two);
-
- pos = ScalarStuff.endScalarStuff(fbb);
-
- fbb.finish(pos);
-
- scalarStuff = ScalarStuff.getRootAsScalarStuff(fbb.dataBuffer());
-
- TestEq(scalarStuff.justI8(), (byte)5);
- TestEq(scalarStuff.maybeI8(), (byte)5);
- TestEq(scalarStuff.defaultI8(), (byte)5);
- TestEq(scalarStuff.justU8(), 6);
- TestEq(scalarStuff.maybeU8(), 6);
- TestEq(scalarStuff.defaultU8(), 6);
- TestEq(scalarStuff.justI16(), (short)7);
- TestEq(scalarStuff.maybeI16(), (short)7);
- TestEq(scalarStuff.defaultI16(), (short)7);
- TestEq(scalarStuff.justU16(), 8);
- TestEq(scalarStuff.maybeU16(), 8);
- TestEq(scalarStuff.defaultU16(), 8);
- TestEq(scalarStuff.justI32(), 9);
- TestEq(scalarStuff.maybeI32(), 9);
- TestEq(scalarStuff.defaultI32(), 9);
- TestEq(scalarStuff.justU32(), 10L);
- TestEq(scalarStuff.maybeU32(), 10L);
- TestEq(scalarStuff.defaultU32(), 10L);
- TestEq(scalarStuff.justI64(), 11L);
- TestEq(scalarStuff.maybeI64(), 11L);
- TestEq(scalarStuff.defaultI64(), 11L);
- TestEq(scalarStuff.justU64(), 12L);
- TestEq(scalarStuff.maybeU64(), 12L);
- TestEq(scalarStuff.defaultU64(), 12L);
- TestEq(scalarStuff.justF32(), 13.0f);
- TestEq(scalarStuff.maybeF32(), 13.0f);
- TestEq(scalarStuff.defaultF32(), 13.0f);
- TestEq(scalarStuff.justF64(), 14.0);
- TestEq(scalarStuff.maybeF64(), 14.0);
- TestEq(scalarStuff.defaultF64(), 14.0);
- TestEq(scalarStuff.justBool(), true);
- TestEq(scalarStuff.maybeBool(), true);
- TestEq(scalarStuff.defaultBool(), true);
- TestEq(scalarStuff.justEnum(), OptionalByte.Two);
- TestEq(scalarStuff.maybeEnum(), OptionalByte.Two);
- TestEq(scalarStuff.defaultEnum(), OptionalByte.Two);
-
- TestEq(scalarStuff.hasMaybeI8(), true);
- TestEq(scalarStuff.hasMaybeI16(), true);
- TestEq(scalarStuff.hasMaybeI32(), true);
- TestEq(scalarStuff.hasMaybeI64(), true);
- TestEq(scalarStuff.hasMaybeU8(), true);
- TestEq(scalarStuff.hasMaybeU16(), true);
- TestEq(scalarStuff.hasMaybeU32(), true);
- TestEq(scalarStuff.hasMaybeU64(), true);
- TestEq(scalarStuff.hasMaybeF32(), true);
- TestEq(scalarStuff.hasMaybeF64(), true);
- TestEq(scalarStuff.hasMaybeBool(), true);
- TestEq(scalarStuff.hasMaybeEnum(), true);
- }
-
- static void TestObject(MonsterT monster) {
- TestEq(monster.getHp(), (short) 80);
- TestEq(monster.getMana(), (short) 150); // default
-
- TestEq(monster.getName(), "MyMonster");
- TestEq(monster.getColor(), Color.Blue);
- // monster.friendly() // can't access, deprecated
-
- Vec3T pos = monster.getPos();
- TestEq(pos.getX(), 1.0f);
- TestEq(pos.getY(), 2.0f);
- TestEq(pos.getZ(), 3.0f);
- TestEq(pos.getTest1(), 3.0);
- // issue: int != byte
- TestEq(pos.getTest2(), (int) Color.Green);
- TestT t = pos.getTest3();
- TestEq(t.getA(), (short) 5);
- TestEq(t.getB(), (byte) 6);
-
- TestEq(monster.getTest().getType(), (byte) Any.Monster);
- MonsterT monster2 = (MonsterT) monster.getTest().getValue();
- TestEq(monster2 != null, true);
- TestEq(monster2.getName(), "Fred");
-
- int[] inv = monster.getInventory();
- TestEq(inv.length, 5);
- int[] expInv = {0, 1, 2, 3, 4};
- for (int i = 0; i < inv.length; i++)
- TestEq(expInv[i], inv[i]);
-
- TestT[] test4 = monster.getTest4();
- TestT test_0 = test4[0];
- TestT test_1 = test4[1];
- TestEq(test4.length, 2);
- TestEq(test_0.getA(), (short) 10);
- TestEq(test_0.getB(), (byte) 20);
- TestEq(test_1.getA(), (short) 30);
- TestEq(test_1.getB(), (byte) 40);
-
- String[] testarrayofstring = monster.getTestarrayofstring();
- TestEq(testarrayofstring.length, 2);
- TestEq(testarrayofstring[0], "test1");
- TestEq(testarrayofstring[1], "test2");
-
- MonsterT[] testarrayoftables = monster.getTestarrayoftables();
- TestEq(testarrayoftables.length, 0);
-
- MonsterT enemy = monster.getEnemy();
- TestEq(enemy != null, true);
- TestEq(enemy.getName(), "Fred");
-
- int[] testnestedflatbuffer = monster.getTestnestedflatbuffer();
- TestEq(testnestedflatbuffer.length, 0);
-
- TestEq(monster.getTestempty() == null, true);
-
- TestEq(monster.getTestbool(), true);
-
- boolean[] testarrayofbools = monster.getTestarrayofbools();
- TestEq(testarrayofbools.length, 3);
- TestEq(testarrayofbools[0], true);
- TestEq(testarrayofbools[1], false);
- TestEq(testarrayofbools[2], true);
-
- TestEq(monster.getTestf(), 3.14159f);
- TestEq(monster.getTestf2(), 3.0f);
- TestEq(monster.getTestf3(), 0.0f);
- TestEq(monster.getTestf3(), 0.0f);
-
- AbilityT[] testarrayofsortedstruct = monster.getTestarrayofsortedstruct();
- TestEq(testarrayofsortedstruct.length, 3);
- TestEq(testarrayofsortedstruct[0].getId(), (long) 0);
- TestEq(testarrayofsortedstruct[1].getId(), (long) 1);
- TestEq(testarrayofsortedstruct[2].getId(), (long) 5);
- TestEq(testarrayofsortedstruct[0].getDistance(), (long) 45);
- TestEq(testarrayofsortedstruct[1].getDistance(), (long) 21);
- TestEq(testarrayofsortedstruct[2].getDistance(), (long) 12);
-
- int[] flex = monster.getFlex();
- TestEq(flex.length, 0);
-
- long[] vectorOfLongs = monster.getVectorOfLongs();
- TestEq(vectorOfLongs.length, 5);
- long l = 1;
- for (int i = 0; i < vectorOfLongs.length; i++) {
- TestEq(vectorOfLongs[i], l);
- l *= 100;
- }
-
- double[] vectorOfDoubles = monster.getVectorOfDoubles();
- TestEq(vectorOfDoubles.length, 3);
- TestEq(vectorOfDoubles[0], -1.7976931348623157E308);
- TestEq(vectorOfDoubles[1], 0.0);
- TestEq(vectorOfDoubles[2], 1.7976931348623157E308);
-
- TestEq(monster.getParentNamespaceTest() == null, true);
- ReferrableT[] vectorOfReferrables = monster.getVectorOfReferrables();
- TestEq(vectorOfReferrables.length, 0);
-
- TestEq(monster.getSignedEnum(), (byte) -1);
- }
-
- static void TestPackUnpack(ByteBuffer bb) {
- Monster m = Monster.getRootAsMonster(bb);
- MonsterT mObject = m.unpack();
- TestObject(mObject);
- FlatBufferBuilder fbb = new FlatBufferBuilder();
- int monster = Monster.pack(fbb, mObject);
- Monster.finishMonsterBuffer(fbb, monster);
- TestBuffer(fbb.dataBuffer());
-
- byte[] bytes = mObject.serializeToBinary();
- MonsterT newMonsterT = MonsterT.deserializeFromBinary(bytes);
- TestObject(newMonsterT);
- }
-
- static <T> void TestEq(T a, T b) {
- if ((a == null && a != b) || (a != null && !a.equals(b))) {
- System.out.println("" + a.getClass().getName() + " " + b.getClass().getName());
- System.out.println("FlatBuffers test FAILED: \'" + a + "\' != \'" + b + "\'");
- new Throwable().printStackTrace();
- assert false;
- System.exit(1);
- }
- }
-
-}
diff --git a/tests/JavaTest.sh b/tests/JavaTest.sh
deleted file mode 100755
index 099447e..0000000
--- a/tests/JavaTest.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2014 Google Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-set -o errexit
-
-echo Compile then run the Java test.
-
-java -version
-
-testdir=$(dirname $0)
-
-targetdir="${testdir}/target"
-
-if [[ -e "${targetdir}" ]]; then
- echo "cleaning target"
- rm -rf "${targetdir}"
-fi
-
-mkdir -v "${targetdir}"
-
-if ! find "${testdir}/../java" -type f -name "*.class" -delete; then
- echo "failed to clean .class files from java directory" >&2
- exit 1
-fi
-
-javac -d "${targetdir}" -classpath "${testdir}/optional_scalars:${testdir}/../java:${testdir}:${testdir}/namespace_test:${testdir}/union_vector" "${testdir}/JavaTest.java"
-
-(cd "${testdir}" && java -ea -classpath "${targetdir}" JavaTest )
-
-rm -rf "${targetdir}"
diff --git a/tests/KeywordTest/KeywordsInTable.cs b/tests/KeywordTest/KeywordsInTable.cs
index 495671b..af2a375 100644
--- a/tests/KeywordTest/KeywordsInTable.cs
+++ b/tests/KeywordTest/KeywordsInTable.cs
@@ -7,13 +7,13 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
public struct KeywordsInTable : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
- public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_8(); }
public static KeywordsInTable GetRootAsKeywordsInTable(ByteBuffer _bb) { return GetRootAsKeywordsInTable(_bb, new KeywordsInTable()); }
public static KeywordsInTable GetRootAsKeywordsInTable(ByteBuffer _bb, KeywordsInTable obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public void __init(int _i, ByteBuffer _bb) { __p = new Table(_i, _bb); }
@@ -25,22 +25,27 @@
public bool MutatePrivate(KeywordTest.@public @private) { int o = __p.__offset(6); if (o != 0) { __p.bb.PutInt(o + __p.bb_pos, (int)@private); return true; } else { return false; } }
public int Type { get { int o = __p.__offset(8); return o != 0 ? __p.bb.GetInt(o + __p.bb_pos) : (int)0; } }
public bool MutateType(int type) { int o = __p.__offset(8); if (o != 0) { __p.bb.PutInt(o + __p.bb_pos, type); return true; } else { return false; } }
+ public bool Default { get { int o = __p.__offset(10); return o != 0 ? 0!=__p.bb.Get(o + __p.bb_pos) : (bool)false; } }
+ public bool MutateDefault(bool @default) { int o = __p.__offset(10); if (o != 0) { __p.bb.Put(o + __p.bb_pos, (byte)(@default ? 1 : 0)); return true; } else { return false; } }
public static Offset<KeywordTest.KeywordsInTable> CreateKeywordsInTable(FlatBufferBuilder builder,
KeywordTest.ABC @is = KeywordTest.ABC.@void,
KeywordTest.@public @private = KeywordTest.@public.NONE,
- int type = 0) {
- builder.StartTable(3);
+ int type = 0,
+ bool @default = false) {
+ builder.StartTable(4);
KeywordsInTable.AddType(builder, type);
KeywordsInTable.AddPrivate(builder, @private);
KeywordsInTable.AddIs(builder, @is);
+ KeywordsInTable.AddDefault(builder, @default);
return KeywordsInTable.EndKeywordsInTable(builder);
}
- public static void StartKeywordsInTable(FlatBufferBuilder builder) { builder.StartTable(3); }
+ public static void StartKeywordsInTable(FlatBufferBuilder builder) { builder.StartTable(4); }
public static void AddIs(FlatBufferBuilder builder, KeywordTest.ABC @is) { builder.AddInt(0, (int)@is, 0); }
public static void AddPrivate(FlatBufferBuilder builder, KeywordTest.@public @private) { builder.AddInt(1, (int)@private, 0); }
public static void AddType(FlatBufferBuilder builder, int type) { builder.AddInt(2, type, 0); }
+ public static void AddDefault(FlatBufferBuilder builder, bool @default) { builder.AddBool(3, @default, false); }
public static Offset<KeywordTest.KeywordsInTable> EndKeywordsInTable(FlatBufferBuilder builder) {
int o = builder.EndTable();
return new Offset<KeywordTest.KeywordsInTable>(o);
@@ -54,6 +59,7 @@
_o.Is = this.Is;
_o.Private = this.Private;
_o.Type = this.Type;
+ _o.Default = this.Default;
}
public static Offset<KeywordTest.KeywordsInTable> Pack(FlatBufferBuilder builder, KeywordsInTableT _o) {
if (_o == null) return default(Offset<KeywordTest.KeywordsInTable>);
@@ -61,7 +67,8 @@
builder,
_o.Is,
_o.Private,
- _o.Type);
+ _o.Type,
+ _o.Default);
}
}
@@ -73,11 +80,14 @@
public KeywordTest.@public Private { get; set; }
[Newtonsoft.Json.JsonProperty("type")]
public int Type { get; set; }
+ [Newtonsoft.Json.JsonProperty("default")]
+ public bool Default { get; set; }
public KeywordsInTableT() {
this.Is = KeywordTest.ABC.@void;
this.Private = KeywordTest.@public.NONE;
this.Type = 0;
+ this.Default = false;
}
}
diff --git a/tests/KeywordTest/KeywordsInUnion.cs b/tests/KeywordTest/KeywordsInUnion.cs
index 68c050e..0efa066 100644
--- a/tests/KeywordTest/KeywordsInUnion.cs
+++ b/tests/KeywordTest/KeywordsInUnion.cs
@@ -28,7 +28,7 @@
public KeywordTest.KeywordsInTableT Asinternal() { return this.As<KeywordTest.KeywordsInTableT>(); }
public static KeywordsInUnionUnion Frominternal(KeywordTest.KeywordsInTableT _internal) { return new KeywordsInUnionUnion{ Type = KeywordsInUnion.@internal, Value = _internal }; }
- public static int Pack(FlatBuffers.FlatBufferBuilder builder, KeywordsInUnionUnion _o) {
+ public static int Pack(Google.FlatBuffers.FlatBufferBuilder builder, KeywordsInUnionUnion _o) {
switch (_o.Type) {
default: return 0;
case KeywordsInUnion.@static: return KeywordTest.KeywordsInTable.Pack(builder, _o.Asstatic()).Value;
diff --git a/tests/KotlinTest.kt b/tests/KotlinTest.kt
index cfb7056..9a8fe5f 100644
--- a/tests/KotlinTest.kt
+++ b/tests/KotlinTest.kt
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+import DictionaryLookup.*;
import MyGame.Example.*
import optional_scalars.*
import com.google.flatbuffers.ByteBufferUtil
@@ -79,9 +80,29 @@
TestSharedStringPool()
TestScalarOptional()
+ TestDictionaryLookup()
println("FlatBuffers test: completed successfully")
}
+ fun TestDictionaryLookup() {
+ val fbb = FlatBufferBuilder(16)
+ val lfIndex = LongFloatEntry.createLongFloatEntry(fbb, 0, 99.0f)
+ val vectorEntriesIdx = LongFloatMap.createEntriesVector(fbb, intArrayOf(lfIndex))
+ val rootIdx = LongFloatMap.createLongFloatMap(fbb, vectorEntriesIdx)
+
+ LongFloatMap.finishLongFloatMapBuffer(fbb, rootIdx)
+ val map = LongFloatMap.getRootAsLongFloatMap(fbb.dataBuffer())
+ assert(map.entriesLength == 1)
+
+ val e = map.entries(0)!!
+ assert(e.key == 0L)
+ assert(e.value == 99.0f)
+
+ val e2 = map.entriesByKey(0)!!
+ assert(e2.key == 0L)
+ assert(e2.value == 99.0f)
+ }
+
fun TestEnums() {
assert(Color.name(Color.Red.toInt()) == "Red")
assert(Color.name(Color.Blue.toInt()) == "Blue")
diff --git a/tests/MyGame/Example/Ability.cs b/tests/MyGame/Example/Ability.cs
index ae6a5b4..e194063 100644
--- a/tests/MyGame/Example/Ability.cs
+++ b/tests/MyGame/Example/Ability.cs
@@ -7,7 +7,7 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
public struct Ability : IFlatbufferObject
{
diff --git a/tests/MyGame/Example/Ability.go b/tests/MyGame/Example/Ability.go
index 9852a75..ae869aa 100644
--- a/tests/MyGame/Example/Ability.go
+++ b/tests/MyGame/Example/Ability.go
@@ -7,8 +7,8 @@
)
type AbilityT struct {
- Id uint32
- Distance uint32
+ Id uint32 `json:"id"`
+ Distance uint32 `json:"distance"`
}
func (t *AbilityT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
diff --git a/tests/MyGame/Example/Ability.lua b/tests/MyGame/Example/Ability.lua
index 870ff81..01c7480 100644
--- a/tests/MyGame/Example/Ability.lua
+++ b/tests/MyGame/Example/Ability.lua
@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
- flatc version: 2.0.6
+ flatc version: 2.0.8
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
diff --git a/tests/MyGame/Example/Any.cs b/tests/MyGame/Example/Any.cs
index 2e1717b..90cd22b 100644
--- a/tests/MyGame/Example/Any.cs
+++ b/tests/MyGame/Example/Any.cs
@@ -31,7 +31,7 @@
public MyGame.Example2.MonsterT AsMyGame_Example2_Monster() { return this.As<MyGame.Example2.MonsterT>(); }
public static AnyUnion FromMyGame_Example2_Monster(MyGame.Example2.MonsterT _mygame_example2_monster) { return new AnyUnion{ Type = Any.MyGame_Example2_Monster, Value = _mygame_example2_monster }; }
- public static int Pack(FlatBuffers.FlatBufferBuilder builder, AnyUnion _o) {
+ public static int Pack(Google.FlatBuffers.FlatBufferBuilder builder, AnyUnion _o) {
switch (_o.Type) {
default: return 0;
case Any.Monster: return MyGame.Example.Monster.Pack(builder, _o.AsMonster()).Value;
diff --git a/tests/MyGame/Example/Any.lua b/tests/MyGame/Example/Any.lua
index 769a224..b99f4c6 100644
--- a/tests/MyGame/Example/Any.lua
+++ b/tests/MyGame/Example/Any.lua
@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
- flatc version: 2.0.6
+ flatc version: 2.0.8
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
diff --git a/tests/MyGame/Example/AnyAmbiguousAliases.cs b/tests/MyGame/Example/AnyAmbiguousAliases.cs
index 9253cc9..eec4172 100644
--- a/tests/MyGame/Example/AnyAmbiguousAliases.cs
+++ b/tests/MyGame/Example/AnyAmbiguousAliases.cs
@@ -31,7 +31,7 @@
public MyGame.Example.MonsterT AsM3() { return this.As<MyGame.Example.MonsterT>(); }
public static AnyAmbiguousAliasesUnion FromM3(MyGame.Example.MonsterT _m3) { return new AnyAmbiguousAliasesUnion{ Type = AnyAmbiguousAliases.M3, Value = _m3 }; }
- public static int Pack(FlatBuffers.FlatBufferBuilder builder, AnyAmbiguousAliasesUnion _o) {
+ public static int Pack(Google.FlatBuffers.FlatBufferBuilder builder, AnyAmbiguousAliasesUnion _o) {
switch (_o.Type) {
default: return 0;
case AnyAmbiguousAliases.M1: return MyGame.Example.Monster.Pack(builder, _o.AsM1()).Value;
diff --git a/tests/MyGame/Example/AnyAmbiguousAliases.lua b/tests/MyGame/Example/AnyAmbiguousAliases.lua
index c0d3407..0d6106c 100644
--- a/tests/MyGame/Example/AnyAmbiguousAliases.lua
+++ b/tests/MyGame/Example/AnyAmbiguousAliases.lua
@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
- flatc version: 2.0.6
+ flatc version: 2.0.8
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
diff --git a/tests/MyGame/Example/AnyUniqueAliases.cs b/tests/MyGame/Example/AnyUniqueAliases.cs
index ab33276..bb6a212 100644
--- a/tests/MyGame/Example/AnyUniqueAliases.cs
+++ b/tests/MyGame/Example/AnyUniqueAliases.cs
@@ -31,7 +31,7 @@
public MyGame.Example2.MonsterT AsM2() { return this.As<MyGame.Example2.MonsterT>(); }
public static AnyUniqueAliasesUnion FromM2(MyGame.Example2.MonsterT _m2) { return new AnyUniqueAliasesUnion{ Type = AnyUniqueAliases.M2, Value = _m2 }; }
- public static int Pack(FlatBuffers.FlatBufferBuilder builder, AnyUniqueAliasesUnion _o) {
+ public static int Pack(Google.FlatBuffers.FlatBufferBuilder builder, AnyUniqueAliasesUnion _o) {
switch (_o.Type) {
default: return 0;
case AnyUniqueAliases.M: return MyGame.Example.Monster.Pack(builder, _o.AsM()).Value;
diff --git a/tests/MyGame/Example/AnyUniqueAliases.lua b/tests/MyGame/Example/AnyUniqueAliases.lua
index 0042b93..7ab4f9c 100644
--- a/tests/MyGame/Example/AnyUniqueAliases.lua
+++ b/tests/MyGame/Example/AnyUniqueAliases.lua
@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
- flatc version: 2.0.6
+ flatc version: 2.0.8
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
diff --git a/tests/MyGame/Example/ArrayStruct.cs b/tests/MyGame/Example/ArrayStruct.cs
index df0e2ac..70a8bdd 100644
--- a/tests/MyGame/Example/ArrayStruct.cs
+++ b/tests/MyGame/Example/ArrayStruct.cs
@@ -7,7 +7,7 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
public struct ArrayStruct : IFlatbufferObject
{
diff --git a/tests/MyGame/Example/ArrayTable.cs b/tests/MyGame/Example/ArrayTable.cs
index 9dc3d45..a5e4e79 100644
--- a/tests/MyGame/Example/ArrayTable.cs
+++ b/tests/MyGame/Example/ArrayTable.cs
@@ -7,13 +7,13 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
public struct ArrayTable : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
- public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_8(); }
public static ArrayTable GetRootAsArrayTable(ByteBuffer _bb) { return GetRootAsArrayTable(_bb, new ArrayTable()); }
public static ArrayTable GetRootAsArrayTable(ByteBuffer _bb, ArrayTable obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public static bool ArrayTableBufferHasIdentifier(ByteBuffer _bb) { return Table.__has_identifier(_bb, "ARRT"); }
diff --git a/tests/MyGame/Example/ArrayTable.java b/tests/MyGame/Example/ArrayTable.java
index 8e3782b..c255da3 100644
--- a/tests/MyGame/Example/ArrayTable.java
+++ b/tests/MyGame/Example/ArrayTable.java
@@ -9,7 +9,7 @@
@SuppressWarnings("unused")
public final class ArrayTable extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static ArrayTable getRootAsArrayTable(ByteBuffer _bb) { return getRootAsArrayTable(_bb, new ArrayTable()); }
public static ArrayTable getRootAsArrayTable(ByteBuffer _bb, ArrayTable obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public static boolean ArrayTableBufferHasIdentifier(ByteBuffer _bb) { return __has_identifier(_bb, "ARRT"); }
diff --git a/tests/MyGame/Example/Color.lua b/tests/MyGame/Example/Color.lua
index 1909a1b..c7a0b1e 100644
--- a/tests/MyGame/Example/Color.lua
+++ b/tests/MyGame/Example/Color.lua
@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
- flatc version: 2.0.6
+ flatc version: 2.0.8
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
diff --git a/tests/MyGame/Example/LongEnum.lua b/tests/MyGame/Example/LongEnum.lua
index 00fb679..a4e3dc5 100644
--- a/tests/MyGame/Example/LongEnum.lua
+++ b/tests/MyGame/Example/LongEnum.lua
@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
- flatc version: 2.0.6
+ flatc version: 2.0.8
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
diff --git a/tests/MyGame/Example/Monster.cs b/tests/MyGame/Example/Monster.cs
index 4a11389..87d8ef3 100644
--- a/tests/MyGame/Example/Monster.cs
+++ b/tests/MyGame/Example/Monster.cs
@@ -7,14 +7,14 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
/// an example documentation comment: "monster object"
public struct Monster : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
- public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_8(); }
public static Monster GetRootAsMonster(ByteBuffer _bb) { return GetRootAsMonster(_bb, new Monster()); }
public static Monster GetRootAsMonster(ByteBuffer _bb, Monster obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public static bool MonsterBufferHasIdentifier(ByteBuffer _bb) { return Table.__has_identifier(_bb, "MONS"); }
@@ -335,6 +335,8 @@
public static void AddInventory(FlatBufferBuilder builder, VectorOffset inventoryOffset) { builder.AddOffset(5, inventoryOffset.Value, 0); }
public static VectorOffset CreateInventoryVector(FlatBufferBuilder builder, byte[] data) { builder.StartVector(1, data.Length, 1); for (int i = data.Length - 1; i >= 0; i--) builder.AddByte(data[i]); return builder.EndVector(); }
public static VectorOffset CreateInventoryVectorBlock(FlatBufferBuilder builder, byte[] data) { builder.StartVector(1, data.Length, 1); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateInventoryVectorBlock(FlatBufferBuilder builder, ArraySegment<byte> data) { builder.StartVector(1, data.Count, 1); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateInventoryVectorBlock(FlatBufferBuilder builder, IntPtr dataPtr, int sizeInBytes) { builder.StartVector(1, sizeInBytes, 1); builder.Add<byte>(dataPtr, sizeInBytes); return builder.EndVector(); }
public static void StartInventoryVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(1, numElems, 1); }
public static void AddColor(FlatBufferBuilder builder, MyGame.Example.Color color) { builder.AddByte(6, (byte)color, 8); }
public static void AddTestType(FlatBufferBuilder builder, MyGame.Example.Any testType) { builder.AddByte(7, (byte)testType, 0); }
@@ -344,15 +346,21 @@
public static void AddTestarrayofstring(FlatBufferBuilder builder, VectorOffset testarrayofstringOffset) { builder.AddOffset(10, testarrayofstringOffset.Value, 0); }
public static VectorOffset CreateTestarrayofstringVector(FlatBufferBuilder builder, StringOffset[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddOffset(data[i].Value); return builder.EndVector(); }
public static VectorOffset CreateTestarrayofstringVectorBlock(FlatBufferBuilder builder, StringOffset[] data) { builder.StartVector(4, data.Length, 4); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateTestarrayofstringVectorBlock(FlatBufferBuilder builder, ArraySegment<StringOffset> data) { builder.StartVector(4, data.Count, 4); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateTestarrayofstringVectorBlock(FlatBufferBuilder builder, IntPtr dataPtr, int sizeInBytes) { builder.StartVector(1, sizeInBytes, 1); builder.Add<StringOffset>(dataPtr, sizeInBytes); return builder.EndVector(); }
public static void StartTestarrayofstringVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
public static void AddTestarrayoftables(FlatBufferBuilder builder, VectorOffset testarrayoftablesOffset) { builder.AddOffset(11, testarrayoftablesOffset.Value, 0); }
public static VectorOffset CreateTestarrayoftablesVector(FlatBufferBuilder builder, Offset<MyGame.Example.Monster>[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddOffset(data[i].Value); return builder.EndVector(); }
public static VectorOffset CreateTestarrayoftablesVectorBlock(FlatBufferBuilder builder, Offset<MyGame.Example.Monster>[] data) { builder.StartVector(4, data.Length, 4); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateTestarrayoftablesVectorBlock(FlatBufferBuilder builder, ArraySegment<Offset<MyGame.Example.Monster>> data) { builder.StartVector(4, data.Count, 4); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateTestarrayoftablesVectorBlock(FlatBufferBuilder builder, IntPtr dataPtr, int sizeInBytes) { builder.StartVector(1, sizeInBytes, 1); builder.Add<Offset<MyGame.Example.Monster>>(dataPtr, sizeInBytes); return builder.EndVector(); }
public static void StartTestarrayoftablesVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
public static void AddEnemy(FlatBufferBuilder builder, Offset<MyGame.Example.Monster> enemyOffset) { builder.AddOffset(12, enemyOffset.Value, 0); }
public static void AddTestnestedflatbuffer(FlatBufferBuilder builder, VectorOffset testnestedflatbufferOffset) { builder.AddOffset(13, testnestedflatbufferOffset.Value, 0); }
public static VectorOffset CreateTestnestedflatbufferVector(FlatBufferBuilder builder, byte[] data) { builder.StartVector(1, data.Length, 1); for (int i = data.Length - 1; i >= 0; i--) builder.AddByte(data[i]); return builder.EndVector(); }
public static VectorOffset CreateTestnestedflatbufferVectorBlock(FlatBufferBuilder builder, byte[] data) { builder.StartVector(1, data.Length, 1); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateTestnestedflatbufferVectorBlock(FlatBufferBuilder builder, ArraySegment<byte> data) { builder.StartVector(1, data.Count, 1); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateTestnestedflatbufferVectorBlock(FlatBufferBuilder builder, IntPtr dataPtr, int sizeInBytes) { builder.StartVector(1, sizeInBytes, 1); builder.Add<byte>(dataPtr, sizeInBytes); return builder.EndVector(); }
public static void StartTestnestedflatbufferVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(1, numElems, 1); }
public static void AddTestempty(FlatBufferBuilder builder, Offset<MyGame.Example.Stat> testemptyOffset) { builder.AddOffset(14, testemptyOffset.Value, 0); }
public static void AddTestbool(FlatBufferBuilder builder, bool testbool) { builder.AddBool(15, testbool, false); }
@@ -367,6 +375,8 @@
public static void AddTestarrayofbools(FlatBufferBuilder builder, VectorOffset testarrayofboolsOffset) { builder.AddOffset(24, testarrayofboolsOffset.Value, 0); }
public static VectorOffset CreateTestarrayofboolsVector(FlatBufferBuilder builder, bool[] data) { builder.StartVector(1, data.Length, 1); for (int i = data.Length - 1; i >= 0; i--) builder.AddBool(data[i]); return builder.EndVector(); }
public static VectorOffset CreateTestarrayofboolsVectorBlock(FlatBufferBuilder builder, bool[] data) { builder.StartVector(1, data.Length, 1); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateTestarrayofboolsVectorBlock(FlatBufferBuilder builder, ArraySegment<bool> data) { builder.StartVector(1, data.Count, 1); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateTestarrayofboolsVectorBlock(FlatBufferBuilder builder, IntPtr dataPtr, int sizeInBytes) { builder.StartVector(1, sizeInBytes, 1); builder.Add<bool>(dataPtr, sizeInBytes); return builder.EndVector(); }
public static void StartTestarrayofboolsVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(1, numElems, 1); }
public static void AddTestf(FlatBufferBuilder builder, float testf) { builder.AddFloat(25, testf, 3.14159f); }
public static void AddTestf2(FlatBufferBuilder builder, float testf2) { builder.AddFloat(26, testf2, 3.0f); }
@@ -374,46 +384,64 @@
public static void AddTestarrayofstring2(FlatBufferBuilder builder, VectorOffset testarrayofstring2Offset) { builder.AddOffset(28, testarrayofstring2Offset.Value, 0); }
public static VectorOffset CreateTestarrayofstring2Vector(FlatBufferBuilder builder, StringOffset[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddOffset(data[i].Value); return builder.EndVector(); }
public static VectorOffset CreateTestarrayofstring2VectorBlock(FlatBufferBuilder builder, StringOffset[] data) { builder.StartVector(4, data.Length, 4); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateTestarrayofstring2VectorBlock(FlatBufferBuilder builder, ArraySegment<StringOffset> data) { builder.StartVector(4, data.Count, 4); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateTestarrayofstring2VectorBlock(FlatBufferBuilder builder, IntPtr dataPtr, int sizeInBytes) { builder.StartVector(1, sizeInBytes, 1); builder.Add<StringOffset>(dataPtr, sizeInBytes); return builder.EndVector(); }
public static void StartTestarrayofstring2Vector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
public static void AddTestarrayofsortedstruct(FlatBufferBuilder builder, VectorOffset testarrayofsortedstructOffset) { builder.AddOffset(29, testarrayofsortedstructOffset.Value, 0); }
public static void StartTestarrayofsortedstructVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(8, numElems, 4); }
public static void AddFlex(FlatBufferBuilder builder, VectorOffset flexOffset) { builder.AddOffset(30, flexOffset.Value, 0); }
public static VectorOffset CreateFlexVector(FlatBufferBuilder builder, byte[] data) { builder.StartVector(1, data.Length, 1); for (int i = data.Length - 1; i >= 0; i--) builder.AddByte(data[i]); return builder.EndVector(); }
public static VectorOffset CreateFlexVectorBlock(FlatBufferBuilder builder, byte[] data) { builder.StartVector(1, data.Length, 1); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateFlexVectorBlock(FlatBufferBuilder builder, ArraySegment<byte> data) { builder.StartVector(1, data.Count, 1); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateFlexVectorBlock(FlatBufferBuilder builder, IntPtr dataPtr, int sizeInBytes) { builder.StartVector(1, sizeInBytes, 1); builder.Add<byte>(dataPtr, sizeInBytes); return builder.EndVector(); }
public static void StartFlexVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(1, numElems, 1); }
public static void AddTest5(FlatBufferBuilder builder, VectorOffset test5Offset) { builder.AddOffset(31, test5Offset.Value, 0); }
public static void StartTest5Vector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 2); }
public static void AddVectorOfLongs(FlatBufferBuilder builder, VectorOffset vectorOfLongsOffset) { builder.AddOffset(32, vectorOfLongsOffset.Value, 0); }
public static VectorOffset CreateVectorOfLongsVector(FlatBufferBuilder builder, long[] data) { builder.StartVector(8, data.Length, 8); for (int i = data.Length - 1; i >= 0; i--) builder.AddLong(data[i]); return builder.EndVector(); }
public static VectorOffset CreateVectorOfLongsVectorBlock(FlatBufferBuilder builder, long[] data) { builder.StartVector(8, data.Length, 8); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateVectorOfLongsVectorBlock(FlatBufferBuilder builder, ArraySegment<long> data) { builder.StartVector(8, data.Count, 8); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateVectorOfLongsVectorBlock(FlatBufferBuilder builder, IntPtr dataPtr, int sizeInBytes) { builder.StartVector(1, sizeInBytes, 1); builder.Add<long>(dataPtr, sizeInBytes); return builder.EndVector(); }
public static void StartVectorOfLongsVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(8, numElems, 8); }
public static void AddVectorOfDoubles(FlatBufferBuilder builder, VectorOffset vectorOfDoublesOffset) { builder.AddOffset(33, vectorOfDoublesOffset.Value, 0); }
public static VectorOffset CreateVectorOfDoublesVector(FlatBufferBuilder builder, double[] data) { builder.StartVector(8, data.Length, 8); for (int i = data.Length - 1; i >= 0; i--) builder.AddDouble(data[i]); return builder.EndVector(); }
public static VectorOffset CreateVectorOfDoublesVectorBlock(FlatBufferBuilder builder, double[] data) { builder.StartVector(8, data.Length, 8); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateVectorOfDoublesVectorBlock(FlatBufferBuilder builder, ArraySegment<double> data) { builder.StartVector(8, data.Count, 8); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateVectorOfDoublesVectorBlock(FlatBufferBuilder builder, IntPtr dataPtr, int sizeInBytes) { builder.StartVector(1, sizeInBytes, 1); builder.Add<double>(dataPtr, sizeInBytes); return builder.EndVector(); }
public static void StartVectorOfDoublesVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(8, numElems, 8); }
public static void AddParentNamespaceTest(FlatBufferBuilder builder, Offset<MyGame.InParentNamespace> parentNamespaceTestOffset) { builder.AddOffset(34, parentNamespaceTestOffset.Value, 0); }
public static void AddVectorOfReferrables(FlatBufferBuilder builder, VectorOffset vectorOfReferrablesOffset) { builder.AddOffset(35, vectorOfReferrablesOffset.Value, 0); }
public static VectorOffset CreateVectorOfReferrablesVector(FlatBufferBuilder builder, Offset<MyGame.Example.Referrable>[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddOffset(data[i].Value); return builder.EndVector(); }
public static VectorOffset CreateVectorOfReferrablesVectorBlock(FlatBufferBuilder builder, Offset<MyGame.Example.Referrable>[] data) { builder.StartVector(4, data.Length, 4); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateVectorOfReferrablesVectorBlock(FlatBufferBuilder builder, ArraySegment<Offset<MyGame.Example.Referrable>> data) { builder.StartVector(4, data.Count, 4); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateVectorOfReferrablesVectorBlock(FlatBufferBuilder builder, IntPtr dataPtr, int sizeInBytes) { builder.StartVector(1, sizeInBytes, 1); builder.Add<Offset<MyGame.Example.Referrable>>(dataPtr, sizeInBytes); return builder.EndVector(); }
public static void StartVectorOfReferrablesVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
public static void AddSingleWeakReference(FlatBufferBuilder builder, ulong singleWeakReference) { builder.AddUlong(36, singleWeakReference, 0); }
public static void AddVectorOfWeakReferences(FlatBufferBuilder builder, VectorOffset vectorOfWeakReferencesOffset) { builder.AddOffset(37, vectorOfWeakReferencesOffset.Value, 0); }
public static VectorOffset CreateVectorOfWeakReferencesVector(FlatBufferBuilder builder, ulong[] data) { builder.StartVector(8, data.Length, 8); for (int i = data.Length - 1; i >= 0; i--) builder.AddUlong(data[i]); return builder.EndVector(); }
public static VectorOffset CreateVectorOfWeakReferencesVectorBlock(FlatBufferBuilder builder, ulong[] data) { builder.StartVector(8, data.Length, 8); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateVectorOfWeakReferencesVectorBlock(FlatBufferBuilder builder, ArraySegment<ulong> data) { builder.StartVector(8, data.Count, 8); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateVectorOfWeakReferencesVectorBlock(FlatBufferBuilder builder, IntPtr dataPtr, int sizeInBytes) { builder.StartVector(1, sizeInBytes, 1); builder.Add<ulong>(dataPtr, sizeInBytes); return builder.EndVector(); }
public static void StartVectorOfWeakReferencesVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(8, numElems, 8); }
public static void AddVectorOfStrongReferrables(FlatBufferBuilder builder, VectorOffset vectorOfStrongReferrablesOffset) { builder.AddOffset(38, vectorOfStrongReferrablesOffset.Value, 0); }
public static VectorOffset CreateVectorOfStrongReferrablesVector(FlatBufferBuilder builder, Offset<MyGame.Example.Referrable>[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddOffset(data[i].Value); return builder.EndVector(); }
public static VectorOffset CreateVectorOfStrongReferrablesVectorBlock(FlatBufferBuilder builder, Offset<MyGame.Example.Referrable>[] data) { builder.StartVector(4, data.Length, 4); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateVectorOfStrongReferrablesVectorBlock(FlatBufferBuilder builder, ArraySegment<Offset<MyGame.Example.Referrable>> data) { builder.StartVector(4, data.Count, 4); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateVectorOfStrongReferrablesVectorBlock(FlatBufferBuilder builder, IntPtr dataPtr, int sizeInBytes) { builder.StartVector(1, sizeInBytes, 1); builder.Add<Offset<MyGame.Example.Referrable>>(dataPtr, sizeInBytes); return builder.EndVector(); }
public static void StartVectorOfStrongReferrablesVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
public static void AddCoOwningReference(FlatBufferBuilder builder, ulong coOwningReference) { builder.AddUlong(39, coOwningReference, 0); }
public static void AddVectorOfCoOwningReferences(FlatBufferBuilder builder, VectorOffset vectorOfCoOwningReferencesOffset) { builder.AddOffset(40, vectorOfCoOwningReferencesOffset.Value, 0); }
public static VectorOffset CreateVectorOfCoOwningReferencesVector(FlatBufferBuilder builder, ulong[] data) { builder.StartVector(8, data.Length, 8); for (int i = data.Length - 1; i >= 0; i--) builder.AddUlong(data[i]); return builder.EndVector(); }
public static VectorOffset CreateVectorOfCoOwningReferencesVectorBlock(FlatBufferBuilder builder, ulong[] data) { builder.StartVector(8, data.Length, 8); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateVectorOfCoOwningReferencesVectorBlock(FlatBufferBuilder builder, ArraySegment<ulong> data) { builder.StartVector(8, data.Count, 8); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateVectorOfCoOwningReferencesVectorBlock(FlatBufferBuilder builder, IntPtr dataPtr, int sizeInBytes) { builder.StartVector(1, sizeInBytes, 1); builder.Add<ulong>(dataPtr, sizeInBytes); return builder.EndVector(); }
public static void StartVectorOfCoOwningReferencesVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(8, numElems, 8); }
public static void AddNonOwningReference(FlatBufferBuilder builder, ulong nonOwningReference) { builder.AddUlong(41, nonOwningReference, 0); }
public static void AddVectorOfNonOwningReferences(FlatBufferBuilder builder, VectorOffset vectorOfNonOwningReferencesOffset) { builder.AddOffset(42, vectorOfNonOwningReferencesOffset.Value, 0); }
public static VectorOffset CreateVectorOfNonOwningReferencesVector(FlatBufferBuilder builder, ulong[] data) { builder.StartVector(8, data.Length, 8); for (int i = data.Length - 1; i >= 0; i--) builder.AddUlong(data[i]); return builder.EndVector(); }
public static VectorOffset CreateVectorOfNonOwningReferencesVectorBlock(FlatBufferBuilder builder, ulong[] data) { builder.StartVector(8, data.Length, 8); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateVectorOfNonOwningReferencesVectorBlock(FlatBufferBuilder builder, ArraySegment<ulong> data) { builder.StartVector(8, data.Count, 8); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateVectorOfNonOwningReferencesVectorBlock(FlatBufferBuilder builder, IntPtr dataPtr, int sizeInBytes) { builder.StartVector(1, sizeInBytes, 1); builder.Add<ulong>(dataPtr, sizeInBytes); return builder.EndVector(); }
public static void StartVectorOfNonOwningReferencesVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(8, numElems, 8); }
public static void AddAnyUniqueType(FlatBufferBuilder builder, MyGame.Example.AnyUniqueAliases anyUniqueType) { builder.AddByte(43, (byte)anyUniqueType, 0); }
public static void AddAnyUnique(FlatBufferBuilder builder, int anyUniqueOffset) { builder.AddOffset(44, anyUniqueOffset, 0); }
@@ -422,15 +450,21 @@
public static void AddVectorOfEnums(FlatBufferBuilder builder, VectorOffset vectorOfEnumsOffset) { builder.AddOffset(47, vectorOfEnumsOffset.Value, 0); }
public static VectorOffset CreateVectorOfEnumsVector(FlatBufferBuilder builder, MyGame.Example.Color[] data) { builder.StartVector(1, data.Length, 1); for (int i = data.Length - 1; i >= 0; i--) builder.AddByte((byte)data[i]); return builder.EndVector(); }
public static VectorOffset CreateVectorOfEnumsVectorBlock(FlatBufferBuilder builder, MyGame.Example.Color[] data) { builder.StartVector(1, data.Length, 1); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateVectorOfEnumsVectorBlock(FlatBufferBuilder builder, ArraySegment<MyGame.Example.Color> data) { builder.StartVector(1, data.Count, 1); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateVectorOfEnumsVectorBlock(FlatBufferBuilder builder, IntPtr dataPtr, int sizeInBytes) { builder.StartVector(1, sizeInBytes, 1); builder.Add<MyGame.Example.Color>(dataPtr, sizeInBytes); return builder.EndVector(); }
public static void StartVectorOfEnumsVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(1, numElems, 1); }
public static void AddSignedEnum(FlatBufferBuilder builder, MyGame.Example.Race signedEnum) { builder.AddSbyte(48, (sbyte)signedEnum, -1); }
public static void AddTestrequirednestedflatbuffer(FlatBufferBuilder builder, VectorOffset testrequirednestedflatbufferOffset) { builder.AddOffset(49, testrequirednestedflatbufferOffset.Value, 0); }
public static VectorOffset CreateTestrequirednestedflatbufferVector(FlatBufferBuilder builder, byte[] data) { builder.StartVector(1, data.Length, 1); for (int i = data.Length - 1; i >= 0; i--) builder.AddByte(data[i]); return builder.EndVector(); }
public static VectorOffset CreateTestrequirednestedflatbufferVectorBlock(FlatBufferBuilder builder, byte[] data) { builder.StartVector(1, data.Length, 1); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateTestrequirednestedflatbufferVectorBlock(FlatBufferBuilder builder, ArraySegment<byte> data) { builder.StartVector(1, data.Count, 1); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateTestrequirednestedflatbufferVectorBlock(FlatBufferBuilder builder, IntPtr dataPtr, int sizeInBytes) { builder.StartVector(1, sizeInBytes, 1); builder.Add<byte>(dataPtr, sizeInBytes); return builder.EndVector(); }
public static void StartTestrequirednestedflatbufferVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(1, numElems, 1); }
public static void AddScalarKeySortedTables(FlatBufferBuilder builder, VectorOffset scalarKeySortedTablesOffset) { builder.AddOffset(50, scalarKeySortedTablesOffset.Value, 0); }
public static VectorOffset CreateScalarKeySortedTablesVector(FlatBufferBuilder builder, Offset<MyGame.Example.Stat>[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddOffset(data[i].Value); return builder.EndVector(); }
public static VectorOffset CreateScalarKeySortedTablesVectorBlock(FlatBufferBuilder builder, Offset<MyGame.Example.Stat>[] data) { builder.StartVector(4, data.Length, 4); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateScalarKeySortedTablesVectorBlock(FlatBufferBuilder builder, ArraySegment<Offset<MyGame.Example.Stat>> data) { builder.StartVector(4, data.Count, 4); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateScalarKeySortedTablesVectorBlock(FlatBufferBuilder builder, IntPtr dataPtr, int sizeInBytes) { builder.StartVector(1, sizeInBytes, 1); builder.Add<Offset<MyGame.Example.Stat>>(dataPtr, sizeInBytes); return builder.EndVector(); }
public static void StartScalarKeySortedTablesVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
public static void AddNativeInline(FlatBufferBuilder builder, Offset<MyGame.Example.Test> nativeInlineOffset) { builder.AddStruct(51, nativeInlineOffset.Value, 0); }
public static void AddLongEnumNonEnumDefault(FlatBufferBuilder builder, MyGame.Example.LongEnum longEnumNonEnumDefault) { builder.AddUlong(52, (ulong)longEnumNonEnumDefault, 0); }
@@ -444,18 +478,21 @@
public static void FinishSizePrefixedMonsterBuffer(FlatBufferBuilder builder, Offset<MyGame.Example.Monster> offset) { builder.FinishSizePrefixed(offset.Value, "MONS"); }
public static VectorOffset CreateSortedVectorOfMonster(FlatBufferBuilder builder, Offset<Monster>[] offsets) {
- Array.Sort(offsets, (Offset<Monster> o1, Offset<Monster> o2) => Table.CompareStrings(Table.__offset(10, o1.Value, builder.DataBuffer), Table.__offset(10, o2.Value, builder.DataBuffer), builder.DataBuffer));
+ Array.Sort(offsets,
+ (Offset<Monster> o1, Offset<Monster> o2) =>
+ new Monster().__assign(builder.DataBuffer.Length - o1.Value, builder.DataBuffer).Name.CompareTo(new Monster().__assign(builder.DataBuffer.Length - o2.Value, builder.DataBuffer).Name));
return builder.CreateVectorOfTables(offsets);
}
public static Monster? __lookup_by_key(int vectorLocation, string key, ByteBuffer bb) {
- byte[] byteKey = System.Text.Encoding.UTF8.GetBytes(key);
+ Monster obj_ = new Monster();
int span = bb.GetInt(vectorLocation - 4);
int start = 0;
while (span != 0) {
int middle = span / 2;
int tableOffset = Table.__indirect(vectorLocation + 4 * (start + middle), bb);
- int comp = Table.CompareStrings(Table.__offset(10, bb.Length - tableOffset, bb), byteKey, bb);
+ obj_.__assign(tableOffset, bb);
+ int comp = obj_.Name.CompareTo(key);
if (comp > 0) {
span = middle;
} else if (comp < 0) {
@@ -463,7 +500,7 @@
start += middle;
span -= middle;
} else {
- return new Monster().__assign(tableOffset, bb);
+ return obj_;
}
}
return null;
diff --git a/tests/MyGame/Example/Monster.go b/tests/MyGame/Example/Monster.go
index 067be0d..237896c 100644
--- a/tests/MyGame/Example/Monster.go
+++ b/tests/MyGame/Example/Monster.go
@@ -10,56 +10,56 @@
/// an example documentation comment: "monster object"
type MonsterT struct {
- Pos *Vec3T
- Mana int16
- Hp int16
- Name string
- Inventory []byte
- Color Color
- Test *AnyT
- Test4 []*TestT
- Testarrayofstring []string
- Testarrayoftables []*MonsterT
- Enemy *MonsterT
- Testnestedflatbuffer []byte
- Testempty *StatT
- Testbool bool
- Testhashs32Fnv1 int32
- Testhashu32Fnv1 uint32
- Testhashs64Fnv1 int64
- Testhashu64Fnv1 uint64
- Testhashs32Fnv1a int32
- Testhashu32Fnv1a uint32
- Testhashs64Fnv1a int64
- Testhashu64Fnv1a uint64
- Testarrayofbools []bool
- Testf float32
- Testf2 float32
- Testf3 float32
- Testarrayofstring2 []string
- Testarrayofsortedstruct []*AbilityT
- Flex []byte
- Test5 []*TestT
- VectorOfLongs []int64
- VectorOfDoubles []float64
- ParentNamespaceTest *MyGame.InParentNamespaceT
- VectorOfReferrables []*ReferrableT
- SingleWeakReference uint64
- VectorOfWeakReferences []uint64
- VectorOfStrongReferrables []*ReferrableT
- CoOwningReference uint64
- VectorOfCoOwningReferences []uint64
- NonOwningReference uint64
- VectorOfNonOwningReferences []uint64
- AnyUnique *AnyUniqueAliasesT
- AnyAmbiguous *AnyAmbiguousAliasesT
- VectorOfEnums []Color
- SignedEnum Race
- Testrequirednestedflatbuffer []byte
- ScalarKeySortedTables []*StatT
- NativeInline *TestT
- LongEnumNonEnumDefault LongEnum
- LongEnumNormalDefault LongEnum
+ Pos *Vec3T `json:"pos"`
+ Mana int16 `json:"mana"`
+ Hp int16 `json:"hp"`
+ Name string `json:"name"`
+ Inventory []byte `json:"inventory"`
+ Color Color `json:"color"`
+ Test *AnyT `json:"test"`
+ Test4 []*TestT `json:"test4"`
+ Testarrayofstring []string `json:"testarrayofstring"`
+ Testarrayoftables []*MonsterT `json:"testarrayoftables"`
+ Enemy *MonsterT `json:"enemy"`
+ Testnestedflatbuffer []byte `json:"testnestedflatbuffer"`
+ Testempty *StatT `json:"testempty"`
+ Testbool bool `json:"testbool"`
+ Testhashs32Fnv1 int32 `json:"testhashs32_fnv1"`
+ Testhashu32Fnv1 uint32 `json:"testhashu32_fnv1"`
+ Testhashs64Fnv1 int64 `json:"testhashs64_fnv1"`
+ Testhashu64Fnv1 uint64 `json:"testhashu64_fnv1"`
+ Testhashs32Fnv1a int32 `json:"testhashs32_fnv1a"`
+ Testhashu32Fnv1a uint32 `json:"testhashu32_fnv1a"`
+ Testhashs64Fnv1a int64 `json:"testhashs64_fnv1a"`
+ Testhashu64Fnv1a uint64 `json:"testhashu64_fnv1a"`
+ Testarrayofbools []bool `json:"testarrayofbools"`
+ Testf float32 `json:"testf"`
+ Testf2 float32 `json:"testf2"`
+ Testf3 float32 `json:"testf3"`
+ Testarrayofstring2 []string `json:"testarrayofstring2"`
+ Testarrayofsortedstruct []*AbilityT `json:"testarrayofsortedstruct"`
+ Flex []byte `json:"flex"`
+ Test5 []*TestT `json:"test5"`
+ VectorOfLongs []int64 `json:"vector_of_longs"`
+ VectorOfDoubles []float64 `json:"vector_of_doubles"`
+ ParentNamespaceTest *MyGame.InParentNamespaceT `json:"parent_namespace_test"`
+ VectorOfReferrables []*ReferrableT `json:"vector_of_referrables"`
+ SingleWeakReference uint64 `json:"single_weak_reference"`
+ VectorOfWeakReferences []uint64 `json:"vector_of_weak_references"`
+ VectorOfStrongReferrables []*ReferrableT `json:"vector_of_strong_referrables"`
+ CoOwningReference uint64 `json:"co_owning_reference"`
+ VectorOfCoOwningReferences []uint64 `json:"vector_of_co_owning_references"`
+ NonOwningReference uint64 `json:"non_owning_reference"`
+ VectorOfNonOwningReferences []uint64 `json:"vector_of_non_owning_references"`
+ AnyUnique *AnyUniqueAliasesT `json:"any_unique"`
+ AnyAmbiguous *AnyAmbiguousAliasesT `json:"any_ambiguous"`
+ VectorOfEnums []Color `json:"vector_of_enums"`
+ SignedEnum Race `json:"signed_enum"`
+ Testrequirednestedflatbuffer []byte `json:"testrequirednestedflatbuffer"`
+ ScalarKeySortedTables []*StatT `json:"scalar_key_sorted_tables"`
+ NativeInline *TestT `json:"native_inline"`
+ LongEnumNonEnumDefault LongEnum `json:"long_enum_non_enum_default"`
+ LongEnumNormalDefault LongEnum `json:"long_enum_normal_default"`
}
func (t *MonsterT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
diff --git a/tests/MyGame/Example/Monster.java b/tests/MyGame/Example/Monster.java
index aeae257..5339054 100644
--- a/tests/MyGame/Example/Monster.java
+++ b/tests/MyGame/Example/Monster.java
@@ -12,7 +12,7 @@
*/
@SuppressWarnings("unused")
public final class Monster extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static Monster getRootAsMonster(ByteBuffer _bb) { return getRootAsMonster(_bb, new Monster()); }
public static Monster getRootAsMonster(ByteBuffer _bb, Monster obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public static boolean MonsterBufferHasIdentifier(ByteBuffer _bb) { return __has_identifier(_bb, "MONS"); }
@@ -221,7 +221,7 @@
public static void addPos(FlatBufferBuilder builder, int posOffset) { builder.addStruct(0, posOffset, 0); }
public static void addMana(FlatBufferBuilder builder, short mana) { builder.addShort(1, mana, 150); }
public static void addHp(FlatBufferBuilder builder, short hp) { builder.addShort(2, hp, 100); }
- public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(3, nameOffset, 0); }
+ public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(nameOffset); builder.slot(3); }
public static void addInventory(FlatBufferBuilder builder, int inventoryOffset) { builder.addOffset(5, inventoryOffset, 0); }
public static int createInventoryVector(FlatBufferBuilder builder, byte[] data) { return builder.createByteVector(data); }
public static int createInventoryVector(FlatBufferBuilder builder, ByteBuffer data) { return builder.createByteVector(data); }
@@ -549,8 +549,9 @@
int _test4 = 0;
MyGame.Example.TestT[] _oTest4 = _o.getTest4();
if (_oTest4 != null) {
+ int _unused_offset = 0;
startTest4Vector(builder, _oTest4.length);
- for (int _j = _oTest4.length - 1; _j >=0; _j--) { MyGame.Example.Test.pack(builder, _oTest4[_j]);}
+ for (int _j = _oTest4.length - 1; _j >=0; _j--) { _unused_offset = MyGame.Example.Test.pack(builder, _oTest4[_j]);}
_test4 = builder.endVector();
}
int _testarrayofstring = 0;
@@ -590,8 +591,9 @@
int _testarrayofsortedstruct = 0;
MyGame.Example.AbilityT[] _oTestarrayofsortedstruct = _o.getTestarrayofsortedstruct();
if (_oTestarrayofsortedstruct != null) {
+ int _unused_offset = 0;
startTestarrayofsortedstructVector(builder, _oTestarrayofsortedstruct.length);
- for (int _j = _oTestarrayofsortedstruct.length - 1; _j >=0; _j--) { MyGame.Example.Ability.pack(builder, _oTestarrayofsortedstruct[_j]);}
+ for (int _j = _oTestarrayofsortedstruct.length - 1; _j >=0; _j--) { _unused_offset = MyGame.Example.Ability.pack(builder, _oTestarrayofsortedstruct[_j]);}
_testarrayofsortedstruct = builder.endVector();
}
int _flex = 0;
@@ -604,8 +606,9 @@
int _test5 = 0;
MyGame.Example.TestT[] _oTest5 = _o.getTest5();
if (_oTest5 != null) {
+ int _unused_offset = 0;
startTest5Vector(builder, _oTest5.length);
- for (int _j = _oTest5.length - 1; _j >=0; _j--) { MyGame.Example.Test.pack(builder, _oTest5[_j]);}
+ for (int _j = _oTest5.length - 1; _j >=0; _j--) { _unused_offset = MyGame.Example.Test.pack(builder, _oTest5[_j]);}
_test5 = builder.endVector();
}
int _vectorOfLongs = 0;
@@ -616,7 +619,7 @@
if (_o.getVectorOfDoubles() != null) {
_vectorOfDoubles = createVectorOfDoublesVector(builder, _o.getVectorOfDoubles());
}
- int _parent_namespace_test = _o.getParentNamespaceTest() == null ? 0 : MyGame.InParentNamespace.pack(builder, _o.getParentNamespaceTest());
+ int _parentNamespaceTest = _o.getParentNamespaceTest() == null ? 0 : MyGame.InParentNamespace.pack(builder, _o.getParentNamespaceTest());
int _vectorOfReferrables = 0;
if (_o.getVectorOfReferrables() != null) {
int[] __vectorOfReferrables = new int[_o.getVectorOfReferrables().length];
@@ -702,7 +705,7 @@
addTest5(builder, _test5);
addVectorOfLongs(builder, _vectorOfLongs);
addVectorOfDoubles(builder, _vectorOfDoubles);
- addParentNamespaceTest(builder, _parent_namespace_test);
+ addParentNamespaceTest(builder, _parentNamespaceTest);
addVectorOfReferrables(builder, _vectorOfReferrables);
addSingleWeakReference(builder, _o.getSingleWeakReference());
addVectorOfWeakReferences(builder, _vectorOfWeakReferences);
diff --git a/tests/MyGame/Example/Monster.kt b/tests/MyGame/Example/Monster.kt
index 1abe05c..fecf665 100644
--- a/tests/MyGame/Example/Monster.kt
+++ b/tests/MyGame/Example/Monster.kt
@@ -874,7 +874,7 @@
return compareStrings(__offset(10, o1, _bb), __offset(10, o2, _bb), _bb)
}
companion object {
- fun validateVersion() = Constants.FLATBUFFERS_2_0_0()
+ fun validateVersion() = Constants.FLATBUFFERS_2_0_8()
fun getRootAsMonster(_bb: ByteBuffer): Monster = getRootAsMonster(_bb, Monster())
fun getRootAsMonster(_bb: ByteBuffer, obj: Monster): Monster {
_bb.order(ByteOrder.LITTLE_ENDIAN)
@@ -885,7 +885,10 @@
fun addPos(builder: FlatBufferBuilder, pos: Int) = builder.addStruct(0, pos, 0)
fun addMana(builder: FlatBufferBuilder, mana: Short) = builder.addShort(1, mana, 150)
fun addHp(builder: FlatBufferBuilder, hp: Short) = builder.addShort(2, hp, 100)
- fun addName(builder: FlatBufferBuilder, name: Int) = builder.addOffset(3, name, 0)
+ fun addName(builder: FlatBufferBuilder, name: Int) {
+ builder.addOffset(name)
+ builder.slot(3)
+ }
fun addInventory(builder: FlatBufferBuilder, inventory: Int) = builder.addOffset(5, inventory, 0)
fun createInventoryVector(builder: FlatBufferBuilder, data: UByteArray) : Int {
builder.startVector(1, data.size, 1)
diff --git a/tests/MyGame/Example/Monster.lua b/tests/MyGame/Example/Monster.lua
index 75108e5..6697c9b 100644
--- a/tests/MyGame/Example/Monster.lua
+++ b/tests/MyGame/Example/Monster.lua
@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
- flatc version: 2.0.6
+ flatc version: 2.0.8
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
diff --git a/tests/MyGame/Example/NestedStruct.cs b/tests/MyGame/Example/NestedStruct.cs
index f323342..78173ac 100644
--- a/tests/MyGame/Example/NestedStruct.cs
+++ b/tests/MyGame/Example/NestedStruct.cs
@@ -7,7 +7,7 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
public struct NestedStruct : IFlatbufferObject
{
diff --git a/tests/MyGame/Example/Race.lua b/tests/MyGame/Example/Race.lua
index f241870..7aa37e5 100644
--- a/tests/MyGame/Example/Race.lua
+++ b/tests/MyGame/Example/Race.lua
@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
- flatc version: 2.0.6
+ flatc version: 2.0.8
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
diff --git a/tests/MyGame/Example/Referrable.cs b/tests/MyGame/Example/Referrable.cs
index e6f3146..a9b59c4 100644
--- a/tests/MyGame/Example/Referrable.cs
+++ b/tests/MyGame/Example/Referrable.cs
@@ -7,13 +7,13 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
public struct Referrable : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
- public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_8(); }
public static Referrable GetRootAsReferrable(ByteBuffer _bb) { return GetRootAsReferrable(_bb, new Referrable()); }
public static Referrable GetRootAsReferrable(ByteBuffer _bb, Referrable obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public void __init(int _i, ByteBuffer _bb) { __p = new Table(_i, _bb); }
@@ -37,17 +37,21 @@
}
public static VectorOffset CreateSortedVectorOfReferrable(FlatBufferBuilder builder, Offset<Referrable>[] offsets) {
- Array.Sort(offsets, (Offset<Referrable> o1, Offset<Referrable> o2) => builder.DataBuffer.GetUlong(Table.__offset(4, o1.Value, builder.DataBuffer)).CompareTo(builder.DataBuffer.GetUlong(Table.__offset(4, o2.Value, builder.DataBuffer))));
+ Array.Sort(offsets,
+ (Offset<Referrable> o1, Offset<Referrable> o2) =>
+ new Referrable().__assign(builder.DataBuffer.Length - o1.Value, builder.DataBuffer).Id.CompareTo(new Referrable().__assign(builder.DataBuffer.Length - o2.Value, builder.DataBuffer).Id));
return builder.CreateVectorOfTables(offsets);
}
public static Referrable? __lookup_by_key(int vectorLocation, ulong key, ByteBuffer bb) {
+ Referrable obj_ = new Referrable();
int span = bb.GetInt(vectorLocation - 4);
int start = 0;
while (span != 0) {
int middle = span / 2;
int tableOffset = Table.__indirect(vectorLocation + 4 * (start + middle), bb);
- int comp = bb.GetUlong(Table.__offset(4, bb.Length - tableOffset, bb)).CompareTo(key);
+ obj_.__assign(tableOffset, bb);
+ int comp = obj_.Id.CompareTo(key);
if (comp > 0) {
span = middle;
} else if (comp < 0) {
@@ -55,7 +59,7 @@
start += middle;
span -= middle;
} else {
- return new Referrable().__assign(tableOffset, bb);
+ return obj_;
}
}
return null;
diff --git a/tests/MyGame/Example/Referrable.go b/tests/MyGame/Example/Referrable.go
index 66c5972..aa27079 100644
--- a/tests/MyGame/Example/Referrable.go
+++ b/tests/MyGame/Example/Referrable.go
@@ -7,7 +7,7 @@
)
type ReferrableT struct {
- Id uint64
+ Id uint64 `json:"id"`
}
func (t *ReferrableT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
diff --git a/tests/MyGame/Example/Referrable.java b/tests/MyGame/Example/Referrable.java
index da8dea6..f28d6cb 100644
--- a/tests/MyGame/Example/Referrable.java
+++ b/tests/MyGame/Example/Referrable.java
@@ -9,7 +9,7 @@
@SuppressWarnings("unused")
public final class Referrable extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static Referrable getRootAsReferrable(ByteBuffer _bb) { return getRootAsReferrable(_bb, new Referrable()); }
public static Referrable getRootAsReferrable(ByteBuffer _bb, Referrable obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
@@ -26,7 +26,7 @@
}
public static void startReferrable(FlatBufferBuilder builder) { builder.startTable(1); }
- public static void addId(FlatBufferBuilder builder, long id) { builder.addLong(0, id, 0L); }
+ public static void addId(FlatBufferBuilder builder, long id) { builder.addLong(id); builder.slot(0); }
public static int endReferrable(FlatBufferBuilder builder) {
int o = builder.endTable();
return o;
diff --git a/tests/MyGame/Example/Referrable.kt b/tests/MyGame/Example/Referrable.kt
index 7f728a7..6d4b63e 100644
--- a/tests/MyGame/Example/Referrable.kt
+++ b/tests/MyGame/Example/Referrable.kt
@@ -36,7 +36,7 @@
return (val_1 - val_2).sign
}
companion object {
- fun validateVersion() = Constants.FLATBUFFERS_2_0_0()
+ fun validateVersion() = Constants.FLATBUFFERS_2_0_8()
fun getRootAsReferrable(_bb: ByteBuffer): Referrable = getRootAsReferrable(_bb, Referrable())
fun getRootAsReferrable(_bb: ByteBuffer, obj: Referrable): Referrable {
_bb.order(ByteOrder.LITTLE_ENDIAN)
@@ -48,7 +48,10 @@
return endReferrable(builder)
}
fun startReferrable(builder: FlatBufferBuilder) = builder.startTable(1)
- fun addId(builder: FlatBufferBuilder, id: ULong) = builder.addLong(0, id.toLong(), 0)
+ fun addId(builder: FlatBufferBuilder, id: ULong) {
+ builder.addLong(id.toLong())
+ builder.slot(0)
+ }
fun endReferrable(builder: FlatBufferBuilder) : Int {
val o = builder.endTable()
return o
diff --git a/tests/MyGame/Example/Referrable.lua b/tests/MyGame/Example/Referrable.lua
index 3bd6b0a..1911906 100644
--- a/tests/MyGame/Example/Referrable.lua
+++ b/tests/MyGame/Example/Referrable.lua
@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
- flatc version: 2.0.6
+ flatc version: 2.0.8
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
diff --git a/tests/MyGame/Example/Stat.cs b/tests/MyGame/Example/Stat.cs
index 149b136..32c05dc 100644
--- a/tests/MyGame/Example/Stat.cs
+++ b/tests/MyGame/Example/Stat.cs
@@ -7,13 +7,13 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
public struct Stat : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
- public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_8(); }
public static Stat GetRootAsStat(ByteBuffer _bb) { return GetRootAsStat(_bb, new Stat()); }
public static Stat GetRootAsStat(ByteBuffer _bb, Stat obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public void __init(int _i, ByteBuffer _bb) { __p = new Table(_i, _bb); }
@@ -52,17 +52,21 @@
}
public static VectorOffset CreateSortedVectorOfStat(FlatBufferBuilder builder, Offset<Stat>[] offsets) {
- Array.Sort(offsets, (Offset<Stat> o1, Offset<Stat> o2) => builder.DataBuffer.GetUshort(Table.__offset(8, o1.Value, builder.DataBuffer)).CompareTo(builder.DataBuffer.GetUshort(Table.__offset(8, o2.Value, builder.DataBuffer))));
+ Array.Sort(offsets,
+ (Offset<Stat> o1, Offset<Stat> o2) =>
+ new Stat().__assign(builder.DataBuffer.Length - o1.Value, builder.DataBuffer).Count.CompareTo(new Stat().__assign(builder.DataBuffer.Length - o2.Value, builder.DataBuffer).Count));
return builder.CreateVectorOfTables(offsets);
}
public static Stat? __lookup_by_key(int vectorLocation, ushort key, ByteBuffer bb) {
+ Stat obj_ = new Stat();
int span = bb.GetInt(vectorLocation - 4);
int start = 0;
while (span != 0) {
int middle = span / 2;
int tableOffset = Table.__indirect(vectorLocation + 4 * (start + middle), bb);
- int comp = bb.GetUshort(Table.__offset(8, bb.Length - tableOffset, bb)).CompareTo(key);
+ obj_.__assign(tableOffset, bb);
+ int comp = obj_.Count.CompareTo(key);
if (comp > 0) {
span = middle;
} else if (comp < 0) {
@@ -70,7 +74,7 @@
start += middle;
span -= middle;
} else {
- return new Stat().__assign(tableOffset, bb);
+ return obj_;
}
}
return null;
diff --git a/tests/MyGame/Example/Stat.go b/tests/MyGame/Example/Stat.go
index 5c060d1..7149640 100644
--- a/tests/MyGame/Example/Stat.go
+++ b/tests/MyGame/Example/Stat.go
@@ -7,9 +7,9 @@
)
type StatT struct {
- Id string
- Val int64
- Count uint16
+ Id string `json:"id"`
+ Val int64 `json:"val"`
+ Count uint16 `json:"count"`
}
func (t *StatT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
diff --git a/tests/MyGame/Example/Stat.java b/tests/MyGame/Example/Stat.java
index efc2673..3044421 100644
--- a/tests/MyGame/Example/Stat.java
+++ b/tests/MyGame/Example/Stat.java
@@ -9,7 +9,7 @@
@SuppressWarnings("unused")
public final class Stat extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static Stat getRootAsStat(ByteBuffer _bb) { return getRootAsStat(_bb, new Stat()); }
public static Stat getRootAsStat(ByteBuffer _bb, Stat obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
@@ -37,7 +37,7 @@
public static void startStat(FlatBufferBuilder builder) { builder.startTable(3); }
public static void addId(FlatBufferBuilder builder, int idOffset) { builder.addOffset(0, idOffset, 0); }
public static void addVal(FlatBufferBuilder builder, long val) { builder.addLong(1, val, 0L); }
- public static void addCount(FlatBufferBuilder builder, int count) { builder.addShort(2, (short) count, (short) 0); }
+ public static void addCount(FlatBufferBuilder builder, int count) { builder.addShort((short) count); builder.slot(2); }
public static int endStat(FlatBufferBuilder builder) {
int o = builder.endTable();
return o;
diff --git a/tests/MyGame/Example/Stat.kt b/tests/MyGame/Example/Stat.kt
index e6cc94c..ef6f31f 100644
--- a/tests/MyGame/Example/Stat.kt
+++ b/tests/MyGame/Example/Stat.kt
@@ -57,7 +57,7 @@
return (val_1 - val_2).sign
}
companion object {
- fun validateVersion() = Constants.FLATBUFFERS_2_0_0()
+ fun validateVersion() = Constants.FLATBUFFERS_2_0_8()
fun getRootAsStat(_bb: ByteBuffer): Stat = getRootAsStat(_bb, Stat())
fun getRootAsStat(_bb: ByteBuffer, obj: Stat): Stat {
_bb.order(ByteOrder.LITTLE_ENDIAN)
@@ -73,7 +73,10 @@
fun startStat(builder: FlatBufferBuilder) = builder.startTable(3)
fun addId(builder: FlatBufferBuilder, id: Int) = builder.addOffset(0, id, 0)
fun addVal_(builder: FlatBufferBuilder, val_: Long) = builder.addLong(1, val_, 0L)
- fun addCount(builder: FlatBufferBuilder, count: UShort) = builder.addShort(2, count.toShort(), 0)
+ fun addCount(builder: FlatBufferBuilder, count: UShort) {
+ builder.addShort(count.toShort())
+ builder.slot(2)
+ }
fun endStat(builder: FlatBufferBuilder) : Int {
val o = builder.endTable()
return o
diff --git a/tests/MyGame/Example/Stat.lua b/tests/MyGame/Example/Stat.lua
index f621fd0..bf5704b 100644
--- a/tests/MyGame/Example/Stat.lua
+++ b/tests/MyGame/Example/Stat.lua
@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
- flatc version: 2.0.6
+ flatc version: 2.0.8
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
diff --git a/tests/MyGame/Example/StructOfStructs.cs b/tests/MyGame/Example/StructOfStructs.cs
index 3a1607d..955aeab 100644
--- a/tests/MyGame/Example/StructOfStructs.cs
+++ b/tests/MyGame/Example/StructOfStructs.cs
@@ -7,7 +7,7 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
public struct StructOfStructs : IFlatbufferObject
{
diff --git a/tests/MyGame/Example/StructOfStructs.go b/tests/MyGame/Example/StructOfStructs.go
index 35ccfcb..22281b6 100644
--- a/tests/MyGame/Example/StructOfStructs.go
+++ b/tests/MyGame/Example/StructOfStructs.go
@@ -7,9 +7,9 @@
)
type StructOfStructsT struct {
- A *AbilityT
- B *TestT
- C *AbilityT
+ A *AbilityT `json:"a"`
+ B *TestT `json:"b"`
+ C *AbilityT `json:"c"`
}
func (t *StructOfStructsT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
diff --git a/tests/MyGame/Example/StructOfStructs.lua b/tests/MyGame/Example/StructOfStructs.lua
index 7f56b34..be0148b 100644
--- a/tests/MyGame/Example/StructOfStructs.lua
+++ b/tests/MyGame/Example/StructOfStructs.lua
@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
- flatc version: 2.0.6
+ flatc version: 2.0.8
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
diff --git a/tests/MyGame/Example/StructOfStructsOfStructs.cs b/tests/MyGame/Example/StructOfStructsOfStructs.cs
new file mode 100644
index 0000000..90cfc29
--- /dev/null
+++ b/tests/MyGame/Example/StructOfStructsOfStructs.cs
@@ -0,0 +1,74 @@
+// <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 StructOfStructsOfStructs : IFlatbufferObject
+{
+ private Struct __p;
+ public ByteBuffer ByteBuffer { get { return __p.bb; } }
+ public void __init(int _i, ByteBuffer _bb) { __p = new Struct(_i, _bb); }
+ public StructOfStructsOfStructs __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
+
+ public MyGame.Example.StructOfStructs A { get { return (new MyGame.Example.StructOfStructs()).__assign(__p.bb_pos + 0, __p.bb); } }
+
+ public static Offset<MyGame.Example.StructOfStructsOfStructs> CreateStructOfStructsOfStructs(FlatBufferBuilder builder, uint a_a_Id, uint a_a_Distance, short a_b_A, sbyte a_b_B, uint a_c_Id, uint a_c_Distance) {
+ builder.Prep(4, 20);
+ builder.Prep(4, 20);
+ builder.Prep(4, 8);
+ builder.PutUint(a_c_Distance);
+ builder.PutUint(a_c_Id);
+ builder.Prep(2, 4);
+ builder.Pad(1);
+ builder.PutSbyte(a_b_B);
+ builder.PutShort(a_b_A);
+ builder.Prep(4, 8);
+ builder.PutUint(a_a_Distance);
+ builder.PutUint(a_a_Id);
+ return new Offset<MyGame.Example.StructOfStructsOfStructs>(builder.Offset);
+ }
+ public StructOfStructsOfStructsT UnPack() {
+ var _o = new StructOfStructsOfStructsT();
+ this.UnPackTo(_o);
+ return _o;
+ }
+ public void UnPackTo(StructOfStructsOfStructsT _o) {
+ _o.A = this.A.UnPack();
+ }
+ public static Offset<MyGame.Example.StructOfStructsOfStructs> Pack(FlatBufferBuilder builder, StructOfStructsOfStructsT _o) {
+ if (_o == null) return default(Offset<MyGame.Example.StructOfStructsOfStructs>);
+ var _a_a_id = _o.A.A.Id;
+ var _a_a_distance = _o.A.A.Distance;
+ var _a_b_a = _o.A.B.A;
+ var _a_b_b = _o.A.B.B;
+ var _a_c_id = _o.A.C.Id;
+ var _a_c_distance = _o.A.C.Distance;
+ return CreateStructOfStructsOfStructs(
+ builder,
+ _a_a_id,
+ _a_a_distance,
+ _a_b_a,
+ _a_b_b,
+ _a_c_id,
+ _a_c_distance);
+ }
+}
+
+public class StructOfStructsOfStructsT
+{
+ [Newtonsoft.Json.JsonProperty("a")]
+ public MyGame.Example.StructOfStructsT A { get; set; }
+
+ public StructOfStructsOfStructsT() {
+ this.A = new MyGame.Example.StructOfStructsT();
+ }
+}
+
+
+}
diff --git a/tests/MyGame/Example/StructOfStructsOfStructs.go b/tests/MyGame/Example/StructOfStructsOfStructs.go
new file mode 100644
index 0000000..b8f32a0
--- /dev/null
+++ b/tests/MyGame/Example/StructOfStructsOfStructs.go
@@ -0,0 +1,63 @@
+// Code generated by the FlatBuffers compiler. DO NOT EDIT.
+
+package Example
+
+import (
+ flatbuffers "github.com/google/flatbuffers/go"
+)
+
+type StructOfStructsOfStructsT struct {
+ A *StructOfStructsT `json:"a"`
+}
+
+func (t *StructOfStructsOfStructsT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
+ if t == nil { return 0 }
+ return CreateStructOfStructsOfStructs(builder, t.A.A.Id, t.A.A.Distance, t.A.B.A, t.A.B.B, t.A.C.Id, t.A.C.Distance)
+}
+func (rcv *StructOfStructsOfStructs) UnPackTo(t *StructOfStructsOfStructsT) {
+ t.A = rcv.A(nil).UnPack()
+}
+
+func (rcv *StructOfStructsOfStructs) UnPack() *StructOfStructsOfStructsT {
+ if rcv == nil { return nil }
+ t := &StructOfStructsOfStructsT{}
+ rcv.UnPackTo(t)
+ return t
+}
+
+type StructOfStructsOfStructs struct {
+ _tab flatbuffers.Struct
+}
+
+func (rcv *StructOfStructsOfStructs) Init(buf []byte, i flatbuffers.UOffsetT) {
+ rcv._tab.Bytes = buf
+ rcv._tab.Pos = i
+}
+
+func (rcv *StructOfStructsOfStructs) Table() flatbuffers.Table {
+ return rcv._tab.Table
+}
+
+func (rcv *StructOfStructsOfStructs) A(obj *StructOfStructs) *StructOfStructs {
+ if obj == nil {
+ obj = new(StructOfStructs)
+ }
+ obj.Init(rcv._tab.Bytes, rcv._tab.Pos+0)
+ return obj
+}
+
+func CreateStructOfStructsOfStructs(builder *flatbuffers.Builder, a_a_id uint32, a_a_distance uint32, a_b_a int16, a_b_b int8, a_c_id uint32, a_c_distance uint32) flatbuffers.UOffsetT {
+ builder.Prep(4, 20)
+ builder.Prep(4, 20)
+ builder.Prep(4, 8)
+ builder.PrependUint32(a_c_distance)
+ builder.PrependUint32(a_c_id)
+ builder.Prep(2, 4)
+ builder.Pad(1)
+ builder.PrependInt8(a_b_b)
+ builder.PrependInt16(a_b_a)
+ builder.Prep(4, 8)
+ builder.PrependUint32(a_a_distance)
+ builder.PrependUint32(a_a_id)
+ return builder.Offset()
+}
diff --git a/tests/MyGame/Example/StructOfStructsOfStructs.java b/tests/MyGame/Example/StructOfStructsOfStructs.java
new file mode 100644
index 0000000..5d5f00f
--- /dev/null
+++ b/tests/MyGame/Example/StructOfStructsOfStructs.java
@@ -0,0 +1,66 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+package MyGame.Example;
+
+import java.nio.*;
+import java.lang.*;
+import java.util.*;
+import com.google.flatbuffers.*;
+
+@SuppressWarnings("unused")
+public final class StructOfStructsOfStructs extends Struct {
+ public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
+ public StructOfStructsOfStructs __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
+
+ public MyGame.Example.StructOfStructs a() { return a(new MyGame.Example.StructOfStructs()); }
+ public MyGame.Example.StructOfStructs a(MyGame.Example.StructOfStructs obj) { return obj.__assign(bb_pos + 0, bb); }
+
+ public static int createStructOfStructsOfStructs(FlatBufferBuilder builder, long a_a_id, long a_a_distance, short a_b_a, byte a_b_b, long a_c_id, long a_c_distance) {
+ builder.prep(4, 20);
+ builder.prep(4, 20);
+ builder.prep(4, 8);
+ builder.putInt((int) a_c_distance);
+ builder.putInt((int) a_c_id);
+ builder.prep(2, 4);
+ builder.pad(1);
+ builder.putByte(a_b_b);
+ builder.putShort(a_b_a);
+ builder.prep(4, 8);
+ builder.putInt((int) a_a_distance);
+ builder.putInt((int) a_a_id);
+ 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 StructOfStructsOfStructs get(int j) { return get(new StructOfStructsOfStructs(), j); }
+ public StructOfStructsOfStructs get(StructOfStructsOfStructs obj, int j) { return obj.__assign(__element(j), bb); }
+ }
+ public StructOfStructsOfStructsT unpack() {
+ StructOfStructsOfStructsT _o = new StructOfStructsOfStructsT();
+ unpackTo(_o);
+ return _o;
+ }
+ public void unpackTo(StructOfStructsOfStructsT _o) {
+ a().unpackTo(_o.getA());
+ }
+ public static int pack(FlatBufferBuilder builder, StructOfStructsOfStructsT _o) {
+ if (_o == null) return 0;
+ int _a_a_id = _o.getA().getA().getId();
+ int _a_a_distance = _o.getA().getA().getDistance();
+ short _a_b_a = _o.getA().getB().getA();
+ byte _a_b_b = _o.getA().getB().getB();
+ int _a_c_id = _o.getA().getC().getId();
+ int _a_c_distance = _o.getA().getC().getDistance();
+ return createStructOfStructsOfStructs(
+ builder,
+ _a_a_id,
+ _a_a_distance,
+ _a_b_a,
+ _a_b_b,
+ _a_c_id,
+ _a_c_distance);
+ }
+}
+
diff --git a/tests/MyGame/Example/StructOfStructsOfStructs.kt b/tests/MyGame/Example/StructOfStructsOfStructs.kt
new file mode 100644
index 0000000..955b600
--- /dev/null
+++ b/tests/MyGame/Example/StructOfStructsOfStructs.kt
@@ -0,0 +1,38 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+package MyGame.Example
+
+import java.nio.*
+import kotlin.math.sign
+import com.google.flatbuffers.*
+
+@Suppress("unused")
+class StructOfStructsOfStructs : Struct() {
+
+ fun __init(_i: Int, _bb: ByteBuffer) {
+ __reset(_i, _bb)
+ }
+ fun __assign(_i: Int, _bb: ByteBuffer) : StructOfStructsOfStructs {
+ __init(_i, _bb)
+ return this
+ }
+ val a : MyGame.Example.StructOfStructs? get() = a(MyGame.Example.StructOfStructs())
+ fun a(obj: MyGame.Example.StructOfStructs) : MyGame.Example.StructOfStructs? = obj.__assign(bb_pos + 0, bb)
+ companion object {
+ fun createStructOfStructsOfStructs(builder: FlatBufferBuilder, a_a_id: UInt, a_a_distance: UInt, a_b_a: Short, a_b_b: Byte, a_c_id: UInt, a_c_distance: UInt) : Int {
+ builder.prep(4, 20)
+ builder.prep(4, 20)
+ builder.prep(4, 8)
+ builder.putInt(a_c_distance.toInt())
+ builder.putInt(a_c_id.toInt())
+ builder.prep(2, 4)
+ builder.pad(1)
+ builder.putByte(a_b_b)
+ builder.putShort(a_b_a)
+ builder.prep(4, 8)
+ builder.putInt(a_a_distance.toInt())
+ builder.putInt(a_a_id.toInt())
+ return builder.offset()
+ }
+ }
+}
diff --git a/tests/MyGame/Example/StructOfStructsOfStructs.lua b/tests/MyGame/Example/StructOfStructsOfStructs.lua
new file mode 100644
index 0000000..f8587c1
--- /dev/null
+++ b/tests/MyGame/Example/StructOfStructsOfStructs.lua
@@ -0,0 +1,49 @@
+--[[ MyGame.Example.StructOfStructsOfStructs
+
+ Automatically generated by the FlatBuffers compiler, do not modify.
+ Or modify. I'm a message, not a cop.
+
+ flatc version: 2.0.8
+
+ Declared by : //monster_test.fbs
+ Rooting type : MyGame.Example.Monster (//monster_test.fbs)
+
+--]]
+
+local flatbuffers = require('flatbuffers')
+
+local StructOfStructsOfStructs = {}
+local mt = {}
+
+function StructOfStructsOfStructs.New()
+ local o = {}
+ setmetatable(o, {__index = mt})
+ return o
+end
+
+function mt:Init(buf, pos)
+ self.view = flatbuffers.view.New(buf, pos)
+end
+
+function mt:A(obj)
+ obj:Init(self.view.bytes, self.view.pos + 0)
+ return obj
+end
+
+function StructOfStructsOfStructs.CreateStructOfStructsOfStructs(builder, a_a_id, a_a_distance, a_b_a, a_b_b, a_c_id, a_c_distance)
+ builder:Prep(4, 20)
+ builder:Prep(4, 20)
+ builder:Prep(4, 8)
+ builder:PrependUint32(a_c_distance)
+ builder:PrependUint32(a_c_id)
+ builder:Prep(2, 4)
+ builder:Pad(1)
+ builder:PrependInt8(a_b_b)
+ builder:PrependInt16(a_b_a)
+ builder:Prep(4, 8)
+ builder:PrependUint32(a_a_distance)
+ builder:PrependUint32(a_a_id)
+ return builder:Offset()
+end
+
+return StructOfStructsOfStructs
\ No newline at end of file
diff --git a/tests/MyGame/Example/StructOfStructsOfStructs.php b/tests/MyGame/Example/StructOfStructsOfStructs.php
new file mode 100644
index 0000000..bcdcca0
--- /dev/null
+++ b/tests/MyGame/Example/StructOfStructsOfStructs.php
@@ -0,0 +1,55 @@
+<?php
+// automatically generated by the FlatBuffers compiler, do not modify
+
+namespace MyGame\Example;
+
+use \Google\FlatBuffers\Struct;
+use \Google\FlatBuffers\Table;
+use \Google\FlatBuffers\ByteBuffer;
+use \Google\FlatBuffers\FlatBufferBuilder;
+
+class StructOfStructsOfStructs extends Struct
+{
+ /**
+ * @param int $_i offset
+ * @param ByteBuffer $_bb
+ * @return StructOfStructsOfStructs
+ **/
+ public function init($_i, ByteBuffer $_bb)
+ {
+ $this->bb_pos = $_i;
+ $this->bb = $_bb;
+ return $this;
+ }
+
+ /**
+ * @return StructOfStructs
+ */
+ public function getA()
+ {
+ $obj = new StructOfStructs();
+ $obj->init($this->bb_pos + 0, $this->bb);
+ return $obj;
+ }
+
+
+ /**
+ * @return int offset
+ */
+ public static function createStructOfStructsOfStructs(FlatBufferBuilder $builder, $a_a_id, $a_a_distance, $a_b_a, $a_b_b, $a_c_id, $a_c_distance)
+ {
+ $builder->prep(4, 20);
+ $builder->prep(4, 20);
+ $builder->prep(4, 8);
+ $builder->putUint($a_c_distance);
+ $builder->putUint($a_c_id);
+ $builder->prep(2, 4);
+ $builder->pad(1);
+ $builder->putSbyte($a_b_b);
+ $builder->putShort($a_b_a);
+ $builder->prep(4, 8);
+ $builder->putUint($a_a_distance);
+ $builder->putUint($a_a_id);
+ return $builder->offset();
+ }
+}
diff --git a/tests/MyGame/Example/StructOfStructsOfStructs.py b/tests/MyGame/Example/StructOfStructsOfStructs.py
new file mode 100644
index 0000000..edba982
--- /dev/null
+++ b/tests/MyGame/Example/StructOfStructsOfStructs.py
@@ -0,0 +1,74 @@
+# automatically generated by the FlatBuffers compiler, do not modify
+
+# namespace: Example
+
+import flatbuffers
+from flatbuffers.compat import import_numpy
+np = import_numpy()
+
+class StructOfStructsOfStructs(object):
+ __slots__ = ['_tab']
+
+ @classmethod
+ def SizeOf(cls):
+ return 20
+
+ # StructOfStructsOfStructs
+ def Init(self, buf, pos):
+ self._tab = flatbuffers.table.Table(buf, pos)
+
+ # StructOfStructsOfStructs
+ def A(self, obj):
+ obj.Init(self._tab.Bytes, self._tab.Pos + 0)
+ return obj
+
+
+def CreateStructOfStructsOfStructs(builder, a_a_id, a_a_distance, a_b_a, a_b_b, a_c_id, a_c_distance):
+ builder.Prep(4, 20)
+ builder.Prep(4, 20)
+ builder.Prep(4, 8)
+ builder.PrependUint32(a_c_distance)
+ builder.PrependUint32(a_c_id)
+ builder.Prep(2, 4)
+ builder.Pad(1)
+ builder.PrependInt8(a_b_b)
+ builder.PrependInt16(a_b_a)
+ builder.Prep(4, 8)
+ builder.PrependUint32(a_a_distance)
+ builder.PrependUint32(a_a_id)
+ return builder.Offset()
+
+import MyGame.Example.StructOfStructs
+try:
+ from typing import Optional
+except:
+ pass
+
+class StructOfStructsOfStructsT(object):
+
+ # StructOfStructsOfStructsT
+ def __init__(self):
+ self.a = None # type: Optional[MyGame.Example.StructOfStructs.StructOfStructsT]
+
+ @classmethod
+ def InitFromBuf(cls, buf, pos):
+ structOfStructsOfStructs = StructOfStructsOfStructs()
+ structOfStructsOfStructs.Init(buf, pos)
+ return cls.InitFromObj(structOfStructsOfStructs)
+
+ @classmethod
+ def InitFromObj(cls, structOfStructsOfStructs):
+ x = StructOfStructsOfStructsT()
+ x._UnPack(structOfStructsOfStructs)
+ return x
+
+ # StructOfStructsOfStructsT
+ def _UnPack(self, structOfStructsOfStructs):
+ if structOfStructsOfStructs is None:
+ return
+ if structOfStructsOfStructs.A(MyGame.Example.StructOfStructs.StructOfStructs()) is not None:
+ self.a = MyGame.Example.StructOfStructs.StructOfStructsT.InitFromObj(structOfStructsOfStructs.A(MyGame.Example.StructOfStructs.StructOfStructs()))
+
+ # StructOfStructsOfStructsT
+ def Pack(self, builder):
+ return CreateStructOfStructsOfStructs(builder, self.a.a.id, self.a.a.distance, self.a.b.a, self.a.b.b, self.a.c.id, self.a.c.distance)
diff --git a/tests/MyGame/Example/StructOfStructsOfStructsT.java b/tests/MyGame/Example/StructOfStructsOfStructsT.java
new file mode 100644
index 0000000..3f23040
--- /dev/null
+++ b/tests/MyGame/Example/StructOfStructsOfStructsT.java
@@ -0,0 +1,22 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+package MyGame.Example;
+
+import java.nio.*;
+import java.lang.*;
+import java.util.*;
+import com.google.flatbuffers.*;
+
+public class StructOfStructsOfStructsT {
+ private MyGame.Example.StructOfStructsT a;
+
+ public MyGame.Example.StructOfStructsT getA() { return a; }
+
+ public void setA(MyGame.Example.StructOfStructsT a) { this.a = a; }
+
+
+ public StructOfStructsOfStructsT() {
+ this.a = new MyGame.Example.StructOfStructsT();
+ }
+}
+
diff --git a/tests/MyGame/Example/Test.cs b/tests/MyGame/Example/Test.cs
index a805218..68f3354 100644
--- a/tests/MyGame/Example/Test.cs
+++ b/tests/MyGame/Example/Test.cs
@@ -7,7 +7,7 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
public struct Test : IFlatbufferObject
{
diff --git a/tests/MyGame/Example/Test.go b/tests/MyGame/Example/Test.go
index cbf7e29..1491711 100644
--- a/tests/MyGame/Example/Test.go
+++ b/tests/MyGame/Example/Test.go
@@ -7,8 +7,8 @@
)
type TestT struct {
- A int16
- B int8
+ A int16 `json:"a"`
+ B int8 `json:"b"`
}
func (t *TestT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
diff --git a/tests/MyGame/Example/Test.lua b/tests/MyGame/Example/Test.lua
index 63b566c..74217cc 100644
--- a/tests/MyGame/Example/Test.lua
+++ b/tests/MyGame/Example/Test.lua
@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
- flatc version: 2.0.6
+ flatc version: 2.0.8
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
diff --git a/tests/MyGame/Example/TestSimpleTableWithEnum.cs b/tests/MyGame/Example/TestSimpleTableWithEnum.cs
index 99a498b..837ad19 100644
--- a/tests/MyGame/Example/TestSimpleTableWithEnum.cs
+++ b/tests/MyGame/Example/TestSimpleTableWithEnum.cs
@@ -7,13 +7,13 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
internal partial struct TestSimpleTableWithEnum : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
- public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_8(); }
public static TestSimpleTableWithEnum GetRootAsTestSimpleTableWithEnum(ByteBuffer _bb) { return GetRootAsTestSimpleTableWithEnum(_bb, new TestSimpleTableWithEnum()); }
public static TestSimpleTableWithEnum GetRootAsTestSimpleTableWithEnum(ByteBuffer _bb, TestSimpleTableWithEnum obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public void __init(int _i, ByteBuffer _bb) { __p = new Table(_i, _bb); }
diff --git a/tests/MyGame/Example/TestSimpleTableWithEnum.go b/tests/MyGame/Example/TestSimpleTableWithEnum.go
index b8cde12..553867f 100644
--- a/tests/MyGame/Example/TestSimpleTableWithEnum.go
+++ b/tests/MyGame/Example/TestSimpleTableWithEnum.go
@@ -7,7 +7,7 @@
)
type TestSimpleTableWithEnumT struct {
- Color Color
+ Color Color `json:"color"`
}
func (t *TestSimpleTableWithEnumT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
diff --git a/tests/MyGame/Example/TestSimpleTableWithEnum.java b/tests/MyGame/Example/TestSimpleTableWithEnum.java
index 92d0d69..39f9421 100644
--- a/tests/MyGame/Example/TestSimpleTableWithEnum.java
+++ b/tests/MyGame/Example/TestSimpleTableWithEnum.java
@@ -9,7 +9,7 @@
@SuppressWarnings("unused")
final class TestSimpleTableWithEnum extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static TestSimpleTableWithEnum getRootAsTestSimpleTableWithEnum(ByteBuffer _bb) { return getRootAsTestSimpleTableWithEnum(_bb, new TestSimpleTableWithEnum()); }
public static TestSimpleTableWithEnum getRootAsTestSimpleTableWithEnum(ByteBuffer _bb, TestSimpleTableWithEnum obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
diff --git a/tests/MyGame/Example/TestSimpleTableWithEnum.kt b/tests/MyGame/Example/TestSimpleTableWithEnum.kt
index 64bf7e2..cb081fc 100644
--- a/tests/MyGame/Example/TestSimpleTableWithEnum.kt
+++ b/tests/MyGame/Example/TestSimpleTableWithEnum.kt
@@ -31,7 +31,7 @@
}
}
companion object {
- fun validateVersion() = Constants.FLATBUFFERS_2_0_0()
+ fun validateVersion() = Constants.FLATBUFFERS_2_0_8()
fun getRootAsTestSimpleTableWithEnum(_bb: ByteBuffer): TestSimpleTableWithEnum = getRootAsTestSimpleTableWithEnum(_bb, TestSimpleTableWithEnum())
fun getRootAsTestSimpleTableWithEnum(_bb: ByteBuffer, obj: TestSimpleTableWithEnum): TestSimpleTableWithEnum {
_bb.order(ByteOrder.LITTLE_ENDIAN)
diff --git a/tests/MyGame/Example/TestSimpleTableWithEnum.lua b/tests/MyGame/Example/TestSimpleTableWithEnum.lua
index 000e6e1..90dcf79 100644
--- a/tests/MyGame/Example/TestSimpleTableWithEnum.lua
+++ b/tests/MyGame/Example/TestSimpleTableWithEnum.lua
@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
- flatc version: 2.0.6
+ flatc version: 2.0.8
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
diff --git a/tests/MyGame/Example/TypeAliases.cs b/tests/MyGame/Example/TypeAliases.cs
index 1801dc8..f936ad6 100644
--- a/tests/MyGame/Example/TypeAliases.cs
+++ b/tests/MyGame/Example/TypeAliases.cs
@@ -7,13 +7,13 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
public struct TypeAliases : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
- public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_8(); }
public static TypeAliases GetRootAsTypeAliases(ByteBuffer _bb) { return GetRootAsTypeAliases(_bb, new TypeAliases()); }
public static TypeAliases GetRootAsTypeAliases(ByteBuffer _bb, TypeAliases obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public void __init(int _i, ByteBuffer _bb) { __p = new Table(_i, _bb); }
@@ -101,10 +101,14 @@
public static void AddV8(FlatBufferBuilder builder, VectorOffset v8Offset) { builder.AddOffset(10, v8Offset.Value, 0); }
public static VectorOffset CreateV8Vector(FlatBufferBuilder builder, sbyte[] data) { builder.StartVector(1, data.Length, 1); for (int i = data.Length - 1; i >= 0; i--) builder.AddSbyte(data[i]); return builder.EndVector(); }
public static VectorOffset CreateV8VectorBlock(FlatBufferBuilder builder, sbyte[] data) { builder.StartVector(1, data.Length, 1); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateV8VectorBlock(FlatBufferBuilder builder, ArraySegment<sbyte> data) { builder.StartVector(1, data.Count, 1); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateV8VectorBlock(FlatBufferBuilder builder, IntPtr dataPtr, int sizeInBytes) { builder.StartVector(1, sizeInBytes, 1); builder.Add<sbyte>(dataPtr, sizeInBytes); return builder.EndVector(); }
public static void StartV8Vector(FlatBufferBuilder builder, int numElems) { builder.StartVector(1, numElems, 1); }
public static void AddVf64(FlatBufferBuilder builder, VectorOffset vf64Offset) { builder.AddOffset(11, vf64Offset.Value, 0); }
public static VectorOffset CreateVf64Vector(FlatBufferBuilder builder, double[] data) { builder.StartVector(8, data.Length, 8); for (int i = data.Length - 1; i >= 0; i--) builder.AddDouble(data[i]); return builder.EndVector(); }
public static VectorOffset CreateVf64VectorBlock(FlatBufferBuilder builder, double[] data) { builder.StartVector(8, data.Length, 8); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateVf64VectorBlock(FlatBufferBuilder builder, ArraySegment<double> data) { builder.StartVector(8, data.Count, 8); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateVf64VectorBlock(FlatBufferBuilder builder, IntPtr dataPtr, int sizeInBytes) { builder.StartVector(1, sizeInBytes, 1); builder.Add<double>(dataPtr, sizeInBytes); return builder.EndVector(); }
public static void StartVf64Vector(FlatBufferBuilder builder, int numElems) { builder.StartVector(8, numElems, 8); }
public static Offset<MyGame.Example.TypeAliases> EndTypeAliases(FlatBufferBuilder builder) {
int o = builder.EndTable();
diff --git a/tests/MyGame/Example/TypeAliases.go b/tests/MyGame/Example/TypeAliases.go
index d018fa1..9ded35e 100644
--- a/tests/MyGame/Example/TypeAliases.go
+++ b/tests/MyGame/Example/TypeAliases.go
@@ -7,18 +7,18 @@
)
type TypeAliasesT struct {
- I8 int8
- U8 byte
- I16 int16
- U16 uint16
- I32 int32
- U32 uint32
- I64 int64
- U64 uint64
- F32 float32
- F64 float64
- V8 []int8
- Vf64 []float64
+ I8 int8 `json:"i8"`
+ U8 byte `json:"u8"`
+ I16 int16 `json:"i16"`
+ U16 uint16 `json:"u16"`
+ I32 int32 `json:"i32"`
+ U32 uint32 `json:"u32"`
+ I64 int64 `json:"i64"`
+ U64 uint64 `json:"u64"`
+ F32 float32 `json:"f32"`
+ F64 float64 `json:"f64"`
+ V8 []int8 `json:"v8"`
+ Vf64 []float64 `json:"vf64"`
}
func (t *TypeAliasesT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
diff --git a/tests/MyGame/Example/TypeAliases.java b/tests/MyGame/Example/TypeAliases.java
index db757cc..d91ca65 100644
--- a/tests/MyGame/Example/TypeAliases.java
+++ b/tests/MyGame/Example/TypeAliases.java
@@ -9,7 +9,7 @@
@SuppressWarnings("unused")
public final class TypeAliases extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static TypeAliases getRootAsTypeAliases(ByteBuffer _bb) { return getRootAsTypeAliases(_bb, new TypeAliases()); }
public static TypeAliases getRootAsTypeAliases(ByteBuffer _bb, TypeAliases obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
diff --git a/tests/MyGame/Example/TypeAliases.kt b/tests/MyGame/Example/TypeAliases.kt
index cdc82b5..8a2d80e 100644
--- a/tests/MyGame/Example/TypeAliases.kt
+++ b/tests/MyGame/Example/TypeAliases.kt
@@ -203,7 +203,7 @@
}
}
companion object {
- fun validateVersion() = Constants.FLATBUFFERS_2_0_0()
+ fun validateVersion() = Constants.FLATBUFFERS_2_0_8()
fun getRootAsTypeAliases(_bb: ByteBuffer): TypeAliases = getRootAsTypeAliases(_bb, TypeAliases())
fun getRootAsTypeAliases(_bb: ByteBuffer, obj: TypeAliases): TypeAliases {
_bb.order(ByteOrder.LITTLE_ENDIAN)
diff --git a/tests/MyGame/Example/TypeAliases.lua b/tests/MyGame/Example/TypeAliases.lua
index 111ae3e..cd406c3 100644
--- a/tests/MyGame/Example/TypeAliases.lua
+++ b/tests/MyGame/Example/TypeAliases.lua
@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
- flatc version: 2.0.6
+ flatc version: 2.0.8
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
diff --git a/tests/MyGame/Example/Vec3.cs b/tests/MyGame/Example/Vec3.cs
index 31c9f7e..a4861fa 100644
--- a/tests/MyGame/Example/Vec3.cs
+++ b/tests/MyGame/Example/Vec3.cs
@@ -7,7 +7,7 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
public struct Vec3 : IFlatbufferObject
{
diff --git a/tests/MyGame/Example/Vec3.go b/tests/MyGame/Example/Vec3.go
index 08311ed..16a05cd 100644
--- a/tests/MyGame/Example/Vec3.go
+++ b/tests/MyGame/Example/Vec3.go
@@ -7,12 +7,12 @@
)
type Vec3T struct {
- X float32
- Y float32
- Z float32
- Test1 float64
- Test2 Color
- Test3 *TestT
+ X float32 `json:"x"`
+ Y float32 `json:"y"`
+ Z float32 `json:"z"`
+ Test1 float64 `json:"test1"`
+ Test2 Color `json:"test2"`
+ Test3 *TestT `json:"test3"`
}
func (t *Vec3T) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
diff --git a/tests/MyGame/Example/Vec3.lua b/tests/MyGame/Example/Vec3.lua
index ef51051..796ac7a 100644
--- a/tests/MyGame/Example/Vec3.lua
+++ b/tests/MyGame/Example/Vec3.lua
@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
- flatc version: 2.0.6
+ flatc version: 2.0.8
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
diff --git a/tests/MyGame/Example2/Monster.cs b/tests/MyGame/Example2/Monster.cs
index 3232bd6..af736e7 100644
--- a/tests/MyGame/Example2/Monster.cs
+++ b/tests/MyGame/Example2/Monster.cs
@@ -7,13 +7,13 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
public struct Monster : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
- public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_8(); }
public static Monster GetRootAsMonster(ByteBuffer _bb) { return GetRootAsMonster(_bb, new Monster()); }
public static Monster GetRootAsMonster(ByteBuffer _bb, Monster obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public void __init(int _i, ByteBuffer _bb) { __p = new Table(_i, _bb); }
diff --git a/tests/MyGame/Example2/Monster.java b/tests/MyGame/Example2/Monster.java
index 6323def..8065218 100644
--- a/tests/MyGame/Example2/Monster.java
+++ b/tests/MyGame/Example2/Monster.java
@@ -9,7 +9,7 @@
@SuppressWarnings("unused")
public final class Monster extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static Monster getRootAsMonster(ByteBuffer _bb) { return getRootAsMonster(_bb, new Monster()); }
public static Monster getRootAsMonster(ByteBuffer _bb, Monster obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
diff --git a/tests/MyGame/Example2/Monster.kt b/tests/MyGame/Example2/Monster.kt
index 88b9d05..b5a148f 100644
--- a/tests/MyGame/Example2/Monster.kt
+++ b/tests/MyGame/Example2/Monster.kt
@@ -17,7 +17,7 @@
return this
}
companion object {
- fun validateVersion() = Constants.FLATBUFFERS_2_0_0()
+ fun validateVersion() = Constants.FLATBUFFERS_2_0_8()
fun getRootAsMonster(_bb: ByteBuffer): Monster = getRootAsMonster(_bb, Monster())
fun getRootAsMonster(_bb: ByteBuffer, obj: Monster): Monster {
_bb.order(ByteOrder.LITTLE_ENDIAN)
diff --git a/tests/MyGame/Example2/Monster.lua b/tests/MyGame/Example2/Monster.lua
index 9c33904..ddf4738 100644
--- a/tests/MyGame/Example2/Monster.lua
+++ b/tests/MyGame/Example2/Monster.lua
@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
- flatc version: 2.0.6
+ flatc version: 2.0.8
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
diff --git a/tests/MyGame/InParentNamespace.cs b/tests/MyGame/InParentNamespace.cs
index b266aae..6237e7c 100644
--- a/tests/MyGame/InParentNamespace.cs
+++ b/tests/MyGame/InParentNamespace.cs
@@ -7,13 +7,13 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
public struct InParentNamespace : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
- public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_8(); }
public static InParentNamespace GetRootAsInParentNamespace(ByteBuffer _bb) { return GetRootAsInParentNamespace(_bb, new InParentNamespace()); }
public static InParentNamespace GetRootAsInParentNamespace(ByteBuffer _bb, InParentNamespace obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public void __init(int _i, ByteBuffer _bb) { __p = new Table(_i, _bb); }
diff --git a/tests/MyGame/InParentNamespace.java b/tests/MyGame/InParentNamespace.java
index a3e6819..c525ed5 100644
--- a/tests/MyGame/InParentNamespace.java
+++ b/tests/MyGame/InParentNamespace.java
@@ -9,7 +9,7 @@
@SuppressWarnings("unused")
public final class InParentNamespace extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static InParentNamespace getRootAsInParentNamespace(ByteBuffer _bb) { return getRootAsInParentNamespace(_bb, new InParentNamespace()); }
public static InParentNamespace getRootAsInParentNamespace(ByteBuffer _bb, InParentNamespace obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
diff --git a/tests/MyGame/InParentNamespace.kt b/tests/MyGame/InParentNamespace.kt
index beb414a..7bed058 100644
--- a/tests/MyGame/InParentNamespace.kt
+++ b/tests/MyGame/InParentNamespace.kt
@@ -17,7 +17,7 @@
return this
}
companion object {
- fun validateVersion() = Constants.FLATBUFFERS_2_0_0()
+ fun validateVersion() = Constants.FLATBUFFERS_2_0_8()
fun getRootAsInParentNamespace(_bb: ByteBuffer): InParentNamespace = getRootAsInParentNamespace(_bb, InParentNamespace())
fun getRootAsInParentNamespace(_bb: ByteBuffer, obj: InParentNamespace): InParentNamespace {
_bb.order(ByteOrder.LITTLE_ENDIAN)
diff --git a/tests/MyGame/InParentNamespace.lua b/tests/MyGame/InParentNamespace.lua
index 8112c25..9115666 100644
--- a/tests/MyGame/InParentNamespace.lua
+++ b/tests/MyGame/InParentNamespace.lua
@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
- flatc version: 2.0.6
+ flatc version: 2.0.8
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
diff --git a/tests/MyGame/MonsterExtra.cs b/tests/MyGame/MonsterExtra.cs
index 6af9932..0236856 100644
--- a/tests/MyGame/MonsterExtra.cs
+++ b/tests/MyGame/MonsterExtra.cs
@@ -7,13 +7,13 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
public struct MonsterExtra : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
- public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_8(); }
public static MonsterExtra GetRootAsMonsterExtra(ByteBuffer _bb) { return GetRootAsMonsterExtra(_bb, new MonsterExtra()); }
public static MonsterExtra GetRootAsMonsterExtra(ByteBuffer _bb, MonsterExtra obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public static bool MonsterExtraBufferHasIdentifier(ByteBuffer _bb) { return Table.__has_identifier(_bb, "MONE"); }
@@ -92,10 +92,14 @@
public static void AddDvec(FlatBufferBuilder builder, VectorOffset dvecOffset) { builder.AddOffset(8, dvecOffset.Value, 0); }
public static VectorOffset CreateDvecVector(FlatBufferBuilder builder, double[] data) { builder.StartVector(8, data.Length, 8); for (int i = data.Length - 1; i >= 0; i--) builder.AddDouble(data[i]); return builder.EndVector(); }
public static VectorOffset CreateDvecVectorBlock(FlatBufferBuilder builder, double[] data) { builder.StartVector(8, data.Length, 8); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateDvecVectorBlock(FlatBufferBuilder builder, ArraySegment<double> data) { builder.StartVector(8, data.Count, 8); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateDvecVectorBlock(FlatBufferBuilder builder, IntPtr dataPtr, int sizeInBytes) { builder.StartVector(1, sizeInBytes, 1); builder.Add<double>(dataPtr, sizeInBytes); return builder.EndVector(); }
public static void StartDvecVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(8, numElems, 8); }
public static void AddFvec(FlatBufferBuilder builder, VectorOffset fvecOffset) { builder.AddOffset(9, fvecOffset.Value, 0); }
public static VectorOffset CreateFvecVector(FlatBufferBuilder builder, float[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddFloat(data[i]); return builder.EndVector(); }
public static VectorOffset CreateFvecVectorBlock(FlatBufferBuilder builder, float[] data) { builder.StartVector(4, data.Length, 4); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateFvecVectorBlock(FlatBufferBuilder builder, ArraySegment<float> data) { builder.StartVector(4, data.Count, 4); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateFvecVectorBlock(FlatBufferBuilder builder, IntPtr dataPtr, int sizeInBytes) { builder.StartVector(1, sizeInBytes, 1); builder.Add<float>(dataPtr, sizeInBytes); return builder.EndVector(); }
public static void StartFvecVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
public static Offset<MyGame.MonsterExtra> EndMonsterExtra(FlatBufferBuilder builder) {
int o = builder.EndTable();
diff --git a/tests/MyGame/MonsterExtra.java b/tests/MyGame/MonsterExtra.java
index a2c342d..fdaf40b 100644
--- a/tests/MyGame/MonsterExtra.java
+++ b/tests/MyGame/MonsterExtra.java
@@ -9,7 +9,7 @@
@SuppressWarnings("unused")
public final class MonsterExtra extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static MonsterExtra getRootAsMonsterExtra(ByteBuffer _bb) { return getRootAsMonsterExtra(_bb, new MonsterExtra()); }
public static MonsterExtra getRootAsMonsterExtra(ByteBuffer _bb, MonsterExtra obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public static boolean MonsterExtraBufferHasIdentifier(ByteBuffer _bb) { return __has_identifier(_bb, "MONE"); }
diff --git a/tests/MyGame/MonsterExtra.kt b/tests/MyGame/MonsterExtra.kt
index f222647..3c8760c 100644
--- a/tests/MyGame/MonsterExtra.kt
+++ b/tests/MyGame/MonsterExtra.kt
@@ -175,7 +175,7 @@
}
}
companion object {
- fun validateVersion() = Constants.FLATBUFFERS_2_0_0()
+ fun validateVersion() = Constants.FLATBUFFERS_2_0_8()
fun getRootAsMonsterExtra(_bb: ByteBuffer): MonsterExtra = getRootAsMonsterExtra(_bb, MonsterExtra())
fun getRootAsMonsterExtra(_bb: ByteBuffer, obj: MonsterExtra): MonsterExtra {
_bb.order(ByteOrder.LITTLE_ENDIAN)
diff --git a/tests/MyGame/OtherNameSpace/FromInclude.lua b/tests/MyGame/OtherNameSpace/FromInclude.lua
index 2c2bf0a..64d894e 100644
--- a/tests/MyGame/OtherNameSpace/FromInclude.lua
+++ b/tests/MyGame/OtherNameSpace/FromInclude.lua
@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
- flatc version: 2.0.6
+ flatc version: 2.0.8
Declared by : //include_test/sub/include_test2.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
diff --git a/tests/MyGame/OtherNameSpace/TableB.lua b/tests/MyGame/OtherNameSpace/TableB.lua
index bfa8b03..1f76c88 100644
--- a/tests/MyGame/OtherNameSpace/TableB.lua
+++ b/tests/MyGame/OtherNameSpace/TableB.lua
@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
- flatc version: 2.0.6
+ flatc version: 2.0.8
Declared by : //include_test/sub/include_test2.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
diff --git a/tests/MyGame/OtherNameSpace/Unused.lua b/tests/MyGame/OtherNameSpace/Unused.lua
index 2769625..155a04e 100644
--- a/tests/MyGame/OtherNameSpace/Unused.lua
+++ b/tests/MyGame/OtherNameSpace/Unused.lua
@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
- flatc version: 2.0.6
+ flatc version: 2.0.8
Declared by : //include_test/sub/include_test2.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
diff --git a/tests/TableA.lua b/tests/TableA.lua
index 90b9c95..312f82d 100644
--- a/tests/TableA.lua
+++ b/tests/TableA.lua
@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
- flatc version: 2.0.6
+ flatc version: 2.0.8
Declared by : //include_test/include_test1.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
diff --git a/tests/TestAll.sh b/tests/TestAll.sh
index 06548a2..3a3fcd7 100755
--- a/tests/TestAll.sh
+++ b/tests/TestAll.sh
@@ -16,7 +16,7 @@
echo "************************ TypeScript:"
-sh TypeScriptTest.sh
+python3 TypeScriptTest.py
echo "************************ C++:"
diff --git a/tests/TypeScriptTest.bat b/tests/TypeScriptTest.bat
deleted file mode 100755
index daa5451..0000000
--- a/tests/TypeScriptTest.bat
+++ /dev/null
@@ -1,9 +0,0 @@
-npm install
-../flatc.exe --ts --gen-name-strings --gen-mutable --gen-object-api -I include_test monster_test.fbs
-../flatc.exe --gen-object-api -b -I include_test monster_test.fbs unicode_test.json
-../flatc.exe --ts --gen-name-strings --gen-mutable --gen-object-api -o union_vector union_vector/union_vector.fbs
-../flatc.exe --ts --gen-name-strings optional_scalars.fbs
-tsc
-node -r esm JavaScriptTest
-node -r esm JavaScriptUnionVectorTest
-node -r esm JavaScriptFlexBuffersTest
diff --git a/tests/TypeScriptTest.sh b/tests/TypeScriptTest.sh
deleted file mode 100755
index fd7b82d..0000000
--- a/tests/TypeScriptTest.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/sh
-#
-# Copyright 2016 Google Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-set -e
-
-# clean node_modules to make sure we depend on latest local flatbuffers at ../
-rm -rf node_modules
-npm install
-
-if [ -x ../flatc ]; then
- ../flatc --ts --gen-name-strings --gen-mutable --gen-object-api -I include_test monster_test.fbs
- ../flatc --gen-object-api -b -I include_test monster_test.fbs unicode_test.json
- ../flatc --ts --gen-name-strings --gen-mutable --gen-object-api -o union_vector union_vector/union_vector.fbs
- ../flatc --ts --gen-name-strings optional_scalars.fbs
- ../flatc --ts --gen-name-strings --gen-object-api --gen-mutable -I ../ ./typescript_keywords.fbs test_dir/typescript_include.fbs test_dir/typescript_transitive_include.fbs ../reflection/reflection.fbs
- ../flatc --ts --gen-name-strings --gen-object-api --gen-mutable --ts-flat-files -I ../ ./typescript_keywords.fbs test_dir/typescript_include.fbs test_dir/typescript_transitive_include.fbs ../reflection/reflection.fbs
-fi
-tsc
-node -r esm JavaScriptTest
-node -r esm JavaScriptUnionVectorTest
-node -r esm JavaScriptFlexBuffersTest
diff --git a/tests/annotated_binary/README.md b/tests/annotated_binary/README.md
new file mode 100644
index 0000000..0cb0461
--- /dev/null
+++ b/tests/annotated_binary/README.md
@@ -0,0 +1,101 @@
+# Annotated Flatbuffer Binary
+
+This directory demonstrates the ability of flatc to annotate binary flatbuffers
+with helpful annotations. The resulting annotated flatbuffer binary (afb)
+contains all the binary data with line-by-line annotations.
+
+## Usage
+
+Given a `schema` in either plain-text (.fbs) or already compiled to a binary
+schema (.bfbs) and `binary` file(s) that was created by the `schema`.
+
+```sh
+flatc --annotate {schema_file} -- {binary_file}...
+```
+
+### Example
+
+The following command should produce `annotated_binary.afb` in this directory:
+
+```sh
+cd tests\annotated_binary
+..\..\flatc --annotate annotated_binary.fbs -- annotated_binary.bin
+```
+
+The `annotated_binary.bin` is the flatbufer binary of the data contained within
+ `annotated_binary.json`, which was made by the following command:
+
+```sh
+..\..\flatc -b annotated_binary.fbs annotated_binary.json
+```
+
+## Text Format
+
+Currently there is a built-in text-based format for outputting the annotations.
+The `annotated_binary.afb` is an example of the text format of a binary
+`annotated_binary.bin` and the `annotated_binary.fbs` (or
+`annotated_binary.bfbs`) schema.
+
+The file is ordered in increasing the offsets from the beginning of the binary.
+The offset is the 1st column, expressed in hexadecimal format (e.g. `+0x003c`).
+
+### Binary Sections
+
+Binary sections are comprised of contigious [binary regions](#binary-regions)
+that are logically grouped together. For example, a binary section may be a
+single instance of a flatbuffer `Table` or its `vtable`. The sections may be
+labelled with the name of the associated type, as defined in the input schema.
+
+Example of a `vtable` Binary Section that is associated with the user-defined
+`AnnotateBinary.Bar` table.
+
+```
+vtable (AnnotatedBinary.Bar):
+ +0x00A0 | 08 00 | uint16_t | 0x0008 (8) | size of this vtable
+ +0x00A2 | 13 00 | uint16_t | 0x0013 (19) | size of referring table
+ +0x00A4 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `a` (id: 0)
+ +0x00A6 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+```
+
+### Binary Regions
+
+Binary regions are contigious bytes regions that are grouped together to form
+some sort of value, e.g. a `scalar` or an array of scalars. A binary region may
+be split up over multiple text lines, if the size of the region is large.
+
+Looking at an example binary region:
+
+```
+vtable (AnnotatedBinary.Bar):
+ +0x00A0 | 08 00 | uint16_t | 0x0008 (8) | size of this vtable
+```
+
+The first column (`+0x00A0`) is the offset to this region from the beginning of
+the buffer.
+
+The second column are the raw bytes (hexadecimal) that make up this
+region. These are expressed in the little-endian format that flatbuffers uses
+for the wire format.
+
+The third column is the type to interpret the bytes as. Some types are special
+to flatbuffer internals (e.g. `SOffet32`, `Offset32`, and `VOffset16`) which are
+used by flatbuffers to point to various offsetes. The other types are specified
+as C++-like types which are the standard fix-width scalars. For the above
+example, the type is `uint16_t` which is a 16-bit unsigned integer type.
+
+The fourth column shows the raw bytes as a compacted, big-endian value. The raw
+bytes are duplicated in this fashion since it is more intutive to read the data
+in the big-endian format (e.g., `0x0008`). This value is followed by the decimal
+representation of the value (e.g., `(8)`). (For strings, the raw string value
+is shown instead).
+
+The fifth column is a textual comment on what the value is. As much metadata as
+known is provided.
+
+#### Offsets
+
+If the type in the 3rd column is of an absolute offset (`SOffet32` or
+`Offset32`), the fourth column also shows an `Loc: +0x025A` value which shows
+where in the binary this region is pointing to. These values are absolute from
+the beginning of the file, their calculation from the raw value in the 4th
+column depends on the context.
diff --git a/tests/annotated_binary/annotated_binary.afb b/tests/annotated_binary/annotated_binary.afb
new file mode 100644
index 0000000..6bd84d7
--- /dev/null
+++ b/tests/annotated_binary/annotated_binary.afb
@@ -0,0 +1,297 @@
+// Annotated Flatbuffer Binary
+//
+// Schema file: annotated_binary.fbs
+// Binary file: annotated_binary.bin
+
+header:
+ +0x0000 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x0044 | offset to root table `AnnotatedBinary.Foo`
+ +0x0004 | 41 4E 4E 4F | char[4] | ANNO | File Identifier
+
+padding:
+ +0x0008 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Foo):
+ +0x000A | 3A 00 | uint16_t | 0x003A (58) | size of this vtable
+ +0x000C | 68 00 | uint16_t | 0x0068 (104) | size of referring table
+ +0x000E | 0C 00 | VOffset16 | 0x000C (12) | offset to field `counter` (id: 0)
+ +0x0010 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `healthy` (id: 1)
+ +0x0012 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `level` (id: 2) <defaults to 99> (Long)
+ +0x0014 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `meal` (id: 3)
+ +0x0016 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `bar` (id: 4)
+ +0x0018 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `home` (id: 5)
+ +0x001A | 30 00 | VOffset16 | 0x0030 (48) | offset to field `name` (id: 6)
+ +0x001C | 34 00 | VOffset16 | 0x0034 (52) | offset to field `bars` (id: 7)
+ +0x001E | 09 00 | VOffset16 | 0x0009 (9) | offset to field `bar_baz_type` (id: 8)
+ +0x0020 | 38 00 | VOffset16 | 0x0038 (56) | offset to field `bar_baz` (id: 9)
+ +0x0022 | 3C 00 | VOffset16 | 0x003C (60) | offset to field `accounts` (id: 10)
+ +0x0024 | 40 00 | VOffset16 | 0x0040 (64) | offset to field `bob` (id: 11)
+ +0x0026 | 44 00 | VOffset16 | 0x0044 (68) | offset to field `alice` (id: 12)
+ +0x0028 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `maybe_i32` (id: 13) <defaults to 0> (Int)
+ +0x002A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_i32` (id: 14) <defaults to 42> (Int)
+ +0x002C | 48 00 | VOffset16 | 0x0048 (72) | offset to field `just_i32` (id: 15)
+ +0x002E | 4C 00 | VOffset16 | 0x004C (76) | offset to field `names` (id: 16)
+ +0x0030 | 50 00 | VOffset16 | 0x0050 (80) | offset to field `points_of_interest` (id: 17)
+ +0x0032 | 54 00 | VOffset16 | 0x0054 (84) | offset to field `foobars_type` (id: 18)
+ +0x0034 | 58 00 | VOffset16 | 0x0058 (88) | offset to field `foobars` (id: 19)
+ +0x0036 | 0A 00 | VOffset16 | 0x000A (10) | offset to field `measurement_type` (id: 20)
+ +0x0038 | 5C 00 | VOffset16 | 0x005C (92) | offset to field `measurement` (id: 21)
+ +0x003A | 0B 00 | VOffset16 | 0x000B (11) | offset to field `anything_type` (id: 22)
+ +0x003C | 60 00 | VOffset16 | 0x0060 (96) | offset to field `anything` (id: 23)
+ +0x003E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `temperature` (id: 24) <defaults to 98.600000> (Float)
+ +0x0040 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `teetotaler` (id: 25) <null> (Obj)
+ +0x0042 | 64 00 | VOffset16 | 0x0064 (100) | offset to field `charlie` (id: 26)
+
+root_table (AnnotatedBinary.Foo):
+ +0x0044 | 3A 00 00 00 | SOffset32 | 0x0000003A (58) Loc: +0x000A | offset to vtable
+ +0x0048 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x004B | 01 | uint8_t | 0x01 (1) | table field `healthy` (Bool)
+ +0x004C | 02 | uint8_t | 0x02 (2) | table field `meal` (Byte)
+ +0x004D | 02 | UType8 | 0x02 (2) | table field `bar_baz_type` (UType)
+ +0x004E | 01 | UType8 | 0x01 (1) | table field `measurement_type` (UType)
+ +0x004F | 01 | UType8 | 0x01 (1) | table field `anything_type` (UType)
+ +0x0050 | D2 04 00 00 | uint32_t | 0x000004D2 (1234) | table field `counter` (Int)
+ +0x0054 | 28 02 00 00 | UOffset32 | 0x00000228 (552) Loc: +0x027C | offset to field `bar` (table)
+ +0x0058 | 01 00 00 00 | uint32_t | 0x00000001 (1) | struct field `AnnotatedBinary.Building.floors` (Int)
+ +0x005C | 02 00 00 00 | uint32_t | 0x00000002 (2) | struct field `AnnotatedBinary.Building.doors` (Int)
+ +0x0060 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | struct field `AnnotatedBinary.Building.windows` (Int)
+ +0x0064 | 0A 00 00 00 | uint32_t | 0x0000000A (10) | array field `AnnotatedBinary.Dimension.values`[0] (Int)
+ +0x0068 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | array field `AnnotatedBinary.Dimension.values`[1] (Int)
+ +0x006C | 14 00 00 00 | uint32_t | 0x00000014 (20) | array field `AnnotatedBinary.Dimension.values`[2] (Int)
+ +0x0070 | 01 | uint8_t | 0x01 (1) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0071 | 02 | uint8_t | 0x02 (2) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0072 | 03 | uint8_t | 0x03 (3) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0073 | 00 | uint8_t[1] | . | padding
+ +0x0074 | C8 01 00 00 | UOffset32 | 0x000001C8 (456) Loc: +0x023C | offset to field `name` (string)
+ +0x0078 | 5C 01 00 00 | UOffset32 | 0x0000015C (348) Loc: +0x01D4 | offset to field `bars` (vector)
+ +0x007C | 50 01 00 00 | UOffset32 | 0x00000150 (336) Loc: +0x01CC | offset to field `bar_baz` (union of type `Baz`)
+ +0x0080 | 34 01 00 00 | UOffset32 | 0x00000134 (308) Loc: +0x01B4 | offset to field `accounts` (vector)
+ +0x0084 | 24 01 00 00 | UOffset32 | 0x00000124 (292) Loc: +0x01A8 | offset to field `bob` (string)
+ +0x0088 | 14 01 00 00 | UOffset32 | 0x00000114 (276) Loc: +0x019C | offset to field `alice` (string)
+ +0x008C | 0D 00 00 00 | uint32_t | 0x0000000D (13) | table field `just_i32` (Int)
+ +0x0090 | DC 00 00 00 | UOffset32 | 0x000000DC (220) Loc: +0x016C | offset to field `names` (vector)
+ +0x0094 | A0 00 00 00 | UOffset32 | 0x000000A0 (160) Loc: +0x0134 | offset to field `points_of_interest` (vector)
+ +0x0098 | 94 00 00 00 | UOffset32 | 0x00000094 (148) Loc: +0x012C | offset to field `foobars_type` (vector)
+ +0x009C | 38 00 00 00 | UOffset32 | 0x00000038 (56) Loc: +0x00D4 | offset to field `foobars` (vector)
+ +0x00A0 | 33 00 00 00 | UOffset32 | 0x00000033 (51) Loc: +0x00D3 | offset to field `measurement` (union of type `Tolerance`)
+ +0x00A4 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x00C0 | offset to field `anything` (union of type `Bar`)
+ +0x00A8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00AC | offset to field `charlie` (string)
+
+string (AnnotatedBinary.Foo.charlie):
+ +0x00AC | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x00B0 | 61 6C 69 63 65 | char[5] | alice | string literal
+ +0x00B5 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x00B6 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Bar):
+ +0x00B8 | 08 00 | uint16_t | 0x0008 (8) | size of this vtable
+ +0x00BA | 13 00 | uint16_t | 0x0013 (19) | size of referring table
+ +0x00BC | 08 00 | VOffset16 | 0x0008 (8) | offset to field `a` (id: 0)
+ +0x00BE | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+
+table (AnnotatedBinary.Bar):
+ +0x00C0 | 08 00 00 00 | SOffset32 | 0x00000008 (8) Loc: +0x00B8 | offset to vtable
+ +0x00C4 | 00 80 23 44 | float | 0x44238000 (654) | table field `b` (Float)
+ +0x00C8 | 00 00 00 00 00 10 74 40 | double | 0x4074100000000000 (321) | table field `a` (Double)
+ +0x00D0 | 00 00 00 | uint8_t[3] | ... | padding
+
+union (AnnotatedBinary.Tolerance.measurement):
+ +0x00D3 | 05 | uint8_t | 0x05 (5) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+
+vector (AnnotatedBinary.Foo.foobars):
+ +0x00D4 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x00D8 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x010C | offset to union[0] (`Bar`)
+ +0x00DC | 2C 00 00 00 | UOffset32 | 0x0000002C (44) Loc: +0x0108 | offset to union[1] (`Baz`)
+ +0x00E0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00E4 | offset to union[2] (`Bar`)
+
+table (AnnotatedBinary.Bar):
+ +0x00E4 | D2 FE FF FF | SOffset32 | 0xFFFFFED2 (-302) Loc: +0x0212 | offset to vtable
+ +0x00E8 | 00 80 23 44 | float | 0x44238000 (654) | table field `b` (Float)
+ +0x00EC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x00FC | offset to field `c` (table)
+ +0x00F0 | 00 00 00 00 00 D8 8E 40 | double | 0x408ED80000000000 (987) | table field `a` (Double)
+ +0x00F8 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+table (AnnotatedBinary.Baz):
+ +0x00FC | 6A FE FF FF | SOffset32 | 0xFFFFFE6A (-406) Loc: +0x0292 | offset to vtable
+ +0x0100 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x0103 | 03 | uint8_t | 0x03 (3) | table field `meal` (Byte)
+
+vtable (AnnotatedBinary.Baz):
+ +0x0104 | 04 00 | uint16_t | 0x0004 (4) | size of this vtable
+ +0x0106 | 04 00 | uint16_t | 0x0004 (4) | size of referring table
+
+table (AnnotatedBinary.Baz):
+ +0x0108 | 04 00 00 00 | SOffset32 | 0x00000004 (4) Loc: +0x0104 | offset to vtable
+
+table (AnnotatedBinary.Bar):
+ +0x010C | FA FE FF FF | SOffset32 | 0xFFFFFEFA (-262) Loc: +0x0212 | offset to vtable
+ +0x0110 | 00 00 E4 43 | float | 0x43E40000 (456) | table field `b` (Float)
+ +0x0114 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x0124 | offset to field `c` (table)
+ +0x0118 | 00 00 00 00 00 C0 5E 40 | double | 0x405EC00000000000 (123) | table field `a` (Double)
+ +0x0120 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+table (AnnotatedBinary.Baz):
+ +0x0124 | 92 FE FF FF | SOffset32 | 0xFFFFFE92 (-366) Loc: +0x0292 | offset to vtable
+ +0x0128 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x012B | 01 | uint8_t | 0x01 (1) | table field `meal` (Byte)
+
+vector (AnnotatedBinary.Foo.foobars_type):
+ +0x012C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0130 | 01 | UType8 | 0x01 (1) | value[0]
+ +0x0131 | 02 | UType8 | 0x02 (2) | value[1]
+ +0x0132 | 01 | UType8 | 0x01 (1) | value[2]
+
+vector (AnnotatedBinary.Foo.points_of_interest):
+ +0x0134 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0138 | 33 33 33 33 33 A3 45 40 | double | 0x4045A33333333333 (43.275) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0140 | 7E 57 04 FF 5B 87 53 C0 | double | 0xC053875BFF04577E (-78.115) | struct field `AnnotatedBinary.Location.longitude` (Double)
+ +0x0148 | 8D F0 F6 20 04 B6 42 40 | double | 0x4042B60420F6F08D (37.422) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0150 | 9F 77 63 41 61 85 5E C0 | double | 0xC05E85614163779F (-122.084) | struct field `AnnotatedBinary.Location.longitude` (Double)
+ +0x0158 | 8F 35 23 83 DC 35 4B C0 | double | 0xC04B35DC8323358F (-54.4208) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0160 | F6 97 DD 93 87 C5 0A 40 | double | 0x400AC58793DD97F6 (3.34645) | struct field `AnnotatedBinary.Location.longitude` (Double)
+
+padding:
+ +0x0168 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (AnnotatedBinary.Foo.names):
+ +0x016C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0170 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x0190 | offset to string[0]
+ +0x0174 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x0188 | offset to string[1]
+ +0x0178 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x017C | offset to string[2]
+
+string (AnnotatedBinary.Foo.names):
+ +0x017C | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x0180 | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x0187 | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.names):
+ +0x0188 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x018C | 62 6F 62 | char[3] | bob | string literal
+ +0x018F | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.names):
+ +0x0190 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x0194 | 61 6C 69 63 65 | char[5] | alice | string literal
+ +0x0199 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x019A | 00 00 | uint8_t[2] | .. | padding
+
+string (AnnotatedBinary.Foo.alice):
+ +0x019C | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x01A0 | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x01A7 | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.bob):
+ +0x01A8 | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x01AC | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x01B3 | 00 | char | 0x00 (0) | string terminator
+
+vector (AnnotatedBinary.Foo.accounts):
+ +0x01B4 | 09 00 00 00 | uint32_t | 0x00000009 (9) | length of vector (# items)
+ +0x01B8 | 09 00 | uint16_t | 0x0009 (9) | value[0]
+ +0x01BA | 08 00 | uint16_t | 0x0008 (8) | value[1]
+ +0x01BC | 07 00 | uint16_t | 0x0007 (7) | value[2]
+ +0x01BE | 01 00 | uint16_t | 0x0001 (1) | value[3]
+ +0x01C0 | 02 00 | uint16_t | 0x0002 (2) | value[4]
+ +0x01C2 | 03 00 | uint16_t | 0x0003 (3) | value[5]
+ +0x01C4 | 06 00 | uint16_t | 0x0006 (6) | value[6]
+ +0x01C6 | 05 00 | uint16_t | 0x0005 (5) | value[7]
+ +0x01C8 | 04 00 | uint16_t | 0x0004 (4) | value[8]
+
+padding:
+ +0x01CA | 00 00 | uint8_t[2] | .. | padding
+
+table (AnnotatedBinary.Baz):
+ +0x01CC | 3A FF FF FF | SOffset32 | 0xFFFFFF3A (-198) Loc: +0x0292 | offset to vtable
+ +0x01D0 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x01D3 | 03 | uint8_t | 0x03 (3) | table field `meal` (Byte)
+
+vector (AnnotatedBinary.Foo.bars):
+ +0x01D4 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x01D8 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x021C | offset to table[0]
+ +0x01DC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x01EC | offset to table[1]
+
+padding:
+ +0x01E0 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Bar):
+ +0x01E2 | 0A 00 | uint16_t | 0x000A (10) | size of this vtable
+ +0x01E4 | 1A 00 | uint16_t | 0x001A (26) | size of referring table
+ +0x01E6 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `a` (id: 0)
+ +0x01E8 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+ +0x01EA | 08 00 | VOffset16 | 0x0008 (8) | offset to field `c` (id: 2)
+
+table (AnnotatedBinary.Bar):
+ +0x01EC | 0A 00 00 00 | SOffset32 | 0x0000000A (10) Loc: +0x01E2 | offset to vtable
+ +0x01F0 | 00 80 23 44 | float | 0x44238000 (654) | table field `b` (Float)
+ +0x01F4 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x020C | offset to field `c` (table)
+ +0x01F8 | 00 00 00 00 00 D8 8E 40 | double | 0x408ED80000000000 (987) | table field `a` (Double)
+ +0x0200 | 00 00 00 00 00 00 | uint8_t[6] | ...... | padding
+
+vtable (AnnotatedBinary.Baz):
+ +0x0206 | 06 00 | uint16_t | 0x0006 (6) | size of this vtable
+ +0x0208 | 06 00 | uint16_t | 0x0006 (6) | size of referring table
+ +0x020A | 05 00 | VOffset16 | 0x0005 (5) | offset to field `meal` (id: 0)
+
+table (AnnotatedBinary.Baz):
+ +0x020C | 06 00 00 00 | SOffset32 | 0x00000006 (6) Loc: +0x0206 | offset to vtable
+ +0x0210 | 00 | uint8_t[1] | . | padding
+ +0x0211 | 03 | uint8_t | 0x03 (3) | table field `meal` (Byte)
+
+vtable (AnnotatedBinary.Bar):
+ +0x0212 | 0A 00 | uint16_t | 0x000A (10) | size of this vtable
+ +0x0214 | 18 00 | uint16_t | 0x0018 (24) | size of referring table
+ +0x0216 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `a` (id: 0)
+ +0x0218 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+ +0x021A | 08 00 | VOffset16 | 0x0008 (8) | offset to field `c` (id: 2)
+
+table (AnnotatedBinary.Bar):
+ +0x021C | 0A 00 00 00 | SOffset32 | 0x0000000A (10) Loc: +0x0212 | offset to vtable
+ +0x0220 | 00 00 E4 43 | float | 0x43E40000 (456) | table field `b` (Float)
+ +0x0224 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x0234 | offset to field `c` (table)
+ +0x0228 | 00 00 00 00 00 C0 5E 40 | double | 0x405EC00000000000 (123) | table field `a` (Double)
+ +0x0230 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+table (AnnotatedBinary.Baz):
+ +0x0234 | A2 FF FF FF | SOffset32 | 0xFFFFFFA2 (-94) Loc: +0x0292 | offset to vtable
+ +0x0238 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x023B | 01 | uint8_t | 0x01 (1) | table field `meal` (Byte)
+
+string (AnnotatedBinary.Foo.name):
+ +0x023C | 2F 00 00 00 | uint32_t | 0x0000002F (47) | length of string
+ +0x0240 | 54 68 69 73 20 69 73 20 | char[47] | This is | string literal
+ +0x0248 | 61 20 6C 6F 6E 67 20 73 | | a long s
+ +0x0250 | 74 72 69 6E 67 20 74 6F | | tring to
+ +0x0258 | 20 73 68 6F 77 20 68 6F | | show ho
+ +0x0260 | 77 20 69 74 20 62 72 65 | | w it bre
+ +0x0268 | 61 6B 73 20 75 70 2E | | aks up.
+ +0x026F | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x0270 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Bar):
+ +0x0272 | 0A 00 | uint16_t | 0x000A (10) | size of this vtable
+ +0x0274 | 16 00 | uint16_t | 0x0016 (22) | size of referring table
+ +0x0276 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `a` (id: 0)
+ +0x0278 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+ +0x027A | 08 00 | VOffset16 | 0x0008 (8) | offset to field `c` (id: 2)
+
+table (AnnotatedBinary.Bar):
+ +0x027C | 0A 00 00 00 | SOffset32 | 0x0000000A (10) Loc: +0x0272 | offset to vtable
+ +0x0280 | 65 20 71 49 | float | 0x49712065 (987654) | table field `b` (Float)
+ +0x0284 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x0298 | offset to field `c` (table)
+ +0x0288 | C9 76 BE 9F 0C 24 FE 40 | double | 0x40FE240C9FBE76C9 (123457) | table field `a` (Double)
+ +0x0290 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Baz):
+ +0x0292 | 06 00 | uint16_t | 0x0006 (6) | size of this vtable
+ +0x0294 | 08 00 | uint16_t | 0x0008 (8) | size of referring table
+ +0x0296 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `meal` (id: 0)
+
+table (AnnotatedBinary.Baz):
+ +0x0298 | 06 00 00 00 | SOffset32 | 0x00000006 (6) Loc: +0x0292 | offset to vtable
+ +0x029C | 00 00 00 | uint8_t[3] | ... | padding
+ +0x029F | 01 | uint8_t | 0x01 (1) | table field `meal` (Byte)
diff --git a/tests/annotated_binary/annotated_binary.bfbs b/tests/annotated_binary/annotated_binary.bfbs
new file mode 100644
index 0000000..b4cf419
--- /dev/null
+++ b/tests/annotated_binary/annotated_binary.bfbs
Binary files differ
diff --git a/tests/annotated_binary/annotated_binary.bin b/tests/annotated_binary/annotated_binary.bin
new file mode 100644
index 0000000..2557aaf
--- /dev/null
+++ b/tests/annotated_binary/annotated_binary.bin
Binary files differ
diff --git a/tests/annotated_binary/annotated_binary.fbs b/tests/annotated_binary/annotated_binary.fbs
new file mode 100644
index 0000000..60e320f
--- /dev/null
+++ b/tests/annotated_binary/annotated_binary.fbs
@@ -0,0 +1,92 @@
+namespace AnnotatedBinary;
+
+enum Food : byte {
+ None = 0,
+ Apple = 1,
+ Banana = 2,
+ Kiwi = 3,
+}
+
+table Baz {
+ meal:Food = Banana;
+}
+
+table Bar {
+ a:double = 3.14;
+ b:float = 1.68;
+ c:Baz;
+}
+
+union BarBaz {
+ Bar, Baz
+}
+
+union Measurement {
+ Tolerance, Dimension
+}
+
+struct Tolerance {
+ width:uint8;
+}
+
+union Any {
+ Bar, Tolerance
+}
+
+struct Dimension {
+ values:[int:3];
+ tolerances:[Tolerance:3];
+}
+
+struct Building {
+ floors:int;
+ doors:int;
+ windows:int;
+ dimensions:Dimension;
+}
+
+struct Location {
+ latitude:double;
+ longitude:double;
+}
+
+table Foo {
+ counter:int;
+ healthy:bool;
+ level:long = 99;
+ meal:Food = Apple;
+ bar:Bar;
+ home:Building;
+ name:string;
+ // Vector of tables
+ bars:[Bar];
+ // Union of tables
+ bar_baz:BarBaz;
+ // Vector of Scalars
+ accounts:[uint16];
+ bob:string;
+ alice:string;
+ // Optional Scalars
+ maybe_i32: int32 = null;
+ default_i32: int32 = 42;
+ just_i32: int32;
+ // Vector of strings
+ names:[string];
+ // Vector of structs
+ points_of_interest:[Location];
+ // Vector of unions
+ foobars:[BarBaz];
+ // Union of structs
+ measurement:Measurement;
+ // Union of struct/table
+ anything:Any;
+ // Default floating point
+ temperature:float=98.6;
+ // Not present object
+ teetotaler:Bar;
+ charlie:string;
+}
+
+file_identifier "ANNO";
+
+root_type Foo;
\ No newline at end of file
diff --git a/tests/annotated_binary/annotated_binary.json b/tests/annotated_binary/annotated_binary.json
new file mode 100644
index 0000000..744e274
--- /dev/null
+++ b/tests/annotated_binary/annotated_binary.json
@@ -0,0 +1,124 @@
+{
+ "counter": 1234,
+ "healthy": true,
+ "meal": "Banana",
+ "bar": {
+ "a": 123456.789,
+ "b": 987654.321,
+ "c": {
+ "meal": "Apple"
+ }
+ },
+ "home": {
+ "floors": 1,
+ "doors": 2,
+ "windows": 12,
+ "dimensions": {
+ "values": [
+ 10,
+ 12,
+ 20
+ ],
+ "tolerances": [
+ {
+ "width": 1
+ },
+ {
+ "width": 2
+ },
+ {
+ "width": 3
+ }
+ ]
+ }
+ },
+ "name": "This is a long string to show how it breaks up.",
+ "bars": [
+ {
+ "a": 123,
+ "b": 456,
+ "c": {
+ "meal": "Apple"
+ }
+ },
+ {
+ "a": 987,
+ "b": 654,
+ "c": {
+ "meal": "Kiwi"
+ }
+ }
+ ],
+ "bar_baz_type": "Baz",
+ "bar_baz": {
+ "meal": "Kiwi"
+ },
+ "accounts": [
+ 9,
+ 8,
+ 7,
+ 1,
+ 2,
+ 3,
+ 6,
+ 5,
+ 4,
+ ],
+ // Use the same string to show shared string support
+ "bob": "charlie",
+ "alice": "charlie",
+ "just_i32": 13,
+ "names": [
+ "alice",
+ "bob",
+ "charlie"
+ ],
+ "points_of_interest": [
+ {
+ "latitude": 43.275,
+ "longitude": -78.114990
+ },
+ {
+ "latitude": 37.422001,
+ "longitude": -122.084061
+ },
+ {
+ "latitude": -54.420792,
+ "longitude": 3.346450
+ }
+ ],
+ "foobars_type": [
+ "Bar",
+ "Baz",
+ "Bar"
+ ],
+ "foobars" : [
+ {
+ "a": 123,
+ "b": 456,
+ "c": {
+ "meal": "Apple"
+ }
+ },
+ {
+ "meal": "Banana"
+ },
+ {
+ "a": 987,
+ "b": 654,
+ "c": {
+ "meal": "Kiwi"
+ }
+ }
+ ],
+ "measurement_type": "Tolerance",
+ "measurement": {
+ "width": 5
+ },
+ "anything_type": "Bar",
+ "anything": {
+ "a": 321,
+ "b": 654
+ },
+ "charlie": "alice"
+}
\ No newline at end of file
diff --git a/tests/annotated_binary/annotated_binary_old.afb b/tests/annotated_binary/annotated_binary_old.afb
new file mode 100644
index 0000000..9a0e5b0
--- /dev/null
+++ b/tests/annotated_binary/annotated_binary_old.afb
@@ -0,0 +1,293 @@
+// Annotated Flatbuffer Binary
+//
+// Schema file: annotated_binary_old.fbs
+// Binary file: annotated_binary.bin
+
+header:
+ +0x0000 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x0044 | offset to root table `AnnotatedBinary.Foo`
+ +0x0004 | 41 4E 4E 4F | char[4] | ANNO | File Identifier
+
+padding:
+ +0x0008 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Foo):
+ +0x000A | 3A 00 | uint16_t | 0x003A (58) | size of this vtable
+ +0x000C | 68 00 | uint16_t | 0x0068 (104) | size of referring table
+ +0x000E | 0C 00 | VOffset16 | 0x000C (12) | offset to field `counter` (id: 0)
+ +0x0010 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `healthy` (id: 1)
+ +0x0012 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `level` (id: 2) <defaults to 99> (Long)
+ +0x0014 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `meal` (id: 3)
+ +0x0016 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `bar` (id: 4)
+ +0x0018 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `home` (id: 5)
+ +0x001A | 30 00 | VOffset16 | 0x0030 (48) | offset to field `name` (id: 6)
+ +0x001C | 34 00 | VOffset16 | 0x0034 (52) | offset to field `bars` (id: 7)
+ +0x001E | 09 00 | VOffset16 | 0x0009 (9) | offset to field `bar_baz_type` (id: 8)
+ +0x0020 | 38 00 | VOffset16 | 0x0038 (56) | offset to field `bar_baz` (id: 9)
+ +0x0022 | 3C 00 | VOffset16 | 0x003C (60) | offset to field `accounts` (id: 10)
+ +0x0024 | 40 00 | VOffset16 | 0x0040 (64) | offset to field `bob` (id: 11)
+ +0x0026 | 44 00 | VOffset16 | 0x0044 (68) | offset to field `alice` (id: 12)
+ +0x0028 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `maybe_i32` (id: 13) <defaults to 0> (Int)
+ +0x002A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_i32` (id: 14) <defaults to 42> (Int)
+ +0x002C | 48 00 | VOffset16 | 0x0048 (72) | offset to field `just_i32` (id: 15)
+ +0x002E | 4C 00 | VOffset16 | 0x004C (76) | offset to field `names` (id: 16)
+ +0x0030 | 50 00 | VOffset16 | 0x0050 (80) | offset to field `points_of_interest` (id: 17)
+ +0x0032 | 54 00 | VOffset16 | 0x0054 (84) | offset to field `foobars_type` (id: 18)
+ +0x0034 | 58 00 | VOffset16 | 0x0058 (88) | offset to field `foobars` (id: 19)
+ +0x0036 | 0A 00 | VOffset16 | 0x000A (10) | offset to field `measurement_type` (id: 20)
+ +0x0038 | 5C 00 | VOffset16 | 0x005C (92) | offset to field `measurement` (id: 21)
+ +0x003A | 0B 00 | VOffset16 | 0x000B (11) | offset to field `anything_type` (id: 22)
+ +0x003C | 60 00 | VOffset16 | 0x0060 (96) | offset to field `anything` (id: 23)
+ +0x003E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `temperature` (id: 24) <defaults to 98.600000> (Float)
+ +0x0040 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `teetotaler` (id: 25) <null> (Obj)
+ +0x0042 | 64 00 | VOffset16 | 0x0064 (100) | offset to unknown field (id: 26)
+
+root_table (AnnotatedBinary.Foo):
+ +0x0044 | 3A 00 00 00 | SOffset32 | 0x0000003A (58) Loc: +0x000A | offset to vtable
+ +0x0048 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x004B | 01 | uint8_t | 0x01 (1) | table field `healthy` (Bool)
+ +0x004C | 02 | uint8_t | 0x02 (2) | table field `meal` (Byte)
+ +0x004D | 02 | uint8_t | 0x02 (2) | table field `bar_baz_type` (UType)
+ +0x004E | 01 | uint8_t | 0x01 (1) | table field `measurement_type` (UType)
+ +0x004F | 01 | uint8_t | 0x01 (1) | table field `anything_type` (UType)
+ +0x0050 | D2 04 00 00 | uint32_t | 0x000004D2 (1234) | table field `counter` (Int)
+ +0x0054 | 28 02 00 00 | UOffset32 | 0x00000228 (552) Loc: +0x027C | offset to field `bar`
+ +0x0058 | 01 00 00 00 | uint32_t | 0x00000001 (1) | struct field `AnnotatedBinary.Building.floors` (Int)
+ +0x005C | 02 00 00 00 | uint32_t | 0x00000002 (2) | struct field `AnnotatedBinary.Building.doors` (Int)
+ +0x0060 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | struct field `AnnotatedBinary.Building.windows` (Int)
+ +0x0064 | 0A 00 00 00 | uint32_t | 0x0000000A (10) | array field `AnnotatedBinary.Dimension.values[0]` (Int)
+ +0x0068 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | array field `AnnotatedBinary.Dimension.values[1]` (Int)
+ +0x006C | 14 00 00 00 | uint32_t | 0x00000014 (20) | array field `AnnotatedBinary.Dimension.values[2]` (Int)
+ +0x0070 | 01 | uint8_t | 0x01 (1) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0071 | 02 | uint8_t | 0x02 (2) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0072 | 03 | uint8_t | 0x03 (3) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0073 | 00 | uint8_t[1] | . | padding
+ +0x0074 | C8 01 00 00 | UOffset32 | 0x000001C8 (456) Loc: +0x023C | offset to field `name`
+ +0x0078 | 5C 01 00 00 | UOffset32 | 0x0000015C (348) Loc: +0x01D4 | offset to field `bars`
+ +0x007C | 50 01 00 00 | UOffset32 | 0x00000150 (336) Loc: +0x01CC | offset to field `bar_baz` (union of type `Baz`)
+ +0x0080 | 34 01 00 00 | UOffset32 | 0x00000134 (308) Loc: +0x01B4 | offset to field `accounts`
+ +0x0084 | 24 01 00 00 | UOffset32 | 0x00000124 (292) Loc: +0x01A8 | offset to field `bob`
+ +0x0088 | 14 01 00 00 | UOffset32 | 0x00000114 (276) Loc: +0x019C | offset to field `alice`
+ +0x008C | 0D 00 00 00 | uint32_t | 0x0000000D (13) | table field `just_i32` (Int)
+ +0x0090 | DC 00 00 00 | UOffset32 | 0x000000DC (220) Loc: +0x016C | offset to field `names`
+ +0x0094 | A0 00 00 00 | UOffset32 | 0x000000A0 (160) Loc: +0x0134 | offset to field `points_of_interest`
+ +0x0098 | 94 00 00 00 | UOffset32 | 0x00000094 (148) Loc: +0x012C | offset to field `foobars_type`
+ +0x009C | 38 00 00 00 | UOffset32 | 0x00000038 (56) Loc: +0x00D4 | offset to field `foobars`
+ +0x00A0 | 33 00 00 00 | UOffset32 | 0x00000033 (51) Loc: +0x00D3 | offset to field `measurement` (union of type `Tolerance`)
+ +0x00A4 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x00C0 | offset to field `anything` (union of type `Bar`)
+ +0x00A8 | 04 00 00 00 | ?uint8_t[4] | .... | Unknown field <possibly an offset? Check Loc: +0x000000AC>
+
+unknown (no known references):
+ +0x00AC | 05 00 00 00 61 6C 69 63 | ?uint8_t[12] | ....alic | WARN: nothing refers to this. Check if any `Unkown Field`s point to this.
+ +0x00B4 | 65 00 00 00 | | e...
+
+vtable (AnnotatedBinary.Bar):
+ +0x00B8 | 08 00 | uint16_t | 0x0008 (8) | size of this vtable
+ +0x00BA | 13 00 | uint16_t | 0x0013 (19) | size of referring table
+ +0x00BC | 08 00 | VOffset16 | 0x0008 (8) | offset to field `a` (id: 0)
+ +0x00BE | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+
+table (AnnotatedBinary.Bar):
+ +0x00C0 | 08 00 00 00 | SOffset32 | 0x00000008 (8) Loc: +0x00B8 | offset to vtable
+ +0x00C4 | 00 80 23 44 | float | 0x44238000 (654.000000) | table field `b` (Float)
+ +0x00C8 | 00 00 00 00 00 10 74 40 | double | 0x4074100000000000 (321.000000) | table field `a` (Double)
+ +0x00D0 | 00 00 00 | uint8_t[3] | ... | padding
+
+union (AnnotatedBinary.Tolerance.measurement):
+ +0x00D3 | 05 | uint8_t | 0x05 (5) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+
+vector (AnnotatedBinary.Foo.foobars):
+ +0x00D4 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x00D8 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x010C | offset to union[0] (`Bar`)
+ +0x00DC | 2C 00 00 00 | UOffset32 | 0x0000002C (44) Loc: +0x0108 | offset to union[1] (`Baz`)
+ +0x00E0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00E4 | offset to union[2] (`Bar`)
+
+table (AnnotatedBinary.Bar):
+ +0x00E4 | D2 FE FF FF | SOffset32 | 0xFFFFFED2 (-302) Loc: +0x0212 | offset to vtable
+ +0x00E8 | 00 80 23 44 | float | 0x44238000 (654.000000) | table field `b` (Float)
+ +0x00EC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x00FC | offset to field `c`
+ +0x00F0 | 00 00 00 00 00 D8 8E 40 | double | 0x408ED80000000000 (987.000000) | table field `a` (Double)
+ +0x00F8 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+table (AnnotatedBinary.Baz):
+ +0x00FC | 6A FE FF FF | SOffset32 | 0xFFFFFE6A (-406) Loc: +0x0292 | offset to vtable
+ +0x0100 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x0103 | 03 | uint8_t | 0x03 (3) | table field `meal` (Byte)
+
+vtable (AnnotatedBinary.Baz):
+ +0x0104 | 04 00 | uint16_t | 0x0004 (4) | size of this vtable
+ +0x0106 | 04 00 | uint16_t | 0x0004 (4) | size of referring table
+
+table (AnnotatedBinary.Baz):
+ +0x0108 | 04 00 00 00 | SOffset32 | 0x00000004 (4) Loc: +0x0104 | offset to vtable
+
+table (AnnotatedBinary.Bar):
+ +0x010C | FA FE FF FF | SOffset32 | 0xFFFFFEFA (-262) Loc: +0x0212 | offset to vtable
+ +0x0110 | 00 00 E4 43 | float | 0x43E40000 (456.000000) | table field `b` (Float)
+ +0x0114 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x0124 | offset to field `c`
+ +0x0118 | 00 00 00 00 00 C0 5E 40 | double | 0x405EC00000000000 (123.000000) | table field `a` (Double)
+ +0x0120 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+table (AnnotatedBinary.Baz):
+ +0x0124 | 92 FE FF FF | SOffset32 | 0xFFFFFE92 (-366) Loc: +0x0292 | offset to vtable
+ +0x0128 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x012B | 01 | uint8_t | 0x01 (1) | table field `meal` (Byte)
+
+vector (AnnotatedBinary.Foo.foobars_type):
+ +0x012C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0130 | 01 | uint8_t | 0x01 (1) | value[0]
+ +0x0131 | 02 | uint8_t | 0x02 (2) | value[1]
+ +0x0132 | 01 | uint8_t | 0x01 (1) | value[2]
+
+vector (AnnotatedBinary.Foo.points_of_interest):
+ +0x0134 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0138 | 33 33 33 33 33 A3 45 40 | double | 0x4045A33333333333 (43.275000) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0140 | 7E 57 04 FF 5B 87 53 C0 | double | 0xC053875BFF04577E (-78.114990) | struct field `AnnotatedBinary.Location.longitude` (Double)
+ +0x0148 | 8D F0 F6 20 04 B6 42 40 | double | 0x4042B60420F6F08D (37.422001) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0150 | 9F 77 63 41 61 85 5E C0 | double | 0xC05E85614163779F (-122.084061) | struct field `AnnotatedBinary.Location.longitude` (Double)
+ +0x0158 | 8F 35 23 83 DC 35 4B C0 | double | 0xC04B35DC8323358F (-54.420792) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0160 | F6 97 DD 93 87 C5 0A 40 | double | 0x400AC58793DD97F6 (3.346450) | struct field `AnnotatedBinary.Location.longitude` (Double)
+
+padding:
+ +0x0168 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (AnnotatedBinary.Foo.names):
+ +0x016C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0170 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x0190 | offset to string[0]
+ +0x0174 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x0188 | offset to string[1]
+ +0x0178 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x017C | offset to string[2]
+
+string (AnnotatedBinary.Foo.names):
+ +0x017C | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x0180 | 63 68 61 72 6C 69 65 | char[7] | charlie
+ +0x0187 | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.names):
+ +0x0188 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x018C | 62 6F 62 | char[3] | bob
+ +0x018F | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.names):
+ +0x0190 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x0194 | 61 6C 69 63 65 | char[5] | alice
+ +0x0199 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x019A | 00 00 | uint8_t[2] | .. | padding
+
+string (AnnotatedBinary.Foo.alice):
+ +0x019C | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x01A0 | 63 68 61 72 6C 69 65 | char[7] | charlie
+ +0x01A7 | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.bob):
+ +0x01A8 | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x01AC | 63 68 61 72 6C 69 65 | char[7] | charlie
+ +0x01B3 | 00 | char | 0x00 (0) | string terminator
+
+vector (AnnotatedBinary.Foo.accounts):
+ +0x01B4 | 09 00 00 00 | uint32_t | 0x00000009 (9) | length of vector (# items)
+ +0x01B8 | 09 00 | uint16_t | 0x0009 (9) | value[0]
+ +0x01BA | 08 00 | uint16_t | 0x0008 (8) | value[1]
+ +0x01BC | 07 00 | uint16_t | 0x0007 (7) | value[2]
+ +0x01BE | 01 00 | uint16_t | 0x0001 (1) | value[3]
+ +0x01C0 | 02 00 | uint16_t | 0x0002 (2) | value[4]
+ +0x01C2 | 03 00 | uint16_t | 0x0003 (3) | value[5]
+ +0x01C4 | 06 00 | uint16_t | 0x0006 (6) | value[6]
+ +0x01C6 | 05 00 | uint16_t | 0x0005 (5) | value[7]
+ +0x01C8 | 04 00 | uint16_t | 0x0004 (4) | value[8]
+
+padding:
+ +0x01CA | 00 00 | uint8_t[2] | .. | padding
+
+table (AnnotatedBinary.Baz):
+ +0x01CC | 3A FF FF FF | SOffset32 | 0xFFFFFF3A (-198) Loc: +0x0292 | offset to vtable
+ +0x01D0 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x01D3 | 03 | uint8_t | 0x03 (3) | table field `meal` (Byte)
+
+vector (AnnotatedBinary.Foo.bars):
+ +0x01D4 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x01D8 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x021C | offset to table[0]
+ +0x01DC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x01EC | offset to table[1]
+
+padding:
+ +0x01E0 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Bar):
+ +0x01E2 | 0A 00 | uint16_t | 0x000A (10) | size of this vtable
+ +0x01E4 | 1A 00 | uint16_t | 0x001A (26) | size of referring table
+ +0x01E6 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `a` (id: 0)
+ +0x01E8 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+ +0x01EA | 08 00 | VOffset16 | 0x0008 (8) | offset to field `c` (id: 2)
+
+table (AnnotatedBinary.Bar):
+ +0x01EC | 0A 00 00 00 | SOffset32 | 0x0000000A (10) Loc: +0x01E2 | offset to vtable
+ +0x01F0 | 00 80 23 44 | float | 0x44238000 (654.000000) | table field `b` (Float)
+ +0x01F4 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x020C | offset to field `c`
+ +0x01F8 | 00 00 00 00 00 D8 8E 40 | double | 0x408ED80000000000 (987.000000) | table field `a` (Double)
+ +0x0200 | 00 00 00 00 00 00 | uint8_t[6] | ...... | padding
+
+vtable (AnnotatedBinary.Baz):
+ +0x0206 | 06 00 | uint16_t | 0x0006 (6) | size of this vtable
+ +0x0208 | 06 00 | uint16_t | 0x0006 (6) | size of referring table
+ +0x020A | 05 00 | VOffset16 | 0x0005 (5) | offset to field `meal` (id: 0)
+
+table (AnnotatedBinary.Baz):
+ +0x020C | 06 00 00 00 | SOffset32 | 0x00000006 (6) Loc: +0x0206 | offset to vtable
+ +0x0210 | 00 | uint8_t[1] | . | padding
+ +0x0211 | 03 | uint8_t | 0x03 (3) | table field `meal` (Byte)
+
+vtable (AnnotatedBinary.Bar):
+ +0x0212 | 0A 00 | uint16_t | 0x000A (10) | size of this vtable
+ +0x0214 | 18 00 | uint16_t | 0x0018 (24) | size of referring table
+ +0x0216 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `a` (id: 0)
+ +0x0218 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+ +0x021A | 08 00 | VOffset16 | 0x0008 (8) | offset to field `c` (id: 2)
+
+table (AnnotatedBinary.Bar):
+ +0x021C | 0A 00 00 00 | SOffset32 | 0x0000000A (10) Loc: +0x0212 | offset to vtable
+ +0x0220 | 00 00 E4 43 | float | 0x43E40000 (456.000000) | table field `b` (Float)
+ +0x0224 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x0234 | offset to field `c`
+ +0x0228 | 00 00 00 00 00 C0 5E 40 | double | 0x405EC00000000000 (123.000000) | table field `a` (Double)
+ +0x0230 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+table (AnnotatedBinary.Baz):
+ +0x0234 | A2 FF FF FF | SOffset32 | 0xFFFFFFA2 (-94) Loc: +0x0292 | offset to vtable
+ +0x0238 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x023B | 01 | uint8_t | 0x01 (1) | table field `meal` (Byte)
+
+string (AnnotatedBinary.Foo.name):
+ +0x023C | 2F 00 00 00 | uint32_t | 0x0000002F (47) | length of string
+ +0x0240 | 54 68 69 73 20 69 73 20 | char[47] | This is
+ +0x0248 | 61 20 6C 6F 6E 67 20 73 | | a long s
+ +0x0250 | 74 72 69 6E 67 20 74 6F | | tring to
+ +0x0258 | 20 73 68 6F 77 20 68 6F | | show ho
+ +0x0260 | 77 20 69 74 20 62 72 65 | | w it bre
+ +0x0268 | 61 6B 73 20 75 70 2E | | aks up.
+ +0x026F | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x0270 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Bar):
+ +0x0272 | 0A 00 | uint16_t | 0x000A (10) | size of this vtable
+ +0x0274 | 16 00 | uint16_t | 0x0016 (22) | size of referring table
+ +0x0276 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `a` (id: 0)
+ +0x0278 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+ +0x027A | 08 00 | VOffset16 | 0x0008 (8) | offset to field `c` (id: 2)
+
+table (AnnotatedBinary.Bar):
+ +0x027C | 0A 00 00 00 | SOffset32 | 0x0000000A (10) Loc: +0x0272 | offset to vtable
+ +0x0280 | 65 20 71 49 | float | 0x49712065 (987654.312500) | table field `b` (Float)
+ +0x0284 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x0298 | offset to field `c`
+ +0x0288 | C9 76 BE 9F 0C 24 FE 40 | double | 0x40FE240C9FBE76C9 (123456.789000) | table field `a` (Double)
+ +0x0290 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Baz):
+ +0x0292 | 06 00 | uint16_t | 0x0006 (6) | size of this vtable
+ +0x0294 | 08 00 | uint16_t | 0x0008 (8) | size of referring table
+ +0x0296 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `meal` (id: 0)
+
+table (AnnotatedBinary.Baz):
+ +0x0298 | 06 00 00 00 | SOffset32 | 0x00000006 (6) Loc: +0x0292 | offset to vtable
+ +0x029C | 00 00 00 | uint8_t[3] | ... | padding
+ +0x029F | 01 | uint8_t | 0x01 (1) | table field `meal` (Byte)
diff --git a/tests/annotated_binary/annotated_binary_old.fbs b/tests/annotated_binary/annotated_binary_old.fbs
new file mode 100644
index 0000000..c22d6d2
--- /dev/null
+++ b/tests/annotated_binary/annotated_binary_old.fbs
@@ -0,0 +1,94 @@
+namespace AnnotatedBinary;
+
+enum Food : byte {
+ None = 0,
+ Apple = 1,
+ Banana = 2,
+ Kiwi = 3,
+}
+
+table Baz {
+ meal:Food = Banana;
+}
+
+table Bar {
+ a:double = 3.14;
+ b:float = 1.68;
+ c:Baz;
+}
+
+union BarBaz {
+ Bar, Baz
+}
+
+union Measurement {
+ Tolerance, Dimension
+}
+
+struct Tolerance {
+ width:uint8;
+}
+
+union Any {
+ Bar, Tolerance
+}
+
+struct Dimension {
+ values:[int:3];
+ tolerances:[Tolerance:3];
+}
+
+struct Building {
+ floors:int;
+ doors:int;
+ windows:int;
+ dimensions:Dimension;
+}
+
+struct Location {
+ latitude:double;
+ longitude:double;
+}
+
+table Foo {
+ counter:int;
+ healthy:bool;
+ level:long = 99;
+ meal:Food = Apple;
+ bar:Bar;
+ home:Building;
+ name:string;
+ // Vector of tables
+ bars:[Bar];
+ // Union of tables
+ bar_baz:BarBaz;
+ // Vector of Scalars
+ accounts:[uint16];
+ bob:string;
+ alice:string;
+ // Optional Scalars
+ maybe_i32: int32 = null;
+ default_i32: int32 = 42;
+ just_i32: int32;
+ // Vector of strings
+ names:[string];
+ // Vector of structs
+ points_of_interest:[Location];
+ // Vector of unions
+ foobars:[BarBaz];
+ // Union of structs
+ measurement:Measurement;
+ // Union of struct/table
+ anything:Any;
+ // Default floating point
+ temperature:float=98.6;
+ // Not present object
+ teetotaler:Bar;
+
+ // NOTE THIS IS A PURPOSELY OLD VERSION OF annotated_binary.fbs TO TEST
+ // PROCESSING OF NEWER BINARIES THAN THE SCHEMA. DO NOT ADD TO THIS.
+}
+
+file_identifier "ANNO";
+
+root_type Foo;
\ No newline at end of file
diff --git a/tests/annotated_binary/generate_annotations.py b/tests/annotated_binary/generate_annotations.py
new file mode 100755
index 0000000..bd5de2b
--- /dev/null
+++ b/tests/annotated_binary/generate_annotations.py
@@ -0,0 +1,76 @@
+#!/usr/bin/env python3
+#
+# Copyright 2021 Google Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import platform
+import subprocess
+from pathlib import Path
+
+# Get the path where this script is located so we can invoke the script from
+# any directory and have the paths work correctly.
+script_path = Path(__file__).parent.resolve()
+
+# Get the root path as an absolute path, so all derived paths are absolute.
+root_path = script_path.parent.parent.absolute()
+
+# Get the location of the flatc executable, reading from the first command line
+# argument or defaulting to default names.
+flatc_exe = Path(
+ ("flatc" if not platform.system() == "Windows" else "flatc.exe")
+)
+
+# Find and assert flatc compiler is present.
+if root_path in flatc_exe.parents:
+ flatc_exe = flatc_exe.relative_to(root_path)
+flatc_path = Path(root_path, flatc_exe)
+assert flatc_path.exists(), "Cannot find the flatc compiler " + str(flatc_path)
+
+# Specify the other paths that will be referenced
+tests_path = Path(script_path, "tests")
+
+
+def flatc_annotate(schema, file, cwd=script_path):
+ cmd = [str(flatc_path), "--annotate", schema, file]
+ result = subprocess.run(cmd, cwd=str(cwd), check=True)
+
+
+test_files = [
+ "annotated_binary.bin",
+ "tests/invalid_root_offset.bin",
+ "tests/invalid_root_table_too_short.bin",
+ "tests/invalid_root_table_vtable_offset.bin",
+ "tests/invalid_string_length.bin",
+ "tests/invalid_string_length_cut_short.bin",
+ "tests/invalid_struct_array_field_cut_short.bin",
+ "tests/invalid_struct_field_cut_short.bin",
+ "tests/invalid_table_field_size.bin",
+ "tests/invalid_table_field_offset.bin",
+ "tests/invalid_union_type_value.bin",
+ "tests/invalid_vector_length_cut_short.bin",
+ "tests/invalid_vector_scalars_cut_short.bin",
+ "tests/invalid_vector_strings_cut_short.bin",
+ "tests/invalid_vector_structs_cut_short.bin",
+ "tests/invalid_vector_tables_cut_short.bin",
+ "tests/invalid_vector_unions_cut_short.bin",
+ "tests/invalid_vector_union_type_value.bin",
+ "tests/invalid_vtable_ref_table_size_short.bin",
+ "tests/invalid_vtable_ref_table_size.bin",
+ "tests/invalid_vtable_size_short.bin",
+ "tests/invalid_vtable_size.bin",
+ "tests/invalid_vtable_field_offset.bin",
+]
+
+for test_file in test_files:
+ flatc_annotate("annotated_binary.fbs", test_file)
diff --git a/tests/annotated_binary/tests/README.md b/tests/annotated_binary/tests/README.md
new file mode 100644
index 0000000..c0d73f4
--- /dev/null
+++ b/tests/annotated_binary/tests/README.md
@@ -0,0 +1,125 @@
+# Tests for Annotated Binaries
+
+## Invalid Binary Tests
+
+The following is a collection of manually corrupted binaries based off of
+`..\annotated_binary.bin`. Each file changes some offset or length/size entry to
+point so an invalid spot, and the generated annotated binaries demonstrate that
+those corruptions can be spotted.
+
+Each of these files were ran with the following command:
+
+```sh
+cd .tests/annotated_binary
+../../flatc -annotate annotated_binary.fbs tests/{binary_file}...
+```
+
+### `invalid_root_offset.bin`
+
+Changed first two bytes from `4400` to `FFFF` which produces an offset larger
+than the binary.
+
+### `invalid_root_table_vtable_offset.bin`
+
+Changed two bytes at 0x0044 from `3A00` to `FFFF` which points to an offset
+outside the binary.
+
+### `invalid_root_table_too_short.bin`
+
+Truncated the file to 0x46 bytes, as that cuts into the vtable offset field of
+the root table.
+
+```sh
+truncate annotated_binary.bin --size=70 >> invalid_root_table_too_short.bin
+```
+
+### `invalid_vtable_size.bin`
+
+Changed two bytes at 0x000A from `3A00` to `FFFF` which size is larger than the
+binary.
+
+### `invalid_vtable_size_short.bin`
+
+Changed two bytes at 0x000A from `3A00` to `0100` which size is smaller than the
+minimum size of 4 bytes.
+
+### `invalid_vtable_ref_table_size.bin`
+
+Changed two bytes at 0x000C from `6800` to `FFFF` which size is larger than the
+binary.
+
+### `invalid_vtable_ref_table_size_short.bin`
+
+Changed two bytes at 0x000C from `6800` to `0100` which size is smaller than
+the minimum size of 4 bytes.
+
+### `invalid_vtable_field_offset.bin`
+
+Changed two bytes at 0x0016 from `1000` to `FFFF` which points to a field larger
+than the binary.
+
+### `invalid_table_field_size.bin`
+
+Truncated the file to 0x52 bytes, as that cuts a Uint32t value in half.
+
+### `invalid_table_field_offset.bin`
+
+Truncated the file to 0x96 bytes, as that cuts a UOffset32 value in half. Also,
+changed two bytes at 0x90 from `DC00` to `FFFF` which points to a section larger
+than the binary.
+
+### `invalid_string_length_cut_short.bin`
+
+Truncated the file to 0xAD bytes, as that cuts string length Uint32t value in
+half.
+
+### `invalid_string_length.bin`
+
+Changed two bytes at 0x00AC from `0500` to `FFFF` which is a string length
+larger than the binary.
+
+### `invalid_vector_length_cut_short.bin`
+
+Truncated the file to 0x0136 bytes, as that cuts vector length Uint32t value in
+half.
+
+### `invalid_struct_field_cut_short.bin`
+
+Truncated the file to 0x5d bytes, as that cuts struct field value in half.
+
+### `invalid_struct_array_field_cut_short.bin`
+
+Truncated the file to 0x6A bytes, as that cuts struct array field value in half.
+
+### `invalid_vector_structs_cut_short.bin`
+
+Truncated the file to 0x0154 bytes, as that cuts into a vector of structs.
+
+### `invalid_vector_tables_cut_short.bin`
+
+Truncated the file to 0x01DE bytes, as that cuts into a vector of table offsets.
+
+### `invalid_vector_strings_cut_short.bin`
+
+Truncated the file to 0x0176 bytes, as that cuts into a vector of string
+offsets.
+
+### `invalid_vector_scalars_cut_short.bin`
+
+Truncated the file to 0x01C1 bytes, as that cuts into a vector of scalars
+values.
+
+### `invalid_vector_unions_cut_short.bin`
+
+Truncated the file to 0x01DE bytes, as that cuts into a vector of union offset
+values.
+
+### `invalid_union_type_value.bin`
+
+Changed one byte at 0x004D from `02` to `FF` which is a union type value that is
+larger than the enum.
+
+### `invalid_vector_union_type_value.bin`
+
+Changed one byte at 0x0131 from `02` to `FF` which is a vector union type value
+that is larger than the enum.
\ No newline at end of file
diff --git a/tests/annotated_binary/tests/invalid_root_offset.afb b/tests/annotated_binary/tests/invalid_root_offset.afb
new file mode 100644
index 0000000..ff50417
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_root_offset.afb
@@ -0,0 +1,93 @@
+// Annotated Flatbuffer Binary
+//
+// Schema file: annotated_binary.fbs
+// Binary file: tests/invalid_root_offset.bin
+
+header:
+ +0x0000 | FF FF 00 00 | UOffset32 | 0x0000FFFF (65535) Loc: +0xFFFF | ERROR: offset to root table `AnnotatedBinary.Foo`. Invalid offset, points outside the binary.
+ +0x0004 | 41 4E 4E 4F | char[4] | ANNO | File Identifier
+
+unknown (no known references):
+ +0x0008 | 00 00 3A 00 68 00 0C 00 | ?uint8_t[664] | ..:.h... | WARN: nothing refers to this section.
+ +0x0010 | 07 00 00 00 08 00 10 00 | | ........
+ +0x0018 | 14 00 30 00 34 00 09 00 | | ..0.4...
+ +0x0020 | 38 00 3C 00 40 00 44 00 | | 8.<.@.D.
+ +0x0028 | 00 00 00 00 48 00 4C 00 | | ....H.L.
+ +0x0030 | 50 00 54 00 58 00 0A 00 | | P.T.X...
+ +0x0038 | 5C 00 0B 00 60 00 00 00 | | \...`...
+ +0x0040 | 00 00 64 00 3A 00 00 00 | | ..d.:...
+ +0x0048 | 00 00 00 01 02 02 01 01 | | ........
+ +0x0050 | D2 04 00 00 28 02 00 00 | | ....(...
+ +0x0058 | 01 00 00 00 02 00 00 00 | | ........
+ +0x0060 | 0C 00 00 00 0A 00 00 00 | | ........
+ +0x0068 | 0C 00 00 00 14 00 00 00 | | ........
+ +0x0070 | 01 02 03 00 C8 01 00 00 | | ........
+ +0x0078 | 5C 01 00 00 50 01 00 00 | | \...P...
+ +0x0080 | 34 01 00 00 24 01 00 00 | | 4...$...
+ +0x0088 | 14 01 00 00 0D 00 00 00 | | ........
+ +0x0090 | DC 00 00 00 A0 00 00 00 | | ........
+ +0x0098 | 94 00 00 00 38 00 00 00 | | ....8...
+ +0x00A0 | 33 00 00 00 1C 00 00 00 | | 3.......
+ +0x00A8 | 04 00 00 00 05 00 00 00 | | ........
+ +0x00B0 | 61 6C 69 63 65 00 00 00 | | alice...
+ +0x00B8 | 08 00 13 00 08 00 04 00 | | ........
+ +0x00C0 | 08 00 00 00 00 80 23 44 | | ......#D
+ +0x00C8 | 00 00 00 00 00 10 74 40 | | ......t@
+ +0x00D0 | 00 00 00 05 03 00 00 00 | | ........
+ +0x00D8 | 34 00 00 00 2C 00 00 00 | | 4...,...
+ +0x00E0 | 04 00 00 00 D2 FE FF FF | | ........
+ +0x00E8 | 00 80 23 44 10 00 00 00 | | ..#D....
+ +0x00F0 | 00 00 00 00 00 D8 8E 40 | | .......@
+ +0x00F8 | 00 00 00 00 6A FE FF FF | | ....j...
+ +0x0100 | 00 00 00 03 04 00 04 00 | | ........
+ +0x0108 | 04 00 00 00 FA FE FF FF | | ........
+ +0x0110 | 00 00 E4 43 10 00 00 00 | | ...C....
+ +0x0118 | 00 00 00 00 00 C0 5E 40 | | ......^@
+ +0x0120 | 00 00 00 00 92 FE FF FF | | ........
+ +0x0128 | 00 00 00 01 03 00 00 00 | | ........
+ +0x0130 | 01 02 01 00 03 00 00 00 | | ........
+ +0x0138 | 33 33 33 33 33 A3 45 40 | | 33333.E@
+ +0x0140 | 7E 57 04 FF 5B 87 53 C0 | | ~W..[.S.
+ +0x0148 | 8D F0 F6 20 04 B6 42 40 | | ... ..B@
+ +0x0150 | 9F 77 63 41 61 85 5E C0 | | .wcAa.^.
+ +0x0158 | 8F 35 23 83 DC 35 4B C0 | | .5#..5K.
+ +0x0160 | F6 97 DD 93 87 C5 0A 40 | | .......@
+ +0x0168 | 00 00 00 00 03 00 00 00 | | ........
+ +0x0170 | 20 00 00 00 14 00 00 00 | | .......
+ +0x0178 | 04 00 00 00 07 00 00 00 | | ........
+ +0x0180 | 63 68 61 72 6C 69 65 00 | | charlie.
+ +0x0188 | 03 00 00 00 62 6F 62 00 | | ....bob.
+ +0x0190 | 05 00 00 00 61 6C 69 63 | | ....alic
+ +0x0198 | 65 00 00 00 07 00 00 00 | | e.......
+ +0x01A0 | 63 68 61 72 6C 69 65 00 | | charlie.
+ +0x01A8 | 07 00 00 00 63 68 61 72 | | ....char
+ +0x01B0 | 6C 69 65 00 09 00 00 00 | | lie.....
+ +0x01B8 | 09 00 08 00 07 00 01 00 | | ........
+ +0x01C0 | 02 00 03 00 06 00 05 00 | | ........
+ +0x01C8 | 04 00 00 00 3A FF FF FF | | ....:...
+ +0x01D0 | 00 00 00 03 02 00 00 00 | | ........
+ +0x01D8 | 44 00 00 00 10 00 00 00 | | D.......
+ +0x01E0 | 00 00 0A 00 1A 00 0C 00 | | ........
+ +0x01E8 | 04 00 08 00 0A 00 00 00 | | ........
+ +0x01F0 | 00 80 23 44 18 00 00 00 | | ..#D....
+ +0x01F8 | 00 00 00 00 00 D8 8E 40 | | .......@
+ +0x0200 | 00 00 00 00 00 00 06 00 | | ........
+ +0x0208 | 06 00 05 00 06 00 00 00 | | ........
+ +0x0210 | 00 03 0A 00 18 00 0C 00 | | ........
+ +0x0218 | 04 00 08 00 0A 00 00 00 | | ........
+ +0x0220 | 00 00 E4 43 10 00 00 00 | | ...C....
+ +0x0228 | 00 00 00 00 00 C0 5E 40 | | ......^@
+ +0x0230 | 00 00 00 00 A2 FF FF FF | | ........
+ +0x0238 | 00 00 00 01 2F 00 00 00 | | ..../...
+ +0x0240 | 54 68 69 73 20 69 73 20 | | This is
+ +0x0248 | 61 20 6C 6F 6E 67 20 73 | | a long s
+ +0x0250 | 74 72 69 6E 67 20 74 6F | | tring to
+ +0x0258 | 20 73 68 6F 77 20 68 6F | | show ho
+ +0x0260 | 77 20 69 74 20 62 72 65 | | w it bre
+ +0x0268 | 61 6B 73 20 75 70 2E 00 | | aks up..
+ +0x0270 | 00 00 0A 00 16 00 0C 00 | | ........
+ +0x0278 | 04 00 08 00 0A 00 00 00 | | ........
+ +0x0280 | 65 20 71 49 14 00 00 00 | | e qI....
+ +0x0288 | C9 76 BE 9F 0C 24 FE 40 | | .v...$.@
+ +0x0290 | 00 00 06 00 08 00 07 00 | | ........
+ +0x0298 | 06 00 00 00 00 00 00 01 | | ........
diff --git a/tests/annotated_binary/tests/invalid_root_offset.bin b/tests/annotated_binary/tests/invalid_root_offset.bin
new file mode 100644
index 0000000..c539a01
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_root_offset.bin
Binary files differ
diff --git a/tests/annotated_binary/tests/invalid_root_table_too_short.afb b/tests/annotated_binary/tests/invalid_root_table_too_short.afb
new file mode 100644
index 0000000..2269d4e
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_root_table_too_short.afb
@@ -0,0 +1,21 @@
+// Annotated Flatbuffer Binary
+//
+// Schema file: annotated_binary.fbs
+// Binary file: tests/invalid_root_table_too_short.bin
+
+header:
+ +0x00 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x44 | offset to root table `AnnotatedBinary.Foo`
+ +0x04 | 41 4E 4E 4F | char[4] | ANNO | File Identifier
+
+unknown (no known references):
+ +0x08 | 00 00 3A 00 68 00 0C 00 | ?uint8_t[60] | ..:.h... | WARN: nothing refers to this section.
+ +0x10 | 07 00 00 00 08 00 10 00 | | ........
+ +0x18 | 14 00 30 00 34 00 09 00 | | ..0.4...
+ +0x20 | 38 00 3C 00 40 00 44 00 | | 8.<.@.D.
+ +0x28 | 00 00 00 00 48 00 4C 00 | | ....H.L.
+ +0x30 | 50 00 54 00 58 00 0A 00 | | P.T.X...
+ +0x38 | 5C 00 0B 00 60 00 00 00 | | \...`...
+ +0x40 | 00 00 64 00 | | ..d.
+
+root_table (AnnotatedBinary.Foo):
+ +0x44 | 3A 00 | ?uint8_t[2] | :. | ERROR: offset to vtable. Incomplete binary, expected to read 4 bytes.
diff --git a/tests/annotated_binary/tests/invalid_root_table_too_short.bin b/tests/annotated_binary/tests/invalid_root_table_too_short.bin
new file mode 100644
index 0000000..bb1c7fc
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_root_table_too_short.bin
Binary files differ
diff --git a/tests/annotated_binary/tests/invalid_root_table_vtable_offset.afb b/tests/annotated_binary/tests/invalid_root_table_vtable_offset.afb
new file mode 100644
index 0000000..d1c6260
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_root_table_vtable_offset.afb
@@ -0,0 +1,98 @@
+// Annotated Flatbuffer Binary
+//
+// Schema file: annotated_binary.fbs
+// Binary file: tests/invalid_root_table_vtable_offset.bin
+
+header:
+ +0x0000 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x0044 | offset to root table `AnnotatedBinary.Foo`
+ +0x0004 | 41 4E 4E 4F | char[4] | ANNO | File Identifier
+
+unknown (no known references):
+ +0x0008 | 00 00 3A 00 68 00 0C 00 | ?uint8_t[60] | ..:.h... | WARN: nothing refers to this section.
+ +0x0010 | 07 00 00 00 08 00 10 00 | | ........
+ +0x0018 | 14 00 30 00 34 00 09 00 | | ..0.4...
+ +0x0020 | 38 00 3C 00 40 00 44 00 | | 8.<.@.D.
+ +0x0028 | 00 00 00 00 48 00 4C 00 | | ....H.L.
+ +0x0030 | 50 00 54 00 58 00 0A 00 | | P.T.X...
+ +0x0038 | 5C 00 0B 00 60 00 00 00 | | \...`...
+ +0x0040 | 00 00 64 00 | | ..d.
+
+root_table (AnnotatedBinary.Foo):
+ +0x0044 | FF FF 00 00 | SOffset32 | 0x0000FFFF (65535) Loc: +0xFFFFFFFFFFFF0045 | ERROR: offset to vtable. Invalid offset, points outside the binary.
+
+unknown (no known references):
+ +0x0048 | 00 00 00 01 02 02 01 01 | ?uint8_t[600] | ........ | WARN: nothing refers to this section.
+ +0x0050 | D2 04 00 00 28 02 00 00 | | ....(...
+ +0x0058 | 01 00 00 00 02 00 00 00 | | ........
+ +0x0060 | 0C 00 00 00 0A 00 00 00 | | ........
+ +0x0068 | 0C 00 00 00 14 00 00 00 | | ........
+ +0x0070 | 01 02 03 00 C8 01 00 00 | | ........
+ +0x0078 | 5C 01 00 00 50 01 00 00 | | \...P...
+ +0x0080 | 34 01 00 00 24 01 00 00 | | 4...$...
+ +0x0088 | 14 01 00 00 0D 00 00 00 | | ........
+ +0x0090 | DC 00 00 00 A0 00 00 00 | | ........
+ +0x0098 | 94 00 00 00 38 00 00 00 | | ....8...
+ +0x00A0 | 33 00 00 00 1C 00 00 00 | | 3.......
+ +0x00A8 | 04 00 00 00 05 00 00 00 | | ........
+ +0x00B0 | 61 6C 69 63 65 00 00 00 | | alice...
+ +0x00B8 | 08 00 13 00 08 00 04 00 | | ........
+ +0x00C0 | 08 00 00 00 00 80 23 44 | | ......#D
+ +0x00C8 | 00 00 00 00 00 10 74 40 | | ......t@
+ +0x00D0 | 00 00 00 05 03 00 00 00 | | ........
+ +0x00D8 | 34 00 00 00 2C 00 00 00 | | 4...,...
+ +0x00E0 | 04 00 00 00 D2 FE FF FF | | ........
+ +0x00E8 | 00 80 23 44 10 00 00 00 | | ..#D....
+ +0x00F0 | 00 00 00 00 00 D8 8E 40 | | .......@
+ +0x00F8 | 00 00 00 00 6A FE FF FF | | ....j...
+ +0x0100 | 00 00 00 03 04 00 04 00 | | ........
+ +0x0108 | 04 00 00 00 FA FE FF FF | | ........
+ +0x0110 | 00 00 E4 43 10 00 00 00 | | ...C....
+ +0x0118 | 00 00 00 00 00 C0 5E 40 | | ......^@
+ +0x0120 | 00 00 00 00 92 FE FF FF | | ........
+ +0x0128 | 00 00 00 01 03 00 00 00 | | ........
+ +0x0130 | 01 02 01 00 03 00 00 00 | | ........
+ +0x0138 | 33 33 33 33 33 A3 45 40 | | 33333.E@
+ +0x0140 | 7E 57 04 FF 5B 87 53 C0 | | ~W..[.S.
+ +0x0148 | 8D F0 F6 20 04 B6 42 40 | | ... ..B@
+ +0x0150 | 9F 77 63 41 61 85 5E C0 | | .wcAa.^.
+ +0x0158 | 8F 35 23 83 DC 35 4B C0 | | .5#..5K.
+ +0x0160 | F6 97 DD 93 87 C5 0A 40 | | .......@
+ +0x0168 | 00 00 00 00 03 00 00 00 | | ........
+ +0x0170 | 20 00 00 00 14 00 00 00 | | .......
+ +0x0178 | 04 00 00 00 07 00 00 00 | | ........
+ +0x0180 | 63 68 61 72 6C 69 65 00 | | charlie.
+ +0x0188 | 03 00 00 00 62 6F 62 00 | | ....bob.
+ +0x0190 | 05 00 00 00 61 6C 69 63 | | ....alic
+ +0x0198 | 65 00 00 00 07 00 00 00 | | e.......
+ +0x01A0 | 63 68 61 72 6C 69 65 00 | | charlie.
+ +0x01A8 | 07 00 00 00 63 68 61 72 | | ....char
+ +0x01B0 | 6C 69 65 00 09 00 00 00 | | lie.....
+ +0x01B8 | 09 00 08 00 07 00 01 00 | | ........
+ +0x01C0 | 02 00 03 00 06 00 05 00 | | ........
+ +0x01C8 | 04 00 00 00 3A FF FF FF | | ....:...
+ +0x01D0 | 00 00 00 03 02 00 00 00 | | ........
+ +0x01D8 | 44 00 00 00 10 00 00 00 | | D.......
+ +0x01E0 | 00 00 0A 00 1A 00 0C 00 | | ........
+ +0x01E8 | 04 00 08 00 0A 00 00 00 | | ........
+ +0x01F0 | 00 80 23 44 18 00 00 00 | | ..#D....
+ +0x01F8 | 00 00 00 00 00 D8 8E 40 | | .......@
+ +0x0200 | 00 00 00 00 00 00 06 00 | | ........
+ +0x0208 | 06 00 05 00 06 00 00 00 | | ........
+ +0x0210 | 00 03 0A 00 18 00 0C 00 | | ........
+ +0x0218 | 04 00 08 00 0A 00 00 00 | | ........
+ +0x0220 | 00 00 E4 43 10 00 00 00 | | ...C....
+ +0x0228 | 00 00 00 00 00 C0 5E 40 | | ......^@
+ +0x0230 | 00 00 00 00 A2 FF FF FF | | ........
+ +0x0238 | 00 00 00 01 2F 00 00 00 | | ..../...
+ +0x0240 | 54 68 69 73 20 69 73 20 | | This is
+ +0x0248 | 61 20 6C 6F 6E 67 20 73 | | a long s
+ +0x0250 | 74 72 69 6E 67 20 74 6F | | tring to
+ +0x0258 | 20 73 68 6F 77 20 68 6F | | show ho
+ +0x0260 | 77 20 69 74 20 62 72 65 | | w it bre
+ +0x0268 | 61 6B 73 20 75 70 2E 00 | | aks up..
+ +0x0270 | 00 00 0A 00 16 00 0C 00 | | ........
+ +0x0278 | 04 00 08 00 0A 00 00 00 | | ........
+ +0x0280 | 65 20 71 49 14 00 00 00 | | e qI....
+ +0x0288 | C9 76 BE 9F 0C 24 FE 40 | | .v...$.@
+ +0x0290 | 00 00 06 00 08 00 07 00 | | ........
+ +0x0298 | 06 00 00 00 00 00 00 01 | | ........
diff --git a/tests/annotated_binary/tests/invalid_root_table_vtable_offset.bin b/tests/annotated_binary/tests/invalid_root_table_vtable_offset.bin
new file mode 100644
index 0000000..a3075ea
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_root_table_vtable_offset.bin
Binary files differ
diff --git a/tests/annotated_binary/tests/invalid_string_length.afb b/tests/annotated_binary/tests/invalid_string_length.afb
new file mode 100644
index 0000000..332cbaf
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_string_length.afb
@@ -0,0 +1,295 @@
+// Annotated Flatbuffer Binary
+//
+// Schema file: annotated_binary.fbs
+// Binary file: tests/invalid_string_length.bin
+
+header:
+ +0x0000 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x0044 | offset to root table `AnnotatedBinary.Foo`
+ +0x0004 | 41 4E 4E 4F | char[4] | ANNO | File Identifier
+
+padding:
+ +0x0008 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Foo):
+ +0x000A | 3A 00 | uint16_t | 0x003A (58) | size of this vtable
+ +0x000C | 68 00 | uint16_t | 0x0068 (104) | size of referring table
+ +0x000E | 0C 00 | VOffset16 | 0x000C (12) | offset to field `counter` (id: 0)
+ +0x0010 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `healthy` (id: 1)
+ +0x0012 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `level` (id: 2) <defaults to 99> (Long)
+ +0x0014 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `meal` (id: 3)
+ +0x0016 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `bar` (id: 4)
+ +0x0018 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `home` (id: 5)
+ +0x001A | 30 00 | VOffset16 | 0x0030 (48) | offset to field `name` (id: 6)
+ +0x001C | 34 00 | VOffset16 | 0x0034 (52) | offset to field `bars` (id: 7)
+ +0x001E | 09 00 | VOffset16 | 0x0009 (9) | offset to field `bar_baz_type` (id: 8)
+ +0x0020 | 38 00 | VOffset16 | 0x0038 (56) | offset to field `bar_baz` (id: 9)
+ +0x0022 | 3C 00 | VOffset16 | 0x003C (60) | offset to field `accounts` (id: 10)
+ +0x0024 | 40 00 | VOffset16 | 0x0040 (64) | offset to field `bob` (id: 11)
+ +0x0026 | 44 00 | VOffset16 | 0x0044 (68) | offset to field `alice` (id: 12)
+ +0x0028 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `maybe_i32` (id: 13) <defaults to 0> (Int)
+ +0x002A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_i32` (id: 14) <defaults to 42> (Int)
+ +0x002C | 48 00 | VOffset16 | 0x0048 (72) | offset to field `just_i32` (id: 15)
+ +0x002E | 4C 00 | VOffset16 | 0x004C (76) | offset to field `names` (id: 16)
+ +0x0030 | 50 00 | VOffset16 | 0x0050 (80) | offset to field `points_of_interest` (id: 17)
+ +0x0032 | 54 00 | VOffset16 | 0x0054 (84) | offset to field `foobars_type` (id: 18)
+ +0x0034 | 58 00 | VOffset16 | 0x0058 (88) | offset to field `foobars` (id: 19)
+ +0x0036 | 0A 00 | VOffset16 | 0x000A (10) | offset to field `measurement_type` (id: 20)
+ +0x0038 | 5C 00 | VOffset16 | 0x005C (92) | offset to field `measurement` (id: 21)
+ +0x003A | 0B 00 | VOffset16 | 0x000B (11) | offset to field `anything_type` (id: 22)
+ +0x003C | 60 00 | VOffset16 | 0x0060 (96) | offset to field `anything` (id: 23)
+ +0x003E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `temperature` (id: 24) <defaults to 98.600000> (Float)
+ +0x0040 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `teetotaler` (id: 25) <null> (Obj)
+ +0x0042 | 64 00 | VOffset16 | 0x0064 (100) | offset to field `charlie` (id: 26)
+
+root_table (AnnotatedBinary.Foo):
+ +0x0044 | 3A 00 00 00 | SOffset32 | 0x0000003A (58) Loc: +0x000A | offset to vtable
+ +0x0048 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x004B | 01 | uint8_t | 0x01 (1) | table field `healthy` (Bool)
+ +0x004C | 02 | uint8_t | 0x02 (2) | table field `meal` (Byte)
+ +0x004D | 02 | UType8 | 0x02 (2) | table field `bar_baz_type` (UType)
+ +0x004E | 01 | UType8 | 0x01 (1) | table field `measurement_type` (UType)
+ +0x004F | 01 | UType8 | 0x01 (1) | table field `anything_type` (UType)
+ +0x0050 | D2 04 00 00 | uint32_t | 0x000004D2 (1234) | table field `counter` (Int)
+ +0x0054 | 28 02 00 00 | UOffset32 | 0x00000228 (552) Loc: +0x027C | offset to field `bar` (table)
+ +0x0058 | 01 00 00 00 | uint32_t | 0x00000001 (1) | struct field `AnnotatedBinary.Building.floors` (Int)
+ +0x005C | 02 00 00 00 | uint32_t | 0x00000002 (2) | struct field `AnnotatedBinary.Building.doors` (Int)
+ +0x0060 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | struct field `AnnotatedBinary.Building.windows` (Int)
+ +0x0064 | 0A 00 00 00 | uint32_t | 0x0000000A (10) | array field `AnnotatedBinary.Dimension.values`[0] (Int)
+ +0x0068 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | array field `AnnotatedBinary.Dimension.values`[1] (Int)
+ +0x006C | 14 00 00 00 | uint32_t | 0x00000014 (20) | array field `AnnotatedBinary.Dimension.values`[2] (Int)
+ +0x0070 | 01 | uint8_t | 0x01 (1) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0071 | 02 | uint8_t | 0x02 (2) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0072 | 03 | uint8_t | 0x03 (3) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0073 | 00 | uint8_t[1] | . | padding
+ +0x0074 | C8 01 00 00 | UOffset32 | 0x000001C8 (456) Loc: +0x023C | offset to field `name` (string)
+ +0x0078 | 5C 01 00 00 | UOffset32 | 0x0000015C (348) Loc: +0x01D4 | offset to field `bars` (vector)
+ +0x007C | 50 01 00 00 | UOffset32 | 0x00000150 (336) Loc: +0x01CC | offset to field `bar_baz` (union of type `Baz`)
+ +0x0080 | 34 01 00 00 | UOffset32 | 0x00000134 (308) Loc: +0x01B4 | offset to field `accounts` (vector)
+ +0x0084 | 24 01 00 00 | UOffset32 | 0x00000124 (292) Loc: +0x01A8 | offset to field `bob` (string)
+ +0x0088 | 14 01 00 00 | UOffset32 | 0x00000114 (276) Loc: +0x019C | offset to field `alice` (string)
+ +0x008C | 0D 00 00 00 | uint32_t | 0x0000000D (13) | table field `just_i32` (Int)
+ +0x0090 | DC 00 00 00 | UOffset32 | 0x000000DC (220) Loc: +0x016C | offset to field `names` (vector)
+ +0x0094 | A0 00 00 00 | UOffset32 | 0x000000A0 (160) Loc: +0x0134 | offset to field `points_of_interest` (vector)
+ +0x0098 | 94 00 00 00 | UOffset32 | 0x00000094 (148) Loc: +0x012C | offset to field `foobars_type` (vector)
+ +0x009C | 38 00 00 00 | UOffset32 | 0x00000038 (56) Loc: +0x00D4 | offset to field `foobars` (vector)
+ +0x00A0 | 33 00 00 00 | UOffset32 | 0x00000033 (51) Loc: +0x00D3 | offset to field `measurement` (union of type `Tolerance`)
+ +0x00A4 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x00C0 | offset to field `anything` (union of type `Bar`)
+ +0x00A8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00AC | offset to field `charlie` (string)
+
+string (AnnotatedBinary.Foo.charlie):
+ +0x00AC | FF FF 00 00 | uint32_t | 0x0000FFFF (65535) | ERROR: length of string. Longer than the binary.
+
+unknown (no known references):
+ +0x00B0 | 61 6C 69 63 65 00 00 00 | ?uint8_t[8] | alice... | WARN: nothing refers to this section.
+
+vtable (AnnotatedBinary.Bar):
+ +0x00B8 | 08 00 | uint16_t | 0x0008 (8) | size of this vtable
+ +0x00BA | 13 00 | uint16_t | 0x0013 (19) | size of referring table
+ +0x00BC | 08 00 | VOffset16 | 0x0008 (8) | offset to field `a` (id: 0)
+ +0x00BE | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+
+table (AnnotatedBinary.Bar):
+ +0x00C0 | 08 00 00 00 | SOffset32 | 0x00000008 (8) Loc: +0x00B8 | offset to vtable
+ +0x00C4 | 00 80 23 44 | float | 0x44238000 (654) | table field `b` (Float)
+ +0x00C8 | 00 00 00 00 00 10 74 40 | double | 0x4074100000000000 (321) | table field `a` (Double)
+ +0x00D0 | 00 00 00 | uint8_t[3] | ... | padding
+
+union (AnnotatedBinary.Tolerance.measurement):
+ +0x00D3 | 05 | uint8_t | 0x05 (5) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+
+vector (AnnotatedBinary.Foo.foobars):
+ +0x00D4 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x00D8 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x010C | offset to union[0] (`Bar`)
+ +0x00DC | 2C 00 00 00 | UOffset32 | 0x0000002C (44) Loc: +0x0108 | offset to union[1] (`Baz`)
+ +0x00E0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00E4 | offset to union[2] (`Bar`)
+
+table (AnnotatedBinary.Bar):
+ +0x00E4 | D2 FE FF FF | SOffset32 | 0xFFFFFED2 (-302) Loc: +0x0212 | offset to vtable
+ +0x00E8 | 00 80 23 44 | float | 0x44238000 (654) | table field `b` (Float)
+ +0x00EC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x00FC | offset to field `c` (table)
+ +0x00F0 | 00 00 00 00 00 D8 8E 40 | double | 0x408ED80000000000 (987) | table field `a` (Double)
+ +0x00F8 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+table (AnnotatedBinary.Baz):
+ +0x00FC | 6A FE FF FF | SOffset32 | 0xFFFFFE6A (-406) Loc: +0x0292 | offset to vtable
+ +0x0100 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x0103 | 03 | uint8_t | 0x03 (3) | table field `meal` (Byte)
+
+vtable (AnnotatedBinary.Baz):
+ +0x0104 | 04 00 | uint16_t | 0x0004 (4) | size of this vtable
+ +0x0106 | 04 00 | uint16_t | 0x0004 (4) | size of referring table
+
+table (AnnotatedBinary.Baz):
+ +0x0108 | 04 00 00 00 | SOffset32 | 0x00000004 (4) Loc: +0x0104 | offset to vtable
+
+table (AnnotatedBinary.Bar):
+ +0x010C | FA FE FF FF | SOffset32 | 0xFFFFFEFA (-262) Loc: +0x0212 | offset to vtable
+ +0x0110 | 00 00 E4 43 | float | 0x43E40000 (456) | table field `b` (Float)
+ +0x0114 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x0124 | offset to field `c` (table)
+ +0x0118 | 00 00 00 00 00 C0 5E 40 | double | 0x405EC00000000000 (123) | table field `a` (Double)
+ +0x0120 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+table (AnnotatedBinary.Baz):
+ +0x0124 | 92 FE FF FF | SOffset32 | 0xFFFFFE92 (-366) Loc: +0x0292 | offset to vtable
+ +0x0128 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x012B | 01 | uint8_t | 0x01 (1) | table field `meal` (Byte)
+
+vector (AnnotatedBinary.Foo.foobars_type):
+ +0x012C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0130 | 01 | UType8 | 0x01 (1) | value[0]
+ +0x0131 | 02 | UType8 | 0x02 (2) | value[1]
+ +0x0132 | 01 | UType8 | 0x01 (1) | value[2]
+
+vector (AnnotatedBinary.Foo.points_of_interest):
+ +0x0134 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0138 | 33 33 33 33 33 A3 45 40 | double | 0x4045A33333333333 (43.275) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0140 | 7E 57 04 FF 5B 87 53 C0 | double | 0xC053875BFF04577E (-78.115) | struct field `AnnotatedBinary.Location.longitude` (Double)
+ +0x0148 | 8D F0 F6 20 04 B6 42 40 | double | 0x4042B60420F6F08D (37.422) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0150 | 9F 77 63 41 61 85 5E C0 | double | 0xC05E85614163779F (-122.084) | struct field `AnnotatedBinary.Location.longitude` (Double)
+ +0x0158 | 8F 35 23 83 DC 35 4B C0 | double | 0xC04B35DC8323358F (-54.4208) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0160 | F6 97 DD 93 87 C5 0A 40 | double | 0x400AC58793DD97F6 (3.34645) | struct field `AnnotatedBinary.Location.longitude` (Double)
+
+padding:
+ +0x0168 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (AnnotatedBinary.Foo.names):
+ +0x016C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0170 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x0190 | offset to string[0]
+ +0x0174 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x0188 | offset to string[1]
+ +0x0178 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x017C | offset to string[2]
+
+string (AnnotatedBinary.Foo.names):
+ +0x017C | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x0180 | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x0187 | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.names):
+ +0x0188 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x018C | 62 6F 62 | char[3] | bob | string literal
+ +0x018F | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.names):
+ +0x0190 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x0194 | 61 6C 69 63 65 | char[5] | alice | string literal
+ +0x0199 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x019A | 00 00 | uint8_t[2] | .. | padding
+
+string (AnnotatedBinary.Foo.alice):
+ +0x019C | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x01A0 | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x01A7 | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.bob):
+ +0x01A8 | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x01AC | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x01B3 | 00 | char | 0x00 (0) | string terminator
+
+vector (AnnotatedBinary.Foo.accounts):
+ +0x01B4 | 09 00 00 00 | uint32_t | 0x00000009 (9) | length of vector (# items)
+ +0x01B8 | 09 00 | uint16_t | 0x0009 (9) | value[0]
+ +0x01BA | 08 00 | uint16_t | 0x0008 (8) | value[1]
+ +0x01BC | 07 00 | uint16_t | 0x0007 (7) | value[2]
+ +0x01BE | 01 00 | uint16_t | 0x0001 (1) | value[3]
+ +0x01C0 | 02 00 | uint16_t | 0x0002 (2) | value[4]
+ +0x01C2 | 03 00 | uint16_t | 0x0003 (3) | value[5]
+ +0x01C4 | 06 00 | uint16_t | 0x0006 (6) | value[6]
+ +0x01C6 | 05 00 | uint16_t | 0x0005 (5) | value[7]
+ +0x01C8 | 04 00 | uint16_t | 0x0004 (4) | value[8]
+
+padding:
+ +0x01CA | 00 00 | uint8_t[2] | .. | padding
+
+table (AnnotatedBinary.Baz):
+ +0x01CC | 3A FF FF FF | SOffset32 | 0xFFFFFF3A (-198) Loc: +0x0292 | offset to vtable
+ +0x01D0 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x01D3 | 03 | uint8_t | 0x03 (3) | table field `meal` (Byte)
+
+vector (AnnotatedBinary.Foo.bars):
+ +0x01D4 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x01D8 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x021C | offset to table[0]
+ +0x01DC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x01EC | offset to table[1]
+
+padding:
+ +0x01E0 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Bar):
+ +0x01E2 | 0A 00 | uint16_t | 0x000A (10) | size of this vtable
+ +0x01E4 | 1A 00 | uint16_t | 0x001A (26) | size of referring table
+ +0x01E6 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `a` (id: 0)
+ +0x01E8 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+ +0x01EA | 08 00 | VOffset16 | 0x0008 (8) | offset to field `c` (id: 2)
+
+table (AnnotatedBinary.Bar):
+ +0x01EC | 0A 00 00 00 | SOffset32 | 0x0000000A (10) Loc: +0x01E2 | offset to vtable
+ +0x01F0 | 00 80 23 44 | float | 0x44238000 (654) | table field `b` (Float)
+ +0x01F4 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x020C | offset to field `c` (table)
+ +0x01F8 | 00 00 00 00 00 D8 8E 40 | double | 0x408ED80000000000 (987) | table field `a` (Double)
+ +0x0200 | 00 00 00 00 00 00 | uint8_t[6] | ...... | padding
+
+vtable (AnnotatedBinary.Baz):
+ +0x0206 | 06 00 | uint16_t | 0x0006 (6) | size of this vtable
+ +0x0208 | 06 00 | uint16_t | 0x0006 (6) | size of referring table
+ +0x020A | 05 00 | VOffset16 | 0x0005 (5) | offset to field `meal` (id: 0)
+
+table (AnnotatedBinary.Baz):
+ +0x020C | 06 00 00 00 | SOffset32 | 0x00000006 (6) Loc: +0x0206 | offset to vtable
+ +0x0210 | 00 | uint8_t[1] | . | padding
+ +0x0211 | 03 | uint8_t | 0x03 (3) | table field `meal` (Byte)
+
+vtable (AnnotatedBinary.Bar):
+ +0x0212 | 0A 00 | uint16_t | 0x000A (10) | size of this vtable
+ +0x0214 | 18 00 | uint16_t | 0x0018 (24) | size of referring table
+ +0x0216 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `a` (id: 0)
+ +0x0218 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+ +0x021A | 08 00 | VOffset16 | 0x0008 (8) | offset to field `c` (id: 2)
+
+table (AnnotatedBinary.Bar):
+ +0x021C | 0A 00 00 00 | SOffset32 | 0x0000000A (10) Loc: +0x0212 | offset to vtable
+ +0x0220 | 00 00 E4 43 | float | 0x43E40000 (456) | table field `b` (Float)
+ +0x0224 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x0234 | offset to field `c` (table)
+ +0x0228 | 00 00 00 00 00 C0 5E 40 | double | 0x405EC00000000000 (123) | table field `a` (Double)
+ +0x0230 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+table (AnnotatedBinary.Baz):
+ +0x0234 | A2 FF FF FF | SOffset32 | 0xFFFFFFA2 (-94) Loc: +0x0292 | offset to vtable
+ +0x0238 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x023B | 01 | uint8_t | 0x01 (1) | table field `meal` (Byte)
+
+string (AnnotatedBinary.Foo.name):
+ +0x023C | 2F 00 00 00 | uint32_t | 0x0000002F (47) | length of string
+ +0x0240 | 54 68 69 73 20 69 73 20 | char[47] | This is | string literal
+ +0x0248 | 61 20 6C 6F 6E 67 20 73 | | a long s
+ +0x0250 | 74 72 69 6E 67 20 74 6F | | tring to
+ +0x0258 | 20 73 68 6F 77 20 68 6F | | show ho
+ +0x0260 | 77 20 69 74 20 62 72 65 | | w it bre
+ +0x0268 | 61 6B 73 20 75 70 2E | | aks up.
+ +0x026F | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x0270 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Bar):
+ +0x0272 | 0A 00 | uint16_t | 0x000A (10) | size of this vtable
+ +0x0274 | 16 00 | uint16_t | 0x0016 (22) | size of referring table
+ +0x0276 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `a` (id: 0)
+ +0x0278 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+ +0x027A | 08 00 | VOffset16 | 0x0008 (8) | offset to field `c` (id: 2)
+
+table (AnnotatedBinary.Bar):
+ +0x027C | 0A 00 00 00 | SOffset32 | 0x0000000A (10) Loc: +0x0272 | offset to vtable
+ +0x0280 | 65 20 71 49 | float | 0x49712065 (987654) | table field `b` (Float)
+ +0x0284 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x0298 | offset to field `c` (table)
+ +0x0288 | C9 76 BE 9F 0C 24 FE 40 | double | 0x40FE240C9FBE76C9 (123457) | table field `a` (Double)
+ +0x0290 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Baz):
+ +0x0292 | 06 00 | uint16_t | 0x0006 (6) | size of this vtable
+ +0x0294 | 08 00 | uint16_t | 0x0008 (8) | size of referring table
+ +0x0296 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `meal` (id: 0)
+
+table (AnnotatedBinary.Baz):
+ +0x0298 | 06 00 00 00 | SOffset32 | 0x00000006 (6) Loc: +0x0292 | offset to vtable
+ +0x029C | 00 00 00 | uint8_t[3] | ... | padding
+ +0x029F | 01 | uint8_t | 0x01 (1) | table field `meal` (Byte)
diff --git a/tests/annotated_binary/tests/invalid_string_length.bin b/tests/annotated_binary/tests/invalid_string_length.bin
new file mode 100644
index 0000000..c4ef678
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_string_length.bin
Binary files differ
diff --git a/tests/annotated_binary/tests/invalid_string_length_cut_short.afb b/tests/annotated_binary/tests/invalid_string_length_cut_short.afb
new file mode 100644
index 0000000..66f397a
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_string_length_cut_short.afb
@@ -0,0 +1,80 @@
+// Annotated Flatbuffer Binary
+//
+// Schema file: annotated_binary.fbs
+// Binary file: tests/invalid_string_length_cut_short.bin
+
+header:
+ +0x00 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x44 | offset to root table `AnnotatedBinary.Foo`
+ +0x04 | 41 4E 4E 4F | char[4] | ANNO | File Identifier
+
+padding:
+ +0x08 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Foo):
+ +0x0A | 3A 00 | uint16_t | 0x003A (58) | size of this vtable
+ +0x0C | 68 00 | uint16_t | 0x0068 (104) | size of referring table
+ +0x0E | 0C 00 | VOffset16 | 0x000C (12) | offset to field `counter` (id: 0)
+ +0x10 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `healthy` (id: 1)
+ +0x12 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `level` (id: 2) <defaults to 99> (Long)
+ +0x14 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `meal` (id: 3)
+ +0x16 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `bar` (id: 4)
+ +0x18 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `home` (id: 5)
+ +0x1A | 30 00 | VOffset16 | 0x0030 (48) | offset to field `name` (id: 6)
+ +0x1C | 34 00 | VOffset16 | 0x0034 (52) | offset to field `bars` (id: 7)
+ +0x1E | 09 00 | VOffset16 | 0x0009 (9) | offset to field `bar_baz_type` (id: 8)
+ +0x20 | 38 00 | VOffset16 | 0x0038 (56) | offset to field `bar_baz` (id: 9)
+ +0x22 | 3C 00 | VOffset16 | 0x003C (60) | offset to field `accounts` (id: 10)
+ +0x24 | 40 00 | VOffset16 | 0x0040 (64) | offset to field `bob` (id: 11)
+ +0x26 | 44 00 | VOffset16 | 0x0044 (68) | offset to field `alice` (id: 12)
+ +0x28 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `maybe_i32` (id: 13) <defaults to 0> (Int)
+ +0x2A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_i32` (id: 14) <defaults to 42> (Int)
+ +0x2C | 48 00 | VOffset16 | 0x0048 (72) | offset to field `just_i32` (id: 15)
+ +0x2E | 4C 00 | VOffset16 | 0x004C (76) | offset to field `names` (id: 16)
+ +0x30 | 50 00 | VOffset16 | 0x0050 (80) | offset to field `points_of_interest` (id: 17)
+ +0x32 | 54 00 | VOffset16 | 0x0054 (84) | offset to field `foobars_type` (id: 18)
+ +0x34 | 58 00 | VOffset16 | 0x0058 (88) | offset to field `foobars` (id: 19)
+ +0x36 | 0A 00 | VOffset16 | 0x000A (10) | offset to field `measurement_type` (id: 20)
+ +0x38 | 5C 00 | VOffset16 | 0x005C (92) | offset to field `measurement` (id: 21)
+ +0x3A | 0B 00 | VOffset16 | 0x000B (11) | offset to field `anything_type` (id: 22)
+ +0x3C | 60 00 | VOffset16 | 0x0060 (96) | offset to field `anything` (id: 23)
+ +0x3E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `temperature` (id: 24) <defaults to 98.600000> (Float)
+ +0x40 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `teetotaler` (id: 25) <null> (Obj)
+ +0x42 | 64 00 | VOffset16 | 0x0064 (100) | offset to field `charlie` (id: 26)
+
+root_table (AnnotatedBinary.Foo):
+ +0x44 | 3A 00 00 00 | SOffset32 | 0x0000003A (58) Loc: +0x0A | offset to vtable
+ +0x48 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x4B | 01 | uint8_t | 0x01 (1) | table field `healthy` (Bool)
+ +0x4C | 02 | uint8_t | 0x02 (2) | table field `meal` (Byte)
+ +0x4D | 02 | UType8 | 0x02 (2) | table field `bar_baz_type` (UType)
+ +0x4E | 01 | UType8 | 0x01 (1) | table field `measurement_type` (UType)
+ +0x4F | 01 | UType8 | 0x01 (1) | table field `anything_type` (UType)
+ +0x50 | D2 04 00 00 | uint32_t | 0x000004D2 (1234) | table field `counter` (Int)
+ +0x54 | 28 02 00 00 | UOffset32 | 0x00000228 (552) Loc: +0x27C | ERROR: offset to field `bar`. Invalid offset, points outside the binary.
+ +0x58 | 01 00 00 00 | uint32_t | 0x00000001 (1) | struct field `AnnotatedBinary.Building.floors` (Int)
+ +0x5C | 02 00 00 00 | uint32_t | 0x00000002 (2) | struct field `AnnotatedBinary.Building.doors` (Int)
+ +0x60 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | struct field `AnnotatedBinary.Building.windows` (Int)
+ +0x64 | 0A 00 00 00 | uint32_t | 0x0000000A (10) | array field `AnnotatedBinary.Dimension.values`[0] (Int)
+ +0x68 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | array field `AnnotatedBinary.Dimension.values`[1] (Int)
+ +0x6C | 14 00 00 00 | uint32_t | 0x00000014 (20) | array field `AnnotatedBinary.Dimension.values`[2] (Int)
+ +0x70 | 01 | uint8_t | 0x01 (1) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x71 | 02 | uint8_t | 0x02 (2) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x72 | 03 | uint8_t | 0x03 (3) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x73 | 00 | uint8_t[1] | . | padding
+ +0x74 | C8 01 00 00 | UOffset32 | 0x000001C8 (456) Loc: +0x23C | ERROR: offset to field `name`. Invalid offset, points outside the binary.
+ +0x78 | 5C 01 00 00 | UOffset32 | 0x0000015C (348) Loc: +0x1D4 | ERROR: offset to field `bars`. Invalid offset, points outside the binary.
+ +0x7C | 50 01 00 00 | UOffset32 | 0x00000150 (336) Loc: +0x1CC | ERROR: offset to field `bar_baz`. Invalid offset, points outside the binary.
+ +0x80 | 34 01 00 00 | UOffset32 | 0x00000134 (308) Loc: +0x1B4 | ERROR: offset to field `accounts`. Invalid offset, points outside the binary.
+ +0x84 | 24 01 00 00 | UOffset32 | 0x00000124 (292) Loc: +0x1A8 | ERROR: offset to field `bob`. Invalid offset, points outside the binary.
+ +0x88 | 14 01 00 00 | UOffset32 | 0x00000114 (276) Loc: +0x19C | ERROR: offset to field `alice`. Invalid offset, points outside the binary.
+ +0x8C | 0D 00 00 00 | uint32_t | 0x0000000D (13) | table field `just_i32` (Int)
+ +0x90 | DC 00 00 00 | UOffset32 | 0x000000DC (220) Loc: +0x16C | ERROR: offset to field `names`. Invalid offset, points outside the binary.
+ +0x94 | A0 00 00 00 | UOffset32 | 0x000000A0 (160) Loc: +0x134 | ERROR: offset to field `points_of_interest`. Invalid offset, points outside the binary.
+ +0x98 | 94 00 00 00 | UOffset32 | 0x00000094 (148) Loc: +0x12C | ERROR: offset to field `foobars_type`. Invalid offset, points outside the binary.
+ +0x9C | 38 00 00 00 | UOffset32 | 0x00000038 (56) Loc: +0xD4 | ERROR: offset to field `foobars`. Invalid offset, points outside the binary.
+ +0xA0 | 33 00 00 00 | UOffset32 | 0x00000033 (51) Loc: +0xD3 | ERROR: offset to field `measurement`. Invalid offset, points outside the binary.
+ +0xA4 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0xC0 | ERROR: offset to field `anything`. Invalid offset, points outside the binary.
+ +0xA8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0xAC | offset to field `charlie` (string)
+
+string (AnnotatedBinary.Foo.charlie):
+ +0xAC | 05 00 | ?uint8_t[2] | .. | ERROR: length of string. Incomplete binary, expected to read 4 bytes.
diff --git a/tests/annotated_binary/tests/invalid_string_length_cut_short.bin b/tests/annotated_binary/tests/invalid_string_length_cut_short.bin
new file mode 100644
index 0000000..69f7e11
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_string_length_cut_short.bin
Binary files differ
diff --git a/tests/annotated_binary/tests/invalid_struct_array_field_cut_short.afb b/tests/annotated_binary/tests/invalid_struct_array_field_cut_short.afb
new file mode 100644
index 0000000..75be69a
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_struct_array_field_cut_short.afb
@@ -0,0 +1,72 @@
+// Annotated Flatbuffer Binary
+//
+// Schema file: annotated_binary.fbs
+// Binary file: tests/invalid_struct_array_field_cut_short.bin
+
+header:
+ +0x00 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x44 | offset to root table `AnnotatedBinary.Foo`
+ +0x04 | 41 4E 4E 4F | char[4] | ANNO | File Identifier
+
+padding:
+ +0x08 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Foo):
+ +0x0A | 3A 00 | uint16_t | 0x003A (58) | size of this vtable
+ +0x0C | 68 00 | uint16_t | 0x0068 (104) | ERROR: size of referring table. Longer than the binary.
+ +0x0E | 0C 00 | VOffset16 | 0x000C (12) | offset to field `counter` (id: 0)
+ +0x10 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `healthy` (id: 1)
+ +0x12 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `level` (id: 2) <defaults to 99> (Long)
+ +0x14 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `meal` (id: 3)
+ +0x16 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `bar` (id: 4)
+ +0x18 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `home` (id: 5)
+ +0x1A | 30 00 | VOffset16 | 0x0030 (48) | ERROR: offset to field `name` (id: 6). Invalid offset, points outside the binary.
+ +0x1C | 34 00 | VOffset16 | 0x0034 (52) | ERROR: offset to field `bars` (id: 7). Invalid offset, points outside the binary.
+ +0x1E | 09 00 | VOffset16 | 0x0009 (9) | offset to field `bar_baz_type` (id: 8)
+ +0x20 | 38 00 | VOffset16 | 0x0038 (56) | ERROR: offset to field `bar_baz` (id: 9). Invalid offset, points outside the binary.
+ +0x22 | 3C 00 | VOffset16 | 0x003C (60) | ERROR: offset to field `accounts` (id: 10). Invalid offset, points outside the binary.
+ +0x24 | 40 00 | VOffset16 | 0x0040 (64) | ERROR: offset to field `bob` (id: 11). Invalid offset, points outside the binary.
+ +0x26 | 44 00 | VOffset16 | 0x0044 (68) | ERROR: offset to field `alice` (id: 12). Invalid offset, points outside the binary.
+ +0x28 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `maybe_i32` (id: 13) <defaults to 0> (Int)
+ +0x2A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_i32` (id: 14) <defaults to 42> (Int)
+ +0x2C | 48 00 | VOffset16 | 0x0048 (72) | ERROR: offset to field `just_i32` (id: 15). Invalid offset, points outside the binary.
+ +0x2E | 4C 00 | VOffset16 | 0x004C (76) | ERROR: offset to field `names` (id: 16). Invalid offset, points outside the binary.
+ +0x30 | 50 00 | VOffset16 | 0x0050 (80) | ERROR: offset to field `points_of_interest` (id: 17). Invalid offset, points outside the binary.
+ +0x32 | 54 00 | VOffset16 | 0x0054 (84) | ERROR: offset to field `foobars_type` (id: 18). Invalid offset, points outside the binary.
+ +0x34 | 58 00 | VOffset16 | 0x0058 (88) | ERROR: offset to field `foobars` (id: 19). Invalid offset, points outside the binary.
+ +0x36 | 0A 00 | VOffset16 | 0x000A (10) | offset to field `measurement_type` (id: 20)
+ +0x38 | 5C 00 | VOffset16 | 0x005C (92) | ERROR: offset to field `measurement` (id: 21). Invalid offset, points outside the binary.
+ +0x3A | 0B 00 | VOffset16 | 0x000B (11) | offset to field `anything_type` (id: 22)
+ +0x3C | 60 00 | VOffset16 | 0x0060 (96) | ERROR: offset to field `anything` (id: 23). Invalid offset, points outside the binary.
+ +0x3E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `temperature` (id: 24) <defaults to 98.600000> (Float)
+ +0x40 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `teetotaler` (id: 25) <null> (Obj)
+ +0x42 | 64 00 | VOffset16 | 0x0064 (100) | ERROR: offset to field `charlie` (id: 26). Invalid offset, points outside the binary.
+ +0x28 | 00 00 | VOffset16 | 0x0000 (0) | offset to unknown field (id: 13)
+ +0x2A | 00 00 | VOffset16 | 0x0000 (0) | offset to unknown field (id: 14)
+ +0x2C | 48 00 | VOffset16 | 0x0048 (72) | offset to unknown field (id: 15)
+ +0x2E | 4C 00 | VOffset16 | 0x004C (76) | offset to unknown field (id: 16)
+ +0x30 | 50 00 | VOffset16 | 0x0050 (80) | offset to unknown field (id: 17)
+ +0x32 | 54 00 | VOffset16 | 0x0054 (84) | offset to unknown field (id: 18)
+ +0x34 | 58 00 | VOffset16 | 0x0058 (88) | offset to unknown field (id: 19)
+ +0x36 | 0A 00 | VOffset16 | 0x000A (10) | offset to unknown field (id: 20)
+ +0x38 | 5C 00 | VOffset16 | 0x005C (92) | offset to unknown field (id: 21)
+ +0x3A | 0B 00 | VOffset16 | 0x000B (11) | offset to unknown field (id: 22)
+ +0x3C | 60 00 | VOffset16 | 0x0060 (96) | offset to unknown field (id: 23)
+ +0x3E | 00 00 | VOffset16 | 0x0000 (0) | offset to unknown field (id: 24)
+ +0x40 | 00 00 | VOffset16 | 0x0000 (0) | offset to unknown field (id: 25)
+ +0x42 | 64 00 | VOffset16 | 0x0064 (100) | offset to unknown field (id: 26)
+
+root_table (AnnotatedBinary.Foo):
+ +0x44 | 3A 00 00 00 | SOffset32 | 0x0000003A (58) Loc: +0x0A | offset to vtable
+ +0x48 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x4B | 01 | uint8_t | 0x01 (1) | table field `healthy` (Bool)
+ +0x4C | 02 | uint8_t | 0x02 (2) | table field `meal` (Byte)
+ +0x4D | 02 | UType8 | 0x02 (2) | table field `bar_baz_type` (UType)
+ +0x4E | 01 | UType8 | 0x01 (1) | table field `measurement_type` (UType)
+ +0x4F | 01 | UType8 | 0x01 (1) | table field `anything_type` (UType)
+ +0x50 | D2 04 00 00 | uint32_t | 0x000004D2 (1234) | table field `counter` (Int)
+ +0x54 | 28 02 00 00 | UOffset32 | 0x00000228 (552) Loc: +0x27C | ERROR: offset to field `bar`. Invalid offset, points outside the binary.
+ +0x58 | 01 00 00 00 | uint32_t | 0x00000001 (1) | struct field `AnnotatedBinary.Building.floors` (Int)
+ +0x5C | 02 00 00 00 | uint32_t | 0x00000002 (2) | struct field `AnnotatedBinary.Building.doors` (Int)
+ +0x60 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | struct field `AnnotatedBinary.Building.windows` (Int)
+ +0x64 | 0A 00 00 00 | uint32_t | 0x0000000A (10) | array field `AnnotatedBinary.Dimension.values`[0] (Int)
+ +0x68 | 0C 00 | ?uint8_t[2] | .. | ERROR: array field `AnnotatedBinary.Dimension.values`[1] (Int). Incomplete binary, expected to read 4 bytes.
diff --git a/tests/annotated_binary/tests/invalid_struct_array_field_cut_short.bin b/tests/annotated_binary/tests/invalid_struct_array_field_cut_short.bin
new file mode 100644
index 0000000..b701f73
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_struct_array_field_cut_short.bin
Binary files differ
diff --git a/tests/annotated_binary/tests/invalid_struct_field_cut_short.afb b/tests/annotated_binary/tests/invalid_struct_field_cut_short.afb
new file mode 100644
index 0000000..59f646c
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_struct_field_cut_short.afb
@@ -0,0 +1,69 @@
+// Annotated Flatbuffer Binary
+//
+// Schema file: annotated_binary.fbs
+// Binary file: tests/invalid_struct_field_cut_short.bin
+
+header:
+ +0x00 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x44 | offset to root table `AnnotatedBinary.Foo`
+ +0x04 | 41 4E 4E 4F | char[4] | ANNO | File Identifier
+
+padding:
+ +0x08 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Foo):
+ +0x0A | 3A 00 | uint16_t | 0x003A (58) | size of this vtable
+ +0x0C | 68 00 | uint16_t | 0x0068 (104) | ERROR: size of referring table. Longer than the binary.
+ +0x0E | 0C 00 | VOffset16 | 0x000C (12) | offset to field `counter` (id: 0)
+ +0x10 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `healthy` (id: 1)
+ +0x12 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `level` (id: 2) <defaults to 99> (Long)
+ +0x14 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `meal` (id: 3)
+ +0x16 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `bar` (id: 4)
+ +0x18 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `home` (id: 5)
+ +0x1A | 30 00 | VOffset16 | 0x0030 (48) | ERROR: offset to field `name` (id: 6). Invalid offset, points outside the binary.
+ +0x1C | 34 00 | VOffset16 | 0x0034 (52) | ERROR: offset to field `bars` (id: 7). Invalid offset, points outside the binary.
+ +0x1E | 09 00 | VOffset16 | 0x0009 (9) | offset to field `bar_baz_type` (id: 8)
+ +0x20 | 38 00 | VOffset16 | 0x0038 (56) | ERROR: offset to field `bar_baz` (id: 9). Invalid offset, points outside the binary.
+ +0x22 | 3C 00 | VOffset16 | 0x003C (60) | ERROR: offset to field `accounts` (id: 10). Invalid offset, points outside the binary.
+ +0x24 | 40 00 | VOffset16 | 0x0040 (64) | ERROR: offset to field `bob` (id: 11). Invalid offset, points outside the binary.
+ +0x26 | 44 00 | VOffset16 | 0x0044 (68) | ERROR: offset to field `alice` (id: 12). Invalid offset, points outside the binary.
+ +0x28 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `maybe_i32` (id: 13) <defaults to 0> (Int)
+ +0x2A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_i32` (id: 14) <defaults to 42> (Int)
+ +0x2C | 48 00 | VOffset16 | 0x0048 (72) | ERROR: offset to field `just_i32` (id: 15). Invalid offset, points outside the binary.
+ +0x2E | 4C 00 | VOffset16 | 0x004C (76) | ERROR: offset to field `names` (id: 16). Invalid offset, points outside the binary.
+ +0x30 | 50 00 | VOffset16 | 0x0050 (80) | ERROR: offset to field `points_of_interest` (id: 17). Invalid offset, points outside the binary.
+ +0x32 | 54 00 | VOffset16 | 0x0054 (84) | ERROR: offset to field `foobars_type` (id: 18). Invalid offset, points outside the binary.
+ +0x34 | 58 00 | VOffset16 | 0x0058 (88) | ERROR: offset to field `foobars` (id: 19). Invalid offset, points outside the binary.
+ +0x36 | 0A 00 | VOffset16 | 0x000A (10) | offset to field `measurement_type` (id: 20)
+ +0x38 | 5C 00 | VOffset16 | 0x005C (92) | ERROR: offset to field `measurement` (id: 21). Invalid offset, points outside the binary.
+ +0x3A | 0B 00 | VOffset16 | 0x000B (11) | offset to field `anything_type` (id: 22)
+ +0x3C | 60 00 | VOffset16 | 0x0060 (96) | ERROR: offset to field `anything` (id: 23). Invalid offset, points outside the binary.
+ +0x3E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `temperature` (id: 24) <defaults to 98.600000> (Float)
+ +0x40 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `teetotaler` (id: 25) <null> (Obj)
+ +0x42 | 64 00 | VOffset16 | 0x0064 (100) | ERROR: offset to field `charlie` (id: 26). Invalid offset, points outside the binary.
+ +0x28 | 00 00 | VOffset16 | 0x0000 (0) | offset to unknown field (id: 13)
+ +0x2A | 00 00 | VOffset16 | 0x0000 (0) | offset to unknown field (id: 14)
+ +0x2C | 48 00 | VOffset16 | 0x0048 (72) | offset to unknown field (id: 15)
+ +0x2E | 4C 00 | VOffset16 | 0x004C (76) | offset to unknown field (id: 16)
+ +0x30 | 50 00 | VOffset16 | 0x0050 (80) | offset to unknown field (id: 17)
+ +0x32 | 54 00 | VOffset16 | 0x0054 (84) | offset to unknown field (id: 18)
+ +0x34 | 58 00 | VOffset16 | 0x0058 (88) | offset to unknown field (id: 19)
+ +0x36 | 0A 00 | VOffset16 | 0x000A (10) | offset to unknown field (id: 20)
+ +0x38 | 5C 00 | VOffset16 | 0x005C (92) | offset to unknown field (id: 21)
+ +0x3A | 0B 00 | VOffset16 | 0x000B (11) | offset to unknown field (id: 22)
+ +0x3C | 60 00 | VOffset16 | 0x0060 (96) | offset to unknown field (id: 23)
+ +0x3E | 00 00 | VOffset16 | 0x0000 (0) | offset to unknown field (id: 24)
+ +0x40 | 00 00 | VOffset16 | 0x0000 (0) | offset to unknown field (id: 25)
+ +0x42 | 64 00 | VOffset16 | 0x0064 (100) | offset to unknown field (id: 26)
+
+root_table (AnnotatedBinary.Foo):
+ +0x44 | 3A 00 00 00 | SOffset32 | 0x0000003A (58) Loc: +0x0A | offset to vtable
+ +0x48 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x4B | 01 | uint8_t | 0x01 (1) | table field `healthy` (Bool)
+ +0x4C | 02 | uint8_t | 0x02 (2) | table field `meal` (Byte)
+ +0x4D | 02 | UType8 | 0x02 (2) | table field `bar_baz_type` (UType)
+ +0x4E | 01 | UType8 | 0x01 (1) | table field `measurement_type` (UType)
+ +0x4F | 01 | UType8 | 0x01 (1) | table field `anything_type` (UType)
+ +0x50 | D2 04 00 00 | uint32_t | 0x000004D2 (1234) | table field `counter` (Int)
+ +0x54 | 28 02 00 00 | UOffset32 | 0x00000228 (552) Loc: +0x27C | ERROR: offset to field `bar`. Invalid offset, points outside the binary.
+ +0x58 | 01 00 00 00 | uint32_t | 0x00000001 (1) | struct field `AnnotatedBinary.Building.floors` (Int)
+ +0x5C | 02 00 | ?uint8_t[2] | .. | ERROR: struct field `AnnotatedBinary.Building.doors` (Int). Incomplete binary, expected to read 4 bytes.
diff --git a/tests/annotated_binary/tests/invalid_struct_field_cut_short.bin b/tests/annotated_binary/tests/invalid_struct_field_cut_short.bin
new file mode 100644
index 0000000..537352d
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_struct_field_cut_short.bin
Binary files differ
diff --git a/tests/annotated_binary/tests/invalid_table_field_offset.afb b/tests/annotated_binary/tests/invalid_table_field_offset.afb
new file mode 100644
index 0000000..4ccd3a7
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_table_field_offset.afb
@@ -0,0 +1,77 @@
+// Annotated Flatbuffer Binary
+//
+// Schema file: annotated_binary.fbs
+// Binary file: tests/invalid_table_field_offset.bin
+
+header:
+ +0x00 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x44 | offset to root table `AnnotatedBinary.Foo`
+ +0x04 | 41 4E 4E 4F | char[4] | ANNO | File Identifier
+
+padding:
+ +0x08 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Foo):
+ +0x0A | 3A 00 | uint16_t | 0x003A (58) | size of this vtable
+ +0x0C | 68 00 | uint16_t | 0x0068 (104) | ERROR: size of referring table. Longer than the binary.
+ +0x0E | 0C 00 | VOffset16 | 0x000C (12) | offset to field `counter` (id: 0)
+ +0x10 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `healthy` (id: 1)
+ +0x12 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `level` (id: 2) <defaults to 99> (Long)
+ +0x14 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `meal` (id: 3)
+ +0x16 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `bar` (id: 4)
+ +0x18 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `home` (id: 5)
+ +0x1A | 30 00 | VOffset16 | 0x0030 (48) | offset to field `name` (id: 6)
+ +0x1C | 34 00 | VOffset16 | 0x0034 (52) | offset to field `bars` (id: 7)
+ +0x1E | 09 00 | VOffset16 | 0x0009 (9) | offset to field `bar_baz_type` (id: 8)
+ +0x20 | 38 00 | VOffset16 | 0x0038 (56) | offset to field `bar_baz` (id: 9)
+ +0x22 | 3C 00 | VOffset16 | 0x003C (60) | offset to field `accounts` (id: 10)
+ +0x24 | 40 00 | VOffset16 | 0x0040 (64) | offset to field `bob` (id: 11)
+ +0x26 | 44 00 | VOffset16 | 0x0044 (68) | offset to field `alice` (id: 12)
+ +0x28 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `maybe_i32` (id: 13) <defaults to 0> (Int)
+ +0x2A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_i32` (id: 14) <defaults to 42> (Int)
+ +0x2C | 48 00 | VOffset16 | 0x0048 (72) | offset to field `just_i32` (id: 15)
+ +0x2E | 4C 00 | VOffset16 | 0x004C (76) | offset to field `names` (id: 16)
+ +0x30 | 50 00 | VOffset16 | 0x0050 (80) | offset to field `points_of_interest` (id: 17)
+ +0x32 | 54 00 | VOffset16 | 0x0054 (84) | ERROR: offset to field `foobars_type` (id: 18). Invalid offset, points outside the binary.
+ +0x34 | 58 00 | VOffset16 | 0x0058 (88) | ERROR: offset to field `foobars` (id: 19). Invalid offset, points outside the binary.
+ +0x36 | 0A 00 | VOffset16 | 0x000A (10) | offset to field `measurement_type` (id: 20)
+ +0x38 | 5C 00 | VOffset16 | 0x005C (92) | ERROR: offset to field `measurement` (id: 21). Invalid offset, points outside the binary.
+ +0x3A | 0B 00 | VOffset16 | 0x000B (11) | offset to field `anything_type` (id: 22)
+ +0x3C | 60 00 | VOffset16 | 0x0060 (96) | ERROR: offset to field `anything` (id: 23). Invalid offset, points outside the binary.
+ +0x3E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `temperature` (id: 24) <defaults to 98.600000> (Float)
+ +0x40 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `teetotaler` (id: 25) <null> (Obj)
+ +0x42 | 64 00 | VOffset16 | 0x0064 (100) | ERROR: offset to field `charlie` (id: 26). Invalid offset, points outside the binary.
+ +0x3A | 0B 00 | VOffset16 | 0x000B (11) | offset to unknown field (id: 22)
+ +0x3C | 60 00 | VOffset16 | 0x0060 (96) | offset to unknown field (id: 23)
+ +0x3E | 00 00 | VOffset16 | 0x0000 (0) | offset to unknown field (id: 24)
+ +0x40 | 00 00 | VOffset16 | 0x0000 (0) | offset to unknown field (id: 25)
+ +0x42 | 64 00 | VOffset16 | 0x0064 (100) | offset to unknown field (id: 26)
+
+root_table (AnnotatedBinary.Foo):
+ +0x44 | 3A 00 00 00 | SOffset32 | 0x0000003A (58) Loc: +0x0A | offset to vtable
+ +0x48 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x4B | 01 | uint8_t | 0x01 (1) | table field `healthy` (Bool)
+ +0x4C | 02 | uint8_t | 0x02 (2) | table field `meal` (Byte)
+ +0x4D | 02 | UType8 | 0x02 (2) | table field `bar_baz_type` (UType)
+ +0x4E | 01 | UType8 | 0x01 (1) | table field `measurement_type` (UType)
+ +0x4F | 01 | UType8 | 0x01 (1) | table field `anything_type` (UType)
+ +0x50 | D2 04 00 00 | uint32_t | 0x000004D2 (1234) | table field `counter` (Int)
+ +0x54 | 28 02 00 00 | UOffset32 | 0x00000228 (552) Loc: +0x27C | ERROR: offset to field `bar`. Invalid offset, points outside the binary.
+ +0x58 | 01 00 00 00 | uint32_t | 0x00000001 (1) | struct field `AnnotatedBinary.Building.floors` (Int)
+ +0x5C | 02 00 00 00 | uint32_t | 0x00000002 (2) | struct field `AnnotatedBinary.Building.doors` (Int)
+ +0x60 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | struct field `AnnotatedBinary.Building.windows` (Int)
+ +0x64 | 0A 00 00 00 | uint32_t | 0x0000000A (10) | array field `AnnotatedBinary.Dimension.values`[0] (Int)
+ +0x68 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | array field `AnnotatedBinary.Dimension.values`[1] (Int)
+ +0x6C | 14 00 00 00 | uint32_t | 0x00000014 (20) | array field `AnnotatedBinary.Dimension.values`[2] (Int)
+ +0x70 | 01 | uint8_t | 0x01 (1) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x71 | 02 | uint8_t | 0x02 (2) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x72 | 03 | uint8_t | 0x03 (3) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x73 | 00 | uint8_t[1] | . | padding
+ +0x74 | C8 01 00 00 | UOffset32 | 0x000001C8 (456) Loc: +0x23C | ERROR: offset to field `name`. Invalid offset, points outside the binary.
+ +0x78 | 5C 01 00 00 | UOffset32 | 0x0000015C (348) Loc: +0x1D4 | ERROR: offset to field `bars`. Invalid offset, points outside the binary.
+ +0x7C | 50 01 00 00 | UOffset32 | 0x00000150 (336) Loc: +0x1CC | ERROR: offset to field `bar_baz`. Invalid offset, points outside the binary.
+ +0x80 | 34 01 00 00 | UOffset32 | 0x00000134 (308) Loc: +0x1B4 | ERROR: offset to field `accounts`. Invalid offset, points outside the binary.
+ +0x84 | 24 01 00 00 | UOffset32 | 0x00000124 (292) Loc: +0x1A8 | ERROR: offset to field `bob`. Invalid offset, points outside the binary.
+ +0x88 | 14 01 00 00 | UOffset32 | 0x00000114 (276) Loc: +0x19C | ERROR: offset to field `alice`. Invalid offset, points outside the binary.
+ +0x8C | 0D 00 00 00 | uint32_t | 0x0000000D (13) | table field `just_i32` (Int)
+ +0x90 | DC 00 00 00 | UOffset32 | 0x000000DC (220) Loc: +0x16C | ERROR: offset to field `names`. Invalid offset, points outside the binary.
+ +0x94 | A0 00 | ?uint8_t[2] | .. | ERROR: offset to field `points_of_interest`. Incomplete binary, expected to read 4 bytes.
diff --git a/tests/annotated_binary/tests/invalid_table_field_offset.bin b/tests/annotated_binary/tests/invalid_table_field_offset.bin
new file mode 100644
index 0000000..f3a79ed
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_table_field_offset.bin
Binary files differ
diff --git a/tests/annotated_binary/tests/invalid_table_field_size.afb b/tests/annotated_binary/tests/invalid_table_field_size.afb
new file mode 100644
index 0000000..f3ca3b9
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_table_field_size.afb
@@ -0,0 +1,68 @@
+// Annotated Flatbuffer Binary
+//
+// Schema file: annotated_binary.fbs
+// Binary file: tests/invalid_table_field_size.bin
+
+header:
+ +0x00 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x44 | offset to root table `AnnotatedBinary.Foo`
+ +0x04 | 41 4E 4E 4F | char[4] | ANNO | File Identifier
+
+padding:
+ +0x08 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Foo):
+ +0x0A | 3A 00 | uint16_t | 0x003A (58) | size of this vtable
+ +0x0C | 68 00 | uint16_t | 0x0068 (104) | ERROR: size of referring table. Longer than the binary.
+ +0x0E | 0C 00 | VOffset16 | 0x000C (12) | offset to field `counter` (id: 0)
+ +0x10 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `healthy` (id: 1)
+ +0x12 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `level` (id: 2) <defaults to 99> (Long)
+ +0x14 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `meal` (id: 3)
+ +0x16 | 10 00 | VOffset16 | 0x0010 (16) | ERROR: offset to field `bar` (id: 4). Invalid offset, points outside the binary.
+ +0x18 | 14 00 | VOffset16 | 0x0014 (20) | ERROR: offset to field `home` (id: 5). Invalid offset, points outside the binary.
+ +0x1A | 30 00 | VOffset16 | 0x0030 (48) | ERROR: offset to field `name` (id: 6). Invalid offset, points outside the binary.
+ +0x1C | 34 00 | VOffset16 | 0x0034 (52) | ERROR: offset to field `bars` (id: 7). Invalid offset, points outside the binary.
+ +0x1E | 09 00 | VOffset16 | 0x0009 (9) | offset to field `bar_baz_type` (id: 8)
+ +0x20 | 38 00 | VOffset16 | 0x0038 (56) | ERROR: offset to field `bar_baz` (id: 9). Invalid offset, points outside the binary.
+ +0x22 | 3C 00 | VOffset16 | 0x003C (60) | ERROR: offset to field `accounts` (id: 10). Invalid offset, points outside the binary.
+ +0x24 | 40 00 | VOffset16 | 0x0040 (64) | ERROR: offset to field `bob` (id: 11). Invalid offset, points outside the binary.
+ +0x26 | 44 00 | VOffset16 | 0x0044 (68) | ERROR: offset to field `alice` (id: 12). Invalid offset, points outside the binary.
+ +0x28 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `maybe_i32` (id: 13) <defaults to 0> (Int)
+ +0x2A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_i32` (id: 14) <defaults to 42> (Int)
+ +0x2C | 48 00 | VOffset16 | 0x0048 (72) | ERROR: offset to field `just_i32` (id: 15). Invalid offset, points outside the binary.
+ +0x2E | 4C 00 | VOffset16 | 0x004C (76) | ERROR: offset to field `names` (id: 16). Invalid offset, points outside the binary.
+ +0x30 | 50 00 | VOffset16 | 0x0050 (80) | ERROR: offset to field `points_of_interest` (id: 17). Invalid offset, points outside the binary.
+ +0x32 | 54 00 | VOffset16 | 0x0054 (84) | ERROR: offset to field `foobars_type` (id: 18). Invalid offset, points outside the binary.
+ +0x34 | 58 00 | VOffset16 | 0x0058 (88) | ERROR: offset to field `foobars` (id: 19). Invalid offset, points outside the binary.
+ +0x36 | 0A 00 | VOffset16 | 0x000A (10) | offset to field `measurement_type` (id: 20)
+ +0x38 | 5C 00 | VOffset16 | 0x005C (92) | ERROR: offset to field `measurement` (id: 21). Invalid offset, points outside the binary.
+ +0x3A | 0B 00 | VOffset16 | 0x000B (11) | offset to field `anything_type` (id: 22)
+ +0x3C | 60 00 | VOffset16 | 0x0060 (96) | ERROR: offset to field `anything` (id: 23). Invalid offset, points outside the binary.
+ +0x3E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `temperature` (id: 24) <defaults to 98.600000> (Float)
+ +0x40 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `teetotaler` (id: 25) <null> (Obj)
+ +0x42 | 64 00 | VOffset16 | 0x0064 (100) | ERROR: offset to field `charlie` (id: 26). Invalid offset, points outside the binary.
+ +0x24 | 40 00 | VOffset16 | 0x0040 (64) | offset to unknown field (id: 11)
+ +0x26 | 44 00 | VOffset16 | 0x0044 (68) | offset to unknown field (id: 12)
+ +0x28 | 00 00 | VOffset16 | 0x0000 (0) | offset to unknown field (id: 13)
+ +0x2A | 00 00 | VOffset16 | 0x0000 (0) | offset to unknown field (id: 14)
+ +0x2C | 48 00 | VOffset16 | 0x0048 (72) | offset to unknown field (id: 15)
+ +0x2E | 4C 00 | VOffset16 | 0x004C (76) | offset to unknown field (id: 16)
+ +0x30 | 50 00 | VOffset16 | 0x0050 (80) | offset to unknown field (id: 17)
+ +0x32 | 54 00 | VOffset16 | 0x0054 (84) | offset to unknown field (id: 18)
+ +0x34 | 58 00 | VOffset16 | 0x0058 (88) | offset to unknown field (id: 19)
+ +0x36 | 0A 00 | VOffset16 | 0x000A (10) | offset to unknown field (id: 20)
+ +0x38 | 5C 00 | VOffset16 | 0x005C (92) | offset to unknown field (id: 21)
+ +0x3A | 0B 00 | VOffset16 | 0x000B (11) | offset to unknown field (id: 22)
+ +0x3C | 60 00 | VOffset16 | 0x0060 (96) | offset to unknown field (id: 23)
+ +0x3E | 00 00 | VOffset16 | 0x0000 (0) | offset to unknown field (id: 24)
+ +0x40 | 00 00 | VOffset16 | 0x0000 (0) | offset to unknown field (id: 25)
+ +0x42 | 64 00 | VOffset16 | 0x0064 (100) | offset to unknown field (id: 26)
+
+root_table (AnnotatedBinary.Foo):
+ +0x44 | 3A 00 00 00 | SOffset32 | 0x0000003A (58) Loc: +0x0A | offset to vtable
+ +0x48 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x4B | 01 | uint8_t | 0x01 (1) | table field `healthy` (Bool)
+ +0x4C | 02 | uint8_t | 0x02 (2) | table field `meal` (Byte)
+ +0x4D | 02 | UType8 | 0x02 (2) | table field `bar_baz_type` (UType)
+ +0x4E | 01 | UType8 | 0x01 (1) | table field `measurement_type` (UType)
+ +0x4F | 01 | UType8 | 0x01 (1) | table field `anything_type` (UType)
+ +0x50 | D2 04 | ?uint8_t[2] | .. | ERROR: table field `counter` (Int). Incomplete binary, expected to read 4 bytes.
diff --git a/tests/annotated_binary/tests/invalid_table_field_size.bin b/tests/annotated_binary/tests/invalid_table_field_size.bin
new file mode 100644
index 0000000..4fbbbdf
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_table_field_size.bin
Binary files differ
diff --git a/tests/annotated_binary/tests/invalid_union_type_value.afb b/tests/annotated_binary/tests/invalid_union_type_value.afb
new file mode 100644
index 0000000..8e63852
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_union_type_value.afb
@@ -0,0 +1,293 @@
+// Annotated Flatbuffer Binary
+//
+// Schema file: annotated_binary.fbs
+// Binary file: tests/invalid_union_type_value.bin
+
+header:
+ +0x0000 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x0044 | offset to root table `AnnotatedBinary.Foo`
+ +0x0004 | 41 4E 4E 4F | char[4] | ANNO | File Identifier
+
+padding:
+ +0x0008 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Foo):
+ +0x000A | 3A 00 | uint16_t | 0x003A (58) | size of this vtable
+ +0x000C | 68 00 | uint16_t | 0x0068 (104) | size of referring table
+ +0x000E | 0C 00 | VOffset16 | 0x000C (12) | offset to field `counter` (id: 0)
+ +0x0010 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `healthy` (id: 1)
+ +0x0012 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `level` (id: 2) <defaults to 99> (Long)
+ +0x0014 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `meal` (id: 3)
+ +0x0016 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `bar` (id: 4)
+ +0x0018 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `home` (id: 5)
+ +0x001A | 30 00 | VOffset16 | 0x0030 (48) | offset to field `name` (id: 6)
+ +0x001C | 34 00 | VOffset16 | 0x0034 (52) | offset to field `bars` (id: 7)
+ +0x001E | 09 00 | VOffset16 | 0x0009 (9) | offset to field `bar_baz_type` (id: 8)
+ +0x0020 | 38 00 | VOffset16 | 0x0038 (56) | offset to field `bar_baz` (id: 9)
+ +0x0022 | 3C 00 | VOffset16 | 0x003C (60) | offset to field `accounts` (id: 10)
+ +0x0024 | 40 00 | VOffset16 | 0x0040 (64) | offset to field `bob` (id: 11)
+ +0x0026 | 44 00 | VOffset16 | 0x0044 (68) | offset to field `alice` (id: 12)
+ +0x0028 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `maybe_i32` (id: 13) <defaults to 0> (Int)
+ +0x002A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_i32` (id: 14) <defaults to 42> (Int)
+ +0x002C | 48 00 | VOffset16 | 0x0048 (72) | offset to field `just_i32` (id: 15)
+ +0x002E | 4C 00 | VOffset16 | 0x004C (76) | offset to field `names` (id: 16)
+ +0x0030 | 50 00 | VOffset16 | 0x0050 (80) | offset to field `points_of_interest` (id: 17)
+ +0x0032 | 54 00 | VOffset16 | 0x0054 (84) | offset to field `foobars_type` (id: 18)
+ +0x0034 | 58 00 | VOffset16 | 0x0058 (88) | offset to field `foobars` (id: 19)
+ +0x0036 | 0A 00 | VOffset16 | 0x000A (10) | offset to field `measurement_type` (id: 20)
+ +0x0038 | 5C 00 | VOffset16 | 0x005C (92) | offset to field `measurement` (id: 21)
+ +0x003A | 0B 00 | VOffset16 | 0x000B (11) | offset to field `anything_type` (id: 22)
+ +0x003C | 60 00 | VOffset16 | 0x0060 (96) | offset to field `anything` (id: 23)
+ +0x003E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `temperature` (id: 24) <defaults to 98.600000> (Float)
+ +0x0040 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `teetotaler` (id: 25) <null> (Obj)
+ +0x0042 | 64 00 | VOffset16 | 0x0064 (100) | offset to field `charlie` (id: 26)
+
+root_table (AnnotatedBinary.Foo):
+ +0x0044 | 3A 00 00 00 | SOffset32 | 0x0000003A (58) Loc: +0x000A | offset to vtable
+ +0x0048 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x004B | 01 | uint8_t | 0x01 (1) | table field `healthy` (Bool)
+ +0x004C | 02 | uint8_t | 0x02 (2) | table field `meal` (Byte)
+ +0x004D | FF | UType8 | 0xFF (255) | ERROR: table field `bar_baz_type` (UType). Invalid union type value.
+ +0x004E | 01 | UType8 | 0x01 (1) | table field `measurement_type` (UType)
+ +0x004F | 01 | UType8 | 0x01 (1) | table field `anything_type` (UType)
+ +0x0050 | D2 04 00 00 | uint32_t | 0x000004D2 (1234) | table field `counter` (Int)
+ +0x0054 | 28 02 00 00 | UOffset32 | 0x00000228 (552) Loc: +0x027C | offset to field `bar` (table)
+ +0x0058 | 01 00 00 00 | uint32_t | 0x00000001 (1) | struct field `AnnotatedBinary.Building.floors` (Int)
+ +0x005C | 02 00 00 00 | uint32_t | 0x00000002 (2) | struct field `AnnotatedBinary.Building.doors` (Int)
+ +0x0060 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | struct field `AnnotatedBinary.Building.windows` (Int)
+ +0x0064 | 0A 00 00 00 | uint32_t | 0x0000000A (10) | array field `AnnotatedBinary.Dimension.values`[0] (Int)
+ +0x0068 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | array field `AnnotatedBinary.Dimension.values`[1] (Int)
+ +0x006C | 14 00 00 00 | uint32_t | 0x00000014 (20) | array field `AnnotatedBinary.Dimension.values`[2] (Int)
+ +0x0070 | 01 | uint8_t | 0x01 (1) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0071 | 02 | uint8_t | 0x02 (2) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0072 | 03 | uint8_t | 0x03 (3) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0073 | 00 | uint8_t[1] | . | padding
+ +0x0074 | C8 01 00 00 | UOffset32 | 0x000001C8 (456) Loc: +0x023C | offset to field `name` (string)
+ +0x0078 | 5C 01 00 00 | UOffset32 | 0x0000015C (348) Loc: +0x01D4 | offset to field `bars` (vector)
+ +0x007C | 50 01 00 00 | ?uint8_t[4] | P... | WARN: nothing refers to this section.
+ +0x0080 | 34 01 00 00 | UOffset32 | 0x00000134 (308) Loc: +0x01B4 | offset to field `accounts` (vector)
+ +0x0084 | 24 01 00 00 | UOffset32 | 0x00000124 (292) Loc: +0x01A8 | offset to field `bob` (string)
+ +0x0088 | 14 01 00 00 | UOffset32 | 0x00000114 (276) Loc: +0x019C | offset to field `alice` (string)
+ +0x008C | 0D 00 00 00 | uint32_t | 0x0000000D (13) | table field `just_i32` (Int)
+ +0x0090 | DC 00 00 00 | UOffset32 | 0x000000DC (220) Loc: +0x016C | offset to field `names` (vector)
+ +0x0094 | A0 00 00 00 | UOffset32 | 0x000000A0 (160) Loc: +0x0134 | offset to field `points_of_interest` (vector)
+ +0x0098 | 94 00 00 00 | UOffset32 | 0x00000094 (148) Loc: +0x012C | offset to field `foobars_type` (vector)
+ +0x009C | 38 00 00 00 | UOffset32 | 0x00000038 (56) Loc: +0x00D4 | offset to field `foobars` (vector)
+ +0x00A0 | 33 00 00 00 | UOffset32 | 0x00000033 (51) Loc: +0x00D3 | offset to field `measurement` (union of type `Tolerance`)
+ +0x00A4 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x00C0 | offset to field `anything` (union of type `Bar`)
+ +0x00A8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00AC | offset to field `charlie` (string)
+
+string (AnnotatedBinary.Foo.charlie):
+ +0x00AC | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x00B0 | 61 6C 69 63 65 | char[5] | alice | string literal
+ +0x00B5 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x00B6 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Bar):
+ +0x00B8 | 08 00 | uint16_t | 0x0008 (8) | size of this vtable
+ +0x00BA | 13 00 | uint16_t | 0x0013 (19) | size of referring table
+ +0x00BC | 08 00 | VOffset16 | 0x0008 (8) | offset to field `a` (id: 0)
+ +0x00BE | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+
+table (AnnotatedBinary.Bar):
+ +0x00C0 | 08 00 00 00 | SOffset32 | 0x00000008 (8) Loc: +0x00B8 | offset to vtable
+ +0x00C4 | 00 80 23 44 | float | 0x44238000 (654) | table field `b` (Float)
+ +0x00C8 | 00 00 00 00 00 10 74 40 | double | 0x4074100000000000 (321) | table field `a` (Double)
+ +0x00D0 | 00 00 00 | uint8_t[3] | ... | padding
+
+union (AnnotatedBinary.Tolerance.measurement):
+ +0x00D3 | 05 | uint8_t | 0x05 (5) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+
+vector (AnnotatedBinary.Foo.foobars):
+ +0x00D4 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x00D8 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x010C | offset to union[0] (`Bar`)
+ +0x00DC | 2C 00 00 00 | UOffset32 | 0x0000002C (44) Loc: +0x0108 | offset to union[1] (`Baz`)
+ +0x00E0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00E4 | offset to union[2] (`Bar`)
+
+table (AnnotatedBinary.Bar):
+ +0x00E4 | D2 FE FF FF | SOffset32 | 0xFFFFFED2 (-302) Loc: +0x0212 | offset to vtable
+ +0x00E8 | 00 80 23 44 | float | 0x44238000 (654) | table field `b` (Float)
+ +0x00EC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x00FC | offset to field `c` (table)
+ +0x00F0 | 00 00 00 00 00 D8 8E 40 | double | 0x408ED80000000000 (987) | table field `a` (Double)
+ +0x00F8 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+table (AnnotatedBinary.Baz):
+ +0x00FC | 6A FE FF FF | SOffset32 | 0xFFFFFE6A (-406) Loc: +0x0292 | offset to vtable
+ +0x0100 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x0103 | 03 | uint8_t | 0x03 (3) | table field `meal` (Byte)
+
+vtable (AnnotatedBinary.Baz):
+ +0x0104 | 04 00 | uint16_t | 0x0004 (4) | size of this vtable
+ +0x0106 | 04 00 | uint16_t | 0x0004 (4) | size of referring table
+
+table (AnnotatedBinary.Baz):
+ +0x0108 | 04 00 00 00 | SOffset32 | 0x00000004 (4) Loc: +0x0104 | offset to vtable
+
+table (AnnotatedBinary.Bar):
+ +0x010C | FA FE FF FF | SOffset32 | 0xFFFFFEFA (-262) Loc: +0x0212 | offset to vtable
+ +0x0110 | 00 00 E4 43 | float | 0x43E40000 (456) | table field `b` (Float)
+ +0x0114 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x0124 | offset to field `c` (table)
+ +0x0118 | 00 00 00 00 00 C0 5E 40 | double | 0x405EC00000000000 (123) | table field `a` (Double)
+ +0x0120 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+table (AnnotatedBinary.Baz):
+ +0x0124 | 92 FE FF FF | SOffset32 | 0xFFFFFE92 (-366) Loc: +0x0292 | offset to vtable
+ +0x0128 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x012B | 01 | uint8_t | 0x01 (1) | table field `meal` (Byte)
+
+vector (AnnotatedBinary.Foo.foobars_type):
+ +0x012C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0130 | 01 | UType8 | 0x01 (1) | value[0]
+ +0x0131 | 02 | UType8 | 0x02 (2) | value[1]
+ +0x0132 | 01 | UType8 | 0x01 (1) | value[2]
+
+vector (AnnotatedBinary.Foo.points_of_interest):
+ +0x0134 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0138 | 33 33 33 33 33 A3 45 40 | double | 0x4045A33333333333 (43.275) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0140 | 7E 57 04 FF 5B 87 53 C0 | double | 0xC053875BFF04577E (-78.115) | struct field `AnnotatedBinary.Location.longitude` (Double)
+ +0x0148 | 8D F0 F6 20 04 B6 42 40 | double | 0x4042B60420F6F08D (37.422) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0150 | 9F 77 63 41 61 85 5E C0 | double | 0xC05E85614163779F (-122.084) | struct field `AnnotatedBinary.Location.longitude` (Double)
+ +0x0158 | 8F 35 23 83 DC 35 4B C0 | double | 0xC04B35DC8323358F (-54.4208) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0160 | F6 97 DD 93 87 C5 0A 40 | double | 0x400AC58793DD97F6 (3.34645) | struct field `AnnotatedBinary.Location.longitude` (Double)
+
+padding:
+ +0x0168 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (AnnotatedBinary.Foo.names):
+ +0x016C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0170 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x0190 | offset to string[0]
+ +0x0174 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x0188 | offset to string[1]
+ +0x0178 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x017C | offset to string[2]
+
+string (AnnotatedBinary.Foo.names):
+ +0x017C | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x0180 | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x0187 | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.names):
+ +0x0188 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x018C | 62 6F 62 | char[3] | bob | string literal
+ +0x018F | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.names):
+ +0x0190 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x0194 | 61 6C 69 63 65 | char[5] | alice | string literal
+ +0x0199 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x019A | 00 00 | uint8_t[2] | .. | padding
+
+string (AnnotatedBinary.Foo.alice):
+ +0x019C | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x01A0 | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x01A7 | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.bob):
+ +0x01A8 | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x01AC | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x01B3 | 00 | char | 0x00 (0) | string terminator
+
+vector (AnnotatedBinary.Foo.accounts):
+ +0x01B4 | 09 00 00 00 | uint32_t | 0x00000009 (9) | length of vector (# items)
+ +0x01B8 | 09 00 | uint16_t | 0x0009 (9) | value[0]
+ +0x01BA | 08 00 | uint16_t | 0x0008 (8) | value[1]
+ +0x01BC | 07 00 | uint16_t | 0x0007 (7) | value[2]
+ +0x01BE | 01 00 | uint16_t | 0x0001 (1) | value[3]
+ +0x01C0 | 02 00 | uint16_t | 0x0002 (2) | value[4]
+ +0x01C2 | 03 00 | uint16_t | 0x0003 (3) | value[5]
+ +0x01C4 | 06 00 | uint16_t | 0x0006 (6) | value[6]
+ +0x01C6 | 05 00 | uint16_t | 0x0005 (5) | value[7]
+ +0x01C8 | 04 00 | uint16_t | 0x0004 (4) | value[8]
+
+unknown (no known references):
+ +0x01CA | 00 00 3A FF FF FF 00 00 | ?uint8_t[10] | ..:..... | WARN: nothing refers to this section.
+ +0x01D2 | 00 03 | | ..
+
+vector (AnnotatedBinary.Foo.bars):
+ +0x01D4 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x01D8 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x021C | offset to table[0]
+ +0x01DC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x01EC | offset to table[1]
+
+padding:
+ +0x01E0 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Bar):
+ +0x01E2 | 0A 00 | uint16_t | 0x000A (10) | size of this vtable
+ +0x01E4 | 1A 00 | uint16_t | 0x001A (26) | size of referring table
+ +0x01E6 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `a` (id: 0)
+ +0x01E8 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+ +0x01EA | 08 00 | VOffset16 | 0x0008 (8) | offset to field `c` (id: 2)
+
+table (AnnotatedBinary.Bar):
+ +0x01EC | 0A 00 00 00 | SOffset32 | 0x0000000A (10) Loc: +0x01E2 | offset to vtable
+ +0x01F0 | 00 80 23 44 | float | 0x44238000 (654) | table field `b` (Float)
+ +0x01F4 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x020C | offset to field `c` (table)
+ +0x01F8 | 00 00 00 00 00 D8 8E 40 | double | 0x408ED80000000000 (987) | table field `a` (Double)
+ +0x0200 | 00 00 00 00 00 00 | uint8_t[6] | ...... | padding
+
+vtable (AnnotatedBinary.Baz):
+ +0x0206 | 06 00 | uint16_t | 0x0006 (6) | size of this vtable
+ +0x0208 | 06 00 | uint16_t | 0x0006 (6) | size of referring table
+ +0x020A | 05 00 | VOffset16 | 0x0005 (5) | offset to field `meal` (id: 0)
+
+table (AnnotatedBinary.Baz):
+ +0x020C | 06 00 00 00 | SOffset32 | 0x00000006 (6) Loc: +0x0206 | offset to vtable
+ +0x0210 | 00 | uint8_t[1] | . | padding
+ +0x0211 | 03 | uint8_t | 0x03 (3) | table field `meal` (Byte)
+
+vtable (AnnotatedBinary.Bar):
+ +0x0212 | 0A 00 | uint16_t | 0x000A (10) | size of this vtable
+ +0x0214 | 18 00 | uint16_t | 0x0018 (24) | size of referring table
+ +0x0216 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `a` (id: 0)
+ +0x0218 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+ +0x021A | 08 00 | VOffset16 | 0x0008 (8) | offset to field `c` (id: 2)
+
+table (AnnotatedBinary.Bar):
+ +0x021C | 0A 00 00 00 | SOffset32 | 0x0000000A (10) Loc: +0x0212 | offset to vtable
+ +0x0220 | 00 00 E4 43 | float | 0x43E40000 (456) | table field `b` (Float)
+ +0x0224 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x0234 | offset to field `c` (table)
+ +0x0228 | 00 00 00 00 00 C0 5E 40 | double | 0x405EC00000000000 (123) | table field `a` (Double)
+ +0x0230 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+table (AnnotatedBinary.Baz):
+ +0x0234 | A2 FF FF FF | SOffset32 | 0xFFFFFFA2 (-94) Loc: +0x0292 | offset to vtable
+ +0x0238 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x023B | 01 | uint8_t | 0x01 (1) | table field `meal` (Byte)
+
+string (AnnotatedBinary.Foo.name):
+ +0x023C | 2F 00 00 00 | uint32_t | 0x0000002F (47) | length of string
+ +0x0240 | 54 68 69 73 20 69 73 20 | char[47] | This is | string literal
+ +0x0248 | 61 20 6C 6F 6E 67 20 73 | | a long s
+ +0x0250 | 74 72 69 6E 67 20 74 6F | | tring to
+ +0x0258 | 20 73 68 6F 77 20 68 6F | | show ho
+ +0x0260 | 77 20 69 74 20 62 72 65 | | w it bre
+ +0x0268 | 61 6B 73 20 75 70 2E | | aks up.
+ +0x026F | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x0270 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Bar):
+ +0x0272 | 0A 00 | uint16_t | 0x000A (10) | size of this vtable
+ +0x0274 | 16 00 | uint16_t | 0x0016 (22) | size of referring table
+ +0x0276 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `a` (id: 0)
+ +0x0278 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+ +0x027A | 08 00 | VOffset16 | 0x0008 (8) | offset to field `c` (id: 2)
+
+table (AnnotatedBinary.Bar):
+ +0x027C | 0A 00 00 00 | SOffset32 | 0x0000000A (10) Loc: +0x0272 | offset to vtable
+ +0x0280 | 65 20 71 49 | float | 0x49712065 (987654) | table field `b` (Float)
+ +0x0284 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x0298 | offset to field `c` (table)
+ +0x0288 | C9 76 BE 9F 0C 24 FE 40 | double | 0x40FE240C9FBE76C9 (123457) | table field `a` (Double)
+ +0x0290 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Baz):
+ +0x0292 | 06 00 | uint16_t | 0x0006 (6) | size of this vtable
+ +0x0294 | 08 00 | uint16_t | 0x0008 (8) | size of referring table
+ +0x0296 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `meal` (id: 0)
+
+table (AnnotatedBinary.Baz):
+ +0x0298 | 06 00 00 00 | SOffset32 | 0x00000006 (6) Loc: +0x0292 | offset to vtable
+ +0x029C | 00 00 00 | uint8_t[3] | ... | padding
+ +0x029F | 01 | uint8_t | 0x01 (1) | table field `meal` (Byte)
diff --git a/tests/annotated_binary/tests/invalid_union_type_value.bin b/tests/annotated_binary/tests/invalid_union_type_value.bin
new file mode 100644
index 0000000..22f2dd5
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_union_type_value.bin
Binary files differ
diff --git a/tests/annotated_binary/tests/invalid_vector_length_cut_short.afb b/tests/annotated_binary/tests/invalid_vector_length_cut_short.afb
new file mode 100644
index 0000000..7d11d2b
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_vector_length_cut_short.afb
@@ -0,0 +1,140 @@
+// Annotated Flatbuffer Binary
+//
+// Schema file: annotated_binary.fbs
+// Binary file: tests/invalid_vector_length_cut_short.bin
+
+header:
+ +0x0000 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x0044 | offset to root table `AnnotatedBinary.Foo`
+ +0x0004 | 41 4E 4E 4F | char[4] | ANNO | File Identifier
+
+padding:
+ +0x0008 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Foo):
+ +0x000A | 3A 00 | uint16_t | 0x003A (58) | size of this vtable
+ +0x000C | 68 00 | uint16_t | 0x0068 (104) | size of referring table
+ +0x000E | 0C 00 | VOffset16 | 0x000C (12) | offset to field `counter` (id: 0)
+ +0x0010 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `healthy` (id: 1)
+ +0x0012 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `level` (id: 2) <defaults to 99> (Long)
+ +0x0014 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `meal` (id: 3)
+ +0x0016 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `bar` (id: 4)
+ +0x0018 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `home` (id: 5)
+ +0x001A | 30 00 | VOffset16 | 0x0030 (48) | offset to field `name` (id: 6)
+ +0x001C | 34 00 | VOffset16 | 0x0034 (52) | offset to field `bars` (id: 7)
+ +0x001E | 09 00 | VOffset16 | 0x0009 (9) | offset to field `bar_baz_type` (id: 8)
+ +0x0020 | 38 00 | VOffset16 | 0x0038 (56) | offset to field `bar_baz` (id: 9)
+ +0x0022 | 3C 00 | VOffset16 | 0x003C (60) | offset to field `accounts` (id: 10)
+ +0x0024 | 40 00 | VOffset16 | 0x0040 (64) | offset to field `bob` (id: 11)
+ +0x0026 | 44 00 | VOffset16 | 0x0044 (68) | offset to field `alice` (id: 12)
+ +0x0028 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `maybe_i32` (id: 13) <defaults to 0> (Int)
+ +0x002A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_i32` (id: 14) <defaults to 42> (Int)
+ +0x002C | 48 00 | VOffset16 | 0x0048 (72) | offset to field `just_i32` (id: 15)
+ +0x002E | 4C 00 | VOffset16 | 0x004C (76) | offset to field `names` (id: 16)
+ +0x0030 | 50 00 | VOffset16 | 0x0050 (80) | offset to field `points_of_interest` (id: 17)
+ +0x0032 | 54 00 | VOffset16 | 0x0054 (84) | offset to field `foobars_type` (id: 18)
+ +0x0034 | 58 00 | VOffset16 | 0x0058 (88) | offset to field `foobars` (id: 19)
+ +0x0036 | 0A 00 | VOffset16 | 0x000A (10) | offset to field `measurement_type` (id: 20)
+ +0x0038 | 5C 00 | VOffset16 | 0x005C (92) | offset to field `measurement` (id: 21)
+ +0x003A | 0B 00 | VOffset16 | 0x000B (11) | offset to field `anything_type` (id: 22)
+ +0x003C | 60 00 | VOffset16 | 0x0060 (96) | offset to field `anything` (id: 23)
+ +0x003E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `temperature` (id: 24) <defaults to 98.600000> (Float)
+ +0x0040 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `teetotaler` (id: 25) <null> (Obj)
+ +0x0042 | 64 00 | VOffset16 | 0x0064 (100) | offset to field `charlie` (id: 26)
+
+root_table (AnnotatedBinary.Foo):
+ +0x0044 | 3A 00 00 00 | SOffset32 | 0x0000003A (58) Loc: +0x000A | offset to vtable
+ +0x0048 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x004B | 01 | uint8_t | 0x01 (1) | table field `healthy` (Bool)
+ +0x004C | 02 | uint8_t | 0x02 (2) | table field `meal` (Byte)
+ +0x004D | 02 | UType8 | 0x02 (2) | table field `bar_baz_type` (UType)
+ +0x004E | 01 | UType8 | 0x01 (1) | table field `measurement_type` (UType)
+ +0x004F | 01 | UType8 | 0x01 (1) | table field `anything_type` (UType)
+ +0x0050 | D2 04 00 00 | uint32_t | 0x000004D2 (1234) | table field `counter` (Int)
+ +0x0054 | 28 02 00 00 | UOffset32 | 0x00000228 (552) Loc: +0x027C | ERROR: offset to field `bar`. Invalid offset, points outside the binary.
+ +0x0058 | 01 00 00 00 | uint32_t | 0x00000001 (1) | struct field `AnnotatedBinary.Building.floors` (Int)
+ +0x005C | 02 00 00 00 | uint32_t | 0x00000002 (2) | struct field `AnnotatedBinary.Building.doors` (Int)
+ +0x0060 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | struct field `AnnotatedBinary.Building.windows` (Int)
+ +0x0064 | 0A 00 00 00 | uint32_t | 0x0000000A (10) | array field `AnnotatedBinary.Dimension.values`[0] (Int)
+ +0x0068 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | array field `AnnotatedBinary.Dimension.values`[1] (Int)
+ +0x006C | 14 00 00 00 | uint32_t | 0x00000014 (20) | array field `AnnotatedBinary.Dimension.values`[2] (Int)
+ +0x0070 | 01 | uint8_t | 0x01 (1) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0071 | 02 | uint8_t | 0x02 (2) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0072 | 03 | uint8_t | 0x03 (3) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0073 | 00 | uint8_t[1] | . | padding
+ +0x0074 | C8 01 00 00 | UOffset32 | 0x000001C8 (456) Loc: +0x023C | ERROR: offset to field `name`. Invalid offset, points outside the binary.
+ +0x0078 | 5C 01 00 00 | UOffset32 | 0x0000015C (348) Loc: +0x01D4 | ERROR: offset to field `bars`. Invalid offset, points outside the binary.
+ +0x007C | 50 01 00 00 | UOffset32 | 0x00000150 (336) Loc: +0x01CC | ERROR: offset to field `bar_baz`. Invalid offset, points outside the binary.
+ +0x0080 | 34 01 00 00 | UOffset32 | 0x00000134 (308) Loc: +0x01B4 | ERROR: offset to field `accounts`. Invalid offset, points outside the binary.
+ +0x0084 | 24 01 00 00 | UOffset32 | 0x00000124 (292) Loc: +0x01A8 | ERROR: offset to field `bob`. Invalid offset, points outside the binary.
+ +0x0088 | 14 01 00 00 | UOffset32 | 0x00000114 (276) Loc: +0x019C | ERROR: offset to field `alice`. Invalid offset, points outside the binary.
+ +0x008C | 0D 00 00 00 | uint32_t | 0x0000000D (13) | table field `just_i32` (Int)
+ +0x0090 | DC 00 00 00 | UOffset32 | 0x000000DC (220) Loc: +0x016C | ERROR: offset to field `names`. Invalid offset, points outside the binary.
+ +0x0094 | A0 00 00 00 | UOffset32 | 0x000000A0 (160) Loc: +0x0134 | offset to field `points_of_interest` (vector)
+ +0x0098 | 94 00 00 00 | UOffset32 | 0x00000094 (148) Loc: +0x012C | offset to field `foobars_type` (vector)
+ +0x009C | 38 00 00 00 | UOffset32 | 0x00000038 (56) Loc: +0x00D4 | offset to field `foobars` (vector)
+ +0x00A0 | 33 00 00 00 | UOffset32 | 0x00000033 (51) Loc: +0x00D3 | offset to field `measurement` (union of type `Tolerance`)
+ +0x00A4 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x00C0 | offset to field `anything` (union of type `Bar`)
+ +0x00A8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00AC | offset to field `charlie` (string)
+
+string (AnnotatedBinary.Foo.charlie):
+ +0x00AC | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x00B0 | 61 6C 69 63 65 | char[5] | alice | string literal
+ +0x00B5 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x00B6 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Bar):
+ +0x00B8 | 08 00 | uint16_t | 0x0008 (8) | size of this vtable
+ +0x00BA | 13 00 | uint16_t | 0x0013 (19) | size of referring table
+ +0x00BC | 08 00 | VOffset16 | 0x0008 (8) | offset to field `a` (id: 0)
+ +0x00BE | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+
+table (AnnotatedBinary.Bar):
+ +0x00C0 | 08 00 00 00 | SOffset32 | 0x00000008 (8) Loc: +0x00B8 | offset to vtable
+ +0x00C4 | 00 80 23 44 | float | 0x44238000 (654) | table field `b` (Float)
+ +0x00C8 | 00 00 00 00 00 10 74 40 | double | 0x4074100000000000 (321) | table field `a` (Double)
+ +0x00D0 | 00 00 00 | uint8_t[3] | ... | padding
+
+union (AnnotatedBinary.Tolerance.measurement):
+ +0x00D3 | 05 | uint8_t | 0x05 (5) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+
+vector (AnnotatedBinary.Foo.foobars):
+ +0x00D4 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x00D8 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x010C | offset to union[0] (`Bar`)
+ +0x00DC | 2C 00 00 00 | UOffset32 | 0x0000002C (44) Loc: +0x0108 | offset to union[1] (`Baz`)
+ +0x00E0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00E4 | offset to union[2] (`Bar`)
+
+table (AnnotatedBinary.Bar):
+ +0x00E4 | D2 FE FF FF | SOffset32 | 0xFFFFFED2 (-302) Loc: +0x0212 | ERROR: offset to vtable. Invalid offset, points outside the binary.
+
+unknown (no known references):
+ +0x00E8 | 00 80 23 44 10 00 00 00 | ?uint8_t[28] | ..#D.... | WARN: nothing refers to this section.
+ +0x00F0 | 00 00 00 00 00 D8 8E 40 | | .......@
+ +0x00F8 | 00 00 00 00 6A FE FF FF | | ....j...
+ +0x0100 | 00 00 00 03 | | ....
+
+vtable (AnnotatedBinary.Baz):
+ +0x0104 | 04 00 | uint16_t | 0x0004 (4) | size of this vtable
+ +0x0106 | 04 00 | uint16_t | 0x0004 (4) | size of referring table
+
+table (AnnotatedBinary.Baz):
+ +0x0108 | 04 00 00 00 | SOffset32 | 0x00000004 (4) Loc: +0x0104 | offset to vtable
+
+table (AnnotatedBinary.Bar):
+ +0x010C | FA FE FF FF | SOffset32 | 0xFFFFFEFA (-262) Loc: +0x0212 | ERROR: offset to vtable. Invalid offset, points outside the binary.
+
+unknown (no known references):
+ +0x0110 | 00 00 E4 43 10 00 00 00 | ?uint8_t[28] | ...C.... | WARN: nothing refers to this section.
+ +0x0118 | 00 00 00 00 00 C0 5E 40 | | ......^@
+ +0x0120 | 00 00 00 00 92 FE FF FF | | ........
+ +0x0128 | 00 00 00 01 | | ....
+
+vector (AnnotatedBinary.Foo.foobars_type):
+ +0x012C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0130 | 01 | UType8 | 0x01 (1) | value[0]
+ +0x0131 | 02 | UType8 | 0x02 (2) | value[1]
+ +0x0132 | 01 | UType8 | 0x01 (1) | value[2]
+
+vector (AnnotatedBinary.Foo.points_of_interest):
+ +0x0134 | 03 00 | ?uint8_t[2] | .. | ERROR: length of vector (# items). Incomplete binary, expected to read 4 bytes.
diff --git a/tests/annotated_binary/tests/invalid_vector_length_cut_short.bin b/tests/annotated_binary/tests/invalid_vector_length_cut_short.bin
new file mode 100644
index 0000000..2d622da
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_vector_length_cut_short.bin
Binary files differ
diff --git a/tests/annotated_binary/tests/invalid_vector_scalars_cut_short.afb b/tests/annotated_binary/tests/invalid_vector_scalars_cut_short.afb
new file mode 100644
index 0000000..c61987a
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_vector_scalars_cut_short.afb
@@ -0,0 +1,190 @@
+// Annotated Flatbuffer Binary
+//
+// Schema file: annotated_binary.fbs
+// Binary file: tests/invalid_vector_scalars_cut_short.bin
+
+header:
+ +0x0000 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x0044 | offset to root table `AnnotatedBinary.Foo`
+ +0x0004 | 41 4E 4E 4F | char[4] | ANNO | File Identifier
+
+padding:
+ +0x0008 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Foo):
+ +0x000A | 3A 00 | uint16_t | 0x003A (58) | size of this vtable
+ +0x000C | 68 00 | uint16_t | 0x0068 (104) | size of referring table
+ +0x000E | 0C 00 | VOffset16 | 0x000C (12) | offset to field `counter` (id: 0)
+ +0x0010 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `healthy` (id: 1)
+ +0x0012 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `level` (id: 2) <defaults to 99> (Long)
+ +0x0014 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `meal` (id: 3)
+ +0x0016 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `bar` (id: 4)
+ +0x0018 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `home` (id: 5)
+ +0x001A | 30 00 | VOffset16 | 0x0030 (48) | offset to field `name` (id: 6)
+ +0x001C | 34 00 | VOffset16 | 0x0034 (52) | offset to field `bars` (id: 7)
+ +0x001E | 09 00 | VOffset16 | 0x0009 (9) | offset to field `bar_baz_type` (id: 8)
+ +0x0020 | 38 00 | VOffset16 | 0x0038 (56) | offset to field `bar_baz` (id: 9)
+ +0x0022 | 3C 00 | VOffset16 | 0x003C (60) | offset to field `accounts` (id: 10)
+ +0x0024 | 40 00 | VOffset16 | 0x0040 (64) | offset to field `bob` (id: 11)
+ +0x0026 | 44 00 | VOffset16 | 0x0044 (68) | offset to field `alice` (id: 12)
+ +0x0028 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `maybe_i32` (id: 13) <defaults to 0> (Int)
+ +0x002A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_i32` (id: 14) <defaults to 42> (Int)
+ +0x002C | 48 00 | VOffset16 | 0x0048 (72) | offset to field `just_i32` (id: 15)
+ +0x002E | 4C 00 | VOffset16 | 0x004C (76) | offset to field `names` (id: 16)
+ +0x0030 | 50 00 | VOffset16 | 0x0050 (80) | offset to field `points_of_interest` (id: 17)
+ +0x0032 | 54 00 | VOffset16 | 0x0054 (84) | offset to field `foobars_type` (id: 18)
+ +0x0034 | 58 00 | VOffset16 | 0x0058 (88) | offset to field `foobars` (id: 19)
+ +0x0036 | 0A 00 | VOffset16 | 0x000A (10) | offset to field `measurement_type` (id: 20)
+ +0x0038 | 5C 00 | VOffset16 | 0x005C (92) | offset to field `measurement` (id: 21)
+ +0x003A | 0B 00 | VOffset16 | 0x000B (11) | offset to field `anything_type` (id: 22)
+ +0x003C | 60 00 | VOffset16 | 0x0060 (96) | offset to field `anything` (id: 23)
+ +0x003E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `temperature` (id: 24) <defaults to 98.600000> (Float)
+ +0x0040 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `teetotaler` (id: 25) <null> (Obj)
+ +0x0042 | 64 00 | VOffset16 | 0x0064 (100) | offset to field `charlie` (id: 26)
+
+root_table (AnnotatedBinary.Foo):
+ +0x0044 | 3A 00 00 00 | SOffset32 | 0x0000003A (58) Loc: +0x000A | offset to vtable
+ +0x0048 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x004B | 01 | uint8_t | 0x01 (1) | table field `healthy` (Bool)
+ +0x004C | 02 | uint8_t | 0x02 (2) | table field `meal` (Byte)
+ +0x004D | 02 | UType8 | 0x02 (2) | table field `bar_baz_type` (UType)
+ +0x004E | 01 | UType8 | 0x01 (1) | table field `measurement_type` (UType)
+ +0x004F | 01 | UType8 | 0x01 (1) | table field `anything_type` (UType)
+ +0x0050 | D2 04 00 00 | uint32_t | 0x000004D2 (1234) | table field `counter` (Int)
+ +0x0054 | 28 02 00 00 | UOffset32 | 0x00000228 (552) Loc: +0x027C | ERROR: offset to field `bar`. Invalid offset, points outside the binary.
+ +0x0058 | 01 00 00 00 | uint32_t | 0x00000001 (1) | struct field `AnnotatedBinary.Building.floors` (Int)
+ +0x005C | 02 00 00 00 | uint32_t | 0x00000002 (2) | struct field `AnnotatedBinary.Building.doors` (Int)
+ +0x0060 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | struct field `AnnotatedBinary.Building.windows` (Int)
+ +0x0064 | 0A 00 00 00 | uint32_t | 0x0000000A (10) | array field `AnnotatedBinary.Dimension.values`[0] (Int)
+ +0x0068 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | array field `AnnotatedBinary.Dimension.values`[1] (Int)
+ +0x006C | 14 00 00 00 | uint32_t | 0x00000014 (20) | array field `AnnotatedBinary.Dimension.values`[2] (Int)
+ +0x0070 | 01 | uint8_t | 0x01 (1) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0071 | 02 | uint8_t | 0x02 (2) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0072 | 03 | uint8_t | 0x03 (3) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0073 | 00 | uint8_t[1] | . | padding
+ +0x0074 | C8 01 00 00 | UOffset32 | 0x000001C8 (456) Loc: +0x023C | ERROR: offset to field `name`. Invalid offset, points outside the binary.
+ +0x0078 | 5C 01 00 00 | UOffset32 | 0x0000015C (348) Loc: +0x01D4 | ERROR: offset to field `bars`. Invalid offset, points outside the binary.
+ +0x007C | 50 01 00 00 | UOffset32 | 0x00000150 (336) Loc: +0x01CC | ERROR: offset to field `bar_baz`. Invalid offset, points outside the binary.
+ +0x0080 | 34 01 00 00 | UOffset32 | 0x00000134 (308) Loc: +0x01B4 | offset to field `accounts` (vector)
+ +0x0084 | 24 01 00 00 | UOffset32 | 0x00000124 (292) Loc: +0x01A8 | offset to field `bob` (string)
+ +0x0088 | 14 01 00 00 | UOffset32 | 0x00000114 (276) Loc: +0x019C | offset to field `alice` (string)
+ +0x008C | 0D 00 00 00 | uint32_t | 0x0000000D (13) | table field `just_i32` (Int)
+ +0x0090 | DC 00 00 00 | UOffset32 | 0x000000DC (220) Loc: +0x016C | offset to field `names` (vector)
+ +0x0094 | A0 00 00 00 | UOffset32 | 0x000000A0 (160) Loc: +0x0134 | offset to field `points_of_interest` (vector)
+ +0x0098 | 94 00 00 00 | UOffset32 | 0x00000094 (148) Loc: +0x012C | offset to field `foobars_type` (vector)
+ +0x009C | 38 00 00 00 | UOffset32 | 0x00000038 (56) Loc: +0x00D4 | offset to field `foobars` (vector)
+ +0x00A0 | 33 00 00 00 | UOffset32 | 0x00000033 (51) Loc: +0x00D3 | offset to field `measurement` (union of type `Tolerance`)
+ +0x00A4 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x00C0 | offset to field `anything` (union of type `Bar`)
+ +0x00A8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00AC | offset to field `charlie` (string)
+
+string (AnnotatedBinary.Foo.charlie):
+ +0x00AC | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x00B0 | 61 6C 69 63 65 | char[5] | alice | string literal
+ +0x00B5 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x00B6 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Bar):
+ +0x00B8 | 08 00 | uint16_t | 0x0008 (8) | size of this vtable
+ +0x00BA | 13 00 | uint16_t | 0x0013 (19) | size of referring table
+ +0x00BC | 08 00 | VOffset16 | 0x0008 (8) | offset to field `a` (id: 0)
+ +0x00BE | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+
+table (AnnotatedBinary.Bar):
+ +0x00C0 | 08 00 00 00 | SOffset32 | 0x00000008 (8) Loc: +0x00B8 | offset to vtable
+ +0x00C4 | 00 80 23 44 | float | 0x44238000 (654) | table field `b` (Float)
+ +0x00C8 | 00 00 00 00 00 10 74 40 | double | 0x4074100000000000 (321) | table field `a` (Double)
+ +0x00D0 | 00 00 00 | uint8_t[3] | ... | padding
+
+union (AnnotatedBinary.Tolerance.measurement):
+ +0x00D3 | 05 | uint8_t | 0x05 (5) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+
+vector (AnnotatedBinary.Foo.foobars):
+ +0x00D4 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x00D8 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x010C | offset to union[0] (`Bar`)
+ +0x00DC | 2C 00 00 00 | UOffset32 | 0x0000002C (44) Loc: +0x0108 | offset to union[1] (`Baz`)
+ +0x00E0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00E4 | offset to union[2] (`Bar`)
+
+table (AnnotatedBinary.Bar):
+ +0x00E4 | D2 FE FF FF | SOffset32 | 0xFFFFFED2 (-302) Loc: +0x0212 | ERROR: offset to vtable. Invalid offset, points outside the binary.
+
+unknown (no known references):
+ +0x00E8 | 00 80 23 44 10 00 00 00 | ?uint8_t[28] | ..#D.... | WARN: nothing refers to this section.
+ +0x00F0 | 00 00 00 00 00 D8 8E 40 | | .......@
+ +0x00F8 | 00 00 00 00 6A FE FF FF | | ....j...
+ +0x0100 | 00 00 00 03 | | ....
+
+vtable (AnnotatedBinary.Baz):
+ +0x0104 | 04 00 | uint16_t | 0x0004 (4) | size of this vtable
+ +0x0106 | 04 00 | uint16_t | 0x0004 (4) | size of referring table
+
+table (AnnotatedBinary.Baz):
+ +0x0108 | 04 00 00 00 | SOffset32 | 0x00000004 (4) Loc: +0x0104 | offset to vtable
+
+table (AnnotatedBinary.Bar):
+ +0x010C | FA FE FF FF | SOffset32 | 0xFFFFFEFA (-262) Loc: +0x0212 | ERROR: offset to vtable. Invalid offset, points outside the binary.
+
+unknown (no known references):
+ +0x0110 | 00 00 E4 43 10 00 00 00 | ?uint8_t[28] | ...C.... | WARN: nothing refers to this section.
+ +0x0118 | 00 00 00 00 00 C0 5E 40 | | ......^@
+ +0x0120 | 00 00 00 00 92 FE FF FF | | ........
+ +0x0128 | 00 00 00 01 | | ....
+
+vector (AnnotatedBinary.Foo.foobars_type):
+ +0x012C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0130 | 01 | UType8 | 0x01 (1) | value[0]
+ +0x0131 | 02 | UType8 | 0x02 (2) | value[1]
+ +0x0132 | 01 | UType8 | 0x01 (1) | value[2]
+
+vector (AnnotatedBinary.Foo.points_of_interest):
+ +0x0134 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0138 | 33 33 33 33 33 A3 45 40 | double | 0x4045A33333333333 (43.275) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0140 | 7E 57 04 FF 5B 87 53 C0 | double | 0xC053875BFF04577E (-78.115) | struct field `AnnotatedBinary.Location.longitude` (Double)
+ +0x0148 | 8D F0 F6 20 04 B6 42 40 | double | 0x4042B60420F6F08D (37.422) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0150 | 9F 77 63 41 61 85 5E C0 | double | 0xC05E85614163779F (-122.084) | struct field `AnnotatedBinary.Location.longitude` (Double)
+ +0x0158 | 8F 35 23 83 DC 35 4B C0 | double | 0xC04B35DC8323358F (-54.4208) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0160 | F6 97 DD 93 87 C5 0A 40 | double | 0x400AC58793DD97F6 (3.34645) | struct field `AnnotatedBinary.Location.longitude` (Double)
+
+padding:
+ +0x0168 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (AnnotatedBinary.Foo.names):
+ +0x016C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0170 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x0190 | offset to string[0]
+ +0x0174 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x0188 | offset to string[1]
+ +0x0178 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x017C | offset to string[2]
+
+string (AnnotatedBinary.Foo.names):
+ +0x017C | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x0180 | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x0187 | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.names):
+ +0x0188 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x018C | 62 6F 62 | char[3] | bob | string literal
+ +0x018F | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.names):
+ +0x0190 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x0194 | 61 6C 69 63 65 | char[5] | alice | string literal
+ +0x0199 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x019A | 00 00 | uint8_t[2] | .. | padding
+
+string (AnnotatedBinary.Foo.alice):
+ +0x019C | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x01A0 | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x01A7 | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.bob):
+ +0x01A8 | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x01AC | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x01B3 | 00 | char | 0x00 (0) | string terminator
+
+vector (AnnotatedBinary.Foo.accounts):
+ +0x01B4 | 09 00 00 00 | uint32_t | 0x00000009 (9) | ERROR: length of vector (# items). Longer than the binary.
+
+unknown (no known references):
+ +0x01B8 | 09 00 08 00 07 00 01 00 | ?uint8_t[9] | ........ | WARN: nothing refers to this section.
+ +0x01C0 | 02 | | .
diff --git a/tests/annotated_binary/tests/invalid_vector_scalars_cut_short.bin b/tests/annotated_binary/tests/invalid_vector_scalars_cut_short.bin
new file mode 100644
index 0000000..79dc796
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_vector_scalars_cut_short.bin
Binary files differ
diff --git a/tests/annotated_binary/tests/invalid_vector_strings_cut_short.afb b/tests/annotated_binary/tests/invalid_vector_strings_cut_short.afb
new file mode 100644
index 0000000..8f17f4e
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_vector_strings_cut_short.afb
@@ -0,0 +1,155 @@
+// Annotated Flatbuffer Binary
+//
+// Schema file: annotated_binary.fbs
+// Binary file: tests/invalid_vector_strings_cut_short.bin
+
+header:
+ +0x0000 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x0044 | offset to root table `AnnotatedBinary.Foo`
+ +0x0004 | 41 4E 4E 4F | char[4] | ANNO | File Identifier
+
+padding:
+ +0x0008 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Foo):
+ +0x000A | 3A 00 | uint16_t | 0x003A (58) | size of this vtable
+ +0x000C | 68 00 | uint16_t | 0x0068 (104) | size of referring table
+ +0x000E | 0C 00 | VOffset16 | 0x000C (12) | offset to field `counter` (id: 0)
+ +0x0010 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `healthy` (id: 1)
+ +0x0012 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `level` (id: 2) <defaults to 99> (Long)
+ +0x0014 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `meal` (id: 3)
+ +0x0016 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `bar` (id: 4)
+ +0x0018 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `home` (id: 5)
+ +0x001A | 30 00 | VOffset16 | 0x0030 (48) | offset to field `name` (id: 6)
+ +0x001C | 34 00 | VOffset16 | 0x0034 (52) | offset to field `bars` (id: 7)
+ +0x001E | 09 00 | VOffset16 | 0x0009 (9) | offset to field `bar_baz_type` (id: 8)
+ +0x0020 | 38 00 | VOffset16 | 0x0038 (56) | offset to field `bar_baz` (id: 9)
+ +0x0022 | 3C 00 | VOffset16 | 0x003C (60) | offset to field `accounts` (id: 10)
+ +0x0024 | 40 00 | VOffset16 | 0x0040 (64) | offset to field `bob` (id: 11)
+ +0x0026 | 44 00 | VOffset16 | 0x0044 (68) | offset to field `alice` (id: 12)
+ +0x0028 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `maybe_i32` (id: 13) <defaults to 0> (Int)
+ +0x002A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_i32` (id: 14) <defaults to 42> (Int)
+ +0x002C | 48 00 | VOffset16 | 0x0048 (72) | offset to field `just_i32` (id: 15)
+ +0x002E | 4C 00 | VOffset16 | 0x004C (76) | offset to field `names` (id: 16)
+ +0x0030 | 50 00 | VOffset16 | 0x0050 (80) | offset to field `points_of_interest` (id: 17)
+ +0x0032 | 54 00 | VOffset16 | 0x0054 (84) | offset to field `foobars_type` (id: 18)
+ +0x0034 | 58 00 | VOffset16 | 0x0058 (88) | offset to field `foobars` (id: 19)
+ +0x0036 | 0A 00 | VOffset16 | 0x000A (10) | offset to field `measurement_type` (id: 20)
+ +0x0038 | 5C 00 | VOffset16 | 0x005C (92) | offset to field `measurement` (id: 21)
+ +0x003A | 0B 00 | VOffset16 | 0x000B (11) | offset to field `anything_type` (id: 22)
+ +0x003C | 60 00 | VOffset16 | 0x0060 (96) | offset to field `anything` (id: 23)
+ +0x003E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `temperature` (id: 24) <defaults to 98.600000> (Float)
+ +0x0040 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `teetotaler` (id: 25) <null> (Obj)
+ +0x0042 | 64 00 | VOffset16 | 0x0064 (100) | offset to field `charlie` (id: 26)
+
+root_table (AnnotatedBinary.Foo):
+ +0x0044 | 3A 00 00 00 | SOffset32 | 0x0000003A (58) Loc: +0x000A | offset to vtable
+ +0x0048 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x004B | 01 | uint8_t | 0x01 (1) | table field `healthy` (Bool)
+ +0x004C | 02 | uint8_t | 0x02 (2) | table field `meal` (Byte)
+ +0x004D | 02 | UType8 | 0x02 (2) | table field `bar_baz_type` (UType)
+ +0x004E | 01 | UType8 | 0x01 (1) | table field `measurement_type` (UType)
+ +0x004F | 01 | UType8 | 0x01 (1) | table field `anything_type` (UType)
+ +0x0050 | D2 04 00 00 | uint32_t | 0x000004D2 (1234) | table field `counter` (Int)
+ +0x0054 | 28 02 00 00 | UOffset32 | 0x00000228 (552) Loc: +0x027C | ERROR: offset to field `bar`. Invalid offset, points outside the binary.
+ +0x0058 | 01 00 00 00 | uint32_t | 0x00000001 (1) | struct field `AnnotatedBinary.Building.floors` (Int)
+ +0x005C | 02 00 00 00 | uint32_t | 0x00000002 (2) | struct field `AnnotatedBinary.Building.doors` (Int)
+ +0x0060 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | struct field `AnnotatedBinary.Building.windows` (Int)
+ +0x0064 | 0A 00 00 00 | uint32_t | 0x0000000A (10) | array field `AnnotatedBinary.Dimension.values`[0] (Int)
+ +0x0068 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | array field `AnnotatedBinary.Dimension.values`[1] (Int)
+ +0x006C | 14 00 00 00 | uint32_t | 0x00000014 (20) | array field `AnnotatedBinary.Dimension.values`[2] (Int)
+ +0x0070 | 01 | uint8_t | 0x01 (1) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0071 | 02 | uint8_t | 0x02 (2) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0072 | 03 | uint8_t | 0x03 (3) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0073 | 00 | uint8_t[1] | . | padding
+ +0x0074 | C8 01 00 00 | UOffset32 | 0x000001C8 (456) Loc: +0x023C | ERROR: offset to field `name`. Invalid offset, points outside the binary.
+ +0x0078 | 5C 01 00 00 | UOffset32 | 0x0000015C (348) Loc: +0x01D4 | ERROR: offset to field `bars`. Invalid offset, points outside the binary.
+ +0x007C | 50 01 00 00 | UOffset32 | 0x00000150 (336) Loc: +0x01CC | ERROR: offset to field `bar_baz`. Invalid offset, points outside the binary.
+ +0x0080 | 34 01 00 00 | UOffset32 | 0x00000134 (308) Loc: +0x01B4 | ERROR: offset to field `accounts`. Invalid offset, points outside the binary.
+ +0x0084 | 24 01 00 00 | UOffset32 | 0x00000124 (292) Loc: +0x01A8 | ERROR: offset to field `bob`. Invalid offset, points outside the binary.
+ +0x0088 | 14 01 00 00 | UOffset32 | 0x00000114 (276) Loc: +0x019C | ERROR: offset to field `alice`. Invalid offset, points outside the binary.
+ +0x008C | 0D 00 00 00 | uint32_t | 0x0000000D (13) | table field `just_i32` (Int)
+ +0x0090 | DC 00 00 00 | UOffset32 | 0x000000DC (220) Loc: +0x016C | offset to field `names` (vector)
+ +0x0094 | A0 00 00 00 | UOffset32 | 0x000000A0 (160) Loc: +0x0134 | offset to field `points_of_interest` (vector)
+ +0x0098 | 94 00 00 00 | UOffset32 | 0x00000094 (148) Loc: +0x012C | offset to field `foobars_type` (vector)
+ +0x009C | 38 00 00 00 | UOffset32 | 0x00000038 (56) Loc: +0x00D4 | offset to field `foobars` (vector)
+ +0x00A0 | 33 00 00 00 | UOffset32 | 0x00000033 (51) Loc: +0x00D3 | offset to field `measurement` (union of type `Tolerance`)
+ +0x00A4 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x00C0 | offset to field `anything` (union of type `Bar`)
+ +0x00A8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00AC | offset to field `charlie` (string)
+
+string (AnnotatedBinary.Foo.charlie):
+ +0x00AC | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x00B0 | 61 6C 69 63 65 | char[5] | alice | string literal
+ +0x00B5 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x00B6 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Bar):
+ +0x00B8 | 08 00 | uint16_t | 0x0008 (8) | size of this vtable
+ +0x00BA | 13 00 | uint16_t | 0x0013 (19) | size of referring table
+ +0x00BC | 08 00 | VOffset16 | 0x0008 (8) | offset to field `a` (id: 0)
+ +0x00BE | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+
+table (AnnotatedBinary.Bar):
+ +0x00C0 | 08 00 00 00 | SOffset32 | 0x00000008 (8) Loc: +0x00B8 | offset to vtable
+ +0x00C4 | 00 80 23 44 | float | 0x44238000 (654) | table field `b` (Float)
+ +0x00C8 | 00 00 00 00 00 10 74 40 | double | 0x4074100000000000 (321) | table field `a` (Double)
+ +0x00D0 | 00 00 00 | uint8_t[3] | ... | padding
+
+union (AnnotatedBinary.Tolerance.measurement):
+ +0x00D3 | 05 | uint8_t | 0x05 (5) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+
+vector (AnnotatedBinary.Foo.foobars):
+ +0x00D4 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x00D8 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x010C | offset to union[0] (`Bar`)
+ +0x00DC | 2C 00 00 00 | UOffset32 | 0x0000002C (44) Loc: +0x0108 | offset to union[1] (`Baz`)
+ +0x00E0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00E4 | offset to union[2] (`Bar`)
+
+table (AnnotatedBinary.Bar):
+ +0x00E4 | D2 FE FF FF | SOffset32 | 0xFFFFFED2 (-302) Loc: +0x0212 | ERROR: offset to vtable. Invalid offset, points outside the binary.
+
+unknown (no known references):
+ +0x00E8 | 00 80 23 44 10 00 00 00 | ?uint8_t[28] | ..#D.... | WARN: nothing refers to this section.
+ +0x00F0 | 00 00 00 00 00 D8 8E 40 | | .......@
+ +0x00F8 | 00 00 00 00 6A FE FF FF | | ....j...
+ +0x0100 | 00 00 00 03 | | ....
+
+vtable (AnnotatedBinary.Baz):
+ +0x0104 | 04 00 | uint16_t | 0x0004 (4) | size of this vtable
+ +0x0106 | 04 00 | uint16_t | 0x0004 (4) | size of referring table
+
+table (AnnotatedBinary.Baz):
+ +0x0108 | 04 00 00 00 | SOffset32 | 0x00000004 (4) Loc: +0x0104 | offset to vtable
+
+table (AnnotatedBinary.Bar):
+ +0x010C | FA FE FF FF | SOffset32 | 0xFFFFFEFA (-262) Loc: +0x0212 | ERROR: offset to vtable. Invalid offset, points outside the binary.
+
+unknown (no known references):
+ +0x0110 | 00 00 E4 43 10 00 00 00 | ?uint8_t[28] | ...C.... | WARN: nothing refers to this section.
+ +0x0118 | 00 00 00 00 00 C0 5E 40 | | ......^@
+ +0x0120 | 00 00 00 00 92 FE FF FF | | ........
+ +0x0128 | 00 00 00 01 | | ....
+
+vector (AnnotatedBinary.Foo.foobars_type):
+ +0x012C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0130 | 01 | UType8 | 0x01 (1) | value[0]
+ +0x0131 | 02 | UType8 | 0x02 (2) | value[1]
+ +0x0132 | 01 | UType8 | 0x01 (1) | value[2]
+
+vector (AnnotatedBinary.Foo.points_of_interest):
+ +0x0134 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0138 | 33 33 33 33 33 A3 45 40 | double | 0x4045A33333333333 (43.275) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0140 | 7E 57 04 FF 5B 87 53 C0 | double | 0xC053875BFF04577E (-78.115) | struct field `AnnotatedBinary.Location.longitude` (Double)
+ +0x0148 | 8D F0 F6 20 04 B6 42 40 | double | 0x4042B60420F6F08D (37.422) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0150 | 9F 77 63 41 61 85 5E C0 | double | 0xC05E85614163779F (-122.084) | struct field `AnnotatedBinary.Location.longitude` (Double)
+ +0x0158 | 8F 35 23 83 DC 35 4B C0 | double | 0xC04B35DC8323358F (-54.4208) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0160 | F6 97 DD 93 87 C5 0A 40 | double | 0x400AC58793DD97F6 (3.34645) | struct field `AnnotatedBinary.Location.longitude` (Double)
+
+padding:
+ +0x0168 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (AnnotatedBinary.Foo.names):
+ +0x016C | 03 00 00 00 | uint32_t | 0x00000003 (3) | ERROR: length of vector (# items). Longer than the binary.
+
+unknown (no known references):
+ +0x0170 | 20 00 00 00 14 00 | ?uint8_t[6] | ..... | WARN: could be corrupted padding region.
diff --git a/tests/annotated_binary/tests/invalid_vector_strings_cut_short.bin b/tests/annotated_binary/tests/invalid_vector_strings_cut_short.bin
new file mode 100644
index 0000000..434aba1
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_vector_strings_cut_short.bin
Binary files differ
diff --git a/tests/annotated_binary/tests/invalid_vector_structs_cut_short.afb b/tests/annotated_binary/tests/invalid_vector_structs_cut_short.afb
new file mode 100644
index 0000000..b62c4db
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_vector_structs_cut_short.afb
@@ -0,0 +1,146 @@
+// Annotated Flatbuffer Binary
+//
+// Schema file: annotated_binary.fbs
+// Binary file: tests/invalid_vector_structs_cut_short.bin
+
+header:
+ +0x0000 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x0044 | offset to root table `AnnotatedBinary.Foo`
+ +0x0004 | 41 4E 4E 4F | char[4] | ANNO | File Identifier
+
+padding:
+ +0x0008 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Foo):
+ +0x000A | 3A 00 | uint16_t | 0x003A (58) | size of this vtable
+ +0x000C | 68 00 | uint16_t | 0x0068 (104) | size of referring table
+ +0x000E | 0C 00 | VOffset16 | 0x000C (12) | offset to field `counter` (id: 0)
+ +0x0010 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `healthy` (id: 1)
+ +0x0012 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `level` (id: 2) <defaults to 99> (Long)
+ +0x0014 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `meal` (id: 3)
+ +0x0016 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `bar` (id: 4)
+ +0x0018 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `home` (id: 5)
+ +0x001A | 30 00 | VOffset16 | 0x0030 (48) | offset to field `name` (id: 6)
+ +0x001C | 34 00 | VOffset16 | 0x0034 (52) | offset to field `bars` (id: 7)
+ +0x001E | 09 00 | VOffset16 | 0x0009 (9) | offset to field `bar_baz_type` (id: 8)
+ +0x0020 | 38 00 | VOffset16 | 0x0038 (56) | offset to field `bar_baz` (id: 9)
+ +0x0022 | 3C 00 | VOffset16 | 0x003C (60) | offset to field `accounts` (id: 10)
+ +0x0024 | 40 00 | VOffset16 | 0x0040 (64) | offset to field `bob` (id: 11)
+ +0x0026 | 44 00 | VOffset16 | 0x0044 (68) | offset to field `alice` (id: 12)
+ +0x0028 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `maybe_i32` (id: 13) <defaults to 0> (Int)
+ +0x002A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_i32` (id: 14) <defaults to 42> (Int)
+ +0x002C | 48 00 | VOffset16 | 0x0048 (72) | offset to field `just_i32` (id: 15)
+ +0x002E | 4C 00 | VOffset16 | 0x004C (76) | offset to field `names` (id: 16)
+ +0x0030 | 50 00 | VOffset16 | 0x0050 (80) | offset to field `points_of_interest` (id: 17)
+ +0x0032 | 54 00 | VOffset16 | 0x0054 (84) | offset to field `foobars_type` (id: 18)
+ +0x0034 | 58 00 | VOffset16 | 0x0058 (88) | offset to field `foobars` (id: 19)
+ +0x0036 | 0A 00 | VOffset16 | 0x000A (10) | offset to field `measurement_type` (id: 20)
+ +0x0038 | 5C 00 | VOffset16 | 0x005C (92) | offset to field `measurement` (id: 21)
+ +0x003A | 0B 00 | VOffset16 | 0x000B (11) | offset to field `anything_type` (id: 22)
+ +0x003C | 60 00 | VOffset16 | 0x0060 (96) | offset to field `anything` (id: 23)
+ +0x003E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `temperature` (id: 24) <defaults to 98.600000> (Float)
+ +0x0040 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `teetotaler` (id: 25) <null> (Obj)
+ +0x0042 | 64 00 | VOffset16 | 0x0064 (100) | offset to field `charlie` (id: 26)
+
+root_table (AnnotatedBinary.Foo):
+ +0x0044 | 3A 00 00 00 | SOffset32 | 0x0000003A (58) Loc: +0x000A | offset to vtable
+ +0x0048 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x004B | 01 | uint8_t | 0x01 (1) | table field `healthy` (Bool)
+ +0x004C | 02 | uint8_t | 0x02 (2) | table field `meal` (Byte)
+ +0x004D | 02 | UType8 | 0x02 (2) | table field `bar_baz_type` (UType)
+ +0x004E | 01 | UType8 | 0x01 (1) | table field `measurement_type` (UType)
+ +0x004F | 01 | UType8 | 0x01 (1) | table field `anything_type` (UType)
+ +0x0050 | D2 04 00 00 | uint32_t | 0x000004D2 (1234) | table field `counter` (Int)
+ +0x0054 | 28 02 00 00 | UOffset32 | 0x00000228 (552) Loc: +0x027C | ERROR: offset to field `bar`. Invalid offset, points outside the binary.
+ +0x0058 | 01 00 00 00 | uint32_t | 0x00000001 (1) | struct field `AnnotatedBinary.Building.floors` (Int)
+ +0x005C | 02 00 00 00 | uint32_t | 0x00000002 (2) | struct field `AnnotatedBinary.Building.doors` (Int)
+ +0x0060 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | struct field `AnnotatedBinary.Building.windows` (Int)
+ +0x0064 | 0A 00 00 00 | uint32_t | 0x0000000A (10) | array field `AnnotatedBinary.Dimension.values`[0] (Int)
+ +0x0068 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | array field `AnnotatedBinary.Dimension.values`[1] (Int)
+ +0x006C | 14 00 00 00 | uint32_t | 0x00000014 (20) | array field `AnnotatedBinary.Dimension.values`[2] (Int)
+ +0x0070 | 01 | uint8_t | 0x01 (1) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0071 | 02 | uint8_t | 0x02 (2) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0072 | 03 | uint8_t | 0x03 (3) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0073 | 00 | uint8_t[1] | . | padding
+ +0x0074 | C8 01 00 00 | UOffset32 | 0x000001C8 (456) Loc: +0x023C | ERROR: offset to field `name`. Invalid offset, points outside the binary.
+ +0x0078 | 5C 01 00 00 | UOffset32 | 0x0000015C (348) Loc: +0x01D4 | ERROR: offset to field `bars`. Invalid offset, points outside the binary.
+ +0x007C | 50 01 00 00 | UOffset32 | 0x00000150 (336) Loc: +0x01CC | ERROR: offset to field `bar_baz`. Invalid offset, points outside the binary.
+ +0x0080 | 34 01 00 00 | UOffset32 | 0x00000134 (308) Loc: +0x01B4 | ERROR: offset to field `accounts`. Invalid offset, points outside the binary.
+ +0x0084 | 24 01 00 00 | UOffset32 | 0x00000124 (292) Loc: +0x01A8 | ERROR: offset to field `bob`. Invalid offset, points outside the binary.
+ +0x0088 | 14 01 00 00 | UOffset32 | 0x00000114 (276) Loc: +0x019C | ERROR: offset to field `alice`. Invalid offset, points outside the binary.
+ +0x008C | 0D 00 00 00 | uint32_t | 0x0000000D (13) | table field `just_i32` (Int)
+ +0x0090 | DC 00 00 00 | UOffset32 | 0x000000DC (220) Loc: +0x016C | ERROR: offset to field `names`. Invalid offset, points outside the binary.
+ +0x0094 | A0 00 00 00 | UOffset32 | 0x000000A0 (160) Loc: +0x0134 | offset to field `points_of_interest` (vector)
+ +0x0098 | 94 00 00 00 | UOffset32 | 0x00000094 (148) Loc: +0x012C | offset to field `foobars_type` (vector)
+ +0x009C | 38 00 00 00 | UOffset32 | 0x00000038 (56) Loc: +0x00D4 | offset to field `foobars` (vector)
+ +0x00A0 | 33 00 00 00 | UOffset32 | 0x00000033 (51) Loc: +0x00D3 | offset to field `measurement` (union of type `Tolerance`)
+ +0x00A4 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x00C0 | offset to field `anything` (union of type `Bar`)
+ +0x00A8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00AC | offset to field `charlie` (string)
+
+string (AnnotatedBinary.Foo.charlie):
+ +0x00AC | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x00B0 | 61 6C 69 63 65 | char[5] | alice | string literal
+ +0x00B5 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x00B6 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Bar):
+ +0x00B8 | 08 00 | uint16_t | 0x0008 (8) | size of this vtable
+ +0x00BA | 13 00 | uint16_t | 0x0013 (19) | size of referring table
+ +0x00BC | 08 00 | VOffset16 | 0x0008 (8) | offset to field `a` (id: 0)
+ +0x00BE | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+
+table (AnnotatedBinary.Bar):
+ +0x00C0 | 08 00 00 00 | SOffset32 | 0x00000008 (8) Loc: +0x00B8 | offset to vtable
+ +0x00C4 | 00 80 23 44 | float | 0x44238000 (654) | table field `b` (Float)
+ +0x00C8 | 00 00 00 00 00 10 74 40 | double | 0x4074100000000000 (321) | table field `a` (Double)
+ +0x00D0 | 00 00 00 | uint8_t[3] | ... | padding
+
+union (AnnotatedBinary.Tolerance.measurement):
+ +0x00D3 | 05 | uint8_t | 0x05 (5) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+
+vector (AnnotatedBinary.Foo.foobars):
+ +0x00D4 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x00D8 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x010C | offset to union[0] (`Bar`)
+ +0x00DC | 2C 00 00 00 | UOffset32 | 0x0000002C (44) Loc: +0x0108 | offset to union[1] (`Baz`)
+ +0x00E0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00E4 | offset to union[2] (`Bar`)
+
+table (AnnotatedBinary.Bar):
+ +0x00E4 | D2 FE FF FF | SOffset32 | 0xFFFFFED2 (-302) Loc: +0x0212 | ERROR: offset to vtable. Invalid offset, points outside the binary.
+
+unknown (no known references):
+ +0x00E8 | 00 80 23 44 10 00 00 00 | ?uint8_t[28] | ..#D.... | WARN: nothing refers to this section.
+ +0x00F0 | 00 00 00 00 00 D8 8E 40 | | .......@
+ +0x00F8 | 00 00 00 00 6A FE FF FF | | ....j...
+ +0x0100 | 00 00 00 03 | | ....
+
+vtable (AnnotatedBinary.Baz):
+ +0x0104 | 04 00 | uint16_t | 0x0004 (4) | size of this vtable
+ +0x0106 | 04 00 | uint16_t | 0x0004 (4) | size of referring table
+
+table (AnnotatedBinary.Baz):
+ +0x0108 | 04 00 00 00 | SOffset32 | 0x00000004 (4) Loc: +0x0104 | offset to vtable
+
+table (AnnotatedBinary.Bar):
+ +0x010C | FA FE FF FF | SOffset32 | 0xFFFFFEFA (-262) Loc: +0x0212 | ERROR: offset to vtable. Invalid offset, points outside the binary.
+
+unknown (no known references):
+ +0x0110 | 00 00 E4 43 10 00 00 00 | ?uint8_t[28] | ...C.... | WARN: nothing refers to this section.
+ +0x0118 | 00 00 00 00 00 C0 5E 40 | | ......^@
+ +0x0120 | 00 00 00 00 92 FE FF FF | | ........
+ +0x0128 | 00 00 00 01 | | ....
+
+vector (AnnotatedBinary.Foo.foobars_type):
+ +0x012C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0130 | 01 | UType8 | 0x01 (1) | value[0]
+ +0x0131 | 02 | UType8 | 0x02 (2) | value[1]
+ +0x0132 | 01 | UType8 | 0x01 (1) | value[2]
+
+vector (AnnotatedBinary.Foo.points_of_interest):
+ +0x0134 | 03 00 00 00 | uint32_t | 0x00000003 (3) | ERROR: length of vector (# items). Longer than the binary.
+
+unknown (no known references):
+ +0x0138 | 33 33 33 33 33 A3 45 40 | ?uint8_t[28] | 33333.E@ | WARN: nothing refers to this section.
+ +0x0140 | 7E 57 04 FF 5B 87 53 C0 | | ~W..[.S.
+ +0x0148 | 8D F0 F6 20 04 B6 42 40 | | ... ..B@
+ +0x0150 | 9F 77 63 41 | | .wcA
diff --git a/tests/annotated_binary/tests/invalid_vector_structs_cut_short.bin b/tests/annotated_binary/tests/invalid_vector_structs_cut_short.bin
new file mode 100644
index 0000000..44da408
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_vector_structs_cut_short.bin
Binary files differ
diff --git a/tests/annotated_binary/tests/invalid_vector_tables_cut_short.afb b/tests/annotated_binary/tests/invalid_vector_tables_cut_short.afb
new file mode 100644
index 0000000..fa8b18f
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_vector_tables_cut_short.afb
@@ -0,0 +1,210 @@
+// Annotated Flatbuffer Binary
+//
+// Schema file: annotated_binary.fbs
+// Binary file: tests/invalid_vector_tables_cut_short.bin
+
+header:
+ +0x0000 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x0044 | offset to root table `AnnotatedBinary.Foo`
+ +0x0004 | 41 4E 4E 4F | char[4] | ANNO | File Identifier
+
+padding:
+ +0x0008 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Foo):
+ +0x000A | 3A 00 | uint16_t | 0x003A (58) | size of this vtable
+ +0x000C | 68 00 | uint16_t | 0x0068 (104) | size of referring table
+ +0x000E | 0C 00 | VOffset16 | 0x000C (12) | offset to field `counter` (id: 0)
+ +0x0010 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `healthy` (id: 1)
+ +0x0012 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `level` (id: 2) <defaults to 99> (Long)
+ +0x0014 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `meal` (id: 3)
+ +0x0016 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `bar` (id: 4)
+ +0x0018 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `home` (id: 5)
+ +0x001A | 30 00 | VOffset16 | 0x0030 (48) | offset to field `name` (id: 6)
+ +0x001C | 34 00 | VOffset16 | 0x0034 (52) | offset to field `bars` (id: 7)
+ +0x001E | 09 00 | VOffset16 | 0x0009 (9) | offset to field `bar_baz_type` (id: 8)
+ +0x0020 | 38 00 | VOffset16 | 0x0038 (56) | offset to field `bar_baz` (id: 9)
+ +0x0022 | 3C 00 | VOffset16 | 0x003C (60) | offset to field `accounts` (id: 10)
+ +0x0024 | 40 00 | VOffset16 | 0x0040 (64) | offset to field `bob` (id: 11)
+ +0x0026 | 44 00 | VOffset16 | 0x0044 (68) | offset to field `alice` (id: 12)
+ +0x0028 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `maybe_i32` (id: 13) <defaults to 0> (Int)
+ +0x002A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_i32` (id: 14) <defaults to 42> (Int)
+ +0x002C | 48 00 | VOffset16 | 0x0048 (72) | offset to field `just_i32` (id: 15)
+ +0x002E | 4C 00 | VOffset16 | 0x004C (76) | offset to field `names` (id: 16)
+ +0x0030 | 50 00 | VOffset16 | 0x0050 (80) | offset to field `points_of_interest` (id: 17)
+ +0x0032 | 54 00 | VOffset16 | 0x0054 (84) | offset to field `foobars_type` (id: 18)
+ +0x0034 | 58 00 | VOffset16 | 0x0058 (88) | offset to field `foobars` (id: 19)
+ +0x0036 | 0A 00 | VOffset16 | 0x000A (10) | offset to field `measurement_type` (id: 20)
+ +0x0038 | 5C 00 | VOffset16 | 0x005C (92) | offset to field `measurement` (id: 21)
+ +0x003A | 0B 00 | VOffset16 | 0x000B (11) | offset to field `anything_type` (id: 22)
+ +0x003C | 60 00 | VOffset16 | 0x0060 (96) | offset to field `anything` (id: 23)
+ +0x003E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `temperature` (id: 24) <defaults to 98.600000> (Float)
+ +0x0040 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `teetotaler` (id: 25) <null> (Obj)
+ +0x0042 | 64 00 | VOffset16 | 0x0064 (100) | offset to field `charlie` (id: 26)
+
+root_table (AnnotatedBinary.Foo):
+ +0x0044 | 3A 00 00 00 | SOffset32 | 0x0000003A (58) Loc: +0x000A | offset to vtable
+ +0x0048 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x004B | 01 | uint8_t | 0x01 (1) | table field `healthy` (Bool)
+ +0x004C | 02 | uint8_t | 0x02 (2) | table field `meal` (Byte)
+ +0x004D | 02 | UType8 | 0x02 (2) | table field `bar_baz_type` (UType)
+ +0x004E | 01 | UType8 | 0x01 (1) | table field `measurement_type` (UType)
+ +0x004F | 01 | UType8 | 0x01 (1) | table field `anything_type` (UType)
+ +0x0050 | D2 04 00 00 | uint32_t | 0x000004D2 (1234) | table field `counter` (Int)
+ +0x0054 | 28 02 00 00 | UOffset32 | 0x00000228 (552) Loc: +0x027C | ERROR: offset to field `bar`. Invalid offset, points outside the binary.
+ +0x0058 | 01 00 00 00 | uint32_t | 0x00000001 (1) | struct field `AnnotatedBinary.Building.floors` (Int)
+ +0x005C | 02 00 00 00 | uint32_t | 0x00000002 (2) | struct field `AnnotatedBinary.Building.doors` (Int)
+ +0x0060 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | struct field `AnnotatedBinary.Building.windows` (Int)
+ +0x0064 | 0A 00 00 00 | uint32_t | 0x0000000A (10) | array field `AnnotatedBinary.Dimension.values`[0] (Int)
+ +0x0068 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | array field `AnnotatedBinary.Dimension.values`[1] (Int)
+ +0x006C | 14 00 00 00 | uint32_t | 0x00000014 (20) | array field `AnnotatedBinary.Dimension.values`[2] (Int)
+ +0x0070 | 01 | uint8_t | 0x01 (1) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0071 | 02 | uint8_t | 0x02 (2) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0072 | 03 | uint8_t | 0x03 (3) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0073 | 00 | uint8_t[1] | . | padding
+ +0x0074 | C8 01 00 00 | UOffset32 | 0x000001C8 (456) Loc: +0x023C | ERROR: offset to field `name`. Invalid offset, points outside the binary.
+ +0x0078 | 5C 01 00 00 | UOffset32 | 0x0000015C (348) Loc: +0x01D4 | offset to field `bars` (vector)
+ +0x007C | 50 01 00 00 | UOffset32 | 0x00000150 (336) Loc: +0x01CC | offset to field `bar_baz` (union of type `Baz`)
+ +0x0080 | 34 01 00 00 | UOffset32 | 0x00000134 (308) Loc: +0x01B4 | offset to field `accounts` (vector)
+ +0x0084 | 24 01 00 00 | UOffset32 | 0x00000124 (292) Loc: +0x01A8 | offset to field `bob` (string)
+ +0x0088 | 14 01 00 00 | UOffset32 | 0x00000114 (276) Loc: +0x019C | offset to field `alice` (string)
+ +0x008C | 0D 00 00 00 | uint32_t | 0x0000000D (13) | table field `just_i32` (Int)
+ +0x0090 | DC 00 00 00 | UOffset32 | 0x000000DC (220) Loc: +0x016C | offset to field `names` (vector)
+ +0x0094 | A0 00 00 00 | UOffset32 | 0x000000A0 (160) Loc: +0x0134 | offset to field `points_of_interest` (vector)
+ +0x0098 | 94 00 00 00 | UOffset32 | 0x00000094 (148) Loc: +0x012C | offset to field `foobars_type` (vector)
+ +0x009C | 38 00 00 00 | UOffset32 | 0x00000038 (56) Loc: +0x00D4 | offset to field `foobars` (vector)
+ +0x00A0 | 33 00 00 00 | UOffset32 | 0x00000033 (51) Loc: +0x00D3 | offset to field `measurement` (union of type `Tolerance`)
+ +0x00A4 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x00C0 | offset to field `anything` (union of type `Bar`)
+ +0x00A8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00AC | offset to field `charlie` (string)
+
+string (AnnotatedBinary.Foo.charlie):
+ +0x00AC | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x00B0 | 61 6C 69 63 65 | char[5] | alice | string literal
+ +0x00B5 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x00B6 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Bar):
+ +0x00B8 | 08 00 | uint16_t | 0x0008 (8) | size of this vtable
+ +0x00BA | 13 00 | uint16_t | 0x0013 (19) | size of referring table
+ +0x00BC | 08 00 | VOffset16 | 0x0008 (8) | offset to field `a` (id: 0)
+ +0x00BE | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+
+table (AnnotatedBinary.Bar):
+ +0x00C0 | 08 00 00 00 | SOffset32 | 0x00000008 (8) Loc: +0x00B8 | offset to vtable
+ +0x00C4 | 00 80 23 44 | float | 0x44238000 (654) | table field `b` (Float)
+ +0x00C8 | 00 00 00 00 00 10 74 40 | double | 0x4074100000000000 (321) | table field `a` (Double)
+ +0x00D0 | 00 00 00 | uint8_t[3] | ... | padding
+
+union (AnnotatedBinary.Tolerance.measurement):
+ +0x00D3 | 05 | uint8_t | 0x05 (5) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+
+vector (AnnotatedBinary.Foo.foobars):
+ +0x00D4 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x00D8 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x010C | offset to union[0] (`Bar`)
+ +0x00DC | 2C 00 00 00 | UOffset32 | 0x0000002C (44) Loc: +0x0108 | offset to union[1] (`Baz`)
+ +0x00E0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00E4 | offset to union[2] (`Bar`)
+
+table (AnnotatedBinary.Bar):
+ +0x00E4 | D2 FE FF FF | SOffset32 | 0xFFFFFED2 (-302) Loc: +0x0212 | ERROR: offset to vtable. Invalid offset, points outside the binary.
+
+unknown (no known references):
+ +0x00E8 | 00 80 23 44 10 00 00 00 | ?uint8_t[28] | ..#D.... | WARN: nothing refers to this section.
+ +0x00F0 | 00 00 00 00 00 D8 8E 40 | | .......@
+ +0x00F8 | 00 00 00 00 6A FE FF FF | | ....j...
+ +0x0100 | 00 00 00 03 | | ....
+
+vtable (AnnotatedBinary.Baz):
+ +0x0104 | 04 00 | uint16_t | 0x0004 (4) | size of this vtable
+ +0x0106 | 04 00 | uint16_t | 0x0004 (4) | size of referring table
+
+table (AnnotatedBinary.Baz):
+ +0x0108 | 04 00 00 00 | SOffset32 | 0x00000004 (4) Loc: +0x0104 | offset to vtable
+
+table (AnnotatedBinary.Bar):
+ +0x010C | FA FE FF FF | SOffset32 | 0xFFFFFEFA (-262) Loc: +0x0212 | ERROR: offset to vtable. Invalid offset, points outside the binary.
+
+unknown (no known references):
+ +0x0110 | 00 00 E4 43 10 00 00 00 | ?uint8_t[28] | ...C.... | WARN: nothing refers to this section.
+ +0x0118 | 00 00 00 00 00 C0 5E 40 | | ......^@
+ +0x0120 | 00 00 00 00 92 FE FF FF | | ........
+ +0x0128 | 00 00 00 01 | | ....
+
+vector (AnnotatedBinary.Foo.foobars_type):
+ +0x012C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0130 | 01 | UType8 | 0x01 (1) | value[0]
+ +0x0131 | 02 | UType8 | 0x02 (2) | value[1]
+ +0x0132 | 01 | UType8 | 0x01 (1) | value[2]
+
+vector (AnnotatedBinary.Foo.points_of_interest):
+ +0x0134 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0138 | 33 33 33 33 33 A3 45 40 | double | 0x4045A33333333333 (43.275) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0140 | 7E 57 04 FF 5B 87 53 C0 | double | 0xC053875BFF04577E (-78.115) | struct field `AnnotatedBinary.Location.longitude` (Double)
+ +0x0148 | 8D F0 F6 20 04 B6 42 40 | double | 0x4042B60420F6F08D (37.422) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0150 | 9F 77 63 41 61 85 5E C0 | double | 0xC05E85614163779F (-122.084) | struct field `AnnotatedBinary.Location.longitude` (Double)
+ +0x0158 | 8F 35 23 83 DC 35 4B C0 | double | 0xC04B35DC8323358F (-54.4208) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0160 | F6 97 DD 93 87 C5 0A 40 | double | 0x400AC58793DD97F6 (3.34645) | struct field `AnnotatedBinary.Location.longitude` (Double)
+
+padding:
+ +0x0168 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (AnnotatedBinary.Foo.names):
+ +0x016C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0170 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x0190 | offset to string[0]
+ +0x0174 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x0188 | offset to string[1]
+ +0x0178 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x017C | offset to string[2]
+
+string (AnnotatedBinary.Foo.names):
+ +0x017C | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x0180 | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x0187 | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.names):
+ +0x0188 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x018C | 62 6F 62 | char[3] | bob | string literal
+ +0x018F | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.names):
+ +0x0190 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x0194 | 61 6C 69 63 65 | char[5] | alice | string literal
+ +0x0199 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x019A | 00 00 | uint8_t[2] | .. | padding
+
+string (AnnotatedBinary.Foo.alice):
+ +0x019C | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x01A0 | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x01A7 | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.bob):
+ +0x01A8 | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x01AC | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x01B3 | 00 | char | 0x00 (0) | string terminator
+
+vector (AnnotatedBinary.Foo.accounts):
+ +0x01B4 | 09 00 00 00 | uint32_t | 0x00000009 (9) | length of vector (# items)
+ +0x01B8 | 09 00 | uint16_t | 0x0009 (9) | value[0]
+ +0x01BA | 08 00 | uint16_t | 0x0008 (8) | value[1]
+ +0x01BC | 07 00 | uint16_t | 0x0007 (7) | value[2]
+ +0x01BE | 01 00 | uint16_t | 0x0001 (1) | value[3]
+ +0x01C0 | 02 00 | uint16_t | 0x0002 (2) | value[4]
+ +0x01C2 | 03 00 | uint16_t | 0x0003 (3) | value[5]
+ +0x01C4 | 06 00 | uint16_t | 0x0006 (6) | value[6]
+ +0x01C6 | 05 00 | uint16_t | 0x0005 (5) | value[7]
+ +0x01C8 | 04 00 | uint16_t | 0x0004 (4) | value[8]
+
+padding:
+ +0x01CA | 00 00 | uint8_t[2] | .. | padding
+
+table (AnnotatedBinary.Baz):
+ +0x01CC | 3A FF FF FF | SOffset32 | 0xFFFFFF3A (-198) Loc: +0x0292 | ERROR: offset to vtable. Invalid offset, points outside the binary.
+
+unknown (no known references):
+ +0x01D0 | 00 00 00 03 | ?uint8_t[4] | .... | WARN: could be corrupted padding region.
+
+vector (AnnotatedBinary.Foo.bars):
+ +0x01D4 | 02 00 00 00 | uint32_t | 0x00000002 (2) | ERROR: length of vector (# items). Longer than the binary.
+
+unknown (no known references):
+ +0x01D8 | 44 00 00 00 10 00 | ?uint8_t[6] | D..... | WARN: could be corrupted padding region.
diff --git a/tests/annotated_binary/tests/invalid_vector_tables_cut_short.bin b/tests/annotated_binary/tests/invalid_vector_tables_cut_short.bin
new file mode 100644
index 0000000..2823d83
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_vector_tables_cut_short.bin
Binary files differ
diff --git a/tests/annotated_binary/tests/invalid_vector_union_type_value.afb b/tests/annotated_binary/tests/invalid_vector_union_type_value.afb
new file mode 100644
index 0000000..ffa6728
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_vector_union_type_value.afb
@@ -0,0 +1,293 @@
+// Annotated Flatbuffer Binary
+//
+// Schema file: annotated_binary.fbs
+// Binary file: tests/invalid_vector_union_type_value.bin
+
+header:
+ +0x0000 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x0044 | offset to root table `AnnotatedBinary.Foo`
+ +0x0004 | 41 4E 4E 4F | char[4] | ANNO | File Identifier
+
+padding:
+ +0x0008 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Foo):
+ +0x000A | 3A 00 | uint16_t | 0x003A (58) | size of this vtable
+ +0x000C | 68 00 | uint16_t | 0x0068 (104) | size of referring table
+ +0x000E | 0C 00 | VOffset16 | 0x000C (12) | offset to field `counter` (id: 0)
+ +0x0010 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `healthy` (id: 1)
+ +0x0012 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `level` (id: 2) <defaults to 99> (Long)
+ +0x0014 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `meal` (id: 3)
+ +0x0016 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `bar` (id: 4)
+ +0x0018 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `home` (id: 5)
+ +0x001A | 30 00 | VOffset16 | 0x0030 (48) | offset to field `name` (id: 6)
+ +0x001C | 34 00 | VOffset16 | 0x0034 (52) | offset to field `bars` (id: 7)
+ +0x001E | 09 00 | VOffset16 | 0x0009 (9) | offset to field `bar_baz_type` (id: 8)
+ +0x0020 | 38 00 | VOffset16 | 0x0038 (56) | offset to field `bar_baz` (id: 9)
+ +0x0022 | 3C 00 | VOffset16 | 0x003C (60) | offset to field `accounts` (id: 10)
+ +0x0024 | 40 00 | VOffset16 | 0x0040 (64) | offset to field `bob` (id: 11)
+ +0x0026 | 44 00 | VOffset16 | 0x0044 (68) | offset to field `alice` (id: 12)
+ +0x0028 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `maybe_i32` (id: 13) <defaults to 0> (Int)
+ +0x002A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_i32` (id: 14) <defaults to 42> (Int)
+ +0x002C | 48 00 | VOffset16 | 0x0048 (72) | offset to field `just_i32` (id: 15)
+ +0x002E | 4C 00 | VOffset16 | 0x004C (76) | offset to field `names` (id: 16)
+ +0x0030 | 50 00 | VOffset16 | 0x0050 (80) | offset to field `points_of_interest` (id: 17)
+ +0x0032 | 54 00 | VOffset16 | 0x0054 (84) | offset to field `foobars_type` (id: 18)
+ +0x0034 | 58 00 | VOffset16 | 0x0058 (88) | offset to field `foobars` (id: 19)
+ +0x0036 | 0A 00 | VOffset16 | 0x000A (10) | offset to field `measurement_type` (id: 20)
+ +0x0038 | 5C 00 | VOffset16 | 0x005C (92) | offset to field `measurement` (id: 21)
+ +0x003A | 0B 00 | VOffset16 | 0x000B (11) | offset to field `anything_type` (id: 22)
+ +0x003C | 60 00 | VOffset16 | 0x0060 (96) | offset to field `anything` (id: 23)
+ +0x003E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `temperature` (id: 24) <defaults to 98.600000> (Float)
+ +0x0040 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `teetotaler` (id: 25) <null> (Obj)
+ +0x0042 | 64 00 | VOffset16 | 0x0064 (100) | offset to field `charlie` (id: 26)
+
+root_table (AnnotatedBinary.Foo):
+ +0x0044 | 3A 00 00 00 | SOffset32 | 0x0000003A (58) Loc: +0x000A | offset to vtable
+ +0x0048 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x004B | 01 | uint8_t | 0x01 (1) | table field `healthy` (Bool)
+ +0x004C | 02 | uint8_t | 0x02 (2) | table field `meal` (Byte)
+ +0x004D | 02 | UType8 | 0x02 (2) | table field `bar_baz_type` (UType)
+ +0x004E | 01 | UType8 | 0x01 (1) | table field `measurement_type` (UType)
+ +0x004F | 01 | UType8 | 0x01 (1) | table field `anything_type` (UType)
+ +0x0050 | D2 04 00 00 | uint32_t | 0x000004D2 (1234) | table field `counter` (Int)
+ +0x0054 | 28 02 00 00 | UOffset32 | 0x00000228 (552) Loc: +0x027C | offset to field `bar` (table)
+ +0x0058 | 01 00 00 00 | uint32_t | 0x00000001 (1) | struct field `AnnotatedBinary.Building.floors` (Int)
+ +0x005C | 02 00 00 00 | uint32_t | 0x00000002 (2) | struct field `AnnotatedBinary.Building.doors` (Int)
+ +0x0060 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | struct field `AnnotatedBinary.Building.windows` (Int)
+ +0x0064 | 0A 00 00 00 | uint32_t | 0x0000000A (10) | array field `AnnotatedBinary.Dimension.values`[0] (Int)
+ +0x0068 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | array field `AnnotatedBinary.Dimension.values`[1] (Int)
+ +0x006C | 14 00 00 00 | uint32_t | 0x00000014 (20) | array field `AnnotatedBinary.Dimension.values`[2] (Int)
+ +0x0070 | 01 | uint8_t | 0x01 (1) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0071 | 02 | uint8_t | 0x02 (2) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0072 | 03 | uint8_t | 0x03 (3) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0073 | 00 | uint8_t[1] | . | padding
+ +0x0074 | C8 01 00 00 | UOffset32 | 0x000001C8 (456) Loc: +0x023C | offset to field `name` (string)
+ +0x0078 | 5C 01 00 00 | UOffset32 | 0x0000015C (348) Loc: +0x01D4 | offset to field `bars` (vector)
+ +0x007C | 50 01 00 00 | UOffset32 | 0x00000150 (336) Loc: +0x01CC | offset to field `bar_baz` (union of type `Baz`)
+ +0x0080 | 34 01 00 00 | UOffset32 | 0x00000134 (308) Loc: +0x01B4 | offset to field `accounts` (vector)
+ +0x0084 | 24 01 00 00 | UOffset32 | 0x00000124 (292) Loc: +0x01A8 | offset to field `bob` (string)
+ +0x0088 | 14 01 00 00 | UOffset32 | 0x00000114 (276) Loc: +0x019C | offset to field `alice` (string)
+ +0x008C | 0D 00 00 00 | uint32_t | 0x0000000D (13) | table field `just_i32` (Int)
+ +0x0090 | DC 00 00 00 | UOffset32 | 0x000000DC (220) Loc: +0x016C | offset to field `names` (vector)
+ +0x0094 | A0 00 00 00 | UOffset32 | 0x000000A0 (160) Loc: +0x0134 | offset to field `points_of_interest` (vector)
+ +0x0098 | 94 00 00 00 | UOffset32 | 0x00000094 (148) Loc: +0x012C | offset to field `foobars_type` (vector)
+ +0x009C | 38 00 00 00 | UOffset32 | 0x00000038 (56) Loc: +0x00D4 | offset to field `foobars` (vector)
+ +0x00A0 | 33 00 00 00 | UOffset32 | 0x00000033 (51) Loc: +0x00D3 | offset to field `measurement` (union of type `Tolerance`)
+ +0x00A4 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x00C0 | offset to field `anything` (union of type `Bar`)
+ +0x00A8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00AC | offset to field `charlie` (string)
+
+string (AnnotatedBinary.Foo.charlie):
+ +0x00AC | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x00B0 | 61 6C 69 63 65 | char[5] | alice | string literal
+ +0x00B5 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x00B6 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Bar):
+ +0x00B8 | 08 00 | uint16_t | 0x0008 (8) | size of this vtable
+ +0x00BA | 13 00 | uint16_t | 0x0013 (19) | size of referring table
+ +0x00BC | 08 00 | VOffset16 | 0x0008 (8) | offset to field `a` (id: 0)
+ +0x00BE | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+
+table (AnnotatedBinary.Bar):
+ +0x00C0 | 08 00 00 00 | SOffset32 | 0x00000008 (8) Loc: +0x00B8 | offset to vtable
+ +0x00C4 | 00 80 23 44 | float | 0x44238000 (654) | table field `b` (Float)
+ +0x00C8 | 00 00 00 00 00 10 74 40 | double | 0x4074100000000000 (321) | table field `a` (Double)
+ +0x00D0 | 00 00 00 | uint8_t[3] | ... | padding
+
+union (AnnotatedBinary.Tolerance.measurement):
+ +0x00D3 | 05 | uint8_t | 0x05 (5) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+
+vector (AnnotatedBinary.Foo.foobars):
+ +0x00D4 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x00D8 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x010C | offset to union[0] (`Bar`)
+ +0x00DC | 2C 00 00 00 | ?uint8_t[4] | ,... | WARN: nothing refers to this section.
+ +0x00E0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00E4 | offset to union[2] (`Bar`)
+
+table (AnnotatedBinary.Bar):
+ +0x00E4 | D2 FE FF FF | SOffset32 | 0xFFFFFED2 (-302) Loc: +0x0212 | offset to vtable
+ +0x00E8 | 00 80 23 44 | float | 0x44238000 (654) | table field `b` (Float)
+ +0x00EC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x00FC | offset to field `c` (table)
+ +0x00F0 | 00 00 00 00 00 D8 8E 40 | double | 0x408ED80000000000 (987) | table field `a` (Double)
+ +0x00F8 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+table (AnnotatedBinary.Baz):
+ +0x00FC | 6A FE FF FF | SOffset32 | 0xFFFFFE6A (-406) Loc: +0x0292 | offset to vtable
+ +0x0100 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x0103 | 03 | uint8_t | 0x03 (3) | table field `meal` (Byte)
+
+unknown (no known references):
+ +0x0104 | 04 00 04 00 04 00 00 00 | ?uint8_t[8] | ........ | WARN: nothing refers to this section.
+
+table (AnnotatedBinary.Bar):
+ +0x010C | FA FE FF FF | SOffset32 | 0xFFFFFEFA (-262) Loc: +0x0212 | offset to vtable
+ +0x0110 | 00 00 E4 43 | float | 0x43E40000 (456) | table field `b` (Float)
+ +0x0114 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x0124 | offset to field `c` (table)
+ +0x0118 | 00 00 00 00 00 C0 5E 40 | double | 0x405EC00000000000 (123) | table field `a` (Double)
+ +0x0120 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+table (AnnotatedBinary.Baz):
+ +0x0124 | 92 FE FF FF | SOffset32 | 0xFFFFFE92 (-366) Loc: +0x0292 | offset to vtable
+ +0x0128 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x012B | 01 | uint8_t | 0x01 (1) | table field `meal` (Byte)
+
+vector (AnnotatedBinary.Foo.foobars_type):
+ +0x012C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0130 | 01 | UType8 | 0x01 (1) | value[0]
+ +0x0131 | FF | UType8 | 0xFF (255) | ERROR: value[1]. Invalid union type value.
+ +0x0132 | 01 | UType8 | 0x01 (1) | value[2]
+
+vector (AnnotatedBinary.Foo.points_of_interest):
+ +0x0134 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0138 | 33 33 33 33 33 A3 45 40 | double | 0x4045A33333333333 (43.275) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0140 | 7E 57 04 FF 5B 87 53 C0 | double | 0xC053875BFF04577E (-78.115) | struct field `AnnotatedBinary.Location.longitude` (Double)
+ +0x0148 | 8D F0 F6 20 04 B6 42 40 | double | 0x4042B60420F6F08D (37.422) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0150 | 9F 77 63 41 61 85 5E C0 | double | 0xC05E85614163779F (-122.084) | struct field `AnnotatedBinary.Location.longitude` (Double)
+ +0x0158 | 8F 35 23 83 DC 35 4B C0 | double | 0xC04B35DC8323358F (-54.4208) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0160 | F6 97 DD 93 87 C5 0A 40 | double | 0x400AC58793DD97F6 (3.34645) | struct field `AnnotatedBinary.Location.longitude` (Double)
+
+padding:
+ +0x0168 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (AnnotatedBinary.Foo.names):
+ +0x016C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0170 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x0190 | offset to string[0]
+ +0x0174 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x0188 | offset to string[1]
+ +0x0178 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x017C | offset to string[2]
+
+string (AnnotatedBinary.Foo.names):
+ +0x017C | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x0180 | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x0187 | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.names):
+ +0x0188 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x018C | 62 6F 62 | char[3] | bob | string literal
+ +0x018F | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.names):
+ +0x0190 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x0194 | 61 6C 69 63 65 | char[5] | alice | string literal
+ +0x0199 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x019A | 00 00 | uint8_t[2] | .. | padding
+
+string (AnnotatedBinary.Foo.alice):
+ +0x019C | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x01A0 | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x01A7 | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.bob):
+ +0x01A8 | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x01AC | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x01B3 | 00 | char | 0x00 (0) | string terminator
+
+vector (AnnotatedBinary.Foo.accounts):
+ +0x01B4 | 09 00 00 00 | uint32_t | 0x00000009 (9) | length of vector (# items)
+ +0x01B8 | 09 00 | uint16_t | 0x0009 (9) | value[0]
+ +0x01BA | 08 00 | uint16_t | 0x0008 (8) | value[1]
+ +0x01BC | 07 00 | uint16_t | 0x0007 (7) | value[2]
+ +0x01BE | 01 00 | uint16_t | 0x0001 (1) | value[3]
+ +0x01C0 | 02 00 | uint16_t | 0x0002 (2) | value[4]
+ +0x01C2 | 03 00 | uint16_t | 0x0003 (3) | value[5]
+ +0x01C4 | 06 00 | uint16_t | 0x0006 (6) | value[6]
+ +0x01C6 | 05 00 | uint16_t | 0x0005 (5) | value[7]
+ +0x01C8 | 04 00 | uint16_t | 0x0004 (4) | value[8]
+
+padding:
+ +0x01CA | 00 00 | uint8_t[2] | .. | padding
+
+table (AnnotatedBinary.Baz):
+ +0x01CC | 3A FF FF FF | SOffset32 | 0xFFFFFF3A (-198) Loc: +0x0292 | offset to vtable
+ +0x01D0 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x01D3 | 03 | uint8_t | 0x03 (3) | table field `meal` (Byte)
+
+vector (AnnotatedBinary.Foo.bars):
+ +0x01D4 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x01D8 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x021C | offset to table[0]
+ +0x01DC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x01EC | offset to table[1]
+
+padding:
+ +0x01E0 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Bar):
+ +0x01E2 | 0A 00 | uint16_t | 0x000A (10) | size of this vtable
+ +0x01E4 | 1A 00 | uint16_t | 0x001A (26) | size of referring table
+ +0x01E6 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `a` (id: 0)
+ +0x01E8 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+ +0x01EA | 08 00 | VOffset16 | 0x0008 (8) | offset to field `c` (id: 2)
+
+table (AnnotatedBinary.Bar):
+ +0x01EC | 0A 00 00 00 | SOffset32 | 0x0000000A (10) Loc: +0x01E2 | offset to vtable
+ +0x01F0 | 00 80 23 44 | float | 0x44238000 (654) | table field `b` (Float)
+ +0x01F4 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x020C | offset to field `c` (table)
+ +0x01F8 | 00 00 00 00 00 D8 8E 40 | double | 0x408ED80000000000 (987) | table field `a` (Double)
+ +0x0200 | 00 00 00 00 00 00 | uint8_t[6] | ...... | padding
+
+vtable (AnnotatedBinary.Baz):
+ +0x0206 | 06 00 | uint16_t | 0x0006 (6) | size of this vtable
+ +0x0208 | 06 00 | uint16_t | 0x0006 (6) | size of referring table
+ +0x020A | 05 00 | VOffset16 | 0x0005 (5) | offset to field `meal` (id: 0)
+
+table (AnnotatedBinary.Baz):
+ +0x020C | 06 00 00 00 | SOffset32 | 0x00000006 (6) Loc: +0x0206 | offset to vtable
+ +0x0210 | 00 | uint8_t[1] | . | padding
+ +0x0211 | 03 | uint8_t | 0x03 (3) | table field `meal` (Byte)
+
+vtable (AnnotatedBinary.Bar):
+ +0x0212 | 0A 00 | uint16_t | 0x000A (10) | size of this vtable
+ +0x0214 | 18 00 | uint16_t | 0x0018 (24) | size of referring table
+ +0x0216 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `a` (id: 0)
+ +0x0218 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+ +0x021A | 08 00 | VOffset16 | 0x0008 (8) | offset to field `c` (id: 2)
+
+table (AnnotatedBinary.Bar):
+ +0x021C | 0A 00 00 00 | SOffset32 | 0x0000000A (10) Loc: +0x0212 | offset to vtable
+ +0x0220 | 00 00 E4 43 | float | 0x43E40000 (456) | table field `b` (Float)
+ +0x0224 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x0234 | offset to field `c` (table)
+ +0x0228 | 00 00 00 00 00 C0 5E 40 | double | 0x405EC00000000000 (123) | table field `a` (Double)
+ +0x0230 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+table (AnnotatedBinary.Baz):
+ +0x0234 | A2 FF FF FF | SOffset32 | 0xFFFFFFA2 (-94) Loc: +0x0292 | offset to vtable
+ +0x0238 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x023B | 01 | uint8_t | 0x01 (1) | table field `meal` (Byte)
+
+string (AnnotatedBinary.Foo.name):
+ +0x023C | 2F 00 00 00 | uint32_t | 0x0000002F (47) | length of string
+ +0x0240 | 54 68 69 73 20 69 73 20 | char[47] | This is | string literal
+ +0x0248 | 61 20 6C 6F 6E 67 20 73 | | a long s
+ +0x0250 | 74 72 69 6E 67 20 74 6F | | tring to
+ +0x0258 | 20 73 68 6F 77 20 68 6F | | show ho
+ +0x0260 | 77 20 69 74 20 62 72 65 | | w it bre
+ +0x0268 | 61 6B 73 20 75 70 2E | | aks up.
+ +0x026F | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x0270 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Bar):
+ +0x0272 | 0A 00 | uint16_t | 0x000A (10) | size of this vtable
+ +0x0274 | 16 00 | uint16_t | 0x0016 (22) | size of referring table
+ +0x0276 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `a` (id: 0)
+ +0x0278 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+ +0x027A | 08 00 | VOffset16 | 0x0008 (8) | offset to field `c` (id: 2)
+
+table (AnnotatedBinary.Bar):
+ +0x027C | 0A 00 00 00 | SOffset32 | 0x0000000A (10) Loc: +0x0272 | offset to vtable
+ +0x0280 | 65 20 71 49 | float | 0x49712065 (987654) | table field `b` (Float)
+ +0x0284 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x0298 | offset to field `c` (table)
+ +0x0288 | C9 76 BE 9F 0C 24 FE 40 | double | 0x40FE240C9FBE76C9 (123457) | table field `a` (Double)
+ +0x0290 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Baz):
+ +0x0292 | 06 00 | uint16_t | 0x0006 (6) | size of this vtable
+ +0x0294 | 08 00 | uint16_t | 0x0008 (8) | size of referring table
+ +0x0296 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `meal` (id: 0)
+
+table (AnnotatedBinary.Baz):
+ +0x0298 | 06 00 00 00 | SOffset32 | 0x00000006 (6) Loc: +0x0292 | offset to vtable
+ +0x029C | 00 00 00 | uint8_t[3] | ... | padding
+ +0x029F | 01 | uint8_t | 0x01 (1) | table field `meal` (Byte)
diff --git a/tests/annotated_binary/tests/invalid_vector_union_type_value.bin b/tests/annotated_binary/tests/invalid_vector_union_type_value.bin
new file mode 100644
index 0000000..8725971
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_vector_union_type_value.bin
Binary files differ
diff --git a/tests/annotated_binary/tests/invalid_vector_unions_cut_short.afb b/tests/annotated_binary/tests/invalid_vector_unions_cut_short.afb
new file mode 100644
index 0000000..7267c76
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_vector_unions_cut_short.afb
@@ -0,0 +1,210 @@
+// Annotated Flatbuffer Binary
+//
+// Schema file: annotated_binary.fbs
+// Binary file: tests/invalid_vector_unions_cut_short.bin
+
+header:
+ +0x0000 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x0044 | offset to root table `AnnotatedBinary.Foo`
+ +0x0004 | 41 4E 4E 4F | char[4] | ANNO | File Identifier
+
+padding:
+ +0x0008 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Foo):
+ +0x000A | 3A 00 | uint16_t | 0x003A (58) | size of this vtable
+ +0x000C | 68 00 | uint16_t | 0x0068 (104) | size of referring table
+ +0x000E | 0C 00 | VOffset16 | 0x000C (12) | offset to field `counter` (id: 0)
+ +0x0010 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `healthy` (id: 1)
+ +0x0012 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `level` (id: 2) <defaults to 99> (Long)
+ +0x0014 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `meal` (id: 3)
+ +0x0016 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `bar` (id: 4)
+ +0x0018 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `home` (id: 5)
+ +0x001A | 30 00 | VOffset16 | 0x0030 (48) | offset to field `name` (id: 6)
+ +0x001C | 34 00 | VOffset16 | 0x0034 (52) | offset to field `bars` (id: 7)
+ +0x001E | 09 00 | VOffset16 | 0x0009 (9) | offset to field `bar_baz_type` (id: 8)
+ +0x0020 | 38 00 | VOffset16 | 0x0038 (56) | offset to field `bar_baz` (id: 9)
+ +0x0022 | 3C 00 | VOffset16 | 0x003C (60) | offset to field `accounts` (id: 10)
+ +0x0024 | 40 00 | VOffset16 | 0x0040 (64) | offset to field `bob` (id: 11)
+ +0x0026 | 44 00 | VOffset16 | 0x0044 (68) | offset to field `alice` (id: 12)
+ +0x0028 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `maybe_i32` (id: 13) <defaults to 0> (Int)
+ +0x002A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_i32` (id: 14) <defaults to 42> (Int)
+ +0x002C | 48 00 | VOffset16 | 0x0048 (72) | offset to field `just_i32` (id: 15)
+ +0x002E | 4C 00 | VOffset16 | 0x004C (76) | offset to field `names` (id: 16)
+ +0x0030 | 50 00 | VOffset16 | 0x0050 (80) | offset to field `points_of_interest` (id: 17)
+ +0x0032 | 54 00 | VOffset16 | 0x0054 (84) | offset to field `foobars_type` (id: 18)
+ +0x0034 | 58 00 | VOffset16 | 0x0058 (88) | offset to field `foobars` (id: 19)
+ +0x0036 | 0A 00 | VOffset16 | 0x000A (10) | offset to field `measurement_type` (id: 20)
+ +0x0038 | 5C 00 | VOffset16 | 0x005C (92) | offset to field `measurement` (id: 21)
+ +0x003A | 0B 00 | VOffset16 | 0x000B (11) | offset to field `anything_type` (id: 22)
+ +0x003C | 60 00 | VOffset16 | 0x0060 (96) | offset to field `anything` (id: 23)
+ +0x003E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `temperature` (id: 24) <defaults to 98.600000> (Float)
+ +0x0040 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `teetotaler` (id: 25) <null> (Obj)
+ +0x0042 | 64 00 | VOffset16 | 0x0064 (100) | offset to field `charlie` (id: 26)
+
+root_table (AnnotatedBinary.Foo):
+ +0x0044 | 3A 00 00 00 | SOffset32 | 0x0000003A (58) Loc: +0x000A | offset to vtable
+ +0x0048 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x004B | 01 | uint8_t | 0x01 (1) | table field `healthy` (Bool)
+ +0x004C | 02 | uint8_t | 0x02 (2) | table field `meal` (Byte)
+ +0x004D | 02 | UType8 | 0x02 (2) | table field `bar_baz_type` (UType)
+ +0x004E | 01 | UType8 | 0x01 (1) | table field `measurement_type` (UType)
+ +0x004F | 01 | UType8 | 0x01 (1) | table field `anything_type` (UType)
+ +0x0050 | D2 04 00 00 | uint32_t | 0x000004D2 (1234) | table field `counter` (Int)
+ +0x0054 | 28 02 00 00 | UOffset32 | 0x00000228 (552) Loc: +0x027C | ERROR: offset to field `bar`. Invalid offset, points outside the binary.
+ +0x0058 | 01 00 00 00 | uint32_t | 0x00000001 (1) | struct field `AnnotatedBinary.Building.floors` (Int)
+ +0x005C | 02 00 00 00 | uint32_t | 0x00000002 (2) | struct field `AnnotatedBinary.Building.doors` (Int)
+ +0x0060 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | struct field `AnnotatedBinary.Building.windows` (Int)
+ +0x0064 | 0A 00 00 00 | uint32_t | 0x0000000A (10) | array field `AnnotatedBinary.Dimension.values`[0] (Int)
+ +0x0068 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | array field `AnnotatedBinary.Dimension.values`[1] (Int)
+ +0x006C | 14 00 00 00 | uint32_t | 0x00000014 (20) | array field `AnnotatedBinary.Dimension.values`[2] (Int)
+ +0x0070 | 01 | uint8_t | 0x01 (1) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0071 | 02 | uint8_t | 0x02 (2) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0072 | 03 | uint8_t | 0x03 (3) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0073 | 00 | uint8_t[1] | . | padding
+ +0x0074 | C8 01 00 00 | UOffset32 | 0x000001C8 (456) Loc: +0x023C | ERROR: offset to field `name`. Invalid offset, points outside the binary.
+ +0x0078 | 5C 01 00 00 | UOffset32 | 0x0000015C (348) Loc: +0x01D4 | offset to field `bars` (vector)
+ +0x007C | 50 01 00 00 | UOffset32 | 0x00000150 (336) Loc: +0x01CC | offset to field `bar_baz` (union of type `Baz`)
+ +0x0080 | 34 01 00 00 | UOffset32 | 0x00000134 (308) Loc: +0x01B4 | offset to field `accounts` (vector)
+ +0x0084 | 24 01 00 00 | UOffset32 | 0x00000124 (292) Loc: +0x01A8 | offset to field `bob` (string)
+ +0x0088 | 14 01 00 00 | UOffset32 | 0x00000114 (276) Loc: +0x019C | offset to field `alice` (string)
+ +0x008C | 0D 00 00 00 | uint32_t | 0x0000000D (13) | table field `just_i32` (Int)
+ +0x0090 | DC 00 00 00 | UOffset32 | 0x000000DC (220) Loc: +0x016C | offset to field `names` (vector)
+ +0x0094 | A0 00 00 00 | UOffset32 | 0x000000A0 (160) Loc: +0x0134 | offset to field `points_of_interest` (vector)
+ +0x0098 | 94 00 00 00 | UOffset32 | 0x00000094 (148) Loc: +0x012C | offset to field `foobars_type` (vector)
+ +0x009C | 38 00 00 00 | UOffset32 | 0x00000038 (56) Loc: +0x00D4 | offset to field `foobars` (vector)
+ +0x00A0 | 33 00 00 00 | UOffset32 | 0x00000033 (51) Loc: +0x00D3 | offset to field `measurement` (union of type `Tolerance`)
+ +0x00A4 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x00C0 | offset to field `anything` (union of type `Bar`)
+ +0x00A8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00AC | offset to field `charlie` (string)
+
+string (AnnotatedBinary.Foo.charlie):
+ +0x00AC | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x00B0 | 61 6C 69 63 65 | char[5] | alice | string literal
+ +0x00B5 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x00B6 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Bar):
+ +0x00B8 | 08 00 | uint16_t | 0x0008 (8) | size of this vtable
+ +0x00BA | 13 00 | uint16_t | 0x0013 (19) | size of referring table
+ +0x00BC | 08 00 | VOffset16 | 0x0008 (8) | offset to field `a` (id: 0)
+ +0x00BE | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+
+table (AnnotatedBinary.Bar):
+ +0x00C0 | 08 00 00 00 | SOffset32 | 0x00000008 (8) Loc: +0x00B8 | offset to vtable
+ +0x00C4 | 00 80 23 44 | float | 0x44238000 (654) | table field `b` (Float)
+ +0x00C8 | 00 00 00 00 00 10 74 40 | double | 0x4074100000000000 (321) | table field `a` (Double)
+ +0x00D0 | 00 00 00 | uint8_t[3] | ... | padding
+
+union (AnnotatedBinary.Tolerance.measurement):
+ +0x00D3 | 05 | uint8_t | 0x05 (5) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+
+vector (AnnotatedBinary.Foo.foobars):
+ +0x00D4 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x00D8 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x010C | offset to union[0] (`Bar`)
+ +0x00DC | 2C 00 00 00 | UOffset32 | 0x0000002C (44) Loc: +0x0108 | offset to union[1] (`Baz`)
+ +0x00E0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00E4 | offset to union[2] (`Bar`)
+
+table (AnnotatedBinary.Bar):
+ +0x00E4 | D2 FE FF FF | SOffset32 | 0xFFFFFED2 (-302) Loc: +0x0212 | ERROR: offset to vtable. Invalid offset, points outside the binary.
+
+unknown (no known references):
+ +0x00E8 | 00 80 23 44 10 00 00 00 | ?uint8_t[28] | ..#D.... | WARN: nothing refers to this section.
+ +0x00F0 | 00 00 00 00 00 D8 8E 40 | | .......@
+ +0x00F8 | 00 00 00 00 6A FE FF FF | | ....j...
+ +0x0100 | 00 00 00 03 | | ....
+
+vtable (AnnotatedBinary.Baz):
+ +0x0104 | 04 00 | uint16_t | 0x0004 (4) | size of this vtable
+ +0x0106 | 04 00 | uint16_t | 0x0004 (4) | size of referring table
+
+table (AnnotatedBinary.Baz):
+ +0x0108 | 04 00 00 00 | SOffset32 | 0x00000004 (4) Loc: +0x0104 | offset to vtable
+
+table (AnnotatedBinary.Bar):
+ +0x010C | FA FE FF FF | SOffset32 | 0xFFFFFEFA (-262) Loc: +0x0212 | ERROR: offset to vtable. Invalid offset, points outside the binary.
+
+unknown (no known references):
+ +0x0110 | 00 00 E4 43 10 00 00 00 | ?uint8_t[28] | ...C.... | WARN: nothing refers to this section.
+ +0x0118 | 00 00 00 00 00 C0 5E 40 | | ......^@
+ +0x0120 | 00 00 00 00 92 FE FF FF | | ........
+ +0x0128 | 00 00 00 01 | | ....
+
+vector (AnnotatedBinary.Foo.foobars_type):
+ +0x012C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0130 | 01 | UType8 | 0x01 (1) | value[0]
+ +0x0131 | 02 | UType8 | 0x02 (2) | value[1]
+ +0x0132 | 01 | UType8 | 0x01 (1) | value[2]
+
+vector (AnnotatedBinary.Foo.points_of_interest):
+ +0x0134 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0138 | 33 33 33 33 33 A3 45 40 | double | 0x4045A33333333333 (43.275) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0140 | 7E 57 04 FF 5B 87 53 C0 | double | 0xC053875BFF04577E (-78.115) | struct field `AnnotatedBinary.Location.longitude` (Double)
+ +0x0148 | 8D F0 F6 20 04 B6 42 40 | double | 0x4042B60420F6F08D (37.422) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0150 | 9F 77 63 41 61 85 5E C0 | double | 0xC05E85614163779F (-122.084) | struct field `AnnotatedBinary.Location.longitude` (Double)
+ +0x0158 | 8F 35 23 83 DC 35 4B C0 | double | 0xC04B35DC8323358F (-54.4208) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0160 | F6 97 DD 93 87 C5 0A 40 | double | 0x400AC58793DD97F6 (3.34645) | struct field `AnnotatedBinary.Location.longitude` (Double)
+
+padding:
+ +0x0168 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (AnnotatedBinary.Foo.names):
+ +0x016C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0170 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x0190 | offset to string[0]
+ +0x0174 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x0188 | offset to string[1]
+ +0x0178 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x017C | offset to string[2]
+
+string (AnnotatedBinary.Foo.names):
+ +0x017C | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x0180 | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x0187 | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.names):
+ +0x0188 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x018C | 62 6F 62 | char[3] | bob | string literal
+ +0x018F | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.names):
+ +0x0190 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x0194 | 61 6C 69 63 65 | char[5] | alice | string literal
+ +0x0199 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x019A | 00 00 | uint8_t[2] | .. | padding
+
+string (AnnotatedBinary.Foo.alice):
+ +0x019C | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x01A0 | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x01A7 | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.bob):
+ +0x01A8 | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x01AC | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x01B3 | 00 | char | 0x00 (0) | string terminator
+
+vector (AnnotatedBinary.Foo.accounts):
+ +0x01B4 | 09 00 00 00 | uint32_t | 0x00000009 (9) | length of vector (# items)
+ +0x01B8 | 09 00 | uint16_t | 0x0009 (9) | value[0]
+ +0x01BA | 08 00 | uint16_t | 0x0008 (8) | value[1]
+ +0x01BC | 07 00 | uint16_t | 0x0007 (7) | value[2]
+ +0x01BE | 01 00 | uint16_t | 0x0001 (1) | value[3]
+ +0x01C0 | 02 00 | uint16_t | 0x0002 (2) | value[4]
+ +0x01C2 | 03 00 | uint16_t | 0x0003 (3) | value[5]
+ +0x01C4 | 06 00 | uint16_t | 0x0006 (6) | value[6]
+ +0x01C6 | 05 00 | uint16_t | 0x0005 (5) | value[7]
+ +0x01C8 | 04 00 | uint16_t | 0x0004 (4) | value[8]
+
+padding:
+ +0x01CA | 00 00 | uint8_t[2] | .. | padding
+
+table (AnnotatedBinary.Baz):
+ +0x01CC | 3A FF FF FF | SOffset32 | 0xFFFFFF3A (-198) Loc: +0x0292 | ERROR: offset to vtable. Invalid offset, points outside the binary.
+
+unknown (no known references):
+ +0x01D0 | 00 00 00 03 | ?uint8_t[4] | .... | WARN: could be corrupted padding region.
+
+vector (AnnotatedBinary.Foo.bars):
+ +0x01D4 | 02 00 00 00 | uint32_t | 0x00000002 (2) | ERROR: length of vector (# items). Longer than the binary.
+
+unknown (no known references):
+ +0x01D8 | 44 00 00 00 10 00 | ?uint8_t[6] | D..... | WARN: could be corrupted padding region.
diff --git a/tests/annotated_binary/tests/invalid_vector_unions_cut_short.bin b/tests/annotated_binary/tests/invalid_vector_unions_cut_short.bin
new file mode 100644
index 0000000..2823d83
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_vector_unions_cut_short.bin
Binary files differ
diff --git a/tests/annotated_binary/tests/invalid_vtable_field_offset.afb b/tests/annotated_binary/tests/invalid_vtable_field_offset.afb
new file mode 100644
index 0000000..8b786be
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_vtable_field_offset.afb
@@ -0,0 +1,286 @@
+// Annotated Flatbuffer Binary
+//
+// Schema file: annotated_binary.fbs
+// Binary file: tests/invalid_vtable_field_offset.bin
+
+header:
+ +0x0000 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x0044 | offset to root table `AnnotatedBinary.Foo`
+ +0x0004 | 41 4E 4E 4F | char[4] | ANNO | File Identifier
+
+padding:
+ +0x0008 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Foo):
+ +0x000A | 3A 00 | uint16_t | 0x003A (58) | size of this vtable
+ +0x000C | 68 00 | uint16_t | 0x0068 (104) | size of referring table
+ +0x000E | 0C 00 | VOffset16 | 0x000C (12) | offset to field `counter` (id: 0)
+ +0x0010 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `healthy` (id: 1)
+ +0x0012 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `level` (id: 2) <defaults to 99> (Long)
+ +0x0014 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `meal` (id: 3)
+ +0x0016 | FF FF | VOffset16 | 0xFFFF (65535) | ERROR: offset to field `bar` (id: 4). Invalid offset, points outside the binary.
+ +0x0018 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `home` (id: 5)
+ +0x001A | 30 00 | VOffset16 | 0x0030 (48) | offset to field `name` (id: 6)
+ +0x001C | 34 00 | VOffset16 | 0x0034 (52) | offset to field `bars` (id: 7)
+ +0x001E | 09 00 | VOffset16 | 0x0009 (9) | offset to field `bar_baz_type` (id: 8)
+ +0x0020 | 38 00 | VOffset16 | 0x0038 (56) | offset to field `bar_baz` (id: 9)
+ +0x0022 | 3C 00 | VOffset16 | 0x003C (60) | offset to field `accounts` (id: 10)
+ +0x0024 | 40 00 | VOffset16 | 0x0040 (64) | offset to field `bob` (id: 11)
+ +0x0026 | 44 00 | VOffset16 | 0x0044 (68) | offset to field `alice` (id: 12)
+ +0x0028 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `maybe_i32` (id: 13) <defaults to 0> (Int)
+ +0x002A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_i32` (id: 14) <defaults to 42> (Int)
+ +0x002C | 48 00 | VOffset16 | 0x0048 (72) | offset to field `just_i32` (id: 15)
+ +0x002E | 4C 00 | VOffset16 | 0x004C (76) | offset to field `names` (id: 16)
+ +0x0030 | 50 00 | VOffset16 | 0x0050 (80) | offset to field `points_of_interest` (id: 17)
+ +0x0032 | 54 00 | VOffset16 | 0x0054 (84) | offset to field `foobars_type` (id: 18)
+ +0x0034 | 58 00 | VOffset16 | 0x0058 (88) | offset to field `foobars` (id: 19)
+ +0x0036 | 0A 00 | VOffset16 | 0x000A (10) | offset to field `measurement_type` (id: 20)
+ +0x0038 | 5C 00 | VOffset16 | 0x005C (92) | offset to field `measurement` (id: 21)
+ +0x003A | 0B 00 | VOffset16 | 0x000B (11) | offset to field `anything_type` (id: 22)
+ +0x003C | 60 00 | VOffset16 | 0x0060 (96) | offset to field `anything` (id: 23)
+ +0x003E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `temperature` (id: 24) <defaults to 98.600000> (Float)
+ +0x0040 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `teetotaler` (id: 25) <null> (Obj)
+ +0x0042 | 64 00 | VOffset16 | 0x0064 (100) | offset to field `charlie` (id: 26)
+ +0x0042 | 64 00 | VOffset16 | 0x0064 (100) | offset to unknown field (id: 26)
+
+root_table (AnnotatedBinary.Foo):
+ +0x0044 | 3A 00 00 00 | SOffset32 | 0x0000003A (58) Loc: +0x000A | offset to vtable
+ +0x0048 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x004B | 01 | uint8_t | 0x01 (1) | table field `healthy` (Bool)
+ +0x004C | 02 | uint8_t | 0x02 (2) | table field `meal` (Byte)
+ +0x004D | 02 | UType8 | 0x02 (2) | table field `bar_baz_type` (UType)
+ +0x004E | 01 | UType8 | 0x01 (1) | table field `measurement_type` (UType)
+ +0x004F | 01 | UType8 | 0x01 (1) | table field `anything_type` (UType)
+ +0x0050 | D2 04 00 00 | uint32_t | 0x000004D2 (1234) | table field `counter` (Int)
+ +0x0054 | 28 02 00 00 | ?uint8_t[4] | (... | WARN: nothing refers to this section.
+ +0x0058 | 01 00 00 00 | uint32_t | 0x00000001 (1) | struct field `AnnotatedBinary.Building.floors` (Int)
+ +0x005C | 02 00 00 00 | uint32_t | 0x00000002 (2) | struct field `AnnotatedBinary.Building.doors` (Int)
+ +0x0060 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | struct field `AnnotatedBinary.Building.windows` (Int)
+ +0x0064 | 0A 00 00 00 | uint32_t | 0x0000000A (10) | array field `AnnotatedBinary.Dimension.values`[0] (Int)
+ +0x0068 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | array field `AnnotatedBinary.Dimension.values`[1] (Int)
+ +0x006C | 14 00 00 00 | uint32_t | 0x00000014 (20) | array field `AnnotatedBinary.Dimension.values`[2] (Int)
+ +0x0070 | 01 | uint8_t | 0x01 (1) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0071 | 02 | uint8_t | 0x02 (2) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0072 | 03 | uint8_t | 0x03 (3) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0073 | 00 | uint8_t[1] | . | padding
+ +0x0074 | C8 01 00 00 | UOffset32 | 0x000001C8 (456) Loc: +0x023C | offset to field `name` (string)
+ +0x0078 | 5C 01 00 00 | UOffset32 | 0x0000015C (348) Loc: +0x01D4 | offset to field `bars` (vector)
+ +0x007C | 50 01 00 00 | UOffset32 | 0x00000150 (336) Loc: +0x01CC | offset to field `bar_baz` (union of type `Baz`)
+ +0x0080 | 34 01 00 00 | UOffset32 | 0x00000134 (308) Loc: +0x01B4 | offset to field `accounts` (vector)
+ +0x0084 | 24 01 00 00 | UOffset32 | 0x00000124 (292) Loc: +0x01A8 | offset to field `bob` (string)
+ +0x0088 | 14 01 00 00 | UOffset32 | 0x00000114 (276) Loc: +0x019C | offset to field `alice` (string)
+ +0x008C | 0D 00 00 00 | uint32_t | 0x0000000D (13) | table field `just_i32` (Int)
+ +0x0090 | DC 00 00 00 | UOffset32 | 0x000000DC (220) Loc: +0x016C | offset to field `names` (vector)
+ +0x0094 | A0 00 00 00 | UOffset32 | 0x000000A0 (160) Loc: +0x0134 | offset to field `points_of_interest` (vector)
+ +0x0098 | 94 00 00 00 | UOffset32 | 0x00000094 (148) Loc: +0x012C | offset to field `foobars_type` (vector)
+ +0x009C | 38 00 00 00 | UOffset32 | 0x00000038 (56) Loc: +0x00D4 | offset to field `foobars` (vector)
+ +0x00A0 | 33 00 00 00 | UOffset32 | 0x00000033 (51) Loc: +0x00D3 | offset to field `measurement` (union of type `Tolerance`)
+ +0x00A4 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x00C0 | offset to field `anything` (union of type `Bar`)
+ +0x00A8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00AC | offset to field `charlie` (string)
+
+string (AnnotatedBinary.Foo.charlie):
+ +0x00AC | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x00B0 | 61 6C 69 63 65 | char[5] | alice | string literal
+ +0x00B5 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x00B6 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Bar):
+ +0x00B8 | 08 00 | uint16_t | 0x0008 (8) | size of this vtable
+ +0x00BA | 13 00 | uint16_t | 0x0013 (19) | size of referring table
+ +0x00BC | 08 00 | VOffset16 | 0x0008 (8) | offset to field `a` (id: 0)
+ +0x00BE | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+
+table (AnnotatedBinary.Bar):
+ +0x00C0 | 08 00 00 00 | SOffset32 | 0x00000008 (8) Loc: +0x00B8 | offset to vtable
+ +0x00C4 | 00 80 23 44 | float | 0x44238000 (654) | table field `b` (Float)
+ +0x00C8 | 00 00 00 00 00 10 74 40 | double | 0x4074100000000000 (321) | table field `a` (Double)
+ +0x00D0 | 00 00 00 | uint8_t[3] | ... | padding
+
+union (AnnotatedBinary.Tolerance.measurement):
+ +0x00D3 | 05 | uint8_t | 0x05 (5) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+
+vector (AnnotatedBinary.Foo.foobars):
+ +0x00D4 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x00D8 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x010C | offset to union[0] (`Bar`)
+ +0x00DC | 2C 00 00 00 | UOffset32 | 0x0000002C (44) Loc: +0x0108 | offset to union[1] (`Baz`)
+ +0x00E0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00E4 | offset to union[2] (`Bar`)
+
+table (AnnotatedBinary.Bar):
+ +0x00E4 | D2 FE FF FF | SOffset32 | 0xFFFFFED2 (-302) Loc: +0x0212 | offset to vtable
+ +0x00E8 | 00 80 23 44 | float | 0x44238000 (654) | table field `b` (Float)
+ +0x00EC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x00FC | offset to field `c` (table)
+ +0x00F0 | 00 00 00 00 00 D8 8E 40 | double | 0x408ED80000000000 (987) | table field `a` (Double)
+ +0x00F8 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+table (AnnotatedBinary.Baz):
+ +0x00FC | 6A FE FF FF | SOffset32 | 0xFFFFFE6A (-406) Loc: +0x0292 | offset to vtable
+ +0x0100 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x0103 | 03 | uint8_t | 0x03 (3) | table field `meal` (Byte)
+
+vtable (AnnotatedBinary.Baz):
+ +0x0104 | 04 00 | uint16_t | 0x0004 (4) | size of this vtable
+ +0x0106 | 04 00 | uint16_t | 0x0004 (4) | size of referring table
+
+table (AnnotatedBinary.Baz):
+ +0x0108 | 04 00 00 00 | SOffset32 | 0x00000004 (4) Loc: +0x0104 | offset to vtable
+
+table (AnnotatedBinary.Bar):
+ +0x010C | FA FE FF FF | SOffset32 | 0xFFFFFEFA (-262) Loc: +0x0212 | offset to vtable
+ +0x0110 | 00 00 E4 43 | float | 0x43E40000 (456) | table field `b` (Float)
+ +0x0114 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x0124 | offset to field `c` (table)
+ +0x0118 | 00 00 00 00 00 C0 5E 40 | double | 0x405EC00000000000 (123) | table field `a` (Double)
+ +0x0120 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+table (AnnotatedBinary.Baz):
+ +0x0124 | 92 FE FF FF | SOffset32 | 0xFFFFFE92 (-366) Loc: +0x0292 | offset to vtable
+ +0x0128 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x012B | 01 | uint8_t | 0x01 (1) | table field `meal` (Byte)
+
+vector (AnnotatedBinary.Foo.foobars_type):
+ +0x012C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0130 | 01 | UType8 | 0x01 (1) | value[0]
+ +0x0131 | 02 | UType8 | 0x02 (2) | value[1]
+ +0x0132 | 01 | UType8 | 0x01 (1) | value[2]
+
+vector (AnnotatedBinary.Foo.points_of_interest):
+ +0x0134 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0138 | 33 33 33 33 33 A3 45 40 | double | 0x4045A33333333333 (43.275) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0140 | 7E 57 04 FF 5B 87 53 C0 | double | 0xC053875BFF04577E (-78.115) | struct field `AnnotatedBinary.Location.longitude` (Double)
+ +0x0148 | 8D F0 F6 20 04 B6 42 40 | double | 0x4042B60420F6F08D (37.422) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0150 | 9F 77 63 41 61 85 5E C0 | double | 0xC05E85614163779F (-122.084) | struct field `AnnotatedBinary.Location.longitude` (Double)
+ +0x0158 | 8F 35 23 83 DC 35 4B C0 | double | 0xC04B35DC8323358F (-54.4208) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0160 | F6 97 DD 93 87 C5 0A 40 | double | 0x400AC58793DD97F6 (3.34645) | struct field `AnnotatedBinary.Location.longitude` (Double)
+
+padding:
+ +0x0168 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (AnnotatedBinary.Foo.names):
+ +0x016C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0170 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x0190 | offset to string[0]
+ +0x0174 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x0188 | offset to string[1]
+ +0x0178 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x017C | offset to string[2]
+
+string (AnnotatedBinary.Foo.names):
+ +0x017C | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x0180 | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x0187 | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.names):
+ +0x0188 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x018C | 62 6F 62 | char[3] | bob | string literal
+ +0x018F | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.names):
+ +0x0190 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x0194 | 61 6C 69 63 65 | char[5] | alice | string literal
+ +0x0199 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x019A | 00 00 | uint8_t[2] | .. | padding
+
+string (AnnotatedBinary.Foo.alice):
+ +0x019C | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x01A0 | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x01A7 | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.bob):
+ +0x01A8 | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x01AC | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x01B3 | 00 | char | 0x00 (0) | string terminator
+
+vector (AnnotatedBinary.Foo.accounts):
+ +0x01B4 | 09 00 00 00 | uint32_t | 0x00000009 (9) | length of vector (# items)
+ +0x01B8 | 09 00 | uint16_t | 0x0009 (9) | value[0]
+ +0x01BA | 08 00 | uint16_t | 0x0008 (8) | value[1]
+ +0x01BC | 07 00 | uint16_t | 0x0007 (7) | value[2]
+ +0x01BE | 01 00 | uint16_t | 0x0001 (1) | value[3]
+ +0x01C0 | 02 00 | uint16_t | 0x0002 (2) | value[4]
+ +0x01C2 | 03 00 | uint16_t | 0x0003 (3) | value[5]
+ +0x01C4 | 06 00 | uint16_t | 0x0006 (6) | value[6]
+ +0x01C6 | 05 00 | uint16_t | 0x0005 (5) | value[7]
+ +0x01C8 | 04 00 | uint16_t | 0x0004 (4) | value[8]
+
+padding:
+ +0x01CA | 00 00 | uint8_t[2] | .. | padding
+
+table (AnnotatedBinary.Baz):
+ +0x01CC | 3A FF FF FF | SOffset32 | 0xFFFFFF3A (-198) Loc: +0x0292 | offset to vtable
+ +0x01D0 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x01D3 | 03 | uint8_t | 0x03 (3) | table field `meal` (Byte)
+
+vector (AnnotatedBinary.Foo.bars):
+ +0x01D4 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x01D8 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x021C | offset to table[0]
+ +0x01DC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x01EC | offset to table[1]
+
+padding:
+ +0x01E0 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Bar):
+ +0x01E2 | 0A 00 | uint16_t | 0x000A (10) | size of this vtable
+ +0x01E4 | 1A 00 | uint16_t | 0x001A (26) | size of referring table
+ +0x01E6 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `a` (id: 0)
+ +0x01E8 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+ +0x01EA | 08 00 | VOffset16 | 0x0008 (8) | offset to field `c` (id: 2)
+
+table (AnnotatedBinary.Bar):
+ +0x01EC | 0A 00 00 00 | SOffset32 | 0x0000000A (10) Loc: +0x01E2 | offset to vtable
+ +0x01F0 | 00 80 23 44 | float | 0x44238000 (654) | table field `b` (Float)
+ +0x01F4 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x020C | offset to field `c` (table)
+ +0x01F8 | 00 00 00 00 00 D8 8E 40 | double | 0x408ED80000000000 (987) | table field `a` (Double)
+ +0x0200 | 00 00 00 00 00 00 | uint8_t[6] | ...... | padding
+
+vtable (AnnotatedBinary.Baz):
+ +0x0206 | 06 00 | uint16_t | 0x0006 (6) | size of this vtable
+ +0x0208 | 06 00 | uint16_t | 0x0006 (6) | size of referring table
+ +0x020A | 05 00 | VOffset16 | 0x0005 (5) | offset to field `meal` (id: 0)
+
+table (AnnotatedBinary.Baz):
+ +0x020C | 06 00 00 00 | SOffset32 | 0x00000006 (6) Loc: +0x0206 | offset to vtable
+ +0x0210 | 00 | uint8_t[1] | . | padding
+ +0x0211 | 03 | uint8_t | 0x03 (3) | table field `meal` (Byte)
+
+vtable (AnnotatedBinary.Bar):
+ +0x0212 | 0A 00 | uint16_t | 0x000A (10) | size of this vtable
+ +0x0214 | 18 00 | uint16_t | 0x0018 (24) | size of referring table
+ +0x0216 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `a` (id: 0)
+ +0x0218 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+ +0x021A | 08 00 | VOffset16 | 0x0008 (8) | offset to field `c` (id: 2)
+
+table (AnnotatedBinary.Bar):
+ +0x021C | 0A 00 00 00 | SOffset32 | 0x0000000A (10) Loc: +0x0212 | offset to vtable
+ +0x0220 | 00 00 E4 43 | float | 0x43E40000 (456) | table field `b` (Float)
+ +0x0224 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x0234 | offset to field `c` (table)
+ +0x0228 | 00 00 00 00 00 C0 5E 40 | double | 0x405EC00000000000 (123) | table field `a` (Double)
+ +0x0230 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+table (AnnotatedBinary.Baz):
+ +0x0234 | A2 FF FF FF | SOffset32 | 0xFFFFFFA2 (-94) Loc: +0x0292 | offset to vtable
+ +0x0238 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x023B | 01 | uint8_t | 0x01 (1) | table field `meal` (Byte)
+
+string (AnnotatedBinary.Foo.name):
+ +0x023C | 2F 00 00 00 | uint32_t | 0x0000002F (47) | length of string
+ +0x0240 | 54 68 69 73 20 69 73 20 | char[47] | This is | string literal
+ +0x0248 | 61 20 6C 6F 6E 67 20 73 | | a long s
+ +0x0250 | 74 72 69 6E 67 20 74 6F | | tring to
+ +0x0258 | 20 73 68 6F 77 20 68 6F | | show ho
+ +0x0260 | 77 20 69 74 20 62 72 65 | | w it bre
+ +0x0268 | 61 6B 73 20 75 70 2E | | aks up.
+ +0x026F | 00 | char | 0x00 (0) | string terminator
+
+unknown (no known references):
+ +0x0270 | 00 00 0A 00 16 00 0C 00 | ?uint8_t[34] | ........ | WARN: nothing refers to this section.
+ +0x0278 | 04 00 08 00 0A 00 00 00 | | ........
+ +0x0280 | 65 20 71 49 14 00 00 00 | | e qI....
+ +0x0288 | C9 76 BE 9F 0C 24 FE 40 | | .v...$.@
+ +0x0290 | 00 00 | | ..
+
+vtable (AnnotatedBinary.Baz):
+ +0x0292 | 06 00 | uint16_t | 0x0006 (6) | size of this vtable
+ +0x0294 | 08 00 | uint16_t | 0x0008 (8) | size of referring table
+ +0x0296 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `meal` (id: 0)
+
+unknown (no known references):
+ +0x0298 | 06 00 00 00 00 00 00 01 | ?uint8_t[8] | ........ | WARN: nothing refers to this section.
diff --git a/tests/annotated_binary/tests/invalid_vtable_field_offset.bin b/tests/annotated_binary/tests/invalid_vtable_field_offset.bin
new file mode 100644
index 0000000..e32ce5b
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_vtable_field_offset.bin
Binary files differ
diff --git a/tests/annotated_binary/tests/invalid_vtable_ref_table_size.afb b/tests/annotated_binary/tests/invalid_vtable_ref_table_size.afb
new file mode 100644
index 0000000..5238e9d
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_vtable_ref_table_size.afb
@@ -0,0 +1,360 @@
+// Annotated Flatbuffer Binary
+//
+// Schema file: annotated_binary.fbs
+// Binary file: tests/invalid_vtable_ref_table_size.bin
+
+header:
+ +0x0000 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x0044 | offset to root table `AnnotatedBinary.Foo`
+ +0x0004 | 41 4E 4E 4F | char[4] | ANNO | File Identifier
+
+padding:
+ +0x0008 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Foo):
+ +0x000A | 3A 00 | uint16_t | 0x003A (58) | size of this vtable
+ +0x000C | FF FF | uint16_t | 0xFFFF (65535) | ERROR: size of referring table. Longer than the binary.
+ +0x000E | 0C 00 | VOffset16 | 0x000C (12) | offset to field `counter` (id: 0)
+ +0x0010 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `healthy` (id: 1)
+ +0x0012 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `level` (id: 2) <defaults to 99> (Long)
+ +0x0014 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `meal` (id: 3)
+ +0x0016 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `bar` (id: 4)
+ +0x0018 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `home` (id: 5)
+ +0x001A | 30 00 | VOffset16 | 0x0030 (48) | offset to field `name` (id: 6)
+ +0x001C | 34 00 | VOffset16 | 0x0034 (52) | offset to field `bars` (id: 7)
+ +0x001E | 09 00 | VOffset16 | 0x0009 (9) | offset to field `bar_baz_type` (id: 8)
+ +0x0020 | 38 00 | VOffset16 | 0x0038 (56) | offset to field `bar_baz` (id: 9)
+ +0x0022 | 3C 00 | VOffset16 | 0x003C (60) | offset to field `accounts` (id: 10)
+ +0x0024 | 40 00 | VOffset16 | 0x0040 (64) | offset to field `bob` (id: 11)
+ +0x0026 | 44 00 | VOffset16 | 0x0044 (68) | offset to field `alice` (id: 12)
+ +0x0028 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `maybe_i32` (id: 13) <defaults to 0> (Int)
+ +0x002A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_i32` (id: 14) <defaults to 42> (Int)
+ +0x002C | 48 00 | VOffset16 | 0x0048 (72) | offset to field `just_i32` (id: 15)
+ +0x002E | 4C 00 | VOffset16 | 0x004C (76) | offset to field `names` (id: 16)
+ +0x0030 | 50 00 | VOffset16 | 0x0050 (80) | offset to field `points_of_interest` (id: 17)
+ +0x0032 | 54 00 | VOffset16 | 0x0054 (84) | offset to field `foobars_type` (id: 18)
+ +0x0034 | 58 00 | VOffset16 | 0x0058 (88) | offset to field `foobars` (id: 19)
+ +0x0036 | 0A 00 | VOffset16 | 0x000A (10) | offset to field `measurement_type` (id: 20)
+ +0x0038 | 5C 00 | VOffset16 | 0x005C (92) | offset to field `measurement` (id: 21)
+ +0x003A | 0B 00 | VOffset16 | 0x000B (11) | offset to field `anything_type` (id: 22)
+ +0x003C | 60 00 | VOffset16 | 0x0060 (96) | offset to field `anything` (id: 23)
+ +0x003E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `temperature` (id: 24) <defaults to 98.600000> (Float)
+ +0x0040 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `teetotaler` (id: 25) <null> (Obj)
+ +0x0042 | 64 00 | VOffset16 | 0x0064 (100) | offset to field `charlie` (id: 26)
+
+root_table (AnnotatedBinary.Foo):
+ +0x0044 | 3A 00 00 00 | SOffset32 | 0x0000003A (58) Loc: +0x000A | offset to vtable
+ +0x0048 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x004B | 01 | uint8_t | 0x01 (1) | table field `healthy` (Bool)
+ +0x004C | 02 | uint8_t | 0x02 (2) | table field `meal` (Byte)
+ +0x004D | 02 | UType8 | 0x02 (2) | table field `bar_baz_type` (UType)
+ +0x004E | 01 | UType8 | 0x01 (1) | table field `measurement_type` (UType)
+ +0x004F | 01 | UType8 | 0x01 (1) | table field `anything_type` (UType)
+ +0x0050 | D2 04 00 00 | uint32_t | 0x000004D2 (1234) | table field `counter` (Int)
+ +0x0054 | 28 02 00 00 | UOffset32 | 0x00000228 (552) Loc: +0x027C | offset to field `bar` (table)
+ +0x0058 | 01 00 00 00 | uint32_t | 0x00000001 (1) | struct field `AnnotatedBinary.Building.floors` (Int)
+ +0x005C | 02 00 00 00 | uint32_t | 0x00000002 (2) | struct field `AnnotatedBinary.Building.doors` (Int)
+ +0x0060 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | struct field `AnnotatedBinary.Building.windows` (Int)
+ +0x0064 | 0A 00 00 00 | uint32_t | 0x0000000A (10) | array field `AnnotatedBinary.Dimension.values`[0] (Int)
+ +0x0068 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | array field `AnnotatedBinary.Dimension.values`[1] (Int)
+ +0x006C | 14 00 00 00 | uint32_t | 0x00000014 (20) | array field `AnnotatedBinary.Dimension.values`[2] (Int)
+ +0x0070 | 01 | uint8_t | 0x01 (1) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0071 | 02 | uint8_t | 0x02 (2) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0072 | 03 | uint8_t | 0x03 (3) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0073 | 00 | uint8_t[1] | . | padding
+ +0x0074 | C8 01 00 00 | UOffset32 | 0x000001C8 (456) Loc: +0x023C | offset to field `name` (string)
+ +0x0078 | 5C 01 00 00 | UOffset32 | 0x0000015C (348) Loc: +0x01D4 | offset to field `bars` (vector)
+ +0x007C | 50 01 00 00 | UOffset32 | 0x00000150 (336) Loc: +0x01CC | offset to field `bar_baz` (union of type `Baz`)
+ +0x0080 | 34 01 00 00 | UOffset32 | 0x00000134 (308) Loc: +0x01B4 | offset to field `accounts` (vector)
+ +0x0084 | 24 01 00 00 | UOffset32 | 0x00000124 (292) Loc: +0x01A8 | offset to field `bob` (string)
+ +0x0088 | 14 01 00 00 | UOffset32 | 0x00000114 (276) Loc: +0x019C | offset to field `alice` (string)
+ +0x008C | 0D 00 00 00 | uint32_t | 0x0000000D (13) | table field `just_i32` (Int)
+ +0x0090 | DC 00 00 00 | UOffset32 | 0x000000DC (220) Loc: +0x016C | offset to field `names` (vector)
+ +0x0094 | A0 00 00 00 | UOffset32 | 0x000000A0 (160) Loc: +0x0134 | offset to field `points_of_interest` (vector)
+ +0x0098 | 94 00 00 00 | UOffset32 | 0x00000094 (148) Loc: +0x012C | offset to field `foobars_type` (vector)
+ +0x009C | 38 00 00 00 | UOffset32 | 0x00000038 (56) Loc: +0x00D4 | offset to field `foobars` (vector)
+ +0x00A0 | 33 00 00 00 | UOffset32 | 0x00000033 (51) Loc: +0x00D3 | offset to field `measurement` (union of type `Tolerance`)
+ +0x00A4 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x00C0 | offset to field `anything` (union of type `Bar`)
+ +0x00A8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00AC | offset to field `charlie` (string)
+ +0x00AC | 05 00 00 00 61 6C 69 63 | uint8_t[500] | ....alic | padding
+ +0x00B4 | 65 00 00 00 08 00 13 00 | | e.......
+ +0x00BC | 08 00 04 00 08 00 00 00 | | ........
+ +0x00C4 | 00 80 23 44 00 00 00 00 | | ..#D....
+ +0x00CC | 00 10 74 40 00 00 00 05 | | ..t@....
+ +0x00D4 | 03 00 00 00 34 00 00 00 | | ....4...
+ +0x00DC | 2C 00 00 00 04 00 00 00 | | ,.......
+ +0x00E4 | D2 FE FF FF 00 80 23 44 | | ......#D
+ +0x00EC | 10 00 00 00 00 00 00 00 | | ........
+ +0x00F4 | 00 D8 8E 40 00 00 00 00 | | ...@....
+ +0x00FC | 6A FE FF FF 00 00 00 03 | | j.......
+ +0x0104 | 04 00 04 00 04 00 00 00 | | ........
+ +0x010C | FA FE FF FF 00 00 E4 43 | | .......C
+ +0x0114 | 10 00 00 00 00 00 00 00 | | ........
+ +0x011C | 00 C0 5E 40 00 00 00 00 | | ..^@....
+ +0x0124 | 92 FE FF FF 00 00 00 01 | | ........
+ +0x012C | 03 00 00 00 01 02 01 00 | | ........
+ +0x0134 | 03 00 00 00 33 33 33 33 | | ....3333
+ +0x013C | 33 A3 45 40 7E 57 04 FF | | 3.E@~W..
+ +0x0144 | 5B 87 53 C0 8D F0 F6 20 | | [.S....
+ +0x014C | 04 B6 42 40 9F 77 63 41 | | ..B@.wcA
+ +0x0154 | 61 85 5E C0 8F 35 23 83 | | a.^..5#.
+ +0x015C | DC 35 4B C0 F6 97 DD 93 | | .5K.....
+ +0x0164 | 87 C5 0A 40 00 00 00 00 | | ...@....
+ +0x016C | 03 00 00 00 20 00 00 00 | | .... ...
+ +0x0174 | 14 00 00 00 04 00 00 00 | | ........
+ +0x017C | 07 00 00 00 63 68 61 72 | | ....char
+ +0x0184 | 6C 69 65 00 03 00 00 00 | | lie.....
+ +0x018C | 62 6F 62 00 05 00 00 00 | | bob.....
+ +0x0194 | 61 6C 69 63 65 00 00 00 | | alice...
+ +0x019C | 07 00 00 00 63 68 61 72 | | ....char
+ +0x01A4 | 6C 69 65 00 07 00 00 00 | | lie.....
+ +0x01AC | 63 68 61 72 6C 69 65 00 | | charlie.
+ +0x01B4 | 09 00 00 00 09 00 08 00 | | ........
+ +0x01BC | 07 00 01 00 02 00 03 00 | | ........
+ +0x01C4 | 06 00 05 00 04 00 00 00 | | ........
+ +0x01CC | 3A FF FF FF 00 00 00 03 | | :.......
+ +0x01D4 | 02 00 00 00 44 00 00 00 | | ....D...
+ +0x01DC | 10 00 00 00 00 00 0A 00 | | ........
+ +0x01E4 | 1A 00 0C 00 04 00 08 00 | | ........
+ +0x01EC | 0A 00 00 00 00 80 23 44 | | ......#D
+ +0x01F4 | 18 00 00 00 00 00 00 00 | | ........
+ +0x01FC | 00 D8 8E 40 00 00 00 00 | | ...@....
+ +0x0204 | 00 00 06 00 06 00 05 00 | | ........
+ +0x020C | 06 00 00 00 00 03 0A 00 | | ........
+ +0x0214 | 18 00 0C 00 04 00 08 00 | | ........
+ +0x021C | 0A 00 00 00 00 00 E4 43 | | .......C
+ +0x0224 | 10 00 00 00 00 00 00 00 | | ........
+ +0x022C | 00 C0 5E 40 00 00 00 00 | | ..^@....
+ +0x0234 | A2 FF FF FF 00 00 00 01 | | ........
+ +0x023C | 2F 00 00 00 54 68 69 73 | | /...This
+ +0x0244 | 20 69 73 20 61 20 6C 6F | | is a lo
+ +0x024C | 6E 67 20 73 74 72 69 6E | | ng strin
+ +0x0254 | 67 20 74 6F 20 73 68 6F | | g to sho
+ +0x025C | 77 20 68 6F 77 20 69 74 | | w how it
+ +0x0264 | 20 62 72 65 61 6B 73 20 | | breaks
+ +0x026C | 75 70 2E 00 00 00 0A 00 | | up......
+ +0x0274 | 16 00 0C 00 04 00 08 00 | | ........
+ +0x027C | 0A 00 00 00 65 20 71 49 | | ....e qI
+ +0x0284 | 14 00 00 00 C9 76 BE 9F | | .....v..
+ +0x028C | 0C 24 FE 40 00 00 06 00 | | .$.@....
+ +0x0294 | 08 00 07 00 06 00 00 00 | | ........
+ +0x029C | 00 00 00 01 | | ....
+
+string (AnnotatedBinary.Foo.charlie):
+ +0x00AC | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x00B0 | 61 6C 69 63 65 | char[5] | alice | string literal
+ +0x00B5 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x00B6 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Bar):
+ +0x00B8 | 08 00 | uint16_t | 0x0008 (8) | size of this vtable
+ +0x00BA | 13 00 | uint16_t | 0x0013 (19) | size of referring table
+ +0x00BC | 08 00 | VOffset16 | 0x0008 (8) | offset to field `a` (id: 0)
+ +0x00BE | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+
+table (AnnotatedBinary.Bar):
+ +0x00C0 | 08 00 00 00 | SOffset32 | 0x00000008 (8) Loc: +0x00B8 | offset to vtable
+ +0x00C4 | 00 80 23 44 | float | 0x44238000 (654) | table field `b` (Float)
+ +0x00C8 | 00 00 00 00 00 10 74 40 | double | 0x4074100000000000 (321) | table field `a` (Double)
+ +0x00D0 | 00 00 00 | uint8_t[3] | ... | padding
+
+union (AnnotatedBinary.Tolerance.measurement):
+ +0x00D3 | 05 | uint8_t | 0x05 (5) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+
+vector (AnnotatedBinary.Foo.foobars):
+ +0x00D4 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x00D8 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x010C | offset to union[0] (`Bar`)
+ +0x00DC | 2C 00 00 00 | UOffset32 | 0x0000002C (44) Loc: +0x0108 | offset to union[1] (`Baz`)
+ +0x00E0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00E4 | offset to union[2] (`Bar`)
+
+table (AnnotatedBinary.Bar):
+ +0x00E4 | D2 FE FF FF | SOffset32 | 0xFFFFFED2 (-302) Loc: +0x0212 | offset to vtable
+ +0x00E8 | 00 80 23 44 | float | 0x44238000 (654) | table field `b` (Float)
+ +0x00EC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x00FC | offset to field `c` (table)
+ +0x00F0 | 00 00 00 00 00 D8 8E 40 | double | 0x408ED80000000000 (987) | table field `a` (Double)
+ +0x00F8 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+table (AnnotatedBinary.Baz):
+ +0x00FC | 6A FE FF FF | SOffset32 | 0xFFFFFE6A (-406) Loc: +0x0292 | offset to vtable
+ +0x0100 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x0103 | 03 | uint8_t | 0x03 (3) | table field `meal` (Byte)
+
+vtable (AnnotatedBinary.Baz):
+ +0x0104 | 04 00 | uint16_t | 0x0004 (4) | size of this vtable
+ +0x0106 | 04 00 | uint16_t | 0x0004 (4) | size of referring table
+
+table (AnnotatedBinary.Baz):
+ +0x0108 | 04 00 00 00 | SOffset32 | 0x00000004 (4) Loc: +0x0104 | offset to vtable
+
+table (AnnotatedBinary.Bar):
+ +0x010C | FA FE FF FF | SOffset32 | 0xFFFFFEFA (-262) Loc: +0x0212 | offset to vtable
+ +0x0110 | 00 00 E4 43 | float | 0x43E40000 (456) | table field `b` (Float)
+ +0x0114 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x0124 | offset to field `c` (table)
+ +0x0118 | 00 00 00 00 00 C0 5E 40 | double | 0x405EC00000000000 (123) | table field `a` (Double)
+ +0x0120 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+table (AnnotatedBinary.Baz):
+ +0x0124 | 92 FE FF FF | SOffset32 | 0xFFFFFE92 (-366) Loc: +0x0292 | offset to vtable
+ +0x0128 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x012B | 01 | uint8_t | 0x01 (1) | table field `meal` (Byte)
+
+vector (AnnotatedBinary.Foo.foobars_type):
+ +0x012C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0130 | 01 | UType8 | 0x01 (1) | value[0]
+ +0x0131 | 02 | UType8 | 0x02 (2) | value[1]
+ +0x0132 | 01 | UType8 | 0x01 (1) | value[2]
+
+vector (AnnotatedBinary.Foo.points_of_interest):
+ +0x0134 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0138 | 33 33 33 33 33 A3 45 40 | double | 0x4045A33333333333 (43.275) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0140 | 7E 57 04 FF 5B 87 53 C0 | double | 0xC053875BFF04577E (-78.115) | struct field `AnnotatedBinary.Location.longitude` (Double)
+ +0x0148 | 8D F0 F6 20 04 B6 42 40 | double | 0x4042B60420F6F08D (37.422) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0150 | 9F 77 63 41 61 85 5E C0 | double | 0xC05E85614163779F (-122.084) | struct field `AnnotatedBinary.Location.longitude` (Double)
+ +0x0158 | 8F 35 23 83 DC 35 4B C0 | double | 0xC04B35DC8323358F (-54.4208) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0160 | F6 97 DD 93 87 C5 0A 40 | double | 0x400AC58793DD97F6 (3.34645) | struct field `AnnotatedBinary.Location.longitude` (Double)
+
+padding:
+ +0x0168 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (AnnotatedBinary.Foo.names):
+ +0x016C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0170 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x0190 | offset to string[0]
+ +0x0174 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x0188 | offset to string[1]
+ +0x0178 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x017C | offset to string[2]
+
+string (AnnotatedBinary.Foo.names):
+ +0x017C | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x0180 | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x0187 | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.names):
+ +0x0188 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x018C | 62 6F 62 | char[3] | bob | string literal
+ +0x018F | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.names):
+ +0x0190 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x0194 | 61 6C 69 63 65 | char[5] | alice | string literal
+ +0x0199 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x019A | 00 00 | uint8_t[2] | .. | padding
+
+string (AnnotatedBinary.Foo.alice):
+ +0x019C | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x01A0 | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x01A7 | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.bob):
+ +0x01A8 | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x01AC | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x01B3 | 00 | char | 0x00 (0) | string terminator
+
+vector (AnnotatedBinary.Foo.accounts):
+ +0x01B4 | 09 00 00 00 | uint32_t | 0x00000009 (9) | length of vector (# items)
+ +0x01B8 | 09 00 | uint16_t | 0x0009 (9) | value[0]
+ +0x01BA | 08 00 | uint16_t | 0x0008 (8) | value[1]
+ +0x01BC | 07 00 | uint16_t | 0x0007 (7) | value[2]
+ +0x01BE | 01 00 | uint16_t | 0x0001 (1) | value[3]
+ +0x01C0 | 02 00 | uint16_t | 0x0002 (2) | value[4]
+ +0x01C2 | 03 00 | uint16_t | 0x0003 (3) | value[5]
+ +0x01C4 | 06 00 | uint16_t | 0x0006 (6) | value[6]
+ +0x01C6 | 05 00 | uint16_t | 0x0005 (5) | value[7]
+ +0x01C8 | 04 00 | uint16_t | 0x0004 (4) | value[8]
+
+padding:
+ +0x01CA | 00 00 | uint8_t[2] | .. | padding
+
+table (AnnotatedBinary.Baz):
+ +0x01CC | 3A FF FF FF | SOffset32 | 0xFFFFFF3A (-198) Loc: +0x0292 | offset to vtable
+ +0x01D0 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x01D3 | 03 | uint8_t | 0x03 (3) | table field `meal` (Byte)
+
+vector (AnnotatedBinary.Foo.bars):
+ +0x01D4 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x01D8 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x021C | offset to table[0]
+ +0x01DC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x01EC | offset to table[1]
+
+padding:
+ +0x01E0 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Bar):
+ +0x01E2 | 0A 00 | uint16_t | 0x000A (10) | size of this vtable
+ +0x01E4 | 1A 00 | uint16_t | 0x001A (26) | size of referring table
+ +0x01E6 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `a` (id: 0)
+ +0x01E8 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+ +0x01EA | 08 00 | VOffset16 | 0x0008 (8) | offset to field `c` (id: 2)
+
+table (AnnotatedBinary.Bar):
+ +0x01EC | 0A 00 00 00 | SOffset32 | 0x0000000A (10) Loc: +0x01E2 | offset to vtable
+ +0x01F0 | 00 80 23 44 | float | 0x44238000 (654) | table field `b` (Float)
+ +0x01F4 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x020C | offset to field `c` (table)
+ +0x01F8 | 00 00 00 00 00 D8 8E 40 | double | 0x408ED80000000000 (987) | table field `a` (Double)
+ +0x0200 | 00 00 00 00 00 00 | uint8_t[6] | ...... | padding
+
+vtable (AnnotatedBinary.Baz):
+ +0x0206 | 06 00 | uint16_t | 0x0006 (6) | size of this vtable
+ +0x0208 | 06 00 | uint16_t | 0x0006 (6) | size of referring table
+ +0x020A | 05 00 | VOffset16 | 0x0005 (5) | offset to field `meal` (id: 0)
+
+table (AnnotatedBinary.Baz):
+ +0x020C | 06 00 00 00 | SOffset32 | 0x00000006 (6) Loc: +0x0206 | offset to vtable
+ +0x0210 | 00 | uint8_t[1] | . | padding
+ +0x0211 | 03 | uint8_t | 0x03 (3) | table field `meal` (Byte)
+
+vtable (AnnotatedBinary.Bar):
+ +0x0212 | 0A 00 | uint16_t | 0x000A (10) | size of this vtable
+ +0x0214 | 18 00 | uint16_t | 0x0018 (24) | size of referring table
+ +0x0216 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `a` (id: 0)
+ +0x0218 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+ +0x021A | 08 00 | VOffset16 | 0x0008 (8) | offset to field `c` (id: 2)
+
+table (AnnotatedBinary.Bar):
+ +0x021C | 0A 00 00 00 | SOffset32 | 0x0000000A (10) Loc: +0x0212 | offset to vtable
+ +0x0220 | 00 00 E4 43 | float | 0x43E40000 (456) | table field `b` (Float)
+ +0x0224 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x0234 | offset to field `c` (table)
+ +0x0228 | 00 00 00 00 00 C0 5E 40 | double | 0x405EC00000000000 (123) | table field `a` (Double)
+ +0x0230 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+table (AnnotatedBinary.Baz):
+ +0x0234 | A2 FF FF FF | SOffset32 | 0xFFFFFFA2 (-94) Loc: +0x0292 | offset to vtable
+ +0x0238 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x023B | 01 | uint8_t | 0x01 (1) | table field `meal` (Byte)
+
+string (AnnotatedBinary.Foo.name):
+ +0x023C | 2F 00 00 00 | uint32_t | 0x0000002F (47) | length of string
+ +0x0240 | 54 68 69 73 20 69 73 20 | char[47] | This is | string literal
+ +0x0248 | 61 20 6C 6F 6E 67 20 73 | | a long s
+ +0x0250 | 74 72 69 6E 67 20 74 6F | | tring to
+ +0x0258 | 20 73 68 6F 77 20 68 6F | | show ho
+ +0x0260 | 77 20 69 74 20 62 72 65 | | w it bre
+ +0x0268 | 61 6B 73 20 75 70 2E | | aks up.
+ +0x026F | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x0270 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Bar):
+ +0x0272 | 0A 00 | uint16_t | 0x000A (10) | size of this vtable
+ +0x0274 | 16 00 | uint16_t | 0x0016 (22) | size of referring table
+ +0x0276 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `a` (id: 0)
+ +0x0278 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+ +0x027A | 08 00 | VOffset16 | 0x0008 (8) | offset to field `c` (id: 2)
+
+table (AnnotatedBinary.Bar):
+ +0x027C | 0A 00 00 00 | SOffset32 | 0x0000000A (10) Loc: +0x0272 | offset to vtable
+ +0x0280 | 65 20 71 49 | float | 0x49712065 (987654) | table field `b` (Float)
+ +0x0284 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x0298 | offset to field `c` (table)
+ +0x0288 | C9 76 BE 9F 0C 24 FE 40 | double | 0x40FE240C9FBE76C9 (123457) | table field `a` (Double)
+ +0x0290 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Baz):
+ +0x0292 | 06 00 | uint16_t | 0x0006 (6) | size of this vtable
+ +0x0294 | 08 00 | uint16_t | 0x0008 (8) | size of referring table
+ +0x0296 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `meal` (id: 0)
+
+table (AnnotatedBinary.Baz):
+ +0x0298 | 06 00 00 00 | SOffset32 | 0x00000006 (6) Loc: +0x0292 | offset to vtable
+ +0x029C | 00 00 00 | uint8_t[3] | ... | padding
+ +0x029F | 01 | uint8_t | 0x01 (1) | table field `meal` (Byte)
diff --git a/tests/annotated_binary/tests/invalid_vtable_ref_table_size.bin b/tests/annotated_binary/tests/invalid_vtable_ref_table_size.bin
new file mode 100644
index 0000000..6b50242
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_vtable_ref_table_size.bin
Binary files differ
diff --git a/tests/annotated_binary/tests/invalid_vtable_ref_table_size_short.afb b/tests/annotated_binary/tests/invalid_vtable_ref_table_size_short.afb
new file mode 100644
index 0000000..35eb6a8
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_vtable_ref_table_size_short.afb
@@ -0,0 +1,297 @@
+// Annotated Flatbuffer Binary
+//
+// Schema file: annotated_binary.fbs
+// Binary file: tests/invalid_vtable_ref_table_size_short.bin
+
+header:
+ +0x0000 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x0044 | offset to root table `AnnotatedBinary.Foo`
+ +0x0004 | 41 4E 4E 4F | char[4] | ANNO | File Identifier
+
+padding:
+ +0x0008 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Foo):
+ +0x000A | 3A 00 | uint16_t | 0x003A (58) | size of this vtable
+ +0x000C | 01 00 | uint16_t | 0x0001 (1) | ERROR: size of referring table. Shorter than the minimum length:
+ +0x000E | 0C 00 | VOffset16 | 0x000C (12) | offset to field `counter` (id: 0)
+ +0x0010 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `healthy` (id: 1)
+ +0x0012 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `level` (id: 2) <defaults to 99> (Long)
+ +0x0014 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `meal` (id: 3)
+ +0x0016 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `bar` (id: 4)
+ +0x0018 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `home` (id: 5)
+ +0x001A | 30 00 | VOffset16 | 0x0030 (48) | offset to field `name` (id: 6)
+ +0x001C | 34 00 | VOffset16 | 0x0034 (52) | offset to field `bars` (id: 7)
+ +0x001E | 09 00 | VOffset16 | 0x0009 (9) | offset to field `bar_baz_type` (id: 8)
+ +0x0020 | 38 00 | VOffset16 | 0x0038 (56) | offset to field `bar_baz` (id: 9)
+ +0x0022 | 3C 00 | VOffset16 | 0x003C (60) | offset to field `accounts` (id: 10)
+ +0x0024 | 40 00 | VOffset16 | 0x0040 (64) | offset to field `bob` (id: 11)
+ +0x0026 | 44 00 | VOffset16 | 0x0044 (68) | offset to field `alice` (id: 12)
+ +0x0028 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `maybe_i32` (id: 13) <defaults to 0> (Int)
+ +0x002A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_i32` (id: 14) <defaults to 42> (Int)
+ +0x002C | 48 00 | VOffset16 | 0x0048 (72) | offset to field `just_i32` (id: 15)
+ +0x002E | 4C 00 | VOffset16 | 0x004C (76) | offset to field `names` (id: 16)
+ +0x0030 | 50 00 | VOffset16 | 0x0050 (80) | offset to field `points_of_interest` (id: 17)
+ +0x0032 | 54 00 | VOffset16 | 0x0054 (84) | offset to field `foobars_type` (id: 18)
+ +0x0034 | 58 00 | VOffset16 | 0x0058 (88) | offset to field `foobars` (id: 19)
+ +0x0036 | 0A 00 | VOffset16 | 0x000A (10) | offset to field `measurement_type` (id: 20)
+ +0x0038 | 5C 00 | VOffset16 | 0x005C (92) | offset to field `measurement` (id: 21)
+ +0x003A | 0B 00 | VOffset16 | 0x000B (11) | offset to field `anything_type` (id: 22)
+ +0x003C | 60 00 | VOffset16 | 0x0060 (96) | offset to field `anything` (id: 23)
+ +0x003E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `temperature` (id: 24) <defaults to 98.600000> (Float)
+ +0x0040 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `teetotaler` (id: 25) <null> (Obj)
+ +0x0042 | 64 00 | VOffset16 | 0x0064 (100) | offset to field `charlie` (id: 26)
+
+root_table (AnnotatedBinary.Foo):
+ +0x0044 | 3A 00 00 00 | SOffset32 | 0x0000003A (58) Loc: +0x000A | offset to vtable
+ +0x0048 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x004B | 01 | uint8_t | 0x01 (1) | table field `healthy` (Bool)
+ +0x004C | 02 | uint8_t | 0x02 (2) | table field `meal` (Byte)
+ +0x004D | 02 | UType8 | 0x02 (2) | table field `bar_baz_type` (UType)
+ +0x004E | 01 | UType8 | 0x01 (1) | table field `measurement_type` (UType)
+ +0x004F | 01 | UType8 | 0x01 (1) | table field `anything_type` (UType)
+ +0x0050 | D2 04 00 00 | uint32_t | 0x000004D2 (1234) | table field `counter` (Int)
+ +0x0054 | 28 02 00 00 | UOffset32 | 0x00000228 (552) Loc: +0x027C | offset to field `bar` (table)
+ +0x0058 | 01 00 00 00 | uint32_t | 0x00000001 (1) | struct field `AnnotatedBinary.Building.floors` (Int)
+ +0x005C | 02 00 00 00 | uint32_t | 0x00000002 (2) | struct field `AnnotatedBinary.Building.doors` (Int)
+ +0x0060 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | struct field `AnnotatedBinary.Building.windows` (Int)
+ +0x0064 | 0A 00 00 00 | uint32_t | 0x0000000A (10) | array field `AnnotatedBinary.Dimension.values`[0] (Int)
+ +0x0068 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | array field `AnnotatedBinary.Dimension.values`[1] (Int)
+ +0x006C | 14 00 00 00 | uint32_t | 0x00000014 (20) | array field `AnnotatedBinary.Dimension.values`[2] (Int)
+ +0x0070 | 01 | uint8_t | 0x01 (1) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0071 | 02 | uint8_t | 0x02 (2) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0072 | 03 | uint8_t | 0x03 (3) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+ +0x0073 | 00 | uint8_t[1] | . | padding
+ +0x0074 | C8 01 00 00 | UOffset32 | 0x000001C8 (456) Loc: +0x023C | offset to field `name` (string)
+ +0x0078 | 5C 01 00 00 | UOffset32 | 0x0000015C (348) Loc: +0x01D4 | offset to field `bars` (vector)
+ +0x007C | 50 01 00 00 | UOffset32 | 0x00000150 (336) Loc: +0x01CC | offset to field `bar_baz` (union of type `Baz`)
+ +0x0080 | 34 01 00 00 | UOffset32 | 0x00000134 (308) Loc: +0x01B4 | offset to field `accounts` (vector)
+ +0x0084 | 24 01 00 00 | UOffset32 | 0x00000124 (292) Loc: +0x01A8 | offset to field `bob` (string)
+ +0x0088 | 14 01 00 00 | UOffset32 | 0x00000114 (276) Loc: +0x019C | offset to field `alice` (string)
+ +0x008C | 0D 00 00 00 | uint32_t | 0x0000000D (13) | table field `just_i32` (Int)
+ +0x0090 | DC 00 00 00 | UOffset32 | 0x000000DC (220) Loc: +0x016C | offset to field `names` (vector)
+ +0x0094 | A0 00 00 00 | UOffset32 | 0x000000A0 (160) Loc: +0x0134 | offset to field `points_of_interest` (vector)
+ +0x0098 | 94 00 00 00 | UOffset32 | 0x00000094 (148) Loc: +0x012C | offset to field `foobars_type` (vector)
+ +0x009C | 38 00 00 00 | UOffset32 | 0x00000038 (56) Loc: +0x00D4 | offset to field `foobars` (vector)
+ +0x00A0 | 33 00 00 00 | UOffset32 | 0x00000033 (51) Loc: +0x00D3 | offset to field `measurement` (union of type `Tolerance`)
+ +0x00A4 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x00C0 | offset to field `anything` (union of type `Bar`)
+ +0x00A8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00AC | offset to field `charlie` (string)
+
+string (AnnotatedBinary.Foo.charlie):
+ +0x00AC | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x00B0 | 61 6C 69 63 65 | char[5] | alice | string literal
+ +0x00B5 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x00B6 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Bar):
+ +0x00B8 | 08 00 | uint16_t | 0x0008 (8) | size of this vtable
+ +0x00BA | 13 00 | uint16_t | 0x0013 (19) | size of referring table
+ +0x00BC | 08 00 | VOffset16 | 0x0008 (8) | offset to field `a` (id: 0)
+ +0x00BE | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+
+table (AnnotatedBinary.Bar):
+ +0x00C0 | 08 00 00 00 | SOffset32 | 0x00000008 (8) Loc: +0x00B8 | offset to vtable
+ +0x00C4 | 00 80 23 44 | float | 0x44238000 (654) | table field `b` (Float)
+ +0x00C8 | 00 00 00 00 00 10 74 40 | double | 0x4074100000000000 (321) | table field `a` (Double)
+ +0x00D0 | 00 00 00 | uint8_t[3] | ... | padding
+
+union (AnnotatedBinary.Tolerance.measurement):
+ +0x00D3 | 05 | uint8_t | 0x05 (5) | struct field `AnnotatedBinary.Tolerance.width` (UByte)
+
+vector (AnnotatedBinary.Foo.foobars):
+ +0x00D4 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x00D8 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x010C | offset to union[0] (`Bar`)
+ +0x00DC | 2C 00 00 00 | UOffset32 | 0x0000002C (44) Loc: +0x0108 | offset to union[1] (`Baz`)
+ +0x00E0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00E4 | offset to union[2] (`Bar`)
+
+table (AnnotatedBinary.Bar):
+ +0x00E4 | D2 FE FF FF | SOffset32 | 0xFFFFFED2 (-302) Loc: +0x0212 | offset to vtable
+ +0x00E8 | 00 80 23 44 | float | 0x44238000 (654) | table field `b` (Float)
+ +0x00EC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x00FC | offset to field `c` (table)
+ +0x00F0 | 00 00 00 00 00 D8 8E 40 | double | 0x408ED80000000000 (987) | table field `a` (Double)
+ +0x00F8 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+table (AnnotatedBinary.Baz):
+ +0x00FC | 6A FE FF FF | SOffset32 | 0xFFFFFE6A (-406) Loc: +0x0292 | offset to vtable
+ +0x0100 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x0103 | 03 | uint8_t | 0x03 (3) | table field `meal` (Byte)
+
+vtable (AnnotatedBinary.Baz):
+ +0x0104 | 04 00 | uint16_t | 0x0004 (4) | size of this vtable
+ +0x0106 | 04 00 | uint16_t | 0x0004 (4) | size of referring table
+
+table (AnnotatedBinary.Baz):
+ +0x0108 | 04 00 00 00 | SOffset32 | 0x00000004 (4) Loc: +0x0104 | offset to vtable
+
+table (AnnotatedBinary.Bar):
+ +0x010C | FA FE FF FF | SOffset32 | 0xFFFFFEFA (-262) Loc: +0x0212 | offset to vtable
+ +0x0110 | 00 00 E4 43 | float | 0x43E40000 (456) | table field `b` (Float)
+ +0x0114 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x0124 | offset to field `c` (table)
+ +0x0118 | 00 00 00 00 00 C0 5E 40 | double | 0x405EC00000000000 (123) | table field `a` (Double)
+ +0x0120 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+table (AnnotatedBinary.Baz):
+ +0x0124 | 92 FE FF FF | SOffset32 | 0xFFFFFE92 (-366) Loc: +0x0292 | offset to vtable
+ +0x0128 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x012B | 01 | uint8_t | 0x01 (1) | table field `meal` (Byte)
+
+vector (AnnotatedBinary.Foo.foobars_type):
+ +0x012C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0130 | 01 | UType8 | 0x01 (1) | value[0]
+ +0x0131 | 02 | UType8 | 0x02 (2) | value[1]
+ +0x0132 | 01 | UType8 | 0x01 (1) | value[2]
+
+vector (AnnotatedBinary.Foo.points_of_interest):
+ +0x0134 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0138 | 33 33 33 33 33 A3 45 40 | double | 0x4045A33333333333 (43.275) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0140 | 7E 57 04 FF 5B 87 53 C0 | double | 0xC053875BFF04577E (-78.115) | struct field `AnnotatedBinary.Location.longitude` (Double)
+ +0x0148 | 8D F0 F6 20 04 B6 42 40 | double | 0x4042B60420F6F08D (37.422) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0150 | 9F 77 63 41 61 85 5E C0 | double | 0xC05E85614163779F (-122.084) | struct field `AnnotatedBinary.Location.longitude` (Double)
+ +0x0158 | 8F 35 23 83 DC 35 4B C0 | double | 0xC04B35DC8323358F (-54.4208) | struct field `AnnotatedBinary.Location.latitude` (Double)
+ +0x0160 | F6 97 DD 93 87 C5 0A 40 | double | 0x400AC58793DD97F6 (3.34645) | struct field `AnnotatedBinary.Location.longitude` (Double)
+
+padding:
+ +0x0168 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (AnnotatedBinary.Foo.names):
+ +0x016C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0170 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x0190 | offset to string[0]
+ +0x0174 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x0188 | offset to string[1]
+ +0x0178 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x017C | offset to string[2]
+
+string (AnnotatedBinary.Foo.names):
+ +0x017C | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x0180 | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x0187 | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.names):
+ +0x0188 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x018C | 62 6F 62 | char[3] | bob | string literal
+ +0x018F | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.names):
+ +0x0190 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x0194 | 61 6C 69 63 65 | char[5] | alice | string literal
+ +0x0199 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x019A | 00 00 | uint8_t[2] | .. | padding
+
+string (AnnotatedBinary.Foo.alice):
+ +0x019C | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x01A0 | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x01A7 | 00 | char | 0x00 (0) | string terminator
+
+string (AnnotatedBinary.Foo.bob):
+ +0x01A8 | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x01AC | 63 68 61 72 6C 69 65 | char[7] | charlie | string literal
+ +0x01B3 | 00 | char | 0x00 (0) | string terminator
+
+vector (AnnotatedBinary.Foo.accounts):
+ +0x01B4 | 09 00 00 00 | uint32_t | 0x00000009 (9) | length of vector (# items)
+ +0x01B8 | 09 00 | uint16_t | 0x0009 (9) | value[0]
+ +0x01BA | 08 00 | uint16_t | 0x0008 (8) | value[1]
+ +0x01BC | 07 00 | uint16_t | 0x0007 (7) | value[2]
+ +0x01BE | 01 00 | uint16_t | 0x0001 (1) | value[3]
+ +0x01C0 | 02 00 | uint16_t | 0x0002 (2) | value[4]
+ +0x01C2 | 03 00 | uint16_t | 0x0003 (3) | value[5]
+ +0x01C4 | 06 00 | uint16_t | 0x0006 (6) | value[6]
+ +0x01C6 | 05 00 | uint16_t | 0x0005 (5) | value[7]
+ +0x01C8 | 04 00 | uint16_t | 0x0004 (4) | value[8]
+
+padding:
+ +0x01CA | 00 00 | uint8_t[2] | .. | padding
+
+table (AnnotatedBinary.Baz):
+ +0x01CC | 3A FF FF FF | SOffset32 | 0xFFFFFF3A (-198) Loc: +0x0292 | offset to vtable
+ +0x01D0 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x01D3 | 03 | uint8_t | 0x03 (3) | table field `meal` (Byte)
+
+vector (AnnotatedBinary.Foo.bars):
+ +0x01D4 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x01D8 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x021C | offset to table[0]
+ +0x01DC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x01EC | offset to table[1]
+
+padding:
+ +0x01E0 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Bar):
+ +0x01E2 | 0A 00 | uint16_t | 0x000A (10) | size of this vtable
+ +0x01E4 | 1A 00 | uint16_t | 0x001A (26) | size of referring table
+ +0x01E6 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `a` (id: 0)
+ +0x01E8 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+ +0x01EA | 08 00 | VOffset16 | 0x0008 (8) | offset to field `c` (id: 2)
+
+table (AnnotatedBinary.Bar):
+ +0x01EC | 0A 00 00 00 | SOffset32 | 0x0000000A (10) Loc: +0x01E2 | offset to vtable
+ +0x01F0 | 00 80 23 44 | float | 0x44238000 (654) | table field `b` (Float)
+ +0x01F4 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x020C | offset to field `c` (table)
+ +0x01F8 | 00 00 00 00 00 D8 8E 40 | double | 0x408ED80000000000 (987) | table field `a` (Double)
+ +0x0200 | 00 00 00 00 00 00 | uint8_t[6] | ...... | padding
+
+vtable (AnnotatedBinary.Baz):
+ +0x0206 | 06 00 | uint16_t | 0x0006 (6) | size of this vtable
+ +0x0208 | 06 00 | uint16_t | 0x0006 (6) | size of referring table
+ +0x020A | 05 00 | VOffset16 | 0x0005 (5) | offset to field `meal` (id: 0)
+
+table (AnnotatedBinary.Baz):
+ +0x020C | 06 00 00 00 | SOffset32 | 0x00000006 (6) Loc: +0x0206 | offset to vtable
+ +0x0210 | 00 | uint8_t[1] | . | padding
+ +0x0211 | 03 | uint8_t | 0x03 (3) | table field `meal` (Byte)
+
+vtable (AnnotatedBinary.Bar):
+ +0x0212 | 0A 00 | uint16_t | 0x000A (10) | size of this vtable
+ +0x0214 | 18 00 | uint16_t | 0x0018 (24) | size of referring table
+ +0x0216 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `a` (id: 0)
+ +0x0218 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+ +0x021A | 08 00 | VOffset16 | 0x0008 (8) | offset to field `c` (id: 2)
+
+table (AnnotatedBinary.Bar):
+ +0x021C | 0A 00 00 00 | SOffset32 | 0x0000000A (10) Loc: +0x0212 | offset to vtable
+ +0x0220 | 00 00 E4 43 | float | 0x43E40000 (456) | table field `b` (Float)
+ +0x0224 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x0234 | offset to field `c` (table)
+ +0x0228 | 00 00 00 00 00 C0 5E 40 | double | 0x405EC00000000000 (123) | table field `a` (Double)
+ +0x0230 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+table (AnnotatedBinary.Baz):
+ +0x0234 | A2 FF FF FF | SOffset32 | 0xFFFFFFA2 (-94) Loc: +0x0292 | offset to vtable
+ +0x0238 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x023B | 01 | uint8_t | 0x01 (1) | table field `meal` (Byte)
+
+string (AnnotatedBinary.Foo.name):
+ +0x023C | 2F 00 00 00 | uint32_t | 0x0000002F (47) | length of string
+ +0x0240 | 54 68 69 73 20 69 73 20 | char[47] | This is | string literal
+ +0x0248 | 61 20 6C 6F 6E 67 20 73 | | a long s
+ +0x0250 | 74 72 69 6E 67 20 74 6F | | tring to
+ +0x0258 | 20 73 68 6F 77 20 68 6F | | show ho
+ +0x0260 | 77 20 69 74 20 62 72 65 | | w it bre
+ +0x0268 | 61 6B 73 20 75 70 2E | | aks up.
+ +0x026F | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x0270 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Bar):
+ +0x0272 | 0A 00 | uint16_t | 0x000A (10) | size of this vtable
+ +0x0274 | 16 00 | uint16_t | 0x0016 (22) | size of referring table
+ +0x0276 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `a` (id: 0)
+ +0x0278 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
+ +0x027A | 08 00 | VOffset16 | 0x0008 (8) | offset to field `c` (id: 2)
+
+table (AnnotatedBinary.Bar):
+ +0x027C | 0A 00 00 00 | SOffset32 | 0x0000000A (10) Loc: +0x0272 | offset to vtable
+ +0x0280 | 65 20 71 49 | float | 0x49712065 (987654) | table field `b` (Float)
+ +0x0284 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x0298 | offset to field `c` (table)
+ +0x0288 | C9 76 BE 9F 0C 24 FE 40 | double | 0x40FE240C9FBE76C9 (123457) | table field `a` (Double)
+ +0x0290 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Baz):
+ +0x0292 | 06 00 | uint16_t | 0x0006 (6) | size of this vtable
+ +0x0294 | 08 00 | uint16_t | 0x0008 (8) | size of referring table
+ +0x0296 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `meal` (id: 0)
+
+table (AnnotatedBinary.Baz):
+ +0x0298 | 06 00 00 00 | SOffset32 | 0x00000006 (6) Loc: +0x0292 | offset to vtable
+ +0x029C | 00 00 00 | uint8_t[3] | ... | padding
+ +0x029F | 01 | uint8_t | 0x01 (1) | table field `meal` (Byte)
diff --git a/tests/annotated_binary/tests/invalid_vtable_ref_table_size_short.bin b/tests/annotated_binary/tests/invalid_vtable_ref_table_size_short.bin
new file mode 100644
index 0000000..e1db9b7
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_vtable_ref_table_size_short.bin
Binary files differ
diff --git a/tests/annotated_binary/tests/invalid_vtable_size.afb b/tests/annotated_binary/tests/invalid_vtable_size.afb
new file mode 100644
index 0000000..43d14d5
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_vtable_size.afb
@@ -0,0 +1,99 @@
+// Annotated Flatbuffer Binary
+//
+// Schema file: annotated_binary.fbs
+// Binary file: tests/invalid_vtable_size.bin
+
+header:
+ +0x0000 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x0044 | offset to root table `AnnotatedBinary.Foo`
+ +0x0004 | 41 4E 4E 4F | char[4] | ANNO | File Identifier
+
+padding:
+ +0x0008 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Foo):
+ +0x000A | FF FF | uint16_t | 0xFFFF (65535) | ERROR: size of this vtable. Longer than the binary.
+
+unknown (no known references):
+ +0x000C | 68 00 0C 00 07 00 00 00 | ?uint8_t[660] | h....... | WARN: nothing refers to this section.
+ +0x0014 | 08 00 10 00 14 00 30 00 | | ......0.
+ +0x001C | 34 00 09 00 38 00 3C 00 | | 4...8.<.
+ +0x0024 | 40 00 44 00 00 00 00 00 | | @.D.....
+ +0x002C | 48 00 4C 00 50 00 54 00 | | H.L.P.T.
+ +0x0034 | 58 00 0A 00 5C 00 0B 00 | | X...\...
+ +0x003C | 60 00 00 00 00 00 64 00 | | `.....d.
+ +0x0044 | 3A 00 00 00 00 00 00 01 | | :.......
+ +0x004C | 02 02 01 01 D2 04 00 00 | | ........
+ +0x0054 | 28 02 00 00 01 00 00 00 | | (.......
+ +0x005C | 02 00 00 00 0C 00 00 00 | | ........
+ +0x0064 | 0A 00 00 00 0C 00 00 00 | | ........
+ +0x006C | 14 00 00 00 01 02 03 00 | | ........
+ +0x0074 | C8 01 00 00 5C 01 00 00 | | ....\...
+ +0x007C | 50 01 00 00 34 01 00 00 | | P...4...
+ +0x0084 | 24 01 00 00 14 01 00 00 | | $.......
+ +0x008C | 0D 00 00 00 DC 00 00 00 | | ........
+ +0x0094 | A0 00 00 00 94 00 00 00 | | ........
+ +0x009C | 38 00 00 00 33 00 00 00 | | 8...3...
+ +0x00A4 | 1C 00 00 00 04 00 00 00 | | ........
+ +0x00AC | 05 00 00 00 61 6C 69 63 | | ....alic
+ +0x00B4 | 65 00 00 00 08 00 13 00 | | e.......
+ +0x00BC | 08 00 04 00 08 00 00 00 | | ........
+ +0x00C4 | 00 80 23 44 00 00 00 00 | | ..#D....
+ +0x00CC | 00 10 74 40 00 00 00 05 | | ..t@....
+ +0x00D4 | 03 00 00 00 34 00 00 00 | | ....4...
+ +0x00DC | 2C 00 00 00 04 00 00 00 | | ,.......
+ +0x00E4 | D2 FE FF FF 00 80 23 44 | | ......#D
+ +0x00EC | 10 00 00 00 00 00 00 00 | | ........
+ +0x00F4 | 00 D8 8E 40 00 00 00 00 | | ...@....
+ +0x00FC | 6A FE FF FF 00 00 00 03 | | j.......
+ +0x0104 | 04 00 04 00 04 00 00 00 | | ........
+ +0x010C | FA FE FF FF 00 00 E4 43 | | .......C
+ +0x0114 | 10 00 00 00 00 00 00 00 | | ........
+ +0x011C | 00 C0 5E 40 00 00 00 00 | | ..^@....
+ +0x0124 | 92 FE FF FF 00 00 00 01 | | ........
+ +0x012C | 03 00 00 00 01 02 01 00 | | ........
+ +0x0134 | 03 00 00 00 33 33 33 33 | | ....3333
+ +0x013C | 33 A3 45 40 7E 57 04 FF | | 3.E@~W..
+ +0x0144 | 5B 87 53 C0 8D F0 F6 20 | | [.S....
+ +0x014C | 04 B6 42 40 9F 77 63 41 | | ..B@.wcA
+ +0x0154 | 61 85 5E C0 8F 35 23 83 | | a.^..5#.
+ +0x015C | DC 35 4B C0 F6 97 DD 93 | | .5K.....
+ +0x0164 | 87 C5 0A 40 00 00 00 00 | | ...@....
+ +0x016C | 03 00 00 00 20 00 00 00 | | .... ...
+ +0x0174 | 14 00 00 00 04 00 00 00 | | ........
+ +0x017C | 07 00 00 00 63 68 61 72 | | ....char
+ +0x0184 | 6C 69 65 00 03 00 00 00 | | lie.....
+ +0x018C | 62 6F 62 00 05 00 00 00 | | bob.....
+ +0x0194 | 61 6C 69 63 65 00 00 00 | | alice...
+ +0x019C | 07 00 00 00 63 68 61 72 | | ....char
+ +0x01A4 | 6C 69 65 00 07 00 00 00 | | lie.....
+ +0x01AC | 63 68 61 72 6C 69 65 00 | | charlie.
+ +0x01B4 | 09 00 00 00 09 00 08 00 | | ........
+ +0x01BC | 07 00 01 00 02 00 03 00 | | ........
+ +0x01C4 | 06 00 05 00 04 00 00 00 | | ........
+ +0x01CC | 3A FF FF FF 00 00 00 03 | | :.......
+ +0x01D4 | 02 00 00 00 44 00 00 00 | | ....D...
+ +0x01DC | 10 00 00 00 00 00 0A 00 | | ........
+ +0x01E4 | 1A 00 0C 00 04 00 08 00 | | ........
+ +0x01EC | 0A 00 00 00 00 80 23 44 | | ......#D
+ +0x01F4 | 18 00 00 00 00 00 00 00 | | ........
+ +0x01FC | 00 D8 8E 40 00 00 00 00 | | ...@....
+ +0x0204 | 00 00 06 00 06 00 05 00 | | ........
+ +0x020C | 06 00 00 00 00 03 0A 00 | | ........
+ +0x0214 | 18 00 0C 00 04 00 08 00 | | ........
+ +0x021C | 0A 00 00 00 00 00 E4 43 | | .......C
+ +0x0224 | 10 00 00 00 00 00 00 00 | | ........
+ +0x022C | 00 C0 5E 40 00 00 00 00 | | ..^@....
+ +0x0234 | A2 FF FF FF 00 00 00 01 | | ........
+ +0x023C | 2F 00 00 00 54 68 69 73 | | /...This
+ +0x0244 | 20 69 73 20 61 20 6C 6F | | is a lo
+ +0x024C | 6E 67 20 73 74 72 69 6E | | ng strin
+ +0x0254 | 67 20 74 6F 20 73 68 6F | | g to sho
+ +0x025C | 77 20 68 6F 77 20 69 74 | | w how it
+ +0x0264 | 20 62 72 65 61 6B 73 20 | | breaks
+ +0x026C | 75 70 2E 00 00 00 0A 00 | | up......
+ +0x0274 | 16 00 0C 00 04 00 08 00 | | ........
+ +0x027C | 0A 00 00 00 65 20 71 49 | | ....e qI
+ +0x0284 | 14 00 00 00 C9 76 BE 9F | | .....v..
+ +0x028C | 0C 24 FE 40 00 00 06 00 | | .$.@....
+ +0x0294 | 08 00 07 00 06 00 00 00 | | ........
+ +0x029C | 00 00 00 01 | | ....
diff --git a/tests/annotated_binary/tests/invalid_vtable_size.bin b/tests/annotated_binary/tests/invalid_vtable_size.bin
new file mode 100644
index 0000000..fdc7e98
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_vtable_size.bin
Binary files differ
diff --git a/tests/annotated_binary/tests/invalid_vtable_size_short.afb b/tests/annotated_binary/tests/invalid_vtable_size_short.afb
new file mode 100644
index 0000000..4ba65f3
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_vtable_size_short.afb
@@ -0,0 +1,99 @@
+// Annotated Flatbuffer Binary
+//
+// Schema file: annotated_binary.fbs
+// Binary file: tests/invalid_vtable_size_short.bin
+
+header:
+ +0x0000 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x0044 | offset to root table `AnnotatedBinary.Foo`
+ +0x0004 | 41 4E 4E 4F | char[4] | ANNO | File Identifier
+
+padding:
+ +0x0008 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (AnnotatedBinary.Foo):
+ +0x000A | 01 00 | uint16_t | 0x0001 (1) | ERROR: size of this vtable. Shorter than the minimum length:
+
+unknown (no known references):
+ +0x000C | 68 00 0C 00 07 00 00 00 | ?uint8_t[660] | h....... | WARN: nothing refers to this section.
+ +0x0014 | 08 00 10 00 14 00 30 00 | | ......0.
+ +0x001C | 34 00 09 00 38 00 3C 00 | | 4...8.<.
+ +0x0024 | 40 00 44 00 00 00 00 00 | | @.D.....
+ +0x002C | 48 00 4C 00 50 00 54 00 | | H.L.P.T.
+ +0x0034 | 58 00 0A 00 5C 00 0B 00 | | X...\...
+ +0x003C | 60 00 00 00 00 00 64 00 | | `.....d.
+ +0x0044 | 3A 00 00 00 00 00 00 01 | | :.......
+ +0x004C | 02 02 01 01 D2 04 00 00 | | ........
+ +0x0054 | 28 02 00 00 01 00 00 00 | | (.......
+ +0x005C | 02 00 00 00 0C 00 00 00 | | ........
+ +0x0064 | 0A 00 00 00 0C 00 00 00 | | ........
+ +0x006C | 14 00 00 00 01 02 03 00 | | ........
+ +0x0074 | C8 01 00 00 5C 01 00 00 | | ....\...
+ +0x007C | 50 01 00 00 34 01 00 00 | | P...4...
+ +0x0084 | 24 01 00 00 14 01 00 00 | | $.......
+ +0x008C | 0D 00 00 00 DC 00 00 00 | | ........
+ +0x0094 | A0 00 00 00 94 00 00 00 | | ........
+ +0x009C | 38 00 00 00 33 00 00 00 | | 8...3...
+ +0x00A4 | 1C 00 00 00 04 00 00 00 | | ........
+ +0x00AC | 05 00 00 00 61 6C 69 63 | | ....alic
+ +0x00B4 | 65 00 00 00 08 00 13 00 | | e.......
+ +0x00BC | 08 00 04 00 08 00 00 00 | | ........
+ +0x00C4 | 00 80 23 44 00 00 00 00 | | ..#D....
+ +0x00CC | 00 10 74 40 00 00 00 05 | | ..t@....
+ +0x00D4 | 03 00 00 00 34 00 00 00 | | ....4...
+ +0x00DC | 2C 00 00 00 04 00 00 00 | | ,.......
+ +0x00E4 | D2 FE FF FF 00 80 23 44 | | ......#D
+ +0x00EC | 10 00 00 00 00 00 00 00 | | ........
+ +0x00F4 | 00 D8 8E 40 00 00 00 00 | | ...@....
+ +0x00FC | 6A FE FF FF 00 00 00 03 | | j.......
+ +0x0104 | 04 00 04 00 04 00 00 00 | | ........
+ +0x010C | FA FE FF FF 00 00 E4 43 | | .......C
+ +0x0114 | 10 00 00 00 00 00 00 00 | | ........
+ +0x011C | 00 C0 5E 40 00 00 00 00 | | ..^@....
+ +0x0124 | 92 FE FF FF 00 00 00 01 | | ........
+ +0x012C | 03 00 00 00 01 02 01 00 | | ........
+ +0x0134 | 03 00 00 00 33 33 33 33 | | ....3333
+ +0x013C | 33 A3 45 40 7E 57 04 FF | | 3.E@~W..
+ +0x0144 | 5B 87 53 C0 8D F0 F6 20 | | [.S....
+ +0x014C | 04 B6 42 40 9F 77 63 41 | | ..B@.wcA
+ +0x0154 | 61 85 5E C0 8F 35 23 83 | | a.^..5#.
+ +0x015C | DC 35 4B C0 F6 97 DD 93 | | .5K.....
+ +0x0164 | 87 C5 0A 40 00 00 00 00 | | ...@....
+ +0x016C | 03 00 00 00 20 00 00 00 | | .... ...
+ +0x0174 | 14 00 00 00 04 00 00 00 | | ........
+ +0x017C | 07 00 00 00 63 68 61 72 | | ....char
+ +0x0184 | 6C 69 65 00 03 00 00 00 | | lie.....
+ +0x018C | 62 6F 62 00 05 00 00 00 | | bob.....
+ +0x0194 | 61 6C 69 63 65 00 00 00 | | alice...
+ +0x019C | 07 00 00 00 63 68 61 72 | | ....char
+ +0x01A4 | 6C 69 65 00 07 00 00 00 | | lie.....
+ +0x01AC | 63 68 61 72 6C 69 65 00 | | charlie.
+ +0x01B4 | 09 00 00 00 09 00 08 00 | | ........
+ +0x01BC | 07 00 01 00 02 00 03 00 | | ........
+ +0x01C4 | 06 00 05 00 04 00 00 00 | | ........
+ +0x01CC | 3A FF FF FF 00 00 00 03 | | :.......
+ +0x01D4 | 02 00 00 00 44 00 00 00 | | ....D...
+ +0x01DC | 10 00 00 00 00 00 0A 00 | | ........
+ +0x01E4 | 1A 00 0C 00 04 00 08 00 | | ........
+ +0x01EC | 0A 00 00 00 00 80 23 44 | | ......#D
+ +0x01F4 | 18 00 00 00 00 00 00 00 | | ........
+ +0x01FC | 00 D8 8E 40 00 00 00 00 | | ...@....
+ +0x0204 | 00 00 06 00 06 00 05 00 | | ........
+ +0x020C | 06 00 00 00 00 03 0A 00 | | ........
+ +0x0214 | 18 00 0C 00 04 00 08 00 | | ........
+ +0x021C | 0A 00 00 00 00 00 E4 43 | | .......C
+ +0x0224 | 10 00 00 00 00 00 00 00 | | ........
+ +0x022C | 00 C0 5E 40 00 00 00 00 | | ..^@....
+ +0x0234 | A2 FF FF FF 00 00 00 01 | | ........
+ +0x023C | 2F 00 00 00 54 68 69 73 | | /...This
+ +0x0244 | 20 69 73 20 61 20 6C 6F | | is a lo
+ +0x024C | 6E 67 20 73 74 72 69 6E | | ng strin
+ +0x0254 | 67 20 74 6F 20 73 68 6F | | g to sho
+ +0x025C | 77 20 68 6F 77 20 69 74 | | w how it
+ +0x0264 | 20 62 72 65 61 6B 73 20 | | breaks
+ +0x026C | 75 70 2E 00 00 00 0A 00 | | up......
+ +0x0274 | 16 00 0C 00 04 00 08 00 | | ........
+ +0x027C | 0A 00 00 00 65 20 71 49 | | ....e qI
+ +0x0284 | 14 00 00 00 C9 76 BE 9F | | .....v..
+ +0x028C | 0C 24 FE 40 00 00 06 00 | | .$.@....
+ +0x0294 | 08 00 07 00 06 00 00 00 | | ........
+ +0x029C | 00 00 00 01 | | ....
diff --git a/tests/annotated_binary/tests/invalid_vtable_size_short.bin b/tests/annotated_binary/tests/invalid_vtable_size_short.bin
new file mode 100644
index 0000000..435bd74
--- /dev/null
+++ b/tests/annotated_binary/tests/invalid_vtable_size_short.bin
Binary files differ
diff --git a/tests/arrays_test/mod.rs b/tests/arrays_test/mod.rs
index 83782dc..5a649d5 100644
--- a/tests/arrays_test/mod.rs
+++ b/tests/arrays_test/mod.rs
@@ -1,4 +1,5 @@
// Automatically generated by the Flatbuffers compiler. Do not modify.
+// @generated
pub mod my_game {
use super::*;
pub mod example {
diff --git a/tests/arrays_test/my_game/example/array_struct_generated.rs b/tests/arrays_test/my_game/example/array_struct_generated.rs
index dea3655..bf41696 100644
--- a/tests/arrays_test/my_game/example/array_struct_generated.rs
+++ b/tests/arrays_test/my_game/example/array_struct_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
// struct ArrayStruct, aligned to 8
@@ -13,8 +18,8 @@
Self([0; 160])
}
}
-impl std::fmt::Debug for ArrayStruct {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+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())
@@ -47,7 +52,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(self as *const ArrayStruct as *const u8, Self::size())
+ ::core::slice::from_raw_parts(self as *const ArrayStruct as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
@@ -58,7 +63,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(*self as *const ArrayStruct as *const u8, Self::size())
+ ::core::slice::from_raw_parts(*self as *const ArrayStruct as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
@@ -158,7 +163,7 @@
pub fn set_d(&mut self, x: &[NestedStruct; 2]) {
unsafe {
- std::ptr::copy(
+ core::ptr::copy(
x.as_ptr() as *const u8,
self.0.as_mut_ptr().add(72),
64,
diff --git a/tests/arrays_test/my_game/example/array_table_generated.rs b/tests/arrays_test/my_game/example/array_table_generated.rs
index f46ac74..bc78fc1 100644
--- a/tests/arrays_test/my_game/example/array_table_generated.rs
+++ b/tests/arrays_test/my_game/example/array_table_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum ArrayTableOffset {}
@@ -103,8 +108,8 @@
}
}
-impl std::fmt::Debug for ArrayTable<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+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()
diff --git a/tests/arrays_test/my_game/example/nested_struct_generated.rs b/tests/arrays_test/my_game/example/nested_struct_generated.rs
index 48a6b91..337affc 100644
--- a/tests/arrays_test/my_game/example/nested_struct_generated.rs
+++ b/tests/arrays_test/my_game/example/nested_struct_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
// struct NestedStruct, aligned to 8
@@ -13,8 +18,8 @@
Self([0; 32])
}
}
-impl std::fmt::Debug for NestedStruct {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+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())
@@ -45,7 +50,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(self as *const NestedStruct as *const u8, Self::size())
+ ::core::slice::from_raw_parts(self as *const NestedStruct as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
@@ -56,7 +61,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(*self as *const NestedStruct as *const u8, Self::size())
+ ::core::slice::from_raw_parts(*self as *const NestedStruct as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
@@ -129,7 +134,7 @@
pub fn set_c(&mut self, x: &[TestEnum; 2]) {
unsafe {
- std::ptr::copy(
+ core::ptr::copy(
x.as_ptr() as *const u8,
self.0.as_mut_ptr().add(9),
2,
diff --git a/tests/arrays_test/my_game/example/test_enum_generated.rs b/tests/arrays_test/my_game/example/test_enum_generated.rs
index 6dcc1cb..5252133 100644
--- a/tests/arrays_test/my_game/example/test_enum_generated.rs
+++ b/tests/arrays_test/my_game/example/test_enum_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -42,8 +47,8 @@
}
}
}
-impl std::fmt::Debug for TestEnum {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+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 {
diff --git a/tests/arrays_test_generated.h b/tests/arrays_test_generated.h
index 1300b92..090f464 100644
--- a/tests/arrays_test_generated.h
+++ b/tests/arrays_test_generated.h
@@ -6,6 +6,13 @@
#include "flatbuffers/flatbuffers.h"
+// Ensure the included flatbuffers.h is the same version as when this file was
+// generated, otherwise it may not be compatible.
+static_assert(FLATBUFFERS_VERSION_MAJOR == 2 &&
+ FLATBUFFERS_VERSION_MINOR == 0 &&
+ FLATBUFFERS_VERSION_REVISION == 8,
+ "Non-compatible flatbuffers version included");
+
namespace MyGame {
namespace Example {
@@ -364,7 +371,7 @@
(void)_rehasher;
(void)_o;
struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const ArrayTableT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
- auto _a = _o->a ? _o->a.get() : 0;
+ auto _a = _o->a ? _o->a.get() : nullptr;
return MyGame::Example::CreateArrayTable(
_fbb,
_a);
diff --git a/tests/cpp17/generated_cpp17/monster_test_generated.h b/tests/cpp17/generated_cpp17/monster_test_generated.h
index 442ba50..be27b45 100644
--- a/tests/cpp17/generated_cpp17/monster_test_generated.h
+++ b/tests/cpp17/generated_cpp17/monster_test_generated.h
@@ -6,6 +6,14 @@
#include "flatbuffers/flatbuffers.h"
#include "flatbuffers/flexbuffers.h"
+#include "flatbuffers/flex_flat_util.h"
+
+// Ensure the included flatbuffers.h is the same version as when this file was
+// generated, otherwise it may not be compatible.
+static_assert(FLATBUFFERS_VERSION_MAJOR == 2 &&
+ FLATBUFFERS_VERSION_MINOR == 0 &&
+ FLATBUFFERS_VERSION_REVISION == 8,
+ "Non-compatible flatbuffers version included");
namespace MyGame {
@@ -35,6 +43,8 @@
struct StructOfStructs;
+struct StructOfStructsOfStructs;
+
struct Stat;
struct StatBuilder;
struct StatT;
@@ -73,6 +83,8 @@
inline const flatbuffers::TypeTable *StructOfStructsTypeTable();
+inline const flatbuffers::TypeTable *StructOfStructsOfStructsTypeTable();
+
inline const flatbuffers::TypeTable *StatTypeTable();
inline const flatbuffers::TypeTable *ReferrableTypeTable();
@@ -815,6 +827,47 @@
using FieldType = decltype(std::declval<type>().get_field<Index>());
};
+FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) StructOfStructsOfStructs FLATBUFFERS_FINAL_CLASS {
+ private:
+ MyGame::Example::StructOfStructs a_;
+
+ public:
+ struct Traits;
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return StructOfStructsOfStructsTypeTable();
+ }
+ StructOfStructsOfStructs()
+ : a_() {
+ }
+ StructOfStructsOfStructs(const MyGame::Example::StructOfStructs &_a)
+ : a_(_a) {
+ }
+ const MyGame::Example::StructOfStructs &a() const {
+ return a_;
+ }
+ MyGame::Example::StructOfStructs &mutable_a() {
+ return a_;
+ }
+ template<size_t Index>
+ auto get_field() const {
+ if constexpr (Index == 0) return a();
+ else static_assert(Index != Index, "Invalid Field Index");
+ }
+};
+FLATBUFFERS_STRUCT_END(StructOfStructsOfStructs, 20);
+
+struct StructOfStructsOfStructs::Traits {
+ using type = StructOfStructsOfStructs;
+ static constexpr auto name = "StructOfStructsOfStructs";
+ static constexpr auto fully_qualified_name = "MyGame.Example.StructOfStructsOfStructs";
+ static constexpr size_t fields_number = 1;
+ static constexpr std::array<const char *, fields_number> field_names = {
+ "a"
+ };
+ template<size_t Index>
+ using FieldType = decltype(std::declval<type>().get_field<Index>());
+};
+
} // namespace Example
struct InParentNamespaceT : public flatbuffers::NativeTable {
@@ -2912,55 +2965,48 @@
{ auto _e = color(); _o->color = _e; }
{ auto _e = test_type(); _o->test.type = _e; }
{ auto _e = test(); if (_e) _o->test.value = MyGame::Example::AnyUnion::UnPack(_e, test_type(), _resolver); }
- { auto _e = test4(); if (_e) { _o->test4.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->test4[_i] = *_e->Get(_i); } } }
- { auto _e = testarrayofstring(); if (_e) { _o->testarrayofstring.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofstring[_i] = _e->Get(_i)->str(); } } }
- { auto _e = testarrayoftables(); if (_e) { _o->testarrayoftables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->testarrayoftables[_i]) { _e->Get(_i)->UnPackTo(_o->testarrayoftables[_i].get(), _resolver); } else { _o->testarrayoftables[_i] = std::unique_ptr<MyGame::Example::MonsterT>(_e->Get(_i)->UnPack(_resolver)); }; } } }
- { auto _e = enemy(); if (_e) { if(_o->enemy) { _e->UnPackTo(_o->enemy.get(), _resolver); } else { _o->enemy = std::unique_ptr<MyGame::Example::MonsterT>(_e->UnPack(_resolver)); } } }
+ { auto _e = test4(); if (_e) { _o->test4.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->test4[_i] = *_e->Get(_i); } } else { _o->test4.resize(0); } }
+ { auto _e = testarrayofstring(); if (_e) { _o->testarrayofstring.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofstring[_i] = _e->Get(_i)->str(); } } else { _o->testarrayofstring.resize(0); } }
+ { auto _e = testarrayoftables(); if (_e) { _o->testarrayoftables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->testarrayoftables[_i]) { _e->Get(_i)->UnPackTo(_o->testarrayoftables[_i].get(), _resolver); } else { _o->testarrayoftables[_i] = std::unique_ptr<MyGame::Example::MonsterT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->testarrayoftables.resize(0); } }
+ { auto _e = enemy(); if (_e) { if(_o->enemy) { _e->UnPackTo(_o->enemy.get(), _resolver); } else { _o->enemy = std::unique_ptr<MyGame::Example::MonsterT>(_e->UnPack(_resolver)); } } else if (_o->enemy) { _o->enemy.reset(); } }
{ auto _e = testnestedflatbuffer(); if (_e) { _o->testnestedflatbuffer.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->testnestedflatbuffer.begin()); } }
- { auto _e = testempty(); if (_e) { if(_o->testempty) { _e->UnPackTo(_o->testempty.get(), _resolver); } else { _o->testempty = std::unique_ptr<MyGame::Example::StatT>(_e->UnPack(_resolver)); } } }
+ { auto _e = testempty(); if (_e) { if(_o->testempty) { _e->UnPackTo(_o->testempty.get(), _resolver); } else { _o->testempty = std::unique_ptr<MyGame::Example::StatT>(_e->UnPack(_resolver)); } } else if (_o->testempty) { _o->testempty.reset(); } }
{ auto _e = testbool(); _o->testbool = _e; }
{ auto _e = testhashs32_fnv1(); _o->testhashs32_fnv1 = _e; }
{ auto _e = testhashu32_fnv1(); _o->testhashu32_fnv1 = _e; }
{ auto _e = testhashs64_fnv1(); _o->testhashs64_fnv1 = _e; }
{ auto _e = testhashu64_fnv1(); _o->testhashu64_fnv1 = _e; }
{ auto _e = testhashs32_fnv1a(); _o->testhashs32_fnv1a = _e; }
- { auto _e = testhashu32_fnv1a(); //scalar resolver, naked
-if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->testhashu32_fnv1a), static_cast<flatbuffers::hash_value_t>(_e)); else _o->testhashu32_fnv1a = nullptr; }
+ { auto _e = testhashu32_fnv1a(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->testhashu32_fnv1a), static_cast<flatbuffers::hash_value_t>(_e)); else _o->testhashu32_fnv1a = nullptr; }
{ auto _e = testhashs64_fnv1a(); _o->testhashs64_fnv1a = _e; }
{ auto _e = testhashu64_fnv1a(); _o->testhashu64_fnv1a = _e; }
- { auto _e = testarrayofbools(); if (_e) { _o->testarrayofbools.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofbools[_i] = _e->Get(_i) != 0; } } }
+ { auto _e = testarrayofbools(); if (_e) { _o->testarrayofbools.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofbools[_i] = _e->Get(_i) != 0; } } else { _o->testarrayofbools.resize(0); } }
{ auto _e = testf(); _o->testf = _e; }
{ auto _e = testf2(); _o->testf2 = _e; }
{ auto _e = testf3(); _o->testf3 = _e; }
- { auto _e = testarrayofstring2(); if (_e) { _o->testarrayofstring2.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofstring2[_i] = _e->Get(_i)->str(); } } }
- { auto _e = testarrayofsortedstruct(); if (_e) { _o->testarrayofsortedstruct.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofsortedstruct[_i] = *_e->Get(_i); } } }
+ { auto _e = testarrayofstring2(); if (_e) { _o->testarrayofstring2.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofstring2[_i] = _e->Get(_i)->str(); } } else { _o->testarrayofstring2.resize(0); } }
+ { auto _e = testarrayofsortedstruct(); if (_e) { _o->testarrayofsortedstruct.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofsortedstruct[_i] = *_e->Get(_i); } } else { _o->testarrayofsortedstruct.resize(0); } }
{ auto _e = flex(); if (_e) { _o->flex.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->flex.begin()); } }
- { auto _e = test5(); if (_e) { _o->test5.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->test5[_i] = *_e->Get(_i); } } }
- { auto _e = vector_of_longs(); if (_e) { _o->vector_of_longs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_longs[_i] = _e->Get(_i); } } }
- { auto _e = vector_of_doubles(); if (_e) { _o->vector_of_doubles.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_doubles[_i] = _e->Get(_i); } } }
- { auto _e = parent_namespace_test(); if (_e) { if(_o->parent_namespace_test) { _e->UnPackTo(_o->parent_namespace_test.get(), _resolver); } else { _o->parent_namespace_test = std::unique_ptr<MyGame::InParentNamespaceT>(_e->UnPack(_resolver)); } } }
- { auto _e = vector_of_referrables(); if (_e) { _o->vector_of_referrables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_referrables[_i].get(), _resolver); } else { _o->vector_of_referrables[_i] = std::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } }
- { auto _e = single_weak_reference(); //scalar resolver, naked
-if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->single_weak_reference), static_cast<flatbuffers::hash_value_t>(_e)); else _o->single_weak_reference = nullptr; }
- { auto _e = vector_of_weak_references(); if (_e) { _o->vector_of_weak_references.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { //vector resolver, naked
-if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_weak_references[_i]), static_cast<flatbuffers::hash_value_t>(_e->Get(_i))); else _o->vector_of_weak_references[_i] = nullptr; } } }
- { auto _e = vector_of_strong_referrables(); if (_e) { _o->vector_of_strong_referrables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_strong_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_strong_referrables[_i].get(), _resolver); } else { _o->vector_of_strong_referrables[_i] = std::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } }
- { auto _e = co_owning_reference(); //scalar resolver, naked
-if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->co_owning_reference), static_cast<flatbuffers::hash_value_t>(_e)); else _o->co_owning_reference = nullptr; }
- { auto _e = vector_of_co_owning_references(); if (_e) { _o->vector_of_co_owning_references.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { //vector resolver, default_ptr_type
-if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_co_owning_references[_i]), static_cast<flatbuffers::hash_value_t>(_e->Get(_i)));/* else do nothing */; } } }
- { auto _e = non_owning_reference(); //scalar resolver, naked
-if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->non_owning_reference), static_cast<flatbuffers::hash_value_t>(_e)); else _o->non_owning_reference = nullptr; }
- { auto _e = vector_of_non_owning_references(); if (_e) { _o->vector_of_non_owning_references.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { //vector resolver, naked
-if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_non_owning_references[_i]), static_cast<flatbuffers::hash_value_t>(_e->Get(_i))); else _o->vector_of_non_owning_references[_i] = nullptr; } } }
+ { auto _e = test5(); if (_e) { _o->test5.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->test5[_i] = *_e->Get(_i); } } else { _o->test5.resize(0); } }
+ { auto _e = vector_of_longs(); if (_e) { _o->vector_of_longs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_longs[_i] = _e->Get(_i); } } else { _o->vector_of_longs.resize(0); } }
+ { auto _e = vector_of_doubles(); if (_e) { _o->vector_of_doubles.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_doubles[_i] = _e->Get(_i); } } else { _o->vector_of_doubles.resize(0); } }
+ { auto _e = parent_namespace_test(); if (_e) { if(_o->parent_namespace_test) { _e->UnPackTo(_o->parent_namespace_test.get(), _resolver); } else { _o->parent_namespace_test = std::unique_ptr<MyGame::InParentNamespaceT>(_e->UnPack(_resolver)); } } else if (_o->parent_namespace_test) { _o->parent_namespace_test.reset(); } }
+ { auto _e = vector_of_referrables(); if (_e) { _o->vector_of_referrables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_referrables[_i].get(), _resolver); } else { _o->vector_of_referrables[_i] = std::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->vector_of_referrables.resize(0); } }
+ { auto _e = single_weak_reference(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->single_weak_reference), static_cast<flatbuffers::hash_value_t>(_e)); else _o->single_weak_reference = nullptr; }
+ { auto _e = vector_of_weak_references(); if (_e) { _o->vector_of_weak_references.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { /*vector resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_weak_references[_i]), static_cast<flatbuffers::hash_value_t>(_e->Get(_i))); else _o->vector_of_weak_references[_i] = nullptr; } } else { _o->vector_of_weak_references.resize(0); } }
+ { auto _e = vector_of_strong_referrables(); if (_e) { _o->vector_of_strong_referrables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_strong_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_strong_referrables[_i].get(), _resolver); } else { _o->vector_of_strong_referrables[_i] = std::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->vector_of_strong_referrables.resize(0); } }
+ { auto _e = co_owning_reference(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->co_owning_reference), static_cast<flatbuffers::hash_value_t>(_e)); else _o->co_owning_reference = nullptr; }
+ { auto _e = vector_of_co_owning_references(); if (_e) { _o->vector_of_co_owning_references.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { /*vector resolver, default_ptr_type*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_co_owning_references[_i]), static_cast<flatbuffers::hash_value_t>(_e->Get(_i)));/* else do nothing */; } } else { _o->vector_of_co_owning_references.resize(0); } }
+ { auto _e = non_owning_reference(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->non_owning_reference), static_cast<flatbuffers::hash_value_t>(_e)); else _o->non_owning_reference = nullptr; }
+ { auto _e = vector_of_non_owning_references(); if (_e) { _o->vector_of_non_owning_references.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { /*vector resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_non_owning_references[_i]), static_cast<flatbuffers::hash_value_t>(_e->Get(_i))); else _o->vector_of_non_owning_references[_i] = nullptr; } } else { _o->vector_of_non_owning_references.resize(0); } }
{ auto _e = any_unique_type(); _o->any_unique.type = _e; }
{ auto _e = any_unique(); if (_e) _o->any_unique.value = MyGame::Example::AnyUniqueAliasesUnion::UnPack(_e, any_unique_type(), _resolver); }
{ auto _e = any_ambiguous_type(); _o->any_ambiguous.type = _e; }
{ auto _e = any_ambiguous(); if (_e) _o->any_ambiguous.value = MyGame::Example::AnyAmbiguousAliasesUnion::UnPack(_e, any_ambiguous_type(), _resolver); }
- { auto _e = vector_of_enums(); if (_e) { _o->vector_of_enums.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_enums[_i] = static_cast<MyGame::Example::Color>(_e->Get(_i)); } } }
+ { auto _e = vector_of_enums(); if (_e) { _o->vector_of_enums.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_enums[_i] = static_cast<MyGame::Example::Color>(_e->Get(_i)); } } else { _o->vector_of_enums.resize(0); } }
{ auto _e = signed_enum(); _o->signed_enum = _e; }
{ auto _e = testrequirednestedflatbuffer(); if (_e) { _o->testrequirednestedflatbuffer.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->testrequirednestedflatbuffer.begin()); } }
- { auto _e = scalar_key_sorted_tables(); if (_e) { _o->scalar_key_sorted_tables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->scalar_key_sorted_tables[_i]) { _e->Get(_i)->UnPackTo(_o->scalar_key_sorted_tables[_i].get(), _resolver); } else { _o->scalar_key_sorted_tables[_i] = std::unique_ptr<MyGame::Example::StatT>(_e->Get(_i)->UnPack(_resolver)); }; } } }
+ { auto _e = scalar_key_sorted_tables(); if (_e) { _o->scalar_key_sorted_tables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->scalar_key_sorted_tables[_i]) { _e->Get(_i)->UnPackTo(_o->scalar_key_sorted_tables[_i].get(), _resolver); } else { _o->scalar_key_sorted_tables[_i] = std::unique_ptr<MyGame::Example::StatT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->scalar_key_sorted_tables.resize(0); } }
{ auto _e = native_inline(); if (_e) _o->native_inline = *_e; }
{ auto _e = long_enum_non_enum_default(); _o->long_enum_non_enum_default = _e; }
{ auto _e = long_enum_normal_default(); _o->long_enum_normal_default = _e; }
@@ -2974,7 +3020,7 @@
(void)_rehasher;
(void)_o;
struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const MonsterT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
- auto _pos = _o->pos ? _o->pos.get() : 0;
+ auto _pos = _o->pos ? _o->pos.get() : nullptr;
auto _mana = _o->mana;
auto _hp = _o->hp;
auto _name = _fbb.CreateString(_o->name);
@@ -3104,7 +3150,7 @@
{ auto _e = f32(); _o->f32 = _e; }
{ auto _e = f64(); _o->f64 = _e; }
{ auto _e = v8(); if (_e) { _o->v8.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->v8.begin()); } }
- { auto _e = vf64(); if (_e) { _o->vf64.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vf64[_i] = _e->Get(_i); } } }
+ { auto _e = vf64(); if (_e) { _o->vf64.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vf64[_i] = _e->Get(_i); } } else { _o->vf64.resize(0); } }
}
inline flatbuffers::Offset<TypeAliases> TypeAliases::Pack(flatbuffers::FlatBufferBuilder &_fbb, const TypeAliasesT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
@@ -3737,6 +3783,23 @@
return &tt;
}
+inline const flatbuffers::TypeTable *StructOfStructsOfStructsTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_SEQUENCE, 0, 0 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::StructOfStructsTypeTable
+ };
+ static const int64_t values[] = { 0, 20 };
+ static const char * const names[] = {
+ "a"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_STRUCT, 1, type_codes, type_refs, nullptr, values, names
+ };
+ return &tt;
+}
+
inline const flatbuffers::TypeTable *StatTypeTable() {
static const flatbuffers::TypeCode type_codes[] = {
{ flatbuffers::ET_STRING, 0, -1 },
diff --git a/tests/cpp17/generated_cpp17/optional_scalars_generated.h b/tests/cpp17/generated_cpp17/optional_scalars_generated.h
index 24b5ccd..b4b0625 100644
--- a/tests/cpp17/generated_cpp17/optional_scalars_generated.h
+++ b/tests/cpp17/generated_cpp17/optional_scalars_generated.h
@@ -6,6 +6,13 @@
#include "flatbuffers/flatbuffers.h"
+// Ensure the included flatbuffers.h is the same version as when this file was
+// generated, otherwise it may not be compatible.
+static_assert(FLATBUFFERS_VERSION_MAJOR == 2 &&
+ FLATBUFFERS_VERSION_MINOR == 0 &&
+ FLATBUFFERS_VERSION_REVISION == 8,
+ "Non-compatible flatbuffers version included");
+
namespace optional_scalars {
struct ScalarStuff;
diff --git a/tests/cpp17/generated_cpp17/union_vector_generated.h b/tests/cpp17/generated_cpp17/union_vector_generated.h
index aa0daf8..5d45644 100644
--- a/tests/cpp17/generated_cpp17/union_vector_generated.h
+++ b/tests/cpp17/generated_cpp17/union_vector_generated.h
@@ -6,6 +6,13 @@
#include "flatbuffers/flatbuffers.h"
+// Ensure the included flatbuffers.h is the same version as when this file was
+// generated, otherwise it may not be compatible.
+static_assert(FLATBUFFERS_VERSION_MAJOR == 2 &&
+ FLATBUFFERS_VERSION_MINOR == 0 &&
+ FLATBUFFERS_VERSION_REVISION == 8,
+ "Non-compatible flatbuffers version included");
+
struct Attacker;
struct AttackerBuilder;
struct AttackerT;
@@ -760,8 +767,8 @@
(void)_resolver;
{ auto _e = main_character_type(); _o->main_character.type = _e; }
{ auto _e = main_character(); if (_e) _o->main_character.value = CharacterUnion::UnPack(_e, main_character_type(), _resolver); }
- { auto _e = characters_type(); if (_e) { _o->characters.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->characters[_i].type = static_cast<Character>(_e->Get(_i)); } } }
- { auto _e = characters(); if (_e) { _o->characters.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->characters[_i].value = CharacterUnion::UnPack(_e->Get(_i), characters_type()->GetEnum<Character>(_i), _resolver); } } }
+ { auto _e = characters_type(); if (_e) { _o->characters.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->characters[_i].type = static_cast<Character>(_e->Get(_i)); } } else { _o->characters.resize(0); } }
+ { auto _e = characters(); if (_e) { _o->characters.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->characters[_i].value = CharacterUnion::UnPack(_e->Get(_i), characters_type()->GetEnum<Character>(_i), _resolver); } } else { _o->characters.resize(0); } }
}
inline flatbuffers::Offset<Movie> Movie::Pack(flatbuffers::FlatBufferBuilder &_fbb, const MovieT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
diff --git a/tests/cpp17/test_cpp17.cpp b/tests/cpp17/test_cpp17.cpp
index a17205a..cfba2b6 100644
--- a/tests/cpp17/test_cpp17.cpp
+++ b/tests/cpp17/test_cpp17.cpp
@@ -20,6 +20,7 @@
// This is an experimental feature and could change at any time.
#include "flatbuffers/flatbuffers.h"
+#include "flatbuffers/flex_flat_util.h"
#include "flatbuffers/flexbuffers.h"
#include "flatbuffers/idl.h"
#include "flatbuffers/minireflect.h"
@@ -46,6 +47,7 @@
/*******************************************************************************
** Build some FB objects.
*******************************************************************************/
+namespace {
const Monster *BuildMonster(flatbuffers::FlatBufferBuilder &fbb) {
using ::cpp17::MyGame::Example::Color;
using ::cpp17::MyGame::Example::MonsterBuilder;
@@ -144,6 +146,8 @@
any_unique_type = 0
any_ambiguous_type = 0
signed_enum = -1
+ long_enum_non_enum_default = 0
+ long_enum_normal_default = 2
})";
// Call a generic function that has no specific knowledge of the flatbuffer we
@@ -167,13 +171,13 @@
** Test Traits::FieldType
*******************************************************************************/
using pos_type = Monster::Traits::FieldType<0>;
-static_assert(std::is_same_v<pos_type, const Vec3*>);
+static_assert(std::is_same_v<pos_type, const Vec3 *>);
using mana_type = Monster::Traits::FieldType<1>;
static_assert(std::is_same_v<mana_type, int16_t>);
using name_type = Monster::Traits::FieldType<3>;
-static_assert(std::is_same_v<name_type, const flatbuffers::String*>);
+static_assert(std::is_same_v<name_type, const flatbuffers::String *>);
/*******************************************************************************
** Generic Create Function Test.
@@ -249,6 +253,7 @@
StringifyAnyFlatbuffersTypeTest();
return 0;
}
+} // namespace
int main(int /*argc*/, const char * /*argv*/[]) {
InitTestEngine();
diff --git a/tests/dictionary_lookup.fbs b/tests/dictionary_lookup.fbs
new file mode 100644
index 0000000..45b9dce
--- /dev/null
+++ b/tests/dictionary_lookup.fbs
@@ -0,0 +1,11 @@
+namespace DictionaryLookup;
+
+table LongFloatEntry {
+ key: long (key);
+ value: float;
+}
+
+table LongFloatMap {
+ entries: [LongFloatEntry];
+}
+root_type LongFloatMap;
diff --git a/tests/docker/languages/Dockerfile.testing.swift_5_2 b/tests/docker/languages/Dockerfile.testing.swift_5_2
index b309477..22995d2 100644
--- a/tests/docker/languages/Dockerfile.testing.swift_5_2
+++ b/tests/docker/languages/Dockerfile.testing.swift_5_2
@@ -4,5 +4,5 @@
RUN cp flatc_debian_stretch flatc
WORKDIR /code/tests
RUN swift --version
-WORKDIR /code/tests/FlatBuffers.Test.Swift
+WORKDIR /code/tests/swift/tests/
RUN sh SwiftTest.sh
diff --git a/tests/evolution_test.cpp b/tests/evolution_test.cpp
new file mode 100644
index 0000000..da0fd74
--- /dev/null
+++ b/tests/evolution_test.cpp
@@ -0,0 +1,139 @@
+#include "evolution_test.h"
+
+#include "evolution_test/evolution_v1_generated.h"
+#include "evolution_test/evolution_v2_generated.h"
+#include "flatbuffers/idl.h"
+#include "test_assert.h"
+
+namespace flatbuffers {
+namespace tests {
+
+void EvolutionTest(const std::string &tests_data_path) {
+ // VS10 does not support typed enums, exclude from tests
+#if !defined(_MSC_VER) || _MSC_VER >= 1700
+ const int NUM_VERSIONS = 2;
+ std::string schemas[NUM_VERSIONS];
+ std::string jsonfiles[NUM_VERSIONS];
+ std::vector<uint8_t> binaries[NUM_VERSIONS];
+
+ flatbuffers::IDLOptions idl_opts;
+ idl_opts.lang_to_generate |= flatbuffers::IDLOptions::kBinary;
+ flatbuffers::Parser parser(idl_opts);
+
+ // Load all the schema versions and their associated data.
+ for (int i = 0; i < NUM_VERSIONS; ++i) {
+ std::string schema = tests_data_path + "evolution_test/evolution_v" +
+ flatbuffers::NumToString(i + 1) + ".fbs";
+ TEST_ASSERT(flatbuffers::LoadFile(schema.c_str(), false, &schemas[i]));
+ std::string json = tests_data_path + "evolution_test/evolution_v" +
+ flatbuffers::NumToString(i + 1) + ".json";
+ TEST_ASSERT(flatbuffers::LoadFile(json.c_str(), false, &jsonfiles[i]));
+
+ TEST_ASSERT(parser.Parse(schemas[i].c_str()));
+ TEST_ASSERT(parser.Parse(jsonfiles[i].c_str()));
+
+ auto bufLen = parser.builder_.GetSize();
+ auto buf = parser.builder_.GetBufferPointer();
+ binaries[i].reserve(bufLen);
+ std::copy(buf, buf + bufLen, std::back_inserter(binaries[i]));
+ }
+
+ // Assert that all the verifiers for the different schema versions properly
+ // verify any version data.
+ for (int i = 0; i < NUM_VERSIONS; ++i) {
+ flatbuffers::Verifier verifier(&binaries[i].front(), binaries[i].size());
+ TEST_ASSERT(Evolution::V1::VerifyRootBuffer(verifier));
+ TEST_ASSERT(Evolution::V2::VerifyRootBuffer(verifier));
+ }
+
+ // Test backwards compatibility by reading old data with an evolved schema.
+ auto root_v1_viewed_from_v2 = Evolution::V2::GetRoot(&binaries[0].front());
+ // field 'k' is new in version 2, so it should be null.
+ TEST_ASSERT(nullptr == root_v1_viewed_from_v2->k());
+ // field 'l' is new in version 2 with a default of 56.
+ TEST_EQ(root_v1_viewed_from_v2->l(), 56);
+ // field 'c' of 'TableA' is new in version 2, so it should be null.
+ TEST_ASSERT(nullptr == root_v1_viewed_from_v2->e()->c());
+ // 'TableC' was added to field 'c' union in version 2, so it should be null.
+ TEST_ASSERT(nullptr == root_v1_viewed_from_v2->c_as_TableC());
+ // The field 'c' union should be of type 'TableB' regardless of schema version
+ TEST_ASSERT(root_v1_viewed_from_v2->c_type() == Evolution::V2::Union::TableB);
+ // The field 'f' was renamed to 'ff' in version 2, it should still be
+ // readable.
+ TEST_EQ(root_v1_viewed_from_v2->ff()->a(), 16);
+
+ // Test forwards compatibility by reading new data with an old schema.
+ auto root_v2_viewed_from_v1 = Evolution::V1::GetRoot(&binaries[1].front());
+ // The field 'c' union in version 2 is a new table (index = 3) and should
+ // still be accessible, but not interpretable.
+ TEST_EQ(static_cast<uint8_t>(root_v2_viewed_from_v1->c_type()), 3);
+ TEST_NOTNULL(root_v2_viewed_from_v1->c());
+ // The field 'd' enum in verison 2 has new members and should still be
+ // accessible, but not interpretable.
+ TEST_EQ(static_cast<int8_t>(root_v2_viewed_from_v1->d()), 3);
+ // The field 'a' in version 2 is deprecated and should return the default
+ // value (0) instead of the value stored in the in the buffer (42).
+ TEST_EQ(root_v2_viewed_from_v1->a(), 0);
+ // The field 'ff' was originally named 'f' in version 1, it should still be
+ // readable.
+ TEST_EQ(root_v2_viewed_from_v1->f()->a(), 35);
+#endif
+}
+
+void ConformTest() {
+ flatbuffers::Parser parser;
+ TEST_EQ(parser.Parse("table T { A:int; } enum E:byte { A }"), true);
+
+ auto test_conform = [](flatbuffers::Parser &parser1, const char *test,
+ const char *expected_err) {
+ flatbuffers::Parser parser2;
+ TEST_EQ(parser2.Parse(test), true);
+ auto err = parser2.ConformTo(parser1);
+ TEST_NOTNULL(strstr(err.c_str(), expected_err));
+ };
+
+ test_conform(parser, "table T { A:byte; }", "types differ for field");
+ test_conform(parser, "table T { B:int; A:int; }", "offsets differ for field");
+ test_conform(parser, "table T { A:int = 1; }", "defaults differ for field");
+ test_conform(parser, "table T { B:float; }",
+ "field renamed to different type");
+ test_conform(parser, "enum E:byte { B, A }", "values differ for enum");
+}
+
+void UnionDeprecationTest(const std::string& tests_data_path) {
+ const int NUM_VERSIONS = 2;
+ std::string schemas[NUM_VERSIONS];
+ std::string jsonfiles[NUM_VERSIONS];
+ std::vector<uint8_t> binaries[NUM_VERSIONS];
+
+ flatbuffers::IDLOptions idl_opts;
+ idl_opts.lang_to_generate |= flatbuffers::IDLOptions::kBinary;
+ flatbuffers::Parser parser(idl_opts);
+
+ // Load all the schema versions and their associated data.
+ for (int i = 0; i < NUM_VERSIONS; ++i) {
+ std::string schema = tests_data_path + "evolution_test/evolution_v" +
+ flatbuffers::NumToString(i + 1) + ".fbs";
+ TEST_ASSERT(flatbuffers::LoadFile(schema.c_str(), false, &schemas[i]));
+ std::string json = tests_data_path + "evolution_test/evolution_v" +
+ flatbuffers::NumToString(i + 1) + ".json";
+ TEST_ASSERT(flatbuffers::LoadFile(json.c_str(), false, &jsonfiles[i]));
+
+ TEST_ASSERT(parser.Parse(schemas[i].c_str()));
+ TEST_ASSERT(parser.Parse(jsonfiles[i].c_str()));
+
+ auto bufLen = parser.builder_.GetSize();
+ auto buf = parser.builder_.GetBufferPointer();
+ binaries[i].reserve(bufLen);
+ std::copy(buf, buf + bufLen, std::back_inserter(binaries[i]));
+ }
+
+ auto v2 = parser.LookupStruct("Evolution.V2.Root");
+ TEST_NOTNULL(v2);
+ auto j_type_field = v2->fields.Lookup("j_type");
+ TEST_NOTNULL(j_type_field);
+ TEST_ASSERT(j_type_field->deprecated);
+}
+
+} // namespace tests
+} // namespace flatbuffers
\ No newline at end of file
diff --git a/tests/evolution_test.h b/tests/evolution_test.h
new file mode 100644
index 0000000..3933c3b
--- /dev/null
+++ b/tests/evolution_test.h
@@ -0,0 +1,16 @@
+#ifndef TESTS_EVOLUTION_TEST_H
+#define TESTS_EVOLUTION_TEST_H
+
+#include <string>
+
+namespace flatbuffers {
+namespace tests {
+
+void EvolutionTest(const std::string &tests_data_path);
+void ConformTest();
+void UnionDeprecationTest(const std::string &tests_data_path);
+
+} // namespace tests
+} // namespace flatbuffers
+
+#endif
diff --git a/tests/evolution_test/evolution_v1_generated.h b/tests/evolution_test/evolution_v1_generated.h
index d5ddf8f..31370d8 100644
--- a/tests/evolution_test/evolution_v1_generated.h
+++ b/tests/evolution_test/evolution_v1_generated.h
@@ -6,6 +6,13 @@
#include "flatbuffers/flatbuffers.h"
+// Ensure the included flatbuffers.h is the same version as when this file was
+// generated, otherwise it may not be compatible.
+static_assert(FLATBUFFERS_VERSION_MAJOR == 2 &&
+ FLATBUFFERS_VERSION_MINOR == 0 &&
+ FLATBUFFERS_VERSION_REVISION == 8,
+ "Non-compatible flatbuffers version included");
+
namespace Evolution {
namespace V1 {
diff --git a/tests/evolution_test/evolution_v2_generated.h b/tests/evolution_test/evolution_v2_generated.h
index 2a0efcb..20d019c 100644
--- a/tests/evolution_test/evolution_v2_generated.h
+++ b/tests/evolution_test/evolution_v2_generated.h
@@ -6,6 +6,13 @@
#include "flatbuffers/flatbuffers.h"
+// Ensure the included flatbuffers.h is the same version as when this file was
+// generated, otherwise it may not be compatible.
+static_assert(FLATBUFFERS_VERSION_MAJOR == 2 &&
+ FLATBUFFERS_VERSION_MINOR == 0 &&
+ FLATBUFFERS_VERSION_REVISION == 8,
+ "Non-compatible flatbuffers version included");
+
namespace Evolution {
namespace V2 {
diff --git a/tests/flatc/bar/bar.fbs b/tests/flatc/bar/bar.fbs
new file mode 100644
index 0000000..afd4be9
--- /dev/null
+++ b/tests/flatc/bar/bar.fbs
@@ -0,0 +1,5 @@
+include "baz/baz.fbs";
+
+table Bar {
+ baz:Baz;
+}
\ No newline at end of file
diff --git a/tests/flatc/bar/bar_with_foo.fbs b/tests/flatc/bar/bar_with_foo.fbs
new file mode 100644
index 0000000..d5c0f9c
--- /dev/null
+++ b/tests/flatc/bar/bar_with_foo.fbs
@@ -0,0 +1,6 @@
+include "foo.fbs";
+include "baz/baz.fbs";
+
+table BarWithFoo {
+ foo:Foo;
+}
\ No newline at end of file
diff --git a/tests/flatc/bar/bar_with_ns.fbs b/tests/flatc/bar/bar_with_ns.fbs
new file mode 100644
index 0000000..f5a800d
--- /dev/null
+++ b/tests/flatc/bar/bar_with_ns.fbs
@@ -0,0 +1,14 @@
+include "baz/baz_with_ns.fbs";
+include "baz/baz.fbs";
+
+namespace bar;
+
+table Bar {
+ baz:baz.Baz;
+ baz2:Baz;
+ foo:Foo;
+}
+
+table Foo {
+ a:int;
+}
\ No newline at end of file
diff --git a/tests/flatc/bar/baz/baz.fbs b/tests/flatc/bar/baz/baz.fbs
new file mode 100644
index 0000000..254e980
--- /dev/null
+++ b/tests/flatc/bar/baz/baz.fbs
@@ -0,0 +1,6 @@
+enum Baz : short {
+ None = 0,
+ Red,
+ Green,
+ Blue,
+}
\ No newline at end of file
diff --git a/tests/flatc/bar/baz/baz_with_ns.fbs b/tests/flatc/bar/baz/baz_with_ns.fbs
new file mode 100644
index 0000000..d258413
--- /dev/null
+++ b/tests/flatc/bar/baz/baz_with_ns.fbs
@@ -0,0 +1,8 @@
+namespace baz;
+
+enum Baz : short {
+ None = 0,
+ Red,
+ Green,
+ Blue,
+}
\ No newline at end of file
diff --git a/tests/flatc/flatc_cpp_tests.py b/tests/flatc/flatc_cpp_tests.py
new file mode 100755
index 0000000..72b2e9d
--- /dev/null
+++ b/tests/flatc/flatc_cpp_tests.py
@@ -0,0 +1,254 @@
+# Copyright 2022 Google Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from flatc_test import *
+
+
+class CppTests:
+ def Flatten(self):
+ # Generate just foo with a "flatten" import of bar.
+ flatc(["--cpp", "foo.fbs"])
+
+ # Foo should be generated in place and include bar flatten
+ assert_file_and_contents("foo_generated.h", '#include "bar_generated.h"')
+
+ def FlattenAbsolutePath(self):
+ # Generate just foo with a "flatten" import of bar.
+ flatc(["--cpp", make_absolute("foo.fbs")])
+
+ # Foo should be generated in place and include bar flatten
+ assert_file_and_contents("foo_generated.h", '#include "bar_generated.h"')
+
+ def FlattenSubDirectory(self):
+ # Generate just foo with a "flatten" import of bar.
+ flatc(["--cpp", "bar/bar.fbs"])
+
+ # Bar should be generated in place and include baz
+ assert_file_and_contents("bar_generated.h", '#include "baz_generated.h"')
+
+ def FlattenOutPath(self):
+ # Generate just foo with a "flatten" import of bar.
+ flatc(["--cpp", "-o", ".tmp", "foo.fbs"])
+
+ # Foo should be generated in the out path and include bar flatten to the out path.
+ assert_file_and_contents(".tmp/foo_generated.h", '#include "bar_generated.h"')
+
+ def FlattenOutPathSuperDirectory(self):
+ # Generate just foo with a "flatten" import of bar.
+ flatc(["--cpp", "-o", "../.tmp", "foo.fbs"])
+
+ # Foo should be generated in the out path and include bar flatten to the out path.
+ assert_file_and_contents(
+ "../.tmp/foo_generated.h", '#include "bar_generated.h"'
+ )
+
+ def FlattenOutPathSubDirectory(self):
+ # Generate just foo with a "flatten" import of bar.
+ flatc(["--cpp", "-o", ".tmp", "bar/bar.fbs"])
+
+ # Bar should be generated in the out path and include baz flatten to the out path.
+ assert_file_and_contents(".tmp/bar_generated.h", '#include "baz_generated.h"')
+
+ def KeepPrefix(self):
+ # Generate just foo with the import of bar keeping the prefix of where it is located.
+ flatc(["--cpp", "--keep-prefix", "foo.fbs"])
+
+ assert_file_and_contents("foo_generated.h", '#include "bar/bar_generated.h"')
+
+ def KeepPrefixAbsolutePath(self):
+ # Generate just foo with the import of bar keeping the prefix of where it is located.
+ flatc(["--cpp", "--keep-prefix", make_absolute("foo.fbs")])
+
+ assert_file_and_contents("foo_generated.h", '#include "bar/bar_generated.h"')
+
+ def KeepPrefixSubDirectory(self):
+ # Generate with the import of bar keeping the prefix of where it is located.
+ flatc(["--cpp", "--keep-prefix", "bar/bar.fbs"])
+
+ assert_file_and_contents("bar_generated.h", '#include "baz/baz_generated.h"')
+
+ def KeepPrefixOutPath(self):
+ # Generate just foo with the import of bar keeping the prefix of where it is located.
+ flatc(["--cpp", "--keep-prefix", "-o", ".tmp", "foo.fbs"])
+
+ assert_file_and_contents(
+ ".tmp/foo_generated.h",
+ '#include "bar/bar_generated.h"',
+ )
+
+ def KeepPrefixOutPathSubDirectory(self):
+ # Generate with the import of bar keeping the prefix of where it is located.
+ flatc(["--cpp", "--keep-prefix", "-o", ".tmp", "bar/bar.fbs"])
+
+ assert_file_and_contents(
+ ".tmp/bar_generated.h", '#include "baz/baz_generated.h"'
+ )
+
+ def IncludePrefix(self):
+ # Generate just foo with the import of bar keeping the prefix of where it is located.
+ flatc(["--cpp", "--include-prefix", "test", "foo.fbs"])
+
+ assert_file_and_contents("foo_generated.h", '#include "test/bar_generated.h"')
+
+ def IncludePrefixAbolutePath(self):
+ # Generate just foo with the import of bar keeping the prefix of where it is located.
+ flatc(["--cpp", "--include-prefix", "test", make_absolute("foo.fbs")])
+
+ assert_file_and_contents("foo_generated.h", '#include "test/bar_generated.h"')
+
+ def IncludePrefixSubDirectory(self):
+ # Generate just foo with the import of bar keeping the prefix of where it is located.
+ flatc(["--cpp", "--include-prefix", "test", "bar/bar.fbs"])
+
+ assert_file_and_contents("bar_generated.h", '#include "test/baz_generated.h"')
+
+ def IncludePrefixOutPath(self):
+ # Generate just foo with the import of bar keeping the prefix of where it is located.
+ flatc(["--cpp", "--include-prefix", "test", "-o", ".tmp", "foo.fbs"])
+
+ assert_file_and_contents(
+ ".tmp/foo_generated.h", '#include "test/bar_generated.h"'
+ )
+
+ def IncludePrefixOutPathSubDirectory(self):
+ # Generate just foo with the import of bar keeping the prefix of where it is located.
+ flatc(["--cpp", "--include-prefix", "test", "-o", ".tmp", "bar/bar.fbs"])
+
+ assert_file_and_contents(
+ ".tmp/bar_generated.h", '#include "test/baz_generated.h"'
+ )
+
+ def KeepPrefixIncludePrefix(self):
+ # Generate just foo with the import of bar keeping the prefix of where it is located.
+ flatc(["--cpp", "--keep-prefix", "--include-prefix", "test", "foo.fbs"])
+
+ # The include prefix should come first, with the kept prefix next.
+ assert_file_and_contents(
+ "foo_generated.h", '#include "test/bar/bar_generated.h"'
+ )
+
+ def KeepPrefixIncludePrefixAbsolutePath(self):
+ # Generate just foo with the import of bar keeping the prefix of where it is located.
+ flatc(
+ [
+ "--cpp",
+ "--keep-prefix",
+ "--include-prefix",
+ "test",
+ make_absolute("foo.fbs"),
+ ]
+ )
+
+ # The include prefix should come first, with the kept prefix next.
+ assert_file_and_contents(
+ "foo_generated.h", '#include "test/bar/bar_generated.h"'
+ )
+
+ def KeepPrefixIncludePrefixSubDirectory(self):
+ # Generate just foo with the import of bar keeping the prefix of where it is located.
+ flatc(["--cpp", "--keep-prefix", "--include-prefix", "test", "bar/bar.fbs"])
+
+ # The include prefix should come first, with the kept prefix next.
+ assert_file_and_contents(
+ "bar_generated.h", '#include "test/baz/baz_generated.h"'
+ )
+
+ def KeepPrefixIncludePrefixOutPathSubDirectory(self):
+ # Generate just foo with the import of bar keeping the prefix of where it is located.
+ flatc(
+ [
+ "--cpp",
+ "--keep-prefix",
+ "--include-prefix",
+ "test",
+ "-o",
+ ".tmp",
+ "bar/bar.fbs",
+ ]
+ )
+
+ # The include prefix should come first, with the kept prefix next.
+ assert_file_and_contents(
+ ".tmp/bar_generated.h", '#include "test/baz/baz_generated.h"'
+ )
+
+ def KeepPrefixIncludePrefixOutPathSuperDirectory(self):
+ # Generate just foo with the import of bar keeping the prefix of where it is located.
+ flatc(
+ [
+ "--cpp",
+ "--keep-prefix",
+ "--include-prefix",
+ "test",
+ "-o",
+ "../.tmp",
+ "bar/bar.fbs",
+ ]
+ )
+
+ # The include prefix should come first, with the kept prefix next.
+ assert_file_and_contents(
+ "../.tmp/bar_generated.h", '#include "test/baz/baz_generated.h"'
+ )
+
+ def KeepPrefixIncludePrefixoutPathAbsoluePaths_SuperDirectoryReference(self):
+ # Generate bar_with_foo that references a type in a super directory.
+ flatc(
+ [
+ "--cpp",
+ "--keep-prefix",
+ "--include-prefix",
+ "generated",
+ "-I",
+ str(script_path.absolute()),
+ "-o",
+ str(Path(script_path, ".tmp").absolute()),
+ str(Path(script_path, "bar/bar_with_foo.fbs").absolute()),
+ ]
+ )
+
+ # The include prefix should come first, with the kept prefix next.
+ assert_file_and_contents(
+ ".tmp/bar_with_foo_generated.h",
+ [
+ '#include "generated/baz/baz_generated.h"',
+ '#include "generated/foo_generated.h"',
+ ],
+ )
+
+ def KeepPrefixIncludePrefixoutPath_SuperDirectoryReference(self):
+ # Generate bar_with_foo that references a type in a super directory.
+ flatc(
+ [
+ "--cpp",
+ "--keep-prefix",
+ "--include-prefix",
+ "generated",
+ "-I",
+ "./",
+ "-o",
+ ".tmp",
+ "bar/bar_with_foo.fbs",
+ ]
+ )
+
+ # The include prefix should come first, with the kept prefix next.
+ assert_file_and_contents(
+ ".tmp/bar_with_foo_generated.h",
+ [
+ '#include "generated/baz/baz_generated.h"',
+ '#include "generated/foo_generated.h"',
+ ],
+ unlink=False,
+ )
diff --git a/tests/flatc/flatc_test.py b/tests/flatc/flatc_test.py
new file mode 100755
index 0000000..fcc32c6
--- /dev/null
+++ b/tests/flatc/flatc_test.py
@@ -0,0 +1,127 @@
+# Copyright 2022 Google Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import argparse
+import platform
+import subprocess
+from pathlib import Path
+
+parser = argparse.ArgumentParser()
+parser.add_argument(
+ "--flatc", help="path of the Flat C compiler relative to the root directory"
+)
+
+args = parser.parse_args()
+
+# Get the path where this script is located so we can invoke the script from
+# any directory and have the paths work correctly.
+script_path = Path(__file__).parent.resolve()
+
+# Get the root path as an absolute path, so all derived paths are absolute.
+root_path = script_path.parent.parent.absolute()
+
+# Get the location of the flatc executable, reading from the first command line
+# argument or defaulting to default names.
+flatc_exe = Path(
+ ("flatc" if not platform.system() == "Windows" else "flatc.exe")
+ if not args.flatc
+ else args.flatc
+)
+
+# Find and assert flatc compiler is present.
+if root_path in flatc_exe.parents:
+ flatc_exe = flatc_exe.relative_to(root_path)
+flatc_path = Path(root_path, flatc_exe)
+assert flatc_path.exists(), "Cannot find the flatc compiler " + str(flatc_path)
+
+# Execute the flatc compiler with the specified parameters
+def flatc(options, cwd=script_path):
+ cmd = [str(flatc_path)] + options
+ subprocess.check_call(cmd, cwd=str(cwd))
+
+
+def make_absolute(filename, path=script_path):
+ return str(Path(path, filename).absolute())
+
+
+def assert_file_exists(filename, path=script_path):
+ file = Path(path, filename)
+ assert file.exists(), "could not find file: " + filename
+ return file
+
+
+def assert_file_doesnt_exists(filename, path=script_path):
+ file = Path(path, filename)
+ assert not file.exists(), "file exists but shouldn't: " + filename
+ return file
+
+
+def assert_file_contains(file, needles):
+ with open(file) as file:
+ contents = file.read()
+ for needle in [needles] if isinstance(needles, str) else needles:
+ assert needle in contents, (
+ "coudn't find '" + needle + "' in file: " + str(file)
+ )
+ return file
+
+
+def assert_file_doesnt_contains(file, needles):
+ with open(file) as file:
+ contents = file.read()
+ for needle in [needles] if isinstance(needles, str) else needles:
+ assert needle not in contents, (
+ "Found unexpected '" + needle + "' in file: " + str(file)
+ )
+ return file
+
+
+def assert_file_and_contents(
+ file, needle, doesnt_contain=None, path=script_path, unlink=True
+):
+ assert_file_contains(assert_file_exists(file, path), needle)
+ if doesnt_contain:
+ assert_file_doesnt_contains(assert_file_exists(file, path), doesnt_contain)
+ if unlink:
+ Path(path, file).unlink()
+
+
+def run_all(*modules):
+ failing = 0
+ passing = 0
+ for module in modules:
+ methods = [
+ func
+ for func in dir(module)
+ if callable(getattr(module, func)) and not func.startswith("__")
+ ]
+ module_failing = 0
+ module_passing = 0
+ for method in methods:
+ try:
+ print("{0}.{1}".format(module.__name__, method))
+ getattr(module, method)(module)
+ print(" [PASSED]")
+ module_passing = module_passing + 1
+ except Exception as e:
+ print(" [FAILED]: " + str(e))
+ module_failing = module_failing + 1
+ print(
+ "{0}: {1} of {2} passsed".format(
+ module.__name__, module_passing, module_passing + module_failing
+ )
+ )
+ passing = passing + module_passing
+ failing = failing + module_failing
+ return passing, failing
diff --git a/tests/flatc/flatc_ts_tests.py b/tests/flatc/flatc_ts_tests.py
new file mode 100755
index 0000000..6e444bc
--- /dev/null
+++ b/tests/flatc/flatc_ts_tests.py
@@ -0,0 +1,242 @@
+# Copyright 2022 Google Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from flatc_test import *
+
+
+class TsTests():
+
+ def Base(self):
+ # Generate just foo with no extra arguments
+ flatc(["--ts", "foo.fbs"])
+
+ # Should generate the module that exports both foo and its direct
+ # include, bar.
+ assert_file_and_contents(
+ "foo_generated.ts",
+ [
+ "export { Bar } from './bar.js';",
+ "export { Foo } from './foo.js';",
+ ],
+ )
+
+ # Foo should be generated in place and exports the Foo table.
+ assert_file_and_contents("foo.ts", "export class Foo {")
+
+ # Included files, like bar, should not be generated.
+ assert_file_doesnt_exists("bar.ts")
+
+ def BaseMultipleFiles(self):
+ # Generate both foo and bar with no extra arguments
+ flatc(["--ts", "foo.fbs", "bar/bar.fbs"])
+
+ # Should generate the module that exports both foo and its direct
+ # include, bar.
+ assert_file_and_contents(
+ "foo_generated.ts",
+ [
+ "export { Bar } from './bar.js';",
+ "export { Foo } from './foo.js';",
+ ],
+ )
+
+ # Foo should be generated in place and exports the Foo table.
+ assert_file_and_contents("foo.ts", "export class Foo {")
+
+ # Bar should also be generatd in place and exports the Bar table.
+ assert_file_and_contents("bar.ts", "export class Bar {")
+
+ def BaseWithNamespace(self):
+ # Generate foo with namespacing, with no extra arguments
+ flatc(["--ts", "foo_with_ns.fbs"])
+
+ # Should generate the module that exports both foo in its namespace
+ # directory and its direct include, bar.
+ assert_file_and_contents(
+ "foo_with_ns_generated.ts",
+ [
+ "export { Bar } from './bar/bar.js';",
+ "export { Foo } from './something/foo.js';",
+ ],
+ )
+
+ # Foo should be placed in the namespaced directory. It should export
+ # Foo, and the import of Bar should be relative to its location.
+ assert_file_and_contents(
+ "something/foo.ts",
+ [
+ "export class Foo {",
+ "import { Bar } from '../bar/bar.js';",
+ ],
+ )
+
+ # Included files, like bar, should not be generated.
+ assert_file_doesnt_exists("bar.ts")
+
+ def GenAll(self):
+ # Generate foo with generate all options
+ flatc(["--ts", "--gen-all", "foo.fbs"])
+
+ # Should generate a single file that exports all the generated types.
+ assert_file_and_contents(
+ "foo_generated.ts",
+ [
+ "export { Bar } from './bar.js'",
+ "export { Baz } from './baz.js'",
+ "export { Foo } from './foo.js'",
+ ],
+ )
+
+ # Foo should be generated with an import to Bar and an export of itself.
+ assert_file_and_contents(
+ "foo.ts",
+ [
+ "import { Bar } from './bar.js';",
+ "export class Foo {",
+ ],
+ )
+
+ # Bar should be generated with an import to Baz and an export of itself.
+ assert_file_and_contents(
+ "bar.ts",
+ [
+ "import { Baz } from './baz.js';",
+ "export class Bar {",
+ ],
+ )
+
+ # Baz should be generated with an export of itself.
+ assert_file_and_contents(
+ "baz.ts",
+ [
+ "export enum Baz {",
+ ],
+ )
+
+
+ def FlatFiles(self):
+ # Generate just foo with the flat files option
+ flatc(["--ts", "--ts-flat-files", "foo.fbs"])
+
+ # Should generate a single file that imports bar as a single file, and
+ # exports the Foo table.
+ assert_file_and_contents(
+ "foo_generated.ts",
+ [
+ "import {Bar as Bar} from './bar_generated.js';",
+ "export class Foo {",
+ ],
+ )
+
+ # The root type Foo should not be generated in its own file.
+ assert_file_doesnt_exists("foo.ts")
+
+ def FlatFilesWithNamespace(self):
+ # Generate just foo with the flat files option
+ flatc(["--ts", "--ts-flat-files", "foo_with_ns.fbs"])
+
+ # Should generate a single file that imports bar as a single file, and
+ # exports the Foo table.
+ assert_file_and_contents(
+ "foo_with_ns_generated.ts",
+ [
+ "import {Bar as Bar} from './bar_with_ns_generated.js';",
+ "export class Foo {",
+ ],
+ )
+
+ # The root type Foo should not be generated in its own file.
+ assert_file_doesnt_exists("foo.ts")
+
+ def FlatFilesMultipleFiles(self):
+ # Generate both foo and bar with the flat files option
+ flatc(["--ts", "--ts-flat-files", "foo.fbs", "bar/bar.fbs"])
+
+ # Should generate a single foo file that imports bar as a single file,
+ # and exports the Foo table.
+ assert_file_and_contents(
+ "foo_generated.ts",
+ [
+ "import {Bar as Bar} from './bar_generated.js';",
+ "export class Foo {",
+ ],
+ )
+
+ # Should generate a single bar file that imports bar as a single file,
+ # and exports the Bar table.
+ assert_file_and_contents(
+ "bar_generated.ts",
+ [
+ "import {Baz as Baz} from './baz_generated.js';",
+ "export class Bar {",
+ ],
+ )
+
+ # The types Foo and Bar should not be generated in their own files
+ assert_file_doesnt_exists("foo.ts")
+ assert_file_doesnt_exists("bar.ts")
+
+ def FlatFilesGenAll(self):
+ # Generate foo with all of its dependents with the flat files option
+ flatc(["--ts", "--ts-flat-files", "--gen-all", "foo.fbs"])
+
+ # Should generate a single foo file
+ assert_file_and_contents(
+ "foo_generated.ts",
+ # Should export each of the types within the single file
+ [
+ "export class Foo {",
+ "export class Bar {",
+ "export enum Baz {",
+ ],
+ # No includes for the dependent types should be present.
+ doesnt_contain=[
+ "import {Bar as Bar}",
+ "import {Baz as Baz}",
+ ],
+ )
+
+ # The types Foo, Bar and Baz should not be generated in their own files.
+ assert_file_doesnt_exists("foo.ts")
+ assert_file_doesnt_exists("bar.ts")
+ assert_file_doesnt_exists("baz.ts")
+
+
+ def ZFlatFilesGenAllWithNamespacing(self):
+ # Generate foo with all of its dependents with the flat files option
+ flatc(["--ts", "--ts-flat-files", "--gen-all", "foo_with_ns.fbs"])
+
+ # Should generate a single foo file
+ assert_file_and_contents(
+ "foo_with_ns_generated.ts",
+ # Should export each of the types within the single file
+ [
+ "export class bar_Bar {",
+ "export class bar_Foo {",
+ "export enum Baz {",
+ "export enum baz_Baz {",
+ "export class something_Foo {"
+ ],
+ # No includes for the dependent types should be present.
+ doesnt_contain=[
+ "import {Bar as Bar}",
+ "import {Baz as Baz}",
+ ],
+ )
+
+ # The types Foo, Bar and Baz should not be generated in their own files.
+ assert_file_doesnt_exists("foo.ts")
+ assert_file_doesnt_exists("bar.ts")
+ assert_file_doesnt_exists("baz.ts")
+
diff --git a/tests/flatc/foo.fbs b/tests/flatc/foo.fbs
new file mode 100644
index 0000000..a2f27aa
--- /dev/null
+++ b/tests/flatc/foo.fbs
@@ -0,0 +1,9 @@
+include "bar/bar.fbs";
+include "bar/bar_with_ns.fbs";
+
+table Foo {
+ bar:Bar;
+ bar2:bar.Bar;
+}
+
+root_type Foo;
\ No newline at end of file
diff --git a/tests/flatc/foo_with_ns.fbs b/tests/flatc/foo_with_ns.fbs
new file mode 100644
index 0000000..c348d9b
--- /dev/null
+++ b/tests/flatc/foo_with_ns.fbs
@@ -0,0 +1,9 @@
+include "bar/bar_with_ns.fbs";
+
+namespace something;
+
+table Foo {
+ bar:bar.Bar;
+}
+
+root_type Foo;
\ No newline at end of file
diff --git a/tests/flatc/main.py b/tests/flatc/main.py
new file mode 100755
index 0000000..1b6bee9
--- /dev/null
+++ b/tests/flatc/main.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python3
+#
+# Copyright 2022 Google Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import sys
+
+from flatc_test import run_all
+from flatc_cpp_tests import CppTests
+from flatc_ts_tests import TsTests
+
+passing, failing = run_all(CppTests, TsTests)
+
+print("")
+print("{0} of {1} tests passed".format(passing, passing + failing))
+
+if failing > 0:
+ sys.exit(1)
diff --git a/tests/flexbuffers_test.cpp b/tests/flexbuffers_test.cpp
new file mode 100644
index 0000000..1b34f85
--- /dev/null
+++ b/tests/flexbuffers_test.cpp
@@ -0,0 +1,292 @@
+#include "flexbuffers_test.h"
+
+#include "flatbuffers/flexbuffers.h"
+#include "flatbuffers/idl.h"
+#include "is_quiet_nan.h"
+#include "test_assert.h"
+
+namespace flatbuffers {
+namespace tests {
+
+// Shortcuts for the infinity.
+static const auto infinity_d = std::numeric_limits<double>::infinity();
+
+void FlexBuffersTest() {
+ flexbuffers::Builder slb(512,
+ flexbuffers::BUILDER_FLAG_SHARE_KEYS_AND_STRINGS);
+
+ // Write the equivalent of:
+ // { vec: [ -100, "Fred", 4.0, false ], bar: [ 1, 2, 3 ], bar3: [ 1, 2, 3 ],
+ // foo: 100, bool: true, mymap: { foo: "Fred" } }
+
+ // It's possible to do this without std::function support as well.
+ slb.Map([&]() {
+ slb.Vector("vec", [&]() {
+ slb += -100; // Equivalent to slb.Add(-100) or slb.Int(-100);
+ slb += "Fred";
+ slb.IndirectFloat(4.0f);
+ auto i_f = slb.LastValue();
+ uint8_t blob[] = { 77 };
+ slb.Blob(blob, 1);
+ slb += false;
+ slb.ReuseValue(i_f);
+ });
+ int ints[] = { 1, 2, 3 };
+ slb.Vector("bar", ints, 3);
+ slb.FixedTypedVector("bar3", ints, 3);
+ bool bools[] = { true, false, true, false };
+ slb.Vector("bools", bools, 4);
+ slb.Bool("bool", true);
+ slb.Double("foo", 100);
+ slb.Map("mymap", [&]() {
+ slb.String("foo", "Fred"); // Testing key and string reuse.
+ });
+ });
+ slb.Finish();
+
+ // clang-format off
+ #ifdef FLATBUFFERS_TEST_VERBOSE
+ for (size_t i = 0; i < slb.GetBuffer().size(); i++)
+ printf("%d ", slb.GetBuffer().data()[i]);
+ printf("\n");
+ #endif
+ // clang-format on
+
+ std::vector<uint8_t> reuse_tracker;
+ TEST_EQ(flexbuffers::VerifyBuffer(slb.GetBuffer().data(),
+ slb.GetBuffer().size(), &reuse_tracker),
+ true);
+
+ auto map = flexbuffers::GetRoot(slb.GetBuffer()).AsMap();
+ TEST_EQ(map.size(), 7);
+ auto vec = map["vec"].AsVector();
+ TEST_EQ(vec.size(), 6);
+ TEST_EQ(vec[0].AsInt64(), -100);
+ TEST_EQ_STR(vec[1].AsString().c_str(), "Fred");
+ TEST_EQ(vec[1].AsInt64(), 0); // Number parsing failed.
+ TEST_EQ(vec[2].AsDouble(), 4.0);
+ TEST_EQ(vec[2].AsString().IsTheEmptyString(), true); // Wrong Type.
+ TEST_EQ_STR(vec[2].AsString().c_str(), ""); // This still works though.
+ TEST_EQ_STR(vec[2].ToString().c_str(), "4.0"); // Or have it converted.
+ // Few tests for templated version of As.
+ TEST_EQ(vec[0].As<int64_t>(), -100);
+ TEST_EQ_STR(vec[1].As<std::string>().c_str(), "Fred");
+ TEST_EQ(vec[1].As<int64_t>(), 0); // Number parsing failed.
+ TEST_EQ(vec[2].As<double>(), 4.0);
+ // Test that the blob can be accessed.
+ TEST_EQ(vec[3].IsBlob(), true);
+ auto blob = vec[3].AsBlob();
+ TEST_EQ(blob.size(), 1);
+ TEST_EQ(blob.data()[0], 77);
+ TEST_EQ(vec[4].IsBool(), true); // Check if type is a bool
+ TEST_EQ(vec[4].AsBool(), false); // Check if value is false
+ TEST_EQ(vec[5].AsDouble(), 4.0); // This is shared with vec[2] !
+ auto tvec = map["bar"].AsTypedVector();
+ TEST_EQ(tvec.size(), 3);
+ TEST_EQ(tvec[2].AsInt8(), 3);
+ auto tvec3 = map["bar3"].AsFixedTypedVector();
+ TEST_EQ(tvec3.size(), 3);
+ TEST_EQ(tvec3[2].AsInt8(), 3);
+ TEST_EQ(map["bool"].AsBool(), true);
+ auto tvecb = map["bools"].AsTypedVector();
+ TEST_EQ(tvecb.ElementType(), flexbuffers::FBT_BOOL);
+ TEST_EQ(map["foo"].AsUInt8(), 100);
+ TEST_EQ(map["unknown"].IsNull(), true);
+ auto mymap = map["mymap"].AsMap();
+ // These should be equal by pointer equality, since key and value are shared.
+ TEST_EQ(mymap.Keys()[0].AsKey(), map.Keys()[4].AsKey());
+ TEST_EQ(mymap.Values()[0].AsString().c_str(), vec[1].AsString().c_str());
+ // We can mutate values in the buffer.
+ TEST_EQ(vec[0].MutateInt(-99), true);
+ TEST_EQ(vec[0].AsInt64(), -99);
+ TEST_EQ(vec[1].MutateString("John"), true); // Size must match.
+ TEST_EQ_STR(vec[1].AsString().c_str(), "John");
+ TEST_EQ(vec[1].MutateString("Alfred"), false); // Too long.
+ TEST_EQ(vec[2].MutateFloat(2.0f), true);
+ TEST_EQ(vec[2].AsFloat(), 2.0f);
+ TEST_EQ(vec[2].MutateFloat(3.14159), false); // Double does not fit in float.
+ TEST_EQ(vec[4].AsBool(), false); // Is false before change
+ TEST_EQ(vec[4].MutateBool(true), true); // Can change a bool
+ TEST_EQ(vec[4].AsBool(), true); // Changed bool is now true
+
+ // Parse from JSON:
+ flatbuffers::Parser parser;
+ slb.Clear();
+ auto jsontest = "{ a: [ 123, 456.0 ], b: \"hello\", c: true, d: false }";
+ TEST_EQ(parser.ParseFlexBuffer(jsontest, nullptr, &slb), true);
+ TEST_EQ(flexbuffers::VerifyBuffer(slb.GetBuffer().data(),
+ slb.GetBuffer().size(), &reuse_tracker),
+ true);
+ auto jroot = flexbuffers::GetRoot(slb.GetBuffer());
+ auto jmap = jroot.AsMap();
+ auto jvec = jmap["a"].AsVector();
+ TEST_EQ(jvec[0].AsInt64(), 123);
+ TEST_EQ(jvec[1].AsDouble(), 456.0);
+ TEST_EQ_STR(jmap["b"].AsString().c_str(), "hello");
+ TEST_EQ(jmap["c"].IsBool(), true); // Parsed correctly to a bool
+ TEST_EQ(jmap["c"].AsBool(), true); // Parsed correctly to true
+ TEST_EQ(jmap["d"].IsBool(), true); // Parsed correctly to a bool
+ TEST_EQ(jmap["d"].AsBool(), false); // Parsed correctly to false
+ // And from FlexBuffer back to JSON:
+ auto jsonback = jroot.ToString();
+ TEST_EQ_STR(jsontest, jsonback.c_str());
+
+ slb.Clear();
+ slb.Vector([&]() {
+ for (int i = 0; i < 130; ++i) slb.Add(static_cast<uint8_t>(255));
+ slb.Vector([&]() {
+ for (int i = 0; i < 130; ++i) slb.Add(static_cast<uint8_t>(255));
+ slb.Vector([] {});
+ });
+ });
+ slb.Finish();
+ TEST_EQ(slb.GetSize(), 664);
+}
+
+void FlexBuffersReuseBugTest() {
+ flexbuffers::Builder slb;
+ slb.Map([&]() {
+ slb.Vector("vec", [&]() {});
+ slb.Bool("bool", true);
+ });
+ slb.Finish();
+ std::vector<uint8_t> reuse_tracker;
+ // This would fail before, since the reuse_tracker would use the address of
+ // the vector reference to check for reuse, but in this case we have an empty
+ // vector, and since the size field is before the pointer, its address is the
+ // same as thing after it, the key "bool".
+ // We fix this by using the address of the size field for tracking reuse.
+ TEST_EQ(flexbuffers::VerifyBuffer(slb.GetBuffer().data(),
+ slb.GetBuffer().size(), &reuse_tracker),
+ true);
+}
+
+void FlexBuffersFloatingPointTest() {
+#if defined(FLATBUFFERS_HAS_NEW_STRTOD) && (FLATBUFFERS_HAS_NEW_STRTOD > 0)
+ flexbuffers::Builder slb(512,
+ flexbuffers::BUILDER_FLAG_SHARE_KEYS_AND_STRINGS);
+ // Parse floating-point values from JSON:
+ flatbuffers::Parser parser;
+ slb.Clear();
+ auto jsontest =
+ "{ a: [1.0, nan, inf, infinity, -inf, +inf, -infinity, 8.0] }";
+ TEST_EQ(parser.ParseFlexBuffer(jsontest, nullptr, &slb), true);
+ auto jroot = flexbuffers::GetRoot(slb.GetBuffer());
+ TEST_EQ(flexbuffers::VerifyBuffer(slb.GetBuffer().data(),
+ slb.GetBuffer().size(), nullptr),
+ true);
+ auto jmap = jroot.AsMap();
+ auto jvec = jmap["a"].AsVector();
+ TEST_EQ(8, jvec.size());
+ TEST_EQ(1.0, jvec[0].AsDouble());
+ TEST_ASSERT(is_quiet_nan(jvec[1].AsDouble()));
+ TEST_EQ(infinity_d, jvec[2].AsDouble());
+ TEST_EQ(infinity_d, jvec[3].AsDouble());
+ TEST_EQ(-infinity_d, jvec[4].AsDouble());
+ TEST_EQ(+infinity_d, jvec[5].AsDouble());
+ TEST_EQ(-infinity_d, jvec[6].AsDouble());
+ TEST_EQ(8.0, jvec[7].AsDouble());
+#endif
+}
+
+void FlexBuffersDeprecatedTest() {
+ // FlexBuffers as originally designed had a flaw involving the
+ // FBT_VECTOR_STRING datatype, and this test documents/tests the fix for it.
+ // Discussion: https://github.com/google/flatbuffers/issues/5627
+ flexbuffers::Builder slb;
+ // FBT_VECTOR_* are "typed vectors" where all elements are of the same type.
+ // Problem is, when storing FBT_STRING elements, it relies on that type to
+ // get the bit-width for the size field of the string, which in this case
+ // isn't present, and instead defaults to 8-bit. This means that any strings
+ // stored inside such a vector, when accessed thru the old API that returns
+ // a String reference, will appear to be truncated if the string stored is
+ // actually >=256 bytes.
+ std::string test_data(300, 'A');
+ auto start = slb.StartVector();
+ // This one will have a 16-bit size field.
+ slb.String(test_data);
+ // This one will have an 8-bit size field.
+ slb.String("hello");
+ // We're asking this to be serialized as a typed vector (true), but not
+ // fixed size (false). The type will be FBT_VECTOR_STRING with a bit-width
+ // of whatever the offsets in the vector need, the bit-widths of the strings
+ // are not stored(!) <- the actual design flaw.
+ // Note that even in the fixed code, we continue to serialize the elements of
+ // FBT_VECTOR_STRING as FBT_STRING, since there may be old code out there
+ // reading new data that we want to continue to function.
+ // Thus, FBT_VECTOR_STRING, while deprecated, will always be represented the
+ // same way, the fix lies on the reading side.
+ slb.EndVector(start, true, false);
+ slb.Finish();
+ // Verify because why not.
+ TEST_EQ(flexbuffers::VerifyBuffer(slb.GetBuffer().data(),
+ slb.GetBuffer().size(), nullptr),
+ true);
+ // So now lets read this data back.
+ // For existing data, since we have no way of knowing what the actual
+ // bit-width of the size field of the string is, we are going to ignore this
+ // field, and instead treat these strings as FBT_KEY (null-terminated), so we
+ // can deal with strings of arbitrary length. This of course truncates strings
+ // with embedded nulls, but we think that that is preferrable over truncating
+ // strings >= 256 bytes.
+ auto vec = flexbuffers::GetRoot(slb.GetBuffer()).AsTypedVector();
+ // Even though this was serialized as FBT_VECTOR_STRING, it is read as
+ // FBT_VECTOR_KEY:
+ TEST_EQ(vec.ElementType(), flexbuffers::FBT_KEY);
+ // Access the long string. Previously, this would return a string of size 1,
+ // since it would read the high-byte of the 16-bit length.
+ // This should now correctly test the full 300 bytes, using AsKey():
+ TEST_EQ_STR(vec[0].AsKey(), test_data.c_str());
+ // Old code that called AsString will continue to work, as the String
+ // accessor objects now use a cached size that can come from a key as well.
+ TEST_EQ_STR(vec[0].AsString().c_str(), test_data.c_str());
+ // Short strings work as before:
+ TEST_EQ_STR(vec[1].AsKey(), "hello");
+ TEST_EQ_STR(vec[1].AsString().c_str(), "hello");
+ // So, while existing code and data mostly "just work" with the fixes applied
+ // to AsTypedVector and AsString, what do you do going forward?
+ // Code accessing existing data doesn't necessarily need to change, though
+ // you could consider using AsKey instead of AsString for a) documenting
+ // that you are accessing keys, or b) a speedup if you don't actually use
+ // the string size.
+ // For new data, or data that doesn't need to be backwards compatible,
+ // instead serialize as FBT_VECTOR (call EndVector with typed = false, then
+ // read elements with AsString), or, for maximum compactness, use
+ // FBT_VECTOR_KEY (call slb.Key above instead, read with AsKey or AsString).
+}
+
+void ParseFlexbuffersFromJsonWithNullTest() {
+ // Test nulls are handled appropriately through flexbuffers to exercise other
+ // code paths of ParseSingleValue in the optional scalars change.
+ // TODO(cneo): Json -> Flatbuffers test once some language can generate code
+ // with optional scalars.
+ {
+ char json[] = "{\"opt_field\": 123 }";
+ flatbuffers::Parser parser;
+ flexbuffers::Builder flexbuild;
+ parser.ParseFlexBuffer(json, nullptr, &flexbuild);
+ auto root = flexbuffers::GetRoot(flexbuild.GetBuffer());
+ TEST_EQ(root.AsMap()["opt_field"].AsInt64(), 123);
+ }
+ {
+ char json[] = "{\"opt_field\": 123.4 }";
+ flatbuffers::Parser parser;
+ flexbuffers::Builder flexbuild;
+ parser.ParseFlexBuffer(json, nullptr, &flexbuild);
+ auto root = flexbuffers::GetRoot(flexbuild.GetBuffer());
+ TEST_EQ(root.AsMap()["opt_field"].AsDouble(), 123.4);
+ }
+ {
+ char json[] = "{\"opt_field\": null }";
+ flatbuffers::Parser parser;
+ flexbuffers::Builder flexbuild;
+ parser.ParseFlexBuffer(json, nullptr, &flexbuild);
+ auto root = flexbuffers::GetRoot(flexbuild.GetBuffer());
+ TEST_ASSERT(!root.AsMap().IsTheEmptyMap());
+ TEST_ASSERT(root.AsMap()["opt_field"].IsNull());
+ TEST_EQ(root.ToString(), std::string("{ opt_field: null }"));
+ }
+}
+
+} // namespace tests
+} // namespace flatbuffers
\ No newline at end of file
diff --git a/tests/flexbuffers_test.h b/tests/flexbuffers_test.h
new file mode 100644
index 0000000..02a10b6
--- /dev/null
+++ b/tests/flexbuffers_test.h
@@ -0,0 +1,16 @@
+#ifndef TESTS_FLEXBUFFERS_TEST_H
+#define TESTS_FLEXBUFFERS_TEST_H
+
+namespace flatbuffers {
+namespace tests {
+
+void FlexBuffersTest();
+void FlexBuffersReuseBugTest();
+void FlexBuffersFloatingPointTest();
+void FlexBuffersDeprecatedTest();
+void ParseFlexbuffersFromJsonWithNullTest();
+
+} // namespace tests
+} // namespace flatbuffers
+
+#endif // TESTS_FLEXBUFFERS_TEST_H
\ No newline at end of file
diff --git a/tests/fuzz_test.cpp b/tests/fuzz_test.cpp
new file mode 100644
index 0000000..66883fa
--- /dev/null
+++ b/tests/fuzz_test.cpp
@@ -0,0 +1,305 @@
+#include "fuzz_test.h"
+
+#include "flatbuffers/flatbuffers.h"
+#include "flatbuffers/idl.h"
+#include "test_assert.h"
+
+namespace flatbuffers {
+namespace tests {
+namespace {
+
+// Include simple random number generator to ensure results will be the
+// same cross platform.
+// http://en.wikipedia.org/wiki/Park%E2%80%93Miller_random_number_generator
+uint32_t lcg_seed = 48271;
+uint32_t lcg_rand() {
+ return lcg_seed =
+ (static_cast<uint64_t>(lcg_seed) * 279470273UL) % 4294967291UL;
+}
+void lcg_reset() { lcg_seed = 48271; }
+
+template<typename T>
+static void CompareTableFieldValue(flatbuffers::Table *table,
+ flatbuffers::voffset_t voffset, T val) {
+ T read = table->GetField(voffset, static_cast<T>(0));
+ TEST_EQ(read, val);
+}
+
+} // namespace
+
+// Low level stress/fuzz test: serialize/deserialize a variety of
+// different kinds of data in different combinations
+void FuzzTest1() {
+ // Values we're testing against: chosen to ensure no bits get chopped
+ // off anywhere, and also be different from eachother.
+ const uint8_t bool_val = true;
+ const int8_t char_val = -127; // 0x81
+ const uint8_t uchar_val = 0xFF;
+ const int16_t short_val = -32222; // 0x8222;
+ const uint16_t ushort_val = 0xFEEE;
+ const int32_t int_val = 0x83333333;
+ const uint32_t uint_val = 0xFDDDDDDD;
+ const int64_t long_val = 0x8444444444444444LL;
+ const uint64_t ulong_val = 0xFCCCCCCCCCCCCCCCULL;
+ const float float_val = 3.14159f;
+ const double double_val = 3.14159265359;
+
+ const int test_values_max = 11;
+ const flatbuffers::voffset_t fields_per_object = 4;
+ const int num_fuzz_objects = 10000; // The higher, the more thorough :)
+
+ flatbuffers::FlatBufferBuilder builder;
+
+ lcg_reset(); // Keep it deterministic.
+
+ flatbuffers::uoffset_t objects[num_fuzz_objects];
+
+ // Generate num_fuzz_objects random objects each consisting of
+ // fields_per_object fields, each of a random type.
+ for (int i = 0; i < num_fuzz_objects; i++) {
+ auto start = builder.StartTable();
+ for (flatbuffers::voffset_t f = 0; f < fields_per_object; f++) {
+ int choice = lcg_rand() % test_values_max;
+ auto off = flatbuffers::FieldIndexToOffset(f);
+ switch (choice) {
+ case 0: builder.AddElement<uint8_t>(off, bool_val, 0); break;
+ case 1: builder.AddElement<int8_t>(off, char_val, 0); break;
+ case 2: builder.AddElement<uint8_t>(off, uchar_val, 0); break;
+ case 3: builder.AddElement<int16_t>(off, short_val, 0); break;
+ case 4: builder.AddElement<uint16_t>(off, ushort_val, 0); break;
+ case 5: builder.AddElement<int32_t>(off, int_val, 0); break;
+ case 6: builder.AddElement<uint32_t>(off, uint_val, 0); break;
+ case 7: builder.AddElement<int64_t>(off, long_val, 0); break;
+ case 8: builder.AddElement<uint64_t>(off, ulong_val, 0); break;
+ case 9: builder.AddElement<float>(off, float_val, 0); break;
+ case 10: builder.AddElement<double>(off, double_val, 0); break;
+ }
+ }
+ objects[i] = builder.EndTable(start);
+ }
+ builder.PreAlign<flatbuffers::largest_scalar_t>(0); // Align whole buffer.
+
+ lcg_reset(); // Reset.
+
+ uint8_t *eob = builder.GetCurrentBufferPointer() + builder.GetSize();
+
+ // Test that all objects we generated are readable and return the
+ // expected values. We generate random objects in the same order
+ // so this is deterministic.
+ for (int i = 0; i < num_fuzz_objects; i++) {
+ auto table = reinterpret_cast<flatbuffers::Table *>(eob - objects[i]);
+ for (flatbuffers::voffset_t f = 0; f < fields_per_object; f++) {
+ int choice = lcg_rand() % test_values_max;
+ flatbuffers::voffset_t off = flatbuffers::FieldIndexToOffset(f);
+ switch (choice) {
+ case 0: CompareTableFieldValue(table, off, bool_val); break;
+ case 1: CompareTableFieldValue(table, off, char_val); break;
+ case 2: CompareTableFieldValue(table, off, uchar_val); break;
+ case 3: CompareTableFieldValue(table, off, short_val); break;
+ case 4: CompareTableFieldValue(table, off, ushort_val); break;
+ case 5: CompareTableFieldValue(table, off, int_val); break;
+ case 6: CompareTableFieldValue(table, off, uint_val); break;
+ case 7: CompareTableFieldValue(table, off, long_val); break;
+ case 8: CompareTableFieldValue(table, off, ulong_val); break;
+ case 9: CompareTableFieldValue(table, off, float_val); break;
+ case 10: CompareTableFieldValue(table, off, double_val); break;
+ }
+ }
+ }
+}
+
+// High level stress/fuzz test: generate a big schema and
+// matching json data in random combinations, then parse both,
+// generate json back from the binary, and compare with the original.
+void FuzzTest2() {
+ lcg_reset(); // Keep it deterministic.
+
+ const int num_definitions = 30;
+ const int num_struct_definitions = 5; // Subset of num_definitions.
+ const int fields_per_definition = 15;
+ const int instances_per_definition = 5;
+ const int deprecation_rate = 10; // 1 in deprecation_rate fields will
+ // be deprecated.
+
+ std::string schema = "namespace test;\n\n";
+
+ struct RndDef {
+ std::string instances[instances_per_definition];
+
+ // Since we're generating schema and corresponding data in tandem,
+ // this convenience function adds strings to both at once.
+ static void Add(RndDef (&definitions_l)[num_definitions],
+ std::string &schema_l, const int instances_per_definition_l,
+ const char *schema_add, const char *instance_add,
+ int definition) {
+ schema_l += schema_add;
+ for (int i = 0; i < instances_per_definition_l; i++)
+ definitions_l[definition].instances[i] += instance_add;
+ }
+ };
+
+ // clang-format off
+ #define AddToSchemaAndInstances(schema_add, instance_add) \
+ RndDef::Add(definitions, schema, instances_per_definition, \
+ schema_add, instance_add, definition)
+
+ #define Dummy() \
+ RndDef::Add(definitions, schema, instances_per_definition, \
+ "byte", "1", definition)
+ // clang-format on
+
+ RndDef definitions[num_definitions];
+
+ // We are going to generate num_definitions, the first
+ // num_struct_definitions will be structs, the rest tables. For each
+ // generate random fields, some of which may be struct/table types
+ // referring to previously generated structs/tables.
+ // Simultanenously, we generate instances_per_definition JSON data
+ // definitions, which will have identical structure to the schema
+ // being generated. We generate multiple instances such that when creating
+ // hierarchy, we get some variety by picking one randomly.
+ for (int definition = 0; definition < num_definitions; definition++) {
+ std::string definition_name = "D" + flatbuffers::NumToString(definition);
+
+ bool is_struct = definition < num_struct_definitions;
+
+ AddToSchemaAndInstances(
+ ((is_struct ? "struct " : "table ") + definition_name + " {\n").c_str(),
+ "{\n");
+
+ for (int field = 0; field < fields_per_definition; field++) {
+ const bool is_last_field = field == fields_per_definition - 1;
+
+ // Deprecate 1 in deprecation_rate fields. Only table fields can be
+ // deprecated.
+ // Don't deprecate the last field to avoid dangling commas in JSON.
+ const bool deprecated =
+ !is_struct && !is_last_field && (lcg_rand() % deprecation_rate == 0);
+
+ std::string field_name = "f" + flatbuffers::NumToString(field);
+ AddToSchemaAndInstances((" " + field_name + ":").c_str(),
+ deprecated ? "" : (field_name + ": ").c_str());
+ // Pick random type:
+ auto base_type = static_cast<flatbuffers::BaseType>(
+ lcg_rand() % (flatbuffers::BASE_TYPE_UNION + 1));
+ switch (base_type) {
+ case flatbuffers::BASE_TYPE_STRING:
+ if (is_struct) {
+ Dummy(); // No strings in structs.
+ } else {
+ AddToSchemaAndInstances("string", deprecated ? "" : "\"hi\"");
+ }
+ break;
+ case flatbuffers::BASE_TYPE_VECTOR:
+ if (is_struct) {
+ Dummy(); // No vectors in structs.
+ } else {
+ AddToSchemaAndInstances("[ubyte]",
+ deprecated ? "" : "[\n0,\n1,\n255\n]");
+ }
+ break;
+ case flatbuffers::BASE_TYPE_NONE:
+ case flatbuffers::BASE_TYPE_UTYPE:
+ case flatbuffers::BASE_TYPE_STRUCT:
+ case flatbuffers::BASE_TYPE_UNION:
+ if (definition) {
+ // Pick a random previous definition and random data instance of
+ // that definition.
+ int defref = lcg_rand() % definition;
+ int instance = lcg_rand() % instances_per_definition;
+ AddToSchemaAndInstances(
+ ("D" + flatbuffers::NumToString(defref)).c_str(),
+ deprecated ? ""
+ : definitions[defref].instances[instance].c_str());
+ } else {
+ // If this is the first definition, we have no definition we can
+ // refer to.
+ Dummy();
+ }
+ break;
+ case flatbuffers::BASE_TYPE_BOOL:
+ AddToSchemaAndInstances(
+ "bool", deprecated ? "" : (lcg_rand() % 2 ? "true" : "false"));
+ break;
+ case flatbuffers::BASE_TYPE_ARRAY:
+ if (!is_struct) {
+ AddToSchemaAndInstances(
+ "ubyte",
+ deprecated ? "" : "255"); // No fixed-length arrays in tables.
+ } else {
+ AddToSchemaAndInstances("[int:3]", deprecated ? "" : "[\n,\n,\n]");
+ }
+ break;
+ default:
+ // All the scalar types.
+ schema += flatbuffers::kTypeNames[base_type];
+
+ if (!deprecated) {
+ // We want each instance to use its own random value.
+ for (int inst = 0; inst < instances_per_definition; inst++)
+ definitions[definition].instances[inst] +=
+ flatbuffers::IsFloat(base_type)
+ ? flatbuffers::NumToString<double>(lcg_rand() % 128)
+ .c_str()
+ : flatbuffers::NumToString<int>(lcg_rand() % 128).c_str();
+ }
+ }
+ AddToSchemaAndInstances(deprecated ? "(deprecated);\n" : ";\n",
+ deprecated ? ""
+ : is_last_field ? "\n"
+ : ",\n");
+ }
+ AddToSchemaAndInstances("}\n\n", "}");
+ }
+
+ schema += "root_type D" + flatbuffers::NumToString(num_definitions - 1);
+ schema += ";\n";
+
+ flatbuffers::Parser parser;
+
+ // Will not compare against the original if we don't write defaults
+ parser.builder_.ForceDefaults(true);
+
+ // Parse the schema, parse the generated data, then generate text back
+ // from the binary and compare against the original.
+ TEST_EQ(parser.Parse(schema.c_str()), true);
+
+ const std::string &json =
+ definitions[num_definitions - 1].instances[0] + "\n";
+
+ TEST_EQ(parser.Parse(json.c_str()), true);
+
+ std::string jsongen;
+ parser.opts.indent_step = 0;
+ auto result =
+ GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen);
+ TEST_EQ(result, true);
+
+ if (jsongen != json) {
+ // These strings are larger than a megabyte, so we show the bytes around
+ // the first bytes that are different rather than the whole string.
+ size_t len = std::min(json.length(), jsongen.length());
+ for (size_t i = 0; i < len; i++) {
+ if (json[i] != jsongen[i]) {
+ i -= std::min(static_cast<size_t>(10), i); // show some context;
+ size_t end = std::min(len, i + 20);
+ for (; i < end; i++)
+ TEST_OUTPUT_LINE("at %d: found \"%c\", expected \"%c\"\n",
+ static_cast<int>(i), jsongen[i], json[i]);
+ break;
+ }
+ }
+ TEST_NOTNULL(nullptr); //-V501 (this comment suppresses CWE-570 warning)
+ }
+
+ // clang-format off
+ #ifdef FLATBUFFERS_TEST_VERBOSE
+ TEST_OUTPUT_LINE("%dk schema tested with %dk of json\n",
+ static_cast<int>(schema.length() / 1024),
+ static_cast<int>(json.length() / 1024));
+ #endif
+ // clang-format on
+}
+
+} // namespace tests
+} // namespace flatbuffers
\ No newline at end of file
diff --git a/tests/fuzz_test.h b/tests/fuzz_test.h
new file mode 100644
index 0000000..3708128
--- /dev/null
+++ b/tests/fuzz_test.h
@@ -0,0 +1,13 @@
+#ifndef TESTS_FUZZ_TEST_H
+#define TESTS_FUZZ_TEST_H
+
+namespace flatbuffers {
+namespace tests {
+
+void FuzzTest1();
+void FuzzTest2();
+
+} // namespace tests
+} // namespace flatbuffers
+
+#endif
diff --git a/tests/fuzzer/.gitignore b/tests/fuzzer/.gitignore
new file mode 100644
index 0000000..2e4d1d1
--- /dev/null
+++ b/tests/fuzzer/.gitignore
@@ -0,0 +1,18 @@
+# The generated fuzzers
+*_fuzzer
+
+# Findings from the fuzzers
+oom-*
+slow-unit-*
+crash-*
+
+# Individual fuzzer logs if job=N
+fuzz-*.log
+
+.clangd/
+
+# These are copied from tests/annotated_binary/ and should use the latest ones.
+annotated_binary.bfbs
+annotated_binary.bin
+
+monster_test.bfbs
\ No newline at end of file
diff --git a/tests/fuzzer/CMakeLists.txt b/tests/fuzzer/CMakeLists.txt
index 9cc5a5f..63bda68 100644
--- a/tests/fuzzer/CMakeLists.txt
+++ b/tests/fuzzer/CMakeLists.txt
@@ -95,6 +95,7 @@
${FLATBUFFERS_DIR}/include/flatbuffers/flatbuffer_builder.h
${FLATBUFFERS_DIR}/include/flatbuffers/flatbuffers.h
${FLATBUFFERS_DIR}/include/flatbuffers/flexbuffers.h
+ ${FLATBUFFERS_DIR}/include/flatbuffers/flex_flat_util.h
${FLATBUFFERS_DIR}/include/flatbuffers/hash.h
${FLATBUFFERS_DIR}/include/flatbuffers/idl.h
${FLATBUFFERS_DIR}/include/flatbuffers/minireflect.h
@@ -112,12 +113,15 @@
${FLATBUFFERS_DIR}/src/idl_parser.cpp
${FLATBUFFERS_DIR}/src/idl_gen_text.cpp
${FLATBUFFERS_DIR}/src/reflection.cpp
+ ${FLATBUFFERS_DIR}/src/binary_annotator.h
+ ${FLATBUFFERS_DIR}/src/binary_annotator.cpp
${FLATBUFFERS_DIR}/src/util.cpp
${FLATBUFFERS_DIR}/tests/test_assert.cpp
)
include_directories(${FLATBUFFERS_DIR}/include)
include_directories(${FLATBUFFERS_DIR}/tests)
+include_directories(${FLATBUFFERS_DIR}/src)
add_library(flatbuffers_fuzzed STATIC ${FlatBuffers_Library_SRCS})
# Use PUBLIC to force 'fuzzer_config' for all dependent targets
@@ -156,7 +160,20 @@
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/../monster_test.bfbs
${CMAKE_CURRENT_BINARY_DIR}/monster_test.bfbs)
-
+
+add_executable(annotator_fuzzer flatbuffers_annotator_fuzzer.cc)
+target_link_libraries(annotator_fuzzer PRIVATE flatbuffers_fuzzed)
+add_custom_command(
+ TARGET annotator_fuzzer PRE_BUILD
+
+ COMMAND ${CMAKE_COMMAND} -E copy
+ ${CMAKE_SOURCE_DIR}/../annotated_binary/annotated_binary.bfbs
+ ${CMAKE_CURRENT_BINARY_DIR}/annotated_binary.bfbs
+
+ COMMAND ${CMAKE_COMMAND} -E copy
+ ${CMAKE_SOURCE_DIR}/../annotated_binary/annotated_binary.bin
+ ${CMAKE_CURRENT_BINARY_DIR}/seed_annotator/annotated_binary.bin
+)
# Build debugger for weird cases found with fuzzer.
if(BUILD_DEBUGGER)
diff --git a/tests/fuzzer/flatbuffers_annotator_fuzzer.cc b/tests/fuzzer/flatbuffers_annotator_fuzzer.cc
new file mode 100644
index 0000000..7ff4313
--- /dev/null
+++ b/tests/fuzzer/flatbuffers_annotator_fuzzer.cc
@@ -0,0 +1,53 @@
+
+#include <filesystem>
+#include <string>
+
+#include "binary_annotator.h"
+#include "test_init.h"
+
+static std::filesystem::path exe_path_;
+static const uint8_t *schema_bfbs_;
+static size_t schema_bfbs_length_;
+
+bool TestFileExists(std::filesystem::path file_path) {
+ if (file_path.has_filename() && std::filesystem::exists(file_path))
+ return true;
+
+ TEST_OUTPUT_LINE("@DEBUG: file '%s' not found", file_path.string().c_str());
+ for (const auto &entry :
+ std::filesystem::directory_iterator(file_path.parent_path())) {
+ TEST_OUTPUT_LINE("@DEBUG: parent path entry: '%s'",
+ entry.path().string().c_str());
+ }
+ return false;
+}
+
+std::string LoadBinarySchema(const char *file_name) {
+ const auto file_path = exe_path_.parent_path() / file_name;
+ TEST_EQ(true, TestFileExists(file_path));
+ std::string schemafile;
+ TEST_EQ(true,
+ flatbuffers::LoadFile(file_path.string().c_str(), true, &schemafile));
+
+ flatbuffers::Verifier verifier(
+ reinterpret_cast<const uint8_t *>(schemafile.c_str()), schemafile.size());
+ TEST_EQ(true, reflection::VerifySchemaBuffer(verifier));
+ return schemafile;
+}
+
+extern "C" int LLVMFuzzerInitialize(int *, char ***argv) {
+ exe_path_ = (*argv)[0];
+ static const std::string schema_file =
+ LoadBinarySchema("annotated_binary.bfbs");
+ schema_bfbs_ = reinterpret_cast<const uint8_t *>(schema_file.c_str());
+ schema_bfbs_length_ = schema_file.size();
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+ flatbuffers::BinaryAnnotator annotator(schema_bfbs_, schema_bfbs_length_,
+ data, size);
+
+ annotator.Annotate();
+ return 0;
+}
\ No newline at end of file
diff --git a/tests/fuzzer/flatbuffers_monster_fuzzer.cc b/tests/fuzzer/flatbuffers_monster_fuzzer.cc
index 8981c2f..4b8b790 100644
--- a/tests/fuzzer/flatbuffers_monster_fuzzer.cc
+++ b/tests/fuzzer/flatbuffers_monster_fuzzer.cc
@@ -23,6 +23,7 @@
#include "cpp17/generated_cpp17/monster_test_generated.h"
#include "flatbuffers/idl.h"
+#include "test_assert.h"
#include "test_init.h"
namespace fs = std::filesystem;
@@ -32,6 +33,8 @@
// The current executable path (see LLVMFuzzerInitialize).
static fs::path exe_path_;
+static flatbuffers::Parser parser_;
+
namespace {
static constexpr size_t kMinInputLength = 1;
@@ -46,7 +49,8 @@
TEST_OUTPUT_LINE("@DEBUG: file '%s' not found", file_path.string().c_str());
for (const auto &entry : fs::directory_iterator(file_path.parent_path())) {
- TEST_OUTPUT_LINE("@DEBUG: parent path entry: '%s'", entry.path().string().c_str());
+ TEST_OUTPUT_LINE("@DEBUG: parent path entry: '%s'",
+ entry.path().string().c_str());
}
return false;
}
@@ -55,7 +59,8 @@
const auto file_path = exe_path_.parent_path() / file_name;
TEST_EQ(true, TestFileExists(file_path));
std::string schemafile;
- TEST_EQ(true, flatbuffers::LoadFile(file_path.string().c_str(), true, &schemafile));
+ TEST_EQ(true,
+ flatbuffers::LoadFile(file_path.string().c_str(), true, &schemafile));
flatbuffers::Verifier verifier(
reinterpret_cast<const uint8_t *>(schemafile.c_str()), schemafile.size());
@@ -65,26 +70,19 @@
std::string do_test(const flatbuffers::IDLOptions &opts,
const std::string input_json, const bool check_parser) {
- // once loaded from disk
- static const std::string schemafile = LoadBinarySchema("monster_test.bfbs");
- // parse schema first, so we can use it to parse the data after
- flatbuffers::Parser parser;
- TEST_EQ(true, parser.Deserialize(
- reinterpret_cast<const uint8_t *>(schemafile.c_str()),
- schemafile.size()));
// (re)define parser options
- parser.opts = opts;
+ parser_.opts = opts;
std::string jsongen;
- if (parser.ParseJson(input_json.c_str())) {
- flatbuffers::Verifier verifier(parser.builder_.GetBufferPointer(),
- parser.builder_.GetSize());
+ if (parser_.ParseJson(input_json.c_str())) {
+ flatbuffers::Verifier verifier(parser_.builder_.GetBufferPointer(),
+ parser_.builder_.GetSize());
TEST_EQ(true, MyGame::Example::VerifyMonsterBuffer(verifier));
TEST_ASSERT(
- GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen));
+ GenerateText(parser_, parser_.builder_.GetBufferPointer(), &jsongen));
} else if (check_parser) {
TEST_OUTPUT_LINE("parser failed with JSON:\n%s", input_json.c_str());
- TEST_EQ_STR("", parser.error_.c_str());
+ TEST_EQ_STR("", parser_.error_.c_str());
TEST_ASSERT(false);
}
return jsongen;
@@ -100,6 +98,11 @@
extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
(void)argc;
exe_path_ = (*argv)[0];
+
+ static const std::string schemafile = LoadBinarySchema("monster_test.bfbs");
+ // parse schema first, so we can use it to parse the data after
+ parser_.Deserialize(reinterpret_cast<const uint8_t *>(schemafile.c_str()),
+ schemafile.size());
return 0;
}
@@ -122,10 +125,20 @@
(flags & flags_skip_unexpected_fields_in_json);
opts.allow_non_utf8 = (flags & flags_allow_non_utf8);
- const std::string jsongen_1 = do_test(opts, input, false);
- if (!jsongen_1.empty()) {
- const std::string jsongen_2 = do_test(opts, jsongen_1, true);
- TEST_EQ(jsongen_1, jsongen_2);
- }
+ do {
+ const std::string jsongen_1 = do_test(opts, input, false);
+ if (!jsongen_1.empty()) {
+ const std::string jsongen_2 = do_test(opts, jsongen_1, true);
+ if (jsongen_1 != jsongen_2 && !opts.output_default_scalars_in_json) {
+ // This gets tricky when the jsongen_1 includes a default-value, as the
+ // generated jsongen_2 doesn't emit default-values. So enable default
+ // scalars and re-run it.
+ opts.output_default_scalars_in_json = true;
+ continue;
+ }
+ TEST_EQ(jsongen_1, jsongen_2);
+ }
+ } while (0);
+
return 0;
}
diff --git a/tests/fuzzer/readme.md b/tests/fuzzer/readme.md
index 1d0b392..c451301 100644
--- a/tests/fuzzer/readme.md
+++ b/tests/fuzzer/readme.md
@@ -11,6 +11,7 @@
To build and run these tests LLVM compiler (with clang frontend) and CMake should be installed before.
The fuzzer section include four tests:
+- `annotator_fuzzer` checks that inputs given to the flatc --annotate are always parsable;
- `verifier_fuzzer` checks stability of deserialization engine for `Monster` schema;
- `parser_fuzzer` checks stability of schema and json parser under various inputs;
- `scalar_parser` focused on validation of the parser while parse numeric scalars in schema and/or json files;
diff --git a/tests/fuzzer/test_init.h b/tests/fuzzer/test_init.h
index 6c9113d..6cb58d3 100644
--- a/tests/fuzzer/test_init.h
+++ b/tests/fuzzer/test_init.h
@@ -11,7 +11,7 @@
// This hook terminate program both in Debug and Release.
static bool TestFailListener(const char *expval, const char *val,
const char *exp, const char *file, int line,
- const char *func = 0) {
+ const char *func = nullptr) {
(void)expval;
(void)val;
(void)exp;
diff --git a/tests/go_test.go b/tests/go_test.go
index 11b3f0a..8cb7b97 100644
--- a/tests/go_test.go
+++ b/tests/go_test.go
@@ -17,14 +17,14 @@
package main
import (
- mygame "MyGame" // refers to generated code
- example "MyGame/Example" // refers to generated code
+ mygame "MyGame" // refers to generated code
+ example "MyGame/Example" // refers to generated code
+ "encoding/json"
optional_scalars "optional_scalars" // refers to generated code
"bytes"
"flag"
"fmt"
- "io/ioutil"
"os"
"reflect"
"sort"
@@ -69,6 +69,35 @@
os.Exit(m.Run())
}
+// TestTextParsing test if text parsing works with object API.
+func TestTextParsing(t *testing.T) {
+ expectedMonster := example.MonsterT{
+ Mana: 42,
+ Name: "foo",
+ LongEnumNormalDefault: example.LongEnumLongTwo,
+ }
+
+ buf := new(bytes.Buffer)
+ if err := json.NewEncoder(buf).Encode(expectedMonster); err != nil {
+ t.Fatal(err)
+ }
+
+ var monster example.MonsterT
+ if err := json.NewDecoder(buf).Decode(&monster); err != nil {
+ t.Fatal(err)
+ }
+
+ if monster.Mana != expectedMonster.Mana {
+ t.Fatal("wrong mana:", monster.Mana)
+ }
+ if monster.Name != expectedMonster.Name {
+ t.Fatal("wrong name:", monster.Name)
+ }
+ if monster.LongEnumNormalDefault != expectedMonster.LongEnumNormalDefault {
+ t.Fatal("wrong enum:", monster.LongEnumNormalDefault)
+ }
+}
+
// TestAll runs all checks, failing if any errors occur.
func TestAll(t *testing.T) {
// Verify that the Go FlatBuffers runtime library generates the
@@ -101,7 +130,7 @@
// Verify that the buffer generated by C++ code is readable by the
// generated Go code:
- monsterDataCpp, err := ioutil.ReadFile(cppData)
+ monsterDataCpp, err := os.ReadFile(cppData)
if err != nil {
t.Fatal(err)
}
@@ -141,7 +170,7 @@
// is given, check that Go code can read it, and that Go code
// generates an identical buffer when used to create the example data:
if javaData != "" {
- monsterDataJava, err := ioutil.ReadFile(javaData)
+ monsterDataJava, err := os.ReadFile(javaData)
if err != nil {
t.Fatal(err)
}
@@ -155,7 +184,7 @@
}
// Write the generated buffer out to a file:
- err = ioutil.WriteFile(outData, generated[off:], os.FileMode(0644))
+ err = os.WriteFile(outData, generated[off:], os.FileMode(0644))
if err != nil {
t.Fatal(err)
}
@@ -1685,7 +1714,7 @@
CheckObjectAPI(generated, off, true, fail)
// Write generated bfufer out to a file
- if err := ioutil.WriteFile(outData+".sp", generated[off:], os.FileMode(0644)); err != nil {
+ if err := os.WriteFile(outData+".sp", generated[off:], os.FileMode(0644)); err != nil {
fail("failed to write file: %s", err)
}
}
diff --git a/tests/include_test1/mod.rs b/tests/include_test1/mod.rs
index 3a6afa9..ca4894d 100644
--- a/tests/include_test1/mod.rs
+++ b/tests/include_test1/mod.rs
@@ -1,4 +1,5 @@
// Automatically generated by the Flatbuffers compiler. Do not modify.
+// @generated
pub mod my_game {
use super::*;
pub mod other_name_space {
diff --git a/tests/include_test1/my_game/other_name_space/from_include_generated.rs b/tests/include_test1/my_game/other_name_space/from_include_generated.rs
index 048bafd..3c5165d 100644
--- a/tests/include_test1/my_game/other_name_space/from_include_generated.rs
+++ b/tests/include_test1/my_game/other_name_space/from_include_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -34,8 +39,8 @@
}
}
}
-impl std::fmt::Debug for FromInclude {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for FromInclude {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
if let Some(name) = self.variant_name() {
f.write_str(name)
} else {
diff --git a/tests/include_test1/my_game/other_name_space/table_b_generated.rs b/tests/include_test1/my_game/other_name_space/table_b_generated.rs
index 46a99cb..da7b937 100644
--- a/tests/include_test1/my_game/other_name_space/table_b_generated.rs
+++ b/tests/include_test1/my_game/other_name_space/table_b_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum TableBOffset {}
@@ -103,8 +108,8 @@
}
}
-impl std::fmt::Debug for TableB<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TableB<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("TableB");
ds.field("a", &self.a());
ds.finish()
diff --git a/tests/include_test1/my_game/other_name_space/unused_generated.rs b/tests/include_test1/my_game/other_name_space/unused_generated.rs
index 1dc5913..1e4ad9c 100644
--- a/tests/include_test1/my_game/other_name_space/unused_generated.rs
+++ b/tests/include_test1/my_game/other_name_space/unused_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
// struct Unused, aligned to 4
@@ -13,8 +18,8 @@
Self([0; 4])
}
}
-impl std::fmt::Debug for Unused {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Unused {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Unused")
.field("a", &self.a())
.finish()
@@ -42,7 +47,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(self as *const Unused as *const u8, Self::size())
+ ::core::slice::from_raw_parts(self as *const Unused as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
@@ -53,7 +58,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(*self as *const Unused as *const u8, Self::size())
+ ::core::slice::from_raw_parts(*self as *const Unused as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
diff --git a/tests/include_test1/table_a_generated.rs b/tests/include_test1/table_a_generated.rs
index 9188b29..0e6a78d 100644
--- a/tests/include_test1/table_a_generated.rs
+++ b/tests/include_test1/table_a_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum TableAOffset {}
@@ -103,8 +108,8 @@
}
}
-impl std::fmt::Debug for TableA<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TableA<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("TableA");
ds.field("b", &self.b());
ds.finish()
diff --git a/tests/include_test2/mod.rs b/tests/include_test2/mod.rs
index 3a6afa9..ca4894d 100644
--- a/tests/include_test2/mod.rs
+++ b/tests/include_test2/mod.rs
@@ -1,4 +1,5 @@
// Automatically generated by the Flatbuffers compiler. Do not modify.
+// @generated
pub mod my_game {
use super::*;
pub mod other_name_space {
diff --git a/tests/include_test2/my_game/other_name_space/from_include_generated.rs b/tests/include_test2/my_game/other_name_space/from_include_generated.rs
index 048bafd..3c5165d 100644
--- a/tests/include_test2/my_game/other_name_space/from_include_generated.rs
+++ b/tests/include_test2/my_game/other_name_space/from_include_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -34,8 +39,8 @@
}
}
}
-impl std::fmt::Debug for FromInclude {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for FromInclude {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
if let Some(name) = self.variant_name() {
f.write_str(name)
} else {
diff --git a/tests/include_test2/my_game/other_name_space/table_b_generated.rs b/tests/include_test2/my_game/other_name_space/table_b_generated.rs
index 46a99cb..da7b937 100644
--- a/tests/include_test2/my_game/other_name_space/table_b_generated.rs
+++ b/tests/include_test2/my_game/other_name_space/table_b_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum TableBOffset {}
@@ -103,8 +108,8 @@
}
}
-impl std::fmt::Debug for TableB<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TableB<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("TableB");
ds.field("a", &self.a());
ds.finish()
diff --git a/tests/include_test2/my_game/other_name_space/unused_generated.rs b/tests/include_test2/my_game/other_name_space/unused_generated.rs
index 1dc5913..1e4ad9c 100644
--- a/tests/include_test2/my_game/other_name_space/unused_generated.rs
+++ b/tests/include_test2/my_game/other_name_space/unused_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
// struct Unused, aligned to 4
@@ -13,8 +18,8 @@
Self([0; 4])
}
}
-impl std::fmt::Debug for Unused {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Unused {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Unused")
.field("a", &self.a())
.finish()
@@ -42,7 +47,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(self as *const Unused as *const u8, Self::size())
+ ::core::slice::from_raw_parts(self as *const Unused as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
@@ -53,7 +58,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(*self as *const Unused as *const u8, Self::size())
+ ::core::slice::from_raw_parts(*self as *const Unused as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
diff --git a/tests/include_test2/table_a_generated.rs b/tests/include_test2/table_a_generated.rs
index 9188b29..0e6a78d 100644
--- a/tests/include_test2/table_a_generated.rs
+++ b/tests/include_test2/table_a_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum TableAOffset {}
@@ -103,8 +108,8 @@
}
}
-impl std::fmt::Debug for TableA<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TableA<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("TableA");
ds.field("b", &self.b());
ds.finish()
diff --git a/tests/is_quiet_nan.h b/tests/is_quiet_nan.h
new file mode 100644
index 0000000..6d31c3d
--- /dev/null
+++ b/tests/is_quiet_nan.h
@@ -0,0 +1,41 @@
+#ifndef TESTS_IS_QUIET_NAN_H
+#define TESTS_IS_QUIET_NAN_H
+
+namespace flatbuffers {
+namespace tests {
+
+#if defined(FLATBUFFERS_HAS_NEW_STRTOD) && (FLATBUFFERS_HAS_NEW_STRTOD > 0)
+// The IEEE-754 quiet_NaN is not simple binary constant.
+// All binary NaN bit strings have all the bits of the biased exponent field E
+// set to 1. A quiet NaN bit string should be encoded with the first bit d[1]
+// of the trailing significand field T being 1 (d[0] is implicit bit).
+// It is assumed that endianness of floating-point is same as integer.
+template<typename T, typename U, U qnan_base> bool is_quiet_nan_impl(T v) {
+ static_assert(sizeof(T) == sizeof(U), "unexpected");
+ U b = 0;
+ std::memcpy(&b, &v, sizeof(T));
+ return ((b & qnan_base) == qnan_base);
+}
+# if defined(__mips__) || defined(__hppa__)
+inline bool is_quiet_nan(float v) {
+ return is_quiet_nan_impl<float, uint32_t, 0x7FC00000u>(v) ||
+ is_quiet_nan_impl<float, uint32_t, 0x7FBFFFFFu>(v);
+}
+inline bool is_quiet_nan(double v) {
+ return is_quiet_nan_impl<double, uint64_t, 0x7FF8000000000000ul>(v) ||
+ is_quiet_nan_impl<double, uint64_t, 0x7FF7FFFFFFFFFFFFu>(v);
+}
+# else
+inline bool is_quiet_nan(float v) {
+ return is_quiet_nan_impl<float, uint32_t, 0x7FC00000u>(v);
+}
+inline bool is_quiet_nan(double v) {
+ return is_quiet_nan_impl<double, uint64_t, 0x7FF8000000000000ul>(v);
+}
+# endif
+#endif
+
+} // namespace tests
+} // namespace flatbuffers
+
+#endif // TESTS_IS_QUIET_NAN_H
diff --git a/tests/json_test.cpp b/tests/json_test.cpp
new file mode 100644
index 0000000..6d4064f
--- /dev/null
+++ b/tests/json_test.cpp
@@ -0,0 +1,174 @@
+#include "json_test.h"
+
+#include "flatbuffers/flatbuffers.h"
+#include "flatbuffers/idl.h"
+#include "monster_test_generated.h"
+#include "monster_test_bfbs_generated.h"
+#include "optional_scalars_generated.h"
+#include "test_assert.h"
+
+namespace flatbuffers {
+namespace tests {
+
+using namespace MyGame::Example;
+
+// Check stringify of an default enum value to json
+void JsonDefaultTest(const std::string& tests_data_path) {
+ // load FlatBuffer schema (.fbs) from disk
+ std::string schemafile;
+ TEST_EQ(flatbuffers::LoadFile((tests_data_path + "monster_test.fbs").c_str(),
+ false, &schemafile),
+ true);
+ // parse schema first, so we can use it to parse the data after
+ flatbuffers::Parser parser;
+ auto include_test_path =
+ flatbuffers::ConCatPathFileName(tests_data_path, "include_test");
+ const char *include_directories[] = { tests_data_path.c_str(),
+ include_test_path.c_str(), nullptr };
+
+ TEST_EQ(parser.Parse(schemafile.c_str(), include_directories), true);
+ // create incomplete monster and store to json
+ parser.opts.output_default_scalars_in_json = true;
+ parser.opts.output_enum_identifiers = true;
+ flatbuffers::FlatBufferBuilder builder;
+ auto name = builder.CreateString("default_enum");
+ MonsterBuilder color_monster(builder);
+ color_monster.add_name(name);
+ FinishMonsterBuffer(builder, color_monster.Finish());
+ std::string jsongen;
+ auto result = GenerateText(parser, builder.GetBufferPointer(), &jsongen);
+ TEST_EQ(result, true);
+ // default value of the "color" field is Blue
+ TEST_EQ(std::string::npos != jsongen.find("color: \"Blue\""), true);
+ // default value of the "testf" field is 3.14159
+ TEST_EQ(std::string::npos != jsongen.find("testf: 3.14159"), true);
+}
+
+void JsonEnumsTest(const std::string& tests_data_path) {
+ // load FlatBuffer schema (.fbs) from disk
+ std::string schemafile;
+ TEST_EQ(flatbuffers::LoadFile((tests_data_path + "monster_test.fbs").c_str(),
+ false, &schemafile),
+ true);
+ // parse schema first, so we can use it to parse the data after
+ flatbuffers::Parser parser;
+ auto include_test_path =
+ flatbuffers::ConCatPathFileName(tests_data_path, "include_test");
+ const char *include_directories[] = { tests_data_path.c_str(),
+ include_test_path.c_str(), nullptr };
+ parser.opts.output_enum_identifiers = true;
+ TEST_EQ(parser.Parse(schemafile.c_str(), include_directories), true);
+ flatbuffers::FlatBufferBuilder builder;
+ auto name = builder.CreateString("bitflag_enum");
+ MonsterBuilder color_monster(builder);
+ color_monster.add_name(name);
+ color_monster.add_color(Color(Color_Blue | Color_Red));
+ FinishMonsterBuffer(builder, color_monster.Finish());
+ std::string jsongen;
+ auto result = GenerateText(parser, builder.GetBufferPointer(), &jsongen);
+ TEST_EQ(result, true);
+ TEST_EQ(std::string::npos != jsongen.find("color: \"Red Blue\""), true);
+ // Test forward compatibility with 'output_enum_identifiers = true'.
+ // Current Color doesn't have '(1u << 2)' field, let's add it.
+ builder.Clear();
+ std::string future_json;
+ auto future_name = builder.CreateString("future bitflag_enum");
+ MonsterBuilder future_color(builder);
+ future_color.add_name(future_name);
+ future_color.add_color(
+ static_cast<Color>((1u << 2) | Color_Blue | Color_Red));
+ FinishMonsterBuffer(builder, future_color.Finish());
+ result = GenerateText(parser, builder.GetBufferPointer(), &future_json);
+ TEST_EQ(result, true);
+ TEST_EQ(std::string::npos != future_json.find("color: 13"), true);
+}
+
+void JsonOptionalTest(const std::string& tests_data_path, bool default_scalars) {
+ // load FlatBuffer schema (.fbs) and JSON from disk
+ std::string schemafile;
+ std::string jsonfile;
+ TEST_EQ(
+ flatbuffers::LoadFile((tests_data_path + "optional_scalars.fbs").c_str(),
+ false, &schemafile),
+ true);
+ TEST_EQ(flatbuffers::LoadFile((tests_data_path + "optional_scalars" +
+ (default_scalars ? "_defaults" : "") + ".json")
+ .c_str(),
+ false, &jsonfile),
+ true);
+
+ auto include_test_path =
+ flatbuffers::ConCatPathFileName(tests_data_path, "include_test");
+ const char *include_directories[] = { tests_data_path.c_str(),
+ include_test_path.c_str(), nullptr };
+
+ // parse schema first, so we can use it to parse the data after
+ flatbuffers::Parser parser;
+ parser.opts.output_default_scalars_in_json = default_scalars;
+ TEST_EQ(parser.Parse(schemafile.c_str(), include_directories), true);
+ TEST_EQ(parser.ParseJson(jsonfile.c_str()), true);
+
+ // here, parser.builder_ contains a binary buffer that is the parsed data.
+
+ // First, verify it, just in case:
+ flatbuffers::Verifier verifier(parser.builder_.GetBufferPointer(),
+ parser.builder_.GetSize());
+ TEST_EQ(optional_scalars::VerifyScalarStuffBuffer(verifier), true);
+
+ // to ensure it is correct, we now generate text back from the binary,
+ // and compare the two:
+ std::string jsongen;
+ auto result =
+ GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen);
+ TEST_EQ(result, true);
+ TEST_EQ_STR(jsongen.c_str(), jsonfile.c_str());
+}
+
+void ParseIncorrectMonsterJsonTest(const std::string& tests_data_path) {
+ std::string schemafile;
+ TEST_EQ(flatbuffers::LoadFile((tests_data_path + "monster_test.bfbs").c_str(),
+ true, &schemafile),
+ true);
+ flatbuffers::Parser parser;
+ flatbuffers::Verifier verifier(
+ reinterpret_cast<const uint8_t *>(schemafile.c_str()), schemafile.size());
+ TEST_EQ(reflection::VerifySchemaBuffer(verifier), true);
+ TEST_EQ(
+ parser.Deserialize(reinterpret_cast<const uint8_t *>(schemafile.c_str()),
+ schemafile.size()),
+ true);
+ TEST_EQ(parser.ParseJson("{name:\"monster\"}"), true);
+ TEST_EQ(parser.ParseJson(""), false);
+ TEST_EQ(parser.ParseJson("{name: 1}"), false);
+ TEST_EQ(parser.ParseJson("{name:+1}"), false);
+ TEST_EQ(parser.ParseJson("{name:-1}"), false);
+ TEST_EQ(parser.ParseJson("{name:-f}"), false);
+ TEST_EQ(parser.ParseJson("{name:+f}"), false);
+}
+
+void JsonUnsortedArrayTest() {
+ flatbuffers::Parser parser;
+ TEST_EQ(parser.Deserialize(MyGame::Example::MonsterBinarySchema::data(),
+ MyGame::Example::MonsterBinarySchema::size()),
+ true);
+ auto jsonStr = R"(
+ {
+ "name": "lookupTest",
+ "testarrayoftables": [
+ { "name": "aaa" },
+ { "name": "ccc" },
+ { "name": "bbb" }
+ ]
+ }
+ )";
+ TEST_EQ(parser.ParseJson(jsonStr), true);
+ auto monster = flatbuffers::GetRoot<MyGame::Example::Monster>(
+ parser.builder_.GetBufferPointer());
+
+ TEST_NOTNULL(monster->testarrayoftables()->LookupByKey("aaa"));
+ TEST_NOTNULL(monster->testarrayoftables()->LookupByKey("bbb"));
+ TEST_NOTNULL(monster->testarrayoftables()->LookupByKey("ccc"));
+}
+
+} // namespace tests
+} // namespace flatbuffers
\ No newline at end of file
diff --git a/tests/json_test.h b/tests/json_test.h
new file mode 100644
index 0000000..fe6efd4
--- /dev/null
+++ b/tests/json_test.h
@@ -0,0 +1,18 @@
+#ifndef TESTS_JSON_TEST_H
+#define TESTS_JSON_TEST_H
+
+#include <string>
+
+namespace flatbuffers {
+namespace tests {
+
+void JsonDefaultTest(const std::string& tests_data_path);
+void JsonEnumsTest(const std::string& tests_data_path);
+void JsonOptionalTest(const std::string& tests_data_path, bool default_scalars);
+void ParseIncorrectMonsterJsonTest(const std::string& tests_data_path);
+void JsonUnsortedArrayTest();
+
+} // namespace tests
+} // namespace flatbuffers
+
+#endif
\ No newline at end of file
diff --git a/tests/keyword_test.fbs b/tests/keyword_test.fbs
index 4ca761b..77fc42b 100644
--- a/tests/keyword_test.fbs
+++ b/tests/keyword_test.fbs
@@ -8,6 +8,7 @@
is: ABC = void;
private: public;
type: int;
+ default: bool = false;
}
union KeywordsInUnion {
diff --git a/tests/keyword_test/keyword_test/abc_generated.rs b/tests/keyword_test/keyword_test/abc_generated.rs
index 99b43e4..823b883 100644
--- a/tests/keyword_test/keyword_test/abc_generated.rs
+++ b/tests/keyword_test/keyword_test/abc_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -42,8 +47,8 @@
}
}
}
-impl std::fmt::Debug for ABC {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for ABC {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
if let Some(name) = self.variant_name() {
f.write_str(name)
} else {
diff --git a/tests/keyword_test/keyword_test/keywords_in_table_generated.rs b/tests/keyword_test/keyword_test/keywords_in_table_generated.rs
index 6a16f05..74ddfba 100644
--- a/tests/keyword_test/keyword_test/keywords_in_table_generated.rs
+++ b/tests/keyword_test/keyword_test/keywords_in_table_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum KeywordsInTableOffset {}
@@ -23,6 +28,7 @@
pub const VT_IS: flatbuffers::VOffsetT = 4;
pub const VT_PRIVATE: flatbuffers::VOffsetT = 6;
pub const VT_TYPE_: flatbuffers::VOffsetT = 8;
+ pub const VT_DEFAULT: flatbuffers::VOffsetT = 10;
pub const fn get_fully_qualified_name() -> &'static str {
"KeywordTest.KeywordsInTable"
@@ -41,6 +47,7 @@
builder.add_type_(args.type_);
builder.add_private(args.private);
builder.add_is(args.is);
+ builder.add_default(args.default);
builder.finish()
}
@@ -48,10 +55,12 @@
let is = self.is();
let private = self.private();
let type_ = self.type_();
+ let default = self.default();
KeywordsInTableT {
is,
private,
type_,
+ default,
}
}
@@ -67,6 +76,10 @@
pub fn type_(&self) -> i32 {
self._tab.get::<i32>(KeywordsInTable::VT_TYPE_, Some(0)).unwrap()
}
+ #[inline]
+ pub fn default(&self) -> bool {
+ self._tab.get::<bool>(KeywordsInTable::VT_DEFAULT, Some(false)).unwrap()
+ }
}
impl flatbuffers::Verifiable for KeywordsInTable<'_> {
@@ -79,6 +92,7 @@
.visit_field::<ABC>("is", Self::VT_IS, false)?
.visit_field::<public>("private", Self::VT_PRIVATE, false)?
.visit_field::<i32>("type_", Self::VT_TYPE_, false)?
+ .visit_field::<bool>("default", Self::VT_DEFAULT, false)?
.finish();
Ok(())
}
@@ -87,6 +101,7 @@
pub is: ABC,
pub private: public,
pub type_: i32,
+ pub default: bool,
}
impl<'a> Default for KeywordsInTableArgs {
#[inline]
@@ -95,6 +110,7 @@
is: ABC::void,
private: public::NONE,
type_: 0,
+ default: false,
}
}
}
@@ -117,6 +133,10 @@
self.fbb_.push_slot::<i32>(KeywordsInTable::VT_TYPE_, type_, 0);
}
#[inline]
+ pub fn add_default(&mut self, default: bool) {
+ self.fbb_.push_slot::<bool>(KeywordsInTable::VT_DEFAULT, default, false);
+ }
+ #[inline]
pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> KeywordsInTableBuilder<'a, 'b> {
let start = _fbb.start_table();
KeywordsInTableBuilder {
@@ -131,12 +151,13 @@
}
}
-impl std::fmt::Debug for KeywordsInTable<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for KeywordsInTable<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("KeywordsInTable");
ds.field("is", &self.is());
ds.field("private", &self.private());
ds.field("type_", &self.type_());
+ ds.field("default", &self.default());
ds.finish()
}
}
@@ -146,6 +167,7 @@
pub is: ABC,
pub private: public,
pub type_: i32,
+ pub default: bool,
}
impl Default for KeywordsInTableT {
fn default() -> Self {
@@ -153,6 +175,7 @@
is: ABC::void,
private: public::NONE,
type_: 0,
+ default: false,
}
}
}
@@ -164,10 +187,12 @@
let is = self.is;
let private = self.private;
let type_ = self.type_;
+ let default = self.default;
KeywordsInTable::create(_fbb, &KeywordsInTableArgs{
is,
private,
type_,
+ default,
})
}
}
diff --git a/tests/keyword_test/keyword_test/keywords_in_union_generated.rs b/tests/keyword_test/keyword_test/keywords_in_union_generated.rs
index cf03797..78d8cd7 100644
--- a/tests/keyword_test/keyword_test/keywords_in_union_generated.rs
+++ b/tests/keyword_test/keyword_test/keywords_in_union_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -42,8 +47,8 @@
}
}
}
-impl std::fmt::Debug for KeywordsInUnion {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for KeywordsInUnion {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
if let Some(name) = self.variant_name() {
f.write_str(name)
} else {
@@ -128,7 +133,7 @@
/// If the union variant matches, return the owned KeywordsInTableT, setting the union to NONE.
pub fn take_static_(&mut self) -> Option<Box<KeywordsInTableT>> {
if let Self::Static_(_) = self {
- let v = std::mem::replace(self, Self::NONE);
+ let v = core::mem::replace(self, Self::NONE);
if let Self::Static_(w) = v {
Some(w)
} else {
@@ -149,7 +154,7 @@
/// If the union variant matches, return the owned KeywordsInTableT, setting the union to NONE.
pub fn take_internal(&mut self) -> Option<Box<KeywordsInTableT>> {
if let Self::Internal(_) = self {
- let v = std::mem::replace(self, Self::NONE);
+ let v = core::mem::replace(self, Self::NONE);
if let Self::Internal(w) = v {
Some(w)
} else {
diff --git a/tests/keyword_test/keyword_test/public_generated.rs b/tests/keyword_test/keyword_test/public_generated.rs
index 2de4c0b..76c6ed0 100644
--- a/tests/keyword_test/keyword_test/public_generated.rs
+++ b/tests/keyword_test/keyword_test/public_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -34,8 +39,8 @@
}
}
}
-impl std::fmt::Debug for public {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for public {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
if let Some(name) = self.variant_name() {
f.write_str(name)
} else {
diff --git a/tests/keyword_test/mod.rs b/tests/keyword_test/mod.rs
index 94ce650..d87e5d1 100644
--- a/tests/keyword_test/mod.rs
+++ b/tests/keyword_test/mod.rs
@@ -1,4 +1,5 @@
// Automatically generated by the Flatbuffers compiler. Do not modify.
+// @generated
pub mod keyword_test {
use super::*;
mod abc_generated;
diff --git a/tests/monster_extra_generated.h b/tests/monster_extra_generated.h
index b27e092..b224677 100644
--- a/tests/monster_extra_generated.h
+++ b/tests/monster_extra_generated.h
@@ -6,6 +6,13 @@
#include "flatbuffers/flatbuffers.h"
+// Ensure the included flatbuffers.h is the same version as when this file was
+// generated, otherwise it may not be compatible.
+static_assert(FLATBUFFERS_VERSION_MAJOR == 2 &&
+ FLATBUFFERS_VERSION_MINOR == 0 &&
+ FLATBUFFERS_VERSION_REVISION == 8,
+ "Non-compatible flatbuffers version included");
+
namespace MyGame {
struct MonsterExtra;
@@ -268,8 +275,8 @@
{ auto _e = f1(); _o->f1 = _e; }
{ auto _e = f2(); _o->f2 = _e; }
{ auto _e = f3(); _o->f3 = _e; }
- { auto _e = dvec(); if (_e) { _o->dvec.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->dvec[_i] = _e->Get(_i); } } }
- { auto _e = fvec(); if (_e) { _o->fvec.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->fvec[_i] = _e->Get(_i); } } }
+ { auto _e = dvec(); if (_e) { _o->dvec.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->dvec[_i] = _e->Get(_i); } } else { _o->dvec.resize(0); } }
+ { auto _e = fvec(); if (_e) { _o->fvec.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->fvec[_i] = _e->Get(_i); } } else { _o->fvec.resize(0); } }
}
inline flatbuffers::Offset<MonsterExtra> MonsterExtra::Pack(flatbuffers::FlatBufferBuilder &_fbb, const MonsterExtraT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
diff --git a/tests/monster_extra_my_game_generated.dart b/tests/monster_extra_my_game_generated.dart
index 238ab8f..26310be 100644
--- a/tests/monster_extra_my_game_generated.dart
+++ b/tests/monster_extra_my_game_generated.dart
@@ -32,7 +32,7 @@
@override
String toString() {
- return 'MonsterExtra{d0: $d0, d1: $d1, d2: $d2, d3: $d3, f0: $f0, f1: $f1, f2: $f2, f3: $f3, dvec: $dvec, fvec: $fvec}';
+ return 'MonsterExtra{d0: ${d0}, d1: ${d1}, d2: ${d2}, d3: ${d3}, f0: ${f0}, f1: ${f1}, f2: ${f2}, f3: ${f3}, dvec: ${dvec}, fvec: ${fvec}}';
}
MonsterExtraT unpack() => MonsterExtraT(
@@ -99,7 +99,7 @@
@override
String toString() {
- return 'MonsterExtraT{d0: $d0, d1: $d1, d2: $d2, d3: $d3, f0: $f0, f1: $f1, f2: $f2, f3: $f3, dvec: $dvec, fvec: $fvec}';
+ return 'MonsterExtraT{d0: ${d0}, d1: ${d1}, d2: ${d2}, d3: ${d3}, f0: ${f0}, f1: ${f1}, f2: ${f2}, f3: ${f3}, dvec: ${dvec}, fvec: ${fvec}}';
}
}
diff --git a/tests/monster_test.afb b/tests/monster_test.afb
new file mode 100644
index 0000000..b98933a
--- /dev/null
+++ b/tests/monster_test.afb
@@ -0,0 +1,6647 @@
+// Annotated Flatbuffer Binary
+//
+// Schema file: ../reflection/reflection.fbs
+// Binary file: monster_test.bfbs
+
+header:
+ +0x0000 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x001C | offset to root table `reflection.Schema`
+ +0x0004 | 42 46 42 53 | char[4] | BFBS | File Identifier
+
+vtable (reflection.Schema):
+ +0x0008 | 14 00 | uint16_t | 0x0014 (20) | size of this vtable
+ +0x000A | 20 00 | uint16_t | 0x0020 (32) | size of referring table
+ +0x000C | 04 00 | VOffset16 | 0x0004 (4) | offset to field `objects` (id: 0)
+ +0x000E | 08 00 | VOffset16 | 0x0008 (8) | offset to field `enums` (id: 1)
+ +0x0010 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `file_ident` (id: 2)
+ +0x0012 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `file_ext` (id: 3)
+ +0x0014 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `root_table` (id: 4)
+ +0x0016 | 18 00 | VOffset16 | 0x0018 (24) | offset to field `services` (id: 5)
+ +0x0018 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `advanced_features` (id: 6) <defaults to 0> (ULong)
+ +0x001A | 1C 00 | VOffset16 | 0x001C (28) | offset to field `fbs_files` (id: 7)
+
+root_table (reflection.Schema):
+ +0x001C | 14 00 00 00 | SOffset32 | 0x00000014 (20) Loc: +0x0008 | offset to vtable
+ +0x0020 | 58 00 00 00 | UOffset32 | 0x00000058 (88) Loc: +0x0078 | offset to field `objects` (vector)
+ +0x0024 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x0058 | offset to field `enums` (vector)
+ +0x0028 | 24 00 00 00 | UOffset32 | 0x00000024 (36) Loc: +0x004C | offset to field `file_ident` (string)
+ +0x002C | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x0044 | offset to field `file_ext` (string)
+ +0x0030 | A0 0E 00 00 | UOffset32 | 0x00000EA0 (3744) Loc: +0x0ED0 | offset to field `root_table` (table)
+ +0x0034 | 08 00 00 00 | UOffset32 | 0x00000008 (8) Loc: +0x003C | offset to field `services` (vector)
+ +0x0038 | 80 00 00 00 | UOffset32 | 0x00000080 (128) Loc: +0x00B8 | offset to field `fbs_files` (vector)
+
+vector (reflection.Schema.services):
+ +0x003C | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x0040 | DC 00 00 00 | UOffset32 | 0x000000DC (220) Loc: +0x011C | offset to table[0]
+
+string (reflection.Schema.file_ext):
+ +0x0044 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x0048 | 6D 6F 6E | char[3] | mon | string literal
+ +0x004B | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.Schema.file_ident):
+ +0x004C | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x0050 | 4D 4F 4E 53 | char[4] | MONS | string literal
+ +0x0054 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x0055 | 00 00 00 | uint8_t[3] | ... | padding
+
+vector (reflection.Schema.enums):
+ +0x0058 | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of vector (# items)
+ +0x005C | 4C 05 00 00 | UOffset32 | 0x0000054C (1356) Loc: +0x05A8 | offset to table[0]
+ +0x0060 | B8 02 00 00 | UOffset32 | 0x000002B8 (696) Loc: +0x0318 | offset to table[1]
+ +0x0064 | F8 03 00 00 | UOffset32 | 0x000003F8 (1016) Loc: +0x045C | offset to table[2]
+ +0x0068 | 04 09 00 00 | UOffset32 | 0x00000904 (2308) Loc: +0x096C | offset to table[3]
+ +0x006C | 90 06 00 00 | UOffset32 | 0x00000690 (1680) Loc: +0x06FC | offset to table[4]
+ +0x0070 | BC 07 00 00 | UOffset32 | 0x000007BC (1980) Loc: +0x082C | offset to table[5]
+ +0x0074 | EC 0A 00 00 | UOffset32 | 0x00000AEC (2796) Loc: +0x0B60 | offset to table[6]
+
+vector (reflection.Schema.objects):
+ +0x0078 | 0F 00 00 00 | uint32_t | 0x0000000F (15) | length of vector (# items)
+ +0x007C | 9C 31 00 00 | UOffset32 | 0x0000319C (12700) Loc: +0x3218 | offset to table[0]
+ +0x0080 | 50 0E 00 00 | UOffset32 | 0x00000E50 (3664) Loc: +0x0ED0 | offset to table[1]
+ +0x0084 | E8 2D 00 00 | UOffset32 | 0x00002DE8 (11752) Loc: +0x2E6C | offset to table[2]
+ +0x0088 | C4 2E 00 00 | UOffset32 | 0x00002EC4 (11972) Loc: +0x2F4C | offset to table[3]
+ +0x008C | 64 30 00 00 | UOffset32 | 0x00003064 (12388) Loc: +0x30F0 | offset to table[4]
+ +0x0090 | D8 2F 00 00 | UOffset32 | 0x00002FD8 (12248) Loc: +0x3068 | offset to table[5]
+ +0x0094 | A0 35 00 00 | UOffset32 | 0x000035A0 (13728) Loc: +0x3634 | offset to table[6]
+ +0x0098 | 80 34 00 00 | UOffset32 | 0x00003480 (13440) Loc: +0x3518 | offset to table[7]
+ +0x009C | 70 0B 00 00 | UOffset32 | 0x00000B70 (2928) Loc: +0x0C0C | offset to table[8]
+ +0x00A0 | 78 32 00 00 | UOffset32 | 0x00003278 (12920) Loc: +0x3318 | offset to table[9]
+ +0x00A4 | 68 36 00 00 | UOffset32 | 0x00003668 (13928) Loc: +0x370C | offset to table[10]
+ +0x00A8 | A0 36 00 00 | UOffset32 | 0x000036A0 (13984) Loc: +0x3748 | offset to table[11]
+ +0x00AC | 90 37 00 00 | UOffset32 | 0x00003790 (14224) Loc: +0x383C | offset to table[12]
+ +0x00B0 | 44 38 00 00 | UOffset32 | 0x00003844 (14404) Loc: +0x38F4 | offset to table[13]
+ +0x00B4 | EC 36 00 00 | UOffset32 | 0x000036EC (14060) Loc: +0x37A0 | offset to table[14]
+
+vector (reflection.Schema.fbs_files):
+ +0x00B8 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x00BC | 38 00 00 00 | UOffset32 | 0x00000038 (56) Loc: +0x00F4 | offset to table[0]
+ +0x00C0 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x00DC | offset to table[1]
+ +0x00C4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00C8 | offset to table[2]
+
+table (reflection.SchemaFile):
+ +0x00C8 | 64 CB FF FF | SOffset32 | 0xFFFFCB64 (-13468) Loc: +0x3564 | offset to vtable
+ +0x00CC | 94 36 00 00 | UOffset32 | 0x00003694 (13972) Loc: +0x3760 | offset to field `key` (string)
+ +0x00D0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00D4 | offset to field `value` (string)
+
+string (reflection.SchemaFile.value):
+ +0x00D4 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x00D8 | E0 | char[1] | à | string literal
+ +0x00D9 | 36 | char | 0x36 (54) | string terminator
+
+padding:
+ +0x00DA | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.SchemaFile):
+ +0x00DC | 78 CB FF FF | SOffset32 | 0xFFFFCB78 (-13448) Loc: +0x3564 | offset to vtable
+ +0x00E0 | 34 38 00 00 | UOffset32 | 0x00003834 (14388) Loc: +0x3914 | offset to field `key` (string)
+ +0x00E4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x00E8 | offset to field `value` (string)
+
+string (reflection.SchemaFile.value):
+ +0x00E8 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x00EC | CC 36 | char[2] | Ì6 | string literal
+ +0x00EE | 00 | char | 0x00 (0) | string terminator
+
+unknown (no known references):
+ +0x00EF | 00 24 38 00 00 | ?uint8_t[5] | .$8.. | WARN: could be corrupted padding region.
+
+table (reflection.SchemaFile):
+ +0x00F4 | 90 CB FF FF | SOffset32 | 0xFFFFCB90 (-13424) Loc: +0x3564 | offset to vtable
+ +0x00F8 | C0 36 00 00 | UOffset32 | 0x000036C0 (14016) Loc: +0x37B8 | offset to field `key` (string)
+ +0x00FC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0100 | offset to field `value` (string)
+
+string (reflection.SchemaFile.value):
+ +0x0100 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x0104 | B4 36 | char[2] | ´6 | string literal
+ +0x0106 | 00 | char | 0x00 (0) | string terminator
+
+unknown (no known references):
+ +0x0107 | 00 0C 38 00 00 00 00 | ?uint8_t[7] | ..8.... | WARN: could be corrupted padding region.
+
+vtable (reflection.Service):
+ +0x010E | 0E 00 | uint16_t | 0x000E (14) | size of this vtable
+ +0x0110 | 14 00 | uint16_t | 0x0014 (20) | size of referring table
+ +0x0112 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `name` (id: 0)
+ +0x0114 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `calls` (id: 1)
+ +0x0116 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `attributes` (id: 2) <null> (Vector)
+ +0x0118 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `documentation` (id: 3)
+ +0x011A | 10 00 | VOffset16 | 0x0010 (16) | offset to field `declaration_file` (id: 4)
+
+table (reflection.Service):
+ +0x011C | 0E 00 00 00 | SOffset32 | 0x0000000E (14) Loc: +0x010E | offset to vtable
+ +0x0120 | 28 00 00 00 | UOffset32 | 0x00000028 (40) Loc: +0x0148 | offset to field `name` (string)
+ +0x0124 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x0134 | offset to field `calls` (vector)
+ +0x0128 | 08 00 00 00 | UOffset32 | 0x00000008 (8) Loc: +0x0130 | offset to field `documentation` (vector)
+ +0x012C | 34 36 00 00 | UOffset32 | 0x00003634 (13876) Loc: +0x3760 | offset to field `declaration_file` (string)
+
+vector (reflection.Service.documentation):
+ +0x0130 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Service.calls):
+ +0x0134 | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of vector (# items)
+ +0x0138 | 88 01 00 00 | UOffset32 | 0x00000188 (392) Loc: +0x02C0 | offset to table[0]
+ +0x013C | F4 00 00 00 | UOffset32 | 0x000000F4 (244) Loc: +0x0230 | offset to table[1]
+ +0x0140 | 90 00 00 00 | UOffset32 | 0x00000090 (144) Loc: +0x01D0 | offset to table[2]
+ +0x0144 | 28 00 00 00 | UOffset32 | 0x00000028 (40) Loc: +0x016C | offset to table[3]
+
+string (reflection.Service.name):
+ +0x0148 | 1D 00 00 00 | uint32_t | 0x0000001D (29) | length of string
+ +0x014C | 4D 79 47 61 6D 65 2E 45 | char[29] | MyGame.E | string literal
+ +0x0154 | 78 61 6D 70 6C 65 2E 4D | | xample.M
+ +0x015C | 6F 6E 73 74 65 72 53 74 | | onsterSt
+ +0x0164 | 6F 72 61 67 65 | | orage
+ +0x0169 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x016A | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.RPCCall):
+ +0x016C | BA FE FF FF | SOffset32 | 0xFFFFFEBA (-326) Loc: +0x02B2 | offset to vtable
+ +0x0170 | 48 00 00 00 | UOffset32 | 0x00000048 (72) Loc: +0x01B8 | offset to field `name` (string)
+ +0x0174 | 5C 0D 00 00 | UOffset32 | 0x00000D5C (3420) Loc: +0x0ED0 | offset to field `request` (table)
+ +0x0178 | D4 2D 00 00 | UOffset32 | 0x00002DD4 (11732) Loc: +0x2F4C | offset to field `response` (table)
+ +0x017C | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x0188 | offset to field `attributes` (vector)
+ +0x0180 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0184 | offset to field `documentation` (vector)
+
+vector (reflection.RPCCall.documentation):
+ +0x0184 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.RPCCall.attributes):
+ +0x0188 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x018C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0190 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x0190 | 2C CC FF FF | SOffset32 | 0xFFFFCC2C (-13268) Loc: +0x3564 | offset to vtable
+ +0x0194 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x01A8 | offset to field `key` (string)
+ +0x0198 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x019C | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x019C | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x01A0 | 62 69 64 69 | char[4] | bidi | string literal
+ +0x01A4 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x01A5 | 00 00 00 | uint8_t[3] | ... | padding
+
+string (reflection.KeyValue.key):
+ +0x01A8 | 09 00 00 00 | uint32_t | 0x00000009 (9) | length of string
+ +0x01AC | 73 74 72 65 61 6D 69 6E | char[9] | streamin | string literal
+ +0x01B4 | 67 | | g
+ +0x01B5 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x01B6 | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.RPCCall.name):
+ +0x01B8 | 12 00 00 00 | uint32_t | 0x00000012 (18) | length of string
+ +0x01BC | 47 65 74 4D 69 6E 4D 61 | char[18] | GetMinMa | string literal
+ +0x01C4 | 78 48 69 74 50 6F 69 6E | | xHitPoin
+ +0x01CC | 74 73 | | ts
+ +0x01CE | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.RPCCall):
+ +0x01D0 | 1E FF FF FF | SOffset32 | 0xFFFFFF1E (-226) Loc: +0x02B2 | offset to vtable
+ +0x01D4 | 48 00 00 00 | UOffset32 | 0x00000048 (72) Loc: +0x021C | offset to field `name` (string)
+ +0x01D8 | F8 0C 00 00 | UOffset32 | 0x00000CF8 (3320) Loc: +0x0ED0 | offset to field `request` (table)
+ +0x01DC | 70 2D 00 00 | UOffset32 | 0x00002D70 (11632) Loc: +0x2F4C | offset to field `response` (table)
+ +0x01E0 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x01EC | offset to field `attributes` (vector)
+ +0x01E4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x01E8 | offset to field `documentation` (vector)
+
+vector (reflection.RPCCall.documentation):
+ +0x01E8 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.RPCCall.attributes):
+ +0x01EC | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x01F0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x01F4 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x01F4 | 90 CC FF FF | SOffset32 | 0xFFFFCC90 (-13168) Loc: +0x3564 | offset to vtable
+ +0x01F8 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x020C | offset to field `key` (string)
+ +0x01FC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0200 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x0200 | 06 00 00 00 | uint32_t | 0x00000006 (6) | length of string
+ +0x0204 | 63 6C 69 65 6E 74 | char[6] | client | string literal
+ +0x020A | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x020C | 09 00 00 00 | uint32_t | 0x00000009 (9) | length of string
+ +0x0210 | 73 74 72 65 61 6D 69 6E | char[9] | streamin | string literal
+ +0x0218 | 67 | | g
+ +0x0219 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x021A | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.RPCCall.name):
+ +0x021C | 0E 00 00 00 | uint32_t | 0x0000000E (14) | length of string
+ +0x0220 | 47 65 74 4D 61 78 48 69 | char[14] | GetMaxHi | string literal
+ +0x0228 | 74 50 6F 69 6E 74 | | tPoint
+ +0x022E | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.RPCCall):
+ +0x0230 | 7E FF FF FF | SOffset32 | 0xFFFFFF7E (-130) Loc: +0x02B2 | offset to vtable
+ +0x0234 | 70 00 00 00 | UOffset32 | 0x00000070 (112) Loc: +0x02A4 | offset to field `name` (string)
+ +0x0238 | 14 2D 00 00 | UOffset32 | 0x00002D14 (11540) Loc: +0x2F4C | offset to field `request` (table)
+ +0x023C | 94 0C 00 00 | UOffset32 | 0x00000C94 (3220) Loc: +0x0ED0 | offset to field `response` (table)
+ +0x0240 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x024C | offset to field `attributes` (vector)
+ +0x0244 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0248 | offset to field `documentation` (vector)
+
+vector (reflection.RPCCall.documentation):
+ +0x0248 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.RPCCall.attributes):
+ +0x024C | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x0250 | 30 00 00 00 | UOffset32 | 0x00000030 (48) Loc: +0x0280 | offset to table[0]
+ +0x0254 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0258 | offset to table[1]
+
+table (reflection.KeyValue):
+ +0x0258 | F4 CC FF FF | SOffset32 | 0xFFFFCCF4 (-13068) Loc: +0x3564 | offset to vtable
+ +0x025C | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x0270 | offset to field `key` (string)
+ +0x0260 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0264 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x0264 | 06 00 00 00 | uint32_t | 0x00000006 (6) | length of string
+ +0x0268 | 73 65 72 76 65 72 | char[6] | server | string literal
+ +0x026E | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x0270 | 09 00 00 00 | uint32_t | 0x00000009 (9) | length of string
+ +0x0274 | 73 74 72 65 61 6D 69 6E | char[9] | streamin | string literal
+ +0x027C | 67 | | g
+ +0x027D | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x027E | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.KeyValue):
+ +0x0280 | 1C CD FF FF | SOffset32 | 0xFFFFCD1C (-13028) Loc: +0x3564 | offset to vtable
+ +0x0284 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x0294 | offset to field `key` (string)
+ +0x0288 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x028C | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x028C | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x0290 | 30 | char[1] | 0 | string literal
+ +0x0291 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x0292 | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x0294 | 0A 00 00 00 | uint32_t | 0x0000000A (10) | length of string
+ +0x0298 | 69 64 65 6D 70 6F 74 65 | char[10] | idempote | string literal
+ +0x02A0 | 6E 74 | | nt
+ +0x02A2 | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.RPCCall.name):
+ +0x02A4 | 08 00 00 00 | uint32_t | 0x00000008 (8) | length of string
+ +0x02A8 | 52 65 74 72 69 65 76 65 | char[8] | Retrieve | string literal
+ +0x02B0 | 00 | char | 0x00 (0) | string terminator
+
+vtable (reflection.RPCCall):
+ +0x02B2 | 0E 00 | uint16_t | 0x000E (14) | size of this vtable
+ +0x02B4 | 18 00 | uint16_t | 0x0018 (24) | size of referring table
+ +0x02B6 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `name` (id: 0)
+ +0x02B8 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `request` (id: 1)
+ +0x02BA | 0C 00 | VOffset16 | 0x000C (12) | offset to field `response` (id: 2)
+ +0x02BC | 10 00 | VOffset16 | 0x0010 (16) | offset to field `attributes` (id: 3)
+ +0x02BE | 14 00 | VOffset16 | 0x0014 (20) | offset to field `documentation` (id: 4)
+
+table (reflection.RPCCall):
+ +0x02C0 | 0E 00 00 00 | SOffset32 | 0x0000000E (14) Loc: +0x02B2 | offset to vtable
+ +0x02C4 | 48 00 00 00 | UOffset32 | 0x00000048 (72) Loc: +0x030C | offset to field `name` (string)
+ +0x02C8 | 08 0C 00 00 | UOffset32 | 0x00000C08 (3080) Loc: +0x0ED0 | offset to field `request` (table)
+ +0x02CC | 80 2C 00 00 | UOffset32 | 0x00002C80 (11392) Loc: +0x2F4C | offset to field `response` (table)
+ +0x02D0 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x02DC | offset to field `attributes` (vector)
+ +0x02D4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x02D8 | offset to field `documentation` (vector)
+
+vector (reflection.RPCCall.documentation):
+ +0x02D8 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.RPCCall.attributes):
+ +0x02DC | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x02E0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x02E4 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x02E4 | 80 CD FF FF | SOffset32 | 0xFFFFCD80 (-12928) Loc: +0x3564 | offset to vtable
+ +0x02E8 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x02FC | offset to field `key` (string)
+ +0x02EC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x02F0 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x02F0 | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x02F4 | 6E 6F 6E 65 | char[4] | none | string literal
+ +0x02F8 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x02F9 | 00 00 00 | uint8_t[3] | ... | padding
+
+string (reflection.KeyValue.key):
+ +0x02FC | 09 00 00 00 | uint32_t | 0x00000009 (9) | length of string
+ +0x0300 | 73 74 72 65 61 6D 69 6E | char[9] | streamin | string literal
+ +0x0308 | 67 | | g
+ +0x0309 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x030A | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.RPCCall.name):
+ +0x030C | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x0310 | 53 74 6F 72 65 | char[5] | Store | string literal
+ +0x0315 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x0316 | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Enum):
+ +0x0318 | 82 FD FF FF | SOffset32 | 0xFFFFFD82 (-638) Loc: +0x0596 | offset to vtable
+ +0x031C | 00 00 00 | uint8_t[3] | ... | padding
+ +0x031F | 01 | uint8_t | 0x01 (1) | table field `is_union` (Bool)
+ +0x0320 | 40 00 00 00 | UOffset32 | 0x00000040 (64) Loc: +0x0360 | offset to field `name` (string)
+ +0x0324 | 28 00 00 00 | UOffset32 | 0x00000028 (40) Loc: +0x034C | offset to field `values` (vector)
+ +0x0328 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x0338 | offset to field `underlying_type` (table)
+ +0x032C | 08 00 00 00 | UOffset32 | 0x00000008 (8) Loc: +0x0334 | offset to field `documentation` (vector)
+ +0x0330 | 30 34 00 00 | UOffset32 | 0x00003430 (13360) Loc: +0x3760 | offset to field `declaration_file` (string)
+
+vector (reflection.Enum.documentation):
+ +0x0334 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x0338 | 34 CD FF FF | SOffset32 | 0xFFFFCD34 (-13004) Loc: +0x3604 | offset to vtable
+ +0x033C | 00 00 00 | uint8_t[3] | ... | padding
+ +0x033F | 01 | uint8_t | 0x01 (1) | table field `base_type` (Byte)
+ +0x0340 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `index` (Int)
+ +0x0344 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x0348 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+vector (reflection.Enum.values):
+ +0x034C | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of vector (# items)
+ +0x0350 | E0 00 00 00 | UOffset32 | 0x000000E0 (224) Loc: +0x0430 | offset to table[0]
+ +0x0354 | A4 00 00 00 | UOffset32 | 0x000000A4 (164) Loc: +0x03F8 | offset to table[1]
+ +0x0358 | 68 00 00 00 | UOffset32 | 0x00000068 (104) Loc: +0x03C0 | offset to table[2]
+ +0x035C | 2C 00 00 00 | UOffset32 | 0x0000002C (44) Loc: +0x0388 | offset to table[3]
+
+string (reflection.Enum.name):
+ +0x0360 | 22 00 00 00 | uint32_t | 0x00000022 (34) | length of string
+ +0x0364 | 4D 79 47 61 6D 65 2E 45 | char[34] | MyGame.E | string literal
+ +0x036C | 78 61 6D 70 6C 65 2E 41 | | xample.A
+ +0x0374 | 6E 79 41 6D 62 69 67 75 | | nyAmbigu
+ +0x037C | 6F 75 73 41 6C 69 61 73 | | ousAlias
+ +0x0384 | 65 73 | | es
+ +0x0386 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.EnumVal):
+ +0x0388 | 7E F8 FF FF | SOffset32 | 0xFFFFF87E (-1922) Loc: +0x0B0A | offset to vtable
+ +0x038C | 2C 00 00 00 | UOffset32 | 0x0000002C (44) Loc: +0x03B8 | offset to field `name` (string)
+ +0x0390 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x03A8 | offset to field `union_type` (table)
+ +0x0394 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x03A4 | offset to field `documentation` (vector)
+ +0x0398 | 03 00 00 00 00 00 00 00 | int64_t | 0x0000000000000003 (3) | table field `value` (Long)
+ +0x03A0 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (reflection.EnumVal.documentation):
+ +0x03A4 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x03A8 | F0 CA FF FF | SOffset32 | 0xFFFFCAF0 (-13584) Loc: +0x38B8 | offset to vtable
+ +0x03AC | 00 00 00 | uint8_t[3] | ... | padding
+ +0x03AF | 0F | uint8_t | 0x0F (15) | table field `base_type` (Byte)
+ +0x03B0 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `index` (Int)
+ +0x03B4 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.EnumVal.name):
+ +0x03B8 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x03BC | 4D 33 | char[2] | M3 | string literal
+ +0x03BE | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.EnumVal):
+ +0x03C0 | B6 F8 FF FF | SOffset32 | 0xFFFFF8B6 (-1866) Loc: +0x0B0A | offset to vtable
+ +0x03C4 | 2C 00 00 00 | UOffset32 | 0x0000002C (44) Loc: +0x03F0 | offset to field `name` (string)
+ +0x03C8 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x03E0 | offset to field `union_type` (table)
+ +0x03CC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x03DC | offset to field `documentation` (vector)
+ +0x03D0 | 02 00 00 00 00 00 00 00 | int64_t | 0x0000000000000002 (2) | table field `value` (Long)
+ +0x03D8 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (reflection.EnumVal.documentation):
+ +0x03DC | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x03E0 | 28 CB FF FF | SOffset32 | 0xFFFFCB28 (-13528) Loc: +0x38B8 | offset to vtable
+ +0x03E4 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x03E7 | 0F | uint8_t | 0x0F (15) | table field `base_type` (Byte)
+ +0x03E8 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `index` (Int)
+ +0x03EC | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.EnumVal.name):
+ +0x03F0 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x03F4 | 4D 32 | char[2] | M2 | string literal
+ +0x03F6 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.EnumVal):
+ +0x03F8 | EE F8 FF FF | SOffset32 | 0xFFFFF8EE (-1810) Loc: +0x0B0A | offset to vtable
+ +0x03FC | 2C 00 00 00 | UOffset32 | 0x0000002C (44) Loc: +0x0428 | offset to field `name` (string)
+ +0x0400 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x0418 | offset to field `union_type` (table)
+ +0x0404 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x0414 | offset to field `documentation` (vector)
+ +0x0408 | 01 00 00 00 00 00 00 00 | int64_t | 0x0000000000000001 (1) | table field `value` (Long)
+ +0x0410 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (reflection.EnumVal.documentation):
+ +0x0414 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x0418 | 60 CB FF FF | SOffset32 | 0xFFFFCB60 (-13472) Loc: +0x38B8 | offset to vtable
+ +0x041C | 00 00 00 | uint8_t[3] | ... | padding
+ +0x041F | 0F | uint8_t | 0x0F (15) | table field `base_type` (Byte)
+ +0x0420 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `index` (Int)
+ +0x0424 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.EnumVal.name):
+ +0x0428 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x042C | 4D 31 | char[2] | M1 | string literal
+ +0x042E | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.EnumVal):
+ +0x0430 | 72 F8 FF FF | SOffset32 | 0xFFFFF872 (-1934) Loc: +0x0BBE | offset to vtable
+ +0x0434 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x0450 | offset to field `name` (string)
+ +0x0438 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x0444 | offset to field `union_type` (table)
+ +0x043C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0440 | offset to field `documentation` (vector)
+
+vector (reflection.EnumVal.documentation):
+ +0x0440 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x0444 | 64 F8 FF FF | SOffset32 | 0xFFFFF864 (-1948) Loc: +0x0BE0 | offset to vtable
+ +0x0448 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x044C | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.EnumVal.name):
+ +0x0450 | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x0454 | 4E 4F 4E 45 | char[4] | NONE | string literal
+ +0x0458 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x0459 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Enum):
+ +0x045C | C6 FE FF FF | SOffset32 | 0xFFFFFEC6 (-314) Loc: +0x0596 | offset to vtable
+ +0x0460 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x0463 | 01 | uint8_t | 0x01 (1) | table field `is_union` (Bool)
+ +0x0464 | 40 00 00 00 | UOffset32 | 0x00000040 (64) Loc: +0x04A4 | offset to field `name` (string)
+ +0x0468 | 28 00 00 00 | UOffset32 | 0x00000028 (40) Loc: +0x0490 | offset to field `values` (vector)
+ +0x046C | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x047C | offset to field `underlying_type` (table)
+ +0x0470 | 08 00 00 00 | UOffset32 | 0x00000008 (8) Loc: +0x0478 | offset to field `documentation` (vector)
+ +0x0474 | EC 32 00 00 | UOffset32 | 0x000032EC (13036) Loc: +0x3760 | offset to field `declaration_file` (string)
+
+vector (reflection.Enum.documentation):
+ +0x0478 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x047C | 78 CE FF FF | SOffset32 | 0xFFFFCE78 (-12680) Loc: +0x3604 | offset to vtable
+ +0x0480 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x0483 | 01 | uint8_t | 0x01 (1) | table field `base_type` (Byte)
+ +0x0484 | 02 00 00 00 | uint32_t | 0x00000002 (2) | table field `index` (Int)
+ +0x0488 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x048C | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+vector (reflection.Enum.values):
+ +0x0490 | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of vector (# items)
+ +0x0494 | D8 00 00 00 | UOffset32 | 0x000000D8 (216) Loc: +0x056C | offset to table[0]
+ +0x0498 | A0 00 00 00 | UOffset32 | 0x000000A0 (160) Loc: +0x0538 | offset to table[1]
+ +0x049C | 64 00 00 00 | UOffset32 | 0x00000064 (100) Loc: +0x0500 | offset to table[2]
+ +0x04A0 | 28 00 00 00 | UOffset32 | 0x00000028 (40) Loc: +0x04C8 | offset to table[3]
+
+string (reflection.Enum.name):
+ +0x04A4 | 1F 00 00 00 | uint32_t | 0x0000001F (31) | length of string
+ +0x04A8 | 4D 79 47 61 6D 65 2E 45 | char[31] | MyGame.E | string literal
+ +0x04B0 | 78 61 6D 70 6C 65 2E 41 | | xample.A
+ +0x04B8 | 6E 79 55 6E 69 71 75 65 | | nyUnique
+ +0x04C0 | 41 6C 69 61 73 65 73 | | Aliases
+ +0x04C7 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.EnumVal):
+ +0x04C8 | BE F9 FF FF | SOffset32 | 0xFFFFF9BE (-1602) Loc: +0x0B0A | offset to vtable
+ +0x04CC | 2C 00 00 00 | UOffset32 | 0x0000002C (44) Loc: +0x04F8 | offset to field `name` (string)
+ +0x04D0 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x04E8 | offset to field `union_type` (table)
+ +0x04D4 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x04E4 | offset to field `documentation` (vector)
+ +0x04D8 | 03 00 00 00 00 00 00 00 | int64_t | 0x0000000000000003 (3) | table field `value` (Long)
+ +0x04E0 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (reflection.EnumVal.documentation):
+ +0x04E4 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x04E8 | 30 CC FF FF | SOffset32 | 0xFFFFCC30 (-13264) Loc: +0x38B8 | offset to vtable
+ +0x04EC | 00 00 00 | uint8_t[3] | ... | padding
+ +0x04EF | 0F | uint8_t | 0x0F (15) | table field `base_type` (Byte)
+ +0x04F0 | 0A 00 00 00 | uint32_t | 0x0000000A (10) | table field `index` (Int)
+ +0x04F4 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.EnumVal.name):
+ +0x04F8 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x04FC | 4D 32 | char[2] | M2 | string literal
+ +0x04FE | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.EnumVal):
+ +0x0500 | F6 F9 FF FF | SOffset32 | 0xFFFFF9F6 (-1546) Loc: +0x0B0A | offset to vtable
+ +0x0504 | 2C 00 00 00 | UOffset32 | 0x0000002C (44) Loc: +0x0530 | offset to field `name` (string)
+ +0x0508 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x0520 | offset to field `union_type` (table)
+ +0x050C | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x051C | offset to field `documentation` (vector)
+ +0x0510 | 02 00 00 00 00 00 00 00 | int64_t | 0x0000000000000002 (2) | table field `value` (Long)
+ +0x0518 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (reflection.EnumVal.documentation):
+ +0x051C | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x0520 | 68 CC FF FF | SOffset32 | 0xFFFFCC68 (-13208) Loc: +0x38B8 | offset to vtable
+ +0x0524 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x0527 | 0F | uint8_t | 0x0F (15) | table field `base_type` (Byte)
+ +0x0528 | 07 00 00 00 | uint32_t | 0x00000007 (7) | table field `index` (Int)
+ +0x052C | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.EnumVal.name):
+ +0x0530 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x0534 | 54 53 | char[2] | TS | string literal
+ +0x0536 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.EnumVal):
+ +0x0538 | 1E FC FF FF | SOffset32 | 0xFFFFFC1E (-994) Loc: +0x091A | offset to vtable
+ +0x053C | 28 00 00 00 | UOffset32 | 0x00000028 (40) Loc: +0x0564 | offset to field `name` (string)
+ +0x0540 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x0554 | offset to field `union_type` (table)
+ +0x0544 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x0550 | offset to field `documentation` (vector)
+ +0x0548 | 01 00 00 00 00 00 00 00 | int64_t | 0x0000000000000001 (1) | table field `value` (Long)
+
+vector (reflection.EnumVal.documentation):
+ +0x0550 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x0554 | 9C CC FF FF | SOffset32 | 0xFFFFCC9C (-13156) Loc: +0x38B8 | offset to vtable
+ +0x0558 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x055B | 0F | uint8_t | 0x0F (15) | table field `base_type` (Byte)
+ +0x055C | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `index` (Int)
+ +0x0560 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.EnumVal.name):
+ +0x0564 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x0568 | 4D | char[1] | M | string literal
+ +0x0569 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x056A | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.EnumVal):
+ +0x056C | AE F9 FF FF | SOffset32 | 0xFFFFF9AE (-1618) Loc: +0x0BBE | offset to vtable
+ +0x0570 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x058C | offset to field `name` (string)
+ +0x0574 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x0580 | offset to field `union_type` (table)
+ +0x0578 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x057C | offset to field `documentation` (vector)
+
+vector (reflection.EnumVal.documentation):
+ +0x057C | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x0580 | A0 F9 FF FF | SOffset32 | 0xFFFFF9A0 (-1632) Loc: +0x0BE0 | offset to vtable
+ +0x0584 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x0588 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.EnumVal.name):
+ +0x058C | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x0590 | 4E 4F 4E 45 | char[4] | NONE | string literal
+ +0x0594 | 00 | char | 0x00 (0) | string terminator
+
+vtable (reflection.Enum):
+ +0x0596 | 12 00 | uint16_t | 0x0012 (18) | size of this vtable
+ +0x0598 | 1C 00 | uint16_t | 0x001C (28) | size of referring table
+ +0x059A | 08 00 | VOffset16 | 0x0008 (8) | offset to field `name` (id: 0)
+ +0x059C | 0C 00 | VOffset16 | 0x000C (12) | offset to field `values` (id: 1)
+ +0x059E | 07 00 | VOffset16 | 0x0007 (7) | offset to field `is_union` (id: 2)
+ +0x05A0 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `underlying_type` (id: 3)
+ +0x05A2 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `attributes` (id: 4) <null> (Vector)
+ +0x05A4 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `documentation` (id: 5)
+ +0x05A6 | 18 00 | VOffset16 | 0x0018 (24) | offset to field `declaration_file` (id: 6)
+
+table (reflection.Enum):
+ +0x05A8 | 12 00 00 00 | SOffset32 | 0x00000012 (18) Loc: +0x0596 | offset to vtable
+ +0x05AC | 00 00 00 | uint8_t[3] | ... | padding
+ +0x05AF | 01 | uint8_t | 0x01 (1) | table field `is_union` (Bool)
+ +0x05B0 | 40 00 00 00 | UOffset32 | 0x00000040 (64) Loc: +0x05F0 | offset to field `name` (string)
+ +0x05B4 | 28 00 00 00 | UOffset32 | 0x00000028 (40) Loc: +0x05DC | offset to field `values` (vector)
+ +0x05B8 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x05C8 | offset to field `underlying_type` (table)
+ +0x05BC | 08 00 00 00 | UOffset32 | 0x00000008 (8) Loc: +0x05C4 | offset to field `documentation` (vector)
+ +0x05C0 | A0 31 00 00 | UOffset32 | 0x000031A0 (12704) Loc: +0x3760 | offset to field `declaration_file` (string)
+
+vector (reflection.Enum.documentation):
+ +0x05C4 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x05C8 | C4 CF FF FF | SOffset32 | 0xFFFFCFC4 (-12348) Loc: +0x3604 | offset to vtable
+ +0x05CC | 00 00 00 | uint8_t[3] | ... | padding
+ +0x05CF | 01 | uint8_t | 0x01 (1) | table field `base_type` (Byte)
+ +0x05D0 | 00 00 00 00 | uint32_t | 0x00000000 (0) | table field `index` (Int)
+ +0x05D4 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x05D8 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+vector (reflection.Enum.values):
+ +0x05DC | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of vector (# items)
+ +0x05E0 | F0 00 00 00 | UOffset32 | 0x000000F0 (240) Loc: +0x06D0 | offset to table[0]
+ +0x05E4 | B4 00 00 00 | UOffset32 | 0x000000B4 (180) Loc: +0x0698 | offset to table[1]
+ +0x05E8 | 68 00 00 00 | UOffset32 | 0x00000068 (104) Loc: +0x0650 | offset to table[2]
+ +0x05EC | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x0608 | offset to table[3]
+
+string (reflection.Enum.name):
+ +0x05F0 | 12 00 00 00 | uint32_t | 0x00000012 (18) | length of string
+ +0x05F4 | 4D 79 47 61 6D 65 2E 45 | char[18] | MyGame.E | string literal
+ +0x05FC | 78 61 6D 70 6C 65 2E 41 | | xample.A
+ +0x0604 | 6E 79 | | ny
+ +0x0606 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.EnumVal):
+ +0x0608 | EE FC FF FF | SOffset32 | 0xFFFFFCEE (-786) Loc: +0x091A | offset to vtable
+ +0x060C | 28 00 00 00 | UOffset32 | 0x00000028 (40) Loc: +0x0634 | offset to field `name` (string)
+ +0x0610 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x0624 | offset to field `union_type` (table)
+ +0x0614 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x0620 | offset to field `documentation` (vector)
+ +0x0618 | 03 00 00 00 00 00 00 00 | int64_t | 0x0000000000000003 (3) | table field `value` (Long)
+
+vector (reflection.EnumVal.documentation):
+ +0x0620 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x0624 | 6C CD FF FF | SOffset32 | 0xFFFFCD6C (-12948) Loc: +0x38B8 | offset to vtable
+ +0x0628 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x062B | 0F | uint8_t | 0x0F (15) | table field `base_type` (Byte)
+ +0x062C | 0A 00 00 00 | uint32_t | 0x0000000A (10) | table field `index` (Int)
+ +0x0630 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.EnumVal.name):
+ +0x0634 | 17 00 00 00 | uint32_t | 0x00000017 (23) | length of string
+ +0x0638 | 4D 79 47 61 6D 65 5F 45 | char[23] | MyGame_E | string literal
+ +0x0640 | 78 61 6D 70 6C 65 32 5F | | xample2_
+ +0x0648 | 4D 6F 6E 73 74 65 72 | | Monster
+ +0x064F | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.EnumVal):
+ +0x0650 | 36 FD FF FF | SOffset32 | 0xFFFFFD36 (-714) Loc: +0x091A | offset to vtable
+ +0x0654 | 28 00 00 00 | UOffset32 | 0x00000028 (40) Loc: +0x067C | offset to field `name` (string)
+ +0x0658 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x066C | offset to field `union_type` (table)
+ +0x065C | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x0668 | offset to field `documentation` (vector)
+ +0x0660 | 02 00 00 00 00 00 00 00 | int64_t | 0x0000000000000002 (2) | table field `value` (Long)
+
+vector (reflection.EnumVal.documentation):
+ +0x0668 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x066C | B4 CD FF FF | SOffset32 | 0xFFFFCDB4 (-12876) Loc: +0x38B8 | offset to vtable
+ +0x0670 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x0673 | 0F | uint8_t | 0x0F (15) | table field `base_type` (Byte)
+ +0x0674 | 07 00 00 00 | uint32_t | 0x00000007 (7) | table field `index` (Int)
+ +0x0678 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.EnumVal.name):
+ +0x067C | 17 00 00 00 | uint32_t | 0x00000017 (23) | length of string
+ +0x0680 | 54 65 73 74 53 69 6D 70 | char[23] | TestSimp | string literal
+ +0x0688 | 6C 65 54 61 62 6C 65 57 | | leTableW
+ +0x0690 | 69 74 68 45 6E 75 6D | | ithEnum
+ +0x0697 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.EnumVal):
+ +0x0698 | 7E FD FF FF | SOffset32 | 0xFFFFFD7E (-642) Loc: +0x091A | offset to vtable
+ +0x069C | 28 00 00 00 | UOffset32 | 0x00000028 (40) Loc: +0x06C4 | offset to field `name` (string)
+ +0x06A0 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x06B4 | offset to field `union_type` (table)
+ +0x06A4 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x06B0 | offset to field `documentation` (vector)
+ +0x06A8 | 01 00 00 00 00 00 00 00 | int64_t | 0x0000000000000001 (1) | table field `value` (Long)
+
+vector (reflection.EnumVal.documentation):
+ +0x06B0 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x06B4 | FC CD FF FF | SOffset32 | 0xFFFFCDFC (-12804) Loc: +0x38B8 | offset to vtable
+ +0x06B8 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x06BB | 0F | uint8_t | 0x0F (15) | table field `base_type` (Byte)
+ +0x06BC | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `index` (Int)
+ +0x06C0 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.EnumVal.name):
+ +0x06C4 | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x06C8 | 4D 6F 6E 73 74 65 72 | char[7] | Monster | string literal
+ +0x06CF | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.EnumVal):
+ +0x06D0 | 12 FB FF FF | SOffset32 | 0xFFFFFB12 (-1262) Loc: +0x0BBE | offset to vtable
+ +0x06D4 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x06F0 | offset to field `name` (string)
+ +0x06D8 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x06E4 | offset to field `union_type` (table)
+ +0x06DC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x06E0 | offset to field `documentation` (vector)
+
+vector (reflection.EnumVal.documentation):
+ +0x06E0 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x06E4 | 04 FB FF FF | SOffset32 | 0xFFFFFB04 (-1276) Loc: +0x0BE0 | offset to vtable
+ +0x06E8 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x06EC | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.EnumVal.name):
+ +0x06F0 | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x06F4 | 4E 4F 4E 45 | char[4] | NONE | string literal
+ +0x06F8 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x06F9 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Enum):
+ +0x06FC | A2 FD FF FF | SOffset32 | 0xFFFFFDA2 (-606) Loc: +0x095A | offset to vtable
+ +0x0700 | 6C 00 00 00 | UOffset32 | 0x0000006C (108) Loc: +0x076C | offset to field `name` (string)
+ +0x0704 | 58 00 00 00 | UOffset32 | 0x00000058 (88) Loc: +0x075C | offset to field `values` (vector)
+ +0x0708 | 40 00 00 00 | UOffset32 | 0x00000040 (64) Loc: +0x0748 | offset to field `underlying_type` (table)
+ +0x070C | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x071C | offset to field `attributes` (vector)
+ +0x0710 | 08 00 00 00 | UOffset32 | 0x00000008 (8) Loc: +0x0718 | offset to field `documentation` (vector)
+ +0x0714 | 4C 30 00 00 | UOffset32 | 0x0000304C (12364) Loc: +0x3760 | offset to field `declaration_file` (string)
+
+vector (reflection.Enum.documentation):
+ +0x0718 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Enum.attributes):
+ +0x071C | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x0720 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0724 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x0724 | C0 D1 FF FF | SOffset32 | 0xFFFFD1C0 (-11840) Loc: +0x3564 | offset to vtable
+ +0x0728 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x0738 | offset to field `key` (string)
+ +0x072C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0730 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x0730 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x0734 | 30 | char[1] | 0 | string literal
+ +0x0735 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x0736 | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x0738 | 09 00 00 00 | uint32_t | 0x00000009 (9) | length of string
+ +0x073C | 62 69 74 5F 66 6C 61 67 | char[9] | bit_flag | string literal
+ +0x0744 | 73 | | s
+ +0x0745 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x0746 | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Type):
+ +0x0748 | 44 D1 FF FF | SOffset32 | 0xFFFFD144 (-11964) Loc: +0x3604 | offset to vtable
+ +0x074C | 00 00 00 | uint8_t[3] | ... | padding
+ +0x074F | 0A | uint8_t | 0x0A (10) | table field `base_type` (Byte)
+ +0x0750 | 04 00 00 00 | uint32_t | 0x00000004 (4) | table field `index` (Int)
+ +0x0754 | 08 00 00 00 | uint32_t | 0x00000008 (8) | table field `base_size` (UInt)
+ +0x0758 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+vector (reflection.Enum.values):
+ +0x075C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0760 | 98 00 00 00 | UOffset32 | 0x00000098 (152) Loc: +0x07F8 | offset to table[0]
+ +0x0764 | 5C 00 00 00 | UOffset32 | 0x0000005C (92) Loc: +0x07C0 | offset to table[1]
+ +0x0768 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x0788 | offset to table[2]
+
+string (reflection.Enum.name):
+ +0x076C | 17 00 00 00 | uint32_t | 0x00000017 (23) | length of string
+ +0x0770 | 4D 79 47 61 6D 65 2E 45 | char[23] | MyGame.E | string literal
+ +0x0778 | 78 61 6D 70 6C 65 2E 4C | | xample.L
+ +0x0780 | 6F 6E 67 45 6E 75 6D | | ongEnum
+ +0x0787 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.EnumVal):
+ +0x0788 | 7E FC FF FF | SOffset32 | 0xFFFFFC7E (-898) Loc: +0x0B0A | offset to vtable
+ +0x078C | 28 00 00 00 | UOffset32 | 0x00000028 (40) Loc: +0x07B4 | offset to field `name` (string)
+ +0x0790 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x07A8 | offset to field `union_type` (table)
+ +0x0794 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x07A4 | offset to field `documentation` (vector)
+ +0x0798 | 00 00 00 00 00 01 00 00 | int64_t | 0x0000010000000000 (1099511627776) | table field `value` (Long)
+ +0x07A0 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (reflection.EnumVal.documentation):
+ +0x07A4 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x07A8 | C8 FB FF FF | SOffset32 | 0xFFFFFBC8 (-1080) Loc: +0x0BE0 | offset to vtable
+ +0x07AC | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x07B0 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.EnumVal.name):
+ +0x07B4 | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x07B8 | 4C 6F 6E 67 42 69 67 | char[7] | LongBig | string literal
+ +0x07BF | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.EnumVal):
+ +0x07C0 | B6 FC FF FF | SOffset32 | 0xFFFFFCB6 (-842) Loc: +0x0B0A | offset to vtable
+ +0x07C4 | 28 00 00 00 | UOffset32 | 0x00000028 (40) Loc: +0x07EC | offset to field `name` (string)
+ +0x07C8 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x07E0 | offset to field `union_type` (table)
+ +0x07CC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x07DC | offset to field `documentation` (vector)
+ +0x07D0 | 04 00 00 00 00 00 00 00 | int64_t | 0x0000000000000004 (4) | table field `value` (Long)
+ +0x07D8 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (reflection.EnumVal.documentation):
+ +0x07DC | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x07E0 | 00 FC FF FF | SOffset32 | 0xFFFFFC00 (-1024) Loc: +0x0BE0 | offset to vtable
+ +0x07E4 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x07E8 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.EnumVal.name):
+ +0x07EC | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x07F0 | 4C 6F 6E 67 54 77 6F | char[7] | LongTwo | string literal
+ +0x07F7 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.EnumVal):
+ +0x07F8 | DE FE FF FF | SOffset32 | 0xFFFFFEDE (-290) Loc: +0x091A | offset to vtable
+ +0x07FC | 24 00 00 00 | UOffset32 | 0x00000024 (36) Loc: +0x0820 | offset to field `name` (string)
+ +0x0800 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x0814 | offset to field `union_type` (table)
+ +0x0804 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x0810 | offset to field `documentation` (vector)
+ +0x0808 | 02 00 00 00 00 00 00 00 | int64_t | 0x0000000000000002 (2) | table field `value` (Long)
+
+vector (reflection.EnumVal.documentation):
+ +0x0810 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x0814 | 34 FC FF FF | SOffset32 | 0xFFFFFC34 (-972) Loc: +0x0BE0 | offset to vtable
+ +0x0818 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x081C | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.EnumVal.name):
+ +0x0820 | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x0824 | 4C 6F 6E 67 4F 6E 65 | char[7] | LongOne | string literal
+ +0x082B | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Enum):
+ +0x082C | DE FC FF FF | SOffset32 | 0xFFFFFCDE (-802) Loc: +0x0B4E | offset to vtable
+ +0x0830 | 40 00 00 00 | UOffset32 | 0x00000040 (64) Loc: +0x0870 | offset to field `name` (string)
+ +0x0834 | 28 00 00 00 | UOffset32 | 0x00000028 (40) Loc: +0x085C | offset to field `values` (vector)
+ +0x0838 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x0848 | offset to field `underlying_type` (table)
+ +0x083C | 08 00 00 00 | UOffset32 | 0x00000008 (8) Loc: +0x0844 | offset to field `documentation` (vector)
+ +0x0840 | 20 2F 00 00 | UOffset32 | 0x00002F20 (12064) Loc: +0x3760 | offset to field `declaration_file` (string)
+
+vector (reflection.Enum.documentation):
+ +0x0844 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x0848 | 44 D2 FF FF | SOffset32 | 0xFFFFD244 (-11708) Loc: +0x3604 | offset to vtable
+ +0x084C | 00 00 00 | uint8_t[3] | ... | padding
+ +0x084F | 03 | uint8_t | 0x03 (3) | table field `base_type` (Byte)
+ +0x0850 | 05 00 00 00 | uint32_t | 0x00000005 (5) | table field `index` (Int)
+ +0x0854 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x0858 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+vector (reflection.Enum.values):
+ +0x085C | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of vector (# items)
+ +0x0860 | C8 00 00 00 | UOffset32 | 0x000000C8 (200) Loc: +0x0928 | offset to table[0]
+ +0x0864 | 8C 00 00 00 | UOffset32 | 0x0000008C (140) Loc: +0x08F0 | offset to table[1]
+ +0x0868 | 50 00 00 00 | UOffset32 | 0x00000050 (80) Loc: +0x08B8 | offset to table[2]
+ +0x086C | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x0888 | offset to table[3]
+
+string (reflection.Enum.name):
+ +0x0870 | 13 00 00 00 | uint32_t | 0x00000013 (19) | length of string
+ +0x0874 | 4D 79 47 61 6D 65 2E 45 | char[19] | MyGame.E | string literal
+ +0x087C | 78 61 6D 70 6C 65 2E 52 | | xample.R
+ +0x0884 | 61 63 65 | | ace
+ +0x0887 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.EnumVal):
+ +0x0888 | 6E FF FF FF | SOffset32 | 0xFFFFFF6E (-146) Loc: +0x091A | offset to vtable
+ +0x088C | 24 00 00 00 | UOffset32 | 0x00000024 (36) Loc: +0x08B0 | offset to field `name` (string)
+ +0x0890 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x08A4 | offset to field `union_type` (table)
+ +0x0894 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x08A0 | offset to field `documentation` (vector)
+ +0x0898 | 02 00 00 00 00 00 00 00 | int64_t | 0x0000000000000002 (2) | table field `value` (Long)
+
+vector (reflection.EnumVal.documentation):
+ +0x08A0 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x08A4 | C4 FC FF FF | SOffset32 | 0xFFFFFCC4 (-828) Loc: +0x0BE0 | offset to vtable
+ +0x08A8 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x08AC | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.EnumVal.name):
+ +0x08B0 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x08B4 | 45 6C 66 | char[3] | Elf | string literal
+ +0x08B7 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.EnumVal):
+ +0x08B8 | AE FD FF FF | SOffset32 | 0xFFFFFDAE (-594) Loc: +0x0B0A | offset to vtable
+ +0x08BC | 28 00 00 00 | UOffset32 | 0x00000028 (40) Loc: +0x08E4 | offset to field `name` (string)
+ +0x08C0 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x08D8 | offset to field `union_type` (table)
+ +0x08C4 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x08D4 | offset to field `documentation` (vector)
+ +0x08C8 | 01 00 00 00 00 00 00 00 | int64_t | 0x0000000000000001 (1) | table field `value` (Long)
+ +0x08D0 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (reflection.EnumVal.documentation):
+ +0x08D4 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x08D8 | F8 FC FF FF | SOffset32 | 0xFFFFFCF8 (-776) Loc: +0x0BE0 | offset to vtable
+ +0x08DC | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x08E0 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.EnumVal.name):
+ +0x08E4 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x08E8 | 44 77 61 72 66 | char[5] | Dwarf | string literal
+ +0x08ED | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x08EE | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.EnumVal):
+ +0x08F0 | 32 FD FF FF | SOffset32 | 0xFFFFFD32 (-718) Loc: +0x0BBE | offset to vtable
+ +0x08F4 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x0910 | offset to field `name` (string)
+ +0x08F8 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x0904 | offset to field `union_type` (table)
+ +0x08FC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0900 | offset to field `documentation` (vector)
+
+vector (reflection.EnumVal.documentation):
+ +0x0900 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x0904 | 24 FD FF FF | SOffset32 | 0xFFFFFD24 (-732) Loc: +0x0BE0 | offset to vtable
+ +0x0908 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x090C | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.EnumVal.name):
+ +0x0910 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x0914 | 48 75 6D 61 6E | char[5] | Human | string literal
+ +0x0919 | 00 | char | 0x00 (0) | string terminator
+
+vtable (reflection.EnumVal):
+ +0x091A | 0E 00 | uint16_t | 0x000E (14) | size of this vtable
+ +0x091C | 18 00 | uint16_t | 0x0018 (24) | size of referring table
+ +0x091E | 04 00 | VOffset16 | 0x0004 (4) | offset to field `name` (id: 0)
+ +0x0920 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `value` (id: 1)
+ +0x0922 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `object` (id: 2) <null> (Obj)
+ +0x0924 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `union_type` (id: 3)
+ +0x0926 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `documentation` (id: 4)
+
+table (reflection.EnumVal):
+ +0x0928 | 0E 00 00 00 | SOffset32 | 0x0000000E (14) Loc: +0x091A | offset to vtable
+ +0x092C | 24 00 00 00 | UOffset32 | 0x00000024 (36) Loc: +0x0950 | offset to field `name` (string)
+ +0x0930 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x0944 | offset to field `union_type` (table)
+ +0x0934 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x0940 | offset to field `documentation` (vector)
+ +0x0938 | FF FF FF FF FF FF FF FF | int64_t | 0xFFFFFFFFFFFFFFFF (-1) | table field `value` (Long)
+
+vector (reflection.EnumVal.documentation):
+ +0x0940 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x0944 | 64 FD FF FF | SOffset32 | 0xFFFFFD64 (-668) Loc: +0x0BE0 | offset to vtable
+ +0x0948 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x094C | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.EnumVal.name):
+ +0x0950 | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x0954 | 4E 6F 6E 65 | char[4] | None | string literal
+ +0x0958 | 00 | char | 0x00 (0) | string terminator
+
+vtable (reflection.Enum):
+ +0x095A | 12 00 | uint16_t | 0x0012 (18) | size of this vtable
+ +0x095C | 1C 00 | uint16_t | 0x001C (28) | size of referring table
+ +0x095E | 04 00 | VOffset16 | 0x0004 (4) | offset to field `name` (id: 0)
+ +0x0960 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `values` (id: 1)
+ +0x0962 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `is_union` (id: 2) <defaults to 0> (Bool)
+ +0x0964 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `underlying_type` (id: 3)
+ +0x0966 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `attributes` (id: 4)
+ +0x0968 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `documentation` (id: 5)
+ +0x096A | 18 00 | VOffset16 | 0x0018 (24) | offset to field `declaration_file` (id: 6)
+
+table (reflection.Enum):
+ +0x096C | 12 00 00 00 | SOffset32 | 0x00000012 (18) Loc: +0x095A | offset to vtable
+ +0x0970 | 9C 00 00 00 | UOffset32 | 0x0000009C (156) Loc: +0x0A0C | offset to field `name` (string)
+ +0x0974 | 88 00 00 00 | UOffset32 | 0x00000088 (136) Loc: +0x09FC | offset to field `values` (vector)
+ +0x0978 | 70 00 00 00 | UOffset32 | 0x00000070 (112) Loc: +0x09E8 | offset to field `underlying_type` (table)
+ +0x097C | 40 00 00 00 | UOffset32 | 0x00000040 (64) Loc: +0x09BC | offset to field `attributes` (vector)
+ +0x0980 | 08 00 00 00 | UOffset32 | 0x00000008 (8) Loc: +0x0988 | offset to field `documentation` (vector)
+ +0x0984 | DC 2D 00 00 | UOffset32 | 0x00002DDC (11740) Loc: +0x3760 | offset to field `declaration_file` (string)
+
+vector (reflection.Enum.documentation):
+ +0x0988 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x098C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0990 | offset to string[0]
+
+string (reflection.Enum.documentation):
+ +0x0990 | 27 00 00 00 | uint32_t | 0x00000027 (39) | length of string
+ +0x0994 | 20 43 6F 6D 70 6F 73 69 | char[39] | Composi | string literal
+ +0x099C | 74 65 20 63 6F 6D 70 6F | | te compo
+ +0x09A4 | 6E 65 6E 74 73 20 6F 66 | | nents of
+ +0x09AC | 20 4D 6F 6E 73 74 65 72 | | Monster
+ +0x09B4 | 20 63 6F 6C 6F 72 2E | | color.
+ +0x09BB | 00 | char | 0x00 (0) | string terminator
+
+vector (reflection.Enum.attributes):
+ +0x09BC | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x09C0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x09C4 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x09C4 | 60 D4 FF FF | SOffset32 | 0xFFFFD460 (-11168) Loc: +0x3564 | offset to vtable
+ +0x09C8 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x09D8 | offset to field `key` (string)
+ +0x09CC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x09D0 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x09D0 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x09D4 | 30 | char[1] | 0 | string literal
+ +0x09D5 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x09D6 | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x09D8 | 09 00 00 00 | uint32_t | 0x00000009 (9) | length of string
+ +0x09DC | 62 69 74 5F 66 6C 61 67 | char[9] | bit_flag | string literal
+ +0x09E4 | 73 | | s
+ +0x09E5 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x09E6 | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Type):
+ +0x09E8 | E4 D3 FF FF | SOffset32 | 0xFFFFD3E4 (-11292) Loc: +0x3604 | offset to vtable
+ +0x09EC | 00 00 00 | uint8_t[3] | ... | padding
+ +0x09EF | 04 | uint8_t | 0x04 (4) | table field `base_type` (Byte)
+ +0x09F0 | 03 00 00 00 | uint32_t | 0x00000003 (3) | table field `index` (Int)
+ +0x09F4 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x09F8 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+vector (reflection.Enum.values):
+ +0x09FC | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0A00 | 18 01 00 00 | UOffset32 | 0x00000118 (280) Loc: +0x0B18 | offset to table[0]
+ +0x0A04 | 84 00 00 00 | UOffset32 | 0x00000084 (132) Loc: +0x0A88 | offset to table[1]
+ +0x0A08 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x0A28 | offset to table[2]
+
+string (reflection.Enum.name):
+ +0x0A0C | 14 00 00 00 | uint32_t | 0x00000014 (20) | length of string
+ +0x0A10 | 4D 79 47 61 6D 65 2E 45 | char[20] | MyGame.E | string literal
+ +0x0A18 | 78 61 6D 70 6C 65 2E 43 | | xample.C
+ +0x0A20 | 6F 6C 6F 72 | | olor
+ +0x0A24 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x0A25 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.EnumVal):
+ +0x0A28 | 1E FF FF FF | SOffset32 | 0xFFFFFF1E (-226) Loc: +0x0B0A | offset to vtable
+ +0x0A2C | 50 00 00 00 | UOffset32 | 0x00000050 (80) Loc: +0x0A7C | offset to field `name` (string)
+ +0x0A30 | 40 00 00 00 | UOffset32 | 0x00000040 (64) Loc: +0x0A70 | offset to field `union_type` (table)
+ +0x0A34 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x0A44 | offset to field `documentation` (vector)
+ +0x0A38 | 08 00 00 00 00 00 00 00 | int64_t | 0x0000000000000008 (8) | table field `value` (Long)
+ +0x0A40 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (reflection.EnumVal.documentation):
+ +0x0A44 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x0A48 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0A4C | offset to string[0]
+
+string (reflection.EnumVal.documentation):
+ +0x0A4C | 1C 00 00 00 | uint32_t | 0x0000001C (28) | length of string
+ +0x0A50 | 20 5C 62 72 69 65 66 20 | char[28] | \brief | string literal
+ +0x0A58 | 63 6F 6C 6F 72 20 42 6C | | color Bl
+ +0x0A60 | 75 65 20 28 31 75 20 3C | | ue (1u <
+ +0x0A68 | 3C 20 33 29 | | < 3)
+ +0x0A6C | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x0A6D | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Type):
+ +0x0A70 | 90 FE FF FF | SOffset32 | 0xFFFFFE90 (-368) Loc: +0x0BE0 | offset to vtable
+ +0x0A74 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x0A78 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.EnumVal.name):
+ +0x0A7C | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x0A80 | 42 6C 75 65 | char[4] | Blue | string literal
+ +0x0A84 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x0A85 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.EnumVal):
+ +0x0A88 | 7E FF FF FF | SOffset32 | 0xFFFFFF7E (-130) Loc: +0x0B0A | offset to vtable
+ +0x0A8C | 74 00 00 00 | UOffset32 | 0x00000074 (116) Loc: +0x0B00 | offset to field `name` (string)
+ +0x0A90 | 64 00 00 00 | UOffset32 | 0x00000064 (100) Loc: +0x0AF4 | offset to field `union_type` (table)
+ +0x0A94 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x0AA4 | offset to field `documentation` (vector)
+ +0x0A98 | 02 00 00 00 00 00 00 00 | int64_t | 0x0000000000000002 (2) | table field `value` (Long)
+ +0x0AA0 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (reflection.EnumVal.documentation):
+ +0x0AA4 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x0AA8 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x0ADC | offset to string[0]
+ +0x0AAC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0AB0 | offset to string[1]
+
+string (reflection.EnumVal.documentation):
+ +0x0AB0 | 27 00 00 00 | uint32_t | 0x00000027 (39) | length of string
+ +0x0AB4 | 20 47 72 65 65 6E 20 69 | char[39] | Green i | string literal
+ +0x0ABC | 73 20 62 69 74 5F 66 6C | | s bit_fl
+ +0x0AC4 | 61 67 20 77 69 74 68 20 | | ag with
+ +0x0ACC | 76 61 6C 75 65 20 28 31 | | value (1
+ +0x0AD4 | 75 20 3C 3C 20 31 29 | | u << 1)
+ +0x0ADB | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.EnumVal.documentation):
+ +0x0ADC | 13 00 00 00 | uint32_t | 0x00000013 (19) | length of string
+ +0x0AE0 | 20 5C 62 72 69 65 66 20 | char[19] | \brief | string literal
+ +0x0AE8 | 63 6F 6C 6F 72 20 47 72 | | color Gr
+ +0x0AF0 | 65 65 6E | | een
+ +0x0AF3 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x0AF4 | 14 FF FF FF | SOffset32 | 0xFFFFFF14 (-236) Loc: +0x0BE0 | offset to vtable
+ +0x0AF8 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x0AFC | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.EnumVal.name):
+ +0x0B00 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x0B04 | 47 72 65 65 6E | char[5] | Green | string literal
+ +0x0B09 | 00 | char | 0x00 (0) | string terminator
+
+vtable (reflection.EnumVal):
+ +0x0B0A | 0E 00 | uint16_t | 0x000E (14) | size of this vtable
+ +0x0B0C | 1C 00 | uint16_t | 0x001C (28) | size of referring table
+ +0x0B0E | 04 00 | VOffset16 | 0x0004 (4) | offset to field `name` (id: 0)
+ +0x0B10 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `value` (id: 1)
+ +0x0B12 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `object` (id: 2) <null> (Obj)
+ +0x0B14 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `union_type` (id: 3)
+ +0x0B16 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `documentation` (id: 4)
+
+table (reflection.EnumVal):
+ +0x0B18 | 0E 00 00 00 | SOffset32 | 0x0000000E (14) Loc: +0x0B0A | offset to vtable
+ +0x0B1C | 28 00 00 00 | UOffset32 | 0x00000028 (40) Loc: +0x0B44 | offset to field `name` (string)
+ +0x0B20 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x0B38 | offset to field `union_type` (table)
+ +0x0B24 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x0B34 | offset to field `documentation` (vector)
+ +0x0B28 | 01 00 00 00 00 00 00 00 | int64_t | 0x0000000000000001 (1) | table field `value` (Long)
+ +0x0B30 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (reflection.EnumVal.documentation):
+ +0x0B34 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x0B38 | 58 FF FF FF | SOffset32 | 0xFFFFFF58 (-168) Loc: +0x0BE0 | offset to vtable
+ +0x0B3C | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x0B40 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.EnumVal.name):
+ +0x0B44 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x0B48 | 52 65 64 | char[3] | Red | string literal
+ +0x0B4B | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x0B4C | 00 00 | uint8_t[2] | .. | padding
+
+vtable (reflection.Enum):
+ +0x0B4E | 12 00 | uint16_t | 0x0012 (18) | size of this vtable
+ +0x0B50 | 18 00 | uint16_t | 0x0018 (24) | size of referring table
+ +0x0B52 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `name` (id: 0)
+ +0x0B54 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `values` (id: 1)
+ +0x0B56 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `is_union` (id: 2) <defaults to 0> (Bool)
+ +0x0B58 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `underlying_type` (id: 3)
+ +0x0B5A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `attributes` (id: 4) <null> (Vector)
+ +0x0B5C | 10 00 | VOffset16 | 0x0010 (16) | offset to field `documentation` (id: 5)
+ +0x0B5E | 14 00 | VOffset16 | 0x0014 (20) | offset to field `declaration_file` (id: 6)
+
+table (reflection.Enum):
+ +0x0B60 | 12 00 00 00 | SOffset32 | 0x00000012 (18) Loc: +0x0B4E | offset to vtable
+ +0x0B64 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x0B98 | offset to field `name` (string)
+ +0x0B68 | 28 00 00 00 | UOffset32 | 0x00000028 (40) Loc: +0x0B90 | offset to field `values` (vector)
+ +0x0B6C | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x0B7C | offset to field `underlying_type` (table)
+ +0x0B70 | 08 00 00 00 | UOffset32 | 0x00000008 (8) Loc: +0x0B78 | offset to field `documentation` (vector)
+ +0x0B74 | A0 2D 00 00 | UOffset32 | 0x00002DA0 (11680) Loc: +0x3914 | offset to field `declaration_file` (string)
+
+vector (reflection.Enum.documentation):
+ +0x0B78 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x0B7C | 78 D5 FF FF | SOffset32 | 0xFFFFD578 (-10888) Loc: +0x3604 | offset to vtable
+ +0x0B80 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x0B83 | 09 | uint8_t | 0x09 (9) | table field `base_type` (Byte)
+ +0x0B84 | 06 00 00 00 | uint32_t | 0x00000006 (6) | table field `index` (Int)
+ +0x0B88 | 08 00 00 00 | uint32_t | 0x00000008 (8) | table field `base_size` (UInt)
+ +0x0B8C | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+vector (reflection.Enum.values):
+ +0x0B90 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x0B94 | 38 00 00 00 | UOffset32 | 0x00000038 (56) Loc: +0x0BCC | offset to table[0]
+
+string (reflection.Enum.name):
+ +0x0B98 | 21 00 00 00 | uint32_t | 0x00000021 (33) | length of string
+ +0x0B9C | 4D 79 47 61 6D 65 2E 4F | char[33] | MyGame.O | string literal
+ +0x0BA4 | 74 68 65 72 4E 61 6D 65 | | therName
+ +0x0BAC | 53 70 61 63 65 2E 46 72 | | Space.Fr
+ +0x0BB4 | 6F 6D 49 6E 63 6C 75 64 | | omInclud
+ +0x0BBC | 65 | | e
+ +0x0BBD | 00 | char | 0x00 (0) | string terminator
+
+vtable (reflection.EnumVal):
+ +0x0BBE | 0E 00 | uint16_t | 0x000E (14) | size of this vtable
+ +0x0BC0 | 10 00 | uint16_t | 0x0010 (16) | size of referring table
+ +0x0BC2 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `name` (id: 0)
+ +0x0BC4 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `value` (id: 1) <defaults to 0> (Long)
+ +0x0BC6 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `object` (id: 2) <null> (Obj)
+ +0x0BC8 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `union_type` (id: 3)
+ +0x0BCA | 0C 00 | VOffset16 | 0x000C (12) | offset to field `documentation` (id: 4)
+
+table (reflection.EnumVal):
+ +0x0BCC | 0E 00 00 00 | SOffset32 | 0x0000000E (14) Loc: +0x0BBE | offset to vtable
+ +0x0BD0 | 2C 00 00 00 | UOffset32 | 0x0000002C (44) Loc: +0x0BFC | offset to field `name` (string)
+ +0x0BD4 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x0BF0 | offset to field `union_type` (table)
+ +0x0BD8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0BDC | offset to field `documentation` (vector)
+
+vector (reflection.EnumVal.documentation):
+ +0x0BDC | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vtable (reflection.Type):
+ +0x0BE0 | 10 00 | uint16_t | 0x0010 (16) | size of this vtable
+ +0x0BE2 | 0C 00 | uint16_t | 0x000C (12) | size of referring table
+ +0x0BE4 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `base_type` (id: 0) <defaults to 0> (Byte)
+ +0x0BE6 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `element` (id: 1) <defaults to 0> (Byte)
+ +0x0BE8 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `index` (id: 2) <defaults to -1> (Int)
+ +0x0BEA | 00 00 | VOffset16 | 0x0000 (0) | offset to field `fixed_length` (id: 3) <defaults to 0> (UShort)
+ +0x0BEC | 04 00 | VOffset16 | 0x0004 (4) | offset to field `base_size` (id: 4)
+ +0x0BEE | 08 00 | VOffset16 | 0x0008 (8) | offset to field `element_size` (id: 5)
+
+table (reflection.Type):
+ +0x0BF0 | 10 00 00 00 | SOffset32 | 0x00000010 (16) Loc: +0x0BE0 | offset to vtable
+ +0x0BF4 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x0BF8 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.EnumVal.name):
+ +0x0BFC | 0A 00 00 00 | uint32_t | 0x0000000A (10) | length of string
+ +0x0C00 | 49 6E 63 6C 75 64 65 56 | char[10] | IncludeV | string literal
+ +0x0C08 | 61 6C | | al
+ +0x0C0A | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Object):
+ +0x0C0C | E4 D3 FF FF | SOffset32 | 0xFFFFD3E4 (-11292) Loc: +0x3828 | offset to vtable
+ +0x0C10 | 4C 00 00 00 | UOffset32 | 0x0000004C (76) Loc: +0x0C5C | offset to field `name` (string)
+ +0x0C14 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x0C28 | offset to field `fields` (vector)
+ +0x0C18 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `minalign` (Int)
+ +0x0C1C | 08 00 00 00 | UOffset32 | 0x00000008 (8) Loc: +0x0C24 | offset to field `documentation` (vector)
+ +0x0C20 | 40 2B 00 00 | UOffset32 | 0x00002B40 (11072) Loc: +0x3760 | offset to field `declaration_file` (string)
+
+vector (reflection.Object.documentation):
+ +0x0C24 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Object.fields):
+ +0x0C28 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | length of vector (# items)
+ +0x0C2C | E4 00 00 00 | UOffset32 | 0x000000E4 (228) Loc: +0x0D10 | offset to table[0]
+ +0x0C30 | B0 00 00 00 | UOffset32 | 0x000000B0 (176) Loc: +0x0CE0 | offset to table[1]
+ +0x0C34 | F0 01 00 00 | UOffset32 | 0x000001F0 (496) Loc: +0x0E24 | offset to table[2]
+ +0x0C38 | 90 01 00 00 | UOffset32 | 0x00000190 (400) Loc: +0x0DC8 | offset to table[3]
+ +0x0C3C | 30 01 00 00 | UOffset32 | 0x00000130 (304) Loc: +0x0D6C | offset to table[4]
+ +0x0C40 | 60 02 00 00 | UOffset32 | 0x00000260 (608) Loc: +0x0EA0 | offset to table[5]
+ +0x0C44 | B0 01 00 00 | UOffset32 | 0x000001B0 (432) Loc: +0x0DF4 | offset to table[6]
+ +0x0C48 | 54 01 00 00 | UOffset32 | 0x00000154 (340) Loc: +0x0D9C | offset to table[7]
+ +0x0C4C | F0 00 00 00 | UOffset32 | 0x000000F0 (240) Loc: +0x0D3C | offset to table[8]
+ +0x0C50 | 04 02 00 00 | UOffset32 | 0x00000204 (516) Loc: +0x0E54 | offset to table[9]
+ +0x0C54 | 5C 00 00 00 | UOffset32 | 0x0000005C (92) Loc: +0x0CB0 | offset to table[10]
+ +0x0C58 | 24 00 00 00 | UOffset32 | 0x00000024 (36) Loc: +0x0C7C | offset to table[11]
+
+string (reflection.Object.name):
+ +0x0C5C | 1A 00 00 00 | uint32_t | 0x0000001A (26) | length of string
+ +0x0C60 | 4D 79 47 61 6D 65 2E 45 | char[26] | MyGame.E | string literal
+ +0x0C68 | 78 61 6D 70 6C 65 2E 54 | | xample.T
+ +0x0C70 | 79 70 65 41 6C 69 61 73 | | ypeAlias
+ +0x0C78 | 65 73 | | es
+ +0x0C7A | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x0C7C | 00 DB FF FF | SOffset32 | 0xFFFFDB00 (-9472) Loc: +0x317C | offset to vtable
+ +0x0C80 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x0C83 | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x0C84 | 0B 00 | uint16_t | 0x000B (11) | table field `id` (UShort)
+ +0x0C86 | 1A 00 | uint16_t | 0x001A (26) | table field `offset` (UShort)
+ +0x0C88 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x0CA4 | offset to field `name` (string)
+ +0x0C8C | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x0C98 | offset to field `type` (table)
+ +0x0C90 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0C94 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x0C94 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x0C98 | 14 E1 FF FF | SOffset32 | 0xFFFFE114 (-7916) Loc: +0x2B84 | offset to vtable
+ +0x0C9C | 00 00 | uint8_t[2] | .. | padding
+ +0x0C9E | 0E | uint8_t | 0x0E (14) | table field `base_type` (Byte)
+ +0x0C9F | 0C | uint8_t | 0x0C (12) | table field `element` (Byte)
+ +0x0CA0 | 08 00 00 00 | uint32_t | 0x00000008 (8) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x0CA4 | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x0CA8 | 76 66 36 34 | char[4] | vf64 | string literal
+ +0x0CAC | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x0CAD | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Field):
+ +0x0CB0 | 34 DB FF FF | SOffset32 | 0xFFFFDB34 (-9420) Loc: +0x317C | offset to vtable
+ +0x0CB4 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x0CB7 | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x0CB8 | 0A 00 | uint16_t | 0x000A (10) | table field `id` (UShort)
+ +0x0CBA | 18 00 | uint16_t | 0x0018 (24) | table field `offset` (UShort)
+ +0x0CBC | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x0CD8 | offset to field `name` (string)
+ +0x0CC0 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x0CCC | offset to field `type` (table)
+ +0x0CC4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0CC8 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x0CC8 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x0CCC | 48 E1 FF FF | SOffset32 | 0xFFFFE148 (-7864) Loc: +0x2B84 | offset to vtable
+ +0x0CD0 | 00 00 | uint8_t[2] | .. | padding
+ +0x0CD2 | 0E | uint8_t | 0x0E (14) | table field `base_type` (Byte)
+ +0x0CD3 | 03 | uint8_t | 0x03 (3) | table field `element` (Byte)
+ +0x0CD4 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x0CD8 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x0CDC | 76 38 | char[2] | v8 | string literal
+ +0x0CDE | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x0CE0 | 4A D8 FF FF | SOffset32 | 0xFFFFD84A (-10166) Loc: +0x3496 | offset to vtable
+ +0x0CE4 | 09 00 | uint16_t | 0x0009 (9) | table field `id` (UShort)
+ +0x0CE6 | 16 00 | uint16_t | 0x0016 (22) | table field `offset` (UShort)
+ +0x0CE8 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x0D08 | offset to field `name` (string)
+ +0x0CEC | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x0CF8 | offset to field `type` (table)
+ +0x0CF0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0CF4 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x0CF4 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x0CF8 | 14 D6 FF FF | SOffset32 | 0xFFFFD614 (-10732) Loc: +0x36E4 | offset to vtable
+ +0x0CFC | 00 00 00 | uint8_t[3] | ... | padding
+ +0x0CFF | 0C | uint8_t | 0x0C (12) | table field `base_type` (Byte)
+ +0x0D00 | 08 00 00 00 | uint32_t | 0x00000008 (8) | table field `base_size` (UInt)
+ +0x0D04 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x0D08 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x0D0C | 66 36 34 | char[3] | f64 | string literal
+ +0x0D0F | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x0D10 | 7A D8 FF FF | SOffset32 | 0xFFFFD87A (-10118) Loc: +0x3496 | offset to vtable
+ +0x0D14 | 08 00 | uint16_t | 0x0008 (8) | table field `id` (UShort)
+ +0x0D16 | 14 00 | uint16_t | 0x0014 (20) | table field `offset` (UShort)
+ +0x0D18 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x0D34 | offset to field `name` (string)
+ +0x0D1C | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x0D28 | offset to field `type` (table)
+ +0x0D20 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0D24 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x0D24 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x0D28 | 8C D3 FF FF | SOffset32 | 0xFFFFD38C (-11380) Loc: +0x399C | offset to vtable
+ +0x0D2C | 00 00 00 | uint8_t[3] | ... | padding
+ +0x0D2F | 0B | uint8_t | 0x0B (11) | table field `base_type` (Byte)
+ +0x0D30 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x0D34 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x0D38 | 66 33 32 | char[3] | f32 | string literal
+ +0x0D3B | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x0D3C | A6 D8 FF FF | SOffset32 | 0xFFFFD8A6 (-10074) Loc: +0x3496 | offset to vtable
+ +0x0D40 | 07 00 | uint16_t | 0x0007 (7) | table field `id` (UShort)
+ +0x0D42 | 12 00 | uint16_t | 0x0012 (18) | table field `offset` (UShort)
+ +0x0D44 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x0D64 | offset to field `name` (string)
+ +0x0D48 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x0D54 | offset to field `type` (table)
+ +0x0D4C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0D50 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x0D50 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x0D54 | 70 D6 FF FF | SOffset32 | 0xFFFFD670 (-10640) Loc: +0x36E4 | offset to vtable
+ +0x0D58 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x0D5B | 0A | uint8_t | 0x0A (10) | table field `base_type` (Byte)
+ +0x0D5C | 08 00 00 00 | uint32_t | 0x00000008 (8) | table field `base_size` (UInt)
+ +0x0D60 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x0D64 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x0D68 | 75 36 34 | char[3] | u64 | string literal
+ +0x0D6B | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x0D6C | D6 D8 FF FF | SOffset32 | 0xFFFFD8D6 (-10026) Loc: +0x3496 | offset to vtable
+ +0x0D70 | 06 00 | uint16_t | 0x0006 (6) | table field `id` (UShort)
+ +0x0D72 | 10 00 | uint16_t | 0x0010 (16) | table field `offset` (UShort)
+ +0x0D74 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x0D94 | offset to field `name` (string)
+ +0x0D78 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x0D84 | offset to field `type` (table)
+ +0x0D7C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0D80 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x0D80 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x0D84 | A0 D6 FF FF | SOffset32 | 0xFFFFD6A0 (-10592) Loc: +0x36E4 | offset to vtable
+ +0x0D88 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x0D8B | 09 | uint8_t | 0x09 (9) | table field `base_type` (Byte)
+ +0x0D8C | 08 00 00 00 | uint32_t | 0x00000008 (8) | table field `base_size` (UInt)
+ +0x0D90 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x0D94 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x0D98 | 69 36 34 | char[3] | i64 | string literal
+ +0x0D9B | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x0D9C | 06 D9 FF FF | SOffset32 | 0xFFFFD906 (-9978) Loc: +0x3496 | offset to vtable
+ +0x0DA0 | 05 00 | uint16_t | 0x0005 (5) | table field `id` (UShort)
+ +0x0DA2 | 0E 00 | uint16_t | 0x000E (14) | table field `offset` (UShort)
+ +0x0DA4 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x0DC0 | offset to field `name` (string)
+ +0x0DA8 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x0DB4 | offset to field `type` (table)
+ +0x0DAC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0DB0 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x0DB0 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x0DB4 | 18 D4 FF FF | SOffset32 | 0xFFFFD418 (-11240) Loc: +0x399C | offset to vtable
+ +0x0DB8 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x0DBB | 08 | uint8_t | 0x08 (8) | table field `base_type` (Byte)
+ +0x0DBC | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x0DC0 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x0DC4 | 75 33 32 | char[3] | u32 | string literal
+ +0x0DC7 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x0DC8 | 32 D9 FF FF | SOffset32 | 0xFFFFD932 (-9934) Loc: +0x3496 | offset to vtable
+ +0x0DCC | 04 00 | uint16_t | 0x0004 (4) | table field `id` (UShort)
+ +0x0DCE | 0C 00 | uint16_t | 0x000C (12) | table field `offset` (UShort)
+ +0x0DD0 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x0DEC | offset to field `name` (string)
+ +0x0DD4 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x0DE0 | offset to field `type` (table)
+ +0x0DD8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0DDC | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x0DDC | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x0DE0 | 44 D4 FF FF | SOffset32 | 0xFFFFD444 (-11196) Loc: +0x399C | offset to vtable
+ +0x0DE4 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x0DE7 | 07 | uint8_t | 0x07 (7) | table field `base_type` (Byte)
+ +0x0DE8 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x0DEC | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x0DF0 | 69 33 32 | char[3] | i32 | string literal
+ +0x0DF3 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x0DF4 | 5E D9 FF FF | SOffset32 | 0xFFFFD95E (-9890) Loc: +0x3496 | offset to vtable
+ +0x0DF8 | 03 00 | uint16_t | 0x0003 (3) | table field `id` (UShort)
+ +0x0DFA | 0A 00 | uint16_t | 0x000A (10) | table field `offset` (UShort)
+ +0x0DFC | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x0E1C | offset to field `name` (string)
+ +0x0E00 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x0E0C | offset to field `type` (table)
+ +0x0E04 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0E08 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x0E08 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x0E0C | 28 D7 FF FF | SOffset32 | 0xFFFFD728 (-10456) Loc: +0x36E4 | offset to vtable
+ +0x0E10 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x0E13 | 06 | uint8_t | 0x06 (6) | table field `base_type` (Byte)
+ +0x0E14 | 02 00 00 00 | uint32_t | 0x00000002 (2) | table field `base_size` (UInt)
+ +0x0E18 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x0E1C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x0E20 | 75 31 36 | char[3] | u16 | string literal
+ +0x0E23 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x0E24 | 8E D9 FF FF | SOffset32 | 0xFFFFD98E (-9842) Loc: +0x3496 | offset to vtable
+ +0x0E28 | 02 00 | uint16_t | 0x0002 (2) | table field `id` (UShort)
+ +0x0E2A | 08 00 | uint16_t | 0x0008 (8) | table field `offset` (UShort)
+ +0x0E2C | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x0E4C | offset to field `name` (string)
+ +0x0E30 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x0E3C | offset to field `type` (table)
+ +0x0E34 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0E38 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x0E38 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x0E3C | 58 D7 FF FF | SOffset32 | 0xFFFFD758 (-10408) Loc: +0x36E4 | offset to vtable
+ +0x0E40 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x0E43 | 05 | uint8_t | 0x05 (5) | table field `base_type` (Byte)
+ +0x0E44 | 02 00 00 00 | uint32_t | 0x00000002 (2) | table field `base_size` (UInt)
+ +0x0E48 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x0E4C | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x0E50 | 69 31 36 | char[3] | i16 | string literal
+ +0x0E53 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x0E54 | BE D9 FF FF | SOffset32 | 0xFFFFD9BE (-9794) Loc: +0x3496 | offset to vtable
+ +0x0E58 | 01 00 | uint16_t | 0x0001 (1) | table field `id` (UShort)
+ +0x0E5A | 06 00 | uint16_t | 0x0006 (6) | table field `offset` (UShort)
+ +0x0E5C | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x0E7C | offset to field `name` (string)
+ +0x0E60 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x0E6C | offset to field `type` (table)
+ +0x0E64 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0E68 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x0E68 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x0E6C | 88 D7 FF FF | SOffset32 | 0xFFFFD788 (-10360) Loc: +0x36E4 | offset to vtable
+ +0x0E70 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x0E73 | 04 | uint8_t | 0x04 (4) | table field `base_type` (Byte)
+ +0x0E74 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x0E78 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x0E7C | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x0E80 | 75 38 | char[2] | u8 | string literal
+ +0x0E82 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x0E83 | 00 00 00 | uint8_t[3] | ... | padding
+
+vtable (reflection.Field):
+ +0x0E86 | 1A 00 | uint16_t | 0x001A (26) | size of this vtable
+ +0x0E88 | 14 00 | uint16_t | 0x0014 (20) | size of referring table
+ +0x0E8A | 08 00 | VOffset16 | 0x0008 (8) | offset to field `name` (id: 0)
+ +0x0E8C | 0C 00 | VOffset16 | 0x000C (12) | offset to field `type` (id: 1)
+ +0x0E8E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `id` (id: 2) <defaults to 0> (UShort)
+ +0x0E90 | 06 00 | VOffset16 | 0x0006 (6) | offset to field `offset` (id: 3)
+ +0x0E92 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_integer` (id: 4) <defaults to 0> (Long)
+ +0x0E94 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_real` (id: 5) <defaults to 0.000000> (Double)
+ +0x0E96 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `deprecated` (id: 6) <defaults to 0> (Bool)
+ +0x0E98 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `required` (id: 7) <defaults to 0> (Bool)
+ +0x0E9A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `key` (id: 8) <defaults to 0> (Bool)
+ +0x0E9C | 00 00 | VOffset16 | 0x0000 (0) | offset to field `attributes` (id: 9) <null> (Vector)
+ +0x0E9E | 10 00 | VOffset16 | 0x0010 (16) | offset to field `documentation` (id: 10)
+
+table (reflection.Field):
+ +0x0EA0 | 1A 00 00 00 | SOffset32 | 0x0000001A (26) Loc: +0x0E86 | offset to vtable
+ +0x0EA4 | 00 00 | uint8_t[2] | .. | padding
+ +0x0EA6 | 04 00 | uint16_t | 0x0004 (4) | table field `offset` (UShort)
+ +0x0EA8 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x0EC8 | offset to field `name` (string)
+ +0x0EAC | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x0EB8 | offset to field `type` (table)
+ +0x0EB0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0EB4 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x0EB4 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x0EB8 | D4 D7 FF FF | SOffset32 | 0xFFFFD7D4 (-10284) Loc: +0x36E4 | offset to vtable
+ +0x0EBC | 00 00 00 | uint8_t[3] | ... | padding
+ +0x0EBF | 03 | uint8_t | 0x03 (3) | table field `base_type` (Byte)
+ +0x0EC0 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x0EC4 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x0EC8 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x0ECC | 69 38 | char[2] | i8 | string literal
+ +0x0ECE | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Object):
+ +0x0ED0 | A8 D6 FF FF | SOffset32 | 0xFFFFD6A8 (-10584) Loc: +0x3828 | offset to vtable
+ +0x0ED4 | 30 01 00 00 | UOffset32 | 0x00000130 (304) Loc: +0x1004 | offset to field `name` (string)
+ +0x0ED8 | 50 00 00 00 | UOffset32 | 0x00000050 (80) Loc: +0x0F28 | offset to field `fields` (vector)
+ +0x0EDC | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `minalign` (Int)
+ +0x0EE0 | 08 00 00 00 | UOffset32 | 0x00000008 (8) Loc: +0x0EE8 | offset to field `documentation` (vector)
+ +0x0EE4 | 7C 28 00 00 | UOffset32 | 0x0000287C (10364) Loc: +0x3760 | offset to field `declaration_file` (string)
+
+vector (reflection.Object.documentation):
+ +0x0EE8 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x0EEC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0EF0 | offset to string[0]
+
+string (reflection.Object.documentation):
+ +0x0EF0 | 33 00 00 00 | uint32_t | 0x00000033 (51) | length of string
+ +0x0EF4 | 20 61 6E 20 65 78 61 6D | char[51] | an exam | string literal
+ +0x0EFC | 70 6C 65 20 64 6F 63 75 | | ple docu
+ +0x0F04 | 6D 65 6E 74 61 74 69 6F | | mentatio
+ +0x0F0C | 6E 20 63 6F 6D 6D 65 6E | | n commen
+ +0x0F14 | 74 3A 20 22 6D 6F 6E 73 | | t: "mons
+ +0x0F1C | 74 65 72 20 6F 62 6A 65 | | ter obje
+ +0x0F24 | 63 74 22 | | ct"
+ +0x0F27 | 00 | char | 0x00 (0) | string terminator
+
+vector (reflection.Object.fields):
+ +0x0F28 | 36 00 00 00 | uint32_t | 0x00000036 (54) | length of vector (# items)
+ +0x0F2C | 80 04 00 00 | UOffset32 | 0x00000480 (1152) Loc: +0x13AC | offset to table[0]
+ +0x0F30 | E4 04 00 00 | UOffset32 | 0x000004E4 (1252) Loc: +0x1414 | offset to table[1]
+ +0x0F34 | 4C 05 00 00 | UOffset32 | 0x0000054C (1356) Loc: +0x1480 | offset to table[2]
+ +0x0F38 | AC 05 00 00 | UOffset32 | 0x000005AC (1452) Loc: +0x14E4 | offset to table[3]
+ +0x0F3C | A8 09 00 00 | UOffset32 | 0x000009A8 (2472) Loc: +0x18E4 | offset to table[4]
+ +0x0F40 | 78 1B 00 00 | UOffset32 | 0x00001B78 (7032) Loc: +0x2AB8 | offset to table[5]
+ +0x0F44 | 88 18 00 00 | UOffset32 | 0x00001888 (6280) Loc: +0x27CC | offset to table[6]
+ +0x0F48 | 44 0F 00 00 | UOffset32 | 0x00000F44 (3908) Loc: +0x1E8C | offset to table[7]
+ +0x0F4C | 7C 1C 00 00 | UOffset32 | 0x00001C7C (7292) Loc: +0x2BC8 | offset to table[8]
+ +0x0F50 | C0 1D 00 00 | UOffset32 | 0x00001DC0 (7616) Loc: +0x2D10 | offset to table[9]
+ +0x0F54 | EC 1B 00 00 | UOffset32 | 0x00001BEC (7148) Loc: +0x2B40 | offset to table[10]
+ +0x0F58 | 44 01 00 00 | UOffset32 | 0x00000144 (324) Loc: +0x109C | offset to table[11]
+ +0x0F5C | C4 00 00 00 | UOffset32 | 0x000000C4 (196) Loc: +0x1020 | offset to table[12]
+ +0x0F60 | 30 1E 00 00 | UOffset32 | 0x00001E30 (7728) Loc: +0x2D90 | offset to table[13]
+ +0x0F64 | 30 1D 00 00 | UOffset32 | 0x00001D30 (7472) Loc: +0x2C94 | offset to table[14]
+ +0x0F68 | A8 01 00 00 | UOffset32 | 0x000001A8 (424) Loc: +0x1110 | offset to table[15]
+ +0x0F6C | 10 07 00 00 | UOffset32 | 0x00000710 (1808) Loc: +0x167C | offset to table[16]
+ +0x0F70 | 80 0D 00 00 | UOffset32 | 0x00000D80 (3456) Loc: +0x1CF0 | offset to table[17]
+ +0x0F74 | A0 1E 00 00 | UOffset32 | 0x00001EA0 (7840) Loc: +0x2E14 | offset to table[18]
+ +0x0F78 | 2C 02 00 00 | UOffset32 | 0x0000022C (556) Loc: +0x11A4 | offset to table[19]
+ +0x0F7C | 5C 03 00 00 | UOffset32 | 0x0000035C (860) Loc: +0x12D8 | offset to table[20]
+ +0x0F80 | 08 0C 00 00 | UOffset32 | 0x00000C08 (3080) Loc: +0x1B88 | offset to table[21]
+ +0x0F84 | 58 1A 00 00 | UOffset32 | 0x00001A58 (6744) Loc: +0x29DC | offset to table[22]
+ +0x0F88 | E4 19 00 00 | UOffset32 | 0x000019E4 (6628) Loc: +0x296C | offset to table[23]
+ +0x0F8C | A0 0E 00 00 | UOffset32 | 0x00000EA0 (3744) Loc: +0x1E2C | offset to table[24]
+ +0x0F90 | C4 1A 00 00 | UOffset32 | 0x00001AC4 (6852) Loc: +0x2A54 | offset to table[25]
+ +0x0F94 | 90 11 00 00 | UOffset32 | 0x00001190 (4496) Loc: +0x2124 | offset to table[26]
+ +0x0F98 | 78 0F 00 00 | UOffset32 | 0x00000F78 (3960) Loc: +0x1F10 | offset to table[27]
+ +0x0F9C | 68 19 00 00 | UOffset32 | 0x00001968 (6504) Loc: +0x2904 | offset to table[28]
+ +0x0FA0 | E0 0F 00 00 | UOffset32 | 0x00000FE0 (4064) Loc: +0x1F80 | offset to table[29]
+ +0x0FA4 | 88 18 00 00 | UOffset32 | 0x00001888 (6280) Loc: +0x282C | offset to table[30]
+ +0x0FA8 | C0 16 00 00 | UOffset32 | 0x000016C0 (5824) Loc: +0x2668 | offset to table[31]
+ +0x0FAC | 1C 17 00 00 | UOffset32 | 0x0000171C (5916) Loc: +0x26C8 | offset to table[32]
+ +0x0FB0 | 10 11 00 00 | UOffset32 | 0x00001110 (4368) Loc: +0x20C0 | offset to table[33]
+ +0x0FB4 | 8C 10 00 00 | UOffset32 | 0x0000108C (4236) Loc: +0x2040 | offset to table[34]
+ +0x0FB8 | 30 10 00 00 | UOffset32 | 0x00001030 (4144) Loc: +0x1FE8 | offset to table[35]
+ +0x0FBC | 20 16 00 00 | UOffset32 | 0x00001620 (5664) Loc: +0x25DC | offset to table[36]
+ +0x0FC0 | E0 13 00 00 | UOffset32 | 0x000013E0 (5088) Loc: +0x23A0 | offset to table[37]
+ +0x0FC4 | FC 14 00 00 | UOffset32 | 0x000014FC (5372) Loc: +0x24C0 | offset to table[38]
+ +0x0FC8 | 58 12 00 00 | UOffset32 | 0x00001258 (4696) Loc: +0x2220 | offset to table[39]
+ +0x0FCC | 84 15 00 00 | UOffset32 | 0x00001584 (5508) Loc: +0x2550 | offset to table[40]
+ +0x0FD0 | E4 12 00 00 | UOffset32 | 0x000012E4 (4836) Loc: +0x22B4 | offset to table[41]
+ +0x0FD4 | 5C 14 00 00 | UOffset32 | 0x0000145C (5212) Loc: +0x2430 | offset to table[42]
+ +0x0FD8 | B4 11 00 00 | UOffset32 | 0x000011B4 (4532) Loc: +0x218C | offset to table[43]
+ +0x0FDC | 50 17 00 00 | UOffset32 | 0x00001750 (5968) Loc: +0x272C | offset to table[44]
+ +0x0FE0 | 38 02 00 00 | UOffset32 | 0x00000238 (568) Loc: +0x1218 | offset to table[45]
+ +0x0FE4 | C0 07 00 00 | UOffset32 | 0x000007C0 (1984) Loc: +0x17A4 | offset to table[46]
+ +0x0FE8 | 78 0D 00 00 | UOffset32 | 0x00000D78 (3448) Loc: +0x1D60 | offset to table[47]
+ +0x0FEC | 58 03 00 00 | UOffset32 | 0x00000358 (856) Loc: +0x1344 | offset to table[48]
+ +0x0FF0 | D8 0D 00 00 | UOffset32 | 0x00000DD8 (3544) Loc: +0x1DC8 | offset to table[49]
+ +0x0FF4 | 58 05 00 00 | UOffset32 | 0x00000558 (1368) Loc: +0x154C | offset to table[50]
+ +0x0FF8 | 88 0C 00 00 | UOffset32 | 0x00000C88 (3208) Loc: +0x1C80 | offset to table[51]
+ +0x0FFC | DC 09 00 00 | UOffset32 | 0x000009DC (2524) Loc: +0x19D8 | offset to table[52]
+ +0x1000 | 8C 0A 00 00 | UOffset32 | 0x00000A8C (2700) Loc: +0x1A8C | offset to table[53]
+
+string (reflection.Object.name):
+ +0x1004 | 16 00 00 00 | uint32_t | 0x00000016 (22) | length of string
+ +0x1008 | 4D 79 47 61 6D 65 2E 45 | char[22] | MyGame.E | string literal
+ +0x1010 | 78 61 6D 70 6C 65 2E 4D | | xample.M
+ +0x1018 | 6F 6E 73 74 65 72 | | onster
+ +0x101E | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x1020 | 62 FD FF FF | SOffset32 | 0xFFFFFD62 (-670) Loc: +0x12BE | offset to vtable
+ +0x1024 | 35 00 | uint16_t | 0x0035 (53) | table field `id` (UShort)
+ +0x1026 | 6E 00 | uint16_t | 0x006E (110) | table field `offset` (UShort)
+ +0x1028 | 54 00 00 00 | UOffset32 | 0x00000054 (84) Loc: +0x107C | offset to field `name` (string)
+ +0x102C | 3C 00 00 00 | UOffset32 | 0x0000003C (60) Loc: +0x1068 | offset to field `type` (table)
+ +0x1030 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x1044 | offset to field `attributes` (vector)
+ +0x1034 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x1040 | offset to field `documentation` (vector)
+ +0x1038 | 02 00 00 00 00 00 00 00 | int64_t | 0x0000000000000002 (2) | table field `default_integer` (Long)
+
+vector (reflection.Field.documentation):
+ +0x1040 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x1044 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x1048 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x104C | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x104C | E8 DA FF FF | SOffset32 | 0xFFFFDAE8 (-9496) Loc: +0x3564 | offset to vtable
+ +0x1050 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x1060 | offset to field `key` (string)
+ +0x1054 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1058 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1058 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x105C | 35 33 | char[2] | 53 | string literal
+ +0x105E | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x1060 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1064 | 69 64 | char[2] | id | string literal
+ +0x1066 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x1068 | 64 DA FF FF | SOffset32 | 0xFFFFDA64 (-9628) Loc: +0x3604 | offset to vtable
+ +0x106C | 00 00 00 | uint8_t[3] | ... | padding
+ +0x106F | 0A | uint8_t | 0x0A (10) | table field `base_type` (Byte)
+ +0x1070 | 04 00 00 00 | uint32_t | 0x00000004 (4) | table field `index` (Int)
+ +0x1074 | 08 00 00 00 | uint32_t | 0x00000008 (8) | table field `base_size` (UInt)
+ +0x1078 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x107C | 18 00 00 00 | uint32_t | 0x00000018 (24) | length of string
+ +0x1080 | 6C 6F 6E 67 5F 65 6E 75 | char[24] | long_enu | string literal
+ +0x1088 | 6D 5F 6E 6F 72 6D 61 6C | | m_normal
+ +0x1090 | 5F 64 65 66 61 75 6C 74 | | _default
+ +0x1098 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1099 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Field):
+ +0x109C | 62 E6 FF FF | SOffset32 | 0xFFFFE662 (-6558) Loc: +0x2A3A | offset to vtable
+ +0x10A0 | 34 00 | uint16_t | 0x0034 (52) | table field `id` (UShort)
+ +0x10A2 | 6C 00 | uint16_t | 0x006C (108) | table field `offset` (UShort)
+ +0x10A4 | 4C 00 00 00 | UOffset32 | 0x0000004C (76) Loc: +0x10F0 | offset to field `name` (string)
+ +0x10A8 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x10DC | offset to field `type` (table)
+ +0x10AC | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x10B8 | offset to field `attributes` (vector)
+ +0x10B0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x10B4 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x10B4 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x10B8 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x10BC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x10C0 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x10C0 | 5C DB FF FF | SOffset32 | 0xFFFFDB5C (-9380) Loc: +0x3564 | offset to vtable
+ +0x10C4 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x10D4 | offset to field `key` (string)
+ +0x10C8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x10CC | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x10CC | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x10D0 | 35 32 | char[2] | 52 | string literal
+ +0x10D2 | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x10D4 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x10D8 | 69 64 | char[2] | id | string literal
+ +0x10DA | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x10DC | D8 DA FF FF | SOffset32 | 0xFFFFDAD8 (-9512) Loc: +0x3604 | offset to vtable
+ +0x10E0 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x10E3 | 0A | uint8_t | 0x0A (10) | table field `base_type` (Byte)
+ +0x10E4 | 04 00 00 00 | uint32_t | 0x00000004 (4) | table field `index` (Int)
+ +0x10E8 | 08 00 00 00 | uint32_t | 0x00000008 (8) | table field `base_size` (UInt)
+ +0x10EC | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x10F0 | 1A 00 00 00 | uint32_t | 0x0000001A (26) | length of string
+ +0x10F4 | 6C 6F 6E 67 5F 65 6E 75 | char[26] | long_enu | string literal
+ +0x10FC | 6D 5F 6E 6F 6E 5F 65 6E | | m_non_en
+ +0x1104 | 75 6D 5F 64 65 66 61 75 | | um_defau
+ +0x110C | 6C 74 | | lt
+ +0x110E | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x1110 | EC E5 FF FF | SOffset32 | 0xFFFFE5EC (-6676) Loc: +0x2B24 | offset to vtable
+ +0x1114 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x1117 | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x1118 | 33 00 | uint16_t | 0x0033 (51) | table field `id` (UShort)
+ +0x111A | 6A 00 | uint16_t | 0x006A (106) | table field `offset` (UShort)
+ +0x111C | 74 00 00 00 | UOffset32 | 0x00000074 (116) Loc: +0x1190 | offset to field `name` (string)
+ +0x1120 | 60 00 00 00 | UOffset32 | 0x00000060 (96) Loc: +0x1180 | offset to field `type` (table)
+ +0x1124 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x1130 | offset to field `attributes` (vector)
+ +0x1128 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x112C | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x112C | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x1130 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x1134 | 30 00 00 00 | UOffset32 | 0x00000030 (48) Loc: +0x1164 | offset to table[0]
+ +0x1138 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x113C | offset to table[1]
+
+table (reflection.KeyValue):
+ +0x113C | D8 DB FF FF | SOffset32 | 0xFFFFDBD8 (-9256) Loc: +0x3564 | offset to vtable
+ +0x1140 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x1150 | offset to field `key` (string)
+ +0x1144 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1148 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1148 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x114C | 30 | char[1] | 0 | string literal
+ +0x114D | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x114E | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x1150 | 0D 00 00 00 | uint32_t | 0x0000000D (13) | length of string
+ +0x1154 | 6E 61 74 69 76 65 5F 69 | char[13] | native_i | string literal
+ +0x115C | 6E 6C 69 6E 65 | | nline
+ +0x1161 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1162 | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.KeyValue):
+ +0x1164 | 00 DC FF FF | SOffset32 | 0xFFFFDC00 (-9216) Loc: +0x3564 | offset to vtable
+ +0x1168 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x1178 | offset to field `key` (string)
+ +0x116C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1170 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1170 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1174 | 35 31 | char[2] | 51 | string literal
+ +0x1176 | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x1178 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x117C | 69 64 | char[2] | id | string literal
+ +0x117E | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x1180 | C8 D8 FF FF | SOffset32 | 0xFFFFD8C8 (-10040) Loc: +0x38B8 | offset to vtable
+ +0x1184 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x1187 | 0F | uint8_t | 0x0F (15) | table field `base_type` (Byte)
+ +0x1188 | 06 00 00 00 | uint32_t | 0x00000006 (6) | table field `index` (Int)
+ +0x118C | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x1190 | 0D 00 00 00 | uint32_t | 0x0000000D (13) | length of string
+ +0x1194 | 6E 61 74 69 76 65 5F 69 | char[13] | native_i | string literal
+ +0x119C | 6E 6C 69 6E 65 | | nline
+ +0x11A1 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x11A2 | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Field):
+ +0x11A4 | 80 E6 FF FF | SOffset32 | 0xFFFFE680 (-6528) Loc: +0x2B24 | offset to vtable
+ +0x11A8 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x11AB | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x11AC | 32 00 | uint16_t | 0x0032 (50) | table field `id` (UShort)
+ +0x11AE | 68 00 | uint16_t | 0x0068 (104) | table field `offset` (UShort)
+ +0x11B0 | 48 00 00 00 | UOffset32 | 0x00000048 (72) Loc: +0x11F8 | offset to field `name` (string)
+ +0x11B4 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x11E8 | offset to field `type` (table)
+ +0x11B8 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x11C4 | offset to field `attributes` (vector)
+ +0x11BC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x11C0 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x11C0 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x11C4 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x11C8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x11CC | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x11CC | 68 DC FF FF | SOffset32 | 0xFFFFDC68 (-9112) Loc: +0x3564 | offset to vtable
+ +0x11D0 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x11E0 | offset to field `key` (string)
+ +0x11D4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x11D8 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x11D8 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x11DC | 35 30 | char[2] | 50 | string literal
+ +0x11DE | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x11E0 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x11E4 | 69 64 | char[2] | id | string literal
+ +0x11E6 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x11E8 | 38 E8 FF FF | SOffset32 | 0xFFFFE838 (-6088) Loc: +0x29B0 | offset to vtable
+ +0x11EC | 00 00 | uint8_t[2] | .. | padding
+ +0x11EE | 0E | uint8_t | 0x0E (14) | table field `base_type` (Byte)
+ +0x11EF | 0F | uint8_t | 0x0F (15) | table field `element` (Byte)
+ +0x11F0 | 03 00 00 00 | uint32_t | 0x00000003 (3) | table field `index` (Int)
+ +0x11F4 | 04 00 00 00 | uint32_t | 0x00000004 (4) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x11F8 | 18 00 00 00 | uint32_t | 0x00000018 (24) | length of string
+ +0x11FC | 73 63 61 6C 61 72 5F 6B | char[24] | scalar_k | string literal
+ +0x1204 | 65 79 5F 73 6F 72 74 65 | | ey_sorte
+ +0x120C | 64 5F 74 61 62 6C 65 73 | | d_tables
+ +0x1214 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1215 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Field):
+ +0x1218 | F4 E6 FF FF | SOffset32 | 0xFFFFE6F4 (-6412) Loc: +0x2B24 | offset to vtable
+ +0x121C | 00 00 00 | uint8_t[3] | ... | padding
+ +0x121F | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x1220 | 31 00 | uint16_t | 0x0031 (49) | table field `id` (UShort)
+ +0x1222 | 66 00 | uint16_t | 0x0066 (102) | table field `offset` (UShort)
+ +0x1224 | 78 00 00 00 | UOffset32 | 0x00000078 (120) Loc: +0x129C | offset to field `name` (string)
+ +0x1228 | 68 00 00 00 | UOffset32 | 0x00000068 (104) Loc: +0x1290 | offset to field `type` (table)
+ +0x122C | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x1238 | offset to field `attributes` (vector)
+ +0x1230 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1234 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x1234 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x1238 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x123C | 38 00 00 00 | UOffset32 | 0x00000038 (56) Loc: +0x1274 | offset to table[0]
+ +0x1240 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1244 | offset to table[1]
+
+table (reflection.KeyValue):
+ +0x1244 | E0 DC FF FF | SOffset32 | 0xFFFFDCE0 (-8992) Loc: +0x3564 | offset to vtable
+ +0x1248 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x125C | offset to field `key` (string)
+ +0x124C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1250 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1250 | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x1254 | 4D 6F 6E 73 74 65 72 | char[7] | Monster | string literal
+ +0x125B | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x125C | 11 00 00 00 | uint32_t | 0x00000011 (17) | length of string
+ +0x1260 | 6E 65 73 74 65 64 5F 66 | char[17] | nested_f | string literal
+ +0x1268 | 6C 61 74 62 75 66 66 65 | | latbuffe
+ +0x1270 | 72 | | r
+ +0x1271 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1272 | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.KeyValue):
+ +0x1274 | 10 DD FF FF | SOffset32 | 0xFFFFDD10 (-8944) Loc: +0x3564 | offset to vtable
+ +0x1278 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x1288 | offset to field `key` (string)
+ +0x127C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1280 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1280 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1284 | 34 39 | char[2] | 49 | string literal
+ +0x1286 | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x1288 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x128C | 69 64 | char[2] | id | string literal
+ +0x128E | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x1290 | 0C E7 FF FF | SOffset32 | 0xFFFFE70C (-6388) Loc: +0x2B84 | offset to vtable
+ +0x1294 | 00 00 | uint8_t[2] | .. | padding
+ +0x1296 | 0E | uint8_t | 0x0E (14) | table field `base_type` (Byte)
+ +0x1297 | 04 | uint8_t | 0x04 (4) | table field `element` (Byte)
+ +0x1298 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x129C | 1C 00 00 00 | uint32_t | 0x0000001C (28) | length of string
+ +0x12A0 | 74 65 73 74 72 65 71 75 | char[28] | testrequ | string literal
+ +0x12A8 | 69 72 65 64 6E 65 73 74 | | irednest
+ +0x12B0 | 65 64 66 6C 61 74 62 75 | | edflatbu
+ +0x12B8 | 66 66 65 72 | | ffer
+ +0x12BC | 00 | char | 0x00 (0) | string terminator
+
+vtable (reflection.Field):
+ +0x12BE | 1A 00 | uint16_t | 0x001A (26) | size of this vtable
+ +0x12C0 | 20 00 | uint16_t | 0x0020 (32) | size of referring table
+ +0x12C2 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `name` (id: 0)
+ +0x12C4 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `type` (id: 1)
+ +0x12C6 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `id` (id: 2)
+ +0x12C8 | 06 00 | VOffset16 | 0x0006 (6) | offset to field `offset` (id: 3)
+ +0x12CA | 18 00 | VOffset16 | 0x0018 (24) | offset to field `default_integer` (id: 4)
+ +0x12CC | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_real` (id: 5) <defaults to 0.000000> (Double)
+ +0x12CE | 00 00 | VOffset16 | 0x0000 (0) | offset to field `deprecated` (id: 6) <defaults to 0> (Bool)
+ +0x12D0 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `required` (id: 7) <defaults to 0> (Bool)
+ +0x12D2 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `key` (id: 8) <defaults to 0> (Bool)
+ +0x12D4 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `attributes` (id: 9)
+ +0x12D6 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `documentation` (id: 10)
+
+table (reflection.Field):
+ +0x12D8 | 1A 00 00 00 | SOffset32 | 0x0000001A (26) Loc: +0x12BE | offset to vtable
+ +0x12DC | 30 00 | uint16_t | 0x0030 (48) | table field `id` (UShort)
+ +0x12DE | 64 00 | uint16_t | 0x0064 (100) | table field `offset` (UShort)
+ +0x12E0 | 54 00 00 00 | UOffset32 | 0x00000054 (84) Loc: +0x1334 | offset to field `name` (string)
+ +0x12E4 | 3C 00 00 00 | UOffset32 | 0x0000003C (60) Loc: +0x1320 | offset to field `type` (table)
+ +0x12E8 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x12FC | offset to field `attributes` (vector)
+ +0x12EC | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x12F8 | offset to field `documentation` (vector)
+ +0x12F0 | FF FF FF FF FF FF FF FF | int64_t | 0xFFFFFFFFFFFFFFFF (-1) | table field `default_integer` (Long)
+
+vector (reflection.Field.documentation):
+ +0x12F8 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x12FC | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x1300 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1304 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x1304 | A0 DD FF FF | SOffset32 | 0xFFFFDDA0 (-8800) Loc: +0x3564 | offset to vtable
+ +0x1308 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x1318 | offset to field `key` (string)
+ +0x130C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1310 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1310 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1314 | 34 38 | char[2] | 48 | string literal
+ +0x1316 | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x1318 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x131C | 69 64 | char[2] | id | string literal
+ +0x131E | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x1320 | 1C DD FF FF | SOffset32 | 0xFFFFDD1C (-8932) Loc: +0x3604 | offset to vtable
+ +0x1324 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x1327 | 03 | uint8_t | 0x03 (3) | table field `base_type` (Byte)
+ +0x1328 | 05 00 00 00 | uint32_t | 0x00000005 (5) | table field `index` (Int)
+ +0x132C | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x1330 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x1334 | 0B 00 00 00 | uint32_t | 0x0000000B (11) | length of string
+ +0x1338 | 73 69 67 6E 65 64 5F 65 | char[11] | signed_e | string literal
+ +0x1340 | 6E 75 6D | | num
+ +0x1343 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x1344 | 20 E8 FF FF | SOffset32 | 0xFFFFE820 (-6112) Loc: +0x2B24 | offset to vtable
+ +0x1348 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x134B | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x134C | 2F 00 | uint16_t | 0x002F (47) | table field `id` (UShort)
+ +0x134E | 62 00 | uint16_t | 0x0062 (98) | table field `offset` (UShort)
+ +0x1350 | 48 00 00 00 | UOffset32 | 0x00000048 (72) Loc: +0x1398 | offset to field `name` (string)
+ +0x1354 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x1388 | offset to field `type` (table)
+ +0x1358 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x1364 | offset to field `attributes` (vector)
+ +0x135C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1360 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x1360 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x1364 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x1368 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x136C | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x136C | 08 DE FF FF | SOffset32 | 0xFFFFDE08 (-8696) Loc: +0x3564 | offset to vtable
+ +0x1370 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x1380 | offset to field `key` (string)
+ +0x1374 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1378 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1378 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x137C | 34 37 | char[2] | 47 | string literal
+ +0x137E | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x1380 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1384 | 69 64 | char[2] | id | string literal
+ +0x1386 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x1388 | D8 E9 FF FF | SOffset32 | 0xFFFFE9D8 (-5672) Loc: +0x29B0 | offset to vtable
+ +0x138C | 00 00 | uint8_t[2] | .. | padding
+ +0x138E | 0E | uint8_t | 0x0E (14) | table field `base_type` (Byte)
+ +0x138F | 04 | uint8_t | 0x04 (4) | table field `element` (Byte)
+ +0x1390 | 03 00 00 00 | uint32_t | 0x00000003 (3) | table field `index` (Int)
+ +0x1394 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x1398 | 0F 00 00 00 | uint32_t | 0x0000000F (15) | length of string
+ +0x139C | 76 65 63 74 6F 72 5F 6F | char[15] | vector_o | string literal
+ +0x13A4 | 66 5F 65 6E 75 6D 73 | | f_enums
+ +0x13AB | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x13AC | 88 E8 FF FF | SOffset32 | 0xFFFFE888 (-6008) Loc: +0x2B24 | offset to vtable
+ +0x13B0 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x13B3 | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x13B4 | 2E 00 | uint16_t | 0x002E (46) | table field `id` (UShort)
+ +0x13B6 | 60 00 | uint16_t | 0x0060 (96) | table field `offset` (UShort)
+ +0x13B8 | 48 00 00 00 | UOffset32 | 0x00000048 (72) Loc: +0x1400 | offset to field `name` (string)
+ +0x13BC | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x13F0 | offset to field `type` (table)
+ +0x13C0 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x13CC | offset to field `attributes` (vector)
+ +0x13C4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x13C8 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x13C8 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x13CC | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x13D0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x13D4 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x13D4 | 70 DE FF FF | SOffset32 | 0xFFFFDE70 (-8592) Loc: +0x3564 | offset to vtable
+ +0x13D8 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x13E8 | offset to field `key` (string)
+ +0x13DC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x13E0 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x13E0 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x13E4 | 34 36 | char[2] | 46 | string literal
+ +0x13E6 | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x13E8 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x13EC | 69 64 | char[2] | id | string literal
+ +0x13EE | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x13F0 | 38 DB FF FF | SOffset32 | 0xFFFFDB38 (-9416) Loc: +0x38B8 | offset to vtable
+ +0x13F4 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x13F7 | 10 | uint8_t | 0x10 (16) | table field `base_type` (Byte)
+ +0x13F8 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `index` (Int)
+ +0x13FC | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x1400 | 0D 00 00 00 | uint32_t | 0x0000000D (13) | length of string
+ +0x1404 | 61 6E 79 5F 61 6D 62 69 | char[13] | any_ambi | string literal
+ +0x140C | 67 75 6F 75 73 | | guous
+ +0x1411 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1412 | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Field):
+ +0x1414 | DA E9 FF FF | SOffset32 | 0xFFFFE9DA (-5670) Loc: +0x2A3A | offset to vtable
+ +0x1418 | 2D 00 | uint16_t | 0x002D (45) | table field `id` (UShort)
+ +0x141A | 5E 00 | uint16_t | 0x005E (94) | table field `offset` (UShort)
+ +0x141C | 4C 00 00 00 | UOffset32 | 0x0000004C (76) Loc: +0x1468 | offset to field `name` (string)
+ +0x1420 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x1454 | offset to field `type` (table)
+ +0x1424 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x1430 | offset to field `attributes` (vector)
+ +0x1428 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x142C | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x142C | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x1430 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x1434 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1438 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x1438 | D4 DE FF FF | SOffset32 | 0xFFFFDED4 (-8492) Loc: +0x3564 | offset to vtable
+ +0x143C | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x144C | offset to field `key` (string)
+ +0x1440 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1444 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1444 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1448 | 34 35 | char[2] | 45 | string literal
+ +0x144A | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x144C | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1450 | 69 64 | char[2] | id | string literal
+ +0x1452 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x1454 | 50 DE FF FF | SOffset32 | 0xFFFFDE50 (-8624) Loc: +0x3604 | offset to vtable
+ +0x1458 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x145B | 01 | uint8_t | 0x01 (1) | table field `base_type` (Byte)
+ +0x145C | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `index` (Int)
+ +0x1460 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x1464 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x1468 | 12 00 00 00 | uint32_t | 0x00000012 (18) | length of string
+ +0x146C | 61 6E 79 5F 61 6D 62 69 | char[18] | any_ambi | string literal
+ +0x1474 | 67 75 6F 75 73 5F 74 79 | | guous_ty
+ +0x147C | 70 65 | | pe
+ +0x147E | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x1480 | 5C E9 FF FF | SOffset32 | 0xFFFFE95C (-5796) Loc: +0x2B24 | offset to vtable
+ +0x1484 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x1487 | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x1488 | 2C 00 | uint16_t | 0x002C (44) | table field `id` (UShort)
+ +0x148A | 5C 00 | uint16_t | 0x005C (92) | table field `offset` (UShort)
+ +0x148C | 48 00 00 00 | UOffset32 | 0x00000048 (72) Loc: +0x14D4 | offset to field `name` (string)
+ +0x1490 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x14C4 | offset to field `type` (table)
+ +0x1494 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x14A0 | offset to field `attributes` (vector)
+ +0x1498 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x149C | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x149C | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x14A0 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x14A4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x14A8 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x14A8 | 44 DF FF FF | SOffset32 | 0xFFFFDF44 (-8380) Loc: +0x3564 | offset to vtable
+ +0x14AC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x14BC | offset to field `key` (string)
+ +0x14B0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x14B4 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x14B4 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x14B8 | 34 34 | char[2] | 44 | string literal
+ +0x14BA | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x14BC | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x14C0 | 69 64 | char[2] | id | string literal
+ +0x14C2 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x14C4 | 0C DC FF FF | SOffset32 | 0xFFFFDC0C (-9204) Loc: +0x38B8 | offset to vtable
+ +0x14C8 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x14CB | 10 | uint8_t | 0x10 (16) | table field `base_type` (Byte)
+ +0x14CC | 02 00 00 00 | uint32_t | 0x00000002 (2) | table field `index` (Int)
+ +0x14D0 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x14D4 | 0A 00 00 00 | uint32_t | 0x0000000A (10) | length of string
+ +0x14D8 | 61 6E 79 5F 75 6E 69 71 | char[10] | any_uniq | string literal
+ +0x14E0 | 75 65 | | ue
+ +0x14E2 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x14E4 | AA EA FF FF | SOffset32 | 0xFFFFEAAA (-5462) Loc: +0x2A3A | offset to vtable
+ +0x14E8 | 2B 00 | uint16_t | 0x002B (43) | table field `id` (UShort)
+ +0x14EA | 5A 00 | uint16_t | 0x005A (90) | table field `offset` (UShort)
+ +0x14EC | 4C 00 00 00 | UOffset32 | 0x0000004C (76) Loc: +0x1538 | offset to field `name` (string)
+ +0x14F0 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x1524 | offset to field `type` (table)
+ +0x14F4 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x1500 | offset to field `attributes` (vector)
+ +0x14F8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x14FC | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x14FC | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x1500 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x1504 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1508 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x1508 | A4 DF FF FF | SOffset32 | 0xFFFFDFA4 (-8284) Loc: +0x3564 | offset to vtable
+ +0x150C | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x151C | offset to field `key` (string)
+ +0x1510 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1514 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1514 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1518 | 34 33 | char[2] | 43 | string literal
+ +0x151A | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x151C | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1520 | 69 64 | char[2] | id | string literal
+ +0x1522 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x1524 | 20 DF FF FF | SOffset32 | 0xFFFFDF20 (-8416) Loc: +0x3604 | offset to vtable
+ +0x1528 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x152B | 01 | uint8_t | 0x01 (1) | table field `base_type` (Byte)
+ +0x152C | 02 00 00 00 | uint32_t | 0x00000002 (2) | table field `index` (Int)
+ +0x1530 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x1534 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x1538 | 0F 00 00 00 | uint32_t | 0x0000000F (15) | length of string
+ +0x153C | 61 6E 79 5F 75 6E 69 71 | char[15] | any_uniq | string literal
+ +0x1544 | 75 65 5F 74 79 70 65 | | ue_type
+ +0x154B | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x154C | 28 EA FF FF | SOffset32 | 0xFFFFEA28 (-5592) Loc: +0x2B24 | offset to vtable
+ +0x1550 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x1553 | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x1554 | 2A 00 | uint16_t | 0x002A (42) | table field `id` (UShort)
+ +0x1556 | 58 00 | uint16_t | 0x0058 (88) | table field `offset` (UShort)
+ +0x1558 | 00 01 00 00 | UOffset32 | 0x00000100 (256) Loc: +0x1658 | offset to field `name` (string)
+ +0x155C | F0 00 00 00 | UOffset32 | 0x000000F0 (240) Loc: +0x164C | offset to field `type` (table)
+ +0x1560 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x156C | offset to field `attributes` (vector)
+ +0x1564 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1568 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x1568 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x156C | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of vector (# items)
+ +0x1570 | B0 00 00 00 | UOffset32 | 0x000000B0 (176) Loc: +0x1620 | offset to table[0]
+ +0x1574 | 80 00 00 00 | UOffset32 | 0x00000080 (128) Loc: +0x15F4 | offset to table[1]
+ +0x1578 | 50 00 00 00 | UOffset32 | 0x00000050 (80) Loc: +0x15C8 | offset to table[2]
+ +0x157C | 24 00 00 00 | UOffset32 | 0x00000024 (36) Loc: +0x15A0 | offset to table[3]
+ +0x1580 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1584 | offset to table[4]
+
+table (reflection.KeyValue):
+ +0x1584 | 20 E0 FF FF | SOffset32 | 0xFFFFE020 (-8160) Loc: +0x3564 | offset to vtable
+ +0x1588 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x1598 | offset to field `key` (string)
+ +0x158C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1590 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1590 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1594 | 34 32 | char[2] | 42 | string literal
+ +0x1596 | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x1598 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x159C | 69 64 | char[2] | id | string literal
+ +0x159E | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.KeyValue):
+ +0x15A0 | 3C E0 FF FF | SOffset32 | 0xFFFFE03C (-8132) Loc: +0x3564 | offset to vtable
+ +0x15A4 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x15BC | offset to field `key` (string)
+ +0x15A8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x15AC | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x15AC | 08 00 00 00 | uint32_t | 0x00000008 (8) | length of string
+ +0x15B0 | 66 6E 76 31 61 5F 36 34 | char[8] | fnv1a_64 | string literal
+ +0x15B8 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x15B9 | 00 00 00 | uint8_t[3] | ... | padding
+
+string (reflection.KeyValue.key):
+ +0x15BC | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x15C0 | 68 61 73 68 | char[4] | hash | string literal
+ +0x15C4 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x15C5 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.KeyValue):
+ +0x15C8 | 64 E0 FF FF | SOffset32 | 0xFFFFE064 (-8092) Loc: +0x3564 | offset to vtable
+ +0x15CC | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x15E4 | offset to field `key` (string)
+ +0x15D0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x15D4 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x15D4 | 0B 00 00 00 | uint32_t | 0x0000000B (11) | length of string
+ +0x15D8 | 52 65 66 65 72 72 61 62 | char[11] | Referrab | string literal
+ +0x15E0 | 6C 65 54 | | leT
+ +0x15E3 | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x15E4 | 08 00 00 00 | uint32_t | 0x00000008 (8) | length of string
+ +0x15E8 | 63 70 70 5F 74 79 70 65 | char[8] | cpp_type | string literal
+ +0x15F0 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x15F1 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.KeyValue):
+ +0x15F4 | 90 E0 FF FF | SOffset32 | 0xFFFFE090 (-8048) Loc: +0x3564 | offset to vtable
+ +0x15F8 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x1608 | offset to field `key` (string)
+ +0x15FC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1600 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1600 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of string
+ +0x1604 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1605 | 00 00 00 | uint8_t[3] | ... | padding
+
+string (reflection.KeyValue.key):
+ +0x1608 | 10 00 00 00 | uint32_t | 0x00000010 (16) | length of string
+ +0x160C | 63 70 70 5F 70 74 72 5F | char[16] | cpp_ptr_ | string literal
+ +0x1614 | 74 79 70 65 5F 67 65 74 | | type_get
+ +0x161C | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x161D | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.KeyValue):
+ +0x1620 | BC E0 FF FF | SOffset32 | 0xFFFFE0BC (-8004) Loc: +0x3564 | offset to vtable
+ +0x1624 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x1638 | offset to field `key` (string)
+ +0x1628 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x162C | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x162C | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x1630 | 6E 61 6B 65 64 | char[5] | naked | string literal
+ +0x1635 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1636 | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x1638 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | length of string
+ +0x163C | 63 70 70 5F 70 74 72 5F | char[12] | cpp_ptr_ | string literal
+ +0x1644 | 74 79 70 65 | | type
+ +0x1648 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1649 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Type):
+ +0x164C | C8 EA FF FF | SOffset32 | 0xFFFFEAC8 (-5432) Loc: +0x2B84 | offset to vtable
+ +0x1650 | 00 00 | uint8_t[2] | .. | padding
+ +0x1652 | 0E | uint8_t | 0x0E (14) | table field `base_type` (Byte)
+ +0x1653 | 0A | uint8_t | 0x0A (10) | table field `element` (Byte)
+ +0x1654 | 08 00 00 00 | uint32_t | 0x00000008 (8) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x1658 | 1F 00 00 00 | uint32_t | 0x0000001F (31) | length of string
+ +0x165C | 76 65 63 74 6F 72 5F 6F | char[31] | vector_o | string literal
+ +0x1664 | 66 5F 6E 6F 6E 5F 6F 77 | | f_non_ow
+ +0x166C | 6E 69 6E 67 5F 72 65 66 | | ning_ref
+ +0x1674 | 65 72 65 6E 63 65 73 | | erences
+ +0x167B | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x167C | 42 EC FF FF | SOffset32 | 0xFFFFEC42 (-5054) Loc: +0x2A3A | offset to vtable
+ +0x1680 | 29 00 | uint16_t | 0x0029 (41) | table field `id` (UShort)
+ +0x1682 | 56 00 | uint16_t | 0x0056 (86) | table field `offset` (UShort)
+ +0x1684 | 04 01 00 00 | UOffset32 | 0x00000104 (260) Loc: +0x1788 | offset to field `name` (string)
+ +0x1688 | F0 00 00 00 | UOffset32 | 0x000000F0 (240) Loc: +0x1778 | offset to field `type` (table)
+ +0x168C | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x1698 | offset to field `attributes` (vector)
+ +0x1690 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1694 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x1694 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x1698 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of vector (# items)
+ +0x169C | B0 00 00 00 | UOffset32 | 0x000000B0 (176) Loc: +0x174C | offset to table[0]
+ +0x16A0 | 80 00 00 00 | UOffset32 | 0x00000080 (128) Loc: +0x1720 | offset to table[1]
+ +0x16A4 | 50 00 00 00 | UOffset32 | 0x00000050 (80) Loc: +0x16F4 | offset to table[2]
+ +0x16A8 | 24 00 00 00 | UOffset32 | 0x00000024 (36) Loc: +0x16CC | offset to table[3]
+ +0x16AC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x16B0 | offset to table[4]
+
+table (reflection.KeyValue):
+ +0x16B0 | 4C E1 FF FF | SOffset32 | 0xFFFFE14C (-7860) Loc: +0x3564 | offset to vtable
+ +0x16B4 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x16C4 | offset to field `key` (string)
+ +0x16B8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x16BC | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x16BC | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x16C0 | 34 31 | char[2] | 41 | string literal
+ +0x16C2 | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x16C4 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x16C8 | 69 64 | char[2] | id | string literal
+ +0x16CA | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.KeyValue):
+ +0x16CC | 68 E1 FF FF | SOffset32 | 0xFFFFE168 (-7832) Loc: +0x3564 | offset to vtable
+ +0x16D0 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x16E8 | offset to field `key` (string)
+ +0x16D4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x16D8 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x16D8 | 08 00 00 00 | uint32_t | 0x00000008 (8) | length of string
+ +0x16DC | 66 6E 76 31 61 5F 36 34 | char[8] | fnv1a_64 | string literal
+ +0x16E4 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x16E5 | 00 00 00 | uint8_t[3] | ... | padding
+
+string (reflection.KeyValue.key):
+ +0x16E8 | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x16EC | 68 61 73 68 | char[4] | hash | string literal
+ +0x16F0 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x16F1 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.KeyValue):
+ +0x16F4 | 90 E1 FF FF | SOffset32 | 0xFFFFE190 (-7792) Loc: +0x3564 | offset to vtable
+ +0x16F8 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x1710 | offset to field `key` (string)
+ +0x16FC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1700 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1700 | 0B 00 00 00 | uint32_t | 0x0000000B (11) | length of string
+ +0x1704 | 52 65 66 65 72 72 61 62 | char[11] | Referrab | string literal
+ +0x170C | 6C 65 54 | | leT
+ +0x170F | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x1710 | 08 00 00 00 | uint32_t | 0x00000008 (8) | length of string
+ +0x1714 | 63 70 70 5F 74 79 70 65 | char[8] | cpp_type | string literal
+ +0x171C | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x171D | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.KeyValue):
+ +0x1720 | BC E1 FF FF | SOffset32 | 0xFFFFE1BC (-7748) Loc: +0x3564 | offset to vtable
+ +0x1724 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x1734 | offset to field `key` (string)
+ +0x1728 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x172C | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x172C | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of string
+ +0x1730 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1731 | 00 00 00 | uint8_t[3] | ... | padding
+
+string (reflection.KeyValue.key):
+ +0x1734 | 10 00 00 00 | uint32_t | 0x00000010 (16) | length of string
+ +0x1738 | 63 70 70 5F 70 74 72 5F | char[16] | cpp_ptr_ | string literal
+ +0x1740 | 74 79 70 65 5F 67 65 74 | | type_get
+ +0x1748 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1749 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.KeyValue):
+ +0x174C | E8 E1 FF FF | SOffset32 | 0xFFFFE1E8 (-7704) Loc: +0x3564 | offset to vtable
+ +0x1750 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x1764 | offset to field `key` (string)
+ +0x1754 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1758 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1758 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x175C | 6E 61 6B 65 64 | char[5] | naked | string literal
+ +0x1761 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1762 | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x1764 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | length of string
+ +0x1768 | 63 70 70 5F 70 74 72 5F | char[12] | cpp_ptr_ | string literal
+ +0x1770 | 74 79 70 65 | | type
+ +0x1774 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1775 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Type):
+ +0x1778 | 94 E0 FF FF | SOffset32 | 0xFFFFE094 (-8044) Loc: +0x36E4 | offset to vtable
+ +0x177C | 00 00 00 | uint8_t[3] | ... | padding
+ +0x177F | 0A | uint8_t | 0x0A (10) | table field `base_type` (Byte)
+ +0x1780 | 08 00 00 00 | uint32_t | 0x00000008 (8) | table field `base_size` (UInt)
+ +0x1784 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x1788 | 14 00 00 00 | uint32_t | 0x00000014 (20) | length of string
+ +0x178C | 6E 6F 6E 5F 6F 77 6E 69 | char[20] | non_owni | string literal
+ +0x1794 | 6E 67 5F 72 65 66 65 72 | | ng_refer
+ +0x179C | 65 6E 63 65 | | ence
+ +0x17A0 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x17A1 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Field):
+ +0x17A4 | 80 EC FF FF | SOffset32 | 0xFFFFEC80 (-4992) Loc: +0x2B24 | offset to vtable
+ +0x17A8 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x17AB | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x17AC | 28 00 | uint16_t | 0x0028 (40) | table field `id` (UShort)
+ +0x17AE | 54 00 | uint16_t | 0x0054 (84) | table field `offset` (UShort)
+ +0x17B0 | 10 01 00 00 | UOffset32 | 0x00000110 (272) Loc: +0x18C0 | offset to field `name` (string)
+ +0x17B4 | 00 01 00 00 | UOffset32 | 0x00000100 (256) Loc: +0x18B4 | offset to field `type` (table)
+ +0x17B8 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x17C4 | offset to field `attributes` (vector)
+ +0x17BC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x17C0 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x17C0 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x17C4 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of vector (# items)
+ +0x17C8 | B4 00 00 00 | UOffset32 | 0x000000B4 (180) Loc: +0x187C | offset to table[0]
+ +0x17CC | 80 00 00 00 | UOffset32 | 0x00000080 (128) Loc: +0x184C | offset to table[1]
+ +0x17D0 | 50 00 00 00 | UOffset32 | 0x00000050 (80) Loc: +0x1820 | offset to table[2]
+ +0x17D4 | 24 00 00 00 | UOffset32 | 0x00000024 (36) Loc: +0x17F8 | offset to table[3]
+ +0x17D8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x17DC | offset to table[4]
+
+table (reflection.KeyValue):
+ +0x17DC | 78 E2 FF FF | SOffset32 | 0xFFFFE278 (-7560) Loc: +0x3564 | offset to vtable
+ +0x17E0 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x17F0 | offset to field `key` (string)
+ +0x17E4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x17E8 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x17E8 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x17EC | 34 30 | char[2] | 40 | string literal
+ +0x17EE | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x17F0 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x17F4 | 69 64 | char[2] | id | string literal
+ +0x17F6 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.KeyValue):
+ +0x17F8 | 94 E2 FF FF | SOffset32 | 0xFFFFE294 (-7532) Loc: +0x3564 | offset to vtable
+ +0x17FC | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x1814 | offset to field `key` (string)
+ +0x1800 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1804 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1804 | 08 00 00 00 | uint32_t | 0x00000008 (8) | length of string
+ +0x1808 | 66 6E 76 31 61 5F 36 34 | char[8] | fnv1a_64 | string literal
+ +0x1810 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1811 | 00 00 00 | uint8_t[3] | ... | padding
+
+string (reflection.KeyValue.key):
+ +0x1814 | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x1818 | 68 61 73 68 | char[4] | hash | string literal
+ +0x181C | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x181D | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.KeyValue):
+ +0x1820 | BC E2 FF FF | SOffset32 | 0xFFFFE2BC (-7492) Loc: +0x3564 | offset to vtable
+ +0x1824 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x183C | offset to field `key` (string)
+ +0x1828 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x182C | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x182C | 0B 00 00 00 | uint32_t | 0x0000000B (11) | length of string
+ +0x1830 | 52 65 66 65 72 72 61 62 | char[11] | Referrab | string literal
+ +0x1838 | 6C 65 54 | | leT
+ +0x183B | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x183C | 08 00 00 00 | uint32_t | 0x00000008 (8) | length of string
+ +0x1840 | 63 70 70 5F 74 79 70 65 | char[8] | cpp_type | string literal
+ +0x1848 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1849 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.KeyValue):
+ +0x184C | E8 E2 FF FF | SOffset32 | 0xFFFFE2E8 (-7448) Loc: +0x3564 | offset to vtable
+ +0x1850 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x1864 | offset to field `key` (string)
+ +0x1854 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1858 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1858 | 06 00 00 00 | uint32_t | 0x00000006 (6) | length of string
+ +0x185C | 2E 67 65 74 28 29 | char[6] | .get() | string literal
+ +0x1862 | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x1864 | 10 00 00 00 | uint32_t | 0x00000010 (16) | length of string
+ +0x1868 | 63 70 70 5F 70 74 72 5F | char[16] | cpp_ptr_ | string literal
+ +0x1870 | 74 79 70 65 5F 67 65 74 | | type_get
+ +0x1878 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1879 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.KeyValue):
+ +0x187C | 18 E3 FF FF | SOffset32 | 0xFFFFE318 (-7400) Loc: +0x3564 | offset to vtable
+ +0x1880 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x18A0 | offset to field `key` (string)
+ +0x1884 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1888 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1888 | 10 00 00 00 | uint32_t | 0x00000010 (16) | length of string
+ +0x188C | 64 65 66 61 75 6C 74 5F | char[16] | default_ | string literal
+ +0x1894 | 70 74 72 5F 74 79 70 65 | | ptr_type
+ +0x189C | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x189D | 00 00 00 | uint8_t[3] | ... | padding
+
+string (reflection.KeyValue.key):
+ +0x18A0 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | length of string
+ +0x18A4 | 63 70 70 5F 70 74 72 5F | char[12] | cpp_ptr_ | string literal
+ +0x18AC | 74 79 70 65 | | type
+ +0x18B0 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x18B1 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Type):
+ +0x18B4 | 30 ED FF FF | SOffset32 | 0xFFFFED30 (-4816) Loc: +0x2B84 | offset to vtable
+ +0x18B8 | 00 00 | uint8_t[2] | .. | padding
+ +0x18BA | 0E | uint8_t | 0x0E (14) | table field `base_type` (Byte)
+ +0x18BB | 0A | uint8_t | 0x0A (10) | table field `element` (Byte)
+ +0x18BC | 08 00 00 00 | uint32_t | 0x00000008 (8) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x18C0 | 1E 00 00 00 | uint32_t | 0x0000001E (30) | length of string
+ +0x18C4 | 76 65 63 74 6F 72 5F 6F | char[30] | vector_o | string literal
+ +0x18CC | 66 5F 63 6F 5F 6F 77 6E | | f_co_own
+ +0x18D4 | 69 6E 67 5F 72 65 66 65 | | ing_refe
+ +0x18DC | 72 65 6E 63 65 73 | | rences
+ +0x18E2 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x18E4 | AA EE FF FF | SOffset32 | 0xFFFFEEAA (-4438) Loc: +0x2A3A | offset to vtable
+ +0x18E8 | 27 00 | uint16_t | 0x0027 (39) | table field `id` (UShort)
+ +0x18EA | 52 00 | uint16_t | 0x0052 (82) | table field `offset` (UShort)
+ +0x18EC | D4 00 00 00 | UOffset32 | 0x000000D4 (212) Loc: +0x19C0 | offset to field `name` (string)
+ +0x18F0 | C0 00 00 00 | UOffset32 | 0x000000C0 (192) Loc: +0x19B0 | offset to field `type` (table)
+ +0x18F4 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x1900 | offset to field `attributes` (vector)
+ +0x18F8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x18FC | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x18FC | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x1900 | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of vector (# items)
+ +0x1904 | 80 00 00 00 | UOffset32 | 0x00000080 (128) Loc: +0x1984 | offset to table[0]
+ +0x1908 | 50 00 00 00 | UOffset32 | 0x00000050 (80) Loc: +0x1958 | offset to table[1]
+ +0x190C | 24 00 00 00 | UOffset32 | 0x00000024 (36) Loc: +0x1930 | offset to table[2]
+ +0x1910 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1914 | offset to table[3]
+
+table (reflection.KeyValue):
+ +0x1914 | B0 E3 FF FF | SOffset32 | 0xFFFFE3B0 (-7248) Loc: +0x3564 | offset to vtable
+ +0x1918 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x1928 | offset to field `key` (string)
+ +0x191C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1920 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1920 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1924 | 33 39 | char[2] | 39 | string literal
+ +0x1926 | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x1928 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x192C | 69 64 | char[2] | id | string literal
+ +0x192E | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.KeyValue):
+ +0x1930 | CC E3 FF FF | SOffset32 | 0xFFFFE3CC (-7220) Loc: +0x3564 | offset to vtable
+ +0x1934 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x194C | offset to field `key` (string)
+ +0x1938 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x193C | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x193C | 08 00 00 00 | uint32_t | 0x00000008 (8) | length of string
+ +0x1940 | 66 6E 76 31 61 5F 36 34 | char[8] | fnv1a_64 | string literal
+ +0x1948 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1949 | 00 00 00 | uint8_t[3] | ... | padding
+
+string (reflection.KeyValue.key):
+ +0x194C | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x1950 | 68 61 73 68 | char[4] | hash | string literal
+ +0x1954 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1955 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.KeyValue):
+ +0x1958 | F4 E3 FF FF | SOffset32 | 0xFFFFE3F4 (-7180) Loc: +0x3564 | offset to vtable
+ +0x195C | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x1974 | offset to field `key` (string)
+ +0x1960 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1964 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1964 | 0B 00 00 00 | uint32_t | 0x0000000B (11) | length of string
+ +0x1968 | 52 65 66 65 72 72 61 62 | char[11] | Referrab | string literal
+ +0x1970 | 6C 65 54 | | leT
+ +0x1973 | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x1974 | 08 00 00 00 | uint32_t | 0x00000008 (8) | length of string
+ +0x1978 | 63 70 70 5F 74 79 70 65 | char[8] | cpp_type | string literal
+ +0x1980 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1981 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.KeyValue):
+ +0x1984 | 20 E4 FF FF | SOffset32 | 0xFFFFE420 (-7136) Loc: +0x3564 | offset to vtable
+ +0x1988 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x199C | offset to field `key` (string)
+ +0x198C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1990 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1990 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x1994 | 6E 61 6B 65 64 | char[5] | naked | string literal
+ +0x1999 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x199A | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x199C | 0C 00 00 00 | uint32_t | 0x0000000C (12) | length of string
+ +0x19A0 | 63 70 70 5F 70 74 72 5F | char[12] | cpp_ptr_ | string literal
+ +0x19A8 | 74 79 70 65 | | type
+ +0x19AC | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x19AD | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Type):
+ +0x19B0 | CC E2 FF FF | SOffset32 | 0xFFFFE2CC (-7476) Loc: +0x36E4 | offset to vtable
+ +0x19B4 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x19B7 | 0A | uint8_t | 0x0A (10) | table field `base_type` (Byte)
+ +0x19B8 | 08 00 00 00 | uint32_t | 0x00000008 (8) | table field `base_size` (UInt)
+ +0x19BC | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x19C0 | 13 00 00 00 | uint32_t | 0x00000013 (19) | length of string
+ +0x19C4 | 63 6F 5F 6F 77 6E 69 6E | char[19] | co_ownin | string literal
+ +0x19CC | 67 5F 72 65 66 65 72 65 | | g_refere
+ +0x19D4 | 6E 63 65 | | nce
+ +0x19D7 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x19D8 | B4 EE FF FF | SOffset32 | 0xFFFFEEB4 (-4428) Loc: +0x2B24 | offset to vtable
+ +0x19DC | 00 00 00 | uint8_t[3] | ... | padding
+ +0x19DF | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x19E0 | 26 00 | uint16_t | 0x0026 (38) | table field `id` (UShort)
+ +0x19E2 | 50 00 | uint16_t | 0x0050 (80) | table field `offset` (UShort)
+ +0x19E4 | 84 00 00 00 | UOffset32 | 0x00000084 (132) Loc: +0x1A68 | offset to field `name` (string)
+ +0x19E8 | 70 00 00 00 | UOffset32 | 0x00000070 (112) Loc: +0x1A58 | offset to field `type` (table)
+ +0x19EC | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x19F8 | offset to field `attributes` (vector)
+ +0x19F0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x19F4 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x19F4 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x19F8 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x19FC | 24 00 00 00 | UOffset32 | 0x00000024 (36) Loc: +0x1A20 | offset to table[0]
+ +0x1A00 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1A04 | offset to table[1]
+
+table (reflection.KeyValue):
+ +0x1A04 | A0 E4 FF FF | SOffset32 | 0xFFFFE4A0 (-7008) Loc: +0x3564 | offset to vtable
+ +0x1A08 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x1A18 | offset to field `key` (string)
+ +0x1A0C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1A10 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1A10 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1A14 | 33 38 | char[2] | 38 | string literal
+ +0x1A16 | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x1A18 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1A1C | 69 64 | char[2] | id | string literal
+ +0x1A1E | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.KeyValue):
+ +0x1A20 | BC E4 FF FF | SOffset32 | 0xFFFFE4BC (-6980) Loc: +0x3564 | offset to vtable
+ +0x1A24 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x1A44 | offset to field `key` (string)
+ +0x1A28 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1A2C | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1A2C | 10 00 00 00 | uint32_t | 0x00000010 (16) | length of string
+ +0x1A30 | 64 65 66 61 75 6C 74 5F | char[16] | default_ | string literal
+ +0x1A38 | 70 74 72 5F 74 79 70 65 | | ptr_type
+ +0x1A40 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1A41 | 00 00 00 | uint8_t[3] | ... | padding
+
+string (reflection.KeyValue.key):
+ +0x1A44 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | length of string
+ +0x1A48 | 63 70 70 5F 70 74 72 5F | char[12] | cpp_ptr_ | string literal
+ +0x1A50 | 74 79 70 65 | | type
+ +0x1A54 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1A55 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Type):
+ +0x1A58 | A8 F0 FF FF | SOffset32 | 0xFFFFF0A8 (-3928) Loc: +0x29B0 | offset to vtable
+ +0x1A5C | 00 00 | uint8_t[2] | .. | padding
+ +0x1A5E | 0E | uint8_t | 0x0E (14) | table field `base_type` (Byte)
+ +0x1A5F | 0F | uint8_t | 0x0F (15) | table field `element` (Byte)
+ +0x1A60 | 02 00 00 00 | uint32_t | 0x00000002 (2) | table field `index` (Int)
+ +0x1A64 | 04 00 00 00 | uint32_t | 0x00000004 (4) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x1A68 | 1C 00 00 00 | uint32_t | 0x0000001C (28) | length of string
+ +0x1A6C | 76 65 63 74 6F 72 5F 6F | char[28] | vector_o | string literal
+ +0x1A74 | 66 5F 73 74 72 6F 6E 67 | | f_strong
+ +0x1A7C | 5F 72 65 66 65 72 72 61 | | _referra
+ +0x1A84 | 62 6C 65 73 | | bles
+ +0x1A88 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1A89 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Field):
+ +0x1A8C | 68 EF FF FF | SOffset32 | 0xFFFFEF68 (-4248) Loc: +0x2B24 | offset to vtable
+ +0x1A90 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x1A93 | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x1A94 | 25 00 | uint16_t | 0x0025 (37) | table field `id` (UShort)
+ +0x1A96 | 4E 00 | uint16_t | 0x004E (78) | table field `offset` (UShort)
+ +0x1A98 | D0 00 00 00 | UOffset32 | 0x000000D0 (208) Loc: +0x1B68 | offset to field `name` (string)
+ +0x1A9C | C0 00 00 00 | UOffset32 | 0x000000C0 (192) Loc: +0x1B5C | offset to field `type` (table)
+ +0x1AA0 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x1AAC | offset to field `attributes` (vector)
+ +0x1AA4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1AA8 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x1AA8 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x1AAC | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of vector (# items)
+ +0x1AB0 | 80 00 00 00 | UOffset32 | 0x00000080 (128) Loc: +0x1B30 | offset to table[0]
+ +0x1AB4 | 50 00 00 00 | UOffset32 | 0x00000050 (80) Loc: +0x1B04 | offset to table[1]
+ +0x1AB8 | 24 00 00 00 | UOffset32 | 0x00000024 (36) Loc: +0x1ADC | offset to table[2]
+ +0x1ABC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1AC0 | offset to table[3]
+
+table (reflection.KeyValue):
+ +0x1AC0 | 5C E5 FF FF | SOffset32 | 0xFFFFE55C (-6820) Loc: +0x3564 | offset to vtable
+ +0x1AC4 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x1AD4 | offset to field `key` (string)
+ +0x1AC8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1ACC | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1ACC | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1AD0 | 33 37 | char[2] | 37 | string literal
+ +0x1AD2 | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x1AD4 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1AD8 | 69 64 | char[2] | id | string literal
+ +0x1ADA | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.KeyValue):
+ +0x1ADC | 78 E5 FF FF | SOffset32 | 0xFFFFE578 (-6792) Loc: +0x3564 | offset to vtable
+ +0x1AE0 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x1AF8 | offset to field `key` (string)
+ +0x1AE4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1AE8 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1AE8 | 08 00 00 00 | uint32_t | 0x00000008 (8) | length of string
+ +0x1AEC | 66 6E 76 31 61 5F 36 34 | char[8] | fnv1a_64 | string literal
+ +0x1AF4 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1AF5 | 00 00 00 | uint8_t[3] | ... | padding
+
+string (reflection.KeyValue.key):
+ +0x1AF8 | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x1AFC | 68 61 73 68 | char[4] | hash | string literal
+ +0x1B00 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1B01 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.KeyValue):
+ +0x1B04 | A0 E5 FF FF | SOffset32 | 0xFFFFE5A0 (-6752) Loc: +0x3564 | offset to vtable
+ +0x1B08 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x1B20 | offset to field `key` (string)
+ +0x1B0C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1B10 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1B10 | 0B 00 00 00 | uint32_t | 0x0000000B (11) | length of string
+ +0x1B14 | 52 65 66 65 72 72 61 62 | char[11] | Referrab | string literal
+ +0x1B1C | 6C 65 54 | | leT
+ +0x1B1F | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x1B20 | 08 00 00 00 | uint32_t | 0x00000008 (8) | length of string
+ +0x1B24 | 63 70 70 5F 74 79 70 65 | char[8] | cpp_type | string literal
+ +0x1B2C | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1B2D | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.KeyValue):
+ +0x1B30 | CC E5 FF FF | SOffset32 | 0xFFFFE5CC (-6708) Loc: +0x3564 | offset to vtable
+ +0x1B34 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x1B48 | offset to field `key` (string)
+ +0x1B38 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1B3C | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1B3C | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x1B40 | 6E 61 6B 65 64 | char[5] | naked | string literal
+ +0x1B45 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1B46 | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x1B48 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | length of string
+ +0x1B4C | 63 70 70 5F 70 74 72 5F | char[12] | cpp_ptr_ | string literal
+ +0x1B54 | 74 79 70 65 | | type
+ +0x1B58 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1B59 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Type):
+ +0x1B5C | D8 EF FF FF | SOffset32 | 0xFFFFEFD8 (-4136) Loc: +0x2B84 | offset to vtable
+ +0x1B60 | 00 00 | uint8_t[2] | .. | padding
+ +0x1B62 | 0E | uint8_t | 0x0E (14) | table field `base_type` (Byte)
+ +0x1B63 | 0A | uint8_t | 0x0A (10) | table field `element` (Byte)
+ +0x1B64 | 08 00 00 00 | uint32_t | 0x00000008 (8) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x1B68 | 19 00 00 00 | uint32_t | 0x00000019 (25) | length of string
+ +0x1B6C | 76 65 63 74 6F 72 5F 6F | char[25] | vector_o | string literal
+ +0x1B74 | 66 5F 77 65 61 6B 5F 72 | | f_weak_r
+ +0x1B7C | 65 66 65 72 65 6E 63 65 | | eference
+ +0x1B84 | 73 | | s
+ +0x1B85 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1B86 | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Field):
+ +0x1B88 | 4E F1 FF FF | SOffset32 | 0xFFFFF14E (-3762) Loc: +0x2A3A | offset to vtable
+ +0x1B8C | 24 00 | uint16_t | 0x0024 (36) | table field `id` (UShort)
+ +0x1B8E | 4C 00 | uint16_t | 0x004C (76) | table field `offset` (UShort)
+ +0x1B90 | D4 00 00 00 | UOffset32 | 0x000000D4 (212) Loc: +0x1C64 | offset to field `name` (string)
+ +0x1B94 | C0 00 00 00 | UOffset32 | 0x000000C0 (192) Loc: +0x1C54 | offset to field `type` (table)
+ +0x1B98 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x1BA4 | offset to field `attributes` (vector)
+ +0x1B9C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1BA0 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x1BA0 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x1BA4 | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of vector (# items)
+ +0x1BA8 | 80 00 00 00 | UOffset32 | 0x00000080 (128) Loc: +0x1C28 | offset to table[0]
+ +0x1BAC | 50 00 00 00 | UOffset32 | 0x00000050 (80) Loc: +0x1BFC | offset to table[1]
+ +0x1BB0 | 24 00 00 00 | UOffset32 | 0x00000024 (36) Loc: +0x1BD4 | offset to table[2]
+ +0x1BB4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1BB8 | offset to table[3]
+
+table (reflection.KeyValue):
+ +0x1BB8 | 54 E6 FF FF | SOffset32 | 0xFFFFE654 (-6572) Loc: +0x3564 | offset to vtable
+ +0x1BBC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x1BCC | offset to field `key` (string)
+ +0x1BC0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1BC4 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1BC4 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1BC8 | 33 36 | char[2] | 36 | string literal
+ +0x1BCA | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x1BCC | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1BD0 | 69 64 | char[2] | id | string literal
+ +0x1BD2 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.KeyValue):
+ +0x1BD4 | 70 E6 FF FF | SOffset32 | 0xFFFFE670 (-6544) Loc: +0x3564 | offset to vtable
+ +0x1BD8 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x1BF0 | offset to field `key` (string)
+ +0x1BDC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1BE0 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1BE0 | 08 00 00 00 | uint32_t | 0x00000008 (8) | length of string
+ +0x1BE4 | 66 6E 76 31 61 5F 36 34 | char[8] | fnv1a_64 | string literal
+ +0x1BEC | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1BED | 00 00 00 | uint8_t[3] | ... | padding
+
+string (reflection.KeyValue.key):
+ +0x1BF0 | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x1BF4 | 68 61 73 68 | char[4] | hash | string literal
+ +0x1BF8 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1BF9 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.KeyValue):
+ +0x1BFC | 98 E6 FF FF | SOffset32 | 0xFFFFE698 (-6504) Loc: +0x3564 | offset to vtable
+ +0x1C00 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x1C18 | offset to field `key` (string)
+ +0x1C04 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1C08 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1C08 | 0B 00 00 00 | uint32_t | 0x0000000B (11) | length of string
+ +0x1C0C | 52 65 66 65 72 72 61 62 | char[11] | Referrab | string literal
+ +0x1C14 | 6C 65 54 | | leT
+ +0x1C17 | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x1C18 | 08 00 00 00 | uint32_t | 0x00000008 (8) | length of string
+ +0x1C1C | 63 70 70 5F 74 79 70 65 | char[8] | cpp_type | string literal
+ +0x1C24 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1C25 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.KeyValue):
+ +0x1C28 | C4 E6 FF FF | SOffset32 | 0xFFFFE6C4 (-6460) Loc: +0x3564 | offset to vtable
+ +0x1C2C | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x1C40 | offset to field `key` (string)
+ +0x1C30 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1C34 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1C34 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x1C38 | 6E 61 6B 65 64 | char[5] | naked | string literal
+ +0x1C3D | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1C3E | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x1C40 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | length of string
+ +0x1C44 | 63 70 70 5F 70 74 72 5F | char[12] | cpp_ptr_ | string literal
+ +0x1C4C | 74 79 70 65 | | type
+ +0x1C50 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1C51 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Type):
+ +0x1C54 | 70 E5 FF FF | SOffset32 | 0xFFFFE570 (-6800) Loc: +0x36E4 | offset to vtable
+ +0x1C58 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x1C5B | 0A | uint8_t | 0x0A (10) | table field `base_type` (Byte)
+ +0x1C5C | 08 00 00 00 | uint32_t | 0x00000008 (8) | table field `base_size` (UInt)
+ +0x1C60 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x1C64 | 15 00 00 00 | uint32_t | 0x00000015 (21) | length of string
+ +0x1C68 | 73 69 6E 67 6C 65 5F 77 | char[21] | single_w | string literal
+ +0x1C70 | 65 61 6B 5F 72 65 66 65 | | eak_refe
+ +0x1C78 | 72 65 6E 63 65 | | rence
+ +0x1C7D | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1C7E | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Field):
+ +0x1C80 | 5C F1 FF FF | SOffset32 | 0xFFFFF15C (-3748) Loc: +0x2B24 | offset to vtable
+ +0x1C84 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x1C87 | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x1C88 | 23 00 | uint16_t | 0x0023 (35) | table field `id` (UShort)
+ +0x1C8A | 4A 00 | uint16_t | 0x004A (74) | table field `offset` (UShort)
+ +0x1C8C | 48 00 00 00 | UOffset32 | 0x00000048 (72) Loc: +0x1CD4 | offset to field `name` (string)
+ +0x1C90 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x1CC4 | offset to field `type` (table)
+ +0x1C94 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x1CA0 | offset to field `attributes` (vector)
+ +0x1C98 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1C9C | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x1C9C | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x1CA0 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x1CA4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1CA8 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x1CA8 | 44 E7 FF FF | SOffset32 | 0xFFFFE744 (-6332) Loc: +0x3564 | offset to vtable
+ +0x1CAC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x1CBC | offset to field `key` (string)
+ +0x1CB0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1CB4 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1CB4 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1CB8 | 33 35 | char[2] | 35 | string literal
+ +0x1CBA | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x1CBC | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1CC0 | 69 64 | char[2] | id | string literal
+ +0x1CC2 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x1CC4 | 14 F3 FF FF | SOffset32 | 0xFFFFF314 (-3308) Loc: +0x29B0 | offset to vtable
+ +0x1CC8 | 00 00 | uint8_t[2] | .. | padding
+ +0x1CCA | 0E | uint8_t | 0x0E (14) | table field `base_type` (Byte)
+ +0x1CCB | 0F | uint8_t | 0x0F (15) | table field `element` (Byte)
+ +0x1CCC | 02 00 00 00 | uint32_t | 0x00000002 (2) | table field `index` (Int)
+ +0x1CD0 | 04 00 00 00 | uint32_t | 0x00000004 (4) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x1CD4 | 15 00 00 00 | uint32_t | 0x00000015 (21) | length of string
+ +0x1CD8 | 76 65 63 74 6F 72 5F 6F | char[21] | vector_o | string literal
+ +0x1CE0 | 66 5F 72 65 66 65 72 72 | | f_referr
+ +0x1CE8 | 61 62 6C 65 73 | | ables
+ +0x1CED | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1CEE | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Field):
+ +0x1CF0 | CC F1 FF FF | SOffset32 | 0xFFFFF1CC (-3636) Loc: +0x2B24 | offset to vtable
+ +0x1CF4 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x1CF7 | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x1CF8 | 22 00 | uint16_t | 0x0022 (34) | table field `id` (UShort)
+ +0x1CFA | 48 00 | uint16_t | 0x0048 (72) | table field `offset` (UShort)
+ +0x1CFC | 48 00 00 00 | UOffset32 | 0x00000048 (72) Loc: +0x1D44 | offset to field `name` (string)
+ +0x1D00 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x1D34 | offset to field `type` (table)
+ +0x1D04 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x1D10 | offset to field `attributes` (vector)
+ +0x1D08 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1D0C | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x1D0C | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x1D10 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x1D14 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1D18 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x1D18 | B4 E7 FF FF | SOffset32 | 0xFFFFE7B4 (-6220) Loc: +0x3564 | offset to vtable
+ +0x1D1C | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x1D2C | offset to field `key` (string)
+ +0x1D20 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1D24 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1D24 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1D28 | 33 34 | char[2] | 34 | string literal
+ +0x1D2A | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x1D2C | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1D30 | 69 64 | char[2] | id | string literal
+ +0x1D32 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x1D34 | 7C E4 FF FF | SOffset32 | 0xFFFFE47C (-7044) Loc: +0x38B8 | offset to vtable
+ +0x1D38 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x1D3B | 0F | uint8_t | 0x0F (15) | table field `base_type` (Byte)
+ +0x1D3C | 0B 00 00 00 | uint32_t | 0x0000000B (11) | table field `index` (Int)
+ +0x1D40 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x1D44 | 15 00 00 00 | uint32_t | 0x00000015 (21) | length of string
+ +0x1D48 | 70 61 72 65 6E 74 5F 6E | char[21] | parent_n | string literal
+ +0x1D50 | 61 6D 65 73 70 61 63 65 | | amespace
+ +0x1D58 | 5F 74 65 73 74 | | _test
+ +0x1D5D | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1D5E | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Field):
+ +0x1D60 | 3C F2 FF FF | SOffset32 | 0xFFFFF23C (-3524) Loc: +0x2B24 | offset to vtable
+ +0x1D64 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x1D67 | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x1D68 | 21 00 | uint16_t | 0x0021 (33) | table field `id` (UShort)
+ +0x1D6A | 46 00 | uint16_t | 0x0046 (70) | table field `offset` (UShort)
+ +0x1D6C | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x1DB0 | offset to field `name` (string)
+ +0x1D70 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x1DA4 | offset to field `type` (table)
+ +0x1D74 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x1D80 | offset to field `attributes` (vector)
+ +0x1D78 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1D7C | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x1D7C | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x1D80 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x1D84 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1D88 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x1D88 | 24 E8 FF FF | SOffset32 | 0xFFFFE824 (-6108) Loc: +0x3564 | offset to vtable
+ +0x1D8C | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x1D9C | offset to field `key` (string)
+ +0x1D90 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1D94 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1D94 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1D98 | 33 33 | char[2] | 33 | string literal
+ +0x1D9A | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x1D9C | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1DA0 | 69 64 | char[2] | id | string literal
+ +0x1DA2 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x1DA4 | 20 F2 FF FF | SOffset32 | 0xFFFFF220 (-3552) Loc: +0x2B84 | offset to vtable
+ +0x1DA8 | 00 00 | uint8_t[2] | .. | padding
+ +0x1DAA | 0E | uint8_t | 0x0E (14) | table field `base_type` (Byte)
+ +0x1DAB | 0C | uint8_t | 0x0C (12) | table field `element` (Byte)
+ +0x1DAC | 08 00 00 00 | uint32_t | 0x00000008 (8) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x1DB0 | 11 00 00 00 | uint32_t | 0x00000011 (17) | length of string
+ +0x1DB4 | 76 65 63 74 6F 72 5F 6F | char[17] | vector_o | string literal
+ +0x1DBC | 66 5F 64 6F 75 62 6C 65 | | f_double
+ +0x1DC4 | 73 | | s
+ +0x1DC5 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1DC6 | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Field):
+ +0x1DC8 | A4 F2 FF FF | SOffset32 | 0xFFFFF2A4 (-3420) Loc: +0x2B24 | offset to vtable
+ +0x1DCC | 00 00 00 | uint8_t[3] | ... | padding
+ +0x1DCF | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x1DD0 | 20 00 | uint16_t | 0x0020 (32) | table field `id` (UShort)
+ +0x1DD2 | 44 00 | uint16_t | 0x0044 (68) | table field `offset` (UShort)
+ +0x1DD4 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x1E18 | offset to field `name` (string)
+ +0x1DD8 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x1E0C | offset to field `type` (table)
+ +0x1DDC | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x1DE8 | offset to field `attributes` (vector)
+ +0x1DE0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1DE4 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x1DE4 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x1DE8 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x1DEC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1DF0 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x1DF0 | 8C E8 FF FF | SOffset32 | 0xFFFFE88C (-6004) Loc: +0x3564 | offset to vtable
+ +0x1DF4 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x1E04 | offset to field `key` (string)
+ +0x1DF8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1DFC | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1DFC | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1E00 | 33 32 | char[2] | 32 | string literal
+ +0x1E02 | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x1E04 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1E08 | 69 64 | char[2] | id | string literal
+ +0x1E0A | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x1E0C | 88 F2 FF FF | SOffset32 | 0xFFFFF288 (-3448) Loc: +0x2B84 | offset to vtable
+ +0x1E10 | 00 00 | uint8_t[2] | .. | padding
+ +0x1E12 | 0E | uint8_t | 0x0E (14) | table field `base_type` (Byte)
+ +0x1E13 | 09 | uint8_t | 0x09 (9) | table field `element` (Byte)
+ +0x1E14 | 08 00 00 00 | uint32_t | 0x00000008 (8) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x1E18 | 0F 00 00 00 | uint32_t | 0x0000000F (15) | length of string
+ +0x1E1C | 76 65 63 74 6F 72 5F 6F | char[15] | vector_o | string literal
+ +0x1E24 | 66 5F 6C 6F 6E 67 73 | | f_longs
+ +0x1E2B | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x1E2C | 08 F3 FF FF | SOffset32 | 0xFFFFF308 (-3320) Loc: +0x2B24 | offset to vtable
+ +0x1E30 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x1E33 | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x1E34 | 1F 00 | uint16_t | 0x001F (31) | table field `id` (UShort)
+ +0x1E36 | 42 00 | uint16_t | 0x0042 (66) | table field `offset` (UShort)
+ +0x1E38 | 48 00 00 00 | UOffset32 | 0x00000048 (72) Loc: +0x1E80 | offset to field `name` (string)
+ +0x1E3C | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x1E70 | offset to field `type` (table)
+ +0x1E40 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x1E4C | offset to field `attributes` (vector)
+ +0x1E44 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1E48 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x1E48 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x1E4C | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x1E50 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1E54 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x1E54 | F0 E8 FF FF | SOffset32 | 0xFFFFE8F0 (-5904) Loc: +0x3564 | offset to vtable
+ +0x1E58 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x1E68 | offset to field `key` (string)
+ +0x1E5C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1E60 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1E60 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1E64 | 33 31 | char[2] | 31 | string literal
+ +0x1E66 | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x1E68 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1E6C | 69 64 | char[2] | id | string literal
+ +0x1E6E | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x1E70 | C0 F4 FF FF | SOffset32 | 0xFFFFF4C0 (-2880) Loc: +0x29B0 | offset to vtable
+ +0x1E74 | 00 00 | uint8_t[2] | .. | padding
+ +0x1E76 | 0E | uint8_t | 0x0E (14) | table field `base_type` (Byte)
+ +0x1E77 | 0F | uint8_t | 0x0F (15) | table field `element` (Byte)
+ +0x1E78 | 06 00 00 00 | uint32_t | 0x00000006 (6) | table field `index` (Int)
+ +0x1E7C | 04 00 00 00 | uint32_t | 0x00000004 (4) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x1E80 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x1E84 | 74 65 73 74 35 | char[5] | test5 | string literal
+ +0x1E89 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1E8A | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Field):
+ +0x1E8C | 68 F3 FF FF | SOffset32 | 0xFFFFF368 (-3224) Loc: +0x2B24 | offset to vtable
+ +0x1E90 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x1E93 | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x1E94 | 1E 00 | uint16_t | 0x001E (30) | table field `id` (UShort)
+ +0x1E96 | 40 00 | uint16_t | 0x0040 (64) | table field `offset` (UShort)
+ +0x1E98 | 6C 00 00 00 | UOffset32 | 0x0000006C (108) Loc: +0x1F04 | offset to field `name` (string)
+ +0x1E9C | 5C 00 00 00 | UOffset32 | 0x0000005C (92) Loc: +0x1EF8 | offset to field `type` (table)
+ +0x1EA0 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x1EAC | offset to field `attributes` (vector)
+ +0x1EA4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1EA8 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x1EA8 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x1EAC | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x1EB0 | 24 00 00 00 | UOffset32 | 0x00000024 (36) Loc: +0x1ED4 | offset to table[0]
+ +0x1EB4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1EB8 | offset to table[1]
+
+table (reflection.KeyValue):
+ +0x1EB8 | 54 E9 FF FF | SOffset32 | 0xFFFFE954 (-5804) Loc: +0x3564 | offset to vtable
+ +0x1EBC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x1ECC | offset to field `key` (string)
+ +0x1EC0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1EC4 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1EC4 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1EC8 | 33 30 | char[2] | 30 | string literal
+ +0x1ECA | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x1ECC | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1ED0 | 69 64 | char[2] | id | string literal
+ +0x1ED2 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.KeyValue):
+ +0x1ED4 | 70 E9 FF FF | SOffset32 | 0xFFFFE970 (-5776) Loc: +0x3564 | offset to vtable
+ +0x1ED8 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x1EE8 | offset to field `key` (string)
+ +0x1EDC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1EE0 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1EE0 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x1EE4 | 30 | char[1] | 0 | string literal
+ +0x1EE5 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1EE6 | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x1EE8 | 0A 00 00 00 | uint32_t | 0x0000000A (10) | length of string
+ +0x1EEC | 66 6C 65 78 62 75 66 66 | char[10] | flexbuff | string literal
+ +0x1EF4 | 65 72 | | er
+ +0x1EF6 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x1EF8 | 74 F3 FF FF | SOffset32 | 0xFFFFF374 (-3212) Loc: +0x2B84 | offset to vtable
+ +0x1EFC | 00 00 | uint8_t[2] | .. | padding
+ +0x1EFE | 0E | uint8_t | 0x0E (14) | table field `base_type` (Byte)
+ +0x1EFF | 04 | uint8_t | 0x04 (4) | table field `element` (Byte)
+ +0x1F00 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x1F04 | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x1F08 | 66 6C 65 78 | char[4] | flex | string literal
+ +0x1F0C | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x1F0D | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Field):
+ +0x1F10 | EC F3 FF FF | SOffset32 | 0xFFFFF3EC (-3092) Loc: +0x2B24 | offset to vtable
+ +0x1F14 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x1F17 | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x1F18 | 1D 00 | uint16_t | 0x001D (29) | table field `id` (UShort)
+ +0x1F1A | 3E 00 | uint16_t | 0x003E (62) | table field `offset` (UShort)
+ +0x1F1C | 48 00 00 00 | UOffset32 | 0x00000048 (72) Loc: +0x1F64 | offset to field `name` (string)
+ +0x1F20 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x1F54 | offset to field `type` (table)
+ +0x1F24 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x1F30 | offset to field `attributes` (vector)
+ +0x1F28 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1F2C | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x1F2C | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x1F30 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x1F34 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1F38 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x1F38 | D4 E9 FF FF | SOffset32 | 0xFFFFE9D4 (-5676) Loc: +0x3564 | offset to vtable
+ +0x1F3C | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x1F4C | offset to field `key` (string)
+ +0x1F40 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1F44 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1F44 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1F48 | 32 39 | char[2] | 29 | string literal
+ +0x1F4A | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x1F4C | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1F50 | 69 64 | char[2] | id | string literal
+ +0x1F52 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x1F54 | A4 F5 FF FF | SOffset32 | 0xFFFFF5A4 (-2652) Loc: +0x29B0 | offset to vtable
+ +0x1F58 | 00 00 | uint8_t[2] | .. | padding
+ +0x1F5A | 0E | uint8_t | 0x0E (14) | table field `base_type` (Byte)
+ +0x1F5B | 0F | uint8_t | 0x0F (15) | table field `element` (Byte)
+ +0x1F5C | 00 00 00 00 | uint32_t | 0x00000000 (0) | table field `index` (Int)
+ +0x1F60 | 04 00 00 00 | uint32_t | 0x00000004 (4) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x1F64 | 17 00 00 00 | uint32_t | 0x00000017 (23) | length of string
+ +0x1F68 | 74 65 73 74 61 72 72 61 | char[23] | testarra | string literal
+ +0x1F70 | 79 6F 66 73 6F 72 74 65 | | yofsorte
+ +0x1F78 | 64 73 74 72 75 63 74 | | dstruct
+ +0x1F7F | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x1F80 | 5C F4 FF FF | SOffset32 | 0xFFFFF45C (-2980) Loc: +0x2B24 | offset to vtable
+ +0x1F84 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x1F87 | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x1F88 | 1C 00 | uint16_t | 0x001C (28) | table field `id` (UShort)
+ +0x1F8A | 3C 00 | uint16_t | 0x003C (60) | table field `offset` (UShort)
+ +0x1F8C | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x1FD0 | offset to field `name` (string)
+ +0x1F90 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x1FC4 | offset to field `type` (table)
+ +0x1F94 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x1FA0 | offset to field `attributes` (vector)
+ +0x1F98 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1F9C | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x1F9C | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x1FA0 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x1FA4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1FA8 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x1FA8 | 44 EA FF FF | SOffset32 | 0xFFFFEA44 (-5564) Loc: +0x3564 | offset to vtable
+ +0x1FAC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x1FBC | offset to field `key` (string)
+ +0x1FB0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x1FB4 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x1FB4 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1FB8 | 32 38 | char[2] | 28 | string literal
+ +0x1FBA | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x1FBC | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x1FC0 | 69 64 | char[2] | id | string literal
+ +0x1FC2 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x1FC4 | 40 F4 FF FF | SOffset32 | 0xFFFFF440 (-3008) Loc: +0x2B84 | offset to vtable
+ +0x1FC8 | 00 00 | uint8_t[2] | .. | padding
+ +0x1FCA | 0E | uint8_t | 0x0E (14) | table field `base_type` (Byte)
+ +0x1FCB | 0D | uint8_t | 0x0D (13) | table field `element` (Byte)
+ +0x1FCC | 04 00 00 00 | uint32_t | 0x00000004 (4) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x1FD0 | 12 00 00 00 | uint32_t | 0x00000012 (18) | length of string
+ +0x1FD4 | 74 65 73 74 61 72 72 61 | char[18] | testarra | string literal
+ +0x1FDC | 79 6F 66 73 74 72 69 6E | | yofstrin
+ +0x1FE4 | 67 32 | | g2
+ +0x1FE6 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x1FE8 | AE F5 FF FF | SOffset32 | 0xFFFFF5AE (-2642) Loc: +0x2A3A | offset to vtable
+ +0x1FEC | 1B 00 | uint16_t | 0x001B (27) | table field `id` (UShort)
+ +0x1FEE | 3A 00 | uint16_t | 0x003A (58) | table field `offset` (UShort)
+ +0x1FF0 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x2034 | offset to field `name` (string)
+ +0x1FF4 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x2028 | offset to field `type` (table)
+ +0x1FF8 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x2004 | offset to field `attributes` (vector)
+ +0x1FFC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2000 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x2000 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x2004 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x2008 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x200C | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x200C | A8 EA FF FF | SOffset32 | 0xFFFFEAA8 (-5464) Loc: +0x3564 | offset to vtable
+ +0x2010 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x2020 | offset to field `key` (string)
+ +0x2014 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2018 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2018 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x201C | 32 37 | char[2] | 27 | string literal
+ +0x201E | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x2020 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2024 | 69 64 | char[2] | id | string literal
+ +0x2026 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x2028 | 8C E6 FF FF | SOffset32 | 0xFFFFE68C (-6516) Loc: +0x399C | offset to vtable
+ +0x202C | 00 00 00 | uint8_t[3] | ... | padding
+ +0x202F | 0B | uint8_t | 0x0B (11) | table field `base_type` (Byte)
+ +0x2030 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x2034 | 06 00 00 00 | uint32_t | 0x00000006 (6) | length of string
+ +0x2038 | 74 65 73 74 66 33 | char[6] | testf3 | string literal
+ +0x203E | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x2040 | 9A FF FF FF | SOffset32 | 0xFFFFFF9A (-102) Loc: +0x20A6 | offset to vtable
+ +0x2044 | 1A 00 | uint16_t | 0x001A (26) | table field `id` (UShort)
+ +0x2046 | 38 00 | uint16_t | 0x0038 (56) | table field `offset` (UShort)
+ +0x2048 | 50 00 00 00 | UOffset32 | 0x00000050 (80) Loc: +0x2098 | offset to field `name` (string)
+ +0x204C | 40 00 00 00 | UOffset32 | 0x00000040 (64) Loc: +0x208C | offset to field `type` (table)
+ +0x2050 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x2068 | offset to field `attributes` (vector)
+ +0x2054 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x2064 | offset to field `documentation` (vector)
+ +0x2058 | 00 00 00 00 00 00 08 40 | double | 0x4008000000000000 (3) | table field `default_real` (Double)
+ +0x2060 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (reflection.Field.documentation):
+ +0x2064 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x2068 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x206C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2070 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x2070 | 0C EB FF FF | SOffset32 | 0xFFFFEB0C (-5364) Loc: +0x3564 | offset to vtable
+ +0x2074 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x2084 | offset to field `key` (string)
+ +0x2078 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x207C | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x207C | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2080 | 32 36 | char[2] | 26 | string literal
+ +0x2082 | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x2084 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2088 | 69 64 | char[2] | id | string literal
+ +0x208A | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x208C | F0 E6 FF FF | SOffset32 | 0xFFFFE6F0 (-6416) Loc: +0x399C | offset to vtable
+ +0x2090 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x2093 | 0B | uint8_t | 0x0B (11) | table field `base_type` (Byte)
+ +0x2094 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x2098 | 06 00 00 00 | uint32_t | 0x00000006 (6) | length of string
+ +0x209C | 74 65 73 74 66 32 | char[6] | testf2 | string literal
+ +0x20A2 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x20A3 | 00 00 00 | uint8_t[3] | ... | padding
+
+vtable (reflection.Field):
+ +0x20A6 | 1A 00 | uint16_t | 0x001A (26) | size of this vtable
+ +0x20A8 | 24 00 | uint16_t | 0x0024 (36) | size of referring table
+ +0x20AA | 08 00 | VOffset16 | 0x0008 (8) | offset to field `name` (id: 0)
+ +0x20AC | 0C 00 | VOffset16 | 0x000C (12) | offset to field `type` (id: 1)
+ +0x20AE | 04 00 | VOffset16 | 0x0004 (4) | offset to field `id` (id: 2)
+ +0x20B0 | 06 00 | VOffset16 | 0x0006 (6) | offset to field `offset` (id: 3)
+ +0x20B2 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_integer` (id: 4) <defaults to 0> (Long)
+ +0x20B4 | 18 00 | VOffset16 | 0x0018 (24) | offset to field `default_real` (id: 5)
+ +0x20B6 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `deprecated` (id: 6) <defaults to 0> (Bool)
+ +0x20B8 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `required` (id: 7) <defaults to 0> (Bool)
+ +0x20BA | 00 00 | VOffset16 | 0x0000 (0) | offset to field `key` (id: 8) <defaults to 0> (Bool)
+ +0x20BC | 10 00 | VOffset16 | 0x0010 (16) | offset to field `attributes` (id: 9)
+ +0x20BE | 14 00 | VOffset16 | 0x0014 (20) | offset to field `documentation` (id: 10)
+
+table (reflection.Field):
+ +0x20C0 | 1A 00 00 00 | SOffset32 | 0x0000001A (26) Loc: +0x20A6 | offset to vtable
+ +0x20C4 | 19 00 | uint16_t | 0x0019 (25) | table field `id` (UShort)
+ +0x20C6 | 36 00 | uint16_t | 0x0036 (54) | table field `offset` (UShort)
+ +0x20C8 | 50 00 00 00 | UOffset32 | 0x00000050 (80) Loc: +0x2118 | offset to field `name` (string)
+ +0x20CC | 40 00 00 00 | UOffset32 | 0x00000040 (64) Loc: +0x210C | offset to field `type` (table)
+ +0x20D0 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x20E8 | offset to field `attributes` (vector)
+ +0x20D4 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x20E4 | offset to field `documentation` (vector)
+ +0x20D8 | 6E 86 1B F0 F9 21 09 40 | double | 0x400921F9F01B866E (3.14159) | table field `default_real` (Double)
+ +0x20E0 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (reflection.Field.documentation):
+ +0x20E4 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x20E8 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x20EC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x20F0 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x20F0 | 8C EB FF FF | SOffset32 | 0xFFFFEB8C (-5236) Loc: +0x3564 | offset to vtable
+ +0x20F4 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x2104 | offset to field `key` (string)
+ +0x20F8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x20FC | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x20FC | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2100 | 32 35 | char[2] | 25 | string literal
+ +0x2102 | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x2104 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2108 | 69 64 | char[2] | id | string literal
+ +0x210A | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x210C | 70 E7 FF FF | SOffset32 | 0xFFFFE770 (-6288) Loc: +0x399C | offset to vtable
+ +0x2110 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x2113 | 0B | uint8_t | 0x0B (11) | table field `base_type` (Byte)
+ +0x2114 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x2118 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x211C | 74 65 73 74 66 | char[5] | testf | string literal
+ +0x2121 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2122 | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Field):
+ +0x2124 | 00 F6 FF FF | SOffset32 | 0xFFFFF600 (-2560) Loc: +0x2B24 | offset to vtable
+ +0x2128 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x212B | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x212C | 18 00 | uint16_t | 0x0018 (24) | table field `id` (UShort)
+ +0x212E | 34 00 | uint16_t | 0x0034 (52) | table field `offset` (UShort)
+ +0x2130 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x2174 | offset to field `name` (string)
+ +0x2134 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x2168 | offset to field `type` (table)
+ +0x2138 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x2144 | offset to field `attributes` (vector)
+ +0x213C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2140 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x2140 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x2144 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x2148 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x214C | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x214C | E8 EB FF FF | SOffset32 | 0xFFFFEBE8 (-5144) Loc: +0x3564 | offset to vtable
+ +0x2150 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x2160 | offset to field `key` (string)
+ +0x2154 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2158 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2158 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x215C | 32 34 | char[2] | 24 | string literal
+ +0x215E | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x2160 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2164 | 69 64 | char[2] | id | string literal
+ +0x2166 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x2168 | E4 F5 FF FF | SOffset32 | 0xFFFFF5E4 (-2588) Loc: +0x2B84 | offset to vtable
+ +0x216C | 00 00 | uint8_t[2] | .. | padding
+ +0x216E | 0E | uint8_t | 0x0E (14) | table field `base_type` (Byte)
+ +0x216F | 02 | uint8_t | 0x02 (2) | table field `element` (Byte)
+ +0x2170 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x2174 | 10 00 00 00 | uint32_t | 0x00000010 (16) | length of string
+ +0x2178 | 74 65 73 74 61 72 72 61 | char[16] | testarra | string literal
+ +0x2180 | 79 6F 66 62 6F 6F 6C 73 | | yofbools
+ +0x2188 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2189 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Field):
+ +0x218C | 52 F7 FF FF | SOffset32 | 0xFFFFF752 (-2222) Loc: +0x2A3A | offset to vtable
+ +0x2190 | 17 00 | uint16_t | 0x0017 (23) | table field `id` (UShort)
+ +0x2192 | 32 00 | uint16_t | 0x0032 (50) | table field `offset` (UShort)
+ +0x2194 | 74 00 00 00 | UOffset32 | 0x00000074 (116) Loc: +0x2208 | offset to field `name` (string)
+ +0x2198 | 60 00 00 00 | UOffset32 | 0x00000060 (96) Loc: +0x21F8 | offset to field `type` (table)
+ +0x219C | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x21A8 | offset to field `attributes` (vector)
+ +0x21A0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x21A4 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x21A4 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x21A8 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x21AC | 24 00 00 00 | UOffset32 | 0x00000024 (36) Loc: +0x21D0 | offset to table[0]
+ +0x21B0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x21B4 | offset to table[1]
+
+table (reflection.KeyValue):
+ +0x21B4 | 50 EC FF FF | SOffset32 | 0xFFFFEC50 (-5040) Loc: +0x3564 | offset to vtable
+ +0x21B8 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x21C8 | offset to field `key` (string)
+ +0x21BC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x21C0 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x21C0 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x21C4 | 32 33 | char[2] | 23 | string literal
+ +0x21C6 | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x21C8 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x21CC | 69 64 | char[2] | id | string literal
+ +0x21CE | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.KeyValue):
+ +0x21D0 | 6C EC FF FF | SOffset32 | 0xFFFFEC6C (-5012) Loc: +0x3564 | offset to vtable
+ +0x21D4 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x21EC | offset to field `key` (string)
+ +0x21D8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x21DC | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x21DC | 08 00 00 00 | uint32_t | 0x00000008 (8) | length of string
+ +0x21E0 | 66 6E 76 31 61 5F 36 34 | char[8] | fnv1a_64 | string literal
+ +0x21E8 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x21E9 | 00 00 00 | uint8_t[3] | ... | padding
+
+string (reflection.KeyValue.key):
+ +0x21EC | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x21F0 | 68 61 73 68 | char[4] | hash | string literal
+ +0x21F4 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x21F5 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Type):
+ +0x21F8 | 14 EB FF FF | SOffset32 | 0xFFFFEB14 (-5356) Loc: +0x36E4 | offset to vtable
+ +0x21FC | 00 00 00 | uint8_t[3] | ... | padding
+ +0x21FF | 0A | uint8_t | 0x0A (10) | table field `base_type` (Byte)
+ +0x2200 | 08 00 00 00 | uint32_t | 0x00000008 (8) | table field `base_size` (UInt)
+ +0x2204 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x2208 | 11 00 00 00 | uint32_t | 0x00000011 (17) | length of string
+ +0x220C | 74 65 73 74 68 61 73 68 | char[17] | testhash | string literal
+ +0x2214 | 75 36 34 5F 66 6E 76 31 | | u64_fnv1
+ +0x221C | 61 | | a
+ +0x221D | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x221E | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Field):
+ +0x2220 | E6 F7 FF FF | SOffset32 | 0xFFFFF7E6 (-2074) Loc: +0x2A3A | offset to vtable
+ +0x2224 | 16 00 | uint16_t | 0x0016 (22) | table field `id` (UShort)
+ +0x2226 | 30 00 | uint16_t | 0x0030 (48) | table field `offset` (UShort)
+ +0x2228 | 74 00 00 00 | UOffset32 | 0x00000074 (116) Loc: +0x229C | offset to field `name` (string)
+ +0x222C | 60 00 00 00 | UOffset32 | 0x00000060 (96) Loc: +0x228C | offset to field `type` (table)
+ +0x2230 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x223C | offset to field `attributes` (vector)
+ +0x2234 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2238 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x2238 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x223C | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x2240 | 24 00 00 00 | UOffset32 | 0x00000024 (36) Loc: +0x2264 | offset to table[0]
+ +0x2244 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2248 | offset to table[1]
+
+table (reflection.KeyValue):
+ +0x2248 | E4 EC FF FF | SOffset32 | 0xFFFFECE4 (-4892) Loc: +0x3564 | offset to vtable
+ +0x224C | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x225C | offset to field `key` (string)
+ +0x2250 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2254 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2254 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2258 | 32 32 | char[2] | 22 | string literal
+ +0x225A | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x225C | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2260 | 69 64 | char[2] | id | string literal
+ +0x2262 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.KeyValue):
+ +0x2264 | 00 ED FF FF | SOffset32 | 0xFFFFED00 (-4864) Loc: +0x3564 | offset to vtable
+ +0x2268 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x2280 | offset to field `key` (string)
+ +0x226C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2270 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2270 | 08 00 00 00 | uint32_t | 0x00000008 (8) | length of string
+ +0x2274 | 66 6E 76 31 61 5F 36 34 | char[8] | fnv1a_64 | string literal
+ +0x227C | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x227D | 00 00 00 | uint8_t[3] | ... | padding
+
+string (reflection.KeyValue.key):
+ +0x2280 | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x2284 | 68 61 73 68 | char[4] | hash | string literal
+ +0x2288 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2289 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Type):
+ +0x228C | A8 EB FF FF | SOffset32 | 0xFFFFEBA8 (-5208) Loc: +0x36E4 | offset to vtable
+ +0x2290 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x2293 | 09 | uint8_t | 0x09 (9) | table field `base_type` (Byte)
+ +0x2294 | 08 00 00 00 | uint32_t | 0x00000008 (8) | table field `base_size` (UInt)
+ +0x2298 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x229C | 11 00 00 00 | uint32_t | 0x00000011 (17) | length of string
+ +0x22A0 | 74 65 73 74 68 61 73 68 | char[17] | testhash | string literal
+ +0x22A8 | 73 36 34 5F 66 6E 76 31 | | s64_fnv1
+ +0x22B0 | 61 | | a
+ +0x22B1 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x22B2 | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Field):
+ +0x22B4 | 7A F8 FF FF | SOffset32 | 0xFFFFF87A (-1926) Loc: +0x2A3A | offset to vtable
+ +0x22B8 | 15 00 | uint16_t | 0x0015 (21) | table field `id` (UShort)
+ +0x22BA | 2E 00 | uint16_t | 0x002E (46) | table field `offset` (UShort)
+ +0x22BC | CC 00 00 00 | UOffset32 | 0x000000CC (204) Loc: +0x2388 | offset to field `name` (string)
+ +0x22C0 | BC 00 00 00 | UOffset32 | 0x000000BC (188) Loc: +0x237C | offset to field `type` (table)
+ +0x22C4 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x22D0 | offset to field `attributes` (vector)
+ +0x22C8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x22CC | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x22CC | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x22D0 | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of vector (# items)
+ +0x22D4 | 7C 00 00 00 | UOffset32 | 0x0000007C (124) Loc: +0x2350 | offset to table[0]
+ +0x22D8 | 50 00 00 00 | UOffset32 | 0x00000050 (80) Loc: +0x2328 | offset to table[1]
+ +0x22DC | 24 00 00 00 | UOffset32 | 0x00000024 (36) Loc: +0x2300 | offset to table[2]
+ +0x22E0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x22E4 | offset to table[3]
+
+table (reflection.KeyValue):
+ +0x22E4 | 80 ED FF FF | SOffset32 | 0xFFFFED80 (-4736) Loc: +0x3564 | offset to vtable
+ +0x22E8 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x22F8 | offset to field `key` (string)
+ +0x22EC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x22F0 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x22F0 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x22F4 | 32 31 | char[2] | 21 | string literal
+ +0x22F6 | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x22F8 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x22FC | 69 64 | char[2] | id | string literal
+ +0x22FE | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.KeyValue):
+ +0x2300 | 9C ED FF FF | SOffset32 | 0xFFFFED9C (-4708) Loc: +0x3564 | offset to vtable
+ +0x2304 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x231C | offset to field `key` (string)
+ +0x2308 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x230C | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x230C | 08 00 00 00 | uint32_t | 0x00000008 (8) | length of string
+ +0x2310 | 66 6E 76 31 61 5F 33 32 | char[8] | fnv1a_32 | string literal
+ +0x2318 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2319 | 00 00 00 | uint8_t[3] | ... | padding
+
+string (reflection.KeyValue.key):
+ +0x231C | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x2320 | 68 61 73 68 | char[4] | hash | string literal
+ +0x2324 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2325 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.KeyValue):
+ +0x2328 | C4 ED FF FF | SOffset32 | 0xFFFFEDC4 (-4668) Loc: +0x3564 | offset to vtable
+ +0x232C | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x2340 | offset to field `key` (string)
+ +0x2330 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2334 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2334 | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x2338 | 53 74 61 74 | char[4] | Stat | string literal
+ +0x233C | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x233D | 00 00 00 | uint8_t[3] | ... | padding
+
+string (reflection.KeyValue.key):
+ +0x2340 | 08 00 00 00 | uint32_t | 0x00000008 (8) | length of string
+ +0x2344 | 63 70 70 5F 74 79 70 65 | char[8] | cpp_type | string literal
+ +0x234C | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x234D | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.KeyValue):
+ +0x2350 | EC ED FF FF | SOffset32 | 0xFFFFEDEC (-4628) Loc: +0x3564 | offset to vtable
+ +0x2354 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x2368 | offset to field `key` (string)
+ +0x2358 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x235C | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x235C | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x2360 | 6E 61 6B 65 64 | char[5] | naked | string literal
+ +0x2365 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2366 | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x2368 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | length of string
+ +0x236C | 63 70 70 5F 70 74 72 5F | char[12] | cpp_ptr_ | string literal
+ +0x2374 | 74 79 70 65 | | type
+ +0x2378 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2379 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Type):
+ +0x237C | E0 E9 FF FF | SOffset32 | 0xFFFFE9E0 (-5664) Loc: +0x399C | offset to vtable
+ +0x2380 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x2383 | 08 | uint8_t | 0x08 (8) | table field `base_type` (Byte)
+ +0x2384 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x2388 | 11 00 00 00 | uint32_t | 0x00000011 (17) | length of string
+ +0x238C | 74 65 73 74 68 61 73 68 | char[17] | testhash | string literal
+ +0x2394 | 75 33 32 5F 66 6E 76 31 | | u32_fnv1
+ +0x239C | 61 | | a
+ +0x239D | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x239E | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Field):
+ +0x23A0 | 66 F9 FF FF | SOffset32 | 0xFFFFF966 (-1690) Loc: +0x2A3A | offset to vtable
+ +0x23A4 | 14 00 | uint16_t | 0x0014 (20) | table field `id` (UShort)
+ +0x23A6 | 2C 00 | uint16_t | 0x002C (44) | table field `offset` (UShort)
+ +0x23A8 | 70 00 00 00 | UOffset32 | 0x00000070 (112) Loc: +0x2418 | offset to field `name` (string)
+ +0x23AC | 60 00 00 00 | UOffset32 | 0x00000060 (96) Loc: +0x240C | offset to field `type` (table)
+ +0x23B0 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x23BC | offset to field `attributes` (vector)
+ +0x23B4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x23B8 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x23B8 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x23BC | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x23C0 | 24 00 00 00 | UOffset32 | 0x00000024 (36) Loc: +0x23E4 | offset to table[0]
+ +0x23C4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x23C8 | offset to table[1]
+
+table (reflection.KeyValue):
+ +0x23C8 | 64 EE FF FF | SOffset32 | 0xFFFFEE64 (-4508) Loc: +0x3564 | offset to vtable
+ +0x23CC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x23DC | offset to field `key` (string)
+ +0x23D0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x23D4 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x23D4 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x23D8 | 32 30 | char[2] | 20 | string literal
+ +0x23DA | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x23DC | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x23E0 | 69 64 | char[2] | id | string literal
+ +0x23E2 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.KeyValue):
+ +0x23E4 | 80 EE FF FF | SOffset32 | 0xFFFFEE80 (-4480) Loc: +0x3564 | offset to vtable
+ +0x23E8 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x2400 | offset to field `key` (string)
+ +0x23EC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x23F0 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x23F0 | 08 00 00 00 | uint32_t | 0x00000008 (8) | length of string
+ +0x23F4 | 66 6E 76 31 61 5F 33 32 | char[8] | fnv1a_32 | string literal
+ +0x23FC | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x23FD | 00 00 00 | uint8_t[3] | ... | padding
+
+string (reflection.KeyValue.key):
+ +0x2400 | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x2404 | 68 61 73 68 | char[4] | hash | string literal
+ +0x2408 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2409 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Type):
+ +0x240C | 70 EA FF FF | SOffset32 | 0xFFFFEA70 (-5520) Loc: +0x399C | offset to vtable
+ +0x2410 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x2413 | 07 | uint8_t | 0x07 (7) | table field `base_type` (Byte)
+ +0x2414 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x2418 | 11 00 00 00 | uint32_t | 0x00000011 (17) | length of string
+ +0x241C | 74 65 73 74 68 61 73 68 | char[17] | testhash | string literal
+ +0x2424 | 73 33 32 5F 66 6E 76 31 | | s32_fnv1
+ +0x242C | 61 | | a
+ +0x242D | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x242E | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Field):
+ +0x2430 | F6 F9 FF FF | SOffset32 | 0xFFFFF9F6 (-1546) Loc: +0x2A3A | offset to vtable
+ +0x2434 | 13 00 | uint16_t | 0x0013 (19) | table field `id` (UShort)
+ +0x2436 | 2A 00 | uint16_t | 0x002A (42) | table field `offset` (UShort)
+ +0x2438 | 70 00 00 00 | UOffset32 | 0x00000070 (112) Loc: +0x24A8 | offset to field `name` (string)
+ +0x243C | 5C 00 00 00 | UOffset32 | 0x0000005C (92) Loc: +0x2498 | offset to field `type` (table)
+ +0x2440 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x244C | offset to field `attributes` (vector)
+ +0x2444 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2448 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x2448 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x244C | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x2450 | 24 00 00 00 | UOffset32 | 0x00000024 (36) Loc: +0x2474 | offset to table[0]
+ +0x2454 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2458 | offset to table[1]
+
+table (reflection.KeyValue):
+ +0x2458 | F4 EE FF FF | SOffset32 | 0xFFFFEEF4 (-4364) Loc: +0x3564 | offset to vtable
+ +0x245C | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x246C | offset to field `key` (string)
+ +0x2460 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2464 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2464 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2468 | 31 39 | char[2] | 19 | string literal
+ +0x246A | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x246C | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2470 | 69 64 | char[2] | id | string literal
+ +0x2472 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.KeyValue):
+ +0x2474 | 10 EF FF FF | SOffset32 | 0xFFFFEF10 (-4336) Loc: +0x3564 | offset to vtable
+ +0x2478 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x248C | offset to field `key` (string)
+ +0x247C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2480 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2480 | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x2484 | 66 6E 76 31 5F 36 34 | char[7] | fnv1_64 | string literal
+ +0x248B | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x248C | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x2490 | 68 61 73 68 | char[4] | hash | string literal
+ +0x2494 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2495 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Type):
+ +0x2498 | B4 ED FF FF | SOffset32 | 0xFFFFEDB4 (-4684) Loc: +0x36E4 | offset to vtable
+ +0x249C | 00 00 00 | uint8_t[3] | ... | padding
+ +0x249F | 0A | uint8_t | 0x0A (10) | table field `base_type` (Byte)
+ +0x24A0 | 08 00 00 00 | uint32_t | 0x00000008 (8) | table field `base_size` (UInt)
+ +0x24A4 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x24A8 | 10 00 00 00 | uint32_t | 0x00000010 (16) | length of string
+ +0x24AC | 74 65 73 74 68 61 73 68 | char[16] | testhash | string literal
+ +0x24B4 | 75 36 34 5F 66 6E 76 31 | | u64_fnv1
+ +0x24BC | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x24BD | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Field):
+ +0x24C0 | 86 FA FF FF | SOffset32 | 0xFFFFFA86 (-1402) Loc: +0x2A3A | offset to vtable
+ +0x24C4 | 12 00 | uint16_t | 0x0012 (18) | table field `id` (UShort)
+ +0x24C6 | 28 00 | uint16_t | 0x0028 (40) | table field `offset` (UShort)
+ +0x24C8 | 70 00 00 00 | UOffset32 | 0x00000070 (112) Loc: +0x2538 | offset to field `name` (string)
+ +0x24CC | 5C 00 00 00 | UOffset32 | 0x0000005C (92) Loc: +0x2528 | offset to field `type` (table)
+ +0x24D0 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x24DC | offset to field `attributes` (vector)
+ +0x24D4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x24D8 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x24D8 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x24DC | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x24E0 | 24 00 00 00 | UOffset32 | 0x00000024 (36) Loc: +0x2504 | offset to table[0]
+ +0x24E4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x24E8 | offset to table[1]
+
+table (reflection.KeyValue):
+ +0x24E8 | 84 EF FF FF | SOffset32 | 0xFFFFEF84 (-4220) Loc: +0x3564 | offset to vtable
+ +0x24EC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x24FC | offset to field `key` (string)
+ +0x24F0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x24F4 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x24F4 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x24F8 | 31 38 | char[2] | 18 | string literal
+ +0x24FA | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x24FC | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2500 | 69 64 | char[2] | id | string literal
+ +0x2502 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.KeyValue):
+ +0x2504 | A0 EF FF FF | SOffset32 | 0xFFFFEFA0 (-4192) Loc: +0x3564 | offset to vtable
+ +0x2508 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x251C | offset to field `key` (string)
+ +0x250C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2510 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2510 | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x2514 | 66 6E 76 31 5F 36 34 | char[7] | fnv1_64 | string literal
+ +0x251B | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x251C | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x2520 | 68 61 73 68 | char[4] | hash | string literal
+ +0x2524 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2525 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Type):
+ +0x2528 | 44 EE FF FF | SOffset32 | 0xFFFFEE44 (-4540) Loc: +0x36E4 | offset to vtable
+ +0x252C | 00 00 00 | uint8_t[3] | ... | padding
+ +0x252F | 09 | uint8_t | 0x09 (9) | table field `base_type` (Byte)
+ +0x2530 | 08 00 00 00 | uint32_t | 0x00000008 (8) | table field `base_size` (UInt)
+ +0x2534 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x2538 | 10 00 00 00 | uint32_t | 0x00000010 (16) | length of string
+ +0x253C | 74 65 73 74 68 61 73 68 | char[16] | testhash | string literal
+ +0x2544 | 73 36 34 5F 66 6E 76 31 | | s64_fnv1
+ +0x254C | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x254D | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Field):
+ +0x2550 | 16 FB FF FF | SOffset32 | 0xFFFFFB16 (-1258) Loc: +0x2A3A | offset to vtable
+ +0x2554 | 11 00 | uint16_t | 0x0011 (17) | table field `id` (UShort)
+ +0x2556 | 26 00 | uint16_t | 0x0026 (38) | table field `offset` (UShort)
+ +0x2558 | 6C 00 00 00 | UOffset32 | 0x0000006C (108) Loc: +0x25C4 | offset to field `name` (string)
+ +0x255C | 5C 00 00 00 | UOffset32 | 0x0000005C (92) Loc: +0x25B8 | offset to field `type` (table)
+ +0x2560 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x256C | offset to field `attributes` (vector)
+ +0x2564 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2568 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x2568 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x256C | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x2570 | 24 00 00 00 | UOffset32 | 0x00000024 (36) Loc: +0x2594 | offset to table[0]
+ +0x2574 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2578 | offset to table[1]
+
+table (reflection.KeyValue):
+ +0x2578 | 14 F0 FF FF | SOffset32 | 0xFFFFF014 (-4076) Loc: +0x3564 | offset to vtable
+ +0x257C | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x258C | offset to field `key` (string)
+ +0x2580 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2584 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2584 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2588 | 31 37 | char[2] | 17 | string literal
+ +0x258A | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x258C | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2590 | 69 64 | char[2] | id | string literal
+ +0x2592 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.KeyValue):
+ +0x2594 | 30 F0 FF FF | SOffset32 | 0xFFFFF030 (-4048) Loc: +0x3564 | offset to vtable
+ +0x2598 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x25AC | offset to field `key` (string)
+ +0x259C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x25A0 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x25A0 | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x25A4 | 66 6E 76 31 5F 33 32 | char[7] | fnv1_32 | string literal
+ +0x25AB | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x25AC | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x25B0 | 68 61 73 68 | char[4] | hash | string literal
+ +0x25B4 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x25B5 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Type):
+ +0x25B8 | 1C EC FF FF | SOffset32 | 0xFFFFEC1C (-5092) Loc: +0x399C | offset to vtable
+ +0x25BC | 00 00 00 | uint8_t[3] | ... | padding
+ +0x25BF | 08 | uint8_t | 0x08 (8) | table field `base_type` (Byte)
+ +0x25C0 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x25C4 | 10 00 00 00 | uint32_t | 0x00000010 (16) | length of string
+ +0x25C8 | 74 65 73 74 68 61 73 68 | char[16] | testhash | string literal
+ +0x25D0 | 75 33 32 5F 66 6E 76 31 | | u32_fnv1
+ +0x25D8 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x25D9 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Field):
+ +0x25DC | A2 FB FF FF | SOffset32 | 0xFFFFFBA2 (-1118) Loc: +0x2A3A | offset to vtable
+ +0x25E0 | 10 00 | uint16_t | 0x0010 (16) | table field `id` (UShort)
+ +0x25E2 | 24 00 | uint16_t | 0x0024 (36) | table field `offset` (UShort)
+ +0x25E4 | 6C 00 00 00 | UOffset32 | 0x0000006C (108) Loc: +0x2650 | offset to field `name` (string)
+ +0x25E8 | 5C 00 00 00 | UOffset32 | 0x0000005C (92) Loc: +0x2644 | offset to field `type` (table)
+ +0x25EC | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x25F8 | offset to field `attributes` (vector)
+ +0x25F0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x25F4 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x25F4 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x25F8 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x25FC | 24 00 00 00 | UOffset32 | 0x00000024 (36) Loc: +0x2620 | offset to table[0]
+ +0x2600 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2604 | offset to table[1]
+
+table (reflection.KeyValue):
+ +0x2604 | A0 F0 FF FF | SOffset32 | 0xFFFFF0A0 (-3936) Loc: +0x3564 | offset to vtable
+ +0x2608 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x2618 | offset to field `key` (string)
+ +0x260C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2610 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2610 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2614 | 31 36 | char[2] | 16 | string literal
+ +0x2616 | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x2618 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x261C | 69 64 | char[2] | id | string literal
+ +0x261E | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.KeyValue):
+ +0x2620 | BC F0 FF FF | SOffset32 | 0xFFFFF0BC (-3908) Loc: +0x3564 | offset to vtable
+ +0x2624 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x2638 | offset to field `key` (string)
+ +0x2628 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x262C | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x262C | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x2630 | 66 6E 76 31 5F 33 32 | char[7] | fnv1_32 | string literal
+ +0x2637 | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x2638 | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x263C | 68 61 73 68 | char[4] | hash | string literal
+ +0x2640 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2641 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Type):
+ +0x2644 | A8 EC FF FF | SOffset32 | 0xFFFFECA8 (-4952) Loc: +0x399C | offset to vtable
+ +0x2648 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x264B | 07 | uint8_t | 0x07 (7) | table field `base_type` (Byte)
+ +0x264C | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x2650 | 10 00 00 00 | uint32_t | 0x00000010 (16) | length of string
+ +0x2654 | 74 65 73 74 68 61 73 68 | char[16] | testhash | string literal
+ +0x265C | 73 33 32 5F 66 6E 76 31 | | s32_fnv1
+ +0x2664 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2665 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Field):
+ +0x2668 | 2E FC FF FF | SOffset32 | 0xFFFFFC2E (-978) Loc: +0x2A3A | offset to vtable
+ +0x266C | 0F 00 | uint16_t | 0x000F (15) | table field `id` (UShort)
+ +0x266E | 22 00 | uint16_t | 0x0022 (34) | table field `offset` (UShort)
+ +0x2670 | 48 00 00 00 | UOffset32 | 0x00000048 (72) Loc: +0x26B8 | offset to field `name` (string)
+ +0x2674 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x26A8 | offset to field `type` (table)
+ +0x2678 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x2684 | offset to field `attributes` (vector)
+ +0x267C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2680 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x2680 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x2684 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x2688 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x268C | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x268C | 28 F1 FF FF | SOffset32 | 0xFFFFF128 (-3800) Loc: +0x3564 | offset to vtable
+ +0x2690 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x26A0 | offset to field `key` (string)
+ +0x2694 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2698 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2698 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x269C | 31 35 | char[2] | 15 | string literal
+ +0x269E | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x26A0 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x26A4 | 69 64 | char[2] | id | string literal
+ +0x26A6 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x26A8 | C4 EF FF FF | SOffset32 | 0xFFFFEFC4 (-4156) Loc: +0x36E4 | offset to vtable
+ +0x26AC | 00 00 00 | uint8_t[3] | ... | padding
+ +0x26AF | 02 | uint8_t | 0x02 (2) | table field `base_type` (Byte)
+ +0x26B0 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x26B4 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x26B8 | 08 00 00 00 | uint32_t | 0x00000008 (8) | length of string
+ +0x26BC | 74 65 73 74 62 6F 6F 6C | char[8] | testbool | string literal
+ +0x26C4 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x26C5 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Field):
+ +0x26C8 | A4 FB FF FF | SOffset32 | 0xFFFFFBA4 (-1116) Loc: +0x2B24 | offset to vtable
+ +0x26CC | 00 00 00 | uint8_t[3] | ... | padding
+ +0x26CF | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x26D0 | 0E 00 | uint16_t | 0x000E (14) | table field `id` (UShort)
+ +0x26D2 | 20 00 | uint16_t | 0x0020 (32) | table field `offset` (UShort)
+ +0x26D4 | 48 00 00 00 | UOffset32 | 0x00000048 (72) Loc: +0x271C | offset to field `name` (string)
+ +0x26D8 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x270C | offset to field `type` (table)
+ +0x26DC | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x26E8 | offset to field `attributes` (vector)
+ +0x26E0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x26E4 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x26E4 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x26E8 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x26EC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x26F0 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x26F0 | 8C F1 FF FF | SOffset32 | 0xFFFFF18C (-3700) Loc: +0x3564 | offset to vtable
+ +0x26F4 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x2704 | offset to field `key` (string)
+ +0x26F8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x26FC | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x26FC | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2700 | 31 34 | char[2] | 14 | string literal
+ +0x2702 | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x2704 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2708 | 69 64 | char[2] | id | string literal
+ +0x270A | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x270C | 54 EE FF FF | SOffset32 | 0xFFFFEE54 (-4524) Loc: +0x38B8 | offset to vtable
+ +0x2710 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x2713 | 0F | uint8_t | 0x0F (15) | table field `base_type` (Byte)
+ +0x2714 | 03 00 00 00 | uint32_t | 0x00000003 (3) | table field `index` (Int)
+ +0x2718 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x271C | 09 00 00 00 | uint32_t | 0x00000009 (9) | length of string
+ +0x2720 | 74 65 73 74 65 6D 70 74 | char[9] | testempt | string literal
+ +0x2728 | 79 | | y
+ +0x2729 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x272A | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Field):
+ +0x272C | 08 FC FF FF | SOffset32 | 0xFFFFFC08 (-1016) Loc: +0x2B24 | offset to vtable
+ +0x2730 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x2733 | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x2734 | 0D 00 | uint16_t | 0x000D (13) | table field `id` (UShort)
+ +0x2736 | 1E 00 | uint16_t | 0x001E (30) | table field `offset` (UShort)
+ +0x2738 | 78 00 00 00 | UOffset32 | 0x00000078 (120) Loc: +0x27B0 | offset to field `name` (string)
+ +0x273C | 68 00 00 00 | UOffset32 | 0x00000068 (104) Loc: +0x27A4 | offset to field `type` (table)
+ +0x2740 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x274C | offset to field `attributes` (vector)
+ +0x2744 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2748 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x2748 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x274C | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x2750 | 38 00 00 00 | UOffset32 | 0x00000038 (56) Loc: +0x2788 | offset to table[0]
+ +0x2754 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2758 | offset to table[1]
+
+table (reflection.KeyValue):
+ +0x2758 | F4 F1 FF FF | SOffset32 | 0xFFFFF1F4 (-3596) Loc: +0x3564 | offset to vtable
+ +0x275C | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x2770 | offset to field `key` (string)
+ +0x2760 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2764 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2764 | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x2768 | 4D 6F 6E 73 74 65 72 | char[7] | Monster | string literal
+ +0x276F | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x2770 | 11 00 00 00 | uint32_t | 0x00000011 (17) | length of string
+ +0x2774 | 6E 65 73 74 65 64 5F 66 | char[17] | nested_f | string literal
+ +0x277C | 6C 61 74 62 75 66 66 65 | | latbuffe
+ +0x2784 | 72 | | r
+ +0x2785 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2786 | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.KeyValue):
+ +0x2788 | 24 F2 FF FF | SOffset32 | 0xFFFFF224 (-3548) Loc: +0x3564 | offset to vtable
+ +0x278C | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x279C | offset to field `key` (string)
+ +0x2790 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2794 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2794 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2798 | 31 33 | char[2] | 13 | string literal
+ +0x279A | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x279C | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x27A0 | 69 64 | char[2] | id | string literal
+ +0x27A2 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x27A4 | 20 FC FF FF | SOffset32 | 0xFFFFFC20 (-992) Loc: +0x2B84 | offset to vtable
+ +0x27A8 | 00 00 | uint8_t[2] | .. | padding
+ +0x27AA | 0E | uint8_t | 0x0E (14) | table field `base_type` (Byte)
+ +0x27AB | 04 | uint8_t | 0x04 (4) | table field `element` (Byte)
+ +0x27AC | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x27B0 | 14 00 00 00 | uint32_t | 0x00000014 (20) | length of string
+ +0x27B4 | 74 65 73 74 6E 65 73 74 | char[20] | testnest | string literal
+ +0x27BC | 65 64 66 6C 61 74 62 75 | | edflatbu
+ +0x27C4 | 66 66 65 72 | | ffer
+ +0x27C8 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x27C9 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Field):
+ +0x27CC | A8 FC FF FF | SOffset32 | 0xFFFFFCA8 (-856) Loc: +0x2B24 | offset to vtable
+ +0x27D0 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x27D3 | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x27D4 | 0C 00 | uint16_t | 0x000C (12) | table field `id` (UShort)
+ +0x27D6 | 1C 00 | uint16_t | 0x001C (28) | table field `offset` (UShort)
+ +0x27D8 | 48 00 00 00 | UOffset32 | 0x00000048 (72) Loc: +0x2820 | offset to field `name` (string)
+ +0x27DC | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x2810 | offset to field `type` (table)
+ +0x27E0 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x27EC | offset to field `attributes` (vector)
+ +0x27E4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x27E8 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x27E8 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x27EC | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x27F0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x27F4 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x27F4 | 90 F2 FF FF | SOffset32 | 0xFFFFF290 (-3440) Loc: +0x3564 | offset to vtable
+ +0x27F8 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x2808 | offset to field `key` (string)
+ +0x27FC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2800 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2800 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2804 | 31 32 | char[2] | 12 | string literal
+ +0x2806 | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x2808 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x280C | 69 64 | char[2] | id | string literal
+ +0x280E | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x2810 | 58 EF FF FF | SOffset32 | 0xFFFFEF58 (-4264) Loc: +0x38B8 | offset to vtable
+ +0x2814 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x2817 | 0F | uint8_t | 0x0F (15) | table field `base_type` (Byte)
+ +0x2818 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `index` (Int)
+ +0x281C | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x2820 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x2824 | 65 6E 65 6D 79 | char[5] | enemy | string literal
+ +0x2829 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x282A | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Field):
+ +0x282C | 08 FD FF FF | SOffset32 | 0xFFFFFD08 (-760) Loc: +0x2B24 | offset to vtable
+ +0x2830 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x2833 | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x2834 | 0B 00 | uint16_t | 0x000B (11) | table field `id` (UShort)
+ +0x2836 | 1A 00 | uint16_t | 0x001A (26) | table field `offset` (UShort)
+ +0x2838 | B4 00 00 00 | UOffset32 | 0x000000B4 (180) Loc: +0x28EC | offset to field `name` (string)
+ +0x283C | A0 00 00 00 | UOffset32 | 0x000000A0 (160) Loc: +0x28DC | offset to field `type` (table)
+ +0x2840 | 78 00 00 00 | UOffset32 | 0x00000078 (120) Loc: +0x28B8 | offset to field `attributes` (vector)
+ +0x2844 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2848 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x2848 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x284C | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x2868 | offset to string[0]
+ +0x2850 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2854 | offset to string[1]
+
+string (reflection.Field.documentation):
+ +0x2854 | 0E 00 00 00 | uint32_t | 0x0000000E (14) | length of string
+ +0x2858 | 20 6D 75 6C 74 69 6C 69 | char[14] | multili | string literal
+ +0x2860 | 6E 65 20 74 6F 6F | | ne too
+ +0x2866 | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.Field.documentation):
+ +0x2868 | 49 00 00 00 | uint32_t | 0x00000049 (73) | length of string
+ +0x286C | 20 61 6E 20 65 78 61 6D | char[73] | an exam | string literal
+ +0x2874 | 70 6C 65 20 64 6F 63 75 | | ple docu
+ +0x287C | 6D 65 6E 74 61 74 69 6F | | mentatio
+ +0x2884 | 6E 20 63 6F 6D 6D 65 6E | | n commen
+ +0x288C | 74 3A 20 74 68 69 73 20 | | t: this
+ +0x2894 | 77 69 6C 6C 20 65 6E 64 | | will end
+ +0x289C | 20 75 70 20 69 6E 20 74 | | up in t
+ +0x28A4 | 68 65 20 67 65 6E 65 72 | | he gener
+ +0x28AC | 61 74 65 64 20 63 6F 64 | | ated cod
+ +0x28B4 | 65 | | e
+ +0x28B5 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x28B6 | 00 00 | uint8_t[2] | .. | padding
+
+vector (reflection.Field.attributes):
+ +0x28B8 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x28BC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x28C0 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x28C0 | 5C F3 FF FF | SOffset32 | 0xFFFFF35C (-3236) Loc: +0x3564 | offset to vtable
+ +0x28C4 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x28D4 | offset to field `key` (string)
+ +0x28C8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x28CC | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x28CC | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x28D0 | 31 31 | char[2] | 11 | string literal
+ +0x28D2 | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x28D4 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x28D8 | 69 64 | char[2] | id | string literal
+ +0x28DA | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x28DC | 2C FF FF FF | SOffset32 | 0xFFFFFF2C (-212) Loc: +0x29B0 | offset to vtable
+ +0x28E0 | 00 00 | uint8_t[2] | .. | padding
+ +0x28E2 | 0E | uint8_t | 0x0E (14) | table field `base_type` (Byte)
+ +0x28E3 | 0F | uint8_t | 0x0F (15) | table field `element` (Byte)
+ +0x28E4 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `index` (Int)
+ +0x28E8 | 04 00 00 00 | uint32_t | 0x00000004 (4) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x28EC | 11 00 00 00 | uint32_t | 0x00000011 (17) | length of string
+ +0x28F0 | 74 65 73 74 61 72 72 61 | char[17] | testarra | string literal
+ +0x28F8 | 79 6F 66 74 61 62 6C 65 | | yoftable
+ +0x2900 | 73 | | s
+ +0x2901 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2902 | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Field):
+ +0x2904 | E0 FD FF FF | SOffset32 | 0xFFFFFDE0 (-544) Loc: +0x2B24 | offset to vtable
+ +0x2908 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x290B | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x290C | 0A 00 | uint16_t | 0x000A (10) | table field `id` (UShort)
+ +0x290E | 18 00 | uint16_t | 0x0018 (24) | table field `offset` (UShort)
+ +0x2910 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x2954 | offset to field `name` (string)
+ +0x2914 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x2948 | offset to field `type` (table)
+ +0x2918 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x2924 | offset to field `attributes` (vector)
+ +0x291C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2920 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x2920 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x2924 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x2928 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x292C | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x292C | C8 F3 FF FF | SOffset32 | 0xFFFFF3C8 (-3128) Loc: +0x3564 | offset to vtable
+ +0x2930 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x2940 | offset to field `key` (string)
+ +0x2934 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2938 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2938 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x293C | 31 30 | char[2] | 10 | string literal
+ +0x293E | 00 | char | 0x00 (0) | string terminator
+
+string (reflection.KeyValue.key):
+ +0x2940 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2944 | 69 64 | char[2] | id | string literal
+ +0x2946 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x2948 | C4 FD FF FF | SOffset32 | 0xFFFFFDC4 (-572) Loc: +0x2B84 | offset to vtable
+ +0x294C | 00 00 | uint8_t[2] | .. | padding
+ +0x294E | 0E | uint8_t | 0x0E (14) | table field `base_type` (Byte)
+ +0x294F | 0D | uint8_t | 0x0D (13) | table field `element` (Byte)
+ +0x2950 | 04 00 00 00 | uint32_t | 0x00000004 (4) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x2954 | 11 00 00 00 | uint32_t | 0x00000011 (17) | length of string
+ +0x2958 | 74 65 73 74 61 72 72 61 | char[17] | testarra | string literal
+ +0x2960 | 79 6F 66 73 74 72 69 6E | | yofstrin
+ +0x2968 | 67 | | g
+ +0x2969 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x296A | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Field):
+ +0x296C | 48 FE FF FF | SOffset32 | 0xFFFFFE48 (-440) Loc: +0x2B24 | offset to vtable
+ +0x2970 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x2973 | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x2974 | 09 00 | uint16_t | 0x0009 (9) | table field `id` (UShort)
+ +0x2976 | 16 00 | uint16_t | 0x0016 (22) | table field `offset` (UShort)
+ +0x2978 | 58 00 00 00 | UOffset32 | 0x00000058 (88) Loc: +0x29D0 | offset to field `name` (string)
+ +0x297C | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x29C0 | offset to field `type` (table)
+ +0x2980 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x298C | offset to field `attributes` (vector)
+ +0x2984 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2988 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x2988 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x298C | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x2990 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2994 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x2994 | 30 F4 FF FF | SOffset32 | 0xFFFFF430 (-3024) Loc: +0x3564 | offset to vtable
+ +0x2998 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x29A8 | offset to field `key` (string)
+ +0x299C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x29A0 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x29A0 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x29A4 | 39 | char[1] | 9 | string literal
+ +0x29A5 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x29A6 | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x29A8 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x29AC | 69 64 | char[2] | id | string literal
+ +0x29AE | 00 | char | 0x00 (0) | string terminator
+
+vtable (reflection.Type):
+ +0x29B0 | 10 00 | uint16_t | 0x0010 (16) | size of this vtable
+ +0x29B2 | 10 00 | uint16_t | 0x0010 (16) | size of referring table
+ +0x29B4 | 06 00 | VOffset16 | 0x0006 (6) | offset to field `base_type` (id: 0)
+ +0x29B6 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `element` (id: 1)
+ +0x29B8 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `index` (id: 2)
+ +0x29BA | 00 00 | VOffset16 | 0x0000 (0) | offset to field `fixed_length` (id: 3) <defaults to 0> (UShort)
+ +0x29BC | 00 00 | VOffset16 | 0x0000 (0) | offset to field `base_size` (id: 4) <defaults to 4> (UInt)
+ +0x29BE | 0C 00 | VOffset16 | 0x000C (12) | offset to field `element_size` (id: 5)
+
+table (reflection.Type):
+ +0x29C0 | 10 00 00 00 | SOffset32 | 0x00000010 (16) Loc: +0x29B0 | offset to vtable
+ +0x29C4 | 00 00 | uint8_t[2] | .. | padding
+ +0x29C6 | 0E | uint8_t | 0x0E (14) | table field `base_type` (Byte)
+ +0x29C7 | 0F | uint8_t | 0x0F (15) | table field `element` (Byte)
+ +0x29C8 | 06 00 00 00 | uint32_t | 0x00000006 (6) | table field `index` (Int)
+ +0x29CC | 04 00 00 00 | uint32_t | 0x00000004 (4) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x29D0 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x29D4 | 74 65 73 74 34 | char[5] | test4 | string literal
+ +0x29D9 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x29DA | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Field):
+ +0x29DC | B8 FE FF FF | SOffset32 | 0xFFFFFEB8 (-328) Loc: +0x2B24 | offset to vtable
+ +0x29E0 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x29E3 | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x29E4 | 08 00 | uint16_t | 0x0008 (8) | table field `id` (UShort)
+ +0x29E6 | 14 00 | uint16_t | 0x0014 (20) | table field `offset` (UShort)
+ +0x29E8 | 48 00 00 00 | UOffset32 | 0x00000048 (72) Loc: +0x2A30 | offset to field `name` (string)
+ +0x29EC | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x2A20 | offset to field `type` (table)
+ +0x29F0 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x29FC | offset to field `attributes` (vector)
+ +0x29F4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x29F8 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x29F8 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x29FC | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x2A00 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2A04 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x2A04 | A0 F4 FF FF | SOffset32 | 0xFFFFF4A0 (-2912) Loc: +0x3564 | offset to vtable
+ +0x2A08 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x2A18 | offset to field `key` (string)
+ +0x2A0C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2A10 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2A10 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x2A14 | 38 | char[1] | 8 | string literal
+ +0x2A15 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2A16 | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x2A18 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2A1C | 69 64 | char[2] | id | string literal
+ +0x2A1E | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x2A20 | 68 F1 FF FF | SOffset32 | 0xFFFFF168 (-3736) Loc: +0x38B8 | offset to vtable
+ +0x2A24 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x2A27 | 10 | uint8_t | 0x10 (16) | table field `base_type` (Byte)
+ +0x2A28 | 00 00 00 00 | uint32_t | 0x00000000 (0) | table field `index` (Int)
+ +0x2A2C | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x2A30 | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x2A34 | 74 65 73 74 | char[4] | test | string literal
+ +0x2A38 | 00 | char | 0x00 (0) | string terminator
+
+vtable (reflection.Field):
+ +0x2A3A | 1A 00 | uint16_t | 0x001A (26) | size of this vtable
+ +0x2A3C | 18 00 | uint16_t | 0x0018 (24) | size of referring table
+ +0x2A3E | 08 00 | VOffset16 | 0x0008 (8) | offset to field `name` (id: 0)
+ +0x2A40 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `type` (id: 1)
+ +0x2A42 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `id` (id: 2)
+ +0x2A44 | 06 00 | VOffset16 | 0x0006 (6) | offset to field `offset` (id: 3)
+ +0x2A46 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_integer` (id: 4) <defaults to 0> (Long)
+ +0x2A48 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_real` (id: 5) <defaults to 0.000000> (Double)
+ +0x2A4A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `deprecated` (id: 6) <defaults to 0> (Bool)
+ +0x2A4C | 00 00 | VOffset16 | 0x0000 (0) | offset to field `required` (id: 7) <defaults to 0> (Bool)
+ +0x2A4E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `key` (id: 8) <defaults to 0> (Bool)
+ +0x2A50 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `attributes` (id: 9)
+ +0x2A52 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `documentation` (id: 10)
+
+table (reflection.Field):
+ +0x2A54 | 1A 00 00 00 | SOffset32 | 0x0000001A (26) Loc: +0x2A3A | offset to vtable
+ +0x2A58 | 07 00 | uint16_t | 0x0007 (7) | table field `id` (UShort)
+ +0x2A5A | 12 00 | uint16_t | 0x0012 (18) | table field `offset` (UShort)
+ +0x2A5C | 4C 00 00 00 | UOffset32 | 0x0000004C (76) Loc: +0x2AA8 | offset to field `name` (string)
+ +0x2A60 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x2A94 | offset to field `type` (table)
+ +0x2A64 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x2A70 | offset to field `attributes` (vector)
+ +0x2A68 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2A6C | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x2A6C | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x2A70 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x2A74 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2A78 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x2A78 | 14 F5 FF FF | SOffset32 | 0xFFFFF514 (-2796) Loc: +0x3564 | offset to vtable
+ +0x2A7C | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x2A8C | offset to field `key` (string)
+ +0x2A80 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2A84 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2A84 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x2A88 | 37 | char[1] | 7 | string literal
+ +0x2A89 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2A8A | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x2A8C | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2A90 | 69 64 | char[2] | id | string literal
+ +0x2A92 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x2A94 | 90 F4 FF FF | SOffset32 | 0xFFFFF490 (-2928) Loc: +0x3604 | offset to vtable
+ +0x2A98 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x2A9B | 01 | uint8_t | 0x01 (1) | table field `base_type` (Byte)
+ +0x2A9C | 00 00 00 00 | uint32_t | 0x00000000 (0) | table field `index` (Int)
+ +0x2AA0 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x2AA4 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x2AA8 | 09 00 00 00 | uint32_t | 0x00000009 (9) | length of string
+ +0x2AAC | 74 65 73 74 5F 74 79 70 | char[9] | test_typ | string literal
+ +0x2AB4 | 65 | | e
+ +0x2AB5 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2AB6 | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Field):
+ +0x2AB8 | 42 FD FF FF | SOffset32 | 0xFFFFFD42 (-702) Loc: +0x2D76 | offset to vtable
+ +0x2ABC | 06 00 | uint16_t | 0x0006 (6) | table field `id` (UShort)
+ +0x2ABE | 10 00 | uint16_t | 0x0010 (16) | table field `offset` (UShort)
+ +0x2AC0 | 58 00 00 00 | UOffset32 | 0x00000058 (88) Loc: +0x2B18 | offset to field `name` (string)
+ +0x2AC4 | 40 00 00 00 | UOffset32 | 0x00000040 (64) Loc: +0x2B04 | offset to field `type` (table)
+ +0x2AC8 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x2AE0 | offset to field `attributes` (vector)
+ +0x2ACC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x2ADC | offset to field `documentation` (vector)
+ +0x2AD0 | 08 00 00 00 00 00 00 00 | int64_t | 0x0000000000000008 (8) | table field `default_integer` (Long)
+ +0x2AD8 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (reflection.Field.documentation):
+ +0x2ADC | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x2AE0 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x2AE4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2AE8 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x2AE8 | 84 F5 FF FF | SOffset32 | 0xFFFFF584 (-2684) Loc: +0x3564 | offset to vtable
+ +0x2AEC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x2AFC | offset to field `key` (string)
+ +0x2AF0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2AF4 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2AF4 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x2AF8 | 36 | char[1] | 6 | string literal
+ +0x2AF9 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2AFA | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x2AFC | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2B00 | 69 64 | char[2] | id | string literal
+ +0x2B02 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x2B04 | 00 F5 FF FF | SOffset32 | 0xFFFFF500 (-2816) Loc: +0x3604 | offset to vtable
+ +0x2B08 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x2B0B | 04 | uint8_t | 0x04 (4) | table field `base_type` (Byte)
+ +0x2B0C | 03 00 00 00 | uint32_t | 0x00000003 (3) | table field `index` (Int)
+ +0x2B10 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x2B14 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x2B18 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x2B1C | 63 6F 6C 6F 72 | char[5] | color | string literal
+ +0x2B21 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2B22 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (reflection.Field):
+ +0x2B24 | 1C 00 | uint16_t | 0x001C (28) | size of this vtable
+ +0x2B26 | 1C 00 | uint16_t | 0x001C (28) | size of referring table
+ +0x2B28 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `name` (id: 0)
+ +0x2B2A | 10 00 | VOffset16 | 0x0010 (16) | offset to field `type` (id: 1)
+ +0x2B2C | 08 00 | VOffset16 | 0x0008 (8) | offset to field `id` (id: 2)
+ +0x2B2E | 0A 00 | VOffset16 | 0x000A (10) | offset to field `offset` (id: 3)
+ +0x2B30 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_integer` (id: 4) <defaults to 0> (Long)
+ +0x2B32 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_real` (id: 5) <defaults to 0.000000> (Double)
+ +0x2B34 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `deprecated` (id: 6) <defaults to 0> (Bool)
+ +0x2B36 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `required` (id: 7) <defaults to 0> (Bool)
+ +0x2B38 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `key` (id: 8) <defaults to 0> (Bool)
+ +0x2B3A | 14 00 | VOffset16 | 0x0014 (20) | offset to field `attributes` (id: 9)
+ +0x2B3C | 18 00 | VOffset16 | 0x0018 (24) | offset to field `documentation` (id: 10)
+ +0x2B3E | 07 00 | VOffset16 | 0x0007 (7) | offset to field `optional` (id: 11)
+
+table (reflection.Field):
+ +0x2B40 | 1C 00 00 00 | SOffset32 | 0x0000001C (28) Loc: +0x2B24 | offset to vtable
+ +0x2B44 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x2B47 | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x2B48 | 05 00 | uint16_t | 0x0005 (5) | table field `id` (UShort)
+ +0x2B4A | 0E 00 | uint16_t | 0x000E (14) | table field `offset` (UShort)
+ +0x2B4C | 54 00 00 00 | UOffset32 | 0x00000054 (84) Loc: +0x2BA0 | offset to field `name` (string)
+ +0x2B50 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x2B94 | offset to field `type` (table)
+ +0x2B54 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x2B60 | offset to field `attributes` (vector)
+ +0x2B58 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2B5C | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x2B5C | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x2B60 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x2B64 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2B68 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x2B68 | 04 F6 FF FF | SOffset32 | 0xFFFFF604 (-2556) Loc: +0x3564 | offset to vtable
+ +0x2B6C | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x2B7C | offset to field `key` (string)
+ +0x2B70 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2B74 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2B74 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x2B78 | 35 | char[1] | 5 | string literal
+ +0x2B79 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2B7A | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x2B7C | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2B80 | 69 64 | char[2] | id | string literal
+ +0x2B82 | 00 | char | 0x00 (0) | string terminator
+
+vtable (reflection.Type):
+ +0x2B84 | 10 00 | uint16_t | 0x0010 (16) | size of this vtable
+ +0x2B86 | 0C 00 | uint16_t | 0x000C (12) | size of referring table
+ +0x2B88 | 06 00 | VOffset16 | 0x0006 (6) | offset to field `base_type` (id: 0)
+ +0x2B8A | 07 00 | VOffset16 | 0x0007 (7) | offset to field `element` (id: 1)
+ +0x2B8C | 00 00 | VOffset16 | 0x0000 (0) | offset to field `index` (id: 2) <defaults to -1> (Int)
+ +0x2B8E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `fixed_length` (id: 3) <defaults to 0> (UShort)
+ +0x2B90 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `base_size` (id: 4) <defaults to 4> (UInt)
+ +0x2B92 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `element_size` (id: 5)
+
+table (reflection.Type):
+ +0x2B94 | 10 00 00 00 | SOffset32 | 0x00000010 (16) Loc: +0x2B84 | offset to vtable
+ +0x2B98 | 00 00 | uint8_t[2] | .. | padding
+ +0x2B9A | 0E | uint8_t | 0x0E (14) | table field `base_type` (Byte)
+ +0x2B9B | 04 | uint8_t | 0x04 (4) | table field `element` (Byte)
+ +0x2B9C | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x2BA0 | 09 00 00 00 | uint32_t | 0x00000009 (9) | length of string
+ +0x2BA4 | 69 6E 76 65 6E 74 6F 72 | char[9] | inventor | string literal
+ +0x2BAC | 79 | | y
+ +0x2BAD | 00 | char | 0x00 (0) | string terminator
+
+vtable (reflection.Field):
+ +0x2BAE | 1A 00 | uint16_t | 0x001A (26) | size of this vtable
+ +0x2BB0 | 1C 00 | uint16_t | 0x001C (28) | size of referring table
+ +0x2BB2 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `name` (id: 0)
+ +0x2BB4 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `type` (id: 1)
+ +0x2BB6 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `id` (id: 2)
+ +0x2BB8 | 0A 00 | VOffset16 | 0x000A (10) | offset to field `offset` (id: 3)
+ +0x2BBA | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_integer` (id: 4) <defaults to 0> (Long)
+ +0x2BBC | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_real` (id: 5) <defaults to 0.000000> (Double)
+ +0x2BBE | 07 00 | VOffset16 | 0x0007 (7) | offset to field `deprecated` (id: 6)
+ +0x2BC0 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `required` (id: 7) <defaults to 0> (Bool)
+ +0x2BC2 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `key` (id: 8) <defaults to 0> (Bool)
+ +0x2BC4 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `attributes` (id: 9)
+ +0x2BC6 | 18 00 | VOffset16 | 0x0018 (24) | offset to field `documentation` (id: 10)
+
+table (reflection.Field):
+ +0x2BC8 | 1A 00 00 00 | SOffset32 | 0x0000001A (26) Loc: +0x2BAE | offset to vtable
+ +0x2BCC | 00 00 00 | uint8_t[3] | ... | padding
+ +0x2BCF | 01 | uint8_t | 0x01 (1) | table field `deprecated` (Bool)
+ +0x2BD0 | 04 00 | uint16_t | 0x0004 (4) | table field `id` (UShort)
+ +0x2BD2 | 0C 00 | uint16_t | 0x000C (12) | table field `offset` (UShort)
+ +0x2BD4 | 98 00 00 00 | UOffset32 | 0x00000098 (152) Loc: +0x2C6C | offset to field `name` (string)
+ +0x2BD8 | 84 00 00 00 | UOffset32 | 0x00000084 (132) Loc: +0x2C5C | offset to field `type` (table)
+ +0x2BDC | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x2BE8 | offset to field `attributes` (vector)
+ +0x2BE0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2BE4 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x2BE4 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x2BE8 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x2BEC | 4C 00 00 00 | UOffset32 | 0x0000004C (76) Loc: +0x2C38 | offset to table[0]
+ +0x2BF0 | 2C 00 00 00 | UOffset32 | 0x0000002C (44) Loc: +0x2C1C | offset to table[1]
+ +0x2BF4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2BF8 | offset to table[2]
+
+table (reflection.KeyValue):
+ +0x2BF8 | 94 F6 FF FF | SOffset32 | 0xFFFFF694 (-2412) Loc: +0x3564 | offset to vtable
+ +0x2BFC | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x2C0C | offset to field `key` (string)
+ +0x2C00 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2C04 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2C04 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x2C08 | 31 | char[1] | 1 | string literal
+ +0x2C09 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2C0A | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x2C0C | 08 00 00 00 | uint32_t | 0x00000008 (8) | length of string
+ +0x2C10 | 70 72 69 6F 72 69 74 79 | char[8] | priority | string literal
+ +0x2C18 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2C19 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.KeyValue):
+ +0x2C1C | B8 F6 FF FF | SOffset32 | 0xFFFFF6B8 (-2376) Loc: +0x3564 | offset to vtable
+ +0x2C20 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x2C30 | offset to field `key` (string)
+ +0x2C24 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2C28 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2C28 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x2C2C | 34 | char[1] | 4 | string literal
+ +0x2C2D | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2C2E | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x2C30 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2C34 | 69 64 | char[2] | id | string literal
+ +0x2C36 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.KeyValue):
+ +0x2C38 | D4 F6 FF FF | SOffset32 | 0xFFFFF6D4 (-2348) Loc: +0x3564 | offset to vtable
+ +0x2C3C | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x2C4C | offset to field `key` (string)
+ +0x2C40 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2C44 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2C44 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x2C48 | 30 | char[1] | 0 | string literal
+ +0x2C49 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2C4A | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x2C4C | 0A 00 00 00 | uint32_t | 0x0000000A (10) | length of string
+ +0x2C50 | 64 65 70 72 65 63 61 74 | char[10] | deprecat | string literal
+ +0x2C58 | 65 64 | | ed
+ +0x2C5A | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x2C5C | 78 F5 FF FF | SOffset32 | 0xFFFFF578 (-2696) Loc: +0x36E4 | offset to vtable
+ +0x2C60 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x2C63 | 02 | uint8_t | 0x02 (2) | table field `base_type` (Byte)
+ +0x2C64 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x2C68 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x2C6C | 08 00 00 00 | uint32_t | 0x00000008 (8) | length of string
+ +0x2C70 | 66 72 69 65 6E 64 6C 79 | char[8] | friendly | string literal
+ +0x2C78 | 00 | char | 0x00 (0) | string terminator
+
+vtable (reflection.Field):
+ +0x2C7A | 1A 00 | uint16_t | 0x001A (26) | size of this vtable
+ +0x2C7C | 1C 00 | uint16_t | 0x001C (28) | size of referring table
+ +0x2C7E | 0C 00 | VOffset16 | 0x000C (12) | offset to field `name` (id: 0)
+ +0x2C80 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `type` (id: 1)
+ +0x2C82 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `id` (id: 2)
+ +0x2C84 | 0A 00 | VOffset16 | 0x000A (10) | offset to field `offset` (id: 3)
+ +0x2C86 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_integer` (id: 4) <defaults to 0> (Long)
+ +0x2C88 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_real` (id: 5) <defaults to 0.000000> (Double)
+ +0x2C8A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `deprecated` (id: 6) <defaults to 0> (Bool)
+ +0x2C8C | 06 00 | VOffset16 | 0x0006 (6) | offset to field `required` (id: 7)
+ +0x2C8E | 07 00 | VOffset16 | 0x0007 (7) | offset to field `key` (id: 8)
+ +0x2C90 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `attributes` (id: 9)
+ +0x2C92 | 18 00 | VOffset16 | 0x0018 (24) | offset to field `documentation` (id: 10)
+
+table (reflection.Field):
+ +0x2C94 | 1A 00 00 00 | SOffset32 | 0x0000001A (26) Loc: +0x2C7A | offset to vtable
+ +0x2C98 | 00 00 | uint8_t[2] | .. | padding
+ +0x2C9A | 01 | uint8_t | 0x01 (1) | table field `required` (Bool)
+ +0x2C9B | 01 | uint8_t | 0x01 (1) | table field `key` (Bool)
+ +0x2C9C | 03 00 | uint16_t | 0x0003 (3) | table field `id` (UShort)
+ +0x2C9E | 0A 00 | uint16_t | 0x000A (10) | table field `offset` (UShort)
+ +0x2CA0 | 64 00 00 00 | UOffset32 | 0x00000064 (100) Loc: +0x2D04 | offset to field `name` (string)
+ +0x2CA4 | 54 00 00 00 | UOffset32 | 0x00000054 (84) Loc: +0x2CF8 | offset to field `type` (table)
+ +0x2CA8 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x2CB4 | offset to field `attributes` (vector)
+ +0x2CAC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2CB0 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x2CB0 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x2CB4 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x2CB8 | 24 00 00 00 | UOffset32 | 0x00000024 (36) Loc: +0x2CDC | offset to table[0]
+ +0x2CBC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2CC0 | offset to table[1]
+
+table (reflection.KeyValue):
+ +0x2CC0 | 5C F7 FF FF | SOffset32 | 0xFFFFF75C (-2212) Loc: +0x3564 | offset to vtable
+ +0x2CC4 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x2CD4 | offset to field `key` (string)
+ +0x2CC8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2CCC | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2CCC | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x2CD0 | 30 | char[1] | 0 | string literal
+ +0x2CD1 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2CD2 | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x2CD4 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x2CD8 | 6B 65 79 | char[3] | key | string literal
+ +0x2CDB | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.KeyValue):
+ +0x2CDC | 78 F7 FF FF | SOffset32 | 0xFFFFF778 (-2184) Loc: +0x3564 | offset to vtable
+ +0x2CE0 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x2CF0 | offset to field `key` (string)
+ +0x2CE4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2CE8 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2CE8 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x2CEC | 33 | char[1] | 3 | string literal
+ +0x2CED | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2CEE | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x2CF0 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2CF4 | 69 64 | char[2] | id | string literal
+ +0x2CF6 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x2CF8 | 5C F3 FF FF | SOffset32 | 0xFFFFF35C (-3236) Loc: +0x399C | offset to vtable
+ +0x2CFC | 00 00 00 | uint8_t[3] | ... | padding
+ +0x2CFF | 0D | uint8_t | 0x0D (13) | table field `base_type` (Byte)
+ +0x2D00 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x2D04 | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x2D08 | 6E 61 6D 65 | char[4] | name | string literal
+ +0x2D0C | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2D0D | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Field):
+ +0x2D10 | 9A FF FF FF | SOffset32 | 0xFFFFFF9A (-102) Loc: +0x2D76 | offset to vtable
+ +0x2D14 | 02 00 | uint16_t | 0x0002 (2) | table field `id` (UShort)
+ +0x2D16 | 08 00 | uint16_t | 0x0008 (8) | table field `offset` (UShort)
+ +0x2D18 | 54 00 00 00 | UOffset32 | 0x00000054 (84) Loc: +0x2D6C | offset to field `name` (string)
+ +0x2D1C | 40 00 00 00 | UOffset32 | 0x00000040 (64) Loc: +0x2D5C | offset to field `type` (table)
+ +0x2D20 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x2D38 | offset to field `attributes` (vector)
+ +0x2D24 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x2D34 | offset to field `documentation` (vector)
+ +0x2D28 | 64 00 00 00 00 00 00 00 | int64_t | 0x0000000000000064 (100) | table field `default_integer` (Long)
+ +0x2D30 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (reflection.Field.documentation):
+ +0x2D34 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x2D38 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x2D3C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2D40 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x2D40 | DC F7 FF FF | SOffset32 | 0xFFFFF7DC (-2084) Loc: +0x3564 | offset to vtable
+ +0x2D44 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x2D54 | offset to field `key` (string)
+ +0x2D48 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2D4C | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2D4C | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x2D50 | 32 | char[1] | 2 | string literal
+ +0x2D51 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2D52 | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x2D54 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2D58 | 69 64 | char[2] | id | string literal
+ +0x2D5A | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x2D5C | 78 F6 FF FF | SOffset32 | 0xFFFFF678 (-2440) Loc: +0x36E4 | offset to vtable
+ +0x2D60 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x2D63 | 05 | uint8_t | 0x05 (5) | table field `base_type` (Byte)
+ +0x2D64 | 02 00 00 00 | uint32_t | 0x00000002 (2) | table field `base_size` (UInt)
+ +0x2D68 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x2D6C | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2D70 | 68 70 | char[2] | hp | string literal
+ +0x2D72 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2D73 | 00 00 00 | uint8_t[3] | ... | padding
+
+vtable (reflection.Field):
+ +0x2D76 | 1A 00 | uint16_t | 0x001A (26) | size of this vtable
+ +0x2D78 | 24 00 | uint16_t | 0x0024 (36) | size of referring table
+ +0x2D7A | 08 00 | VOffset16 | 0x0008 (8) | offset to field `name` (id: 0)
+ +0x2D7C | 0C 00 | VOffset16 | 0x000C (12) | offset to field `type` (id: 1)
+ +0x2D7E | 04 00 | VOffset16 | 0x0004 (4) | offset to field `id` (id: 2)
+ +0x2D80 | 06 00 | VOffset16 | 0x0006 (6) | offset to field `offset` (id: 3)
+ +0x2D82 | 18 00 | VOffset16 | 0x0018 (24) | offset to field `default_integer` (id: 4)
+ +0x2D84 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_real` (id: 5) <defaults to 0.000000> (Double)
+ +0x2D86 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `deprecated` (id: 6) <defaults to 0> (Bool)
+ +0x2D88 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `required` (id: 7) <defaults to 0> (Bool)
+ +0x2D8A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `key` (id: 8) <defaults to 0> (Bool)
+ +0x2D8C | 10 00 | VOffset16 | 0x0010 (16) | offset to field `attributes` (id: 9)
+ +0x2D8E | 14 00 | VOffset16 | 0x0014 (20) | offset to field `documentation` (id: 10)
+
+table (reflection.Field):
+ +0x2D90 | 1A 00 00 00 | SOffset32 | 0x0000001A (26) Loc: +0x2D76 | offset to vtable
+ +0x2D94 | 01 00 | uint16_t | 0x0001 (1) | table field `id` (UShort)
+ +0x2D96 | 06 00 | uint16_t | 0x0006 (6) | table field `offset` (UShort)
+ +0x2D98 | 54 00 00 00 | UOffset32 | 0x00000054 (84) Loc: +0x2DEC | offset to field `name` (string)
+ +0x2D9C | 40 00 00 00 | UOffset32 | 0x00000040 (64) Loc: +0x2DDC | offset to field `type` (table)
+ +0x2DA0 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x2DB8 | offset to field `attributes` (vector)
+ +0x2DA4 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x2DB4 | offset to field `documentation` (vector)
+ +0x2DA8 | 96 00 00 00 00 00 00 00 | int64_t | 0x0000000000000096 (150) | table field `default_integer` (Long)
+ +0x2DB0 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (reflection.Field.documentation):
+ +0x2DB4 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x2DB8 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x2DBC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2DC0 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x2DC0 | 5C F8 FF FF | SOffset32 | 0xFFFFF85C (-1956) Loc: +0x3564 | offset to vtable
+ +0x2DC4 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x2DD4 | offset to field `key` (string)
+ +0x2DC8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2DCC | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2DCC | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x2DD0 | 31 | char[1] | 1 | string literal
+ +0x2DD1 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2DD2 | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x2DD4 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2DD8 | 69 64 | char[2] | id | string literal
+ +0x2DDA | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x2DDC | F8 F6 FF FF | SOffset32 | 0xFFFFF6F8 (-2312) Loc: +0x36E4 | offset to vtable
+ +0x2DE0 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x2DE3 | 05 | uint8_t | 0x05 (5) | table field `base_type` (Byte)
+ +0x2DE4 | 02 00 00 00 | uint32_t | 0x00000002 (2) | table field `base_size` (UInt)
+ +0x2DE8 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x2DEC | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x2DF0 | 6D 61 6E 61 | char[4] | mana | string literal
+ +0x2DF4 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2DF5 | 00 00 00 | uint8_t[3] | ... | padding
+
+vtable (reflection.Field):
+ +0x2DF8 | 1C 00 | uint16_t | 0x001C (28) | size of this vtable
+ +0x2DFA | 18 00 | uint16_t | 0x0018 (24) | size of referring table
+ +0x2DFC | 08 00 | VOffset16 | 0x0008 (8) | offset to field `name` (id: 0)
+ +0x2DFE | 0C 00 | VOffset16 | 0x000C (12) | offset to field `type` (id: 1)
+ +0x2E00 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `id` (id: 2) <defaults to 0> (UShort)
+ +0x2E02 | 06 00 | VOffset16 | 0x0006 (6) | offset to field `offset` (id: 3)
+ +0x2E04 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_integer` (id: 4) <defaults to 0> (Long)
+ +0x2E06 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_real` (id: 5) <defaults to 0.000000> (Double)
+ +0x2E08 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `deprecated` (id: 6) <defaults to 0> (Bool)
+ +0x2E0A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `required` (id: 7) <defaults to 0> (Bool)
+ +0x2E0C | 00 00 | VOffset16 | 0x0000 (0) | offset to field `key` (id: 8) <defaults to 0> (Bool)
+ +0x2E0E | 10 00 | VOffset16 | 0x0010 (16) | offset to field `attributes` (id: 9)
+ +0x2E10 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `documentation` (id: 10)
+ +0x2E12 | 05 00 | VOffset16 | 0x0005 (5) | offset to field `optional` (id: 11)
+
+table (reflection.Field):
+ +0x2E14 | 1C 00 00 00 | SOffset32 | 0x0000001C (28) Loc: +0x2DF8 | offset to vtable
+ +0x2E18 | 00 | uint8_t[1] | . | padding
+ +0x2E19 | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x2E1A | 04 00 | uint16_t | 0x0004 (4) | table field `offset` (UShort)
+ +0x2E1C | 48 00 00 00 | UOffset32 | 0x00000048 (72) Loc: +0x2E64 | offset to field `name` (string)
+ +0x2E20 | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x2E54 | offset to field `type` (table)
+ +0x2E24 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x2E30 | offset to field `attributes` (vector)
+ +0x2E28 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2E2C | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x2E2C | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x2E30 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x2E34 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2E38 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x2E38 | D4 F8 FF FF | SOffset32 | 0xFFFFF8D4 (-1836) Loc: +0x3564 | offset to vtable
+ +0x2E3C | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x2E4C | offset to field `key` (string)
+ +0x2E40 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2E44 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2E44 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x2E48 | 30 | char[1] | 0 | string literal
+ +0x2E49 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2E4A | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x2E4C | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2E50 | 69 64 | char[2] | id | string literal
+ +0x2E52 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x2E54 | 9C F5 FF FF | SOffset32 | 0xFFFFF59C (-2660) Loc: +0x38B8 | offset to vtable
+ +0x2E58 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x2E5B | 0F | uint8_t | 0x0F (15) | table field `base_type` (Byte)
+ +0x2E5C | 09 00 00 00 | uint32_t | 0x00000009 (9) | table field `index` (Int)
+ +0x2E60 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x2E64 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x2E68 | 70 6F 73 | char[3] | pos | string literal
+ +0x2E6B | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Object):
+ +0x2E6C | 44 F6 FF FF | SOffset32 | 0xFFFFF644 (-2492) Loc: +0x3828 | offset to vtable
+ +0x2E70 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x2E90 | offset to field `name` (string)
+ +0x2E74 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x2E88 | offset to field `fields` (vector)
+ +0x2E78 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `minalign` (Int)
+ +0x2E7C | 08 00 00 00 | UOffset32 | 0x00000008 (8) Loc: +0x2E84 | offset to field `documentation` (vector)
+ +0x2E80 | E0 08 00 00 | UOffset32 | 0x000008E0 (2272) Loc: +0x3760 | offset to field `declaration_file` (string)
+
+vector (reflection.Object.documentation):
+ +0x2E84 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Object.fields):
+ +0x2E88 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x2E8C | 3C 00 00 00 | UOffset32 | 0x0000003C (60) Loc: +0x2EC8 | offset to table[0]
+
+string (reflection.Object.name):
+ +0x2E90 | 19 00 00 00 | uint32_t | 0x00000019 (25) | length of string
+ +0x2E94 | 4D 79 47 61 6D 65 2E 45 | char[25] | MyGame.E | string literal
+ +0x2E9C | 78 61 6D 70 6C 65 2E 52 | | xample.R
+ +0x2EA4 | 65 66 65 72 72 61 62 6C | | eferrabl
+ +0x2EAC | 65 | | e
+ +0x2EAD | 00 | char | 0x00 (0) | string terminator
+
+vtable (reflection.Field):
+ +0x2EAE | 1A 00 | uint16_t | 0x001A (26) | size of this vtable
+ +0x2EB0 | 18 00 | uint16_t | 0x0018 (24) | size of referring table
+ +0x2EB2 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `name` (id: 0)
+ +0x2EB4 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `type` (id: 1)
+ +0x2EB6 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `id` (id: 2) <defaults to 0> (UShort)
+ +0x2EB8 | 06 00 | VOffset16 | 0x0006 (6) | offset to field `offset` (id: 3)
+ +0x2EBA | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_integer` (id: 4) <defaults to 0> (Long)
+ +0x2EBC | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_real` (id: 5) <defaults to 0.000000> (Double)
+ +0x2EBE | 00 00 | VOffset16 | 0x0000 (0) | offset to field `deprecated` (id: 6) <defaults to 0> (Bool)
+ +0x2EC0 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `required` (id: 7) <defaults to 0> (Bool)
+ +0x2EC2 | 05 00 | VOffset16 | 0x0005 (5) | offset to field `key` (id: 8)
+ +0x2EC4 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `attributes` (id: 9)
+ +0x2EC6 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `documentation` (id: 10)
+
+table (reflection.Field):
+ +0x2EC8 | 1A 00 00 00 | SOffset32 | 0x0000001A (26) Loc: +0x2EAE | offset to vtable
+ +0x2ECC | 00 | uint8_t[1] | . | padding
+ +0x2ECD | 01 | uint8_t | 0x01 (1) | table field `key` (Bool)
+ +0x2ECE | 04 00 | uint16_t | 0x0004 (4) | table field `offset` (UShort)
+ +0x2ED0 | 74 00 00 00 | UOffset32 | 0x00000074 (116) Loc: +0x2F44 | offset to field `name` (string)
+ +0x2ED4 | 60 00 00 00 | UOffset32 | 0x00000060 (96) Loc: +0x2F34 | offset to field `type` (table)
+ +0x2ED8 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x2EE4 | offset to field `attributes` (vector)
+ +0x2EDC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2EE0 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x2EE0 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x2EE4 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x2EE8 | 24 00 00 00 | UOffset32 | 0x00000024 (36) Loc: +0x2F0C | offset to table[0]
+ +0x2EEC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2EF0 | offset to table[1]
+
+table (reflection.KeyValue):
+ +0x2EF0 | 8C F9 FF FF | SOffset32 | 0xFFFFF98C (-1652) Loc: +0x3564 | offset to vtable
+ +0x2EF4 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x2F04 | offset to field `key` (string)
+ +0x2EF8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2EFC | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2EFC | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x2F00 | 30 | char[1] | 0 | string literal
+ +0x2F01 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2F02 | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x2F04 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x2F08 | 6B 65 79 | char[3] | key | string literal
+ +0x2F0B | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.KeyValue):
+ +0x2F0C | A8 F9 FF FF | SOffset32 | 0xFFFFF9A8 (-1624) Loc: +0x3564 | offset to vtable
+ +0x2F10 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x2F28 | offset to field `key` (string)
+ +0x2F14 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2F18 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2F18 | 08 00 00 00 | uint32_t | 0x00000008 (8) | length of string
+ +0x2F1C | 66 6E 76 31 61 5F 36 34 | char[8] | fnv1a_64 | string literal
+ +0x2F24 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2F25 | 00 00 00 | uint8_t[3] | ... | padding
+
+string (reflection.KeyValue.key):
+ +0x2F28 | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x2F2C | 68 61 73 68 | char[4] | hash | string literal
+ +0x2F30 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2F31 | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Type):
+ +0x2F34 | 50 F8 FF FF | SOffset32 | 0xFFFFF850 (-1968) Loc: +0x36E4 | offset to vtable
+ +0x2F38 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x2F3B | 0A | uint8_t | 0x0A (10) | table field `base_type` (Byte)
+ +0x2F3C | 08 00 00 00 | uint32_t | 0x00000008 (8) | table field `base_size` (UInt)
+ +0x2F40 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x2F44 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x2F48 | 69 64 | char[2] | id | string literal
+ +0x2F4A | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Object):
+ +0x2F4C | 24 F7 FF FF | SOffset32 | 0xFFFFF724 (-2268) Loc: +0x3828 | offset to vtable
+ +0x2F50 | 28 00 00 00 | UOffset32 | 0x00000028 (40) Loc: +0x2F78 | offset to field `name` (string)
+ +0x2F54 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x2F68 | offset to field `fields` (vector)
+ +0x2F58 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `minalign` (Int)
+ +0x2F5C | 08 00 00 00 | UOffset32 | 0x00000008 (8) Loc: +0x2F64 | offset to field `documentation` (vector)
+ +0x2F60 | 00 08 00 00 | UOffset32 | 0x00000800 (2048) Loc: +0x3760 | offset to field `declaration_file` (string)
+
+vector (reflection.Object.documentation):
+ +0x2F64 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Object.fields):
+ +0x2F68 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x2F6C | 40 00 00 00 | UOffset32 | 0x00000040 (64) Loc: +0x2FAC | offset to table[0]
+ +0x2F70 | CC 00 00 00 | UOffset32 | 0x000000CC (204) Loc: +0x303C | offset to table[1]
+ +0x2F74 | 98 00 00 00 | UOffset32 | 0x00000098 (152) Loc: +0x300C | offset to table[2]
+
+string (reflection.Object.name):
+ +0x2F78 | 13 00 00 00 | uint32_t | 0x00000013 (19) | length of string
+ +0x2F7C | 4D 79 47 61 6D 65 2E 45 | char[19] | MyGame.E | string literal
+ +0x2F84 | 78 61 6D 70 6C 65 2E 53 | | xample.S
+ +0x2F8C | 74 61 74 | | tat
+ +0x2F8F | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2F90 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (reflection.Field):
+ +0x2F92 | 1A 00 | uint16_t | 0x001A (26) | size of this vtable
+ +0x2F94 | 1C 00 | uint16_t | 0x001C (28) | size of referring table
+ +0x2F96 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `name` (id: 0)
+ +0x2F98 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `type` (id: 1)
+ +0x2F9A | 08 00 | VOffset16 | 0x0008 (8) | offset to field `id` (id: 2)
+ +0x2F9C | 0A 00 | VOffset16 | 0x000A (10) | offset to field `offset` (id: 3)
+ +0x2F9E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_integer` (id: 4) <defaults to 0> (Long)
+ +0x2FA0 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_real` (id: 5) <defaults to 0.000000> (Double)
+ +0x2FA2 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `deprecated` (id: 6) <defaults to 0> (Bool)
+ +0x2FA4 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `required` (id: 7) <defaults to 0> (Bool)
+ +0x2FA6 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `key` (id: 8)
+ +0x2FA8 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `attributes` (id: 9)
+ +0x2FAA | 18 00 | VOffset16 | 0x0018 (24) | offset to field `documentation` (id: 10)
+
+table (reflection.Field):
+ +0x2FAC | 1A 00 00 00 | SOffset32 | 0x0000001A (26) Loc: +0x2F92 | offset to vtable
+ +0x2FB0 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x2FB3 | 01 | uint8_t | 0x01 (1) | table field `key` (Bool)
+ +0x2FB4 | 02 00 | uint16_t | 0x0002 (2) | table field `id` (UShort)
+ +0x2FB6 | 08 00 | uint16_t | 0x0008 (8) | table field `offset` (UShort)
+ +0x2FB8 | 48 00 00 00 | UOffset32 | 0x00000048 (72) Loc: +0x3000 | offset to field `name` (string)
+ +0x2FBC | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x2FF0 | offset to field `type` (table)
+ +0x2FC0 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x2FCC | offset to field `attributes` (vector)
+ +0x2FC4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2FC8 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x2FC8 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x2FCC | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x2FD0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2FD4 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x2FD4 | 70 FA FF FF | SOffset32 | 0xFFFFFA70 (-1424) Loc: +0x3564 | offset to vtable
+ +0x2FD8 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x2FE8 | offset to field `key` (string)
+ +0x2FDC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x2FE0 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x2FE0 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x2FE4 | 30 | char[1] | 0 | string literal
+ +0x2FE5 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x2FE6 | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x2FE8 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x2FEC | 6B 65 79 | char[3] | key | string literal
+ +0x2FEF | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x2FF0 | 0C F9 FF FF | SOffset32 | 0xFFFFF90C (-1780) Loc: +0x36E4 | offset to vtable
+ +0x2FF4 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x2FF7 | 06 | uint8_t | 0x06 (6) | table field `base_type` (Byte)
+ +0x2FF8 | 02 00 00 00 | uint32_t | 0x00000002 (2) | table field `base_size` (UInt)
+ +0x2FFC | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x3000 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x3004 | 63 6F 75 6E 74 | char[5] | count | string literal
+ +0x3009 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x300A | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Field):
+ +0x300C | 76 FB FF FF | SOffset32 | 0xFFFFFB76 (-1162) Loc: +0x3496 | offset to vtable
+ +0x3010 | 01 00 | uint16_t | 0x0001 (1) | table field `id` (UShort)
+ +0x3012 | 06 00 | uint16_t | 0x0006 (6) | table field `offset` (UShort)
+ +0x3014 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x3034 | offset to field `name` (string)
+ +0x3018 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x3024 | offset to field `type` (table)
+ +0x301C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x3020 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x3020 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x3024 | 40 F9 FF FF | SOffset32 | 0xFFFFF940 (-1728) Loc: +0x36E4 | offset to vtable
+ +0x3028 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x302B | 09 | uint8_t | 0x09 (9) | table field `base_type` (Byte)
+ +0x302C | 08 00 00 00 | uint32_t | 0x00000008 (8) | table field `base_size` (UInt)
+ +0x3030 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x3034 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x3038 | 76 61 6C | char[3] | val | string literal
+ +0x303B | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x303C | B8 F7 FF FF | SOffset32 | 0xFFFFF7B8 (-2120) Loc: +0x3884 | offset to vtable
+ +0x3040 | 00 | uint8_t[1] | . | padding
+ +0x3041 | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x3042 | 04 00 | uint16_t | 0x0004 (4) | table field `offset` (UShort)
+ +0x3044 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x3060 | offset to field `name` (string)
+ +0x3048 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x3054 | offset to field `type` (table)
+ +0x304C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x3050 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x3050 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x3054 | B8 F6 FF FF | SOffset32 | 0xFFFFF6B8 (-2376) Loc: +0x399C | offset to vtable
+ +0x3058 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x305B | 0D | uint8_t | 0x0D (13) | table field `base_type` (Byte)
+ +0x305C | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x3060 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x3064 | 69 64 | char[2] | id | string literal
+ +0x3066 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Object):
+ +0x3068 | 88 F7 FF FF | SOffset32 | 0xFFFFF788 (-2168) Loc: +0x38E0 | offset to vtable
+ +0x306C | 00 00 00 | uint8_t[3] | ... | padding
+ +0x306F | 01 | uint8_t | 0x01 (1) | table field `is_struct` (Bool)
+ +0x3070 | 24 00 00 00 | UOffset32 | 0x00000024 (36) Loc: +0x3094 | offset to field `name` (string)
+ +0x3074 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x308C | offset to field `fields` (vector)
+ +0x3078 | 04 00 00 00 | uint32_t | 0x00000004 (4) | table field `minalign` (Int)
+ +0x307C | 14 00 00 00 | uint32_t | 0x00000014 (20) | table field `bytesize` (Int)
+ +0x3080 | 08 00 00 00 | UOffset32 | 0x00000008 (8) Loc: +0x3088 | offset to field `documentation` (vector)
+ +0x3084 | DC 06 00 00 | UOffset32 | 0x000006DC (1756) Loc: +0x3760 | offset to field `declaration_file` (string)
+
+vector (reflection.Object.documentation):
+ +0x3088 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Object.fields):
+ +0x308C | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x3090 | 30 00 00 00 | UOffset32 | 0x00000030 (48) Loc: +0x30C0 | offset to table[0]
+
+string (reflection.Object.name):
+ +0x3094 | 27 00 00 00 | uint32_t | 0x00000027 (39) | length of string
+ +0x3098 | 4D 79 47 61 6D 65 2E 45 | char[39] | MyGame.E | string literal
+ +0x30A0 | 78 61 6D 70 6C 65 2E 53 | | xample.S
+ +0x30A8 | 74 72 75 63 74 4F 66 53 | | tructOfS
+ +0x30B0 | 74 72 75 63 74 73 4F 66 | | tructsOf
+ +0x30B8 | 53 74 72 75 63 74 73 | | Structs
+ +0x30BF | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x30C0 | F4 FE FF FF | SOffset32 | 0xFFFFFEF4 (-268) Loc: +0x31CC | offset to vtable
+ +0x30C4 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x30C7 | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x30C8 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x30E8 | offset to field `name` (string)
+ +0x30CC | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x30D8 | offset to field `type` (table)
+ +0x30D0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x30D4 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x30D4 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x30D8 | 20 F8 FF FF | SOffset32 | 0xFFFFF820 (-2016) Loc: +0x38B8 | offset to vtable
+ +0x30DC | 00 00 00 | uint8_t[3] | ... | padding
+ +0x30DF | 0F | uint8_t | 0x0F (15) | table field `base_type` (Byte)
+ +0x30E0 | 04 00 00 00 | uint32_t | 0x00000004 (4) | table field `index` (Int)
+ +0x30E4 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x30E8 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x30EC | 61 | char[1] | a | string literal
+ +0x30ED | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x30EE | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Object):
+ +0x30F0 | 10 F8 FF FF | SOffset32 | 0xFFFFF810 (-2032) Loc: +0x38E0 | offset to vtable
+ +0x30F4 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x30F7 | 01 | uint8_t | 0x01 (1) | table field `is_struct` (Bool)
+ +0x30F8 | 2C 00 00 00 | UOffset32 | 0x0000002C (44) Loc: +0x3124 | offset to field `name` (string)
+ +0x30FC | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x3114 | offset to field `fields` (vector)
+ +0x3100 | 04 00 00 00 | uint32_t | 0x00000004 (4) | table field `minalign` (Int)
+ +0x3104 | 14 00 00 00 | uint32_t | 0x00000014 (20) | table field `bytesize` (Int)
+ +0x3108 | 08 00 00 00 | UOffset32 | 0x00000008 (8) Loc: +0x3110 | offset to field `documentation` (vector)
+ +0x310C | 54 06 00 00 | UOffset32 | 0x00000654 (1620) Loc: +0x3760 | offset to field `declaration_file` (string)
+
+vector (reflection.Object.documentation):
+ +0x3110 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Object.fields):
+ +0x3114 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x3118 | D0 00 00 00 | UOffset32 | 0x000000D0 (208) Loc: +0x31E8 | offset to table[0]
+ +0x311C | 7C 00 00 00 | UOffset32 | 0x0000007C (124) Loc: +0x3198 | offset to table[1]
+ +0x3120 | 28 00 00 00 | UOffset32 | 0x00000028 (40) Loc: +0x3148 | offset to table[2]
+
+string (reflection.Object.name):
+ +0x3124 | 1E 00 00 00 | uint32_t | 0x0000001E (30) | length of string
+ +0x3128 | 4D 79 47 61 6D 65 2E 45 | char[30] | MyGame.E | string literal
+ +0x3130 | 78 61 6D 70 6C 65 2E 53 | | xample.S
+ +0x3138 | 74 72 75 63 74 4F 66 53 | | tructOfS
+ +0x3140 | 74 72 75 63 74 73 | | tructs
+ +0x3146 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x3148 | CC FF FF FF | SOffset32 | 0xFFFFFFCC (-52) Loc: +0x317C | offset to vtable
+ +0x314C | 00 00 00 | uint8_t[3] | ... | padding
+ +0x314F | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x3150 | 02 00 | uint16_t | 0x0002 (2) | table field `id` (UShort)
+ +0x3152 | 0C 00 | uint16_t | 0x000C (12) | table field `offset` (UShort)
+ +0x3154 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x3174 | offset to field `name` (string)
+ +0x3158 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x3164 | offset to field `type` (table)
+ +0x315C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x3160 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x3160 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x3164 | AC F8 FF FF | SOffset32 | 0xFFFFF8AC (-1876) Loc: +0x38B8 | offset to vtable
+ +0x3168 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x316B | 0F | uint8_t | 0x0F (15) | table field `base_type` (Byte)
+ +0x316C | 00 00 00 00 | uint32_t | 0x00000000 (0) | table field `index` (Int)
+ +0x3170 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x3174 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x3178 | 63 | char[1] | c | string literal
+ +0x3179 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x317A | 00 00 | uint8_t[2] | .. | padding
+
+vtable (reflection.Field):
+ +0x317C | 1C 00 | uint16_t | 0x001C (28) | size of this vtable
+ +0x317E | 18 00 | uint16_t | 0x0018 (24) | size of referring table
+ +0x3180 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `name` (id: 0)
+ +0x3182 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `type` (id: 1)
+ +0x3184 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `id` (id: 2)
+ +0x3186 | 0A 00 | VOffset16 | 0x000A (10) | offset to field `offset` (id: 3)
+ +0x3188 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_integer` (id: 4) <defaults to 0> (Long)
+ +0x318A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_real` (id: 5) <defaults to 0.000000> (Double)
+ +0x318C | 00 00 | VOffset16 | 0x0000 (0) | offset to field `deprecated` (id: 6) <defaults to 0> (Bool)
+ +0x318E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `required` (id: 7) <defaults to 0> (Bool)
+ +0x3190 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `key` (id: 8) <defaults to 0> (Bool)
+ +0x3192 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `attributes` (id: 9) <null> (Vector)
+ +0x3194 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `documentation` (id: 10)
+ +0x3196 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `optional` (id: 11)
+
+table (reflection.Field):
+ +0x3198 | 1C 00 00 00 | SOffset32 | 0x0000001C (28) Loc: +0x317C | offset to vtable
+ +0x319C | 00 00 00 | uint8_t[3] | ... | padding
+ +0x319F | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x31A0 | 01 00 | uint16_t | 0x0001 (1) | table field `id` (UShort)
+ +0x31A2 | 08 00 | uint16_t | 0x0008 (8) | table field `offset` (UShort)
+ +0x31A4 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x31C4 | offset to field `name` (string)
+ +0x31A8 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x31B4 | offset to field `type` (table)
+ +0x31AC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x31B0 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x31B0 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x31B4 | FC F8 FF FF | SOffset32 | 0xFFFFF8FC (-1796) Loc: +0x38B8 | offset to vtable
+ +0x31B8 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x31BB | 0F | uint8_t | 0x0F (15) | table field `base_type` (Byte)
+ +0x31BC | 06 00 00 00 | uint32_t | 0x00000006 (6) | table field `index` (Int)
+ +0x31C0 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x31C4 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x31C8 | 62 | char[1] | b | string literal
+ +0x31C9 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x31CA | 00 00 | uint8_t[2] | .. | padding
+
+vtable (reflection.Field):
+ +0x31CC | 1C 00 | uint16_t | 0x001C (28) | size of this vtable
+ +0x31CE | 14 00 | uint16_t | 0x0014 (20) | size of referring table
+ +0x31D0 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `name` (id: 0)
+ +0x31D2 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `type` (id: 1)
+ +0x31D4 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `id` (id: 2) <defaults to 0> (UShort)
+ +0x31D6 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `offset` (id: 3) <defaults to 0> (UShort)
+ +0x31D8 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_integer` (id: 4) <defaults to 0> (Long)
+ +0x31DA | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_real` (id: 5) <defaults to 0.000000> (Double)
+ +0x31DC | 00 00 | VOffset16 | 0x0000 (0) | offset to field `deprecated` (id: 6) <defaults to 0> (Bool)
+ +0x31DE | 00 00 | VOffset16 | 0x0000 (0) | offset to field `required` (id: 7) <defaults to 0> (Bool)
+ +0x31E0 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `key` (id: 8) <defaults to 0> (Bool)
+ +0x31E2 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `attributes` (id: 9) <null> (Vector)
+ +0x31E4 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `documentation` (id: 10)
+ +0x31E6 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `optional` (id: 11)
+
+table (reflection.Field):
+ +0x31E8 | 1C 00 00 00 | SOffset32 | 0x0000001C (28) Loc: +0x31CC | offset to vtable
+ +0x31EC | 00 00 00 | uint8_t[3] | ... | padding
+ +0x31EF | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x31F0 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x3210 | offset to field `name` (string)
+ +0x31F4 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x3200 | offset to field `type` (table)
+ +0x31F8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x31FC | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x31FC | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x3200 | 48 F9 FF FF | SOffset32 | 0xFFFFF948 (-1720) Loc: +0x38B8 | offset to vtable
+ +0x3204 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x3207 | 0F | uint8_t | 0x0F (15) | table field `base_type` (Byte)
+ +0x3208 | 00 00 00 00 | uint32_t | 0x00000000 (0) | table field `index` (Int)
+ +0x320C | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x3210 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x3214 | 61 | char[1] | a | string literal
+ +0x3215 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x3216 | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Object):
+ +0x3218 | 38 F9 FF FF | SOffset32 | 0xFFFFF938 (-1736) Loc: +0x38E0 | offset to vtable
+ +0x321C | 00 00 00 | uint8_t[3] | ... | padding
+ +0x321F | 01 | uint8_t | 0x01 (1) | table field `is_struct` (Bool)
+ +0x3220 | 28 00 00 00 | UOffset32 | 0x00000028 (40) Loc: +0x3248 | offset to field `name` (string)
+ +0x3224 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x323C | offset to field `fields` (vector)
+ +0x3228 | 04 00 00 00 | uint32_t | 0x00000004 (4) | table field `minalign` (Int)
+ +0x322C | 08 00 00 00 | uint32_t | 0x00000008 (8) | table field `bytesize` (Int)
+ +0x3230 | 08 00 00 00 | UOffset32 | 0x00000008 (8) Loc: +0x3238 | offset to field `documentation` (vector)
+ +0x3234 | 2C 05 00 00 | UOffset32 | 0x0000052C (1324) Loc: +0x3760 | offset to field `declaration_file` (string)
+
+vector (reflection.Object.documentation):
+ +0x3238 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Object.fields):
+ +0x323C | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x3240 | 24 00 00 00 | UOffset32 | 0x00000024 (36) Loc: +0x3264 | offset to table[0]
+ +0x3244 | 6C 00 00 00 | UOffset32 | 0x0000006C (108) Loc: +0x32B0 | offset to table[1]
+
+string (reflection.Object.name):
+ +0x3248 | 16 00 00 00 | uint32_t | 0x00000016 (22) | length of string
+ +0x324C | 4D 79 47 61 6D 65 2E 45 | char[22] | MyGame.E | string literal
+ +0x3254 | 78 61 6D 70 6C 65 2E 41 | | xample.A
+ +0x325C | 62 69 6C 69 74 79 | | bility
+ +0x3262 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x3264 | CE FD FF FF | SOffset32 | 0xFFFFFDCE (-562) Loc: +0x3496 | offset to vtable
+ +0x3268 | 01 00 | uint16_t | 0x0001 (1) | table field `id` (UShort)
+ +0x326A | 04 00 | uint16_t | 0x0004 (4) | table field `offset` (UShort)
+ +0x326C | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x3288 | offset to field `name` (string)
+ +0x3270 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x327C | offset to field `type` (table)
+ +0x3274 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x3278 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x3278 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x327C | E0 F8 FF FF | SOffset32 | 0xFFFFF8E0 (-1824) Loc: +0x399C | offset to vtable
+ +0x3280 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x3283 | 08 | uint8_t | 0x08 (8) | table field `base_type` (Byte)
+ +0x3284 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x3288 | 08 00 00 00 | uint32_t | 0x00000008 (8) | length of string
+ +0x328C | 64 69 73 74 61 6E 63 65 | char[8] | distance | string literal
+ +0x3294 | 00 | char | 0x00 (0) | string terminator
+
+vtable (reflection.Field):
+ +0x3296 | 1A 00 | uint16_t | 0x001A (26) | size of this vtable
+ +0x3298 | 18 00 | uint16_t | 0x0018 (24) | size of referring table
+ +0x329A | 08 00 | VOffset16 | 0x0008 (8) | offset to field `name` (id: 0)
+ +0x329C | 0C 00 | VOffset16 | 0x000C (12) | offset to field `type` (id: 1)
+ +0x329E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `id` (id: 2) <defaults to 0> (UShort)
+ +0x32A0 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `offset` (id: 3) <defaults to 0> (UShort)
+ +0x32A2 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_integer` (id: 4) <defaults to 0> (Long)
+ +0x32A4 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_real` (id: 5) <defaults to 0.000000> (Double)
+ +0x32A6 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `deprecated` (id: 6) <defaults to 0> (Bool)
+ +0x32A8 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `required` (id: 7) <defaults to 0> (Bool)
+ +0x32AA | 07 00 | VOffset16 | 0x0007 (7) | offset to field `key` (id: 8)
+ +0x32AC | 10 00 | VOffset16 | 0x0010 (16) | offset to field `attributes` (id: 9)
+ +0x32AE | 14 00 | VOffset16 | 0x0014 (20) | offset to field `documentation` (id: 10)
+
+table (reflection.Field):
+ +0x32B0 | 1A 00 00 00 | SOffset32 | 0x0000001A (26) Loc: +0x3296 | offset to vtable
+ +0x32B4 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x32B7 | 01 | uint8_t | 0x01 (1) | table field `key` (Bool)
+ +0x32B8 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x32FC | offset to field `name` (string)
+ +0x32BC | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x32F0 | offset to field `type` (table)
+ +0x32C0 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x32CC | offset to field `attributes` (vector)
+ +0x32C4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x32C8 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x32C8 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Field.attributes):
+ +0x32CC | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x32D0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x32D4 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x32D4 | 70 FD FF FF | SOffset32 | 0xFFFFFD70 (-656) Loc: +0x3564 | offset to vtable
+ +0x32D8 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x32E8 | offset to field `key` (string)
+ +0x32DC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x32E0 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x32E0 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x32E4 | 30 | char[1] | 0 | string literal
+ +0x32E5 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x32E6 | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x32E8 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x32EC | 6B 65 79 | char[3] | key | string literal
+ +0x32EF | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Type):
+ +0x32F0 | 54 F9 FF FF | SOffset32 | 0xFFFFF954 (-1708) Loc: +0x399C | offset to vtable
+ +0x32F4 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x32F7 | 08 | uint8_t | 0x08 (8) | table field `base_type` (Byte)
+ +0x32F8 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x32FC | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of string
+ +0x3300 | 69 64 | char[2] | id | string literal
+ +0x3302 | 00 | char | 0x00 (0) | string terminator
+
+vtable (reflection.Object):
+ +0x3304 | 14 00 | uint16_t | 0x0014 (20) | size of this vtable
+ +0x3306 | 24 00 | uint16_t | 0x0024 (36) | size of referring table
+ +0x3308 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `name` (id: 0)
+ +0x330A | 0C 00 | VOffset16 | 0x000C (12) | offset to field `fields` (id: 1)
+ +0x330C | 07 00 | VOffset16 | 0x0007 (7) | offset to field `is_struct` (id: 2)
+ +0x330E | 10 00 | VOffset16 | 0x0010 (16) | offset to field `minalign` (id: 3)
+ +0x3310 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `bytesize` (id: 4)
+ +0x3312 | 18 00 | VOffset16 | 0x0018 (24) | offset to field `attributes` (id: 5)
+ +0x3314 | 1C 00 | VOffset16 | 0x001C (28) | offset to field `documentation` (id: 6)
+ +0x3316 | 20 00 | VOffset16 | 0x0020 (32) | offset to field `declaration_file` (id: 7)
+
+table (reflection.Object):
+ +0x3318 | 14 00 00 00 | SOffset32 | 0x00000014 (20) Loc: +0x3304 | offset to vtable
+ +0x331C | 00 00 00 | uint8_t[3] | ... | padding
+ +0x331F | 01 | uint8_t | 0x01 (1) | table field `is_struct` (Bool)
+ +0x3320 | 68 00 00 00 | UOffset32 | 0x00000068 (104) Loc: +0x3388 | offset to field `name` (string)
+ +0x3324 | 48 00 00 00 | UOffset32 | 0x00000048 (72) Loc: +0x336C | offset to field `fields` (vector)
+ +0x3328 | 08 00 00 00 | uint32_t | 0x00000008 (8) | table field `minalign` (Int)
+ +0x332C | 20 00 00 00 | uint32_t | 0x00000020 (32) | table field `bytesize` (Int)
+ +0x3330 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x3340 | offset to field `attributes` (vector)
+ +0x3334 | 08 00 00 00 | UOffset32 | 0x00000008 (8) Loc: +0x333C | offset to field `documentation` (vector)
+ +0x3338 | 28 04 00 00 | UOffset32 | 0x00000428 (1064) Loc: +0x3760 | offset to field `declaration_file` (string)
+
+vector (reflection.Object.documentation):
+ +0x333C | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Object.attributes):
+ +0x3340 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x3344 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x3348 | offset to table[0]
+
+table (reflection.KeyValue):
+ +0x3348 | E4 FD FF FF | SOffset32 | 0xFFFFFDE4 (-540) Loc: +0x3564 | offset to vtable
+ +0x334C | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x335C | offset to field `key` (string)
+ +0x3350 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x3354 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x3354 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x3358 | 38 | char[1] | 8 | string literal
+ +0x3359 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x335A | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x335C | 0B 00 00 00 | uint32_t | 0x0000000B (11) | length of string
+ +0x3360 | 66 6F 72 63 65 5F 61 6C | char[11] | force_al | string literal
+ +0x3368 | 69 67 6E | | ign
+ +0x336B | 00 | char | 0x00 (0) | string terminator
+
+vector (reflection.Object.fields):
+ +0x336C | 06 00 00 00 | uint32_t | 0x00000006 (6) | length of vector (# items)
+ +0x3370 | C4 00 00 00 | UOffset32 | 0x000000C4 (196) Loc: +0x3434 | offset to table[0]
+ +0x3374 | 84 00 00 00 | UOffset32 | 0x00000084 (132) Loc: +0x33F8 | offset to table[1]
+ +0x3378 | 48 00 00 00 | UOffset32 | 0x00000048 (72) Loc: +0x33C0 | offset to table[2]
+ +0x337C | 60 01 00 00 | UOffset32 | 0x00000160 (352) Loc: +0x34DC | offset to table[3]
+ +0x3380 | 30 01 00 00 | UOffset32 | 0x00000130 (304) Loc: +0x34B0 | offset to table[4]
+ +0x3384 | E4 00 00 00 | UOffset32 | 0x000000E4 (228) Loc: +0x3468 | offset to table[5]
+
+string (reflection.Object.name):
+ +0x3388 | 13 00 00 00 | uint32_t | 0x00000013 (19) | length of string
+ +0x338C | 4D 79 47 61 6D 65 2E 45 | char[19] | MyGame.E | string literal
+ +0x3394 | 78 61 6D 70 6C 65 2E 56 | | xample.V
+ +0x339C | 65 63 33 | | ec3
+ +0x339F | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x33A0 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (reflection.Field):
+ +0x33A2 | 1E 00 | uint16_t | 0x001E (30) | size of this vtable
+ +0x33A4 | 18 00 | uint16_t | 0x0018 (24) | size of referring table
+ +0x33A6 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `name` (id: 0)
+ +0x33A8 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `type` (id: 1)
+ +0x33AA | 06 00 | VOffset16 | 0x0006 (6) | offset to field `id` (id: 2)
+ +0x33AC | 08 00 | VOffset16 | 0x0008 (8) | offset to field `offset` (id: 3)
+ +0x33AE | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_integer` (id: 4) <defaults to 0> (Long)
+ +0x33B0 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_real` (id: 5) <defaults to 0.000000> (Double)
+ +0x33B2 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `deprecated` (id: 6) <defaults to 0> (Bool)
+ +0x33B4 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `required` (id: 7) <defaults to 0> (Bool)
+ +0x33B6 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `key` (id: 8) <defaults to 0> (Bool)
+ +0x33B8 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `attributes` (id: 9) <null> (Vector)
+ +0x33BA | 14 00 | VOffset16 | 0x0014 (20) | offset to field `documentation` (id: 10)
+ +0x33BC | 05 00 | VOffset16 | 0x0005 (5) | offset to field `optional` (id: 11)
+ +0x33BE | 0A 00 | VOffset16 | 0x000A (10) | offset to field `padding` (id: 12)
+
+table (reflection.Field):
+ +0x33C0 | 1E 00 00 00 | SOffset32 | 0x0000001E (30) Loc: +0x33A2 | offset to vtable
+ +0x33C4 | 00 | uint8_t[1] | . | padding
+ +0x33C5 | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x33C6 | 05 00 | uint16_t | 0x0005 (5) | table field `id` (UShort)
+ +0x33C8 | 1A 00 | uint16_t | 0x001A (26) | table field `offset` (UShort)
+ +0x33CA | 02 00 | uint16_t | 0x0002 (2) | table field `padding` (UShort)
+ +0x33CC | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x33EC | offset to field `name` (string)
+ +0x33D0 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x33DC | offset to field `type` (table)
+ +0x33D4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x33D8 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x33D8 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x33DC | 24 FB FF FF | SOffset32 | 0xFFFFFB24 (-1244) Loc: +0x38B8 | offset to vtable
+ +0x33E0 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x33E3 | 0F | uint8_t | 0x0F (15) | table field `base_type` (Byte)
+ +0x33E4 | 06 00 00 00 | uint32_t | 0x00000006 (6) | table field `index` (Int)
+ +0x33E8 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x33EC | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x33F0 | 74 65 73 74 33 | char[5] | test3 | string literal
+ +0x33F5 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x33F6 | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Field):
+ +0x33F8 | 7A FD FF FF | SOffset32 | 0xFFFFFD7A (-646) Loc: +0x367E | offset to vtable
+ +0x33FC | 00 00 | uint8_t[2] | .. | padding
+ +0x33FE | 04 00 | uint16_t | 0x0004 (4) | table field `id` (UShort)
+ +0x3400 | 18 00 | uint16_t | 0x0018 (24) | table field `offset` (UShort)
+ +0x3402 | 01 00 | uint16_t | 0x0001 (1) | table field `padding` (UShort)
+ +0x3404 | 24 00 00 00 | UOffset32 | 0x00000024 (36) Loc: +0x3428 | offset to field `name` (string)
+ +0x3408 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x3414 | offset to field `type` (table)
+ +0x340C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x3410 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x3410 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x3414 | 10 FE FF FF | SOffset32 | 0xFFFFFE10 (-496) Loc: +0x3604 | offset to vtable
+ +0x3418 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x341B | 04 | uint8_t | 0x04 (4) | table field `base_type` (Byte)
+ +0x341C | 03 00 00 00 | uint32_t | 0x00000003 (3) | table field `index` (Int)
+ +0x3420 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x3424 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x3428 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x342C | 74 65 73 74 32 | char[5] | test2 | string literal
+ +0x3431 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x3432 | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Field):
+ +0x3434 | 9E FF FF FF | SOffset32 | 0xFFFFFF9E (-98) Loc: +0x3496 | offset to vtable
+ +0x3438 | 03 00 | uint16_t | 0x0003 (3) | table field `id` (UShort)
+ +0x343A | 10 00 | uint16_t | 0x0010 (16) | table field `offset` (UShort)
+ +0x343C | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x345C | offset to field `name` (string)
+ +0x3440 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x344C | offset to field `type` (table)
+ +0x3444 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x3448 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x3448 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x344C | 68 FD FF FF | SOffset32 | 0xFFFFFD68 (-664) Loc: +0x36E4 | offset to vtable
+ +0x3450 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x3453 | 0C | uint8_t | 0x0C (12) | table field `base_type` (Byte)
+ +0x3454 | 08 00 00 00 | uint32_t | 0x00000008 (8) | table field `base_size` (UInt)
+ +0x3458 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x345C | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x3460 | 74 65 73 74 31 | char[5] | test1 | string literal
+ +0x3465 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x3466 | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Field):
+ +0x3468 | EA FD FF FF | SOffset32 | 0xFFFFFDEA (-534) Loc: +0x367E | offset to vtable
+ +0x346C | 00 00 | uint8_t[2] | .. | padding
+ +0x346E | 02 00 | uint16_t | 0x0002 (2) | table field `id` (UShort)
+ +0x3470 | 08 00 | uint16_t | 0x0008 (8) | table field `offset` (UShort)
+ +0x3472 | 04 00 | uint16_t | 0x0004 (4) | table field `padding` (UShort)
+ +0x3474 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x3490 | offset to field `name` (string)
+ +0x3478 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x3484 | offset to field `type` (table)
+ +0x347C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x3480 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x3480 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x3484 | E8 FA FF FF | SOffset32 | 0xFFFFFAE8 (-1304) Loc: +0x399C | offset to vtable
+ +0x3488 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x348B | 0B | uint8_t | 0x0B (11) | table field `base_type` (Byte)
+ +0x348C | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x3490 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x3494 | 7A | char[1] | z | string literal
+ +0x3495 | 00 | char | 0x00 (0) | string terminator
+
+vtable (reflection.Field):
+ +0x3496 | 1A 00 | uint16_t | 0x001A (26) | size of this vtable
+ +0x3498 | 14 00 | uint16_t | 0x0014 (20) | size of referring table
+ +0x349A | 08 00 | VOffset16 | 0x0008 (8) | offset to field `name` (id: 0)
+ +0x349C | 0C 00 | VOffset16 | 0x000C (12) | offset to field `type` (id: 1)
+ +0x349E | 04 00 | VOffset16 | 0x0004 (4) | offset to field `id` (id: 2)
+ +0x34A0 | 06 00 | VOffset16 | 0x0006 (6) | offset to field `offset` (id: 3)
+ +0x34A2 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_integer` (id: 4) <defaults to 0> (Long)
+ +0x34A4 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_real` (id: 5) <defaults to 0.000000> (Double)
+ +0x34A6 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `deprecated` (id: 6) <defaults to 0> (Bool)
+ +0x34A8 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `required` (id: 7) <defaults to 0> (Bool)
+ +0x34AA | 00 00 | VOffset16 | 0x0000 (0) | offset to field `key` (id: 8) <defaults to 0> (Bool)
+ +0x34AC | 00 00 | VOffset16 | 0x0000 (0) | offset to field `attributes` (id: 9) <null> (Vector)
+ +0x34AE | 10 00 | VOffset16 | 0x0010 (16) | offset to field `documentation` (id: 10)
+
+table (reflection.Field):
+ +0x34B0 | 1A 00 00 00 | SOffset32 | 0x0000001A (26) Loc: +0x3496 | offset to vtable
+ +0x34B4 | 01 00 | uint16_t | 0x0001 (1) | table field `id` (UShort)
+ +0x34B6 | 04 00 | uint16_t | 0x0004 (4) | table field `offset` (UShort)
+ +0x34B8 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x34D4 | offset to field `name` (string)
+ +0x34BC | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x34C8 | offset to field `type` (table)
+ +0x34C0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x34C4 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x34C4 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x34C8 | 2C FB FF FF | SOffset32 | 0xFFFFFB2C (-1236) Loc: +0x399C | offset to vtable
+ +0x34CC | 00 00 00 | uint8_t[3] | ... | padding
+ +0x34CF | 0B | uint8_t | 0x0B (11) | table field `base_type` (Byte)
+ +0x34D0 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x34D4 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x34D8 | 79 | char[1] | y | string literal
+ +0x34D9 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x34DA | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Field):
+ +0x34DC | 6E FB FF FF | SOffset32 | 0xFFFFFB6E (-1170) Loc: +0x396E | offset to vtable
+ +0x34E0 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x34FC | offset to field `name` (string)
+ +0x34E4 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x34F0 | offset to field `type` (table)
+ +0x34E8 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x34EC | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x34EC | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x34F0 | 54 FB FF FF | SOffset32 | 0xFFFFFB54 (-1196) Loc: +0x399C | offset to vtable
+ +0x34F4 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x34F7 | 0B | uint8_t | 0x0B (11) | table field `base_type` (Byte)
+ +0x34F8 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x34FC | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x3500 | 78 | char[1] | x | string literal
+ +0x3501 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x3502 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (reflection.Object):
+ +0x3504 | 14 00 | uint16_t | 0x0014 (20) | size of this vtable
+ +0x3506 | 1C 00 | uint16_t | 0x001C (28) | size of referring table
+ +0x3508 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `name` (id: 0)
+ +0x350A | 08 00 | VOffset16 | 0x0008 (8) | offset to field `fields` (id: 1)
+ +0x350C | 00 00 | VOffset16 | 0x0000 (0) | offset to field `is_struct` (id: 2) <defaults to 0> (Bool)
+ +0x350E | 0C 00 | VOffset16 | 0x000C (12) | offset to field `minalign` (id: 3)
+ +0x3510 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `bytesize` (id: 4) <defaults to 0> (Int)
+ +0x3512 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `attributes` (id: 5)
+ +0x3514 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `documentation` (id: 6)
+ +0x3516 | 18 00 | VOffset16 | 0x0018 (24) | offset to field `declaration_file` (id: 7)
+
+table (reflection.Object):
+ +0x3518 | 14 00 00 00 | SOffset32 | 0x00000014 (20) Loc: +0x3504 | offset to vtable
+ +0x351C | 80 00 00 00 | UOffset32 | 0x00000080 (128) Loc: +0x359C | offset to field `name` (string)
+ +0x3520 | 74 00 00 00 | UOffset32 | 0x00000074 (116) Loc: +0x3594 | offset to field `fields` (vector)
+ +0x3524 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `minalign` (Int)
+ +0x3528 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x3538 | offset to field `attributes` (vector)
+ +0x352C | 08 00 00 00 | UOffset32 | 0x00000008 (8) Loc: +0x3534 | offset to field `documentation` (vector)
+ +0x3530 | 30 02 00 00 | UOffset32 | 0x00000230 (560) Loc: +0x3760 | offset to field `declaration_file` (string)
+
+vector (reflection.Object.documentation):
+ +0x3534 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Object.attributes):
+ +0x3538 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x353C | 30 00 00 00 | UOffset32 | 0x00000030 (48) Loc: +0x356C | offset to table[0]
+ +0x3540 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x3544 | offset to table[1]
+
+table (reflection.KeyValue):
+ +0x3544 | E0 FF FF FF | SOffset32 | 0xFFFFFFE0 (-32) Loc: +0x3564 | offset to vtable
+ +0x3548 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x3558 | offset to field `key` (string)
+ +0x354C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x3550 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x3550 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x3554 | 30 | char[1] | 0 | string literal
+ +0x3555 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x3556 | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x3558 | 07 00 00 00 | uint32_t | 0x00000007 (7) | length of string
+ +0x355C | 70 72 69 76 61 74 65 | char[7] | private | string literal
+ +0x3563 | 00 | char | 0x00 (0) | string terminator
+
+vtable (reflection.KeyValue):
+ +0x3564 | 08 00 | uint16_t | 0x0008 (8) | size of this vtable
+ +0x3566 | 0C 00 | uint16_t | 0x000C (12) | size of referring table
+ +0x3568 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `key` (id: 0)
+ +0x356A | 08 00 | VOffset16 | 0x0008 (8) | offset to field `value` (id: 1)
+
+table (reflection.KeyValue):
+ +0x356C | 08 00 00 00 | SOffset32 | 0x00000008 (8) Loc: +0x3564 | offset to vtable
+ +0x3570 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x3580 | offset to field `key` (string)
+ +0x3574 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x3578 | offset to field `value` (string)
+
+string (reflection.KeyValue.value):
+ +0x3578 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x357C | 30 | char[1] | 0 | string literal
+ +0x357D | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x357E | 00 00 | uint8_t[2] | .. | padding
+
+string (reflection.KeyValue.key):
+ +0x3580 | 0E 00 00 00 | uint32_t | 0x0000000E (14) | length of string
+ +0x3584 | 63 73 68 61 72 70 5F 70 | char[14] | csharp_p | string literal
+ +0x358C | 61 72 74 69 61 6C | | artial
+ +0x3592 | 00 | char | 0x00 (0) | string terminator
+
+vector (reflection.Object.fields):
+ +0x3594 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x3598 | 4C 00 00 00 | UOffset32 | 0x0000004C (76) Loc: +0x35E4 | offset to table[0]
+
+string (reflection.Object.name):
+ +0x359C | 26 00 00 00 | uint32_t | 0x00000026 (38) | length of string
+ +0x35A0 | 4D 79 47 61 6D 65 2E 45 | char[38] | MyGame.E | string literal
+ +0x35A8 | 78 61 6D 70 6C 65 2E 54 | | xample.T
+ +0x35B0 | 65 73 74 53 69 6D 70 6C | | estSimpl
+ +0x35B8 | 65 54 61 62 6C 65 57 69 | | eTableWi
+ +0x35C0 | 74 68 45 6E 75 6D | | thEnum
+ +0x35C6 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x35C7 | 00 00 00 | uint8_t[3] | ... | padding
+
+vtable (reflection.Field):
+ +0x35CA | 1A 00 | uint16_t | 0x001A (26) | size of this vtable
+ +0x35CC | 1C 00 | uint16_t | 0x001C (28) | size of referring table
+ +0x35CE | 08 00 | VOffset16 | 0x0008 (8) | offset to field `name` (id: 0)
+ +0x35D0 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `type` (id: 1)
+ +0x35D2 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `id` (id: 2) <defaults to 0> (UShort)
+ +0x35D4 | 06 00 | VOffset16 | 0x0006 (6) | offset to field `offset` (id: 3)
+ +0x35D6 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `default_integer` (id: 4)
+ +0x35D8 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_real` (id: 5) <defaults to 0.000000> (Double)
+ +0x35DA | 00 00 | VOffset16 | 0x0000 (0) | offset to field `deprecated` (id: 6) <defaults to 0> (Bool)
+ +0x35DC | 00 00 | VOffset16 | 0x0000 (0) | offset to field `required` (id: 7) <defaults to 0> (Bool)
+ +0x35DE | 00 00 | VOffset16 | 0x0000 (0) | offset to field `key` (id: 8) <defaults to 0> (Bool)
+ +0x35E0 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `attributes` (id: 9) <null> (Vector)
+ +0x35E2 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `documentation` (id: 10)
+
+table (reflection.Field):
+ +0x35E4 | 1A 00 00 00 | SOffset32 | 0x0000001A (26) Loc: +0x35CA | offset to vtable
+ +0x35E8 | 00 00 | uint8_t[2] | .. | padding
+ +0x35EA | 04 00 | uint16_t | 0x0004 (4) | table field `offset` (UShort)
+ +0x35EC | 3C 00 00 00 | UOffset32 | 0x0000003C (60) Loc: +0x3628 | offset to field `name` (string)
+ +0x35F0 | 24 00 00 00 | UOffset32 | 0x00000024 (36) Loc: +0x3614 | offset to field `type` (table)
+ +0x35F4 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x3600 | offset to field `documentation` (vector)
+ +0x35F8 | 02 00 00 00 00 00 00 00 | int64_t | 0x0000000000000002 (2) | table field `default_integer` (Long)
+
+vector (reflection.Field.documentation):
+ +0x3600 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vtable (reflection.Type):
+ +0x3604 | 10 00 | uint16_t | 0x0010 (16) | size of this vtable
+ +0x3606 | 14 00 | uint16_t | 0x0014 (20) | size of referring table
+ +0x3608 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `base_type` (id: 0)
+ +0x360A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `element` (id: 1) <defaults to 0> (Byte)
+ +0x360C | 08 00 | VOffset16 | 0x0008 (8) | offset to field `index` (id: 2)
+ +0x360E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `fixed_length` (id: 3) <defaults to 0> (UShort)
+ +0x3610 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `base_size` (id: 4)
+ +0x3612 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `element_size` (id: 5)
+
+table (reflection.Type):
+ +0x3614 | 10 00 00 00 | SOffset32 | 0x00000010 (16) Loc: +0x3604 | offset to vtable
+ +0x3618 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x361B | 04 | uint8_t | 0x04 (4) | table field `base_type` (Byte)
+ +0x361C | 03 00 00 00 | uint32_t | 0x00000003 (3) | table field `index` (Int)
+ +0x3620 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x3624 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x3628 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x362C | 63 6F 6C 6F 72 | char[5] | color | string literal
+ +0x3631 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x3632 | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Object):
+ +0x3634 | 54 FD FF FF | SOffset32 | 0xFFFFFD54 (-684) Loc: +0x38E0 | offset to vtable
+ +0x3638 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x363B | 01 | uint8_t | 0x01 (1) | table field `is_struct` (Bool)
+ +0x363C | 28 00 00 00 | UOffset32 | 0x00000028 (40) Loc: +0x3664 | offset to field `name` (string)
+ +0x3640 | 18 00 00 00 | UOffset32 | 0x00000018 (24) Loc: +0x3658 | offset to field `fields` (vector)
+ +0x3644 | 02 00 00 00 | uint32_t | 0x00000002 (2) | table field `minalign` (Int)
+ +0x3648 | 04 00 00 00 | uint32_t | 0x00000004 (4) | table field `bytesize` (Int)
+ +0x364C | 08 00 00 00 | UOffset32 | 0x00000008 (8) Loc: +0x3654 | offset to field `documentation` (vector)
+ +0x3650 | 10 01 00 00 | UOffset32 | 0x00000110 (272) Loc: +0x3760 | offset to field `declaration_file` (string)
+
+vector (reflection.Object.documentation):
+ +0x3654 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Object.fields):
+ +0x3658 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x365C | 74 00 00 00 | UOffset32 | 0x00000074 (116) Loc: +0x36D0 | offset to table[0]
+ +0x3660 | 3C 00 00 00 | UOffset32 | 0x0000003C (60) Loc: +0x369C | offset to table[1]
+
+string (reflection.Object.name):
+ +0x3664 | 13 00 00 00 | uint32_t | 0x00000013 (19) | length of string
+ +0x3668 | 4D 79 47 61 6D 65 2E 45 | char[19] | MyGame.E | string literal
+ +0x3670 | 78 61 6D 70 6C 65 2E 54 | | xample.T
+ +0x3678 | 65 73 74 | | est
+ +0x367B | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x367C | 00 00 | uint8_t[2] | .. | padding
+
+vtable (reflection.Field):
+ +0x367E | 1E 00 | uint16_t | 0x001E (30) | size of this vtable
+ +0x3680 | 18 00 | uint16_t | 0x0018 (24) | size of referring table
+ +0x3682 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `name` (id: 0)
+ +0x3684 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `type` (id: 1)
+ +0x3686 | 06 00 | VOffset16 | 0x0006 (6) | offset to field `id` (id: 2)
+ +0x3688 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `offset` (id: 3)
+ +0x368A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_integer` (id: 4) <defaults to 0> (Long)
+ +0x368C | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_real` (id: 5) <defaults to 0.000000> (Double)
+ +0x368E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `deprecated` (id: 6) <defaults to 0> (Bool)
+ +0x3690 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `required` (id: 7) <defaults to 0> (Bool)
+ +0x3692 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `key` (id: 8) <defaults to 0> (Bool)
+ +0x3694 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `attributes` (id: 9) <null> (Vector)
+ +0x3696 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `documentation` (id: 10)
+ +0x3698 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `optional` (id: 11) <defaults to 0> (Bool)
+ +0x369A | 0A 00 | VOffset16 | 0x000A (10) | offset to field `padding` (id: 12)
+
+table (reflection.Field):
+ +0x369C | 1E 00 00 00 | SOffset32 | 0x0000001E (30) Loc: +0x367E | offset to vtable
+ +0x36A0 | 00 00 | uint8_t[2] | .. | padding
+ +0x36A2 | 01 00 | uint16_t | 0x0001 (1) | table field `id` (UShort)
+ +0x36A4 | 02 00 | uint16_t | 0x0002 (2) | table field `offset` (UShort)
+ +0x36A6 | 01 00 | uint16_t | 0x0001 (1) | table field `padding` (UShort)
+ +0x36A8 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x36C8 | offset to field `name` (string)
+ +0x36AC | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x36B8 | offset to field `type` (table)
+ +0x36B0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x36B4 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x36B4 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x36B8 | D4 FF FF FF | SOffset32 | 0xFFFFFFD4 (-44) Loc: +0x36E4 | offset to vtable
+ +0x36BC | 00 00 00 | uint8_t[3] | ... | padding
+ +0x36BF | 03 | uint8_t | 0x03 (3) | table field `base_type` (Byte)
+ +0x36C0 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `base_size` (UInt)
+ +0x36C4 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x36C8 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x36CC | 62 | char[1] | b | string literal
+ +0x36CD | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x36CE | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Field):
+ +0x36D0 | 62 FD FF FF | SOffset32 | 0xFFFFFD62 (-670) Loc: +0x396E | offset to vtable
+ +0x36D4 | 30 00 00 00 | UOffset32 | 0x00000030 (48) Loc: +0x3704 | offset to field `name` (string)
+ +0x36D8 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x36F4 | offset to field `type` (table)
+ +0x36DC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x36E0 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x36E0 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vtable (reflection.Type):
+ +0x36E4 | 10 00 | uint16_t | 0x0010 (16) | size of this vtable
+ +0x36E6 | 10 00 | uint16_t | 0x0010 (16) | size of referring table
+ +0x36E8 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `base_type` (id: 0)
+ +0x36EA | 00 00 | VOffset16 | 0x0000 (0) | offset to field `element` (id: 1) <defaults to 0> (Byte)
+ +0x36EC | 00 00 | VOffset16 | 0x0000 (0) | offset to field `index` (id: 2) <defaults to -1> (Int)
+ +0x36EE | 00 00 | VOffset16 | 0x0000 (0) | offset to field `fixed_length` (id: 3) <defaults to 0> (UShort)
+ +0x36F0 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `base_size` (id: 4)
+ +0x36F2 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `element_size` (id: 5)
+
+table (reflection.Type):
+ +0x36F4 | 10 00 00 00 | SOffset32 | 0x00000010 (16) Loc: +0x36E4 | offset to vtable
+ +0x36F8 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x36FB | 05 | uint8_t | 0x05 (5) | table field `base_type` (Byte)
+ +0x36FC | 02 00 00 00 | uint32_t | 0x00000002 (2) | table field `base_size` (UInt)
+ +0x3700 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x3704 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x3708 | 61 | char[1] | a | string literal
+ +0x3709 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x370A | 00 00 | uint8_t[2] | .. | padding
+
+table (reflection.Object):
+ +0x370C | E4 FE FF FF | SOffset32 | 0xFFFFFEE4 (-284) Loc: +0x3828 | offset to vtable
+ +0x3710 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x372C | offset to field `name` (string)
+ +0x3714 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x3728 | offset to field `fields` (vector)
+ +0x3718 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `minalign` (Int)
+ +0x371C | 08 00 00 00 | UOffset32 | 0x00000008 (8) Loc: +0x3724 | offset to field `documentation` (vector)
+ +0x3720 | 40 00 00 00 | UOffset32 | 0x00000040 (64) Loc: +0x3760 | offset to field `declaration_file` (string)
+
+vector (reflection.Object.documentation):
+ +0x3724 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Object.fields):
+ +0x3728 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+string (reflection.Object.name):
+ +0x372C | 17 00 00 00 | uint32_t | 0x00000017 (23) | length of string
+ +0x3730 | 4D 79 47 61 6D 65 2E 45 | char[23] | MyGame.E | string literal
+ +0x3738 | 78 61 6D 70 6C 65 32 2E | | xample2.
+ +0x3740 | 4D 6F 6E 73 74 65 72 | | Monster
+ +0x3747 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Object):
+ +0x3748 | 20 FF FF FF | SOffset32 | 0xFFFFFF20 (-224) Loc: +0x3828 | offset to vtable
+ +0x374C | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x3780 | offset to field `name` (string)
+ +0x3750 | 2C 00 00 00 | UOffset32 | 0x0000002C (44) Loc: +0x377C | offset to field `fields` (vector)
+ +0x3754 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `minalign` (Int)
+ +0x3758 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x3778 | offset to field `documentation` (vector)
+ +0x375C | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x3760 | offset to field `declaration_file` (string)
+
+string (reflection.Object.declaration_file):
+ +0x3760 | 12 00 00 00 | uint32_t | 0x00000012 (18) | length of string
+ +0x3764 | 2F 2F 6D 6F 6E 73 74 65 | char[18] | //monste | string literal
+ +0x376C | 72 5F 74 65 73 74 2E 66 | | r_test.f
+ +0x3774 | 62 73 | | bs
+ +0x3776 | 00 | char | 0x00 (0) | string terminator
+
+vector (reflection.Object.documentation):
+ +0x3778 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Object.fields):
+ +0x377C | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+string (reflection.Object.name):
+ +0x3780 | 18 00 00 00 | uint32_t | 0x00000018 (24) | length of string
+ +0x3784 | 4D 79 47 61 6D 65 2E 49 | char[24] | MyGame.I | string literal
+ +0x378C | 6E 50 61 72 65 6E 74 4E | | nParentN
+ +0x3794 | 61 6D 65 73 70 61 63 65 | | amespace
+ +0x379C | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x379D | 00 00 00 | uint8_t[3] | ... | padding
+
+table (reflection.Object):
+ +0x37A0 | 78 FF FF FF | SOffset32 | 0xFFFFFF78 (-136) Loc: +0x3828 | offset to vtable
+ +0x37A4 | 48 00 00 00 | UOffset32 | 0x00000048 (72) Loc: +0x37EC | offset to field `name` (string)
+ +0x37A8 | 3C 00 00 00 | UOffset32 | 0x0000003C (60) Loc: +0x37E4 | offset to field `fields` (vector)
+ +0x37AC | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `minalign` (Int)
+ +0x37B0 | 30 00 00 00 | UOffset32 | 0x00000030 (48) Loc: +0x37E0 | offset to field `documentation` (vector)
+ +0x37B4 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x37B8 | offset to field `declaration_file` (string)
+
+string (reflection.Object.declaration_file):
+ +0x37B8 | 20 00 00 00 | uint32_t | 0x00000020 (32) | length of string
+ +0x37BC | 2F 2F 69 6E 63 6C 75 64 | char[32] | //includ | string literal
+ +0x37C4 | 65 5F 74 65 73 74 2F 69 | | e_test/i
+ +0x37CC | 6E 63 6C 75 64 65 5F 74 | | nclude_t
+ +0x37D4 | 65 73 74 31 2E 66 62 73 | | est1.fbs
+ +0x37DC | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x37DD | 00 00 00 | uint8_t[3] | ... | padding
+
+vector (reflection.Object.documentation):
+ +0x37E0 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Object.fields):
+ +0x37E4 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x37E8 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x37F8 | offset to table[0]
+
+string (reflection.Object.name):
+ +0x37EC | 06 00 00 00 | uint32_t | 0x00000006 (6) | length of string
+ +0x37F0 | 54 61 62 6C 65 41 | char[6] | TableA | string literal
+ +0x37F6 | 00 | char | 0x00 (0) | string terminator
+
+table (reflection.Field):
+ +0x37F8 | 74 FF FF FF | SOffset32 | 0xFFFFFF74 (-140) Loc: +0x3884 | offset to vtable
+ +0x37FC | 00 | uint8_t[1] | . | padding
+ +0x37FD | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x37FE | 04 00 | uint16_t | 0x0004 (4) | table field `offset` (UShort)
+ +0x3800 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x3820 | offset to field `name` (string)
+ +0x3804 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x3810 | offset to field `type` (table)
+ +0x3808 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x380C | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x380C | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+table (reflection.Type):
+ +0x3810 | 58 FF FF FF | SOffset32 | 0xFFFFFF58 (-168) Loc: +0x38B8 | offset to vtable
+ +0x3814 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x3817 | 0F | uint8_t | 0x0F (15) | table field `base_type` (Byte)
+ +0x3818 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | table field `index` (Int)
+ +0x381C | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x3820 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x3824 | 62 | char[1] | b | string literal
+ +0x3825 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x3826 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (reflection.Object):
+ +0x3828 | 14 00 | uint16_t | 0x0014 (20) | size of this vtable
+ +0x382A | 18 00 | uint16_t | 0x0018 (24) | size of referring table
+ +0x382C | 04 00 | VOffset16 | 0x0004 (4) | offset to field `name` (id: 0)
+ +0x382E | 08 00 | VOffset16 | 0x0008 (8) | offset to field `fields` (id: 1)
+ +0x3830 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `is_struct` (id: 2) <defaults to 0> (Bool)
+ +0x3832 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `minalign` (id: 3)
+ +0x3834 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `bytesize` (id: 4) <defaults to 0> (Int)
+ +0x3836 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `attributes` (id: 5) <null> (Vector)
+ +0x3838 | 10 00 | VOffset16 | 0x0010 (16) | offset to field `documentation` (id: 6)
+ +0x383A | 14 00 | VOffset16 | 0x0014 (20) | offset to field `declaration_file` (id: 7)
+
+table (reflection.Object):
+ +0x383C | 14 00 00 00 | SOffset32 | 0x00000014 (20) Loc: +0x3828 | offset to vtable
+ +0x3840 | 20 00 00 00 | UOffset32 | 0x00000020 (32) Loc: +0x3860 | offset to field `name` (string)
+ +0x3844 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x3858 | offset to field `fields` (vector)
+ +0x3848 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `minalign` (Int)
+ +0x384C | 08 00 00 00 | UOffset32 | 0x00000008 (8) Loc: +0x3854 | offset to field `documentation` (vector)
+ +0x3850 | C4 00 00 00 | UOffset32 | 0x000000C4 (196) Loc: +0x3914 | offset to field `declaration_file` (string)
+
+vector (reflection.Object.documentation):
+ +0x3854 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Object.fields):
+ +0x3858 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x385C | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x38A0 | offset to table[0]
+
+string (reflection.Object.name):
+ +0x3860 | 1C 00 00 00 | uint32_t | 0x0000001C (28) | length of string
+ +0x3864 | 4D 79 47 61 6D 65 2E 4F | char[28] | MyGame.O | string literal
+ +0x386C | 74 68 65 72 4E 61 6D 65 | | therName
+ +0x3874 | 53 70 61 63 65 2E 54 61 | | Space.Ta
+ +0x387C | 62 6C 65 42 | | bleB
+ +0x3880 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x3881 | 00 00 00 | uint8_t[3] | ... | padding
+
+vtable (reflection.Field):
+ +0x3884 | 1C 00 | uint16_t | 0x001C (28) | size of this vtable
+ +0x3886 | 14 00 | uint16_t | 0x0014 (20) | size of referring table
+ +0x3888 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `name` (id: 0)
+ +0x388A | 0C 00 | VOffset16 | 0x000C (12) | offset to field `type` (id: 1)
+ +0x388C | 00 00 | VOffset16 | 0x0000 (0) | offset to field `id` (id: 2) <defaults to 0> (UShort)
+ +0x388E | 06 00 | VOffset16 | 0x0006 (6) | offset to field `offset` (id: 3)
+ +0x3890 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_integer` (id: 4) <defaults to 0> (Long)
+ +0x3892 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_real` (id: 5) <defaults to 0.000000> (Double)
+ +0x3894 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `deprecated` (id: 6) <defaults to 0> (Bool)
+ +0x3896 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `required` (id: 7) <defaults to 0> (Bool)
+ +0x3898 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `key` (id: 8) <defaults to 0> (Bool)
+ +0x389A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `attributes` (id: 9) <null> (Vector)
+ +0x389C | 10 00 | VOffset16 | 0x0010 (16) | offset to field `documentation` (id: 10)
+ +0x389E | 05 00 | VOffset16 | 0x0005 (5) | offset to field `optional` (id: 11)
+
+table (reflection.Field):
+ +0x38A0 | 1C 00 00 00 | SOffset32 | 0x0000001C (28) Loc: +0x3884 | offset to vtable
+ +0x38A4 | 00 | uint8_t[1] | . | padding
+ +0x38A5 | 01 | uint8_t | 0x01 (1) | table field `optional` (Bool)
+ +0x38A6 | 04 00 | uint16_t | 0x0004 (4) | table field `offset` (UShort)
+ +0x38A8 | 30 00 00 00 | UOffset32 | 0x00000030 (48) Loc: +0x38D8 | offset to field `name` (string)
+ +0x38AC | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x38C8 | offset to field `type` (table)
+ +0x38B0 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x38B4 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x38B4 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vtable (reflection.Type):
+ +0x38B8 | 10 00 | uint16_t | 0x0010 (16) | size of this vtable
+ +0x38BA | 10 00 | uint16_t | 0x0010 (16) | size of referring table
+ +0x38BC | 07 00 | VOffset16 | 0x0007 (7) | offset to field `base_type` (id: 0)
+ +0x38BE | 00 00 | VOffset16 | 0x0000 (0) | offset to field `element` (id: 1) <defaults to 0> (Byte)
+ +0x38C0 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `index` (id: 2)
+ +0x38C2 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `fixed_length` (id: 3) <defaults to 0> (UShort)
+ +0x38C4 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `base_size` (id: 4) <defaults to 4> (UInt)
+ +0x38C6 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `element_size` (id: 5)
+
+table (reflection.Type):
+ +0x38C8 | 10 00 00 00 | SOffset32 | 0x00000010 (16) Loc: +0x38B8 | offset to vtable
+ +0x38CC | 00 00 00 | uint8_t[3] | ... | padding
+ +0x38CF | 0F | uint8_t | 0x0F (15) | table field `base_type` (Byte)
+ +0x38D0 | 0E 00 00 00 | uint32_t | 0x0000000E (14) | table field `index` (Int)
+ +0x38D4 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x38D8 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x38DC | 61 | char[1] | a | string literal
+ +0x38DD | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x38DE | 00 00 | uint8_t[2] | .. | padding
+
+vtable (reflection.Object):
+ +0x38E0 | 14 00 | uint16_t | 0x0014 (20) | size of this vtable
+ +0x38E2 | 20 00 | uint16_t | 0x0020 (32) | size of referring table
+ +0x38E4 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `name` (id: 0)
+ +0x38E6 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `fields` (id: 1)
+ +0x38E8 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `is_struct` (id: 2)
+ +0x38EA | 10 00 | VOffset16 | 0x0010 (16) | offset to field `minalign` (id: 3)
+ +0x38EC | 14 00 | VOffset16 | 0x0014 (20) | offset to field `bytesize` (id: 4)
+ +0x38EE | 00 00 | VOffset16 | 0x0000 (0) | offset to field `attributes` (id: 5) <null> (Vector)
+ +0x38F0 | 18 00 | VOffset16 | 0x0018 (24) | offset to field `documentation` (id: 6)
+ +0x38F2 | 1C 00 | VOffset16 | 0x001C (28) | offset to field `declaration_file` (id: 7)
+
+table (reflection.Object):
+ +0x38F4 | 14 00 00 00 | SOffset32 | 0x00000014 (20) Loc: +0x38E0 | offset to vtable
+ +0x38F8 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x38FB | 01 | uint8_t | 0x01 (1) | table field `is_struct` (Bool)
+ +0x38FC | 50 00 00 00 | UOffset32 | 0x00000050 (80) Loc: +0x394C | offset to field `name` (string)
+ +0x3900 | 44 00 00 00 | UOffset32 | 0x00000044 (68) Loc: +0x3944 | offset to field `fields` (vector)
+ +0x3904 | 04 00 00 00 | uint32_t | 0x00000004 (4) | table field `minalign` (Int)
+ +0x3908 | 04 00 00 00 | uint32_t | 0x00000004 (4) | table field `bytesize` (Int)
+ +0x390C | 34 00 00 00 | UOffset32 | 0x00000034 (52) Loc: +0x3940 | offset to field `documentation` (vector)
+ +0x3910 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x3914 | offset to field `declaration_file` (string)
+
+string (reflection.Object.declaration_file):
+ +0x3914 | 24 00 00 00 | uint32_t | 0x00000024 (36) | length of string
+ +0x3918 | 2F 2F 69 6E 63 6C 75 64 | char[36] | //includ | string literal
+ +0x3920 | 65 5F 74 65 73 74 2F 73 | | e_test/s
+ +0x3928 | 75 62 2F 69 6E 63 6C 75 | | ub/inclu
+ +0x3930 | 64 65 5F 74 65 73 74 32 | | de_test2
+ +0x3938 | 2E 66 62 73 | | .fbs
+ +0x393C | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x393D | 00 00 00 | uint8_t[3] | ... | padding
+
+vector (reflection.Object.documentation):
+ +0x3940 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vector (reflection.Object.fields):
+ +0x3944 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of vector (# items)
+ +0x3948 | 40 00 00 00 | UOffset32 | 0x00000040 (64) Loc: +0x3988 | offset to table[0]
+
+string (reflection.Object.name):
+ +0x394C | 1C 00 00 00 | uint32_t | 0x0000001C (28) | length of string
+ +0x3950 | 4D 79 47 61 6D 65 2E 4F | char[28] | MyGame.O | string literal
+ +0x3958 | 74 68 65 72 4E 61 6D 65 | | therName
+ +0x3960 | 53 70 61 63 65 2E 55 6E | | Space.Un
+ +0x3968 | 75 73 65 64 | | used
+ +0x396C | 00 | char | 0x00 (0) | string terminator
+
+vtable (reflection.Field):
+ +0x396E | 1A 00 | uint16_t | 0x001A (26) | size of this vtable
+ +0x3970 | 10 00 | uint16_t | 0x0010 (16) | size of referring table
+ +0x3972 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `name` (id: 0)
+ +0x3974 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `type` (id: 1)
+ +0x3976 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `id` (id: 2) <defaults to 0> (UShort)
+ +0x3978 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `offset` (id: 3) <defaults to 0> (UShort)
+ +0x397A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_integer` (id: 4) <defaults to 0> (Long)
+ +0x397C | 00 00 | VOffset16 | 0x0000 (0) | offset to field `default_real` (id: 5) <defaults to 0.000000> (Double)
+ +0x397E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `deprecated` (id: 6) <defaults to 0> (Bool)
+ +0x3980 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `required` (id: 7) <defaults to 0> (Bool)
+ +0x3982 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `key` (id: 8) <defaults to 0> (Bool)
+ +0x3984 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `attributes` (id: 9) <null> (Vector)
+ +0x3986 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `documentation` (id: 10)
+
+table (reflection.Field):
+ +0x3988 | 1A 00 00 00 | SOffset32 | 0x0000001A (26) Loc: +0x396E | offset to vtable
+ +0x398C | 2C 00 00 00 | UOffset32 | 0x0000002C (44) Loc: +0x39B8 | offset to field `name` (string)
+ +0x3990 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: +0x39AC | offset to field `type` (table)
+ +0x3994 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x3998 | offset to field `documentation` (vector)
+
+vector (reflection.Field.documentation):
+ +0x3998 | 00 00 00 00 | uint32_t | 0x00000000 (0) | length of vector (# items)
+
+vtable (reflection.Type):
+ +0x399C | 10 00 | uint16_t | 0x0010 (16) | size of this vtable
+ +0x399E | 0C 00 | uint16_t | 0x000C (12) | size of referring table
+ +0x39A0 | 07 00 | VOffset16 | 0x0007 (7) | offset to field `base_type` (id: 0)
+ +0x39A2 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `element` (id: 1) <defaults to 0> (Byte)
+ +0x39A4 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `index` (id: 2) <defaults to -1> (Int)
+ +0x39A6 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `fixed_length` (id: 3) <defaults to 0> (UShort)
+ +0x39A8 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `base_size` (id: 4) <defaults to 4> (UInt)
+ +0x39AA | 08 00 | VOffset16 | 0x0008 (8) | offset to field `element_size` (id: 5)
+
+table (reflection.Type):
+ +0x39AC | 10 00 00 00 | SOffset32 | 0x00000010 (16) Loc: +0x399C | offset to vtable
+ +0x39B0 | 00 00 00 | uint8_t[3] | ... | padding
+ +0x39B3 | 07 | uint8_t | 0x07 (7) | table field `base_type` (Byte)
+ +0x39B4 | 01 00 00 00 | uint32_t | 0x00000001 (1) | table field `element_size` (UInt)
+
+string (reflection.Field.name):
+ +0x39B8 | 01 00 00 00 | uint32_t | 0x00000001 (1) | length of string
+ +0x39BC | 61 | char[1] | a | string literal
+ +0x39BD | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x39BE | 00 00 | uint8_t[2] | .. | padding
diff --git a/tests/monster_test.bfbs b/tests/monster_test.bfbs
index 0eb130a..d389aab 100644
--- a/tests/monster_test.bfbs
+++ b/tests/monster_test.bfbs
Binary files differ
diff --git a/tests/monster_test.cpp b/tests/monster_test.cpp
new file mode 100644
index 0000000..4fc9e14
--- /dev/null
+++ b/tests/monster_test.cpp
@@ -0,0 +1,845 @@
+#include "monster_test.h"
+
+#include <vector>
+
+#include "flatbuffers/flatbuffer_builder.h"
+#include "flatbuffers/idl.h"
+#include "flatbuffers/registry.h"
+#include "flatbuffers/verifier.h"
+#include "is_quiet_nan.h"
+#include "monster_extra_generated.h"
+#include "monster_test_generated.h"
+#include "test_assert.h"
+
+namespace flatbuffers {
+namespace tests {
+
+// Shortcuts for the infinity.
+static const auto infinity_f = std::numeric_limits<float>::infinity();
+static const auto infinity_d = std::numeric_limits<double>::infinity();
+
+using namespace MyGame::Example;
+
+// example of how to build up a serialized buffer algorithmically:
+flatbuffers::DetachedBuffer CreateFlatBufferTest(std::string &buffer) {
+ flatbuffers::FlatBufferBuilder builder;
+
+ auto vec = Vec3(1, 2, 3, 0, Color_Red, Test(10, 20));
+
+ auto name = builder.CreateString("MyMonster");
+
+ // Use the initializer_list specialization of CreateVector.
+ auto inventory =
+ builder.CreateVector<uint8_t>({ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
+
+ // Alternatively, create the vector first, and fill in data later:
+ // unsigned char *inv_buf = nullptr;
+ // auto inventory = builder.CreateUninitializedVector<unsigned char>(
+ // 10, &inv_buf);
+ // memcpy(inv_buf, inv_data, 10);
+
+ Test tests[] = { Test(10, 20), Test(30, 40) };
+ auto testv = builder.CreateVectorOfStructs(tests, 2);
+
+ // Create a vector of structures from a lambda.
+ auto testv2 = builder.CreateVectorOfStructs<Test>(
+ 2, [&](size_t i, Test *s) -> void { *s = tests[i]; });
+
+ // create monster with very few fields set:
+ // (same functionality as CreateMonster below, but sets fields manually)
+ flatbuffers::Offset<Monster> mlocs[3];
+ auto fred = builder.CreateString("Fred");
+ auto barney = builder.CreateString("Barney");
+ auto wilma = builder.CreateString("Wilma");
+ MonsterBuilder mb1(builder);
+ mb1.add_name(fred);
+ mlocs[0] = mb1.Finish();
+ MonsterBuilder mb2(builder);
+ mb2.add_name(barney);
+ mb2.add_hp(1000);
+ mlocs[1] = mb2.Finish();
+ MonsterBuilder mb3(builder);
+ mb3.add_name(wilma);
+ mlocs[2] = mb3.Finish();
+
+ // Create an array of strings. Also test string pooling, and lambdas.
+ auto vecofstrings =
+ builder.CreateVector<flatbuffers::Offset<flatbuffers::String>>(
+ 4,
+ [](size_t i, flatbuffers::FlatBufferBuilder *b)
+ -> flatbuffers::Offset<flatbuffers::String> {
+ static const char *names[] = { "bob", "fred", "bob", "fred" };
+ return b->CreateSharedString(names[i]);
+ },
+ &builder);
+
+ // Creating vectors of strings in one convenient call.
+ std::vector<std::string> names2;
+ names2.push_back("jane");
+ names2.push_back("mary");
+ auto vecofstrings2 = builder.CreateVectorOfStrings(names2);
+
+ // Creating vectors from types that are different from std::string
+ std::vector<const char *> names3;
+ names3.push_back("foo");
+ names3.push_back("bar");
+ builder.CreateVectorOfStrings(names3); // Also an accepted type
+
+#ifdef FLATBUFFERS_HAS_STRING_VIEW
+ std::vector<flatbuffers::string_view> names4;
+ names3.push_back("baz");
+ names3.push_back("quux");
+ builder.CreateVectorOfStrings(names4); // Also an accepted type
+#endif
+
+ // Make sure the template deduces an initializer as std::vector<std::string>
+ builder.CreateVectorOfStrings({ "hello", "world" });
+
+ // Create many vectors of strings
+ std::vector<std::string> manyNames;
+ for (auto i = 0; i < 100; i++) { manyNames.push_back("john_doe"); }
+ auto manyNamesVec = builder.CreateVectorOfStrings(manyNames);
+ TEST_EQ(false, manyNamesVec.IsNull());
+ auto manyNamesVec2 =
+ builder.CreateVectorOfStrings(manyNames.cbegin(), manyNames.cend());
+ TEST_EQ(false, manyNamesVec2.IsNull());
+
+ // Create an array of sorted tables, can be used with binary search when read:
+ auto vecoftables = builder.CreateVectorOfSortedTables(mlocs, 3);
+
+ // Create an array of sorted structs,
+ // can be used with binary search when read:
+ std::vector<Ability> abilities;
+ abilities.push_back(Ability(4, 40));
+ abilities.push_back(Ability(3, 30));
+ abilities.push_back(Ability(2, 20));
+ abilities.push_back(Ability(0, 0));
+ auto vecofstructs = builder.CreateVectorOfSortedStructs(&abilities);
+
+ flatbuffers::Offset<Stat> mlocs_stats[1];
+ auto miss = builder.CreateString("miss");
+ StatBuilder mb_miss(builder);
+ mb_miss.add_id(miss);
+ mb_miss.add_val(0);
+ mb_miss.add_count(0); // key
+ mlocs_stats[0] = mb_miss.Finish();
+ auto vec_of_stats = builder.CreateVectorOfSortedTables(mlocs_stats, 1);
+
+ // Create a nested FlatBuffer.
+ // Nested FlatBuffers are stored in a ubyte vector, which can be convenient
+ // since they can be memcpy'd around much easier than other FlatBuffer
+ // values. They have little overhead compared to storing the table directly.
+ // As a test, create a mostly empty Monster buffer:
+ flatbuffers::FlatBufferBuilder nested_builder;
+ auto nmloc = CreateMonster(nested_builder, nullptr, 0, 0,
+ nested_builder.CreateString("NestedMonster"));
+ FinishMonsterBuffer(nested_builder, nmloc);
+ // Now we can store the buffer in the parent. Note that by default, vectors
+ // are only aligned to their elements or size field, so in this case if the
+ // buffer contains 64-bit elements, they may not be correctly aligned. We fix
+ // that with:
+ builder.ForceVectorAlignment(nested_builder.GetSize(), sizeof(uint8_t),
+ nested_builder.GetBufferMinAlignment());
+ // If for whatever reason you don't have the nested_builder available, you
+ // can substitute flatbuffers::largest_scalar_t (64-bit) for the alignment, or
+ // the largest force_align value in your schema if you're using it.
+ auto nested_flatbuffer_vector = builder.CreateVector(
+ nested_builder.GetBufferPointer(), nested_builder.GetSize());
+
+ // Test a nested FlexBuffer:
+ flexbuffers::Builder flexbuild;
+ flexbuild.Int(1234);
+ flexbuild.Finish();
+ auto flex = builder.CreateVector(flexbuild.GetBuffer());
+ // Test vector of enums.
+ Color colors[] = { Color_Blue, Color_Green };
+ // We use this special creation function because we have an array of
+ // pre-C++11 (enum class) enums whose size likely is int, yet its declared
+ // type in the schema is byte.
+ auto vecofcolors = builder.CreateVectorScalarCast<uint8_t, Color>(colors, 2);
+
+ // shortcut for creating monster with all fields set:
+ auto mloc = CreateMonster(
+ builder, &vec, 150, 80, name, inventory, Color_Blue, Any_Monster,
+ mlocs[1].Union(), // Store a union.
+ testv, vecofstrings, vecoftables, 0, nested_flatbuffer_vector, 0, false,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 3.14159f, 3.0f, 0.0f, vecofstrings2,
+ vecofstructs, flex, testv2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ AnyUniqueAliases_NONE, 0, AnyAmbiguousAliases_NONE, 0, vecofcolors,
+ MyGame::Example::Race_None, 0, vec_of_stats);
+
+ FinishMonsterBuffer(builder, mloc);
+
+ // clang-format off
+ #ifdef FLATBUFFERS_TEST_VERBOSE
+ // print byte data for debugging:
+ auto p = builder.GetBufferPointer();
+ for (flatbuffers::uoffset_t i = 0; i < builder.GetSize(); i++)
+ printf("%d ", p[i]);
+ #endif
+ // clang-format on
+
+ // return the buffer for the caller to use.
+ auto bufferpointer =
+ reinterpret_cast<const char *>(builder.GetBufferPointer());
+ buffer.assign(bufferpointer, bufferpointer + builder.GetSize());
+
+ return builder.Release();
+}
+
+// example of accessing a buffer loaded in memory:
+void AccessFlatBufferTest(const uint8_t *flatbuf, size_t length, bool pooled) {
+ // First, verify the buffers integrity (optional)
+ flatbuffers::Verifier verifier(flatbuf, length);
+ std::vector<uint8_t> flex_reuse_tracker;
+ verifier.SetFlexReuseTracker(&flex_reuse_tracker);
+ TEST_EQ(VerifyMonsterBuffer(verifier), true);
+
+ // clang-format off
+ #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
+ std::vector<uint8_t> test_buff;
+ test_buff.resize(length * 2);
+ std::memcpy(&test_buff[0], flatbuf, length);
+ std::memcpy(&test_buff[length], flatbuf, length);
+
+ flatbuffers::Verifier verifier1(&test_buff[0], length);
+ TEST_EQ(VerifyMonsterBuffer(verifier1), true);
+ TEST_EQ(verifier1.GetComputedSize(), length);
+
+ flatbuffers::Verifier verifier2(&test_buff[length], length);
+ TEST_EQ(VerifyMonsterBuffer(verifier2), true);
+ TEST_EQ(verifier2.GetComputedSize(), length);
+ #endif
+ // clang-format on
+
+ TEST_EQ(strcmp(MonsterIdentifier(), "MONS"), 0);
+ TEST_EQ(MonsterBufferHasIdentifier(flatbuf), true);
+ TEST_EQ(strcmp(MonsterExtension(), "mon"), 0);
+
+ // Access the buffer from the root.
+ auto monster = GetMonster(flatbuf);
+
+ TEST_EQ(monster->hp(), 80);
+ TEST_EQ(monster->mana(), 150); // default
+ TEST_EQ_STR(monster->name()->c_str(), "MyMonster");
+ // Can't access the following field, it is deprecated in the schema,
+ // which means accessors are not generated:
+ // monster.friendly()
+
+ auto pos = monster->pos();
+ TEST_NOTNULL(pos);
+ TEST_EQ(pos->z(), 3);
+ TEST_EQ(pos->test3().a(), 10);
+ TEST_EQ(pos->test3().b(), 20);
+
+ auto inventory = monster->inventory();
+ TEST_EQ(VectorLength(inventory), 10UL); // Works even if inventory is null.
+ TEST_NOTNULL(inventory);
+ unsigned char inv_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+ // Check compatibilty of iterators with STL.
+ std::vector<unsigned char> inv_vec(inventory->begin(), inventory->end());
+ size_t n = 0;
+ for (auto it = inventory->begin(); it != inventory->end(); ++it, ++n) {
+ auto indx = it - inventory->begin();
+ TEST_EQ(*it, inv_vec.at(indx)); // Use bounds-check.
+ TEST_EQ(*it, inv_data[indx]);
+ }
+ TEST_EQ(n, inv_vec.size());
+
+ n = 0;
+ for (auto it = inventory->cbegin(); it != inventory->cend(); ++it, ++n) {
+ auto indx = it - inventory->cbegin();
+ TEST_EQ(*it, inv_vec.at(indx)); // Use bounds-check.
+ TEST_EQ(*it, inv_data[indx]);
+ }
+ TEST_EQ(n, inv_vec.size());
+
+ n = 0;
+ for (auto it = inventory->rbegin(); it != inventory->rend(); ++it, ++n) {
+ auto indx = inventory->rend() - it - 1;
+ TEST_EQ(*it, inv_vec.at(indx)); // Use bounds-check.
+ TEST_EQ(*it, inv_data[indx]);
+ }
+ TEST_EQ(n, inv_vec.size());
+
+ n = 0;
+ for (auto it = inventory->crbegin(); it != inventory->crend(); ++it, ++n) {
+ auto indx = inventory->crend() - it - 1;
+ TEST_EQ(*it, inv_vec.at(indx)); // Use bounds-check.
+ TEST_EQ(*it, inv_data[indx]);
+ }
+ TEST_EQ(n, inv_vec.size());
+
+ TEST_EQ(monster->color(), Color_Blue);
+
+ // Example of accessing a union:
+ TEST_EQ(monster->test_type(), Any_Monster); // First make sure which it is.
+ auto monster2 = reinterpret_cast<const Monster *>(monster->test());
+ TEST_NOTNULL(monster2);
+ TEST_EQ_STR(monster2->name()->c_str(), "Fred");
+
+ // Example of accessing a vector of strings:
+ auto vecofstrings = monster->testarrayofstring();
+ TEST_EQ(vecofstrings->size(), 4U);
+ TEST_EQ_STR(vecofstrings->Get(0)->c_str(), "bob");
+ TEST_EQ_STR(vecofstrings->Get(1)->c_str(), "fred");
+ if (pooled) {
+ // These should have pointer equality because of string pooling.
+ TEST_EQ(vecofstrings->Get(0)->c_str(), vecofstrings->Get(2)->c_str());
+ TEST_EQ(vecofstrings->Get(1)->c_str(), vecofstrings->Get(3)->c_str());
+ }
+
+ auto vecofstrings2 = monster->testarrayofstring2();
+ if (vecofstrings2) {
+ TEST_EQ(vecofstrings2->size(), 2U);
+ TEST_EQ_STR(vecofstrings2->Get(0)->c_str(), "jane");
+ TEST_EQ_STR(vecofstrings2->Get(1)->c_str(), "mary");
+ }
+
+ // Example of accessing a vector of tables:
+ auto vecoftables = monster->testarrayoftables();
+ TEST_EQ(vecoftables->size(), 3U);
+ for (auto it = vecoftables->begin(); it != vecoftables->end(); ++it) {
+ TEST_EQ(strlen(it->name()->c_str()) >= 4, true);
+ }
+ TEST_EQ_STR(vecoftables->Get(0)->name()->c_str(), "Barney");
+ TEST_EQ(vecoftables->Get(0)->hp(), 1000);
+ TEST_EQ_STR(vecoftables->Get(1)->name()->c_str(), "Fred");
+ TEST_EQ_STR(vecoftables->Get(2)->name()->c_str(), "Wilma");
+ TEST_NOTNULL(vecoftables->LookupByKey("Barney"));
+ TEST_NOTNULL(vecoftables->LookupByKey("Fred"));
+ TEST_NOTNULL(vecoftables->LookupByKey("Wilma"));
+
+ // Test accessing a vector of sorted structs
+ auto vecofstructs = monster->testarrayofsortedstruct();
+ if (vecofstructs) { // not filled in monster_test.bfbs
+ for (flatbuffers::uoffset_t i = 0; i < vecofstructs->size() - 1; i++) {
+ auto left = vecofstructs->Get(i);
+ auto right = vecofstructs->Get(i + 1);
+ TEST_EQ(true, (left->KeyCompareLessThan(right)));
+ }
+ TEST_NOTNULL(vecofstructs->LookupByKey(0)); // test default value
+ TEST_NOTNULL(vecofstructs->LookupByKey(3));
+ TEST_EQ(static_cast<const Ability *>(nullptr),
+ vecofstructs->LookupByKey(5));
+ }
+
+ if (auto vec_of_stat = monster->scalar_key_sorted_tables()) {
+ auto stat_0 = vec_of_stat->LookupByKey(static_cast<uint16_t>(0u));
+ TEST_NOTNULL(stat_0);
+ TEST_NOTNULL(stat_0->id());
+ TEST_EQ(0, stat_0->count());
+ TEST_EQ_STR("miss", stat_0->id()->c_str());
+ }
+
+ // Test nested FlatBuffers if available:
+ auto nested_buffer = monster->testnestedflatbuffer();
+ if (nested_buffer) {
+ // nested_buffer is a vector of bytes you can memcpy. However, if you
+ // actually want to access the nested data, this is a convenient
+ // accessor that directly gives you the root table:
+ auto nested_monster = monster->testnestedflatbuffer_nested_root();
+ TEST_EQ_STR(nested_monster->name()->c_str(), "NestedMonster");
+ }
+
+ // Test flexbuffer if available:
+ auto flex = monster->flex();
+ // flex is a vector of bytes you can memcpy etc.
+ TEST_EQ(flex->size(), 4); // Encoded FlexBuffer bytes.
+ // However, if you actually want to access the nested data, this is a
+ // convenient accessor that directly gives you the root value:
+ TEST_EQ(monster->flex_flexbuffer_root().AsInt16(), 1234);
+
+ // Test vector of enums:
+ auto colors = monster->vector_of_enums();
+ if (colors) {
+ TEST_EQ(colors->size(), 2);
+ TEST_EQ(colors->Get(0), Color_Blue);
+ TEST_EQ(colors->Get(1), Color_Green);
+ }
+
+ // Since Flatbuffers uses explicit mechanisms to override the default
+ // compiler alignment, double check that the compiler indeed obeys them:
+ // (Test consists of a short and byte):
+ TEST_EQ(flatbuffers::AlignOf<Test>(), 2UL);
+ TEST_EQ(sizeof(Test), 4UL);
+
+ const flatbuffers::Vector<const Test *> *tests_array[] = {
+ monster->test4(),
+ monster->test5(),
+ };
+ for (size_t i = 0; i < sizeof(tests_array) / sizeof(tests_array[0]); ++i) {
+ auto tests = tests_array[i];
+ TEST_NOTNULL(tests);
+ auto test_0 = tests->Get(0);
+ auto test_1 = tests->Get(1);
+ TEST_EQ(test_0->a(), 10);
+ TEST_EQ(test_0->b(), 20);
+ TEST_EQ(test_1->a(), 30);
+ TEST_EQ(test_1->b(), 40);
+ for (auto it = tests->begin(); it != tests->end(); ++it) {
+ TEST_EQ(it->a() == 10 || it->a() == 30, true); // Just testing iterators.
+ }
+ }
+
+ // Checking for presence of fields:
+ TEST_EQ(flatbuffers::IsFieldPresent(monster, Monster::VT_HP), true);
+ TEST_EQ(flatbuffers::IsFieldPresent(monster, Monster::VT_MANA), false);
+
+ // Obtaining a buffer from a root:
+ TEST_EQ(GetBufferStartFromRootPointer(monster), flatbuf);
+}
+
+// Change a FlatBuffer in-place, after it has been constructed.
+void MutateFlatBuffersTest(uint8_t *flatbuf, std::size_t length) {
+ // Get non-const pointer to root.
+ auto monster = GetMutableMonster(flatbuf);
+
+ // Each of these tests mutates, then tests, then set back to the original,
+ // so we can test that the buffer in the end still passes our original test.
+ auto hp_ok = monster->mutate_hp(10);
+ TEST_EQ(hp_ok, true); // Field was present.
+ TEST_EQ(monster->hp(), 10);
+ // Mutate to default value
+ auto hp_ok_default = monster->mutate_hp(100);
+ TEST_EQ(hp_ok_default, true); // Field was present.
+ TEST_EQ(monster->hp(), 100);
+ // Test that mutate to default above keeps field valid for further mutations
+ auto hp_ok_2 = monster->mutate_hp(20);
+ TEST_EQ(hp_ok_2, true);
+ TEST_EQ(monster->hp(), 20);
+ monster->mutate_hp(80);
+
+ // Monster originally at 150 mana (default value)
+ auto mana_default_ok = monster->mutate_mana(150); // Mutate to default value.
+ TEST_EQ(mana_default_ok,
+ true); // Mutation should succeed, because default value.
+ TEST_EQ(monster->mana(), 150);
+ auto mana_ok = monster->mutate_mana(10);
+ TEST_EQ(mana_ok, false); // Field was NOT present, because default value.
+ TEST_EQ(monster->mana(), 150);
+
+ // Mutate structs.
+ auto pos = monster->mutable_pos();
+ auto test3 = pos->mutable_test3(); // Struct inside a struct.
+ test3.mutate_a(50); // Struct fields never fail.
+ TEST_EQ(test3.a(), 50);
+ test3.mutate_a(10);
+
+ // Mutate vectors.
+ auto inventory = monster->mutable_inventory();
+ inventory->Mutate(9, 100);
+ TEST_EQ(inventory->Get(9), 100);
+ inventory->Mutate(9, 9);
+
+ auto tables = monster->mutable_testarrayoftables();
+ auto first = tables->GetMutableObject(0);
+ TEST_EQ(first->hp(), 1000);
+ first->mutate_hp(0);
+ TEST_EQ(first->hp(), 0);
+ first->mutate_hp(1000);
+
+ // Mutate via LookupByKey
+ TEST_NOTNULL(tables->MutableLookupByKey("Barney"));
+ TEST_EQ(static_cast<Monster *>(nullptr),
+ tables->MutableLookupByKey("DoesntExist"));
+ TEST_EQ(tables->MutableLookupByKey("Barney")->hp(), 1000);
+ TEST_EQ(tables->MutableLookupByKey("Barney")->mutate_hp(0), true);
+ TEST_EQ(tables->LookupByKey("Barney")->hp(), 0);
+ TEST_EQ(tables->MutableLookupByKey("Barney")->mutate_hp(1000), true);
+
+ // Run the verifier and the regular test to make sure we didn't trample on
+ // anything.
+ AccessFlatBufferTest(flatbuf, length);
+}
+
+// Unpack a FlatBuffer into objects.
+void ObjectFlatBuffersTest(uint8_t *flatbuf) {
+ // Optional: we can specify resolver and rehasher functions to turn hashed
+ // strings into object pointers and back, to implement remote references
+ // and such.
+ auto resolver = flatbuffers::resolver_function_t(
+ [](void **pointer_adr, flatbuffers::hash_value_t hash) {
+ (void)pointer_adr;
+ (void)hash;
+ // Don't actually do anything, leave variable null.
+ });
+ auto rehasher = flatbuffers::rehasher_function_t(
+ [](void *pointer) -> flatbuffers::hash_value_t {
+ (void)pointer;
+ return 0;
+ });
+
+ // Turn a buffer into C++ objects.
+ auto monster1 = UnPackMonster(flatbuf, &resolver);
+
+ // Re-serialize the data.
+ flatbuffers::FlatBufferBuilder fbb1;
+ fbb1.Finish(CreateMonster(fbb1, monster1.get(), &rehasher),
+ MonsterIdentifier());
+
+ // Unpack again, and re-serialize again.
+ auto monster2 = UnPackMonster(fbb1.GetBufferPointer(), &resolver);
+ flatbuffers::FlatBufferBuilder fbb2;
+ fbb2.Finish(CreateMonster(fbb2, monster2.get(), &rehasher),
+ MonsterIdentifier());
+
+ // Now we've gone full round-trip, the two buffers should match.
+ const auto len1 = fbb1.GetSize();
+ const auto len2 = fbb2.GetSize();
+ TEST_EQ(len1, len2);
+ TEST_EQ(memcmp(fbb1.GetBufferPointer(), fbb2.GetBufferPointer(), len1), 0);
+
+ // Test it with the original buffer test to make sure all data survived.
+ AccessFlatBufferTest(fbb2.GetBufferPointer(), len2, false);
+
+ // Test accessing fields, similar to AccessFlatBufferTest above.
+ CheckMonsterObject(monster2.get());
+
+ // Test object copy.
+ auto monster3 = *monster2;
+ flatbuffers::FlatBufferBuilder fbb3;
+ fbb3.Finish(CreateMonster(fbb3, &monster3, &rehasher), MonsterIdentifier());
+ const auto len3 = fbb3.GetSize();
+ TEST_EQ(len2, len3);
+ TEST_EQ(memcmp(fbb2.GetBufferPointer(), fbb3.GetBufferPointer(), len2), 0);
+ // Delete monster1 and monster2, then test accessing fields in monster3.
+ monster1.reset();
+ monster2.reset();
+ CheckMonsterObject(&monster3);
+}
+
+// Utility function to check a Monster object.
+void CheckMonsterObject(MonsterT *monster2) {
+ TEST_EQ(monster2->hp, 80);
+ TEST_EQ(monster2->mana, 150); // default
+ TEST_EQ_STR(monster2->name.c_str(), "MyMonster");
+
+ auto &pos = monster2->pos;
+ TEST_NOTNULL(pos);
+ TEST_EQ(pos->z(), 3);
+ TEST_EQ(pos->test3().a(), 10);
+ TEST_EQ(pos->test3().b(), 20);
+
+ auto &inventory = monster2->inventory;
+ TEST_EQ(inventory.size(), 10UL);
+ unsigned char inv_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+ for (auto it = inventory.begin(); it != inventory.end(); ++it)
+ TEST_EQ(*it, inv_data[it - inventory.begin()]);
+
+ TEST_EQ(monster2->color, Color_Blue);
+
+ auto monster3 = monster2->test.AsMonster();
+ TEST_NOTNULL(monster3);
+ TEST_EQ_STR(monster3->name.c_str(), "Fred");
+
+ auto &vecofstrings = monster2->testarrayofstring;
+ TEST_EQ(vecofstrings.size(), 4U);
+ TEST_EQ_STR(vecofstrings[0].c_str(), "bob");
+ TEST_EQ_STR(vecofstrings[1].c_str(), "fred");
+
+ auto &vecofstrings2 = monster2->testarrayofstring2;
+ TEST_EQ(vecofstrings2.size(), 2U);
+ TEST_EQ_STR(vecofstrings2[0].c_str(), "jane");
+ TEST_EQ_STR(vecofstrings2[1].c_str(), "mary");
+
+ auto &vecoftables = monster2->testarrayoftables;
+ TEST_EQ(vecoftables.size(), 3U);
+ TEST_EQ_STR(vecoftables[0]->name.c_str(), "Barney");
+ TEST_EQ(vecoftables[0]->hp, 1000);
+ TEST_EQ_STR(vecoftables[1]->name.c_str(), "Fred");
+ TEST_EQ_STR(vecoftables[2]->name.c_str(), "Wilma");
+
+ auto &tests = monster2->test4;
+ TEST_EQ(tests[0].a(), 10);
+ TEST_EQ(tests[0].b(), 20);
+ TEST_EQ(tests[1].a(), 30);
+ TEST_EQ(tests[1].b(), 40);
+}
+
+// Prefix a FlatBuffer with a size field.
+void SizePrefixedTest() {
+ // Create size prefixed buffer.
+ flatbuffers::FlatBufferBuilder fbb;
+ FinishSizePrefixedMonsterBuffer(
+ fbb, CreateMonster(fbb, nullptr, 200, 300, fbb.CreateString("bob")));
+
+ // Verify it.
+ flatbuffers::Verifier verifier(fbb.GetBufferPointer(), fbb.GetSize());
+ TEST_EQ(VerifySizePrefixedMonsterBuffer(verifier), true);
+
+ // Access it.
+ auto m = GetSizePrefixedMonster(fbb.GetBufferPointer());
+ TEST_EQ(m->mana(), 200);
+ TEST_EQ(m->hp(), 300);
+ TEST_EQ_STR(m->name()->c_str(), "bob");
+}
+
+void TestMonsterExtraFloats(const std::string &tests_data_path) {
+#if defined(FLATBUFFERS_HAS_NEW_STRTOD) && (FLATBUFFERS_HAS_NEW_STRTOD > 0)
+ TEST_EQ(is_quiet_nan(1.0), false);
+ TEST_EQ(is_quiet_nan(infinity_d), false);
+ TEST_EQ(is_quiet_nan(-infinity_f), false);
+ TEST_EQ(is_quiet_nan(std::numeric_limits<float>::quiet_NaN()), true);
+ TEST_EQ(is_quiet_nan(std::numeric_limits<double>::quiet_NaN()), true);
+
+ using namespace flatbuffers;
+ using namespace MyGame;
+ // Load FlatBuffer schema (.fbs) from disk.
+ std::string schemafile;
+ TEST_EQ(LoadFile((tests_data_path + "monster_extra.fbs").c_str(), false,
+ &schemafile),
+ true);
+ // Parse schema first, so we can use it to parse the data after.
+ Parser parser;
+ auto include_test_path = ConCatPathFileName(tests_data_path, "include_test");
+ const char *include_directories[] = { tests_data_path.c_str(),
+ include_test_path.c_str(), nullptr };
+ TEST_EQ(parser.Parse(schemafile.c_str(), include_directories), true);
+ // Create empty extra and store to json.
+ parser.opts.output_default_scalars_in_json = true;
+ parser.opts.output_enum_identifiers = true;
+ FlatBufferBuilder builder;
+ const auto def_root = MonsterExtraBuilder(builder).Finish();
+ FinishMonsterExtraBuffer(builder, def_root);
+ const auto def_obj = builder.GetBufferPointer();
+ const auto def_extra = GetMonsterExtra(def_obj);
+ TEST_NOTNULL(def_extra);
+ TEST_EQ(is_quiet_nan(def_extra->f0()), true);
+ TEST_EQ(is_quiet_nan(def_extra->f1()), true);
+ TEST_EQ(def_extra->f2(), +infinity_f);
+ TEST_EQ(def_extra->f3(), -infinity_f);
+ TEST_EQ(is_quiet_nan(def_extra->d0()), true);
+ TEST_EQ(is_quiet_nan(def_extra->d1()), true);
+ TEST_EQ(def_extra->d2(), +infinity_d);
+ TEST_EQ(def_extra->d3(), -infinity_d);
+ std::string jsongen;
+ auto result = GenerateText(parser, def_obj, &jsongen);
+ TEST_EQ(result, true);
+ // Check expected default values.
+ TEST_EQ(std::string::npos != jsongen.find("f0: nan"), true);
+ TEST_EQ(std::string::npos != jsongen.find("f1: nan"), true);
+ TEST_EQ(std::string::npos != jsongen.find("f2: inf"), true);
+ TEST_EQ(std::string::npos != jsongen.find("f3: -inf"), true);
+ TEST_EQ(std::string::npos != jsongen.find("d0: nan"), true);
+ TEST_EQ(std::string::npos != jsongen.find("d1: nan"), true);
+ TEST_EQ(std::string::npos != jsongen.find("d2: inf"), true);
+ TEST_EQ(std::string::npos != jsongen.find("d3: -inf"), true);
+ // Parse 'mosterdata_extra.json'.
+ const auto extra_base = tests_data_path + "monsterdata_extra";
+ jsongen = "";
+ TEST_EQ(LoadFile((extra_base + ".json").c_str(), false, &jsongen), true);
+ TEST_EQ(parser.Parse(jsongen.c_str()), true);
+ const auto test_file = parser.builder_.GetBufferPointer();
+ const auto test_size = parser.builder_.GetSize();
+ Verifier verifier(test_file, test_size);
+ TEST_ASSERT(VerifyMonsterExtraBuffer(verifier));
+ const auto extra = GetMonsterExtra(test_file);
+ TEST_NOTNULL(extra);
+ TEST_EQ(is_quiet_nan(extra->f0()), true);
+ TEST_EQ(is_quiet_nan(extra->f1()), true);
+ TEST_EQ(extra->f2(), +infinity_f);
+ TEST_EQ(extra->f3(), -infinity_f);
+ TEST_EQ(is_quiet_nan(extra->d0()), true);
+ TEST_EQ(extra->d1(), +infinity_d);
+ TEST_EQ(extra->d2(), -infinity_d);
+ TEST_EQ(is_quiet_nan(extra->d3()), true);
+ TEST_NOTNULL(extra->fvec());
+ TEST_EQ(extra->fvec()->size(), 4);
+ TEST_EQ(extra->fvec()->Get(0), 1.0f);
+ TEST_EQ(extra->fvec()->Get(1), -infinity_f);
+ TEST_EQ(extra->fvec()->Get(2), +infinity_f);
+ TEST_EQ(is_quiet_nan(extra->fvec()->Get(3)), true);
+ TEST_NOTNULL(extra->dvec());
+ TEST_EQ(extra->dvec()->size(), 4);
+ TEST_EQ(extra->dvec()->Get(0), 2.0);
+ TEST_EQ(extra->dvec()->Get(1), +infinity_d);
+ TEST_EQ(extra->dvec()->Get(2), -infinity_d);
+ TEST_EQ(is_quiet_nan(extra->dvec()->Get(3)), true);
+#endif
+}
+
+void EnumNamesTest() {
+ TEST_EQ_STR("Red", EnumNameColor(Color_Red));
+ TEST_EQ_STR("Green", EnumNameColor(Color_Green));
+ TEST_EQ_STR("Blue", EnumNameColor(Color_Blue));
+ // Check that Color to string don't crash while decode a mixture of Colors.
+ // 1) Example::Color enum is enum with unfixed underlying type.
+ // 2) Valid enum range: [0; 2^(ceil(log2(Color_ANY))) - 1].
+ // Consequence: A value is out of this range will lead to UB (since C++17).
+ // For details see C++17 standard or explanation on the SO:
+ // stackoverflow.com/questions/18195312/what-happens-if-you-static-cast-invalid-value-to-enum-class
+ TEST_EQ_STR("", EnumNameColor(static_cast<Color>(0)));
+ TEST_EQ_STR("", EnumNameColor(static_cast<Color>(Color_ANY - 1)));
+ TEST_EQ_STR("", EnumNameColor(static_cast<Color>(Color_ANY + 1)));
+}
+
+void TypeAliasesTest() {
+ flatbuffers::FlatBufferBuilder builder;
+
+ builder.Finish(CreateTypeAliases(
+ builder, flatbuffers::numeric_limits<int8_t>::min(),
+ flatbuffers::numeric_limits<uint8_t>::max(),
+ flatbuffers::numeric_limits<int16_t>::min(),
+ flatbuffers::numeric_limits<uint16_t>::max(),
+ flatbuffers::numeric_limits<int32_t>::min(),
+ flatbuffers::numeric_limits<uint32_t>::max(),
+ flatbuffers::numeric_limits<int64_t>::min(),
+ flatbuffers::numeric_limits<uint64_t>::max(), 2.3f, 2.3));
+
+ auto p = builder.GetBufferPointer();
+ auto ta = flatbuffers::GetRoot<TypeAliases>(p);
+
+ TEST_EQ(ta->i8(), flatbuffers::numeric_limits<int8_t>::min());
+ TEST_EQ(ta->u8(), flatbuffers::numeric_limits<uint8_t>::max());
+ TEST_EQ(ta->i16(), flatbuffers::numeric_limits<int16_t>::min());
+ TEST_EQ(ta->u16(), flatbuffers::numeric_limits<uint16_t>::max());
+ TEST_EQ(ta->i32(), flatbuffers::numeric_limits<int32_t>::min());
+ TEST_EQ(ta->u32(), flatbuffers::numeric_limits<uint32_t>::max());
+ TEST_EQ(ta->i64(), flatbuffers::numeric_limits<int64_t>::min());
+ TEST_EQ(ta->u64(), flatbuffers::numeric_limits<uint64_t>::max());
+ TEST_EQ(ta->f32(), 2.3f);
+ TEST_EQ(ta->f64(), 2.3);
+ using namespace flatbuffers; // is_same
+ static_assert(is_same<decltype(ta->i8()), int8_t>::value, "invalid type");
+ static_assert(is_same<decltype(ta->i16()), int16_t>::value, "invalid type");
+ static_assert(is_same<decltype(ta->i32()), int32_t>::value, "invalid type");
+ static_assert(is_same<decltype(ta->i64()), int64_t>::value, "invalid type");
+ static_assert(is_same<decltype(ta->u8()), uint8_t>::value, "invalid type");
+ static_assert(is_same<decltype(ta->u16()), uint16_t>::value, "invalid type");
+ static_assert(is_same<decltype(ta->u32()), uint32_t>::value, "invalid type");
+ static_assert(is_same<decltype(ta->u64()), uint64_t>::value, "invalid type");
+ static_assert(is_same<decltype(ta->f32()), float>::value, "invalid type");
+ static_assert(is_same<decltype(ta->f64()), double>::value, "invalid type");
+}
+
+// example of parsing text straight into a buffer, and generating
+// text back from it:
+void ParseAndGenerateTextTest(const std::string &tests_data_path, bool binary) {
+ // load FlatBuffer schema (.fbs) and JSON from disk
+ std::string schemafile;
+ std::string jsonfile;
+ TEST_EQ(flatbuffers::LoadFile(
+ (tests_data_path + "monster_test." + (binary ? "bfbs" : "fbs"))
+ .c_str(),
+ binary, &schemafile),
+ true);
+ TEST_EQ(flatbuffers::LoadFile(
+ (tests_data_path + "monsterdata_test.golden").c_str(), false,
+ &jsonfile),
+ true);
+
+ auto include_test_path =
+ flatbuffers::ConCatPathFileName(tests_data_path, "include_test");
+ const char *include_directories[] = { tests_data_path.c_str(),
+ include_test_path.c_str(), nullptr };
+
+ // parse schema first, so we can use it to parse the data after
+ flatbuffers::Parser parser;
+ if (binary) {
+ flatbuffers::Verifier verifier(
+ reinterpret_cast<const uint8_t *>(schemafile.c_str()),
+ schemafile.size());
+ TEST_EQ(reflection::VerifySchemaBuffer(verifier), true);
+ // auto schema = reflection::GetSchema(schemafile.c_str());
+ TEST_EQ(parser.Deserialize(
+ reinterpret_cast<const uint8_t *>(schemafile.c_str()),
+ schemafile.size()),
+ true);
+ } else {
+ TEST_EQ(parser.Parse(schemafile.c_str(), include_directories), true);
+ }
+ TEST_EQ(parser.ParseJson(jsonfile.c_str()), true);
+
+ // here, parser.builder_ contains a binary buffer that is the parsed data.
+
+ // First, verify it, just in case:
+ flatbuffers::Verifier verifier(parser.builder_.GetBufferPointer(),
+ parser.builder_.GetSize());
+ TEST_EQ(VerifyMonsterBuffer(verifier), true);
+
+ AccessFlatBufferTest(parser.builder_.GetBufferPointer(),
+ parser.builder_.GetSize(), false);
+
+ // to ensure it is correct, we now generate text back from the binary,
+ // and compare the two:
+ std::string jsongen;
+ auto result =
+ GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen);
+ TEST_EQ(result, true);
+ TEST_EQ_STR(jsongen.c_str(), jsonfile.c_str());
+
+ // We can also do the above using the convenient Registry that knows about
+ // a set of file_identifiers mapped to schemas.
+ flatbuffers::Registry registry;
+ // Make sure schemas can find their includes.
+ registry.AddIncludeDirectory(tests_data_path.c_str());
+ registry.AddIncludeDirectory(include_test_path.c_str());
+ // Call this with many schemas if possible.
+ registry.Register(MonsterIdentifier(),
+ (tests_data_path + "monster_test.fbs").c_str());
+ // Now we got this set up, we can parse by just specifying the identifier,
+ // the correct schema will be loaded on the fly:
+ auto buf = registry.TextToFlatBuffer(jsonfile.c_str(), MonsterIdentifier());
+ // If this fails, check registry.lasterror_.
+ TEST_NOTNULL(buf.data());
+ // Test the buffer, to be sure:
+ AccessFlatBufferTest(buf.data(), buf.size(), false);
+ // We can use the registry to turn this back into text, in this case it
+ // will get the file_identifier from the binary:
+ std::string text;
+ auto ok = registry.FlatBufferToText(buf.data(), buf.size(), &text);
+ // If this fails, check registry.lasterror_.
+ TEST_EQ(ok, true);
+ TEST_EQ_STR(text.c_str(), jsonfile.c_str());
+
+ // Generate text for UTF-8 strings without escapes.
+ std::string jsonfile_utf8;
+ TEST_EQ(flatbuffers::LoadFile((tests_data_path + "unicode_test.json").c_str(),
+ false, &jsonfile_utf8),
+ true);
+ TEST_EQ(parser.Parse(jsonfile_utf8.c_str(), include_directories), true);
+ // To ensure it is correct, generate utf-8 text back from the binary.
+ std::string jsongen_utf8;
+ // request natural printing for utf-8 strings
+ parser.opts.natural_utf8 = true;
+ parser.opts.strict_json = true;
+ TEST_EQ(
+ GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen_utf8),
+ true);
+ TEST_EQ_STR(jsongen_utf8.c_str(), jsonfile_utf8.c_str());
+}
+
+void UnPackTo(const uint8_t *flatbuf) {
+ // Get a monster that has a name and no enemy
+ auto orig_monster = GetMonster(flatbuf);
+ TEST_EQ_STR(orig_monster->name()->c_str(), "MyMonster");
+ TEST_ASSERT(orig_monster->enemy() == nullptr);
+
+ // Create an enemy
+ MonsterT *enemy = new MonsterT();
+ enemy->name = "Enemy";
+
+ // And create another monster owning the enemy,
+ MonsterT mon;
+ mon.name = "I'm monster 1";
+ mon.enemy.reset(enemy);
+ TEST_ASSERT(mon.enemy != nullptr);
+
+ // Assert that all the Monster objects are correct.
+ TEST_EQ_STR(mon.name.c_str(), "I'm monster 1");
+ TEST_EQ_STR(enemy->name.c_str(), "Enemy");
+ TEST_EQ_STR(mon.enemy->name.c_str(), "Enemy");
+
+ // Now unpack monster ("MyMonster") into monster
+ orig_monster->UnPackTo(&mon);
+
+ // Monster name should be from monster
+ TEST_EQ_STR(mon.name.c_str(), "MyMonster");
+
+ // The monster shouldn't have any enemies, because monster didn't.
+ TEST_ASSERT(mon.enemy == nullptr);
+}
+
+} // namespace tests
+} // namespace flatbuffers
\ No newline at end of file
diff --git a/tests/monster_test.fbs b/tests/monster_test.fbs
index b28ddc8..14d34cb 100644
--- a/tests/monster_test.fbs
+++ b/tests/monster_test.fbs
@@ -70,6 +70,10 @@
c: Ability;
}
+struct StructOfStructsOfStructs {
+ a: StructOfStructs;
+}
+
table Stat {
id:string;
val:long;
diff --git a/tests/monster_test.grpc.fb.h b/tests/monster_test.grpc.fb.h
index 4d726e1..e3f3037 100644
--- a/tests/monster_test.grpc.fb.h
+++ b/tests/monster_test.grpc.fb.h
@@ -201,7 +201,7 @@
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
- ::grpc::Status GetMaxHitPoint(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< flatbuffers::grpc::Message<Monster>>* /*reader*/, flatbuffers::grpc::Message<Stat>* response) final override {
+ ::grpc::Status GetMaxHitPoint(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< flatbuffers::grpc::Message<Monster>>* /*reader*/, flatbuffers::grpc::Message<Stat>* /*response*/) final override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
diff --git a/tests/monster_test.h b/tests/monster_test.h
new file mode 100644
index 0000000..5ab968b
--- /dev/null
+++ b/tests/monster_test.h
@@ -0,0 +1,38 @@
+#ifndef TESTS_MONSTER_TEST_H
+#define TESTS_MONSTER_TEST_H
+
+#include <string>
+
+#include "flatbuffers/detached_buffer.h"
+#include "monster_test_generated.h"
+
+namespace flatbuffers {
+namespace tests {
+
+flatbuffers::DetachedBuffer CreateFlatBufferTest(std::string &buffer);
+
+void AccessFlatBufferTest(const uint8_t *flatbuf, size_t length,
+ bool pooled = true);
+
+void MutateFlatBuffersTest(uint8_t *flatbuf, std::size_t length);
+
+void ObjectFlatBuffersTest(uint8_t *flatbuf);
+
+void CheckMonsterObject(MyGame::Example::MonsterT *monster2);
+
+void SizePrefixedTest();
+
+void TestMonsterExtraFloats(const std::string& tests_data_path);
+
+void EnumNamesTest();
+
+void TypeAliasesTest();
+
+void ParseAndGenerateTextTest(const std::string& tests_data_path, bool binary);
+
+void UnPackTo(const uint8_t *flatbuf);
+
+} // namespace tests
+} // namespace flatbuffers
+
+#endif
\ No newline at end of file
diff --git a/tests/monster_test.schema.json b/tests/monster_test.schema.json
index 7517269..5e98ef4 100644
--- a/tests/monster_test.schema.json
+++ b/tests/monster_test.schema.json
@@ -140,6 +140,15 @@
},
"additionalProperties" : false
},
+ "MyGame_Example_StructOfStructsOfStructs" : {
+ "type" : "object",
+ "properties" : {
+ "a" : {
+ "$ref" : "#/definitions/MyGame_Example_StructOfStructs"
+ }
+ },
+ "additionalProperties" : false
+ },
"MyGame_Example_Stat" : {
"type" : "object",
"properties" : {
diff --git a/tests/monster_test/mod.rs b/tests/monster_test/mod.rs
index fdbc26b..7f1fab1 100644
--- a/tests/monster_test/mod.rs
+++ b/tests/monster_test/mod.rs
@@ -1,4 +1,5 @@
// Automatically generated by the Flatbuffers compiler. Do not modify.
+// @generated
pub mod my_game {
use super::*;
pub mod example {
@@ -25,6 +26,8 @@
pub use self::ability_generated::*;
mod struct_of_structs_generated;
pub use self::struct_of_structs_generated::*;
+ mod struct_of_structs_of_structs_generated;
+ pub use self::struct_of_structs_of_structs_generated::*;
mod stat_generated;
pub use self::stat_generated::*;
mod referrable_generated;
diff --git a/tests/monster_test/my_game/example/ability_generated.rs b/tests/monster_test/my_game/example/ability_generated.rs
index 5746e8e..d1f177c 100644
--- a/tests/monster_test/my_game/example/ability_generated.rs
+++ b/tests/monster_test/my_game/example/ability_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
// struct Ability, aligned to 4
@@ -13,8 +18,8 @@
Self([0; 8])
}
}
-impl std::fmt::Debug for Ability {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Ability {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Ability")
.field("id", &self.id())
.field("distance", &self.distance())
@@ -43,7 +48,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(self as *const Ability as *const u8, Self::size())
+ ::core::slice::from_raw_parts(self as *const Ability as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
@@ -54,7 +59,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(*self as *const Ability as *const u8, Self::size())
+ ::core::slice::from_raw_parts(*self as *const Ability as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
@@ -115,7 +120,7 @@
}
#[inline]
- pub fn key_compare_with_value(&self, val: u32) -> ::std::cmp::Ordering {
+ pub fn key_compare_with_value(&self, val: u32) -> ::core::cmp::Ordering {
let key = self.id();
key.cmp(&val)
}
diff --git a/tests/monster_test/my_game/example/any_ambiguous_aliases_generated.rs b/tests/monster_test/my_game/example/any_ambiguous_aliases_generated.rs
index 321007a..ee8cba7 100644
--- a/tests/monster_test/my_game/example/any_ambiguous_aliases_generated.rs
+++ b/tests/monster_test/my_game/example/any_ambiguous_aliases_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -46,8 +51,8 @@
}
}
}
-impl std::fmt::Debug for AnyAmbiguousAliases {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for AnyAmbiguousAliases {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
if let Some(name) = self.variant_name() {
f.write_str(name)
} else {
@@ -135,7 +140,7 @@
/// If the union variant matches, return the owned MonsterT, setting the union to NONE.
pub fn take_m1(&mut self) -> Option<Box<MonsterT>> {
if let Self::M1(_) = self {
- let v = std::mem::replace(self, Self::NONE);
+ let v = core::mem::replace(self, Self::NONE);
if let Self::M1(w) = v {
Some(w)
} else {
@@ -156,7 +161,7 @@
/// If the union variant matches, return the owned MonsterT, setting the union to NONE.
pub fn take_m2(&mut self) -> Option<Box<MonsterT>> {
if let Self::M2(_) = self {
- let v = std::mem::replace(self, Self::NONE);
+ let v = core::mem::replace(self, Self::NONE);
if let Self::M2(w) = v {
Some(w)
} else {
@@ -177,7 +182,7 @@
/// If the union variant matches, return the owned MonsterT, setting the union to NONE.
pub fn take_m3(&mut self) -> Option<Box<MonsterT>> {
if let Self::M3(_) = self {
- let v = std::mem::replace(self, Self::NONE);
+ let v = core::mem::replace(self, Self::NONE);
if let Self::M3(w) = v {
Some(w)
} else {
diff --git a/tests/monster_test/my_game/example/any_generated.rs b/tests/monster_test/my_game/example/any_generated.rs
index 6f7f6fd..adddc10 100644
--- a/tests/monster_test/my_game/example/any_generated.rs
+++ b/tests/monster_test/my_game/example/any_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -46,8 +51,8 @@
}
}
}
-impl std::fmt::Debug for Any {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Any {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
if let Some(name) = self.variant_name() {
f.write_str(name)
} else {
@@ -135,7 +140,7 @@
/// If the union variant matches, return the owned MonsterT, setting the union to NONE.
pub fn take_monster(&mut self) -> Option<Box<MonsterT>> {
if let Self::Monster(_) = self {
- let v = std::mem::replace(self, Self::NONE);
+ let v = core::mem::replace(self, Self::NONE);
if let Self::Monster(w) = v {
Some(w)
} else {
@@ -156,7 +161,7 @@
/// If the union variant matches, return the owned TestSimpleTableWithEnumT, setting the union to NONE.
pub fn take_test_simple_table_with_enum(&mut self) -> Option<Box<TestSimpleTableWithEnumT>> {
if let Self::TestSimpleTableWithEnum(_) = self {
- let v = std::mem::replace(self, Self::NONE);
+ let v = core::mem::replace(self, Self::NONE);
if let Self::TestSimpleTableWithEnum(w) = v {
Some(w)
} else {
@@ -177,7 +182,7 @@
/// If the union variant matches, return the owned super::example_2::MonsterT, setting the union to NONE.
pub fn take_my_game_example_2_monster(&mut self) -> Option<Box<super::example_2::MonsterT>> {
if let Self::MyGameExample2Monster(_) = self {
- let v = std::mem::replace(self, Self::NONE);
+ let v = core::mem::replace(self, Self::NONE);
if let Self::MyGameExample2Monster(w) = v {
Some(w)
} else {
diff --git a/tests/monster_test/my_game/example/any_unique_aliases_generated.rs b/tests/monster_test/my_game/example/any_unique_aliases_generated.rs
index 1749d5d..5142d0e 100644
--- a/tests/monster_test/my_game/example/any_unique_aliases_generated.rs
+++ b/tests/monster_test/my_game/example/any_unique_aliases_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -46,8 +51,8 @@
}
}
}
-impl std::fmt::Debug for AnyUniqueAliases {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for AnyUniqueAliases {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
if let Some(name) = self.variant_name() {
f.write_str(name)
} else {
@@ -135,7 +140,7 @@
/// If the union variant matches, return the owned MonsterT, setting the union to NONE.
pub fn take_m(&mut self) -> Option<Box<MonsterT>> {
if let Self::M(_) = self {
- let v = std::mem::replace(self, Self::NONE);
+ let v = core::mem::replace(self, Self::NONE);
if let Self::M(w) = v {
Some(w)
} else {
@@ -156,7 +161,7 @@
/// If the union variant matches, return the owned TestSimpleTableWithEnumT, setting the union to NONE.
pub fn take_ts(&mut self) -> Option<Box<TestSimpleTableWithEnumT>> {
if let Self::TS(_) = self {
- let v = std::mem::replace(self, Self::NONE);
+ let v = core::mem::replace(self, Self::NONE);
if let Self::TS(w) = v {
Some(w)
} else {
@@ -177,7 +182,7 @@
/// If the union variant matches, return the owned super::example_2::MonsterT, setting the union to NONE.
pub fn take_m2(&mut self) -> Option<Box<super::example_2::MonsterT>> {
if let Self::M2(_) = self {
- let v = std::mem::replace(self, Self::NONE);
+ let v = core::mem::replace(self, Self::NONE);
if let Self::M2(w) = v {
Some(w)
} else {
diff --git a/tests/monster_test/my_game/example/color_generated.rs b/tests/monster_test/my_game/example/color_generated.rs
index 4a3282b..1b9287f 100644
--- a/tests/monster_test/my_game/example/color_generated.rs
+++ b/tests/monster_test/my_game/example/color_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
#[allow(non_upper_case_globals)]
diff --git a/tests/monster_test/my_game/example/long_enum_generated.rs b/tests/monster_test/my_game/example/long_enum_generated.rs
index b22f826..6a24d74 100644
--- a/tests/monster_test/my_game/example/long_enum_generated.rs
+++ b/tests/monster_test/my_game/example/long_enum_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
#[allow(non_upper_case_globals)]
diff --git a/tests/monster_test/my_game/example/monster_generated.rs b/tests/monster_test/my_game/example/monster_generated.rs
index 58e7628..dd325b2 100644
--- a/tests/monster_test/my_game/example/monster_generated.rs
+++ b/tests/monster_test/my_game/example/monster_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum MonsterOffset {}
@@ -379,7 +384,7 @@
}
#[inline]
- pub fn key_compare_with_value(&self, val: & str) -> ::std::cmp::Ordering {
+ pub fn key_compare_with_value(&self, val: & str) -> ::core::cmp::Ordering {
let key = self.name();
key.cmp(val)
}
@@ -1116,8 +1121,8 @@
}
}
-impl std::fmt::Debug for Monster<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for Monster<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("Monster");
ds.field("pos", &self.pos());
ds.field("mana", &self.mana());
diff --git a/tests/monster_test/my_game/example/race_generated.rs b/tests/monster_test/my_game/example/race_generated.rs
index ab012f9..47f3855 100644
--- a/tests/monster_test/my_game/example/race_generated.rs
+++ b/tests/monster_test/my_game/example/race_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -46,8 +51,8 @@
}
}
}
-impl std::fmt::Debug for Race {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Race {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
if let Some(name) = self.variant_name() {
f.write_str(name)
} else {
diff --git a/tests/monster_test/my_game/example/referrable_generated.rs b/tests/monster_test/my_game/example/referrable_generated.rs
index 877e3b8..81a9d60 100644
--- a/tests/monster_test/my_game/example/referrable_generated.rs
+++ b/tests/monster_test/my_game/example/referrable_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum ReferrableOffset {}
@@ -57,7 +62,7 @@
}
#[inline]
- pub fn key_compare_with_value(&self, val: u64) -> ::std::cmp::Ordering {
+ pub fn key_compare_with_value(&self, val: u64) -> ::core::cmp::Ordering {
let key = self.id();
key.cmp(&val)
}
@@ -111,8 +116,8 @@
}
}
-impl std::fmt::Debug for Referrable<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for Referrable<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("Referrable");
ds.field("id", &self.id());
ds.finish()
diff --git a/tests/monster_test/my_game/example/stat_generated.rs b/tests/monster_test/my_game/example/stat_generated.rs
index d6e5fad..98bc331 100644
--- a/tests/monster_test/my_game/example/stat_generated.rs
+++ b/tests/monster_test/my_game/example/stat_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum StatOffset {}
@@ -75,7 +80,7 @@
}
#[inline]
- pub fn key_compare_with_value(&self, val: u16) -> ::std::cmp::Ordering {
+ pub fn key_compare_with_value(&self, val: u16) -> ::core::cmp::Ordering {
let key = self.count();
key.cmp(&val)
}
@@ -143,8 +148,8 @@
}
}
-impl std::fmt::Debug for Stat<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for Stat<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("Stat");
ds.field("id", &self.id());
ds.field("val", &self.val());
diff --git a/tests/monster_test/my_game/example/struct_of_structs_generated.rs b/tests/monster_test/my_game/example/struct_of_structs_generated.rs
index 9994f7e..bc05c77 100644
--- a/tests/monster_test/my_game/example/struct_of_structs_generated.rs
+++ b/tests/monster_test/my_game/example/struct_of_structs_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
// struct StructOfStructs, aligned to 4
@@ -13,8 +18,8 @@
Self([0; 20])
}
}
-impl std::fmt::Debug for StructOfStructs {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for StructOfStructs {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("StructOfStructs")
.field("a", &self.a())
.field("b", &self.b())
@@ -44,7 +49,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(self as *const StructOfStructs as *const u8, Self::size())
+ ::core::slice::from_raw_parts(self as *const StructOfStructs as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
@@ -55,7 +60,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(*self as *const StructOfStructs as *const u8, Self::size())
+ ::core::slice::from_raw_parts(*self as *const StructOfStructs as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
diff --git a/tests/monster_test/my_game/example/struct_of_structs_of_structs_generated.rs b/tests/monster_test/my_game/example/struct_of_structs_of_structs_generated.rs
new file mode 100644
index 0000000..9c7ae0b
--- /dev/null
+++ b/tests/monster_test/my_game/example/struct_of_structs_of_structs_generated.rs
@@ -0,0 +1,118 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
+extern crate flatbuffers;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
+use self::flatbuffers::{EndianScalar, Follow};
+use super::*;
+// struct StructOfStructsOfStructs, aligned to 4
+#[repr(transparent)]
+#[derive(Clone, Copy, PartialEq)]
+pub struct StructOfStructsOfStructs(pub [u8; 20]);
+impl Default for StructOfStructsOfStructs {
+ fn default() -> Self {
+ Self([0; 20])
+ }
+}
+impl core::fmt::Debug for StructOfStructsOfStructs {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
+ f.debug_struct("StructOfStructsOfStructs")
+ .field("a", &self.a())
+ .finish()
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for StructOfStructsOfStructs {}
+impl flatbuffers::SafeSliceAccess for StructOfStructsOfStructs {}
+impl<'a> flatbuffers::Follow<'a> for StructOfStructsOfStructs {
+ type Inner = &'a StructOfStructsOfStructs;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ <&'a StructOfStructsOfStructs>::follow(buf, loc)
+ }
+}
+impl<'a> flatbuffers::Follow<'a> for &'a StructOfStructsOfStructs {
+ type Inner = &'a StructOfStructsOfStructs;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ flatbuffers::follow_cast_ref::<StructOfStructsOfStructs>(buf, loc)
+ }
+}
+impl<'b> flatbuffers::Push for StructOfStructsOfStructs {
+ type Output = StructOfStructsOfStructs;
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ let src = unsafe {
+ ::core::slice::from_raw_parts(self as *const StructOfStructsOfStructs as *const u8, Self::size())
+ };
+ dst.copy_from_slice(src);
+ }
+}
+impl<'b> flatbuffers::Push for &'b StructOfStructsOfStructs {
+ type Output = StructOfStructsOfStructs;
+
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ let src = unsafe {
+ ::core::slice::from_raw_parts(*self as *const StructOfStructsOfStructs as *const u8, Self::size())
+ };
+ dst.copy_from_slice(src);
+ }
+}
+
+impl<'a> flatbuffers::Verifiable for StructOfStructsOfStructs {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ v.in_buffer::<Self>(pos)
+ }
+}
+
+impl<'a> StructOfStructsOfStructs {
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ a: &StructOfStructs,
+ ) -> Self {
+ let mut s = Self([0; 20]);
+ s.set_a(a);
+ s
+ }
+
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.StructOfStructsOfStructs"
+ }
+
+ pub fn a(&self) -> &StructOfStructs {
+ unsafe { &*(self.0[0..].as_ptr() as *const StructOfStructs) }
+ }
+
+ #[allow(clippy::identity_op)]
+ pub fn set_a(&mut self, x: &StructOfStructs) {
+ self.0[0..0 + 20].copy_from_slice(&x.0)
+ }
+
+ pub fn unpack(&self) -> StructOfStructsOfStructsT {
+ StructOfStructsOfStructsT {
+ a: self.a().unpack(),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, Default)]
+pub struct StructOfStructsOfStructsT {
+ pub a: StructOfStructsT,
+}
+impl StructOfStructsOfStructsT {
+ pub fn pack(&self) -> StructOfStructsOfStructs {
+ StructOfStructsOfStructs::new(
+ &self.a.pack(),
+ )
+ }
+}
+
diff --git a/tests/monster_test/my_game/example/test_generated.rs b/tests/monster_test/my_game/example/test_generated.rs
index 187b7cd..1b72ee6 100644
--- a/tests/monster_test/my_game/example/test_generated.rs
+++ b/tests/monster_test/my_game/example/test_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
// struct Test, aligned to 2
@@ -13,8 +18,8 @@
Self([0; 4])
}
}
-impl std::fmt::Debug for Test {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Test {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Test")
.field("a", &self.a())
.field("b", &self.b())
@@ -43,7 +48,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(self as *const Test as *const u8, Self::size())
+ ::core::slice::from_raw_parts(self as *const Test as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
@@ -54,7 +59,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(*self as *const Test as *const u8, Self::size())
+ ::core::slice::from_raw_parts(*self as *const Test as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
diff --git a/tests/monster_test/my_game/example/test_simple_table_with_enum_generated.rs b/tests/monster_test/my_game/example/test_simple_table_with_enum_generated.rs
index 6ebe31f..e97dfa0 100644
--- a/tests/monster_test/my_game/example/test_simple_table_with_enum_generated.rs
+++ b/tests/monster_test/my_game/example/test_simple_table_with_enum_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum TestSimpleTableWithEnumOffset {}
@@ -101,8 +106,8 @@
}
}
-impl std::fmt::Debug for TestSimpleTableWithEnum<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TestSimpleTableWithEnum<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("TestSimpleTableWithEnum");
ds.field("color", &self.color());
ds.finish()
diff --git a/tests/monster_test/my_game/example/type_aliases_generated.rs b/tests/monster_test/my_game/example/type_aliases_generated.rs
index 5b3ede5..dfa8d56 100644
--- a/tests/monster_test/my_game/example/type_aliases_generated.rs
+++ b/tests/monster_test/my_game/example/type_aliases_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum TypeAliasesOffset {}
@@ -270,8 +275,8 @@
}
}
-impl std::fmt::Debug for TypeAliases<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TypeAliases<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("TypeAliases");
ds.field("i8_", &self.i8_());
ds.field("u8_", &self.u8_());
diff --git a/tests/monster_test/my_game/example/vec_3_generated.rs b/tests/monster_test/my_game/example/vec_3_generated.rs
index e5a25bb..fa0ab53 100644
--- a/tests/monster_test/my_game/example/vec_3_generated.rs
+++ b/tests/monster_test/my_game/example/vec_3_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
// struct Vec3, aligned to 8
@@ -13,8 +18,8 @@
Self([0; 32])
}
}
-impl std::fmt::Debug for Vec3 {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Vec3 {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Vec3")
.field("x", &self.x())
.field("y", &self.y())
@@ -47,7 +52,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(self as *const Vec3 as *const u8, Self::size())
+ ::core::slice::from_raw_parts(self as *const Vec3 as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
@@ -58,7 +63,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(*self as *const Vec3 as *const u8, Self::size())
+ ::core::slice::from_raw_parts(*self as *const Vec3 as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
diff --git a/tests/monster_test/my_game/example_2/monster_generated.rs b/tests/monster_test/my_game/example_2/monster_generated.rs
index 54384b5..34e0db1 100644
--- a/tests/monster_test/my_game/example_2/monster_generated.rs
+++ b/tests/monster_test/my_game/example_2/monster_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum MonsterOffset {}
@@ -85,8 +90,8 @@
}
}
-impl std::fmt::Debug for Monster<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for Monster<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("Monster");
ds.finish()
}
diff --git a/tests/monster_test/my_game/in_parent_namespace_generated.rs b/tests/monster_test/my_game/in_parent_namespace_generated.rs
index aabd4b8..263fae7 100644
--- a/tests/monster_test/my_game/in_parent_namespace_generated.rs
+++ b/tests/monster_test/my_game/in_parent_namespace_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum InParentNamespaceOffset {}
@@ -85,8 +90,8 @@
}
}
-impl std::fmt::Debug for InParentNamespace<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for InParentNamespace<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("InParentNamespace");
ds.finish()
}
diff --git a/tests/monster_test/my_game/other_name_space/from_include_generated.rs b/tests/monster_test/my_game/other_name_space/from_include_generated.rs
index 048bafd..3c5165d 100644
--- a/tests/monster_test/my_game/other_name_space/from_include_generated.rs
+++ b/tests/monster_test/my_game/other_name_space/from_include_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -34,8 +39,8 @@
}
}
}
-impl std::fmt::Debug for FromInclude {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for FromInclude {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
if let Some(name) = self.variant_name() {
f.write_str(name)
} else {
diff --git a/tests/monster_test/my_game/other_name_space/table_b_generated.rs b/tests/monster_test/my_game/other_name_space/table_b_generated.rs
index 46a99cb..da7b937 100644
--- a/tests/monster_test/my_game/other_name_space/table_b_generated.rs
+++ b/tests/monster_test/my_game/other_name_space/table_b_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum TableBOffset {}
@@ -103,8 +108,8 @@
}
}
-impl std::fmt::Debug for TableB<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TableB<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("TableB");
ds.field("a", &self.a());
ds.finish()
diff --git a/tests/monster_test/my_game/other_name_space/unused_generated.rs b/tests/monster_test/my_game/other_name_space/unused_generated.rs
index 1dc5913..1e4ad9c 100644
--- a/tests/monster_test/my_game/other_name_space/unused_generated.rs
+++ b/tests/monster_test/my_game/other_name_space/unused_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
// struct Unused, aligned to 4
@@ -13,8 +18,8 @@
Self([0; 4])
}
}
-impl std::fmt::Debug for Unused {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Unused {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Unused")
.field("a", &self.a())
.finish()
@@ -42,7 +47,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(self as *const Unused as *const u8, Self::size())
+ ::core::slice::from_raw_parts(self as *const Unused as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
@@ -53,7 +58,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(*self as *const Unused as *const u8, Self::size())
+ ::core::slice::from_raw_parts(*self as *const Unused as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
diff --git a/tests/monster_test/table_a_generated.rs b/tests/monster_test/table_a_generated.rs
index 9188b29..0e6a78d 100644
--- a/tests/monster_test/table_a_generated.rs
+++ b/tests/monster_test/table_a_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum TableAOffset {}
@@ -103,8 +108,8 @@
}
}
-impl std::fmt::Debug for TableA<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TableA<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("TableA");
ds.field("b", &self.b());
ds.finish()
diff --git a/tests/monster_test_bfbs_generated.h b/tests/monster_test_bfbs_generated.h
index fc611db..f8bc4aa 100644
--- a/tests/monster_test_bfbs_generated.h
+++ b/tests/monster_test_bfbs_generated.h
@@ -6,107 +6,114 @@
#include "flatbuffers/flatbuffers.h"
+// Ensure the included flatbuffers.h is the same version as when this file was
+// generated, otherwise it may not be compatible.
+static_assert(FLATBUFFERS_VERSION_MAJOR == 2 &&
+ FLATBUFFERS_VERSION_MINOR == 0 &&
+ FLATBUFFERS_VERSION_REVISION == 8,
+ "Non-compatible flatbuffers version included");
+
namespace MyGame {
namespace Example {
struct MonsterBinarySchema {
static const uint8_t *data() {
// Buffer containing the binary schema.
- static const uint8_t bfbsData[14648] = {
- 0x20,0x00,0x00,0x00,0x42,0x46,0x42,0x53,0x00,0x00,0x00,0x00,0x14,0x00,0x20,0x00,0x04,0x00,0x08,0x00,
- 0x0C,0x00,0x10,0x00,0x14,0x00,0x18,0x00,0x00,0x00,0x1C,0x00,0x14,0x00,0x00,0x00,0x58,0x00,0x00,0x00,
- 0x34,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x9C,0x0E,0x00,0x00,0x08,0x00,0x00,0x00,
- 0x7C,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xD8,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x6D,0x6F,0x6E,0x00,
- 0x04,0x00,0x00,0x00,0x4D,0x4F,0x4E,0x53,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x48,0x05,0x00,0x00,
- 0xB4,0x02,0x00,0x00,0xF4,0x03,0x00,0x00,0x00,0x09,0x00,0x00,0x8C,0x06,0x00,0x00,0xB8,0x07,0x00,0x00,
- 0xE8,0x0A,0x00,0x00,0x0E,0x00,0x00,0x00,0x10,0x31,0x00,0x00,0x4C,0x0E,0x00,0x00,0xE4,0x2D,0x00,0x00,
- 0xC0,0x2E,0x00,0x00,0xD8,0x2F,0x00,0x00,0x18,0x35,0x00,0x00,0xF8,0x33,0x00,0x00,0x70,0x0B,0x00,0x00,
- 0xF0,0x31,0x00,0x00,0xE0,0x35,0x00,0x00,0x18,0x36,0x00,0x00,0x08,0x37,0x00,0x00,0xBC,0x37,0x00,0x00,
- 0x64,0x36,0x00,0x00,0x03,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0xEC,0xCB,0xFF,0xFF,0x0C,0x36,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x58,0x36,0x00,0x00,
- 0x00,0xCC,0xFF,0xFF,0xAC,0x37,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x44,0x36,0x00,0x00,
- 0x9C,0x37,0x00,0x00,0x18,0xCC,0xFF,0xFF,0x38,0x36,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
- 0x2C,0x36,0x00,0x00,0x84,0x37,0x00,0x00,0x00,0x00,0x0E,0x00,0x14,0x00,0x04,0x00,0x08,0x00,0x00,0x00,
+ static const uint8_t bfbsData[14784] = {
+ 0x1C,0x00,0x00,0x00,0x42,0x46,0x42,0x53,0x14,0x00,0x20,0x00,0x04,0x00,0x08,0x00,0x0C,0x00,0x10,0x00,
+ 0x14,0x00,0x18,0x00,0x00,0x00,0x1C,0x00,0x14,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x34,0x00,0x00,0x00,
+ 0x24,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0xA0,0x0E,0x00,0x00,0x08,0x00,0x00,0x00,0x80,0x00,0x00,0x00,
+ 0x01,0x00,0x00,0x00,0xDC,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x6D,0x6F,0x6E,0x00,0x04,0x00,0x00,0x00,
+ 0x4D,0x4F,0x4E,0x53,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x4C,0x05,0x00,0x00,0xB8,0x02,0x00,0x00,
+ 0xF8,0x03,0x00,0x00,0x04,0x09,0x00,0x00,0x90,0x06,0x00,0x00,0xBC,0x07,0x00,0x00,0xEC,0x0A,0x00,0x00,
+ 0x0F,0x00,0x00,0x00,0x9C,0x31,0x00,0x00,0x50,0x0E,0x00,0x00,0xE8,0x2D,0x00,0x00,0xC4,0x2E,0x00,0x00,
+ 0x64,0x30,0x00,0x00,0xD8,0x2F,0x00,0x00,0xA0,0x35,0x00,0x00,0x80,0x34,0x00,0x00,0x70,0x0B,0x00,0x00,
+ 0x78,0x32,0x00,0x00,0x68,0x36,0x00,0x00,0xA0,0x36,0x00,0x00,0x90,0x37,0x00,0x00,0x44,0x38,0x00,0x00,
+ 0xEC,0x36,0x00,0x00,0x03,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x64,0xCB,0xFF,0xFF,0x94,0x36,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xE0,0x36,0x00,0x00,
+ 0x78,0xCB,0xFF,0xFF,0x34,0x38,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0xCC,0x36,0x00,0x00,
+ 0x24,0x38,0x00,0x00,0x90,0xCB,0xFF,0xFF,0xC0,0x36,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
+ 0xB4,0x36,0x00,0x00,0x0C,0x38,0x00,0x00,0x00,0x00,0x0E,0x00,0x14,0x00,0x04,0x00,0x08,0x00,0x00,0x00,
0x0C,0x00,0x10,0x00,0x0E,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x08,0x00,0x00,0x00,
- 0xAC,0x35,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x88,0x01,0x00,0x00,0xF4,0x00,0x00,0x00,
+ 0x34,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x88,0x01,0x00,0x00,0xF4,0x00,0x00,0x00,
0x90,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x1D,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,0x6D,0x65,0x2E,0x45,
0x78,0x61,0x6D,0x70,0x6C,0x65,0x2E,0x4D,0x6F,0x6E,0x73,0x74,0x65,0x72,0x53,0x74,0x6F,0x72,0x61,0x67,
0x65,0x00,0x00,0x00,0xBA,0xFE,0xFF,0xFF,0x48,0x00,0x00,0x00,0x5C,0x0D,0x00,0x00,0xD4,0x2D,0x00,0x00,
0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0xB4,0xCC,0xFF,0xFF,0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x62,0x69,0x64,0x69,
+ 0x2C,0xCC,0xFF,0xFF,0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x62,0x69,0x64,0x69,
0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x73,0x74,0x72,0x65,0x61,0x6D,0x69,0x6E,0x67,0x00,0x00,0x00,
0x12,0x00,0x00,0x00,0x47,0x65,0x74,0x4D,0x69,0x6E,0x4D,0x61,0x78,0x48,0x69,0x74,0x50,0x6F,0x69,0x6E,
0x74,0x73,0x00,0x00,0x1E,0xFF,0xFF,0xFF,0x48,0x00,0x00,0x00,0xF8,0x0C,0x00,0x00,0x70,0x2D,0x00,0x00,
0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x18,0xCD,0xFF,0xFF,0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x63,0x6C,0x69,0x65,
+ 0x90,0xCC,0xFF,0xFF,0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x63,0x6C,0x69,0x65,
0x6E,0x74,0x00,0x00,0x09,0x00,0x00,0x00,0x73,0x74,0x72,0x65,0x61,0x6D,0x69,0x6E,0x67,0x00,0x00,0x00,
0x0E,0x00,0x00,0x00,0x47,0x65,0x74,0x4D,0x61,0x78,0x48,0x69,0x74,0x50,0x6F,0x69,0x6E,0x74,0x00,0x00,
0x7E,0xFF,0xFF,0xFF,0x70,0x00,0x00,0x00,0x14,0x2D,0x00,0x00,0x94,0x0C,0x00,0x00,0x0C,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x7C,0xCD,0xFF,0xFF,0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x73,0x65,0x72,0x76,
+ 0xF4,0xCC,0xFF,0xFF,0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x73,0x65,0x72,0x76,
0x65,0x72,0x00,0x00,0x09,0x00,0x00,0x00,0x73,0x74,0x72,0x65,0x61,0x6D,0x69,0x6E,0x67,0x00,0x00,0x00,
- 0xA4,0xCD,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x30,0x00,0x00,0x00,
+ 0x1C,0xCD,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x30,0x00,0x00,0x00,
0x0A,0x00,0x00,0x00,0x69,0x64,0x65,0x6D,0x70,0x6F,0x74,0x65,0x6E,0x74,0x00,0x00,0x08,0x00,0x00,0x00,
0x52,0x65,0x74,0x72,0x69,0x65,0x76,0x65,0x00,0x00,0x0E,0x00,0x18,0x00,0x04,0x00,0x08,0x00,0x0C,0x00,
0x10,0x00,0x14,0x00,0x0E,0x00,0x00,0x00,0x48,0x00,0x00,0x00,0x08,0x0C,0x00,0x00,0x80,0x2C,0x00,0x00,
0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x08,0xCE,0xFF,0xFF,0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x6E,0x6F,0x6E,0x65,
+ 0x80,0xCD,0xFF,0xFF,0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x6E,0x6F,0x6E,0x65,
0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x73,0x74,0x72,0x65,0x61,0x6D,0x69,0x6E,0x67,0x00,0x00,0x00,
0x05,0x00,0x00,0x00,0x53,0x74,0x6F,0x72,0x65,0x00,0x00,0x00,0x82,0xFD,0xFF,0xFF,0x00,0x00,0x00,0x01,
- 0x40,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0xA8,0x33,0x00,0x00,
- 0x00,0x00,0x00,0x00,0xBC,0xCD,0xFF,0xFF,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x40,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x30,0x34,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x34,0xCD,0xFF,0xFF,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xE0,0x00,0x00,0x00,0xA4,0x00,0x00,0x00,0x68,0x00,0x00,0x00,
0x2C,0x00,0x00,0x00,0x22,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,0x6D,0x65,0x2E,0x45,0x78,0x61,0x6D,0x70,
0x6C,0x65,0x2E,0x41,0x6E,0x79,0x41,0x6D,0x62,0x69,0x67,0x75,0x6F,0x75,0x73,0x41,0x6C,0x69,0x61,0x73,
0x65,0x73,0x00,0x00,0x7E,0xF8,0xFF,0xFF,0x2C,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x10,0x00,0x00,0x00,
- 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0xCB,0xFF,0xFF,
+ 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0xCA,0xFF,0xFF,
0x00,0x00,0x00,0x0F,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x4D,0x33,0x00,0x00,
0xB6,0xF8,0xFF,0xFF,0x2C,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xB0,0xCB,0xFF,0xFF,0x00,0x00,0x00,0x0F,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x28,0xCB,0xFF,0xFF,0x00,0x00,0x00,0x0F,
0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x4D,0x32,0x00,0x00,0xEE,0xF8,0xFF,0xFF,
0x2C,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE8,0xCB,0xFF,0xFF,0x00,0x00,0x00,0x0F,0x01,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0xCB,0xFF,0xFF,0x00,0x00,0x00,0x0F,0x01,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x4D,0x31,0x00,0x00,0x72,0xF8,0xFF,0xFF,0x1C,0x00,0x00,0x00,
0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x64,0xF8,0xFF,0xFF,0x01,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x4E,0x4F,0x4E,0x45,0x00,0x00,0x00,0x00,0xC6,0xFE,0xFF,0xFF,
0x00,0x00,0x00,0x01,0x40,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x08,0x00,0x00,0x00,
- 0x64,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCF,0xFF,0xFF,0x00,0x00,0x00,0x01,0x02,0x00,0x00,0x00,
+ 0xEC,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0xCE,0xFF,0xFF,0x00,0x00,0x00,0x01,0x02,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xD8,0x00,0x00,0x00,0xA0,0x00,0x00,0x00,
0x64,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,0x6D,0x65,0x2E,0x45,
0x78,0x61,0x6D,0x70,0x6C,0x65,0x2E,0x41,0x6E,0x79,0x55,0x6E,0x69,0x71,0x75,0x65,0x41,0x6C,0x69,0x61,
0x73,0x65,0x73,0x00,0xBE,0xF9,0xFF,0xFF,0x2C,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x10,0x00,0x00,0x00,
- 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xB8,0xCC,0xFF,0xFF,
- 0x00,0x00,0x00,0x0F,0x09,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x4D,0x32,0x00,0x00,
+ 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0xCC,0xFF,0xFF,
+ 0x00,0x00,0x00,0x0F,0x0A,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x4D,0x32,0x00,0x00,
0xF6,0xF9,0xFF,0xFF,0x2C,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0xCC,0xFF,0xFF,0x00,0x00,0x00,0x0F,
- 0x06,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x54,0x53,0x00,0x00,0x1E,0xFC,0xFF,0xFF,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x68,0xCC,0xFF,0xFF,0x00,0x00,0x00,0x0F,
+ 0x07,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x54,0x53,0x00,0x00,0x1E,0xFC,0xFF,0xFF,
0x28,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x24,0xCD,0xFF,0xFF,0x00,0x00,0x00,0x0F,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x9C,0xCC,0xFF,0xFF,0x00,0x00,0x00,0x0F,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0x4D,0x00,0x00,0x00,0xAE,0xF9,0xFF,0xFF,0x1C,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xA0,0xF9,0xFF,0xFF,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x4E,0x4F,0x4E,0x45,0x00,0x00,0x12,0x00,0x1C,0x00,0x08,0x00,0x0C,0x00,0x07,0x00,
0x10,0x00,0x00,0x00,0x14,0x00,0x18,0x00,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x40,0x00,0x00,0x00,
- 0x28,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x18,0x31,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x4C,0xD0,0xFF,0xFF,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x28,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0xA0,0x31,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xC4,0xCF,0xFF,0xFF,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0xB4,0x00,0x00,0x00,0x68,0x00,0x00,0x00,0x1C,0x00,0x00,0x00,
0x12,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,0x6D,0x65,0x2E,0x45,0x78,0x61,0x6D,0x70,0x6C,0x65,0x2E,0x41,
0x6E,0x79,0x00,0x00,0xEE,0xFC,0xFF,0xFF,0x28,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,
- 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF4,0xCD,0xFF,0xFF,0x00,0x00,0x00,0x0F,
- 0x09,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x17,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,0x6D,0x65,0x5F,0x45,
+ 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6C,0xCD,0xFF,0xFF,0x00,0x00,0x00,0x0F,
+ 0x0A,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x17,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,0x6D,0x65,0x5F,0x45,
0x78,0x61,0x6D,0x70,0x6C,0x65,0x32,0x5F,0x4D,0x6F,0x6E,0x73,0x74,0x65,0x72,0x00,0x36,0xFD,0xFF,0xFF,
0x28,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x3C,0xCE,0xFF,0xFF,0x00,0x00,0x00,0x0F,0x06,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xB4,0xCD,0xFF,0xFF,0x00,0x00,0x00,0x0F,0x07,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
0x17,0x00,0x00,0x00,0x54,0x65,0x73,0x74,0x53,0x69,0x6D,0x70,0x6C,0x65,0x54,0x61,0x62,0x6C,0x65,0x57,
0x69,0x74,0x68,0x45,0x6E,0x75,0x6D,0x00,0x7E,0xFD,0xFF,0xFF,0x28,0x00,0x00,0x00,0x14,0x00,0x00,0x00,
- 0x0C,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x84,0xCE,0xFF,0xFF,
+ 0x0C,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0xCD,0xFF,0xFF,
0x00,0x00,0x00,0x0F,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x4D,0x6F,0x6E,0x73,
0x74,0x65,0x72,0x00,0x12,0xFB,0xFF,0xFF,0x1C,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x04,0xFB,0xFF,0xFF,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
0x4E,0x4F,0x4E,0x45,0x00,0x00,0x00,0x00,0xA2,0xFD,0xFF,0xFF,0x6C,0x00,0x00,0x00,0x58,0x00,0x00,0x00,
- 0x40,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0xC4,0x2F,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x48,0xD2,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x40,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x4C,0x30,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xC0,0xD1,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x62,0x69,0x74,0x5F,0x66,0x6C,0x61,0x67,
- 0x73,0x00,0x00,0x00,0xCC,0xD1,0xFF,0xFF,0x00,0x00,0x00,0x0A,0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,
+ 0x73,0x00,0x00,0x00,0x44,0xD1,0xFF,0xFF,0x00,0x00,0x00,0x0A,0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x98,0x00,0x00,0x00,0x5C,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
0x17,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,0x6D,0x65,0x2E,0x45,0x78,0x61,0x6D,0x70,0x6C,0x65,0x2E,0x4C,
0x6F,0x6E,0x67,0x45,0x6E,0x75,0x6D,0x00,0x7E,0xFC,0xFF,0xFF,0x28,0x00,0x00,0x00,0x18,0x00,0x00,0x00,
@@ -118,8 +125,8 @@
0xDE,0xFE,0xFF,0xFF,0x24,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x34,0xFC,0xFF,0xFF,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
0x07,0x00,0x00,0x00,0x4C,0x6F,0x6E,0x67,0x4F,0x6E,0x65,0x00,0xDE,0xFC,0xFF,0xFF,0x40,0x00,0x00,0x00,
- 0x28,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x98,0x2E,0x00,0x00,0x00,0x00,0x00,0x00,
- 0xCC,0xD2,0xFF,0xFF,0x00,0x00,0x00,0x03,0x05,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x28,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x20,0x2F,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x44,0xD2,0xFF,0xFF,0x00,0x00,0x00,0x03,0x05,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0xC8,0x00,0x00,0x00,0x8C,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0x1C,0x00,0x00,0x00,
0x13,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,0x6D,0x65,0x2E,0x45,0x78,0x61,0x6D,0x70,0x6C,0x65,0x2E,0x52,
0x61,0x63,0x65,0x00,0x6E,0xFF,0xFF,0xFF,0x24,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,
@@ -134,12 +141,12 @@
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x64,0xFD,0xFF,0xFF,0x01,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x4E,0x6F,0x6E,0x65,0x00,0x00,0x12,0x00,0x1C,0x00,0x04,0x00,
0x08,0x00,0x00,0x00,0x0C,0x00,0x10,0x00,0x14,0x00,0x18,0x00,0x12,0x00,0x00,0x00,0x9C,0x00,0x00,0x00,
- 0x88,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x54,0x2D,0x00,0x00,
+ 0x88,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0xDC,0x2D,0x00,0x00,
0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x27,0x00,0x00,0x00,0x20,0x43,0x6F,0x6D,0x70,0x6F,0x73,0x69,
0x74,0x65,0x20,0x63,0x6F,0x6D,0x70,0x6F,0x6E,0x65,0x6E,0x74,0x73,0x20,0x6F,0x66,0x20,0x4D,0x6F,0x6E,
0x73,0x74,0x65,0x72,0x20,0x63,0x6F,0x6C,0x6F,0x72,0x2E,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0xE8,0xD4,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x30,0x00,0x00,0x00,
- 0x09,0x00,0x00,0x00,0x62,0x69,0x74,0x5F,0x66,0x6C,0x61,0x67,0x73,0x00,0x00,0x00,0x6C,0xD4,0xFF,0xFF,
+ 0x60,0xD4,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x30,0x00,0x00,0x00,
+ 0x09,0x00,0x00,0x00,0x62,0x69,0x74,0x5F,0x66,0x6C,0x61,0x67,0x73,0x00,0x00,0x00,0xE4,0xD3,0xFF,0xFF,
0x00,0x00,0x00,0x04,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
0x18,0x01,0x00,0x00,0x84,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,
0x6D,0x65,0x2E,0x45,0x78,0x61,0x6D,0x70,0x6C,0x65,0x2E,0x43,0x6F,0x6C,0x6F,0x72,0x00,0x00,0x00,0x00,
@@ -159,51 +166,51 @@
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0xFF,0xFF,0xFF,0x01,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x52,0x65,0x64,0x00,0x00,0x00,0x12,0x00,0x18,0x00,0x04,0x00,
0x08,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x10,0x00,0x14,0x00,0x12,0x00,0x00,0x00,0x34,0x00,0x00,0x00,
- 0x28,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x18,0x2D,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0xD6,0xFF,0xFF,0x00,0x00,0x00,0x09,0x06,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x28,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0xA0,0x2D,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x78,0xD5,0xFF,0xFF,0x00,0x00,0x00,0x09,0x06,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x21,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,0x6D,0x65,0x2E,0x4F,
0x74,0x68,0x65,0x72,0x4E,0x61,0x6D,0x65,0x53,0x70,0x61,0x63,0x65,0x2E,0x46,0x72,0x6F,0x6D,0x49,0x6E,
0x63,0x6C,0x75,0x64,0x65,0x00,0x0E,0x00,0x10,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x0C,0x00,
0x0E,0x00,0x00,0x00,0x2C,0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x10,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x08,0x00,0x10,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0A,0x00,0x00,0x00,0x49,0x6E,0x63,0x6C,0x75,0x64,0x65,0x56,
- 0x61,0x6C,0x00,0x00,0x6C,0xD4,0xFF,0xFF,0x4C,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
- 0x08,0x00,0x00,0x00,0xB8,0x2A,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0xE4,0x00,0x00,0x00,
+ 0x61,0x6C,0x00,0x00,0xE4,0xD3,0xFF,0xFF,0x4C,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x08,0x00,0x00,0x00,0x40,0x2B,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0xE4,0x00,0x00,0x00,
0xB0,0x00,0x00,0x00,0xF0,0x01,0x00,0x00,0x90,0x01,0x00,0x00,0x30,0x01,0x00,0x00,0x60,0x02,0x00,0x00,
0xB0,0x01,0x00,0x00,0x54,0x01,0x00,0x00,0xF0,0x00,0x00,0x00,0x04,0x02,0x00,0x00,0x5C,0x00,0x00,0x00,
0x24,0x00,0x00,0x00,0x1A,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,0x6D,0x65,0x2E,0x45,0x78,0x61,0x6D,0x70,
- 0x6C,0x65,0x2E,0x54,0x79,0x70,0x65,0x41,0x6C,0x69,0x61,0x73,0x65,0x73,0x00,0x00,0x88,0xDB,0xFF,0xFF,
+ 0x6C,0x65,0x2E,0x54,0x79,0x70,0x65,0x41,0x6C,0x69,0x61,0x73,0x65,0x73,0x00,0x00,0x00,0xDB,0xFF,0xFF,
0x00,0x00,0x00,0x01,0x0B,0x00,0x1A,0x00,0x1C,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x14,0xE1,0xFF,0xFF,0x00,0x00,0x0E,0x0C,0x08,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x76,0x66,0x36,0x34,0x00,0x00,0x00,0x00,0xBC,0xDB,0xFF,0xFF,0x00,0x00,0x00,0x01,0x0A,0x00,0x18,0x00,
+ 0x76,0x66,0x36,0x34,0x00,0x00,0x00,0x00,0x34,0xDB,0xFF,0xFF,0x00,0x00,0x00,0x01,0x0A,0x00,0x18,0x00,
0x1C,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x48,0xE1,0xFF,0xFF,
- 0x00,0x00,0x0E,0x03,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x76,0x38,0x00,0x00,0xD2,0xD8,0xFF,0xFF,
+ 0x00,0x00,0x0E,0x03,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x76,0x38,0x00,0x00,0x4A,0xD8,0xFF,0xFF,
0x09,0x00,0x16,0x00,0x20,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x9C,0xD6,0xFF,0xFF,0x00,0x00,0x00,0x0C,0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
- 0x66,0x36,0x34,0x00,0x02,0xD9,0xFF,0xFF,0x08,0x00,0x14,0x00,0x1C,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0xD4,0xFF,0xFF,0x00,0x00,0x00,0x0B,0x01,0x00,0x00,0x00,
- 0x03,0x00,0x00,0x00,0x66,0x33,0x32,0x00,0x2E,0xD9,0xFF,0xFF,0x07,0x00,0x12,0x00,0x20,0x00,0x00,0x00,
- 0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0xD6,0xFF,0xFF,0x00,0x00,0x00,0x0A,
- 0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x75,0x36,0x34,0x00,0x5E,0xD9,0xFF,0xFF,
+ 0x14,0xD6,0xFF,0xFF,0x00,0x00,0x00,0x0C,0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
+ 0x66,0x36,0x34,0x00,0x7A,0xD8,0xFF,0xFF,0x08,0x00,0x14,0x00,0x1C,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,
+ 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x8C,0xD3,0xFF,0xFF,0x00,0x00,0x00,0x0B,0x01,0x00,0x00,0x00,
+ 0x03,0x00,0x00,0x00,0x66,0x33,0x32,0x00,0xA6,0xD8,0xFF,0xFF,0x07,0x00,0x12,0x00,0x20,0x00,0x00,0x00,
+ 0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0xD6,0xFF,0xFF,0x00,0x00,0x00,0x0A,
+ 0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x75,0x36,0x34,0x00,0xD6,0xD8,0xFF,0xFF,
0x06,0x00,0x10,0x00,0x20,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x28,0xD7,0xFF,0xFF,0x00,0x00,0x00,0x09,0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
- 0x69,0x36,0x34,0x00,0x8E,0xD9,0xFF,0xFF,0x05,0x00,0x0E,0x00,0x1C,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xA0,0xD4,0xFF,0xFF,0x00,0x00,0x00,0x08,0x01,0x00,0x00,0x00,
- 0x03,0x00,0x00,0x00,0x75,0x33,0x32,0x00,0xBA,0xD9,0xFF,0xFF,0x04,0x00,0x0C,0x00,0x1C,0x00,0x00,0x00,
- 0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCC,0xD4,0xFF,0xFF,0x00,0x00,0x00,0x07,
- 0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x69,0x33,0x32,0x00,0xE6,0xD9,0xFF,0xFF,0x03,0x00,0x0A,0x00,
- 0x20,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xB0,0xD7,0xFF,0xFF,
+ 0xA0,0xD6,0xFF,0xFF,0x00,0x00,0x00,0x09,0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
+ 0x69,0x36,0x34,0x00,0x06,0xD9,0xFF,0xFF,0x05,0x00,0x0E,0x00,0x1C,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,
+ 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0xD4,0xFF,0xFF,0x00,0x00,0x00,0x08,0x01,0x00,0x00,0x00,
+ 0x03,0x00,0x00,0x00,0x75,0x33,0x32,0x00,0x32,0xD9,0xFF,0xFF,0x04,0x00,0x0C,0x00,0x1C,0x00,0x00,0x00,
+ 0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0xD4,0xFF,0xFF,0x00,0x00,0x00,0x07,
+ 0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x69,0x33,0x32,0x00,0x5E,0xD9,0xFF,0xFF,0x03,0x00,0x0A,0x00,
+ 0x20,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x28,0xD7,0xFF,0xFF,
0x00,0x00,0x00,0x06,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x75,0x31,0x36,0x00,
- 0x16,0xDA,0xFF,0xFF,0x02,0x00,0x08,0x00,0x20,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0xE0,0xD7,0xFF,0xFF,0x00,0x00,0x00,0x05,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
- 0x03,0x00,0x00,0x00,0x69,0x31,0x36,0x00,0x46,0xDA,0xFF,0xFF,0x01,0x00,0x06,0x00,0x20,0x00,0x00,0x00,
- 0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0xD8,0xFF,0xFF,0x00,0x00,0x00,0x04,
+ 0x8E,0xD9,0xFF,0xFF,0x02,0x00,0x08,0x00,0x20,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x58,0xD7,0xFF,0xFF,0x00,0x00,0x00,0x05,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x03,0x00,0x00,0x00,0x69,0x31,0x36,0x00,0xBE,0xD9,0xFF,0xFF,0x01,0x00,0x06,0x00,0x20,0x00,0x00,0x00,
+ 0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x88,0xD7,0xFF,0xFF,0x00,0x00,0x00,0x04,
0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x75,0x38,0x00,0x00,0x00,0x00,0x1A,0x00,
0x14,0x00,0x08,0x00,0x0C,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x10,0x00,0x1A,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x20,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5C,0xD8,0xFF,0xFF,0x00,0x00,0x00,0x03,0x01,0x00,0x00,0x00,
- 0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x38,0x00,0x00,0x30,0xD7,0xFF,0xFF,0x30,0x01,0x00,0x00,
- 0x50,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0xF4,0x27,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xD4,0xD7,0xFF,0xFF,0x00,0x00,0x00,0x03,0x01,0x00,0x00,0x00,
+ 0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x38,0x00,0x00,0xA8,0xD6,0xFF,0xFF,0x30,0x01,0x00,0x00,
+ 0x50,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x7C,0x28,0x00,0x00,0x01,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x33,0x00,0x00,0x00,0x20,0x61,0x6E,0x20,0x65,0x78,0x61,0x6D,0x70,0x6C,0x65,0x20,
0x64,0x6F,0x63,0x75,0x6D,0x65,0x6E,0x74,0x61,0x74,0x69,0x6F,0x6E,0x20,0x63,0x6F,0x6D,0x6D,0x65,0x6E,
0x74,0x3A,0x20,0x22,0x6D,0x6F,0x6E,0x73,0x74,0x65,0x72,0x20,0x6F,0x62,0x6A,0x65,0x63,0x74,0x22,0x00,
@@ -221,112 +228,112 @@
0x16,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,0x6D,0x65,0x2E,0x45,0x78,0x61,0x6D,0x70,0x6C,0x65,0x2E,0x4D,
0x6F,0x6E,0x73,0x74,0x65,0x72,0x00,0x00,0x62,0xFD,0xFF,0xFF,0x35,0x00,0x6E,0x00,0x54,0x00,0x00,0x00,
0x3C,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x70,0xDB,0xFF,0xFF,0x10,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xE8,0xDA,0xFF,0xFF,0x10,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x35,0x33,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,
- 0xEC,0xDA,0xFF,0xFF,0x00,0x00,0x00,0x0A,0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x64,0xDA,0xFF,0xFF,0x00,0x00,0x00,0x0A,0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
0x18,0x00,0x00,0x00,0x6C,0x6F,0x6E,0x67,0x5F,0x65,0x6E,0x75,0x6D,0x5F,0x6E,0x6F,0x72,0x6D,0x61,0x6C,
0x5F,0x64,0x65,0x66,0x61,0x75,0x6C,0x74,0x00,0x00,0x00,0x00,0x62,0xE6,0xFF,0xFF,0x34,0x00,0x6C,0x00,
0x4C,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xE4,0xDB,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x02,0x00,0x00,0x00,0x35,0x32,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x60,0xDB,0xFF,0xFF,
+ 0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x5C,0xDB,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x02,0x00,0x00,0x00,0x35,0x32,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0xD8,0xDA,0xFF,0xFF,
0x00,0x00,0x00,0x0A,0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1A,0x00,0x00,0x00,
0x6C,0x6F,0x6E,0x67,0x5F,0x65,0x6E,0x75,0x6D,0x5F,0x6E,0x6F,0x6E,0x5F,0x65,0x6E,0x75,0x6D,0x5F,0x64,
0x65,0x66,0x61,0x75,0x6C,0x74,0x00,0x00,0xEC,0xE5,0xFF,0xFF,0x00,0x00,0x00,0x01,0x33,0x00,0x6A,0x00,
0x74,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x02,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x60,0xDC,0xFF,0xFF,0x10,0x00,0x00,0x00,
+ 0x02,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xD8,0xDB,0xFF,0xFF,0x10,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x0D,0x00,0x00,0x00,0x6E,0x61,0x74,0x69,
- 0x76,0x65,0x5F,0x69,0x6E,0x6C,0x69,0x6E,0x65,0x00,0x00,0x00,0x88,0xDC,0xFF,0xFF,0x10,0x00,0x00,0x00,
+ 0x76,0x65,0x5F,0x69,0x6E,0x6C,0x69,0x6E,0x65,0x00,0x00,0x00,0x00,0xDC,0xFF,0xFF,0x10,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x35,0x31,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,
- 0x50,0xD9,0xFF,0xFF,0x00,0x00,0x00,0x0F,0x05,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0D,0x00,0x00,0x00,
+ 0xC8,0xD8,0xFF,0xFF,0x00,0x00,0x00,0x0F,0x06,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0D,0x00,0x00,0x00,
0x6E,0x61,0x74,0x69,0x76,0x65,0x5F,0x69,0x6E,0x6C,0x69,0x6E,0x65,0x00,0x00,0x00,0x80,0xE6,0xFF,0xFF,
0x00,0x00,0x00,0x01,0x32,0x00,0x68,0x00,0x48,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xF0,0xDC,0xFF,0xFF,
+ 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x68,0xDC,0xFF,0xFF,
0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x35,0x30,0x00,0x00,0x02,0x00,0x00,0x00,
0x69,0x64,0x00,0x00,0x38,0xE8,0xFF,0xFF,0x00,0x00,0x0E,0x0F,0x03,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
0x18,0x00,0x00,0x00,0x73,0x63,0x61,0x6C,0x61,0x72,0x5F,0x6B,0x65,0x79,0x5F,0x73,0x6F,0x72,0x74,0x65,
0x64,0x5F,0x74,0x61,0x62,0x6C,0x65,0x73,0x00,0x00,0x00,0x00,0xF4,0xE6,0xFF,0xFF,0x00,0x00,0x00,0x01,
0x31,0x00,0x66,0x00,0x78,0x00,0x00,0x00,0x68,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x68,0xDD,0xFF,0xFF,
+ 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xE0,0xDC,0xFF,0xFF,
0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x4D,0x6F,0x6E,0x73,0x74,0x65,0x72,0x00,
0x11,0x00,0x00,0x00,0x6E,0x65,0x73,0x74,0x65,0x64,0x5F,0x66,0x6C,0x61,0x74,0x62,0x75,0x66,0x66,0x65,
- 0x72,0x00,0x00,0x00,0x98,0xDD,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
+ 0x72,0x00,0x00,0x00,0x10,0xDD,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
0x34,0x39,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x0C,0xE7,0xFF,0xFF,0x00,0x00,0x0E,0x04,
0x01,0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x74,0x65,0x73,0x74,0x72,0x65,0x71,0x75,0x69,0x72,0x65,0x64,
0x6E,0x65,0x73,0x74,0x65,0x64,0x66,0x6C,0x61,0x74,0x62,0x75,0x66,0x66,0x65,0x72,0x00,0x00,0x1A,0x00,
0x20,0x00,0x08,0x00,0x0C,0x00,0x04,0x00,0x06,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x10,0x00,0x14,0x00,0x1A,0x00,0x00,0x00,0x30,0x00,0x64,0x00,0x54,0x00,0x00,0x00,0x3C,0x00,0x00,0x00,
0x14,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,
- 0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x28,0xDE,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x02,0x00,0x00,0x00,0x34,0x38,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0xA4,0xDD,0xFF,0xFF,
+ 0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xA0,0xDD,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x02,0x00,0x00,0x00,0x34,0x38,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x1C,0xDD,0xFF,0xFF,
0x00,0x00,0x00,0x03,0x05,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0B,0x00,0x00,0x00,
0x73,0x69,0x67,0x6E,0x65,0x64,0x5F,0x65,0x6E,0x75,0x6D,0x00,0x20,0xE8,0xFF,0xFF,0x00,0x00,0x00,0x01,
0x2F,0x00,0x62,0x00,0x48,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x90,0xDE,0xFF,0xFF,0x10,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x08,0xDE,0xFF,0xFF,0x10,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x34,0x37,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,
0xD8,0xE9,0xFF,0xFF,0x00,0x00,0x0E,0x04,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,
0x76,0x65,0x63,0x74,0x6F,0x72,0x5F,0x6F,0x66,0x5F,0x65,0x6E,0x75,0x6D,0x73,0x00,0x88,0xE8,0xFF,0xFF,
0x00,0x00,0x00,0x01,0x2E,0x00,0x60,0x00,0x48,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xF8,0xDE,0xFF,0xFF,
+ 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x70,0xDE,0xFF,0xFF,
0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x34,0x36,0x00,0x00,0x02,0x00,0x00,0x00,
- 0x69,0x64,0x00,0x00,0xC0,0xDB,0xFF,0xFF,0x00,0x00,0x00,0x10,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x69,0x64,0x00,0x00,0x38,0xDB,0xFF,0xFF,0x00,0x00,0x00,0x10,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
0x0D,0x00,0x00,0x00,0x61,0x6E,0x79,0x5F,0x61,0x6D,0x62,0x69,0x67,0x75,0x6F,0x75,0x73,0x00,0x00,0x00,
0xDA,0xE9,0xFF,0xFF,0x2D,0x00,0x5E,0x00,0x4C,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x5C,0xDF,0xFF,0xFF,
+ 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xD4,0xDE,0xFF,0xFF,
0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x34,0x35,0x00,0x00,0x02,0x00,0x00,0x00,
- 0x69,0x64,0x00,0x00,0xD8,0xDE,0xFF,0xFF,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x69,0x64,0x00,0x00,0x50,0xDE,0xFF,0xFF,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x61,0x6E,0x79,0x5F,0x61,0x6D,0x62,0x69,0x67,0x75,0x6F,0x75,
0x73,0x5F,0x74,0x79,0x70,0x65,0x00,0x00,0x5C,0xE9,0xFF,0xFF,0x00,0x00,0x00,0x01,0x2C,0x00,0x5C,0x00,
0x48,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xCC,0xDF,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x02,0x00,0x00,0x00,0x34,0x34,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x94,0xDC,0xFF,0xFF,
+ 0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x44,0xDF,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x02,0x00,0x00,0x00,0x34,0x34,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x0C,0xDC,0xFF,0xFF,
0x00,0x00,0x00,0x10,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0A,0x00,0x00,0x00,0x61,0x6E,0x79,0x5F,
0x75,0x6E,0x69,0x71,0x75,0x65,0x00,0x00,0xAA,0xEA,0xFF,0xFF,0x2B,0x00,0x5A,0x00,0x4C,0x00,0x00,0x00,
0x34,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0x2C,0xE0,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
- 0x34,0x33,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0xA8,0xDF,0xFF,0xFF,0x00,0x00,0x00,0x01,
+ 0x04,0x00,0x00,0x00,0xA4,0xDF,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
+ 0x34,0x33,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x20,0xDF,0xFF,0xFF,0x00,0x00,0x00,0x01,
0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x61,0x6E,0x79,0x5F,
0x75,0x6E,0x69,0x71,0x75,0x65,0x5F,0x74,0x79,0x70,0x65,0x00,0x28,0xEA,0xFF,0xFF,0x00,0x00,0x00,0x01,
0x2A,0x00,0x58,0x00,0x00,0x01,0x00,0x00,0xF0,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0xB0,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x50,0x00,0x00,0x00,
- 0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xA8,0xE0,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x02,0x00,0x00,0x00,0x34,0x32,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0xC4,0xE0,0xFF,0xFF,
+ 0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x20,0xE0,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x02,0x00,0x00,0x00,0x34,0x32,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x3C,0xE0,0xFF,0xFF,
0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x66,0x6E,0x76,0x31,0x61,0x5F,0x36,0x34,
- 0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x68,0x61,0x73,0x68,0x00,0x00,0x00,0x00,0xEC,0xE0,0xFF,0xFF,
+ 0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x68,0x61,0x73,0x68,0x00,0x00,0x00,0x00,0x64,0xE0,0xFF,0xFF,
0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x0B,0x00,0x00,0x00,0x52,0x65,0x66,0x65,0x72,0x72,0x61,0x62,
0x6C,0x65,0x54,0x00,0x08,0x00,0x00,0x00,0x63,0x70,0x70,0x5F,0x74,0x79,0x70,0x65,0x00,0x00,0x00,0x00,
- 0x18,0xE1,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x90,0xE0,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x10,0x00,0x00,0x00,0x63,0x70,0x70,0x5F,0x70,0x74,0x72,0x5F,0x74,0x79,0x70,0x65,0x5F,0x67,0x65,0x74,
- 0x00,0x00,0x00,0x00,0x44,0xE1,0xFF,0xFF,0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x05,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xBC,0xE0,0xFF,0xFF,0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x05,0x00,0x00,0x00,
0x6E,0x61,0x6B,0x65,0x64,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x63,0x70,0x70,0x5F,0x70,0x74,0x72,0x5F,
0x74,0x79,0x70,0x65,0x00,0x00,0x00,0x00,0xC8,0xEA,0xFF,0xFF,0x00,0x00,0x0E,0x0A,0x08,0x00,0x00,0x00,
0x1F,0x00,0x00,0x00,0x76,0x65,0x63,0x74,0x6F,0x72,0x5F,0x6F,0x66,0x5F,0x6E,0x6F,0x6E,0x5F,0x6F,0x77,
0x6E,0x69,0x6E,0x67,0x5F,0x72,0x65,0x66,0x65,0x72,0x65,0x6E,0x63,0x65,0x73,0x00,0x42,0xEC,0xFF,0xFF,
0x29,0x00,0x56,0x00,0x04,0x01,0x00,0x00,0xF0,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0xB0,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x50,0x00,0x00,0x00,
- 0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xD4,0xE1,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x02,0x00,0x00,0x00,0x34,0x31,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0xF0,0xE1,0xFF,0xFF,
+ 0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x4C,0xE1,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x02,0x00,0x00,0x00,0x34,0x31,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x68,0xE1,0xFF,0xFF,
0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x66,0x6E,0x76,0x31,0x61,0x5F,0x36,0x34,
- 0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x68,0x61,0x73,0x68,0x00,0x00,0x00,0x00,0x18,0xE2,0xFF,0xFF,
+ 0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x68,0x61,0x73,0x68,0x00,0x00,0x00,0x00,0x90,0xE1,0xFF,0xFF,
0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x0B,0x00,0x00,0x00,0x52,0x65,0x66,0x65,0x72,0x72,0x61,0x62,
0x6C,0x65,0x54,0x00,0x08,0x00,0x00,0x00,0x63,0x70,0x70,0x5F,0x74,0x79,0x70,0x65,0x00,0x00,0x00,0x00,
- 0x44,0xE2,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xBC,0xE1,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x10,0x00,0x00,0x00,0x63,0x70,0x70,0x5F,0x70,0x74,0x72,0x5F,0x74,0x79,0x70,0x65,0x5F,0x67,0x65,0x74,
- 0x00,0x00,0x00,0x00,0x70,0xE2,0xFF,0xFF,0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x05,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xE8,0xE1,0xFF,0xFF,0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x05,0x00,0x00,0x00,
0x6E,0x61,0x6B,0x65,0x64,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x63,0x70,0x70,0x5F,0x70,0x74,0x72,0x5F,
- 0x74,0x79,0x70,0x65,0x00,0x00,0x00,0x00,0x1C,0xE1,0xFF,0xFF,0x00,0x00,0x00,0x0A,0x08,0x00,0x00,0x00,
+ 0x74,0x79,0x70,0x65,0x00,0x00,0x00,0x00,0x94,0xE0,0xFF,0xFF,0x00,0x00,0x00,0x0A,0x08,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x6E,0x6F,0x6E,0x5F,0x6F,0x77,0x6E,0x69,0x6E,0x67,0x5F,0x72,
0x65,0x66,0x65,0x72,0x65,0x6E,0x63,0x65,0x00,0x00,0x00,0x00,0x80,0xEC,0xFF,0xFF,0x00,0x00,0x00,0x01,
0x28,0x00,0x54,0x00,0x10,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0xB4,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x50,0x00,0x00,0x00,
- 0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0xE3,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x02,0x00,0x00,0x00,0x34,0x30,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x1C,0xE3,0xFF,0xFF,
+ 0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x78,0xE2,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x02,0x00,0x00,0x00,0x34,0x30,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x94,0xE2,0xFF,0xFF,
0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x66,0x6E,0x76,0x31,0x61,0x5F,0x36,0x34,
- 0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x68,0x61,0x73,0x68,0x00,0x00,0x00,0x00,0x44,0xE3,0xFF,0xFF,
+ 0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x68,0x61,0x73,0x68,0x00,0x00,0x00,0x00,0xBC,0xE2,0xFF,0xFF,
0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x0B,0x00,0x00,0x00,0x52,0x65,0x66,0x65,0x72,0x72,0x61,0x62,
0x6C,0x65,0x54,0x00,0x08,0x00,0x00,0x00,0x63,0x70,0x70,0x5F,0x74,0x79,0x70,0x65,0x00,0x00,0x00,0x00,
- 0x70,0xE3,0xFF,0xFF,0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x2E,0x67,0x65,0x74,
+ 0xE8,0xE2,0xFF,0xFF,0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x2E,0x67,0x65,0x74,
0x28,0x29,0x00,0x00,0x10,0x00,0x00,0x00,0x63,0x70,0x70,0x5F,0x70,0x74,0x72,0x5F,0x74,0x79,0x70,0x65,
- 0x5F,0x67,0x65,0x74,0x00,0x00,0x00,0x00,0xA0,0xE3,0xFF,0xFF,0x20,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x5F,0x67,0x65,0x74,0x00,0x00,0x00,0x00,0x18,0xE3,0xFF,0xFF,0x20,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
0x10,0x00,0x00,0x00,0x64,0x65,0x66,0x61,0x75,0x6C,0x74,0x5F,0x70,0x74,0x72,0x5F,0x74,0x79,0x70,0x65,
0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x63,0x70,0x70,0x5F,0x70,0x74,0x72,0x5F,0x74,0x79,0x70,0x65,
0x00,0x00,0x00,0x00,0x30,0xED,0xFF,0xFF,0x00,0x00,0x0E,0x0A,0x08,0x00,0x00,0x00,0x1E,0x00,0x00,0x00,
@@ -334,20 +341,20 @@
0x72,0x65,0x66,0x65,0x72,0x65,0x6E,0x63,0x65,0x73,0x00,0x00,0xAA,0xEE,0xFF,0xFF,0x27,0x00,0x52,0x00,
0xD4,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x38,0xE4,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x33,0x39,0x00,0x00,
- 0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x54,0xE4,0xFF,0xFF,0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0xB0,0xE3,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x33,0x39,0x00,0x00,
+ 0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0xCC,0xE3,0xFF,0xFF,0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
0x08,0x00,0x00,0x00,0x66,0x6E,0x76,0x31,0x61,0x5F,0x36,0x34,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x68,0x61,0x73,0x68,0x00,0x00,0x00,0x00,0x7C,0xE4,0xFF,0xFF,0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x68,0x61,0x73,0x68,0x00,0x00,0x00,0x00,0xF4,0xE3,0xFF,0xFF,0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
0x0B,0x00,0x00,0x00,0x52,0x65,0x66,0x65,0x72,0x72,0x61,0x62,0x6C,0x65,0x54,0x00,0x08,0x00,0x00,0x00,
- 0x63,0x70,0x70,0x5F,0x74,0x79,0x70,0x65,0x00,0x00,0x00,0x00,0xA8,0xE4,0xFF,0xFF,0x14,0x00,0x00,0x00,
+ 0x63,0x70,0x70,0x5F,0x74,0x79,0x70,0x65,0x00,0x00,0x00,0x00,0x20,0xE4,0xFF,0xFF,0x14,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x6E,0x61,0x6B,0x65,0x64,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,
- 0x63,0x70,0x70,0x5F,0x70,0x74,0x72,0x5F,0x74,0x79,0x70,0x65,0x00,0x00,0x00,0x00,0x54,0xE3,0xFF,0xFF,
+ 0x63,0x70,0x70,0x5F,0x70,0x74,0x72,0x5F,0x74,0x79,0x70,0x65,0x00,0x00,0x00,0x00,0xCC,0xE2,0xFF,0xFF,
0x00,0x00,0x00,0x0A,0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x13,0x00,0x00,0x00,0x63,0x6F,0x5F,0x6F,
0x77,0x6E,0x69,0x6E,0x67,0x5F,0x72,0x65,0x66,0x65,0x72,0x65,0x6E,0x63,0x65,0x00,0xB4,0xEE,0xFF,0xFF,
0x00,0x00,0x00,0x01,0x26,0x00,0x50,0x00,0x84,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x28,0xE5,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x33,0x38,0x00,0x00,
- 0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x44,0xE5,0xFF,0xFF,0x20,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0xA0,0xE4,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x33,0x38,0x00,0x00,
+ 0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0xBC,0xE4,0xFF,0xFF,0x20,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
0x10,0x00,0x00,0x00,0x64,0x65,0x66,0x61,0x75,0x6C,0x74,0x5F,0x70,0x74,0x72,0x5F,0x74,0x79,0x70,0x65,
0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x63,0x70,0x70,0x5F,0x70,0x74,0x72,0x5F,0x74,0x79,0x70,0x65,
0x00,0x00,0x00,0x00,0xA8,0xF0,0xFF,0xFF,0x00,0x00,0x0E,0x0F,0x02,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
@@ -355,177 +362,177 @@
0x5F,0x72,0x65,0x66,0x65,0x72,0x72,0x61,0x62,0x6C,0x65,0x73,0x00,0x00,0x00,0x00,0x68,0xEF,0xFF,0xFF,
0x00,0x00,0x00,0x01,0x25,0x00,0x4E,0x00,0xD0,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x50,0x00,0x00,0x00,
- 0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xE4,0xE5,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x02,0x00,0x00,0x00,0x33,0x37,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x00,0xE6,0xFF,0xFF,
+ 0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x5C,0xE5,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x02,0x00,0x00,0x00,0x33,0x37,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x78,0xE5,0xFF,0xFF,
0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x66,0x6E,0x76,0x31,0x61,0x5F,0x36,0x34,
- 0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x68,0x61,0x73,0x68,0x00,0x00,0x00,0x00,0x28,0xE6,0xFF,0xFF,
+ 0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x68,0x61,0x73,0x68,0x00,0x00,0x00,0x00,0xA0,0xE5,0xFF,0xFF,
0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x0B,0x00,0x00,0x00,0x52,0x65,0x66,0x65,0x72,0x72,0x61,0x62,
0x6C,0x65,0x54,0x00,0x08,0x00,0x00,0x00,0x63,0x70,0x70,0x5F,0x74,0x79,0x70,0x65,0x00,0x00,0x00,0x00,
- 0x54,0xE6,0xFF,0xFF,0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x6E,0x61,0x6B,0x65,
+ 0xCC,0xE5,0xFF,0xFF,0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x6E,0x61,0x6B,0x65,
0x64,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x63,0x70,0x70,0x5F,0x70,0x74,0x72,0x5F,0x74,0x79,0x70,0x65,
0x00,0x00,0x00,0x00,0xD8,0xEF,0xFF,0xFF,0x00,0x00,0x0E,0x0A,0x08,0x00,0x00,0x00,0x19,0x00,0x00,0x00,
0x76,0x65,0x63,0x74,0x6F,0x72,0x5F,0x6F,0x66,0x5F,0x77,0x65,0x61,0x6B,0x5F,0x72,0x65,0x66,0x65,0x72,
0x65,0x6E,0x63,0x65,0x73,0x00,0x00,0x00,0x4E,0xF1,0xFF,0xFF,0x24,0x00,0x4C,0x00,0xD4,0x00,0x00,0x00,
0xC0,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x80,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xDC,0xE6,0xFF,0xFF,
+ 0x80,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x54,0xE6,0xFF,0xFF,
0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x33,0x36,0x00,0x00,0x02,0x00,0x00,0x00,
- 0x69,0x64,0x00,0x00,0xF8,0xE6,0xFF,0xFF,0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,
+ 0x69,0x64,0x00,0x00,0x70,0xE6,0xFF,0xFF,0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,
0x66,0x6E,0x76,0x31,0x61,0x5F,0x36,0x34,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x68,0x61,0x73,0x68,
- 0x00,0x00,0x00,0x00,0x20,0xE7,0xFF,0xFF,0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x0B,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x98,0xE6,0xFF,0xFF,0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x0B,0x00,0x00,0x00,
0x52,0x65,0x66,0x65,0x72,0x72,0x61,0x62,0x6C,0x65,0x54,0x00,0x08,0x00,0x00,0x00,0x63,0x70,0x70,0x5F,
- 0x74,0x79,0x70,0x65,0x00,0x00,0x00,0x00,0x4C,0xE7,0xFF,0xFF,0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x74,0x79,0x70,0x65,0x00,0x00,0x00,0x00,0xC4,0xE6,0xFF,0xFF,0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
0x05,0x00,0x00,0x00,0x6E,0x61,0x6B,0x65,0x64,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x63,0x70,0x70,0x5F,
- 0x70,0x74,0x72,0x5F,0x74,0x79,0x70,0x65,0x00,0x00,0x00,0x00,0xF8,0xE5,0xFF,0xFF,0x00,0x00,0x00,0x0A,
+ 0x70,0x74,0x72,0x5F,0x74,0x79,0x70,0x65,0x00,0x00,0x00,0x00,0x70,0xE5,0xFF,0xFF,0x00,0x00,0x00,0x0A,
0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x73,0x69,0x6E,0x67,0x6C,0x65,0x5F,0x77,
0x65,0x61,0x6B,0x5F,0x72,0x65,0x66,0x65,0x72,0x65,0x6E,0x63,0x65,0x00,0x00,0x00,0x5C,0xF1,0xFF,0xFF,
0x00,0x00,0x00,0x01,0x23,0x00,0x4A,0x00,0x48,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xCC,0xE7,0xFF,0xFF,
+ 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x44,0xE7,0xFF,0xFF,
0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x33,0x35,0x00,0x00,0x02,0x00,0x00,0x00,
0x69,0x64,0x00,0x00,0x14,0xF3,0xFF,0xFF,0x00,0x00,0x0E,0x0F,0x02,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
0x15,0x00,0x00,0x00,0x76,0x65,0x63,0x74,0x6F,0x72,0x5F,0x6F,0x66,0x5F,0x72,0x65,0x66,0x65,0x72,0x72,
0x61,0x62,0x6C,0x65,0x73,0x00,0x00,0x00,0xCC,0xF1,0xFF,0xFF,0x00,0x00,0x00,0x01,0x22,0x00,0x48,0x00,
0x48,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x3C,0xE8,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x02,0x00,0x00,0x00,0x33,0x34,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x04,0xE5,0xFF,0xFF,
- 0x00,0x00,0x00,0x0F,0x0A,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x70,0x61,0x72,0x65,
+ 0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xB4,0xE7,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x02,0x00,0x00,0x00,0x33,0x34,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x7C,0xE4,0xFF,0xFF,
+ 0x00,0x00,0x00,0x0F,0x0B,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x70,0x61,0x72,0x65,
0x6E,0x74,0x5F,0x6E,0x61,0x6D,0x65,0x73,0x70,0x61,0x63,0x65,0x5F,0x74,0x65,0x73,0x74,0x00,0x00,0x00,
0x3C,0xF2,0xFF,0xFF,0x00,0x00,0x00,0x01,0x21,0x00,0x46,0x00,0x44,0x00,0x00,0x00,0x34,0x00,0x00,0x00,
0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0xAC,0xE8,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x33,0x33,0x00,0x00,
+ 0x24,0xE8,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x33,0x33,0x00,0x00,
0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x20,0xF2,0xFF,0xFF,0x00,0x00,0x0E,0x0C,0x08,0x00,0x00,0x00,
0x11,0x00,0x00,0x00,0x76,0x65,0x63,0x74,0x6F,0x72,0x5F,0x6F,0x66,0x5F,0x64,0x6F,0x75,0x62,0x6C,0x65,
0x73,0x00,0x00,0x00,0xA4,0xF2,0xFF,0xFF,0x00,0x00,0x00,0x01,0x20,0x00,0x44,0x00,0x44,0x00,0x00,0x00,
0x34,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0x14,0xE9,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
+ 0x04,0x00,0x00,0x00,0x8C,0xE8,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
0x33,0x32,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x88,0xF2,0xFF,0xFF,0x00,0x00,0x0E,0x09,
0x08,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x76,0x65,0x63,0x74,0x6F,0x72,0x5F,0x6F,0x66,0x5F,0x6C,0x6F,
0x6E,0x67,0x73,0x00,0x08,0xF3,0xFF,0xFF,0x00,0x00,0x00,0x01,0x1F,0x00,0x42,0x00,0x48,0x00,0x00,0x00,
0x34,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0x78,0xE9,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
+ 0x04,0x00,0x00,0x00,0xF0,0xE8,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
0x33,0x31,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0xC0,0xF4,0xFF,0xFF,0x00,0x00,0x0E,0x0F,
- 0x05,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x74,0x65,0x73,0x74,0x35,0x00,0x00,0x00,
+ 0x06,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x74,0x65,0x73,0x74,0x35,0x00,0x00,0x00,
0x68,0xF3,0xFF,0xFF,0x00,0x00,0x00,0x01,0x1E,0x00,0x40,0x00,0x6C,0x00,0x00,0x00,0x5C,0x00,0x00,0x00,
0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x24,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0xDC,0xE9,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
- 0x33,0x30,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0xF8,0xE9,0xFF,0xFF,0x10,0x00,0x00,0x00,
+ 0x04,0x00,0x00,0x00,0x54,0xE9,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
+ 0x33,0x30,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x70,0xE9,0xFF,0xFF,0x10,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x0A,0x00,0x00,0x00,0x66,0x6C,0x65,0x78,
0x62,0x75,0x66,0x66,0x65,0x72,0x00,0x00,0x74,0xF3,0xFF,0xFF,0x00,0x00,0x0E,0x04,0x01,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x66,0x6C,0x65,0x78,0x00,0x00,0x00,0x00,0xEC,0xF3,0xFF,0xFF,0x00,0x00,0x00,0x01,
0x1D,0x00,0x3E,0x00,0x48,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x5C,0xEA,0xFF,0xFF,0x10,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xD4,0xE9,0xFF,0xFF,0x10,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x32,0x39,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,
0xA4,0xF5,0xFF,0xFF,0x00,0x00,0x0E,0x0F,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x17,0x00,0x00,0x00,
0x74,0x65,0x73,0x74,0x61,0x72,0x72,0x61,0x79,0x6F,0x66,0x73,0x6F,0x72,0x74,0x65,0x64,0x73,0x74,0x72,
0x75,0x63,0x74,0x00,0x5C,0xF4,0xFF,0xFF,0x00,0x00,0x00,0x01,0x1C,0x00,0x3C,0x00,0x44,0x00,0x00,0x00,
0x34,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0xCC,0xEA,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
+ 0x04,0x00,0x00,0x00,0x44,0xEA,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
0x32,0x38,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x40,0xF4,0xFF,0xFF,0x00,0x00,0x0E,0x0D,
0x04,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x74,0x65,0x73,0x74,0x61,0x72,0x72,0x61,0x79,0x6F,0x66,0x73,
0x74,0x72,0x69,0x6E,0x67,0x32,0x00,0x00,0xAE,0xF5,0xFF,0xFF,0x1B,0x00,0x3A,0x00,0x44,0x00,0x00,0x00,
0x34,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0x30,0xEB,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
- 0x32,0x37,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x14,0xE7,0xFF,0xFF,0x00,0x00,0x00,0x0B,
+ 0x04,0x00,0x00,0x00,0xA8,0xEA,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
+ 0x32,0x37,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x8C,0xE6,0xFF,0xFF,0x00,0x00,0x00,0x0B,
0x01,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x74,0x65,0x73,0x74,0x66,0x33,0x00,0x00,0x9A,0xFF,0xFF,0xFF,
0x1A,0x00,0x38,0x00,0x50,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x10,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0x94,0xEB,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
- 0x32,0x36,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x78,0xE7,0xFF,0xFF,0x00,0x00,0x00,0x0B,
+ 0x04,0x00,0x00,0x00,0x0C,0xEB,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
+ 0x32,0x36,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0xF0,0xE6,0xFF,0xFF,0x00,0x00,0x00,0x0B,
0x01,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x74,0x65,0x73,0x74,0x66,0x32,0x00,0x00,0x00,0x00,0x1A,0x00,
0x24,0x00,0x08,0x00,0x0C,0x00,0x04,0x00,0x06,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x10,0x00,0x14,0x00,0x1A,0x00,0x00,0x00,0x19,0x00,0x36,0x00,0x50,0x00,0x00,0x00,0x40,0x00,0x00,0x00,
0x18,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x6E,0x86,0x1B,0xF0,0xF9,0x21,0x09,0x40,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x14,0xEC,0xFF,0xFF,0x10,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x8C,0xEB,0xFF,0xFF,0x10,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x32,0x35,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,
- 0xF8,0xE7,0xFF,0xFF,0x00,0x00,0x00,0x0B,0x01,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x74,0x65,0x73,0x74,
+ 0x70,0xE7,0xFF,0xFF,0x00,0x00,0x00,0x0B,0x01,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x74,0x65,0x73,0x74,
0x66,0x00,0x00,0x00,0x00,0xF6,0xFF,0xFF,0x00,0x00,0x00,0x01,0x18,0x00,0x34,0x00,0x44,0x00,0x00,0x00,
0x34,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0x70,0xEC,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
+ 0x04,0x00,0x00,0x00,0xE8,0xEB,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
0x32,0x34,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0xE4,0xF5,0xFF,0xFF,0x00,0x00,0x0E,0x02,
0x01,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x74,0x65,0x73,0x74,0x61,0x72,0x72,0x61,0x79,0x6F,0x66,0x62,
0x6F,0x6F,0x6C,0x73,0x00,0x00,0x00,0x00,0x52,0xF7,0xFF,0xFF,0x17,0x00,0x32,0x00,0x74,0x00,0x00,0x00,
0x60,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
- 0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xD8,0xEC,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x02,0x00,0x00,0x00,0x32,0x33,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0xF4,0xEC,0xFF,0xFF,
+ 0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x50,0xEC,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x02,0x00,0x00,0x00,0x32,0x33,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x6C,0xEC,0xFF,0xFF,
0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x66,0x6E,0x76,0x31,0x61,0x5F,0x36,0x34,
- 0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x68,0x61,0x73,0x68,0x00,0x00,0x00,0x00,0x9C,0xEB,0xFF,0xFF,
+ 0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x68,0x61,0x73,0x68,0x00,0x00,0x00,0x00,0x14,0xEB,0xFF,0xFF,
0x00,0x00,0x00,0x0A,0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0x74,0x65,0x73,0x74,
0x68,0x61,0x73,0x68,0x75,0x36,0x34,0x5F,0x66,0x6E,0x76,0x31,0x61,0x00,0x00,0x00,0xE6,0xF7,0xFF,0xFF,
0x16,0x00,0x30,0x00,0x74,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x6C,0xED,0xFF,0xFF,
+ 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xE4,0xEC,0xFF,0xFF,
0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x32,0x32,0x00,0x00,0x02,0x00,0x00,0x00,
- 0x69,0x64,0x00,0x00,0x88,0xED,0xFF,0xFF,0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,
+ 0x69,0x64,0x00,0x00,0x00,0xED,0xFF,0xFF,0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,
0x66,0x6E,0x76,0x31,0x61,0x5F,0x36,0x34,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x68,0x61,0x73,0x68,
- 0x00,0x00,0x00,0x00,0x30,0xEC,0xFF,0xFF,0x00,0x00,0x00,0x09,0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xA8,0xEB,0xFF,0xFF,0x00,0x00,0x00,0x09,0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
0x11,0x00,0x00,0x00,0x74,0x65,0x73,0x74,0x68,0x61,0x73,0x68,0x73,0x36,0x34,0x5F,0x66,0x6E,0x76,0x31,
0x61,0x00,0x00,0x00,0x7A,0xF8,0xFF,0xFF,0x15,0x00,0x2E,0x00,0xCC,0x00,0x00,0x00,0xBC,0x00,0x00,0x00,
0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,
- 0x50,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x08,0xEE,0xFF,0xFF,0x10,0x00,0x00,0x00,
+ 0x50,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x80,0xED,0xFF,0xFF,0x10,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x32,0x31,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,
- 0x24,0xEE,0xFF,0xFF,0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x66,0x6E,0x76,0x31,
+ 0x9C,0xED,0xFF,0xFF,0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x66,0x6E,0x76,0x31,
0x61,0x5F,0x33,0x32,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x68,0x61,0x73,0x68,0x00,0x00,0x00,0x00,
- 0x4C,0xEE,0xFF,0xFF,0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x53,0x74,0x61,0x74,
+ 0xC4,0xED,0xFF,0xFF,0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x53,0x74,0x61,0x74,
0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x63,0x70,0x70,0x5F,0x74,0x79,0x70,0x65,0x00,0x00,0x00,0x00,
- 0x74,0xEE,0xFF,0xFF,0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x6E,0x61,0x6B,0x65,
+ 0xEC,0xED,0xFF,0xFF,0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x6E,0x61,0x6B,0x65,
0x64,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x63,0x70,0x70,0x5F,0x70,0x74,0x72,0x5F,0x74,0x79,0x70,0x65,
- 0x00,0x00,0x00,0x00,0x68,0xEA,0xFF,0xFF,0x00,0x00,0x00,0x08,0x01,0x00,0x00,0x00,0x11,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xE0,0xE9,0xFF,0xFF,0x00,0x00,0x00,0x08,0x01,0x00,0x00,0x00,0x11,0x00,0x00,0x00,
0x74,0x65,0x73,0x74,0x68,0x61,0x73,0x68,0x75,0x33,0x32,0x5F,0x66,0x6E,0x76,0x31,0x61,0x00,0x00,0x00,
0x66,0xF9,0xFF,0xFF,0x14,0x00,0x2C,0x00,0x70,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0xEC,0xEE,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x32,0x30,0x00,0x00,
- 0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x08,0xEF,0xFF,0xFF,0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x64,0xEE,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x32,0x30,0x00,0x00,
+ 0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x80,0xEE,0xFF,0xFF,0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
0x08,0x00,0x00,0x00,0x66,0x6E,0x76,0x31,0x61,0x5F,0x33,0x32,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x68,0x61,0x73,0x68,0x00,0x00,0x00,0x00,0xF8,0xEA,0xFF,0xFF,0x00,0x00,0x00,0x07,0x01,0x00,0x00,0x00,
+ 0x68,0x61,0x73,0x68,0x00,0x00,0x00,0x00,0x70,0xEA,0xFF,0xFF,0x00,0x00,0x00,0x07,0x01,0x00,0x00,0x00,
0x11,0x00,0x00,0x00,0x74,0x65,0x73,0x74,0x68,0x61,0x73,0x68,0x73,0x33,0x32,0x5F,0x66,0x6E,0x76,0x31,
0x61,0x00,0x00,0x00,0xF6,0xF9,0xFF,0xFF,0x13,0x00,0x2A,0x00,0x70,0x00,0x00,0x00,0x5C,0x00,0x00,0x00,
0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x24,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0x7C,0xEF,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
- 0x31,0x39,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x98,0xEF,0xFF,0xFF,0x14,0x00,0x00,0x00,
+ 0x04,0x00,0x00,0x00,0xF4,0xEE,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
+ 0x31,0x39,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x10,0xEF,0xFF,0xFF,0x14,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x66,0x6E,0x76,0x31,0x5F,0x36,0x34,0x00,0x04,0x00,0x00,0x00,
- 0x68,0x61,0x73,0x68,0x00,0x00,0x00,0x00,0x3C,0xEE,0xFF,0xFF,0x00,0x00,0x00,0x0A,0x08,0x00,0x00,0x00,
+ 0x68,0x61,0x73,0x68,0x00,0x00,0x00,0x00,0xB4,0xED,0xFF,0xFF,0x00,0x00,0x00,0x0A,0x08,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x74,0x65,0x73,0x74,0x68,0x61,0x73,0x68,0x75,0x36,0x34,0x5F,
0x66,0x6E,0x76,0x31,0x00,0x00,0x00,0x00,0x86,0xFA,0xFF,0xFF,0x12,0x00,0x28,0x00,0x70,0x00,0x00,0x00,
0x5C,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
- 0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x0C,0xF0,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x02,0x00,0x00,0x00,0x31,0x38,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x28,0xF0,0xFF,0xFF,
+ 0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x84,0xEF,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x02,0x00,0x00,0x00,0x31,0x38,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0xA0,0xEF,0xFF,0xFF,
0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x66,0x6E,0x76,0x31,0x5F,0x36,0x34,0x00,
- 0x04,0x00,0x00,0x00,0x68,0x61,0x73,0x68,0x00,0x00,0x00,0x00,0xCC,0xEE,0xFF,0xFF,0x00,0x00,0x00,0x09,
+ 0x04,0x00,0x00,0x00,0x68,0x61,0x73,0x68,0x00,0x00,0x00,0x00,0x44,0xEE,0xFF,0xFF,0x00,0x00,0x00,0x09,
0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x74,0x65,0x73,0x74,0x68,0x61,0x73,0x68,
0x73,0x36,0x34,0x5F,0x66,0x6E,0x76,0x31,0x00,0x00,0x00,0x00,0x16,0xFB,0xFF,0xFF,0x11,0x00,0x26,0x00,
0x6C,0x00,0x00,0x00,0x5C,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x02,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x9C,0xF0,0xFF,0xFF,0x10,0x00,0x00,0x00,
+ 0x02,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x14,0xF0,0xFF,0xFF,0x10,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x31,0x37,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,
- 0xB8,0xF0,0xFF,0xFF,0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x66,0x6E,0x76,0x31,
- 0x5F,0x33,0x32,0x00,0x04,0x00,0x00,0x00,0x68,0x61,0x73,0x68,0x00,0x00,0x00,0x00,0xA4,0xEC,0xFF,0xFF,
+ 0x30,0xF0,0xFF,0xFF,0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x66,0x6E,0x76,0x31,
+ 0x5F,0x33,0x32,0x00,0x04,0x00,0x00,0x00,0x68,0x61,0x73,0x68,0x00,0x00,0x00,0x00,0x1C,0xEC,0xFF,0xFF,
0x00,0x00,0x00,0x08,0x01,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x74,0x65,0x73,0x74,0x68,0x61,0x73,0x68,
0x75,0x33,0x32,0x5F,0x66,0x6E,0x76,0x31,0x00,0x00,0x00,0x00,0xA2,0xFB,0xFF,0xFF,0x10,0x00,0x24,0x00,
0x6C,0x00,0x00,0x00,0x5C,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x02,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x28,0xF1,0xFF,0xFF,0x10,0x00,0x00,0x00,
+ 0x02,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xA0,0xF0,0xFF,0xFF,0x10,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x31,0x36,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,
- 0x44,0xF1,0xFF,0xFF,0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x66,0x6E,0x76,0x31,
- 0x5F,0x33,0x32,0x00,0x04,0x00,0x00,0x00,0x68,0x61,0x73,0x68,0x00,0x00,0x00,0x00,0x30,0xED,0xFF,0xFF,
+ 0xBC,0xF0,0xFF,0xFF,0x14,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x66,0x6E,0x76,0x31,
+ 0x5F,0x33,0x32,0x00,0x04,0x00,0x00,0x00,0x68,0x61,0x73,0x68,0x00,0x00,0x00,0x00,0xA8,0xEC,0xFF,0xFF,
0x00,0x00,0x00,0x07,0x01,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x74,0x65,0x73,0x74,0x68,0x61,0x73,0x68,
0x73,0x33,0x32,0x5F,0x66,0x6E,0x76,0x31,0x00,0x00,0x00,0x00,0x2E,0xFC,0xFF,0xFF,0x0F,0x00,0x22,0x00,
0x48,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xB0,0xF1,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x02,0x00,0x00,0x00,0x31,0x35,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x4C,0xF0,0xFF,0xFF,
+ 0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x28,0xF1,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x02,0x00,0x00,0x00,0x31,0x35,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0xC4,0xEF,0xFF,0xFF,
0x00,0x00,0x00,0x02,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x74,0x65,0x73,0x74,
0x62,0x6F,0x6F,0x6C,0x00,0x00,0x00,0x00,0xA4,0xFB,0xFF,0xFF,0x00,0x00,0x00,0x01,0x0E,0x00,0x20,0x00,
0x48,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x14,0xF2,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x02,0x00,0x00,0x00,0x31,0x34,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0xDC,0xEE,0xFF,0xFF,
+ 0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x8C,0xF1,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x02,0x00,0x00,0x00,0x31,0x34,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x54,0xEE,0xFF,0xFF,
0x00,0x00,0x00,0x0F,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x74,0x65,0x73,0x74,
0x65,0x6D,0x70,0x74,0x79,0x00,0x00,0x00,0x08,0xFC,0xFF,0xFF,0x00,0x00,0x00,0x01,0x0D,0x00,0x1E,0x00,
0x78,0x00,0x00,0x00,0x68,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x02,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x7C,0xF2,0xFF,0xFF,0x14,0x00,0x00,0x00,
+ 0x02,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xF4,0xF1,0xFF,0xFF,0x14,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x4D,0x6F,0x6E,0x73,0x74,0x65,0x72,0x00,0x11,0x00,0x00,0x00,
0x6E,0x65,0x73,0x74,0x65,0x64,0x5F,0x66,0x6C,0x61,0x74,0x62,0x75,0x66,0x66,0x65,0x72,0x00,0x00,0x00,
- 0xAC,0xF2,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x31,0x33,0x00,0x00,
+ 0x24,0xF2,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x31,0x33,0x00,0x00,
0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x20,0xFC,0xFF,0xFF,0x00,0x00,0x0E,0x04,0x01,0x00,0x00,0x00,
0x14,0x00,0x00,0x00,0x74,0x65,0x73,0x74,0x6E,0x65,0x73,0x74,0x65,0x64,0x66,0x6C,0x61,0x74,0x62,0x75,
0x66,0x66,0x65,0x72,0x00,0x00,0x00,0x00,0xA8,0xFC,0xFF,0xFF,0x00,0x00,0x00,0x01,0x0C,0x00,0x1C,0x00,
0x48,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x18,0xF3,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x02,0x00,0x00,0x00,0x31,0x32,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0xE0,0xEF,0xFF,0xFF,
+ 0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x90,0xF2,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x02,0x00,0x00,0x00,0x31,0x32,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x58,0xEF,0xFF,0xFF,
0x00,0x00,0x00,0x0F,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x65,0x6E,0x65,0x6D,
0x79,0x00,0x00,0x00,0x08,0xFD,0xFF,0xFF,0x00,0x00,0x00,0x01,0x0B,0x00,0x1A,0x00,0xB4,0x00,0x00,0x00,
0xA0,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x1C,0x00,0x00,0x00,
@@ -534,223 +541,230 @@
0x64,0x6F,0x63,0x75,0x6D,0x65,0x6E,0x74,0x61,0x74,0x69,0x6F,0x6E,0x20,0x63,0x6F,0x6D,0x6D,0x65,0x6E,
0x74,0x3A,0x20,0x74,0x68,0x69,0x73,0x20,0x77,0x69,0x6C,0x6C,0x20,0x65,0x6E,0x64,0x20,0x75,0x70,0x20,
0x69,0x6E,0x20,0x74,0x68,0x65,0x20,0x67,0x65,0x6E,0x65,0x72,0x61,0x74,0x65,0x64,0x20,0x63,0x6F,0x64,
- 0x65,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xE4,0xF3,0xFF,0xFF,0x10,0x00,0x00,0x00,
+ 0x65,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x5C,0xF3,0xFF,0xFF,0x10,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x31,0x31,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,
0x2C,0xFF,0xFF,0xFF,0x00,0x00,0x0E,0x0F,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x11,0x00,0x00,0x00,
0x74,0x65,0x73,0x74,0x61,0x72,0x72,0x61,0x79,0x6F,0x66,0x74,0x61,0x62,0x6C,0x65,0x73,0x00,0x00,0x00,
0xE0,0xFD,0xFF,0xFF,0x00,0x00,0x00,0x01,0x0A,0x00,0x18,0x00,0x44,0x00,0x00,0x00,0x34,0x00,0x00,0x00,
0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x50,0xF4,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x31,0x30,0x00,0x00,
+ 0xC8,0xF3,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x31,0x30,0x00,0x00,
0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0xC4,0xFD,0xFF,0xFF,0x00,0x00,0x0E,0x0D,0x04,0x00,0x00,0x00,
0x11,0x00,0x00,0x00,0x74,0x65,0x73,0x74,0x61,0x72,0x72,0x61,0x79,0x6F,0x66,0x73,0x74,0x72,0x69,0x6E,
0x67,0x00,0x00,0x00,0x48,0xFE,0xFF,0xFF,0x00,0x00,0x00,0x01,0x09,0x00,0x16,0x00,0x58,0x00,0x00,0x00,
0x44,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0xB8,0xF4,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x04,0x00,0x00,0x00,0x30,0xF4,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
0x39,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x10,0x00,0x10,0x00,0x06,0x00,0x07,0x00,
- 0x08,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x0E,0x0F,0x05,0x00,0x00,0x00,
+ 0x08,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x0E,0x0F,0x06,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x74,0x65,0x73,0x74,0x34,0x00,0x00,0x00,0xB8,0xFE,0xFF,0xFF,
0x00,0x00,0x00,0x01,0x08,0x00,0x14,0x00,0x48,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x28,0xF5,0xFF,0xFF,
+ 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xA0,0xF4,0xFF,0xFF,
0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
- 0x69,0x64,0x00,0x00,0xF0,0xF1,0xFF,0xFF,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x69,0x64,0x00,0x00,0x68,0xF1,0xFF,0xFF,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x74,0x65,0x73,0x74,0x00,0x00,0x1A,0x00,0x18,0x00,0x08,0x00,0x0C,0x00,0x04,0x00,
0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x14,0x00,0x1A,0x00,0x00,0x00,
0x07,0x00,0x12,0x00,0x4C,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x9C,0xF5,0xFF,0xFF,0x10,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x14,0xF5,0xFF,0xFF,0x10,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x37,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,
- 0x18,0xF5,0xFF,0xFF,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x90,0xF4,0xFF,0xFF,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
0x09,0x00,0x00,0x00,0x74,0x65,0x73,0x74,0x5F,0x74,0x79,0x70,0x65,0x00,0x00,0x00,0x42,0xFD,0xFF,0xFF,
0x06,0x00,0x10,0x00,0x58,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x10,0x00,0x00,0x00,
0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0x0C,0xF6,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
- 0x36,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x88,0xF5,0xFF,0xFF,0x00,0x00,0x00,0x04,
+ 0x04,0x00,0x00,0x00,0x84,0xF5,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x36,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x00,0xF5,0xFF,0xFF,0x00,0x00,0x00,0x04,
0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x63,0x6F,0x6C,0x6F,
0x72,0x00,0x00,0x00,0x1C,0x00,0x1C,0x00,0x0C,0x00,0x10,0x00,0x08,0x00,0x0A,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x00,0x18,0x00,0x07,0x00,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x05,0x00,0x0E,0x00,0x54,0x00,0x00,0x00,0x44,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x8C,0xF6,0xFF,0xFF,0x10,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x04,0xF6,0xFF,0xFF,0x10,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x35,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,
0x10,0x00,0x0C,0x00,0x06,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x10,0x00,0x00,0x00,
0x00,0x00,0x0E,0x04,0x01,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x69,0x6E,0x76,0x65,0x6E,0x74,0x6F,0x72,
0x79,0x00,0x1A,0x00,0x1C,0x00,0x0C,0x00,0x10,0x00,0x08,0x00,0x0A,0x00,0x00,0x00,0x00,0x00,0x07,0x00,
0x00,0x00,0x00,0x00,0x14,0x00,0x18,0x00,0x1A,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x04,0x00,0x0C,0x00,
0x98,0x00,0x00,0x00,0x84,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x03,0x00,0x00,0x00,0x4C,0x00,0x00,0x00,0x2C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x1C,0xF7,0xFF,0xFF,
+ 0x03,0x00,0x00,0x00,0x4C,0x00,0x00,0x00,0x2C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x94,0xF6,0xFF,0xFF,
0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x31,0x00,0x00,0x00,0x08,0x00,0x00,0x00,
- 0x70,0x72,0x69,0x6F,0x72,0x69,0x74,0x79,0x00,0x00,0x00,0x00,0x40,0xF7,0xFF,0xFF,0x10,0x00,0x00,0x00,
+ 0x70,0x72,0x69,0x6F,0x72,0x69,0x74,0x79,0x00,0x00,0x00,0x00,0xB8,0xF6,0xFF,0xFF,0x10,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,
- 0x5C,0xF7,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x30,0x00,0x00,0x00,
- 0x0A,0x00,0x00,0x00,0x64,0x65,0x70,0x72,0x65,0x63,0x61,0x74,0x65,0x64,0x00,0x00,0x00,0xF6,0xFF,0xFF,
+ 0xD4,0xF6,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x30,0x00,0x00,0x00,
+ 0x0A,0x00,0x00,0x00,0x64,0x65,0x70,0x72,0x65,0x63,0x61,0x74,0x65,0x64,0x00,0x00,0x78,0xF5,0xFF,0xFF,
0x00,0x00,0x00,0x02,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x66,0x72,0x69,0x65,
0x6E,0x64,0x6C,0x79,0x00,0x00,0x1A,0x00,0x1C,0x00,0x0C,0x00,0x10,0x00,0x08,0x00,0x0A,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x06,0x00,0x07,0x00,0x14,0x00,0x18,0x00,0x1A,0x00,0x00,0x00,0x00,0x00,0x01,0x01,
0x03,0x00,0x0A,0x00,0x64,0x00,0x00,0x00,0x54,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xE4,0xF7,0xFF,0xFF,
+ 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x5C,0xF7,0xFF,0xFF,
0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
- 0x6B,0x65,0x79,0x00,0x00,0xF8,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
- 0x33,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0xE4,0xF3,0xFF,0xFF,0x00,0x00,0x00,0x0D,
+ 0x6B,0x65,0x79,0x00,0x78,0xF7,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x33,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x5C,0xF3,0xFF,0xFF,0x00,0x00,0x00,0x0D,
0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x6E,0x61,0x6D,0x65,0x00,0x00,0x00,0x00,0x9A,0xFF,0xFF,0xFF,
0x02,0x00,0x08,0x00,0x54,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x10,0x00,0x00,0x00,
0x64,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0x64,0xF8,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
- 0x32,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x00,0xF7,0xFF,0xFF,0x00,0x00,0x00,0x05,
+ 0x04,0x00,0x00,0x00,0xDC,0xF7,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x32,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x78,0xF6,0xFF,0xFF,0x00,0x00,0x00,0x05,
0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x68,0x70,0x00,0x00,0x00,0x00,0x1A,0x00,
0x24,0x00,0x08,0x00,0x0C,0x00,0x04,0x00,0x06,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x10,0x00,0x14,0x00,0x1A,0x00,0x00,0x00,0x01,0x00,0x06,0x00,0x54,0x00,0x00,0x00,0x40,0x00,0x00,0x00,
0x18,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x96,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xE4,0xF8,0xFF,0xFF,0x10,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x5C,0xF8,0xFF,0xFF,0x10,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x31,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,
- 0x80,0xF7,0xFF,0xFF,0x00,0x00,0x00,0x05,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0xF8,0xF6,0xFF,0xFF,0x00,0x00,0x00,0x05,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
0x6D,0x61,0x6E,0x61,0x00,0x00,0x00,0x00,0x1C,0x00,0x18,0x00,0x08,0x00,0x0C,0x00,0x00,0x00,0x06,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x14,0x00,0x05,0x00,0x1C,0x00,0x00,0x00,
0x00,0x01,0x04,0x00,0x48,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x5C,0xF9,0xFF,0xFF,0x10,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xD4,0xF8,0xFF,0xFF,0x10,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,
- 0x24,0xF6,0xFF,0xFF,0x00,0x00,0x00,0x0F,0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
- 0x70,0x6F,0x73,0x00,0xCC,0xF6,0xFF,0xFF,0x20,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
- 0x08,0x00,0x00,0x00,0x58,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x3C,0x00,0x00,0x00,
+ 0x9C,0xF5,0xFF,0xFF,0x00,0x00,0x00,0x0F,0x09,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
+ 0x70,0x6F,0x73,0x00,0x44,0xF6,0xFF,0xFF,0x20,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x08,0x00,0x00,0x00,0xE0,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x3C,0x00,0x00,0x00,
0x19,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,0x6D,0x65,0x2E,0x45,0x78,0x61,0x6D,0x70,0x6C,0x65,0x2E,0x52,
0x65,0x66,0x65,0x72,0x72,0x61,0x62,0x6C,0x65,0x00,0x1A,0x00,0x18,0x00,0x08,0x00,0x0C,0x00,0x00,0x00,
0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x10,0x00,0x14,0x00,0x1A,0x00,0x00,0x00,
0x00,0x01,0x04,0x00,0x74,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x14,0xFA,0xFF,0xFF,
+ 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x8C,0xF9,0xFF,0xFF,
0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
- 0x6B,0x65,0x79,0x00,0x30,0xFA,0xFF,0xFF,0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,
+ 0x6B,0x65,0x79,0x00,0xA8,0xF9,0xFF,0xFF,0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,
0x66,0x6E,0x76,0x31,0x61,0x5F,0x36,0x34,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x68,0x61,0x73,0x68,
- 0x00,0x00,0x00,0x00,0xD8,0xF8,0xFF,0xFF,0x00,0x00,0x00,0x0A,0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
- 0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0xAC,0xF7,0xFF,0xFF,0x28,0x00,0x00,0x00,0x14,0x00,0x00,0x00,
- 0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x78,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x50,0xF8,0xFF,0xFF,0x00,0x00,0x00,0x0A,0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x24,0xF7,0xFF,0xFF,0x28,0x00,0x00,0x00,0x14,0x00,0x00,0x00,
+ 0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
0x40,0x00,0x00,0x00,0xCC,0x00,0x00,0x00,0x98,0x00,0x00,0x00,0x13,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,
0x6D,0x65,0x2E,0x45,0x78,0x61,0x6D,0x70,0x6C,0x65,0x2E,0x53,0x74,0x61,0x74,0x00,0x00,0x00,0x1A,0x00,
0x1C,0x00,0x0C,0x00,0x10,0x00,0x08,0x00,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,
0x14,0x00,0x18,0x00,0x1A,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x00,0x08,0x00,0x48,0x00,0x00,0x00,
0x34,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0xF8,0xFA,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
- 0x30,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x6B,0x65,0x79,0x00,0x94,0xF9,0xFF,0xFF,0x00,0x00,0x00,0x06,
+ 0x04,0x00,0x00,0x00,0x70,0xFA,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x30,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x6B,0x65,0x79,0x00,0x0C,0xF9,0xFF,0xFF,0x00,0x00,0x00,0x06,
0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x63,0x6F,0x75,0x6E,0x74,0x00,0x00,0x00,
- 0xFE,0xFB,0xFF,0xFF,0x01,0x00,0x06,0x00,0x20,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0xC8,0xF9,0xFF,0xFF,0x00,0x00,0x00,0x09,0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
- 0x03,0x00,0x00,0x00,0x76,0x61,0x6C,0x00,0x40,0xF8,0xFF,0xFF,0x00,0x01,0x04,0x00,0x1C,0x00,0x00,0x00,
- 0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xF7,0xFF,0xFF,0x00,0x00,0x00,0x0D,
- 0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x10,0xF8,0xFF,0xFF,0x00,0x00,0x00,0x01,
- 0x2C,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x08,0x00,0x00,0x00,
- 0x54,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0xD0,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,
- 0x28,0x00,0x00,0x00,0x1E,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,0x6D,0x65,0x2E,0x45,0x78,0x61,0x6D,0x70,
- 0x6C,0x65,0x2E,0x53,0x74,0x72,0x75,0x63,0x74,0x4F,0x66,0x53,0x74,0x72,0x75,0x63,0x74,0x73,0x00,0x00,
- 0xCC,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x01,0x02,0x00,0x0C,0x00,0x20,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xAC,0xF8,0xFF,0xFF,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x00,
- 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x63,0x00,0x00,0x00,0x1C,0x00,0x18,0x00,0x0C,0x00,0x10,0x00,
- 0x08,0x00,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x00,0x07,0x00,
- 0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x08,0x00,0x20,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0xF8,0xFF,0xFF,0x00,0x00,0x00,0x0F,0x05,0x00,0x00,0x00,
- 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x62,0x00,0x00,0x00,0x1C,0x00,0x14,0x00,0x08,0x00,0x0C,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x07,0x00,
- 0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x20,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x48,0xF9,0xFF,0xFF,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
- 0x01,0x00,0x00,0x00,0x61,0x00,0x00,0x00,0x38,0xF9,0xFF,0xFF,0x00,0x00,0x00,0x01,0x28,0x00,0x00,0x00,
- 0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x2C,0x05,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x6C,0x00,0x00,0x00,0x16,0x00,0x00,0x00,
- 0x4D,0x79,0x47,0x61,0x6D,0x65,0x2E,0x45,0x78,0x61,0x6D,0x70,0x6C,0x65,0x2E,0x41,0x62,0x69,0x6C,0x69,
- 0x74,0x79,0x00,0x00,0xCE,0xFD,0xFF,0xFF,0x01,0x00,0x04,0x00,0x1C,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xF8,0xFF,0xFF,0x00,0x00,0x00,0x08,0x01,0x00,0x00,0x00,
- 0x08,0x00,0x00,0x00,0x64,0x69,0x73,0x74,0x61,0x6E,0x63,0x65,0x00,0x00,0x1A,0x00,0x18,0x00,0x08,0x00,
- 0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x10,0x00,0x14,0x00,
- 0x1A,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x44,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x70,0xFD,0xFF,0xFF,
- 0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
- 0x6B,0x65,0x79,0x00,0x54,0xF9,0xFF,0xFF,0x00,0x00,0x00,0x08,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
- 0x69,0x64,0x00,0x00,0x14,0x00,0x24,0x00,0x08,0x00,0x0C,0x00,0x07,0x00,0x10,0x00,0x14,0x00,0x18,0x00,
- 0x1C,0x00,0x20,0x00,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x68,0x00,0x00,0x00,0x48,0x00,0x00,0x00,
- 0x08,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x28,0x04,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xE4,0xFD,0xFF,0xFF,0x10,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x0B,0x00,0x00,0x00,0x66,0x6F,0x72,0x63,
- 0x65,0x5F,0x61,0x6C,0x69,0x67,0x6E,0x00,0x06,0x00,0x00,0x00,0xC4,0x00,0x00,0x00,0x84,0x00,0x00,0x00,
- 0x48,0x00,0x00,0x00,0x60,0x01,0x00,0x00,0x30,0x01,0x00,0x00,0xE4,0x00,0x00,0x00,0x13,0x00,0x00,0x00,
- 0x4D,0x79,0x47,0x61,0x6D,0x65,0x2E,0x45,0x78,0x61,0x6D,0x70,0x6C,0x65,0x2E,0x56,0x65,0x63,0x33,0x00,
- 0x00,0x00,0x1E,0x00,0x18,0x00,0x0C,0x00,0x10,0x00,0x06,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x00,0x05,0x00,0x0A,0x00,0x1E,0x00,0x00,0x00,0x00,0x01,0x05,0x00,
- 0x1A,0x00,0x02,0x00,0x20,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x24,0xFB,0xFF,0xFF,0x00,0x00,0x00,0x0F,0x05,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x05,0x00,0x00,0x00,
- 0x74,0x65,0x73,0x74,0x33,0x00,0x00,0x00,0x7A,0xFD,0xFF,0xFF,0x00,0x00,0x04,0x00,0x18,0x00,0x01,0x00,
- 0x24,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0xFE,0xFF,0xFF,
- 0x00,0x00,0x00,0x04,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x05,0x00,0x00,0x00,
- 0x74,0x65,0x73,0x74,0x32,0x00,0x00,0x00,0x9E,0xFF,0xFF,0xFF,0x03,0x00,0x10,0x00,0x20,0x00,0x00,0x00,
- 0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x68,0xFD,0xFF,0xFF,0x00,0x00,0x00,0x0C,
- 0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x74,0x65,0x73,0x74,0x31,0x00,0x00,0x00,
- 0xEA,0xFD,0xFF,0xFF,0x00,0x00,0x02,0x00,0x08,0x00,0x04,0x00,0x1C,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE8,0xFA,0xFF,0xFF,0x00,0x00,0x00,0x0B,0x01,0x00,0x00,0x00,
- 0x01,0x00,0x00,0x00,0x7A,0x00,0x1A,0x00,0x14,0x00,0x08,0x00,0x0C,0x00,0x04,0x00,0x06,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x1A,0x00,0x00,0x00,0x01,0x00,0x04,0x00,
- 0x1C,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2C,0xFB,0xFF,0xFF,
- 0x00,0x00,0x00,0x0B,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x79,0x00,0x00,0x00,0x6E,0xFB,0xFF,0xFF,
- 0x1C,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x54,0xFB,0xFF,0xFF,
- 0x00,0x00,0x00,0x0B,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x14,0x00,0x1C,0x00,
- 0x04,0x00,0x08,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x10,0x00,0x14,0x00,0x18,0x00,0x14,0x00,0x00,0x00,
- 0x80,0x00,0x00,0x00,0x74,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x08,0x00,0x00,0x00,
- 0x30,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0xE0,0xFF,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x30,0x00,0x00,0x00,
- 0x07,0x00,0x00,0x00,0x70,0x72,0x69,0x76,0x61,0x74,0x65,0x00,0x08,0x00,0x0C,0x00,0x04,0x00,0x08,0x00,
- 0x08,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x30,0x00,0x00,0x00,
- 0x0E,0x00,0x00,0x00,0x63,0x73,0x68,0x61,0x72,0x70,0x5F,0x70,0x61,0x72,0x74,0x69,0x61,0x6C,0x00,0x00,
- 0x01,0x00,0x00,0x00,0x4C,0x00,0x00,0x00,0x26,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,0x6D,0x65,0x2E,0x45,
- 0x78,0x61,0x6D,0x70,0x6C,0x65,0x2E,0x54,0x65,0x73,0x74,0x53,0x69,0x6D,0x70,0x6C,0x65,0x54,0x61,0x62,
- 0x6C,0x65,0x57,0x69,0x74,0x68,0x45,0x6E,0x75,0x6D,0x00,0x00,0x00,0x00,0x1A,0x00,0x1C,0x00,0x08,0x00,
- 0x0C,0x00,0x00,0x00,0x06,0x00,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,
- 0x1A,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x3C,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,
- 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x14,0x00,0x07,0x00,0x00,0x00,
- 0x08,0x00,0x00,0x00,0x0C,0x00,0x10,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x03,0x00,0x00,0x00,
- 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x63,0x6F,0x6C,0x6F,0x72,0x00,0x00,0x00,
- 0x54,0xFD,0xFF,0xFF,0x00,0x00,0x00,0x01,0x28,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x10,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
- 0x74,0x00,0x00,0x00,0x3C,0x00,0x00,0x00,0x13,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,0x6D,0x65,0x2E,0x45,
- 0x78,0x61,0x6D,0x70,0x6C,0x65,0x2E,0x54,0x65,0x73,0x74,0x00,0x00,0x00,0x1E,0x00,0x18,0x00,0x0C,0x00,
- 0x10,0x00,0x06,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x00,
- 0x00,0x00,0x0A,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x02,0x00,0x01,0x00,0x20,0x00,0x00,0x00,
- 0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xD4,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x03,
- 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x62,0x00,0x00,0x00,0x62,0xFD,0xFF,0xFF,
- 0x30,0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x10,0x00,
- 0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x0C,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x05,
- 0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x61,0x00,0x00,0x00,0xE4,0xFE,0xFF,0xFF,
- 0x1C,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x40,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x17,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,0x6D,0x65,0x2E,0x45,
- 0x78,0x61,0x6D,0x70,0x6C,0x65,0x32,0x2E,0x4D,0x6F,0x6E,0x73,0x74,0x65,0x72,0x00,0x20,0xFF,0xFF,0xFF,
- 0x34,0x00,0x00,0x00,0x2C,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x12,0x00,0x00,0x00,0x2F,0x2F,0x6D,0x6F,0x6E,0x73,0x74,0x65,0x72,0x5F,0x74,0x65,0x73,0x74,0x2E,0x66,
- 0x62,0x73,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,
- 0x6D,0x65,0x2E,0x49,0x6E,0x50,0x61,0x72,0x65,0x6E,0x74,0x4E,0x61,0x6D,0x65,0x73,0x70,0x61,0x63,0x65,
- 0x00,0x00,0x00,0x00,0x78,0xFF,0xFF,0xFF,0x48,0x00,0x00,0x00,0x3C,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
- 0x30,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x2F,0x2F,0x69,0x6E,0x63,0x6C,0x75,0x64,
- 0x65,0x5F,0x74,0x65,0x73,0x74,0x2F,0x69,0x6E,0x63,0x6C,0x75,0x64,0x65,0x5F,0x74,0x65,0x73,0x74,0x31,
- 0x2E,0x66,0x62,0x73,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x10,0x00,0x00,0x00,
- 0x06,0x00,0x00,0x00,0x54,0x61,0x62,0x6C,0x65,0x41,0x00,0x00,0x74,0xFF,0xFF,0xFF,0x00,0x01,0x04,0x00,
- 0x20,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0xFF,0xFF,0xFF,
- 0x00,0x00,0x00,0x0F,0x0B,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x62,0x00,0x00,0x00,
- 0x14,0x00,0x18,0x00,0x04,0x00,0x08,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x14,0x00,
- 0x14,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00,
- 0xC4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x44,0x00,0x00,0x00,0x1C,0x00,0x00,0x00,
- 0x4D,0x79,0x47,0x61,0x6D,0x65,0x2E,0x4F,0x74,0x68,0x65,0x72,0x4E,0x61,0x6D,0x65,0x53,0x70,0x61,0x63,
- 0x65,0x2E,0x54,0x61,0x62,0x6C,0x65,0x42,0x00,0x00,0x00,0x00,0x1C,0x00,0x14,0x00,0x08,0x00,0x0C,0x00,
- 0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x05,0x00,
- 0x1C,0x00,0x00,0x00,0x00,0x01,0x04,0x00,0x30,0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x07,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,
- 0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x0D,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
- 0x61,0x00,0x00,0x00,0x14,0x00,0x20,0x00,0x08,0x00,0x0C,0x00,0x07,0x00,0x10,0x00,0x14,0x00,0x00,0x00,
- 0x18,0x00,0x1C,0x00,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x50,0x00,0x00,0x00,0x44,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x24,0x00,0x00,0x00,
- 0x2F,0x2F,0x69,0x6E,0x63,0x6C,0x75,0x64,0x65,0x5F,0x74,0x65,0x73,0x74,0x2F,0x73,0x75,0x62,0x2F,0x69,
- 0x6E,0x63,0x6C,0x75,0x64,0x65,0x5F,0x74,0x65,0x73,0x74,0x32,0x2E,0x66,0x62,0x73,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,
- 0x6D,0x65,0x2E,0x4F,0x74,0x68,0x65,0x72,0x4E,0x61,0x6D,0x65,0x53,0x70,0x61,0x63,0x65,0x2E,0x55,0x6E,
- 0x75,0x73,0x65,0x64,0x00,0x00,0x1A,0x00,0x10,0x00,0x04,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x1A,0x00,0x00,0x00,0x2C,0x00,0x00,0x00,
- 0x1C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x0C,0x00,0x07,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x01,0x00,0x00,0x00,
- 0x01,0x00,0x00,0x00,0x61,0x00,0x00,0x00
+ 0x76,0xFB,0xFF,0xFF,0x01,0x00,0x06,0x00,0x20,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x40,0xF9,0xFF,0xFF,0x00,0x00,0x00,0x09,0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x03,0x00,0x00,0x00,0x76,0x61,0x6C,0x00,0xB8,0xF7,0xFF,0xFF,0x00,0x01,0x04,0x00,0x1C,0x00,0x00,0x00,
+ 0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xB8,0xF6,0xFF,0xFF,0x00,0x00,0x00,0x0D,
+ 0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,0x88,0xF7,0xFF,0xFF,0x00,0x00,0x00,0x01,
+ 0x24,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x08,0x00,0x00,0x00,
+ 0xDC,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x27,0x00,0x00,0x00,
+ 0x4D,0x79,0x47,0x61,0x6D,0x65,0x2E,0x45,0x78,0x61,0x6D,0x70,0x6C,0x65,0x2E,0x53,0x74,0x72,0x75,0x63,
+ 0x74,0x4F,0x66,0x53,0x74,0x72,0x75,0x63,0x74,0x73,0x4F,0x66,0x53,0x74,0x72,0x75,0x63,0x74,0x73,0x00,
+ 0xF4,0xFE,0xFF,0xFF,0x00,0x00,0x00,0x01,0x20,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x20,0xF8,0xFF,0xFF,0x00,0x00,0x00,0x0F,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x01,0x00,0x00,0x00,0x61,0x00,0x00,0x00,0x10,0xF8,0xFF,0xFF,0x00,0x00,0x00,0x01,0x2C,0x00,0x00,0x00,
+ 0x18,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x54,0x06,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0xD0,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x28,0x00,0x00,0x00,
+ 0x1E,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,0x6D,0x65,0x2E,0x45,0x78,0x61,0x6D,0x70,0x6C,0x65,0x2E,0x53,
+ 0x74,0x72,0x75,0x63,0x74,0x4F,0x66,0x53,0x74,0x72,0x75,0x63,0x74,0x73,0x00,0x00,0xCC,0xFF,0xFF,0xFF,
+ 0x00,0x00,0x00,0x01,0x02,0x00,0x0C,0x00,0x20,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xAC,0xF8,0xFF,0xFF,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x01,0x00,0x00,0x00,0x63,0x00,0x00,0x00,0x1C,0x00,0x18,0x00,0x0C,0x00,0x10,0x00,0x08,0x00,0x0A,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x00,0x07,0x00,0x1C,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x01,0x01,0x00,0x08,0x00,0x20,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xFC,0xF8,0xFF,0xFF,0x00,0x00,0x00,0x0F,0x06,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x01,0x00,0x00,0x00,0x62,0x00,0x00,0x00,0x1C,0x00,0x14,0x00,0x08,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x07,0x00,0x1C,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x01,0x20,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x48,0xF9,0xFF,0xFF,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x61,0x00,0x00,0x00,0x38,0xF9,0xFF,0xFF,0x00,0x00,0x00,0x01,0x28,0x00,0x00,0x00,0x18,0x00,0x00,0x00,
+ 0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x2C,0x05,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x02,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x6C,0x00,0x00,0x00,0x16,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,
+ 0x6D,0x65,0x2E,0x45,0x78,0x61,0x6D,0x70,0x6C,0x65,0x2E,0x41,0x62,0x69,0x6C,0x69,0x74,0x79,0x00,0x00,
+ 0xCE,0xFD,0xFF,0xFF,0x01,0x00,0x04,0x00,0x1C,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xE0,0xF8,0xFF,0xFF,0x00,0x00,0x00,0x08,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00,
+ 0x64,0x69,0x73,0x74,0x61,0x6E,0x63,0x65,0x00,0x00,0x1A,0x00,0x18,0x00,0x08,0x00,0x0C,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x10,0x00,0x14,0x00,0x1A,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x01,0x44,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x70,0xFD,0xFF,0xFF,0x10,0x00,0x00,0x00,
+ 0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x6B,0x65,0x79,0x00,
+ 0x54,0xF9,0xFF,0xFF,0x00,0x00,0x00,0x08,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x69,0x64,0x00,0x00,
+ 0x14,0x00,0x24,0x00,0x08,0x00,0x0C,0x00,0x07,0x00,0x10,0x00,0x14,0x00,0x18,0x00,0x1C,0x00,0x20,0x00,
+ 0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x68,0x00,0x00,0x00,0x48,0x00,0x00,0x00,0x08,0x00,0x00,0x00,
+ 0x20,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x28,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xE4,0xFD,0xFF,0xFF,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x01,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x0B,0x00,0x00,0x00,0x66,0x6F,0x72,0x63,0x65,0x5F,0x61,0x6C,
+ 0x69,0x67,0x6E,0x00,0x06,0x00,0x00,0x00,0xC4,0x00,0x00,0x00,0x84,0x00,0x00,0x00,0x48,0x00,0x00,0x00,
+ 0x60,0x01,0x00,0x00,0x30,0x01,0x00,0x00,0xE4,0x00,0x00,0x00,0x13,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,
+ 0x6D,0x65,0x2E,0x45,0x78,0x61,0x6D,0x70,0x6C,0x65,0x2E,0x56,0x65,0x63,0x33,0x00,0x00,0x00,0x1E,0x00,
+ 0x18,0x00,0x0C,0x00,0x10,0x00,0x06,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x14,0x00,0x05,0x00,0x0A,0x00,0x1E,0x00,0x00,0x00,0x00,0x01,0x05,0x00,0x1A,0x00,0x02,0x00,
+ 0x20,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0xFB,0xFF,0xFF,
+ 0x00,0x00,0x00,0x0F,0x06,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x74,0x65,0x73,0x74,
+ 0x33,0x00,0x00,0x00,0x7A,0xFD,0xFF,0xFF,0x00,0x00,0x04,0x00,0x18,0x00,0x01,0x00,0x24,0x00,0x00,0x00,
+ 0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0xFE,0xFF,0xFF,0x00,0x00,0x00,0x04,
+ 0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x74,0x65,0x73,0x74,
+ 0x32,0x00,0x00,0x00,0x9E,0xFF,0xFF,0xFF,0x03,0x00,0x10,0x00,0x20,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,
+ 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x68,0xFD,0xFF,0xFF,0x00,0x00,0x00,0x0C,0x08,0x00,0x00,0x00,
+ 0x01,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x74,0x65,0x73,0x74,0x31,0x00,0x00,0x00,0xEA,0xFD,0xFF,0xFF,
+ 0x00,0x00,0x02,0x00,0x08,0x00,0x04,0x00,0x1C,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xE8,0xFA,0xFF,0xFF,0x00,0x00,0x00,0x0B,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x7A,0x00,0x1A,0x00,0x14,0x00,0x08,0x00,0x0C,0x00,0x04,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x1A,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0x1C,0x00,0x00,0x00,
+ 0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2C,0xFB,0xFF,0xFF,0x00,0x00,0x00,0x0B,
+ 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x79,0x00,0x00,0x00,0x6E,0xFB,0xFF,0xFF,0x1C,0x00,0x00,0x00,
+ 0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x54,0xFB,0xFF,0xFF,0x00,0x00,0x00,0x0B,
+ 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x14,0x00,0x1C,0x00,0x04,0x00,0x08,0x00,
+ 0x00,0x00,0x0C,0x00,0x00,0x00,0x10,0x00,0x14,0x00,0x18,0x00,0x14,0x00,0x00,0x00,0x80,0x00,0x00,0x00,
+ 0x74,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x30,0x02,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xE0,0xFF,0xFF,0xFF,
+ 0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x07,0x00,0x00,0x00,
+ 0x70,0x72,0x69,0x76,0x61,0x74,0x65,0x00,0x08,0x00,0x0C,0x00,0x04,0x00,0x08,0x00,0x08,0x00,0x00,0x00,
+ 0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x0E,0x00,0x00,0x00,
+ 0x63,0x73,0x68,0x61,0x72,0x70,0x5F,0x70,0x61,0x72,0x74,0x69,0x61,0x6C,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x4C,0x00,0x00,0x00,0x26,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,0x6D,0x65,0x2E,0x45,0x78,0x61,0x6D,0x70,
+ 0x6C,0x65,0x2E,0x54,0x65,0x73,0x74,0x53,0x69,0x6D,0x70,0x6C,0x65,0x54,0x61,0x62,0x6C,0x65,0x57,0x69,
+ 0x74,0x68,0x45,0x6E,0x75,0x6D,0x00,0x00,0x00,0x00,0x1A,0x00,0x1C,0x00,0x08,0x00,0x0C,0x00,0x00,0x00,
+ 0x06,0x00,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x1A,0x00,0x00,0x00,
+ 0x00,0x00,0x04,0x00,0x3C,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x14,0x00,0x07,0x00,0x00,0x00,0x08,0x00,0x00,0x00,
+ 0x0C,0x00,0x10,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x01,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x63,0x6F,0x6C,0x6F,0x72,0x00,0x00,0x00,0x54,0xFD,0xFF,0xFF,
+ 0x00,0x00,0x00,0x01,0x28,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x08,0x00,0x00,0x00,0x10,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x74,0x00,0x00,0x00,
+ 0x3C,0x00,0x00,0x00,0x13,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,0x6D,0x65,0x2E,0x45,0x78,0x61,0x6D,0x70,
+ 0x6C,0x65,0x2E,0x54,0x65,0x73,0x74,0x00,0x00,0x00,0x1E,0x00,0x18,0x00,0x0C,0x00,0x10,0x00,0x06,0x00,
+ 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x0A,0x00,
+ 0x1E,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x02,0x00,0x01,0x00,0x20,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,
+ 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xD4,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x03,0x01,0x00,0x00,0x00,
+ 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x62,0x00,0x00,0x00,0x62,0xFD,0xFF,0xFF,0x30,0x00,0x00,0x00,
+ 0x1C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x07,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x08,0x00,0x0C,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x02,0x00,0x00,0x00,
+ 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x61,0x00,0x00,0x00,0xE4,0xFE,0xFF,0xFF,0x1C,0x00,0x00,0x00,
+ 0x14,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x17,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,0x6D,0x65,0x2E,0x45,0x78,0x61,0x6D,0x70,
+ 0x6C,0x65,0x32,0x2E,0x4D,0x6F,0x6E,0x73,0x74,0x65,0x72,0x00,0x20,0xFF,0xFF,0xFF,0x34,0x00,0x00,0x00,
+ 0x2C,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x12,0x00,0x00,0x00,
+ 0x2F,0x2F,0x6D,0x6F,0x6E,0x73,0x74,0x65,0x72,0x5F,0x74,0x65,0x73,0x74,0x2E,0x66,0x62,0x73,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,0x6D,0x65,0x2E,0x49,
+ 0x6E,0x50,0x61,0x72,0x65,0x6E,0x74,0x4E,0x61,0x6D,0x65,0x73,0x70,0x61,0x63,0x65,0x00,0x00,0x00,0x00,
+ 0x78,0xFF,0xFF,0xFF,0x48,0x00,0x00,0x00,0x3C,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x30,0x00,0x00,0x00,
+ 0x04,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x2F,0x2F,0x69,0x6E,0x63,0x6C,0x75,0x64,0x65,0x5F,0x74,0x65,
+ 0x73,0x74,0x2F,0x69,0x6E,0x63,0x6C,0x75,0x64,0x65,0x5F,0x74,0x65,0x73,0x74,0x31,0x2E,0x66,0x62,0x73,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x06,0x00,0x00,0x00,
+ 0x54,0x61,0x62,0x6C,0x65,0x41,0x00,0x00,0x74,0xFF,0xFF,0xFF,0x00,0x01,0x04,0x00,0x20,0x00,0x00,0x00,
+ 0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x0F,
+ 0x0C,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x62,0x00,0x00,0x00,0x14,0x00,0x18,0x00,
+ 0x04,0x00,0x08,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x14,0x00,0x14,0x00,0x00,0x00,
+ 0x20,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0xC4,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x44,0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,
+ 0x6D,0x65,0x2E,0x4F,0x74,0x68,0x65,0x72,0x4E,0x61,0x6D,0x65,0x53,0x70,0x61,0x63,0x65,0x2E,0x54,0x61,
+ 0x62,0x6C,0x65,0x42,0x00,0x00,0x00,0x00,0x1C,0x00,0x14,0x00,0x08,0x00,0x0C,0x00,0x00,0x00,0x06,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x05,0x00,0x1C,0x00,0x00,0x00,
+ 0x00,0x01,0x04,0x00,0x30,0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x10,0x00,0x10,0x00,0x07,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x10,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x0F,0x0E,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x61,0x00,0x00,0x00,
+ 0x14,0x00,0x20,0x00,0x08,0x00,0x0C,0x00,0x07,0x00,0x10,0x00,0x14,0x00,0x00,0x00,0x18,0x00,0x1C,0x00,
+ 0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x50,0x00,0x00,0x00,0x44,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
+ 0x04,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x2F,0x2F,0x69,0x6E,
+ 0x63,0x6C,0x75,0x64,0x65,0x5F,0x74,0x65,0x73,0x74,0x2F,0x73,0x75,0x62,0x2F,0x69,0x6E,0x63,0x6C,0x75,
+ 0x64,0x65,0x5F,0x74,0x65,0x73,0x74,0x32,0x2E,0x66,0x62,0x73,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x01,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x4D,0x79,0x47,0x61,0x6D,0x65,0x2E,0x4F,
+ 0x74,0x68,0x65,0x72,0x4E,0x61,0x6D,0x65,0x53,0x70,0x61,0x63,0x65,0x2E,0x55,0x6E,0x75,0x73,0x65,0x64,
+ 0x00,0x00,0x1A,0x00,0x10,0x00,0x04,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x1A,0x00,0x00,0x00,0x2C,0x00,0x00,0x00,0x1C,0x00,0x00,0x00,
+ 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x0C,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x08,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x61,0x00,0x00,0x00
};
return bfbsData;
}
static size_t size() {
- return 14648;
+ return 14784;
}
const uint8_t *begin() {
return data();
diff --git a/tests/monster_test_generated.h b/tests/monster_test_generated.h
index eeaa341..deab77b 100644
--- a/tests/monster_test_generated.h
+++ b/tests/monster_test_generated.h
@@ -6,6 +6,14 @@
#include "flatbuffers/flatbuffers.h"
#include "flatbuffers/flexbuffers.h"
+#include "flatbuffers/flex_flat_util.h"
+
+// Ensure the included flatbuffers.h is the same version as when this file was
+// generated, otherwise it may not be compatible.
+static_assert(FLATBUFFERS_VERSION_MAJOR == 2 &&
+ FLATBUFFERS_VERSION_MINOR == 0 &&
+ FLATBUFFERS_VERSION_REVISION == 8,
+ "Non-compatible flatbuffers version included");
namespace MyGame {
@@ -35,6 +43,8 @@
struct StructOfStructs;
+struct StructOfStructsOfStructs;
+
struct Stat;
struct StatBuilder;
struct StatT;
@@ -73,6 +83,8 @@
bool operator!=(const Ability &lhs, const Ability &rhs);
bool operator==(const StructOfStructs &lhs, const StructOfStructs &rhs);
bool operator!=(const StructOfStructs &lhs, const StructOfStructs &rhs);
+bool operator==(const StructOfStructsOfStructs &lhs, const StructOfStructsOfStructs &rhs);
+bool operator!=(const StructOfStructsOfStructs &lhs, const StructOfStructsOfStructs &rhs);
bool operator==(const StatT &lhs, const StatT &rhs);
bool operator!=(const StatT &lhs, const StatT &rhs);
bool operator==(const ReferrableT &lhs, const ReferrableT &rhs);
@@ -104,6 +116,8 @@
inline const flatbuffers::TypeTable *StructOfStructsTypeTable();
+inline const flatbuffers::TypeTable *StructOfStructsOfStructsTypeTable();
+
inline const flatbuffers::TypeTable *StatTypeTable();
inline const flatbuffers::TypeTable *ReferrableTypeTable();
@@ -890,6 +904,39 @@
}
+FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) StructOfStructsOfStructs FLATBUFFERS_FINAL_CLASS {
+ private:
+ MyGame::Example::StructOfStructs a_;
+
+ public:
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return StructOfStructsOfStructsTypeTable();
+ }
+ StructOfStructsOfStructs()
+ : a_() {
+ }
+ StructOfStructsOfStructs(const MyGame::Example::StructOfStructs &_a)
+ : a_(_a) {
+ }
+ const MyGame::Example::StructOfStructs &a() const {
+ return a_;
+ }
+ MyGame::Example::StructOfStructs &mutable_a() {
+ return a_;
+ }
+};
+FLATBUFFERS_STRUCT_END(StructOfStructsOfStructs, 20);
+
+inline bool operator==(const StructOfStructsOfStructs &lhs, const StructOfStructsOfStructs &rhs) {
+ return
+ (lhs.a() == rhs.a());
+}
+
+inline bool operator!=(const StructOfStructsOfStructs &lhs, const StructOfStructsOfStructs &rhs) {
+ return !(lhs == rhs);
+}
+
+
} // namespace Example
struct InParentNamespaceT : public flatbuffers::NativeTable {
@@ -2680,7 +2727,7 @@
(lhs.test == rhs.test) &&
(lhs.test4 == rhs.test4) &&
(lhs.testarrayofstring == rhs.testarrayofstring) &&
- (lhs.testarrayoftables == rhs.testarrayoftables) &&
+ (lhs.testarrayoftables.size() == rhs.testarrayoftables.size() && std::equal(lhs.testarrayoftables.cbegin(), lhs.testarrayoftables.cend(), rhs.testarrayoftables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::MonsterT> const &a, flatbuffers::unique_ptr<MyGame::Example::MonsterT> const &b) { return (a == b) || (a && b && *a == *b); })) &&
((lhs.enemy == rhs.enemy) || (lhs.enemy && rhs.enemy && *lhs.enemy == *rhs.enemy)) &&
(lhs.testnestedflatbuffer == rhs.testnestedflatbuffer) &&
((lhs.testempty == rhs.testempty) || (lhs.testempty && rhs.testempty && *lhs.testempty == *rhs.testempty)) &&
@@ -2704,10 +2751,10 @@
(lhs.vector_of_longs == rhs.vector_of_longs) &&
(lhs.vector_of_doubles == rhs.vector_of_doubles) &&
((lhs.parent_namespace_test == rhs.parent_namespace_test) || (lhs.parent_namespace_test && rhs.parent_namespace_test && *lhs.parent_namespace_test == *rhs.parent_namespace_test)) &&
- (lhs.vector_of_referrables == rhs.vector_of_referrables) &&
+ (lhs.vector_of_referrables.size() == rhs.vector_of_referrables.size() && std::equal(lhs.vector_of_referrables.cbegin(), lhs.vector_of_referrables.cend(), rhs.vector_of_referrables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &a, flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &b) { return (a == b) || (a && b && *a == *b); })) &&
(lhs.single_weak_reference == rhs.single_weak_reference) &&
(lhs.vector_of_weak_references == rhs.vector_of_weak_references) &&
- (lhs.vector_of_strong_referrables == rhs.vector_of_strong_referrables) &&
+ (lhs.vector_of_strong_referrables.size() == rhs.vector_of_strong_referrables.size() && std::equal(lhs.vector_of_strong_referrables.cbegin(), lhs.vector_of_strong_referrables.cend(), rhs.vector_of_strong_referrables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &a, flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &b) { return (a == b) || (a && b && *a == *b); })) &&
(lhs.co_owning_reference == rhs.co_owning_reference) &&
(lhs.vector_of_co_owning_references == rhs.vector_of_co_owning_references) &&
(lhs.non_owning_reference == rhs.non_owning_reference) &&
@@ -2717,7 +2764,7 @@
(lhs.vector_of_enums == rhs.vector_of_enums) &&
(lhs.signed_enum == rhs.signed_enum) &&
(lhs.testrequirednestedflatbuffer == rhs.testrequirednestedflatbuffer) &&
- (lhs.scalar_key_sorted_tables == rhs.scalar_key_sorted_tables) &&
+ (lhs.scalar_key_sorted_tables.size() == rhs.scalar_key_sorted_tables.size() && std::equal(lhs.scalar_key_sorted_tables.cbegin(), lhs.scalar_key_sorted_tables.cend(), rhs.scalar_key_sorted_tables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::StatT> const &a, flatbuffers::unique_ptr<MyGame::Example::StatT> const &b) { return (a == b) || (a && b && *a == *b); })) &&
(lhs.native_inline == rhs.native_inline) &&
(lhs.long_enum_non_enum_default == rhs.long_enum_non_enum_default) &&
(lhs.long_enum_normal_default == rhs.long_enum_normal_default);
@@ -2857,55 +2904,48 @@
{ auto _e = color(); _o->color = _e; }
{ auto _e = test_type(); _o->test.type = _e; }
{ auto _e = test(); if (_e) _o->test.value = MyGame::Example::AnyUnion::UnPack(_e, test_type(), _resolver); }
- { auto _e = test4(); if (_e) { _o->test4.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->test4[_i] = *_e->Get(_i); } } }
- { auto _e = testarrayofstring(); if (_e) { _o->testarrayofstring.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofstring[_i] = _e->Get(_i)->str(); } } }
- { auto _e = testarrayoftables(); if (_e) { _o->testarrayoftables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->testarrayoftables[_i]) { _e->Get(_i)->UnPackTo(_o->testarrayoftables[_i].get(), _resolver); } else { _o->testarrayoftables[_i] = flatbuffers::unique_ptr<MyGame::Example::MonsterT>(_e->Get(_i)->UnPack(_resolver)); }; } } }
- { auto _e = enemy(); if (_e) { if(_o->enemy) { _e->UnPackTo(_o->enemy.get(), _resolver); } else { _o->enemy = flatbuffers::unique_ptr<MyGame::Example::MonsterT>(_e->UnPack(_resolver)); } } }
+ { auto _e = test4(); if (_e) { _o->test4.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->test4[_i] = *_e->Get(_i); } } else { _o->test4.resize(0); } }
+ { auto _e = testarrayofstring(); if (_e) { _o->testarrayofstring.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofstring[_i] = _e->Get(_i)->str(); } } else { _o->testarrayofstring.resize(0); } }
+ { auto _e = testarrayoftables(); if (_e) { _o->testarrayoftables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->testarrayoftables[_i]) { _e->Get(_i)->UnPackTo(_o->testarrayoftables[_i].get(), _resolver); } else { _o->testarrayoftables[_i] = flatbuffers::unique_ptr<MyGame::Example::MonsterT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->testarrayoftables.resize(0); } }
+ { auto _e = enemy(); if (_e) { if(_o->enemy) { _e->UnPackTo(_o->enemy.get(), _resolver); } else { _o->enemy = flatbuffers::unique_ptr<MyGame::Example::MonsterT>(_e->UnPack(_resolver)); } } else if (_o->enemy) { _o->enemy.reset(); } }
{ auto _e = testnestedflatbuffer(); if (_e) { _o->testnestedflatbuffer.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->testnestedflatbuffer.begin()); } }
- { auto _e = testempty(); if (_e) { if(_o->testempty) { _e->UnPackTo(_o->testempty.get(), _resolver); } else { _o->testempty = flatbuffers::unique_ptr<MyGame::Example::StatT>(_e->UnPack(_resolver)); } } }
+ { auto _e = testempty(); if (_e) { if(_o->testempty) { _e->UnPackTo(_o->testempty.get(), _resolver); } else { _o->testempty = flatbuffers::unique_ptr<MyGame::Example::StatT>(_e->UnPack(_resolver)); } } else if (_o->testempty) { _o->testempty.reset(); } }
{ auto _e = testbool(); _o->testbool = _e; }
{ auto _e = testhashs32_fnv1(); _o->testhashs32_fnv1 = _e; }
{ auto _e = testhashu32_fnv1(); _o->testhashu32_fnv1 = _e; }
{ auto _e = testhashs64_fnv1(); _o->testhashs64_fnv1 = _e; }
{ auto _e = testhashu64_fnv1(); _o->testhashu64_fnv1 = _e; }
{ auto _e = testhashs32_fnv1a(); _o->testhashs32_fnv1a = _e; }
- { auto _e = testhashu32_fnv1a(); //scalar resolver, naked
-if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->testhashu32_fnv1a), static_cast<flatbuffers::hash_value_t>(_e)); else _o->testhashu32_fnv1a = nullptr; }
+ { auto _e = testhashu32_fnv1a(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->testhashu32_fnv1a), static_cast<flatbuffers::hash_value_t>(_e)); else _o->testhashu32_fnv1a = nullptr; }
{ auto _e = testhashs64_fnv1a(); _o->testhashs64_fnv1a = _e; }
{ auto _e = testhashu64_fnv1a(); _o->testhashu64_fnv1a = _e; }
- { auto _e = testarrayofbools(); if (_e) { _o->testarrayofbools.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofbools[_i] = _e->Get(_i) != 0; } } }
+ { auto _e = testarrayofbools(); if (_e) { _o->testarrayofbools.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofbools[_i] = _e->Get(_i) != 0; } } else { _o->testarrayofbools.resize(0); } }
{ auto _e = testf(); _o->testf = _e; }
{ auto _e = testf2(); _o->testf2 = _e; }
{ auto _e = testf3(); _o->testf3 = _e; }
- { auto _e = testarrayofstring2(); if (_e) { _o->testarrayofstring2.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofstring2[_i] = _e->Get(_i)->str(); } } }
- { auto _e = testarrayofsortedstruct(); if (_e) { _o->testarrayofsortedstruct.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofsortedstruct[_i] = *_e->Get(_i); } } }
+ { auto _e = testarrayofstring2(); if (_e) { _o->testarrayofstring2.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofstring2[_i] = _e->Get(_i)->str(); } } else { _o->testarrayofstring2.resize(0); } }
+ { auto _e = testarrayofsortedstruct(); if (_e) { _o->testarrayofsortedstruct.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofsortedstruct[_i] = *_e->Get(_i); } } else { _o->testarrayofsortedstruct.resize(0); } }
{ auto _e = flex(); if (_e) { _o->flex.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->flex.begin()); } }
- { auto _e = test5(); if (_e) { _o->test5.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->test5[_i] = *_e->Get(_i); } } }
- { auto _e = vector_of_longs(); if (_e) { _o->vector_of_longs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_longs[_i] = _e->Get(_i); } } }
- { auto _e = vector_of_doubles(); if (_e) { _o->vector_of_doubles.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_doubles[_i] = _e->Get(_i); } } }
- { auto _e = parent_namespace_test(); if (_e) { if(_o->parent_namespace_test) { _e->UnPackTo(_o->parent_namespace_test.get(), _resolver); } else { _o->parent_namespace_test = flatbuffers::unique_ptr<MyGame::InParentNamespaceT>(_e->UnPack(_resolver)); } } }
- { auto _e = vector_of_referrables(); if (_e) { _o->vector_of_referrables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_referrables[_i].get(), _resolver); } else { _o->vector_of_referrables[_i] = flatbuffers::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } }
- { auto _e = single_weak_reference(); //scalar resolver, naked
-if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->single_weak_reference), static_cast<flatbuffers::hash_value_t>(_e)); else _o->single_weak_reference = nullptr; }
- { auto _e = vector_of_weak_references(); if (_e) { _o->vector_of_weak_references.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { //vector resolver, naked
-if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_weak_references[_i]), static_cast<flatbuffers::hash_value_t>(_e->Get(_i))); else _o->vector_of_weak_references[_i] = nullptr; } } }
- { auto _e = vector_of_strong_referrables(); if (_e) { _o->vector_of_strong_referrables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_strong_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_strong_referrables[_i].get(), _resolver); } else { _o->vector_of_strong_referrables[_i] = flatbuffers::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } }
- { auto _e = co_owning_reference(); //scalar resolver, naked
-if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->co_owning_reference), static_cast<flatbuffers::hash_value_t>(_e)); else _o->co_owning_reference = nullptr; }
- { auto _e = vector_of_co_owning_references(); if (_e) { _o->vector_of_co_owning_references.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { //vector resolver, default_ptr_type
-if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_co_owning_references[_i]), static_cast<flatbuffers::hash_value_t>(_e->Get(_i)));/* else do nothing */; } } }
- { auto _e = non_owning_reference(); //scalar resolver, naked
-if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->non_owning_reference), static_cast<flatbuffers::hash_value_t>(_e)); else _o->non_owning_reference = nullptr; }
- { auto _e = vector_of_non_owning_references(); if (_e) { _o->vector_of_non_owning_references.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { //vector resolver, naked
-if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_non_owning_references[_i]), static_cast<flatbuffers::hash_value_t>(_e->Get(_i))); else _o->vector_of_non_owning_references[_i] = nullptr; } } }
+ { auto _e = test5(); if (_e) { _o->test5.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->test5[_i] = *_e->Get(_i); } } else { _o->test5.resize(0); } }
+ { auto _e = vector_of_longs(); if (_e) { _o->vector_of_longs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_longs[_i] = _e->Get(_i); } } else { _o->vector_of_longs.resize(0); } }
+ { auto _e = vector_of_doubles(); if (_e) { _o->vector_of_doubles.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_doubles[_i] = _e->Get(_i); } } else { _o->vector_of_doubles.resize(0); } }
+ { auto _e = parent_namespace_test(); if (_e) { if(_o->parent_namespace_test) { _e->UnPackTo(_o->parent_namespace_test.get(), _resolver); } else { _o->parent_namespace_test = flatbuffers::unique_ptr<MyGame::InParentNamespaceT>(_e->UnPack(_resolver)); } } else if (_o->parent_namespace_test) { _o->parent_namespace_test.reset(); } }
+ { auto _e = vector_of_referrables(); if (_e) { _o->vector_of_referrables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_referrables[_i].get(), _resolver); } else { _o->vector_of_referrables[_i] = flatbuffers::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->vector_of_referrables.resize(0); } }
+ { auto _e = single_weak_reference(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->single_weak_reference), static_cast<flatbuffers::hash_value_t>(_e)); else _o->single_weak_reference = nullptr; }
+ { auto _e = vector_of_weak_references(); if (_e) { _o->vector_of_weak_references.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { /*vector resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_weak_references[_i]), static_cast<flatbuffers::hash_value_t>(_e->Get(_i))); else _o->vector_of_weak_references[_i] = nullptr; } } else { _o->vector_of_weak_references.resize(0); } }
+ { auto _e = vector_of_strong_referrables(); if (_e) { _o->vector_of_strong_referrables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_strong_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_strong_referrables[_i].get(), _resolver); } else { _o->vector_of_strong_referrables[_i] = flatbuffers::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->vector_of_strong_referrables.resize(0); } }
+ { auto _e = co_owning_reference(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->co_owning_reference), static_cast<flatbuffers::hash_value_t>(_e)); else _o->co_owning_reference = nullptr; }
+ { auto _e = vector_of_co_owning_references(); if (_e) { _o->vector_of_co_owning_references.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { /*vector resolver, default_ptr_type*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_co_owning_references[_i]), static_cast<flatbuffers::hash_value_t>(_e->Get(_i)));/* else do nothing */; } } else { _o->vector_of_co_owning_references.resize(0); } }
+ { auto _e = non_owning_reference(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->non_owning_reference), static_cast<flatbuffers::hash_value_t>(_e)); else _o->non_owning_reference = nullptr; }
+ { auto _e = vector_of_non_owning_references(); if (_e) { _o->vector_of_non_owning_references.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { /*vector resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_non_owning_references[_i]), static_cast<flatbuffers::hash_value_t>(_e->Get(_i))); else _o->vector_of_non_owning_references[_i] = nullptr; } } else { _o->vector_of_non_owning_references.resize(0); } }
{ auto _e = any_unique_type(); _o->any_unique.type = _e; }
{ auto _e = any_unique(); if (_e) _o->any_unique.value = MyGame::Example::AnyUniqueAliasesUnion::UnPack(_e, any_unique_type(), _resolver); }
{ auto _e = any_ambiguous_type(); _o->any_ambiguous.type = _e; }
{ auto _e = any_ambiguous(); if (_e) _o->any_ambiguous.value = MyGame::Example::AnyAmbiguousAliasesUnion::UnPack(_e, any_ambiguous_type(), _resolver); }
- { auto _e = vector_of_enums(); if (_e) { _o->vector_of_enums.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_enums[_i] = static_cast<MyGame::Example::Color>(_e->Get(_i)); } } }
+ { auto _e = vector_of_enums(); if (_e) { _o->vector_of_enums.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_enums[_i] = static_cast<MyGame::Example::Color>(_e->Get(_i)); } } else { _o->vector_of_enums.resize(0); } }
{ auto _e = signed_enum(); _o->signed_enum = _e; }
{ auto _e = testrequirednestedflatbuffer(); if (_e) { _o->testrequirednestedflatbuffer.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->testrequirednestedflatbuffer.begin()); } }
- { auto _e = scalar_key_sorted_tables(); if (_e) { _o->scalar_key_sorted_tables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->scalar_key_sorted_tables[_i]) { _e->Get(_i)->UnPackTo(_o->scalar_key_sorted_tables[_i].get(), _resolver); } else { _o->scalar_key_sorted_tables[_i] = flatbuffers::unique_ptr<MyGame::Example::StatT>(_e->Get(_i)->UnPack(_resolver)); }; } } }
+ { auto _e = scalar_key_sorted_tables(); if (_e) { _o->scalar_key_sorted_tables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->scalar_key_sorted_tables[_i]) { _e->Get(_i)->UnPackTo(_o->scalar_key_sorted_tables[_i].get(), _resolver); } else { _o->scalar_key_sorted_tables[_i] = flatbuffers::unique_ptr<MyGame::Example::StatT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->scalar_key_sorted_tables.resize(0); } }
{ auto _e = native_inline(); if (_e) _o->native_inline = *_e; }
{ auto _e = long_enum_non_enum_default(); _o->long_enum_non_enum_default = _e; }
{ auto _e = long_enum_normal_default(); _o->long_enum_normal_default = _e; }
@@ -2919,7 +2959,7 @@
(void)_rehasher;
(void)_o;
struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const MonsterT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
- auto _pos = _o->pos ? _o->pos.get() : 0;
+ auto _pos = _o->pos ? _o->pos.get() : nullptr;
auto _mana = _o->mana;
auto _hp = _o->hp;
auto _name = _fbb.CreateString(_o->name);
@@ -3071,7 +3111,7 @@
{ auto _e = f32(); _o->f32 = _e; }
{ auto _e = f64(); _o->f64 = _e; }
{ auto _e = v8(); if (_e) { _o->v8.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->v8.begin()); } }
- { auto _e = vf64(); if (_e) { _o->vf64.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vf64[_i] = _e->Get(_i); } } }
+ { auto _e = vf64(); if (_e) { _o->vf64.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vf64[_i] = _e->Get(_i); } } else { _o->vf64.resize(0); } }
}
inline flatbuffers::Offset<TypeAliases> TypeAliases::Pack(flatbuffers::FlatBufferBuilder &_fbb, const TypeAliasesT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
@@ -3704,6 +3744,23 @@
return &tt;
}
+inline const flatbuffers::TypeTable *StructOfStructsOfStructsTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_SEQUENCE, 0, 0 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::StructOfStructsTypeTable
+ };
+ static const int64_t values[] = { 0, 20 };
+ static const char * const names[] = {
+ "a"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_STRUCT, 1, type_codes, type_refs, nullptr, values, names
+ };
+ return &tt;
+}
+
inline const flatbuffers::TypeTable *StatTypeTable() {
static const flatbuffers::TypeCode type_codes[] = {
{ flatbuffers::ET_STRING, 0, -1 },
diff --git a/tests/monster_test_generated.lobster b/tests/monster_test_generated.lobster
index 238206f..c3ee785 100644
--- a/tests/monster_test_generated.lobster
+++ b/tests/monster_test_generated.lobster
@@ -61,6 +61,8 @@
class StructOfStructs
+class StructOfStructsOfStructs
+
class Stat
class Referrable
@@ -100,9 +102,9 @@
namespace MyGame_Example
class Test : flatbuffers_handle
- def a():
+ def a() -> int:
return buf_.read_int16_le(pos_ + 0)
- def b():
+ def b() -> int:
return buf_.read_int8_le(pos_ + 2)
def CreateTest(b_:flatbuffers_builder, a:int, b:int):
@@ -113,7 +115,7 @@
return b_.Offset()
class TestSimpleTableWithEnum : flatbuffers_handle
- def color():
+ def color() -> Color:
return Color(buf_.flatbuffers_field_uint8(pos_, 4, 2))
def GetRootAsTestSimpleTableWithEnum(buf:string): return TestSimpleTableWithEnum { buf, buf.flatbuffers_indirect(0) }
@@ -130,17 +132,17 @@
return b_.EndObject()
class Vec3 : flatbuffers_handle
- def x():
+ def x() -> float:
return buf_.read_float32_le(pos_ + 0)
- def y():
+ def y() -> float:
return buf_.read_float32_le(pos_ + 4)
- def z():
+ def z() -> float:
return buf_.read_float32_le(pos_ + 8)
- def test1():
+ def test1() -> float:
return buf_.read_float64_le(pos_ + 16)
- def test2():
+ def test2() -> Color:
return Color(buf_.read_uint8_le(pos_ + 24))
- def test3():
+ def test3() -> MyGame_Example_Test:
return MyGame_Example_Test{ buf_, pos_ + 26 }
def CreateVec3(b_:flatbuffers_builder, x:float, y:float, z:float, test1:float, test2:Color, test3_a:int, test3_b:int):
@@ -160,9 +162,9 @@
return b_.Offset()
class Ability : flatbuffers_handle
- def id():
+ def id() -> int:
return buf_.read_uint32_le(pos_ + 0)
- def distance():
+ def distance() -> int:
return buf_.read_uint32_le(pos_ + 4)
def CreateAbility(b_:flatbuffers_builder, id:int, distance:int):
@@ -172,11 +174,11 @@
return b_.Offset()
class StructOfStructs : flatbuffers_handle
- def a():
+ def a() -> MyGame_Example_Ability:
return MyGame_Example_Ability{ buf_, pos_ + 0 }
- def b():
+ def b() -> MyGame_Example_Test:
return MyGame_Example_Test{ buf_, pos_ + 8 }
- def c():
+ def c() -> MyGame_Example_Ability:
return MyGame_Example_Ability{ buf_, pos_ + 12 }
def CreateStructOfStructs(b_:flatbuffers_builder, a_id:int, a_distance:int, b_a:int, b_b:int, c_id:int, c_distance:int):
@@ -193,12 +195,31 @@
b_.PrependUint32(a_id)
return b_.Offset()
+class StructOfStructsOfStructs : flatbuffers_handle
+ def a() -> MyGame_Example_StructOfStructs:
+ return MyGame_Example_StructOfStructs{ buf_, pos_ + 0 }
+
+def CreateStructOfStructsOfStructs(b_:flatbuffers_builder, a_a_id:int, a_a_distance:int, a_b_a:int, a_b_b:int, a_c_id:int, a_c_distance:int):
+ b_.Prep(4, 20)
+ b_.Prep(4, 20)
+ b_.Prep(4, 8)
+ b_.PrependUint32(a_c_distance)
+ b_.PrependUint32(a_c_id)
+ b_.Prep(2, 4)
+ b_.Pad(1)
+ b_.PrependInt8(a_b_b)
+ b_.PrependInt16(a_b_a)
+ b_.Prep(4, 8)
+ b_.PrependUint32(a_a_distance)
+ b_.PrependUint32(a_a_id)
+ return b_.Offset()
+
class Stat : flatbuffers_handle
- def id():
+ def id() -> string:
return buf_.flatbuffers_field_string(pos_, 4)
- def val():
+ def val() -> int:
return buf_.flatbuffers_field_int64(pos_, 6, 0)
- def count():
+ def count() -> int:
return buf_.flatbuffers_field_uint16(pos_, 8, 0)
def GetRootAsStat(buf:string): return Stat { buf, buf.flatbuffers_indirect(0) }
@@ -221,7 +242,7 @@
return b_.EndObject()
class Referrable : flatbuffers_handle
- def id():
+ def id() -> int:
return buf_.flatbuffers_field_uint64(pos_, 4, 0)
def GetRootAsReferrable(buf:string): return Referrable { buf, buf.flatbuffers_indirect(0) }
@@ -239,22 +260,22 @@
/// an example documentation comment: "monster object"
class Monster : flatbuffers_handle
- def pos():
+ def pos() -> MyGame_Example_Vec3?:
let o = buf_.flatbuffers_field_struct(pos_, 4)
return if o: MyGame_Example_Vec3 { buf_, o } else: nil
- def mana():
+ def mana() -> int:
return buf_.flatbuffers_field_int16(pos_, 6, 150)
- def hp():
+ def hp() -> int:
return buf_.flatbuffers_field_int16(pos_, 8, 100)
- def name():
+ def name() -> string:
return buf_.flatbuffers_field_string(pos_, 10)
- def inventory(i:int):
+ def inventory(i:int) -> int:
return buf_.read_uint8_le(buf_.flatbuffers_field_vector(pos_, 14) + i * 1)
- def inventory_length():
+ def inventory_length() -> int:
return buf_.flatbuffers_field_vector_len(pos_, 14)
- def color():
+ def color() -> Color:
return Color(buf_.flatbuffers_field_uint8(pos_, 16, 8))
- def test_type():
+ def test_type() -> Any:
return Any(buf_.flatbuffers_field_uint8(pos_, 18, 0))
def test_as_Monster():
return MyGame_Example_Monster { buf_, buf_.flatbuffers_field_table(pos_, 20) }
@@ -262,112 +283,112 @@
return MyGame_Example_TestSimpleTableWithEnum { buf_, buf_.flatbuffers_field_table(pos_, 20) }
def test_as_MyGame_Example2_Monster():
return MyGame_Example2_Monster { buf_, buf_.flatbuffers_field_table(pos_, 20) }
- def test4(i:int):
+ def test4(i:int) -> MyGame_Example_Test:
return MyGame_Example_Test { buf_, buf_.flatbuffers_field_vector(pos_, 22) + i * 4 }
- def test4_length():
+ def test4_length() -> int:
return buf_.flatbuffers_field_vector_len(pos_, 22)
- def testarrayofstring(i:int):
+ def testarrayofstring(i:int) -> string:
return buf_.flatbuffers_string(buf_.flatbuffers_field_vector(pos_, 24) + i * 4)
- def testarrayofstring_length():
+ def testarrayofstring_length() -> int:
return buf_.flatbuffers_field_vector_len(pos_, 24)
/// an example documentation comment: this will end up in the generated code
/// multiline too
- def testarrayoftables(i:int):
+ def testarrayoftables(i:int) -> MyGame_Example_Monster:
return MyGame_Example_Monster { buf_, buf_.flatbuffers_indirect(buf_.flatbuffers_field_vector(pos_, 26) + i * 4) }
- def testarrayoftables_length():
+ def testarrayoftables_length() -> int:
return buf_.flatbuffers_field_vector_len(pos_, 26)
- def enemy():
+ def enemy() -> MyGame_Example_Monster?:
let o = buf_.flatbuffers_field_table(pos_, 28)
return if o: MyGame_Example_Monster { buf_, o } else: nil
- def testnestedflatbuffer(i:int):
+ def testnestedflatbuffer(i:int) -> int:
return buf_.read_uint8_le(buf_.flatbuffers_field_vector(pos_, 30) + i * 1)
- def testnestedflatbuffer_length():
+ def testnestedflatbuffer_length() -> int:
return buf_.flatbuffers_field_vector_len(pos_, 30)
- def testempty():
+ def testempty() -> MyGame_Example_Stat?:
let o = buf_.flatbuffers_field_table(pos_, 32)
return if o: MyGame_Example_Stat { buf_, o } else: nil
- def testbool():
- return buf_.flatbuffers_field_int8(pos_, 34, 0)
- def testhashs32_fnv1():
+ def testbool() -> bool:
+ return bool(buf_.flatbuffers_field_int8(pos_, 34, 0))
+ def testhashs32_fnv1() -> int:
return buf_.flatbuffers_field_int32(pos_, 36, 0)
- def testhashu32_fnv1():
+ def testhashu32_fnv1() -> int:
return buf_.flatbuffers_field_uint32(pos_, 38, 0)
- def testhashs64_fnv1():
+ def testhashs64_fnv1() -> int:
return buf_.flatbuffers_field_int64(pos_, 40, 0)
- def testhashu64_fnv1():
+ def testhashu64_fnv1() -> int:
return buf_.flatbuffers_field_uint64(pos_, 42, 0)
- def testhashs32_fnv1a():
+ def testhashs32_fnv1a() -> int:
return buf_.flatbuffers_field_int32(pos_, 44, 0)
- def testhashu32_fnv1a():
+ def testhashu32_fnv1a() -> int:
return buf_.flatbuffers_field_uint32(pos_, 46, 0)
- def testhashs64_fnv1a():
+ def testhashs64_fnv1a() -> int:
return buf_.flatbuffers_field_int64(pos_, 48, 0)
- def testhashu64_fnv1a():
+ def testhashu64_fnv1a() -> int:
return buf_.flatbuffers_field_uint64(pos_, 50, 0)
- def testarrayofbools(i:int):
+ def testarrayofbools(i:int) -> bool:
return buf_.read_int8_le(buf_.flatbuffers_field_vector(pos_, 52) + i * 1)
- def testarrayofbools_length():
+ def testarrayofbools_length() -> int:
return buf_.flatbuffers_field_vector_len(pos_, 52)
- def testf():
+ def testf() -> float:
return buf_.flatbuffers_field_float32(pos_, 54, 3.14159)
- def testf2():
+ def testf2() -> float:
return buf_.flatbuffers_field_float32(pos_, 56, 3.0)
- def testf3():
+ def testf3() -> float:
return buf_.flatbuffers_field_float32(pos_, 58, 0.0)
- def testarrayofstring2(i:int):
+ def testarrayofstring2(i:int) -> string:
return buf_.flatbuffers_string(buf_.flatbuffers_field_vector(pos_, 60) + i * 4)
- def testarrayofstring2_length():
+ def testarrayofstring2_length() -> int:
return buf_.flatbuffers_field_vector_len(pos_, 60)
- def testarrayofsortedstruct(i:int):
+ def testarrayofsortedstruct(i:int) -> MyGame_Example_Ability:
return MyGame_Example_Ability { buf_, buf_.flatbuffers_field_vector(pos_, 62) + i * 8 }
- def testarrayofsortedstruct_length():
+ def testarrayofsortedstruct_length() -> int:
return buf_.flatbuffers_field_vector_len(pos_, 62)
- def flex(i:int):
+ def flex(i:int) -> int:
return buf_.read_uint8_le(buf_.flatbuffers_field_vector(pos_, 64) + i * 1)
- def flex_length():
+ def flex_length() -> int:
return buf_.flatbuffers_field_vector_len(pos_, 64)
- def test5(i:int):
+ def test5(i:int) -> MyGame_Example_Test:
return MyGame_Example_Test { buf_, buf_.flatbuffers_field_vector(pos_, 66) + i * 4 }
- def test5_length():
+ def test5_length() -> int:
return buf_.flatbuffers_field_vector_len(pos_, 66)
- def vector_of_longs(i:int):
+ def vector_of_longs(i:int) -> int:
return buf_.read_int64_le(buf_.flatbuffers_field_vector(pos_, 68) + i * 8)
- def vector_of_longs_length():
+ def vector_of_longs_length() -> int:
return buf_.flatbuffers_field_vector_len(pos_, 68)
- def vector_of_doubles(i:int):
+ def vector_of_doubles(i:int) -> float:
return buf_.read_float64_le(buf_.flatbuffers_field_vector(pos_, 70) + i * 8)
- def vector_of_doubles_length():
+ def vector_of_doubles_length() -> int:
return buf_.flatbuffers_field_vector_len(pos_, 70)
- def parent_namespace_test():
+ def parent_namespace_test() -> MyGame_InParentNamespace?:
let o = buf_.flatbuffers_field_table(pos_, 72)
return if o: MyGame_InParentNamespace { buf_, o } else: nil
- def vector_of_referrables(i:int):
+ def vector_of_referrables(i:int) -> MyGame_Example_Referrable:
return MyGame_Example_Referrable { buf_, buf_.flatbuffers_indirect(buf_.flatbuffers_field_vector(pos_, 74) + i * 4) }
- def vector_of_referrables_length():
+ def vector_of_referrables_length() -> int:
return buf_.flatbuffers_field_vector_len(pos_, 74)
- def single_weak_reference():
+ def single_weak_reference() -> int:
return buf_.flatbuffers_field_uint64(pos_, 76, 0)
- def vector_of_weak_references(i:int):
+ def vector_of_weak_references(i:int) -> int:
return buf_.read_uint64_le(buf_.flatbuffers_field_vector(pos_, 78) + i * 8)
- def vector_of_weak_references_length():
+ def vector_of_weak_references_length() -> int:
return buf_.flatbuffers_field_vector_len(pos_, 78)
- def vector_of_strong_referrables(i:int):
+ def vector_of_strong_referrables(i:int) -> MyGame_Example_Referrable:
return MyGame_Example_Referrable { buf_, buf_.flatbuffers_indirect(buf_.flatbuffers_field_vector(pos_, 80) + i * 4) }
- def vector_of_strong_referrables_length():
+ def vector_of_strong_referrables_length() -> int:
return buf_.flatbuffers_field_vector_len(pos_, 80)
- def co_owning_reference():
+ def co_owning_reference() -> int:
return buf_.flatbuffers_field_uint64(pos_, 82, 0)
- def vector_of_co_owning_references(i:int):
+ def vector_of_co_owning_references(i:int) -> int:
return buf_.read_uint64_le(buf_.flatbuffers_field_vector(pos_, 84) + i * 8)
- def vector_of_co_owning_references_length():
+ def vector_of_co_owning_references_length() -> int:
return buf_.flatbuffers_field_vector_len(pos_, 84)
- def non_owning_reference():
+ def non_owning_reference() -> int:
return buf_.flatbuffers_field_uint64(pos_, 86, 0)
- def vector_of_non_owning_references(i:int):
+ def vector_of_non_owning_references(i:int) -> int:
return buf_.read_uint64_le(buf_.flatbuffers_field_vector(pos_, 88) + i * 8)
- def vector_of_non_owning_references_length():
+ def vector_of_non_owning_references_length() -> int:
return buf_.flatbuffers_field_vector_len(pos_, 88)
- def any_unique_type():
+ def any_unique_type() -> AnyUniqueAliases:
return AnyUniqueAliases(buf_.flatbuffers_field_uint8(pos_, 90, 0))
def any_unique_as_M():
return MyGame_Example_Monster { buf_, buf_.flatbuffers_field_table(pos_, 92) }
@@ -375,7 +396,7 @@
return MyGame_Example_TestSimpleTableWithEnum { buf_, buf_.flatbuffers_field_table(pos_, 92) }
def any_unique_as_M2():
return MyGame_Example2_Monster { buf_, buf_.flatbuffers_field_table(pos_, 92) }
- def any_ambiguous_type():
+ def any_ambiguous_type() -> AnyAmbiguousAliases:
return AnyAmbiguousAliases(buf_.flatbuffers_field_uint8(pos_, 94, 0))
def any_ambiguous_as_M1():
return MyGame_Example_Monster { buf_, buf_.flatbuffers_field_table(pos_, 96) }
@@ -383,26 +404,26 @@
return MyGame_Example_Monster { buf_, buf_.flatbuffers_field_table(pos_, 96) }
def any_ambiguous_as_M3():
return MyGame_Example_Monster { buf_, buf_.flatbuffers_field_table(pos_, 96) }
- def vector_of_enums(i:int):
+ def vector_of_enums(i:int) -> Color:
return buf_.read_uint8_le(buf_.flatbuffers_field_vector(pos_, 98) + i * 1)
- def vector_of_enums_length():
+ def vector_of_enums_length() -> int:
return buf_.flatbuffers_field_vector_len(pos_, 98)
- def signed_enum():
+ def signed_enum() -> Race:
return Race(buf_.flatbuffers_field_int8(pos_, 100, -1))
- def testrequirednestedflatbuffer(i:int):
+ def testrequirednestedflatbuffer(i:int) -> int:
return buf_.read_uint8_le(buf_.flatbuffers_field_vector(pos_, 102) + i * 1)
- def testrequirednestedflatbuffer_length():
+ def testrequirednestedflatbuffer_length() -> int:
return buf_.flatbuffers_field_vector_len(pos_, 102)
- def scalar_key_sorted_tables(i:int):
+ def scalar_key_sorted_tables(i:int) -> MyGame_Example_Stat:
return MyGame_Example_Stat { buf_, buf_.flatbuffers_indirect(buf_.flatbuffers_field_vector(pos_, 104) + i * 4) }
- def scalar_key_sorted_tables_length():
+ def scalar_key_sorted_tables_length() -> int:
return buf_.flatbuffers_field_vector_len(pos_, 104)
- def native_inline():
+ def native_inline() -> MyGame_Example_Test?:
let o = buf_.flatbuffers_field_struct(pos_, 106)
return if o: MyGame_Example_Test { buf_, o } else: nil
- def long_enum_non_enum_default():
+ def long_enum_non_enum_default() -> LongEnum:
return LongEnum(buf_.flatbuffers_field_uint64(pos_, 108, 0))
- def long_enum_normal_default():
+ def long_enum_normal_default() -> LongEnum:
return LongEnum(buf_.flatbuffers_field_uint64(pos_, 110, 2))
def GetRootAsMonster(buf:string): return Monster { buf, buf.flatbuffers_indirect(0) }
@@ -454,7 +475,7 @@
def add_testempty(testempty:flatbuffers_offset):
b_.PrependUOffsetTRelativeSlot(14, testempty)
return this
- def add_testbool(testbool:int):
+ def add_testbool(testbool:bool):
b_.PrependBoolSlot(15, testbool, 0)
return this
def add_testhashs32_fnv1(testhashs32_fnv1:int):
@@ -607,7 +628,7 @@
def MonsterStartTestarrayofboolsVector(b_:flatbuffers_builder, n_:int):
b_.StartVector(1, n_, 1)
-def MonsterCreateTestarrayofboolsVector(b_:flatbuffers_builder, v_:[int]):
+def MonsterCreateTestarrayofboolsVector(b_:flatbuffers_builder, v_:[bool]):
b_.StartVector(1, v_.length, 1)
reverse(v_) e_: b_.PrependBool(e_)
return b_.EndVector(v_.length)
@@ -703,33 +724,33 @@
return b_.EndVector(v_.length)
class TypeAliases : flatbuffers_handle
- def i8():
+ def i8() -> int:
return buf_.flatbuffers_field_int8(pos_, 4, 0)
- def u8():
+ def u8() -> int:
return buf_.flatbuffers_field_uint8(pos_, 6, 0)
- def i16():
+ def i16() -> int:
return buf_.flatbuffers_field_int16(pos_, 8, 0)
- def u16():
+ def u16() -> int:
return buf_.flatbuffers_field_uint16(pos_, 10, 0)
- def i32():
+ def i32() -> int:
return buf_.flatbuffers_field_int32(pos_, 12, 0)
- def u32():
+ def u32() -> int:
return buf_.flatbuffers_field_uint32(pos_, 14, 0)
- def i64():
+ def i64() -> int:
return buf_.flatbuffers_field_int64(pos_, 16, 0)
- def u64():
+ def u64() -> int:
return buf_.flatbuffers_field_uint64(pos_, 18, 0)
- def f32():
+ def f32() -> float:
return buf_.flatbuffers_field_float32(pos_, 20, 0.0)
- def f64():
+ def f64() -> float:
return buf_.flatbuffers_field_float64(pos_, 22, 0.0)
- def v8(i:int):
+ def v8(i:int) -> int:
return buf_.read_int8_le(buf_.flatbuffers_field_vector(pos_, 24) + i * 1)
- def v8_length():
+ def v8_length() -> int:
return buf_.flatbuffers_field_vector_len(pos_, 24)
- def vf64(i:int):
+ def vf64(i:int) -> float:
return buf_.read_float64_le(buf_.flatbuffers_field_vector(pos_, 26) + i * 8)
- def vf64_length():
+ def vf64_length() -> int:
return buf_.flatbuffers_field_vector_len(pos_, 26)
def GetRootAsTypeAliases(buf:string): return TypeAliases { buf, buf.flatbuffers_indirect(0) }
diff --git a/tests/monster_test_generated.py b/tests/monster_test_generated.py
index 71e266d..0fa2140 100644
--- a/tests/monster_test_generated.py
+++ b/tests/monster_test_generated.py
@@ -543,6 +543,73 @@
return CreateStructOfStructs(builder, self.a.id, self.a.distance, self.b.a, self.b.b, self.c.id, self.c.distance)
+class StructOfStructsOfStructs(object):
+ __slots__ = ['_tab']
+
+ @classmethod
+ def SizeOf(cls):
+ return 20
+
+ # StructOfStructsOfStructs
+ def Init(self, buf, pos):
+ self._tab = flatbuffers.table.Table(buf, pos)
+
+ # StructOfStructsOfStructs
+ def A(self, obj):
+ obj.Init(self._tab.Bytes, self._tab.Pos + 0)
+ return obj
+
+
+def CreateStructOfStructsOfStructs(builder, a_a_id, a_a_distance, a_b_a, a_b_b, a_c_id, a_c_distance):
+ builder.Prep(4, 20)
+ builder.Prep(4, 20)
+ builder.Prep(4, 8)
+ builder.PrependUint32(a_c_distance)
+ builder.PrependUint32(a_c_id)
+ builder.Prep(2, 4)
+ builder.Pad(1)
+ builder.PrependInt8(a_b_b)
+ builder.PrependInt16(a_b_a)
+ builder.Prep(4, 8)
+ builder.PrependUint32(a_a_distance)
+ builder.PrependUint32(a_a_id)
+ return builder.Offset()
+
+try:
+ from typing import Optional
+except:
+ pass
+
+class StructOfStructsOfStructsT(object):
+
+ # StructOfStructsOfStructsT
+ def __init__(self):
+ self.a = None # type: Optional[StructOfStructsT]
+
+ @classmethod
+ def InitFromBuf(cls, buf, pos):
+ structOfStructsOfStructs = StructOfStructsOfStructs()
+ structOfStructsOfStructs.Init(buf, pos)
+ return cls.InitFromObj(structOfStructsOfStructs)
+
+ @classmethod
+ def InitFromObj(cls, structOfStructsOfStructs):
+ x = StructOfStructsOfStructsT()
+ x._UnPack(structOfStructsOfStructs)
+ return x
+
+ # StructOfStructsOfStructsT
+ def _UnPack(self, structOfStructsOfStructs):
+ if structOfStructsOfStructs is None:
+ return
+ if structOfStructsOfStructs.A(StructOfStructs()) is not None:
+ self.a = StructOfStructsT.InitFromObj(structOfStructsOfStructs.A(StructOfStructs()))
+
+ # StructOfStructsOfStructsT
+ def Pack(self, builder):
+ return CreateStructOfStructsOfStructs(builder, self.a.a.id, self.a.a.distance, self.a.b.a, self.a.b.b, self.a.c.id, self.a.c.distance)
+
+
class Stat(object):
__slots__ = ['_tab']
diff --git a/tests/monster_test.js b/tests/monster_test_generated.ts
similarity index 78%
copy from tests/monster_test.js
copy to tests/monster_test_generated.ts
index b4e13d1..5fd080e 100644
--- a/tests/monster_test.js
+++ b/tests/monster_test_generated.ts
@@ -1,4 +1,6 @@
-export { Monster as MyGameExample2Monster, MonsterT as MyGameExample2MonsterT } from './my-game/example2/monster';
+// automatically generated by the FlatBuffers compiler, do not modify
+
+export { Monster as MyGame_Example2_Monster, MonsterT as MyGame_Example2_MonsterT } from './my-game/example2/monster';
export { Ability, AbilityT } from './my-game/example/ability';
export { Any, unionToAny, unionListToAny } from './my-game/example/any';
export { AnyAmbiguousAliases, unionToAnyAmbiguousAliases, unionListToAnyAmbiguousAliases } from './my-game/example/any-ambiguous-aliases';
@@ -9,6 +11,7 @@
export { Referrable, ReferrableT } from './my-game/example/referrable';
export { Stat, StatT } from './my-game/example/stat';
export { StructOfStructs, StructOfStructsT } from './my-game/example/struct-of-structs';
+export { StructOfStructsOfStructs, StructOfStructsOfStructsT } from './my-game/example/struct-of-structs-of-structs';
export { Test, TestT } from './my-game/example/test';
export { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from './my-game/example/test-simple-table-with-enum';
export { TypeAliases, TypeAliasesT } from './my-game/example/type-aliases';
diff --git a/tests/monster_test_my_game.example_generated.dart b/tests/monster_test_my_game.example_generated.dart
index dd816d9..174fe1d 100644
--- a/tests/monster_test_my_game.example_generated.dart
+++ b/tests/monster_test_my_game.example_generated.dart
@@ -152,7 +152,7 @@
const _LongEnumReader();
@override
- int get size => 1;
+ int get size => 8;
@override
LongEnum read(fb.BufferContext bc, int offset) =>
@@ -316,7 +316,7 @@
@override
String toString() {
- return 'Test{a: $a, b: $b}';
+ return 'Test{a: ${a}, b: ${b}}';
}
TestT unpack() => TestT(
@@ -347,7 +347,7 @@
@override
String toString() {
- return 'TestT{a: $a, b: $b}';
+ return 'TestT{a: ${a}, b: ${b}}';
}
}
@@ -420,7 +420,7 @@
@override
String toString() {
- return 'TestSimpleTableWithEnum{color: $color}';
+ return 'TestSimpleTableWithEnum{color: ${color}}';
}
TestSimpleTableWithEnumT unpack() => TestSimpleTableWithEnumT(
@@ -447,7 +447,7 @@
@override
String toString() {
- return 'TestSimpleTableWithEnumT{color: $color}';
+ return 'TestSimpleTableWithEnumT{color: ${color}}';
}
}
@@ -519,7 +519,7 @@
@override
String toString() {
- return 'Vec3{x: $x, y: $y, z: $z, test1: $test1, test2: $test2, test3: $test3}';
+ return 'Vec3{x: ${x}, y: ${y}, z: ${z}, test1: ${test1}, test2: ${test2}, test3: ${test3}}';
}
Vec3T unpack() => Vec3T(
@@ -568,7 +568,7 @@
@override
String toString() {
- return 'Vec3T{x: $x, y: $y, z: $z, test1: $test1, test2: $test2, test3: $test3}';
+ return 'Vec3T{x: ${x}, y: ${y}, z: ${z}, test1: ${test1}, test2: ${test2}, test3: ${test3}}';
}
}
@@ -662,7 +662,7 @@
@override
String toString() {
- return 'Ability{id: $id, distance: $distance}';
+ return 'Ability{id: ${id}, distance: ${distance}}';
}
AbilityT unpack() => AbilityT(
@@ -692,7 +692,7 @@
@override
String toString() {
- return 'AbilityT{id: $id, distance: $distance}';
+ return 'AbilityT{id: ${id}, distance: ${distance}}';
}
}
@@ -761,7 +761,7 @@
@override
String toString() {
- return 'StructOfStructs{a: $a, b: $b, c: $c}';
+ return 'StructOfStructs{a: ${a}, b: ${b}, c: ${c}}';
}
StructOfStructsT unpack() => StructOfStructsT(
@@ -795,7 +795,7 @@
@override
String toString() {
- return 'StructOfStructsT{a: $a, b: $b, c: $c}';
+ return 'StructOfStructsT{a: ${a}, b: ${b}, c: ${c}}';
}
}
@@ -855,6 +855,94 @@
return fbBuilder.buffer;
}
}
+class StructOfStructsOfStructs {
+ StructOfStructsOfStructs._(this._bc, this._bcOffset);
+
+ static const fb.Reader<StructOfStructsOfStructs> reader = _StructOfStructsOfStructsReader();
+
+ final fb.BufferContext _bc;
+ final int _bcOffset;
+
+ StructOfStructs get a => StructOfStructs.reader.read(_bc, _bcOffset + 0);
+
+ @override
+ String toString() {
+ return 'StructOfStructsOfStructs{a: ${a}}';
+ }
+
+ StructOfStructsOfStructsT unpack() => StructOfStructsOfStructsT(
+ a: a.unpack());
+
+ static int pack(fb.Builder fbBuilder, StructOfStructsOfStructsT? object) {
+ if (object == null) return 0;
+ return object.pack(fbBuilder);
+ }
+}
+
+class StructOfStructsOfStructsT implements fb.Packable {
+ StructOfStructsT a;
+
+ StructOfStructsOfStructsT({
+ required this.a});
+
+ @override
+ int pack(fb.Builder fbBuilder) {
+ a.pack(fbBuilder);
+ return fbBuilder.offset;
+ }
+
+ @override
+ String toString() {
+ return 'StructOfStructsOfStructsT{a: ${a}}';
+ }
+}
+
+class _StructOfStructsOfStructsReader extends fb.StructReader<StructOfStructsOfStructs> {
+ const _StructOfStructsOfStructsReader();
+
+ @override
+ int get size => 20;
+
+ @override
+ StructOfStructsOfStructs createObject(fb.BufferContext bc, int offset) =>
+ StructOfStructsOfStructs._(bc, offset);
+}
+
+class StructOfStructsOfStructsBuilder {
+ StructOfStructsOfStructsBuilder(this.fbBuilder);
+
+ final fb.Builder fbBuilder;
+
+ int finish(fb.StructBuilder a) {
+ a();
+ return fbBuilder.offset;
+ }
+
+}
+
+class StructOfStructsOfStructsObjectBuilder extends fb.ObjectBuilder {
+ final StructOfStructsObjectBuilder _a;
+
+ StructOfStructsOfStructsObjectBuilder({
+ required StructOfStructsObjectBuilder a,
+ })
+ : _a = a;
+
+ /// Finish building, and store into the [fbBuilder].
+ @override
+ int finish(fb.Builder fbBuilder) {
+ _a.finish(fbBuilder);
+ return fbBuilder.offset;
+ }
+
+ /// Convenience method to serialize to byte list.
+ @override
+ Uint8List toBytes([String? fileIdentifier]) {
+ final fbBuilder = fb.Builder(deduplicateTables: false);
+ fbBuilder.finish(finish(fbBuilder), fileIdentifier);
+ return fbBuilder.buffer;
+ }
+}
class Stat {
Stat._(this._bc, this._bcOffset);
factory Stat(List<int> bytes) {
@@ -873,7 +961,7 @@
@override
String toString() {
- return 'Stat{id: $id, val: $val, count: $count}';
+ return 'Stat{id: ${id}, val: ${val}, count: ${count}}';
}
StatT unpack() => StatT(
@@ -910,7 +998,7 @@
@override
String toString() {
- return 'StatT{id: $id, val: $val, count: $count}';
+ return 'StatT{id: ${id}, val: ${val}, count: ${count}}';
}
}
@@ -999,7 +1087,7 @@
@override
String toString() {
- return 'Referrable{id: $id}';
+ return 'Referrable{id: ${id}}';
}
ReferrableT unpack() => ReferrableT(
@@ -1026,7 +1114,7 @@
@override
String toString() {
- return 'ReferrableT{id: $id}';
+ return 'ReferrableT{id: ${id}}';
}
}
@@ -1173,7 +1261,7 @@
@override
String toString() {
- return 'Monster{pos: $pos, mana: $mana, hp: $hp, name: $name, inventory: $inventory, color: $color, testType: $testType, test: $test, test4: $test4, testarrayofstring: $testarrayofstring, testarrayoftables: $testarrayoftables, enemy: $enemy, testnestedflatbuffer: $testnestedflatbuffer, testempty: $testempty, testbool: $testbool, testhashs32Fnv1: $testhashs32Fnv1, testhashu32Fnv1: $testhashu32Fnv1, testhashs64Fnv1: $testhashs64Fnv1, testhashu64Fnv1: $testhashu64Fnv1, testhashs32Fnv1a: $testhashs32Fnv1a, testhashu32Fnv1a: $testhashu32Fnv1a, testhashs64Fnv1a: $testhashs64Fnv1a, testhashu64Fnv1a: $testhashu64Fnv1a, testarrayofbools: $testarrayofbools, testf: $testf, testf2: $testf2, testf3: $testf3, testarrayofstring2: $testarrayofstring2, testarrayofsortedstruct: $testarrayofsortedstruct, flex: $flex, test5: $test5, vectorOfLongs: $vectorOfLongs, vectorOfDoubles: $vectorOfDoubles, parentNamespaceTest: $parentNamespaceTest, vectorOfReferrables: $vectorOfReferrables, singleWeakReference: $singleWeakReference, vectorOfWeakReferences: $vectorOfWeakReferences, vectorOfStrongReferrables: $vectorOfStrongReferrables, coOwningReference: $coOwningReference, vectorOfCoOwningReferences: $vectorOfCoOwningReferences, nonOwningReference: $nonOwningReference, vectorOfNonOwningReferences: $vectorOfNonOwningReferences, anyUniqueType: $anyUniqueType, anyUnique: $anyUnique, anyAmbiguousType: $anyAmbiguousType, anyAmbiguous: $anyAmbiguous, vectorOfEnums: $vectorOfEnums, signedEnum: $signedEnum, testrequirednestedflatbuffer: $testrequirednestedflatbuffer, scalarKeySortedTables: $scalarKeySortedTables, nativeInline: $nativeInline, longEnumNonEnumDefault: $longEnumNonEnumDefault, longEnumNormalDefault: $longEnumNormalDefault}';
+ return 'Monster{pos: ${pos}, mana: ${mana}, hp: ${hp}, name: ${name}, inventory: ${inventory}, color: ${color}, testType: ${testType}, test: ${test}, test4: ${test4}, testarrayofstring: ${testarrayofstring}, testarrayoftables: ${testarrayoftables}, enemy: ${enemy}, testnestedflatbuffer: ${testnestedflatbuffer}, testempty: ${testempty}, testbool: ${testbool}, testhashs32Fnv1: ${testhashs32Fnv1}, testhashu32Fnv1: ${testhashu32Fnv1}, testhashs64Fnv1: ${testhashs64Fnv1}, testhashu64Fnv1: ${testhashu64Fnv1}, testhashs32Fnv1a: ${testhashs32Fnv1a}, testhashu32Fnv1a: ${testhashu32Fnv1a}, testhashs64Fnv1a: ${testhashs64Fnv1a}, testhashu64Fnv1a: ${testhashu64Fnv1a}, testarrayofbools: ${testarrayofbools}, testf: ${testf}, testf2: ${testf2}, testf3: ${testf3}, testarrayofstring2: ${testarrayofstring2}, testarrayofsortedstruct: ${testarrayofsortedstruct}, flex: ${flex}, test5: ${test5}, vectorOfLongs: ${vectorOfLongs}, vectorOfDoubles: ${vectorOfDoubles}, parentNamespaceTest: ${parentNamespaceTest}, vectorOfReferrables: ${vectorOfReferrables}, singleWeakReference: ${singleWeakReference}, vectorOfWeakReferences: ${vectorOfWeakReferences}, vectorOfStrongReferrables: ${vectorOfStrongReferrables}, coOwningReference: ${coOwningReference}, vectorOfCoOwningReferences: ${vectorOfCoOwningReferences}, nonOwningReference: ${nonOwningReference}, vectorOfNonOwningReferences: ${vectorOfNonOwningReferences}, anyUniqueType: ${anyUniqueType}, anyUnique: ${anyUnique}, anyAmbiguousType: ${anyAmbiguousType}, anyAmbiguous: ${anyAmbiguous}, vectorOfEnums: ${vectorOfEnums}, signedEnum: ${signedEnum}, testrequirednestedflatbuffer: ${testrequirednestedflatbuffer}, scalarKeySortedTables: ${scalarKeySortedTables}, nativeInline: ${nativeInline}, longEnumNonEnumDefault: ${longEnumNonEnumDefault}, longEnumNormalDefault: ${longEnumNormalDefault}}';
}
MonsterT unpack() => MonsterT(
@@ -1472,7 +1560,7 @@
@override
String toString() {
- return 'MonsterT{pos: $pos, mana: $mana, hp: $hp, name: $name, inventory: $inventory, color: $color, testType: $testType, test: $test, test4: $test4, testarrayofstring: $testarrayofstring, testarrayoftables: $testarrayoftables, enemy: $enemy, testnestedflatbuffer: $testnestedflatbuffer, testempty: $testempty, testbool: $testbool, testhashs32Fnv1: $testhashs32Fnv1, testhashu32Fnv1: $testhashu32Fnv1, testhashs64Fnv1: $testhashs64Fnv1, testhashu64Fnv1: $testhashu64Fnv1, testhashs32Fnv1a: $testhashs32Fnv1a, testhashu32Fnv1a: $testhashu32Fnv1a, testhashs64Fnv1a: $testhashs64Fnv1a, testhashu64Fnv1a: $testhashu64Fnv1a, testarrayofbools: $testarrayofbools, testf: $testf, testf2: $testf2, testf3: $testf3, testarrayofstring2: $testarrayofstring2, testarrayofsortedstruct: $testarrayofsortedstruct, flex: $flex, test5: $test5, vectorOfLongs: $vectorOfLongs, vectorOfDoubles: $vectorOfDoubles, parentNamespaceTest: $parentNamespaceTest, vectorOfReferrables: $vectorOfReferrables, singleWeakReference: $singleWeakReference, vectorOfWeakReferences: $vectorOfWeakReferences, vectorOfStrongReferrables: $vectorOfStrongReferrables, coOwningReference: $coOwningReference, vectorOfCoOwningReferences: $vectorOfCoOwningReferences, nonOwningReference: $nonOwningReference, vectorOfNonOwningReferences: $vectorOfNonOwningReferences, anyUniqueType: $anyUniqueType, anyUnique: $anyUnique, anyAmbiguousType: $anyAmbiguousType, anyAmbiguous: $anyAmbiguous, vectorOfEnums: $vectorOfEnums, signedEnum: $signedEnum, testrequirednestedflatbuffer: $testrequirednestedflatbuffer, scalarKeySortedTables: $scalarKeySortedTables, nativeInline: $nativeInline, longEnumNonEnumDefault: $longEnumNonEnumDefault, longEnumNormalDefault: $longEnumNormalDefault}';
+ return 'MonsterT{pos: ${pos}, mana: ${mana}, hp: ${hp}, name: ${name}, inventory: ${inventory}, color: ${color}, testType: ${testType}, test: ${test}, test4: ${test4}, testarrayofstring: ${testarrayofstring}, testarrayoftables: ${testarrayoftables}, enemy: ${enemy}, testnestedflatbuffer: ${testnestedflatbuffer}, testempty: ${testempty}, testbool: ${testbool}, testhashs32Fnv1: ${testhashs32Fnv1}, testhashu32Fnv1: ${testhashu32Fnv1}, testhashs64Fnv1: ${testhashs64Fnv1}, testhashu64Fnv1: ${testhashu64Fnv1}, testhashs32Fnv1a: ${testhashs32Fnv1a}, testhashu32Fnv1a: ${testhashu32Fnv1a}, testhashs64Fnv1a: ${testhashs64Fnv1a}, testhashu64Fnv1a: ${testhashu64Fnv1a}, testarrayofbools: ${testarrayofbools}, testf: ${testf}, testf2: ${testf2}, testf3: ${testf3}, testarrayofstring2: ${testarrayofstring2}, testarrayofsortedstruct: ${testarrayofsortedstruct}, flex: ${flex}, test5: ${test5}, vectorOfLongs: ${vectorOfLongs}, vectorOfDoubles: ${vectorOfDoubles}, parentNamespaceTest: ${parentNamespaceTest}, vectorOfReferrables: ${vectorOfReferrables}, singleWeakReference: ${singleWeakReference}, vectorOfWeakReferences: ${vectorOfWeakReferences}, vectorOfStrongReferrables: ${vectorOfStrongReferrables}, coOwningReference: ${coOwningReference}, vectorOfCoOwningReferences: ${vectorOfCoOwningReferences}, nonOwningReference: ${nonOwningReference}, vectorOfNonOwningReferences: ${vectorOfNonOwningReferences}, anyUniqueType: ${anyUniqueType}, anyUnique: ${anyUnique}, anyAmbiguousType: ${anyAmbiguousType}, anyAmbiguous: ${anyAmbiguous}, vectorOfEnums: ${vectorOfEnums}, signedEnum: ${signedEnum}, testrequirednestedflatbuffer: ${testrequirednestedflatbuffer}, scalarKeySortedTables: ${scalarKeySortedTables}, nativeInline: ${nativeInline}, longEnumNonEnumDefault: ${longEnumNonEnumDefault}, longEnumNormalDefault: ${longEnumNormalDefault}}';
}
}
@@ -2022,7 +2110,7 @@
@override
String toString() {
- return 'TypeAliases{i8: $i8, u8: $u8, i16: $i16, u16: $u16, i32: $i32, u32: $u32, i64: $i64, u64: $u64, f32: $f32, f64: $f64, v8: $v8, vf64: $vf64}';
+ return 'TypeAliases{i8: ${i8}, u8: ${u8}, i16: ${i16}, u16: ${u16}, i32: ${i32}, u32: ${u32}, i64: ${i64}, u64: ${u64}, f32: ${f32}, f64: ${f64}, v8: ${v8}, vf64: ${vf64}}';
}
TypeAliasesT unpack() => TypeAliasesT(
@@ -2097,7 +2185,7 @@
@override
String toString() {
- return 'TypeAliasesT{i8: $i8, u8: $u8, i16: $i16, u16: $u16, i32: $i32, u32: $u32, i64: $i64, u64: $u64, f32: $f32, f64: $f64, v8: $v8, vf64: $vf64}';
+ return 'TypeAliasesT{i8: ${i8}, u8: ${u8}, i16: ${i16}, u16: ${u16}, i32: ${i32}, u32: ${u32}, i64: ${i64}, u64: ${u64}, f32: ${f32}, f64: ${f64}, v8: ${v8}, vf64: ${vf64}}';
}
}
diff --git a/tests/monster_test_serialize/mod.rs b/tests/monster_test_serialize/mod.rs
index fdbc26b..7f1fab1 100644
--- a/tests/monster_test_serialize/mod.rs
+++ b/tests/monster_test_serialize/mod.rs
@@ -1,4 +1,5 @@
// Automatically generated by the Flatbuffers compiler. Do not modify.
+// @generated
pub mod my_game {
use super::*;
pub mod example {
@@ -25,6 +26,8 @@
pub use self::ability_generated::*;
mod struct_of_structs_generated;
pub use self::struct_of_structs_generated::*;
+ mod struct_of_structs_of_structs_generated;
+ pub use self::struct_of_structs_of_structs_generated::*;
mod stat_generated;
pub use self::stat_generated::*;
mod referrable_generated;
diff --git a/tests/monster_test_serialize/my_game/example/ability_generated.rs b/tests/monster_test_serialize/my_game/example/ability_generated.rs
index cdc7882..5c8bcf8 100644
--- a/tests/monster_test_serialize/my_game/example/ability_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/ability_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use self::flatbuffers::{EndianScalar, Follow};
@@ -15,8 +20,8 @@
Self([0; 8])
}
}
-impl std::fmt::Debug for Ability {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Ability {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Ability")
.field("id", &self.id())
.field("distance", &self.distance())
@@ -45,7 +50,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(self as *const Ability as *const u8, Self::size())
+ ::core::slice::from_raw_parts(self as *const Ability as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
@@ -56,7 +61,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(*self as *const Ability as *const u8, Self::size())
+ ::core::slice::from_raw_parts(*self as *const Ability as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
@@ -129,7 +134,7 @@
}
#[inline]
- pub fn key_compare_with_value(&self, val: u32) -> ::std::cmp::Ordering {
+ pub fn key_compare_with_value(&self, val: u32) -> ::core::cmp::Ordering {
let key = self.id();
key.cmp(&val)
}
diff --git a/tests/monster_test_serialize/my_game/example/any_ambiguous_aliases_generated.rs b/tests/monster_test_serialize/my_game/example/any_ambiguous_aliases_generated.rs
index 2e757a8..b278ca1 100644
--- a/tests/monster_test_serialize/my_game/example/any_ambiguous_aliases_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/any_ambiguous_aliases_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use self::flatbuffers::{EndianScalar, Follow};
@@ -48,8 +53,8 @@
}
}
}
-impl std::fmt::Debug for AnyAmbiguousAliases {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for AnyAmbiguousAliases {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
if let Some(name) = self.variant_name() {
f.write_str(name)
} else {
@@ -146,7 +151,7 @@
/// If the union variant matches, return the owned MonsterT, setting the union to NONE.
pub fn take_m1(&mut self) -> Option<Box<MonsterT>> {
if let Self::M1(_) = self {
- let v = std::mem::replace(self, Self::NONE);
+ let v = core::mem::replace(self, Self::NONE);
if let Self::M1(w) = v {
Some(w)
} else {
@@ -167,7 +172,7 @@
/// If the union variant matches, return the owned MonsterT, setting the union to NONE.
pub fn take_m2(&mut self) -> Option<Box<MonsterT>> {
if let Self::M2(_) = self {
- let v = std::mem::replace(self, Self::NONE);
+ let v = core::mem::replace(self, Self::NONE);
if let Self::M2(w) = v {
Some(w)
} else {
@@ -188,7 +193,7 @@
/// If the union variant matches, return the owned MonsterT, setting the union to NONE.
pub fn take_m3(&mut self) -> Option<Box<MonsterT>> {
if let Self::M3(_) = self {
- let v = std::mem::replace(self, Self::NONE);
+ let v = core::mem::replace(self, Self::NONE);
if let Self::M3(w) = v {
Some(w)
} else {
diff --git a/tests/monster_test_serialize/my_game/example/any_generated.rs b/tests/monster_test_serialize/my_game/example/any_generated.rs
index d572642..f67392d 100644
--- a/tests/monster_test_serialize/my_game/example/any_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/any_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use self::flatbuffers::{EndianScalar, Follow};
@@ -48,8 +53,8 @@
}
}
}
-impl std::fmt::Debug for Any {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Any {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
if let Some(name) = self.variant_name() {
f.write_str(name)
} else {
@@ -146,7 +151,7 @@
/// If the union variant matches, return the owned MonsterT, setting the union to NONE.
pub fn take_monster(&mut self) -> Option<Box<MonsterT>> {
if let Self::Monster(_) = self {
- let v = std::mem::replace(self, Self::NONE);
+ let v = core::mem::replace(self, Self::NONE);
if let Self::Monster(w) = v {
Some(w)
} else {
@@ -167,7 +172,7 @@
/// If the union variant matches, return the owned TestSimpleTableWithEnumT, setting the union to NONE.
pub fn take_test_simple_table_with_enum(&mut self) -> Option<Box<TestSimpleTableWithEnumT>> {
if let Self::TestSimpleTableWithEnum(_) = self {
- let v = std::mem::replace(self, Self::NONE);
+ let v = core::mem::replace(self, Self::NONE);
if let Self::TestSimpleTableWithEnum(w) = v {
Some(w)
} else {
@@ -188,7 +193,7 @@
/// If the union variant matches, return the owned super::example_2::MonsterT, setting the union to NONE.
pub fn take_my_game_example_2_monster(&mut self) -> Option<Box<super::example_2::MonsterT>> {
if let Self::MyGameExample2Monster(_) = self {
- let v = std::mem::replace(self, Self::NONE);
+ let v = core::mem::replace(self, Self::NONE);
if let Self::MyGameExample2Monster(w) = v {
Some(w)
} else {
diff --git a/tests/monster_test_serialize/my_game/example/any_unique_aliases_generated.rs b/tests/monster_test_serialize/my_game/example/any_unique_aliases_generated.rs
index 8a3fa66..1b3d091 100644
--- a/tests/monster_test_serialize/my_game/example/any_unique_aliases_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/any_unique_aliases_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use self::flatbuffers::{EndianScalar, Follow};
@@ -48,8 +53,8 @@
}
}
}
-impl std::fmt::Debug for AnyUniqueAliases {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for AnyUniqueAliases {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
if let Some(name) = self.variant_name() {
f.write_str(name)
} else {
@@ -146,7 +151,7 @@
/// If the union variant matches, return the owned MonsterT, setting the union to NONE.
pub fn take_m(&mut self) -> Option<Box<MonsterT>> {
if let Self::M(_) = self {
- let v = std::mem::replace(self, Self::NONE);
+ let v = core::mem::replace(self, Self::NONE);
if let Self::M(w) = v {
Some(w)
} else {
@@ -167,7 +172,7 @@
/// If the union variant matches, return the owned TestSimpleTableWithEnumT, setting the union to NONE.
pub fn take_ts(&mut self) -> Option<Box<TestSimpleTableWithEnumT>> {
if let Self::TS(_) = self {
- let v = std::mem::replace(self, Self::NONE);
+ let v = core::mem::replace(self, Self::NONE);
if let Self::TS(w) = v {
Some(w)
} else {
@@ -188,7 +193,7 @@
/// If the union variant matches, return the owned super::example_2::MonsterT, setting the union to NONE.
pub fn take_m2(&mut self) -> Option<Box<super::example_2::MonsterT>> {
if let Self::M2(_) = self {
- let v = std::mem::replace(self, Self::NONE);
+ let v = core::mem::replace(self, Self::NONE);
if let Self::M2(w) = v {
Some(w)
} else {
diff --git a/tests/monster_test_serialize/my_game/example/color_generated.rs b/tests/monster_test_serialize/my_game/example/color_generated.rs
index e27f79c..e001d43 100644
--- a/tests/monster_test_serialize/my_game/example/color_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/color_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use self::flatbuffers::{EndianScalar, Follow};
diff --git a/tests/monster_test_serialize/my_game/example/long_enum_generated.rs b/tests/monster_test_serialize/my_game/example/long_enum_generated.rs
index f513d29..b29b97f 100644
--- a/tests/monster_test_serialize/my_game/example/long_enum_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/long_enum_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use self::flatbuffers::{EndianScalar, Follow};
diff --git a/tests/monster_test_serialize/my_game/example/monster_generated.rs b/tests/monster_test_serialize/my_game/example/monster_generated.rs
index cd5730f..7aa3ec7 100644
--- a/tests/monster_test_serialize/my_game/example/monster_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/monster_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use self::flatbuffers::{EndianScalar, Follow};
@@ -381,7 +386,7 @@
}
#[inline]
- pub fn key_compare_with_value(&self, val: & str) -> ::std::cmp::Ordering {
+ pub fn key_compare_with_value(&self, val: & str) -> ::core::cmp::Ordering {
let key = self.name();
key.cmp(val)
}
@@ -1335,8 +1340,8 @@
}
}
-impl std::fmt::Debug for Monster<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for Monster<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("Monster");
ds.field("pos", &self.pos());
ds.field("mana", &self.mana());
diff --git a/tests/monster_test_serialize/my_game/example/race_generated.rs b/tests/monster_test_serialize/my_game/example/race_generated.rs
index 63754ff..a1a6749 100644
--- a/tests/monster_test_serialize/my_game/example/race_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/race_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use self::flatbuffers::{EndianScalar, Follow};
@@ -48,8 +53,8 @@
}
}
}
-impl std::fmt::Debug for Race {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Race {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
if let Some(name) = self.variant_name() {
f.write_str(name)
} else {
diff --git a/tests/monster_test_serialize/my_game/example/referrable_generated.rs b/tests/monster_test_serialize/my_game/example/referrable_generated.rs
index 490980d..9992293 100644
--- a/tests/monster_test_serialize/my_game/example/referrable_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/referrable_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use self::flatbuffers::{EndianScalar, Follow};
@@ -59,7 +64,7 @@
}
#[inline]
- pub fn key_compare_with_value(&self, val: u64) -> ::std::cmp::Ordering {
+ pub fn key_compare_with_value(&self, val: u64) -> ::core::cmp::Ordering {
let key = self.id();
key.cmp(&val)
}
@@ -124,8 +129,8 @@
}
}
-impl std::fmt::Debug for Referrable<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for Referrable<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("Referrable");
ds.field("id", &self.id());
ds.finish()
diff --git a/tests/monster_test_serialize/my_game/example/stat_generated.rs b/tests/monster_test_serialize/my_game/example/stat_generated.rs
index abfa05d..fbd7ce8 100644
--- a/tests/monster_test_serialize/my_game/example/stat_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/stat_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use self::flatbuffers::{EndianScalar, Follow};
@@ -77,7 +82,7 @@
}
#[inline]
- pub fn key_compare_with_value(&self, val: u16) -> ::std::cmp::Ordering {
+ pub fn key_compare_with_value(&self, val: u16) -> ::core::cmp::Ordering {
let key = self.count();
key.cmp(&val)
}
@@ -162,8 +167,8 @@
}
}
-impl std::fmt::Debug for Stat<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for Stat<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("Stat");
ds.field("id", &self.id());
ds.field("val", &self.val());
diff --git a/tests/monster_test_serialize/my_game/example/struct_of_structs_generated.rs b/tests/monster_test_serialize/my_game/example/struct_of_structs_generated.rs
index 75b8865..0046447 100644
--- a/tests/monster_test_serialize/my_game/example/struct_of_structs_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/struct_of_structs_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use self::flatbuffers::{EndianScalar, Follow};
@@ -15,8 +20,8 @@
Self([0; 20])
}
}
-impl std::fmt::Debug for StructOfStructs {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for StructOfStructs {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("StructOfStructs")
.field("a", &self.a())
.field("b", &self.b())
@@ -46,7 +51,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(self as *const StructOfStructs as *const u8, Self::size())
+ ::core::slice::from_raw_parts(self as *const StructOfStructs as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
@@ -57,7 +62,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(*self as *const StructOfStructs as *const u8, Self::size())
+ ::core::slice::from_raw_parts(*self as *const StructOfStructs as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
diff --git a/tests/monster_test_serialize/my_game/example/struct_of_structs_of_structs_generated.rs b/tests/monster_test_serialize/my_game/example/struct_of_structs_of_structs_generated.rs
new file mode 100644
index 0000000..234eb91
--- /dev/null
+++ b/tests/monster_test_serialize/my_game/example/struct_of_structs_of_structs_generated.rs
@@ -0,0 +1,131 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
+extern crate flatbuffers;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
+extern crate serde;
+use self::serde::ser::{Serialize, Serializer, SerializeStruct};
+use self::flatbuffers::{EndianScalar, Follow};
+use super::*;
+// struct StructOfStructsOfStructs, aligned to 4
+#[repr(transparent)]
+#[derive(Clone, Copy, PartialEq)]
+pub struct StructOfStructsOfStructs(pub [u8; 20]);
+impl Default for StructOfStructsOfStructs {
+ fn default() -> Self {
+ Self([0; 20])
+ }
+}
+impl core::fmt::Debug for StructOfStructsOfStructs {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
+ f.debug_struct("StructOfStructsOfStructs")
+ .field("a", &self.a())
+ .finish()
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for StructOfStructsOfStructs {}
+impl flatbuffers::SafeSliceAccess for StructOfStructsOfStructs {}
+impl<'a> flatbuffers::Follow<'a> for StructOfStructsOfStructs {
+ type Inner = &'a StructOfStructsOfStructs;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ <&'a StructOfStructsOfStructs>::follow(buf, loc)
+ }
+}
+impl<'a> flatbuffers::Follow<'a> for &'a StructOfStructsOfStructs {
+ type Inner = &'a StructOfStructsOfStructs;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ flatbuffers::follow_cast_ref::<StructOfStructsOfStructs>(buf, loc)
+ }
+}
+impl<'b> flatbuffers::Push for StructOfStructsOfStructs {
+ type Output = StructOfStructsOfStructs;
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ let src = unsafe {
+ ::core::slice::from_raw_parts(self as *const StructOfStructsOfStructs as *const u8, Self::size())
+ };
+ dst.copy_from_slice(src);
+ }
+}
+impl<'b> flatbuffers::Push for &'b StructOfStructsOfStructs {
+ type Output = StructOfStructsOfStructs;
+
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ let src = unsafe {
+ ::core::slice::from_raw_parts(*self as *const StructOfStructsOfStructs as *const u8, Self::size())
+ };
+ dst.copy_from_slice(src);
+ }
+}
+
+impl<'a> flatbuffers::Verifiable for StructOfStructsOfStructs {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ v.in_buffer::<Self>(pos)
+ }
+}
+
+impl Serialize for StructOfStructsOfStructs {
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
+ let mut s = serializer.serialize_struct("StructOfStructsOfStructs", 1)?;
+ s.serialize_field("a", &self.a())?;
+ s.end()
+ }
+}
+
+impl<'a> StructOfStructsOfStructs {
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ a: &StructOfStructs,
+ ) -> Self {
+ let mut s = Self([0; 20]);
+ s.set_a(a);
+ s
+ }
+
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.StructOfStructsOfStructs"
+ }
+
+ pub fn a(&self) -> &StructOfStructs {
+ unsafe { &*(self.0[0..].as_ptr() as *const StructOfStructs) }
+ }
+
+ #[allow(clippy::identity_op)]
+ pub fn set_a(&mut self, x: &StructOfStructs) {
+ self.0[0..0 + 20].copy_from_slice(&x.0)
+ }
+
+ pub fn unpack(&self) -> StructOfStructsOfStructsT {
+ StructOfStructsOfStructsT {
+ a: self.a().unpack(),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, Default)]
+pub struct StructOfStructsOfStructsT {
+ pub a: StructOfStructsT,
+}
+impl StructOfStructsOfStructsT {
+ pub fn pack(&self) -> StructOfStructsOfStructs {
+ StructOfStructsOfStructs::new(
+ &self.a.pack(),
+ )
+ }
+}
+
diff --git a/tests/monster_test_serialize/my_game/example/test_generated.rs b/tests/monster_test_serialize/my_game/example/test_generated.rs
index 56493ba..472bff9 100644
--- a/tests/monster_test_serialize/my_game/example/test_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/test_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use self::flatbuffers::{EndianScalar, Follow};
@@ -15,8 +20,8 @@
Self([0; 4])
}
}
-impl std::fmt::Debug for Test {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Test {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Test")
.field("a", &self.a())
.field("b", &self.b())
@@ -45,7 +50,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(self as *const Test as *const u8, Self::size())
+ ::core::slice::from_raw_parts(self as *const Test as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
@@ -56,7 +61,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(*self as *const Test as *const u8, Self::size())
+ ::core::slice::from_raw_parts(*self as *const Test as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
diff --git a/tests/monster_test_serialize/my_game/example/test_simple_table_with_enum_generated.rs b/tests/monster_test_serialize/my_game/example/test_simple_table_with_enum_generated.rs
index cd64311..8a7b627 100644
--- a/tests/monster_test_serialize/my_game/example/test_simple_table_with_enum_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/test_simple_table_with_enum_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use self::flatbuffers::{EndianScalar, Follow};
@@ -114,8 +119,8 @@
}
}
-impl std::fmt::Debug for TestSimpleTableWithEnum<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TestSimpleTableWithEnum<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("TestSimpleTableWithEnum");
ds.field("color", &self.color());
ds.finish()
diff --git a/tests/monster_test_serialize/my_game/example/type_aliases_generated.rs b/tests/monster_test_serialize/my_game/example/type_aliases_generated.rs
index 44d1198..f6f7bb7 100644
--- a/tests/monster_test_serialize/my_game/example/type_aliases_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/type_aliases_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use self::flatbuffers::{EndianScalar, Follow};
@@ -302,8 +307,8 @@
}
}
-impl std::fmt::Debug for TypeAliases<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TypeAliases<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("TypeAliases");
ds.field("i8_", &self.i8_());
ds.field("u8_", &self.u8_());
diff --git a/tests/monster_test_serialize/my_game/example/vec_3_generated.rs b/tests/monster_test_serialize/my_game/example/vec_3_generated.rs
index f04d0e8..ebbe94c 100644
--- a/tests/monster_test_serialize/my_game/example/vec_3_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/vec_3_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use self::flatbuffers::{EndianScalar, Follow};
@@ -15,8 +20,8 @@
Self([0; 32])
}
}
-impl std::fmt::Debug for Vec3 {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Vec3 {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Vec3")
.field("x", &self.x())
.field("y", &self.y())
@@ -49,7 +54,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(self as *const Vec3 as *const u8, Self::size())
+ ::core::slice::from_raw_parts(self as *const Vec3 as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
@@ -60,7 +65,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(*self as *const Vec3 as *const u8, Self::size())
+ ::core::slice::from_raw_parts(*self as *const Vec3 as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
diff --git a/tests/monster_test_serialize/my_game/example_2/monster_generated.rs b/tests/monster_test_serialize/my_game/example_2/monster_generated.rs
index 7687c5e..9422b57 100644
--- a/tests/monster_test_serialize/my_game/example_2/monster_generated.rs
+++ b/tests/monster_test_serialize/my_game/example_2/monster_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use self::flatbuffers::{EndianScalar, Follow};
@@ -97,8 +102,8 @@
}
}
-impl std::fmt::Debug for Monster<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for Monster<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("Monster");
ds.finish()
}
diff --git a/tests/monster_test_serialize/my_game/in_parent_namespace_generated.rs b/tests/monster_test_serialize/my_game/in_parent_namespace_generated.rs
index b2b0a09..71ceaa0 100644
--- a/tests/monster_test_serialize/my_game/in_parent_namespace_generated.rs
+++ b/tests/monster_test_serialize/my_game/in_parent_namespace_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use self::flatbuffers::{EndianScalar, Follow};
@@ -97,8 +102,8 @@
}
}
-impl std::fmt::Debug for InParentNamespace<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for InParentNamespace<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("InParentNamespace");
ds.finish()
}
diff --git a/tests/monster_test_serialize/my_game/other_name_space/from_include_generated.rs b/tests/monster_test_serialize/my_game/other_name_space/from_include_generated.rs
index 06a0fa8..de5e5e2 100644
--- a/tests/monster_test_serialize/my_game/other_name_space/from_include_generated.rs
+++ b/tests/monster_test_serialize/my_game/other_name_space/from_include_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use self::flatbuffers::{EndianScalar, Follow};
@@ -36,8 +41,8 @@
}
}
}
-impl std::fmt::Debug for FromInclude {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for FromInclude {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
if let Some(name) = self.variant_name() {
f.write_str(name)
} else {
diff --git a/tests/monster_test_serialize/my_game/other_name_space/table_b_generated.rs b/tests/monster_test_serialize/my_game/other_name_space/table_b_generated.rs
index f09e175..e593299 100644
--- a/tests/monster_test_serialize/my_game/other_name_space/table_b_generated.rs
+++ b/tests/monster_test_serialize/my_game/other_name_space/table_b_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use self::flatbuffers::{EndianScalar, Follow};
@@ -120,8 +125,8 @@
}
}
-impl std::fmt::Debug for TableB<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TableB<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("TableB");
ds.field("a", &self.a());
ds.finish()
diff --git a/tests/monster_test_serialize/my_game/other_name_space/unused_generated.rs b/tests/monster_test_serialize/my_game/other_name_space/unused_generated.rs
index 7b91447..2991781 100644
--- a/tests/monster_test_serialize/my_game/other_name_space/unused_generated.rs
+++ b/tests/monster_test_serialize/my_game/other_name_space/unused_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use self::flatbuffers::{EndianScalar, Follow};
@@ -15,8 +20,8 @@
Self([0; 4])
}
}
-impl std::fmt::Debug for Unused {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for Unused {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Unused")
.field("a", &self.a())
.finish()
@@ -44,7 +49,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(self as *const Unused as *const u8, Self::size())
+ ::core::slice::from_raw_parts(self as *const Unused as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
@@ -55,7 +60,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(*self as *const Unused as *const u8, Self::size())
+ ::core::slice::from_raw_parts(*self as *const Unused as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
diff --git a/tests/monster_test_serialize/table_a_generated.rs b/tests/monster_test_serialize/table_a_generated.rs
index eb03f49..c4bbd69 100644
--- a/tests/monster_test_serialize/table_a_generated.rs
+++ b/tests/monster_test_serialize/table_a_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use self::flatbuffers::{EndianScalar, Follow};
@@ -120,8 +125,8 @@
}
}
-impl std::fmt::Debug for TableA<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TableA<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("TableA");
ds.field("b", &self.b());
ds.finish()
diff --git a/tests/monster_test_suffix/ext_only/monster_test.grpc.fb.cc b/tests/monster_test_suffix/ext_only/monster_test.grpc.fb.cc
new file mode 100644
index 0000000..3cc72ed
--- /dev/null
+++ b/tests/monster_test_suffix/ext_only/monster_test.grpc.fb.cc
@@ -0,0 +1,131 @@
+// Generated by the gRPC C++ plugin.
+// If you make any local change, they will be lost.
+// source: monster_test
+
+#include "monster_test_generated.hpp"
+#include "monster_test.grpc.fb.h"
+
+#include <grpcpp/impl/codegen/async_stream.h>
+#include <grpcpp/impl/codegen/async_unary_call.h>
+#include <grpcpp/impl/codegen/channel_interface.h>
+#include <grpcpp/impl/codegen/client_unary_call.h>
+#include <grpcpp/impl/codegen/method_handler.h>
+#include <grpcpp/impl/codegen/rpc_service_method.h>
+#include <grpcpp/impl/codegen/service_type.h>
+#include <grpcpp/impl/codegen/sync_stream.h>
+namespace MyGame {
+namespace Example {
+
+static const char* MonsterStorage_method_names[] = {
+ "/MyGame.Example.MonsterStorage/Store",
+ "/MyGame.Example.MonsterStorage/Retrieve",
+ "/MyGame.Example.MonsterStorage/GetMaxHitPoint",
+ "/MyGame.Example.MonsterStorage/GetMinMaxHitPoints",
+};
+
+std::unique_ptr< MonsterStorage::Stub> MonsterStorage::NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& /*options*/) {
+ std::unique_ptr< MonsterStorage::Stub> stub(new MonsterStorage::Stub(channel));
+ return stub;
+}
+
+MonsterStorage::Stub::Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel)
+ : channel_(channel) , rpcmethod_Store_(MonsterStorage_method_names[0], ::grpc::internal::RpcMethod::NORMAL_RPC, channel)
+ , rpcmethod_Retrieve_(MonsterStorage_method_names[1], ::grpc::internal::RpcMethod::SERVER_STREAMING, channel)
+ , rpcmethod_GetMaxHitPoint_(MonsterStorage_method_names[2], ::grpc::internal::RpcMethod::CLIENT_STREAMING, channel)
+ , rpcmethod_GetMinMaxHitPoints_(MonsterStorage_method_names[3], ::grpc::internal::RpcMethod::BIDI_STREAMING, channel)
+ {}
+
+::grpc::Status MonsterStorage::Stub::Store(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, flatbuffers::grpc::Message<Stat>* response) {
+ return ::grpc::internal::BlockingUnaryCall(channel_.get(), rpcmethod_Store_, context, request, response);
+}
+
+::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>* MonsterStorage::Stub::AsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) {
+ return ::grpc::internal::ClientAsyncResponseReaderFactory< flatbuffers::grpc::Message<Stat>>::Create(channel_.get(), cq, rpcmethod_Store_, context, request, true);
+}
+
+::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>* MonsterStorage::Stub::PrepareAsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) {
+ return ::grpc::internal::ClientAsyncResponseReaderFactory< flatbuffers::grpc::Message<Stat>>::Create(channel_.get(), cq, rpcmethod_Store_, context, request, false);
+}
+
+::grpc::ClientReader< flatbuffers::grpc::Message<Monster>>* MonsterStorage::Stub::RetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request) {
+ return ::grpc::internal::ClientReaderFactory< flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), rpcmethod_Retrieve_, context, request);
+}
+
+::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>* MonsterStorage::Stub::AsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq, void* tag) {
+ return ::grpc::internal::ClientAsyncReaderFactory< flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), cq, rpcmethod_Retrieve_, context, request, true, tag);
+}
+
+::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>* MonsterStorage::Stub::PrepareAsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq) {
+ return ::grpc::internal::ClientAsyncReaderFactory< flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), cq, rpcmethod_Retrieve_, context, request, false, nullptr);
+}
+
+::grpc::ClientWriter< flatbuffers::grpc::Message<Monster>>* MonsterStorage::Stub::GetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response) {
+ return ::grpc::internal::ClientWriterFactory< flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), rpcmethod_GetMaxHitPoint_, context, response);
+}
+
+::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>* MonsterStorage::Stub::AsyncGetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq, void* tag) {
+ return ::grpc::internal::ClientAsyncWriterFactory< flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), cq, rpcmethod_GetMaxHitPoint_, context, response, true, tag);
+}
+
+::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>* MonsterStorage::Stub::PrepareAsyncGetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq) {
+ return ::grpc::internal::ClientAsyncWriterFactory< flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), cq, rpcmethod_GetMaxHitPoint_, context, response, false, nullptr);
+}
+
+::grpc::ClientReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* MonsterStorage::Stub::GetMinMaxHitPointsRaw(::grpc::ClientContext* context) {
+ return ::grpc::internal::ClientReaderWriterFactory< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>::Create(channel_.get(), rpcmethod_GetMinMaxHitPoints_, context);
+}
+
+::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* MonsterStorage::Stub::AsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) {
+ return ::grpc::internal::ClientAsyncReaderWriterFactory< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>::Create(channel_.get(), cq, rpcmethod_GetMinMaxHitPoints_, context, true, tag);
+}
+
+::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* MonsterStorage::Stub::PrepareAsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) {
+ return ::grpc::internal::ClientAsyncReaderWriterFactory< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>::Create(channel_.get(), cq, rpcmethod_GetMinMaxHitPoints_, context, false, nullptr);
+}
+
+MonsterStorage::Service::Service() {
+ AddMethod(new ::grpc::internal::RpcServiceMethod(
+ MonsterStorage_method_names[0],
+ ::grpc::internal::RpcMethod::NORMAL_RPC,
+ new ::grpc::internal::RpcMethodHandler< MonsterStorage::Service, flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>(
+ std::mem_fn(&MonsterStorage::Service::Store), this)));
+ AddMethod(new ::grpc::internal::RpcServiceMethod(
+ MonsterStorage_method_names[1],
+ ::grpc::internal::RpcMethod::SERVER_STREAMING,
+ new ::grpc::internal::ServerStreamingHandler< MonsterStorage::Service, flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>(
+ std::mem_fn(&MonsterStorage::Service::Retrieve), this)));
+ AddMethod(new ::grpc::internal::RpcServiceMethod(
+ MonsterStorage_method_names[2],
+ ::grpc::internal::RpcMethod::CLIENT_STREAMING,
+ new ::grpc::internal::ClientStreamingHandler< MonsterStorage::Service, flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>(
+ std::mem_fn(&MonsterStorage::Service::GetMaxHitPoint), this)));
+ AddMethod(new ::grpc::internal::RpcServiceMethod(
+ MonsterStorage_method_names[3],
+ ::grpc::internal::RpcMethod::BIDI_STREAMING,
+ new ::grpc::internal::BidiStreamingHandler< MonsterStorage::Service, flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>(
+ std::mem_fn(&MonsterStorage::Service::GetMinMaxHitPoints), this)));
+}
+
+MonsterStorage::Service::~Service() {
+}
+
+::grpc::Status MonsterStorage::Service::Store(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Monster>* /*request*/, flatbuffers::grpc::Message<Stat>* /*response*/) {
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+}
+
+::grpc::Status MonsterStorage::Service::Retrieve(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Stat>* /*request*/, ::grpc::ServerWriter< flatbuffers::grpc::Message<Monster>>* /*writer*/) {
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+}
+
+::grpc::Status MonsterStorage::Service::GetMaxHitPoint(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< flatbuffers::grpc::Message<Monster>>* /*reader*/, flatbuffers::grpc::Message<Stat>* /*response*/) {
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+}
+
+::grpc::Status MonsterStorage::Service::GetMinMaxHitPoints(::grpc::ServerContext* /*context*/, ::grpc::ServerReaderWriter< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>* /*stream*/) {
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+}
+
+
+} // namespace MyGame
+} // namespace Example
+
diff --git a/tests/monster_test_suffix/ext_only/monster_test.grpc.fb.h b/tests/monster_test_suffix/ext_only/monster_test.grpc.fb.h
new file mode 100644
index 0000000..530504e
--- /dev/null
+++ b/tests/monster_test_suffix/ext_only/monster_test.grpc.fb.h
@@ -0,0 +1,350 @@
+// Generated by the gRPC C++ plugin.
+// If you make any local change, they will be lost.
+// source: monster_test
+#ifndef GRPC_monster_5ftest__INCLUDED
+#define GRPC_monster_5ftest__INCLUDED
+
+#include "monster_test_generated.hpp"
+#include "flatbuffers/grpc.h"
+
+#include <grpcpp/impl/codegen/async_stream.h>
+#include <grpcpp/impl/codegen/async_unary_call.h>
+#include <grpcpp/impl/codegen/method_handler.h>
+#include <grpcpp/impl/codegen/proto_utils.h>
+#include <grpcpp/impl/codegen/rpc_method.h>
+#include <grpcpp/impl/codegen/service_type.h>
+#include <grpcpp/impl/codegen/status.h>
+#include <grpcpp/impl/codegen/stub_options.h>
+#include <grpcpp/impl/codegen/sync_stream.h>
+
+namespace grpc {
+class CompletionQueue;
+class Channel;
+class ServerCompletionQueue;
+class ServerContext;
+} // namespace grpc
+
+namespace MyGame {
+namespace Example {
+
+class MonsterStorage final {
+ public:
+ static constexpr char const* service_full_name() {
+ return "MyGame.Example.MonsterStorage";
+ }
+ class StubInterface {
+ public:
+ virtual ~StubInterface() {}
+ virtual ::grpc::Status Store(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, flatbuffers::grpc::Message<Stat>* response) = 0;
+ std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::grpc::Message<Stat>>> AsyncStore(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::grpc::Message<Stat>>>(AsyncStoreRaw(context, request, cq));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::grpc::Message<Stat>>> PrepareAsyncStore(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::grpc::Message<Stat>>>(PrepareAsyncStoreRaw(context, request, cq));
+ }
+ std::unique_ptr< ::grpc::ClientReaderInterface< flatbuffers::grpc::Message<Monster>>> Retrieve(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request) {
+ return std::unique_ptr< ::grpc::ClientReaderInterface< flatbuffers::grpc::Message<Monster>>>(RetrieveRaw(context, request));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncReaderInterface< flatbuffers::grpc::Message<Monster>>> AsyncRetrieve(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq, void* tag) {
+ return std::unique_ptr< ::grpc::ClientAsyncReaderInterface< flatbuffers::grpc::Message<Monster>>>(AsyncRetrieveRaw(context, request, cq, tag));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncReaderInterface< flatbuffers::grpc::Message<Monster>>> PrepareAsyncRetrieve(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncReaderInterface< flatbuffers::grpc::Message<Monster>>>(PrepareAsyncRetrieveRaw(context, request, cq));
+ }
+ std::unique_ptr< ::grpc::ClientWriterInterface< flatbuffers::grpc::Message<Monster>>> GetMaxHitPoint(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response) {
+ return std::unique_ptr< ::grpc::ClientWriterInterface< flatbuffers::grpc::Message<Monster>>>(GetMaxHitPointRaw(context, response));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncWriterInterface< flatbuffers::grpc::Message<Monster>>> AsyncGetMaxHitPoint(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq, void* tag) {
+ return std::unique_ptr< ::grpc::ClientAsyncWriterInterface< flatbuffers::grpc::Message<Monster>>>(AsyncGetMaxHitPointRaw(context, response, cq, tag));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncWriterInterface< flatbuffers::grpc::Message<Monster>>> PrepareAsyncGetMaxHitPoint(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncWriterInterface< flatbuffers::grpc::Message<Monster>>>(PrepareAsyncGetMaxHitPointRaw(context, response, cq));
+ }
+ std::unique_ptr< ::grpc::ClientReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>> GetMinMaxHitPoints(::grpc::ClientContext* context) {
+ return std::unique_ptr< ::grpc::ClientReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>(GetMinMaxHitPointsRaw(context));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>> AsyncGetMinMaxHitPoints(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) {
+ return std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>(AsyncGetMinMaxHitPointsRaw(context, cq, tag));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>> PrepareAsyncGetMinMaxHitPoints(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>(PrepareAsyncGetMinMaxHitPointsRaw(context, cq));
+ }
+ private:
+ virtual ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::grpc::Message<Stat>>* AsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) = 0;
+ virtual ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::grpc::Message<Stat>>* PrepareAsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) = 0;
+ virtual ::grpc::ClientReaderInterface< flatbuffers::grpc::Message<Monster>>* RetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request) = 0;
+ virtual ::grpc::ClientAsyncReaderInterface< flatbuffers::grpc::Message<Monster>>* AsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq, void* tag) = 0;
+ virtual ::grpc::ClientAsyncReaderInterface< flatbuffers::grpc::Message<Monster>>* PrepareAsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq) = 0;
+ virtual ::grpc::ClientWriterInterface< flatbuffers::grpc::Message<Monster>>* GetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response) = 0;
+ virtual ::grpc::ClientAsyncWriterInterface< flatbuffers::grpc::Message<Monster>>* AsyncGetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq, void* tag) = 0;
+ virtual ::grpc::ClientAsyncWriterInterface< flatbuffers::grpc::Message<Monster>>* PrepareAsyncGetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq) = 0;
+ virtual ::grpc::ClientReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* GetMinMaxHitPointsRaw(::grpc::ClientContext* context) = 0;
+ virtual ::grpc::ClientAsyncReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* AsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) = 0;
+ virtual ::grpc::ClientAsyncReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* PrepareAsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) = 0;
+ };
+ class Stub final : public StubInterface {
+ public:
+ Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel);
+ ::grpc::Status Store(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, flatbuffers::grpc::Message<Stat>* response) override;
+ std::unique_ptr< ::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>> AsyncStore(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>>(AsyncStoreRaw(context, request, cq));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>> PrepareAsyncStore(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>>(PrepareAsyncStoreRaw(context, request, cq));
+ }
+ std::unique_ptr< ::grpc::ClientReader< flatbuffers::grpc::Message<Monster>>> Retrieve(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request) {
+ return std::unique_ptr< ::grpc::ClientReader< flatbuffers::grpc::Message<Monster>>>(RetrieveRaw(context, request));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>> AsyncRetrieve(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq, void* tag) {
+ return std::unique_ptr< ::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>>(AsyncRetrieveRaw(context, request, cq, tag));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>> PrepareAsyncRetrieve(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>>(PrepareAsyncRetrieveRaw(context, request, cq));
+ }
+ std::unique_ptr< ::grpc::ClientWriter< flatbuffers::grpc::Message<Monster>>> GetMaxHitPoint(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response) {
+ return std::unique_ptr< ::grpc::ClientWriter< flatbuffers::grpc::Message<Monster>>>(GetMaxHitPointRaw(context, response));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>> AsyncGetMaxHitPoint(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq, void* tag) {
+ return std::unique_ptr< ::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>>(AsyncGetMaxHitPointRaw(context, response, cq, tag));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>> PrepareAsyncGetMaxHitPoint(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>>(PrepareAsyncGetMaxHitPointRaw(context, response, cq));
+ }
+ std::unique_ptr< ::grpc::ClientReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>> GetMinMaxHitPoints(::grpc::ClientContext* context) {
+ return std::unique_ptr< ::grpc::ClientReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>(GetMinMaxHitPointsRaw(context));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>> AsyncGetMinMaxHitPoints(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) {
+ return std::unique_ptr< ::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>(AsyncGetMinMaxHitPointsRaw(context, cq, tag));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>> PrepareAsyncGetMinMaxHitPoints(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>(PrepareAsyncGetMinMaxHitPointsRaw(context, cq));
+ }
+
+ private:
+ std::shared_ptr< ::grpc::ChannelInterface> channel_;
+ ::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>* AsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) override;
+ ::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>* PrepareAsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) override;
+ ::grpc::ClientReader< flatbuffers::grpc::Message<Monster>>* RetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request) override;
+ ::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>* AsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq, void* tag) override;
+ ::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>* PrepareAsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq) override;
+ ::grpc::ClientWriter< flatbuffers::grpc::Message<Monster>>* GetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response) override;
+ ::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>* AsyncGetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq, void* tag) override;
+ ::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>* PrepareAsyncGetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq) override;
+ ::grpc::ClientReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* GetMinMaxHitPointsRaw(::grpc::ClientContext* context) override;
+ ::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* AsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) override;
+ ::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* PrepareAsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) override;
+ const ::grpc::internal::RpcMethod rpcmethod_Store_;
+ const ::grpc::internal::RpcMethod rpcmethod_Retrieve_;
+ const ::grpc::internal::RpcMethod rpcmethod_GetMaxHitPoint_;
+ const ::grpc::internal::RpcMethod rpcmethod_GetMinMaxHitPoints_;
+ };
+ static std::unique_ptr<Stub> NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options = ::grpc::StubOptions());
+
+ class Service : public ::grpc::Service {
+ public:
+ Service();
+ virtual ~Service();
+ virtual ::grpc::Status Store(::grpc::ServerContext* context, const flatbuffers::grpc::Message<Monster>* request, flatbuffers::grpc::Message<Stat>* response);
+ virtual ::grpc::Status Retrieve(::grpc::ServerContext* context, const flatbuffers::grpc::Message<Stat>* request, ::grpc::ServerWriter< flatbuffers::grpc::Message<Monster>>* writer);
+ virtual ::grpc::Status GetMaxHitPoint(::grpc::ServerContext* context, ::grpc::ServerReader< flatbuffers::grpc::Message<Monster>>* reader, flatbuffers::grpc::Message<Stat>* response);
+ virtual ::grpc::Status GetMinMaxHitPoints(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>* stream);
+ };
+ template <class BaseClass>
+ class WithAsyncMethod_Store : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
+ public:
+ WithAsyncMethod_Store() {
+ ::grpc::Service::MarkMethodAsync(0);
+ }
+ ~WithAsyncMethod_Store() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status Store(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Monster>* /*request*/, flatbuffers::grpc::Message<Stat>* /*response*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ void RequestStore(::grpc::ServerContext* context, flatbuffers::grpc::Message<Monster>* request, ::grpc::ServerAsyncResponseWriter< flatbuffers::grpc::Message<Stat>>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
+ ::grpc::Service::RequestAsyncUnary(0, context, request, response, new_call_cq, notification_cq, tag);
+ }
+ };
+ template <class BaseClass>
+ class WithAsyncMethod_Retrieve : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
+ public:
+ WithAsyncMethod_Retrieve() {
+ ::grpc::Service::MarkMethodAsync(1);
+ }
+ ~WithAsyncMethod_Retrieve() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status Retrieve(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Stat>* /*request*/, ::grpc::ServerWriter< flatbuffers::grpc::Message<Monster>>* /*writer*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ void RequestRetrieve(::grpc::ServerContext* context, flatbuffers::grpc::Message<Stat>* request, ::grpc::ServerAsyncWriter< flatbuffers::grpc::Message<Monster>>* writer, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
+ ::grpc::Service::RequestAsyncServerStreaming(1, context, request, writer, new_call_cq, notification_cq, tag);
+ }
+ };
+ template <class BaseClass>
+ class WithAsyncMethod_GetMaxHitPoint : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
+ public:
+ WithAsyncMethod_GetMaxHitPoint() {
+ ::grpc::Service::MarkMethodAsync(2);
+ }
+ ~WithAsyncMethod_GetMaxHitPoint() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status GetMaxHitPoint(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< flatbuffers::grpc::Message<Monster>>* /*reader*/, flatbuffers::grpc::Message<Stat>* /*response*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ void RequestGetMaxHitPoint(::grpc::ServerContext* context, ::grpc::ServerAsyncReader< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>* reader, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
+ ::grpc::Service::RequestAsyncClientStreaming(2, context, reader, new_call_cq, notification_cq, tag);
+ }
+ };
+ template <class BaseClass>
+ class WithAsyncMethod_GetMinMaxHitPoints : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
+ public:
+ WithAsyncMethod_GetMinMaxHitPoints() {
+ ::grpc::Service::MarkMethodAsync(3);
+ }
+ ~WithAsyncMethod_GetMinMaxHitPoints() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status GetMinMaxHitPoints(::grpc::ServerContext* /*context*/, ::grpc::ServerReaderWriter< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>* /*stream*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ void RequestGetMinMaxHitPoints(::grpc::ServerContext* context, ::grpc::ServerAsyncReaderWriter< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>* stream, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
+ ::grpc::Service::RequestAsyncBidiStreaming(3, context, stream, new_call_cq, notification_cq, tag);
+ }
+ };
+ typedef WithAsyncMethod_Store< WithAsyncMethod_Retrieve< WithAsyncMethod_GetMaxHitPoint< WithAsyncMethod_GetMinMaxHitPoints< Service > > > > AsyncService;
+ template <class BaseClass>
+ class WithGenericMethod_Store : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
+ public:
+ WithGenericMethod_Store() {
+ ::grpc::Service::MarkMethodGeneric(0);
+ }
+ ~WithGenericMethod_Store() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status Store(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Monster>* /*request*/, flatbuffers::grpc::Message<Stat>* /*response*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ };
+ template <class BaseClass>
+ class WithGenericMethod_Retrieve : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
+ public:
+ WithGenericMethod_Retrieve() {
+ ::grpc::Service::MarkMethodGeneric(1);
+ }
+ ~WithGenericMethod_Retrieve() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status Retrieve(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Stat>* /*request*/, ::grpc::ServerWriter< flatbuffers::grpc::Message<Monster>>* /*writer*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ };
+ template <class BaseClass>
+ class WithGenericMethod_GetMaxHitPoint : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
+ public:
+ WithGenericMethod_GetMaxHitPoint() {
+ ::grpc::Service::MarkMethodGeneric(2);
+ }
+ ~WithGenericMethod_GetMaxHitPoint() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status GetMaxHitPoint(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< flatbuffers::grpc::Message<Monster>>* /*reader*/, flatbuffers::grpc::Message<Stat>* /*response*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ };
+ template <class BaseClass>
+ class WithGenericMethod_GetMinMaxHitPoints : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
+ public:
+ WithGenericMethod_GetMinMaxHitPoints() {
+ ::grpc::Service::MarkMethodGeneric(3);
+ }
+ ~WithGenericMethod_GetMinMaxHitPoints() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status GetMinMaxHitPoints(::grpc::ServerContext* /*context*/, ::grpc::ServerReaderWriter< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>* /*stream*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ };
+ template <class BaseClass>
+ class WithStreamedUnaryMethod_Store : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
+ public:
+ WithStreamedUnaryMethod_Store() {
+ ::grpc::Service::MarkMethodStreamed(0,
+ new ::grpc::internal::StreamedUnaryHandler< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>(std::bind(&WithStreamedUnaryMethod_Store<BaseClass>::StreamedStore, this, std::placeholders::_1, std::placeholders::_2)));
+ }
+ ~WithStreamedUnaryMethod_Store() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable regular version of this method
+ ::grpc::Status Store(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Monster>* /*request*/, flatbuffers::grpc::Message<Stat>* /*response*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ // replace default version of method with streamed unary
+ virtual ::grpc::Status StreamedStore(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer< flatbuffers::grpc::Message<Monster>,flatbuffers::grpc::Message<Stat>>* server_unary_streamer) = 0;
+ };
+ typedef WithStreamedUnaryMethod_Store< Service > StreamedUnaryService;
+ template <class BaseClass>
+ class WithSplitStreamingMethod_Retrieve : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) { }
+ public:
+ WithSplitStreamingMethod_Retrieve() {
+ ::grpc::Service::MarkMethodStreamed(1,
+ new ::grpc::internal::SplitServerStreamingHandler< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>(std::bind(&WithSplitStreamingMethod_Retrieve<BaseClass>::StreamedRetrieve, this, std::placeholders::_1, std::placeholders::_2)));
+ }
+ ~WithSplitStreamingMethod_Retrieve() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable regular version of this method
+ ::grpc::Status Retrieve(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Stat>* /*request*/, ::grpc::ServerWriter< flatbuffers::grpc::Message<Monster>>* /*writer*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ // replace default version of method with split streamed
+ virtual ::grpc::Status StreamedRetrieve(::grpc::ServerContext* context, ::grpc::ServerSplitStreamer< flatbuffers::grpc::Message<Stat>,flatbuffers::grpc::Message<Monster>>* server_split_streamer) = 0;
+ };
+ typedef WithSplitStreamingMethod_Retrieve< Service > SplitStreamedService;
+ typedef WithStreamedUnaryMethod_Store< WithSplitStreamingMethod_Retrieve< Service > > StreamedService;
+};
+
+} // namespace Example
+} // namespace MyGame
+
+
+#endif // GRPC_monster_5ftest__INCLUDED
diff --git a/tests/monster_test_suffix/ext_only/monster_test_generated.hpp b/tests/monster_test_suffix/ext_only/monster_test_generated.hpp
new file mode 100644
index 0000000..deab77b
--- /dev/null
+++ b/tests/monster_test_suffix/ext_only/monster_test_generated.hpp
@@ -0,0 +1,4034 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+
+#ifndef FLATBUFFERS_GENERATED_MONSTERTEST_MYGAME_EXAMPLE_H_
+#define FLATBUFFERS_GENERATED_MONSTERTEST_MYGAME_EXAMPLE_H_
+
+#include "flatbuffers/flatbuffers.h"
+#include "flatbuffers/flexbuffers.h"
+#include "flatbuffers/flex_flat_util.h"
+
+// Ensure the included flatbuffers.h is the same version as when this file was
+// generated, otherwise it may not be compatible.
+static_assert(FLATBUFFERS_VERSION_MAJOR == 2 &&
+ FLATBUFFERS_VERSION_MINOR == 0 &&
+ FLATBUFFERS_VERSION_REVISION == 8,
+ "Non-compatible flatbuffers version included");
+
+namespace MyGame {
+
+struct InParentNamespace;
+struct InParentNamespaceBuilder;
+struct InParentNamespaceT;
+
+namespace Example2 {
+
+struct Monster;
+struct MonsterBuilder;
+struct MonsterT;
+
+} // namespace Example2
+
+namespace Example {
+
+struct Test;
+
+struct TestSimpleTableWithEnum;
+struct TestSimpleTableWithEnumBuilder;
+struct TestSimpleTableWithEnumT;
+
+struct Vec3;
+
+struct Ability;
+
+struct StructOfStructs;
+
+struct StructOfStructsOfStructs;
+
+struct Stat;
+struct StatBuilder;
+struct StatT;
+
+struct Referrable;
+struct ReferrableBuilder;
+struct ReferrableT;
+
+struct Monster;
+struct MonsterBuilder;
+struct MonsterT;
+
+struct TypeAliases;
+struct TypeAliasesBuilder;
+struct TypeAliasesT;
+
+} // namespace Example
+
+bool operator==(const InParentNamespaceT &lhs, const InParentNamespaceT &rhs);
+bool operator!=(const InParentNamespaceT &lhs, const InParentNamespaceT &rhs);
+namespace Example2 {
+
+bool operator==(const MonsterT &lhs, const MonsterT &rhs);
+bool operator!=(const MonsterT &lhs, const MonsterT &rhs);
+} // namespace Example2
+
+namespace Example {
+
+bool operator==(const Test &lhs, const Test &rhs);
+bool operator!=(const Test &lhs, const Test &rhs);
+bool operator==(const TestSimpleTableWithEnumT &lhs, const TestSimpleTableWithEnumT &rhs);
+bool operator!=(const TestSimpleTableWithEnumT &lhs, const TestSimpleTableWithEnumT &rhs);
+bool operator==(const Vec3 &lhs, const Vec3 &rhs);
+bool operator!=(const Vec3 &lhs, const Vec3 &rhs);
+bool operator==(const Ability &lhs, const Ability &rhs);
+bool operator!=(const Ability &lhs, const Ability &rhs);
+bool operator==(const StructOfStructs &lhs, const StructOfStructs &rhs);
+bool operator!=(const StructOfStructs &lhs, const StructOfStructs &rhs);
+bool operator==(const StructOfStructsOfStructs &lhs, const StructOfStructsOfStructs &rhs);
+bool operator!=(const StructOfStructsOfStructs &lhs, const StructOfStructsOfStructs &rhs);
+bool operator==(const StatT &lhs, const StatT &rhs);
+bool operator!=(const StatT &lhs, const StatT &rhs);
+bool operator==(const ReferrableT &lhs, const ReferrableT &rhs);
+bool operator!=(const ReferrableT &lhs, const ReferrableT &rhs);
+bool operator==(const MonsterT &lhs, const MonsterT &rhs);
+bool operator!=(const MonsterT &lhs, const MonsterT &rhs);
+bool operator==(const TypeAliasesT &lhs, const TypeAliasesT &rhs);
+bool operator!=(const TypeAliasesT &lhs, const TypeAliasesT &rhs);
+
+} // namespace Example
+
+inline const flatbuffers::TypeTable *InParentNamespaceTypeTable();
+
+namespace Example2 {
+
+inline const flatbuffers::TypeTable *MonsterTypeTable();
+
+} // namespace Example2
+
+namespace Example {
+
+inline const flatbuffers::TypeTable *TestTypeTable();
+
+inline const flatbuffers::TypeTable *TestSimpleTableWithEnumTypeTable();
+
+inline const flatbuffers::TypeTable *Vec3TypeTable();
+
+inline const flatbuffers::TypeTable *AbilityTypeTable();
+
+inline const flatbuffers::TypeTable *StructOfStructsTypeTable();
+
+inline const flatbuffers::TypeTable *StructOfStructsOfStructsTypeTable();
+
+inline const flatbuffers::TypeTable *StatTypeTable();
+
+inline const flatbuffers::TypeTable *ReferrableTypeTable();
+
+inline const flatbuffers::TypeTable *MonsterTypeTable();
+
+inline const flatbuffers::TypeTable *TypeAliasesTypeTable();
+
+/// Composite components of Monster color.
+enum Color : uint8_t {
+ Color_Red = 1,
+ /// \brief color Green
+ /// Green is bit_flag with value (1u << 1)
+ Color_Green = 2,
+ /// \brief color Blue (1u << 3)
+ Color_Blue = 8,
+ Color_NONE = 0,
+ Color_ANY = 11
+};
+
+inline const Color (&EnumValuesColor())[3] {
+ static const Color values[] = {
+ Color_Red,
+ Color_Green,
+ Color_Blue
+ };
+ return values;
+}
+
+inline const char * const *EnumNamesColor() {
+ static const char * const names[9] = {
+ "Red",
+ "Green",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "Blue",
+ nullptr
+ };
+ return names;
+}
+
+inline const char *EnumNameColor(Color e) {
+ if (flatbuffers::IsOutRange(e, Color_Red, Color_Blue)) return "";
+ const size_t index = static_cast<size_t>(e) - static_cast<size_t>(Color_Red);
+ return EnumNamesColor()[index];
+}
+
+enum Race : int8_t {
+ Race_None = -1,
+ Race_Human = 0,
+ Race_Dwarf = 1,
+ Race_Elf = 2,
+ Race_MIN = Race_None,
+ Race_MAX = Race_Elf
+};
+
+inline const Race (&EnumValuesRace())[4] {
+ static const Race values[] = {
+ Race_None,
+ Race_Human,
+ Race_Dwarf,
+ Race_Elf
+ };
+ return values;
+}
+
+inline const char * const *EnumNamesRace() {
+ static const char * const names[5] = {
+ "None",
+ "Human",
+ "Dwarf",
+ "Elf",
+ nullptr
+ };
+ return names;
+}
+
+inline const char *EnumNameRace(Race e) {
+ if (flatbuffers::IsOutRange(e, Race_None, Race_Elf)) return "";
+ const size_t index = static_cast<size_t>(e) - static_cast<size_t>(Race_None);
+ return EnumNamesRace()[index];
+}
+
+enum LongEnum : uint64_t {
+ LongEnum_LongOne = 2ULL,
+ LongEnum_LongTwo = 4ULL,
+ LongEnum_LongBig = 1099511627776ULL,
+ LongEnum_NONE = 0,
+ LongEnum_ANY = 1099511627782ULL
+};
+
+inline const LongEnum (&EnumValuesLongEnum())[3] {
+ static const LongEnum values[] = {
+ LongEnum_LongOne,
+ LongEnum_LongTwo,
+ LongEnum_LongBig
+ };
+ return values;
+}
+
+inline const char *EnumNameLongEnum(LongEnum e) {
+ switch (e) {
+ case LongEnum_LongOne: return "LongOne";
+ case LongEnum_LongTwo: return "LongTwo";
+ case LongEnum_LongBig: return "LongBig";
+ default: return "";
+ }
+}
+
+enum Any : uint8_t {
+ Any_NONE = 0,
+ Any_Monster = 1,
+ Any_TestSimpleTableWithEnum = 2,
+ Any_MyGame_Example2_Monster = 3,
+ Any_MIN = Any_NONE,
+ Any_MAX = Any_MyGame_Example2_Monster
+};
+
+inline const Any (&EnumValuesAny())[4] {
+ static const Any values[] = {
+ Any_NONE,
+ Any_Monster,
+ Any_TestSimpleTableWithEnum,
+ Any_MyGame_Example2_Monster
+ };
+ return values;
+}
+
+inline const char * const *EnumNamesAny() {
+ static const char * const names[5] = {
+ "NONE",
+ "Monster",
+ "TestSimpleTableWithEnum",
+ "MyGame_Example2_Monster",
+ nullptr
+ };
+ return names;
+}
+
+inline const char *EnumNameAny(Any e) {
+ if (flatbuffers::IsOutRange(e, Any_NONE, Any_MyGame_Example2_Monster)) return "";
+ const size_t index = static_cast<size_t>(e);
+ return EnumNamesAny()[index];
+}
+
+template<typename T> struct AnyTraits {
+ static const Any enum_value = Any_NONE;
+};
+
+template<> struct AnyTraits<MyGame::Example::Monster> {
+ static const Any enum_value = Any_Monster;
+};
+
+template<> struct AnyTraits<MyGame::Example::TestSimpleTableWithEnum> {
+ static const Any enum_value = Any_TestSimpleTableWithEnum;
+};
+
+template<> struct AnyTraits<MyGame::Example2::Monster> {
+ static const Any enum_value = Any_MyGame_Example2_Monster;
+};
+
+template<typename T> struct AnyUnionTraits {
+ static const Any enum_value = Any_NONE;
+};
+
+template<> struct AnyUnionTraits<MyGame::Example::MonsterT> {
+ static const Any enum_value = Any_Monster;
+};
+
+template<> struct AnyUnionTraits<MyGame::Example::TestSimpleTableWithEnumT> {
+ static const Any enum_value = Any_TestSimpleTableWithEnum;
+};
+
+template<> struct AnyUnionTraits<MyGame::Example2::MonsterT> {
+ static const Any enum_value = Any_MyGame_Example2_Monster;
+};
+
+struct AnyUnion {
+ Any type;
+ void *value;
+
+ AnyUnion() : type(Any_NONE), value(nullptr) {}
+ AnyUnion(AnyUnion&& u) FLATBUFFERS_NOEXCEPT :
+ type(Any_NONE), value(nullptr)
+ { std::swap(type, u.type); std::swap(value, u.value); }
+ AnyUnion(const AnyUnion &);
+ AnyUnion &operator=(const AnyUnion &u)
+ { AnyUnion t(u); std::swap(type, t.type); std::swap(value, t.value); return *this; }
+ AnyUnion &operator=(AnyUnion &&u) FLATBUFFERS_NOEXCEPT
+ { std::swap(type, u.type); std::swap(value, u.value); return *this; }
+ ~AnyUnion() { Reset(); }
+
+ void Reset();
+
+ template <typename T>
+ void Set(T&& val) {
+ typedef typename std::remove_reference<T>::type RT;
+ Reset();
+ type = AnyUnionTraits<RT>::enum_value;
+ if (type != Any_NONE) {
+ value = new RT(std::forward<T>(val));
+ }
+ }
+
+ static void *UnPack(const void *obj, Any type, const flatbuffers::resolver_function_t *resolver);
+ flatbuffers::Offset<void> Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const;
+
+ MyGame::Example::MonsterT *AsMonster() {
+ return type == Any_Monster ?
+ reinterpret_cast<MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+ const MyGame::Example::MonsterT *AsMonster() const {
+ return type == Any_Monster ?
+ reinterpret_cast<const MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+ MyGame::Example::TestSimpleTableWithEnumT *AsTestSimpleTableWithEnum() {
+ return type == Any_TestSimpleTableWithEnum ?
+ reinterpret_cast<MyGame::Example::TestSimpleTableWithEnumT *>(value) : nullptr;
+ }
+ const MyGame::Example::TestSimpleTableWithEnumT *AsTestSimpleTableWithEnum() const {
+ return type == Any_TestSimpleTableWithEnum ?
+ reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnumT *>(value) : nullptr;
+ }
+ MyGame::Example2::MonsterT *AsMyGame_Example2_Monster() {
+ return type == Any_MyGame_Example2_Monster ?
+ reinterpret_cast<MyGame::Example2::MonsterT *>(value) : nullptr;
+ }
+ const MyGame::Example2::MonsterT *AsMyGame_Example2_Monster() const {
+ return type == Any_MyGame_Example2_Monster ?
+ reinterpret_cast<const MyGame::Example2::MonsterT *>(value) : nullptr;
+ }
+};
+
+
+inline bool operator==(const AnyUnion &lhs, const AnyUnion &rhs) {
+ if (lhs.type != rhs.type) return false;
+ switch (lhs.type) {
+ case Any_NONE: {
+ return true;
+ }
+ case Any_Monster: {
+ return *(reinterpret_cast<const MyGame::Example::MonsterT *>(lhs.value)) ==
+ *(reinterpret_cast<const MyGame::Example::MonsterT *>(rhs.value));
+ }
+ case Any_TestSimpleTableWithEnum: {
+ return *(reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnumT *>(lhs.value)) ==
+ *(reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnumT *>(rhs.value));
+ }
+ case Any_MyGame_Example2_Monster: {
+ return *(reinterpret_cast<const MyGame::Example2::MonsterT *>(lhs.value)) ==
+ *(reinterpret_cast<const MyGame::Example2::MonsterT *>(rhs.value));
+ }
+ default: {
+ return false;
+ }
+ }
+}
+
+inline bool operator!=(const AnyUnion &lhs, const AnyUnion &rhs) {
+ return !(lhs == rhs);
+}
+
+bool VerifyAny(flatbuffers::Verifier &verifier, const void *obj, Any type);
+bool VerifyAnyVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types);
+
+enum AnyUniqueAliases : uint8_t {
+ AnyUniqueAliases_NONE = 0,
+ AnyUniqueAliases_M = 1,
+ AnyUniqueAliases_TS = 2,
+ AnyUniqueAliases_M2 = 3,
+ AnyUniqueAliases_MIN = AnyUniqueAliases_NONE,
+ AnyUniqueAliases_MAX = AnyUniqueAliases_M2
+};
+
+inline const AnyUniqueAliases (&EnumValuesAnyUniqueAliases())[4] {
+ static const AnyUniqueAliases values[] = {
+ AnyUniqueAliases_NONE,
+ AnyUniqueAliases_M,
+ AnyUniqueAliases_TS,
+ AnyUniqueAliases_M2
+ };
+ return values;
+}
+
+inline const char * const *EnumNamesAnyUniqueAliases() {
+ static const char * const names[5] = {
+ "NONE",
+ "M",
+ "TS",
+ "M2",
+ nullptr
+ };
+ return names;
+}
+
+inline const char *EnumNameAnyUniqueAliases(AnyUniqueAliases e) {
+ if (flatbuffers::IsOutRange(e, AnyUniqueAliases_NONE, AnyUniqueAliases_M2)) return "";
+ const size_t index = static_cast<size_t>(e);
+ return EnumNamesAnyUniqueAliases()[index];
+}
+
+template<typename T> struct AnyUniqueAliasesTraits {
+ static const AnyUniqueAliases enum_value = AnyUniqueAliases_NONE;
+};
+
+template<> struct AnyUniqueAliasesTraits<MyGame::Example::Monster> {
+ static const AnyUniqueAliases enum_value = AnyUniqueAliases_M;
+};
+
+template<> struct AnyUniqueAliasesTraits<MyGame::Example::TestSimpleTableWithEnum> {
+ static const AnyUniqueAliases enum_value = AnyUniqueAliases_TS;
+};
+
+template<> struct AnyUniqueAliasesTraits<MyGame::Example2::Monster> {
+ static const AnyUniqueAliases enum_value = AnyUniqueAliases_M2;
+};
+
+template<typename T> struct AnyUniqueAliasesUnionTraits {
+ static const AnyUniqueAliases enum_value = AnyUniqueAliases_NONE;
+};
+
+template<> struct AnyUniqueAliasesUnionTraits<MyGame::Example::MonsterT> {
+ static const AnyUniqueAliases enum_value = AnyUniqueAliases_M;
+};
+
+template<> struct AnyUniqueAliasesUnionTraits<MyGame::Example::TestSimpleTableWithEnumT> {
+ static const AnyUniqueAliases enum_value = AnyUniqueAliases_TS;
+};
+
+template<> struct AnyUniqueAliasesUnionTraits<MyGame::Example2::MonsterT> {
+ static const AnyUniqueAliases enum_value = AnyUniqueAliases_M2;
+};
+
+struct AnyUniqueAliasesUnion {
+ AnyUniqueAliases type;
+ void *value;
+
+ AnyUniqueAliasesUnion() : type(AnyUniqueAliases_NONE), value(nullptr) {}
+ AnyUniqueAliasesUnion(AnyUniqueAliasesUnion&& u) FLATBUFFERS_NOEXCEPT :
+ type(AnyUniqueAliases_NONE), value(nullptr)
+ { std::swap(type, u.type); std::swap(value, u.value); }
+ AnyUniqueAliasesUnion(const AnyUniqueAliasesUnion &);
+ AnyUniqueAliasesUnion &operator=(const AnyUniqueAliasesUnion &u)
+ { AnyUniqueAliasesUnion t(u); std::swap(type, t.type); std::swap(value, t.value); return *this; }
+ AnyUniqueAliasesUnion &operator=(AnyUniqueAliasesUnion &&u) FLATBUFFERS_NOEXCEPT
+ { std::swap(type, u.type); std::swap(value, u.value); return *this; }
+ ~AnyUniqueAliasesUnion() { Reset(); }
+
+ void Reset();
+
+ template <typename T>
+ void Set(T&& val) {
+ typedef typename std::remove_reference<T>::type RT;
+ Reset();
+ type = AnyUniqueAliasesUnionTraits<RT>::enum_value;
+ if (type != AnyUniqueAliases_NONE) {
+ value = new RT(std::forward<T>(val));
+ }
+ }
+
+ static void *UnPack(const void *obj, AnyUniqueAliases type, const flatbuffers::resolver_function_t *resolver);
+ flatbuffers::Offset<void> Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const;
+
+ MyGame::Example::MonsterT *AsM() {
+ return type == AnyUniqueAliases_M ?
+ reinterpret_cast<MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+ const MyGame::Example::MonsterT *AsM() const {
+ return type == AnyUniqueAliases_M ?
+ reinterpret_cast<const MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+ MyGame::Example::TestSimpleTableWithEnumT *AsTS() {
+ return type == AnyUniqueAliases_TS ?
+ reinterpret_cast<MyGame::Example::TestSimpleTableWithEnumT *>(value) : nullptr;
+ }
+ const MyGame::Example::TestSimpleTableWithEnumT *AsTS() const {
+ return type == AnyUniqueAliases_TS ?
+ reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnumT *>(value) : nullptr;
+ }
+ MyGame::Example2::MonsterT *AsM2() {
+ return type == AnyUniqueAliases_M2 ?
+ reinterpret_cast<MyGame::Example2::MonsterT *>(value) : nullptr;
+ }
+ const MyGame::Example2::MonsterT *AsM2() const {
+ return type == AnyUniqueAliases_M2 ?
+ reinterpret_cast<const MyGame::Example2::MonsterT *>(value) : nullptr;
+ }
+};
+
+
+inline bool operator==(const AnyUniqueAliasesUnion &lhs, const AnyUniqueAliasesUnion &rhs) {
+ if (lhs.type != rhs.type) return false;
+ switch (lhs.type) {
+ case AnyUniqueAliases_NONE: {
+ return true;
+ }
+ case AnyUniqueAliases_M: {
+ return *(reinterpret_cast<const MyGame::Example::MonsterT *>(lhs.value)) ==
+ *(reinterpret_cast<const MyGame::Example::MonsterT *>(rhs.value));
+ }
+ case AnyUniqueAliases_TS: {
+ return *(reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnumT *>(lhs.value)) ==
+ *(reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnumT *>(rhs.value));
+ }
+ case AnyUniqueAliases_M2: {
+ return *(reinterpret_cast<const MyGame::Example2::MonsterT *>(lhs.value)) ==
+ *(reinterpret_cast<const MyGame::Example2::MonsterT *>(rhs.value));
+ }
+ default: {
+ return false;
+ }
+ }
+}
+
+inline bool operator!=(const AnyUniqueAliasesUnion &lhs, const AnyUniqueAliasesUnion &rhs) {
+ return !(lhs == rhs);
+}
+
+bool VerifyAnyUniqueAliases(flatbuffers::Verifier &verifier, const void *obj, AnyUniqueAliases type);
+bool VerifyAnyUniqueAliasesVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types);
+
+enum AnyAmbiguousAliases : uint8_t {
+ AnyAmbiguousAliases_NONE = 0,
+ AnyAmbiguousAliases_M1 = 1,
+ AnyAmbiguousAliases_M2 = 2,
+ AnyAmbiguousAliases_M3 = 3,
+ AnyAmbiguousAliases_MIN = AnyAmbiguousAliases_NONE,
+ AnyAmbiguousAliases_MAX = AnyAmbiguousAliases_M3
+};
+
+inline const AnyAmbiguousAliases (&EnumValuesAnyAmbiguousAliases())[4] {
+ static const AnyAmbiguousAliases values[] = {
+ AnyAmbiguousAliases_NONE,
+ AnyAmbiguousAliases_M1,
+ AnyAmbiguousAliases_M2,
+ AnyAmbiguousAliases_M3
+ };
+ return values;
+}
+
+inline const char * const *EnumNamesAnyAmbiguousAliases() {
+ static const char * const names[5] = {
+ "NONE",
+ "M1",
+ "M2",
+ "M3",
+ nullptr
+ };
+ return names;
+}
+
+inline const char *EnumNameAnyAmbiguousAliases(AnyAmbiguousAliases e) {
+ if (flatbuffers::IsOutRange(e, AnyAmbiguousAliases_NONE, AnyAmbiguousAliases_M3)) return "";
+ const size_t index = static_cast<size_t>(e);
+ return EnumNamesAnyAmbiguousAliases()[index];
+}
+
+struct AnyAmbiguousAliasesUnion {
+ AnyAmbiguousAliases type;
+ void *value;
+
+ AnyAmbiguousAliasesUnion() : type(AnyAmbiguousAliases_NONE), value(nullptr) {}
+ AnyAmbiguousAliasesUnion(AnyAmbiguousAliasesUnion&& u) FLATBUFFERS_NOEXCEPT :
+ type(AnyAmbiguousAliases_NONE), value(nullptr)
+ { std::swap(type, u.type); std::swap(value, u.value); }
+ AnyAmbiguousAliasesUnion(const AnyAmbiguousAliasesUnion &);
+ AnyAmbiguousAliasesUnion &operator=(const AnyAmbiguousAliasesUnion &u)
+ { AnyAmbiguousAliasesUnion t(u); std::swap(type, t.type); std::swap(value, t.value); return *this; }
+ AnyAmbiguousAliasesUnion &operator=(AnyAmbiguousAliasesUnion &&u) FLATBUFFERS_NOEXCEPT
+ { std::swap(type, u.type); std::swap(value, u.value); return *this; }
+ ~AnyAmbiguousAliasesUnion() { Reset(); }
+
+ void Reset();
+
+ static void *UnPack(const void *obj, AnyAmbiguousAliases type, const flatbuffers::resolver_function_t *resolver);
+ flatbuffers::Offset<void> Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const;
+
+ MyGame::Example::MonsterT *AsM1() {
+ return type == AnyAmbiguousAliases_M1 ?
+ reinterpret_cast<MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+ const MyGame::Example::MonsterT *AsM1() const {
+ return type == AnyAmbiguousAliases_M1 ?
+ reinterpret_cast<const MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+ MyGame::Example::MonsterT *AsM2() {
+ return type == AnyAmbiguousAliases_M2 ?
+ reinterpret_cast<MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+ const MyGame::Example::MonsterT *AsM2() const {
+ return type == AnyAmbiguousAliases_M2 ?
+ reinterpret_cast<const MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+ MyGame::Example::MonsterT *AsM3() {
+ return type == AnyAmbiguousAliases_M3 ?
+ reinterpret_cast<MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+ const MyGame::Example::MonsterT *AsM3() const {
+ return type == AnyAmbiguousAliases_M3 ?
+ reinterpret_cast<const MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+};
+
+
+inline bool operator==(const AnyAmbiguousAliasesUnion &lhs, const AnyAmbiguousAliasesUnion &rhs) {
+ if (lhs.type != rhs.type) return false;
+ switch (lhs.type) {
+ case AnyAmbiguousAliases_NONE: {
+ return true;
+ }
+ case AnyAmbiguousAliases_M1: {
+ return *(reinterpret_cast<const MyGame::Example::MonsterT *>(lhs.value)) ==
+ *(reinterpret_cast<const MyGame::Example::MonsterT *>(rhs.value));
+ }
+ case AnyAmbiguousAliases_M2: {
+ return *(reinterpret_cast<const MyGame::Example::MonsterT *>(lhs.value)) ==
+ *(reinterpret_cast<const MyGame::Example::MonsterT *>(rhs.value));
+ }
+ case AnyAmbiguousAliases_M3: {
+ return *(reinterpret_cast<const MyGame::Example::MonsterT *>(lhs.value)) ==
+ *(reinterpret_cast<const MyGame::Example::MonsterT *>(rhs.value));
+ }
+ default: {
+ return false;
+ }
+ }
+}
+
+inline bool operator!=(const AnyAmbiguousAliasesUnion &lhs, const AnyAmbiguousAliasesUnion &rhs) {
+ return !(lhs == rhs);
+}
+
+bool VerifyAnyAmbiguousAliases(flatbuffers::Verifier &verifier, const void *obj, AnyAmbiguousAliases type);
+bool VerifyAnyAmbiguousAliasesVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types);
+
+FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(2) Test FLATBUFFERS_FINAL_CLASS {
+ private:
+ int16_t a_;
+ int8_t b_;
+ int8_t padding0__;
+
+ public:
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return TestTypeTable();
+ }
+ Test()
+ : a_(0),
+ b_(0),
+ padding0__(0) {
+ (void)padding0__;
+ }
+ Test(int16_t _a, int8_t _b)
+ : a_(flatbuffers::EndianScalar(_a)),
+ b_(flatbuffers::EndianScalar(_b)),
+ padding0__(0) {
+ (void)padding0__;
+ }
+ int16_t a() const {
+ return flatbuffers::EndianScalar(a_);
+ }
+ void mutate_a(int16_t _a) {
+ flatbuffers::WriteScalar(&a_, _a);
+ }
+ int8_t b() const {
+ return flatbuffers::EndianScalar(b_);
+ }
+ void mutate_b(int8_t _b) {
+ flatbuffers::WriteScalar(&b_, _b);
+ }
+};
+FLATBUFFERS_STRUCT_END(Test, 4);
+
+inline bool operator==(const Test &lhs, const Test &rhs) {
+ return
+ (lhs.a() == rhs.a()) &&
+ (lhs.b() == rhs.b());
+}
+
+inline bool operator!=(const Test &lhs, const Test &rhs) {
+ return !(lhs == rhs);
+}
+
+
+FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) Vec3 FLATBUFFERS_FINAL_CLASS {
+ private:
+ float x_;
+ float y_;
+ float z_;
+ int32_t padding0__;
+ double test1_;
+ uint8_t test2_;
+ int8_t padding1__;
+ MyGame::Example::Test test3_;
+ int16_t padding2__;
+
+ public:
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return Vec3TypeTable();
+ }
+ Vec3()
+ : x_(0),
+ y_(0),
+ z_(0),
+ padding0__(0),
+ test1_(0),
+ test2_(0),
+ padding1__(0),
+ test3_(),
+ padding2__(0) {
+ (void)padding0__;
+ (void)padding1__;
+ (void)padding2__;
+ }
+ Vec3(float _x, float _y, float _z, double _test1, MyGame::Example::Color _test2, const MyGame::Example::Test &_test3)
+ : x_(flatbuffers::EndianScalar(_x)),
+ y_(flatbuffers::EndianScalar(_y)),
+ z_(flatbuffers::EndianScalar(_z)),
+ padding0__(0),
+ test1_(flatbuffers::EndianScalar(_test1)),
+ test2_(flatbuffers::EndianScalar(static_cast<uint8_t>(_test2))),
+ padding1__(0),
+ test3_(_test3),
+ padding2__(0) {
+ (void)padding0__;
+ (void)padding1__;
+ (void)padding2__;
+ }
+ float x() const {
+ return flatbuffers::EndianScalar(x_);
+ }
+ void mutate_x(float _x) {
+ flatbuffers::WriteScalar(&x_, _x);
+ }
+ float y() const {
+ return flatbuffers::EndianScalar(y_);
+ }
+ void mutate_y(float _y) {
+ flatbuffers::WriteScalar(&y_, _y);
+ }
+ float z() const {
+ return flatbuffers::EndianScalar(z_);
+ }
+ void mutate_z(float _z) {
+ flatbuffers::WriteScalar(&z_, _z);
+ }
+ double test1() const {
+ return flatbuffers::EndianScalar(test1_);
+ }
+ void mutate_test1(double _test1) {
+ flatbuffers::WriteScalar(&test1_, _test1);
+ }
+ MyGame::Example::Color test2() const {
+ return static_cast<MyGame::Example::Color>(flatbuffers::EndianScalar(test2_));
+ }
+ void mutate_test2(MyGame::Example::Color _test2) {
+ flatbuffers::WriteScalar(&test2_, static_cast<uint8_t>(_test2));
+ }
+ const MyGame::Example::Test &test3() const {
+ return test3_;
+ }
+ MyGame::Example::Test &mutable_test3() {
+ return test3_;
+ }
+};
+FLATBUFFERS_STRUCT_END(Vec3, 32);
+
+inline bool operator==(const Vec3 &lhs, const Vec3 &rhs) {
+ return
+ (lhs.x() == rhs.x()) &&
+ (lhs.y() == rhs.y()) &&
+ (lhs.z() == rhs.z()) &&
+ (lhs.test1() == rhs.test1()) &&
+ (lhs.test2() == rhs.test2()) &&
+ (lhs.test3() == rhs.test3());
+}
+
+inline bool operator!=(const Vec3 &lhs, const Vec3 &rhs) {
+ return !(lhs == rhs);
+}
+
+
+FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Ability FLATBUFFERS_FINAL_CLASS {
+ private:
+ uint32_t id_;
+ uint32_t distance_;
+
+ public:
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return AbilityTypeTable();
+ }
+ Ability()
+ : id_(0),
+ distance_(0) {
+ }
+ Ability(uint32_t _id, uint32_t _distance)
+ : id_(flatbuffers::EndianScalar(_id)),
+ distance_(flatbuffers::EndianScalar(_distance)) {
+ }
+ uint32_t id() const {
+ return flatbuffers::EndianScalar(id_);
+ }
+ void mutate_id(uint32_t _id) {
+ flatbuffers::WriteScalar(&id_, _id);
+ }
+ bool KeyCompareLessThan(const Ability *o) const {
+ return id() < o->id();
+ }
+ int KeyCompareWithValue(uint32_t _id) const {
+ return static_cast<int>(id() > _id) - static_cast<int>(id() < _id);
+ }
+ uint32_t distance() const {
+ return flatbuffers::EndianScalar(distance_);
+ }
+ void mutate_distance(uint32_t _distance) {
+ flatbuffers::WriteScalar(&distance_, _distance);
+ }
+};
+FLATBUFFERS_STRUCT_END(Ability, 8);
+
+inline bool operator==(const Ability &lhs, const Ability &rhs) {
+ return
+ (lhs.id() == rhs.id()) &&
+ (lhs.distance() == rhs.distance());
+}
+
+inline bool operator!=(const Ability &lhs, const Ability &rhs) {
+ return !(lhs == rhs);
+}
+
+
+FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) StructOfStructs FLATBUFFERS_FINAL_CLASS {
+ private:
+ MyGame::Example::Ability a_;
+ MyGame::Example::Test b_;
+ MyGame::Example::Ability c_;
+
+ public:
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return StructOfStructsTypeTable();
+ }
+ StructOfStructs()
+ : a_(),
+ b_(),
+ c_() {
+ }
+ StructOfStructs(const MyGame::Example::Ability &_a, const MyGame::Example::Test &_b, const MyGame::Example::Ability &_c)
+ : a_(_a),
+ b_(_b),
+ c_(_c) {
+ }
+ const MyGame::Example::Ability &a() const {
+ return a_;
+ }
+ MyGame::Example::Ability &mutable_a() {
+ return a_;
+ }
+ const MyGame::Example::Test &b() const {
+ return b_;
+ }
+ MyGame::Example::Test &mutable_b() {
+ return b_;
+ }
+ const MyGame::Example::Ability &c() const {
+ return c_;
+ }
+ MyGame::Example::Ability &mutable_c() {
+ return c_;
+ }
+};
+FLATBUFFERS_STRUCT_END(StructOfStructs, 20);
+
+inline bool operator==(const StructOfStructs &lhs, const StructOfStructs &rhs) {
+ return
+ (lhs.a() == rhs.a()) &&
+ (lhs.b() == rhs.b()) &&
+ (lhs.c() == rhs.c());
+}
+
+inline bool operator!=(const StructOfStructs &lhs, const StructOfStructs &rhs) {
+ return !(lhs == rhs);
+}
+
+
+FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) StructOfStructsOfStructs FLATBUFFERS_FINAL_CLASS {
+ private:
+ MyGame::Example::StructOfStructs a_;
+
+ public:
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return StructOfStructsOfStructsTypeTable();
+ }
+ StructOfStructsOfStructs()
+ : a_() {
+ }
+ StructOfStructsOfStructs(const MyGame::Example::StructOfStructs &_a)
+ : a_(_a) {
+ }
+ const MyGame::Example::StructOfStructs &a() const {
+ return a_;
+ }
+ MyGame::Example::StructOfStructs &mutable_a() {
+ return a_;
+ }
+};
+FLATBUFFERS_STRUCT_END(StructOfStructsOfStructs, 20);
+
+inline bool operator==(const StructOfStructsOfStructs &lhs, const StructOfStructsOfStructs &rhs) {
+ return
+ (lhs.a() == rhs.a());
+}
+
+inline bool operator!=(const StructOfStructsOfStructs &lhs, const StructOfStructsOfStructs &rhs) {
+ return !(lhs == rhs);
+}
+
+
+} // namespace Example
+
+struct InParentNamespaceT : public flatbuffers::NativeTable {
+ typedef InParentNamespace TableType;
+};
+
+struct InParentNamespace FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
+ typedef InParentNamespaceT NativeTableType;
+ typedef InParentNamespaceBuilder Builder;
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return InParentNamespaceTypeTable();
+ }
+ bool Verify(flatbuffers::Verifier &verifier) const {
+ return VerifyTableStart(verifier) &&
+ verifier.EndTable();
+ }
+ InParentNamespaceT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ void UnPackTo(InParentNamespaceT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ static flatbuffers::Offset<InParentNamespace> Pack(flatbuffers::FlatBufferBuilder &_fbb, const InParentNamespaceT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+};
+
+struct InParentNamespaceBuilder {
+ typedef InParentNamespace Table;
+ flatbuffers::FlatBufferBuilder &fbb_;
+ flatbuffers::uoffset_t start_;
+ explicit InParentNamespaceBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
+ flatbuffers::Offset<InParentNamespace> Finish() {
+ const auto end = fbb_.EndTable(start_);
+ auto o = flatbuffers::Offset<InParentNamespace>(end);
+ return o;
+ }
+};
+
+inline flatbuffers::Offset<InParentNamespace> CreateInParentNamespace(
+ flatbuffers::FlatBufferBuilder &_fbb) {
+ InParentNamespaceBuilder builder_(_fbb);
+ return builder_.Finish();
+}
+
+flatbuffers::Offset<InParentNamespace> CreateInParentNamespace(flatbuffers::FlatBufferBuilder &_fbb, const InParentNamespaceT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+
+namespace Example2 {
+
+struct MonsterT : public flatbuffers::NativeTable {
+ typedef Monster TableType;
+};
+
+struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
+ typedef MonsterT NativeTableType;
+ typedef MonsterBuilder Builder;
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return MonsterTypeTable();
+ }
+ bool Verify(flatbuffers::Verifier &verifier) const {
+ return VerifyTableStart(verifier) &&
+ verifier.EndTable();
+ }
+ MonsterT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ void UnPackTo(MonsterT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ static flatbuffers::Offset<Monster> Pack(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+};
+
+struct MonsterBuilder {
+ typedef Monster Table;
+ flatbuffers::FlatBufferBuilder &fbb_;
+ flatbuffers::uoffset_t start_;
+ explicit MonsterBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
+ flatbuffers::Offset<Monster> Finish() {
+ const auto end = fbb_.EndTable(start_);
+ auto o = flatbuffers::Offset<Monster>(end);
+ return o;
+ }
+};
+
+inline flatbuffers::Offset<Monster> CreateMonster(
+ flatbuffers::FlatBufferBuilder &_fbb) {
+ MonsterBuilder builder_(_fbb);
+ return builder_.Finish();
+}
+
+flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+
+} // namespace Example2
+
+namespace Example {
+
+struct TestSimpleTableWithEnumT : public flatbuffers::NativeTable {
+ typedef TestSimpleTableWithEnum TableType;
+ MyGame::Example::Color color = MyGame::Example::Color_Green;
+};
+
+struct TestSimpleTableWithEnum FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
+ typedef TestSimpleTableWithEnumT NativeTableType;
+ typedef TestSimpleTableWithEnumBuilder Builder;
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return TestSimpleTableWithEnumTypeTable();
+ }
+ enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
+ VT_COLOR = 4
+ };
+ MyGame::Example::Color color() const {
+ return static_cast<MyGame::Example::Color>(GetField<uint8_t>(VT_COLOR, 2));
+ }
+ bool mutate_color(MyGame::Example::Color _color = static_cast<MyGame::Example::Color>(2)) {
+ return SetField<uint8_t>(VT_COLOR, static_cast<uint8_t>(_color), 2);
+ }
+ bool Verify(flatbuffers::Verifier &verifier) const {
+ return VerifyTableStart(verifier) &&
+ VerifyField<uint8_t>(verifier, VT_COLOR, 1) &&
+ verifier.EndTable();
+ }
+ TestSimpleTableWithEnumT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ void UnPackTo(TestSimpleTableWithEnumT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ static flatbuffers::Offset<TestSimpleTableWithEnum> Pack(flatbuffers::FlatBufferBuilder &_fbb, const TestSimpleTableWithEnumT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+};
+
+struct TestSimpleTableWithEnumBuilder {
+ typedef TestSimpleTableWithEnum Table;
+ flatbuffers::FlatBufferBuilder &fbb_;
+ flatbuffers::uoffset_t start_;
+ void add_color(MyGame::Example::Color color) {
+ fbb_.AddElement<uint8_t>(TestSimpleTableWithEnum::VT_COLOR, static_cast<uint8_t>(color), 2);
+ }
+ explicit TestSimpleTableWithEnumBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
+ flatbuffers::Offset<TestSimpleTableWithEnum> Finish() {
+ const auto end = fbb_.EndTable(start_);
+ auto o = flatbuffers::Offset<TestSimpleTableWithEnum>(end);
+ return o;
+ }
+};
+
+inline flatbuffers::Offset<TestSimpleTableWithEnum> CreateTestSimpleTableWithEnum(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ MyGame::Example::Color color = MyGame::Example::Color_Green) {
+ TestSimpleTableWithEnumBuilder builder_(_fbb);
+ builder_.add_color(color);
+ return builder_.Finish();
+}
+
+flatbuffers::Offset<TestSimpleTableWithEnum> CreateTestSimpleTableWithEnum(flatbuffers::FlatBufferBuilder &_fbb, const TestSimpleTableWithEnumT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+
+struct StatT : public flatbuffers::NativeTable {
+ typedef Stat TableType;
+ std::string id{};
+ int64_t val = 0;
+ uint16_t count = 0;
+};
+
+struct Stat FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
+ typedef StatT NativeTableType;
+ typedef StatBuilder Builder;
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return StatTypeTable();
+ }
+ enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
+ VT_ID = 4,
+ VT_VAL = 6,
+ VT_COUNT = 8
+ };
+ const flatbuffers::String *id() const {
+ return GetPointer<const flatbuffers::String *>(VT_ID);
+ }
+ flatbuffers::String *mutable_id() {
+ return GetPointer<flatbuffers::String *>(VT_ID);
+ }
+ int64_t val() const {
+ return GetField<int64_t>(VT_VAL, 0);
+ }
+ bool mutate_val(int64_t _val = 0) {
+ return SetField<int64_t>(VT_VAL, _val, 0);
+ }
+ uint16_t count() const {
+ return GetField<uint16_t>(VT_COUNT, 0);
+ }
+ bool mutate_count(uint16_t _count = 0) {
+ return SetField<uint16_t>(VT_COUNT, _count, 0);
+ }
+ bool KeyCompareLessThan(const Stat *o) const {
+ return count() < o->count();
+ }
+ int KeyCompareWithValue(uint16_t _count) const {
+ return static_cast<int>(count() > _count) - static_cast<int>(count() < _count);
+ }
+ bool Verify(flatbuffers::Verifier &verifier) const {
+ return VerifyTableStart(verifier) &&
+ VerifyOffset(verifier, VT_ID) &&
+ verifier.VerifyString(id()) &&
+ VerifyField<int64_t>(verifier, VT_VAL, 8) &&
+ VerifyField<uint16_t>(verifier, VT_COUNT, 2) &&
+ verifier.EndTable();
+ }
+ StatT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ void UnPackTo(StatT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ static flatbuffers::Offset<Stat> Pack(flatbuffers::FlatBufferBuilder &_fbb, const StatT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+};
+
+struct StatBuilder {
+ typedef Stat Table;
+ flatbuffers::FlatBufferBuilder &fbb_;
+ flatbuffers::uoffset_t start_;
+ void add_id(flatbuffers::Offset<flatbuffers::String> id) {
+ fbb_.AddOffset(Stat::VT_ID, id);
+ }
+ void add_val(int64_t val) {
+ fbb_.AddElement<int64_t>(Stat::VT_VAL, val, 0);
+ }
+ void add_count(uint16_t count) {
+ fbb_.AddElement<uint16_t>(Stat::VT_COUNT, count, 0);
+ }
+ explicit StatBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
+ flatbuffers::Offset<Stat> Finish() {
+ const auto end = fbb_.EndTable(start_);
+ auto o = flatbuffers::Offset<Stat>(end);
+ return o;
+ }
+};
+
+inline flatbuffers::Offset<Stat> CreateStat(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ flatbuffers::Offset<flatbuffers::String> id = 0,
+ int64_t val = 0,
+ uint16_t count = 0) {
+ StatBuilder builder_(_fbb);
+ builder_.add_val(val);
+ builder_.add_id(id);
+ builder_.add_count(count);
+ return builder_.Finish();
+}
+
+inline flatbuffers::Offset<Stat> CreateStatDirect(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ const char *id = nullptr,
+ int64_t val = 0,
+ uint16_t count = 0) {
+ auto id__ = id ? _fbb.CreateString(id) : 0;
+ return MyGame::Example::CreateStat(
+ _fbb,
+ id__,
+ val,
+ count);
+}
+
+flatbuffers::Offset<Stat> CreateStat(flatbuffers::FlatBufferBuilder &_fbb, const StatT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+
+struct ReferrableT : public flatbuffers::NativeTable {
+ typedef Referrable TableType;
+ uint64_t id = 0;
+};
+
+struct Referrable FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
+ typedef ReferrableT NativeTableType;
+ typedef ReferrableBuilder Builder;
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return ReferrableTypeTable();
+ }
+ enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
+ VT_ID = 4
+ };
+ uint64_t id() const {
+ return GetField<uint64_t>(VT_ID, 0);
+ }
+ bool mutate_id(uint64_t _id = 0) {
+ return SetField<uint64_t>(VT_ID, _id, 0);
+ }
+ bool KeyCompareLessThan(const Referrable *o) const {
+ return id() < o->id();
+ }
+ int KeyCompareWithValue(uint64_t _id) const {
+ return static_cast<int>(id() > _id) - static_cast<int>(id() < _id);
+ }
+ bool Verify(flatbuffers::Verifier &verifier) const {
+ return VerifyTableStart(verifier) &&
+ VerifyField<uint64_t>(verifier, VT_ID, 8) &&
+ verifier.EndTable();
+ }
+ ReferrableT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ void UnPackTo(ReferrableT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ static flatbuffers::Offset<Referrable> Pack(flatbuffers::FlatBufferBuilder &_fbb, const ReferrableT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+};
+
+struct ReferrableBuilder {
+ typedef Referrable Table;
+ flatbuffers::FlatBufferBuilder &fbb_;
+ flatbuffers::uoffset_t start_;
+ void add_id(uint64_t id) {
+ fbb_.AddElement<uint64_t>(Referrable::VT_ID, id, 0);
+ }
+ explicit ReferrableBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
+ flatbuffers::Offset<Referrable> Finish() {
+ const auto end = fbb_.EndTable(start_);
+ auto o = flatbuffers::Offset<Referrable>(end);
+ return o;
+ }
+};
+
+inline flatbuffers::Offset<Referrable> CreateReferrable(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ uint64_t id = 0) {
+ ReferrableBuilder builder_(_fbb);
+ builder_.add_id(id);
+ return builder_.Finish();
+}
+
+flatbuffers::Offset<Referrable> CreateReferrable(flatbuffers::FlatBufferBuilder &_fbb, const ReferrableT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+
+struct MonsterT : public flatbuffers::NativeTable {
+ typedef Monster TableType;
+ flatbuffers::unique_ptr<MyGame::Example::Vec3> pos{};
+ int16_t mana = 150;
+ int16_t hp = 100;
+ std::string name{};
+ std::vector<uint8_t> inventory{};
+ MyGame::Example::Color color = MyGame::Example::Color_Blue;
+ MyGame::Example::AnyUnion test{};
+ std::vector<MyGame::Example::Test> test4{};
+ std::vector<std::string> testarrayofstring{};
+ std::vector<flatbuffers::unique_ptr<MyGame::Example::MonsterT>> testarrayoftables{};
+ flatbuffers::unique_ptr<MyGame::Example::MonsterT> enemy{};
+ std::vector<uint8_t> testnestedflatbuffer{};
+ flatbuffers::unique_ptr<MyGame::Example::StatT> testempty{};
+ bool testbool = false;
+ int32_t testhashs32_fnv1 = 0;
+ uint32_t testhashu32_fnv1 = 0;
+ int64_t testhashs64_fnv1 = 0;
+ uint64_t testhashu64_fnv1 = 0;
+ int32_t testhashs32_fnv1a = 0;
+ Stat *testhashu32_fnv1a = nullptr;
+ int64_t testhashs64_fnv1a = 0;
+ uint64_t testhashu64_fnv1a = 0;
+ std::vector<bool> testarrayofbools{};
+ float testf = 3.14159f;
+ float testf2 = 3.0f;
+ float testf3 = 0.0f;
+ std::vector<std::string> testarrayofstring2{};
+ std::vector<MyGame::Example::Ability> testarrayofsortedstruct{};
+ std::vector<uint8_t> flex{};
+ std::vector<MyGame::Example::Test> test5{};
+ std::vector<int64_t> vector_of_longs{};
+ std::vector<double> vector_of_doubles{};
+ flatbuffers::unique_ptr<MyGame::InParentNamespaceT> parent_namespace_test{};
+ std::vector<flatbuffers::unique_ptr<MyGame::Example::ReferrableT>> vector_of_referrables{};
+ ReferrableT *single_weak_reference = nullptr;
+ std::vector<ReferrableT *> vector_of_weak_references{};
+ std::vector<flatbuffers::unique_ptr<MyGame::Example::ReferrableT>> vector_of_strong_referrables{};
+ ReferrableT *co_owning_reference = nullptr;
+ std::vector<flatbuffers::unique_ptr<ReferrableT>> vector_of_co_owning_references{};
+ ReferrableT *non_owning_reference = nullptr;
+ std::vector<ReferrableT *> vector_of_non_owning_references{};
+ MyGame::Example::AnyUniqueAliasesUnion any_unique{};
+ MyGame::Example::AnyAmbiguousAliasesUnion any_ambiguous{};
+ std::vector<MyGame::Example::Color> vector_of_enums{};
+ MyGame::Example::Race signed_enum = MyGame::Example::Race_None;
+ std::vector<uint8_t> testrequirednestedflatbuffer{};
+ std::vector<flatbuffers::unique_ptr<MyGame::Example::StatT>> scalar_key_sorted_tables{};
+ MyGame::Example::Test native_inline{};
+ MyGame::Example::LongEnum long_enum_non_enum_default = static_cast<MyGame::Example::LongEnum>(0);
+ MyGame::Example::LongEnum long_enum_normal_default = MyGame::Example::LongEnum_LongOne;
+ MonsterT() = default;
+ MonsterT(const MonsterT &o);
+ MonsterT(MonsterT&&) FLATBUFFERS_NOEXCEPT = default;
+ MonsterT &operator=(MonsterT o) FLATBUFFERS_NOEXCEPT;
+};
+
+/// an example documentation comment: "monster object"
+struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
+ typedef MonsterT NativeTableType;
+ typedef MonsterBuilder Builder;
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return MonsterTypeTable();
+ }
+ enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
+ VT_POS = 4,
+ VT_MANA = 6,
+ VT_HP = 8,
+ VT_NAME = 10,
+ VT_INVENTORY = 14,
+ VT_COLOR = 16,
+ VT_TEST_TYPE = 18,
+ VT_TEST = 20,
+ VT_TEST4 = 22,
+ VT_TESTARRAYOFSTRING = 24,
+ VT_TESTARRAYOFTABLES = 26,
+ VT_ENEMY = 28,
+ VT_TESTNESTEDFLATBUFFER = 30,
+ VT_TESTEMPTY = 32,
+ VT_TESTBOOL = 34,
+ VT_TESTHASHS32_FNV1 = 36,
+ VT_TESTHASHU32_FNV1 = 38,
+ VT_TESTHASHS64_FNV1 = 40,
+ VT_TESTHASHU64_FNV1 = 42,
+ VT_TESTHASHS32_FNV1A = 44,
+ VT_TESTHASHU32_FNV1A = 46,
+ VT_TESTHASHS64_FNV1A = 48,
+ VT_TESTHASHU64_FNV1A = 50,
+ VT_TESTARRAYOFBOOLS = 52,
+ VT_TESTF = 54,
+ VT_TESTF2 = 56,
+ VT_TESTF3 = 58,
+ VT_TESTARRAYOFSTRING2 = 60,
+ VT_TESTARRAYOFSORTEDSTRUCT = 62,
+ VT_FLEX = 64,
+ VT_TEST5 = 66,
+ VT_VECTOR_OF_LONGS = 68,
+ VT_VECTOR_OF_DOUBLES = 70,
+ VT_PARENT_NAMESPACE_TEST = 72,
+ VT_VECTOR_OF_REFERRABLES = 74,
+ VT_SINGLE_WEAK_REFERENCE = 76,
+ VT_VECTOR_OF_WEAK_REFERENCES = 78,
+ VT_VECTOR_OF_STRONG_REFERRABLES = 80,
+ VT_CO_OWNING_REFERENCE = 82,
+ VT_VECTOR_OF_CO_OWNING_REFERENCES = 84,
+ VT_NON_OWNING_REFERENCE = 86,
+ VT_VECTOR_OF_NON_OWNING_REFERENCES = 88,
+ VT_ANY_UNIQUE_TYPE = 90,
+ VT_ANY_UNIQUE = 92,
+ VT_ANY_AMBIGUOUS_TYPE = 94,
+ VT_ANY_AMBIGUOUS = 96,
+ VT_VECTOR_OF_ENUMS = 98,
+ VT_SIGNED_ENUM = 100,
+ VT_TESTREQUIREDNESTEDFLATBUFFER = 102,
+ VT_SCALAR_KEY_SORTED_TABLES = 104,
+ VT_NATIVE_INLINE = 106,
+ VT_LONG_ENUM_NON_ENUM_DEFAULT = 108,
+ VT_LONG_ENUM_NORMAL_DEFAULT = 110
+ };
+ const MyGame::Example::Vec3 *pos() const {
+ return GetStruct<const MyGame::Example::Vec3 *>(VT_POS);
+ }
+ MyGame::Example::Vec3 *mutable_pos() {
+ return GetStruct<MyGame::Example::Vec3 *>(VT_POS);
+ }
+ int16_t mana() const {
+ return GetField<int16_t>(VT_MANA, 150);
+ }
+ bool mutate_mana(int16_t _mana = 150) {
+ return SetField<int16_t>(VT_MANA, _mana, 150);
+ }
+ int16_t hp() const {
+ return GetField<int16_t>(VT_HP, 100);
+ }
+ bool mutate_hp(int16_t _hp = 100) {
+ return SetField<int16_t>(VT_HP, _hp, 100);
+ }
+ const flatbuffers::String *name() const {
+ return GetPointer<const flatbuffers::String *>(VT_NAME);
+ }
+ flatbuffers::String *mutable_name() {
+ return GetPointer<flatbuffers::String *>(VT_NAME);
+ }
+ bool KeyCompareLessThan(const Monster *o) const {
+ return *name() < *o->name();
+ }
+ int KeyCompareWithValue(const char *_name) const {
+ return strcmp(name()->c_str(), _name);
+ }
+ const flatbuffers::Vector<uint8_t> *inventory() const {
+ return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_INVENTORY);
+ }
+ flatbuffers::Vector<uint8_t> *mutable_inventory() {
+ return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_INVENTORY);
+ }
+ MyGame::Example::Color color() const {
+ return static_cast<MyGame::Example::Color>(GetField<uint8_t>(VT_COLOR, 8));
+ }
+ bool mutate_color(MyGame::Example::Color _color = static_cast<MyGame::Example::Color>(8)) {
+ return SetField<uint8_t>(VT_COLOR, static_cast<uint8_t>(_color), 8);
+ }
+ MyGame::Example::Any test_type() const {
+ return static_cast<MyGame::Example::Any>(GetField<uint8_t>(VT_TEST_TYPE, 0));
+ }
+ const void *test() const {
+ return GetPointer<const void *>(VT_TEST);
+ }
+ template<typename T> const T *test_as() const;
+ const MyGame::Example::Monster *test_as_Monster() const {
+ return test_type() == MyGame::Example::Any_Monster ? static_cast<const MyGame::Example::Monster *>(test()) : nullptr;
+ }
+ const MyGame::Example::TestSimpleTableWithEnum *test_as_TestSimpleTableWithEnum() const {
+ return test_type() == MyGame::Example::Any_TestSimpleTableWithEnum ? static_cast<const MyGame::Example::TestSimpleTableWithEnum *>(test()) : nullptr;
+ }
+ const MyGame::Example2::Monster *test_as_MyGame_Example2_Monster() const {
+ return test_type() == MyGame::Example::Any_MyGame_Example2_Monster ? static_cast<const MyGame::Example2::Monster *>(test()) : nullptr;
+ }
+ void *mutable_test() {
+ return GetPointer<void *>(VT_TEST);
+ }
+ const flatbuffers::Vector<const MyGame::Example::Test *> *test4() const {
+ return GetPointer<const flatbuffers::Vector<const MyGame::Example::Test *> *>(VT_TEST4);
+ }
+ flatbuffers::Vector<const MyGame::Example::Test *> *mutable_test4() {
+ return GetPointer<flatbuffers::Vector<const MyGame::Example::Test *> *>(VT_TEST4);
+ }
+ const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *testarrayofstring() const {
+ return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_TESTARRAYOFSTRING);
+ }
+ flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *mutable_testarrayofstring() {
+ return GetPointer<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_TESTARRAYOFSTRING);
+ }
+ /// an example documentation comment: this will end up in the generated code
+ /// multiline too
+ const flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Monster>> *testarrayoftables() const {
+ return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Monster>> *>(VT_TESTARRAYOFTABLES);
+ }
+ flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Monster>> *mutable_testarrayoftables() {
+ return GetPointer<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Monster>> *>(VT_TESTARRAYOFTABLES);
+ }
+ const MyGame::Example::Monster *enemy() const {
+ return GetPointer<const MyGame::Example::Monster *>(VT_ENEMY);
+ }
+ MyGame::Example::Monster *mutable_enemy() {
+ return GetPointer<MyGame::Example::Monster *>(VT_ENEMY);
+ }
+ const flatbuffers::Vector<uint8_t> *testnestedflatbuffer() const {
+ return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_TESTNESTEDFLATBUFFER);
+ }
+ flatbuffers::Vector<uint8_t> *mutable_testnestedflatbuffer() {
+ return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_TESTNESTEDFLATBUFFER);
+ }
+ const MyGame::Example::Monster *testnestedflatbuffer_nested_root() const {
+ return flatbuffers::GetRoot<MyGame::Example::Monster>(testnestedflatbuffer()->Data());
+ }
+ const MyGame::Example::Stat *testempty() const {
+ return GetPointer<const MyGame::Example::Stat *>(VT_TESTEMPTY);
+ }
+ MyGame::Example::Stat *mutable_testempty() {
+ return GetPointer<MyGame::Example::Stat *>(VT_TESTEMPTY);
+ }
+ bool testbool() const {
+ return GetField<uint8_t>(VT_TESTBOOL, 0) != 0;
+ }
+ bool mutate_testbool(bool _testbool = 0) {
+ return SetField<uint8_t>(VT_TESTBOOL, static_cast<uint8_t>(_testbool), 0);
+ }
+ int32_t testhashs32_fnv1() const {
+ return GetField<int32_t>(VT_TESTHASHS32_FNV1, 0);
+ }
+ bool mutate_testhashs32_fnv1(int32_t _testhashs32_fnv1 = 0) {
+ return SetField<int32_t>(VT_TESTHASHS32_FNV1, _testhashs32_fnv1, 0);
+ }
+ uint32_t testhashu32_fnv1() const {
+ return GetField<uint32_t>(VT_TESTHASHU32_FNV1, 0);
+ }
+ bool mutate_testhashu32_fnv1(uint32_t _testhashu32_fnv1 = 0) {
+ return SetField<uint32_t>(VT_TESTHASHU32_FNV1, _testhashu32_fnv1, 0);
+ }
+ int64_t testhashs64_fnv1() const {
+ return GetField<int64_t>(VT_TESTHASHS64_FNV1, 0);
+ }
+ bool mutate_testhashs64_fnv1(int64_t _testhashs64_fnv1 = 0) {
+ return SetField<int64_t>(VT_TESTHASHS64_FNV1, _testhashs64_fnv1, 0);
+ }
+ uint64_t testhashu64_fnv1() const {
+ return GetField<uint64_t>(VT_TESTHASHU64_FNV1, 0);
+ }
+ bool mutate_testhashu64_fnv1(uint64_t _testhashu64_fnv1 = 0) {
+ return SetField<uint64_t>(VT_TESTHASHU64_FNV1, _testhashu64_fnv1, 0);
+ }
+ int32_t testhashs32_fnv1a() const {
+ return GetField<int32_t>(VT_TESTHASHS32_FNV1A, 0);
+ }
+ bool mutate_testhashs32_fnv1a(int32_t _testhashs32_fnv1a = 0) {
+ return SetField<int32_t>(VT_TESTHASHS32_FNV1A, _testhashs32_fnv1a, 0);
+ }
+ uint32_t testhashu32_fnv1a() const {
+ return GetField<uint32_t>(VT_TESTHASHU32_FNV1A, 0);
+ }
+ bool mutate_testhashu32_fnv1a(uint32_t _testhashu32_fnv1a = 0) {
+ return SetField<uint32_t>(VT_TESTHASHU32_FNV1A, _testhashu32_fnv1a, 0);
+ }
+ int64_t testhashs64_fnv1a() const {
+ return GetField<int64_t>(VT_TESTHASHS64_FNV1A, 0);
+ }
+ bool mutate_testhashs64_fnv1a(int64_t _testhashs64_fnv1a = 0) {
+ return SetField<int64_t>(VT_TESTHASHS64_FNV1A, _testhashs64_fnv1a, 0);
+ }
+ uint64_t testhashu64_fnv1a() const {
+ return GetField<uint64_t>(VT_TESTHASHU64_FNV1A, 0);
+ }
+ bool mutate_testhashu64_fnv1a(uint64_t _testhashu64_fnv1a = 0) {
+ return SetField<uint64_t>(VT_TESTHASHU64_FNV1A, _testhashu64_fnv1a, 0);
+ }
+ const flatbuffers::Vector<uint8_t> *testarrayofbools() const {
+ return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_TESTARRAYOFBOOLS);
+ }
+ flatbuffers::Vector<uint8_t> *mutable_testarrayofbools() {
+ return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_TESTARRAYOFBOOLS);
+ }
+ float testf() const {
+ return GetField<float>(VT_TESTF, 3.14159f);
+ }
+ bool mutate_testf(float _testf = 3.14159f) {
+ return SetField<float>(VT_TESTF, _testf, 3.14159f);
+ }
+ float testf2() const {
+ return GetField<float>(VT_TESTF2, 3.0f);
+ }
+ bool mutate_testf2(float _testf2 = 3.0f) {
+ return SetField<float>(VT_TESTF2, _testf2, 3.0f);
+ }
+ float testf3() const {
+ return GetField<float>(VT_TESTF3, 0.0f);
+ }
+ bool mutate_testf3(float _testf3 = 0.0f) {
+ return SetField<float>(VT_TESTF3, _testf3, 0.0f);
+ }
+ const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *testarrayofstring2() const {
+ return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_TESTARRAYOFSTRING2);
+ }
+ flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *mutable_testarrayofstring2() {
+ return GetPointer<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_TESTARRAYOFSTRING2);
+ }
+ const flatbuffers::Vector<const MyGame::Example::Ability *> *testarrayofsortedstruct() const {
+ return GetPointer<const flatbuffers::Vector<const MyGame::Example::Ability *> *>(VT_TESTARRAYOFSORTEDSTRUCT);
+ }
+ flatbuffers::Vector<const MyGame::Example::Ability *> *mutable_testarrayofsortedstruct() {
+ return GetPointer<flatbuffers::Vector<const MyGame::Example::Ability *> *>(VT_TESTARRAYOFSORTEDSTRUCT);
+ }
+ const flatbuffers::Vector<uint8_t> *flex() const {
+ return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_FLEX);
+ }
+ flatbuffers::Vector<uint8_t> *mutable_flex() {
+ return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_FLEX);
+ }
+ flexbuffers::Reference flex_flexbuffer_root() const {
+ return flexbuffers::GetRoot(flex()->Data(), flex()->size());
+ }
+ const flatbuffers::Vector<const MyGame::Example::Test *> *test5() const {
+ return GetPointer<const flatbuffers::Vector<const MyGame::Example::Test *> *>(VT_TEST5);
+ }
+ flatbuffers::Vector<const MyGame::Example::Test *> *mutable_test5() {
+ return GetPointer<flatbuffers::Vector<const MyGame::Example::Test *> *>(VT_TEST5);
+ }
+ const flatbuffers::Vector<int64_t> *vector_of_longs() const {
+ return GetPointer<const flatbuffers::Vector<int64_t> *>(VT_VECTOR_OF_LONGS);
+ }
+ flatbuffers::Vector<int64_t> *mutable_vector_of_longs() {
+ return GetPointer<flatbuffers::Vector<int64_t> *>(VT_VECTOR_OF_LONGS);
+ }
+ const flatbuffers::Vector<double> *vector_of_doubles() const {
+ return GetPointer<const flatbuffers::Vector<double> *>(VT_VECTOR_OF_DOUBLES);
+ }
+ flatbuffers::Vector<double> *mutable_vector_of_doubles() {
+ return GetPointer<flatbuffers::Vector<double> *>(VT_VECTOR_OF_DOUBLES);
+ }
+ const MyGame::InParentNamespace *parent_namespace_test() const {
+ return GetPointer<const MyGame::InParentNamespace *>(VT_PARENT_NAMESPACE_TEST);
+ }
+ MyGame::InParentNamespace *mutable_parent_namespace_test() {
+ return GetPointer<MyGame::InParentNamespace *>(VT_PARENT_NAMESPACE_TEST);
+ }
+ const flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>> *vector_of_referrables() const {
+ return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>> *>(VT_VECTOR_OF_REFERRABLES);
+ }
+ flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>> *mutable_vector_of_referrables() {
+ return GetPointer<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>> *>(VT_VECTOR_OF_REFERRABLES);
+ }
+ uint64_t single_weak_reference() const {
+ return GetField<uint64_t>(VT_SINGLE_WEAK_REFERENCE, 0);
+ }
+ bool mutate_single_weak_reference(uint64_t _single_weak_reference = 0) {
+ return SetField<uint64_t>(VT_SINGLE_WEAK_REFERENCE, _single_weak_reference, 0);
+ }
+ const flatbuffers::Vector<uint64_t> *vector_of_weak_references() const {
+ return GetPointer<const flatbuffers::Vector<uint64_t> *>(VT_VECTOR_OF_WEAK_REFERENCES);
+ }
+ flatbuffers::Vector<uint64_t> *mutable_vector_of_weak_references() {
+ return GetPointer<flatbuffers::Vector<uint64_t> *>(VT_VECTOR_OF_WEAK_REFERENCES);
+ }
+ const flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>> *vector_of_strong_referrables() const {
+ return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>> *>(VT_VECTOR_OF_STRONG_REFERRABLES);
+ }
+ flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>> *mutable_vector_of_strong_referrables() {
+ return GetPointer<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>> *>(VT_VECTOR_OF_STRONG_REFERRABLES);
+ }
+ uint64_t co_owning_reference() const {
+ return GetField<uint64_t>(VT_CO_OWNING_REFERENCE, 0);
+ }
+ bool mutate_co_owning_reference(uint64_t _co_owning_reference = 0) {
+ return SetField<uint64_t>(VT_CO_OWNING_REFERENCE, _co_owning_reference, 0);
+ }
+ const flatbuffers::Vector<uint64_t> *vector_of_co_owning_references() const {
+ return GetPointer<const flatbuffers::Vector<uint64_t> *>(VT_VECTOR_OF_CO_OWNING_REFERENCES);
+ }
+ flatbuffers::Vector<uint64_t> *mutable_vector_of_co_owning_references() {
+ return GetPointer<flatbuffers::Vector<uint64_t> *>(VT_VECTOR_OF_CO_OWNING_REFERENCES);
+ }
+ uint64_t non_owning_reference() const {
+ return GetField<uint64_t>(VT_NON_OWNING_REFERENCE, 0);
+ }
+ bool mutate_non_owning_reference(uint64_t _non_owning_reference = 0) {
+ return SetField<uint64_t>(VT_NON_OWNING_REFERENCE, _non_owning_reference, 0);
+ }
+ const flatbuffers::Vector<uint64_t> *vector_of_non_owning_references() const {
+ return GetPointer<const flatbuffers::Vector<uint64_t> *>(VT_VECTOR_OF_NON_OWNING_REFERENCES);
+ }
+ flatbuffers::Vector<uint64_t> *mutable_vector_of_non_owning_references() {
+ return GetPointer<flatbuffers::Vector<uint64_t> *>(VT_VECTOR_OF_NON_OWNING_REFERENCES);
+ }
+ MyGame::Example::AnyUniqueAliases any_unique_type() const {
+ return static_cast<MyGame::Example::AnyUniqueAliases>(GetField<uint8_t>(VT_ANY_UNIQUE_TYPE, 0));
+ }
+ const void *any_unique() const {
+ return GetPointer<const void *>(VT_ANY_UNIQUE);
+ }
+ template<typename T> const T *any_unique_as() const;
+ const MyGame::Example::Monster *any_unique_as_M() const {
+ return any_unique_type() == MyGame::Example::AnyUniqueAliases_M ? static_cast<const MyGame::Example::Monster *>(any_unique()) : nullptr;
+ }
+ const MyGame::Example::TestSimpleTableWithEnum *any_unique_as_TS() const {
+ return any_unique_type() == MyGame::Example::AnyUniqueAliases_TS ? static_cast<const MyGame::Example::TestSimpleTableWithEnum *>(any_unique()) : nullptr;
+ }
+ const MyGame::Example2::Monster *any_unique_as_M2() const {
+ return any_unique_type() == MyGame::Example::AnyUniqueAliases_M2 ? static_cast<const MyGame::Example2::Monster *>(any_unique()) : nullptr;
+ }
+ void *mutable_any_unique() {
+ return GetPointer<void *>(VT_ANY_UNIQUE);
+ }
+ MyGame::Example::AnyAmbiguousAliases any_ambiguous_type() const {
+ return static_cast<MyGame::Example::AnyAmbiguousAliases>(GetField<uint8_t>(VT_ANY_AMBIGUOUS_TYPE, 0));
+ }
+ const void *any_ambiguous() const {
+ return GetPointer<const void *>(VT_ANY_AMBIGUOUS);
+ }
+ const MyGame::Example::Monster *any_ambiguous_as_M1() const {
+ return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M1 ? static_cast<const MyGame::Example::Monster *>(any_ambiguous()) : nullptr;
+ }
+ const MyGame::Example::Monster *any_ambiguous_as_M2() const {
+ return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M2 ? static_cast<const MyGame::Example::Monster *>(any_ambiguous()) : nullptr;
+ }
+ const MyGame::Example::Monster *any_ambiguous_as_M3() const {
+ return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M3 ? static_cast<const MyGame::Example::Monster *>(any_ambiguous()) : nullptr;
+ }
+ void *mutable_any_ambiguous() {
+ return GetPointer<void *>(VT_ANY_AMBIGUOUS);
+ }
+ const flatbuffers::Vector<uint8_t> *vector_of_enums() const {
+ return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_VECTOR_OF_ENUMS);
+ }
+ flatbuffers::Vector<uint8_t> *mutable_vector_of_enums() {
+ return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_VECTOR_OF_ENUMS);
+ }
+ MyGame::Example::Race signed_enum() const {
+ return static_cast<MyGame::Example::Race>(GetField<int8_t>(VT_SIGNED_ENUM, -1));
+ }
+ bool mutate_signed_enum(MyGame::Example::Race _signed_enum = static_cast<MyGame::Example::Race>(-1)) {
+ return SetField<int8_t>(VT_SIGNED_ENUM, static_cast<int8_t>(_signed_enum), -1);
+ }
+ const flatbuffers::Vector<uint8_t> *testrequirednestedflatbuffer() const {
+ return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_TESTREQUIREDNESTEDFLATBUFFER);
+ }
+ flatbuffers::Vector<uint8_t> *mutable_testrequirednestedflatbuffer() {
+ return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_TESTREQUIREDNESTEDFLATBUFFER);
+ }
+ const MyGame::Example::Monster *testrequirednestedflatbuffer_nested_root() const {
+ return flatbuffers::GetRoot<MyGame::Example::Monster>(testrequirednestedflatbuffer()->Data());
+ }
+ const flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Stat>> *scalar_key_sorted_tables() const {
+ return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Stat>> *>(VT_SCALAR_KEY_SORTED_TABLES);
+ }
+ flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Stat>> *mutable_scalar_key_sorted_tables() {
+ return GetPointer<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Stat>> *>(VT_SCALAR_KEY_SORTED_TABLES);
+ }
+ const MyGame::Example::Test *native_inline() const {
+ return GetStruct<const MyGame::Example::Test *>(VT_NATIVE_INLINE);
+ }
+ MyGame::Example::Test *mutable_native_inline() {
+ return GetStruct<MyGame::Example::Test *>(VT_NATIVE_INLINE);
+ }
+ MyGame::Example::LongEnum long_enum_non_enum_default() const {
+ return static_cast<MyGame::Example::LongEnum>(GetField<uint64_t>(VT_LONG_ENUM_NON_ENUM_DEFAULT, 0));
+ }
+ bool mutate_long_enum_non_enum_default(MyGame::Example::LongEnum _long_enum_non_enum_default = static_cast<MyGame::Example::LongEnum>(0)) {
+ return SetField<uint64_t>(VT_LONG_ENUM_NON_ENUM_DEFAULT, static_cast<uint64_t>(_long_enum_non_enum_default), 0);
+ }
+ MyGame::Example::LongEnum long_enum_normal_default() const {
+ return static_cast<MyGame::Example::LongEnum>(GetField<uint64_t>(VT_LONG_ENUM_NORMAL_DEFAULT, 2ULL));
+ }
+ bool mutate_long_enum_normal_default(MyGame::Example::LongEnum _long_enum_normal_default = static_cast<MyGame::Example::LongEnum>(2ULL)) {
+ return SetField<uint64_t>(VT_LONG_ENUM_NORMAL_DEFAULT, static_cast<uint64_t>(_long_enum_normal_default), 2ULL);
+ }
+ bool Verify(flatbuffers::Verifier &verifier) const {
+ return VerifyTableStart(verifier) &&
+ VerifyField<MyGame::Example::Vec3>(verifier, VT_POS, 8) &&
+ VerifyField<int16_t>(verifier, VT_MANA, 2) &&
+ VerifyField<int16_t>(verifier, VT_HP, 2) &&
+ VerifyOffsetRequired(verifier, VT_NAME) &&
+ verifier.VerifyString(name()) &&
+ VerifyOffset(verifier, VT_INVENTORY) &&
+ verifier.VerifyVector(inventory()) &&
+ VerifyField<uint8_t>(verifier, VT_COLOR, 1) &&
+ VerifyField<uint8_t>(verifier, VT_TEST_TYPE, 1) &&
+ VerifyOffset(verifier, VT_TEST) &&
+ VerifyAny(verifier, test(), test_type()) &&
+ VerifyOffset(verifier, VT_TEST4) &&
+ verifier.VerifyVector(test4()) &&
+ VerifyOffset(verifier, VT_TESTARRAYOFSTRING) &&
+ verifier.VerifyVector(testarrayofstring()) &&
+ verifier.VerifyVectorOfStrings(testarrayofstring()) &&
+ VerifyOffset(verifier, VT_TESTARRAYOFTABLES) &&
+ verifier.VerifyVector(testarrayoftables()) &&
+ verifier.VerifyVectorOfTables(testarrayoftables()) &&
+ VerifyOffset(verifier, VT_ENEMY) &&
+ verifier.VerifyTable(enemy()) &&
+ VerifyOffset(verifier, VT_TESTNESTEDFLATBUFFER) &&
+ verifier.VerifyVector(testnestedflatbuffer()) &&
+ verifier.VerifyNestedFlatBuffer<MyGame::Example::Monster>(testnestedflatbuffer(), nullptr) &&
+ VerifyOffset(verifier, VT_TESTEMPTY) &&
+ verifier.VerifyTable(testempty()) &&
+ VerifyField<uint8_t>(verifier, VT_TESTBOOL, 1) &&
+ VerifyField<int32_t>(verifier, VT_TESTHASHS32_FNV1, 4) &&
+ VerifyField<uint32_t>(verifier, VT_TESTHASHU32_FNV1, 4) &&
+ VerifyField<int64_t>(verifier, VT_TESTHASHS64_FNV1, 8) &&
+ VerifyField<uint64_t>(verifier, VT_TESTHASHU64_FNV1, 8) &&
+ VerifyField<int32_t>(verifier, VT_TESTHASHS32_FNV1A, 4) &&
+ VerifyField<uint32_t>(verifier, VT_TESTHASHU32_FNV1A, 4) &&
+ VerifyField<int64_t>(verifier, VT_TESTHASHS64_FNV1A, 8) &&
+ VerifyField<uint64_t>(verifier, VT_TESTHASHU64_FNV1A, 8) &&
+ VerifyOffset(verifier, VT_TESTARRAYOFBOOLS) &&
+ verifier.VerifyVector(testarrayofbools()) &&
+ VerifyField<float>(verifier, VT_TESTF, 4) &&
+ VerifyField<float>(verifier, VT_TESTF2, 4) &&
+ VerifyField<float>(verifier, VT_TESTF3, 4) &&
+ VerifyOffset(verifier, VT_TESTARRAYOFSTRING2) &&
+ verifier.VerifyVector(testarrayofstring2()) &&
+ verifier.VerifyVectorOfStrings(testarrayofstring2()) &&
+ VerifyOffset(verifier, VT_TESTARRAYOFSORTEDSTRUCT) &&
+ verifier.VerifyVector(testarrayofsortedstruct()) &&
+ VerifyOffset(verifier, VT_FLEX) &&
+ verifier.VerifyVector(flex()) &&
+ flexbuffers::VerifyNestedFlexBuffer(flex(), verifier) &&
+ VerifyOffset(verifier, VT_TEST5) &&
+ verifier.VerifyVector(test5()) &&
+ VerifyOffset(verifier, VT_VECTOR_OF_LONGS) &&
+ verifier.VerifyVector(vector_of_longs()) &&
+ VerifyOffset(verifier, VT_VECTOR_OF_DOUBLES) &&
+ verifier.VerifyVector(vector_of_doubles()) &&
+ VerifyOffset(verifier, VT_PARENT_NAMESPACE_TEST) &&
+ verifier.VerifyTable(parent_namespace_test()) &&
+ VerifyOffset(verifier, VT_VECTOR_OF_REFERRABLES) &&
+ verifier.VerifyVector(vector_of_referrables()) &&
+ verifier.VerifyVectorOfTables(vector_of_referrables()) &&
+ VerifyField<uint64_t>(verifier, VT_SINGLE_WEAK_REFERENCE, 8) &&
+ VerifyOffset(verifier, VT_VECTOR_OF_WEAK_REFERENCES) &&
+ verifier.VerifyVector(vector_of_weak_references()) &&
+ VerifyOffset(verifier, VT_VECTOR_OF_STRONG_REFERRABLES) &&
+ verifier.VerifyVector(vector_of_strong_referrables()) &&
+ verifier.VerifyVectorOfTables(vector_of_strong_referrables()) &&
+ VerifyField<uint64_t>(verifier, VT_CO_OWNING_REFERENCE, 8) &&
+ VerifyOffset(verifier, VT_VECTOR_OF_CO_OWNING_REFERENCES) &&
+ verifier.VerifyVector(vector_of_co_owning_references()) &&
+ VerifyField<uint64_t>(verifier, VT_NON_OWNING_REFERENCE, 8) &&
+ VerifyOffset(verifier, VT_VECTOR_OF_NON_OWNING_REFERENCES) &&
+ verifier.VerifyVector(vector_of_non_owning_references()) &&
+ VerifyField<uint8_t>(verifier, VT_ANY_UNIQUE_TYPE, 1) &&
+ VerifyOffset(verifier, VT_ANY_UNIQUE) &&
+ VerifyAnyUniqueAliases(verifier, any_unique(), any_unique_type()) &&
+ VerifyField<uint8_t>(verifier, VT_ANY_AMBIGUOUS_TYPE, 1) &&
+ VerifyOffset(verifier, VT_ANY_AMBIGUOUS) &&
+ VerifyAnyAmbiguousAliases(verifier, any_ambiguous(), any_ambiguous_type()) &&
+ VerifyOffset(verifier, VT_VECTOR_OF_ENUMS) &&
+ verifier.VerifyVector(vector_of_enums()) &&
+ VerifyField<int8_t>(verifier, VT_SIGNED_ENUM, 1) &&
+ VerifyOffset(verifier, VT_TESTREQUIREDNESTEDFLATBUFFER) &&
+ verifier.VerifyVector(testrequirednestedflatbuffer()) &&
+ verifier.VerifyNestedFlatBuffer<MyGame::Example::Monster>(testrequirednestedflatbuffer(), nullptr) &&
+ VerifyOffset(verifier, VT_SCALAR_KEY_SORTED_TABLES) &&
+ verifier.VerifyVector(scalar_key_sorted_tables()) &&
+ verifier.VerifyVectorOfTables(scalar_key_sorted_tables()) &&
+ VerifyField<MyGame::Example::Test>(verifier, VT_NATIVE_INLINE, 2) &&
+ VerifyField<uint64_t>(verifier, VT_LONG_ENUM_NON_ENUM_DEFAULT, 8) &&
+ VerifyField<uint64_t>(verifier, VT_LONG_ENUM_NORMAL_DEFAULT, 8) &&
+ verifier.EndTable();
+ }
+ MonsterT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ void UnPackTo(MonsterT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ static flatbuffers::Offset<Monster> Pack(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+};
+
+template<> inline const MyGame::Example::Monster *Monster::test_as<MyGame::Example::Monster>() const {
+ return test_as_Monster();
+}
+
+template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::test_as<MyGame::Example::TestSimpleTableWithEnum>() const {
+ return test_as_TestSimpleTableWithEnum();
+}
+
+template<> inline const MyGame::Example2::Monster *Monster::test_as<MyGame::Example2::Monster>() const {
+ return test_as_MyGame_Example2_Monster();
+}
+
+template<> inline const MyGame::Example::Monster *Monster::any_unique_as<MyGame::Example::Monster>() const {
+ return any_unique_as_M();
+}
+
+template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() const {
+ return any_unique_as_TS();
+}
+
+template<> inline const MyGame::Example2::Monster *Monster::any_unique_as<MyGame::Example2::Monster>() const {
+ return any_unique_as_M2();
+}
+
+struct MonsterBuilder {
+ typedef Monster Table;
+ flatbuffers::FlatBufferBuilder &fbb_;
+ flatbuffers::uoffset_t start_;
+ void add_pos(const MyGame::Example::Vec3 *pos) {
+ fbb_.AddStruct(Monster::VT_POS, pos);
+ }
+ void add_mana(int16_t mana) {
+ fbb_.AddElement<int16_t>(Monster::VT_MANA, mana, 150);
+ }
+ void add_hp(int16_t hp) {
+ fbb_.AddElement<int16_t>(Monster::VT_HP, hp, 100);
+ }
+ void add_name(flatbuffers::Offset<flatbuffers::String> name) {
+ fbb_.AddOffset(Monster::VT_NAME, name);
+ }
+ void add_inventory(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> inventory) {
+ fbb_.AddOffset(Monster::VT_INVENTORY, inventory);
+ }
+ void add_color(MyGame::Example::Color color) {
+ fbb_.AddElement<uint8_t>(Monster::VT_COLOR, static_cast<uint8_t>(color), 8);
+ }
+ void add_test_type(MyGame::Example::Any test_type) {
+ fbb_.AddElement<uint8_t>(Monster::VT_TEST_TYPE, static_cast<uint8_t>(test_type), 0);
+ }
+ void add_test(flatbuffers::Offset<void> test) {
+ fbb_.AddOffset(Monster::VT_TEST, test);
+ }
+ void add_test4(flatbuffers::Offset<flatbuffers::Vector<const MyGame::Example::Test *>> test4) {
+ fbb_.AddOffset(Monster::VT_TEST4, test4);
+ }
+ void add_testarrayofstring(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> testarrayofstring) {
+ fbb_.AddOffset(Monster::VT_TESTARRAYOFSTRING, testarrayofstring);
+ }
+ void add_testarrayoftables(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Monster>>> testarrayoftables) {
+ fbb_.AddOffset(Monster::VT_TESTARRAYOFTABLES, testarrayoftables);
+ }
+ void add_enemy(flatbuffers::Offset<MyGame::Example::Monster> enemy) {
+ fbb_.AddOffset(Monster::VT_ENEMY, enemy);
+ }
+ void add_testnestedflatbuffer(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> testnestedflatbuffer) {
+ fbb_.AddOffset(Monster::VT_TESTNESTEDFLATBUFFER, testnestedflatbuffer);
+ }
+ void add_testempty(flatbuffers::Offset<MyGame::Example::Stat> testempty) {
+ fbb_.AddOffset(Monster::VT_TESTEMPTY, testempty);
+ }
+ void add_testbool(bool testbool) {
+ fbb_.AddElement<uint8_t>(Monster::VT_TESTBOOL, static_cast<uint8_t>(testbool), 0);
+ }
+ void add_testhashs32_fnv1(int32_t testhashs32_fnv1) {
+ fbb_.AddElement<int32_t>(Monster::VT_TESTHASHS32_FNV1, testhashs32_fnv1, 0);
+ }
+ void add_testhashu32_fnv1(uint32_t testhashu32_fnv1) {
+ fbb_.AddElement<uint32_t>(Monster::VT_TESTHASHU32_FNV1, testhashu32_fnv1, 0);
+ }
+ void add_testhashs64_fnv1(int64_t testhashs64_fnv1) {
+ fbb_.AddElement<int64_t>(Monster::VT_TESTHASHS64_FNV1, testhashs64_fnv1, 0);
+ }
+ void add_testhashu64_fnv1(uint64_t testhashu64_fnv1) {
+ fbb_.AddElement<uint64_t>(Monster::VT_TESTHASHU64_FNV1, testhashu64_fnv1, 0);
+ }
+ void add_testhashs32_fnv1a(int32_t testhashs32_fnv1a) {
+ fbb_.AddElement<int32_t>(Monster::VT_TESTHASHS32_FNV1A, testhashs32_fnv1a, 0);
+ }
+ void add_testhashu32_fnv1a(uint32_t testhashu32_fnv1a) {
+ fbb_.AddElement<uint32_t>(Monster::VT_TESTHASHU32_FNV1A, testhashu32_fnv1a, 0);
+ }
+ void add_testhashs64_fnv1a(int64_t testhashs64_fnv1a) {
+ fbb_.AddElement<int64_t>(Monster::VT_TESTHASHS64_FNV1A, testhashs64_fnv1a, 0);
+ }
+ void add_testhashu64_fnv1a(uint64_t testhashu64_fnv1a) {
+ fbb_.AddElement<uint64_t>(Monster::VT_TESTHASHU64_FNV1A, testhashu64_fnv1a, 0);
+ }
+ void add_testarrayofbools(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> testarrayofbools) {
+ fbb_.AddOffset(Monster::VT_TESTARRAYOFBOOLS, testarrayofbools);
+ }
+ void add_testf(float testf) {
+ fbb_.AddElement<float>(Monster::VT_TESTF, testf, 3.14159f);
+ }
+ void add_testf2(float testf2) {
+ fbb_.AddElement<float>(Monster::VT_TESTF2, testf2, 3.0f);
+ }
+ void add_testf3(float testf3) {
+ fbb_.AddElement<float>(Monster::VT_TESTF3, testf3, 0.0f);
+ }
+ void add_testarrayofstring2(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> testarrayofstring2) {
+ fbb_.AddOffset(Monster::VT_TESTARRAYOFSTRING2, testarrayofstring2);
+ }
+ void add_testarrayofsortedstruct(flatbuffers::Offset<flatbuffers::Vector<const MyGame::Example::Ability *>> testarrayofsortedstruct) {
+ fbb_.AddOffset(Monster::VT_TESTARRAYOFSORTEDSTRUCT, testarrayofsortedstruct);
+ }
+ void add_flex(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> flex) {
+ fbb_.AddOffset(Monster::VT_FLEX, flex);
+ }
+ void add_test5(flatbuffers::Offset<flatbuffers::Vector<const MyGame::Example::Test *>> test5) {
+ fbb_.AddOffset(Monster::VT_TEST5, test5);
+ }
+ void add_vector_of_longs(flatbuffers::Offset<flatbuffers::Vector<int64_t>> vector_of_longs) {
+ fbb_.AddOffset(Monster::VT_VECTOR_OF_LONGS, vector_of_longs);
+ }
+ void add_vector_of_doubles(flatbuffers::Offset<flatbuffers::Vector<double>> vector_of_doubles) {
+ fbb_.AddOffset(Monster::VT_VECTOR_OF_DOUBLES, vector_of_doubles);
+ }
+ void add_parent_namespace_test(flatbuffers::Offset<MyGame::InParentNamespace> parent_namespace_test) {
+ fbb_.AddOffset(Monster::VT_PARENT_NAMESPACE_TEST, parent_namespace_test);
+ }
+ void add_vector_of_referrables(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>>> vector_of_referrables) {
+ fbb_.AddOffset(Monster::VT_VECTOR_OF_REFERRABLES, vector_of_referrables);
+ }
+ void add_single_weak_reference(uint64_t single_weak_reference) {
+ fbb_.AddElement<uint64_t>(Monster::VT_SINGLE_WEAK_REFERENCE, single_weak_reference, 0);
+ }
+ void add_vector_of_weak_references(flatbuffers::Offset<flatbuffers::Vector<uint64_t>> vector_of_weak_references) {
+ fbb_.AddOffset(Monster::VT_VECTOR_OF_WEAK_REFERENCES, vector_of_weak_references);
+ }
+ void add_vector_of_strong_referrables(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>>> vector_of_strong_referrables) {
+ fbb_.AddOffset(Monster::VT_VECTOR_OF_STRONG_REFERRABLES, vector_of_strong_referrables);
+ }
+ void add_co_owning_reference(uint64_t co_owning_reference) {
+ fbb_.AddElement<uint64_t>(Monster::VT_CO_OWNING_REFERENCE, co_owning_reference, 0);
+ }
+ void add_vector_of_co_owning_references(flatbuffers::Offset<flatbuffers::Vector<uint64_t>> vector_of_co_owning_references) {
+ fbb_.AddOffset(Monster::VT_VECTOR_OF_CO_OWNING_REFERENCES, vector_of_co_owning_references);
+ }
+ void add_non_owning_reference(uint64_t non_owning_reference) {
+ fbb_.AddElement<uint64_t>(Monster::VT_NON_OWNING_REFERENCE, non_owning_reference, 0);
+ }
+ void add_vector_of_non_owning_references(flatbuffers::Offset<flatbuffers::Vector<uint64_t>> vector_of_non_owning_references) {
+ fbb_.AddOffset(Monster::VT_VECTOR_OF_NON_OWNING_REFERENCES, vector_of_non_owning_references);
+ }
+ void add_any_unique_type(MyGame::Example::AnyUniqueAliases any_unique_type) {
+ fbb_.AddElement<uint8_t>(Monster::VT_ANY_UNIQUE_TYPE, static_cast<uint8_t>(any_unique_type), 0);
+ }
+ void add_any_unique(flatbuffers::Offset<void> any_unique) {
+ fbb_.AddOffset(Monster::VT_ANY_UNIQUE, any_unique);
+ }
+ void add_any_ambiguous_type(MyGame::Example::AnyAmbiguousAliases any_ambiguous_type) {
+ fbb_.AddElement<uint8_t>(Monster::VT_ANY_AMBIGUOUS_TYPE, static_cast<uint8_t>(any_ambiguous_type), 0);
+ }
+ void add_any_ambiguous(flatbuffers::Offset<void> any_ambiguous) {
+ fbb_.AddOffset(Monster::VT_ANY_AMBIGUOUS, any_ambiguous);
+ }
+ void add_vector_of_enums(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> vector_of_enums) {
+ fbb_.AddOffset(Monster::VT_VECTOR_OF_ENUMS, vector_of_enums);
+ }
+ void add_signed_enum(MyGame::Example::Race signed_enum) {
+ fbb_.AddElement<int8_t>(Monster::VT_SIGNED_ENUM, static_cast<int8_t>(signed_enum), -1);
+ }
+ void add_testrequirednestedflatbuffer(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> testrequirednestedflatbuffer) {
+ fbb_.AddOffset(Monster::VT_TESTREQUIREDNESTEDFLATBUFFER, testrequirednestedflatbuffer);
+ }
+ void add_scalar_key_sorted_tables(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Stat>>> scalar_key_sorted_tables) {
+ fbb_.AddOffset(Monster::VT_SCALAR_KEY_SORTED_TABLES, scalar_key_sorted_tables);
+ }
+ void add_native_inline(const MyGame::Example::Test *native_inline) {
+ fbb_.AddStruct(Monster::VT_NATIVE_INLINE, native_inline);
+ }
+ void add_long_enum_non_enum_default(MyGame::Example::LongEnum long_enum_non_enum_default) {
+ fbb_.AddElement<uint64_t>(Monster::VT_LONG_ENUM_NON_ENUM_DEFAULT, static_cast<uint64_t>(long_enum_non_enum_default), 0);
+ }
+ void add_long_enum_normal_default(MyGame::Example::LongEnum long_enum_normal_default) {
+ fbb_.AddElement<uint64_t>(Monster::VT_LONG_ENUM_NORMAL_DEFAULT, static_cast<uint64_t>(long_enum_normal_default), 2ULL);
+ }
+ explicit MonsterBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
+ flatbuffers::Offset<Monster> Finish() {
+ const auto end = fbb_.EndTable(start_);
+ auto o = flatbuffers::Offset<Monster>(end);
+ fbb_.Required(o, Monster::VT_NAME);
+ return o;
+ }
+};
+
+inline flatbuffers::Offset<Monster> CreateMonster(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ const MyGame::Example::Vec3 *pos = nullptr,
+ int16_t mana = 150,
+ int16_t hp = 100,
+ flatbuffers::Offset<flatbuffers::String> name = 0,
+ flatbuffers::Offset<flatbuffers::Vector<uint8_t>> inventory = 0,
+ MyGame::Example::Color color = MyGame::Example::Color_Blue,
+ MyGame::Example::Any test_type = MyGame::Example::Any_NONE,
+ flatbuffers::Offset<void> test = 0,
+ flatbuffers::Offset<flatbuffers::Vector<const MyGame::Example::Test *>> test4 = 0,
+ flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> testarrayofstring = 0,
+ flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Monster>>> testarrayoftables = 0,
+ flatbuffers::Offset<MyGame::Example::Monster> enemy = 0,
+ flatbuffers::Offset<flatbuffers::Vector<uint8_t>> testnestedflatbuffer = 0,
+ flatbuffers::Offset<MyGame::Example::Stat> testempty = 0,
+ bool testbool = false,
+ int32_t testhashs32_fnv1 = 0,
+ uint32_t testhashu32_fnv1 = 0,
+ int64_t testhashs64_fnv1 = 0,
+ uint64_t testhashu64_fnv1 = 0,
+ int32_t testhashs32_fnv1a = 0,
+ uint32_t testhashu32_fnv1a = 0,
+ int64_t testhashs64_fnv1a = 0,
+ uint64_t testhashu64_fnv1a = 0,
+ flatbuffers::Offset<flatbuffers::Vector<uint8_t>> testarrayofbools = 0,
+ float testf = 3.14159f,
+ float testf2 = 3.0f,
+ float testf3 = 0.0f,
+ flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> testarrayofstring2 = 0,
+ flatbuffers::Offset<flatbuffers::Vector<const MyGame::Example::Ability *>> testarrayofsortedstruct = 0,
+ flatbuffers::Offset<flatbuffers::Vector<uint8_t>> flex = 0,
+ flatbuffers::Offset<flatbuffers::Vector<const MyGame::Example::Test *>> test5 = 0,
+ flatbuffers::Offset<flatbuffers::Vector<int64_t>> vector_of_longs = 0,
+ flatbuffers::Offset<flatbuffers::Vector<double>> vector_of_doubles = 0,
+ flatbuffers::Offset<MyGame::InParentNamespace> parent_namespace_test = 0,
+ flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>>> vector_of_referrables = 0,
+ uint64_t single_weak_reference = 0,
+ flatbuffers::Offset<flatbuffers::Vector<uint64_t>> vector_of_weak_references = 0,
+ flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>>> vector_of_strong_referrables = 0,
+ uint64_t co_owning_reference = 0,
+ flatbuffers::Offset<flatbuffers::Vector<uint64_t>> vector_of_co_owning_references = 0,
+ uint64_t non_owning_reference = 0,
+ flatbuffers::Offset<flatbuffers::Vector<uint64_t>> vector_of_non_owning_references = 0,
+ MyGame::Example::AnyUniqueAliases any_unique_type = MyGame::Example::AnyUniqueAliases_NONE,
+ flatbuffers::Offset<void> any_unique = 0,
+ MyGame::Example::AnyAmbiguousAliases any_ambiguous_type = MyGame::Example::AnyAmbiguousAliases_NONE,
+ flatbuffers::Offset<void> any_ambiguous = 0,
+ flatbuffers::Offset<flatbuffers::Vector<uint8_t>> vector_of_enums = 0,
+ MyGame::Example::Race signed_enum = MyGame::Example::Race_None,
+ flatbuffers::Offset<flatbuffers::Vector<uint8_t>> testrequirednestedflatbuffer = 0,
+ flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Stat>>> scalar_key_sorted_tables = 0,
+ const MyGame::Example::Test *native_inline = nullptr,
+ MyGame::Example::LongEnum long_enum_non_enum_default = static_cast<MyGame::Example::LongEnum>(0),
+ MyGame::Example::LongEnum long_enum_normal_default = MyGame::Example::LongEnum_LongOne) {
+ MonsterBuilder builder_(_fbb);
+ builder_.add_long_enum_normal_default(long_enum_normal_default);
+ builder_.add_long_enum_non_enum_default(long_enum_non_enum_default);
+ builder_.add_non_owning_reference(non_owning_reference);
+ builder_.add_co_owning_reference(co_owning_reference);
+ builder_.add_single_weak_reference(single_weak_reference);
+ builder_.add_testhashu64_fnv1a(testhashu64_fnv1a);
+ builder_.add_testhashs64_fnv1a(testhashs64_fnv1a);
+ builder_.add_testhashu64_fnv1(testhashu64_fnv1);
+ builder_.add_testhashs64_fnv1(testhashs64_fnv1);
+ builder_.add_native_inline(native_inline);
+ builder_.add_scalar_key_sorted_tables(scalar_key_sorted_tables);
+ builder_.add_testrequirednestedflatbuffer(testrequirednestedflatbuffer);
+ builder_.add_vector_of_enums(vector_of_enums);
+ builder_.add_any_ambiguous(any_ambiguous);
+ builder_.add_any_unique(any_unique);
+ builder_.add_vector_of_non_owning_references(vector_of_non_owning_references);
+ builder_.add_vector_of_co_owning_references(vector_of_co_owning_references);
+ builder_.add_vector_of_strong_referrables(vector_of_strong_referrables);
+ builder_.add_vector_of_weak_references(vector_of_weak_references);
+ builder_.add_vector_of_referrables(vector_of_referrables);
+ builder_.add_parent_namespace_test(parent_namespace_test);
+ builder_.add_vector_of_doubles(vector_of_doubles);
+ builder_.add_vector_of_longs(vector_of_longs);
+ builder_.add_test5(test5);
+ builder_.add_flex(flex);
+ builder_.add_testarrayofsortedstruct(testarrayofsortedstruct);
+ builder_.add_testarrayofstring2(testarrayofstring2);
+ builder_.add_testf3(testf3);
+ builder_.add_testf2(testf2);
+ builder_.add_testf(testf);
+ builder_.add_testarrayofbools(testarrayofbools);
+ builder_.add_testhashu32_fnv1a(testhashu32_fnv1a);
+ builder_.add_testhashs32_fnv1a(testhashs32_fnv1a);
+ builder_.add_testhashu32_fnv1(testhashu32_fnv1);
+ builder_.add_testhashs32_fnv1(testhashs32_fnv1);
+ builder_.add_testempty(testempty);
+ builder_.add_testnestedflatbuffer(testnestedflatbuffer);
+ builder_.add_enemy(enemy);
+ builder_.add_testarrayoftables(testarrayoftables);
+ builder_.add_testarrayofstring(testarrayofstring);
+ builder_.add_test4(test4);
+ builder_.add_test(test);
+ builder_.add_inventory(inventory);
+ builder_.add_name(name);
+ builder_.add_pos(pos);
+ builder_.add_hp(hp);
+ builder_.add_mana(mana);
+ builder_.add_signed_enum(signed_enum);
+ builder_.add_any_ambiguous_type(any_ambiguous_type);
+ builder_.add_any_unique_type(any_unique_type);
+ builder_.add_testbool(testbool);
+ builder_.add_test_type(test_type);
+ builder_.add_color(color);
+ return builder_.Finish();
+}
+
+inline flatbuffers::Offset<Monster> CreateMonsterDirect(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ const MyGame::Example::Vec3 *pos = nullptr,
+ int16_t mana = 150,
+ int16_t hp = 100,
+ const char *name = nullptr,
+ const std::vector<uint8_t> *inventory = nullptr,
+ MyGame::Example::Color color = MyGame::Example::Color_Blue,
+ MyGame::Example::Any test_type = MyGame::Example::Any_NONE,
+ flatbuffers::Offset<void> test = 0,
+ const std::vector<MyGame::Example::Test> *test4 = nullptr,
+ const std::vector<flatbuffers::Offset<flatbuffers::String>> *testarrayofstring = nullptr,
+ std::vector<flatbuffers::Offset<MyGame::Example::Monster>> *testarrayoftables = nullptr,
+ flatbuffers::Offset<MyGame::Example::Monster> enemy = 0,
+ const std::vector<uint8_t> *testnestedflatbuffer = nullptr,
+ flatbuffers::Offset<MyGame::Example::Stat> testempty = 0,
+ bool testbool = false,
+ int32_t testhashs32_fnv1 = 0,
+ uint32_t testhashu32_fnv1 = 0,
+ int64_t testhashs64_fnv1 = 0,
+ uint64_t testhashu64_fnv1 = 0,
+ int32_t testhashs32_fnv1a = 0,
+ uint32_t testhashu32_fnv1a = 0,
+ int64_t testhashs64_fnv1a = 0,
+ uint64_t testhashu64_fnv1a = 0,
+ const std::vector<uint8_t> *testarrayofbools = nullptr,
+ float testf = 3.14159f,
+ float testf2 = 3.0f,
+ float testf3 = 0.0f,
+ const std::vector<flatbuffers::Offset<flatbuffers::String>> *testarrayofstring2 = nullptr,
+ std::vector<MyGame::Example::Ability> *testarrayofsortedstruct = nullptr,
+ const std::vector<uint8_t> *flex = nullptr,
+ const std::vector<MyGame::Example::Test> *test5 = nullptr,
+ const std::vector<int64_t> *vector_of_longs = nullptr,
+ const std::vector<double> *vector_of_doubles = nullptr,
+ flatbuffers::Offset<MyGame::InParentNamespace> parent_namespace_test = 0,
+ std::vector<flatbuffers::Offset<MyGame::Example::Referrable>> *vector_of_referrables = nullptr,
+ uint64_t single_weak_reference = 0,
+ const std::vector<uint64_t> *vector_of_weak_references = nullptr,
+ std::vector<flatbuffers::Offset<MyGame::Example::Referrable>> *vector_of_strong_referrables = nullptr,
+ uint64_t co_owning_reference = 0,
+ const std::vector<uint64_t> *vector_of_co_owning_references = nullptr,
+ uint64_t non_owning_reference = 0,
+ const std::vector<uint64_t> *vector_of_non_owning_references = nullptr,
+ MyGame::Example::AnyUniqueAliases any_unique_type = MyGame::Example::AnyUniqueAliases_NONE,
+ flatbuffers::Offset<void> any_unique = 0,
+ MyGame::Example::AnyAmbiguousAliases any_ambiguous_type = MyGame::Example::AnyAmbiguousAliases_NONE,
+ flatbuffers::Offset<void> any_ambiguous = 0,
+ const std::vector<uint8_t> *vector_of_enums = nullptr,
+ MyGame::Example::Race signed_enum = MyGame::Example::Race_None,
+ const std::vector<uint8_t> *testrequirednestedflatbuffer = nullptr,
+ std::vector<flatbuffers::Offset<MyGame::Example::Stat>> *scalar_key_sorted_tables = nullptr,
+ const MyGame::Example::Test *native_inline = nullptr,
+ MyGame::Example::LongEnum long_enum_non_enum_default = static_cast<MyGame::Example::LongEnum>(0),
+ MyGame::Example::LongEnum long_enum_normal_default = MyGame::Example::LongEnum_LongOne) {
+ auto name__ = name ? _fbb.CreateString(name) : 0;
+ auto inventory__ = inventory ? _fbb.CreateVector<uint8_t>(*inventory) : 0;
+ auto test4__ = test4 ? _fbb.CreateVectorOfStructs<MyGame::Example::Test>(*test4) : 0;
+ auto testarrayofstring__ = testarrayofstring ? _fbb.CreateVector<flatbuffers::Offset<flatbuffers::String>>(*testarrayofstring) : 0;
+ auto testarrayoftables__ = testarrayoftables ? _fbb.CreateVectorOfSortedTables<MyGame::Example::Monster>(testarrayoftables) : 0;
+ auto testnestedflatbuffer__ = testnestedflatbuffer ? _fbb.CreateVector<uint8_t>(*testnestedflatbuffer) : 0;
+ auto testarrayofbools__ = testarrayofbools ? _fbb.CreateVector<uint8_t>(*testarrayofbools) : 0;
+ auto testarrayofstring2__ = testarrayofstring2 ? _fbb.CreateVector<flatbuffers::Offset<flatbuffers::String>>(*testarrayofstring2) : 0;
+ auto testarrayofsortedstruct__ = testarrayofsortedstruct ? _fbb.CreateVectorOfSortedStructs<MyGame::Example::Ability>(testarrayofsortedstruct) : 0;
+ auto flex__ = flex ? _fbb.CreateVector<uint8_t>(*flex) : 0;
+ auto test5__ = test5 ? _fbb.CreateVectorOfStructs<MyGame::Example::Test>(*test5) : 0;
+ auto vector_of_longs__ = vector_of_longs ? _fbb.CreateVector<int64_t>(*vector_of_longs) : 0;
+ auto vector_of_doubles__ = vector_of_doubles ? _fbb.CreateVector<double>(*vector_of_doubles) : 0;
+ auto vector_of_referrables__ = vector_of_referrables ? _fbb.CreateVectorOfSortedTables<MyGame::Example::Referrable>(vector_of_referrables) : 0;
+ auto vector_of_weak_references__ = vector_of_weak_references ? _fbb.CreateVector<uint64_t>(*vector_of_weak_references) : 0;
+ auto vector_of_strong_referrables__ = vector_of_strong_referrables ? _fbb.CreateVectorOfSortedTables<MyGame::Example::Referrable>(vector_of_strong_referrables) : 0;
+ auto vector_of_co_owning_references__ = vector_of_co_owning_references ? _fbb.CreateVector<uint64_t>(*vector_of_co_owning_references) : 0;
+ auto vector_of_non_owning_references__ = vector_of_non_owning_references ? _fbb.CreateVector<uint64_t>(*vector_of_non_owning_references) : 0;
+ auto vector_of_enums__ = vector_of_enums ? _fbb.CreateVector<uint8_t>(*vector_of_enums) : 0;
+ auto testrequirednestedflatbuffer__ = testrequirednestedflatbuffer ? _fbb.CreateVector<uint8_t>(*testrequirednestedflatbuffer) : 0;
+ auto scalar_key_sorted_tables__ = scalar_key_sorted_tables ? _fbb.CreateVectorOfSortedTables<MyGame::Example::Stat>(scalar_key_sorted_tables) : 0;
+ return MyGame::Example::CreateMonster(
+ _fbb,
+ pos,
+ mana,
+ hp,
+ name__,
+ inventory__,
+ color,
+ test_type,
+ test,
+ test4__,
+ testarrayofstring__,
+ testarrayoftables__,
+ enemy,
+ testnestedflatbuffer__,
+ testempty,
+ testbool,
+ testhashs32_fnv1,
+ testhashu32_fnv1,
+ testhashs64_fnv1,
+ testhashu64_fnv1,
+ testhashs32_fnv1a,
+ testhashu32_fnv1a,
+ testhashs64_fnv1a,
+ testhashu64_fnv1a,
+ testarrayofbools__,
+ testf,
+ testf2,
+ testf3,
+ testarrayofstring2__,
+ testarrayofsortedstruct__,
+ flex__,
+ test5__,
+ vector_of_longs__,
+ vector_of_doubles__,
+ parent_namespace_test,
+ vector_of_referrables__,
+ single_weak_reference,
+ vector_of_weak_references__,
+ vector_of_strong_referrables__,
+ co_owning_reference,
+ vector_of_co_owning_references__,
+ non_owning_reference,
+ vector_of_non_owning_references__,
+ any_unique_type,
+ any_unique,
+ any_ambiguous_type,
+ any_ambiguous,
+ vector_of_enums__,
+ signed_enum,
+ testrequirednestedflatbuffer__,
+ scalar_key_sorted_tables__,
+ native_inline,
+ long_enum_non_enum_default,
+ long_enum_normal_default);
+}
+
+flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+
+struct TypeAliasesT : public flatbuffers::NativeTable {
+ typedef TypeAliases TableType;
+ int8_t i8 = 0;
+ uint8_t u8 = 0;
+ int16_t i16 = 0;
+ uint16_t u16 = 0;
+ int32_t i32 = 0;
+ uint32_t u32 = 0;
+ int64_t i64 = 0;
+ uint64_t u64 = 0;
+ float f32 = 0.0f;
+ double f64 = 0.0;
+ std::vector<int8_t> v8{};
+ std::vector<double> vf64{};
+};
+
+struct TypeAliases FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
+ typedef TypeAliasesT NativeTableType;
+ typedef TypeAliasesBuilder Builder;
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return TypeAliasesTypeTable();
+ }
+ enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
+ VT_I8 = 4,
+ VT_U8 = 6,
+ VT_I16 = 8,
+ VT_U16 = 10,
+ VT_I32 = 12,
+ VT_U32 = 14,
+ VT_I64 = 16,
+ VT_U64 = 18,
+ VT_F32 = 20,
+ VT_F64 = 22,
+ VT_V8 = 24,
+ VT_VF64 = 26
+ };
+ int8_t i8() const {
+ return GetField<int8_t>(VT_I8, 0);
+ }
+ bool mutate_i8(int8_t _i8 = 0) {
+ return SetField<int8_t>(VT_I8, _i8, 0);
+ }
+ uint8_t u8() const {
+ return GetField<uint8_t>(VT_U8, 0);
+ }
+ bool mutate_u8(uint8_t _u8 = 0) {
+ return SetField<uint8_t>(VT_U8, _u8, 0);
+ }
+ int16_t i16() const {
+ return GetField<int16_t>(VT_I16, 0);
+ }
+ bool mutate_i16(int16_t _i16 = 0) {
+ return SetField<int16_t>(VT_I16, _i16, 0);
+ }
+ uint16_t u16() const {
+ return GetField<uint16_t>(VT_U16, 0);
+ }
+ bool mutate_u16(uint16_t _u16 = 0) {
+ return SetField<uint16_t>(VT_U16, _u16, 0);
+ }
+ int32_t i32() const {
+ return GetField<int32_t>(VT_I32, 0);
+ }
+ bool mutate_i32(int32_t _i32 = 0) {
+ return SetField<int32_t>(VT_I32, _i32, 0);
+ }
+ uint32_t u32() const {
+ return GetField<uint32_t>(VT_U32, 0);
+ }
+ bool mutate_u32(uint32_t _u32 = 0) {
+ return SetField<uint32_t>(VT_U32, _u32, 0);
+ }
+ int64_t i64() const {
+ return GetField<int64_t>(VT_I64, 0);
+ }
+ bool mutate_i64(int64_t _i64 = 0) {
+ return SetField<int64_t>(VT_I64, _i64, 0);
+ }
+ uint64_t u64() const {
+ return GetField<uint64_t>(VT_U64, 0);
+ }
+ bool mutate_u64(uint64_t _u64 = 0) {
+ return SetField<uint64_t>(VT_U64, _u64, 0);
+ }
+ float f32() const {
+ return GetField<float>(VT_F32, 0.0f);
+ }
+ bool mutate_f32(float _f32 = 0.0f) {
+ return SetField<float>(VT_F32, _f32, 0.0f);
+ }
+ double f64() const {
+ return GetField<double>(VT_F64, 0.0);
+ }
+ bool mutate_f64(double _f64 = 0.0) {
+ return SetField<double>(VT_F64, _f64, 0.0);
+ }
+ const flatbuffers::Vector<int8_t> *v8() const {
+ return GetPointer<const flatbuffers::Vector<int8_t> *>(VT_V8);
+ }
+ flatbuffers::Vector<int8_t> *mutable_v8() {
+ return GetPointer<flatbuffers::Vector<int8_t> *>(VT_V8);
+ }
+ const flatbuffers::Vector<double> *vf64() const {
+ return GetPointer<const flatbuffers::Vector<double> *>(VT_VF64);
+ }
+ flatbuffers::Vector<double> *mutable_vf64() {
+ return GetPointer<flatbuffers::Vector<double> *>(VT_VF64);
+ }
+ bool Verify(flatbuffers::Verifier &verifier) const {
+ return VerifyTableStart(verifier) &&
+ VerifyField<int8_t>(verifier, VT_I8, 1) &&
+ VerifyField<uint8_t>(verifier, VT_U8, 1) &&
+ VerifyField<int16_t>(verifier, VT_I16, 2) &&
+ VerifyField<uint16_t>(verifier, VT_U16, 2) &&
+ VerifyField<int32_t>(verifier, VT_I32, 4) &&
+ VerifyField<uint32_t>(verifier, VT_U32, 4) &&
+ VerifyField<int64_t>(verifier, VT_I64, 8) &&
+ VerifyField<uint64_t>(verifier, VT_U64, 8) &&
+ VerifyField<float>(verifier, VT_F32, 4) &&
+ VerifyField<double>(verifier, VT_F64, 8) &&
+ VerifyOffset(verifier, VT_V8) &&
+ verifier.VerifyVector(v8()) &&
+ VerifyOffset(verifier, VT_VF64) &&
+ verifier.VerifyVector(vf64()) &&
+ verifier.EndTable();
+ }
+ TypeAliasesT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ void UnPackTo(TypeAliasesT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ static flatbuffers::Offset<TypeAliases> Pack(flatbuffers::FlatBufferBuilder &_fbb, const TypeAliasesT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+};
+
+struct TypeAliasesBuilder {
+ typedef TypeAliases Table;
+ flatbuffers::FlatBufferBuilder &fbb_;
+ flatbuffers::uoffset_t start_;
+ void add_i8(int8_t i8) {
+ fbb_.AddElement<int8_t>(TypeAliases::VT_I8, i8, 0);
+ }
+ void add_u8(uint8_t u8) {
+ fbb_.AddElement<uint8_t>(TypeAliases::VT_U8, u8, 0);
+ }
+ void add_i16(int16_t i16) {
+ fbb_.AddElement<int16_t>(TypeAliases::VT_I16, i16, 0);
+ }
+ void add_u16(uint16_t u16) {
+ fbb_.AddElement<uint16_t>(TypeAliases::VT_U16, u16, 0);
+ }
+ void add_i32(int32_t i32) {
+ fbb_.AddElement<int32_t>(TypeAliases::VT_I32, i32, 0);
+ }
+ void add_u32(uint32_t u32) {
+ fbb_.AddElement<uint32_t>(TypeAliases::VT_U32, u32, 0);
+ }
+ void add_i64(int64_t i64) {
+ fbb_.AddElement<int64_t>(TypeAliases::VT_I64, i64, 0);
+ }
+ void add_u64(uint64_t u64) {
+ fbb_.AddElement<uint64_t>(TypeAliases::VT_U64, u64, 0);
+ }
+ void add_f32(float f32) {
+ fbb_.AddElement<float>(TypeAliases::VT_F32, f32, 0.0f);
+ }
+ void add_f64(double f64) {
+ fbb_.AddElement<double>(TypeAliases::VT_F64, f64, 0.0);
+ }
+ void add_v8(flatbuffers::Offset<flatbuffers::Vector<int8_t>> v8) {
+ fbb_.AddOffset(TypeAliases::VT_V8, v8);
+ }
+ void add_vf64(flatbuffers::Offset<flatbuffers::Vector<double>> vf64) {
+ fbb_.AddOffset(TypeAliases::VT_VF64, vf64);
+ }
+ explicit TypeAliasesBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
+ flatbuffers::Offset<TypeAliases> Finish() {
+ const auto end = fbb_.EndTable(start_);
+ auto o = flatbuffers::Offset<TypeAliases>(end);
+ return o;
+ }
+};
+
+inline flatbuffers::Offset<TypeAliases> CreateTypeAliases(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ int8_t i8 = 0,
+ uint8_t u8 = 0,
+ int16_t i16 = 0,
+ uint16_t u16 = 0,
+ int32_t i32 = 0,
+ uint32_t u32 = 0,
+ int64_t i64 = 0,
+ uint64_t u64 = 0,
+ float f32 = 0.0f,
+ double f64 = 0.0,
+ flatbuffers::Offset<flatbuffers::Vector<int8_t>> v8 = 0,
+ flatbuffers::Offset<flatbuffers::Vector<double>> vf64 = 0) {
+ TypeAliasesBuilder builder_(_fbb);
+ builder_.add_f64(f64);
+ builder_.add_u64(u64);
+ builder_.add_i64(i64);
+ builder_.add_vf64(vf64);
+ builder_.add_v8(v8);
+ builder_.add_f32(f32);
+ builder_.add_u32(u32);
+ builder_.add_i32(i32);
+ builder_.add_u16(u16);
+ builder_.add_i16(i16);
+ builder_.add_u8(u8);
+ builder_.add_i8(i8);
+ return builder_.Finish();
+}
+
+inline flatbuffers::Offset<TypeAliases> CreateTypeAliasesDirect(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ int8_t i8 = 0,
+ uint8_t u8 = 0,
+ int16_t i16 = 0,
+ uint16_t u16 = 0,
+ int32_t i32 = 0,
+ uint32_t u32 = 0,
+ int64_t i64 = 0,
+ uint64_t u64 = 0,
+ float f32 = 0.0f,
+ double f64 = 0.0,
+ const std::vector<int8_t> *v8 = nullptr,
+ const std::vector<double> *vf64 = nullptr) {
+ auto v8__ = v8 ? _fbb.CreateVector<int8_t>(*v8) : 0;
+ auto vf64__ = vf64 ? _fbb.CreateVector<double>(*vf64) : 0;
+ return MyGame::Example::CreateTypeAliases(
+ _fbb,
+ i8,
+ u8,
+ i16,
+ u16,
+ i32,
+ u32,
+ i64,
+ u64,
+ f32,
+ f64,
+ v8__,
+ vf64__);
+}
+
+flatbuffers::Offset<TypeAliases> CreateTypeAliases(flatbuffers::FlatBufferBuilder &_fbb, const TypeAliasesT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+
+} // namespace Example
+
+
+inline bool operator==(const InParentNamespaceT &, const InParentNamespaceT &) {
+ return true;
+}
+
+inline bool operator!=(const InParentNamespaceT &lhs, const InParentNamespaceT &rhs) {
+ return !(lhs == rhs);
+}
+
+
+inline InParentNamespaceT *InParentNamespace::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
+ auto _o = std::unique_ptr<InParentNamespaceT>(new InParentNamespaceT());
+ UnPackTo(_o.get(), _resolver);
+ return _o.release();
+}
+
+inline void InParentNamespace::UnPackTo(InParentNamespaceT *_o, const flatbuffers::resolver_function_t *_resolver) const {
+ (void)_o;
+ (void)_resolver;
+}
+
+inline flatbuffers::Offset<InParentNamespace> InParentNamespace::Pack(flatbuffers::FlatBufferBuilder &_fbb, const InParentNamespaceT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
+ return CreateInParentNamespace(_fbb, _o, _rehasher);
+}
+
+inline flatbuffers::Offset<InParentNamespace> CreateInParentNamespace(flatbuffers::FlatBufferBuilder &_fbb, const InParentNamespaceT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
+ (void)_rehasher;
+ (void)_o;
+ struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const InParentNamespaceT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
+ return MyGame::CreateInParentNamespace(
+ _fbb);
+}
+
+namespace Example2 {
+
+
+inline bool operator==(const MonsterT &, const MonsterT &) {
+ return true;
+}
+
+inline bool operator!=(const MonsterT &lhs, const MonsterT &rhs) {
+ return !(lhs == rhs);
+}
+
+
+inline MonsterT *Monster::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
+ auto _o = std::unique_ptr<MonsterT>(new MonsterT());
+ UnPackTo(_o.get(), _resolver);
+ return _o.release();
+}
+
+inline void Monster::UnPackTo(MonsterT *_o, const flatbuffers::resolver_function_t *_resolver) const {
+ (void)_o;
+ (void)_resolver;
+}
+
+inline flatbuffers::Offset<Monster> Monster::Pack(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
+ return CreateMonster(_fbb, _o, _rehasher);
+}
+
+inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
+ (void)_rehasher;
+ (void)_o;
+ struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const MonsterT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
+ return MyGame::Example2::CreateMonster(
+ _fbb);
+}
+
+} // namespace Example2
+
+namespace Example {
+
+
+inline bool operator==(const TestSimpleTableWithEnumT &lhs, const TestSimpleTableWithEnumT &rhs) {
+ return
+ (lhs.color == rhs.color);
+}
+
+inline bool operator!=(const TestSimpleTableWithEnumT &lhs, const TestSimpleTableWithEnumT &rhs) {
+ return !(lhs == rhs);
+}
+
+
+inline TestSimpleTableWithEnumT *TestSimpleTableWithEnum::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
+ auto _o = std::unique_ptr<TestSimpleTableWithEnumT>(new TestSimpleTableWithEnumT());
+ UnPackTo(_o.get(), _resolver);
+ return _o.release();
+}
+
+inline void TestSimpleTableWithEnum::UnPackTo(TestSimpleTableWithEnumT *_o, const flatbuffers::resolver_function_t *_resolver) const {
+ (void)_o;
+ (void)_resolver;
+ { auto _e = color(); _o->color = _e; }
+}
+
+inline flatbuffers::Offset<TestSimpleTableWithEnum> TestSimpleTableWithEnum::Pack(flatbuffers::FlatBufferBuilder &_fbb, const TestSimpleTableWithEnumT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
+ return CreateTestSimpleTableWithEnum(_fbb, _o, _rehasher);
+}
+
+inline flatbuffers::Offset<TestSimpleTableWithEnum> CreateTestSimpleTableWithEnum(flatbuffers::FlatBufferBuilder &_fbb, const TestSimpleTableWithEnumT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
+ (void)_rehasher;
+ (void)_o;
+ struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const TestSimpleTableWithEnumT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
+ auto _color = _o->color;
+ return MyGame::Example::CreateTestSimpleTableWithEnum(
+ _fbb,
+ _color);
+}
+
+
+inline bool operator==(const StatT &lhs, const StatT &rhs) {
+ return
+ (lhs.id == rhs.id) &&
+ (lhs.val == rhs.val) &&
+ (lhs.count == rhs.count);
+}
+
+inline bool operator!=(const StatT &lhs, const StatT &rhs) {
+ return !(lhs == rhs);
+}
+
+
+inline StatT *Stat::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
+ auto _o = std::unique_ptr<StatT>(new StatT());
+ UnPackTo(_o.get(), _resolver);
+ return _o.release();
+}
+
+inline void Stat::UnPackTo(StatT *_o, const flatbuffers::resolver_function_t *_resolver) const {
+ (void)_o;
+ (void)_resolver;
+ { auto _e = id(); if (_e) _o->id = _e->str(); }
+ { auto _e = val(); _o->val = _e; }
+ { auto _e = count(); _o->count = _e; }
+}
+
+inline flatbuffers::Offset<Stat> Stat::Pack(flatbuffers::FlatBufferBuilder &_fbb, const StatT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
+ return CreateStat(_fbb, _o, _rehasher);
+}
+
+inline flatbuffers::Offset<Stat> CreateStat(flatbuffers::FlatBufferBuilder &_fbb, const StatT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
+ (void)_rehasher;
+ (void)_o;
+ struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const StatT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
+ auto _id = _o->id.empty() ? 0 : _fbb.CreateString(_o->id);
+ auto _val = _o->val;
+ auto _count = _o->count;
+ return MyGame::Example::CreateStat(
+ _fbb,
+ _id,
+ _val,
+ _count);
+}
+
+
+inline bool operator==(const ReferrableT &lhs, const ReferrableT &rhs) {
+ return
+ (lhs.id == rhs.id);
+}
+
+inline bool operator!=(const ReferrableT &lhs, const ReferrableT &rhs) {
+ return !(lhs == rhs);
+}
+
+
+inline ReferrableT *Referrable::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
+ auto _o = std::unique_ptr<ReferrableT>(new ReferrableT());
+ UnPackTo(_o.get(), _resolver);
+ return _o.release();
+}
+
+inline void Referrable::UnPackTo(ReferrableT *_o, const flatbuffers::resolver_function_t *_resolver) const {
+ (void)_o;
+ (void)_resolver;
+ { auto _e = id(); _o->id = _e; }
+}
+
+inline flatbuffers::Offset<Referrable> Referrable::Pack(flatbuffers::FlatBufferBuilder &_fbb, const ReferrableT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
+ return CreateReferrable(_fbb, _o, _rehasher);
+}
+
+inline flatbuffers::Offset<Referrable> CreateReferrable(flatbuffers::FlatBufferBuilder &_fbb, const ReferrableT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
+ (void)_rehasher;
+ (void)_o;
+ struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const ReferrableT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
+ auto _id = _o->id;
+ return MyGame::Example::CreateReferrable(
+ _fbb,
+ _id);
+}
+
+
+inline bool operator==(const MonsterT &lhs, const MonsterT &rhs) {
+ return
+ ((lhs.pos == rhs.pos) || (lhs.pos && rhs.pos && *lhs.pos == *rhs.pos)) &&
+ (lhs.mana == rhs.mana) &&
+ (lhs.hp == rhs.hp) &&
+ (lhs.name == rhs.name) &&
+ (lhs.inventory == rhs.inventory) &&
+ (lhs.color == rhs.color) &&
+ (lhs.test == rhs.test) &&
+ (lhs.test4 == rhs.test4) &&
+ (lhs.testarrayofstring == rhs.testarrayofstring) &&
+ (lhs.testarrayoftables.size() == rhs.testarrayoftables.size() && std::equal(lhs.testarrayoftables.cbegin(), lhs.testarrayoftables.cend(), rhs.testarrayoftables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::MonsterT> const &a, flatbuffers::unique_ptr<MyGame::Example::MonsterT> const &b) { return (a == b) || (a && b && *a == *b); })) &&
+ ((lhs.enemy == rhs.enemy) || (lhs.enemy && rhs.enemy && *lhs.enemy == *rhs.enemy)) &&
+ (lhs.testnestedflatbuffer == rhs.testnestedflatbuffer) &&
+ ((lhs.testempty == rhs.testempty) || (lhs.testempty && rhs.testempty && *lhs.testempty == *rhs.testempty)) &&
+ (lhs.testbool == rhs.testbool) &&
+ (lhs.testhashs32_fnv1 == rhs.testhashs32_fnv1) &&
+ (lhs.testhashu32_fnv1 == rhs.testhashu32_fnv1) &&
+ (lhs.testhashs64_fnv1 == rhs.testhashs64_fnv1) &&
+ (lhs.testhashu64_fnv1 == rhs.testhashu64_fnv1) &&
+ (lhs.testhashs32_fnv1a == rhs.testhashs32_fnv1a) &&
+ (lhs.testhashu32_fnv1a == rhs.testhashu32_fnv1a) &&
+ (lhs.testhashs64_fnv1a == rhs.testhashs64_fnv1a) &&
+ (lhs.testhashu64_fnv1a == rhs.testhashu64_fnv1a) &&
+ (lhs.testarrayofbools == rhs.testarrayofbools) &&
+ (lhs.testf == rhs.testf) &&
+ (lhs.testf2 == rhs.testf2) &&
+ (lhs.testf3 == rhs.testf3) &&
+ (lhs.testarrayofstring2 == rhs.testarrayofstring2) &&
+ (lhs.testarrayofsortedstruct == rhs.testarrayofsortedstruct) &&
+ (lhs.flex == rhs.flex) &&
+ (lhs.test5 == rhs.test5) &&
+ (lhs.vector_of_longs == rhs.vector_of_longs) &&
+ (lhs.vector_of_doubles == rhs.vector_of_doubles) &&
+ ((lhs.parent_namespace_test == rhs.parent_namespace_test) || (lhs.parent_namespace_test && rhs.parent_namespace_test && *lhs.parent_namespace_test == *rhs.parent_namespace_test)) &&
+ (lhs.vector_of_referrables.size() == rhs.vector_of_referrables.size() && std::equal(lhs.vector_of_referrables.cbegin(), lhs.vector_of_referrables.cend(), rhs.vector_of_referrables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &a, flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &b) { return (a == b) || (a && b && *a == *b); })) &&
+ (lhs.single_weak_reference == rhs.single_weak_reference) &&
+ (lhs.vector_of_weak_references == rhs.vector_of_weak_references) &&
+ (lhs.vector_of_strong_referrables.size() == rhs.vector_of_strong_referrables.size() && std::equal(lhs.vector_of_strong_referrables.cbegin(), lhs.vector_of_strong_referrables.cend(), rhs.vector_of_strong_referrables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &a, flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &b) { return (a == b) || (a && b && *a == *b); })) &&
+ (lhs.co_owning_reference == rhs.co_owning_reference) &&
+ (lhs.vector_of_co_owning_references == rhs.vector_of_co_owning_references) &&
+ (lhs.non_owning_reference == rhs.non_owning_reference) &&
+ (lhs.vector_of_non_owning_references == rhs.vector_of_non_owning_references) &&
+ (lhs.any_unique == rhs.any_unique) &&
+ (lhs.any_ambiguous == rhs.any_ambiguous) &&
+ (lhs.vector_of_enums == rhs.vector_of_enums) &&
+ (lhs.signed_enum == rhs.signed_enum) &&
+ (lhs.testrequirednestedflatbuffer == rhs.testrequirednestedflatbuffer) &&
+ (lhs.scalar_key_sorted_tables.size() == rhs.scalar_key_sorted_tables.size() && std::equal(lhs.scalar_key_sorted_tables.cbegin(), lhs.scalar_key_sorted_tables.cend(), rhs.scalar_key_sorted_tables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::StatT> const &a, flatbuffers::unique_ptr<MyGame::Example::StatT> const &b) { return (a == b) || (a && b && *a == *b); })) &&
+ (lhs.native_inline == rhs.native_inline) &&
+ (lhs.long_enum_non_enum_default == rhs.long_enum_non_enum_default) &&
+ (lhs.long_enum_normal_default == rhs.long_enum_normal_default);
+}
+
+inline bool operator!=(const MonsterT &lhs, const MonsterT &rhs) {
+ return !(lhs == rhs);
+}
+
+
+inline MonsterT::MonsterT(const MonsterT &o)
+ : pos((o.pos) ? new MyGame::Example::Vec3(*o.pos) : nullptr),
+ mana(o.mana),
+ hp(o.hp),
+ name(o.name),
+ inventory(o.inventory),
+ color(o.color),
+ test(o.test),
+ test4(o.test4),
+ testarrayofstring(o.testarrayofstring),
+ enemy((o.enemy) ? new MyGame::Example::MonsterT(*o.enemy) : nullptr),
+ testnestedflatbuffer(o.testnestedflatbuffer),
+ testempty((o.testempty) ? new MyGame::Example::StatT(*o.testempty) : nullptr),
+ testbool(o.testbool),
+ testhashs32_fnv1(o.testhashs32_fnv1),
+ testhashu32_fnv1(o.testhashu32_fnv1),
+ testhashs64_fnv1(o.testhashs64_fnv1),
+ testhashu64_fnv1(o.testhashu64_fnv1),
+ testhashs32_fnv1a(o.testhashs32_fnv1a),
+ testhashu32_fnv1a(o.testhashu32_fnv1a),
+ testhashs64_fnv1a(o.testhashs64_fnv1a),
+ testhashu64_fnv1a(o.testhashu64_fnv1a),
+ testarrayofbools(o.testarrayofbools),
+ testf(o.testf),
+ testf2(o.testf2),
+ testf3(o.testf3),
+ testarrayofstring2(o.testarrayofstring2),
+ testarrayofsortedstruct(o.testarrayofsortedstruct),
+ flex(o.flex),
+ test5(o.test5),
+ vector_of_longs(o.vector_of_longs),
+ vector_of_doubles(o.vector_of_doubles),
+ parent_namespace_test((o.parent_namespace_test) ? new MyGame::InParentNamespaceT(*o.parent_namespace_test) : nullptr),
+ single_weak_reference(o.single_weak_reference),
+ vector_of_weak_references(o.vector_of_weak_references),
+ co_owning_reference(o.co_owning_reference),
+ non_owning_reference(o.non_owning_reference),
+ vector_of_non_owning_references(o.vector_of_non_owning_references),
+ any_unique(o.any_unique),
+ any_ambiguous(o.any_ambiguous),
+ vector_of_enums(o.vector_of_enums),
+ signed_enum(o.signed_enum),
+ testrequirednestedflatbuffer(o.testrequirednestedflatbuffer),
+ native_inline(o.native_inline),
+ long_enum_non_enum_default(o.long_enum_non_enum_default),
+ long_enum_normal_default(o.long_enum_normal_default) {
+ testarrayoftables.reserve(o.testarrayoftables.size());
+ for (const auto &testarrayoftables_ : o.testarrayoftables) { testarrayoftables.emplace_back((testarrayoftables_) ? new MyGame::Example::MonsterT(*testarrayoftables_) : nullptr); }
+ vector_of_referrables.reserve(o.vector_of_referrables.size());
+ for (const auto &vector_of_referrables_ : o.vector_of_referrables) { vector_of_referrables.emplace_back((vector_of_referrables_) ? new MyGame::Example::ReferrableT(*vector_of_referrables_) : nullptr); }
+ vector_of_strong_referrables.reserve(o.vector_of_strong_referrables.size());
+ for (const auto &vector_of_strong_referrables_ : o.vector_of_strong_referrables) { vector_of_strong_referrables.emplace_back((vector_of_strong_referrables_) ? new MyGame::Example::ReferrableT(*vector_of_strong_referrables_) : nullptr); }
+ vector_of_co_owning_references.reserve(o.vector_of_co_owning_references.size());
+ for (const auto &vector_of_co_owning_references_ : o.vector_of_co_owning_references) { vector_of_co_owning_references.emplace_back((vector_of_co_owning_references_) ? new ReferrableT(*vector_of_co_owning_references_) : nullptr); }
+ scalar_key_sorted_tables.reserve(o.scalar_key_sorted_tables.size());
+ for (const auto &scalar_key_sorted_tables_ : o.scalar_key_sorted_tables) { scalar_key_sorted_tables.emplace_back((scalar_key_sorted_tables_) ? new MyGame::Example::StatT(*scalar_key_sorted_tables_) : nullptr); }
+}
+
+inline MonsterT &MonsterT::operator=(MonsterT o) FLATBUFFERS_NOEXCEPT {
+ std::swap(pos, o.pos);
+ std::swap(mana, o.mana);
+ std::swap(hp, o.hp);
+ std::swap(name, o.name);
+ std::swap(inventory, o.inventory);
+ std::swap(color, o.color);
+ std::swap(test, o.test);
+ std::swap(test4, o.test4);
+ std::swap(testarrayofstring, o.testarrayofstring);
+ std::swap(testarrayoftables, o.testarrayoftables);
+ std::swap(enemy, o.enemy);
+ std::swap(testnestedflatbuffer, o.testnestedflatbuffer);
+ std::swap(testempty, o.testempty);
+ std::swap(testbool, o.testbool);
+ std::swap(testhashs32_fnv1, o.testhashs32_fnv1);
+ std::swap(testhashu32_fnv1, o.testhashu32_fnv1);
+ std::swap(testhashs64_fnv1, o.testhashs64_fnv1);
+ std::swap(testhashu64_fnv1, o.testhashu64_fnv1);
+ std::swap(testhashs32_fnv1a, o.testhashs32_fnv1a);
+ std::swap(testhashu32_fnv1a, o.testhashu32_fnv1a);
+ std::swap(testhashs64_fnv1a, o.testhashs64_fnv1a);
+ std::swap(testhashu64_fnv1a, o.testhashu64_fnv1a);
+ std::swap(testarrayofbools, o.testarrayofbools);
+ std::swap(testf, o.testf);
+ std::swap(testf2, o.testf2);
+ std::swap(testf3, o.testf3);
+ std::swap(testarrayofstring2, o.testarrayofstring2);
+ std::swap(testarrayofsortedstruct, o.testarrayofsortedstruct);
+ std::swap(flex, o.flex);
+ std::swap(test5, o.test5);
+ std::swap(vector_of_longs, o.vector_of_longs);
+ std::swap(vector_of_doubles, o.vector_of_doubles);
+ std::swap(parent_namespace_test, o.parent_namespace_test);
+ std::swap(vector_of_referrables, o.vector_of_referrables);
+ std::swap(single_weak_reference, o.single_weak_reference);
+ std::swap(vector_of_weak_references, o.vector_of_weak_references);
+ std::swap(vector_of_strong_referrables, o.vector_of_strong_referrables);
+ std::swap(co_owning_reference, o.co_owning_reference);
+ std::swap(vector_of_co_owning_references, o.vector_of_co_owning_references);
+ std::swap(non_owning_reference, o.non_owning_reference);
+ std::swap(vector_of_non_owning_references, o.vector_of_non_owning_references);
+ std::swap(any_unique, o.any_unique);
+ std::swap(any_ambiguous, o.any_ambiguous);
+ std::swap(vector_of_enums, o.vector_of_enums);
+ std::swap(signed_enum, o.signed_enum);
+ std::swap(testrequirednestedflatbuffer, o.testrequirednestedflatbuffer);
+ std::swap(scalar_key_sorted_tables, o.scalar_key_sorted_tables);
+ std::swap(native_inline, o.native_inline);
+ std::swap(long_enum_non_enum_default, o.long_enum_non_enum_default);
+ std::swap(long_enum_normal_default, o.long_enum_normal_default);
+ return *this;
+}
+
+inline MonsterT *Monster::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
+ auto _o = std::unique_ptr<MonsterT>(new MonsterT());
+ UnPackTo(_o.get(), _resolver);
+ return _o.release();
+}
+
+inline void Monster::UnPackTo(MonsterT *_o, const flatbuffers::resolver_function_t *_resolver) const {
+ (void)_o;
+ (void)_resolver;
+ { auto _e = pos(); if (_e) _o->pos = flatbuffers::unique_ptr<MyGame::Example::Vec3>(new MyGame::Example::Vec3(*_e)); }
+ { auto _e = mana(); _o->mana = _e; }
+ { auto _e = hp(); _o->hp = _e; }
+ { auto _e = name(); if (_e) _o->name = _e->str(); }
+ { auto _e = inventory(); if (_e) { _o->inventory.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->inventory.begin()); } }
+ { auto _e = color(); _o->color = _e; }
+ { auto _e = test_type(); _o->test.type = _e; }
+ { auto _e = test(); if (_e) _o->test.value = MyGame::Example::AnyUnion::UnPack(_e, test_type(), _resolver); }
+ { auto _e = test4(); if (_e) { _o->test4.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->test4[_i] = *_e->Get(_i); } } else { _o->test4.resize(0); } }
+ { auto _e = testarrayofstring(); if (_e) { _o->testarrayofstring.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofstring[_i] = _e->Get(_i)->str(); } } else { _o->testarrayofstring.resize(0); } }
+ { auto _e = testarrayoftables(); if (_e) { _o->testarrayoftables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->testarrayoftables[_i]) { _e->Get(_i)->UnPackTo(_o->testarrayoftables[_i].get(), _resolver); } else { _o->testarrayoftables[_i] = flatbuffers::unique_ptr<MyGame::Example::MonsterT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->testarrayoftables.resize(0); } }
+ { auto _e = enemy(); if (_e) { if(_o->enemy) { _e->UnPackTo(_o->enemy.get(), _resolver); } else { _o->enemy = flatbuffers::unique_ptr<MyGame::Example::MonsterT>(_e->UnPack(_resolver)); } } else if (_o->enemy) { _o->enemy.reset(); } }
+ { auto _e = testnestedflatbuffer(); if (_e) { _o->testnestedflatbuffer.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->testnestedflatbuffer.begin()); } }
+ { auto _e = testempty(); if (_e) { if(_o->testempty) { _e->UnPackTo(_o->testempty.get(), _resolver); } else { _o->testempty = flatbuffers::unique_ptr<MyGame::Example::StatT>(_e->UnPack(_resolver)); } } else if (_o->testempty) { _o->testempty.reset(); } }
+ { auto _e = testbool(); _o->testbool = _e; }
+ { auto _e = testhashs32_fnv1(); _o->testhashs32_fnv1 = _e; }
+ { auto _e = testhashu32_fnv1(); _o->testhashu32_fnv1 = _e; }
+ { auto _e = testhashs64_fnv1(); _o->testhashs64_fnv1 = _e; }
+ { auto _e = testhashu64_fnv1(); _o->testhashu64_fnv1 = _e; }
+ { auto _e = testhashs32_fnv1a(); _o->testhashs32_fnv1a = _e; }
+ { auto _e = testhashu32_fnv1a(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->testhashu32_fnv1a), static_cast<flatbuffers::hash_value_t>(_e)); else _o->testhashu32_fnv1a = nullptr; }
+ { auto _e = testhashs64_fnv1a(); _o->testhashs64_fnv1a = _e; }
+ { auto _e = testhashu64_fnv1a(); _o->testhashu64_fnv1a = _e; }
+ { auto _e = testarrayofbools(); if (_e) { _o->testarrayofbools.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofbools[_i] = _e->Get(_i) != 0; } } else { _o->testarrayofbools.resize(0); } }
+ { auto _e = testf(); _o->testf = _e; }
+ { auto _e = testf2(); _o->testf2 = _e; }
+ { auto _e = testf3(); _o->testf3 = _e; }
+ { auto _e = testarrayofstring2(); if (_e) { _o->testarrayofstring2.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofstring2[_i] = _e->Get(_i)->str(); } } else { _o->testarrayofstring2.resize(0); } }
+ { auto _e = testarrayofsortedstruct(); if (_e) { _o->testarrayofsortedstruct.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofsortedstruct[_i] = *_e->Get(_i); } } else { _o->testarrayofsortedstruct.resize(0); } }
+ { auto _e = flex(); if (_e) { _o->flex.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->flex.begin()); } }
+ { auto _e = test5(); if (_e) { _o->test5.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->test5[_i] = *_e->Get(_i); } } else { _o->test5.resize(0); } }
+ { auto _e = vector_of_longs(); if (_e) { _o->vector_of_longs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_longs[_i] = _e->Get(_i); } } else { _o->vector_of_longs.resize(0); } }
+ { auto _e = vector_of_doubles(); if (_e) { _o->vector_of_doubles.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_doubles[_i] = _e->Get(_i); } } else { _o->vector_of_doubles.resize(0); } }
+ { auto _e = parent_namespace_test(); if (_e) { if(_o->parent_namespace_test) { _e->UnPackTo(_o->parent_namespace_test.get(), _resolver); } else { _o->parent_namespace_test = flatbuffers::unique_ptr<MyGame::InParentNamespaceT>(_e->UnPack(_resolver)); } } else if (_o->parent_namespace_test) { _o->parent_namespace_test.reset(); } }
+ { auto _e = vector_of_referrables(); if (_e) { _o->vector_of_referrables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_referrables[_i].get(), _resolver); } else { _o->vector_of_referrables[_i] = flatbuffers::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->vector_of_referrables.resize(0); } }
+ { auto _e = single_weak_reference(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->single_weak_reference), static_cast<flatbuffers::hash_value_t>(_e)); else _o->single_weak_reference = nullptr; }
+ { auto _e = vector_of_weak_references(); if (_e) { _o->vector_of_weak_references.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { /*vector resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_weak_references[_i]), static_cast<flatbuffers::hash_value_t>(_e->Get(_i))); else _o->vector_of_weak_references[_i] = nullptr; } } else { _o->vector_of_weak_references.resize(0); } }
+ { auto _e = vector_of_strong_referrables(); if (_e) { _o->vector_of_strong_referrables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_strong_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_strong_referrables[_i].get(), _resolver); } else { _o->vector_of_strong_referrables[_i] = flatbuffers::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->vector_of_strong_referrables.resize(0); } }
+ { auto _e = co_owning_reference(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->co_owning_reference), static_cast<flatbuffers::hash_value_t>(_e)); else _o->co_owning_reference = nullptr; }
+ { auto _e = vector_of_co_owning_references(); if (_e) { _o->vector_of_co_owning_references.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { /*vector resolver, default_ptr_type*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_co_owning_references[_i]), static_cast<flatbuffers::hash_value_t>(_e->Get(_i)));/* else do nothing */; } } else { _o->vector_of_co_owning_references.resize(0); } }
+ { auto _e = non_owning_reference(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->non_owning_reference), static_cast<flatbuffers::hash_value_t>(_e)); else _o->non_owning_reference = nullptr; }
+ { auto _e = vector_of_non_owning_references(); if (_e) { _o->vector_of_non_owning_references.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { /*vector resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_non_owning_references[_i]), static_cast<flatbuffers::hash_value_t>(_e->Get(_i))); else _o->vector_of_non_owning_references[_i] = nullptr; } } else { _o->vector_of_non_owning_references.resize(0); } }
+ { auto _e = any_unique_type(); _o->any_unique.type = _e; }
+ { auto _e = any_unique(); if (_e) _o->any_unique.value = MyGame::Example::AnyUniqueAliasesUnion::UnPack(_e, any_unique_type(), _resolver); }
+ { auto _e = any_ambiguous_type(); _o->any_ambiguous.type = _e; }
+ { auto _e = any_ambiguous(); if (_e) _o->any_ambiguous.value = MyGame::Example::AnyAmbiguousAliasesUnion::UnPack(_e, any_ambiguous_type(), _resolver); }
+ { auto _e = vector_of_enums(); if (_e) { _o->vector_of_enums.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_enums[_i] = static_cast<MyGame::Example::Color>(_e->Get(_i)); } } else { _o->vector_of_enums.resize(0); } }
+ { auto _e = signed_enum(); _o->signed_enum = _e; }
+ { auto _e = testrequirednestedflatbuffer(); if (_e) { _o->testrequirednestedflatbuffer.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->testrequirednestedflatbuffer.begin()); } }
+ { auto _e = scalar_key_sorted_tables(); if (_e) { _o->scalar_key_sorted_tables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->scalar_key_sorted_tables[_i]) { _e->Get(_i)->UnPackTo(_o->scalar_key_sorted_tables[_i].get(), _resolver); } else { _o->scalar_key_sorted_tables[_i] = flatbuffers::unique_ptr<MyGame::Example::StatT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->scalar_key_sorted_tables.resize(0); } }
+ { auto _e = native_inline(); if (_e) _o->native_inline = *_e; }
+ { auto _e = long_enum_non_enum_default(); _o->long_enum_non_enum_default = _e; }
+ { auto _e = long_enum_normal_default(); _o->long_enum_normal_default = _e; }
+}
+
+inline flatbuffers::Offset<Monster> Monster::Pack(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
+ return CreateMonster(_fbb, _o, _rehasher);
+}
+
+inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
+ (void)_rehasher;
+ (void)_o;
+ struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const MonsterT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
+ auto _pos = _o->pos ? _o->pos.get() : nullptr;
+ auto _mana = _o->mana;
+ auto _hp = _o->hp;
+ auto _name = _fbb.CreateString(_o->name);
+ auto _inventory = _o->inventory.size() ? _fbb.CreateVector(_o->inventory) : 0;
+ auto _color = _o->color;
+ auto _test_type = _o->test.type;
+ auto _test = _o->test.Pack(_fbb);
+ auto _test4 = _o->test4.size() ? _fbb.CreateVectorOfStructs(_o->test4) : 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 _enemy = _o->enemy ? CreateMonster(_fbb, _o->enemy.get(), _rehasher) : 0;
+ auto _testnestedflatbuffer = _o->testnestedflatbuffer.size() ? _fbb.CreateVector(_o->testnestedflatbuffer) : 0;
+ auto _testempty = _o->testempty ? CreateStat(_fbb, _o->testempty.get(), _rehasher) : 0;
+ auto _testbool = _o->testbool;
+ auto _testhashs32_fnv1 = _o->testhashs32_fnv1;
+ auto _testhashu32_fnv1 = _o->testhashu32_fnv1;
+ auto _testhashs64_fnv1 = _o->testhashs64_fnv1;
+ auto _testhashu64_fnv1 = _o->testhashu64_fnv1;
+ auto _testhashs32_fnv1a = _o->testhashs32_fnv1a;
+ auto _testhashu32_fnv1a = _rehasher ? static_cast<uint32_t>((*_rehasher)(_o->testhashu32_fnv1a)) : 0;
+ auto _testhashs64_fnv1a = _o->testhashs64_fnv1a;
+ auto _testhashu64_fnv1a = _o->testhashu64_fnv1a;
+ auto _testarrayofbools = _o->testarrayofbools.size() ? _fbb.CreateVector(_o->testarrayofbools) : 0;
+ auto _testf = _o->testf;
+ auto _testf2 = _o->testf2;
+ auto _testf3 = _o->testf3;
+ auto _testarrayofstring2 = _o->testarrayofstring2.size() ? _fbb.CreateVectorOfStrings(_o->testarrayofstring2) : 0;
+ auto _testarrayofsortedstruct = _o->testarrayofsortedstruct.size() ? _fbb.CreateVectorOfStructs(_o->testarrayofsortedstruct) : 0;
+ auto _flex = _o->flex.size() ? _fbb.CreateVector(_o->flex) : 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_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 _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 _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_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 _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 _non_owning_reference = _rehasher ? static_cast<uint64_t>((*_rehasher)(_o->non_owning_reference)) : 0;
+ auto _vector_of_non_owning_references = _o->vector_of_non_owning_references.size() ? _fbb.CreateVector<uint64_t>(_o->vector_of_non_owning_references.size(), [](size_t i, _VectorArgs *__va) { return __va->__rehasher ? static_cast<uint64_t>((*__va->__rehasher)(__va->__o->vector_of_non_owning_references[i])) : 0; }, &_va ) : 0;
+ auto _any_unique_type = _o->any_unique.type;
+ auto _any_unique = _o->any_unique.Pack(_fbb);
+ auto _any_ambiguous_type = _o->any_ambiguous.type;
+ auto _any_ambiguous = _o->any_ambiguous.Pack(_fbb);
+ auto _vector_of_enums = _o->vector_of_enums.size() ? _fbb.CreateVectorScalarCast<uint8_t>(flatbuffers::data(_o->vector_of_enums), _o->vector_of_enums.size()) : 0;
+ auto _signed_enum = _o->signed_enum;
+ 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 _native_inline = &_o->native_inline;
+ auto _long_enum_non_enum_default = _o->long_enum_non_enum_default;
+ auto _long_enum_normal_default = _o->long_enum_normal_default;
+ return MyGame::Example::CreateMonster(
+ _fbb,
+ _pos,
+ _mana,
+ _hp,
+ _name,
+ _inventory,
+ _color,
+ _test_type,
+ _test,
+ _test4,
+ _testarrayofstring,
+ _testarrayoftables,
+ _enemy,
+ _testnestedflatbuffer,
+ _testempty,
+ _testbool,
+ _testhashs32_fnv1,
+ _testhashu32_fnv1,
+ _testhashs64_fnv1,
+ _testhashu64_fnv1,
+ _testhashs32_fnv1a,
+ _testhashu32_fnv1a,
+ _testhashs64_fnv1a,
+ _testhashu64_fnv1a,
+ _testarrayofbools,
+ _testf,
+ _testf2,
+ _testf3,
+ _testarrayofstring2,
+ _testarrayofsortedstruct,
+ _flex,
+ _test5,
+ _vector_of_longs,
+ _vector_of_doubles,
+ _parent_namespace_test,
+ _vector_of_referrables,
+ _single_weak_reference,
+ _vector_of_weak_references,
+ _vector_of_strong_referrables,
+ _co_owning_reference,
+ _vector_of_co_owning_references,
+ _non_owning_reference,
+ _vector_of_non_owning_references,
+ _any_unique_type,
+ _any_unique,
+ _any_ambiguous_type,
+ _any_ambiguous,
+ _vector_of_enums,
+ _signed_enum,
+ _testrequirednestedflatbuffer,
+ _scalar_key_sorted_tables,
+ _native_inline,
+ _long_enum_non_enum_default,
+ _long_enum_normal_default);
+}
+
+
+inline bool operator==(const TypeAliasesT &lhs, const TypeAliasesT &rhs) {
+ return
+ (lhs.i8 == rhs.i8) &&
+ (lhs.u8 == rhs.u8) &&
+ (lhs.i16 == rhs.i16) &&
+ (lhs.u16 == rhs.u16) &&
+ (lhs.i32 == rhs.i32) &&
+ (lhs.u32 == rhs.u32) &&
+ (lhs.i64 == rhs.i64) &&
+ (lhs.u64 == rhs.u64) &&
+ (lhs.f32 == rhs.f32) &&
+ (lhs.f64 == rhs.f64) &&
+ (lhs.v8 == rhs.v8) &&
+ (lhs.vf64 == rhs.vf64);
+}
+
+inline bool operator!=(const TypeAliasesT &lhs, const TypeAliasesT &rhs) {
+ return !(lhs == rhs);
+}
+
+
+inline TypeAliasesT *TypeAliases::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
+ auto _o = std::unique_ptr<TypeAliasesT>(new TypeAliasesT());
+ UnPackTo(_o.get(), _resolver);
+ return _o.release();
+}
+
+inline void TypeAliases::UnPackTo(TypeAliasesT *_o, const flatbuffers::resolver_function_t *_resolver) const {
+ (void)_o;
+ (void)_resolver;
+ { auto _e = i8(); _o->i8 = _e; }
+ { auto _e = u8(); _o->u8 = _e; }
+ { auto _e = i16(); _o->i16 = _e; }
+ { auto _e = u16(); _o->u16 = _e; }
+ { auto _e = i32(); _o->i32 = _e; }
+ { auto _e = u32(); _o->u32 = _e; }
+ { auto _e = i64(); _o->i64 = _e; }
+ { auto _e = u64(); _o->u64 = _e; }
+ { auto _e = f32(); _o->f32 = _e; }
+ { auto _e = f64(); _o->f64 = _e; }
+ { auto _e = v8(); if (_e) { _o->v8.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->v8.begin()); } }
+ { auto _e = vf64(); if (_e) { _o->vf64.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vf64[_i] = _e->Get(_i); } } else { _o->vf64.resize(0); } }
+}
+
+inline flatbuffers::Offset<TypeAliases> TypeAliases::Pack(flatbuffers::FlatBufferBuilder &_fbb, const TypeAliasesT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
+ return CreateTypeAliases(_fbb, _o, _rehasher);
+}
+
+inline flatbuffers::Offset<TypeAliases> CreateTypeAliases(flatbuffers::FlatBufferBuilder &_fbb, const TypeAliasesT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
+ (void)_rehasher;
+ (void)_o;
+ struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const TypeAliasesT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
+ auto _i8 = _o->i8;
+ auto _u8 = _o->u8;
+ auto _i16 = _o->i16;
+ auto _u16 = _o->u16;
+ auto _i32 = _o->i32;
+ auto _u32 = _o->u32;
+ auto _i64 = _o->i64;
+ auto _u64 = _o->u64;
+ auto _f32 = _o->f32;
+ auto _f64 = _o->f64;
+ auto _v8 = _o->v8.size() ? _fbb.CreateVector(_o->v8) : 0;
+ auto _vf64 = _o->vf64.size() ? _fbb.CreateVector(_o->vf64) : 0;
+ return MyGame::Example::CreateTypeAliases(
+ _fbb,
+ _i8,
+ _u8,
+ _i16,
+ _u16,
+ _i32,
+ _u32,
+ _i64,
+ _u64,
+ _f32,
+ _f64,
+ _v8,
+ _vf64);
+}
+
+inline bool VerifyAny(flatbuffers::Verifier &verifier, const void *obj, Any type) {
+ switch (type) {
+ case Any_NONE: {
+ return true;
+ }
+ case Any_Monster: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ case Any_TestSimpleTableWithEnum: {
+ auto ptr = reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnum *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ case Any_MyGame_Example2_Monster: {
+ auto ptr = reinterpret_cast<const MyGame::Example2::Monster *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ default: return true;
+ }
+}
+
+inline bool VerifyAnyVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types) {
+ if (!values || !types) return !values && !types;
+ if (values->size() != types->size()) return false;
+ for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
+ if (!VerifyAny(
+ verifier, values->Get(i), types->GetEnum<Any>(i))) {
+ return false;
+ }
+ }
+ return true;
+}
+
+inline void *AnyUnion::UnPack(const void *obj, Any type, const flatbuffers::resolver_function_t *resolver) {
+ (void)resolver;
+ switch (type) {
+ case Any_Monster: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ case Any_TestSimpleTableWithEnum: {
+ auto ptr = reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnum *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ case Any_MyGame_Example2_Monster: {
+ auto ptr = reinterpret_cast<const MyGame::Example2::Monster *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ default: return nullptr;
+ }
+}
+
+inline flatbuffers::Offset<void> AnyUnion::Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher) const {
+ (void)_rehasher;
+ switch (type) {
+ case Any_Monster: {
+ auto ptr = reinterpret_cast<const MyGame::Example::MonsterT *>(value);
+ return CreateMonster(_fbb, ptr, _rehasher).Union();
+ }
+ case Any_TestSimpleTableWithEnum: {
+ auto ptr = reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnumT *>(value);
+ return CreateTestSimpleTableWithEnum(_fbb, ptr, _rehasher).Union();
+ }
+ case Any_MyGame_Example2_Monster: {
+ auto ptr = reinterpret_cast<const MyGame::Example2::MonsterT *>(value);
+ return CreateMonster(_fbb, ptr, _rehasher).Union();
+ }
+ default: return 0;
+ }
+}
+
+inline AnyUnion::AnyUnion(const AnyUnion &u) : type(u.type), value(nullptr) {
+ switch (type) {
+ case Any_Monster: {
+ value = new MyGame::Example::MonsterT(*reinterpret_cast<MyGame::Example::MonsterT *>(u.value));
+ break;
+ }
+ case Any_TestSimpleTableWithEnum: {
+ value = new MyGame::Example::TestSimpleTableWithEnumT(*reinterpret_cast<MyGame::Example::TestSimpleTableWithEnumT *>(u.value));
+ break;
+ }
+ case Any_MyGame_Example2_Monster: {
+ value = new MyGame::Example2::MonsterT(*reinterpret_cast<MyGame::Example2::MonsterT *>(u.value));
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+inline void AnyUnion::Reset() {
+ switch (type) {
+ case Any_Monster: {
+ auto ptr = reinterpret_cast<MyGame::Example::MonsterT *>(value);
+ delete ptr;
+ break;
+ }
+ case Any_TestSimpleTableWithEnum: {
+ auto ptr = reinterpret_cast<MyGame::Example::TestSimpleTableWithEnumT *>(value);
+ delete ptr;
+ break;
+ }
+ case Any_MyGame_Example2_Monster: {
+ auto ptr = reinterpret_cast<MyGame::Example2::MonsterT *>(value);
+ delete ptr;
+ break;
+ }
+ default: break;
+ }
+ value = nullptr;
+ type = Any_NONE;
+}
+
+inline bool VerifyAnyUniqueAliases(flatbuffers::Verifier &verifier, const void *obj, AnyUniqueAliases type) {
+ switch (type) {
+ case AnyUniqueAliases_NONE: {
+ return true;
+ }
+ case AnyUniqueAliases_M: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ case AnyUniqueAliases_TS: {
+ auto ptr = reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnum *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ case AnyUniqueAliases_M2: {
+ auto ptr = reinterpret_cast<const MyGame::Example2::Monster *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ default: return true;
+ }
+}
+
+inline bool VerifyAnyUniqueAliasesVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types) {
+ if (!values || !types) return !values && !types;
+ if (values->size() != types->size()) return false;
+ for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
+ if (!VerifyAnyUniqueAliases(
+ verifier, values->Get(i), types->GetEnum<AnyUniqueAliases>(i))) {
+ return false;
+ }
+ }
+ return true;
+}
+
+inline void *AnyUniqueAliasesUnion::UnPack(const void *obj, AnyUniqueAliases type, const flatbuffers::resolver_function_t *resolver) {
+ (void)resolver;
+ switch (type) {
+ case AnyUniqueAliases_M: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ case AnyUniqueAliases_TS: {
+ auto ptr = reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnum *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ case AnyUniqueAliases_M2: {
+ auto ptr = reinterpret_cast<const MyGame::Example2::Monster *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ default: return nullptr;
+ }
+}
+
+inline flatbuffers::Offset<void> AnyUniqueAliasesUnion::Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher) const {
+ (void)_rehasher;
+ switch (type) {
+ case AnyUniqueAliases_M: {
+ auto ptr = reinterpret_cast<const MyGame::Example::MonsterT *>(value);
+ return CreateMonster(_fbb, ptr, _rehasher).Union();
+ }
+ case AnyUniqueAliases_TS: {
+ auto ptr = reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnumT *>(value);
+ return CreateTestSimpleTableWithEnum(_fbb, ptr, _rehasher).Union();
+ }
+ case AnyUniqueAliases_M2: {
+ auto ptr = reinterpret_cast<const MyGame::Example2::MonsterT *>(value);
+ return CreateMonster(_fbb, ptr, _rehasher).Union();
+ }
+ default: return 0;
+ }
+}
+
+inline AnyUniqueAliasesUnion::AnyUniqueAliasesUnion(const AnyUniqueAliasesUnion &u) : type(u.type), value(nullptr) {
+ switch (type) {
+ case AnyUniqueAliases_M: {
+ value = new MyGame::Example::MonsterT(*reinterpret_cast<MyGame::Example::MonsterT *>(u.value));
+ break;
+ }
+ case AnyUniqueAliases_TS: {
+ value = new MyGame::Example::TestSimpleTableWithEnumT(*reinterpret_cast<MyGame::Example::TestSimpleTableWithEnumT *>(u.value));
+ break;
+ }
+ case AnyUniqueAliases_M2: {
+ value = new MyGame::Example2::MonsterT(*reinterpret_cast<MyGame::Example2::MonsterT *>(u.value));
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+inline void AnyUniqueAliasesUnion::Reset() {
+ switch (type) {
+ case AnyUniqueAliases_M: {
+ auto ptr = reinterpret_cast<MyGame::Example::MonsterT *>(value);
+ delete ptr;
+ break;
+ }
+ case AnyUniqueAliases_TS: {
+ auto ptr = reinterpret_cast<MyGame::Example::TestSimpleTableWithEnumT *>(value);
+ delete ptr;
+ break;
+ }
+ case AnyUniqueAliases_M2: {
+ auto ptr = reinterpret_cast<MyGame::Example2::MonsterT *>(value);
+ delete ptr;
+ break;
+ }
+ default: break;
+ }
+ value = nullptr;
+ type = AnyUniqueAliases_NONE;
+}
+
+inline bool VerifyAnyAmbiguousAliases(flatbuffers::Verifier &verifier, const void *obj, AnyAmbiguousAliases type) {
+ switch (type) {
+ case AnyAmbiguousAliases_NONE: {
+ return true;
+ }
+ case AnyAmbiguousAliases_M1: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ case AnyAmbiguousAliases_M2: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ case AnyAmbiguousAliases_M3: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ default: return true;
+ }
+}
+
+inline bool VerifyAnyAmbiguousAliasesVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types) {
+ if (!values || !types) return !values && !types;
+ if (values->size() != types->size()) return false;
+ for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
+ if (!VerifyAnyAmbiguousAliases(
+ verifier, values->Get(i), types->GetEnum<AnyAmbiguousAliases>(i))) {
+ return false;
+ }
+ }
+ return true;
+}
+
+inline void *AnyAmbiguousAliasesUnion::UnPack(const void *obj, AnyAmbiguousAliases type, const flatbuffers::resolver_function_t *resolver) {
+ (void)resolver;
+ switch (type) {
+ case AnyAmbiguousAliases_M1: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ case AnyAmbiguousAliases_M2: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ case AnyAmbiguousAliases_M3: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ default: return nullptr;
+ }
+}
+
+inline flatbuffers::Offset<void> AnyAmbiguousAliasesUnion::Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher) const {
+ (void)_rehasher;
+ switch (type) {
+ case AnyAmbiguousAliases_M1: {
+ auto ptr = reinterpret_cast<const MyGame::Example::MonsterT *>(value);
+ return CreateMonster(_fbb, ptr, _rehasher).Union();
+ }
+ case AnyAmbiguousAliases_M2: {
+ auto ptr = reinterpret_cast<const MyGame::Example::MonsterT *>(value);
+ return CreateMonster(_fbb, ptr, _rehasher).Union();
+ }
+ case AnyAmbiguousAliases_M3: {
+ auto ptr = reinterpret_cast<const MyGame::Example::MonsterT *>(value);
+ return CreateMonster(_fbb, ptr, _rehasher).Union();
+ }
+ default: return 0;
+ }
+}
+
+inline AnyAmbiguousAliasesUnion::AnyAmbiguousAliasesUnion(const AnyAmbiguousAliasesUnion &u) : type(u.type), value(nullptr) {
+ switch (type) {
+ case AnyAmbiguousAliases_M1: {
+ value = new MyGame::Example::MonsterT(*reinterpret_cast<MyGame::Example::MonsterT *>(u.value));
+ break;
+ }
+ case AnyAmbiguousAliases_M2: {
+ value = new MyGame::Example::MonsterT(*reinterpret_cast<MyGame::Example::MonsterT *>(u.value));
+ break;
+ }
+ case AnyAmbiguousAliases_M3: {
+ value = new MyGame::Example::MonsterT(*reinterpret_cast<MyGame::Example::MonsterT *>(u.value));
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+inline void AnyAmbiguousAliasesUnion::Reset() {
+ switch (type) {
+ case AnyAmbiguousAliases_M1: {
+ auto ptr = reinterpret_cast<MyGame::Example::MonsterT *>(value);
+ delete ptr;
+ break;
+ }
+ case AnyAmbiguousAliases_M2: {
+ auto ptr = reinterpret_cast<MyGame::Example::MonsterT *>(value);
+ delete ptr;
+ break;
+ }
+ case AnyAmbiguousAliases_M3: {
+ auto ptr = reinterpret_cast<MyGame::Example::MonsterT *>(value);
+ delete ptr;
+ break;
+ }
+ default: break;
+ }
+ value = nullptr;
+ type = AnyAmbiguousAliases_NONE;
+}
+
+inline const flatbuffers::TypeTable *ColorTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_UCHAR, 0, 0 },
+ { flatbuffers::ET_UCHAR, 0, 0 },
+ { flatbuffers::ET_UCHAR, 0, 0 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::ColorTypeTable
+ };
+ static const int64_t values[] = { 1, 2, 8 };
+ static const char * const names[] = {
+ "Red",
+ "Green",
+ "Blue"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_ENUM, 3, type_codes, type_refs, nullptr, values, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *RaceTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_CHAR, 0, 0 },
+ { flatbuffers::ET_CHAR, 0, 0 },
+ { flatbuffers::ET_CHAR, 0, 0 },
+ { flatbuffers::ET_CHAR, 0, 0 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::RaceTypeTable
+ };
+ static const int64_t values[] = { -1, 0, 1, 2 };
+ static const char * const names[] = {
+ "None",
+ "Human",
+ "Dwarf",
+ "Elf"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_ENUM, 4, type_codes, type_refs, nullptr, values, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *LongEnumTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_ULONG, 0, 0 },
+ { flatbuffers::ET_ULONG, 0, 0 },
+ { flatbuffers::ET_ULONG, 0, 0 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::LongEnumTypeTable
+ };
+ static const int64_t values[] = { 2ULL, 4ULL, 1099511627776ULL };
+ static const char * const names[] = {
+ "LongOne",
+ "LongTwo",
+ "LongBig"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_ENUM, 3, type_codes, type_refs, nullptr, values, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *AnyTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_SEQUENCE, 0, -1 },
+ { flatbuffers::ET_SEQUENCE, 0, 0 },
+ { flatbuffers::ET_SEQUENCE, 0, 1 },
+ { flatbuffers::ET_SEQUENCE, 0, 2 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::MonsterTypeTable,
+ MyGame::Example::TestSimpleTableWithEnumTypeTable,
+ MyGame::Example2::MonsterTypeTable
+ };
+ static const char * const names[] = {
+ "NONE",
+ "Monster",
+ "TestSimpleTableWithEnum",
+ "MyGame_Example2_Monster"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_UNION, 4, type_codes, type_refs, nullptr, nullptr, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *AnyUniqueAliasesTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_SEQUENCE, 0, -1 },
+ { flatbuffers::ET_SEQUENCE, 0, 0 },
+ { flatbuffers::ET_SEQUENCE, 0, 1 },
+ { flatbuffers::ET_SEQUENCE, 0, 2 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::MonsterTypeTable,
+ MyGame::Example::TestSimpleTableWithEnumTypeTable,
+ MyGame::Example2::MonsterTypeTable
+ };
+ static const char * const names[] = {
+ "NONE",
+ "M",
+ "TS",
+ "M2"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_UNION, 4, type_codes, type_refs, nullptr, nullptr, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *AnyAmbiguousAliasesTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_SEQUENCE, 0, -1 },
+ { flatbuffers::ET_SEQUENCE, 0, 0 },
+ { flatbuffers::ET_SEQUENCE, 0, 0 },
+ { flatbuffers::ET_SEQUENCE, 0, 0 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::MonsterTypeTable
+ };
+ static const char * const names[] = {
+ "NONE",
+ "M1",
+ "M2",
+ "M3"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_UNION, 4, type_codes, type_refs, nullptr, nullptr, names
+ };
+ return &tt;
+}
+
+} // namespace Example
+
+inline const flatbuffers::TypeTable *InParentNamespaceTypeTable() {
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_TABLE, 0, nullptr, nullptr, nullptr, nullptr, nullptr
+ };
+ return &tt;
+}
+
+namespace Example2 {
+
+inline const flatbuffers::TypeTable *MonsterTypeTable() {
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_TABLE, 0, nullptr, nullptr, nullptr, nullptr, nullptr
+ };
+ return &tt;
+}
+
+} // namespace Example2
+
+namespace Example {
+
+inline const flatbuffers::TypeTable *TestTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_SHORT, 0, -1 },
+ { flatbuffers::ET_CHAR, 0, -1 }
+ };
+ static const int64_t values[] = { 0, 2, 4 };
+ static const char * const names[] = {
+ "a",
+ "b"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_STRUCT, 2, type_codes, nullptr, nullptr, values, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *TestSimpleTableWithEnumTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_UCHAR, 0, 0 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::ColorTypeTable
+ };
+ static const char * const names[] = {
+ "color"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_TABLE, 1, type_codes, type_refs, nullptr, nullptr, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *Vec3TypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_FLOAT, 0, -1 },
+ { flatbuffers::ET_FLOAT, 0, -1 },
+ { flatbuffers::ET_FLOAT, 0, -1 },
+ { flatbuffers::ET_DOUBLE, 0, -1 },
+ { flatbuffers::ET_UCHAR, 0, 0 },
+ { flatbuffers::ET_SEQUENCE, 0, 1 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::ColorTypeTable,
+ MyGame::Example::TestTypeTable
+ };
+ static const int64_t values[] = { 0, 4, 8, 16, 24, 26, 32 };
+ static const char * const names[] = {
+ "x",
+ "y",
+ "z",
+ "test1",
+ "test2",
+ "test3"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_STRUCT, 6, type_codes, type_refs, nullptr, values, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *AbilityTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_UINT, 0, -1 },
+ { flatbuffers::ET_UINT, 0, -1 }
+ };
+ static const int64_t values[] = { 0, 4, 8 };
+ static const char * const names[] = {
+ "id",
+ "distance"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_STRUCT, 2, type_codes, nullptr, nullptr, values, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *StructOfStructsTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_SEQUENCE, 0, 0 },
+ { flatbuffers::ET_SEQUENCE, 0, 1 },
+ { flatbuffers::ET_SEQUENCE, 0, 0 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::AbilityTypeTable,
+ MyGame::Example::TestTypeTable
+ };
+ static const int64_t values[] = { 0, 8, 12, 20 };
+ static const char * const names[] = {
+ "a",
+ "b",
+ "c"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_STRUCT, 3, type_codes, type_refs, nullptr, values, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *StructOfStructsOfStructsTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_SEQUENCE, 0, 0 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::StructOfStructsTypeTable
+ };
+ static const int64_t values[] = { 0, 20 };
+ static const char * const names[] = {
+ "a"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_STRUCT, 1, type_codes, type_refs, nullptr, values, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *StatTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_STRING, 0, -1 },
+ { flatbuffers::ET_LONG, 0, -1 },
+ { flatbuffers::ET_USHORT, 0, -1 }
+ };
+ static const char * const names[] = {
+ "id",
+ "val",
+ "count"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_TABLE, 3, type_codes, nullptr, nullptr, nullptr, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *ReferrableTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_ULONG, 0, -1 }
+ };
+ static const char * const names[] = {
+ "id"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_TABLE, 1, type_codes, nullptr, nullptr, nullptr, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *MonsterTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_SEQUENCE, 0, 0 },
+ { flatbuffers::ET_SHORT, 0, -1 },
+ { flatbuffers::ET_SHORT, 0, -1 },
+ { flatbuffers::ET_STRING, 0, -1 },
+ { flatbuffers::ET_BOOL, 0, -1 },
+ { flatbuffers::ET_UCHAR, 1, -1 },
+ { flatbuffers::ET_UCHAR, 0, 1 },
+ { flatbuffers::ET_UTYPE, 0, 2 },
+ { flatbuffers::ET_SEQUENCE, 0, 2 },
+ { flatbuffers::ET_SEQUENCE, 1, 3 },
+ { flatbuffers::ET_STRING, 1, -1 },
+ { flatbuffers::ET_SEQUENCE, 1, 4 },
+ { flatbuffers::ET_SEQUENCE, 0, 4 },
+ { flatbuffers::ET_UCHAR, 1, -1 },
+ { flatbuffers::ET_SEQUENCE, 0, 5 },
+ { flatbuffers::ET_BOOL, 0, -1 },
+ { flatbuffers::ET_INT, 0, -1 },
+ { flatbuffers::ET_UINT, 0, -1 },
+ { flatbuffers::ET_LONG, 0, -1 },
+ { flatbuffers::ET_ULONG, 0, -1 },
+ { flatbuffers::ET_INT, 0, -1 },
+ { flatbuffers::ET_UINT, 0, -1 },
+ { flatbuffers::ET_LONG, 0, -1 },
+ { flatbuffers::ET_ULONG, 0, -1 },
+ { flatbuffers::ET_BOOL, 1, -1 },
+ { flatbuffers::ET_FLOAT, 0, -1 },
+ { flatbuffers::ET_FLOAT, 0, -1 },
+ { flatbuffers::ET_FLOAT, 0, -1 },
+ { flatbuffers::ET_STRING, 1, -1 },
+ { flatbuffers::ET_SEQUENCE, 1, 6 },
+ { flatbuffers::ET_UCHAR, 1, -1 },
+ { flatbuffers::ET_SEQUENCE, 1, 3 },
+ { flatbuffers::ET_LONG, 1, -1 },
+ { flatbuffers::ET_DOUBLE, 1, -1 },
+ { flatbuffers::ET_SEQUENCE, 0, 7 },
+ { flatbuffers::ET_SEQUENCE, 1, 8 },
+ { flatbuffers::ET_ULONG, 0, -1 },
+ { flatbuffers::ET_ULONG, 1, -1 },
+ { flatbuffers::ET_SEQUENCE, 1, 8 },
+ { flatbuffers::ET_ULONG, 0, -1 },
+ { flatbuffers::ET_ULONG, 1, -1 },
+ { flatbuffers::ET_ULONG, 0, -1 },
+ { flatbuffers::ET_ULONG, 1, -1 },
+ { flatbuffers::ET_UTYPE, 0, 9 },
+ { flatbuffers::ET_SEQUENCE, 0, 9 },
+ { flatbuffers::ET_UTYPE, 0, 10 },
+ { flatbuffers::ET_SEQUENCE, 0, 10 },
+ { flatbuffers::ET_UCHAR, 1, 1 },
+ { flatbuffers::ET_CHAR, 0, 11 },
+ { flatbuffers::ET_UCHAR, 1, -1 },
+ { flatbuffers::ET_SEQUENCE, 1, 5 },
+ { flatbuffers::ET_SEQUENCE, 0, 3 },
+ { flatbuffers::ET_ULONG, 0, 12 },
+ { flatbuffers::ET_ULONG, 0, 12 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::Vec3TypeTable,
+ MyGame::Example::ColorTypeTable,
+ MyGame::Example::AnyTypeTable,
+ MyGame::Example::TestTypeTable,
+ MyGame::Example::MonsterTypeTable,
+ MyGame::Example::StatTypeTable,
+ MyGame::Example::AbilityTypeTable,
+ MyGame::InParentNamespaceTypeTable,
+ MyGame::Example::ReferrableTypeTable,
+ MyGame::Example::AnyUniqueAliasesTypeTable,
+ MyGame::Example::AnyAmbiguousAliasesTypeTable,
+ MyGame::Example::RaceTypeTable,
+ MyGame::Example::LongEnumTypeTable
+ };
+ static const char * const names[] = {
+ "pos",
+ "mana",
+ "hp",
+ "name",
+ "friendly",
+ "inventory",
+ "color",
+ "test_type",
+ "test",
+ "test4",
+ "testarrayofstring",
+ "testarrayoftables",
+ "enemy",
+ "testnestedflatbuffer",
+ "testempty",
+ "testbool",
+ "testhashs32_fnv1",
+ "testhashu32_fnv1",
+ "testhashs64_fnv1",
+ "testhashu64_fnv1",
+ "testhashs32_fnv1a",
+ "testhashu32_fnv1a",
+ "testhashs64_fnv1a",
+ "testhashu64_fnv1a",
+ "testarrayofbools",
+ "testf",
+ "testf2",
+ "testf3",
+ "testarrayofstring2",
+ "testarrayofsortedstruct",
+ "flex",
+ "test5",
+ "vector_of_longs",
+ "vector_of_doubles",
+ "parent_namespace_test",
+ "vector_of_referrables",
+ "single_weak_reference",
+ "vector_of_weak_references",
+ "vector_of_strong_referrables",
+ "co_owning_reference",
+ "vector_of_co_owning_references",
+ "non_owning_reference",
+ "vector_of_non_owning_references",
+ "any_unique_type",
+ "any_unique",
+ "any_ambiguous_type",
+ "any_ambiguous",
+ "vector_of_enums",
+ "signed_enum",
+ "testrequirednestedflatbuffer",
+ "scalar_key_sorted_tables",
+ "native_inline",
+ "long_enum_non_enum_default",
+ "long_enum_normal_default"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_TABLE, 54, type_codes, type_refs, nullptr, nullptr, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *TypeAliasesTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_CHAR, 0, -1 },
+ { flatbuffers::ET_UCHAR, 0, -1 },
+ { flatbuffers::ET_SHORT, 0, -1 },
+ { flatbuffers::ET_USHORT, 0, -1 },
+ { flatbuffers::ET_INT, 0, -1 },
+ { flatbuffers::ET_UINT, 0, -1 },
+ { flatbuffers::ET_LONG, 0, -1 },
+ { flatbuffers::ET_ULONG, 0, -1 },
+ { flatbuffers::ET_FLOAT, 0, -1 },
+ { flatbuffers::ET_DOUBLE, 0, -1 },
+ { flatbuffers::ET_CHAR, 1, -1 },
+ { flatbuffers::ET_DOUBLE, 1, -1 }
+ };
+ static const char * const names[] = {
+ "i8",
+ "u8",
+ "i16",
+ "u16",
+ "i32",
+ "u32",
+ "i64",
+ "u64",
+ "f32",
+ "f64",
+ "v8",
+ "vf64"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_TABLE, 12, type_codes, nullptr, nullptr, nullptr, names
+ };
+ return &tt;
+}
+
+inline const MyGame::Example::Monster *GetMonster(const void *buf) {
+ return flatbuffers::GetRoot<MyGame::Example::Monster>(buf);
+}
+
+inline const MyGame::Example::Monster *GetSizePrefixedMonster(const void *buf) {
+ return flatbuffers::GetSizePrefixedRoot<MyGame::Example::Monster>(buf);
+}
+
+inline Monster *GetMutableMonster(void *buf) {
+ return flatbuffers::GetMutableRoot<Monster>(buf);
+}
+
+inline MyGame::Example::Monster *GetMutableSizePrefixedMonster(void *buf) {
+ return flatbuffers::GetMutableSizePrefixedRoot<MyGame::Example::Monster>(buf);
+}
+
+inline const char *MonsterIdentifier() {
+ return "MONS";
+}
+
+inline bool MonsterBufferHasIdentifier(const void *buf) {
+ return flatbuffers::BufferHasIdentifier(
+ buf, MonsterIdentifier());
+}
+
+inline bool SizePrefixedMonsterBufferHasIdentifier(const void *buf) {
+ return flatbuffers::BufferHasIdentifier(
+ buf, MonsterIdentifier(), true);
+}
+
+inline bool VerifyMonsterBuffer(
+ flatbuffers::Verifier &verifier) {
+ return verifier.VerifyBuffer<MyGame::Example::Monster>(MonsterIdentifier());
+}
+
+inline bool VerifySizePrefixedMonsterBuffer(
+ flatbuffers::Verifier &verifier) {
+ return verifier.VerifySizePrefixedBuffer<MyGame::Example::Monster>(MonsterIdentifier());
+}
+
+inline const char *MonsterExtension() {
+ return "mon";
+}
+
+inline void FinishMonsterBuffer(
+ flatbuffers::FlatBufferBuilder &fbb,
+ flatbuffers::Offset<MyGame::Example::Monster> root) {
+ fbb.Finish(root, MonsterIdentifier());
+}
+
+inline void FinishSizePrefixedMonsterBuffer(
+ flatbuffers::FlatBufferBuilder &fbb,
+ flatbuffers::Offset<MyGame::Example::Monster> root) {
+ fbb.FinishSizePrefixed(root, MonsterIdentifier());
+}
+
+inline flatbuffers::unique_ptr<MyGame::Example::MonsterT> UnPackMonster(
+ const void *buf,
+ const flatbuffers::resolver_function_t *res = nullptr) {
+ return flatbuffers::unique_ptr<MyGame::Example::MonsterT>(GetMonster(buf)->UnPack(res));
+}
+
+inline flatbuffers::unique_ptr<MyGame::Example::MonsterT> UnPackSizePrefixedMonster(
+ const void *buf,
+ const flatbuffers::resolver_function_t *res = nullptr) {
+ return flatbuffers::unique_ptr<MyGame::Example::MonsterT>(GetSizePrefixedMonster(buf)->UnPack(res));
+}
+
+} // namespace Example
+} // namespace MyGame
+
+#endif // FLATBUFFERS_GENERATED_MONSTERTEST_MYGAME_EXAMPLE_H_
diff --git a/tests/monster_test_suffix/filesuffix_only/monster_test.grpc.fb.cc b/tests/monster_test_suffix/filesuffix_only/monster_test.grpc.fb.cc
new file mode 100644
index 0000000..3ef89ce
--- /dev/null
+++ b/tests/monster_test_suffix/filesuffix_only/monster_test.grpc.fb.cc
@@ -0,0 +1,131 @@
+// Generated by the gRPC C++ plugin.
+// If you make any local change, they will be lost.
+// source: monster_test
+
+#include "monster_test_suffix.h"
+#include "monster_test.grpc.fb.h"
+
+#include <grpcpp/impl/codegen/async_stream.h>
+#include <grpcpp/impl/codegen/async_unary_call.h>
+#include <grpcpp/impl/codegen/channel_interface.h>
+#include <grpcpp/impl/codegen/client_unary_call.h>
+#include <grpcpp/impl/codegen/method_handler.h>
+#include <grpcpp/impl/codegen/rpc_service_method.h>
+#include <grpcpp/impl/codegen/service_type.h>
+#include <grpcpp/impl/codegen/sync_stream.h>
+namespace MyGame {
+namespace Example {
+
+static const char* MonsterStorage_method_names[] = {
+ "/MyGame.Example.MonsterStorage/Store",
+ "/MyGame.Example.MonsterStorage/Retrieve",
+ "/MyGame.Example.MonsterStorage/GetMaxHitPoint",
+ "/MyGame.Example.MonsterStorage/GetMinMaxHitPoints",
+};
+
+std::unique_ptr< MonsterStorage::Stub> MonsterStorage::NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& /*options*/) {
+ std::unique_ptr< MonsterStorage::Stub> stub(new MonsterStorage::Stub(channel));
+ return stub;
+}
+
+MonsterStorage::Stub::Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel)
+ : channel_(channel) , rpcmethod_Store_(MonsterStorage_method_names[0], ::grpc::internal::RpcMethod::NORMAL_RPC, channel)
+ , rpcmethod_Retrieve_(MonsterStorage_method_names[1], ::grpc::internal::RpcMethod::SERVER_STREAMING, channel)
+ , rpcmethod_GetMaxHitPoint_(MonsterStorage_method_names[2], ::grpc::internal::RpcMethod::CLIENT_STREAMING, channel)
+ , rpcmethod_GetMinMaxHitPoints_(MonsterStorage_method_names[3], ::grpc::internal::RpcMethod::BIDI_STREAMING, channel)
+ {}
+
+::grpc::Status MonsterStorage::Stub::Store(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, flatbuffers::grpc::Message<Stat>* response) {
+ return ::grpc::internal::BlockingUnaryCall(channel_.get(), rpcmethod_Store_, context, request, response);
+}
+
+::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>* MonsterStorage::Stub::AsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) {
+ return ::grpc::internal::ClientAsyncResponseReaderFactory< flatbuffers::grpc::Message<Stat>>::Create(channel_.get(), cq, rpcmethod_Store_, context, request, true);
+}
+
+::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>* MonsterStorage::Stub::PrepareAsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) {
+ return ::grpc::internal::ClientAsyncResponseReaderFactory< flatbuffers::grpc::Message<Stat>>::Create(channel_.get(), cq, rpcmethod_Store_, context, request, false);
+}
+
+::grpc::ClientReader< flatbuffers::grpc::Message<Monster>>* MonsterStorage::Stub::RetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request) {
+ return ::grpc::internal::ClientReaderFactory< flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), rpcmethod_Retrieve_, context, request);
+}
+
+::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>* MonsterStorage::Stub::AsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq, void* tag) {
+ return ::grpc::internal::ClientAsyncReaderFactory< flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), cq, rpcmethod_Retrieve_, context, request, true, tag);
+}
+
+::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>* MonsterStorage::Stub::PrepareAsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq) {
+ return ::grpc::internal::ClientAsyncReaderFactory< flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), cq, rpcmethod_Retrieve_, context, request, false, nullptr);
+}
+
+::grpc::ClientWriter< flatbuffers::grpc::Message<Monster>>* MonsterStorage::Stub::GetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response) {
+ return ::grpc::internal::ClientWriterFactory< flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), rpcmethod_GetMaxHitPoint_, context, response);
+}
+
+::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>* MonsterStorage::Stub::AsyncGetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq, void* tag) {
+ return ::grpc::internal::ClientAsyncWriterFactory< flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), cq, rpcmethod_GetMaxHitPoint_, context, response, true, tag);
+}
+
+::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>* MonsterStorage::Stub::PrepareAsyncGetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq) {
+ return ::grpc::internal::ClientAsyncWriterFactory< flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), cq, rpcmethod_GetMaxHitPoint_, context, response, false, nullptr);
+}
+
+::grpc::ClientReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* MonsterStorage::Stub::GetMinMaxHitPointsRaw(::grpc::ClientContext* context) {
+ return ::grpc::internal::ClientReaderWriterFactory< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>::Create(channel_.get(), rpcmethod_GetMinMaxHitPoints_, context);
+}
+
+::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* MonsterStorage::Stub::AsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) {
+ return ::grpc::internal::ClientAsyncReaderWriterFactory< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>::Create(channel_.get(), cq, rpcmethod_GetMinMaxHitPoints_, context, true, tag);
+}
+
+::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* MonsterStorage::Stub::PrepareAsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) {
+ return ::grpc::internal::ClientAsyncReaderWriterFactory< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>::Create(channel_.get(), cq, rpcmethod_GetMinMaxHitPoints_, context, false, nullptr);
+}
+
+MonsterStorage::Service::Service() {
+ AddMethod(new ::grpc::internal::RpcServiceMethod(
+ MonsterStorage_method_names[0],
+ ::grpc::internal::RpcMethod::NORMAL_RPC,
+ new ::grpc::internal::RpcMethodHandler< MonsterStorage::Service, flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>(
+ std::mem_fn(&MonsterStorage::Service::Store), this)));
+ AddMethod(new ::grpc::internal::RpcServiceMethod(
+ MonsterStorage_method_names[1],
+ ::grpc::internal::RpcMethod::SERVER_STREAMING,
+ new ::grpc::internal::ServerStreamingHandler< MonsterStorage::Service, flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>(
+ std::mem_fn(&MonsterStorage::Service::Retrieve), this)));
+ AddMethod(new ::grpc::internal::RpcServiceMethod(
+ MonsterStorage_method_names[2],
+ ::grpc::internal::RpcMethod::CLIENT_STREAMING,
+ new ::grpc::internal::ClientStreamingHandler< MonsterStorage::Service, flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>(
+ std::mem_fn(&MonsterStorage::Service::GetMaxHitPoint), this)));
+ AddMethod(new ::grpc::internal::RpcServiceMethod(
+ MonsterStorage_method_names[3],
+ ::grpc::internal::RpcMethod::BIDI_STREAMING,
+ new ::grpc::internal::BidiStreamingHandler< MonsterStorage::Service, flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>(
+ std::mem_fn(&MonsterStorage::Service::GetMinMaxHitPoints), this)));
+}
+
+MonsterStorage::Service::~Service() {
+}
+
+::grpc::Status MonsterStorage::Service::Store(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Monster>* /*request*/, flatbuffers::grpc::Message<Stat>* /*response*/) {
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+}
+
+::grpc::Status MonsterStorage::Service::Retrieve(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Stat>* /*request*/, ::grpc::ServerWriter< flatbuffers::grpc::Message<Monster>>* /*writer*/) {
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+}
+
+::grpc::Status MonsterStorage::Service::GetMaxHitPoint(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< flatbuffers::grpc::Message<Monster>>* /*reader*/, flatbuffers::grpc::Message<Stat>* /*response*/) {
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+}
+
+::grpc::Status MonsterStorage::Service::GetMinMaxHitPoints(::grpc::ServerContext* /*context*/, ::grpc::ServerReaderWriter< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>* /*stream*/) {
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+}
+
+
+} // namespace MyGame
+} // namespace Example
+
diff --git a/tests/monster_test_suffix/filesuffix_only/monster_test.grpc.fb.h b/tests/monster_test_suffix/filesuffix_only/monster_test.grpc.fb.h
new file mode 100644
index 0000000..a8f4b95
--- /dev/null
+++ b/tests/monster_test_suffix/filesuffix_only/monster_test.grpc.fb.h
@@ -0,0 +1,350 @@
+// Generated by the gRPC C++ plugin.
+// If you make any local change, they will be lost.
+// source: monster_test
+#ifndef GRPC_monster_5ftest__INCLUDED
+#define GRPC_monster_5ftest__INCLUDED
+
+#include "monster_test_suffix.h"
+#include "flatbuffers/grpc.h"
+
+#include <grpcpp/impl/codegen/async_stream.h>
+#include <grpcpp/impl/codegen/async_unary_call.h>
+#include <grpcpp/impl/codegen/method_handler.h>
+#include <grpcpp/impl/codegen/proto_utils.h>
+#include <grpcpp/impl/codegen/rpc_method.h>
+#include <grpcpp/impl/codegen/service_type.h>
+#include <grpcpp/impl/codegen/status.h>
+#include <grpcpp/impl/codegen/stub_options.h>
+#include <grpcpp/impl/codegen/sync_stream.h>
+
+namespace grpc {
+class CompletionQueue;
+class Channel;
+class ServerCompletionQueue;
+class ServerContext;
+} // namespace grpc
+
+namespace MyGame {
+namespace Example {
+
+class MonsterStorage final {
+ public:
+ static constexpr char const* service_full_name() {
+ return "MyGame.Example.MonsterStorage";
+ }
+ class StubInterface {
+ public:
+ virtual ~StubInterface() {}
+ virtual ::grpc::Status Store(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, flatbuffers::grpc::Message<Stat>* response) = 0;
+ std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::grpc::Message<Stat>>> AsyncStore(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::grpc::Message<Stat>>>(AsyncStoreRaw(context, request, cq));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::grpc::Message<Stat>>> PrepareAsyncStore(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::grpc::Message<Stat>>>(PrepareAsyncStoreRaw(context, request, cq));
+ }
+ std::unique_ptr< ::grpc::ClientReaderInterface< flatbuffers::grpc::Message<Monster>>> Retrieve(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request) {
+ return std::unique_ptr< ::grpc::ClientReaderInterface< flatbuffers::grpc::Message<Monster>>>(RetrieveRaw(context, request));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncReaderInterface< flatbuffers::grpc::Message<Monster>>> AsyncRetrieve(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq, void* tag) {
+ return std::unique_ptr< ::grpc::ClientAsyncReaderInterface< flatbuffers::grpc::Message<Monster>>>(AsyncRetrieveRaw(context, request, cq, tag));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncReaderInterface< flatbuffers::grpc::Message<Monster>>> PrepareAsyncRetrieve(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncReaderInterface< flatbuffers::grpc::Message<Monster>>>(PrepareAsyncRetrieveRaw(context, request, cq));
+ }
+ std::unique_ptr< ::grpc::ClientWriterInterface< flatbuffers::grpc::Message<Monster>>> GetMaxHitPoint(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response) {
+ return std::unique_ptr< ::grpc::ClientWriterInterface< flatbuffers::grpc::Message<Monster>>>(GetMaxHitPointRaw(context, response));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncWriterInterface< flatbuffers::grpc::Message<Monster>>> AsyncGetMaxHitPoint(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq, void* tag) {
+ return std::unique_ptr< ::grpc::ClientAsyncWriterInterface< flatbuffers::grpc::Message<Monster>>>(AsyncGetMaxHitPointRaw(context, response, cq, tag));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncWriterInterface< flatbuffers::grpc::Message<Monster>>> PrepareAsyncGetMaxHitPoint(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncWriterInterface< flatbuffers::grpc::Message<Monster>>>(PrepareAsyncGetMaxHitPointRaw(context, response, cq));
+ }
+ std::unique_ptr< ::grpc::ClientReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>> GetMinMaxHitPoints(::grpc::ClientContext* context) {
+ return std::unique_ptr< ::grpc::ClientReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>(GetMinMaxHitPointsRaw(context));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>> AsyncGetMinMaxHitPoints(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) {
+ return std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>(AsyncGetMinMaxHitPointsRaw(context, cq, tag));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>> PrepareAsyncGetMinMaxHitPoints(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>(PrepareAsyncGetMinMaxHitPointsRaw(context, cq));
+ }
+ private:
+ virtual ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::grpc::Message<Stat>>* AsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) = 0;
+ virtual ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::grpc::Message<Stat>>* PrepareAsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) = 0;
+ virtual ::grpc::ClientReaderInterface< flatbuffers::grpc::Message<Monster>>* RetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request) = 0;
+ virtual ::grpc::ClientAsyncReaderInterface< flatbuffers::grpc::Message<Monster>>* AsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq, void* tag) = 0;
+ virtual ::grpc::ClientAsyncReaderInterface< flatbuffers::grpc::Message<Monster>>* PrepareAsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq) = 0;
+ virtual ::grpc::ClientWriterInterface< flatbuffers::grpc::Message<Monster>>* GetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response) = 0;
+ virtual ::grpc::ClientAsyncWriterInterface< flatbuffers::grpc::Message<Monster>>* AsyncGetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq, void* tag) = 0;
+ virtual ::grpc::ClientAsyncWriterInterface< flatbuffers::grpc::Message<Monster>>* PrepareAsyncGetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq) = 0;
+ virtual ::grpc::ClientReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* GetMinMaxHitPointsRaw(::grpc::ClientContext* context) = 0;
+ virtual ::grpc::ClientAsyncReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* AsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) = 0;
+ virtual ::grpc::ClientAsyncReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* PrepareAsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) = 0;
+ };
+ class Stub final : public StubInterface {
+ public:
+ Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel);
+ ::grpc::Status Store(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, flatbuffers::grpc::Message<Stat>* response) override;
+ std::unique_ptr< ::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>> AsyncStore(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>>(AsyncStoreRaw(context, request, cq));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>> PrepareAsyncStore(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>>(PrepareAsyncStoreRaw(context, request, cq));
+ }
+ std::unique_ptr< ::grpc::ClientReader< flatbuffers::grpc::Message<Monster>>> Retrieve(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request) {
+ return std::unique_ptr< ::grpc::ClientReader< flatbuffers::grpc::Message<Monster>>>(RetrieveRaw(context, request));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>> AsyncRetrieve(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq, void* tag) {
+ return std::unique_ptr< ::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>>(AsyncRetrieveRaw(context, request, cq, tag));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>> PrepareAsyncRetrieve(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>>(PrepareAsyncRetrieveRaw(context, request, cq));
+ }
+ std::unique_ptr< ::grpc::ClientWriter< flatbuffers::grpc::Message<Monster>>> GetMaxHitPoint(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response) {
+ return std::unique_ptr< ::grpc::ClientWriter< flatbuffers::grpc::Message<Monster>>>(GetMaxHitPointRaw(context, response));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>> AsyncGetMaxHitPoint(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq, void* tag) {
+ return std::unique_ptr< ::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>>(AsyncGetMaxHitPointRaw(context, response, cq, tag));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>> PrepareAsyncGetMaxHitPoint(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>>(PrepareAsyncGetMaxHitPointRaw(context, response, cq));
+ }
+ std::unique_ptr< ::grpc::ClientReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>> GetMinMaxHitPoints(::grpc::ClientContext* context) {
+ return std::unique_ptr< ::grpc::ClientReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>(GetMinMaxHitPointsRaw(context));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>> AsyncGetMinMaxHitPoints(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) {
+ return std::unique_ptr< ::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>(AsyncGetMinMaxHitPointsRaw(context, cq, tag));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>> PrepareAsyncGetMinMaxHitPoints(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>(PrepareAsyncGetMinMaxHitPointsRaw(context, cq));
+ }
+
+ private:
+ std::shared_ptr< ::grpc::ChannelInterface> channel_;
+ ::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>* AsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) override;
+ ::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>* PrepareAsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) override;
+ ::grpc::ClientReader< flatbuffers::grpc::Message<Monster>>* RetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request) override;
+ ::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>* AsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq, void* tag) override;
+ ::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>* PrepareAsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq) override;
+ ::grpc::ClientWriter< flatbuffers::grpc::Message<Monster>>* GetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response) override;
+ ::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>* AsyncGetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq, void* tag) override;
+ ::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>* PrepareAsyncGetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq) override;
+ ::grpc::ClientReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* GetMinMaxHitPointsRaw(::grpc::ClientContext* context) override;
+ ::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* AsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) override;
+ ::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* PrepareAsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) override;
+ const ::grpc::internal::RpcMethod rpcmethod_Store_;
+ const ::grpc::internal::RpcMethod rpcmethod_Retrieve_;
+ const ::grpc::internal::RpcMethod rpcmethod_GetMaxHitPoint_;
+ const ::grpc::internal::RpcMethod rpcmethod_GetMinMaxHitPoints_;
+ };
+ static std::unique_ptr<Stub> NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options = ::grpc::StubOptions());
+
+ class Service : public ::grpc::Service {
+ public:
+ Service();
+ virtual ~Service();
+ virtual ::grpc::Status Store(::grpc::ServerContext* context, const flatbuffers::grpc::Message<Monster>* request, flatbuffers::grpc::Message<Stat>* response);
+ virtual ::grpc::Status Retrieve(::grpc::ServerContext* context, const flatbuffers::grpc::Message<Stat>* request, ::grpc::ServerWriter< flatbuffers::grpc::Message<Monster>>* writer);
+ virtual ::grpc::Status GetMaxHitPoint(::grpc::ServerContext* context, ::grpc::ServerReader< flatbuffers::grpc::Message<Monster>>* reader, flatbuffers::grpc::Message<Stat>* response);
+ virtual ::grpc::Status GetMinMaxHitPoints(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>* stream);
+ };
+ template <class BaseClass>
+ class WithAsyncMethod_Store : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
+ public:
+ WithAsyncMethod_Store() {
+ ::grpc::Service::MarkMethodAsync(0);
+ }
+ ~WithAsyncMethod_Store() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status Store(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Monster>* /*request*/, flatbuffers::grpc::Message<Stat>* /*response*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ void RequestStore(::grpc::ServerContext* context, flatbuffers::grpc::Message<Monster>* request, ::grpc::ServerAsyncResponseWriter< flatbuffers::grpc::Message<Stat>>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
+ ::grpc::Service::RequestAsyncUnary(0, context, request, response, new_call_cq, notification_cq, tag);
+ }
+ };
+ template <class BaseClass>
+ class WithAsyncMethod_Retrieve : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
+ public:
+ WithAsyncMethod_Retrieve() {
+ ::grpc::Service::MarkMethodAsync(1);
+ }
+ ~WithAsyncMethod_Retrieve() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status Retrieve(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Stat>* /*request*/, ::grpc::ServerWriter< flatbuffers::grpc::Message<Monster>>* /*writer*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ void RequestRetrieve(::grpc::ServerContext* context, flatbuffers::grpc::Message<Stat>* request, ::grpc::ServerAsyncWriter< flatbuffers::grpc::Message<Monster>>* writer, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
+ ::grpc::Service::RequestAsyncServerStreaming(1, context, request, writer, new_call_cq, notification_cq, tag);
+ }
+ };
+ template <class BaseClass>
+ class WithAsyncMethod_GetMaxHitPoint : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
+ public:
+ WithAsyncMethod_GetMaxHitPoint() {
+ ::grpc::Service::MarkMethodAsync(2);
+ }
+ ~WithAsyncMethod_GetMaxHitPoint() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status GetMaxHitPoint(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< flatbuffers::grpc::Message<Monster>>* /*reader*/, flatbuffers::grpc::Message<Stat>* /*response*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ void RequestGetMaxHitPoint(::grpc::ServerContext* context, ::grpc::ServerAsyncReader< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>* reader, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
+ ::grpc::Service::RequestAsyncClientStreaming(2, context, reader, new_call_cq, notification_cq, tag);
+ }
+ };
+ template <class BaseClass>
+ class WithAsyncMethod_GetMinMaxHitPoints : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
+ public:
+ WithAsyncMethod_GetMinMaxHitPoints() {
+ ::grpc::Service::MarkMethodAsync(3);
+ }
+ ~WithAsyncMethod_GetMinMaxHitPoints() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status GetMinMaxHitPoints(::grpc::ServerContext* /*context*/, ::grpc::ServerReaderWriter< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>* /*stream*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ void RequestGetMinMaxHitPoints(::grpc::ServerContext* context, ::grpc::ServerAsyncReaderWriter< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>* stream, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
+ ::grpc::Service::RequestAsyncBidiStreaming(3, context, stream, new_call_cq, notification_cq, tag);
+ }
+ };
+ typedef WithAsyncMethod_Store< WithAsyncMethod_Retrieve< WithAsyncMethod_GetMaxHitPoint< WithAsyncMethod_GetMinMaxHitPoints< Service > > > > AsyncService;
+ template <class BaseClass>
+ class WithGenericMethod_Store : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
+ public:
+ WithGenericMethod_Store() {
+ ::grpc::Service::MarkMethodGeneric(0);
+ }
+ ~WithGenericMethod_Store() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status Store(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Monster>* /*request*/, flatbuffers::grpc::Message<Stat>* /*response*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ };
+ template <class BaseClass>
+ class WithGenericMethod_Retrieve : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
+ public:
+ WithGenericMethod_Retrieve() {
+ ::grpc::Service::MarkMethodGeneric(1);
+ }
+ ~WithGenericMethod_Retrieve() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status Retrieve(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Stat>* /*request*/, ::grpc::ServerWriter< flatbuffers::grpc::Message<Monster>>* /*writer*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ };
+ template <class BaseClass>
+ class WithGenericMethod_GetMaxHitPoint : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
+ public:
+ WithGenericMethod_GetMaxHitPoint() {
+ ::grpc::Service::MarkMethodGeneric(2);
+ }
+ ~WithGenericMethod_GetMaxHitPoint() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status GetMaxHitPoint(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< flatbuffers::grpc::Message<Monster>>* /*reader*/, flatbuffers::grpc::Message<Stat>* /*response*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ };
+ template <class BaseClass>
+ class WithGenericMethod_GetMinMaxHitPoints : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
+ public:
+ WithGenericMethod_GetMinMaxHitPoints() {
+ ::grpc::Service::MarkMethodGeneric(3);
+ }
+ ~WithGenericMethod_GetMinMaxHitPoints() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status GetMinMaxHitPoints(::grpc::ServerContext* /*context*/, ::grpc::ServerReaderWriter< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>* /*stream*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ };
+ template <class BaseClass>
+ class WithStreamedUnaryMethod_Store : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
+ public:
+ WithStreamedUnaryMethod_Store() {
+ ::grpc::Service::MarkMethodStreamed(0,
+ new ::grpc::internal::StreamedUnaryHandler< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>(std::bind(&WithStreamedUnaryMethod_Store<BaseClass>::StreamedStore, this, std::placeholders::_1, std::placeholders::_2)));
+ }
+ ~WithStreamedUnaryMethod_Store() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable regular version of this method
+ ::grpc::Status Store(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Monster>* /*request*/, flatbuffers::grpc::Message<Stat>* /*response*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ // replace default version of method with streamed unary
+ virtual ::grpc::Status StreamedStore(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer< flatbuffers::grpc::Message<Monster>,flatbuffers::grpc::Message<Stat>>* server_unary_streamer) = 0;
+ };
+ typedef WithStreamedUnaryMethod_Store< Service > StreamedUnaryService;
+ template <class BaseClass>
+ class WithSplitStreamingMethod_Retrieve : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) { }
+ public:
+ WithSplitStreamingMethod_Retrieve() {
+ ::grpc::Service::MarkMethodStreamed(1,
+ new ::grpc::internal::SplitServerStreamingHandler< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>(std::bind(&WithSplitStreamingMethod_Retrieve<BaseClass>::StreamedRetrieve, this, std::placeholders::_1, std::placeholders::_2)));
+ }
+ ~WithSplitStreamingMethod_Retrieve() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable regular version of this method
+ ::grpc::Status Retrieve(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Stat>* /*request*/, ::grpc::ServerWriter< flatbuffers::grpc::Message<Monster>>* /*writer*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ // replace default version of method with split streamed
+ virtual ::grpc::Status StreamedRetrieve(::grpc::ServerContext* context, ::grpc::ServerSplitStreamer< flatbuffers::grpc::Message<Stat>,flatbuffers::grpc::Message<Monster>>* server_split_streamer) = 0;
+ };
+ typedef WithSplitStreamingMethod_Retrieve< Service > SplitStreamedService;
+ typedef WithStreamedUnaryMethod_Store< WithSplitStreamingMethod_Retrieve< Service > > StreamedService;
+};
+
+} // namespace Example
+} // namespace MyGame
+
+
+#endif // GRPC_monster_5ftest__INCLUDED
diff --git a/tests/monster_test_suffix/filesuffix_only/monster_test_suffix.h b/tests/monster_test_suffix/filesuffix_only/monster_test_suffix.h
new file mode 100644
index 0000000..deab77b
--- /dev/null
+++ b/tests/monster_test_suffix/filesuffix_only/monster_test_suffix.h
@@ -0,0 +1,4034 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+
+#ifndef FLATBUFFERS_GENERATED_MONSTERTEST_MYGAME_EXAMPLE_H_
+#define FLATBUFFERS_GENERATED_MONSTERTEST_MYGAME_EXAMPLE_H_
+
+#include "flatbuffers/flatbuffers.h"
+#include "flatbuffers/flexbuffers.h"
+#include "flatbuffers/flex_flat_util.h"
+
+// Ensure the included flatbuffers.h is the same version as when this file was
+// generated, otherwise it may not be compatible.
+static_assert(FLATBUFFERS_VERSION_MAJOR == 2 &&
+ FLATBUFFERS_VERSION_MINOR == 0 &&
+ FLATBUFFERS_VERSION_REVISION == 8,
+ "Non-compatible flatbuffers version included");
+
+namespace MyGame {
+
+struct InParentNamespace;
+struct InParentNamespaceBuilder;
+struct InParentNamespaceT;
+
+namespace Example2 {
+
+struct Monster;
+struct MonsterBuilder;
+struct MonsterT;
+
+} // namespace Example2
+
+namespace Example {
+
+struct Test;
+
+struct TestSimpleTableWithEnum;
+struct TestSimpleTableWithEnumBuilder;
+struct TestSimpleTableWithEnumT;
+
+struct Vec3;
+
+struct Ability;
+
+struct StructOfStructs;
+
+struct StructOfStructsOfStructs;
+
+struct Stat;
+struct StatBuilder;
+struct StatT;
+
+struct Referrable;
+struct ReferrableBuilder;
+struct ReferrableT;
+
+struct Monster;
+struct MonsterBuilder;
+struct MonsterT;
+
+struct TypeAliases;
+struct TypeAliasesBuilder;
+struct TypeAliasesT;
+
+} // namespace Example
+
+bool operator==(const InParentNamespaceT &lhs, const InParentNamespaceT &rhs);
+bool operator!=(const InParentNamespaceT &lhs, const InParentNamespaceT &rhs);
+namespace Example2 {
+
+bool operator==(const MonsterT &lhs, const MonsterT &rhs);
+bool operator!=(const MonsterT &lhs, const MonsterT &rhs);
+} // namespace Example2
+
+namespace Example {
+
+bool operator==(const Test &lhs, const Test &rhs);
+bool operator!=(const Test &lhs, const Test &rhs);
+bool operator==(const TestSimpleTableWithEnumT &lhs, const TestSimpleTableWithEnumT &rhs);
+bool operator!=(const TestSimpleTableWithEnumT &lhs, const TestSimpleTableWithEnumT &rhs);
+bool operator==(const Vec3 &lhs, const Vec3 &rhs);
+bool operator!=(const Vec3 &lhs, const Vec3 &rhs);
+bool operator==(const Ability &lhs, const Ability &rhs);
+bool operator!=(const Ability &lhs, const Ability &rhs);
+bool operator==(const StructOfStructs &lhs, const StructOfStructs &rhs);
+bool operator!=(const StructOfStructs &lhs, const StructOfStructs &rhs);
+bool operator==(const StructOfStructsOfStructs &lhs, const StructOfStructsOfStructs &rhs);
+bool operator!=(const StructOfStructsOfStructs &lhs, const StructOfStructsOfStructs &rhs);
+bool operator==(const StatT &lhs, const StatT &rhs);
+bool operator!=(const StatT &lhs, const StatT &rhs);
+bool operator==(const ReferrableT &lhs, const ReferrableT &rhs);
+bool operator!=(const ReferrableT &lhs, const ReferrableT &rhs);
+bool operator==(const MonsterT &lhs, const MonsterT &rhs);
+bool operator!=(const MonsterT &lhs, const MonsterT &rhs);
+bool operator==(const TypeAliasesT &lhs, const TypeAliasesT &rhs);
+bool operator!=(const TypeAliasesT &lhs, const TypeAliasesT &rhs);
+
+} // namespace Example
+
+inline const flatbuffers::TypeTable *InParentNamespaceTypeTable();
+
+namespace Example2 {
+
+inline const flatbuffers::TypeTable *MonsterTypeTable();
+
+} // namespace Example2
+
+namespace Example {
+
+inline const flatbuffers::TypeTable *TestTypeTable();
+
+inline const flatbuffers::TypeTable *TestSimpleTableWithEnumTypeTable();
+
+inline const flatbuffers::TypeTable *Vec3TypeTable();
+
+inline const flatbuffers::TypeTable *AbilityTypeTable();
+
+inline const flatbuffers::TypeTable *StructOfStructsTypeTable();
+
+inline const flatbuffers::TypeTable *StructOfStructsOfStructsTypeTable();
+
+inline const flatbuffers::TypeTable *StatTypeTable();
+
+inline const flatbuffers::TypeTable *ReferrableTypeTable();
+
+inline const flatbuffers::TypeTable *MonsterTypeTable();
+
+inline const flatbuffers::TypeTable *TypeAliasesTypeTable();
+
+/// Composite components of Monster color.
+enum Color : uint8_t {
+ Color_Red = 1,
+ /// \brief color Green
+ /// Green is bit_flag with value (1u << 1)
+ Color_Green = 2,
+ /// \brief color Blue (1u << 3)
+ Color_Blue = 8,
+ Color_NONE = 0,
+ Color_ANY = 11
+};
+
+inline const Color (&EnumValuesColor())[3] {
+ static const Color values[] = {
+ Color_Red,
+ Color_Green,
+ Color_Blue
+ };
+ return values;
+}
+
+inline const char * const *EnumNamesColor() {
+ static const char * const names[9] = {
+ "Red",
+ "Green",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "Blue",
+ nullptr
+ };
+ return names;
+}
+
+inline const char *EnumNameColor(Color e) {
+ if (flatbuffers::IsOutRange(e, Color_Red, Color_Blue)) return "";
+ const size_t index = static_cast<size_t>(e) - static_cast<size_t>(Color_Red);
+ return EnumNamesColor()[index];
+}
+
+enum Race : int8_t {
+ Race_None = -1,
+ Race_Human = 0,
+ Race_Dwarf = 1,
+ Race_Elf = 2,
+ Race_MIN = Race_None,
+ Race_MAX = Race_Elf
+};
+
+inline const Race (&EnumValuesRace())[4] {
+ static const Race values[] = {
+ Race_None,
+ Race_Human,
+ Race_Dwarf,
+ Race_Elf
+ };
+ return values;
+}
+
+inline const char * const *EnumNamesRace() {
+ static const char * const names[5] = {
+ "None",
+ "Human",
+ "Dwarf",
+ "Elf",
+ nullptr
+ };
+ return names;
+}
+
+inline const char *EnumNameRace(Race e) {
+ if (flatbuffers::IsOutRange(e, Race_None, Race_Elf)) return "";
+ const size_t index = static_cast<size_t>(e) - static_cast<size_t>(Race_None);
+ return EnumNamesRace()[index];
+}
+
+enum LongEnum : uint64_t {
+ LongEnum_LongOne = 2ULL,
+ LongEnum_LongTwo = 4ULL,
+ LongEnum_LongBig = 1099511627776ULL,
+ LongEnum_NONE = 0,
+ LongEnum_ANY = 1099511627782ULL
+};
+
+inline const LongEnum (&EnumValuesLongEnum())[3] {
+ static const LongEnum values[] = {
+ LongEnum_LongOne,
+ LongEnum_LongTwo,
+ LongEnum_LongBig
+ };
+ return values;
+}
+
+inline const char *EnumNameLongEnum(LongEnum e) {
+ switch (e) {
+ case LongEnum_LongOne: return "LongOne";
+ case LongEnum_LongTwo: return "LongTwo";
+ case LongEnum_LongBig: return "LongBig";
+ default: return "";
+ }
+}
+
+enum Any : uint8_t {
+ Any_NONE = 0,
+ Any_Monster = 1,
+ Any_TestSimpleTableWithEnum = 2,
+ Any_MyGame_Example2_Monster = 3,
+ Any_MIN = Any_NONE,
+ Any_MAX = Any_MyGame_Example2_Monster
+};
+
+inline const Any (&EnumValuesAny())[4] {
+ static const Any values[] = {
+ Any_NONE,
+ Any_Monster,
+ Any_TestSimpleTableWithEnum,
+ Any_MyGame_Example2_Monster
+ };
+ return values;
+}
+
+inline const char * const *EnumNamesAny() {
+ static const char * const names[5] = {
+ "NONE",
+ "Monster",
+ "TestSimpleTableWithEnum",
+ "MyGame_Example2_Monster",
+ nullptr
+ };
+ return names;
+}
+
+inline const char *EnumNameAny(Any e) {
+ if (flatbuffers::IsOutRange(e, Any_NONE, Any_MyGame_Example2_Monster)) return "";
+ const size_t index = static_cast<size_t>(e);
+ return EnumNamesAny()[index];
+}
+
+template<typename T> struct AnyTraits {
+ static const Any enum_value = Any_NONE;
+};
+
+template<> struct AnyTraits<MyGame::Example::Monster> {
+ static const Any enum_value = Any_Monster;
+};
+
+template<> struct AnyTraits<MyGame::Example::TestSimpleTableWithEnum> {
+ static const Any enum_value = Any_TestSimpleTableWithEnum;
+};
+
+template<> struct AnyTraits<MyGame::Example2::Monster> {
+ static const Any enum_value = Any_MyGame_Example2_Monster;
+};
+
+template<typename T> struct AnyUnionTraits {
+ static const Any enum_value = Any_NONE;
+};
+
+template<> struct AnyUnionTraits<MyGame::Example::MonsterT> {
+ static const Any enum_value = Any_Monster;
+};
+
+template<> struct AnyUnionTraits<MyGame::Example::TestSimpleTableWithEnumT> {
+ static const Any enum_value = Any_TestSimpleTableWithEnum;
+};
+
+template<> struct AnyUnionTraits<MyGame::Example2::MonsterT> {
+ static const Any enum_value = Any_MyGame_Example2_Monster;
+};
+
+struct AnyUnion {
+ Any type;
+ void *value;
+
+ AnyUnion() : type(Any_NONE), value(nullptr) {}
+ AnyUnion(AnyUnion&& u) FLATBUFFERS_NOEXCEPT :
+ type(Any_NONE), value(nullptr)
+ { std::swap(type, u.type); std::swap(value, u.value); }
+ AnyUnion(const AnyUnion &);
+ AnyUnion &operator=(const AnyUnion &u)
+ { AnyUnion t(u); std::swap(type, t.type); std::swap(value, t.value); return *this; }
+ AnyUnion &operator=(AnyUnion &&u) FLATBUFFERS_NOEXCEPT
+ { std::swap(type, u.type); std::swap(value, u.value); return *this; }
+ ~AnyUnion() { Reset(); }
+
+ void Reset();
+
+ template <typename T>
+ void Set(T&& val) {
+ typedef typename std::remove_reference<T>::type RT;
+ Reset();
+ type = AnyUnionTraits<RT>::enum_value;
+ if (type != Any_NONE) {
+ value = new RT(std::forward<T>(val));
+ }
+ }
+
+ static void *UnPack(const void *obj, Any type, const flatbuffers::resolver_function_t *resolver);
+ flatbuffers::Offset<void> Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const;
+
+ MyGame::Example::MonsterT *AsMonster() {
+ return type == Any_Monster ?
+ reinterpret_cast<MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+ const MyGame::Example::MonsterT *AsMonster() const {
+ return type == Any_Monster ?
+ reinterpret_cast<const MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+ MyGame::Example::TestSimpleTableWithEnumT *AsTestSimpleTableWithEnum() {
+ return type == Any_TestSimpleTableWithEnum ?
+ reinterpret_cast<MyGame::Example::TestSimpleTableWithEnumT *>(value) : nullptr;
+ }
+ const MyGame::Example::TestSimpleTableWithEnumT *AsTestSimpleTableWithEnum() const {
+ return type == Any_TestSimpleTableWithEnum ?
+ reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnumT *>(value) : nullptr;
+ }
+ MyGame::Example2::MonsterT *AsMyGame_Example2_Monster() {
+ return type == Any_MyGame_Example2_Monster ?
+ reinterpret_cast<MyGame::Example2::MonsterT *>(value) : nullptr;
+ }
+ const MyGame::Example2::MonsterT *AsMyGame_Example2_Monster() const {
+ return type == Any_MyGame_Example2_Monster ?
+ reinterpret_cast<const MyGame::Example2::MonsterT *>(value) : nullptr;
+ }
+};
+
+
+inline bool operator==(const AnyUnion &lhs, const AnyUnion &rhs) {
+ if (lhs.type != rhs.type) return false;
+ switch (lhs.type) {
+ case Any_NONE: {
+ return true;
+ }
+ case Any_Monster: {
+ return *(reinterpret_cast<const MyGame::Example::MonsterT *>(lhs.value)) ==
+ *(reinterpret_cast<const MyGame::Example::MonsterT *>(rhs.value));
+ }
+ case Any_TestSimpleTableWithEnum: {
+ return *(reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnumT *>(lhs.value)) ==
+ *(reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnumT *>(rhs.value));
+ }
+ case Any_MyGame_Example2_Monster: {
+ return *(reinterpret_cast<const MyGame::Example2::MonsterT *>(lhs.value)) ==
+ *(reinterpret_cast<const MyGame::Example2::MonsterT *>(rhs.value));
+ }
+ default: {
+ return false;
+ }
+ }
+}
+
+inline bool operator!=(const AnyUnion &lhs, const AnyUnion &rhs) {
+ return !(lhs == rhs);
+}
+
+bool VerifyAny(flatbuffers::Verifier &verifier, const void *obj, Any type);
+bool VerifyAnyVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types);
+
+enum AnyUniqueAliases : uint8_t {
+ AnyUniqueAliases_NONE = 0,
+ AnyUniqueAliases_M = 1,
+ AnyUniqueAliases_TS = 2,
+ AnyUniqueAliases_M2 = 3,
+ AnyUniqueAliases_MIN = AnyUniqueAliases_NONE,
+ AnyUniqueAliases_MAX = AnyUniqueAliases_M2
+};
+
+inline const AnyUniqueAliases (&EnumValuesAnyUniqueAliases())[4] {
+ static const AnyUniqueAliases values[] = {
+ AnyUniqueAliases_NONE,
+ AnyUniqueAliases_M,
+ AnyUniqueAliases_TS,
+ AnyUniqueAliases_M2
+ };
+ return values;
+}
+
+inline const char * const *EnumNamesAnyUniqueAliases() {
+ static const char * const names[5] = {
+ "NONE",
+ "M",
+ "TS",
+ "M2",
+ nullptr
+ };
+ return names;
+}
+
+inline const char *EnumNameAnyUniqueAliases(AnyUniqueAliases e) {
+ if (flatbuffers::IsOutRange(e, AnyUniqueAliases_NONE, AnyUniqueAliases_M2)) return "";
+ const size_t index = static_cast<size_t>(e);
+ return EnumNamesAnyUniqueAliases()[index];
+}
+
+template<typename T> struct AnyUniqueAliasesTraits {
+ static const AnyUniqueAliases enum_value = AnyUniqueAliases_NONE;
+};
+
+template<> struct AnyUniqueAliasesTraits<MyGame::Example::Monster> {
+ static const AnyUniqueAliases enum_value = AnyUniqueAliases_M;
+};
+
+template<> struct AnyUniqueAliasesTraits<MyGame::Example::TestSimpleTableWithEnum> {
+ static const AnyUniqueAliases enum_value = AnyUniqueAliases_TS;
+};
+
+template<> struct AnyUniqueAliasesTraits<MyGame::Example2::Monster> {
+ static const AnyUniqueAliases enum_value = AnyUniqueAliases_M2;
+};
+
+template<typename T> struct AnyUniqueAliasesUnionTraits {
+ static const AnyUniqueAliases enum_value = AnyUniqueAliases_NONE;
+};
+
+template<> struct AnyUniqueAliasesUnionTraits<MyGame::Example::MonsterT> {
+ static const AnyUniqueAliases enum_value = AnyUniqueAliases_M;
+};
+
+template<> struct AnyUniqueAliasesUnionTraits<MyGame::Example::TestSimpleTableWithEnumT> {
+ static const AnyUniqueAliases enum_value = AnyUniqueAliases_TS;
+};
+
+template<> struct AnyUniqueAliasesUnionTraits<MyGame::Example2::MonsterT> {
+ static const AnyUniqueAliases enum_value = AnyUniqueAliases_M2;
+};
+
+struct AnyUniqueAliasesUnion {
+ AnyUniqueAliases type;
+ void *value;
+
+ AnyUniqueAliasesUnion() : type(AnyUniqueAliases_NONE), value(nullptr) {}
+ AnyUniqueAliasesUnion(AnyUniqueAliasesUnion&& u) FLATBUFFERS_NOEXCEPT :
+ type(AnyUniqueAliases_NONE), value(nullptr)
+ { std::swap(type, u.type); std::swap(value, u.value); }
+ AnyUniqueAliasesUnion(const AnyUniqueAliasesUnion &);
+ AnyUniqueAliasesUnion &operator=(const AnyUniqueAliasesUnion &u)
+ { AnyUniqueAliasesUnion t(u); std::swap(type, t.type); std::swap(value, t.value); return *this; }
+ AnyUniqueAliasesUnion &operator=(AnyUniqueAliasesUnion &&u) FLATBUFFERS_NOEXCEPT
+ { std::swap(type, u.type); std::swap(value, u.value); return *this; }
+ ~AnyUniqueAliasesUnion() { Reset(); }
+
+ void Reset();
+
+ template <typename T>
+ void Set(T&& val) {
+ typedef typename std::remove_reference<T>::type RT;
+ Reset();
+ type = AnyUniqueAliasesUnionTraits<RT>::enum_value;
+ if (type != AnyUniqueAliases_NONE) {
+ value = new RT(std::forward<T>(val));
+ }
+ }
+
+ static void *UnPack(const void *obj, AnyUniqueAliases type, const flatbuffers::resolver_function_t *resolver);
+ flatbuffers::Offset<void> Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const;
+
+ MyGame::Example::MonsterT *AsM() {
+ return type == AnyUniqueAliases_M ?
+ reinterpret_cast<MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+ const MyGame::Example::MonsterT *AsM() const {
+ return type == AnyUniqueAliases_M ?
+ reinterpret_cast<const MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+ MyGame::Example::TestSimpleTableWithEnumT *AsTS() {
+ return type == AnyUniqueAliases_TS ?
+ reinterpret_cast<MyGame::Example::TestSimpleTableWithEnumT *>(value) : nullptr;
+ }
+ const MyGame::Example::TestSimpleTableWithEnumT *AsTS() const {
+ return type == AnyUniqueAliases_TS ?
+ reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnumT *>(value) : nullptr;
+ }
+ MyGame::Example2::MonsterT *AsM2() {
+ return type == AnyUniqueAliases_M2 ?
+ reinterpret_cast<MyGame::Example2::MonsterT *>(value) : nullptr;
+ }
+ const MyGame::Example2::MonsterT *AsM2() const {
+ return type == AnyUniqueAliases_M2 ?
+ reinterpret_cast<const MyGame::Example2::MonsterT *>(value) : nullptr;
+ }
+};
+
+
+inline bool operator==(const AnyUniqueAliasesUnion &lhs, const AnyUniqueAliasesUnion &rhs) {
+ if (lhs.type != rhs.type) return false;
+ switch (lhs.type) {
+ case AnyUniqueAliases_NONE: {
+ return true;
+ }
+ case AnyUniqueAliases_M: {
+ return *(reinterpret_cast<const MyGame::Example::MonsterT *>(lhs.value)) ==
+ *(reinterpret_cast<const MyGame::Example::MonsterT *>(rhs.value));
+ }
+ case AnyUniqueAliases_TS: {
+ return *(reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnumT *>(lhs.value)) ==
+ *(reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnumT *>(rhs.value));
+ }
+ case AnyUniqueAliases_M2: {
+ return *(reinterpret_cast<const MyGame::Example2::MonsterT *>(lhs.value)) ==
+ *(reinterpret_cast<const MyGame::Example2::MonsterT *>(rhs.value));
+ }
+ default: {
+ return false;
+ }
+ }
+}
+
+inline bool operator!=(const AnyUniqueAliasesUnion &lhs, const AnyUniqueAliasesUnion &rhs) {
+ return !(lhs == rhs);
+}
+
+bool VerifyAnyUniqueAliases(flatbuffers::Verifier &verifier, const void *obj, AnyUniqueAliases type);
+bool VerifyAnyUniqueAliasesVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types);
+
+enum AnyAmbiguousAliases : uint8_t {
+ AnyAmbiguousAliases_NONE = 0,
+ AnyAmbiguousAliases_M1 = 1,
+ AnyAmbiguousAliases_M2 = 2,
+ AnyAmbiguousAliases_M3 = 3,
+ AnyAmbiguousAliases_MIN = AnyAmbiguousAliases_NONE,
+ AnyAmbiguousAliases_MAX = AnyAmbiguousAliases_M3
+};
+
+inline const AnyAmbiguousAliases (&EnumValuesAnyAmbiguousAliases())[4] {
+ static const AnyAmbiguousAliases values[] = {
+ AnyAmbiguousAliases_NONE,
+ AnyAmbiguousAliases_M1,
+ AnyAmbiguousAliases_M2,
+ AnyAmbiguousAliases_M3
+ };
+ return values;
+}
+
+inline const char * const *EnumNamesAnyAmbiguousAliases() {
+ static const char * const names[5] = {
+ "NONE",
+ "M1",
+ "M2",
+ "M3",
+ nullptr
+ };
+ return names;
+}
+
+inline const char *EnumNameAnyAmbiguousAliases(AnyAmbiguousAliases e) {
+ if (flatbuffers::IsOutRange(e, AnyAmbiguousAliases_NONE, AnyAmbiguousAliases_M3)) return "";
+ const size_t index = static_cast<size_t>(e);
+ return EnumNamesAnyAmbiguousAliases()[index];
+}
+
+struct AnyAmbiguousAliasesUnion {
+ AnyAmbiguousAliases type;
+ void *value;
+
+ AnyAmbiguousAliasesUnion() : type(AnyAmbiguousAliases_NONE), value(nullptr) {}
+ AnyAmbiguousAliasesUnion(AnyAmbiguousAliasesUnion&& u) FLATBUFFERS_NOEXCEPT :
+ type(AnyAmbiguousAliases_NONE), value(nullptr)
+ { std::swap(type, u.type); std::swap(value, u.value); }
+ AnyAmbiguousAliasesUnion(const AnyAmbiguousAliasesUnion &);
+ AnyAmbiguousAliasesUnion &operator=(const AnyAmbiguousAliasesUnion &u)
+ { AnyAmbiguousAliasesUnion t(u); std::swap(type, t.type); std::swap(value, t.value); return *this; }
+ AnyAmbiguousAliasesUnion &operator=(AnyAmbiguousAliasesUnion &&u) FLATBUFFERS_NOEXCEPT
+ { std::swap(type, u.type); std::swap(value, u.value); return *this; }
+ ~AnyAmbiguousAliasesUnion() { Reset(); }
+
+ void Reset();
+
+ static void *UnPack(const void *obj, AnyAmbiguousAliases type, const flatbuffers::resolver_function_t *resolver);
+ flatbuffers::Offset<void> Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const;
+
+ MyGame::Example::MonsterT *AsM1() {
+ return type == AnyAmbiguousAliases_M1 ?
+ reinterpret_cast<MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+ const MyGame::Example::MonsterT *AsM1() const {
+ return type == AnyAmbiguousAliases_M1 ?
+ reinterpret_cast<const MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+ MyGame::Example::MonsterT *AsM2() {
+ return type == AnyAmbiguousAliases_M2 ?
+ reinterpret_cast<MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+ const MyGame::Example::MonsterT *AsM2() const {
+ return type == AnyAmbiguousAliases_M2 ?
+ reinterpret_cast<const MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+ MyGame::Example::MonsterT *AsM3() {
+ return type == AnyAmbiguousAliases_M3 ?
+ reinterpret_cast<MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+ const MyGame::Example::MonsterT *AsM3() const {
+ return type == AnyAmbiguousAliases_M3 ?
+ reinterpret_cast<const MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+};
+
+
+inline bool operator==(const AnyAmbiguousAliasesUnion &lhs, const AnyAmbiguousAliasesUnion &rhs) {
+ if (lhs.type != rhs.type) return false;
+ switch (lhs.type) {
+ case AnyAmbiguousAliases_NONE: {
+ return true;
+ }
+ case AnyAmbiguousAliases_M1: {
+ return *(reinterpret_cast<const MyGame::Example::MonsterT *>(lhs.value)) ==
+ *(reinterpret_cast<const MyGame::Example::MonsterT *>(rhs.value));
+ }
+ case AnyAmbiguousAliases_M2: {
+ return *(reinterpret_cast<const MyGame::Example::MonsterT *>(lhs.value)) ==
+ *(reinterpret_cast<const MyGame::Example::MonsterT *>(rhs.value));
+ }
+ case AnyAmbiguousAliases_M3: {
+ return *(reinterpret_cast<const MyGame::Example::MonsterT *>(lhs.value)) ==
+ *(reinterpret_cast<const MyGame::Example::MonsterT *>(rhs.value));
+ }
+ default: {
+ return false;
+ }
+ }
+}
+
+inline bool operator!=(const AnyAmbiguousAliasesUnion &lhs, const AnyAmbiguousAliasesUnion &rhs) {
+ return !(lhs == rhs);
+}
+
+bool VerifyAnyAmbiguousAliases(flatbuffers::Verifier &verifier, const void *obj, AnyAmbiguousAliases type);
+bool VerifyAnyAmbiguousAliasesVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types);
+
+FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(2) Test FLATBUFFERS_FINAL_CLASS {
+ private:
+ int16_t a_;
+ int8_t b_;
+ int8_t padding0__;
+
+ public:
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return TestTypeTable();
+ }
+ Test()
+ : a_(0),
+ b_(0),
+ padding0__(0) {
+ (void)padding0__;
+ }
+ Test(int16_t _a, int8_t _b)
+ : a_(flatbuffers::EndianScalar(_a)),
+ b_(flatbuffers::EndianScalar(_b)),
+ padding0__(0) {
+ (void)padding0__;
+ }
+ int16_t a() const {
+ return flatbuffers::EndianScalar(a_);
+ }
+ void mutate_a(int16_t _a) {
+ flatbuffers::WriteScalar(&a_, _a);
+ }
+ int8_t b() const {
+ return flatbuffers::EndianScalar(b_);
+ }
+ void mutate_b(int8_t _b) {
+ flatbuffers::WriteScalar(&b_, _b);
+ }
+};
+FLATBUFFERS_STRUCT_END(Test, 4);
+
+inline bool operator==(const Test &lhs, const Test &rhs) {
+ return
+ (lhs.a() == rhs.a()) &&
+ (lhs.b() == rhs.b());
+}
+
+inline bool operator!=(const Test &lhs, const Test &rhs) {
+ return !(lhs == rhs);
+}
+
+
+FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) Vec3 FLATBUFFERS_FINAL_CLASS {
+ private:
+ float x_;
+ float y_;
+ float z_;
+ int32_t padding0__;
+ double test1_;
+ uint8_t test2_;
+ int8_t padding1__;
+ MyGame::Example::Test test3_;
+ int16_t padding2__;
+
+ public:
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return Vec3TypeTable();
+ }
+ Vec3()
+ : x_(0),
+ y_(0),
+ z_(0),
+ padding0__(0),
+ test1_(0),
+ test2_(0),
+ padding1__(0),
+ test3_(),
+ padding2__(0) {
+ (void)padding0__;
+ (void)padding1__;
+ (void)padding2__;
+ }
+ Vec3(float _x, float _y, float _z, double _test1, MyGame::Example::Color _test2, const MyGame::Example::Test &_test3)
+ : x_(flatbuffers::EndianScalar(_x)),
+ y_(flatbuffers::EndianScalar(_y)),
+ z_(flatbuffers::EndianScalar(_z)),
+ padding0__(0),
+ test1_(flatbuffers::EndianScalar(_test1)),
+ test2_(flatbuffers::EndianScalar(static_cast<uint8_t>(_test2))),
+ padding1__(0),
+ test3_(_test3),
+ padding2__(0) {
+ (void)padding0__;
+ (void)padding1__;
+ (void)padding2__;
+ }
+ float x() const {
+ return flatbuffers::EndianScalar(x_);
+ }
+ void mutate_x(float _x) {
+ flatbuffers::WriteScalar(&x_, _x);
+ }
+ float y() const {
+ return flatbuffers::EndianScalar(y_);
+ }
+ void mutate_y(float _y) {
+ flatbuffers::WriteScalar(&y_, _y);
+ }
+ float z() const {
+ return flatbuffers::EndianScalar(z_);
+ }
+ void mutate_z(float _z) {
+ flatbuffers::WriteScalar(&z_, _z);
+ }
+ double test1() const {
+ return flatbuffers::EndianScalar(test1_);
+ }
+ void mutate_test1(double _test1) {
+ flatbuffers::WriteScalar(&test1_, _test1);
+ }
+ MyGame::Example::Color test2() const {
+ return static_cast<MyGame::Example::Color>(flatbuffers::EndianScalar(test2_));
+ }
+ void mutate_test2(MyGame::Example::Color _test2) {
+ flatbuffers::WriteScalar(&test2_, static_cast<uint8_t>(_test2));
+ }
+ const MyGame::Example::Test &test3() const {
+ return test3_;
+ }
+ MyGame::Example::Test &mutable_test3() {
+ return test3_;
+ }
+};
+FLATBUFFERS_STRUCT_END(Vec3, 32);
+
+inline bool operator==(const Vec3 &lhs, const Vec3 &rhs) {
+ return
+ (lhs.x() == rhs.x()) &&
+ (lhs.y() == rhs.y()) &&
+ (lhs.z() == rhs.z()) &&
+ (lhs.test1() == rhs.test1()) &&
+ (lhs.test2() == rhs.test2()) &&
+ (lhs.test3() == rhs.test3());
+}
+
+inline bool operator!=(const Vec3 &lhs, const Vec3 &rhs) {
+ return !(lhs == rhs);
+}
+
+
+FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Ability FLATBUFFERS_FINAL_CLASS {
+ private:
+ uint32_t id_;
+ uint32_t distance_;
+
+ public:
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return AbilityTypeTable();
+ }
+ Ability()
+ : id_(0),
+ distance_(0) {
+ }
+ Ability(uint32_t _id, uint32_t _distance)
+ : id_(flatbuffers::EndianScalar(_id)),
+ distance_(flatbuffers::EndianScalar(_distance)) {
+ }
+ uint32_t id() const {
+ return flatbuffers::EndianScalar(id_);
+ }
+ void mutate_id(uint32_t _id) {
+ flatbuffers::WriteScalar(&id_, _id);
+ }
+ bool KeyCompareLessThan(const Ability *o) const {
+ return id() < o->id();
+ }
+ int KeyCompareWithValue(uint32_t _id) const {
+ return static_cast<int>(id() > _id) - static_cast<int>(id() < _id);
+ }
+ uint32_t distance() const {
+ return flatbuffers::EndianScalar(distance_);
+ }
+ void mutate_distance(uint32_t _distance) {
+ flatbuffers::WriteScalar(&distance_, _distance);
+ }
+};
+FLATBUFFERS_STRUCT_END(Ability, 8);
+
+inline bool operator==(const Ability &lhs, const Ability &rhs) {
+ return
+ (lhs.id() == rhs.id()) &&
+ (lhs.distance() == rhs.distance());
+}
+
+inline bool operator!=(const Ability &lhs, const Ability &rhs) {
+ return !(lhs == rhs);
+}
+
+
+FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) StructOfStructs FLATBUFFERS_FINAL_CLASS {
+ private:
+ MyGame::Example::Ability a_;
+ MyGame::Example::Test b_;
+ MyGame::Example::Ability c_;
+
+ public:
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return StructOfStructsTypeTable();
+ }
+ StructOfStructs()
+ : a_(),
+ b_(),
+ c_() {
+ }
+ StructOfStructs(const MyGame::Example::Ability &_a, const MyGame::Example::Test &_b, const MyGame::Example::Ability &_c)
+ : a_(_a),
+ b_(_b),
+ c_(_c) {
+ }
+ const MyGame::Example::Ability &a() const {
+ return a_;
+ }
+ MyGame::Example::Ability &mutable_a() {
+ return a_;
+ }
+ const MyGame::Example::Test &b() const {
+ return b_;
+ }
+ MyGame::Example::Test &mutable_b() {
+ return b_;
+ }
+ const MyGame::Example::Ability &c() const {
+ return c_;
+ }
+ MyGame::Example::Ability &mutable_c() {
+ return c_;
+ }
+};
+FLATBUFFERS_STRUCT_END(StructOfStructs, 20);
+
+inline bool operator==(const StructOfStructs &lhs, const StructOfStructs &rhs) {
+ return
+ (lhs.a() == rhs.a()) &&
+ (lhs.b() == rhs.b()) &&
+ (lhs.c() == rhs.c());
+}
+
+inline bool operator!=(const StructOfStructs &lhs, const StructOfStructs &rhs) {
+ return !(lhs == rhs);
+}
+
+
+FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) StructOfStructsOfStructs FLATBUFFERS_FINAL_CLASS {
+ private:
+ MyGame::Example::StructOfStructs a_;
+
+ public:
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return StructOfStructsOfStructsTypeTable();
+ }
+ StructOfStructsOfStructs()
+ : a_() {
+ }
+ StructOfStructsOfStructs(const MyGame::Example::StructOfStructs &_a)
+ : a_(_a) {
+ }
+ const MyGame::Example::StructOfStructs &a() const {
+ return a_;
+ }
+ MyGame::Example::StructOfStructs &mutable_a() {
+ return a_;
+ }
+};
+FLATBUFFERS_STRUCT_END(StructOfStructsOfStructs, 20);
+
+inline bool operator==(const StructOfStructsOfStructs &lhs, const StructOfStructsOfStructs &rhs) {
+ return
+ (lhs.a() == rhs.a());
+}
+
+inline bool operator!=(const StructOfStructsOfStructs &lhs, const StructOfStructsOfStructs &rhs) {
+ return !(lhs == rhs);
+}
+
+
+} // namespace Example
+
+struct InParentNamespaceT : public flatbuffers::NativeTable {
+ typedef InParentNamespace TableType;
+};
+
+struct InParentNamespace FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
+ typedef InParentNamespaceT NativeTableType;
+ typedef InParentNamespaceBuilder Builder;
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return InParentNamespaceTypeTable();
+ }
+ bool Verify(flatbuffers::Verifier &verifier) const {
+ return VerifyTableStart(verifier) &&
+ verifier.EndTable();
+ }
+ InParentNamespaceT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ void UnPackTo(InParentNamespaceT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ static flatbuffers::Offset<InParentNamespace> Pack(flatbuffers::FlatBufferBuilder &_fbb, const InParentNamespaceT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+};
+
+struct InParentNamespaceBuilder {
+ typedef InParentNamespace Table;
+ flatbuffers::FlatBufferBuilder &fbb_;
+ flatbuffers::uoffset_t start_;
+ explicit InParentNamespaceBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
+ flatbuffers::Offset<InParentNamespace> Finish() {
+ const auto end = fbb_.EndTable(start_);
+ auto o = flatbuffers::Offset<InParentNamespace>(end);
+ return o;
+ }
+};
+
+inline flatbuffers::Offset<InParentNamespace> CreateInParentNamespace(
+ flatbuffers::FlatBufferBuilder &_fbb) {
+ InParentNamespaceBuilder builder_(_fbb);
+ return builder_.Finish();
+}
+
+flatbuffers::Offset<InParentNamespace> CreateInParentNamespace(flatbuffers::FlatBufferBuilder &_fbb, const InParentNamespaceT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+
+namespace Example2 {
+
+struct MonsterT : public flatbuffers::NativeTable {
+ typedef Monster TableType;
+};
+
+struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
+ typedef MonsterT NativeTableType;
+ typedef MonsterBuilder Builder;
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return MonsterTypeTable();
+ }
+ bool Verify(flatbuffers::Verifier &verifier) const {
+ return VerifyTableStart(verifier) &&
+ verifier.EndTable();
+ }
+ MonsterT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ void UnPackTo(MonsterT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ static flatbuffers::Offset<Monster> Pack(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+};
+
+struct MonsterBuilder {
+ typedef Monster Table;
+ flatbuffers::FlatBufferBuilder &fbb_;
+ flatbuffers::uoffset_t start_;
+ explicit MonsterBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
+ flatbuffers::Offset<Monster> Finish() {
+ const auto end = fbb_.EndTable(start_);
+ auto o = flatbuffers::Offset<Monster>(end);
+ return o;
+ }
+};
+
+inline flatbuffers::Offset<Monster> CreateMonster(
+ flatbuffers::FlatBufferBuilder &_fbb) {
+ MonsterBuilder builder_(_fbb);
+ return builder_.Finish();
+}
+
+flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+
+} // namespace Example2
+
+namespace Example {
+
+struct TestSimpleTableWithEnumT : public flatbuffers::NativeTable {
+ typedef TestSimpleTableWithEnum TableType;
+ MyGame::Example::Color color = MyGame::Example::Color_Green;
+};
+
+struct TestSimpleTableWithEnum FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
+ typedef TestSimpleTableWithEnumT NativeTableType;
+ typedef TestSimpleTableWithEnumBuilder Builder;
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return TestSimpleTableWithEnumTypeTable();
+ }
+ enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
+ VT_COLOR = 4
+ };
+ MyGame::Example::Color color() const {
+ return static_cast<MyGame::Example::Color>(GetField<uint8_t>(VT_COLOR, 2));
+ }
+ bool mutate_color(MyGame::Example::Color _color = static_cast<MyGame::Example::Color>(2)) {
+ return SetField<uint8_t>(VT_COLOR, static_cast<uint8_t>(_color), 2);
+ }
+ bool Verify(flatbuffers::Verifier &verifier) const {
+ return VerifyTableStart(verifier) &&
+ VerifyField<uint8_t>(verifier, VT_COLOR, 1) &&
+ verifier.EndTable();
+ }
+ TestSimpleTableWithEnumT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ void UnPackTo(TestSimpleTableWithEnumT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ static flatbuffers::Offset<TestSimpleTableWithEnum> Pack(flatbuffers::FlatBufferBuilder &_fbb, const TestSimpleTableWithEnumT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+};
+
+struct TestSimpleTableWithEnumBuilder {
+ typedef TestSimpleTableWithEnum Table;
+ flatbuffers::FlatBufferBuilder &fbb_;
+ flatbuffers::uoffset_t start_;
+ void add_color(MyGame::Example::Color color) {
+ fbb_.AddElement<uint8_t>(TestSimpleTableWithEnum::VT_COLOR, static_cast<uint8_t>(color), 2);
+ }
+ explicit TestSimpleTableWithEnumBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
+ flatbuffers::Offset<TestSimpleTableWithEnum> Finish() {
+ const auto end = fbb_.EndTable(start_);
+ auto o = flatbuffers::Offset<TestSimpleTableWithEnum>(end);
+ return o;
+ }
+};
+
+inline flatbuffers::Offset<TestSimpleTableWithEnum> CreateTestSimpleTableWithEnum(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ MyGame::Example::Color color = MyGame::Example::Color_Green) {
+ TestSimpleTableWithEnumBuilder builder_(_fbb);
+ builder_.add_color(color);
+ return builder_.Finish();
+}
+
+flatbuffers::Offset<TestSimpleTableWithEnum> CreateTestSimpleTableWithEnum(flatbuffers::FlatBufferBuilder &_fbb, const TestSimpleTableWithEnumT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+
+struct StatT : public flatbuffers::NativeTable {
+ typedef Stat TableType;
+ std::string id{};
+ int64_t val = 0;
+ uint16_t count = 0;
+};
+
+struct Stat FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
+ typedef StatT NativeTableType;
+ typedef StatBuilder Builder;
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return StatTypeTable();
+ }
+ enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
+ VT_ID = 4,
+ VT_VAL = 6,
+ VT_COUNT = 8
+ };
+ const flatbuffers::String *id() const {
+ return GetPointer<const flatbuffers::String *>(VT_ID);
+ }
+ flatbuffers::String *mutable_id() {
+ return GetPointer<flatbuffers::String *>(VT_ID);
+ }
+ int64_t val() const {
+ return GetField<int64_t>(VT_VAL, 0);
+ }
+ bool mutate_val(int64_t _val = 0) {
+ return SetField<int64_t>(VT_VAL, _val, 0);
+ }
+ uint16_t count() const {
+ return GetField<uint16_t>(VT_COUNT, 0);
+ }
+ bool mutate_count(uint16_t _count = 0) {
+ return SetField<uint16_t>(VT_COUNT, _count, 0);
+ }
+ bool KeyCompareLessThan(const Stat *o) const {
+ return count() < o->count();
+ }
+ int KeyCompareWithValue(uint16_t _count) const {
+ return static_cast<int>(count() > _count) - static_cast<int>(count() < _count);
+ }
+ bool Verify(flatbuffers::Verifier &verifier) const {
+ return VerifyTableStart(verifier) &&
+ VerifyOffset(verifier, VT_ID) &&
+ verifier.VerifyString(id()) &&
+ VerifyField<int64_t>(verifier, VT_VAL, 8) &&
+ VerifyField<uint16_t>(verifier, VT_COUNT, 2) &&
+ verifier.EndTable();
+ }
+ StatT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ void UnPackTo(StatT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ static flatbuffers::Offset<Stat> Pack(flatbuffers::FlatBufferBuilder &_fbb, const StatT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+};
+
+struct StatBuilder {
+ typedef Stat Table;
+ flatbuffers::FlatBufferBuilder &fbb_;
+ flatbuffers::uoffset_t start_;
+ void add_id(flatbuffers::Offset<flatbuffers::String> id) {
+ fbb_.AddOffset(Stat::VT_ID, id);
+ }
+ void add_val(int64_t val) {
+ fbb_.AddElement<int64_t>(Stat::VT_VAL, val, 0);
+ }
+ void add_count(uint16_t count) {
+ fbb_.AddElement<uint16_t>(Stat::VT_COUNT, count, 0);
+ }
+ explicit StatBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
+ flatbuffers::Offset<Stat> Finish() {
+ const auto end = fbb_.EndTable(start_);
+ auto o = flatbuffers::Offset<Stat>(end);
+ return o;
+ }
+};
+
+inline flatbuffers::Offset<Stat> CreateStat(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ flatbuffers::Offset<flatbuffers::String> id = 0,
+ int64_t val = 0,
+ uint16_t count = 0) {
+ StatBuilder builder_(_fbb);
+ builder_.add_val(val);
+ builder_.add_id(id);
+ builder_.add_count(count);
+ return builder_.Finish();
+}
+
+inline flatbuffers::Offset<Stat> CreateStatDirect(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ const char *id = nullptr,
+ int64_t val = 0,
+ uint16_t count = 0) {
+ auto id__ = id ? _fbb.CreateString(id) : 0;
+ return MyGame::Example::CreateStat(
+ _fbb,
+ id__,
+ val,
+ count);
+}
+
+flatbuffers::Offset<Stat> CreateStat(flatbuffers::FlatBufferBuilder &_fbb, const StatT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+
+struct ReferrableT : public flatbuffers::NativeTable {
+ typedef Referrable TableType;
+ uint64_t id = 0;
+};
+
+struct Referrable FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
+ typedef ReferrableT NativeTableType;
+ typedef ReferrableBuilder Builder;
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return ReferrableTypeTable();
+ }
+ enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
+ VT_ID = 4
+ };
+ uint64_t id() const {
+ return GetField<uint64_t>(VT_ID, 0);
+ }
+ bool mutate_id(uint64_t _id = 0) {
+ return SetField<uint64_t>(VT_ID, _id, 0);
+ }
+ bool KeyCompareLessThan(const Referrable *o) const {
+ return id() < o->id();
+ }
+ int KeyCompareWithValue(uint64_t _id) const {
+ return static_cast<int>(id() > _id) - static_cast<int>(id() < _id);
+ }
+ bool Verify(flatbuffers::Verifier &verifier) const {
+ return VerifyTableStart(verifier) &&
+ VerifyField<uint64_t>(verifier, VT_ID, 8) &&
+ verifier.EndTable();
+ }
+ ReferrableT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ void UnPackTo(ReferrableT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ static flatbuffers::Offset<Referrable> Pack(flatbuffers::FlatBufferBuilder &_fbb, const ReferrableT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+};
+
+struct ReferrableBuilder {
+ typedef Referrable Table;
+ flatbuffers::FlatBufferBuilder &fbb_;
+ flatbuffers::uoffset_t start_;
+ void add_id(uint64_t id) {
+ fbb_.AddElement<uint64_t>(Referrable::VT_ID, id, 0);
+ }
+ explicit ReferrableBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
+ flatbuffers::Offset<Referrable> Finish() {
+ const auto end = fbb_.EndTable(start_);
+ auto o = flatbuffers::Offset<Referrable>(end);
+ return o;
+ }
+};
+
+inline flatbuffers::Offset<Referrable> CreateReferrable(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ uint64_t id = 0) {
+ ReferrableBuilder builder_(_fbb);
+ builder_.add_id(id);
+ return builder_.Finish();
+}
+
+flatbuffers::Offset<Referrable> CreateReferrable(flatbuffers::FlatBufferBuilder &_fbb, const ReferrableT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+
+struct MonsterT : public flatbuffers::NativeTable {
+ typedef Monster TableType;
+ flatbuffers::unique_ptr<MyGame::Example::Vec3> pos{};
+ int16_t mana = 150;
+ int16_t hp = 100;
+ std::string name{};
+ std::vector<uint8_t> inventory{};
+ MyGame::Example::Color color = MyGame::Example::Color_Blue;
+ MyGame::Example::AnyUnion test{};
+ std::vector<MyGame::Example::Test> test4{};
+ std::vector<std::string> testarrayofstring{};
+ std::vector<flatbuffers::unique_ptr<MyGame::Example::MonsterT>> testarrayoftables{};
+ flatbuffers::unique_ptr<MyGame::Example::MonsterT> enemy{};
+ std::vector<uint8_t> testnestedflatbuffer{};
+ flatbuffers::unique_ptr<MyGame::Example::StatT> testempty{};
+ bool testbool = false;
+ int32_t testhashs32_fnv1 = 0;
+ uint32_t testhashu32_fnv1 = 0;
+ int64_t testhashs64_fnv1 = 0;
+ uint64_t testhashu64_fnv1 = 0;
+ int32_t testhashs32_fnv1a = 0;
+ Stat *testhashu32_fnv1a = nullptr;
+ int64_t testhashs64_fnv1a = 0;
+ uint64_t testhashu64_fnv1a = 0;
+ std::vector<bool> testarrayofbools{};
+ float testf = 3.14159f;
+ float testf2 = 3.0f;
+ float testf3 = 0.0f;
+ std::vector<std::string> testarrayofstring2{};
+ std::vector<MyGame::Example::Ability> testarrayofsortedstruct{};
+ std::vector<uint8_t> flex{};
+ std::vector<MyGame::Example::Test> test5{};
+ std::vector<int64_t> vector_of_longs{};
+ std::vector<double> vector_of_doubles{};
+ flatbuffers::unique_ptr<MyGame::InParentNamespaceT> parent_namespace_test{};
+ std::vector<flatbuffers::unique_ptr<MyGame::Example::ReferrableT>> vector_of_referrables{};
+ ReferrableT *single_weak_reference = nullptr;
+ std::vector<ReferrableT *> vector_of_weak_references{};
+ std::vector<flatbuffers::unique_ptr<MyGame::Example::ReferrableT>> vector_of_strong_referrables{};
+ ReferrableT *co_owning_reference = nullptr;
+ std::vector<flatbuffers::unique_ptr<ReferrableT>> vector_of_co_owning_references{};
+ ReferrableT *non_owning_reference = nullptr;
+ std::vector<ReferrableT *> vector_of_non_owning_references{};
+ MyGame::Example::AnyUniqueAliasesUnion any_unique{};
+ MyGame::Example::AnyAmbiguousAliasesUnion any_ambiguous{};
+ std::vector<MyGame::Example::Color> vector_of_enums{};
+ MyGame::Example::Race signed_enum = MyGame::Example::Race_None;
+ std::vector<uint8_t> testrequirednestedflatbuffer{};
+ std::vector<flatbuffers::unique_ptr<MyGame::Example::StatT>> scalar_key_sorted_tables{};
+ MyGame::Example::Test native_inline{};
+ MyGame::Example::LongEnum long_enum_non_enum_default = static_cast<MyGame::Example::LongEnum>(0);
+ MyGame::Example::LongEnum long_enum_normal_default = MyGame::Example::LongEnum_LongOne;
+ MonsterT() = default;
+ MonsterT(const MonsterT &o);
+ MonsterT(MonsterT&&) FLATBUFFERS_NOEXCEPT = default;
+ MonsterT &operator=(MonsterT o) FLATBUFFERS_NOEXCEPT;
+};
+
+/// an example documentation comment: "monster object"
+struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
+ typedef MonsterT NativeTableType;
+ typedef MonsterBuilder Builder;
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return MonsterTypeTable();
+ }
+ enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
+ VT_POS = 4,
+ VT_MANA = 6,
+ VT_HP = 8,
+ VT_NAME = 10,
+ VT_INVENTORY = 14,
+ VT_COLOR = 16,
+ VT_TEST_TYPE = 18,
+ VT_TEST = 20,
+ VT_TEST4 = 22,
+ VT_TESTARRAYOFSTRING = 24,
+ VT_TESTARRAYOFTABLES = 26,
+ VT_ENEMY = 28,
+ VT_TESTNESTEDFLATBUFFER = 30,
+ VT_TESTEMPTY = 32,
+ VT_TESTBOOL = 34,
+ VT_TESTHASHS32_FNV1 = 36,
+ VT_TESTHASHU32_FNV1 = 38,
+ VT_TESTHASHS64_FNV1 = 40,
+ VT_TESTHASHU64_FNV1 = 42,
+ VT_TESTHASHS32_FNV1A = 44,
+ VT_TESTHASHU32_FNV1A = 46,
+ VT_TESTHASHS64_FNV1A = 48,
+ VT_TESTHASHU64_FNV1A = 50,
+ VT_TESTARRAYOFBOOLS = 52,
+ VT_TESTF = 54,
+ VT_TESTF2 = 56,
+ VT_TESTF3 = 58,
+ VT_TESTARRAYOFSTRING2 = 60,
+ VT_TESTARRAYOFSORTEDSTRUCT = 62,
+ VT_FLEX = 64,
+ VT_TEST5 = 66,
+ VT_VECTOR_OF_LONGS = 68,
+ VT_VECTOR_OF_DOUBLES = 70,
+ VT_PARENT_NAMESPACE_TEST = 72,
+ VT_VECTOR_OF_REFERRABLES = 74,
+ VT_SINGLE_WEAK_REFERENCE = 76,
+ VT_VECTOR_OF_WEAK_REFERENCES = 78,
+ VT_VECTOR_OF_STRONG_REFERRABLES = 80,
+ VT_CO_OWNING_REFERENCE = 82,
+ VT_VECTOR_OF_CO_OWNING_REFERENCES = 84,
+ VT_NON_OWNING_REFERENCE = 86,
+ VT_VECTOR_OF_NON_OWNING_REFERENCES = 88,
+ VT_ANY_UNIQUE_TYPE = 90,
+ VT_ANY_UNIQUE = 92,
+ VT_ANY_AMBIGUOUS_TYPE = 94,
+ VT_ANY_AMBIGUOUS = 96,
+ VT_VECTOR_OF_ENUMS = 98,
+ VT_SIGNED_ENUM = 100,
+ VT_TESTREQUIREDNESTEDFLATBUFFER = 102,
+ VT_SCALAR_KEY_SORTED_TABLES = 104,
+ VT_NATIVE_INLINE = 106,
+ VT_LONG_ENUM_NON_ENUM_DEFAULT = 108,
+ VT_LONG_ENUM_NORMAL_DEFAULT = 110
+ };
+ const MyGame::Example::Vec3 *pos() const {
+ return GetStruct<const MyGame::Example::Vec3 *>(VT_POS);
+ }
+ MyGame::Example::Vec3 *mutable_pos() {
+ return GetStruct<MyGame::Example::Vec3 *>(VT_POS);
+ }
+ int16_t mana() const {
+ return GetField<int16_t>(VT_MANA, 150);
+ }
+ bool mutate_mana(int16_t _mana = 150) {
+ return SetField<int16_t>(VT_MANA, _mana, 150);
+ }
+ int16_t hp() const {
+ return GetField<int16_t>(VT_HP, 100);
+ }
+ bool mutate_hp(int16_t _hp = 100) {
+ return SetField<int16_t>(VT_HP, _hp, 100);
+ }
+ const flatbuffers::String *name() const {
+ return GetPointer<const flatbuffers::String *>(VT_NAME);
+ }
+ flatbuffers::String *mutable_name() {
+ return GetPointer<flatbuffers::String *>(VT_NAME);
+ }
+ bool KeyCompareLessThan(const Monster *o) const {
+ return *name() < *o->name();
+ }
+ int KeyCompareWithValue(const char *_name) const {
+ return strcmp(name()->c_str(), _name);
+ }
+ const flatbuffers::Vector<uint8_t> *inventory() const {
+ return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_INVENTORY);
+ }
+ flatbuffers::Vector<uint8_t> *mutable_inventory() {
+ return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_INVENTORY);
+ }
+ MyGame::Example::Color color() const {
+ return static_cast<MyGame::Example::Color>(GetField<uint8_t>(VT_COLOR, 8));
+ }
+ bool mutate_color(MyGame::Example::Color _color = static_cast<MyGame::Example::Color>(8)) {
+ return SetField<uint8_t>(VT_COLOR, static_cast<uint8_t>(_color), 8);
+ }
+ MyGame::Example::Any test_type() const {
+ return static_cast<MyGame::Example::Any>(GetField<uint8_t>(VT_TEST_TYPE, 0));
+ }
+ const void *test() const {
+ return GetPointer<const void *>(VT_TEST);
+ }
+ template<typename T> const T *test_as() const;
+ const MyGame::Example::Monster *test_as_Monster() const {
+ return test_type() == MyGame::Example::Any_Monster ? static_cast<const MyGame::Example::Monster *>(test()) : nullptr;
+ }
+ const MyGame::Example::TestSimpleTableWithEnum *test_as_TestSimpleTableWithEnum() const {
+ return test_type() == MyGame::Example::Any_TestSimpleTableWithEnum ? static_cast<const MyGame::Example::TestSimpleTableWithEnum *>(test()) : nullptr;
+ }
+ const MyGame::Example2::Monster *test_as_MyGame_Example2_Monster() const {
+ return test_type() == MyGame::Example::Any_MyGame_Example2_Monster ? static_cast<const MyGame::Example2::Monster *>(test()) : nullptr;
+ }
+ void *mutable_test() {
+ return GetPointer<void *>(VT_TEST);
+ }
+ const flatbuffers::Vector<const MyGame::Example::Test *> *test4() const {
+ return GetPointer<const flatbuffers::Vector<const MyGame::Example::Test *> *>(VT_TEST4);
+ }
+ flatbuffers::Vector<const MyGame::Example::Test *> *mutable_test4() {
+ return GetPointer<flatbuffers::Vector<const MyGame::Example::Test *> *>(VT_TEST4);
+ }
+ const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *testarrayofstring() const {
+ return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_TESTARRAYOFSTRING);
+ }
+ flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *mutable_testarrayofstring() {
+ return GetPointer<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_TESTARRAYOFSTRING);
+ }
+ /// an example documentation comment: this will end up in the generated code
+ /// multiline too
+ const flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Monster>> *testarrayoftables() const {
+ return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Monster>> *>(VT_TESTARRAYOFTABLES);
+ }
+ flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Monster>> *mutable_testarrayoftables() {
+ return GetPointer<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Monster>> *>(VT_TESTARRAYOFTABLES);
+ }
+ const MyGame::Example::Monster *enemy() const {
+ return GetPointer<const MyGame::Example::Monster *>(VT_ENEMY);
+ }
+ MyGame::Example::Monster *mutable_enemy() {
+ return GetPointer<MyGame::Example::Monster *>(VT_ENEMY);
+ }
+ const flatbuffers::Vector<uint8_t> *testnestedflatbuffer() const {
+ return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_TESTNESTEDFLATBUFFER);
+ }
+ flatbuffers::Vector<uint8_t> *mutable_testnestedflatbuffer() {
+ return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_TESTNESTEDFLATBUFFER);
+ }
+ const MyGame::Example::Monster *testnestedflatbuffer_nested_root() const {
+ return flatbuffers::GetRoot<MyGame::Example::Monster>(testnestedflatbuffer()->Data());
+ }
+ const MyGame::Example::Stat *testempty() const {
+ return GetPointer<const MyGame::Example::Stat *>(VT_TESTEMPTY);
+ }
+ MyGame::Example::Stat *mutable_testempty() {
+ return GetPointer<MyGame::Example::Stat *>(VT_TESTEMPTY);
+ }
+ bool testbool() const {
+ return GetField<uint8_t>(VT_TESTBOOL, 0) != 0;
+ }
+ bool mutate_testbool(bool _testbool = 0) {
+ return SetField<uint8_t>(VT_TESTBOOL, static_cast<uint8_t>(_testbool), 0);
+ }
+ int32_t testhashs32_fnv1() const {
+ return GetField<int32_t>(VT_TESTHASHS32_FNV1, 0);
+ }
+ bool mutate_testhashs32_fnv1(int32_t _testhashs32_fnv1 = 0) {
+ return SetField<int32_t>(VT_TESTHASHS32_FNV1, _testhashs32_fnv1, 0);
+ }
+ uint32_t testhashu32_fnv1() const {
+ return GetField<uint32_t>(VT_TESTHASHU32_FNV1, 0);
+ }
+ bool mutate_testhashu32_fnv1(uint32_t _testhashu32_fnv1 = 0) {
+ return SetField<uint32_t>(VT_TESTHASHU32_FNV1, _testhashu32_fnv1, 0);
+ }
+ int64_t testhashs64_fnv1() const {
+ return GetField<int64_t>(VT_TESTHASHS64_FNV1, 0);
+ }
+ bool mutate_testhashs64_fnv1(int64_t _testhashs64_fnv1 = 0) {
+ return SetField<int64_t>(VT_TESTHASHS64_FNV1, _testhashs64_fnv1, 0);
+ }
+ uint64_t testhashu64_fnv1() const {
+ return GetField<uint64_t>(VT_TESTHASHU64_FNV1, 0);
+ }
+ bool mutate_testhashu64_fnv1(uint64_t _testhashu64_fnv1 = 0) {
+ return SetField<uint64_t>(VT_TESTHASHU64_FNV1, _testhashu64_fnv1, 0);
+ }
+ int32_t testhashs32_fnv1a() const {
+ return GetField<int32_t>(VT_TESTHASHS32_FNV1A, 0);
+ }
+ bool mutate_testhashs32_fnv1a(int32_t _testhashs32_fnv1a = 0) {
+ return SetField<int32_t>(VT_TESTHASHS32_FNV1A, _testhashs32_fnv1a, 0);
+ }
+ uint32_t testhashu32_fnv1a() const {
+ return GetField<uint32_t>(VT_TESTHASHU32_FNV1A, 0);
+ }
+ bool mutate_testhashu32_fnv1a(uint32_t _testhashu32_fnv1a = 0) {
+ return SetField<uint32_t>(VT_TESTHASHU32_FNV1A, _testhashu32_fnv1a, 0);
+ }
+ int64_t testhashs64_fnv1a() const {
+ return GetField<int64_t>(VT_TESTHASHS64_FNV1A, 0);
+ }
+ bool mutate_testhashs64_fnv1a(int64_t _testhashs64_fnv1a = 0) {
+ return SetField<int64_t>(VT_TESTHASHS64_FNV1A, _testhashs64_fnv1a, 0);
+ }
+ uint64_t testhashu64_fnv1a() const {
+ return GetField<uint64_t>(VT_TESTHASHU64_FNV1A, 0);
+ }
+ bool mutate_testhashu64_fnv1a(uint64_t _testhashu64_fnv1a = 0) {
+ return SetField<uint64_t>(VT_TESTHASHU64_FNV1A, _testhashu64_fnv1a, 0);
+ }
+ const flatbuffers::Vector<uint8_t> *testarrayofbools() const {
+ return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_TESTARRAYOFBOOLS);
+ }
+ flatbuffers::Vector<uint8_t> *mutable_testarrayofbools() {
+ return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_TESTARRAYOFBOOLS);
+ }
+ float testf() const {
+ return GetField<float>(VT_TESTF, 3.14159f);
+ }
+ bool mutate_testf(float _testf = 3.14159f) {
+ return SetField<float>(VT_TESTF, _testf, 3.14159f);
+ }
+ float testf2() const {
+ return GetField<float>(VT_TESTF2, 3.0f);
+ }
+ bool mutate_testf2(float _testf2 = 3.0f) {
+ return SetField<float>(VT_TESTF2, _testf2, 3.0f);
+ }
+ float testf3() const {
+ return GetField<float>(VT_TESTF3, 0.0f);
+ }
+ bool mutate_testf3(float _testf3 = 0.0f) {
+ return SetField<float>(VT_TESTF3, _testf3, 0.0f);
+ }
+ const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *testarrayofstring2() const {
+ return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_TESTARRAYOFSTRING2);
+ }
+ flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *mutable_testarrayofstring2() {
+ return GetPointer<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_TESTARRAYOFSTRING2);
+ }
+ const flatbuffers::Vector<const MyGame::Example::Ability *> *testarrayofsortedstruct() const {
+ return GetPointer<const flatbuffers::Vector<const MyGame::Example::Ability *> *>(VT_TESTARRAYOFSORTEDSTRUCT);
+ }
+ flatbuffers::Vector<const MyGame::Example::Ability *> *mutable_testarrayofsortedstruct() {
+ return GetPointer<flatbuffers::Vector<const MyGame::Example::Ability *> *>(VT_TESTARRAYOFSORTEDSTRUCT);
+ }
+ const flatbuffers::Vector<uint8_t> *flex() const {
+ return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_FLEX);
+ }
+ flatbuffers::Vector<uint8_t> *mutable_flex() {
+ return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_FLEX);
+ }
+ flexbuffers::Reference flex_flexbuffer_root() const {
+ return flexbuffers::GetRoot(flex()->Data(), flex()->size());
+ }
+ const flatbuffers::Vector<const MyGame::Example::Test *> *test5() const {
+ return GetPointer<const flatbuffers::Vector<const MyGame::Example::Test *> *>(VT_TEST5);
+ }
+ flatbuffers::Vector<const MyGame::Example::Test *> *mutable_test5() {
+ return GetPointer<flatbuffers::Vector<const MyGame::Example::Test *> *>(VT_TEST5);
+ }
+ const flatbuffers::Vector<int64_t> *vector_of_longs() const {
+ return GetPointer<const flatbuffers::Vector<int64_t> *>(VT_VECTOR_OF_LONGS);
+ }
+ flatbuffers::Vector<int64_t> *mutable_vector_of_longs() {
+ return GetPointer<flatbuffers::Vector<int64_t> *>(VT_VECTOR_OF_LONGS);
+ }
+ const flatbuffers::Vector<double> *vector_of_doubles() const {
+ return GetPointer<const flatbuffers::Vector<double> *>(VT_VECTOR_OF_DOUBLES);
+ }
+ flatbuffers::Vector<double> *mutable_vector_of_doubles() {
+ return GetPointer<flatbuffers::Vector<double> *>(VT_VECTOR_OF_DOUBLES);
+ }
+ const MyGame::InParentNamespace *parent_namespace_test() const {
+ return GetPointer<const MyGame::InParentNamespace *>(VT_PARENT_NAMESPACE_TEST);
+ }
+ MyGame::InParentNamespace *mutable_parent_namespace_test() {
+ return GetPointer<MyGame::InParentNamespace *>(VT_PARENT_NAMESPACE_TEST);
+ }
+ const flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>> *vector_of_referrables() const {
+ return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>> *>(VT_VECTOR_OF_REFERRABLES);
+ }
+ flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>> *mutable_vector_of_referrables() {
+ return GetPointer<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>> *>(VT_VECTOR_OF_REFERRABLES);
+ }
+ uint64_t single_weak_reference() const {
+ return GetField<uint64_t>(VT_SINGLE_WEAK_REFERENCE, 0);
+ }
+ bool mutate_single_weak_reference(uint64_t _single_weak_reference = 0) {
+ return SetField<uint64_t>(VT_SINGLE_WEAK_REFERENCE, _single_weak_reference, 0);
+ }
+ const flatbuffers::Vector<uint64_t> *vector_of_weak_references() const {
+ return GetPointer<const flatbuffers::Vector<uint64_t> *>(VT_VECTOR_OF_WEAK_REFERENCES);
+ }
+ flatbuffers::Vector<uint64_t> *mutable_vector_of_weak_references() {
+ return GetPointer<flatbuffers::Vector<uint64_t> *>(VT_VECTOR_OF_WEAK_REFERENCES);
+ }
+ const flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>> *vector_of_strong_referrables() const {
+ return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>> *>(VT_VECTOR_OF_STRONG_REFERRABLES);
+ }
+ flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>> *mutable_vector_of_strong_referrables() {
+ return GetPointer<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>> *>(VT_VECTOR_OF_STRONG_REFERRABLES);
+ }
+ uint64_t co_owning_reference() const {
+ return GetField<uint64_t>(VT_CO_OWNING_REFERENCE, 0);
+ }
+ bool mutate_co_owning_reference(uint64_t _co_owning_reference = 0) {
+ return SetField<uint64_t>(VT_CO_OWNING_REFERENCE, _co_owning_reference, 0);
+ }
+ const flatbuffers::Vector<uint64_t> *vector_of_co_owning_references() const {
+ return GetPointer<const flatbuffers::Vector<uint64_t> *>(VT_VECTOR_OF_CO_OWNING_REFERENCES);
+ }
+ flatbuffers::Vector<uint64_t> *mutable_vector_of_co_owning_references() {
+ return GetPointer<flatbuffers::Vector<uint64_t> *>(VT_VECTOR_OF_CO_OWNING_REFERENCES);
+ }
+ uint64_t non_owning_reference() const {
+ return GetField<uint64_t>(VT_NON_OWNING_REFERENCE, 0);
+ }
+ bool mutate_non_owning_reference(uint64_t _non_owning_reference = 0) {
+ return SetField<uint64_t>(VT_NON_OWNING_REFERENCE, _non_owning_reference, 0);
+ }
+ const flatbuffers::Vector<uint64_t> *vector_of_non_owning_references() const {
+ return GetPointer<const flatbuffers::Vector<uint64_t> *>(VT_VECTOR_OF_NON_OWNING_REFERENCES);
+ }
+ flatbuffers::Vector<uint64_t> *mutable_vector_of_non_owning_references() {
+ return GetPointer<flatbuffers::Vector<uint64_t> *>(VT_VECTOR_OF_NON_OWNING_REFERENCES);
+ }
+ MyGame::Example::AnyUniqueAliases any_unique_type() const {
+ return static_cast<MyGame::Example::AnyUniqueAliases>(GetField<uint8_t>(VT_ANY_UNIQUE_TYPE, 0));
+ }
+ const void *any_unique() const {
+ return GetPointer<const void *>(VT_ANY_UNIQUE);
+ }
+ template<typename T> const T *any_unique_as() const;
+ const MyGame::Example::Monster *any_unique_as_M() const {
+ return any_unique_type() == MyGame::Example::AnyUniqueAliases_M ? static_cast<const MyGame::Example::Monster *>(any_unique()) : nullptr;
+ }
+ const MyGame::Example::TestSimpleTableWithEnum *any_unique_as_TS() const {
+ return any_unique_type() == MyGame::Example::AnyUniqueAliases_TS ? static_cast<const MyGame::Example::TestSimpleTableWithEnum *>(any_unique()) : nullptr;
+ }
+ const MyGame::Example2::Monster *any_unique_as_M2() const {
+ return any_unique_type() == MyGame::Example::AnyUniqueAliases_M2 ? static_cast<const MyGame::Example2::Monster *>(any_unique()) : nullptr;
+ }
+ void *mutable_any_unique() {
+ return GetPointer<void *>(VT_ANY_UNIQUE);
+ }
+ MyGame::Example::AnyAmbiguousAliases any_ambiguous_type() const {
+ return static_cast<MyGame::Example::AnyAmbiguousAliases>(GetField<uint8_t>(VT_ANY_AMBIGUOUS_TYPE, 0));
+ }
+ const void *any_ambiguous() const {
+ return GetPointer<const void *>(VT_ANY_AMBIGUOUS);
+ }
+ const MyGame::Example::Monster *any_ambiguous_as_M1() const {
+ return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M1 ? static_cast<const MyGame::Example::Monster *>(any_ambiguous()) : nullptr;
+ }
+ const MyGame::Example::Monster *any_ambiguous_as_M2() const {
+ return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M2 ? static_cast<const MyGame::Example::Monster *>(any_ambiguous()) : nullptr;
+ }
+ const MyGame::Example::Monster *any_ambiguous_as_M3() const {
+ return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M3 ? static_cast<const MyGame::Example::Monster *>(any_ambiguous()) : nullptr;
+ }
+ void *mutable_any_ambiguous() {
+ return GetPointer<void *>(VT_ANY_AMBIGUOUS);
+ }
+ const flatbuffers::Vector<uint8_t> *vector_of_enums() const {
+ return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_VECTOR_OF_ENUMS);
+ }
+ flatbuffers::Vector<uint8_t> *mutable_vector_of_enums() {
+ return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_VECTOR_OF_ENUMS);
+ }
+ MyGame::Example::Race signed_enum() const {
+ return static_cast<MyGame::Example::Race>(GetField<int8_t>(VT_SIGNED_ENUM, -1));
+ }
+ bool mutate_signed_enum(MyGame::Example::Race _signed_enum = static_cast<MyGame::Example::Race>(-1)) {
+ return SetField<int8_t>(VT_SIGNED_ENUM, static_cast<int8_t>(_signed_enum), -1);
+ }
+ const flatbuffers::Vector<uint8_t> *testrequirednestedflatbuffer() const {
+ return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_TESTREQUIREDNESTEDFLATBUFFER);
+ }
+ flatbuffers::Vector<uint8_t> *mutable_testrequirednestedflatbuffer() {
+ return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_TESTREQUIREDNESTEDFLATBUFFER);
+ }
+ const MyGame::Example::Monster *testrequirednestedflatbuffer_nested_root() const {
+ return flatbuffers::GetRoot<MyGame::Example::Monster>(testrequirednestedflatbuffer()->Data());
+ }
+ const flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Stat>> *scalar_key_sorted_tables() const {
+ return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Stat>> *>(VT_SCALAR_KEY_SORTED_TABLES);
+ }
+ flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Stat>> *mutable_scalar_key_sorted_tables() {
+ return GetPointer<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Stat>> *>(VT_SCALAR_KEY_SORTED_TABLES);
+ }
+ const MyGame::Example::Test *native_inline() const {
+ return GetStruct<const MyGame::Example::Test *>(VT_NATIVE_INLINE);
+ }
+ MyGame::Example::Test *mutable_native_inline() {
+ return GetStruct<MyGame::Example::Test *>(VT_NATIVE_INLINE);
+ }
+ MyGame::Example::LongEnum long_enum_non_enum_default() const {
+ return static_cast<MyGame::Example::LongEnum>(GetField<uint64_t>(VT_LONG_ENUM_NON_ENUM_DEFAULT, 0));
+ }
+ bool mutate_long_enum_non_enum_default(MyGame::Example::LongEnum _long_enum_non_enum_default = static_cast<MyGame::Example::LongEnum>(0)) {
+ return SetField<uint64_t>(VT_LONG_ENUM_NON_ENUM_DEFAULT, static_cast<uint64_t>(_long_enum_non_enum_default), 0);
+ }
+ MyGame::Example::LongEnum long_enum_normal_default() const {
+ return static_cast<MyGame::Example::LongEnum>(GetField<uint64_t>(VT_LONG_ENUM_NORMAL_DEFAULT, 2ULL));
+ }
+ bool mutate_long_enum_normal_default(MyGame::Example::LongEnum _long_enum_normal_default = static_cast<MyGame::Example::LongEnum>(2ULL)) {
+ return SetField<uint64_t>(VT_LONG_ENUM_NORMAL_DEFAULT, static_cast<uint64_t>(_long_enum_normal_default), 2ULL);
+ }
+ bool Verify(flatbuffers::Verifier &verifier) const {
+ return VerifyTableStart(verifier) &&
+ VerifyField<MyGame::Example::Vec3>(verifier, VT_POS, 8) &&
+ VerifyField<int16_t>(verifier, VT_MANA, 2) &&
+ VerifyField<int16_t>(verifier, VT_HP, 2) &&
+ VerifyOffsetRequired(verifier, VT_NAME) &&
+ verifier.VerifyString(name()) &&
+ VerifyOffset(verifier, VT_INVENTORY) &&
+ verifier.VerifyVector(inventory()) &&
+ VerifyField<uint8_t>(verifier, VT_COLOR, 1) &&
+ VerifyField<uint8_t>(verifier, VT_TEST_TYPE, 1) &&
+ VerifyOffset(verifier, VT_TEST) &&
+ VerifyAny(verifier, test(), test_type()) &&
+ VerifyOffset(verifier, VT_TEST4) &&
+ verifier.VerifyVector(test4()) &&
+ VerifyOffset(verifier, VT_TESTARRAYOFSTRING) &&
+ verifier.VerifyVector(testarrayofstring()) &&
+ verifier.VerifyVectorOfStrings(testarrayofstring()) &&
+ VerifyOffset(verifier, VT_TESTARRAYOFTABLES) &&
+ verifier.VerifyVector(testarrayoftables()) &&
+ verifier.VerifyVectorOfTables(testarrayoftables()) &&
+ VerifyOffset(verifier, VT_ENEMY) &&
+ verifier.VerifyTable(enemy()) &&
+ VerifyOffset(verifier, VT_TESTNESTEDFLATBUFFER) &&
+ verifier.VerifyVector(testnestedflatbuffer()) &&
+ verifier.VerifyNestedFlatBuffer<MyGame::Example::Monster>(testnestedflatbuffer(), nullptr) &&
+ VerifyOffset(verifier, VT_TESTEMPTY) &&
+ verifier.VerifyTable(testempty()) &&
+ VerifyField<uint8_t>(verifier, VT_TESTBOOL, 1) &&
+ VerifyField<int32_t>(verifier, VT_TESTHASHS32_FNV1, 4) &&
+ VerifyField<uint32_t>(verifier, VT_TESTHASHU32_FNV1, 4) &&
+ VerifyField<int64_t>(verifier, VT_TESTHASHS64_FNV1, 8) &&
+ VerifyField<uint64_t>(verifier, VT_TESTHASHU64_FNV1, 8) &&
+ VerifyField<int32_t>(verifier, VT_TESTHASHS32_FNV1A, 4) &&
+ VerifyField<uint32_t>(verifier, VT_TESTHASHU32_FNV1A, 4) &&
+ VerifyField<int64_t>(verifier, VT_TESTHASHS64_FNV1A, 8) &&
+ VerifyField<uint64_t>(verifier, VT_TESTHASHU64_FNV1A, 8) &&
+ VerifyOffset(verifier, VT_TESTARRAYOFBOOLS) &&
+ verifier.VerifyVector(testarrayofbools()) &&
+ VerifyField<float>(verifier, VT_TESTF, 4) &&
+ VerifyField<float>(verifier, VT_TESTF2, 4) &&
+ VerifyField<float>(verifier, VT_TESTF3, 4) &&
+ VerifyOffset(verifier, VT_TESTARRAYOFSTRING2) &&
+ verifier.VerifyVector(testarrayofstring2()) &&
+ verifier.VerifyVectorOfStrings(testarrayofstring2()) &&
+ VerifyOffset(verifier, VT_TESTARRAYOFSORTEDSTRUCT) &&
+ verifier.VerifyVector(testarrayofsortedstruct()) &&
+ VerifyOffset(verifier, VT_FLEX) &&
+ verifier.VerifyVector(flex()) &&
+ flexbuffers::VerifyNestedFlexBuffer(flex(), verifier) &&
+ VerifyOffset(verifier, VT_TEST5) &&
+ verifier.VerifyVector(test5()) &&
+ VerifyOffset(verifier, VT_VECTOR_OF_LONGS) &&
+ verifier.VerifyVector(vector_of_longs()) &&
+ VerifyOffset(verifier, VT_VECTOR_OF_DOUBLES) &&
+ verifier.VerifyVector(vector_of_doubles()) &&
+ VerifyOffset(verifier, VT_PARENT_NAMESPACE_TEST) &&
+ verifier.VerifyTable(parent_namespace_test()) &&
+ VerifyOffset(verifier, VT_VECTOR_OF_REFERRABLES) &&
+ verifier.VerifyVector(vector_of_referrables()) &&
+ verifier.VerifyVectorOfTables(vector_of_referrables()) &&
+ VerifyField<uint64_t>(verifier, VT_SINGLE_WEAK_REFERENCE, 8) &&
+ VerifyOffset(verifier, VT_VECTOR_OF_WEAK_REFERENCES) &&
+ verifier.VerifyVector(vector_of_weak_references()) &&
+ VerifyOffset(verifier, VT_VECTOR_OF_STRONG_REFERRABLES) &&
+ verifier.VerifyVector(vector_of_strong_referrables()) &&
+ verifier.VerifyVectorOfTables(vector_of_strong_referrables()) &&
+ VerifyField<uint64_t>(verifier, VT_CO_OWNING_REFERENCE, 8) &&
+ VerifyOffset(verifier, VT_VECTOR_OF_CO_OWNING_REFERENCES) &&
+ verifier.VerifyVector(vector_of_co_owning_references()) &&
+ VerifyField<uint64_t>(verifier, VT_NON_OWNING_REFERENCE, 8) &&
+ VerifyOffset(verifier, VT_VECTOR_OF_NON_OWNING_REFERENCES) &&
+ verifier.VerifyVector(vector_of_non_owning_references()) &&
+ VerifyField<uint8_t>(verifier, VT_ANY_UNIQUE_TYPE, 1) &&
+ VerifyOffset(verifier, VT_ANY_UNIQUE) &&
+ VerifyAnyUniqueAliases(verifier, any_unique(), any_unique_type()) &&
+ VerifyField<uint8_t>(verifier, VT_ANY_AMBIGUOUS_TYPE, 1) &&
+ VerifyOffset(verifier, VT_ANY_AMBIGUOUS) &&
+ VerifyAnyAmbiguousAliases(verifier, any_ambiguous(), any_ambiguous_type()) &&
+ VerifyOffset(verifier, VT_VECTOR_OF_ENUMS) &&
+ verifier.VerifyVector(vector_of_enums()) &&
+ VerifyField<int8_t>(verifier, VT_SIGNED_ENUM, 1) &&
+ VerifyOffset(verifier, VT_TESTREQUIREDNESTEDFLATBUFFER) &&
+ verifier.VerifyVector(testrequirednestedflatbuffer()) &&
+ verifier.VerifyNestedFlatBuffer<MyGame::Example::Monster>(testrequirednestedflatbuffer(), nullptr) &&
+ VerifyOffset(verifier, VT_SCALAR_KEY_SORTED_TABLES) &&
+ verifier.VerifyVector(scalar_key_sorted_tables()) &&
+ verifier.VerifyVectorOfTables(scalar_key_sorted_tables()) &&
+ VerifyField<MyGame::Example::Test>(verifier, VT_NATIVE_INLINE, 2) &&
+ VerifyField<uint64_t>(verifier, VT_LONG_ENUM_NON_ENUM_DEFAULT, 8) &&
+ VerifyField<uint64_t>(verifier, VT_LONG_ENUM_NORMAL_DEFAULT, 8) &&
+ verifier.EndTable();
+ }
+ MonsterT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ void UnPackTo(MonsterT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ static flatbuffers::Offset<Monster> Pack(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+};
+
+template<> inline const MyGame::Example::Monster *Monster::test_as<MyGame::Example::Monster>() const {
+ return test_as_Monster();
+}
+
+template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::test_as<MyGame::Example::TestSimpleTableWithEnum>() const {
+ return test_as_TestSimpleTableWithEnum();
+}
+
+template<> inline const MyGame::Example2::Monster *Monster::test_as<MyGame::Example2::Monster>() const {
+ return test_as_MyGame_Example2_Monster();
+}
+
+template<> inline const MyGame::Example::Monster *Monster::any_unique_as<MyGame::Example::Monster>() const {
+ return any_unique_as_M();
+}
+
+template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() const {
+ return any_unique_as_TS();
+}
+
+template<> inline const MyGame::Example2::Monster *Monster::any_unique_as<MyGame::Example2::Monster>() const {
+ return any_unique_as_M2();
+}
+
+struct MonsterBuilder {
+ typedef Monster Table;
+ flatbuffers::FlatBufferBuilder &fbb_;
+ flatbuffers::uoffset_t start_;
+ void add_pos(const MyGame::Example::Vec3 *pos) {
+ fbb_.AddStruct(Monster::VT_POS, pos);
+ }
+ void add_mana(int16_t mana) {
+ fbb_.AddElement<int16_t>(Monster::VT_MANA, mana, 150);
+ }
+ void add_hp(int16_t hp) {
+ fbb_.AddElement<int16_t>(Monster::VT_HP, hp, 100);
+ }
+ void add_name(flatbuffers::Offset<flatbuffers::String> name) {
+ fbb_.AddOffset(Monster::VT_NAME, name);
+ }
+ void add_inventory(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> inventory) {
+ fbb_.AddOffset(Monster::VT_INVENTORY, inventory);
+ }
+ void add_color(MyGame::Example::Color color) {
+ fbb_.AddElement<uint8_t>(Monster::VT_COLOR, static_cast<uint8_t>(color), 8);
+ }
+ void add_test_type(MyGame::Example::Any test_type) {
+ fbb_.AddElement<uint8_t>(Monster::VT_TEST_TYPE, static_cast<uint8_t>(test_type), 0);
+ }
+ void add_test(flatbuffers::Offset<void> test) {
+ fbb_.AddOffset(Monster::VT_TEST, test);
+ }
+ void add_test4(flatbuffers::Offset<flatbuffers::Vector<const MyGame::Example::Test *>> test4) {
+ fbb_.AddOffset(Monster::VT_TEST4, test4);
+ }
+ void add_testarrayofstring(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> testarrayofstring) {
+ fbb_.AddOffset(Monster::VT_TESTARRAYOFSTRING, testarrayofstring);
+ }
+ void add_testarrayoftables(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Monster>>> testarrayoftables) {
+ fbb_.AddOffset(Monster::VT_TESTARRAYOFTABLES, testarrayoftables);
+ }
+ void add_enemy(flatbuffers::Offset<MyGame::Example::Monster> enemy) {
+ fbb_.AddOffset(Monster::VT_ENEMY, enemy);
+ }
+ void add_testnestedflatbuffer(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> testnestedflatbuffer) {
+ fbb_.AddOffset(Monster::VT_TESTNESTEDFLATBUFFER, testnestedflatbuffer);
+ }
+ void add_testempty(flatbuffers::Offset<MyGame::Example::Stat> testempty) {
+ fbb_.AddOffset(Monster::VT_TESTEMPTY, testempty);
+ }
+ void add_testbool(bool testbool) {
+ fbb_.AddElement<uint8_t>(Monster::VT_TESTBOOL, static_cast<uint8_t>(testbool), 0);
+ }
+ void add_testhashs32_fnv1(int32_t testhashs32_fnv1) {
+ fbb_.AddElement<int32_t>(Monster::VT_TESTHASHS32_FNV1, testhashs32_fnv1, 0);
+ }
+ void add_testhashu32_fnv1(uint32_t testhashu32_fnv1) {
+ fbb_.AddElement<uint32_t>(Monster::VT_TESTHASHU32_FNV1, testhashu32_fnv1, 0);
+ }
+ void add_testhashs64_fnv1(int64_t testhashs64_fnv1) {
+ fbb_.AddElement<int64_t>(Monster::VT_TESTHASHS64_FNV1, testhashs64_fnv1, 0);
+ }
+ void add_testhashu64_fnv1(uint64_t testhashu64_fnv1) {
+ fbb_.AddElement<uint64_t>(Monster::VT_TESTHASHU64_FNV1, testhashu64_fnv1, 0);
+ }
+ void add_testhashs32_fnv1a(int32_t testhashs32_fnv1a) {
+ fbb_.AddElement<int32_t>(Monster::VT_TESTHASHS32_FNV1A, testhashs32_fnv1a, 0);
+ }
+ void add_testhashu32_fnv1a(uint32_t testhashu32_fnv1a) {
+ fbb_.AddElement<uint32_t>(Monster::VT_TESTHASHU32_FNV1A, testhashu32_fnv1a, 0);
+ }
+ void add_testhashs64_fnv1a(int64_t testhashs64_fnv1a) {
+ fbb_.AddElement<int64_t>(Monster::VT_TESTHASHS64_FNV1A, testhashs64_fnv1a, 0);
+ }
+ void add_testhashu64_fnv1a(uint64_t testhashu64_fnv1a) {
+ fbb_.AddElement<uint64_t>(Monster::VT_TESTHASHU64_FNV1A, testhashu64_fnv1a, 0);
+ }
+ void add_testarrayofbools(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> testarrayofbools) {
+ fbb_.AddOffset(Monster::VT_TESTARRAYOFBOOLS, testarrayofbools);
+ }
+ void add_testf(float testf) {
+ fbb_.AddElement<float>(Monster::VT_TESTF, testf, 3.14159f);
+ }
+ void add_testf2(float testf2) {
+ fbb_.AddElement<float>(Monster::VT_TESTF2, testf2, 3.0f);
+ }
+ void add_testf3(float testf3) {
+ fbb_.AddElement<float>(Monster::VT_TESTF3, testf3, 0.0f);
+ }
+ void add_testarrayofstring2(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> testarrayofstring2) {
+ fbb_.AddOffset(Monster::VT_TESTARRAYOFSTRING2, testarrayofstring2);
+ }
+ void add_testarrayofsortedstruct(flatbuffers::Offset<flatbuffers::Vector<const MyGame::Example::Ability *>> testarrayofsortedstruct) {
+ fbb_.AddOffset(Monster::VT_TESTARRAYOFSORTEDSTRUCT, testarrayofsortedstruct);
+ }
+ void add_flex(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> flex) {
+ fbb_.AddOffset(Monster::VT_FLEX, flex);
+ }
+ void add_test5(flatbuffers::Offset<flatbuffers::Vector<const MyGame::Example::Test *>> test5) {
+ fbb_.AddOffset(Monster::VT_TEST5, test5);
+ }
+ void add_vector_of_longs(flatbuffers::Offset<flatbuffers::Vector<int64_t>> vector_of_longs) {
+ fbb_.AddOffset(Monster::VT_VECTOR_OF_LONGS, vector_of_longs);
+ }
+ void add_vector_of_doubles(flatbuffers::Offset<flatbuffers::Vector<double>> vector_of_doubles) {
+ fbb_.AddOffset(Monster::VT_VECTOR_OF_DOUBLES, vector_of_doubles);
+ }
+ void add_parent_namespace_test(flatbuffers::Offset<MyGame::InParentNamespace> parent_namespace_test) {
+ fbb_.AddOffset(Monster::VT_PARENT_NAMESPACE_TEST, parent_namespace_test);
+ }
+ void add_vector_of_referrables(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>>> vector_of_referrables) {
+ fbb_.AddOffset(Monster::VT_VECTOR_OF_REFERRABLES, vector_of_referrables);
+ }
+ void add_single_weak_reference(uint64_t single_weak_reference) {
+ fbb_.AddElement<uint64_t>(Monster::VT_SINGLE_WEAK_REFERENCE, single_weak_reference, 0);
+ }
+ void add_vector_of_weak_references(flatbuffers::Offset<flatbuffers::Vector<uint64_t>> vector_of_weak_references) {
+ fbb_.AddOffset(Monster::VT_VECTOR_OF_WEAK_REFERENCES, vector_of_weak_references);
+ }
+ void add_vector_of_strong_referrables(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>>> vector_of_strong_referrables) {
+ fbb_.AddOffset(Monster::VT_VECTOR_OF_STRONG_REFERRABLES, vector_of_strong_referrables);
+ }
+ void add_co_owning_reference(uint64_t co_owning_reference) {
+ fbb_.AddElement<uint64_t>(Monster::VT_CO_OWNING_REFERENCE, co_owning_reference, 0);
+ }
+ void add_vector_of_co_owning_references(flatbuffers::Offset<flatbuffers::Vector<uint64_t>> vector_of_co_owning_references) {
+ fbb_.AddOffset(Monster::VT_VECTOR_OF_CO_OWNING_REFERENCES, vector_of_co_owning_references);
+ }
+ void add_non_owning_reference(uint64_t non_owning_reference) {
+ fbb_.AddElement<uint64_t>(Monster::VT_NON_OWNING_REFERENCE, non_owning_reference, 0);
+ }
+ void add_vector_of_non_owning_references(flatbuffers::Offset<flatbuffers::Vector<uint64_t>> vector_of_non_owning_references) {
+ fbb_.AddOffset(Monster::VT_VECTOR_OF_NON_OWNING_REFERENCES, vector_of_non_owning_references);
+ }
+ void add_any_unique_type(MyGame::Example::AnyUniqueAliases any_unique_type) {
+ fbb_.AddElement<uint8_t>(Monster::VT_ANY_UNIQUE_TYPE, static_cast<uint8_t>(any_unique_type), 0);
+ }
+ void add_any_unique(flatbuffers::Offset<void> any_unique) {
+ fbb_.AddOffset(Monster::VT_ANY_UNIQUE, any_unique);
+ }
+ void add_any_ambiguous_type(MyGame::Example::AnyAmbiguousAliases any_ambiguous_type) {
+ fbb_.AddElement<uint8_t>(Monster::VT_ANY_AMBIGUOUS_TYPE, static_cast<uint8_t>(any_ambiguous_type), 0);
+ }
+ void add_any_ambiguous(flatbuffers::Offset<void> any_ambiguous) {
+ fbb_.AddOffset(Monster::VT_ANY_AMBIGUOUS, any_ambiguous);
+ }
+ void add_vector_of_enums(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> vector_of_enums) {
+ fbb_.AddOffset(Monster::VT_VECTOR_OF_ENUMS, vector_of_enums);
+ }
+ void add_signed_enum(MyGame::Example::Race signed_enum) {
+ fbb_.AddElement<int8_t>(Monster::VT_SIGNED_ENUM, static_cast<int8_t>(signed_enum), -1);
+ }
+ void add_testrequirednestedflatbuffer(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> testrequirednestedflatbuffer) {
+ fbb_.AddOffset(Monster::VT_TESTREQUIREDNESTEDFLATBUFFER, testrequirednestedflatbuffer);
+ }
+ void add_scalar_key_sorted_tables(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Stat>>> scalar_key_sorted_tables) {
+ fbb_.AddOffset(Monster::VT_SCALAR_KEY_SORTED_TABLES, scalar_key_sorted_tables);
+ }
+ void add_native_inline(const MyGame::Example::Test *native_inline) {
+ fbb_.AddStruct(Monster::VT_NATIVE_INLINE, native_inline);
+ }
+ void add_long_enum_non_enum_default(MyGame::Example::LongEnum long_enum_non_enum_default) {
+ fbb_.AddElement<uint64_t>(Monster::VT_LONG_ENUM_NON_ENUM_DEFAULT, static_cast<uint64_t>(long_enum_non_enum_default), 0);
+ }
+ void add_long_enum_normal_default(MyGame::Example::LongEnum long_enum_normal_default) {
+ fbb_.AddElement<uint64_t>(Monster::VT_LONG_ENUM_NORMAL_DEFAULT, static_cast<uint64_t>(long_enum_normal_default), 2ULL);
+ }
+ explicit MonsterBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
+ flatbuffers::Offset<Monster> Finish() {
+ const auto end = fbb_.EndTable(start_);
+ auto o = flatbuffers::Offset<Monster>(end);
+ fbb_.Required(o, Monster::VT_NAME);
+ return o;
+ }
+};
+
+inline flatbuffers::Offset<Monster> CreateMonster(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ const MyGame::Example::Vec3 *pos = nullptr,
+ int16_t mana = 150,
+ int16_t hp = 100,
+ flatbuffers::Offset<flatbuffers::String> name = 0,
+ flatbuffers::Offset<flatbuffers::Vector<uint8_t>> inventory = 0,
+ MyGame::Example::Color color = MyGame::Example::Color_Blue,
+ MyGame::Example::Any test_type = MyGame::Example::Any_NONE,
+ flatbuffers::Offset<void> test = 0,
+ flatbuffers::Offset<flatbuffers::Vector<const MyGame::Example::Test *>> test4 = 0,
+ flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> testarrayofstring = 0,
+ flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Monster>>> testarrayoftables = 0,
+ flatbuffers::Offset<MyGame::Example::Monster> enemy = 0,
+ flatbuffers::Offset<flatbuffers::Vector<uint8_t>> testnestedflatbuffer = 0,
+ flatbuffers::Offset<MyGame::Example::Stat> testempty = 0,
+ bool testbool = false,
+ int32_t testhashs32_fnv1 = 0,
+ uint32_t testhashu32_fnv1 = 0,
+ int64_t testhashs64_fnv1 = 0,
+ uint64_t testhashu64_fnv1 = 0,
+ int32_t testhashs32_fnv1a = 0,
+ uint32_t testhashu32_fnv1a = 0,
+ int64_t testhashs64_fnv1a = 0,
+ uint64_t testhashu64_fnv1a = 0,
+ flatbuffers::Offset<flatbuffers::Vector<uint8_t>> testarrayofbools = 0,
+ float testf = 3.14159f,
+ float testf2 = 3.0f,
+ float testf3 = 0.0f,
+ flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> testarrayofstring2 = 0,
+ flatbuffers::Offset<flatbuffers::Vector<const MyGame::Example::Ability *>> testarrayofsortedstruct = 0,
+ flatbuffers::Offset<flatbuffers::Vector<uint8_t>> flex = 0,
+ flatbuffers::Offset<flatbuffers::Vector<const MyGame::Example::Test *>> test5 = 0,
+ flatbuffers::Offset<flatbuffers::Vector<int64_t>> vector_of_longs = 0,
+ flatbuffers::Offset<flatbuffers::Vector<double>> vector_of_doubles = 0,
+ flatbuffers::Offset<MyGame::InParentNamespace> parent_namespace_test = 0,
+ flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>>> vector_of_referrables = 0,
+ uint64_t single_weak_reference = 0,
+ flatbuffers::Offset<flatbuffers::Vector<uint64_t>> vector_of_weak_references = 0,
+ flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>>> vector_of_strong_referrables = 0,
+ uint64_t co_owning_reference = 0,
+ flatbuffers::Offset<flatbuffers::Vector<uint64_t>> vector_of_co_owning_references = 0,
+ uint64_t non_owning_reference = 0,
+ flatbuffers::Offset<flatbuffers::Vector<uint64_t>> vector_of_non_owning_references = 0,
+ MyGame::Example::AnyUniqueAliases any_unique_type = MyGame::Example::AnyUniqueAliases_NONE,
+ flatbuffers::Offset<void> any_unique = 0,
+ MyGame::Example::AnyAmbiguousAliases any_ambiguous_type = MyGame::Example::AnyAmbiguousAliases_NONE,
+ flatbuffers::Offset<void> any_ambiguous = 0,
+ flatbuffers::Offset<flatbuffers::Vector<uint8_t>> vector_of_enums = 0,
+ MyGame::Example::Race signed_enum = MyGame::Example::Race_None,
+ flatbuffers::Offset<flatbuffers::Vector<uint8_t>> testrequirednestedflatbuffer = 0,
+ flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Stat>>> scalar_key_sorted_tables = 0,
+ const MyGame::Example::Test *native_inline = nullptr,
+ MyGame::Example::LongEnum long_enum_non_enum_default = static_cast<MyGame::Example::LongEnum>(0),
+ MyGame::Example::LongEnum long_enum_normal_default = MyGame::Example::LongEnum_LongOne) {
+ MonsterBuilder builder_(_fbb);
+ builder_.add_long_enum_normal_default(long_enum_normal_default);
+ builder_.add_long_enum_non_enum_default(long_enum_non_enum_default);
+ builder_.add_non_owning_reference(non_owning_reference);
+ builder_.add_co_owning_reference(co_owning_reference);
+ builder_.add_single_weak_reference(single_weak_reference);
+ builder_.add_testhashu64_fnv1a(testhashu64_fnv1a);
+ builder_.add_testhashs64_fnv1a(testhashs64_fnv1a);
+ builder_.add_testhashu64_fnv1(testhashu64_fnv1);
+ builder_.add_testhashs64_fnv1(testhashs64_fnv1);
+ builder_.add_native_inline(native_inline);
+ builder_.add_scalar_key_sorted_tables(scalar_key_sorted_tables);
+ builder_.add_testrequirednestedflatbuffer(testrequirednestedflatbuffer);
+ builder_.add_vector_of_enums(vector_of_enums);
+ builder_.add_any_ambiguous(any_ambiguous);
+ builder_.add_any_unique(any_unique);
+ builder_.add_vector_of_non_owning_references(vector_of_non_owning_references);
+ builder_.add_vector_of_co_owning_references(vector_of_co_owning_references);
+ builder_.add_vector_of_strong_referrables(vector_of_strong_referrables);
+ builder_.add_vector_of_weak_references(vector_of_weak_references);
+ builder_.add_vector_of_referrables(vector_of_referrables);
+ builder_.add_parent_namespace_test(parent_namespace_test);
+ builder_.add_vector_of_doubles(vector_of_doubles);
+ builder_.add_vector_of_longs(vector_of_longs);
+ builder_.add_test5(test5);
+ builder_.add_flex(flex);
+ builder_.add_testarrayofsortedstruct(testarrayofsortedstruct);
+ builder_.add_testarrayofstring2(testarrayofstring2);
+ builder_.add_testf3(testf3);
+ builder_.add_testf2(testf2);
+ builder_.add_testf(testf);
+ builder_.add_testarrayofbools(testarrayofbools);
+ builder_.add_testhashu32_fnv1a(testhashu32_fnv1a);
+ builder_.add_testhashs32_fnv1a(testhashs32_fnv1a);
+ builder_.add_testhashu32_fnv1(testhashu32_fnv1);
+ builder_.add_testhashs32_fnv1(testhashs32_fnv1);
+ builder_.add_testempty(testempty);
+ builder_.add_testnestedflatbuffer(testnestedflatbuffer);
+ builder_.add_enemy(enemy);
+ builder_.add_testarrayoftables(testarrayoftables);
+ builder_.add_testarrayofstring(testarrayofstring);
+ builder_.add_test4(test4);
+ builder_.add_test(test);
+ builder_.add_inventory(inventory);
+ builder_.add_name(name);
+ builder_.add_pos(pos);
+ builder_.add_hp(hp);
+ builder_.add_mana(mana);
+ builder_.add_signed_enum(signed_enum);
+ builder_.add_any_ambiguous_type(any_ambiguous_type);
+ builder_.add_any_unique_type(any_unique_type);
+ builder_.add_testbool(testbool);
+ builder_.add_test_type(test_type);
+ builder_.add_color(color);
+ return builder_.Finish();
+}
+
+inline flatbuffers::Offset<Monster> CreateMonsterDirect(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ const MyGame::Example::Vec3 *pos = nullptr,
+ int16_t mana = 150,
+ int16_t hp = 100,
+ const char *name = nullptr,
+ const std::vector<uint8_t> *inventory = nullptr,
+ MyGame::Example::Color color = MyGame::Example::Color_Blue,
+ MyGame::Example::Any test_type = MyGame::Example::Any_NONE,
+ flatbuffers::Offset<void> test = 0,
+ const std::vector<MyGame::Example::Test> *test4 = nullptr,
+ const std::vector<flatbuffers::Offset<flatbuffers::String>> *testarrayofstring = nullptr,
+ std::vector<flatbuffers::Offset<MyGame::Example::Monster>> *testarrayoftables = nullptr,
+ flatbuffers::Offset<MyGame::Example::Monster> enemy = 0,
+ const std::vector<uint8_t> *testnestedflatbuffer = nullptr,
+ flatbuffers::Offset<MyGame::Example::Stat> testempty = 0,
+ bool testbool = false,
+ int32_t testhashs32_fnv1 = 0,
+ uint32_t testhashu32_fnv1 = 0,
+ int64_t testhashs64_fnv1 = 0,
+ uint64_t testhashu64_fnv1 = 0,
+ int32_t testhashs32_fnv1a = 0,
+ uint32_t testhashu32_fnv1a = 0,
+ int64_t testhashs64_fnv1a = 0,
+ uint64_t testhashu64_fnv1a = 0,
+ const std::vector<uint8_t> *testarrayofbools = nullptr,
+ float testf = 3.14159f,
+ float testf2 = 3.0f,
+ float testf3 = 0.0f,
+ const std::vector<flatbuffers::Offset<flatbuffers::String>> *testarrayofstring2 = nullptr,
+ std::vector<MyGame::Example::Ability> *testarrayofsortedstruct = nullptr,
+ const std::vector<uint8_t> *flex = nullptr,
+ const std::vector<MyGame::Example::Test> *test5 = nullptr,
+ const std::vector<int64_t> *vector_of_longs = nullptr,
+ const std::vector<double> *vector_of_doubles = nullptr,
+ flatbuffers::Offset<MyGame::InParentNamespace> parent_namespace_test = 0,
+ std::vector<flatbuffers::Offset<MyGame::Example::Referrable>> *vector_of_referrables = nullptr,
+ uint64_t single_weak_reference = 0,
+ const std::vector<uint64_t> *vector_of_weak_references = nullptr,
+ std::vector<flatbuffers::Offset<MyGame::Example::Referrable>> *vector_of_strong_referrables = nullptr,
+ uint64_t co_owning_reference = 0,
+ const std::vector<uint64_t> *vector_of_co_owning_references = nullptr,
+ uint64_t non_owning_reference = 0,
+ const std::vector<uint64_t> *vector_of_non_owning_references = nullptr,
+ MyGame::Example::AnyUniqueAliases any_unique_type = MyGame::Example::AnyUniqueAliases_NONE,
+ flatbuffers::Offset<void> any_unique = 0,
+ MyGame::Example::AnyAmbiguousAliases any_ambiguous_type = MyGame::Example::AnyAmbiguousAliases_NONE,
+ flatbuffers::Offset<void> any_ambiguous = 0,
+ const std::vector<uint8_t> *vector_of_enums = nullptr,
+ MyGame::Example::Race signed_enum = MyGame::Example::Race_None,
+ const std::vector<uint8_t> *testrequirednestedflatbuffer = nullptr,
+ std::vector<flatbuffers::Offset<MyGame::Example::Stat>> *scalar_key_sorted_tables = nullptr,
+ const MyGame::Example::Test *native_inline = nullptr,
+ MyGame::Example::LongEnum long_enum_non_enum_default = static_cast<MyGame::Example::LongEnum>(0),
+ MyGame::Example::LongEnum long_enum_normal_default = MyGame::Example::LongEnum_LongOne) {
+ auto name__ = name ? _fbb.CreateString(name) : 0;
+ auto inventory__ = inventory ? _fbb.CreateVector<uint8_t>(*inventory) : 0;
+ auto test4__ = test4 ? _fbb.CreateVectorOfStructs<MyGame::Example::Test>(*test4) : 0;
+ auto testarrayofstring__ = testarrayofstring ? _fbb.CreateVector<flatbuffers::Offset<flatbuffers::String>>(*testarrayofstring) : 0;
+ auto testarrayoftables__ = testarrayoftables ? _fbb.CreateVectorOfSortedTables<MyGame::Example::Monster>(testarrayoftables) : 0;
+ auto testnestedflatbuffer__ = testnestedflatbuffer ? _fbb.CreateVector<uint8_t>(*testnestedflatbuffer) : 0;
+ auto testarrayofbools__ = testarrayofbools ? _fbb.CreateVector<uint8_t>(*testarrayofbools) : 0;
+ auto testarrayofstring2__ = testarrayofstring2 ? _fbb.CreateVector<flatbuffers::Offset<flatbuffers::String>>(*testarrayofstring2) : 0;
+ auto testarrayofsortedstruct__ = testarrayofsortedstruct ? _fbb.CreateVectorOfSortedStructs<MyGame::Example::Ability>(testarrayofsortedstruct) : 0;
+ auto flex__ = flex ? _fbb.CreateVector<uint8_t>(*flex) : 0;
+ auto test5__ = test5 ? _fbb.CreateVectorOfStructs<MyGame::Example::Test>(*test5) : 0;
+ auto vector_of_longs__ = vector_of_longs ? _fbb.CreateVector<int64_t>(*vector_of_longs) : 0;
+ auto vector_of_doubles__ = vector_of_doubles ? _fbb.CreateVector<double>(*vector_of_doubles) : 0;
+ auto vector_of_referrables__ = vector_of_referrables ? _fbb.CreateVectorOfSortedTables<MyGame::Example::Referrable>(vector_of_referrables) : 0;
+ auto vector_of_weak_references__ = vector_of_weak_references ? _fbb.CreateVector<uint64_t>(*vector_of_weak_references) : 0;
+ auto vector_of_strong_referrables__ = vector_of_strong_referrables ? _fbb.CreateVectorOfSortedTables<MyGame::Example::Referrable>(vector_of_strong_referrables) : 0;
+ auto vector_of_co_owning_references__ = vector_of_co_owning_references ? _fbb.CreateVector<uint64_t>(*vector_of_co_owning_references) : 0;
+ auto vector_of_non_owning_references__ = vector_of_non_owning_references ? _fbb.CreateVector<uint64_t>(*vector_of_non_owning_references) : 0;
+ auto vector_of_enums__ = vector_of_enums ? _fbb.CreateVector<uint8_t>(*vector_of_enums) : 0;
+ auto testrequirednestedflatbuffer__ = testrequirednestedflatbuffer ? _fbb.CreateVector<uint8_t>(*testrequirednestedflatbuffer) : 0;
+ auto scalar_key_sorted_tables__ = scalar_key_sorted_tables ? _fbb.CreateVectorOfSortedTables<MyGame::Example::Stat>(scalar_key_sorted_tables) : 0;
+ return MyGame::Example::CreateMonster(
+ _fbb,
+ pos,
+ mana,
+ hp,
+ name__,
+ inventory__,
+ color,
+ test_type,
+ test,
+ test4__,
+ testarrayofstring__,
+ testarrayoftables__,
+ enemy,
+ testnestedflatbuffer__,
+ testempty,
+ testbool,
+ testhashs32_fnv1,
+ testhashu32_fnv1,
+ testhashs64_fnv1,
+ testhashu64_fnv1,
+ testhashs32_fnv1a,
+ testhashu32_fnv1a,
+ testhashs64_fnv1a,
+ testhashu64_fnv1a,
+ testarrayofbools__,
+ testf,
+ testf2,
+ testf3,
+ testarrayofstring2__,
+ testarrayofsortedstruct__,
+ flex__,
+ test5__,
+ vector_of_longs__,
+ vector_of_doubles__,
+ parent_namespace_test,
+ vector_of_referrables__,
+ single_weak_reference,
+ vector_of_weak_references__,
+ vector_of_strong_referrables__,
+ co_owning_reference,
+ vector_of_co_owning_references__,
+ non_owning_reference,
+ vector_of_non_owning_references__,
+ any_unique_type,
+ any_unique,
+ any_ambiguous_type,
+ any_ambiguous,
+ vector_of_enums__,
+ signed_enum,
+ testrequirednestedflatbuffer__,
+ scalar_key_sorted_tables__,
+ native_inline,
+ long_enum_non_enum_default,
+ long_enum_normal_default);
+}
+
+flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+
+struct TypeAliasesT : public flatbuffers::NativeTable {
+ typedef TypeAliases TableType;
+ int8_t i8 = 0;
+ uint8_t u8 = 0;
+ int16_t i16 = 0;
+ uint16_t u16 = 0;
+ int32_t i32 = 0;
+ uint32_t u32 = 0;
+ int64_t i64 = 0;
+ uint64_t u64 = 0;
+ float f32 = 0.0f;
+ double f64 = 0.0;
+ std::vector<int8_t> v8{};
+ std::vector<double> vf64{};
+};
+
+struct TypeAliases FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
+ typedef TypeAliasesT NativeTableType;
+ typedef TypeAliasesBuilder Builder;
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return TypeAliasesTypeTable();
+ }
+ enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
+ VT_I8 = 4,
+ VT_U8 = 6,
+ VT_I16 = 8,
+ VT_U16 = 10,
+ VT_I32 = 12,
+ VT_U32 = 14,
+ VT_I64 = 16,
+ VT_U64 = 18,
+ VT_F32 = 20,
+ VT_F64 = 22,
+ VT_V8 = 24,
+ VT_VF64 = 26
+ };
+ int8_t i8() const {
+ return GetField<int8_t>(VT_I8, 0);
+ }
+ bool mutate_i8(int8_t _i8 = 0) {
+ return SetField<int8_t>(VT_I8, _i8, 0);
+ }
+ uint8_t u8() const {
+ return GetField<uint8_t>(VT_U8, 0);
+ }
+ bool mutate_u8(uint8_t _u8 = 0) {
+ return SetField<uint8_t>(VT_U8, _u8, 0);
+ }
+ int16_t i16() const {
+ return GetField<int16_t>(VT_I16, 0);
+ }
+ bool mutate_i16(int16_t _i16 = 0) {
+ return SetField<int16_t>(VT_I16, _i16, 0);
+ }
+ uint16_t u16() const {
+ return GetField<uint16_t>(VT_U16, 0);
+ }
+ bool mutate_u16(uint16_t _u16 = 0) {
+ return SetField<uint16_t>(VT_U16, _u16, 0);
+ }
+ int32_t i32() const {
+ return GetField<int32_t>(VT_I32, 0);
+ }
+ bool mutate_i32(int32_t _i32 = 0) {
+ return SetField<int32_t>(VT_I32, _i32, 0);
+ }
+ uint32_t u32() const {
+ return GetField<uint32_t>(VT_U32, 0);
+ }
+ bool mutate_u32(uint32_t _u32 = 0) {
+ return SetField<uint32_t>(VT_U32, _u32, 0);
+ }
+ int64_t i64() const {
+ return GetField<int64_t>(VT_I64, 0);
+ }
+ bool mutate_i64(int64_t _i64 = 0) {
+ return SetField<int64_t>(VT_I64, _i64, 0);
+ }
+ uint64_t u64() const {
+ return GetField<uint64_t>(VT_U64, 0);
+ }
+ bool mutate_u64(uint64_t _u64 = 0) {
+ return SetField<uint64_t>(VT_U64, _u64, 0);
+ }
+ float f32() const {
+ return GetField<float>(VT_F32, 0.0f);
+ }
+ bool mutate_f32(float _f32 = 0.0f) {
+ return SetField<float>(VT_F32, _f32, 0.0f);
+ }
+ double f64() const {
+ return GetField<double>(VT_F64, 0.0);
+ }
+ bool mutate_f64(double _f64 = 0.0) {
+ return SetField<double>(VT_F64, _f64, 0.0);
+ }
+ const flatbuffers::Vector<int8_t> *v8() const {
+ return GetPointer<const flatbuffers::Vector<int8_t> *>(VT_V8);
+ }
+ flatbuffers::Vector<int8_t> *mutable_v8() {
+ return GetPointer<flatbuffers::Vector<int8_t> *>(VT_V8);
+ }
+ const flatbuffers::Vector<double> *vf64() const {
+ return GetPointer<const flatbuffers::Vector<double> *>(VT_VF64);
+ }
+ flatbuffers::Vector<double> *mutable_vf64() {
+ return GetPointer<flatbuffers::Vector<double> *>(VT_VF64);
+ }
+ bool Verify(flatbuffers::Verifier &verifier) const {
+ return VerifyTableStart(verifier) &&
+ VerifyField<int8_t>(verifier, VT_I8, 1) &&
+ VerifyField<uint8_t>(verifier, VT_U8, 1) &&
+ VerifyField<int16_t>(verifier, VT_I16, 2) &&
+ VerifyField<uint16_t>(verifier, VT_U16, 2) &&
+ VerifyField<int32_t>(verifier, VT_I32, 4) &&
+ VerifyField<uint32_t>(verifier, VT_U32, 4) &&
+ VerifyField<int64_t>(verifier, VT_I64, 8) &&
+ VerifyField<uint64_t>(verifier, VT_U64, 8) &&
+ VerifyField<float>(verifier, VT_F32, 4) &&
+ VerifyField<double>(verifier, VT_F64, 8) &&
+ VerifyOffset(verifier, VT_V8) &&
+ verifier.VerifyVector(v8()) &&
+ VerifyOffset(verifier, VT_VF64) &&
+ verifier.VerifyVector(vf64()) &&
+ verifier.EndTable();
+ }
+ TypeAliasesT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ void UnPackTo(TypeAliasesT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ static flatbuffers::Offset<TypeAliases> Pack(flatbuffers::FlatBufferBuilder &_fbb, const TypeAliasesT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+};
+
+struct TypeAliasesBuilder {
+ typedef TypeAliases Table;
+ flatbuffers::FlatBufferBuilder &fbb_;
+ flatbuffers::uoffset_t start_;
+ void add_i8(int8_t i8) {
+ fbb_.AddElement<int8_t>(TypeAliases::VT_I8, i8, 0);
+ }
+ void add_u8(uint8_t u8) {
+ fbb_.AddElement<uint8_t>(TypeAliases::VT_U8, u8, 0);
+ }
+ void add_i16(int16_t i16) {
+ fbb_.AddElement<int16_t>(TypeAliases::VT_I16, i16, 0);
+ }
+ void add_u16(uint16_t u16) {
+ fbb_.AddElement<uint16_t>(TypeAliases::VT_U16, u16, 0);
+ }
+ void add_i32(int32_t i32) {
+ fbb_.AddElement<int32_t>(TypeAliases::VT_I32, i32, 0);
+ }
+ void add_u32(uint32_t u32) {
+ fbb_.AddElement<uint32_t>(TypeAliases::VT_U32, u32, 0);
+ }
+ void add_i64(int64_t i64) {
+ fbb_.AddElement<int64_t>(TypeAliases::VT_I64, i64, 0);
+ }
+ void add_u64(uint64_t u64) {
+ fbb_.AddElement<uint64_t>(TypeAliases::VT_U64, u64, 0);
+ }
+ void add_f32(float f32) {
+ fbb_.AddElement<float>(TypeAliases::VT_F32, f32, 0.0f);
+ }
+ void add_f64(double f64) {
+ fbb_.AddElement<double>(TypeAliases::VT_F64, f64, 0.0);
+ }
+ void add_v8(flatbuffers::Offset<flatbuffers::Vector<int8_t>> v8) {
+ fbb_.AddOffset(TypeAliases::VT_V8, v8);
+ }
+ void add_vf64(flatbuffers::Offset<flatbuffers::Vector<double>> vf64) {
+ fbb_.AddOffset(TypeAliases::VT_VF64, vf64);
+ }
+ explicit TypeAliasesBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
+ flatbuffers::Offset<TypeAliases> Finish() {
+ const auto end = fbb_.EndTable(start_);
+ auto o = flatbuffers::Offset<TypeAliases>(end);
+ return o;
+ }
+};
+
+inline flatbuffers::Offset<TypeAliases> CreateTypeAliases(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ int8_t i8 = 0,
+ uint8_t u8 = 0,
+ int16_t i16 = 0,
+ uint16_t u16 = 0,
+ int32_t i32 = 0,
+ uint32_t u32 = 0,
+ int64_t i64 = 0,
+ uint64_t u64 = 0,
+ float f32 = 0.0f,
+ double f64 = 0.0,
+ flatbuffers::Offset<flatbuffers::Vector<int8_t>> v8 = 0,
+ flatbuffers::Offset<flatbuffers::Vector<double>> vf64 = 0) {
+ TypeAliasesBuilder builder_(_fbb);
+ builder_.add_f64(f64);
+ builder_.add_u64(u64);
+ builder_.add_i64(i64);
+ builder_.add_vf64(vf64);
+ builder_.add_v8(v8);
+ builder_.add_f32(f32);
+ builder_.add_u32(u32);
+ builder_.add_i32(i32);
+ builder_.add_u16(u16);
+ builder_.add_i16(i16);
+ builder_.add_u8(u8);
+ builder_.add_i8(i8);
+ return builder_.Finish();
+}
+
+inline flatbuffers::Offset<TypeAliases> CreateTypeAliasesDirect(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ int8_t i8 = 0,
+ uint8_t u8 = 0,
+ int16_t i16 = 0,
+ uint16_t u16 = 0,
+ int32_t i32 = 0,
+ uint32_t u32 = 0,
+ int64_t i64 = 0,
+ uint64_t u64 = 0,
+ float f32 = 0.0f,
+ double f64 = 0.0,
+ const std::vector<int8_t> *v8 = nullptr,
+ const std::vector<double> *vf64 = nullptr) {
+ auto v8__ = v8 ? _fbb.CreateVector<int8_t>(*v8) : 0;
+ auto vf64__ = vf64 ? _fbb.CreateVector<double>(*vf64) : 0;
+ return MyGame::Example::CreateTypeAliases(
+ _fbb,
+ i8,
+ u8,
+ i16,
+ u16,
+ i32,
+ u32,
+ i64,
+ u64,
+ f32,
+ f64,
+ v8__,
+ vf64__);
+}
+
+flatbuffers::Offset<TypeAliases> CreateTypeAliases(flatbuffers::FlatBufferBuilder &_fbb, const TypeAliasesT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+
+} // namespace Example
+
+
+inline bool operator==(const InParentNamespaceT &, const InParentNamespaceT &) {
+ return true;
+}
+
+inline bool operator!=(const InParentNamespaceT &lhs, const InParentNamespaceT &rhs) {
+ return !(lhs == rhs);
+}
+
+
+inline InParentNamespaceT *InParentNamespace::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
+ auto _o = std::unique_ptr<InParentNamespaceT>(new InParentNamespaceT());
+ UnPackTo(_o.get(), _resolver);
+ return _o.release();
+}
+
+inline void InParentNamespace::UnPackTo(InParentNamespaceT *_o, const flatbuffers::resolver_function_t *_resolver) const {
+ (void)_o;
+ (void)_resolver;
+}
+
+inline flatbuffers::Offset<InParentNamespace> InParentNamespace::Pack(flatbuffers::FlatBufferBuilder &_fbb, const InParentNamespaceT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
+ return CreateInParentNamespace(_fbb, _o, _rehasher);
+}
+
+inline flatbuffers::Offset<InParentNamespace> CreateInParentNamespace(flatbuffers::FlatBufferBuilder &_fbb, const InParentNamespaceT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
+ (void)_rehasher;
+ (void)_o;
+ struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const InParentNamespaceT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
+ return MyGame::CreateInParentNamespace(
+ _fbb);
+}
+
+namespace Example2 {
+
+
+inline bool operator==(const MonsterT &, const MonsterT &) {
+ return true;
+}
+
+inline bool operator!=(const MonsterT &lhs, const MonsterT &rhs) {
+ return !(lhs == rhs);
+}
+
+
+inline MonsterT *Monster::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
+ auto _o = std::unique_ptr<MonsterT>(new MonsterT());
+ UnPackTo(_o.get(), _resolver);
+ return _o.release();
+}
+
+inline void Monster::UnPackTo(MonsterT *_o, const flatbuffers::resolver_function_t *_resolver) const {
+ (void)_o;
+ (void)_resolver;
+}
+
+inline flatbuffers::Offset<Monster> Monster::Pack(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
+ return CreateMonster(_fbb, _o, _rehasher);
+}
+
+inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
+ (void)_rehasher;
+ (void)_o;
+ struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const MonsterT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
+ return MyGame::Example2::CreateMonster(
+ _fbb);
+}
+
+} // namespace Example2
+
+namespace Example {
+
+
+inline bool operator==(const TestSimpleTableWithEnumT &lhs, const TestSimpleTableWithEnumT &rhs) {
+ return
+ (lhs.color == rhs.color);
+}
+
+inline bool operator!=(const TestSimpleTableWithEnumT &lhs, const TestSimpleTableWithEnumT &rhs) {
+ return !(lhs == rhs);
+}
+
+
+inline TestSimpleTableWithEnumT *TestSimpleTableWithEnum::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
+ auto _o = std::unique_ptr<TestSimpleTableWithEnumT>(new TestSimpleTableWithEnumT());
+ UnPackTo(_o.get(), _resolver);
+ return _o.release();
+}
+
+inline void TestSimpleTableWithEnum::UnPackTo(TestSimpleTableWithEnumT *_o, const flatbuffers::resolver_function_t *_resolver) const {
+ (void)_o;
+ (void)_resolver;
+ { auto _e = color(); _o->color = _e; }
+}
+
+inline flatbuffers::Offset<TestSimpleTableWithEnum> TestSimpleTableWithEnum::Pack(flatbuffers::FlatBufferBuilder &_fbb, const TestSimpleTableWithEnumT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
+ return CreateTestSimpleTableWithEnum(_fbb, _o, _rehasher);
+}
+
+inline flatbuffers::Offset<TestSimpleTableWithEnum> CreateTestSimpleTableWithEnum(flatbuffers::FlatBufferBuilder &_fbb, const TestSimpleTableWithEnumT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
+ (void)_rehasher;
+ (void)_o;
+ struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const TestSimpleTableWithEnumT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
+ auto _color = _o->color;
+ return MyGame::Example::CreateTestSimpleTableWithEnum(
+ _fbb,
+ _color);
+}
+
+
+inline bool operator==(const StatT &lhs, const StatT &rhs) {
+ return
+ (lhs.id == rhs.id) &&
+ (lhs.val == rhs.val) &&
+ (lhs.count == rhs.count);
+}
+
+inline bool operator!=(const StatT &lhs, const StatT &rhs) {
+ return !(lhs == rhs);
+}
+
+
+inline StatT *Stat::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
+ auto _o = std::unique_ptr<StatT>(new StatT());
+ UnPackTo(_o.get(), _resolver);
+ return _o.release();
+}
+
+inline void Stat::UnPackTo(StatT *_o, const flatbuffers::resolver_function_t *_resolver) const {
+ (void)_o;
+ (void)_resolver;
+ { auto _e = id(); if (_e) _o->id = _e->str(); }
+ { auto _e = val(); _o->val = _e; }
+ { auto _e = count(); _o->count = _e; }
+}
+
+inline flatbuffers::Offset<Stat> Stat::Pack(flatbuffers::FlatBufferBuilder &_fbb, const StatT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
+ return CreateStat(_fbb, _o, _rehasher);
+}
+
+inline flatbuffers::Offset<Stat> CreateStat(flatbuffers::FlatBufferBuilder &_fbb, const StatT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
+ (void)_rehasher;
+ (void)_o;
+ struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const StatT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
+ auto _id = _o->id.empty() ? 0 : _fbb.CreateString(_o->id);
+ auto _val = _o->val;
+ auto _count = _o->count;
+ return MyGame::Example::CreateStat(
+ _fbb,
+ _id,
+ _val,
+ _count);
+}
+
+
+inline bool operator==(const ReferrableT &lhs, const ReferrableT &rhs) {
+ return
+ (lhs.id == rhs.id);
+}
+
+inline bool operator!=(const ReferrableT &lhs, const ReferrableT &rhs) {
+ return !(lhs == rhs);
+}
+
+
+inline ReferrableT *Referrable::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
+ auto _o = std::unique_ptr<ReferrableT>(new ReferrableT());
+ UnPackTo(_o.get(), _resolver);
+ return _o.release();
+}
+
+inline void Referrable::UnPackTo(ReferrableT *_o, const flatbuffers::resolver_function_t *_resolver) const {
+ (void)_o;
+ (void)_resolver;
+ { auto _e = id(); _o->id = _e; }
+}
+
+inline flatbuffers::Offset<Referrable> Referrable::Pack(flatbuffers::FlatBufferBuilder &_fbb, const ReferrableT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
+ return CreateReferrable(_fbb, _o, _rehasher);
+}
+
+inline flatbuffers::Offset<Referrable> CreateReferrable(flatbuffers::FlatBufferBuilder &_fbb, const ReferrableT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
+ (void)_rehasher;
+ (void)_o;
+ struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const ReferrableT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
+ auto _id = _o->id;
+ return MyGame::Example::CreateReferrable(
+ _fbb,
+ _id);
+}
+
+
+inline bool operator==(const MonsterT &lhs, const MonsterT &rhs) {
+ return
+ ((lhs.pos == rhs.pos) || (lhs.pos && rhs.pos && *lhs.pos == *rhs.pos)) &&
+ (lhs.mana == rhs.mana) &&
+ (lhs.hp == rhs.hp) &&
+ (lhs.name == rhs.name) &&
+ (lhs.inventory == rhs.inventory) &&
+ (lhs.color == rhs.color) &&
+ (lhs.test == rhs.test) &&
+ (lhs.test4 == rhs.test4) &&
+ (lhs.testarrayofstring == rhs.testarrayofstring) &&
+ (lhs.testarrayoftables.size() == rhs.testarrayoftables.size() && std::equal(lhs.testarrayoftables.cbegin(), lhs.testarrayoftables.cend(), rhs.testarrayoftables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::MonsterT> const &a, flatbuffers::unique_ptr<MyGame::Example::MonsterT> const &b) { return (a == b) || (a && b && *a == *b); })) &&
+ ((lhs.enemy == rhs.enemy) || (lhs.enemy && rhs.enemy && *lhs.enemy == *rhs.enemy)) &&
+ (lhs.testnestedflatbuffer == rhs.testnestedflatbuffer) &&
+ ((lhs.testempty == rhs.testempty) || (lhs.testempty && rhs.testempty && *lhs.testempty == *rhs.testempty)) &&
+ (lhs.testbool == rhs.testbool) &&
+ (lhs.testhashs32_fnv1 == rhs.testhashs32_fnv1) &&
+ (lhs.testhashu32_fnv1 == rhs.testhashu32_fnv1) &&
+ (lhs.testhashs64_fnv1 == rhs.testhashs64_fnv1) &&
+ (lhs.testhashu64_fnv1 == rhs.testhashu64_fnv1) &&
+ (lhs.testhashs32_fnv1a == rhs.testhashs32_fnv1a) &&
+ (lhs.testhashu32_fnv1a == rhs.testhashu32_fnv1a) &&
+ (lhs.testhashs64_fnv1a == rhs.testhashs64_fnv1a) &&
+ (lhs.testhashu64_fnv1a == rhs.testhashu64_fnv1a) &&
+ (lhs.testarrayofbools == rhs.testarrayofbools) &&
+ (lhs.testf == rhs.testf) &&
+ (lhs.testf2 == rhs.testf2) &&
+ (lhs.testf3 == rhs.testf3) &&
+ (lhs.testarrayofstring2 == rhs.testarrayofstring2) &&
+ (lhs.testarrayofsortedstruct == rhs.testarrayofsortedstruct) &&
+ (lhs.flex == rhs.flex) &&
+ (lhs.test5 == rhs.test5) &&
+ (lhs.vector_of_longs == rhs.vector_of_longs) &&
+ (lhs.vector_of_doubles == rhs.vector_of_doubles) &&
+ ((lhs.parent_namespace_test == rhs.parent_namespace_test) || (lhs.parent_namespace_test && rhs.parent_namespace_test && *lhs.parent_namespace_test == *rhs.parent_namespace_test)) &&
+ (lhs.vector_of_referrables.size() == rhs.vector_of_referrables.size() && std::equal(lhs.vector_of_referrables.cbegin(), lhs.vector_of_referrables.cend(), rhs.vector_of_referrables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &a, flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &b) { return (a == b) || (a && b && *a == *b); })) &&
+ (lhs.single_weak_reference == rhs.single_weak_reference) &&
+ (lhs.vector_of_weak_references == rhs.vector_of_weak_references) &&
+ (lhs.vector_of_strong_referrables.size() == rhs.vector_of_strong_referrables.size() && std::equal(lhs.vector_of_strong_referrables.cbegin(), lhs.vector_of_strong_referrables.cend(), rhs.vector_of_strong_referrables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &a, flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &b) { return (a == b) || (a && b && *a == *b); })) &&
+ (lhs.co_owning_reference == rhs.co_owning_reference) &&
+ (lhs.vector_of_co_owning_references == rhs.vector_of_co_owning_references) &&
+ (lhs.non_owning_reference == rhs.non_owning_reference) &&
+ (lhs.vector_of_non_owning_references == rhs.vector_of_non_owning_references) &&
+ (lhs.any_unique == rhs.any_unique) &&
+ (lhs.any_ambiguous == rhs.any_ambiguous) &&
+ (lhs.vector_of_enums == rhs.vector_of_enums) &&
+ (lhs.signed_enum == rhs.signed_enum) &&
+ (lhs.testrequirednestedflatbuffer == rhs.testrequirednestedflatbuffer) &&
+ (lhs.scalar_key_sorted_tables.size() == rhs.scalar_key_sorted_tables.size() && std::equal(lhs.scalar_key_sorted_tables.cbegin(), lhs.scalar_key_sorted_tables.cend(), rhs.scalar_key_sorted_tables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::StatT> const &a, flatbuffers::unique_ptr<MyGame::Example::StatT> const &b) { return (a == b) || (a && b && *a == *b); })) &&
+ (lhs.native_inline == rhs.native_inline) &&
+ (lhs.long_enum_non_enum_default == rhs.long_enum_non_enum_default) &&
+ (lhs.long_enum_normal_default == rhs.long_enum_normal_default);
+}
+
+inline bool operator!=(const MonsterT &lhs, const MonsterT &rhs) {
+ return !(lhs == rhs);
+}
+
+
+inline MonsterT::MonsterT(const MonsterT &o)
+ : pos((o.pos) ? new MyGame::Example::Vec3(*o.pos) : nullptr),
+ mana(o.mana),
+ hp(o.hp),
+ name(o.name),
+ inventory(o.inventory),
+ color(o.color),
+ test(o.test),
+ test4(o.test4),
+ testarrayofstring(o.testarrayofstring),
+ enemy((o.enemy) ? new MyGame::Example::MonsterT(*o.enemy) : nullptr),
+ testnestedflatbuffer(o.testnestedflatbuffer),
+ testempty((o.testempty) ? new MyGame::Example::StatT(*o.testempty) : nullptr),
+ testbool(o.testbool),
+ testhashs32_fnv1(o.testhashs32_fnv1),
+ testhashu32_fnv1(o.testhashu32_fnv1),
+ testhashs64_fnv1(o.testhashs64_fnv1),
+ testhashu64_fnv1(o.testhashu64_fnv1),
+ testhashs32_fnv1a(o.testhashs32_fnv1a),
+ testhashu32_fnv1a(o.testhashu32_fnv1a),
+ testhashs64_fnv1a(o.testhashs64_fnv1a),
+ testhashu64_fnv1a(o.testhashu64_fnv1a),
+ testarrayofbools(o.testarrayofbools),
+ testf(o.testf),
+ testf2(o.testf2),
+ testf3(o.testf3),
+ testarrayofstring2(o.testarrayofstring2),
+ testarrayofsortedstruct(o.testarrayofsortedstruct),
+ flex(o.flex),
+ test5(o.test5),
+ vector_of_longs(o.vector_of_longs),
+ vector_of_doubles(o.vector_of_doubles),
+ parent_namespace_test((o.parent_namespace_test) ? new MyGame::InParentNamespaceT(*o.parent_namespace_test) : nullptr),
+ single_weak_reference(o.single_weak_reference),
+ vector_of_weak_references(o.vector_of_weak_references),
+ co_owning_reference(o.co_owning_reference),
+ non_owning_reference(o.non_owning_reference),
+ vector_of_non_owning_references(o.vector_of_non_owning_references),
+ any_unique(o.any_unique),
+ any_ambiguous(o.any_ambiguous),
+ vector_of_enums(o.vector_of_enums),
+ signed_enum(o.signed_enum),
+ testrequirednestedflatbuffer(o.testrequirednestedflatbuffer),
+ native_inline(o.native_inline),
+ long_enum_non_enum_default(o.long_enum_non_enum_default),
+ long_enum_normal_default(o.long_enum_normal_default) {
+ testarrayoftables.reserve(o.testarrayoftables.size());
+ for (const auto &testarrayoftables_ : o.testarrayoftables) { testarrayoftables.emplace_back((testarrayoftables_) ? new MyGame::Example::MonsterT(*testarrayoftables_) : nullptr); }
+ vector_of_referrables.reserve(o.vector_of_referrables.size());
+ for (const auto &vector_of_referrables_ : o.vector_of_referrables) { vector_of_referrables.emplace_back((vector_of_referrables_) ? new MyGame::Example::ReferrableT(*vector_of_referrables_) : nullptr); }
+ vector_of_strong_referrables.reserve(o.vector_of_strong_referrables.size());
+ for (const auto &vector_of_strong_referrables_ : o.vector_of_strong_referrables) { vector_of_strong_referrables.emplace_back((vector_of_strong_referrables_) ? new MyGame::Example::ReferrableT(*vector_of_strong_referrables_) : nullptr); }
+ vector_of_co_owning_references.reserve(o.vector_of_co_owning_references.size());
+ for (const auto &vector_of_co_owning_references_ : o.vector_of_co_owning_references) { vector_of_co_owning_references.emplace_back((vector_of_co_owning_references_) ? new ReferrableT(*vector_of_co_owning_references_) : nullptr); }
+ scalar_key_sorted_tables.reserve(o.scalar_key_sorted_tables.size());
+ for (const auto &scalar_key_sorted_tables_ : o.scalar_key_sorted_tables) { scalar_key_sorted_tables.emplace_back((scalar_key_sorted_tables_) ? new MyGame::Example::StatT(*scalar_key_sorted_tables_) : nullptr); }
+}
+
+inline MonsterT &MonsterT::operator=(MonsterT o) FLATBUFFERS_NOEXCEPT {
+ std::swap(pos, o.pos);
+ std::swap(mana, o.mana);
+ std::swap(hp, o.hp);
+ std::swap(name, o.name);
+ std::swap(inventory, o.inventory);
+ std::swap(color, o.color);
+ std::swap(test, o.test);
+ std::swap(test4, o.test4);
+ std::swap(testarrayofstring, o.testarrayofstring);
+ std::swap(testarrayoftables, o.testarrayoftables);
+ std::swap(enemy, o.enemy);
+ std::swap(testnestedflatbuffer, o.testnestedflatbuffer);
+ std::swap(testempty, o.testempty);
+ std::swap(testbool, o.testbool);
+ std::swap(testhashs32_fnv1, o.testhashs32_fnv1);
+ std::swap(testhashu32_fnv1, o.testhashu32_fnv1);
+ std::swap(testhashs64_fnv1, o.testhashs64_fnv1);
+ std::swap(testhashu64_fnv1, o.testhashu64_fnv1);
+ std::swap(testhashs32_fnv1a, o.testhashs32_fnv1a);
+ std::swap(testhashu32_fnv1a, o.testhashu32_fnv1a);
+ std::swap(testhashs64_fnv1a, o.testhashs64_fnv1a);
+ std::swap(testhashu64_fnv1a, o.testhashu64_fnv1a);
+ std::swap(testarrayofbools, o.testarrayofbools);
+ std::swap(testf, o.testf);
+ std::swap(testf2, o.testf2);
+ std::swap(testf3, o.testf3);
+ std::swap(testarrayofstring2, o.testarrayofstring2);
+ std::swap(testarrayofsortedstruct, o.testarrayofsortedstruct);
+ std::swap(flex, o.flex);
+ std::swap(test5, o.test5);
+ std::swap(vector_of_longs, o.vector_of_longs);
+ std::swap(vector_of_doubles, o.vector_of_doubles);
+ std::swap(parent_namespace_test, o.parent_namespace_test);
+ std::swap(vector_of_referrables, o.vector_of_referrables);
+ std::swap(single_weak_reference, o.single_weak_reference);
+ std::swap(vector_of_weak_references, o.vector_of_weak_references);
+ std::swap(vector_of_strong_referrables, o.vector_of_strong_referrables);
+ std::swap(co_owning_reference, o.co_owning_reference);
+ std::swap(vector_of_co_owning_references, o.vector_of_co_owning_references);
+ std::swap(non_owning_reference, o.non_owning_reference);
+ std::swap(vector_of_non_owning_references, o.vector_of_non_owning_references);
+ std::swap(any_unique, o.any_unique);
+ std::swap(any_ambiguous, o.any_ambiguous);
+ std::swap(vector_of_enums, o.vector_of_enums);
+ std::swap(signed_enum, o.signed_enum);
+ std::swap(testrequirednestedflatbuffer, o.testrequirednestedflatbuffer);
+ std::swap(scalar_key_sorted_tables, o.scalar_key_sorted_tables);
+ std::swap(native_inline, o.native_inline);
+ std::swap(long_enum_non_enum_default, o.long_enum_non_enum_default);
+ std::swap(long_enum_normal_default, o.long_enum_normal_default);
+ return *this;
+}
+
+inline MonsterT *Monster::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
+ auto _o = std::unique_ptr<MonsterT>(new MonsterT());
+ UnPackTo(_o.get(), _resolver);
+ return _o.release();
+}
+
+inline void Monster::UnPackTo(MonsterT *_o, const flatbuffers::resolver_function_t *_resolver) const {
+ (void)_o;
+ (void)_resolver;
+ { auto _e = pos(); if (_e) _o->pos = flatbuffers::unique_ptr<MyGame::Example::Vec3>(new MyGame::Example::Vec3(*_e)); }
+ { auto _e = mana(); _o->mana = _e; }
+ { auto _e = hp(); _o->hp = _e; }
+ { auto _e = name(); if (_e) _o->name = _e->str(); }
+ { auto _e = inventory(); if (_e) { _o->inventory.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->inventory.begin()); } }
+ { auto _e = color(); _o->color = _e; }
+ { auto _e = test_type(); _o->test.type = _e; }
+ { auto _e = test(); if (_e) _o->test.value = MyGame::Example::AnyUnion::UnPack(_e, test_type(), _resolver); }
+ { auto _e = test4(); if (_e) { _o->test4.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->test4[_i] = *_e->Get(_i); } } else { _o->test4.resize(0); } }
+ { auto _e = testarrayofstring(); if (_e) { _o->testarrayofstring.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofstring[_i] = _e->Get(_i)->str(); } } else { _o->testarrayofstring.resize(0); } }
+ { auto _e = testarrayoftables(); if (_e) { _o->testarrayoftables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->testarrayoftables[_i]) { _e->Get(_i)->UnPackTo(_o->testarrayoftables[_i].get(), _resolver); } else { _o->testarrayoftables[_i] = flatbuffers::unique_ptr<MyGame::Example::MonsterT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->testarrayoftables.resize(0); } }
+ { auto _e = enemy(); if (_e) { if(_o->enemy) { _e->UnPackTo(_o->enemy.get(), _resolver); } else { _o->enemy = flatbuffers::unique_ptr<MyGame::Example::MonsterT>(_e->UnPack(_resolver)); } } else if (_o->enemy) { _o->enemy.reset(); } }
+ { auto _e = testnestedflatbuffer(); if (_e) { _o->testnestedflatbuffer.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->testnestedflatbuffer.begin()); } }
+ { auto _e = testempty(); if (_e) { if(_o->testempty) { _e->UnPackTo(_o->testempty.get(), _resolver); } else { _o->testempty = flatbuffers::unique_ptr<MyGame::Example::StatT>(_e->UnPack(_resolver)); } } else if (_o->testempty) { _o->testempty.reset(); } }
+ { auto _e = testbool(); _o->testbool = _e; }
+ { auto _e = testhashs32_fnv1(); _o->testhashs32_fnv1 = _e; }
+ { auto _e = testhashu32_fnv1(); _o->testhashu32_fnv1 = _e; }
+ { auto _e = testhashs64_fnv1(); _o->testhashs64_fnv1 = _e; }
+ { auto _e = testhashu64_fnv1(); _o->testhashu64_fnv1 = _e; }
+ { auto _e = testhashs32_fnv1a(); _o->testhashs32_fnv1a = _e; }
+ { auto _e = testhashu32_fnv1a(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->testhashu32_fnv1a), static_cast<flatbuffers::hash_value_t>(_e)); else _o->testhashu32_fnv1a = nullptr; }
+ { auto _e = testhashs64_fnv1a(); _o->testhashs64_fnv1a = _e; }
+ { auto _e = testhashu64_fnv1a(); _o->testhashu64_fnv1a = _e; }
+ { auto _e = testarrayofbools(); if (_e) { _o->testarrayofbools.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofbools[_i] = _e->Get(_i) != 0; } } else { _o->testarrayofbools.resize(0); } }
+ { auto _e = testf(); _o->testf = _e; }
+ { auto _e = testf2(); _o->testf2 = _e; }
+ { auto _e = testf3(); _o->testf3 = _e; }
+ { auto _e = testarrayofstring2(); if (_e) { _o->testarrayofstring2.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofstring2[_i] = _e->Get(_i)->str(); } } else { _o->testarrayofstring2.resize(0); } }
+ { auto _e = testarrayofsortedstruct(); if (_e) { _o->testarrayofsortedstruct.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofsortedstruct[_i] = *_e->Get(_i); } } else { _o->testarrayofsortedstruct.resize(0); } }
+ { auto _e = flex(); if (_e) { _o->flex.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->flex.begin()); } }
+ { auto _e = test5(); if (_e) { _o->test5.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->test5[_i] = *_e->Get(_i); } } else { _o->test5.resize(0); } }
+ { auto _e = vector_of_longs(); if (_e) { _o->vector_of_longs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_longs[_i] = _e->Get(_i); } } else { _o->vector_of_longs.resize(0); } }
+ { auto _e = vector_of_doubles(); if (_e) { _o->vector_of_doubles.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_doubles[_i] = _e->Get(_i); } } else { _o->vector_of_doubles.resize(0); } }
+ { auto _e = parent_namespace_test(); if (_e) { if(_o->parent_namespace_test) { _e->UnPackTo(_o->parent_namespace_test.get(), _resolver); } else { _o->parent_namespace_test = flatbuffers::unique_ptr<MyGame::InParentNamespaceT>(_e->UnPack(_resolver)); } } else if (_o->parent_namespace_test) { _o->parent_namespace_test.reset(); } }
+ { auto _e = vector_of_referrables(); if (_e) { _o->vector_of_referrables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_referrables[_i].get(), _resolver); } else { _o->vector_of_referrables[_i] = flatbuffers::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->vector_of_referrables.resize(0); } }
+ { auto _e = single_weak_reference(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->single_weak_reference), static_cast<flatbuffers::hash_value_t>(_e)); else _o->single_weak_reference = nullptr; }
+ { auto _e = vector_of_weak_references(); if (_e) { _o->vector_of_weak_references.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { /*vector resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_weak_references[_i]), static_cast<flatbuffers::hash_value_t>(_e->Get(_i))); else _o->vector_of_weak_references[_i] = nullptr; } } else { _o->vector_of_weak_references.resize(0); } }
+ { auto _e = vector_of_strong_referrables(); if (_e) { _o->vector_of_strong_referrables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_strong_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_strong_referrables[_i].get(), _resolver); } else { _o->vector_of_strong_referrables[_i] = flatbuffers::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->vector_of_strong_referrables.resize(0); } }
+ { auto _e = co_owning_reference(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->co_owning_reference), static_cast<flatbuffers::hash_value_t>(_e)); else _o->co_owning_reference = nullptr; }
+ { auto _e = vector_of_co_owning_references(); if (_e) { _o->vector_of_co_owning_references.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { /*vector resolver, default_ptr_type*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_co_owning_references[_i]), static_cast<flatbuffers::hash_value_t>(_e->Get(_i)));/* else do nothing */; } } else { _o->vector_of_co_owning_references.resize(0); } }
+ { auto _e = non_owning_reference(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->non_owning_reference), static_cast<flatbuffers::hash_value_t>(_e)); else _o->non_owning_reference = nullptr; }
+ { auto _e = vector_of_non_owning_references(); if (_e) { _o->vector_of_non_owning_references.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { /*vector resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_non_owning_references[_i]), static_cast<flatbuffers::hash_value_t>(_e->Get(_i))); else _o->vector_of_non_owning_references[_i] = nullptr; } } else { _o->vector_of_non_owning_references.resize(0); } }
+ { auto _e = any_unique_type(); _o->any_unique.type = _e; }
+ { auto _e = any_unique(); if (_e) _o->any_unique.value = MyGame::Example::AnyUniqueAliasesUnion::UnPack(_e, any_unique_type(), _resolver); }
+ { auto _e = any_ambiguous_type(); _o->any_ambiguous.type = _e; }
+ { auto _e = any_ambiguous(); if (_e) _o->any_ambiguous.value = MyGame::Example::AnyAmbiguousAliasesUnion::UnPack(_e, any_ambiguous_type(), _resolver); }
+ { auto _e = vector_of_enums(); if (_e) { _o->vector_of_enums.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_enums[_i] = static_cast<MyGame::Example::Color>(_e->Get(_i)); } } else { _o->vector_of_enums.resize(0); } }
+ { auto _e = signed_enum(); _o->signed_enum = _e; }
+ { auto _e = testrequirednestedflatbuffer(); if (_e) { _o->testrequirednestedflatbuffer.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->testrequirednestedflatbuffer.begin()); } }
+ { auto _e = scalar_key_sorted_tables(); if (_e) { _o->scalar_key_sorted_tables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->scalar_key_sorted_tables[_i]) { _e->Get(_i)->UnPackTo(_o->scalar_key_sorted_tables[_i].get(), _resolver); } else { _o->scalar_key_sorted_tables[_i] = flatbuffers::unique_ptr<MyGame::Example::StatT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->scalar_key_sorted_tables.resize(0); } }
+ { auto _e = native_inline(); if (_e) _o->native_inline = *_e; }
+ { auto _e = long_enum_non_enum_default(); _o->long_enum_non_enum_default = _e; }
+ { auto _e = long_enum_normal_default(); _o->long_enum_normal_default = _e; }
+}
+
+inline flatbuffers::Offset<Monster> Monster::Pack(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
+ return CreateMonster(_fbb, _o, _rehasher);
+}
+
+inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
+ (void)_rehasher;
+ (void)_o;
+ struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const MonsterT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
+ auto _pos = _o->pos ? _o->pos.get() : nullptr;
+ auto _mana = _o->mana;
+ auto _hp = _o->hp;
+ auto _name = _fbb.CreateString(_o->name);
+ auto _inventory = _o->inventory.size() ? _fbb.CreateVector(_o->inventory) : 0;
+ auto _color = _o->color;
+ auto _test_type = _o->test.type;
+ auto _test = _o->test.Pack(_fbb);
+ auto _test4 = _o->test4.size() ? _fbb.CreateVectorOfStructs(_o->test4) : 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 _enemy = _o->enemy ? CreateMonster(_fbb, _o->enemy.get(), _rehasher) : 0;
+ auto _testnestedflatbuffer = _o->testnestedflatbuffer.size() ? _fbb.CreateVector(_o->testnestedflatbuffer) : 0;
+ auto _testempty = _o->testempty ? CreateStat(_fbb, _o->testempty.get(), _rehasher) : 0;
+ auto _testbool = _o->testbool;
+ auto _testhashs32_fnv1 = _o->testhashs32_fnv1;
+ auto _testhashu32_fnv1 = _o->testhashu32_fnv1;
+ auto _testhashs64_fnv1 = _o->testhashs64_fnv1;
+ auto _testhashu64_fnv1 = _o->testhashu64_fnv1;
+ auto _testhashs32_fnv1a = _o->testhashs32_fnv1a;
+ auto _testhashu32_fnv1a = _rehasher ? static_cast<uint32_t>((*_rehasher)(_o->testhashu32_fnv1a)) : 0;
+ auto _testhashs64_fnv1a = _o->testhashs64_fnv1a;
+ auto _testhashu64_fnv1a = _o->testhashu64_fnv1a;
+ auto _testarrayofbools = _o->testarrayofbools.size() ? _fbb.CreateVector(_o->testarrayofbools) : 0;
+ auto _testf = _o->testf;
+ auto _testf2 = _o->testf2;
+ auto _testf3 = _o->testf3;
+ auto _testarrayofstring2 = _o->testarrayofstring2.size() ? _fbb.CreateVectorOfStrings(_o->testarrayofstring2) : 0;
+ auto _testarrayofsortedstruct = _o->testarrayofsortedstruct.size() ? _fbb.CreateVectorOfStructs(_o->testarrayofsortedstruct) : 0;
+ auto _flex = _o->flex.size() ? _fbb.CreateVector(_o->flex) : 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_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 _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 _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_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 _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 _non_owning_reference = _rehasher ? static_cast<uint64_t>((*_rehasher)(_o->non_owning_reference)) : 0;
+ auto _vector_of_non_owning_references = _o->vector_of_non_owning_references.size() ? _fbb.CreateVector<uint64_t>(_o->vector_of_non_owning_references.size(), [](size_t i, _VectorArgs *__va) { return __va->__rehasher ? static_cast<uint64_t>((*__va->__rehasher)(__va->__o->vector_of_non_owning_references[i])) : 0; }, &_va ) : 0;
+ auto _any_unique_type = _o->any_unique.type;
+ auto _any_unique = _o->any_unique.Pack(_fbb);
+ auto _any_ambiguous_type = _o->any_ambiguous.type;
+ auto _any_ambiguous = _o->any_ambiguous.Pack(_fbb);
+ auto _vector_of_enums = _o->vector_of_enums.size() ? _fbb.CreateVectorScalarCast<uint8_t>(flatbuffers::data(_o->vector_of_enums), _o->vector_of_enums.size()) : 0;
+ auto _signed_enum = _o->signed_enum;
+ 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 _native_inline = &_o->native_inline;
+ auto _long_enum_non_enum_default = _o->long_enum_non_enum_default;
+ auto _long_enum_normal_default = _o->long_enum_normal_default;
+ return MyGame::Example::CreateMonster(
+ _fbb,
+ _pos,
+ _mana,
+ _hp,
+ _name,
+ _inventory,
+ _color,
+ _test_type,
+ _test,
+ _test4,
+ _testarrayofstring,
+ _testarrayoftables,
+ _enemy,
+ _testnestedflatbuffer,
+ _testempty,
+ _testbool,
+ _testhashs32_fnv1,
+ _testhashu32_fnv1,
+ _testhashs64_fnv1,
+ _testhashu64_fnv1,
+ _testhashs32_fnv1a,
+ _testhashu32_fnv1a,
+ _testhashs64_fnv1a,
+ _testhashu64_fnv1a,
+ _testarrayofbools,
+ _testf,
+ _testf2,
+ _testf3,
+ _testarrayofstring2,
+ _testarrayofsortedstruct,
+ _flex,
+ _test5,
+ _vector_of_longs,
+ _vector_of_doubles,
+ _parent_namespace_test,
+ _vector_of_referrables,
+ _single_weak_reference,
+ _vector_of_weak_references,
+ _vector_of_strong_referrables,
+ _co_owning_reference,
+ _vector_of_co_owning_references,
+ _non_owning_reference,
+ _vector_of_non_owning_references,
+ _any_unique_type,
+ _any_unique,
+ _any_ambiguous_type,
+ _any_ambiguous,
+ _vector_of_enums,
+ _signed_enum,
+ _testrequirednestedflatbuffer,
+ _scalar_key_sorted_tables,
+ _native_inline,
+ _long_enum_non_enum_default,
+ _long_enum_normal_default);
+}
+
+
+inline bool operator==(const TypeAliasesT &lhs, const TypeAliasesT &rhs) {
+ return
+ (lhs.i8 == rhs.i8) &&
+ (lhs.u8 == rhs.u8) &&
+ (lhs.i16 == rhs.i16) &&
+ (lhs.u16 == rhs.u16) &&
+ (lhs.i32 == rhs.i32) &&
+ (lhs.u32 == rhs.u32) &&
+ (lhs.i64 == rhs.i64) &&
+ (lhs.u64 == rhs.u64) &&
+ (lhs.f32 == rhs.f32) &&
+ (lhs.f64 == rhs.f64) &&
+ (lhs.v8 == rhs.v8) &&
+ (lhs.vf64 == rhs.vf64);
+}
+
+inline bool operator!=(const TypeAliasesT &lhs, const TypeAliasesT &rhs) {
+ return !(lhs == rhs);
+}
+
+
+inline TypeAliasesT *TypeAliases::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
+ auto _o = std::unique_ptr<TypeAliasesT>(new TypeAliasesT());
+ UnPackTo(_o.get(), _resolver);
+ return _o.release();
+}
+
+inline void TypeAliases::UnPackTo(TypeAliasesT *_o, const flatbuffers::resolver_function_t *_resolver) const {
+ (void)_o;
+ (void)_resolver;
+ { auto _e = i8(); _o->i8 = _e; }
+ { auto _e = u8(); _o->u8 = _e; }
+ { auto _e = i16(); _o->i16 = _e; }
+ { auto _e = u16(); _o->u16 = _e; }
+ { auto _e = i32(); _o->i32 = _e; }
+ { auto _e = u32(); _o->u32 = _e; }
+ { auto _e = i64(); _o->i64 = _e; }
+ { auto _e = u64(); _o->u64 = _e; }
+ { auto _e = f32(); _o->f32 = _e; }
+ { auto _e = f64(); _o->f64 = _e; }
+ { auto _e = v8(); if (_e) { _o->v8.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->v8.begin()); } }
+ { auto _e = vf64(); if (_e) { _o->vf64.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vf64[_i] = _e->Get(_i); } } else { _o->vf64.resize(0); } }
+}
+
+inline flatbuffers::Offset<TypeAliases> TypeAliases::Pack(flatbuffers::FlatBufferBuilder &_fbb, const TypeAliasesT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
+ return CreateTypeAliases(_fbb, _o, _rehasher);
+}
+
+inline flatbuffers::Offset<TypeAliases> CreateTypeAliases(flatbuffers::FlatBufferBuilder &_fbb, const TypeAliasesT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
+ (void)_rehasher;
+ (void)_o;
+ struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const TypeAliasesT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
+ auto _i8 = _o->i8;
+ auto _u8 = _o->u8;
+ auto _i16 = _o->i16;
+ auto _u16 = _o->u16;
+ auto _i32 = _o->i32;
+ auto _u32 = _o->u32;
+ auto _i64 = _o->i64;
+ auto _u64 = _o->u64;
+ auto _f32 = _o->f32;
+ auto _f64 = _o->f64;
+ auto _v8 = _o->v8.size() ? _fbb.CreateVector(_o->v8) : 0;
+ auto _vf64 = _o->vf64.size() ? _fbb.CreateVector(_o->vf64) : 0;
+ return MyGame::Example::CreateTypeAliases(
+ _fbb,
+ _i8,
+ _u8,
+ _i16,
+ _u16,
+ _i32,
+ _u32,
+ _i64,
+ _u64,
+ _f32,
+ _f64,
+ _v8,
+ _vf64);
+}
+
+inline bool VerifyAny(flatbuffers::Verifier &verifier, const void *obj, Any type) {
+ switch (type) {
+ case Any_NONE: {
+ return true;
+ }
+ case Any_Monster: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ case Any_TestSimpleTableWithEnum: {
+ auto ptr = reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnum *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ case Any_MyGame_Example2_Monster: {
+ auto ptr = reinterpret_cast<const MyGame::Example2::Monster *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ default: return true;
+ }
+}
+
+inline bool VerifyAnyVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types) {
+ if (!values || !types) return !values && !types;
+ if (values->size() != types->size()) return false;
+ for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
+ if (!VerifyAny(
+ verifier, values->Get(i), types->GetEnum<Any>(i))) {
+ return false;
+ }
+ }
+ return true;
+}
+
+inline void *AnyUnion::UnPack(const void *obj, Any type, const flatbuffers::resolver_function_t *resolver) {
+ (void)resolver;
+ switch (type) {
+ case Any_Monster: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ case Any_TestSimpleTableWithEnum: {
+ auto ptr = reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnum *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ case Any_MyGame_Example2_Monster: {
+ auto ptr = reinterpret_cast<const MyGame::Example2::Monster *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ default: return nullptr;
+ }
+}
+
+inline flatbuffers::Offset<void> AnyUnion::Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher) const {
+ (void)_rehasher;
+ switch (type) {
+ case Any_Monster: {
+ auto ptr = reinterpret_cast<const MyGame::Example::MonsterT *>(value);
+ return CreateMonster(_fbb, ptr, _rehasher).Union();
+ }
+ case Any_TestSimpleTableWithEnum: {
+ auto ptr = reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnumT *>(value);
+ return CreateTestSimpleTableWithEnum(_fbb, ptr, _rehasher).Union();
+ }
+ case Any_MyGame_Example2_Monster: {
+ auto ptr = reinterpret_cast<const MyGame::Example2::MonsterT *>(value);
+ return CreateMonster(_fbb, ptr, _rehasher).Union();
+ }
+ default: return 0;
+ }
+}
+
+inline AnyUnion::AnyUnion(const AnyUnion &u) : type(u.type), value(nullptr) {
+ switch (type) {
+ case Any_Monster: {
+ value = new MyGame::Example::MonsterT(*reinterpret_cast<MyGame::Example::MonsterT *>(u.value));
+ break;
+ }
+ case Any_TestSimpleTableWithEnum: {
+ value = new MyGame::Example::TestSimpleTableWithEnumT(*reinterpret_cast<MyGame::Example::TestSimpleTableWithEnumT *>(u.value));
+ break;
+ }
+ case Any_MyGame_Example2_Monster: {
+ value = new MyGame::Example2::MonsterT(*reinterpret_cast<MyGame::Example2::MonsterT *>(u.value));
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+inline void AnyUnion::Reset() {
+ switch (type) {
+ case Any_Monster: {
+ auto ptr = reinterpret_cast<MyGame::Example::MonsterT *>(value);
+ delete ptr;
+ break;
+ }
+ case Any_TestSimpleTableWithEnum: {
+ auto ptr = reinterpret_cast<MyGame::Example::TestSimpleTableWithEnumT *>(value);
+ delete ptr;
+ break;
+ }
+ case Any_MyGame_Example2_Monster: {
+ auto ptr = reinterpret_cast<MyGame::Example2::MonsterT *>(value);
+ delete ptr;
+ break;
+ }
+ default: break;
+ }
+ value = nullptr;
+ type = Any_NONE;
+}
+
+inline bool VerifyAnyUniqueAliases(flatbuffers::Verifier &verifier, const void *obj, AnyUniqueAliases type) {
+ switch (type) {
+ case AnyUniqueAliases_NONE: {
+ return true;
+ }
+ case AnyUniqueAliases_M: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ case AnyUniqueAliases_TS: {
+ auto ptr = reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnum *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ case AnyUniqueAliases_M2: {
+ auto ptr = reinterpret_cast<const MyGame::Example2::Monster *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ default: return true;
+ }
+}
+
+inline bool VerifyAnyUniqueAliasesVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types) {
+ if (!values || !types) return !values && !types;
+ if (values->size() != types->size()) return false;
+ for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
+ if (!VerifyAnyUniqueAliases(
+ verifier, values->Get(i), types->GetEnum<AnyUniqueAliases>(i))) {
+ return false;
+ }
+ }
+ return true;
+}
+
+inline void *AnyUniqueAliasesUnion::UnPack(const void *obj, AnyUniqueAliases type, const flatbuffers::resolver_function_t *resolver) {
+ (void)resolver;
+ switch (type) {
+ case AnyUniqueAliases_M: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ case AnyUniqueAliases_TS: {
+ auto ptr = reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnum *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ case AnyUniqueAliases_M2: {
+ auto ptr = reinterpret_cast<const MyGame::Example2::Monster *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ default: return nullptr;
+ }
+}
+
+inline flatbuffers::Offset<void> AnyUniqueAliasesUnion::Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher) const {
+ (void)_rehasher;
+ switch (type) {
+ case AnyUniqueAliases_M: {
+ auto ptr = reinterpret_cast<const MyGame::Example::MonsterT *>(value);
+ return CreateMonster(_fbb, ptr, _rehasher).Union();
+ }
+ case AnyUniqueAliases_TS: {
+ auto ptr = reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnumT *>(value);
+ return CreateTestSimpleTableWithEnum(_fbb, ptr, _rehasher).Union();
+ }
+ case AnyUniqueAliases_M2: {
+ auto ptr = reinterpret_cast<const MyGame::Example2::MonsterT *>(value);
+ return CreateMonster(_fbb, ptr, _rehasher).Union();
+ }
+ default: return 0;
+ }
+}
+
+inline AnyUniqueAliasesUnion::AnyUniqueAliasesUnion(const AnyUniqueAliasesUnion &u) : type(u.type), value(nullptr) {
+ switch (type) {
+ case AnyUniqueAliases_M: {
+ value = new MyGame::Example::MonsterT(*reinterpret_cast<MyGame::Example::MonsterT *>(u.value));
+ break;
+ }
+ case AnyUniqueAliases_TS: {
+ value = new MyGame::Example::TestSimpleTableWithEnumT(*reinterpret_cast<MyGame::Example::TestSimpleTableWithEnumT *>(u.value));
+ break;
+ }
+ case AnyUniqueAliases_M2: {
+ value = new MyGame::Example2::MonsterT(*reinterpret_cast<MyGame::Example2::MonsterT *>(u.value));
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+inline void AnyUniqueAliasesUnion::Reset() {
+ switch (type) {
+ case AnyUniqueAliases_M: {
+ auto ptr = reinterpret_cast<MyGame::Example::MonsterT *>(value);
+ delete ptr;
+ break;
+ }
+ case AnyUniqueAliases_TS: {
+ auto ptr = reinterpret_cast<MyGame::Example::TestSimpleTableWithEnumT *>(value);
+ delete ptr;
+ break;
+ }
+ case AnyUniqueAliases_M2: {
+ auto ptr = reinterpret_cast<MyGame::Example2::MonsterT *>(value);
+ delete ptr;
+ break;
+ }
+ default: break;
+ }
+ value = nullptr;
+ type = AnyUniqueAliases_NONE;
+}
+
+inline bool VerifyAnyAmbiguousAliases(flatbuffers::Verifier &verifier, const void *obj, AnyAmbiguousAliases type) {
+ switch (type) {
+ case AnyAmbiguousAliases_NONE: {
+ return true;
+ }
+ case AnyAmbiguousAliases_M1: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ case AnyAmbiguousAliases_M2: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ case AnyAmbiguousAliases_M3: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ default: return true;
+ }
+}
+
+inline bool VerifyAnyAmbiguousAliasesVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types) {
+ if (!values || !types) return !values && !types;
+ if (values->size() != types->size()) return false;
+ for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
+ if (!VerifyAnyAmbiguousAliases(
+ verifier, values->Get(i), types->GetEnum<AnyAmbiguousAliases>(i))) {
+ return false;
+ }
+ }
+ return true;
+}
+
+inline void *AnyAmbiguousAliasesUnion::UnPack(const void *obj, AnyAmbiguousAliases type, const flatbuffers::resolver_function_t *resolver) {
+ (void)resolver;
+ switch (type) {
+ case AnyAmbiguousAliases_M1: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ case AnyAmbiguousAliases_M2: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ case AnyAmbiguousAliases_M3: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ default: return nullptr;
+ }
+}
+
+inline flatbuffers::Offset<void> AnyAmbiguousAliasesUnion::Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher) const {
+ (void)_rehasher;
+ switch (type) {
+ case AnyAmbiguousAliases_M1: {
+ auto ptr = reinterpret_cast<const MyGame::Example::MonsterT *>(value);
+ return CreateMonster(_fbb, ptr, _rehasher).Union();
+ }
+ case AnyAmbiguousAliases_M2: {
+ auto ptr = reinterpret_cast<const MyGame::Example::MonsterT *>(value);
+ return CreateMonster(_fbb, ptr, _rehasher).Union();
+ }
+ case AnyAmbiguousAliases_M3: {
+ auto ptr = reinterpret_cast<const MyGame::Example::MonsterT *>(value);
+ return CreateMonster(_fbb, ptr, _rehasher).Union();
+ }
+ default: return 0;
+ }
+}
+
+inline AnyAmbiguousAliasesUnion::AnyAmbiguousAliasesUnion(const AnyAmbiguousAliasesUnion &u) : type(u.type), value(nullptr) {
+ switch (type) {
+ case AnyAmbiguousAliases_M1: {
+ value = new MyGame::Example::MonsterT(*reinterpret_cast<MyGame::Example::MonsterT *>(u.value));
+ break;
+ }
+ case AnyAmbiguousAliases_M2: {
+ value = new MyGame::Example::MonsterT(*reinterpret_cast<MyGame::Example::MonsterT *>(u.value));
+ break;
+ }
+ case AnyAmbiguousAliases_M3: {
+ value = new MyGame::Example::MonsterT(*reinterpret_cast<MyGame::Example::MonsterT *>(u.value));
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+inline void AnyAmbiguousAliasesUnion::Reset() {
+ switch (type) {
+ case AnyAmbiguousAliases_M1: {
+ auto ptr = reinterpret_cast<MyGame::Example::MonsterT *>(value);
+ delete ptr;
+ break;
+ }
+ case AnyAmbiguousAliases_M2: {
+ auto ptr = reinterpret_cast<MyGame::Example::MonsterT *>(value);
+ delete ptr;
+ break;
+ }
+ case AnyAmbiguousAliases_M3: {
+ auto ptr = reinterpret_cast<MyGame::Example::MonsterT *>(value);
+ delete ptr;
+ break;
+ }
+ default: break;
+ }
+ value = nullptr;
+ type = AnyAmbiguousAliases_NONE;
+}
+
+inline const flatbuffers::TypeTable *ColorTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_UCHAR, 0, 0 },
+ { flatbuffers::ET_UCHAR, 0, 0 },
+ { flatbuffers::ET_UCHAR, 0, 0 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::ColorTypeTable
+ };
+ static const int64_t values[] = { 1, 2, 8 };
+ static const char * const names[] = {
+ "Red",
+ "Green",
+ "Blue"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_ENUM, 3, type_codes, type_refs, nullptr, values, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *RaceTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_CHAR, 0, 0 },
+ { flatbuffers::ET_CHAR, 0, 0 },
+ { flatbuffers::ET_CHAR, 0, 0 },
+ { flatbuffers::ET_CHAR, 0, 0 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::RaceTypeTable
+ };
+ static const int64_t values[] = { -1, 0, 1, 2 };
+ static const char * const names[] = {
+ "None",
+ "Human",
+ "Dwarf",
+ "Elf"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_ENUM, 4, type_codes, type_refs, nullptr, values, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *LongEnumTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_ULONG, 0, 0 },
+ { flatbuffers::ET_ULONG, 0, 0 },
+ { flatbuffers::ET_ULONG, 0, 0 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::LongEnumTypeTable
+ };
+ static const int64_t values[] = { 2ULL, 4ULL, 1099511627776ULL };
+ static const char * const names[] = {
+ "LongOne",
+ "LongTwo",
+ "LongBig"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_ENUM, 3, type_codes, type_refs, nullptr, values, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *AnyTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_SEQUENCE, 0, -1 },
+ { flatbuffers::ET_SEQUENCE, 0, 0 },
+ { flatbuffers::ET_SEQUENCE, 0, 1 },
+ { flatbuffers::ET_SEQUENCE, 0, 2 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::MonsterTypeTable,
+ MyGame::Example::TestSimpleTableWithEnumTypeTable,
+ MyGame::Example2::MonsterTypeTable
+ };
+ static const char * const names[] = {
+ "NONE",
+ "Monster",
+ "TestSimpleTableWithEnum",
+ "MyGame_Example2_Monster"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_UNION, 4, type_codes, type_refs, nullptr, nullptr, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *AnyUniqueAliasesTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_SEQUENCE, 0, -1 },
+ { flatbuffers::ET_SEQUENCE, 0, 0 },
+ { flatbuffers::ET_SEQUENCE, 0, 1 },
+ { flatbuffers::ET_SEQUENCE, 0, 2 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::MonsterTypeTable,
+ MyGame::Example::TestSimpleTableWithEnumTypeTable,
+ MyGame::Example2::MonsterTypeTable
+ };
+ static const char * const names[] = {
+ "NONE",
+ "M",
+ "TS",
+ "M2"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_UNION, 4, type_codes, type_refs, nullptr, nullptr, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *AnyAmbiguousAliasesTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_SEQUENCE, 0, -1 },
+ { flatbuffers::ET_SEQUENCE, 0, 0 },
+ { flatbuffers::ET_SEQUENCE, 0, 0 },
+ { flatbuffers::ET_SEQUENCE, 0, 0 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::MonsterTypeTable
+ };
+ static const char * const names[] = {
+ "NONE",
+ "M1",
+ "M2",
+ "M3"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_UNION, 4, type_codes, type_refs, nullptr, nullptr, names
+ };
+ return &tt;
+}
+
+} // namespace Example
+
+inline const flatbuffers::TypeTable *InParentNamespaceTypeTable() {
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_TABLE, 0, nullptr, nullptr, nullptr, nullptr, nullptr
+ };
+ return &tt;
+}
+
+namespace Example2 {
+
+inline const flatbuffers::TypeTable *MonsterTypeTable() {
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_TABLE, 0, nullptr, nullptr, nullptr, nullptr, nullptr
+ };
+ return &tt;
+}
+
+} // namespace Example2
+
+namespace Example {
+
+inline const flatbuffers::TypeTable *TestTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_SHORT, 0, -1 },
+ { flatbuffers::ET_CHAR, 0, -1 }
+ };
+ static const int64_t values[] = { 0, 2, 4 };
+ static const char * const names[] = {
+ "a",
+ "b"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_STRUCT, 2, type_codes, nullptr, nullptr, values, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *TestSimpleTableWithEnumTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_UCHAR, 0, 0 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::ColorTypeTable
+ };
+ static const char * const names[] = {
+ "color"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_TABLE, 1, type_codes, type_refs, nullptr, nullptr, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *Vec3TypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_FLOAT, 0, -1 },
+ { flatbuffers::ET_FLOAT, 0, -1 },
+ { flatbuffers::ET_FLOAT, 0, -1 },
+ { flatbuffers::ET_DOUBLE, 0, -1 },
+ { flatbuffers::ET_UCHAR, 0, 0 },
+ { flatbuffers::ET_SEQUENCE, 0, 1 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::ColorTypeTable,
+ MyGame::Example::TestTypeTable
+ };
+ static const int64_t values[] = { 0, 4, 8, 16, 24, 26, 32 };
+ static const char * const names[] = {
+ "x",
+ "y",
+ "z",
+ "test1",
+ "test2",
+ "test3"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_STRUCT, 6, type_codes, type_refs, nullptr, values, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *AbilityTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_UINT, 0, -1 },
+ { flatbuffers::ET_UINT, 0, -1 }
+ };
+ static const int64_t values[] = { 0, 4, 8 };
+ static const char * const names[] = {
+ "id",
+ "distance"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_STRUCT, 2, type_codes, nullptr, nullptr, values, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *StructOfStructsTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_SEQUENCE, 0, 0 },
+ { flatbuffers::ET_SEQUENCE, 0, 1 },
+ { flatbuffers::ET_SEQUENCE, 0, 0 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::AbilityTypeTable,
+ MyGame::Example::TestTypeTable
+ };
+ static const int64_t values[] = { 0, 8, 12, 20 };
+ static const char * const names[] = {
+ "a",
+ "b",
+ "c"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_STRUCT, 3, type_codes, type_refs, nullptr, values, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *StructOfStructsOfStructsTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_SEQUENCE, 0, 0 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::StructOfStructsTypeTable
+ };
+ static const int64_t values[] = { 0, 20 };
+ static const char * const names[] = {
+ "a"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_STRUCT, 1, type_codes, type_refs, nullptr, values, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *StatTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_STRING, 0, -1 },
+ { flatbuffers::ET_LONG, 0, -1 },
+ { flatbuffers::ET_USHORT, 0, -1 }
+ };
+ static const char * const names[] = {
+ "id",
+ "val",
+ "count"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_TABLE, 3, type_codes, nullptr, nullptr, nullptr, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *ReferrableTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_ULONG, 0, -1 }
+ };
+ static const char * const names[] = {
+ "id"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_TABLE, 1, type_codes, nullptr, nullptr, nullptr, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *MonsterTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_SEQUENCE, 0, 0 },
+ { flatbuffers::ET_SHORT, 0, -1 },
+ { flatbuffers::ET_SHORT, 0, -1 },
+ { flatbuffers::ET_STRING, 0, -1 },
+ { flatbuffers::ET_BOOL, 0, -1 },
+ { flatbuffers::ET_UCHAR, 1, -1 },
+ { flatbuffers::ET_UCHAR, 0, 1 },
+ { flatbuffers::ET_UTYPE, 0, 2 },
+ { flatbuffers::ET_SEQUENCE, 0, 2 },
+ { flatbuffers::ET_SEQUENCE, 1, 3 },
+ { flatbuffers::ET_STRING, 1, -1 },
+ { flatbuffers::ET_SEQUENCE, 1, 4 },
+ { flatbuffers::ET_SEQUENCE, 0, 4 },
+ { flatbuffers::ET_UCHAR, 1, -1 },
+ { flatbuffers::ET_SEQUENCE, 0, 5 },
+ { flatbuffers::ET_BOOL, 0, -1 },
+ { flatbuffers::ET_INT, 0, -1 },
+ { flatbuffers::ET_UINT, 0, -1 },
+ { flatbuffers::ET_LONG, 0, -1 },
+ { flatbuffers::ET_ULONG, 0, -1 },
+ { flatbuffers::ET_INT, 0, -1 },
+ { flatbuffers::ET_UINT, 0, -1 },
+ { flatbuffers::ET_LONG, 0, -1 },
+ { flatbuffers::ET_ULONG, 0, -1 },
+ { flatbuffers::ET_BOOL, 1, -1 },
+ { flatbuffers::ET_FLOAT, 0, -1 },
+ { flatbuffers::ET_FLOAT, 0, -1 },
+ { flatbuffers::ET_FLOAT, 0, -1 },
+ { flatbuffers::ET_STRING, 1, -1 },
+ { flatbuffers::ET_SEQUENCE, 1, 6 },
+ { flatbuffers::ET_UCHAR, 1, -1 },
+ { flatbuffers::ET_SEQUENCE, 1, 3 },
+ { flatbuffers::ET_LONG, 1, -1 },
+ { flatbuffers::ET_DOUBLE, 1, -1 },
+ { flatbuffers::ET_SEQUENCE, 0, 7 },
+ { flatbuffers::ET_SEQUENCE, 1, 8 },
+ { flatbuffers::ET_ULONG, 0, -1 },
+ { flatbuffers::ET_ULONG, 1, -1 },
+ { flatbuffers::ET_SEQUENCE, 1, 8 },
+ { flatbuffers::ET_ULONG, 0, -1 },
+ { flatbuffers::ET_ULONG, 1, -1 },
+ { flatbuffers::ET_ULONG, 0, -1 },
+ { flatbuffers::ET_ULONG, 1, -1 },
+ { flatbuffers::ET_UTYPE, 0, 9 },
+ { flatbuffers::ET_SEQUENCE, 0, 9 },
+ { flatbuffers::ET_UTYPE, 0, 10 },
+ { flatbuffers::ET_SEQUENCE, 0, 10 },
+ { flatbuffers::ET_UCHAR, 1, 1 },
+ { flatbuffers::ET_CHAR, 0, 11 },
+ { flatbuffers::ET_UCHAR, 1, -1 },
+ { flatbuffers::ET_SEQUENCE, 1, 5 },
+ { flatbuffers::ET_SEQUENCE, 0, 3 },
+ { flatbuffers::ET_ULONG, 0, 12 },
+ { flatbuffers::ET_ULONG, 0, 12 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::Vec3TypeTable,
+ MyGame::Example::ColorTypeTable,
+ MyGame::Example::AnyTypeTable,
+ MyGame::Example::TestTypeTable,
+ MyGame::Example::MonsterTypeTable,
+ MyGame::Example::StatTypeTable,
+ MyGame::Example::AbilityTypeTable,
+ MyGame::InParentNamespaceTypeTable,
+ MyGame::Example::ReferrableTypeTable,
+ MyGame::Example::AnyUniqueAliasesTypeTable,
+ MyGame::Example::AnyAmbiguousAliasesTypeTable,
+ MyGame::Example::RaceTypeTable,
+ MyGame::Example::LongEnumTypeTable
+ };
+ static const char * const names[] = {
+ "pos",
+ "mana",
+ "hp",
+ "name",
+ "friendly",
+ "inventory",
+ "color",
+ "test_type",
+ "test",
+ "test4",
+ "testarrayofstring",
+ "testarrayoftables",
+ "enemy",
+ "testnestedflatbuffer",
+ "testempty",
+ "testbool",
+ "testhashs32_fnv1",
+ "testhashu32_fnv1",
+ "testhashs64_fnv1",
+ "testhashu64_fnv1",
+ "testhashs32_fnv1a",
+ "testhashu32_fnv1a",
+ "testhashs64_fnv1a",
+ "testhashu64_fnv1a",
+ "testarrayofbools",
+ "testf",
+ "testf2",
+ "testf3",
+ "testarrayofstring2",
+ "testarrayofsortedstruct",
+ "flex",
+ "test5",
+ "vector_of_longs",
+ "vector_of_doubles",
+ "parent_namespace_test",
+ "vector_of_referrables",
+ "single_weak_reference",
+ "vector_of_weak_references",
+ "vector_of_strong_referrables",
+ "co_owning_reference",
+ "vector_of_co_owning_references",
+ "non_owning_reference",
+ "vector_of_non_owning_references",
+ "any_unique_type",
+ "any_unique",
+ "any_ambiguous_type",
+ "any_ambiguous",
+ "vector_of_enums",
+ "signed_enum",
+ "testrequirednestedflatbuffer",
+ "scalar_key_sorted_tables",
+ "native_inline",
+ "long_enum_non_enum_default",
+ "long_enum_normal_default"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_TABLE, 54, type_codes, type_refs, nullptr, nullptr, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *TypeAliasesTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_CHAR, 0, -1 },
+ { flatbuffers::ET_UCHAR, 0, -1 },
+ { flatbuffers::ET_SHORT, 0, -1 },
+ { flatbuffers::ET_USHORT, 0, -1 },
+ { flatbuffers::ET_INT, 0, -1 },
+ { flatbuffers::ET_UINT, 0, -1 },
+ { flatbuffers::ET_LONG, 0, -1 },
+ { flatbuffers::ET_ULONG, 0, -1 },
+ { flatbuffers::ET_FLOAT, 0, -1 },
+ { flatbuffers::ET_DOUBLE, 0, -1 },
+ { flatbuffers::ET_CHAR, 1, -1 },
+ { flatbuffers::ET_DOUBLE, 1, -1 }
+ };
+ static const char * const names[] = {
+ "i8",
+ "u8",
+ "i16",
+ "u16",
+ "i32",
+ "u32",
+ "i64",
+ "u64",
+ "f32",
+ "f64",
+ "v8",
+ "vf64"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_TABLE, 12, type_codes, nullptr, nullptr, nullptr, names
+ };
+ return &tt;
+}
+
+inline const MyGame::Example::Monster *GetMonster(const void *buf) {
+ return flatbuffers::GetRoot<MyGame::Example::Monster>(buf);
+}
+
+inline const MyGame::Example::Monster *GetSizePrefixedMonster(const void *buf) {
+ return flatbuffers::GetSizePrefixedRoot<MyGame::Example::Monster>(buf);
+}
+
+inline Monster *GetMutableMonster(void *buf) {
+ return flatbuffers::GetMutableRoot<Monster>(buf);
+}
+
+inline MyGame::Example::Monster *GetMutableSizePrefixedMonster(void *buf) {
+ return flatbuffers::GetMutableSizePrefixedRoot<MyGame::Example::Monster>(buf);
+}
+
+inline const char *MonsterIdentifier() {
+ return "MONS";
+}
+
+inline bool MonsterBufferHasIdentifier(const void *buf) {
+ return flatbuffers::BufferHasIdentifier(
+ buf, MonsterIdentifier());
+}
+
+inline bool SizePrefixedMonsterBufferHasIdentifier(const void *buf) {
+ return flatbuffers::BufferHasIdentifier(
+ buf, MonsterIdentifier(), true);
+}
+
+inline bool VerifyMonsterBuffer(
+ flatbuffers::Verifier &verifier) {
+ return verifier.VerifyBuffer<MyGame::Example::Monster>(MonsterIdentifier());
+}
+
+inline bool VerifySizePrefixedMonsterBuffer(
+ flatbuffers::Verifier &verifier) {
+ return verifier.VerifySizePrefixedBuffer<MyGame::Example::Monster>(MonsterIdentifier());
+}
+
+inline const char *MonsterExtension() {
+ return "mon";
+}
+
+inline void FinishMonsterBuffer(
+ flatbuffers::FlatBufferBuilder &fbb,
+ flatbuffers::Offset<MyGame::Example::Monster> root) {
+ fbb.Finish(root, MonsterIdentifier());
+}
+
+inline void FinishSizePrefixedMonsterBuffer(
+ flatbuffers::FlatBufferBuilder &fbb,
+ flatbuffers::Offset<MyGame::Example::Monster> root) {
+ fbb.FinishSizePrefixed(root, MonsterIdentifier());
+}
+
+inline flatbuffers::unique_ptr<MyGame::Example::MonsterT> UnPackMonster(
+ const void *buf,
+ const flatbuffers::resolver_function_t *res = nullptr) {
+ return flatbuffers::unique_ptr<MyGame::Example::MonsterT>(GetMonster(buf)->UnPack(res));
+}
+
+inline flatbuffers::unique_ptr<MyGame::Example::MonsterT> UnPackSizePrefixedMonster(
+ const void *buf,
+ const flatbuffers::resolver_function_t *res = nullptr) {
+ return flatbuffers::unique_ptr<MyGame::Example::MonsterT>(GetSizePrefixedMonster(buf)->UnPack(res));
+}
+
+} // namespace Example
+} // namespace MyGame
+
+#endif // FLATBUFFERS_GENERATED_MONSTERTEST_MYGAME_EXAMPLE_H_
diff --git a/tests/monster_test_suffix/monster_test.grpc.fb.cc b/tests/monster_test_suffix/monster_test.grpc.fb.cc
new file mode 100644
index 0000000..6680f4f
--- /dev/null
+++ b/tests/monster_test_suffix/monster_test.grpc.fb.cc
@@ -0,0 +1,131 @@
+// Generated by the gRPC C++ plugin.
+// If you make any local change, they will be lost.
+// source: monster_test
+
+#include "monster_test_suffix.hpp"
+#include "monster_test.grpc.fb.h"
+
+#include <grpcpp/impl/codegen/async_stream.h>
+#include <grpcpp/impl/codegen/async_unary_call.h>
+#include <grpcpp/impl/codegen/channel_interface.h>
+#include <grpcpp/impl/codegen/client_unary_call.h>
+#include <grpcpp/impl/codegen/method_handler.h>
+#include <grpcpp/impl/codegen/rpc_service_method.h>
+#include <grpcpp/impl/codegen/service_type.h>
+#include <grpcpp/impl/codegen/sync_stream.h>
+namespace MyGame {
+namespace Example {
+
+static const char* MonsterStorage_method_names[] = {
+ "/MyGame.Example.MonsterStorage/Store",
+ "/MyGame.Example.MonsterStorage/Retrieve",
+ "/MyGame.Example.MonsterStorage/GetMaxHitPoint",
+ "/MyGame.Example.MonsterStorage/GetMinMaxHitPoints",
+};
+
+std::unique_ptr< MonsterStorage::Stub> MonsterStorage::NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& /*options*/) {
+ std::unique_ptr< MonsterStorage::Stub> stub(new MonsterStorage::Stub(channel));
+ return stub;
+}
+
+MonsterStorage::Stub::Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel)
+ : channel_(channel) , rpcmethod_Store_(MonsterStorage_method_names[0], ::grpc::internal::RpcMethod::NORMAL_RPC, channel)
+ , rpcmethod_Retrieve_(MonsterStorage_method_names[1], ::grpc::internal::RpcMethod::SERVER_STREAMING, channel)
+ , rpcmethod_GetMaxHitPoint_(MonsterStorage_method_names[2], ::grpc::internal::RpcMethod::CLIENT_STREAMING, channel)
+ , rpcmethod_GetMinMaxHitPoints_(MonsterStorage_method_names[3], ::grpc::internal::RpcMethod::BIDI_STREAMING, channel)
+ {}
+
+::grpc::Status MonsterStorage::Stub::Store(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, flatbuffers::grpc::Message<Stat>* response) {
+ return ::grpc::internal::BlockingUnaryCall(channel_.get(), rpcmethod_Store_, context, request, response);
+}
+
+::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>* MonsterStorage::Stub::AsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) {
+ return ::grpc::internal::ClientAsyncResponseReaderFactory< flatbuffers::grpc::Message<Stat>>::Create(channel_.get(), cq, rpcmethod_Store_, context, request, true);
+}
+
+::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>* MonsterStorage::Stub::PrepareAsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) {
+ return ::grpc::internal::ClientAsyncResponseReaderFactory< flatbuffers::grpc::Message<Stat>>::Create(channel_.get(), cq, rpcmethod_Store_, context, request, false);
+}
+
+::grpc::ClientReader< flatbuffers::grpc::Message<Monster>>* MonsterStorage::Stub::RetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request) {
+ return ::grpc::internal::ClientReaderFactory< flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), rpcmethod_Retrieve_, context, request);
+}
+
+::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>* MonsterStorage::Stub::AsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq, void* tag) {
+ return ::grpc::internal::ClientAsyncReaderFactory< flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), cq, rpcmethod_Retrieve_, context, request, true, tag);
+}
+
+::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>* MonsterStorage::Stub::PrepareAsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq) {
+ return ::grpc::internal::ClientAsyncReaderFactory< flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), cq, rpcmethod_Retrieve_, context, request, false, nullptr);
+}
+
+::grpc::ClientWriter< flatbuffers::grpc::Message<Monster>>* MonsterStorage::Stub::GetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response) {
+ return ::grpc::internal::ClientWriterFactory< flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), rpcmethod_GetMaxHitPoint_, context, response);
+}
+
+::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>* MonsterStorage::Stub::AsyncGetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq, void* tag) {
+ return ::grpc::internal::ClientAsyncWriterFactory< flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), cq, rpcmethod_GetMaxHitPoint_, context, response, true, tag);
+}
+
+::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>* MonsterStorage::Stub::PrepareAsyncGetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq) {
+ return ::grpc::internal::ClientAsyncWriterFactory< flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), cq, rpcmethod_GetMaxHitPoint_, context, response, false, nullptr);
+}
+
+::grpc::ClientReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* MonsterStorage::Stub::GetMinMaxHitPointsRaw(::grpc::ClientContext* context) {
+ return ::grpc::internal::ClientReaderWriterFactory< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>::Create(channel_.get(), rpcmethod_GetMinMaxHitPoints_, context);
+}
+
+::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* MonsterStorage::Stub::AsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) {
+ return ::grpc::internal::ClientAsyncReaderWriterFactory< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>::Create(channel_.get(), cq, rpcmethod_GetMinMaxHitPoints_, context, true, tag);
+}
+
+::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* MonsterStorage::Stub::PrepareAsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) {
+ return ::grpc::internal::ClientAsyncReaderWriterFactory< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>::Create(channel_.get(), cq, rpcmethod_GetMinMaxHitPoints_, context, false, nullptr);
+}
+
+MonsterStorage::Service::Service() {
+ AddMethod(new ::grpc::internal::RpcServiceMethod(
+ MonsterStorage_method_names[0],
+ ::grpc::internal::RpcMethod::NORMAL_RPC,
+ new ::grpc::internal::RpcMethodHandler< MonsterStorage::Service, flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>(
+ std::mem_fn(&MonsterStorage::Service::Store), this)));
+ AddMethod(new ::grpc::internal::RpcServiceMethod(
+ MonsterStorage_method_names[1],
+ ::grpc::internal::RpcMethod::SERVER_STREAMING,
+ new ::grpc::internal::ServerStreamingHandler< MonsterStorage::Service, flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>(
+ std::mem_fn(&MonsterStorage::Service::Retrieve), this)));
+ AddMethod(new ::grpc::internal::RpcServiceMethod(
+ MonsterStorage_method_names[2],
+ ::grpc::internal::RpcMethod::CLIENT_STREAMING,
+ new ::grpc::internal::ClientStreamingHandler< MonsterStorage::Service, flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>(
+ std::mem_fn(&MonsterStorage::Service::GetMaxHitPoint), this)));
+ AddMethod(new ::grpc::internal::RpcServiceMethod(
+ MonsterStorage_method_names[3],
+ ::grpc::internal::RpcMethod::BIDI_STREAMING,
+ new ::grpc::internal::BidiStreamingHandler< MonsterStorage::Service, flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>(
+ std::mem_fn(&MonsterStorage::Service::GetMinMaxHitPoints), this)));
+}
+
+MonsterStorage::Service::~Service() {
+}
+
+::grpc::Status MonsterStorage::Service::Store(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Monster>* /*request*/, flatbuffers::grpc::Message<Stat>* /*response*/) {
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+}
+
+::grpc::Status MonsterStorage::Service::Retrieve(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Stat>* /*request*/, ::grpc::ServerWriter< flatbuffers::grpc::Message<Monster>>* /*writer*/) {
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+}
+
+::grpc::Status MonsterStorage::Service::GetMaxHitPoint(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< flatbuffers::grpc::Message<Monster>>* /*reader*/, flatbuffers::grpc::Message<Stat>* /*response*/) {
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+}
+
+::grpc::Status MonsterStorage::Service::GetMinMaxHitPoints(::grpc::ServerContext* /*context*/, ::grpc::ServerReaderWriter< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>* /*stream*/) {
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+}
+
+
+} // namespace MyGame
+} // namespace Example
+
diff --git a/tests/monster_test_suffix/monster_test.grpc.fb.h b/tests/monster_test_suffix/monster_test.grpc.fb.h
new file mode 100644
index 0000000..1b6ab6f
--- /dev/null
+++ b/tests/monster_test_suffix/monster_test.grpc.fb.h
@@ -0,0 +1,350 @@
+// Generated by the gRPC C++ plugin.
+// If you make any local change, they will be lost.
+// source: monster_test
+#ifndef GRPC_monster_5ftest__INCLUDED
+#define GRPC_monster_5ftest__INCLUDED
+
+#include "monster_test_suffix.hpp"
+#include "flatbuffers/grpc.h"
+
+#include <grpcpp/impl/codegen/async_stream.h>
+#include <grpcpp/impl/codegen/async_unary_call.h>
+#include <grpcpp/impl/codegen/method_handler.h>
+#include <grpcpp/impl/codegen/proto_utils.h>
+#include <grpcpp/impl/codegen/rpc_method.h>
+#include <grpcpp/impl/codegen/service_type.h>
+#include <grpcpp/impl/codegen/status.h>
+#include <grpcpp/impl/codegen/stub_options.h>
+#include <grpcpp/impl/codegen/sync_stream.h>
+
+namespace grpc {
+class CompletionQueue;
+class Channel;
+class ServerCompletionQueue;
+class ServerContext;
+} // namespace grpc
+
+namespace MyGame {
+namespace Example {
+
+class MonsterStorage final {
+ public:
+ static constexpr char const* service_full_name() {
+ return "MyGame.Example.MonsterStorage";
+ }
+ class StubInterface {
+ public:
+ virtual ~StubInterface() {}
+ virtual ::grpc::Status Store(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, flatbuffers::grpc::Message<Stat>* response) = 0;
+ std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::grpc::Message<Stat>>> AsyncStore(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::grpc::Message<Stat>>>(AsyncStoreRaw(context, request, cq));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::grpc::Message<Stat>>> PrepareAsyncStore(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::grpc::Message<Stat>>>(PrepareAsyncStoreRaw(context, request, cq));
+ }
+ std::unique_ptr< ::grpc::ClientReaderInterface< flatbuffers::grpc::Message<Monster>>> Retrieve(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request) {
+ return std::unique_ptr< ::grpc::ClientReaderInterface< flatbuffers::grpc::Message<Monster>>>(RetrieveRaw(context, request));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncReaderInterface< flatbuffers::grpc::Message<Monster>>> AsyncRetrieve(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq, void* tag) {
+ return std::unique_ptr< ::grpc::ClientAsyncReaderInterface< flatbuffers::grpc::Message<Monster>>>(AsyncRetrieveRaw(context, request, cq, tag));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncReaderInterface< flatbuffers::grpc::Message<Monster>>> PrepareAsyncRetrieve(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncReaderInterface< flatbuffers::grpc::Message<Monster>>>(PrepareAsyncRetrieveRaw(context, request, cq));
+ }
+ std::unique_ptr< ::grpc::ClientWriterInterface< flatbuffers::grpc::Message<Monster>>> GetMaxHitPoint(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response) {
+ return std::unique_ptr< ::grpc::ClientWriterInterface< flatbuffers::grpc::Message<Monster>>>(GetMaxHitPointRaw(context, response));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncWriterInterface< flatbuffers::grpc::Message<Monster>>> AsyncGetMaxHitPoint(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq, void* tag) {
+ return std::unique_ptr< ::grpc::ClientAsyncWriterInterface< flatbuffers::grpc::Message<Monster>>>(AsyncGetMaxHitPointRaw(context, response, cq, tag));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncWriterInterface< flatbuffers::grpc::Message<Monster>>> PrepareAsyncGetMaxHitPoint(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncWriterInterface< flatbuffers::grpc::Message<Monster>>>(PrepareAsyncGetMaxHitPointRaw(context, response, cq));
+ }
+ std::unique_ptr< ::grpc::ClientReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>> GetMinMaxHitPoints(::grpc::ClientContext* context) {
+ return std::unique_ptr< ::grpc::ClientReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>(GetMinMaxHitPointsRaw(context));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>> AsyncGetMinMaxHitPoints(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) {
+ return std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>(AsyncGetMinMaxHitPointsRaw(context, cq, tag));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>> PrepareAsyncGetMinMaxHitPoints(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>(PrepareAsyncGetMinMaxHitPointsRaw(context, cq));
+ }
+ private:
+ virtual ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::grpc::Message<Stat>>* AsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) = 0;
+ virtual ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::grpc::Message<Stat>>* PrepareAsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) = 0;
+ virtual ::grpc::ClientReaderInterface< flatbuffers::grpc::Message<Monster>>* RetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request) = 0;
+ virtual ::grpc::ClientAsyncReaderInterface< flatbuffers::grpc::Message<Monster>>* AsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq, void* tag) = 0;
+ virtual ::grpc::ClientAsyncReaderInterface< flatbuffers::grpc::Message<Monster>>* PrepareAsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq) = 0;
+ virtual ::grpc::ClientWriterInterface< flatbuffers::grpc::Message<Monster>>* GetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response) = 0;
+ virtual ::grpc::ClientAsyncWriterInterface< flatbuffers::grpc::Message<Monster>>* AsyncGetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq, void* tag) = 0;
+ virtual ::grpc::ClientAsyncWriterInterface< flatbuffers::grpc::Message<Monster>>* PrepareAsyncGetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq) = 0;
+ virtual ::grpc::ClientReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* GetMinMaxHitPointsRaw(::grpc::ClientContext* context) = 0;
+ virtual ::grpc::ClientAsyncReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* AsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) = 0;
+ virtual ::grpc::ClientAsyncReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* PrepareAsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) = 0;
+ };
+ class Stub final : public StubInterface {
+ public:
+ Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel);
+ ::grpc::Status Store(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, flatbuffers::grpc::Message<Stat>* response) override;
+ std::unique_ptr< ::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>> AsyncStore(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>>(AsyncStoreRaw(context, request, cq));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>> PrepareAsyncStore(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>>(PrepareAsyncStoreRaw(context, request, cq));
+ }
+ std::unique_ptr< ::grpc::ClientReader< flatbuffers::grpc::Message<Monster>>> Retrieve(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request) {
+ return std::unique_ptr< ::grpc::ClientReader< flatbuffers::grpc::Message<Monster>>>(RetrieveRaw(context, request));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>> AsyncRetrieve(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq, void* tag) {
+ return std::unique_ptr< ::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>>(AsyncRetrieveRaw(context, request, cq, tag));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>> PrepareAsyncRetrieve(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>>(PrepareAsyncRetrieveRaw(context, request, cq));
+ }
+ std::unique_ptr< ::grpc::ClientWriter< flatbuffers::grpc::Message<Monster>>> GetMaxHitPoint(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response) {
+ return std::unique_ptr< ::grpc::ClientWriter< flatbuffers::grpc::Message<Monster>>>(GetMaxHitPointRaw(context, response));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>> AsyncGetMaxHitPoint(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq, void* tag) {
+ return std::unique_ptr< ::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>>(AsyncGetMaxHitPointRaw(context, response, cq, tag));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>> PrepareAsyncGetMaxHitPoint(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>>(PrepareAsyncGetMaxHitPointRaw(context, response, cq));
+ }
+ std::unique_ptr< ::grpc::ClientReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>> GetMinMaxHitPoints(::grpc::ClientContext* context) {
+ return std::unique_ptr< ::grpc::ClientReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>(GetMinMaxHitPointsRaw(context));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>> AsyncGetMinMaxHitPoints(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) {
+ return std::unique_ptr< ::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>(AsyncGetMinMaxHitPointsRaw(context, cq, tag));
+ }
+ std::unique_ptr< ::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>> PrepareAsyncGetMinMaxHitPoints(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) {
+ return std::unique_ptr< ::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>(PrepareAsyncGetMinMaxHitPointsRaw(context, cq));
+ }
+
+ private:
+ std::shared_ptr< ::grpc::ChannelInterface> channel_;
+ ::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>* AsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) override;
+ ::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>* PrepareAsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) override;
+ ::grpc::ClientReader< flatbuffers::grpc::Message<Monster>>* RetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request) override;
+ ::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>* AsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq, void* tag) override;
+ ::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>* PrepareAsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq) override;
+ ::grpc::ClientWriter< flatbuffers::grpc::Message<Monster>>* GetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response) override;
+ ::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>* AsyncGetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq, void* tag) override;
+ ::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>* PrepareAsyncGetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq) override;
+ ::grpc::ClientReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* GetMinMaxHitPointsRaw(::grpc::ClientContext* context) override;
+ ::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* AsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) override;
+ ::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* PrepareAsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) override;
+ const ::grpc::internal::RpcMethod rpcmethod_Store_;
+ const ::grpc::internal::RpcMethod rpcmethod_Retrieve_;
+ const ::grpc::internal::RpcMethod rpcmethod_GetMaxHitPoint_;
+ const ::grpc::internal::RpcMethod rpcmethod_GetMinMaxHitPoints_;
+ };
+ static std::unique_ptr<Stub> NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options = ::grpc::StubOptions());
+
+ class Service : public ::grpc::Service {
+ public:
+ Service();
+ virtual ~Service();
+ virtual ::grpc::Status Store(::grpc::ServerContext* context, const flatbuffers::grpc::Message<Monster>* request, flatbuffers::grpc::Message<Stat>* response);
+ virtual ::grpc::Status Retrieve(::grpc::ServerContext* context, const flatbuffers::grpc::Message<Stat>* request, ::grpc::ServerWriter< flatbuffers::grpc::Message<Monster>>* writer);
+ virtual ::grpc::Status GetMaxHitPoint(::grpc::ServerContext* context, ::grpc::ServerReader< flatbuffers::grpc::Message<Monster>>* reader, flatbuffers::grpc::Message<Stat>* response);
+ virtual ::grpc::Status GetMinMaxHitPoints(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>* stream);
+ };
+ template <class BaseClass>
+ class WithAsyncMethod_Store : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
+ public:
+ WithAsyncMethod_Store() {
+ ::grpc::Service::MarkMethodAsync(0);
+ }
+ ~WithAsyncMethod_Store() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status Store(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Monster>* /*request*/, flatbuffers::grpc::Message<Stat>* /*response*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ void RequestStore(::grpc::ServerContext* context, flatbuffers::grpc::Message<Monster>* request, ::grpc::ServerAsyncResponseWriter< flatbuffers::grpc::Message<Stat>>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
+ ::grpc::Service::RequestAsyncUnary(0, context, request, response, new_call_cq, notification_cq, tag);
+ }
+ };
+ template <class BaseClass>
+ class WithAsyncMethod_Retrieve : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
+ public:
+ WithAsyncMethod_Retrieve() {
+ ::grpc::Service::MarkMethodAsync(1);
+ }
+ ~WithAsyncMethod_Retrieve() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status Retrieve(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Stat>* /*request*/, ::grpc::ServerWriter< flatbuffers::grpc::Message<Monster>>* /*writer*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ void RequestRetrieve(::grpc::ServerContext* context, flatbuffers::grpc::Message<Stat>* request, ::grpc::ServerAsyncWriter< flatbuffers::grpc::Message<Monster>>* writer, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
+ ::grpc::Service::RequestAsyncServerStreaming(1, context, request, writer, new_call_cq, notification_cq, tag);
+ }
+ };
+ template <class BaseClass>
+ class WithAsyncMethod_GetMaxHitPoint : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
+ public:
+ WithAsyncMethod_GetMaxHitPoint() {
+ ::grpc::Service::MarkMethodAsync(2);
+ }
+ ~WithAsyncMethod_GetMaxHitPoint() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status GetMaxHitPoint(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< flatbuffers::grpc::Message<Monster>>* /*reader*/, flatbuffers::grpc::Message<Stat>* /*response*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ void RequestGetMaxHitPoint(::grpc::ServerContext* context, ::grpc::ServerAsyncReader< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>* reader, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
+ ::grpc::Service::RequestAsyncClientStreaming(2, context, reader, new_call_cq, notification_cq, tag);
+ }
+ };
+ template <class BaseClass>
+ class WithAsyncMethod_GetMinMaxHitPoints : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
+ public:
+ WithAsyncMethod_GetMinMaxHitPoints() {
+ ::grpc::Service::MarkMethodAsync(3);
+ }
+ ~WithAsyncMethod_GetMinMaxHitPoints() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status GetMinMaxHitPoints(::grpc::ServerContext* /*context*/, ::grpc::ServerReaderWriter< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>* /*stream*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ void RequestGetMinMaxHitPoints(::grpc::ServerContext* context, ::grpc::ServerAsyncReaderWriter< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>* stream, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
+ ::grpc::Service::RequestAsyncBidiStreaming(3, context, stream, new_call_cq, notification_cq, tag);
+ }
+ };
+ typedef WithAsyncMethod_Store< WithAsyncMethod_Retrieve< WithAsyncMethod_GetMaxHitPoint< WithAsyncMethod_GetMinMaxHitPoints< Service > > > > AsyncService;
+ template <class BaseClass>
+ class WithGenericMethod_Store : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
+ public:
+ WithGenericMethod_Store() {
+ ::grpc::Service::MarkMethodGeneric(0);
+ }
+ ~WithGenericMethod_Store() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status Store(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Monster>* /*request*/, flatbuffers::grpc::Message<Stat>* /*response*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ };
+ template <class BaseClass>
+ class WithGenericMethod_Retrieve : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
+ public:
+ WithGenericMethod_Retrieve() {
+ ::grpc::Service::MarkMethodGeneric(1);
+ }
+ ~WithGenericMethod_Retrieve() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status Retrieve(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Stat>* /*request*/, ::grpc::ServerWriter< flatbuffers::grpc::Message<Monster>>* /*writer*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ };
+ template <class BaseClass>
+ class WithGenericMethod_GetMaxHitPoint : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
+ public:
+ WithGenericMethod_GetMaxHitPoint() {
+ ::grpc::Service::MarkMethodGeneric(2);
+ }
+ ~WithGenericMethod_GetMaxHitPoint() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status GetMaxHitPoint(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< flatbuffers::grpc::Message<Monster>>* /*reader*/, flatbuffers::grpc::Message<Stat>* /*response*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ };
+ template <class BaseClass>
+ class WithGenericMethod_GetMinMaxHitPoints : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
+ public:
+ WithGenericMethod_GetMinMaxHitPoints() {
+ ::grpc::Service::MarkMethodGeneric(3);
+ }
+ ~WithGenericMethod_GetMinMaxHitPoints() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status GetMinMaxHitPoints(::grpc::ServerContext* /*context*/, ::grpc::ServerReaderWriter< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>* /*stream*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ };
+ template <class BaseClass>
+ class WithStreamedUnaryMethod_Store : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
+ public:
+ WithStreamedUnaryMethod_Store() {
+ ::grpc::Service::MarkMethodStreamed(0,
+ new ::grpc::internal::StreamedUnaryHandler< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>(std::bind(&WithStreamedUnaryMethod_Store<BaseClass>::StreamedStore, this, std::placeholders::_1, std::placeholders::_2)));
+ }
+ ~WithStreamedUnaryMethod_Store() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable regular version of this method
+ ::grpc::Status Store(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Monster>* /*request*/, flatbuffers::grpc::Message<Stat>* /*response*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ // replace default version of method with streamed unary
+ virtual ::grpc::Status StreamedStore(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer< flatbuffers::grpc::Message<Monster>,flatbuffers::grpc::Message<Stat>>* server_unary_streamer) = 0;
+ };
+ typedef WithStreamedUnaryMethod_Store< Service > StreamedUnaryService;
+ template <class BaseClass>
+ class WithSplitStreamingMethod_Retrieve : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service */*service*/) { }
+ public:
+ WithSplitStreamingMethod_Retrieve() {
+ ::grpc::Service::MarkMethodStreamed(1,
+ new ::grpc::internal::SplitServerStreamingHandler< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>(std::bind(&WithSplitStreamingMethod_Retrieve<BaseClass>::StreamedRetrieve, this, std::placeholders::_1, std::placeholders::_2)));
+ }
+ ~WithSplitStreamingMethod_Retrieve() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable regular version of this method
+ ::grpc::Status Retrieve(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Stat>* /*request*/, ::grpc::ServerWriter< flatbuffers::grpc::Message<Monster>>* /*writer*/) final override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ // replace default version of method with split streamed
+ virtual ::grpc::Status StreamedRetrieve(::grpc::ServerContext* context, ::grpc::ServerSplitStreamer< flatbuffers::grpc::Message<Stat>,flatbuffers::grpc::Message<Monster>>* server_split_streamer) = 0;
+ };
+ typedef WithSplitStreamingMethod_Retrieve< Service > SplitStreamedService;
+ typedef WithStreamedUnaryMethod_Store< WithSplitStreamingMethod_Retrieve< Service > > StreamedService;
+};
+
+} // namespace Example
+} // namespace MyGame
+
+
+#endif // GRPC_monster_5ftest__INCLUDED
diff --git a/tests/monster_test_suffix/monster_test_suffix.hpp b/tests/monster_test_suffix/monster_test_suffix.hpp
new file mode 100644
index 0000000..deab77b
--- /dev/null
+++ b/tests/monster_test_suffix/monster_test_suffix.hpp
@@ -0,0 +1,4034 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+
+#ifndef FLATBUFFERS_GENERATED_MONSTERTEST_MYGAME_EXAMPLE_H_
+#define FLATBUFFERS_GENERATED_MONSTERTEST_MYGAME_EXAMPLE_H_
+
+#include "flatbuffers/flatbuffers.h"
+#include "flatbuffers/flexbuffers.h"
+#include "flatbuffers/flex_flat_util.h"
+
+// Ensure the included flatbuffers.h is the same version as when this file was
+// generated, otherwise it may not be compatible.
+static_assert(FLATBUFFERS_VERSION_MAJOR == 2 &&
+ FLATBUFFERS_VERSION_MINOR == 0 &&
+ FLATBUFFERS_VERSION_REVISION == 8,
+ "Non-compatible flatbuffers version included");
+
+namespace MyGame {
+
+struct InParentNamespace;
+struct InParentNamespaceBuilder;
+struct InParentNamespaceT;
+
+namespace Example2 {
+
+struct Monster;
+struct MonsterBuilder;
+struct MonsterT;
+
+} // namespace Example2
+
+namespace Example {
+
+struct Test;
+
+struct TestSimpleTableWithEnum;
+struct TestSimpleTableWithEnumBuilder;
+struct TestSimpleTableWithEnumT;
+
+struct Vec3;
+
+struct Ability;
+
+struct StructOfStructs;
+
+struct StructOfStructsOfStructs;
+
+struct Stat;
+struct StatBuilder;
+struct StatT;
+
+struct Referrable;
+struct ReferrableBuilder;
+struct ReferrableT;
+
+struct Monster;
+struct MonsterBuilder;
+struct MonsterT;
+
+struct TypeAliases;
+struct TypeAliasesBuilder;
+struct TypeAliasesT;
+
+} // namespace Example
+
+bool operator==(const InParentNamespaceT &lhs, const InParentNamespaceT &rhs);
+bool operator!=(const InParentNamespaceT &lhs, const InParentNamespaceT &rhs);
+namespace Example2 {
+
+bool operator==(const MonsterT &lhs, const MonsterT &rhs);
+bool operator!=(const MonsterT &lhs, const MonsterT &rhs);
+} // namespace Example2
+
+namespace Example {
+
+bool operator==(const Test &lhs, const Test &rhs);
+bool operator!=(const Test &lhs, const Test &rhs);
+bool operator==(const TestSimpleTableWithEnumT &lhs, const TestSimpleTableWithEnumT &rhs);
+bool operator!=(const TestSimpleTableWithEnumT &lhs, const TestSimpleTableWithEnumT &rhs);
+bool operator==(const Vec3 &lhs, const Vec3 &rhs);
+bool operator!=(const Vec3 &lhs, const Vec3 &rhs);
+bool operator==(const Ability &lhs, const Ability &rhs);
+bool operator!=(const Ability &lhs, const Ability &rhs);
+bool operator==(const StructOfStructs &lhs, const StructOfStructs &rhs);
+bool operator!=(const StructOfStructs &lhs, const StructOfStructs &rhs);
+bool operator==(const StructOfStructsOfStructs &lhs, const StructOfStructsOfStructs &rhs);
+bool operator!=(const StructOfStructsOfStructs &lhs, const StructOfStructsOfStructs &rhs);
+bool operator==(const StatT &lhs, const StatT &rhs);
+bool operator!=(const StatT &lhs, const StatT &rhs);
+bool operator==(const ReferrableT &lhs, const ReferrableT &rhs);
+bool operator!=(const ReferrableT &lhs, const ReferrableT &rhs);
+bool operator==(const MonsterT &lhs, const MonsterT &rhs);
+bool operator!=(const MonsterT &lhs, const MonsterT &rhs);
+bool operator==(const TypeAliasesT &lhs, const TypeAliasesT &rhs);
+bool operator!=(const TypeAliasesT &lhs, const TypeAliasesT &rhs);
+
+} // namespace Example
+
+inline const flatbuffers::TypeTable *InParentNamespaceTypeTable();
+
+namespace Example2 {
+
+inline const flatbuffers::TypeTable *MonsterTypeTable();
+
+} // namespace Example2
+
+namespace Example {
+
+inline const flatbuffers::TypeTable *TestTypeTable();
+
+inline const flatbuffers::TypeTable *TestSimpleTableWithEnumTypeTable();
+
+inline const flatbuffers::TypeTable *Vec3TypeTable();
+
+inline const flatbuffers::TypeTable *AbilityTypeTable();
+
+inline const flatbuffers::TypeTable *StructOfStructsTypeTable();
+
+inline const flatbuffers::TypeTable *StructOfStructsOfStructsTypeTable();
+
+inline const flatbuffers::TypeTable *StatTypeTable();
+
+inline const flatbuffers::TypeTable *ReferrableTypeTable();
+
+inline const flatbuffers::TypeTable *MonsterTypeTable();
+
+inline const flatbuffers::TypeTable *TypeAliasesTypeTable();
+
+/// Composite components of Monster color.
+enum Color : uint8_t {
+ Color_Red = 1,
+ /// \brief color Green
+ /// Green is bit_flag with value (1u << 1)
+ Color_Green = 2,
+ /// \brief color Blue (1u << 3)
+ Color_Blue = 8,
+ Color_NONE = 0,
+ Color_ANY = 11
+};
+
+inline const Color (&EnumValuesColor())[3] {
+ static const Color values[] = {
+ Color_Red,
+ Color_Green,
+ Color_Blue
+ };
+ return values;
+}
+
+inline const char * const *EnumNamesColor() {
+ static const char * const names[9] = {
+ "Red",
+ "Green",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "Blue",
+ nullptr
+ };
+ return names;
+}
+
+inline const char *EnumNameColor(Color e) {
+ if (flatbuffers::IsOutRange(e, Color_Red, Color_Blue)) return "";
+ const size_t index = static_cast<size_t>(e) - static_cast<size_t>(Color_Red);
+ return EnumNamesColor()[index];
+}
+
+enum Race : int8_t {
+ Race_None = -1,
+ Race_Human = 0,
+ Race_Dwarf = 1,
+ Race_Elf = 2,
+ Race_MIN = Race_None,
+ Race_MAX = Race_Elf
+};
+
+inline const Race (&EnumValuesRace())[4] {
+ static const Race values[] = {
+ Race_None,
+ Race_Human,
+ Race_Dwarf,
+ Race_Elf
+ };
+ return values;
+}
+
+inline const char * const *EnumNamesRace() {
+ static const char * const names[5] = {
+ "None",
+ "Human",
+ "Dwarf",
+ "Elf",
+ nullptr
+ };
+ return names;
+}
+
+inline const char *EnumNameRace(Race e) {
+ if (flatbuffers::IsOutRange(e, Race_None, Race_Elf)) return "";
+ const size_t index = static_cast<size_t>(e) - static_cast<size_t>(Race_None);
+ return EnumNamesRace()[index];
+}
+
+enum LongEnum : uint64_t {
+ LongEnum_LongOne = 2ULL,
+ LongEnum_LongTwo = 4ULL,
+ LongEnum_LongBig = 1099511627776ULL,
+ LongEnum_NONE = 0,
+ LongEnum_ANY = 1099511627782ULL
+};
+
+inline const LongEnum (&EnumValuesLongEnum())[3] {
+ static const LongEnum values[] = {
+ LongEnum_LongOne,
+ LongEnum_LongTwo,
+ LongEnum_LongBig
+ };
+ return values;
+}
+
+inline const char *EnumNameLongEnum(LongEnum e) {
+ switch (e) {
+ case LongEnum_LongOne: return "LongOne";
+ case LongEnum_LongTwo: return "LongTwo";
+ case LongEnum_LongBig: return "LongBig";
+ default: return "";
+ }
+}
+
+enum Any : uint8_t {
+ Any_NONE = 0,
+ Any_Monster = 1,
+ Any_TestSimpleTableWithEnum = 2,
+ Any_MyGame_Example2_Monster = 3,
+ Any_MIN = Any_NONE,
+ Any_MAX = Any_MyGame_Example2_Monster
+};
+
+inline const Any (&EnumValuesAny())[4] {
+ static const Any values[] = {
+ Any_NONE,
+ Any_Monster,
+ Any_TestSimpleTableWithEnum,
+ Any_MyGame_Example2_Monster
+ };
+ return values;
+}
+
+inline const char * const *EnumNamesAny() {
+ static const char * const names[5] = {
+ "NONE",
+ "Monster",
+ "TestSimpleTableWithEnum",
+ "MyGame_Example2_Monster",
+ nullptr
+ };
+ return names;
+}
+
+inline const char *EnumNameAny(Any e) {
+ if (flatbuffers::IsOutRange(e, Any_NONE, Any_MyGame_Example2_Monster)) return "";
+ const size_t index = static_cast<size_t>(e);
+ return EnumNamesAny()[index];
+}
+
+template<typename T> struct AnyTraits {
+ static const Any enum_value = Any_NONE;
+};
+
+template<> struct AnyTraits<MyGame::Example::Monster> {
+ static const Any enum_value = Any_Monster;
+};
+
+template<> struct AnyTraits<MyGame::Example::TestSimpleTableWithEnum> {
+ static const Any enum_value = Any_TestSimpleTableWithEnum;
+};
+
+template<> struct AnyTraits<MyGame::Example2::Monster> {
+ static const Any enum_value = Any_MyGame_Example2_Monster;
+};
+
+template<typename T> struct AnyUnionTraits {
+ static const Any enum_value = Any_NONE;
+};
+
+template<> struct AnyUnionTraits<MyGame::Example::MonsterT> {
+ static const Any enum_value = Any_Monster;
+};
+
+template<> struct AnyUnionTraits<MyGame::Example::TestSimpleTableWithEnumT> {
+ static const Any enum_value = Any_TestSimpleTableWithEnum;
+};
+
+template<> struct AnyUnionTraits<MyGame::Example2::MonsterT> {
+ static const Any enum_value = Any_MyGame_Example2_Monster;
+};
+
+struct AnyUnion {
+ Any type;
+ void *value;
+
+ AnyUnion() : type(Any_NONE), value(nullptr) {}
+ AnyUnion(AnyUnion&& u) FLATBUFFERS_NOEXCEPT :
+ type(Any_NONE), value(nullptr)
+ { std::swap(type, u.type); std::swap(value, u.value); }
+ AnyUnion(const AnyUnion &);
+ AnyUnion &operator=(const AnyUnion &u)
+ { AnyUnion t(u); std::swap(type, t.type); std::swap(value, t.value); return *this; }
+ AnyUnion &operator=(AnyUnion &&u) FLATBUFFERS_NOEXCEPT
+ { std::swap(type, u.type); std::swap(value, u.value); return *this; }
+ ~AnyUnion() { Reset(); }
+
+ void Reset();
+
+ template <typename T>
+ void Set(T&& val) {
+ typedef typename std::remove_reference<T>::type RT;
+ Reset();
+ type = AnyUnionTraits<RT>::enum_value;
+ if (type != Any_NONE) {
+ value = new RT(std::forward<T>(val));
+ }
+ }
+
+ static void *UnPack(const void *obj, Any type, const flatbuffers::resolver_function_t *resolver);
+ flatbuffers::Offset<void> Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const;
+
+ MyGame::Example::MonsterT *AsMonster() {
+ return type == Any_Monster ?
+ reinterpret_cast<MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+ const MyGame::Example::MonsterT *AsMonster() const {
+ return type == Any_Monster ?
+ reinterpret_cast<const MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+ MyGame::Example::TestSimpleTableWithEnumT *AsTestSimpleTableWithEnum() {
+ return type == Any_TestSimpleTableWithEnum ?
+ reinterpret_cast<MyGame::Example::TestSimpleTableWithEnumT *>(value) : nullptr;
+ }
+ const MyGame::Example::TestSimpleTableWithEnumT *AsTestSimpleTableWithEnum() const {
+ return type == Any_TestSimpleTableWithEnum ?
+ reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnumT *>(value) : nullptr;
+ }
+ MyGame::Example2::MonsterT *AsMyGame_Example2_Monster() {
+ return type == Any_MyGame_Example2_Monster ?
+ reinterpret_cast<MyGame::Example2::MonsterT *>(value) : nullptr;
+ }
+ const MyGame::Example2::MonsterT *AsMyGame_Example2_Monster() const {
+ return type == Any_MyGame_Example2_Monster ?
+ reinterpret_cast<const MyGame::Example2::MonsterT *>(value) : nullptr;
+ }
+};
+
+
+inline bool operator==(const AnyUnion &lhs, const AnyUnion &rhs) {
+ if (lhs.type != rhs.type) return false;
+ switch (lhs.type) {
+ case Any_NONE: {
+ return true;
+ }
+ case Any_Monster: {
+ return *(reinterpret_cast<const MyGame::Example::MonsterT *>(lhs.value)) ==
+ *(reinterpret_cast<const MyGame::Example::MonsterT *>(rhs.value));
+ }
+ case Any_TestSimpleTableWithEnum: {
+ return *(reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnumT *>(lhs.value)) ==
+ *(reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnumT *>(rhs.value));
+ }
+ case Any_MyGame_Example2_Monster: {
+ return *(reinterpret_cast<const MyGame::Example2::MonsterT *>(lhs.value)) ==
+ *(reinterpret_cast<const MyGame::Example2::MonsterT *>(rhs.value));
+ }
+ default: {
+ return false;
+ }
+ }
+}
+
+inline bool operator!=(const AnyUnion &lhs, const AnyUnion &rhs) {
+ return !(lhs == rhs);
+}
+
+bool VerifyAny(flatbuffers::Verifier &verifier, const void *obj, Any type);
+bool VerifyAnyVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types);
+
+enum AnyUniqueAliases : uint8_t {
+ AnyUniqueAliases_NONE = 0,
+ AnyUniqueAliases_M = 1,
+ AnyUniqueAliases_TS = 2,
+ AnyUniqueAliases_M2 = 3,
+ AnyUniqueAliases_MIN = AnyUniqueAliases_NONE,
+ AnyUniqueAliases_MAX = AnyUniqueAliases_M2
+};
+
+inline const AnyUniqueAliases (&EnumValuesAnyUniqueAliases())[4] {
+ static const AnyUniqueAliases values[] = {
+ AnyUniqueAliases_NONE,
+ AnyUniqueAliases_M,
+ AnyUniqueAliases_TS,
+ AnyUniqueAliases_M2
+ };
+ return values;
+}
+
+inline const char * const *EnumNamesAnyUniqueAliases() {
+ static const char * const names[5] = {
+ "NONE",
+ "M",
+ "TS",
+ "M2",
+ nullptr
+ };
+ return names;
+}
+
+inline const char *EnumNameAnyUniqueAliases(AnyUniqueAliases e) {
+ if (flatbuffers::IsOutRange(e, AnyUniqueAliases_NONE, AnyUniqueAliases_M2)) return "";
+ const size_t index = static_cast<size_t>(e);
+ return EnumNamesAnyUniqueAliases()[index];
+}
+
+template<typename T> struct AnyUniqueAliasesTraits {
+ static const AnyUniqueAliases enum_value = AnyUniqueAliases_NONE;
+};
+
+template<> struct AnyUniqueAliasesTraits<MyGame::Example::Monster> {
+ static const AnyUniqueAliases enum_value = AnyUniqueAliases_M;
+};
+
+template<> struct AnyUniqueAliasesTraits<MyGame::Example::TestSimpleTableWithEnum> {
+ static const AnyUniqueAliases enum_value = AnyUniqueAliases_TS;
+};
+
+template<> struct AnyUniqueAliasesTraits<MyGame::Example2::Monster> {
+ static const AnyUniqueAliases enum_value = AnyUniqueAliases_M2;
+};
+
+template<typename T> struct AnyUniqueAliasesUnionTraits {
+ static const AnyUniqueAliases enum_value = AnyUniqueAliases_NONE;
+};
+
+template<> struct AnyUniqueAliasesUnionTraits<MyGame::Example::MonsterT> {
+ static const AnyUniqueAliases enum_value = AnyUniqueAliases_M;
+};
+
+template<> struct AnyUniqueAliasesUnionTraits<MyGame::Example::TestSimpleTableWithEnumT> {
+ static const AnyUniqueAliases enum_value = AnyUniqueAliases_TS;
+};
+
+template<> struct AnyUniqueAliasesUnionTraits<MyGame::Example2::MonsterT> {
+ static const AnyUniqueAliases enum_value = AnyUniqueAliases_M2;
+};
+
+struct AnyUniqueAliasesUnion {
+ AnyUniqueAliases type;
+ void *value;
+
+ AnyUniqueAliasesUnion() : type(AnyUniqueAliases_NONE), value(nullptr) {}
+ AnyUniqueAliasesUnion(AnyUniqueAliasesUnion&& u) FLATBUFFERS_NOEXCEPT :
+ type(AnyUniqueAliases_NONE), value(nullptr)
+ { std::swap(type, u.type); std::swap(value, u.value); }
+ AnyUniqueAliasesUnion(const AnyUniqueAliasesUnion &);
+ AnyUniqueAliasesUnion &operator=(const AnyUniqueAliasesUnion &u)
+ { AnyUniqueAliasesUnion t(u); std::swap(type, t.type); std::swap(value, t.value); return *this; }
+ AnyUniqueAliasesUnion &operator=(AnyUniqueAliasesUnion &&u) FLATBUFFERS_NOEXCEPT
+ { std::swap(type, u.type); std::swap(value, u.value); return *this; }
+ ~AnyUniqueAliasesUnion() { Reset(); }
+
+ void Reset();
+
+ template <typename T>
+ void Set(T&& val) {
+ typedef typename std::remove_reference<T>::type RT;
+ Reset();
+ type = AnyUniqueAliasesUnionTraits<RT>::enum_value;
+ if (type != AnyUniqueAliases_NONE) {
+ value = new RT(std::forward<T>(val));
+ }
+ }
+
+ static void *UnPack(const void *obj, AnyUniqueAliases type, const flatbuffers::resolver_function_t *resolver);
+ flatbuffers::Offset<void> Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const;
+
+ MyGame::Example::MonsterT *AsM() {
+ return type == AnyUniqueAliases_M ?
+ reinterpret_cast<MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+ const MyGame::Example::MonsterT *AsM() const {
+ return type == AnyUniqueAliases_M ?
+ reinterpret_cast<const MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+ MyGame::Example::TestSimpleTableWithEnumT *AsTS() {
+ return type == AnyUniqueAliases_TS ?
+ reinterpret_cast<MyGame::Example::TestSimpleTableWithEnumT *>(value) : nullptr;
+ }
+ const MyGame::Example::TestSimpleTableWithEnumT *AsTS() const {
+ return type == AnyUniqueAliases_TS ?
+ reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnumT *>(value) : nullptr;
+ }
+ MyGame::Example2::MonsterT *AsM2() {
+ return type == AnyUniqueAliases_M2 ?
+ reinterpret_cast<MyGame::Example2::MonsterT *>(value) : nullptr;
+ }
+ const MyGame::Example2::MonsterT *AsM2() const {
+ return type == AnyUniqueAliases_M2 ?
+ reinterpret_cast<const MyGame::Example2::MonsterT *>(value) : nullptr;
+ }
+};
+
+
+inline bool operator==(const AnyUniqueAliasesUnion &lhs, const AnyUniqueAliasesUnion &rhs) {
+ if (lhs.type != rhs.type) return false;
+ switch (lhs.type) {
+ case AnyUniqueAliases_NONE: {
+ return true;
+ }
+ case AnyUniqueAliases_M: {
+ return *(reinterpret_cast<const MyGame::Example::MonsterT *>(lhs.value)) ==
+ *(reinterpret_cast<const MyGame::Example::MonsterT *>(rhs.value));
+ }
+ case AnyUniqueAliases_TS: {
+ return *(reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnumT *>(lhs.value)) ==
+ *(reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnumT *>(rhs.value));
+ }
+ case AnyUniqueAliases_M2: {
+ return *(reinterpret_cast<const MyGame::Example2::MonsterT *>(lhs.value)) ==
+ *(reinterpret_cast<const MyGame::Example2::MonsterT *>(rhs.value));
+ }
+ default: {
+ return false;
+ }
+ }
+}
+
+inline bool operator!=(const AnyUniqueAliasesUnion &lhs, const AnyUniqueAliasesUnion &rhs) {
+ return !(lhs == rhs);
+}
+
+bool VerifyAnyUniqueAliases(flatbuffers::Verifier &verifier, const void *obj, AnyUniqueAliases type);
+bool VerifyAnyUniqueAliasesVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types);
+
+enum AnyAmbiguousAliases : uint8_t {
+ AnyAmbiguousAliases_NONE = 0,
+ AnyAmbiguousAliases_M1 = 1,
+ AnyAmbiguousAliases_M2 = 2,
+ AnyAmbiguousAliases_M3 = 3,
+ AnyAmbiguousAliases_MIN = AnyAmbiguousAliases_NONE,
+ AnyAmbiguousAliases_MAX = AnyAmbiguousAliases_M3
+};
+
+inline const AnyAmbiguousAliases (&EnumValuesAnyAmbiguousAliases())[4] {
+ static const AnyAmbiguousAliases values[] = {
+ AnyAmbiguousAliases_NONE,
+ AnyAmbiguousAliases_M1,
+ AnyAmbiguousAliases_M2,
+ AnyAmbiguousAliases_M3
+ };
+ return values;
+}
+
+inline const char * const *EnumNamesAnyAmbiguousAliases() {
+ static const char * const names[5] = {
+ "NONE",
+ "M1",
+ "M2",
+ "M3",
+ nullptr
+ };
+ return names;
+}
+
+inline const char *EnumNameAnyAmbiguousAliases(AnyAmbiguousAliases e) {
+ if (flatbuffers::IsOutRange(e, AnyAmbiguousAliases_NONE, AnyAmbiguousAliases_M3)) return "";
+ const size_t index = static_cast<size_t>(e);
+ return EnumNamesAnyAmbiguousAliases()[index];
+}
+
+struct AnyAmbiguousAliasesUnion {
+ AnyAmbiguousAliases type;
+ void *value;
+
+ AnyAmbiguousAliasesUnion() : type(AnyAmbiguousAliases_NONE), value(nullptr) {}
+ AnyAmbiguousAliasesUnion(AnyAmbiguousAliasesUnion&& u) FLATBUFFERS_NOEXCEPT :
+ type(AnyAmbiguousAliases_NONE), value(nullptr)
+ { std::swap(type, u.type); std::swap(value, u.value); }
+ AnyAmbiguousAliasesUnion(const AnyAmbiguousAliasesUnion &);
+ AnyAmbiguousAliasesUnion &operator=(const AnyAmbiguousAliasesUnion &u)
+ { AnyAmbiguousAliasesUnion t(u); std::swap(type, t.type); std::swap(value, t.value); return *this; }
+ AnyAmbiguousAliasesUnion &operator=(AnyAmbiguousAliasesUnion &&u) FLATBUFFERS_NOEXCEPT
+ { std::swap(type, u.type); std::swap(value, u.value); return *this; }
+ ~AnyAmbiguousAliasesUnion() { Reset(); }
+
+ void Reset();
+
+ static void *UnPack(const void *obj, AnyAmbiguousAliases type, const flatbuffers::resolver_function_t *resolver);
+ flatbuffers::Offset<void> Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const;
+
+ MyGame::Example::MonsterT *AsM1() {
+ return type == AnyAmbiguousAliases_M1 ?
+ reinterpret_cast<MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+ const MyGame::Example::MonsterT *AsM1() const {
+ return type == AnyAmbiguousAliases_M1 ?
+ reinterpret_cast<const MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+ MyGame::Example::MonsterT *AsM2() {
+ return type == AnyAmbiguousAliases_M2 ?
+ reinterpret_cast<MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+ const MyGame::Example::MonsterT *AsM2() const {
+ return type == AnyAmbiguousAliases_M2 ?
+ reinterpret_cast<const MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+ MyGame::Example::MonsterT *AsM3() {
+ return type == AnyAmbiguousAliases_M3 ?
+ reinterpret_cast<MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+ const MyGame::Example::MonsterT *AsM3() const {
+ return type == AnyAmbiguousAliases_M3 ?
+ reinterpret_cast<const MyGame::Example::MonsterT *>(value) : nullptr;
+ }
+};
+
+
+inline bool operator==(const AnyAmbiguousAliasesUnion &lhs, const AnyAmbiguousAliasesUnion &rhs) {
+ if (lhs.type != rhs.type) return false;
+ switch (lhs.type) {
+ case AnyAmbiguousAliases_NONE: {
+ return true;
+ }
+ case AnyAmbiguousAliases_M1: {
+ return *(reinterpret_cast<const MyGame::Example::MonsterT *>(lhs.value)) ==
+ *(reinterpret_cast<const MyGame::Example::MonsterT *>(rhs.value));
+ }
+ case AnyAmbiguousAliases_M2: {
+ return *(reinterpret_cast<const MyGame::Example::MonsterT *>(lhs.value)) ==
+ *(reinterpret_cast<const MyGame::Example::MonsterT *>(rhs.value));
+ }
+ case AnyAmbiguousAliases_M3: {
+ return *(reinterpret_cast<const MyGame::Example::MonsterT *>(lhs.value)) ==
+ *(reinterpret_cast<const MyGame::Example::MonsterT *>(rhs.value));
+ }
+ default: {
+ return false;
+ }
+ }
+}
+
+inline bool operator!=(const AnyAmbiguousAliasesUnion &lhs, const AnyAmbiguousAliasesUnion &rhs) {
+ return !(lhs == rhs);
+}
+
+bool VerifyAnyAmbiguousAliases(flatbuffers::Verifier &verifier, const void *obj, AnyAmbiguousAliases type);
+bool VerifyAnyAmbiguousAliasesVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types);
+
+FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(2) Test FLATBUFFERS_FINAL_CLASS {
+ private:
+ int16_t a_;
+ int8_t b_;
+ int8_t padding0__;
+
+ public:
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return TestTypeTable();
+ }
+ Test()
+ : a_(0),
+ b_(0),
+ padding0__(0) {
+ (void)padding0__;
+ }
+ Test(int16_t _a, int8_t _b)
+ : a_(flatbuffers::EndianScalar(_a)),
+ b_(flatbuffers::EndianScalar(_b)),
+ padding0__(0) {
+ (void)padding0__;
+ }
+ int16_t a() const {
+ return flatbuffers::EndianScalar(a_);
+ }
+ void mutate_a(int16_t _a) {
+ flatbuffers::WriteScalar(&a_, _a);
+ }
+ int8_t b() const {
+ return flatbuffers::EndianScalar(b_);
+ }
+ void mutate_b(int8_t _b) {
+ flatbuffers::WriteScalar(&b_, _b);
+ }
+};
+FLATBUFFERS_STRUCT_END(Test, 4);
+
+inline bool operator==(const Test &lhs, const Test &rhs) {
+ return
+ (lhs.a() == rhs.a()) &&
+ (lhs.b() == rhs.b());
+}
+
+inline bool operator!=(const Test &lhs, const Test &rhs) {
+ return !(lhs == rhs);
+}
+
+
+FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) Vec3 FLATBUFFERS_FINAL_CLASS {
+ private:
+ float x_;
+ float y_;
+ float z_;
+ int32_t padding0__;
+ double test1_;
+ uint8_t test2_;
+ int8_t padding1__;
+ MyGame::Example::Test test3_;
+ int16_t padding2__;
+
+ public:
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return Vec3TypeTable();
+ }
+ Vec3()
+ : x_(0),
+ y_(0),
+ z_(0),
+ padding0__(0),
+ test1_(0),
+ test2_(0),
+ padding1__(0),
+ test3_(),
+ padding2__(0) {
+ (void)padding0__;
+ (void)padding1__;
+ (void)padding2__;
+ }
+ Vec3(float _x, float _y, float _z, double _test1, MyGame::Example::Color _test2, const MyGame::Example::Test &_test3)
+ : x_(flatbuffers::EndianScalar(_x)),
+ y_(flatbuffers::EndianScalar(_y)),
+ z_(flatbuffers::EndianScalar(_z)),
+ padding0__(0),
+ test1_(flatbuffers::EndianScalar(_test1)),
+ test2_(flatbuffers::EndianScalar(static_cast<uint8_t>(_test2))),
+ padding1__(0),
+ test3_(_test3),
+ padding2__(0) {
+ (void)padding0__;
+ (void)padding1__;
+ (void)padding2__;
+ }
+ float x() const {
+ return flatbuffers::EndianScalar(x_);
+ }
+ void mutate_x(float _x) {
+ flatbuffers::WriteScalar(&x_, _x);
+ }
+ float y() const {
+ return flatbuffers::EndianScalar(y_);
+ }
+ void mutate_y(float _y) {
+ flatbuffers::WriteScalar(&y_, _y);
+ }
+ float z() const {
+ return flatbuffers::EndianScalar(z_);
+ }
+ void mutate_z(float _z) {
+ flatbuffers::WriteScalar(&z_, _z);
+ }
+ double test1() const {
+ return flatbuffers::EndianScalar(test1_);
+ }
+ void mutate_test1(double _test1) {
+ flatbuffers::WriteScalar(&test1_, _test1);
+ }
+ MyGame::Example::Color test2() const {
+ return static_cast<MyGame::Example::Color>(flatbuffers::EndianScalar(test2_));
+ }
+ void mutate_test2(MyGame::Example::Color _test2) {
+ flatbuffers::WriteScalar(&test2_, static_cast<uint8_t>(_test2));
+ }
+ const MyGame::Example::Test &test3() const {
+ return test3_;
+ }
+ MyGame::Example::Test &mutable_test3() {
+ return test3_;
+ }
+};
+FLATBUFFERS_STRUCT_END(Vec3, 32);
+
+inline bool operator==(const Vec3 &lhs, const Vec3 &rhs) {
+ return
+ (lhs.x() == rhs.x()) &&
+ (lhs.y() == rhs.y()) &&
+ (lhs.z() == rhs.z()) &&
+ (lhs.test1() == rhs.test1()) &&
+ (lhs.test2() == rhs.test2()) &&
+ (lhs.test3() == rhs.test3());
+}
+
+inline bool operator!=(const Vec3 &lhs, const Vec3 &rhs) {
+ return !(lhs == rhs);
+}
+
+
+FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Ability FLATBUFFERS_FINAL_CLASS {
+ private:
+ uint32_t id_;
+ uint32_t distance_;
+
+ public:
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return AbilityTypeTable();
+ }
+ Ability()
+ : id_(0),
+ distance_(0) {
+ }
+ Ability(uint32_t _id, uint32_t _distance)
+ : id_(flatbuffers::EndianScalar(_id)),
+ distance_(flatbuffers::EndianScalar(_distance)) {
+ }
+ uint32_t id() const {
+ return flatbuffers::EndianScalar(id_);
+ }
+ void mutate_id(uint32_t _id) {
+ flatbuffers::WriteScalar(&id_, _id);
+ }
+ bool KeyCompareLessThan(const Ability *o) const {
+ return id() < o->id();
+ }
+ int KeyCompareWithValue(uint32_t _id) const {
+ return static_cast<int>(id() > _id) - static_cast<int>(id() < _id);
+ }
+ uint32_t distance() const {
+ return flatbuffers::EndianScalar(distance_);
+ }
+ void mutate_distance(uint32_t _distance) {
+ flatbuffers::WriteScalar(&distance_, _distance);
+ }
+};
+FLATBUFFERS_STRUCT_END(Ability, 8);
+
+inline bool operator==(const Ability &lhs, const Ability &rhs) {
+ return
+ (lhs.id() == rhs.id()) &&
+ (lhs.distance() == rhs.distance());
+}
+
+inline bool operator!=(const Ability &lhs, const Ability &rhs) {
+ return !(lhs == rhs);
+}
+
+
+FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) StructOfStructs FLATBUFFERS_FINAL_CLASS {
+ private:
+ MyGame::Example::Ability a_;
+ MyGame::Example::Test b_;
+ MyGame::Example::Ability c_;
+
+ public:
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return StructOfStructsTypeTable();
+ }
+ StructOfStructs()
+ : a_(),
+ b_(),
+ c_() {
+ }
+ StructOfStructs(const MyGame::Example::Ability &_a, const MyGame::Example::Test &_b, const MyGame::Example::Ability &_c)
+ : a_(_a),
+ b_(_b),
+ c_(_c) {
+ }
+ const MyGame::Example::Ability &a() const {
+ return a_;
+ }
+ MyGame::Example::Ability &mutable_a() {
+ return a_;
+ }
+ const MyGame::Example::Test &b() const {
+ return b_;
+ }
+ MyGame::Example::Test &mutable_b() {
+ return b_;
+ }
+ const MyGame::Example::Ability &c() const {
+ return c_;
+ }
+ MyGame::Example::Ability &mutable_c() {
+ return c_;
+ }
+};
+FLATBUFFERS_STRUCT_END(StructOfStructs, 20);
+
+inline bool operator==(const StructOfStructs &lhs, const StructOfStructs &rhs) {
+ return
+ (lhs.a() == rhs.a()) &&
+ (lhs.b() == rhs.b()) &&
+ (lhs.c() == rhs.c());
+}
+
+inline bool operator!=(const StructOfStructs &lhs, const StructOfStructs &rhs) {
+ return !(lhs == rhs);
+}
+
+
+FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) StructOfStructsOfStructs FLATBUFFERS_FINAL_CLASS {
+ private:
+ MyGame::Example::StructOfStructs a_;
+
+ public:
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return StructOfStructsOfStructsTypeTable();
+ }
+ StructOfStructsOfStructs()
+ : a_() {
+ }
+ StructOfStructsOfStructs(const MyGame::Example::StructOfStructs &_a)
+ : a_(_a) {
+ }
+ const MyGame::Example::StructOfStructs &a() const {
+ return a_;
+ }
+ MyGame::Example::StructOfStructs &mutable_a() {
+ return a_;
+ }
+};
+FLATBUFFERS_STRUCT_END(StructOfStructsOfStructs, 20);
+
+inline bool operator==(const StructOfStructsOfStructs &lhs, const StructOfStructsOfStructs &rhs) {
+ return
+ (lhs.a() == rhs.a());
+}
+
+inline bool operator!=(const StructOfStructsOfStructs &lhs, const StructOfStructsOfStructs &rhs) {
+ return !(lhs == rhs);
+}
+
+
+} // namespace Example
+
+struct InParentNamespaceT : public flatbuffers::NativeTable {
+ typedef InParentNamespace TableType;
+};
+
+struct InParentNamespace FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
+ typedef InParentNamespaceT NativeTableType;
+ typedef InParentNamespaceBuilder Builder;
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return InParentNamespaceTypeTable();
+ }
+ bool Verify(flatbuffers::Verifier &verifier) const {
+ return VerifyTableStart(verifier) &&
+ verifier.EndTable();
+ }
+ InParentNamespaceT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ void UnPackTo(InParentNamespaceT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ static flatbuffers::Offset<InParentNamespace> Pack(flatbuffers::FlatBufferBuilder &_fbb, const InParentNamespaceT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+};
+
+struct InParentNamespaceBuilder {
+ typedef InParentNamespace Table;
+ flatbuffers::FlatBufferBuilder &fbb_;
+ flatbuffers::uoffset_t start_;
+ explicit InParentNamespaceBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
+ flatbuffers::Offset<InParentNamespace> Finish() {
+ const auto end = fbb_.EndTable(start_);
+ auto o = flatbuffers::Offset<InParentNamespace>(end);
+ return o;
+ }
+};
+
+inline flatbuffers::Offset<InParentNamespace> CreateInParentNamespace(
+ flatbuffers::FlatBufferBuilder &_fbb) {
+ InParentNamespaceBuilder builder_(_fbb);
+ return builder_.Finish();
+}
+
+flatbuffers::Offset<InParentNamespace> CreateInParentNamespace(flatbuffers::FlatBufferBuilder &_fbb, const InParentNamespaceT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+
+namespace Example2 {
+
+struct MonsterT : public flatbuffers::NativeTable {
+ typedef Monster TableType;
+};
+
+struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
+ typedef MonsterT NativeTableType;
+ typedef MonsterBuilder Builder;
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return MonsterTypeTable();
+ }
+ bool Verify(flatbuffers::Verifier &verifier) const {
+ return VerifyTableStart(verifier) &&
+ verifier.EndTable();
+ }
+ MonsterT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ void UnPackTo(MonsterT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ static flatbuffers::Offset<Monster> Pack(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+};
+
+struct MonsterBuilder {
+ typedef Monster Table;
+ flatbuffers::FlatBufferBuilder &fbb_;
+ flatbuffers::uoffset_t start_;
+ explicit MonsterBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
+ flatbuffers::Offset<Monster> Finish() {
+ const auto end = fbb_.EndTable(start_);
+ auto o = flatbuffers::Offset<Monster>(end);
+ return o;
+ }
+};
+
+inline flatbuffers::Offset<Monster> CreateMonster(
+ flatbuffers::FlatBufferBuilder &_fbb) {
+ MonsterBuilder builder_(_fbb);
+ return builder_.Finish();
+}
+
+flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+
+} // namespace Example2
+
+namespace Example {
+
+struct TestSimpleTableWithEnumT : public flatbuffers::NativeTable {
+ typedef TestSimpleTableWithEnum TableType;
+ MyGame::Example::Color color = MyGame::Example::Color_Green;
+};
+
+struct TestSimpleTableWithEnum FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
+ typedef TestSimpleTableWithEnumT NativeTableType;
+ typedef TestSimpleTableWithEnumBuilder Builder;
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return TestSimpleTableWithEnumTypeTable();
+ }
+ enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
+ VT_COLOR = 4
+ };
+ MyGame::Example::Color color() const {
+ return static_cast<MyGame::Example::Color>(GetField<uint8_t>(VT_COLOR, 2));
+ }
+ bool mutate_color(MyGame::Example::Color _color = static_cast<MyGame::Example::Color>(2)) {
+ return SetField<uint8_t>(VT_COLOR, static_cast<uint8_t>(_color), 2);
+ }
+ bool Verify(flatbuffers::Verifier &verifier) const {
+ return VerifyTableStart(verifier) &&
+ VerifyField<uint8_t>(verifier, VT_COLOR, 1) &&
+ verifier.EndTable();
+ }
+ TestSimpleTableWithEnumT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ void UnPackTo(TestSimpleTableWithEnumT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ static flatbuffers::Offset<TestSimpleTableWithEnum> Pack(flatbuffers::FlatBufferBuilder &_fbb, const TestSimpleTableWithEnumT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+};
+
+struct TestSimpleTableWithEnumBuilder {
+ typedef TestSimpleTableWithEnum Table;
+ flatbuffers::FlatBufferBuilder &fbb_;
+ flatbuffers::uoffset_t start_;
+ void add_color(MyGame::Example::Color color) {
+ fbb_.AddElement<uint8_t>(TestSimpleTableWithEnum::VT_COLOR, static_cast<uint8_t>(color), 2);
+ }
+ explicit TestSimpleTableWithEnumBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
+ flatbuffers::Offset<TestSimpleTableWithEnum> Finish() {
+ const auto end = fbb_.EndTable(start_);
+ auto o = flatbuffers::Offset<TestSimpleTableWithEnum>(end);
+ return o;
+ }
+};
+
+inline flatbuffers::Offset<TestSimpleTableWithEnum> CreateTestSimpleTableWithEnum(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ MyGame::Example::Color color = MyGame::Example::Color_Green) {
+ TestSimpleTableWithEnumBuilder builder_(_fbb);
+ builder_.add_color(color);
+ return builder_.Finish();
+}
+
+flatbuffers::Offset<TestSimpleTableWithEnum> CreateTestSimpleTableWithEnum(flatbuffers::FlatBufferBuilder &_fbb, const TestSimpleTableWithEnumT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+
+struct StatT : public flatbuffers::NativeTable {
+ typedef Stat TableType;
+ std::string id{};
+ int64_t val = 0;
+ uint16_t count = 0;
+};
+
+struct Stat FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
+ typedef StatT NativeTableType;
+ typedef StatBuilder Builder;
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return StatTypeTable();
+ }
+ enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
+ VT_ID = 4,
+ VT_VAL = 6,
+ VT_COUNT = 8
+ };
+ const flatbuffers::String *id() const {
+ return GetPointer<const flatbuffers::String *>(VT_ID);
+ }
+ flatbuffers::String *mutable_id() {
+ return GetPointer<flatbuffers::String *>(VT_ID);
+ }
+ int64_t val() const {
+ return GetField<int64_t>(VT_VAL, 0);
+ }
+ bool mutate_val(int64_t _val = 0) {
+ return SetField<int64_t>(VT_VAL, _val, 0);
+ }
+ uint16_t count() const {
+ return GetField<uint16_t>(VT_COUNT, 0);
+ }
+ bool mutate_count(uint16_t _count = 0) {
+ return SetField<uint16_t>(VT_COUNT, _count, 0);
+ }
+ bool KeyCompareLessThan(const Stat *o) const {
+ return count() < o->count();
+ }
+ int KeyCompareWithValue(uint16_t _count) const {
+ return static_cast<int>(count() > _count) - static_cast<int>(count() < _count);
+ }
+ bool Verify(flatbuffers::Verifier &verifier) const {
+ return VerifyTableStart(verifier) &&
+ VerifyOffset(verifier, VT_ID) &&
+ verifier.VerifyString(id()) &&
+ VerifyField<int64_t>(verifier, VT_VAL, 8) &&
+ VerifyField<uint16_t>(verifier, VT_COUNT, 2) &&
+ verifier.EndTable();
+ }
+ StatT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ void UnPackTo(StatT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ static flatbuffers::Offset<Stat> Pack(flatbuffers::FlatBufferBuilder &_fbb, const StatT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+};
+
+struct StatBuilder {
+ typedef Stat Table;
+ flatbuffers::FlatBufferBuilder &fbb_;
+ flatbuffers::uoffset_t start_;
+ void add_id(flatbuffers::Offset<flatbuffers::String> id) {
+ fbb_.AddOffset(Stat::VT_ID, id);
+ }
+ void add_val(int64_t val) {
+ fbb_.AddElement<int64_t>(Stat::VT_VAL, val, 0);
+ }
+ void add_count(uint16_t count) {
+ fbb_.AddElement<uint16_t>(Stat::VT_COUNT, count, 0);
+ }
+ explicit StatBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
+ flatbuffers::Offset<Stat> Finish() {
+ const auto end = fbb_.EndTable(start_);
+ auto o = flatbuffers::Offset<Stat>(end);
+ return o;
+ }
+};
+
+inline flatbuffers::Offset<Stat> CreateStat(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ flatbuffers::Offset<flatbuffers::String> id = 0,
+ int64_t val = 0,
+ uint16_t count = 0) {
+ StatBuilder builder_(_fbb);
+ builder_.add_val(val);
+ builder_.add_id(id);
+ builder_.add_count(count);
+ return builder_.Finish();
+}
+
+inline flatbuffers::Offset<Stat> CreateStatDirect(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ const char *id = nullptr,
+ int64_t val = 0,
+ uint16_t count = 0) {
+ auto id__ = id ? _fbb.CreateString(id) : 0;
+ return MyGame::Example::CreateStat(
+ _fbb,
+ id__,
+ val,
+ count);
+}
+
+flatbuffers::Offset<Stat> CreateStat(flatbuffers::FlatBufferBuilder &_fbb, const StatT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+
+struct ReferrableT : public flatbuffers::NativeTable {
+ typedef Referrable TableType;
+ uint64_t id = 0;
+};
+
+struct Referrable FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
+ typedef ReferrableT NativeTableType;
+ typedef ReferrableBuilder Builder;
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return ReferrableTypeTable();
+ }
+ enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
+ VT_ID = 4
+ };
+ uint64_t id() const {
+ return GetField<uint64_t>(VT_ID, 0);
+ }
+ bool mutate_id(uint64_t _id = 0) {
+ return SetField<uint64_t>(VT_ID, _id, 0);
+ }
+ bool KeyCompareLessThan(const Referrable *o) const {
+ return id() < o->id();
+ }
+ int KeyCompareWithValue(uint64_t _id) const {
+ return static_cast<int>(id() > _id) - static_cast<int>(id() < _id);
+ }
+ bool Verify(flatbuffers::Verifier &verifier) const {
+ return VerifyTableStart(verifier) &&
+ VerifyField<uint64_t>(verifier, VT_ID, 8) &&
+ verifier.EndTable();
+ }
+ ReferrableT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ void UnPackTo(ReferrableT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ static flatbuffers::Offset<Referrable> Pack(flatbuffers::FlatBufferBuilder &_fbb, const ReferrableT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+};
+
+struct ReferrableBuilder {
+ typedef Referrable Table;
+ flatbuffers::FlatBufferBuilder &fbb_;
+ flatbuffers::uoffset_t start_;
+ void add_id(uint64_t id) {
+ fbb_.AddElement<uint64_t>(Referrable::VT_ID, id, 0);
+ }
+ explicit ReferrableBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
+ flatbuffers::Offset<Referrable> Finish() {
+ const auto end = fbb_.EndTable(start_);
+ auto o = flatbuffers::Offset<Referrable>(end);
+ return o;
+ }
+};
+
+inline flatbuffers::Offset<Referrable> CreateReferrable(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ uint64_t id = 0) {
+ ReferrableBuilder builder_(_fbb);
+ builder_.add_id(id);
+ return builder_.Finish();
+}
+
+flatbuffers::Offset<Referrable> CreateReferrable(flatbuffers::FlatBufferBuilder &_fbb, const ReferrableT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+
+struct MonsterT : public flatbuffers::NativeTable {
+ typedef Monster TableType;
+ flatbuffers::unique_ptr<MyGame::Example::Vec3> pos{};
+ int16_t mana = 150;
+ int16_t hp = 100;
+ std::string name{};
+ std::vector<uint8_t> inventory{};
+ MyGame::Example::Color color = MyGame::Example::Color_Blue;
+ MyGame::Example::AnyUnion test{};
+ std::vector<MyGame::Example::Test> test4{};
+ std::vector<std::string> testarrayofstring{};
+ std::vector<flatbuffers::unique_ptr<MyGame::Example::MonsterT>> testarrayoftables{};
+ flatbuffers::unique_ptr<MyGame::Example::MonsterT> enemy{};
+ std::vector<uint8_t> testnestedflatbuffer{};
+ flatbuffers::unique_ptr<MyGame::Example::StatT> testempty{};
+ bool testbool = false;
+ int32_t testhashs32_fnv1 = 0;
+ uint32_t testhashu32_fnv1 = 0;
+ int64_t testhashs64_fnv1 = 0;
+ uint64_t testhashu64_fnv1 = 0;
+ int32_t testhashs32_fnv1a = 0;
+ Stat *testhashu32_fnv1a = nullptr;
+ int64_t testhashs64_fnv1a = 0;
+ uint64_t testhashu64_fnv1a = 0;
+ std::vector<bool> testarrayofbools{};
+ float testf = 3.14159f;
+ float testf2 = 3.0f;
+ float testf3 = 0.0f;
+ std::vector<std::string> testarrayofstring2{};
+ std::vector<MyGame::Example::Ability> testarrayofsortedstruct{};
+ std::vector<uint8_t> flex{};
+ std::vector<MyGame::Example::Test> test5{};
+ std::vector<int64_t> vector_of_longs{};
+ std::vector<double> vector_of_doubles{};
+ flatbuffers::unique_ptr<MyGame::InParentNamespaceT> parent_namespace_test{};
+ std::vector<flatbuffers::unique_ptr<MyGame::Example::ReferrableT>> vector_of_referrables{};
+ ReferrableT *single_weak_reference = nullptr;
+ std::vector<ReferrableT *> vector_of_weak_references{};
+ std::vector<flatbuffers::unique_ptr<MyGame::Example::ReferrableT>> vector_of_strong_referrables{};
+ ReferrableT *co_owning_reference = nullptr;
+ std::vector<flatbuffers::unique_ptr<ReferrableT>> vector_of_co_owning_references{};
+ ReferrableT *non_owning_reference = nullptr;
+ std::vector<ReferrableT *> vector_of_non_owning_references{};
+ MyGame::Example::AnyUniqueAliasesUnion any_unique{};
+ MyGame::Example::AnyAmbiguousAliasesUnion any_ambiguous{};
+ std::vector<MyGame::Example::Color> vector_of_enums{};
+ MyGame::Example::Race signed_enum = MyGame::Example::Race_None;
+ std::vector<uint8_t> testrequirednestedflatbuffer{};
+ std::vector<flatbuffers::unique_ptr<MyGame::Example::StatT>> scalar_key_sorted_tables{};
+ MyGame::Example::Test native_inline{};
+ MyGame::Example::LongEnum long_enum_non_enum_default = static_cast<MyGame::Example::LongEnum>(0);
+ MyGame::Example::LongEnum long_enum_normal_default = MyGame::Example::LongEnum_LongOne;
+ MonsterT() = default;
+ MonsterT(const MonsterT &o);
+ MonsterT(MonsterT&&) FLATBUFFERS_NOEXCEPT = default;
+ MonsterT &operator=(MonsterT o) FLATBUFFERS_NOEXCEPT;
+};
+
+/// an example documentation comment: "monster object"
+struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
+ typedef MonsterT NativeTableType;
+ typedef MonsterBuilder Builder;
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return MonsterTypeTable();
+ }
+ enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
+ VT_POS = 4,
+ VT_MANA = 6,
+ VT_HP = 8,
+ VT_NAME = 10,
+ VT_INVENTORY = 14,
+ VT_COLOR = 16,
+ VT_TEST_TYPE = 18,
+ VT_TEST = 20,
+ VT_TEST4 = 22,
+ VT_TESTARRAYOFSTRING = 24,
+ VT_TESTARRAYOFTABLES = 26,
+ VT_ENEMY = 28,
+ VT_TESTNESTEDFLATBUFFER = 30,
+ VT_TESTEMPTY = 32,
+ VT_TESTBOOL = 34,
+ VT_TESTHASHS32_FNV1 = 36,
+ VT_TESTHASHU32_FNV1 = 38,
+ VT_TESTHASHS64_FNV1 = 40,
+ VT_TESTHASHU64_FNV1 = 42,
+ VT_TESTHASHS32_FNV1A = 44,
+ VT_TESTHASHU32_FNV1A = 46,
+ VT_TESTHASHS64_FNV1A = 48,
+ VT_TESTHASHU64_FNV1A = 50,
+ VT_TESTARRAYOFBOOLS = 52,
+ VT_TESTF = 54,
+ VT_TESTF2 = 56,
+ VT_TESTF3 = 58,
+ VT_TESTARRAYOFSTRING2 = 60,
+ VT_TESTARRAYOFSORTEDSTRUCT = 62,
+ VT_FLEX = 64,
+ VT_TEST5 = 66,
+ VT_VECTOR_OF_LONGS = 68,
+ VT_VECTOR_OF_DOUBLES = 70,
+ VT_PARENT_NAMESPACE_TEST = 72,
+ VT_VECTOR_OF_REFERRABLES = 74,
+ VT_SINGLE_WEAK_REFERENCE = 76,
+ VT_VECTOR_OF_WEAK_REFERENCES = 78,
+ VT_VECTOR_OF_STRONG_REFERRABLES = 80,
+ VT_CO_OWNING_REFERENCE = 82,
+ VT_VECTOR_OF_CO_OWNING_REFERENCES = 84,
+ VT_NON_OWNING_REFERENCE = 86,
+ VT_VECTOR_OF_NON_OWNING_REFERENCES = 88,
+ VT_ANY_UNIQUE_TYPE = 90,
+ VT_ANY_UNIQUE = 92,
+ VT_ANY_AMBIGUOUS_TYPE = 94,
+ VT_ANY_AMBIGUOUS = 96,
+ VT_VECTOR_OF_ENUMS = 98,
+ VT_SIGNED_ENUM = 100,
+ VT_TESTREQUIREDNESTEDFLATBUFFER = 102,
+ VT_SCALAR_KEY_SORTED_TABLES = 104,
+ VT_NATIVE_INLINE = 106,
+ VT_LONG_ENUM_NON_ENUM_DEFAULT = 108,
+ VT_LONG_ENUM_NORMAL_DEFAULT = 110
+ };
+ const MyGame::Example::Vec3 *pos() const {
+ return GetStruct<const MyGame::Example::Vec3 *>(VT_POS);
+ }
+ MyGame::Example::Vec3 *mutable_pos() {
+ return GetStruct<MyGame::Example::Vec3 *>(VT_POS);
+ }
+ int16_t mana() const {
+ return GetField<int16_t>(VT_MANA, 150);
+ }
+ bool mutate_mana(int16_t _mana = 150) {
+ return SetField<int16_t>(VT_MANA, _mana, 150);
+ }
+ int16_t hp() const {
+ return GetField<int16_t>(VT_HP, 100);
+ }
+ bool mutate_hp(int16_t _hp = 100) {
+ return SetField<int16_t>(VT_HP, _hp, 100);
+ }
+ const flatbuffers::String *name() const {
+ return GetPointer<const flatbuffers::String *>(VT_NAME);
+ }
+ flatbuffers::String *mutable_name() {
+ return GetPointer<flatbuffers::String *>(VT_NAME);
+ }
+ bool KeyCompareLessThan(const Monster *o) const {
+ return *name() < *o->name();
+ }
+ int KeyCompareWithValue(const char *_name) const {
+ return strcmp(name()->c_str(), _name);
+ }
+ const flatbuffers::Vector<uint8_t> *inventory() const {
+ return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_INVENTORY);
+ }
+ flatbuffers::Vector<uint8_t> *mutable_inventory() {
+ return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_INVENTORY);
+ }
+ MyGame::Example::Color color() const {
+ return static_cast<MyGame::Example::Color>(GetField<uint8_t>(VT_COLOR, 8));
+ }
+ bool mutate_color(MyGame::Example::Color _color = static_cast<MyGame::Example::Color>(8)) {
+ return SetField<uint8_t>(VT_COLOR, static_cast<uint8_t>(_color), 8);
+ }
+ MyGame::Example::Any test_type() const {
+ return static_cast<MyGame::Example::Any>(GetField<uint8_t>(VT_TEST_TYPE, 0));
+ }
+ const void *test() const {
+ return GetPointer<const void *>(VT_TEST);
+ }
+ template<typename T> const T *test_as() const;
+ const MyGame::Example::Monster *test_as_Monster() const {
+ return test_type() == MyGame::Example::Any_Monster ? static_cast<const MyGame::Example::Monster *>(test()) : nullptr;
+ }
+ const MyGame::Example::TestSimpleTableWithEnum *test_as_TestSimpleTableWithEnum() const {
+ return test_type() == MyGame::Example::Any_TestSimpleTableWithEnum ? static_cast<const MyGame::Example::TestSimpleTableWithEnum *>(test()) : nullptr;
+ }
+ const MyGame::Example2::Monster *test_as_MyGame_Example2_Monster() const {
+ return test_type() == MyGame::Example::Any_MyGame_Example2_Monster ? static_cast<const MyGame::Example2::Monster *>(test()) : nullptr;
+ }
+ void *mutable_test() {
+ return GetPointer<void *>(VT_TEST);
+ }
+ const flatbuffers::Vector<const MyGame::Example::Test *> *test4() const {
+ return GetPointer<const flatbuffers::Vector<const MyGame::Example::Test *> *>(VT_TEST4);
+ }
+ flatbuffers::Vector<const MyGame::Example::Test *> *mutable_test4() {
+ return GetPointer<flatbuffers::Vector<const MyGame::Example::Test *> *>(VT_TEST4);
+ }
+ const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *testarrayofstring() const {
+ return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_TESTARRAYOFSTRING);
+ }
+ flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *mutable_testarrayofstring() {
+ return GetPointer<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_TESTARRAYOFSTRING);
+ }
+ /// an example documentation comment: this will end up in the generated code
+ /// multiline too
+ const flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Monster>> *testarrayoftables() const {
+ return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Monster>> *>(VT_TESTARRAYOFTABLES);
+ }
+ flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Monster>> *mutable_testarrayoftables() {
+ return GetPointer<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Monster>> *>(VT_TESTARRAYOFTABLES);
+ }
+ const MyGame::Example::Monster *enemy() const {
+ return GetPointer<const MyGame::Example::Monster *>(VT_ENEMY);
+ }
+ MyGame::Example::Monster *mutable_enemy() {
+ return GetPointer<MyGame::Example::Monster *>(VT_ENEMY);
+ }
+ const flatbuffers::Vector<uint8_t> *testnestedflatbuffer() const {
+ return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_TESTNESTEDFLATBUFFER);
+ }
+ flatbuffers::Vector<uint8_t> *mutable_testnestedflatbuffer() {
+ return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_TESTNESTEDFLATBUFFER);
+ }
+ const MyGame::Example::Monster *testnestedflatbuffer_nested_root() const {
+ return flatbuffers::GetRoot<MyGame::Example::Monster>(testnestedflatbuffer()->Data());
+ }
+ const MyGame::Example::Stat *testempty() const {
+ return GetPointer<const MyGame::Example::Stat *>(VT_TESTEMPTY);
+ }
+ MyGame::Example::Stat *mutable_testempty() {
+ return GetPointer<MyGame::Example::Stat *>(VT_TESTEMPTY);
+ }
+ bool testbool() const {
+ return GetField<uint8_t>(VT_TESTBOOL, 0) != 0;
+ }
+ bool mutate_testbool(bool _testbool = 0) {
+ return SetField<uint8_t>(VT_TESTBOOL, static_cast<uint8_t>(_testbool), 0);
+ }
+ int32_t testhashs32_fnv1() const {
+ return GetField<int32_t>(VT_TESTHASHS32_FNV1, 0);
+ }
+ bool mutate_testhashs32_fnv1(int32_t _testhashs32_fnv1 = 0) {
+ return SetField<int32_t>(VT_TESTHASHS32_FNV1, _testhashs32_fnv1, 0);
+ }
+ uint32_t testhashu32_fnv1() const {
+ return GetField<uint32_t>(VT_TESTHASHU32_FNV1, 0);
+ }
+ bool mutate_testhashu32_fnv1(uint32_t _testhashu32_fnv1 = 0) {
+ return SetField<uint32_t>(VT_TESTHASHU32_FNV1, _testhashu32_fnv1, 0);
+ }
+ int64_t testhashs64_fnv1() const {
+ return GetField<int64_t>(VT_TESTHASHS64_FNV1, 0);
+ }
+ bool mutate_testhashs64_fnv1(int64_t _testhashs64_fnv1 = 0) {
+ return SetField<int64_t>(VT_TESTHASHS64_FNV1, _testhashs64_fnv1, 0);
+ }
+ uint64_t testhashu64_fnv1() const {
+ return GetField<uint64_t>(VT_TESTHASHU64_FNV1, 0);
+ }
+ bool mutate_testhashu64_fnv1(uint64_t _testhashu64_fnv1 = 0) {
+ return SetField<uint64_t>(VT_TESTHASHU64_FNV1, _testhashu64_fnv1, 0);
+ }
+ int32_t testhashs32_fnv1a() const {
+ return GetField<int32_t>(VT_TESTHASHS32_FNV1A, 0);
+ }
+ bool mutate_testhashs32_fnv1a(int32_t _testhashs32_fnv1a = 0) {
+ return SetField<int32_t>(VT_TESTHASHS32_FNV1A, _testhashs32_fnv1a, 0);
+ }
+ uint32_t testhashu32_fnv1a() const {
+ return GetField<uint32_t>(VT_TESTHASHU32_FNV1A, 0);
+ }
+ bool mutate_testhashu32_fnv1a(uint32_t _testhashu32_fnv1a = 0) {
+ return SetField<uint32_t>(VT_TESTHASHU32_FNV1A, _testhashu32_fnv1a, 0);
+ }
+ int64_t testhashs64_fnv1a() const {
+ return GetField<int64_t>(VT_TESTHASHS64_FNV1A, 0);
+ }
+ bool mutate_testhashs64_fnv1a(int64_t _testhashs64_fnv1a = 0) {
+ return SetField<int64_t>(VT_TESTHASHS64_FNV1A, _testhashs64_fnv1a, 0);
+ }
+ uint64_t testhashu64_fnv1a() const {
+ return GetField<uint64_t>(VT_TESTHASHU64_FNV1A, 0);
+ }
+ bool mutate_testhashu64_fnv1a(uint64_t _testhashu64_fnv1a = 0) {
+ return SetField<uint64_t>(VT_TESTHASHU64_FNV1A, _testhashu64_fnv1a, 0);
+ }
+ const flatbuffers::Vector<uint8_t> *testarrayofbools() const {
+ return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_TESTARRAYOFBOOLS);
+ }
+ flatbuffers::Vector<uint8_t> *mutable_testarrayofbools() {
+ return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_TESTARRAYOFBOOLS);
+ }
+ float testf() const {
+ return GetField<float>(VT_TESTF, 3.14159f);
+ }
+ bool mutate_testf(float _testf = 3.14159f) {
+ return SetField<float>(VT_TESTF, _testf, 3.14159f);
+ }
+ float testf2() const {
+ return GetField<float>(VT_TESTF2, 3.0f);
+ }
+ bool mutate_testf2(float _testf2 = 3.0f) {
+ return SetField<float>(VT_TESTF2, _testf2, 3.0f);
+ }
+ float testf3() const {
+ return GetField<float>(VT_TESTF3, 0.0f);
+ }
+ bool mutate_testf3(float _testf3 = 0.0f) {
+ return SetField<float>(VT_TESTF3, _testf3, 0.0f);
+ }
+ const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *testarrayofstring2() const {
+ return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_TESTARRAYOFSTRING2);
+ }
+ flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *mutable_testarrayofstring2() {
+ return GetPointer<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_TESTARRAYOFSTRING2);
+ }
+ const flatbuffers::Vector<const MyGame::Example::Ability *> *testarrayofsortedstruct() const {
+ return GetPointer<const flatbuffers::Vector<const MyGame::Example::Ability *> *>(VT_TESTARRAYOFSORTEDSTRUCT);
+ }
+ flatbuffers::Vector<const MyGame::Example::Ability *> *mutable_testarrayofsortedstruct() {
+ return GetPointer<flatbuffers::Vector<const MyGame::Example::Ability *> *>(VT_TESTARRAYOFSORTEDSTRUCT);
+ }
+ const flatbuffers::Vector<uint8_t> *flex() const {
+ return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_FLEX);
+ }
+ flatbuffers::Vector<uint8_t> *mutable_flex() {
+ return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_FLEX);
+ }
+ flexbuffers::Reference flex_flexbuffer_root() const {
+ return flexbuffers::GetRoot(flex()->Data(), flex()->size());
+ }
+ const flatbuffers::Vector<const MyGame::Example::Test *> *test5() const {
+ return GetPointer<const flatbuffers::Vector<const MyGame::Example::Test *> *>(VT_TEST5);
+ }
+ flatbuffers::Vector<const MyGame::Example::Test *> *mutable_test5() {
+ return GetPointer<flatbuffers::Vector<const MyGame::Example::Test *> *>(VT_TEST5);
+ }
+ const flatbuffers::Vector<int64_t> *vector_of_longs() const {
+ return GetPointer<const flatbuffers::Vector<int64_t> *>(VT_VECTOR_OF_LONGS);
+ }
+ flatbuffers::Vector<int64_t> *mutable_vector_of_longs() {
+ return GetPointer<flatbuffers::Vector<int64_t> *>(VT_VECTOR_OF_LONGS);
+ }
+ const flatbuffers::Vector<double> *vector_of_doubles() const {
+ return GetPointer<const flatbuffers::Vector<double> *>(VT_VECTOR_OF_DOUBLES);
+ }
+ flatbuffers::Vector<double> *mutable_vector_of_doubles() {
+ return GetPointer<flatbuffers::Vector<double> *>(VT_VECTOR_OF_DOUBLES);
+ }
+ const MyGame::InParentNamespace *parent_namespace_test() const {
+ return GetPointer<const MyGame::InParentNamespace *>(VT_PARENT_NAMESPACE_TEST);
+ }
+ MyGame::InParentNamespace *mutable_parent_namespace_test() {
+ return GetPointer<MyGame::InParentNamespace *>(VT_PARENT_NAMESPACE_TEST);
+ }
+ const flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>> *vector_of_referrables() const {
+ return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>> *>(VT_VECTOR_OF_REFERRABLES);
+ }
+ flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>> *mutable_vector_of_referrables() {
+ return GetPointer<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>> *>(VT_VECTOR_OF_REFERRABLES);
+ }
+ uint64_t single_weak_reference() const {
+ return GetField<uint64_t>(VT_SINGLE_WEAK_REFERENCE, 0);
+ }
+ bool mutate_single_weak_reference(uint64_t _single_weak_reference = 0) {
+ return SetField<uint64_t>(VT_SINGLE_WEAK_REFERENCE, _single_weak_reference, 0);
+ }
+ const flatbuffers::Vector<uint64_t> *vector_of_weak_references() const {
+ return GetPointer<const flatbuffers::Vector<uint64_t> *>(VT_VECTOR_OF_WEAK_REFERENCES);
+ }
+ flatbuffers::Vector<uint64_t> *mutable_vector_of_weak_references() {
+ return GetPointer<flatbuffers::Vector<uint64_t> *>(VT_VECTOR_OF_WEAK_REFERENCES);
+ }
+ const flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>> *vector_of_strong_referrables() const {
+ return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>> *>(VT_VECTOR_OF_STRONG_REFERRABLES);
+ }
+ flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>> *mutable_vector_of_strong_referrables() {
+ return GetPointer<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>> *>(VT_VECTOR_OF_STRONG_REFERRABLES);
+ }
+ uint64_t co_owning_reference() const {
+ return GetField<uint64_t>(VT_CO_OWNING_REFERENCE, 0);
+ }
+ bool mutate_co_owning_reference(uint64_t _co_owning_reference = 0) {
+ return SetField<uint64_t>(VT_CO_OWNING_REFERENCE, _co_owning_reference, 0);
+ }
+ const flatbuffers::Vector<uint64_t> *vector_of_co_owning_references() const {
+ return GetPointer<const flatbuffers::Vector<uint64_t> *>(VT_VECTOR_OF_CO_OWNING_REFERENCES);
+ }
+ flatbuffers::Vector<uint64_t> *mutable_vector_of_co_owning_references() {
+ return GetPointer<flatbuffers::Vector<uint64_t> *>(VT_VECTOR_OF_CO_OWNING_REFERENCES);
+ }
+ uint64_t non_owning_reference() const {
+ return GetField<uint64_t>(VT_NON_OWNING_REFERENCE, 0);
+ }
+ bool mutate_non_owning_reference(uint64_t _non_owning_reference = 0) {
+ return SetField<uint64_t>(VT_NON_OWNING_REFERENCE, _non_owning_reference, 0);
+ }
+ const flatbuffers::Vector<uint64_t> *vector_of_non_owning_references() const {
+ return GetPointer<const flatbuffers::Vector<uint64_t> *>(VT_VECTOR_OF_NON_OWNING_REFERENCES);
+ }
+ flatbuffers::Vector<uint64_t> *mutable_vector_of_non_owning_references() {
+ return GetPointer<flatbuffers::Vector<uint64_t> *>(VT_VECTOR_OF_NON_OWNING_REFERENCES);
+ }
+ MyGame::Example::AnyUniqueAliases any_unique_type() const {
+ return static_cast<MyGame::Example::AnyUniqueAliases>(GetField<uint8_t>(VT_ANY_UNIQUE_TYPE, 0));
+ }
+ const void *any_unique() const {
+ return GetPointer<const void *>(VT_ANY_UNIQUE);
+ }
+ template<typename T> const T *any_unique_as() const;
+ const MyGame::Example::Monster *any_unique_as_M() const {
+ return any_unique_type() == MyGame::Example::AnyUniqueAliases_M ? static_cast<const MyGame::Example::Monster *>(any_unique()) : nullptr;
+ }
+ const MyGame::Example::TestSimpleTableWithEnum *any_unique_as_TS() const {
+ return any_unique_type() == MyGame::Example::AnyUniqueAliases_TS ? static_cast<const MyGame::Example::TestSimpleTableWithEnum *>(any_unique()) : nullptr;
+ }
+ const MyGame::Example2::Monster *any_unique_as_M2() const {
+ return any_unique_type() == MyGame::Example::AnyUniqueAliases_M2 ? static_cast<const MyGame::Example2::Monster *>(any_unique()) : nullptr;
+ }
+ void *mutable_any_unique() {
+ return GetPointer<void *>(VT_ANY_UNIQUE);
+ }
+ MyGame::Example::AnyAmbiguousAliases any_ambiguous_type() const {
+ return static_cast<MyGame::Example::AnyAmbiguousAliases>(GetField<uint8_t>(VT_ANY_AMBIGUOUS_TYPE, 0));
+ }
+ const void *any_ambiguous() const {
+ return GetPointer<const void *>(VT_ANY_AMBIGUOUS);
+ }
+ const MyGame::Example::Monster *any_ambiguous_as_M1() const {
+ return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M1 ? static_cast<const MyGame::Example::Monster *>(any_ambiguous()) : nullptr;
+ }
+ const MyGame::Example::Monster *any_ambiguous_as_M2() const {
+ return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M2 ? static_cast<const MyGame::Example::Monster *>(any_ambiguous()) : nullptr;
+ }
+ const MyGame::Example::Monster *any_ambiguous_as_M3() const {
+ return any_ambiguous_type() == MyGame::Example::AnyAmbiguousAliases_M3 ? static_cast<const MyGame::Example::Monster *>(any_ambiguous()) : nullptr;
+ }
+ void *mutable_any_ambiguous() {
+ return GetPointer<void *>(VT_ANY_AMBIGUOUS);
+ }
+ const flatbuffers::Vector<uint8_t> *vector_of_enums() const {
+ return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_VECTOR_OF_ENUMS);
+ }
+ flatbuffers::Vector<uint8_t> *mutable_vector_of_enums() {
+ return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_VECTOR_OF_ENUMS);
+ }
+ MyGame::Example::Race signed_enum() const {
+ return static_cast<MyGame::Example::Race>(GetField<int8_t>(VT_SIGNED_ENUM, -1));
+ }
+ bool mutate_signed_enum(MyGame::Example::Race _signed_enum = static_cast<MyGame::Example::Race>(-1)) {
+ return SetField<int8_t>(VT_SIGNED_ENUM, static_cast<int8_t>(_signed_enum), -1);
+ }
+ const flatbuffers::Vector<uint8_t> *testrequirednestedflatbuffer() const {
+ return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_TESTREQUIREDNESTEDFLATBUFFER);
+ }
+ flatbuffers::Vector<uint8_t> *mutable_testrequirednestedflatbuffer() {
+ return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_TESTREQUIREDNESTEDFLATBUFFER);
+ }
+ const MyGame::Example::Monster *testrequirednestedflatbuffer_nested_root() const {
+ return flatbuffers::GetRoot<MyGame::Example::Monster>(testrequirednestedflatbuffer()->Data());
+ }
+ const flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Stat>> *scalar_key_sorted_tables() const {
+ return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Stat>> *>(VT_SCALAR_KEY_SORTED_TABLES);
+ }
+ flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Stat>> *mutable_scalar_key_sorted_tables() {
+ return GetPointer<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Stat>> *>(VT_SCALAR_KEY_SORTED_TABLES);
+ }
+ const MyGame::Example::Test *native_inline() const {
+ return GetStruct<const MyGame::Example::Test *>(VT_NATIVE_INLINE);
+ }
+ MyGame::Example::Test *mutable_native_inline() {
+ return GetStruct<MyGame::Example::Test *>(VT_NATIVE_INLINE);
+ }
+ MyGame::Example::LongEnum long_enum_non_enum_default() const {
+ return static_cast<MyGame::Example::LongEnum>(GetField<uint64_t>(VT_LONG_ENUM_NON_ENUM_DEFAULT, 0));
+ }
+ bool mutate_long_enum_non_enum_default(MyGame::Example::LongEnum _long_enum_non_enum_default = static_cast<MyGame::Example::LongEnum>(0)) {
+ return SetField<uint64_t>(VT_LONG_ENUM_NON_ENUM_DEFAULT, static_cast<uint64_t>(_long_enum_non_enum_default), 0);
+ }
+ MyGame::Example::LongEnum long_enum_normal_default() const {
+ return static_cast<MyGame::Example::LongEnum>(GetField<uint64_t>(VT_LONG_ENUM_NORMAL_DEFAULT, 2ULL));
+ }
+ bool mutate_long_enum_normal_default(MyGame::Example::LongEnum _long_enum_normal_default = static_cast<MyGame::Example::LongEnum>(2ULL)) {
+ return SetField<uint64_t>(VT_LONG_ENUM_NORMAL_DEFAULT, static_cast<uint64_t>(_long_enum_normal_default), 2ULL);
+ }
+ bool Verify(flatbuffers::Verifier &verifier) const {
+ return VerifyTableStart(verifier) &&
+ VerifyField<MyGame::Example::Vec3>(verifier, VT_POS, 8) &&
+ VerifyField<int16_t>(verifier, VT_MANA, 2) &&
+ VerifyField<int16_t>(verifier, VT_HP, 2) &&
+ VerifyOffsetRequired(verifier, VT_NAME) &&
+ verifier.VerifyString(name()) &&
+ VerifyOffset(verifier, VT_INVENTORY) &&
+ verifier.VerifyVector(inventory()) &&
+ VerifyField<uint8_t>(verifier, VT_COLOR, 1) &&
+ VerifyField<uint8_t>(verifier, VT_TEST_TYPE, 1) &&
+ VerifyOffset(verifier, VT_TEST) &&
+ VerifyAny(verifier, test(), test_type()) &&
+ VerifyOffset(verifier, VT_TEST4) &&
+ verifier.VerifyVector(test4()) &&
+ VerifyOffset(verifier, VT_TESTARRAYOFSTRING) &&
+ verifier.VerifyVector(testarrayofstring()) &&
+ verifier.VerifyVectorOfStrings(testarrayofstring()) &&
+ VerifyOffset(verifier, VT_TESTARRAYOFTABLES) &&
+ verifier.VerifyVector(testarrayoftables()) &&
+ verifier.VerifyVectorOfTables(testarrayoftables()) &&
+ VerifyOffset(verifier, VT_ENEMY) &&
+ verifier.VerifyTable(enemy()) &&
+ VerifyOffset(verifier, VT_TESTNESTEDFLATBUFFER) &&
+ verifier.VerifyVector(testnestedflatbuffer()) &&
+ verifier.VerifyNestedFlatBuffer<MyGame::Example::Monster>(testnestedflatbuffer(), nullptr) &&
+ VerifyOffset(verifier, VT_TESTEMPTY) &&
+ verifier.VerifyTable(testempty()) &&
+ VerifyField<uint8_t>(verifier, VT_TESTBOOL, 1) &&
+ VerifyField<int32_t>(verifier, VT_TESTHASHS32_FNV1, 4) &&
+ VerifyField<uint32_t>(verifier, VT_TESTHASHU32_FNV1, 4) &&
+ VerifyField<int64_t>(verifier, VT_TESTHASHS64_FNV1, 8) &&
+ VerifyField<uint64_t>(verifier, VT_TESTHASHU64_FNV1, 8) &&
+ VerifyField<int32_t>(verifier, VT_TESTHASHS32_FNV1A, 4) &&
+ VerifyField<uint32_t>(verifier, VT_TESTHASHU32_FNV1A, 4) &&
+ VerifyField<int64_t>(verifier, VT_TESTHASHS64_FNV1A, 8) &&
+ VerifyField<uint64_t>(verifier, VT_TESTHASHU64_FNV1A, 8) &&
+ VerifyOffset(verifier, VT_TESTARRAYOFBOOLS) &&
+ verifier.VerifyVector(testarrayofbools()) &&
+ VerifyField<float>(verifier, VT_TESTF, 4) &&
+ VerifyField<float>(verifier, VT_TESTF2, 4) &&
+ VerifyField<float>(verifier, VT_TESTF3, 4) &&
+ VerifyOffset(verifier, VT_TESTARRAYOFSTRING2) &&
+ verifier.VerifyVector(testarrayofstring2()) &&
+ verifier.VerifyVectorOfStrings(testarrayofstring2()) &&
+ VerifyOffset(verifier, VT_TESTARRAYOFSORTEDSTRUCT) &&
+ verifier.VerifyVector(testarrayofsortedstruct()) &&
+ VerifyOffset(verifier, VT_FLEX) &&
+ verifier.VerifyVector(flex()) &&
+ flexbuffers::VerifyNestedFlexBuffer(flex(), verifier) &&
+ VerifyOffset(verifier, VT_TEST5) &&
+ verifier.VerifyVector(test5()) &&
+ VerifyOffset(verifier, VT_VECTOR_OF_LONGS) &&
+ verifier.VerifyVector(vector_of_longs()) &&
+ VerifyOffset(verifier, VT_VECTOR_OF_DOUBLES) &&
+ verifier.VerifyVector(vector_of_doubles()) &&
+ VerifyOffset(verifier, VT_PARENT_NAMESPACE_TEST) &&
+ verifier.VerifyTable(parent_namespace_test()) &&
+ VerifyOffset(verifier, VT_VECTOR_OF_REFERRABLES) &&
+ verifier.VerifyVector(vector_of_referrables()) &&
+ verifier.VerifyVectorOfTables(vector_of_referrables()) &&
+ VerifyField<uint64_t>(verifier, VT_SINGLE_WEAK_REFERENCE, 8) &&
+ VerifyOffset(verifier, VT_VECTOR_OF_WEAK_REFERENCES) &&
+ verifier.VerifyVector(vector_of_weak_references()) &&
+ VerifyOffset(verifier, VT_VECTOR_OF_STRONG_REFERRABLES) &&
+ verifier.VerifyVector(vector_of_strong_referrables()) &&
+ verifier.VerifyVectorOfTables(vector_of_strong_referrables()) &&
+ VerifyField<uint64_t>(verifier, VT_CO_OWNING_REFERENCE, 8) &&
+ VerifyOffset(verifier, VT_VECTOR_OF_CO_OWNING_REFERENCES) &&
+ verifier.VerifyVector(vector_of_co_owning_references()) &&
+ VerifyField<uint64_t>(verifier, VT_NON_OWNING_REFERENCE, 8) &&
+ VerifyOffset(verifier, VT_VECTOR_OF_NON_OWNING_REFERENCES) &&
+ verifier.VerifyVector(vector_of_non_owning_references()) &&
+ VerifyField<uint8_t>(verifier, VT_ANY_UNIQUE_TYPE, 1) &&
+ VerifyOffset(verifier, VT_ANY_UNIQUE) &&
+ VerifyAnyUniqueAliases(verifier, any_unique(), any_unique_type()) &&
+ VerifyField<uint8_t>(verifier, VT_ANY_AMBIGUOUS_TYPE, 1) &&
+ VerifyOffset(verifier, VT_ANY_AMBIGUOUS) &&
+ VerifyAnyAmbiguousAliases(verifier, any_ambiguous(), any_ambiguous_type()) &&
+ VerifyOffset(verifier, VT_VECTOR_OF_ENUMS) &&
+ verifier.VerifyVector(vector_of_enums()) &&
+ VerifyField<int8_t>(verifier, VT_SIGNED_ENUM, 1) &&
+ VerifyOffset(verifier, VT_TESTREQUIREDNESTEDFLATBUFFER) &&
+ verifier.VerifyVector(testrequirednestedflatbuffer()) &&
+ verifier.VerifyNestedFlatBuffer<MyGame::Example::Monster>(testrequirednestedflatbuffer(), nullptr) &&
+ VerifyOffset(verifier, VT_SCALAR_KEY_SORTED_TABLES) &&
+ verifier.VerifyVector(scalar_key_sorted_tables()) &&
+ verifier.VerifyVectorOfTables(scalar_key_sorted_tables()) &&
+ VerifyField<MyGame::Example::Test>(verifier, VT_NATIVE_INLINE, 2) &&
+ VerifyField<uint64_t>(verifier, VT_LONG_ENUM_NON_ENUM_DEFAULT, 8) &&
+ VerifyField<uint64_t>(verifier, VT_LONG_ENUM_NORMAL_DEFAULT, 8) &&
+ verifier.EndTable();
+ }
+ MonsterT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ void UnPackTo(MonsterT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ static flatbuffers::Offset<Monster> Pack(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+};
+
+template<> inline const MyGame::Example::Monster *Monster::test_as<MyGame::Example::Monster>() const {
+ return test_as_Monster();
+}
+
+template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::test_as<MyGame::Example::TestSimpleTableWithEnum>() const {
+ return test_as_TestSimpleTableWithEnum();
+}
+
+template<> inline const MyGame::Example2::Monster *Monster::test_as<MyGame::Example2::Monster>() const {
+ return test_as_MyGame_Example2_Monster();
+}
+
+template<> inline const MyGame::Example::Monster *Monster::any_unique_as<MyGame::Example::Monster>() const {
+ return any_unique_as_M();
+}
+
+template<> inline const MyGame::Example::TestSimpleTableWithEnum *Monster::any_unique_as<MyGame::Example::TestSimpleTableWithEnum>() const {
+ return any_unique_as_TS();
+}
+
+template<> inline const MyGame::Example2::Monster *Monster::any_unique_as<MyGame::Example2::Monster>() const {
+ return any_unique_as_M2();
+}
+
+struct MonsterBuilder {
+ typedef Monster Table;
+ flatbuffers::FlatBufferBuilder &fbb_;
+ flatbuffers::uoffset_t start_;
+ void add_pos(const MyGame::Example::Vec3 *pos) {
+ fbb_.AddStruct(Monster::VT_POS, pos);
+ }
+ void add_mana(int16_t mana) {
+ fbb_.AddElement<int16_t>(Monster::VT_MANA, mana, 150);
+ }
+ void add_hp(int16_t hp) {
+ fbb_.AddElement<int16_t>(Monster::VT_HP, hp, 100);
+ }
+ void add_name(flatbuffers::Offset<flatbuffers::String> name) {
+ fbb_.AddOffset(Monster::VT_NAME, name);
+ }
+ void add_inventory(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> inventory) {
+ fbb_.AddOffset(Monster::VT_INVENTORY, inventory);
+ }
+ void add_color(MyGame::Example::Color color) {
+ fbb_.AddElement<uint8_t>(Monster::VT_COLOR, static_cast<uint8_t>(color), 8);
+ }
+ void add_test_type(MyGame::Example::Any test_type) {
+ fbb_.AddElement<uint8_t>(Monster::VT_TEST_TYPE, static_cast<uint8_t>(test_type), 0);
+ }
+ void add_test(flatbuffers::Offset<void> test) {
+ fbb_.AddOffset(Monster::VT_TEST, test);
+ }
+ void add_test4(flatbuffers::Offset<flatbuffers::Vector<const MyGame::Example::Test *>> test4) {
+ fbb_.AddOffset(Monster::VT_TEST4, test4);
+ }
+ void add_testarrayofstring(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> testarrayofstring) {
+ fbb_.AddOffset(Monster::VT_TESTARRAYOFSTRING, testarrayofstring);
+ }
+ void add_testarrayoftables(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Monster>>> testarrayoftables) {
+ fbb_.AddOffset(Monster::VT_TESTARRAYOFTABLES, testarrayoftables);
+ }
+ void add_enemy(flatbuffers::Offset<MyGame::Example::Monster> enemy) {
+ fbb_.AddOffset(Monster::VT_ENEMY, enemy);
+ }
+ void add_testnestedflatbuffer(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> testnestedflatbuffer) {
+ fbb_.AddOffset(Monster::VT_TESTNESTEDFLATBUFFER, testnestedflatbuffer);
+ }
+ void add_testempty(flatbuffers::Offset<MyGame::Example::Stat> testempty) {
+ fbb_.AddOffset(Monster::VT_TESTEMPTY, testempty);
+ }
+ void add_testbool(bool testbool) {
+ fbb_.AddElement<uint8_t>(Monster::VT_TESTBOOL, static_cast<uint8_t>(testbool), 0);
+ }
+ void add_testhashs32_fnv1(int32_t testhashs32_fnv1) {
+ fbb_.AddElement<int32_t>(Monster::VT_TESTHASHS32_FNV1, testhashs32_fnv1, 0);
+ }
+ void add_testhashu32_fnv1(uint32_t testhashu32_fnv1) {
+ fbb_.AddElement<uint32_t>(Monster::VT_TESTHASHU32_FNV1, testhashu32_fnv1, 0);
+ }
+ void add_testhashs64_fnv1(int64_t testhashs64_fnv1) {
+ fbb_.AddElement<int64_t>(Monster::VT_TESTHASHS64_FNV1, testhashs64_fnv1, 0);
+ }
+ void add_testhashu64_fnv1(uint64_t testhashu64_fnv1) {
+ fbb_.AddElement<uint64_t>(Monster::VT_TESTHASHU64_FNV1, testhashu64_fnv1, 0);
+ }
+ void add_testhashs32_fnv1a(int32_t testhashs32_fnv1a) {
+ fbb_.AddElement<int32_t>(Monster::VT_TESTHASHS32_FNV1A, testhashs32_fnv1a, 0);
+ }
+ void add_testhashu32_fnv1a(uint32_t testhashu32_fnv1a) {
+ fbb_.AddElement<uint32_t>(Monster::VT_TESTHASHU32_FNV1A, testhashu32_fnv1a, 0);
+ }
+ void add_testhashs64_fnv1a(int64_t testhashs64_fnv1a) {
+ fbb_.AddElement<int64_t>(Monster::VT_TESTHASHS64_FNV1A, testhashs64_fnv1a, 0);
+ }
+ void add_testhashu64_fnv1a(uint64_t testhashu64_fnv1a) {
+ fbb_.AddElement<uint64_t>(Monster::VT_TESTHASHU64_FNV1A, testhashu64_fnv1a, 0);
+ }
+ void add_testarrayofbools(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> testarrayofbools) {
+ fbb_.AddOffset(Monster::VT_TESTARRAYOFBOOLS, testarrayofbools);
+ }
+ void add_testf(float testf) {
+ fbb_.AddElement<float>(Monster::VT_TESTF, testf, 3.14159f);
+ }
+ void add_testf2(float testf2) {
+ fbb_.AddElement<float>(Monster::VT_TESTF2, testf2, 3.0f);
+ }
+ void add_testf3(float testf3) {
+ fbb_.AddElement<float>(Monster::VT_TESTF3, testf3, 0.0f);
+ }
+ void add_testarrayofstring2(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> testarrayofstring2) {
+ fbb_.AddOffset(Monster::VT_TESTARRAYOFSTRING2, testarrayofstring2);
+ }
+ void add_testarrayofsortedstruct(flatbuffers::Offset<flatbuffers::Vector<const MyGame::Example::Ability *>> testarrayofsortedstruct) {
+ fbb_.AddOffset(Monster::VT_TESTARRAYOFSORTEDSTRUCT, testarrayofsortedstruct);
+ }
+ void add_flex(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> flex) {
+ fbb_.AddOffset(Monster::VT_FLEX, flex);
+ }
+ void add_test5(flatbuffers::Offset<flatbuffers::Vector<const MyGame::Example::Test *>> test5) {
+ fbb_.AddOffset(Monster::VT_TEST5, test5);
+ }
+ void add_vector_of_longs(flatbuffers::Offset<flatbuffers::Vector<int64_t>> vector_of_longs) {
+ fbb_.AddOffset(Monster::VT_VECTOR_OF_LONGS, vector_of_longs);
+ }
+ void add_vector_of_doubles(flatbuffers::Offset<flatbuffers::Vector<double>> vector_of_doubles) {
+ fbb_.AddOffset(Monster::VT_VECTOR_OF_DOUBLES, vector_of_doubles);
+ }
+ void add_parent_namespace_test(flatbuffers::Offset<MyGame::InParentNamespace> parent_namespace_test) {
+ fbb_.AddOffset(Monster::VT_PARENT_NAMESPACE_TEST, parent_namespace_test);
+ }
+ void add_vector_of_referrables(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>>> vector_of_referrables) {
+ fbb_.AddOffset(Monster::VT_VECTOR_OF_REFERRABLES, vector_of_referrables);
+ }
+ void add_single_weak_reference(uint64_t single_weak_reference) {
+ fbb_.AddElement<uint64_t>(Monster::VT_SINGLE_WEAK_REFERENCE, single_weak_reference, 0);
+ }
+ void add_vector_of_weak_references(flatbuffers::Offset<flatbuffers::Vector<uint64_t>> vector_of_weak_references) {
+ fbb_.AddOffset(Monster::VT_VECTOR_OF_WEAK_REFERENCES, vector_of_weak_references);
+ }
+ void add_vector_of_strong_referrables(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>>> vector_of_strong_referrables) {
+ fbb_.AddOffset(Monster::VT_VECTOR_OF_STRONG_REFERRABLES, vector_of_strong_referrables);
+ }
+ void add_co_owning_reference(uint64_t co_owning_reference) {
+ fbb_.AddElement<uint64_t>(Monster::VT_CO_OWNING_REFERENCE, co_owning_reference, 0);
+ }
+ void add_vector_of_co_owning_references(flatbuffers::Offset<flatbuffers::Vector<uint64_t>> vector_of_co_owning_references) {
+ fbb_.AddOffset(Monster::VT_VECTOR_OF_CO_OWNING_REFERENCES, vector_of_co_owning_references);
+ }
+ void add_non_owning_reference(uint64_t non_owning_reference) {
+ fbb_.AddElement<uint64_t>(Monster::VT_NON_OWNING_REFERENCE, non_owning_reference, 0);
+ }
+ void add_vector_of_non_owning_references(flatbuffers::Offset<flatbuffers::Vector<uint64_t>> vector_of_non_owning_references) {
+ fbb_.AddOffset(Monster::VT_VECTOR_OF_NON_OWNING_REFERENCES, vector_of_non_owning_references);
+ }
+ void add_any_unique_type(MyGame::Example::AnyUniqueAliases any_unique_type) {
+ fbb_.AddElement<uint8_t>(Monster::VT_ANY_UNIQUE_TYPE, static_cast<uint8_t>(any_unique_type), 0);
+ }
+ void add_any_unique(flatbuffers::Offset<void> any_unique) {
+ fbb_.AddOffset(Monster::VT_ANY_UNIQUE, any_unique);
+ }
+ void add_any_ambiguous_type(MyGame::Example::AnyAmbiguousAliases any_ambiguous_type) {
+ fbb_.AddElement<uint8_t>(Monster::VT_ANY_AMBIGUOUS_TYPE, static_cast<uint8_t>(any_ambiguous_type), 0);
+ }
+ void add_any_ambiguous(flatbuffers::Offset<void> any_ambiguous) {
+ fbb_.AddOffset(Monster::VT_ANY_AMBIGUOUS, any_ambiguous);
+ }
+ void add_vector_of_enums(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> vector_of_enums) {
+ fbb_.AddOffset(Monster::VT_VECTOR_OF_ENUMS, vector_of_enums);
+ }
+ void add_signed_enum(MyGame::Example::Race signed_enum) {
+ fbb_.AddElement<int8_t>(Monster::VT_SIGNED_ENUM, static_cast<int8_t>(signed_enum), -1);
+ }
+ void add_testrequirednestedflatbuffer(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> testrequirednestedflatbuffer) {
+ fbb_.AddOffset(Monster::VT_TESTREQUIREDNESTEDFLATBUFFER, testrequirednestedflatbuffer);
+ }
+ void add_scalar_key_sorted_tables(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Stat>>> scalar_key_sorted_tables) {
+ fbb_.AddOffset(Monster::VT_SCALAR_KEY_SORTED_TABLES, scalar_key_sorted_tables);
+ }
+ void add_native_inline(const MyGame::Example::Test *native_inline) {
+ fbb_.AddStruct(Monster::VT_NATIVE_INLINE, native_inline);
+ }
+ void add_long_enum_non_enum_default(MyGame::Example::LongEnum long_enum_non_enum_default) {
+ fbb_.AddElement<uint64_t>(Monster::VT_LONG_ENUM_NON_ENUM_DEFAULT, static_cast<uint64_t>(long_enum_non_enum_default), 0);
+ }
+ void add_long_enum_normal_default(MyGame::Example::LongEnum long_enum_normal_default) {
+ fbb_.AddElement<uint64_t>(Monster::VT_LONG_ENUM_NORMAL_DEFAULT, static_cast<uint64_t>(long_enum_normal_default), 2ULL);
+ }
+ explicit MonsterBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
+ flatbuffers::Offset<Monster> Finish() {
+ const auto end = fbb_.EndTable(start_);
+ auto o = flatbuffers::Offset<Monster>(end);
+ fbb_.Required(o, Monster::VT_NAME);
+ return o;
+ }
+};
+
+inline flatbuffers::Offset<Monster> CreateMonster(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ const MyGame::Example::Vec3 *pos = nullptr,
+ int16_t mana = 150,
+ int16_t hp = 100,
+ flatbuffers::Offset<flatbuffers::String> name = 0,
+ flatbuffers::Offset<flatbuffers::Vector<uint8_t>> inventory = 0,
+ MyGame::Example::Color color = MyGame::Example::Color_Blue,
+ MyGame::Example::Any test_type = MyGame::Example::Any_NONE,
+ flatbuffers::Offset<void> test = 0,
+ flatbuffers::Offset<flatbuffers::Vector<const MyGame::Example::Test *>> test4 = 0,
+ flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> testarrayofstring = 0,
+ flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Monster>>> testarrayoftables = 0,
+ flatbuffers::Offset<MyGame::Example::Monster> enemy = 0,
+ flatbuffers::Offset<flatbuffers::Vector<uint8_t>> testnestedflatbuffer = 0,
+ flatbuffers::Offset<MyGame::Example::Stat> testempty = 0,
+ bool testbool = false,
+ int32_t testhashs32_fnv1 = 0,
+ uint32_t testhashu32_fnv1 = 0,
+ int64_t testhashs64_fnv1 = 0,
+ uint64_t testhashu64_fnv1 = 0,
+ int32_t testhashs32_fnv1a = 0,
+ uint32_t testhashu32_fnv1a = 0,
+ int64_t testhashs64_fnv1a = 0,
+ uint64_t testhashu64_fnv1a = 0,
+ flatbuffers::Offset<flatbuffers::Vector<uint8_t>> testarrayofbools = 0,
+ float testf = 3.14159f,
+ float testf2 = 3.0f,
+ float testf3 = 0.0f,
+ flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> testarrayofstring2 = 0,
+ flatbuffers::Offset<flatbuffers::Vector<const MyGame::Example::Ability *>> testarrayofsortedstruct = 0,
+ flatbuffers::Offset<flatbuffers::Vector<uint8_t>> flex = 0,
+ flatbuffers::Offset<flatbuffers::Vector<const MyGame::Example::Test *>> test5 = 0,
+ flatbuffers::Offset<flatbuffers::Vector<int64_t>> vector_of_longs = 0,
+ flatbuffers::Offset<flatbuffers::Vector<double>> vector_of_doubles = 0,
+ flatbuffers::Offset<MyGame::InParentNamespace> parent_namespace_test = 0,
+ flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>>> vector_of_referrables = 0,
+ uint64_t single_weak_reference = 0,
+ flatbuffers::Offset<flatbuffers::Vector<uint64_t>> vector_of_weak_references = 0,
+ flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Referrable>>> vector_of_strong_referrables = 0,
+ uint64_t co_owning_reference = 0,
+ flatbuffers::Offset<flatbuffers::Vector<uint64_t>> vector_of_co_owning_references = 0,
+ uint64_t non_owning_reference = 0,
+ flatbuffers::Offset<flatbuffers::Vector<uint64_t>> vector_of_non_owning_references = 0,
+ MyGame::Example::AnyUniqueAliases any_unique_type = MyGame::Example::AnyUniqueAliases_NONE,
+ flatbuffers::Offset<void> any_unique = 0,
+ MyGame::Example::AnyAmbiguousAliases any_ambiguous_type = MyGame::Example::AnyAmbiguousAliases_NONE,
+ flatbuffers::Offset<void> any_ambiguous = 0,
+ flatbuffers::Offset<flatbuffers::Vector<uint8_t>> vector_of_enums = 0,
+ MyGame::Example::Race signed_enum = MyGame::Example::Race_None,
+ flatbuffers::Offset<flatbuffers::Vector<uint8_t>> testrequirednestedflatbuffer = 0,
+ flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Example::Stat>>> scalar_key_sorted_tables = 0,
+ const MyGame::Example::Test *native_inline = nullptr,
+ MyGame::Example::LongEnum long_enum_non_enum_default = static_cast<MyGame::Example::LongEnum>(0),
+ MyGame::Example::LongEnum long_enum_normal_default = MyGame::Example::LongEnum_LongOne) {
+ MonsterBuilder builder_(_fbb);
+ builder_.add_long_enum_normal_default(long_enum_normal_default);
+ builder_.add_long_enum_non_enum_default(long_enum_non_enum_default);
+ builder_.add_non_owning_reference(non_owning_reference);
+ builder_.add_co_owning_reference(co_owning_reference);
+ builder_.add_single_weak_reference(single_weak_reference);
+ builder_.add_testhashu64_fnv1a(testhashu64_fnv1a);
+ builder_.add_testhashs64_fnv1a(testhashs64_fnv1a);
+ builder_.add_testhashu64_fnv1(testhashu64_fnv1);
+ builder_.add_testhashs64_fnv1(testhashs64_fnv1);
+ builder_.add_native_inline(native_inline);
+ builder_.add_scalar_key_sorted_tables(scalar_key_sorted_tables);
+ builder_.add_testrequirednestedflatbuffer(testrequirednestedflatbuffer);
+ builder_.add_vector_of_enums(vector_of_enums);
+ builder_.add_any_ambiguous(any_ambiguous);
+ builder_.add_any_unique(any_unique);
+ builder_.add_vector_of_non_owning_references(vector_of_non_owning_references);
+ builder_.add_vector_of_co_owning_references(vector_of_co_owning_references);
+ builder_.add_vector_of_strong_referrables(vector_of_strong_referrables);
+ builder_.add_vector_of_weak_references(vector_of_weak_references);
+ builder_.add_vector_of_referrables(vector_of_referrables);
+ builder_.add_parent_namespace_test(parent_namespace_test);
+ builder_.add_vector_of_doubles(vector_of_doubles);
+ builder_.add_vector_of_longs(vector_of_longs);
+ builder_.add_test5(test5);
+ builder_.add_flex(flex);
+ builder_.add_testarrayofsortedstruct(testarrayofsortedstruct);
+ builder_.add_testarrayofstring2(testarrayofstring2);
+ builder_.add_testf3(testf3);
+ builder_.add_testf2(testf2);
+ builder_.add_testf(testf);
+ builder_.add_testarrayofbools(testarrayofbools);
+ builder_.add_testhashu32_fnv1a(testhashu32_fnv1a);
+ builder_.add_testhashs32_fnv1a(testhashs32_fnv1a);
+ builder_.add_testhashu32_fnv1(testhashu32_fnv1);
+ builder_.add_testhashs32_fnv1(testhashs32_fnv1);
+ builder_.add_testempty(testempty);
+ builder_.add_testnestedflatbuffer(testnestedflatbuffer);
+ builder_.add_enemy(enemy);
+ builder_.add_testarrayoftables(testarrayoftables);
+ builder_.add_testarrayofstring(testarrayofstring);
+ builder_.add_test4(test4);
+ builder_.add_test(test);
+ builder_.add_inventory(inventory);
+ builder_.add_name(name);
+ builder_.add_pos(pos);
+ builder_.add_hp(hp);
+ builder_.add_mana(mana);
+ builder_.add_signed_enum(signed_enum);
+ builder_.add_any_ambiguous_type(any_ambiguous_type);
+ builder_.add_any_unique_type(any_unique_type);
+ builder_.add_testbool(testbool);
+ builder_.add_test_type(test_type);
+ builder_.add_color(color);
+ return builder_.Finish();
+}
+
+inline flatbuffers::Offset<Monster> CreateMonsterDirect(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ const MyGame::Example::Vec3 *pos = nullptr,
+ int16_t mana = 150,
+ int16_t hp = 100,
+ const char *name = nullptr,
+ const std::vector<uint8_t> *inventory = nullptr,
+ MyGame::Example::Color color = MyGame::Example::Color_Blue,
+ MyGame::Example::Any test_type = MyGame::Example::Any_NONE,
+ flatbuffers::Offset<void> test = 0,
+ const std::vector<MyGame::Example::Test> *test4 = nullptr,
+ const std::vector<flatbuffers::Offset<flatbuffers::String>> *testarrayofstring = nullptr,
+ std::vector<flatbuffers::Offset<MyGame::Example::Monster>> *testarrayoftables = nullptr,
+ flatbuffers::Offset<MyGame::Example::Monster> enemy = 0,
+ const std::vector<uint8_t> *testnestedflatbuffer = nullptr,
+ flatbuffers::Offset<MyGame::Example::Stat> testempty = 0,
+ bool testbool = false,
+ int32_t testhashs32_fnv1 = 0,
+ uint32_t testhashu32_fnv1 = 0,
+ int64_t testhashs64_fnv1 = 0,
+ uint64_t testhashu64_fnv1 = 0,
+ int32_t testhashs32_fnv1a = 0,
+ uint32_t testhashu32_fnv1a = 0,
+ int64_t testhashs64_fnv1a = 0,
+ uint64_t testhashu64_fnv1a = 0,
+ const std::vector<uint8_t> *testarrayofbools = nullptr,
+ float testf = 3.14159f,
+ float testf2 = 3.0f,
+ float testf3 = 0.0f,
+ const std::vector<flatbuffers::Offset<flatbuffers::String>> *testarrayofstring2 = nullptr,
+ std::vector<MyGame::Example::Ability> *testarrayofsortedstruct = nullptr,
+ const std::vector<uint8_t> *flex = nullptr,
+ const std::vector<MyGame::Example::Test> *test5 = nullptr,
+ const std::vector<int64_t> *vector_of_longs = nullptr,
+ const std::vector<double> *vector_of_doubles = nullptr,
+ flatbuffers::Offset<MyGame::InParentNamespace> parent_namespace_test = 0,
+ std::vector<flatbuffers::Offset<MyGame::Example::Referrable>> *vector_of_referrables = nullptr,
+ uint64_t single_weak_reference = 0,
+ const std::vector<uint64_t> *vector_of_weak_references = nullptr,
+ std::vector<flatbuffers::Offset<MyGame::Example::Referrable>> *vector_of_strong_referrables = nullptr,
+ uint64_t co_owning_reference = 0,
+ const std::vector<uint64_t> *vector_of_co_owning_references = nullptr,
+ uint64_t non_owning_reference = 0,
+ const std::vector<uint64_t> *vector_of_non_owning_references = nullptr,
+ MyGame::Example::AnyUniqueAliases any_unique_type = MyGame::Example::AnyUniqueAliases_NONE,
+ flatbuffers::Offset<void> any_unique = 0,
+ MyGame::Example::AnyAmbiguousAliases any_ambiguous_type = MyGame::Example::AnyAmbiguousAliases_NONE,
+ flatbuffers::Offset<void> any_ambiguous = 0,
+ const std::vector<uint8_t> *vector_of_enums = nullptr,
+ MyGame::Example::Race signed_enum = MyGame::Example::Race_None,
+ const std::vector<uint8_t> *testrequirednestedflatbuffer = nullptr,
+ std::vector<flatbuffers::Offset<MyGame::Example::Stat>> *scalar_key_sorted_tables = nullptr,
+ const MyGame::Example::Test *native_inline = nullptr,
+ MyGame::Example::LongEnum long_enum_non_enum_default = static_cast<MyGame::Example::LongEnum>(0),
+ MyGame::Example::LongEnum long_enum_normal_default = MyGame::Example::LongEnum_LongOne) {
+ auto name__ = name ? _fbb.CreateString(name) : 0;
+ auto inventory__ = inventory ? _fbb.CreateVector<uint8_t>(*inventory) : 0;
+ auto test4__ = test4 ? _fbb.CreateVectorOfStructs<MyGame::Example::Test>(*test4) : 0;
+ auto testarrayofstring__ = testarrayofstring ? _fbb.CreateVector<flatbuffers::Offset<flatbuffers::String>>(*testarrayofstring) : 0;
+ auto testarrayoftables__ = testarrayoftables ? _fbb.CreateVectorOfSortedTables<MyGame::Example::Monster>(testarrayoftables) : 0;
+ auto testnestedflatbuffer__ = testnestedflatbuffer ? _fbb.CreateVector<uint8_t>(*testnestedflatbuffer) : 0;
+ auto testarrayofbools__ = testarrayofbools ? _fbb.CreateVector<uint8_t>(*testarrayofbools) : 0;
+ auto testarrayofstring2__ = testarrayofstring2 ? _fbb.CreateVector<flatbuffers::Offset<flatbuffers::String>>(*testarrayofstring2) : 0;
+ auto testarrayofsortedstruct__ = testarrayofsortedstruct ? _fbb.CreateVectorOfSortedStructs<MyGame::Example::Ability>(testarrayofsortedstruct) : 0;
+ auto flex__ = flex ? _fbb.CreateVector<uint8_t>(*flex) : 0;
+ auto test5__ = test5 ? _fbb.CreateVectorOfStructs<MyGame::Example::Test>(*test5) : 0;
+ auto vector_of_longs__ = vector_of_longs ? _fbb.CreateVector<int64_t>(*vector_of_longs) : 0;
+ auto vector_of_doubles__ = vector_of_doubles ? _fbb.CreateVector<double>(*vector_of_doubles) : 0;
+ auto vector_of_referrables__ = vector_of_referrables ? _fbb.CreateVectorOfSortedTables<MyGame::Example::Referrable>(vector_of_referrables) : 0;
+ auto vector_of_weak_references__ = vector_of_weak_references ? _fbb.CreateVector<uint64_t>(*vector_of_weak_references) : 0;
+ auto vector_of_strong_referrables__ = vector_of_strong_referrables ? _fbb.CreateVectorOfSortedTables<MyGame::Example::Referrable>(vector_of_strong_referrables) : 0;
+ auto vector_of_co_owning_references__ = vector_of_co_owning_references ? _fbb.CreateVector<uint64_t>(*vector_of_co_owning_references) : 0;
+ auto vector_of_non_owning_references__ = vector_of_non_owning_references ? _fbb.CreateVector<uint64_t>(*vector_of_non_owning_references) : 0;
+ auto vector_of_enums__ = vector_of_enums ? _fbb.CreateVector<uint8_t>(*vector_of_enums) : 0;
+ auto testrequirednestedflatbuffer__ = testrequirednestedflatbuffer ? _fbb.CreateVector<uint8_t>(*testrequirednestedflatbuffer) : 0;
+ auto scalar_key_sorted_tables__ = scalar_key_sorted_tables ? _fbb.CreateVectorOfSortedTables<MyGame::Example::Stat>(scalar_key_sorted_tables) : 0;
+ return MyGame::Example::CreateMonster(
+ _fbb,
+ pos,
+ mana,
+ hp,
+ name__,
+ inventory__,
+ color,
+ test_type,
+ test,
+ test4__,
+ testarrayofstring__,
+ testarrayoftables__,
+ enemy,
+ testnestedflatbuffer__,
+ testempty,
+ testbool,
+ testhashs32_fnv1,
+ testhashu32_fnv1,
+ testhashs64_fnv1,
+ testhashu64_fnv1,
+ testhashs32_fnv1a,
+ testhashu32_fnv1a,
+ testhashs64_fnv1a,
+ testhashu64_fnv1a,
+ testarrayofbools__,
+ testf,
+ testf2,
+ testf3,
+ testarrayofstring2__,
+ testarrayofsortedstruct__,
+ flex__,
+ test5__,
+ vector_of_longs__,
+ vector_of_doubles__,
+ parent_namespace_test,
+ vector_of_referrables__,
+ single_weak_reference,
+ vector_of_weak_references__,
+ vector_of_strong_referrables__,
+ co_owning_reference,
+ vector_of_co_owning_references__,
+ non_owning_reference,
+ vector_of_non_owning_references__,
+ any_unique_type,
+ any_unique,
+ any_ambiguous_type,
+ any_ambiguous,
+ vector_of_enums__,
+ signed_enum,
+ testrequirednestedflatbuffer__,
+ scalar_key_sorted_tables__,
+ native_inline,
+ long_enum_non_enum_default,
+ long_enum_normal_default);
+}
+
+flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+
+struct TypeAliasesT : public flatbuffers::NativeTable {
+ typedef TypeAliases TableType;
+ int8_t i8 = 0;
+ uint8_t u8 = 0;
+ int16_t i16 = 0;
+ uint16_t u16 = 0;
+ int32_t i32 = 0;
+ uint32_t u32 = 0;
+ int64_t i64 = 0;
+ uint64_t u64 = 0;
+ float f32 = 0.0f;
+ double f64 = 0.0;
+ std::vector<int8_t> v8{};
+ std::vector<double> vf64{};
+};
+
+struct TypeAliases FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
+ typedef TypeAliasesT NativeTableType;
+ typedef TypeAliasesBuilder Builder;
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return TypeAliasesTypeTable();
+ }
+ enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
+ VT_I8 = 4,
+ VT_U8 = 6,
+ VT_I16 = 8,
+ VT_U16 = 10,
+ VT_I32 = 12,
+ VT_U32 = 14,
+ VT_I64 = 16,
+ VT_U64 = 18,
+ VT_F32 = 20,
+ VT_F64 = 22,
+ VT_V8 = 24,
+ VT_VF64 = 26
+ };
+ int8_t i8() const {
+ return GetField<int8_t>(VT_I8, 0);
+ }
+ bool mutate_i8(int8_t _i8 = 0) {
+ return SetField<int8_t>(VT_I8, _i8, 0);
+ }
+ uint8_t u8() const {
+ return GetField<uint8_t>(VT_U8, 0);
+ }
+ bool mutate_u8(uint8_t _u8 = 0) {
+ return SetField<uint8_t>(VT_U8, _u8, 0);
+ }
+ int16_t i16() const {
+ return GetField<int16_t>(VT_I16, 0);
+ }
+ bool mutate_i16(int16_t _i16 = 0) {
+ return SetField<int16_t>(VT_I16, _i16, 0);
+ }
+ uint16_t u16() const {
+ return GetField<uint16_t>(VT_U16, 0);
+ }
+ bool mutate_u16(uint16_t _u16 = 0) {
+ return SetField<uint16_t>(VT_U16, _u16, 0);
+ }
+ int32_t i32() const {
+ return GetField<int32_t>(VT_I32, 0);
+ }
+ bool mutate_i32(int32_t _i32 = 0) {
+ return SetField<int32_t>(VT_I32, _i32, 0);
+ }
+ uint32_t u32() const {
+ return GetField<uint32_t>(VT_U32, 0);
+ }
+ bool mutate_u32(uint32_t _u32 = 0) {
+ return SetField<uint32_t>(VT_U32, _u32, 0);
+ }
+ int64_t i64() const {
+ return GetField<int64_t>(VT_I64, 0);
+ }
+ bool mutate_i64(int64_t _i64 = 0) {
+ return SetField<int64_t>(VT_I64, _i64, 0);
+ }
+ uint64_t u64() const {
+ return GetField<uint64_t>(VT_U64, 0);
+ }
+ bool mutate_u64(uint64_t _u64 = 0) {
+ return SetField<uint64_t>(VT_U64, _u64, 0);
+ }
+ float f32() const {
+ return GetField<float>(VT_F32, 0.0f);
+ }
+ bool mutate_f32(float _f32 = 0.0f) {
+ return SetField<float>(VT_F32, _f32, 0.0f);
+ }
+ double f64() const {
+ return GetField<double>(VT_F64, 0.0);
+ }
+ bool mutate_f64(double _f64 = 0.0) {
+ return SetField<double>(VT_F64, _f64, 0.0);
+ }
+ const flatbuffers::Vector<int8_t> *v8() const {
+ return GetPointer<const flatbuffers::Vector<int8_t> *>(VT_V8);
+ }
+ flatbuffers::Vector<int8_t> *mutable_v8() {
+ return GetPointer<flatbuffers::Vector<int8_t> *>(VT_V8);
+ }
+ const flatbuffers::Vector<double> *vf64() const {
+ return GetPointer<const flatbuffers::Vector<double> *>(VT_VF64);
+ }
+ flatbuffers::Vector<double> *mutable_vf64() {
+ return GetPointer<flatbuffers::Vector<double> *>(VT_VF64);
+ }
+ bool Verify(flatbuffers::Verifier &verifier) const {
+ return VerifyTableStart(verifier) &&
+ VerifyField<int8_t>(verifier, VT_I8, 1) &&
+ VerifyField<uint8_t>(verifier, VT_U8, 1) &&
+ VerifyField<int16_t>(verifier, VT_I16, 2) &&
+ VerifyField<uint16_t>(verifier, VT_U16, 2) &&
+ VerifyField<int32_t>(verifier, VT_I32, 4) &&
+ VerifyField<uint32_t>(verifier, VT_U32, 4) &&
+ VerifyField<int64_t>(verifier, VT_I64, 8) &&
+ VerifyField<uint64_t>(verifier, VT_U64, 8) &&
+ VerifyField<float>(verifier, VT_F32, 4) &&
+ VerifyField<double>(verifier, VT_F64, 8) &&
+ VerifyOffset(verifier, VT_V8) &&
+ verifier.VerifyVector(v8()) &&
+ VerifyOffset(verifier, VT_VF64) &&
+ verifier.VerifyVector(vf64()) &&
+ verifier.EndTable();
+ }
+ TypeAliasesT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ void UnPackTo(TypeAliasesT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ static flatbuffers::Offset<TypeAliases> Pack(flatbuffers::FlatBufferBuilder &_fbb, const TypeAliasesT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+};
+
+struct TypeAliasesBuilder {
+ typedef TypeAliases Table;
+ flatbuffers::FlatBufferBuilder &fbb_;
+ flatbuffers::uoffset_t start_;
+ void add_i8(int8_t i8) {
+ fbb_.AddElement<int8_t>(TypeAliases::VT_I8, i8, 0);
+ }
+ void add_u8(uint8_t u8) {
+ fbb_.AddElement<uint8_t>(TypeAliases::VT_U8, u8, 0);
+ }
+ void add_i16(int16_t i16) {
+ fbb_.AddElement<int16_t>(TypeAliases::VT_I16, i16, 0);
+ }
+ void add_u16(uint16_t u16) {
+ fbb_.AddElement<uint16_t>(TypeAliases::VT_U16, u16, 0);
+ }
+ void add_i32(int32_t i32) {
+ fbb_.AddElement<int32_t>(TypeAliases::VT_I32, i32, 0);
+ }
+ void add_u32(uint32_t u32) {
+ fbb_.AddElement<uint32_t>(TypeAliases::VT_U32, u32, 0);
+ }
+ void add_i64(int64_t i64) {
+ fbb_.AddElement<int64_t>(TypeAliases::VT_I64, i64, 0);
+ }
+ void add_u64(uint64_t u64) {
+ fbb_.AddElement<uint64_t>(TypeAliases::VT_U64, u64, 0);
+ }
+ void add_f32(float f32) {
+ fbb_.AddElement<float>(TypeAliases::VT_F32, f32, 0.0f);
+ }
+ void add_f64(double f64) {
+ fbb_.AddElement<double>(TypeAliases::VT_F64, f64, 0.0);
+ }
+ void add_v8(flatbuffers::Offset<flatbuffers::Vector<int8_t>> v8) {
+ fbb_.AddOffset(TypeAliases::VT_V8, v8);
+ }
+ void add_vf64(flatbuffers::Offset<flatbuffers::Vector<double>> vf64) {
+ fbb_.AddOffset(TypeAliases::VT_VF64, vf64);
+ }
+ explicit TypeAliasesBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
+ flatbuffers::Offset<TypeAliases> Finish() {
+ const auto end = fbb_.EndTable(start_);
+ auto o = flatbuffers::Offset<TypeAliases>(end);
+ return o;
+ }
+};
+
+inline flatbuffers::Offset<TypeAliases> CreateTypeAliases(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ int8_t i8 = 0,
+ uint8_t u8 = 0,
+ int16_t i16 = 0,
+ uint16_t u16 = 0,
+ int32_t i32 = 0,
+ uint32_t u32 = 0,
+ int64_t i64 = 0,
+ uint64_t u64 = 0,
+ float f32 = 0.0f,
+ double f64 = 0.0,
+ flatbuffers::Offset<flatbuffers::Vector<int8_t>> v8 = 0,
+ flatbuffers::Offset<flatbuffers::Vector<double>> vf64 = 0) {
+ TypeAliasesBuilder builder_(_fbb);
+ builder_.add_f64(f64);
+ builder_.add_u64(u64);
+ builder_.add_i64(i64);
+ builder_.add_vf64(vf64);
+ builder_.add_v8(v8);
+ builder_.add_f32(f32);
+ builder_.add_u32(u32);
+ builder_.add_i32(i32);
+ builder_.add_u16(u16);
+ builder_.add_i16(i16);
+ builder_.add_u8(u8);
+ builder_.add_i8(i8);
+ return builder_.Finish();
+}
+
+inline flatbuffers::Offset<TypeAliases> CreateTypeAliasesDirect(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ int8_t i8 = 0,
+ uint8_t u8 = 0,
+ int16_t i16 = 0,
+ uint16_t u16 = 0,
+ int32_t i32 = 0,
+ uint32_t u32 = 0,
+ int64_t i64 = 0,
+ uint64_t u64 = 0,
+ float f32 = 0.0f,
+ double f64 = 0.0,
+ const std::vector<int8_t> *v8 = nullptr,
+ const std::vector<double> *vf64 = nullptr) {
+ auto v8__ = v8 ? _fbb.CreateVector<int8_t>(*v8) : 0;
+ auto vf64__ = vf64 ? _fbb.CreateVector<double>(*vf64) : 0;
+ return MyGame::Example::CreateTypeAliases(
+ _fbb,
+ i8,
+ u8,
+ i16,
+ u16,
+ i32,
+ u32,
+ i64,
+ u64,
+ f32,
+ f64,
+ v8__,
+ vf64__);
+}
+
+flatbuffers::Offset<TypeAliases> CreateTypeAliases(flatbuffers::FlatBufferBuilder &_fbb, const TypeAliasesT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+
+} // namespace Example
+
+
+inline bool operator==(const InParentNamespaceT &, const InParentNamespaceT &) {
+ return true;
+}
+
+inline bool operator!=(const InParentNamespaceT &lhs, const InParentNamespaceT &rhs) {
+ return !(lhs == rhs);
+}
+
+
+inline InParentNamespaceT *InParentNamespace::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
+ auto _o = std::unique_ptr<InParentNamespaceT>(new InParentNamespaceT());
+ UnPackTo(_o.get(), _resolver);
+ return _o.release();
+}
+
+inline void InParentNamespace::UnPackTo(InParentNamespaceT *_o, const flatbuffers::resolver_function_t *_resolver) const {
+ (void)_o;
+ (void)_resolver;
+}
+
+inline flatbuffers::Offset<InParentNamespace> InParentNamespace::Pack(flatbuffers::FlatBufferBuilder &_fbb, const InParentNamespaceT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
+ return CreateInParentNamespace(_fbb, _o, _rehasher);
+}
+
+inline flatbuffers::Offset<InParentNamespace> CreateInParentNamespace(flatbuffers::FlatBufferBuilder &_fbb, const InParentNamespaceT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
+ (void)_rehasher;
+ (void)_o;
+ struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const InParentNamespaceT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
+ return MyGame::CreateInParentNamespace(
+ _fbb);
+}
+
+namespace Example2 {
+
+
+inline bool operator==(const MonsterT &, const MonsterT &) {
+ return true;
+}
+
+inline bool operator!=(const MonsterT &lhs, const MonsterT &rhs) {
+ return !(lhs == rhs);
+}
+
+
+inline MonsterT *Monster::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
+ auto _o = std::unique_ptr<MonsterT>(new MonsterT());
+ UnPackTo(_o.get(), _resolver);
+ return _o.release();
+}
+
+inline void Monster::UnPackTo(MonsterT *_o, const flatbuffers::resolver_function_t *_resolver) const {
+ (void)_o;
+ (void)_resolver;
+}
+
+inline flatbuffers::Offset<Monster> Monster::Pack(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
+ return CreateMonster(_fbb, _o, _rehasher);
+}
+
+inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
+ (void)_rehasher;
+ (void)_o;
+ struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const MonsterT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
+ return MyGame::Example2::CreateMonster(
+ _fbb);
+}
+
+} // namespace Example2
+
+namespace Example {
+
+
+inline bool operator==(const TestSimpleTableWithEnumT &lhs, const TestSimpleTableWithEnumT &rhs) {
+ return
+ (lhs.color == rhs.color);
+}
+
+inline bool operator!=(const TestSimpleTableWithEnumT &lhs, const TestSimpleTableWithEnumT &rhs) {
+ return !(lhs == rhs);
+}
+
+
+inline TestSimpleTableWithEnumT *TestSimpleTableWithEnum::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
+ auto _o = std::unique_ptr<TestSimpleTableWithEnumT>(new TestSimpleTableWithEnumT());
+ UnPackTo(_o.get(), _resolver);
+ return _o.release();
+}
+
+inline void TestSimpleTableWithEnum::UnPackTo(TestSimpleTableWithEnumT *_o, const flatbuffers::resolver_function_t *_resolver) const {
+ (void)_o;
+ (void)_resolver;
+ { auto _e = color(); _o->color = _e; }
+}
+
+inline flatbuffers::Offset<TestSimpleTableWithEnum> TestSimpleTableWithEnum::Pack(flatbuffers::FlatBufferBuilder &_fbb, const TestSimpleTableWithEnumT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
+ return CreateTestSimpleTableWithEnum(_fbb, _o, _rehasher);
+}
+
+inline flatbuffers::Offset<TestSimpleTableWithEnum> CreateTestSimpleTableWithEnum(flatbuffers::FlatBufferBuilder &_fbb, const TestSimpleTableWithEnumT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
+ (void)_rehasher;
+ (void)_o;
+ struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const TestSimpleTableWithEnumT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
+ auto _color = _o->color;
+ return MyGame::Example::CreateTestSimpleTableWithEnum(
+ _fbb,
+ _color);
+}
+
+
+inline bool operator==(const StatT &lhs, const StatT &rhs) {
+ return
+ (lhs.id == rhs.id) &&
+ (lhs.val == rhs.val) &&
+ (lhs.count == rhs.count);
+}
+
+inline bool operator!=(const StatT &lhs, const StatT &rhs) {
+ return !(lhs == rhs);
+}
+
+
+inline StatT *Stat::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
+ auto _o = std::unique_ptr<StatT>(new StatT());
+ UnPackTo(_o.get(), _resolver);
+ return _o.release();
+}
+
+inline void Stat::UnPackTo(StatT *_o, const flatbuffers::resolver_function_t *_resolver) const {
+ (void)_o;
+ (void)_resolver;
+ { auto _e = id(); if (_e) _o->id = _e->str(); }
+ { auto _e = val(); _o->val = _e; }
+ { auto _e = count(); _o->count = _e; }
+}
+
+inline flatbuffers::Offset<Stat> Stat::Pack(flatbuffers::FlatBufferBuilder &_fbb, const StatT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
+ return CreateStat(_fbb, _o, _rehasher);
+}
+
+inline flatbuffers::Offset<Stat> CreateStat(flatbuffers::FlatBufferBuilder &_fbb, const StatT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
+ (void)_rehasher;
+ (void)_o;
+ struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const StatT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
+ auto _id = _o->id.empty() ? 0 : _fbb.CreateString(_o->id);
+ auto _val = _o->val;
+ auto _count = _o->count;
+ return MyGame::Example::CreateStat(
+ _fbb,
+ _id,
+ _val,
+ _count);
+}
+
+
+inline bool operator==(const ReferrableT &lhs, const ReferrableT &rhs) {
+ return
+ (lhs.id == rhs.id);
+}
+
+inline bool operator!=(const ReferrableT &lhs, const ReferrableT &rhs) {
+ return !(lhs == rhs);
+}
+
+
+inline ReferrableT *Referrable::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
+ auto _o = std::unique_ptr<ReferrableT>(new ReferrableT());
+ UnPackTo(_o.get(), _resolver);
+ return _o.release();
+}
+
+inline void Referrable::UnPackTo(ReferrableT *_o, const flatbuffers::resolver_function_t *_resolver) const {
+ (void)_o;
+ (void)_resolver;
+ { auto _e = id(); _o->id = _e; }
+}
+
+inline flatbuffers::Offset<Referrable> Referrable::Pack(flatbuffers::FlatBufferBuilder &_fbb, const ReferrableT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
+ return CreateReferrable(_fbb, _o, _rehasher);
+}
+
+inline flatbuffers::Offset<Referrable> CreateReferrable(flatbuffers::FlatBufferBuilder &_fbb, const ReferrableT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
+ (void)_rehasher;
+ (void)_o;
+ struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const ReferrableT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
+ auto _id = _o->id;
+ return MyGame::Example::CreateReferrable(
+ _fbb,
+ _id);
+}
+
+
+inline bool operator==(const MonsterT &lhs, const MonsterT &rhs) {
+ return
+ ((lhs.pos == rhs.pos) || (lhs.pos && rhs.pos && *lhs.pos == *rhs.pos)) &&
+ (lhs.mana == rhs.mana) &&
+ (lhs.hp == rhs.hp) &&
+ (lhs.name == rhs.name) &&
+ (lhs.inventory == rhs.inventory) &&
+ (lhs.color == rhs.color) &&
+ (lhs.test == rhs.test) &&
+ (lhs.test4 == rhs.test4) &&
+ (lhs.testarrayofstring == rhs.testarrayofstring) &&
+ (lhs.testarrayoftables.size() == rhs.testarrayoftables.size() && std::equal(lhs.testarrayoftables.cbegin(), lhs.testarrayoftables.cend(), rhs.testarrayoftables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::MonsterT> const &a, flatbuffers::unique_ptr<MyGame::Example::MonsterT> const &b) { return (a == b) || (a && b && *a == *b); })) &&
+ ((lhs.enemy == rhs.enemy) || (lhs.enemy && rhs.enemy && *lhs.enemy == *rhs.enemy)) &&
+ (lhs.testnestedflatbuffer == rhs.testnestedflatbuffer) &&
+ ((lhs.testempty == rhs.testempty) || (lhs.testempty && rhs.testempty && *lhs.testempty == *rhs.testempty)) &&
+ (lhs.testbool == rhs.testbool) &&
+ (lhs.testhashs32_fnv1 == rhs.testhashs32_fnv1) &&
+ (lhs.testhashu32_fnv1 == rhs.testhashu32_fnv1) &&
+ (lhs.testhashs64_fnv1 == rhs.testhashs64_fnv1) &&
+ (lhs.testhashu64_fnv1 == rhs.testhashu64_fnv1) &&
+ (lhs.testhashs32_fnv1a == rhs.testhashs32_fnv1a) &&
+ (lhs.testhashu32_fnv1a == rhs.testhashu32_fnv1a) &&
+ (lhs.testhashs64_fnv1a == rhs.testhashs64_fnv1a) &&
+ (lhs.testhashu64_fnv1a == rhs.testhashu64_fnv1a) &&
+ (lhs.testarrayofbools == rhs.testarrayofbools) &&
+ (lhs.testf == rhs.testf) &&
+ (lhs.testf2 == rhs.testf2) &&
+ (lhs.testf3 == rhs.testf3) &&
+ (lhs.testarrayofstring2 == rhs.testarrayofstring2) &&
+ (lhs.testarrayofsortedstruct == rhs.testarrayofsortedstruct) &&
+ (lhs.flex == rhs.flex) &&
+ (lhs.test5 == rhs.test5) &&
+ (lhs.vector_of_longs == rhs.vector_of_longs) &&
+ (lhs.vector_of_doubles == rhs.vector_of_doubles) &&
+ ((lhs.parent_namespace_test == rhs.parent_namespace_test) || (lhs.parent_namespace_test && rhs.parent_namespace_test && *lhs.parent_namespace_test == *rhs.parent_namespace_test)) &&
+ (lhs.vector_of_referrables.size() == rhs.vector_of_referrables.size() && std::equal(lhs.vector_of_referrables.cbegin(), lhs.vector_of_referrables.cend(), rhs.vector_of_referrables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &a, flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &b) { return (a == b) || (a && b && *a == *b); })) &&
+ (lhs.single_weak_reference == rhs.single_weak_reference) &&
+ (lhs.vector_of_weak_references == rhs.vector_of_weak_references) &&
+ (lhs.vector_of_strong_referrables.size() == rhs.vector_of_strong_referrables.size() && std::equal(lhs.vector_of_strong_referrables.cbegin(), lhs.vector_of_strong_referrables.cend(), rhs.vector_of_strong_referrables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &a, flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &b) { return (a == b) || (a && b && *a == *b); })) &&
+ (lhs.co_owning_reference == rhs.co_owning_reference) &&
+ (lhs.vector_of_co_owning_references == rhs.vector_of_co_owning_references) &&
+ (lhs.non_owning_reference == rhs.non_owning_reference) &&
+ (lhs.vector_of_non_owning_references == rhs.vector_of_non_owning_references) &&
+ (lhs.any_unique == rhs.any_unique) &&
+ (lhs.any_ambiguous == rhs.any_ambiguous) &&
+ (lhs.vector_of_enums == rhs.vector_of_enums) &&
+ (lhs.signed_enum == rhs.signed_enum) &&
+ (lhs.testrequirednestedflatbuffer == rhs.testrequirednestedflatbuffer) &&
+ (lhs.scalar_key_sorted_tables.size() == rhs.scalar_key_sorted_tables.size() && std::equal(lhs.scalar_key_sorted_tables.cbegin(), lhs.scalar_key_sorted_tables.cend(), rhs.scalar_key_sorted_tables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::StatT> const &a, flatbuffers::unique_ptr<MyGame::Example::StatT> const &b) { return (a == b) || (a && b && *a == *b); })) &&
+ (lhs.native_inline == rhs.native_inline) &&
+ (lhs.long_enum_non_enum_default == rhs.long_enum_non_enum_default) &&
+ (lhs.long_enum_normal_default == rhs.long_enum_normal_default);
+}
+
+inline bool operator!=(const MonsterT &lhs, const MonsterT &rhs) {
+ return !(lhs == rhs);
+}
+
+
+inline MonsterT::MonsterT(const MonsterT &o)
+ : pos((o.pos) ? new MyGame::Example::Vec3(*o.pos) : nullptr),
+ mana(o.mana),
+ hp(o.hp),
+ name(o.name),
+ inventory(o.inventory),
+ color(o.color),
+ test(o.test),
+ test4(o.test4),
+ testarrayofstring(o.testarrayofstring),
+ enemy((o.enemy) ? new MyGame::Example::MonsterT(*o.enemy) : nullptr),
+ testnestedflatbuffer(o.testnestedflatbuffer),
+ testempty((o.testempty) ? new MyGame::Example::StatT(*o.testempty) : nullptr),
+ testbool(o.testbool),
+ testhashs32_fnv1(o.testhashs32_fnv1),
+ testhashu32_fnv1(o.testhashu32_fnv1),
+ testhashs64_fnv1(o.testhashs64_fnv1),
+ testhashu64_fnv1(o.testhashu64_fnv1),
+ testhashs32_fnv1a(o.testhashs32_fnv1a),
+ testhashu32_fnv1a(o.testhashu32_fnv1a),
+ testhashs64_fnv1a(o.testhashs64_fnv1a),
+ testhashu64_fnv1a(o.testhashu64_fnv1a),
+ testarrayofbools(o.testarrayofbools),
+ testf(o.testf),
+ testf2(o.testf2),
+ testf3(o.testf3),
+ testarrayofstring2(o.testarrayofstring2),
+ testarrayofsortedstruct(o.testarrayofsortedstruct),
+ flex(o.flex),
+ test5(o.test5),
+ vector_of_longs(o.vector_of_longs),
+ vector_of_doubles(o.vector_of_doubles),
+ parent_namespace_test((o.parent_namespace_test) ? new MyGame::InParentNamespaceT(*o.parent_namespace_test) : nullptr),
+ single_weak_reference(o.single_weak_reference),
+ vector_of_weak_references(o.vector_of_weak_references),
+ co_owning_reference(o.co_owning_reference),
+ non_owning_reference(o.non_owning_reference),
+ vector_of_non_owning_references(o.vector_of_non_owning_references),
+ any_unique(o.any_unique),
+ any_ambiguous(o.any_ambiguous),
+ vector_of_enums(o.vector_of_enums),
+ signed_enum(o.signed_enum),
+ testrequirednestedflatbuffer(o.testrequirednestedflatbuffer),
+ native_inline(o.native_inline),
+ long_enum_non_enum_default(o.long_enum_non_enum_default),
+ long_enum_normal_default(o.long_enum_normal_default) {
+ testarrayoftables.reserve(o.testarrayoftables.size());
+ for (const auto &testarrayoftables_ : o.testarrayoftables) { testarrayoftables.emplace_back((testarrayoftables_) ? new MyGame::Example::MonsterT(*testarrayoftables_) : nullptr); }
+ vector_of_referrables.reserve(o.vector_of_referrables.size());
+ for (const auto &vector_of_referrables_ : o.vector_of_referrables) { vector_of_referrables.emplace_back((vector_of_referrables_) ? new MyGame::Example::ReferrableT(*vector_of_referrables_) : nullptr); }
+ vector_of_strong_referrables.reserve(o.vector_of_strong_referrables.size());
+ for (const auto &vector_of_strong_referrables_ : o.vector_of_strong_referrables) { vector_of_strong_referrables.emplace_back((vector_of_strong_referrables_) ? new MyGame::Example::ReferrableT(*vector_of_strong_referrables_) : nullptr); }
+ vector_of_co_owning_references.reserve(o.vector_of_co_owning_references.size());
+ for (const auto &vector_of_co_owning_references_ : o.vector_of_co_owning_references) { vector_of_co_owning_references.emplace_back((vector_of_co_owning_references_) ? new ReferrableT(*vector_of_co_owning_references_) : nullptr); }
+ scalar_key_sorted_tables.reserve(o.scalar_key_sorted_tables.size());
+ for (const auto &scalar_key_sorted_tables_ : o.scalar_key_sorted_tables) { scalar_key_sorted_tables.emplace_back((scalar_key_sorted_tables_) ? new MyGame::Example::StatT(*scalar_key_sorted_tables_) : nullptr); }
+}
+
+inline MonsterT &MonsterT::operator=(MonsterT o) FLATBUFFERS_NOEXCEPT {
+ std::swap(pos, o.pos);
+ std::swap(mana, o.mana);
+ std::swap(hp, o.hp);
+ std::swap(name, o.name);
+ std::swap(inventory, o.inventory);
+ std::swap(color, o.color);
+ std::swap(test, o.test);
+ std::swap(test4, o.test4);
+ std::swap(testarrayofstring, o.testarrayofstring);
+ std::swap(testarrayoftables, o.testarrayoftables);
+ std::swap(enemy, o.enemy);
+ std::swap(testnestedflatbuffer, o.testnestedflatbuffer);
+ std::swap(testempty, o.testempty);
+ std::swap(testbool, o.testbool);
+ std::swap(testhashs32_fnv1, o.testhashs32_fnv1);
+ std::swap(testhashu32_fnv1, o.testhashu32_fnv1);
+ std::swap(testhashs64_fnv1, o.testhashs64_fnv1);
+ std::swap(testhashu64_fnv1, o.testhashu64_fnv1);
+ std::swap(testhashs32_fnv1a, o.testhashs32_fnv1a);
+ std::swap(testhashu32_fnv1a, o.testhashu32_fnv1a);
+ std::swap(testhashs64_fnv1a, o.testhashs64_fnv1a);
+ std::swap(testhashu64_fnv1a, o.testhashu64_fnv1a);
+ std::swap(testarrayofbools, o.testarrayofbools);
+ std::swap(testf, o.testf);
+ std::swap(testf2, o.testf2);
+ std::swap(testf3, o.testf3);
+ std::swap(testarrayofstring2, o.testarrayofstring2);
+ std::swap(testarrayofsortedstruct, o.testarrayofsortedstruct);
+ std::swap(flex, o.flex);
+ std::swap(test5, o.test5);
+ std::swap(vector_of_longs, o.vector_of_longs);
+ std::swap(vector_of_doubles, o.vector_of_doubles);
+ std::swap(parent_namespace_test, o.parent_namespace_test);
+ std::swap(vector_of_referrables, o.vector_of_referrables);
+ std::swap(single_weak_reference, o.single_weak_reference);
+ std::swap(vector_of_weak_references, o.vector_of_weak_references);
+ std::swap(vector_of_strong_referrables, o.vector_of_strong_referrables);
+ std::swap(co_owning_reference, o.co_owning_reference);
+ std::swap(vector_of_co_owning_references, o.vector_of_co_owning_references);
+ std::swap(non_owning_reference, o.non_owning_reference);
+ std::swap(vector_of_non_owning_references, o.vector_of_non_owning_references);
+ std::swap(any_unique, o.any_unique);
+ std::swap(any_ambiguous, o.any_ambiguous);
+ std::swap(vector_of_enums, o.vector_of_enums);
+ std::swap(signed_enum, o.signed_enum);
+ std::swap(testrequirednestedflatbuffer, o.testrequirednestedflatbuffer);
+ std::swap(scalar_key_sorted_tables, o.scalar_key_sorted_tables);
+ std::swap(native_inline, o.native_inline);
+ std::swap(long_enum_non_enum_default, o.long_enum_non_enum_default);
+ std::swap(long_enum_normal_default, o.long_enum_normal_default);
+ return *this;
+}
+
+inline MonsterT *Monster::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
+ auto _o = std::unique_ptr<MonsterT>(new MonsterT());
+ UnPackTo(_o.get(), _resolver);
+ return _o.release();
+}
+
+inline void Monster::UnPackTo(MonsterT *_o, const flatbuffers::resolver_function_t *_resolver) const {
+ (void)_o;
+ (void)_resolver;
+ { auto _e = pos(); if (_e) _o->pos = flatbuffers::unique_ptr<MyGame::Example::Vec3>(new MyGame::Example::Vec3(*_e)); }
+ { auto _e = mana(); _o->mana = _e; }
+ { auto _e = hp(); _o->hp = _e; }
+ { auto _e = name(); if (_e) _o->name = _e->str(); }
+ { auto _e = inventory(); if (_e) { _o->inventory.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->inventory.begin()); } }
+ { auto _e = color(); _o->color = _e; }
+ { auto _e = test_type(); _o->test.type = _e; }
+ { auto _e = test(); if (_e) _o->test.value = MyGame::Example::AnyUnion::UnPack(_e, test_type(), _resolver); }
+ { auto _e = test4(); if (_e) { _o->test4.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->test4[_i] = *_e->Get(_i); } } else { _o->test4.resize(0); } }
+ { auto _e = testarrayofstring(); if (_e) { _o->testarrayofstring.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofstring[_i] = _e->Get(_i)->str(); } } else { _o->testarrayofstring.resize(0); } }
+ { auto _e = testarrayoftables(); if (_e) { _o->testarrayoftables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->testarrayoftables[_i]) { _e->Get(_i)->UnPackTo(_o->testarrayoftables[_i].get(), _resolver); } else { _o->testarrayoftables[_i] = flatbuffers::unique_ptr<MyGame::Example::MonsterT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->testarrayoftables.resize(0); } }
+ { auto _e = enemy(); if (_e) { if(_o->enemy) { _e->UnPackTo(_o->enemy.get(), _resolver); } else { _o->enemy = flatbuffers::unique_ptr<MyGame::Example::MonsterT>(_e->UnPack(_resolver)); } } else if (_o->enemy) { _o->enemy.reset(); } }
+ { auto _e = testnestedflatbuffer(); if (_e) { _o->testnestedflatbuffer.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->testnestedflatbuffer.begin()); } }
+ { auto _e = testempty(); if (_e) { if(_o->testempty) { _e->UnPackTo(_o->testempty.get(), _resolver); } else { _o->testempty = flatbuffers::unique_ptr<MyGame::Example::StatT>(_e->UnPack(_resolver)); } } else if (_o->testempty) { _o->testempty.reset(); } }
+ { auto _e = testbool(); _o->testbool = _e; }
+ { auto _e = testhashs32_fnv1(); _o->testhashs32_fnv1 = _e; }
+ { auto _e = testhashu32_fnv1(); _o->testhashu32_fnv1 = _e; }
+ { auto _e = testhashs64_fnv1(); _o->testhashs64_fnv1 = _e; }
+ { auto _e = testhashu64_fnv1(); _o->testhashu64_fnv1 = _e; }
+ { auto _e = testhashs32_fnv1a(); _o->testhashs32_fnv1a = _e; }
+ { auto _e = testhashu32_fnv1a(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->testhashu32_fnv1a), static_cast<flatbuffers::hash_value_t>(_e)); else _o->testhashu32_fnv1a = nullptr; }
+ { auto _e = testhashs64_fnv1a(); _o->testhashs64_fnv1a = _e; }
+ { auto _e = testhashu64_fnv1a(); _o->testhashu64_fnv1a = _e; }
+ { auto _e = testarrayofbools(); if (_e) { _o->testarrayofbools.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofbools[_i] = _e->Get(_i) != 0; } } else { _o->testarrayofbools.resize(0); } }
+ { auto _e = testf(); _o->testf = _e; }
+ { auto _e = testf2(); _o->testf2 = _e; }
+ { auto _e = testf3(); _o->testf3 = _e; }
+ { auto _e = testarrayofstring2(); if (_e) { _o->testarrayofstring2.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofstring2[_i] = _e->Get(_i)->str(); } } else { _o->testarrayofstring2.resize(0); } }
+ { auto _e = testarrayofsortedstruct(); if (_e) { _o->testarrayofsortedstruct.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofsortedstruct[_i] = *_e->Get(_i); } } else { _o->testarrayofsortedstruct.resize(0); } }
+ { auto _e = flex(); if (_e) { _o->flex.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->flex.begin()); } }
+ { auto _e = test5(); if (_e) { _o->test5.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->test5[_i] = *_e->Get(_i); } } else { _o->test5.resize(0); } }
+ { auto _e = vector_of_longs(); if (_e) { _o->vector_of_longs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_longs[_i] = _e->Get(_i); } } else { _o->vector_of_longs.resize(0); } }
+ { auto _e = vector_of_doubles(); if (_e) { _o->vector_of_doubles.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_doubles[_i] = _e->Get(_i); } } else { _o->vector_of_doubles.resize(0); } }
+ { auto _e = parent_namespace_test(); if (_e) { if(_o->parent_namespace_test) { _e->UnPackTo(_o->parent_namespace_test.get(), _resolver); } else { _o->parent_namespace_test = flatbuffers::unique_ptr<MyGame::InParentNamespaceT>(_e->UnPack(_resolver)); } } else if (_o->parent_namespace_test) { _o->parent_namespace_test.reset(); } }
+ { auto _e = vector_of_referrables(); if (_e) { _o->vector_of_referrables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_referrables[_i].get(), _resolver); } else { _o->vector_of_referrables[_i] = flatbuffers::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->vector_of_referrables.resize(0); } }
+ { auto _e = single_weak_reference(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->single_weak_reference), static_cast<flatbuffers::hash_value_t>(_e)); else _o->single_weak_reference = nullptr; }
+ { auto _e = vector_of_weak_references(); if (_e) { _o->vector_of_weak_references.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { /*vector resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_weak_references[_i]), static_cast<flatbuffers::hash_value_t>(_e->Get(_i))); else _o->vector_of_weak_references[_i] = nullptr; } } else { _o->vector_of_weak_references.resize(0); } }
+ { auto _e = vector_of_strong_referrables(); if (_e) { _o->vector_of_strong_referrables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_strong_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_strong_referrables[_i].get(), _resolver); } else { _o->vector_of_strong_referrables[_i] = flatbuffers::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->vector_of_strong_referrables.resize(0); } }
+ { auto _e = co_owning_reference(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->co_owning_reference), static_cast<flatbuffers::hash_value_t>(_e)); else _o->co_owning_reference = nullptr; }
+ { auto _e = vector_of_co_owning_references(); if (_e) { _o->vector_of_co_owning_references.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { /*vector resolver, default_ptr_type*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_co_owning_references[_i]), static_cast<flatbuffers::hash_value_t>(_e->Get(_i)));/* else do nothing */; } } else { _o->vector_of_co_owning_references.resize(0); } }
+ { auto _e = non_owning_reference(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->non_owning_reference), static_cast<flatbuffers::hash_value_t>(_e)); else _o->non_owning_reference = nullptr; }
+ { auto _e = vector_of_non_owning_references(); if (_e) { _o->vector_of_non_owning_references.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { /*vector resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_non_owning_references[_i]), static_cast<flatbuffers::hash_value_t>(_e->Get(_i))); else _o->vector_of_non_owning_references[_i] = nullptr; } } else { _o->vector_of_non_owning_references.resize(0); } }
+ { auto _e = any_unique_type(); _o->any_unique.type = _e; }
+ { auto _e = any_unique(); if (_e) _o->any_unique.value = MyGame::Example::AnyUniqueAliasesUnion::UnPack(_e, any_unique_type(), _resolver); }
+ { auto _e = any_ambiguous_type(); _o->any_ambiguous.type = _e; }
+ { auto _e = any_ambiguous(); if (_e) _o->any_ambiguous.value = MyGame::Example::AnyAmbiguousAliasesUnion::UnPack(_e, any_ambiguous_type(), _resolver); }
+ { auto _e = vector_of_enums(); if (_e) { _o->vector_of_enums.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_enums[_i] = static_cast<MyGame::Example::Color>(_e->Get(_i)); } } else { _o->vector_of_enums.resize(0); } }
+ { auto _e = signed_enum(); _o->signed_enum = _e; }
+ { auto _e = testrequirednestedflatbuffer(); if (_e) { _o->testrequirednestedflatbuffer.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->testrequirednestedflatbuffer.begin()); } }
+ { auto _e = scalar_key_sorted_tables(); if (_e) { _o->scalar_key_sorted_tables.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->scalar_key_sorted_tables[_i]) { _e->Get(_i)->UnPackTo(_o->scalar_key_sorted_tables[_i].get(), _resolver); } else { _o->scalar_key_sorted_tables[_i] = flatbuffers::unique_ptr<MyGame::Example::StatT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->scalar_key_sorted_tables.resize(0); } }
+ { auto _e = native_inline(); if (_e) _o->native_inline = *_e; }
+ { auto _e = long_enum_non_enum_default(); _o->long_enum_non_enum_default = _e; }
+ { auto _e = long_enum_normal_default(); _o->long_enum_normal_default = _e; }
+}
+
+inline flatbuffers::Offset<Monster> Monster::Pack(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
+ return CreateMonster(_fbb, _o, _rehasher);
+}
+
+inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
+ (void)_rehasher;
+ (void)_o;
+ struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const MonsterT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
+ auto _pos = _o->pos ? _o->pos.get() : nullptr;
+ auto _mana = _o->mana;
+ auto _hp = _o->hp;
+ auto _name = _fbb.CreateString(_o->name);
+ auto _inventory = _o->inventory.size() ? _fbb.CreateVector(_o->inventory) : 0;
+ auto _color = _o->color;
+ auto _test_type = _o->test.type;
+ auto _test = _o->test.Pack(_fbb);
+ auto _test4 = _o->test4.size() ? _fbb.CreateVectorOfStructs(_o->test4) : 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 _enemy = _o->enemy ? CreateMonster(_fbb, _o->enemy.get(), _rehasher) : 0;
+ auto _testnestedflatbuffer = _o->testnestedflatbuffer.size() ? _fbb.CreateVector(_o->testnestedflatbuffer) : 0;
+ auto _testempty = _o->testempty ? CreateStat(_fbb, _o->testempty.get(), _rehasher) : 0;
+ auto _testbool = _o->testbool;
+ auto _testhashs32_fnv1 = _o->testhashs32_fnv1;
+ auto _testhashu32_fnv1 = _o->testhashu32_fnv1;
+ auto _testhashs64_fnv1 = _o->testhashs64_fnv1;
+ auto _testhashu64_fnv1 = _o->testhashu64_fnv1;
+ auto _testhashs32_fnv1a = _o->testhashs32_fnv1a;
+ auto _testhashu32_fnv1a = _rehasher ? static_cast<uint32_t>((*_rehasher)(_o->testhashu32_fnv1a)) : 0;
+ auto _testhashs64_fnv1a = _o->testhashs64_fnv1a;
+ auto _testhashu64_fnv1a = _o->testhashu64_fnv1a;
+ auto _testarrayofbools = _o->testarrayofbools.size() ? _fbb.CreateVector(_o->testarrayofbools) : 0;
+ auto _testf = _o->testf;
+ auto _testf2 = _o->testf2;
+ auto _testf3 = _o->testf3;
+ auto _testarrayofstring2 = _o->testarrayofstring2.size() ? _fbb.CreateVectorOfStrings(_o->testarrayofstring2) : 0;
+ auto _testarrayofsortedstruct = _o->testarrayofsortedstruct.size() ? _fbb.CreateVectorOfStructs(_o->testarrayofsortedstruct) : 0;
+ auto _flex = _o->flex.size() ? _fbb.CreateVector(_o->flex) : 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_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 _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 _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_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 _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 _non_owning_reference = _rehasher ? static_cast<uint64_t>((*_rehasher)(_o->non_owning_reference)) : 0;
+ auto _vector_of_non_owning_references = _o->vector_of_non_owning_references.size() ? _fbb.CreateVector<uint64_t>(_o->vector_of_non_owning_references.size(), [](size_t i, _VectorArgs *__va) { return __va->__rehasher ? static_cast<uint64_t>((*__va->__rehasher)(__va->__o->vector_of_non_owning_references[i])) : 0; }, &_va ) : 0;
+ auto _any_unique_type = _o->any_unique.type;
+ auto _any_unique = _o->any_unique.Pack(_fbb);
+ auto _any_ambiguous_type = _o->any_ambiguous.type;
+ auto _any_ambiguous = _o->any_ambiguous.Pack(_fbb);
+ auto _vector_of_enums = _o->vector_of_enums.size() ? _fbb.CreateVectorScalarCast<uint8_t>(flatbuffers::data(_o->vector_of_enums), _o->vector_of_enums.size()) : 0;
+ auto _signed_enum = _o->signed_enum;
+ 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 _native_inline = &_o->native_inline;
+ auto _long_enum_non_enum_default = _o->long_enum_non_enum_default;
+ auto _long_enum_normal_default = _o->long_enum_normal_default;
+ return MyGame::Example::CreateMonster(
+ _fbb,
+ _pos,
+ _mana,
+ _hp,
+ _name,
+ _inventory,
+ _color,
+ _test_type,
+ _test,
+ _test4,
+ _testarrayofstring,
+ _testarrayoftables,
+ _enemy,
+ _testnestedflatbuffer,
+ _testempty,
+ _testbool,
+ _testhashs32_fnv1,
+ _testhashu32_fnv1,
+ _testhashs64_fnv1,
+ _testhashu64_fnv1,
+ _testhashs32_fnv1a,
+ _testhashu32_fnv1a,
+ _testhashs64_fnv1a,
+ _testhashu64_fnv1a,
+ _testarrayofbools,
+ _testf,
+ _testf2,
+ _testf3,
+ _testarrayofstring2,
+ _testarrayofsortedstruct,
+ _flex,
+ _test5,
+ _vector_of_longs,
+ _vector_of_doubles,
+ _parent_namespace_test,
+ _vector_of_referrables,
+ _single_weak_reference,
+ _vector_of_weak_references,
+ _vector_of_strong_referrables,
+ _co_owning_reference,
+ _vector_of_co_owning_references,
+ _non_owning_reference,
+ _vector_of_non_owning_references,
+ _any_unique_type,
+ _any_unique,
+ _any_ambiguous_type,
+ _any_ambiguous,
+ _vector_of_enums,
+ _signed_enum,
+ _testrequirednestedflatbuffer,
+ _scalar_key_sorted_tables,
+ _native_inline,
+ _long_enum_non_enum_default,
+ _long_enum_normal_default);
+}
+
+
+inline bool operator==(const TypeAliasesT &lhs, const TypeAliasesT &rhs) {
+ return
+ (lhs.i8 == rhs.i8) &&
+ (lhs.u8 == rhs.u8) &&
+ (lhs.i16 == rhs.i16) &&
+ (lhs.u16 == rhs.u16) &&
+ (lhs.i32 == rhs.i32) &&
+ (lhs.u32 == rhs.u32) &&
+ (lhs.i64 == rhs.i64) &&
+ (lhs.u64 == rhs.u64) &&
+ (lhs.f32 == rhs.f32) &&
+ (lhs.f64 == rhs.f64) &&
+ (lhs.v8 == rhs.v8) &&
+ (lhs.vf64 == rhs.vf64);
+}
+
+inline bool operator!=(const TypeAliasesT &lhs, const TypeAliasesT &rhs) {
+ return !(lhs == rhs);
+}
+
+
+inline TypeAliasesT *TypeAliases::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
+ auto _o = std::unique_ptr<TypeAliasesT>(new TypeAliasesT());
+ UnPackTo(_o.get(), _resolver);
+ return _o.release();
+}
+
+inline void TypeAliases::UnPackTo(TypeAliasesT *_o, const flatbuffers::resolver_function_t *_resolver) const {
+ (void)_o;
+ (void)_resolver;
+ { auto _e = i8(); _o->i8 = _e; }
+ { auto _e = u8(); _o->u8 = _e; }
+ { auto _e = i16(); _o->i16 = _e; }
+ { auto _e = u16(); _o->u16 = _e; }
+ { auto _e = i32(); _o->i32 = _e; }
+ { auto _e = u32(); _o->u32 = _e; }
+ { auto _e = i64(); _o->i64 = _e; }
+ { auto _e = u64(); _o->u64 = _e; }
+ { auto _e = f32(); _o->f32 = _e; }
+ { auto _e = f64(); _o->f64 = _e; }
+ { auto _e = v8(); if (_e) { _o->v8.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->v8.begin()); } }
+ { auto _e = vf64(); if (_e) { _o->vf64.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vf64[_i] = _e->Get(_i); } } else { _o->vf64.resize(0); } }
+}
+
+inline flatbuffers::Offset<TypeAliases> TypeAliases::Pack(flatbuffers::FlatBufferBuilder &_fbb, const TypeAliasesT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
+ return CreateTypeAliases(_fbb, _o, _rehasher);
+}
+
+inline flatbuffers::Offset<TypeAliases> CreateTypeAliases(flatbuffers::FlatBufferBuilder &_fbb, const TypeAliasesT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
+ (void)_rehasher;
+ (void)_o;
+ struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const TypeAliasesT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
+ auto _i8 = _o->i8;
+ auto _u8 = _o->u8;
+ auto _i16 = _o->i16;
+ auto _u16 = _o->u16;
+ auto _i32 = _o->i32;
+ auto _u32 = _o->u32;
+ auto _i64 = _o->i64;
+ auto _u64 = _o->u64;
+ auto _f32 = _o->f32;
+ auto _f64 = _o->f64;
+ auto _v8 = _o->v8.size() ? _fbb.CreateVector(_o->v8) : 0;
+ auto _vf64 = _o->vf64.size() ? _fbb.CreateVector(_o->vf64) : 0;
+ return MyGame::Example::CreateTypeAliases(
+ _fbb,
+ _i8,
+ _u8,
+ _i16,
+ _u16,
+ _i32,
+ _u32,
+ _i64,
+ _u64,
+ _f32,
+ _f64,
+ _v8,
+ _vf64);
+}
+
+inline bool VerifyAny(flatbuffers::Verifier &verifier, const void *obj, Any type) {
+ switch (type) {
+ case Any_NONE: {
+ return true;
+ }
+ case Any_Monster: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ case Any_TestSimpleTableWithEnum: {
+ auto ptr = reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnum *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ case Any_MyGame_Example2_Monster: {
+ auto ptr = reinterpret_cast<const MyGame::Example2::Monster *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ default: return true;
+ }
+}
+
+inline bool VerifyAnyVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types) {
+ if (!values || !types) return !values && !types;
+ if (values->size() != types->size()) return false;
+ for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
+ if (!VerifyAny(
+ verifier, values->Get(i), types->GetEnum<Any>(i))) {
+ return false;
+ }
+ }
+ return true;
+}
+
+inline void *AnyUnion::UnPack(const void *obj, Any type, const flatbuffers::resolver_function_t *resolver) {
+ (void)resolver;
+ switch (type) {
+ case Any_Monster: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ case Any_TestSimpleTableWithEnum: {
+ auto ptr = reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnum *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ case Any_MyGame_Example2_Monster: {
+ auto ptr = reinterpret_cast<const MyGame::Example2::Monster *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ default: return nullptr;
+ }
+}
+
+inline flatbuffers::Offset<void> AnyUnion::Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher) const {
+ (void)_rehasher;
+ switch (type) {
+ case Any_Monster: {
+ auto ptr = reinterpret_cast<const MyGame::Example::MonsterT *>(value);
+ return CreateMonster(_fbb, ptr, _rehasher).Union();
+ }
+ case Any_TestSimpleTableWithEnum: {
+ auto ptr = reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnumT *>(value);
+ return CreateTestSimpleTableWithEnum(_fbb, ptr, _rehasher).Union();
+ }
+ case Any_MyGame_Example2_Monster: {
+ auto ptr = reinterpret_cast<const MyGame::Example2::MonsterT *>(value);
+ return CreateMonster(_fbb, ptr, _rehasher).Union();
+ }
+ default: return 0;
+ }
+}
+
+inline AnyUnion::AnyUnion(const AnyUnion &u) : type(u.type), value(nullptr) {
+ switch (type) {
+ case Any_Monster: {
+ value = new MyGame::Example::MonsterT(*reinterpret_cast<MyGame::Example::MonsterT *>(u.value));
+ break;
+ }
+ case Any_TestSimpleTableWithEnum: {
+ value = new MyGame::Example::TestSimpleTableWithEnumT(*reinterpret_cast<MyGame::Example::TestSimpleTableWithEnumT *>(u.value));
+ break;
+ }
+ case Any_MyGame_Example2_Monster: {
+ value = new MyGame::Example2::MonsterT(*reinterpret_cast<MyGame::Example2::MonsterT *>(u.value));
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+inline void AnyUnion::Reset() {
+ switch (type) {
+ case Any_Monster: {
+ auto ptr = reinterpret_cast<MyGame::Example::MonsterT *>(value);
+ delete ptr;
+ break;
+ }
+ case Any_TestSimpleTableWithEnum: {
+ auto ptr = reinterpret_cast<MyGame::Example::TestSimpleTableWithEnumT *>(value);
+ delete ptr;
+ break;
+ }
+ case Any_MyGame_Example2_Monster: {
+ auto ptr = reinterpret_cast<MyGame::Example2::MonsterT *>(value);
+ delete ptr;
+ break;
+ }
+ default: break;
+ }
+ value = nullptr;
+ type = Any_NONE;
+}
+
+inline bool VerifyAnyUniqueAliases(flatbuffers::Verifier &verifier, const void *obj, AnyUniqueAliases type) {
+ switch (type) {
+ case AnyUniqueAliases_NONE: {
+ return true;
+ }
+ case AnyUniqueAliases_M: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ case AnyUniqueAliases_TS: {
+ auto ptr = reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnum *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ case AnyUniqueAliases_M2: {
+ auto ptr = reinterpret_cast<const MyGame::Example2::Monster *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ default: return true;
+ }
+}
+
+inline bool VerifyAnyUniqueAliasesVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types) {
+ if (!values || !types) return !values && !types;
+ if (values->size() != types->size()) return false;
+ for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
+ if (!VerifyAnyUniqueAliases(
+ verifier, values->Get(i), types->GetEnum<AnyUniqueAliases>(i))) {
+ return false;
+ }
+ }
+ return true;
+}
+
+inline void *AnyUniqueAliasesUnion::UnPack(const void *obj, AnyUniqueAliases type, const flatbuffers::resolver_function_t *resolver) {
+ (void)resolver;
+ switch (type) {
+ case AnyUniqueAliases_M: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ case AnyUniqueAliases_TS: {
+ auto ptr = reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnum *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ case AnyUniqueAliases_M2: {
+ auto ptr = reinterpret_cast<const MyGame::Example2::Monster *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ default: return nullptr;
+ }
+}
+
+inline flatbuffers::Offset<void> AnyUniqueAliasesUnion::Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher) const {
+ (void)_rehasher;
+ switch (type) {
+ case AnyUniqueAliases_M: {
+ auto ptr = reinterpret_cast<const MyGame::Example::MonsterT *>(value);
+ return CreateMonster(_fbb, ptr, _rehasher).Union();
+ }
+ case AnyUniqueAliases_TS: {
+ auto ptr = reinterpret_cast<const MyGame::Example::TestSimpleTableWithEnumT *>(value);
+ return CreateTestSimpleTableWithEnum(_fbb, ptr, _rehasher).Union();
+ }
+ case AnyUniqueAliases_M2: {
+ auto ptr = reinterpret_cast<const MyGame::Example2::MonsterT *>(value);
+ return CreateMonster(_fbb, ptr, _rehasher).Union();
+ }
+ default: return 0;
+ }
+}
+
+inline AnyUniqueAliasesUnion::AnyUniqueAliasesUnion(const AnyUniqueAliasesUnion &u) : type(u.type), value(nullptr) {
+ switch (type) {
+ case AnyUniqueAliases_M: {
+ value = new MyGame::Example::MonsterT(*reinterpret_cast<MyGame::Example::MonsterT *>(u.value));
+ break;
+ }
+ case AnyUniqueAliases_TS: {
+ value = new MyGame::Example::TestSimpleTableWithEnumT(*reinterpret_cast<MyGame::Example::TestSimpleTableWithEnumT *>(u.value));
+ break;
+ }
+ case AnyUniqueAliases_M2: {
+ value = new MyGame::Example2::MonsterT(*reinterpret_cast<MyGame::Example2::MonsterT *>(u.value));
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+inline void AnyUniqueAliasesUnion::Reset() {
+ switch (type) {
+ case AnyUniqueAliases_M: {
+ auto ptr = reinterpret_cast<MyGame::Example::MonsterT *>(value);
+ delete ptr;
+ break;
+ }
+ case AnyUniqueAliases_TS: {
+ auto ptr = reinterpret_cast<MyGame::Example::TestSimpleTableWithEnumT *>(value);
+ delete ptr;
+ break;
+ }
+ case AnyUniqueAliases_M2: {
+ auto ptr = reinterpret_cast<MyGame::Example2::MonsterT *>(value);
+ delete ptr;
+ break;
+ }
+ default: break;
+ }
+ value = nullptr;
+ type = AnyUniqueAliases_NONE;
+}
+
+inline bool VerifyAnyAmbiguousAliases(flatbuffers::Verifier &verifier, const void *obj, AnyAmbiguousAliases type) {
+ switch (type) {
+ case AnyAmbiguousAliases_NONE: {
+ return true;
+ }
+ case AnyAmbiguousAliases_M1: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ case AnyAmbiguousAliases_M2: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ case AnyAmbiguousAliases_M3: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ default: return true;
+ }
+}
+
+inline bool VerifyAnyAmbiguousAliasesVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types) {
+ if (!values || !types) return !values && !types;
+ if (values->size() != types->size()) return false;
+ for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
+ if (!VerifyAnyAmbiguousAliases(
+ verifier, values->Get(i), types->GetEnum<AnyAmbiguousAliases>(i))) {
+ return false;
+ }
+ }
+ return true;
+}
+
+inline void *AnyAmbiguousAliasesUnion::UnPack(const void *obj, AnyAmbiguousAliases type, const flatbuffers::resolver_function_t *resolver) {
+ (void)resolver;
+ switch (type) {
+ case AnyAmbiguousAliases_M1: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ case AnyAmbiguousAliases_M2: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ case AnyAmbiguousAliases_M3: {
+ auto ptr = reinterpret_cast<const MyGame::Example::Monster *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ default: return nullptr;
+ }
+}
+
+inline flatbuffers::Offset<void> AnyAmbiguousAliasesUnion::Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher) const {
+ (void)_rehasher;
+ switch (type) {
+ case AnyAmbiguousAliases_M1: {
+ auto ptr = reinterpret_cast<const MyGame::Example::MonsterT *>(value);
+ return CreateMonster(_fbb, ptr, _rehasher).Union();
+ }
+ case AnyAmbiguousAliases_M2: {
+ auto ptr = reinterpret_cast<const MyGame::Example::MonsterT *>(value);
+ return CreateMonster(_fbb, ptr, _rehasher).Union();
+ }
+ case AnyAmbiguousAliases_M3: {
+ auto ptr = reinterpret_cast<const MyGame::Example::MonsterT *>(value);
+ return CreateMonster(_fbb, ptr, _rehasher).Union();
+ }
+ default: return 0;
+ }
+}
+
+inline AnyAmbiguousAliasesUnion::AnyAmbiguousAliasesUnion(const AnyAmbiguousAliasesUnion &u) : type(u.type), value(nullptr) {
+ switch (type) {
+ case AnyAmbiguousAliases_M1: {
+ value = new MyGame::Example::MonsterT(*reinterpret_cast<MyGame::Example::MonsterT *>(u.value));
+ break;
+ }
+ case AnyAmbiguousAliases_M2: {
+ value = new MyGame::Example::MonsterT(*reinterpret_cast<MyGame::Example::MonsterT *>(u.value));
+ break;
+ }
+ case AnyAmbiguousAliases_M3: {
+ value = new MyGame::Example::MonsterT(*reinterpret_cast<MyGame::Example::MonsterT *>(u.value));
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+inline void AnyAmbiguousAliasesUnion::Reset() {
+ switch (type) {
+ case AnyAmbiguousAliases_M1: {
+ auto ptr = reinterpret_cast<MyGame::Example::MonsterT *>(value);
+ delete ptr;
+ break;
+ }
+ case AnyAmbiguousAliases_M2: {
+ auto ptr = reinterpret_cast<MyGame::Example::MonsterT *>(value);
+ delete ptr;
+ break;
+ }
+ case AnyAmbiguousAliases_M3: {
+ auto ptr = reinterpret_cast<MyGame::Example::MonsterT *>(value);
+ delete ptr;
+ break;
+ }
+ default: break;
+ }
+ value = nullptr;
+ type = AnyAmbiguousAliases_NONE;
+}
+
+inline const flatbuffers::TypeTable *ColorTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_UCHAR, 0, 0 },
+ { flatbuffers::ET_UCHAR, 0, 0 },
+ { flatbuffers::ET_UCHAR, 0, 0 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::ColorTypeTable
+ };
+ static const int64_t values[] = { 1, 2, 8 };
+ static const char * const names[] = {
+ "Red",
+ "Green",
+ "Blue"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_ENUM, 3, type_codes, type_refs, nullptr, values, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *RaceTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_CHAR, 0, 0 },
+ { flatbuffers::ET_CHAR, 0, 0 },
+ { flatbuffers::ET_CHAR, 0, 0 },
+ { flatbuffers::ET_CHAR, 0, 0 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::RaceTypeTable
+ };
+ static const int64_t values[] = { -1, 0, 1, 2 };
+ static const char * const names[] = {
+ "None",
+ "Human",
+ "Dwarf",
+ "Elf"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_ENUM, 4, type_codes, type_refs, nullptr, values, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *LongEnumTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_ULONG, 0, 0 },
+ { flatbuffers::ET_ULONG, 0, 0 },
+ { flatbuffers::ET_ULONG, 0, 0 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::LongEnumTypeTable
+ };
+ static const int64_t values[] = { 2ULL, 4ULL, 1099511627776ULL };
+ static const char * const names[] = {
+ "LongOne",
+ "LongTwo",
+ "LongBig"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_ENUM, 3, type_codes, type_refs, nullptr, values, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *AnyTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_SEQUENCE, 0, -1 },
+ { flatbuffers::ET_SEQUENCE, 0, 0 },
+ { flatbuffers::ET_SEQUENCE, 0, 1 },
+ { flatbuffers::ET_SEQUENCE, 0, 2 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::MonsterTypeTable,
+ MyGame::Example::TestSimpleTableWithEnumTypeTable,
+ MyGame::Example2::MonsterTypeTable
+ };
+ static const char * const names[] = {
+ "NONE",
+ "Monster",
+ "TestSimpleTableWithEnum",
+ "MyGame_Example2_Monster"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_UNION, 4, type_codes, type_refs, nullptr, nullptr, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *AnyUniqueAliasesTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_SEQUENCE, 0, -1 },
+ { flatbuffers::ET_SEQUENCE, 0, 0 },
+ { flatbuffers::ET_SEQUENCE, 0, 1 },
+ { flatbuffers::ET_SEQUENCE, 0, 2 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::MonsterTypeTable,
+ MyGame::Example::TestSimpleTableWithEnumTypeTable,
+ MyGame::Example2::MonsterTypeTable
+ };
+ static const char * const names[] = {
+ "NONE",
+ "M",
+ "TS",
+ "M2"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_UNION, 4, type_codes, type_refs, nullptr, nullptr, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *AnyAmbiguousAliasesTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_SEQUENCE, 0, -1 },
+ { flatbuffers::ET_SEQUENCE, 0, 0 },
+ { flatbuffers::ET_SEQUENCE, 0, 0 },
+ { flatbuffers::ET_SEQUENCE, 0, 0 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::MonsterTypeTable
+ };
+ static const char * const names[] = {
+ "NONE",
+ "M1",
+ "M2",
+ "M3"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_UNION, 4, type_codes, type_refs, nullptr, nullptr, names
+ };
+ return &tt;
+}
+
+} // namespace Example
+
+inline const flatbuffers::TypeTable *InParentNamespaceTypeTable() {
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_TABLE, 0, nullptr, nullptr, nullptr, nullptr, nullptr
+ };
+ return &tt;
+}
+
+namespace Example2 {
+
+inline const flatbuffers::TypeTable *MonsterTypeTable() {
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_TABLE, 0, nullptr, nullptr, nullptr, nullptr, nullptr
+ };
+ return &tt;
+}
+
+} // namespace Example2
+
+namespace Example {
+
+inline const flatbuffers::TypeTable *TestTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_SHORT, 0, -1 },
+ { flatbuffers::ET_CHAR, 0, -1 }
+ };
+ static const int64_t values[] = { 0, 2, 4 };
+ static const char * const names[] = {
+ "a",
+ "b"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_STRUCT, 2, type_codes, nullptr, nullptr, values, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *TestSimpleTableWithEnumTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_UCHAR, 0, 0 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::ColorTypeTable
+ };
+ static const char * const names[] = {
+ "color"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_TABLE, 1, type_codes, type_refs, nullptr, nullptr, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *Vec3TypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_FLOAT, 0, -1 },
+ { flatbuffers::ET_FLOAT, 0, -1 },
+ { flatbuffers::ET_FLOAT, 0, -1 },
+ { flatbuffers::ET_DOUBLE, 0, -1 },
+ { flatbuffers::ET_UCHAR, 0, 0 },
+ { flatbuffers::ET_SEQUENCE, 0, 1 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::ColorTypeTable,
+ MyGame::Example::TestTypeTable
+ };
+ static const int64_t values[] = { 0, 4, 8, 16, 24, 26, 32 };
+ static const char * const names[] = {
+ "x",
+ "y",
+ "z",
+ "test1",
+ "test2",
+ "test3"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_STRUCT, 6, type_codes, type_refs, nullptr, values, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *AbilityTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_UINT, 0, -1 },
+ { flatbuffers::ET_UINT, 0, -1 }
+ };
+ static const int64_t values[] = { 0, 4, 8 };
+ static const char * const names[] = {
+ "id",
+ "distance"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_STRUCT, 2, type_codes, nullptr, nullptr, values, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *StructOfStructsTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_SEQUENCE, 0, 0 },
+ { flatbuffers::ET_SEQUENCE, 0, 1 },
+ { flatbuffers::ET_SEQUENCE, 0, 0 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::AbilityTypeTable,
+ MyGame::Example::TestTypeTable
+ };
+ static const int64_t values[] = { 0, 8, 12, 20 };
+ static const char * const names[] = {
+ "a",
+ "b",
+ "c"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_STRUCT, 3, type_codes, type_refs, nullptr, values, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *StructOfStructsOfStructsTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_SEQUENCE, 0, 0 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::StructOfStructsTypeTable
+ };
+ static const int64_t values[] = { 0, 20 };
+ static const char * const names[] = {
+ "a"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_STRUCT, 1, type_codes, type_refs, nullptr, values, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *StatTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_STRING, 0, -1 },
+ { flatbuffers::ET_LONG, 0, -1 },
+ { flatbuffers::ET_USHORT, 0, -1 }
+ };
+ static const char * const names[] = {
+ "id",
+ "val",
+ "count"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_TABLE, 3, type_codes, nullptr, nullptr, nullptr, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *ReferrableTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_ULONG, 0, -1 }
+ };
+ static const char * const names[] = {
+ "id"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_TABLE, 1, type_codes, nullptr, nullptr, nullptr, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *MonsterTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_SEQUENCE, 0, 0 },
+ { flatbuffers::ET_SHORT, 0, -1 },
+ { flatbuffers::ET_SHORT, 0, -1 },
+ { flatbuffers::ET_STRING, 0, -1 },
+ { flatbuffers::ET_BOOL, 0, -1 },
+ { flatbuffers::ET_UCHAR, 1, -1 },
+ { flatbuffers::ET_UCHAR, 0, 1 },
+ { flatbuffers::ET_UTYPE, 0, 2 },
+ { flatbuffers::ET_SEQUENCE, 0, 2 },
+ { flatbuffers::ET_SEQUENCE, 1, 3 },
+ { flatbuffers::ET_STRING, 1, -1 },
+ { flatbuffers::ET_SEQUENCE, 1, 4 },
+ { flatbuffers::ET_SEQUENCE, 0, 4 },
+ { flatbuffers::ET_UCHAR, 1, -1 },
+ { flatbuffers::ET_SEQUENCE, 0, 5 },
+ { flatbuffers::ET_BOOL, 0, -1 },
+ { flatbuffers::ET_INT, 0, -1 },
+ { flatbuffers::ET_UINT, 0, -1 },
+ { flatbuffers::ET_LONG, 0, -1 },
+ { flatbuffers::ET_ULONG, 0, -1 },
+ { flatbuffers::ET_INT, 0, -1 },
+ { flatbuffers::ET_UINT, 0, -1 },
+ { flatbuffers::ET_LONG, 0, -1 },
+ { flatbuffers::ET_ULONG, 0, -1 },
+ { flatbuffers::ET_BOOL, 1, -1 },
+ { flatbuffers::ET_FLOAT, 0, -1 },
+ { flatbuffers::ET_FLOAT, 0, -1 },
+ { flatbuffers::ET_FLOAT, 0, -1 },
+ { flatbuffers::ET_STRING, 1, -1 },
+ { flatbuffers::ET_SEQUENCE, 1, 6 },
+ { flatbuffers::ET_UCHAR, 1, -1 },
+ { flatbuffers::ET_SEQUENCE, 1, 3 },
+ { flatbuffers::ET_LONG, 1, -1 },
+ { flatbuffers::ET_DOUBLE, 1, -1 },
+ { flatbuffers::ET_SEQUENCE, 0, 7 },
+ { flatbuffers::ET_SEQUENCE, 1, 8 },
+ { flatbuffers::ET_ULONG, 0, -1 },
+ { flatbuffers::ET_ULONG, 1, -1 },
+ { flatbuffers::ET_SEQUENCE, 1, 8 },
+ { flatbuffers::ET_ULONG, 0, -1 },
+ { flatbuffers::ET_ULONG, 1, -1 },
+ { flatbuffers::ET_ULONG, 0, -1 },
+ { flatbuffers::ET_ULONG, 1, -1 },
+ { flatbuffers::ET_UTYPE, 0, 9 },
+ { flatbuffers::ET_SEQUENCE, 0, 9 },
+ { flatbuffers::ET_UTYPE, 0, 10 },
+ { flatbuffers::ET_SEQUENCE, 0, 10 },
+ { flatbuffers::ET_UCHAR, 1, 1 },
+ { flatbuffers::ET_CHAR, 0, 11 },
+ { flatbuffers::ET_UCHAR, 1, -1 },
+ { flatbuffers::ET_SEQUENCE, 1, 5 },
+ { flatbuffers::ET_SEQUENCE, 0, 3 },
+ { flatbuffers::ET_ULONG, 0, 12 },
+ { flatbuffers::ET_ULONG, 0, 12 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ MyGame::Example::Vec3TypeTable,
+ MyGame::Example::ColorTypeTable,
+ MyGame::Example::AnyTypeTable,
+ MyGame::Example::TestTypeTable,
+ MyGame::Example::MonsterTypeTable,
+ MyGame::Example::StatTypeTable,
+ MyGame::Example::AbilityTypeTable,
+ MyGame::InParentNamespaceTypeTable,
+ MyGame::Example::ReferrableTypeTable,
+ MyGame::Example::AnyUniqueAliasesTypeTable,
+ MyGame::Example::AnyAmbiguousAliasesTypeTable,
+ MyGame::Example::RaceTypeTable,
+ MyGame::Example::LongEnumTypeTable
+ };
+ static const char * const names[] = {
+ "pos",
+ "mana",
+ "hp",
+ "name",
+ "friendly",
+ "inventory",
+ "color",
+ "test_type",
+ "test",
+ "test4",
+ "testarrayofstring",
+ "testarrayoftables",
+ "enemy",
+ "testnestedflatbuffer",
+ "testempty",
+ "testbool",
+ "testhashs32_fnv1",
+ "testhashu32_fnv1",
+ "testhashs64_fnv1",
+ "testhashu64_fnv1",
+ "testhashs32_fnv1a",
+ "testhashu32_fnv1a",
+ "testhashs64_fnv1a",
+ "testhashu64_fnv1a",
+ "testarrayofbools",
+ "testf",
+ "testf2",
+ "testf3",
+ "testarrayofstring2",
+ "testarrayofsortedstruct",
+ "flex",
+ "test5",
+ "vector_of_longs",
+ "vector_of_doubles",
+ "parent_namespace_test",
+ "vector_of_referrables",
+ "single_weak_reference",
+ "vector_of_weak_references",
+ "vector_of_strong_referrables",
+ "co_owning_reference",
+ "vector_of_co_owning_references",
+ "non_owning_reference",
+ "vector_of_non_owning_references",
+ "any_unique_type",
+ "any_unique",
+ "any_ambiguous_type",
+ "any_ambiguous",
+ "vector_of_enums",
+ "signed_enum",
+ "testrequirednestedflatbuffer",
+ "scalar_key_sorted_tables",
+ "native_inline",
+ "long_enum_non_enum_default",
+ "long_enum_normal_default"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_TABLE, 54, type_codes, type_refs, nullptr, nullptr, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *TypeAliasesTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_CHAR, 0, -1 },
+ { flatbuffers::ET_UCHAR, 0, -1 },
+ { flatbuffers::ET_SHORT, 0, -1 },
+ { flatbuffers::ET_USHORT, 0, -1 },
+ { flatbuffers::ET_INT, 0, -1 },
+ { flatbuffers::ET_UINT, 0, -1 },
+ { flatbuffers::ET_LONG, 0, -1 },
+ { flatbuffers::ET_ULONG, 0, -1 },
+ { flatbuffers::ET_FLOAT, 0, -1 },
+ { flatbuffers::ET_DOUBLE, 0, -1 },
+ { flatbuffers::ET_CHAR, 1, -1 },
+ { flatbuffers::ET_DOUBLE, 1, -1 }
+ };
+ static const char * const names[] = {
+ "i8",
+ "u8",
+ "i16",
+ "u16",
+ "i32",
+ "u32",
+ "i64",
+ "u64",
+ "f32",
+ "f64",
+ "v8",
+ "vf64"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_TABLE, 12, type_codes, nullptr, nullptr, nullptr, names
+ };
+ return &tt;
+}
+
+inline const MyGame::Example::Monster *GetMonster(const void *buf) {
+ return flatbuffers::GetRoot<MyGame::Example::Monster>(buf);
+}
+
+inline const MyGame::Example::Monster *GetSizePrefixedMonster(const void *buf) {
+ return flatbuffers::GetSizePrefixedRoot<MyGame::Example::Monster>(buf);
+}
+
+inline Monster *GetMutableMonster(void *buf) {
+ return flatbuffers::GetMutableRoot<Monster>(buf);
+}
+
+inline MyGame::Example::Monster *GetMutableSizePrefixedMonster(void *buf) {
+ return flatbuffers::GetMutableSizePrefixedRoot<MyGame::Example::Monster>(buf);
+}
+
+inline const char *MonsterIdentifier() {
+ return "MONS";
+}
+
+inline bool MonsterBufferHasIdentifier(const void *buf) {
+ return flatbuffers::BufferHasIdentifier(
+ buf, MonsterIdentifier());
+}
+
+inline bool SizePrefixedMonsterBufferHasIdentifier(const void *buf) {
+ return flatbuffers::BufferHasIdentifier(
+ buf, MonsterIdentifier(), true);
+}
+
+inline bool VerifyMonsterBuffer(
+ flatbuffers::Verifier &verifier) {
+ return verifier.VerifyBuffer<MyGame::Example::Monster>(MonsterIdentifier());
+}
+
+inline bool VerifySizePrefixedMonsterBuffer(
+ flatbuffers::Verifier &verifier) {
+ return verifier.VerifySizePrefixedBuffer<MyGame::Example::Monster>(MonsterIdentifier());
+}
+
+inline const char *MonsterExtension() {
+ return "mon";
+}
+
+inline void FinishMonsterBuffer(
+ flatbuffers::FlatBufferBuilder &fbb,
+ flatbuffers::Offset<MyGame::Example::Monster> root) {
+ fbb.Finish(root, MonsterIdentifier());
+}
+
+inline void FinishSizePrefixedMonsterBuffer(
+ flatbuffers::FlatBufferBuilder &fbb,
+ flatbuffers::Offset<MyGame::Example::Monster> root) {
+ fbb.FinishSizePrefixed(root, MonsterIdentifier());
+}
+
+inline flatbuffers::unique_ptr<MyGame::Example::MonsterT> UnPackMonster(
+ const void *buf,
+ const flatbuffers::resolver_function_t *res = nullptr) {
+ return flatbuffers::unique_ptr<MyGame::Example::MonsterT>(GetMonster(buf)->UnPack(res));
+}
+
+inline flatbuffers::unique_ptr<MyGame::Example::MonsterT> UnPackSizePrefixedMonster(
+ const void *buf,
+ const flatbuffers::resolver_function_t *res = nullptr) {
+ return flatbuffers::unique_ptr<MyGame::Example::MonsterT>(GetSizePrefixedMonster(buf)->UnPack(res));
+}
+
+} // namespace Example
+} // namespace MyGame
+
+#endif // FLATBUFFERS_GENERATED_MONSTERTEST_MYGAME_EXAMPLE_H_
diff --git a/tests/monsterdata_test.afb b/tests/monsterdata_test.afb
new file mode 100644
index 0000000..8e3c00f
--- /dev/null
+++ b/tests/monsterdata_test.afb
@@ -0,0 +1,276 @@
+// Annotated Flatbuffer Binary
+//
+// Schema file: monster_test.fbs
+// Binary file: monsterdata_test.mon
+
+header:
+ +0x0000 | 78 00 00 00 | UOffset32 | 0x00000078 (120) Loc: +0x0078 | offset to root table `MyGame.Example.Monster`
+ +0x0004 | 4D 4F 4E 53 | char[4] | MONS | File Identifier
+
+padding:
+ +0x0008 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vtable (MyGame.Example.Monster):
+ +0x000C | 6C 00 | uint16_t | 0x006C (108) | size of this vtable
+ +0x000E | 94 00 | uint16_t | 0x0094 (148) | size of referring table
+ +0x0010 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `pos` (id: 0)
+ +0x0012 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `mana` (id: 1) <defaults to 150> (Short)
+ +0x0014 | 06 00 | VOffset16 | 0x0006 (6) | offset to field `hp` (id: 2)
+ +0x0016 | 2C 00 | VOffset16 | 0x002C (44) | offset to field `name` (id: 3)
+ +0x0018 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `friendly` (id: 4) <defaults to 0> (Bool)
+ +0x001A | 30 00 | VOffset16 | 0x0030 (48) | offset to field `inventory` (id: 5)
+ +0x001C | 00 00 | VOffset16 | 0x0000 (0) | offset to field `color` (id: 6) <defaults to 8> (UByte)
+ +0x001E | 04 00 | VOffset16 | 0x0004 (4) | offset to field `test_type` (id: 7)
+ +0x0020 | 34 00 | VOffset16 | 0x0034 (52) | offset to field `test` (id: 8)
+ +0x0022 | 38 00 | VOffset16 | 0x0038 (56) | offset to field `test4` (id: 9)
+ +0x0024 | 3C 00 | VOffset16 | 0x003C (60) | offset to field `testarrayofstring` (id: 10)
+ +0x0026 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `testarrayoftables` (id: 11) <null> (Vector)
+ +0x0028 | 40 00 | VOffset16 | 0x0040 (64) | offset to field `enemy` (id: 12)
+ +0x002A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `testnestedflatbuffer` (id: 13) <null> (Vector)
+ +0x002C | 00 00 | VOffset16 | 0x0000 (0) | offset to field `testempty` (id: 14) <null> (Obj)
+ +0x002E | 05 00 | VOffset16 | 0x0005 (5) | offset to field `testbool` (id: 15)
+ +0x0030 | 44 00 | VOffset16 | 0x0044 (68) | offset to field `testhashs32_fnv1` (id: 16)
+ +0x0032 | 48 00 | VOffset16 | 0x0048 (72) | offset to field `testhashu32_fnv1` (id: 17)
+ +0x0034 | 70 00 | VOffset16 | 0x0070 (112) | offset to field `testhashs64_fnv1` (id: 18)
+ +0x0036 | 78 00 | VOffset16 | 0x0078 (120) | offset to field `testhashu64_fnv1` (id: 19)
+ +0x0038 | 4C 00 | VOffset16 | 0x004C (76) | offset to field `testhashs32_fnv1a` (id: 20)
+ +0x003A | 50 00 | VOffset16 | 0x0050 (80) | offset to field `testhashu32_fnv1a` (id: 21)
+ +0x003C | 80 00 | VOffset16 | 0x0080 (128) | offset to field `testhashs64_fnv1a` (id: 22)
+ +0x003E | 88 00 | VOffset16 | 0x0088 (136) | offset to field `testhashu64_fnv1a` (id: 23)
+ +0x0040 | 54 00 | VOffset16 | 0x0054 (84) | offset to field `testarrayofbools` (id: 24)
+ +0x0042 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `testf` (id: 25) <defaults to 3.141590> (Float)
+ +0x0044 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `testf2` (id: 26) <defaults to 3.000000> (Float)
+ +0x0046 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `testf3` (id: 27) <defaults to 0.000000> (Float)
+ +0x0048 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `testarrayofstring2` (id: 28) <null> (Vector)
+ +0x004A | 58 00 | VOffset16 | 0x0058 (88) | offset to field `testarrayofsortedstruct` (id: 29)
+ +0x004C | 00 00 | VOffset16 | 0x0000 (0) | offset to field `flex` (id: 30) <null> (Vector)
+ +0x004E | 5C 00 | VOffset16 | 0x005C (92) | offset to field `test5` (id: 31)
+ +0x0050 | 60 00 | VOffset16 | 0x0060 (96) | offset to field `vector_of_longs` (id: 32)
+ +0x0052 | 64 00 | VOffset16 | 0x0064 (100) | offset to field `vector_of_doubles` (id: 33)
+ +0x0054 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `parent_namespace_test` (id: 34) <null> (Obj)
+ +0x0056 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `vector_of_referrables` (id: 35) <null> (Vector)
+ +0x0058 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `single_weak_reference` (id: 36) <defaults to 0> (ULong)
+ +0x005A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `vector_of_weak_references` (id: 37) <null> (Vector)
+ +0x005C | 00 00 | VOffset16 | 0x0000 (0) | offset to field `vector_of_strong_referrables` (id: 38) <null> (Vector)
+ +0x005E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `co_owning_reference` (id: 39) <defaults to 0> (ULong)
+ +0x0060 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `vector_of_co_owning_references` (id: 40) <null> (Vector)
+ +0x0062 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `non_owning_reference` (id: 41) <defaults to 0> (ULong)
+ +0x0064 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `vector_of_non_owning_references` (id: 42) <null> (Vector)
+ +0x0066 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `any_unique_type` (id: 43) <defaults to 0> (UType)
+ +0x0068 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `any_unique` (id: 44) <null> (Union)
+ +0x006A | 00 00 | VOffset16 | 0x0000 (0) | offset to field `any_ambiguous_type` (id: 45) <defaults to 0> (UType)
+ +0x006C | 00 00 | VOffset16 | 0x0000 (0) | offset to field `any_ambiguous` (id: 46) <null> (Union)
+ +0x006E | 00 00 | VOffset16 | 0x0000 (0) | offset to field `vector_of_enums` (id: 47) <null> (Vector)
+ +0x0070 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `signed_enum` (id: 48) <defaults to -1> (Byte)
+ +0x0072 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `testrequirednestedflatbuffer` (id: 49) <null> (Vector)
+ +0x0074 | 68 00 | VOffset16 | 0x0068 (104) | offset to field `scalar_key_sorted_tables` (id: 50)
+ +0x0076 | 6C 00 | VOffset16 | 0x006C (108) | offset to field `native_inline` (id: 51)
+
+root_table (MyGame.Example.Monster):
+ +0x0078 | 6C 00 00 00 | SOffset32 | 0x0000006C (108) Loc: +0x000C | offset to vtable
+ +0x007C | 01 | UType8 | 0x01 (1) | table field `test_type` (UType)
+ +0x007D | 01 | uint8_t | 0x01 (1) | table field `testbool` (Bool)
+ +0x007E | 50 00 | int16_t | 0x0050 (80) | table field `hp` (Short)
+ +0x0080 | 00 00 80 3F | float | 0x3F800000 (1) | struct field `MyGame.Example.Vec3.x` (Float)
+ +0x0084 | 00 00 00 40 | float | 0x40000000 (2) | struct field `MyGame.Example.Vec3.y` (Float)
+ +0x0088 | 00 00 40 40 | float | 0x40400000 (3) | struct field `MyGame.Example.Vec3.z` (Float)
+ +0x008C | 00 00 00 00 | uint8_t[4] | .... | padding
+ +0x0090 | 00 00 00 00 00 00 08 40 | double | 0x4008000000000000 (3) | struct field `MyGame.Example.Vec3.test1` (Double)
+ +0x0098 | 02 | uint8_t | 0x02 (2) | struct field `MyGame.Example.Vec3.test2` (UByte)
+ +0x0099 | 00 | uint8_t[1] | . | padding
+ +0x009A | 05 00 | int16_t | 0x0005 (5) | struct field `MyGame.Example.Test.a` (Short)
+ +0x009C | 06 | uint8_t | 0x06 (6) | struct field `MyGame.Example.Test.b` (Byte)
+ +0x009D | 00 | uint8_t[1] | . | padding
+ +0x009E | 00 00 | uint8_t[2] | .. | padding
+ +0x00A0 | 00 00 00 00 | uint8_t[4] | .... | padding
+ +0x00A4 | A4 01 00 00 | UOffset32 | 0x000001A4 (420) Loc: +0x0248 | offset to field `name` (string)
+ +0x00A8 | 94 01 00 00 | UOffset32 | 0x00000194 (404) Loc: +0x023C | offset to field `inventory` (vector)
+ +0x00AC | 2C 01 00 00 | UOffset32 | 0x0000012C (300) Loc: +0x01D8 | offset to field `test` (union of type `Monster`)
+ +0x00B0 | 10 01 00 00 | UOffset32 | 0x00000110 (272) Loc: +0x01C0 | offset to field `test4` (vector)
+ +0x00B4 | DC 00 00 00 | UOffset32 | 0x000000DC (220) Loc: +0x0190 | offset to field `testarrayofstring` (vector)
+ +0x00B8 | C4 00 00 00 | UOffset32 | 0x000000C4 (196) Loc: +0x017C | offset to field `enemy` (table)
+ +0x00BC | 41 C9 79 DD | uint32_t | 0xDD79C941 (3715746113) | table field `testhashs32_fnv1` (Int)
+ +0x00C0 | 41 C9 79 DD | uint32_t | 0xDD79C941 (3715746113) | table field `testhashu32_fnv1` (UInt)
+ +0x00C4 | 71 A4 81 8E | uint32_t | 0x8E81A471 (2390860913) | table field `testhashs32_fnv1a` (Int)
+ +0x00C8 | 71 A4 81 8E | uint32_t | 0x8E81A471 (2390860913) | table field `testhashu32_fnv1a` (UInt)
+ +0x00CC | A8 00 00 00 | UOffset32 | 0x000000A8 (168) Loc: +0x0174 | offset to field `testarrayofbools` (vector)
+ +0x00D0 | 88 00 00 00 | UOffset32 | 0x00000088 (136) Loc: +0x0158 | offset to field `testarrayofsortedstruct` (vector)
+ +0x00D4 | E0 00 00 00 | UOffset32 | 0x000000E0 (224) Loc: +0x01B4 | offset to field `test5` (vector)
+ +0x00D8 | 34 01 00 00 | UOffset32 | 0x00000134 (308) Loc: +0x020C | offset to field `vector_of_longs` (vector)
+ +0x00DC | 10 01 00 00 | UOffset32 | 0x00000110 (272) Loc: +0x01EC | offset to field `vector_of_doubles` (vector)
+ +0x00E0 | 2C 00 00 00 | UOffset32 | 0x0000002C (44) Loc: +0x010C | offset to field `scalar_key_sorted_tables` (vector)
+ +0x00E4 | 01 00 | int16_t | 0x0001 (1) | struct field `MyGame.Example.Test.a` (Short)
+ +0x00E6 | 02 | uint8_t | 0x02 (2) | struct field `MyGame.Example.Test.b` (Byte)
+ +0x00E7 | 00 | uint8_t[1] | . | padding
+ +0x00E8 | 81 91 7B F2 CD 80 0F 6E | int64_t | 0x6E0F80CDF27B9181 (7930699090847568257) | table field `testhashs64_fnv1` (Long)
+ +0x00F0 | 81 91 7B F2 CD 80 0F 6E | uint64_t | 0x6E0F80CDF27B9181 (7930699090847568257) | table field `testhashu64_fnv1` (ULong)
+ +0x00F8 | F1 DD 67 C7 DC 48 F9 43 | int64_t | 0x43F948DCC767DDF1 (4898026182817603057) | table field `testhashs64_fnv1a` (Long)
+ +0x0100 | F1 DD 67 C7 DC 48 F9 43 | uint64_t | 0x43F948DCC767DDF1 (4898026182817603057) | table field `testhashu64_fnv1a` (ULong)
+ +0x0108 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (MyGame.Example.Monster.scalar_key_sorted_tables):
+ +0x010C | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x0110 | 10 00 00 00 | UOffset32 | 0x00000010 (16) Loc: +0x0120 | offset to table[0]
+ +0x0114 | 28 00 00 00 | UOffset32 | 0x00000028 (40) Loc: +0x013C | offset to table[1]
+
+padding:
+ +0x0118 | 00 00 | uint8_t[2] | .. | padding
+
+vtable (MyGame.Example.Stat):
+ +0x011A | 06 00 | uint16_t | 0x0006 (6) | size of this vtable
+ +0x011C | 08 00 | uint16_t | 0x0008 (8) | size of referring table
+ +0x011E | 04 00 | VOffset16 | 0x0004 (4) | offset to field `id` (id: 0)
+
+table (MyGame.Example.Stat):
+ +0x0120 | 06 00 00 00 | SOffset32 | 0x00000006 (6) Loc: +0x011A | offset to vtable
+ +0x0124 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0128 | offset to field `id` (string)
+
+string (MyGame.Example.Stat.id):
+ +0x0128 | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x012C | 6D 69 73 73 | char[4] | miss | string literal
+ +0x0130 | 00 | char | 0x00 (0) | string terminator
+
+vtable (MyGame.Example.Stat):
+ +0x0132 | 0A 00 | uint16_t | 0x000A (10) | size of this vtable
+ +0x0134 | 14 00 | uint16_t | 0x0014 (20) | size of referring table
+ +0x0136 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `id` (id: 0)
+ +0x0138 | 0C 00 | VOffset16 | 0x000C (12) | offset to field `val` (id: 1)
+ +0x013A | 06 00 | VOffset16 | 0x0006 (6) | offset to field `count` (id: 2)
+
+table (MyGame.Example.Stat):
+ +0x013C | 0A 00 00 00 | SOffset32 | 0x0000000A (10) Loc: +0x0132 | offset to vtable
+ +0x0140 | 00 00 | uint8_t[2] | .. | padding
+ +0x0142 | 01 00 | uint16_t | 0x0001 (1) | table field `count` (UShort)
+ +0x0144 | 0C 00 00 00 | UOffset32 | 0x0000000C (12) Loc: +0x0150 | offset to field `id` (string)
+ +0x0148 | 0A 00 00 00 00 00 00 00 | int64_t | 0x000000000000000A (10) | table field `val` (Long)
+
+string (MyGame.Example.Stat.id):
+ +0x0150 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of string
+ +0x0154 | 68 69 74 | char[3] | hit | string literal
+ +0x0157 | 00 | char | 0x00 (0) | string terminator
+
+vector (MyGame.Example.Monster.testarrayofsortedstruct):
+ +0x0158 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x015C | 00 00 00 00 | uint32_t | 0x00000000 (0) | struct field `MyGame.Example.Ability.id` (UInt)
+ +0x0160 | 2D 00 00 00 | uint32_t | 0x0000002D (45) | struct field `MyGame.Example.Ability.distance` (UInt)
+ +0x0164 | 01 00 00 00 | uint32_t | 0x00000001 (1) | struct field `MyGame.Example.Ability.id` (UInt)
+ +0x0168 | 15 00 00 00 | uint32_t | 0x00000015 (21) | struct field `MyGame.Example.Ability.distance` (UInt)
+ +0x016C | 05 00 00 00 | uint32_t | 0x00000005 (5) | struct field `MyGame.Example.Ability.id` (UInt)
+ +0x0170 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | struct field `MyGame.Example.Ability.distance` (UInt)
+
+vector (MyGame.Example.Monster.testarrayofbools):
+ +0x0174 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x0178 | 01 | uint8_t | 0x01 (1) | value[0]
+ +0x0179 | 00 | uint8_t | 0x00 (0) | value[1]
+ +0x017A | 01 | uint8_t | 0x01 (1) | value[2]
+
+table (MyGame.Example.Monster):
+ +0x017C | B0 FF FF FF | SOffset32 | 0xFFFFFFB0 (-80) Loc: +0x01CC | offset to vtable
+ +0x0180 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x0184 | offset to field `name` (string)
+
+string (MyGame.Example.Monster.name):
+ +0x0184 | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x0188 | 46 72 65 64 | char[4] | Fred | string literal
+ +0x018C | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x018D | 00 00 00 | uint8_t[3] | ... | padding
+
+vector (MyGame.Example.Monster.testarrayofstring):
+ +0x0190 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x0194 | 14 00 00 00 | UOffset32 | 0x00000014 (20) Loc: +0x01A8 | offset to string[0]
+ +0x0198 | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x019C | offset to string[1]
+
+string (MyGame.Example.Monster.testarrayofstring):
+ +0x019C | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x01A0 | 74 65 73 74 32 | char[5] | test2 | string literal
+ +0x01A5 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x01A6 | 00 00 | uint8_t[2] | .. | padding
+
+string (MyGame.Example.Monster.testarrayofstring):
+ +0x01A8 | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of string
+ +0x01AC | 74 65 73 74 31 | char[5] | test1 | string literal
+ +0x01B1 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x01B2 | 00 00 | uint8_t[2] | .. | padding
+
+vector (MyGame.Example.Monster.test5):
+ +0x01B4 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x01B8 | 0A 00 | int16_t | 0x000A (10) | struct field `MyGame.Example.Test.a` (Short)
+ +0x01BA | 14 | uint8_t | 0x14 (20) | struct field `MyGame.Example.Test.b` (Byte)
+ +0x01BB | 00 | uint8_t[1] | . | padding
+ +0x01BC | 1E 00 | int16_t | 0x001E (30) | struct field `MyGame.Example.Test.a` (Short)
+ +0x01BE | 28 | uint8_t | 0x28 (40) | struct field `MyGame.Example.Test.b` (Byte)
+ +0x01BF | 00 | uint8_t[1] | . | padding
+
+vector (MyGame.Example.Monster.test4):
+ +0x01C0 | 02 00 00 00 | uint32_t | 0x00000002 (2) | length of vector (# items)
+ +0x01C4 | 0A 00 | int16_t | 0x000A (10) | struct field `MyGame.Example.Test.a` (Short)
+ +0x01C6 | 14 | uint8_t | 0x14 (20) | struct field `MyGame.Example.Test.b` (Byte)
+ +0x01C7 | 00 | uint8_t[1] | . | padding
+ +0x01C8 | 1E 00 | int16_t | 0x001E (30) | struct field `MyGame.Example.Test.a` (Short)
+ +0x01CA | 28 | uint8_t | 0x28 (40) | struct field `MyGame.Example.Test.b` (Byte)
+ +0x01CB | 00 | uint8_t[1] | . | padding
+
+vtable (MyGame.Example.Monster):
+ +0x01CC | 0C 00 | uint16_t | 0x000C (12) | size of this vtable
+ +0x01CE | 08 00 | uint16_t | 0x0008 (8) | size of referring table
+ +0x01D0 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `pos` (id: 0) <null> (Obj)
+ +0x01D2 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `mana` (id: 1) <defaults to 150> (Short)
+ +0x01D4 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `hp` (id: 2) <defaults to 100> (Short)
+ +0x01D6 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `name` (id: 3)
+
+table (MyGame.Example.Monster):
+ +0x01D8 | 0C 00 00 00 | SOffset32 | 0x0000000C (12) Loc: +0x01CC | offset to vtable
+ +0x01DC | 04 00 00 00 | UOffset32 | 0x00000004 (4) Loc: +0x01E0 | offset to field `name` (string)
+
+string (MyGame.Example.Monster.name):
+ +0x01E0 | 04 00 00 00 | uint32_t | 0x00000004 (4) | length of string
+ +0x01E4 | 46 72 65 64 | char[4] | Fred | string literal
+ +0x01E8 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x01E9 | 00 00 00 | uint8_t[3] | ... | padding
+
+vector (MyGame.Example.Monster.vector_of_doubles):
+ +0x01EC | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+ +0x01F0 | FF FF FF FF FF FF EF FF | double | 0xFFEFFFFFFFFFFFFF (-1.79769e+308) | value[0]
+ +0x01F8 | 00 00 00 00 00 00 00 00 | double | 0x0000000000000000 (0) | value[1]
+ +0x0200 | FF FF FF FF FF FF EF 7F | double | 0x7FEFFFFFFFFFFFFF (1.79769e+308) | value[2]
+
+padding:
+ +0x0208 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (MyGame.Example.Monster.vector_of_longs):
+ +0x020C | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of vector (# items)
+ +0x0210 | 01 00 00 00 00 00 00 00 | int64_t | 0x0000000000000001 (1) | value[0]
+ +0x0218 | 64 00 00 00 00 00 00 00 | int64_t | 0x0000000000000064 (100) | value[1]
+ +0x0220 | 10 27 00 00 00 00 00 00 | int64_t | 0x0000000000002710 (10000) | value[2]
+ +0x0228 | 40 42 0F 00 00 00 00 00 | int64_t | 0x00000000000F4240 (1000000) | value[3]
+ +0x0230 | 00 E1 F5 05 00 00 00 00 | int64_t | 0x0000000005F5E100 (100000000) | value[4]
+
+padding:
+ +0x0238 | 00 00 00 00 | uint8_t[4] | .... | padding
+
+vector (MyGame.Example.Monster.inventory):
+ +0x023C | 05 00 00 00 | uint32_t | 0x00000005 (5) | length of vector (# items)
+ +0x0240 | 00 | uint8_t | 0x00 (0) | value[0]
+ +0x0241 | 01 | uint8_t | 0x01 (1) | value[1]
+ +0x0242 | 02 | uint8_t | 0x02 (2) | value[2]
+ +0x0243 | 03 | uint8_t | 0x03 (3) | value[3]
+ +0x0244 | 04 | uint8_t | 0x04 (4) | value[4]
+
+padding:
+ +0x0245 | 00 00 00 | uint8_t[3] | ... | padding
+
+string (MyGame.Example.Monster.name):
+ +0x0248 | 09 00 00 00 | uint32_t | 0x00000009 (9) | length of string
+ +0x024C | 4D 79 4D 6F 6E 73 74 65 | char[9] | MyMonste | string literal
+ +0x0254 | 72 | | r
+ +0x0255 | 00 | char | 0x00 (0) | string terminator
+
+padding:
+ +0x0256 | 00 00 | uint8_t[2] | .. | padding
diff --git a/tests/more_defaults/abc_generated.rs b/tests/more_defaults/abc_generated.rs
index 8622d9b..f2bdbad 100644
--- a/tests/more_defaults/abc_generated.rs
+++ b/tests/more_defaults/abc_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -42,8 +47,8 @@
}
}
}
-impl std::fmt::Debug for ABC {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for ABC {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
if let Some(name) = self.variant_name() {
f.write_str(name)
} else {
diff --git a/tests/more_defaults/mod.rs b/tests/more_defaults/mod.rs
index 639f8ac..940204d 100644
--- a/tests/more_defaults/mod.rs
+++ b/tests/more_defaults/mod.rs
@@ -1,4 +1,5 @@
// Automatically generated by the Flatbuffers compiler. Do not modify.
+// @generated
mod abc_generated;
pub use self::abc_generated::*;
mod more_defaults_generated;
diff --git a/tests/more_defaults/more_defaults_generated.rs b/tests/more_defaults/more_defaults_generated.rs
index 0a88105..27fa65c 100644
--- a/tests/more_defaults/more_defaults_generated.rs
+++ b/tests/more_defaults/more_defaults_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum MoreDefaultsOffset {}
@@ -194,8 +199,8 @@
}
}
-impl std::fmt::Debug for MoreDefaults<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for MoreDefaults<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("MoreDefaults");
ds.field("ints", &self.ints());
ds.field("floats", &self.floats());
diff --git a/tests/my-game/example/ability.js b/tests/my-game/example/ability.js
index 9fea3d6..4d7d3db 100644
--- a/tests/my-game/example/ability.js
+++ b/tests/my-game/example/ability.js
@@ -24,7 +24,7 @@
return true;
}
static getFullyQualifiedName() {
- return 'MyGame.Example.Ability';
+ return 'MyGame_Example_Ability';
}
static sizeOf() {
return 8;
diff --git a/tests/my-game/example/ability.ts b/tests/my-game/example/ability.ts
index 26395fb..36b0eb8 100644
--- a/tests/my-game/example/ability.ts
+++ b/tests/my-game/example/ability.ts
@@ -7,7 +7,7 @@
export class Ability {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
-__init(i:number, bb:flatbuffers.ByteBuffer):Ability {
+ __init(i:number, bb:flatbuffers.ByteBuffer):Ability {
this.bb_pos = i;
this.bb = bb;
return this;
@@ -32,7 +32,7 @@
}
static getFullyQualifiedName():string {
- return 'MyGame.Example.Ability';
+ return 'MyGame_Example_Ability';
}
static sizeOf():number {
diff --git a/tests/my-game/example/any-ambiguous-aliases.ts b/tests/my-game/example/any-ambiguous-aliases.ts
index 6687a41..fb308fc 100644
--- a/tests/my-game/example/any-ambiguous-aliases.ts
+++ b/tests/my-game/example/any-ambiguous-aliases.ts
@@ -3,7 +3,7 @@
import { Monster, MonsterT } from '../../my-game/example/monster';
-export enum AnyAmbiguousAliases{
+export enum AnyAmbiguousAliases {
NONE = 0,
M1 = 1,
M2 = 2,
@@ -36,4 +36,3 @@
default: return null;
}
}
-
diff --git a/tests/my-game/example/any-unique-aliases.js b/tests/my-game/example/any-unique-aliases.js
index b5cc882..98e5597 100644
--- a/tests/my-game/example/any-unique-aliases.js
+++ b/tests/my-game/example/any-unique-aliases.js
@@ -1,5 +1,5 @@
// automatically generated by the FlatBuffers compiler, do not modify
-import { Monster as MyGameExample2Monster } from '../../my-game/example2/monster';
+import { Monster as MyGame_Example2_Monster } from '../../my-game/example2/monster';
import { Monster } from '../../my-game/example/monster';
import { TestSimpleTableWithEnum } from '../../my-game/example/test-simple-table-with-enum';
export var AnyUniqueAliases;
@@ -14,7 +14,7 @@
case 'NONE': return null;
case 'M': return accessor(new Monster());
case 'TS': return accessor(new TestSimpleTableWithEnum());
- case 'M2': return accessor(new MyGameExample2Monster());
+ case 'M2': return accessor(new MyGame_Example2_Monster());
default: return null;
}
}
@@ -23,7 +23,7 @@
case 'NONE': return null;
case 'M': return accessor(index, new Monster());
case 'TS': return accessor(index, new TestSimpleTableWithEnum());
- case 'M2': return accessor(index, new MyGameExample2Monster());
+ case 'M2': return accessor(index, new MyGame_Example2_Monster());
default: return null;
}
}
diff --git a/tests/my-game/example/any-unique-aliases.ts b/tests/my-game/example/any-unique-aliases.ts
index 5106148..7ca769f 100644
--- a/tests/my-game/example/any-unique-aliases.ts
+++ b/tests/my-game/example/any-unique-aliases.ts
@@ -1,11 +1,11 @@
// automatically generated by the FlatBuffers compiler, do not modify
-import { Monster as MyGameExample2Monster, MonsterT as MyGameExample2MonsterT } from '../../my-game/example2/monster';
+import { Monster as MyGame_Example2_Monster, MonsterT as MyGame_Example2_MonsterT } from '../../my-game/example2/monster';
import { Monster, MonsterT } from '../../my-game/example/monster';
import { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from '../../my-game/example/test-simple-table-with-enum';
-export enum AnyUniqueAliases{
+export enum AnyUniqueAliases {
NONE = 0,
M = 1,
TS = 2,
@@ -14,28 +14,27 @@
export function unionToAnyUniqueAliases(
type: AnyUniqueAliases,
- accessor: (obj:Monster|MyGameExample2Monster|TestSimpleTableWithEnum) => Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null
-): Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null {
+ accessor: (obj:Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum) => Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null
+): Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null {
switch(AnyUniqueAliases[type]) {
case 'NONE': return null;
case 'M': return accessor(new Monster())! as Monster;
case 'TS': return accessor(new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum;
- case 'M2': return accessor(new MyGameExample2Monster())! as MyGameExample2Monster;
+ case 'M2': return accessor(new MyGame_Example2_Monster())! as MyGame_Example2_Monster;
default: return null;
}
}
export function unionListToAnyUniqueAliases(
type: AnyUniqueAliases,
- accessor: (index: number, obj:Monster|MyGameExample2Monster|TestSimpleTableWithEnum) => Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null,
+ accessor: (index: number, obj:Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum) => Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null,
index: number
-): Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null {
+): Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null {
switch(AnyUniqueAliases[type]) {
case 'NONE': return null;
case 'M': return accessor(index, new Monster())! as Monster;
case 'TS': return accessor(index, new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum;
- case 'M2': return accessor(index, new MyGameExample2Monster())! as MyGameExample2Monster;
+ case 'M2': return accessor(index, new MyGame_Example2_Monster())! as MyGame_Example2_Monster;
default: return null;
}
}
-
diff --git a/tests/my-game/example/any.js b/tests/my-game/example/any.js
index 7349c07..47bfb25 100644
--- a/tests/my-game/example/any.js
+++ b/tests/my-game/example/any.js
@@ -1,5 +1,5 @@
// automatically generated by the FlatBuffers compiler, do not modify
-import { Monster as MyGameExample2Monster } from '../../my-game/example2/monster';
+import { Monster as MyGame_Example2_Monster } from '../../my-game/example2/monster';
import { Monster } from '../../my-game/example/monster';
import { TestSimpleTableWithEnum } from '../../my-game/example/test-simple-table-with-enum';
export var Any;
@@ -14,7 +14,7 @@
case 'NONE': return null;
case 'Monster': return accessor(new Monster());
case 'TestSimpleTableWithEnum': return accessor(new TestSimpleTableWithEnum());
- case 'MyGame_Example2_Monster': return accessor(new MyGameExample2Monster());
+ case 'MyGame_Example2_Monster': return accessor(new MyGame_Example2_Monster());
default: return null;
}
}
@@ -23,7 +23,7 @@
case 'NONE': return null;
case 'Monster': return accessor(index, new Monster());
case 'TestSimpleTableWithEnum': return accessor(index, new TestSimpleTableWithEnum());
- case 'MyGame_Example2_Monster': return accessor(index, new MyGameExample2Monster());
+ case 'MyGame_Example2_Monster': return accessor(index, new MyGame_Example2_Monster());
default: return null;
}
}
diff --git a/tests/my-game/example/any.ts b/tests/my-game/example/any.ts
index 9d8b2a6..f7bb94f 100644
--- a/tests/my-game/example/any.ts
+++ b/tests/my-game/example/any.ts
@@ -1,11 +1,11 @@
// automatically generated by the FlatBuffers compiler, do not modify
-import { Monster as MyGameExample2Monster, MonsterT as MyGameExample2MonsterT } from '../../my-game/example2/monster';
+import { Monster as MyGame_Example2_Monster, MonsterT as MyGame_Example2_MonsterT } from '../../my-game/example2/monster';
import { Monster, MonsterT } from '../../my-game/example/monster';
import { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from '../../my-game/example/test-simple-table-with-enum';
-export enum Any{
+export enum Any {
NONE = 0,
Monster = 1,
TestSimpleTableWithEnum = 2,
@@ -14,28 +14,27 @@
export function unionToAny(
type: Any,
- accessor: (obj:Monster|MyGameExample2Monster|TestSimpleTableWithEnum) => Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null
-): Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null {
+ accessor: (obj:Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum) => Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null
+): Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null {
switch(Any[type]) {
case 'NONE': return null;
case 'Monster': return accessor(new Monster())! as Monster;
case 'TestSimpleTableWithEnum': return accessor(new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum;
- case 'MyGame_Example2_Monster': return accessor(new MyGameExample2Monster())! as MyGameExample2Monster;
+ case 'MyGame_Example2_Monster': return accessor(new MyGame_Example2_Monster())! as MyGame_Example2_Monster;
default: return null;
}
}
export function unionListToAny(
type: Any,
- accessor: (index: number, obj:Monster|MyGameExample2Monster|TestSimpleTableWithEnum) => Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null,
+ accessor: (index: number, obj:Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum) => Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null,
index: number
-): Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null {
+): Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null {
switch(Any[type]) {
case 'NONE': return null;
case 'Monster': return accessor(index, new Monster())! as Monster;
case 'TestSimpleTableWithEnum': return accessor(index, new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum;
- case 'MyGame_Example2_Monster': return accessor(index, new MyGameExample2Monster())! as MyGameExample2Monster;
+ case 'MyGame_Example2_Monster': return accessor(index, new MyGame_Example2_Monster())! as MyGame_Example2_Monster;
default: return null;
}
}
-
diff --git a/tests/my-game/example/color.ts b/tests/my-game/example/color.ts
index ceb31f8..8ce58da 100644
--- a/tests/my-game/example/color.ts
+++ b/tests/my-game/example/color.ts
@@ -3,7 +3,7 @@
/**
* Composite components of Monster color.
*/
-export enum Color{
+export enum Color {
Red = 1,
/**
@@ -17,4 +17,3 @@
*/
Blue = 8
}
-
diff --git a/tests/my-game/example/long-enum.ts b/tests/my-game/example/long-enum.ts
index be41819..31ea188 100644
--- a/tests/my-game/example/long-enum.ts
+++ b/tests/my-game/example/long-enum.ts
@@ -1,8 +1,7 @@
// automatically generated by the FlatBuffers compiler, do not modify
-export enum LongEnum{
+export enum LongEnum {
LongOne = '2',
LongTwo = '4',
LongBig = '1099511627776'
}
-
diff --git a/tests/my-game/example/monster.js b/tests/my-game/example/monster.js
index 3c3c23b..f9c8cca 100644
--- a/tests/my-game/example/monster.js
+++ b/tests/my-game/example/monster.js
@@ -527,7 +527,7 @@
return true;
}
static getFullyQualifiedName() {
- return 'MyGame.Example.Monster';
+ return 'MyGame_Example_Monster';
}
static startMonster(builder) {
builder.startObject(54);
diff --git a/tests/my-game/example/monster.ts b/tests/my-game/example/monster.ts
index c6cb33e..d65b7c3 100644
--- a/tests/my-game/example/monster.ts
+++ b/tests/my-game/example/monster.ts
@@ -2,7 +2,7 @@
import * as flatbuffers from 'flatbuffers';
-import { Monster as MyGameExample2Monster, MonsterT as MyGameExample2MonsterT } from '../../my-game/example2/monster';
+import { Monster as MyGame_Example2_Monster, MonsterT as MyGame_Example2_MonsterT } from '../../my-game/example2/monster';
import { Ability, AbilityT } from '../../my-game/example/ability';
import { Any, unionToAny, unionListToAny } from '../../my-game/example/any';
import { AnyAmbiguousAliases, unionToAnyAmbiguousAliases, unionListToAnyAmbiguousAliases } from '../../my-game/example/any-ambiguous-aliases';
@@ -23,7 +23,7 @@
export class Monster {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
-__init(i:number, bb:flatbuffers.ByteBuffer):Monster {
+ __init(i:number, bb:flatbuffers.ByteBuffer):Monster {
this.bb_pos = i;
this.bb = bb;
return this;
@@ -684,7 +684,7 @@
}
static getFullyQualifiedName():string {
- return 'MyGame.Example.Monster';
+ return 'MyGame_Example_Monster';
}
static startMonster(builder:flatbuffers.Builder) {
@@ -1296,7 +1296,7 @@
public inventory: (number)[] = [],
public color: Color = Color.Blue,
public testType: Any = Any.NONE,
- public test: MonsterT|MyGameExample2MonsterT|TestSimpleTableWithEnumT|null = null,
+ public test: MonsterT|MyGame_Example2_MonsterT|TestSimpleTableWithEnumT|null = null,
public test4: (TestT)[] = [],
public testarrayofstring: (string)[] = [],
public testarrayoftables: (MonsterT)[] = [],
@@ -1332,7 +1332,7 @@
public nonOwningReference: bigint = BigInt('0'),
public vectorOfNonOwningReferences: (bigint)[] = [],
public anyUniqueType: AnyUniqueAliases = AnyUniqueAliases.NONE,
- public anyUnique: MonsterT|MyGameExample2MonsterT|TestSimpleTableWithEnumT|null = null,
+ public anyUnique: MonsterT|MyGame_Example2_MonsterT|TestSimpleTableWithEnumT|null = null,
public anyAmbiguousType: AnyAmbiguousAliases = AnyAmbiguousAliases.NONE,
public anyAmbiguous: MonsterT|null = null,
public vectorOfEnums: (Color)[] = [],
diff --git a/tests/my-game/example/race.ts b/tests/my-game/example/race.ts
index 06ca128..8cb9654 100644
--- a/tests/my-game/example/race.ts
+++ b/tests/my-game/example/race.ts
@@ -1,9 +1,8 @@
// automatically generated by the FlatBuffers compiler, do not modify
-export enum Race{
+export enum Race {
None = -1,
Human = 0,
Dwarf = 1,
Elf = 2
}
-
diff --git a/tests/my-game/example/referrable.js b/tests/my-game/example/referrable.js
index 0370768..367034b 100644
--- a/tests/my-game/example/referrable.js
+++ b/tests/my-game/example/referrable.js
@@ -30,7 +30,7 @@
return true;
}
static getFullyQualifiedName() {
- return 'MyGame.Example.Referrable';
+ return 'MyGame_Example_Referrable';
}
static startReferrable(builder) {
builder.startObject(1);
diff --git a/tests/my-game/example/referrable.ts b/tests/my-game/example/referrable.ts
index fdac6c3..ec02980 100644
--- a/tests/my-game/example/referrable.ts
+++ b/tests/my-game/example/referrable.ts
@@ -7,7 +7,7 @@
export class Referrable {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
-__init(i:number, bb:flatbuffers.ByteBuffer):Referrable {
+ __init(i:number, bb:flatbuffers.ByteBuffer):Referrable {
this.bb_pos = i;
this.bb = bb;
return this;
@@ -39,7 +39,7 @@
}
static getFullyQualifiedName():string {
- return 'MyGame.Example.Referrable';
+ return 'MyGame_Example_Referrable';
}
static startReferrable(builder:flatbuffers.Builder) {
diff --git a/tests/my-game/example/stat.js b/tests/my-game/example/stat.js
index 46eec43..43b569f 100644
--- a/tests/my-game/example/stat.js
+++ b/tests/my-game/example/stat.js
@@ -46,7 +46,7 @@
return true;
}
static getFullyQualifiedName() {
- return 'MyGame.Example.Stat';
+ return 'MyGame_Example_Stat';
}
static startStat(builder) {
builder.startObject(3);
diff --git a/tests/my-game/example/stat.ts b/tests/my-game/example/stat.ts
index 0082ef8..e452599 100644
--- a/tests/my-game/example/stat.ts
+++ b/tests/my-game/example/stat.ts
@@ -7,7 +7,7 @@
export class Stat {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
-__init(i:number, bb:flatbuffers.ByteBuffer):Stat {
+ __init(i:number, bb:flatbuffers.ByteBuffer):Stat {
this.bb_pos = i;
this.bb = bb;
return this;
@@ -62,7 +62,7 @@
}
static getFullyQualifiedName():string {
- return 'MyGame.Example.Stat';
+ return 'MyGame_Example_Stat';
}
static startStat(builder:flatbuffers.Builder) {
diff --git a/tests/my-game/example/struct-of-structs-of-structs.ts b/tests/my-game/example/struct-of-structs-of-structs.ts
new file mode 100644
index 0000000..afe869f
--- /dev/null
+++ b/tests/my-game/example/struct-of-structs-of-structs.ts
@@ -0,0 +1,74 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+import { StructOfStructs, StructOfStructsT } from '../../my-game/example/struct-of-structs';
+
+
+export class StructOfStructsOfStructs {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):StructOfStructsOfStructs {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+a(obj?:StructOfStructs):StructOfStructs|null {
+ return (obj || new StructOfStructs()).__init(this.bb_pos, this.bb!);
+}
+
+static getFullyQualifiedName():string {
+ return 'MyGame_Example_StructOfStructsOfStructs';
+}
+
+static sizeOf():number {
+ return 20;
+}
+
+static createStructOfStructsOfStructs(builder:flatbuffers.Builder, a_a_id: number, a_a_distance: number, a_b_a: number, a_b_b: number, a_c_id: number, a_c_distance: number):flatbuffers.Offset {
+ builder.prep(4, 20);
+ builder.prep(4, 20);
+ builder.prep(4, 8);
+ builder.writeInt32(a_c_distance);
+ builder.writeInt32(a_c_id);
+ builder.prep(2, 4);
+ builder.pad(1);
+ builder.writeInt8(a_b_b);
+ builder.writeInt16(a_b_a);
+ builder.prep(4, 8);
+ builder.writeInt32(a_a_distance);
+ builder.writeInt32(a_a_id);
+ return builder.offset();
+}
+
+
+unpack(): StructOfStructsOfStructsT {
+ return new StructOfStructsOfStructsT(
+ (this.a() !== null ? this.a()!.unpack() : null)
+ );
+}
+
+
+unpackTo(_o: StructOfStructsOfStructsT): void {
+ _o.a = (this.a() !== null ? this.a()!.unpack() : null);
+}
+}
+
+export class StructOfStructsOfStructsT {
+constructor(
+ public a: StructOfStructsT|null = null
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ return StructOfStructsOfStructs.createStructOfStructsOfStructs(builder,
+ (this.a?.a?.id ?? 0),
+ (this.a?.a?.distance ?? 0),
+ (this.a?.b?.a ?? 0),
+ (this.a?.b?.b ?? 0),
+ (this.a?.c?.id ?? 0),
+ (this.a?.c?.distance ?? 0)
+ );
+}
+}
diff --git a/tests/my-game/example/struct-of-structs.js b/tests/my-game/example/struct-of-structs.js
index 2debc29..09c7910 100644
--- a/tests/my-game/example/struct-of-structs.js
+++ b/tests/my-game/example/struct-of-structs.js
@@ -21,7 +21,7 @@
return (obj || new Ability()).__init(this.bb_pos + 12, this.bb);
}
static getFullyQualifiedName() {
- return 'MyGame.Example.StructOfStructs';
+ return 'MyGame_Example_StructOfStructs';
}
static sizeOf() {
return 20;
@@ -56,6 +56,7 @@
this.c = c;
}
pack(builder) {
- return StructOfStructs.createStructOfStructs(builder, (this.a === null ? 0 : this.a.id), (this.a === null ? 0 : this.a.distance), (this.b === null ? 0 : this.b.a), (this.b === null ? 0 : this.b.b), (this.c === null ? 0 : this.c.id), (this.c === null ? 0 : this.c.distance));
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
+ return StructOfStructs.createStructOfStructs(builder, ((_b = (_a = this.a) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : 0), ((_d = (_c = this.a) === null || _c === void 0 ? void 0 : _c.distance) !== null && _d !== void 0 ? _d : 0), ((_f = (_e = this.b) === null || _e === void 0 ? void 0 : _e.a) !== null && _f !== void 0 ? _f : 0), ((_h = (_g = this.b) === null || _g === void 0 ? void 0 : _g.b) !== null && _h !== void 0 ? _h : 0), ((_k = (_j = this.c) === null || _j === void 0 ? void 0 : _j.id) !== null && _k !== void 0 ? _k : 0), ((_m = (_l = this.c) === null || _l === void 0 ? void 0 : _l.distance) !== null && _m !== void 0 ? _m : 0));
}
}
diff --git a/tests/my-game/example/struct-of-structs.ts b/tests/my-game/example/struct-of-structs.ts
index 11eca7e..0cb87de 100644
--- a/tests/my-game/example/struct-of-structs.ts
+++ b/tests/my-game/example/struct-of-structs.ts
@@ -9,7 +9,7 @@
export class StructOfStructs {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
-__init(i:number, bb:flatbuffers.ByteBuffer):StructOfStructs {
+ __init(i:number, bb:flatbuffers.ByteBuffer):StructOfStructs {
this.bb_pos = i;
this.bb = bb;
return this;
@@ -28,7 +28,7 @@
}
static getFullyQualifiedName():string {
- return 'MyGame.Example.StructOfStructs';
+ return 'MyGame_Example_StructOfStructs';
}
static sizeOf():number {
@@ -77,12 +77,12 @@
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return StructOfStructs.createStructOfStructs(builder,
- (this.a === null ? 0 : this.a.id!),
- (this.a === null ? 0 : this.a.distance!),
- (this.b === null ? 0 : this.b.a!),
- (this.b === null ? 0 : this.b.b!),
- (this.c === null ? 0 : this.c.id!),
- (this.c === null ? 0 : this.c.distance!)
+ (this.a?.id ?? 0),
+ (this.a?.distance ?? 0),
+ (this.b?.a ?? 0),
+ (this.b?.b ?? 0),
+ (this.c?.id ?? 0),
+ (this.c?.distance ?? 0)
);
}
}
diff --git a/tests/my-game/example/test-simple-table-with-enum.js b/tests/my-game/example/test-simple-table-with-enum.js
index b56bda4..a31d011 100644
--- a/tests/my-game/example/test-simple-table-with-enum.js
+++ b/tests/my-game/example/test-simple-table-with-enum.js
@@ -31,7 +31,7 @@
return true;
}
static getFullyQualifiedName() {
- return 'MyGame.Example.TestSimpleTableWithEnum';
+ return 'MyGame_Example_TestSimpleTableWithEnum';
}
static startTestSimpleTableWithEnum(builder) {
builder.startObject(1);
diff --git a/tests/my-game/example/test-simple-table-with-enum.ts b/tests/my-game/example/test-simple-table-with-enum.ts
index 99a541f..86a19aa 100644
--- a/tests/my-game/example/test-simple-table-with-enum.ts
+++ b/tests/my-game/example/test-simple-table-with-enum.ts
@@ -8,7 +8,7 @@
export class TestSimpleTableWithEnum {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
-__init(i:number, bb:flatbuffers.ByteBuffer):TestSimpleTableWithEnum {
+ __init(i:number, bb:flatbuffers.ByteBuffer):TestSimpleTableWithEnum {
this.bb_pos = i;
this.bb = bb;
return this;
@@ -40,7 +40,7 @@
}
static getFullyQualifiedName():string {
- return 'MyGame.Example.TestSimpleTableWithEnum';
+ return 'MyGame_Example_TestSimpleTableWithEnum';
}
static startTestSimpleTableWithEnum(builder:flatbuffers.Builder) {
diff --git a/tests/my-game/example/test.js b/tests/my-game/example/test.js
index ba6ebfb..9c43619 100644
--- a/tests/my-game/example/test.js
+++ b/tests/my-game/example/test.js
@@ -24,7 +24,7 @@
return true;
}
static getFullyQualifiedName() {
- return 'MyGame.Example.Test';
+ return 'MyGame_Example_Test';
}
static sizeOf() {
return 4;
diff --git a/tests/my-game/example/test.ts b/tests/my-game/example/test.ts
index afed125..b3d84ee 100644
--- a/tests/my-game/example/test.ts
+++ b/tests/my-game/example/test.ts
@@ -7,7 +7,7 @@
export class Test {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
-__init(i:number, bb:flatbuffers.ByteBuffer):Test {
+ __init(i:number, bb:flatbuffers.ByteBuffer):Test {
this.bb_pos = i;
this.bb = bb;
return this;
@@ -32,7 +32,7 @@
}
static getFullyQualifiedName():string {
- return 'MyGame.Example.Test';
+ return 'MyGame_Example_Test';
}
static sizeOf():number {
diff --git a/tests/my-game/example/type-aliases.js b/tests/my-game/example/type-aliases.js
index f26f226..a4b5f89 100644
--- a/tests/my-game/example/type-aliases.js
+++ b/tests/my-game/example/type-aliases.js
@@ -162,7 +162,7 @@
return offset ? new Float64Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
}
static getFullyQualifiedName() {
- return 'MyGame.Example.TypeAliases';
+ return 'MyGame_Example_TypeAliases';
}
static startTypeAliases(builder) {
builder.startObject(12);
diff --git a/tests/my-game/example/type-aliases.ts b/tests/my-game/example/type-aliases.ts
index edb4567..805c8cf 100644
--- a/tests/my-game/example/type-aliases.ts
+++ b/tests/my-game/example/type-aliases.ts
@@ -7,7 +7,7 @@
export class TypeAliases {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
-__init(i:number, bb:flatbuffers.ByteBuffer):TypeAliases {
+ __init(i:number, bb:flatbuffers.ByteBuffer):TypeAliases {
this.bb_pos = i;
this.bb = bb;
return this;
@@ -213,7 +213,7 @@
}
static getFullyQualifiedName():string {
- return 'MyGame.Example.TypeAliases';
+ return 'MyGame_Example_TypeAliases';
}
static startTypeAliases(builder:flatbuffers.Builder) {
diff --git a/tests/my-game/example/vec3.js b/tests/my-game/example/vec3.js
index 5fd2447..82b2eab 100644
--- a/tests/my-game/example/vec3.js
+++ b/tests/my-game/example/vec3.js
@@ -49,7 +49,7 @@
return (obj || new Test()).__init(this.bb_pos + 26, this.bb);
}
static getFullyQualifiedName() {
- return 'MyGame.Example.Vec3';
+ return 'MyGame_Example_Vec3';
}
static sizeOf() {
return 32;
@@ -92,6 +92,7 @@
this.test3 = test3;
}
pack(builder) {
- return Vec3.createVec3(builder, this.x, this.y, this.z, this.test1, this.test2, (this.test3 === null ? 0 : this.test3.a), (this.test3 === null ? 0 : this.test3.b));
+ var _a, _b, _c, _d;
+ return Vec3.createVec3(builder, this.x, this.y, this.z, this.test1, this.test2, ((_b = (_a = this.test3) === null || _a === void 0 ? void 0 : _a.a) !== null && _b !== void 0 ? _b : 0), ((_d = (_c = this.test3) === null || _c === void 0 ? void 0 : _c.b) !== null && _d !== void 0 ? _d : 0));
}
}
diff --git a/tests/my-game/example/vec3.ts b/tests/my-game/example/vec3.ts
index 9756977..3c692e2 100644
--- a/tests/my-game/example/vec3.ts
+++ b/tests/my-game/example/vec3.ts
@@ -9,7 +9,7 @@
export class Vec3 {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
-__init(i:number, bb:flatbuffers.ByteBuffer):Vec3 {
+ __init(i:number, bb:flatbuffers.ByteBuffer):Vec3 {
this.bb_pos = i;
this.bb = bb;
return this;
@@ -65,7 +65,7 @@
}
static getFullyQualifiedName():string {
- return 'MyGame.Example.Vec3';
+ return 'MyGame_Example_Vec3';
}
static sizeOf():number {
@@ -130,8 +130,8 @@
this.z,
this.test1,
this.test2,
- (this.test3 === null ? 0 : this.test3.a!),
- (this.test3 === null ? 0 : this.test3.b!)
+ (this.test3?.a ?? 0),
+ (this.test3?.b ?? 0)
);
}
}
diff --git a/tests/my-game/example2/monster.js b/tests/my-game/example2/monster.js
index 17f02b1..f50a2c8 100644
--- a/tests/my-game/example2/monster.js
+++ b/tests/my-game/example2/monster.js
@@ -18,7 +18,7 @@
return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getFullyQualifiedName() {
- return 'MyGame.Example2.Monster';
+ return 'MyGame_Example2_Monster';
}
static startMonster(builder) {
builder.startObject(0);
diff --git a/tests/my-game/example2/monster.ts b/tests/my-game/example2/monster.ts
index 14d7685..7240476 100644
--- a/tests/my-game/example2/monster.ts
+++ b/tests/my-game/example2/monster.ts
@@ -7,7 +7,7 @@
export class Monster {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
-__init(i:number, bb:flatbuffers.ByteBuffer):Monster {
+ __init(i:number, bb:flatbuffers.ByteBuffer):Monster {
this.bb_pos = i;
this.bb = bb;
return this;
@@ -23,7 +23,7 @@
}
static getFullyQualifiedName():string {
- return 'MyGame.Example2.Monster';
+ return 'MyGame_Example2_Monster';
}
static startMonster(builder:flatbuffers.Builder) {
diff --git a/tests/my-game/in-parent-namespace.js b/tests/my-game/in-parent-namespace.js
index 4881741..24b0ed7 100644
--- a/tests/my-game/in-parent-namespace.js
+++ b/tests/my-game/in-parent-namespace.js
@@ -18,7 +18,7 @@
return (obj || new InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getFullyQualifiedName() {
- return 'MyGame.InParentNamespace';
+ return 'MyGame_InParentNamespace';
}
static startInParentNamespace(builder) {
builder.startObject(0);
diff --git a/tests/my-game/in-parent-namespace.ts b/tests/my-game/in-parent-namespace.ts
index 8cfe9b6..0de94df 100644
--- a/tests/my-game/in-parent-namespace.ts
+++ b/tests/my-game/in-parent-namespace.ts
@@ -7,7 +7,7 @@
export class InParentNamespace {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
-__init(i:number, bb:flatbuffers.ByteBuffer):InParentNamespace {
+ __init(i:number, bb:flatbuffers.ByteBuffer):InParentNamespace {
this.bb_pos = i;
this.bb = bb;
return this;
@@ -23,7 +23,7 @@
}
static getFullyQualifiedName():string {
- return 'MyGame.InParentNamespace';
+ return 'MyGame_InParentNamespace';
}
static startInParentNamespace(builder:flatbuffers.Builder) {
diff --git a/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.cs b/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.cs
index 0ed6a63..2874a27 100644
--- a/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.cs
+++ b/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.cs
@@ -7,7 +7,7 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
public struct StructInNestedNS : IFlatbufferObject
{
diff --git a/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.cs b/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.cs
index 9e67112..fab8e02 100644
--- a/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.cs
+++ b/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.cs
@@ -7,13 +7,13 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
public struct TableInNestedNS : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
- public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_8(); }
public static TableInNestedNS GetRootAsTableInNestedNS(ByteBuffer _bb) { return GetRootAsTableInNestedNS(_bb, new TableInNestedNS()); }
public static TableInNestedNS GetRootAsTableInNestedNS(ByteBuffer _bb, TableInNestedNS obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public void __init(int _i, ByteBuffer _bb) { __p = new Table(_i, _bb); }
diff --git a/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.java b/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.java
index 45e4974..e185e4b 100644
--- a/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.java
+++ b/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.java
@@ -9,7 +9,7 @@
@SuppressWarnings("unused")
public final class TableInNestedNS extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static TableInNestedNS getRootAsTableInNestedNS(ByteBuffer _bb) { return getRootAsTableInNestedNS(_bb, new TableInNestedNS()); }
public static TableInNestedNS getRootAsTableInNestedNS(ByteBuffer _bb, TableInNestedNS obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
diff --git a/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.kt b/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.kt
index cb4cc10..0fbbba8 100644
--- a/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.kt
+++ b/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.kt
@@ -32,7 +32,7 @@
}
}
companion object {
- fun validateVersion() = Constants.FLATBUFFERS_2_0_0()
+ fun validateVersion() = Constants.FLATBUFFERS_2_0_8()
fun getRootAsTableInNestedNS(_bb: ByteBuffer): TableInNestedNS = getRootAsTableInNestedNS(_bb, TableInNestedNS())
fun getRootAsTableInNestedNS(_bb: ByteBuffer, obj: TableInNestedNS): TableInNestedNS {
_bb.order(ByteOrder.LITTLE_ENDIAN)
diff --git a/tests/namespace_test/NamespaceA/NamespaceB/UnionInNestedNS.cs b/tests/namespace_test/NamespaceA/NamespaceB/UnionInNestedNS.cs
index 7d1234f..08bc431 100644
--- a/tests/namespace_test/NamespaceA/NamespaceB/UnionInNestedNS.cs
+++ b/tests/namespace_test/NamespaceA/NamespaceB/UnionInNestedNS.cs
@@ -25,7 +25,7 @@
public NamespaceA.NamespaceB.TableInNestedNST AsTableInNestedNS() { return this.As<NamespaceA.NamespaceB.TableInNestedNST>(); }
public static UnionInNestedNSUnion FromTableInNestedNS(NamespaceA.NamespaceB.TableInNestedNST _tableinnestedns) { return new UnionInNestedNSUnion{ Type = UnionInNestedNS.TableInNestedNS, Value = _tableinnestedns }; }
- public static int Pack(FlatBuffers.FlatBufferBuilder builder, UnionInNestedNSUnion _o) {
+ public static int Pack(Google.FlatBuffers.FlatBufferBuilder builder, UnionInNestedNSUnion _o) {
switch (_o.Type) {
default: return 0;
case UnionInNestedNS.TableInNestedNS: return NamespaceA.NamespaceB.TableInNestedNS.Pack(builder, _o.AsTableInNestedNS()).Value;
diff --git a/tests/namespace_test/NamespaceA/SecondTableInA.cs b/tests/namespace_test/NamespaceA/SecondTableInA.cs
index 6e7ef88..9db2226 100644
--- a/tests/namespace_test/NamespaceA/SecondTableInA.cs
+++ b/tests/namespace_test/NamespaceA/SecondTableInA.cs
@@ -7,13 +7,13 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
public struct SecondTableInA : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
- public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_8(); }
public static SecondTableInA GetRootAsSecondTableInA(ByteBuffer _bb) { return GetRootAsSecondTableInA(_bb, new SecondTableInA()); }
public static SecondTableInA GetRootAsSecondTableInA(ByteBuffer _bb, SecondTableInA obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public void __init(int _i, ByteBuffer _bb) { __p = new Table(_i, _bb); }
diff --git a/tests/namespace_test/NamespaceA/SecondTableInA.java b/tests/namespace_test/NamespaceA/SecondTableInA.java
index ff539ab..f2e65d4 100644
--- a/tests/namespace_test/NamespaceA/SecondTableInA.java
+++ b/tests/namespace_test/NamespaceA/SecondTableInA.java
@@ -9,7 +9,7 @@
@SuppressWarnings("unused")
public final class SecondTableInA extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static SecondTableInA getRootAsSecondTableInA(ByteBuffer _bb) { return getRootAsSecondTableInA(_bb, new SecondTableInA()); }
public static SecondTableInA getRootAsSecondTableInA(ByteBuffer _bb, SecondTableInA obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
diff --git a/tests/namespace_test/NamespaceA/SecondTableInA.kt b/tests/namespace_test/NamespaceA/SecondTableInA.kt
index a516070..50d02df 100644
--- a/tests/namespace_test/NamespaceA/SecondTableInA.kt
+++ b/tests/namespace_test/NamespaceA/SecondTableInA.kt
@@ -27,7 +27,7 @@
}
}
companion object {
- fun validateVersion() = Constants.FLATBUFFERS_2_0_0()
+ fun validateVersion() = Constants.FLATBUFFERS_2_0_8()
fun getRootAsSecondTableInA(_bb: ByteBuffer): SecondTableInA = getRootAsSecondTableInA(_bb, SecondTableInA())
fun getRootAsSecondTableInA(_bb: ByteBuffer, obj: SecondTableInA): SecondTableInA {
_bb.order(ByteOrder.LITTLE_ENDIAN)
diff --git a/tests/namespace_test/NamespaceA/TableInFirstNS.cs b/tests/namespace_test/NamespaceA/TableInFirstNS.cs
index 6522f49..ad72eee 100644
--- a/tests/namespace_test/NamespaceA/TableInFirstNS.cs
+++ b/tests/namespace_test/NamespaceA/TableInFirstNS.cs
@@ -7,13 +7,13 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
public struct TableInFirstNS : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
- public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_8(); }
public static TableInFirstNS GetRootAsTableInFirstNS(ByteBuffer _bb) { return GetRootAsTableInFirstNS(_bb, new TableInFirstNS()); }
public static TableInFirstNS GetRootAsTableInFirstNS(ByteBuffer _bb, TableInFirstNS obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public void __init(int _i, ByteBuffer _bb) { __p = new Table(_i, _bb); }
diff --git a/tests/namespace_test/NamespaceA/TableInFirstNS.java b/tests/namespace_test/NamespaceA/TableInFirstNS.java
index 2fdfec8..809ece2 100644
--- a/tests/namespace_test/NamespaceA/TableInFirstNS.java
+++ b/tests/namespace_test/NamespaceA/TableInFirstNS.java
@@ -9,7 +9,7 @@
@SuppressWarnings("unused")
public final class TableInFirstNS extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static TableInFirstNS getRootAsTableInFirstNS(ByteBuffer _bb) { return getRootAsTableInFirstNS(_bb, new TableInFirstNS()); }
public static TableInFirstNS getRootAsTableInFirstNS(ByteBuffer _bb, TableInFirstNS obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
diff --git a/tests/namespace_test/NamespaceA/TableInFirstNS.kt b/tests/namespace_test/NamespaceA/TableInFirstNS.kt
index bec3319..4ae9368 100644
--- a/tests/namespace_test/NamespaceA/TableInFirstNS.kt
+++ b/tests/namespace_test/NamespaceA/TableInFirstNS.kt
@@ -67,7 +67,7 @@
}
}
companion object {
- fun validateVersion() = Constants.FLATBUFFERS_2_0_0()
+ fun validateVersion() = Constants.FLATBUFFERS_2_0_8()
fun getRootAsTableInFirstNS(_bb: ByteBuffer): TableInFirstNS = getRootAsTableInFirstNS(_bb, TableInFirstNS())
fun getRootAsTableInFirstNS(_bb: ByteBuffer, obj: TableInFirstNS): TableInFirstNS {
_bb.order(ByteOrder.LITTLE_ENDIAN)
diff --git a/tests/namespace_test/NamespaceC/TableInC.cs b/tests/namespace_test/NamespaceC/TableInC.cs
index 2077e32..50ca3e4 100644
--- a/tests/namespace_test/NamespaceC/TableInC.cs
+++ b/tests/namespace_test/NamespaceC/TableInC.cs
@@ -7,13 +7,13 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
public struct TableInC : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
- public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_8(); }
public static TableInC GetRootAsTableInC(ByteBuffer _bb) { return GetRootAsTableInC(_bb, new TableInC()); }
public static TableInC GetRootAsTableInC(ByteBuffer _bb, TableInC obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public void __init(int _i, ByteBuffer _bb) { __p = new Table(_i, _bb); }
diff --git a/tests/namespace_test/NamespaceC/TableInC.java b/tests/namespace_test/NamespaceC/TableInC.java
index 04ceac7..7af7620 100644
--- a/tests/namespace_test/NamespaceC/TableInC.java
+++ b/tests/namespace_test/NamespaceC/TableInC.java
@@ -9,7 +9,7 @@
@SuppressWarnings("unused")
public final class TableInC extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static TableInC getRootAsTableInC(ByteBuffer _bb) { return getRootAsTableInC(_bb, new TableInC()); }
public static TableInC getRootAsTableInC(ByteBuffer _bb, TableInC obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
diff --git a/tests/namespace_test/NamespaceC/TableInC.kt b/tests/namespace_test/NamespaceC/TableInC.kt
index 7586e25..b195c6c 100644
--- a/tests/namespace_test/NamespaceC/TableInC.kt
+++ b/tests/namespace_test/NamespaceC/TableInC.kt
@@ -36,7 +36,7 @@
}
}
companion object {
- fun validateVersion() = Constants.FLATBUFFERS_2_0_0()
+ fun validateVersion() = Constants.FLATBUFFERS_2_0_8()
fun getRootAsTableInC(_bb: ByteBuffer): TableInC = getRootAsTableInC(_bb, TableInC())
fun getRootAsTableInC(_bb: ByteBuffer, obj: TableInC): TableInC {
_bb.order(ByteOrder.LITTLE_ENDIAN)
diff --git a/tests/namespace_test/mod.rs b/tests/namespace_test/mod.rs
index 8572c8d..22c667e 100644
--- a/tests/namespace_test/mod.rs
+++ b/tests/namespace_test/mod.rs
@@ -1,4 +1,5 @@
// Automatically generated by the Flatbuffers compiler. Do not modify.
+// @generated
pub mod namespace_a {
use super::*;
pub mod namespace_b {
diff --git a/tests/namespace_test/namespace_a/namespace_b/enum_in_nested_ns_generated.rs b/tests/namespace_test/namespace_a/namespace_b/enum_in_nested_ns_generated.rs
index b636638..246d28f 100644
--- a/tests/namespace_test/namespace_a/namespace_b/enum_in_nested_ns_generated.rs
+++ b/tests/namespace_test/namespace_a/namespace_b/enum_in_nested_ns_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -42,8 +47,8 @@
}
}
}
-impl std::fmt::Debug for EnumInNestedNS {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for EnumInNestedNS {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
if let Some(name) = self.variant_name() {
f.write_str(name)
} else {
diff --git a/tests/namespace_test/namespace_a/namespace_b/struct_in_nested_ns_generated.rs b/tests/namespace_test/namespace_a/namespace_b/struct_in_nested_ns_generated.rs
index 55fff40..dc13b0c 100644
--- a/tests/namespace_test/namespace_a/namespace_b/struct_in_nested_ns_generated.rs
+++ b/tests/namespace_test/namespace_a/namespace_b/struct_in_nested_ns_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
// struct StructInNestedNS, aligned to 4
@@ -13,8 +18,8 @@
Self([0; 8])
}
}
-impl std::fmt::Debug for StructInNestedNS {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for StructInNestedNS {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("StructInNestedNS")
.field("a", &self.a())
.field("b", &self.b())
@@ -43,7 +48,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(self as *const StructInNestedNS as *const u8, Self::size())
+ ::core::slice::from_raw_parts(self as *const StructInNestedNS as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
@@ -54,7 +59,7 @@
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(*self as *const StructInNestedNS as *const u8, Self::size())
+ ::core::slice::from_raw_parts(*self as *const StructInNestedNS as *const u8, Self::size())
};
dst.copy_from_slice(src);
}
diff --git a/tests/namespace_test/namespace_a/namespace_b/table_in_nested_ns_generated.rs b/tests/namespace_test/namespace_a/namespace_b/table_in_nested_ns_generated.rs
index 10d5b7c..76744f9 100644
--- a/tests/namespace_test/namespace_a/namespace_b/table_in_nested_ns_generated.rs
+++ b/tests/namespace_test/namespace_a/namespace_b/table_in_nested_ns_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum TableInNestedNSOffset {}
@@ -101,8 +106,8 @@
}
}
-impl std::fmt::Debug for TableInNestedNS<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TableInNestedNS<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("TableInNestedNS");
ds.field("foo", &self.foo());
ds.finish()
diff --git a/tests/namespace_test/namespace_a/namespace_b/union_in_nested_ns_generated.rs b/tests/namespace_test/namespace_a/namespace_b/union_in_nested_ns_generated.rs
index 8d650a5..a77108f 100644
--- a/tests/namespace_test/namespace_a/namespace_b/union_in_nested_ns_generated.rs
+++ b/tests/namespace_test/namespace_a/namespace_b/union_in_nested_ns_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -38,8 +43,8 @@
}
}
}
-impl std::fmt::Debug for UnionInNestedNS {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for UnionInNestedNS {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
if let Some(name) = self.variant_name() {
f.write_str(name)
} else {
@@ -121,7 +126,7 @@
/// If the union variant matches, return the owned TableInNestedNST, setting the union to NONE.
pub fn take_table_in_nested_ns(&mut self) -> Option<Box<TableInNestedNST>> {
if let Self::TableInNestedNS(_) = self {
- let v = std::mem::replace(self, Self::NONE);
+ let v = core::mem::replace(self, Self::NONE);
if let Self::TableInNestedNS(w) = v {
Some(w)
} else {
diff --git a/tests/namespace_test/namespace_a/second_table_in_a_generated.rs b/tests/namespace_test/namespace_a/second_table_in_a_generated.rs
index d63438b..c32fdc0 100644
--- a/tests/namespace_test/namespace_a/second_table_in_a_generated.rs
+++ b/tests/namespace_test/namespace_a/second_table_in_a_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum SecondTableInAOffset {}
@@ -103,8 +108,8 @@
}
}
-impl std::fmt::Debug for SecondTableInA<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for SecondTableInA<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("SecondTableInA");
ds.field("refer_to_c", &self.refer_to_c());
ds.finish()
diff --git a/tests/namespace_test/namespace_a/table_in_first_ns_generated.rs b/tests/namespace_test/namespace_a/table_in_first_ns_generated.rs
index 0a16074..ab46d7e 100644
--- a/tests/namespace_test/namespace_a/table_in_first_ns_generated.rs
+++ b/tests/namespace_test/namespace_a/table_in_first_ns_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum TableInFirstNSOffset {}
@@ -185,8 +190,8 @@
}
}
-impl std::fmt::Debug for TableInFirstNS<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TableInFirstNS<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("TableInFirstNS");
ds.field("foo_table", &self.foo_table());
ds.field("foo_enum", &self.foo_enum());
diff --git a/tests/namespace_test/namespace_c/table_in_c_generated.rs b/tests/namespace_test/namespace_c/table_in_c_generated.rs
index d4ac783..a6ba7bf 100644
--- a/tests/namespace_test/namespace_c/table_in_c_generated.rs
+++ b/tests/namespace_test/namespace_c/table_in_c_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum TableInCOffset {}
@@ -120,8 +125,8 @@
}
}
-impl std::fmt::Debug for TableInC<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for TableInC<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("TableInC");
ds.field("refer_to_a1", &self.refer_to_a1());
ds.field("refer_to_a2", &self.refer_to_a2());
diff --git a/tests/namespace_test/namespace_test1_generated.h b/tests/namespace_test/namespace_test1_generated.h
index bb82236..c2af28e 100644
--- a/tests/namespace_test/namespace_test1_generated.h
+++ b/tests/namespace_test/namespace_test1_generated.h
@@ -6,6 +6,13 @@
#include "flatbuffers/flatbuffers.h"
+// Ensure the included flatbuffers.h is the same version as when this file was
+// generated, otherwise it may not be compatible.
+static_assert(FLATBUFFERS_VERSION_MAJOR == 2 &&
+ FLATBUFFERS_VERSION_MINOR == 0 &&
+ FLATBUFFERS_VERSION_REVISION == 8,
+ "Non-compatible flatbuffers version included");
+
namespace NamespaceA {
namespace NamespaceB {
diff --git a/tests/namespace_test/namespace_test2_generated.h b/tests/namespace_test/namespace_test2_generated.h
index ff164cc..85dc12f 100644
--- a/tests/namespace_test/namespace_test2_generated.h
+++ b/tests/namespace_test/namespace_test2_generated.h
@@ -6,6 +6,13 @@
#include "flatbuffers/flatbuffers.h"
+// Ensure the included flatbuffers.h is the same version as when this file was
+// generated, otherwise it may not be compatible.
+static_assert(FLATBUFFERS_VERSION_MAJOR == 2 &&
+ FLATBUFFERS_VERSION_MINOR == 0 &&
+ FLATBUFFERS_VERSION_REVISION == 8,
+ "Non-compatible flatbuffers version included");
+
namespace NamespaceA {
struct TableInFirstNS;
@@ -386,7 +393,7 @@
inline void TableInFirstNS::UnPackTo(TableInFirstNST *_o, const flatbuffers::resolver_function_t *_resolver) const {
(void)_o;
(void)_resolver;
- { auto _e = foo_table(); if (_e) { if(_o->foo_table) { _e->UnPackTo(_o->foo_table.get(), _resolver); } else { _o->foo_table = flatbuffers::unique_ptr<NamespaceA::NamespaceB::TableInNestedNST>(_e->UnPack(_resolver)); } } }
+ { auto _e = foo_table(); if (_e) { if(_o->foo_table) { _e->UnPackTo(_o->foo_table.get(), _resolver); } else { _o->foo_table = flatbuffers::unique_ptr<NamespaceA::NamespaceB::TableInNestedNST>(_e->UnPack(_resolver)); } } else if (_o->foo_table) { _o->foo_table.reset(); } }
{ auto _e = foo_enum(); _o->foo_enum = _e; }
{ auto _e = foo_union_type(); _o->foo_union.type = _e; }
{ auto _e = foo_union(); if (_e) _o->foo_union.value = NamespaceA::NamespaceB::UnionInNestedNSUnion::UnPack(_e, foo_union_type(), _resolver); }
@@ -405,7 +412,7 @@
auto _foo_enum = _o->foo_enum;
auto _foo_union_type = _o->foo_union.type;
auto _foo_union = _o->foo_union.Pack(_fbb);
- auto _foo_struct = _o->foo_struct ? _o->foo_struct.get() : 0;
+ auto _foo_struct = _o->foo_struct ? _o->foo_struct.get() : nullptr;
return NamespaceA::CreateTableInFirstNS(
_fbb,
_foo_table,
@@ -451,8 +458,8 @@
inline void TableInC::UnPackTo(TableInCT *_o, const flatbuffers::resolver_function_t *_resolver) const {
(void)_o;
(void)_resolver;
- { auto _e = refer_to_a1(); if (_e) { if(_o->refer_to_a1) { _e->UnPackTo(_o->refer_to_a1.get(), _resolver); } else { _o->refer_to_a1 = flatbuffers::unique_ptr<NamespaceA::TableInFirstNST>(_e->UnPack(_resolver)); } } }
- { auto _e = refer_to_a2(); if (_e) { if(_o->refer_to_a2) { _e->UnPackTo(_o->refer_to_a2.get(), _resolver); } else { _o->refer_to_a2 = flatbuffers::unique_ptr<NamespaceA::SecondTableInAT>(_e->UnPack(_resolver)); } } }
+ { auto _e = refer_to_a1(); if (_e) { if(_o->refer_to_a1) { _e->UnPackTo(_o->refer_to_a1.get(), _resolver); } else { _o->refer_to_a1 = flatbuffers::unique_ptr<NamespaceA::TableInFirstNST>(_e->UnPack(_resolver)); } } else if (_o->refer_to_a1) { _o->refer_to_a1.reset(); } }
+ { auto _e = refer_to_a2(); if (_e) { if(_o->refer_to_a2) { _e->UnPackTo(_o->refer_to_a2.get(), _resolver); } else { _o->refer_to_a2 = flatbuffers::unique_ptr<NamespaceA::SecondTableInAT>(_e->UnPack(_resolver)); } } else if (_o->refer_to_a2) { _o->refer_to_a2.reset(); } }
}
inline flatbuffers::Offset<TableInC> TableInC::Pack(flatbuffers::FlatBufferBuilder &_fbb, const TableInCT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
@@ -504,7 +511,7 @@
inline void SecondTableInA::UnPackTo(SecondTableInAT *_o, const flatbuffers::resolver_function_t *_resolver) const {
(void)_o;
(void)_resolver;
- { auto _e = refer_to_c(); if (_e) { if(_o->refer_to_c) { _e->UnPackTo(_o->refer_to_c.get(), _resolver); } else { _o->refer_to_c = flatbuffers::unique_ptr<NamespaceC::TableInCT>(_e->UnPack(_resolver)); } } }
+ { auto _e = refer_to_c(); if (_e) { if(_o->refer_to_c) { _e->UnPackTo(_o->refer_to_c.get(), _resolver); } else { _o->refer_to_c = flatbuffers::unique_ptr<NamespaceC::TableInCT>(_e->UnPack(_resolver)); } } else if (_o->refer_to_c) { _o->refer_to_c.reset(); } }
}
inline flatbuffers::Offset<SecondTableInA> SecondTableInA::Pack(flatbuffers::FlatBufferBuilder &_fbb, const SecondTableInAT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
diff --git a/tests/native_inline_table_test.fbs b/tests/native_inline_table_test.fbs
new file mode 100644
index 0000000..cbe8940
--- /dev/null
+++ b/tests/native_inline_table_test.fbs
@@ -0,0 +1,7 @@
+table NativeInlineTable {
+ a: int;
+}
+
+table TestNativeInlineTable {
+ t: [NativeInlineTable] (native_inline);
+}
diff --git a/tests/native_inline_table_test_generated.h b/tests/native_inline_table_test_generated.h
new file mode 100644
index 0000000..9502663
--- /dev/null
+++ b/tests/native_inline_table_test_generated.h
@@ -0,0 +1,263 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+
+#ifndef FLATBUFFERS_GENERATED_NATIVEINLINETABLETEST_H_
+#define FLATBUFFERS_GENERATED_NATIVEINLINETABLETEST_H_
+
+#include "flatbuffers/flatbuffers.h"
+
+// Ensure the included flatbuffers.h is the same version as when this file was
+// generated, otherwise it may not be compatible.
+static_assert(FLATBUFFERS_VERSION_MAJOR == 2 &&
+ FLATBUFFERS_VERSION_MINOR == 0 &&
+ FLATBUFFERS_VERSION_REVISION == 8,
+ "Non-compatible flatbuffers version included");
+
+struct NativeInlineTable;
+struct NativeInlineTableBuilder;
+struct NativeInlineTableT;
+
+struct TestNativeInlineTable;
+struct TestNativeInlineTableBuilder;
+struct TestNativeInlineTableT;
+
+bool operator==(const NativeInlineTableT &lhs, const NativeInlineTableT &rhs);
+bool operator!=(const NativeInlineTableT &lhs, const NativeInlineTableT &rhs);
+bool operator==(const TestNativeInlineTableT &lhs, const TestNativeInlineTableT &rhs);
+bool operator!=(const TestNativeInlineTableT &lhs, const TestNativeInlineTableT &rhs);
+
+inline const flatbuffers::TypeTable *NativeInlineTableTypeTable();
+
+inline const flatbuffers::TypeTable *TestNativeInlineTableTypeTable();
+
+struct NativeInlineTableT : public flatbuffers::NativeTable {
+ typedef NativeInlineTable TableType;
+ int32_t a = 0;
+};
+
+struct NativeInlineTable FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
+ typedef NativeInlineTableT NativeTableType;
+ typedef NativeInlineTableBuilder Builder;
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return NativeInlineTableTypeTable();
+ }
+ enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
+ VT_A = 4
+ };
+ int32_t a() const {
+ return GetField<int32_t>(VT_A, 0);
+ }
+ bool mutate_a(int32_t _a = 0) {
+ return SetField<int32_t>(VT_A, _a, 0);
+ }
+ bool Verify(flatbuffers::Verifier &verifier) const {
+ return VerifyTableStart(verifier) &&
+ VerifyField<int32_t>(verifier, VT_A, 4) &&
+ verifier.EndTable();
+ }
+ NativeInlineTableT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ void UnPackTo(NativeInlineTableT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ static flatbuffers::Offset<NativeInlineTable> Pack(flatbuffers::FlatBufferBuilder &_fbb, const NativeInlineTableT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+};
+
+struct NativeInlineTableBuilder {
+ typedef NativeInlineTable Table;
+ flatbuffers::FlatBufferBuilder &fbb_;
+ flatbuffers::uoffset_t start_;
+ void add_a(int32_t a) {
+ fbb_.AddElement<int32_t>(NativeInlineTable::VT_A, a, 0);
+ }
+ explicit NativeInlineTableBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
+ flatbuffers::Offset<NativeInlineTable> Finish() {
+ const auto end = fbb_.EndTable(start_);
+ auto o = flatbuffers::Offset<NativeInlineTable>(end);
+ return o;
+ }
+};
+
+inline flatbuffers::Offset<NativeInlineTable> CreateNativeInlineTable(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ int32_t a = 0) {
+ NativeInlineTableBuilder builder_(_fbb);
+ builder_.add_a(a);
+ return builder_.Finish();
+}
+
+flatbuffers::Offset<NativeInlineTable> CreateNativeInlineTable(flatbuffers::FlatBufferBuilder &_fbb, const NativeInlineTableT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+
+struct TestNativeInlineTableT : public flatbuffers::NativeTable {
+ typedef TestNativeInlineTable TableType;
+ std::vector<NativeInlineTableT> t{};
+};
+
+struct TestNativeInlineTable FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
+ typedef TestNativeInlineTableT NativeTableType;
+ typedef TestNativeInlineTableBuilder Builder;
+ static const flatbuffers::TypeTable *MiniReflectTypeTable() {
+ return TestNativeInlineTableTypeTable();
+ }
+ enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
+ VT_T = 4
+ };
+ const flatbuffers::Vector<flatbuffers::Offset<NativeInlineTable>> *t() const {
+ return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<NativeInlineTable>> *>(VT_T);
+ }
+ flatbuffers::Vector<flatbuffers::Offset<NativeInlineTable>> *mutable_t() {
+ return GetPointer<flatbuffers::Vector<flatbuffers::Offset<NativeInlineTable>> *>(VT_T);
+ }
+ bool Verify(flatbuffers::Verifier &verifier) const {
+ return VerifyTableStart(verifier) &&
+ VerifyOffset(verifier, VT_T) &&
+ verifier.VerifyVector(t()) &&
+ verifier.VerifyVectorOfTables(t()) &&
+ verifier.EndTable();
+ }
+ TestNativeInlineTableT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ void UnPackTo(TestNativeInlineTableT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ static flatbuffers::Offset<TestNativeInlineTable> Pack(flatbuffers::FlatBufferBuilder &_fbb, const TestNativeInlineTableT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+};
+
+struct TestNativeInlineTableBuilder {
+ typedef TestNativeInlineTable Table;
+ flatbuffers::FlatBufferBuilder &fbb_;
+ flatbuffers::uoffset_t start_;
+ void add_t(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<NativeInlineTable>>> t) {
+ fbb_.AddOffset(TestNativeInlineTable::VT_T, t);
+ }
+ explicit TestNativeInlineTableBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
+ flatbuffers::Offset<TestNativeInlineTable> Finish() {
+ const auto end = fbb_.EndTable(start_);
+ auto o = flatbuffers::Offset<TestNativeInlineTable>(end);
+ return o;
+ }
+};
+
+inline flatbuffers::Offset<TestNativeInlineTable> CreateTestNativeInlineTable(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<NativeInlineTable>>> t = 0) {
+ TestNativeInlineTableBuilder builder_(_fbb);
+ builder_.add_t(t);
+ return builder_.Finish();
+}
+
+inline flatbuffers::Offset<TestNativeInlineTable> CreateTestNativeInlineTableDirect(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ const std::vector<flatbuffers::Offset<NativeInlineTable>> *t = nullptr) {
+ auto t__ = t ? _fbb.CreateVector<flatbuffers::Offset<NativeInlineTable>>(*t) : 0;
+ return CreateTestNativeInlineTable(
+ _fbb,
+ t__);
+}
+
+flatbuffers::Offset<TestNativeInlineTable> CreateTestNativeInlineTable(flatbuffers::FlatBufferBuilder &_fbb, const TestNativeInlineTableT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+
+
+inline bool operator==(const NativeInlineTableT &lhs, const NativeInlineTableT &rhs) {
+ return
+ (lhs.a == rhs.a);
+}
+
+inline bool operator!=(const NativeInlineTableT &lhs, const NativeInlineTableT &rhs) {
+ return !(lhs == rhs);
+}
+
+
+inline NativeInlineTableT *NativeInlineTable::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
+ auto _o = std::unique_ptr<NativeInlineTableT>(new NativeInlineTableT());
+ UnPackTo(_o.get(), _resolver);
+ return _o.release();
+}
+
+inline void NativeInlineTable::UnPackTo(NativeInlineTableT *_o, const flatbuffers::resolver_function_t *_resolver) const {
+ (void)_o;
+ (void)_resolver;
+ { auto _e = a(); _o->a = _e; }
+}
+
+inline flatbuffers::Offset<NativeInlineTable> NativeInlineTable::Pack(flatbuffers::FlatBufferBuilder &_fbb, const NativeInlineTableT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
+ return CreateNativeInlineTable(_fbb, _o, _rehasher);
+}
+
+inline flatbuffers::Offset<NativeInlineTable> CreateNativeInlineTable(flatbuffers::FlatBufferBuilder &_fbb, const NativeInlineTableT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
+ (void)_rehasher;
+ (void)_o;
+ struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const NativeInlineTableT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
+ auto _a = _o->a;
+ return CreateNativeInlineTable(
+ _fbb,
+ _a);
+}
+
+
+inline bool operator==(const TestNativeInlineTableT &lhs, const TestNativeInlineTableT &rhs) {
+ return
+ (lhs.t == rhs.t);
+}
+
+inline bool operator!=(const TestNativeInlineTableT &lhs, const TestNativeInlineTableT &rhs) {
+ return !(lhs == rhs);
+}
+
+
+inline TestNativeInlineTableT *TestNativeInlineTable::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
+ auto _o = std::unique_ptr<TestNativeInlineTableT>(new TestNativeInlineTableT());
+ UnPackTo(_o.get(), _resolver);
+ return _o.release();
+}
+
+inline void TestNativeInlineTable::UnPackTo(TestNativeInlineTableT *_o, const flatbuffers::resolver_function_t *_resolver) const {
+ (void)_o;
+ (void)_resolver;
+ { auto _e = t(); if (_e) { _o->t.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->t[_i] = *flatbuffers::unique_ptr<NativeInlineTableT>(_e->Get(_i)->UnPack(_resolver)); } } else { _o->t.resize(0); } }
+}
+
+inline flatbuffers::Offset<TestNativeInlineTable> TestNativeInlineTable::Pack(flatbuffers::FlatBufferBuilder &_fbb, const TestNativeInlineTableT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
+ return CreateTestNativeInlineTable(_fbb, _o, _rehasher);
+}
+
+inline flatbuffers::Offset<TestNativeInlineTable> CreateTestNativeInlineTable(flatbuffers::FlatBufferBuilder &_fbb, const TestNativeInlineTableT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
+ (void)_rehasher;
+ (void)_o;
+ struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const TestNativeInlineTableT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
+ auto _t = _o->t.size() ? _fbb.CreateVector<flatbuffers::Offset<NativeInlineTable>> (_o->t.size(), [](size_t i, _VectorArgs *__va) { return CreateNativeInlineTable(*__va->__fbb, &(__va->__o->t[i]), __va->__rehasher); }, &_va ) : 0;
+ return CreateTestNativeInlineTable(
+ _fbb,
+ _t);
+}
+
+inline const flatbuffers::TypeTable *NativeInlineTableTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_INT, 0, -1 }
+ };
+ static const char * const names[] = {
+ "a"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_TABLE, 1, type_codes, nullptr, nullptr, nullptr, names
+ };
+ return &tt;
+}
+
+inline const flatbuffers::TypeTable *TestNativeInlineTableTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_SEQUENCE, 1, 0 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ NativeInlineTableTypeTable
+ };
+ static const char * const names[] = {
+ "t"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_TABLE, 1, type_codes, type_refs, nullptr, nullptr, names
+ };
+ return &tt;
+}
+
+#endif // FLATBUFFERS_GENERATED_NATIVEINLINETABLETEST_H_
diff --git a/tests/native_type_test_generated.h b/tests/native_type_test_generated.h
index 8678718..63304f1 100644
--- a/tests/native_type_test_generated.h
+++ b/tests/native_type_test_generated.h
@@ -6,6 +6,13 @@
#include "flatbuffers/flatbuffers.h"
+// Ensure the included flatbuffers.h is the same version as when this file was
+// generated, otherwise it may not be compatible.
+static_assert(FLATBUFFERS_VERSION_MAJOR == 2 &&
+ FLATBUFFERS_VERSION_MINOR == 0 &&
+ FLATBUFFERS_VERSION_REVISION == 8,
+ "Non-compatible flatbuffers version included");
+
#include "native_type_test_impl.h"
namespace Geometry {
@@ -201,8 +208,8 @@
inline void ApplicationData::UnPackTo(ApplicationDataT *_o, const flatbuffers::resolver_function_t *_resolver) const {
(void)_o;
(void)_resolver;
- { auto _e = vectors(); if (_e) { _o->vectors.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vectors[_i] = flatbuffers::UnPack(*_e->Get(_i)); } } }
- { auto _e = vectors_alt(); if (_e) { _o->vectors_alt.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vectors_alt[_i] = flatbuffers::UnPackVector3DAlt(*_e->Get(_i)); } } }
+ { auto _e = vectors(); if (_e) { _o->vectors.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vectors[_i] = flatbuffers::UnPack(*_e->Get(_i)); } } else { _o->vectors.resize(0); } }
+ { auto _e = vectors_alt(); if (_e) { _o->vectors_alt.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vectors_alt[_i] = flatbuffers::UnPackVector3DAlt(*_e->Get(_i)); } } else { _o->vectors_alt.resize(0); } }
}
inline flatbuffers::Offset<ApplicationData> ApplicationData::Pack(flatbuffers::FlatBufferBuilder &_fbb, const ApplicationDataT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
diff --git a/tests/nested_namespace_test/nested_namespace_test1_generated.cs b/tests/nested_namespace_test/nested_namespace_test1_generated.cs
index e42e96a..f1e646c 100644
--- a/tests/nested_namespace_test/nested_namespace_test1_generated.cs
+++ b/tests/nested_namespace_test/nested_namespace_test1_generated.cs
@@ -7,7 +7,7 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
public enum Color : sbyte
diff --git a/tests/nested_namespace_test/nested_namespace_test2_generated.cs b/tests/nested_namespace_test/nested_namespace_test2_generated.cs
index cdc1b09..efd2584 100644
--- a/tests/nested_namespace_test/nested_namespace_test2_generated.cs
+++ b/tests/nested_namespace_test/nested_namespace_test2_generated.cs
@@ -7,7 +7,7 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
public enum Color : sbyte
diff --git a/tests/nested_namespace_test/nested_namespace_test3_generated.cs b/tests/nested_namespace_test/nested_namespace_test3_generated.cs
index f2f3778..85040c5 100644
--- a/tests/nested_namespace_test/nested_namespace_test3_generated.cs
+++ b/tests/nested_namespace_test/nested_namespace_test3_generated.cs
@@ -7,13 +7,13 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
public struct ColorTestTable : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
- public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_8(); }
public static ColorTestTable GetRootAsColorTestTable(ByteBuffer _bb) { return GetRootAsColorTestTable(_bb, new ColorTestTable()); }
public static ColorTestTable GetRootAsColorTestTable(ByteBuffer _bb, ColorTestTable obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public void __init(int _i, ByteBuffer _bb) { __p = new Table(_i, _bb); }
diff --git a/tests/optional-scalars/optional-byte.ts b/tests/optional-scalars/optional-byte.ts
index 1db479f..f4db265 100644
--- a/tests/optional-scalars/optional-byte.ts
+++ b/tests/optional-scalars/optional-byte.ts
@@ -1,8 +1,7 @@
// automatically generated by the FlatBuffers compiler, do not modify
-export enum OptionalByte{
+export enum OptionalByte {
None = 0,
One = 1,
Two = 2
}
-
diff --git a/tests/optional-scalars/scalar-stuff.ts b/tests/optional-scalars/scalar-stuff.ts
index a748c22..7c8fd51 100644
--- a/tests/optional-scalars/scalar-stuff.ts
+++ b/tests/optional-scalars/scalar-stuff.ts
@@ -8,7 +8,7 @@
export class ScalarStuff {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
-__init(i:number, bb:flatbuffers.ByteBuffer):ScalarStuff {
+ __init(i:number, bb:flatbuffers.ByteBuffer):ScalarStuff {
this.bb_pos = i;
this.bb = bb;
return this;
diff --git a/tests/optional_scalars.json b/tests/optional_scalars.json
new file mode 100644
index 0000000..87bd22e
--- /dev/null
+++ b/tests/optional_scalars.json
@@ -0,0 +1,21 @@
+{
+ just_i8: 4,
+ maybe_u8: 0,
+ default_u8: 0,
+ just_i16: 4,
+ maybe_u16: 0,
+ default_u16: 0,
+ just_i32: 4,
+ maybe_u32: 0,
+ default_u32: 0,
+ just_i64: 4,
+ maybe_u64: 0,
+ default_u64: 0,
+ just_f32: 4.0,
+ maybe_f64: 0.0,
+ default_f64: 0.0,
+ just_bool: true,
+ default_bool: false,
+ maybe_enum: "One",
+ default_enum: "Two"
+}
diff --git a/tests/optional_scalars/OptionalByte.py b/tests/optional_scalars/OptionalByte.py
new file mode 100644
index 0000000..5e7df8b
--- /dev/null
+++ b/tests/optional_scalars/OptionalByte.py
@@ -0,0 +1,8 @@
+# automatically generated by the FlatBuffers compiler, do not modify
+
+# namespace: optional_scalars
+
+class OptionalByte(object):
+ None_ = 0
+ One = 1
+ Two = 2
diff --git a/tests/optional_scalars/ScalarStuff.cs b/tests/optional_scalars/ScalarStuff.cs
index e549838..85c1672 100644
--- a/tests/optional_scalars/ScalarStuff.cs
+++ b/tests/optional_scalars/ScalarStuff.cs
@@ -7,13 +7,13 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
public struct ScalarStuff : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
- public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_8(); }
public static ScalarStuff GetRootAsScalarStuff(ByteBuffer _bb) { return GetRootAsScalarStuff(_bb, new ScalarStuff()); }
public static ScalarStuff GetRootAsScalarStuff(ByteBuffer _bb, ScalarStuff obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public static bool ScalarStuffBufferHasIdentifier(ByteBuffer _bb) { return Table.__has_identifier(_bb, "NULL"); }
diff --git a/tests/optional_scalars/ScalarStuff.go b/tests/optional_scalars/ScalarStuff.go
index 2992f30..8b56567 100644
--- a/tests/optional_scalars/ScalarStuff.go
+++ b/tests/optional_scalars/ScalarStuff.go
@@ -7,42 +7,42 @@
)
type ScalarStuffT struct {
- JustI8 int8
- MaybeI8 *int8
- DefaultI8 int8
- JustU8 byte
- MaybeU8 *byte
- DefaultU8 byte
- JustI16 int16
- MaybeI16 *int16
- DefaultI16 int16
- JustU16 uint16
- MaybeU16 *uint16
- DefaultU16 uint16
- JustI32 int32
- MaybeI32 *int32
- DefaultI32 int32
- JustU32 uint32
- MaybeU32 *uint32
- DefaultU32 uint32
- JustI64 int64
- MaybeI64 *int64
- DefaultI64 int64
- JustU64 uint64
- MaybeU64 *uint64
- DefaultU64 uint64
- JustF32 float32
- MaybeF32 *float32
- DefaultF32 float32
- JustF64 float64
- MaybeF64 *float64
- DefaultF64 float64
- JustBool bool
- MaybeBool *bool
- DefaultBool bool
- JustEnum OptionalByte
- MaybeEnum *OptionalByte
- DefaultEnum OptionalByte
+ JustI8 int8 `json:"just_i8"`
+ MaybeI8 *int8 `json:"maybe_i8"`
+ DefaultI8 int8 `json:"default_i8"`
+ JustU8 byte `json:"just_u8"`
+ MaybeU8 *byte `json:"maybe_u8"`
+ DefaultU8 byte `json:"default_u8"`
+ JustI16 int16 `json:"just_i16"`
+ MaybeI16 *int16 `json:"maybe_i16"`
+ DefaultI16 int16 `json:"default_i16"`
+ JustU16 uint16 `json:"just_u16"`
+ MaybeU16 *uint16 `json:"maybe_u16"`
+ DefaultU16 uint16 `json:"default_u16"`
+ JustI32 int32 `json:"just_i32"`
+ MaybeI32 *int32 `json:"maybe_i32"`
+ DefaultI32 int32 `json:"default_i32"`
+ JustU32 uint32 `json:"just_u32"`
+ MaybeU32 *uint32 `json:"maybe_u32"`
+ DefaultU32 uint32 `json:"default_u32"`
+ JustI64 int64 `json:"just_i64"`
+ MaybeI64 *int64 `json:"maybe_i64"`
+ DefaultI64 int64 `json:"default_i64"`
+ JustU64 uint64 `json:"just_u64"`
+ MaybeU64 *uint64 `json:"maybe_u64"`
+ DefaultU64 uint64 `json:"default_u64"`
+ JustF32 float32 `json:"just_f32"`
+ MaybeF32 *float32 `json:"maybe_f32"`
+ DefaultF32 float32 `json:"default_f32"`
+ JustF64 float64 `json:"just_f64"`
+ MaybeF64 *float64 `json:"maybe_f64"`
+ DefaultF64 float64 `json:"default_f64"`
+ JustBool bool `json:"just_bool"`
+ MaybeBool *bool `json:"maybe_bool"`
+ DefaultBool bool `json:"default_bool"`
+ JustEnum OptionalByte `json:"just_enum"`
+ MaybeEnum *OptionalByte `json:"maybe_enum"`
+ DefaultEnum OptionalByte `json:"default_enum"`
}
func (t *ScalarStuffT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
diff --git a/tests/optional_scalars/ScalarStuff.java b/tests/optional_scalars/ScalarStuff.java
index e415210..f4890b1 100644
--- a/tests/optional_scalars/ScalarStuff.java
+++ b/tests/optional_scalars/ScalarStuff.java
@@ -9,7 +9,7 @@
@SuppressWarnings("unused")
public final class ScalarStuff extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static ScalarStuff getRootAsScalarStuff(ByteBuffer _bb) { return getRootAsScalarStuff(_bb, new ScalarStuff()); }
public static ScalarStuff getRootAsScalarStuff(ByteBuffer _bb, ScalarStuff obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public static boolean ScalarStuffBufferHasIdentifier(ByteBuffer _bb) { return __has_identifier(_bb, "NULL"); }
diff --git a/tests/optional_scalars/ScalarStuff.kt b/tests/optional_scalars/ScalarStuff.kt
index 5ab8bf4..e9067bb 100644
--- a/tests/optional_scalars/ScalarStuff.kt
+++ b/tests/optional_scalars/ScalarStuff.kt
@@ -197,7 +197,7 @@
return if(o != 0) bb.get(o + bb_pos) else 1
}
companion object {
- fun validateVersion() = Constants.FLATBUFFERS_2_0_0()
+ fun validateVersion() = Constants.FLATBUFFERS_2_0_8()
fun getRootAsScalarStuff(_bb: ByteBuffer): ScalarStuff = getRootAsScalarStuff(_bb, ScalarStuff())
fun getRootAsScalarStuff(_bb: ByteBuffer, obj: ScalarStuff): ScalarStuff {
_bb.order(ByteOrder.LITTLE_ENDIAN)
diff --git a/tests/optional_scalars/ScalarStuff.py b/tests/optional_scalars/ScalarStuff.py
new file mode 100644
index 0000000..4dea123
--- /dev/null
+++ b/tests/optional_scalars/ScalarStuff.py
@@ -0,0 +1,532 @@
+# automatically generated by the FlatBuffers compiler, do not modify
+
+# namespace: optional_scalars
+
+import flatbuffers
+from flatbuffers.compat import import_numpy
+np = import_numpy()
+
+class ScalarStuff(object):
+ __slots__ = ['_tab']
+
+ @classmethod
+ def GetRootAs(cls, buf, offset=0):
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
+ x = ScalarStuff()
+ x.Init(buf, n + offset)
+ return x
+
+ @classmethod
+ def GetRootAsScalarStuff(cls, buf, offset=0):
+ """This method is deprecated. Please switch to GetRootAs."""
+ return cls.GetRootAs(buf, offset)
+ @classmethod
+ def ScalarStuffBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4E\x55\x4C\x4C", size_prefixed=size_prefixed)
+
+ # ScalarStuff
+ def Init(self, buf, pos):
+ self._tab = flatbuffers.table.Table(buf, pos)
+
+ # ScalarStuff
+ def JustI8(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
+ return 0
+
+ # ScalarStuff
+ def MaybeI8(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
+ return None
+
+ # ScalarStuff
+ def DefaultI8(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
+ return 42
+
+ # ScalarStuff
+ def JustU8(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
+ return 0
+
+ # ScalarStuff
+ def MaybeU8(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
+ return None
+
+ # ScalarStuff
+ def DefaultU8(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
+ return 42
+
+ # ScalarStuff
+ def JustI16(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Int16Flags, o + self._tab.Pos)
+ return 0
+
+ # ScalarStuff
+ def MaybeI16(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Int16Flags, o + self._tab.Pos)
+ return None
+
+ # ScalarStuff
+ def DefaultI16(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Int16Flags, o + self._tab.Pos)
+ return 42
+
+ # ScalarStuff
+ def JustU16(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Uint16Flags, o + self._tab.Pos)
+ return 0
+
+ # ScalarStuff
+ def MaybeU16(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(24))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Uint16Flags, o + self._tab.Pos)
+ return None
+
+ # ScalarStuff
+ def DefaultU16(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(26))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Uint16Flags, o + self._tab.Pos)
+ return 42
+
+ # ScalarStuff
+ def JustI32(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(28))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
+ return 0
+
+ # ScalarStuff
+ def MaybeI32(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(30))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
+ return None
+
+ # ScalarStuff
+ def DefaultI32(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(32))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
+ return 42
+
+ # ScalarStuff
+ def JustU32(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(34))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos)
+ return 0
+
+ # ScalarStuff
+ def MaybeU32(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(36))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos)
+ return None
+
+ # ScalarStuff
+ def DefaultU32(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(38))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos)
+ return 42
+
+ # ScalarStuff
+ def JustI64(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(40))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos)
+ return 0
+
+ # ScalarStuff
+ def MaybeI64(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(42))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos)
+ return None
+
+ # ScalarStuff
+ def DefaultI64(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(44))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos)
+ return 42
+
+ # ScalarStuff
+ def JustU64(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(46))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos)
+ return 0
+
+ # ScalarStuff
+ def MaybeU64(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(48))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos)
+ return None
+
+ # ScalarStuff
+ def DefaultU64(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(50))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos)
+ return 42
+
+ # ScalarStuff
+ def JustF32(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(52))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos)
+ return 0.0
+
+ # ScalarStuff
+ def MaybeF32(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(54))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos)
+ return None
+
+ # ScalarStuff
+ def DefaultF32(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(56))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos)
+ return 42.0
+
+ # ScalarStuff
+ def JustF64(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(58))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Float64Flags, o + self._tab.Pos)
+ return 0.0
+
+ # ScalarStuff
+ def MaybeF64(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(60))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Float64Flags, o + self._tab.Pos)
+ return None
+
+ # ScalarStuff
+ def DefaultF64(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(62))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Float64Flags, o + self._tab.Pos)
+ return 42.0
+
+ # ScalarStuff
+ def JustBool(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(64))
+ if o != 0:
+ return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
+ return False
+
+ # ScalarStuff
+ def MaybeBool(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(66))
+ if o != 0:
+ return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
+ return None
+
+ # ScalarStuff
+ def DefaultBool(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(68))
+ if o != 0:
+ return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
+ return True
+
+ # ScalarStuff
+ def JustEnum(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(70))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
+ return 0
+
+ # ScalarStuff
+ def MaybeEnum(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(72))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
+ return None
+
+ # ScalarStuff
+ def DefaultEnum(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(74))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
+ return 1
+
+def ScalarStuffStart(builder): builder.StartObject(36)
+def Start(builder):
+ return ScalarStuffStart(builder)
+def ScalarStuffAddJustI8(builder, justI8): builder.PrependInt8Slot(0, justI8, 0)
+def AddJustI8(builder, justI8):
+ return ScalarStuffAddJustI8(builder, justI8)
+def ScalarStuffAddMaybeI8(builder, maybeI8): builder.PrependInt8Slot(1, maybeI8, None)
+def AddMaybeI8(builder, maybeI8):
+ return ScalarStuffAddMaybeI8(builder, maybeI8)
+def ScalarStuffAddDefaultI8(builder, defaultI8): builder.PrependInt8Slot(2, defaultI8, 42)
+def AddDefaultI8(builder, defaultI8):
+ return ScalarStuffAddDefaultI8(builder, defaultI8)
+def ScalarStuffAddJustU8(builder, justU8): builder.PrependUint8Slot(3, justU8, 0)
+def AddJustU8(builder, justU8):
+ return ScalarStuffAddJustU8(builder, justU8)
+def ScalarStuffAddMaybeU8(builder, maybeU8): builder.PrependUint8Slot(4, maybeU8, None)
+def AddMaybeU8(builder, maybeU8):
+ return ScalarStuffAddMaybeU8(builder, maybeU8)
+def ScalarStuffAddDefaultU8(builder, defaultU8): builder.PrependUint8Slot(5, defaultU8, 42)
+def AddDefaultU8(builder, defaultU8):
+ return ScalarStuffAddDefaultU8(builder, defaultU8)
+def ScalarStuffAddJustI16(builder, justI16): builder.PrependInt16Slot(6, justI16, 0)
+def AddJustI16(builder, justI16):
+ return ScalarStuffAddJustI16(builder, justI16)
+def ScalarStuffAddMaybeI16(builder, maybeI16): builder.PrependInt16Slot(7, maybeI16, None)
+def AddMaybeI16(builder, maybeI16):
+ return ScalarStuffAddMaybeI16(builder, maybeI16)
+def ScalarStuffAddDefaultI16(builder, defaultI16): builder.PrependInt16Slot(8, defaultI16, 42)
+def AddDefaultI16(builder, defaultI16):
+ return ScalarStuffAddDefaultI16(builder, defaultI16)
+def ScalarStuffAddJustU16(builder, justU16): builder.PrependUint16Slot(9, justU16, 0)
+def AddJustU16(builder, justU16):
+ return ScalarStuffAddJustU16(builder, justU16)
+def ScalarStuffAddMaybeU16(builder, maybeU16): builder.PrependUint16Slot(10, maybeU16, None)
+def AddMaybeU16(builder, maybeU16):
+ return ScalarStuffAddMaybeU16(builder, maybeU16)
+def ScalarStuffAddDefaultU16(builder, defaultU16): builder.PrependUint16Slot(11, defaultU16, 42)
+def AddDefaultU16(builder, defaultU16):
+ return ScalarStuffAddDefaultU16(builder, defaultU16)
+def ScalarStuffAddJustI32(builder, justI32): builder.PrependInt32Slot(12, justI32, 0)
+def AddJustI32(builder, justI32):
+ return ScalarStuffAddJustI32(builder, justI32)
+def ScalarStuffAddMaybeI32(builder, maybeI32): builder.PrependInt32Slot(13, maybeI32, None)
+def AddMaybeI32(builder, maybeI32):
+ return ScalarStuffAddMaybeI32(builder, maybeI32)
+def ScalarStuffAddDefaultI32(builder, defaultI32): builder.PrependInt32Slot(14, defaultI32, 42)
+def AddDefaultI32(builder, defaultI32):
+ return ScalarStuffAddDefaultI32(builder, defaultI32)
+def ScalarStuffAddJustU32(builder, justU32): builder.PrependUint32Slot(15, justU32, 0)
+def AddJustU32(builder, justU32):
+ return ScalarStuffAddJustU32(builder, justU32)
+def ScalarStuffAddMaybeU32(builder, maybeU32): builder.PrependUint32Slot(16, maybeU32, None)
+def AddMaybeU32(builder, maybeU32):
+ return ScalarStuffAddMaybeU32(builder, maybeU32)
+def ScalarStuffAddDefaultU32(builder, defaultU32): builder.PrependUint32Slot(17, defaultU32, 42)
+def AddDefaultU32(builder, defaultU32):
+ return ScalarStuffAddDefaultU32(builder, defaultU32)
+def ScalarStuffAddJustI64(builder, justI64): builder.PrependInt64Slot(18, justI64, 0)
+def AddJustI64(builder, justI64):
+ return ScalarStuffAddJustI64(builder, justI64)
+def ScalarStuffAddMaybeI64(builder, maybeI64): builder.PrependInt64Slot(19, maybeI64, None)
+def AddMaybeI64(builder, maybeI64):
+ return ScalarStuffAddMaybeI64(builder, maybeI64)
+def ScalarStuffAddDefaultI64(builder, defaultI64): builder.PrependInt64Slot(20, defaultI64, 42)
+def AddDefaultI64(builder, defaultI64):
+ return ScalarStuffAddDefaultI64(builder, defaultI64)
+def ScalarStuffAddJustU64(builder, justU64): builder.PrependUint64Slot(21, justU64, 0)
+def AddJustU64(builder, justU64):
+ return ScalarStuffAddJustU64(builder, justU64)
+def ScalarStuffAddMaybeU64(builder, maybeU64): builder.PrependUint64Slot(22, maybeU64, None)
+def AddMaybeU64(builder, maybeU64):
+ return ScalarStuffAddMaybeU64(builder, maybeU64)
+def ScalarStuffAddDefaultU64(builder, defaultU64): builder.PrependUint64Slot(23, defaultU64, 42)
+def AddDefaultU64(builder, defaultU64):
+ return ScalarStuffAddDefaultU64(builder, defaultU64)
+def ScalarStuffAddJustF32(builder, justF32): builder.PrependFloat32Slot(24, justF32, 0.0)
+def AddJustF32(builder, justF32):
+ return ScalarStuffAddJustF32(builder, justF32)
+def ScalarStuffAddMaybeF32(builder, maybeF32): builder.PrependFloat32Slot(25, maybeF32, None)
+def AddMaybeF32(builder, maybeF32):
+ return ScalarStuffAddMaybeF32(builder, maybeF32)
+def ScalarStuffAddDefaultF32(builder, defaultF32): builder.PrependFloat32Slot(26, defaultF32, 42.0)
+def AddDefaultF32(builder, defaultF32):
+ return ScalarStuffAddDefaultF32(builder, defaultF32)
+def ScalarStuffAddJustF64(builder, justF64): builder.PrependFloat64Slot(27, justF64, 0.0)
+def AddJustF64(builder, justF64):
+ return ScalarStuffAddJustF64(builder, justF64)
+def ScalarStuffAddMaybeF64(builder, maybeF64): builder.PrependFloat64Slot(28, maybeF64, None)
+def AddMaybeF64(builder, maybeF64):
+ return ScalarStuffAddMaybeF64(builder, maybeF64)
+def ScalarStuffAddDefaultF64(builder, defaultF64): builder.PrependFloat64Slot(29, defaultF64, 42.0)
+def AddDefaultF64(builder, defaultF64):
+ return ScalarStuffAddDefaultF64(builder, defaultF64)
+def ScalarStuffAddJustBool(builder, justBool): builder.PrependBoolSlot(30, justBool, 0)
+def AddJustBool(builder, justBool):
+ return ScalarStuffAddJustBool(builder, justBool)
+def ScalarStuffAddMaybeBool(builder, maybeBool): builder.PrependBoolSlot(31, maybeBool, None)
+def AddMaybeBool(builder, maybeBool):
+ return ScalarStuffAddMaybeBool(builder, maybeBool)
+def ScalarStuffAddDefaultBool(builder, defaultBool): builder.PrependBoolSlot(32, defaultBool, 1)
+def AddDefaultBool(builder, defaultBool):
+ return ScalarStuffAddDefaultBool(builder, defaultBool)
+def ScalarStuffAddJustEnum(builder, justEnum): builder.PrependInt8Slot(33, justEnum, 0)
+def AddJustEnum(builder, justEnum):
+ return ScalarStuffAddJustEnum(builder, justEnum)
+def ScalarStuffAddMaybeEnum(builder, maybeEnum): builder.PrependInt8Slot(34, maybeEnum, None)
+def AddMaybeEnum(builder, maybeEnum):
+ return ScalarStuffAddMaybeEnum(builder, maybeEnum)
+def ScalarStuffAddDefaultEnum(builder, defaultEnum): builder.PrependInt8Slot(35, defaultEnum, 1)
+def AddDefaultEnum(builder, defaultEnum):
+ return ScalarStuffAddDefaultEnum(builder, defaultEnum)
+def ScalarStuffEnd(builder): return builder.EndObject()
+def End(builder):
+ return ScalarStuffEnd(builder)
+
+class ScalarStuffT(object):
+
+ # ScalarStuffT
+ def __init__(self):
+ self.justI8 = 0 # type: int
+ self.maybeI8 = None # type: Optional[int]
+ self.defaultI8 = 42 # type: int
+ self.justU8 = 0 # type: int
+ self.maybeU8 = None # type: Optional[int]
+ self.defaultU8 = 42 # type: int
+ self.justI16 = 0 # type: int
+ self.maybeI16 = None # type: Optional[int]
+ self.defaultI16 = 42 # type: int
+ self.justU16 = 0 # type: int
+ self.maybeU16 = None # type: Optional[int]
+ self.defaultU16 = 42 # type: int
+ self.justI32 = 0 # type: int
+ self.maybeI32 = None # type: Optional[int]
+ self.defaultI32 = 42 # type: int
+ self.justU32 = 0 # type: int
+ self.maybeU32 = None # type: Optional[int]
+ self.defaultU32 = 42 # type: int
+ self.justI64 = 0 # type: int
+ self.maybeI64 = None # type: Optional[int]
+ self.defaultI64 = 42 # type: int
+ self.justU64 = 0 # type: int
+ self.maybeU64 = None # type: Optional[int]
+ self.defaultU64 = 42 # type: int
+ self.justF32 = 0.0 # type: float
+ self.maybeF32 = None # type: Optional[float]
+ self.defaultF32 = 42.0 # type: float
+ self.justF64 = 0.0 # type: float
+ self.maybeF64 = None # type: Optional[float]
+ self.defaultF64 = 42.0 # type: float
+ self.justBool = False # type: bool
+ self.maybeBool = None # type: Optional[bool]
+ self.defaultBool = True # type: bool
+ self.justEnum = 0 # type: int
+ self.maybeEnum = None # type: Optional[int]
+ self.defaultEnum = 1 # type: int
+
+ @classmethod
+ def InitFromBuf(cls, buf, pos):
+ scalarStuff = ScalarStuff()
+ scalarStuff.Init(buf, pos)
+ return cls.InitFromObj(scalarStuff)
+
+ @classmethod
+ def InitFromObj(cls, scalarStuff):
+ x = ScalarStuffT()
+ x._UnPack(scalarStuff)
+ return x
+
+ # ScalarStuffT
+ def _UnPack(self, scalarStuff):
+ if scalarStuff is None:
+ return
+ self.justI8 = scalarStuff.JustI8()
+ self.maybeI8 = scalarStuff.MaybeI8()
+ self.defaultI8 = scalarStuff.DefaultI8()
+ self.justU8 = scalarStuff.JustU8()
+ self.maybeU8 = scalarStuff.MaybeU8()
+ self.defaultU8 = scalarStuff.DefaultU8()
+ self.justI16 = scalarStuff.JustI16()
+ self.maybeI16 = scalarStuff.MaybeI16()
+ self.defaultI16 = scalarStuff.DefaultI16()
+ self.justU16 = scalarStuff.JustU16()
+ self.maybeU16 = scalarStuff.MaybeU16()
+ self.defaultU16 = scalarStuff.DefaultU16()
+ self.justI32 = scalarStuff.JustI32()
+ self.maybeI32 = scalarStuff.MaybeI32()
+ self.defaultI32 = scalarStuff.DefaultI32()
+ self.justU32 = scalarStuff.JustU32()
+ self.maybeU32 = scalarStuff.MaybeU32()
+ self.defaultU32 = scalarStuff.DefaultU32()
+ self.justI64 = scalarStuff.JustI64()
+ self.maybeI64 = scalarStuff.MaybeI64()
+ self.defaultI64 = scalarStuff.DefaultI64()
+ self.justU64 = scalarStuff.JustU64()
+ self.maybeU64 = scalarStuff.MaybeU64()
+ self.defaultU64 = scalarStuff.DefaultU64()
+ self.justF32 = scalarStuff.JustF32()
+ self.maybeF32 = scalarStuff.MaybeF32()
+ self.defaultF32 = scalarStuff.DefaultF32()
+ self.justF64 = scalarStuff.JustF64()
+ self.maybeF64 = scalarStuff.MaybeF64()
+ self.defaultF64 = scalarStuff.DefaultF64()
+ self.justBool = scalarStuff.JustBool()
+ self.maybeBool = scalarStuff.MaybeBool()
+ self.defaultBool = scalarStuff.DefaultBool()
+ self.justEnum = scalarStuff.JustEnum()
+ self.maybeEnum = scalarStuff.MaybeEnum()
+ self.defaultEnum = scalarStuff.DefaultEnum()
+
+ # ScalarStuffT
+ def Pack(self, builder):
+ ScalarStuffStart(builder)
+ ScalarStuffAddJustI8(builder, self.justI8)
+ ScalarStuffAddMaybeI8(builder, self.maybeI8)
+ ScalarStuffAddDefaultI8(builder, self.defaultI8)
+ ScalarStuffAddJustU8(builder, self.justU8)
+ ScalarStuffAddMaybeU8(builder, self.maybeU8)
+ ScalarStuffAddDefaultU8(builder, self.defaultU8)
+ ScalarStuffAddJustI16(builder, self.justI16)
+ ScalarStuffAddMaybeI16(builder, self.maybeI16)
+ ScalarStuffAddDefaultI16(builder, self.defaultI16)
+ ScalarStuffAddJustU16(builder, self.justU16)
+ ScalarStuffAddMaybeU16(builder, self.maybeU16)
+ ScalarStuffAddDefaultU16(builder, self.defaultU16)
+ ScalarStuffAddJustI32(builder, self.justI32)
+ ScalarStuffAddMaybeI32(builder, self.maybeI32)
+ ScalarStuffAddDefaultI32(builder, self.defaultI32)
+ ScalarStuffAddJustU32(builder, self.justU32)
+ ScalarStuffAddMaybeU32(builder, self.maybeU32)
+ ScalarStuffAddDefaultU32(builder, self.defaultU32)
+ ScalarStuffAddJustI64(builder, self.justI64)
+ ScalarStuffAddMaybeI64(builder, self.maybeI64)
+ ScalarStuffAddDefaultI64(builder, self.defaultI64)
+ ScalarStuffAddJustU64(builder, self.justU64)
+ ScalarStuffAddMaybeU64(builder, self.maybeU64)
+ ScalarStuffAddDefaultU64(builder, self.defaultU64)
+ ScalarStuffAddJustF32(builder, self.justF32)
+ ScalarStuffAddMaybeF32(builder, self.maybeF32)
+ ScalarStuffAddDefaultF32(builder, self.defaultF32)
+ ScalarStuffAddJustF64(builder, self.justF64)
+ ScalarStuffAddMaybeF64(builder, self.maybeF64)
+ ScalarStuffAddDefaultF64(builder, self.defaultF64)
+ ScalarStuffAddJustBool(builder, self.justBool)
+ ScalarStuffAddMaybeBool(builder, self.maybeBool)
+ ScalarStuffAddDefaultBool(builder, self.defaultBool)
+ ScalarStuffAddJustEnum(builder, self.justEnum)
+ ScalarStuffAddMaybeEnum(builder, self.maybeEnum)
+ ScalarStuffAddDefaultEnum(builder, self.defaultEnum)
+ scalarStuff = ScalarStuffEnd(builder)
+ return scalarStuff
diff --git a/tests/optional_scalars/__init__.py b/tests/optional_scalars/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/optional_scalars/__init__.py
diff --git a/tests/optional_scalars/mod.rs b/tests/optional_scalars/mod.rs
index b7af3c5..84291e3 100644
--- a/tests/optional_scalars/mod.rs
+++ b/tests/optional_scalars/mod.rs
@@ -1,4 +1,5 @@
// Automatically generated by the Flatbuffers compiler. Do not modify.
+// @generated
pub mod optional_scalars {
use super::*;
mod optional_byte_generated;
diff --git a/tests/optional_scalars/optional_scalars/optional_byte_generated.rs b/tests/optional_scalars/optional_scalars/optional_byte_generated.rs
index 226e9ec..dae1366 100644
--- a/tests/optional_scalars/optional_scalars/optional_byte_generated.rs
+++ b/tests/optional_scalars/optional_scalars/optional_byte_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
@@ -42,8 +47,8 @@
}
}
}
-impl std::fmt::Debug for OptionalByte {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+impl core::fmt::Debug for OptionalByte {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
if let Some(name) = self.variant_name() {
f.write_str(name)
} else {
diff --git a/tests/optional_scalars/optional_scalars/scalar_stuff_generated.rs b/tests/optional_scalars/optional_scalars/scalar_stuff_generated.rs
index 407e278..e201cc0 100644
--- a/tests/optional_scalars/optional_scalars/scalar_stuff_generated.rs
+++ b/tests/optional_scalars/optional_scalars/scalar_stuff_generated.rs
@@ -1,7 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
extern crate flatbuffers;
-use std::mem;
-use std::cmp::Ordering;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum ScalarStuffOffset {}
@@ -626,8 +631,8 @@
}
}
-impl std::fmt::Debug for ScalarStuff<'_> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Debug for ScalarStuff<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("ScalarStuff");
ds.field("just_i8", &self.just_i8());
ds.field("maybe_i8", &self.maybe_i8());
diff --git a/tests/optional_scalars_defaults.json b/tests/optional_scalars_defaults.json
new file mode 100644
index 0000000..1f44993
--- /dev/null
+++ b/tests/optional_scalars_defaults.json
@@ -0,0 +1,38 @@
+{
+ just_i8: 4,
+ maybe_i8: null,
+ default_i8: 42,
+ just_u8: 0,
+ maybe_u8: 0,
+ default_u8: 0,
+ just_i16: 4,
+ maybe_i16: null,
+ default_i16: 42,
+ just_u16: 0,
+ maybe_u16: 0,
+ default_u16: 0,
+ just_i32: 4,
+ maybe_i32: null,
+ default_i32: 42,
+ just_u32: 0,
+ maybe_u32: 0,
+ default_u32: 0,
+ just_i64: 4,
+ maybe_i64: null,
+ default_i64: 42,
+ just_u64: 0,
+ maybe_u64: 0,
+ default_u64: 0,
+ just_f32: 4.0,
+ maybe_f32: null,
+ default_f32: 42.0,
+ just_f64: 0.0,
+ maybe_f64: 0.0,
+ default_f64: 0.0,
+ just_bool: true,
+ maybe_bool: null,
+ default_bool: false,
+ just_enum: "None",
+ maybe_enum: "One",
+ default_enum: "Two"
+}
diff --git a/tests/optional_scalars_generated.h b/tests/optional_scalars_generated.h
index c295eba..f71f98d 100644
--- a/tests/optional_scalars_generated.h
+++ b/tests/optional_scalars_generated.h
@@ -6,6 +6,13 @@
#include "flatbuffers/flatbuffers.h"
+// Ensure the included flatbuffers.h is the same version as when this file was
+// generated, otherwise it may not be compatible.
+static_assert(FLATBUFFERS_VERSION_MAJOR == 2 &&
+ FLATBUFFERS_VERSION_MINOR == 0 &&
+ FLATBUFFERS_VERSION_REVISION == 8,
+ "Non-compatible flatbuffers version included");
+
namespace optional_scalars {
struct ScalarStuff;
diff --git a/tests/optional_scalars_generated.lobster b/tests/optional_scalars_generated.lobster
index 95cba95..16d9c56 100644
--- a/tests/optional_scalars_generated.lobster
+++ b/tests/optional_scalars_generated.lobster
@@ -11,77 +11,77 @@
class ScalarStuff
class ScalarStuff : flatbuffers_handle
- def just_i8():
+ def just_i8() -> int:
return buf_.flatbuffers_field_int8(pos_, 4, 0)
- def maybe_i8():
+ def maybe_i8() -> int, bool:
return buf_.flatbuffers_field_int8(pos_, 6, 0), buf_.flatbuffers_field_present(pos_, 6)
- def default_i8():
+ def default_i8() -> int:
return buf_.flatbuffers_field_int8(pos_, 8, 42)
- def just_u8():
+ def just_u8() -> int:
return buf_.flatbuffers_field_uint8(pos_, 10, 0)
- def maybe_u8():
+ def maybe_u8() -> int, bool:
return buf_.flatbuffers_field_uint8(pos_, 12, 0), buf_.flatbuffers_field_present(pos_, 12)
- def default_u8():
+ def default_u8() -> int:
return buf_.flatbuffers_field_uint8(pos_, 14, 42)
- def just_i16():
+ def just_i16() -> int:
return buf_.flatbuffers_field_int16(pos_, 16, 0)
- def maybe_i16():
+ def maybe_i16() -> int, bool:
return buf_.flatbuffers_field_int16(pos_, 18, 0), buf_.flatbuffers_field_present(pos_, 18)
- def default_i16():
+ def default_i16() -> int:
return buf_.flatbuffers_field_int16(pos_, 20, 42)
- def just_u16():
+ def just_u16() -> int:
return buf_.flatbuffers_field_uint16(pos_, 22, 0)
- def maybe_u16():
+ def maybe_u16() -> int, bool:
return buf_.flatbuffers_field_uint16(pos_, 24, 0), buf_.flatbuffers_field_present(pos_, 24)
- def default_u16():
+ def default_u16() -> int:
return buf_.flatbuffers_field_uint16(pos_, 26, 42)
- def just_i32():
+ def just_i32() -> int:
return buf_.flatbuffers_field_int32(pos_, 28, 0)
- def maybe_i32():
+ def maybe_i32() -> int, bool:
return buf_.flatbuffers_field_int32(pos_, 30, 0), buf_.flatbuffers_field_present(pos_, 30)
- def default_i32():
+ def default_i32() -> int:
return buf_.flatbuffers_field_int32(pos_, 32, 42)
- def just_u32():
+ def just_u32() -> int:
return buf_.flatbuffers_field_uint32(pos_, 34, 0)
- def maybe_u32():
+ def maybe_u32() -> int, bool:
return buf_.flatbuffers_field_uint32(pos_, 36, 0), buf_.flatbuffers_field_present(pos_, 36)
- def default_u32():
+ def default_u32() -> int:
return buf_.flatbuffers_field_uint32(pos_, 38, 42)
- def just_i64():
+ def just_i64() -> int:
return buf_.flatbuffers_field_int64(pos_, 40, 0)
- def maybe_i64():
+ def maybe_i64() -> int, bool:
return buf_.flatbuffers_field_int64(pos_, 42, 0), buf_.flatbuffers_field_present(pos_, 42)
- def default_i64():
+ def default_i64() -> int:
return buf_.flatbuffers_field_int64(pos_, 44, 42)
- def just_u64():
+ def just_u64() -> int:
return buf_.flatbuffers_field_uint64(pos_, 46, 0)
- def maybe_u64():
+ def maybe_u64() -> int, bool:
return buf_.flatbuffers_field_uint64(pos_, 48, 0), buf_.flatbuffers_field_present(pos_, 48)
- def default_u64():
+ def default_u64() -> int:
return buf_.flatbuffers_field_uint64(pos_, 50, 42)
- def just_f32():
+ def just_f32() -> float:
return buf_.flatbuffers_field_float32(pos_, 52, 0.0)
- def maybe_f32():
+ def maybe_f32() -> float, bool:
return buf_.flatbuffers_field_float32(pos_, 54, 0), buf_.flatbuffers_field_present(pos_, 54)
- def default_f32():
+ def default_f32() -> float:
return buf_.flatbuffers_field_float32(pos_, 56, 42.0)
- def just_f64():
+ def just_f64() -> float:
return buf_.flatbuffers_field_float64(pos_, 58, 0.0)
- def maybe_f64():
+ def maybe_f64() -> float, bool:
return buf_.flatbuffers_field_float64(pos_, 60, 0), buf_.flatbuffers_field_present(pos_, 60)
- def default_f64():
+ def default_f64() -> float:
return buf_.flatbuffers_field_float64(pos_, 62, 42.0)
- def just_bool():
- return buf_.flatbuffers_field_int8(pos_, 64, 0)
- def maybe_bool():
- return buf_.flatbuffers_field_int8(pos_, 66, 0), buf_.flatbuffers_field_present(pos_, 66)
- def default_bool():
- return buf_.flatbuffers_field_int8(pos_, 68, 1)
- def just_enum():
+ def just_bool() -> bool:
+ return bool(buf_.flatbuffers_field_int8(pos_, 64, 0))
+ def maybe_bool() -> bool, bool:
+ return bool(buf_.flatbuffers_field_int8(pos_, 66, 0)), buf_.flatbuffers_field_present(pos_, 66)
+ def default_bool() -> bool:
+ return bool(buf_.flatbuffers_field_int8(pos_, 68, 1))
+ def just_enum() -> OptionalByte:
return OptionalByte(buf_.flatbuffers_field_int8(pos_, 70, 0))
- def maybe_enum():
+ def maybe_enum() -> OptionalByte, bool:
return OptionalByte(buf_.flatbuffers_field_int8(pos_, 72, 0)), buf_.flatbuffers_field_present(pos_, 72)
- def default_enum():
+ def default_enum() -> OptionalByte:
return OptionalByte(buf_.flatbuffers_field_int8(pos_, 74, 1))
def GetRootAsScalarStuff(buf:string): return ScalarStuff { buf, buf.flatbuffers_indirect(0) }
@@ -181,13 +181,13 @@
def add_default_f64(default_f64:float):
b_.PrependFloat64Slot(29, default_f64, 42.0)
return this
- def add_just_bool(just_bool:int):
+ def add_just_bool(just_bool:bool):
b_.PrependBoolSlot(30, just_bool, 0)
return this
- def add_maybe_bool(maybe_bool:int):
+ def add_maybe_bool(maybe_bool:bool):
b_.PrependBoolSlot(31, maybe_bool)
return this
- def add_default_bool(default_bool:int):
+ def add_default_bool(default_bool:bool):
b_.PrependBoolSlot(32, default_bool, 1)
return this
def add_just_enum(just_enum:OptionalByte):
diff --git a/tests/optional_scalars_generated.ts b/tests/optional_scalars_generated.ts
new file mode 100644
index 0000000..4a83c43
--- /dev/null
+++ b/tests/optional_scalars_generated.ts
@@ -0,0 +1,4 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+export { OptionalByte } from './optional-scalars/optional-byte';
+export { ScalarStuff } from './optional-scalars/scalar-stuff';
diff --git a/tests/optional_scalars_test.cpp b/tests/optional_scalars_test.cpp
new file mode 100644
index 0000000..7d4a87d
--- /dev/null
+++ b/tests/optional_scalars_test.cpp
@@ -0,0 +1,101 @@
+#include "optional_scalars_test.h"
+#include <string>
+#include <vector>
+#include "flatbuffers/idl.h"
+#include "optional_scalars_generated.h"
+#include "test_assert.h"
+
+namespace flatbuffers{
+ namespace tests{
+
+
+void OptionalScalarsTest() {
+ // Simple schemas and a "has optional scalar" sentinal.
+ std::vector<std::string> schemas;
+ schemas.push_back("table Monster { mana : int; }");
+ schemas.push_back("table Monster { mana : int = 42; }");
+ schemas.push_back("table Monster { mana : int = null; }");
+ schemas.push_back("table Monster { mana : long; }");
+ schemas.push_back("table Monster { mana : long = 42; }");
+ schemas.push_back("table Monster { mana : long = null; }");
+ schemas.push_back("table Monster { mana : float; }");
+ schemas.push_back("table Monster { mana : float = 42; }");
+ schemas.push_back("table Monster { mana : float = null; }");
+ schemas.push_back("table Monster { mana : double; }");
+ schemas.push_back("table Monster { mana : double = 42; }");
+ schemas.push_back("table Monster { mana : double = null; }");
+ schemas.push_back("table Monster { mana : bool; }");
+ schemas.push_back("table Monster { mana : bool = 42; }");
+ schemas.push_back("table Monster { mana : bool = null; }");
+ schemas.push_back(
+ "enum Enum: int {A=0, B=1} "
+ "table Monster { mana : Enum; }");
+ schemas.push_back(
+ "enum Enum: int {A=0, B=1} "
+ "table Monster { mana : Enum = B; }");
+ schemas.push_back(
+ "enum Enum: int {A=0, B=1} "
+ "table Monster { mana : Enum = null; }");
+
+ // Check the FieldDef is correctly set.
+ for (auto schema = schemas.begin(); schema < schemas.end(); schema++) {
+ const bool has_null = schema->find("null") != std::string::npos;
+ flatbuffers::Parser parser;
+ TEST_ASSERT(parser.Parse(schema->c_str()));
+ const auto *mana = parser.structs_.Lookup("Monster")->fields.Lookup("mana");
+ TEST_EQ(mana->IsOptional(), has_null);
+ }
+
+ // Test if nullable scalars are allowed for each language.
+ for (unsigned lang = 1; lang < flatbuffers::IDLOptions::kMAX; lang <<= 1) {
+ flatbuffers::IDLOptions opts;
+ opts.lang_to_generate = lang;
+ if (false == flatbuffers::Parser::SupportsOptionalScalars(opts)) {
+ continue;
+ }
+ for (auto schema = schemas.begin(); schema < schemas.end(); schema++) {
+ flatbuffers::Parser parser(opts);
+ auto done = parser.Parse(schema->c_str());
+ TEST_EQ_STR(parser.error_.c_str(), "");
+ TEST_ASSERT(done);
+ }
+ }
+
+ // test C++ nullable
+ flatbuffers::FlatBufferBuilder fbb;
+ FinishScalarStuffBuffer(
+ fbb, optional_scalars::CreateScalarStuff(fbb, 1, static_cast<int8_t>(2)));
+ auto opts = optional_scalars::GetMutableScalarStuff(fbb.GetBufferPointer());
+ TEST_ASSERT(!opts->maybe_bool());
+ TEST_ASSERT(!opts->maybe_f32().has_value());
+ TEST_ASSERT(opts->maybe_i8().has_value());
+ TEST_EQ(opts->maybe_i8().value(), 2);
+ TEST_ASSERT(opts->mutate_maybe_i8(3));
+ TEST_ASSERT(opts->maybe_i8().has_value());
+ TEST_EQ(opts->maybe_i8().value(), 3);
+ TEST_ASSERT(!opts->mutate_maybe_i16(-10));
+
+ optional_scalars::ScalarStuffT obj;
+ TEST_ASSERT(!obj.maybe_bool);
+ TEST_ASSERT(!obj.maybe_f32.has_value());
+ opts->UnPackTo(&obj);
+ TEST_ASSERT(!obj.maybe_bool);
+ TEST_ASSERT(!obj.maybe_f32.has_value());
+ TEST_ASSERT(obj.maybe_i8.has_value() && obj.maybe_i8.value() == 3);
+ TEST_ASSERT(obj.maybe_i8 && *obj.maybe_i8 == 3);
+ obj.maybe_i32 = -1;
+ obj.maybe_enum = optional_scalars::OptionalByte_Two;
+
+ fbb.Clear();
+ FinishScalarStuffBuffer(fbb, optional_scalars::ScalarStuff::Pack(fbb, &obj));
+ opts = optional_scalars::GetMutableScalarStuff(fbb.GetBufferPointer());
+ TEST_ASSERT(opts->maybe_i8().has_value());
+ TEST_EQ(opts->maybe_i8().value(), 3);
+ TEST_ASSERT(opts->maybe_i32().has_value());
+ TEST_EQ(opts->maybe_i32().value(), -1);
+ TEST_EQ(opts->maybe_enum().value(), optional_scalars::OptionalByte_Two);
+ TEST_ASSERT(opts->maybe_i32() == flatbuffers::Optional<int64_t>(-1));
+}
+
+ }
+}
\ No newline at end of file
diff --git a/tests/optional_scalars_test.h b/tests/optional_scalars_test.h
new file mode 100644
index 0000000..922e52c
--- /dev/null
+++ b/tests/optional_scalars_test.h
@@ -0,0 +1,13 @@
+#ifndef TESTS_OPTIONAL_SCALARS_TEST_H
+#define TESTS_OPTIONAL_SCALARS_TEST_H
+
+
+namespace flatbuffers {
+namespace tests {
+
+void OptionalScalarsTest();
+
+} // namespace tests
+} // namespace flatbuffers
+
+#endif
diff --git a/tests/package.json b/tests/package.json
deleted file mode 100644
index 654e57f..0000000
--- a/tests/package.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "dependencies": {
- "esm": "^3.2.25",
- "flatbuffers": "../",
- "grpc": "^1.24.6"
- }
-}
diff --git a/tests/parser_test.cpp b/tests/parser_test.cpp
new file mode 100644
index 0000000..1a43504
--- /dev/null
+++ b/tests/parser_test.cpp
@@ -0,0 +1,900 @@
+#include "parser_test.h"
+
+#include <cmath>
+#include <string>
+
+#include "flatbuffers/idl.h"
+#include "test_assert.h"
+
+namespace flatbuffers {
+namespace tests {
+namespace {
+
+// Shortcuts for the infinity.
+static const auto infinity_f = std::numeric_limits<float>::infinity();
+static const auto infinity_d = std::numeric_limits<double>::infinity();
+
+// Test that parser errors are actually generated.
+static void TestError_(const char *src, const char *error_substr, bool strict_json,
+ const char *file, int line, const char *func) {
+ flatbuffers::IDLOptions opts;
+ opts.strict_json = strict_json;
+ flatbuffers::Parser parser(opts);
+ if (parser.Parse(src)) {
+ TestFail("true", "false",
+ ("parser.Parse(\"" + std::string(src) + "\")").c_str(), file, line,
+ func);
+ } else if (!strstr(parser.error_.c_str(), error_substr)) {
+ TestFail(error_substr, parser.error_.c_str(),
+ ("parser.Parse(\"" + std::string(src) + "\")").c_str(), file, line,
+ func);
+ }
+}
+
+static void TestError_(const char *src, const char *error_substr, const char *file,
+ int line, const char *func) {
+ TestError_(src, error_substr, false, file, line, func);
+}
+
+#ifdef _WIN32
+# define TestError(src, ...) \
+ TestError_(src, __VA_ARGS__, __FILE__, __LINE__, __FUNCTION__)
+#else
+# define TestError(src, ...) \
+ TestError_(src, __VA_ARGS__, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#endif
+
+static bool FloatCompare(float a, float b) { return fabs(a - b) < 0.001; }
+
+} // namespace
+
+// Test that parsing errors occur as we'd expect.
+// Also useful for coverage, making sure these paths are run.
+void ErrorTest() {
+ // In order they appear in idl_parser.cpp
+ TestError("table X { Y:byte; } root_type X; { Y: 999 }", "does not fit");
+ TestError("\"\0", "illegal");
+ TestError("\"\\q", "escape code");
+ TestError("table ///", "documentation");
+ TestError("@", "illegal");
+ TestError("table 1", "expecting");
+ TestError("table X { Y:[[int]]; }", "nested vector");
+ TestError("table X { Y:1; }", "illegal type");
+ TestError("table X { Y:int; Y:int; }", "field already");
+ TestError("table Y {} table X { Y:int; }", "same as table");
+ TestError("struct X { Y:string; }", "only scalar");
+ TestError("struct X { a:uint = 42; }", "default values");
+ TestError("enum Y:byte { Z = 1 } table X { y:Y; }", "not part of enum");
+ TestError("struct X { Y:int (deprecated); }", "deprecate");
+ TestError("union Z { X } table X { Y:Z; } root_type X; { Y: {}, A:1 }",
+ "missing type field");
+ TestError("union Z { X } table X { Y:Z; } root_type X; { Y_type: 99, Y: {",
+ "type id");
+ TestError("table X { Y:int; } root_type X; { Z:", "unknown field");
+ TestError("table X { Y:int; } root_type X; { Y:", "string constant", true);
+ TestError("table X { Y:int; } root_type X; { \"Y\":1, }", "string constant",
+ true);
+ TestError(
+ "struct X { Y:int; Z:int; } table W { V:X; } root_type W; "
+ "{ V:{ Y:1 } }",
+ "wrong number");
+ TestError("enum E:byte { A } table X { Y:E; } root_type X; { Y:U }",
+ "unknown enum value");
+ TestError("table X { Y:byte; } root_type X; { Y:; }", "starting");
+ TestError("enum X:byte { Y } enum X {", "enum already");
+ TestError("enum X:float {}", "underlying");
+ TestError("enum X:byte { Y, Y }", "value already");
+ TestError("enum X:byte { Y=2, Z=2 }", "unique");
+ TestError("enum X:byte (force_align: 4) { Y }", "force_align");
+ TestError("table X { Y:int; } table X {", "datatype already");
+ TestError("table X { } union X { }", "datatype already");
+ TestError("union X { } table X { }", "datatype already");
+ TestError("namespace A; table X { } namespace A; union X { }",
+ "datatype already");
+ TestError("namespace A; union X { } namespace A; table X { }",
+ "datatype already");
+ TestError("struct X (force_align: 7) { Y:int; }", "force_align");
+ TestError("struct X {}", "size 0");
+ TestError("{}", "no root");
+ TestError("table X { Y:byte; } root_type X; { Y:1 } { Y:1 }", "end of file");
+ TestError("table X { Y:byte; } root_type X; { Y:1 } table Y{ Z:int }",
+ "end of file");
+ TestError("root_type X;", "unknown root");
+ TestError("struct X { Y:int; } root_type X;", "a table");
+ TestError("union X { Y }", "referenced");
+ TestError("union Z { X } struct X { Y:int; }", "only tables");
+ TestError("table X { Y:[int]; YLength:int; }", "clash");
+ TestError("table X { Y:byte; } root_type X; { Y:1, Y:2 }", "more than once");
+ // float to integer conversion is forbidden
+ TestError("table X { Y:int; } root_type X; { Y:1.0 }", "float");
+ TestError("table X { Y:bool; } root_type X; { Y:1.0 }", "float");
+ TestError("enum X:bool { Y = true }", "must be integral");
+ // Array of non-scalar
+ TestError("table X { x:int; } struct Y { y:[X:2]; }",
+ "may contain only scalar or struct fields");
+ // Non-snake case field names
+ TestError("table X { Y: int; } root_type Y: {Y:1.0}", "snake_case");
+ // Complex defaults
+ TestError("table X { y: string = 1; }", "expecting: string");
+ TestError("table X { y: string = []; }", " Cannot assign token");
+ TestError("table X { y: [int] = [1]; }", "Expected `]`");
+ TestError("table X { y: [int] = [; }", "Expected `]`");
+ TestError("table X { y: [int] = \"\"; }", "type mismatch");
+ // An identifier can't start from sign (+|-)
+ TestError("table X { -Y: int; } root_type Y: {Y:1.0}", "identifier");
+ TestError("table X { +Y: int; } root_type Y: {Y:1.0}", "identifier");
+}
+
+void EnumOutOfRangeTest() {
+ TestError("enum X:byte { Y = 128 }", "enum value does not fit");
+ TestError("enum X:byte { Y = -129 }", "enum value does not fit");
+ TestError("enum X:byte { Y = 126, Z0, Z1 }", "enum value does not fit");
+ TestError("enum X:ubyte { Y = -1 }", "enum value does not fit");
+ TestError("enum X:ubyte { Y = 256 }", "enum value does not fit");
+ TestError("enum X:ubyte { Y = 255, Z }", "enum value does not fit");
+ TestError("table Y{} union X { Y = -1 }", "enum value does not fit");
+ TestError("table Y{} union X { Y = 256 }", "enum value does not fit");
+ TestError("table Y{} union X { Y = 255, Z:Y }", "enum value does not fit");
+ TestError("enum X:int { Y = -2147483649 }", "enum value does not fit");
+ TestError("enum X:int { Y = 2147483648 }", "enum value does not fit");
+ TestError("enum X:uint { Y = -1 }", "enum value does not fit");
+ TestError("enum X:uint { Y = 4294967297 }", "enum value does not fit");
+ TestError("enum X:long { Y = 9223372036854775808 }", "does not fit");
+ TestError("enum X:long { Y = 9223372036854775807, Z }",
+ "enum value does not fit");
+ TestError("enum X:ulong { Y = -1 }", "does not fit");
+ TestError("enum X:ubyte (bit_flags) { Y=8 }", "bit flag out");
+ TestError("enum X:byte (bit_flags) { Y=7 }", "must be unsigned"); // -128
+ // bit_flgs out of range
+ TestError("enum X:ubyte (bit_flags) { Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8 }",
+ "out of range");
+}
+
+void IntegerOutOfRangeTest() {
+ TestError("table T { F:byte; } root_type T; { F:128 }",
+ "constant does not fit");
+ TestError("table T { F:byte; } root_type T; { F:-129 }",
+ "constant does not fit");
+ TestError("table T { F:ubyte; } root_type T; { F:256 }",
+ "constant does not fit");
+ TestError("table T { F:ubyte; } root_type T; { F:-1 }",
+ "constant does not fit");
+ TestError("table T { F:short; } root_type T; { F:32768 }",
+ "constant does not fit");
+ TestError("table T { F:short; } root_type T; { F:-32769 }",
+ "constant does not fit");
+ TestError("table T { F:ushort; } root_type T; { F:65536 }",
+ "constant does not fit");
+ TestError("table T { F:ushort; } root_type T; { F:-1 }",
+ "constant does not fit");
+ TestError("table T { F:int; } root_type T; { F:2147483648 }",
+ "constant does not fit");
+ TestError("table T { F:int; } root_type T; { F:-2147483649 }",
+ "constant does not fit");
+ TestError("table T { F:uint; } root_type T; { F:4294967296 }",
+ "constant does not fit");
+ TestError("table T { F:uint; } root_type T; { F:-1 }",
+ "constant does not fit");
+ // Check fixed width aliases
+ TestError("table X { Y:uint8; } root_type X; { Y: -1 }", "does not fit");
+ TestError("table X { Y:uint8; } root_type X; { Y: 256 }", "does not fit");
+ TestError("table X { Y:uint16; } root_type X; { Y: -1 }", "does not fit");
+ TestError("table X { Y:uint16; } root_type X; { Y: 65536 }", "does not fit");
+ TestError("table X { Y:uint32; } root_type X; { Y: -1 }", "");
+ TestError("table X { Y:uint32; } root_type X; { Y: 4294967296 }",
+ "does not fit");
+ TestError("table X { Y:uint64; } root_type X; { Y: -1 }", "");
+ TestError("table X { Y:uint64; } root_type X; { Y: -9223372036854775809 }",
+ "does not fit");
+ TestError("table X { Y:uint64; } root_type X; { Y: 18446744073709551616 }",
+ "does not fit");
+
+ TestError("table X { Y:int8; } root_type X; { Y: -129 }", "does not fit");
+ TestError("table X { Y:int8; } root_type X; { Y: 128 }", "does not fit");
+ TestError("table X { Y:int16; } root_type X; { Y: -32769 }", "does not fit");
+ TestError("table X { Y:int16; } root_type X; { Y: 32768 }", "does not fit");
+ TestError("table X { Y:int32; } root_type X; { Y: -2147483649 }", "");
+ TestError("table X { Y:int32; } root_type X; { Y: 2147483648 }",
+ "does not fit");
+ TestError("table X { Y:int64; } root_type X; { Y: -9223372036854775809 }",
+ "does not fit");
+ TestError("table X { Y:int64; } root_type X; { Y: 9223372036854775808 }",
+ "does not fit");
+ // check out-of-int64 as int8
+ TestError("table X { Y:int8; } root_type X; { Y: -9223372036854775809 }",
+ "does not fit");
+ TestError("table X { Y:int8; } root_type X; { Y: 9223372036854775808 }",
+ "does not fit");
+
+ // Check default values
+ TestError("table X { Y:int64=-9223372036854775809; } root_type X; {}",
+ "does not fit");
+ TestError("table X { Y:int64= 9223372036854775808; } root_type X; {}",
+ "does not fit");
+ TestError("table X { Y:uint64; } root_type X; { Y: -1 }", "");
+ TestError("table X { Y:uint64=-9223372036854775809; } root_type X; {}",
+ "does not fit");
+ TestError("table X { Y:uint64= 18446744073709551616; } root_type X; {}",
+ "does not fit");
+}
+
+void InvalidFloatTest() {
+ auto invalid_msg = "invalid number";
+ auto comma_msg = "expecting: ,";
+ TestError("table T { F:float; } root_type T; { F:1,0 }", "");
+ TestError("table T { F:float; } root_type T; { F:. }", "");
+ TestError("table T { F:float; } root_type T; { F:- }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:+ }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:-. }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:+. }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:.e }", "");
+ TestError("table T { F:float; } root_type T; { F:-e }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:+e }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:-.e }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:+.e }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:-e1 }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:+e1 }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:1.0e+ }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:1.0e- }", invalid_msg);
+ // exponent pP is mandatory for hex-float
+ TestError("table T { F:float; } root_type T; { F:0x0 }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:-0x. }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:0x. }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:0Xe }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:\"0Xe\" }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:\"nan(1)\" }", invalid_msg);
+ // eE not exponent in hex-float!
+ TestError("table T { F:float; } root_type T; { F:0x0.0e+ }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:0x0.0e- }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:0x0.0p }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:0x0.0p+ }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:0x0.0p- }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:0x0.0pa1 }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:0x0.0e+ }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:0x0.0e- }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:0x0.0e+0 }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:0x0.0e-0 }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:0x0.0ep+ }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:0x0.0ep- }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:1.2.3 }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:1.2.e3 }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:1.2e.3 }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:1.2e0.3 }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:1.2e3. }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:1.2e3.0 }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:+-1.0 }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:1.0e+-1 }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:\"1.0e+-1\" }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:1.e0e }", comma_msg);
+ TestError("table T { F:float; } root_type T; { F:0x1.p0e }", comma_msg);
+ TestError("table T { F:float; } root_type T; { F:\" 0x10 \" }", invalid_msg);
+ // floats in string
+ TestError("table T { F:float; } root_type T; { F:\"1,2.\" }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:\"1.2e3.\" }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:\"0x1.p0e\" }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:\"0x1.0\" }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:\" 0x1.0\" }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:\"+ 0\" }", invalid_msg);
+ // disable escapes for "number-in-string"
+ TestError("table T { F:float; } root_type T; { F:\"\\f1.2e3.\" }", "invalid");
+ TestError("table T { F:float; } root_type T; { F:\"\\t1.2e3.\" }", "invalid");
+ TestError("table T { F:float; } root_type T; { F:\"\\n1.2e3.\" }", "invalid");
+ TestError("table T { F:float; } root_type T; { F:\"\\r1.2e3.\" }", "invalid");
+ TestError("table T { F:float; } root_type T; { F:\"4\\x005\" }", "invalid");
+ TestError("table T { F:float; } root_type T; { F:\"\'12\'\" }", invalid_msg);
+ // null is not a number constant!
+ TestError("table T { F:float; } root_type T; { F:\"null\" }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:null }", invalid_msg);
+}
+
+void UnicodeInvalidSurrogatesTest() {
+ TestError(
+ "table T { F:string; }"
+ "root_type T;"
+ "{ F:\"\\uD800\"}",
+ "unpaired high surrogate");
+ TestError(
+ "table T { F:string; }"
+ "root_type T;"
+ "{ F:\"\\uD800abcd\"}",
+ "unpaired high surrogate");
+ TestError(
+ "table T { F:string; }"
+ "root_type T;"
+ "{ F:\"\\uD800\\n\"}",
+ "unpaired high surrogate");
+ TestError(
+ "table T { F:string; }"
+ "root_type T;"
+ "{ F:\"\\uD800\\uD800\"}",
+ "multiple high surrogates");
+ TestError(
+ "table T { F:string; }"
+ "root_type T;"
+ "{ F:\"\\uDC00\"}",
+ "unpaired low surrogate");
+}
+
+void InvalidUTF8Test() {
+ // "1 byte" pattern, under min length of 2 bytes
+ TestError(
+ "table T { F:string; }"
+ "root_type T;"
+ "{ F:\"\x80\"}",
+ "illegal UTF-8 sequence");
+ // 2 byte pattern, string too short
+ TestError(
+ "table T { F:string; }"
+ "root_type T;"
+ "{ F:\"\xDF\"}",
+ "illegal UTF-8 sequence");
+ // 3 byte pattern, string too short
+ TestError(
+ "table T { F:string; }"
+ "root_type T;"
+ "{ F:\"\xEF\xBF\"}",
+ "illegal UTF-8 sequence");
+ // 4 byte pattern, string too short
+ TestError(
+ "table T { F:string; }"
+ "root_type T;"
+ "{ F:\"\xF7\xBF\xBF\"}",
+ "illegal UTF-8 sequence");
+ // "5 byte" pattern, string too short
+ TestError(
+ "table T { F:string; }"
+ "root_type T;"
+ "{ F:\"\xFB\xBF\xBF\xBF\"}",
+ "illegal UTF-8 sequence");
+ // "6 byte" pattern, string too short
+ TestError(
+ "table T { F:string; }"
+ "root_type T;"
+ "{ F:\"\xFD\xBF\xBF\xBF\xBF\"}",
+ "illegal UTF-8 sequence");
+ // "7 byte" pattern, string too short
+ TestError(
+ "table T { F:string; }"
+ "root_type T;"
+ "{ F:\"\xFE\xBF\xBF\xBF\xBF\xBF\"}",
+ "illegal UTF-8 sequence");
+ // "5 byte" pattern, over max length of 4 bytes
+ TestError(
+ "table T { F:string; }"
+ "root_type T;"
+ "{ F:\"\xFB\xBF\xBF\xBF\xBF\"}",
+ "illegal UTF-8 sequence");
+ // "6 byte" pattern, over max length of 4 bytes
+ TestError(
+ "table T { F:string; }"
+ "root_type T;"
+ "{ F:\"\xFD\xBF\xBF\xBF\xBF\xBF\"}",
+ "illegal UTF-8 sequence");
+ // "7 byte" pattern, over max length of 4 bytes
+ TestError(
+ "table T { F:string; }"
+ "root_type T;"
+ "{ F:\"\xFE\xBF\xBF\xBF\xBF\xBF\xBF\"}",
+ "illegal UTF-8 sequence");
+
+ // Three invalid encodings for U+000A (\n, aka NEWLINE)
+ TestError(
+ "table T { F:string; }"
+ "root_type T;"
+ "{ F:\"\xC0\x8A\"}",
+ "illegal UTF-8 sequence");
+ TestError(
+ "table T { F:string; }"
+ "root_type T;"
+ "{ F:\"\xE0\x80\x8A\"}",
+ "illegal UTF-8 sequence");
+ TestError(
+ "table T { F:string; }"
+ "root_type T;"
+ "{ F:\"\xF0\x80\x80\x8A\"}",
+ "illegal UTF-8 sequence");
+
+ // Two invalid encodings for U+00A9 (COPYRIGHT SYMBOL)
+ TestError(
+ "table T { F:string; }"
+ "root_type T;"
+ "{ F:\"\xE0\x81\xA9\"}",
+ "illegal UTF-8 sequence");
+ TestError(
+ "table T { F:string; }"
+ "root_type T;"
+ "{ F:\"\xF0\x80\x81\xA9\"}",
+ "illegal UTF-8 sequence");
+
+ // Invalid encoding for U+20AC (EURO SYMBOL)
+ TestError(
+ "table T { F:string; }"
+ "root_type T;"
+ "{ F:\"\xF0\x82\x82\xAC\"}",
+ "illegal UTF-8 sequence");
+
+ // UTF-16 surrogate values between U+D800 and U+DFFF cannot be encoded in
+ // UTF-8
+ TestError(
+ "table T { F:string; }"
+ "root_type T;"
+ // U+10400 "encoded" as U+D801 U+DC00
+ "{ F:\"\xED\xA0\x81\xED\xB0\x80\"}",
+ "illegal UTF-8 sequence");
+
+ // Check independence of identifier from locale.
+ std::string locale_ident;
+ locale_ident += "table T { F";
+ locale_ident += static_cast<char>(-32); // unsigned 0xE0
+ locale_ident += " :string; }";
+ locale_ident += "root_type T;";
+ locale_ident += "{}";
+ TestError(locale_ident.c_str(), "");
+}
+
+template<typename T>
+T TestValue(const char *json, const char *type_name,
+ const char *decls = nullptr) {
+ flatbuffers::Parser parser;
+ parser.builder_.ForceDefaults(true); // return defaults
+ auto check_default = json ? false : true;
+ if (check_default) { parser.opts.output_default_scalars_in_json = true; }
+ // Simple schema.
+ std::string schema = std::string(decls ? decls : "") + "\n" +
+ "table X { y:" + std::string(type_name) +
+ "; } root_type X;";
+ auto schema_done = parser.Parse(schema.c_str());
+ TEST_EQ_STR(parser.error_.c_str(), "");
+ TEST_EQ(schema_done, true);
+
+ auto done = parser.Parse(check_default ? "{}" : json);
+ TEST_EQ_STR(parser.error_.c_str(), "");
+ TEST_EQ(done, true);
+
+ // Check with print.
+ std::string print_back;
+ parser.opts.indent_step = -1;
+ TEST_EQ(GenerateText(parser, parser.builder_.GetBufferPointer(), &print_back),
+ true);
+ // restore value from its default
+ if (check_default) { TEST_EQ(parser.Parse(print_back.c_str()), true); }
+
+ auto root = flatbuffers::GetRoot<flatbuffers::Table>(
+ parser.builder_.GetBufferPointer());
+ return root->GetField<T>(flatbuffers::FieldIndexToOffset(0), 0);
+}
+
+// Additional parser testing not covered elsewhere.
+void ValueTest() {
+ // Test scientific notation numbers.
+ TEST_EQ(
+ FloatCompare(TestValue<float>("{ y:0.0314159e+2 }", "float"), 3.14159f),
+ true);
+ // number in string
+ TEST_EQ(FloatCompare(TestValue<float>("{ y:\"0.0314159e+2\" }", "float"),
+ 3.14159f),
+ true);
+
+ // Test conversion functions.
+ TEST_EQ(FloatCompare(TestValue<float>("{ y:cos(rad(180)) }", "float"), -1),
+ true);
+
+ // int embedded to string
+ TEST_EQ(TestValue<int>("{ y:\"-876\" }", "int=-123"), -876);
+ TEST_EQ(TestValue<int>("{ y:\"876\" }", "int=-123"), 876);
+
+ // Test negative hex constant.
+ TEST_EQ(TestValue<int>("{ y:-0x8ea0 }", "int=-0x8ea0"), -36512);
+ TEST_EQ(TestValue<int>(nullptr, "int=-0x8ea0"), -36512);
+
+ // positive hex constant
+ TEST_EQ(TestValue<int>("{ y:0x1abcdef }", "int=0x1"), 0x1abcdef);
+ // with optional '+' sign
+ TEST_EQ(TestValue<int>("{ y:+0x1abcdef }", "int=+0x1"), 0x1abcdef);
+ // hex in string
+ TEST_EQ(TestValue<int>("{ y:\"0x1abcdef\" }", "int=+0x1"), 0x1abcdef);
+
+ // Make sure we do unsigned 64bit correctly.
+ TEST_EQ(TestValue<uint64_t>("{ y:12335089644688340133 }", "ulong"),
+ 12335089644688340133ULL);
+
+ // bool in string
+ TEST_EQ(TestValue<bool>("{ y:\"false\" }", "bool=true"), false);
+ TEST_EQ(TestValue<bool>("{ y:\"true\" }", "bool=\"true\""), true);
+ TEST_EQ(TestValue<bool>("{ y:'false' }", "bool=true"), false);
+ TEST_EQ(TestValue<bool>("{ y:'true' }", "bool=\"true\""), true);
+
+ // check comments before and after json object
+ TEST_EQ(TestValue<int>("/*before*/ { y:1 } /*after*/", "int"), 1);
+ TEST_EQ(TestValue<int>("//before \n { y:1 } //after", "int"), 1);
+}
+
+void NestedListTest() {
+ flatbuffers::Parser parser1;
+ TEST_EQ(parser1.Parse("struct Test { a:short; b:byte; } table T { F:[Test]; }"
+ "root_type T;"
+ "{ F:[ [10,20], [30,40]] }"),
+ true);
+}
+
+void EnumStringsTest() {
+ flatbuffers::Parser parser1;
+ TEST_EQ(parser1.Parse("enum E:byte { A, B, C } table T { F:[E]; }"
+ "root_type T;"
+ "{ F:[ A, B, \"C\", \"A B C\" ] }"),
+ true);
+ flatbuffers::Parser parser2;
+ TEST_EQ(parser2.Parse("enum E:byte { A, B, C } table T { F:[int]; }"
+ "root_type T;"
+ "{ F:[ \"E.C\", \"E.A E.B E.C\" ] }"),
+ true);
+ // unsigned bit_flags
+ flatbuffers::Parser parser3;
+ TEST_EQ(
+ parser3.Parse("enum E:uint16 (bit_flags) { F0, F07=7, F08, F14=14, F15 }"
+ " table T { F: E = \"F15 F08\"; }"
+ "root_type T;"),
+ true);
+}
+
+void EnumValueTest() {
+ // json: "{ Y:0 }", schema: table X { y: "E"}
+ // 0 in enum (V=0) E then Y=0 is valid.
+ TEST_EQ(TestValue<int>("{ y:0 }", "E", "enum E:int { V }"), 0);
+ TEST_EQ(TestValue<int>("{ y:V }", "E", "enum E:int { V }"), 0);
+ // A default value of Y is 0.
+ TEST_EQ(TestValue<int>("{ }", "E", "enum E:int { V }"), 0);
+ TEST_EQ(TestValue<int>("{ y:5 }", "E=V", "enum E:int { V=5 }"), 5);
+ // Generate json with defaults and check.
+ TEST_EQ(TestValue<int>(nullptr, "E=V", "enum E:int { V=5 }"), 5);
+ // 5 in enum
+ TEST_EQ(TestValue<int>("{ y:5 }", "E", "enum E:int { Z, V=5 }"), 5);
+ TEST_EQ(TestValue<int>("{ y:5 }", "E=V", "enum E:int { Z, V=5 }"), 5);
+ // Generate json with defaults and check.
+ TEST_EQ(TestValue<int>(nullptr, "E", "enum E:int { Z, V=5 }"), 0);
+ TEST_EQ(TestValue<int>(nullptr, "E=V", "enum E:int { Z, V=5 }"), 5);
+ // u84 test
+ TEST_EQ(TestValue<uint64_t>(nullptr, "E=V",
+ "enum E:ulong { V = 13835058055282163712 }"),
+ 13835058055282163712ULL);
+ TEST_EQ(TestValue<uint64_t>(nullptr, "E=V",
+ "enum E:ulong { V = 18446744073709551615 }"),
+ 18446744073709551615ULL);
+ // Assign non-enum value to enum field. Is it right?
+ TEST_EQ(TestValue<int>("{ y:7 }", "E", "enum E:int { V = 0 }"), 7);
+ // Check that non-ascending values are valid.
+ TEST_EQ(TestValue<int>("{ y:5 }", "E=V", "enum E:int { Z=10, V=5 }"), 5);
+}
+
+void IntegerBoundaryTest() {
+ // Check numerical compatibility with non-C++ languages.
+ // By the C++ standard, std::numerical_limits<int64_t>::min() ==
+ // -9223372036854775807 (-2^63+1) or less* The Flatbuffers grammar and most of
+ // the languages (C#, Java, Rust) expect that minimum values are: -128,
+ // -32768,.., -9223372036854775808. Since C++20,
+ // static_cast<int64>(0x8000000000000000ULL) is well-defined two's complement
+ // cast. Therefore -9223372036854775808 should be valid negative value.
+ TEST_EQ(flatbuffers::numeric_limits<int8_t>::min(), -128);
+ TEST_EQ(flatbuffers::numeric_limits<int8_t>::max(), 127);
+ TEST_EQ(flatbuffers::numeric_limits<int16_t>::min(), -32768);
+ TEST_EQ(flatbuffers::numeric_limits<int16_t>::max(), 32767);
+ TEST_EQ(flatbuffers::numeric_limits<int32_t>::min() + 1, -2147483647);
+ TEST_EQ(flatbuffers::numeric_limits<int32_t>::max(), 2147483647ULL);
+ TEST_EQ(flatbuffers::numeric_limits<int64_t>::min() + 1LL,
+ -9223372036854775807LL);
+ TEST_EQ(flatbuffers::numeric_limits<int64_t>::max(), 9223372036854775807ULL);
+ TEST_EQ(flatbuffers::numeric_limits<uint8_t>::max(), 255);
+ TEST_EQ(flatbuffers::numeric_limits<uint16_t>::max(), 65535);
+ TEST_EQ(flatbuffers::numeric_limits<uint32_t>::max(), 4294967295ULL);
+ TEST_EQ(flatbuffers::numeric_limits<uint64_t>::max(),
+ 18446744073709551615ULL);
+
+ TEST_EQ(TestValue<int8_t>("{ y:127 }", "byte"), 127);
+ TEST_EQ(TestValue<int8_t>("{ y:-128 }", "byte"), -128);
+ TEST_EQ(TestValue<uint8_t>("{ y:255 }", "ubyte"), 255);
+ TEST_EQ(TestValue<uint8_t>("{ y:0 }", "ubyte"), 0);
+ TEST_EQ(TestValue<int16_t>("{ y:32767 }", "short"), 32767);
+ TEST_EQ(TestValue<int16_t>("{ y:-32768 }", "short"), -32768);
+ TEST_EQ(TestValue<uint16_t>("{ y:65535 }", "ushort"), 65535);
+ TEST_EQ(TestValue<uint16_t>("{ y:0 }", "ushort"), 0);
+ TEST_EQ(TestValue<int32_t>("{ y:2147483647 }", "int"), 2147483647);
+ TEST_EQ(TestValue<int32_t>("{ y:-2147483648 }", "int") + 1, -2147483647);
+ TEST_EQ(TestValue<uint32_t>("{ y:4294967295 }", "uint"), 4294967295);
+ TEST_EQ(TestValue<uint32_t>("{ y:0 }", "uint"), 0);
+ TEST_EQ(TestValue<int64_t>("{ y:9223372036854775807 }", "long"),
+ 9223372036854775807LL);
+ TEST_EQ(TestValue<int64_t>("{ y:-9223372036854775808 }", "long") + 1LL,
+ -9223372036854775807LL);
+ TEST_EQ(TestValue<uint64_t>("{ y:18446744073709551615 }", "ulong"),
+ 18446744073709551615ULL);
+ TEST_EQ(TestValue<uint64_t>("{ y:0 }", "ulong"), 0);
+ TEST_EQ(TestValue<uint64_t>("{ y: 18446744073709551615 }", "uint64"),
+ 18446744073709551615ULL);
+ // check that the default works
+ TEST_EQ(TestValue<uint64_t>(nullptr, "uint64 = 18446744073709551615"),
+ 18446744073709551615ULL);
+}
+
+void ValidFloatTest() {
+ // check rounding to infinity
+ TEST_EQ(TestValue<float>("{ y:+3.4029e+38 }", "float"), +infinity_f);
+ TEST_EQ(TestValue<float>("{ y:-3.4029e+38 }", "float"), -infinity_f);
+ TEST_EQ(TestValue<double>("{ y:+1.7977e+308 }", "double"), +infinity_d);
+ TEST_EQ(TestValue<double>("{ y:-1.7977e+308 }", "double"), -infinity_d);
+
+ TEST_EQ(
+ FloatCompare(TestValue<float>("{ y:0.0314159e+2 }", "float"), 3.14159f),
+ true);
+ // float in string
+ TEST_EQ(FloatCompare(TestValue<float>("{ y:\" 0.0314159e+2 \" }", "float"),
+ 3.14159f),
+ true);
+
+ TEST_EQ(TestValue<float>("{ y:1 }", "float"), 1.0f);
+ TEST_EQ(TestValue<float>("{ y:1.0 }", "float"), 1.0f);
+ TEST_EQ(TestValue<float>("{ y:1. }", "float"), 1.0f);
+ TEST_EQ(TestValue<float>("{ y:+1. }", "float"), 1.0f);
+ TEST_EQ(TestValue<float>("{ y:-1. }", "float"), -1.0f);
+ TEST_EQ(TestValue<float>("{ y:1.e0 }", "float"), 1.0f);
+ TEST_EQ(TestValue<float>("{ y:1.e+0 }", "float"), 1.0f);
+ TEST_EQ(TestValue<float>("{ y:1.e-0 }", "float"), 1.0f);
+ TEST_EQ(TestValue<float>("{ y:0.125 }", "float"), 0.125f);
+ TEST_EQ(TestValue<float>("{ y:.125 }", "float"), 0.125f);
+ TEST_EQ(TestValue<float>("{ y:-.125 }", "float"), -0.125f);
+ TEST_EQ(TestValue<float>("{ y:+.125 }", "float"), +0.125f);
+ TEST_EQ(TestValue<float>("{ y:5 }", "float"), 5.0f);
+ TEST_EQ(TestValue<float>("{ y:\"5\" }", "float"), 5.0f);
+
+#if defined(FLATBUFFERS_HAS_NEW_STRTOD) && (FLATBUFFERS_HAS_NEW_STRTOD > 0)
+ // Old MSVC versions may have problem with this check.
+ // https://www.exploringbinary.com/visual-c-plus-plus-strtod-still-broken/
+ TEST_EQ(TestValue<double>("{ y:6.9294956446009195e15 }", "double"),
+ 6929495644600920.0);
+ // check nan's
+ TEST_EQ(std::isnan(TestValue<double>("{ y:nan }", "double")), true);
+ TEST_EQ(std::isnan(TestValue<float>("{ y:nan }", "float")), true);
+ TEST_EQ(std::isnan(TestValue<float>("{ y:\"nan\" }", "float")), true);
+ TEST_EQ(std::isnan(TestValue<float>("{ y:\"+nan\" }", "float")), true);
+ TEST_EQ(std::isnan(TestValue<float>("{ y:\"-nan\" }", "float")), true);
+ TEST_EQ(std::isnan(TestValue<float>("{ y:+nan }", "float")), true);
+ TEST_EQ(std::isnan(TestValue<float>("{ y:-nan }", "float")), true);
+ TEST_EQ(std::isnan(TestValue<float>(nullptr, "float=nan")), true);
+ TEST_EQ(std::isnan(TestValue<float>(nullptr, "float=-nan")), true);
+ // check inf
+ TEST_EQ(TestValue<float>("{ y:inf }", "float"), infinity_f);
+ TEST_EQ(TestValue<float>("{ y:\"inf\" }", "float"), infinity_f);
+ TEST_EQ(TestValue<float>("{ y:\"-inf\" }", "float"), -infinity_f);
+ TEST_EQ(TestValue<float>("{ y:\"+inf\" }", "float"), infinity_f);
+ TEST_EQ(TestValue<float>("{ y:+inf }", "float"), infinity_f);
+ TEST_EQ(TestValue<float>("{ y:-inf }", "float"), -infinity_f);
+ TEST_EQ(TestValue<float>(nullptr, "float=inf"), infinity_f);
+ TEST_EQ(TestValue<float>(nullptr, "float=-inf"), -infinity_f);
+ TestValue<double>(
+ "{ y: [0.2, .2, 1.0, -1.0, -2., 2., 1e0, -1e0, 1.0e0, -1.0e0, -3.e2, "
+ "3.0e2] }",
+ "[double]");
+ TestValue<float>(
+ "{ y: [0.2, .2, 1.0, -1.0, -2., 2., 1e0, -1e0, 1.0e0, -1.0e0, -3.e2, "
+ "3.0e2] }",
+ "[float]");
+
+ // Test binary format of float point.
+ // https://en.cppreference.com/w/cpp/language/floating_literal
+ // 0x11.12p-1 = (1*16^1 + 2*16^0 + 3*16^-1 + 4*16^-2) * 2^-1 =
+ TEST_EQ(TestValue<double>("{ y:0x12.34p-1 }", "double"), 9.1015625);
+ // hex fraction 1.2 (decimal 1.125) scaled by 2^3, that is 9.0
+ TEST_EQ(TestValue<float>("{ y:-0x0.2p0 }", "float"), -0.125f);
+ TEST_EQ(TestValue<float>("{ y:-0x.2p1 }", "float"), -0.25f);
+ TEST_EQ(TestValue<float>("{ y:0x1.2p3 }", "float"), 9.0f);
+ TEST_EQ(TestValue<float>("{ y:0x10.1p0 }", "float"), 16.0625f);
+ TEST_EQ(TestValue<double>("{ y:0x1.2p3 }", "double"), 9.0);
+ TEST_EQ(TestValue<double>("{ y:0x10.1p0 }", "double"), 16.0625);
+ TEST_EQ(TestValue<double>("{ y:0xC.68p+2 }", "double"), 49.625);
+ TestValue<double>("{ y: [0x20.4ep1, +0x20.4ep1, -0x20.4ep1] }", "[double]");
+ TestValue<float>("{ y: [0x20.4ep1, +0x20.4ep1, -0x20.4ep1] }", "[float]");
+
+#else // FLATBUFFERS_HAS_NEW_STRTOD
+ TEST_OUTPUT_LINE("FLATBUFFERS_HAS_NEW_STRTOD tests skipped");
+#endif // !FLATBUFFERS_HAS_NEW_STRTOD
+}
+
+void UnicodeTest() {
+ flatbuffers::Parser parser;
+ // Without setting allow_non_utf8 = true, we treat \x sequences as byte
+ // sequences which are then validated as UTF-8.
+ TEST_EQ(parser.Parse("table T { F:string; }"
+ "root_type T;"
+ "{ F:\"\\u20AC\\u00A2\\u30E6\\u30FC\\u30B6\\u30FC"
+ "\\u5225\\u30B5\\u30A4\\u30C8\\xE2\\x82\\xAC\\u0080\\uD8"
+ "3D\\uDE0E\" }"),
+ true);
+ std::string jsongen;
+ parser.opts.indent_step = -1;
+ auto result =
+ GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen);
+ TEST_EQ(result, true);
+ TEST_EQ_STR(jsongen.c_str(),
+ "{F: \"\\u20AC\\u00A2\\u30E6\\u30FC\\u30B6\\u30FC"
+ "\\u5225\\u30B5\\u30A4\\u30C8\\u20AC\\u0080\\uD83D\\uDE0E\"}");
+}
+
+void UnicodeTestAllowNonUTF8() {
+ flatbuffers::Parser parser;
+ parser.opts.allow_non_utf8 = true;
+ TEST_EQ(
+ parser.Parse(
+ "table T { F:string; }"
+ "root_type T;"
+ "{ F:\"\\u20AC\\u00A2\\u30E6\\u30FC\\u30B6\\u30FC"
+ "\\u5225\\u30B5\\u30A4\\u30C8\\x01\\x80\\u0080\\uD83D\\uDE0E\" }"),
+ true);
+ std::string jsongen;
+ parser.opts.indent_step = -1;
+ auto result =
+ GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen);
+ TEST_EQ(result, true);
+ TEST_EQ_STR(
+ jsongen.c_str(),
+ "{F: \"\\u20AC\\u00A2\\u30E6\\u30FC\\u30B6\\u30FC"
+ "\\u5225\\u30B5\\u30A4\\u30C8\\u0001\\x80\\u0080\\uD83D\\uDE0E\"}");
+}
+
+void UnicodeTestGenerateTextFailsOnNonUTF8() {
+ flatbuffers::Parser parser;
+ // Allow non-UTF-8 initially to model what happens when we load a binary
+ // flatbuffer from disk which contains non-UTF-8 strings.
+ parser.opts.allow_non_utf8 = true;
+ TEST_EQ(
+ parser.Parse(
+ "table T { F:string; }"
+ "root_type T;"
+ "{ F:\"\\u20AC\\u00A2\\u30E6\\u30FC\\u30B6\\u30FC"
+ "\\u5225\\u30B5\\u30A4\\u30C8\\x01\\x80\\u0080\\uD83D\\uDE0E\" }"),
+ true);
+ std::string jsongen;
+ parser.opts.indent_step = -1;
+ // Now, disallow non-UTF-8 (the default behavior) so GenerateText indicates
+ // failure.
+ parser.opts.allow_non_utf8 = false;
+ auto result =
+ GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen);
+ TEST_EQ(result, false);
+}
+
+void UnicodeSurrogatesTest() {
+ flatbuffers::Parser parser;
+
+ TEST_EQ(parser.Parse("table T { F:string (id: 0); }"
+ "root_type T;"
+ "{ F:\"\\uD83D\\uDCA9\"}"),
+ true);
+ auto root = flatbuffers::GetRoot<flatbuffers::Table>(
+ parser.builder_.GetBufferPointer());
+ auto string = root->GetPointer<flatbuffers::String *>(
+ flatbuffers::FieldIndexToOffset(0));
+ TEST_EQ_STR(string->c_str(), "\xF0\x9F\x92\xA9");
+}
+
+
+
+void UnknownFieldsTest() {
+ flatbuffers::IDLOptions opts;
+ opts.skip_unexpected_fields_in_json = true;
+ flatbuffers::Parser parser(opts);
+
+ TEST_EQ(parser.Parse("table T { str:string; i:int;}"
+ "root_type T;"
+ "{ str:\"test\","
+ "unknown_string:\"test\","
+ "\"unknown_string\":\"test\","
+ "unknown_int:10,"
+ "unknown_float:1.0,"
+ "unknown_array: [ 1, 2, 3, 4],"
+ "unknown_object: { i: 10 },"
+ "\"unknown_object\": { \"i\": 10 },"
+ "i:10}"),
+ true);
+
+ std::string jsongen;
+ parser.opts.indent_step = -1;
+ auto result =
+ GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen);
+ TEST_EQ(result, true);
+ TEST_EQ_STR(jsongen.c_str(), "{str: \"test\",i: 10}");
+}
+
+void ParseUnionTest() {
+ // Unions must be parseable with the type field following the object.
+ flatbuffers::Parser parser;
+ TEST_EQ(parser.Parse("table T { A:int; }"
+ "union U { T }"
+ "table V { X:U; }"
+ "root_type V;"
+ "{ X:{ A:1 }, X_type: T }"),
+ true);
+ // Unions must be parsable with prefixed namespace.
+ flatbuffers::Parser parser2;
+ TEST_EQ(parser2.Parse("namespace N; table A {} namespace; union U { N.A }"
+ "table B { e:U; } root_type B;"
+ "{ e_type: N_A, e: {} }"),
+ true);
+}
+
+void ValidSameNameDifferentNamespaceTest() {
+ // Duplicate table names in different namespaces must be parsable
+ TEST_ASSERT(flatbuffers::Parser().Parse(
+ "namespace A; table X {} namespace B; table X {}"));
+ // Duplicate union names in different namespaces must be parsable
+ TEST_ASSERT(flatbuffers::Parser().Parse(
+ "namespace A; union X {} namespace B; union X {}"));
+ // Clashing table and union names in different namespaces must be parsable
+ TEST_ASSERT(flatbuffers::Parser().Parse(
+ "namespace A; table X {} namespace B; union X {}"));
+ TEST_ASSERT(flatbuffers::Parser().Parse(
+ "namespace A; union X {} namespace B; table X {}"));
+}
+
+void WarningsAsErrorsTest() {
+ {
+ flatbuffers::IDLOptions opts;
+ // opts.warnings_as_errors should default to false
+ flatbuffers::Parser parser(opts);
+ TEST_EQ(parser.Parse("table T { THIS_NAME_CAUSES_A_WARNING:string;}\n"
+ "root_type T;"),
+ true);
+ }
+ {
+ flatbuffers::IDLOptions opts;
+ opts.warnings_as_errors = true;
+ flatbuffers::Parser parser(opts);
+ TEST_EQ(parser.Parse("table T { THIS_NAME_CAUSES_A_WARNING:string;}\n"
+ "root_type T;"),
+ false);
+ }
+}
+
+void StringVectorDefaultsTest() {
+ std::vector<std::string> schemas;
+ schemas.push_back("table Monster { mana: string = \"\"; }");
+ schemas.push_back("table Monster { mana: string = \"mystr\"; }");
+ schemas.push_back("table Monster { mana: string = \" \"; }");
+ schemas.push_back("table Monster { mana: string = \"null\"; }");
+ schemas.push_back("table Monster { mana: [int] = []; }");
+ schemas.push_back("table Monster { mana: [uint] = [ ]; }");
+ schemas.push_back("table Monster { mana: [byte] = [\t\t\n]; }");
+ schemas.push_back("enum E:int{}table Monster{mana:[E]=[];}");
+ for (auto s = schemas.begin(); s < schemas.end(); s++) {
+ flatbuffers::Parser parser;
+ TEST_ASSERT(parser.Parse(s->c_str()));
+ const auto *mana = parser.structs_.Lookup("Monster")->fields.Lookup("mana");
+ TEST_EQ(mana->IsDefault(), true);
+ }
+}
+
+void FieldIdentifierTest() {
+ using flatbuffers::Parser;
+ TEST_EQ(true, Parser().Parse("table T{ f: int (id:0); }"));
+ // non-integer `id` should be rejected
+ TEST_EQ(false, Parser().Parse("table T{ f: int (id:text); }"));
+ TEST_EQ(false, Parser().Parse("table T{ f: int (id:\"text\"); }"));
+ TEST_EQ(false, Parser().Parse("table T{ f: int (id:0text); }"));
+ TEST_EQ(false, Parser().Parse("table T{ f: int (id:1.0); }"));
+ TEST_EQ(false, Parser().Parse("table T{ f: int (id:-1); g: int (id:0); }"));
+ TEST_EQ(false, Parser().Parse("table T{ f: int (id:129496726); }"));
+ // A unuion filed occupys two ids: enumerator + pointer (offset).
+ TEST_EQ(false,
+ Parser().Parse("union X{} table T{ u: X(id:0); table F{x:int;\n}"));
+ // Positive tests for unions
+ TEST_EQ(true, Parser().Parse("union X{} table T{ u: X (id:1); }"));
+ TEST_EQ(true, Parser().Parse("union X{} table T{ u: X; }"));
+ // Test using 'inf' and 'nan' words both as identifiers and as default values.
+ TEST_EQ(true, Parser().Parse("table T{ nan: string; }"));
+ TEST_EQ(true, Parser().Parse("table T{ inf: string; }"));
+#if defined(FLATBUFFERS_HAS_NEW_STRTOD) && (FLATBUFFERS_HAS_NEW_STRTOD > 0)
+ TEST_EQ(true, Parser().Parse("table T{ inf: float = inf; }"));
+ TEST_EQ(true, Parser().Parse("table T{ nan: float = inf; }"));
+#endif
+}
+
+} // namespace tests
+} // namespace flatbuffers
diff --git a/tests/parser_test.h b/tests/parser_test.h
new file mode 100644
index 0000000..ce6b5e2
--- /dev/null
+++ b/tests/parser_test.h
@@ -0,0 +1,33 @@
+#ifndef TESTS_PARSER_TEST_H
+#define TESTS_PARSER_TEST_H
+
+namespace flatbuffers {
+namespace tests {
+
+void ErrorTest();
+void EnumOutOfRangeTest();
+void IntegerOutOfRangeTest();
+void InvalidFloatTest();
+void UnicodeInvalidSurrogatesTest();
+void InvalidUTF8Test();
+void ValueTest();
+void NestedListTest();
+void EnumStringsTest();
+void EnumValueTest();
+void IntegerBoundaryTest();
+void ValidFloatTest();
+void UnicodeTest();
+void UnicodeTestAllowNonUTF8();
+void UnicodeTestGenerateTextFailsOnNonUTF8();
+void UnicodeSurrogatesTest();
+void UnknownFieldsTest();
+void ParseUnionTest();
+void ValidSameNameDifferentNamespaceTest();
+void WarningsAsErrorsTest();
+void StringVectorDefaultsTest();
+void FieldIdentifierTest();
+
+} // namespace tests
+} // namespace flatbuffers
+
+#endif // TESTS_PARSER_TEST_H
\ No newline at end of file
diff --git a/tests/private_annotation_test.fbs b/tests/private_annotation_test.fbs
new file mode 100644
index 0000000..434927b
--- /dev/null
+++ b/tests/private_annotation_test.fbs
@@ -0,0 +1,18 @@
+enum AB:byte (private) {
+ A,
+ B,
+}
+
+struct Object (private) {
+ value: int;
+}
+
+union Any (private) { Game, Annotations }
+
+table Game (private) {
+ value: int;
+}
+
+table Annotations (private) {
+ value: int;
+}
\ No newline at end of file
diff --git a/tests/private_annotation_test/ab_generated.rs b/tests/private_annotation_test/ab_generated.rs
new file mode 100644
index 0000000..6ed8850
--- /dev/null
+++ b/tests/private_annotation_test/ab_generated.rs
@@ -0,0 +1,98 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
+extern crate flatbuffers;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
+use self::flatbuffers::{EndianScalar, Follow};
+use super::*;
+#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
+pub const ENUM_MIN_AB: i8 = 0;
+#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
+pub const ENUM_MAX_AB: i8 = 1;
+#[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_AB: [AB; 2] = [
+ AB::A,
+ AB::B,
+];
+
+#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
+#[repr(transparent)]
+pub(crate) struct AB(pub i8);
+#[allow(non_upper_case_globals)]
+impl AB {
+ pub const A: Self = Self(0);
+ pub const B: Self = Self(1);
+
+ pub const ENUM_MIN: i8 = 0;
+ pub const ENUM_MAX: i8 = 1;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::A,
+ Self::B,
+ ];
+ /// 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"),
+ _ => None,
+ }
+ }
+}
+impl core::fmt::Debug for AB {
+ 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 AB {
+ type Inner = Self;
+ #[inline]
+ 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 AB {
+ type Output = AB;
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ unsafe { flatbuffers::emplace_scalar::<i8>(dst, self.0); }
+ }
+}
+
+impl flatbuffers::EndianScalar for AB {
+ #[inline]
+ fn to_little_endian(self) -> Self {
+ let b = i8::to_le(self.0);
+ Self(b)
+ }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(self) -> Self {
+ let b = i8::from_le(self.0);
+ Self(b)
+ }
+}
+
+impl<'a> flatbuffers::Verifiable for AB {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ i8::run_verifier(v, pos)
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for AB {}
diff --git a/tests/private_annotation_test/annotations_generated.rs b/tests/private_annotation_test/annotations_generated.rs
new file mode 100644
index 0000000..7c5166b
--- /dev/null
+++ b/tests/private_annotation_test/annotations_generated.rs
@@ -0,0 +1,138 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
+extern crate flatbuffers;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
+use self::flatbuffers::{EndianScalar, Follow};
+use super::*;
+pub(crate) enum AnnotationsOffset {}
+#[derive(Copy, Clone, PartialEq)]
+
+pub(crate) struct Annotations<'a> {
+ pub _tab: flatbuffers::Table<'a>,
+}
+
+impl<'a> flatbuffers::Follow<'a> for Annotations<'a> {
+ type Inner = Annotations<'a>;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: flatbuffers::Table { buf, loc } }
+ }
+}
+
+impl<'a> Annotations<'a> {
+ pub const VT_VALUE: flatbuffers::VOffsetT = 4;
+
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "Annotations"
+ }
+
+ #[inline]
+ pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
+ Annotations { _tab: table }
+ }
+ #[allow(unused_mut)]
+ pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
+ _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
+ args: &'args AnnotationsArgs
+ ) -> flatbuffers::WIPOffset<Annotations<'bldr>> {
+ let mut builder = AnnotationsBuilder::new(_fbb);
+ builder.add_value(args.value);
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> AnnotationsT {
+ let value = self.value();
+ AnnotationsT {
+ value,
+ }
+ }
+
+ #[inline]
+ pub fn value(&self) -> i32 {
+ self._tab.get::<i32>(Annotations::VT_VALUE, Some(0)).unwrap()
+ }
+}
+
+impl flatbuffers::Verifiable for Annotations<'_> {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<i32>("value", Self::VT_VALUE, false)?
+ .finish();
+ Ok(())
+ }
+}
+pub(crate) struct AnnotationsArgs {
+ pub value: i32,
+}
+impl<'a> Default for AnnotationsArgs {
+ #[inline]
+ fn default() -> Self {
+ AnnotationsArgs {
+ value: 0,
+ }
+ }
+}
+
+pub(crate) struct AnnotationsBuilder<'a: 'b, 'b> {
+ fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
+ start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
+}
+impl<'a: 'b, 'b> AnnotationsBuilder<'a, 'b> {
+ #[inline]
+ pub fn add_value(&mut self, value: i32) {
+ self.fbb_.push_slot::<i32>(Annotations::VT_VALUE, value, 0);
+ }
+ #[inline]
+ pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> AnnotationsBuilder<'a, 'b> {
+ let start = _fbb.start_table();
+ AnnotationsBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+ #[inline]
+ pub fn finish(self) -> flatbuffers::WIPOffset<Annotations<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ flatbuffers::WIPOffset::new(o.value())
+ }
+}
+
+impl core::fmt::Debug for Annotations<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
+ let mut ds = f.debug_struct("Annotations");
+ ds.field("value", &self.value());
+ ds.finish()
+ }
+}
+#[non_exhaustive]
+#[derive(Debug, Clone, PartialEq)]
+pub(crate) struct AnnotationsT {
+ pub value: i32,
+}
+impl Default for AnnotationsT {
+ fn default() -> Self {
+ Self {
+ value: 0,
+ }
+ }
+}
+impl AnnotationsT {
+ pub fn pack<'b>(
+ &self,
+ _fbb: &mut flatbuffers::FlatBufferBuilder<'b>
+ ) -> flatbuffers::WIPOffset<Annotations<'b>> {
+ let value = self.value;
+ Annotations::create(_fbb, &AnnotationsArgs{
+ value,
+ })
+ }
+}
diff --git a/tests/private_annotation_test/any_generated.rs b/tests/private_annotation_test/any_generated.rs
new file mode 100644
index 0000000..c3049a0
--- /dev/null
+++ b/tests/private_annotation_test/any_generated.rs
@@ -0,0 +1,175 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
+extern crate flatbuffers;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
+use self::flatbuffers::{EndianScalar, Follow};
+use super::*;
+#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
+pub const ENUM_MIN_ANY: u8 = 0;
+#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
+pub const ENUM_MAX_ANY: u8 = 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_ANY: [Any; 3] = [
+ Any::NONE,
+ Any::Game,
+ Any::Annotations,
+];
+
+#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
+#[repr(transparent)]
+pub(crate) struct Any(pub u8);
+#[allow(non_upper_case_globals)]
+impl Any {
+ pub const NONE: Self = Self(0);
+ pub const Game: Self = Self(1);
+ pub const Annotations: Self = Self(2);
+
+ pub const ENUM_MIN: u8 = 0;
+ pub const ENUM_MAX: u8 = 2;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::NONE,
+ Self::Game,
+ Self::Annotations,
+ ];
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::NONE => Some("NONE"),
+ Self::Game => Some("Game"),
+ Self::Annotations => Some("Annotations"),
+ _ => None,
+ }
+ }
+}
+impl core::fmt::Debug for Any {
+ 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 Any {
+ type Inner = Self;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe {
+ flatbuffers::read_scalar_at::<u8>(buf, loc)
+ };
+ Self(b)
+ }
+}
+
+impl flatbuffers::Push for Any {
+ type Output = Any;
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ unsafe { flatbuffers::emplace_scalar::<u8>(dst, self.0); }
+ }
+}
+
+impl flatbuffers::EndianScalar for Any {
+ #[inline]
+ fn to_little_endian(self) -> Self {
+ let b = u8::to_le(self.0);
+ Self(b)
+ }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(self) -> Self {
+ let b = u8::from_le(self.0);
+ Self(b)
+ }
+}
+
+impl<'a> flatbuffers::Verifiable for Any {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ u8::run_verifier(v, pos)
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for Any {}
+pub(crate) struct AnyUnionTableOffset {}
+
+#[allow(clippy::upper_case_acronyms)]
+#[non_exhaustive]
+#[derive(Debug, Clone, PartialEq)]
+pub(crate) enum AnyT {
+ NONE,
+ Game(Box<GameT>),
+ Annotations(Box<AnnotationsT>),
+}
+impl Default for AnyT {
+ fn default() -> Self {
+ Self::NONE
+ }
+}
+impl AnyT {
+ pub fn any_type(&self) -> Any {
+ match self {
+ Self::NONE => Any::NONE,
+ Self::Game(_) => Any::Game,
+ Self::Annotations(_) => Any::Annotations,
+ }
+ }
+ pub fn pack(&self, fbb: &mut flatbuffers::FlatBufferBuilder) -> Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>> {
+ match self {
+ Self::NONE => None,
+ Self::Game(v) => Some(v.pack(fbb).as_union_value()),
+ Self::Annotations(v) => Some(v.pack(fbb).as_union_value()),
+ }
+ }
+ /// If the union variant matches, return the owned GameT, setting the union to NONE.
+ pub fn take_game(&mut self) -> Option<Box<GameT>> {
+ if let Self::Game(_) = self {
+ let v = core::mem::replace(self, Self::NONE);
+ if let Self::Game(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
+ /// If the union variant matches, return a reference to the GameT.
+ pub fn as_game(&self) -> Option<&GameT> {
+ if let Self::Game(v) = self { Some(v.as_ref()) } else { None }
+ }
+ /// If the union variant matches, return a mutable reference to the GameT.
+ pub fn as_game_mut(&mut self) -> Option<&mut GameT> {
+ if let Self::Game(v) = self { Some(v.as_mut()) } else { None }
+ }
+ /// If the union variant matches, return the owned AnnotationsT, setting the union to NONE.
+ pub fn take_annotations(&mut self) -> Option<Box<AnnotationsT>> {
+ if let Self::Annotations(_) = self {
+ let v = core::mem::replace(self, Self::NONE);
+ if let Self::Annotations(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
+ /// If the union variant matches, return a reference to the AnnotationsT.
+ pub fn as_annotations(&self) -> Option<&AnnotationsT> {
+ if let Self::Annotations(v) = self { Some(v.as_ref()) } else { None }
+ }
+ /// If the union variant matches, return a mutable reference to the AnnotationsT.
+ pub fn as_annotations_mut(&mut self) -> Option<&mut AnnotationsT> {
+ if let Self::Annotations(v) = self { Some(v.as_mut()) } else { None }
+ }
+}
diff --git a/tests/private_annotation_test/game_generated.rs b/tests/private_annotation_test/game_generated.rs
new file mode 100644
index 0000000..e696611
--- /dev/null
+++ b/tests/private_annotation_test/game_generated.rs
@@ -0,0 +1,138 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
+extern crate flatbuffers;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
+use self::flatbuffers::{EndianScalar, Follow};
+use super::*;
+pub(crate) enum GameOffset {}
+#[derive(Copy, Clone, PartialEq)]
+
+pub(crate) struct Game<'a> {
+ pub _tab: flatbuffers::Table<'a>,
+}
+
+impl<'a> flatbuffers::Follow<'a> for Game<'a> {
+ type Inner = Game<'a>;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: flatbuffers::Table { buf, loc } }
+ }
+}
+
+impl<'a> Game<'a> {
+ pub const VT_VALUE: flatbuffers::VOffsetT = 4;
+
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "Game"
+ }
+
+ #[inline]
+ pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
+ Game { _tab: table }
+ }
+ #[allow(unused_mut)]
+ pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
+ _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
+ args: &'args GameArgs
+ ) -> flatbuffers::WIPOffset<Game<'bldr>> {
+ let mut builder = GameBuilder::new(_fbb);
+ builder.add_value(args.value);
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> GameT {
+ let value = self.value();
+ GameT {
+ value,
+ }
+ }
+
+ #[inline]
+ pub fn value(&self) -> i32 {
+ self._tab.get::<i32>(Game::VT_VALUE, Some(0)).unwrap()
+ }
+}
+
+impl flatbuffers::Verifiable for Game<'_> {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<i32>("value", Self::VT_VALUE, false)?
+ .finish();
+ Ok(())
+ }
+}
+pub(crate) struct GameArgs {
+ pub value: i32,
+}
+impl<'a> Default for GameArgs {
+ #[inline]
+ fn default() -> Self {
+ GameArgs {
+ value: 0,
+ }
+ }
+}
+
+pub(crate) struct GameBuilder<'a: 'b, 'b> {
+ fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
+ start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
+}
+impl<'a: 'b, 'b> GameBuilder<'a, 'b> {
+ #[inline]
+ pub fn add_value(&mut self, value: i32) {
+ self.fbb_.push_slot::<i32>(Game::VT_VALUE, value, 0);
+ }
+ #[inline]
+ pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> GameBuilder<'a, 'b> {
+ let start = _fbb.start_table();
+ GameBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+ #[inline]
+ pub fn finish(self) -> flatbuffers::WIPOffset<Game<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ flatbuffers::WIPOffset::new(o.value())
+ }
+}
+
+impl core::fmt::Debug for Game<'_> {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
+ let mut ds = f.debug_struct("Game");
+ ds.field("value", &self.value());
+ ds.finish()
+ }
+}
+#[non_exhaustive]
+#[derive(Debug, Clone, PartialEq)]
+pub(crate) struct GameT {
+ pub value: i32,
+}
+impl Default for GameT {
+ fn default() -> Self {
+ Self {
+ value: 0,
+ }
+ }
+}
+impl GameT {
+ pub fn pack<'b>(
+ &self,
+ _fbb: &mut flatbuffers::FlatBufferBuilder<'b>
+ ) -> flatbuffers::WIPOffset<Game<'b>> {
+ let value = self.value;
+ Game::create(_fbb, &GameArgs{
+ value,
+ })
+ }
+}
diff --git a/tests/private_annotation_test/mod.rs b/tests/private_annotation_test/mod.rs
new file mode 100644
index 0000000..def5184
--- /dev/null
+++ b/tests/private_annotation_test/mod.rs
@@ -0,0 +1,12 @@
+// Automatically generated by the Flatbuffers compiler. Do not modify.
+// @generated
+mod ab_generated;
+pub use self::ab_generated::*;
+mod any_generated;
+pub use self::any_generated::*;
+mod object_generated;
+pub use self::object_generated::*;
+mod game_generated;
+pub use self::game_generated::*;
+mod annotations_generated;
+pub use self::annotations_generated::*;
diff --git a/tests/private_annotation_test/object_generated.rs b/tests/private_annotation_test/object_generated.rs
new file mode 100644
index 0000000..64419a9
--- /dev/null
+++ b/tests/private_annotation_test/object_generated.rs
@@ -0,0 +1,132 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+// @generated
+extern crate alloc;
+extern crate flatbuffers;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::mem;
+use core::cmp::Ordering;
+use self::flatbuffers::{EndianScalar, Follow};
+use super::*;
+// struct Object, aligned to 4
+#[repr(transparent)]
+#[derive(Clone, Copy, PartialEq)]
+pub(crate) struct Object(pub [u8; 4]);
+impl Default for Object {
+ fn default() -> Self {
+ Self([0; 4])
+ }
+}
+impl core::fmt::Debug for Object {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
+ f.debug_struct("Object")
+ .field("value", &self.value())
+ .finish()
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for Object {}
+impl flatbuffers::SafeSliceAccess for Object {}
+impl<'a> flatbuffers::Follow<'a> for Object {
+ type Inner = &'a Object;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ <&'a Object>::follow(buf, loc)
+ }
+}
+impl<'a> flatbuffers::Follow<'a> for &'a Object {
+ type Inner = &'a Object;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ flatbuffers::follow_cast_ref::<Object>(buf, loc)
+ }
+}
+impl<'b> flatbuffers::Push for Object {
+ type Output = Object;
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ let src = unsafe {
+ ::core::slice::from_raw_parts(self as *const Object as *const u8, Self::size())
+ };
+ dst.copy_from_slice(src);
+ }
+}
+impl<'b> flatbuffers::Push for &'b Object {
+ type Output = Object;
+
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ let src = unsafe {
+ ::core::slice::from_raw_parts(*self as *const Object as *const u8, Self::size())
+ };
+ dst.copy_from_slice(src);
+ }
+}
+
+impl<'a> flatbuffers::Verifiable for Object {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ v.in_buffer::<Self>(pos)
+ }
+}
+
+impl<'a> Object {
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ value: i32,
+ ) -> Self {
+ let mut s = Self([0; 4]);
+ s.set_value(value);
+ s
+ }
+
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "Object"
+ }
+
+ pub fn value(&self) -> i32 {
+ let mut mem = core::mem::MaybeUninit::<i32>::uninit();
+ unsafe {
+ core::ptr::copy_nonoverlapping(
+ self.0[0..].as_ptr(),
+ mem.as_mut_ptr() as *mut u8,
+ core::mem::size_of::<i32>(),
+ );
+ mem.assume_init()
+ }.from_little_endian()
+ }
+
+ pub fn set_value(&mut self, x: i32) {
+ let x_le = x.to_little_endian();
+ unsafe {
+ core::ptr::copy_nonoverlapping(
+ &x_le as *const i32 as *const u8,
+ self.0[0..].as_mut_ptr(),
+ core::mem::size_of::<i32>(),
+ );
+ }
+ }
+
+ pub fn unpack(&self) -> ObjectT {
+ ObjectT {
+ value: self.value(),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, Default)]
+pub(crate) struct ObjectT {
+ pub value: i32,
+}
+impl ObjectT {
+ pub fn pack(&self) -> Object {
+ Object::new(
+ self.value,
+ )
+ }
+}
+
diff --git a/tests/proto_test.cpp b/tests/proto_test.cpp
new file mode 100644
index 0000000..7281c2c
--- /dev/null
+++ b/tests/proto_test.cpp
@@ -0,0 +1,204 @@
+#include "proto_test.h"
+
+#include "flatbuffers/idl.h"
+#include "test_assert.h"
+
+namespace flatbuffers {
+namespace tests {
+
+// Parse a .proto schema, output as .fbs
+void ParseProtoTest(const std::string &tests_data_path) {
+ // load the .proto and the golden file from disk
+ std::string protofile;
+ std::string goldenfile;
+ std::string goldenunionfile;
+ TEST_EQ(
+ flatbuffers::LoadFile((tests_data_path + "prototest/test.proto").c_str(),
+ false, &protofile),
+ true);
+ TEST_EQ(
+ flatbuffers::LoadFile((tests_data_path + "prototest/test.golden").c_str(),
+ false, &goldenfile),
+ true);
+ TEST_EQ(flatbuffers::LoadFile(
+ (tests_data_path + "prototest/test_union.golden").c_str(), false,
+ &goldenunionfile),
+ true);
+
+ flatbuffers::IDLOptions opts;
+ opts.include_dependence_headers = false;
+ opts.proto_mode = true;
+
+ // Parse proto.
+ flatbuffers::Parser parser(opts);
+ auto protopath = tests_data_path + "prototest/";
+ const char *include_directories[] = { protopath.c_str(), nullptr };
+ TEST_EQ(parser.Parse(protofile.c_str(), include_directories), true);
+
+ // Generate fbs.
+ auto fbs = flatbuffers::GenerateFBS(parser, "test");
+
+ // Ensure generated file is parsable.
+ flatbuffers::Parser parser2;
+ TEST_EQ(parser2.Parse(fbs.c_str(), nullptr), true);
+ TEST_EQ_STR(fbs.c_str(), goldenfile.c_str());
+
+ // Parse proto with --oneof-union option.
+ opts.proto_oneof_union = true;
+ flatbuffers::Parser parser3(opts);
+ TEST_EQ(parser3.Parse(protofile.c_str(), include_directories), true);
+
+ // Generate fbs.
+ auto fbs_union = flatbuffers::GenerateFBS(parser3, "test");
+
+ // Ensure generated file is parsable.
+ flatbuffers::Parser parser4;
+ TEST_EQ(parser4.Parse(fbs_union.c_str(), nullptr), true);
+ TEST_EQ_STR(fbs_union.c_str(), goldenunionfile.c_str());
+}
+
+// Parse a .proto schema, output as .fbs
+void ParseProtoTestWithSuffix(const std::string &tests_data_path) {
+ // load the .proto and the golden file from disk
+ std::string protofile;
+ std::string goldenfile;
+ std::string goldenunionfile;
+ TEST_EQ(
+ flatbuffers::LoadFile((tests_data_path + "prototest/test.proto").c_str(),
+ false, &protofile),
+ true);
+ TEST_EQ(flatbuffers::LoadFile(
+ (tests_data_path + "prototest/test_suffix.golden").c_str(), false,
+ &goldenfile),
+ true);
+ TEST_EQ(flatbuffers::LoadFile(
+ (tests_data_path + "prototest/test_union_suffix.golden").c_str(),
+ false, &goldenunionfile),
+ true);
+
+ flatbuffers::IDLOptions opts;
+ opts.include_dependence_headers = false;
+ opts.proto_mode = true;
+ opts.proto_namespace_suffix = "test_namespace_suffix";
+
+ // Parse proto.
+ flatbuffers::Parser parser(opts);
+ auto protopath = tests_data_path + "prototest/";
+ const char *include_directories[] = { protopath.c_str(), nullptr };
+ TEST_EQ(parser.Parse(protofile.c_str(), include_directories), true);
+
+ // Generate fbs.
+ auto fbs = flatbuffers::GenerateFBS(parser, "test");
+
+ // Ensure generated file is parsable.
+ flatbuffers::Parser parser2;
+ TEST_EQ(parser2.Parse(fbs.c_str(), nullptr), true);
+ TEST_EQ_STR(fbs.c_str(), goldenfile.c_str());
+
+ // Parse proto with --oneof-union option.
+ opts.proto_oneof_union = true;
+ flatbuffers::Parser parser3(opts);
+ TEST_EQ(parser3.Parse(protofile.c_str(), include_directories), true);
+
+ // Generate fbs.
+ auto fbs_union = flatbuffers::GenerateFBS(parser3, "test");
+
+ // Ensure generated file is parsable.
+ flatbuffers::Parser parser4;
+ TEST_EQ(parser4.Parse(fbs_union.c_str(), nullptr), true);
+ TEST_EQ_STR(fbs_union.c_str(), goldenunionfile.c_str());
+}
+
+// Parse a .proto schema, output as .fbs
+void ParseProtoTestWithIncludes(const std::string &tests_data_path) {
+ // load the .proto and the golden file from disk
+ std::string protofile;
+ std::string goldenfile;
+ std::string goldenunionfile;
+ std::string importprotofile;
+ TEST_EQ(
+ flatbuffers::LoadFile((tests_data_path + "prototest/test.proto").c_str(),
+ false, &protofile),
+ true);
+ TEST_EQ(flatbuffers::LoadFile(
+ (tests_data_path + "prototest/imported.proto").c_str(), false,
+ &importprotofile),
+ true);
+ TEST_EQ(flatbuffers::LoadFile(
+ (tests_data_path + "prototest/test_include.golden").c_str(),
+ false, &goldenfile),
+ true);
+ TEST_EQ(flatbuffers::LoadFile(
+ (tests_data_path + "prototest/test_union_include.golden").c_str(),
+ false, &goldenunionfile),
+ true);
+
+ flatbuffers::IDLOptions opts;
+ opts.include_dependence_headers = true;
+ opts.proto_mode = true;
+
+ // Parse proto.
+ flatbuffers::Parser parser(opts);
+ auto protopath = tests_data_path + "prototest/";
+ const char *include_directories[] = { protopath.c_str(), nullptr };
+ TEST_EQ(parser.Parse(protofile.c_str(), include_directories), true);
+
+ // Generate fbs.
+ auto fbs = flatbuffers::GenerateFBS(parser, "test");
+
+ // Generate fbs from import.proto
+ flatbuffers::Parser import_parser(opts);
+ TEST_EQ(import_parser.Parse(importprotofile.c_str(), include_directories),
+ true);
+ auto import_fbs = flatbuffers::GenerateFBS(import_parser, "test");
+
+ // Ensure generated file is parsable.
+ flatbuffers::Parser parser2;
+ // Since `imported.fbs` isn't in the filesystem AbsolutePath can't figure it
+ // out by itself. We manually construct it so Parser works.
+ std::string imported_fbs = flatbuffers::PosixPath(
+ flatbuffers::AbsolutePath(protopath) + "/imported.fbs");
+ TEST_EQ(parser2.Parse(import_fbs.c_str(), include_directories,
+ imported_fbs.c_str()),
+ true);
+ TEST_EQ(parser2.Parse(fbs.c_str(), nullptr), true);
+ TEST_EQ_STR(fbs.c_str(), goldenfile.c_str());
+
+ // Parse proto with --oneof-union option.
+ opts.proto_oneof_union = true;
+ flatbuffers::Parser parser3(opts);
+ TEST_EQ(parser3.Parse(protofile.c_str(), include_directories), true);
+
+ // Generate fbs.
+ auto fbs_union = flatbuffers::GenerateFBS(parser3, "test");
+
+ // Ensure generated file is parsable.
+ flatbuffers::Parser parser4;
+ TEST_EQ(parser4.Parse(import_fbs.c_str(), nullptr, imported_fbs.c_str()),
+ true);
+ TEST_EQ(parser4.Parse(fbs_union.c_str(), nullptr), true);
+ TEST_EQ_STR(fbs_union.c_str(), goldenunionfile.c_str());
+}
+
+void ParseProtoBufAsciiTest() {
+ // We can put the parser in a mode where it will accept JSON that looks more
+ // like Protobuf ASCII, for users that have data in that format.
+ // This uses no "" for field names (which we already support by default,
+ // omits `,`, `:` before `{` and a couple of other features.
+ flatbuffers::Parser parser;
+ parser.opts.protobuf_ascii_alike = true;
+ TEST_EQ(
+ parser.Parse("table S { B:int; } table T { A:[int]; C:S; } root_type T;"),
+ true);
+ TEST_EQ(parser.Parse("{ A [1 2] C { B:2 }}"), true);
+ // Similarly, in text output, it should omit these.
+ std::string text;
+ auto ok = flatbuffers::GenerateText(
+ parser, parser.builder_.GetBufferPointer(), &text);
+ TEST_EQ(ok, true);
+ TEST_EQ_STR(text.c_str(),
+ "{\n A [\n 1\n 2\n ]\n C {\n B: 2\n }\n}\n");
+}
+
+} // namespace tests
+} // namespace flatbuffers
\ No newline at end of file
diff --git a/tests/proto_test.h b/tests/proto_test.h
new file mode 100644
index 0000000..9f6137d
--- /dev/null
+++ b/tests/proto_test.h
@@ -0,0 +1,18 @@
+#ifndef TESTS_PROTO_TEST_H
+#define TESTS_PROTO_TEST_H
+
+#include <string>
+
+namespace flatbuffers {
+namespace tests {
+
+void ParseProtoTest(const std::string& tests_data_path);
+void ParseProtoTestWithSuffix(const std::string& tests_data_path);
+void ParseProtoTestWithIncludes(const std::string& tests_data_path);
+void ParseProtoBufAsciiTest();
+
+
+} // namespace tests
+} // namespace flatbuffers
+
+#endif
\ No newline at end of file
diff --git a/tests/prototest/test.golden b/tests/prototest/test.golden
index eb10671..949a003 100644
--- a/tests/prototest/test.golden
+++ b/tests/prototest/test.golden
@@ -51,6 +51,9 @@
/// doc comment for r.
r:proto.test.ProtoMessage_.Anonymous0;
outer_enum:proto.test.ProtoEnum;
+ u:float = +inf;
+ v:float = +inf;
+ w:float = -inf;
}
namespace proto.test.ProtoMessage_;
diff --git a/tests/prototest/test.proto b/tests/prototest/test.proto
index 10e45af..71ec8d5 100644
--- a/tests/prototest/test.proto
+++ b/tests/prototest/test.proto
@@ -67,4 +67,8 @@
OtherMessage t = 18;
}
optional ProtoEnum outer_enum = 33;
+ // Tests that `inf` and `+/-inf` can be parsed in proto options.
+ optional float u = 34 [default = inf];
+ optional float v = 35 [default = +inf];
+ optional float w = 36 [default = -inf];
}
diff --git a/tests/prototest/test_include.golden b/tests/prototest/test_include.golden
index 358c3f6..b98de44 100644
--- a/tests/prototest/test_include.golden
+++ b/tests/prototest/test_include.golden
@@ -49,6 +49,9 @@
/// doc comment for r.
r:proto.test.ProtoMessage_.Anonymous0;
outer_enum:proto.test.ProtoEnum;
+ u:float = +inf;
+ v:float = +inf;
+ w:float = -inf;
}
namespace proto.test.ProtoMessage_;
diff --git a/tests/prototest/test_suffix.golden b/tests/prototest/test_suffix.golden
index a99f807..4ab2146 100644
--- a/tests/prototest/test_suffix.golden
+++ b/tests/prototest/test_suffix.golden
@@ -51,6 +51,9 @@
/// doc comment for r.
r:proto.test.test_namespace_suffix.ProtoMessage_.Anonymous0;
outer_enum:proto.test.test_namespace_suffix.ProtoEnum;
+ u:float = +inf;
+ v:float = +inf;
+ w:float = -inf;
}
namespace proto.test.test_namespace_suffix.ProtoMessage_;
diff --git a/tests/prototest/test_union.golden b/tests/prototest/test_union.golden
index 3e6becd..241f349 100644
--- a/tests/prototest/test_union.golden
+++ b/tests/prototest/test_union.golden
@@ -61,6 +61,9 @@
/// doc comment for r.
r:proto.test.ProtoMessage_.RUnion;
outer_enum:proto.test.ProtoEnum;
+ u:float = +inf;
+ v:float = +inf;
+ w:float = -inf;
}
namespace proto.test.ProtoMessage_;
diff --git a/tests/prototest/test_union_include.golden b/tests/prototest/test_union_include.golden
index abdb6e2..1fdb2ac 100644
--- a/tests/prototest/test_union_include.golden
+++ b/tests/prototest/test_union_include.golden
@@ -59,6 +59,9 @@
/// doc comment for r.
r:proto.test.ProtoMessage_.RUnion;
outer_enum:proto.test.ProtoEnum;
+ u:float = +inf;
+ v:float = +inf;
+ w:float = -inf;
}
namespace proto.test.ProtoMessage_;
diff --git a/tests/prototest/test_union_suffix.golden b/tests/prototest/test_union_suffix.golden
index 6a240c0..2278edd 100644
--- a/tests/prototest/test_union_suffix.golden
+++ b/tests/prototest/test_union_suffix.golden
@@ -61,6 +61,9 @@
/// doc comment for r.
r:proto.test.test_namespace_suffix.ProtoMessage_.RUnion;
outer_enum:proto.test.test_namespace_suffix.ProtoEnum;
+ u:float = +inf;
+ v:float = +inf;
+ w:float = -inf;
}
namespace proto.test.test_namespace_suffix.ProtoMessage_;
diff --git a/tests/py_test.py b/tests/py_test.py
index ed966d5..5e3c547 100644
--- a/tests/py_test.py
+++ b/tests/py_test.py
@@ -48,6 +48,8 @@
import MyGame.Example.NestedStruct # refers to generated code
import MyGame.Example.TestEnum # refers to generated code
import monster_test_generated # the one-file version
+import optional_scalars
+import optional_scalars.ScalarStuff
def create_namespace_shortcut(is_onefile):
@@ -274,6 +276,35 @@
self.assertEqual(monster2.VectorOfEnumsLength(), 0)
self.assertTrue(monster2.VectorOfEnumsIsNone())
+ def test_optional_scalars_with_pack_and_unpack(self):
+ """ Serializes and deserializes between a buffer with optional values (no
+ specific values are filled when the buffer is created) and its python
+ object.
+ """
+ # Creates a flatbuffer with optional values.
+ b1 = flatbuffers.Builder(0)
+ optional_scalars.ScalarStuff.ScalarStuffStart(b1)
+ gen_opt = optional_scalars.ScalarStuff.ScalarStuffEnd(b1)
+ b1.Finish(gen_opt)
+
+ # Converts the flatbuffer into the object class.
+ opts1 = optional_scalars.ScalarStuff.ScalarStuff.GetRootAs(b1.Bytes, b1.Head())
+ optsT1 = optional_scalars.ScalarStuff.ScalarStuffT.InitFromObj(opts1)
+
+ # Packs the object class into another flatbuffer.
+ b2 = flatbuffers.Builder(0)
+ b2.Finish(optsT1.Pack(b2))
+ opts2 = optional_scalars.ScalarStuff.ScalarStuff.GetRootAs(b2.Bytes, b2.Head())
+ optsT2 = optional_scalars.ScalarStuff.ScalarStuffT.InitFromObj(opts2)
+ # Checks the default values.
+ self.assertTrue(opts2.JustI8() == 0)
+ self.assertTrue(opts2.MaybeF32() is None)
+ self.assertTrue(opts2.DefaultBool() is True)
+ self.assertTrue(optsT2.justU16 == 0)
+ self.assertTrue(optsT2.maybeEnum is None)
+ self.assertTrue(optsT2.defaultU64 == 42)
+
+
class TestAllMutableCodePathsOfExampleSchema(unittest.TestCase):
""" Tests the object API generated for monster_test.fbs for mutation
diff --git a/tests/reflection_test.cpp b/tests/reflection_test.cpp
new file mode 100644
index 0000000..b48bd81
--- /dev/null
+++ b/tests/reflection_test.cpp
@@ -0,0 +1,320 @@
+#include "reflection_test.h"
+#include "arrays_test_generated.h"
+#include "flatbuffers/minireflect.h"
+#include "flatbuffers/reflection.h"
+#include "flatbuffers/reflection_generated.h"
+#include "flatbuffers/verifier.h"
+#include "test_assert.h"
+#include "monster_test.h"
+#include "monster_test_generated.h"
+
+namespace flatbuffers {
+namespace tests {
+
+using namespace MyGame::Example;
+
+void ReflectionTest(const std::string& tests_data_path, uint8_t *flatbuf, size_t length) {
+ // Load a binary schema.
+ std::string bfbsfile;
+ TEST_EQ(flatbuffers::LoadFile((tests_data_path + "monster_test.bfbs").c_str(),
+ true, &bfbsfile),
+ true);
+
+ // Verify it, just in case:
+ flatbuffers::Verifier verifier(
+ reinterpret_cast<const uint8_t *>(bfbsfile.c_str()), bfbsfile.length());
+ TEST_EQ(reflection::VerifySchemaBuffer(verifier), true);
+
+ // Make sure the schema is what we expect it to be.
+ auto &schema = *reflection::GetSchema(bfbsfile.c_str());
+ auto root_table = schema.root_table();
+
+ // Check the declaration files.
+ TEST_EQ_STR(root_table->name()->c_str(), "MyGame.Example.Monster");
+ TEST_EQ_STR(root_table->declaration_file()->c_str(), "//monster_test.fbs");
+ TEST_EQ_STR(
+ schema.objects()->LookupByKey("TableA")->declaration_file()->c_str(),
+ "//include_test/include_test1.fbs");
+ TEST_EQ_STR(schema.objects()
+ ->LookupByKey("MyGame.OtherNameSpace.Unused")
+ ->declaration_file()
+ ->c_str(),
+ "//include_test/sub/include_test2.fbs");
+ TEST_EQ_STR(schema.enums()
+ ->LookupByKey("MyGame.OtherNameSpace.FromInclude")
+ ->declaration_file()
+ ->c_str(),
+ "//include_test/sub/include_test2.fbs");
+
+ // Check scheam filenames and their includes.
+ TEST_EQ(schema.fbs_files()->size(), 3);
+
+ const auto fbs0 = schema.fbs_files()->Get(0);
+ TEST_EQ_STR(fbs0->filename()->c_str(), "//include_test/include_test1.fbs");
+ const auto fbs0_includes = fbs0->included_filenames();
+ TEST_EQ(fbs0_includes->size(), 2);
+
+ // TODO(caspern): Should we force or disallow inclusion of self?
+ TEST_EQ_STR(fbs0_includes->Get(0)->c_str(),
+ "//include_test/include_test1.fbs");
+ TEST_EQ_STR(fbs0_includes->Get(1)->c_str(),
+ "//include_test/sub/include_test2.fbs");
+
+ const auto fbs1 = schema.fbs_files()->Get(1);
+ TEST_EQ_STR(fbs1->filename()->c_str(),
+ "//include_test/sub/include_test2.fbs");
+ const auto fbs1_includes = fbs1->included_filenames();
+ TEST_EQ(fbs1_includes->size(), 2);
+ TEST_EQ_STR(fbs1_includes->Get(0)->c_str(),
+ "//include_test/include_test1.fbs");
+ TEST_EQ_STR(fbs1_includes->Get(1)->c_str(),
+ "//include_test/sub/include_test2.fbs");
+
+ const auto fbs2 = schema.fbs_files()->Get(2);
+ TEST_EQ_STR(fbs2->filename()->c_str(), "//monster_test.fbs");
+ const auto fbs2_includes = fbs2->included_filenames();
+ TEST_EQ(fbs2_includes->size(), 1);
+ TEST_EQ_STR(fbs2_includes->Get(0)->c_str(),
+ "//include_test/include_test1.fbs");
+
+ // Check Root table fields
+ auto fields = root_table->fields();
+ auto hp_field_ptr = fields->LookupByKey("hp");
+ TEST_NOTNULL(hp_field_ptr);
+ auto &hp_field = *hp_field_ptr;
+ TEST_EQ_STR(hp_field.name()->c_str(), "hp");
+ TEST_EQ(hp_field.id(), 2);
+ TEST_EQ(hp_field.type()->base_type(), reflection::Short);
+
+ auto friendly_field_ptr = fields->LookupByKey("friendly");
+ TEST_NOTNULL(friendly_field_ptr);
+ TEST_NOTNULL(friendly_field_ptr->attributes());
+ TEST_NOTNULL(friendly_field_ptr->attributes()->LookupByKey("priority"));
+
+ // Make sure the table index is what we expect it to be.
+ auto pos_field_ptr = fields->LookupByKey("pos");
+ TEST_NOTNULL(pos_field_ptr);
+ TEST_EQ(pos_field_ptr->type()->base_type(), reflection::Obj);
+ auto pos_table_ptr = schema.objects()->Get(pos_field_ptr->type()->index());
+ TEST_NOTNULL(pos_table_ptr);
+ TEST_EQ_STR(pos_table_ptr->name()->c_str(), "MyGame.Example.Vec3");
+
+ // Test nullability of fields: hp is a 0-default scalar, pos is a struct =>
+ // optional, and name is a required string => not optional.
+ TEST_EQ(hp_field.optional(), false);
+ TEST_EQ(pos_field_ptr->optional(), true);
+ TEST_EQ(fields->LookupByKey("name")->optional(), false);
+
+ // Now use it to dynamically access a buffer.
+ auto &root = *flatbuffers::GetAnyRoot(flatbuf);
+
+ // Verify the buffer first using reflection based verification
+ TEST_EQ(flatbuffers::Verify(schema, *schema.root_table(), flatbuf, length),
+ true);
+
+ auto hp = flatbuffers::GetFieldI<uint16_t>(root, hp_field);
+ TEST_EQ(hp, 80);
+
+ // Rather than needing to know the type, we can also get the value of
+ // any field as an int64_t/double/string, regardless of what it actually is.
+ auto hp_int64 = flatbuffers::GetAnyFieldI(root, hp_field);
+ TEST_EQ(hp_int64, 80);
+ auto hp_double = flatbuffers::GetAnyFieldF(root, hp_field);
+ TEST_EQ(hp_double, 80.0);
+ auto hp_string = flatbuffers::GetAnyFieldS(root, hp_field, &schema);
+ TEST_EQ_STR(hp_string.c_str(), "80");
+
+ // Get struct field through reflection
+ auto pos_struct = flatbuffers::GetFieldStruct(root, *pos_field_ptr);
+ TEST_NOTNULL(pos_struct);
+ TEST_EQ(flatbuffers::GetAnyFieldF(*pos_struct,
+ *pos_table_ptr->fields()->LookupByKey("z")),
+ 3.0f);
+
+ auto test3_field = pos_table_ptr->fields()->LookupByKey("test3");
+ auto test3_struct = flatbuffers::GetFieldStruct(*pos_struct, *test3_field);
+ TEST_NOTNULL(test3_struct);
+ auto test3_object = schema.objects()->Get(test3_field->type()->index());
+
+ TEST_EQ(flatbuffers::GetAnyFieldF(*test3_struct,
+ *test3_object->fields()->LookupByKey("a")),
+ 10);
+
+ // We can also modify it.
+ flatbuffers::SetField<uint16_t>(&root, hp_field, 200);
+ hp = flatbuffers::GetFieldI<uint16_t>(root, hp_field);
+ TEST_EQ(hp, 200);
+
+ // We can also set fields generically:
+ flatbuffers::SetAnyFieldI(&root, hp_field, 300);
+ hp_int64 = flatbuffers::GetAnyFieldI(root, hp_field);
+ TEST_EQ(hp_int64, 300);
+ flatbuffers::SetAnyFieldF(&root, hp_field, 300.5);
+ hp_int64 = flatbuffers::GetAnyFieldI(root, hp_field);
+ TEST_EQ(hp_int64, 300);
+ flatbuffers::SetAnyFieldS(&root, hp_field, "300");
+ hp_int64 = flatbuffers::GetAnyFieldI(root, hp_field);
+ TEST_EQ(hp_int64, 300);
+
+ // Test buffer is valid after the modifications
+ TEST_EQ(flatbuffers::Verify(schema, *schema.root_table(), flatbuf, length),
+ true);
+
+ // Reset it, for further tests.
+ flatbuffers::SetField<uint16_t>(&root, hp_field, 80);
+
+ // More advanced functionality: changing the size of items in-line!
+ // First we put the FlatBuffer inside an std::vector.
+ std::vector<uint8_t> resizingbuf(flatbuf, flatbuf + length);
+ // Find the field we want to modify.
+ auto &name_field = *fields->LookupByKey("name");
+ // Get the root.
+ // This time we wrap the result from GetAnyRoot in a smartpointer that
+ // will keep rroot valid as resizingbuf resizes.
+ auto rroot = flatbuffers::piv(flatbuffers::GetAnyRoot(resizingbuf.data()),
+ resizingbuf);
+ SetString(schema, "totally new string", GetFieldS(**rroot, name_field),
+ &resizingbuf);
+ // Here resizingbuf has changed, but rroot is still valid.
+ TEST_EQ_STR(GetFieldS(**rroot, name_field)->c_str(), "totally new string");
+ // Now lets extend a vector by 100 elements (10 -> 110).
+ auto &inventory_field = *fields->LookupByKey("inventory");
+ auto rinventory = flatbuffers::piv(
+ flatbuffers::GetFieldV<uint8_t>(**rroot, inventory_field), resizingbuf);
+ flatbuffers::ResizeVector<uint8_t>(schema, 110, 50, *rinventory,
+ &resizingbuf);
+ // rinventory still valid, so lets read from it.
+ TEST_EQ(rinventory->Get(10), 50);
+
+ // For reflection uses not covered already, there is a more powerful way:
+ // we can simply generate whatever object we want to add/modify in a
+ // FlatBuffer of its own, then add that to an existing FlatBuffer:
+ // As an example, let's add a string to an array of strings.
+ // First, find our field:
+ auto &testarrayofstring_field = *fields->LookupByKey("testarrayofstring");
+ // Find the vector value:
+ auto rtestarrayofstring = flatbuffers::piv(
+ flatbuffers::GetFieldV<flatbuffers::Offset<flatbuffers::String>>(
+ **rroot, testarrayofstring_field),
+ resizingbuf);
+ // It's a vector of 2 strings, to which we add one more, initialized to
+ // offset 0.
+ flatbuffers::ResizeVector<flatbuffers::Offset<flatbuffers::String>>(
+ schema, 3, 0, *rtestarrayofstring, &resizingbuf);
+ // Here we just create a buffer that contans a single string, but this
+ // could also be any complex set of tables and other values.
+ flatbuffers::FlatBufferBuilder stringfbb;
+ stringfbb.Finish(stringfbb.CreateString("hank"));
+ // Add the contents of it to our existing FlatBuffer.
+ // We do this last, so the pointer doesn't get invalidated (since it is
+ // at the end of the buffer):
+ auto string_ptr = flatbuffers::AddFlatBuffer(
+ resizingbuf, stringfbb.GetBufferPointer(), stringfbb.GetSize());
+ // Finally, set the new value in the vector.
+ rtestarrayofstring->MutateOffset(2, string_ptr);
+ TEST_EQ_STR(rtestarrayofstring->Get(0)->c_str(), "bob");
+ TEST_EQ_STR(rtestarrayofstring->Get(2)->c_str(), "hank");
+ // Test integrity of all resize operations above.
+ flatbuffers::Verifier resize_verifier(
+ reinterpret_cast<const uint8_t *>(resizingbuf.data()),
+ resizingbuf.size());
+ TEST_EQ(VerifyMonsterBuffer(resize_verifier), true);
+
+ // Test buffer is valid using reflection as well
+ TEST_EQ(flatbuffers::Verify(schema, *schema.root_table(), resizingbuf.data(),
+ resizingbuf.size()),
+ true);
+
+ // As an additional test, also set it on the name field.
+ // Note: unlike the name change above, this just overwrites the offset,
+ // rather than changing the string in-place.
+ SetFieldT(*rroot, name_field, string_ptr);
+ TEST_EQ_STR(GetFieldS(**rroot, name_field)->c_str(), "hank");
+
+ // Using reflection, rather than mutating binary FlatBuffers, we can also copy
+ // tables and other things out of other FlatBuffers into a FlatBufferBuilder,
+ // either part or whole.
+ flatbuffers::FlatBufferBuilder fbb;
+ auto root_offset = flatbuffers::CopyTable(
+ fbb, schema, *root_table, *flatbuffers::GetAnyRoot(flatbuf), true);
+ fbb.Finish(root_offset, MonsterIdentifier());
+ // Test that it was copied correctly:
+ AccessFlatBufferTest(fbb.GetBufferPointer(), fbb.GetSize());
+
+ // Test buffer is valid using reflection as well
+ TEST_EQ(flatbuffers::Verify(schema, *schema.root_table(),
+ fbb.GetBufferPointer(), fbb.GetSize()),
+ true);
+}
+
+void MiniReflectFlatBuffersTest(uint8_t *flatbuf) {
+ auto s =
+ flatbuffers::FlatBufferToString(flatbuf, Monster::MiniReflectTypeTable());
+ TEST_EQ_STR(
+ s.c_str(),
+ "{ "
+ "pos: { x: 1.0, y: 2.0, z: 3.0, test1: 0.0, test2: Red, test3: "
+ "{ a: 10, b: 20 } }, "
+ "hp: 80, "
+ "name: \"MyMonster\", "
+ "inventory: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], "
+ "test_type: Monster, "
+ "test: { name: \"Fred\" }, "
+ "test4: [ { a: 10, b: 20 }, { a: 30, b: 40 } ], "
+ "testarrayofstring: [ \"bob\", \"fred\", \"bob\", \"fred\" ], "
+ "testarrayoftables: [ { hp: 1000, name: \"Barney\" }, { name: \"Fred\" "
+ "}, "
+ "{ name: \"Wilma\" } ], "
+ // TODO(wvo): should really print this nested buffer correctly.
+ "testnestedflatbuffer: [ 20, 0, 0, 0, 77, 79, 78, 83, 12, 0, 12, 0, 0, "
+ "0, "
+ "4, 0, 6, 0, 8, 0, 12, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 13, 0, 0, 0, 78, "
+ "101, 115, 116, 101, 100, 77, 111, 110, 115, 116, 101, 114, 0, 0, 0 ], "
+ "testarrayofstring2: [ \"jane\", \"mary\" ], "
+ "testarrayofsortedstruct: [ { id: 0, distance: 0 }, "
+ "{ id: 2, distance: 20 }, { id: 3, distance: 30 }, "
+ "{ id: 4, distance: 40 } ], "
+ "flex: [ 210, 4, 5, 2 ], "
+ "test5: [ { a: 10, b: 20 }, { a: 30, b: 40 } ], "
+ "vector_of_enums: [ Blue, Green ], "
+ "scalar_key_sorted_tables: [ { id: \"miss\" } ] "
+ "}");
+
+ Test test(16, 32);
+ Vec3 vec(1, 2, 3, 1.5, Color_Red, test);
+ flatbuffers::FlatBufferBuilder vec_builder;
+ vec_builder.Finish(vec_builder.CreateStruct(vec));
+ auto vec_buffer = vec_builder.Release();
+ auto vec_str = flatbuffers::FlatBufferToString(vec_buffer.data(),
+ Vec3::MiniReflectTypeTable());
+ TEST_EQ_STR(vec_str.c_str(),
+ "{ x: 1.0, y: 2.0, z: 3.0, test1: 1.5, test2: Red, test3: { a: "
+ "16, b: 32 } }");
+}
+
+void MiniReflectFixedLengthArrayTest() {
+ // VS10 does not support typed enums, exclude from tests
+#if !defined(_MSC_VER) || _MSC_VER >= 1700
+ flatbuffers::FlatBufferBuilder fbb;
+ MyGame::Example::ArrayStruct aStruct(2, 12, 1);
+ auto aTable = MyGame::Example::CreateArrayTable(fbb, &aStruct);
+ fbb.Finish(aTable);
+
+ auto flatbuf = fbb.Release();
+ auto s = flatbuffers::FlatBufferToString(
+ flatbuf.data(), MyGame::Example::ArrayTableTypeTable());
+ TEST_EQ_STR(
+ "{ "
+ "a: { a: 2.0, "
+ "b: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], "
+ "c: 12, "
+ "d: [ { a: [ 0, 0 ], b: A, c: [ A, A ], d: [ 0, 0 ] }, "
+ "{ a: [ 0, 0 ], b: A, c: [ A, A ], d: [ 0, 0 ] } ], "
+ "e: 1, f: [ 0, 0 ] } "
+ "}",
+ s.c_str());
+#endif
+}
+
+} // namespace tests
+} // namespace flatbuffers
\ No newline at end of file
diff --git a/tests/reflection_test.h b/tests/reflection_test.h
new file mode 100644
index 0000000..d514867
--- /dev/null
+++ b/tests/reflection_test.h
@@ -0,0 +1,16 @@
+#ifndef TESTS_REFLECTION_TEST_H
+#define TESTS_REFLECTION_TEST_H
+
+#include <string>
+
+namespace flatbuffers {
+namespace tests {
+
+void ReflectionTest(const std::string& tests_data_path, uint8_t *flatbuf, size_t length);
+void MiniReflectFixedLengthArrayTest();
+void MiniReflectFlatBuffersTest(uint8_t *flatbuf);
+
+} // namespace tests
+} // namespace flatbuffers
+
+#endif
diff --git a/tests/rust_usage_test/Cargo.toml b/tests/rust_usage_test/Cargo.toml
index e676970..d5731e7 100644
--- a/tests/rust_usage_test/Cargo.toml
+++ b/tests/rust_usage_test/Cargo.toml
@@ -4,6 +4,7 @@
authors = ["Robert Winslow <hello@rwinslow.com>",
"Casper Neo <cneo@google.com>",
"FlatBuffers Maintainers"]
+edition = "2018"
[dependencies]
flatbuffers = { path = "../../rust/flatbuffers", default-features = false }
diff --git a/tests/rust_usage_test/benches/flatbuffers_benchmarks.rs b/tests/rust_usage_test/benches/flatbuffers_benchmarks.rs
index 580d433..7d72501 100644
--- a/tests/rust_usage_test/benches/flatbuffers_benchmarks.rs
+++ b/tests/rust_usage_test/benches/flatbuffers_benchmarks.rs
@@ -14,9 +14,8 @@
* limitations under the License.
*/
+use bencher::{benchmark_group, Bencher};
use flatbuffers;
-use bencher::Bencher;
-
#[allow(dead_code, unused_imports)]
#[path = "../../monster_test/mod.rs"]
diff --git a/tests/rust_usage_test/benches/flexbuffers_benchmarks.rs b/tests/rust_usage_test/benches/flexbuffers_benchmarks.rs
index 1b9a8fb..2684291 100644
--- a/tests/rust_usage_test/benches/flexbuffers_benchmarks.rs
+++ b/tests/rust_usage_test/benches/flexbuffers_benchmarks.rs
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-use bencher::Bencher;
+use bencher::{benchmark_group, benchmark_main, Bencher};
use flexbuffers::*;
fn push_vec_u64_to_map(b: &mut Bencher) {
diff --git a/tests/rust_usage_test/tests/arrays_test.rs b/tests/rust_usage_test/tests/arrays_test.rs
index faa0ac8..e92e862 100644
--- a/tests/rust_usage_test/tests/arrays_test.rs
+++ b/tests/rust_usage_test/tests/arrays_test.rs
@@ -1,16 +1,23 @@
+#![no_std]
+
+#[cfg(not(feature = "no_std"))]
+extern crate std;
+
+extern crate alloc;
+
extern crate array_init;
#[allow(dead_code, unused_imports)]
#[path = "../../arrays_test/mod.rs"]
mod arrays_test_generated;
-use std::fmt::Debug;
+use alloc::format;
+use core::fmt::Debug;
use crate::arrays_test_generated::my_game::example::*;
extern crate quickcheck;
use array_init::array_init;
-use std::mem::size_of;
+use core::mem::size_of;
use quickcheck::{Arbitrary, Gen};
-
fn create_serialized_example_with_generated_code(builder: &mut flatbuffers::FlatBufferBuilder) {
let nested_struct1 = NestedStruct::new(
&[-1, 2],
@@ -111,12 +118,12 @@
#[test]
fn struct_netsted_struct_is_32_bytes() {
- assert_eq!(32, ::std::mem::size_of::<NestedStruct>());
+ assert_eq!(32, ::core::mem::size_of::<NestedStruct>());
}
#[test]
fn struct_array_struct_is_160_bytes() {
- assert_eq!(160, ::std::mem::size_of::<ArrayStruct>());
+ assert_eq!(160, ::core::mem::size_of::<ArrayStruct>());
}
#[test]
@@ -228,7 +235,7 @@
let b_start_ptr = array_struct.b().as_ptr() as usize;
let d_start_ptr = array_struct.d().as_ptr() as usize;
// The T type of b
- let b_aln = ::std::mem::align_of::<i32>();
+ let b_aln = ::core::mem::align_of::<i32>();
assert_eq!((b_start_ptr - struct_start_ptr) % b_aln, 0);
assert_eq!((d_start_ptr - b_start_ptr) % b_aln, 0);
assert_eq!((d_start_ptr - struct_start_ptr) % 8, 0);
diff --git a/tests/rust_usage_test/tests/flexbuffers_tests/binary_format.rs b/tests/rust_usage_test/tests/flexbuffers_tests/binary_format.rs
index 910fc78..84fd21b 100644
--- a/tests/rust_usage_test/tests/flexbuffers_tests/binary_format.rs
+++ b/tests/rust_usage_test/tests/flexbuffers_tests/binary_format.rs
@@ -115,7 +115,6 @@
let mut expected = x.to_le_bytes().to_vec();
expected.push(3 << 2 | 2); // Float W32.
expected.push(4); // Root width W32.
- println!("{:?}: {:?} vs {:?} cmp {:?}", x, &fxb, &expected, fxb==expected);
fxb == expected
}
}
@@ -321,7 +320,7 @@
v.push(IndirectUInt(u64::max_value()));
v.push(IndirectInt(i64::min_value()));
// TODO(cneo): Something about Float EPSILON and casting leads to a different binary format.
- v.push(IndirectFloat(std::f64::consts::PI));
+ v.push(IndirectFloat(core::f64::consts::PI));
v.push(0u32); // This is stored in 8 bits instead of 64 because of indirection.
v.end_vector();
assert_eq!(
@@ -385,7 +384,6 @@
v.push(IndirectInt(i64::max_value()));
v.end_vector();
let len_with_indirect = builder.view().len() as f32;
- dbg!(len_with_indirect, len_without_indirect);
assert!(len_with_indirect * 2.5 < len_without_indirect);
}
#[test]
diff --git a/tests/rust_usage_test/tests/flexbuffers_tests/mod.rs b/tests/rust_usage_test/tests/flexbuffers_tests/mod.rs
index 621f81b..ee52aca 100644
--- a/tests/rust_usage_test/tests/flexbuffers_tests/mod.rs
+++ b/tests/rust_usage_test/tests/flexbuffers_tests/mod.rs
@@ -13,6 +13,7 @@
// limitations under the License.
mod binary_format;
+#[cfg(not(feature = "no_std"))] // uses file I/O
mod interop;
mod other_api;
#[cfg(not(miri))] // slow.
diff --git a/tests/rust_usage_test/tests/flexbuffers_tests/other_api.rs b/tests/rust_usage_test/tests/flexbuffers_tests/other_api.rs
index d1c0873..9875c22 100644
--- a/tests/rust_usage_test/tests/flexbuffers_tests/other_api.rs
+++ b/tests/rust_usage_test/tests/flexbuffers_tests/other_api.rs
@@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+use alloc::vec::Vec;
+
use flexbuffers::*;
#[cfg(not(miri))] // slow.
use quickcheck::QuickCheck;
diff --git a/tests/rust_usage_test/tests/flexbuffers_tests/qc_serious.rs b/tests/rust_usage_test/tests/flexbuffers_tests/qc_serious.rs
index 1bed3c2..b2e04ec 100644
--- a/tests/rust_usage_test/tests/flexbuffers_tests/qc_serious.rs
+++ b/tests/rust_usage_test/tests/flexbuffers_tests/qc_serious.rs
@@ -1,7 +1,10 @@
+use alloc::collections::BTreeMap;
+use alloc::string::String;
+use alloc::vec::Vec;
+
use super::rwyw::NonNullString;
use flexbuffers::*;
use quickcheck::{Arbitrary, Gen};
-use std::collections::BTreeMap;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
enum Enum {
diff --git a/tests/rust_usage_test/tests/flexbuffers_tests/rwyw.rs b/tests/rust_usage_test/tests/flexbuffers_tests/rwyw.rs
index 8c27e6b..478d33a 100644
--- a/tests/rust_usage_test/tests/flexbuffers_tests/rwyw.rs
+++ b/tests/rust_usage_test/tests/flexbuffers_tests/rwyw.rs
@@ -12,6 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+
// Read what you wrote.
use flexbuffers::*;
#[cfg(not(miri))] // slow.
@@ -23,7 +26,7 @@
pub struct NonNullString(String);
impl quickcheck::Arbitrary for NonNullString {
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
- let size = std::cmp::min(1, usize::arbitrary(g));
+ let size = core::cmp::min(1, usize::arbitrary(g));
NonNullString(
(0..)
.map(|_| <char>::arbitrary(g))
@@ -74,7 +77,7 @@
}
v.end_vector();
let r = Reader::get_root(builder.view()).unwrap().as_vector();
- xs.iter().enumerate().all(|(i, &x)| (r.idx(i).as_f64() - x).abs() < std::f64::EPSILON)
+ xs.iter().enumerate().all(|(i, &x)| (r.idx(i).as_f64() - x).abs() < core::f64::EPSILON)
}
fn qc_vec_string(xs: Vec<String>) -> bool {
let mut builder = Builder::default();
@@ -86,6 +89,7 @@
let r = Reader::get_root(builder.view()).unwrap().as_vector();
xs.iter().enumerate().all(|(i, x)| (r.idx(i).as_str() == x))
}
+ #[cfg(not(feature = "no_std"))]
fn qc_map_int(xs: std::collections::BTreeMap<NonNullString, i64>) -> bool {
let mut builder = Builder::default();
let mut m = builder.start_map();
@@ -98,6 +102,7 @@
r.idx(i).as_i64() == v && r.idx(k.0.as_str()).as_i64() == v
})
}
+ #[cfg(not(feature = "no_std"))]
fn qc_map_string(xs: std::collections::BTreeMap<NonNullString, String>) -> bool {
let mut builder = Builder::default();
let mut m = builder.start_map();
@@ -195,7 +200,6 @@
let foo1 = Foo::default();
let mut s = FlexbufferSerializer::new();
foo1.serialize(&mut s).unwrap();
- dbg!(s.view());
let r = Reader::get_root(s.view()).unwrap();
let foo2 = Foo::deserialize(r).unwrap();
assert_eq!(foo1, foo2);
diff --git a/tests/rust_usage_test/tests/integration_test.rs b/tests/rust_usage_test/tests/integration_test.rs
index 9a4c8b3..73d4a1f 100644
--- a/tests/rust_usage_test/tests/integration_test.rs
+++ b/tests/rust_usage_test/tests/integration_test.rs
@@ -15,6 +15,18 @@
* limitations under the License.
*/
+#![no_std]
+
+#[cfg(not(feature = "no_std"))]
+extern crate std;
+#[cfg(not(feature = "no_std"))]
+use alloc::vec::Vec;
+
+#[macro_use]
+extern crate alloc;
+
+use alloc::string::String;
+
#[cfg(feature = "no_std")]
#[global_allocator]
static ALLOCATOR: libc_alloc::LibcAlloc = libc_alloc::LibcAlloc;
@@ -392,9 +404,9 @@
// If the verifier says a buffer is okay then using it won't cause a crash.
// We use write_fmt since Debug visits all the fields - but there's no need to store anything.
struct ForgetfulWriter;
- use std::fmt::Write;
+ use core::fmt::Write;
impl Write for ForgetfulWriter {
- fn write_str(&mut self, _: &str) -> Result<(), std::fmt::Error> {
+ fn write_str(&mut self, _: &str) -> Result<(), core::fmt::Error> {
Ok(())
}
}
@@ -442,7 +454,7 @@
let b = &mut flatbuffers::FlatBufferBuilder::new();
let name = Some(b.create_string("foo"));
// String amplification attack.
- let s = b.create_string(&(std::iter::repeat("X").take(1000).collect::<String>()));
+ let s = b.create_string(&(core::iter::repeat("X").take(1000).collect::<String>()));
let testarrayofstring = Some(b.create_vector(&vec![s; 1000]));
let m = Monster::create(b, &MonsterArgs {
testarrayofstring,
@@ -541,11 +553,12 @@
}
}
+#[cfg(not(feature = "no_std"))]
#[cfg(test)]
mod lifetime_correctness {
extern crate flatbuffers;
- use std::mem;
+ use core::mem;
use super::my_game;
use super::load_file;
@@ -593,6 +606,8 @@
mod roundtrip_generated_code {
extern crate flatbuffers;
+ use alloc::vec::Vec;
+
use super::my_game;
fn build_mon<'a, 'b>(builder: &'a mut flatbuffers::FlatBufferBuilder, args: &'b my_game::example::MonsterArgs) -> my_game::example::Monster<'a> {
@@ -988,25 +1003,25 @@
#[test]
fn enum_color_is_1_byte() {
- assert_eq!(1, ::std::mem::size_of::<my_game::example::Color>());
+ assert_eq!(1, ::core::mem::size_of::<my_game::example::Color>());
}
#[test]
fn union_any_is_1_byte() {
- assert_eq!(1, ::std::mem::size_of::<my_game::example::Any>());
+ assert_eq!(1, ::core::mem::size_of::<my_game::example::Any>());
}
#[test]
fn union_any_is_aligned_to_1() {
- assert_eq!(1, ::std::mem::align_of::<my_game::example::Any>());
+ assert_eq!(1, ::core::mem::align_of::<my_game::example::Any>());
}
#[test]
fn struct_test_is_4_bytes() {
- assert_eq!(4, ::std::mem::size_of::<my_game::example::Test>());
+ assert_eq!(4, ::core::mem::size_of::<my_game::example::Test>());
}
#[test]
fn struct_vec3_is_32_bytes() {
- assert_eq!(32, ::std::mem::size_of::<my_game::example::Vec3>());
+ assert_eq!(32, ::core::mem::size_of::<my_game::example::Vec3>());
}
#[test]
@@ -1036,7 +1051,7 @@
#[test]
fn struct_ability_is_8_bytes() {
- assert_eq!(8, ::std::mem::size_of::<my_game::example::Ability>());
+ assert_eq!(8, ::core::mem::size_of::<my_game::example::Ability>());
}
#[test]
@@ -1061,7 +1076,7 @@
for a in abilities.iter() {
let a_ptr = a as *const my_game::example::Ability as usize;
assert!(a_ptr > start_ptr);
- let aln = ::std::mem::align_of::<my_game::example::Ability>();
+ let aln = ::core::mem::align_of::<my_game::example::Ability>();
assert_eq!((a_ptr - start_ptr) % aln, 0);
}
for a in abilities.iter().rev() {
@@ -1166,6 +1181,8 @@
extern crate quickcheck;
extern crate flatbuffers;
+ use alloc::vec::Vec;
+
const N: u64 = 20;
fn prop<T>(xs: Vec<T>)
@@ -1173,7 +1190,7 @@
T: for<'a> flatbuffers::Follow<'a, Inner = T>
+ flatbuffers::EndianScalar
+ flatbuffers::Push
- + ::std::fmt::Debug,
+ + ::core::fmt::Debug,
{
use flatbuffers::Follow;
@@ -1247,7 +1264,7 @@
// complicated.
macro_rules! impl_prop {
($test_name:ident, $fn_name:ident, $ty:ident) => (
- fn $fn_name(xs: Vec<$ty>) {
+ fn $fn_name(xs: alloc::vec::Vec<$ty>) {
use flatbuffers::Follow;
let mut b = flatbuffers::FlatBufferBuilder::new();
@@ -1258,7 +1275,7 @@
assert_eq!(got, &xs[..]);
}
#[test]
- fn $test_name() { quickcheck::QuickCheck::new().max_tests(N).quickcheck($fn_name as fn(Vec<_>)); }
+ fn $test_name() { quickcheck::QuickCheck::new().max_tests(N).quickcheck($fn_name as fn(alloc::vec::Vec<_>)); }
)
}
@@ -1289,6 +1306,9 @@
extern crate quickcheck;
extern crate flatbuffers;
+ use alloc::string::String;
+ use alloc::vec::Vec;
+
fn prop(xs: Vec<String>) {
use flatbuffers::Follow;
@@ -1327,6 +1347,9 @@
extern crate quickcheck;
extern crate flatbuffers;
+ use alloc::string::String;
+ use alloc::vec::Vec;
+
fn prop(input: Vec<String>) {
let xs: Vec<&str> = input.iter().map(|s: &String| &s[..]).collect();
@@ -1358,6 +1381,8 @@
extern crate quickcheck;
extern crate flatbuffers;
+ use alloc::vec::Vec;
+
#[cfg(not(miri))] // slow.
#[test]
fn fuzz_manual_build() {
@@ -1409,8 +1434,11 @@
}
}
+#[cfg(not(feature = "no_std"))]
#[cfg(test)]
mod roundtrip_table {
+ use alloc::string::String;
+ use alloc::vec::Vec;
use std::collections::HashMap;
extern crate flatbuffers;
@@ -1429,9 +1457,9 @@
let uchar_val: u8 = 0xFF;
let short_val: i16 = -32222; // 0x8222;
let ushort_val: u16 = 0xFEEE;
- let int_val: i32 = unsafe { ::std::mem::transmute(0x83333333u32) };
+ let int_val: i32 = unsafe { ::core::mem::transmute(0x83333333u32) };
let uint_val: u32 = 0xFDDDDDDD;
- let long_val: i64 = unsafe { ::std::mem::transmute(0x8444444444444444u64) }; // TODO: byte literal?
+ let long_val: i64 = unsafe { ::core::mem::transmute(0x8444444444444444u64) }; // TODO: byte literal?
let ulong_val: u64 = 0xFCCCCCCCCCCCCCCCu64;
let float_val: f32 = 3.14159;
let double_val: f64 = 3.14159265359;
@@ -1598,6 +1626,9 @@
#[cfg(not(miri))] // slow.
mod table_of_vectors_of_scalars {
+
+ use alloc::vec::Vec;
+
extern crate flatbuffers;
#[cfg(not(miri))] // slow.
extern crate quickcheck;
@@ -1609,7 +1640,7 @@
T: for<'a> flatbuffers::Follow<'a, Inner = T>
+ flatbuffers::EndianScalar
+ flatbuffers::Push
- + ::std::fmt::Debug,
+ + ::core::fmt::Debug,
{
use flatbuffers::field_index_to_field_offset as fi2fo;
use flatbuffers::Follow;
@@ -1689,8 +1720,8 @@
const N: u64 = 1000;
- fn prop<T: PartialEq + ::std::fmt::Debug + Copy + flatbuffers::EndianScalar>(x: T) {
- let mut buf = vec![0u8; ::std::mem::size_of::<T>()];
+ fn prop<T: PartialEq + ::core::fmt::Debug + Copy + flatbuffers::EndianScalar>(x: T) {
+ let mut buf = vec![0u8; ::core::mem::size_of::<T>()];
let y = unsafe {
flatbuffers::emplace_scalar(&mut buf[..], x);
flatbuffers::read_scalar(&buf[..])
@@ -1742,7 +1773,7 @@
macro_rules! impl_prop {
($fn_name:ident, $ty:ident) => (
fn $fn_name(x: $ty) {
- let mut buf = vec![0u8; ::std::mem::size_of::<$ty>()];
+ let mut buf = vec![0u8; ::core::mem::size_of::<$ty>()];
x.push(&mut buf[..], &[][..]);
let fs: flatbuffers::FollowStart<$ty> = flatbuffers::FollowStart::new();
assert_eq!(fs.self_follow(&buf[..], 0), x);
@@ -1896,10 +1927,13 @@
}
}
+#[cfg(not(feature = "no_std"))]
#[cfg(test)]
mod read_examples_from_other_language_ports {
extern crate flatbuffers;
+ use std::println;
+
use super::load_file;
use super::serialized_example_is_accessible_and_correct;
@@ -1974,9 +2008,9 @@
fn struct_key_compare_with_value() {
let a = my_game::example::Ability::new(1, 2);
- assert_eq!(a.key_compare_with_value(0), ::std::cmp::Ordering::Greater);
- assert_eq!(a.key_compare_with_value(1), ::std::cmp::Ordering::Equal);
- assert_eq!(a.key_compare_with_value(2), ::std::cmp::Ordering::Less);
+ assert_eq!(a.key_compare_with_value(0), ::core::cmp::Ordering::Greater);
+ assert_eq!(a.key_compare_with_value(1), ::core::cmp::Ordering::Equal);
+ assert_eq!(a.key_compare_with_value(2), ::core::cmp::Ordering::Less);
}
#[test]
@@ -2010,9 +2044,9 @@
// preconditions
assert_eq!(a.name(), "MyMonster");
- assert_eq!(a.key_compare_with_value("AAA"), ::std::cmp::Ordering::Greater);
- assert_eq!(a.key_compare_with_value("MyMonster"), ::std::cmp::Ordering::Equal);
- assert_eq!(a.key_compare_with_value("ZZZ"), ::std::cmp::Ordering::Less);
+ assert_eq!(a.key_compare_with_value("AAA"), ::core::cmp::Ordering::Greater);
+ assert_eq!(a.key_compare_with_value("MyMonster"), ::core::cmp::Ordering::Equal);
+ assert_eq!(a.key_compare_with_value("ZZZ"), ::core::cmp::Ordering::Less);
}
#[test]
@@ -2116,6 +2150,8 @@
use flatbuffers::Follow;
use flatbuffers::field_index_to_field_offset as fi2fo;
+ use alloc::vec::Vec;
+
// Define a test struct to use in a few tests. This replicates the work that the code generator
// would normally do when defining a FlatBuffer struct. For reference, compare the following
// `FooStruct` code with the code generated for the `Vec3` struct in
@@ -2884,12 +2920,12 @@
c: i8,
_pad2: [u8; 4],
}
- assert_eq!(::std::mem::size_of::<foo>(), 16);
+ assert_eq!(::core::mem::size_of::<foo>(), 16);
impl<'b> flatbuffers::Push for &'b foo {
type Output = foo;
fn push<'a>(&'a self, dst: &'a mut [u8], _rest: &'a [u8]) {
let src = unsafe {
- ::std::slice::from_raw_parts(*self as *const foo as *const u8, ::std::mem::size_of::<foo>())
+ ::core::slice::from_raw_parts(*self as *const foo as *const u8, ::core::mem::size_of::<foo>())
};
dst.copy_from_slice(src);
}
@@ -3170,6 +3206,9 @@
#[cfg(test)]
mod copy_clone_traits {
+
+ use alloc::vec::Vec;
+
#[test]
fn follow_types_implement_copy_and_clone() {
static_assertions::assert_impl_all!(flatbuffers::WIPOffset<u32>: Copy, Clone);
@@ -3187,17 +3226,18 @@
mod fully_qualified_name {
#[test]
fn fully_qualified_name_generated() {
- assert!(check_eq!(::my_game::example::Monster::get_fully_qualified_name(), "MyGame.Example.Monster").is_ok());
- assert!(check_eq!(::my_game::example_2::Monster::get_fully_qualified_name(), "MyGame.Example2.Monster").is_ok());
+ assert!(check_eq!(super::my_game::example::Monster::get_fully_qualified_name(), "MyGame.Example.Monster").is_ok());
+ assert!(check_eq!(super::my_game::example_2::Monster::get_fully_qualified_name(), "MyGame.Example2.Monster").is_ok());
- assert!(check_eq!(::my_game::example::Vec3::get_fully_qualified_name(), "MyGame.Example.Vec3").is_ok());
- assert!(check_eq!(::my_game::example::Ability::get_fully_qualified_name(), "MyGame.Example.Ability").is_ok());
+ assert!(check_eq!(super::my_game::example::Vec3::get_fully_qualified_name(), "MyGame.Example.Vec3").is_ok());
+ assert!(check_eq!(super::my_game::example::Ability::get_fully_qualified_name(), "MyGame.Example.Ability").is_ok());
}
}
// this is not technically a test, but we want to always keep this generated
// file up-to-date, and the simplest way to do that is to make sure that when
// tests are run, the file is generated.
+#[cfg(not(feature = "no_std"))]
#[test]
fn write_example_wire_data_to_file() {
let b = &mut flatbuffers::FlatBufferBuilder::new();
@@ -3208,6 +3248,7 @@
f.write_all(b.finished_data()).unwrap();
}
+#[cfg(not(feature = "no_std"))]
fn load_file(filename: &str) -> Result<Vec<u8>, std::io::Error> {
use std::io::Read;
let mut f = std::fs::File::open(filename)?;
diff --git a/tests/rust_usage_test/tests/more_defaults_test.rs b/tests/rust_usage_test/tests/more_defaults_test.rs
index af664f2..4d62a4a 100644
--- a/tests/rust_usage_test/tests/more_defaults_test.rs
+++ b/tests/rust_usage_test/tests/more_defaults_test.rs
@@ -1,3 +1,8 @@
+extern crate alloc;
+
+use alloc::string::ToString;
+use alloc::vec::Vec;
+
#[allow(dead_code, unused_imports)]
#[path = "../../more_defaults/mod.rs"]
mod more_defaults_generated;
diff --git a/tests/FlatBuffers.Benchmarks.swift/Package.swift b/tests/swift/Wasm.tests/Package.swift
similarity index 79%
rename from tests/FlatBuffers.Benchmarks.swift/Package.swift
rename to tests/swift/Wasm.tests/Package.swift
index 2026247..6d3b164 100644
--- a/tests/FlatBuffers.Benchmarks.swift/Package.swift
+++ b/tests/swift/Wasm.tests/Package.swift
@@ -18,15 +18,17 @@
import PackageDescription
let package = Package(
- name: "FlatBuffers.Benchmarks.swift",
+ name: "FlatBuffers.Test.Swift.Wasm",
platforms: [
.macOS(.v10_14),
],
dependencies: [
- .package(path: "../../swift"),
+ .package(path: "../../../swift"),
],
targets: [
.target(
- name: "FlatBuffers.Benchmarks.swift",
- dependencies: ["FlatBuffers"]),
+ name: "Wasm"),
+ .testTarget(
+ name: "FlatBuffers.Test.Swift.WasmTests",
+ dependencies: ["FlatBuffers"])
])
diff --git a/tests/swift/Wasm.tests/Sources/Wasm/Wasm.swift b/tests/swift/Wasm.tests/Sources/Wasm/Wasm.swift
new file mode 100644
index 0000000..c14abeb
--- /dev/null
+++ b/tests/swift/Wasm.tests/Sources/Wasm/Wasm.swift
@@ -0,0 +1 @@
+public struct Wasm {}
\ No newline at end of file
diff --git a/tests/swift/Wasm.tests/Tests/FlatBuffers.Test.Swift.WasmTests/FlatBuffersMonsterWriterTests.swift b/tests/swift/Wasm.tests/Tests/FlatBuffers.Test.Swift.WasmTests/FlatBuffersMonsterWriterTests.swift
new file mode 100644
index 0000000..614791e
--- /dev/null
+++ b/tests/swift/Wasm.tests/Tests/FlatBuffers.Test.Swift.WasmTests/FlatBuffersMonsterWriterTests.swift
@@ -0,0 +1,355 @@
+/*
+ * Copyright 2021 Google Inc. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import Foundation
+import XCTest
+@testable import FlatBuffers
+
+typealias Test = MyGame_Example_Test
+typealias Monster = MyGame_Example_Monster
+typealias Vec3 = MyGame_Example_Vec3
+typealias Stat = MyGame_Example_Stat
+
+class FlatBuffersMonsterWriterTests: XCTestCase {
+
+ func testData() {
+ // swiftformat:disable all
+ let data: [UInt8] = [48, 0, 0, 0, 77, 79, 78, 83, 0, 0, 0, 0, 36, 0, 72, 0, 40, 0, 0, 0, 38, 0, 32, 0, 0, 0, 28, 0, 0, 0, 27, 0, 20, 0, 16, 0, 12, 0, 4, 0, 0, 0, 0, 0, 0, 0, 11, 0, 36, 0, 0, 0, 164, 0, 0, 0, 0, 0, 0, 1, 60, 0, 0, 0, 68, 0, 0, 0, 76, 0, 0, 0, 0, 0, 0, 1, 88, 0, 0, 0, 120, 0, 0, 0, 0, 0, 80, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 64, 2, 0, 5, 0, 6, 0, 0, 0, 2, 0, 0, 0, 64, 0, 0, 0, 48, 0, 0, 0, 2, 0, 0, 0, 30, 0, 40, 0, 10, 0, 20, 0, 152, 255, 255, 255, 4, 0, 0, 0, 4, 0, 0, 0, 70, 114, 101, 100, 0, 0, 0, 0, 5, 0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 0, 5, 0, 0, 0, 116, 101, 115, 116, 50, 0, 0, 0, 5, 0, 0, 0, 116, 101, 115, 116, 49, 0, 0, 0, 9, 0, 0, 0, 77, 121, 77, 111, 110, 115, 116, 101, 114, 0, 0, 0, 3, 0, 0, 0, 20, 0, 0, 0, 36, 0, 0, 0, 4, 0, 0, 0, 240, 255, 255, 255, 32, 0, 0, 0, 248, 255, 255, 255, 36, 0, 0, 0, 12, 0, 8, 0, 0, 0, 0, 0, 0, 0, 4, 0, 12, 0, 0, 0, 28, 0, 0, 0, 5, 0, 0, 0, 87, 105, 108, 109, 97, 0, 0, 0, 6, 0, 0, 0, 66, 97, 114, 110, 101, 121, 0, 0, 5, 0, 0, 0, 70, 114, 111, 100, 111, 0, 0, 0]
+ // swiftformat:enable all
+ let _data = ByteBuffer(bytes: data)
+ readVerifiedMonster(fb: _data)
+ }
+
+ func testCreateMonster() {
+ let bytes = createMonster(withPrefix: false)
+ // swiftformat:disable all
+ XCTAssertEqual(bytes.sizedByteArray, [48, 0, 0, 0, 77, 79, 78, 83, 0, 0, 0, 0, 36, 0, 72, 0, 40, 0, 0, 0, 38, 0, 32, 0, 0, 0, 28, 0, 0, 0, 27, 0, 20, 0, 16, 0, 12, 0, 4, 0, 0, 0, 0, 0, 0, 0, 11, 0, 36, 0, 0, 0, 164, 0, 0, 0, 0, 0, 0, 1, 60, 0, 0, 0, 68, 0, 0, 0, 76, 0, 0, 0, 0, 0, 0, 1, 88, 0, 0, 0, 120, 0, 0, 0, 0, 0, 80, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 64, 2, 0, 5, 0, 6, 0, 0, 0, 2, 0, 0, 0, 64, 0, 0, 0, 48, 0, 0, 0, 2, 0, 0, 0, 30, 0, 40, 0, 10, 0, 20, 0, 152, 255, 255, 255, 4, 0, 0, 0, 4, 0, 0, 0, 70, 114, 101, 100, 0, 0, 0, 0, 5, 0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 0, 5, 0, 0, 0, 116, 101, 115, 116, 50, 0, 0, 0, 5, 0, 0, 0, 116, 101, 115, 116, 49, 0, 0, 0, 9, 0, 0, 0, 77, 121, 77, 111, 110, 115, 116, 101, 114, 0, 0, 0, 3, 0, 0, 0, 20, 0, 0, 0, 36, 0, 0, 0, 4, 0, 0, 0, 240, 255, 255, 255, 32, 0, 0, 0, 248, 255, 255, 255, 36, 0, 0, 0, 12, 0, 8, 0, 0, 0, 0, 0, 0, 0, 4, 0, 12, 0, 0, 0, 28, 0, 0, 0, 5, 0, 0, 0, 87, 105, 108, 109, 97, 0, 0, 0, 6, 0, 0, 0, 66, 97, 114, 110, 101, 121, 0, 0, 5, 0, 0, 0, 70, 114, 111, 100, 111, 0, 0, 0])
+ // swiftformat:enable all
+ let monster = MyGame_Example_Monster.getRootAsMonster(bb: bytes.buffer)
+ readMonster(monster: monster)
+ mutateMonster(fb: bytes.buffer)
+ readMonster(monster: monster)
+ }
+
+ func testCreateMonsterResizedBuffer() {
+ let bytes = createMonster(withPrefix: false)
+ // swiftformat:disable all
+ XCTAssertEqual(bytes.sizedByteArray, [48, 0, 0, 0, 77, 79, 78, 83, 0, 0, 0, 0, 36, 0, 72, 0, 40, 0, 0, 0, 38, 0, 32, 0, 0, 0, 28, 0, 0, 0, 27, 0, 20, 0, 16, 0, 12, 0, 4, 0, 0, 0, 0, 0, 0, 0, 11, 0, 36, 0, 0, 0, 164, 0, 0, 0, 0, 0, 0, 1, 60, 0, 0, 0, 68, 0, 0, 0, 76, 0, 0, 0, 0, 0, 0, 1, 88, 0, 0, 0, 120, 0, 0, 0, 0, 0, 80, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 64, 2, 0, 5, 0, 6, 0, 0, 0, 2, 0, 0, 0, 64, 0, 0, 0, 48, 0, 0, 0, 2, 0, 0, 0, 30, 0, 40, 0, 10, 0, 20, 0, 152, 255, 255, 255, 4, 0, 0, 0, 4, 0, 0, 0, 70, 114, 101, 100, 0, 0, 0, 0, 5, 0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 0, 5, 0, 0, 0, 116, 101, 115, 116, 50, 0, 0, 0, 5, 0, 0, 0, 116, 101, 115, 116, 49, 0, 0, 0, 9, 0, 0, 0, 77, 121, 77, 111, 110, 115, 116, 101, 114, 0, 0, 0, 3, 0, 0, 0, 20, 0, 0, 0, 36, 0, 0, 0, 4, 0, 0, 0, 240, 255, 255, 255, 32, 0, 0, 0, 248, 255, 255, 255, 36, 0, 0, 0, 12, 0, 8, 0, 0, 0, 0, 0, 0, 0, 4, 0, 12, 0, 0, 0, 28, 0, 0, 0, 5, 0, 0, 0, 87, 105, 108, 109, 97, 0, 0, 0, 6, 0, 0, 0, 66, 97, 114, 110, 101, 121, 0, 0, 5, 0, 0, 0, 70, 114, 111, 100, 111, 0, 0, 0])
+ // swiftformat:enable all
+ readVerifiedMonster(fb: bytes.sizedBuffer)
+ }
+
+ func testCreateMonsterPrefixed() {
+ let bytes = createMonster(withPrefix: true)
+ // swiftformat:disable all
+ XCTAssertEqual(bytes.sizedByteArray, [44, 1, 0, 0, 44, 0, 0, 0, 77, 79, 78, 83, 36, 0, 72, 0, 40, 0, 0, 0, 38, 0, 32, 0, 0, 0, 28, 0, 0, 0, 27, 0, 20, 0, 16, 0, 12, 0, 4, 0, 0, 0, 0, 0, 0, 0, 11, 0, 36, 0, 0, 0, 164, 0, 0, 0, 0, 0, 0, 1, 60, 0, 0, 0, 68, 0, 0, 0, 76, 0, 0, 0, 0, 0, 0, 1, 88, 0, 0, 0, 120, 0, 0, 0, 0, 0, 80, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 64, 2, 0, 5, 0, 6, 0, 0, 0, 2, 0, 0, 0, 64, 0, 0, 0, 48, 0, 0, 0, 2, 0, 0, 0, 30, 0, 40, 0, 10, 0, 20, 0, 152, 255, 255, 255, 4, 0, 0, 0, 4, 0, 0, 0, 70, 114, 101, 100, 0, 0, 0, 0, 5, 0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 0, 5, 0, 0, 0, 116, 101, 115, 116, 50, 0, 0, 0, 5, 0, 0, 0, 116, 101, 115, 116, 49, 0, 0, 0, 9, 0, 0, 0, 77, 121, 77, 111, 110, 115, 116, 101, 114, 0, 0, 0, 3, 0, 0, 0, 20, 0, 0, 0, 36, 0, 0, 0, 4, 0, 0, 0, 240, 255, 255, 255, 32, 0, 0, 0, 248, 255, 255, 255, 36, 0, 0, 0, 12, 0, 8, 0, 0, 0, 0, 0, 0, 0, 4, 0, 12, 0, 0, 0, 28, 0, 0, 0, 5, 0, 0, 0, 87, 105, 108, 109, 97, 0, 0, 0, 6, 0, 0, 0, 66, 97, 114, 110, 101, 121, 0, 0, 5, 0, 0, 0, 70, 114, 111, 100, 111, 0, 0, 0])
+ // swiftformat:enable all
+
+ var buffer = bytes.buffer
+ readMonster(monster: getPrefixedSizeRoot(byteBuffer: &buffer))
+ }
+
+ func testCreateMonsterUsingCreateMonsterMethodWithNilPos() {
+ var fbb = FlatBufferBuilder(initialSize: 1)
+ let name = fbb.create(string: "Frodo")
+ let mStart = Monster.startMonster(&fbb)
+ Monster.add(name: name, &fbb)
+ let root = Monster.endMonster(&fbb, start: mStart)
+ fbb.finish(offset: root)
+ let newMonster = Monster.getRootAsMonster(bb: fbb.sizedBuffer)
+ XCTAssertNil(newMonster.pos)
+ XCTAssertEqual(newMonster.name, "Frodo")
+ }
+
+ func testCreateMonsterUsingCreateMonsterMethodWithPosX() {
+ var fbb = FlatBufferBuilder(initialSize: 1)
+ let name = fbb.create(string: "Barney")
+ let mStart = Monster.startMonster(&fbb)
+ Monster.add(
+ pos: MyGame_Example_Vec3(
+ x: 10,
+ y: 0,
+ z: 0,
+ test1: 0,
+ test2: .blue,
+ test3: .init()),
+ &fbb)
+ Monster.add(name: name, &fbb)
+ let root = Monster.endMonster(&fbb, start: mStart)
+ fbb.finish(offset: root)
+
+ let newMonster = Monster.getRootAsMonster(bb: fbb.sizedBuffer)
+ XCTAssertEqual(newMonster.pos!.x, 10)
+ XCTAssertEqual(newMonster.name, "Barney")
+ }
+
+ func testArrayOfBools() {
+ let boolArray = [false, true, false, true, false, true, false]
+ var fbb = FlatBufferBuilder(initialSize: 1)
+ let name = fbb.create(string: "Frodo")
+ let bools = fbb.createVector(boolArray)
+ let root = Monster.createMonster(
+ &fbb,
+ nameOffset: name,
+ testarrayofboolsVectorOffset: bools)
+ fbb.finish(offset: root)
+ let monster = Monster.getRootAsMonster(bb: fbb.sizedBuffer)
+
+ let values = monster.testarrayofbools
+
+ XCTAssertEqual(boolArray, values)
+
+ for i in 0..<monster.testarrayofboolsCount {
+ XCTAssertEqual(boolArray[Int(i)], monster.testarrayofbools(at: i))
+ }
+ }
+
+ func readVerifiedMonster(fb: ByteBuffer) {
+ var byteBuffer = fb
+ XCTAssertNoThrow(
+ try readMonster(
+ monster: getCheckedRoot(
+ byteBuffer: &byteBuffer) as MyGame_Example_Monster))
+ }
+
+ func readMonster(monster: Monster) {
+ var monster = monster
+ readFlatbufferMonster(monster: &monster)
+ let unpacked: MyGame_Example_MonsterT? = monster.unpack()
+ readObjectApi(monster: unpacked!)
+ guard let buffer = unpacked?.serialize()
+ else { fatalError("Couldnt generate bytebuffer") }
+ var newMonster = Monster.getRootAsMonster(bb: buffer)
+ readFlatbufferMonster(monster: &newMonster)
+ }
+
+ func createMonster(withPrefix prefix: Bool) -> FlatBufferBuilder {
+ var fbb = FlatBufferBuilder(initialSize: 1)
+ let names = [
+ fbb.create(string: "Frodo"),
+ fbb.create(string: "Barney"),
+ fbb.create(string: "Wilma"),
+ ]
+ var offsets: [Offset] = []
+ let start1 = Monster.startMonster(&fbb)
+ Monster.add(name: names[0], &fbb)
+ offsets.append(Monster.endMonster(&fbb, start: start1))
+ let start2 = Monster.startMonster(&fbb)
+ Monster.add(name: names[1], &fbb)
+ offsets.append(Monster.endMonster(&fbb, start: start2))
+ let start3 = Monster.startMonster(&fbb)
+ Monster.add(name: names[2], &fbb)
+ offsets.append(Monster.endMonster(&fbb, start: start3))
+
+ let sortedArray = Monster.sortVectorOfMonster(offsets: offsets, &fbb)
+
+ let str = fbb.create(string: "MyMonster")
+ let test1 = fbb.create(string: "test1")
+ let test2 = fbb.create(string: "test2")
+ let _inv: [Byte] = [0, 1, 2, 3, 4]
+ let inv = fbb.createVector(_inv)
+
+ let fred = fbb.create(string: "Fred")
+ let mon1Start = Monster.startMonster(&fbb)
+ Monster.add(name: fred, &fbb)
+ let mon2 = Monster.endMonster(&fbb, start: mon1Start)
+
+ let test4 = fbb.createVector(ofStructs: [
+ MyGame_Example_Test(a: 30, b: 40),
+ MyGame_Example_Test(a: 10, b: 20),
+ ])
+
+ let stringTestVector = fbb.createVector(ofOffsets: [test1, test2])
+ let mStart = Monster.startMonster(&fbb)
+ Monster.add(
+ pos: MyGame_Example_Vec3(
+ x: 1,
+ y: 2,
+ z: 3,
+ test1: 3,
+ test2: .green,
+ test3: .init(a: 5, b: 6)),
+ &fbb)
+ Monster.add(hp: 80, &fbb)
+ Monster.add(name: str, &fbb)
+ Monster.addVectorOf(inventory: inv, &fbb)
+ Monster.add(testType: .monster, &fbb)
+ Monster.add(test: mon2, &fbb)
+ Monster.addVectorOf(test4: test4, &fbb)
+ Monster.addVectorOf(testarrayofstring: stringTestVector, &fbb)
+ Monster.add(testbool: true, &fbb)
+ Monster.addVectorOf(testarrayoftables: sortedArray, &fbb)
+ let end = Monster.endMonster(&fbb, start: mStart)
+ Monster.finish(&fbb, end: end, prefix: prefix)
+ return fbb
+ }
+
+ func mutateMonster(fb: ByteBuffer) {
+ let monster = Monster.getRootAsMonster(bb: fb)
+ XCTAssertFalse(monster.mutate(mana: 10))
+ XCTAssertEqual(monster.testarrayoftables(at: 0)?.name, "Barney")
+ XCTAssertEqual(monster.testarrayoftables(at: 1)?.name, "Frodo")
+ XCTAssertEqual(monster.testarrayoftables(at: 2)?.name, "Wilma")
+
+ // Example of searching for a table by the key
+ XCTAssertNotNil(monster.testarrayoftablesBy(key: "Frodo"))
+ XCTAssertNotNil(monster.testarrayoftablesBy(key: "Barney"))
+ XCTAssertNotNil(monster.testarrayoftablesBy(key: "Wilma"))
+
+ XCTAssertEqual(monster.testType, .monster)
+
+ XCTAssertEqual(monster.mutate(inventory: 1, at: 0), true)
+ XCTAssertEqual(monster.mutate(inventory: 2, at: 1), true)
+ XCTAssertEqual(monster.mutate(inventory: 3, at: 2), true)
+ XCTAssertEqual(monster.mutate(inventory: 4, at: 3), true)
+ XCTAssertEqual(monster.mutate(inventory: 5, at: 4), true)
+
+ for i in 0..<monster.inventoryCount {
+ XCTAssertEqual(monster.inventory(at: i), Byte(i + 1))
+ }
+
+ XCTAssertEqual(monster.mutate(inventory: 0, at: 0), true)
+ XCTAssertEqual(monster.mutate(inventory: 1, at: 1), true)
+ XCTAssertEqual(monster.mutate(inventory: 2, at: 2), true)
+ XCTAssertEqual(monster.mutate(inventory: 3, at: 3), true)
+ XCTAssertEqual(monster.mutate(inventory: 4, at: 4), true)
+
+ let vec = monster.mutablePos
+ XCTAssertEqual(vec?.x, 1)
+ XCTAssertTrue(vec?.mutate(x: 55.0) ?? false)
+ XCTAssertTrue(vec?.mutate(test1: 55) ?? false)
+ XCTAssertEqual(vec?.x, 55.0)
+ XCTAssertEqual(vec?.test1, 55.0)
+ XCTAssertTrue(vec?.mutate(x: 1) ?? false)
+ XCTAssertEqual(vec?.x, 1)
+ XCTAssertTrue(vec?.mutate(test1: 3) ?? false)
+ }
+
+ func readFlatbufferMonster(monster: inout MyGame_Example_Monster) {
+ XCTAssertEqual(monster.hp, 80)
+ XCTAssertEqual(monster.mana, 150)
+ XCTAssertEqual(monster.name, "MyMonster")
+ let pos = monster.pos
+ XCTAssertEqual(pos?.x, 1)
+ XCTAssertEqual(pos?.y, 2)
+ XCTAssertEqual(pos?.z, 3)
+ XCTAssertEqual(pos?.test1, 3)
+ XCTAssertEqual(pos?.test2, .green)
+ let test = pos?.test3
+ XCTAssertEqual(test?.a, 5)
+ XCTAssertEqual(test?.b, 6)
+ XCTAssertEqual(monster.testType, .monster)
+ let monster2 = monster.test(type: Monster.self)
+ XCTAssertEqual(monster2?.name, "Fred")
+
+ XCTAssertEqual(monster.mutate(mana: 10), false)
+
+ XCTAssertEqual(monster.mana, 150)
+ XCTAssertEqual(monster.inventoryCount, 5)
+ var sum: Byte = 0
+ for i in 0...monster.inventoryCount {
+ sum += monster.inventory(at: i)
+ }
+ XCTAssertEqual(sum, 10)
+ XCTAssertEqual(monster.test4Count, 2)
+
+ let test0 = monster.test4(at: 0)
+ let test1 = monster.test4(at: 1)
+ var sum0 = 0
+ var sum1 = 0
+ if let a = test0?.a, let b = test0?.b {
+ sum0 = Int(a) + Int(b)
+ }
+ if let a = test1?.a, let b = test1?.b {
+ sum1 = Int(a) + Int(b)
+ }
+ XCTAssertEqual(sum0 + sum1, 100)
+
+ let mutableTest0 = monster.mutableTest4(at: 0)
+ let mutableTest1 = monster.mutableTest4(at: 1)
+ var sum2 = 0
+ var sum3 = 0
+ if let a = mutableTest0?.a, let b = mutableTest0?.b {
+ sum2 = Int(a) + Int(b)
+ }
+ if let a = mutableTest1?.a, let b = mutableTest1?.b {
+ sum3 = Int(a) + Int(b)
+ }
+ XCTAssertEqual(sum2 + sum3, 100)
+
+ XCTAssertEqual(monster.testarrayofstringCount, 2)
+ XCTAssertEqual(monster.testarrayofstring(at: 0), "test1")
+ XCTAssertEqual(monster.testarrayofstring(at: 1), "test2")
+ XCTAssertEqual(monster.testbool, true)
+
+ let array = monster.nameSegmentArray
+ XCTAssertEqual(String(bytes: array ?? [], encoding: .utf8), "MyMonster")
+
+ if 0 == monster.testarrayofboolsCount {
+ XCTAssertEqual(monster.testarrayofbools.isEmpty, true)
+ } else {
+ XCTAssertEqual(monster.testarrayofbools.isEmpty, false)
+ }
+ }
+
+ func readObjectApi(monster: MyGame_Example_MonsterT) {
+ XCTAssertEqual(monster.hp, 80)
+ XCTAssertEqual(monster.mana, 150)
+ XCTAssertEqual(monster.name, "MyMonster")
+ let pos = monster.pos
+ XCTAssertEqual(pos?.x, 1)
+ XCTAssertEqual(pos?.y, 2)
+ XCTAssertEqual(pos?.z, 3)
+ XCTAssertEqual(pos?.test1, 3)
+ XCTAssertEqual(pos?.test2, .green)
+ let test = pos?.test3
+ XCTAssertEqual(test?.a, 5)
+ XCTAssertEqual(test?.b, 6)
+ let monster2 = monster.test?.value as? MyGame_Example_MonsterT
+ XCTAssertEqual(monster2?.name, "Fred")
+ XCTAssertEqual(monster.mana, 150)
+ monster.mana = 10
+ XCTAssertEqual(monster.mana, 10)
+ monster.mana = 150
+ XCTAssertEqual(monster.mana, 150)
+
+ XCTAssertEqual(monster.inventory.count, 5)
+ var sum: Byte = 0
+ for i in monster.inventory {
+ sum += i
+ }
+ XCTAssertEqual(sum, 10)
+ XCTAssertEqual(monster.test4.count, 2)
+ let test0 = monster.test4[0]
+ let test1 = monster.test4[1]
+ var sum0 = 0
+ var sum1 = 0
+ if let a = test0?.a, let b = test0?.b {
+ sum0 = Int(a) + Int(b)
+ }
+ if let a = test1?.a, let b = test1?.b {
+ sum1 = Int(a) + Int(b)
+ }
+ XCTAssertEqual(sum0 + sum1, 100)
+ XCTAssertEqual(monster.testbool, true)
+ }
+
+ var jsonData: String {
+ """
+ {\"hp\":80,\"inventory\":[0,1,2,3,4],\"test\":{\"name\":\"Fred\"},\"testarrayofstring\":[\"test1\",\"test2\"],\"testarrayoftables\":[{\"name\":\"Barney\"},{\"name\":\"Frodo\"},{\"name\":\"Wilma\"}],\"test4\":[{\"a\":30,\"b\":40},{\"a\":10,\"b\":20}],\"testbool\":true,\"test_type\":\"Monster\",\"pos\":{\"y\":2,\"test3\":{\"a\":5,\"b\":6},\"z\":3,\"x\":1,\"test1\":3,\"test2\":\"Green\"},\"name\":\"MyMonster\"}
+ """
+ }
+}
diff --git a/tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/monster_test_generated.swift b/tests/swift/Wasm.tests/Tests/FlatBuffers.Test.Swift.WasmTests/monster_test_generated.swift
similarity index 94%
rename from tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/monster_test_generated.swift
rename to tests/swift/Wasm.tests/Tests/FlatBuffers.Test.Swift.WasmTests/monster_test_generated.swift
index c8a0502..d37a5bb 100644
--- a/tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/monster_test_generated.swift
+++ b/tests/swift/Wasm.tests/Tests/FlatBuffers.Test.Swift.WasmTests/monster_test_generated.swift
@@ -237,7 +237,7 @@
}
public struct MyGame_Example_Test: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _a: Int16
private var _b: Int8
@@ -291,7 +291,7 @@
public struct MyGame_Example_Test_Mutable: FlatBufferObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -318,7 +318,7 @@
public struct MyGame_Example_Vec3: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _x: Float32
private var _y: Float32
@@ -413,7 +413,7 @@
public struct MyGame_Example_Vec3_Mutable: FlatBufferObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -447,7 +447,7 @@
public struct MyGame_Example_Ability: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _id: UInt32
private var _distance: UInt32
@@ -500,7 +500,7 @@
public struct MyGame_Example_Ability_Mutable: FlatBufferObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -527,7 +527,7 @@
public struct MyGame_Example_StructOfStructs: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _a: MyGame_Example_Ability
private var _b: MyGame_Example_Test
@@ -587,7 +587,7 @@
public struct MyGame_Example_StructOfStructs_Mutable: FlatBufferObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -611,13 +611,80 @@
}
}
+public struct MyGame_Example_StructOfStructsOfStructs: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
+
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
+
+ private var _a: MyGame_Example_StructOfStructs
+
+ public init(_ bb: ByteBuffer, o: Int32) {
+ let _accessor = Struct(bb: bb, position: o)
+ _a = MyGame_Example_StructOfStructs(_accessor.bb, o: _accessor.postion + 0)
+ }
+
+ public init(a: MyGame_Example_StructOfStructs) {
+ _a = a
+ }
+
+ public init() {
+ _a = MyGame_Example_StructOfStructs()
+ }
+
+ public init(_ _t: inout MyGame_Example_StructOfStructsOfStructs_Mutable) {
+ var _va = _t.a
+ _a = _va.unpack()
+ }
+
+ public var a: MyGame_Example_StructOfStructs { _a }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ try verifier.inBuffer(position: position, of: MyGame_Example_StructOfStructsOfStructs.self)
+ }
+}
+
+extension MyGame_Example_StructOfStructsOfStructs: Encodable {
+
+ enum CodingKeys: String, CodingKey {
+ case a = "a"
+ }
+ public func encode(to encoder: Encoder) throws {
+ var container = encoder.container(keyedBy: CodingKeys.self)
+ try container.encodeIfPresent(a, forKey: .a)
+ }
+}
+
+public struct MyGame_Example_StructOfStructsOfStructs_Mutable: FlatBufferObject {
+
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Struct
+
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Struct(bb: bb, position: o) }
+
+ public var a: MyGame_Example_StructOfStructs_Mutable { return MyGame_Example_StructOfStructs_Mutable(_accessor.bb, o: _accessor.postion + 0) }
+
+
+ public mutating func unpack() -> MyGame_Example_StructOfStructsOfStructs {
+ return MyGame_Example_StructOfStructsOfStructs(&self)
+ }
+ public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MyGame_Example_StructOfStructsOfStructs?) -> Offset {
+ guard var obj = obj else { return Offset() }
+ return pack(&builder, obj: &obj)
+ }
+
+ public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MyGame_Example_StructOfStructsOfStructs) -> Offset {
+ return builder.create(struct: obj)
+ }
+}
+
public struct MyGame_InParentNamespace: FlatBufferObject, Verifiable, ObjectAPIPacker {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
- public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: "MONS", addPrefix: prefix) }
+ public static var id: String { "MONS" }
+ public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: MyGame_InParentNamespace.id, addPrefix: prefix) }
public static func getRootAsInParentNamespace(bb: ByteBuffer) -> MyGame_InParentNamespace { return MyGame_InParentNamespace(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
private init(_ t: Table) { _accessor = t }
@@ -666,11 +733,12 @@
}
public struct MyGame_Example2_Monster: FlatBufferObject, Verifiable, ObjectAPIPacker {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
- public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: "MONS", addPrefix: prefix) }
+ public static var id: String { "MONS" }
+ public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: MyGame_Example2_Monster.id, addPrefix: prefix) }
public static func getRootAsMonster(bb: ByteBuffer) -> MyGame_Example2_Monster { return MyGame_Example2_Monster(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
private init(_ t: Table) { _accessor = t }
@@ -719,11 +787,12 @@
}
internal struct MyGame_Example_TestSimpleTableWithEnum: FlatBufferObject, Verifiable, ObjectAPIPacker {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
internal var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
- internal static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: "MONS", addPrefix: prefix) }
+ internal static var id: String { "MONS" }
+ internal static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: MyGame_Example_TestSimpleTableWithEnum.id, addPrefix: prefix) }
internal static func getRootAsTestSimpleTableWithEnum(bb: ByteBuffer) -> MyGame_Example_TestSimpleTableWithEnum { return MyGame_Example_TestSimpleTableWithEnum(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
private init(_ t: Table) { _accessor = t }
@@ -764,7 +833,7 @@
return MyGame_Example_TestSimpleTableWithEnum.endTestSimpleTableWithEnum(&builder, start: __root)
}
- public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ internal static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
var _v = try verifier.visitTable(at: position)
try _v.visit(field: VTOFFSET.color.p, fieldName: "color", required: false, type: MyGame_Example_Color.self)
_v.finish()
@@ -776,7 +845,7 @@
enum CodingKeys: String, CodingKey {
case color = "color"
}
- public func encode(to encoder: Encoder) throws {
+ internal func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
if color != .green {
try container.encodeIfPresent(color, forKey: .color)
@@ -801,11 +870,12 @@
}
public struct MyGame_Example_Stat: FlatBufferObject, Verifiable, ObjectAPIPacker {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
- public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: "MONS", addPrefix: prefix) }
+ public static var id: String { "MONS" }
+ public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: MyGame_Example_Stat.id, addPrefix: prefix) }
public static func getRootAsStat(bb: ByteBuffer) -> MyGame_Example_Stat { return MyGame_Example_Stat(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
private init(_ t: Table) { _accessor = t }
@@ -941,11 +1011,12 @@
}
public struct MyGame_Example_Referrable: FlatBufferObject, Verifiable, ObjectAPIPacker {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
- public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: "MONS", addPrefix: prefix) }
+ public static var id: String { "MONS" }
+ public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: MyGame_Example_Referrable.id, addPrefix: prefix) }
public static func getRootAsReferrable(bb: ByteBuffer) -> MyGame_Example_Referrable { return MyGame_Example_Referrable(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
private init(_ t: Table) { _accessor = t }
@@ -1048,11 +1119,12 @@
/// an example documentation comment: "monster object"
public struct MyGame_Example_Monster: FlatBufferObject, Verifiable, ObjectAPIPacker {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
- public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: "MONS", addPrefix: prefix) }
+ public static var id: String { "MONS" }
+ public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: MyGame_Example_Monster.id, addPrefix: prefix) }
public static func getRootAsMonster(bb: ByteBuffer) -> MyGame_Example_Monster { return MyGame_Example_Monster(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
private init(_ t: Table) { _accessor = t }
@@ -1124,6 +1196,7 @@
@discardableResult public func mutate(hp: Int16) -> Bool {let o = _accessor.offset(VTOFFSET.hp.v); return _accessor.mutate(hp, index: o) }
public var name: String! { let o = _accessor.offset(VTOFFSET.name.v); return _accessor.string(at: o) }
public var nameSegmentArray: [UInt8]! { return _accessor.getVector(at: VTOFFSET.name.v) }
+ public var hasInventory: Bool { let o = _accessor.offset(VTOFFSET.inventory.v); return o == 0 ? false : true }
public var inventoryCount: Int32 { let o = _accessor.offset(VTOFFSET.inventory.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func inventory(at index: Int32) -> UInt8 { let o = _accessor.offset(VTOFFSET.inventory.v); return o == 0 ? 0 : _accessor.directRead(of: UInt8.self, offset: _accessor.vector(at: o) + index * 1) }
public var inventory: [UInt8] { return _accessor.getVector(at: VTOFFSET.inventory.v) ?? [] }
@@ -1132,17 +1205,21 @@
@discardableResult public func mutate(color: MyGame_Example_Color) -> Bool {let o = _accessor.offset(VTOFFSET.color.v); return _accessor.mutate(color.rawValue, index: o) }
public var testType: MyGame_Example_Any_ { let o = _accessor.offset(VTOFFSET.testType.v); return o == 0 ? .none_ : MyGame_Example_Any_(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) ?? .none_ }
public func test<T: FlatbuffersInitializable>(type: T.Type) -> T? { let o = _accessor.offset(VTOFFSET.test.v); return o == 0 ? nil : _accessor.union(o) }
+ public var hasTest4: Bool { let o = _accessor.offset(VTOFFSET.test4.v); return o == 0 ? false : true }
public var test4Count: Int32 { let o = _accessor.offset(VTOFFSET.test4.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func test4(at index: Int32) -> MyGame_Example_Test? { let o = _accessor.offset(VTOFFSET.test4.v); return o == 0 ? nil : _accessor.directRead(of: MyGame_Example_Test.self, offset: _accessor.vector(at: o) + index * 4) }
public func mutableTest4(at index: Int32) -> MyGame_Example_Test_Mutable? { let o = _accessor.offset(VTOFFSET.test4.v); return o == 0 ? nil : MyGame_Example_Test_Mutable(_accessor.bb, o: _accessor.vector(at: o) + index * 4) }
+ public var hasTestarrayofstring: Bool { let o = _accessor.offset(VTOFFSET.testarrayofstring.v); return o == 0 ? false : true }
public var testarrayofstringCount: Int32 { let o = _accessor.offset(VTOFFSET.testarrayofstring.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func testarrayofstring(at index: Int32) -> String? { let o = _accessor.offset(VTOFFSET.testarrayofstring.v); return o == 0 ? nil : _accessor.directString(at: _accessor.vector(at: o) + index * 4) }
/// an example documentation comment: this will end up in the generated code
/// multiline too
+ public var hasTestarrayoftables: Bool { let o = _accessor.offset(VTOFFSET.testarrayoftables.v); return o == 0 ? false : true }
public var testarrayoftablesCount: Int32 { let o = _accessor.offset(VTOFFSET.testarrayoftables.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func testarrayoftables(at index: Int32) -> MyGame_Example_Monster? { let o = _accessor.offset(VTOFFSET.testarrayoftables.v); return o == 0 ? nil : MyGame_Example_Monster(_accessor.bb, o: _accessor.indirect(_accessor.vector(at: o) + index * 4)) }
public func testarrayoftablesBy(key: String) -> MyGame_Example_Monster? { let o = _accessor.offset(VTOFFSET.testarrayoftables.v); return o == 0 ? nil : MyGame_Example_Monster.lookupByKey(vector: _accessor.vector(at: o), key: key, fbb: _accessor.bb) }
public var enemy: MyGame_Example_Monster? { let o = _accessor.offset(VTOFFSET.enemy.v); return o == 0 ? nil : MyGame_Example_Monster(_accessor.bb, o: _accessor.indirect(o + _accessor.postion)) }
+ public var hasTestnestedflatbuffer: Bool { let o = _accessor.offset(VTOFFSET.testnestedflatbuffer.v); return o == 0 ? false : true }
public var testnestedflatbufferCount: Int32 { let o = _accessor.offset(VTOFFSET.testnestedflatbuffer.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func testnestedflatbuffer(at index: Int32) -> UInt8 { let o = _accessor.offset(VTOFFSET.testnestedflatbuffer.v); return o == 0 ? 0 : _accessor.directRead(of: UInt8.self, offset: _accessor.vector(at: o) + index * 1) }
public var testnestedflatbuffer: [UInt8] { return _accessor.getVector(at: VTOFFSET.testnestedflatbuffer.v) ?? [] }
@@ -1166,6 +1243,7 @@
@discardableResult public func mutate(testhashs64Fnv1a: Int64) -> Bool {let o = _accessor.offset(VTOFFSET.testhashs64Fnv1a.v); return _accessor.mutate(testhashs64Fnv1a, index: o) }
public var testhashu64Fnv1a: UInt64 { let o = _accessor.offset(VTOFFSET.testhashu64Fnv1a.v); return o == 0 ? 0 : _accessor.readBuffer(of: UInt64.self, at: o) }
@discardableResult public func mutate(testhashu64Fnv1a: UInt64) -> Bool {let o = _accessor.offset(VTOFFSET.testhashu64Fnv1a.v); return _accessor.mutate(testhashu64Fnv1a, index: o) }
+ public var hasTestarrayofbools: Bool { let o = _accessor.offset(VTOFFSET.testarrayofbools.v); return o == 0 ? false : true }
public var testarrayofboolsCount: Int32 { let o = _accessor.offset(VTOFFSET.testarrayofbools.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func testarrayofbools(at index: Int32) -> Bool { let o = _accessor.offset(VTOFFSET.testarrayofbools.v); return o == 0 ? true : _accessor.directRead(of: Bool.self, offset: _accessor.vector(at: o) + index * 1) }
public var testarrayofbools: [Bool] { return _accessor.getVector(at: VTOFFSET.testarrayofbools.v) ?? [] }
@@ -1176,47 +1254,58 @@
@discardableResult public func mutate(testf2: Float32) -> Bool {let o = _accessor.offset(VTOFFSET.testf2.v); return _accessor.mutate(testf2, index: o) }
public var testf3: Float32 { let o = _accessor.offset(VTOFFSET.testf3.v); return o == 0 ? 0.0 : _accessor.readBuffer(of: Float32.self, at: o) }
@discardableResult public func mutate(testf3: Float32) -> Bool {let o = _accessor.offset(VTOFFSET.testf3.v); return _accessor.mutate(testf3, index: o) }
+ public var hasTestarrayofstring2: Bool { let o = _accessor.offset(VTOFFSET.testarrayofstring2.v); return o == 0 ? false : true }
public var testarrayofstring2Count: Int32 { let o = _accessor.offset(VTOFFSET.testarrayofstring2.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func testarrayofstring2(at index: Int32) -> String? { let o = _accessor.offset(VTOFFSET.testarrayofstring2.v); return o == 0 ? nil : _accessor.directString(at: _accessor.vector(at: o) + index * 4) }
+ public var hasTestarrayofsortedstruct: Bool { let o = _accessor.offset(VTOFFSET.testarrayofsortedstruct.v); return o == 0 ? false : true }
public var testarrayofsortedstructCount: Int32 { let o = _accessor.offset(VTOFFSET.testarrayofsortedstruct.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func testarrayofsortedstruct(at index: Int32) -> MyGame_Example_Ability? { let o = _accessor.offset(VTOFFSET.testarrayofsortedstruct.v); return o == 0 ? nil : _accessor.directRead(of: MyGame_Example_Ability.self, offset: _accessor.vector(at: o) + index * 8) }
public func mutableTestarrayofsortedstruct(at index: Int32) -> MyGame_Example_Ability_Mutable? { let o = _accessor.offset(VTOFFSET.testarrayofsortedstruct.v); return o == 0 ? nil : MyGame_Example_Ability_Mutable(_accessor.bb, o: _accessor.vector(at: o) + index * 8) }
+ public var hasFlex: Bool { let o = _accessor.offset(VTOFFSET.flex.v); return o == 0 ? false : true }
public var flexCount: Int32 { let o = _accessor.offset(VTOFFSET.flex.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func flex(at index: Int32) -> UInt8 { let o = _accessor.offset(VTOFFSET.flex.v); return o == 0 ? 0 : _accessor.directRead(of: UInt8.self, offset: _accessor.vector(at: o) + index * 1) }
public var flex: [UInt8] { return _accessor.getVector(at: VTOFFSET.flex.v) ?? [] }
public func mutate(flex: UInt8, at index: Int32) -> Bool { let o = _accessor.offset(VTOFFSET.flex.v); return _accessor.directMutate(flex, index: _accessor.vector(at: o) + index * 1) }
+ public var hasTest5: Bool { let o = _accessor.offset(VTOFFSET.test5.v); return o == 0 ? false : true }
public var test5Count: Int32 { let o = _accessor.offset(VTOFFSET.test5.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func test5(at index: Int32) -> MyGame_Example_Test? { let o = _accessor.offset(VTOFFSET.test5.v); return o == 0 ? nil : _accessor.directRead(of: MyGame_Example_Test.self, offset: _accessor.vector(at: o) + index * 4) }
public func mutableTest5(at index: Int32) -> MyGame_Example_Test_Mutable? { let o = _accessor.offset(VTOFFSET.test5.v); return o == 0 ? nil : MyGame_Example_Test_Mutable(_accessor.bb, o: _accessor.vector(at: o) + index * 4) }
+ public var hasVectorOfLongs: Bool { let o = _accessor.offset(VTOFFSET.vectorOfLongs.v); return o == 0 ? false : true }
public var vectorOfLongsCount: Int32 { let o = _accessor.offset(VTOFFSET.vectorOfLongs.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func vectorOfLongs(at index: Int32) -> Int64 { let o = _accessor.offset(VTOFFSET.vectorOfLongs.v); return o == 0 ? 0 : _accessor.directRead(of: Int64.self, offset: _accessor.vector(at: o) + index * 8) }
public var vectorOfLongs: [Int64] { return _accessor.getVector(at: VTOFFSET.vectorOfLongs.v) ?? [] }
public func mutate(vectorOfLongs: Int64, at index: Int32) -> Bool { let o = _accessor.offset(VTOFFSET.vectorOfLongs.v); return _accessor.directMutate(vectorOfLongs, index: _accessor.vector(at: o) + index * 8) }
+ public var hasVectorOfDoubles: Bool { let o = _accessor.offset(VTOFFSET.vectorOfDoubles.v); return o == 0 ? false : true }
public var vectorOfDoublesCount: Int32 { let o = _accessor.offset(VTOFFSET.vectorOfDoubles.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func vectorOfDoubles(at index: Int32) -> Double { let o = _accessor.offset(VTOFFSET.vectorOfDoubles.v); return o == 0 ? 0 : _accessor.directRead(of: Double.self, offset: _accessor.vector(at: o) + index * 8) }
public var vectorOfDoubles: [Double] { return _accessor.getVector(at: VTOFFSET.vectorOfDoubles.v) ?? [] }
public func mutate(vectorOfDoubles: Double, at index: Int32) -> Bool { let o = _accessor.offset(VTOFFSET.vectorOfDoubles.v); return _accessor.directMutate(vectorOfDoubles, index: _accessor.vector(at: o) + index * 8) }
public var parentNamespaceTest: MyGame_InParentNamespace? { let o = _accessor.offset(VTOFFSET.parentNamespaceTest.v); return o == 0 ? nil : MyGame_InParentNamespace(_accessor.bb, o: _accessor.indirect(o + _accessor.postion)) }
+ public var hasVectorOfReferrables: Bool { let o = _accessor.offset(VTOFFSET.vectorOfReferrables.v); return o == 0 ? false : true }
public var vectorOfReferrablesCount: Int32 { let o = _accessor.offset(VTOFFSET.vectorOfReferrables.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func vectorOfReferrables(at index: Int32) -> MyGame_Example_Referrable? { let o = _accessor.offset(VTOFFSET.vectorOfReferrables.v); return o == 0 ? nil : MyGame_Example_Referrable(_accessor.bb, o: _accessor.indirect(_accessor.vector(at: o) + index * 4)) }
public func vectorOfReferrablesBy(key: UInt64) -> MyGame_Example_Referrable? { let o = _accessor.offset(VTOFFSET.vectorOfReferrables.v); return o == 0 ? nil : MyGame_Example_Referrable.lookupByKey(vector: _accessor.vector(at: o), key: key, fbb: _accessor.bb) }
public var singleWeakReference: UInt64 { let o = _accessor.offset(VTOFFSET.singleWeakReference.v); return o == 0 ? 0 : _accessor.readBuffer(of: UInt64.self, at: o) }
@discardableResult public func mutate(singleWeakReference: UInt64) -> Bool {let o = _accessor.offset(VTOFFSET.singleWeakReference.v); return _accessor.mutate(singleWeakReference, index: o) }
+ public var hasVectorOfWeakReferences: Bool { let o = _accessor.offset(VTOFFSET.vectorOfWeakReferences.v); return o == 0 ? false : true }
public var vectorOfWeakReferencesCount: Int32 { let o = _accessor.offset(VTOFFSET.vectorOfWeakReferences.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func vectorOfWeakReferences(at index: Int32) -> UInt64 { let o = _accessor.offset(VTOFFSET.vectorOfWeakReferences.v); return o == 0 ? 0 : _accessor.directRead(of: UInt64.self, offset: _accessor.vector(at: o) + index * 8) }
public var vectorOfWeakReferences: [UInt64] { return _accessor.getVector(at: VTOFFSET.vectorOfWeakReferences.v) ?? [] }
public func mutate(vectorOfWeakReferences: UInt64, at index: Int32) -> Bool { let o = _accessor.offset(VTOFFSET.vectorOfWeakReferences.v); return _accessor.directMutate(vectorOfWeakReferences, index: _accessor.vector(at: o) + index * 8) }
+ public var hasVectorOfStrongReferrables: Bool { let o = _accessor.offset(VTOFFSET.vectorOfStrongReferrables.v); return o == 0 ? false : true }
public var vectorOfStrongReferrablesCount: Int32 { let o = _accessor.offset(VTOFFSET.vectorOfStrongReferrables.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func vectorOfStrongReferrables(at index: Int32) -> MyGame_Example_Referrable? { let o = _accessor.offset(VTOFFSET.vectorOfStrongReferrables.v); return o == 0 ? nil : MyGame_Example_Referrable(_accessor.bb, o: _accessor.indirect(_accessor.vector(at: o) + index * 4)) }
public func vectorOfStrongReferrablesBy(key: UInt64) -> MyGame_Example_Referrable? { let o = _accessor.offset(VTOFFSET.vectorOfStrongReferrables.v); return o == 0 ? nil : MyGame_Example_Referrable.lookupByKey(vector: _accessor.vector(at: o), key: key, fbb: _accessor.bb) }
public var coOwningReference: UInt64 { let o = _accessor.offset(VTOFFSET.coOwningReference.v); return o == 0 ? 0 : _accessor.readBuffer(of: UInt64.self, at: o) }
@discardableResult public func mutate(coOwningReference: UInt64) -> Bool {let o = _accessor.offset(VTOFFSET.coOwningReference.v); return _accessor.mutate(coOwningReference, index: o) }
+ public var hasVectorOfCoOwningReferences: Bool { let o = _accessor.offset(VTOFFSET.vectorOfCoOwningReferences.v); return o == 0 ? false : true }
public var vectorOfCoOwningReferencesCount: Int32 { let o = _accessor.offset(VTOFFSET.vectorOfCoOwningReferences.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func vectorOfCoOwningReferences(at index: Int32) -> UInt64 { let o = _accessor.offset(VTOFFSET.vectorOfCoOwningReferences.v); return o == 0 ? 0 : _accessor.directRead(of: UInt64.self, offset: _accessor.vector(at: o) + index * 8) }
public var vectorOfCoOwningReferences: [UInt64] { return _accessor.getVector(at: VTOFFSET.vectorOfCoOwningReferences.v) ?? [] }
public func mutate(vectorOfCoOwningReferences: UInt64, at index: Int32) -> Bool { let o = _accessor.offset(VTOFFSET.vectorOfCoOwningReferences.v); return _accessor.directMutate(vectorOfCoOwningReferences, index: _accessor.vector(at: o) + index * 8) }
public var nonOwningReference: UInt64 { let o = _accessor.offset(VTOFFSET.nonOwningReference.v); return o == 0 ? 0 : _accessor.readBuffer(of: UInt64.self, at: o) }
@discardableResult public func mutate(nonOwningReference: UInt64) -> Bool {let o = _accessor.offset(VTOFFSET.nonOwningReference.v); return _accessor.mutate(nonOwningReference, index: o) }
+ public var hasVectorOfNonOwningReferences: Bool { let o = _accessor.offset(VTOFFSET.vectorOfNonOwningReferences.v); return o == 0 ? false : true }
public var vectorOfNonOwningReferencesCount: Int32 { let o = _accessor.offset(VTOFFSET.vectorOfNonOwningReferences.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func vectorOfNonOwningReferences(at index: Int32) -> UInt64 { let o = _accessor.offset(VTOFFSET.vectorOfNonOwningReferences.v); return o == 0 ? 0 : _accessor.directRead(of: UInt64.self, offset: _accessor.vector(at: o) + index * 8) }
public var vectorOfNonOwningReferences: [UInt64] { return _accessor.getVector(at: VTOFFSET.vectorOfNonOwningReferences.v) ?? [] }
@@ -1225,14 +1314,17 @@
public func anyUnique<T: FlatbuffersInitializable>(type: T.Type) -> T? { let o = _accessor.offset(VTOFFSET.anyUnique.v); return o == 0 ? nil : _accessor.union(o) }
public var anyAmbiguousType: MyGame_Example_AnyAmbiguousAliases { let o = _accessor.offset(VTOFFSET.anyAmbiguousType.v); return o == 0 ? .none_ : MyGame_Example_AnyAmbiguousAliases(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) ?? .none_ }
public func anyAmbiguous<T: FlatbuffersInitializable>(type: T.Type) -> T? { let o = _accessor.offset(VTOFFSET.anyAmbiguous.v); return o == 0 ? nil : _accessor.union(o) }
+ public var hasVectorOfEnums: Bool { let o = _accessor.offset(VTOFFSET.vectorOfEnums.v); return o == 0 ? false : true }
public var vectorOfEnumsCount: Int32 { let o = _accessor.offset(VTOFFSET.vectorOfEnums.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func vectorOfEnums(at index: Int32) -> MyGame_Example_Color? { let o = _accessor.offset(VTOFFSET.vectorOfEnums.v); return o == 0 ? MyGame_Example_Color.red : MyGame_Example_Color(rawValue: _accessor.directRead(of: UInt8.self, offset: _accessor.vector(at: o) + index * 1)) }
public var signedEnum: MyGame_Example_Race { let o = _accessor.offset(VTOFFSET.signedEnum.v); return o == 0 ? .none_ : MyGame_Example_Race(rawValue: _accessor.readBuffer(of: Int8.self, at: o)) ?? .none_ }
@discardableResult public func mutate(signedEnum: MyGame_Example_Race) -> Bool {let o = _accessor.offset(VTOFFSET.signedEnum.v); return _accessor.mutate(signedEnum.rawValue, index: o) }
+ public var hasTestrequirednestedflatbuffer: Bool { let o = _accessor.offset(VTOFFSET.testrequirednestedflatbuffer.v); return o == 0 ? false : true }
public var testrequirednestedflatbufferCount: Int32 { let o = _accessor.offset(VTOFFSET.testrequirednestedflatbuffer.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func testrequirednestedflatbuffer(at index: Int32) -> UInt8 { let o = _accessor.offset(VTOFFSET.testrequirednestedflatbuffer.v); return o == 0 ? 0 : _accessor.directRead(of: UInt8.self, offset: _accessor.vector(at: o) + index * 1) }
public var testrequirednestedflatbuffer: [UInt8] { return _accessor.getVector(at: VTOFFSET.testrequirednestedflatbuffer.v) ?? [] }
public func mutate(testrequirednestedflatbuffer: UInt8, at index: Int32) -> Bool { let o = _accessor.offset(VTOFFSET.testrequirednestedflatbuffer.v); return _accessor.directMutate(testrequirednestedflatbuffer, index: _accessor.vector(at: o) + index * 1) }
+ public var hasScalarKeySortedTables: Bool { let o = _accessor.offset(VTOFFSET.scalarKeySortedTables.v); return o == 0 ? false : true }
public var scalarKeySortedTablesCount: Int32 { let o = _accessor.offset(VTOFFSET.scalarKeySortedTables.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func scalarKeySortedTables(at index: Int32) -> MyGame_Example_Stat? { let o = _accessor.offset(VTOFFSET.scalarKeySortedTables.v); return o == 0 ? nil : MyGame_Example_Stat(_accessor.bb, o: _accessor.indirect(_accessor.vector(at: o) + index * 4)) }
public func scalarKeySortedTablesBy(key: UInt16) -> MyGame_Example_Stat? { let o = _accessor.offset(VTOFFSET.scalarKeySortedTables.v); return o == 0 ? nil : MyGame_Example_Stat.lookupByKey(vector: _accessor.vector(at: o), key: key, fbb: _accessor.bb) }
@@ -1312,7 +1404,7 @@
pos: MyGame_Example_Vec3? = nil,
mana: Int16 = 150,
hp: Int16 = 100,
- nameOffset name: Offset = Offset(),
+ nameOffset name: Offset,
inventoryVectorOffset inventory: Offset = Offset(),
color: MyGame_Example_Color = .blue,
testType: MyGame_Example_Any_ = .none_,
@@ -2205,11 +2297,12 @@
}
public struct MyGame_Example_TypeAliases: FlatBufferObject, Verifiable, ObjectAPIPacker {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
- public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: "MONS", addPrefix: prefix) }
+ public static var id: String { "MONS" }
+ public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: MyGame_Example_TypeAliases.id, addPrefix: prefix) }
public static func getRootAsTypeAliases(bb: ByteBuffer) -> MyGame_Example_TypeAliases { return MyGame_Example_TypeAliases(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
private init(_ t: Table) { _accessor = t }
@@ -2252,10 +2345,12 @@
@discardableResult public func mutate(f32: Float32) -> Bool {let o = _accessor.offset(VTOFFSET.f32.v); return _accessor.mutate(f32, index: o) }
public var f64: Double { let o = _accessor.offset(VTOFFSET.f64.v); return o == 0 ? 0.0 : _accessor.readBuffer(of: Double.self, at: o) }
@discardableResult public func mutate(f64: Double) -> Bool {let o = _accessor.offset(VTOFFSET.f64.v); return _accessor.mutate(f64, index: o) }
+ public var hasV8: Bool { let o = _accessor.offset(VTOFFSET.v8.v); return o == 0 ? false : true }
public var v8Count: Int32 { let o = _accessor.offset(VTOFFSET.v8.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func v8(at index: Int32) -> Int8 { let o = _accessor.offset(VTOFFSET.v8.v); return o == 0 ? 0 : _accessor.directRead(of: Int8.self, offset: _accessor.vector(at: o) + index * 1) }
public var v8: [Int8] { return _accessor.getVector(at: VTOFFSET.v8.v) ?? [] }
public func mutate(v8: Int8, at index: Int32) -> Bool { let o = _accessor.offset(VTOFFSET.v8.v); return _accessor.directMutate(v8, index: _accessor.vector(at: o) + index * 1) }
+ public var hasVf64: Bool { let o = _accessor.offset(VTOFFSET.vf64.v); return o == 0 ? false : true }
public var vf64Count: Int32 { let o = _accessor.offset(VTOFFSET.vf64.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func vf64(at index: Int32) -> Double { let o = _accessor.offset(VTOFFSET.vf64.v); return o == 0 ? 0 : _accessor.directRead(of: Double.self, offset: _accessor.vector(at: o) + index * 8) }
public var vf64: [Double] { return _accessor.getVector(at: VTOFFSET.vf64.v) ?? [] }
diff --git a/tests/FlatBuffers.Benchmarks.swift/Package.swift b/tests/swift/benchmarks/Package.swift
similarity index 73%
copy from tests/FlatBuffers.Benchmarks.swift/Package.swift
copy to tests/swift/benchmarks/Package.swift
index 2026247..d711493 100644
--- a/tests/FlatBuffers.Benchmarks.swift/Package.swift
+++ b/tests/swift/benchmarks/Package.swift
@@ -18,15 +18,17 @@
import PackageDescription
let package = Package(
- name: "FlatBuffers.Benchmarks.swift",
+ name: "benchmarks",
platforms: [
.macOS(.v10_14),
],
dependencies: [
- .package(path: "../../swift"),
+ .package(path: "../../../swift"),
+ .package(url: "https://github.com/google/swift-benchmark", from: "0.1.0"),
],
targets: [
.target(
- name: "FlatBuffers.Benchmarks.swift",
- dependencies: ["FlatBuffers"]),
+ name: "benchmarks",
+ dependencies: ["FlatBuffers",
+ .product(name: "Benchmark", package: "swift-benchmark")]),
])
diff --git a/tests/swift/benchmarks/Sources/benchmarks/main.swift b/tests/swift/benchmarks/Sources/benchmarks/main.swift
new file mode 100644
index 0000000..a25a646
--- /dev/null
+++ b/tests/swift/benchmarks/Sources/benchmarks/main.swift
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2021 Google Inc. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import Benchmark
+import CoreFoundation
+import FlatBuffers
+
+benchmark("10Strings") {
+ var fb = FlatBufferBuilder(initialSize: 1<<20)
+ for _ in 0..<1_000_000 {
+ _ = fb.create(string: "foobarbaz")
+ }
+}
+
+benchmark("100Strings") {
+ var fb = FlatBufferBuilder(initialSize: 1<<20)
+ for _ in 0..<1_000_000 {
+ _ = fb.create(string: str)
+ }
+}
+
+benchmark("FlatBufferBuilder.add") {
+ var fb = FlatBufferBuilder(initialSize: 1024 * 1024 * 32)
+ for _ in 0..<1_000_000 {
+ let off = fb.create(string: "T")
+ let s = fb.startTable(with: 4)
+ fb.add(element: 3.2, def: 0, at: 2)
+ fb.add(element: 4.2, def: 0, at: 4)
+ fb.add(element: 5.2, def: 0, at: 6)
+ fb.add(offset: off, at: 8)
+ _ = fb.endTable(at: s)
+ }
+}
+
+benchmark("structs") {
+ let structCount = 1_000_000
+
+ let rawSize = ((16 * 5) * structCount) / 1024
+
+ var fb = FlatBufferBuilder(initialSize: Int32(rawSize * 1600))
+
+ var offsets: [Offset] = []
+ for _ in 0..<structCount {
+ fb.startVector(
+ 5 * MemoryLayout<AA>.size,
+ elementSize: MemoryLayout<AA>.alignment)
+ for _ in 0..<5 {
+ _ = fb.create(struct: AA(a: 2.4, b: 2.4))
+ }
+ let vector = fb.endVector(len: 5)
+ let start = fb.startTable(with: 1)
+ fb.add(offset: vector, at: 4)
+ offsets.append(Offset(offset: fb.endTable(at: start)))
+ }
+ let vector = fb.createVector(ofOffsets: offsets)
+ let start = fb.startTable(with: 1)
+ fb.add(offset: vector, at: 4)
+ let root = Offset(offset: fb.endTable(at: start))
+ fb.finish(offset: root)
+}
+
+let str = (0...99).map { _ -> String in "x" }.joined()
+
+@usableFromInline
+struct AA: NativeStruct {
+ public init(a: Double, b: Double) {
+ self.a = a
+ self.b = b
+ }
+ var a: Double
+ var b: Double
+}
+
+Benchmark.main()
diff --git a/tests/swift/tests/CodeGenerationTests/test_import.fbs b/tests/swift/tests/CodeGenerationTests/test_import.fbs
new file mode 100644
index 0000000..0a43956
--- /dev/null
+++ b/tests/swift/tests/CodeGenerationTests/test_import.fbs
@@ -0,0 +1,3 @@
+table Message {
+ internal_message: string;
+}
\ No newline at end of file
diff --git a/tests/swift/tests/CodeGenerationTests/test_import_generated.swift b/tests/swift/tests/CodeGenerationTests/test_import_generated.swift
new file mode 100644
index 0000000..4e160ca
--- /dev/null
+++ b/tests/swift/tests/CodeGenerationTests/test_import_generated.swift
@@ -0,0 +1,91 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+// swiftlint:disable all
+// swiftformat:disable all
+
+@_implementationOnly import FlatBuffers
+
+internal struct Message: FlatBufferObject, Verifiable, ObjectAPIPacker {
+
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
+ internal var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ internal static func getRootAsMessage(bb: ByteBuffer) -> Message { return Message(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ internal init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case internalMessage = 4
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ internal var internalMessage: String? { let o = _accessor.offset(VTOFFSET.internalMessage.v); return o == 0 ? nil : _accessor.string(at: o) }
+ internal var internalMessageSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.internalMessage.v) }
+ internal static func startMessage(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
+ internal static func add(internalMessage: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: internalMessage, at: VTOFFSET.internalMessage.p) }
+ internal static func endMessage(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+ internal static func createMessage(
+ _ fbb: inout FlatBufferBuilder,
+ internalMessageOffset internalMessage: Offset = Offset()
+ ) -> Offset {
+ let __start = Message.startMessage(&fbb)
+ Message.add(internalMessage: internalMessage, &fbb)
+ return Message.endMessage(&fbb, start: __start)
+ }
+
+
+ internal mutating func unpack() -> MessageT {
+ return MessageT(&self)
+ }
+ internal static func pack(_ builder: inout FlatBufferBuilder, obj: inout MessageT?) -> Offset {
+ guard var obj = obj else { return Offset() }
+ return pack(&builder, obj: &obj)
+ }
+
+ internal static func pack(_ builder: inout FlatBufferBuilder, obj: inout MessageT) -> Offset {
+ let __internalMessage: Offset
+ if let s = obj.internalMessage {
+ __internalMessage = builder.create(string: s)
+ } else {
+ __internalMessage = Offset()
+ }
+
+ let __root = Message.startMessage(&builder)
+ Message.add(internalMessage: __internalMessage, &builder)
+ return Message.endMessage(&builder, start: __root)
+ }
+
+ internal static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.internalMessage.p, fieldName: "internalMessage", required: false, type: ForwardOffset<String>.self)
+ _v.finish()
+ }
+}
+
+extension Message: Encodable {
+
+ enum CodingKeys: String, CodingKey {
+ case internalMessage = "internal_message"
+ }
+ internal func encode(to encoder: Encoder) throws {
+ var container = encoder.container(keyedBy: CodingKeys.self)
+ try container.encodeIfPresent(internalMessage, forKey: .internalMessage)
+ }
+}
+
+internal class MessageT: NativeObject {
+
+ internal var internalMessage: String?
+
+ internal init(_ _t: inout Message) {
+ internalMessage = _t.internalMessage
+ }
+
+ internal init() {
+ }
+
+ internal func serialize() -> ByteBuffer { return serialize(type: Message.self) }
+
+}
diff --git a/tests/swift/tests/CodeGenerationTests/test_no_include.fbs b/tests/swift/tests/CodeGenerationTests/test_no_include.fbs
new file mode 100644
index 0000000..2f95468
--- /dev/null
+++ b/tests/swift/tests/CodeGenerationTests/test_no_include.fbs
@@ -0,0 +1,13 @@
+struct BytesCount {
+ x: int64;
+}
+
+table InternalMessage {
+ str: string;
+}
+
+table Message {
+ id: int64;
+ position: BytesCount (required);
+ pointer: InternalMessage (required);
+}
\ No newline at end of file
diff --git a/tests/swift/tests/CodeGenerationTests/test_no_include_generated.swift b/tests/swift/tests/CodeGenerationTests/test_no_include_generated.swift
new file mode 100644
index 0000000..3348b05
--- /dev/null
+++ b/tests/swift/tests/CodeGenerationTests/test_no_include_generated.swift
@@ -0,0 +1,265 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+// swiftlint:disable all
+// swiftformat:disable all
+
+public struct BytesCount: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
+
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
+
+ private var _x: Int64
+
+ public init(_ bb: ByteBuffer, o: Int32) {
+ let _accessor = Struct(bb: bb, position: o)
+ _x = _accessor.readBuffer(of: Int64.self, at: 0)
+ }
+
+ public init(x: Int64) {
+ _x = x
+ }
+
+ public init() {
+ _x = 0
+ }
+
+ public init(_ _t: inout BytesCount_Mutable) {
+ _x = _t.x
+ }
+
+ public var x: Int64 { _x }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ try verifier.inBuffer(position: position, of: BytesCount.self)
+ }
+}
+
+extension BytesCount: Encodable {
+
+ enum CodingKeys: String, CodingKey {
+ case x = "x"
+ }
+ public func encode(to encoder: Encoder) throws {
+ var container = encoder.container(keyedBy: CodingKeys.self)
+ if x != 0 {
+ try container.encodeIfPresent(x, forKey: .x)
+ }
+ }
+}
+
+public struct BytesCount_Mutable: FlatBufferObject {
+
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Struct
+
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Struct(bb: bb, position: o) }
+
+ public var x: Int64 { return _accessor.readBuffer(of: Int64.self, at: 0) }
+ @discardableResult public func mutate(x: Int64) -> Bool { return _accessor.mutate(x, index: 0) }
+
+
+ public mutating func unpack() -> BytesCount {
+ return BytesCount(&self)
+ }
+ public static func pack(_ builder: inout FlatBufferBuilder, obj: inout BytesCount?) -> Offset {
+ guard var obj = obj else { return Offset() }
+ return pack(&builder, obj: &obj)
+ }
+
+ public static func pack(_ builder: inout FlatBufferBuilder, obj: inout BytesCount) -> Offset {
+ return builder.create(struct: obj)
+ }
+}
+
+public struct InternalMessage: FlatBufferObject, Verifiable, ObjectAPIPacker {
+
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsInternalMessage(bb: ByteBuffer) -> InternalMessage { return InternalMessage(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case str = 4
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ public var str: String? { let o = _accessor.offset(VTOFFSET.str.v); return o == 0 ? nil : _accessor.string(at: o) }
+ public var strSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.str.v) }
+ public static func startInternalMessage(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
+ public static func add(str: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: str, at: VTOFFSET.str.p) }
+ public static func endInternalMessage(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+ public static func createInternalMessage(
+ _ fbb: inout FlatBufferBuilder,
+ strOffset str: Offset = Offset()
+ ) -> Offset {
+ let __start = InternalMessage.startInternalMessage(&fbb)
+ InternalMessage.add(str: str, &fbb)
+ return InternalMessage.endInternalMessage(&fbb, start: __start)
+ }
+
+
+ public mutating func unpack() -> InternalMessageT {
+ return InternalMessageT(&self)
+ }
+ public static func pack(_ builder: inout FlatBufferBuilder, obj: inout InternalMessageT?) -> Offset {
+ guard var obj = obj else { return Offset() }
+ return pack(&builder, obj: &obj)
+ }
+
+ public static func pack(_ builder: inout FlatBufferBuilder, obj: inout InternalMessageT) -> Offset {
+ let __str: Offset
+ if let s = obj.str {
+ __str = builder.create(string: s)
+ } else {
+ __str = Offset()
+ }
+
+ let __root = InternalMessage.startInternalMessage(&builder)
+ InternalMessage.add(str: __str, &builder)
+ return InternalMessage.endInternalMessage(&builder, start: __root)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.str.p, fieldName: "str", required: false, type: ForwardOffset<String>.self)
+ _v.finish()
+ }
+}
+
+extension InternalMessage: Encodable {
+
+ enum CodingKeys: String, CodingKey {
+ case str = "str"
+ }
+ public func encode(to encoder: Encoder) throws {
+ var container = encoder.container(keyedBy: CodingKeys.self)
+ try container.encodeIfPresent(str, forKey: .str)
+ }
+}
+
+public class InternalMessageT: NativeObject {
+
+ public var str: String?
+
+ public init(_ _t: inout InternalMessage) {
+ str = _t.str
+ }
+
+ public init() {
+ }
+
+ public func serialize() -> ByteBuffer { return serialize(type: InternalMessage.self) }
+
+}
+public struct Message: FlatBufferObject, Verifiable, ObjectAPIPacker {
+
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsMessage(bb: ByteBuffer) -> Message { return Message(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case id = 4
+ case position = 6
+ case pointer = 8
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ public var id: Int64 { let o = _accessor.offset(VTOFFSET.id.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int64.self, at: o) }
+ @discardableResult public func mutate(id: Int64) -> Bool {let o = _accessor.offset(VTOFFSET.id.v); return _accessor.mutate(id, index: o) }
+ public var position: BytesCount! { let o = _accessor.offset(VTOFFSET.position.v); return _accessor.readBuffer(of: BytesCount.self, at: o) }
+ public var mutablePosition: BytesCount_Mutable! { let o = _accessor.offset(VTOFFSET.position.v); return BytesCount_Mutable(_accessor.bb, o: o + _accessor.postion) }
+ public var pointer: InternalMessage! { let o = _accessor.offset(VTOFFSET.pointer.v); return InternalMessage(_accessor.bb, o: _accessor.indirect(o + _accessor.postion)) }
+ public static func startMessage(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 3) }
+ public static func add(id: Int64, _ fbb: inout FlatBufferBuilder) { fbb.add(element: id, def: 0, at: VTOFFSET.id.p) }
+ public static func add(position: BytesCount?, _ fbb: inout FlatBufferBuilder) { guard let position = position else { return }; fbb.create(struct: position, position: VTOFFSET.position.p) }
+ public static func add(pointer: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: pointer, at: VTOFFSET.pointer.p) }
+ public static func endMessage(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); fbb.require(table: end, fields: [6, 8]); return end }
+ public static func createMessage(
+ _ fbb: inout FlatBufferBuilder,
+ id: Int64 = 0,
+ position: BytesCount,
+ pointerOffset pointer: Offset
+ ) -> Offset {
+ let __start = Message.startMessage(&fbb)
+ Message.add(id: id, &fbb)
+ Message.add(position: position, &fbb)
+ Message.add(pointer: pointer, &fbb)
+ return Message.endMessage(&fbb, start: __start)
+ }
+
+
+ public mutating func unpack() -> MessageT {
+ return MessageT(&self)
+ }
+ public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MessageT?) -> Offset {
+ guard var obj = obj else { return Offset() }
+ return pack(&builder, obj: &obj)
+ }
+
+ public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MessageT) -> Offset {
+ let __pointer = InternalMessage.pack(&builder, obj: &obj.pointer)
+ let __root = Message.startMessage(&builder)
+ Message.add(id: obj.id, &builder)
+ Message.add(position: obj.position, &builder)
+ Message.add(pointer: __pointer, &builder)
+ return Message.endMessage(&builder, start: __root)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.id.p, fieldName: "id", required: false, type: Int64.self)
+ try _v.visit(field: VTOFFSET.position.p, fieldName: "position", required: true, type: BytesCount.self)
+ try _v.visit(field: VTOFFSET.pointer.p, fieldName: "pointer", required: true, type: ForwardOffset<InternalMessage>.self)
+ _v.finish()
+ }
+}
+
+extension Message: Encodable {
+
+ enum CodingKeys: String, CodingKey {
+ case id = "id"
+ case position = "position"
+ case pointer = "pointer"
+ }
+ public func encode(to encoder: Encoder) throws {
+ var container = encoder.container(keyedBy: CodingKeys.self)
+ if id != 0 {
+ try container.encodeIfPresent(id, forKey: .id)
+ }
+ try container.encodeIfPresent(position, forKey: .position)
+ try container.encodeIfPresent(pointer, forKey: .pointer)
+ }
+}
+
+public class MessageT: NativeObject {
+
+ public var id: Int64
+ public var position: BytesCount
+ public var pointer: InternalMessageT
+
+ public init(_ _t: inout Message) {
+ id = _t.id
+ position = _t.position
+ var __pointer = _t.pointer
+ pointer = __pointer!.unpack()
+ }
+
+ public init() {
+ id = 0
+ position = BytesCount()
+ pointer = InternalMessageT()
+ }
+
+ public func serialize() -> ByteBuffer { return serialize(type: Message.self) }
+
+}
diff --git a/tests/FlatBuffers.Test.Swift/Package.swift b/tests/swift/tests/Package.swift
similarity index 96%
rename from tests/FlatBuffers.Test.Swift/Package.swift
rename to tests/swift/tests/Package.swift
index e2a53df..64fcd54 100644
--- a/tests/FlatBuffers.Test.Swift/Package.swift
+++ b/tests/swift/tests/Package.swift
@@ -24,7 +24,7 @@
.macOS(.v10_14),
],
dependencies: [
- .package(path: "../../swift/"),
+ .package(path: "../../../swift"),
.package(url: "https://github.com/grpc/grpc-swift.git", from: "1.4.1"),
],
targets: [
diff --git a/tests/FlatBuffers.Test.Swift/Sources/SwiftFlatBuffers/fuzzer.fbs b/tests/swift/tests/Sources/SwiftFlatBuffers/fuzzer.fbs
similarity index 100%
rename from tests/FlatBuffers.Test.Swift/Sources/SwiftFlatBuffers/fuzzer.fbs
rename to tests/swift/tests/Sources/SwiftFlatBuffers/fuzzer.fbs
diff --git a/tests/FlatBuffers.Test.Swift/Sources/SwiftFlatBuffers/fuzzer_generated.swift b/tests/swift/tests/Sources/SwiftFlatBuffers/fuzzer_generated.swift
similarity index 95%
rename from tests/FlatBuffers.Test.Swift/Sources/SwiftFlatBuffers/fuzzer_generated.swift
rename to tests/swift/tests/Sources/SwiftFlatBuffers/fuzzer_generated.swift
index 7051380..fe7ca0b 100644
--- a/tests/FlatBuffers.Test.Swift/Sources/SwiftFlatBuffers/fuzzer_generated.swift
+++ b/tests/swift/tests/Sources/SwiftFlatBuffers/fuzzer_generated.swift
@@ -32,7 +32,7 @@
public struct Test: NativeStruct, Verifiable, FlatbuffersInitializable {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _a: Int16
private var _b: Int8
@@ -81,7 +81,7 @@
public struct Test_Mutable: FlatBufferObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -93,7 +93,7 @@
public struct Vec3: NativeStruct, Verifiable, FlatbuffersInitializable {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _x: Float32
private var _y: Float32
@@ -178,7 +178,7 @@
public struct Vec3_Mutable: FlatBufferObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -195,7 +195,7 @@
/// an example documentation comment: "monster object"
public struct Monster: FlatBufferObject, Verifiable {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
@@ -222,9 +222,11 @@
public var hp: Int16 { let o = _accessor.offset(VTOFFSET.hp.v); return o == 0 ? 100 : _accessor.readBuffer(of: Int16.self, at: o) }
public var name: String! { let o = _accessor.offset(VTOFFSET.name.v); return _accessor.string(at: o) }
public var nameSegmentArray: [UInt8]! { return _accessor.getVector(at: VTOFFSET.name.v) }
+ public var hasTestarrayoftables: Bool { let o = _accessor.offset(VTOFFSET.testarrayoftables.v); return o == 0 ? false : true }
public var testarrayoftablesCount: Int32 { let o = _accessor.offset(VTOFFSET.testarrayoftables.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func testarrayoftables(at index: Int32) -> Monster? { let o = _accessor.offset(VTOFFSET.testarrayoftables.v); return o == 0 ? nil : Monster(_accessor.bb, o: _accessor.indirect(_accessor.vector(at: o) + index * 4)) }
public func testarrayoftablesBy(key: String) -> Monster? { let o = _accessor.offset(VTOFFSET.testarrayoftables.v); return o == 0 ? nil : Monster.lookupByKey(vector: _accessor.vector(at: o), key: key, fbb: _accessor.bb) }
+ public var hasInventory: Bool { let o = _accessor.offset(VTOFFSET.inventory.v); return o == 0 ? false : true }
public var inventoryCount: Int32 { let o = _accessor.offset(VTOFFSET.inventory.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func inventory(at index: Int32) -> UInt8 { let o = _accessor.offset(VTOFFSET.inventory.v); return o == 0 ? 0 : _accessor.directRead(of: UInt8.self, offset: _accessor.vector(at: o) + index * 1) }
public var inventory: [UInt8] { return _accessor.getVector(at: VTOFFSET.inventory.v) ?? [] }
@@ -243,7 +245,7 @@
pos: Vec3? = nil,
mana: Int16 = 150,
hp: Int16 = 100,
- nameOffset name: Offset = Offset(),
+ nameOffset name: Offset,
testarrayoftablesVectorOffset testarrayoftables: Offset = Offset(),
inventoryVectorOffset inventory: Offset = Offset(),
color: Color = .blue
diff --git a/tests/FlatBuffers.Test.Swift/Sources/SwiftFlatBuffers/main.swift b/tests/swift/tests/Sources/SwiftFlatBuffers/main.swift
similarity index 100%
rename from tests/FlatBuffers.Test.Swift/Sources/SwiftFlatBuffers/main.swift
rename to tests/swift/tests/Sources/SwiftFlatBuffers/main.swift
diff --git a/tests/swift/tests/SwiftTest.sh b/tests/swift/tests/SwiftTest.sh
new file mode 100755
index 0000000..37563d4
--- /dev/null
+++ b/tests/swift/tests/SwiftTest.sh
@@ -0,0 +1,39 @@
+current_dir=`pwd`
+cd ..
+swift_dir=`pwd`
+cd ..
+test_dir=`pwd`
+alias fbc='${test_dir}/../flatc'
+shopt -s expand_aliases
+
+cd ${current_dir}/Tests/FlatBuffers.Test.SwiftTests
+fbc --swift --gen-mutable --grpc --gen-json-emit --gen-object-api -I ${test_dir}/include_test ${test_dir}/monster_test.fbs ${test_dir}/union_vector/union_vector.fbs
+fbc --swift --gen-json-emit ${test_dir}/optional_scalars.fbs
+fbc --swift --gen-json-emit --gen-object-api ${test_dir}/more_defaults.fbs
+fbc --swift --gen-json-emit --gen-mutable --gen-object-api ${test_dir}/MutatingBool.fbs
+fbc --swift --gen-json-emit ${test_dir}/vector_has_test.fbs
+cd ${current_dir}
+
+# Goes into the code generation tests
+cd CodeGenerationTests
+fbc --swift --gen-mutable --grpc --gen-json-emit --gen-object-api --swift-implementation-only test_import.fbs
+fbc --swift --gen-mutable --grpc --gen-json-emit --gen-object-api --no-includes test_no_include.fbs
+cd ..
+
+cd ${current_dir}/Sources/SwiftFlatBuffers
+# create better fuzzing test file
+fbc --swift --gen-json-emit fuzzer.fbs
+cd ${current_dir}
+
+cd ${swift_dir}/Wasm.tests/Tests/FlatBuffers.Test.Swift.WasmTests
+fbc --swift --gen-mutable --gen-json-emit --gen-object-api -I ${test_dir}/include_test ${test_dir}/monster_test.fbs
+cd ${current_dir}
+
+swift build --build-tests
+swift test
+
+if [ $(uname -s) != Darwin ]; then
+ echo fuzzing
+ swift build -c debug -Xswiftc -sanitize=fuzzer,address -Xswiftc -parse-as-library
+ swift build -c release -Xswiftc -sanitize=fuzzer,address -Xswiftc -parse-as-library
+fi
diff --git a/tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/FlatBuffersMonsterWriterTests.swift b/tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/FlatBuffersMonsterWriterTests.swift
similarity index 100%
rename from tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/FlatBuffersMonsterWriterTests.swift
rename to tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/FlatBuffersMonsterWriterTests.swift
diff --git a/tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/FlatBuffersStructsTests.swift b/tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/FlatBuffersStructsTests.swift
similarity index 100%
rename from tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/FlatBuffersStructsTests.swift
rename to tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/FlatBuffersStructsTests.swift
diff --git a/tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/FlatBuffersTests.swift b/tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/FlatBuffersTests.swift
similarity index 100%
rename from tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/FlatBuffersTests.swift
rename to tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/FlatBuffersTests.swift
diff --git a/tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/FlatBuffersUnionTests.swift b/tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/FlatBuffersUnionTests.swift
similarity index 100%
rename from tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/FlatBuffersUnionTests.swift
rename to tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/FlatBuffersUnionTests.swift
diff --git a/tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/FlatBuffersVectorsTests.swift b/tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/FlatBuffersVectorsTests.swift
similarity index 85%
rename from tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/FlatBuffersVectorsTests.swift
rename to tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/FlatBuffersVectorsTests.swift
index 4cb245f..122facb 100644
--- a/tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/FlatBuffersVectorsTests.swift
+++ b/tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/FlatBuffersVectorsTests.swift
@@ -105,6 +105,27 @@
let number = Numbers.getRootAsNumbers(ByteBuffer(bytes: b.sizedByteArray))
XCTAssertEqual(number.vArrayDouble, [1, 2, 3, 4, 5])
}
+
+ func testHasForArray() {
+ var builder = FlatBufferBuilder(initialSize: 20)
+ let emptyVector = [UInt8]()
+ let emptyOffset = builder.createVector(emptyVector)
+ let nonEmptyVector = [1, 2, 3]
+ let nonEmptyVectorOffest = builder.createVector(nonEmptyVector)
+ let start = Swift_Tests_Vectors.startVectors(&builder)
+ Swift_Tests_Vectors.addVectorOf(empty: emptyOffset, &builder)
+ Swift_Tests_Vectors.addVectorOf(array: nonEmptyVectorOffest, &builder)
+ let finish = Swift_Tests_Vectors.endVectors(&builder, start: start)
+ builder.finish(offset: finish)
+
+ let msg = Swift_Tests_Vectors.getRootAsVectors(bb: ByteBuffer(bytes: builder.sizedByteArray))
+ XCTAssertEqual(msg.hasNone, false)
+ XCTAssertEqual(msg.hasEmpty, true)
+ XCTAssertEqual(msg.emptyCount, 0)
+ XCTAssertEqual(msg.hasArray, true)
+ XCTAssertEqual(msg.arrayCount, 3)
+ XCTAssertEqual(msg.array, [1, 2, 3])
+ }
}
struct Numbers {
diff --git a/tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/FlatbuffersDoubleTests.swift b/tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/FlatbuffersDoubleTests.swift
similarity index 100%
rename from tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/FlatbuffersDoubleTests.swift
rename to tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/FlatbuffersDoubleTests.swift
diff --git a/tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/FlatbuffersMoreDefaults.swift b/tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/FlatbuffersMoreDefaults.swift
similarity index 100%
rename from tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/FlatbuffersMoreDefaults.swift
rename to tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/FlatbuffersMoreDefaults.swift
diff --git a/tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/FlatbuffersVerifierTests.swift b/tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/FlatbuffersVerifierTests.swift
similarity index 89%
rename from tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/FlatbuffersVerifierTests.swift
rename to tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/FlatbuffersVerifierTests.swift
index 750f97b..cb26c27 100644
--- a/tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/FlatbuffersVerifierTests.swift
+++ b/tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/FlatbuffersVerifierTests.swift
@@ -201,12 +201,34 @@
XCTAssertNoThrow(try getCheckedRoot(byteBuffer: &byteBuffer) as Movie)
}
+ func testErrorWrongFileId() {
+ // swiftformat:disable all
+ var byteBuffer = ByteBuffer(bytes: [20, 0, 0, 0, 77, 79, 86, 73, 12, 0, 12, 0, 0, 0, 0, 0, 8, 0, 4, 0, 12, 0, 0, 0, 8, 0, 0, 0, 20, 0, 0, 0, 3, 0, 0, 0, 24, 0, 0, 0, 32, 0, 0, 0, 12, 0, 0, 0, 3, 0, 0, 0, 3, 1, 4, 0, 2, 0, 0, 0, 7, 0, 0, 0, 0, 0, 6, 0, 8, 0, 4, 0, 6, 0, 0, 0, 8, 0, 0, 0])
+ // swiftformat:enable all
+ XCTAssertThrowsError(try getCheckedRoot(byteBuffer: &byteBuffer, fileId: "FLEX") as Movie)
+ }
+
+ func testVerifyPrefixedBuffer() {
+ // swiftformat:disable all
+ var byteBuffer = ByteBuffer(bytes: [0, 0, 0, 1, 20, 0, 0, 0, 77, 79, 86, 73, 12, 0, 12, 0, 0, 0, 0, 0, 8, 0, 4, 0, 12, 0, 0, 0, 8, 0, 0, 0, 20, 0, 0, 0, 3, 0, 0, 0, 24, 0, 0, 0, 32, 0, 0, 0, 12, 0, 0, 0, 3, 0, 0, 0, 3, 1, 4, 0, 2, 0, 0, 0, 7, 0, 0, 0, 0, 0, 6, 0, 8, 0, 4, 0, 6, 0, 0, 0, 8, 0, 0, 0])
+ // swiftformat:enable all
+ XCTAssertThrowsError(
+ try getCheckedPrefixedSizeRoot(byteBuffer: &byteBuffer) as Movie)
+ }
+
func testFullVerifier() {
XCTAssertNoThrow(
try getCheckedRoot(
byteBuffer: &validFlatbuffersObject) as MyGame_Example_Monster)
}
+ func testFullVerifierWithFileId() {
+ XCTAssertNoThrow(
+ try getCheckedRoot(
+ byteBuffer: &validFlatbuffersObject,
+ fileId: MyGame_Example_Monster.id) as MyGame_Example_Monster)
+ }
+
func testInvalidBuffer() {
XCTAssertThrowsError(
try getCheckedRoot(
diff --git a/tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/MutatingBool_generated.swift b/tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/MutatingBool_generated.swift
similarity index 96%
rename from tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/MutatingBool_generated.swift
rename to tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/MutatingBool_generated.swift
index 155080a..4c243d9 100644
--- a/tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/MutatingBool_generated.swift
+++ b/tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/MutatingBool_generated.swift
@@ -6,7 +6,7 @@
public struct Property: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _property: Bool
@@ -49,7 +49,7 @@
public struct Property_Mutable: FlatBufferObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -74,7 +74,7 @@
public struct TestMutatingBool: FlatBufferObject, Verifiable, ObjectAPIPacker {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
diff --git a/tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/XCTestManifests.swift b/tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/XCTestManifests.swift
similarity index 98%
rename from tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/XCTestManifests.swift
rename to tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/XCTestManifests.swift
index 4134762..e15ea83 100644
--- a/tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/XCTestManifests.swift
+++ b/tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/XCTestManifests.swift
@@ -109,6 +109,7 @@
("testCreateSharedStringVector", testCreateSharedStringVector),
("testCreateVectorOfStrings", testCreateVectorOfStrings),
("testCreatingTwoCountries", testCreatingTwoCountries),
+ ("testHasForArray", testHasForArray),
("testReadDoubleArray", testReadDoubleArray),
("testReadInt32Array", testReadInt32Array),
]
diff --git a/tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/monster_test.grpc.swift b/tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/monster_test.grpc.swift
similarity index 100%
rename from tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/monster_test.grpc.swift
rename to tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/monster_test.grpc.swift
diff --git a/tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/monster_test_generated.swift b/tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/monster_test_generated.swift
similarity index 94%
copy from tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/monster_test_generated.swift
copy to tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/monster_test_generated.swift
index c8a0502..d37a5bb 100644
--- a/tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/monster_test_generated.swift
+++ b/tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/monster_test_generated.swift
@@ -237,7 +237,7 @@
}
public struct MyGame_Example_Test: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _a: Int16
private var _b: Int8
@@ -291,7 +291,7 @@
public struct MyGame_Example_Test_Mutable: FlatBufferObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -318,7 +318,7 @@
public struct MyGame_Example_Vec3: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _x: Float32
private var _y: Float32
@@ -413,7 +413,7 @@
public struct MyGame_Example_Vec3_Mutable: FlatBufferObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -447,7 +447,7 @@
public struct MyGame_Example_Ability: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _id: UInt32
private var _distance: UInt32
@@ -500,7 +500,7 @@
public struct MyGame_Example_Ability_Mutable: FlatBufferObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -527,7 +527,7 @@
public struct MyGame_Example_StructOfStructs: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _a: MyGame_Example_Ability
private var _b: MyGame_Example_Test
@@ -587,7 +587,7 @@
public struct MyGame_Example_StructOfStructs_Mutable: FlatBufferObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -611,13 +611,80 @@
}
}
+public struct MyGame_Example_StructOfStructsOfStructs: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
+
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
+
+ private var _a: MyGame_Example_StructOfStructs
+
+ public init(_ bb: ByteBuffer, o: Int32) {
+ let _accessor = Struct(bb: bb, position: o)
+ _a = MyGame_Example_StructOfStructs(_accessor.bb, o: _accessor.postion + 0)
+ }
+
+ public init(a: MyGame_Example_StructOfStructs) {
+ _a = a
+ }
+
+ public init() {
+ _a = MyGame_Example_StructOfStructs()
+ }
+
+ public init(_ _t: inout MyGame_Example_StructOfStructsOfStructs_Mutable) {
+ var _va = _t.a
+ _a = _va.unpack()
+ }
+
+ public var a: MyGame_Example_StructOfStructs { _a }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ try verifier.inBuffer(position: position, of: MyGame_Example_StructOfStructsOfStructs.self)
+ }
+}
+
+extension MyGame_Example_StructOfStructsOfStructs: Encodable {
+
+ enum CodingKeys: String, CodingKey {
+ case a = "a"
+ }
+ public func encode(to encoder: Encoder) throws {
+ var container = encoder.container(keyedBy: CodingKeys.self)
+ try container.encodeIfPresent(a, forKey: .a)
+ }
+}
+
+public struct MyGame_Example_StructOfStructsOfStructs_Mutable: FlatBufferObject {
+
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Struct
+
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Struct(bb: bb, position: o) }
+
+ public var a: MyGame_Example_StructOfStructs_Mutable { return MyGame_Example_StructOfStructs_Mutable(_accessor.bb, o: _accessor.postion + 0) }
+
+
+ public mutating func unpack() -> MyGame_Example_StructOfStructsOfStructs {
+ return MyGame_Example_StructOfStructsOfStructs(&self)
+ }
+ public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MyGame_Example_StructOfStructsOfStructs?) -> Offset {
+ guard var obj = obj else { return Offset() }
+ return pack(&builder, obj: &obj)
+ }
+
+ public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MyGame_Example_StructOfStructsOfStructs) -> Offset {
+ return builder.create(struct: obj)
+ }
+}
+
public struct MyGame_InParentNamespace: FlatBufferObject, Verifiable, ObjectAPIPacker {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
- public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: "MONS", addPrefix: prefix) }
+ public static var id: String { "MONS" }
+ public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: MyGame_InParentNamespace.id, addPrefix: prefix) }
public static func getRootAsInParentNamespace(bb: ByteBuffer) -> MyGame_InParentNamespace { return MyGame_InParentNamespace(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
private init(_ t: Table) { _accessor = t }
@@ -666,11 +733,12 @@
}
public struct MyGame_Example2_Monster: FlatBufferObject, Verifiable, ObjectAPIPacker {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
- public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: "MONS", addPrefix: prefix) }
+ public static var id: String { "MONS" }
+ public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: MyGame_Example2_Monster.id, addPrefix: prefix) }
public static func getRootAsMonster(bb: ByteBuffer) -> MyGame_Example2_Monster { return MyGame_Example2_Monster(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
private init(_ t: Table) { _accessor = t }
@@ -719,11 +787,12 @@
}
internal struct MyGame_Example_TestSimpleTableWithEnum: FlatBufferObject, Verifiable, ObjectAPIPacker {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
internal var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
- internal static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: "MONS", addPrefix: prefix) }
+ internal static var id: String { "MONS" }
+ internal static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: MyGame_Example_TestSimpleTableWithEnum.id, addPrefix: prefix) }
internal static func getRootAsTestSimpleTableWithEnum(bb: ByteBuffer) -> MyGame_Example_TestSimpleTableWithEnum { return MyGame_Example_TestSimpleTableWithEnum(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
private init(_ t: Table) { _accessor = t }
@@ -764,7 +833,7 @@
return MyGame_Example_TestSimpleTableWithEnum.endTestSimpleTableWithEnum(&builder, start: __root)
}
- public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ internal static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
var _v = try verifier.visitTable(at: position)
try _v.visit(field: VTOFFSET.color.p, fieldName: "color", required: false, type: MyGame_Example_Color.self)
_v.finish()
@@ -776,7 +845,7 @@
enum CodingKeys: String, CodingKey {
case color = "color"
}
- public func encode(to encoder: Encoder) throws {
+ internal func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
if color != .green {
try container.encodeIfPresent(color, forKey: .color)
@@ -801,11 +870,12 @@
}
public struct MyGame_Example_Stat: FlatBufferObject, Verifiable, ObjectAPIPacker {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
- public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: "MONS", addPrefix: prefix) }
+ public static var id: String { "MONS" }
+ public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: MyGame_Example_Stat.id, addPrefix: prefix) }
public static func getRootAsStat(bb: ByteBuffer) -> MyGame_Example_Stat { return MyGame_Example_Stat(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
private init(_ t: Table) { _accessor = t }
@@ -941,11 +1011,12 @@
}
public struct MyGame_Example_Referrable: FlatBufferObject, Verifiable, ObjectAPIPacker {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
- public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: "MONS", addPrefix: prefix) }
+ public static var id: String { "MONS" }
+ public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: MyGame_Example_Referrable.id, addPrefix: prefix) }
public static func getRootAsReferrable(bb: ByteBuffer) -> MyGame_Example_Referrable { return MyGame_Example_Referrable(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
private init(_ t: Table) { _accessor = t }
@@ -1048,11 +1119,12 @@
/// an example documentation comment: "monster object"
public struct MyGame_Example_Monster: FlatBufferObject, Verifiable, ObjectAPIPacker {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
- public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: "MONS", addPrefix: prefix) }
+ public static var id: String { "MONS" }
+ public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: MyGame_Example_Monster.id, addPrefix: prefix) }
public static func getRootAsMonster(bb: ByteBuffer) -> MyGame_Example_Monster { return MyGame_Example_Monster(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
private init(_ t: Table) { _accessor = t }
@@ -1124,6 +1196,7 @@
@discardableResult public func mutate(hp: Int16) -> Bool {let o = _accessor.offset(VTOFFSET.hp.v); return _accessor.mutate(hp, index: o) }
public var name: String! { let o = _accessor.offset(VTOFFSET.name.v); return _accessor.string(at: o) }
public var nameSegmentArray: [UInt8]! { return _accessor.getVector(at: VTOFFSET.name.v) }
+ public var hasInventory: Bool { let o = _accessor.offset(VTOFFSET.inventory.v); return o == 0 ? false : true }
public var inventoryCount: Int32 { let o = _accessor.offset(VTOFFSET.inventory.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func inventory(at index: Int32) -> UInt8 { let o = _accessor.offset(VTOFFSET.inventory.v); return o == 0 ? 0 : _accessor.directRead(of: UInt8.self, offset: _accessor.vector(at: o) + index * 1) }
public var inventory: [UInt8] { return _accessor.getVector(at: VTOFFSET.inventory.v) ?? [] }
@@ -1132,17 +1205,21 @@
@discardableResult public func mutate(color: MyGame_Example_Color) -> Bool {let o = _accessor.offset(VTOFFSET.color.v); return _accessor.mutate(color.rawValue, index: o) }
public var testType: MyGame_Example_Any_ { let o = _accessor.offset(VTOFFSET.testType.v); return o == 0 ? .none_ : MyGame_Example_Any_(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) ?? .none_ }
public func test<T: FlatbuffersInitializable>(type: T.Type) -> T? { let o = _accessor.offset(VTOFFSET.test.v); return o == 0 ? nil : _accessor.union(o) }
+ public var hasTest4: Bool { let o = _accessor.offset(VTOFFSET.test4.v); return o == 0 ? false : true }
public var test4Count: Int32 { let o = _accessor.offset(VTOFFSET.test4.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func test4(at index: Int32) -> MyGame_Example_Test? { let o = _accessor.offset(VTOFFSET.test4.v); return o == 0 ? nil : _accessor.directRead(of: MyGame_Example_Test.self, offset: _accessor.vector(at: o) + index * 4) }
public func mutableTest4(at index: Int32) -> MyGame_Example_Test_Mutable? { let o = _accessor.offset(VTOFFSET.test4.v); return o == 0 ? nil : MyGame_Example_Test_Mutable(_accessor.bb, o: _accessor.vector(at: o) + index * 4) }
+ public var hasTestarrayofstring: Bool { let o = _accessor.offset(VTOFFSET.testarrayofstring.v); return o == 0 ? false : true }
public var testarrayofstringCount: Int32 { let o = _accessor.offset(VTOFFSET.testarrayofstring.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func testarrayofstring(at index: Int32) -> String? { let o = _accessor.offset(VTOFFSET.testarrayofstring.v); return o == 0 ? nil : _accessor.directString(at: _accessor.vector(at: o) + index * 4) }
/// an example documentation comment: this will end up in the generated code
/// multiline too
+ public var hasTestarrayoftables: Bool { let o = _accessor.offset(VTOFFSET.testarrayoftables.v); return o == 0 ? false : true }
public var testarrayoftablesCount: Int32 { let o = _accessor.offset(VTOFFSET.testarrayoftables.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func testarrayoftables(at index: Int32) -> MyGame_Example_Monster? { let o = _accessor.offset(VTOFFSET.testarrayoftables.v); return o == 0 ? nil : MyGame_Example_Monster(_accessor.bb, o: _accessor.indirect(_accessor.vector(at: o) + index * 4)) }
public func testarrayoftablesBy(key: String) -> MyGame_Example_Monster? { let o = _accessor.offset(VTOFFSET.testarrayoftables.v); return o == 0 ? nil : MyGame_Example_Monster.lookupByKey(vector: _accessor.vector(at: o), key: key, fbb: _accessor.bb) }
public var enemy: MyGame_Example_Monster? { let o = _accessor.offset(VTOFFSET.enemy.v); return o == 0 ? nil : MyGame_Example_Monster(_accessor.bb, o: _accessor.indirect(o + _accessor.postion)) }
+ public var hasTestnestedflatbuffer: Bool { let o = _accessor.offset(VTOFFSET.testnestedflatbuffer.v); return o == 0 ? false : true }
public var testnestedflatbufferCount: Int32 { let o = _accessor.offset(VTOFFSET.testnestedflatbuffer.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func testnestedflatbuffer(at index: Int32) -> UInt8 { let o = _accessor.offset(VTOFFSET.testnestedflatbuffer.v); return o == 0 ? 0 : _accessor.directRead(of: UInt8.self, offset: _accessor.vector(at: o) + index * 1) }
public var testnestedflatbuffer: [UInt8] { return _accessor.getVector(at: VTOFFSET.testnestedflatbuffer.v) ?? [] }
@@ -1166,6 +1243,7 @@
@discardableResult public func mutate(testhashs64Fnv1a: Int64) -> Bool {let o = _accessor.offset(VTOFFSET.testhashs64Fnv1a.v); return _accessor.mutate(testhashs64Fnv1a, index: o) }
public var testhashu64Fnv1a: UInt64 { let o = _accessor.offset(VTOFFSET.testhashu64Fnv1a.v); return o == 0 ? 0 : _accessor.readBuffer(of: UInt64.self, at: o) }
@discardableResult public func mutate(testhashu64Fnv1a: UInt64) -> Bool {let o = _accessor.offset(VTOFFSET.testhashu64Fnv1a.v); return _accessor.mutate(testhashu64Fnv1a, index: o) }
+ public var hasTestarrayofbools: Bool { let o = _accessor.offset(VTOFFSET.testarrayofbools.v); return o == 0 ? false : true }
public var testarrayofboolsCount: Int32 { let o = _accessor.offset(VTOFFSET.testarrayofbools.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func testarrayofbools(at index: Int32) -> Bool { let o = _accessor.offset(VTOFFSET.testarrayofbools.v); return o == 0 ? true : _accessor.directRead(of: Bool.self, offset: _accessor.vector(at: o) + index * 1) }
public var testarrayofbools: [Bool] { return _accessor.getVector(at: VTOFFSET.testarrayofbools.v) ?? [] }
@@ -1176,47 +1254,58 @@
@discardableResult public func mutate(testf2: Float32) -> Bool {let o = _accessor.offset(VTOFFSET.testf2.v); return _accessor.mutate(testf2, index: o) }
public var testf3: Float32 { let o = _accessor.offset(VTOFFSET.testf3.v); return o == 0 ? 0.0 : _accessor.readBuffer(of: Float32.self, at: o) }
@discardableResult public func mutate(testf3: Float32) -> Bool {let o = _accessor.offset(VTOFFSET.testf3.v); return _accessor.mutate(testf3, index: o) }
+ public var hasTestarrayofstring2: Bool { let o = _accessor.offset(VTOFFSET.testarrayofstring2.v); return o == 0 ? false : true }
public var testarrayofstring2Count: Int32 { let o = _accessor.offset(VTOFFSET.testarrayofstring2.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func testarrayofstring2(at index: Int32) -> String? { let o = _accessor.offset(VTOFFSET.testarrayofstring2.v); return o == 0 ? nil : _accessor.directString(at: _accessor.vector(at: o) + index * 4) }
+ public var hasTestarrayofsortedstruct: Bool { let o = _accessor.offset(VTOFFSET.testarrayofsortedstruct.v); return o == 0 ? false : true }
public var testarrayofsortedstructCount: Int32 { let o = _accessor.offset(VTOFFSET.testarrayofsortedstruct.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func testarrayofsortedstruct(at index: Int32) -> MyGame_Example_Ability? { let o = _accessor.offset(VTOFFSET.testarrayofsortedstruct.v); return o == 0 ? nil : _accessor.directRead(of: MyGame_Example_Ability.self, offset: _accessor.vector(at: o) + index * 8) }
public func mutableTestarrayofsortedstruct(at index: Int32) -> MyGame_Example_Ability_Mutable? { let o = _accessor.offset(VTOFFSET.testarrayofsortedstruct.v); return o == 0 ? nil : MyGame_Example_Ability_Mutable(_accessor.bb, o: _accessor.vector(at: o) + index * 8) }
+ public var hasFlex: Bool { let o = _accessor.offset(VTOFFSET.flex.v); return o == 0 ? false : true }
public var flexCount: Int32 { let o = _accessor.offset(VTOFFSET.flex.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func flex(at index: Int32) -> UInt8 { let o = _accessor.offset(VTOFFSET.flex.v); return o == 0 ? 0 : _accessor.directRead(of: UInt8.self, offset: _accessor.vector(at: o) + index * 1) }
public var flex: [UInt8] { return _accessor.getVector(at: VTOFFSET.flex.v) ?? [] }
public func mutate(flex: UInt8, at index: Int32) -> Bool { let o = _accessor.offset(VTOFFSET.flex.v); return _accessor.directMutate(flex, index: _accessor.vector(at: o) + index * 1) }
+ public var hasTest5: Bool { let o = _accessor.offset(VTOFFSET.test5.v); return o == 0 ? false : true }
public var test5Count: Int32 { let o = _accessor.offset(VTOFFSET.test5.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func test5(at index: Int32) -> MyGame_Example_Test? { let o = _accessor.offset(VTOFFSET.test5.v); return o == 0 ? nil : _accessor.directRead(of: MyGame_Example_Test.self, offset: _accessor.vector(at: o) + index * 4) }
public func mutableTest5(at index: Int32) -> MyGame_Example_Test_Mutable? { let o = _accessor.offset(VTOFFSET.test5.v); return o == 0 ? nil : MyGame_Example_Test_Mutable(_accessor.bb, o: _accessor.vector(at: o) + index * 4) }
+ public var hasVectorOfLongs: Bool { let o = _accessor.offset(VTOFFSET.vectorOfLongs.v); return o == 0 ? false : true }
public var vectorOfLongsCount: Int32 { let o = _accessor.offset(VTOFFSET.vectorOfLongs.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func vectorOfLongs(at index: Int32) -> Int64 { let o = _accessor.offset(VTOFFSET.vectorOfLongs.v); return o == 0 ? 0 : _accessor.directRead(of: Int64.self, offset: _accessor.vector(at: o) + index * 8) }
public var vectorOfLongs: [Int64] { return _accessor.getVector(at: VTOFFSET.vectorOfLongs.v) ?? [] }
public func mutate(vectorOfLongs: Int64, at index: Int32) -> Bool { let o = _accessor.offset(VTOFFSET.vectorOfLongs.v); return _accessor.directMutate(vectorOfLongs, index: _accessor.vector(at: o) + index * 8) }
+ public var hasVectorOfDoubles: Bool { let o = _accessor.offset(VTOFFSET.vectorOfDoubles.v); return o == 0 ? false : true }
public var vectorOfDoublesCount: Int32 { let o = _accessor.offset(VTOFFSET.vectorOfDoubles.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func vectorOfDoubles(at index: Int32) -> Double { let o = _accessor.offset(VTOFFSET.vectorOfDoubles.v); return o == 0 ? 0 : _accessor.directRead(of: Double.self, offset: _accessor.vector(at: o) + index * 8) }
public var vectorOfDoubles: [Double] { return _accessor.getVector(at: VTOFFSET.vectorOfDoubles.v) ?? [] }
public func mutate(vectorOfDoubles: Double, at index: Int32) -> Bool { let o = _accessor.offset(VTOFFSET.vectorOfDoubles.v); return _accessor.directMutate(vectorOfDoubles, index: _accessor.vector(at: o) + index * 8) }
public var parentNamespaceTest: MyGame_InParentNamespace? { let o = _accessor.offset(VTOFFSET.parentNamespaceTest.v); return o == 0 ? nil : MyGame_InParentNamespace(_accessor.bb, o: _accessor.indirect(o + _accessor.postion)) }
+ public var hasVectorOfReferrables: Bool { let o = _accessor.offset(VTOFFSET.vectorOfReferrables.v); return o == 0 ? false : true }
public var vectorOfReferrablesCount: Int32 { let o = _accessor.offset(VTOFFSET.vectorOfReferrables.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func vectorOfReferrables(at index: Int32) -> MyGame_Example_Referrable? { let o = _accessor.offset(VTOFFSET.vectorOfReferrables.v); return o == 0 ? nil : MyGame_Example_Referrable(_accessor.bb, o: _accessor.indirect(_accessor.vector(at: o) + index * 4)) }
public func vectorOfReferrablesBy(key: UInt64) -> MyGame_Example_Referrable? { let o = _accessor.offset(VTOFFSET.vectorOfReferrables.v); return o == 0 ? nil : MyGame_Example_Referrable.lookupByKey(vector: _accessor.vector(at: o), key: key, fbb: _accessor.bb) }
public var singleWeakReference: UInt64 { let o = _accessor.offset(VTOFFSET.singleWeakReference.v); return o == 0 ? 0 : _accessor.readBuffer(of: UInt64.self, at: o) }
@discardableResult public func mutate(singleWeakReference: UInt64) -> Bool {let o = _accessor.offset(VTOFFSET.singleWeakReference.v); return _accessor.mutate(singleWeakReference, index: o) }
+ public var hasVectorOfWeakReferences: Bool { let o = _accessor.offset(VTOFFSET.vectorOfWeakReferences.v); return o == 0 ? false : true }
public var vectorOfWeakReferencesCount: Int32 { let o = _accessor.offset(VTOFFSET.vectorOfWeakReferences.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func vectorOfWeakReferences(at index: Int32) -> UInt64 { let o = _accessor.offset(VTOFFSET.vectorOfWeakReferences.v); return o == 0 ? 0 : _accessor.directRead(of: UInt64.self, offset: _accessor.vector(at: o) + index * 8) }
public var vectorOfWeakReferences: [UInt64] { return _accessor.getVector(at: VTOFFSET.vectorOfWeakReferences.v) ?? [] }
public func mutate(vectorOfWeakReferences: UInt64, at index: Int32) -> Bool { let o = _accessor.offset(VTOFFSET.vectorOfWeakReferences.v); return _accessor.directMutate(vectorOfWeakReferences, index: _accessor.vector(at: o) + index * 8) }
+ public var hasVectorOfStrongReferrables: Bool { let o = _accessor.offset(VTOFFSET.vectorOfStrongReferrables.v); return o == 0 ? false : true }
public var vectorOfStrongReferrablesCount: Int32 { let o = _accessor.offset(VTOFFSET.vectorOfStrongReferrables.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func vectorOfStrongReferrables(at index: Int32) -> MyGame_Example_Referrable? { let o = _accessor.offset(VTOFFSET.vectorOfStrongReferrables.v); return o == 0 ? nil : MyGame_Example_Referrable(_accessor.bb, o: _accessor.indirect(_accessor.vector(at: o) + index * 4)) }
public func vectorOfStrongReferrablesBy(key: UInt64) -> MyGame_Example_Referrable? { let o = _accessor.offset(VTOFFSET.vectorOfStrongReferrables.v); return o == 0 ? nil : MyGame_Example_Referrable.lookupByKey(vector: _accessor.vector(at: o), key: key, fbb: _accessor.bb) }
public var coOwningReference: UInt64 { let o = _accessor.offset(VTOFFSET.coOwningReference.v); return o == 0 ? 0 : _accessor.readBuffer(of: UInt64.self, at: o) }
@discardableResult public func mutate(coOwningReference: UInt64) -> Bool {let o = _accessor.offset(VTOFFSET.coOwningReference.v); return _accessor.mutate(coOwningReference, index: o) }
+ public var hasVectorOfCoOwningReferences: Bool { let o = _accessor.offset(VTOFFSET.vectorOfCoOwningReferences.v); return o == 0 ? false : true }
public var vectorOfCoOwningReferencesCount: Int32 { let o = _accessor.offset(VTOFFSET.vectorOfCoOwningReferences.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func vectorOfCoOwningReferences(at index: Int32) -> UInt64 { let o = _accessor.offset(VTOFFSET.vectorOfCoOwningReferences.v); return o == 0 ? 0 : _accessor.directRead(of: UInt64.self, offset: _accessor.vector(at: o) + index * 8) }
public var vectorOfCoOwningReferences: [UInt64] { return _accessor.getVector(at: VTOFFSET.vectorOfCoOwningReferences.v) ?? [] }
public func mutate(vectorOfCoOwningReferences: UInt64, at index: Int32) -> Bool { let o = _accessor.offset(VTOFFSET.vectorOfCoOwningReferences.v); return _accessor.directMutate(vectorOfCoOwningReferences, index: _accessor.vector(at: o) + index * 8) }
public var nonOwningReference: UInt64 { let o = _accessor.offset(VTOFFSET.nonOwningReference.v); return o == 0 ? 0 : _accessor.readBuffer(of: UInt64.self, at: o) }
@discardableResult public func mutate(nonOwningReference: UInt64) -> Bool {let o = _accessor.offset(VTOFFSET.nonOwningReference.v); return _accessor.mutate(nonOwningReference, index: o) }
+ public var hasVectorOfNonOwningReferences: Bool { let o = _accessor.offset(VTOFFSET.vectorOfNonOwningReferences.v); return o == 0 ? false : true }
public var vectorOfNonOwningReferencesCount: Int32 { let o = _accessor.offset(VTOFFSET.vectorOfNonOwningReferences.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func vectorOfNonOwningReferences(at index: Int32) -> UInt64 { let o = _accessor.offset(VTOFFSET.vectorOfNonOwningReferences.v); return o == 0 ? 0 : _accessor.directRead(of: UInt64.self, offset: _accessor.vector(at: o) + index * 8) }
public var vectorOfNonOwningReferences: [UInt64] { return _accessor.getVector(at: VTOFFSET.vectorOfNonOwningReferences.v) ?? [] }
@@ -1225,14 +1314,17 @@
public func anyUnique<T: FlatbuffersInitializable>(type: T.Type) -> T? { let o = _accessor.offset(VTOFFSET.anyUnique.v); return o == 0 ? nil : _accessor.union(o) }
public var anyAmbiguousType: MyGame_Example_AnyAmbiguousAliases { let o = _accessor.offset(VTOFFSET.anyAmbiguousType.v); return o == 0 ? .none_ : MyGame_Example_AnyAmbiguousAliases(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) ?? .none_ }
public func anyAmbiguous<T: FlatbuffersInitializable>(type: T.Type) -> T? { let o = _accessor.offset(VTOFFSET.anyAmbiguous.v); return o == 0 ? nil : _accessor.union(o) }
+ public var hasVectorOfEnums: Bool { let o = _accessor.offset(VTOFFSET.vectorOfEnums.v); return o == 0 ? false : true }
public var vectorOfEnumsCount: Int32 { let o = _accessor.offset(VTOFFSET.vectorOfEnums.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func vectorOfEnums(at index: Int32) -> MyGame_Example_Color? { let o = _accessor.offset(VTOFFSET.vectorOfEnums.v); return o == 0 ? MyGame_Example_Color.red : MyGame_Example_Color(rawValue: _accessor.directRead(of: UInt8.self, offset: _accessor.vector(at: o) + index * 1)) }
public var signedEnum: MyGame_Example_Race { let o = _accessor.offset(VTOFFSET.signedEnum.v); return o == 0 ? .none_ : MyGame_Example_Race(rawValue: _accessor.readBuffer(of: Int8.self, at: o)) ?? .none_ }
@discardableResult public func mutate(signedEnum: MyGame_Example_Race) -> Bool {let o = _accessor.offset(VTOFFSET.signedEnum.v); return _accessor.mutate(signedEnum.rawValue, index: o) }
+ public var hasTestrequirednestedflatbuffer: Bool { let o = _accessor.offset(VTOFFSET.testrequirednestedflatbuffer.v); return o == 0 ? false : true }
public var testrequirednestedflatbufferCount: Int32 { let o = _accessor.offset(VTOFFSET.testrequirednestedflatbuffer.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func testrequirednestedflatbuffer(at index: Int32) -> UInt8 { let o = _accessor.offset(VTOFFSET.testrequirednestedflatbuffer.v); return o == 0 ? 0 : _accessor.directRead(of: UInt8.self, offset: _accessor.vector(at: o) + index * 1) }
public var testrequirednestedflatbuffer: [UInt8] { return _accessor.getVector(at: VTOFFSET.testrequirednestedflatbuffer.v) ?? [] }
public func mutate(testrequirednestedflatbuffer: UInt8, at index: Int32) -> Bool { let o = _accessor.offset(VTOFFSET.testrequirednestedflatbuffer.v); return _accessor.directMutate(testrequirednestedflatbuffer, index: _accessor.vector(at: o) + index * 1) }
+ public var hasScalarKeySortedTables: Bool { let o = _accessor.offset(VTOFFSET.scalarKeySortedTables.v); return o == 0 ? false : true }
public var scalarKeySortedTablesCount: Int32 { let o = _accessor.offset(VTOFFSET.scalarKeySortedTables.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func scalarKeySortedTables(at index: Int32) -> MyGame_Example_Stat? { let o = _accessor.offset(VTOFFSET.scalarKeySortedTables.v); return o == 0 ? nil : MyGame_Example_Stat(_accessor.bb, o: _accessor.indirect(_accessor.vector(at: o) + index * 4)) }
public func scalarKeySortedTablesBy(key: UInt16) -> MyGame_Example_Stat? { let o = _accessor.offset(VTOFFSET.scalarKeySortedTables.v); return o == 0 ? nil : MyGame_Example_Stat.lookupByKey(vector: _accessor.vector(at: o), key: key, fbb: _accessor.bb) }
@@ -1312,7 +1404,7 @@
pos: MyGame_Example_Vec3? = nil,
mana: Int16 = 150,
hp: Int16 = 100,
- nameOffset name: Offset = Offset(),
+ nameOffset name: Offset,
inventoryVectorOffset inventory: Offset = Offset(),
color: MyGame_Example_Color = .blue,
testType: MyGame_Example_Any_ = .none_,
@@ -2205,11 +2297,12 @@
}
public struct MyGame_Example_TypeAliases: FlatBufferObject, Verifiable, ObjectAPIPacker {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
- public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: "MONS", addPrefix: prefix) }
+ public static var id: String { "MONS" }
+ public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: MyGame_Example_TypeAliases.id, addPrefix: prefix) }
public static func getRootAsTypeAliases(bb: ByteBuffer) -> MyGame_Example_TypeAliases { return MyGame_Example_TypeAliases(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
private init(_ t: Table) { _accessor = t }
@@ -2252,10 +2345,12 @@
@discardableResult public func mutate(f32: Float32) -> Bool {let o = _accessor.offset(VTOFFSET.f32.v); return _accessor.mutate(f32, index: o) }
public var f64: Double { let o = _accessor.offset(VTOFFSET.f64.v); return o == 0 ? 0.0 : _accessor.readBuffer(of: Double.self, at: o) }
@discardableResult public func mutate(f64: Double) -> Bool {let o = _accessor.offset(VTOFFSET.f64.v); return _accessor.mutate(f64, index: o) }
+ public var hasV8: Bool { let o = _accessor.offset(VTOFFSET.v8.v); return o == 0 ? false : true }
public var v8Count: Int32 { let o = _accessor.offset(VTOFFSET.v8.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func v8(at index: Int32) -> Int8 { let o = _accessor.offset(VTOFFSET.v8.v); return o == 0 ? 0 : _accessor.directRead(of: Int8.self, offset: _accessor.vector(at: o) + index * 1) }
public var v8: [Int8] { return _accessor.getVector(at: VTOFFSET.v8.v) ?? [] }
public func mutate(v8: Int8, at index: Int32) -> Bool { let o = _accessor.offset(VTOFFSET.v8.v); return _accessor.directMutate(v8, index: _accessor.vector(at: o) + index * 1) }
+ public var hasVf64: Bool { let o = _accessor.offset(VTOFFSET.vf64.v); return o == 0 ? false : true }
public var vf64Count: Int32 { let o = _accessor.offset(VTOFFSET.vf64.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func vf64(at index: Int32) -> Double { let o = _accessor.offset(VTOFFSET.vf64.v); return o == 0 ? 0 : _accessor.directRead(of: Double.self, offset: _accessor.vector(at: o) + index * 8) }
public var vf64: [Double] { return _accessor.getVector(at: VTOFFSET.vf64.v) ?? [] }
diff --git a/tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/more_defaults_generated.swift b/tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/more_defaults_generated.swift
similarity index 94%
rename from tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/more_defaults_generated.swift
rename to tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/more_defaults_generated.swift
index 3ebaa2a..f6692c9 100644
--- a/tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/more_defaults_generated.swift
+++ b/tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/more_defaults_generated.swift
@@ -29,7 +29,7 @@
public struct MoreDefaults: FlatBufferObject, Verifiable, ObjectAPIPacker {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
@@ -49,9 +49,11 @@
var p: VOffset { self.rawValue }
}
+ public var hasInts: Bool { let o = _accessor.offset(VTOFFSET.ints.v); return o == 0 ? false : true }
public var intsCount: Int32 { let o = _accessor.offset(VTOFFSET.ints.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func ints(at index: Int32) -> Int32 { let o = _accessor.offset(VTOFFSET.ints.v); return o == 0 ? 0 : _accessor.directRead(of: Int32.self, offset: _accessor.vector(at: o) + index * 4) }
public var ints: [Int32] { return _accessor.getVector(at: VTOFFSET.ints.v) ?? [] }
+ public var hasFloats: Bool { let o = _accessor.offset(VTOFFSET.floats.v); return o == 0 ? false : true }
public var floatsCount: Int32 { let o = _accessor.offset(VTOFFSET.floats.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func floats(at index: Int32) -> Float32 { let o = _accessor.offset(VTOFFSET.floats.v); return o == 0 ? 0 : _accessor.directRead(of: Float32.self, offset: _accessor.vector(at: o) + index * 4) }
public var floats: [Float32] { return _accessor.getVector(at: VTOFFSET.floats.v) ?? [] }
@@ -59,8 +61,10 @@
public var emptyStringSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.emptyString.v) }
public var someString: String? { let o = _accessor.offset(VTOFFSET.someString.v); return o == 0 ? "some" : _accessor.string(at: o) }
public var someStringSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.someString.v) }
+ public var hasAbcs: Bool { let o = _accessor.offset(VTOFFSET.abcs.v); return o == 0 ? false : true }
public var abcsCount: Int32 { let o = _accessor.offset(VTOFFSET.abcs.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func abcs(at index: Int32) -> ABC? { let o = _accessor.offset(VTOFFSET.abcs.v); return o == 0 ? ABC.a : ABC(rawValue: _accessor.directRead(of: Int32.self, offset: _accessor.vector(at: o) + index * 4)) }
+ public var hasBools: Bool { let o = _accessor.offset(VTOFFSET.bools.v); return o == 0 ? false : true }
public var boolsCount: Int32 { let o = _accessor.offset(VTOFFSET.bools.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func bools(at index: Int32) -> Bool { let o = _accessor.offset(VTOFFSET.bools.v); return o == 0 ? true : _accessor.directRead(of: Bool.self, offset: _accessor.vector(at: o) + index * 1) }
public var bools: [Bool] { return _accessor.getVector(at: VTOFFSET.bools.v) ?? [] }
diff --git a/tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/optional_scalars_generated.swift b/tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/optional_scalars_generated.swift
similarity index 99%
rename from tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/optional_scalars_generated.swift
rename to tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/optional_scalars_generated.swift
index 0f427c8..565bbd4 100644
--- a/tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/optional_scalars_generated.swift
+++ b/tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/optional_scalars_generated.swift
@@ -29,11 +29,12 @@
public struct optional_scalars_ScalarStuff: FlatBufferObject, Verifiable {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
- public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: "NULL", addPrefix: prefix) }
+ public static var id: String { "NULL" }
+ public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: optional_scalars_ScalarStuff.id, addPrefix: prefix) }
public static func getRootAsScalarStuff(bb: ByteBuffer) -> optional_scalars_ScalarStuff { return optional_scalars_ScalarStuff(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
private init(_ t: Table) { _accessor = t }
diff --git a/tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/union_vector_generated.swift b/tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/union_vector_generated.swift
similarity index 95%
rename from tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/union_vector_generated.swift
rename to tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/union_vector_generated.swift
index 59ed005..ce3d37f 100644
--- a/tests/FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests/union_vector_generated.swift
+++ b/tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/union_vector_generated.swift
@@ -120,7 +120,7 @@
}
public struct Rapunzel: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _hairLength: Int32
@@ -163,7 +163,7 @@
public struct Rapunzel_Mutable: FlatBufferObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -188,7 +188,7 @@
public struct BookReader: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _booksRead: Int32
@@ -231,7 +231,7 @@
public struct BookReader_Mutable: FlatBufferObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -256,7 +256,7 @@
public struct FallingTub: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _weight: Int32
@@ -299,7 +299,7 @@
public struct FallingTub_Mutable: FlatBufferObject {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -324,11 +324,12 @@
public struct Attacker: FlatBufferObject, Verifiable, ObjectAPIPacker {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
- public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: "MOVI", addPrefix: prefix) }
+ public static var id: String { "MOVI" }
+ public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: Attacker.id, addPrefix: prefix) }
public static func getRootAsAttacker(bb: ByteBuffer) -> Attacker { return Attacker(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
private init(_ t: Table) { _accessor = t }
@@ -406,11 +407,12 @@
}
public struct HandFan: FlatBufferObject, Verifiable, ObjectAPIPacker {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
- public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: "MOVI", addPrefix: prefix) }
+ public static var id: String { "MOVI" }
+ public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: HandFan.id, addPrefix: prefix) }
public static func getRootAsHandFan(bb: ByteBuffer) -> HandFan { return HandFan(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
private init(_ t: Table) { _accessor = t }
@@ -488,11 +490,12 @@
}
public struct Movie: FlatBufferObject, Verifiable, ObjectAPIPacker {
- static func validateVersion() { FlatBuffersVersion_2_0_0() }
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
- public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: "MOVI", addPrefix: prefix) }
+ public static var id: String { "MOVI" }
+ public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: Movie.id, addPrefix: prefix) }
public static func getRootAsMovie(bb: ByteBuffer) -> Movie { return Movie(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
private init(_ t: Table) { _accessor = t }
@@ -509,8 +512,10 @@
public var mainCharacterType: Character { let o = _accessor.offset(VTOFFSET.mainCharacterType.v); return o == 0 ? .none_ : Character(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) ?? .none_ }
public func mainCharacter<T: FlatbuffersInitializable>(type: T.Type) -> T? { let o = _accessor.offset(VTOFFSET.mainCharacter.v); return o == 0 ? nil : _accessor.union(o) }
+ public var hasCharactersType: Bool { let o = _accessor.offset(VTOFFSET.charactersType.v); return o == 0 ? false : true }
public var charactersTypeCount: Int32 { let o = _accessor.offset(VTOFFSET.charactersType.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func charactersType(at index: Int32) -> Character? { let o = _accessor.offset(VTOFFSET.charactersType.v); return o == 0 ? Character.none_ : Character(rawValue: _accessor.directRead(of: UInt8.self, offset: _accessor.vector(at: o) + index * 1)) }
+ public var hasCharacters: Bool { let o = _accessor.offset(VTOFFSET.characters.v); return o == 0 ? false : true }
public var charactersCount: Int32 { let o = _accessor.offset(VTOFFSET.characters.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func characters<T: FlatbuffersInitializable>(at index: Int32, type: T.Type) -> T? { let o = _accessor.offset(VTOFFSET.characters.v); return o == 0 ? nil : _accessor.directUnion(_accessor.vector(at: o) + index * 4) }
public static func startMovie(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 4) }
diff --git a/tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/vector_has_test_generated.swift b/tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/vector_has_test_generated.swift
new file mode 100644
index 0000000..dc292f3
--- /dev/null
+++ b/tests/swift/tests/Tests/FlatBuffers.Test.SwiftTests/vector_has_test_generated.swift
@@ -0,0 +1,85 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+// swiftlint:disable all
+// swiftformat:disable all
+
+import FlatBuffers
+
+public struct Swift_Tests_Vectors: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_2_0_8() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsVectors(bb: ByteBuffer) -> Swift_Tests_Vectors { return Swift_Tests_Vectors(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case none_ = 4
+ case empty = 6
+ case array = 8
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ public var hasNone: Bool { let o = _accessor.offset(VTOFFSET.none_.v); return o == 0 ? false : true }
+ public var none_Count: Int32 { let o = _accessor.offset(VTOFFSET.none_.v); return o == 0 ? 0 : _accessor.vector(count: o) }
+ public func none_(at index: Int32) -> UInt64 { let o = _accessor.offset(VTOFFSET.none_.v); return o == 0 ? 0 : _accessor.directRead(of: UInt64.self, offset: _accessor.vector(at: o) + index * 8) }
+ public var none_: [UInt64] { return _accessor.getVector(at: VTOFFSET.none_.v) ?? [] }
+ public var hasEmpty: Bool { let o = _accessor.offset(VTOFFSET.empty.v); return o == 0 ? false : true }
+ public var emptyCount: Int32 { let o = _accessor.offset(VTOFFSET.empty.v); return o == 0 ? 0 : _accessor.vector(count: o) }
+ public func empty(at index: Int32) -> UInt64 { let o = _accessor.offset(VTOFFSET.empty.v); return o == 0 ? 0 : _accessor.directRead(of: UInt64.self, offset: _accessor.vector(at: o) + index * 8) }
+ public var empty: [UInt64] { return _accessor.getVector(at: VTOFFSET.empty.v) ?? [] }
+ public var hasArray: Bool { let o = _accessor.offset(VTOFFSET.array.v); return o == 0 ? false : true }
+ public var arrayCount: Int32 { let o = _accessor.offset(VTOFFSET.array.v); return o == 0 ? 0 : _accessor.vector(count: o) }
+ public func array(at index: Int32) -> UInt64 { let o = _accessor.offset(VTOFFSET.array.v); return o == 0 ? 0 : _accessor.directRead(of: UInt64.self, offset: _accessor.vector(at: o) + index * 8) }
+ public var array: [UInt64] { return _accessor.getVector(at: VTOFFSET.array.v) ?? [] }
+ public static func startVectors(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 3) }
+ public static func addVectorOf(none_: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: none_, at: VTOFFSET.none_.p) }
+ public static func addVectorOf(empty: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: empty, at: VTOFFSET.empty.p) }
+ public static func addVectorOf(array: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: array, at: VTOFFSET.array.p) }
+ public static func endVectors(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+ public static func createVectors(
+ _ fbb: inout FlatBufferBuilder,
+ none_VectorOffset none_: Offset = Offset(),
+ emptyVectorOffset empty: Offset = Offset(),
+ arrayVectorOffset array: Offset = Offset()
+ ) -> Offset {
+ let __start = Swift_Tests_Vectors.startVectors(&fbb)
+ Swift_Tests_Vectors.addVectorOf(none_: none_, &fbb)
+ Swift_Tests_Vectors.addVectorOf(empty: empty, &fbb)
+ Swift_Tests_Vectors.addVectorOf(array: array, &fbb)
+ return Swift_Tests_Vectors.endVectors(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.none_.p, fieldName: "none_", required: false, type: ForwardOffset<Vector<UInt64, UInt64>>.self)
+ try _v.visit(field: VTOFFSET.empty.p, fieldName: "empty", required: false, type: ForwardOffset<Vector<UInt64, UInt64>>.self)
+ try _v.visit(field: VTOFFSET.array.p, fieldName: "array", required: false, type: ForwardOffset<Vector<UInt64, UInt64>>.self)
+ _v.finish()
+ }
+}
+
+extension Swift_Tests_Vectors: Encodable {
+
+ enum CodingKeys: String, CodingKey {
+ case none_ = "none"
+ case empty = "empty"
+ case array = "array"
+ }
+ public func encode(to encoder: Encoder) throws {
+ var container = encoder.container(keyedBy: CodingKeys.self)
+ if none_Count > 0 {
+ try container.encodeIfPresent(none_, forKey: .none_)
+ }
+ if emptyCount > 0 {
+ try container.encodeIfPresent(empty, forKey: .empty)
+ }
+ if arrayCount > 0 {
+ try container.encodeIfPresent(array, forKey: .array)
+ }
+ }
+}
+
diff --git a/tests/FlatBuffers.Test.Swift/Tests/LinuxMain.swift b/tests/swift/tests/Tests/LinuxMain.swift
similarity index 100%
rename from tests/FlatBuffers.Test.Swift/Tests/LinuxMain.swift
rename to tests/swift/tests/Tests/LinuxMain.swift
diff --git a/tests/FlatBuffers.Test.Swift/monsterdata_test.mon b/tests/swift/tests/monsterdata_test.mon
similarity index 100%
rename from tests/FlatBuffers.Test.Swift/monsterdata_test.mon
rename to tests/swift/tests/monsterdata_test.mon
Binary files differ
diff --git a/tests/test.cpp b/tests/test.cpp
index 756c0ea..7e05c08 100644
--- a/tests/test.cpp
+++ b/tests/test.cpp
@@ -13,30 +13,44 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <stdint.h>
+
#include <cmath>
+#include <memory>
#include <string>
+#include "evolution_test.h"
#include "flatbuffers/flatbuffers.h"
#include "flatbuffers/idl.h"
#include "flatbuffers/minireflect.h"
#include "flatbuffers/registry.h"
#include "flatbuffers/util.h"
+#include "fuzz_test.h"
+#include "json_test.h"
+#include "monster_test.h"
#include "monster_test_generated.h"
-#include "namespace_test/namespace_test1_generated.h"
-#include "namespace_test/namespace_test2_generated.h"
-#include "optional_scalars_generated.h"
+#include "optional_scalars_test.h"
+#include "native_inline_table_test_generated.h"
+#include "parser_test.h"
+#include "proto_test.h"
+#include "reflection_test.h"
#include "union_vector/union_vector_generated.h"
#if !defined(_MSC_VER) || _MSC_VER >= 1700
# include "arrays_test_generated.h"
-# include "evolution_test/evolution_v1_generated.h"
-# include "evolution_test/evolution_v2_generated.h"
-# include "monster_extra_generated.h"
#endif
-#include "flatbuffers/flexbuffers.h"
+#include "flexbuffers_test.h"
+#include "is_quiet_nan.h"
#include "monster_test_bfbs_generated.h" // Generated using --bfbs-comments --bfbs-builtins --cpp --bfbs-gen-embed
#include "native_type_test_generated.h"
#include "test_assert.h"
+#include "util_test.h"
+
+void FlatBufferBuilderTest();
+
+namespace flatbuffers {
+namespace tests {
+namespace {
// clang-format off
// Check that char* and uint8_t* are interoperable types.
@@ -53,573 +67,12 @@
#endif
// clang-format on
-// Shortcuts for the infinity.
-static const auto infinity_f = std::numeric_limits<float>::infinity();
-static const auto infinity_d = std::numeric_limits<double>::infinity();
-
using namespace MyGame::Example;
-void FlatBufferBuilderTest();
-
-// Include simple random number generator to ensure results will be the
-// same cross platform.
-// http://en.wikipedia.org/wiki/Park%E2%80%93Miller_random_number_generator
-uint32_t lcg_seed = 48271;
-uint32_t lcg_rand() {
- return lcg_seed =
- (static_cast<uint64_t>(lcg_seed) * 279470273UL) % 4294967291UL;
-}
-void lcg_reset() { lcg_seed = 48271; }
-
-std::string test_data_path =
-#ifdef BAZEL_TEST_DATA_PATH
- "../com_github_google_flatbuffers/tests/";
-#else
- "tests/";
-#endif
-
-// example of how to build up a serialized buffer algorithmically:
-flatbuffers::DetachedBuffer CreateFlatBufferTest(std::string &buffer) {
- flatbuffers::FlatBufferBuilder builder;
-
- auto vec = Vec3(1, 2, 3, 0, Color_Red, Test(10, 20));
-
- auto name = builder.CreateString("MyMonster");
-
- unsigned char inv_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
- auto inventory = builder.CreateVector(inv_data, 10);
-
- // Alternatively, create the vector first, and fill in data later:
- // unsigned char *inv_buf = nullptr;
- // auto inventory = builder.CreateUninitializedVector<unsigned char>(
- // 10, &inv_buf);
- // memcpy(inv_buf, inv_data, 10);
-
- Test tests[] = { Test(10, 20), Test(30, 40) };
- auto testv = builder.CreateVectorOfStructs(tests, 2);
-
- // Create a vector of structures from a lambda.
- auto testv2 = builder.CreateVectorOfStructs<Test>(
- 2, [&](size_t i, Test *s) -> void { *s = tests[i]; });
-
- // create monster with very few fields set:
- // (same functionality as CreateMonster below, but sets fields manually)
- flatbuffers::Offset<Monster> mlocs[3];
- auto fred = builder.CreateString("Fred");
- auto barney = builder.CreateString("Barney");
- auto wilma = builder.CreateString("Wilma");
- MonsterBuilder mb1(builder);
- mb1.add_name(fred);
- mlocs[0] = mb1.Finish();
- MonsterBuilder mb2(builder);
- mb2.add_name(barney);
- mb2.add_hp(1000);
- mlocs[1] = mb2.Finish();
- MonsterBuilder mb3(builder);
- mb3.add_name(wilma);
- mlocs[2] = mb3.Finish();
-
- // Create an array of strings. Also test string pooling, and lambdas.
- auto vecofstrings =
- builder.CreateVector<flatbuffers::Offset<flatbuffers::String>>(
- 4,
- [](size_t i, flatbuffers::FlatBufferBuilder *b)
- -> flatbuffers::Offset<flatbuffers::String> {
- static const char *names[] = { "bob", "fred", "bob", "fred" };
- return b->CreateSharedString(names[i]);
- },
- &builder);
-
- // Creating vectors of strings in one convenient call.
- std::vector<std::string> names2;
- names2.push_back("jane");
- names2.push_back("mary");
- auto vecofstrings2 = builder.CreateVectorOfStrings(names2);
-
- // Create many vectors of strings
- std::vector<std::string> manyNames;
- for (auto i = 0; i < 100; i++) { manyNames.push_back("john_doe"); }
- auto manyNamesVec = builder.CreateVectorOfStrings(manyNames);
- TEST_EQ(false, manyNamesVec.IsNull());
- auto manyNamesVec2 =
- builder.CreateVectorOfStrings(manyNames.cbegin(), manyNames.cend());
- TEST_EQ(false, manyNamesVec2.IsNull());
-
- // Create an array of sorted tables, can be used with binary search when read:
- auto vecoftables = builder.CreateVectorOfSortedTables(mlocs, 3);
-
- // Create an array of sorted structs,
- // can be used with binary search when read:
- std::vector<Ability> abilities;
- abilities.push_back(Ability(4, 40));
- abilities.push_back(Ability(3, 30));
- abilities.push_back(Ability(2, 20));
- abilities.push_back(Ability(0, 0));
- auto vecofstructs = builder.CreateVectorOfSortedStructs(&abilities);
-
- flatbuffers::Offset<Stat> mlocs_stats[1];
- auto miss = builder.CreateString("miss");
- StatBuilder mb_miss(builder);
- mb_miss.add_id(miss);
- mb_miss.add_val(0);
- mb_miss.add_count(0); // key
- mlocs_stats[0] = mb_miss.Finish();
- auto vec_of_stats = builder.CreateVectorOfSortedTables(mlocs_stats, 1);
-
- // Create a nested FlatBuffer.
- // Nested FlatBuffers are stored in a ubyte vector, which can be convenient
- // since they can be memcpy'd around much easier than other FlatBuffer
- // values. They have little overhead compared to storing the table directly.
- // As a test, create a mostly empty Monster buffer:
- flatbuffers::FlatBufferBuilder nested_builder;
- auto nmloc = CreateMonster(nested_builder, nullptr, 0, 0,
- nested_builder.CreateString("NestedMonster"));
- FinishMonsterBuffer(nested_builder, nmloc);
- // Now we can store the buffer in the parent. Note that by default, vectors
- // are only aligned to their elements or size field, so in this case if the
- // buffer contains 64-bit elements, they may not be correctly aligned. We fix
- // that with:
- builder.ForceVectorAlignment(nested_builder.GetSize(), sizeof(uint8_t),
- nested_builder.GetBufferMinAlignment());
- // If for whatever reason you don't have the nested_builder available, you
- // can substitute flatbuffers::largest_scalar_t (64-bit) for the alignment, or
- // the largest force_align value in your schema if you're using it.
- auto nested_flatbuffer_vector = builder.CreateVector(
- nested_builder.GetBufferPointer(), nested_builder.GetSize());
-
- // Test a nested FlexBuffer:
- flexbuffers::Builder flexbuild;
- flexbuild.Int(1234);
- flexbuild.Finish();
- auto flex = builder.CreateVector(flexbuild.GetBuffer());
- // Test vector of enums.
- Color colors[] = { Color_Blue, Color_Green };
- // We use this special creation function because we have an array of
- // pre-C++11 (enum class) enums whose size likely is int, yet its declared
- // type in the schema is byte.
- auto vecofcolors = builder.CreateVectorScalarCast<uint8_t, Color>(colors, 2);
-
- // shortcut for creating monster with all fields set:
- auto mloc = CreateMonster(
- builder, &vec, 150, 80, name, inventory, Color_Blue, Any_Monster,
- mlocs[1].Union(), // Store a union.
- testv, vecofstrings, vecoftables, 0, nested_flatbuffer_vector, 0, false,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 3.14159f, 3.0f, 0.0f, vecofstrings2,
- vecofstructs, flex, testv2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- AnyUniqueAliases_NONE, 0, AnyAmbiguousAliases_NONE, 0, vecofcolors,
- MyGame::Example::Race_None, 0, vec_of_stats);
-
- FinishMonsterBuffer(builder, mloc);
-
-// clang-format off
- #ifdef FLATBUFFERS_TEST_VERBOSE
- // print byte data for debugging:
- auto p = builder.GetBufferPointer();
- for (flatbuffers::uoffset_t i = 0; i < builder.GetSize(); i++)
- printf("%d ", p[i]);
- #endif
- // clang-format on
-
- // return the buffer for the caller to use.
- auto bufferpointer =
- reinterpret_cast<const char *>(builder.GetBufferPointer());
- buffer.assign(bufferpointer, bufferpointer + builder.GetSize());
-
- return builder.Release();
-}
-
-// example of accessing a buffer loaded in memory:
-void AccessFlatBufferTest(const uint8_t *flatbuf, size_t length,
- bool pooled = true) {
- // First, verify the buffers integrity (optional)
- flatbuffers::Verifier verifier(flatbuf, length);
- std::vector<uint8_t> flex_reuse_tracker;
- verifier.SetFlexReuseTracker(&flex_reuse_tracker);
- TEST_EQ(VerifyMonsterBuffer(verifier), true);
-
-// clang-format off
- #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
- std::vector<uint8_t> test_buff;
- test_buff.resize(length * 2);
- std::memcpy(&test_buff[0], flatbuf, length);
- std::memcpy(&test_buff[length], flatbuf, length);
-
- flatbuffers::Verifier verifier1(&test_buff[0], length);
- TEST_EQ(VerifyMonsterBuffer(verifier1), true);
- TEST_EQ(verifier1.GetComputedSize(), length);
-
- flatbuffers::Verifier verifier2(&test_buff[length], length);
- TEST_EQ(VerifyMonsterBuffer(verifier2), true);
- TEST_EQ(verifier2.GetComputedSize(), length);
- #endif
- // clang-format on
-
- TEST_EQ(strcmp(MonsterIdentifier(), "MONS"), 0);
- TEST_EQ(MonsterBufferHasIdentifier(flatbuf), true);
- TEST_EQ(strcmp(MonsterExtension(), "mon"), 0);
-
- // Access the buffer from the root.
- auto monster = GetMonster(flatbuf);
-
- TEST_EQ(monster->hp(), 80);
- TEST_EQ(monster->mana(), 150); // default
- TEST_EQ_STR(monster->name()->c_str(), "MyMonster");
- // Can't access the following field, it is deprecated in the schema,
- // which means accessors are not generated:
- // monster.friendly()
-
- auto pos = monster->pos();
- TEST_NOTNULL(pos);
- TEST_EQ(pos->z(), 3);
- TEST_EQ(pos->test3().a(), 10);
- TEST_EQ(pos->test3().b(), 20);
-
- auto inventory = monster->inventory();
- TEST_EQ(VectorLength(inventory), 10UL); // Works even if inventory is null.
- TEST_NOTNULL(inventory);
- unsigned char inv_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
- // Check compatibilty of iterators with STL.
- std::vector<unsigned char> inv_vec(inventory->begin(), inventory->end());
- size_t n = 0;
- for (auto it = inventory->begin(); it != inventory->end(); ++it, ++n) {
- auto indx = it - inventory->begin();
- TEST_EQ(*it, inv_vec.at(indx)); // Use bounds-check.
- TEST_EQ(*it, inv_data[indx]);
- }
- TEST_EQ(n, inv_vec.size());
-
- n = 0;
- for (auto it = inventory->cbegin(); it != inventory->cend(); ++it, ++n) {
- auto indx = it - inventory->cbegin();
- TEST_EQ(*it, inv_vec.at(indx)); // Use bounds-check.
- TEST_EQ(*it, inv_data[indx]);
- }
- TEST_EQ(n, inv_vec.size());
-
- n = 0;
- for (auto it = inventory->rbegin(); it != inventory->rend(); ++it, ++n) {
- auto indx = inventory->rend() - it - 1;
- TEST_EQ(*it, inv_vec.at(indx)); // Use bounds-check.
- TEST_EQ(*it, inv_data[indx]);
- }
- TEST_EQ(n, inv_vec.size());
-
- n = 0;
- for (auto it = inventory->crbegin(); it != inventory->crend(); ++it, ++n) {
- auto indx = inventory->crend() - it - 1;
- TEST_EQ(*it, inv_vec.at(indx)); // Use bounds-check.
- TEST_EQ(*it, inv_data[indx]);
- }
- TEST_EQ(n, inv_vec.size());
-
- TEST_EQ(monster->color(), Color_Blue);
-
- // Example of accessing a union:
- TEST_EQ(monster->test_type(), Any_Monster); // First make sure which it is.
- auto monster2 = reinterpret_cast<const Monster *>(monster->test());
- TEST_NOTNULL(monster2);
- TEST_EQ_STR(monster2->name()->c_str(), "Fred");
-
- // Example of accessing a vector of strings:
- auto vecofstrings = monster->testarrayofstring();
- TEST_EQ(vecofstrings->size(), 4U);
- TEST_EQ_STR(vecofstrings->Get(0)->c_str(), "bob");
- TEST_EQ_STR(vecofstrings->Get(1)->c_str(), "fred");
- if (pooled) {
- // These should have pointer equality because of string pooling.
- TEST_EQ(vecofstrings->Get(0)->c_str(), vecofstrings->Get(2)->c_str());
- TEST_EQ(vecofstrings->Get(1)->c_str(), vecofstrings->Get(3)->c_str());
- }
-
- auto vecofstrings2 = monster->testarrayofstring2();
- if (vecofstrings2) {
- TEST_EQ(vecofstrings2->size(), 2U);
- TEST_EQ_STR(vecofstrings2->Get(0)->c_str(), "jane");
- TEST_EQ_STR(vecofstrings2->Get(1)->c_str(), "mary");
- }
-
- // Example of accessing a vector of tables:
- auto vecoftables = monster->testarrayoftables();
- TEST_EQ(vecoftables->size(), 3U);
- for (auto it = vecoftables->begin(); it != vecoftables->end(); ++it) {
- TEST_EQ(strlen(it->name()->c_str()) >= 4, true);
- }
- TEST_EQ_STR(vecoftables->Get(0)->name()->c_str(), "Barney");
- TEST_EQ(vecoftables->Get(0)->hp(), 1000);
- TEST_EQ_STR(vecoftables->Get(1)->name()->c_str(), "Fred");
- TEST_EQ_STR(vecoftables->Get(2)->name()->c_str(), "Wilma");
- TEST_NOTNULL(vecoftables->LookupByKey("Barney"));
- TEST_NOTNULL(vecoftables->LookupByKey("Fred"));
- TEST_NOTNULL(vecoftables->LookupByKey("Wilma"));
-
- // Test accessing a vector of sorted structs
- auto vecofstructs = monster->testarrayofsortedstruct();
- if (vecofstructs) { // not filled in monster_test.bfbs
- for (flatbuffers::uoffset_t i = 0; i < vecofstructs->size() - 1; i++) {
- auto left = vecofstructs->Get(i);
- auto right = vecofstructs->Get(i + 1);
- TEST_EQ(true, (left->KeyCompareLessThan(right)));
- }
- TEST_NOTNULL(vecofstructs->LookupByKey(0)); // test default value
- TEST_NOTNULL(vecofstructs->LookupByKey(3));
- TEST_EQ(static_cast<const Ability *>(nullptr),
- vecofstructs->LookupByKey(5));
- }
-
- if (auto vec_of_stat = monster->scalar_key_sorted_tables()) {
- auto stat_0 = vec_of_stat->LookupByKey(static_cast<uint16_t>(0u));
- TEST_NOTNULL(stat_0);
- TEST_NOTNULL(stat_0->id());
- TEST_EQ(0, stat_0->count());
- TEST_EQ_STR("miss", stat_0->id()->c_str());
- }
-
- // Test nested FlatBuffers if available:
- auto nested_buffer = monster->testnestedflatbuffer();
- if (nested_buffer) {
- // nested_buffer is a vector of bytes you can memcpy. However, if you
- // actually want to access the nested data, this is a convenient
- // accessor that directly gives you the root table:
- auto nested_monster = monster->testnestedflatbuffer_nested_root();
- TEST_EQ_STR(nested_monster->name()->c_str(), "NestedMonster");
- }
-
- // Test flexbuffer if available:
- auto flex = monster->flex();
- // flex is a vector of bytes you can memcpy etc.
- TEST_EQ(flex->size(), 4); // Encoded FlexBuffer bytes.
- // However, if you actually want to access the nested data, this is a
- // convenient accessor that directly gives you the root value:
- TEST_EQ(monster->flex_flexbuffer_root().AsInt16(), 1234);
-
- // Test vector of enums:
- auto colors = monster->vector_of_enums();
- if (colors) {
- TEST_EQ(colors->size(), 2);
- TEST_EQ(colors->Get(0), Color_Blue);
- TEST_EQ(colors->Get(1), Color_Green);
- }
-
- // Since Flatbuffers uses explicit mechanisms to override the default
- // compiler alignment, double check that the compiler indeed obeys them:
- // (Test consists of a short and byte):
- TEST_EQ(flatbuffers::AlignOf<Test>(), 2UL);
- TEST_EQ(sizeof(Test), 4UL);
-
- const flatbuffers::Vector<const Test *> *tests_array[] = {
- monster->test4(),
- monster->test5(),
- };
- for (size_t i = 0; i < sizeof(tests_array) / sizeof(tests_array[0]); ++i) {
- auto tests = tests_array[i];
- TEST_NOTNULL(tests);
- auto test_0 = tests->Get(0);
- auto test_1 = tests->Get(1);
- TEST_EQ(test_0->a(), 10);
- TEST_EQ(test_0->b(), 20);
- TEST_EQ(test_1->a(), 30);
- TEST_EQ(test_1->b(), 40);
- for (auto it = tests->begin(); it != tests->end(); ++it) {
- TEST_EQ(it->a() == 10 || it->a() == 30, true); // Just testing iterators.
- }
- }
-
- // Checking for presence of fields:
- TEST_EQ(flatbuffers::IsFieldPresent(monster, Monster::VT_HP), true);
- TEST_EQ(flatbuffers::IsFieldPresent(monster, Monster::VT_MANA), false);
-
- // Obtaining a buffer from a root:
- TEST_EQ(GetBufferStartFromRootPointer(monster), flatbuf);
-}
-
-// Change a FlatBuffer in-place, after it has been constructed.
-void MutateFlatBuffersTest(uint8_t *flatbuf, std::size_t length) {
- // Get non-const pointer to root.
- auto monster = GetMutableMonster(flatbuf);
-
- // Each of these tests mutates, then tests, then set back to the original,
- // so we can test that the buffer in the end still passes our original test.
- auto hp_ok = monster->mutate_hp(10);
- TEST_EQ(hp_ok, true); // Field was present.
- TEST_EQ(monster->hp(), 10);
- // Mutate to default value
- auto hp_ok_default = monster->mutate_hp(100);
- TEST_EQ(hp_ok_default, true); // Field was present.
- TEST_EQ(monster->hp(), 100);
- // Test that mutate to default above keeps field valid for further mutations
- auto hp_ok_2 = monster->mutate_hp(20);
- TEST_EQ(hp_ok_2, true);
- TEST_EQ(monster->hp(), 20);
- monster->mutate_hp(80);
-
- // Monster originally at 150 mana (default value)
- auto mana_default_ok = monster->mutate_mana(150); // Mutate to default value.
- TEST_EQ(mana_default_ok,
- true); // Mutation should succeed, because default value.
- TEST_EQ(monster->mana(), 150);
- auto mana_ok = monster->mutate_mana(10);
- TEST_EQ(mana_ok, false); // Field was NOT present, because default value.
- TEST_EQ(monster->mana(), 150);
-
- // Mutate structs.
- auto pos = monster->mutable_pos();
- auto test3 = pos->mutable_test3(); // Struct inside a struct.
- test3.mutate_a(50); // Struct fields never fail.
- TEST_EQ(test3.a(), 50);
- test3.mutate_a(10);
-
- // Mutate vectors.
- auto inventory = monster->mutable_inventory();
- inventory->Mutate(9, 100);
- TEST_EQ(inventory->Get(9), 100);
- inventory->Mutate(9, 9);
-
- auto tables = monster->mutable_testarrayoftables();
- auto first = tables->GetMutableObject(0);
- TEST_EQ(first->hp(), 1000);
- first->mutate_hp(0);
- TEST_EQ(first->hp(), 0);
- first->mutate_hp(1000);
-
- // Mutate via LookupByKey
- TEST_NOTNULL(tables->MutableLookupByKey("Barney"));
- TEST_EQ(static_cast<Monster *>(nullptr),
- tables->MutableLookupByKey("DoesntExist"));
- TEST_EQ(tables->MutableLookupByKey("Barney")->hp(), 1000);
- TEST_EQ(tables->MutableLookupByKey("Barney")->mutate_hp(0), true);
- TEST_EQ(tables->LookupByKey("Barney")->hp(), 0);
- TEST_EQ(tables->MutableLookupByKey("Barney")->mutate_hp(1000), true);
-
- // Run the verifier and the regular test to make sure we didn't trample on
- // anything.
- AccessFlatBufferTest(flatbuf, length);
-}
-
-// Utility function to check a Monster object.
-void CheckMonsterObject(MonsterT *monster2) {
- TEST_EQ(monster2->hp, 80);
- TEST_EQ(monster2->mana, 150); // default
- TEST_EQ_STR(monster2->name.c_str(), "MyMonster");
-
- auto &pos = monster2->pos;
- TEST_NOTNULL(pos);
- TEST_EQ(pos->z(), 3);
- TEST_EQ(pos->test3().a(), 10);
- TEST_EQ(pos->test3().b(), 20);
-
- auto &inventory = monster2->inventory;
- TEST_EQ(inventory.size(), 10UL);
- unsigned char inv_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
- for (auto it = inventory.begin(); it != inventory.end(); ++it)
- TEST_EQ(*it, inv_data[it - inventory.begin()]);
-
- TEST_EQ(monster2->color, Color_Blue);
-
- auto monster3 = monster2->test.AsMonster();
- TEST_NOTNULL(monster3);
- TEST_EQ_STR(monster3->name.c_str(), "Fred");
-
- auto &vecofstrings = monster2->testarrayofstring;
- TEST_EQ(vecofstrings.size(), 4U);
- TEST_EQ_STR(vecofstrings[0].c_str(), "bob");
- TEST_EQ_STR(vecofstrings[1].c_str(), "fred");
-
- auto &vecofstrings2 = monster2->testarrayofstring2;
- TEST_EQ(vecofstrings2.size(), 2U);
- TEST_EQ_STR(vecofstrings2[0].c_str(), "jane");
- TEST_EQ_STR(vecofstrings2[1].c_str(), "mary");
-
- auto &vecoftables = monster2->testarrayoftables;
- TEST_EQ(vecoftables.size(), 3U);
- TEST_EQ_STR(vecoftables[0]->name.c_str(), "Barney");
- TEST_EQ(vecoftables[0]->hp, 1000);
- TEST_EQ_STR(vecoftables[1]->name.c_str(), "Fred");
- TEST_EQ_STR(vecoftables[2]->name.c_str(), "Wilma");
-
- auto &tests = monster2->test4;
- TEST_EQ(tests[0].a(), 10);
- TEST_EQ(tests[0].b(), 20);
- TEST_EQ(tests[1].a(), 30);
- TEST_EQ(tests[1].b(), 40);
-}
-
-// Unpack a FlatBuffer into objects.
-void ObjectFlatBuffersTest(uint8_t *flatbuf) {
- // Optional: we can specify resolver and rehasher functions to turn hashed
- // strings into object pointers and back, to implement remote references
- // and such.
- auto resolver = flatbuffers::resolver_function_t(
- [](void **pointer_adr, flatbuffers::hash_value_t hash) {
- (void)pointer_adr;
- (void)hash;
- // Don't actually do anything, leave variable null.
- });
- auto rehasher = flatbuffers::rehasher_function_t(
- [](void *pointer) -> flatbuffers::hash_value_t {
- (void)pointer;
- return 0;
- });
-
- // Turn a buffer into C++ objects.
- auto monster1 = UnPackMonster(flatbuf, &resolver);
-
- // Re-serialize the data.
- flatbuffers::FlatBufferBuilder fbb1;
- fbb1.Finish(CreateMonster(fbb1, monster1.get(), &rehasher),
- MonsterIdentifier());
-
- // Unpack again, and re-serialize again.
- auto monster2 = UnPackMonster(fbb1.GetBufferPointer(), &resolver);
- flatbuffers::FlatBufferBuilder fbb2;
- fbb2.Finish(CreateMonster(fbb2, monster2.get(), &rehasher),
- MonsterIdentifier());
-
- // Now we've gone full round-trip, the two buffers should match.
- const auto len1 = fbb1.GetSize();
- const auto len2 = fbb2.GetSize();
- TEST_EQ(len1, len2);
- TEST_EQ(memcmp(fbb1.GetBufferPointer(), fbb2.GetBufferPointer(), len1), 0);
-
- // Test it with the original buffer test to make sure all data survived.
- AccessFlatBufferTest(fbb2.GetBufferPointer(), len2, false);
-
- // Test accessing fields, similar to AccessFlatBufferTest above.
- CheckMonsterObject(monster2.get());
-
- // Test object copy.
- auto monster3 = *monster2;
- flatbuffers::FlatBufferBuilder fbb3;
- fbb3.Finish(CreateMonster(fbb3, &monster3, &rehasher), MonsterIdentifier());
- const auto len3 = fbb3.GetSize();
- TEST_EQ(len2, len3);
- TEST_EQ(memcmp(fbb2.GetBufferPointer(), fbb3.GetBufferPointer(), len2), 0);
- // Delete monster1 and monster2, then test accessing fields in monster3.
- monster1.reset();
- monster2.reset();
- CheckMonsterObject(&monster3);
-}
-
-// Prefix a FlatBuffer with a size field.
-void SizePrefixedTest() {
- // Create size prefixed buffer.
- flatbuffers::FlatBufferBuilder fbb;
- FinishSizePrefixedMonsterBuffer(
- fbb, CreateMonster(fbb, 0, 200, 300, fbb.CreateString("bob")));
-
- // Verify it.
- flatbuffers::Verifier verifier(fbb.GetBufferPointer(), fbb.GetSize());
- TEST_EQ(VerifySizePrefixedMonsterBuffer(verifier), true);
-
- // Access it.
- auto m = GetSizePrefixedMonster(fbb.GetBufferPointer());
- TEST_EQ(m->mana(), 200);
- TEST_EQ(m->hp(), 300);
- TEST_EQ_STR(m->name()->c_str(), "bob");
-}
-
void TriviallyCopyableTest() {
// clang-format off
- #if __GNUG__ && __GNUC__ < 5
+ #if __GNUG__ && __GNUC__ < 5 && \
+ !(defined(__clang__) && __clang_major__ >= 16)
TEST_EQ(__has_trivial_copy(Vec3), true);
#else
#if __cplusplus >= 201103L
@@ -629,1693 +82,18 @@
// clang-format on
}
-// Check stringify of an default enum value to json
-void JsonDefaultTest() {
- // load FlatBuffer schema (.fbs) from disk
- std::string schemafile;
- TEST_EQ(flatbuffers::LoadFile((test_data_path + "monster_test.fbs").c_str(),
- false, &schemafile),
- true);
- // parse schema first, so we can use it to parse the data after
- flatbuffers::Parser parser;
- auto include_test_path =
- flatbuffers::ConCatPathFileName(test_data_path, "include_test");
- const char *include_directories[] = { test_data_path.c_str(),
- include_test_path.c_str(), nullptr };
-
- TEST_EQ(parser.Parse(schemafile.c_str(), include_directories), true);
- // create incomplete monster and store to json
- parser.opts.output_default_scalars_in_json = true;
- parser.opts.output_enum_identifiers = true;
- flatbuffers::FlatBufferBuilder builder;
- auto name = builder.CreateString("default_enum");
- MonsterBuilder color_monster(builder);
- color_monster.add_name(name);
- FinishMonsterBuffer(builder, color_monster.Finish());
- std::string jsongen;
- auto result = GenerateText(parser, builder.GetBufferPointer(), &jsongen);
- TEST_EQ(result, true);
- // default value of the "color" field is Blue
- TEST_EQ(std::string::npos != jsongen.find("color: \"Blue\""), true);
- // default value of the "testf" field is 3.14159
- TEST_EQ(std::string::npos != jsongen.find("testf: 3.14159"), true);
-}
-
-void JsonEnumsTest() {
- // load FlatBuffer schema (.fbs) from disk
- std::string schemafile;
- TEST_EQ(flatbuffers::LoadFile((test_data_path + "monster_test.fbs").c_str(),
- false, &schemafile),
- true);
- // parse schema first, so we can use it to parse the data after
- flatbuffers::Parser parser;
- auto include_test_path =
- flatbuffers::ConCatPathFileName(test_data_path, "include_test");
- const char *include_directories[] = { test_data_path.c_str(),
- include_test_path.c_str(), nullptr };
- parser.opts.output_enum_identifiers = true;
- TEST_EQ(parser.Parse(schemafile.c_str(), include_directories), true);
- flatbuffers::FlatBufferBuilder builder;
- auto name = builder.CreateString("bitflag_enum");
- MonsterBuilder color_monster(builder);
- color_monster.add_name(name);
- color_monster.add_color(Color(Color_Blue | Color_Red));
- FinishMonsterBuffer(builder, color_monster.Finish());
- std::string jsongen;
- auto result = GenerateText(parser, builder.GetBufferPointer(), &jsongen);
- TEST_EQ(result, true);
- TEST_EQ(std::string::npos != jsongen.find("color: \"Red Blue\""), true);
- // Test forward compatibility with 'output_enum_identifiers = true'.
- // Current Color doesn't have '(1u << 2)' field, let's add it.
- builder.Clear();
- std::string future_json;
- auto future_name = builder.CreateString("future bitflag_enum");
- MonsterBuilder future_color(builder);
- future_color.add_name(future_name);
- future_color.add_color(
- static_cast<Color>((1u << 2) | Color_Blue | Color_Red));
- FinishMonsterBuffer(builder, future_color.Finish());
- result = GenerateText(parser, builder.GetBufferPointer(), &future_json);
- TEST_EQ(result, true);
- TEST_EQ(std::string::npos != future_json.find("color: 13"), true);
-}
-
-#if defined(FLATBUFFERS_HAS_NEW_STRTOD) && (FLATBUFFERS_HAS_NEW_STRTOD > 0)
-// The IEEE-754 quiet_NaN is not simple binary constant.
-// All binary NaN bit strings have all the bits of the biased exponent field E
-// set to 1. A quiet NaN bit string should be encoded with the first bit d[1]
-// of the trailing significand field T being 1 (d[0] is implicit bit).
-// It is assumed that endianness of floating-point is same as integer.
-template<typename T, typename U, U qnan_base> bool is_quiet_nan_impl(T v) {
- static_assert(sizeof(T) == sizeof(U), "unexpected");
- U b = 0;
- std::memcpy(&b, &v, sizeof(T));
- return ((b & qnan_base) == qnan_base);
-}
-# if defined(__mips__) || defined(__hppa__)
-static bool is_quiet_nan(float v) {
- return is_quiet_nan_impl<float, uint32_t, 0x7FC00000u>(v) ||
- is_quiet_nan_impl<float, uint32_t, 0x7FBFFFFFu>(v);
-}
-static bool is_quiet_nan(double v) {
- return is_quiet_nan_impl<double, uint64_t, 0x7FF8000000000000ul>(v) ||
- is_quiet_nan_impl<double, uint64_t, 0x7FF7FFFFFFFFFFFFu>(v);
-}
-# else
-static bool is_quiet_nan(float v) {
- return is_quiet_nan_impl<float, uint32_t, 0x7FC00000u>(v);
-}
-static bool is_quiet_nan(double v) {
- return is_quiet_nan_impl<double, uint64_t, 0x7FF8000000000000ul>(v);
-}
-# endif
-
-void TestMonsterExtraFloats() {
- TEST_EQ(is_quiet_nan(1.0), false);
- TEST_EQ(is_quiet_nan(infinity_d), false);
- TEST_EQ(is_quiet_nan(-infinity_f), false);
- TEST_EQ(is_quiet_nan(std::numeric_limits<float>::quiet_NaN()), true);
- TEST_EQ(is_quiet_nan(std::numeric_limits<double>::quiet_NaN()), true);
-
- using namespace flatbuffers;
- using namespace MyGame;
- // Load FlatBuffer schema (.fbs) from disk.
- std::string schemafile;
- TEST_EQ(LoadFile((test_data_path + "monster_extra.fbs").c_str(), false,
- &schemafile),
- true);
- // Parse schema first, so we can use it to parse the data after.
- Parser parser;
- auto include_test_path = ConCatPathFileName(test_data_path, "include_test");
- const char *include_directories[] = { test_data_path.c_str(),
- include_test_path.c_str(), nullptr };
- TEST_EQ(parser.Parse(schemafile.c_str(), include_directories), true);
- // Create empty extra and store to json.
- parser.opts.output_default_scalars_in_json = true;
- parser.opts.output_enum_identifiers = true;
- FlatBufferBuilder builder;
- const auto def_root = MonsterExtraBuilder(builder).Finish();
- FinishMonsterExtraBuffer(builder, def_root);
- const auto def_obj = builder.GetBufferPointer();
- const auto def_extra = GetMonsterExtra(def_obj);
- TEST_NOTNULL(def_extra);
- TEST_EQ(is_quiet_nan(def_extra->f0()), true);
- TEST_EQ(is_quiet_nan(def_extra->f1()), true);
- TEST_EQ(def_extra->f2(), +infinity_f);
- TEST_EQ(def_extra->f3(), -infinity_f);
- TEST_EQ(is_quiet_nan(def_extra->d0()), true);
- TEST_EQ(is_quiet_nan(def_extra->d1()), true);
- TEST_EQ(def_extra->d2(), +infinity_d);
- TEST_EQ(def_extra->d3(), -infinity_d);
- std::string jsongen;
- auto result = GenerateText(parser, def_obj, &jsongen);
- TEST_EQ(result, true);
- // Check expected default values.
- TEST_EQ(std::string::npos != jsongen.find("f0: nan"), true);
- TEST_EQ(std::string::npos != jsongen.find("f1: nan"), true);
- TEST_EQ(std::string::npos != jsongen.find("f2: inf"), true);
- TEST_EQ(std::string::npos != jsongen.find("f3: -inf"), true);
- TEST_EQ(std::string::npos != jsongen.find("d0: nan"), true);
- TEST_EQ(std::string::npos != jsongen.find("d1: nan"), true);
- TEST_EQ(std::string::npos != jsongen.find("d2: inf"), true);
- TEST_EQ(std::string::npos != jsongen.find("d3: -inf"), true);
- // Parse 'mosterdata_extra.json'.
- const auto extra_base = test_data_path + "monsterdata_extra";
- jsongen = "";
- TEST_EQ(LoadFile((extra_base + ".json").c_str(), false, &jsongen), true);
- TEST_EQ(parser.Parse(jsongen.c_str()), true);
- const auto test_file = parser.builder_.GetBufferPointer();
- const auto test_size = parser.builder_.GetSize();
- Verifier verifier(test_file, test_size);
- TEST_ASSERT(VerifyMonsterExtraBuffer(verifier));
- const auto extra = GetMonsterExtra(test_file);
- TEST_NOTNULL(extra);
- TEST_EQ(is_quiet_nan(extra->f0()), true);
- TEST_EQ(is_quiet_nan(extra->f1()), true);
- TEST_EQ(extra->f2(), +infinity_f);
- TEST_EQ(extra->f3(), -infinity_f);
- TEST_EQ(is_quiet_nan(extra->d0()), true);
- TEST_EQ(extra->d1(), +infinity_d);
- TEST_EQ(extra->d2(), -infinity_d);
- TEST_EQ(is_quiet_nan(extra->d3()), true);
- TEST_NOTNULL(extra->fvec());
- TEST_EQ(extra->fvec()->size(), 4);
- TEST_EQ(extra->fvec()->Get(0), 1.0f);
- TEST_EQ(extra->fvec()->Get(1), -infinity_f);
- TEST_EQ(extra->fvec()->Get(2), +infinity_f);
- TEST_EQ(is_quiet_nan(extra->fvec()->Get(3)), true);
- TEST_NOTNULL(extra->dvec());
- TEST_EQ(extra->dvec()->size(), 4);
- TEST_EQ(extra->dvec()->Get(0), 2.0);
- TEST_EQ(extra->dvec()->Get(1), +infinity_d);
- TEST_EQ(extra->dvec()->Get(2), -infinity_d);
- TEST_EQ(is_quiet_nan(extra->dvec()->Get(3)), true);
-}
-#else
-void TestMonsterExtraFloats() {}
-#endif
-
-// example of parsing text straight into a buffer, and generating
-// text back from it:
-void ParseAndGenerateTextTest(bool binary) {
- // load FlatBuffer schema (.fbs) and JSON from disk
- std::string schemafile;
- std::string jsonfile;
- TEST_EQ(flatbuffers::LoadFile(
- (test_data_path + "monster_test." + (binary ? "bfbs" : "fbs"))
- .c_str(),
- binary, &schemafile),
- true);
- TEST_EQ(flatbuffers::LoadFile(
- (test_data_path + "monsterdata_test.golden").c_str(), false,
- &jsonfile),
- true);
-
- auto include_test_path =
- flatbuffers::ConCatPathFileName(test_data_path, "include_test");
- const char *include_directories[] = { test_data_path.c_str(),
- include_test_path.c_str(), nullptr };
-
- // parse schema first, so we can use it to parse the data after
- flatbuffers::Parser parser;
- if (binary) {
- flatbuffers::Verifier verifier(
- reinterpret_cast<const uint8_t *>(schemafile.c_str()),
- schemafile.size());
- TEST_EQ(reflection::VerifySchemaBuffer(verifier), true);
- // auto schema = reflection::GetSchema(schemafile.c_str());
- TEST_EQ(parser.Deserialize((const uint8_t *)schemafile.c_str(),
- schemafile.size()),
- true);
- } else {
- TEST_EQ(parser.Parse(schemafile.c_str(), include_directories), true);
- }
- TEST_EQ(parser.ParseJson(jsonfile.c_str()), true);
-
- // here, parser.builder_ contains a binary buffer that is the parsed data.
-
- // First, verify it, just in case:
- flatbuffers::Verifier verifier(parser.builder_.GetBufferPointer(),
- parser.builder_.GetSize());
- TEST_EQ(VerifyMonsterBuffer(verifier), true);
-
- AccessFlatBufferTest(parser.builder_.GetBufferPointer(),
- parser.builder_.GetSize(), false);
-
- // to ensure it is correct, we now generate text back from the binary,
- // and compare the two:
- std::string jsongen;
- auto result =
- GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen);
- TEST_EQ(result, true);
- TEST_EQ_STR(jsongen.c_str(), jsonfile.c_str());
-
- // We can also do the above using the convenient Registry that knows about
- // a set of file_identifiers mapped to schemas.
- flatbuffers::Registry registry;
- // Make sure schemas can find their includes.
- registry.AddIncludeDirectory(test_data_path.c_str());
- registry.AddIncludeDirectory(include_test_path.c_str());
- // Call this with many schemas if possible.
- registry.Register(MonsterIdentifier(),
- (test_data_path + "monster_test.fbs").c_str());
- // Now we got this set up, we can parse by just specifying the identifier,
- // the correct schema will be loaded on the fly:
- auto buf = registry.TextToFlatBuffer(jsonfile.c_str(), MonsterIdentifier());
- // If this fails, check registry.lasterror_.
- TEST_NOTNULL(buf.data());
- // Test the buffer, to be sure:
- AccessFlatBufferTest(buf.data(), buf.size(), false);
- // We can use the registry to turn this back into text, in this case it
- // will get the file_identifier from the binary:
- std::string text;
- auto ok = registry.FlatBufferToText(buf.data(), buf.size(), &text);
- // If this fails, check registry.lasterror_.
- TEST_EQ(ok, true);
- TEST_EQ_STR(text.c_str(), jsonfile.c_str());
-
- // Generate text for UTF-8 strings without escapes.
- std::string jsonfile_utf8;
- TEST_EQ(flatbuffers::LoadFile((test_data_path + "unicode_test.json").c_str(),
- false, &jsonfile_utf8),
- true);
- TEST_EQ(parser.Parse(jsonfile_utf8.c_str(), include_directories), true);
- // To ensure it is correct, generate utf-8 text back from the binary.
- std::string jsongen_utf8;
- // request natural printing for utf-8 strings
- parser.opts.natural_utf8 = true;
- parser.opts.strict_json = true;
- TEST_EQ(
- GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen_utf8),
- true);
- TEST_EQ_STR(jsongen_utf8.c_str(), jsonfile_utf8.c_str());
-}
-
-void ReflectionTest(uint8_t *flatbuf, size_t length) {
- // Load a binary schema.
- std::string bfbsfile;
- TEST_EQ(flatbuffers::LoadFile((test_data_path + "monster_test.bfbs").c_str(),
- true, &bfbsfile),
- true);
-
- // Verify it, just in case:
- flatbuffers::Verifier verifier(
- reinterpret_cast<const uint8_t *>(bfbsfile.c_str()), bfbsfile.length());
- TEST_EQ(reflection::VerifySchemaBuffer(verifier), true);
-
- // Make sure the schema is what we expect it to be.
- auto &schema = *reflection::GetSchema(bfbsfile.c_str());
- auto root_table = schema.root_table();
-
- // Check the declaration files.
- TEST_EQ_STR(root_table->name()->c_str(), "MyGame.Example.Monster");
- TEST_EQ_STR(root_table->declaration_file()->c_str(), "//monster_test.fbs");
- TEST_EQ_STR(
- schema.objects()->LookupByKey("TableA")->declaration_file()->c_str(),
- "//include_test/include_test1.fbs");
- TEST_EQ_STR(schema.objects()
- ->LookupByKey("MyGame.OtherNameSpace.Unused")
- ->declaration_file()
- ->c_str(),
- "//include_test/sub/include_test2.fbs");
- TEST_EQ_STR(schema.enums()
- ->LookupByKey("MyGame.OtherNameSpace.FromInclude")
- ->declaration_file()
- ->c_str(),
- "//include_test/sub/include_test2.fbs");
-
- // Check scheam filenames and their includes.
- TEST_EQ(schema.fbs_files()->size(), 3);
-
- const auto fbs0 = schema.fbs_files()->Get(0);
- TEST_EQ_STR(fbs0->filename()->c_str(), "//include_test/include_test1.fbs");
- const auto fbs0_includes = fbs0->included_filenames();
- TEST_EQ(fbs0_includes->size(), 2);
-
- // TODO(caspern): Should we force or disallow inclusion of self?
- TEST_EQ_STR(fbs0_includes->Get(0)->c_str(),
- "//include_test/include_test1.fbs");
- TEST_EQ_STR(fbs0_includes->Get(1)->c_str(),
- "//include_test/sub/include_test2.fbs");
-
- const auto fbs1 = schema.fbs_files()->Get(1);
- TEST_EQ_STR(fbs1->filename()->c_str(),
- "//include_test/sub/include_test2.fbs");
- const auto fbs1_includes = fbs1->included_filenames();
- TEST_EQ(fbs1_includes->size(), 2);
- TEST_EQ_STR(fbs1_includes->Get(0)->c_str(),
- "//include_test/include_test1.fbs");
- TEST_EQ_STR(fbs1_includes->Get(1)->c_str(),
- "//include_test/sub/include_test2.fbs");
-
- const auto fbs2 = schema.fbs_files()->Get(2);
- TEST_EQ_STR(fbs2->filename()->c_str(), "//monster_test.fbs");
- const auto fbs2_includes = fbs2->included_filenames();
- TEST_EQ(fbs2_includes->size(), 1);
- TEST_EQ_STR(fbs2_includes->Get(0)->c_str(),
- "//include_test/include_test1.fbs");
-
- // Check Root table fields
- auto fields = root_table->fields();
- auto hp_field_ptr = fields->LookupByKey("hp");
- TEST_NOTNULL(hp_field_ptr);
- auto &hp_field = *hp_field_ptr;
- TEST_EQ_STR(hp_field.name()->c_str(), "hp");
- TEST_EQ(hp_field.id(), 2);
- TEST_EQ(hp_field.type()->base_type(), reflection::Short);
-
- auto friendly_field_ptr = fields->LookupByKey("friendly");
- TEST_NOTNULL(friendly_field_ptr);
- TEST_NOTNULL(friendly_field_ptr->attributes());
- TEST_NOTNULL(friendly_field_ptr->attributes()->LookupByKey("priority"));
-
- // Make sure the table index is what we expect it to be.
- auto pos_field_ptr = fields->LookupByKey("pos");
- TEST_NOTNULL(pos_field_ptr);
- TEST_EQ(pos_field_ptr->type()->base_type(), reflection::Obj);
- auto pos_table_ptr = schema.objects()->Get(pos_field_ptr->type()->index());
- TEST_NOTNULL(pos_table_ptr);
- TEST_EQ_STR(pos_table_ptr->name()->c_str(), "MyGame.Example.Vec3");
-
- // Test nullability of fields: hp is a 0-default scalar, pos is a struct =>
- // optional, and name is a required string => not optional.
- TEST_EQ(hp_field.optional(), false);
- TEST_EQ(pos_field_ptr->optional(), true);
- TEST_EQ(fields->LookupByKey("name")->optional(), false);
-
- // Now use it to dynamically access a buffer.
- auto &root = *flatbuffers::GetAnyRoot(flatbuf);
-
- // Verify the buffer first using reflection based verification
- TEST_EQ(flatbuffers::Verify(schema, *schema.root_table(), flatbuf, length),
- true);
-
- auto hp = flatbuffers::GetFieldI<uint16_t>(root, hp_field);
- TEST_EQ(hp, 80);
-
- // Rather than needing to know the type, we can also get the value of
- // any field as an int64_t/double/string, regardless of what it actually is.
- auto hp_int64 = flatbuffers::GetAnyFieldI(root, hp_field);
- TEST_EQ(hp_int64, 80);
- auto hp_double = flatbuffers::GetAnyFieldF(root, hp_field);
- TEST_EQ(hp_double, 80.0);
- auto hp_string = flatbuffers::GetAnyFieldS(root, hp_field, &schema);
- TEST_EQ_STR(hp_string.c_str(), "80");
-
- // Get struct field through reflection
- auto pos_struct = flatbuffers::GetFieldStruct(root, *pos_field_ptr);
- TEST_NOTNULL(pos_struct);
- TEST_EQ(flatbuffers::GetAnyFieldF(*pos_struct,
- *pos_table_ptr->fields()->LookupByKey("z")),
- 3.0f);
-
- auto test3_field = pos_table_ptr->fields()->LookupByKey("test3");
- auto test3_struct = flatbuffers::GetFieldStruct(*pos_struct, *test3_field);
- TEST_NOTNULL(test3_struct);
- auto test3_object = schema.objects()->Get(test3_field->type()->index());
-
- TEST_EQ(flatbuffers::GetAnyFieldF(*test3_struct,
- *test3_object->fields()->LookupByKey("a")),
- 10);
-
- // We can also modify it.
- flatbuffers::SetField<uint16_t>(&root, hp_field, 200);
- hp = flatbuffers::GetFieldI<uint16_t>(root, hp_field);
- TEST_EQ(hp, 200);
-
- // We can also set fields generically:
- flatbuffers::SetAnyFieldI(&root, hp_field, 300);
- hp_int64 = flatbuffers::GetAnyFieldI(root, hp_field);
- TEST_EQ(hp_int64, 300);
- flatbuffers::SetAnyFieldF(&root, hp_field, 300.5);
- hp_int64 = flatbuffers::GetAnyFieldI(root, hp_field);
- TEST_EQ(hp_int64, 300);
- flatbuffers::SetAnyFieldS(&root, hp_field, "300");
- hp_int64 = flatbuffers::GetAnyFieldI(root, hp_field);
- TEST_EQ(hp_int64, 300);
-
- // Test buffer is valid after the modifications
- TEST_EQ(flatbuffers::Verify(schema, *schema.root_table(), flatbuf, length),
- true);
-
- // Reset it, for further tests.
- flatbuffers::SetField<uint16_t>(&root, hp_field, 80);
-
- // More advanced functionality: changing the size of items in-line!
- // First we put the FlatBuffer inside an std::vector.
- std::vector<uint8_t> resizingbuf(flatbuf, flatbuf + length);
- // Find the field we want to modify.
- auto &name_field = *fields->LookupByKey("name");
- // Get the root.
- // This time we wrap the result from GetAnyRoot in a smartpointer that
- // will keep rroot valid as resizingbuf resizes.
- auto rroot = flatbuffers::piv(flatbuffers::GetAnyRoot(resizingbuf.data()),
- resizingbuf);
- SetString(schema, "totally new string", GetFieldS(**rroot, name_field),
- &resizingbuf);
- // Here resizingbuf has changed, but rroot is still valid.
- TEST_EQ_STR(GetFieldS(**rroot, name_field)->c_str(), "totally new string");
- // Now lets extend a vector by 100 elements (10 -> 110).
- auto &inventory_field = *fields->LookupByKey("inventory");
- auto rinventory = flatbuffers::piv(
- flatbuffers::GetFieldV<uint8_t>(**rroot, inventory_field), resizingbuf);
- flatbuffers::ResizeVector<uint8_t>(schema, 110, 50, *rinventory,
- &resizingbuf);
- // rinventory still valid, so lets read from it.
- TEST_EQ(rinventory->Get(10), 50);
-
- // For reflection uses not covered already, there is a more powerful way:
- // we can simply generate whatever object we want to add/modify in a
- // FlatBuffer of its own, then add that to an existing FlatBuffer:
- // As an example, let's add a string to an array of strings.
- // First, find our field:
- auto &testarrayofstring_field = *fields->LookupByKey("testarrayofstring");
- // Find the vector value:
- auto rtestarrayofstring = flatbuffers::piv(
- flatbuffers::GetFieldV<flatbuffers::Offset<flatbuffers::String>>(
- **rroot, testarrayofstring_field),
- resizingbuf);
- // It's a vector of 2 strings, to which we add one more, initialized to
- // offset 0.
- flatbuffers::ResizeVector<flatbuffers::Offset<flatbuffers::String>>(
- schema, 3, 0, *rtestarrayofstring, &resizingbuf);
- // Here we just create a buffer that contans a single string, but this
- // could also be any complex set of tables and other values.
- flatbuffers::FlatBufferBuilder stringfbb;
- stringfbb.Finish(stringfbb.CreateString("hank"));
- // Add the contents of it to our existing FlatBuffer.
- // We do this last, so the pointer doesn't get invalidated (since it is
- // at the end of the buffer):
- auto string_ptr = flatbuffers::AddFlatBuffer(
- resizingbuf, stringfbb.GetBufferPointer(), stringfbb.GetSize());
- // Finally, set the new value in the vector.
- rtestarrayofstring->MutateOffset(2, string_ptr);
- TEST_EQ_STR(rtestarrayofstring->Get(0)->c_str(), "bob");
- TEST_EQ_STR(rtestarrayofstring->Get(2)->c_str(), "hank");
- // Test integrity of all resize operations above.
- flatbuffers::Verifier resize_verifier(
- reinterpret_cast<const uint8_t *>(resizingbuf.data()),
- resizingbuf.size());
- TEST_EQ(VerifyMonsterBuffer(resize_verifier), true);
-
- // Test buffer is valid using reflection as well
- TEST_EQ(flatbuffers::Verify(schema, *schema.root_table(), resizingbuf.data(),
- resizingbuf.size()),
- true);
-
- // As an additional test, also set it on the name field.
- // Note: unlike the name change above, this just overwrites the offset,
- // rather than changing the string in-place.
- SetFieldT(*rroot, name_field, string_ptr);
- TEST_EQ_STR(GetFieldS(**rroot, name_field)->c_str(), "hank");
-
- // Using reflection, rather than mutating binary FlatBuffers, we can also copy
- // tables and other things out of other FlatBuffers into a FlatBufferBuilder,
- // either part or whole.
- flatbuffers::FlatBufferBuilder fbb;
- auto root_offset = flatbuffers::CopyTable(
- fbb, schema, *root_table, *flatbuffers::GetAnyRoot(flatbuf), true);
- fbb.Finish(root_offset, MonsterIdentifier());
- // Test that it was copied correctly:
- AccessFlatBufferTest(fbb.GetBufferPointer(), fbb.GetSize());
-
- // Test buffer is valid using reflection as well
- TEST_EQ(flatbuffers::Verify(schema, *schema.root_table(),
- fbb.GetBufferPointer(), fbb.GetSize()),
- true);
-}
-
-void MiniReflectFlatBuffersTest(uint8_t *flatbuf) {
- auto s =
- flatbuffers::FlatBufferToString(flatbuf, Monster::MiniReflectTypeTable());
- TEST_EQ_STR(
- s.c_str(),
- "{ "
- "pos: { x: 1.0, y: 2.0, z: 3.0, test1: 0.0, test2: Red, test3: "
- "{ a: 10, b: 20 } }, "
- "hp: 80, "
- "name: \"MyMonster\", "
- "inventory: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], "
- "test_type: Monster, "
- "test: { name: \"Fred\" }, "
- "test4: [ { a: 10, b: 20 }, { a: 30, b: 40 } ], "
- "testarrayofstring: [ \"bob\", \"fred\", \"bob\", \"fred\" ], "
- "testarrayoftables: [ { hp: 1000, name: \"Barney\" }, { name: \"Fred\" "
- "}, "
- "{ name: \"Wilma\" } ], "
- // TODO(wvo): should really print this nested buffer correctly.
- "testnestedflatbuffer: [ 20, 0, 0, 0, 77, 79, 78, 83, 12, 0, 12, 0, 0, "
- "0, "
- "4, 0, 6, 0, 8, 0, 12, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 13, 0, 0, 0, 78, "
- "101, 115, 116, 101, 100, 77, 111, 110, 115, 116, 101, 114, 0, 0, 0 ], "
- "testarrayofstring2: [ \"jane\", \"mary\" ], "
- "testarrayofsortedstruct: [ { id: 0, distance: 0 }, "
- "{ id: 2, distance: 20 }, { id: 3, distance: 30 }, "
- "{ id: 4, distance: 40 } ], "
- "flex: [ 210, 4, 5, 2 ], "
- "test5: [ { a: 10, b: 20 }, { a: 30, b: 40 } ], "
- "vector_of_enums: [ Blue, Green ], "
- "scalar_key_sorted_tables: [ { id: \"miss\" } ] "
- "}");
-
- Test test(16, 32);
- Vec3 vec(1, 2, 3, 1.5, Color_Red, test);
- flatbuffers::FlatBufferBuilder vec_builder;
- vec_builder.Finish(vec_builder.CreateStruct(vec));
- auto vec_buffer = vec_builder.Release();
- auto vec_str = flatbuffers::FlatBufferToString(vec_buffer.data(),
- Vec3::MiniReflectTypeTable());
- TEST_EQ_STR(vec_str.c_str(),
- "{ x: 1.0, y: 2.0, z: 3.0, test1: 1.5, test2: Red, test3: { a: "
- "16, b: 32 } }");
-}
-
-void MiniReflectFixedLengthArrayTest() {
- // VS10 does not support typed enums, exclude from tests
-#if !defined(_MSC_VER) || _MSC_VER >= 1700
- flatbuffers::FlatBufferBuilder fbb;
- MyGame::Example::ArrayStruct aStruct(2, 12, 1);
- auto aTable = MyGame::Example::CreateArrayTable(fbb, &aStruct);
- fbb.Finish(aTable);
-
- auto flatbuf = fbb.Release();
- auto s = flatbuffers::FlatBufferToString(
- flatbuf.data(), MyGame::Example::ArrayTableTypeTable());
- TEST_EQ_STR(
- "{ "
- "a: { a: 2.0, "
- "b: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], "
- "c: 12, "
- "d: [ { a: [ 0, 0 ], b: A, c: [ A, A ], d: [ 0, 0 ] }, "
- "{ a: [ 0, 0 ], b: A, c: [ A, A ], d: [ 0, 0 ] } ], "
- "e: 1, f: [ 0, 0 ] } "
- "}",
- s.c_str());
-#endif
-}
-
-// Parse a .proto schema, output as .fbs
-void ParseProtoTest() {
- // load the .proto and the golden file from disk
- std::string protofile;
- std::string goldenfile;
- std::string goldenunionfile;
- TEST_EQ(
- flatbuffers::LoadFile((test_data_path + "prototest/test.proto").c_str(),
- false, &protofile),
- true);
- TEST_EQ(
- flatbuffers::LoadFile((test_data_path + "prototest/test.golden").c_str(),
- false, &goldenfile),
- true);
- TEST_EQ(flatbuffers::LoadFile(
- (test_data_path + "prototest/test_union.golden").c_str(), false,
- &goldenunionfile),
- true);
-
- flatbuffers::IDLOptions opts;
- opts.include_dependence_headers = false;
- opts.proto_mode = true;
-
- // Parse proto.
- flatbuffers::Parser parser(opts);
- auto protopath = test_data_path + "prototest/";
- const char *include_directories[] = { protopath.c_str(), nullptr };
- TEST_EQ(parser.Parse(protofile.c_str(), include_directories), true);
-
- // Generate fbs.
- auto fbs = flatbuffers::GenerateFBS(parser, "test");
-
- // Ensure generated file is parsable.
- flatbuffers::Parser parser2;
- TEST_EQ(parser2.Parse(fbs.c_str(), nullptr), true);
- TEST_EQ_STR(fbs.c_str(), goldenfile.c_str());
-
- // Parse proto with --oneof-union option.
- opts.proto_oneof_union = true;
- flatbuffers::Parser parser3(opts);
- TEST_EQ(parser3.Parse(protofile.c_str(), include_directories), true);
-
- // Generate fbs.
- auto fbs_union = flatbuffers::GenerateFBS(parser3, "test");
-
- // Ensure generated file is parsable.
- flatbuffers::Parser parser4;
- TEST_EQ(parser4.Parse(fbs_union.c_str(), nullptr), true);
- TEST_EQ_STR(fbs_union.c_str(), goldenunionfile.c_str());
-}
-
-// Parse a .proto schema, output as .fbs
-void ParseProtoTestWithSuffix() {
- // load the .proto and the golden file from disk
- std::string protofile;
- std::string goldenfile;
- std::string goldenunionfile;
- TEST_EQ(
- flatbuffers::LoadFile((test_data_path + "prototest/test.proto").c_str(),
- false, &protofile),
- true);
- TEST_EQ(flatbuffers::LoadFile(
- (test_data_path + "prototest/test_suffix.golden").c_str(), false,
- &goldenfile),
- true);
- TEST_EQ(flatbuffers::LoadFile(
- (test_data_path + "prototest/test_union_suffix.golden").c_str(),
- false, &goldenunionfile),
- true);
-
- flatbuffers::IDLOptions opts;
- opts.include_dependence_headers = false;
- opts.proto_mode = true;
- opts.proto_namespace_suffix = "test_namespace_suffix";
-
- // Parse proto.
- flatbuffers::Parser parser(opts);
- auto protopath = test_data_path + "prototest/";
- const char *include_directories[] = { protopath.c_str(), nullptr };
- TEST_EQ(parser.Parse(protofile.c_str(), include_directories), true);
-
- // Generate fbs.
- auto fbs = flatbuffers::GenerateFBS(parser, "test");
-
- // Ensure generated file is parsable.
- flatbuffers::Parser parser2;
- TEST_EQ(parser2.Parse(fbs.c_str(), nullptr), true);
- TEST_EQ_STR(fbs.c_str(), goldenfile.c_str());
-
- // Parse proto with --oneof-union option.
- opts.proto_oneof_union = true;
- flatbuffers::Parser parser3(opts);
- TEST_EQ(parser3.Parse(protofile.c_str(), include_directories), true);
-
- // Generate fbs.
- auto fbs_union = flatbuffers::GenerateFBS(parser3, "test");
-
- // Ensure generated file is parsable.
- flatbuffers::Parser parser4;
- TEST_EQ(parser4.Parse(fbs_union.c_str(), nullptr), true);
- TEST_EQ_STR(fbs_union.c_str(), goldenunionfile.c_str());
-}
-
-// Parse a .proto schema, output as .fbs
-void ParseProtoTestWithIncludes() {
- // load the .proto and the golden file from disk
- std::string protofile;
- std::string goldenfile;
- std::string goldenunionfile;
- std::string importprotofile;
- TEST_EQ(
- flatbuffers::LoadFile((test_data_path + "prototest/test.proto").c_str(),
- false, &protofile),
- true);
- TEST_EQ(flatbuffers::LoadFile(
- (test_data_path + "prototest/imported.proto").c_str(), false,
- &importprotofile),
- true);
- TEST_EQ(flatbuffers::LoadFile(
- (test_data_path + "prototest/test_include.golden").c_str(), false,
- &goldenfile),
- true);
- TEST_EQ(flatbuffers::LoadFile(
- (test_data_path + "prototest/test_union_include.golden").c_str(),
- false, &goldenunionfile),
- true);
-
- flatbuffers::IDLOptions opts;
- opts.include_dependence_headers = true;
- opts.proto_mode = true;
-
- // Parse proto.
- flatbuffers::Parser parser(opts);
- auto protopath = test_data_path + "prototest/";
- const char *include_directories[] = { protopath.c_str(), nullptr };
- TEST_EQ(parser.Parse(protofile.c_str(), include_directories), true);
-
- // Generate fbs.
- auto fbs = flatbuffers::GenerateFBS(parser, "test");
-
- // Generate fbs from import.proto
- flatbuffers::Parser import_parser(opts);
- TEST_EQ(import_parser.Parse(importprotofile.c_str(), include_directories),
- true);
- auto import_fbs = flatbuffers::GenerateFBS(import_parser, "test");
-
- // Ensure generated file is parsable.
- flatbuffers::Parser parser2;
- // Since `imported.fbs` isn't in the filesystem AbsolutePath can't figure it
- // out by itself. We manually construct it so Parser works.
- std::string imported_fbs = flatbuffers::PosixPath(
- flatbuffers::AbsolutePath(protopath) + "/imported.fbs");
- TEST_EQ(parser2.Parse(import_fbs.c_str(), include_directories,
- imported_fbs.c_str()),
- true);
- TEST_EQ(parser2.Parse(fbs.c_str(), nullptr), true);
- TEST_EQ_STR(fbs.c_str(), goldenfile.c_str());
-
- // Parse proto with --oneof-union option.
- opts.proto_oneof_union = true;
- flatbuffers::Parser parser3(opts);
- TEST_EQ(parser3.Parse(protofile.c_str(), include_directories), true);
-
- // Generate fbs.
- auto fbs_union = flatbuffers::GenerateFBS(parser3, "test");
-
- // Ensure generated file is parsable.
- flatbuffers::Parser parser4;
- TEST_EQ(parser4.Parse(import_fbs.c_str(), nullptr, imported_fbs.c_str()),
- true);
- TEST_EQ(parser4.Parse(fbs_union.c_str(), nullptr), true);
- TEST_EQ_STR(fbs_union.c_str(), goldenunionfile.c_str());
-}
-
-template<typename T>
-void CompareTableFieldValue(flatbuffers::Table *table,
- flatbuffers::voffset_t voffset, T val) {
- T read = table->GetField(voffset, static_cast<T>(0));
- TEST_EQ(read, val);
-}
-
-void UtilConvertCase() {
- {
- std::vector<std::tuple<std::string, flatbuffers::Case, std::string>>
- cases = {
- // Tests for the common cases
- { "the_quick_brown_fox", flatbuffers::Case::kUpperCamel,
- "TheQuickBrownFox" },
- { "the_quick_brown_fox", flatbuffers::Case::kLowerCamel,
- "theQuickBrownFox" },
- { "the_quick_brown_fox", flatbuffers::Case::kSnake,
- "the_quick_brown_fox" },
- { "the_quick_brown_fox", flatbuffers::Case::kScreamingSnake,
- "THE_QUICK_BROWN_FOX" },
- { "the_quick_brown_fox", flatbuffers::Case::kAllLower,
- "the_quick_brown_fox" },
- { "the_quick_brown_fox", flatbuffers::Case::kAllUpper,
- "THE_QUICK_BROWN_FOX" },
- { "the_quick_brown_fox", flatbuffers::Case::kUnknown,
- "the_quick_brown_fox" },
- { "the_quick_brown_fox", flatbuffers::Case::kKeep,
- "the_quick_brown_fox" },
-
- // Tests for some snake_cases where the _ is oddly placed or missing.
- { "single", flatbuffers::Case::kUpperCamel, "Single" },
- { "Single", flatbuffers::Case::kUpperCamel, "Single" },
- { "_leading", flatbuffers::Case::kUpperCamel, "_leading" },
- { "trailing_", flatbuffers::Case::kUpperCamel, "Trailing_" },
- { "double__underscore", flatbuffers::Case::kUpperCamel,
- "Double_underscore" },
- { "single", flatbuffers::Case::kLowerCamel, "single" },
- { "Single", flatbuffers::Case::kLowerCamel, "Single" },
- { "_leading", flatbuffers::Case::kLowerCamel, "Leading" },
- { "trailing_", flatbuffers::Case::kLowerCamel, "trailing_" },
- { "double__underscore", flatbuffers::Case::kLowerCamel,
- "double_underscore" },
-
- // Tests for some output snake_cases
- { "single", flatbuffers::Case::kSnake, "single" },
- { "single", flatbuffers::Case::kScreamingSnake, "SINGLE" },
- { "_leading", flatbuffers::Case::kScreamingSnake, "_LEADING" },
- { "trailing_", flatbuffers::Case::kScreamingSnake, "TRAILING_" },
- { "double__underscore", flatbuffers::Case::kScreamingSnake,
- "DOUBLE__UNDERSCORE" },
- };
-
- for (auto &test_case : cases) {
- TEST_EQ(std::get<2>(test_case),
- flatbuffers::ConvertCase(std::get<0>(test_case),
- std::get<1>(test_case)));
- }
- }
-
- // Tests for the non snake_case inputs.
- {
- std::vector<std::tuple<flatbuffers::Case, std::string, flatbuffers::Case,
- std::string>>
- cases = {
- { flatbuffers::Case::kUpperCamel, "TheQuickBrownFox",
- flatbuffers::Case::kSnake, "the_quick_brown_fox" },
- { flatbuffers::Case::kLowerCamel, "theQuickBrownFox",
- flatbuffers::Case::kSnake, "the_quick_brown_fox" },
- { flatbuffers::Case::kSnake, "the_quick_brown_fox",
- flatbuffers::Case::kSnake, "the_quick_brown_fox" },
- { flatbuffers::Case::kScreamingSnake, "THE_QUICK_BROWN_FOX",
- flatbuffers::Case::kSnake, "THE_QUICK_BROWN_FOX" },
- { flatbuffers::Case::kAllUpper, "SINGLE", flatbuffers::Case::kSnake,
- "SINGLE" },
- { flatbuffers::Case::kAllLower, "single", flatbuffers::Case::kSnake,
- "single" },
- { flatbuffers::Case::kUpperCamel, "ABCtest",
- flatbuffers::Case::kSnake, "abctest" },
- { flatbuffers::Case::kUpperCamel, "tHe_qUiCk_BrOwN_fOx",
- flatbuffers::Case::kKeep, "tHe_qUiCk_BrOwN_fOx" },
- };
-
- for (auto &test_case : cases) {
- TEST_EQ(std::get<3>(test_case),
- flatbuffers::ConvertCase(std::get<1>(test_case),
- std::get<2>(test_case),
- std::get<0>(test_case)));
- }
- }
-}
-
-// Low level stress/fuzz test: serialize/deserialize a variety of
-// different kinds of data in different combinations
-void FuzzTest1() {
- // Values we're testing against: chosen to ensure no bits get chopped
- // off anywhere, and also be different from eachother.
- const uint8_t bool_val = true;
- const int8_t char_val = -127; // 0x81
- const uint8_t uchar_val = 0xFF;
- const int16_t short_val = -32222; // 0x8222;
- const uint16_t ushort_val = 0xFEEE;
- const int32_t int_val = 0x83333333;
- const uint32_t uint_val = 0xFDDDDDDD;
- const int64_t long_val = 0x8444444444444444LL;
- const uint64_t ulong_val = 0xFCCCCCCCCCCCCCCCULL;
- const float float_val = 3.14159f;
- const double double_val = 3.14159265359;
-
- const int test_values_max = 11;
- const flatbuffers::voffset_t fields_per_object = 4;
- const int num_fuzz_objects = 10000; // The higher, the more thorough :)
-
- flatbuffers::FlatBufferBuilder builder;
-
- lcg_reset(); // Keep it deterministic.
-
- flatbuffers::uoffset_t objects[num_fuzz_objects];
-
- // Generate num_fuzz_objects random objects each consisting of
- // fields_per_object fields, each of a random type.
- for (int i = 0; i < num_fuzz_objects; i++) {
- auto start = builder.StartTable();
- for (flatbuffers::voffset_t f = 0; f < fields_per_object; f++) {
- int choice = lcg_rand() % test_values_max;
- auto off = flatbuffers::FieldIndexToOffset(f);
- switch (choice) {
- case 0: builder.AddElement<uint8_t>(off, bool_val, 0); break;
- case 1: builder.AddElement<int8_t>(off, char_val, 0); break;
- case 2: builder.AddElement<uint8_t>(off, uchar_val, 0); break;
- case 3: builder.AddElement<int16_t>(off, short_val, 0); break;
- case 4: builder.AddElement<uint16_t>(off, ushort_val, 0); break;
- case 5: builder.AddElement<int32_t>(off, int_val, 0); break;
- case 6: builder.AddElement<uint32_t>(off, uint_val, 0); break;
- case 7: builder.AddElement<int64_t>(off, long_val, 0); break;
- case 8: builder.AddElement<uint64_t>(off, ulong_val, 0); break;
- case 9: builder.AddElement<float>(off, float_val, 0); break;
- case 10: builder.AddElement<double>(off, double_val, 0); break;
- }
- }
- objects[i] = builder.EndTable(start);
- }
- builder.PreAlign<flatbuffers::largest_scalar_t>(0); // Align whole buffer.
-
- lcg_reset(); // Reset.
-
- uint8_t *eob = builder.GetCurrentBufferPointer() + builder.GetSize();
-
- // Test that all objects we generated are readable and return the
- // expected values. We generate random objects in the same order
- // so this is deterministic.
- for (int i = 0; i < num_fuzz_objects; i++) {
- auto table = reinterpret_cast<flatbuffers::Table *>(eob - objects[i]);
- for (flatbuffers::voffset_t f = 0; f < fields_per_object; f++) {
- int choice = lcg_rand() % test_values_max;
- flatbuffers::voffset_t off = flatbuffers::FieldIndexToOffset(f);
- switch (choice) {
- case 0: CompareTableFieldValue(table, off, bool_val); break;
- case 1: CompareTableFieldValue(table, off, char_val); break;
- case 2: CompareTableFieldValue(table, off, uchar_val); break;
- case 3: CompareTableFieldValue(table, off, short_val); break;
- case 4: CompareTableFieldValue(table, off, ushort_val); break;
- case 5: CompareTableFieldValue(table, off, int_val); break;
- case 6: CompareTableFieldValue(table, off, uint_val); break;
- case 7: CompareTableFieldValue(table, off, long_val); break;
- case 8: CompareTableFieldValue(table, off, ulong_val); break;
- case 9: CompareTableFieldValue(table, off, float_val); break;
- case 10: CompareTableFieldValue(table, off, double_val); break;
- }
- }
- }
-}
-
-// High level stress/fuzz test: generate a big schema and
-// matching json data in random combinations, then parse both,
-// generate json back from the binary, and compare with the original.
-void FuzzTest2() {
- lcg_reset(); // Keep it deterministic.
-
- const int num_definitions = 30;
- const int num_struct_definitions = 5; // Subset of num_definitions.
- const int fields_per_definition = 15;
- const int instances_per_definition = 5;
- const int deprecation_rate = 10; // 1 in deprecation_rate fields will
- // be deprecated.
-
- std::string schema = "namespace test;\n\n";
-
- struct RndDef {
- std::string instances[instances_per_definition];
-
- // Since we're generating schema and corresponding data in tandem,
- // this convenience function adds strings to both at once.
- static void Add(RndDef (&definitions_l)[num_definitions],
- std::string &schema_l, const int instances_per_definition_l,
- const char *schema_add, const char *instance_add,
- int definition) {
- schema_l += schema_add;
- for (int i = 0; i < instances_per_definition_l; i++)
- definitions_l[definition].instances[i] += instance_add;
- }
- };
-
-// clang-format off
- #define AddToSchemaAndInstances(schema_add, instance_add) \
- RndDef::Add(definitions, schema, instances_per_definition, \
- schema_add, instance_add, definition)
-
- #define Dummy() \
- RndDef::Add(definitions, schema, instances_per_definition, \
- "byte", "1", definition)
- // clang-format on
-
- RndDef definitions[num_definitions];
-
- // We are going to generate num_definitions, the first
- // num_struct_definitions will be structs, the rest tables. For each
- // generate random fields, some of which may be struct/table types
- // referring to previously generated structs/tables.
- // Simultanenously, we generate instances_per_definition JSON data
- // definitions, which will have identical structure to the schema
- // being generated. We generate multiple instances such that when creating
- // hierarchy, we get some variety by picking one randomly.
- for (int definition = 0; definition < num_definitions; definition++) {
- std::string definition_name = "D" + flatbuffers::NumToString(definition);
-
- bool is_struct = definition < num_struct_definitions;
-
- AddToSchemaAndInstances(
- ((is_struct ? "struct " : "table ") + definition_name + " {\n").c_str(),
- "{\n");
-
- for (int field = 0; field < fields_per_definition; field++) {
- const bool is_last_field = field == fields_per_definition - 1;
-
- // Deprecate 1 in deprecation_rate fields. Only table fields can be
- // deprecated.
- // Don't deprecate the last field to avoid dangling commas in JSON.
- const bool deprecated =
- !is_struct && !is_last_field && (lcg_rand() % deprecation_rate == 0);
-
- std::string field_name = "f" + flatbuffers::NumToString(field);
- AddToSchemaAndInstances((" " + field_name + ":").c_str(),
- deprecated ? "" : (field_name + ": ").c_str());
- // Pick random type:
- auto base_type = static_cast<flatbuffers::BaseType>(
- lcg_rand() % (flatbuffers::BASE_TYPE_UNION + 1));
- switch (base_type) {
- case flatbuffers::BASE_TYPE_STRING:
- if (is_struct) {
- Dummy(); // No strings in structs.
- } else {
- AddToSchemaAndInstances("string", deprecated ? "" : "\"hi\"");
- }
- break;
- case flatbuffers::BASE_TYPE_VECTOR:
- if (is_struct) {
- Dummy(); // No vectors in structs.
- } else {
- AddToSchemaAndInstances("[ubyte]",
- deprecated ? "" : "[\n0,\n1,\n255\n]");
- }
- break;
- case flatbuffers::BASE_TYPE_NONE:
- case flatbuffers::BASE_TYPE_UTYPE:
- case flatbuffers::BASE_TYPE_STRUCT:
- case flatbuffers::BASE_TYPE_UNION:
- if (definition) {
- // Pick a random previous definition and random data instance of
- // that definition.
- int defref = lcg_rand() % definition;
- int instance = lcg_rand() % instances_per_definition;
- AddToSchemaAndInstances(
- ("D" + flatbuffers::NumToString(defref)).c_str(),
- deprecated ? ""
- : definitions[defref].instances[instance].c_str());
- } else {
- // If this is the first definition, we have no definition we can
- // refer to.
- Dummy();
- }
- break;
- case flatbuffers::BASE_TYPE_BOOL:
- AddToSchemaAndInstances(
- "bool", deprecated ? "" : (lcg_rand() % 2 ? "true" : "false"));
- break;
- case flatbuffers::BASE_TYPE_ARRAY:
- if (!is_struct) {
- AddToSchemaAndInstances(
- "ubyte",
- deprecated ? "" : "255"); // No fixed-length arrays in tables.
- } else {
- AddToSchemaAndInstances("[int:3]", deprecated ? "" : "[\n,\n,\n]");
- }
- break;
- default:
- // All the scalar types.
- schema += flatbuffers::kTypeNames[base_type];
-
- if (!deprecated) {
- // We want each instance to use its own random value.
- for (int inst = 0; inst < instances_per_definition; inst++)
- definitions[definition].instances[inst] +=
- flatbuffers::IsFloat(base_type)
- ? flatbuffers::NumToString<double>(lcg_rand() % 128)
- .c_str()
- : flatbuffers::NumToString<int>(lcg_rand() % 128).c_str();
- }
- }
- AddToSchemaAndInstances(deprecated ? "(deprecated);\n" : ";\n",
- deprecated ? ""
- : is_last_field ? "\n"
- : ",\n");
- }
- AddToSchemaAndInstances("}\n\n", "}");
- }
-
- schema += "root_type D" + flatbuffers::NumToString(num_definitions - 1);
- schema += ";\n";
-
- flatbuffers::Parser parser;
-
- // Will not compare against the original if we don't write defaults
- parser.builder_.ForceDefaults(true);
-
- // Parse the schema, parse the generated data, then generate text back
- // from the binary and compare against the original.
- TEST_EQ(parser.Parse(schema.c_str()), true);
-
- const std::string &json =
- definitions[num_definitions - 1].instances[0] + "\n";
-
- TEST_EQ(parser.Parse(json.c_str()), true);
-
- std::string jsongen;
- parser.opts.indent_step = 0;
- auto result =
- GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen);
- TEST_EQ(result, true);
-
- if (jsongen != json) {
- // These strings are larger than a megabyte, so we show the bytes around
- // the first bytes that are different rather than the whole string.
- size_t len = std::min(json.length(), jsongen.length());
- for (size_t i = 0; i < len; i++) {
- if (json[i] != jsongen[i]) {
- i -= std::min(static_cast<size_t>(10), i); // show some context;
- size_t end = std::min(len, i + 20);
- for (; i < end; i++)
- TEST_OUTPUT_LINE("at %d: found \"%c\", expected \"%c\"\n",
- static_cast<int>(i), jsongen[i], json[i]);
- break;
- }
- }
- TEST_NOTNULL(nullptr); //-V501 (this comment supresses CWE-570 warning)
- }
-
-// clang-format off
- #ifdef FLATBUFFERS_TEST_VERBOSE
- TEST_OUTPUT_LINE("%dk schema tested with %dk of json\n",
- static_cast<int>(schema.length() / 1024),
- static_cast<int>(json.length() / 1024));
- #endif
- // clang-format on
-}
-
-// Test that parser errors are actually generated.
-void TestError_(const char *src, const char *error_substr, bool strict_json,
- const char *file, int line, const char *func) {
- flatbuffers::IDLOptions opts;
- opts.strict_json = strict_json;
- flatbuffers::Parser parser(opts);
- if (parser.Parse(src)) {
- TestFail("true", "false",
- ("parser.Parse(\"" + std::string(src) + "\")").c_str(), file, line,
- func);
- } else if (!strstr(parser.error_.c_str(), error_substr)) {
- TestFail(error_substr, parser.error_.c_str(),
- ("parser.Parse(\"" + std::string(src) + "\")").c_str(), file, line,
- func);
- }
-}
-
-void TestError_(const char *src, const char *error_substr, const char *file,
- int line, const char *func) {
- TestError_(src, error_substr, false, file, line, func);
-}
-
-#ifdef _WIN32
-# define TestError(src, ...) \
- TestError_(src, __VA_ARGS__, __FILE__, __LINE__, __FUNCTION__)
-#else
-# define TestError(src, ...) \
- TestError_(src, __VA_ARGS__, __FILE__, __LINE__, __PRETTY_FUNCTION__)
-#endif
-
-// Test that parsing errors occur as we'd expect.
-// Also useful for coverage, making sure these paths are run.
-void ErrorTest() {
- // In order they appear in idl_parser.cpp
- TestError("table X { Y:byte; } root_type X; { Y: 999 }", "does not fit");
- TestError("\"\0", "illegal");
- TestError("\"\\q", "escape code");
- TestError("table ///", "documentation");
- TestError("@", "illegal");
- TestError("table 1", "expecting");
- TestError("table X { Y:[[int]]; }", "nested vector");
- TestError("table X { Y:1; }", "illegal type");
- TestError("table X { Y:int; Y:int; }", "field already");
- TestError("table Y {} table X { Y:int; }", "same as table");
- TestError("struct X { Y:string; }", "only scalar");
- TestError("struct X { a:uint = 42; }", "default values");
- TestError("enum Y:byte { Z = 1 } table X { y:Y; }", "not part of enum");
- TestError("struct X { Y:int (deprecated); }", "deprecate");
- TestError("union Z { X } table X { Y:Z; } root_type X; { Y: {}, A:1 }",
- "missing type field");
- TestError("union Z { X } table X { Y:Z; } root_type X; { Y_type: 99, Y: {",
- "type id");
- TestError("table X { Y:int; } root_type X; { Z:", "unknown field");
- TestError("table X { Y:int; } root_type X; { Y:", "string constant", true);
- TestError("table X { Y:int; } root_type X; { \"Y\":1, }", "string constant",
- true);
- TestError(
- "struct X { Y:int; Z:int; } table W { V:X; } root_type W; "
- "{ V:{ Y:1 } }",
- "wrong number");
- TestError("enum E:byte { A } table X { Y:E; } root_type X; { Y:U }",
- "unknown enum value");
- TestError("table X { Y:byte; } root_type X; { Y:; }", "starting");
- TestError("enum X:byte { Y } enum X {", "enum already");
- TestError("enum X:float {}", "underlying");
- TestError("enum X:byte { Y, Y }", "value already");
- TestError("enum X:byte { Y=2, Z=2 }", "unique");
- TestError("table X { Y:int; } table X {", "datatype already");
- TestError("table X { } union X { }", "datatype already");
- TestError("union X { } table X { }", "datatype already");
- TestError("namespace A; table X { } namespace A; union X { }",
- "datatype already");
- TestError("namespace A; union X { } namespace A; table X { }",
- "datatype already");
- TestError("struct X (force_align: 7) { Y:int; }", "force_align");
- TestError("struct X {}", "size 0");
- TestError("{}", "no root");
- TestError("table X { Y:byte; } root_type X; { Y:1 } { Y:1 }", "end of file");
- TestError("table X { Y:byte; } root_type X; { Y:1 } table Y{ Z:int }",
- "end of file");
- TestError("root_type X;", "unknown root");
- TestError("struct X { Y:int; } root_type X;", "a table");
- TestError("union X { Y }", "referenced");
- TestError("union Z { X } struct X { Y:int; }", "only tables");
- TestError("table X { Y:[int]; YLength:int; }", "clash");
- TestError("table X { Y:byte; } root_type X; { Y:1, Y:2 }", "more than once");
- // float to integer conversion is forbidden
- TestError("table X { Y:int; } root_type X; { Y:1.0 }", "float");
- TestError("table X { Y:bool; } root_type X; { Y:1.0 }", "float");
- TestError("enum X:bool { Y = true }", "must be integral");
- // Array of non-scalar
- TestError("table X { x:int; } struct Y { y:[X:2]; }",
- "may contain only scalar or struct fields");
- // Non-snake case field names
- TestError("table X { Y: int; } root_type Y: {Y:1.0}", "snake_case");
- // Complex defaults
- TestError("table X { y: string = 1; }", "expecting: string");
- TestError("table X { y: string = []; }", " Cannot assign token");
- TestError("table X { y: [int] = [1]; }", "Expected `]`");
- TestError("table X { y: [int] = [; }", "Expected `]`");
- TestError("table X { y: [int] = \"\"; }", "type mismatch");
- // An identifier can't start from sign (+|-)
- TestError("table X { -Y: int; } root_type Y: {Y:1.0}", "identifier");
- TestError("table X { +Y: int; } root_type Y: {Y:1.0}", "identifier");
-}
-
-template<typename T>
-T TestValue(const char *json, const char *type_name,
- const char *decls = nullptr) {
- flatbuffers::Parser parser;
- parser.builder_.ForceDefaults(true); // return defaults
- auto check_default = json ? false : true;
- if (check_default) { parser.opts.output_default_scalars_in_json = true; }
- // Simple schema.
- std::string schema = std::string(decls ? decls : "") + "\n" +
- "table X { y:" + std::string(type_name) +
- "; } root_type X;";
- auto schema_done = parser.Parse(schema.c_str());
- TEST_EQ_STR(parser.error_.c_str(), "");
- TEST_EQ(schema_done, true);
-
- auto done = parser.Parse(check_default ? "{}" : json);
- TEST_EQ_STR(parser.error_.c_str(), "");
- TEST_EQ(done, true);
-
- // Check with print.
- std::string print_back;
- parser.opts.indent_step = -1;
- TEST_EQ(GenerateText(parser, parser.builder_.GetBufferPointer(), &print_back),
- true);
- // restore value from its default
- if (check_default) { TEST_EQ(parser.Parse(print_back.c_str()), true); }
-
- auto root = flatbuffers::GetRoot<flatbuffers::Table>(
- parser.builder_.GetBufferPointer());
- return root->GetField<T>(flatbuffers::FieldIndexToOffset(0), 0);
-}
-
-bool FloatCompare(float a, float b) { return fabs(a - b) < 0.001; }
-
-// Additional parser testing not covered elsewhere.
-void ValueTest() {
- // Test scientific notation numbers.
- TEST_EQ(
- FloatCompare(TestValue<float>("{ y:0.0314159e+2 }", "float"), 3.14159f),
- true);
- // number in string
- TEST_EQ(FloatCompare(TestValue<float>("{ y:\"0.0314159e+2\" }", "float"),
- 3.14159f),
- true);
-
- // Test conversion functions.
- TEST_EQ(FloatCompare(TestValue<float>("{ y:cos(rad(180)) }", "float"), -1),
- true);
-
- // int embedded to string
- TEST_EQ(TestValue<int>("{ y:\"-876\" }", "int=-123"), -876);
- TEST_EQ(TestValue<int>("{ y:\"876\" }", "int=-123"), 876);
-
- // Test negative hex constant.
- TEST_EQ(TestValue<int>("{ y:-0x8ea0 }", "int=-0x8ea0"), -36512);
- TEST_EQ(TestValue<int>(nullptr, "int=-0x8ea0"), -36512);
-
- // positive hex constant
- TEST_EQ(TestValue<int>("{ y:0x1abcdef }", "int=0x1"), 0x1abcdef);
- // with optional '+' sign
- TEST_EQ(TestValue<int>("{ y:+0x1abcdef }", "int=+0x1"), 0x1abcdef);
- // hex in string
- TEST_EQ(TestValue<int>("{ y:\"0x1abcdef\" }", "int=+0x1"), 0x1abcdef);
-
- // Make sure we do unsigned 64bit correctly.
- TEST_EQ(TestValue<uint64_t>("{ y:12335089644688340133 }", "ulong"),
- 12335089644688340133ULL);
-
- // bool in string
- TEST_EQ(TestValue<bool>("{ y:\"false\" }", "bool=true"), false);
- TEST_EQ(TestValue<bool>("{ y:\"true\" }", "bool=\"true\""), true);
- TEST_EQ(TestValue<bool>("{ y:'false' }", "bool=true"), false);
- TEST_EQ(TestValue<bool>("{ y:'true' }", "bool=\"true\""), true);
-
- // check comments before and after json object
- TEST_EQ(TestValue<int>("/*before*/ { y:1 } /*after*/", "int"), 1);
- TEST_EQ(TestValue<int>("//before \n { y:1 } //after", "int"), 1);
-}
-
-void NestedListTest() {
- flatbuffers::Parser parser1;
- TEST_EQ(parser1.Parse("struct Test { a:short; b:byte; } table T { F:[Test]; }"
- "root_type T;"
- "{ F:[ [10,20], [30,40]] }"),
- true);
-}
-
-void EnumStringsTest() {
- flatbuffers::Parser parser1;
- TEST_EQ(parser1.Parse("enum E:byte { A, B, C } table T { F:[E]; }"
- "root_type T;"
- "{ F:[ A, B, \"C\", \"A B C\" ] }"),
- true);
- flatbuffers::Parser parser2;
- TEST_EQ(parser2.Parse("enum E:byte { A, B, C } table T { F:[int]; }"
- "root_type T;"
- "{ F:[ \"E.C\", \"E.A E.B E.C\" ] }"),
- true);
- // unsigned bit_flags
- flatbuffers::Parser parser3;
- TEST_EQ(
- parser3.Parse("enum E:uint16 (bit_flags) { F0, F07=7, F08, F14=14, F15 }"
- " table T { F: E = \"F15 F08\"; }"
- "root_type T;"),
- true);
-}
-
-void EnumNamesTest() {
- TEST_EQ_STR("Red", EnumNameColor(Color_Red));
- TEST_EQ_STR("Green", EnumNameColor(Color_Green));
- TEST_EQ_STR("Blue", EnumNameColor(Color_Blue));
- // Check that Color to string don't crash while decode a mixture of Colors.
- // 1) Example::Color enum is enum with unfixed underlying type.
- // 2) Valid enum range: [0; 2^(ceil(log2(Color_ANY))) - 1].
- // Consequence: A value is out of this range will lead to UB (since C++17).
- // For details see C++17 standard or explanation on the SO:
- // stackoverflow.com/questions/18195312/what-happens-if-you-static-cast-invalid-value-to-enum-class
- TEST_EQ_STR("", EnumNameColor(static_cast<Color>(0)));
- TEST_EQ_STR("", EnumNameColor(static_cast<Color>(Color_ANY - 1)));
- TEST_EQ_STR("", EnumNameColor(static_cast<Color>(Color_ANY + 1)));
-}
-
-void EnumOutOfRangeTest() {
- TestError("enum X:byte { Y = 128 }", "enum value does not fit");
- TestError("enum X:byte { Y = -129 }", "enum value does not fit");
- TestError("enum X:byte { Y = 126, Z0, Z1 }", "enum value does not fit");
- TestError("enum X:ubyte { Y = -1 }", "enum value does not fit");
- TestError("enum X:ubyte { Y = 256 }", "enum value does not fit");
- TestError("enum X:ubyte { Y = 255, Z }", "enum value does not fit");
- TestError("table Y{} union X { Y = -1 }", "enum value does not fit");
- TestError("table Y{} union X { Y = 256 }", "enum value does not fit");
- TestError("table Y{} union X { Y = 255, Z:Y }", "enum value does not fit");
- TestError("enum X:int { Y = -2147483649 }", "enum value does not fit");
- TestError("enum X:int { Y = 2147483648 }", "enum value does not fit");
- TestError("enum X:uint { Y = -1 }", "enum value does not fit");
- TestError("enum X:uint { Y = 4294967297 }", "enum value does not fit");
- TestError("enum X:long { Y = 9223372036854775808 }", "does not fit");
- TestError("enum X:long { Y = 9223372036854775807, Z }",
- "enum value does not fit");
- TestError("enum X:ulong { Y = -1 }", "does not fit");
- TestError("enum X:ubyte (bit_flags) { Y=8 }", "bit flag out");
- TestError("enum X:byte (bit_flags) { Y=7 }", "must be unsigned"); // -128
- // bit_flgs out of range
- TestError("enum X:ubyte (bit_flags) { Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8 }",
- "out of range");
-}
-
-void EnumValueTest() {
- // json: "{ Y:0 }", schema: table X { y: "E"}
- // 0 in enum (V=0) E then Y=0 is valid.
- TEST_EQ(TestValue<int>("{ y:0 }", "E", "enum E:int { V }"), 0);
- TEST_EQ(TestValue<int>("{ y:V }", "E", "enum E:int { V }"), 0);
- // A default value of Y is 0.
- TEST_EQ(TestValue<int>("{ }", "E", "enum E:int { V }"), 0);
- TEST_EQ(TestValue<int>("{ y:5 }", "E=V", "enum E:int { V=5 }"), 5);
- // Generate json with defaults and check.
- TEST_EQ(TestValue<int>(nullptr, "E=V", "enum E:int { V=5 }"), 5);
- // 5 in enum
- TEST_EQ(TestValue<int>("{ y:5 }", "E", "enum E:int { Z, V=5 }"), 5);
- TEST_EQ(TestValue<int>("{ y:5 }", "E=V", "enum E:int { Z, V=5 }"), 5);
- // Generate json with defaults and check.
- TEST_EQ(TestValue<int>(nullptr, "E", "enum E:int { Z, V=5 }"), 0);
- TEST_EQ(TestValue<int>(nullptr, "E=V", "enum E:int { Z, V=5 }"), 5);
- // u84 test
- TEST_EQ(TestValue<uint64_t>(nullptr, "E=V",
- "enum E:ulong { V = 13835058055282163712 }"),
- 13835058055282163712ULL);
- TEST_EQ(TestValue<uint64_t>(nullptr, "E=V",
- "enum E:ulong { V = 18446744073709551615 }"),
- 18446744073709551615ULL);
- // Assign non-enum value to enum field. Is it right?
- TEST_EQ(TestValue<int>("{ y:7 }", "E", "enum E:int { V = 0 }"), 7);
- // Check that non-ascending values are valid.
- TEST_EQ(TestValue<int>("{ y:5 }", "E=V", "enum E:int { Z=10, V=5 }"), 5);
-}
-
-void IntegerOutOfRangeTest() {
- TestError("table T { F:byte; } root_type T; { F:128 }",
- "constant does not fit");
- TestError("table T { F:byte; } root_type T; { F:-129 }",
- "constant does not fit");
- TestError("table T { F:ubyte; } root_type T; { F:256 }",
- "constant does not fit");
- TestError("table T { F:ubyte; } root_type T; { F:-1 }",
- "constant does not fit");
- TestError("table T { F:short; } root_type T; { F:32768 }",
- "constant does not fit");
- TestError("table T { F:short; } root_type T; { F:-32769 }",
- "constant does not fit");
- TestError("table T { F:ushort; } root_type T; { F:65536 }",
- "constant does not fit");
- TestError("table T { F:ushort; } root_type T; { F:-1 }",
- "constant does not fit");
- TestError("table T { F:int; } root_type T; { F:2147483648 }",
- "constant does not fit");
- TestError("table T { F:int; } root_type T; { F:-2147483649 }",
- "constant does not fit");
- TestError("table T { F:uint; } root_type T; { F:4294967296 }",
- "constant does not fit");
- TestError("table T { F:uint; } root_type T; { F:-1 }",
- "constant does not fit");
- // Check fixed width aliases
- TestError("table X { Y:uint8; } root_type X; { Y: -1 }", "does not fit");
- TestError("table X { Y:uint8; } root_type X; { Y: 256 }", "does not fit");
- TestError("table X { Y:uint16; } root_type X; { Y: -1 }", "does not fit");
- TestError("table X { Y:uint16; } root_type X; { Y: 65536 }", "does not fit");
- TestError("table X { Y:uint32; } root_type X; { Y: -1 }", "");
- TestError("table X { Y:uint32; } root_type X; { Y: 4294967296 }",
- "does not fit");
- TestError("table X { Y:uint64; } root_type X; { Y: -1 }", "");
- TestError("table X { Y:uint64; } root_type X; { Y: -9223372036854775809 }",
- "does not fit");
- TestError("table X { Y:uint64; } root_type X; { Y: 18446744073709551616 }",
- "does not fit");
-
- TestError("table X { Y:int8; } root_type X; { Y: -129 }", "does not fit");
- TestError("table X { Y:int8; } root_type X; { Y: 128 }", "does not fit");
- TestError("table X { Y:int16; } root_type X; { Y: -32769 }", "does not fit");
- TestError("table X { Y:int16; } root_type X; { Y: 32768 }", "does not fit");
- TestError("table X { Y:int32; } root_type X; { Y: -2147483649 }", "");
- TestError("table X { Y:int32; } root_type X; { Y: 2147483648 }",
- "does not fit");
- TestError("table X { Y:int64; } root_type X; { Y: -9223372036854775809 }",
- "does not fit");
- TestError("table X { Y:int64; } root_type X; { Y: 9223372036854775808 }",
- "does not fit");
- // check out-of-int64 as int8
- TestError("table X { Y:int8; } root_type X; { Y: -9223372036854775809 }",
- "does not fit");
- TestError("table X { Y:int8; } root_type X; { Y: 9223372036854775808 }",
- "does not fit");
-
- // Check default values
- TestError("table X { Y:int64=-9223372036854775809; } root_type X; {}",
- "does not fit");
- TestError("table X { Y:int64= 9223372036854775808; } root_type X; {}",
- "does not fit");
- TestError("table X { Y:uint64; } root_type X; { Y: -1 }", "");
- TestError("table X { Y:uint64=-9223372036854775809; } root_type X; {}",
- "does not fit");
- TestError("table X { Y:uint64= 18446744073709551616; } root_type X; {}",
- "does not fit");
-}
-
-void IntegerBoundaryTest() {
- // Check numerical compatibility with non-C++ languages.
- // By the C++ standard, std::numerical_limits<int64_t>::min() ==
- // -9223372036854775807 (-2^63+1) or less* The Flatbuffers grammar and most of
- // the languages (C#, Java, Rust) expect that minimum values are: -128,
- // -32768,.., -9223372036854775808. Since C++20,
- // static_cast<int64>(0x8000000000000000ULL) is well-defined two's complement
- // cast. Therefore -9223372036854775808 should be valid negative value.
- TEST_EQ(flatbuffers::numeric_limits<int8_t>::min(), -128);
- TEST_EQ(flatbuffers::numeric_limits<int8_t>::max(), 127);
- TEST_EQ(flatbuffers::numeric_limits<int16_t>::min(), -32768);
- TEST_EQ(flatbuffers::numeric_limits<int16_t>::max(), 32767);
- TEST_EQ(flatbuffers::numeric_limits<int32_t>::min() + 1, -2147483647);
- TEST_EQ(flatbuffers::numeric_limits<int32_t>::max(), 2147483647ULL);
- TEST_EQ(flatbuffers::numeric_limits<int64_t>::min() + 1LL,
- -9223372036854775807LL);
- TEST_EQ(flatbuffers::numeric_limits<int64_t>::max(), 9223372036854775807ULL);
- TEST_EQ(flatbuffers::numeric_limits<uint8_t>::max(), 255);
- TEST_EQ(flatbuffers::numeric_limits<uint16_t>::max(), 65535);
- TEST_EQ(flatbuffers::numeric_limits<uint32_t>::max(), 4294967295ULL);
- TEST_EQ(flatbuffers::numeric_limits<uint64_t>::max(),
- 18446744073709551615ULL);
-
- TEST_EQ(TestValue<int8_t>("{ y:127 }", "byte"), 127);
- TEST_EQ(TestValue<int8_t>("{ y:-128 }", "byte"), -128);
- TEST_EQ(TestValue<uint8_t>("{ y:255 }", "ubyte"), 255);
- TEST_EQ(TestValue<uint8_t>("{ y:0 }", "ubyte"), 0);
- TEST_EQ(TestValue<int16_t>("{ y:32767 }", "short"), 32767);
- TEST_EQ(TestValue<int16_t>("{ y:-32768 }", "short"), -32768);
- TEST_EQ(TestValue<uint16_t>("{ y:65535 }", "ushort"), 65535);
- TEST_EQ(TestValue<uint16_t>("{ y:0 }", "ushort"), 0);
- TEST_EQ(TestValue<int32_t>("{ y:2147483647 }", "int"), 2147483647);
- TEST_EQ(TestValue<int32_t>("{ y:-2147483648 }", "int") + 1, -2147483647);
- TEST_EQ(TestValue<uint32_t>("{ y:4294967295 }", "uint"), 4294967295);
- TEST_EQ(TestValue<uint32_t>("{ y:0 }", "uint"), 0);
- TEST_EQ(TestValue<int64_t>("{ y:9223372036854775807 }", "long"),
- 9223372036854775807LL);
- TEST_EQ(TestValue<int64_t>("{ y:-9223372036854775808 }", "long") + 1LL,
- -9223372036854775807LL);
- TEST_EQ(TestValue<uint64_t>("{ y:18446744073709551615 }", "ulong"),
- 18446744073709551615ULL);
- TEST_EQ(TestValue<uint64_t>("{ y:0 }", "ulong"), 0);
- TEST_EQ(TestValue<uint64_t>("{ y: 18446744073709551615 }", "uint64"),
- 18446744073709551615ULL);
- // check that the default works
- TEST_EQ(TestValue<uint64_t>(nullptr, "uint64 = 18446744073709551615"),
- 18446744073709551615ULL);
-}
-
-void ValidFloatTest() {
- // check rounding to infinity
- TEST_EQ(TestValue<float>("{ y:+3.4029e+38 }", "float"), +infinity_f);
- TEST_EQ(TestValue<float>("{ y:-3.4029e+38 }", "float"), -infinity_f);
- TEST_EQ(TestValue<double>("{ y:+1.7977e+308 }", "double"), +infinity_d);
- TEST_EQ(TestValue<double>("{ y:-1.7977e+308 }", "double"), -infinity_d);
-
- TEST_EQ(
- FloatCompare(TestValue<float>("{ y:0.0314159e+2 }", "float"), 3.14159f),
- true);
- // float in string
- TEST_EQ(FloatCompare(TestValue<float>("{ y:\" 0.0314159e+2 \" }", "float"),
- 3.14159f),
- true);
-
- TEST_EQ(TestValue<float>("{ y:1 }", "float"), 1.0f);
- TEST_EQ(TestValue<float>("{ y:1.0 }", "float"), 1.0f);
- TEST_EQ(TestValue<float>("{ y:1. }", "float"), 1.0f);
- TEST_EQ(TestValue<float>("{ y:+1. }", "float"), 1.0f);
- TEST_EQ(TestValue<float>("{ y:-1. }", "float"), -1.0f);
- TEST_EQ(TestValue<float>("{ y:1.e0 }", "float"), 1.0f);
- TEST_EQ(TestValue<float>("{ y:1.e+0 }", "float"), 1.0f);
- TEST_EQ(TestValue<float>("{ y:1.e-0 }", "float"), 1.0f);
- TEST_EQ(TestValue<float>("{ y:0.125 }", "float"), 0.125f);
- TEST_EQ(TestValue<float>("{ y:.125 }", "float"), 0.125f);
- TEST_EQ(TestValue<float>("{ y:-.125 }", "float"), -0.125f);
- TEST_EQ(TestValue<float>("{ y:+.125 }", "float"), +0.125f);
- TEST_EQ(TestValue<float>("{ y:5 }", "float"), 5.0f);
- TEST_EQ(TestValue<float>("{ y:\"5\" }", "float"), 5.0f);
-
-#if defined(FLATBUFFERS_HAS_NEW_STRTOD) && (FLATBUFFERS_HAS_NEW_STRTOD > 0)
- // Old MSVC versions may have problem with this check.
- // https://www.exploringbinary.com/visual-c-plus-plus-strtod-still-broken/
- TEST_EQ(TestValue<double>("{ y:6.9294956446009195e15 }", "double"),
- 6929495644600920.0);
- // check nan's
- TEST_EQ(std::isnan(TestValue<double>("{ y:nan }", "double")), true);
- TEST_EQ(std::isnan(TestValue<float>("{ y:nan }", "float")), true);
- TEST_EQ(std::isnan(TestValue<float>("{ y:\"nan\" }", "float")), true);
- TEST_EQ(std::isnan(TestValue<float>("{ y:\"+nan\" }", "float")), true);
- TEST_EQ(std::isnan(TestValue<float>("{ y:\"-nan\" }", "float")), true);
- TEST_EQ(std::isnan(TestValue<float>("{ y:+nan }", "float")), true);
- TEST_EQ(std::isnan(TestValue<float>("{ y:-nan }", "float")), true);
- TEST_EQ(std::isnan(TestValue<float>(nullptr, "float=nan")), true);
- TEST_EQ(std::isnan(TestValue<float>(nullptr, "float=-nan")), true);
- // check inf
- TEST_EQ(TestValue<float>("{ y:inf }", "float"), infinity_f);
- TEST_EQ(TestValue<float>("{ y:\"inf\" }", "float"), infinity_f);
- TEST_EQ(TestValue<float>("{ y:\"-inf\" }", "float"), -infinity_f);
- TEST_EQ(TestValue<float>("{ y:\"+inf\" }", "float"), infinity_f);
- TEST_EQ(TestValue<float>("{ y:+inf }", "float"), infinity_f);
- TEST_EQ(TestValue<float>("{ y:-inf }", "float"), -infinity_f);
- TEST_EQ(TestValue<float>(nullptr, "float=inf"), infinity_f);
- TEST_EQ(TestValue<float>(nullptr, "float=-inf"), -infinity_f);
- TestValue<double>(
- "{ y: [0.2, .2, 1.0, -1.0, -2., 2., 1e0, -1e0, 1.0e0, -1.0e0, -3.e2, "
- "3.0e2] }",
- "[double]");
- TestValue<float>(
- "{ y: [0.2, .2, 1.0, -1.0, -2., 2., 1e0, -1e0, 1.0e0, -1.0e0, -3.e2, "
- "3.0e2] }",
- "[float]");
-
- // Test binary format of float point.
- // https://en.cppreference.com/w/cpp/language/floating_literal
- // 0x11.12p-1 = (1*16^1 + 2*16^0 + 3*16^-1 + 4*16^-2) * 2^-1 =
- TEST_EQ(TestValue<double>("{ y:0x12.34p-1 }", "double"), 9.1015625);
- // hex fraction 1.2 (decimal 1.125) scaled by 2^3, that is 9.0
- TEST_EQ(TestValue<float>("{ y:-0x0.2p0 }", "float"), -0.125f);
- TEST_EQ(TestValue<float>("{ y:-0x.2p1 }", "float"), -0.25f);
- TEST_EQ(TestValue<float>("{ y:0x1.2p3 }", "float"), 9.0f);
- TEST_EQ(TestValue<float>("{ y:0x10.1p0 }", "float"), 16.0625f);
- TEST_EQ(TestValue<double>("{ y:0x1.2p3 }", "double"), 9.0);
- TEST_EQ(TestValue<double>("{ y:0x10.1p0 }", "double"), 16.0625);
- TEST_EQ(TestValue<double>("{ y:0xC.68p+2 }", "double"), 49.625);
- TestValue<double>("{ y: [0x20.4ep1, +0x20.4ep1, -0x20.4ep1] }", "[double]");
- TestValue<float>("{ y: [0x20.4ep1, +0x20.4ep1, -0x20.4ep1] }", "[float]");
-
-#else // FLATBUFFERS_HAS_NEW_STRTOD
- TEST_OUTPUT_LINE("FLATBUFFERS_HAS_NEW_STRTOD tests skipped");
-#endif // !FLATBUFFERS_HAS_NEW_STRTOD
-}
-
-void InvalidFloatTest() {
- auto invalid_msg = "invalid number";
- auto comma_msg = "expecting: ,";
- TestError("table T { F:float; } root_type T; { F:1,0 }", "");
- TestError("table T { F:float; } root_type T; { F:. }", "");
- TestError("table T { F:float; } root_type T; { F:- }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:+ }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:-. }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:+. }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:.e }", "");
- TestError("table T { F:float; } root_type T; { F:-e }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:+e }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:-.e }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:+.e }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:-e1 }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:+e1 }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:1.0e+ }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:1.0e- }", invalid_msg);
- // exponent pP is mandatory for hex-float
- TestError("table T { F:float; } root_type T; { F:0x0 }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:-0x. }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:0x. }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:0Xe }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:\"0Xe\" }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:\"nan(1)\" }", invalid_msg);
- // eE not exponent in hex-float!
- TestError("table T { F:float; } root_type T; { F:0x0.0e+ }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:0x0.0e- }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:0x0.0p }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:0x0.0p+ }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:0x0.0p- }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:0x0.0pa1 }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:0x0.0e+ }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:0x0.0e- }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:0x0.0e+0 }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:0x0.0e-0 }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:0x0.0ep+ }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:0x0.0ep- }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:1.2.3 }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:1.2.e3 }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:1.2e.3 }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:1.2e0.3 }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:1.2e3. }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:1.2e3.0 }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:+-1.0 }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:1.0e+-1 }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:\"1.0e+-1\" }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:1.e0e }", comma_msg);
- TestError("table T { F:float; } root_type T; { F:0x1.p0e }", comma_msg);
- TestError("table T { F:float; } root_type T; { F:\" 0x10 \" }", invalid_msg);
- // floats in string
- TestError("table T { F:float; } root_type T; { F:\"1,2.\" }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:\"1.2e3.\" }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:\"0x1.p0e\" }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:\"0x1.0\" }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:\" 0x1.0\" }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:\"+ 0\" }", invalid_msg);
- // disable escapes for "number-in-string"
- TestError("table T { F:float; } root_type T; { F:\"\\f1.2e3.\" }", "invalid");
- TestError("table T { F:float; } root_type T; { F:\"\\t1.2e3.\" }", "invalid");
- TestError("table T { F:float; } root_type T; { F:\"\\n1.2e3.\" }", "invalid");
- TestError("table T { F:float; } root_type T; { F:\"\\r1.2e3.\" }", "invalid");
- TestError("table T { F:float; } root_type T; { F:\"4\\x005\" }", "invalid");
- TestError("table T { F:float; } root_type T; { F:\"\'12\'\" }", invalid_msg);
- // null is not a number constant!
- TestError("table T { F:float; } root_type T; { F:\"null\" }", invalid_msg);
- TestError("table T { F:float; } root_type T; { F:null }", invalid_msg);
-}
-
-void GenerateTableTextTest() {
+void GenerateTableTextTest(const std::string &tests_data_path) {
std::string schemafile;
std::string jsonfile;
bool ok =
- flatbuffers::LoadFile((test_data_path + "monster_test.fbs").c_str(),
+ flatbuffers::LoadFile((tests_data_path + "monster_test.fbs").c_str(),
false, &schemafile) &&
- flatbuffers::LoadFile((test_data_path + "monsterdata_test.json").c_str(),
+ flatbuffers::LoadFile((tests_data_path + "monsterdata_test.json").c_str(),
false, &jsonfile);
TEST_EQ(ok, true);
auto include_test_path =
- flatbuffers::ConCatPathFileName(test_data_path, "include_test");
- const char *include_directories[] = { test_data_path.c_str(),
+ flatbuffers::ConCatPathFileName(tests_data_path, "include_test");
+ const char *include_directories[] = { tests_data_path.c_str(),
include_test_path.c_str(), nullptr };
flatbuffers::IDLOptions opt;
opt.indent_step = -1;
@@ -2360,338 +138,9 @@
TEST_EQ_STR(jsongen.c_str(), "{a: 10,b: 20}");
}
-template<typename T>
-void NumericUtilsTestInteger(const char *lower, const char *upper) {
- T x;
- TEST_EQ(flatbuffers::StringToNumber("1q", &x), false);
- TEST_EQ(x, 0);
- TEST_EQ(flatbuffers::StringToNumber(upper, &x), false);
- TEST_EQ(x, flatbuffers::numeric_limits<T>::max());
- TEST_EQ(flatbuffers::StringToNumber(lower, &x), false);
- auto expval = flatbuffers::is_unsigned<T>::value
- ? flatbuffers::numeric_limits<T>::max()
- : flatbuffers::numeric_limits<T>::lowest();
- TEST_EQ(x, expval);
-}
-
-template<typename T>
-void NumericUtilsTestFloat(const char *lower, const char *upper) {
- T f;
- TEST_EQ(flatbuffers::StringToNumber("", &f), false);
- TEST_EQ(flatbuffers::StringToNumber("1q", &f), false);
- TEST_EQ(f, 0);
- TEST_EQ(flatbuffers::StringToNumber(upper, &f), true);
- TEST_EQ(f, +flatbuffers::numeric_limits<T>::infinity());
- TEST_EQ(flatbuffers::StringToNumber(lower, &f), true);
- TEST_EQ(f, -flatbuffers::numeric_limits<T>::infinity());
-}
-
-void NumericUtilsTest() {
- NumericUtilsTestInteger<uint64_t>("-1", "18446744073709551616");
- NumericUtilsTestInteger<uint8_t>("-1", "256");
- NumericUtilsTestInteger<int64_t>("-9223372036854775809",
- "9223372036854775808");
- NumericUtilsTestInteger<int8_t>("-129", "128");
- NumericUtilsTestFloat<float>("-3.4029e+38", "+3.4029e+38");
- NumericUtilsTestFloat<float>("-1.7977e+308", "+1.7977e+308");
-}
-
-void IsAsciiUtilsTest() {
- char c = -128;
- for (int cnt = 0; cnt < 256; cnt++) {
- auto alpha = (('a' <= c) && (c <= 'z')) || (('A' <= c) && (c <= 'Z'));
- auto dec = (('0' <= c) && (c <= '9'));
- auto hex = (('a' <= c) && (c <= 'f')) || (('A' <= c) && (c <= 'F'));
- TEST_EQ(flatbuffers::is_alpha(c), alpha);
- TEST_EQ(flatbuffers::is_alnum(c), alpha || dec);
- TEST_EQ(flatbuffers::is_digit(c), dec);
- TEST_EQ(flatbuffers::is_xdigit(c), dec || hex);
- c += 1;
- }
-}
-
-void UnicodeTest() {
- flatbuffers::Parser parser;
- // Without setting allow_non_utf8 = true, we treat \x sequences as byte
- // sequences which are then validated as UTF-8.
- TEST_EQ(parser.Parse("table T { F:string; }"
- "root_type T;"
- "{ F:\"\\u20AC\\u00A2\\u30E6\\u30FC\\u30B6\\u30FC"
- "\\u5225\\u30B5\\u30A4\\u30C8\\xE2\\x82\\xAC\\u0080\\uD8"
- "3D\\uDE0E\" }"),
- true);
- std::string jsongen;
- parser.opts.indent_step = -1;
- auto result =
- GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen);
- TEST_EQ(result, true);
- TEST_EQ_STR(jsongen.c_str(),
- "{F: \"\\u20AC\\u00A2\\u30E6\\u30FC\\u30B6\\u30FC"
- "\\u5225\\u30B5\\u30A4\\u30C8\\u20AC\\u0080\\uD83D\\uDE0E\"}");
-}
-
-void UnicodeTestAllowNonUTF8() {
- flatbuffers::Parser parser;
- parser.opts.allow_non_utf8 = true;
- TEST_EQ(
- parser.Parse(
- "table T { F:string; }"
- "root_type T;"
- "{ F:\"\\u20AC\\u00A2\\u30E6\\u30FC\\u30B6\\u30FC"
- "\\u5225\\u30B5\\u30A4\\u30C8\\x01\\x80\\u0080\\uD83D\\uDE0E\" }"),
- true);
- std::string jsongen;
- parser.opts.indent_step = -1;
- auto result =
- GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen);
- TEST_EQ(result, true);
- TEST_EQ_STR(
- jsongen.c_str(),
- "{F: \"\\u20AC\\u00A2\\u30E6\\u30FC\\u30B6\\u30FC"
- "\\u5225\\u30B5\\u30A4\\u30C8\\u0001\\x80\\u0080\\uD83D\\uDE0E\"}");
-}
-
-void UnicodeTestGenerateTextFailsOnNonUTF8() {
- flatbuffers::Parser parser;
- // Allow non-UTF-8 initially to model what happens when we load a binary
- // flatbuffer from disk which contains non-UTF-8 strings.
- parser.opts.allow_non_utf8 = true;
- TEST_EQ(
- parser.Parse(
- "table T { F:string; }"
- "root_type T;"
- "{ F:\"\\u20AC\\u00A2\\u30E6\\u30FC\\u30B6\\u30FC"
- "\\u5225\\u30B5\\u30A4\\u30C8\\x01\\x80\\u0080\\uD83D\\uDE0E\" }"),
- true);
- std::string jsongen;
- parser.opts.indent_step = -1;
- // Now, disallow non-UTF-8 (the default behavior) so GenerateText indicates
- // failure.
- parser.opts.allow_non_utf8 = false;
- auto result =
- GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen);
- TEST_EQ(result, false);
-}
-
-void UnicodeSurrogatesTest() {
- flatbuffers::Parser parser;
-
- TEST_EQ(parser.Parse("table T { F:string (id: 0); }"
- "root_type T;"
- "{ F:\"\\uD83D\\uDCA9\"}"),
- true);
- auto root = flatbuffers::GetRoot<flatbuffers::Table>(
- parser.builder_.GetBufferPointer());
- auto string = root->GetPointer<flatbuffers::String *>(
- flatbuffers::FieldIndexToOffset(0));
- TEST_EQ_STR(string->c_str(), "\xF0\x9F\x92\xA9");
-}
-
-void UnicodeInvalidSurrogatesTest() {
- TestError(
- "table T { F:string; }"
- "root_type T;"
- "{ F:\"\\uD800\"}",
- "unpaired high surrogate");
- TestError(
- "table T { F:string; }"
- "root_type T;"
- "{ F:\"\\uD800abcd\"}",
- "unpaired high surrogate");
- TestError(
- "table T { F:string; }"
- "root_type T;"
- "{ F:\"\\uD800\\n\"}",
- "unpaired high surrogate");
- TestError(
- "table T { F:string; }"
- "root_type T;"
- "{ F:\"\\uD800\\uD800\"}",
- "multiple high surrogates");
- TestError(
- "table T { F:string; }"
- "root_type T;"
- "{ F:\"\\uDC00\"}",
- "unpaired low surrogate");
-}
-
-void InvalidUTF8Test() {
- // "1 byte" pattern, under min length of 2 bytes
- TestError(
- "table T { F:string; }"
- "root_type T;"
- "{ F:\"\x80\"}",
- "illegal UTF-8 sequence");
- // 2 byte pattern, string too short
- TestError(
- "table T { F:string; }"
- "root_type T;"
- "{ F:\"\xDF\"}",
- "illegal UTF-8 sequence");
- // 3 byte pattern, string too short
- TestError(
- "table T { F:string; }"
- "root_type T;"
- "{ F:\"\xEF\xBF\"}",
- "illegal UTF-8 sequence");
- // 4 byte pattern, string too short
- TestError(
- "table T { F:string; }"
- "root_type T;"
- "{ F:\"\xF7\xBF\xBF\"}",
- "illegal UTF-8 sequence");
- // "5 byte" pattern, string too short
- TestError(
- "table T { F:string; }"
- "root_type T;"
- "{ F:\"\xFB\xBF\xBF\xBF\"}",
- "illegal UTF-8 sequence");
- // "6 byte" pattern, string too short
- TestError(
- "table T { F:string; }"
- "root_type T;"
- "{ F:\"\xFD\xBF\xBF\xBF\xBF\"}",
- "illegal UTF-8 sequence");
- // "7 byte" pattern, string too short
- TestError(
- "table T { F:string; }"
- "root_type T;"
- "{ F:\"\xFE\xBF\xBF\xBF\xBF\xBF\"}",
- "illegal UTF-8 sequence");
- // "5 byte" pattern, over max length of 4 bytes
- TestError(
- "table T { F:string; }"
- "root_type T;"
- "{ F:\"\xFB\xBF\xBF\xBF\xBF\"}",
- "illegal UTF-8 sequence");
- // "6 byte" pattern, over max length of 4 bytes
- TestError(
- "table T { F:string; }"
- "root_type T;"
- "{ F:\"\xFD\xBF\xBF\xBF\xBF\xBF\"}",
- "illegal UTF-8 sequence");
- // "7 byte" pattern, over max length of 4 bytes
- TestError(
- "table T { F:string; }"
- "root_type T;"
- "{ F:\"\xFE\xBF\xBF\xBF\xBF\xBF\xBF\"}",
- "illegal UTF-8 sequence");
-
- // Three invalid encodings for U+000A (\n, aka NEWLINE)
- TestError(
- "table T { F:string; }"
- "root_type T;"
- "{ F:\"\xC0\x8A\"}",
- "illegal UTF-8 sequence");
- TestError(
- "table T { F:string; }"
- "root_type T;"
- "{ F:\"\xE0\x80\x8A\"}",
- "illegal UTF-8 sequence");
- TestError(
- "table T { F:string; }"
- "root_type T;"
- "{ F:\"\xF0\x80\x80\x8A\"}",
- "illegal UTF-8 sequence");
-
- // Two invalid encodings for U+00A9 (COPYRIGHT SYMBOL)
- TestError(
- "table T { F:string; }"
- "root_type T;"
- "{ F:\"\xE0\x81\xA9\"}",
- "illegal UTF-8 sequence");
- TestError(
- "table T { F:string; }"
- "root_type T;"
- "{ F:\"\xF0\x80\x81\xA9\"}",
- "illegal UTF-8 sequence");
-
- // Invalid encoding for U+20AC (EURO SYMBOL)
- TestError(
- "table T { F:string; }"
- "root_type T;"
- "{ F:\"\xF0\x82\x82\xAC\"}",
- "illegal UTF-8 sequence");
-
- // UTF-16 surrogate values between U+D800 and U+DFFF cannot be encoded in
- // UTF-8
- TestError(
- "table T { F:string; }"
- "root_type T;"
- // U+10400 "encoded" as U+D801 U+DC00
- "{ F:\"\xED\xA0\x81\xED\xB0\x80\"}",
- "illegal UTF-8 sequence");
-
- // Check independence of identifier from locale.
- std::string locale_ident;
- locale_ident += "table T { F";
- locale_ident += static_cast<char>(-32); // unsigned 0xE0
- locale_ident += " :string; }";
- locale_ident += "root_type T;";
- locale_ident += "{}";
- TestError(locale_ident.c_str(), "");
-}
-
-void UnknownFieldsTest() {
- flatbuffers::IDLOptions opts;
- opts.skip_unexpected_fields_in_json = true;
- flatbuffers::Parser parser(opts);
-
- TEST_EQ(parser.Parse("table T { str:string; i:int;}"
- "root_type T;"
- "{ str:\"test\","
- "unknown_string:\"test\","
- "\"unknown_string\":\"test\","
- "unknown_int:10,"
- "unknown_float:1.0,"
- "unknown_array: [ 1, 2, 3, 4],"
- "unknown_object: { i: 10 },"
- "\"unknown_object\": { \"i\": 10 },"
- "i:10}"),
- true);
-
- std::string jsongen;
- parser.opts.indent_step = -1;
- auto result =
- GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen);
- TEST_EQ(result, true);
- TEST_EQ_STR(jsongen.c_str(), "{str: \"test\",i: 10}");
-}
-
-void ParseUnionTest() {
- // Unions must be parseable with the type field following the object.
- flatbuffers::Parser parser;
- TEST_EQ(parser.Parse("table T { A:int; }"
- "union U { T }"
- "table V { X:U; }"
- "root_type V;"
- "{ X:{ A:1 }, X_type: T }"),
- true);
- // Unions must be parsable with prefixed namespace.
- flatbuffers::Parser parser2;
- TEST_EQ(parser2.Parse("namespace N; table A {} namespace; union U { N.A }"
- "table B { e:U; } root_type B;"
- "{ e_type: N_A, e: {} }"),
- true);
-}
-
-void ValidSameNameDifferentNamespaceTest() {
- // Duplicate table names in different namespaces must be parsable
- TEST_ASSERT(flatbuffers::Parser().Parse(
- "namespace A; table X {} namespace B; table X {}"));
- // Duplicate union names in different namespaces must be parsable
- TEST_ASSERT(flatbuffers::Parser().Parse(
- "namespace A; union X {} namespace B; union X {}"));
- // Clashing table and union names in different namespaces must be parsable
- TEST_ASSERT(flatbuffers::Parser().Parse(
- "namespace A; table X {} namespace B; union X {}"));
- TEST_ASSERT(flatbuffers::Parser().Parse(
- "namespace A; union X {} namespace B; table X {}"));
-}
-
-void MultiFileNameClashTest() {
+void MultiFileNameClashTest(const std::string &tests_data_path) {
const auto name_clash_path =
- flatbuffers::ConCatPathFileName(test_data_path, "name_clash_test");
+ flatbuffers::ConCatPathFileName(tests_data_path, "name_clash_test");
const char *include_directories[] = { name_clash_path.c_str() };
// Load valid 2 file Flatbuffer schema
@@ -2718,15 +167,15 @@
false);
}
-void InvalidNestedFlatbufferTest() {
+void InvalidNestedFlatbufferTest(const std::string &tests_data_path) {
// First, load and parse FlatBuffer schema (.fbs)
std::string schemafile;
- TEST_EQ(flatbuffers::LoadFile((test_data_path + "monster_test.fbs").c_str(),
+ TEST_EQ(flatbuffers::LoadFile((tests_data_path + "monster_test.fbs").c_str(),
false, &schemafile),
true);
auto include_test_path =
- flatbuffers::ConCatPathFileName(test_data_path, "include_test");
- const char *include_directories[] = { test_data_path.c_str(),
+ flatbuffers::ConCatPathFileName(tests_data_path, "include_test");
+ const char *include_directories[] = { tests_data_path.c_str(),
include_test_path.c_str(), nullptr };
flatbuffers::Parser parser1;
TEST_EQ(parser1.Parse(schemafile.c_str(), include_directories), true);
@@ -2737,122 +186,15 @@
false);
}
-void EvolutionTest() {
- // VS10 does not support typed enums, exclude from tests
-#if !defined(_MSC_VER) || _MSC_VER >= 1700
- const int NUM_VERSIONS = 2;
- std::string schemas[NUM_VERSIONS];
- std::string jsonfiles[NUM_VERSIONS];
- std::vector<uint8_t> binaries[NUM_VERSIONS];
-
- flatbuffers::IDLOptions idl_opts;
- idl_opts.lang_to_generate |= flatbuffers::IDLOptions::kBinary;
- flatbuffers::Parser parser(idl_opts);
-
- // Load all the schema versions and their associated data.
- for (int i = 0; i < NUM_VERSIONS; ++i) {
- std::string schema = test_data_path + "evolution_test/evolution_v" +
- flatbuffers::NumToString(i + 1) + ".fbs";
- TEST_ASSERT(flatbuffers::LoadFile(schema.c_str(), false, &schemas[i]));
- std::string json = test_data_path + "evolution_test/evolution_v" +
- flatbuffers::NumToString(i + 1) + ".json";
- TEST_ASSERT(flatbuffers::LoadFile(json.c_str(), false, &jsonfiles[i]));
-
- TEST_ASSERT(parser.Parse(schemas[i].c_str()));
- TEST_ASSERT(parser.Parse(jsonfiles[i].c_str()));
-
- auto bufLen = parser.builder_.GetSize();
- auto buf = parser.builder_.GetBufferPointer();
- binaries[i].reserve(bufLen);
- std::copy(buf, buf + bufLen, std::back_inserter(binaries[i]));
- }
-
- // Assert that all the verifiers for the different schema versions properly
- // verify any version data.
- for (int i = 0; i < NUM_VERSIONS; ++i) {
- flatbuffers::Verifier verifier(&binaries[i].front(), binaries[i].size());
- TEST_ASSERT(Evolution::V1::VerifyRootBuffer(verifier));
- TEST_ASSERT(Evolution::V2::VerifyRootBuffer(verifier));
- }
-
- // Test backwards compatibility by reading old data with an evolved schema.
- auto root_v1_viewed_from_v2 = Evolution::V2::GetRoot(&binaries[0].front());
- // field 'k' is new in version 2, so it should be null.
- TEST_ASSERT(nullptr == root_v1_viewed_from_v2->k());
- // field 'l' is new in version 2 with a default of 56.
- TEST_EQ(root_v1_viewed_from_v2->l(), 56);
- // field 'c' of 'TableA' is new in version 2, so it should be null.
- TEST_ASSERT(nullptr == root_v1_viewed_from_v2->e()->c());
- // 'TableC' was added to field 'c' union in version 2, so it should be null.
- TEST_ASSERT(nullptr == root_v1_viewed_from_v2->c_as_TableC());
- // The field 'c' union should be of type 'TableB' regardless of schema version
- TEST_ASSERT(root_v1_viewed_from_v2->c_type() == Evolution::V2::Union::TableB);
- // The field 'f' was renamed to 'ff' in version 2, it should still be
- // readable.
- TEST_EQ(root_v1_viewed_from_v2->ff()->a(), 16);
-
- // Test forwards compatibility by reading new data with an old schema.
- auto root_v2_viewed_from_v1 = Evolution::V1::GetRoot(&binaries[1].front());
- // The field 'c' union in version 2 is a new table (index = 3) and should
- // still be accessible, but not interpretable.
- TEST_EQ(static_cast<uint8_t>(root_v2_viewed_from_v1->c_type()), 3);
- TEST_NOTNULL(root_v2_viewed_from_v1->c());
- // The field 'd' enum in verison 2 has new members and should still be
- // accessible, but not interpretable.
- TEST_EQ(static_cast<int8_t>(root_v2_viewed_from_v1->d()), 3);
- // The field 'a' in version 2 is deprecated and should return the default
- // value (0) instead of the value stored in the in the buffer (42).
- TEST_EQ(root_v2_viewed_from_v1->a(), 0);
- // The field 'ff' was originally named 'f' in version 1, it should still be
- // readable.
- TEST_EQ(root_v2_viewed_from_v1->f()->a(), 35);
-#endif
-}
-
-void UnionDeprecationTest() {
- const int NUM_VERSIONS = 2;
- std::string schemas[NUM_VERSIONS];
- std::string jsonfiles[NUM_VERSIONS];
- std::vector<uint8_t> binaries[NUM_VERSIONS];
-
- flatbuffers::IDLOptions idl_opts;
- idl_opts.lang_to_generate |= flatbuffers::IDLOptions::kBinary;
- flatbuffers::Parser parser(idl_opts);
-
- // Load all the schema versions and their associated data.
- for (int i = 0; i < NUM_VERSIONS; ++i) {
- std::string schema = test_data_path + "evolution_test/evolution_v" +
- flatbuffers::NumToString(i + 1) + ".fbs";
- TEST_ASSERT(flatbuffers::LoadFile(schema.c_str(), false, &schemas[i]));
- std::string json = test_data_path + "evolution_test/evolution_v" +
- flatbuffers::NumToString(i + 1) + ".json";
- TEST_ASSERT(flatbuffers::LoadFile(json.c_str(), false, &jsonfiles[i]));
-
- TEST_ASSERT(parser.Parse(schemas[i].c_str()));
- TEST_ASSERT(parser.Parse(jsonfiles[i].c_str()));
-
- auto bufLen = parser.builder_.GetSize();
- auto buf = parser.builder_.GetBufferPointer();
- binaries[i].reserve(bufLen);
- std::copy(buf, buf + bufLen, std::back_inserter(binaries[i]));
- }
-
- auto v2 = parser.LookupStruct("Evolution.V2.Root");
- TEST_NOTNULL(v2);
- auto j_type_field = v2->fields.Lookup("j_type");
- TEST_NOTNULL(j_type_field);
- TEST_ASSERT(j_type_field->deprecated);
-}
-
-void UnionVectorTest() {
+void UnionVectorTest(const std::string &tests_data_path) {
// load FlatBuffer fbs schema and json.
std::string schemafile, jsonfile;
TEST_EQ(flatbuffers::LoadFile(
- (test_data_path + "union_vector/union_vector.fbs").c_str(), false,
- &schemafile),
+ (tests_data_path + "union_vector/union_vector.fbs").c_str(),
+ false, &schemafile),
true);
TEST_EQ(flatbuffers::LoadFile(
- (test_data_path + "union_vector/union_vector.json").c_str(),
+ (tests_data_path + "union_vector/union_vector.json").c_str(),
false, &jsonfile),
true);
@@ -3035,339 +377,6 @@
TEST_EQ(parser2.Parse("{a_type:Bool,a:{b:true}}"), true);
}
-void StructUnionTest() {
- GadgetUnion gadget;
- gadget.Set(FallingTub(100));
-
- HandFanT fan;
- fan.length = 10;
- gadget.Set(fan);
-}
-
-void WarningsAsErrorsTest() {
- {
- flatbuffers::IDLOptions opts;
- // opts.warnings_as_errors should default to false
- flatbuffers::Parser parser(opts);
- TEST_EQ(parser.Parse("table T { THIS_NAME_CAUSES_A_WARNING:string;}\n"
- "root_type T;"),
- true);
- }
- {
- flatbuffers::IDLOptions opts;
- opts.warnings_as_errors = true;
- flatbuffers::Parser parser(opts);
- TEST_EQ(parser.Parse("table T { THIS_NAME_CAUSES_A_WARNING:string;}\n"
- "root_type T;"),
- false);
- }
-}
-
-void ConformTest() {
- flatbuffers::Parser parser;
- TEST_EQ(parser.Parse("table T { A:int; } enum E:byte { A }"), true);
-
- auto test_conform = [](flatbuffers::Parser &parser1, const char *test,
- const char *expected_err) {
- flatbuffers::Parser parser2;
- TEST_EQ(parser2.Parse(test), true);
- auto err = parser2.ConformTo(parser1);
- TEST_NOTNULL(strstr(err.c_str(), expected_err));
- };
-
- test_conform(parser, "table T { A:byte; }", "types differ for field");
- test_conform(parser, "table T { B:int; A:int; }", "offsets differ for field");
- test_conform(parser, "table T { A:int = 1; }", "defaults differ for field");
- test_conform(parser, "table T { B:float; }",
- "field renamed to different type");
- test_conform(parser, "enum E:byte { B, A }", "values differ for enum");
-}
-
-void ParseProtoBufAsciiTest() {
- // We can put the parser in a mode where it will accept JSON that looks more
- // like Protobuf ASCII, for users that have data in that format.
- // This uses no "" for field names (which we already support by default,
- // omits `,`, `:` before `{` and a couple of other features.
- flatbuffers::Parser parser;
- parser.opts.protobuf_ascii_alike = true;
- TEST_EQ(
- parser.Parse("table S { B:int; } table T { A:[int]; C:S; } root_type T;"),
- true);
- TEST_EQ(parser.Parse("{ A [1 2] C { B:2 }}"), true);
- // Similarly, in text output, it should omit these.
- std::string text;
- auto ok = flatbuffers::GenerateText(
- parser, parser.builder_.GetBufferPointer(), &text);
- TEST_EQ(ok, true);
- TEST_EQ_STR(text.c_str(),
- "{\n A [\n 1\n 2\n ]\n C {\n B: 2\n }\n}\n");
-}
-
-void FlexBuffersTest() {
- flexbuffers::Builder slb(512,
- flexbuffers::BUILDER_FLAG_SHARE_KEYS_AND_STRINGS);
-
- // Write the equivalent of:
- // { vec: [ -100, "Fred", 4.0, false ], bar: [ 1, 2, 3 ], bar3: [ 1, 2, 3 ],
- // foo: 100, bool: true, mymap: { foo: "Fred" } }
-
- // It's possible to do this without std::function support as well.
- slb.Map([&]() {
- slb.Vector("vec", [&]() {
- slb += -100; // Equivalent to slb.Add(-100) or slb.Int(-100);
- slb += "Fred";
- slb.IndirectFloat(4.0f);
- auto i_f = slb.LastValue();
- uint8_t blob[] = { 77 };
- slb.Blob(blob, 1);
- slb += false;
- slb.ReuseValue(i_f);
- });
- int ints[] = { 1, 2, 3 };
- slb.Vector("bar", ints, 3);
- slb.FixedTypedVector("bar3", ints, 3);
- bool bools[] = { true, false, true, false };
- slb.Vector("bools", bools, 4);
- slb.Bool("bool", true);
- slb.Double("foo", 100);
- slb.Map("mymap", [&]() {
- slb.String("foo", "Fred"); // Testing key and string reuse.
- });
- });
- slb.Finish();
-
-// clang-format off
- #ifdef FLATBUFFERS_TEST_VERBOSE
- for (size_t i = 0; i < slb.GetBuffer().size(); i++)
- printf("%d ", slb.GetBuffer().data()[i]);
- printf("\n");
- #endif
- // clang-format on
-
- std::vector<uint8_t> reuse_tracker;
- TEST_EQ(flexbuffers::VerifyBuffer(slb.GetBuffer().data(),
- slb.GetBuffer().size(), &reuse_tracker),
- true);
-
- auto map = flexbuffers::GetRoot(slb.GetBuffer()).AsMap();
- TEST_EQ(map.size(), 7);
- auto vec = map["vec"].AsVector();
- TEST_EQ(vec.size(), 6);
- TEST_EQ(vec[0].AsInt64(), -100);
- TEST_EQ_STR(vec[1].AsString().c_str(), "Fred");
- TEST_EQ(vec[1].AsInt64(), 0); // Number parsing failed.
- TEST_EQ(vec[2].AsDouble(), 4.0);
- TEST_EQ(vec[2].AsString().IsTheEmptyString(), true); // Wrong Type.
- TEST_EQ_STR(vec[2].AsString().c_str(), ""); // This still works though.
- TEST_EQ_STR(vec[2].ToString().c_str(), "4.0"); // Or have it converted.
- // Few tests for templated version of As.
- TEST_EQ(vec[0].As<int64_t>(), -100);
- TEST_EQ_STR(vec[1].As<std::string>().c_str(), "Fred");
- TEST_EQ(vec[1].As<int64_t>(), 0); // Number parsing failed.
- TEST_EQ(vec[2].As<double>(), 4.0);
- // Test that the blob can be accessed.
- TEST_EQ(vec[3].IsBlob(), true);
- auto blob = vec[3].AsBlob();
- TEST_EQ(blob.size(), 1);
- TEST_EQ(blob.data()[0], 77);
- TEST_EQ(vec[4].IsBool(), true); // Check if type is a bool
- TEST_EQ(vec[4].AsBool(), false); // Check if value is false
- TEST_EQ(vec[5].AsDouble(), 4.0); // This is shared with vec[2] !
- auto tvec = map["bar"].AsTypedVector();
- TEST_EQ(tvec.size(), 3);
- TEST_EQ(tvec[2].AsInt8(), 3);
- auto tvec3 = map["bar3"].AsFixedTypedVector();
- TEST_EQ(tvec3.size(), 3);
- TEST_EQ(tvec3[2].AsInt8(), 3);
- TEST_EQ(map["bool"].AsBool(), true);
- auto tvecb = map["bools"].AsTypedVector();
- TEST_EQ(tvecb.ElementType(), flexbuffers::FBT_BOOL);
- TEST_EQ(map["foo"].AsUInt8(), 100);
- TEST_EQ(map["unknown"].IsNull(), true);
- auto mymap = map["mymap"].AsMap();
- // These should be equal by pointer equality, since key and value are shared.
- TEST_EQ(mymap.Keys()[0].AsKey(), map.Keys()[4].AsKey());
- TEST_EQ(mymap.Values()[0].AsString().c_str(), vec[1].AsString().c_str());
- // We can mutate values in the buffer.
- TEST_EQ(vec[0].MutateInt(-99), true);
- TEST_EQ(vec[0].AsInt64(), -99);
- TEST_EQ(vec[1].MutateString("John"), true); // Size must match.
- TEST_EQ_STR(vec[1].AsString().c_str(), "John");
- TEST_EQ(vec[1].MutateString("Alfred"), false); // Too long.
- TEST_EQ(vec[2].MutateFloat(2.0f), true);
- TEST_EQ(vec[2].AsFloat(), 2.0f);
- TEST_EQ(vec[2].MutateFloat(3.14159), false); // Double does not fit in float.
- TEST_EQ(vec[4].AsBool(), false); // Is false before change
- TEST_EQ(vec[4].MutateBool(true), true); // Can change a bool
- TEST_EQ(vec[4].AsBool(), true); // Changed bool is now true
-
- // Parse from JSON:
- flatbuffers::Parser parser;
- slb.Clear();
- auto jsontest = "{ a: [ 123, 456.0 ], b: \"hello\", c: true, d: false }";
- TEST_EQ(parser.ParseFlexBuffer(jsontest, nullptr, &slb), true);
- TEST_EQ(flexbuffers::VerifyBuffer(slb.GetBuffer().data(),
- slb.GetBuffer().size(), &reuse_tracker),
- true);
- auto jroot = flexbuffers::GetRoot(slb.GetBuffer());
- auto jmap = jroot.AsMap();
- auto jvec = jmap["a"].AsVector();
- TEST_EQ(jvec[0].AsInt64(), 123);
- TEST_EQ(jvec[1].AsDouble(), 456.0);
- TEST_EQ_STR(jmap["b"].AsString().c_str(), "hello");
- TEST_EQ(jmap["c"].IsBool(), true); // Parsed correctly to a bool
- TEST_EQ(jmap["c"].AsBool(), true); // Parsed correctly to true
- TEST_EQ(jmap["d"].IsBool(), true); // Parsed correctly to a bool
- TEST_EQ(jmap["d"].AsBool(), false); // Parsed correctly to false
- // And from FlexBuffer back to JSON:
- auto jsonback = jroot.ToString();
- TEST_EQ_STR(jsontest, jsonback.c_str());
-
- slb.Clear();
- slb.Vector([&]() {
- for (int i = 0; i < 130; ++i) slb.Add(static_cast<uint8_t>(255));
- slb.Vector([&]() {
- for (int i = 0; i < 130; ++i) slb.Add(static_cast<uint8_t>(255));
- slb.Vector([] {});
- });
- });
- slb.Finish();
- TEST_EQ(slb.GetSize(), 664);
-}
-
-void FlexBuffersFloatingPointTest() {
-#if defined(FLATBUFFERS_HAS_NEW_STRTOD) && (FLATBUFFERS_HAS_NEW_STRTOD > 0)
- flexbuffers::Builder slb(512,
- flexbuffers::BUILDER_FLAG_SHARE_KEYS_AND_STRINGS);
- // Parse floating-point values from JSON:
- flatbuffers::Parser parser;
- slb.Clear();
- auto jsontest =
- "{ a: [1.0, nan, inf, infinity, -inf, +inf, -infinity, 8.0] }";
- TEST_EQ(parser.ParseFlexBuffer(jsontest, nullptr, &slb), true);
- auto jroot = flexbuffers::GetRoot(slb.GetBuffer());
- TEST_EQ(flexbuffers::VerifyBuffer(slb.GetBuffer().data(),
- slb.GetBuffer().size(), nullptr),
- true);
- auto jmap = jroot.AsMap();
- auto jvec = jmap["a"].AsVector();
- TEST_EQ(8, jvec.size());
- TEST_EQ(1.0, jvec[0].AsDouble());
- TEST_ASSERT(is_quiet_nan(jvec[1].AsDouble()));
- TEST_EQ(infinity_d, jvec[2].AsDouble());
- TEST_EQ(infinity_d, jvec[3].AsDouble());
- TEST_EQ(-infinity_d, jvec[4].AsDouble());
- TEST_EQ(+infinity_d, jvec[5].AsDouble());
- TEST_EQ(-infinity_d, jvec[6].AsDouble());
- TEST_EQ(8.0, jvec[7].AsDouble());
-#endif
-}
-
-void FlexBuffersDeprecatedTest() {
- // FlexBuffers as originally designed had a flaw involving the
- // FBT_VECTOR_STRING datatype, and this test documents/tests the fix for it.
- // Discussion: https://github.com/google/flatbuffers/issues/5627
- flexbuffers::Builder slb;
- // FBT_VECTOR_* are "typed vectors" where all elements are of the same type.
- // Problem is, when storing FBT_STRING elements, it relies on that type to
- // get the bit-width for the size field of the string, which in this case
- // isn't present, and instead defaults to 8-bit. This means that any strings
- // stored inside such a vector, when accessed thru the old API that returns
- // a String reference, will appear to be truncated if the string stored is
- // actually >=256 bytes.
- std::string test_data(300, 'A');
- auto start = slb.StartVector();
- // This one will have a 16-bit size field.
- slb.String(test_data);
- // This one will have an 8-bit size field.
- slb.String("hello");
- // We're asking this to be serialized as a typed vector (true), but not
- // fixed size (false). The type will be FBT_VECTOR_STRING with a bit-width
- // of whatever the offsets in the vector need, the bit-widths of the strings
- // are not stored(!) <- the actual design flaw.
- // Note that even in the fixed code, we continue to serialize the elements of
- // FBT_VECTOR_STRING as FBT_STRING, since there may be old code out there
- // reading new data that we want to continue to function.
- // Thus, FBT_VECTOR_STRING, while deprecated, will always be represented the
- // same way, the fix lies on the reading side.
- slb.EndVector(start, true, false);
- slb.Finish();
- // Verify because why not.
- TEST_EQ(flexbuffers::VerifyBuffer(slb.GetBuffer().data(),
- slb.GetBuffer().size(), nullptr),
- true);
- // So now lets read this data back.
- // For existing data, since we have no way of knowing what the actual
- // bit-width of the size field of the string is, we are going to ignore this
- // field, and instead treat these strings as FBT_KEY (null-terminated), so we
- // can deal with strings of arbitrary length. This of course truncates strings
- // with embedded nulls, but we think that that is preferrable over truncating
- // strings >= 256 bytes.
- auto vec = flexbuffers::GetRoot(slb.GetBuffer()).AsTypedVector();
- // Even though this was serialized as FBT_VECTOR_STRING, it is read as
- // FBT_VECTOR_KEY:
- TEST_EQ(vec.ElementType(), flexbuffers::FBT_KEY);
- // Access the long string. Previously, this would return a string of size 1,
- // since it would read the high-byte of the 16-bit length.
- // This should now correctly test the full 300 bytes, using AsKey():
- TEST_EQ_STR(vec[0].AsKey(), test_data.c_str());
- // Old code that called AsString will continue to work, as the String
- // accessor objects now use a cached size that can come from a key as well.
- TEST_EQ_STR(vec[0].AsString().c_str(), test_data.c_str());
- // Short strings work as before:
- TEST_EQ_STR(vec[1].AsKey(), "hello");
- TEST_EQ_STR(vec[1].AsString().c_str(), "hello");
- // So, while existing code and data mostly "just work" with the fixes applied
- // to AsTypedVector and AsString, what do you do going forward?
- // Code accessing existing data doesn't necessarily need to change, though
- // you could consider using AsKey instead of AsString for a) documenting
- // that you are accessing keys, or b) a speedup if you don't actually use
- // the string size.
- // For new data, or data that doesn't need to be backwards compatible,
- // instead serialize as FBT_VECTOR (call EndVector with typed = false, then
- // read elements with AsString), or, for maximum compactness, use
- // FBT_VECTOR_KEY (call slb.Key above instead, read with AsKey or AsString).
-}
-
-void TypeAliasesTest() {
- flatbuffers::FlatBufferBuilder builder;
-
- builder.Finish(CreateTypeAliases(
- builder, flatbuffers::numeric_limits<int8_t>::min(),
- flatbuffers::numeric_limits<uint8_t>::max(),
- flatbuffers::numeric_limits<int16_t>::min(),
- flatbuffers::numeric_limits<uint16_t>::max(),
- flatbuffers::numeric_limits<int32_t>::min(),
- flatbuffers::numeric_limits<uint32_t>::max(),
- flatbuffers::numeric_limits<int64_t>::min(),
- flatbuffers::numeric_limits<uint64_t>::max(), 2.3f, 2.3));
-
- auto p = builder.GetBufferPointer();
- auto ta = flatbuffers::GetRoot<TypeAliases>(p);
-
- TEST_EQ(ta->i8(), flatbuffers::numeric_limits<int8_t>::min());
- TEST_EQ(ta->u8(), flatbuffers::numeric_limits<uint8_t>::max());
- TEST_EQ(ta->i16(), flatbuffers::numeric_limits<int16_t>::min());
- TEST_EQ(ta->u16(), flatbuffers::numeric_limits<uint16_t>::max());
- TEST_EQ(ta->i32(), flatbuffers::numeric_limits<int32_t>::min());
- TEST_EQ(ta->u32(), flatbuffers::numeric_limits<uint32_t>::max());
- TEST_EQ(ta->i64(), flatbuffers::numeric_limits<int64_t>::min());
- TEST_EQ(ta->u64(), flatbuffers::numeric_limits<uint64_t>::max());
- TEST_EQ(ta->f32(), 2.3f);
- TEST_EQ(ta->f64(), 2.3);
- using namespace flatbuffers; // is_same
- static_assert(is_same<decltype(ta->i8()), int8_t>::value, "invalid type");
- static_assert(is_same<decltype(ta->i16()), int16_t>::value, "invalid type");
- static_assert(is_same<decltype(ta->i32()), int32_t>::value, "invalid type");
- static_assert(is_same<decltype(ta->i64()), int64_t>::value, "invalid type");
- static_assert(is_same<decltype(ta->u8()), uint8_t>::value, "invalid type");
- static_assert(is_same<decltype(ta->u16()), uint16_t>::value, "invalid type");
- static_assert(is_same<decltype(ta->u32()), uint32_t>::value, "invalid type");
- static_assert(is_same<decltype(ta->u64()), uint64_t>::value, "invalid type");
- static_assert(is_same<decltype(ta->f32()), float>::value, "invalid type");
- static_assert(is_same<decltype(ta->f64()), double>::value, "invalid type");
-}
-
void EndianSwapTest() {
TEST_EQ(flatbuffers::EndianSwap(static_cast<int16_t>(0x1234)), 0x3412);
TEST_EQ(flatbuffers::EndianSwap(static_cast<int32_t>(0x12345678)),
@@ -3455,17 +464,47 @@
b.test.type = Any_Monster;
TEST_EQ(b == a, false);
TEST_EQ(b != a, true);
-}
-// For testing any binaries, e.g. from fuzzing.
-void LoadVerifyBinaryTest() {
- std::string binary;
- if (flatbuffers::LoadFile(
- (test_data_path + "fuzzer/your-filename-here").c_str(), true,
- &binary)) {
- flatbuffers::Verifier verifier(
- reinterpret_cast<const uint8_t *>(binary.data()), binary.size());
- TEST_EQ(VerifyMonsterBuffer(verifier), true);
+ // Test that vector of tables are compared by value and not by reference.
+ {
+ // Two tables are equal by default.
+ MonsterT a, b;
+ TEST_EQ(a == b, true);
+
+ // Adding only a table to one of the monster vectors should make it not
+ // equal (due to size mistmatch).
+ a.testarrayoftables.push_back(
+ flatbuffers::unique_ptr<MonsterT>(new MonsterT));
+ TEST_EQ(a == b, false);
+
+ // Adding an equalivant table to the other monster vector should make it
+ // equal again.
+ b.testarrayoftables.push_back(
+ flatbuffers::unique_ptr<MonsterT>(new MonsterT));
+ TEST_EQ(a == b, true);
+
+ // Create two new monsters that are different.
+ auto c = flatbuffers::unique_ptr<MonsterT>(new MonsterT);
+ auto d = flatbuffers::unique_ptr<MonsterT>(new MonsterT);
+ c->hp = 1;
+ d->hp = 2;
+ TEST_EQ(c == d, false);
+
+ // Adding them to the original monsters should also make them different.
+ a.testarrayoftables.push_back(std::move(c));
+ b.testarrayoftables.push_back(std::move(d));
+ TEST_EQ(a == b, false);
+
+ // Remove the mismatching monsters to get back to equality
+ a.testarrayoftables.pop_back();
+ b.testarrayoftables.pop_back();
+ TEST_EQ(a == b, true);
+
+ // Check that nullptr are OK.
+ a.testarrayoftables.push_back(nullptr);
+ b.testarrayoftables.push_back(
+ flatbuffers::unique_ptr<MonsterT>(new MonsterT));
+ TEST_EQ(a == b, false);
}
}
@@ -3526,17 +565,17 @@
TEST_EQ((*a[6]) < (*a[5]), true);
}
-#if !defined(FLATBUFFERS_SPAN_MINIMAL)
+#if !defined(FLATBUFFERS_USE_STD_SPAN) && !defined(FLATBUFFERS_SPAN_MINIMAL)
void FlatbuffersSpanTest() {
// Compile-time checking of non-const [] to const [] conversions.
- using flatbuffers::internal::is_span_convertable;
- (void)is_span_convertable<int, 1, int, 1>::type(123);
- (void)is_span_convertable<const int, 1, int, 1>::type(123);
- (void)is_span_convertable<const int64_t, 1, int64_t, 1>::type(123);
- (void)is_span_convertable<const uint64_t, 1, uint64_t, 1>::type(123);
- (void)is_span_convertable<const int, 1, const int, 1>::type(123);
- (void)is_span_convertable<const int64_t, 1, const int64_t, 1>::type(123);
- (void)is_span_convertable<const uint64_t, 1, const uint64_t, 1>::type(123);
+ using flatbuffers::internal::is_span_convertible;
+ (void)is_span_convertible<int, 1, int, 1>::type(123);
+ (void)is_span_convertible<const int, 1, int, 1>::type(123);
+ (void)is_span_convertible<const int64_t, 1, int64_t, 1>::type(123);
+ (void)is_span_convertible<const uint64_t, 1, uint64_t, 1>::type(123);
+ (void)is_span_convertible<const int, 1, const int, 1>::type(123);
+ (void)is_span_convertible<const int64_t, 1, const int64_t, 1>::type(123);
+ (void)is_span_convertible<const uint64_t, 1, const uint64_t, 1>::type(123);
using flatbuffers::span;
span<char, 0> c1;
@@ -3803,18 +842,19 @@
// VS10 does not support typed enums, exclude from tests
#if !defined(_MSC_VER) || _MSC_VER >= 1700
-void FixedLengthArrayJsonTest(bool binary) {
+void FixedLengthArrayJsonTest(const std::string &tests_data_path, bool binary) {
// load FlatBuffer schema (.fbs) and JSON from disk
std::string schemafile;
std::string jsonfile;
- TEST_EQ(
- flatbuffers::LoadFile(
- (test_data_path + "arrays_test." + (binary ? "bfbs" : "fbs")).c_str(),
- binary, &schemafile),
- true);
- TEST_EQ(flatbuffers::LoadFile((test_data_path + "arrays_test.golden").c_str(),
- false, &jsonfile),
+ TEST_EQ(flatbuffers::LoadFile(
+ (tests_data_path + "arrays_test." + (binary ? "bfbs" : "fbs"))
+ .c_str(),
+ binary, &schemafile),
true);
+ TEST_EQ(
+ flatbuffers::LoadFile((tests_data_path + "arrays_test.golden").c_str(),
+ false, &jsonfile),
+ true);
// parse schema first, so we can use it to parse the data after
flatbuffers::Parser parserOrg, parserGen;
@@ -3823,11 +863,13 @@
reinterpret_cast<const uint8_t *>(schemafile.c_str()),
schemafile.size());
TEST_EQ(reflection::VerifySchemaBuffer(verifier), true);
- TEST_EQ(parserOrg.Deserialize((const uint8_t *)schemafile.c_str(),
- schemafile.size()),
+ TEST_EQ(parserOrg.Deserialize(
+ reinterpret_cast<const uint8_t *>(schemafile.c_str()),
+ schemafile.size()),
true);
- TEST_EQ(parserGen.Deserialize((const uint8_t *)schemafile.c_str(),
- schemafile.size()),
+ TEST_EQ(parserGen.Deserialize(
+ reinterpret_cast<const uint8_t *>(schemafile.c_str()),
+ schemafile.size()),
true);
} else {
TEST_EQ(parserOrg.Parse(schemafile.c_str()), true);
@@ -3862,16 +904,17 @@
0);
}
-void FixedLengthArraySpanTest() {
+void FixedLengthArraySpanTest(const std::string &tests_data_path) {
// load FlatBuffer schema (.fbs) and JSON from disk
std::string schemafile;
std::string jsonfile;
- TEST_EQ(flatbuffers::LoadFile((test_data_path + "arrays_test.fbs").c_str(),
+ TEST_EQ(flatbuffers::LoadFile((tests_data_path + "arrays_test.fbs").c_str(),
false, &schemafile),
true);
- TEST_EQ(flatbuffers::LoadFile((test_data_path + "arrays_test.golden").c_str(),
- false, &jsonfile),
- true);
+ TEST_EQ(
+ flatbuffers::LoadFile((tests_data_path + "arrays_test.golden").c_str(),
+ false, &jsonfile),
+ true);
// parse schema first, so we can use it to parse the data after
flatbuffers::Parser parser;
@@ -3911,11 +954,11 @@
TEST_EQ(2, mutable_d_c.size());
TEST_EQ(MyGame::Example::TestEnum::C, const_d_c[0]);
TEST_EQ(MyGame::Example::TestEnum::B, const_d_c[1]);
- TEST_ASSERT(mutable_d_c.end() == std::copy(const_d_c.cbegin(),
- const_d_c.cend(),
+ TEST_ASSERT(mutable_d_c.end() == std::copy(const_d_c.begin(),
+ const_d_c.end(),
mutable_d_c.begin()));
TEST_ASSERT(
- std::equal(const_d_c.cbegin(), const_d_c.cend(), mutable_d_c.cbegin()));
+ std::equal(const_d_c.begin(), const_d_c.end(), mutable_d_c.begin()));
}
// test little endian array of int32
# if FLATBUFFERS_LITTLEENDIAN
@@ -3927,11 +970,11 @@
TEST_EQ(2, mutable_d_a.size());
TEST_EQ(-1, const_d_a[0]);
TEST_EQ(2, const_d_a[1]);
- TEST_ASSERT(mutable_d_a.end() == std::copy(const_d_a.cbegin(),
- const_d_a.cend(),
+ TEST_ASSERT(mutable_d_a.end() == std::copy(const_d_a.begin(),
+ const_d_a.end(),
mutable_d_a.begin()));
TEST_ASSERT(
- std::equal(const_d_a.cbegin(), const_d_a.cend(), mutable_d_a.cbegin()));
+ std::equal(const_d_a.begin(), const_d_a.end(), mutable_d_a.begin()));
}
# endif
}
@@ -3940,11 +983,11 @@
void FixedLengthArraySpanTest() {}
#endif
-void TestEmbeddedBinarySchema() {
+void TestEmbeddedBinarySchema(const std::string &tests_data_path) {
// load JSON from disk
std::string jsonfile;
TEST_EQ(flatbuffers::LoadFile(
- (test_data_path + "monsterdata_test.golden").c_str(), false,
+ (tests_data_path + "monsterdata_test.golden").c_str(), false,
&jsonfile),
true);
@@ -3988,192 +1031,93 @@
0);
}
-void StringVectorDefaultsTest() {
- std::vector<std::string> schemas;
- schemas.push_back("table Monster { mana: string = \"\"; }");
- schemas.push_back("table Monster { mana: string = \"mystr\"; }");
- schemas.push_back("table Monster { mana: string = \" \"; }");
- schemas.push_back("table Monster { mana: string = \"null\"; }");
- schemas.push_back("table Monster { mana: [int] = []; }");
- schemas.push_back("table Monster { mana: [uint] = [ ]; }");
- schemas.push_back("table Monster { mana: [byte] = [\t\t\n]; }");
- schemas.push_back("enum E:int{}table Monster{mana:[E]=[];}");
- for (auto s = schemas.begin(); s < schemas.end(); s++) {
- flatbuffers::Parser parser;
- TEST_ASSERT(parser.Parse(s->c_str()));
- const auto *mana = parser.structs_.Lookup("Monster")->fields.Lookup("mana");
- TEST_EQ(mana->IsDefault(), true);
- }
-}
+void NestedVerifierTest() {
+ // Create a nested monster.
+ flatbuffers::FlatBufferBuilder nested_builder;
+ FinishMonsterBuffer(
+ nested_builder,
+ CreateMonster(nested_builder, nullptr, 0, 0,
+ nested_builder.CreateString("NestedMonster")));
-void OptionalScalarsTest() {
- // Simple schemas and a "has optional scalar" sentinal.
- std::vector<std::string> schemas;
- schemas.push_back("table Monster { mana : int; }");
- schemas.push_back("table Monster { mana : int = 42; }");
- schemas.push_back("table Monster { mana : int = null; }");
- schemas.push_back("table Monster { mana : long; }");
- schemas.push_back("table Monster { mana : long = 42; }");
- schemas.push_back("table Monster { mana : long = null; }");
- schemas.push_back("table Monster { mana : float; }");
- schemas.push_back("table Monster { mana : float = 42; }");
- schemas.push_back("table Monster { mana : float = null; }");
- schemas.push_back("table Monster { mana : double; }");
- schemas.push_back("table Monster { mana : double = 42; }");
- schemas.push_back("table Monster { mana : double = null; }");
- schemas.push_back("table Monster { mana : bool; }");
- schemas.push_back("table Monster { mana : bool = 42; }");
- schemas.push_back("table Monster { mana : bool = null; }");
- schemas.push_back(
- "enum Enum: int {A=0, B=1} "
- "table Monster { mana : Enum; }");
- schemas.push_back(
- "enum Enum: int {A=0, B=1} "
- "table Monster { mana : Enum = B; }");
- schemas.push_back(
- "enum Enum: int {A=0, B=1} "
- "table Monster { mana : Enum = null; }");
+ // Verify the nested monster
+ flatbuffers::Verifier verifier(nested_builder.GetBufferPointer(),
+ nested_builder.GetSize());
+ TEST_EQ(true, VerifyMonsterBuffer(verifier));
- // Check the FieldDef is correctly set.
- for (auto schema = schemas.begin(); schema < schemas.end(); schema++) {
- const bool has_null = schema->find("null") != std::string::npos;
- flatbuffers::Parser parser;
- TEST_ASSERT(parser.Parse(schema->c_str()));
- const auto *mana = parser.structs_.Lookup("Monster")->fields.Lookup("mana");
- TEST_EQ(mana->IsOptional(), has_null);
- }
-
- // Test if nullable scalars are allowed for each language.
- for (unsigned lang = 1; lang < flatbuffers::IDLOptions::kMAX; lang <<= 1) {
- flatbuffers::IDLOptions opts;
- opts.lang_to_generate = lang;
- if (false == flatbuffers::Parser::SupportsOptionalScalars(opts)) {
- continue;
- }
- for (auto schema = schemas.begin(); schema < schemas.end(); schema++) {
- flatbuffers::Parser parser(opts);
- auto done = parser.Parse(schema->c_str());
- TEST_EQ_STR(parser.error_.c_str(), "");
- TEST_ASSERT(done);
- }
- }
-
- // test C++ nullable
- flatbuffers::FlatBufferBuilder fbb;
- FinishScalarStuffBuffer(
- fbb, optional_scalars::CreateScalarStuff(fbb, 1, static_cast<int8_t>(2)));
- auto opts = optional_scalars::GetMutableScalarStuff(fbb.GetBufferPointer());
- TEST_ASSERT(!opts->maybe_bool());
- TEST_ASSERT(!opts->maybe_f32().has_value());
- TEST_ASSERT(opts->maybe_i8().has_value());
- TEST_EQ(opts->maybe_i8().value(), 2);
- TEST_ASSERT(opts->mutate_maybe_i8(3));
- TEST_ASSERT(opts->maybe_i8().has_value());
- TEST_EQ(opts->maybe_i8().value(), 3);
- TEST_ASSERT(!opts->mutate_maybe_i16(-10));
-
- optional_scalars::ScalarStuffT obj;
- TEST_ASSERT(!obj.maybe_bool);
- TEST_ASSERT(!obj.maybe_f32.has_value());
- opts->UnPackTo(&obj);
- TEST_ASSERT(!obj.maybe_bool);
- TEST_ASSERT(!obj.maybe_f32.has_value());
- TEST_ASSERT(obj.maybe_i8.has_value() && obj.maybe_i8.value() == 3);
- TEST_ASSERT(obj.maybe_i8 && *obj.maybe_i8 == 3);
- obj.maybe_i32 = -1;
- obj.maybe_enum = optional_scalars::OptionalByte_Two;
-
- fbb.Clear();
- FinishScalarStuffBuffer(fbb, optional_scalars::ScalarStuff::Pack(fbb, &obj));
- opts = optional_scalars::GetMutableScalarStuff(fbb.GetBufferPointer());
- TEST_ASSERT(opts->maybe_i8().has_value());
- TEST_EQ(opts->maybe_i8().value(), 3);
- TEST_ASSERT(opts->maybe_i32().has_value());
- TEST_EQ(opts->maybe_i32().value(), -1);
- TEST_EQ(opts->maybe_enum().value(), optional_scalars::OptionalByte_Two);
- TEST_ASSERT(opts->maybe_i32() == flatbuffers::Optional<int64_t>(-1));
-}
-
-void ParseFlexbuffersFromJsonWithNullTest() {
- // Test nulls are handled appropriately through flexbuffers to exercise other
- // code paths of ParseSingleValue in the optional scalars change.
- // TODO(cneo): Json -> Flatbuffers test once some language can generate code
- // with optional scalars.
{
- char json[] = "{\"opt_field\": 123 }";
- flatbuffers::Parser parser;
- flexbuffers::Builder flexbuild;
- parser.ParseFlexBuffer(json, nullptr, &flexbuild);
- auto root = flexbuffers::GetRoot(flexbuild.GetBuffer());
- TEST_EQ(root.AsMap()["opt_field"].AsInt64(), 123);
+ // Create the outer monster.
+ flatbuffers::FlatBufferBuilder builder;
+
+ // Add the nested monster as a vector of bytes.
+ auto nested_monster_bytes = builder.CreateVector(
+ nested_builder.GetBufferPointer(), nested_builder.GetSize());
+
+ auto name = builder.CreateString("OuterMonster");
+
+ MonsterBuilder mon_builder(builder);
+ mon_builder.add_name(name);
+ mon_builder.add_testnestedflatbuffer(nested_monster_bytes);
+ FinishMonsterBuffer(builder, mon_builder.Finish());
+
+ // Verify the root monster, which includes verifing the nested monster
+ flatbuffers::Verifier verifier(builder.GetBufferPointer(),
+ builder.GetSize());
+ TEST_EQ(true, VerifyMonsterBuffer(verifier));
}
+
{
- char json[] = "{\"opt_field\": 123.4 }";
- flatbuffers::Parser parser;
- flexbuffers::Builder flexbuild;
- parser.ParseFlexBuffer(json, nullptr, &flexbuild);
- auto root = flexbuffers::GetRoot(flexbuild.GetBuffer());
- TEST_EQ(root.AsMap()["opt_field"].AsDouble(), 123.4);
+ // Create the outer monster.
+ flatbuffers::FlatBufferBuilder builder;
+
+ // Purposely invalidate the nested flatbuffer setting its length to 1, an
+ // invalid length.
+ uint8_t invalid_nested_buffer[1];
+ auto nested_monster_bytes = builder.CreateVector(invalid_nested_buffer, 1);
+
+ auto name = builder.CreateString("OuterMonster");
+
+ MonsterBuilder mon_builder(builder);
+ mon_builder.add_name(name);
+ mon_builder.add_testnestedflatbuffer(nested_monster_bytes);
+ FinishMonsterBuffer(builder, mon_builder.Finish());
+
+ // Verify the root monster fails, since the included nested monster fails.
+ flatbuffers::Verifier verifier(builder.GetBufferPointer(),
+ builder.GetSize());
+ TEST_EQ(false, VerifyMonsterBuffer(verifier));
+
+ // Verify the root monster succeeds, since we've disabled checking nested
+ // flatbuffers
+ flatbuffers::Verifier::Options options;
+ options.check_nested_flatbuffers = false;
+ flatbuffers::Verifier no_check_nested(builder.GetBufferPointer(),
+ builder.GetSize(), options);
+ TEST_EQ(true, VerifyMonsterBuffer(no_check_nested));
}
+
{
- char json[] = "{\"opt_field\": null }";
- flatbuffers::Parser parser;
- flexbuffers::Builder flexbuild;
- parser.ParseFlexBuffer(json, nullptr, &flexbuild);
- auto root = flexbuffers::GetRoot(flexbuild.GetBuffer());
- TEST_ASSERT(!root.AsMap().IsTheEmptyMap());
- TEST_ASSERT(root.AsMap()["opt_field"].IsNull());
- TEST_EQ(root.ToString(), std::string("{ opt_field: null }"));
+ // Create the outer monster.
+ flatbuffers::FlatBufferBuilder builder;
+
+ // Purposely invalidate the nested flatbuffer setting its length to 0, an
+ // invalid length.
+ uint8_t *invalid_nested_buffer = nullptr;
+ auto nested_monster_bytes = builder.CreateVector(invalid_nested_buffer, 0);
+
+ auto name = builder.CreateString("OuterMonster");
+
+ MonsterBuilder mon_builder(builder);
+ mon_builder.add_name(name);
+ mon_builder.add_testnestedflatbuffer(nested_monster_bytes);
+ FinishMonsterBuffer(builder, mon_builder.Finish());
+
+ // Verify the root monster fails, since the included nested monster fails.
+ flatbuffers::Verifier verifier(builder.GetBufferPointer(),
+ builder.GetSize());
+ TEST_EQ(false, VerifyMonsterBuffer(verifier));
}
}
-void FieldIdentifierTest() {
- using flatbuffers::Parser;
- TEST_EQ(true, Parser().Parse("table T{ f: int (id:0); }"));
- // non-integer `id` should be rejected
- TEST_EQ(false, Parser().Parse("table T{ f: int (id:text); }"));
- TEST_EQ(false, Parser().Parse("table T{ f: int (id:\"text\"); }"));
- TEST_EQ(false, Parser().Parse("table T{ f: int (id:0text); }"));
- TEST_EQ(false, Parser().Parse("table T{ f: int (id:1.0); }"));
- TEST_EQ(false, Parser().Parse("table T{ f: int (id:-1); g: int (id:0); }"));
- TEST_EQ(false, Parser().Parse("table T{ f: int (id:129496726); }"));
- // A unuion filed occupys two ids: enumerator + pointer (offset).
- TEST_EQ(false,
- Parser().Parse("union X{} table T{ u: X(id:0); table F{x:int;\n}"));
- // Positive tests for unions
- TEST_EQ(true, Parser().Parse("union X{} table T{ u: X (id:1); }"));
- TEST_EQ(true, Parser().Parse("union X{} table T{ u: X; }"));
- // Test using 'inf' and 'nan' words both as identifiers and as default values.
- TEST_EQ(true, Parser().Parse("table T{ nan: string; }"));
- TEST_EQ(true, Parser().Parse("table T{ inf: string; }"));
-#if defined(FLATBUFFERS_HAS_NEW_STRTOD) && (FLATBUFFERS_HAS_NEW_STRTOD > 0)
- TEST_EQ(true, Parser().Parse("table T{ inf: float = inf; }"));
- TEST_EQ(true, Parser().Parse("table T{ nan: float = inf; }"));
-#endif
-}
-
-void ParseIncorrectMonsterJsonTest() {
- std::string schemafile;
- TEST_EQ(flatbuffers::LoadFile((test_data_path + "monster_test.bfbs").c_str(),
- true, &schemafile),
- true);
- flatbuffers::Parser parser;
- flatbuffers::Verifier verifier(
- reinterpret_cast<const uint8_t *>(schemafile.c_str()), schemafile.size());
- TEST_EQ(reflection::VerifySchemaBuffer(verifier), true);
- TEST_EQ(parser.Deserialize((const uint8_t *)schemafile.c_str(),
- schemafile.size()),
- true);
- TEST_EQ(parser.ParseJson("{name:\"monster\"}"), true);
- TEST_EQ(parser.ParseJson(""), false);
- TEST_EQ(parser.ParseJson("{name: 1}"), false);
- TEST_EQ(parser.ParseJson("{name:+1}"), false);
- TEST_EQ(parser.ParseJson("{name:-1}"), false);
- TEST_EQ(parser.ParseJson("{name:-f}"), false);
- TEST_EQ(parser.ParseJson("{name:+f}"), false);
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1700
template<class T, class Container>
void TestIterators(const std::vector<T> &expected, const Container &tested) {
TEST_ASSERT(tested.rbegin().base() == tested.end());
@@ -4232,21 +1176,232 @@
TestIterators(std::vector<int>(15, 0), int_15);
}
}
-#else
-void FlatbuffersIteratorsTest() {}
-#endif
-int FlatBufferTests() {
- // clang-format off
+void PrivateAnnotationsLeaks() {
+ // Simple schemas and a "has optional scalar" sentinal.
+ std::vector<std::string> schemas;
+ std::vector<std::string> failure_schemas;
+ // (private) (table/struct)
+ schemas.push_back(
+ "table Monster (private) { mana: int; }"
+ "struct ABC (private) { mana: int; }");
+
+ // (public) (table/struct)
+ schemas.push_back(
+ "table Monster { mana: int; }"
+ "struct ABC { mana: int; }");
+
+ // (private) (union) containing (private) (table/struct)
+ schemas.push_back(
+ "table Monster (private) { mana: int; } "
+ "struct ABC (private) { mana: int; } "
+ "union Any (private) { Monster, ABC } ");
+
+ // (public) (union) containing (public) (table/struct)
+ schemas.push_back(
+ "table Monster { mana: int; }"
+ "struct ABC { mana: int; }"
+ "union Any { Monster, ABC }");
+
+ // (private) (table/struct/enum)
+ schemas.push_back(
+ "table Monster (private) { mana: int; }"
+ "struct ABC (private) { mana: int; }"
+ "enum Race:byte (private) { None = -1, Human = 0, }");
+
+ // (public) (table/struct/enum)
+ schemas.push_back(
+ "table Monster { mana: int; }"
+ "struct ABC { mana: int; }"
+ "enum Race:byte { None = -1, Human = 0, }");
+
+ // (private) (union) containing (private) (table/struct)
+ schemas.push_back(
+ "table Monster (private) { mana: int; }"
+ "struct ABC (private) { mana: int; }"
+ "enum Race:byte (private) { None = -1, Human = 0, }"
+ "union Any (private) { Monster, ABC }");
+
+ // (public) (union) containing (public) (table/struct)
+ schemas.push_back(
+ "table Monster { mana: int; }"
+ "struct ABC { mana: int; }"
+ "enum Race:byte { None = -1, Human = 0, }"
+ "union Any { Monster, ABC }");
+
+ // (private) (table), (public struct)
+ schemas.push_back(
+ "table Monster (private) { mana: int; }"
+ "struct ABC { mana: int; }");
+
+ // (private) (table), (public) (struct/enum)
+ schemas.push_back(
+ "table Monster (private) { mana: int; }"
+ "struct ABC { mana: int; }"
+ "enum Race:byte { None = -1, Human = 0, }");
+
+ // (public) (struct) containing (public) (enum)
+ schemas.push_back(
+ "enum Race:byte { None = -1, Human = 0, }"
+ "table Monster { mana: int; }"
+ "struct ABC { mana: int; type: Race; }");
+
+ // (public) (union) containing (private) (table) & (public) (struct)
+ failure_schemas.push_back(
+ "table Monster (private) { mana: int; }"
+ "struct ABC { mana: int; }"
+ "union Any { Monster, ABC }");
+
+ // (public) (union) containing (private) (table/struct)
+ failure_schemas.push_back(
+ "table Monster (private) { mana: int; }"
+ "struct ABC (private) { mana: int; }"
+ "enum Race:byte { None = -1, Human = 0, }"
+ "union Any { Monster, ABC }");
+
+ // (public) (table) containing (private) (struct)
+ failure_schemas.push_back(
+ "table Monster { mana: int; ab: ABC; }"
+ "struct ABC (private) { mana: int; }");
+
+ // (public) (struct) containing (private) (enum)
+ failure_schemas.push_back(
+ "enum Race:byte (private) { None = -1, Human = 0, }"
+ "table Monster { mana: int; }"
+ "struct ABC { mana: int; type: Race; }");
+
+ flatbuffers::IDLOptions opts;
+ opts.lang_to_generate = flatbuffers::IDLOptions::Language::kSwift;
+ opts.no_leak_private_annotations = true;
+
+ for (auto schema = schemas.begin(); schema < schemas.end(); schema++) {
+ flatbuffers::Parser parser(opts);
+ TEST_ASSERT(parser.Parse(schema->c_str()));
+ }
+
+ for (auto schema = failure_schemas.begin(); schema < failure_schemas.end();
+ schema++) {
+ flatbuffers::Parser parser(opts);
+ TEST_EQ(false, parser.Parse(schema->c_str()));
+ }
+
+ opts.no_leak_private_annotations = false;
+
+ for (auto schema = schemas.begin(); schema < schemas.end(); schema++) {
+ flatbuffers::Parser parser(opts);
+ TEST_ASSERT(parser.Parse(schema->c_str()));
+ }
+
+ for (auto schema = failure_schemas.begin(); schema < failure_schemas.end();
+ schema++) {
+ flatbuffers::Parser parser(opts);
+ TEST_ASSERT(parser.Parse(schema->c_str()));
+ }
+}
+
+void VectorSpanTest() {
+ flatbuffers::FlatBufferBuilder builder;
+
+ auto mloc = CreateMonster(
+ builder, nullptr, 0, 0, builder.CreateString("Monster"),
+ builder.CreateVector<uint8_t>({ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }));
+
+ FinishMonsterBuffer(builder, mloc);
+
+ auto monster = GetMonster(builder.GetBufferPointer());
+ auto mutable_monster = GetMutableMonster(builder.GetBufferPointer());
+
+ { // using references
+ TEST_NOTNULL(monster->inventory());
+
+ flatbuffers::span<const uint8_t> const_inventory =
+ flatbuffers::make_span(*monster->inventory());
+ TEST_EQ(const_inventory.size(), 10);
+ TEST_EQ(const_inventory[0], 0);
+ TEST_EQ(const_inventory[9], 9);
+
+ flatbuffers::span<uint8_t> mutable_inventory =
+ flatbuffers::make_span(*mutable_monster->mutable_inventory());
+ TEST_EQ(mutable_inventory.size(), 10);
+ TEST_EQ(mutable_inventory[0], 0);
+ TEST_EQ(mutable_inventory[9], 9);
+
+ mutable_inventory[0] = 42;
+ TEST_EQ(mutable_inventory[0], 42);
+
+ mutable_inventory[0] = 0;
+ TEST_EQ(mutable_inventory[0], 0);
+ }
+
+ { // using pointers
+ TEST_EQ(flatbuffers::VectorLength(monster->inventory()), 10);
+
+ flatbuffers::span<const uint8_t> const_inventory =
+ flatbuffers::make_span(monster->inventory());
+ TEST_EQ(const_inventory.size(), 10);
+ TEST_EQ(const_inventory[0], 0);
+ TEST_EQ(const_inventory[9], 9);
+
+ flatbuffers::span<uint8_t> mutable_inventory =
+ flatbuffers::make_span(mutable_monster->mutable_inventory());
+ TEST_EQ(mutable_inventory.size(), 10);
+ TEST_EQ(mutable_inventory[0], 0);
+ TEST_EQ(mutable_inventory[9], 9);
+
+ mutable_inventory[0] = 42;
+ TEST_EQ(mutable_inventory[0], 42);
+
+ mutable_inventory[0] = 0;
+ TEST_EQ(mutable_inventory[0], 0);
+ }
+
+ {
+ TEST_ASSERT(nullptr == monster->testnestedflatbuffer());
+
+ TEST_EQ(flatbuffers::VectorLength(monster->testnestedflatbuffer()), 0);
+
+ flatbuffers::span<const uint8_t> const_nested =
+ flatbuffers::make_span(monster->testnestedflatbuffer());
+ TEST_ASSERT(const_nested.empty());
+
+ flatbuffers::span<uint8_t> mutable_nested =
+ flatbuffers::make_span(mutable_monster->mutable_testnestedflatbuffer());
+ TEST_ASSERT(mutable_nested.empty());
+ }
+}
+
+void NativeInlineTableVectorTest() {
+ TestNativeInlineTableT test;
+ for (int i = 0; i < 10; ++i) {
+ NativeInlineTableT t;
+ t.a = i;
+ test.t.push_back(t);
+ }
+
+ flatbuffers::FlatBufferBuilder fbb;
+ auto offset = TestNativeInlineTable::Pack(fbb, &test);
+ fbb.Finish(offset);
+
+ auto *root =
+ flatbuffers::GetRoot<TestNativeInlineTable>(fbb.GetBufferPointer());
+ TestNativeInlineTableT unpacked;
+ root->UnPackTo(&unpacked);
+
+ for (int i = 0; i < 10; ++i) {
+ TEST_ASSERT(unpacked.t[i] == test.t[i]);
+ }
+
+ TEST_ASSERT(unpacked.t == test.t);
+}
+
+int FlatBufferTests(const std::string &tests_data_path) {
// Run our various test suites:
std::string rawbuf;
auto flatbuf1 = CreateFlatBufferTest(rawbuf);
auto flatbuf = std::move(flatbuf1); // Test move assignment.
- TriviallyCopyableTest();
-
AccessFlatBufferTest(reinterpret_cast<const uint8_t *>(rawbuf.c_str()),
rawbuf.length());
AccessFlatBufferTest(flatbuf.data(), flatbuf.size());
@@ -4254,42 +1409,48 @@
MutateFlatBuffersTest(flatbuf.data(), flatbuf.size());
ObjectFlatBuffersTest(flatbuf.data());
+ UnPackTo(flatbuf.data());
MiniReflectFlatBuffersTest(flatbuf.data());
MiniReflectFixedLengthArrayTest();
SizePrefixedTest();
- #ifndef FLATBUFFERS_NO_FILE_TESTS
- #ifdef FLATBUFFERS_TEST_PATH_PREFIX
- test_data_path = FLATBUFFERS_STRING(FLATBUFFERS_TEST_PATH_PREFIX) +
- test_data_path;
- #endif
- ParseAndGenerateTextTest(false);
- ParseAndGenerateTextTest(true);
- FixedLengthArrayJsonTest(false);
- FixedLengthArrayJsonTest(true);
- ReflectionTest(flatbuf.data(), flatbuf.size());
- ParseProtoTest();
- ParseProtoTestWithSuffix();
- ParseProtoTestWithIncludes();
- EvolutionTest();
- UnionDeprecationTest();
- UnionVectorTest();
- LoadVerifyBinaryTest();
- GenerateTableTextTest();
- TestEmbeddedBinarySchema();
- #endif
- // clang-format on
+#ifndef FLATBUFFERS_NO_FILE_TESTS
+ ParseAndGenerateTextTest(tests_data_path, false);
+ ParseAndGenerateTextTest(tests_data_path, true);
+ FixedLengthArrayJsonTest(tests_data_path, false);
+ FixedLengthArrayJsonTest(tests_data_path, true);
+ ReflectionTest(tests_data_path, flatbuf.data(), flatbuf.size());
+ ParseProtoTest(tests_data_path);
+ ParseProtoTestWithSuffix(tests_data_path);
+ ParseProtoTestWithIncludes(tests_data_path);
+ EvolutionTest(tests_data_path);
+ UnionDeprecationTest(tests_data_path);
+ UnionVectorTest(tests_data_path);
+ GenerateTableTextTest(tests_data_path);
+ TestEmbeddedBinarySchema(tests_data_path);
+ JsonOptionalTest(tests_data_path, false);
+ JsonOptionalTest(tests_data_path, true);
+ MultiFileNameClashTest(tests_data_path);
+ InvalidNestedFlatbufferTest(tests_data_path);
+ JsonDefaultTest(tests_data_path);
+ JsonEnumsTest(tests_data_path);
+ TestMonsterExtraFloats(tests_data_path);
+ ParseIncorrectMonsterJsonTest(tests_data_path);
+ FixedLengthArraySpanTest(tests_data_path);
+#endif
UtilConvertCase();
FuzzTest1();
FuzzTest2();
+ TriviallyCopyableTest();
ErrorTest();
ValueTest();
EnumValueTest();
+ NestedListTest();
EnumStringsTest();
EnumNamesTest();
EnumOutOfRangeTest();
@@ -4304,16 +1465,13 @@
UnknownFieldsTest();
ParseUnionTest();
ValidSameNameDifferentNamespaceTest();
- MultiFileNameClashTest();
- InvalidNestedFlatbufferTest();
ConformTest();
ParseProtoBufAsciiTest();
TypeAliasesTest();
EndianSwapTest();
CreateSharedStringTest();
- JsonDefaultTest();
- JsonEnumsTest();
FlexBuffersTest();
+ FlexBuffersReuseBugTest();
FlexBuffersDeprecatedTest();
UninitializedVectorTest();
EqualOperatorTest();
@@ -4321,7 +1479,6 @@
IsAsciiUtilsTest();
ValidFloatTest();
InvalidFloatTest();
- TestMonsterExtraFloats();
FixedLengthArrayTest();
NativeTypeTest();
OptionalScalarsTest();
@@ -4330,16 +1487,28 @@
FixedLengthArrayConstructorTest();
FieldIdentifierTest();
StringVectorDefaultsTest();
- ParseIncorrectMonsterJsonTest();
FlexBuffersFloatingPointTest();
FlatbuffersIteratorsTest();
- FixedLengthArraySpanTest();
- StructUnionTest();
WarningsAsErrorsTest();
+ NestedVerifierTest();
+ PrivateAnnotationsLeaks();
+ JsonUnsortedArrayTest();
+ VectorSpanTest();
+ NativeInlineTableVectorTest();
return 0;
}
+} // namespace
+} // namespace tests
+} // namespace flatbuffers
int main(int argc, const char *argv[]) {
+ std::string tests_data_path =
+#ifdef BAZEL_TEST_DATA_PATH
+ "../com_github_google_flatbuffers/tests/";
+#else
+ "tests/";
+#endif
+
for (int argi = 1; argi < argc; argi++) {
std::string arg = argv[argi];
if (arg == "--test_path") {
@@ -4347,7 +1516,9 @@
fprintf(stderr, "error: missing path following: %s\n", arg.c_str());
exit(1);
}
- test_data_path = argv[argi];
+ // Override default path if provided one.
+ tests_data_path = argv[argi];
+
} else {
fprintf(stderr, "error: Unknown argument: %s\n", arg.c_str());
exit(1);
@@ -4368,7 +1539,12 @@
TEST_OUTPUT_LINE("The global C-locale changed: %s", the_locale.c_str());
}
- FlatBufferTests();
+#ifdef FLATBUFFERS_TEST_PATH_PREFIX
+ tests_data_path =
+ FLATBUFFERS_STRING(FLATBUFFERS_TEST_PATH_PREFIX) + tests_data_path;
+#endif
+
+ flatbuffers::tests::FlatBufferTests(tests_data_path);
FlatBufferBuilderTest();
if (!testing_fails) {
diff --git a/tests/test_assert.cpp b/tests/test_assert.cpp
index e2b43a7..32dece9 100644
--- a/tests/test_assert.cpp
+++ b/tests/test_assert.cpp
@@ -40,10 +40,8 @@
testing_fails = 0;
// Disable stdout buffering to prevent information lost on assertion or core
// dump.
- setvbuf(stdout, NULL, _IONBF, 0);
- setvbuf(stderr, NULL, _IONBF, 0);
-
- flatbuffers::SetupDefaultCRTReportMode();
+ setvbuf(stdout, nullptr, _IONBF, 0);
+ setvbuf(stderr, nullptr, _IONBF, 0);
// clang-format off
diff --git a/tests/test_assert.h b/tests/test_assert.h
index e6140cc..9d5f780 100644
--- a/tests/test_assert.h
+++ b/tests/test_assert.h
@@ -51,10 +51,10 @@
// Write captured state to a log and terminate test run.
void TestFail(const char *expval, const char *val, const char *exp,
- const char *file, int line, const char *func = 0);
+ const char *file, int line, const char *func = nullptr);
void TestEqStr(const char *expval, const char *val, const char *exp,
- const char *file, int line, const char *func = 0);
+ const char *file, int line, const char *func = nullptr);
// Workaround for `enum class` printing.
// There is an issue with the printing of enums with a fixed underlying type.
diff --git a/tests/test_builder.cpp b/tests/test_builder.cpp
index ae67076..047a380 100644
--- a/tests/test_builder.cpp
+++ b/tests/test_builder.cpp
@@ -117,6 +117,9 @@
return verify(buf, expected_name, color);
}
+// forward-declared in test.cpp
+void FlatBufferBuilderTest();
+
void FlatBufferBuilderTest() {
using flatbuffers::FlatBufferBuilder;
@@ -138,5 +141,8 @@
TestSelector(tests, tests + 4));
}
+// forward-declared in test_builder.h
+void CheckTestGeneratedIsValid(const MyGame::Example::Color&);
+
// Link-time check using pointer type.
void CheckTestGeneratedIsValid(const MyGame::Example::Color &) {}
diff --git a/tests/ts/BUILD.bazel b/tests/ts/BUILD.bazel
new file mode 100644
index 0000000..054011a
--- /dev/null
+++ b/tests/ts/BUILD.bazel
@@ -0,0 +1,12 @@
+load("//:typescript.bzl", "flatbuffer_ts_library")
+
+package(default_visibility = ["//visibility:private"])
+
+flatbuffer_ts_library(
+ name = "typescript_ts_fbs",
+ srcs = ["typescript_keywords.fbs"],
+ deps = [
+ "//tests/ts/test_dir:include_ts_fbs",
+ "//tests/ts/test_dir:typescript_transitive_ts_fbs",
+ ],
+)
diff --git a/tests/JavaScriptFlexBuffersTest.js b/tests/ts/JavaScriptFlexBuffersTest.js
similarity index 98%
rename from tests/JavaScriptFlexBuffersTest.js
rename to tests/ts/JavaScriptFlexBuffersTest.js
index d2462c6..04e670c 100644
--- a/tests/JavaScriptFlexBuffersTest.js
+++ b/tests/ts/JavaScriptFlexBuffersTest.js
@@ -1,7 +1,7 @@
// Run this using JavaScriptTest.sh
import assert from 'assert'
import fs from 'fs'
-import * as flexbuffers from 'flatbuffers/js/flexbuffers'
+import * as flexbuffers from 'flatbuffers/js/flexbuffers.js'
function main() {
testSingleValueBuffers();
@@ -264,6 +264,7 @@
_assert(example);
_assert(0x100000001n);
+ _assert({ test_number: 72.6 })
}
function testRoundTripWithBuilder() {
@@ -340,7 +341,7 @@
}
function testGoldBuffer() {
- const data = new Uint8Array(fs.readFileSync('gold_flexbuffer_example.bin')).buffer;
+ const data = new Uint8Array(fs.readFileSync('../gold_flexbuffer_example.bin')).buffer;
const b1 = flexbuffers.toReference(data).get("bools").get(1);
assert.strictEqual(b1.isBool(), true);
assert.strictEqual(b1.boolValue(), false);
diff --git a/tests/JavaScriptTest.js b/tests/ts/JavaScriptTest.js
similarity index 93%
rename from tests/JavaScriptTest.js
rename to tests/ts/JavaScriptTest.js
index f1fdc69..b76dd2e 100644
--- a/tests/JavaScriptTest.js
+++ b/tests/ts/JavaScriptTest.js
@@ -3,18 +3,18 @@
import fs from 'fs'
import * as flatbuffers from 'flatbuffers'
-import { Monster, MonsterT } from './my-game/example/monster'
-import { Test } from './my-game/example/test'
-import { Stat } from './my-game/example/stat'
-import { Vec3 } from './my-game/example/vec3'
-import { Color } from './my-game/example/color';
-import { Any } from './my-game/example/any';
+import { Monster, MonsterT } from './my-game/example/monster.js'
+import { Test, TestT } from './my-game/example/test.js'
+import { Stat } from './my-game/example/stat.js'
+import { Vec3 } from './my-game/example/vec3.js'
+import { Color } from './my-game/example/color.js';
+import { Any } from './my-game/example/any.js';
function main() {
// First, let's test reading a FlatBuffer generated by C++ code:
// This file was generated from monsterdata_test.json
- var data = new Uint8Array(fs.readFileSync('monsterdata_test.mon'));
+ var data = new Uint8Array(fs.readFileSync('../monsterdata_test.mon'));
// Now test it:
@@ -47,6 +47,7 @@
fuzzTest1();
testNullStrings();
testSharedStrings();
+ testVectorOfStructs();
console.log('FlatBuffers test: completed successfully');
}
@@ -284,8 +285,8 @@
}
function testUnicode() {
- var correct = fs.readFileSync('unicode_test.mon');
- var json = JSON.parse(fs.readFileSync('unicode_test.json', 'utf8'));
+ var correct = fs.readFileSync('../unicode_test.mon');
+ var json = JSON.parse(fs.readFileSync('../unicode_test.json', 'utf8'));
// Test reading
function testReadingUnicode(bb) {
@@ -458,4 +459,22 @@
assert.strictEqual(builder.createSharedString(undefined), 0);
}
+function testVectorOfStructs() {
+ let monster = new MonsterT();
+ monster.name = 'testVectorOfStructs';
+ monster.test4 = [
+ new TestT(1, 2),
+ new TestT(3, 4)
+ ];
+
+ let builder = new flatbuffers.Builder();
+ builder.finish(monster.pack(builder));
+
+ let decodedMonster = Monster.getRootAsMonster(builder.dataBuffer()).unpack();
+ assert.strictEqual(decodedMonster.test4[0].a, 1);
+ assert.strictEqual(decodedMonster.test4[0].b, 2);
+ assert.strictEqual(decodedMonster.test4[1].a, 3);
+ assert.strictEqual(decodedMonster.test4[1].b, 4);
+}
+
main();
diff --git a/tests/JavaScriptUnionVectorTest.js b/tests/ts/JavaScriptUnionVectorTest.js
similarity index 94%
rename from tests/JavaScriptUnionVectorTest.js
rename to tests/ts/JavaScriptUnionVectorTest.js
index b80e37f..18857d6 100644
--- a/tests/JavaScriptUnionVectorTest.js
+++ b/tests/ts/JavaScriptUnionVectorTest.js
@@ -1,10 +1,10 @@
import assert from 'assert'
import * as flatbuffers from 'flatbuffers'
-import { Character } from './union_vector/character'
-import { BookReader, BookReaderT } from './union_vector/book-reader'
-import { Attacker, AttackerT } from './union_vector/attacker'
-import { Movie, MovieT } from './union_vector/movie'
+import { Character } from './union_vector/character.js'
+import { BookReader, BookReaderT } from './union_vector/book-reader.js'
+import { Attacker, AttackerT } from './union_vector/attacker.js'
+import { Movie, MovieT } from './union_vector/movie.js'
var charTypes = [
Character.Belle,
diff --git a/tests/ts/TypeScriptTest.py b/tests/ts/TypeScriptTest.py
new file mode 100755
index 0000000..c95ed72
--- /dev/null
+++ b/tests/ts/TypeScriptTest.py
@@ -0,0 +1,123 @@
+#!/usr/bin/env python3
+#
+# Copyright 2022 Google Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import platform
+import shutil
+import subprocess
+import sys
+from pathlib import Path
+
+# Get the path where this script is located so we can invoke the script from
+# any directory and have the paths work correctly.
+tests_path = Path(__file__).parent.resolve()
+
+# Get the root path as an absolute path, so all derived paths are absolute.
+root_path = tests_path.parent.parent.absolute()
+
+# Windows works with subprocess.run a bit differently.
+is_windows = platform.system() == "Windows"
+
+# Get the location of the flatc executable
+flatc_exe = Path("flatc.exe" if is_windows else "flatc")
+
+# Find and assert flatc compiler is present.
+if root_path in flatc_exe.parents:
+ flatc_exe = flatc_exe.relative_to(root_path)
+flatc_path = Path(root_path, flatc_exe)
+assert flatc_path.exists(), "Cannot find the flatc compiler " + str(flatc_path)
+
+def check_call(args, cwd=tests_path):
+ subprocess.check_call(args, cwd=str(cwd), shell=is_windows)
+
+# Execute the flatc compiler with the specified parameters
+def flatc(options, schema, prefix=None, include=None, data=None, cwd=tests_path):
+ cmd = [str(flatc_path)] + options
+ if prefix:
+ cmd += ["-o"] + [prefix]
+ if include:
+ cmd += ["-I"] + [include]
+ cmd += [schema] if isinstance(schema, str) else schema
+ if data:
+ cmd += [data] if isinstance(data, str) else data
+ check_call(cmd)
+
+print("Removing node_modules/ directory...")
+shutil.rmtree(Path(tests_path, "node_modules"), ignore_errors=True)
+
+check_call(["npm", "install", "--silent"])
+
+print("Invoking flatc...")
+flatc(
+ options=["--ts", "--gen-name-strings", "--gen-mutable", "--gen-object-api"],
+ schema="../monster_test.fbs",
+ include="../include_test",
+)
+
+flatc(
+ options=["--gen-object-api", "-b"],
+ schema="../monster_test.fbs",
+ include="../include_test",
+ data="../unicode_test.json",
+)
+
+flatc(
+ options=["--ts", "--gen-name-strings", "--gen-mutable", "--gen-object-api"],
+ schema="../union_vector/union_vector.fbs",
+ prefix="union_vector",
+)
+
+flatc(
+ options=["--ts", "--gen-name-strings"],
+ schema="../optional_scalars.fbs",
+)
+
+flatc(
+ options=["--ts", "--gen-name-strings", "--gen-mutable", "--gen-object-api"],
+ schema=[
+ "typescript_keywords.fbs",
+ "test_dir/typescript_include.fbs",
+ "test_dir/typescript_transitive_include.fbs",
+ "../../reflection/reflection.fbs",
+ ],
+ include="../../",
+)
+
+flatc(
+ options=[
+ "--ts",
+ "--gen-name-strings",
+ "--gen-mutable",
+ "--gen-object-api",
+ "--ts-flat-files",
+ ],
+ schema=[
+ "typescript_keywords.fbs",
+ "test_dir/typescript_include.fbs",
+ "test_dir/typescript_transitive_include.fbs",
+ "../../reflection/reflection.fbs",
+ ],
+ include="../../",
+)
+
+print("Running TypeScript Compiler...")
+check_call(["tsc"])
+
+NODE_CMD = ["node"]
+
+print("Running TypeScript Tests...")
+check_call(NODE_CMD + ["JavaScriptTest"])
+check_call(NODE_CMD + ["JavaScriptUnionVectorTest"])
+check_call(NODE_CMD + ["JavaScriptFlexBuffersTest"])
\ No newline at end of file
diff --git a/tests/ts/foobar/abc.js b/tests/ts/foobar/abc.js
new file mode 100644
index 0000000..cdef988
--- /dev/null
+++ b/tests/ts/foobar/abc.js
@@ -0,0 +1,5 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+export var Abc;
+(function (Abc) {
+ Abc[Abc["a"] = 0] = "a";
+})(Abc || (Abc = {}));
diff --git a/tests/ts/foobar/abc.ts b/tests/ts/foobar/abc.ts
new file mode 100644
index 0000000..ef8842b
--- /dev/null
+++ b/tests/ts/foobar/abc.ts
@@ -0,0 +1,5 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+export enum Abc {
+ a = 0
+}
diff --git a/tests/ts/foobar/class.js b/tests/ts/foobar/class.js
new file mode 100644
index 0000000..e0e1df1
--- /dev/null
+++ b/tests/ts/foobar/class.js
@@ -0,0 +1,5 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+export var class_;
+(function (class_) {
+ class_[class_["arguments_"] = 0] = "arguments_";
+})(class_ || (class_ = {}));
diff --git a/tests/ts/foobar/class.ts b/tests/ts/foobar/class.ts
new file mode 100644
index 0000000..d26fb28
--- /dev/null
+++ b/tests/ts/foobar/class.ts
@@ -0,0 +1,5 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+export enum class_ {
+ arguments_ = 0
+}
diff --git a/tests/monster_test.js b/tests/ts/monster_test.js
similarity index 91%
rename from tests/monster_test.js
rename to tests/ts/monster_test.js
index b4e13d1..afc333e 100644
--- a/tests/monster_test.js
+++ b/tests/ts/monster_test.js
@@ -9,6 +9,7 @@
export { Referrable, ReferrableT } from './my-game/example/referrable';
export { Stat, StatT } from './my-game/example/stat';
export { StructOfStructs, StructOfStructsT } from './my-game/example/struct-of-structs';
+export { StructOfStructsOfStructs, StructOfStructsOfStructsT } from './my-game/example/struct-of-structs-of-structs';
export { Test, TestT } from './my-game/example/test';
export { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from './my-game/example/test-simple-table-with-enum';
export { TypeAliases, TypeAliasesT } from './my-game/example/type-aliases';
diff --git a/tests/monster_test.ts b/tests/ts/monster_test.ts
similarity index 91%
rename from tests/monster_test.ts
rename to tests/ts/monster_test.ts
index b4e13d1..afc333e 100644
--- a/tests/monster_test.ts
+++ b/tests/ts/monster_test.ts
@@ -9,6 +9,7 @@
export { Referrable, ReferrableT } from './my-game/example/referrable';
export { Stat, StatT } from './my-game/example/stat';
export { StructOfStructs, StructOfStructsT } from './my-game/example/struct-of-structs';
+export { StructOfStructsOfStructs, StructOfStructsOfStructsT } from './my-game/example/struct-of-structs-of-structs';
export { Test, TestT } from './my-game/example/test';
export { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from './my-game/example/test-simple-table-with-enum';
export { TypeAliases, TypeAliasesT } from './my-game/example/type-aliases';
diff --git a/tests/ts/monster_test_generated.ts b/tests/ts/monster_test_generated.ts
new file mode 100644
index 0000000..18aec07
--- /dev/null
+++ b/tests/ts/monster_test_generated.ts
@@ -0,0 +1,19 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+export { Monster as MyGame_Example2_Monster, MonsterT as MyGame_Example2_MonsterT } from './my-game/example2/monster.js';
+export { Ability, AbilityT } from './my-game/example/ability.js';
+export { Any, unionToAny, unionListToAny } from './my-game/example/any.js';
+export { AnyAmbiguousAliases, unionToAnyAmbiguousAliases, unionListToAnyAmbiguousAliases } from './my-game/example/any-ambiguous-aliases.js';
+export { AnyUniqueAliases, unionToAnyUniqueAliases, unionListToAnyUniqueAliases } from './my-game/example/any-unique-aliases.js';
+export { Color } from './my-game/example/color.js';
+export { Monster, MonsterT } from './my-game/example/monster.js';
+export { Race } from './my-game/example/race.js';
+export { Referrable, ReferrableT } from './my-game/example/referrable.js';
+export { Stat, StatT } from './my-game/example/stat.js';
+export { StructOfStructs, StructOfStructsT } from './my-game/example/struct-of-structs.js';
+export { StructOfStructsOfStructs, StructOfStructsOfStructsT } from './my-game/example/struct-of-structs-of-structs.js';
+export { Test, TestT } from './my-game/example/test.js';
+export { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from './my-game/example/test-simple-table-with-enum.js';
+export { TypeAliases, TypeAliasesT } from './my-game/example/type-aliases.js';
+export { Vec3, Vec3T } from './my-game/example/vec3.js';
+export { InParentNamespace, InParentNamespaceT } from './my-game/in-parent-namespace.js';
diff --git a/tests/monster_test_grpc.d.ts b/tests/ts/monster_test_grpc.d.ts
similarity index 100%
rename from tests/monster_test_grpc.d.ts
rename to tests/ts/monster_test_grpc.d.ts
diff --git a/tests/monster_test_grpc.js b/tests/ts/monster_test_grpc.js
similarity index 100%
rename from tests/monster_test_grpc.js
rename to tests/ts/monster_test_grpc.js
diff --git a/tests/ts/monsterdata_javascript_wire.mon b/tests/ts/monsterdata_javascript_wire.mon
new file mode 100644
index 0000000..c6020a2
--- /dev/null
+++ b/tests/ts/monsterdata_javascript_wire.mon
Binary files differ
diff --git a/tests/ts/my-game/example/ability.js b/tests/ts/my-game/example/ability.js
new file mode 100644
index 0000000..4d7d3db
--- /dev/null
+++ b/tests/ts/my-game/example/ability.js
@@ -0,0 +1,54 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+export class Ability {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ id() {
+ return this.bb.readUint32(this.bb_pos);
+ }
+ mutate_id(value) {
+ this.bb.writeUint32(this.bb_pos + 0, value);
+ return true;
+ }
+ distance() {
+ return this.bb.readUint32(this.bb_pos + 4);
+ }
+ mutate_distance(value) {
+ this.bb.writeUint32(this.bb_pos + 4, value);
+ return true;
+ }
+ static getFullyQualifiedName() {
+ return 'MyGame_Example_Ability';
+ }
+ static sizeOf() {
+ return 8;
+ }
+ static createAbility(builder, id, distance) {
+ builder.prep(4, 8);
+ builder.writeInt32(distance);
+ builder.writeInt32(id);
+ return builder.offset();
+ }
+ unpack() {
+ return new AbilityT(this.id(), this.distance());
+ }
+ unpackTo(_o) {
+ _o.id = this.id();
+ _o.distance = this.distance();
+ }
+}
+export class AbilityT {
+ constructor(id = 0, distance = 0) {
+ this.id = id;
+ this.distance = distance;
+ }
+ pack(builder) {
+ return Ability.createAbility(builder, this.id, this.distance);
+ }
+}
diff --git a/tests/ts/my-game/example/ability.ts b/tests/ts/my-game/example/ability.ts
new file mode 100644
index 0000000..36b0eb8
--- /dev/null
+++ b/tests/ts/my-game/example/ability.ts
@@ -0,0 +1,77 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+
+
+export class Ability {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):Ability {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+id():number {
+ return this.bb!.readUint32(this.bb_pos);
+}
+
+mutate_id(value:number):boolean {
+ this.bb!.writeUint32(this.bb_pos + 0, value);
+ return true;
+}
+
+distance():number {
+ return this.bb!.readUint32(this.bb_pos + 4);
+}
+
+mutate_distance(value:number):boolean {
+ this.bb!.writeUint32(this.bb_pos + 4, value);
+ return true;
+}
+
+static getFullyQualifiedName():string {
+ return 'MyGame_Example_Ability';
+}
+
+static sizeOf():number {
+ return 8;
+}
+
+static createAbility(builder:flatbuffers.Builder, id: number, distance: number):flatbuffers.Offset {
+ builder.prep(4, 8);
+ builder.writeInt32(distance);
+ builder.writeInt32(id);
+ return builder.offset();
+}
+
+
+unpack(): AbilityT {
+ return new AbilityT(
+ this.id(),
+ this.distance()
+ );
+}
+
+
+unpackTo(_o: AbilityT): void {
+ _o.id = this.id();
+ _o.distance = this.distance();
+}
+}
+
+export class AbilityT {
+constructor(
+ public id: number = 0,
+ public distance: number = 0
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ return Ability.createAbility(builder,
+ this.id,
+ this.distance
+ );
+}
+}
diff --git a/tests/ts/my-game/example/any-ambiguous-aliases.js b/tests/ts/my-game/example/any-ambiguous-aliases.js
new file mode 100644
index 0000000..ca81908
--- /dev/null
+++ b/tests/ts/my-game/example/any-ambiguous-aliases.js
@@ -0,0 +1,27 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import { Monster } from '../../my-game/example/monster.js';
+export var AnyAmbiguousAliases;
+(function (AnyAmbiguousAliases) {
+ AnyAmbiguousAliases[AnyAmbiguousAliases["NONE"] = 0] = "NONE";
+ AnyAmbiguousAliases[AnyAmbiguousAliases["M1"] = 1] = "M1";
+ AnyAmbiguousAliases[AnyAmbiguousAliases["M2"] = 2] = "M2";
+ AnyAmbiguousAliases[AnyAmbiguousAliases["M3"] = 3] = "M3";
+})(AnyAmbiguousAliases || (AnyAmbiguousAliases = {}));
+export function unionToAnyAmbiguousAliases(type, accessor) {
+ switch (AnyAmbiguousAliases[type]) {
+ case 'NONE': return null;
+ case 'M1': return accessor(new Monster());
+ case 'M2': return accessor(new Monster());
+ case 'M3': return accessor(new Monster());
+ default: return null;
+ }
+}
+export function unionListToAnyAmbiguousAliases(type, accessor, index) {
+ switch (AnyAmbiguousAliases[type]) {
+ case 'NONE': return null;
+ case 'M1': return accessor(index, new Monster());
+ case 'M2': return accessor(index, new Monster());
+ case 'M3': return accessor(index, new Monster());
+ default: return null;
+ }
+}
diff --git a/tests/ts/my-game/example/any-ambiguous-aliases.ts b/tests/ts/my-game/example/any-ambiguous-aliases.ts
new file mode 100644
index 0000000..a7a63b7
--- /dev/null
+++ b/tests/ts/my-game/example/any-ambiguous-aliases.ts
@@ -0,0 +1,38 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import { Monster, MonsterT } from '../../my-game/example/monster.js';
+
+
+export enum AnyAmbiguousAliases {
+ NONE = 0,
+ M1 = 1,
+ M2 = 2,
+ M3 = 3
+}
+
+export function unionToAnyAmbiguousAliases(
+ type: AnyAmbiguousAliases,
+ accessor: (obj:Monster) => Monster|null
+): Monster|null {
+ switch(AnyAmbiguousAliases[type]) {
+ case 'NONE': return null;
+ case 'M1': return accessor(new Monster())! as Monster;
+ case 'M2': return accessor(new Monster())! as Monster;
+ case 'M3': return accessor(new Monster())! as Monster;
+ default: return null;
+ }
+}
+
+export function unionListToAnyAmbiguousAliases(
+ type: AnyAmbiguousAliases,
+ accessor: (index: number, obj:Monster) => Monster|null,
+ index: number
+): Monster|null {
+ switch(AnyAmbiguousAliases[type]) {
+ case 'NONE': return null;
+ case 'M1': return accessor(index, new Monster())! as Monster;
+ case 'M2': return accessor(index, new Monster())! as Monster;
+ case 'M3': return accessor(index, new Monster())! as Monster;
+ default: return null;
+ }
+}
diff --git a/tests/ts/my-game/example/any-unique-aliases.js b/tests/ts/my-game/example/any-unique-aliases.js
new file mode 100644
index 0000000..d1ac6bf
--- /dev/null
+++ b/tests/ts/my-game/example/any-unique-aliases.js
@@ -0,0 +1,29 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import { Monster as MyGame_Example2_Monster } from '../../my-game/example2/monster.js';
+import { Monster } from '../../my-game/example/monster.js';
+import { TestSimpleTableWithEnum } from '../../my-game/example/test-simple-table-with-enum.js';
+export var AnyUniqueAliases;
+(function (AnyUniqueAliases) {
+ AnyUniqueAliases[AnyUniqueAliases["NONE"] = 0] = "NONE";
+ AnyUniqueAliases[AnyUniqueAliases["M"] = 1] = "M";
+ AnyUniqueAliases[AnyUniqueAliases["TS"] = 2] = "TS";
+ AnyUniqueAliases[AnyUniqueAliases["M2"] = 3] = "M2";
+})(AnyUniqueAliases || (AnyUniqueAliases = {}));
+export function unionToAnyUniqueAliases(type, accessor) {
+ switch (AnyUniqueAliases[type]) {
+ case 'NONE': return null;
+ case 'M': return accessor(new Monster());
+ case 'TS': return accessor(new TestSimpleTableWithEnum());
+ case 'M2': return accessor(new MyGame_Example2_Monster());
+ default: return null;
+ }
+}
+export function unionListToAnyUniqueAliases(type, accessor, index) {
+ switch (AnyUniqueAliases[type]) {
+ case 'NONE': return null;
+ case 'M': return accessor(index, new Monster());
+ case 'TS': return accessor(index, new TestSimpleTableWithEnum());
+ case 'M2': return accessor(index, new MyGame_Example2_Monster());
+ default: return null;
+ }
+}
diff --git a/tests/ts/my-game/example/any-unique-aliases.ts b/tests/ts/my-game/example/any-unique-aliases.ts
new file mode 100644
index 0000000..16aa378
--- /dev/null
+++ b/tests/ts/my-game/example/any-unique-aliases.ts
@@ -0,0 +1,40 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import { Monster as MyGame_Example2_Monster, MonsterT as MyGame_Example2_MonsterT } from '../../my-game/example2/monster.js';
+import { Monster, MonsterT } from '../../my-game/example/monster.js';
+import { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from '../../my-game/example/test-simple-table-with-enum.js';
+
+
+export enum AnyUniqueAliases {
+ NONE = 0,
+ M = 1,
+ TS = 2,
+ M2 = 3
+}
+
+export function unionToAnyUniqueAliases(
+ type: AnyUniqueAliases,
+ accessor: (obj:Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum) => Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null
+): Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null {
+ switch(AnyUniqueAliases[type]) {
+ case 'NONE': return null;
+ case 'M': return accessor(new Monster())! as Monster;
+ case 'TS': return accessor(new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum;
+ case 'M2': return accessor(new MyGame_Example2_Monster())! as MyGame_Example2_Monster;
+ default: return null;
+ }
+}
+
+export function unionListToAnyUniqueAliases(
+ type: AnyUniqueAliases,
+ accessor: (index: number, obj:Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum) => Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null,
+ index: number
+): Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null {
+ switch(AnyUniqueAliases[type]) {
+ case 'NONE': return null;
+ case 'M': return accessor(index, new Monster())! as Monster;
+ case 'TS': return accessor(index, new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum;
+ case 'M2': return accessor(index, new MyGame_Example2_Monster())! as MyGame_Example2_Monster;
+ default: return null;
+ }
+}
diff --git a/tests/ts/my-game/example/any.js b/tests/ts/my-game/example/any.js
new file mode 100644
index 0000000..27be8f4
--- /dev/null
+++ b/tests/ts/my-game/example/any.js
@@ -0,0 +1,29 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import { Monster as MyGame_Example2_Monster } from '../../my-game/example2/monster.js';
+import { Monster } from '../../my-game/example/monster.js';
+import { TestSimpleTableWithEnum } from '../../my-game/example/test-simple-table-with-enum.js';
+export var Any;
+(function (Any) {
+ Any[Any["NONE"] = 0] = "NONE";
+ Any[Any["Monster"] = 1] = "Monster";
+ Any[Any["TestSimpleTableWithEnum"] = 2] = "TestSimpleTableWithEnum";
+ Any[Any["MyGame_Example2_Monster"] = 3] = "MyGame_Example2_Monster";
+})(Any || (Any = {}));
+export function unionToAny(type, accessor) {
+ switch (Any[type]) {
+ case 'NONE': return null;
+ case 'Monster': return accessor(new Monster());
+ case 'TestSimpleTableWithEnum': return accessor(new TestSimpleTableWithEnum());
+ case 'MyGame_Example2_Monster': return accessor(new MyGame_Example2_Monster());
+ default: return null;
+ }
+}
+export function unionListToAny(type, accessor, index) {
+ switch (Any[type]) {
+ case 'NONE': return null;
+ case 'Monster': return accessor(index, new Monster());
+ case 'TestSimpleTableWithEnum': return accessor(index, new TestSimpleTableWithEnum());
+ case 'MyGame_Example2_Monster': return accessor(index, new MyGame_Example2_Monster());
+ default: return null;
+ }
+}
diff --git a/tests/ts/my-game/example/any.ts b/tests/ts/my-game/example/any.ts
new file mode 100644
index 0000000..de1cbfd
--- /dev/null
+++ b/tests/ts/my-game/example/any.ts
@@ -0,0 +1,40 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import { Monster as MyGame_Example2_Monster, MonsterT as MyGame_Example2_MonsterT } from '../../my-game/example2/monster.js';
+import { Monster, MonsterT } from '../../my-game/example/monster.js';
+import { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from '../../my-game/example/test-simple-table-with-enum.js';
+
+
+export enum Any {
+ NONE = 0,
+ Monster = 1,
+ TestSimpleTableWithEnum = 2,
+ MyGame_Example2_Monster = 3
+}
+
+export function unionToAny(
+ type: Any,
+ accessor: (obj:Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum) => Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null
+): Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null {
+ switch(Any[type]) {
+ case 'NONE': return null;
+ case 'Monster': return accessor(new Monster())! as Monster;
+ case 'TestSimpleTableWithEnum': return accessor(new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum;
+ case 'MyGame_Example2_Monster': return accessor(new MyGame_Example2_Monster())! as MyGame_Example2_Monster;
+ default: return null;
+ }
+}
+
+export function unionListToAny(
+ type: Any,
+ accessor: (index: number, obj:Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum) => Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null,
+ index: number
+): Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null {
+ switch(Any[type]) {
+ case 'NONE': return null;
+ case 'Monster': return accessor(index, new Monster())! as Monster;
+ case 'TestSimpleTableWithEnum': return accessor(index, new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum;
+ case 'MyGame_Example2_Monster': return accessor(index, new MyGame_Example2_Monster())! as MyGame_Example2_Monster;
+ default: return null;
+ }
+}
diff --git a/tests/ts/my-game/example/color.js b/tests/ts/my-game/example/color.js
new file mode 100644
index 0000000..f95f75e
--- /dev/null
+++ b/tests/ts/my-game/example/color.js
@@ -0,0 +1,17 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+/**
+ * Composite components of Monster color.
+ */
+export var Color;
+(function (Color) {
+ Color[Color["Red"] = 1] = "Red";
+ /**
+ * \brief color Green
+ * Green is bit_flag with value (1u << 1)
+ */
+ Color[Color["Green"] = 2] = "Green";
+ /**
+ * \brief color Blue (1u << 3)
+ */
+ Color[Color["Blue"] = 8] = "Blue";
+})(Color || (Color = {}));
diff --git a/tests/ts/my-game/example/color.ts b/tests/ts/my-game/example/color.ts
new file mode 100644
index 0000000..8ce58da
--- /dev/null
+++ b/tests/ts/my-game/example/color.ts
@@ -0,0 +1,19 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+/**
+ * Composite components of Monster color.
+ */
+export enum Color {
+ Red = 1,
+
+ /**
+ * \brief color Green
+ * Green is bit_flag with value (1u << 1)
+ */
+ Green = 2,
+
+ /**
+ * \brief color Blue (1u << 3)
+ */
+ Blue = 8
+}
diff --git a/tests/ts/my-game/example/long-enum.js b/tests/ts/my-game/example/long-enum.js
new file mode 100644
index 0000000..040d8a6
--- /dev/null
+++ b/tests/ts/my-game/example/long-enum.js
@@ -0,0 +1,7 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+export var LongEnum;
+(function (LongEnum) {
+ LongEnum["LongOne"] = "2";
+ LongEnum["LongTwo"] = "4";
+ LongEnum["LongBig"] = "1099511627776";
+})(LongEnum || (LongEnum = {}));
diff --git a/tests/ts/my-game/example/long-enum.ts b/tests/ts/my-game/example/long-enum.ts
new file mode 100644
index 0000000..31ea188
--- /dev/null
+++ b/tests/ts/my-game/example/long-enum.ts
@@ -0,0 +1,7 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+export enum LongEnum {
+ LongOne = '2',
+ LongTwo = '4',
+ LongBig = '1099511627776'
+}
diff --git a/tests/ts/my-game/example/monster.js b/tests/ts/my-game/example/monster.js
new file mode 100644
index 0000000..e4ef970
--- /dev/null
+++ b/tests/ts/my-game/example/monster.js
@@ -0,0 +1,1125 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import * as flatbuffers from 'flatbuffers';
+import { Ability } from '../../my-game/example/ability.js';
+import { Any, unionToAny } from '../../my-game/example/any.js';
+import { AnyAmbiguousAliases, unionToAnyAmbiguousAliases } from '../../my-game/example/any-ambiguous-aliases.js';
+import { AnyUniqueAliases, unionToAnyUniqueAliases } from '../../my-game/example/any-unique-aliases.js';
+import { Color } from '../../my-game/example/color.js';
+import { Race } from '../../my-game/example/race.js';
+import { Referrable } from '../../my-game/example/referrable.js';
+import { Stat } from '../../my-game/example/stat.js';
+import { Test } from '../../my-game/example/test.js';
+import { Vec3 } from '../../my-game/example/vec3.js';
+import { InParentNamespace } from '../../my-game/in-parent-namespace.js';
+/**
+ * an example documentation comment: "monster object"
+ */
+export class Monster {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsMonster(bb, obj) {
+ return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsMonster(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static bufferHasIdentifier(bb) {
+ return bb.__has_identifier('MONS');
+ }
+ pos(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? (obj || new Vec3()).__init(this.bb_pos + offset, this.bb) : null;
+ }
+ mana() {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? this.bb.readInt16(this.bb_pos + offset) : 150;
+ }
+ mutate_mana(value) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt16(this.bb_pos + offset, value);
+ return true;
+ }
+ hp() {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ return offset ? this.bb.readInt16(this.bb_pos + offset) : 100;
+ }
+ mutate_hp(value) {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt16(this.bb_pos + offset, value);
+ return true;
+ }
+ name(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ inventory(index) {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0;
+ }
+ inventoryLength() {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ inventoryArray() {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
+ }
+ color() {
+ const offset = this.bb.__offset(this.bb_pos, 16);
+ return offset ? this.bb.readUint8(this.bb_pos + offset) : Color.Blue;
+ }
+ mutate_color(value) {
+ const offset = this.bb.__offset(this.bb_pos, 16);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint8(this.bb_pos + offset, value);
+ return true;
+ }
+ testType() {
+ const offset = this.bb.__offset(this.bb_pos, 18);
+ return offset ? this.bb.readUint8(this.bb_pos + offset) : Any.NONE;
+ }
+ test(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 20);
+ return offset ? this.bb.__union(obj, this.bb_pos + offset) : null;
+ }
+ test4(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 22);
+ return offset ? (obj || new Test()).__init(this.bb.__vector(this.bb_pos + offset) + index * 4, this.bb) : null;
+ }
+ test4Length() {
+ const offset = this.bb.__offset(this.bb_pos, 22);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ testarrayofstring(index, optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 24);
+ return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+ }
+ testarrayofstringLength() {
+ const offset = this.bb.__offset(this.bb_pos, 24);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ /**
+ * an example documentation comment: this will end up in the generated code
+ * multiline too
+ */
+ testarrayoftables(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 26);
+ return offset ? (obj || new Monster()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ testarrayoftablesLength() {
+ const offset = this.bb.__offset(this.bb_pos, 26);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ enemy(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 28);
+ return offset ? (obj || new Monster()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
+ }
+ testnestedflatbuffer(index) {
+ const offset = this.bb.__offset(this.bb_pos, 30);
+ return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0;
+ }
+ testnestedflatbufferLength() {
+ const offset = this.bb.__offset(this.bb_pos, 30);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ testnestedflatbufferArray() {
+ const offset = this.bb.__offset(this.bb_pos, 30);
+ return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
+ }
+ testempty(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 32);
+ return offset ? (obj || new Stat()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
+ }
+ testbool() {
+ const offset = this.bb.__offset(this.bb_pos, 34);
+ return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;
+ }
+ mutate_testbool(value) {
+ const offset = this.bb.__offset(this.bb_pos, 34);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt8(this.bb_pos + offset, +value);
+ return true;
+ }
+ testhashs32Fnv1() {
+ const offset = this.bb.__offset(this.bb_pos, 36);
+ return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
+ }
+ mutate_testhashs32_fnv1(value) {
+ const offset = this.bb.__offset(this.bb_pos, 36);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt32(this.bb_pos + offset, value);
+ return true;
+ }
+ testhashu32Fnv1() {
+ const offset = this.bb.__offset(this.bb_pos, 38);
+ return offset ? this.bb.readUint32(this.bb_pos + offset) : 0;
+ }
+ mutate_testhashu32_fnv1(value) {
+ const offset = this.bb.__offset(this.bb_pos, 38);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint32(this.bb_pos + offset, value);
+ return true;
+ }
+ testhashs64Fnv1() {
+ const offset = this.bb.__offset(this.bb_pos, 40);
+ return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0');
+ }
+ mutate_testhashs64_fnv1(value) {
+ const offset = this.bb.__offset(this.bb_pos, 40);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt64(this.bb_pos + offset, value);
+ return true;
+ }
+ testhashu64Fnv1() {
+ const offset = this.bb.__offset(this.bb_pos, 42);
+ return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0');
+ }
+ mutate_testhashu64_fnv1(value) {
+ const offset = this.bb.__offset(this.bb_pos, 42);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint64(this.bb_pos + offset, value);
+ return true;
+ }
+ testhashs32Fnv1a() {
+ const offset = this.bb.__offset(this.bb_pos, 44);
+ return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
+ }
+ mutate_testhashs32_fnv1a(value) {
+ const offset = this.bb.__offset(this.bb_pos, 44);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt32(this.bb_pos + offset, value);
+ return true;
+ }
+ testhashu32Fnv1a() {
+ const offset = this.bb.__offset(this.bb_pos, 46);
+ return offset ? this.bb.readUint32(this.bb_pos + offset) : 0;
+ }
+ mutate_testhashu32_fnv1a(value) {
+ const offset = this.bb.__offset(this.bb_pos, 46);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint32(this.bb_pos + offset, value);
+ return true;
+ }
+ testhashs64Fnv1a() {
+ const offset = this.bb.__offset(this.bb_pos, 48);
+ return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0');
+ }
+ mutate_testhashs64_fnv1a(value) {
+ const offset = this.bb.__offset(this.bb_pos, 48);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt64(this.bb_pos + offset, value);
+ return true;
+ }
+ testhashu64Fnv1a() {
+ const offset = this.bb.__offset(this.bb_pos, 50);
+ return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0');
+ }
+ mutate_testhashu64_fnv1a(value) {
+ const offset = this.bb.__offset(this.bb_pos, 50);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint64(this.bb_pos + offset, value);
+ return true;
+ }
+ testarrayofbools(index) {
+ const offset = this.bb.__offset(this.bb_pos, 52);
+ return offset ? !!this.bb.readInt8(this.bb.__vector(this.bb_pos + offset) + index) : false;
+ }
+ testarrayofboolsLength() {
+ const offset = this.bb.__offset(this.bb_pos, 52);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ testarrayofboolsArray() {
+ const offset = this.bb.__offset(this.bb_pos, 52);
+ return offset ? new Int8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
+ }
+ testf() {
+ const offset = this.bb.__offset(this.bb_pos, 54);
+ return offset ? this.bb.readFloat32(this.bb_pos + offset) : 3.14159;
+ }
+ mutate_testf(value) {
+ const offset = this.bb.__offset(this.bb_pos, 54);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeFloat32(this.bb_pos + offset, value);
+ return true;
+ }
+ testf2() {
+ const offset = this.bb.__offset(this.bb_pos, 56);
+ return offset ? this.bb.readFloat32(this.bb_pos + offset) : 3.0;
+ }
+ mutate_testf2(value) {
+ const offset = this.bb.__offset(this.bb_pos, 56);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeFloat32(this.bb_pos + offset, value);
+ return true;
+ }
+ testf3() {
+ const offset = this.bb.__offset(this.bb_pos, 58);
+ return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0;
+ }
+ mutate_testf3(value) {
+ const offset = this.bb.__offset(this.bb_pos, 58);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeFloat32(this.bb_pos + offset, value);
+ return true;
+ }
+ testarrayofstring2(index, optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 60);
+ return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+ }
+ testarrayofstring2Length() {
+ const offset = this.bb.__offset(this.bb_pos, 60);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ testarrayofsortedstruct(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 62);
+ return offset ? (obj || new Ability()).__init(this.bb.__vector(this.bb_pos + offset) + index * 8, this.bb) : null;
+ }
+ testarrayofsortedstructLength() {
+ const offset = this.bb.__offset(this.bb_pos, 62);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ flex(index) {
+ const offset = this.bb.__offset(this.bb_pos, 64);
+ return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0;
+ }
+ flexLength() {
+ const offset = this.bb.__offset(this.bb_pos, 64);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ flexArray() {
+ const offset = this.bb.__offset(this.bb_pos, 64);
+ return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
+ }
+ test5(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 66);
+ return offset ? (obj || new Test()).__init(this.bb.__vector(this.bb_pos + offset) + index * 4, this.bb) : null;
+ }
+ test5Length() {
+ const offset = this.bb.__offset(this.bb_pos, 66);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ vectorOfLongs(index) {
+ const offset = this.bb.__offset(this.bb_pos, 68);
+ return offset ? this.bb.readInt64(this.bb.__vector(this.bb_pos + offset) + index * 8) : BigInt(0);
+ }
+ vectorOfLongsLength() {
+ const offset = this.bb.__offset(this.bb_pos, 68);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ vectorOfDoubles(index) {
+ const offset = this.bb.__offset(this.bb_pos, 70);
+ return offset ? this.bb.readFloat64(this.bb.__vector(this.bb_pos + offset) + index * 8) : 0;
+ }
+ vectorOfDoublesLength() {
+ const offset = this.bb.__offset(this.bb_pos, 70);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ vectorOfDoublesArray() {
+ const offset = this.bb.__offset(this.bb_pos, 70);
+ return offset ? new Float64Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
+ }
+ parentNamespaceTest(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 72);
+ return offset ? (obj || new InParentNamespace()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
+ }
+ vectorOfReferrables(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 74);
+ return offset ? (obj || new Referrable()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ vectorOfReferrablesLength() {
+ const offset = this.bb.__offset(this.bb_pos, 74);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ singleWeakReference() {
+ const offset = this.bb.__offset(this.bb_pos, 76);
+ return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0');
+ }
+ mutate_single_weak_reference(value) {
+ const offset = this.bb.__offset(this.bb_pos, 76);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint64(this.bb_pos + offset, value);
+ return true;
+ }
+ vectorOfWeakReferences(index) {
+ const offset = this.bb.__offset(this.bb_pos, 78);
+ return offset ? this.bb.readUint64(this.bb.__vector(this.bb_pos + offset) + index * 8) : BigInt(0);
+ }
+ vectorOfWeakReferencesLength() {
+ const offset = this.bb.__offset(this.bb_pos, 78);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ vectorOfStrongReferrables(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 80);
+ return offset ? (obj || new Referrable()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ vectorOfStrongReferrablesLength() {
+ const offset = this.bb.__offset(this.bb_pos, 80);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ coOwningReference() {
+ const offset = this.bb.__offset(this.bb_pos, 82);
+ return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0');
+ }
+ mutate_co_owning_reference(value) {
+ const offset = this.bb.__offset(this.bb_pos, 82);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint64(this.bb_pos + offset, value);
+ return true;
+ }
+ vectorOfCoOwningReferences(index) {
+ const offset = this.bb.__offset(this.bb_pos, 84);
+ return offset ? this.bb.readUint64(this.bb.__vector(this.bb_pos + offset) + index * 8) : BigInt(0);
+ }
+ vectorOfCoOwningReferencesLength() {
+ const offset = this.bb.__offset(this.bb_pos, 84);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ nonOwningReference() {
+ const offset = this.bb.__offset(this.bb_pos, 86);
+ return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0');
+ }
+ mutate_non_owning_reference(value) {
+ const offset = this.bb.__offset(this.bb_pos, 86);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint64(this.bb_pos + offset, value);
+ return true;
+ }
+ vectorOfNonOwningReferences(index) {
+ const offset = this.bb.__offset(this.bb_pos, 88);
+ return offset ? this.bb.readUint64(this.bb.__vector(this.bb_pos + offset) + index * 8) : BigInt(0);
+ }
+ vectorOfNonOwningReferencesLength() {
+ const offset = this.bb.__offset(this.bb_pos, 88);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ anyUniqueType() {
+ const offset = this.bb.__offset(this.bb_pos, 90);
+ return offset ? this.bb.readUint8(this.bb_pos + offset) : AnyUniqueAliases.NONE;
+ }
+ anyUnique(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 92);
+ return offset ? this.bb.__union(obj, this.bb_pos + offset) : null;
+ }
+ anyAmbiguousType() {
+ const offset = this.bb.__offset(this.bb_pos, 94);
+ return offset ? this.bb.readUint8(this.bb_pos + offset) : AnyAmbiguousAliases.NONE;
+ }
+ anyAmbiguous(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 96);
+ return offset ? this.bb.__union(obj, this.bb_pos + offset) : null;
+ }
+ vectorOfEnums(index) {
+ const offset = this.bb.__offset(this.bb_pos, 98);
+ return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0;
+ }
+ vectorOfEnumsLength() {
+ const offset = this.bb.__offset(this.bb_pos, 98);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ vectorOfEnumsArray() {
+ const offset = this.bb.__offset(this.bb_pos, 98);
+ return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
+ }
+ signedEnum() {
+ const offset = this.bb.__offset(this.bb_pos, 100);
+ return offset ? this.bb.readInt8(this.bb_pos + offset) : Race.None;
+ }
+ mutate_signed_enum(value) {
+ const offset = this.bb.__offset(this.bb_pos, 100);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt8(this.bb_pos + offset, value);
+ return true;
+ }
+ testrequirednestedflatbuffer(index) {
+ const offset = this.bb.__offset(this.bb_pos, 102);
+ return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0;
+ }
+ testrequirednestedflatbufferLength() {
+ const offset = this.bb.__offset(this.bb_pos, 102);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ testrequirednestedflatbufferArray() {
+ const offset = this.bb.__offset(this.bb_pos, 102);
+ return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
+ }
+ scalarKeySortedTables(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 104);
+ return offset ? (obj || new Stat()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ scalarKeySortedTablesLength() {
+ const offset = this.bb.__offset(this.bb_pos, 104);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ nativeInline(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 106);
+ return offset ? (obj || new Test()).__init(this.bb_pos + offset, this.bb) : null;
+ }
+ longEnumNonEnumDefault() {
+ const offset = this.bb.__offset(this.bb_pos, 108);
+ return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0');
+ }
+ mutate_long_enum_non_enum_default(value) {
+ const offset = this.bb.__offset(this.bb_pos, 108);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint64(this.bb_pos + offset, value);
+ return true;
+ }
+ longEnumNormalDefault() {
+ const offset = this.bb.__offset(this.bb_pos, 110);
+ return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('2');
+ }
+ mutate_long_enum_normal_default(value) {
+ const offset = this.bb.__offset(this.bb_pos, 110);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint64(this.bb_pos + offset, value);
+ return true;
+ }
+ static getFullyQualifiedName() {
+ return 'MyGame_Example_Monster';
+ }
+ static startMonster(builder) {
+ builder.startObject(54);
+ }
+ static addPos(builder, posOffset) {
+ builder.addFieldStruct(0, posOffset, 0);
+ }
+ static addMana(builder, mana) {
+ builder.addFieldInt16(1, mana, 150);
+ }
+ static addHp(builder, hp) {
+ builder.addFieldInt16(2, hp, 100);
+ }
+ static addName(builder, nameOffset) {
+ builder.addFieldOffset(3, nameOffset, 0);
+ }
+ static addInventory(builder, inventoryOffset) {
+ builder.addFieldOffset(5, inventoryOffset, 0);
+ }
+ static createInventoryVector(builder, data) {
+ builder.startVector(1, data.length, 1);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt8(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startInventoryVector(builder, numElems) {
+ builder.startVector(1, numElems, 1);
+ }
+ static addColor(builder, color) {
+ builder.addFieldInt8(6, color, Color.Blue);
+ }
+ static addTestType(builder, testType) {
+ builder.addFieldInt8(7, testType, Any.NONE);
+ }
+ static addTest(builder, testOffset) {
+ builder.addFieldOffset(8, testOffset, 0);
+ }
+ static addTest4(builder, test4Offset) {
+ builder.addFieldOffset(9, test4Offset, 0);
+ }
+ static startTest4Vector(builder, numElems) {
+ builder.startVector(4, numElems, 2);
+ }
+ static addTestarrayofstring(builder, testarrayofstringOffset) {
+ builder.addFieldOffset(10, testarrayofstringOffset, 0);
+ }
+ static createTestarrayofstringVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startTestarrayofstringVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addTestarrayoftables(builder, testarrayoftablesOffset) {
+ builder.addFieldOffset(11, testarrayoftablesOffset, 0);
+ }
+ static createTestarrayoftablesVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startTestarrayoftablesVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addEnemy(builder, enemyOffset) {
+ builder.addFieldOffset(12, enemyOffset, 0);
+ }
+ static addTestnestedflatbuffer(builder, testnestedflatbufferOffset) {
+ builder.addFieldOffset(13, testnestedflatbufferOffset, 0);
+ }
+ static createTestnestedflatbufferVector(builder, data) {
+ builder.startVector(1, data.length, 1);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt8(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startTestnestedflatbufferVector(builder, numElems) {
+ builder.startVector(1, numElems, 1);
+ }
+ static addTestempty(builder, testemptyOffset) {
+ builder.addFieldOffset(14, testemptyOffset, 0);
+ }
+ static addTestbool(builder, testbool) {
+ builder.addFieldInt8(15, +testbool, +false);
+ }
+ static addTesthashs32Fnv1(builder, testhashs32Fnv1) {
+ builder.addFieldInt32(16, testhashs32Fnv1, 0);
+ }
+ static addTesthashu32Fnv1(builder, testhashu32Fnv1) {
+ builder.addFieldInt32(17, testhashu32Fnv1, 0);
+ }
+ static addTesthashs64Fnv1(builder, testhashs64Fnv1) {
+ builder.addFieldInt64(18, testhashs64Fnv1, BigInt('0'));
+ }
+ static addTesthashu64Fnv1(builder, testhashu64Fnv1) {
+ builder.addFieldInt64(19, testhashu64Fnv1, BigInt('0'));
+ }
+ static addTesthashs32Fnv1a(builder, testhashs32Fnv1a) {
+ builder.addFieldInt32(20, testhashs32Fnv1a, 0);
+ }
+ static addTesthashu32Fnv1a(builder, testhashu32Fnv1a) {
+ builder.addFieldInt32(21, testhashu32Fnv1a, 0);
+ }
+ static addTesthashs64Fnv1a(builder, testhashs64Fnv1a) {
+ builder.addFieldInt64(22, testhashs64Fnv1a, BigInt('0'));
+ }
+ static addTesthashu64Fnv1a(builder, testhashu64Fnv1a) {
+ builder.addFieldInt64(23, testhashu64Fnv1a, BigInt('0'));
+ }
+ static addTestarrayofbools(builder, testarrayofboolsOffset) {
+ builder.addFieldOffset(24, testarrayofboolsOffset, 0);
+ }
+ static createTestarrayofboolsVector(builder, data) {
+ builder.startVector(1, data.length, 1);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt8(+data[i]);
+ }
+ return builder.endVector();
+ }
+ static startTestarrayofboolsVector(builder, numElems) {
+ builder.startVector(1, numElems, 1);
+ }
+ static addTestf(builder, testf) {
+ builder.addFieldFloat32(25, testf, 3.14159);
+ }
+ static addTestf2(builder, testf2) {
+ builder.addFieldFloat32(26, testf2, 3.0);
+ }
+ static addTestf3(builder, testf3) {
+ builder.addFieldFloat32(27, testf3, 0.0);
+ }
+ static addTestarrayofstring2(builder, testarrayofstring2Offset) {
+ builder.addFieldOffset(28, testarrayofstring2Offset, 0);
+ }
+ static createTestarrayofstring2Vector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startTestarrayofstring2Vector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addTestarrayofsortedstruct(builder, testarrayofsortedstructOffset) {
+ builder.addFieldOffset(29, testarrayofsortedstructOffset, 0);
+ }
+ static startTestarrayofsortedstructVector(builder, numElems) {
+ builder.startVector(8, numElems, 4);
+ }
+ static addFlex(builder, flexOffset) {
+ builder.addFieldOffset(30, flexOffset, 0);
+ }
+ static createFlexVector(builder, data) {
+ builder.startVector(1, data.length, 1);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt8(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startFlexVector(builder, numElems) {
+ builder.startVector(1, numElems, 1);
+ }
+ static addTest5(builder, test5Offset) {
+ builder.addFieldOffset(31, test5Offset, 0);
+ }
+ static startTest5Vector(builder, numElems) {
+ builder.startVector(4, numElems, 2);
+ }
+ static addVectorOfLongs(builder, vectorOfLongsOffset) {
+ builder.addFieldOffset(32, vectorOfLongsOffset, 0);
+ }
+ static createVectorOfLongsVector(builder, data) {
+ builder.startVector(8, data.length, 8);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt64(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startVectorOfLongsVector(builder, numElems) {
+ builder.startVector(8, numElems, 8);
+ }
+ static addVectorOfDoubles(builder, vectorOfDoublesOffset) {
+ builder.addFieldOffset(33, vectorOfDoublesOffset, 0);
+ }
+ static createVectorOfDoublesVector(builder, data) {
+ builder.startVector(8, data.length, 8);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addFloat64(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startVectorOfDoublesVector(builder, numElems) {
+ builder.startVector(8, numElems, 8);
+ }
+ static addParentNamespaceTest(builder, parentNamespaceTestOffset) {
+ builder.addFieldOffset(34, parentNamespaceTestOffset, 0);
+ }
+ static addVectorOfReferrables(builder, vectorOfReferrablesOffset) {
+ builder.addFieldOffset(35, vectorOfReferrablesOffset, 0);
+ }
+ static createVectorOfReferrablesVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startVectorOfReferrablesVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addSingleWeakReference(builder, singleWeakReference) {
+ builder.addFieldInt64(36, singleWeakReference, BigInt('0'));
+ }
+ static addVectorOfWeakReferences(builder, vectorOfWeakReferencesOffset) {
+ builder.addFieldOffset(37, vectorOfWeakReferencesOffset, 0);
+ }
+ static createVectorOfWeakReferencesVector(builder, data) {
+ builder.startVector(8, data.length, 8);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt64(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startVectorOfWeakReferencesVector(builder, numElems) {
+ builder.startVector(8, numElems, 8);
+ }
+ static addVectorOfStrongReferrables(builder, vectorOfStrongReferrablesOffset) {
+ builder.addFieldOffset(38, vectorOfStrongReferrablesOffset, 0);
+ }
+ static createVectorOfStrongReferrablesVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startVectorOfStrongReferrablesVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addCoOwningReference(builder, coOwningReference) {
+ builder.addFieldInt64(39, coOwningReference, BigInt('0'));
+ }
+ static addVectorOfCoOwningReferences(builder, vectorOfCoOwningReferencesOffset) {
+ builder.addFieldOffset(40, vectorOfCoOwningReferencesOffset, 0);
+ }
+ static createVectorOfCoOwningReferencesVector(builder, data) {
+ builder.startVector(8, data.length, 8);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt64(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startVectorOfCoOwningReferencesVector(builder, numElems) {
+ builder.startVector(8, numElems, 8);
+ }
+ static addNonOwningReference(builder, nonOwningReference) {
+ builder.addFieldInt64(41, nonOwningReference, BigInt('0'));
+ }
+ static addVectorOfNonOwningReferences(builder, vectorOfNonOwningReferencesOffset) {
+ builder.addFieldOffset(42, vectorOfNonOwningReferencesOffset, 0);
+ }
+ static createVectorOfNonOwningReferencesVector(builder, data) {
+ builder.startVector(8, data.length, 8);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt64(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startVectorOfNonOwningReferencesVector(builder, numElems) {
+ builder.startVector(8, numElems, 8);
+ }
+ static addAnyUniqueType(builder, anyUniqueType) {
+ builder.addFieldInt8(43, anyUniqueType, AnyUniqueAliases.NONE);
+ }
+ static addAnyUnique(builder, anyUniqueOffset) {
+ builder.addFieldOffset(44, anyUniqueOffset, 0);
+ }
+ static addAnyAmbiguousType(builder, anyAmbiguousType) {
+ builder.addFieldInt8(45, anyAmbiguousType, AnyAmbiguousAliases.NONE);
+ }
+ static addAnyAmbiguous(builder, anyAmbiguousOffset) {
+ builder.addFieldOffset(46, anyAmbiguousOffset, 0);
+ }
+ static addVectorOfEnums(builder, vectorOfEnumsOffset) {
+ builder.addFieldOffset(47, vectorOfEnumsOffset, 0);
+ }
+ static createVectorOfEnumsVector(builder, data) {
+ builder.startVector(1, data.length, 1);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt8(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startVectorOfEnumsVector(builder, numElems) {
+ builder.startVector(1, numElems, 1);
+ }
+ static addSignedEnum(builder, signedEnum) {
+ builder.addFieldInt8(48, signedEnum, Race.None);
+ }
+ static addTestrequirednestedflatbuffer(builder, testrequirednestedflatbufferOffset) {
+ builder.addFieldOffset(49, testrequirednestedflatbufferOffset, 0);
+ }
+ static createTestrequirednestedflatbufferVector(builder, data) {
+ builder.startVector(1, data.length, 1);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt8(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startTestrequirednestedflatbufferVector(builder, numElems) {
+ builder.startVector(1, numElems, 1);
+ }
+ static addScalarKeySortedTables(builder, scalarKeySortedTablesOffset) {
+ builder.addFieldOffset(50, scalarKeySortedTablesOffset, 0);
+ }
+ static createScalarKeySortedTablesVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startScalarKeySortedTablesVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addNativeInline(builder, nativeInlineOffset) {
+ builder.addFieldStruct(51, nativeInlineOffset, 0);
+ }
+ static addLongEnumNonEnumDefault(builder, longEnumNonEnumDefault) {
+ builder.addFieldInt64(52, longEnumNonEnumDefault, BigInt('0'));
+ }
+ static addLongEnumNormalDefault(builder, longEnumNormalDefault) {
+ builder.addFieldInt64(53, longEnumNormalDefault, BigInt('2'));
+ }
+ static endMonster(builder) {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 10); // name
+ return offset;
+ }
+ static finishMonsterBuffer(builder, offset) {
+ builder.finish(offset, 'MONS');
+ }
+ static finishSizePrefixedMonsterBuffer(builder, offset) {
+ builder.finish(offset, 'MONS', true);
+ }
+ serialize() {
+ return this.bb.bytes();
+ }
+ static deserialize(buffer) {
+ return Monster.getRootAsMonster(new flatbuffers.ByteBuffer(buffer));
+ }
+ unpack() {
+ return new MonsterT((this.pos() !== null ? this.pos().unpack() : null), this.mana(), this.hp(), this.name(), this.bb.createScalarList(this.inventory.bind(this), this.inventoryLength()), this.color(), this.testType(), (() => {
+ let temp = unionToAny(this.testType(), this.test.bind(this));
+ if (temp === null) {
+ return null;
+ }
+ return temp.unpack();
+ })(), this.bb.createObjList(this.test4.bind(this), this.test4Length()), this.bb.createScalarList(this.testarrayofstring.bind(this), this.testarrayofstringLength()), this.bb.createObjList(this.testarrayoftables.bind(this), this.testarrayoftablesLength()), (this.enemy() !== null ? this.enemy().unpack() : null), this.bb.createScalarList(this.testnestedflatbuffer.bind(this), this.testnestedflatbufferLength()), (this.testempty() !== null ? this.testempty().unpack() : null), this.testbool(), this.testhashs32Fnv1(), this.testhashu32Fnv1(), this.testhashs64Fnv1(), this.testhashu64Fnv1(), this.testhashs32Fnv1a(), this.testhashu32Fnv1a(), this.testhashs64Fnv1a(), this.testhashu64Fnv1a(), this.bb.createScalarList(this.testarrayofbools.bind(this), this.testarrayofboolsLength()), this.testf(), this.testf2(), this.testf3(), this.bb.createScalarList(this.testarrayofstring2.bind(this), this.testarrayofstring2Length()), this.bb.createObjList(this.testarrayofsortedstruct.bind(this), this.testarrayofsortedstructLength()), this.bb.createScalarList(this.flex.bind(this), this.flexLength()), this.bb.createObjList(this.test5.bind(this), this.test5Length()), this.bb.createScalarList(this.vectorOfLongs.bind(this), this.vectorOfLongsLength()), this.bb.createScalarList(this.vectorOfDoubles.bind(this), this.vectorOfDoublesLength()), (this.parentNamespaceTest() !== null ? this.parentNamespaceTest().unpack() : null), this.bb.createObjList(this.vectorOfReferrables.bind(this), this.vectorOfReferrablesLength()), this.singleWeakReference(), this.bb.createScalarList(this.vectorOfWeakReferences.bind(this), this.vectorOfWeakReferencesLength()), this.bb.createObjList(this.vectorOfStrongReferrables.bind(this), this.vectorOfStrongReferrablesLength()), this.coOwningReference(), this.bb.createScalarList(this.vectorOfCoOwningReferences.bind(this), this.vectorOfCoOwningReferencesLength()), this.nonOwningReference(), this.bb.createScalarList(this.vectorOfNonOwningReferences.bind(this), this.vectorOfNonOwningReferencesLength()), this.anyUniqueType(), (() => {
+ let temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this));
+ if (temp === null) {
+ return null;
+ }
+ return temp.unpack();
+ })(), this.anyAmbiguousType(), (() => {
+ let temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this));
+ if (temp === null) {
+ return null;
+ }
+ return temp.unpack();
+ })(), this.bb.createScalarList(this.vectorOfEnums.bind(this), this.vectorOfEnumsLength()), this.signedEnum(), this.bb.createScalarList(this.testrequirednestedflatbuffer.bind(this), this.testrequirednestedflatbufferLength()), this.bb.createObjList(this.scalarKeySortedTables.bind(this), this.scalarKeySortedTablesLength()), (this.nativeInline() !== null ? this.nativeInline().unpack() : null), this.longEnumNonEnumDefault(), this.longEnumNormalDefault());
+ }
+ unpackTo(_o) {
+ _o.pos = (this.pos() !== null ? this.pos().unpack() : null);
+ _o.mana = this.mana();
+ _o.hp = this.hp();
+ _o.name = this.name();
+ _o.inventory = this.bb.createScalarList(this.inventory.bind(this), this.inventoryLength());
+ _o.color = this.color();
+ _o.testType = this.testType();
+ _o.test = (() => {
+ let temp = unionToAny(this.testType(), this.test.bind(this));
+ if (temp === null) {
+ return null;
+ }
+ return temp.unpack();
+ })();
+ _o.test4 = this.bb.createObjList(this.test4.bind(this), this.test4Length());
+ _o.testarrayofstring = this.bb.createScalarList(this.testarrayofstring.bind(this), this.testarrayofstringLength());
+ _o.testarrayoftables = this.bb.createObjList(this.testarrayoftables.bind(this), this.testarrayoftablesLength());
+ _o.enemy = (this.enemy() !== null ? this.enemy().unpack() : null);
+ _o.testnestedflatbuffer = this.bb.createScalarList(this.testnestedflatbuffer.bind(this), this.testnestedflatbufferLength());
+ _o.testempty = (this.testempty() !== null ? this.testempty().unpack() : null);
+ _o.testbool = this.testbool();
+ _o.testhashs32Fnv1 = this.testhashs32Fnv1();
+ _o.testhashu32Fnv1 = this.testhashu32Fnv1();
+ _o.testhashs64Fnv1 = this.testhashs64Fnv1();
+ _o.testhashu64Fnv1 = this.testhashu64Fnv1();
+ _o.testhashs32Fnv1a = this.testhashs32Fnv1a();
+ _o.testhashu32Fnv1a = this.testhashu32Fnv1a();
+ _o.testhashs64Fnv1a = this.testhashs64Fnv1a();
+ _o.testhashu64Fnv1a = this.testhashu64Fnv1a();
+ _o.testarrayofbools = this.bb.createScalarList(this.testarrayofbools.bind(this), this.testarrayofboolsLength());
+ _o.testf = this.testf();
+ _o.testf2 = this.testf2();
+ _o.testf3 = this.testf3();
+ _o.testarrayofstring2 = this.bb.createScalarList(this.testarrayofstring2.bind(this), this.testarrayofstring2Length());
+ _o.testarrayofsortedstruct = this.bb.createObjList(this.testarrayofsortedstruct.bind(this), this.testarrayofsortedstructLength());
+ _o.flex = this.bb.createScalarList(this.flex.bind(this), this.flexLength());
+ _o.test5 = this.bb.createObjList(this.test5.bind(this), this.test5Length());
+ _o.vectorOfLongs = this.bb.createScalarList(this.vectorOfLongs.bind(this), this.vectorOfLongsLength());
+ _o.vectorOfDoubles = this.bb.createScalarList(this.vectorOfDoubles.bind(this), this.vectorOfDoublesLength());
+ _o.parentNamespaceTest = (this.parentNamespaceTest() !== null ? this.parentNamespaceTest().unpack() : null);
+ _o.vectorOfReferrables = this.bb.createObjList(this.vectorOfReferrables.bind(this), this.vectorOfReferrablesLength());
+ _o.singleWeakReference = this.singleWeakReference();
+ _o.vectorOfWeakReferences = this.bb.createScalarList(this.vectorOfWeakReferences.bind(this), this.vectorOfWeakReferencesLength());
+ _o.vectorOfStrongReferrables = this.bb.createObjList(this.vectorOfStrongReferrables.bind(this), this.vectorOfStrongReferrablesLength());
+ _o.coOwningReference = this.coOwningReference();
+ _o.vectorOfCoOwningReferences = this.bb.createScalarList(this.vectorOfCoOwningReferences.bind(this), this.vectorOfCoOwningReferencesLength());
+ _o.nonOwningReference = this.nonOwningReference();
+ _o.vectorOfNonOwningReferences = this.bb.createScalarList(this.vectorOfNonOwningReferences.bind(this), this.vectorOfNonOwningReferencesLength());
+ _o.anyUniqueType = this.anyUniqueType();
+ _o.anyUnique = (() => {
+ let temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this));
+ if (temp === null) {
+ return null;
+ }
+ return temp.unpack();
+ })();
+ _o.anyAmbiguousType = this.anyAmbiguousType();
+ _o.anyAmbiguous = (() => {
+ let temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this));
+ if (temp === null) {
+ return null;
+ }
+ return temp.unpack();
+ })();
+ _o.vectorOfEnums = this.bb.createScalarList(this.vectorOfEnums.bind(this), this.vectorOfEnumsLength());
+ _o.signedEnum = this.signedEnum();
+ _o.testrequirednestedflatbuffer = this.bb.createScalarList(this.testrequirednestedflatbuffer.bind(this), this.testrequirednestedflatbufferLength());
+ _o.scalarKeySortedTables = this.bb.createObjList(this.scalarKeySortedTables.bind(this), this.scalarKeySortedTablesLength());
+ _o.nativeInline = (this.nativeInline() !== null ? this.nativeInline().unpack() : null);
+ _o.longEnumNonEnumDefault = this.longEnumNonEnumDefault();
+ _o.longEnumNormalDefault = this.longEnumNormalDefault();
+ }
+}
+export class MonsterT {
+ constructor(pos = null, mana = 150, hp = 100, name = null, inventory = [], color = Color.Blue, testType = Any.NONE, test = null, test4 = [], testarrayofstring = [], testarrayoftables = [], enemy = null, testnestedflatbuffer = [], testempty = null, testbool = false, testhashs32Fnv1 = 0, testhashu32Fnv1 = 0, testhashs64Fnv1 = BigInt('0'), testhashu64Fnv1 = BigInt('0'), testhashs32Fnv1a = 0, testhashu32Fnv1a = 0, testhashs64Fnv1a = BigInt('0'), testhashu64Fnv1a = BigInt('0'), testarrayofbools = [], testf = 3.14159, testf2 = 3.0, testf3 = 0.0, testarrayofstring2 = [], testarrayofsortedstruct = [], flex = [], test5 = [], vectorOfLongs = [], vectorOfDoubles = [], parentNamespaceTest = null, vectorOfReferrables = [], singleWeakReference = BigInt('0'), vectorOfWeakReferences = [], vectorOfStrongReferrables = [], coOwningReference = BigInt('0'), vectorOfCoOwningReferences = [], nonOwningReference = BigInt('0'), vectorOfNonOwningReferences = [], anyUniqueType = AnyUniqueAliases.NONE, anyUnique = null, anyAmbiguousType = AnyAmbiguousAliases.NONE, anyAmbiguous = null, vectorOfEnums = [], signedEnum = Race.None, testrequirednestedflatbuffer = [], scalarKeySortedTables = [], nativeInline = null, longEnumNonEnumDefault = BigInt('0'), longEnumNormalDefault = BigInt('2')) {
+ this.pos = pos;
+ this.mana = mana;
+ this.hp = hp;
+ this.name = name;
+ this.inventory = inventory;
+ this.color = color;
+ this.testType = testType;
+ this.test = test;
+ this.test4 = test4;
+ this.testarrayofstring = testarrayofstring;
+ this.testarrayoftables = testarrayoftables;
+ this.enemy = enemy;
+ this.testnestedflatbuffer = testnestedflatbuffer;
+ this.testempty = testempty;
+ this.testbool = testbool;
+ this.testhashs32Fnv1 = testhashs32Fnv1;
+ this.testhashu32Fnv1 = testhashu32Fnv1;
+ this.testhashs64Fnv1 = testhashs64Fnv1;
+ this.testhashu64Fnv1 = testhashu64Fnv1;
+ this.testhashs32Fnv1a = testhashs32Fnv1a;
+ this.testhashu32Fnv1a = testhashu32Fnv1a;
+ this.testhashs64Fnv1a = testhashs64Fnv1a;
+ this.testhashu64Fnv1a = testhashu64Fnv1a;
+ this.testarrayofbools = testarrayofbools;
+ this.testf = testf;
+ this.testf2 = testf2;
+ this.testf3 = testf3;
+ this.testarrayofstring2 = testarrayofstring2;
+ this.testarrayofsortedstruct = testarrayofsortedstruct;
+ this.flex = flex;
+ this.test5 = test5;
+ this.vectorOfLongs = vectorOfLongs;
+ this.vectorOfDoubles = vectorOfDoubles;
+ this.parentNamespaceTest = parentNamespaceTest;
+ this.vectorOfReferrables = vectorOfReferrables;
+ this.singleWeakReference = singleWeakReference;
+ this.vectorOfWeakReferences = vectorOfWeakReferences;
+ this.vectorOfStrongReferrables = vectorOfStrongReferrables;
+ this.coOwningReference = coOwningReference;
+ this.vectorOfCoOwningReferences = vectorOfCoOwningReferences;
+ this.nonOwningReference = nonOwningReference;
+ this.vectorOfNonOwningReferences = vectorOfNonOwningReferences;
+ this.anyUniqueType = anyUniqueType;
+ this.anyUnique = anyUnique;
+ this.anyAmbiguousType = anyAmbiguousType;
+ this.anyAmbiguous = anyAmbiguous;
+ this.vectorOfEnums = vectorOfEnums;
+ this.signedEnum = signedEnum;
+ this.testrequirednestedflatbuffer = testrequirednestedflatbuffer;
+ this.scalarKeySortedTables = scalarKeySortedTables;
+ this.nativeInline = nativeInline;
+ this.longEnumNonEnumDefault = longEnumNonEnumDefault;
+ this.longEnumNormalDefault = longEnumNormalDefault;
+ }
+ pack(builder) {
+ const name = (this.name !== null ? builder.createString(this.name) : 0);
+ const inventory = Monster.createInventoryVector(builder, this.inventory);
+ const test = builder.createObjectOffset(this.test);
+ const test4 = builder.createStructOffsetList(this.test4, Monster.startTest4Vector);
+ const testarrayofstring = Monster.createTestarrayofstringVector(builder, builder.createObjectOffsetList(this.testarrayofstring));
+ const testarrayoftables = Monster.createTestarrayoftablesVector(builder, builder.createObjectOffsetList(this.testarrayoftables));
+ const enemy = (this.enemy !== null ? this.enemy.pack(builder) : 0);
+ const testnestedflatbuffer = Monster.createTestnestedflatbufferVector(builder, this.testnestedflatbuffer);
+ const testempty = (this.testempty !== null ? this.testempty.pack(builder) : 0);
+ const testarrayofbools = Monster.createTestarrayofboolsVector(builder, this.testarrayofbools);
+ const testarrayofstring2 = Monster.createTestarrayofstring2Vector(builder, builder.createObjectOffsetList(this.testarrayofstring2));
+ const testarrayofsortedstruct = builder.createStructOffsetList(this.testarrayofsortedstruct, Monster.startTestarrayofsortedstructVector);
+ const flex = Monster.createFlexVector(builder, this.flex);
+ const test5 = builder.createStructOffsetList(this.test5, Monster.startTest5Vector);
+ const vectorOfLongs = Monster.createVectorOfLongsVector(builder, this.vectorOfLongs);
+ const vectorOfDoubles = Monster.createVectorOfDoublesVector(builder, this.vectorOfDoubles);
+ const parentNamespaceTest = (this.parentNamespaceTest !== null ? this.parentNamespaceTest.pack(builder) : 0);
+ const vectorOfReferrables = Monster.createVectorOfReferrablesVector(builder, builder.createObjectOffsetList(this.vectorOfReferrables));
+ const vectorOfWeakReferences = Monster.createVectorOfWeakReferencesVector(builder, this.vectorOfWeakReferences);
+ const vectorOfStrongReferrables = Monster.createVectorOfStrongReferrablesVector(builder, builder.createObjectOffsetList(this.vectorOfStrongReferrables));
+ const vectorOfCoOwningReferences = Monster.createVectorOfCoOwningReferencesVector(builder, this.vectorOfCoOwningReferences);
+ const vectorOfNonOwningReferences = Monster.createVectorOfNonOwningReferencesVector(builder, this.vectorOfNonOwningReferences);
+ const anyUnique = builder.createObjectOffset(this.anyUnique);
+ const anyAmbiguous = builder.createObjectOffset(this.anyAmbiguous);
+ const vectorOfEnums = Monster.createVectorOfEnumsVector(builder, this.vectorOfEnums);
+ const testrequirednestedflatbuffer = Monster.createTestrequirednestedflatbufferVector(builder, this.testrequirednestedflatbuffer);
+ const scalarKeySortedTables = Monster.createScalarKeySortedTablesVector(builder, builder.createObjectOffsetList(this.scalarKeySortedTables));
+ Monster.startMonster(builder);
+ Monster.addPos(builder, (this.pos !== null ? this.pos.pack(builder) : 0));
+ Monster.addMana(builder, this.mana);
+ Monster.addHp(builder, this.hp);
+ Monster.addName(builder, name);
+ Monster.addInventory(builder, inventory);
+ Monster.addColor(builder, this.color);
+ Monster.addTestType(builder, this.testType);
+ Monster.addTest(builder, test);
+ Monster.addTest4(builder, test4);
+ Monster.addTestarrayofstring(builder, testarrayofstring);
+ Monster.addTestarrayoftables(builder, testarrayoftables);
+ Monster.addEnemy(builder, enemy);
+ Monster.addTestnestedflatbuffer(builder, testnestedflatbuffer);
+ Monster.addTestempty(builder, testempty);
+ Monster.addTestbool(builder, this.testbool);
+ Monster.addTesthashs32Fnv1(builder, this.testhashs32Fnv1);
+ Monster.addTesthashu32Fnv1(builder, this.testhashu32Fnv1);
+ Monster.addTesthashs64Fnv1(builder, this.testhashs64Fnv1);
+ Monster.addTesthashu64Fnv1(builder, this.testhashu64Fnv1);
+ Monster.addTesthashs32Fnv1a(builder, this.testhashs32Fnv1a);
+ Monster.addTesthashu32Fnv1a(builder, this.testhashu32Fnv1a);
+ Monster.addTesthashs64Fnv1a(builder, this.testhashs64Fnv1a);
+ Monster.addTesthashu64Fnv1a(builder, this.testhashu64Fnv1a);
+ Monster.addTestarrayofbools(builder, testarrayofbools);
+ Monster.addTestf(builder, this.testf);
+ Monster.addTestf2(builder, this.testf2);
+ Monster.addTestf3(builder, this.testf3);
+ Monster.addTestarrayofstring2(builder, testarrayofstring2);
+ Monster.addTestarrayofsortedstruct(builder, testarrayofsortedstruct);
+ Monster.addFlex(builder, flex);
+ Monster.addTest5(builder, test5);
+ Monster.addVectorOfLongs(builder, vectorOfLongs);
+ Monster.addVectorOfDoubles(builder, vectorOfDoubles);
+ Monster.addParentNamespaceTest(builder, parentNamespaceTest);
+ Monster.addVectorOfReferrables(builder, vectorOfReferrables);
+ Monster.addSingleWeakReference(builder, this.singleWeakReference);
+ Monster.addVectorOfWeakReferences(builder, vectorOfWeakReferences);
+ Monster.addVectorOfStrongReferrables(builder, vectorOfStrongReferrables);
+ Monster.addCoOwningReference(builder, this.coOwningReference);
+ Monster.addVectorOfCoOwningReferences(builder, vectorOfCoOwningReferences);
+ Monster.addNonOwningReference(builder, this.nonOwningReference);
+ Monster.addVectorOfNonOwningReferences(builder, vectorOfNonOwningReferences);
+ Monster.addAnyUniqueType(builder, this.anyUniqueType);
+ Monster.addAnyUnique(builder, anyUnique);
+ Monster.addAnyAmbiguousType(builder, this.anyAmbiguousType);
+ Monster.addAnyAmbiguous(builder, anyAmbiguous);
+ Monster.addVectorOfEnums(builder, vectorOfEnums);
+ Monster.addSignedEnum(builder, this.signedEnum);
+ Monster.addTestrequirednestedflatbuffer(builder, testrequirednestedflatbuffer);
+ Monster.addScalarKeySortedTables(builder, scalarKeySortedTables);
+ Monster.addNativeInline(builder, (this.nativeInline !== null ? this.nativeInline.pack(builder) : 0));
+ Monster.addLongEnumNonEnumDefault(builder, this.longEnumNonEnumDefault);
+ Monster.addLongEnumNormalDefault(builder, this.longEnumNormalDefault);
+ return Monster.endMonster(builder);
+ }
+}
diff --git a/tests/ts/my-game/example/monster.ts b/tests/ts/my-game/example/monster.ts
new file mode 100644
index 0000000..63e5768
--- /dev/null
+++ b/tests/ts/my-game/example/monster.ts
@@ -0,0 +1,1434 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+import { Monster as MyGame_Example2_Monster, MonsterT as MyGame_Example2_MonsterT } from '../../my-game/example2/monster.js';
+import { Ability, AbilityT } from '../../my-game/example/ability.js';
+import { Any, unionToAny, unionListToAny } from '../../my-game/example/any.js';
+import { AnyAmbiguousAliases, unionToAnyAmbiguousAliases, unionListToAnyAmbiguousAliases } from '../../my-game/example/any-ambiguous-aliases.js';
+import { AnyUniqueAliases, unionToAnyUniqueAliases, unionListToAnyUniqueAliases } from '../../my-game/example/any-unique-aliases.js';
+import { Color } from '../../my-game/example/color.js';
+import { Race } from '../../my-game/example/race.js';
+import { Referrable, ReferrableT } from '../../my-game/example/referrable.js';
+import { Stat, StatT } from '../../my-game/example/stat.js';
+import { Test, TestT } from '../../my-game/example/test.js';
+import { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from '../../my-game/example/test-simple-table-with-enum.js';
+import { Vec3, Vec3T } from '../../my-game/example/vec3.js';
+import { InParentNamespace, InParentNamespaceT } from '../../my-game/in-parent-namespace.js';
+
+
+/**
+ * an example documentation comment: "monster object"
+ */
+export class Monster {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):Monster {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:Monster):Monster {
+ return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:Monster):Monster {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean {
+ return bb.__has_identifier('MONS');
+}
+
+pos(obj?:Vec3):Vec3|null {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? (obj || new Vec3()).__init(this.bb_pos + offset, this.bb!) : null;
+}
+
+mana():number {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.readInt16(this.bb_pos + offset) : 150;
+}
+
+mutate_mana(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt16(this.bb_pos + offset, value);
+ return true;
+}
+
+hp():number {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? this.bb!.readInt16(this.bb_pos + offset) : 100;
+}
+
+mutate_hp(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt16(this.bb_pos + offset, value);
+ return true;
+}
+
+name():string|null
+name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+name(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+inventory(index: number):number|null {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
+}
+
+inventoryLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+inventoryArray():Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
+}
+
+color():Color {
+ const offset = this.bb!.__offset(this.bb_pos, 16);
+ return offset ? this.bb!.readUint8(this.bb_pos + offset) : Color.Blue;
+}
+
+mutate_color(value:Color):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 16);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint8(this.bb_pos + offset, value);
+ return true;
+}
+
+testType():Any {
+ const offset = this.bb!.__offset(this.bb_pos, 18);
+ return offset ? this.bb!.readUint8(this.bb_pos + offset) : Any.NONE;
+}
+
+test<T extends flatbuffers.Table>(obj:any):any|null {
+ const offset = this.bb!.__offset(this.bb_pos, 20);
+ return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null;
+}
+
+test4(index: number, obj?:Test):Test|null {
+ const offset = this.bb!.__offset(this.bb_pos, 22);
+ return offset ? (obj || new Test()).__init(this.bb!.__vector(this.bb_pos + offset) + index * 4, this.bb!) : null;
+}
+
+test4Length():number {
+ const offset = this.bb!.__offset(this.bb_pos, 22);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+testarrayofstring(index: number):string
+testarrayofstring(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array
+testarrayofstring(index: number,optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 24);
+ return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+}
+
+testarrayofstringLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 24);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+/**
+ * an example documentation comment: this will end up in the generated code
+ * multiline too
+ */
+testarrayoftables(index: number, obj?:Monster):Monster|null {
+ const offset = this.bb!.__offset(this.bb_pos, 26);
+ return offset ? (obj || new Monster()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+testarrayoftablesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 26);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+enemy(obj?:Monster):Monster|null {
+ const offset = this.bb!.__offset(this.bb_pos, 28);
+ return offset ? (obj || new Monster()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
+}
+
+testnestedflatbuffer(index: number):number|null {
+ const offset = this.bb!.__offset(this.bb_pos, 30);
+ return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
+}
+
+testnestedflatbufferLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 30);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+testnestedflatbufferArray():Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 30);
+ return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
+}
+
+testempty(obj?:Stat):Stat|null {
+ const offset = this.bb!.__offset(this.bb_pos, 32);
+ return offset ? (obj || new Stat()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
+}
+
+testbool():boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 34);
+ return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
+}
+
+mutate_testbool(value:boolean):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 34);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt8(this.bb_pos + offset, +value);
+ return true;
+}
+
+testhashs32Fnv1():number {
+ const offset = this.bb!.__offset(this.bb_pos, 36);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
+}
+
+mutate_testhashs32_fnv1(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 36);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt32(this.bb_pos + offset, value);
+ return true;
+}
+
+testhashu32Fnv1():number {
+ const offset = this.bb!.__offset(this.bb_pos, 38);
+ return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0;
+}
+
+mutate_testhashu32_fnv1(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 38);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint32(this.bb_pos + offset, value);
+ return true;
+}
+
+testhashs64Fnv1():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 40);
+ return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
+}
+
+mutate_testhashs64_fnv1(value:bigint):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 40);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt64(this.bb_pos + offset, value);
+ return true;
+}
+
+testhashu64Fnv1():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 42);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
+}
+
+mutate_testhashu64_fnv1(value:bigint):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 42);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint64(this.bb_pos + offset, value);
+ return true;
+}
+
+testhashs32Fnv1a():number {
+ const offset = this.bb!.__offset(this.bb_pos, 44);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
+}
+
+mutate_testhashs32_fnv1a(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 44);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt32(this.bb_pos + offset, value);
+ return true;
+}
+
+testhashu32Fnv1a():number {
+ const offset = this.bb!.__offset(this.bb_pos, 46);
+ return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0;
+}
+
+mutate_testhashu32_fnv1a(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 46);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint32(this.bb_pos + offset, value);
+ return true;
+}
+
+testhashs64Fnv1a():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 48);
+ return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
+}
+
+mutate_testhashs64_fnv1a(value:bigint):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 48);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt64(this.bb_pos + offset, value);
+ return true;
+}
+
+testhashu64Fnv1a():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 50);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
+}
+
+mutate_testhashu64_fnv1a(value:bigint):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 50);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint64(this.bb_pos + offset, value);
+ return true;
+}
+
+testarrayofbools(index: number):boolean|null {
+ const offset = this.bb!.__offset(this.bb_pos, 52);
+ return offset ? !!this.bb!.readInt8(this.bb!.__vector(this.bb_pos + offset) + index) : false;
+}
+
+testarrayofboolsLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 52);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+testarrayofboolsArray():Int8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 52);
+ return offset ? new Int8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
+}
+
+testf():number {
+ const offset = this.bb!.__offset(this.bb_pos, 54);
+ return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 3.14159;
+}
+
+mutate_testf(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 54);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeFloat32(this.bb_pos + offset, value);
+ return true;
+}
+
+testf2():number {
+ const offset = this.bb!.__offset(this.bb_pos, 56);
+ return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 3.0;
+}
+
+mutate_testf2(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 56);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeFloat32(this.bb_pos + offset, value);
+ return true;
+}
+
+testf3():number {
+ const offset = this.bb!.__offset(this.bb_pos, 58);
+ return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
+}
+
+mutate_testf3(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 58);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeFloat32(this.bb_pos + offset, value);
+ return true;
+}
+
+testarrayofstring2(index: number):string
+testarrayofstring2(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array
+testarrayofstring2(index: number,optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 60);
+ return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+}
+
+testarrayofstring2Length():number {
+ const offset = this.bb!.__offset(this.bb_pos, 60);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+testarrayofsortedstruct(index: number, obj?:Ability):Ability|null {
+ const offset = this.bb!.__offset(this.bb_pos, 62);
+ return offset ? (obj || new Ability()).__init(this.bb!.__vector(this.bb_pos + offset) + index * 8, this.bb!) : null;
+}
+
+testarrayofsortedstructLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 62);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+flex(index: number):number|null {
+ const offset = this.bb!.__offset(this.bb_pos, 64);
+ return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
+}
+
+flexLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 64);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+flexArray():Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 64);
+ return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
+}
+
+test5(index: number, obj?:Test):Test|null {
+ const offset = this.bb!.__offset(this.bb_pos, 66);
+ return offset ? (obj || new Test()).__init(this.bb!.__vector(this.bb_pos + offset) + index * 4, this.bb!) : null;
+}
+
+test5Length():number {
+ const offset = this.bb!.__offset(this.bb_pos, 66);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+vectorOfLongs(index: number):bigint|null {
+ const offset = this.bb!.__offset(this.bb_pos, 68);
+ return offset ? this.bb!.readInt64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : BigInt(0);
+}
+
+vectorOfLongsLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 68);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+vectorOfDoubles(index: number):number|null {
+ const offset = this.bb!.__offset(this.bb_pos, 70);
+ return offset ? this.bb!.readFloat64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : 0;
+}
+
+vectorOfDoublesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 70);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+vectorOfDoublesArray():Float64Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 70);
+ return offset ? new Float64Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
+}
+
+parentNamespaceTest(obj?:InParentNamespace):InParentNamespace|null {
+ const offset = this.bb!.__offset(this.bb_pos, 72);
+ return offset ? (obj || new InParentNamespace()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
+}
+
+vectorOfReferrables(index: number, obj?:Referrable):Referrable|null {
+ const offset = this.bb!.__offset(this.bb_pos, 74);
+ return offset ? (obj || new Referrable()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+vectorOfReferrablesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 74);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+singleWeakReference():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 76);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
+}
+
+mutate_single_weak_reference(value:bigint):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 76);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint64(this.bb_pos + offset, value);
+ return true;
+}
+
+vectorOfWeakReferences(index: number):bigint|null {
+ const offset = this.bb!.__offset(this.bb_pos, 78);
+ return offset ? this.bb!.readUint64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : BigInt(0);
+}
+
+vectorOfWeakReferencesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 78);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+vectorOfStrongReferrables(index: number, obj?:Referrable):Referrable|null {
+ const offset = this.bb!.__offset(this.bb_pos, 80);
+ return offset ? (obj || new Referrable()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+vectorOfStrongReferrablesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 80);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+coOwningReference():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 82);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
+}
+
+mutate_co_owning_reference(value:bigint):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 82);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint64(this.bb_pos + offset, value);
+ return true;
+}
+
+vectorOfCoOwningReferences(index: number):bigint|null {
+ const offset = this.bb!.__offset(this.bb_pos, 84);
+ return offset ? this.bb!.readUint64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : BigInt(0);
+}
+
+vectorOfCoOwningReferencesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 84);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+nonOwningReference():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 86);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
+}
+
+mutate_non_owning_reference(value:bigint):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 86);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint64(this.bb_pos + offset, value);
+ return true;
+}
+
+vectorOfNonOwningReferences(index: number):bigint|null {
+ const offset = this.bb!.__offset(this.bb_pos, 88);
+ return offset ? this.bb!.readUint64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : BigInt(0);
+}
+
+vectorOfNonOwningReferencesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 88);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+anyUniqueType():AnyUniqueAliases {
+ const offset = this.bb!.__offset(this.bb_pos, 90);
+ return offset ? this.bb!.readUint8(this.bb_pos + offset) : AnyUniqueAliases.NONE;
+}
+
+anyUnique<T extends flatbuffers.Table>(obj:any):any|null {
+ const offset = this.bb!.__offset(this.bb_pos, 92);
+ return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null;
+}
+
+anyAmbiguousType():AnyAmbiguousAliases {
+ const offset = this.bb!.__offset(this.bb_pos, 94);
+ return offset ? this.bb!.readUint8(this.bb_pos + offset) : AnyAmbiguousAliases.NONE;
+}
+
+anyAmbiguous<T extends flatbuffers.Table>(obj:any):any|null {
+ const offset = this.bb!.__offset(this.bb_pos, 96);
+ return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null;
+}
+
+vectorOfEnums(index: number):Color|null {
+ const offset = this.bb!.__offset(this.bb_pos, 98);
+ return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
+}
+
+vectorOfEnumsLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 98);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+vectorOfEnumsArray():Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 98);
+ return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
+}
+
+signedEnum():Race {
+ const offset = this.bb!.__offset(this.bb_pos, 100);
+ return offset ? this.bb!.readInt8(this.bb_pos + offset) : Race.None;
+}
+
+mutate_signed_enum(value:Race):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 100);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt8(this.bb_pos + offset, value);
+ return true;
+}
+
+testrequirednestedflatbuffer(index: number):number|null {
+ const offset = this.bb!.__offset(this.bb_pos, 102);
+ return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
+}
+
+testrequirednestedflatbufferLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 102);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+testrequirednestedflatbufferArray():Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 102);
+ return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
+}
+
+scalarKeySortedTables(index: number, obj?:Stat):Stat|null {
+ const offset = this.bb!.__offset(this.bb_pos, 104);
+ return offset ? (obj || new Stat()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+scalarKeySortedTablesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 104);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+nativeInline(obj?:Test):Test|null {
+ const offset = this.bb!.__offset(this.bb_pos, 106);
+ return offset ? (obj || new Test()).__init(this.bb_pos + offset, this.bb!) : null;
+}
+
+longEnumNonEnumDefault():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 108);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
+}
+
+mutate_long_enum_non_enum_default(value:bigint):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 108);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint64(this.bb_pos + offset, value);
+ return true;
+}
+
+longEnumNormalDefault():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 110);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('2');
+}
+
+mutate_long_enum_normal_default(value:bigint):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 110);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint64(this.bb_pos + offset, value);
+ return true;
+}
+
+static getFullyQualifiedName():string {
+ return 'MyGame_Example_Monster';
+}
+
+static startMonster(builder:flatbuffers.Builder) {
+ builder.startObject(54);
+}
+
+static addPos(builder:flatbuffers.Builder, posOffset:flatbuffers.Offset) {
+ builder.addFieldStruct(0, posOffset, 0);
+}
+
+static addMana(builder:flatbuffers.Builder, mana:number) {
+ builder.addFieldInt16(1, mana, 150);
+}
+
+static addHp(builder:flatbuffers.Builder, hp:number) {
+ builder.addFieldInt16(2, hp, 100);
+}
+
+static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(3, nameOffset, 0);
+}
+
+static addInventory(builder:flatbuffers.Builder, inventoryOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(5, inventoryOffset, 0);
+}
+
+static createInventoryVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset {
+ builder.startVector(1, data.length, 1);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt8(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startInventoryVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(1, numElems, 1);
+}
+
+static addColor(builder:flatbuffers.Builder, color:Color) {
+ builder.addFieldInt8(6, color, Color.Blue);
+}
+
+static addTestType(builder:flatbuffers.Builder, testType:Any) {
+ builder.addFieldInt8(7, testType, Any.NONE);
+}
+
+static addTest(builder:flatbuffers.Builder, testOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(8, testOffset, 0);
+}
+
+static addTest4(builder:flatbuffers.Builder, test4Offset:flatbuffers.Offset) {
+ builder.addFieldOffset(9, test4Offset, 0);
+}
+
+static startTest4Vector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 2);
+}
+
+static addTestarrayofstring(builder:flatbuffers.Builder, testarrayofstringOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(10, testarrayofstringOffset, 0);
+}
+
+static createTestarrayofstringVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startTestarrayofstringVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addTestarrayoftables(builder:flatbuffers.Builder, testarrayoftablesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(11, testarrayoftablesOffset, 0);
+}
+
+static createTestarrayoftablesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startTestarrayoftablesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addEnemy(builder:flatbuffers.Builder, enemyOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(12, enemyOffset, 0);
+}
+
+static addTestnestedflatbuffer(builder:flatbuffers.Builder, testnestedflatbufferOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(13, testnestedflatbufferOffset, 0);
+}
+
+static createTestnestedflatbufferVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset {
+ builder.startVector(1, data.length, 1);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt8(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startTestnestedflatbufferVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(1, numElems, 1);
+}
+
+static addTestempty(builder:flatbuffers.Builder, testemptyOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(14, testemptyOffset, 0);
+}
+
+static addTestbool(builder:flatbuffers.Builder, testbool:boolean) {
+ builder.addFieldInt8(15, +testbool, +false);
+}
+
+static addTesthashs32Fnv1(builder:flatbuffers.Builder, testhashs32Fnv1:number) {
+ builder.addFieldInt32(16, testhashs32Fnv1, 0);
+}
+
+static addTesthashu32Fnv1(builder:flatbuffers.Builder, testhashu32Fnv1:number) {
+ builder.addFieldInt32(17, testhashu32Fnv1, 0);
+}
+
+static addTesthashs64Fnv1(builder:flatbuffers.Builder, testhashs64Fnv1:bigint) {
+ builder.addFieldInt64(18, testhashs64Fnv1, BigInt('0'));
+}
+
+static addTesthashu64Fnv1(builder:flatbuffers.Builder, testhashu64Fnv1:bigint) {
+ builder.addFieldInt64(19, testhashu64Fnv1, BigInt('0'));
+}
+
+static addTesthashs32Fnv1a(builder:flatbuffers.Builder, testhashs32Fnv1a:number) {
+ builder.addFieldInt32(20, testhashs32Fnv1a, 0);
+}
+
+static addTesthashu32Fnv1a(builder:flatbuffers.Builder, testhashu32Fnv1a:number) {
+ builder.addFieldInt32(21, testhashu32Fnv1a, 0);
+}
+
+static addTesthashs64Fnv1a(builder:flatbuffers.Builder, testhashs64Fnv1a:bigint) {
+ builder.addFieldInt64(22, testhashs64Fnv1a, BigInt('0'));
+}
+
+static addTesthashu64Fnv1a(builder:flatbuffers.Builder, testhashu64Fnv1a:bigint) {
+ builder.addFieldInt64(23, testhashu64Fnv1a, BigInt('0'));
+}
+
+static addTestarrayofbools(builder:flatbuffers.Builder, testarrayofboolsOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(24, testarrayofboolsOffset, 0);
+}
+
+static createTestarrayofboolsVector(builder:flatbuffers.Builder, data:boolean[]):flatbuffers.Offset {
+ builder.startVector(1, data.length, 1);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt8(+data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startTestarrayofboolsVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(1, numElems, 1);
+}
+
+static addTestf(builder:flatbuffers.Builder, testf:number) {
+ builder.addFieldFloat32(25, testf, 3.14159);
+}
+
+static addTestf2(builder:flatbuffers.Builder, testf2:number) {
+ builder.addFieldFloat32(26, testf2, 3.0);
+}
+
+static addTestf3(builder:flatbuffers.Builder, testf3:number) {
+ builder.addFieldFloat32(27, testf3, 0.0);
+}
+
+static addTestarrayofstring2(builder:flatbuffers.Builder, testarrayofstring2Offset:flatbuffers.Offset) {
+ builder.addFieldOffset(28, testarrayofstring2Offset, 0);
+}
+
+static createTestarrayofstring2Vector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startTestarrayofstring2Vector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addTestarrayofsortedstruct(builder:flatbuffers.Builder, testarrayofsortedstructOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(29, testarrayofsortedstructOffset, 0);
+}
+
+static startTestarrayofsortedstructVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(8, numElems, 4);
+}
+
+static addFlex(builder:flatbuffers.Builder, flexOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(30, flexOffset, 0);
+}
+
+static createFlexVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset {
+ builder.startVector(1, data.length, 1);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt8(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startFlexVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(1, numElems, 1);
+}
+
+static addTest5(builder:flatbuffers.Builder, test5Offset:flatbuffers.Offset) {
+ builder.addFieldOffset(31, test5Offset, 0);
+}
+
+static startTest5Vector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 2);
+}
+
+static addVectorOfLongs(builder:flatbuffers.Builder, vectorOfLongsOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(32, vectorOfLongsOffset, 0);
+}
+
+static createVectorOfLongsVector(builder:flatbuffers.Builder, data:bigint[]):flatbuffers.Offset {
+ builder.startVector(8, data.length, 8);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt64(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startVectorOfLongsVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(8, numElems, 8);
+}
+
+static addVectorOfDoubles(builder:flatbuffers.Builder, vectorOfDoublesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(33, vectorOfDoublesOffset, 0);
+}
+
+static createVectorOfDoublesVector(builder:flatbuffers.Builder, data:number[]|Float64Array):flatbuffers.Offset;
+/**
+ * @deprecated This Uint8Array overload will be removed in the future.
+ */
+static createVectorOfDoublesVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset;
+static createVectorOfDoublesVector(builder:flatbuffers.Builder, data:number[]|Float64Array|Uint8Array):flatbuffers.Offset {
+ builder.startVector(8, data.length, 8);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addFloat64(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startVectorOfDoublesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(8, numElems, 8);
+}
+
+static addParentNamespaceTest(builder:flatbuffers.Builder, parentNamespaceTestOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(34, parentNamespaceTestOffset, 0);
+}
+
+static addVectorOfReferrables(builder:flatbuffers.Builder, vectorOfReferrablesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(35, vectorOfReferrablesOffset, 0);
+}
+
+static createVectorOfReferrablesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startVectorOfReferrablesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addSingleWeakReference(builder:flatbuffers.Builder, singleWeakReference:bigint) {
+ builder.addFieldInt64(36, singleWeakReference, BigInt('0'));
+}
+
+static addVectorOfWeakReferences(builder:flatbuffers.Builder, vectorOfWeakReferencesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(37, vectorOfWeakReferencesOffset, 0);
+}
+
+static createVectorOfWeakReferencesVector(builder:flatbuffers.Builder, data:bigint[]):flatbuffers.Offset {
+ builder.startVector(8, data.length, 8);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt64(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startVectorOfWeakReferencesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(8, numElems, 8);
+}
+
+static addVectorOfStrongReferrables(builder:flatbuffers.Builder, vectorOfStrongReferrablesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(38, vectorOfStrongReferrablesOffset, 0);
+}
+
+static createVectorOfStrongReferrablesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startVectorOfStrongReferrablesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addCoOwningReference(builder:flatbuffers.Builder, coOwningReference:bigint) {
+ builder.addFieldInt64(39, coOwningReference, BigInt('0'));
+}
+
+static addVectorOfCoOwningReferences(builder:flatbuffers.Builder, vectorOfCoOwningReferencesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(40, vectorOfCoOwningReferencesOffset, 0);
+}
+
+static createVectorOfCoOwningReferencesVector(builder:flatbuffers.Builder, data:bigint[]):flatbuffers.Offset {
+ builder.startVector(8, data.length, 8);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt64(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startVectorOfCoOwningReferencesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(8, numElems, 8);
+}
+
+static addNonOwningReference(builder:flatbuffers.Builder, nonOwningReference:bigint) {
+ builder.addFieldInt64(41, nonOwningReference, BigInt('0'));
+}
+
+static addVectorOfNonOwningReferences(builder:flatbuffers.Builder, vectorOfNonOwningReferencesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(42, vectorOfNonOwningReferencesOffset, 0);
+}
+
+static createVectorOfNonOwningReferencesVector(builder:flatbuffers.Builder, data:bigint[]):flatbuffers.Offset {
+ builder.startVector(8, data.length, 8);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt64(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startVectorOfNonOwningReferencesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(8, numElems, 8);
+}
+
+static addAnyUniqueType(builder:flatbuffers.Builder, anyUniqueType:AnyUniqueAliases) {
+ builder.addFieldInt8(43, anyUniqueType, AnyUniqueAliases.NONE);
+}
+
+static addAnyUnique(builder:flatbuffers.Builder, anyUniqueOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(44, anyUniqueOffset, 0);
+}
+
+static addAnyAmbiguousType(builder:flatbuffers.Builder, anyAmbiguousType:AnyAmbiguousAliases) {
+ builder.addFieldInt8(45, anyAmbiguousType, AnyAmbiguousAliases.NONE);
+}
+
+static addAnyAmbiguous(builder:flatbuffers.Builder, anyAmbiguousOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(46, anyAmbiguousOffset, 0);
+}
+
+static addVectorOfEnums(builder:flatbuffers.Builder, vectorOfEnumsOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(47, vectorOfEnumsOffset, 0);
+}
+
+static createVectorOfEnumsVector(builder:flatbuffers.Builder, data:Color[]):flatbuffers.Offset {
+ builder.startVector(1, data.length, 1);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt8(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startVectorOfEnumsVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(1, numElems, 1);
+}
+
+static addSignedEnum(builder:flatbuffers.Builder, signedEnum:Race) {
+ builder.addFieldInt8(48, signedEnum, Race.None);
+}
+
+static addTestrequirednestedflatbuffer(builder:flatbuffers.Builder, testrequirednestedflatbufferOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(49, testrequirednestedflatbufferOffset, 0);
+}
+
+static createTestrequirednestedflatbufferVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset {
+ builder.startVector(1, data.length, 1);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt8(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startTestrequirednestedflatbufferVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(1, numElems, 1);
+}
+
+static addScalarKeySortedTables(builder:flatbuffers.Builder, scalarKeySortedTablesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(50, scalarKeySortedTablesOffset, 0);
+}
+
+static createScalarKeySortedTablesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startScalarKeySortedTablesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addNativeInline(builder:flatbuffers.Builder, nativeInlineOffset:flatbuffers.Offset) {
+ builder.addFieldStruct(51, nativeInlineOffset, 0);
+}
+
+static addLongEnumNonEnumDefault(builder:flatbuffers.Builder, longEnumNonEnumDefault:bigint) {
+ builder.addFieldInt64(52, longEnumNonEnumDefault, BigInt('0'));
+}
+
+static addLongEnumNormalDefault(builder:flatbuffers.Builder, longEnumNormalDefault:bigint) {
+ builder.addFieldInt64(53, longEnumNormalDefault, BigInt('2'));
+}
+
+static endMonster(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 10) // name
+ return offset;
+}
+
+static finishMonsterBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
+ builder.finish(offset, 'MONS');
+}
+
+static finishSizePrefixedMonsterBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
+ builder.finish(offset, 'MONS', true);
+}
+
+
+serialize():Uint8Array {
+ return this.bb!.bytes();
+}
+
+static deserialize(buffer: Uint8Array):Monster {
+ return Monster.getRootAsMonster(new flatbuffers.ByteBuffer(buffer))
+}
+
+unpack(): MonsterT {
+ return new MonsterT(
+ (this.pos() !== null ? this.pos()!.unpack() : null),
+ this.mana(),
+ this.hp(),
+ this.name(),
+ this.bb!.createScalarList(this.inventory.bind(this), this.inventoryLength()),
+ this.color(),
+ this.testType(),
+ (() => {
+ let temp = unionToAny(this.testType(), this.test.bind(this));
+ if(temp === null) { return null; }
+ return temp.unpack()
+ })(),
+ this.bb!.createObjList(this.test4.bind(this), this.test4Length()),
+ this.bb!.createScalarList(this.testarrayofstring.bind(this), this.testarrayofstringLength()),
+ this.bb!.createObjList(this.testarrayoftables.bind(this), this.testarrayoftablesLength()),
+ (this.enemy() !== null ? this.enemy()!.unpack() : null),
+ this.bb!.createScalarList(this.testnestedflatbuffer.bind(this), this.testnestedflatbufferLength()),
+ (this.testempty() !== null ? this.testempty()!.unpack() : null),
+ this.testbool(),
+ this.testhashs32Fnv1(),
+ this.testhashu32Fnv1(),
+ this.testhashs64Fnv1(),
+ this.testhashu64Fnv1(),
+ this.testhashs32Fnv1a(),
+ this.testhashu32Fnv1a(),
+ this.testhashs64Fnv1a(),
+ this.testhashu64Fnv1a(),
+ this.bb!.createScalarList(this.testarrayofbools.bind(this), this.testarrayofboolsLength()),
+ this.testf(),
+ this.testf2(),
+ this.testf3(),
+ this.bb!.createScalarList(this.testarrayofstring2.bind(this), this.testarrayofstring2Length()),
+ this.bb!.createObjList(this.testarrayofsortedstruct.bind(this), this.testarrayofsortedstructLength()),
+ this.bb!.createScalarList(this.flex.bind(this), this.flexLength()),
+ this.bb!.createObjList(this.test5.bind(this), this.test5Length()),
+ this.bb!.createScalarList(this.vectorOfLongs.bind(this), this.vectorOfLongsLength()),
+ this.bb!.createScalarList(this.vectorOfDoubles.bind(this), this.vectorOfDoublesLength()),
+ (this.parentNamespaceTest() !== null ? this.parentNamespaceTest()!.unpack() : null),
+ this.bb!.createObjList(this.vectorOfReferrables.bind(this), this.vectorOfReferrablesLength()),
+ this.singleWeakReference(),
+ this.bb!.createScalarList(this.vectorOfWeakReferences.bind(this), this.vectorOfWeakReferencesLength()),
+ this.bb!.createObjList(this.vectorOfStrongReferrables.bind(this), this.vectorOfStrongReferrablesLength()),
+ this.coOwningReference(),
+ this.bb!.createScalarList(this.vectorOfCoOwningReferences.bind(this), this.vectorOfCoOwningReferencesLength()),
+ this.nonOwningReference(),
+ this.bb!.createScalarList(this.vectorOfNonOwningReferences.bind(this), this.vectorOfNonOwningReferencesLength()),
+ this.anyUniqueType(),
+ (() => {
+ let temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this));
+ if(temp === null) { return null; }
+ return temp.unpack()
+ })(),
+ this.anyAmbiguousType(),
+ (() => {
+ let temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this));
+ if(temp === null) { return null; }
+ return temp.unpack()
+ })(),
+ this.bb!.createScalarList(this.vectorOfEnums.bind(this), this.vectorOfEnumsLength()),
+ this.signedEnum(),
+ this.bb!.createScalarList(this.testrequirednestedflatbuffer.bind(this), this.testrequirednestedflatbufferLength()),
+ this.bb!.createObjList(this.scalarKeySortedTables.bind(this), this.scalarKeySortedTablesLength()),
+ (this.nativeInline() !== null ? this.nativeInline()!.unpack() : null),
+ this.longEnumNonEnumDefault(),
+ this.longEnumNormalDefault()
+ );
+}
+
+
+unpackTo(_o: MonsterT): void {
+ _o.pos = (this.pos() !== null ? this.pos()!.unpack() : null);
+ _o.mana = this.mana();
+ _o.hp = this.hp();
+ _o.name = this.name();
+ _o.inventory = this.bb!.createScalarList(this.inventory.bind(this), this.inventoryLength());
+ _o.color = this.color();
+ _o.testType = this.testType();
+ _o.test = (() => {
+ let temp = unionToAny(this.testType(), this.test.bind(this));
+ if(temp === null) { return null; }
+ return temp.unpack()
+ })();
+ _o.test4 = this.bb!.createObjList(this.test4.bind(this), this.test4Length());
+ _o.testarrayofstring = this.bb!.createScalarList(this.testarrayofstring.bind(this), this.testarrayofstringLength());
+ _o.testarrayoftables = this.bb!.createObjList(this.testarrayoftables.bind(this), this.testarrayoftablesLength());
+ _o.enemy = (this.enemy() !== null ? this.enemy()!.unpack() : null);
+ _o.testnestedflatbuffer = this.bb!.createScalarList(this.testnestedflatbuffer.bind(this), this.testnestedflatbufferLength());
+ _o.testempty = (this.testempty() !== null ? this.testempty()!.unpack() : null);
+ _o.testbool = this.testbool();
+ _o.testhashs32Fnv1 = this.testhashs32Fnv1();
+ _o.testhashu32Fnv1 = this.testhashu32Fnv1();
+ _o.testhashs64Fnv1 = this.testhashs64Fnv1();
+ _o.testhashu64Fnv1 = this.testhashu64Fnv1();
+ _o.testhashs32Fnv1a = this.testhashs32Fnv1a();
+ _o.testhashu32Fnv1a = this.testhashu32Fnv1a();
+ _o.testhashs64Fnv1a = this.testhashs64Fnv1a();
+ _o.testhashu64Fnv1a = this.testhashu64Fnv1a();
+ _o.testarrayofbools = this.bb!.createScalarList(this.testarrayofbools.bind(this), this.testarrayofboolsLength());
+ _o.testf = this.testf();
+ _o.testf2 = this.testf2();
+ _o.testf3 = this.testf3();
+ _o.testarrayofstring2 = this.bb!.createScalarList(this.testarrayofstring2.bind(this), this.testarrayofstring2Length());
+ _o.testarrayofsortedstruct = this.bb!.createObjList(this.testarrayofsortedstruct.bind(this), this.testarrayofsortedstructLength());
+ _o.flex = this.bb!.createScalarList(this.flex.bind(this), this.flexLength());
+ _o.test5 = this.bb!.createObjList(this.test5.bind(this), this.test5Length());
+ _o.vectorOfLongs = this.bb!.createScalarList(this.vectorOfLongs.bind(this), this.vectorOfLongsLength());
+ _o.vectorOfDoubles = this.bb!.createScalarList(this.vectorOfDoubles.bind(this), this.vectorOfDoublesLength());
+ _o.parentNamespaceTest = (this.parentNamespaceTest() !== null ? this.parentNamespaceTest()!.unpack() : null);
+ _o.vectorOfReferrables = this.bb!.createObjList(this.vectorOfReferrables.bind(this), this.vectorOfReferrablesLength());
+ _o.singleWeakReference = this.singleWeakReference();
+ _o.vectorOfWeakReferences = this.bb!.createScalarList(this.vectorOfWeakReferences.bind(this), this.vectorOfWeakReferencesLength());
+ _o.vectorOfStrongReferrables = this.bb!.createObjList(this.vectorOfStrongReferrables.bind(this), this.vectorOfStrongReferrablesLength());
+ _o.coOwningReference = this.coOwningReference();
+ _o.vectorOfCoOwningReferences = this.bb!.createScalarList(this.vectorOfCoOwningReferences.bind(this), this.vectorOfCoOwningReferencesLength());
+ _o.nonOwningReference = this.nonOwningReference();
+ _o.vectorOfNonOwningReferences = this.bb!.createScalarList(this.vectorOfNonOwningReferences.bind(this), this.vectorOfNonOwningReferencesLength());
+ _o.anyUniqueType = this.anyUniqueType();
+ _o.anyUnique = (() => {
+ let temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this));
+ if(temp === null) { return null; }
+ return temp.unpack()
+ })();
+ _o.anyAmbiguousType = this.anyAmbiguousType();
+ _o.anyAmbiguous = (() => {
+ let temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this));
+ if(temp === null) { return null; }
+ return temp.unpack()
+ })();
+ _o.vectorOfEnums = this.bb!.createScalarList(this.vectorOfEnums.bind(this), this.vectorOfEnumsLength());
+ _o.signedEnum = this.signedEnum();
+ _o.testrequirednestedflatbuffer = this.bb!.createScalarList(this.testrequirednestedflatbuffer.bind(this), this.testrequirednestedflatbufferLength());
+ _o.scalarKeySortedTables = this.bb!.createObjList(this.scalarKeySortedTables.bind(this), this.scalarKeySortedTablesLength());
+ _o.nativeInline = (this.nativeInline() !== null ? this.nativeInline()!.unpack() : null);
+ _o.longEnumNonEnumDefault = this.longEnumNonEnumDefault();
+ _o.longEnumNormalDefault = this.longEnumNormalDefault();
+}
+}
+
+export class MonsterT {
+constructor(
+ public pos: Vec3T|null = null,
+ public mana: number = 150,
+ public hp: number = 100,
+ public name: string|Uint8Array|null = null,
+ public inventory: (number)[] = [],
+ public color: Color = Color.Blue,
+ public testType: Any = Any.NONE,
+ public test: MonsterT|MyGame_Example2_MonsterT|TestSimpleTableWithEnumT|null = null,
+ public test4: (TestT)[] = [],
+ public testarrayofstring: (string)[] = [],
+ public testarrayoftables: (MonsterT)[] = [],
+ public enemy: MonsterT|null = null,
+ public testnestedflatbuffer: (number)[] = [],
+ public testempty: StatT|null = null,
+ public testbool: boolean = false,
+ public testhashs32Fnv1: number = 0,
+ public testhashu32Fnv1: number = 0,
+ public testhashs64Fnv1: bigint = BigInt('0'),
+ public testhashu64Fnv1: bigint = BigInt('0'),
+ public testhashs32Fnv1a: number = 0,
+ public testhashu32Fnv1a: number = 0,
+ public testhashs64Fnv1a: bigint = BigInt('0'),
+ public testhashu64Fnv1a: bigint = BigInt('0'),
+ public testarrayofbools: (boolean)[] = [],
+ public testf: number = 3.14159,
+ public testf2: number = 3.0,
+ public testf3: number = 0.0,
+ public testarrayofstring2: (string)[] = [],
+ public testarrayofsortedstruct: (AbilityT)[] = [],
+ public flex: (number)[] = [],
+ public test5: (TestT)[] = [],
+ public vectorOfLongs: (bigint)[] = [],
+ public vectorOfDoubles: (number)[] = [],
+ public parentNamespaceTest: InParentNamespaceT|null = null,
+ public vectorOfReferrables: (ReferrableT)[] = [],
+ public singleWeakReference: bigint = BigInt('0'),
+ public vectorOfWeakReferences: (bigint)[] = [],
+ public vectorOfStrongReferrables: (ReferrableT)[] = [],
+ public coOwningReference: bigint = BigInt('0'),
+ public vectorOfCoOwningReferences: (bigint)[] = [],
+ public nonOwningReference: bigint = BigInt('0'),
+ public vectorOfNonOwningReferences: (bigint)[] = [],
+ public anyUniqueType: AnyUniqueAliases = AnyUniqueAliases.NONE,
+ public anyUnique: MonsterT|MyGame_Example2_MonsterT|TestSimpleTableWithEnumT|null = null,
+ public anyAmbiguousType: AnyAmbiguousAliases = AnyAmbiguousAliases.NONE,
+ public anyAmbiguous: MonsterT|null = null,
+ public vectorOfEnums: (Color)[] = [],
+ public signedEnum: Race = Race.None,
+ public testrequirednestedflatbuffer: (number)[] = [],
+ public scalarKeySortedTables: (StatT)[] = [],
+ public nativeInline: TestT|null = null,
+ public longEnumNonEnumDefault: bigint = BigInt('0'),
+ public longEnumNormalDefault: bigint = BigInt('2')
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ const name = (this.name !== null ? builder.createString(this.name!) : 0);
+ const inventory = Monster.createInventoryVector(builder, this.inventory);
+ const test = builder.createObjectOffset(this.test);
+ const test4 = builder.createStructOffsetList(this.test4, Monster.startTest4Vector);
+ const testarrayofstring = Monster.createTestarrayofstringVector(builder, builder.createObjectOffsetList(this.testarrayofstring));
+ const testarrayoftables = Monster.createTestarrayoftablesVector(builder, builder.createObjectOffsetList(this.testarrayoftables));
+ const enemy = (this.enemy !== null ? this.enemy!.pack(builder) : 0);
+ const testnestedflatbuffer = Monster.createTestnestedflatbufferVector(builder, this.testnestedflatbuffer);
+ const testempty = (this.testempty !== null ? this.testempty!.pack(builder) : 0);
+ const testarrayofbools = Monster.createTestarrayofboolsVector(builder, this.testarrayofbools);
+ const testarrayofstring2 = Monster.createTestarrayofstring2Vector(builder, builder.createObjectOffsetList(this.testarrayofstring2));
+ const testarrayofsortedstruct = builder.createStructOffsetList(this.testarrayofsortedstruct, Monster.startTestarrayofsortedstructVector);
+ const flex = Monster.createFlexVector(builder, this.flex);
+ const test5 = builder.createStructOffsetList(this.test5, Monster.startTest5Vector);
+ const vectorOfLongs = Monster.createVectorOfLongsVector(builder, this.vectorOfLongs);
+ const vectorOfDoubles = Monster.createVectorOfDoublesVector(builder, this.vectorOfDoubles);
+ const parentNamespaceTest = (this.parentNamespaceTest !== null ? this.parentNamespaceTest!.pack(builder) : 0);
+ const vectorOfReferrables = Monster.createVectorOfReferrablesVector(builder, builder.createObjectOffsetList(this.vectorOfReferrables));
+ const vectorOfWeakReferences = Monster.createVectorOfWeakReferencesVector(builder, this.vectorOfWeakReferences);
+ const vectorOfStrongReferrables = Monster.createVectorOfStrongReferrablesVector(builder, builder.createObjectOffsetList(this.vectorOfStrongReferrables));
+ const vectorOfCoOwningReferences = Monster.createVectorOfCoOwningReferencesVector(builder, this.vectorOfCoOwningReferences);
+ const vectorOfNonOwningReferences = Monster.createVectorOfNonOwningReferencesVector(builder, this.vectorOfNonOwningReferences);
+ const anyUnique = builder.createObjectOffset(this.anyUnique);
+ const anyAmbiguous = builder.createObjectOffset(this.anyAmbiguous);
+ const vectorOfEnums = Monster.createVectorOfEnumsVector(builder, this.vectorOfEnums);
+ const testrequirednestedflatbuffer = Monster.createTestrequirednestedflatbufferVector(builder, this.testrequirednestedflatbuffer);
+ const scalarKeySortedTables = Monster.createScalarKeySortedTablesVector(builder, builder.createObjectOffsetList(this.scalarKeySortedTables));
+
+ Monster.startMonster(builder);
+ Monster.addPos(builder, (this.pos !== null ? this.pos!.pack(builder) : 0));
+ Monster.addMana(builder, this.mana);
+ Monster.addHp(builder, this.hp);
+ Monster.addName(builder, name);
+ Monster.addInventory(builder, inventory);
+ Monster.addColor(builder, this.color);
+ Monster.addTestType(builder, this.testType);
+ Monster.addTest(builder, test);
+ Monster.addTest4(builder, test4);
+ Monster.addTestarrayofstring(builder, testarrayofstring);
+ Monster.addTestarrayoftables(builder, testarrayoftables);
+ Monster.addEnemy(builder, enemy);
+ Monster.addTestnestedflatbuffer(builder, testnestedflatbuffer);
+ Monster.addTestempty(builder, testempty);
+ Monster.addTestbool(builder, this.testbool);
+ Monster.addTesthashs32Fnv1(builder, this.testhashs32Fnv1);
+ Monster.addTesthashu32Fnv1(builder, this.testhashu32Fnv1);
+ Monster.addTesthashs64Fnv1(builder, this.testhashs64Fnv1);
+ Monster.addTesthashu64Fnv1(builder, this.testhashu64Fnv1);
+ Monster.addTesthashs32Fnv1a(builder, this.testhashs32Fnv1a);
+ Monster.addTesthashu32Fnv1a(builder, this.testhashu32Fnv1a);
+ Monster.addTesthashs64Fnv1a(builder, this.testhashs64Fnv1a);
+ Monster.addTesthashu64Fnv1a(builder, this.testhashu64Fnv1a);
+ Monster.addTestarrayofbools(builder, testarrayofbools);
+ Monster.addTestf(builder, this.testf);
+ Monster.addTestf2(builder, this.testf2);
+ Monster.addTestf3(builder, this.testf3);
+ Monster.addTestarrayofstring2(builder, testarrayofstring2);
+ Monster.addTestarrayofsortedstruct(builder, testarrayofsortedstruct);
+ Monster.addFlex(builder, flex);
+ Monster.addTest5(builder, test5);
+ Monster.addVectorOfLongs(builder, vectorOfLongs);
+ Monster.addVectorOfDoubles(builder, vectorOfDoubles);
+ Monster.addParentNamespaceTest(builder, parentNamespaceTest);
+ Monster.addVectorOfReferrables(builder, vectorOfReferrables);
+ Monster.addSingleWeakReference(builder, this.singleWeakReference);
+ Monster.addVectorOfWeakReferences(builder, vectorOfWeakReferences);
+ Monster.addVectorOfStrongReferrables(builder, vectorOfStrongReferrables);
+ Monster.addCoOwningReference(builder, this.coOwningReference);
+ Monster.addVectorOfCoOwningReferences(builder, vectorOfCoOwningReferences);
+ Monster.addNonOwningReference(builder, this.nonOwningReference);
+ Monster.addVectorOfNonOwningReferences(builder, vectorOfNonOwningReferences);
+ Monster.addAnyUniqueType(builder, this.anyUniqueType);
+ Monster.addAnyUnique(builder, anyUnique);
+ Monster.addAnyAmbiguousType(builder, this.anyAmbiguousType);
+ Monster.addAnyAmbiguous(builder, anyAmbiguous);
+ Monster.addVectorOfEnums(builder, vectorOfEnums);
+ Monster.addSignedEnum(builder, this.signedEnum);
+ Monster.addTestrequirednestedflatbuffer(builder, testrequirednestedflatbuffer);
+ Monster.addScalarKeySortedTables(builder, scalarKeySortedTables);
+ Monster.addNativeInline(builder, (this.nativeInline !== null ? this.nativeInline!.pack(builder) : 0));
+ Monster.addLongEnumNonEnumDefault(builder, this.longEnumNonEnumDefault);
+ Monster.addLongEnumNormalDefault(builder, this.longEnumNormalDefault);
+
+ return Monster.endMonster(builder);
+}
+}
diff --git a/tests/ts/my-game/example/race.js b/tests/ts/my-game/example/race.js
new file mode 100644
index 0000000..74f5105
--- /dev/null
+++ b/tests/ts/my-game/example/race.js
@@ -0,0 +1,8 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+export var Race;
+(function (Race) {
+ Race[Race["None"] = -1] = "None";
+ Race[Race["Human"] = 0] = "Human";
+ Race[Race["Dwarf"] = 1] = "Dwarf";
+ Race[Race["Elf"] = 2] = "Elf";
+})(Race || (Race = {}));
diff --git a/tests/ts/my-game/example/race.ts b/tests/ts/my-game/example/race.ts
new file mode 100644
index 0000000..8cb9654
--- /dev/null
+++ b/tests/ts/my-game/example/race.ts
@@ -0,0 +1,8 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+export enum Race {
+ None = -1,
+ Human = 0,
+ Dwarf = 1,
+ Elf = 2
+}
diff --git a/tests/ts/my-game/example/referrable.js b/tests/ts/my-game/example/referrable.js
new file mode 100644
index 0000000..367034b
--- /dev/null
+++ b/tests/ts/my-game/example/referrable.js
@@ -0,0 +1,70 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import * as flatbuffers from 'flatbuffers';
+export class Referrable {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsReferrable(bb, obj) {
+ return (obj || new Referrable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsReferrable(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Referrable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ id() {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0');
+ }
+ mutate_id(value) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint64(this.bb_pos + offset, value);
+ return true;
+ }
+ static getFullyQualifiedName() {
+ return 'MyGame_Example_Referrable';
+ }
+ static startReferrable(builder) {
+ builder.startObject(1);
+ }
+ static addId(builder, id) {
+ builder.addFieldInt64(0, id, BigInt('0'));
+ }
+ static endReferrable(builder) {
+ const offset = builder.endObject();
+ return offset;
+ }
+ static createReferrable(builder, id) {
+ Referrable.startReferrable(builder);
+ Referrable.addId(builder, id);
+ return Referrable.endReferrable(builder);
+ }
+ serialize() {
+ return this.bb.bytes();
+ }
+ static deserialize(buffer) {
+ return Referrable.getRootAsReferrable(new flatbuffers.ByteBuffer(buffer));
+ }
+ unpack() {
+ return new ReferrableT(this.id());
+ }
+ unpackTo(_o) {
+ _o.id = this.id();
+ }
+}
+export class ReferrableT {
+ constructor(id = BigInt('0')) {
+ this.id = id;
+ }
+ pack(builder) {
+ return Referrable.createReferrable(builder, this.id);
+ }
+}
diff --git a/tests/ts/my-game/example/referrable.ts b/tests/ts/my-game/example/referrable.ts
new file mode 100644
index 0000000..ec02980
--- /dev/null
+++ b/tests/ts/my-game/example/referrable.ts
@@ -0,0 +1,95 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+
+
+export class Referrable {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):Referrable {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsReferrable(bb:flatbuffers.ByteBuffer, obj?:Referrable):Referrable {
+ return (obj || new Referrable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsReferrable(bb:flatbuffers.ByteBuffer, obj?:Referrable):Referrable {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Referrable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+id():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
+}
+
+mutate_id(value:bigint):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint64(this.bb_pos + offset, value);
+ return true;
+}
+
+static getFullyQualifiedName():string {
+ return 'MyGame_Example_Referrable';
+}
+
+static startReferrable(builder:flatbuffers.Builder) {
+ builder.startObject(1);
+}
+
+static addId(builder:flatbuffers.Builder, id:bigint) {
+ builder.addFieldInt64(0, id, BigInt('0'));
+}
+
+static endReferrable(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+static createReferrable(builder:flatbuffers.Builder, id:bigint):flatbuffers.Offset {
+ Referrable.startReferrable(builder);
+ Referrable.addId(builder, id);
+ return Referrable.endReferrable(builder);
+}
+
+serialize():Uint8Array {
+ return this.bb!.bytes();
+}
+
+static deserialize(buffer: Uint8Array):Referrable {
+ return Referrable.getRootAsReferrable(new flatbuffers.ByteBuffer(buffer))
+}
+
+unpack(): ReferrableT {
+ return new ReferrableT(
+ this.id()
+ );
+}
+
+
+unpackTo(_o: ReferrableT): void {
+ _o.id = this.id();
+}
+}
+
+export class ReferrableT {
+constructor(
+ public id: bigint = BigInt('0')
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ return Referrable.createReferrable(builder,
+ this.id
+ );
+}
+}
diff --git a/tests/ts/my-game/example/stat.js b/tests/ts/my-game/example/stat.js
new file mode 100644
index 0000000..43b569f
--- /dev/null
+++ b/tests/ts/my-game/example/stat.js
@@ -0,0 +1,99 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import * as flatbuffers from 'flatbuffers';
+export class Stat {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsStat(bb, obj) {
+ return (obj || new Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsStat(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ id(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ val() {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0');
+ }
+ mutate_val(value) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt64(this.bb_pos + offset, value);
+ return true;
+ }
+ count() {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ return offset ? this.bb.readUint16(this.bb_pos + offset) : 0;
+ }
+ mutate_count(value) {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint16(this.bb_pos + offset, value);
+ return true;
+ }
+ static getFullyQualifiedName() {
+ return 'MyGame_Example_Stat';
+ }
+ static startStat(builder) {
+ builder.startObject(3);
+ }
+ static addId(builder, idOffset) {
+ builder.addFieldOffset(0, idOffset, 0);
+ }
+ static addVal(builder, val) {
+ builder.addFieldInt64(1, val, BigInt('0'));
+ }
+ static addCount(builder, count) {
+ builder.addFieldInt16(2, count, 0);
+ }
+ static endStat(builder) {
+ const offset = builder.endObject();
+ return offset;
+ }
+ static createStat(builder, idOffset, val, count) {
+ Stat.startStat(builder);
+ Stat.addId(builder, idOffset);
+ Stat.addVal(builder, val);
+ Stat.addCount(builder, count);
+ return Stat.endStat(builder);
+ }
+ serialize() {
+ return this.bb.bytes();
+ }
+ static deserialize(buffer) {
+ return Stat.getRootAsStat(new flatbuffers.ByteBuffer(buffer));
+ }
+ unpack() {
+ return new StatT(this.id(), this.val(), this.count());
+ }
+ unpackTo(_o) {
+ _o.id = this.id();
+ _o.val = this.val();
+ _o.count = this.count();
+ }
+}
+export class StatT {
+ constructor(id = null, val = BigInt('0'), count = 0) {
+ this.id = id;
+ this.val = val;
+ this.count = count;
+ }
+ pack(builder) {
+ const id = (this.id !== null ? builder.createString(this.id) : 0);
+ return Stat.createStat(builder, id, this.val, this.count);
+ }
+}
diff --git a/tests/ts/my-game/example/stat.ts b/tests/ts/my-game/example/stat.ts
new file mode 100644
index 0000000..e452599
--- /dev/null
+++ b/tests/ts/my-game/example/stat.ts
@@ -0,0 +1,138 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+
+
+export class Stat {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):Stat {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsStat(bb:flatbuffers.ByteBuffer, obj?:Stat):Stat {
+ return (obj || new Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsStat(bb:flatbuffers.ByteBuffer, obj?:Stat):Stat {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+id():string|null
+id(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+id(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+val():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
+}
+
+mutate_val(value:bigint):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt64(this.bb_pos + offset, value);
+ return true;
+}
+
+count():number {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
+}
+
+mutate_count(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint16(this.bb_pos + offset, value);
+ return true;
+}
+
+static getFullyQualifiedName():string {
+ return 'MyGame_Example_Stat';
+}
+
+static startStat(builder:flatbuffers.Builder) {
+ builder.startObject(3);
+}
+
+static addId(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(0, idOffset, 0);
+}
+
+static addVal(builder:flatbuffers.Builder, val:bigint) {
+ builder.addFieldInt64(1, val, BigInt('0'));
+}
+
+static addCount(builder:flatbuffers.Builder, count:number) {
+ builder.addFieldInt16(2, count, 0);
+}
+
+static endStat(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+static createStat(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset, val:bigint, count:number):flatbuffers.Offset {
+ Stat.startStat(builder);
+ Stat.addId(builder, idOffset);
+ Stat.addVal(builder, val);
+ Stat.addCount(builder, count);
+ return Stat.endStat(builder);
+}
+
+serialize():Uint8Array {
+ return this.bb!.bytes();
+}
+
+static deserialize(buffer: Uint8Array):Stat {
+ return Stat.getRootAsStat(new flatbuffers.ByteBuffer(buffer))
+}
+
+unpack(): StatT {
+ return new StatT(
+ this.id(),
+ this.val(),
+ this.count()
+ );
+}
+
+
+unpackTo(_o: StatT): void {
+ _o.id = this.id();
+ _o.val = this.val();
+ _o.count = this.count();
+}
+}
+
+export class StatT {
+constructor(
+ public id: string|Uint8Array|null = null,
+ public val: bigint = BigInt('0'),
+ public count: number = 0
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ const id = (this.id !== null ? builder.createString(this.id!) : 0);
+
+ return Stat.createStat(builder,
+ id,
+ this.val,
+ this.count
+ );
+}
+}
diff --git a/tests/ts/my-game/example/struct-of-structs-of-structs.js b/tests/ts/my-game/example/struct-of-structs-of-structs.js
new file mode 100644
index 0000000..a5fbc66
--- /dev/null
+++ b/tests/ts/my-game/example/struct-of-structs-of-structs.js
@@ -0,0 +1,52 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import { StructOfStructs } from '../../my-game/example/struct-of-structs.js';
+export class StructOfStructsOfStructs {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ a(obj) {
+ return (obj || new StructOfStructs()).__init(this.bb_pos, this.bb);
+ }
+ static getFullyQualifiedName() {
+ return 'MyGame_Example_StructOfStructsOfStructs';
+ }
+ static sizeOf() {
+ return 20;
+ }
+ static createStructOfStructsOfStructs(builder, a_a_id, a_a_distance, a_b_a, a_b_b, a_c_id, a_c_distance) {
+ builder.prep(4, 20);
+ builder.prep(4, 20);
+ builder.prep(4, 8);
+ builder.writeInt32(a_c_distance);
+ builder.writeInt32(a_c_id);
+ builder.prep(2, 4);
+ builder.pad(1);
+ builder.writeInt8(a_b_b);
+ builder.writeInt16(a_b_a);
+ builder.prep(4, 8);
+ builder.writeInt32(a_a_distance);
+ builder.writeInt32(a_a_id);
+ return builder.offset();
+ }
+ unpack() {
+ return new StructOfStructsOfStructsT((this.a() !== null ? this.a().unpack() : null));
+ }
+ unpackTo(_o) {
+ _o.a = (this.a() !== null ? this.a().unpack() : null);
+ }
+}
+export class StructOfStructsOfStructsT {
+ constructor(a = null) {
+ this.a = a;
+ }
+ pack(builder) {
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _p, _q, _r, _s, _t, _u;
+ return StructOfStructsOfStructs.createStructOfStructsOfStructs(builder, ((_c = (_b = (_a = this.a) === null || _a === void 0 ? void 0 : _a.a) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : 0), ((_f = (_e = (_d = this.a) === null || _d === void 0 ? void 0 : _d.a) === null || _e === void 0 ? void 0 : _e.distance) !== null && _f !== void 0 ? _f : 0), ((_j = (_h = (_g = this.a) === null || _g === void 0 ? void 0 : _g.b) === null || _h === void 0 ? void 0 : _h.a) !== null && _j !== void 0 ? _j : 0), ((_m = (_l = (_k = this.a) === null || _k === void 0 ? void 0 : _k.b) === null || _l === void 0 ? void 0 : _l.b) !== null && _m !== void 0 ? _m : 0), ((_r = (_q = (_p = this.a) === null || _p === void 0 ? void 0 : _p.c) === null || _q === void 0 ? void 0 : _q.id) !== null && _r !== void 0 ? _r : 0), ((_u = (_t = (_s = this.a) === null || _s === void 0 ? void 0 : _s.c) === null || _t === void 0 ? void 0 : _t.distance) !== null && _u !== void 0 ? _u : 0));
+ }
+}
diff --git a/tests/ts/my-game/example/struct-of-structs-of-structs.ts b/tests/ts/my-game/example/struct-of-structs-of-structs.ts
new file mode 100644
index 0000000..52efc12
--- /dev/null
+++ b/tests/ts/my-game/example/struct-of-structs-of-structs.ts
@@ -0,0 +1,74 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+import { StructOfStructs, StructOfStructsT } from '../../my-game/example/struct-of-structs.js';
+
+
+export class StructOfStructsOfStructs {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):StructOfStructsOfStructs {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+a(obj?:StructOfStructs):StructOfStructs|null {
+ return (obj || new StructOfStructs()).__init(this.bb_pos, this.bb!);
+}
+
+static getFullyQualifiedName():string {
+ return 'MyGame_Example_StructOfStructsOfStructs';
+}
+
+static sizeOf():number {
+ return 20;
+}
+
+static createStructOfStructsOfStructs(builder:flatbuffers.Builder, a_a_id: number, a_a_distance: number, a_b_a: number, a_b_b: number, a_c_id: number, a_c_distance: number):flatbuffers.Offset {
+ builder.prep(4, 20);
+ builder.prep(4, 20);
+ builder.prep(4, 8);
+ builder.writeInt32(a_c_distance);
+ builder.writeInt32(a_c_id);
+ builder.prep(2, 4);
+ builder.pad(1);
+ builder.writeInt8(a_b_b);
+ builder.writeInt16(a_b_a);
+ builder.prep(4, 8);
+ builder.writeInt32(a_a_distance);
+ builder.writeInt32(a_a_id);
+ return builder.offset();
+}
+
+
+unpack(): StructOfStructsOfStructsT {
+ return new StructOfStructsOfStructsT(
+ (this.a() !== null ? this.a()!.unpack() : null)
+ );
+}
+
+
+unpackTo(_o: StructOfStructsOfStructsT): void {
+ _o.a = (this.a() !== null ? this.a()!.unpack() : null);
+}
+}
+
+export class StructOfStructsOfStructsT {
+constructor(
+ public a: StructOfStructsT|null = null
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ return StructOfStructsOfStructs.createStructOfStructsOfStructs(builder,
+ (this.a?.a?.id ?? 0),
+ (this.a?.a?.distance ?? 0),
+ (this.a?.b?.a ?? 0),
+ (this.a?.b?.b ?? 0),
+ (this.a?.c?.id ?? 0),
+ (this.a?.c?.distance ?? 0)
+ );
+}
+}
diff --git a/tests/ts/my-game/example/struct-of-structs.js b/tests/ts/my-game/example/struct-of-structs.js
new file mode 100644
index 0000000..66aadc8
--- /dev/null
+++ b/tests/ts/my-game/example/struct-of-structs.js
@@ -0,0 +1,62 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import { Ability } from '../../my-game/example/ability.js';
+import { Test } from '../../my-game/example/test.js';
+export class StructOfStructs {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ a(obj) {
+ return (obj || new Ability()).__init(this.bb_pos, this.bb);
+ }
+ b(obj) {
+ return (obj || new Test()).__init(this.bb_pos + 8, this.bb);
+ }
+ c(obj) {
+ return (obj || new Ability()).__init(this.bb_pos + 12, this.bb);
+ }
+ static getFullyQualifiedName() {
+ return 'MyGame_Example_StructOfStructs';
+ }
+ static sizeOf() {
+ return 20;
+ }
+ static createStructOfStructs(builder, a_id, a_distance, b_a, b_b, c_id, c_distance) {
+ builder.prep(4, 20);
+ builder.prep(4, 8);
+ builder.writeInt32(c_distance);
+ builder.writeInt32(c_id);
+ builder.prep(2, 4);
+ builder.pad(1);
+ builder.writeInt8(b_b);
+ builder.writeInt16(b_a);
+ builder.prep(4, 8);
+ builder.writeInt32(a_distance);
+ builder.writeInt32(a_id);
+ return builder.offset();
+ }
+ unpack() {
+ return new StructOfStructsT((this.a() !== null ? this.a().unpack() : null), (this.b() !== null ? this.b().unpack() : null), (this.c() !== null ? this.c().unpack() : null));
+ }
+ unpackTo(_o) {
+ _o.a = (this.a() !== null ? this.a().unpack() : null);
+ _o.b = (this.b() !== null ? this.b().unpack() : null);
+ _o.c = (this.c() !== null ? this.c().unpack() : null);
+ }
+}
+export class StructOfStructsT {
+ constructor(a = null, b = null, c = null) {
+ this.a = a;
+ this.b = b;
+ this.c = c;
+ }
+ pack(builder) {
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
+ return StructOfStructs.createStructOfStructs(builder, ((_b = (_a = this.a) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : 0), ((_d = (_c = this.a) === null || _c === void 0 ? void 0 : _c.distance) !== null && _d !== void 0 ? _d : 0), ((_f = (_e = this.b) === null || _e === void 0 ? void 0 : _e.a) !== null && _f !== void 0 ? _f : 0), ((_h = (_g = this.b) === null || _g === void 0 ? void 0 : _g.b) !== null && _h !== void 0 ? _h : 0), ((_k = (_j = this.c) === null || _j === void 0 ? void 0 : _j.id) !== null && _k !== void 0 ? _k : 0), ((_m = (_l = this.c) === null || _l === void 0 ? void 0 : _l.distance) !== null && _m !== void 0 ? _m : 0));
+ }
+}
diff --git a/tests/ts/my-game/example/struct-of-structs.ts b/tests/ts/my-game/example/struct-of-structs.ts
new file mode 100644
index 0000000..749a73c
--- /dev/null
+++ b/tests/ts/my-game/example/struct-of-structs.ts
@@ -0,0 +1,88 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+import { Ability, AbilityT } from '../../my-game/example/ability.js';
+import { Test, TestT } from '../../my-game/example/test.js';
+
+
+export class StructOfStructs {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):StructOfStructs {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+a(obj?:Ability):Ability|null {
+ return (obj || new Ability()).__init(this.bb_pos, this.bb!);
+}
+
+b(obj?:Test):Test|null {
+ return (obj || new Test()).__init(this.bb_pos + 8, this.bb!);
+}
+
+c(obj?:Ability):Ability|null {
+ return (obj || new Ability()).__init(this.bb_pos + 12, this.bb!);
+}
+
+static getFullyQualifiedName():string {
+ return 'MyGame_Example_StructOfStructs';
+}
+
+static sizeOf():number {
+ return 20;
+}
+
+static createStructOfStructs(builder:flatbuffers.Builder, a_id: number, a_distance: number, b_a: number, b_b: number, c_id: number, c_distance: number):flatbuffers.Offset {
+ builder.prep(4, 20);
+ builder.prep(4, 8);
+ builder.writeInt32(c_distance);
+ builder.writeInt32(c_id);
+ builder.prep(2, 4);
+ builder.pad(1);
+ builder.writeInt8(b_b);
+ builder.writeInt16(b_a);
+ builder.prep(4, 8);
+ builder.writeInt32(a_distance);
+ builder.writeInt32(a_id);
+ return builder.offset();
+}
+
+
+unpack(): StructOfStructsT {
+ return new StructOfStructsT(
+ (this.a() !== null ? this.a()!.unpack() : null),
+ (this.b() !== null ? this.b()!.unpack() : null),
+ (this.c() !== null ? this.c()!.unpack() : null)
+ );
+}
+
+
+unpackTo(_o: StructOfStructsT): void {
+ _o.a = (this.a() !== null ? this.a()!.unpack() : null);
+ _o.b = (this.b() !== null ? this.b()!.unpack() : null);
+ _o.c = (this.c() !== null ? this.c()!.unpack() : null);
+}
+}
+
+export class StructOfStructsT {
+constructor(
+ public a: AbilityT|null = null,
+ public b: TestT|null = null,
+ public c: AbilityT|null = null
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ return StructOfStructs.createStructOfStructs(builder,
+ (this.a?.id ?? 0),
+ (this.a?.distance ?? 0),
+ (this.b?.a ?? 0),
+ (this.b?.b ?? 0),
+ (this.c?.id ?? 0),
+ (this.c?.distance ?? 0)
+ );
+}
+}
diff --git a/tests/ts/my-game/example/test-simple-table-with-enum.js b/tests/ts/my-game/example/test-simple-table-with-enum.js
new file mode 100644
index 0000000..3690fee
--- /dev/null
+++ b/tests/ts/my-game/example/test-simple-table-with-enum.js
@@ -0,0 +1,71 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import * as flatbuffers from 'flatbuffers';
+import { Color } from '../../my-game/example/color.js';
+export class TestSimpleTableWithEnum {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsTestSimpleTableWithEnum(bb, obj) {
+ return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsTestSimpleTableWithEnum(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ color() {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.readUint8(this.bb_pos + offset) : Color.Green;
+ }
+ mutate_color(value) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint8(this.bb_pos + offset, value);
+ return true;
+ }
+ static getFullyQualifiedName() {
+ return 'MyGame_Example_TestSimpleTableWithEnum';
+ }
+ static startTestSimpleTableWithEnum(builder) {
+ builder.startObject(1);
+ }
+ static addColor(builder, color) {
+ builder.addFieldInt8(0, color, Color.Green);
+ }
+ static endTestSimpleTableWithEnum(builder) {
+ const offset = builder.endObject();
+ return offset;
+ }
+ static createTestSimpleTableWithEnum(builder, color) {
+ TestSimpleTableWithEnum.startTestSimpleTableWithEnum(builder);
+ TestSimpleTableWithEnum.addColor(builder, color);
+ return TestSimpleTableWithEnum.endTestSimpleTableWithEnum(builder);
+ }
+ serialize() {
+ return this.bb.bytes();
+ }
+ static deserialize(buffer) {
+ return TestSimpleTableWithEnum.getRootAsTestSimpleTableWithEnum(new flatbuffers.ByteBuffer(buffer));
+ }
+ unpack() {
+ return new TestSimpleTableWithEnumT(this.color());
+ }
+ unpackTo(_o) {
+ _o.color = this.color();
+ }
+}
+export class TestSimpleTableWithEnumT {
+ constructor(color = Color.Green) {
+ this.color = color;
+ }
+ pack(builder) {
+ return TestSimpleTableWithEnum.createTestSimpleTableWithEnum(builder, this.color);
+ }
+}
diff --git a/tests/ts/my-game/example/test-simple-table-with-enum.ts b/tests/ts/my-game/example/test-simple-table-with-enum.ts
new file mode 100644
index 0000000..cfca00b
--- /dev/null
+++ b/tests/ts/my-game/example/test-simple-table-with-enum.ts
@@ -0,0 +1,96 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+import { Color } from '../../my-game/example/color.js';
+
+
+export class TestSimpleTableWithEnum {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):TestSimpleTableWithEnum {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsTestSimpleTableWithEnum(bb:flatbuffers.ByteBuffer, obj?:TestSimpleTableWithEnum):TestSimpleTableWithEnum {
+ return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsTestSimpleTableWithEnum(bb:flatbuffers.ByteBuffer, obj?:TestSimpleTableWithEnum):TestSimpleTableWithEnum {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+color():Color {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.readUint8(this.bb_pos + offset) : Color.Green;
+}
+
+mutate_color(value:Color):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint8(this.bb_pos + offset, value);
+ return true;
+}
+
+static getFullyQualifiedName():string {
+ return 'MyGame_Example_TestSimpleTableWithEnum';
+}
+
+static startTestSimpleTableWithEnum(builder:flatbuffers.Builder) {
+ builder.startObject(1);
+}
+
+static addColor(builder:flatbuffers.Builder, color:Color) {
+ builder.addFieldInt8(0, color, Color.Green);
+}
+
+static endTestSimpleTableWithEnum(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+static createTestSimpleTableWithEnum(builder:flatbuffers.Builder, color:Color):flatbuffers.Offset {
+ TestSimpleTableWithEnum.startTestSimpleTableWithEnum(builder);
+ TestSimpleTableWithEnum.addColor(builder, color);
+ return TestSimpleTableWithEnum.endTestSimpleTableWithEnum(builder);
+}
+
+serialize():Uint8Array {
+ return this.bb!.bytes();
+}
+
+static deserialize(buffer: Uint8Array):TestSimpleTableWithEnum {
+ return TestSimpleTableWithEnum.getRootAsTestSimpleTableWithEnum(new flatbuffers.ByteBuffer(buffer))
+}
+
+unpack(): TestSimpleTableWithEnumT {
+ return new TestSimpleTableWithEnumT(
+ this.color()
+ );
+}
+
+
+unpackTo(_o: TestSimpleTableWithEnumT): void {
+ _o.color = this.color();
+}
+}
+
+export class TestSimpleTableWithEnumT {
+constructor(
+ public color: Color = Color.Green
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ return TestSimpleTableWithEnum.createTestSimpleTableWithEnum(builder,
+ this.color
+ );
+}
+}
diff --git a/tests/ts/my-game/example/test.js b/tests/ts/my-game/example/test.js
new file mode 100644
index 0000000..9c43619
--- /dev/null
+++ b/tests/ts/my-game/example/test.js
@@ -0,0 +1,55 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+export class Test {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ a() {
+ return this.bb.readInt16(this.bb_pos);
+ }
+ mutate_a(value) {
+ this.bb.writeInt16(this.bb_pos + 0, value);
+ return true;
+ }
+ b() {
+ return this.bb.readInt8(this.bb_pos + 2);
+ }
+ mutate_b(value) {
+ this.bb.writeInt8(this.bb_pos + 2, value);
+ return true;
+ }
+ static getFullyQualifiedName() {
+ return 'MyGame_Example_Test';
+ }
+ static sizeOf() {
+ return 4;
+ }
+ static createTest(builder, a, b) {
+ builder.prep(2, 4);
+ builder.pad(1);
+ builder.writeInt8(b);
+ builder.writeInt16(a);
+ return builder.offset();
+ }
+ unpack() {
+ return new TestT(this.a(), this.b());
+ }
+ unpackTo(_o) {
+ _o.a = this.a();
+ _o.b = this.b();
+ }
+}
+export class TestT {
+ constructor(a = 0, b = 0) {
+ this.a = a;
+ this.b = b;
+ }
+ pack(builder) {
+ return Test.createTest(builder, this.a, this.b);
+ }
+}
diff --git a/tests/ts/my-game/example/test.ts b/tests/ts/my-game/example/test.ts
new file mode 100644
index 0000000..b3d84ee
--- /dev/null
+++ b/tests/ts/my-game/example/test.ts
@@ -0,0 +1,78 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+
+
+export class Test {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):Test {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+a():number {
+ return this.bb!.readInt16(this.bb_pos);
+}
+
+mutate_a(value:number):boolean {
+ this.bb!.writeInt16(this.bb_pos + 0, value);
+ return true;
+}
+
+b():number {
+ return this.bb!.readInt8(this.bb_pos + 2);
+}
+
+mutate_b(value:number):boolean {
+ this.bb!.writeInt8(this.bb_pos + 2, value);
+ return true;
+}
+
+static getFullyQualifiedName():string {
+ return 'MyGame_Example_Test';
+}
+
+static sizeOf():number {
+ return 4;
+}
+
+static createTest(builder:flatbuffers.Builder, a: number, b: number):flatbuffers.Offset {
+ builder.prep(2, 4);
+ builder.pad(1);
+ builder.writeInt8(b);
+ builder.writeInt16(a);
+ return builder.offset();
+}
+
+
+unpack(): TestT {
+ return new TestT(
+ this.a(),
+ this.b()
+ );
+}
+
+
+unpackTo(_o: TestT): void {
+ _o.a = this.a();
+ _o.b = this.b();
+}
+}
+
+export class TestT {
+constructor(
+ public a: number = 0,
+ public b: number = 0
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ return Test.createTest(builder,
+ this.a,
+ this.b
+ );
+}
+}
diff --git a/tests/ts/my-game/example/type-aliases.js b/tests/ts/my-game/example/type-aliases.js
new file mode 100644
index 0000000..a4b5f89
--- /dev/null
+++ b/tests/ts/my-game/example/type-aliases.js
@@ -0,0 +1,290 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import * as flatbuffers from 'flatbuffers';
+export class TypeAliases {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsTypeAliases(bb, obj) {
+ return (obj || new TypeAliases()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsTypeAliases(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new TypeAliases()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ i8() {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.readInt8(this.bb_pos + offset) : 0;
+ }
+ mutate_i8(value) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt8(this.bb_pos + offset, value);
+ return true;
+ }
+ u8() {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? this.bb.readUint8(this.bb_pos + offset) : 0;
+ }
+ mutate_u8(value) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint8(this.bb_pos + offset, value);
+ return true;
+ }
+ i16() {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ return offset ? this.bb.readInt16(this.bb_pos + offset) : 0;
+ }
+ mutate_i16(value) {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt16(this.bb_pos + offset, value);
+ return true;
+ }
+ u16() {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? this.bb.readUint16(this.bb_pos + offset) : 0;
+ }
+ mutate_u16(value) {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint16(this.bb_pos + offset, value);
+ return true;
+ }
+ i32() {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
+ }
+ mutate_i32(value) {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt32(this.bb_pos + offset, value);
+ return true;
+ }
+ u32() {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ return offset ? this.bb.readUint32(this.bb_pos + offset) : 0;
+ }
+ mutate_u32(value) {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint32(this.bb_pos + offset, value);
+ return true;
+ }
+ i64() {
+ const offset = this.bb.__offset(this.bb_pos, 16);
+ return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0');
+ }
+ mutate_i64(value) {
+ const offset = this.bb.__offset(this.bb_pos, 16);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt64(this.bb_pos + offset, value);
+ return true;
+ }
+ u64() {
+ const offset = this.bb.__offset(this.bb_pos, 18);
+ return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0');
+ }
+ mutate_u64(value) {
+ const offset = this.bb.__offset(this.bb_pos, 18);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint64(this.bb_pos + offset, value);
+ return true;
+ }
+ f32() {
+ const offset = this.bb.__offset(this.bb_pos, 20);
+ return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0;
+ }
+ mutate_f32(value) {
+ const offset = this.bb.__offset(this.bb_pos, 20);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeFloat32(this.bb_pos + offset, value);
+ return true;
+ }
+ f64() {
+ const offset = this.bb.__offset(this.bb_pos, 22);
+ return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0;
+ }
+ mutate_f64(value) {
+ const offset = this.bb.__offset(this.bb_pos, 22);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeFloat64(this.bb_pos + offset, value);
+ return true;
+ }
+ v8(index) {
+ const offset = this.bb.__offset(this.bb_pos, 24);
+ return offset ? this.bb.readInt8(this.bb.__vector(this.bb_pos + offset) + index) : 0;
+ }
+ v8Length() {
+ const offset = this.bb.__offset(this.bb_pos, 24);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ v8Array() {
+ const offset = this.bb.__offset(this.bb_pos, 24);
+ return offset ? new Int8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
+ }
+ vf64(index) {
+ const offset = this.bb.__offset(this.bb_pos, 26);
+ return offset ? this.bb.readFloat64(this.bb.__vector(this.bb_pos + offset) + index * 8) : 0;
+ }
+ vf64Length() {
+ const offset = this.bb.__offset(this.bb_pos, 26);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ vf64Array() {
+ const offset = this.bb.__offset(this.bb_pos, 26);
+ return offset ? new Float64Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
+ }
+ static getFullyQualifiedName() {
+ return 'MyGame_Example_TypeAliases';
+ }
+ static startTypeAliases(builder) {
+ builder.startObject(12);
+ }
+ static addI8(builder, i8) {
+ builder.addFieldInt8(0, i8, 0);
+ }
+ static addU8(builder, u8) {
+ builder.addFieldInt8(1, u8, 0);
+ }
+ static addI16(builder, i16) {
+ builder.addFieldInt16(2, i16, 0);
+ }
+ static addU16(builder, u16) {
+ builder.addFieldInt16(3, u16, 0);
+ }
+ static addI32(builder, i32) {
+ builder.addFieldInt32(4, i32, 0);
+ }
+ static addU32(builder, u32) {
+ builder.addFieldInt32(5, u32, 0);
+ }
+ static addI64(builder, i64) {
+ builder.addFieldInt64(6, i64, BigInt('0'));
+ }
+ static addU64(builder, u64) {
+ builder.addFieldInt64(7, u64, BigInt('0'));
+ }
+ static addF32(builder, f32) {
+ builder.addFieldFloat32(8, f32, 0.0);
+ }
+ static addF64(builder, f64) {
+ builder.addFieldFloat64(9, f64, 0.0);
+ }
+ static addV8(builder, v8Offset) {
+ builder.addFieldOffset(10, v8Offset, 0);
+ }
+ static createV8Vector(builder, data) {
+ builder.startVector(1, data.length, 1);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt8(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startV8Vector(builder, numElems) {
+ builder.startVector(1, numElems, 1);
+ }
+ static addVf64(builder, vf64Offset) {
+ builder.addFieldOffset(11, vf64Offset, 0);
+ }
+ static createVf64Vector(builder, data) {
+ builder.startVector(8, data.length, 8);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addFloat64(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startVf64Vector(builder, numElems) {
+ builder.startVector(8, numElems, 8);
+ }
+ static endTypeAliases(builder) {
+ const offset = builder.endObject();
+ return offset;
+ }
+ static createTypeAliases(builder, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, v8Offset, vf64Offset) {
+ TypeAliases.startTypeAliases(builder);
+ TypeAliases.addI8(builder, i8);
+ TypeAliases.addU8(builder, u8);
+ TypeAliases.addI16(builder, i16);
+ TypeAliases.addU16(builder, u16);
+ TypeAliases.addI32(builder, i32);
+ TypeAliases.addU32(builder, u32);
+ TypeAliases.addI64(builder, i64);
+ TypeAliases.addU64(builder, u64);
+ TypeAliases.addF32(builder, f32);
+ TypeAliases.addF64(builder, f64);
+ TypeAliases.addV8(builder, v8Offset);
+ TypeAliases.addVf64(builder, vf64Offset);
+ return TypeAliases.endTypeAliases(builder);
+ }
+ serialize() {
+ return this.bb.bytes();
+ }
+ static deserialize(buffer) {
+ return TypeAliases.getRootAsTypeAliases(new flatbuffers.ByteBuffer(buffer));
+ }
+ unpack() {
+ return new TypeAliasesT(this.i8(), this.u8(), this.i16(), this.u16(), this.i32(), this.u32(), this.i64(), this.u64(), this.f32(), this.f64(), this.bb.createScalarList(this.v8.bind(this), this.v8Length()), this.bb.createScalarList(this.vf64.bind(this), this.vf64Length()));
+ }
+ unpackTo(_o) {
+ _o.i8 = this.i8();
+ _o.u8 = this.u8();
+ _o.i16 = this.i16();
+ _o.u16 = this.u16();
+ _o.i32 = this.i32();
+ _o.u32 = this.u32();
+ _o.i64 = this.i64();
+ _o.u64 = this.u64();
+ _o.f32 = this.f32();
+ _o.f64 = this.f64();
+ _o.v8 = this.bb.createScalarList(this.v8.bind(this), this.v8Length());
+ _o.vf64 = this.bb.createScalarList(this.vf64.bind(this), this.vf64Length());
+ }
+}
+export class TypeAliasesT {
+ constructor(i8 = 0, u8 = 0, i16 = 0, u16 = 0, i32 = 0, u32 = 0, i64 = BigInt('0'), u64 = BigInt('0'), f32 = 0.0, f64 = 0.0, v8 = [], vf64 = []) {
+ this.i8 = i8;
+ this.u8 = u8;
+ this.i16 = i16;
+ this.u16 = u16;
+ this.i32 = i32;
+ this.u32 = u32;
+ this.i64 = i64;
+ this.u64 = u64;
+ this.f32 = f32;
+ this.f64 = f64;
+ this.v8 = v8;
+ this.vf64 = vf64;
+ }
+ pack(builder) {
+ const v8 = TypeAliases.createV8Vector(builder, this.v8);
+ const vf64 = TypeAliases.createVf64Vector(builder, this.vf64);
+ return TypeAliases.createTypeAliases(builder, this.i8, this.u8, this.i16, this.u16, this.i32, this.u32, this.i64, this.u64, this.f32, this.f64, v8, vf64);
+ }
+}
diff --git a/tests/ts/my-game/example/type-aliases.ts b/tests/ts/my-game/example/type-aliases.ts
new file mode 100644
index 0000000..805c8cf
--- /dev/null
+++ b/tests/ts/my-game/example/type-aliases.ts
@@ -0,0 +1,405 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+
+
+export class TypeAliases {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):TypeAliases {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsTypeAliases(bb:flatbuffers.ByteBuffer, obj?:TypeAliases):TypeAliases {
+ return (obj || new TypeAliases()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsTypeAliases(bb:flatbuffers.ByteBuffer, obj?:TypeAliases):TypeAliases {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new TypeAliases()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+i8():number {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.readInt8(this.bb_pos + offset) : 0;
+}
+
+mutate_i8(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt8(this.bb_pos + offset, value);
+ return true;
+}
+
+u8():number {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0;
+}
+
+mutate_u8(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint8(this.bb_pos + offset, value);
+ return true;
+}
+
+i16():number {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? this.bb!.readInt16(this.bb_pos + offset) : 0;
+}
+
+mutate_i16(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt16(this.bb_pos + offset, value);
+ return true;
+}
+
+u16():number {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
+}
+
+mutate_u16(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint16(this.bb_pos + offset, value);
+ return true;
+}
+
+i32():number {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
+}
+
+mutate_i32(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt32(this.bb_pos + offset, value);
+ return true;
+}
+
+u32():number {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0;
+}
+
+mutate_u32(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint32(this.bb_pos + offset, value);
+ return true;
+}
+
+i64():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 16);
+ return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
+}
+
+mutate_i64(value:bigint):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 16);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt64(this.bb_pos + offset, value);
+ return true;
+}
+
+u64():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 18);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
+}
+
+mutate_u64(value:bigint):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 18);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint64(this.bb_pos + offset, value);
+ return true;
+}
+
+f32():number {
+ const offset = this.bb!.__offset(this.bb_pos, 20);
+ return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
+}
+
+mutate_f32(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 20);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeFloat32(this.bb_pos + offset, value);
+ return true;
+}
+
+f64():number {
+ const offset = this.bb!.__offset(this.bb_pos, 22);
+ return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0;
+}
+
+mutate_f64(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 22);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeFloat64(this.bb_pos + offset, value);
+ return true;
+}
+
+v8(index: number):number|null {
+ const offset = this.bb!.__offset(this.bb_pos, 24);
+ return offset ? this.bb!.readInt8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
+}
+
+v8Length():number {
+ const offset = this.bb!.__offset(this.bb_pos, 24);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+v8Array():Int8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 24);
+ return offset ? new Int8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
+}
+
+vf64(index: number):number|null {
+ const offset = this.bb!.__offset(this.bb_pos, 26);
+ return offset ? this.bb!.readFloat64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : 0;
+}
+
+vf64Length():number {
+ const offset = this.bb!.__offset(this.bb_pos, 26);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+vf64Array():Float64Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 26);
+ return offset ? new Float64Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
+}
+
+static getFullyQualifiedName():string {
+ return 'MyGame_Example_TypeAliases';
+}
+
+static startTypeAliases(builder:flatbuffers.Builder) {
+ builder.startObject(12);
+}
+
+static addI8(builder:flatbuffers.Builder, i8:number) {
+ builder.addFieldInt8(0, i8, 0);
+}
+
+static addU8(builder:flatbuffers.Builder, u8:number) {
+ builder.addFieldInt8(1, u8, 0);
+}
+
+static addI16(builder:flatbuffers.Builder, i16:number) {
+ builder.addFieldInt16(2, i16, 0);
+}
+
+static addU16(builder:flatbuffers.Builder, u16:number) {
+ builder.addFieldInt16(3, u16, 0);
+}
+
+static addI32(builder:flatbuffers.Builder, i32:number) {
+ builder.addFieldInt32(4, i32, 0);
+}
+
+static addU32(builder:flatbuffers.Builder, u32:number) {
+ builder.addFieldInt32(5, u32, 0);
+}
+
+static addI64(builder:flatbuffers.Builder, i64:bigint) {
+ builder.addFieldInt64(6, i64, BigInt('0'));
+}
+
+static addU64(builder:flatbuffers.Builder, u64:bigint) {
+ builder.addFieldInt64(7, u64, BigInt('0'));
+}
+
+static addF32(builder:flatbuffers.Builder, f32:number) {
+ builder.addFieldFloat32(8, f32, 0.0);
+}
+
+static addF64(builder:flatbuffers.Builder, f64:number) {
+ builder.addFieldFloat64(9, f64, 0.0);
+}
+
+static addV8(builder:flatbuffers.Builder, v8Offset:flatbuffers.Offset) {
+ builder.addFieldOffset(10, v8Offset, 0);
+}
+
+static createV8Vector(builder:flatbuffers.Builder, data:number[]|Int8Array):flatbuffers.Offset;
+/**
+ * @deprecated This Uint8Array overload will be removed in the future.
+ */
+static createV8Vector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset;
+static createV8Vector(builder:flatbuffers.Builder, data:number[]|Int8Array|Uint8Array):flatbuffers.Offset {
+ builder.startVector(1, data.length, 1);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt8(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startV8Vector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(1, numElems, 1);
+}
+
+static addVf64(builder:flatbuffers.Builder, vf64Offset:flatbuffers.Offset) {
+ builder.addFieldOffset(11, vf64Offset, 0);
+}
+
+static createVf64Vector(builder:flatbuffers.Builder, data:number[]|Float64Array):flatbuffers.Offset;
+/**
+ * @deprecated This Uint8Array overload will be removed in the future.
+ */
+static createVf64Vector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset;
+static createVf64Vector(builder:flatbuffers.Builder, data:number[]|Float64Array|Uint8Array):flatbuffers.Offset {
+ builder.startVector(8, data.length, 8);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addFloat64(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startVf64Vector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(8, numElems, 8);
+}
+
+static endTypeAliases(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+static createTypeAliases(builder:flatbuffers.Builder, i8:number, u8:number, i16:number, u16:number, i32:number, u32:number, i64:bigint, u64:bigint, f32:number, f64:number, v8Offset:flatbuffers.Offset, vf64Offset:flatbuffers.Offset):flatbuffers.Offset {
+ TypeAliases.startTypeAliases(builder);
+ TypeAliases.addI8(builder, i8);
+ TypeAliases.addU8(builder, u8);
+ TypeAliases.addI16(builder, i16);
+ TypeAliases.addU16(builder, u16);
+ TypeAliases.addI32(builder, i32);
+ TypeAliases.addU32(builder, u32);
+ TypeAliases.addI64(builder, i64);
+ TypeAliases.addU64(builder, u64);
+ TypeAliases.addF32(builder, f32);
+ TypeAliases.addF64(builder, f64);
+ TypeAliases.addV8(builder, v8Offset);
+ TypeAliases.addVf64(builder, vf64Offset);
+ return TypeAliases.endTypeAliases(builder);
+}
+
+serialize():Uint8Array {
+ return this.bb!.bytes();
+}
+
+static deserialize(buffer: Uint8Array):TypeAliases {
+ return TypeAliases.getRootAsTypeAliases(new flatbuffers.ByteBuffer(buffer))
+}
+
+unpack(): TypeAliasesT {
+ return new TypeAliasesT(
+ this.i8(),
+ this.u8(),
+ this.i16(),
+ this.u16(),
+ this.i32(),
+ this.u32(),
+ this.i64(),
+ this.u64(),
+ this.f32(),
+ this.f64(),
+ this.bb!.createScalarList(this.v8.bind(this), this.v8Length()),
+ this.bb!.createScalarList(this.vf64.bind(this), this.vf64Length())
+ );
+}
+
+
+unpackTo(_o: TypeAliasesT): void {
+ _o.i8 = this.i8();
+ _o.u8 = this.u8();
+ _o.i16 = this.i16();
+ _o.u16 = this.u16();
+ _o.i32 = this.i32();
+ _o.u32 = this.u32();
+ _o.i64 = this.i64();
+ _o.u64 = this.u64();
+ _o.f32 = this.f32();
+ _o.f64 = this.f64();
+ _o.v8 = this.bb!.createScalarList(this.v8.bind(this), this.v8Length());
+ _o.vf64 = this.bb!.createScalarList(this.vf64.bind(this), this.vf64Length());
+}
+}
+
+export class TypeAliasesT {
+constructor(
+ public i8: number = 0,
+ public u8: number = 0,
+ public i16: number = 0,
+ public u16: number = 0,
+ public i32: number = 0,
+ public u32: number = 0,
+ public i64: bigint = BigInt('0'),
+ public u64: bigint = BigInt('0'),
+ public f32: number = 0.0,
+ public f64: number = 0.0,
+ public v8: (number)[] = [],
+ public vf64: (number)[] = []
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ const v8 = TypeAliases.createV8Vector(builder, this.v8);
+ const vf64 = TypeAliases.createVf64Vector(builder, this.vf64);
+
+ return TypeAliases.createTypeAliases(builder,
+ this.i8,
+ this.u8,
+ this.i16,
+ this.u16,
+ this.i32,
+ this.u32,
+ this.i64,
+ this.u64,
+ this.f32,
+ this.f64,
+ v8,
+ vf64
+ );
+}
+}
diff --git a/tests/ts/my-game/example/vec3.js b/tests/ts/my-game/example/vec3.js
new file mode 100644
index 0000000..cae64eb
--- /dev/null
+++ b/tests/ts/my-game/example/vec3.js
@@ -0,0 +1,98 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import { Test } from '../../my-game/example/test.js';
+export class Vec3 {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ x() {
+ return this.bb.readFloat32(this.bb_pos);
+ }
+ mutate_x(value) {
+ this.bb.writeFloat32(this.bb_pos + 0, value);
+ return true;
+ }
+ y() {
+ return this.bb.readFloat32(this.bb_pos + 4);
+ }
+ mutate_y(value) {
+ this.bb.writeFloat32(this.bb_pos + 4, value);
+ return true;
+ }
+ z() {
+ return this.bb.readFloat32(this.bb_pos + 8);
+ }
+ mutate_z(value) {
+ this.bb.writeFloat32(this.bb_pos + 8, value);
+ return true;
+ }
+ test1() {
+ return this.bb.readFloat64(this.bb_pos + 16);
+ }
+ mutate_test1(value) {
+ this.bb.writeFloat64(this.bb_pos + 16, value);
+ return true;
+ }
+ test2() {
+ return this.bb.readUint8(this.bb_pos + 24);
+ }
+ mutate_test2(value) {
+ this.bb.writeUint8(this.bb_pos + 24, value);
+ return true;
+ }
+ test3(obj) {
+ return (obj || new Test()).__init(this.bb_pos + 26, this.bb);
+ }
+ static getFullyQualifiedName() {
+ return 'MyGame_Example_Vec3';
+ }
+ static sizeOf() {
+ return 32;
+ }
+ static createVec3(builder, x, y, z, test1, test2, test3_a, test3_b) {
+ builder.prep(8, 32);
+ builder.pad(2);
+ builder.prep(2, 4);
+ builder.pad(1);
+ builder.writeInt8(test3_b);
+ builder.writeInt16(test3_a);
+ builder.pad(1);
+ builder.writeInt8(test2);
+ builder.writeFloat64(test1);
+ builder.pad(4);
+ builder.writeFloat32(z);
+ builder.writeFloat32(y);
+ builder.writeFloat32(x);
+ return builder.offset();
+ }
+ unpack() {
+ return new Vec3T(this.x(), this.y(), this.z(), this.test1(), this.test2(), (this.test3() !== null ? this.test3().unpack() : null));
+ }
+ unpackTo(_o) {
+ _o.x = this.x();
+ _o.y = this.y();
+ _o.z = this.z();
+ _o.test1 = this.test1();
+ _o.test2 = this.test2();
+ _o.test3 = (this.test3() !== null ? this.test3().unpack() : null);
+ }
+}
+export class Vec3T {
+ constructor(x = 0.0, y = 0.0, z = 0.0, test1 = 0.0, test2 = 0, test3 = null) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.test1 = test1;
+ this.test2 = test2;
+ this.test3 = test3;
+ }
+ pack(builder) {
+ var _a, _b, _c, _d;
+ return Vec3.createVec3(builder, this.x, this.y, this.z, this.test1, this.test2, ((_b = (_a = this.test3) === null || _a === void 0 ? void 0 : _a.a) !== null && _b !== void 0 ? _b : 0), ((_d = (_c = this.test3) === null || _c === void 0 ? void 0 : _c.b) !== null && _d !== void 0 ? _d : 0));
+ }
+}
diff --git a/tests/ts/my-game/example/vec3.ts b/tests/ts/my-game/example/vec3.ts
new file mode 100644
index 0000000..bc4c473
--- /dev/null
+++ b/tests/ts/my-game/example/vec3.ts
@@ -0,0 +1,137 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+import { Color } from '../../my-game/example/color.js';
+import { Test, TestT } from '../../my-game/example/test.js';
+
+
+export class Vec3 {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):Vec3 {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+x():number {
+ return this.bb!.readFloat32(this.bb_pos);
+}
+
+mutate_x(value:number):boolean {
+ this.bb!.writeFloat32(this.bb_pos + 0, value);
+ return true;
+}
+
+y():number {
+ return this.bb!.readFloat32(this.bb_pos + 4);
+}
+
+mutate_y(value:number):boolean {
+ this.bb!.writeFloat32(this.bb_pos + 4, value);
+ return true;
+}
+
+z():number {
+ return this.bb!.readFloat32(this.bb_pos + 8);
+}
+
+mutate_z(value:number):boolean {
+ this.bb!.writeFloat32(this.bb_pos + 8, value);
+ return true;
+}
+
+test1():number {
+ return this.bb!.readFloat64(this.bb_pos + 16);
+}
+
+mutate_test1(value:number):boolean {
+ this.bb!.writeFloat64(this.bb_pos + 16, value);
+ return true;
+}
+
+test2():Color {
+ return this.bb!.readUint8(this.bb_pos + 24);
+}
+
+mutate_test2(value:Color):boolean {
+ this.bb!.writeUint8(this.bb_pos + 24, value);
+ return true;
+}
+
+test3(obj?:Test):Test|null {
+ return (obj || new Test()).__init(this.bb_pos + 26, this.bb!);
+}
+
+static getFullyQualifiedName():string {
+ return 'MyGame_Example_Vec3';
+}
+
+static sizeOf():number {
+ return 32;
+}
+
+static createVec3(builder:flatbuffers.Builder, x: number, y: number, z: number, test1: number, test2: Color, test3_a: number, test3_b: number):flatbuffers.Offset {
+ builder.prep(8, 32);
+ builder.pad(2);
+ builder.prep(2, 4);
+ builder.pad(1);
+ builder.writeInt8(test3_b);
+ builder.writeInt16(test3_a);
+ builder.pad(1);
+ builder.writeInt8(test2);
+ builder.writeFloat64(test1);
+ builder.pad(4);
+ builder.writeFloat32(z);
+ builder.writeFloat32(y);
+ builder.writeFloat32(x);
+ return builder.offset();
+}
+
+
+unpack(): Vec3T {
+ return new Vec3T(
+ this.x(),
+ this.y(),
+ this.z(),
+ this.test1(),
+ this.test2(),
+ (this.test3() !== null ? this.test3()!.unpack() : null)
+ );
+}
+
+
+unpackTo(_o: Vec3T): void {
+ _o.x = this.x();
+ _o.y = this.y();
+ _o.z = this.z();
+ _o.test1 = this.test1();
+ _o.test2 = this.test2();
+ _o.test3 = (this.test3() !== null ? this.test3()!.unpack() : null);
+}
+}
+
+export class Vec3T {
+constructor(
+ public x: number = 0.0,
+ public y: number = 0.0,
+ public z: number = 0.0,
+ public test1: number = 0.0,
+ public test2: Color = 0,
+ public test3: TestT|null = null
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ return Vec3.createVec3(builder,
+ this.x,
+ this.y,
+ this.z,
+ this.test1,
+ this.test2,
+ (this.test3?.a ?? 0),
+ (this.test3?.b ?? 0)
+ );
+}
+}
diff --git a/tests/ts/my-game/example2/monster.js b/tests/ts/my-game/example2/monster.js
new file mode 100644
index 0000000..f50a2c8
--- /dev/null
+++ b/tests/ts/my-game/example2/monster.js
@@ -0,0 +1,50 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import * as flatbuffers from 'flatbuffers';
+export class Monster {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsMonster(bb, obj) {
+ return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsMonster(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getFullyQualifiedName() {
+ return 'MyGame_Example2_Monster';
+ }
+ static startMonster(builder) {
+ builder.startObject(0);
+ }
+ static endMonster(builder) {
+ const offset = builder.endObject();
+ return offset;
+ }
+ static createMonster(builder) {
+ Monster.startMonster(builder);
+ return Monster.endMonster(builder);
+ }
+ serialize() {
+ return this.bb.bytes();
+ }
+ static deserialize(buffer) {
+ return Monster.getRootAsMonster(new flatbuffers.ByteBuffer(buffer));
+ }
+ unpack() {
+ return new MonsterT();
+ }
+ unpackTo(_o) { }
+}
+export class MonsterT {
+ constructor() { }
+ pack(builder) {
+ return Monster.createMonster(builder);
+ }
+}
diff --git a/tests/ts/my-game/example2/monster.ts b/tests/ts/my-game/example2/monster.ts
new file mode 100644
index 0000000..7240476
--- /dev/null
+++ b/tests/ts/my-game/example2/monster.ts
@@ -0,0 +1,66 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+
+
+export class Monster {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):Monster {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:Monster):Monster {
+ return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:Monster):Monster {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getFullyQualifiedName():string {
+ return 'MyGame_Example2_Monster';
+}
+
+static startMonster(builder:flatbuffers.Builder) {
+ builder.startObject(0);
+}
+
+static endMonster(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+static createMonster(builder:flatbuffers.Builder):flatbuffers.Offset {
+ Monster.startMonster(builder);
+ return Monster.endMonster(builder);
+}
+
+serialize():Uint8Array {
+ return this.bb!.bytes();
+}
+
+static deserialize(buffer: Uint8Array):Monster {
+ return Monster.getRootAsMonster(new flatbuffers.ByteBuffer(buffer))
+}
+
+unpack(): MonsterT {
+ return new MonsterT();
+}
+
+
+unpackTo(_o: MonsterT): void {}
+}
+
+export class MonsterT {
+constructor(){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ return Monster.createMonster(builder);
+}
+}
diff --git a/tests/ts/my-game/in-parent-namespace.js b/tests/ts/my-game/in-parent-namespace.js
new file mode 100644
index 0000000..24b0ed7
--- /dev/null
+++ b/tests/ts/my-game/in-parent-namespace.js
@@ -0,0 +1,50 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import * as flatbuffers from 'flatbuffers';
+export class InParentNamespace {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsInParentNamespace(bb, obj) {
+ return (obj || new InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsInParentNamespace(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getFullyQualifiedName() {
+ return 'MyGame_InParentNamespace';
+ }
+ static startInParentNamespace(builder) {
+ builder.startObject(0);
+ }
+ static endInParentNamespace(builder) {
+ const offset = builder.endObject();
+ return offset;
+ }
+ static createInParentNamespace(builder) {
+ InParentNamespace.startInParentNamespace(builder);
+ return InParentNamespace.endInParentNamespace(builder);
+ }
+ serialize() {
+ return this.bb.bytes();
+ }
+ static deserialize(buffer) {
+ return InParentNamespace.getRootAsInParentNamespace(new flatbuffers.ByteBuffer(buffer));
+ }
+ unpack() {
+ return new InParentNamespaceT();
+ }
+ unpackTo(_o) { }
+}
+export class InParentNamespaceT {
+ constructor() { }
+ pack(builder) {
+ return InParentNamespace.createInParentNamespace(builder);
+ }
+}
diff --git a/tests/ts/my-game/in-parent-namespace.ts b/tests/ts/my-game/in-parent-namespace.ts
new file mode 100644
index 0000000..0de94df
--- /dev/null
+++ b/tests/ts/my-game/in-parent-namespace.ts
@@ -0,0 +1,66 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+
+
+export class InParentNamespace {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):InParentNamespace {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsInParentNamespace(bb:flatbuffers.ByteBuffer, obj?:InParentNamespace):InParentNamespace {
+ return (obj || new InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsInParentNamespace(bb:flatbuffers.ByteBuffer, obj?:InParentNamespace):InParentNamespace {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getFullyQualifiedName():string {
+ return 'MyGame_InParentNamespace';
+}
+
+static startInParentNamespace(builder:flatbuffers.Builder) {
+ builder.startObject(0);
+}
+
+static endInParentNamespace(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+static createInParentNamespace(builder:flatbuffers.Builder):flatbuffers.Offset {
+ InParentNamespace.startInParentNamespace(builder);
+ return InParentNamespace.endInParentNamespace(builder);
+}
+
+serialize():Uint8Array {
+ return this.bb!.bytes();
+}
+
+static deserialize(buffer: Uint8Array):InParentNamespace {
+ return InParentNamespace.getRootAsInParentNamespace(new flatbuffers.ByteBuffer(buffer))
+}
+
+unpack(): InParentNamespaceT {
+ return new InParentNamespaceT();
+}
+
+
+unpackTo(_o: InParentNamespaceT): void {}
+}
+
+export class InParentNamespaceT {
+constructor(){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ return InParentNamespace.createInParentNamespace(builder);
+}
+}
diff --git a/tests/ts/optional-scalars/optional-byte.ts b/tests/ts/optional-scalars/optional-byte.ts
new file mode 100644
index 0000000..f4db265
--- /dev/null
+++ b/tests/ts/optional-scalars/optional-byte.ts
@@ -0,0 +1,7 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+export enum OptionalByte {
+ None = 0,
+ One = 1,
+ Two = 2
+}
diff --git a/tests/ts/optional-scalars/scalar-stuff.ts b/tests/ts/optional-scalars/scalar-stuff.ts
new file mode 100644
index 0000000..2adf31b
--- /dev/null
+++ b/tests/ts/optional-scalars/scalar-stuff.ts
@@ -0,0 +1,427 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+import { OptionalByte } from '../optional-scalars/optional-byte.js';
+
+
+export class ScalarStuff {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):ScalarStuff {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsScalarStuff(bb:flatbuffers.ByteBuffer, obj?:ScalarStuff):ScalarStuff {
+ return (obj || new ScalarStuff()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsScalarStuff(bb:flatbuffers.ByteBuffer, obj?:ScalarStuff):ScalarStuff {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new ScalarStuff()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean {
+ return bb.__has_identifier('NULL');
+}
+
+justI8():number {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.readInt8(this.bb_pos + offset) : 0;
+}
+
+maybeI8():number|null {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.readInt8(this.bb_pos + offset) : null;
+}
+
+defaultI8():number {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? this.bb!.readInt8(this.bb_pos + offset) : 42;
+}
+
+justU8():number {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0;
+}
+
+maybeU8():number|null {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? this.bb!.readUint8(this.bb_pos + offset) : null;
+}
+
+defaultU8():number {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? this.bb!.readUint8(this.bb_pos + offset) : 42;
+}
+
+justI16():number {
+ const offset = this.bb!.__offset(this.bb_pos, 16);
+ return offset ? this.bb!.readInt16(this.bb_pos + offset) : 0;
+}
+
+maybeI16():number|null {
+ const offset = this.bb!.__offset(this.bb_pos, 18);
+ return offset ? this.bb!.readInt16(this.bb_pos + offset) : null;
+}
+
+defaultI16():number {
+ const offset = this.bb!.__offset(this.bb_pos, 20);
+ return offset ? this.bb!.readInt16(this.bb_pos + offset) : 42;
+}
+
+justU16():number {
+ const offset = this.bb!.__offset(this.bb_pos, 22);
+ return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
+}
+
+maybeU16():number|null {
+ const offset = this.bb!.__offset(this.bb_pos, 24);
+ return offset ? this.bb!.readUint16(this.bb_pos + offset) : null;
+}
+
+defaultU16():number {
+ const offset = this.bb!.__offset(this.bb_pos, 26);
+ return offset ? this.bb!.readUint16(this.bb_pos + offset) : 42;
+}
+
+justI32():number {
+ const offset = this.bb!.__offset(this.bb_pos, 28);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
+}
+
+maybeI32():number|null {
+ const offset = this.bb!.__offset(this.bb_pos, 30);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : null;
+}
+
+defaultI32():number {
+ const offset = this.bb!.__offset(this.bb_pos, 32);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : 42;
+}
+
+justU32():number {
+ const offset = this.bb!.__offset(this.bb_pos, 34);
+ return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0;
+}
+
+maybeU32():number|null {
+ const offset = this.bb!.__offset(this.bb_pos, 36);
+ return offset ? this.bb!.readUint32(this.bb_pos + offset) : null;
+}
+
+defaultU32():number {
+ const offset = this.bb!.__offset(this.bb_pos, 38);
+ return offset ? this.bb!.readUint32(this.bb_pos + offset) : 42;
+}
+
+justI64():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 40);
+ return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
+}
+
+maybeI64():bigint|null {
+ const offset = this.bb!.__offset(this.bb_pos, 42);
+ return offset ? this.bb!.readInt64(this.bb_pos + offset) : null;
+}
+
+defaultI64():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 44);
+ return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('42');
+}
+
+justU64():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 46);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
+}
+
+maybeU64():bigint|null {
+ const offset = this.bb!.__offset(this.bb_pos, 48);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : null;
+}
+
+defaultU64():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 50);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('42');
+}
+
+justF32():number {
+ const offset = this.bb!.__offset(this.bb_pos, 52);
+ return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
+}
+
+maybeF32():number|null {
+ const offset = this.bb!.__offset(this.bb_pos, 54);
+ return offset ? this.bb!.readFloat32(this.bb_pos + offset) : null;
+}
+
+defaultF32():number {
+ const offset = this.bb!.__offset(this.bb_pos, 56);
+ return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 42.0;
+}
+
+justF64():number {
+ const offset = this.bb!.__offset(this.bb_pos, 58);
+ return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0;
+}
+
+maybeF64():number|null {
+ const offset = this.bb!.__offset(this.bb_pos, 60);
+ return offset ? this.bb!.readFloat64(this.bb_pos + offset) : null;
+}
+
+defaultF64():number {
+ const offset = this.bb!.__offset(this.bb_pos, 62);
+ return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 42.0;
+}
+
+justBool():boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 64);
+ return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
+}
+
+maybeBool():boolean|null {
+ const offset = this.bb!.__offset(this.bb_pos, 66);
+ return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : null;
+}
+
+defaultBool():boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 68);
+ return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : true;
+}
+
+justEnum():OptionalByte {
+ const offset = this.bb!.__offset(this.bb_pos, 70);
+ return offset ? this.bb!.readInt8(this.bb_pos + offset) : OptionalByte.None;
+}
+
+maybeEnum():OptionalByte|null {
+ const offset = this.bb!.__offset(this.bb_pos, 72);
+ return offset ? this.bb!.readInt8(this.bb_pos + offset) : null;
+}
+
+defaultEnum():OptionalByte {
+ const offset = this.bb!.__offset(this.bb_pos, 74);
+ return offset ? this.bb!.readInt8(this.bb_pos + offset) : OptionalByte.One;
+}
+
+static getFullyQualifiedName():string {
+ return 'optional_scalars_ScalarStuff';
+}
+
+static startScalarStuff(builder:flatbuffers.Builder) {
+ builder.startObject(36);
+}
+
+static addJustI8(builder:flatbuffers.Builder, justI8:number) {
+ builder.addFieldInt8(0, justI8, 0);
+}
+
+static addMaybeI8(builder:flatbuffers.Builder, maybeI8:number) {
+ builder.addFieldInt8(1, maybeI8, 0);
+}
+
+static addDefaultI8(builder:flatbuffers.Builder, defaultI8:number) {
+ builder.addFieldInt8(2, defaultI8, 42);
+}
+
+static addJustU8(builder:flatbuffers.Builder, justU8:number) {
+ builder.addFieldInt8(3, justU8, 0);
+}
+
+static addMaybeU8(builder:flatbuffers.Builder, maybeU8:number) {
+ builder.addFieldInt8(4, maybeU8, 0);
+}
+
+static addDefaultU8(builder:flatbuffers.Builder, defaultU8:number) {
+ builder.addFieldInt8(5, defaultU8, 42);
+}
+
+static addJustI16(builder:flatbuffers.Builder, justI16:number) {
+ builder.addFieldInt16(6, justI16, 0);
+}
+
+static addMaybeI16(builder:flatbuffers.Builder, maybeI16:number) {
+ builder.addFieldInt16(7, maybeI16, 0);
+}
+
+static addDefaultI16(builder:flatbuffers.Builder, defaultI16:number) {
+ builder.addFieldInt16(8, defaultI16, 42);
+}
+
+static addJustU16(builder:flatbuffers.Builder, justU16:number) {
+ builder.addFieldInt16(9, justU16, 0);
+}
+
+static addMaybeU16(builder:flatbuffers.Builder, maybeU16:number) {
+ builder.addFieldInt16(10, maybeU16, 0);
+}
+
+static addDefaultU16(builder:flatbuffers.Builder, defaultU16:number) {
+ builder.addFieldInt16(11, defaultU16, 42);
+}
+
+static addJustI32(builder:flatbuffers.Builder, justI32:number) {
+ builder.addFieldInt32(12, justI32, 0);
+}
+
+static addMaybeI32(builder:flatbuffers.Builder, maybeI32:number) {
+ builder.addFieldInt32(13, maybeI32, 0);
+}
+
+static addDefaultI32(builder:flatbuffers.Builder, defaultI32:number) {
+ builder.addFieldInt32(14, defaultI32, 42);
+}
+
+static addJustU32(builder:flatbuffers.Builder, justU32:number) {
+ builder.addFieldInt32(15, justU32, 0);
+}
+
+static addMaybeU32(builder:flatbuffers.Builder, maybeU32:number) {
+ builder.addFieldInt32(16, maybeU32, 0);
+}
+
+static addDefaultU32(builder:flatbuffers.Builder, defaultU32:number) {
+ builder.addFieldInt32(17, defaultU32, 42);
+}
+
+static addJustI64(builder:flatbuffers.Builder, justI64:bigint) {
+ builder.addFieldInt64(18, justI64, BigInt('0'));
+}
+
+static addMaybeI64(builder:flatbuffers.Builder, maybeI64:bigint) {
+ builder.addFieldInt64(19, maybeI64, BigInt(0));
+}
+
+static addDefaultI64(builder:flatbuffers.Builder, defaultI64:bigint) {
+ builder.addFieldInt64(20, defaultI64, BigInt('42'));
+}
+
+static addJustU64(builder:flatbuffers.Builder, justU64:bigint) {
+ builder.addFieldInt64(21, justU64, BigInt('0'));
+}
+
+static addMaybeU64(builder:flatbuffers.Builder, maybeU64:bigint) {
+ builder.addFieldInt64(22, maybeU64, BigInt(0));
+}
+
+static addDefaultU64(builder:flatbuffers.Builder, defaultU64:bigint) {
+ builder.addFieldInt64(23, defaultU64, BigInt('42'));
+}
+
+static addJustF32(builder:flatbuffers.Builder, justF32:number) {
+ builder.addFieldFloat32(24, justF32, 0.0);
+}
+
+static addMaybeF32(builder:flatbuffers.Builder, maybeF32:number) {
+ builder.addFieldFloat32(25, maybeF32, 0);
+}
+
+static addDefaultF32(builder:flatbuffers.Builder, defaultF32:number) {
+ builder.addFieldFloat32(26, defaultF32, 42.0);
+}
+
+static addJustF64(builder:flatbuffers.Builder, justF64:number) {
+ builder.addFieldFloat64(27, justF64, 0.0);
+}
+
+static addMaybeF64(builder:flatbuffers.Builder, maybeF64:number) {
+ builder.addFieldFloat64(28, maybeF64, 0);
+}
+
+static addDefaultF64(builder:flatbuffers.Builder, defaultF64:number) {
+ builder.addFieldFloat64(29, defaultF64, 42.0);
+}
+
+static addJustBool(builder:flatbuffers.Builder, justBool:boolean) {
+ builder.addFieldInt8(30, +justBool, +false);
+}
+
+static addMaybeBool(builder:flatbuffers.Builder, maybeBool:boolean) {
+ builder.addFieldInt8(31, +maybeBool, 0);
+}
+
+static addDefaultBool(builder:flatbuffers.Builder, defaultBool:boolean) {
+ builder.addFieldInt8(32, +defaultBool, +true);
+}
+
+static addJustEnum(builder:flatbuffers.Builder, justEnum:OptionalByte) {
+ builder.addFieldInt8(33, justEnum, OptionalByte.None);
+}
+
+static addMaybeEnum(builder:flatbuffers.Builder, maybeEnum:OptionalByte) {
+ builder.addFieldInt8(34, maybeEnum, 0);
+}
+
+static addDefaultEnum(builder:flatbuffers.Builder, defaultEnum:OptionalByte) {
+ builder.addFieldInt8(35, defaultEnum, OptionalByte.One);
+}
+
+static endScalarStuff(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+static finishScalarStuffBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
+ builder.finish(offset, 'NULL');
+}
+
+static finishSizePrefixedScalarStuffBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
+ builder.finish(offset, 'NULL', true);
+}
+
+static createScalarStuff(builder:flatbuffers.Builder, justI8:number, maybeI8:number|null, defaultI8:number, justU8:number, maybeU8:number|null, defaultU8:number, justI16:number, maybeI16:number|null, defaultI16:number, justU16:number, maybeU16:number|null, defaultU16:number, justI32:number, maybeI32:number|null, defaultI32:number, justU32:number, maybeU32:number|null, defaultU32:number, justI64:bigint, maybeI64:bigint|null, defaultI64:bigint, justU64:bigint, maybeU64:bigint|null, defaultU64:bigint, justF32:number, maybeF32:number|null, defaultF32:number, justF64:number, maybeF64:number|null, defaultF64:number, justBool:boolean, maybeBool:boolean|null, defaultBool:boolean, justEnum:OptionalByte, maybeEnum:OptionalByte|null, defaultEnum:OptionalByte):flatbuffers.Offset {
+ ScalarStuff.startScalarStuff(builder);
+ ScalarStuff.addJustI8(builder, justI8);
+ if (maybeI8 !== null)
+ ScalarStuff.addMaybeI8(builder, maybeI8);
+ ScalarStuff.addDefaultI8(builder, defaultI8);
+ ScalarStuff.addJustU8(builder, justU8);
+ if (maybeU8 !== null)
+ ScalarStuff.addMaybeU8(builder, maybeU8);
+ ScalarStuff.addDefaultU8(builder, defaultU8);
+ ScalarStuff.addJustI16(builder, justI16);
+ if (maybeI16 !== null)
+ ScalarStuff.addMaybeI16(builder, maybeI16);
+ ScalarStuff.addDefaultI16(builder, defaultI16);
+ ScalarStuff.addJustU16(builder, justU16);
+ if (maybeU16 !== null)
+ ScalarStuff.addMaybeU16(builder, maybeU16);
+ ScalarStuff.addDefaultU16(builder, defaultU16);
+ ScalarStuff.addJustI32(builder, justI32);
+ if (maybeI32 !== null)
+ ScalarStuff.addMaybeI32(builder, maybeI32);
+ ScalarStuff.addDefaultI32(builder, defaultI32);
+ ScalarStuff.addJustU32(builder, justU32);
+ if (maybeU32 !== null)
+ ScalarStuff.addMaybeU32(builder, maybeU32);
+ ScalarStuff.addDefaultU32(builder, defaultU32);
+ ScalarStuff.addJustI64(builder, justI64);
+ if (maybeI64 !== null)
+ ScalarStuff.addMaybeI64(builder, maybeI64);
+ ScalarStuff.addDefaultI64(builder, defaultI64);
+ ScalarStuff.addJustU64(builder, justU64);
+ if (maybeU64 !== null)
+ ScalarStuff.addMaybeU64(builder, maybeU64);
+ ScalarStuff.addDefaultU64(builder, defaultU64);
+ ScalarStuff.addJustF32(builder, justF32);
+ if (maybeF32 !== null)
+ ScalarStuff.addMaybeF32(builder, maybeF32);
+ ScalarStuff.addDefaultF32(builder, defaultF32);
+ ScalarStuff.addJustF64(builder, justF64);
+ if (maybeF64 !== null)
+ ScalarStuff.addMaybeF64(builder, maybeF64);
+ ScalarStuff.addDefaultF64(builder, defaultF64);
+ ScalarStuff.addJustBool(builder, justBool);
+ if (maybeBool !== null)
+ ScalarStuff.addMaybeBool(builder, maybeBool);
+ ScalarStuff.addDefaultBool(builder, defaultBool);
+ ScalarStuff.addJustEnum(builder, justEnum);
+ if (maybeEnum !== null)
+ ScalarStuff.addMaybeEnum(builder, maybeEnum);
+ ScalarStuff.addDefaultEnum(builder, defaultEnum);
+ return ScalarStuff.endScalarStuff(builder);
+}
+}
diff --git a/tests/optional_scalars.ts b/tests/ts/optional_scalars.ts
similarity index 100%
rename from tests/optional_scalars.ts
rename to tests/ts/optional_scalars.ts
diff --git a/tests/ts/optional_scalars_generated.ts b/tests/ts/optional_scalars_generated.ts
new file mode 100644
index 0000000..ebd3350
--- /dev/null
+++ b/tests/ts/optional_scalars_generated.ts
@@ -0,0 +1,4 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+export { OptionalByte } from './optional-scalars/optional-byte.js';
+export { ScalarStuff } from './optional-scalars/scalar-stuff.js';
diff --git a/tests/ts/package.json b/tests/ts/package.json
new file mode 100644
index 0000000..ac2639e
--- /dev/null
+++ b/tests/ts/package.json
@@ -0,0 +1,7 @@
+{
+ "type": "module",
+ "dependencies": {
+ "@grpc/grpc-js": "^1.7.0",
+ "flatbuffers": "../../"
+ }
+}
diff --git a/tests/ts/reflection/advanced-features.ts b/tests/ts/reflection/advanced-features.ts
new file mode 100644
index 0000000..dd3b865
--- /dev/null
+++ b/tests/ts/reflection/advanced-features.ts
@@ -0,0 +1,11 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+/**
+ * New schema language features that are not supported by old code generators.
+ */
+export enum AdvancedFeatures {
+ AdvancedArrayFeatures = '1',
+ AdvancedUnionFeatures = '2',
+ OptionalScalars = '4',
+ DefaultVectorsAndStrings = '8'
+}
diff --git a/tests/ts/reflection/base-type.js b/tests/ts/reflection/base-type.js
new file mode 100644
index 0000000..dccd0ac
--- /dev/null
+++ b/tests/ts/reflection/base-type.js
@@ -0,0 +1,23 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+export var BaseType;
+(function (BaseType) {
+ BaseType[BaseType["None"] = 0] = "None";
+ BaseType[BaseType["UType"] = 1] = "UType";
+ BaseType[BaseType["Bool"] = 2] = "Bool";
+ BaseType[BaseType["Byte"] = 3] = "Byte";
+ BaseType[BaseType["UByte"] = 4] = "UByte";
+ BaseType[BaseType["Short"] = 5] = "Short";
+ BaseType[BaseType["UShort"] = 6] = "UShort";
+ BaseType[BaseType["Int"] = 7] = "Int";
+ BaseType[BaseType["UInt"] = 8] = "UInt";
+ BaseType[BaseType["Long"] = 9] = "Long";
+ BaseType[BaseType["ULong"] = 10] = "ULong";
+ BaseType[BaseType["Float"] = 11] = "Float";
+ BaseType[BaseType["Double"] = 12] = "Double";
+ BaseType[BaseType["String"] = 13] = "String";
+ BaseType[BaseType["Vector"] = 14] = "Vector";
+ BaseType[BaseType["Obj"] = 15] = "Obj";
+ BaseType[BaseType["Union"] = 16] = "Union";
+ BaseType[BaseType["Array"] = 17] = "Array";
+ BaseType[BaseType["MaxBaseType"] = 18] = "MaxBaseType";
+})(BaseType || (BaseType = {}));
diff --git a/tests/ts/reflection/base-type.ts b/tests/ts/reflection/base-type.ts
new file mode 100644
index 0000000..7ee98ed
--- /dev/null
+++ b/tests/ts/reflection/base-type.ts
@@ -0,0 +1,23 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+export enum BaseType {
+ None = 0,
+ UType = 1,
+ Bool = 2,
+ Byte = 3,
+ UByte = 4,
+ Short = 5,
+ UShort = 6,
+ Int = 7,
+ UInt = 8,
+ Long = 9,
+ ULong = 10,
+ Float = 11,
+ Double = 12,
+ String = 13,
+ Vector = 14,
+ Obj = 15,
+ Union = 16,
+ Array = 17,
+ MaxBaseType = 18
+}
diff --git a/tests/ts/reflection/enum-val.js b/tests/ts/reflection/enum-val.js
new file mode 100644
index 0000000..f2ce03d
--- /dev/null
+++ b/tests/ts/reflection/enum-val.js
@@ -0,0 +1,110 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import * as flatbuffers from 'flatbuffers';
+import { Type } from '../reflection/type.js';
+export class EnumVal {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsEnumVal(bb, obj) {
+ return (obj || new EnumVal()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsEnumVal(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new EnumVal()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ name(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ value() {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0');
+ }
+ mutate_value(value) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt64(this.bb_pos + offset, value);
+ return true;
+ }
+ unionType(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? (obj || new Type()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
+ }
+ documentation(index, optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+ }
+ documentationLength() {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ static getFullyQualifiedName() {
+ return 'reflection_EnumVal';
+ }
+ static startEnumVal(builder) {
+ builder.startObject(5);
+ }
+ static addName(builder, nameOffset) {
+ builder.addFieldOffset(0, nameOffset, 0);
+ }
+ static addValue(builder, value) {
+ builder.addFieldInt64(1, value, BigInt('0'));
+ }
+ static addUnionType(builder, unionTypeOffset) {
+ builder.addFieldOffset(3, unionTypeOffset, 0);
+ }
+ static addDocumentation(builder, documentationOffset) {
+ builder.addFieldOffset(4, documentationOffset, 0);
+ }
+ static createDocumentationVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startDocumentationVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static endEnumVal(builder) {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4); // name
+ return offset;
+ }
+ unpack() {
+ return new EnumValT(this.name(), this.value(), (this.unionType() !== null ? this.unionType().unpack() : null), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()));
+ }
+ unpackTo(_o) {
+ _o.name = this.name();
+ _o.value = this.value();
+ _o.unionType = (this.unionType() !== null ? this.unionType().unpack() : null);
+ _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength());
+ }
+}
+export class EnumValT {
+ constructor(name = null, value = BigInt('0'), unionType = null, documentation = []) {
+ this.name = name;
+ this.value = value;
+ this.unionType = unionType;
+ this.documentation = documentation;
+ }
+ pack(builder) {
+ const name = (this.name !== null ? builder.createString(this.name) : 0);
+ const unionType = (this.unionType !== null ? this.unionType.pack(builder) : 0);
+ const documentation = EnumVal.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation));
+ EnumVal.startEnumVal(builder);
+ EnumVal.addName(builder, name);
+ EnumVal.addValue(builder, this.value);
+ EnumVal.addUnionType(builder, unionType);
+ EnumVal.addDocumentation(builder, documentation);
+ return EnumVal.endEnumVal(builder);
+ }
+}
diff --git a/tests/ts/reflection/enum-val.ts b/tests/ts/reflection/enum-val.ts
new file mode 100644
index 0000000..8527832
--- /dev/null
+++ b/tests/ts/reflection/enum-val.ts
@@ -0,0 +1,149 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+import { Type, TypeT } from '../reflection/type.js';
+
+
+export class EnumVal {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):EnumVal {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsEnumVal(bb:flatbuffers.ByteBuffer, obj?:EnumVal):EnumVal {
+ return (obj || new EnumVal()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsEnumVal(bb:flatbuffers.ByteBuffer, obj?:EnumVal):EnumVal {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new EnumVal()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+name():string|null
+name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+name(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+value():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
+}
+
+mutate_value(value:bigint):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt64(this.bb_pos + offset, value);
+ return true;
+}
+
+unionType(obj?:Type):Type|null {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? (obj || new Type()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
+}
+
+documentation(index: number):string
+documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array
+documentation(index: number,optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+}
+
+documentationLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+static getFullyQualifiedName():string {
+ return 'reflection_EnumVal';
+}
+
+static startEnumVal(builder:flatbuffers.Builder) {
+ builder.startObject(5);
+}
+
+static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(0, nameOffset, 0);
+}
+
+static addValue(builder:flatbuffers.Builder, value:bigint) {
+ builder.addFieldInt64(1, value, BigInt('0'));
+}
+
+static addUnionType(builder:flatbuffers.Builder, unionTypeOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(3, unionTypeOffset, 0);
+}
+
+static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(4, documentationOffset, 0);
+}
+
+static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static endEnumVal(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4) // name
+ return offset;
+}
+
+
+unpack(): EnumValT {
+ return new EnumValT(
+ this.name(),
+ this.value(),
+ (this.unionType() !== null ? this.unionType()!.unpack() : null),
+ this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength())
+ );
+}
+
+
+unpackTo(_o: EnumValT): void {
+ _o.name = this.name();
+ _o.value = this.value();
+ _o.unionType = (this.unionType() !== null ? this.unionType()!.unpack() : null);
+ _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength());
+}
+}
+
+export class EnumValT {
+constructor(
+ public name: string|Uint8Array|null = null,
+ public value: bigint = BigInt('0'),
+ public unionType: TypeT|null = null,
+ public documentation: (string)[] = []
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ const name = (this.name !== null ? builder.createString(this.name!) : 0);
+ const unionType = (this.unionType !== null ? this.unionType!.pack(builder) : 0);
+ const documentation = EnumVal.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation));
+
+ EnumVal.startEnumVal(builder);
+ EnumVal.addName(builder, name);
+ EnumVal.addValue(builder, this.value);
+ EnumVal.addUnionType(builder, unionType);
+ EnumVal.addDocumentation(builder, documentation);
+
+ return EnumVal.endEnumVal(builder);
+}
+}
diff --git a/tests/ts/reflection/enum.js b/tests/ts/reflection/enum.js
new file mode 100644
index 0000000..4939307
--- /dev/null
+++ b/tests/ts/reflection/enum.js
@@ -0,0 +1,175 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import * as flatbuffers from 'flatbuffers';
+import { EnumVal } from '../reflection/enum-val.js';
+import { KeyValue } from '../reflection/key-value.js';
+import { Type } from '../reflection/type.js';
+export class Enum {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsEnum(bb, obj) {
+ return (obj || new Enum()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsEnum(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Enum()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ name(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ values(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? (obj || new EnumVal()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ valuesLength() {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ isUnion() {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;
+ }
+ mutate_is_union(value) {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt8(this.bb_pos + offset, +value);
+ return true;
+ }
+ underlyingType(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? (obj || new Type()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
+ }
+ attributes(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ attributesLength() {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ documentation(index, optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+ }
+ documentationLength() {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ declarationFile(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 16);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ static getFullyQualifiedName() {
+ return 'reflection_Enum';
+ }
+ static startEnum(builder) {
+ builder.startObject(7);
+ }
+ static addName(builder, nameOffset) {
+ builder.addFieldOffset(0, nameOffset, 0);
+ }
+ static addValues(builder, valuesOffset) {
+ builder.addFieldOffset(1, valuesOffset, 0);
+ }
+ static createValuesVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startValuesVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addIsUnion(builder, isUnion) {
+ builder.addFieldInt8(2, +isUnion, +false);
+ }
+ static addUnderlyingType(builder, underlyingTypeOffset) {
+ builder.addFieldOffset(3, underlyingTypeOffset, 0);
+ }
+ static addAttributes(builder, attributesOffset) {
+ builder.addFieldOffset(4, attributesOffset, 0);
+ }
+ static createAttributesVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startAttributesVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addDocumentation(builder, documentationOffset) {
+ builder.addFieldOffset(5, documentationOffset, 0);
+ }
+ static createDocumentationVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startDocumentationVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addDeclarationFile(builder, declarationFileOffset) {
+ builder.addFieldOffset(6, declarationFileOffset, 0);
+ }
+ static endEnum(builder) {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4); // name
+ builder.requiredField(offset, 6); // values
+ builder.requiredField(offset, 10); // underlying_type
+ return offset;
+ }
+ unpack() {
+ return new EnumT(this.name(), this.bb.createObjList(this.values.bind(this), this.valuesLength()), this.isUnion(), (this.underlyingType() !== null ? this.underlyingType().unpack() : null), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.declarationFile());
+ }
+ unpackTo(_o) {
+ _o.name = this.name();
+ _o.values = this.bb.createObjList(this.values.bind(this), this.valuesLength());
+ _o.isUnion = this.isUnion();
+ _o.underlyingType = (this.underlyingType() !== null ? this.underlyingType().unpack() : null);
+ _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength());
+ _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength());
+ _o.declarationFile = this.declarationFile();
+ }
+}
+export class EnumT {
+ constructor(name = null, values = [], isUnion = false, underlyingType = null, attributes = [], documentation = [], declarationFile = null) {
+ this.name = name;
+ this.values = values;
+ this.isUnion = isUnion;
+ this.underlyingType = underlyingType;
+ this.attributes = attributes;
+ this.documentation = documentation;
+ this.declarationFile = declarationFile;
+ }
+ pack(builder) {
+ const name = (this.name !== null ? builder.createString(this.name) : 0);
+ const values = Enum.createValuesVector(builder, builder.createObjectOffsetList(this.values));
+ const underlyingType = (this.underlyingType !== null ? this.underlyingType.pack(builder) : 0);
+ const attributes = Enum.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes));
+ const documentation = Enum.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation));
+ const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile) : 0);
+ Enum.startEnum(builder);
+ Enum.addName(builder, name);
+ Enum.addValues(builder, values);
+ Enum.addIsUnion(builder, this.isUnion);
+ Enum.addUnderlyingType(builder, underlyingType);
+ Enum.addAttributes(builder, attributes);
+ Enum.addDocumentation(builder, documentation);
+ Enum.addDeclarationFile(builder, declarationFile);
+ return Enum.endEnum(builder);
+ }
+}
diff --git a/tests/ts/reflection/enum.ts b/tests/ts/reflection/enum.ts
new file mode 100644
index 0000000..7bba354
--- /dev/null
+++ b/tests/ts/reflection/enum.ts
@@ -0,0 +1,234 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+import { EnumVal, EnumValT } from '../reflection/enum-val.js';
+import { KeyValue, KeyValueT } from '../reflection/key-value.js';
+import { Type, TypeT } from '../reflection/type.js';
+
+
+export class Enum {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):Enum {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsEnum(bb:flatbuffers.ByteBuffer, obj?:Enum):Enum {
+ return (obj || new Enum()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsEnum(bb:flatbuffers.ByteBuffer, obj?:Enum):Enum {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Enum()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+name():string|null
+name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+name(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+values(index: number, obj?:EnumVal):EnumVal|null {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? (obj || new EnumVal()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+valuesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+isUnion():boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
+}
+
+mutate_is_union(value:boolean):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt8(this.bb_pos + offset, +value);
+ return true;
+}
+
+underlyingType(obj?:Type):Type|null {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? (obj || new Type()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
+}
+
+attributes(index: number, obj?:KeyValue):KeyValue|null {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? (obj || new KeyValue()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+attributesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+documentation(index: number):string
+documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array
+documentation(index: number,optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+}
+
+documentationLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+/**
+ * File that this Enum is declared in.
+ */
+declarationFile():string|null
+declarationFile(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+declarationFile(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 16);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+static getFullyQualifiedName():string {
+ return 'reflection_Enum';
+}
+
+static startEnum(builder:flatbuffers.Builder) {
+ builder.startObject(7);
+}
+
+static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(0, nameOffset, 0);
+}
+
+static addValues(builder:flatbuffers.Builder, valuesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(1, valuesOffset, 0);
+}
+
+static createValuesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startValuesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addIsUnion(builder:flatbuffers.Builder, isUnion:boolean) {
+ builder.addFieldInt8(2, +isUnion, +false);
+}
+
+static addUnderlyingType(builder:flatbuffers.Builder, underlyingTypeOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(3, underlyingTypeOffset, 0);
+}
+
+static addAttributes(builder:flatbuffers.Builder, attributesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(4, attributesOffset, 0);
+}
+
+static createAttributesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startAttributesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(5, documentationOffset, 0);
+}
+
+static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addDeclarationFile(builder:flatbuffers.Builder, declarationFileOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(6, declarationFileOffset, 0);
+}
+
+static endEnum(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4) // name
+ builder.requiredField(offset, 6) // values
+ builder.requiredField(offset, 10) // underlying_type
+ return offset;
+}
+
+
+unpack(): EnumT {
+ return new EnumT(
+ this.name(),
+ this.bb!.createObjList(this.values.bind(this), this.valuesLength()),
+ this.isUnion(),
+ (this.underlyingType() !== null ? this.underlyingType()!.unpack() : null),
+ this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()),
+ this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()),
+ this.declarationFile()
+ );
+}
+
+
+unpackTo(_o: EnumT): void {
+ _o.name = this.name();
+ _o.values = this.bb!.createObjList(this.values.bind(this), this.valuesLength());
+ _o.isUnion = this.isUnion();
+ _o.underlyingType = (this.underlyingType() !== null ? this.underlyingType()!.unpack() : null);
+ _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength());
+ _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength());
+ _o.declarationFile = this.declarationFile();
+}
+}
+
+export class EnumT {
+constructor(
+ public name: string|Uint8Array|null = null,
+ public values: (EnumValT)[] = [],
+ public isUnion: boolean = false,
+ public underlyingType: TypeT|null = null,
+ public attributes: (KeyValueT)[] = [],
+ public documentation: (string)[] = [],
+ public declarationFile: string|Uint8Array|null = null
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ const name = (this.name !== null ? builder.createString(this.name!) : 0);
+ const values = Enum.createValuesVector(builder, builder.createObjectOffsetList(this.values));
+ const underlyingType = (this.underlyingType !== null ? this.underlyingType!.pack(builder) : 0);
+ const attributes = Enum.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes));
+ const documentation = Enum.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation));
+ const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile!) : 0);
+
+ Enum.startEnum(builder);
+ Enum.addName(builder, name);
+ Enum.addValues(builder, values);
+ Enum.addIsUnion(builder, this.isUnion);
+ Enum.addUnderlyingType(builder, underlyingType);
+ Enum.addAttributes(builder, attributes);
+ Enum.addDocumentation(builder, documentation);
+ Enum.addDeclarationFile(builder, declarationFile);
+
+ return Enum.endEnum(builder);
+}
+}
diff --git a/tests/ts/reflection/field.js b/tests/ts/reflection/field.js
new file mode 100644
index 0000000..107b77b
--- /dev/null
+++ b/tests/ts/reflection/field.js
@@ -0,0 +1,284 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import * as flatbuffers from 'flatbuffers';
+import { KeyValue } from '../reflection/key-value.js';
+import { Type } from '../reflection/type.js';
+export class Field {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsField(bb, obj) {
+ return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsField(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ name(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ type(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? (obj || new Type()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
+ }
+ id() {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ return offset ? this.bb.readUint16(this.bb_pos + offset) : 0;
+ }
+ mutate_id(value) {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint16(this.bb_pos + offset, value);
+ return true;
+ }
+ offset() {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? this.bb.readUint16(this.bb_pos + offset) : 0;
+ }
+ mutate_offset(value) {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint16(this.bb_pos + offset, value);
+ return true;
+ }
+ defaultInteger() {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0');
+ }
+ mutate_default_integer(value) {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt64(this.bb_pos + offset, value);
+ return true;
+ }
+ defaultReal() {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0;
+ }
+ mutate_default_real(value) {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeFloat64(this.bb_pos + offset, value);
+ return true;
+ }
+ deprecated() {
+ const offset = this.bb.__offset(this.bb_pos, 16);
+ return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;
+ }
+ mutate_deprecated(value) {
+ const offset = this.bb.__offset(this.bb_pos, 16);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt8(this.bb_pos + offset, +value);
+ return true;
+ }
+ required() {
+ const offset = this.bb.__offset(this.bb_pos, 18);
+ return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;
+ }
+ mutate_required(value) {
+ const offset = this.bb.__offset(this.bb_pos, 18);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt8(this.bb_pos + offset, +value);
+ return true;
+ }
+ key() {
+ const offset = this.bb.__offset(this.bb_pos, 20);
+ return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;
+ }
+ mutate_key(value) {
+ const offset = this.bb.__offset(this.bb_pos, 20);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt8(this.bb_pos + offset, +value);
+ return true;
+ }
+ attributes(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 22);
+ return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ attributesLength() {
+ const offset = this.bb.__offset(this.bb_pos, 22);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ documentation(index, optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 24);
+ return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+ }
+ documentationLength() {
+ const offset = this.bb.__offset(this.bb_pos, 24);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ optional() {
+ const offset = this.bb.__offset(this.bb_pos, 26);
+ return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;
+ }
+ mutate_optional(value) {
+ const offset = this.bb.__offset(this.bb_pos, 26);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt8(this.bb_pos + offset, +value);
+ return true;
+ }
+ /**
+ * Number of padding octets to always add after this field. Structs only.
+ */
+ padding() {
+ const offset = this.bb.__offset(this.bb_pos, 28);
+ return offset ? this.bb.readUint16(this.bb_pos + offset) : 0;
+ }
+ mutate_padding(value) {
+ const offset = this.bb.__offset(this.bb_pos, 28);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint16(this.bb_pos + offset, value);
+ return true;
+ }
+ static getFullyQualifiedName() {
+ return 'reflection_Field';
+ }
+ static startField(builder) {
+ builder.startObject(13);
+ }
+ static addName(builder, nameOffset) {
+ builder.addFieldOffset(0, nameOffset, 0);
+ }
+ static addType(builder, typeOffset) {
+ builder.addFieldOffset(1, typeOffset, 0);
+ }
+ static addId(builder, id) {
+ builder.addFieldInt16(2, id, 0);
+ }
+ static addOffset(builder, offset) {
+ builder.addFieldInt16(3, offset, 0);
+ }
+ static addDefaultInteger(builder, defaultInteger) {
+ builder.addFieldInt64(4, defaultInteger, BigInt('0'));
+ }
+ static addDefaultReal(builder, defaultReal) {
+ builder.addFieldFloat64(5, defaultReal, 0.0);
+ }
+ static addDeprecated(builder, deprecated) {
+ builder.addFieldInt8(6, +deprecated, +false);
+ }
+ static addRequired(builder, required) {
+ builder.addFieldInt8(7, +required, +false);
+ }
+ static addKey(builder, key) {
+ builder.addFieldInt8(8, +key, +false);
+ }
+ static addAttributes(builder, attributesOffset) {
+ builder.addFieldOffset(9, attributesOffset, 0);
+ }
+ static createAttributesVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startAttributesVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addDocumentation(builder, documentationOffset) {
+ builder.addFieldOffset(10, documentationOffset, 0);
+ }
+ static createDocumentationVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startDocumentationVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addOptional(builder, optional) {
+ builder.addFieldInt8(11, +optional, +false);
+ }
+ static addPadding(builder, padding) {
+ builder.addFieldInt16(12, padding, 0);
+ }
+ static endField(builder) {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4); // name
+ builder.requiredField(offset, 6); // type
+ return offset;
+ }
+ unpack() {
+ return new FieldT(this.name(), (this.type() !== null ? this.type().unpack() : null), this.id(), this.offset(), this.defaultInteger(), this.defaultReal(), this.deprecated(), this.required(), this.key(), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.optional(), this.padding());
+ }
+ unpackTo(_o) {
+ _o.name = this.name();
+ _o.type = (this.type() !== null ? this.type().unpack() : null);
+ _o.id = this.id();
+ _o.offset = this.offset();
+ _o.defaultInteger = this.defaultInteger();
+ _o.defaultReal = this.defaultReal();
+ _o.deprecated = this.deprecated();
+ _o.required = this.required();
+ _o.key = this.key();
+ _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength());
+ _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength());
+ _o.optional = this.optional();
+ _o.padding = this.padding();
+ }
+}
+export class FieldT {
+ constructor(name = null, type = null, id = 0, offset = 0, defaultInteger = BigInt('0'), defaultReal = 0.0, deprecated = false, required = false, key = false, attributes = [], documentation = [], optional = false, padding = 0) {
+ this.name = name;
+ this.type = type;
+ this.id = id;
+ this.offset = offset;
+ this.defaultInteger = defaultInteger;
+ this.defaultReal = defaultReal;
+ this.deprecated = deprecated;
+ this.required = required;
+ this.key = key;
+ this.attributes = attributes;
+ this.documentation = documentation;
+ this.optional = optional;
+ this.padding = padding;
+ }
+ pack(builder) {
+ const name = (this.name !== null ? builder.createString(this.name) : 0);
+ const type = (this.type !== null ? this.type.pack(builder) : 0);
+ const attributes = Field.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes));
+ const documentation = Field.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation));
+ Field.startField(builder);
+ Field.addName(builder, name);
+ Field.addType(builder, type);
+ Field.addId(builder, this.id);
+ Field.addOffset(builder, this.offset);
+ Field.addDefaultInteger(builder, this.defaultInteger);
+ Field.addDefaultReal(builder, this.defaultReal);
+ Field.addDeprecated(builder, this.deprecated);
+ Field.addRequired(builder, this.required);
+ Field.addKey(builder, this.key);
+ Field.addAttributes(builder, attributes);
+ Field.addDocumentation(builder, documentation);
+ Field.addOptional(builder, this.optional);
+ Field.addPadding(builder, this.padding);
+ return Field.endField(builder);
+ }
+}
diff --git a/tests/ts/reflection/field.ts b/tests/ts/reflection/field.ts
new file mode 100644
index 0000000..48c1bed
--- /dev/null
+++ b/tests/ts/reflection/field.ts
@@ -0,0 +1,377 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+import { KeyValue, KeyValueT } from '../reflection/key-value.js';
+import { Type, TypeT } from '../reflection/type.js';
+
+
+export class Field {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):Field {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsField(bb:flatbuffers.ByteBuffer, obj?:Field):Field {
+ return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsField(bb:flatbuffers.ByteBuffer, obj?:Field):Field {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+name():string|null
+name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+name(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+type(obj?:Type):Type|null {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? (obj || new Type()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
+}
+
+id():number {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
+}
+
+mutate_id(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint16(this.bb_pos + offset, value);
+ return true;
+}
+
+offset():number {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
+}
+
+mutate_offset(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint16(this.bb_pos + offset, value);
+ return true;
+}
+
+defaultInteger():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
+}
+
+mutate_default_integer(value:bigint):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt64(this.bb_pos + offset, value);
+ return true;
+}
+
+defaultReal():number {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0;
+}
+
+mutate_default_real(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeFloat64(this.bb_pos + offset, value);
+ return true;
+}
+
+deprecated():boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 16);
+ return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
+}
+
+mutate_deprecated(value:boolean):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 16);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt8(this.bb_pos + offset, +value);
+ return true;
+}
+
+required():boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 18);
+ return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
+}
+
+mutate_required(value:boolean):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 18);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt8(this.bb_pos + offset, +value);
+ return true;
+}
+
+key():boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 20);
+ return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
+}
+
+mutate_key(value:boolean):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 20);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt8(this.bb_pos + offset, +value);
+ return true;
+}
+
+attributes(index: number, obj?:KeyValue):KeyValue|null {
+ const offset = this.bb!.__offset(this.bb_pos, 22);
+ return offset ? (obj || new KeyValue()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+attributesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 22);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+documentation(index: number):string
+documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array
+documentation(index: number,optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 24);
+ return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+}
+
+documentationLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 24);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+optional():boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 26);
+ return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
+}
+
+mutate_optional(value:boolean):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 26);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt8(this.bb_pos + offset, +value);
+ return true;
+}
+
+/**
+ * Number of padding octets to always add after this field. Structs only.
+ */
+padding():number {
+ const offset = this.bb!.__offset(this.bb_pos, 28);
+ return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
+}
+
+mutate_padding(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 28);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint16(this.bb_pos + offset, value);
+ return true;
+}
+
+static getFullyQualifiedName():string {
+ return 'reflection_Field';
+}
+
+static startField(builder:flatbuffers.Builder) {
+ builder.startObject(13);
+}
+
+static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(0, nameOffset, 0);
+}
+
+static addType(builder:flatbuffers.Builder, typeOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(1, typeOffset, 0);
+}
+
+static addId(builder:flatbuffers.Builder, id:number) {
+ builder.addFieldInt16(2, id, 0);
+}
+
+static addOffset(builder:flatbuffers.Builder, offset:number) {
+ builder.addFieldInt16(3, offset, 0);
+}
+
+static addDefaultInteger(builder:flatbuffers.Builder, defaultInteger:bigint) {
+ builder.addFieldInt64(4, defaultInteger, BigInt('0'));
+}
+
+static addDefaultReal(builder:flatbuffers.Builder, defaultReal:number) {
+ builder.addFieldFloat64(5, defaultReal, 0.0);
+}
+
+static addDeprecated(builder:flatbuffers.Builder, deprecated:boolean) {
+ builder.addFieldInt8(6, +deprecated, +false);
+}
+
+static addRequired(builder:flatbuffers.Builder, required:boolean) {
+ builder.addFieldInt8(7, +required, +false);
+}
+
+static addKey(builder:flatbuffers.Builder, key:boolean) {
+ builder.addFieldInt8(8, +key, +false);
+}
+
+static addAttributes(builder:flatbuffers.Builder, attributesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(9, attributesOffset, 0);
+}
+
+static createAttributesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startAttributesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(10, documentationOffset, 0);
+}
+
+static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addOptional(builder:flatbuffers.Builder, optional:boolean) {
+ builder.addFieldInt8(11, +optional, +false);
+}
+
+static addPadding(builder:flatbuffers.Builder, padding:number) {
+ builder.addFieldInt16(12, padding, 0);
+}
+
+static endField(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4) // name
+ builder.requiredField(offset, 6) // type
+ return offset;
+}
+
+
+unpack(): FieldT {
+ return new FieldT(
+ this.name(),
+ (this.type() !== null ? this.type()!.unpack() : null),
+ this.id(),
+ this.offset(),
+ this.defaultInteger(),
+ this.defaultReal(),
+ this.deprecated(),
+ this.required(),
+ this.key(),
+ this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()),
+ this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()),
+ this.optional(),
+ this.padding()
+ );
+}
+
+
+unpackTo(_o: FieldT): void {
+ _o.name = this.name();
+ _o.type = (this.type() !== null ? this.type()!.unpack() : null);
+ _o.id = this.id();
+ _o.offset = this.offset();
+ _o.defaultInteger = this.defaultInteger();
+ _o.defaultReal = this.defaultReal();
+ _o.deprecated = this.deprecated();
+ _o.required = this.required();
+ _o.key = this.key();
+ _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength());
+ _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength());
+ _o.optional = this.optional();
+ _o.padding = this.padding();
+}
+}
+
+export class FieldT {
+constructor(
+ public name: string|Uint8Array|null = null,
+ public type: TypeT|null = null,
+ public id: number = 0,
+ public offset: number = 0,
+ public defaultInteger: bigint = BigInt('0'),
+ public defaultReal: number = 0.0,
+ public deprecated: boolean = false,
+ public required: boolean = false,
+ public key: boolean = false,
+ public attributes: (KeyValueT)[] = [],
+ public documentation: (string)[] = [],
+ public optional: boolean = false,
+ public padding: number = 0
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ const name = (this.name !== null ? builder.createString(this.name!) : 0);
+ const type = (this.type !== null ? this.type!.pack(builder) : 0);
+ const attributes = Field.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes));
+ const documentation = Field.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation));
+
+ Field.startField(builder);
+ Field.addName(builder, name);
+ Field.addType(builder, type);
+ Field.addId(builder, this.id);
+ Field.addOffset(builder, this.offset);
+ Field.addDefaultInteger(builder, this.defaultInteger);
+ Field.addDefaultReal(builder, this.defaultReal);
+ Field.addDeprecated(builder, this.deprecated);
+ Field.addRequired(builder, this.required);
+ Field.addKey(builder, this.key);
+ Field.addAttributes(builder, attributes);
+ Field.addDocumentation(builder, documentation);
+ Field.addOptional(builder, this.optional);
+ Field.addPadding(builder, this.padding);
+
+ return Field.endField(builder);
+}
+}
diff --git a/tests/ts/reflection/key-value.js b/tests/ts/reflection/key-value.js
new file mode 100644
index 0000000..622b4f2
--- /dev/null
+++ b/tests/ts/reflection/key-value.js
@@ -0,0 +1,69 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import * as flatbuffers from 'flatbuffers';
+export class KeyValue {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsKeyValue(bb, obj) {
+ return (obj || new KeyValue()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsKeyValue(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new KeyValue()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ key(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ value(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ static getFullyQualifiedName() {
+ return 'reflection_KeyValue';
+ }
+ static startKeyValue(builder) {
+ builder.startObject(2);
+ }
+ static addKey(builder, keyOffset) {
+ builder.addFieldOffset(0, keyOffset, 0);
+ }
+ static addValue(builder, valueOffset) {
+ builder.addFieldOffset(1, valueOffset, 0);
+ }
+ static endKeyValue(builder) {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4); // key
+ return offset;
+ }
+ static createKeyValue(builder, keyOffset, valueOffset) {
+ KeyValue.startKeyValue(builder);
+ KeyValue.addKey(builder, keyOffset);
+ KeyValue.addValue(builder, valueOffset);
+ return KeyValue.endKeyValue(builder);
+ }
+ unpack() {
+ return new KeyValueT(this.key(), this.value());
+ }
+ unpackTo(_o) {
+ _o.key = this.key();
+ _o.value = this.value();
+ }
+}
+export class KeyValueT {
+ constructor(key = null, value = null) {
+ this.key = key;
+ this.value = value;
+ }
+ pack(builder) {
+ const key = (this.key !== null ? builder.createString(this.key) : 0);
+ const value = (this.value !== null ? builder.createString(this.value) : 0);
+ return KeyValue.createKeyValue(builder, key, value);
+ }
+}
diff --git a/tests/ts/reflection/key-value.ts b/tests/ts/reflection/key-value.ts
new file mode 100644
index 0000000..736766b
--- /dev/null
+++ b/tests/ts/reflection/key-value.ts
@@ -0,0 +1,98 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+
+
+export class KeyValue {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):KeyValue {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsKeyValue(bb:flatbuffers.ByteBuffer, obj?:KeyValue):KeyValue {
+ return (obj || new KeyValue()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsKeyValue(bb:flatbuffers.ByteBuffer, obj?:KeyValue):KeyValue {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new KeyValue()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+key():string|null
+key(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+key(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+value():string|null
+value(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+value(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+static getFullyQualifiedName():string {
+ return 'reflection_KeyValue';
+}
+
+static startKeyValue(builder:flatbuffers.Builder) {
+ builder.startObject(2);
+}
+
+static addKey(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(0, keyOffset, 0);
+}
+
+static addValue(builder:flatbuffers.Builder, valueOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(1, valueOffset, 0);
+}
+
+static endKeyValue(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4) // key
+ return offset;
+}
+
+static createKeyValue(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset, valueOffset:flatbuffers.Offset):flatbuffers.Offset {
+ KeyValue.startKeyValue(builder);
+ KeyValue.addKey(builder, keyOffset);
+ KeyValue.addValue(builder, valueOffset);
+ return KeyValue.endKeyValue(builder);
+}
+
+unpack(): KeyValueT {
+ return new KeyValueT(
+ this.key(),
+ this.value()
+ );
+}
+
+
+unpackTo(_o: KeyValueT): void {
+ _o.key = this.key();
+ _o.value = this.value();
+}
+}
+
+export class KeyValueT {
+constructor(
+ public key: string|Uint8Array|null = null,
+ public value: string|Uint8Array|null = null
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ const key = (this.key !== null ? builder.createString(this.key!) : 0);
+ const value = (this.value !== null ? builder.createString(this.value!) : 0);
+
+ return KeyValue.createKeyValue(builder,
+ key,
+ value
+ );
+}
+}
diff --git a/tests/ts/reflection/object.js b/tests/ts/reflection/object.js
new file mode 100644
index 0000000..d288545
--- /dev/null
+++ b/tests/ts/reflection/object.js
@@ -0,0 +1,201 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import * as flatbuffers from 'flatbuffers';
+import { Field } from '../reflection/field.js';
+import { KeyValue } from '../reflection/key-value.js';
+export class Object_ {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsObject(bb, obj) {
+ return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsObject(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ name(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ fields(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? (obj || new Field()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ fieldsLength() {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ isStruct() {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;
+ }
+ mutate_is_struct(value) {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt8(this.bb_pos + offset, +value);
+ return true;
+ }
+ minalign() {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
+ }
+ mutate_minalign(value) {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt32(this.bb_pos + offset, value);
+ return true;
+ }
+ bytesize() {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
+ }
+ mutate_bytesize(value) {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt32(this.bb_pos + offset, value);
+ return true;
+ }
+ attributes(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ attributesLength() {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ documentation(index, optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 16);
+ return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+ }
+ documentationLength() {
+ const offset = this.bb.__offset(this.bb_pos, 16);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ declarationFile(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 18);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ static getFullyQualifiedName() {
+ return 'reflection_Object';
+ }
+ static startObject(builder) {
+ builder.startObject(8);
+ }
+ static addName(builder, nameOffset) {
+ builder.addFieldOffset(0, nameOffset, 0);
+ }
+ static addFields(builder, fieldsOffset) {
+ builder.addFieldOffset(1, fieldsOffset, 0);
+ }
+ static createFieldsVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startFieldsVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addIsStruct(builder, isStruct) {
+ builder.addFieldInt8(2, +isStruct, +false);
+ }
+ static addMinalign(builder, minalign) {
+ builder.addFieldInt32(3, minalign, 0);
+ }
+ static addBytesize(builder, bytesize) {
+ builder.addFieldInt32(4, bytesize, 0);
+ }
+ static addAttributes(builder, attributesOffset) {
+ builder.addFieldOffset(5, attributesOffset, 0);
+ }
+ static createAttributesVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startAttributesVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addDocumentation(builder, documentationOffset) {
+ builder.addFieldOffset(6, documentationOffset, 0);
+ }
+ static createDocumentationVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startDocumentationVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addDeclarationFile(builder, declarationFileOffset) {
+ builder.addFieldOffset(7, declarationFileOffset, 0);
+ }
+ static endObject(builder) {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4); // name
+ builder.requiredField(offset, 6); // fields
+ return offset;
+ }
+ static createObject(builder, nameOffset, fieldsOffset, isStruct, minalign, bytesize, attributesOffset, documentationOffset, declarationFileOffset) {
+ Object_.startObject(builder);
+ Object_.addName(builder, nameOffset);
+ Object_.addFields(builder, fieldsOffset);
+ Object_.addIsStruct(builder, isStruct);
+ Object_.addMinalign(builder, minalign);
+ Object_.addBytesize(builder, bytesize);
+ Object_.addAttributes(builder, attributesOffset);
+ Object_.addDocumentation(builder, documentationOffset);
+ Object_.addDeclarationFile(builder, declarationFileOffset);
+ return Object_.endObject(builder);
+ }
+ unpack() {
+ return new Object_T(this.name(), this.bb.createObjList(this.fields.bind(this), this.fieldsLength()), this.isStruct(), this.minalign(), this.bytesize(), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.declarationFile());
+ }
+ unpackTo(_o) {
+ _o.name = this.name();
+ _o.fields = this.bb.createObjList(this.fields.bind(this), this.fieldsLength());
+ _o.isStruct = this.isStruct();
+ _o.minalign = this.minalign();
+ _o.bytesize = this.bytesize();
+ _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength());
+ _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength());
+ _o.declarationFile = this.declarationFile();
+ }
+}
+export class Object_T {
+ constructor(name = null, fields = [], isStruct = false, minalign = 0, bytesize = 0, attributes = [], documentation = [], declarationFile = null) {
+ this.name = name;
+ this.fields = fields;
+ this.isStruct = isStruct;
+ this.minalign = minalign;
+ this.bytesize = bytesize;
+ this.attributes = attributes;
+ this.documentation = documentation;
+ this.declarationFile = declarationFile;
+ }
+ pack(builder) {
+ const name = (this.name !== null ? builder.createString(this.name) : 0);
+ const fields = Object_.createFieldsVector(builder, builder.createObjectOffsetList(this.fields));
+ const attributes = Object_.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes));
+ const documentation = Object_.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation));
+ const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile) : 0);
+ return Object_.createObject(builder, name, fields, this.isStruct, this.minalign, this.bytesize, attributes, documentation, declarationFile);
+ }
+}
diff --git a/tests/ts/reflection/object.ts b/tests/ts/reflection/object.ts
new file mode 100644
index 0000000..1e14f03
--- /dev/null
+++ b/tests/ts/reflection/object.ts
@@ -0,0 +1,277 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+import { Field, FieldT } from '../reflection/field.js';
+import { KeyValue, KeyValueT } from '../reflection/key-value.js';
+
+
+export class Object_ {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):Object_ {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsObject(bb:flatbuffers.ByteBuffer, obj?:Object_):Object_ {
+ return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsObject(bb:flatbuffers.ByteBuffer, obj?:Object_):Object_ {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+name():string|null
+name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+name(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+fields(index: number, obj?:Field):Field|null {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? (obj || new Field()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+fieldsLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+isStruct():boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
+}
+
+mutate_is_struct(value:boolean):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt8(this.bb_pos + offset, +value);
+ return true;
+}
+
+minalign():number {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
+}
+
+mutate_minalign(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt32(this.bb_pos + offset, value);
+ return true;
+}
+
+bytesize():number {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
+}
+
+mutate_bytesize(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt32(this.bb_pos + offset, value);
+ return true;
+}
+
+attributes(index: number, obj?:KeyValue):KeyValue|null {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? (obj || new KeyValue()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+attributesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+documentation(index: number):string
+documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array
+documentation(index: number,optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 16);
+ return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+}
+
+documentationLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 16);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+/**
+ * File that this Object is declared in.
+ */
+declarationFile():string|null
+declarationFile(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+declarationFile(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 18);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+static getFullyQualifiedName():string {
+ return 'reflection_Object';
+}
+
+static startObject(builder:flatbuffers.Builder) {
+ builder.startObject(8);
+}
+
+static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(0, nameOffset, 0);
+}
+
+static addFields(builder:flatbuffers.Builder, fieldsOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(1, fieldsOffset, 0);
+}
+
+static createFieldsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startFieldsVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addIsStruct(builder:flatbuffers.Builder, isStruct:boolean) {
+ builder.addFieldInt8(2, +isStruct, +false);
+}
+
+static addMinalign(builder:flatbuffers.Builder, minalign:number) {
+ builder.addFieldInt32(3, minalign, 0);
+}
+
+static addBytesize(builder:flatbuffers.Builder, bytesize:number) {
+ builder.addFieldInt32(4, bytesize, 0);
+}
+
+static addAttributes(builder:flatbuffers.Builder, attributesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(5, attributesOffset, 0);
+}
+
+static createAttributesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startAttributesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(6, documentationOffset, 0);
+}
+
+static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addDeclarationFile(builder:flatbuffers.Builder, declarationFileOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(7, declarationFileOffset, 0);
+}
+
+static endObject(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4) // name
+ builder.requiredField(offset, 6) // fields
+ return offset;
+}
+
+static createObject(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset, fieldsOffset:flatbuffers.Offset, isStruct:boolean, minalign:number, bytesize:number, attributesOffset:flatbuffers.Offset, documentationOffset:flatbuffers.Offset, declarationFileOffset:flatbuffers.Offset):flatbuffers.Offset {
+ Object_.startObject(builder);
+ Object_.addName(builder, nameOffset);
+ Object_.addFields(builder, fieldsOffset);
+ Object_.addIsStruct(builder, isStruct);
+ Object_.addMinalign(builder, minalign);
+ Object_.addBytesize(builder, bytesize);
+ Object_.addAttributes(builder, attributesOffset);
+ Object_.addDocumentation(builder, documentationOffset);
+ Object_.addDeclarationFile(builder, declarationFileOffset);
+ return Object_.endObject(builder);
+}
+
+unpack(): Object_T {
+ return new Object_T(
+ this.name(),
+ this.bb!.createObjList(this.fields.bind(this), this.fieldsLength()),
+ this.isStruct(),
+ this.minalign(),
+ this.bytesize(),
+ this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()),
+ this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()),
+ this.declarationFile()
+ );
+}
+
+
+unpackTo(_o: Object_T): void {
+ _o.name = this.name();
+ _o.fields = this.bb!.createObjList(this.fields.bind(this), this.fieldsLength());
+ _o.isStruct = this.isStruct();
+ _o.minalign = this.minalign();
+ _o.bytesize = this.bytesize();
+ _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength());
+ _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength());
+ _o.declarationFile = this.declarationFile();
+}
+}
+
+export class Object_T {
+constructor(
+ public name: string|Uint8Array|null = null,
+ public fields: (FieldT)[] = [],
+ public isStruct: boolean = false,
+ public minalign: number = 0,
+ public bytesize: number = 0,
+ public attributes: (KeyValueT)[] = [],
+ public documentation: (string)[] = [],
+ public declarationFile: string|Uint8Array|null = null
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ const name = (this.name !== null ? builder.createString(this.name!) : 0);
+ const fields = Object_.createFieldsVector(builder, builder.createObjectOffsetList(this.fields));
+ const attributes = Object_.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes));
+ const documentation = Object_.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation));
+ const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile!) : 0);
+
+ return Object_.createObject(builder,
+ name,
+ fields,
+ this.isStruct,
+ this.minalign,
+ this.bytesize,
+ attributes,
+ documentation,
+ declarationFile
+ );
+}
+}
diff --git a/tests/ts/reflection/rpccall.js b/tests/ts/reflection/rpccall.js
new file mode 100644
index 0000000..96e92eb
--- /dev/null
+++ b/tests/ts/reflection/rpccall.js
@@ -0,0 +1,131 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import * as flatbuffers from 'flatbuffers';
+import { KeyValue } from '../reflection/key-value.js';
+import { Object_ } from '../reflection/object.js';
+export class RPCCall {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsRPCCall(bb, obj) {
+ return (obj || new RPCCall()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsRPCCall(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new RPCCall()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ name(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ request(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? (obj || new Object_()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
+ }
+ response(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ return offset ? (obj || new Object_()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
+ }
+ attributes(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ attributesLength() {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ documentation(index, optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+ }
+ documentationLength() {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ static getFullyQualifiedName() {
+ return 'reflection_RPCCall';
+ }
+ static startRPCCall(builder) {
+ builder.startObject(5);
+ }
+ static addName(builder, nameOffset) {
+ builder.addFieldOffset(0, nameOffset, 0);
+ }
+ static addRequest(builder, requestOffset) {
+ builder.addFieldOffset(1, requestOffset, 0);
+ }
+ static addResponse(builder, responseOffset) {
+ builder.addFieldOffset(2, responseOffset, 0);
+ }
+ static addAttributes(builder, attributesOffset) {
+ builder.addFieldOffset(3, attributesOffset, 0);
+ }
+ static createAttributesVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startAttributesVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addDocumentation(builder, documentationOffset) {
+ builder.addFieldOffset(4, documentationOffset, 0);
+ }
+ static createDocumentationVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startDocumentationVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static endRPCCall(builder) {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4); // name
+ builder.requiredField(offset, 6); // request
+ builder.requiredField(offset, 8); // response
+ return offset;
+ }
+ unpack() {
+ return new RPCCallT(this.name(), (this.request() !== null ? this.request().unpack() : null), (this.response() !== null ? this.response().unpack() : null), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()));
+ }
+ unpackTo(_o) {
+ _o.name = this.name();
+ _o.request = (this.request() !== null ? this.request().unpack() : null);
+ _o.response = (this.response() !== null ? this.response().unpack() : null);
+ _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength());
+ _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength());
+ }
+}
+export class RPCCallT {
+ constructor(name = null, request = null, response = null, attributes = [], documentation = []) {
+ this.name = name;
+ this.request = request;
+ this.response = response;
+ this.attributes = attributes;
+ this.documentation = documentation;
+ }
+ pack(builder) {
+ const name = (this.name !== null ? builder.createString(this.name) : 0);
+ const request = (this.request !== null ? this.request.pack(builder) : 0);
+ const response = (this.response !== null ? this.response.pack(builder) : 0);
+ const attributes = RPCCall.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes));
+ const documentation = RPCCall.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation));
+ RPCCall.startRPCCall(builder);
+ RPCCall.addName(builder, name);
+ RPCCall.addRequest(builder, request);
+ RPCCall.addResponse(builder, response);
+ RPCCall.addAttributes(builder, attributes);
+ RPCCall.addDocumentation(builder, documentation);
+ return RPCCall.endRPCCall(builder);
+ }
+}
diff --git a/tests/ts/reflection/rpccall.ts b/tests/ts/reflection/rpccall.ts
new file mode 100644
index 0000000..151d7b1
--- /dev/null
+++ b/tests/ts/reflection/rpccall.ts
@@ -0,0 +1,173 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+import { KeyValue, KeyValueT } from '../reflection/key-value.js';
+import { Object_, Object_T } from '../reflection/object.js';
+
+
+export class RPCCall {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):RPCCall {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsRPCCall(bb:flatbuffers.ByteBuffer, obj?:RPCCall):RPCCall {
+ return (obj || new RPCCall()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsRPCCall(bb:flatbuffers.ByteBuffer, obj?:RPCCall):RPCCall {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new RPCCall()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+name():string|null
+name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+name(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+request(obj?:Object_):Object_|null {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? (obj || new Object_()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
+}
+
+response(obj?:Object_):Object_|null {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? (obj || new Object_()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
+}
+
+attributes(index: number, obj?:KeyValue):KeyValue|null {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? (obj || new KeyValue()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+attributesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+documentation(index: number):string
+documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array
+documentation(index: number,optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+}
+
+documentationLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+static getFullyQualifiedName():string {
+ return 'reflection_RPCCall';
+}
+
+static startRPCCall(builder:flatbuffers.Builder) {
+ builder.startObject(5);
+}
+
+static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(0, nameOffset, 0);
+}
+
+static addRequest(builder:flatbuffers.Builder, requestOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(1, requestOffset, 0);
+}
+
+static addResponse(builder:flatbuffers.Builder, responseOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(2, responseOffset, 0);
+}
+
+static addAttributes(builder:flatbuffers.Builder, attributesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(3, attributesOffset, 0);
+}
+
+static createAttributesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startAttributesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(4, documentationOffset, 0);
+}
+
+static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static endRPCCall(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4) // name
+ builder.requiredField(offset, 6) // request
+ builder.requiredField(offset, 8) // response
+ return offset;
+}
+
+
+unpack(): RPCCallT {
+ return new RPCCallT(
+ this.name(),
+ (this.request() !== null ? this.request()!.unpack() : null),
+ (this.response() !== null ? this.response()!.unpack() : null),
+ this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()),
+ this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength())
+ );
+}
+
+
+unpackTo(_o: RPCCallT): void {
+ _o.name = this.name();
+ _o.request = (this.request() !== null ? this.request()!.unpack() : null);
+ _o.response = (this.response() !== null ? this.response()!.unpack() : null);
+ _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength());
+ _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength());
+}
+}
+
+export class RPCCallT {
+constructor(
+ public name: string|Uint8Array|null = null,
+ public request: Object_T|null = null,
+ public response: Object_T|null = null,
+ public attributes: (KeyValueT)[] = [],
+ public documentation: (string)[] = []
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ const name = (this.name !== null ? builder.createString(this.name!) : 0);
+ const request = (this.request !== null ? this.request!.pack(builder) : 0);
+ const response = (this.response !== null ? this.response!.pack(builder) : 0);
+ const attributes = RPCCall.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes));
+ const documentation = RPCCall.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation));
+
+ RPCCall.startRPCCall(builder);
+ RPCCall.addName(builder, name);
+ RPCCall.addRequest(builder, request);
+ RPCCall.addResponse(builder, response);
+ RPCCall.addAttributes(builder, attributes);
+ RPCCall.addDocumentation(builder, documentation);
+
+ return RPCCall.endRPCCall(builder);
+}
+}
diff --git a/tests/ts/reflection/schema-file.js b/tests/ts/reflection/schema-file.js
new file mode 100644
index 0000000..31c6145
--- /dev/null
+++ b/tests/ts/reflection/schema-file.js
@@ -0,0 +1,88 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import * as flatbuffers from 'flatbuffers';
+/**
+ * File specific information.
+ * Symbols declared within a file may be recovered by iterating over all
+ * symbols and examining the `declaration_file` field.
+ */
+export class SchemaFile {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsSchemaFile(bb, obj) {
+ return (obj || new SchemaFile()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsSchemaFile(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new SchemaFile()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ filename(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ includedFilenames(index, optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+ }
+ includedFilenamesLength() {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ static getFullyQualifiedName() {
+ return 'reflection_SchemaFile';
+ }
+ static startSchemaFile(builder) {
+ builder.startObject(2);
+ }
+ static addFilename(builder, filenameOffset) {
+ builder.addFieldOffset(0, filenameOffset, 0);
+ }
+ static addIncludedFilenames(builder, includedFilenamesOffset) {
+ builder.addFieldOffset(1, includedFilenamesOffset, 0);
+ }
+ static createIncludedFilenamesVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startIncludedFilenamesVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static endSchemaFile(builder) {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4); // filename
+ return offset;
+ }
+ static createSchemaFile(builder, filenameOffset, includedFilenamesOffset) {
+ SchemaFile.startSchemaFile(builder);
+ SchemaFile.addFilename(builder, filenameOffset);
+ SchemaFile.addIncludedFilenames(builder, includedFilenamesOffset);
+ return SchemaFile.endSchemaFile(builder);
+ }
+ unpack() {
+ return new SchemaFileT(this.filename(), this.bb.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength()));
+ }
+ unpackTo(_o) {
+ _o.filename = this.filename();
+ _o.includedFilenames = this.bb.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength());
+ }
+}
+export class SchemaFileT {
+ constructor(filename = null, includedFilenames = []) {
+ this.filename = filename;
+ this.includedFilenames = includedFilenames;
+ }
+ pack(builder) {
+ const filename = (this.filename !== null ? builder.createString(this.filename) : 0);
+ const includedFilenames = SchemaFile.createIncludedFilenamesVector(builder, builder.createObjectOffsetList(this.includedFilenames));
+ return SchemaFile.createSchemaFile(builder, filename, includedFilenames);
+ }
+}
diff --git a/tests/ts/reflection/schema-file.ts b/tests/ts/reflection/schema-file.ts
new file mode 100644
index 0000000..e1f5035
--- /dev/null
+++ b/tests/ts/reflection/schema-file.ts
@@ -0,0 +1,126 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+
+
+/**
+ * File specific information.
+ * Symbols declared within a file may be recovered by iterating over all
+ * symbols and examining the `declaration_file` field.
+ */
+export class SchemaFile {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):SchemaFile {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsSchemaFile(bb:flatbuffers.ByteBuffer, obj?:SchemaFile):SchemaFile {
+ return (obj || new SchemaFile()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsSchemaFile(bb:flatbuffers.ByteBuffer, obj?:SchemaFile):SchemaFile {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new SchemaFile()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+/**
+ * Filename, relative to project root.
+ */
+filename():string|null
+filename(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+filename(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+/**
+ * Names of included files, relative to project root.
+ */
+includedFilenames(index: number):string
+includedFilenames(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array
+includedFilenames(index: number,optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+}
+
+includedFilenamesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+static getFullyQualifiedName():string {
+ return 'reflection_SchemaFile';
+}
+
+static startSchemaFile(builder:flatbuffers.Builder) {
+ builder.startObject(2);
+}
+
+static addFilename(builder:flatbuffers.Builder, filenameOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(0, filenameOffset, 0);
+}
+
+static addIncludedFilenames(builder:flatbuffers.Builder, includedFilenamesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(1, includedFilenamesOffset, 0);
+}
+
+static createIncludedFilenamesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startIncludedFilenamesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static endSchemaFile(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4) // filename
+ return offset;
+}
+
+static createSchemaFile(builder:flatbuffers.Builder, filenameOffset:flatbuffers.Offset, includedFilenamesOffset:flatbuffers.Offset):flatbuffers.Offset {
+ SchemaFile.startSchemaFile(builder);
+ SchemaFile.addFilename(builder, filenameOffset);
+ SchemaFile.addIncludedFilenames(builder, includedFilenamesOffset);
+ return SchemaFile.endSchemaFile(builder);
+}
+
+unpack(): SchemaFileT {
+ return new SchemaFileT(
+ this.filename(),
+ this.bb!.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength())
+ );
+}
+
+
+unpackTo(_o: SchemaFileT): void {
+ _o.filename = this.filename();
+ _o.includedFilenames = this.bb!.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength());
+}
+}
+
+export class SchemaFileT {
+constructor(
+ public filename: string|Uint8Array|null = null,
+ public includedFilenames: (string)[] = []
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ const filename = (this.filename !== null ? builder.createString(this.filename!) : 0);
+ const includedFilenames = SchemaFile.createIncludedFilenamesVector(builder, builder.createObjectOffsetList(this.includedFilenames));
+
+ return SchemaFile.createSchemaFile(builder,
+ filename,
+ includedFilenames
+ );
+}
+}
diff --git a/tests/ts/reflection/schema.js b/tests/ts/reflection/schema.js
new file mode 100644
index 0000000..d502297
--- /dev/null
+++ b/tests/ts/reflection/schema.js
@@ -0,0 +1,213 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import * as flatbuffers from 'flatbuffers';
+import { Enum } from '../reflection/enum.js';
+import { Object_ } from '../reflection/object.js';
+import { SchemaFile } from '../reflection/schema-file.js';
+import { Service } from '../reflection/service.js';
+export class Schema {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsSchema(bb, obj) {
+ return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsSchema(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static bufferHasIdentifier(bb) {
+ return bb.__has_identifier('BFBS');
+ }
+ objects(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? (obj || new Object_()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ objectsLength() {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ enums(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? (obj || new Enum()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ enumsLength() {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ fileIdent(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ fileExt(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ rootTable(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ return offset ? (obj || new Object_()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
+ }
+ services(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ return offset ? (obj || new Service()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ servicesLength() {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ advancedFeatures() {
+ const offset = this.bb.__offset(this.bb_pos, 16);
+ return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0');
+ }
+ mutate_advanced_features(value) {
+ const offset = this.bb.__offset(this.bb_pos, 16);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint64(this.bb_pos + offset, value);
+ return true;
+ }
+ /**
+ * All the files used in this compilation. Files are relative to where
+ * flatc was invoked.
+ */
+ fbsFiles(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 18);
+ return offset ? (obj || new SchemaFile()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ fbsFilesLength() {
+ const offset = this.bb.__offset(this.bb_pos, 18);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ static getFullyQualifiedName() {
+ return 'reflection_Schema';
+ }
+ static startSchema(builder) {
+ builder.startObject(8);
+ }
+ static addObjects(builder, objectsOffset) {
+ builder.addFieldOffset(0, objectsOffset, 0);
+ }
+ static createObjectsVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startObjectsVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addEnums(builder, enumsOffset) {
+ builder.addFieldOffset(1, enumsOffset, 0);
+ }
+ static createEnumsVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startEnumsVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addFileIdent(builder, fileIdentOffset) {
+ builder.addFieldOffset(2, fileIdentOffset, 0);
+ }
+ static addFileExt(builder, fileExtOffset) {
+ builder.addFieldOffset(3, fileExtOffset, 0);
+ }
+ static addRootTable(builder, rootTableOffset) {
+ builder.addFieldOffset(4, rootTableOffset, 0);
+ }
+ static addServices(builder, servicesOffset) {
+ builder.addFieldOffset(5, servicesOffset, 0);
+ }
+ static createServicesVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startServicesVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addAdvancedFeatures(builder, advancedFeatures) {
+ builder.addFieldInt64(6, advancedFeatures, BigInt('0'));
+ }
+ static addFbsFiles(builder, fbsFilesOffset) {
+ builder.addFieldOffset(7, fbsFilesOffset, 0);
+ }
+ static createFbsFilesVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startFbsFilesVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static endSchema(builder) {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4); // objects
+ builder.requiredField(offset, 6); // enums
+ return offset;
+ }
+ static finishSchemaBuffer(builder, offset) {
+ builder.finish(offset, 'BFBS');
+ }
+ static finishSizePrefixedSchemaBuffer(builder, offset) {
+ builder.finish(offset, 'BFBS', true);
+ }
+ unpack() {
+ return new SchemaT(this.bb.createObjList(this.objects.bind(this), this.objectsLength()), this.bb.createObjList(this.enums.bind(this), this.enumsLength()), this.fileIdent(), this.fileExt(), (this.rootTable() !== null ? this.rootTable().unpack() : null), this.bb.createObjList(this.services.bind(this), this.servicesLength()), this.advancedFeatures(), this.bb.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength()));
+ }
+ unpackTo(_o) {
+ _o.objects = this.bb.createObjList(this.objects.bind(this), this.objectsLength());
+ _o.enums = this.bb.createObjList(this.enums.bind(this), this.enumsLength());
+ _o.fileIdent = this.fileIdent();
+ _o.fileExt = this.fileExt();
+ _o.rootTable = (this.rootTable() !== null ? this.rootTable().unpack() : null);
+ _o.services = this.bb.createObjList(this.services.bind(this), this.servicesLength());
+ _o.advancedFeatures = this.advancedFeatures();
+ _o.fbsFiles = this.bb.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength());
+ }
+}
+export class SchemaT {
+ constructor(objects = [], enums = [], fileIdent = null, fileExt = null, rootTable = null, services = [], advancedFeatures = BigInt('0'), fbsFiles = []) {
+ this.objects = objects;
+ this.enums = enums;
+ this.fileIdent = fileIdent;
+ this.fileExt = fileExt;
+ this.rootTable = rootTable;
+ this.services = services;
+ this.advancedFeatures = advancedFeatures;
+ this.fbsFiles = fbsFiles;
+ }
+ pack(builder) {
+ const objects = Schema.createObjectsVector(builder, builder.createObjectOffsetList(this.objects));
+ const enums = Schema.createEnumsVector(builder, builder.createObjectOffsetList(this.enums));
+ const fileIdent = (this.fileIdent !== null ? builder.createString(this.fileIdent) : 0);
+ const fileExt = (this.fileExt !== null ? builder.createString(this.fileExt) : 0);
+ const rootTable = (this.rootTable !== null ? this.rootTable.pack(builder) : 0);
+ const services = Schema.createServicesVector(builder, builder.createObjectOffsetList(this.services));
+ const fbsFiles = Schema.createFbsFilesVector(builder, builder.createObjectOffsetList(this.fbsFiles));
+ Schema.startSchema(builder);
+ Schema.addObjects(builder, objects);
+ Schema.addEnums(builder, enums);
+ Schema.addFileIdent(builder, fileIdent);
+ Schema.addFileExt(builder, fileExt);
+ Schema.addRootTable(builder, rootTable);
+ Schema.addServices(builder, services);
+ Schema.addAdvancedFeatures(builder, this.advancedFeatures);
+ Schema.addFbsFiles(builder, fbsFiles);
+ return Schema.endSchema(builder);
+ }
+}
diff --git a/tests/ts/reflection/schema.ts b/tests/ts/reflection/schema.ts
new file mode 100644
index 0000000..d1839c7
--- /dev/null
+++ b/tests/ts/reflection/schema.ts
@@ -0,0 +1,276 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+import { Enum, EnumT } from '../reflection/enum.js';
+import { Object_, Object_T } from '../reflection/object.js';
+import { SchemaFile, SchemaFileT } from '../reflection/schema-file.js';
+import { Service, ServiceT } from '../reflection/service.js';
+
+
+export class Schema {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):Schema {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsSchema(bb:flatbuffers.ByteBuffer, obj?:Schema):Schema {
+ return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsSchema(bb:flatbuffers.ByteBuffer, obj?:Schema):Schema {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean {
+ return bb.__has_identifier('BFBS');
+}
+
+objects(index: number, obj?:Object_):Object_|null {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? (obj || new Object_()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+objectsLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+enums(index: number, obj?:Enum):Enum|null {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? (obj || new Enum()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+enumsLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+fileIdent():string|null
+fileIdent(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+fileIdent(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+fileExt():string|null
+fileExt(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+fileExt(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+rootTable(obj?:Object_):Object_|null {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? (obj || new Object_()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
+}
+
+services(index: number, obj?:Service):Service|null {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? (obj || new Service()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+servicesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+advancedFeatures():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 16);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
+}
+
+mutate_advanced_features(value:bigint):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 16);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint64(this.bb_pos + offset, value);
+ return true;
+}
+
+/**
+ * All the files used in this compilation. Files are relative to where
+ * flatc was invoked.
+ */
+fbsFiles(index: number, obj?:SchemaFile):SchemaFile|null {
+ const offset = this.bb!.__offset(this.bb_pos, 18);
+ return offset ? (obj || new SchemaFile()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+fbsFilesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 18);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+static getFullyQualifiedName():string {
+ return 'reflection_Schema';
+}
+
+static startSchema(builder:flatbuffers.Builder) {
+ builder.startObject(8);
+}
+
+static addObjects(builder:flatbuffers.Builder, objectsOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(0, objectsOffset, 0);
+}
+
+static createObjectsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startObjectsVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addEnums(builder:flatbuffers.Builder, enumsOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(1, enumsOffset, 0);
+}
+
+static createEnumsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startEnumsVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addFileIdent(builder:flatbuffers.Builder, fileIdentOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(2, fileIdentOffset, 0);
+}
+
+static addFileExt(builder:flatbuffers.Builder, fileExtOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(3, fileExtOffset, 0);
+}
+
+static addRootTable(builder:flatbuffers.Builder, rootTableOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(4, rootTableOffset, 0);
+}
+
+static addServices(builder:flatbuffers.Builder, servicesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(5, servicesOffset, 0);
+}
+
+static createServicesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startServicesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addAdvancedFeatures(builder:flatbuffers.Builder, advancedFeatures:bigint) {
+ builder.addFieldInt64(6, advancedFeatures, BigInt('0'));
+}
+
+static addFbsFiles(builder:flatbuffers.Builder, fbsFilesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(7, fbsFilesOffset, 0);
+}
+
+static createFbsFilesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startFbsFilesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static endSchema(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4) // objects
+ builder.requiredField(offset, 6) // enums
+ return offset;
+}
+
+static finishSchemaBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
+ builder.finish(offset, 'BFBS');
+}
+
+static finishSizePrefixedSchemaBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
+ builder.finish(offset, 'BFBS', true);
+}
+
+
+unpack(): SchemaT {
+ return new SchemaT(
+ this.bb!.createObjList(this.objects.bind(this), this.objectsLength()),
+ this.bb!.createObjList(this.enums.bind(this), this.enumsLength()),
+ this.fileIdent(),
+ this.fileExt(),
+ (this.rootTable() !== null ? this.rootTable()!.unpack() : null),
+ this.bb!.createObjList(this.services.bind(this), this.servicesLength()),
+ this.advancedFeatures(),
+ this.bb!.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength())
+ );
+}
+
+
+unpackTo(_o: SchemaT): void {
+ _o.objects = this.bb!.createObjList(this.objects.bind(this), this.objectsLength());
+ _o.enums = this.bb!.createObjList(this.enums.bind(this), this.enumsLength());
+ _o.fileIdent = this.fileIdent();
+ _o.fileExt = this.fileExt();
+ _o.rootTable = (this.rootTable() !== null ? this.rootTable()!.unpack() : null);
+ _o.services = this.bb!.createObjList(this.services.bind(this), this.servicesLength());
+ _o.advancedFeatures = this.advancedFeatures();
+ _o.fbsFiles = this.bb!.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength());
+}
+}
+
+export class SchemaT {
+constructor(
+ public objects: (Object_T)[] = [],
+ public enums: (EnumT)[] = [],
+ public fileIdent: string|Uint8Array|null = null,
+ public fileExt: string|Uint8Array|null = null,
+ public rootTable: Object_T|null = null,
+ public services: (ServiceT)[] = [],
+ public advancedFeatures: bigint = BigInt('0'),
+ public fbsFiles: (SchemaFileT)[] = []
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ const objects = Schema.createObjectsVector(builder, builder.createObjectOffsetList(this.objects));
+ const enums = Schema.createEnumsVector(builder, builder.createObjectOffsetList(this.enums));
+ const fileIdent = (this.fileIdent !== null ? builder.createString(this.fileIdent!) : 0);
+ const fileExt = (this.fileExt !== null ? builder.createString(this.fileExt!) : 0);
+ const rootTable = (this.rootTable !== null ? this.rootTable!.pack(builder) : 0);
+ const services = Schema.createServicesVector(builder, builder.createObjectOffsetList(this.services));
+ const fbsFiles = Schema.createFbsFilesVector(builder, builder.createObjectOffsetList(this.fbsFiles));
+
+ Schema.startSchema(builder);
+ Schema.addObjects(builder, objects);
+ Schema.addEnums(builder, enums);
+ Schema.addFileIdent(builder, fileIdent);
+ Schema.addFileExt(builder, fileExt);
+ Schema.addRootTable(builder, rootTable);
+ Schema.addServices(builder, services);
+ Schema.addAdvancedFeatures(builder, this.advancedFeatures);
+ Schema.addFbsFiles(builder, fbsFiles);
+
+ return Schema.endSchema(builder);
+}
+}
diff --git a/tests/ts/reflection/service.js b/tests/ts/reflection/service.js
new file mode 100644
index 0000000..8c66ef7
--- /dev/null
+++ b/tests/ts/reflection/service.js
@@ -0,0 +1,146 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import * as flatbuffers from 'flatbuffers';
+import { KeyValue } from '../reflection/key-value.js';
+import { RPCCall } from '../reflection/rpccall.js';
+export class Service {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsService(bb, obj) {
+ return (obj || new Service()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsService(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Service()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ name(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ calls(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? (obj || new RPCCall()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ callsLength() {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ attributes(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ attributesLength() {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ documentation(index, optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+ }
+ documentationLength() {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ declarationFile(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ static getFullyQualifiedName() {
+ return 'reflection_Service';
+ }
+ static startService(builder) {
+ builder.startObject(5);
+ }
+ static addName(builder, nameOffset) {
+ builder.addFieldOffset(0, nameOffset, 0);
+ }
+ static addCalls(builder, callsOffset) {
+ builder.addFieldOffset(1, callsOffset, 0);
+ }
+ static createCallsVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startCallsVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addAttributes(builder, attributesOffset) {
+ builder.addFieldOffset(2, attributesOffset, 0);
+ }
+ static createAttributesVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startAttributesVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addDocumentation(builder, documentationOffset) {
+ builder.addFieldOffset(3, documentationOffset, 0);
+ }
+ static createDocumentationVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startDocumentationVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addDeclarationFile(builder, declarationFileOffset) {
+ builder.addFieldOffset(4, declarationFileOffset, 0);
+ }
+ static endService(builder) {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4); // name
+ return offset;
+ }
+ static createService(builder, nameOffset, callsOffset, attributesOffset, documentationOffset, declarationFileOffset) {
+ Service.startService(builder);
+ Service.addName(builder, nameOffset);
+ Service.addCalls(builder, callsOffset);
+ Service.addAttributes(builder, attributesOffset);
+ Service.addDocumentation(builder, documentationOffset);
+ Service.addDeclarationFile(builder, declarationFileOffset);
+ return Service.endService(builder);
+ }
+ unpack() {
+ return new ServiceT(this.name(), this.bb.createObjList(this.calls.bind(this), this.callsLength()), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.declarationFile());
+ }
+ unpackTo(_o) {
+ _o.name = this.name();
+ _o.calls = this.bb.createObjList(this.calls.bind(this), this.callsLength());
+ _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength());
+ _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength());
+ _o.declarationFile = this.declarationFile();
+ }
+}
+export class ServiceT {
+ constructor(name = null, calls = [], attributes = [], documentation = [], declarationFile = null) {
+ this.name = name;
+ this.calls = calls;
+ this.attributes = attributes;
+ this.documentation = documentation;
+ this.declarationFile = declarationFile;
+ }
+ pack(builder) {
+ const name = (this.name !== null ? builder.createString(this.name) : 0);
+ const calls = Service.createCallsVector(builder, builder.createObjectOffsetList(this.calls));
+ const attributes = Service.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes));
+ const documentation = Service.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation));
+ const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile) : 0);
+ return Service.createService(builder, name, calls, attributes, documentation, declarationFile);
+ }
+}
diff --git a/tests/ts/reflection/service.ts b/tests/ts/reflection/service.ts
new file mode 100644
index 0000000..c083cae
--- /dev/null
+++ b/tests/ts/reflection/service.ts
@@ -0,0 +1,201 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+import { KeyValue, KeyValueT } from '../reflection/key-value.js';
+import { RPCCall, RPCCallT } from '../reflection/rpccall.js';
+
+
+export class Service {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):Service {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsService(bb:flatbuffers.ByteBuffer, obj?:Service):Service {
+ return (obj || new Service()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsService(bb:flatbuffers.ByteBuffer, obj?:Service):Service {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Service()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+name():string|null
+name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+name(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+calls(index: number, obj?:RPCCall):RPCCall|null {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? (obj || new RPCCall()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+callsLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+attributes(index: number, obj?:KeyValue):KeyValue|null {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? (obj || new KeyValue()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+attributesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+documentation(index: number):string
+documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array
+documentation(index: number,optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+}
+
+documentationLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+/**
+ * File that this Service is declared in.
+ */
+declarationFile():string|null
+declarationFile(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+declarationFile(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+static getFullyQualifiedName():string {
+ return 'reflection_Service';
+}
+
+static startService(builder:flatbuffers.Builder) {
+ builder.startObject(5);
+}
+
+static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(0, nameOffset, 0);
+}
+
+static addCalls(builder:flatbuffers.Builder, callsOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(1, callsOffset, 0);
+}
+
+static createCallsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startCallsVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addAttributes(builder:flatbuffers.Builder, attributesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(2, attributesOffset, 0);
+}
+
+static createAttributesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startAttributesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(3, documentationOffset, 0);
+}
+
+static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addDeclarationFile(builder:flatbuffers.Builder, declarationFileOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(4, declarationFileOffset, 0);
+}
+
+static endService(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4) // name
+ return offset;
+}
+
+static createService(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset, callsOffset:flatbuffers.Offset, attributesOffset:flatbuffers.Offset, documentationOffset:flatbuffers.Offset, declarationFileOffset:flatbuffers.Offset):flatbuffers.Offset {
+ Service.startService(builder);
+ Service.addName(builder, nameOffset);
+ Service.addCalls(builder, callsOffset);
+ Service.addAttributes(builder, attributesOffset);
+ Service.addDocumentation(builder, documentationOffset);
+ Service.addDeclarationFile(builder, declarationFileOffset);
+ return Service.endService(builder);
+}
+
+unpack(): ServiceT {
+ return new ServiceT(
+ this.name(),
+ this.bb!.createObjList(this.calls.bind(this), this.callsLength()),
+ this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()),
+ this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()),
+ this.declarationFile()
+ );
+}
+
+
+unpackTo(_o: ServiceT): void {
+ _o.name = this.name();
+ _o.calls = this.bb!.createObjList(this.calls.bind(this), this.callsLength());
+ _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength());
+ _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength());
+ _o.declarationFile = this.declarationFile();
+}
+}
+
+export class ServiceT {
+constructor(
+ public name: string|Uint8Array|null = null,
+ public calls: (RPCCallT)[] = [],
+ public attributes: (KeyValueT)[] = [],
+ public documentation: (string)[] = [],
+ public declarationFile: string|Uint8Array|null = null
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ const name = (this.name !== null ? builder.createString(this.name!) : 0);
+ const calls = Service.createCallsVector(builder, builder.createObjectOffsetList(this.calls));
+ const attributes = Service.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes));
+ const documentation = Service.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation));
+ const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile!) : 0);
+
+ return Service.createService(builder,
+ name,
+ calls,
+ attributes,
+ documentation,
+ declarationFile
+ );
+}
+}
diff --git a/tests/ts/reflection/type.js b/tests/ts/reflection/type.js
new file mode 100644
index 0000000..f3ccbdf
--- /dev/null
+++ b/tests/ts/reflection/type.js
@@ -0,0 +1,161 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import * as flatbuffers from 'flatbuffers';
+import { BaseType } from '../reflection/base-type.js';
+export class Type {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsType(bb, obj) {
+ return (obj || new Type()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsType(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Type()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ baseType() {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.readInt8(this.bb_pos + offset) : BaseType.None;
+ }
+ mutate_base_type(value) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt8(this.bb_pos + offset, value);
+ return true;
+ }
+ element() {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? this.bb.readInt8(this.bb_pos + offset) : BaseType.None;
+ }
+ mutate_element(value) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt8(this.bb_pos + offset, value);
+ return true;
+ }
+ index() {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ return offset ? this.bb.readInt32(this.bb_pos + offset) : -1;
+ }
+ mutate_index(value) {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt32(this.bb_pos + offset, value);
+ return true;
+ }
+ fixedLength() {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? this.bb.readUint16(this.bb_pos + offset) : 0;
+ }
+ mutate_fixed_length(value) {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint16(this.bb_pos + offset, value);
+ return true;
+ }
+ /**
+ * The size (octets) of the `base_type` field.
+ */
+ baseSize() {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ return offset ? this.bb.readUint32(this.bb_pos + offset) : 4;
+ }
+ mutate_base_size(value) {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint32(this.bb_pos + offset, value);
+ return true;
+ }
+ /**
+ * The size (octets) of the `element` field, if present.
+ */
+ elementSize() {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ return offset ? this.bb.readUint32(this.bb_pos + offset) : 0;
+ }
+ mutate_element_size(value) {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint32(this.bb_pos + offset, value);
+ return true;
+ }
+ static getFullyQualifiedName() {
+ return 'reflection_Type';
+ }
+ static startType(builder) {
+ builder.startObject(6);
+ }
+ static addBaseType(builder, baseType) {
+ builder.addFieldInt8(0, baseType, BaseType.None);
+ }
+ static addElement(builder, element) {
+ builder.addFieldInt8(1, element, BaseType.None);
+ }
+ static addIndex(builder, index) {
+ builder.addFieldInt32(2, index, -1);
+ }
+ static addFixedLength(builder, fixedLength) {
+ builder.addFieldInt16(3, fixedLength, 0);
+ }
+ static addBaseSize(builder, baseSize) {
+ builder.addFieldInt32(4, baseSize, 4);
+ }
+ static addElementSize(builder, elementSize) {
+ builder.addFieldInt32(5, elementSize, 0);
+ }
+ static endType(builder) {
+ const offset = builder.endObject();
+ return offset;
+ }
+ static createType(builder, baseType, element, index, fixedLength, baseSize, elementSize) {
+ Type.startType(builder);
+ Type.addBaseType(builder, baseType);
+ Type.addElement(builder, element);
+ Type.addIndex(builder, index);
+ Type.addFixedLength(builder, fixedLength);
+ Type.addBaseSize(builder, baseSize);
+ Type.addElementSize(builder, elementSize);
+ return Type.endType(builder);
+ }
+ unpack() {
+ return new TypeT(this.baseType(), this.element(), this.index(), this.fixedLength(), this.baseSize(), this.elementSize());
+ }
+ unpackTo(_o) {
+ _o.baseType = this.baseType();
+ _o.element = this.element();
+ _o.index = this.index();
+ _o.fixedLength = this.fixedLength();
+ _o.baseSize = this.baseSize();
+ _o.elementSize = this.elementSize();
+ }
+}
+export class TypeT {
+ constructor(baseType = BaseType.None, element = BaseType.None, index = -1, fixedLength = 0, baseSize = 4, elementSize = 0) {
+ this.baseType = baseType;
+ this.element = element;
+ this.index = index;
+ this.fixedLength = fixedLength;
+ this.baseSize = baseSize;
+ this.elementSize = elementSize;
+ }
+ pack(builder) {
+ return Type.createType(builder, this.baseType, this.element, this.index, this.fixedLength, this.baseSize, this.elementSize);
+ }
+}
diff --git a/tests/ts/reflection/type.ts b/tests/ts/reflection/type.ts
new file mode 100644
index 0000000..e831e21
--- /dev/null
+++ b/tests/ts/reflection/type.ts
@@ -0,0 +1,219 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+import { BaseType } from '../reflection/base-type.js';
+
+
+export class Type {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):Type {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsType(bb:flatbuffers.ByteBuffer, obj?:Type):Type {
+ return (obj || new Type()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsType(bb:flatbuffers.ByteBuffer, obj?:Type):Type {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Type()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+baseType():BaseType {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.readInt8(this.bb_pos + offset) : BaseType.None;
+}
+
+mutate_base_type(value:BaseType):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt8(this.bb_pos + offset, value);
+ return true;
+}
+
+element():BaseType {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.readInt8(this.bb_pos + offset) : BaseType.None;
+}
+
+mutate_element(value:BaseType):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt8(this.bb_pos + offset, value);
+ return true;
+}
+
+index():number {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : -1;
+}
+
+mutate_index(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt32(this.bb_pos + offset, value);
+ return true;
+}
+
+fixedLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
+}
+
+mutate_fixed_length(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint16(this.bb_pos + offset, value);
+ return true;
+}
+
+/**
+ * The size (octets) of the `base_type` field.
+ */
+baseSize():number {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? this.bb!.readUint32(this.bb_pos + offset) : 4;
+}
+
+mutate_base_size(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint32(this.bb_pos + offset, value);
+ return true;
+}
+
+/**
+ * The size (octets) of the `element` field, if present.
+ */
+elementSize():number {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0;
+}
+
+mutate_element_size(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint32(this.bb_pos + offset, value);
+ return true;
+}
+
+static getFullyQualifiedName():string {
+ return 'reflection_Type';
+}
+
+static startType(builder:flatbuffers.Builder) {
+ builder.startObject(6);
+}
+
+static addBaseType(builder:flatbuffers.Builder, baseType:BaseType) {
+ builder.addFieldInt8(0, baseType, BaseType.None);
+}
+
+static addElement(builder:flatbuffers.Builder, element:BaseType) {
+ builder.addFieldInt8(1, element, BaseType.None);
+}
+
+static addIndex(builder:flatbuffers.Builder, index:number) {
+ builder.addFieldInt32(2, index, -1);
+}
+
+static addFixedLength(builder:flatbuffers.Builder, fixedLength:number) {
+ builder.addFieldInt16(3, fixedLength, 0);
+}
+
+static addBaseSize(builder:flatbuffers.Builder, baseSize:number) {
+ builder.addFieldInt32(4, baseSize, 4);
+}
+
+static addElementSize(builder:flatbuffers.Builder, elementSize:number) {
+ builder.addFieldInt32(5, elementSize, 0);
+}
+
+static endType(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+static createType(builder:flatbuffers.Builder, baseType:BaseType, element:BaseType, index:number, fixedLength:number, baseSize:number, elementSize:number):flatbuffers.Offset {
+ Type.startType(builder);
+ Type.addBaseType(builder, baseType);
+ Type.addElement(builder, element);
+ Type.addIndex(builder, index);
+ Type.addFixedLength(builder, fixedLength);
+ Type.addBaseSize(builder, baseSize);
+ Type.addElementSize(builder, elementSize);
+ return Type.endType(builder);
+}
+
+unpack(): TypeT {
+ return new TypeT(
+ this.baseType(),
+ this.element(),
+ this.index(),
+ this.fixedLength(),
+ this.baseSize(),
+ this.elementSize()
+ );
+}
+
+
+unpackTo(_o: TypeT): void {
+ _o.baseType = this.baseType();
+ _o.element = this.element();
+ _o.index = this.index();
+ _o.fixedLength = this.fixedLength();
+ _o.baseSize = this.baseSize();
+ _o.elementSize = this.elementSize();
+}
+}
+
+export class TypeT {
+constructor(
+ public baseType: BaseType = BaseType.None,
+ public element: BaseType = BaseType.None,
+ public index: number = -1,
+ public fixedLength: number = 0,
+ public baseSize: number = 4,
+ public elementSize: number = 0
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ return Type.createType(builder,
+ this.baseType,
+ this.element,
+ this.index,
+ this.fixedLength,
+ this.baseSize,
+ this.elementSize
+ );
+}
+}
diff --git a/tests/ts/reflection_generated.js b/tests/ts/reflection_generated.js
new file mode 100644
index 0000000..dd686cc
--- /dev/null
+++ b/tests/ts/reflection_generated.js
@@ -0,0 +1,1575 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import * as flatbuffers from 'flatbuffers';
+export var BaseType;
+(function (BaseType) {
+ BaseType[BaseType["None"] = 0] = "None";
+ BaseType[BaseType["UType"] = 1] = "UType";
+ BaseType[BaseType["Bool"] = 2] = "Bool";
+ BaseType[BaseType["Byte"] = 3] = "Byte";
+ BaseType[BaseType["UByte"] = 4] = "UByte";
+ BaseType[BaseType["Short"] = 5] = "Short";
+ BaseType[BaseType["UShort"] = 6] = "UShort";
+ BaseType[BaseType["Int"] = 7] = "Int";
+ BaseType[BaseType["UInt"] = 8] = "UInt";
+ BaseType[BaseType["Long"] = 9] = "Long";
+ BaseType[BaseType["ULong"] = 10] = "ULong";
+ BaseType[BaseType["Float"] = 11] = "Float";
+ BaseType[BaseType["Double"] = 12] = "Double";
+ BaseType[BaseType["String"] = 13] = "String";
+ BaseType[BaseType["Vector"] = 14] = "Vector";
+ BaseType[BaseType["Obj"] = 15] = "Obj";
+ BaseType[BaseType["Union"] = 16] = "Union";
+ BaseType[BaseType["Array"] = 17] = "Array";
+ BaseType[BaseType["MaxBaseType"] = 18] = "MaxBaseType";
+})(BaseType || (BaseType = {}));
+/**
+ * New schema language features that are not supported by old code generators.
+ */
+export var AdvancedFeatures;
+(function (AdvancedFeatures) {
+ AdvancedFeatures["AdvancedArrayFeatures"] = "1";
+ AdvancedFeatures["AdvancedUnionFeatures"] = "2";
+ AdvancedFeatures["OptionalScalars"] = "4";
+ AdvancedFeatures["DefaultVectorsAndStrings"] = "8";
+})(AdvancedFeatures || (AdvancedFeatures = {}));
+export class Type {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsType(bb, obj) {
+ return (obj || new Type()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsType(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Type()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ baseType() {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.readInt8(this.bb_pos + offset) : BaseType.None;
+ }
+ mutate_base_type(value) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt8(this.bb_pos + offset, value);
+ return true;
+ }
+ element() {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? this.bb.readInt8(this.bb_pos + offset) : BaseType.None;
+ }
+ mutate_element(value) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt8(this.bb_pos + offset, value);
+ return true;
+ }
+ index() {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ return offset ? this.bb.readInt32(this.bb_pos + offset) : -1;
+ }
+ mutate_index(value) {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt32(this.bb_pos + offset, value);
+ return true;
+ }
+ fixedLength() {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? this.bb.readUint16(this.bb_pos + offset) : 0;
+ }
+ mutate_fixed_length(value) {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint16(this.bb_pos + offset, value);
+ return true;
+ }
+ /**
+ * The size (octets) of the `base_type` field.
+ */
+ baseSize() {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ return offset ? this.bb.readUint32(this.bb_pos + offset) : 4;
+ }
+ mutate_base_size(value) {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint32(this.bb_pos + offset, value);
+ return true;
+ }
+ /**
+ * The size (octets) of the `element` field, if present.
+ */
+ elementSize() {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ return offset ? this.bb.readUint32(this.bb_pos + offset) : 0;
+ }
+ mutate_element_size(value) {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint32(this.bb_pos + offset, value);
+ return true;
+ }
+ static getFullyQualifiedName() {
+ return 'reflection_Type';
+ }
+ static startType(builder) {
+ builder.startObject(6);
+ }
+ static addBaseType(builder, baseType) {
+ builder.addFieldInt8(0, baseType, BaseType.None);
+ }
+ static addElement(builder, element) {
+ builder.addFieldInt8(1, element, BaseType.None);
+ }
+ static addIndex(builder, index) {
+ builder.addFieldInt32(2, index, -1);
+ }
+ static addFixedLength(builder, fixedLength) {
+ builder.addFieldInt16(3, fixedLength, 0);
+ }
+ static addBaseSize(builder, baseSize) {
+ builder.addFieldInt32(4, baseSize, 4);
+ }
+ static addElementSize(builder, elementSize) {
+ builder.addFieldInt32(5, elementSize, 0);
+ }
+ static endType(builder) {
+ const offset = builder.endObject();
+ return offset;
+ }
+ static createType(builder, baseType, element, index, fixedLength, baseSize, elementSize) {
+ Type.startType(builder);
+ Type.addBaseType(builder, baseType);
+ Type.addElement(builder, element);
+ Type.addIndex(builder, index);
+ Type.addFixedLength(builder, fixedLength);
+ Type.addBaseSize(builder, baseSize);
+ Type.addElementSize(builder, elementSize);
+ return Type.endType(builder);
+ }
+ unpack() {
+ return new TypeT(this.baseType(), this.element(), this.index(), this.fixedLength(), this.baseSize(), this.elementSize());
+ }
+ unpackTo(_o) {
+ _o.baseType = this.baseType();
+ _o.element = this.element();
+ _o.index = this.index();
+ _o.fixedLength = this.fixedLength();
+ _o.baseSize = this.baseSize();
+ _o.elementSize = this.elementSize();
+ }
+}
+export class TypeT {
+ constructor(baseType = BaseType.None, element = BaseType.None, index = -1, fixedLength = 0, baseSize = 4, elementSize = 0) {
+ this.baseType = baseType;
+ this.element = element;
+ this.index = index;
+ this.fixedLength = fixedLength;
+ this.baseSize = baseSize;
+ this.elementSize = elementSize;
+ }
+ pack(builder) {
+ return Type.createType(builder, this.baseType, this.element, this.index, this.fixedLength, this.baseSize, this.elementSize);
+ }
+}
+export class KeyValue {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsKeyValue(bb, obj) {
+ return (obj || new KeyValue()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsKeyValue(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new KeyValue()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ key(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ value(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ static getFullyQualifiedName() {
+ return 'reflection_KeyValue';
+ }
+ static startKeyValue(builder) {
+ builder.startObject(2);
+ }
+ static addKey(builder, keyOffset) {
+ builder.addFieldOffset(0, keyOffset, 0);
+ }
+ static addValue(builder, valueOffset) {
+ builder.addFieldOffset(1, valueOffset, 0);
+ }
+ static endKeyValue(builder) {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4); // key
+ return offset;
+ }
+ static createKeyValue(builder, keyOffset, valueOffset) {
+ KeyValue.startKeyValue(builder);
+ KeyValue.addKey(builder, keyOffset);
+ KeyValue.addValue(builder, valueOffset);
+ return KeyValue.endKeyValue(builder);
+ }
+ unpack() {
+ return new KeyValueT(this.key(), this.value());
+ }
+ unpackTo(_o) {
+ _o.key = this.key();
+ _o.value = this.value();
+ }
+}
+export class KeyValueT {
+ constructor(key = null, value = null) {
+ this.key = key;
+ this.value = value;
+ }
+ pack(builder) {
+ const key = (this.key !== null ? builder.createString(this.key) : 0);
+ const value = (this.value !== null ? builder.createString(this.value) : 0);
+ return KeyValue.createKeyValue(builder, key, value);
+ }
+}
+export class EnumVal {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsEnumVal(bb, obj) {
+ return (obj || new EnumVal()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsEnumVal(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new EnumVal()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ name(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ value() {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0');
+ }
+ mutate_value(value) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt64(this.bb_pos + offset, value);
+ return true;
+ }
+ unionType(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? (obj || new Type()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
+ }
+ documentation(index, optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+ }
+ documentationLength() {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ static getFullyQualifiedName() {
+ return 'reflection_EnumVal';
+ }
+ static startEnumVal(builder) {
+ builder.startObject(5);
+ }
+ static addName(builder, nameOffset) {
+ builder.addFieldOffset(0, nameOffset, 0);
+ }
+ static addValue(builder, value) {
+ builder.addFieldInt64(1, value, BigInt('0'));
+ }
+ static addUnionType(builder, unionTypeOffset) {
+ builder.addFieldOffset(3, unionTypeOffset, 0);
+ }
+ static addDocumentation(builder, documentationOffset) {
+ builder.addFieldOffset(4, documentationOffset, 0);
+ }
+ static createDocumentationVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startDocumentationVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static endEnumVal(builder) {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4); // name
+ return offset;
+ }
+ unpack() {
+ return new EnumValT(this.name(), this.value(), (this.unionType() !== null ? this.unionType().unpack() : null), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()));
+ }
+ unpackTo(_o) {
+ _o.name = this.name();
+ _o.value = this.value();
+ _o.unionType = (this.unionType() !== null ? this.unionType().unpack() : null);
+ _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength());
+ }
+}
+export class EnumValT {
+ constructor(name = null, value = BigInt('0'), unionType = null, documentation = []) {
+ this.name = name;
+ this.value = value;
+ this.unionType = unionType;
+ this.documentation = documentation;
+ }
+ pack(builder) {
+ const name = (this.name !== null ? builder.createString(this.name) : 0);
+ const unionType = (this.unionType !== null ? this.unionType.pack(builder) : 0);
+ const documentation = EnumVal.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation));
+ EnumVal.startEnumVal(builder);
+ EnumVal.addName(builder, name);
+ EnumVal.addValue(builder, this.value);
+ EnumVal.addUnionType(builder, unionType);
+ EnumVal.addDocumentation(builder, documentation);
+ return EnumVal.endEnumVal(builder);
+ }
+}
+export class Enum {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsEnum(bb, obj) {
+ return (obj || new Enum()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsEnum(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Enum()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ name(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ values(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? (obj || new EnumVal()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ valuesLength() {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ isUnion() {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;
+ }
+ mutate_is_union(value) {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt8(this.bb_pos + offset, +value);
+ return true;
+ }
+ underlyingType(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? (obj || new Type()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
+ }
+ attributes(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ attributesLength() {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ documentation(index, optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+ }
+ documentationLength() {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ declarationFile(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 16);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ static getFullyQualifiedName() {
+ return 'reflection_Enum';
+ }
+ static startEnum(builder) {
+ builder.startObject(7);
+ }
+ static addName(builder, nameOffset) {
+ builder.addFieldOffset(0, nameOffset, 0);
+ }
+ static addValues(builder, valuesOffset) {
+ builder.addFieldOffset(1, valuesOffset, 0);
+ }
+ static createValuesVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startValuesVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addIsUnion(builder, isUnion) {
+ builder.addFieldInt8(2, +isUnion, +false);
+ }
+ static addUnderlyingType(builder, underlyingTypeOffset) {
+ builder.addFieldOffset(3, underlyingTypeOffset, 0);
+ }
+ static addAttributes(builder, attributesOffset) {
+ builder.addFieldOffset(4, attributesOffset, 0);
+ }
+ static createAttributesVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startAttributesVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addDocumentation(builder, documentationOffset) {
+ builder.addFieldOffset(5, documentationOffset, 0);
+ }
+ static createDocumentationVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startDocumentationVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addDeclarationFile(builder, declarationFileOffset) {
+ builder.addFieldOffset(6, declarationFileOffset, 0);
+ }
+ static endEnum(builder) {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4); // name
+ builder.requiredField(offset, 6); // values
+ builder.requiredField(offset, 10); // underlying_type
+ return offset;
+ }
+ unpack() {
+ return new EnumT(this.name(), this.bb.createObjList(this.values.bind(this), this.valuesLength()), this.isUnion(), (this.underlyingType() !== null ? this.underlyingType().unpack() : null), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.declarationFile());
+ }
+ unpackTo(_o) {
+ _o.name = this.name();
+ _o.values = this.bb.createObjList(this.values.bind(this), this.valuesLength());
+ _o.isUnion = this.isUnion();
+ _o.underlyingType = (this.underlyingType() !== null ? this.underlyingType().unpack() : null);
+ _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength());
+ _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength());
+ _o.declarationFile = this.declarationFile();
+ }
+}
+export class EnumT {
+ constructor(name = null, values = [], isUnion = false, underlyingType = null, attributes = [], documentation = [], declarationFile = null) {
+ this.name = name;
+ this.values = values;
+ this.isUnion = isUnion;
+ this.underlyingType = underlyingType;
+ this.attributes = attributes;
+ this.documentation = documentation;
+ this.declarationFile = declarationFile;
+ }
+ pack(builder) {
+ const name = (this.name !== null ? builder.createString(this.name) : 0);
+ const values = Enum.createValuesVector(builder, builder.createObjectOffsetList(this.values));
+ const underlyingType = (this.underlyingType !== null ? this.underlyingType.pack(builder) : 0);
+ const attributes = Enum.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes));
+ const documentation = Enum.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation));
+ const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile) : 0);
+ Enum.startEnum(builder);
+ Enum.addName(builder, name);
+ Enum.addValues(builder, values);
+ Enum.addIsUnion(builder, this.isUnion);
+ Enum.addUnderlyingType(builder, underlyingType);
+ Enum.addAttributes(builder, attributes);
+ Enum.addDocumentation(builder, documentation);
+ Enum.addDeclarationFile(builder, declarationFile);
+ return Enum.endEnum(builder);
+ }
+}
+export class Field {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsField(bb, obj) {
+ return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsField(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ name(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ type(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? (obj || new Type()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
+ }
+ id() {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ return offset ? this.bb.readUint16(this.bb_pos + offset) : 0;
+ }
+ mutate_id(value) {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint16(this.bb_pos + offset, value);
+ return true;
+ }
+ offset() {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? this.bb.readUint16(this.bb_pos + offset) : 0;
+ }
+ mutate_offset(value) {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint16(this.bb_pos + offset, value);
+ return true;
+ }
+ defaultInteger() {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0');
+ }
+ mutate_default_integer(value) {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt64(this.bb_pos + offset, value);
+ return true;
+ }
+ defaultReal() {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0;
+ }
+ mutate_default_real(value) {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeFloat64(this.bb_pos + offset, value);
+ return true;
+ }
+ deprecated() {
+ const offset = this.bb.__offset(this.bb_pos, 16);
+ return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;
+ }
+ mutate_deprecated(value) {
+ const offset = this.bb.__offset(this.bb_pos, 16);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt8(this.bb_pos + offset, +value);
+ return true;
+ }
+ required() {
+ const offset = this.bb.__offset(this.bb_pos, 18);
+ return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;
+ }
+ mutate_required(value) {
+ const offset = this.bb.__offset(this.bb_pos, 18);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt8(this.bb_pos + offset, +value);
+ return true;
+ }
+ key() {
+ const offset = this.bb.__offset(this.bb_pos, 20);
+ return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;
+ }
+ mutate_key(value) {
+ const offset = this.bb.__offset(this.bb_pos, 20);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt8(this.bb_pos + offset, +value);
+ return true;
+ }
+ attributes(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 22);
+ return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ attributesLength() {
+ const offset = this.bb.__offset(this.bb_pos, 22);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ documentation(index, optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 24);
+ return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+ }
+ documentationLength() {
+ const offset = this.bb.__offset(this.bb_pos, 24);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ optional() {
+ const offset = this.bb.__offset(this.bb_pos, 26);
+ return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;
+ }
+ mutate_optional(value) {
+ const offset = this.bb.__offset(this.bb_pos, 26);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt8(this.bb_pos + offset, +value);
+ return true;
+ }
+ /**
+ * Number of padding octets to always add after this field. Structs only.
+ */
+ padding() {
+ const offset = this.bb.__offset(this.bb_pos, 28);
+ return offset ? this.bb.readUint16(this.bb_pos + offset) : 0;
+ }
+ mutate_padding(value) {
+ const offset = this.bb.__offset(this.bb_pos, 28);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint16(this.bb_pos + offset, value);
+ return true;
+ }
+ static getFullyQualifiedName() {
+ return 'reflection_Field';
+ }
+ static startField(builder) {
+ builder.startObject(13);
+ }
+ static addName(builder, nameOffset) {
+ builder.addFieldOffset(0, nameOffset, 0);
+ }
+ static addType(builder, typeOffset) {
+ builder.addFieldOffset(1, typeOffset, 0);
+ }
+ static addId(builder, id) {
+ builder.addFieldInt16(2, id, 0);
+ }
+ static addOffset(builder, offset) {
+ builder.addFieldInt16(3, offset, 0);
+ }
+ static addDefaultInteger(builder, defaultInteger) {
+ builder.addFieldInt64(4, defaultInteger, BigInt('0'));
+ }
+ static addDefaultReal(builder, defaultReal) {
+ builder.addFieldFloat64(5, defaultReal, 0.0);
+ }
+ static addDeprecated(builder, deprecated) {
+ builder.addFieldInt8(6, +deprecated, +false);
+ }
+ static addRequired(builder, required) {
+ builder.addFieldInt8(7, +required, +false);
+ }
+ static addKey(builder, key) {
+ builder.addFieldInt8(8, +key, +false);
+ }
+ static addAttributes(builder, attributesOffset) {
+ builder.addFieldOffset(9, attributesOffset, 0);
+ }
+ static createAttributesVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startAttributesVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addDocumentation(builder, documentationOffset) {
+ builder.addFieldOffset(10, documentationOffset, 0);
+ }
+ static createDocumentationVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startDocumentationVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addOptional(builder, optional) {
+ builder.addFieldInt8(11, +optional, +false);
+ }
+ static addPadding(builder, padding) {
+ builder.addFieldInt16(12, padding, 0);
+ }
+ static endField(builder) {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4); // name
+ builder.requiredField(offset, 6); // type
+ return offset;
+ }
+ unpack() {
+ return new FieldT(this.name(), (this.type() !== null ? this.type().unpack() : null), this.id(), this.offset(), this.defaultInteger(), this.defaultReal(), this.deprecated(), this.required(), this.key(), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.optional(), this.padding());
+ }
+ unpackTo(_o) {
+ _o.name = this.name();
+ _o.type = (this.type() !== null ? this.type().unpack() : null);
+ _o.id = this.id();
+ _o.offset = this.offset();
+ _o.defaultInteger = this.defaultInteger();
+ _o.defaultReal = this.defaultReal();
+ _o.deprecated = this.deprecated();
+ _o.required = this.required();
+ _o.key = this.key();
+ _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength());
+ _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength());
+ _o.optional = this.optional();
+ _o.padding = this.padding();
+ }
+}
+export class FieldT {
+ constructor(name = null, type = null, id = 0, offset = 0, defaultInteger = BigInt('0'), defaultReal = 0.0, deprecated = false, required = false, key = false, attributes = [], documentation = [], optional = false, padding = 0) {
+ this.name = name;
+ this.type = type;
+ this.id = id;
+ this.offset = offset;
+ this.defaultInteger = defaultInteger;
+ this.defaultReal = defaultReal;
+ this.deprecated = deprecated;
+ this.required = required;
+ this.key = key;
+ this.attributes = attributes;
+ this.documentation = documentation;
+ this.optional = optional;
+ this.padding = padding;
+ }
+ pack(builder) {
+ const name = (this.name !== null ? builder.createString(this.name) : 0);
+ const type = (this.type !== null ? this.type.pack(builder) : 0);
+ const attributes = Field.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes));
+ const documentation = Field.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation));
+ Field.startField(builder);
+ Field.addName(builder, name);
+ Field.addType(builder, type);
+ Field.addId(builder, this.id);
+ Field.addOffset(builder, this.offset);
+ Field.addDefaultInteger(builder, this.defaultInteger);
+ Field.addDefaultReal(builder, this.defaultReal);
+ Field.addDeprecated(builder, this.deprecated);
+ Field.addRequired(builder, this.required);
+ Field.addKey(builder, this.key);
+ Field.addAttributes(builder, attributes);
+ Field.addDocumentation(builder, documentation);
+ Field.addOptional(builder, this.optional);
+ Field.addPadding(builder, this.padding);
+ return Field.endField(builder);
+ }
+}
+export class Object_ {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsObject(bb, obj) {
+ return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsObject(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ name(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ fields(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? (obj || new Field()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ fieldsLength() {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ isStruct() {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;
+ }
+ mutate_is_struct(value) {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt8(this.bb_pos + offset, +value);
+ return true;
+ }
+ minalign() {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
+ }
+ mutate_minalign(value) {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt32(this.bb_pos + offset, value);
+ return true;
+ }
+ bytesize() {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
+ }
+ mutate_bytesize(value) {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt32(this.bb_pos + offset, value);
+ return true;
+ }
+ attributes(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ attributesLength() {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ documentation(index, optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 16);
+ return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+ }
+ documentationLength() {
+ const offset = this.bb.__offset(this.bb_pos, 16);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ declarationFile(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 18);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ static getFullyQualifiedName() {
+ return 'reflection_Object';
+ }
+ static startObject(builder) {
+ builder.startObject(8);
+ }
+ static addName(builder, nameOffset) {
+ builder.addFieldOffset(0, nameOffset, 0);
+ }
+ static addFields(builder, fieldsOffset) {
+ builder.addFieldOffset(1, fieldsOffset, 0);
+ }
+ static createFieldsVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startFieldsVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addIsStruct(builder, isStruct) {
+ builder.addFieldInt8(2, +isStruct, +false);
+ }
+ static addMinalign(builder, minalign) {
+ builder.addFieldInt32(3, minalign, 0);
+ }
+ static addBytesize(builder, bytesize) {
+ builder.addFieldInt32(4, bytesize, 0);
+ }
+ static addAttributes(builder, attributesOffset) {
+ builder.addFieldOffset(5, attributesOffset, 0);
+ }
+ static createAttributesVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startAttributesVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addDocumentation(builder, documentationOffset) {
+ builder.addFieldOffset(6, documentationOffset, 0);
+ }
+ static createDocumentationVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startDocumentationVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addDeclarationFile(builder, declarationFileOffset) {
+ builder.addFieldOffset(7, declarationFileOffset, 0);
+ }
+ static endObject(builder) {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4); // name
+ builder.requiredField(offset, 6); // fields
+ return offset;
+ }
+ static createObject(builder, nameOffset, fieldsOffset, isStruct, minalign, bytesize, attributesOffset, documentationOffset, declarationFileOffset) {
+ Object_.startObject(builder);
+ Object_.addName(builder, nameOffset);
+ Object_.addFields(builder, fieldsOffset);
+ Object_.addIsStruct(builder, isStruct);
+ Object_.addMinalign(builder, minalign);
+ Object_.addBytesize(builder, bytesize);
+ Object_.addAttributes(builder, attributesOffset);
+ Object_.addDocumentation(builder, documentationOffset);
+ Object_.addDeclarationFile(builder, declarationFileOffset);
+ return Object_.endObject(builder);
+ }
+ unpack() {
+ return new Object_T(this.name(), this.bb.createObjList(this.fields.bind(this), this.fieldsLength()), this.isStruct(), this.minalign(), this.bytesize(), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.declarationFile());
+ }
+ unpackTo(_o) {
+ _o.name = this.name();
+ _o.fields = this.bb.createObjList(this.fields.bind(this), this.fieldsLength());
+ _o.isStruct = this.isStruct();
+ _o.minalign = this.minalign();
+ _o.bytesize = this.bytesize();
+ _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength());
+ _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength());
+ _o.declarationFile = this.declarationFile();
+ }
+}
+export class Object_T {
+ constructor(name = null, fields = [], isStruct = false, minalign = 0, bytesize = 0, attributes = [], documentation = [], declarationFile = null) {
+ this.name = name;
+ this.fields = fields;
+ this.isStruct = isStruct;
+ this.minalign = minalign;
+ this.bytesize = bytesize;
+ this.attributes = attributes;
+ this.documentation = documentation;
+ this.declarationFile = declarationFile;
+ }
+ pack(builder) {
+ const name = (this.name !== null ? builder.createString(this.name) : 0);
+ const fields = Object_.createFieldsVector(builder, builder.createObjectOffsetList(this.fields));
+ const attributes = Object_.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes));
+ const documentation = Object_.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation));
+ const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile) : 0);
+ return Object_.createObject(builder, name, fields, this.isStruct, this.minalign, this.bytesize, attributes, documentation, declarationFile);
+ }
+}
+export class RPCCall {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsRPCCall(bb, obj) {
+ return (obj || new RPCCall()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsRPCCall(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new RPCCall()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ name(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ request(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? (obj || new Object_()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
+ }
+ response(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ return offset ? (obj || new Object_()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
+ }
+ attributes(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ attributesLength() {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ documentation(index, optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+ }
+ documentationLength() {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ static getFullyQualifiedName() {
+ return 'reflection_RPCCall';
+ }
+ static startRPCCall(builder) {
+ builder.startObject(5);
+ }
+ static addName(builder, nameOffset) {
+ builder.addFieldOffset(0, nameOffset, 0);
+ }
+ static addRequest(builder, requestOffset) {
+ builder.addFieldOffset(1, requestOffset, 0);
+ }
+ static addResponse(builder, responseOffset) {
+ builder.addFieldOffset(2, responseOffset, 0);
+ }
+ static addAttributes(builder, attributesOffset) {
+ builder.addFieldOffset(3, attributesOffset, 0);
+ }
+ static createAttributesVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startAttributesVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addDocumentation(builder, documentationOffset) {
+ builder.addFieldOffset(4, documentationOffset, 0);
+ }
+ static createDocumentationVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startDocumentationVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static endRPCCall(builder) {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4); // name
+ builder.requiredField(offset, 6); // request
+ builder.requiredField(offset, 8); // response
+ return offset;
+ }
+ unpack() {
+ return new RPCCallT(this.name(), (this.request() !== null ? this.request().unpack() : null), (this.response() !== null ? this.response().unpack() : null), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()));
+ }
+ unpackTo(_o) {
+ _o.name = this.name();
+ _o.request = (this.request() !== null ? this.request().unpack() : null);
+ _o.response = (this.response() !== null ? this.response().unpack() : null);
+ _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength());
+ _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength());
+ }
+}
+export class RPCCallT {
+ constructor(name = null, request = null, response = null, attributes = [], documentation = []) {
+ this.name = name;
+ this.request = request;
+ this.response = response;
+ this.attributes = attributes;
+ this.documentation = documentation;
+ }
+ pack(builder) {
+ const name = (this.name !== null ? builder.createString(this.name) : 0);
+ const request = (this.request !== null ? this.request.pack(builder) : 0);
+ const response = (this.response !== null ? this.response.pack(builder) : 0);
+ const attributes = RPCCall.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes));
+ const documentation = RPCCall.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation));
+ RPCCall.startRPCCall(builder);
+ RPCCall.addName(builder, name);
+ RPCCall.addRequest(builder, request);
+ RPCCall.addResponse(builder, response);
+ RPCCall.addAttributes(builder, attributes);
+ RPCCall.addDocumentation(builder, documentation);
+ return RPCCall.endRPCCall(builder);
+ }
+}
+export class Service {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsService(bb, obj) {
+ return (obj || new Service()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsService(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Service()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ name(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ calls(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? (obj || new RPCCall()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ callsLength() {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ attributes(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ attributesLength() {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ documentation(index, optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+ }
+ documentationLength() {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ declarationFile(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ static getFullyQualifiedName() {
+ return 'reflection_Service';
+ }
+ static startService(builder) {
+ builder.startObject(5);
+ }
+ static addName(builder, nameOffset) {
+ builder.addFieldOffset(0, nameOffset, 0);
+ }
+ static addCalls(builder, callsOffset) {
+ builder.addFieldOffset(1, callsOffset, 0);
+ }
+ static createCallsVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startCallsVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addAttributes(builder, attributesOffset) {
+ builder.addFieldOffset(2, attributesOffset, 0);
+ }
+ static createAttributesVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startAttributesVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addDocumentation(builder, documentationOffset) {
+ builder.addFieldOffset(3, documentationOffset, 0);
+ }
+ static createDocumentationVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startDocumentationVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addDeclarationFile(builder, declarationFileOffset) {
+ builder.addFieldOffset(4, declarationFileOffset, 0);
+ }
+ static endService(builder) {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4); // name
+ return offset;
+ }
+ static createService(builder, nameOffset, callsOffset, attributesOffset, documentationOffset, declarationFileOffset) {
+ Service.startService(builder);
+ Service.addName(builder, nameOffset);
+ Service.addCalls(builder, callsOffset);
+ Service.addAttributes(builder, attributesOffset);
+ Service.addDocumentation(builder, documentationOffset);
+ Service.addDeclarationFile(builder, declarationFileOffset);
+ return Service.endService(builder);
+ }
+ unpack() {
+ return new ServiceT(this.name(), this.bb.createObjList(this.calls.bind(this), this.callsLength()), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.declarationFile());
+ }
+ unpackTo(_o) {
+ _o.name = this.name();
+ _o.calls = this.bb.createObjList(this.calls.bind(this), this.callsLength());
+ _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength());
+ _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength());
+ _o.declarationFile = this.declarationFile();
+ }
+}
+export class ServiceT {
+ constructor(name = null, calls = [], attributes = [], documentation = [], declarationFile = null) {
+ this.name = name;
+ this.calls = calls;
+ this.attributes = attributes;
+ this.documentation = documentation;
+ this.declarationFile = declarationFile;
+ }
+ pack(builder) {
+ const name = (this.name !== null ? builder.createString(this.name) : 0);
+ const calls = Service.createCallsVector(builder, builder.createObjectOffsetList(this.calls));
+ const attributes = Service.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes));
+ const documentation = Service.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation));
+ const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile) : 0);
+ return Service.createService(builder, name, calls, attributes, documentation, declarationFile);
+ }
+}
+/**
+ * File specific information.
+ * Symbols declared within a file may be recovered by iterating over all
+ * symbols and examining the `declaration_file` field.
+ */
+export class SchemaFile {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsSchemaFile(bb, obj) {
+ return (obj || new SchemaFile()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsSchemaFile(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new SchemaFile()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ filename(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ includedFilenames(index, optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+ }
+ includedFilenamesLength() {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ static getFullyQualifiedName() {
+ return 'reflection_SchemaFile';
+ }
+ static startSchemaFile(builder) {
+ builder.startObject(2);
+ }
+ static addFilename(builder, filenameOffset) {
+ builder.addFieldOffset(0, filenameOffset, 0);
+ }
+ static addIncludedFilenames(builder, includedFilenamesOffset) {
+ builder.addFieldOffset(1, includedFilenamesOffset, 0);
+ }
+ static createIncludedFilenamesVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startIncludedFilenamesVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static endSchemaFile(builder) {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4); // filename
+ return offset;
+ }
+ static createSchemaFile(builder, filenameOffset, includedFilenamesOffset) {
+ SchemaFile.startSchemaFile(builder);
+ SchemaFile.addFilename(builder, filenameOffset);
+ SchemaFile.addIncludedFilenames(builder, includedFilenamesOffset);
+ return SchemaFile.endSchemaFile(builder);
+ }
+ unpack() {
+ return new SchemaFileT(this.filename(), this.bb.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength()));
+ }
+ unpackTo(_o) {
+ _o.filename = this.filename();
+ _o.includedFilenames = this.bb.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength());
+ }
+}
+export class SchemaFileT {
+ constructor(filename = null, includedFilenames = []) {
+ this.filename = filename;
+ this.includedFilenames = includedFilenames;
+ }
+ pack(builder) {
+ const filename = (this.filename !== null ? builder.createString(this.filename) : 0);
+ const includedFilenames = SchemaFile.createIncludedFilenamesVector(builder, builder.createObjectOffsetList(this.includedFilenames));
+ return SchemaFile.createSchemaFile(builder, filename, includedFilenames);
+ }
+}
+export class Schema {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsSchema(bb, obj) {
+ return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsSchema(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static bufferHasIdentifier(bb) {
+ return bb.__has_identifier('BFBS');
+ }
+ objects(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? (obj || new Object_()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ objectsLength() {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ enums(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? (obj || new Enum()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ enumsLength() {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ fileIdent(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ fileExt(optionalEncoding) {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+ }
+ rootTable(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ return offset ? (obj || new Object_()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
+ }
+ services(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ return offset ? (obj || new Service()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ servicesLength() {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ advancedFeatures() {
+ const offset = this.bb.__offset(this.bb_pos, 16);
+ return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0');
+ }
+ mutate_advanced_features(value) {
+ const offset = this.bb.__offset(this.bb_pos, 16);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeUint64(this.bb_pos + offset, value);
+ return true;
+ }
+ /**
+ * All the files used in this compilation. Files are relative to where
+ * flatc was invoked.
+ */
+ fbsFiles(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 18);
+ return offset ? (obj || new SchemaFile()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
+ }
+ fbsFilesLength() {
+ const offset = this.bb.__offset(this.bb_pos, 18);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ static getFullyQualifiedName() {
+ return 'reflection_Schema';
+ }
+ static startSchema(builder) {
+ builder.startObject(8);
+ }
+ static addObjects(builder, objectsOffset) {
+ builder.addFieldOffset(0, objectsOffset, 0);
+ }
+ static createObjectsVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startObjectsVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addEnums(builder, enumsOffset) {
+ builder.addFieldOffset(1, enumsOffset, 0);
+ }
+ static createEnumsVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startEnumsVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addFileIdent(builder, fileIdentOffset) {
+ builder.addFieldOffset(2, fileIdentOffset, 0);
+ }
+ static addFileExt(builder, fileExtOffset) {
+ builder.addFieldOffset(3, fileExtOffset, 0);
+ }
+ static addRootTable(builder, rootTableOffset) {
+ builder.addFieldOffset(4, rootTableOffset, 0);
+ }
+ static addServices(builder, servicesOffset) {
+ builder.addFieldOffset(5, servicesOffset, 0);
+ }
+ static createServicesVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startServicesVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static addAdvancedFeatures(builder, advancedFeatures) {
+ builder.addFieldInt64(6, advancedFeatures, BigInt('0'));
+ }
+ static addFbsFiles(builder, fbsFilesOffset) {
+ builder.addFieldOffset(7, fbsFilesOffset, 0);
+ }
+ static createFbsFilesVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startFbsFilesVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static endSchema(builder) {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4); // objects
+ builder.requiredField(offset, 6); // enums
+ return offset;
+ }
+ static finishSchemaBuffer(builder, offset) {
+ builder.finish(offset, 'BFBS');
+ }
+ static finishSizePrefixedSchemaBuffer(builder, offset) {
+ builder.finish(offset, 'BFBS', true);
+ }
+ unpack() {
+ return new SchemaT(this.bb.createObjList(this.objects.bind(this), this.objectsLength()), this.bb.createObjList(this.enums.bind(this), this.enumsLength()), this.fileIdent(), this.fileExt(), (this.rootTable() !== null ? this.rootTable().unpack() : null), this.bb.createObjList(this.services.bind(this), this.servicesLength()), this.advancedFeatures(), this.bb.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength()));
+ }
+ unpackTo(_o) {
+ _o.objects = this.bb.createObjList(this.objects.bind(this), this.objectsLength());
+ _o.enums = this.bb.createObjList(this.enums.bind(this), this.enumsLength());
+ _o.fileIdent = this.fileIdent();
+ _o.fileExt = this.fileExt();
+ _o.rootTable = (this.rootTable() !== null ? this.rootTable().unpack() : null);
+ _o.services = this.bb.createObjList(this.services.bind(this), this.servicesLength());
+ _o.advancedFeatures = this.advancedFeatures();
+ _o.fbsFiles = this.bb.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength());
+ }
+}
+export class SchemaT {
+ constructor(objects = [], enums = [], fileIdent = null, fileExt = null, rootTable = null, services = [], advancedFeatures = BigInt('0'), fbsFiles = []) {
+ this.objects = objects;
+ this.enums = enums;
+ this.fileIdent = fileIdent;
+ this.fileExt = fileExt;
+ this.rootTable = rootTable;
+ this.services = services;
+ this.advancedFeatures = advancedFeatures;
+ this.fbsFiles = fbsFiles;
+ }
+ pack(builder) {
+ const objects = Schema.createObjectsVector(builder, builder.createObjectOffsetList(this.objects));
+ const enums = Schema.createEnumsVector(builder, builder.createObjectOffsetList(this.enums));
+ const fileIdent = (this.fileIdent !== null ? builder.createString(this.fileIdent) : 0);
+ const fileExt = (this.fileExt !== null ? builder.createString(this.fileExt) : 0);
+ const rootTable = (this.rootTable !== null ? this.rootTable.pack(builder) : 0);
+ const services = Schema.createServicesVector(builder, builder.createObjectOffsetList(this.services));
+ const fbsFiles = Schema.createFbsFilesVector(builder, builder.createObjectOffsetList(this.fbsFiles));
+ Schema.startSchema(builder);
+ Schema.addObjects(builder, objects);
+ Schema.addEnums(builder, enums);
+ Schema.addFileIdent(builder, fileIdent);
+ Schema.addFileExt(builder, fileExt);
+ Schema.addRootTable(builder, rootTable);
+ Schema.addServices(builder, services);
+ Schema.addAdvancedFeatures(builder, this.advancedFeatures);
+ Schema.addFbsFiles(builder, fbsFiles);
+ return Schema.endSchema(builder);
+ }
+}
diff --git a/tests/ts/reflection_generated.ts b/tests/ts/reflection_generated.ts
new file mode 100644
index 0000000..4bb1222
--- /dev/null
+++ b/tests/ts/reflection_generated.ts
@@ -0,0 +1,2100 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+
+export enum BaseType {
+ None = 0,
+ UType = 1,
+ Bool = 2,
+ Byte = 3,
+ UByte = 4,
+ Short = 5,
+ UShort = 6,
+ Int = 7,
+ UInt = 8,
+ Long = 9,
+ ULong = 10,
+ Float = 11,
+ Double = 12,
+ String = 13,
+ Vector = 14,
+ Obj = 15,
+ Union = 16,
+ Array = 17,
+ MaxBaseType = 18
+}
+
+/**
+ * New schema language features that are not supported by old code generators.
+ */
+export enum AdvancedFeatures {
+ AdvancedArrayFeatures = '1',
+ AdvancedUnionFeatures = '2',
+ OptionalScalars = '4',
+ DefaultVectorsAndStrings = '8'
+}
+
+export class Type {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):Type {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsType(bb:flatbuffers.ByteBuffer, obj?:Type):Type {
+ return (obj || new Type()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsType(bb:flatbuffers.ByteBuffer, obj?:Type):Type {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Type()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+baseType():BaseType {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.readInt8(this.bb_pos + offset) : BaseType.None;
+}
+
+mutate_base_type(value:BaseType):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt8(this.bb_pos + offset, value);
+ return true;
+}
+
+element():BaseType {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.readInt8(this.bb_pos + offset) : BaseType.None;
+}
+
+mutate_element(value:BaseType):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt8(this.bb_pos + offset, value);
+ return true;
+}
+
+index():number {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : -1;
+}
+
+mutate_index(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt32(this.bb_pos + offset, value);
+ return true;
+}
+
+fixedLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
+}
+
+mutate_fixed_length(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint16(this.bb_pos + offset, value);
+ return true;
+}
+
+/**
+ * The size (octets) of the `base_type` field.
+ */
+baseSize():number {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? this.bb!.readUint32(this.bb_pos + offset) : 4;
+}
+
+mutate_base_size(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint32(this.bb_pos + offset, value);
+ return true;
+}
+
+/**
+ * The size (octets) of the `element` field, if present.
+ */
+elementSize():number {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0;
+}
+
+mutate_element_size(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint32(this.bb_pos + offset, value);
+ return true;
+}
+
+static getFullyQualifiedName():string {
+ return 'reflection_Type';
+}
+
+static startType(builder:flatbuffers.Builder) {
+ builder.startObject(6);
+}
+
+static addBaseType(builder:flatbuffers.Builder, baseType:BaseType) {
+ builder.addFieldInt8(0, baseType, BaseType.None);
+}
+
+static addElement(builder:flatbuffers.Builder, element:BaseType) {
+ builder.addFieldInt8(1, element, BaseType.None);
+}
+
+static addIndex(builder:flatbuffers.Builder, index:number) {
+ builder.addFieldInt32(2, index, -1);
+}
+
+static addFixedLength(builder:flatbuffers.Builder, fixedLength:number) {
+ builder.addFieldInt16(3, fixedLength, 0);
+}
+
+static addBaseSize(builder:flatbuffers.Builder, baseSize:number) {
+ builder.addFieldInt32(4, baseSize, 4);
+}
+
+static addElementSize(builder:flatbuffers.Builder, elementSize:number) {
+ builder.addFieldInt32(5, elementSize, 0);
+}
+
+static endType(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+static createType(builder:flatbuffers.Builder, baseType:BaseType, element:BaseType, index:number, fixedLength:number, baseSize:number, elementSize:number):flatbuffers.Offset {
+ Type.startType(builder);
+ Type.addBaseType(builder, baseType);
+ Type.addElement(builder, element);
+ Type.addIndex(builder, index);
+ Type.addFixedLength(builder, fixedLength);
+ Type.addBaseSize(builder, baseSize);
+ Type.addElementSize(builder, elementSize);
+ return Type.endType(builder);
+}
+
+unpack(): TypeT {
+ return new TypeT(
+ this.baseType(),
+ this.element(),
+ this.index(),
+ this.fixedLength(),
+ this.baseSize(),
+ this.elementSize()
+ );
+}
+
+
+unpackTo(_o: TypeT): void {
+ _o.baseType = this.baseType();
+ _o.element = this.element();
+ _o.index = this.index();
+ _o.fixedLength = this.fixedLength();
+ _o.baseSize = this.baseSize();
+ _o.elementSize = this.elementSize();
+}
+}
+
+export class TypeT {
+constructor(
+ public baseType: BaseType = BaseType.None,
+ public element: BaseType = BaseType.None,
+ public index: number = -1,
+ public fixedLength: number = 0,
+ public baseSize: number = 4,
+ public elementSize: number = 0
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ return Type.createType(builder,
+ this.baseType,
+ this.element,
+ this.index,
+ this.fixedLength,
+ this.baseSize,
+ this.elementSize
+ );
+}
+}
+
+export class KeyValue {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):KeyValue {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsKeyValue(bb:flatbuffers.ByteBuffer, obj?:KeyValue):KeyValue {
+ return (obj || new KeyValue()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsKeyValue(bb:flatbuffers.ByteBuffer, obj?:KeyValue):KeyValue {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new KeyValue()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+key():string|null
+key(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+key(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+value():string|null
+value(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+value(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+static getFullyQualifiedName():string {
+ return 'reflection_KeyValue';
+}
+
+static startKeyValue(builder:flatbuffers.Builder) {
+ builder.startObject(2);
+}
+
+static addKey(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(0, keyOffset, 0);
+}
+
+static addValue(builder:flatbuffers.Builder, valueOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(1, valueOffset, 0);
+}
+
+static endKeyValue(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4) // key
+ return offset;
+}
+
+static createKeyValue(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset, valueOffset:flatbuffers.Offset):flatbuffers.Offset {
+ KeyValue.startKeyValue(builder);
+ KeyValue.addKey(builder, keyOffset);
+ KeyValue.addValue(builder, valueOffset);
+ return KeyValue.endKeyValue(builder);
+}
+
+unpack(): KeyValueT {
+ return new KeyValueT(
+ this.key(),
+ this.value()
+ );
+}
+
+
+unpackTo(_o: KeyValueT): void {
+ _o.key = this.key();
+ _o.value = this.value();
+}
+}
+
+export class KeyValueT {
+constructor(
+ public key: string|Uint8Array|null = null,
+ public value: string|Uint8Array|null = null
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ const key = (this.key !== null ? builder.createString(this.key!) : 0);
+ const value = (this.value !== null ? builder.createString(this.value!) : 0);
+
+ return KeyValue.createKeyValue(builder,
+ key,
+ value
+ );
+}
+}
+
+export class EnumVal {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):EnumVal {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsEnumVal(bb:flatbuffers.ByteBuffer, obj?:EnumVal):EnumVal {
+ return (obj || new EnumVal()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsEnumVal(bb:flatbuffers.ByteBuffer, obj?:EnumVal):EnumVal {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new EnumVal()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+name():string|null
+name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+name(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+value():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
+}
+
+mutate_value(value:bigint):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt64(this.bb_pos + offset, value);
+ return true;
+}
+
+unionType(obj?:Type):Type|null {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? (obj || new Type()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
+}
+
+documentation(index: number):string
+documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array
+documentation(index: number,optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+}
+
+documentationLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+static getFullyQualifiedName():string {
+ return 'reflection_EnumVal';
+}
+
+static startEnumVal(builder:flatbuffers.Builder) {
+ builder.startObject(5);
+}
+
+static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(0, nameOffset, 0);
+}
+
+static addValue(builder:flatbuffers.Builder, value:bigint) {
+ builder.addFieldInt64(1, value, BigInt('0'));
+}
+
+static addUnionType(builder:flatbuffers.Builder, unionTypeOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(3, unionTypeOffset, 0);
+}
+
+static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(4, documentationOffset, 0);
+}
+
+static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static endEnumVal(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4) // name
+ return offset;
+}
+
+
+unpack(): EnumValT {
+ return new EnumValT(
+ this.name(),
+ this.value(),
+ (this.unionType() !== null ? this.unionType()!.unpack() : null),
+ this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength())
+ );
+}
+
+
+unpackTo(_o: EnumValT): void {
+ _o.name = this.name();
+ _o.value = this.value();
+ _o.unionType = (this.unionType() !== null ? this.unionType()!.unpack() : null);
+ _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength());
+}
+}
+
+export class EnumValT {
+constructor(
+ public name: string|Uint8Array|null = null,
+ public value: bigint = BigInt('0'),
+ public unionType: TypeT|null = null,
+ public documentation: (string)[] = []
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ const name = (this.name !== null ? builder.createString(this.name!) : 0);
+ const unionType = (this.unionType !== null ? this.unionType!.pack(builder) : 0);
+ const documentation = EnumVal.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation));
+
+ EnumVal.startEnumVal(builder);
+ EnumVal.addName(builder, name);
+ EnumVal.addValue(builder, this.value);
+ EnumVal.addUnionType(builder, unionType);
+ EnumVal.addDocumentation(builder, documentation);
+
+ return EnumVal.endEnumVal(builder);
+}
+}
+
+export class Enum {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):Enum {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsEnum(bb:flatbuffers.ByteBuffer, obj?:Enum):Enum {
+ return (obj || new Enum()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsEnum(bb:flatbuffers.ByteBuffer, obj?:Enum):Enum {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Enum()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+name():string|null
+name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+name(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+values(index: number, obj?:EnumVal):EnumVal|null {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? (obj || new EnumVal()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+valuesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+isUnion():boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
+}
+
+mutate_is_union(value:boolean):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt8(this.bb_pos + offset, +value);
+ return true;
+}
+
+underlyingType(obj?:Type):Type|null {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? (obj || new Type()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
+}
+
+attributes(index: number, obj?:KeyValue):KeyValue|null {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? (obj || new KeyValue()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+attributesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+documentation(index: number):string
+documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array
+documentation(index: number,optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+}
+
+documentationLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+/**
+ * File that this Enum is declared in.
+ */
+declarationFile():string|null
+declarationFile(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+declarationFile(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 16);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+static getFullyQualifiedName():string {
+ return 'reflection_Enum';
+}
+
+static startEnum(builder:flatbuffers.Builder) {
+ builder.startObject(7);
+}
+
+static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(0, nameOffset, 0);
+}
+
+static addValues(builder:flatbuffers.Builder, valuesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(1, valuesOffset, 0);
+}
+
+static createValuesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startValuesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addIsUnion(builder:flatbuffers.Builder, isUnion:boolean) {
+ builder.addFieldInt8(2, +isUnion, +false);
+}
+
+static addUnderlyingType(builder:flatbuffers.Builder, underlyingTypeOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(3, underlyingTypeOffset, 0);
+}
+
+static addAttributes(builder:flatbuffers.Builder, attributesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(4, attributesOffset, 0);
+}
+
+static createAttributesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startAttributesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(5, documentationOffset, 0);
+}
+
+static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addDeclarationFile(builder:flatbuffers.Builder, declarationFileOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(6, declarationFileOffset, 0);
+}
+
+static endEnum(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4) // name
+ builder.requiredField(offset, 6) // values
+ builder.requiredField(offset, 10) // underlying_type
+ return offset;
+}
+
+
+unpack(): EnumT {
+ return new EnumT(
+ this.name(),
+ this.bb!.createObjList(this.values.bind(this), this.valuesLength()),
+ this.isUnion(),
+ (this.underlyingType() !== null ? this.underlyingType()!.unpack() : null),
+ this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()),
+ this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()),
+ this.declarationFile()
+ );
+}
+
+
+unpackTo(_o: EnumT): void {
+ _o.name = this.name();
+ _o.values = this.bb!.createObjList(this.values.bind(this), this.valuesLength());
+ _o.isUnion = this.isUnion();
+ _o.underlyingType = (this.underlyingType() !== null ? this.underlyingType()!.unpack() : null);
+ _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength());
+ _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength());
+ _o.declarationFile = this.declarationFile();
+}
+}
+
+export class EnumT {
+constructor(
+ public name: string|Uint8Array|null = null,
+ public values: (EnumValT)[] = [],
+ public isUnion: boolean = false,
+ public underlyingType: TypeT|null = null,
+ public attributes: (KeyValueT)[] = [],
+ public documentation: (string)[] = [],
+ public declarationFile: string|Uint8Array|null = null
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ const name = (this.name !== null ? builder.createString(this.name!) : 0);
+ const values = Enum.createValuesVector(builder, builder.createObjectOffsetList(this.values));
+ const underlyingType = (this.underlyingType !== null ? this.underlyingType!.pack(builder) : 0);
+ const attributes = Enum.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes));
+ const documentation = Enum.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation));
+ const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile!) : 0);
+
+ Enum.startEnum(builder);
+ Enum.addName(builder, name);
+ Enum.addValues(builder, values);
+ Enum.addIsUnion(builder, this.isUnion);
+ Enum.addUnderlyingType(builder, underlyingType);
+ Enum.addAttributes(builder, attributes);
+ Enum.addDocumentation(builder, documentation);
+ Enum.addDeclarationFile(builder, declarationFile);
+
+ return Enum.endEnum(builder);
+}
+}
+
+export class Field {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):Field {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsField(bb:flatbuffers.ByteBuffer, obj?:Field):Field {
+ return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsField(bb:flatbuffers.ByteBuffer, obj?:Field):Field {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+name():string|null
+name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+name(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+type(obj?:Type):Type|null {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? (obj || new Type()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
+}
+
+id():number {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
+}
+
+mutate_id(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint16(this.bb_pos + offset, value);
+ return true;
+}
+
+offset():number {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
+}
+
+mutate_offset(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint16(this.bb_pos + offset, value);
+ return true;
+}
+
+defaultInteger():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
+}
+
+mutate_default_integer(value:bigint):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt64(this.bb_pos + offset, value);
+ return true;
+}
+
+defaultReal():number {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0;
+}
+
+mutate_default_real(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeFloat64(this.bb_pos + offset, value);
+ return true;
+}
+
+deprecated():boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 16);
+ return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
+}
+
+mutate_deprecated(value:boolean):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 16);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt8(this.bb_pos + offset, +value);
+ return true;
+}
+
+required():boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 18);
+ return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
+}
+
+mutate_required(value:boolean):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 18);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt8(this.bb_pos + offset, +value);
+ return true;
+}
+
+key():boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 20);
+ return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
+}
+
+mutate_key(value:boolean):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 20);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt8(this.bb_pos + offset, +value);
+ return true;
+}
+
+attributes(index: number, obj?:KeyValue):KeyValue|null {
+ const offset = this.bb!.__offset(this.bb_pos, 22);
+ return offset ? (obj || new KeyValue()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+attributesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 22);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+documentation(index: number):string
+documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array
+documentation(index: number,optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 24);
+ return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+}
+
+documentationLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 24);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+optional():boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 26);
+ return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
+}
+
+mutate_optional(value:boolean):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 26);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt8(this.bb_pos + offset, +value);
+ return true;
+}
+
+/**
+ * Number of padding octets to always add after this field. Structs only.
+ */
+padding():number {
+ const offset = this.bb!.__offset(this.bb_pos, 28);
+ return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
+}
+
+mutate_padding(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 28);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint16(this.bb_pos + offset, value);
+ return true;
+}
+
+static getFullyQualifiedName():string {
+ return 'reflection_Field';
+}
+
+static startField(builder:flatbuffers.Builder) {
+ builder.startObject(13);
+}
+
+static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(0, nameOffset, 0);
+}
+
+static addType(builder:flatbuffers.Builder, typeOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(1, typeOffset, 0);
+}
+
+static addId(builder:flatbuffers.Builder, id:number) {
+ builder.addFieldInt16(2, id, 0);
+}
+
+static addOffset(builder:flatbuffers.Builder, offset:number) {
+ builder.addFieldInt16(3, offset, 0);
+}
+
+static addDefaultInteger(builder:flatbuffers.Builder, defaultInteger:bigint) {
+ builder.addFieldInt64(4, defaultInteger, BigInt('0'));
+}
+
+static addDefaultReal(builder:flatbuffers.Builder, defaultReal:number) {
+ builder.addFieldFloat64(5, defaultReal, 0.0);
+}
+
+static addDeprecated(builder:flatbuffers.Builder, deprecated:boolean) {
+ builder.addFieldInt8(6, +deprecated, +false);
+}
+
+static addRequired(builder:flatbuffers.Builder, required:boolean) {
+ builder.addFieldInt8(7, +required, +false);
+}
+
+static addKey(builder:flatbuffers.Builder, key:boolean) {
+ builder.addFieldInt8(8, +key, +false);
+}
+
+static addAttributes(builder:flatbuffers.Builder, attributesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(9, attributesOffset, 0);
+}
+
+static createAttributesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startAttributesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(10, documentationOffset, 0);
+}
+
+static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addOptional(builder:flatbuffers.Builder, optional:boolean) {
+ builder.addFieldInt8(11, +optional, +false);
+}
+
+static addPadding(builder:flatbuffers.Builder, padding:number) {
+ builder.addFieldInt16(12, padding, 0);
+}
+
+static endField(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4) // name
+ builder.requiredField(offset, 6) // type
+ return offset;
+}
+
+
+unpack(): FieldT {
+ return new FieldT(
+ this.name(),
+ (this.type() !== null ? this.type()!.unpack() : null),
+ this.id(),
+ this.offset(),
+ this.defaultInteger(),
+ this.defaultReal(),
+ this.deprecated(),
+ this.required(),
+ this.key(),
+ this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()),
+ this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()),
+ this.optional(),
+ this.padding()
+ );
+}
+
+
+unpackTo(_o: FieldT): void {
+ _o.name = this.name();
+ _o.type = (this.type() !== null ? this.type()!.unpack() : null);
+ _o.id = this.id();
+ _o.offset = this.offset();
+ _o.defaultInteger = this.defaultInteger();
+ _o.defaultReal = this.defaultReal();
+ _o.deprecated = this.deprecated();
+ _o.required = this.required();
+ _o.key = this.key();
+ _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength());
+ _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength());
+ _o.optional = this.optional();
+ _o.padding = this.padding();
+}
+}
+
+export class FieldT {
+constructor(
+ public name: string|Uint8Array|null = null,
+ public type: TypeT|null = null,
+ public id: number = 0,
+ public offset: number = 0,
+ public defaultInteger: bigint = BigInt('0'),
+ public defaultReal: number = 0.0,
+ public deprecated: boolean = false,
+ public required: boolean = false,
+ public key: boolean = false,
+ public attributes: (KeyValueT)[] = [],
+ public documentation: (string)[] = [],
+ public optional: boolean = false,
+ public padding: number = 0
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ const name = (this.name !== null ? builder.createString(this.name!) : 0);
+ const type = (this.type !== null ? this.type!.pack(builder) : 0);
+ const attributes = Field.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes));
+ const documentation = Field.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation));
+
+ Field.startField(builder);
+ Field.addName(builder, name);
+ Field.addType(builder, type);
+ Field.addId(builder, this.id);
+ Field.addOffset(builder, this.offset);
+ Field.addDefaultInteger(builder, this.defaultInteger);
+ Field.addDefaultReal(builder, this.defaultReal);
+ Field.addDeprecated(builder, this.deprecated);
+ Field.addRequired(builder, this.required);
+ Field.addKey(builder, this.key);
+ Field.addAttributes(builder, attributes);
+ Field.addDocumentation(builder, documentation);
+ Field.addOptional(builder, this.optional);
+ Field.addPadding(builder, this.padding);
+
+ return Field.endField(builder);
+}
+}
+
+export class Object_ {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):Object_ {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsObject(bb:flatbuffers.ByteBuffer, obj?:Object_):Object_ {
+ return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsObject(bb:flatbuffers.ByteBuffer, obj?:Object_):Object_ {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+name():string|null
+name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+name(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+fields(index: number, obj?:Field):Field|null {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? (obj || new Field()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+fieldsLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+isStruct():boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
+}
+
+mutate_is_struct(value:boolean):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt8(this.bb_pos + offset, +value);
+ return true;
+}
+
+minalign():number {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
+}
+
+mutate_minalign(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt32(this.bb_pos + offset, value);
+ return true;
+}
+
+bytesize():number {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
+}
+
+mutate_bytesize(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt32(this.bb_pos + offset, value);
+ return true;
+}
+
+attributes(index: number, obj?:KeyValue):KeyValue|null {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? (obj || new KeyValue()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+attributesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+documentation(index: number):string
+documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array
+documentation(index: number,optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 16);
+ return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+}
+
+documentationLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 16);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+/**
+ * File that this Object is declared in.
+ */
+declarationFile():string|null
+declarationFile(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+declarationFile(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 18);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+static getFullyQualifiedName():string {
+ return 'reflection_Object';
+}
+
+static startObject(builder:flatbuffers.Builder) {
+ builder.startObject(8);
+}
+
+static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(0, nameOffset, 0);
+}
+
+static addFields(builder:flatbuffers.Builder, fieldsOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(1, fieldsOffset, 0);
+}
+
+static createFieldsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startFieldsVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addIsStruct(builder:flatbuffers.Builder, isStruct:boolean) {
+ builder.addFieldInt8(2, +isStruct, +false);
+}
+
+static addMinalign(builder:flatbuffers.Builder, minalign:number) {
+ builder.addFieldInt32(3, minalign, 0);
+}
+
+static addBytesize(builder:flatbuffers.Builder, bytesize:number) {
+ builder.addFieldInt32(4, bytesize, 0);
+}
+
+static addAttributes(builder:flatbuffers.Builder, attributesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(5, attributesOffset, 0);
+}
+
+static createAttributesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startAttributesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(6, documentationOffset, 0);
+}
+
+static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addDeclarationFile(builder:flatbuffers.Builder, declarationFileOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(7, declarationFileOffset, 0);
+}
+
+static endObject(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4) // name
+ builder.requiredField(offset, 6) // fields
+ return offset;
+}
+
+static createObject(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset, fieldsOffset:flatbuffers.Offset, isStruct:boolean, minalign:number, bytesize:number, attributesOffset:flatbuffers.Offset, documentationOffset:flatbuffers.Offset, declarationFileOffset:flatbuffers.Offset):flatbuffers.Offset {
+ Object_.startObject(builder);
+ Object_.addName(builder, nameOffset);
+ Object_.addFields(builder, fieldsOffset);
+ Object_.addIsStruct(builder, isStruct);
+ Object_.addMinalign(builder, minalign);
+ Object_.addBytesize(builder, bytesize);
+ Object_.addAttributes(builder, attributesOffset);
+ Object_.addDocumentation(builder, documentationOffset);
+ Object_.addDeclarationFile(builder, declarationFileOffset);
+ return Object_.endObject(builder);
+}
+
+unpack(): Object_T {
+ return new Object_T(
+ this.name(),
+ this.bb!.createObjList(this.fields.bind(this), this.fieldsLength()),
+ this.isStruct(),
+ this.minalign(),
+ this.bytesize(),
+ this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()),
+ this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()),
+ this.declarationFile()
+ );
+}
+
+
+unpackTo(_o: Object_T): void {
+ _o.name = this.name();
+ _o.fields = this.bb!.createObjList(this.fields.bind(this), this.fieldsLength());
+ _o.isStruct = this.isStruct();
+ _o.minalign = this.minalign();
+ _o.bytesize = this.bytesize();
+ _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength());
+ _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength());
+ _o.declarationFile = this.declarationFile();
+}
+}
+
+export class Object_T {
+constructor(
+ public name: string|Uint8Array|null = null,
+ public fields: (FieldT)[] = [],
+ public isStruct: boolean = false,
+ public minalign: number = 0,
+ public bytesize: number = 0,
+ public attributes: (KeyValueT)[] = [],
+ public documentation: (string)[] = [],
+ public declarationFile: string|Uint8Array|null = null
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ const name = (this.name !== null ? builder.createString(this.name!) : 0);
+ const fields = Object_.createFieldsVector(builder, builder.createObjectOffsetList(this.fields));
+ const attributes = Object_.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes));
+ const documentation = Object_.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation));
+ const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile!) : 0);
+
+ return Object_.createObject(builder,
+ name,
+ fields,
+ this.isStruct,
+ this.minalign,
+ this.bytesize,
+ attributes,
+ documentation,
+ declarationFile
+ );
+}
+}
+
+export class RPCCall {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):RPCCall {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsRPCCall(bb:flatbuffers.ByteBuffer, obj?:RPCCall):RPCCall {
+ return (obj || new RPCCall()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsRPCCall(bb:flatbuffers.ByteBuffer, obj?:RPCCall):RPCCall {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new RPCCall()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+name():string|null
+name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+name(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+request(obj?:Object_):Object_|null {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? (obj || new Object_()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
+}
+
+response(obj?:Object_):Object_|null {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? (obj || new Object_()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
+}
+
+attributes(index: number, obj?:KeyValue):KeyValue|null {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? (obj || new KeyValue()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+attributesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+documentation(index: number):string
+documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array
+documentation(index: number,optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+}
+
+documentationLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+static getFullyQualifiedName():string {
+ return 'reflection_RPCCall';
+}
+
+static startRPCCall(builder:flatbuffers.Builder) {
+ builder.startObject(5);
+}
+
+static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(0, nameOffset, 0);
+}
+
+static addRequest(builder:flatbuffers.Builder, requestOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(1, requestOffset, 0);
+}
+
+static addResponse(builder:flatbuffers.Builder, responseOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(2, responseOffset, 0);
+}
+
+static addAttributes(builder:flatbuffers.Builder, attributesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(3, attributesOffset, 0);
+}
+
+static createAttributesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startAttributesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(4, documentationOffset, 0);
+}
+
+static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static endRPCCall(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4) // name
+ builder.requiredField(offset, 6) // request
+ builder.requiredField(offset, 8) // response
+ return offset;
+}
+
+
+unpack(): RPCCallT {
+ return new RPCCallT(
+ this.name(),
+ (this.request() !== null ? this.request()!.unpack() : null),
+ (this.response() !== null ? this.response()!.unpack() : null),
+ this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()),
+ this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength())
+ );
+}
+
+
+unpackTo(_o: RPCCallT): void {
+ _o.name = this.name();
+ _o.request = (this.request() !== null ? this.request()!.unpack() : null);
+ _o.response = (this.response() !== null ? this.response()!.unpack() : null);
+ _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength());
+ _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength());
+}
+}
+
+export class RPCCallT {
+constructor(
+ public name: string|Uint8Array|null = null,
+ public request: Object_T|null = null,
+ public response: Object_T|null = null,
+ public attributes: (KeyValueT)[] = [],
+ public documentation: (string)[] = []
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ const name = (this.name !== null ? builder.createString(this.name!) : 0);
+ const request = (this.request !== null ? this.request!.pack(builder) : 0);
+ const response = (this.response !== null ? this.response!.pack(builder) : 0);
+ const attributes = RPCCall.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes));
+ const documentation = RPCCall.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation));
+
+ RPCCall.startRPCCall(builder);
+ RPCCall.addName(builder, name);
+ RPCCall.addRequest(builder, request);
+ RPCCall.addResponse(builder, response);
+ RPCCall.addAttributes(builder, attributes);
+ RPCCall.addDocumentation(builder, documentation);
+
+ return RPCCall.endRPCCall(builder);
+}
+}
+
+export class Service {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):Service {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsService(bb:flatbuffers.ByteBuffer, obj?:Service):Service {
+ return (obj || new Service()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsService(bb:flatbuffers.ByteBuffer, obj?:Service):Service {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Service()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+name():string|null
+name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+name(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+calls(index: number, obj?:RPCCall):RPCCall|null {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? (obj || new RPCCall()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+callsLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+attributes(index: number, obj?:KeyValue):KeyValue|null {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? (obj || new KeyValue()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+attributesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+documentation(index: number):string
+documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array
+documentation(index: number,optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+}
+
+documentationLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+/**
+ * File that this Service is declared in.
+ */
+declarationFile():string|null
+declarationFile(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+declarationFile(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+static getFullyQualifiedName():string {
+ return 'reflection_Service';
+}
+
+static startService(builder:flatbuffers.Builder) {
+ builder.startObject(5);
+}
+
+static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(0, nameOffset, 0);
+}
+
+static addCalls(builder:flatbuffers.Builder, callsOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(1, callsOffset, 0);
+}
+
+static createCallsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startCallsVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addAttributes(builder:flatbuffers.Builder, attributesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(2, attributesOffset, 0);
+}
+
+static createAttributesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startAttributesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(3, documentationOffset, 0);
+}
+
+static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addDeclarationFile(builder:flatbuffers.Builder, declarationFileOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(4, declarationFileOffset, 0);
+}
+
+static endService(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4) // name
+ return offset;
+}
+
+static createService(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset, callsOffset:flatbuffers.Offset, attributesOffset:flatbuffers.Offset, documentationOffset:flatbuffers.Offset, declarationFileOffset:flatbuffers.Offset):flatbuffers.Offset {
+ Service.startService(builder);
+ Service.addName(builder, nameOffset);
+ Service.addCalls(builder, callsOffset);
+ Service.addAttributes(builder, attributesOffset);
+ Service.addDocumentation(builder, documentationOffset);
+ Service.addDeclarationFile(builder, declarationFileOffset);
+ return Service.endService(builder);
+}
+
+unpack(): ServiceT {
+ return new ServiceT(
+ this.name(),
+ this.bb!.createObjList(this.calls.bind(this), this.callsLength()),
+ this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()),
+ this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()),
+ this.declarationFile()
+ );
+}
+
+
+unpackTo(_o: ServiceT): void {
+ _o.name = this.name();
+ _o.calls = this.bb!.createObjList(this.calls.bind(this), this.callsLength());
+ _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength());
+ _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength());
+ _o.declarationFile = this.declarationFile();
+}
+}
+
+export class ServiceT {
+constructor(
+ public name: string|Uint8Array|null = null,
+ public calls: (RPCCallT)[] = [],
+ public attributes: (KeyValueT)[] = [],
+ public documentation: (string)[] = [],
+ public declarationFile: string|Uint8Array|null = null
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ const name = (this.name !== null ? builder.createString(this.name!) : 0);
+ const calls = Service.createCallsVector(builder, builder.createObjectOffsetList(this.calls));
+ const attributes = Service.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes));
+ const documentation = Service.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation));
+ const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile!) : 0);
+
+ return Service.createService(builder,
+ name,
+ calls,
+ attributes,
+ documentation,
+ declarationFile
+ );
+}
+}
+
+/**
+ * File specific information.
+ * Symbols declared within a file may be recovered by iterating over all
+ * symbols and examining the `declaration_file` field.
+ */
+export class SchemaFile {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):SchemaFile {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsSchemaFile(bb:flatbuffers.ByteBuffer, obj?:SchemaFile):SchemaFile {
+ return (obj || new SchemaFile()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsSchemaFile(bb:flatbuffers.ByteBuffer, obj?:SchemaFile):SchemaFile {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new SchemaFile()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+/**
+ * Filename, relative to project root.
+ */
+filename():string|null
+filename(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+filename(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+/**
+ * Names of included files, relative to project root.
+ */
+includedFilenames(index: number):string
+includedFilenames(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array
+includedFilenames(index: number,optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+}
+
+includedFilenamesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+static getFullyQualifiedName():string {
+ return 'reflection_SchemaFile';
+}
+
+static startSchemaFile(builder:flatbuffers.Builder) {
+ builder.startObject(2);
+}
+
+static addFilename(builder:flatbuffers.Builder, filenameOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(0, filenameOffset, 0);
+}
+
+static addIncludedFilenames(builder:flatbuffers.Builder, includedFilenamesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(1, includedFilenamesOffset, 0);
+}
+
+static createIncludedFilenamesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startIncludedFilenamesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static endSchemaFile(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4) // filename
+ return offset;
+}
+
+static createSchemaFile(builder:flatbuffers.Builder, filenameOffset:flatbuffers.Offset, includedFilenamesOffset:flatbuffers.Offset):flatbuffers.Offset {
+ SchemaFile.startSchemaFile(builder);
+ SchemaFile.addFilename(builder, filenameOffset);
+ SchemaFile.addIncludedFilenames(builder, includedFilenamesOffset);
+ return SchemaFile.endSchemaFile(builder);
+}
+
+unpack(): SchemaFileT {
+ return new SchemaFileT(
+ this.filename(),
+ this.bb!.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength())
+ );
+}
+
+
+unpackTo(_o: SchemaFileT): void {
+ _o.filename = this.filename();
+ _o.includedFilenames = this.bb!.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength());
+}
+}
+
+export class SchemaFileT {
+constructor(
+ public filename: string|Uint8Array|null = null,
+ public includedFilenames: (string)[] = []
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ const filename = (this.filename !== null ? builder.createString(this.filename!) : 0);
+ const includedFilenames = SchemaFile.createIncludedFilenamesVector(builder, builder.createObjectOffsetList(this.includedFilenames));
+
+ return SchemaFile.createSchemaFile(builder,
+ filename,
+ includedFilenames
+ );
+}
+}
+
+export class Schema {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):Schema {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsSchema(bb:flatbuffers.ByteBuffer, obj?:Schema):Schema {
+ return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsSchema(bb:flatbuffers.ByteBuffer, obj?:Schema):Schema {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean {
+ return bb.__has_identifier('BFBS');
+}
+
+objects(index: number, obj?:Object_):Object_|null {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? (obj || new Object_()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+objectsLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+enums(index: number, obj?:Enum):Enum|null {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? (obj || new Enum()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+enumsLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+fileIdent():string|null
+fileIdent(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+fileIdent(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+fileExt():string|null
+fileExt(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+fileExt(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+rootTable(obj?:Object_):Object_|null {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? (obj || new Object_()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
+}
+
+services(index: number, obj?:Service):Service|null {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? (obj || new Service()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+servicesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+advancedFeatures():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 16);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
+}
+
+mutate_advanced_features(value:bigint):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 16);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint64(this.bb_pos + offset, value);
+ return true;
+}
+
+/**
+ * All the files used in this compilation. Files are relative to where
+ * flatc was invoked.
+ */
+fbsFiles(index: number, obj?:SchemaFile):SchemaFile|null {
+ const offset = this.bb!.__offset(this.bb_pos, 18);
+ return offset ? (obj || new SchemaFile()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+fbsFilesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 18);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+static getFullyQualifiedName():string {
+ return 'reflection_Schema';
+}
+
+static startSchema(builder:flatbuffers.Builder) {
+ builder.startObject(8);
+}
+
+static addObjects(builder:flatbuffers.Builder, objectsOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(0, objectsOffset, 0);
+}
+
+static createObjectsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startObjectsVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addEnums(builder:flatbuffers.Builder, enumsOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(1, enumsOffset, 0);
+}
+
+static createEnumsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startEnumsVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addFileIdent(builder:flatbuffers.Builder, fileIdentOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(2, fileIdentOffset, 0);
+}
+
+static addFileExt(builder:flatbuffers.Builder, fileExtOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(3, fileExtOffset, 0);
+}
+
+static addRootTable(builder:flatbuffers.Builder, rootTableOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(4, rootTableOffset, 0);
+}
+
+static addServices(builder:flatbuffers.Builder, servicesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(5, servicesOffset, 0);
+}
+
+static createServicesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startServicesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addAdvancedFeatures(builder:flatbuffers.Builder, advancedFeatures:bigint) {
+ builder.addFieldInt64(6, advancedFeatures, BigInt('0'));
+}
+
+static addFbsFiles(builder:flatbuffers.Builder, fbsFilesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(7, fbsFilesOffset, 0);
+}
+
+static createFbsFilesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startFbsFilesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static endSchema(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 4) // objects
+ builder.requiredField(offset, 6) // enums
+ return offset;
+}
+
+static finishSchemaBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
+ builder.finish(offset, 'BFBS');
+}
+
+static finishSizePrefixedSchemaBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
+ builder.finish(offset, 'BFBS', true);
+}
+
+
+unpack(): SchemaT {
+ return new SchemaT(
+ this.bb!.createObjList(this.objects.bind(this), this.objectsLength()),
+ this.bb!.createObjList(this.enums.bind(this), this.enumsLength()),
+ this.fileIdent(),
+ this.fileExt(),
+ (this.rootTable() !== null ? this.rootTable()!.unpack() : null),
+ this.bb!.createObjList(this.services.bind(this), this.servicesLength()),
+ this.advancedFeatures(),
+ this.bb!.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength())
+ );
+}
+
+
+unpackTo(_o: SchemaT): void {
+ _o.objects = this.bb!.createObjList(this.objects.bind(this), this.objectsLength());
+ _o.enums = this.bb!.createObjList(this.enums.bind(this), this.enumsLength());
+ _o.fileIdent = this.fileIdent();
+ _o.fileExt = this.fileExt();
+ _o.rootTable = (this.rootTable() !== null ? this.rootTable()!.unpack() : null);
+ _o.services = this.bb!.createObjList(this.services.bind(this), this.servicesLength());
+ _o.advancedFeatures = this.advancedFeatures();
+ _o.fbsFiles = this.bb!.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength());
+}
+}
+
+export class SchemaT {
+constructor(
+ public objects: (Object_T)[] = [],
+ public enums: (EnumT)[] = [],
+ public fileIdent: string|Uint8Array|null = null,
+ public fileExt: string|Uint8Array|null = null,
+ public rootTable: Object_T|null = null,
+ public services: (ServiceT)[] = [],
+ public advancedFeatures: bigint = BigInt('0'),
+ public fbsFiles: (SchemaFileT)[] = []
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ const objects = Schema.createObjectsVector(builder, builder.createObjectOffsetList(this.objects));
+ const enums = Schema.createEnumsVector(builder, builder.createObjectOffsetList(this.enums));
+ const fileIdent = (this.fileIdent !== null ? builder.createString(this.fileIdent!) : 0);
+ const fileExt = (this.fileExt !== null ? builder.createString(this.fileExt!) : 0);
+ const rootTable = (this.rootTable !== null ? this.rootTable!.pack(builder) : 0);
+ const services = Schema.createServicesVector(builder, builder.createObjectOffsetList(this.services));
+ const fbsFiles = Schema.createFbsFilesVector(builder, builder.createObjectOffsetList(this.fbsFiles));
+
+ Schema.startSchema(builder);
+ Schema.addObjects(builder, objects);
+ Schema.addEnums(builder, enums);
+ Schema.addFileIdent(builder, fileIdent);
+ Schema.addFileExt(builder, fileExt);
+ Schema.addRootTable(builder, rootTable);
+ Schema.addServices(builder, services);
+ Schema.addAdvancedFeatures(builder, this.advancedFeatures);
+ Schema.addFbsFiles(builder, fbsFiles);
+
+ return Schema.endSchema(builder);
+}
+}
+
diff --git a/tests/test_dir/BUILD.bazel b/tests/ts/test_dir/BUILD.bazel
similarity index 86%
rename from tests/test_dir/BUILD.bazel
rename to tests/ts/test_dir/BUILD.bazel
index 6140d28..8b0acca 100644
--- a/tests/test_dir/BUILD.bazel
+++ b/tests/ts/test_dir/BUILD.bazel
@@ -1,4 +1,4 @@
-load("//:build_defs.bzl", "flatbuffer_ts_library")
+load("//:typescript.bzl", "flatbuffer_ts_library")
flatbuffer_ts_library(
name = "typescript_transitive_ts_fbs",
diff --git a/tests/test_dir/typescript_include.fbs b/tests/ts/test_dir/typescript_include.fbs
similarity index 100%
rename from tests/test_dir/typescript_include.fbs
rename to tests/ts/test_dir/typescript_include.fbs
diff --git a/tests/test_dir/typescript_transitive_include.fbs b/tests/ts/test_dir/typescript_transitive_include.fbs
similarity index 100%
rename from tests/test_dir/typescript_transitive_include.fbs
rename to tests/ts/test_dir/typescript_transitive_include.fbs
diff --git a/tests/ts/ts-flat-files/monster_test_generated.ts b/tests/ts/ts-flat-files/monster_test_generated.ts
new file mode 100644
index 0000000..8a768f2
--- /dev/null
+++ b/tests/ts/ts-flat-files/monster_test_generated.ts
@@ -0,0 +1,1830 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+export enum MyGame_OtherNameSpace_FromInclude {
+ IncludeVal = '0'
+}
+
+/**
+ * Composite components of Monster color.
+ */
+export enum MyGame_Example_Color {
+ Red = 1,
+
+ /**
+ * \brief color Green
+ * Green is bit_flag with value (1u << 1)
+ */
+ Green = 2,
+
+ /**
+ * \brief color Blue (1u << 3)
+ */
+ Blue = 8
+}
+
+export enum MyGame_Example_Race {
+ None = -1,
+ Human = 0,
+ Dwarf = 1,
+ Elf = 2
+}
+
+export enum MyGame_Example_LongEnum {
+ LongOne = '2',
+ LongTwo = '4',
+ LongBig = '1099511627776'
+}
+
+export enum MyGame_Example_Any {
+ NONE = 0,
+ Monster = 1,
+ TestSimpleTableWithEnum = 2,
+ MyGame_Example2_Monster = 3
+}
+
+export function unionToAny(
+ type: MyGame_Example_Any,
+ accessor: (obj:MyGame_Example2_Monster|MyGame_Example_Monster|MyGame_Example_TestSimpleTableWithEnum) => MyGame_Example2_Monster|MyGame_Example_Monster|MyGame_Example_TestSimpleTableWithEnum|null
+): MyGame_Example2_Monster|MyGame_Example_Monster|MyGame_Example_TestSimpleTableWithEnum|null {
+ switch(MyGame_Example_Any[type]) {
+ case 'NONE': return null;
+ case 'Monster': return accessor(new MyGame_Example_Monster())! as MyGame_Example_Monster;
+ case 'TestSimpleTableWithEnum': return accessor(new MyGame_Example_TestSimpleTableWithEnum())! as MyGame_Example_TestSimpleTableWithEnum;
+ case 'MyGame_Example2_Monster': return accessor(new MyGame_Example2_Monster())! as MyGame_Example2_Monster;
+ default: return null;
+ }
+}
+
+export function unionListToAny(
+ type: MyGame_Example_Any,
+ accessor: (index: number, obj:MyGame_Example2_Monster|MyGame_Example_Monster|MyGame_Example_TestSimpleTableWithEnum) => MyGame_Example2_Monster|MyGame_Example_Monster|MyGame_Example_TestSimpleTableWithEnum|null,
+ index: number
+): MyGame_Example2_Monster|MyGame_Example_Monster|MyGame_Example_TestSimpleTableWithEnum|null {
+ switch(MyGame_Example_Any[type]) {
+ case 'NONE': return null;
+ case 'Monster': return accessor(index, new MyGame_Example_Monster())! as MyGame_Example_Monster;
+ case 'TestSimpleTableWithEnum': return accessor(index, new MyGame_Example_TestSimpleTableWithEnum())! as MyGame_Example_TestSimpleTableWithEnum;
+ case 'MyGame_Example2_Monster': return accessor(index, new MyGame_Example2_Monster())! as MyGame_Example2_Monster;
+ default: return null;
+ }
+}
+
+export enum MyGame_Example_AnyUniqueAliases {
+ NONE = 0,
+ M = 1,
+ TS = 2,
+ M2 = 3
+}
+
+export function unionToAnyUniqueAliases(
+ type: MyGame_Example_AnyUniqueAliases,
+ accessor: (obj:MyGame_Example2_Monster|MyGame_Example_Monster|MyGame_Example_TestSimpleTableWithEnum) => MyGame_Example2_Monster|MyGame_Example_Monster|MyGame_Example_TestSimpleTableWithEnum|null
+): MyGame_Example2_Monster|MyGame_Example_Monster|MyGame_Example_TestSimpleTableWithEnum|null {
+ switch(MyGame_Example_AnyUniqueAliases[type]) {
+ case 'NONE': return null;
+ case 'M': return accessor(new MyGame_Example_Monster())! as MyGame_Example_Monster;
+ case 'TS': return accessor(new MyGame_Example_TestSimpleTableWithEnum())! as MyGame_Example_TestSimpleTableWithEnum;
+ case 'M2': return accessor(new MyGame_Example2_Monster())! as MyGame_Example2_Monster;
+ default: return null;
+ }
+}
+
+export function unionListToAnyUniqueAliases(
+ type: MyGame_Example_AnyUniqueAliases,
+ accessor: (index: number, obj:MyGame_Example2_Monster|MyGame_Example_Monster|MyGame_Example_TestSimpleTableWithEnum) => MyGame_Example2_Monster|MyGame_Example_Monster|MyGame_Example_TestSimpleTableWithEnum|null,
+ index: number
+): MyGame_Example2_Monster|MyGame_Example_Monster|MyGame_Example_TestSimpleTableWithEnum|null {
+ switch(MyGame_Example_AnyUniqueAliases[type]) {
+ case 'NONE': return null;
+ case 'M': return accessor(index, new MyGame_Example_Monster())! as MyGame_Example_Monster;
+ case 'TS': return accessor(index, new MyGame_Example_TestSimpleTableWithEnum())! as MyGame_Example_TestSimpleTableWithEnum;
+ case 'M2': return accessor(index, new MyGame_Example2_Monster())! as MyGame_Example2_Monster;
+ default: return null;
+ }
+}
+
+export enum MyGame_Example_AnyAmbiguousAliases {
+ NONE = 0,
+ M1 = 1,
+ M2 = 2,
+ M3 = 3
+}
+
+export function unionToAnyAmbiguousAliases(
+ type: MyGame_Example_AnyAmbiguousAliases,
+ accessor: (obj:MyGame_Example_Monster) => MyGame_Example_Monster|null
+): MyGame_Example_Monster|null {
+ switch(MyGame_Example_AnyAmbiguousAliases[type]) {
+ case 'NONE': return null;
+ case 'M1': return accessor(new MyGame_Example_Monster())! as MyGame_Example_Monster;
+ case 'M2': return accessor(new MyGame_Example_Monster())! as MyGame_Example_Monster;
+ case 'M3': return accessor(new MyGame_Example_Monster())! as MyGame_Example_Monster;
+ default: return null;
+ }
+}
+
+export function unionListToAnyAmbiguousAliases(
+ type: MyGame_Example_AnyAmbiguousAliases,
+ accessor: (index: number, obj:MyGame_Example_Monster) => MyGame_Example_Monster|null,
+ index: number
+): MyGame_Example_Monster|null {
+ switch(MyGame_Example_AnyAmbiguousAliases[type]) {
+ case 'NONE': return null;
+ case 'M1': return accessor(index, new MyGame_Example_Monster())! as MyGame_Example_Monster;
+ case 'M2': return accessor(index, new MyGame_Example_Monster())! as MyGame_Example_Monster;
+ case 'M3': return accessor(index, new MyGame_Example_Monster())! as MyGame_Example_Monster;
+ default: return null;
+ }
+}
+
+export class MyGame_OtherNameSpace_Unused {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_OtherNameSpace_Unused {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+a():number {
+ return this.bb!.readInt32(this.bb_pos);
+}
+
+static sizeOf():number {
+ return 4;
+}
+
+static createUnused(builder:flatbuffers.Builder, a: number):flatbuffers.Offset {
+ builder.prep(4, 4);
+ builder.writeInt32(a);
+ return builder.offset();
+}
+
+}
+
+export class MyGame_OtherNameSpace_TableB {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_OtherNameSpace_TableB {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsTableB(bb:flatbuffers.ByteBuffer, obj?:MyGame_OtherNameSpace_TableB):MyGame_OtherNameSpace_TableB {
+ return (obj || new MyGame_OtherNameSpace_TableB()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsTableB(bb:flatbuffers.ByteBuffer, obj?:MyGame_OtherNameSpace_TableB):MyGame_OtherNameSpace_TableB {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new MyGame_OtherNameSpace_TableB()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+a(obj?:TableA):TableA|null {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? (obj || new TableA()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
+}
+
+static startTableB(builder:flatbuffers.Builder) {
+ builder.startObject(1);
+}
+
+static addA(builder:flatbuffers.Builder, aOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(0, aOffset, 0);
+}
+
+static endTableB(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+static createTableB(builder:flatbuffers.Builder, aOffset:flatbuffers.Offset):flatbuffers.Offset {
+ MyGame_OtherNameSpace_TableB.startTableB(builder);
+ MyGame_OtherNameSpace_TableB.addA(builder, aOffset);
+ return MyGame_OtherNameSpace_TableB.endTableB(builder);
+}
+
+serialize():Uint8Array {
+ return this.bb!.bytes();
+}
+
+static deserialize(buffer: Uint8Array):TableB {
+ return MyGame_OtherNameSpace_TableB.getRootAsTableB(new flatbuffers.ByteBuffer(buffer))
+}
+}
+
+export class TableA {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):TableA {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsTableA(bb:flatbuffers.ByteBuffer, obj?:TableA):TableA {
+ return (obj || new TableA()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsTableA(bb:flatbuffers.ByteBuffer, obj?:TableA):TableA {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new TableA()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+b(obj?:MyGame_OtherNameSpace_TableB):MyGame_OtherNameSpace_TableB|null {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? (obj || new MyGame_OtherNameSpace_TableB()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
+}
+
+static startTableA(builder:flatbuffers.Builder) {
+ builder.startObject(1);
+}
+
+static addB(builder:flatbuffers.Builder, bOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(0, bOffset, 0);
+}
+
+static endTableA(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+static createTableA(builder:flatbuffers.Builder, bOffset:flatbuffers.Offset):flatbuffers.Offset {
+ TableA.startTableA(builder);
+ TableA.addB(builder, bOffset);
+ return TableA.endTableA(builder);
+}
+
+serialize():Uint8Array {
+ return this.bb!.bytes();
+}
+
+static deserialize(buffer: Uint8Array):TableA {
+ return TableA.getRootAsTableA(new flatbuffers.ByteBuffer(buffer))
+}
+}
+
+export class MyGame_InParentNamespace {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_InParentNamespace {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsInParentNamespace(bb:flatbuffers.ByteBuffer, obj?:MyGame_InParentNamespace):MyGame_InParentNamespace {
+ return (obj || new MyGame_InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsInParentNamespace(bb:flatbuffers.ByteBuffer, obj?:MyGame_InParentNamespace):MyGame_InParentNamespace {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new MyGame_InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static startInParentNamespace(builder:flatbuffers.Builder) {
+ builder.startObject(0);
+}
+
+static endInParentNamespace(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+static createInParentNamespace(builder:flatbuffers.Builder):flatbuffers.Offset {
+ MyGame_InParentNamespace.startInParentNamespace(builder);
+ return MyGame_InParentNamespace.endInParentNamespace(builder);
+}
+
+serialize():Uint8Array {
+ return this.bb!.bytes();
+}
+
+static deserialize(buffer: Uint8Array):InParentNamespace {
+ return MyGame_InParentNamespace.getRootAsInParentNamespace(new flatbuffers.ByteBuffer(buffer))
+}
+}
+
+export class MyGame_Example2_Monster {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_Example2_Monster {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:MyGame_Example2_Monster):MyGame_Example2_Monster {
+ return (obj || new MyGame_Example2_Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:MyGame_Example2_Monster):MyGame_Example2_Monster {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new MyGame_Example2_Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static startMonster(builder:flatbuffers.Builder) {
+ builder.startObject(0);
+}
+
+static endMonster(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+static createMonster(builder:flatbuffers.Builder):flatbuffers.Offset {
+ MyGame_Example2_Monster.startMonster(builder);
+ return MyGame_Example2_Monster.endMonster(builder);
+}
+
+serialize():Uint8Array {
+ return this.bb!.bytes();
+}
+
+static deserialize(buffer: Uint8Array):Monster {
+ return MyGame_Example2_Monster.getRootAsMonster(new flatbuffers.ByteBuffer(buffer))
+}
+}
+
+export class MyGame_Example_Test {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_Example_Test {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+a():number {
+ return this.bb!.readInt16(this.bb_pos);
+}
+
+b():number {
+ return this.bb!.readInt8(this.bb_pos + 2);
+}
+
+static sizeOf():number {
+ return 4;
+}
+
+static createTest(builder:flatbuffers.Builder, a: number, b: number):flatbuffers.Offset {
+ builder.prep(2, 4);
+ builder.pad(1);
+ builder.writeInt8(b);
+ builder.writeInt16(a);
+ return builder.offset();
+}
+
+}
+
+export class MyGame_Example_TestSimpleTableWithEnum {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_Example_TestSimpleTableWithEnum {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsTestSimpleTableWithEnum(bb:flatbuffers.ByteBuffer, obj?:MyGame_Example_TestSimpleTableWithEnum):MyGame_Example_TestSimpleTableWithEnum {
+ return (obj || new MyGame_Example_TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsTestSimpleTableWithEnum(bb:flatbuffers.ByteBuffer, obj?:MyGame_Example_TestSimpleTableWithEnum):MyGame_Example_TestSimpleTableWithEnum {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new MyGame_Example_TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+color():MyGame_Example_Color {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.readUint8(this.bb_pos + offset) : MyGame_Example_Color.Green;
+}
+
+static startTestSimpleTableWithEnum(builder:flatbuffers.Builder) {
+ builder.startObject(1);
+}
+
+static addColor(builder:flatbuffers.Builder, color:MyGame_Example_Color) {
+ builder.addFieldInt8(0, color, MyGame_Example_Color.Green);
+}
+
+static endTestSimpleTableWithEnum(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+static createTestSimpleTableWithEnum(builder:flatbuffers.Builder, color:MyGame_Example_Color):flatbuffers.Offset {
+ MyGame_Example_TestSimpleTableWithEnum.startTestSimpleTableWithEnum(builder);
+ MyGame_Example_TestSimpleTableWithEnum.addColor(builder, color);
+ return MyGame_Example_TestSimpleTableWithEnum.endTestSimpleTableWithEnum(builder);
+}
+
+serialize():Uint8Array {
+ return this.bb!.bytes();
+}
+
+static deserialize(buffer: Uint8Array):TestSimpleTableWithEnum {
+ return MyGame_Example_TestSimpleTableWithEnum.getRootAsTestSimpleTableWithEnum(new flatbuffers.ByteBuffer(buffer))
+}
+}
+
+export class MyGame_Example_Vec3 {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_Example_Vec3 {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+x():number {
+ return this.bb!.readFloat32(this.bb_pos);
+}
+
+y():number {
+ return this.bb!.readFloat32(this.bb_pos + 4);
+}
+
+z():number {
+ return this.bb!.readFloat32(this.bb_pos + 8);
+}
+
+test1():number {
+ return this.bb!.readFloat64(this.bb_pos + 16);
+}
+
+test2():MyGame_Example_Color {
+ return this.bb!.readUint8(this.bb_pos + 24);
+}
+
+test3(obj?:MyGame_Example_Test):MyGame_Example_Test|null {
+ return (obj || new MyGame_Example_Test()).__init(this.bb_pos + 26, this.bb!);
+}
+
+static sizeOf():number {
+ return 32;
+}
+
+static createVec3(builder:flatbuffers.Builder, x: number, y: number, z: number, test1: number, test2: MyGame_Example_Color, test3_a: number, test3_b: number):flatbuffers.Offset {
+ builder.prep(8, 32);
+ builder.pad(2);
+ builder.prep(2, 4);
+ builder.pad(1);
+ builder.writeInt8(test3_b);
+ builder.writeInt16(test3_a);
+ builder.pad(1);
+ builder.writeInt8(test2);
+ builder.writeFloat64(test1);
+ builder.pad(4);
+ builder.writeFloat32(z);
+ builder.writeFloat32(y);
+ builder.writeFloat32(x);
+ return builder.offset();
+}
+
+}
+
+export class MyGame_Example_Ability {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_Example_Ability {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+id():number {
+ return this.bb!.readUint32(this.bb_pos);
+}
+
+distance():number {
+ return this.bb!.readUint32(this.bb_pos + 4);
+}
+
+static sizeOf():number {
+ return 8;
+}
+
+static createAbility(builder:flatbuffers.Builder, id: number, distance: number):flatbuffers.Offset {
+ builder.prep(4, 8);
+ builder.writeInt32(distance);
+ builder.writeInt32(id);
+ return builder.offset();
+}
+
+}
+
+export class MyGame_Example_StructOfStructs {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_Example_StructOfStructs {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+a(obj?:MyGame_Example_Ability):MyGame_Example_Ability|null {
+ return (obj || new MyGame_Example_Ability()).__init(this.bb_pos, this.bb!);
+}
+
+b(obj?:MyGame_Example_Test):MyGame_Example_Test|null {
+ return (obj || new MyGame_Example_Test()).__init(this.bb_pos + 8, this.bb!);
+}
+
+c(obj?:MyGame_Example_Ability):MyGame_Example_Ability|null {
+ return (obj || new MyGame_Example_Ability()).__init(this.bb_pos + 12, this.bb!);
+}
+
+static sizeOf():number {
+ return 20;
+}
+
+static createStructOfStructs(builder:flatbuffers.Builder, a_id: number, a_distance: number, b_a: number, b_b: number, c_id: number, c_distance: number):flatbuffers.Offset {
+ builder.prep(4, 20);
+ builder.prep(4, 8);
+ builder.writeInt32(c_distance);
+ builder.writeInt32(c_id);
+ builder.prep(2, 4);
+ builder.pad(1);
+ builder.writeInt8(b_b);
+ builder.writeInt16(b_a);
+ builder.prep(4, 8);
+ builder.writeInt32(a_distance);
+ builder.writeInt32(a_id);
+ return builder.offset();
+}
+
+}
+
+export class MyGame_Example_StructOfStructsOfStructs {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_Example_StructOfStructsOfStructs {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+a(obj?:MyGame_Example_StructOfStructs):MyGame_Example_StructOfStructs|null {
+ return (obj || new MyGame_Example_StructOfStructs()).__init(this.bb_pos, this.bb!);
+}
+
+static sizeOf():number {
+ return 20;
+}
+
+static createStructOfStructsOfStructs(builder:flatbuffers.Builder, a_a_id: number, a_a_distance: number, a_b_a: number, a_b_b: number, a_c_id: number, a_c_distance: number):flatbuffers.Offset {
+ builder.prep(4, 20);
+ builder.prep(4, 20);
+ builder.prep(4, 8);
+ builder.writeInt32(a_c_distance);
+ builder.writeInt32(a_c_id);
+ builder.prep(2, 4);
+ builder.pad(1);
+ builder.writeInt8(a_b_b);
+ builder.writeInt16(a_b_a);
+ builder.prep(4, 8);
+ builder.writeInt32(a_a_distance);
+ builder.writeInt32(a_a_id);
+ return builder.offset();
+}
+
+}
+
+export class MyGame_Example_Stat {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_Example_Stat {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsStat(bb:flatbuffers.ByteBuffer, obj?:MyGame_Example_Stat):MyGame_Example_Stat {
+ return (obj || new MyGame_Example_Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsStat(bb:flatbuffers.ByteBuffer, obj?:MyGame_Example_Stat):MyGame_Example_Stat {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new MyGame_Example_Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+id():string|null
+id(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+id(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+val():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
+}
+
+count():number {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
+}
+
+static startStat(builder:flatbuffers.Builder) {
+ builder.startObject(3);
+}
+
+static addId(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(0, idOffset, 0);
+}
+
+static addVal(builder:flatbuffers.Builder, val:bigint) {
+ builder.addFieldInt64(1, val, BigInt('0'));
+}
+
+static addCount(builder:flatbuffers.Builder, count:number) {
+ builder.addFieldInt16(2, count, 0);
+}
+
+static endStat(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+static createStat(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset, val:bigint, count:number):flatbuffers.Offset {
+ MyGame_Example_Stat.startStat(builder);
+ MyGame_Example_Stat.addId(builder, idOffset);
+ MyGame_Example_Stat.addVal(builder, val);
+ MyGame_Example_Stat.addCount(builder, count);
+ return MyGame_Example_Stat.endStat(builder);
+}
+
+serialize():Uint8Array {
+ return this.bb!.bytes();
+}
+
+static deserialize(buffer: Uint8Array):Stat {
+ return MyGame_Example_Stat.getRootAsStat(new flatbuffers.ByteBuffer(buffer))
+}
+}
+
+export class MyGame_Example_Referrable {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_Example_Referrable {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsReferrable(bb:flatbuffers.ByteBuffer, obj?:MyGame_Example_Referrable):MyGame_Example_Referrable {
+ return (obj || new MyGame_Example_Referrable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsReferrable(bb:flatbuffers.ByteBuffer, obj?:MyGame_Example_Referrable):MyGame_Example_Referrable {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new MyGame_Example_Referrable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+id():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
+}
+
+static startReferrable(builder:flatbuffers.Builder) {
+ builder.startObject(1);
+}
+
+static addId(builder:flatbuffers.Builder, id:bigint) {
+ builder.addFieldInt64(0, id, BigInt('0'));
+}
+
+static endReferrable(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+static createReferrable(builder:flatbuffers.Builder, id:bigint):flatbuffers.Offset {
+ MyGame_Example_Referrable.startReferrable(builder);
+ MyGame_Example_Referrable.addId(builder, id);
+ return MyGame_Example_Referrable.endReferrable(builder);
+}
+
+serialize():Uint8Array {
+ return this.bb!.bytes();
+}
+
+static deserialize(buffer: Uint8Array):Referrable {
+ return MyGame_Example_Referrable.getRootAsReferrable(new flatbuffers.ByteBuffer(buffer))
+}
+}
+
+/**
+ * an example documentation comment: "monster object"
+ */
+export class MyGame_Example_Monster {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_Example_Monster {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:MyGame_Example_Monster):MyGame_Example_Monster {
+ return (obj || new MyGame_Example_Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:MyGame_Example_Monster):MyGame_Example_Monster {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new MyGame_Example_Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean {
+ return bb.__has_identifier('MONS');
+}
+
+pos(obj?:MyGame_Example_Vec3):MyGame_Example_Vec3|null {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? (obj || new MyGame_Example_Vec3()).__init(this.bb_pos + offset, this.bb!) : null;
+}
+
+mana():number {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.readInt16(this.bb_pos + offset) : 150;
+}
+
+hp():number {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? this.bb!.readInt16(this.bb_pos + offset) : 100;
+}
+
+name():string|null
+name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+name(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+inventory(index: number):number|null {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
+}
+
+inventoryLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+inventoryArray():Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
+}
+
+color():MyGame_Example_Color {
+ const offset = this.bb!.__offset(this.bb_pos, 16);
+ return offset ? this.bb!.readUint8(this.bb_pos + offset) : MyGame_Example_Color.Blue;
+}
+
+testType():MyGame_Example_Any {
+ const offset = this.bb!.__offset(this.bb_pos, 18);
+ return offset ? this.bb!.readUint8(this.bb_pos + offset) : MyGame_Example_Any.NONE;
+}
+
+test<T extends flatbuffers.Table>(obj:any):any|null {
+ const offset = this.bb!.__offset(this.bb_pos, 20);
+ return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null;
+}
+
+test4(index: number, obj?:MyGame_Example_Test):MyGame_Example_Test|null {
+ const offset = this.bb!.__offset(this.bb_pos, 22);
+ return offset ? (obj || new MyGame_Example_Test()).__init(this.bb!.__vector(this.bb_pos + offset) + index * 4, this.bb!) : null;
+}
+
+test4Length():number {
+ const offset = this.bb!.__offset(this.bb_pos, 22);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+testarrayofstring(index: number):string
+testarrayofstring(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array
+testarrayofstring(index: number,optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 24);
+ return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+}
+
+testarrayofstringLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 24);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+/**
+ * an example documentation comment: this will end up in the generated code
+ * multiline too
+ */
+testarrayoftables(index: number, obj?:MyGame_Example_Monster):MyGame_Example_Monster|null {
+ const offset = this.bb!.__offset(this.bb_pos, 26);
+ return offset ? (obj || new MyGame_Example_Monster()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+testarrayoftablesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 26);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+enemy(obj?:MyGame_Example_Monster):MyGame_Example_Monster|null {
+ const offset = this.bb!.__offset(this.bb_pos, 28);
+ return offset ? (obj || new MyGame_Example_Monster()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
+}
+
+testnestedflatbuffer(index: number):number|null {
+ const offset = this.bb!.__offset(this.bb_pos, 30);
+ return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
+}
+
+testnestedflatbufferLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 30);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+testnestedflatbufferArray():Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 30);
+ return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
+}
+
+testempty(obj?:MyGame_Example_Stat):MyGame_Example_Stat|null {
+ const offset = this.bb!.__offset(this.bb_pos, 32);
+ return offset ? (obj || new MyGame_Example_Stat()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
+}
+
+testbool():boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 34);
+ return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
+}
+
+testhashs32Fnv1():number {
+ const offset = this.bb!.__offset(this.bb_pos, 36);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
+}
+
+testhashu32Fnv1():number {
+ const offset = this.bb!.__offset(this.bb_pos, 38);
+ return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0;
+}
+
+testhashs64Fnv1():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 40);
+ return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
+}
+
+testhashu64Fnv1():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 42);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
+}
+
+testhashs32Fnv1a():number {
+ const offset = this.bb!.__offset(this.bb_pos, 44);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
+}
+
+testhashu32Fnv1a():number {
+ const offset = this.bb!.__offset(this.bb_pos, 46);
+ return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0;
+}
+
+testhashs64Fnv1a():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 48);
+ return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
+}
+
+testhashu64Fnv1a():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 50);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
+}
+
+testarrayofbools(index: number):boolean|null {
+ const offset = this.bb!.__offset(this.bb_pos, 52);
+ return offset ? !!this.bb!.readInt8(this.bb!.__vector(this.bb_pos + offset) + index) : false;
+}
+
+testarrayofboolsLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 52);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+testarrayofboolsArray():Int8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 52);
+ return offset ? new Int8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
+}
+
+testf():number {
+ const offset = this.bb!.__offset(this.bb_pos, 54);
+ return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 3.14159;
+}
+
+testf2():number {
+ const offset = this.bb!.__offset(this.bb_pos, 56);
+ return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 3.0;
+}
+
+testf3():number {
+ const offset = this.bb!.__offset(this.bb_pos, 58);
+ return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
+}
+
+testarrayofstring2(index: number):string
+testarrayofstring2(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array
+testarrayofstring2(index: number,optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 60);
+ return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
+}
+
+testarrayofstring2Length():number {
+ const offset = this.bb!.__offset(this.bb_pos, 60);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+testarrayofsortedstruct(index: number, obj?:MyGame_Example_Ability):MyGame_Example_Ability|null {
+ const offset = this.bb!.__offset(this.bb_pos, 62);
+ return offset ? (obj || new MyGame_Example_Ability()).__init(this.bb!.__vector(this.bb_pos + offset) + index * 8, this.bb!) : null;
+}
+
+testarrayofsortedstructLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 62);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+flex(index: number):number|null {
+ const offset = this.bb!.__offset(this.bb_pos, 64);
+ return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
+}
+
+flexLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 64);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+flexArray():Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 64);
+ return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
+}
+
+test5(index: number, obj?:MyGame_Example_Test):MyGame_Example_Test|null {
+ const offset = this.bb!.__offset(this.bb_pos, 66);
+ return offset ? (obj || new MyGame_Example_Test()).__init(this.bb!.__vector(this.bb_pos + offset) + index * 4, this.bb!) : null;
+}
+
+test5Length():number {
+ const offset = this.bb!.__offset(this.bb_pos, 66);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+vectorOfLongs(index: number):bigint|null {
+ const offset = this.bb!.__offset(this.bb_pos, 68);
+ return offset ? this.bb!.readInt64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : BigInt(0);
+}
+
+vectorOfLongsLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 68);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+vectorOfDoubles(index: number):number|null {
+ const offset = this.bb!.__offset(this.bb_pos, 70);
+ return offset ? this.bb!.readFloat64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : 0;
+}
+
+vectorOfDoublesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 70);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+vectorOfDoublesArray():Float64Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 70);
+ return offset ? new Float64Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
+}
+
+parentNamespaceTest(obj?:MyGame_InParentNamespace):MyGame_InParentNamespace|null {
+ const offset = this.bb!.__offset(this.bb_pos, 72);
+ return offset ? (obj || new MyGame_InParentNamespace()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
+}
+
+vectorOfReferrables(index: number, obj?:MyGame_Example_Referrable):MyGame_Example_Referrable|null {
+ const offset = this.bb!.__offset(this.bb_pos, 74);
+ return offset ? (obj || new MyGame_Example_Referrable()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+vectorOfReferrablesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 74);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+singleWeakReference():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 76);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
+}
+
+vectorOfWeakReferences(index: number):bigint|null {
+ const offset = this.bb!.__offset(this.bb_pos, 78);
+ return offset ? this.bb!.readUint64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : BigInt(0);
+}
+
+vectorOfWeakReferencesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 78);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+vectorOfStrongReferrables(index: number, obj?:MyGame_Example_Referrable):MyGame_Example_Referrable|null {
+ const offset = this.bb!.__offset(this.bb_pos, 80);
+ return offset ? (obj || new MyGame_Example_Referrable()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+vectorOfStrongReferrablesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 80);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+coOwningReference():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 82);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
+}
+
+vectorOfCoOwningReferences(index: number):bigint|null {
+ const offset = this.bb!.__offset(this.bb_pos, 84);
+ return offset ? this.bb!.readUint64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : BigInt(0);
+}
+
+vectorOfCoOwningReferencesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 84);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+nonOwningReference():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 86);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
+}
+
+vectorOfNonOwningReferences(index: number):bigint|null {
+ const offset = this.bb!.__offset(this.bb_pos, 88);
+ return offset ? this.bb!.readUint64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : BigInt(0);
+}
+
+vectorOfNonOwningReferencesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 88);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+anyUniqueType():MyGame_Example_AnyUniqueAliases {
+ const offset = this.bb!.__offset(this.bb_pos, 90);
+ return offset ? this.bb!.readUint8(this.bb_pos + offset) : MyGame_Example_AnyUniqueAliases.NONE;
+}
+
+anyUnique<T extends flatbuffers.Table>(obj:any):any|null {
+ const offset = this.bb!.__offset(this.bb_pos, 92);
+ return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null;
+}
+
+anyAmbiguousType():MyGame_Example_AnyAmbiguousAliases {
+ const offset = this.bb!.__offset(this.bb_pos, 94);
+ return offset ? this.bb!.readUint8(this.bb_pos + offset) : MyGame_Example_AnyAmbiguousAliases.NONE;
+}
+
+anyAmbiguous<T extends flatbuffers.Table>(obj:any):any|null {
+ const offset = this.bb!.__offset(this.bb_pos, 96);
+ return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null;
+}
+
+vectorOfEnums(index: number):MyGame_Example_Color|null {
+ const offset = this.bb!.__offset(this.bb_pos, 98);
+ return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
+}
+
+vectorOfEnumsLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 98);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+vectorOfEnumsArray():Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 98);
+ return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
+}
+
+signedEnum():MyGame_Example_Race {
+ const offset = this.bb!.__offset(this.bb_pos, 100);
+ return offset ? this.bb!.readInt8(this.bb_pos + offset) : MyGame_Example_Race.None;
+}
+
+testrequirednestedflatbuffer(index: number):number|null {
+ const offset = this.bb!.__offset(this.bb_pos, 102);
+ return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
+}
+
+testrequirednestedflatbufferLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 102);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+testrequirednestedflatbufferArray():Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 102);
+ return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
+}
+
+scalarKeySortedTables(index: number, obj?:MyGame_Example_Stat):MyGame_Example_Stat|null {
+ const offset = this.bb!.__offset(this.bb_pos, 104);
+ return offset ? (obj || new MyGame_Example_Stat()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
+}
+
+scalarKeySortedTablesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 104);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+nativeInline(obj?:MyGame_Example_Test):MyGame_Example_Test|null {
+ const offset = this.bb!.__offset(this.bb_pos, 106);
+ return offset ? (obj || new MyGame_Example_Test()).__init(this.bb_pos + offset, this.bb!) : null;
+}
+
+longEnumNonEnumDefault():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 108);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
+}
+
+longEnumNormalDefault():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 110);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('2');
+}
+
+static startMonster(builder:flatbuffers.Builder) {
+ builder.startObject(54);
+}
+
+static addPos(builder:flatbuffers.Builder, posOffset:flatbuffers.Offset) {
+ builder.addFieldStruct(0, posOffset, 0);
+}
+
+static addMana(builder:flatbuffers.Builder, mana:number) {
+ builder.addFieldInt16(1, mana, 150);
+}
+
+static addHp(builder:flatbuffers.Builder, hp:number) {
+ builder.addFieldInt16(2, hp, 100);
+}
+
+static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(3, nameOffset, 0);
+}
+
+static addInventory(builder:flatbuffers.Builder, inventoryOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(5, inventoryOffset, 0);
+}
+
+static createInventoryVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset {
+ builder.startVector(1, data.length, 1);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt8(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startInventoryVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(1, numElems, 1);
+}
+
+static addColor(builder:flatbuffers.Builder, color:MyGame_Example_Color) {
+ builder.addFieldInt8(6, color, MyGame_Example_Color.Blue);
+}
+
+static addTestType(builder:flatbuffers.Builder, testType:MyGame_Example_Any) {
+ builder.addFieldInt8(7, testType, MyGame_Example_Any.NONE);
+}
+
+static addTest(builder:flatbuffers.Builder, testOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(8, testOffset, 0);
+}
+
+static addTest4(builder:flatbuffers.Builder, test4Offset:flatbuffers.Offset) {
+ builder.addFieldOffset(9, test4Offset, 0);
+}
+
+static startTest4Vector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 2);
+}
+
+static addTestarrayofstring(builder:flatbuffers.Builder, testarrayofstringOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(10, testarrayofstringOffset, 0);
+}
+
+static createTestarrayofstringVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startTestarrayofstringVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addTestarrayoftables(builder:flatbuffers.Builder, testarrayoftablesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(11, testarrayoftablesOffset, 0);
+}
+
+static createTestarrayoftablesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startTestarrayoftablesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addEnemy(builder:flatbuffers.Builder, enemyOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(12, enemyOffset, 0);
+}
+
+static addTestnestedflatbuffer(builder:flatbuffers.Builder, testnestedflatbufferOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(13, testnestedflatbufferOffset, 0);
+}
+
+static createTestnestedflatbufferVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset {
+ builder.startVector(1, data.length, 1);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt8(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startTestnestedflatbufferVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(1, numElems, 1);
+}
+
+static addTestempty(builder:flatbuffers.Builder, testemptyOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(14, testemptyOffset, 0);
+}
+
+static addTestbool(builder:flatbuffers.Builder, testbool:boolean) {
+ builder.addFieldInt8(15, +testbool, +false);
+}
+
+static addTesthashs32Fnv1(builder:flatbuffers.Builder, testhashs32Fnv1:number) {
+ builder.addFieldInt32(16, testhashs32Fnv1, 0);
+}
+
+static addTesthashu32Fnv1(builder:flatbuffers.Builder, testhashu32Fnv1:number) {
+ builder.addFieldInt32(17, testhashu32Fnv1, 0);
+}
+
+static addTesthashs64Fnv1(builder:flatbuffers.Builder, testhashs64Fnv1:bigint) {
+ builder.addFieldInt64(18, testhashs64Fnv1, BigInt('0'));
+}
+
+static addTesthashu64Fnv1(builder:flatbuffers.Builder, testhashu64Fnv1:bigint) {
+ builder.addFieldInt64(19, testhashu64Fnv1, BigInt('0'));
+}
+
+static addTesthashs32Fnv1a(builder:flatbuffers.Builder, testhashs32Fnv1a:number) {
+ builder.addFieldInt32(20, testhashs32Fnv1a, 0);
+}
+
+static addTesthashu32Fnv1a(builder:flatbuffers.Builder, testhashu32Fnv1a:number) {
+ builder.addFieldInt32(21, testhashu32Fnv1a, 0);
+}
+
+static addTesthashs64Fnv1a(builder:flatbuffers.Builder, testhashs64Fnv1a:bigint) {
+ builder.addFieldInt64(22, testhashs64Fnv1a, BigInt('0'));
+}
+
+static addTesthashu64Fnv1a(builder:flatbuffers.Builder, testhashu64Fnv1a:bigint) {
+ builder.addFieldInt64(23, testhashu64Fnv1a, BigInt('0'));
+}
+
+static addTestarrayofbools(builder:flatbuffers.Builder, testarrayofboolsOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(24, testarrayofboolsOffset, 0);
+}
+
+static createTestarrayofboolsVector(builder:flatbuffers.Builder, data:boolean[]):flatbuffers.Offset {
+ builder.startVector(1, data.length, 1);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt8(+data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startTestarrayofboolsVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(1, numElems, 1);
+}
+
+static addTestf(builder:flatbuffers.Builder, testf:number) {
+ builder.addFieldFloat32(25, testf, 3.14159);
+}
+
+static addTestf2(builder:flatbuffers.Builder, testf2:number) {
+ builder.addFieldFloat32(26, testf2, 3.0);
+}
+
+static addTestf3(builder:flatbuffers.Builder, testf3:number) {
+ builder.addFieldFloat32(27, testf3, 0.0);
+}
+
+static addTestarrayofstring2(builder:flatbuffers.Builder, testarrayofstring2Offset:flatbuffers.Offset) {
+ builder.addFieldOffset(28, testarrayofstring2Offset, 0);
+}
+
+static createTestarrayofstring2Vector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startTestarrayofstring2Vector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addTestarrayofsortedstruct(builder:flatbuffers.Builder, testarrayofsortedstructOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(29, testarrayofsortedstructOffset, 0);
+}
+
+static startTestarrayofsortedstructVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(8, numElems, 4);
+}
+
+static addFlex(builder:flatbuffers.Builder, flexOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(30, flexOffset, 0);
+}
+
+static createFlexVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset {
+ builder.startVector(1, data.length, 1);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt8(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startFlexVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(1, numElems, 1);
+}
+
+static addTest5(builder:flatbuffers.Builder, test5Offset:flatbuffers.Offset) {
+ builder.addFieldOffset(31, test5Offset, 0);
+}
+
+static startTest5Vector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 2);
+}
+
+static addVectorOfLongs(builder:flatbuffers.Builder, vectorOfLongsOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(32, vectorOfLongsOffset, 0);
+}
+
+static createVectorOfLongsVector(builder:flatbuffers.Builder, data:bigint[]):flatbuffers.Offset {
+ builder.startVector(8, data.length, 8);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt64(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startVectorOfLongsVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(8, numElems, 8);
+}
+
+static addVectorOfDoubles(builder:flatbuffers.Builder, vectorOfDoublesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(33, vectorOfDoublesOffset, 0);
+}
+
+static createVectorOfDoublesVector(builder:flatbuffers.Builder, data:number[]|Float64Array):flatbuffers.Offset;
+/**
+ * @deprecated This Uint8Array overload will be removed in the future.
+ */
+static createVectorOfDoublesVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset;
+static createVectorOfDoublesVector(builder:flatbuffers.Builder, data:number[]|Float64Array|Uint8Array):flatbuffers.Offset {
+ builder.startVector(8, data.length, 8);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addFloat64(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startVectorOfDoublesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(8, numElems, 8);
+}
+
+static addParentNamespaceTest(builder:flatbuffers.Builder, parentNamespaceTestOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(34, parentNamespaceTestOffset, 0);
+}
+
+static addVectorOfReferrables(builder:flatbuffers.Builder, vectorOfReferrablesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(35, vectorOfReferrablesOffset, 0);
+}
+
+static createVectorOfReferrablesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startVectorOfReferrablesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addSingleWeakReference(builder:flatbuffers.Builder, singleWeakReference:bigint) {
+ builder.addFieldInt64(36, singleWeakReference, BigInt('0'));
+}
+
+static addVectorOfWeakReferences(builder:flatbuffers.Builder, vectorOfWeakReferencesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(37, vectorOfWeakReferencesOffset, 0);
+}
+
+static createVectorOfWeakReferencesVector(builder:flatbuffers.Builder, data:bigint[]):flatbuffers.Offset {
+ builder.startVector(8, data.length, 8);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt64(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startVectorOfWeakReferencesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(8, numElems, 8);
+}
+
+static addVectorOfStrongReferrables(builder:flatbuffers.Builder, vectorOfStrongReferrablesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(38, vectorOfStrongReferrablesOffset, 0);
+}
+
+static createVectorOfStrongReferrablesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startVectorOfStrongReferrablesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addCoOwningReference(builder:flatbuffers.Builder, coOwningReference:bigint) {
+ builder.addFieldInt64(39, coOwningReference, BigInt('0'));
+}
+
+static addVectorOfCoOwningReferences(builder:flatbuffers.Builder, vectorOfCoOwningReferencesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(40, vectorOfCoOwningReferencesOffset, 0);
+}
+
+static createVectorOfCoOwningReferencesVector(builder:flatbuffers.Builder, data:bigint[]):flatbuffers.Offset {
+ builder.startVector(8, data.length, 8);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt64(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startVectorOfCoOwningReferencesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(8, numElems, 8);
+}
+
+static addNonOwningReference(builder:flatbuffers.Builder, nonOwningReference:bigint) {
+ builder.addFieldInt64(41, nonOwningReference, BigInt('0'));
+}
+
+static addVectorOfNonOwningReferences(builder:flatbuffers.Builder, vectorOfNonOwningReferencesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(42, vectorOfNonOwningReferencesOffset, 0);
+}
+
+static createVectorOfNonOwningReferencesVector(builder:flatbuffers.Builder, data:bigint[]):flatbuffers.Offset {
+ builder.startVector(8, data.length, 8);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt64(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startVectorOfNonOwningReferencesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(8, numElems, 8);
+}
+
+static addAnyUniqueType(builder:flatbuffers.Builder, anyUniqueType:MyGame_Example_AnyUniqueAliases) {
+ builder.addFieldInt8(43, anyUniqueType, MyGame_Example_AnyUniqueAliases.NONE);
+}
+
+static addAnyUnique(builder:flatbuffers.Builder, anyUniqueOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(44, anyUniqueOffset, 0);
+}
+
+static addAnyAmbiguousType(builder:flatbuffers.Builder, anyAmbiguousType:MyGame_Example_AnyAmbiguousAliases) {
+ builder.addFieldInt8(45, anyAmbiguousType, MyGame_Example_AnyAmbiguousAliases.NONE);
+}
+
+static addAnyAmbiguous(builder:flatbuffers.Builder, anyAmbiguousOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(46, anyAmbiguousOffset, 0);
+}
+
+static addVectorOfEnums(builder:flatbuffers.Builder, vectorOfEnumsOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(47, vectorOfEnumsOffset, 0);
+}
+
+static createVectorOfEnumsVector(builder:flatbuffers.Builder, data:MyGame_Example_Color[]):flatbuffers.Offset {
+ builder.startVector(1, data.length, 1);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt8(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startVectorOfEnumsVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(1, numElems, 1);
+}
+
+static addSignedEnum(builder:flatbuffers.Builder, signedEnum:MyGame_Example_Race) {
+ builder.addFieldInt8(48, signedEnum, MyGame_Example_Race.None);
+}
+
+static addTestrequirednestedflatbuffer(builder:flatbuffers.Builder, testrequirednestedflatbufferOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(49, testrequirednestedflatbufferOffset, 0);
+}
+
+static createTestrequirednestedflatbufferVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset {
+ builder.startVector(1, data.length, 1);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt8(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startTestrequirednestedflatbufferVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(1, numElems, 1);
+}
+
+static addScalarKeySortedTables(builder:flatbuffers.Builder, scalarKeySortedTablesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(50, scalarKeySortedTablesOffset, 0);
+}
+
+static createScalarKeySortedTablesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startScalarKeySortedTablesVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static addNativeInline(builder:flatbuffers.Builder, nativeInlineOffset:flatbuffers.Offset) {
+ builder.addFieldStruct(51, nativeInlineOffset, 0);
+}
+
+static addLongEnumNonEnumDefault(builder:flatbuffers.Builder, longEnumNonEnumDefault:bigint) {
+ builder.addFieldInt64(52, longEnumNonEnumDefault, BigInt('0'));
+}
+
+static addLongEnumNormalDefault(builder:flatbuffers.Builder, longEnumNormalDefault:bigint) {
+ builder.addFieldInt64(53, longEnumNormalDefault, BigInt('2'));
+}
+
+static endMonster(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ builder.requiredField(offset, 10) // name
+ return offset;
+}
+
+static finishMonsterBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
+ builder.finish(offset, 'MONS');
+}
+
+static finishSizePrefixedMonsterBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
+ builder.finish(offset, 'MONS', true);
+}
+
+
+serialize():Uint8Array {
+ return this.bb!.bytes();
+}
+
+static deserialize(buffer: Uint8Array):Monster {
+ return MyGame_Example_Monster.getRootAsMonster(new flatbuffers.ByteBuffer(buffer))
+}
+}
+
+export class MyGame_Example_TypeAliases {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_Example_TypeAliases {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsTypeAliases(bb:flatbuffers.ByteBuffer, obj?:MyGame_Example_TypeAliases):MyGame_Example_TypeAliases {
+ return (obj || new MyGame_Example_TypeAliases()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsTypeAliases(bb:flatbuffers.ByteBuffer, obj?:MyGame_Example_TypeAliases):MyGame_Example_TypeAliases {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new MyGame_Example_TypeAliases()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+i8():number {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.readInt8(this.bb_pos + offset) : 0;
+}
+
+u8():number {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0;
+}
+
+i16():number {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? this.bb!.readInt16(this.bb_pos + offset) : 0;
+}
+
+u16():number {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
+}
+
+i32():number {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
+}
+
+u32():number {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0;
+}
+
+i64():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 16);
+ return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
+}
+
+u64():bigint {
+ const offset = this.bb!.__offset(this.bb_pos, 18);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
+}
+
+f32():number {
+ const offset = this.bb!.__offset(this.bb_pos, 20);
+ return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
+}
+
+f64():number {
+ const offset = this.bb!.__offset(this.bb_pos, 22);
+ return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0;
+}
+
+v8(index: number):number|null {
+ const offset = this.bb!.__offset(this.bb_pos, 24);
+ return offset ? this.bb!.readInt8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
+}
+
+v8Length():number {
+ const offset = this.bb!.__offset(this.bb_pos, 24);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+v8Array():Int8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 24);
+ return offset ? new Int8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
+}
+
+vf64(index: number):number|null {
+ const offset = this.bb!.__offset(this.bb_pos, 26);
+ return offset ? this.bb!.readFloat64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : 0;
+}
+
+vf64Length():number {
+ const offset = this.bb!.__offset(this.bb_pos, 26);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+vf64Array():Float64Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 26);
+ return offset ? new Float64Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
+}
+
+static startTypeAliases(builder:flatbuffers.Builder) {
+ builder.startObject(12);
+}
+
+static addI8(builder:flatbuffers.Builder, i8:number) {
+ builder.addFieldInt8(0, i8, 0);
+}
+
+static addU8(builder:flatbuffers.Builder, u8:number) {
+ builder.addFieldInt8(1, u8, 0);
+}
+
+static addI16(builder:flatbuffers.Builder, i16:number) {
+ builder.addFieldInt16(2, i16, 0);
+}
+
+static addU16(builder:flatbuffers.Builder, u16:number) {
+ builder.addFieldInt16(3, u16, 0);
+}
+
+static addI32(builder:flatbuffers.Builder, i32:number) {
+ builder.addFieldInt32(4, i32, 0);
+}
+
+static addU32(builder:flatbuffers.Builder, u32:number) {
+ builder.addFieldInt32(5, u32, 0);
+}
+
+static addI64(builder:flatbuffers.Builder, i64:bigint) {
+ builder.addFieldInt64(6, i64, BigInt('0'));
+}
+
+static addU64(builder:flatbuffers.Builder, u64:bigint) {
+ builder.addFieldInt64(7, u64, BigInt('0'));
+}
+
+static addF32(builder:flatbuffers.Builder, f32:number) {
+ builder.addFieldFloat32(8, f32, 0.0);
+}
+
+static addF64(builder:flatbuffers.Builder, f64:number) {
+ builder.addFieldFloat64(9, f64, 0.0);
+}
+
+static addV8(builder:flatbuffers.Builder, v8Offset:flatbuffers.Offset) {
+ builder.addFieldOffset(10, v8Offset, 0);
+}
+
+static createV8Vector(builder:flatbuffers.Builder, data:number[]|Int8Array):flatbuffers.Offset;
+/**
+ * @deprecated This Uint8Array overload will be removed in the future.
+ */
+static createV8Vector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset;
+static createV8Vector(builder:flatbuffers.Builder, data:number[]|Int8Array|Uint8Array):flatbuffers.Offset {
+ builder.startVector(1, data.length, 1);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt8(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startV8Vector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(1, numElems, 1);
+}
+
+static addVf64(builder:flatbuffers.Builder, vf64Offset:flatbuffers.Offset) {
+ builder.addFieldOffset(11, vf64Offset, 0);
+}
+
+static createVf64Vector(builder:flatbuffers.Builder, data:number[]|Float64Array):flatbuffers.Offset;
+/**
+ * @deprecated This Uint8Array overload will be removed in the future.
+ */
+static createVf64Vector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset;
+static createVf64Vector(builder:flatbuffers.Builder, data:number[]|Float64Array|Uint8Array):flatbuffers.Offset {
+ builder.startVector(8, data.length, 8);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addFloat64(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startVf64Vector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(8, numElems, 8);
+}
+
+static endTypeAliases(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+static createTypeAliases(builder:flatbuffers.Builder, i8:number, u8:number, i16:number, u16:number, i32:number, u32:number, i64:bigint, u64:bigint, f32:number, f64:number, v8Offset:flatbuffers.Offset, vf64Offset:flatbuffers.Offset):flatbuffers.Offset {
+ MyGame_Example_TypeAliases.startTypeAliases(builder);
+ MyGame_Example_TypeAliases.addI8(builder, i8);
+ MyGame_Example_TypeAliases.addU8(builder, u8);
+ MyGame_Example_TypeAliases.addI16(builder, i16);
+ MyGame_Example_TypeAliases.addU16(builder, u16);
+ MyGame_Example_TypeAliases.addI32(builder, i32);
+ MyGame_Example_TypeAliases.addU32(builder, u32);
+ MyGame_Example_TypeAliases.addI64(builder, i64);
+ MyGame_Example_TypeAliases.addU64(builder, u64);
+ MyGame_Example_TypeAliases.addF32(builder, f32);
+ MyGame_Example_TypeAliases.addF64(builder, f64);
+ MyGame_Example_TypeAliases.addV8(builder, v8Offset);
+ MyGame_Example_TypeAliases.addVf64(builder, vf64Offset);
+ return MyGame_Example_TypeAliases.endTypeAliases(builder);
+}
+
+serialize():Uint8Array {
+ return this.bb!.bytes();
+}
+
+static deserialize(buffer: Uint8Array):TypeAliases {
+ return MyGame_Example_TypeAliases.getRootAsTypeAliases(new flatbuffers.ByteBuffer(buffer))
+}
+}
+
diff --git a/tests/tsconfig.json b/tests/ts/tsconfig.json
similarity index 100%
rename from tests/tsconfig.json
rename to tests/ts/tsconfig.json
diff --git a/tests/ts/typescript/class.js b/tests/ts/typescript/class.js
new file mode 100644
index 0000000..9b0f2c0
--- /dev/null
+++ b/tests/ts/typescript/class.js
@@ -0,0 +1,6 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+export var class_;
+(function (class_) {
+ class_[class_["new_"] = 0] = "new_";
+ class_[class_["instanceof_"] = 1] = "instanceof_";
+})(class_ || (class_ = {}));
diff --git a/tests/ts/typescript/class.ts b/tests/ts/typescript/class.ts
new file mode 100644
index 0000000..fd8f145
--- /dev/null
+++ b/tests/ts/typescript/class.ts
@@ -0,0 +1,6 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+export enum class_ {
+ new_ = 0,
+ instanceof_ = 1
+}
diff --git a/tests/ts/typescript/object.js b/tests/ts/typescript/object.js
new file mode 100644
index 0000000..05ffb1a
--- /dev/null
+++ b/tests/ts/typescript/object.js
@@ -0,0 +1,166 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import * as flatbuffers from 'flatbuffers';
+import { Abc } from '../foobar/abc.js';
+import { class_ as foobar_class_ } from '../foobar/class.js';
+import { Schema } from '../reflection/schema.js';
+import { class_ } from '../typescript/class.js';
+export class Object_ {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsObject(bb, obj) {
+ return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsObject(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ return_() {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
+ }
+ mutate_return(value) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt32(this.bb_pos + offset, value);
+ return true;
+ }
+ if_() {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
+ }
+ mutate_if(value) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt32(this.bb_pos + offset, value);
+ return true;
+ }
+ switch_() {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
+ }
+ mutate_switch(value) {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt32(this.bb_pos + offset, value);
+ return true;
+ }
+ enum_() {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? this.bb.readInt32(this.bb_pos + offset) : class_.new_;
+ }
+ mutate_enum(value) {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt32(this.bb_pos + offset, value);
+ return true;
+ }
+ enum2() {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ return offset ? this.bb.readInt32(this.bb_pos + offset) : foobar_class_.arguments_;
+ }
+ mutate_enum2(value) {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt32(this.bb_pos + offset, value);
+ return true;
+ }
+ enum3() {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ return offset ? this.bb.readInt32(this.bb_pos + offset) : Abc.a;
+ }
+ mutate_enum3(value) {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt32(this.bb_pos + offset, value);
+ return true;
+ }
+ reflect(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 16);
+ return offset ? (obj || new Schema()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
+ }
+ static getFullyQualifiedName() {
+ return 'typescript_Object';
+ }
+ static startObject(builder) {
+ builder.startObject(7);
+ }
+ static addReturn(builder, return_) {
+ builder.addFieldInt32(0, return_, 0);
+ }
+ static addIf(builder, if_) {
+ builder.addFieldInt32(1, if_, 0);
+ }
+ static addSwitch(builder, switch_) {
+ builder.addFieldInt32(2, switch_, 0);
+ }
+ static addEnum(builder, enum_) {
+ builder.addFieldInt32(3, enum_, class_.new_);
+ }
+ static addEnum2(builder, enum2) {
+ builder.addFieldInt32(4, enum2, foobar_class_.arguments_);
+ }
+ static addEnum3(builder, enum3) {
+ builder.addFieldInt32(5, enum3, Abc.a);
+ }
+ static addReflect(builder, reflectOffset) {
+ builder.addFieldOffset(6, reflectOffset, 0);
+ }
+ static endObject(builder) {
+ const offset = builder.endObject();
+ return offset;
+ }
+ unpack() {
+ return new Object_T(this.return_(), this.if_(), this.switch_(), this.enum_(), this.enum2(), this.enum3(), (this.reflect() !== null ? this.reflect().unpack() : null));
+ }
+ unpackTo(_o) {
+ _o.return_ = this.return_();
+ _o.if_ = this.if_();
+ _o.switch_ = this.switch_();
+ _o.enum_ = this.enum_();
+ _o.enum2 = this.enum2();
+ _o.enum3 = this.enum3();
+ _o.reflect = (this.reflect() !== null ? this.reflect().unpack() : null);
+ }
+}
+export class Object_T {
+ constructor(return_ = 0, if_ = 0, switch_ = 0, enum_ = class_.new_, enum2 = foobar_class_.arguments_, enum3 = Abc.a, reflect = null) {
+ this.return_ = return_;
+ this.if_ = if_;
+ this.switch_ = switch_;
+ this.enum_ = enum_;
+ this.enum2 = enum2;
+ this.enum3 = enum3;
+ this.reflect = reflect;
+ }
+ pack(builder) {
+ const reflect = (this.reflect !== null ? this.reflect.pack(builder) : 0);
+ Object_.startObject(builder);
+ Object_.addReturn(builder, this.return_);
+ Object_.addIf(builder, this.if_);
+ Object_.addSwitch(builder, this.switch_);
+ Object_.addEnum(builder, this.enum_);
+ Object_.addEnum2(builder, this.enum2);
+ Object_.addEnum3(builder, this.enum3);
+ Object_.addReflect(builder, reflect);
+ return Object_.endObject(builder);
+ }
+}
diff --git a/tests/ts/typescript/object.ts b/tests/ts/typescript/object.ts
new file mode 100644
index 0000000..041b660
--- /dev/null
+++ b/tests/ts/typescript/object.ts
@@ -0,0 +1,222 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+import { Abc } from '../foobar/abc.js';
+import { class_ as foobar_class_ } from '../foobar/class.js';
+import { Schema, SchemaT } from '../reflection/schema.js';
+import { class_ } from '../typescript/class.js';
+
+
+export class Object_ {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):Object_ {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsObject(bb:flatbuffers.ByteBuffer, obj?:Object_):Object_ {
+ return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsObject(bb:flatbuffers.ByteBuffer, obj?:Object_):Object_ {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+return_():number {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
+}
+
+mutate_return(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt32(this.bb_pos + offset, value);
+ return true;
+}
+
+if_():number {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
+}
+
+mutate_if(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt32(this.bb_pos + offset, value);
+ return true;
+}
+
+switch_():number {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
+}
+
+mutate_switch(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt32(this.bb_pos + offset, value);
+ return true;
+}
+
+enum_():class_ {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : class_.new_;
+}
+
+mutate_enum(value:class_):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt32(this.bb_pos + offset, value);
+ return true;
+}
+
+enum2():foobar_class_ {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : foobar_class_.arguments_;
+}
+
+mutate_enum2(value:foobar_class_):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt32(this.bb_pos + offset, value);
+ return true;
+}
+
+enum3():Abc {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : Abc.a;
+}
+
+mutate_enum3(value:Abc):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt32(this.bb_pos + offset, value);
+ return true;
+}
+
+reflect(obj?:Schema):Schema|null {
+ const offset = this.bb!.__offset(this.bb_pos, 16);
+ return offset ? (obj || new Schema()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
+}
+
+static getFullyQualifiedName():string {
+ return 'typescript_Object';
+}
+
+static startObject(builder:flatbuffers.Builder) {
+ builder.startObject(7);
+}
+
+static addReturn(builder:flatbuffers.Builder, return_:number) {
+ builder.addFieldInt32(0, return_, 0);
+}
+
+static addIf(builder:flatbuffers.Builder, if_:number) {
+ builder.addFieldInt32(1, if_, 0);
+}
+
+static addSwitch(builder:flatbuffers.Builder, switch_:number) {
+ builder.addFieldInt32(2, switch_, 0);
+}
+
+static addEnum(builder:flatbuffers.Builder, enum_:class_) {
+ builder.addFieldInt32(3, enum_, class_.new_);
+}
+
+static addEnum2(builder:flatbuffers.Builder, enum2:foobar_class_) {
+ builder.addFieldInt32(4, enum2, foobar_class_.arguments_);
+}
+
+static addEnum3(builder:flatbuffers.Builder, enum3:Abc) {
+ builder.addFieldInt32(5, enum3, Abc.a);
+}
+
+static addReflect(builder:flatbuffers.Builder, reflectOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(6, reflectOffset, 0);
+}
+
+static endObject(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+
+unpack(): Object_T {
+ return new Object_T(
+ this.return_(),
+ this.if_(),
+ this.switch_(),
+ this.enum_(),
+ this.enum2(),
+ this.enum3(),
+ (this.reflect() !== null ? this.reflect()!.unpack() : null)
+ );
+}
+
+
+unpackTo(_o: Object_T): void {
+ _o.return_ = this.return_();
+ _o.if_ = this.if_();
+ _o.switch_ = this.switch_();
+ _o.enum_ = this.enum_();
+ _o.enum2 = this.enum2();
+ _o.enum3 = this.enum3();
+ _o.reflect = (this.reflect() !== null ? this.reflect()!.unpack() : null);
+}
+}
+
+export class Object_T {
+constructor(
+ public return_: number = 0,
+ public if_: number = 0,
+ public switch_: number = 0,
+ public enum_: class_ = class_.new_,
+ public enum2: foobar_class_ = foobar_class_.arguments_,
+ public enum3: Abc = Abc.a,
+ public reflect: SchemaT|null = null
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ const reflect = (this.reflect !== null ? this.reflect!.pack(builder) : 0);
+
+ Object_.startObject(builder);
+ Object_.addReturn(builder, this.return_);
+ Object_.addIf(builder, this.if_);
+ Object_.addSwitch(builder, this.switch_);
+ Object_.addEnum(builder, this.enum_);
+ Object_.addEnum2(builder, this.enum2);
+ Object_.addEnum3(builder, this.enum3);
+ Object_.addReflect(builder, reflect);
+
+ return Object_.endObject(builder);
+}
+}
diff --git a/tests/ts/typescript_include_generated.js b/tests/ts/typescript_include_generated.js
new file mode 100644
index 0000000..e0e1df1
--- /dev/null
+++ b/tests/ts/typescript_include_generated.js
@@ -0,0 +1,5 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+export var class_;
+(function (class_) {
+ class_[class_["arguments_"] = 0] = "arguments_";
+})(class_ || (class_ = {}));
diff --git a/tests/ts/typescript_include_generated.ts b/tests/ts/typescript_include_generated.ts
new file mode 100644
index 0000000..d419431
--- /dev/null
+++ b/tests/ts/typescript_include_generated.ts
@@ -0,0 +1,7 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+
+export enum class_ {
+ arguments_ = 0
+}
+
diff --git a/tests/typescript_keywords.fbs b/tests/ts/typescript_keywords.fbs
similarity index 100%
rename from tests/typescript_keywords.fbs
rename to tests/ts/typescript_keywords.fbs
diff --git a/tests/ts/typescript_keywords_generated.js b/tests/ts/typescript_keywords_generated.js
new file mode 100644
index 0000000..4525da7
--- /dev/null
+++ b/tests/ts/typescript_keywords_generated.js
@@ -0,0 +1,170 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import * as flatbuffers from 'flatbuffers';
+import { Schema as Schema } from './reflection_generated.js';
+import { class_ as foobar_class_ } from './typescript_include_generated.js';
+import { Abc as Abc } from './typescript_transitive_include_generated.js';
+export var class_;
+(function (class_) {
+ class_[class_["new_"] = 0] = "new_";
+ class_[class_["instanceof_"] = 1] = "instanceof_";
+})(class_ || (class_ = {}));
+export class Object_ {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsObject(bb, obj) {
+ return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsObject(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ return_() {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
+ }
+ mutate_return(value) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt32(this.bb_pos + offset, value);
+ return true;
+ }
+ if_() {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
+ }
+ mutate_if(value) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt32(this.bb_pos + offset, value);
+ return true;
+ }
+ switch_() {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
+ }
+ mutate_switch(value) {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt32(this.bb_pos + offset, value);
+ return true;
+ }
+ enum_() {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? this.bb.readInt32(this.bb_pos + offset) : class_.new_;
+ }
+ mutate_enum(value) {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt32(this.bb_pos + offset, value);
+ return true;
+ }
+ enum2() {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ return offset ? this.bb.readInt32(this.bb_pos + offset) : foobar_class_.arguments_;
+ }
+ mutate_enum2(value) {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt32(this.bb_pos + offset, value);
+ return true;
+ }
+ enum3() {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ return offset ? this.bb.readInt32(this.bb_pos + offset) : Abc.a;
+ }
+ mutate_enum3(value) {
+ const offset = this.bb.__offset(this.bb_pos, 14);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt32(this.bb_pos + offset, value);
+ return true;
+ }
+ reflect(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 16);
+ return offset ? (obj || new Schema()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
+ }
+ static getFullyQualifiedName() {
+ return 'typescript_Object';
+ }
+ static startObject(builder) {
+ builder.startObject(7);
+ }
+ static addReturn(builder, return_) {
+ builder.addFieldInt32(0, return_, 0);
+ }
+ static addIf(builder, if_) {
+ builder.addFieldInt32(1, if_, 0);
+ }
+ static addSwitch(builder, switch_) {
+ builder.addFieldInt32(2, switch_, 0);
+ }
+ static addEnum(builder, enum_) {
+ builder.addFieldInt32(3, enum_, class_.new_);
+ }
+ static addEnum2(builder, enum2) {
+ builder.addFieldInt32(4, enum2, foobar_class_.arguments_);
+ }
+ static addEnum3(builder, enum3) {
+ builder.addFieldInt32(5, enum3, Abc.a);
+ }
+ static addReflect(builder, reflectOffset) {
+ builder.addFieldOffset(6, reflectOffset, 0);
+ }
+ static endObject(builder) {
+ const offset = builder.endObject();
+ return offset;
+ }
+ unpack() {
+ return new Object_T(this.return_(), this.if_(), this.switch_(), this.enum_(), this.enum2(), this.enum3(), (this.reflect() !== null ? this.reflect().unpack() : null));
+ }
+ unpackTo(_o) {
+ _o.return_ = this.return_();
+ _o.if_ = this.if_();
+ _o.switch_ = this.switch_();
+ _o.enum_ = this.enum_();
+ _o.enum2 = this.enum2();
+ _o.enum3 = this.enum3();
+ _o.reflect = (this.reflect() !== null ? this.reflect().unpack() : null);
+ }
+}
+export class Object_T {
+ constructor(return_ = 0, if_ = 0, switch_ = 0, enum_ = class_.new_, enum2 = foobar_class_.arguments_, enum3 = Abc.a, reflect = null) {
+ this.return_ = return_;
+ this.if_ = if_;
+ this.switch_ = switch_;
+ this.enum_ = enum_;
+ this.enum2 = enum2;
+ this.enum3 = enum3;
+ this.reflect = reflect;
+ }
+ pack(builder) {
+ const reflect = (this.reflect !== null ? this.reflect.pack(builder) : 0);
+ Object_.startObject(builder);
+ Object_.addReturn(builder, this.return_);
+ Object_.addIf(builder, this.if_);
+ Object_.addSwitch(builder, this.switch_);
+ Object_.addEnum(builder, this.enum_);
+ Object_.addEnum2(builder, this.enum2);
+ Object_.addEnum3(builder, this.enum3);
+ Object_.addReflect(builder, reflect);
+ return Object_.endObject(builder);
+ }
+}
diff --git a/tests/ts/typescript_keywords_generated.ts b/tests/ts/typescript_keywords_generated.ts
new file mode 100644
index 0000000..4272425
--- /dev/null
+++ b/tests/ts/typescript_keywords_generated.ts
@@ -0,0 +1,226 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+import {Schema as Schema, SchemaT as SchemaT} from './reflection_generated.js';
+import {class_ as foobar_class_} from './typescript_include_generated.js';
+import {Abc as Abc} from './typescript_transitive_include_generated.js';
+
+export enum class_ {
+ new_ = 0,
+ instanceof_ = 1
+}
+
+export class Object_ {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):Object_ {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsObject(bb:flatbuffers.ByteBuffer, obj?:Object_):Object_ {
+ return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsObject(bb:flatbuffers.ByteBuffer, obj?:Object_):Object_ {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+return_():number {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
+}
+
+mutate_return(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt32(this.bb_pos + offset, value);
+ return true;
+}
+
+if_():number {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
+}
+
+mutate_if(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt32(this.bb_pos + offset, value);
+ return true;
+}
+
+switch_():number {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
+}
+
+mutate_switch(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt32(this.bb_pos + offset, value);
+ return true;
+}
+
+enum_():class_ {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : class_.new_;
+}
+
+mutate_enum(value:class_):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt32(this.bb_pos + offset, value);
+ return true;
+}
+
+enum2():foobar_class_ {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : foobar_class_.arguments_;
+}
+
+mutate_enum2(value:foobar_class_):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt32(this.bb_pos + offset, value);
+ return true;
+}
+
+enum3():Abc {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : Abc.a;
+}
+
+mutate_enum3(value:Abc):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt32(this.bb_pos + offset, value);
+ return true;
+}
+
+reflect(obj?:Schema):Schema|null {
+ const offset = this.bb!.__offset(this.bb_pos, 16);
+ return offset ? (obj || new Schema()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
+}
+
+static getFullyQualifiedName():string {
+ return 'typescript_Object';
+}
+
+static startObject(builder:flatbuffers.Builder) {
+ builder.startObject(7);
+}
+
+static addReturn(builder:flatbuffers.Builder, return_:number) {
+ builder.addFieldInt32(0, return_, 0);
+}
+
+static addIf(builder:flatbuffers.Builder, if_:number) {
+ builder.addFieldInt32(1, if_, 0);
+}
+
+static addSwitch(builder:flatbuffers.Builder, switch_:number) {
+ builder.addFieldInt32(2, switch_, 0);
+}
+
+static addEnum(builder:flatbuffers.Builder, enum_:class_) {
+ builder.addFieldInt32(3, enum_, class_.new_);
+}
+
+static addEnum2(builder:flatbuffers.Builder, enum2:foobar_class_) {
+ builder.addFieldInt32(4, enum2, foobar_class_.arguments_);
+}
+
+static addEnum3(builder:flatbuffers.Builder, enum3:Abc) {
+ builder.addFieldInt32(5, enum3, Abc.a);
+}
+
+static addReflect(builder:flatbuffers.Builder, reflectOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(6, reflectOffset, 0);
+}
+
+static endObject(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+
+unpack(): Object_T {
+ return new Object_T(
+ this.return_(),
+ this.if_(),
+ this.switch_(),
+ this.enum_(),
+ this.enum2(),
+ this.enum3(),
+ (this.reflect() !== null ? this.reflect()!.unpack() : null)
+ );
+}
+
+
+unpackTo(_o: Object_T): void {
+ _o.return_ = this.return_();
+ _o.if_ = this.if_();
+ _o.switch_ = this.switch_();
+ _o.enum_ = this.enum_();
+ _o.enum2 = this.enum2();
+ _o.enum3 = this.enum3();
+ _o.reflect = (this.reflect() !== null ? this.reflect()!.unpack() : null);
+}
+}
+
+export class Object_T {
+constructor(
+ public return_: number = 0,
+ public if_: number = 0,
+ public switch_: number = 0,
+ public enum_: class_ = class_.new_,
+ public enum2: foobar_class_ = foobar_class_.arguments_,
+ public enum3: Abc = Abc.a,
+ public reflect: SchemaT|null = null
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ const reflect = (this.reflect !== null ? this.reflect!.pack(builder) : 0);
+
+ Object_.startObject(builder);
+ Object_.addReturn(builder, this.return_);
+ Object_.addIf(builder, this.if_);
+ Object_.addSwitch(builder, this.switch_);
+ Object_.addEnum(builder, this.enum_);
+ Object_.addEnum2(builder, this.enum2);
+ Object_.addEnum3(builder, this.enum3);
+ Object_.addReflect(builder, reflect);
+
+ return Object_.endObject(builder);
+}
+}
+
diff --git a/tests/ts/typescript_transitive_include_generated.js b/tests/ts/typescript_transitive_include_generated.js
new file mode 100644
index 0000000..cdef988
--- /dev/null
+++ b/tests/ts/typescript_transitive_include_generated.js
@@ -0,0 +1,5 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+export var Abc;
+(function (Abc) {
+ Abc[Abc["a"] = 0] = "a";
+})(Abc || (Abc = {}));
diff --git a/tests/ts/typescript_transitive_include_generated.ts b/tests/ts/typescript_transitive_include_generated.ts
new file mode 100644
index 0000000..6bb1601
--- /dev/null
+++ b/tests/ts/typescript_transitive_include_generated.ts
@@ -0,0 +1,7 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+
+export enum Abc {
+ a = 0
+}
+
diff --git a/tests/ts/unicode_test.mon b/tests/ts/unicode_test.mon
new file mode 100644
index 0000000..14f5fb4
--- /dev/null
+++ b/tests/ts/unicode_test.mon
Binary files differ
diff --git a/tests/ts/union_vector/attacker.js b/tests/ts/union_vector/attacker.js
new file mode 100644
index 0000000..32be94e
--- /dev/null
+++ b/tests/ts/union_vector/attacker.js
@@ -0,0 +1,64 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import * as flatbuffers from 'flatbuffers';
+export class Attacker {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsAttacker(bb, obj) {
+ return (obj || new Attacker()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsAttacker(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Attacker()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ swordAttackDamage() {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
+ }
+ mutate_sword_attack_damage(value) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt32(this.bb_pos + offset, value);
+ return true;
+ }
+ static getFullyQualifiedName() {
+ return 'Attacker';
+ }
+ static startAttacker(builder) {
+ builder.startObject(1);
+ }
+ static addSwordAttackDamage(builder, swordAttackDamage) {
+ builder.addFieldInt32(0, swordAttackDamage, 0);
+ }
+ static endAttacker(builder) {
+ const offset = builder.endObject();
+ return offset;
+ }
+ static createAttacker(builder, swordAttackDamage) {
+ Attacker.startAttacker(builder);
+ Attacker.addSwordAttackDamage(builder, swordAttackDamage);
+ return Attacker.endAttacker(builder);
+ }
+ unpack() {
+ return new AttackerT(this.swordAttackDamage());
+ }
+ unpackTo(_o) {
+ _o.swordAttackDamage = this.swordAttackDamage();
+ }
+}
+export class AttackerT {
+ constructor(swordAttackDamage = 0) {
+ this.swordAttackDamage = swordAttackDamage;
+ }
+ pack(builder) {
+ return Attacker.createAttacker(builder, this.swordAttackDamage);
+ }
+}
diff --git a/tests/ts/union_vector/attacker.ts b/tests/ts/union_vector/attacker.ts
new file mode 100644
index 0000000..6b3fc0f
--- /dev/null
+++ b/tests/ts/union_vector/attacker.ts
@@ -0,0 +1,87 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+
+
+export class Attacker {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):Attacker {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsAttacker(bb:flatbuffers.ByteBuffer, obj?:Attacker):Attacker {
+ return (obj || new Attacker()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsAttacker(bb:flatbuffers.ByteBuffer, obj?:Attacker):Attacker {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Attacker()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+swordAttackDamage():number {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
+}
+
+mutate_sword_attack_damage(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt32(this.bb_pos + offset, value);
+ return true;
+}
+
+static getFullyQualifiedName():string {
+ return 'Attacker';
+}
+
+static startAttacker(builder:flatbuffers.Builder) {
+ builder.startObject(1);
+}
+
+static addSwordAttackDamage(builder:flatbuffers.Builder, swordAttackDamage:number) {
+ builder.addFieldInt32(0, swordAttackDamage, 0);
+}
+
+static endAttacker(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+static createAttacker(builder:flatbuffers.Builder, swordAttackDamage:number):flatbuffers.Offset {
+ Attacker.startAttacker(builder);
+ Attacker.addSwordAttackDamage(builder, swordAttackDamage);
+ return Attacker.endAttacker(builder);
+}
+
+unpack(): AttackerT {
+ return new AttackerT(
+ this.swordAttackDamage()
+ );
+}
+
+
+unpackTo(_o: AttackerT): void {
+ _o.swordAttackDamage = this.swordAttackDamage();
+}
+}
+
+export class AttackerT {
+constructor(
+ public swordAttackDamage: number = 0
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ return Attacker.createAttacker(builder,
+ this.swordAttackDamage
+ );
+}
+}
diff --git a/tests/ts/union_vector/book-reader.js b/tests/ts/union_vector/book-reader.js
new file mode 100644
index 0000000..0d9e1a5
--- /dev/null
+++ b/tests/ts/union_vector/book-reader.js
@@ -0,0 +1,44 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+export class BookReader {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ booksRead() {
+ return this.bb.readInt32(this.bb_pos);
+ }
+ mutate_books_read(value) {
+ this.bb.writeInt32(this.bb_pos + 0, value);
+ return true;
+ }
+ static getFullyQualifiedName() {
+ return 'BookReader';
+ }
+ static sizeOf() {
+ return 4;
+ }
+ static createBookReader(builder, books_read) {
+ builder.prep(4, 4);
+ builder.writeInt32(books_read);
+ return builder.offset();
+ }
+ unpack() {
+ return new BookReaderT(this.booksRead());
+ }
+ unpackTo(_o) {
+ _o.booksRead = this.booksRead();
+ }
+}
+export class BookReaderT {
+ constructor(booksRead = 0) {
+ this.booksRead = booksRead;
+ }
+ pack(builder) {
+ return BookReader.createBookReader(builder, this.booksRead);
+ }
+}
diff --git a/tests/ts/union_vector/book-reader.ts b/tests/ts/union_vector/book-reader.ts
new file mode 100644
index 0000000..7a31278
--- /dev/null
+++ b/tests/ts/union_vector/book-reader.ts
@@ -0,0 +1,63 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+
+
+export class BookReader {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):BookReader {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+booksRead():number {
+ return this.bb!.readInt32(this.bb_pos);
+}
+
+mutate_books_read(value:number):boolean {
+ this.bb!.writeInt32(this.bb_pos + 0, value);
+ return true;
+}
+
+static getFullyQualifiedName():string {
+ return 'BookReader';
+}
+
+static sizeOf():number {
+ return 4;
+}
+
+static createBookReader(builder:flatbuffers.Builder, books_read: number):flatbuffers.Offset {
+ builder.prep(4, 4);
+ builder.writeInt32(books_read);
+ return builder.offset();
+}
+
+
+unpack(): BookReaderT {
+ return new BookReaderT(
+ this.booksRead()
+ );
+}
+
+
+unpackTo(_o: BookReaderT): void {
+ _o.booksRead = this.booksRead();
+}
+}
+
+export class BookReaderT {
+constructor(
+ public booksRead: number = 0
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ return BookReader.createBookReader(builder,
+ this.booksRead
+ );
+}
+}
diff --git a/tests/ts/union_vector/character.js b/tests/ts/union_vector/character.js
new file mode 100644
index 0000000..04e3294
--- /dev/null
+++ b/tests/ts/union_vector/character.js
@@ -0,0 +1,38 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import { Attacker } from './attacker.js';
+import { BookReader } from './book-reader.js';
+import { Rapunzel } from './rapunzel.js';
+export var Character;
+(function (Character) {
+ Character[Character["NONE"] = 0] = "NONE";
+ Character[Character["MuLan"] = 1] = "MuLan";
+ Character[Character["Rapunzel"] = 2] = "Rapunzel";
+ Character[Character["Belle"] = 3] = "Belle";
+ Character[Character["BookFan"] = 4] = "BookFan";
+ Character[Character["Other"] = 5] = "Other";
+ Character[Character["Unused"] = 6] = "Unused";
+})(Character || (Character = {}));
+export function unionToCharacter(type, accessor) {
+ switch (Character[type]) {
+ case 'NONE': return null;
+ case 'MuLan': return accessor(new Attacker());
+ case 'Rapunzel': return accessor(new Rapunzel());
+ case 'Belle': return accessor(new BookReader());
+ case 'BookFan': return accessor(new BookReader());
+ case 'Other': return accessor('');
+ case 'Unused': return accessor('');
+ default: return null;
+ }
+}
+export function unionListToCharacter(type, accessor, index) {
+ switch (Character[type]) {
+ case 'NONE': return null;
+ case 'MuLan': return accessor(index, new Attacker());
+ case 'Rapunzel': return accessor(index, new Rapunzel());
+ case 'Belle': return accessor(index, new BookReader());
+ case 'BookFan': return accessor(index, new BookReader());
+ case 'Other': return accessor(index, '');
+ case 'Unused': return accessor(index, '');
+ default: return null;
+ }
+}
diff --git a/tests/ts/union_vector/character.ts b/tests/ts/union_vector/character.ts
new file mode 100644
index 0000000..ddad875
--- /dev/null
+++ b/tests/ts/union_vector/character.ts
@@ -0,0 +1,49 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import { Attacker, AttackerT } from './attacker.js';
+import { BookReader, BookReaderT } from './book-reader.js';
+import { Rapunzel, RapunzelT } from './rapunzel.js';
+
+
+export enum Character {
+ NONE = 0,
+ MuLan = 1,
+ Rapunzel = 2,
+ Belle = 3,
+ BookFan = 4,
+ Other = 5,
+ Unused = 6
+}
+
+export function unionToCharacter(
+ type: Character,
+ accessor: (obj:Attacker|BookReader|Rapunzel|string) => Attacker|BookReader|Rapunzel|string|null
+): Attacker|BookReader|Rapunzel|string|null {
+ switch(Character[type]) {
+ case 'NONE': return null;
+ case 'MuLan': return accessor(new Attacker())! as Attacker;
+ case 'Rapunzel': return accessor(new Rapunzel())! as Rapunzel;
+ case 'Belle': return accessor(new BookReader())! as BookReader;
+ case 'BookFan': return accessor(new BookReader())! as BookReader;
+ case 'Other': return accessor('') as string;
+ case 'Unused': return accessor('') as string;
+ default: return null;
+ }
+}
+
+export function unionListToCharacter(
+ type: Character,
+ accessor: (index: number, obj:Attacker|BookReader|Rapunzel|string) => Attacker|BookReader|Rapunzel|string|null,
+ index: number
+): Attacker|BookReader|Rapunzel|string|null {
+ switch(Character[type]) {
+ case 'NONE': return null;
+ case 'MuLan': return accessor(index, new Attacker())! as Attacker;
+ case 'Rapunzel': return accessor(index, new Rapunzel())! as Rapunzel;
+ case 'Belle': return accessor(index, new BookReader())! as BookReader;
+ case 'BookFan': return accessor(index, new BookReader())! as BookReader;
+ case 'Other': return accessor(index, '') as string;
+ case 'Unused': return accessor(index, '') as string;
+ default: return null;
+ }
+}
diff --git a/tests/ts/union_vector/falling-tub.js b/tests/ts/union_vector/falling-tub.js
new file mode 100644
index 0000000..d3c4dfe
--- /dev/null
+++ b/tests/ts/union_vector/falling-tub.js
@@ -0,0 +1,44 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+export class FallingTub {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ weight() {
+ return this.bb.readInt32(this.bb_pos);
+ }
+ mutate_weight(value) {
+ this.bb.writeInt32(this.bb_pos + 0, value);
+ return true;
+ }
+ static getFullyQualifiedName() {
+ return 'FallingTub';
+ }
+ static sizeOf() {
+ return 4;
+ }
+ static createFallingTub(builder, weight) {
+ builder.prep(4, 4);
+ builder.writeInt32(weight);
+ return builder.offset();
+ }
+ unpack() {
+ return new FallingTubT(this.weight());
+ }
+ unpackTo(_o) {
+ _o.weight = this.weight();
+ }
+}
+export class FallingTubT {
+ constructor(weight = 0) {
+ this.weight = weight;
+ }
+ pack(builder) {
+ return FallingTub.createFallingTub(builder, this.weight);
+ }
+}
diff --git a/tests/ts/union_vector/falling-tub.ts b/tests/ts/union_vector/falling-tub.ts
new file mode 100644
index 0000000..b32f99d
--- /dev/null
+++ b/tests/ts/union_vector/falling-tub.ts
@@ -0,0 +1,63 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+
+
+export class FallingTub {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):FallingTub {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+weight():number {
+ return this.bb!.readInt32(this.bb_pos);
+}
+
+mutate_weight(value:number):boolean {
+ this.bb!.writeInt32(this.bb_pos + 0, value);
+ return true;
+}
+
+static getFullyQualifiedName():string {
+ return 'FallingTub';
+}
+
+static sizeOf():number {
+ return 4;
+}
+
+static createFallingTub(builder:flatbuffers.Builder, weight: number):flatbuffers.Offset {
+ builder.prep(4, 4);
+ builder.writeInt32(weight);
+ return builder.offset();
+}
+
+
+unpack(): FallingTubT {
+ return new FallingTubT(
+ this.weight()
+ );
+}
+
+
+unpackTo(_o: FallingTubT): void {
+ _o.weight = this.weight();
+}
+}
+
+export class FallingTubT {
+constructor(
+ public weight: number = 0
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ return FallingTub.createFallingTub(builder,
+ this.weight
+ );
+}
+}
diff --git a/tests/ts/union_vector/gadget.js b/tests/ts/union_vector/gadget.js
new file mode 100644
index 0000000..202a214
--- /dev/null
+++ b/tests/ts/union_vector/gadget.js
@@ -0,0 +1,25 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import { FallingTub } from './falling-tub.js';
+import { HandFan } from './hand-fan.js';
+export var Gadget;
+(function (Gadget) {
+ Gadget[Gadget["NONE"] = 0] = "NONE";
+ Gadget[Gadget["FallingTub"] = 1] = "FallingTub";
+ Gadget[Gadget["HandFan"] = 2] = "HandFan";
+})(Gadget || (Gadget = {}));
+export function unionToGadget(type, accessor) {
+ switch (Gadget[type]) {
+ case 'NONE': return null;
+ case 'FallingTub': return accessor(new FallingTub());
+ case 'HandFan': return accessor(new HandFan());
+ default: return null;
+ }
+}
+export function unionListToGadget(type, accessor, index) {
+ switch (Gadget[type]) {
+ case 'NONE': return null;
+ case 'FallingTub': return accessor(index, new FallingTub());
+ case 'HandFan': return accessor(index, new HandFan());
+ default: return null;
+ }
+}
diff --git a/tests/ts/union_vector/gadget.ts b/tests/ts/union_vector/gadget.ts
new file mode 100644
index 0000000..b6e117b
--- /dev/null
+++ b/tests/ts/union_vector/gadget.ts
@@ -0,0 +1,36 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import { FallingTub, FallingTubT } from './falling-tub.js';
+import { HandFan, HandFanT } from './hand-fan.js';
+
+
+export enum Gadget {
+ NONE = 0,
+ FallingTub = 1,
+ HandFan = 2
+}
+
+export function unionToGadget(
+ type: Gadget,
+ accessor: (obj:FallingTub|HandFan) => FallingTub|HandFan|null
+): FallingTub|HandFan|null {
+ switch(Gadget[type]) {
+ case 'NONE': return null;
+ case 'FallingTub': return accessor(new FallingTub())! as FallingTub;
+ case 'HandFan': return accessor(new HandFan())! as HandFan;
+ default: return null;
+ }
+}
+
+export function unionListToGadget(
+ type: Gadget,
+ accessor: (index: number, obj:FallingTub|HandFan) => FallingTub|HandFan|null,
+ index: number
+): FallingTub|HandFan|null {
+ switch(Gadget[type]) {
+ case 'NONE': return null;
+ case 'FallingTub': return accessor(index, new FallingTub())! as FallingTub;
+ case 'HandFan': return accessor(index, new HandFan())! as HandFan;
+ default: return null;
+ }
+}
diff --git a/tests/ts/union_vector/hand-fan.js b/tests/ts/union_vector/hand-fan.js
new file mode 100644
index 0000000..21decca
--- /dev/null
+++ b/tests/ts/union_vector/hand-fan.js
@@ -0,0 +1,64 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import * as flatbuffers from 'flatbuffers';
+export class HandFan {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsHandFan(bb, obj) {
+ return (obj || new HandFan()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsHandFan(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new HandFan()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ length() {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
+ }
+ mutate_length(value) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt32(this.bb_pos + offset, value);
+ return true;
+ }
+ static getFullyQualifiedName() {
+ return 'HandFan';
+ }
+ static startHandFan(builder) {
+ builder.startObject(1);
+ }
+ static addLength(builder, length) {
+ builder.addFieldInt32(0, length, 0);
+ }
+ static endHandFan(builder) {
+ const offset = builder.endObject();
+ return offset;
+ }
+ static createHandFan(builder, length) {
+ HandFan.startHandFan(builder);
+ HandFan.addLength(builder, length);
+ return HandFan.endHandFan(builder);
+ }
+ unpack() {
+ return new HandFanT(this.length());
+ }
+ unpackTo(_o) {
+ _o.length = this.length();
+ }
+}
+export class HandFanT {
+ constructor(length = 0) {
+ this.length = length;
+ }
+ pack(builder) {
+ return HandFan.createHandFan(builder, this.length);
+ }
+}
diff --git a/tests/ts/union_vector/hand-fan.ts b/tests/ts/union_vector/hand-fan.ts
new file mode 100644
index 0000000..f90b4dd
--- /dev/null
+++ b/tests/ts/union_vector/hand-fan.ts
@@ -0,0 +1,87 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+
+
+export class HandFan {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):HandFan {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsHandFan(bb:flatbuffers.ByteBuffer, obj?:HandFan):HandFan {
+ return (obj || new HandFan()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsHandFan(bb:flatbuffers.ByteBuffer, obj?:HandFan):HandFan {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new HandFan()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+length():number {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
+}
+
+mutate_length(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt32(this.bb_pos + offset, value);
+ return true;
+}
+
+static getFullyQualifiedName():string {
+ return 'HandFan';
+}
+
+static startHandFan(builder:flatbuffers.Builder) {
+ builder.startObject(1);
+}
+
+static addLength(builder:flatbuffers.Builder, length:number) {
+ builder.addFieldInt32(0, length, 0);
+}
+
+static endHandFan(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+static createHandFan(builder:flatbuffers.Builder, length:number):flatbuffers.Offset {
+ HandFan.startHandFan(builder);
+ HandFan.addLength(builder, length);
+ return HandFan.endHandFan(builder);
+}
+
+unpack(): HandFanT {
+ return new HandFanT(
+ this.length()
+ );
+}
+
+
+unpackTo(_o: HandFanT): void {
+ _o.length = this.length();
+}
+}
+
+export class HandFanT {
+constructor(
+ public length: number = 0
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ return HandFan.createHandFan(builder,
+ this.length
+ );
+}
+}
diff --git a/tests/ts/union_vector/movie.js b/tests/ts/union_vector/movie.js
new file mode 100644
index 0000000..0245a43
--- /dev/null
+++ b/tests/ts/union_vector/movie.js
@@ -0,0 +1,185 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import * as flatbuffers from 'flatbuffers';
+import { Character, unionToCharacter, unionListToCharacter } from './character.js';
+export class Movie {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsMovie(bb, obj) {
+ return (obj || new Movie()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsMovie(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Movie()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static bufferHasIdentifier(bb) {
+ return bb.__has_identifier('MOVI');
+ }
+ mainCharacterType() {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.readUint8(this.bb_pos + offset) : Character.NONE;
+ }
+ mainCharacter(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? this.bb.__union_with_string(obj, this.bb_pos + offset) : null;
+ }
+ charactersType(index) {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0;
+ }
+ charactersTypeLength() {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ charactersTypeArray() {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
+ }
+ characters(index, obj) {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? this.bb.__union_with_string(obj, this.bb.__vector(this.bb_pos + offset) + index * 4) : null;
+ }
+ charactersLength() {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
+ }
+ static getFullyQualifiedName() {
+ return 'Movie';
+ }
+ static startMovie(builder) {
+ builder.startObject(4);
+ }
+ static addMainCharacterType(builder, mainCharacterType) {
+ builder.addFieldInt8(0, mainCharacterType, Character.NONE);
+ }
+ static addMainCharacter(builder, mainCharacterOffset) {
+ builder.addFieldOffset(1, mainCharacterOffset, 0);
+ }
+ static addCharactersType(builder, charactersTypeOffset) {
+ builder.addFieldOffset(2, charactersTypeOffset, 0);
+ }
+ static createCharactersTypeVector(builder, data) {
+ builder.startVector(1, data.length, 1);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt8(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startCharactersTypeVector(builder, numElems) {
+ builder.startVector(1, numElems, 1);
+ }
+ static addCharacters(builder, charactersOffset) {
+ builder.addFieldOffset(3, charactersOffset, 0);
+ }
+ static createCharactersVector(builder, data) {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+ }
+ static startCharactersVector(builder, numElems) {
+ builder.startVector(4, numElems, 4);
+ }
+ static endMovie(builder) {
+ const offset = builder.endObject();
+ return offset;
+ }
+ static finishMovieBuffer(builder, offset) {
+ builder.finish(offset, 'MOVI');
+ }
+ static finishSizePrefixedMovieBuffer(builder, offset) {
+ builder.finish(offset, 'MOVI', true);
+ }
+ static createMovie(builder, mainCharacterType, mainCharacterOffset, charactersTypeOffset, charactersOffset) {
+ Movie.startMovie(builder);
+ Movie.addMainCharacterType(builder, mainCharacterType);
+ Movie.addMainCharacter(builder, mainCharacterOffset);
+ Movie.addCharactersType(builder, charactersTypeOffset);
+ Movie.addCharacters(builder, charactersOffset);
+ return Movie.endMovie(builder);
+ }
+ unpack() {
+ return new MovieT(this.mainCharacterType(), (() => {
+ let temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this));
+ if (temp === null) {
+ return null;
+ }
+ if (typeof temp === 'string') {
+ return temp;
+ }
+ return temp.unpack();
+ })(), this.bb.createScalarList(this.charactersType.bind(this), this.charactersTypeLength()), (() => {
+ let ret = [];
+ for (let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) {
+ let targetEnum = this.charactersType(targetEnumIndex);
+ if (targetEnum === null || Character[targetEnum] === 'NONE') {
+ continue;
+ }
+ let temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex);
+ if (temp === null) {
+ continue;
+ }
+ if (typeof temp === 'string') {
+ ret.push(temp);
+ continue;
+ }
+ ret.push(temp.unpack());
+ }
+ return ret;
+ })());
+ }
+ unpackTo(_o) {
+ _o.mainCharacterType = this.mainCharacterType();
+ _o.mainCharacter = (() => {
+ let temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this));
+ if (temp === null) {
+ return null;
+ }
+ if (typeof temp === 'string') {
+ return temp;
+ }
+ return temp.unpack();
+ })();
+ _o.charactersType = this.bb.createScalarList(this.charactersType.bind(this), this.charactersTypeLength());
+ _o.characters = (() => {
+ let ret = [];
+ for (let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) {
+ let targetEnum = this.charactersType(targetEnumIndex);
+ if (targetEnum === null || Character[targetEnum] === 'NONE') {
+ continue;
+ }
+ let temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex);
+ if (temp === null) {
+ continue;
+ }
+ if (typeof temp === 'string') {
+ ret.push(temp);
+ continue;
+ }
+ ret.push(temp.unpack());
+ }
+ return ret;
+ })();
+ }
+}
+export class MovieT {
+ constructor(mainCharacterType = Character.NONE, mainCharacter = null, charactersType = [], characters = []) {
+ this.mainCharacterType = mainCharacterType;
+ this.mainCharacter = mainCharacter;
+ this.charactersType = charactersType;
+ this.characters = characters;
+ }
+ pack(builder) {
+ const mainCharacter = builder.createObjectOffset(this.mainCharacter);
+ const charactersType = Movie.createCharactersTypeVector(builder, this.charactersType);
+ const characters = Movie.createCharactersVector(builder, builder.createObjectOffsetList(this.characters));
+ return Movie.createMovie(builder, this.mainCharacterType, mainCharacter, charactersType, characters);
+ }
+}
diff --git a/tests/ts/union_vector/movie.ts b/tests/ts/union_vector/movie.ts
new file mode 100644
index 0000000..6edeb53
--- /dev/null
+++ b/tests/ts/union_vector/movie.ts
@@ -0,0 +1,211 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+import { Attacker, AttackerT } from './attacker.js';
+import { BookReader, BookReaderT } from './book-reader.js';
+import { Character, unionToCharacter, unionListToCharacter } from './character.js';
+import { Rapunzel, RapunzelT } from './rapunzel.js';
+
+
+export class Movie {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):Movie {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsMovie(bb:flatbuffers.ByteBuffer, obj?:Movie):Movie {
+ return (obj || new Movie()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsMovie(bb:flatbuffers.ByteBuffer, obj?:Movie):Movie {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Movie()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean {
+ return bb.__has_identifier('MOVI');
+}
+
+mainCharacterType():Character {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.readUint8(this.bb_pos + offset) : Character.NONE;
+}
+
+mainCharacter<T extends flatbuffers.Table>(obj:any|string):any|string|null {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.__union_with_string(obj, this.bb_pos + offset) : null;
+}
+
+charactersType(index: number):Character|null {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
+}
+
+charactersTypeLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+charactersTypeArray():Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
+}
+
+characters(index: number, obj:any|string):any|string|null {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? this.bb!.__union_with_string(obj, this.bb!.__vector(this.bb_pos + offset) + index * 4) : null;
+}
+
+charactersLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+static getFullyQualifiedName():string {
+ return 'Movie';
+}
+
+static startMovie(builder:flatbuffers.Builder) {
+ builder.startObject(4);
+}
+
+static addMainCharacterType(builder:flatbuffers.Builder, mainCharacterType:Character) {
+ builder.addFieldInt8(0, mainCharacterType, Character.NONE);
+}
+
+static addMainCharacter(builder:flatbuffers.Builder, mainCharacterOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(1, mainCharacterOffset, 0);
+}
+
+static addCharactersType(builder:flatbuffers.Builder, charactersTypeOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(2, charactersTypeOffset, 0);
+}
+
+static createCharactersTypeVector(builder:flatbuffers.Builder, data:Character[]):flatbuffers.Offset {
+ builder.startVector(1, data.length, 1);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt8(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startCharactersTypeVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(1, numElems, 1);
+}
+
+static addCharacters(builder:flatbuffers.Builder, charactersOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(3, charactersOffset, 0);
+}
+
+static createCharactersVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]!);
+ }
+ return builder.endVector();
+}
+
+static startCharactersVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static endMovie(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+static finishMovieBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
+ builder.finish(offset, 'MOVI');
+}
+
+static finishSizePrefixedMovieBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
+ builder.finish(offset, 'MOVI', true);
+}
+
+static createMovie(builder:flatbuffers.Builder, mainCharacterType:Character, mainCharacterOffset:flatbuffers.Offset, charactersTypeOffset:flatbuffers.Offset, charactersOffset:flatbuffers.Offset):flatbuffers.Offset {
+ Movie.startMovie(builder);
+ Movie.addMainCharacterType(builder, mainCharacterType);
+ Movie.addMainCharacter(builder, mainCharacterOffset);
+ Movie.addCharactersType(builder, charactersTypeOffset);
+ Movie.addCharacters(builder, charactersOffset);
+ return Movie.endMovie(builder);
+}
+
+unpack(): MovieT {
+ return new MovieT(
+ this.mainCharacterType(),
+ (() => {
+ let temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this));
+ if(temp === null) { return null; }
+ if(typeof temp === 'string') { return temp; }
+ return temp.unpack()
+ })(),
+ this.bb!.createScalarList(this.charactersType.bind(this), this.charactersTypeLength()),
+ (() => {
+ let ret = [];
+ for(let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) {
+ let targetEnum = this.charactersType(targetEnumIndex);
+ if(targetEnum === null || Character[targetEnum!] === 'NONE') { continue; }
+
+ let temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex);
+ if(temp === null) { continue; }
+ if(typeof temp === 'string') { ret.push(temp); continue; }
+ ret.push(temp.unpack());
+ }
+ return ret;
+ })()
+ );
+}
+
+
+unpackTo(_o: MovieT): void {
+ _o.mainCharacterType = this.mainCharacterType();
+ _o.mainCharacter = (() => {
+ let temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this));
+ if(temp === null) { return null; }
+ if(typeof temp === 'string') { return temp; }
+ return temp.unpack()
+ })();
+ _o.charactersType = this.bb!.createScalarList(this.charactersType.bind(this), this.charactersTypeLength());
+ _o.characters = (() => {
+ let ret = [];
+ for(let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) {
+ let targetEnum = this.charactersType(targetEnumIndex);
+ if(targetEnum === null || Character[targetEnum!] === 'NONE') { continue; }
+
+ let temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex);
+ if(temp === null) { continue; }
+ if(typeof temp === 'string') { ret.push(temp); continue; }
+ ret.push(temp.unpack());
+ }
+ return ret;
+ })();
+}
+}
+
+export class MovieT {
+constructor(
+ public mainCharacterType: Character = Character.NONE,
+ public mainCharacter: AttackerT|BookReaderT|RapunzelT|string|null = null,
+ public charactersType: (Character)[] = [],
+ public characters: (AttackerT|BookReaderT|RapunzelT|string)[] = []
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ const mainCharacter = builder.createObjectOffset(this.mainCharacter);
+ const charactersType = Movie.createCharactersTypeVector(builder, this.charactersType);
+ const characters = Movie.createCharactersVector(builder, builder.createObjectOffsetList(this.characters));
+
+ return Movie.createMovie(builder,
+ this.mainCharacterType,
+ mainCharacter,
+ charactersType,
+ characters
+ );
+}
+}
diff --git a/tests/ts/union_vector/rapunzel.js b/tests/ts/union_vector/rapunzel.js
new file mode 100644
index 0000000..67a5e44
--- /dev/null
+++ b/tests/ts/union_vector/rapunzel.js
@@ -0,0 +1,44 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+export class Rapunzel {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ hairLength() {
+ return this.bb.readInt32(this.bb_pos);
+ }
+ mutate_hair_length(value) {
+ this.bb.writeInt32(this.bb_pos + 0, value);
+ return true;
+ }
+ static getFullyQualifiedName() {
+ return 'Rapunzel';
+ }
+ static sizeOf() {
+ return 4;
+ }
+ static createRapunzel(builder, hair_length) {
+ builder.prep(4, 4);
+ builder.writeInt32(hair_length);
+ return builder.offset();
+ }
+ unpack() {
+ return new RapunzelT(this.hairLength());
+ }
+ unpackTo(_o) {
+ _o.hairLength = this.hairLength();
+ }
+}
+export class RapunzelT {
+ constructor(hairLength = 0) {
+ this.hairLength = hairLength;
+ }
+ pack(builder) {
+ return Rapunzel.createRapunzel(builder, this.hairLength);
+ }
+}
diff --git a/tests/ts/union_vector/rapunzel.ts b/tests/ts/union_vector/rapunzel.ts
new file mode 100644
index 0000000..e1dc63d
--- /dev/null
+++ b/tests/ts/union_vector/rapunzel.ts
@@ -0,0 +1,63 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+
+
+export class Rapunzel {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+ __init(i:number, bb:flatbuffers.ByteBuffer):Rapunzel {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+hairLength():number {
+ return this.bb!.readInt32(this.bb_pos);
+}
+
+mutate_hair_length(value:number):boolean {
+ this.bb!.writeInt32(this.bb_pos + 0, value);
+ return true;
+}
+
+static getFullyQualifiedName():string {
+ return 'Rapunzel';
+}
+
+static sizeOf():number {
+ return 4;
+}
+
+static createRapunzel(builder:flatbuffers.Builder, hair_length: number):flatbuffers.Offset {
+ builder.prep(4, 4);
+ builder.writeInt32(hair_length);
+ return builder.offset();
+}
+
+
+unpack(): RapunzelT {
+ return new RapunzelT(
+ this.hairLength()
+ );
+}
+
+
+unpackTo(_o: RapunzelT): void {
+ _o.hairLength = this.hairLength();
+}
+}
+
+export class RapunzelT {
+constructor(
+ public hairLength: number = 0
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ return Rapunzel.createRapunzel(builder,
+ this.hairLength
+ );
+}
+}
diff --git a/tests/ts/union_vector/union_vector_generated.js b/tests/ts/union_vector/union_vector_generated.js
new file mode 100644
index 0000000..69ea199
--- /dev/null
+++ b/tests/ts/union_vector/union_vector_generated.js
@@ -0,0 +1,9 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+export { Attacker, AttackerT } from './attacker.js';
+export { BookReader, BookReaderT } from './book-reader.js';
+export { Character, unionToCharacter, unionListToCharacter } from './character.js';
+export { FallingTub, FallingTubT } from './falling-tub.js';
+export { Gadget, unionToGadget, unionListToGadget } from './gadget.js';
+export { HandFan, HandFanT } from './hand-fan.js';
+export { Movie, MovieT } from './movie.js';
+export { Rapunzel, RapunzelT } from './rapunzel.js';
diff --git a/tests/ts/union_vector/union_vector_generated.ts b/tests/ts/union_vector/union_vector_generated.ts
new file mode 100644
index 0000000..5527abe
--- /dev/null
+++ b/tests/ts/union_vector/union_vector_generated.ts
@@ -0,0 +1,10 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+export { Attacker, AttackerT } from './attacker.js';
+export { BookReader, BookReaderT } from './book-reader.js';
+export { Character, unionToCharacter, unionListToCharacter } from './character.js';
+export { FallingTub, FallingTubT } from './falling-tub.js';
+export { Gadget, unionToGadget, unionListToGadget } from './gadget.js';
+export { HandFan, HandFanT } from './hand-fan.js';
+export { Movie, MovieT } from './movie.js';
+export { Rapunzel, RapunzelT } from './rapunzel.js';
diff --git a/tests/type_field_collsion.fbs b/tests/type_field_collsion.fbs
new file mode 100644
index 0000000..ec73544
--- /dev/null
+++ b/tests/type_field_collsion.fbs
@@ -0,0 +1,8 @@
+namespace type_field_collsion;
+
+// This table tests collsions of identifiers.
+table Collision {
+ collision : int;
+}
+
+root_type Collision;
diff --git a/tests/type_field_collsion/Collision.cs b/tests/type_field_collsion/Collision.cs
new file mode 100644
index 0000000..2fc24f3
--- /dev/null
+++ b/tests/type_field_collsion/Collision.cs
@@ -0,0 +1,73 @@
+// <auto-generated>
+// automatically generated by the FlatBuffers compiler, do not modify
+// </auto-generated>
+
+namespace type_field_collsion
+{
+
+using global::System;
+using global::System.Collections.Generic;
+using global::Google.FlatBuffers;
+
+public struct Collision : IFlatbufferObject
+{
+ private Table __p;
+ public ByteBuffer ByteBuffer { get { return __p.bb; } }
+ public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_8(); }
+ public static Collision GetRootAsCollision(ByteBuffer _bb) { return GetRootAsCollision(_bb, new Collision()); }
+ public static Collision GetRootAsCollision(ByteBuffer _bb, Collision obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
+ public void __init(int _i, ByteBuffer _bb) { __p = new Table(_i, _bb); }
+ public Collision __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
+
+ public int Collision_ { get { int o = __p.__offset(4); return o != 0 ? __p.bb.GetInt(o + __p.bb_pos) : (int)0; } }
+
+ public static Offset<type_field_collsion.Collision> CreateCollision(FlatBufferBuilder builder,
+ int collision = 0) {
+ builder.StartTable(1);
+ Collision.AddCollision(builder, collision);
+ return Collision.EndCollision(builder);
+ }
+
+ public static void StartCollision(FlatBufferBuilder builder) { builder.StartTable(1); }
+ public static void AddCollision(FlatBufferBuilder builder, int collision) { builder.AddInt(0, collision, 0); }
+ public static Offset<type_field_collsion.Collision> EndCollision(FlatBufferBuilder builder) {
+ int o = builder.EndTable();
+ return new Offset<type_field_collsion.Collision>(o);
+ }
+ public static void FinishCollisionBuffer(FlatBufferBuilder builder, Offset<type_field_collsion.Collision> offset) { builder.Finish(offset.Value); }
+ public static void FinishSizePrefixedCollisionBuffer(FlatBufferBuilder builder, Offset<type_field_collsion.Collision> offset) { builder.FinishSizePrefixed(offset.Value); }
+ public CollisionT UnPack() {
+ var _o = new CollisionT();
+ this.UnPackTo(_o);
+ return _o;
+ }
+ public void UnPackTo(CollisionT _o) {
+ _o.Collision_ = this.Collision_;
+ }
+ public static Offset<type_field_collsion.Collision> Pack(FlatBufferBuilder builder, CollisionT _o) {
+ if (_o == null) return default(Offset<type_field_collsion.Collision>);
+ return CreateCollision(
+ builder,
+ _o.Collision_);
+ }
+}
+
+public class CollisionT
+{
+ public int Collision_ { get; set; }
+
+ public CollisionT() {
+ this.Collision_ = 0;
+ }
+ public static CollisionT DeserializeFromBinary(byte[] fbBuffer) {
+ return Collision.GetRootAsCollision(new ByteBuffer(fbBuffer)).UnPack();
+ }
+ public byte[] SerializeToBinary() {
+ var fbb = new FlatBufferBuilder(0x10000);
+ Collision.FinishCollisionBuffer(fbb, Collision.Pack(fbb, this));
+ return fbb.DataBuffer.ToSizedArray();
+ }
+}
+
+
+}
diff --git a/tests/union_vector/Attacker.cs b/tests/union_vector/Attacker.cs
index cf6d1a7..57c32fa 100644
--- a/tests/union_vector/Attacker.cs
+++ b/tests/union_vector/Attacker.cs
@@ -4,13 +4,13 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
public struct Attacker : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
- public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_8(); }
public static Attacker GetRootAsAttacker(ByteBuffer _bb) { return GetRootAsAttacker(_bb, new Attacker()); }
public static Attacker GetRootAsAttacker(ByteBuffer _bb, Attacker obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public void __init(int _i, ByteBuffer _bb) { __p = new Table(_i, _bb); }
diff --git a/tests/union_vector/Attacker.java b/tests/union_vector/Attacker.java
index 482a3ae..e156444 100644
--- a/tests/union_vector/Attacker.java
+++ b/tests/union_vector/Attacker.java
@@ -7,7 +7,7 @@
@SuppressWarnings("unused")
public final class Attacker extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static Attacker getRootAsAttacker(ByteBuffer _bb) { return getRootAsAttacker(_bb, new Attacker()); }
public static Attacker getRootAsAttacker(ByteBuffer _bb, Attacker obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
diff --git a/tests/union_vector/Attacker.kt b/tests/union_vector/Attacker.kt
index 9f22e98..6942bad 100644
--- a/tests/union_vector/Attacker.kt
+++ b/tests/union_vector/Attacker.kt
@@ -29,7 +29,7 @@
}
}
companion object {
- fun validateVersion() = Constants.FLATBUFFERS_2_0_0()
+ fun validateVersion() = Constants.FLATBUFFERS_2_0_8()
fun getRootAsAttacker(_bb: ByteBuffer): Attacker = getRootAsAttacker(_bb, Attacker())
fun getRootAsAttacker(_bb: ByteBuffer, obj: Attacker): Attacker {
_bb.order(ByteOrder.LITTLE_ENDIAN)
diff --git a/tests/union_vector/BookReader.cs b/tests/union_vector/BookReader.cs
index 6cd88b3..74dd32f 100644
--- a/tests/union_vector/BookReader.cs
+++ b/tests/union_vector/BookReader.cs
@@ -4,7 +4,7 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
public struct BookReader : IFlatbufferObject
{
diff --git a/tests/union_vector/Character.cs b/tests/union_vector/Character.cs
index 4978bdc..181f914 100644
--- a/tests/union_vector/Character.cs
+++ b/tests/union_vector/Character.cs
@@ -37,7 +37,7 @@
public string AsUnused() { return this.As<string>(); }
public static CharacterUnion FromUnused(string _unused) { return new CharacterUnion{ Type = Character.Unused, Value = _unused }; }
- public static int Pack(FlatBuffers.FlatBufferBuilder builder, CharacterUnion _o) {
+ public static int Pack(Google.FlatBuffers.FlatBufferBuilder builder, CharacterUnion _o) {
switch (_o.Type) {
default: return 0;
case Character.MuLan: return Attacker.Pack(builder, _o.AsMuLan()).Value;
diff --git a/tests/union_vector/FallingTub.cs b/tests/union_vector/FallingTub.cs
index 36c574c..792dbed 100644
--- a/tests/union_vector/FallingTub.cs
+++ b/tests/union_vector/FallingTub.cs
@@ -4,7 +4,7 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
public struct FallingTub : IFlatbufferObject
{
diff --git a/tests/union_vector/Gadget.cs b/tests/union_vector/Gadget.cs
index e4770dd..8e5ca7b 100644
--- a/tests/union_vector/Gadget.cs
+++ b/tests/union_vector/Gadget.cs
@@ -25,7 +25,7 @@
public HandFanT AsHandFan() { return this.As<HandFanT>(); }
public static GadgetUnion FromHandFan(HandFanT _handfan) { return new GadgetUnion{ Type = Gadget.HandFan, Value = _handfan }; }
- public static int Pack(FlatBuffers.FlatBufferBuilder builder, GadgetUnion _o) {
+ public static int Pack(Google.FlatBuffers.FlatBufferBuilder builder, GadgetUnion _o) {
switch (_o.Type) {
default: return 0;
case Gadget.FallingTub: return FallingTub.Pack(builder, _o.AsFallingTub()).Value;
diff --git a/tests/union_vector/HandFan.cs b/tests/union_vector/HandFan.cs
index a888abf..52e3e74 100644
--- a/tests/union_vector/HandFan.cs
+++ b/tests/union_vector/HandFan.cs
@@ -4,13 +4,13 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
public struct HandFan : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
- public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_8(); }
public static HandFan GetRootAsHandFan(ByteBuffer _bb) { return GetRootAsHandFan(_bb, new HandFan()); }
public static HandFan GetRootAsHandFan(ByteBuffer _bb, HandFan obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public void __init(int _i, ByteBuffer _bb) { __p = new Table(_i, _bb); }
diff --git a/tests/union_vector/HandFan.java b/tests/union_vector/HandFan.java
index 14b2520..641da84 100644
--- a/tests/union_vector/HandFan.java
+++ b/tests/union_vector/HandFan.java
@@ -7,7 +7,7 @@
@SuppressWarnings("unused")
public final class HandFan extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static HandFan getRootAsHandFan(ByteBuffer _bb) { return getRootAsHandFan(_bb, new HandFan()); }
public static HandFan getRootAsHandFan(ByteBuffer _bb, HandFan obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
diff --git a/tests/union_vector/HandFan.kt b/tests/union_vector/HandFan.kt
index 0a8a055..8304d1f 100644
--- a/tests/union_vector/HandFan.kt
+++ b/tests/union_vector/HandFan.kt
@@ -29,7 +29,7 @@
}
}
companion object {
- fun validateVersion() = Constants.FLATBUFFERS_2_0_0()
+ fun validateVersion() = Constants.FLATBUFFERS_2_0_8()
fun getRootAsHandFan(_bb: ByteBuffer): HandFan = getRootAsHandFan(_bb, HandFan())
fun getRootAsHandFan(_bb: ByteBuffer, obj: HandFan): HandFan {
_bb.order(ByteOrder.LITTLE_ENDIAN)
diff --git a/tests/union_vector/Movie.cs b/tests/union_vector/Movie.cs
index f85daa6..9bc2d9a 100644
--- a/tests/union_vector/Movie.cs
+++ b/tests/union_vector/Movie.cs
@@ -4,13 +4,13 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
public struct Movie : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
- public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_8(); }
public static Movie GetRootAsMovie(ByteBuffer _bb) { return GetRootAsMovie(_bb, new Movie()); }
public static Movie GetRootAsMovie(ByteBuffer _bb, Movie obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public static bool MovieBufferHasIdentifier(ByteBuffer _bb) { return Table.__has_identifier(_bb, "MOVI"); }
@@ -57,10 +57,14 @@
public static void AddCharactersType(FlatBufferBuilder builder, VectorOffset charactersTypeOffset) { builder.AddOffset(2, charactersTypeOffset.Value, 0); }
public static VectorOffset CreateCharactersTypeVector(FlatBufferBuilder builder, Character[] data) { builder.StartVector(1, data.Length, 1); for (int i = data.Length - 1; i >= 0; i--) builder.AddByte((byte)data[i]); return builder.EndVector(); }
public static VectorOffset CreateCharactersTypeVectorBlock(FlatBufferBuilder builder, Character[] data) { builder.StartVector(1, data.Length, 1); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateCharactersTypeVectorBlock(FlatBufferBuilder builder, ArraySegment<Character> data) { builder.StartVector(1, data.Count, 1); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateCharactersTypeVectorBlock(FlatBufferBuilder builder, IntPtr dataPtr, int sizeInBytes) { builder.StartVector(1, sizeInBytes, 1); builder.Add<Character>(dataPtr, sizeInBytes); return builder.EndVector(); }
public static void StartCharactersTypeVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(1, numElems, 1); }
public static void AddCharacters(FlatBufferBuilder builder, VectorOffset charactersOffset) { builder.AddOffset(3, charactersOffset.Value, 0); }
public static VectorOffset CreateCharactersVector(FlatBufferBuilder builder, int[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddOffset(data[i]); return builder.EndVector(); }
public static VectorOffset CreateCharactersVectorBlock(FlatBufferBuilder builder, int[] data) { builder.StartVector(4, data.Length, 4); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateCharactersVectorBlock(FlatBufferBuilder builder, ArraySegment<int> data) { builder.StartVector(4, data.Count, 4); builder.Add(data); return builder.EndVector(); }
+ public static VectorOffset CreateCharactersVectorBlock(FlatBufferBuilder builder, IntPtr dataPtr, int sizeInBytes) { builder.StartVector(1, sizeInBytes, 1); builder.Add<int>(dataPtr, sizeInBytes); return builder.EndVector(); }
public static void StartCharactersVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
public static Offset<Movie> EndMovie(FlatBufferBuilder builder) {
int o = builder.EndTable();
diff --git a/tests/union_vector/Movie.java b/tests/union_vector/Movie.java
index dc40d80..2cf1622 100644
--- a/tests/union_vector/Movie.java
+++ b/tests/union_vector/Movie.java
@@ -7,7 +7,7 @@
@SuppressWarnings("unused")
public final class Movie extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
+ public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static Movie getRootAsMovie(ByteBuffer _bb) { return getRootAsMovie(_bb, new Movie()); }
public static Movie getRootAsMovie(ByteBuffer _bb, Movie obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public static boolean MovieBufferHasIdentifier(ByteBuffer _bb) { return __has_identifier(_bb, "MOVI"); }
diff --git a/tests/union_vector/Movie.kt b/tests/union_vector/Movie.kt
index a9ad906..ee26a59 100644
--- a/tests/union_vector/Movie.kt
+++ b/tests/union_vector/Movie.kt
@@ -67,7 +67,7 @@
val o = __offset(10); return if (o != 0) __vector_len(o) else 0
}
companion object {
- fun validateVersion() = Constants.FLATBUFFERS_2_0_0()
+ fun validateVersion() = Constants.FLATBUFFERS_2_0_8()
fun getRootAsMovie(_bb: ByteBuffer): Movie = getRootAsMovie(_bb, Movie())
fun getRootAsMovie(_bb: ByteBuffer, obj: Movie): Movie {
_bb.order(ByteOrder.LITTLE_ENDIAN)
diff --git a/tests/union_vector/Rapunzel.cs b/tests/union_vector/Rapunzel.cs
index 31d2cdf..b9559d3 100644
--- a/tests/union_vector/Rapunzel.cs
+++ b/tests/union_vector/Rapunzel.cs
@@ -4,7 +4,7 @@
using global::System;
using global::System.Collections.Generic;
-using global::FlatBuffers;
+using global::Google.FlatBuffers;
public struct Rapunzel : IFlatbufferObject
{
diff --git a/tests/union_vector/attacker.ts b/tests/union_vector/attacker.ts
index af37020..6b3fc0f 100644
--- a/tests/union_vector/attacker.ts
+++ b/tests/union_vector/attacker.ts
@@ -7,7 +7,7 @@
export class Attacker {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
-__init(i:number, bb:flatbuffers.ByteBuffer):Attacker {
+ __init(i:number, bb:flatbuffers.ByteBuffer):Attacker {
this.bb_pos = i;
this.bb = bb;
return this;
diff --git a/tests/union_vector/book-reader.ts b/tests/union_vector/book-reader.ts
index 2310600..7a31278 100644
--- a/tests/union_vector/book-reader.ts
+++ b/tests/union_vector/book-reader.ts
@@ -7,7 +7,7 @@
export class BookReader {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
-__init(i:number, bb:flatbuffers.ByteBuffer):BookReader {
+ __init(i:number, bb:flatbuffers.ByteBuffer):BookReader {
this.bb_pos = i;
this.bb = bb;
return this;
diff --git a/tests/union_vector/character.ts b/tests/union_vector/character.ts
index dbf8d51..d8ffbc2 100644
--- a/tests/union_vector/character.ts
+++ b/tests/union_vector/character.ts
@@ -5,7 +5,7 @@
import { Rapunzel, RapunzelT } from './rapunzel';
-export enum Character{
+export enum Character {
NONE = 0,
MuLan = 1,
Rapunzel = 2,
@@ -47,4 +47,3 @@
default: return null;
}
}
-
diff --git a/tests/union_vector/falling-tub.ts b/tests/union_vector/falling-tub.ts
index 3a836b3..b32f99d 100644
--- a/tests/union_vector/falling-tub.ts
+++ b/tests/union_vector/falling-tub.ts
@@ -7,7 +7,7 @@
export class FallingTub {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
-__init(i:number, bb:flatbuffers.ByteBuffer):FallingTub {
+ __init(i:number, bb:flatbuffers.ByteBuffer):FallingTub {
this.bb_pos = i;
this.bb = bb;
return this;
diff --git a/tests/union_vector/gadget.ts b/tests/union_vector/gadget.ts
index 4d84b0a..328071e 100644
--- a/tests/union_vector/gadget.ts
+++ b/tests/union_vector/gadget.ts
@@ -4,7 +4,7 @@
import { HandFan, HandFanT } from './hand-fan';
-export enum Gadget{
+export enum Gadget {
NONE = 0,
FallingTub = 1,
HandFan = 2
@@ -34,4 +34,3 @@
default: return null;
}
}
-
diff --git a/tests/union_vector/hand-fan.ts b/tests/union_vector/hand-fan.ts
index 4a770ba..f90b4dd 100644
--- a/tests/union_vector/hand-fan.ts
+++ b/tests/union_vector/hand-fan.ts
@@ -7,7 +7,7 @@
export class HandFan {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
-__init(i:number, bb:flatbuffers.ByteBuffer):HandFan {
+ __init(i:number, bb:flatbuffers.ByteBuffer):HandFan {
this.bb_pos = i;
this.bb = bb;
return this;
diff --git a/tests/union_vector/movie.ts b/tests/union_vector/movie.ts
index b3e8381..fceadaa 100644
--- a/tests/union_vector/movie.ts
+++ b/tests/union_vector/movie.ts
@@ -11,7 +11,7 @@
export class Movie {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
-__init(i:number, bb:flatbuffers.ByteBuffer):Movie {
+ __init(i:number, bb:flatbuffers.ByteBuffer):Movie {
this.bb_pos = i;
this.bb = bb;
return this;
diff --git a/tests/union_vector/rapunzel.ts b/tests/union_vector/rapunzel.ts
index 28f6e99..e1dc63d 100644
--- a/tests/union_vector/rapunzel.ts
+++ b/tests/union_vector/rapunzel.ts
@@ -7,7 +7,7 @@
export class Rapunzel {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
-__init(i:number, bb:flatbuffers.ByteBuffer):Rapunzel {
+ __init(i:number, bb:flatbuffers.ByteBuffer):Rapunzel {
this.bb_pos = i;
this.bb = bb;
return this;
diff --git a/tests/union_vector/union_vector_generated.h b/tests/union_vector/union_vector_generated.h
index e08df6a..8f60272 100644
--- a/tests/union_vector/union_vector_generated.h
+++ b/tests/union_vector/union_vector_generated.h
@@ -6,6 +6,13 @@
#include "flatbuffers/flatbuffers.h"
+// Ensure the included flatbuffers.h is the same version as when this file was
+// generated, otherwise it may not be compatible.
+static_assert(FLATBUFFERS_VERSION_MAJOR == 2 &&
+ FLATBUFFERS_VERSION_MINOR == 0 &&
+ FLATBUFFERS_VERSION_REVISION == 8,
+ "Non-compatible flatbuffers version included");
+
struct Attacker;
struct AttackerBuilder;
struct AttackerT;
@@ -349,9 +356,6 @@
static const flatbuffers::TypeTable *MiniReflectTypeTable() {
return RapunzelTypeTable();
}
- static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
- return "Rapunzel";
- }
Rapunzel()
: hair_length_(0) {
}
@@ -385,9 +389,6 @@
static const flatbuffers::TypeTable *MiniReflectTypeTable() {
return BookReaderTypeTable();
}
- static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
- return "BookReader";
- }
BookReader()
: books_read_(0) {
}
@@ -421,9 +422,6 @@
static const flatbuffers::TypeTable *MiniReflectTypeTable() {
return FallingTubTypeTable();
}
- static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
- return "FallingTub";
- }
FallingTub()
: weight_(0) {
}
@@ -451,9 +449,6 @@
struct AttackerT : public flatbuffers::NativeTable {
typedef Attacker TableType;
- static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
- return "AttackerT";
- }
int32_t sword_attack_damage = 0;
};
@@ -463,9 +458,6 @@
static const flatbuffers::TypeTable *MiniReflectTypeTable() {
return AttackerTypeTable();
}
- static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
- return "Attacker";
- }
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_SWORD_ATTACK_DAMAGE = 4
};
@@ -515,9 +507,6 @@
struct HandFanT : public flatbuffers::NativeTable {
typedef HandFan TableType;
- static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
- return "HandFanT";
- }
int32_t length = 0;
};
@@ -527,9 +516,6 @@
static const flatbuffers::TypeTable *MiniReflectTypeTable() {
return HandFanTypeTable();
}
- static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
- return "HandFan";
- }
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_LENGTH = 4
};
@@ -579,9 +565,6 @@
struct MovieT : public flatbuffers::NativeTable {
typedef Movie TableType;
- static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
- return "MovieT";
- }
CharacterUnion main_character{};
std::vector<CharacterUnion> characters{};
};
@@ -592,9 +575,6 @@
static const flatbuffers::TypeTable *MiniReflectTypeTable() {
return MovieTypeTable();
}
- static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
- return "Movie";
- }
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_MAIN_CHARACTER_TYPE = 4,
VT_MAIN_CHARACTER = 6,
@@ -813,8 +793,8 @@
(void)_resolver;
{ auto _e = main_character_type(); _o->main_character.type = _e; }
{ auto _e = main_character(); if (_e) _o->main_character.value = CharacterUnion::UnPack(_e, main_character_type(), _resolver); }
- { auto _e = characters_type(); if (_e) { _o->characters.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->characters[_i].type = static_cast<Character>(_e->Get(_i)); } } }
- { auto _e = characters(); if (_e) { _o->characters.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->characters[_i].value = CharacterUnion::UnPack(_e->Get(_i), characters_type()->GetEnum<Character>(_i), _resolver); } } }
+ { auto _e = characters_type(); if (_e) { _o->characters.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->characters[_i].type = static_cast<Character>(_e->Get(_i)); } } else { _o->characters.resize(0); } }
+ { auto _e = characters(); if (_e) { _o->characters.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->characters[_i].value = CharacterUnion::UnPack(_e->Get(_i), characters_type()->GetEnum<Character>(_i), _resolver); } } else { _o->characters.resize(0); } }
}
inline flatbuffers::Offset<Movie> Movie::Pack(flatbuffers::FlatBufferBuilder &_fbb, const MovieT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
diff --git a/tests/union_vector/union_vector_generated.ts b/tests/union_vector/union_vector_generated.ts
new file mode 100644
index 0000000..d3b41c4
--- /dev/null
+++ b/tests/union_vector/union_vector_generated.ts
@@ -0,0 +1,10 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+export { Attacker, AttackerT } from './attacker';
+export { BookReader, BookReaderT } from './book-reader';
+export { Character, unionToCharacter, unionListToCharacter } from './character';
+export { FallingTub, FallingTubT } from './falling-tub';
+export { Gadget, unionToGadget, unionListToGadget } from './gadget';
+export { HandFan, HandFanT } from './hand-fan';
+export { Movie, MovieT } from './movie';
+export { Rapunzel, RapunzelT } from './rapunzel';
diff --git a/tests/util_test.cpp b/tests/util_test.cpp
new file mode 100644
index 0000000..d6db916
--- /dev/null
+++ b/tests/util_test.cpp
@@ -0,0 +1,167 @@
+#include "util_test.h"
+
+#include "flatbuffers/util.h"
+#include "test_assert.h"
+
+namespace flatbuffers {
+namespace tests {
+namespace {
+
+template<typename T>
+void NumericUtilsTestInteger(const char *lower, const char *upper) {
+ T x;
+ TEST_EQ(flatbuffers::StringToNumber("1q", &x), false);
+ TEST_EQ(x, 0);
+ TEST_EQ(flatbuffers::StringToNumber(upper, &x), false);
+ TEST_EQ(x, flatbuffers::numeric_limits<T>::max());
+ TEST_EQ(flatbuffers::StringToNumber(lower, &x), false);
+ auto expval = flatbuffers::is_unsigned<T>::value
+ ? flatbuffers::numeric_limits<T>::max()
+ : flatbuffers::numeric_limits<T>::lowest();
+ TEST_EQ(x, expval);
+}
+
+template<typename T>
+void NumericUtilsTestFloat(const char *lower, const char *upper) {
+ T f;
+ TEST_EQ(flatbuffers::StringToNumber("", &f), false);
+ TEST_EQ(flatbuffers::StringToNumber("1q", &f), false);
+ TEST_EQ(f, 0);
+ TEST_EQ(flatbuffers::StringToNumber(upper, &f), true);
+ TEST_EQ(f, +flatbuffers::numeric_limits<T>::infinity());
+ TEST_EQ(flatbuffers::StringToNumber(lower, &f), true);
+ TEST_EQ(f, -flatbuffers::numeric_limits<T>::infinity());
+}
+} // namespace
+
+void NumericUtilsTest() {
+ NumericUtilsTestInteger<uint64_t>("-1", "18446744073709551616");
+ NumericUtilsTestInteger<uint8_t>("-1", "256");
+ NumericUtilsTestInteger<int64_t>("-9223372036854775809",
+ "9223372036854775808");
+ NumericUtilsTestInteger<int8_t>("-129", "128");
+ NumericUtilsTestFloat<float>("-3.4029e+38", "+3.4029e+38");
+ NumericUtilsTestFloat<float>("-1.7977e+308", "+1.7977e+308");
+}
+
+void IsAsciiUtilsTest() {
+ char c = -128;
+ for (int cnt = 0; cnt < 256; cnt++) {
+ auto alpha = (('a' <= c) && (c <= 'z')) || (('A' <= c) && (c <= 'Z'));
+ auto dec = (('0' <= c) && (c <= '9'));
+ auto hex = (('a' <= c) && (c <= 'f')) || (('A' <= c) && (c <= 'F'));
+ TEST_EQ(flatbuffers::is_alpha(c), alpha);
+ TEST_EQ(flatbuffers::is_alnum(c), alpha || dec);
+ TEST_EQ(flatbuffers::is_digit(c), dec);
+ TEST_EQ(flatbuffers::is_xdigit(c), dec || hex);
+ c += 1;
+ }
+}
+
+void UtilConvertCase() {
+ {
+ struct TestCase {
+ std::string input;
+ flatbuffers::Case output_case;
+ std::string expected_output;
+ };
+
+ std::vector<TestCase> cases;
+
+ // Tests for the common cases
+ cases.push_back({ "the_quick_brown_fox", flatbuffers::Case::kUpperCamel,
+ "TheQuickBrownFox" });
+ cases.push_back({ "the_quick_brown_fox", flatbuffers::Case::kLowerCamel,
+ "theQuickBrownFox" });
+ cases.push_back({ "the_quick_brown_fox", flatbuffers::Case::kSnake,
+ "the_quick_brown_fox" });
+ cases.push_back({ "the_quick_brown_fox", flatbuffers::Case::kScreamingSnake,
+ "THE_QUICK_BROWN_FOX" });
+ cases.push_back({ "the_quick_brown_fox", flatbuffers::Case::kAllLower,
+ "the_quick_brown_fox" });
+ cases.push_back({ "the_quick_brown_fox", flatbuffers::Case::kAllUpper,
+ "THE_QUICK_BROWN_FOX" });
+ cases.push_back({ "the_quick_brown_fox", flatbuffers::Case::kUnknown,
+ "the_quick_brown_fox" });
+ cases.push_back({ "the_quick_brown_fox", flatbuffers::Case::kKeep,
+ "the_quick_brown_fox" });
+ cases.push_back({ "the_quick_brown_fox", flatbuffers::Case::kSnake2,
+ "the_quick_brown_fox" });
+
+ // Tests for some snake_cases where the _ is oddly placed or
+ // missing.
+ cases.push_back({ "single", flatbuffers::Case::kUpperCamel, "Single" });
+ cases.push_back({ "Single", flatbuffers::Case::kUpperCamel, "Single" });
+ cases.push_back({ "_leading", flatbuffers::Case::kUpperCamel, "_leading" });
+ cases.push_back(
+ { "trailing_", flatbuffers::Case::kUpperCamel, "Trailing_" });
+ cases.push_back({ "double__underscore", flatbuffers::Case::kUpperCamel,
+ "Double_underscore" });
+ cases.push_back({ "single", flatbuffers::Case::kLowerCamel, "single" });
+ cases.push_back({ "Single", flatbuffers::Case::kLowerCamel, "Single" });
+ cases.push_back({ "_leading", flatbuffers::Case::kLowerCamel, "Leading" });
+ cases.push_back(
+ { "trailing_", flatbuffers::Case::kLowerCamel, "trailing_" });
+ cases.push_back({ "double__underscore", flatbuffers::Case::kLowerCamel,
+ "double_underscore" });
+
+ // Tests for some output snake_cases
+ cases.push_back({ "single", flatbuffers::Case::kSnake, "single" });
+ cases.push_back({ "single", flatbuffers::Case::kScreamingSnake, "SINGLE" });
+ cases.push_back(
+ { "_leading", flatbuffers::Case::kScreamingSnake, "_LEADING" });
+ cases.push_back(
+ { "trailing_", flatbuffers::Case::kScreamingSnake, "TRAILING_" });
+ cases.push_back({ "double__underscore", flatbuffers::Case::kScreamingSnake,
+ "DOUBLE__UNDERSCORE" });
+
+ for (auto &test_case : cases) {
+ TEST_EQ(test_case.expected_output,
+ flatbuffers::ConvertCase(test_case.input, test_case.output_case));
+ }
+ }
+
+ // Tests for the non snake_case inputs.
+ {
+ struct TestCase {
+ flatbuffers::Case input_case;
+ std::string input;
+ flatbuffers::Case output_case;
+ std::string expected_output;
+ };
+
+ std::vector<TestCase> cases;
+
+ cases.push_back({ flatbuffers::Case::kUpperCamel, "TheQuickBrownFox",
+ flatbuffers::Case::kSnake, "the_quick_brown_fox" });
+ cases.push_back({ flatbuffers::Case::kLowerCamel, "theQuickBrownFox",
+ flatbuffers::Case::kSnake, "the_quick_brown_fox" });
+ cases.push_back({ flatbuffers::Case::kSnake, "the_quick_brown_fox",
+ flatbuffers::Case::kSnake, "the_quick_brown_fox" });
+ cases.push_back({ flatbuffers::Case::kScreamingSnake, "THE_QUICK_BROWN_FOX",
+ flatbuffers::Case::kSnake, "THE_QUICK_BROWN_FOX" });
+ cases.push_back({ flatbuffers::Case::kAllUpper, "SINGLE",
+ flatbuffers::Case::kSnake, "SINGLE" });
+ cases.push_back({ flatbuffers::Case::kAllLower, "single",
+ flatbuffers::Case::kSnake, "single" });
+ cases.push_back({ flatbuffers::Case::kUpperCamel, "ABCtest",
+ flatbuffers::Case::kSnake, "abctest" });
+ cases.push_back({ flatbuffers::Case::kUpperCamel, "tHe_qUiCk_BrOwN_fOx",
+ flatbuffers::Case::kKeep, "tHe_qUiCk_BrOwN_fOx" });
+ cases.push_back({ flatbuffers::Case::kLowerCamel, "theQuick12345Fox",
+ flatbuffers::Case::kSnake, "the_quick_12345fox" });
+ cases.push_back({ flatbuffers::Case::kLowerCamel, "a12b34c45",
+ flatbuffers::Case::kSnake, "a_12b_34c_45" });
+ cases.push_back({ flatbuffers::Case::kLowerCamel, "a12b34c45",
+ flatbuffers::Case::kSnake2, "a12_b34_c45" });
+
+ for (auto &test_case : cases) {
+ TEST_EQ(test_case.expected_output,
+ flatbuffers::ConvertCase(test_case.input, test_case.output_case,
+ test_case.input_case));
+ }
+ }
+}
+
+} // namespace tests
+} // namespace flatbuffers
diff --git a/tests/util_test.h b/tests/util_test.h
new file mode 100644
index 0000000..9f2a257
--- /dev/null
+++ b/tests/util_test.h
@@ -0,0 +1,15 @@
+#ifndef TESTS_UTIL_TEST_H
+#define TESTS_UTIL_TEST_H
+
+namespace flatbuffers {
+namespace tests {
+
+void NumericUtilsTest();
+void IsAsciiUtilsTest();
+void UtilConvertCase();
+
+
+} // namespace tests
+} // namespace flatbuffers
+
+#endif
diff --git a/tests/vector_has_test.fbs b/tests/vector_has_test.fbs
new file mode 100644
index 0000000..dbc7271
--- /dev/null
+++ b/tests/vector_has_test.fbs
@@ -0,0 +1,10 @@
+namespace Swift.Tests;
+
+table Vectors
+{
+ none:[ulong];
+ empty:[ulong];
+ array:[ulong];
+}
+
+root_type Vectors;
diff --git a/ts/builder.ts b/ts/builder.ts
index 344a629..85f5726 100644
--- a/ts/builder.ts
+++ b/ts/builder.ts
@@ -24,6 +24,7 @@
private force_defaults = false;
private string_maps: Map<string | Uint8Array, number> | null = null;
+ private text_encoder = new TextEncoder();
/**
* Create a FlatBufferBuilder.
@@ -149,7 +150,7 @@
/**
* Add an `int8` to the buffer, properly aligned, and grows the buffer (if necessary).
- * @param value The `int8` to add the the buffer.
+ * @param value The `int8` to add the buffer.
*/
addInt8(value: number): void {
this.prep(1, 0);
@@ -158,7 +159,7 @@
/**
* Add an `int16` to the buffer, properly aligned, and grows the buffer (if necessary).
- * @param value The `int16` to add the the buffer.
+ * @param value The `int16` to add the buffer.
*/
addInt16(value: number): void {
this.prep(2, 0);
@@ -167,7 +168,7 @@
/**
* Add an `int32` to the buffer, properly aligned, and grows the buffer (if necessary).
- * @param value The `int32` to add the the buffer.
+ * @param value The `int32` to add the buffer.
*/
addInt32(value: number): void {
this.prep(4, 0);
@@ -176,7 +177,7 @@
/**
* Add an `int64` to the buffer, properly aligned, and grows the buffer (if necessary).
- * @param value The `int64` to add the the buffer.
+ * @param value The `int64` to add the buffer.
*/
addInt64(value: bigint): void {
this.prep(8, 0);
@@ -185,7 +186,7 @@
/**
* Add a `float32` to the buffer, properly aligned, and grows the buffer (if necessary).
- * @param value The `float32` to add the the buffer.
+ * @param value The `float32` to add the buffer.
*/
addFloat32(value: number): void {
this.prep(4, 0);
@@ -194,7 +195,7 @@
/**
* Add a `float64` to the buffer, properly aligned, and grows the buffer (if necessary).
- * @param value The `float64` to add the the buffer.
+ * @param value The `float64` to add the buffer.
*/
addFloat64(value: number): void {
this.prep(8, 0);
@@ -531,40 +532,7 @@
if (s instanceof Uint8Array) {
utf8 = s;
} else {
- utf8 = [];
- let i = 0;
-
- while (i < s.length) {
- let codePoint;
-
- // Decode UTF-16
- const a = s.charCodeAt(i++);
- if (a < 0xD800 || a >= 0xDC00) {
- codePoint = a;
- } else {
- const b = s.charCodeAt(i++);
- codePoint = (a << 10) + b + (0x10000 - (0xD800 << 10) - 0xDC00);
- }
-
- // Encode UTF-8
- if (codePoint < 0x80) {
- utf8.push(codePoint);
- } else {
- if (codePoint < 0x800) {
- utf8.push(((codePoint >> 6) & 0x1F) | 0xC0);
- } else {
- if (codePoint < 0x10000) {
- utf8.push(((codePoint >> 12) & 0x0F) | 0xE0);
- } else {
- utf8.push(
- ((codePoint >> 18) & 0x07) | 0xF0,
- ((codePoint >> 12) & 0x3F) | 0x80);
- }
- utf8.push(((codePoint >> 6) & 0x3F) | 0x80);
- }
- utf8.push((codePoint & 0x3F) | 0x80);
- }
- }
+ utf8 = this.text_encoder.encode(s);
}
this.addInt8(0);
@@ -617,7 +585,7 @@
createStructOffsetList(list: string[] | any[], startFunc: (builder: Builder, length: number) => void): Offset {
startFunc(this, list.length);
- this.createObjectOffsetList(list);
+ this.createObjectOffsetList(list.slice().reverse());
return this.endVector();
}
}
diff --git a/ts/byte-buffer.ts b/ts/byte-buffer.ts
index bb77f3b..09c55ad 100644
--- a/ts/byte-buffer.ts
+++ b/ts/byte-buffer.ts
@@ -5,6 +5,7 @@
export class ByteBuffer {
private position_ = 0;
+ private text_decoder_ = new TextDecoder();
/**
* Create a new ByteBuffer with a given array of bytes (`Uint8Array`)
@@ -187,70 +188,22 @@
* Create a JavaScript string from UTF-8 data stored inside the FlatBuffer.
* This allocates a new string and converts to wide chars upon each access.
*
- * To avoid the conversion to UTF-16, pass Encoding.UTF8_BYTES as
- * the "optionalEncoding" argument. This is useful for avoiding conversion to
- * and from UTF-16 when the data will just be packaged back up in another
- * FlatBuffer later on.
+ * To avoid the conversion to string, pass Encoding.UTF8_BYTES as the
+ * "optionalEncoding" argument. This is useful for avoiding conversion when
+ * the data will just be packaged back up in another FlatBuffer later on.
*
* @param offset
* @param opt_encoding Defaults to UTF16_STRING
*/
__string(offset: number, opt_encoding?: Encoding): string | Uint8Array {
offset += this.readInt32(offset);
-
const length = this.readInt32(offset);
- let result = '';
- let i = 0;
-
offset += SIZEOF_INT;
-
- if (opt_encoding === Encoding.UTF8_BYTES) {
- return this.bytes_.subarray(offset, offset + length);
- }
-
- while (i < length) {
- let codePoint;
-
- // Decode UTF-8
- const a = this.readUint8(offset + i++);
- if (a < 0xC0) {
- codePoint = a;
- } else {
- const b = this.readUint8(offset + i++);
- if (a < 0xE0) {
- codePoint =
- ((a & 0x1F) << 6) |
- (b & 0x3F);
- } else {
- const c = this.readUint8(offset + i++);
- if (a < 0xF0) {
- codePoint =
- ((a & 0x0F) << 12) |
- ((b & 0x3F) << 6) |
- (c & 0x3F);
- } else {
- const d = this.readUint8(offset + i++);
- codePoint =
- ((a & 0x07) << 18) |
- ((b & 0x3F) << 12) |
- ((c & 0x3F) << 6) |
- (d & 0x3F);
- }
- }
- }
-
- // Encode UTF-16
- if (codePoint < 0x10000) {
- result += String.fromCharCode(codePoint);
- } else {
- codePoint -= 0x10000;
- result += String.fromCharCode(
- (codePoint >> 10) + 0xD800,
- (codePoint & ((1 << 10) - 1)) + 0xDC00);
- }
- }
-
- return result;
+ const utf8bytes = this.bytes_.subarray(offset, offset + length);
+ if (opt_encoding === Encoding.UTF8_BYTES)
+ return utf8bytes;
+ else
+ return this.text_decoder_.decode(utf8bytes);
}
/**
diff --git a/ts/flexbuffers/reference-util.ts b/ts/flexbuffers/reference-util.ts
index c55a941..52fb600 100644
--- a/ts/flexbuffers/reference-util.ts
+++ b/ts/flexbuffers/reference-util.ts
@@ -65,8 +65,8 @@
const input = toUTF8Array(key);
const keysVectorOffset = indirect(dataView, offset, parentWidth) - byteWidth * 3;
const bitWidth = fromByteWidth(byteWidth);
- const indirectOffset = keysVectorOffset - (readUInt(dataView, keysVectorOffset, bitWidth) as number);
- const _byteWidth = readUInt(dataView, keysVectorOffset + byteWidth, bitWidth) as number;
+ const indirectOffset = keysVectorOffset - Number(readUInt(dataView, keysVectorOffset, bitWidth));
+ const _byteWidth = Number(readUInt(dataView, keysVectorOffset + byteWidth, bitWidth));
let low = 0;
let high = length - 1;
while (low <= high) {
@@ -84,7 +84,7 @@
export function diffKeys(input: Uint8Array, index: number, dataView: DataView, offset: number, width: number): number {
const keyOffset = offset + index * width;
- const keyIndirectOffset = keyOffset - (readUInt(dataView, keyOffset, fromByteWidth(width)) as number);
+ const keyIndirectOffset = keyOffset - Number(readUInt(dataView, keyOffset, fromByteWidth(width)));
for (let i = 0; i < input.length; i++) {
const dif = input[i] - dataView.getUint8(keyIndirectOffset + i);
if (dif !== 0) {
@@ -97,10 +97,10 @@
export function keyForIndex(index: number, dataView: DataView, offset: number, parentWidth: number, byteWidth: number): string {
const keysVectorOffset = indirect(dataView, offset, parentWidth) - byteWidth * 3;
const bitWidth = fromByteWidth(byteWidth);
- const indirectOffset = keysVectorOffset - (readUInt(dataView, keysVectorOffset, bitWidth) as number);
- const _byteWidth = readUInt(dataView, keysVectorOffset + byteWidth, bitWidth) as number;
+ const indirectOffset = keysVectorOffset - Number(readUInt(dataView, keysVectorOffset, bitWidth));
+ const _byteWidth = Number(readUInt(dataView, keysVectorOffset + byteWidth, bitWidth));
const keyOffset = indirectOffset + index * _byteWidth;
- const keyIndirectOffset = keyOffset - (readUInt(dataView, keyOffset, fromByteWidth(_byteWidth)) as number);
+ const keyIndirectOffset = keyOffset - Number(readUInt(dataView, keyOffset, fromByteWidth(_byteWidth)));
let length = 0;
while (dataView.getUint8(keyIndirectOffset + length) !== 0) {
length++;
diff --git a/ts/flexbuffers/reference.ts b/ts/flexbuffers/reference.ts
index 0eff6f4..38c2f0a 100644
--- a/ts/flexbuffers/reference.ts
+++ b/ts/flexbuffers/reference.ts
@@ -157,7 +157,7 @@
} else {
this._length = 1;
}
- return this._length;
+ return Number(this._length);
}
toObject(): unknown {
diff --git a/typescript.bzl b/typescript.bzl
new file mode 100644
index 0000000..f112f34
--- /dev/null
+++ b/typescript.bzl
@@ -0,0 +1,134 @@
+"""
+Rules for building typescript flatbuffers with Bazel.
+"""
+
+load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
+load("@npm//@bazel/typescript:index.bzl", "ts_project")
+load(":build_defs.bzl", "DEFAULT_INCLUDE_PATHS", "flatbuffer_library_public")
+
+DEFAULT_FLATC_TS_ARGS = [
+ "--gen-object-api",
+ "--gen-mutable",
+ "--reflect-names",
+ "--gen-name-strings",
+ "--ts-flat-files",
+ "--keep-prefix",
+]
+
+def flatbuffer_ts_library(
+ name,
+ srcs,
+ compatible_with = None,
+ target_compatible_with = None,
+ deps = [],
+ include_paths = DEFAULT_INCLUDE_PATHS,
+ flatc_args = DEFAULT_FLATC_TS_ARGS,
+ visibility = None,
+ restricted_to = None,
+ include_reflection = True,
+ gen_reflections = False,
+ package_name = None):
+ """Generates a ts_library rule for a given flatbuffer definition.
+
+ Args:
+ name: Name of the generated ts_library rule.
+ srcs: Source .fbs file(s).
+ deps: Other flatbuffer_ts_library's to depend on. Note that currently
+ you must specify all your transitive dependencies manually.
+ include_paths: Optional, list of paths the includes files can be found in.
+ flatc_args: Optional list of additional arguments to pass to flatc
+ (e.g. --gen-mutable).
+ visibility: The visibility of the generated cc_library. By default, use the
+ default visibility of the project.
+ compatible_with: Optional, The list of environments this rule can be built
+ for, in addition to default-supported environments.
+ restricted_to: Optional, The list of environments this rule can be built
+ for, instead of default-supported environments.
+ target_compatible_with: Optional, The list of target platform constraints
+ to use.
+ include_reflection: Optional, Whether to depend on the flatbuffer
+ reflection library automatically. Only really relevant for the
+ target that builds the reflection library itself.
+ gen_reflections: Optional, if true this will generate the flatbuffer
+ reflection binaries for the schemas.
+ package_name: Optional, Package name to use for the generated code.
+ """
+ srcs_lib = "%s_srcs" % (name)
+ out_base = [s.replace(".fbs", "").split("/")[-1].split(":")[-1] for s in srcs]
+
+ # Because of how we have to manage the bazel rules for typescript,
+ # reflection has to get special-cased to get imported when
+ # run within bazel. As such, generate the code using the _pregenerate
+ # suffix; then do a find/replace to fix-up all the reflection imports.
+ pre_outs = ["%s_pregenerated.ts" % s for s in out_base]
+ outs = ["%s_generated.ts" % s for s in out_base]
+ includes = [d + "_includes" for d in deps]
+ reflection_name = "%s_reflection" % name if gen_reflections else ""
+ flatbuffer_library_public(
+ name = srcs_lib,
+ srcs = srcs,
+ outs = pre_outs,
+ language_flag = "--ts",
+ includes = includes,
+ include_paths = include_paths,
+ flatc_args = flatc_args + ["--filename-suffix _pregenerated"],
+ compatible_with = compatible_with,
+ restricted_to = restricted_to,
+ reflection_name = reflection_name,
+ reflection_visibility = visibility,
+ target_compatible_with = target_compatible_with,
+ )
+ fix_import_cmd = " ".join([
+ "SRCS=($(SRCS));",
+ "OUTS=($(OUTS));",
+ "for i in $${!SRCS[@]}; do",
+ "sed \"s/'.*reflection\\/reflection_pregenerated/'flatbuffers_reflection\\/reflection_generated/; s/_pregenerated/_generated/\" $${SRCS[i]} > $${OUTS[i]};",
+ "done",
+ ])
+ native.genrule(
+ name = name + "_reimporter",
+ srcs = pre_outs,
+ outs = outs,
+ cmd = fix_import_cmd,
+ )
+ ts_project(
+ name = name + "_ts",
+ srcs = outs,
+ declaration = True,
+ visibility = visibility,
+ compatible_with = compatible_with,
+ restricted_to = restricted_to,
+ target_compatible_with = target_compatible_with,
+ tsconfig = {
+ "compilerOptions": {
+ "declaration": True,
+ "lib": [
+ "ES2015",
+ "ES2020.BigInt",
+ "DOM",
+ ],
+ "module": "commonjs",
+ "moduleResolution": "node",
+ "noUnusedLocals": True,
+ "strict": True,
+ "types": ["node"],
+ },
+ },
+ deps = deps + ["@com_github_google_flatbuffers//ts:flatbuffers"] + (["@com_github_google_flatbuffers//reflection/ts:reflection_ts_fbs"] if include_reflection else []),
+ )
+ js_library(
+ name = name,
+ visibility = visibility,
+ compatible_with = compatible_with,
+ restricted_to = restricted_to,
+ target_compatible_with = target_compatible_with,
+ deps = [name + "_ts"],
+ package_name = package_name,
+ )
+ native.filegroup(
+ name = "%s_includes" % (name),
+ srcs = srcs + includes,
+ compatible_with = compatible_with,
+ restricted_to = restricted_to,
+ visibility = visibility,
+ )
diff --git a/yarn.lock b/yarn.lock
index 171854d..8636de9 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2,28 +2,7 @@
# yarn lockfile v1
-"@babel/code-frame@7.12.11":
- version "7.12.11"
- resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.12.11.tgz#f4ad435aa263db935b8f10f2c552d23fb716a63f"
- integrity sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw==
- dependencies:
- "@babel/highlight" "^7.10.4"
-
-"@babel/helper-validator-identifier@^7.16.7":
- version "7.16.7"
- resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz#e8c602438c4a8195751243da9031d1607d247cad"
- integrity sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==
-
-"@babel/highlight@^7.10.4":
- version "7.16.10"
- resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.16.10.tgz#744f2eb81579d6eea753c227b0f570ad785aba88"
- integrity sha512-5FnTQLSLswEj6IkgVw5KusNUUFY9ZGqe/TRFnP/BKYHYgfh7tc+C7mwiy95/yNP7Dh9x580Vv8r7u7ZfTBFxdw==
- dependencies:
- "@babel/helper-validator-identifier" "^7.16.7"
- chalk "^2.0.0"
- js-tokens "^4.0.0"
-
-"@bazel/typescript@^5.2.0":
+"@bazel/typescript@5.2.0":
version "5.2.0"
resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-5.2.0.tgz#131127c8016c712ef1b291f2b52108e5326f0447"
integrity sha512-hNpSCQj5dOX95iC4Yf/fuyxfMU5uTAe84thqPcTCvOJFmpypN6qzxH24S5UiXkwbsL8sQM9DP0+qFyT/TRKdNw==
@@ -41,31 +20,41 @@
dependencies:
google-protobuf "^3.6.1"
-"@eslint/eslintrc@^0.4.3":
- version "0.4.3"
- resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.4.3.tgz#9e42981ef035beb3dd49add17acb96e8ff6f394c"
- integrity sha512-J6KFFz5QCYUJq3pf0mjEcCJVERbzv71PUIDczuh9JkwGEzced6CO5ADLHB1rbf/+oPBtoPfMYNOpGDzCANlbXw==
+"@eslint/eslintrc@^1.3.2":
+ version "1.3.2"
+ resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.3.2.tgz#58b69582f3b7271d8fa67fe5251767a5b38ea356"
+ integrity sha512-AXYd23w1S/bv3fTs3Lz0vjiYemS08jWkI3hYyS9I1ry+0f+Yjs1wm+sU0BS8qDOPrBIkp4qHYC16I8uVtpLajQ==
dependencies:
ajv "^6.12.4"
- debug "^4.1.1"
- espree "^7.3.0"
- globals "^13.9.0"
- ignore "^4.0.6"
+ debug "^4.3.2"
+ espree "^9.4.0"
+ globals "^13.15.0"
+ ignore "^5.2.0"
import-fresh "^3.2.1"
- js-yaml "^3.13.1"
- minimatch "^3.0.4"
+ js-yaml "^4.1.0"
+ minimatch "^3.1.2"
strip-json-comments "^3.1.1"
-"@humanwhocodes/config-array@^0.5.0":
- version "0.5.0"
- resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.5.0.tgz#1407967d4c6eecd7388f83acf1eaf4d0c6e58ef9"
- integrity sha512-FagtKFz74XrTl7y6HCzQpwDfXP0yhxe9lHLD1UZxjvZIcbyRz8zTFF/yYNfSfzU414eDwZ1SrO0Qvtyf+wFMQg==
+"@humanwhocodes/config-array@^0.10.4":
+ version "0.10.4"
+ resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.10.4.tgz#01e7366e57d2ad104feea63e72248f22015c520c"
+ integrity sha512-mXAIHxZT3Vcpg83opl1wGlVZ9xydbfZO3r5YfRSH6Gpp2J/PfdBP0wbDa2sO6/qRbcalpoevVyW6A/fI6LfeMw==
dependencies:
- "@humanwhocodes/object-schema" "^1.2.0"
+ "@humanwhocodes/object-schema" "^1.2.1"
debug "^4.1.1"
minimatch "^3.0.4"
-"@humanwhocodes/object-schema@^1.2.0":
+"@humanwhocodes/gitignore-to-minimatch@^1.0.2":
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/@humanwhocodes/gitignore-to-minimatch/-/gitignore-to-minimatch-1.0.2.tgz#316b0a63b91c10e53f242efb4ace5c3b34e8728d"
+ integrity sha512-rSqmMJDdLFUsyxR6FMtD00nfQKKLFb1kv+qBbOVKqErvloEIJLo5bDTJTQNTYgeyp78JsA7u/NPi5jT1GR/MuA==
+
+"@humanwhocodes/module-importer@^1.0.1":
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz#af5b2691a22b44be847b0ca81641c5fb6ad0172c"
+ integrity sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==
+
+"@humanwhocodes/object-schema@^1.2.1":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45"
integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==
@@ -94,7 +83,7 @@
"@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf"
- integrity sha1-m4sMxmPWaafY9vXQiToU00jzD78=
+ integrity sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==
"@protobufjs/base64@^1.1.2":
version "1.1.2"
@@ -109,12 +98,12 @@
"@protobufjs/eventemitter@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz#355cbc98bafad5978f9ed095f397621f1d066b70"
- integrity sha1-NVy8mLr61ZePntCV85diHx0Ga3A=
+ integrity sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==
"@protobufjs/fetch@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@protobufjs/fetch/-/fetch-1.1.0.tgz#ba99fb598614af65700c1619ff06d454b0d84c45"
- integrity sha1-upn7WYYUr2VwDBYZ/wbUVLDYTEU=
+ integrity sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==
dependencies:
"@protobufjs/aspromise" "^1.1.1"
"@protobufjs/inquire" "^1.1.0"
@@ -122,127 +111,138 @@
"@protobufjs/float@^1.0.2":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@protobufjs/float/-/float-1.0.2.tgz#5e9e1abdcb73fc0a7cb8b291df78c8cbd97b87d1"
- integrity sha1-Xp4avctz/Ap8uLKR33jIy9l7h9E=
+ integrity sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==
"@protobufjs/inquire@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@protobufjs/inquire/-/inquire-1.1.0.tgz#ff200e3e7cf2429e2dcafc1140828e8cc638f089"
- integrity sha1-/yAOPnzyQp4tyvwRQIKOjMY48Ik=
+ integrity sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==
"@protobufjs/path@^1.1.2":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@protobufjs/path/-/path-1.1.2.tgz#6cc2b20c5c9ad6ad0dccfd21ca7673d8d7fbf68d"
- integrity sha1-bMKyDFya1q0NzP0hynZz2Nf79o0=
+ integrity sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==
"@protobufjs/pool@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@protobufjs/pool/-/pool-1.1.0.tgz#09fd15f2d6d3abfa9b65bc366506d6ad7846ff54"
- integrity sha1-Cf0V8tbTq/qbZbw2ZQbWrXhG/1Q=
+ integrity sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==
"@protobufjs/utf8@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570"
- integrity sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA=
+ integrity sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==
-"@types/json-schema@^7.0.7":
- version "7.0.9"
- resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d"
- integrity sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==
+"@types/json-schema@^7.0.9":
+ version "7.0.11"
+ resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3"
+ integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==
"@types/long@^4.0.0":
- version "4.0.1"
- resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.1.tgz#459c65fa1867dafe6a8f322c4c51695663cc55e9"
- integrity sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w==
+ version "4.0.2"
+ resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.2.tgz#b74129719fc8d11c01868010082d483b7545591a"
+ integrity sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA==
-"@types/node@17.0.21":
- version "17.0.21"
- resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.21.tgz#864b987c0c68d07b4345845c3e63b75edd143644"
- integrity sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ==
+"@types/node@18.7.16":
+ version "18.7.16"
+ resolved "https://registry.yarnpkg.com/@types/node/-/node-18.7.16.tgz#0eb3cce1e37c79619943d2fd903919fc30850601"
+ integrity sha512-EQHhixfu+mkqHMZl1R2Ovuvn47PUw18azMJOTwSZr9/fhzHNGXAJ0ma0dayRVchprpCj0Kc1K1xKoWaATWF1qg==
"@types/node@^10.1.0":
version "10.17.60"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.60.tgz#35f3d6213daed95da7f0f73e75bcc6980e90597b"
integrity sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw==
-"@typescript-eslint/eslint-plugin@^4.12.0":
- version "4.33.0"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.33.0.tgz#c24dc7c8069c7706bc40d99f6fa87edcb2005276"
- integrity sha512-aINiAxGVdOl1eJyVjaWn/YcVAq4Gi/Yo35qHGCnqbWVz61g39D0h23veY/MA0rFFGfxK7TySg2uwDeNv+JgVpg==
+"@typescript-eslint/eslint-plugin@^5.36.2":
+ version "5.36.2"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.36.2.tgz#6df092a20e0f9ec748b27f293a12cb39d0c1fe4d"
+ integrity sha512-OwwR8LRwSnI98tdc2z7mJYgY60gf7I9ZfGjN5EjCwwns9bdTuQfAXcsjSB2wSQ/TVNYSGKf4kzVXbNGaZvwiXw==
dependencies:
- "@typescript-eslint/experimental-utils" "4.33.0"
- "@typescript-eslint/scope-manager" "4.33.0"
- debug "^4.3.1"
+ "@typescript-eslint/scope-manager" "5.36.2"
+ "@typescript-eslint/type-utils" "5.36.2"
+ "@typescript-eslint/utils" "5.36.2"
+ debug "^4.3.4"
functional-red-black-tree "^1.0.1"
- ignore "^5.1.8"
- regexpp "^3.1.0"
- semver "^7.3.5"
+ ignore "^5.2.0"
+ regexpp "^3.2.0"
+ semver "^7.3.7"
tsutils "^3.21.0"
-"@typescript-eslint/experimental-utils@4.33.0":
- version "4.33.0"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.33.0.tgz#6f2a786a4209fa2222989e9380b5331b2810f7fd"
- integrity sha512-zeQjOoES5JFjTnAhI5QY7ZviczMzDptls15GFsI6jyUOq0kOf9+WonkhtlIhh0RgHRnqj5gdNxW5j1EvAyYg6Q==
+"@typescript-eslint/parser@^5.36.2":
+ version "5.36.2"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.36.2.tgz#3ddf323d3ac85a25295a55fcb9c7a49ab4680ddd"
+ integrity sha512-qS/Kb0yzy8sR0idFspI9Z6+t7mqk/oRjnAYfewG+VN73opAUvmYL3oPIMmgOX6CnQS6gmVIXGshlb5RY/R22pA==
dependencies:
- "@types/json-schema" "^7.0.7"
- "@typescript-eslint/scope-manager" "4.33.0"
- "@typescript-eslint/types" "4.33.0"
- "@typescript-eslint/typescript-estree" "4.33.0"
+ "@typescript-eslint/scope-manager" "5.36.2"
+ "@typescript-eslint/types" "5.36.2"
+ "@typescript-eslint/typescript-estree" "5.36.2"
+ debug "^4.3.4"
+
+"@typescript-eslint/scope-manager@5.36.2":
+ version "5.36.2"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.36.2.tgz#a75eb588a3879ae659514780831370642505d1cd"
+ integrity sha512-cNNP51L8SkIFSfce8B1NSUBTJTu2Ts4nWeWbFrdaqjmn9yKrAaJUBHkyTZc0cL06OFHpb+JZq5AUHROS398Orw==
+ dependencies:
+ "@typescript-eslint/types" "5.36.2"
+ "@typescript-eslint/visitor-keys" "5.36.2"
+
+"@typescript-eslint/type-utils@5.36.2":
+ version "5.36.2"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.36.2.tgz#752373f4babf05e993adf2cd543a763632826391"
+ integrity sha512-rPQtS5rfijUWLouhy6UmyNquKDPhQjKsaKH0WnY6hl/07lasj8gPaH2UD8xWkePn6SC+jW2i9c2DZVDnL+Dokw==
+ dependencies:
+ "@typescript-eslint/typescript-estree" "5.36.2"
+ "@typescript-eslint/utils" "5.36.2"
+ debug "^4.3.4"
+ tsutils "^3.21.0"
+
+"@typescript-eslint/types@5.36.2":
+ version "5.36.2"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.36.2.tgz#a5066e500ebcfcee36694186ccc57b955c05faf9"
+ integrity sha512-9OJSvvwuF1L5eS2EQgFUbECb99F0mwq501w0H0EkYULkhFa19Qq7WFbycdw1PexAc929asupbZcgjVIe6OK/XQ==
+
+"@typescript-eslint/typescript-estree@5.36.2":
+ version "5.36.2"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.36.2.tgz#0c93418b36c53ba0bc34c61fe9405c4d1d8fe560"
+ integrity sha512-8fyH+RfbKc0mTspfuEjlfqA4YywcwQK2Amcf6TDOwaRLg7Vwdu4bZzyvBZp4bjt1RRjQ5MDnOZahxMrt2l5v9w==
+ dependencies:
+ "@typescript-eslint/types" "5.36.2"
+ "@typescript-eslint/visitor-keys" "5.36.2"
+ debug "^4.3.4"
+ globby "^11.1.0"
+ is-glob "^4.0.3"
+ semver "^7.3.7"
+ tsutils "^3.21.0"
+
+"@typescript-eslint/utils@5.36.2":
+ version "5.36.2"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.36.2.tgz#b01a76f0ab244404c7aefc340c5015d5ce6da74c"
+ integrity sha512-uNcopWonEITX96v9pefk9DC1bWMdkweeSsewJ6GeC7L6j2t0SJywisgkr9wUTtXk90fi2Eljj90HSHm3OGdGRg==
+ dependencies:
+ "@types/json-schema" "^7.0.9"
+ "@typescript-eslint/scope-manager" "5.36.2"
+ "@typescript-eslint/types" "5.36.2"
+ "@typescript-eslint/typescript-estree" "5.36.2"
eslint-scope "^5.1.1"
eslint-utils "^3.0.0"
-"@typescript-eslint/parser@^4.12.0":
- version "4.33.0"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.33.0.tgz#dfe797570d9694e560528d18eecad86c8c744899"
- integrity sha512-ZohdsbXadjGBSK0/r+d87X0SBmKzOq4/S5nzK6SBgJspFo9/CUDJ7hjayuze+JK7CZQLDMroqytp7pOcFKTxZA==
+"@typescript-eslint/visitor-keys@5.36.2":
+ version "5.36.2"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.36.2.tgz#2f8f78da0a3bad3320d2ac24965791ac39dace5a"
+ integrity sha512-BtRvSR6dEdrNt7Net2/XDjbYKU5Ml6GqJgVfXT0CxTCJlnIqK7rAGreuWKMT2t8cFUT2Msv5oxw0GMRD7T5J7A==
dependencies:
- "@typescript-eslint/scope-manager" "4.33.0"
- "@typescript-eslint/types" "4.33.0"
- "@typescript-eslint/typescript-estree" "4.33.0"
- debug "^4.3.1"
+ "@typescript-eslint/types" "5.36.2"
+ eslint-visitor-keys "^3.3.0"
-"@typescript-eslint/scope-manager@4.33.0":
- version "4.33.0"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.33.0.tgz#d38e49280d983e8772e29121cf8c6e9221f280a3"
- integrity sha512-5IfJHpgTsTZuONKbODctL4kKuQje/bzBRkwHE8UOZ4f89Zeddg+EGZs8PD8NcN4LdM3ygHWYB3ukPAYjvl/qbQ==
- dependencies:
- "@typescript-eslint/types" "4.33.0"
- "@typescript-eslint/visitor-keys" "4.33.0"
-
-"@typescript-eslint/types@4.33.0":
- version "4.33.0"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.33.0.tgz#a1e59036a3b53ae8430ceebf2a919dc7f9af6d72"
- integrity sha512-zKp7CjQzLQImXEpLt2BUw1tvOMPfNoTAfb8l51evhYbOEEzdWyQNmHWWGPR6hwKJDAi+1VXSBmnhL9kyVTTOuQ==
-
-"@typescript-eslint/typescript-estree@4.33.0":
- version "4.33.0"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.33.0.tgz#0dfb51c2908f68c5c08d82aefeaf166a17c24609"
- integrity sha512-rkWRY1MPFzjwnEVHsxGemDzqqddw2QbTJlICPD9p9I9LfsO8fdmfQPOX3uKfUaGRDFJbfrtm/sXhVXN4E+bzCA==
- dependencies:
- "@typescript-eslint/types" "4.33.0"
- "@typescript-eslint/visitor-keys" "4.33.0"
- debug "^4.3.1"
- globby "^11.0.3"
- is-glob "^4.0.1"
- semver "^7.3.5"
- tsutils "^3.21.0"
-
-"@typescript-eslint/visitor-keys@4.33.0":
- version "4.33.0"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.33.0.tgz#2a22f77a41604289b7a186586e9ec48ca92ef1dd"
- integrity sha512-uqi/2aSz9g2ftcHWf8uLPJA70rUv6yuMW5Bohw+bwcuzaxQIHaKFZCKGoGXIrc9vkTJ3+0txM73K0Hq3d5wgIg==
- dependencies:
- "@typescript-eslint/types" "4.33.0"
- eslint-visitor-keys "^2.0.0"
-
-acorn-jsx@^5.3.1:
+acorn-jsx@^5.3.2:
version "5.3.2"
resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937"
integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==
-acorn@^7.4.0:
- version "7.4.1"
- resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa"
- integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==
+acorn@^8.8.0:
+ version "8.8.0"
+ resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.0.tgz#88c0187620435c7f6015803f5539dae05a9dbea8"
+ integrity sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==
ajv@^6.10.0, ajv@^6.12.4:
version "6.12.6"
@@ -254,57 +254,28 @@
json-schema-traverse "^0.4.1"
uri-js "^4.2.2"
-ajv@^8.0.1:
- version "8.10.0"
- resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.10.0.tgz#e573f719bd3af069017e3b66538ab968d040e54d"
- integrity sha512-bzqAEZOjkrUMl2afH8dknrq5KEk2SrwdBROR+vH1EKVQTqaUbJVPdc/gEdggTMM0Se+s+Ja4ju4TlNcStKl2Hw==
- dependencies:
- fast-deep-equal "^3.1.1"
- json-schema-traverse "^1.0.0"
- require-from-string "^2.0.2"
- uri-js "^4.2.2"
-
-ansi-colors@^4.1.1:
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348"
- integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==
-
ansi-regex@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304"
integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==
-ansi-styles@^3.2.1:
- version "3.2.1"
- resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d"
- integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==
- dependencies:
- color-convert "^1.9.0"
-
-ansi-styles@^4.0.0, ansi-styles@^4.1.0:
+ansi-styles@^4.1.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937"
integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==
dependencies:
color-convert "^2.0.1"
-argparse@^1.0.7:
- version "1.0.10"
- resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
- integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==
- dependencies:
- sprintf-js "~1.0.2"
+argparse@^2.0.1:
+ version "2.0.1"
+ resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38"
+ integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==
array-union@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d"
integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==
-astral-regex@^2.0.0:
- version "2.0.0"
- resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31"
- integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==
-
balanced-match@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
@@ -318,7 +289,7 @@
balanced-match "^1.0.0"
concat-map "0.0.1"
-braces@^3.0.1:
+braces@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==
@@ -335,15 +306,6 @@
resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73"
integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==
-chalk@^2.0.0:
- version "2.4.2"
- resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
- integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==
- dependencies:
- ansi-styles "^3.2.1"
- escape-string-regexp "^1.0.5"
- supports-color "^5.3.0"
-
chalk@^4.0.0:
version "4.1.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
@@ -352,13 +314,6 @@
ansi-styles "^4.1.0"
supports-color "^7.1.0"
-color-convert@^1.9.0:
- version "1.9.3"
- resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8"
- integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==
- dependencies:
- color-name "1.1.3"
-
color-convert@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3"
@@ -366,11 +321,6 @@
dependencies:
color-name "~1.1.4"
-color-name@1.1.3:
- version "1.1.3"
- resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"
- integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=
-
color-name@~1.1.4:
version "1.1.4"
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
@@ -379,7 +329,7 @@
concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
- integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
+ integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==
cross-spawn@^7.0.2:
version "7.0.3"
@@ -390,10 +340,10 @@
shebang-command "^2.0.0"
which "^2.0.1"
-debug@^4.0.1, debug@^4.1.1, debug@^4.3.1:
- version "4.3.3"
- resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.3.tgz#04266e0b70a98d4462e6e288e38259213332b664"
- integrity sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==
+debug@^4.1.1, debug@^4.3.2, debug@^4.3.4:
+ version "4.3.4"
+ resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
+ integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
dependencies:
ms "2.1.2"
@@ -416,23 +366,6 @@
dependencies:
esutils "^2.0.2"
-emoji-regex@^8.0.0:
- version "8.0.0"
- resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37"
- integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==
-
-enquirer@^2.3.5:
- version "2.3.6"
- resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.3.6.tgz#2a7fe5dd634a1e4125a975ec994ff5456dc3734d"
- integrity sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==
- dependencies:
- ansi-colors "^4.1.1"
-
-escape-string-regexp@^1.0.5:
- version "1.0.5"
- resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
- integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
-
escape-string-regexp@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34"
@@ -446,12 +379,13 @@
esrecurse "^4.3.0"
estraverse "^4.1.1"
-eslint-utils@^2.1.0:
- version "2.1.0"
- resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-2.1.0.tgz#d2de5e03424e707dc10c74068ddedae708741b27"
- integrity sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==
+eslint-scope@^7.1.1:
+ version "7.1.1"
+ resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-7.1.1.tgz#fff34894c2f65e5226d3041ac480b4513a163642"
+ integrity sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==
dependencies:
- eslint-visitor-keys "^1.1.0"
+ esrecurse "^4.3.0"
+ estraverse "^5.2.0"
eslint-utils@^3.0.0:
version "3.0.0"
@@ -460,75 +394,69 @@
dependencies:
eslint-visitor-keys "^2.0.0"
-eslint-visitor-keys@^1.1.0, eslint-visitor-keys@^1.3.0:
- version "1.3.0"
- resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e"
- integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==
-
eslint-visitor-keys@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz#f65328259305927392c938ed44eb0a5c9b2bd303"
integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==
-eslint@^7.17.0:
- version "7.32.0"
- resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.32.0.tgz#c6d328a14be3fb08c8d1d21e12c02fdb7a2a812d"
- integrity sha512-VHZ8gX+EDfz+97jGcgyGCyRia/dPOd6Xh9yPv8Bl1+SoaIwD+a/vlrOmGRUyOYu7MwUhc7CxqeaDZU13S4+EpA==
+eslint-visitor-keys@^3.3.0:
+ version "3.3.0"
+ resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826"
+ integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==
+
+eslint@^8.23.1:
+ version "8.23.1"
+ resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.23.1.tgz#cfd7b3f7fdd07db8d16b4ac0516a29c8d8dca5dc"
+ integrity sha512-w7C1IXCc6fNqjpuYd0yPlcTKKmHlHHktRkzmBPZ+7cvNBQuiNjx0xaMTjAJGCafJhQkrFJooREv0CtrVzmHwqg==
dependencies:
- "@babel/code-frame" "7.12.11"
- "@eslint/eslintrc" "^0.4.3"
- "@humanwhocodes/config-array" "^0.5.0"
+ "@eslint/eslintrc" "^1.3.2"
+ "@humanwhocodes/config-array" "^0.10.4"
+ "@humanwhocodes/gitignore-to-minimatch" "^1.0.2"
+ "@humanwhocodes/module-importer" "^1.0.1"
ajv "^6.10.0"
chalk "^4.0.0"
cross-spawn "^7.0.2"
- debug "^4.0.1"
+ debug "^4.3.2"
doctrine "^3.0.0"
- enquirer "^2.3.5"
escape-string-regexp "^4.0.0"
- eslint-scope "^5.1.1"
- eslint-utils "^2.1.0"
- eslint-visitor-keys "^2.0.0"
- espree "^7.3.1"
+ eslint-scope "^7.1.1"
+ eslint-utils "^3.0.0"
+ eslint-visitor-keys "^3.3.0"
+ espree "^9.4.0"
esquery "^1.4.0"
esutils "^2.0.2"
fast-deep-equal "^3.1.3"
file-entry-cache "^6.0.1"
- functional-red-black-tree "^1.0.1"
- glob-parent "^5.1.2"
- globals "^13.6.0"
- ignore "^4.0.6"
+ find-up "^5.0.0"
+ glob-parent "^6.0.1"
+ globals "^13.15.0"
+ globby "^11.1.0"
+ grapheme-splitter "^1.0.4"
+ ignore "^5.2.0"
import-fresh "^3.0.0"
imurmurhash "^0.1.4"
is-glob "^4.0.0"
- js-yaml "^3.13.1"
+ js-sdsl "^4.1.4"
+ js-yaml "^4.1.0"
json-stable-stringify-without-jsonify "^1.0.1"
levn "^0.4.1"
lodash.merge "^4.6.2"
- minimatch "^3.0.4"
+ minimatch "^3.1.2"
natural-compare "^1.4.0"
optionator "^0.9.1"
- progress "^2.0.0"
- regexpp "^3.1.0"
- semver "^7.2.1"
- strip-ansi "^6.0.0"
+ regexpp "^3.2.0"
+ strip-ansi "^6.0.1"
strip-json-comments "^3.1.0"
- table "^6.0.9"
text-table "^0.2.0"
- v8-compile-cache "^2.0.3"
-espree@^7.3.0, espree@^7.3.1:
- version "7.3.1"
- resolved "https://registry.yarnpkg.com/espree/-/espree-7.3.1.tgz#f2df330b752c6f55019f8bd89b7660039c1bbbb6"
- integrity sha512-v3JCNCE64umkFpmkFGqzVKsOT0tN1Zr+ueqLZfpV1Ob8e+CEgPWa+OxCoGH3tnhimMKIaBm4m/vaRpJ/krRz2g==
+espree@^9.4.0:
+ version "9.4.0"
+ resolved "https://registry.yarnpkg.com/espree/-/espree-9.4.0.tgz#cd4bc3d6e9336c433265fc0aa016fc1aaf182f8a"
+ integrity sha512-DQmnRpLj7f6TgN/NYb0MTzJXL+vJF9h3pHy4JhCIs3zwcgez8xmGg3sXHcEO97BrmO2OSvCwMdfdlyl+E9KjOw==
dependencies:
- acorn "^7.4.0"
- acorn-jsx "^5.3.1"
- eslint-visitor-keys "^1.3.0"
-
-esprima@^4.0.0:
- version "4.0.1"
- resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
- integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==
+ acorn "^8.8.0"
+ acorn-jsx "^5.3.2"
+ eslint-visitor-keys "^3.3.0"
esquery@^1.4.0:
version "1.4.0"
@@ -583,7 +511,7 @@
fast-levenshtein@^2.0.6:
version "2.0.6"
resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917"
- integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=
+ integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==
fastq@^1.6.0:
version "1.13.0"
@@ -606,6 +534,14 @@
dependencies:
to-regex-range "^5.0.1"
+find-up@^5.0.0:
+ version "5.0.0"
+ resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc"
+ integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==
+ dependencies:
+ locate-path "^6.0.0"
+ path-exists "^4.0.0"
+
flat-cache@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.0.4.tgz#61b0338302b2fe9f957dcc32fc2a87f1c3048b11"
@@ -615,19 +551,24 @@
rimraf "^3.0.2"
flatted@^3.1.0:
- version "3.2.5"
- resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.5.tgz#76c8584f4fc843db64702a6bd04ab7a8bd666da3"
- integrity sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==
+ version "3.2.7"
+ resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.7.tgz#609f39207cb614b89d0765b477cb2d437fbf9787"
+ integrity sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
- integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=
+ integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==
+
+fsevents@~2.3.2:
+ version "2.3.2"
+ resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
+ integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
functional-red-black-tree@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327"
- integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=
+ integrity sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==
glob-parent@^5.1.2:
version "5.1.2"
@@ -636,26 +577,33 @@
dependencies:
is-glob "^4.0.1"
+glob-parent@^6.0.1:
+ version "6.0.2"
+ resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-6.0.2.tgz#6d237d99083950c79290f24c7642a3de9a28f9e3"
+ integrity sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==
+ dependencies:
+ is-glob "^4.0.3"
+
glob@^7.1.3:
- version "7.2.0"
- resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023"
- integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==
+ version "7.2.3"
+ resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b"
+ integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
- minimatch "^3.0.4"
+ minimatch "^3.1.1"
once "^1.3.0"
path-is-absolute "^1.0.0"
-globals@^13.6.0, globals@^13.9.0:
- version "13.12.1"
- resolved "https://registry.yarnpkg.com/globals/-/globals-13.12.1.tgz#ec206be932e6c77236677127577aa8e50bf1c5cb"
- integrity sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw==
+globals@^13.15.0:
+ version "13.17.0"
+ resolved "https://registry.yarnpkg.com/globals/-/globals-13.17.0.tgz#902eb1e680a41da93945adbdcb5a9f361ba69bd4"
+ integrity sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==
dependencies:
type-fest "^0.20.2"
-globby@^11.0.3:
+globby@^11.1.0:
version "11.1.0"
resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b"
integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==
@@ -668,26 +616,21 @@
slash "^3.0.0"
google-protobuf@^3.6.1:
- version "3.19.4"
- resolved "https://registry.yarnpkg.com/google-protobuf/-/google-protobuf-3.19.4.tgz#8d32c3e34be9250956f28c0fb90955d13f311888"
- integrity sha512-OIPNCxsG2lkIvf+P5FNfJ/Km95CsXOBecS9ZcAU6m2Rq3svc0Apl9nB3GMDNKfQ9asNv4KjyAqGwPQFrVle3Yg==
+ version "3.21.0"
+ resolved "https://registry.yarnpkg.com/google-protobuf/-/google-protobuf-3.21.0.tgz#8dfa3fca16218618d373d414d3c1139e28034d6e"
+ integrity sha512-byR7MBTK4tZ5PZEb+u5ZTzpt4SfrTxv5682MjPlHN16XeqgZE2/8HOIWeiXe8JKnT9OVbtBGhbq8mtvkK8cd5g==
-has-flag@^3.0.0:
- version "3.0.0"
- resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd"
- integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0=
+grapheme-splitter@^1.0.4:
+ version "1.0.4"
+ resolved "https://registry.yarnpkg.com/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz#9cf3a665c6247479896834af35cf1dbb4400767e"
+ integrity sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==
has-flag@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b"
integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==
-ignore@^4.0.6:
- version "4.0.6"
- resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc"
- integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==
-
-ignore@^5.1.8, ignore@^5.2.0:
+ignore@^5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a"
integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==
@@ -703,12 +646,12 @@
imurmurhash@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
- integrity sha1-khi5srkoojixPcT7a21XbyMUU+o=
+ integrity sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==
inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
- integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=
+ integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==
dependencies:
once "^1.3.0"
wrappy "1"
@@ -721,14 +664,9 @@
is-extglob@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2"
- integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=
+ integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==
-is-fullwidth-code-point@^3.0.0:
- version "3.0.0"
- resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d"
- integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==
-
-is-glob@^4.0.0, is-glob@^4.0.1:
+is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3:
version "4.0.3"
resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084"
integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==
@@ -743,35 +681,29 @@
isexe@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
- integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=
+ integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==
-js-tokens@^4.0.0:
- version "4.0.0"
- resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
- integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==
+js-sdsl@^4.1.4:
+ version "4.1.4"
+ resolved "https://registry.yarnpkg.com/js-sdsl/-/js-sdsl-4.1.4.tgz#78793c90f80e8430b7d8dc94515b6c77d98a26a6"
+ integrity sha512-Y2/yD55y5jteOAmY50JbUZYwk3CP3wnLPEZnlR1w9oKhITrBEtAxwuWKebFf8hMrPMgbYwFoWK/lH2sBkErELw==
-js-yaml@^3.13.1:
- version "3.14.1"
- resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537"
- integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==
+js-yaml@^4.1.0:
+ version "4.1.0"
+ resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602"
+ integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==
dependencies:
- argparse "^1.0.7"
- esprima "^4.0.0"
+ argparse "^2.0.1"
json-schema-traverse@^0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660"
integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==
-json-schema-traverse@^1.0.0:
- version "1.0.0"
- resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz#ae7bcb3656ab77a73ba5c49bf654f38e6b6860e2"
- integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==
-
json-stable-stringify-without-jsonify@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651"
- integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=
+ integrity sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==
levn@^0.4.1:
version "0.4.1"
@@ -781,16 +713,18 @@
prelude-ls "^1.2.1"
type-check "~0.4.0"
+locate-path@^6.0.0:
+ version "6.0.0"
+ resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286"
+ integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==
+ dependencies:
+ p-locate "^5.0.0"
+
lodash.merge@^4.6.2:
version "4.6.2"
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==
-lodash.truncate@^4.4.2:
- version "4.4.2"
- resolved "https://registry.yarnpkg.com/lodash.truncate/-/lodash.truncate-4.4.2.tgz#5a350da0b1113b837ecfffd5812cbe58d6eae193"
- integrity sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM=
-
long@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28"
@@ -809,14 +743,14 @@
integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==
micromatch@^4.0.4:
- version "4.0.4"
- resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.4.tgz#896d519dfe9db25fce94ceb7a500919bf881ebf9"
- integrity sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==
+ version "4.0.5"
+ resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6"
+ integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==
dependencies:
- braces "^3.0.1"
- picomatch "^2.2.3"
+ braces "^3.0.2"
+ picomatch "^2.3.1"
-minimatch@^3.0.4:
+minimatch@^3.0.4, minimatch@^3.1.1, minimatch@^3.1.2:
version "3.1.2"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==
@@ -831,12 +765,12 @@
natural-compare@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
- integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=
+ integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==
once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
- integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E=
+ integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==
dependencies:
wrappy "1"
@@ -852,6 +786,20 @@
type-check "^0.4.0"
word-wrap "^1.2.3"
+p-limit@^3.0.2:
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b"
+ integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==
+ dependencies:
+ yocto-queue "^0.1.0"
+
+p-locate@^5.0.0:
+ version "5.0.0"
+ resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834"
+ integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==
+ dependencies:
+ p-limit "^3.0.2"
+
parent-module@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2"
@@ -859,10 +807,15 @@
dependencies:
callsites "^3.0.0"
+path-exists@^4.0.0:
+ version "4.0.0"
+ resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3"
+ integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==
+
path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
- integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
+ integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==
path-key@^3.1.0:
version "3.1.1"
@@ -874,7 +827,7 @@
resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==
-picomatch@^2.2.3:
+picomatch@^2.3.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42"
integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==
@@ -884,11 +837,6 @@
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==
-progress@^2.0.0:
- version "2.0.3"
- resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8"
- integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==
-
protobufjs@6.8.8:
version "6.8.8"
resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-6.8.8.tgz#c8b4f1282fd7a90e6f5b109ed11c84af82908e7c"
@@ -918,16 +866,11 @@
resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243"
integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==
-regexpp@^3.1.0:
+regexpp@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2"
integrity sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==
-require-from-string@^2.0.2:
- version "2.0.2"
- resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909"
- integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==
-
resolve-from@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6"
@@ -945,6 +888,13 @@
dependencies:
glob "^7.1.3"
+rollup@^2.79.0:
+ version "2.79.0"
+ resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.79.0.tgz#9177992c9f09eb58c5e56cbfa641607a12b57ce2"
+ integrity sha512-x4KsrCgwQ7ZJPcFA/SUu6QVcYlO7uRLfLAy0DSA4NS2eG8japdbpM50ToH7z4iObodRYOJ0soneF0iaQRJ6zhA==
+ optionalDependencies:
+ fsevents "~2.3.2"
+
run-parallel@^1.1.9:
version "1.2.0"
resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee"
@@ -957,10 +907,10 @@
resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004"
integrity sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==
-semver@^7.2.1, semver@^7.3.5:
- version "7.3.5"
- resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7"
- integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==
+semver@^7.3.7:
+ version "7.3.7"
+ resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.7.tgz#12c5b649afdbf9049707796e22a4028814ce523f"
+ integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==
dependencies:
lru-cache "^6.0.0"
@@ -981,15 +931,6 @@
resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"
integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==
-slice-ansi@^4.0.0:
- version "4.0.0"
- resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-4.0.0.tgz#500e8dd0fd55b05815086255b3195adf2a45fe6b"
- integrity sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==
- dependencies:
- ansi-styles "^4.0.0"
- astral-regex "^2.0.0"
- is-fullwidth-code-point "^3.0.0"
-
source-map-support@0.5.9:
version "0.5.9"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.9.tgz#41bc953b2534267ea2d605bccfa7bfa3111ced5f"
@@ -1003,21 +944,7 @@
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
-sprintf-js@~1.0.2:
- version "1.0.3"
- resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
- integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=
-
-string-width@^4.2.3:
- version "4.2.3"
- resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
- integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
- dependencies:
- emoji-regex "^8.0.0"
- is-fullwidth-code-point "^3.0.0"
- strip-ansi "^6.0.1"
-
-strip-ansi@^6.0.0, strip-ansi@^6.0.1:
+strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -1029,13 +956,6 @@
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006"
integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==
-supports-color@^5.3.0:
- version "5.5.0"
- resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f"
- integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==
- dependencies:
- has-flag "^3.0.0"
-
supports-color@^7.1.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da"
@@ -1043,21 +963,10 @@
dependencies:
has-flag "^4.0.0"
-table@^6.0.9:
- version "6.8.0"
- resolved "https://registry.yarnpkg.com/table/-/table-6.8.0.tgz#87e28f14fa4321c3377ba286f07b79b281a3b3ca"
- integrity sha512-s/fitrbVeEyHKFa7mFdkuQMWlH1Wgw/yEXMt5xACT4ZpzWFluehAxRtUUQKPuWhaLAWhFcVx6w3oC8VKaUfPGA==
- dependencies:
- ajv "^8.0.1"
- lodash.truncate "^4.4.2"
- slice-ansi "^4.0.0"
- string-width "^4.2.3"
- strip-ansi "^6.0.1"
-
text-table@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
- integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=
+ integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==
to-regex-range@^5.0.1:
version "5.0.1"
@@ -1090,10 +999,10 @@
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4"
integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==
-typescript@^4.5.5:
- version "4.6.2"
- resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.2.tgz#fe12d2727b708f4eef40f51598b3398baa9611d4"
- integrity sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg==
+typescript@^4.8.3:
+ version "4.8.3"
+ resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.3.tgz#d59344522c4bc464a65a730ac695007fdb66dd88"
+ integrity sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==
uri-js@^4.2.2:
version "4.4.1"
@@ -1102,11 +1011,6 @@
dependencies:
punycode "^2.1.0"
-v8-compile-cache@^2.0.3:
- version "2.3.0"
- resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee"
- integrity sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==
-
which@^2.0.1:
version "2.0.2"
resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1"
@@ -1122,9 +1026,14 @@
wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
- integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=
+ integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==
yallist@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==
+
+yocto-queue@^0.1.0:
+ version "0.1.0"
+ resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
+ integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==