mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 12:05:50 +00:00
Compare commits
123 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ff9e90e7e | ||
|
|
5b32e8f5c2 | ||
|
|
0bed8cd4a0 | ||
|
|
7cd216c51e | ||
|
|
129ef422e8 | ||
|
|
e5fc3b16d8 | ||
|
|
c0d16995a4 | ||
|
|
70c8292c29 | ||
|
|
d47cd10d77 | ||
|
|
66bd3d7400 | ||
|
|
0cc1edb3ad | ||
|
|
57375a9e1c | ||
|
|
0346535221 | ||
|
|
7d62dcc422 | ||
|
|
b3cd878dfe | ||
|
|
09486a9f97 | ||
|
|
dd79eed495 | ||
|
|
0e1305c8e2 | ||
|
|
88549130e1 | ||
|
|
6dfc59dfcc | ||
|
|
5ba80c24e0 | ||
|
|
da55ac3a27 | ||
|
|
c6f9e010bb | ||
|
|
94ff188a3e | ||
|
|
5a937f1ba1 | ||
|
|
e1c3690a2a | ||
|
|
b08abbbbf6 | ||
|
|
7d6d99c6be | ||
|
|
d3055a97e7 | ||
|
|
0dc5a75dc0 | ||
|
|
f175e60998 | ||
|
|
a632c3c004 | ||
|
|
11789e41b6 | ||
|
|
a9c0845504 | ||
|
|
526c92546f | ||
|
|
eb80ead90b | ||
|
|
386b6353ed | ||
|
|
d09696bbe6 | ||
|
|
a228e8c9b8 | ||
|
|
91a3172519 | ||
|
|
e0d4562782 | ||
|
|
49677b0b70 | ||
|
|
8e34ad5db7 | ||
|
|
eb64390080 | ||
|
|
46577d0d2f | ||
|
|
32029ac699 | ||
|
|
4354945727 | ||
|
|
755573bcda | ||
|
|
205285c35c | ||
|
|
f4e23bf91e | ||
|
|
1fdb5d263a | ||
|
|
c4211538bd | ||
|
|
bcb9ef1876 | ||
|
|
c5441dc199 | ||
|
|
7f417e3397 | ||
|
|
3c35a143ea | ||
|
|
56e2bc30b0 | ||
|
|
eb40a54672 | ||
|
|
15f16f149e | ||
|
|
053d39adaf | ||
|
|
6f71b76e6f | ||
|
|
4b7d8e0df9 | ||
|
|
0def91105f | ||
|
|
8176a204fc | ||
|
|
e8b2492cf1 | ||
|
|
5d4386b1bc | ||
|
|
a6a3989dd4 | ||
|
|
696f47f1f7 | ||
|
|
a3dfcf3326 | ||
|
|
d3e8cb60a1 | ||
|
|
0343396e49 | ||
|
|
f625ff3330 | ||
|
|
362dd663f8 | ||
|
|
5a8a395756 | ||
|
|
afafd206a3 | ||
|
|
48da238920 | ||
|
|
8836ddab41 | ||
|
|
23922e7eba | ||
|
|
f8fe811d5c | ||
|
|
0cc525b722 | ||
|
|
28861d1d7d | ||
|
|
204473cdb5 | ||
|
|
85088a196d | ||
|
|
6e214c3a49 | ||
|
|
96294e9f84 | ||
|
|
b7856f8e27 | ||
|
|
0100f6a577 | ||
|
|
e0a87e36d5 | ||
|
|
b67f1ad6d0 | ||
|
|
ae6753684e | ||
|
|
a352bdbc34 | ||
|
|
cb14043f82 | ||
|
|
d64dc6200a | ||
|
|
ea7cfcd591 | ||
|
|
067553156a | ||
|
|
b128b802d9 | ||
|
|
1d3afb90c5 | ||
|
|
fe5e4c71c5 | ||
|
|
17b9eed4e1 | ||
|
|
cbc8872b99 | ||
|
|
05743591e1 | ||
|
|
2bc2529245 | ||
|
|
18cadc79c1 | ||
|
|
426f3b8bf2 | ||
|
|
950a71ab89 | ||
|
|
86486a1735 | ||
|
|
c2f764c22b | ||
|
|
e97ff95970 | ||
|
|
33212657ae | ||
|
|
66e9d9823a | ||
|
|
9fc153a8f8 | ||
|
|
c2bf810638 | ||
|
|
0ce6957763 | ||
|
|
82c6712606 | ||
|
|
b5957975c5 | ||
|
|
85f71321fd | ||
|
|
3e6cd51b63 | ||
|
|
10b79d87c1 | ||
|
|
16a7df46f0 | ||
|
|
76f5e9816a | ||
|
|
368428cb94 | ||
|
|
72b56fd081 | ||
|
|
63b7b25289 |
@@ -1,5 +1,6 @@
|
||||
---
|
||||
buildifier: latest
|
||||
bazel: 6.4.0
|
||||
platforms:
|
||||
ubuntu1804:
|
||||
environment:
|
||||
|
||||
2
.github/labeler.yml
vendored
2
.github/labeler.yml
vendored
@@ -48,11 +48,11 @@ java:
|
||||
kotlin:
|
||||
- '**/*.kt'
|
||||
- src/idl_gen_kotlin.cpp
|
||||
- src/idl_gen_kotlin_kmp.cpp
|
||||
|
||||
lua:
|
||||
- '**/*.lua'
|
||||
- lua/**/*
|
||||
- src/idl_gen_lua.cpp
|
||||
- src/bfbs_gen_lua.cpp
|
||||
|
||||
lobster:
|
||||
|
||||
182
.github/workflows/build.yml
vendored
182
.github/workflows/build.yml
vendored
@@ -9,7 +9,6 @@ on:
|
||||
- "*" # new tag version, like `0.8.4` or else
|
||||
branches:
|
||||
- master
|
||||
- flatbuffers-64
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
@@ -22,10 +21,10 @@ jobs:
|
||||
digests-gcc: ${{ steps.hash-gcc.outputs.hashes }}
|
||||
digests-clang: ${{ steps.hash-clang.outputs.hashes }}
|
||||
name: Build Linux
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04-64core
|
||||
strategy:
|
||||
matrix:
|
||||
cxx: [g++-10, clang++-12]
|
||||
cxx: [g++-13, clang++-15]
|
||||
fail-fast: false
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@@ -39,10 +38,6 @@ jobs:
|
||||
run: |
|
||||
chmod +x flatc
|
||||
./flatc --version
|
||||
# - name: flatc tests
|
||||
# run: |
|
||||
# yarn global add esbuild
|
||||
# python3 tests/flatc/main.py
|
||||
- name: upload build artifacts
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
@@ -58,42 +53,67 @@ jobs:
|
||||
with:
|
||||
files: Linux.flatc.binary.${{ matrix.cxx }}.zip
|
||||
- name: Generate SLSA subjects - clang
|
||||
if: matrix.cxx == 'clang++-12' && startsWith(github.ref, 'refs/tags/')
|
||||
if: matrix.cxx == 'clang++-15' && startsWith(github.ref, 'refs/tags/')
|
||||
id: hash-clang
|
||||
run: echo "hashes=$(sha256sum Linux.flatc.binary.${{ matrix.cxx }}.zip | base64 -w0)" >> $GITHUB_OUTPUT
|
||||
- name: Generate SLSA subjects - gcc
|
||||
if: matrix.cxx == 'g++-10' && startsWith(github.ref, 'refs/tags/')
|
||||
if: matrix.cxx == 'g++-13' && startsWith(github.ref, 'refs/tags/')
|
||||
id: hash-gcc
|
||||
run: echo "hashes=$(sha256sum Linux.flatc.binary.${{ matrix.cxx }}.zip | base64 -w0)" >> $GITHUB_OUTPUT
|
||||
|
||||
build-linux-no-file-tests:
|
||||
|
||||
build-linux-no-file-tests:
|
||||
name: Build Linux with -DFLATBUFFERS_NO_FILE_TESTS
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04-64core
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: CXX=clang++-12 cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON -DFLATBUFFERS_CXX_FLAGS="-DFLATBUFFERS_NO_FILE_TESTS" .
|
||||
run: CXX=clang++-15 cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON -DFLATBUFFERS_CXX_FLAGS="-DFLATBUFFERS_NO_FILE_TESTS" .
|
||||
- name: build
|
||||
run: make -j
|
||||
- name: test
|
||||
run: ./flattests
|
||||
|
||||
build-linux-out-of-source:
|
||||
name: Build Linux with out-of-source build location
|
||||
runs-on: ubuntu-22.04-64core
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: make build directory
|
||||
run: mkdir build
|
||||
- name: cmake
|
||||
working-directory: build
|
||||
run: >
|
||||
CXX=clang++-15 cmake .. -G "Unix Makefiles" -DFLATBUFFERS_STRICT_MODE=ON
|
||||
-DFLATBUFFERS_BUILD_CPP17=ON -DFLATBUFFERS_CPP_STD=17
|
||||
- name: build
|
||||
working-directory: build
|
||||
run: make -j
|
||||
- name: test
|
||||
working-directory: build
|
||||
run: pwd && ./flattests
|
||||
- name: test C++17
|
||||
working-directory: build
|
||||
run: ./flattests_cpp17
|
||||
|
||||
build-linux-cpp-std:
|
||||
name: Build Linux C++
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04-64core
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
std: [11, 14, 17, 20, 23]
|
||||
cxx: [g++-10, clang++-12]
|
||||
cxx: [g++-13, clang++-15]
|
||||
exclude:
|
||||
# GCC 10.3.0 doesn't support std 23
|
||||
- cxx: g++-10
|
||||
# Clang++15 10.3.0 stdlibc++ doesn't fully support std 23
|
||||
- cxx: clang++-15
|
||||
std: 23
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: >
|
||||
CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles"
|
||||
-DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON
|
||||
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
|
||||
@@ -104,7 +124,7 @@ jobs:
|
||||
if: matrix.std >= 17
|
||||
run: ./flattests_cpp17
|
||||
|
||||
build-windows-cpp-std:
|
||||
build-cpp-std:
|
||||
name: Build Windows C++
|
||||
runs-on: windows-2019
|
||||
strategy:
|
||||
@@ -117,8 +137,8 @@ jobs:
|
||||
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
|
||||
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
|
||||
@@ -134,7 +154,7 @@ jobs:
|
||||
contents: write
|
||||
outputs:
|
||||
digests: ${{ steps.hash.outputs.hashes }}
|
||||
name: Build Windows 2019
|
||||
name: Build Windows 2019
|
||||
runs-on: windows-2019
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@@ -146,8 +166,6 @@ jobs:
|
||||
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:
|
||||
@@ -168,42 +186,14 @@ jobs:
|
||||
shell: bash
|
||||
run: echo "hashes=$(sha256sum Windows.flatc.binary.zip | base64 -w0)" >> $GITHUB_OUTPUT
|
||||
|
||||
build-windows-2017:
|
||||
name: Build Windows 2017
|
||||
runs-on: windows-2019
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- 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 .
|
||||
- name: build tool version 15 (VS 2017)
|
||||
run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64 /p:VisualStudioVersion=15.0
|
||||
- name: test
|
||||
run: Release\flattests.exe
|
||||
|
||||
build-windows-2015:
|
||||
name: Build Windows 2015
|
||||
runs-on: windows-2019
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- 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 -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
|
||||
run: Release\flattests.exe
|
||||
|
||||
build-dotnet-windows:
|
||||
name: Build .NET Windows
|
||||
runs-on: windows-2019
|
||||
runs-on: windows-2022-64core
|
||||
strategy:
|
||||
matrix:
|
||||
configuration: [
|
||||
'',
|
||||
'-p:UnsafeByteBuffer=true',
|
||||
'-p:UnsafeByteBuffer=true',
|
||||
# Fails two tests currently.
|
||||
#'-p:EnableSpanT=true,UnsafeByteBuffer=true'
|
||||
]
|
||||
@@ -211,18 +201,18 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup .NET Core SDK
|
||||
uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: '3.1.x'
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
- name: Build
|
||||
run: |
|
||||
cd tests\FlatBuffers.Test
|
||||
dotnet new sln --force --name FlatBuffers.Core.Test
|
||||
dotnet sln FlatBuffers.Core.Test.sln add FlatBuffers.Core.Test.csproj
|
||||
dotnet build -c Release ${{matrix.configuration}} -o out FlatBuffers.Core.Test.sln
|
||||
dotnet new sln --force --name FlatBuffers.Test
|
||||
dotnet sln FlatBuffers.Test.sln add FlatBuffers.Test.csproj
|
||||
dotnet build -c Release ${{matrix.configuration}} -o out FlatBuffers.Test.sln
|
||||
- name: Run
|
||||
run: |
|
||||
cd tests\FlatBuffers.Test
|
||||
out\FlatBuffers.Core.Test.exe
|
||||
out\FlatBuffers.Test.exe
|
||||
|
||||
build-mac-intel:
|
||||
permissions:
|
||||
@@ -248,8 +238,6 @@ jobs:
|
||||
run: |
|
||||
chmod +x Release/flatc
|
||||
Release/flatc --version
|
||||
# - name: flatc tests
|
||||
# run: python3 tests/flatc/main.py --flatc Release/flatc
|
||||
- name: upload build artifacts
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
@@ -314,7 +302,7 @@ jobs:
|
||||
|
||||
build-android:
|
||||
name: Build Android (on Linux)
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04-64core
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: set up Java
|
||||
@@ -333,10 +321,10 @@ jobs:
|
||||
|
||||
build-generator:
|
||||
name: Check Generated Code
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04-64core
|
||||
strategy:
|
||||
matrix:
|
||||
cxx: [g++-10, clang++-12]
|
||||
cxx: [g++-13, clang++-15]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
@@ -364,10 +352,10 @@ jobs:
|
||||
|
||||
build-benchmarks:
|
||||
name: Build Benchmarks (on Linux)
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04-64core
|
||||
strategy:
|
||||
matrix:
|
||||
cxx: [g++-10]
|
||||
cxx: [g++-13]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
@@ -382,7 +370,7 @@ jobs:
|
||||
|
||||
build-java:
|
||||
name: Build Java
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04-64core
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: test
|
||||
@@ -400,13 +388,18 @@ jobs:
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '11'
|
||||
- name: Build flatc
|
||||
run: |
|
||||
cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF .
|
||||
make -j
|
||||
echo "${PWD}" >> $GITHUB_PATH
|
||||
- name: Build
|
||||
working-directory: kotlin
|
||||
run: ./gradlew clean iosX64Test macosX64Test
|
||||
run: ./gradlew clean iosSimulatorArm64Test macosX64Test macosArm64Test
|
||||
|
||||
build-kotlin-linux:
|
||||
name: Build Kotlin Linux
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04-64core
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
@@ -415,6 +408,11 @@ jobs:
|
||||
distribution: 'temurin'
|
||||
java-version: '11'
|
||||
- uses: gradle/wrapper-validation-action@v1.0.5
|
||||
- name: Build flatc
|
||||
run: |
|
||||
cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF .
|
||||
make -j
|
||||
echo "${PWD}" >> $GITHUB_PATH
|
||||
- name: Build
|
||||
working-directory: kotlin
|
||||
# we are using docker's version of gradle
|
||||
@@ -422,27 +420,39 @@ jobs:
|
||||
# gradlew
|
||||
run: gradle jvmMainClasses jvmTest jsTest jsBrowserTest
|
||||
|
||||
build-rust:
|
||||
name: Build Rust
|
||||
runs-on: ubuntu-latest
|
||||
build-rust-linux:
|
||||
name: Build Rust Linux
|
||||
runs-on: ubuntu-22.04-64core
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: test
|
||||
working-directory: tests
|
||||
run: bash RustTest.sh
|
||||
|
||||
build-python:
|
||||
name: Build Python
|
||||
runs-on: ubuntu-latest
|
||||
build-rust-windows:
|
||||
name: Build Rust Windows
|
||||
runs-on: windows-2022-64core
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: test
|
||||
working-directory: tests
|
||||
run: ./RustTest.bat
|
||||
|
||||
build-python:
|
||||
name: Build Python
|
||||
runs-on: ubuntu-22.04-64core
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- 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 -DFLATBUFFERS_STRICT_MODE=ON . && make -j
|
||||
- name: test
|
||||
working-directory: tests
|
||||
run: bash PythonTest.sh
|
||||
|
||||
build-go:
|
||||
name: Build Go
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04-64core
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: flatc
|
||||
@@ -454,7 +464,7 @@ jobs:
|
||||
|
||||
build-php:
|
||||
name: Build PHP
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04-64core
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: flatc
|
||||
@@ -468,7 +478,7 @@ jobs:
|
||||
|
||||
build-swift:
|
||||
name: Build Swift
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04-64core
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: test
|
||||
@@ -479,7 +489,7 @@ jobs:
|
||||
|
||||
build-swift-wasm:
|
||||
name: Build Swift Wasm
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04-64core
|
||||
container:
|
||||
image: ghcr.io/swiftwasm/carton:0.15.3
|
||||
steps:
|
||||
@@ -492,7 +502,7 @@ jobs:
|
||||
|
||||
build-ts:
|
||||
name: Build TS
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04-64core
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: flatc
|
||||
@@ -510,7 +520,7 @@ jobs:
|
||||
|
||||
build-dart:
|
||||
name: Build Dart
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04-64core
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: dart-lang/setup-dart@v1
|
||||
@@ -525,7 +535,7 @@ jobs:
|
||||
|
||||
build-nim:
|
||||
name: Build Nim
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04-64core
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: flatc
|
||||
@@ -534,7 +544,7 @@ jobs:
|
||||
- uses: jiro4989/setup-nim-action@v1
|
||||
- name: install library
|
||||
working-directory: nim
|
||||
run: nimble -y develop
|
||||
run: nimble -y develop && nimble install
|
||||
- name: test
|
||||
working-directory: tests/nim
|
||||
run: python3 testnim.py
|
||||
@@ -544,7 +554,7 @@ jobs:
|
||||
needs: [build-linux, build-windows, build-mac-intel, build-mac-universal]
|
||||
outputs:
|
||||
digests: ${{ steps.hash.outputs.digests }}
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04-64core
|
||||
steps:
|
||||
- name: Merge results
|
||||
id: hash
|
||||
|
||||
4
.github/workflows/label.yml
vendored
4
.github/workflows/label.yml
vendored
@@ -19,6 +19,6 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/labeler@main
|
||||
- uses: actions/labeler@ee18d5d34efd9b4f7dafdb0e363cb688eb438044 # 4.1.0
|
||||
with:
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
|
||||
35
.github/workflows/release.yml
vendored
35
.github/workflows/release.yml
vendored
@@ -10,18 +10,18 @@ on:
|
||||
jobs:
|
||||
publish-npm:
|
||||
name: Publish NPM
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '16.x'
|
||||
node-version: '20.x'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
|
||||
- run: npm publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
|
||||
publish-pypi:
|
||||
name: Publish PyPi
|
||||
runs-on: ubuntu-latest
|
||||
@@ -33,16 +33,16 @@ jobs:
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.10'
|
||||
|
||||
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
python3 -m pip install --upgrade pip
|
||||
python3 -m pip install setuptools wheel twine
|
||||
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
python3 setup.py sdist bdist_wheel
|
||||
|
||||
|
||||
- name: Upload to PyPi
|
||||
run: |
|
||||
python3 -m twine upload dist/*
|
||||
@@ -60,20 +60,19 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: '6.0.x'
|
||||
|
||||
dotnet-version: '8.0.x'
|
||||
- name: Build
|
||||
run: |
|
||||
dotnet build Google.FlatBuffers.csproj -c Release
|
||||
|
||||
|
||||
- name: Pack
|
||||
run: |
|
||||
dotnet pack Google.FlatBuffers.csproj -c Release
|
||||
|
||||
|
||||
- name: Upload to NuGet
|
||||
run: |
|
||||
dotnet nuget push .\bin\Release\Google.FlatBuffers.*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
|
||||
|
||||
dotnet nuget push .\bin\Release\Google.FlatBuffers.*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
|
||||
|
||||
publish-maven:
|
||||
name: Publish Maven
|
||||
runs-on: ubuntu-latest
|
||||
@@ -82,7 +81,7 @@ jobs:
|
||||
working-directory: ./java
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
|
||||
- name: Set up Maven Central Repository
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
@@ -94,13 +93,13 @@ jobs:
|
||||
server-password: OSSRH_PASSWORD
|
||||
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
|
||||
gpg-passphrase: MAVEN_GPG_PASSPHRASE # this needs to be an env var
|
||||
|
||||
|
||||
- name: Publish Maven
|
||||
run: mvn --batch-mode clean deploy
|
||||
env:
|
||||
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
|
||||
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
|
||||
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
8
.github/workflows/stale.yml
vendored
8
.github/workflows/stale.yml
vendored
@@ -28,10 +28,10 @@ jobs:
|
||||
days-before-issue-close: 14 # 2 weeks
|
||||
exempt-issue-labels: not-stale
|
||||
|
||||
stale-pr-message: 'This pull request is stale because it has been open 3 weeks with no activity. Please comment or label `not-stale`, or this will be closed in 7 days.'
|
||||
close-pr-message: 'This pull request was automatically closed due to no activity for 3 weeks plus the 7 day notice period.'
|
||||
days-before-pr-stale: 21 # 3 weeks
|
||||
days-before-pr-close: 7 # 1 week
|
||||
stale-pr-message: 'This pull request is stale because it has been open 6 months with no activity. Please comment or label `not-stale`, or this will be closed in 14 days.'
|
||||
close-pr-message: 'This pull request was automatically closed due to no activity for 6 months plus the 14 day notice period.'
|
||||
days-before-pr-stale: 182 # 6 months
|
||||
days-before-pr-close: 14 # 2 week
|
||||
exempt-pr-labels: not-stale
|
||||
exempt-draft-pr: false
|
||||
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -151,3 +151,5 @@ flatbuffers.pc
|
||||
# https://cmake.org/cmake/help/latest/module/FetchContent.html#variable:FETCHCONTENT_BASE_DIR
|
||||
cmake-build-debug/
|
||||
_deps/
|
||||
**/.gradle/**
|
||||
kotlin/**/generated
|
||||
|
||||
17
CHANGELOG.md
17
CHANGELOG.md
@@ -4,6 +4,23 @@ 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.
|
||||
|
||||
## [24.3.7] (March 7 2024)(https://github.com/google/flatbuffers/releases/tag/v24.3.7)
|
||||
|
||||
* Just to fix some of the CI build issues from the 24.3.6 release.
|
||||
|
||||
## [24.3.6] (March 6 2024)(https://github.com/google/flatbuffers/releases/tag/v24.3.6)
|
||||
|
||||
* Fix typescript object API to allow 0 values for null-default scalars (#7864)
|
||||
|
||||
## [23.5.26 (May 26 2023)](https://github.com/google/flatbuffers/releases/tag/v23.5.26)
|
||||
|
||||
* Mostly bug fixing for 64-bit support
|
||||
* Adds support for specifying underling type of unions in C++ and TS/JS (#7954)
|
||||
|
||||
## [23.5.9 (May 9 2023)](https://github.com/google/flatbuffers/releases/tag/v23.5.9)
|
||||
|
||||
* 64-bit support for C++ (#7935)
|
||||
|
||||
## [23.5.8 (May 8 2023)](https://github.com/google/flatbuffers/releases/tag/v23.5.8)
|
||||
|
||||
* add key_field to compiled tests
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
set(VERSION_MAJOR 23)
|
||||
set(VERSION_MINOR 5)
|
||||
set(VERSION_PATCH 8)
|
||||
set(VERSION_MAJOR 24)
|
||||
set(VERSION_MINOR 3)
|
||||
set(VERSION_PATCH 7)
|
||||
set(VERSION_COMMIT 0)
|
||||
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||
@@ -29,7 +29,7 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||
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}")
|
||||
message(WARNING "git describe failed with exit code: ${GIT_DESCRIBE_RESULT}\nMake sure you cloned with tags or run 'git fetch --tags'.")
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "git is not found")
|
||||
|
||||
@@ -160,13 +160,13 @@ set(FlatBuffers_Compiler_SRCS
|
||||
src/idl_gen_csharp.cpp
|
||||
src/idl_gen_dart.cpp
|
||||
src/idl_gen_kotlin.cpp
|
||||
src/idl_gen_kotlin_kmp.cpp
|
||||
src/idl_gen_go.cpp
|
||||
src/idl_gen_java.cpp
|
||||
src/idl_gen_ts.cpp
|
||||
src/idl_gen_php.cpp
|
||||
src/idl_gen_python.cpp
|
||||
src/idl_gen_lobster.cpp
|
||||
src/idl_gen_lua.cpp
|
||||
src/idl_gen_rust.cpp
|
||||
src/idl_gen_fbs.cpp
|
||||
src/idl_gen_grpc.cpp
|
||||
@@ -234,6 +234,8 @@ set(FlatBuffers_Tests_SRCS
|
||||
tests/native_type_test_impl.cpp
|
||||
tests/alignment_test.h
|
||||
tests/alignment_test.cpp
|
||||
tests/64bit/offset64_test.h
|
||||
tests/64bit/offset64_test.cpp
|
||||
include/flatbuffers/code_generators.h
|
||||
src/code_generators.cpp
|
||||
)
|
||||
@@ -246,7 +248,6 @@ set(FlatBuffers_Tests_CPP17_SRCS
|
||||
)
|
||||
|
||||
set(FlatBuffers_Sample_Binary_SRCS
|
||||
include/flatbuffers/flatbuffers.h
|
||||
samples/sample_binary.cpp
|
||||
)
|
||||
|
||||
@@ -490,12 +491,13 @@ endif()
|
||||
function(compile_schema SRC_FBS OPT OUT_GEN_FILE)
|
||||
get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH)
|
||||
string(REGEX REPLACE "\\.fbs$" "_generated.h" GEN_HEADER ${SRC_FBS})
|
||||
add_custom_command(TARGET flatc POST_BUILD
|
||||
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}"
|
||||
add_custom_command(
|
||||
OUTPUT ${GEN_HEADER}
|
||||
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}"
|
||||
${OPT}
|
||||
-o "${SRC_FBS_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
|
||||
BYPRODUCTS ${GEN_HEADER}
|
||||
DEPENDS flatc ${SRC_FBS}
|
||||
COMMENT "flatc generation: `${SRC_FBS}` -> `${GEN_HEADER}`"
|
||||
)
|
||||
set(${OUT_GEN_FILE} ${GEN_HEADER} PARENT_SCOPE)
|
||||
@@ -508,25 +510,39 @@ endfunction()
|
||||
|
||||
function(compile_schema_for_samples SRC_FBS OPT)
|
||||
compile_schema("${SRC_FBS}" "${OPT}" GEN_FILE)
|
||||
target_sources(flatsamplebinary PRIVATE ${GEN_FILE})
|
||||
target_sources(flatsampletext PRIVATE ${GEN_FILE})
|
||||
target_sources(flatsamplebfbs PRIVATE ${GEN_FILE})
|
||||
target_sources(flatsample PRIVATE ${GEN_FILE})
|
||||
endfunction()
|
||||
|
||||
if(FLATBUFFERS_BUILD_TESTS)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/tests)
|
||||
add_executable(flattests ${FlatBuffers_Tests_SRCS})
|
||||
target_link_libraries(flattests PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||
target_include_directories(flattests PUBLIC src)
|
||||
target_include_directories(flattests PUBLIC
|
||||
# Ideally everything is fully qualified from the root directories
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
# TODO(derekbailey): update includes to fully qualify src/ and tests/
|
||||
src
|
||||
tests
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests
|
||||
)
|
||||
|
||||
# Have tests load data from the source directory, not the build directory.
|
||||
add_definitions(-DFLATBUFFERS_TEST_PATH_PREFIX=${CMAKE_CURRENT_SOURCE_DIR}/)
|
||||
|
||||
# The flattest target needs some generated files
|
||||
SET(FLATC_OPT --cpp --gen-mutable --gen-object-api --reflect-names)
|
||||
SET(FLATC_OPT_COMP ${FLATC_OPT};--gen-compare)
|
||||
SET(FLATC_OPT_SCOPED_ENUMS ${FLATC_OPT_COMP};--scoped-enums)
|
||||
|
||||
compile_schema_for_test(tests/alignment_test.fbs "${FLATC_OPT_COMP}")
|
||||
compile_schema_for_test(tests/arrays_test.fbs "${FLATC_OPT_SCOPED_ENUMS}")
|
||||
compile_schema_for_test(tests/native_inline_table_test.fbs "${FLATC_OPT_COMP}")
|
||||
compile_schema_for_test(tests/native_type_test.fbs "${FLATC_OPT}")
|
||||
compile_schema_for_test(tests/key_field/key_field_sample.fbs "${FLATC_OPT_COMP}")
|
||||
compile_schema_for_test(tests/64bit/test_64bit.fbs "${FLATC_OPT_COMP};--bfbs-gen-embed")
|
||||
compile_schema_for_test(tests/64bit/evolution/v1.fbs "${FLATC_OPT_COMP}")
|
||||
compile_schema_for_test(tests/64bit/evolution/v2.fbs "${FLATC_OPT_COMP}")
|
||||
compile_schema_for_test(tests/union_underlying_type_test.fbs "${FLATC_OPT_SCOPED_ENUMS}")
|
||||
|
||||
if(FLATBUFFERS_CODE_SANITIZE)
|
||||
add_fsanitize_to_target(flattests ${FLATBUFFERS_CODE_SANITIZE})
|
||||
@@ -537,16 +553,28 @@ if(FLATBUFFERS_BUILD_TESTS)
|
||||
add_executable(flatsamplebinary ${FlatBuffers_Sample_Binary_SRCS})
|
||||
add_executable(flatsampletext ${FlatBuffers_Sample_Text_SRCS})
|
||||
add_executable(flatsamplebfbs ${FlatBuffers_Sample_BFBS_SRCS})
|
||||
|
||||
target_link_libraries(flatsamplebinary PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||
target_link_libraries(flatsampletext PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||
target_link_libraries(flatsamplebfbs PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||
|
||||
# Add a library so there is a single target that the generated samples can
|
||||
# link too.
|
||||
if(MSVC OR ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.20.0")
|
||||
add_library(flatsample INTERFACE)
|
||||
else()
|
||||
add_library(flatsample STATIC)
|
||||
endif()
|
||||
|
||||
# Since flatsample has no sources, we have to explicitly set the linker lang.
|
||||
set_target_properties(flatsample PROPERTIES LINKER_LANGUAGE CXX)
|
||||
|
||||
compile_schema_for_samples(samples/monster.fbs "${FLATC_OPT_COMP}")
|
||||
|
||||
target_link_libraries(flatsamplebinary PRIVATE $<BUILD_INTERFACE:ProjectConfig> flatsample)
|
||||
target_link_libraries(flatsampletext PRIVATE $<BUILD_INTERFACE:ProjectConfig> flatsample)
|
||||
target_link_libraries(flatsamplebfbs PRIVATE $<BUILD_INTERFACE:ProjectConfig> flatsample)
|
||||
|
||||
if(FLATBUFFERS_BUILD_CPP17)
|
||||
add_executable(flattests_cpp17 ${FlatBuffers_Tests_CPP17_SRCS})
|
||||
target_link_libraries(flattests_cpp17 PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||
target_include_directories(flattests_cpp17 PUBLIC src tests)
|
||||
target_compile_features(flattests_cpp17 PRIVATE cxx_std_17) # requires cmake 3.8
|
||||
|
||||
if(FLATBUFFERS_CODE_SANITIZE)
|
||||
@@ -570,7 +598,7 @@ if(FLATBUFFERS_BUILD_GRPCTEST)
|
||||
find_package(protobuf CONFIG REQUIRED)
|
||||
find_package(gRPC CONFIG REQUIRED)
|
||||
add_executable(grpctest ${FlatBuffers_GRPCTest_SRCS})
|
||||
target_link_libraries(grpctext
|
||||
target_link_libraries(grpctest
|
||||
PRIVATE
|
||||
$<BUILD_INTERFACE:ProjectConfig>
|
||||
gRPC::grpc++_unsecure
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'FlatBuffers'
|
||||
s.version = '23.5.8'
|
||||
s.version = '24.3.7'
|
||||
s.summary = 'FlatBuffers: Memory Efficient Serialization Library'
|
||||
|
||||
s.description = "FlatBuffers is a cross platform serialization library architected for
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// swift-tools-version:5.2
|
||||
// swift-tools-version:5.6
|
||||
/*
|
||||
* Copyright 2020 Google Inc. All rights reserved.
|
||||
*
|
||||
@@ -32,6 +32,5 @@ let package = Package(
|
||||
.target(
|
||||
name: "FlatBuffers",
|
||||
dependencies: [],
|
||||
path: "swift/Sources",
|
||||
exclude: ["Documentation.docc/Resources/code/swift"]),
|
||||
path: "swift/Sources"),
|
||||
])
|
||||
|
||||
46
README.md
46
README.md
@@ -14,6 +14,47 @@
|
||||
**FlatBuffers** is a cross platform serialization library architected for
|
||||
maximum memory efficiency. It allows you to directly access serialized data without parsing/unpacking it first, while still having great forwards/backwards compatibility.
|
||||
|
||||
## Quick Start
|
||||
|
||||
1. Build the compiler for flatbuffers (`flatc`)
|
||||
|
||||
Use `cmake` to create the build files for your platform and then perform the compliation (Linux example).
|
||||
|
||||
```
|
||||
cmake -G "Unix Makefiles"
|
||||
make -j
|
||||
```
|
||||
|
||||
2. Define your flatbuffer schema (`.fbs`)
|
||||
|
||||
Write the [schema](https://flatbuffers.dev/flatbuffers_guide_writing_schema.html) to define the data you want to serialize. See [monster.fbs](https://github.com/google/flatbuffers/blob/master/samples/monster.fbs) for an example.
|
||||
|
||||
3. Generate code for your language(s)
|
||||
|
||||
Use the `flatc` compiler to take your schema and generate language-specific code:
|
||||
|
||||
```
|
||||
./flatc --cpp --rust monster.fbs
|
||||
```
|
||||
|
||||
Which generates `monster_generated.h` and `monster_generated.rs` files.
|
||||
|
||||
4. Serialize data
|
||||
|
||||
Use the generated code, as well as the `FlatBufferBuilder` to construct your serialized buffer. ([`C++` example](https://github.com/google/flatbuffers/blob/master/samples/sample_binary.cpp#L24-L56))
|
||||
|
||||
5. Transmit/store/save Buffer
|
||||
|
||||
Use your serialized buffer however you want. Send it to someone, save it for later, etc...
|
||||
|
||||
6. Read the data
|
||||
|
||||
Use the generated accessors to read the data from the serialized buffer.
|
||||
|
||||
It doesn't need to be the same language/schema version, FlatBuffers ensures the data is readable across languages and schema versions. See the [`Rust` example](https://github.com/google/flatbuffers/blob/master/samples/sample_binary.rs#L92-L106) reading the data written by `C++`.
|
||||
|
||||
## Documentation
|
||||
|
||||
**Go to our [landing page][] to browse our documentation.**
|
||||
|
||||
## Supported operating systems
|
||||
@@ -46,7 +87,7 @@ Code generation and runtime libraries for many popular languages.
|
||||
|
||||
## Versioning
|
||||
|
||||
FlatBuffers does not follow traditional Semver versioning (see [rationale](https://github.com/google/flatbuffers/wiki/Versioning)) but rather uses a format of the date of the release.
|
||||
FlatBuffers does not follow traditional SemVer versioning (see [rationale](https://github.com/google/flatbuffers/wiki/Versioning)) but rather uses a format of the date of the release.
|
||||
|
||||
## Contribution
|
||||
|
||||
@@ -57,10 +98,7 @@ FlatBuffers does not follow traditional Semver versioning (see [rationale](https
|
||||
|
||||
## 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
|
||||
|
||||
|
||||
56
WORKSPACE
56
WORKSPACE
@@ -4,13 +4,26 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file"
|
||||
|
||||
http_archive(
|
||||
name = "platforms",
|
||||
sha256 = "379113459b0feaf6bfbb584a91874c065078aa673222846ac765f86661c27407",
|
||||
sha256 = "3a561c99e7bdbe9173aa653fd579fe849f1d8d67395780ab4770b1f381431d51",
|
||||
urls = [
|
||||
"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",
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz",
|
||||
"https://github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "build_bazel_rules_apple",
|
||||
sha256 = "34c41bfb59cdaea29ac2df5a2fa79e5add609c71bb303b2ebb10985f93fa20e7",
|
||||
url = "https://github.com/bazelbuild/rules_apple/releases/download/3.1.1/rules_apple.3.1.1.tar.gz",
|
||||
)
|
||||
|
||||
load(
|
||||
"@build_bazel_rules_apple//apple:repositories.bzl",
|
||||
"apple_rules_dependencies",
|
||||
)
|
||||
|
||||
apple_rules_dependencies()
|
||||
|
||||
http_archive(
|
||||
name = "build_bazel_rules_swift",
|
||||
sha256 = "a2fd565e527f83fb3f9eb07eb9737240e668c9242d3bc318712efa54a7deda97",
|
||||
@@ -33,10 +46,10 @@ swift_rules_extra_dependencies()
|
||||
|
||||
http_archive(
|
||||
name = "io_bazel_rules_go",
|
||||
sha256 = "ae013bf35bd23234d1dea46b079f1e05ba74ac0321423830119d3e787ec73483",
|
||||
sha256 = "278b7ff5a826f3dc10f04feaf0b70d48b68748ccd512d7f98bf442077f043fe3",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.36.0/rules_go-v0.36.0.zip",
|
||||
"https://github.com/bazelbuild/rules_go/releases/download/v0.36.0/rules_go-v0.36.0.zip",
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip",
|
||||
"https://github.com/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -79,9 +92,9 @@ grpc_extra_deps()
|
||||
|
||||
http_archive(
|
||||
name = "aspect_rules_js",
|
||||
sha256 = "124ed29fb0b3d0cba5b44f8f8e07897cf61b34e35e33b1f83d1a943dfd91b193",
|
||||
strip_prefix = "rules_js-1.24.0",
|
||||
url = "https://github.com/aspect-build/rules_js/releases/download/v1.24.0/rules_js-v1.24.0.tar.gz",
|
||||
sha256 = "76a04ef2120ee00231d85d1ff012ede23963733339ad8db81f590791a031f643",
|
||||
strip_prefix = "rules_js-1.34.1",
|
||||
url = "https://github.com/aspect-build/rules_js/releases/download/v1.34.1/rules_js-v1.34.1.tar.gz",
|
||||
)
|
||||
|
||||
load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")
|
||||
@@ -94,9 +107,9 @@ pnpm_repository(name = "pnpm")
|
||||
|
||||
http_archive(
|
||||
name = "aspect_rules_ts",
|
||||
sha256 = "8eb25d1fdafc0836f5778d33fb8eaac37c64176481d67872b54b0a05de5be5c0",
|
||||
strip_prefix = "rules_ts-1.3.3",
|
||||
url = "https://github.com/aspect-build/rules_ts/releases/download/v1.3.3/rules_ts-v1.3.3.tar.gz",
|
||||
sha256 = "4c3f34fff9f96ffc9c26635d8235a32a23a6797324486c7d23c1dfa477e8b451",
|
||||
strip_prefix = "rules_ts-1.4.5",
|
||||
url = "https://github.com/aspect-build/rules_ts/releases/download/v1.4.5/rules_ts-v1.4.5.tar.gz",
|
||||
)
|
||||
|
||||
load("@aspect_rules_ts//ts:repositories.bzl", "rules_ts_dependencies")
|
||||
@@ -104,8 +117,8 @@ load("@aspect_rules_ts//ts:repositories.bzl", "rules_ts_dependencies")
|
||||
rules_ts_dependencies(
|
||||
# Since rules_ts doesn't always have the newest integrity hashes, we
|
||||
# compute it manually here.
|
||||
# $ curl --silent https://registry.npmjs.org/typescript/5.0.4 | jq ._integrity
|
||||
ts_integrity = "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==",
|
||||
# $ curl --silent https://registry.npmjs.org/typescript/5.3.3 | jq ._integrity
|
||||
ts_integrity = "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==",
|
||||
ts_version_from = "//:package.json",
|
||||
)
|
||||
|
||||
@@ -132,24 +145,25 @@ npm_repositories()
|
||||
|
||||
http_archive(
|
||||
name = "aspect_rules_esbuild",
|
||||
sha256 = "2ea31bd97181a315e048be693ddc2815fddda0f3a12ca7b7cc6e91e80f31bac7",
|
||||
strip_prefix = "rules_esbuild-0.14.4",
|
||||
url = "https://github.com/aspect-build/rules_esbuild/releases/download/v0.14.4/rules_esbuild-v0.14.4.tar.gz",
|
||||
sha256 = "098e38e5ee868c14a6484ba263b79e57d48afacfc361ba30137c757a9c4716d6",
|
||||
strip_prefix = "rules_esbuild-0.15.0",
|
||||
url = "https://github.com/aspect-build/rules_esbuild/releases/download/v0.15.0/rules_esbuild-v0.15.0.tar.gz",
|
||||
)
|
||||
|
||||
# Register a toolchain containing esbuild npm package and native bindings
|
||||
load("@aspect_rules_esbuild//esbuild:repositories.bzl", "LATEST_VERSION", "esbuild_register_toolchains")
|
||||
load("@aspect_rules_esbuild//esbuild:repositories.bzl", "LATEST_ESBUILD_VERSION", "esbuild_register_toolchains")
|
||||
|
||||
esbuild_register_toolchains(
|
||||
name = "esbuild",
|
||||
esbuild_version = LATEST_VERSION,
|
||||
esbuild_version = LATEST_ESBUILD_VERSION,
|
||||
)
|
||||
|
||||
http_file(
|
||||
name = "bazel_linux_x86_64",
|
||||
downloaded_file_path = "bazel",
|
||||
sha256 = "e89747d63443e225b140d7d37ded952dacea73aaed896bca01ccd745827c6289",
|
||||
executable = True,
|
||||
sha256 = "e78fc3394deae5408d6f49a15c7b1e615901969ecf6e50d55ef899996b0b8458",
|
||||
urls = [
|
||||
"https://github.com/bazelbuild/bazel/releases/download/6.1.2/bazel-6.1.2-linux-x86_64",
|
||||
"https://github.com/bazelbuild/bazel/releases/download/6.3.2/bazel-6.3.2-linux-x86_64",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
</natures>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1677235311958</id>
|
||||
<id>1672434305228</id>
|
||||
<name></name>
|
||||
<type>30</type>
|
||||
<matcher>
|
||||
|
||||
@@ -48,7 +48,6 @@ find_library( # Sets the name of the path variable.
|
||||
target_link_libraries( # Specifies the target library.
|
||||
native-lib
|
||||
flatbuffers
|
||||
flatbuffers_tests
|
||||
# Links the target library to the log library
|
||||
# included in the NDK.
|
||||
${log-lib} )
|
||||
|
||||
@@ -48,26 +48,9 @@ set(FlatBuffers_Library_SRCS
|
||||
${FLATBUFFERS_SRC}/src/code_generators.cpp
|
||||
)
|
||||
|
||||
set(FlatBuffers_Test_SRCS
|
||||
${FLATBUFFERS_SRC}/tests/test.cpp
|
||||
${FLATBUFFERS_SRC}/tests/test_assert.h
|
||||
${FLATBUFFERS_SRC}/tests/test_builder.h
|
||||
${FLATBUFFERS_SRC}/tests/test_assert.cpp
|
||||
${FLATBUFFERS_SRC}/tests/test_builder.cpp
|
||||
${FLATBUFFERS_SRC}/tests/native_type_test_impl.h
|
||||
${FLATBUFFERS_SRC}/tests/native_type_test_impl.cpp
|
||||
)
|
||||
|
||||
add_library( # Sets the name of the library.
|
||||
flatbuffers
|
||||
|
||||
${FlatBuffers_Library_SRCS}
|
||||
${FlatBuffers_Test_SRCS}
|
||||
${Generated_SRCS}
|
||||
)
|
||||
|
||||
add_library( # Sets the name of the library.
|
||||
flatbuffers_tests
|
||||
|
||||
${FlatBuffers_Test_SRCS}
|
||||
)
|
||||
|
||||
@@ -57,7 +57,7 @@ class Animal : Table() {
|
||||
return if(o != 0) bb.getShort(o + bb_pos).toUShort() else 0u
|
||||
}
|
||||
companion object {
|
||||
fun validateVersion() = Constants.FLATBUFFERS_23_5_8()
|
||||
fun validateVersion() = Constants.FLATBUFFERS_24_3_7()
|
||||
fun getRootAsAnimal(_bb: ByteBuffer): Animal = getRootAsAnimal(_bb, Animal())
|
||||
fun getRootAsAnimal(_bb: ByteBuffer, obj: Animal): Animal {
|
||||
_bb.order(ByteOrder.LITTLE_ENDIAN)
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
* Copyright 2023 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
|
||||
|
||||
@usableFromInline
|
||||
struct AA: NativeStruct {
|
||||
public init(a: Double, b: Double) {
|
||||
self.a = a
|
||||
self.b = b
|
||||
}
|
||||
var a: Double
|
||||
var b: Double
|
||||
}
|
||||
|
||||
let benchmarks = {
|
||||
let ints: [Int] = Array(repeating: 42, count: 100)
|
||||
let bytes: [UInt8] = Array(repeating: 42, count: 100)
|
||||
let str10 = (0...9).map { _ -> String in "x" }.joined()
|
||||
let str100 = (0...99).map { _ -> String in "x" }.joined()
|
||||
let array: [AA] = [
|
||||
AA(a: 2.4, b: 2.4),
|
||||
AA(a: 2.4, b: 2.4),
|
||||
AA(a: 2.4, b: 2.4),
|
||||
AA(a: 2.4, b: 2.4),
|
||||
AA(a: 2.4, b: 2.4),
|
||||
]
|
||||
|
||||
let metrics: [BenchmarkMetric] = [
|
||||
.cpuTotal,
|
||||
.wallClock,
|
||||
.mallocCountTotal,
|
||||
.releaseCount,
|
||||
.peakMemoryResident,
|
||||
]
|
||||
let maxIterations = 1_000_000
|
||||
let maxDuration: Duration = .seconds(3)
|
||||
let singleConfiguration: Benchmark.Configuration = .init(
|
||||
metrics: metrics,
|
||||
warmupIterations: 1,
|
||||
scalingFactor: .one,
|
||||
maxDuration: maxDuration,
|
||||
maxIterations: maxIterations)
|
||||
let kiloConfiguration: Benchmark.Configuration = .init(
|
||||
metrics: metrics,
|
||||
warmupIterations: 1,
|
||||
scalingFactor: .kilo,
|
||||
maxDuration: maxDuration,
|
||||
maxIterations: maxIterations)
|
||||
let megaConfiguration: Benchmark.Configuration = .init(
|
||||
metrics: metrics,
|
||||
warmupIterations: 1,
|
||||
scalingFactor: .mega,
|
||||
maxDuration: maxDuration,
|
||||
maxIterations: maxIterations)
|
||||
|
||||
Benchmark.defaultConfiguration = megaConfiguration
|
||||
|
||||
Benchmark("Allocating 1GB", configuration: singleConfiguration) { benchmark in
|
||||
for _ in benchmark.scaledIterations {
|
||||
blackHole(FlatBufferBuilder(initialSize: 1_024_000_000))
|
||||
}
|
||||
}
|
||||
|
||||
Benchmark("Clearing 1GB", configuration: singleConfiguration) { benchmark in
|
||||
var fb = FlatBufferBuilder(initialSize: 1_024_000_000)
|
||||
benchmark.startMeasurement()
|
||||
for _ in benchmark.scaledIterations {
|
||||
blackHole(fb.clear())
|
||||
}
|
||||
}
|
||||
|
||||
Benchmark("Strings 10") { benchmark in
|
||||
var fb = FlatBufferBuilder(initialSize: 1<<20)
|
||||
benchmark.startMeasurement()
|
||||
for _ in benchmark.scaledIterations {
|
||||
blackHole(fb.create(string: str10))
|
||||
}
|
||||
}
|
||||
|
||||
Benchmark("Strings 100") { benchmark in
|
||||
var fb = FlatBufferBuilder(initialSize: 1<<20)
|
||||
benchmark.startMeasurement()
|
||||
for _ in benchmark.scaledIterations {
|
||||
blackHole(fb.create(string: str100))
|
||||
}
|
||||
}
|
||||
|
||||
Benchmark("Vector 1 Bytes") { benchmark in
|
||||
var fb = FlatBufferBuilder(initialSize: 1<<20)
|
||||
benchmark.startMeasurement()
|
||||
for _ in benchmark.scaledIterations {
|
||||
blackHole(fb.createVector(bytes: bytes))
|
||||
}
|
||||
}
|
||||
|
||||
Benchmark("Vector 1 Ints") { benchmark in
|
||||
var fb = FlatBufferBuilder(initialSize: 1<<20)
|
||||
benchmark.startMeasurement()
|
||||
for _ in benchmark.scaledIterations {
|
||||
blackHole(fb.createVector(ints))
|
||||
}
|
||||
}
|
||||
|
||||
Benchmark("Vector 100 Ints") { benchmark in
|
||||
var fb = FlatBufferBuilder(initialSize: 1<<20)
|
||||
benchmark.startMeasurement()
|
||||
for i in benchmark.scaledIterations {
|
||||
blackHole(fb.createVector(ints))
|
||||
}
|
||||
}
|
||||
|
||||
Benchmark("Vector 100 Bytes") { benchmark in
|
||||
var fb = FlatBufferBuilder(initialSize: 1<<20)
|
||||
benchmark.startMeasurement()
|
||||
for i in benchmark.scaledIterations {
|
||||
blackHole(fb.createVector(bytes))
|
||||
}
|
||||
}
|
||||
|
||||
Benchmark("Vector 100 ContiguousBytes") { benchmark in
|
||||
var fb = FlatBufferBuilder(initialSize: 1<<20)
|
||||
benchmark.startMeasurement()
|
||||
for i in benchmark.scaledIterations {
|
||||
blackHole(fb.createVector(bytes: bytes))
|
||||
}
|
||||
}
|
||||
|
||||
Benchmark(
|
||||
"FlatBufferBuilder Add",
|
||||
configuration: kiloConfiguration)
|
||||
{ benchmark in
|
||||
var fb = FlatBufferBuilder(initialSize: 1024 * 1024 * 32)
|
||||
benchmark.startMeasurement()
|
||||
for _ in benchmark.scaledIterations {
|
||||
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)
|
||||
blackHole(fb.endTable(at: s))
|
||||
}
|
||||
}
|
||||
|
||||
Benchmark("Structs") { benchmark in
|
||||
let rawSize = ((16 * 5) * benchmark.scaledIterations.count) / 1024
|
||||
var fb = FlatBufferBuilder(initialSize: Int32(rawSize * 1600))
|
||||
var offsets: [Offset] = []
|
||||
|
||||
benchmark.startMeasurement()
|
||||
for _ in benchmark.scaledIterations {
|
||||
let vector = fb.createVector(
|
||||
ofStructs: array)
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// swift-tools-version:5.1
|
||||
// swift-tools-version:5.8
|
||||
/*
|
||||
* Copyright 2020 Google Inc. All rights reserved.
|
||||
*
|
||||
@@ -20,15 +20,23 @@ import PackageDescription
|
||||
let package = Package(
|
||||
name: "benchmarks",
|
||||
platforms: [
|
||||
.macOS(.v10_14),
|
||||
.macOS(.v13),
|
||||
],
|
||||
dependencies: [
|
||||
.package(path: "../../.."),
|
||||
.package(url: "https://github.com/google/swift-benchmark", from: "0.1.0"),
|
||||
.package(path: "../.."),
|
||||
.package(
|
||||
url: "https://github.com/ordo-one/package-benchmark",
|
||||
from: "1.12.0"),
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "benchmarks",
|
||||
dependencies: ["FlatBuffers",
|
||||
.product(name: "Benchmark", package: "swift-benchmark")]),
|
||||
.executableTarget(
|
||||
name: "FlatbuffersBenchmarks",
|
||||
dependencies: [
|
||||
.product(name: "FlatBuffers", package: "flatbuffers"),
|
||||
.product(name: "Benchmark", package: "package-benchmark"),
|
||||
],
|
||||
path: "Benchmarks/FlatbuffersBenchmarks",
|
||||
plugins: [
|
||||
.plugin(name: "BenchmarkPlugin", package: "package-benchmark"),
|
||||
]),
|
||||
])
|
||||
9
benchmarks/swift/README.md
Normal file
9
benchmarks/swift/README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# Benchmarks
|
||||
|
||||
To open the benchmarks in xcode use:
|
||||
|
||||
`open --env BENCHMARK_DISABLE_JEMALLOC=true Package.swift`
|
||||
|
||||
or running them directly within terminal using:
|
||||
|
||||
`swift package benchmark`
|
||||
@@ -87,6 +87,7 @@ def flatbuffer_library_public(
|
||||
optionally a Fileset([reflection_name]) with all generated reflection
|
||||
binaries.
|
||||
"""
|
||||
reflection_include_paths = include_paths
|
||||
if include_paths == None:
|
||||
include_paths = default_include_paths(flatc_path)
|
||||
include_paths_cmd = ["-I %s" % (s) for s in include_paths]
|
||||
@@ -124,13 +125,16 @@ def flatbuffer_library_public(
|
||||
**kwargs
|
||||
)
|
||||
if reflection_name:
|
||||
if reflection_include_paths == None:
|
||||
reflection_include_paths = default_include_paths(TRUE_FLATC_PATH)
|
||||
reflection_include_paths_cmd = ["-I %s" % (s) for s in reflection_include_paths]
|
||||
reflection_genrule_cmd = " ".join([
|
||||
"SRCS=($(SRCS));",
|
||||
"for f in $${SRCS[@]:0:%s}; do" % len(srcs),
|
||||
"$(location %s)" % (TRUE_FLATC_PATH),
|
||||
"-b --schema",
|
||||
" ".join(flatc_args),
|
||||
" ".join(include_paths_cmd),
|
||||
" ".join(reflection_include_paths_cmd),
|
||||
language_flag,
|
||||
output_directory,
|
||||
"$$f;",
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
# Changelog
|
||||
|
||||
## 23.5.26
|
||||
|
||||
- omit type annotationes for local variables (#7067, #7069, #7070)
|
||||
- remove BSD 3-clause license (#7073)
|
||||
- correctly parse lists of enums (#7157)
|
||||
- align naming conventions for generated code (#7187)
|
||||
- add `putBool` to fix errors when serializing structs with booleans (#7359)
|
||||
- fix handling of +/-inf defaults in codegen (#7588)
|
||||
- fix import issues in generated code (#7621)
|
||||
- Fix incorrect storage of floats as ints in some cases (#7703)
|
||||
- add final modifiers to the library implementation (#7943)
|
||||
|
||||
## 2.0.5
|
||||
|
||||
- switch to null safety (#6696)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
This package is used to read and write [FlatBuffers](https://google.github.io/flatbuffers/).
|
||||
|
||||
Most consumers will want to use the [`flatc` - FlatBuffer compiler](https://github.com/google/flatbuffers) binary for your platform.
|
||||
You can find it in the `generator/{Platform}` directory of the [released package archive](https://pub.dev/packages/flat_buffers/versions/2.0.5.tar.gz).
|
||||
You can download the flatc version matching your dart package version from [GitHub releases](https://github.com/google/flatbuffers/releases).
|
||||
|
||||
The FlatBuffer compiler `flatc` reads a FlatBuffers IDL schema and generates Dart code.
|
||||
The generated classes can be used to read or write binary data/files that are interoperable with
|
||||
@@ -13,11 +13,3 @@ examples folder.
|
||||
For more details and documentation, head over to the official site and read the
|
||||
[Tutorial](https://google.github.io/flatbuffers/flatbuffers_guide_tutorial.html) and how to
|
||||
[use FlatBuffers in Dart](https://google.github.io/flatbuffers/flatbuffers_guide_use_dart.html).
|
||||
|
||||
## Dart 2.0 notes
|
||||
Version 2.0.5 ships with it's own custom build of `flatc` because this is an extraordinary release to catch-up
|
||||
with FlatBuffers for other platforms. This generator can only generate dart code (to avoid generating code for other platforms which isn't released yet).
|
||||
On the other hand, the generated code still produces standard binary FlatBuffers compatible with other languages.
|
||||
In other words: only `flatc --dart ...` works with this generator, but your app will be able to produce and read standard binary (`Uint8List`) FlatBuffers that are fully compotible with other languages supporting FlatBuffers (e.g. Java, C++, ...).
|
||||
|
||||
In the future a common `flatc` binary for all platforms would be shipped through GitHub release page instead.
|
||||
|
||||
@@ -654,7 +654,7 @@ class Builder {
|
||||
var tail = _tail;
|
||||
_setUint32AtTail(tail, values.length);
|
||||
tail -= _sizeofUint32;
|
||||
for (var value in values) {
|
||||
for (final value in values) {
|
||||
_setInt8AtTail(tail, value);
|
||||
tail -= _sizeofUint8;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
name: flat_buffers
|
||||
version: 23.5.8
|
||||
version: 24.3.7
|
||||
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
|
||||
|
||||
environment:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
sdk: '>=2.12.0 <4.0.0'
|
||||
|
||||
dev_dependencies:
|
||||
test: ^1.17.7
|
||||
test_reflective_loader: ^0.2.0
|
||||
path: ^1.8.0
|
||||
lints: ^1.0.1
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ 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(() {
|
||||
@@ -62,92 +61,91 @@ class CheckOtherLangaugesData {
|
||||
|
||||
// this will fail if accessing any field fails.
|
||||
expect(
|
||||
mon.toString(),
|
||||
'Monster{'
|
||||
'pos: Vec3{x: 1.0, y: 2.0, z: 3.0, test1: 3.0, test2: Color{value: 2}, test3: Test{a: 5, b: 6}}, '
|
||||
'mana: 150, hp: 80, name: MyMonster, inventory: [0, 1, 2, 3, 4], '
|
||||
'color: Color{value: 8}, testType: AnyTypeId{value: 1}, '
|
||||
'test: Monster{pos: null, mana: 150, hp: 100, name: Fred, '
|
||||
'inventory: null, color: Color{value: 8}, testType: null, '
|
||||
'test: null, test4: null, testarrayofstring: null, '
|
||||
'testarrayoftables: null, enemy: null, testnestedflatbuffer: null, '
|
||||
'testempty: null, testbool: false, testhashs32Fnv1: 0, '
|
||||
'testhashu32Fnv1: 0, testhashs64Fnv1: 0, testhashu64Fnv1: 0, '
|
||||
'testhashs32Fnv1a: 0, testhashu32Fnv1a: 0, testhashs64Fnv1a: 0, '
|
||||
'testhashu64Fnv1a: 0, testarrayofbools: null, testf: 3.14159, '
|
||||
'testf2: 3.0, testf3: 0.0, testarrayofstring2: null, '
|
||||
'testarrayofsortedstruct: null, flex: null, test5: null, '
|
||||
'vectorOfLongs: null, vectorOfDoubles: null, parentNamespaceTest: null, '
|
||||
'vectorOfReferrables: null, singleWeakReference: 0, '
|
||||
'vectorOfWeakReferences: null, vectorOfStrongReferrables: null, '
|
||||
'coOwningReference: 0, vectorOfCoOwningReferences: null, '
|
||||
'nonOwningReference: 0, vectorOfNonOwningReferences: null, '
|
||||
'anyUniqueType: null, anyUnique: null, anyAmbiguousType: null, '
|
||||
'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race{value: -1}, '
|
||||
'testrequirednestedflatbuffer: null, scalarKeySortedTables: null, '
|
||||
'nativeInline: null, '
|
||||
'longEnumNonEnumDefault: LongEnum{value: 0}, '
|
||||
'longEnumNormalDefault: LongEnum{value: 2}, nanDefault: NaN, '
|
||||
'infDefault: Infinity, positiveInfDefault: Infinity, infinityDefault: '
|
||||
'Infinity, positiveInfinityDefault: Infinity, negativeInfDefault: '
|
||||
'-Infinity, negativeInfinityDefault: -Infinity, doubleInfDefault: Infinity}, '
|
||||
'test4: [Test{a: 10, b: 20}, Test{a: 30, b: 40}], '
|
||||
'testarrayofstring: [test1, test2], testarrayoftables: null, '
|
||||
'enemy: Monster{pos: null, mana: 150, hp: 100, name: Fred, '
|
||||
'inventory: null, color: Color{value: 8}, testType: null, '
|
||||
'test: null, test4: null, testarrayofstring: null, '
|
||||
'testarrayoftables: null, enemy: null, testnestedflatbuffer: null, '
|
||||
'testempty: null, testbool: false, testhashs32Fnv1: 0, '
|
||||
'testhashu32Fnv1: 0, testhashs64Fnv1: 0, testhashu64Fnv1: 0, '
|
||||
'testhashs32Fnv1a: 0, testhashu32Fnv1a: 0, testhashs64Fnv1a: 0, '
|
||||
'testhashu64Fnv1a: 0, testarrayofbools: null, testf: 3.14159, '
|
||||
'testf2: 3.0, testf3: 0.0, testarrayofstring2: null, '
|
||||
'testarrayofsortedstruct: null, flex: null, test5: null, '
|
||||
'vectorOfLongs: null, vectorOfDoubles: null, parentNamespaceTest: null, '
|
||||
'vectorOfReferrables: null, singleWeakReference: 0, '
|
||||
'vectorOfWeakReferences: null, vectorOfStrongReferrables: null, '
|
||||
'coOwningReference: 0, vectorOfCoOwningReferences: null, '
|
||||
'nonOwningReference: 0, vectorOfNonOwningReferences: null, '
|
||||
'anyUniqueType: null, anyUnique: null, anyAmbiguousType: null, '
|
||||
'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race{value: -1}, '
|
||||
'testrequirednestedflatbuffer: null, scalarKeySortedTables: null, '
|
||||
'nativeInline: null, '
|
||||
'longEnumNonEnumDefault: LongEnum{value: 0}, '
|
||||
'longEnumNormalDefault: LongEnum{value: 2}, nanDefault: NaN, '
|
||||
'infDefault: Infinity, positiveInfDefault: Infinity, infinityDefault: '
|
||||
'Infinity, positiveInfinityDefault: Infinity, negativeInfDefault: '
|
||||
'-Infinity, negativeInfinityDefault: -Infinity, doubleInfDefault: Infinity}, '
|
||||
'testnestedflatbuffer: null, testempty: null, testbool: true, '
|
||||
'testhashs32Fnv1: -579221183, testhashu32Fnv1: 3715746113, '
|
||||
'testhashs64Fnv1: 7930699090847568257, '
|
||||
'testhashu64Fnv1: 7930699090847568257, '
|
||||
'testhashs32Fnv1a: -1904106383, testhashu32Fnv1a: 2390860913, '
|
||||
'testhashs64Fnv1a: 4898026182817603057, '
|
||||
'testhashu64Fnv1a: 4898026182817603057, '
|
||||
'testarrayofbools: [true, false, true], testf: 3.14159, testf2: 3.0, '
|
||||
'testf3: 0.0, testarrayofstring2: null, testarrayofsortedstruct: ['
|
||||
'Ability{id: 0, distance: 45}, Ability{id: 1, distance: 21}, '
|
||||
'Ability{id: 5, distance: 12}], '
|
||||
'flex: null, test5: [Test{a: 10, b: 20}, Test{a: 30, b: 40}], '
|
||||
'vectorOfLongs: [1, 100, 10000, 1000000, 100000000], '
|
||||
'vectorOfDoubles: [-1.7976931348623157e+308, 0.0, 1.7976931348623157e+308], '
|
||||
'parentNamespaceTest: null, vectorOfReferrables: null, '
|
||||
'singleWeakReference: 0, vectorOfWeakReferences: null, '
|
||||
'vectorOfStrongReferrables: null, coOwningReference: 0, '
|
||||
'vectorOfCoOwningReferences: null, nonOwningReference: 0, '
|
||||
'vectorOfNonOwningReferences: null, '
|
||||
'anyUniqueType: null, anyUnique: null, '
|
||||
'anyAmbiguousType: null, '
|
||||
'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race{value: -1}, '
|
||||
'testrequirednestedflatbuffer: null, scalarKeySortedTables: [Stat{id: '
|
||||
'miss, val: 0, count: 0}, Stat{id: hit, val: 10, count: 1}], '
|
||||
'nativeInline: Test{a: 1, b: 2}, '
|
||||
'longEnumNonEnumDefault: LongEnum{value: 0}, '
|
||||
'longEnumNormalDefault: LongEnum{value: 2}, nanDefault: NaN, '
|
||||
'infDefault: Infinity, positiveInfDefault: Infinity, infinityDefault: '
|
||||
'Infinity, positiveInfinityDefault: Infinity, negativeInfDefault: '
|
||||
'-Infinity, negativeInfinityDefault: -Infinity, doubleInfDefault: Infinity}'
|
||||
);
|
||||
mon.toString(),
|
||||
'Monster{'
|
||||
'pos: Vec3{x: 1.0, y: 2.0, z: 3.0, test1: 3.0, test2: Color{value: 2}, test3: Test{a: 5, b: 6}}, '
|
||||
'mana: 150, hp: 80, name: MyMonster, inventory: [0, 1, 2, 3, 4], '
|
||||
'color: Color{value: 8}, testType: AnyTypeId{value: 1}, '
|
||||
'test: Monster{pos: null, mana: 150, hp: 100, name: Fred, '
|
||||
'inventory: null, color: Color{value: 8}, testType: null, '
|
||||
'test: null, test4: null, testarrayofstring: null, '
|
||||
'testarrayoftables: null, enemy: null, testnestedflatbuffer: null, '
|
||||
'testempty: null, testbool: false, testhashs32Fnv1: 0, '
|
||||
'testhashu32Fnv1: 0, testhashs64Fnv1: 0, testhashu64Fnv1: 0, '
|
||||
'testhashs32Fnv1a: 0, testhashu32Fnv1a: 0, testhashs64Fnv1a: 0, '
|
||||
'testhashu64Fnv1a: 0, testarrayofbools: null, testf: 3.14159, '
|
||||
'testf2: 3.0, testf3: 0.0, testarrayofstring2: null, '
|
||||
'testarrayofsortedstruct: null, flex: null, test5: null, '
|
||||
'vectorOfLongs: null, vectorOfDoubles: null, parentNamespaceTest: null, '
|
||||
'vectorOfReferrables: null, singleWeakReference: 0, '
|
||||
'vectorOfWeakReferences: null, vectorOfStrongReferrables: null, '
|
||||
'coOwningReference: 0, vectorOfCoOwningReferences: null, '
|
||||
'nonOwningReference: 0, vectorOfNonOwningReferences: null, '
|
||||
'anyUniqueType: null, anyUnique: null, anyAmbiguousType: null, '
|
||||
'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race{value: -1}, '
|
||||
'testrequirednestedflatbuffer: null, scalarKeySortedTables: null, '
|
||||
'nativeInline: null, '
|
||||
'longEnumNonEnumDefault: LongEnum{value: 0}, '
|
||||
'longEnumNormalDefault: LongEnum{value: 2}, nanDefault: NaN, '
|
||||
'infDefault: Infinity, positiveInfDefault: Infinity, infinityDefault: '
|
||||
'Infinity, positiveInfinityDefault: Infinity, negativeInfDefault: '
|
||||
'-Infinity, negativeInfinityDefault: -Infinity, doubleInfDefault: Infinity}, '
|
||||
'test4: [Test{a: 10, b: 20}, Test{a: 30, b: 40}], '
|
||||
'testarrayofstring: [test1, test2], testarrayoftables: null, '
|
||||
'enemy: Monster{pos: null, mana: 150, hp: 100, name: Fred, '
|
||||
'inventory: null, color: Color{value: 8}, testType: null, '
|
||||
'test: null, test4: null, testarrayofstring: null, '
|
||||
'testarrayoftables: null, enemy: null, testnestedflatbuffer: null, '
|
||||
'testempty: null, testbool: false, testhashs32Fnv1: 0, '
|
||||
'testhashu32Fnv1: 0, testhashs64Fnv1: 0, testhashu64Fnv1: 0, '
|
||||
'testhashs32Fnv1a: 0, testhashu32Fnv1a: 0, testhashs64Fnv1a: 0, '
|
||||
'testhashu64Fnv1a: 0, testarrayofbools: null, testf: 3.14159, '
|
||||
'testf2: 3.0, testf3: 0.0, testarrayofstring2: null, '
|
||||
'testarrayofsortedstruct: null, flex: null, test5: null, '
|
||||
'vectorOfLongs: null, vectorOfDoubles: null, parentNamespaceTest: null, '
|
||||
'vectorOfReferrables: null, singleWeakReference: 0, '
|
||||
'vectorOfWeakReferences: null, vectorOfStrongReferrables: null, '
|
||||
'coOwningReference: 0, vectorOfCoOwningReferences: null, '
|
||||
'nonOwningReference: 0, vectorOfNonOwningReferences: null, '
|
||||
'anyUniqueType: null, anyUnique: null, anyAmbiguousType: null, '
|
||||
'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race{value: -1}, '
|
||||
'testrequirednestedflatbuffer: null, scalarKeySortedTables: null, '
|
||||
'nativeInline: null, '
|
||||
'longEnumNonEnumDefault: LongEnum{value: 0}, '
|
||||
'longEnumNormalDefault: LongEnum{value: 2}, nanDefault: NaN, '
|
||||
'infDefault: Infinity, positiveInfDefault: Infinity, infinityDefault: '
|
||||
'Infinity, positiveInfinityDefault: Infinity, negativeInfDefault: '
|
||||
'-Infinity, negativeInfinityDefault: -Infinity, doubleInfDefault: Infinity}, '
|
||||
'testnestedflatbuffer: null, testempty: null, testbool: true, '
|
||||
'testhashs32Fnv1: -579221183, testhashu32Fnv1: 3715746113, '
|
||||
'testhashs64Fnv1: 7930699090847568257, '
|
||||
'testhashu64Fnv1: 7930699090847568257, '
|
||||
'testhashs32Fnv1a: -1904106383, testhashu32Fnv1a: 2390860913, '
|
||||
'testhashs64Fnv1a: 4898026182817603057, '
|
||||
'testhashu64Fnv1a: 4898026182817603057, '
|
||||
'testarrayofbools: [true, false, true], testf: 3.14159, testf2: 3.0, '
|
||||
'testf3: 0.0, testarrayofstring2: null, testarrayofsortedstruct: ['
|
||||
'Ability{id: 0, distance: 45}, Ability{id: 1, distance: 21}, '
|
||||
'Ability{id: 5, distance: 12}], '
|
||||
'flex: null, test5: [Test{a: 10, b: 20}, Test{a: 30, b: 40}], '
|
||||
'vectorOfLongs: [1, 100, 10000, 1000000, 100000000], '
|
||||
'vectorOfDoubles: [-1.7976931348623157e+308, 0.0, 1.7976931348623157e+308], '
|
||||
'parentNamespaceTest: null, vectorOfReferrables: null, '
|
||||
'singleWeakReference: 0, vectorOfWeakReferences: null, '
|
||||
'vectorOfStrongReferrables: null, coOwningReference: 0, '
|
||||
'vectorOfCoOwningReferences: null, nonOwningReference: 0, '
|
||||
'vectorOfNonOwningReferences: null, '
|
||||
'anyUniqueType: null, anyUnique: null, '
|
||||
'anyAmbiguousType: null, '
|
||||
'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race{value: -1}, '
|
||||
'testrequirednestedflatbuffer: null, scalarKeySortedTables: [Stat{id: '
|
||||
'miss, val: 0, count: 0}, Stat{id: hit, val: 10, count: 1}], '
|
||||
'nativeInline: Test{a: 1, b: 2}, '
|
||||
'longEnumNonEnumDefault: LongEnum{value: 0}, '
|
||||
'longEnumNormalDefault: LongEnum{value: 2}, nanDefault: NaN, '
|
||||
'infDefault: Infinity, positiveInfDefault: Infinity, infinityDefault: '
|
||||
'Infinity, positiveInfinityDefault: Infinity, negativeInfDefault: '
|
||||
'-Infinity, negativeInfinityDefault: -Infinity, doubleInfDefault: Infinity}');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -769,7 +767,6 @@ class BuilderTest {
|
||||
class ObjectAPITest {
|
||||
void test_tableStat() {
|
||||
final object1 = example.StatT(count: 3, id: "foo", val: 4);
|
||||
expect(object1 is Packable, isTrue);
|
||||
final fbb = Builder();
|
||||
fbb.finish(object1.pack(fbb));
|
||||
final object2 = example.Stat(fbb.buffer).unpack();
|
||||
|
||||
@@ -59,8 +59,6 @@ struct Vec3 (force_align: 8) {
|
||||
test3:Test;
|
||||
}
|
||||
|
||||
// Stats for monster
|
||||
|
||||
struct Ability {
|
||||
id:uint(key);
|
||||
distance:uint;
|
||||
|
||||
@@ -23,31 +23,35 @@ For any schema input files, one or more generators can be specified:
|
||||
|
||||
- `--java`, `-j` : Generate Java code.
|
||||
|
||||
- `--kotlin`, `-k` : Generate Kotlin code.
|
||||
- `--kotlin` , `--kotlin-kmp` : Generate Kotlin code.
|
||||
|
||||
- `--csharp`, `-n` : Generate C# code.
|
||||
|
||||
- `--go`, `-g` : Generate Go code.
|
||||
|
||||
- `--python`, `-p`: Generate Python code.
|
||||
- `--python`, `-p` : Generate Python code.
|
||||
|
||||
- `--js`, `-s`: Generate JavaScript code.
|
||||
- `--js`, `-s` : Generate JavaScript code.
|
||||
|
||||
- `--ts`: Generate TypeScript code.
|
||||
- `--ts`, `-T` : Generate TypeScript code.
|
||||
|
||||
- `--php`: Generate PHP code.
|
||||
- `--php` : Generate PHP code.
|
||||
|
||||
- `--grpc`: Generate RPC stub code for GRPC.
|
||||
- `--grpc` : Generate RPC stub code for GRPC.
|
||||
|
||||
- `--dart`: Generate Dart code.
|
||||
- `--dart`, `-d` : Generate Dart code.
|
||||
|
||||
- `--lua`: Generate Lua code.
|
||||
- `--lua`, `-l` : Generate Lua code.
|
||||
|
||||
- `--lobster`: Generate Lobster code.
|
||||
- `--lobster` : Generate Lobster code.
|
||||
|
||||
- `--rust`, `-r` : Generate Rust code.
|
||||
|
||||
- `--swift`: Generate Swift code.
|
||||
- `--swift` : Generate Swift code.
|
||||
|
||||
- `--nim` : Generate Nim code.
|
||||
|
||||
|
||||
|
||||
For any data input files:
|
||||
|
||||
@@ -58,6 +62,8 @@ For any data input files:
|
||||
- `--json`, `-t` : If data is contained in this file, generate a
|
||||
`filename.json` representing the data in the flatbuffer.
|
||||
|
||||
- `--jsonschema` : Generate Json schema
|
||||
|
||||
Additional options:
|
||||
|
||||
- `-o PATH` : Output all generated files to PATH (either absolute, or
|
||||
@@ -115,7 +121,7 @@ Additional options:
|
||||
|
||||
- `--gen-compare` : Generate operator== for object-based API types.
|
||||
|
||||
- `--gen-nullable` : Add Clang _Nullable for C++ pointer. or @Nullable for Java.
|
||||
- `--gen-nullable` : Add Clang \_Nullable for C++ pointer. or @Nullable for Java.
|
||||
|
||||
- `--gen-generated` : Add @Generated annotation for Java.
|
||||
|
||||
@@ -189,7 +195,7 @@ Additional options:
|
||||
`--conform PATH`.
|
||||
|
||||
- `--filename-suffix SUFFIX` : The suffix appended to the generated
|
||||
file names. Default is '_generated'.
|
||||
file names. Default is '\_generated'.
|
||||
|
||||
- `--filename-ext EXTENSION` : The extension appended to the generated
|
||||
file names. Default is language-specific (e.g. "h" for C++). This
|
||||
@@ -227,5 +233,10 @@ Additional options:
|
||||
vector of bytes in JSON, which is unsafe unless checked by a verifier
|
||||
afterwards.
|
||||
|
||||
- `--python-no-type-prefix-suffix` : Skip emission of Python functions that are prefixed
|
||||
with typenames
|
||||
|
||||
- `--python-typing` : Generate Python type annotations
|
||||
|
||||
NOTE: short-form options for generators are deprecated, use the long form
|
||||
whenever possible.
|
||||
|
||||
@@ -24,17 +24,14 @@ FlatBuffers).
|
||||
## Building the FlatBuffers C# library
|
||||
|
||||
The `FlatBuffers.csproj` project contains multitargeting for .NET Standard 2.1,
|
||||
.NET Standard 2.0, and .NET Framework 4.6 (Unity 2017). Support for .NET
|
||||
Framework 3.5 (Unity 5) is provided by the `FlatBuffers.net35.csproj` project.
|
||||
In most cases (including Unity 2018 and newer), .NET Standard 2.0 is
|
||||
recommended.
|
||||
.NET 6 and .NET 8.
|
||||
|
||||
You can build for a specific framework target when using the cross-platform
|
||||
[.NET Core SDK](https://dotnet.microsoft.com/download) by adding the `-f`
|
||||
command line option:
|
||||
|
||||
~~~{.sh}
|
||||
dotnet build -f netstandard2.0 "FlatBuffers.csproj"
|
||||
dotnet build -f netstandard2.1 "FlatBuffers.csproj"
|
||||
~~~
|
||||
|
||||
The `FlatBuffers.csproj` project also provides support for defining various
|
||||
@@ -142,10 +139,10 @@ To use it:
|
||||
`ByKey` only works if the vector has been sorted, it will
|
||||
likely not find elements if it hasn't been sorted.
|
||||
|
||||
## Buffer verification
|
||||
## Buffer verification
|
||||
|
||||
As mentioned in [C++ Usage](@ref flatbuffers_guide_use_cpp) buffer
|
||||
accessor functions do not verify buffer offsets at run-time.
|
||||
accessor functions do not verify buffer offsets at run-time.
|
||||
If it is necessary, you can optionally use a buffer verifier before you
|
||||
access the data. This verifier will check all offsets, all sizes of
|
||||
fields, and null termination of strings to ensure that when a buffer
|
||||
@@ -158,17 +155,17 @@ e.g. `Monster.VerifyMonster`. This can be called as shown:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
if `ok` is true, the buffer is safe to read.
|
||||
|
||||
For a more detailed control of verification `MonsterVerify.Verify`
|
||||
for `Monster` type can be used:
|
||||
For a more detailed control of verification `MonsterVerify.Verify`
|
||||
for `Monster` type can be used:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cs}
|
||||
# Sequence of calls
|
||||
FlatBuffers.Verifier verifier = new FlatBuffers.Verifier(buf);
|
||||
var ok = verifier.VerifyBuffer("MONS", false, MonsterVerify.Verify);
|
||||
|
||||
# Or single line call
|
||||
|
||||
# Or single line call
|
||||
var ok = new FlatBuffers.Verifier(bb).setStringCheck(true).\
|
||||
VerifyBuffer("MONS", false, MonsterVerify.Verify);
|
||||
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
if `ok` is true, the buffer is safe to read.
|
||||
|
||||
@@ -181,7 +178,7 @@ Verifier supports options that can be set using appropriate fluent methods:
|
||||
* SetMaxTables - total amount of tables the verifier may encounter. Default: 64
|
||||
* SetAlignmentCheck - check content alignment. Default: True
|
||||
* SetStringCheck - check if strings contain termination '0' character. Default: true
|
||||
|
||||
|
||||
|
||||
## Text parsing
|
||||
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
|
||||
#ifndef FLATBUFFERS_GENERATED_BASIC_H_
|
||||
#define FLATBUFFERS_GENERATED_BASIC_H_
|
||||
#ifndef FLATBUFFERS_GENERATED_BASIC_FLATBUFFERS_GOLDENS_H_
|
||||
#define FLATBUFFERS_GENERATED_BASIC_FLATBUFFERS_GOLDENS_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 == 23 &&
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 24 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 3 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 3,
|
||||
FLATBUFFERS_VERSION_REVISION == 7,
|
||||
"Non-compatible flatbuffers version included");
|
||||
|
||||
namespace flatbuffers {
|
||||
namespace goldens {
|
||||
|
||||
struct Galaxy;
|
||||
struct GalaxyBuilder;
|
||||
|
||||
@@ -69,8 +72,8 @@ struct Universe FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
double age() const {
|
||||
return GetField<double>(VT_AGE, 0.0);
|
||||
}
|
||||
const ::flatbuffers::Vector<::flatbuffers::Offset<Galaxy>> *galaxies() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<Galaxy>> *>(VT_GALAXIES);
|
||||
const ::flatbuffers::Vector<::flatbuffers::Offset<flatbuffers::goldens::Galaxy>> *galaxies() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<flatbuffers::goldens::Galaxy>> *>(VT_GALAXIES);
|
||||
}
|
||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
@@ -89,7 +92,7 @@ struct UniverseBuilder {
|
||||
void add_age(double age) {
|
||||
fbb_.AddElement<double>(Universe::VT_AGE, age, 0.0);
|
||||
}
|
||||
void add_galaxies(::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<Galaxy>>> galaxies) {
|
||||
void add_galaxies(::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<flatbuffers::goldens::Galaxy>>> galaxies) {
|
||||
fbb_.AddOffset(Universe::VT_GALAXIES, galaxies);
|
||||
}
|
||||
explicit UniverseBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
@@ -106,7 +109,7 @@ struct UniverseBuilder {
|
||||
inline ::flatbuffers::Offset<Universe> CreateUniverse(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
double age = 0.0,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<Galaxy>>> galaxies = 0) {
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<flatbuffers::goldens::Galaxy>>> galaxies = 0) {
|
||||
UniverseBuilder builder_(_fbb);
|
||||
builder_.add_age(age);
|
||||
builder_.add_galaxies(galaxies);
|
||||
@@ -116,42 +119,45 @@ inline ::flatbuffers::Offset<Universe> CreateUniverse(
|
||||
inline ::flatbuffers::Offset<Universe> CreateUniverseDirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
double age = 0.0,
|
||||
const std::vector<::flatbuffers::Offset<Galaxy>> *galaxies = nullptr) {
|
||||
auto galaxies__ = galaxies ? _fbb.CreateVector<::flatbuffers::Offset<Galaxy>>(*galaxies) : 0;
|
||||
return CreateUniverse(
|
||||
const std::vector<::flatbuffers::Offset<flatbuffers::goldens::Galaxy>> *galaxies = nullptr) {
|
||||
auto galaxies__ = galaxies ? _fbb.CreateVector<::flatbuffers::Offset<flatbuffers::goldens::Galaxy>>(*galaxies) : 0;
|
||||
return flatbuffers::goldens::CreateUniverse(
|
||||
_fbb,
|
||||
age,
|
||||
galaxies__);
|
||||
}
|
||||
|
||||
inline const Universe *GetUniverse(const void *buf) {
|
||||
return ::flatbuffers::GetRoot<Universe>(buf);
|
||||
inline const flatbuffers::goldens::Universe *GetUniverse(const void *buf) {
|
||||
return ::flatbuffers::GetRoot<flatbuffers::goldens::Universe>(buf);
|
||||
}
|
||||
|
||||
inline const Universe *GetSizePrefixedUniverse(const void *buf) {
|
||||
return ::flatbuffers::GetSizePrefixedRoot<Universe>(buf);
|
||||
inline const flatbuffers::goldens::Universe *GetSizePrefixedUniverse(const void *buf) {
|
||||
return ::flatbuffers::GetSizePrefixedRoot<flatbuffers::goldens::Universe>(buf);
|
||||
}
|
||||
|
||||
inline bool VerifyUniverseBuffer(
|
||||
::flatbuffers::Verifier &verifier) {
|
||||
return verifier.VerifyBuffer<Universe>(nullptr);
|
||||
return verifier.VerifyBuffer<flatbuffers::goldens::Universe>(nullptr);
|
||||
}
|
||||
|
||||
inline bool VerifySizePrefixedUniverseBuffer(
|
||||
::flatbuffers::Verifier &verifier) {
|
||||
return verifier.VerifySizePrefixedBuffer<Universe>(nullptr);
|
||||
return verifier.VerifySizePrefixedBuffer<flatbuffers::goldens::Universe>(nullptr);
|
||||
}
|
||||
|
||||
inline void FinishUniverseBuffer(
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<Universe> root) {
|
||||
::flatbuffers::Offset<flatbuffers::goldens::Universe> root) {
|
||||
fbb.Finish(root);
|
||||
}
|
||||
|
||||
inline void FinishSizePrefixedUniverseBuffer(
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<Universe> root) {
|
||||
::flatbuffers::Offset<flatbuffers::goldens::Universe> root) {
|
||||
fbb.FinishSizePrefixed(root);
|
||||
}
|
||||
|
||||
#endif // FLATBUFFERS_GENERATED_BASIC_H_
|
||||
} // namespace goldens
|
||||
} // namespace flatbuffers
|
||||
|
||||
#endif // FLATBUFFERS_GENERATED_BASIC_FLATBUFFERS_GOLDENS_H_
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// </auto-generated>
|
||||
|
||||
namespace flatbuffers.goldens
|
||||
{
|
||||
|
||||
using global::System;
|
||||
using global::System.Collections.Generic;
|
||||
using global::Google.FlatBuffers;
|
||||
@@ -10,7 +13,7 @@ public struct Galaxy : IFlatbufferObject
|
||||
{
|
||||
private Table __p;
|
||||
public ByteBuffer ByteBuffer { get { return __p.bb; } }
|
||||
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_23_5_8(); }
|
||||
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_24_3_7(); }
|
||||
public static Galaxy GetRootAsGalaxy(ByteBuffer _bb) { return GetRootAsGalaxy(_bb, new Galaxy()); }
|
||||
public static Galaxy GetRootAsGalaxy(ByteBuffer _bb, Galaxy obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
|
||||
public void __init(int _i, ByteBuffer _bb) { __p = new Table(_i, _bb); }
|
||||
@@ -18,7 +21,7 @@ public struct Galaxy : IFlatbufferObject
|
||||
|
||||
public long NumStars { get { int o = __p.__offset(4); return o != 0 ? __p.bb.GetLong(o + __p.bb_pos) : (long)0; } }
|
||||
|
||||
public static Offset<Galaxy> CreateGalaxy(FlatBufferBuilder builder,
|
||||
public static Offset<flatbuffers.goldens.Galaxy> CreateGalaxy(FlatBufferBuilder builder,
|
||||
long num_stars = 0) {
|
||||
builder.StartTable(1);
|
||||
Galaxy.AddNumStars(builder, num_stars);
|
||||
@@ -27,9 +30,9 @@ public struct Galaxy : IFlatbufferObject
|
||||
|
||||
public static void StartGalaxy(FlatBufferBuilder builder) { builder.StartTable(1); }
|
||||
public static void AddNumStars(FlatBufferBuilder builder, long numStars) { builder.AddLong(0, numStars, 0); }
|
||||
public static Offset<Galaxy> EndGalaxy(FlatBufferBuilder builder) {
|
||||
public static Offset<flatbuffers.goldens.Galaxy> EndGalaxy(FlatBufferBuilder builder) {
|
||||
int o = builder.EndTable();
|
||||
return new Offset<Galaxy>(o);
|
||||
return new Offset<flatbuffers.goldens.Galaxy>(o);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,3 +46,5 @@ static public class GalaxyVerify
|
||||
&& verifier.VerifyTableEnd(tablePos);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,9 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// </auto-generated>
|
||||
|
||||
namespace flatbuffers.goldens
|
||||
{
|
||||
|
||||
using global::System;
|
||||
using global::System.Collections.Generic;
|
||||
using global::Google.FlatBuffers;
|
||||
@@ -10,7 +13,7 @@ public struct Universe : IFlatbufferObject
|
||||
{
|
||||
private Table __p;
|
||||
public ByteBuffer ByteBuffer { get { return __p.bb; } }
|
||||
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_23_5_8(); }
|
||||
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_24_3_7(); }
|
||||
public static Universe GetRootAsUniverse(ByteBuffer _bb) { return GetRootAsUniverse(_bb, new Universe()); }
|
||||
public static Universe GetRootAsUniverse(ByteBuffer _bb, Universe obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
|
||||
public static bool VerifyUniverse(ByteBuffer _bb) {Google.FlatBuffers.Verifier verifier = new Google.FlatBuffers.Verifier(_bb); return verifier.VerifyBuffer("", false, UniverseVerify.Verify); }
|
||||
@@ -18,10 +21,10 @@ public struct Universe : IFlatbufferObject
|
||||
public Universe __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
public double Age { get { int o = __p.__offset(4); return o != 0 ? __p.bb.GetDouble(o + __p.bb_pos) : (double)0.0; } }
|
||||
public Galaxy? Galaxies(int j) { int o = __p.__offset(6); return o != 0 ? (Galaxy?)(new Galaxy()).__assign(__p.__indirect(__p.__vector(o) + j * 4), __p.bb) : null; }
|
||||
public flatbuffers.goldens.Galaxy? Galaxies(int j) { int o = __p.__offset(6); return o != 0 ? (flatbuffers.goldens.Galaxy?)(new flatbuffers.goldens.Galaxy()).__assign(__p.__indirect(__p.__vector(o) + j * 4), __p.bb) : null; }
|
||||
public int GalaxiesLength { get { int o = __p.__offset(6); return o != 0 ? __p.__vector_len(o) : 0; } }
|
||||
|
||||
public static Offset<Universe> CreateUniverse(FlatBufferBuilder builder,
|
||||
public static Offset<flatbuffers.goldens.Universe> CreateUniverse(FlatBufferBuilder builder,
|
||||
double age = 0.0,
|
||||
VectorOffset galaxiesOffset = default(VectorOffset)) {
|
||||
builder.StartTable(2);
|
||||
@@ -33,17 +36,17 @@ public struct Universe : IFlatbufferObject
|
||||
public static void StartUniverse(FlatBufferBuilder builder) { builder.StartTable(2); }
|
||||
public static void AddAge(FlatBufferBuilder builder, double age) { builder.AddDouble(0, age, 0.0); }
|
||||
public static void AddGalaxies(FlatBufferBuilder builder, VectorOffset galaxiesOffset) { builder.AddOffset(1, galaxiesOffset.Value, 0); }
|
||||
public static VectorOffset CreateGalaxiesVector(FlatBufferBuilder builder, Offset<Galaxy>[] 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 CreateGalaxiesVectorBlock(FlatBufferBuilder builder, Offset<Galaxy>[] data) { builder.StartVector(4, data.Length, 4); builder.Add(data); return builder.EndVector(); }
|
||||
public static VectorOffset CreateGalaxiesVectorBlock(FlatBufferBuilder builder, ArraySegment<Offset<Galaxy>> data) { builder.StartVector(4, data.Count, 4); builder.Add(data); return builder.EndVector(); }
|
||||
public static VectorOffset CreateGalaxiesVectorBlock(FlatBufferBuilder builder, IntPtr dataPtr, int sizeInBytes) { builder.StartVector(1, sizeInBytes, 1); builder.Add<Offset<Galaxy>>(dataPtr, sizeInBytes); return builder.EndVector(); }
|
||||
public static VectorOffset CreateGalaxiesVector(FlatBufferBuilder builder, Offset<flatbuffers.goldens.Galaxy>[] 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 CreateGalaxiesVectorBlock(FlatBufferBuilder builder, Offset<flatbuffers.goldens.Galaxy>[] data) { builder.StartVector(4, data.Length, 4); builder.Add(data); return builder.EndVector(); }
|
||||
public static VectorOffset CreateGalaxiesVectorBlock(FlatBufferBuilder builder, ArraySegment<Offset<flatbuffers.goldens.Galaxy>> data) { builder.StartVector(4, data.Count, 4); builder.Add(data); return builder.EndVector(); }
|
||||
public static VectorOffset CreateGalaxiesVectorBlock(FlatBufferBuilder builder, IntPtr dataPtr, int sizeInBytes) { builder.StartVector(1, sizeInBytes, 1); builder.Add<Offset<flatbuffers.goldens.Galaxy>>(dataPtr, sizeInBytes); return builder.EndVector(); }
|
||||
public static void StartGalaxiesVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
|
||||
public static Offset<Universe> EndUniverse(FlatBufferBuilder builder) {
|
||||
public static Offset<flatbuffers.goldens.Universe> EndUniverse(FlatBufferBuilder builder) {
|
||||
int o = builder.EndTable();
|
||||
return new Offset<Universe>(o);
|
||||
return new Offset<flatbuffers.goldens.Universe>(o);
|
||||
}
|
||||
public static void FinishUniverseBuffer(FlatBufferBuilder builder, Offset<Universe> offset) { builder.Finish(offset.Value); }
|
||||
public static void FinishSizePrefixedUniverseBuffer(FlatBufferBuilder builder, Offset<Universe> offset) { builder.FinishSizePrefixed(offset.Value); }
|
||||
public static void FinishUniverseBuffer(FlatBufferBuilder builder, Offset<flatbuffers.goldens.Universe> offset) { builder.Finish(offset.Value); }
|
||||
public static void FinishSizePrefixedUniverseBuffer(FlatBufferBuilder builder, Offset<flatbuffers.goldens.Universe> offset) { builder.FinishSizePrefixed(offset.Value); }
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +56,9 @@ static public class UniverseVerify
|
||||
{
|
||||
return verifier.VerifyTableStart(tablePos)
|
||||
&& verifier.VerifyField(tablePos, 4 /*Age*/, 8 /*double*/, 8, false)
|
||||
&& verifier.VerifyVectorOfTables(tablePos, 6 /*Galaxies*/, GalaxyVerify.Verify, false)
|
||||
&& verifier.VerifyVectorOfTables(tablePos, 6 /*Galaxies*/, flatbuffers.goldens.GalaxyVerify.Verify, false)
|
||||
&& verifier.VerifyTableEnd(tablePos);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable
|
||||
|
||||
library flatbuffers.goldens;
|
||||
|
||||
import 'dart:typed_data' show Uint8List;
|
||||
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||
|
||||
@@ -23,9 +23,8 @@ GenerateGo()
|
||||
GenerateJava()
|
||||
GenerateKotlin()
|
||||
GenerateLobster()
|
||||
# TODO these doesn't respect the output prefix, fix and reenable
|
||||
# GenerateLua()
|
||||
# GenerateNim()
|
||||
GenerateLua()
|
||||
GenerateNim()
|
||||
GeneratePhp()
|
||||
GeneratePython()
|
||||
GenerateRust()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by the FlatBuffers compiler. DO NOT EDIT.
|
||||
|
||||
package Galaxy
|
||||
package goldens
|
||||
|
||||
import (
|
||||
flatbuffers "github.com/google/flatbuffers/go"
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by the FlatBuffers compiler. DO NOT EDIT.
|
||||
|
||||
package Universe
|
||||
package goldens
|
||||
|
||||
import (
|
||||
flatbuffers "github.com/google/flatbuffers/go"
|
||||
@@ -1,5 +1,7 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package flatbuffers.goldens;
|
||||
|
||||
import com.google.flatbuffers.BaseVector;
|
||||
import com.google.flatbuffers.BooleanVector;
|
||||
import com.google.flatbuffers.ByteVector;
|
||||
@@ -19,7 +21,7 @@ import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class Galaxy extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_8(); }
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_7(); }
|
||||
public static Galaxy getRootAsGalaxy(ByteBuffer _bb) { return getRootAsGalaxy(_bb, new Galaxy()); }
|
||||
public static Galaxy getRootAsGalaxy(ByteBuffer _bb, Galaxy 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); }
|
||||
@@ -1,5 +1,7 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package flatbuffers.goldens;
|
||||
|
||||
import com.google.flatbuffers.BaseVector;
|
||||
import com.google.flatbuffers.BooleanVector;
|
||||
import com.google.flatbuffers.ByteVector;
|
||||
@@ -19,18 +21,18 @@ import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class Universe extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_8(); }
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_7(); }
|
||||
public static Universe getRootAsUniverse(ByteBuffer _bb) { return getRootAsUniverse(_bb, new Universe()); }
|
||||
public static Universe getRootAsUniverse(ByteBuffer _bb, Universe 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 Universe __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
public double age() { int o = __offset(4); return o != 0 ? bb.getDouble(o + bb_pos) : 0.0; }
|
||||
public Galaxy galaxies(int j) { return galaxies(new Galaxy(), j); }
|
||||
public Galaxy galaxies(Galaxy obj, int j) { int o = __offset(6); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public flatbuffers.goldens.Galaxy galaxies(int j) { return galaxies(new flatbuffers.goldens.Galaxy(), j); }
|
||||
public flatbuffers.goldens.Galaxy galaxies(flatbuffers.goldens.Galaxy obj, int j) { int o = __offset(6); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int galaxiesLength() { int o = __offset(6); return o != 0 ? __vector_len(o) : 0; }
|
||||
public Galaxy.Vector galaxiesVector() { return galaxiesVector(new Galaxy.Vector()); }
|
||||
public Galaxy.Vector galaxiesVector(Galaxy.Vector obj) { int o = __offset(6); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public flatbuffers.goldens.Galaxy.Vector galaxiesVector() { return galaxiesVector(new flatbuffers.goldens.Galaxy.Vector()); }
|
||||
public flatbuffers.goldens.Galaxy.Vector galaxiesVector(flatbuffers.goldens.Galaxy.Vector obj) { int o = __offset(6); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
|
||||
public static int createUniverse(FlatBufferBuilder builder,
|
||||
double age,
|
||||
@@ -1,5 +1,7 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package flatbuffers.goldens
|
||||
|
||||
import com.google.flatbuffers.BaseVector
|
||||
import com.google.flatbuffers.BooleanVector
|
||||
import com.google.flatbuffers.ByteVector
|
||||
@@ -32,7 +34,7 @@ class Galaxy : Table() {
|
||||
return if(o != 0) bb.getLong(o + bb_pos) else 0L
|
||||
}
|
||||
companion object {
|
||||
fun validateVersion() = Constants.FLATBUFFERS_23_5_8()
|
||||
fun validateVersion() = Constants.FLATBUFFERS_24_3_7()
|
||||
fun getRootAsGalaxy(_bb: ByteBuffer): Galaxy = getRootAsGalaxy(_bb, Galaxy())
|
||||
fun getRootAsGalaxy(_bb: ByteBuffer, obj: Galaxy): Galaxy {
|
||||
_bb.order(ByteOrder.LITTLE_ENDIAN)
|
||||
@@ -1,5 +1,7 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package flatbuffers.goldens
|
||||
|
||||
import com.google.flatbuffers.BaseVector
|
||||
import com.google.flatbuffers.BooleanVector
|
||||
import com.google.flatbuffers.ByteVector
|
||||
@@ -31,8 +33,8 @@ class Universe : Table() {
|
||||
val o = __offset(4)
|
||||
return if(o != 0) bb.getDouble(o + bb_pos) else 0.0
|
||||
}
|
||||
fun galaxies(j: Int) : Galaxy? = galaxies(Galaxy(), j)
|
||||
fun galaxies(obj: Galaxy, j: Int) : Galaxy? {
|
||||
fun galaxies(j: Int) : flatbuffers.goldens.Galaxy? = galaxies(flatbuffers.goldens.Galaxy(), j)
|
||||
fun galaxies(obj: flatbuffers.goldens.Galaxy, j: Int) : flatbuffers.goldens.Galaxy? {
|
||||
val o = __offset(6)
|
||||
return if (o != 0) {
|
||||
obj.__assign(__indirect(__vector(o) + j * 4), bb)
|
||||
@@ -45,7 +47,7 @@ class Universe : Table() {
|
||||
val o = __offset(6); return if (o != 0) __vector_len(o) else 0
|
||||
}
|
||||
companion object {
|
||||
fun validateVersion() = Constants.FLATBUFFERS_23_5_8()
|
||||
fun validateVersion() = Constants.FLATBUFFERS_24_3_7()
|
||||
fun getRootAsUniverse(_bb: ByteBuffer): Universe = getRootAsUniverse(_bb, Universe())
|
||||
fun getRootAsUniverse(_bb: ByteBuffer, obj: Universe): Universe {
|
||||
_bb.order(ByteOrder.LITTLE_ENDIAN)
|
||||
@@ -1,18 +1,20 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
import flatbuffers
|
||||
|
||||
namespace flatbuffers.goldens
|
||||
|
||||
class Galaxy
|
||||
|
||||
class Universe
|
||||
|
||||
class Galaxy : flatbuffers_handle
|
||||
class Galaxy : flatbuffers.handle
|
||||
def num_stars() -> int:
|
||||
return buf_.flatbuffers_field_int64(pos_, 4, 0)
|
||||
return flatbuffers.field_int64(buf_, pos_, 4, 0)
|
||||
|
||||
def GetRootAsGalaxy(buf:string): return Galaxy { buf, buf.flatbuffers_indirect(0) }
|
||||
def GetRootAsGalaxy(buf:string): return Galaxy { buf, flatbuffers.indirect(buf, 0) }
|
||||
|
||||
struct GalaxyBuilder:
|
||||
b_:flatbuffers_builder
|
||||
b_:flatbuffers.builder
|
||||
def start():
|
||||
b_.StartObject(1)
|
||||
return this
|
||||
@@ -22,33 +24,33 @@ struct GalaxyBuilder:
|
||||
def end():
|
||||
return b_.EndObject()
|
||||
|
||||
class Universe : flatbuffers_handle
|
||||
class Universe : flatbuffers.handle
|
||||
def age() -> float:
|
||||
return buf_.flatbuffers_field_float64(pos_, 4, 0.0)
|
||||
def galaxies(i:int) -> Galaxy:
|
||||
return Galaxy { buf_, buf_.flatbuffers_indirect(buf_.flatbuffers_field_vector(pos_, 6) + i * 4) }
|
||||
return flatbuffers.field_float64(buf_, pos_, 4, 0.0)
|
||||
def galaxies(i:int) -> flatbuffers.goldens.Galaxy:
|
||||
return flatbuffers.goldens.Galaxy { buf_, flatbuffers.indirect(buf_, flatbuffers.field_vector(buf_, pos_, 6) + i * 4) }
|
||||
def galaxies_length() -> int:
|
||||
return buf_.flatbuffers_field_vector_len(pos_, 6)
|
||||
return flatbuffers.field_vector_len(buf_, pos_, 6)
|
||||
|
||||
def GetRootAsUniverse(buf:string): return Universe { buf, buf.flatbuffers_indirect(0) }
|
||||
def GetRootAsUniverse(buf:string): return Universe { buf, flatbuffers.indirect(buf, 0) }
|
||||
|
||||
struct UniverseBuilder:
|
||||
b_:flatbuffers_builder
|
||||
b_:flatbuffers.builder
|
||||
def start():
|
||||
b_.StartObject(2)
|
||||
return this
|
||||
def add_age(age:float):
|
||||
b_.PrependFloat64Slot(0, age, 0.0)
|
||||
return this
|
||||
def add_galaxies(galaxies:flatbuffers_offset):
|
||||
def add_galaxies(galaxies:flatbuffers.offset):
|
||||
b_.PrependUOffsetTRelativeSlot(1, galaxies)
|
||||
return this
|
||||
def end():
|
||||
return b_.EndObject()
|
||||
|
||||
def UniverseStartGalaxiesVector(b_:flatbuffers_builder, n_:int):
|
||||
def UniverseStartGalaxiesVector(b_:flatbuffers.builder, n_:int):
|
||||
b_.StartVector(4, n_, 4)
|
||||
def UniverseCreateGalaxiesVector(b_:flatbuffers_builder, v_:[flatbuffers_offset]):
|
||||
def UniverseCreateGalaxiesVector(b_:flatbuffers.builder, v_:[flatbuffers.offset]):
|
||||
b_.StartVector(4, v_.length, 4)
|
||||
reverse(v_) e_: b_.PrependUOffsetTRelative(e_)
|
||||
return b_.EndVector(v_.length)
|
||||
|
||||
48
goldens/lua/Galaxy.lua
Normal file
48
goldens/lua/Galaxy.lua
Normal file
@@ -0,0 +1,48 @@
|
||||
--[[ Galaxy
|
||||
|
||||
Automatically generated by the FlatBuffers compiler, do not modify.
|
||||
Or modify. I'm a message, not a cop.
|
||||
|
||||
flatc version: 23.5.26
|
||||
|
||||
Declared by : //basic.fbs
|
||||
Rooting type : Universe (//basic.fbs)
|
||||
|
||||
--]]
|
||||
|
||||
local flatbuffers = require('flatbuffers')
|
||||
|
||||
local Galaxy = {}
|
||||
local mt = {}
|
||||
|
||||
function Galaxy.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:NumStars()
|
||||
local o = self.view:Offset(4)
|
||||
if o ~= 0 then
|
||||
return self.view:Get(flatbuffers.N.Int64, self.view.pos + o)
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
function Galaxy.Start(builder)
|
||||
builder:StartObject(1)
|
||||
end
|
||||
|
||||
function Galaxy.AddNumStars(builder, numStars)
|
||||
builder:PrependInt64Slot(0, numStars, 0)
|
||||
end
|
||||
|
||||
function Galaxy.End(builder)
|
||||
return builder:EndObject()
|
||||
end
|
||||
|
||||
return Galaxy
|
||||
88
goldens/lua/Universe.lua
Normal file
88
goldens/lua/Universe.lua
Normal file
@@ -0,0 +1,88 @@
|
||||
--[[ Universe
|
||||
|
||||
Automatically generated by the FlatBuffers compiler, do not modify.
|
||||
Or modify. I'm a message, not a cop.
|
||||
|
||||
flatc version: 23.5.26
|
||||
|
||||
Declared by : //basic.fbs
|
||||
Rooting type : Universe (//basic.fbs)
|
||||
|
||||
--]]
|
||||
|
||||
local __Galaxy = require('Galaxy')
|
||||
local flatbuffers = require('flatbuffers')
|
||||
|
||||
local Universe = {}
|
||||
local mt = {}
|
||||
|
||||
function Universe.New()
|
||||
local o = {}
|
||||
setmetatable(o, {__index = mt})
|
||||
return o
|
||||
end
|
||||
|
||||
function Universe.GetRootAsUniverse(buf, offset)
|
||||
if type(buf) == "string" then
|
||||
buf = flatbuffers.binaryArray.New(buf)
|
||||
end
|
||||
|
||||
local n = flatbuffers.N.UOffsetT:Unpack(buf, offset)
|
||||
local o = Universe.New()
|
||||
o:Init(buf, n + offset)
|
||||
return o
|
||||
end
|
||||
|
||||
function mt:Init(buf, pos)
|
||||
self.view = flatbuffers.view.New(buf, pos)
|
||||
end
|
||||
|
||||
function mt:Age()
|
||||
local o = self.view:Offset(4)
|
||||
if o ~= 0 then
|
||||
return self.view:Get(flatbuffers.N.Float64, self.view.pos + o)
|
||||
end
|
||||
return 0.0
|
||||
end
|
||||
|
||||
function mt:Galaxies(j)
|
||||
local o = self.view:Offset(6)
|
||||
if o ~= 0 then
|
||||
local x = self.view:Vector(o)
|
||||
x = x + ((j-1) * 4)
|
||||
x = self.view:Indirect(x)
|
||||
local obj = __Galaxy.New()
|
||||
obj:Init(self.view.bytes, x)
|
||||
return obj
|
||||
end
|
||||
end
|
||||
|
||||
function mt:GalaxiesLength()
|
||||
local o = self.view:Offset(6)
|
||||
if o ~= 0 then
|
||||
return self.view:VectorLen(o)
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
function Universe.Start(builder)
|
||||
builder:StartObject(2)
|
||||
end
|
||||
|
||||
function Universe.AddAge(builder, age)
|
||||
builder:PrependFloat64Slot(0, age, 0.0)
|
||||
end
|
||||
|
||||
function Universe.AddGalaxies(builder, galaxies)
|
||||
builder:PrependUOffsetTRelativeSlot(1, galaxies, 0)
|
||||
end
|
||||
|
||||
function Universe.StartGalaxiesVector(builder, numElems)
|
||||
return builder:StartVector(4, numElems, 4)
|
||||
end
|
||||
|
||||
function Universe.End(builder)
|
||||
return builder:EndObject()
|
||||
end
|
||||
|
||||
return Universe
|
||||
26
goldens/nim/Galaxy.nim
Normal file
26
goldens/nim/Galaxy.nim
Normal file
@@ -0,0 +1,26 @@
|
||||
#[ Galaxy
|
||||
Automatically generated by the FlatBuffers compiler, do not modify.
|
||||
Or modify. I'm a message, not a cop.
|
||||
|
||||
flatc version: 23.5.26
|
||||
|
||||
Declared by : //basic.fbs
|
||||
Rooting type : Universe (//basic.fbs)
|
||||
]#
|
||||
|
||||
import flatbuffers
|
||||
|
||||
type Galaxy* = object of FlatObj
|
||||
func numStars*(self: Galaxy): int64 =
|
||||
let o = self.tab.Offset(4)
|
||||
if o != 0:
|
||||
return Get[int64](self.tab, self.tab.Pos + o)
|
||||
return 0
|
||||
func `numStars=`*(self: var Galaxy, n: int64): bool =
|
||||
return self.tab.MutateSlot(4, n)
|
||||
proc GalaxyStart*(builder: var Builder) =
|
||||
builder.StartObject(1)
|
||||
proc GalaxyAddnumStars*(builder: var Builder, numStars: int64) =
|
||||
builder.PrependSlot(0, numStars, default(int64))
|
||||
proc GalaxyEnd*(builder: var Builder): uoffset =
|
||||
return builder.EndObject()
|
||||
46
goldens/nim/Universe.nim
Normal file
46
goldens/nim/Universe.nim
Normal file
@@ -0,0 +1,46 @@
|
||||
#[ Universe
|
||||
Automatically generated by the FlatBuffers compiler, do not modify.
|
||||
Or modify. I'm a message, not a cop.
|
||||
|
||||
flatc version: 23.5.26
|
||||
|
||||
Declared by : //basic.fbs
|
||||
Rooting type : Universe (//basic.fbs)
|
||||
]#
|
||||
|
||||
import Galaxy as Galaxy
|
||||
import flatbuffers
|
||||
import std/options
|
||||
|
||||
type Universe* = object of FlatObj
|
||||
func age*(self: Universe): float64 =
|
||||
let o = self.tab.Offset(4)
|
||||
if o != 0:
|
||||
return Get[float64](self.tab, self.tab.Pos + o)
|
||||
return 0.0
|
||||
func `age=`*(self: var Universe, n: float64): bool =
|
||||
return self.tab.MutateSlot(4, n)
|
||||
func galaxiesLength*(self: Universe): int =
|
||||
let o = self.tab.Offset(6)
|
||||
if o != 0:
|
||||
return self.tab.VectorLen(o)
|
||||
func galaxies*(self: Universe, j: int): Galaxy.Galaxy =
|
||||
let o = self.tab.Offset(6)
|
||||
if o != 0:
|
||||
var x = self.tab.Vector(o)
|
||||
x += j.uoffset * 4.uoffset
|
||||
return Galaxy.Galaxy(tab: Vtable(Bytes: self.tab.Bytes, Pos: x))
|
||||
func galaxies*(self: Universe): seq[Galaxy.Galaxy] =
|
||||
let len = self.galaxiesLength
|
||||
for i in countup(0, len - 1):
|
||||
result.add(self.galaxies(i))
|
||||
proc UniverseStart*(builder: var Builder) =
|
||||
builder.StartObject(2)
|
||||
proc UniverseAddage*(builder: var Builder, age: float64) =
|
||||
builder.PrependSlot(0, age, default(float64))
|
||||
proc UniverseAddgalaxies*(builder: var Builder, galaxies: uoffset) =
|
||||
builder.PrependSlot(1, galaxies, default(uoffset))
|
||||
proc UniverseStartgalaxiesVector*(builder: var Builder, numElems: uoffset) =
|
||||
builder.StartVector(4, numElems, 4)
|
||||
proc UniverseEnd*(builder: var Builder): uoffset =
|
||||
return builder.EndObject()
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace flatbuffers\goldens;
|
||||
|
||||
use \Google\FlatBuffers\Struct;
|
||||
use \Google\FlatBuffers\Table;
|
||||
use \Google\FlatBuffers\ByteBuffer;
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace flatbuffers\goldens;
|
||||
|
||||
use \Google\FlatBuffers\Struct;
|
||||
use \Google\FlatBuffers\Table;
|
||||
use \Google\FlatBuffers\ByteBuffer;
|
||||
0
goldens/py/flatbuffers/__init__.py
Normal file
0
goldens/py/flatbuffers/__init__.py
Normal file
@@ -1,6 +1,6 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace:
|
||||
# namespace: goldens
|
||||
|
||||
import flatbuffers
|
||||
from flatbuffers.compat import import_numpy
|
||||
@@ -40,7 +40,7 @@ def Start(builder):
|
||||
def GalaxyAddNumStars(builder, numStars):
|
||||
builder.PrependInt64Slot(0, numStars, 0)
|
||||
|
||||
def AddNumStars(builder: flatbuffers.Builder, numStars: int):
|
||||
def AddNumStars(builder, numStars):
|
||||
GalaxyAddNumStars(builder, numStars)
|
||||
|
||||
def GalaxyEnd(builder):
|
||||
@@ -1,6 +1,6 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace:
|
||||
# namespace: goldens
|
||||
|
||||
import flatbuffers
|
||||
from flatbuffers.compat import import_numpy
|
||||
@@ -38,7 +38,7 @@ class Universe(object):
|
||||
x = self._tab.Vector(o)
|
||||
x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
|
||||
x = self._tab.Indirect(x)
|
||||
from .Galaxy import Galaxy
|
||||
from flatbuffers.goldens.Galaxy import Galaxy
|
||||
obj = Galaxy()
|
||||
obj.Init(self._tab.Bytes, x)
|
||||
return obj
|
||||
@@ -65,19 +65,19 @@ def Start(builder):
|
||||
def UniverseAddAge(builder, age):
|
||||
builder.PrependFloat64Slot(0, age, 0.0)
|
||||
|
||||
def AddAge(builder: flatbuffers.Builder, age: float):
|
||||
def AddAge(builder, age):
|
||||
UniverseAddAge(builder, age)
|
||||
|
||||
def UniverseAddGalaxies(builder, galaxies):
|
||||
builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(galaxies), 0)
|
||||
|
||||
def AddGalaxies(builder: flatbuffers.Builder, galaxies: int):
|
||||
def AddGalaxies(builder, galaxies):
|
||||
UniverseAddGalaxies(builder, galaxies)
|
||||
|
||||
def UniverseStartGalaxiesVector(builder, numElems):
|
||||
return builder.StartVector(4, numElems, 4)
|
||||
|
||||
def StartGalaxiesVector(builder, numElems: int) -> int:
|
||||
def StartGalaxiesVector(builder, numElems):
|
||||
return UniverseStartGalaxiesVector(builder, numElems)
|
||||
|
||||
def UniverseEnd(builder):
|
||||
0
goldens/py/flatbuffers/goldens/__init__.py
Normal file
0
goldens/py/flatbuffers/goldens/__init__.py
Normal file
@@ -9,6 +9,23 @@ use core::cmp::Ordering;
|
||||
extern crate flatbuffers;
|
||||
use self::flatbuffers::{EndianScalar, Follow};
|
||||
|
||||
#[allow(unused_imports, dead_code)]
|
||||
pub mod flatbuffers {
|
||||
|
||||
use core::mem;
|
||||
use core::cmp::Ordering;
|
||||
|
||||
extern crate flatbuffers;
|
||||
use self::flatbuffers::{EndianScalar, Follow};
|
||||
#[allow(unused_imports, dead_code)]
|
||||
pub mod goldens {
|
||||
|
||||
use core::mem;
|
||||
use core::cmp::Ordering;
|
||||
|
||||
extern crate flatbuffers;
|
||||
use self::flatbuffers::{EndianScalar, Follow};
|
||||
|
||||
pub enum GalaxyOffset {}
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
|
||||
@@ -32,8 +49,8 @@ impl<'a> Galaxy<'a> {
|
||||
Galaxy { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||
args: &'args GalaxyArgs
|
||||
) -> flatbuffers::WIPOffset<Galaxy<'bldr>> {
|
||||
let mut builder = GalaxyBuilder::new(_fbb);
|
||||
@@ -75,17 +92,17 @@ impl<'a> Default for GalaxyArgs {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct GalaxyBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
pub struct GalaxyBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
|
||||
start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
|
||||
}
|
||||
impl<'a: 'b, 'b> GalaxyBuilder<'a, 'b> {
|
||||
impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> GalaxyBuilder<'a, 'b, A> {
|
||||
#[inline]
|
||||
pub fn add_num_stars(&mut self, num_stars: i64) {
|
||||
self.fbb_.push_slot::<i64>(Galaxy::VT_NUM_STARS, num_stars, 0);
|
||||
}
|
||||
#[inline]
|
||||
pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> GalaxyBuilder<'a, 'b> {
|
||||
pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> GalaxyBuilder<'a, 'b, A> {
|
||||
let start = _fbb.start_table();
|
||||
GalaxyBuilder {
|
||||
fbb_: _fbb,
|
||||
@@ -130,8 +147,8 @@ impl<'a> Universe<'a> {
|
||||
Universe { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||
args: &'args UniverseArgs<'args>
|
||||
) -> flatbuffers::WIPOffset<Universe<'bldr>> {
|
||||
let mut builder = UniverseBuilder::new(_fbb);
|
||||
@@ -184,11 +201,11 @@ impl<'a> Default for UniverseArgs<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct UniverseBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
pub struct UniverseBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
|
||||
start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
|
||||
}
|
||||
impl<'a: 'b, 'b> UniverseBuilder<'a, 'b> {
|
||||
impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> UniverseBuilder<'a, 'b, A> {
|
||||
#[inline]
|
||||
pub fn add_age(&mut self, age: f64) {
|
||||
self.fbb_.push_slot::<f64>(Universe::VT_AGE, age, 0.0);
|
||||
@@ -198,7 +215,7 @@ impl<'a: 'b, 'b> UniverseBuilder<'a, 'b> {
|
||||
self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Universe::VT_GALAXIES, galaxies);
|
||||
}
|
||||
#[inline]
|
||||
pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> UniverseBuilder<'a, 'b> {
|
||||
pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> UniverseBuilder<'a, 'b, A> {
|
||||
let start = _fbb.start_table();
|
||||
UniverseBuilder {
|
||||
fbb_: _fbb,
|
||||
@@ -281,13 +298,16 @@ pub unsafe fn size_prefixed_root_as_universe_unchecked(buf: &[u8]) -> Universe {
|
||||
flatbuffers::size_prefixed_root_unchecked::<Universe>(buf)
|
||||
}
|
||||
#[inline]
|
||||
pub fn finish_universe_buffer<'a, 'b>(
|
||||
fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
pub fn finish_universe_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(
|
||||
fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
|
||||
root: flatbuffers::WIPOffset<Universe<'a>>) {
|
||||
fbb.finish(root, None);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn finish_size_prefixed_universe_buffer<'a, 'b>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, root: flatbuffers::WIPOffset<Universe<'a>>) {
|
||||
pub fn finish_size_prefixed_universe_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, root: flatbuffers::WIPOffset<Universe<'a>>) {
|
||||
fbb.finish_size_prefixed(root, None);
|
||||
}
|
||||
} // pub mod goldens
|
||||
} // pub mod flatbuffers
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// This file should contain the basics of flatbuffers that all languages should
|
||||
// support.
|
||||
|
||||
namespace flatbuffers.goldens;
|
||||
|
||||
table Galaxy {
|
||||
num_stars:long;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
import FlatBuffers
|
||||
|
||||
public struct Galaxy: FlatBufferObject, Verifiable {
|
||||
public struct flatbuffers_goldens_Galaxy: FlatBufferObject, Verifiable {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_23_5_8() }
|
||||
static func validateVersion() { FlatBuffersVersion_24_3_7() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
private var _accessor: Table
|
||||
|
||||
@@ -27,9 +27,9 @@ public struct Galaxy: FlatBufferObject, Verifiable {
|
||||
_ fbb: inout FlatBufferBuilder,
|
||||
numStars: Int64 = 0
|
||||
) -> Offset {
|
||||
let __start = Galaxy.startGalaxy(&fbb)
|
||||
Galaxy.add(numStars: numStars, &fbb)
|
||||
return Galaxy.endGalaxy(&fbb, start: __start)
|
||||
let __start = flatbuffers_goldens_Galaxy.startGalaxy(&fbb)
|
||||
flatbuffers_goldens_Galaxy.add(numStars: numStars, &fbb)
|
||||
return flatbuffers_goldens_Galaxy.endGalaxy(&fbb, start: __start)
|
||||
}
|
||||
|
||||
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
|
||||
@@ -39,9 +39,9 @@ public struct Galaxy: FlatBufferObject, Verifiable {
|
||||
}
|
||||
}
|
||||
|
||||
public struct Universe: FlatBufferObject, Verifiable {
|
||||
public struct flatbuffers_goldens_Universe: FlatBufferObject, Verifiable {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_23_5_8() }
|
||||
static func validateVersion() { FlatBuffersVersion_24_3_7() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
private var _accessor: Table
|
||||
|
||||
@@ -58,7 +58,7 @@ public struct Universe: FlatBufferObject, Verifiable {
|
||||
public var age: Double { let o = _accessor.offset(VTOFFSET.age.v); return o == 0 ? 0.0 : _accessor.readBuffer(of: Double.self, at: o) }
|
||||
public var hasGalaxies: Bool { let o = _accessor.offset(VTOFFSET.galaxies.v); return o == 0 ? false : true }
|
||||
public var galaxiesCount: Int32 { let o = _accessor.offset(VTOFFSET.galaxies.v); return o == 0 ? 0 : _accessor.vector(count: o) }
|
||||
public func galaxies(at index: Int32) -> Galaxy? { let o = _accessor.offset(VTOFFSET.galaxies.v); return o == 0 ? nil : Galaxy(_accessor.bb, o: _accessor.indirect(_accessor.vector(at: o) + index * 4)) }
|
||||
public func galaxies(at index: Int32) -> flatbuffers_goldens_Galaxy? { let o = _accessor.offset(VTOFFSET.galaxies.v); return o == 0 ? nil : flatbuffers_goldens_Galaxy(_accessor.bb, o: _accessor.indirect(_accessor.vector(at: o) + index * 4)) }
|
||||
public static func startUniverse(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 2) }
|
||||
public static func add(age: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: age, def: 0.0, at: VTOFFSET.age.p) }
|
||||
public static func addVectorOf(galaxies: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: galaxies, at: VTOFFSET.galaxies.p) }
|
||||
@@ -68,16 +68,16 @@ public struct Universe: FlatBufferObject, Verifiable {
|
||||
age: Double = 0.0,
|
||||
galaxiesVectorOffset galaxies: Offset = Offset()
|
||||
) -> Offset {
|
||||
let __start = Universe.startUniverse(&fbb)
|
||||
Universe.add(age: age, &fbb)
|
||||
Universe.addVectorOf(galaxies: galaxies, &fbb)
|
||||
return Universe.endUniverse(&fbb, start: __start)
|
||||
let __start = flatbuffers_goldens_Universe.startUniverse(&fbb)
|
||||
flatbuffers_goldens_Universe.add(age: age, &fbb)
|
||||
flatbuffers_goldens_Universe.addVectorOf(galaxies: galaxies, &fbb)
|
||||
return flatbuffers_goldens_Universe.endUniverse(&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.age.p, fieldName: "age", required: false, type: Double.self)
|
||||
try _v.visit(field: VTOFFSET.galaxies.p, fieldName: "galaxies", required: false, type: ForwardOffset<Vector<ForwardOffset<Galaxy>, Galaxy>>.self)
|
||||
try _v.visit(field: VTOFFSET.galaxies.p, fieldName: "galaxies", required: false, type: ForwardOffset<Vector<ForwardOffset<flatbuffers_goldens_Galaxy>, flatbuffers_goldens_Galaxy>>.self)
|
||||
_v.finish()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
export { Galaxy } from './galaxy.js';
|
||||
export { Universe } from './universe.js';
|
||||
|
||||
6
goldens/ts/flatbuffers/goldens.ts
Normal file
6
goldens/ts/flatbuffers/goldens.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
export { Galaxy } from './goldens/galaxy.js';
|
||||
export { Universe } from './goldens/universe.js';
|
||||
@@ -1,5 +1,7 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
export class Galaxy {
|
||||
@@ -1,8 +1,10 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
import { Galaxy } from './galaxy.js';
|
||||
import { Galaxy } from '../../flatbuffers/goldens/galaxy.js';
|
||||
|
||||
|
||||
export class Universe {
|
||||
@@ -5,7 +5,7 @@ go 1.15
|
||||
replace github.com/google/flatbuffers/grpc/examples/go/greeter/models v0.0.0 => ../models
|
||||
|
||||
require (
|
||||
github.com/google/flatbuffers v1.12.0
|
||||
github.com/google/flatbuffers v2.0.8+incompatible
|
||||
github.com/google/flatbuffers/grpc/examples/go/greeter/models v0.0.0
|
||||
google.golang.org/grpc v1.35.0
|
||||
google.golang.org/grpc v1.56.3
|
||||
)
|
||||
|
||||
@@ -3,6 +3,6 @@ module github.com/google/flatbuffers/grpc/examples/go/greeter/models
|
||||
go 1.15
|
||||
|
||||
require (
|
||||
github.com/google/flatbuffers v1.12.0
|
||||
google.golang.org/grpc v1.35.0
|
||||
github.com/google/flatbuffers v2.0.8+incompatible
|
||||
google.golang.org/grpc v1.56.3
|
||||
)
|
||||
|
||||
@@ -5,7 +5,7 @@ go 1.15
|
||||
replace github.com/google/flatbuffers/grpc/examples/go/greeter/models v0.0.0 => ../models
|
||||
|
||||
require (
|
||||
github.com/google/flatbuffers v1.12.0
|
||||
github.com/google/flatbuffers v2.0.8+incompatible
|
||||
github.com/google/flatbuffers/grpc/examples/go/greeter/models v0.0.0
|
||||
google.golang.org/grpc v1.39.0-dev
|
||||
google.golang.org/grpc v1.56.3
|
||||
)
|
||||
|
||||
@@ -40,7 +40,7 @@ def Start(builder):
|
||||
def HelloReplyAddMessage(builder, message):
|
||||
builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(message), 0)
|
||||
|
||||
def AddMessage(builder: flatbuffers.Builder, message: int):
|
||||
def AddMessage(builder, message):
|
||||
HelloReplyAddMessage(builder, message)
|
||||
|
||||
def HelloReplyEnd(builder):
|
||||
|
||||
@@ -40,7 +40,7 @@ def Start(builder):
|
||||
def HelloRequestAddName(builder, name):
|
||||
builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0)
|
||||
|
||||
def AddName(builder: flatbuffers.Builder, name: int):
|
||||
def AddName(builder, name):
|
||||
HelloRequestAddName(builder, name)
|
||||
|
||||
def HelloRequestEnd(builder):
|
||||
|
||||
@@ -6,7 +6,7 @@ import FlatBuffers
|
||||
|
||||
public struct models_HelloReply: FlatBufferObject, Verifiable {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_23_5_8() }
|
||||
static func validateVersion() { FlatBuffersVersion_24_3_7() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
private var _accessor: Table
|
||||
|
||||
@@ -53,7 +53,7 @@ extension models_HelloReply: Encodable {
|
||||
|
||||
public struct models_HelloRequest: FlatBufferObject, Verifiable {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_23_5_8() }
|
||||
static func validateVersion() { FlatBuffersVersion_24_3_7() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
private var _accessor: Table
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
export * as models from './models.js';
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
export { HelloReply } from './models/hello-reply.js';
|
||||
export { HelloRequest } from './models/hello-request.js';
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#ifndef FLATBUFFERS_ARRAY_H_
|
||||
#define FLATBUFFERS_ARRAY_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
#include "flatbuffers/base.h"
|
||||
@@ -37,7 +38,7 @@ template<typename T, uint16_t length> class Array {
|
||||
public:
|
||||
typedef uint16_t size_type;
|
||||
typedef typename IndirectHelper<IndirectHelperType>::return_type return_type;
|
||||
typedef VectorConstIterator<T, return_type> const_iterator;
|
||||
typedef VectorConstIterator<T, return_type, uoffset_t> const_iterator;
|
||||
typedef VectorReverseIterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
// If T is a LE-scalar or a struct (!scalar_tag::value).
|
||||
@@ -158,11 +159,13 @@ template<typename T, uint16_t length> class Array {
|
||||
|
||||
// Specialization for Array[struct] with access using Offset<void> pointer.
|
||||
// This specialization used by idl_gen_text.cpp.
|
||||
template<typename T, uint16_t length> class Array<Offset<T>, length> {
|
||||
template<typename T, uint16_t length, template<typename> class OffsetT>
|
||||
class Array<OffsetT<T>, length> {
|
||||
static_assert(flatbuffers::is_same<T, void>::value, "unexpected type T");
|
||||
|
||||
public:
|
||||
typedef const void *return_type;
|
||||
typedef uint16_t size_type;
|
||||
|
||||
const uint8_t *Data() const { return data_; }
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
|
||||
@@ -138,9 +139,9 @@
|
||||
#endif
|
||||
#endif // !defined(FLATBUFFERS_LITTLEENDIAN)
|
||||
|
||||
#define FLATBUFFERS_VERSION_MAJOR 23
|
||||
#define FLATBUFFERS_VERSION_MINOR 5
|
||||
#define FLATBUFFERS_VERSION_REVISION 8
|
||||
#define FLATBUFFERS_VERSION_MAJOR 24
|
||||
#define FLATBUFFERS_VERSION_MINOR 3
|
||||
#define FLATBUFFERS_VERSION_REVISION 7
|
||||
#define FLATBUFFERS_STRING_EXPAND(X) #X
|
||||
#define FLATBUFFERS_STRING(X) FLATBUFFERS_STRING_EXPAND(X)
|
||||
namespace flatbuffers {
|
||||
@@ -154,7 +155,7 @@ namespace flatbuffers {
|
||||
#define FLATBUFFERS_FINAL_CLASS final
|
||||
#define FLATBUFFERS_OVERRIDE override
|
||||
#define FLATBUFFERS_EXPLICIT_CPP11 explicit
|
||||
#define FLATBUFFERS_VTABLE_UNDERLYING_TYPE : flatbuffers::voffset_t
|
||||
#define FLATBUFFERS_VTABLE_UNDERLYING_TYPE : ::flatbuffers::voffset_t
|
||||
#else
|
||||
#define FLATBUFFERS_FINAL_CLASS
|
||||
#define FLATBUFFERS_OVERRIDE
|
||||
@@ -278,20 +279,22 @@ namespace flatbuffers {
|
||||
#endif // !FLATBUFFERS_LOCALE_INDEPENDENT
|
||||
|
||||
// Suppress Undefined Behavior Sanitizer (recoverable only). Usage:
|
||||
// - __suppress_ubsan__("undefined")
|
||||
// - __suppress_ubsan__("signed-integer-overflow")
|
||||
// - FLATBUFFERS_SUPPRESS_UBSAN("undefined")
|
||||
// - FLATBUFFERS_SUPPRESS_UBSAN("signed-integer-overflow")
|
||||
#if defined(__clang__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >=7))
|
||||
#define __suppress_ubsan__(type) __attribute__((no_sanitize(type)))
|
||||
#define FLATBUFFERS_SUPPRESS_UBSAN(type) __attribute__((no_sanitize(type)))
|
||||
#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 409)
|
||||
#define __suppress_ubsan__(type) __attribute__((no_sanitize_undefined))
|
||||
#define FLATBUFFERS_SUPPRESS_UBSAN(type) __attribute__((no_sanitize_undefined))
|
||||
#else
|
||||
#define __suppress_ubsan__(type)
|
||||
#define FLATBUFFERS_SUPPRESS_UBSAN(type)
|
||||
#endif
|
||||
|
||||
// This is constexpr function used for checking compile-time constants.
|
||||
// Avoid `#pragma warning(disable: 4127) // C4127: expression is constant`.
|
||||
template<typename T> FLATBUFFERS_CONSTEXPR inline bool IsConstTrue(T t) {
|
||||
return !!t;
|
||||
namespace flatbuffers {
|
||||
// This is constexpr function used for checking compile-time constants.
|
||||
// Avoid `#pragma warning(disable: 4127) // C4127: expression is constant`.
|
||||
template<typename T> FLATBUFFERS_CONSTEXPR inline bool IsConstTrue(T t) {
|
||||
return !!t;
|
||||
}
|
||||
}
|
||||
|
||||
// Enable C++ attribute [[]] if std:c++17 or higher.
|
||||
@@ -323,9 +326,11 @@ namespace flatbuffers {
|
||||
// Also, using a consistent offset type maintains compatibility of serialized
|
||||
// offset values between 32bit and 64bit systems.
|
||||
typedef uint32_t uoffset_t;
|
||||
typedef uint64_t uoffset64_t;
|
||||
|
||||
// Signed offsets for references that can go in both directions.
|
||||
typedef int32_t soffset_t;
|
||||
typedef int64_t soffset64_t;
|
||||
|
||||
// Offset/index used in v-tables, can be changed to uint8_t in
|
||||
// format forks to save a bit of space if desired.
|
||||
@@ -334,7 +339,8 @@ typedef uint16_t voffset_t;
|
||||
typedef uintmax_t largest_scalar_t;
|
||||
|
||||
// In 32bits, this evaluates to 2GB - 1
|
||||
#define FLATBUFFERS_MAX_BUFFER_SIZE ((1ULL << (sizeof(::flatbuffers::soffset_t) * 8 - 1)) - 1)
|
||||
#define FLATBUFFERS_MAX_BUFFER_SIZE std::numeric_limits<::flatbuffers::soffset_t>::max()
|
||||
#define FLATBUFFERS_MAX_64_BUFFER_SIZE std::numeric_limits<::flatbuffers::soffset64_t>::max()
|
||||
|
||||
// The minimum size buffer that can be a valid flatbuffer.
|
||||
// Includes the offset to the root table (uoffset_t), the offset to the vtable
|
||||
@@ -357,7 +363,6 @@ inline bool VerifyAlignmentRequirements(size_t align, size_t min_align = 1) {
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable: 4351) // C4351: new behavior: elements of array ... will be default initialized
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4127) // C4127: conditional expression is constant
|
||||
#endif
|
||||
@@ -418,7 +423,7 @@ template<typename T> T EndianScalar(T t) {
|
||||
|
||||
template<typename T>
|
||||
// UBSAN: C++ aliasing type rules, see std::bit_cast<> for details.
|
||||
__suppress_ubsan__("alignment")
|
||||
FLATBUFFERS_SUPPRESS_UBSAN("alignment")
|
||||
T ReadScalar(const void *p) {
|
||||
return EndianScalar(*reinterpret_cast<const T *>(p));
|
||||
}
|
||||
@@ -432,13 +437,13 @@ T ReadScalar(const void *p) {
|
||||
|
||||
template<typename T>
|
||||
// UBSAN: C++ aliasing type rules, see std::bit_cast<> for details.
|
||||
__suppress_ubsan__("alignment")
|
||||
FLATBUFFERS_SUPPRESS_UBSAN("alignment")
|
||||
void WriteScalar(void *p, T t) {
|
||||
*reinterpret_cast<T *>(p) = EndianScalar(t);
|
||||
}
|
||||
|
||||
template<typename T> struct Offset;
|
||||
template<typename T> __suppress_ubsan__("alignment") void WriteScalar(void *p, Offset<T> t) {
|
||||
template<typename T> FLATBUFFERS_SUPPRESS_UBSAN("alignment") void WriteScalar(void *p, Offset<T> t) {
|
||||
*reinterpret_cast<uoffset_t *>(p) = EndianScalar(t.o);
|
||||
}
|
||||
|
||||
@@ -449,7 +454,7 @@ template<typename T> __suppress_ubsan__("alignment") void WriteScalar(void *p, O
|
||||
// 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).
|
||||
__suppress_ubsan__("unsigned-integer-overflow")
|
||||
FLATBUFFERS_SUPPRESS_UBSAN("unsigned-integer-overflow")
|
||||
inline size_t PaddingBytes(size_t buf_size, size_t scalar_size) {
|
||||
return ((~buf_size) + 1) & (scalar_size - 1);
|
||||
}
|
||||
|
||||
@@ -25,14 +25,33 @@ namespace flatbuffers {
|
||||
|
||||
// Wrapper for uoffset_t to allow safe template specialization.
|
||||
// Value is allowed to be 0 to indicate a null object (see e.g. AddOffset).
|
||||
template<typename T> struct Offset {
|
||||
uoffset_t o;
|
||||
template<typename T = void> struct Offset {
|
||||
// The type of offset to use.
|
||||
typedef uoffset_t offset_type;
|
||||
|
||||
offset_type o;
|
||||
Offset() : o(0) {}
|
||||
Offset(uoffset_t _o) : o(_o) {}
|
||||
Offset<void> Union() const { return Offset<void>(o); }
|
||||
Offset(const offset_type _o) : o(_o) {}
|
||||
Offset<> Union() const { return o; }
|
||||
bool IsNull() const { return !o; }
|
||||
};
|
||||
|
||||
// Wrapper for uoffset64_t Offsets.
|
||||
template<typename T = void> struct Offset64 {
|
||||
// The type of offset to use.
|
||||
typedef uoffset64_t offset_type;
|
||||
|
||||
offset_type o;
|
||||
Offset64() : o(0) {}
|
||||
Offset64(const offset_type offset) : o(offset) {}
|
||||
Offset64<> Union() const { return o; }
|
||||
bool IsNull() const { return !o; }
|
||||
};
|
||||
|
||||
// Litmus check for ensuring the Offsets are the expected size.
|
||||
static_assert(sizeof(Offset<>) == 4, "Offset has wrong size");
|
||||
static_assert(sizeof(Offset64<>) == 8, "Offset64 has wrong size");
|
||||
|
||||
inline void EndianCheck() {
|
||||
int endiantest = 1;
|
||||
// If this fails, see FLATBUFFERS_LITTLEENDIAN above.
|
||||
@@ -75,35 +94,59 @@ template<typename T> struct IndirectHelper {
|
||||
typedef T return_type;
|
||||
typedef T mutable_return_type;
|
||||
static const size_t element_stride = sizeof(T);
|
||||
static return_type Read(const uint8_t *p, uoffset_t i) {
|
||||
|
||||
static return_type Read(const uint8_t *p, const size_t i) {
|
||||
return EndianScalar((reinterpret_cast<const T *>(p))[i]);
|
||||
}
|
||||
static return_type Read(uint8_t *p, uoffset_t i) {
|
||||
return Read(const_cast<const uint8_t *>(p), i);
|
||||
static mutable_return_type Read(uint8_t *p, const size_t i) {
|
||||
return reinterpret_cast<mutable_return_type>(
|
||||
Read(const_cast<const uint8_t *>(p), i));
|
||||
}
|
||||
};
|
||||
template<typename T> struct IndirectHelper<Offset<T>> {
|
||||
|
||||
// For vector of Offsets.
|
||||
template<typename T, template<typename> class OffsetT>
|
||||
struct IndirectHelper<OffsetT<T>> {
|
||||
typedef const T *return_type;
|
||||
typedef T *mutable_return_type;
|
||||
static const size_t element_stride = sizeof(uoffset_t);
|
||||
static return_type Read(const uint8_t *p, uoffset_t i) {
|
||||
p += i * sizeof(uoffset_t);
|
||||
return reinterpret_cast<return_type>(p + ReadScalar<uoffset_t>(p));
|
||||
typedef typename OffsetT<T>::offset_type offset_type;
|
||||
static const offset_type element_stride = sizeof(offset_type);
|
||||
|
||||
static return_type Read(const uint8_t *const p, const offset_type i) {
|
||||
// Offsets are relative to themselves, so first update the pointer to
|
||||
// point to the offset location.
|
||||
const uint8_t *const offset_location = p + i * element_stride;
|
||||
|
||||
// Then read the scalar value of the offset (which may be 32 or 64-bits) and
|
||||
// then determine the relative location from the offset location.
|
||||
return reinterpret_cast<return_type>(
|
||||
offset_location + ReadScalar<offset_type>(offset_location));
|
||||
}
|
||||
static mutable_return_type Read(uint8_t *p, uoffset_t i) {
|
||||
p += i * sizeof(uoffset_t);
|
||||
return reinterpret_cast<mutable_return_type>(p + ReadScalar<uoffset_t>(p));
|
||||
static mutable_return_type Read(uint8_t *const p, const offset_type i) {
|
||||
// Offsets are relative to themselves, so first update the pointer to
|
||||
// point to the offset location.
|
||||
uint8_t *const offset_location = p + i * element_stride;
|
||||
|
||||
// Then read the scalar value of the offset (which may be 32 or 64-bits) and
|
||||
// then determine the relative location from the offset location.
|
||||
return reinterpret_cast<mutable_return_type>(
|
||||
offset_location + ReadScalar<offset_type>(offset_location));
|
||||
}
|
||||
};
|
||||
|
||||
// For vector of structs.
|
||||
template<typename T> struct IndirectHelper<const T *> {
|
||||
typedef const T *return_type;
|
||||
typedef T *mutable_return_type;
|
||||
static const size_t element_stride = sizeof(T);
|
||||
static return_type Read(const uint8_t *p, uoffset_t i) {
|
||||
return reinterpret_cast<return_type>(p + i * sizeof(T));
|
||||
|
||||
static return_type Read(const uint8_t *const p, const size_t i) {
|
||||
// Structs are stored inline, relative to the first struct pointer.
|
||||
return reinterpret_cast<return_type>(p + i * element_stride);
|
||||
}
|
||||
static mutable_return_type Read(uint8_t *p, uoffset_t i) {
|
||||
return reinterpret_cast<mutable_return_type>(p + i * sizeof(T));
|
||||
static mutable_return_type Read(uint8_t *const p, const size_t i) {
|
||||
// Structs are stored inline, relative to the first struct pointer.
|
||||
return reinterpret_cast<mutable_return_type>(p + i * element_stride);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -130,23 +173,25 @@ inline bool BufferHasIdentifier(const void *buf, const char *identifier,
|
||||
/// @cond FLATBUFFERS_INTERNAL
|
||||
// Helpers to get a typed pointer to the root object contained in the buffer.
|
||||
template<typename T> T *GetMutableRoot(void *buf) {
|
||||
if (!buf) return nullptr;
|
||||
EndianCheck();
|
||||
return reinterpret_cast<T *>(
|
||||
reinterpret_cast<uint8_t *>(buf) +
|
||||
EndianScalar(*reinterpret_cast<uoffset_t *>(buf)));
|
||||
}
|
||||
|
||||
template<typename T> T *GetMutableSizePrefixedRoot(void *buf) {
|
||||
return GetMutableRoot<T>(reinterpret_cast<uint8_t *>(buf) +
|
||||
sizeof(uoffset_t));
|
||||
template<typename T, typename SizeT = uoffset_t>
|
||||
T *GetMutableSizePrefixedRoot(void *buf) {
|
||||
return GetMutableRoot<T>(reinterpret_cast<uint8_t *>(buf) + sizeof(SizeT));
|
||||
}
|
||||
|
||||
template<typename T> const T *GetRoot(const void *buf) {
|
||||
return GetMutableRoot<T>(const_cast<void *>(buf));
|
||||
}
|
||||
|
||||
template<typename T> const T *GetSizePrefixedRoot(const void *buf) {
|
||||
return GetRoot<T>(reinterpret_cast<const uint8_t *>(buf) + sizeof(uoffset_t));
|
||||
template<typename T, typename SizeT = uoffset_t>
|
||||
const T *GetSizePrefixedRoot(const void *buf) {
|
||||
return GetRoot<T>(reinterpret_cast<const uint8_t *>(buf) + sizeof(SizeT));
|
||||
}
|
||||
|
||||
} // namespace flatbuffers
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
|
||||
namespace flatbuffers {
|
||||
|
||||
struct CodeGenOptions {
|
||||
std::string output_path;
|
||||
};
|
||||
|
||||
// A code generator interface for producing converting flatbuffer schema into
|
||||
// code.
|
||||
class CodeGenerator {
|
||||
@@ -44,9 +48,20 @@ class CodeGenerator {
|
||||
virtual Status GenerateCode(const Parser &parser, const std::string &path,
|
||||
const std::string &filename) = 0;
|
||||
|
||||
// Generate code from the provided `parser` and place it in the output.
|
||||
virtual Status GenerateCodeString(const Parser &parser,
|
||||
const std::string &filename,
|
||||
std::string &output) {
|
||||
(void)parser;
|
||||
(void)filename;
|
||||
(void)output;
|
||||
return Status::NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// Generate code from the provided `buffer` of given `length`. The buffer is a
|
||||
// serialized reflection.fbs.
|
||||
virtual Status GenerateCode(const uint8_t *buffer, int64_t length) = 0;
|
||||
virtual Status GenerateCode(const uint8_t *buffer, int64_t length,
|
||||
const CodeGenOptions &options) = 0;
|
||||
|
||||
virtual Status GenerateMakeRule(const Parser &parser, const std::string &path,
|
||||
const std::string &filename,
|
||||
|
||||
@@ -229,6 +229,10 @@ class TypedFloatConstantGenerator : public FloatConstantGenerator {
|
||||
const std::string neg_inf_number_;
|
||||
};
|
||||
|
||||
std::string JavaCSharpMakeRule(const bool java, const Parser &parser,
|
||||
const std::string &path,
|
||||
const std::string &file_name);
|
||||
|
||||
} // namespace flatbuffers
|
||||
|
||||
#endif // FLATBUFFERS_CODE_GENERATORS_H_
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -76,8 +76,20 @@ inline const uint8_t *GetBufferStartFromRootPointer(const void *root) {
|
||||
}
|
||||
|
||||
/// @brief This return the prefixed size of a FlatBuffer.
|
||||
inline uoffset_t GetPrefixedSize(const uint8_t *buf) {
|
||||
return ReadScalar<uoffset_t>(buf);
|
||||
template<typename SizeT = uoffset_t>
|
||||
inline SizeT GetPrefixedSize(const uint8_t *buf) {
|
||||
return ReadScalar<SizeT>(buf);
|
||||
}
|
||||
|
||||
// Gets the total length of the buffer given a sized prefixed FlatBuffer.
|
||||
//
|
||||
// This includes the size of the prefix as well as the buffer:
|
||||
//
|
||||
// [size prefix][flatbuffer]
|
||||
// |---------length--------|
|
||||
template<typename SizeT = uoffset_t>
|
||||
inline SizeT GetSizePrefixedBufferLength(const uint8_t *const buf) {
|
||||
return ReadScalar<SizeT>(buf) + sizeof(SizeT);
|
||||
}
|
||||
|
||||
// Base class for native objects (FlatBuffer data de-serialized into native
|
||||
@@ -236,31 +248,31 @@ inline const char *flatbuffers_version_string() {
|
||||
|
||||
// clang-format off
|
||||
#define FLATBUFFERS_DEFINE_BITMASK_OPERATORS(E, T)\
|
||||
inline E operator | (E lhs, E rhs){\
|
||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator | (E lhs, E rhs){\
|
||||
return E(T(lhs) | T(rhs));\
|
||||
}\
|
||||
inline E operator & (E lhs, E rhs){\
|
||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator & (E lhs, E rhs){\
|
||||
return E(T(lhs) & T(rhs));\
|
||||
}\
|
||||
inline E operator ^ (E lhs, E rhs){\
|
||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator ^ (E lhs, E rhs){\
|
||||
return E(T(lhs) ^ T(rhs));\
|
||||
}\
|
||||
inline E operator ~ (E lhs){\
|
||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator ~ (E lhs){\
|
||||
return E(~T(lhs));\
|
||||
}\
|
||||
inline E operator |= (E &lhs, E rhs){\
|
||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator |= (E &lhs, E rhs){\
|
||||
lhs = lhs | rhs;\
|
||||
return lhs;\
|
||||
}\
|
||||
inline E operator &= (E &lhs, E rhs){\
|
||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator &= (E &lhs, E rhs){\
|
||||
lhs = lhs & rhs;\
|
||||
return lhs;\
|
||||
}\
|
||||
inline E operator ^= (E &lhs, E rhs){\
|
||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator ^= (E &lhs, E rhs){\
|
||||
lhs = lhs ^ rhs;\
|
||||
return lhs;\
|
||||
}\
|
||||
inline bool operator !(E rhs) \
|
||||
inline FLATBUFFERS_CONSTEXPR_CPP11 bool operator !(E rhs) \
|
||||
{\
|
||||
return !bool(T(rhs)); \
|
||||
}
|
||||
|
||||
@@ -360,16 +360,40 @@ class Map : public Vector {
|
||||
bool IsTheEmptyMap() const { return data_ == EmptyMap().data_; }
|
||||
};
|
||||
|
||||
inline void IndentString(std::string &s, int indent,
|
||||
const char *indent_string) {
|
||||
for (int i = 0; i < indent; i++) s += indent_string;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void AppendToString(std::string &s, T &&v, bool keys_quoted, bool indented,
|
||||
int cur_indent, const char *indent_string) {
|
||||
s += "[";
|
||||
s += indented ? "\n" : " ";
|
||||
for (size_t i = 0; i < v.size(); i++) {
|
||||
if (i) {
|
||||
s += ",";
|
||||
s += indented ? "\n" : " ";
|
||||
}
|
||||
if (indented) IndentString(s, cur_indent, indent_string);
|
||||
v[i].ToString(true, keys_quoted, s, indented, cur_indent,
|
||||
indent_string);
|
||||
}
|
||||
if (indented) {
|
||||
s += "\n";
|
||||
IndentString(s, cur_indent - 1, indent_string);
|
||||
} else {
|
||||
s += " ";
|
||||
}
|
||||
s += "]";
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void AppendToString(std::string &s, T &&v, bool keys_quoted) {
|
||||
s += "[ ";
|
||||
for (size_t i = 0; i < v.size(); i++) {
|
||||
if (i) s += ", ";
|
||||
v[i].ToString(true, keys_quoted, s);
|
||||
}
|
||||
s += " ]";
|
||||
AppendToString(s, v, keys_quoted);
|
||||
}
|
||||
|
||||
|
||||
class Reference {
|
||||
public:
|
||||
Reference()
|
||||
@@ -542,8 +566,13 @@ class Reference {
|
||||
// Convert any type to a JSON-like string. strings_quoted determines if
|
||||
// string values at the top level receive "" quotes (inside other values
|
||||
// they always do). keys_quoted determines if keys are quoted, at any level.
|
||||
// TODO(wvo): add further options to have indentation/newlines.
|
||||
void ToString(bool strings_quoted, bool keys_quoted, std::string &s) const {
|
||||
ToString(strings_quoted, keys_quoted, s, false, 0, "");
|
||||
}
|
||||
|
||||
// This version additionally allow you to specify if you want indentation.
|
||||
void ToString(bool strings_quoted, bool keys_quoted, std::string &s,
|
||||
bool indented, int cur_indent, const char *indent_string) const {
|
||||
if (type_ == FBT_STRING) {
|
||||
String str(Indirect(), byte_width_);
|
||||
if (strings_quoted) {
|
||||
@@ -569,7 +598,8 @@ class Reference {
|
||||
} else if (IsBool()) {
|
||||
s += AsBool() ? "true" : "false";
|
||||
} else if (IsMap()) {
|
||||
s += "{ ";
|
||||
s += "{";
|
||||
s += indented ? "\n" : " ";
|
||||
auto m = AsMap();
|
||||
auto keys = m.Keys();
|
||||
auto vals = m.Values();
|
||||
@@ -590,18 +620,28 @@ class Reference {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (indented) IndentString(s, cur_indent + 1, indent_string);
|
||||
keys[i].ToString(true, kq, s);
|
||||
s += ": ";
|
||||
vals[i].ToString(true, keys_quoted, s);
|
||||
if (i < keys.size() - 1) s += ", ";
|
||||
vals[i].ToString(true, keys_quoted, s, indented, cur_indent + 1, indent_string);
|
||||
if (i < keys.size() - 1) {
|
||||
s += ",";
|
||||
if (!indented) s += " ";
|
||||
}
|
||||
if (indented) s += "\n";
|
||||
}
|
||||
s += " }";
|
||||
if (!indented) s += " ";
|
||||
if (indented) IndentString(s, cur_indent, indent_string);
|
||||
s += "}";
|
||||
} else if (IsVector()) {
|
||||
AppendToString<Vector>(s, AsVector(), keys_quoted);
|
||||
AppendToString<Vector>(s, AsVector(), keys_quoted, indented,
|
||||
cur_indent + 1, indent_string);
|
||||
} else if (IsTypedVector()) {
|
||||
AppendToString<TypedVector>(s, AsTypedVector(), keys_quoted);
|
||||
AppendToString<TypedVector>(s, AsTypedVector(), keys_quoted, indented,
|
||||
cur_indent + 1, indent_string);
|
||||
} else if (IsFixedTypedVector()) {
|
||||
AppendToString<FixedTypedVector>(s, AsFixedTypedVector(), keys_quoted);
|
||||
AppendToString<FixedTypedVector>(s, AsFixedTypedVector(), keys_quoted,
|
||||
indented, cur_indent + 1, indent_string);
|
||||
} else if (IsBlob()) {
|
||||
auto blob = AsBlob();
|
||||
flatbuffers::EscapeString(reinterpret_cast<const char *>(blob.data()),
|
||||
@@ -1128,10 +1168,7 @@ class Builder FLATBUFFERS_FINAL_CLASS {
|
||||
|
||||
size_t EndMap(size_t start) {
|
||||
// We should have interleaved keys and values on the stack.
|
||||
// Make sure it is an even number:
|
||||
auto len = stack_.size() - start;
|
||||
FLATBUFFERS_ASSERT(!(len & 1));
|
||||
len /= 2;
|
||||
auto len = MapElementCount(start);
|
||||
// Make sure keys are all strings:
|
||||
for (auto key = start; key < stack_.size(); key += 2) {
|
||||
FLATBUFFERS_ASSERT(stack_[key].type_ == FBT_KEY);
|
||||
@@ -1289,6 +1326,14 @@ class Builder FLATBUFFERS_FINAL_CLASS {
|
||||
EndMap(start);
|
||||
}
|
||||
|
||||
size_t MapElementCount(size_t start) {
|
||||
// Make sure it is an even number:
|
||||
auto len = stack_.size() - start;
|
||||
FLATBUFFERS_ASSERT(!(len & 1));
|
||||
len /= 2;
|
||||
return len;
|
||||
}
|
||||
|
||||
// If you wish to share a value explicitly (a value not shared automatically
|
||||
// through one of the BUILDER_FLAG_SHARE_* flags) you can do so with these
|
||||
// functions. Or if you wish to turn those flags off for performance reasons
|
||||
@@ -1307,6 +1352,12 @@ class Builder FLATBUFFERS_FINAL_CLASS {
|
||||
ReuseValue(v);
|
||||
}
|
||||
|
||||
// Undo the last element serialized. Call once for a value and once for a
|
||||
// key.
|
||||
void Undo() {
|
||||
stack_.pop_back();
|
||||
}
|
||||
|
||||
// Overloaded Add that tries to call the correct function above.
|
||||
void Add(int8_t i) { Int(i); }
|
||||
void Add(int16_t i) { Int(i); }
|
||||
@@ -1669,7 +1720,7 @@ class Verifier FLATBUFFERS_FINAL_CLASS {
|
||||
max_vectors_(buf_len),
|
||||
check_alignment_(_check_alignment),
|
||||
reuse_tracker_(reuse_tracker) {
|
||||
FLATBUFFERS_ASSERT(size_ < FLATBUFFERS_MAX_BUFFER_SIZE);
|
||||
FLATBUFFERS_ASSERT(static_cast<int32_t>(size_) < FLATBUFFERS_MAX_BUFFER_SIZE);
|
||||
if (reuse_tracker_) {
|
||||
reuse_tracker_->clear();
|
||||
reuse_tracker_->resize(size_, PackedType(BIT_WIDTH_8, FBT_NULL));
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
// Helper functionality to glue FlatBuffers and GRPC.
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
#include "grpc/byte_buffer_reader.h"
|
||||
#include "grpcpp/support/byte_buffer.h"
|
||||
#include "grpcpp/support/slice.h"
|
||||
|
||||
|
||||
@@ -45,26 +45,27 @@ namespace flatbuffers {
|
||||
// of type tokens.
|
||||
// clang-format off
|
||||
#define FLATBUFFERS_GEN_TYPES_SCALAR(TD) \
|
||||
TD(NONE, "", uint8_t, byte, byte, byte, uint8, u8, UByte, UInt8, 0) \
|
||||
TD(UTYPE, "", uint8_t, byte, byte, byte, uint8, u8, UByte, UInt8, 1) /* begin scalar/int */ \
|
||||
TD(BOOL, "bool", uint8_t, boolean,bool, bool, bool, bool, Boolean, Bool, 2) \
|
||||
TD(CHAR, "byte", int8_t, byte, int8, sbyte, int8, i8, Byte, Int8, 3) \
|
||||
TD(UCHAR, "ubyte", uint8_t, byte, byte, byte, uint8, u8, UByte, UInt8, 4) \
|
||||
TD(SHORT, "short", int16_t, short, int16, short, int16, i16, Short, Int16, 5) \
|
||||
TD(USHORT, "ushort", uint16_t, short, uint16, ushort, uint16, u16, UShort, UInt16, 6) \
|
||||
TD(INT, "int", int32_t, int, int32, int, int32, i32, Int, Int32, 7) \
|
||||
TD(UINT, "uint", uint32_t, int, uint32, uint, uint32, u32, UInt, UInt32, 8) \
|
||||
TD(LONG, "long", int64_t, long, int64, long, int64, i64, Long, Int64, 9) \
|
||||
TD(ULONG, "ulong", uint64_t, long, uint64, ulong, uint64, u64, ULong, UInt64, 10) /* end int */ \
|
||||
TD(FLOAT, "float", float, float, float32, float, float32, f32, Float, Float32, 11) /* begin float */ \
|
||||
TD(DOUBLE, "double", double, double, float64, double, float64, f64, Double, Double, 12) /* end float/scalar */
|
||||
TD(NONE, "", uint8_t, byte, byte, byte, uint8, u8, UByte, UInt8, 0) \
|
||||
TD(UTYPE, "", uint8_t, byte, byte, byte, uint8, u8, UByte, UInt8, 1) /* begin scalar/int */ \
|
||||
TD(BOOL, "bool", uint8_t, boolean,bool, bool, bool, bool, Boolean, Bool, 2) \
|
||||
TD(CHAR, "byte", int8_t, byte, int8, sbyte, int8, i8, Byte, Int8, 3) \
|
||||
TD(UCHAR, "ubyte", uint8_t, byte, byte, byte, uint8, u8, UByte, UInt8, 4) \
|
||||
TD(SHORT, "short", int16_t, short, int16, short, int16, i16, Short, Int16, 5) \
|
||||
TD(USHORT, "ushort", uint16_t, short, uint16, ushort, uint16, u16, UShort, UInt16, 6) \
|
||||
TD(INT, "int", int32_t, int, int32, int, int32, i32, Int, Int32, 7) \
|
||||
TD(UINT, "uint", uint32_t, int, uint32, uint, uint32, u32, UInt, UInt32, 8) \
|
||||
TD(LONG, "long", int64_t, long, int64, long, int64, i64, Long, Int64, 9) \
|
||||
TD(ULONG, "ulong", uint64_t, long, uint64, ulong, uint64, u64, ULong, UInt64, 10) /* end int */ \
|
||||
TD(FLOAT, "float", float, float, float32, float, float32, f32, Float, Float32, 11) /* begin float */ \
|
||||
TD(DOUBLE, "double", double, double, float64, double, float64, f64, Double, Double, 12) /* end float/scalar */
|
||||
#define FLATBUFFERS_GEN_TYPES_POINTER(TD) \
|
||||
TD(STRING, "string", Offset<void>, int, int, StringOffset, int, unused, Int, Offset<String>, 13) \
|
||||
TD(VECTOR, "", Offset<void>, int, int, VectorOffset, int, unused, Int, Offset<UOffset>, 14) \
|
||||
TD(STRUCT, "", Offset<void>, int, int, int, int, unused, Int, Offset<UOffset>, 15) \
|
||||
TD(UNION, "", Offset<void>, int, int, int, int, unused, Int, Offset<UOffset>, 16)
|
||||
TD(STRING, "string", Offset<void>, int, int, StringOffset, int, unused, Int, Offset<String>, 13) \
|
||||
TD(VECTOR, "", Offset<void>, int, int, VectorOffset, int, unused, Int, Offset<UOffset>, 14) \
|
||||
TD(VECTOR64, "", Offset64<void>, int, int, VectorOffset, int, unused, Int, Offset<UOffset>, 18) \
|
||||
TD(STRUCT, "", Offset<void>, int, int, int, int, unused, Int, Offset<UOffset>, 15) \
|
||||
TD(UNION, "", Offset<void>, int, int, int, int, unused, Int, Offset<UOffset>, 16)
|
||||
#define FLATBUFFERS_GEN_TYPE_ARRAY(TD) \
|
||||
TD(ARRAY, "", int, int, int, int, int, unused, Int, Offset<UOffset>, 17)
|
||||
TD(ARRAY, "", int, int, int, int, int, unused, Int, Offset<UOffset>, 17)
|
||||
// The fields are:
|
||||
// - enum
|
||||
// - FlatBuffers schema type.
|
||||
@@ -139,6 +140,8 @@ inline bool IsLong (BaseType t) { return t == BASE_TYPE_LONG ||
|
||||
inline bool IsBool (BaseType t) { return t == BASE_TYPE_BOOL; }
|
||||
inline bool IsOneByte(BaseType t) { return t >= BASE_TYPE_UTYPE &&
|
||||
t <= BASE_TYPE_UCHAR; }
|
||||
inline bool IsVector (BaseType t) { return t == BASE_TYPE_VECTOR ||
|
||||
t == BASE_TYPE_VECTOR64; }
|
||||
|
||||
inline bool IsUnsigned(BaseType t) {
|
||||
return (t == BASE_TYPE_UTYPE) || (t == BASE_TYPE_UCHAR) ||
|
||||
@@ -210,7 +213,8 @@ struct Type {
|
||||
bool Deserialize(const Parser &parser, const reflection::Type *type);
|
||||
|
||||
BaseType base_type;
|
||||
BaseType element; // only set if t == BASE_TYPE_VECTOR
|
||||
BaseType element; // only set if t == BASE_TYPE_VECTOR or
|
||||
// BASE_TYPE_VECTOR64
|
||||
StructDef *struct_def; // only set if t or element == BASE_TYPE_STRUCT
|
||||
EnumDef *enum_def; // set if t == BASE_TYPE_UNION / BASE_TYPE_UTYPE,
|
||||
// or for an integral type derived from an enum.
|
||||
@@ -326,6 +330,7 @@ struct FieldDef : public Definition {
|
||||
shared(false),
|
||||
native_inline(false),
|
||||
flexbuffer(false),
|
||||
offset64(false),
|
||||
presence(kDefault),
|
||||
nested_flatbuffer(nullptr),
|
||||
padding(0),
|
||||
@@ -337,7 +342,10 @@ struct FieldDef : public Definition {
|
||||
bool Deserialize(Parser &parser, const reflection::Field *field);
|
||||
|
||||
bool IsScalarOptional() const {
|
||||
return IsScalar(value.type.base_type) && IsOptional();
|
||||
return IsScalar() && IsOptional();
|
||||
}
|
||||
bool IsScalar() const {
|
||||
return ::flatbuffers::IsScalar(value.type.base_type);
|
||||
}
|
||||
bool IsOptional() const { return presence == kOptional; }
|
||||
bool IsRequired() const { return presence == kRequired; }
|
||||
@@ -352,6 +360,7 @@ struct FieldDef : public Definition {
|
||||
bool native_inline; // Field will be defined inline (instead of as a pointer)
|
||||
// for native tables if field is a struct.
|
||||
bool flexbuffer; // This field contains FlexBuffer data.
|
||||
bool offset64; // If the field uses 64-bit offsets.
|
||||
|
||||
enum Presence {
|
||||
// Field must always be present.
|
||||
@@ -528,9 +537,7 @@ inline bool IsUnionType(const Type &type) {
|
||||
return IsUnion(type) && IsInteger(type.base_type);
|
||||
}
|
||||
|
||||
inline bool IsVector(const Type &type) {
|
||||
return type.base_type == BASE_TYPE_VECTOR;
|
||||
}
|
||||
inline bool IsVector(const Type &type) { return IsVector(type.base_type); }
|
||||
|
||||
inline bool IsVectorOfStruct(const Type &type) {
|
||||
return IsVector(type) && IsStruct(type.VectorType());
|
||||
@@ -669,6 +676,7 @@ struct IDLOptions {
|
||||
bool binary_schema_comments;
|
||||
bool binary_schema_builtins;
|
||||
bool binary_schema_gen_embed;
|
||||
bool binary_schema_absolute_paths;
|
||||
std::string go_import;
|
||||
std::string go_namespace;
|
||||
std::string go_module_name;
|
||||
@@ -699,6 +707,7 @@ struct IDLOptions {
|
||||
bool keep_proto_id;
|
||||
bool python_no_type_prefix_suffix;
|
||||
bool python_typing;
|
||||
bool ts_omit_entrypoint;
|
||||
ProtoIdGapAction proto_id_gap_action;
|
||||
|
||||
// Possible options for the more general generator below.
|
||||
@@ -721,6 +730,7 @@ struct IDLOptions {
|
||||
kSwift = 1 << 16,
|
||||
kNim = 1 << 17,
|
||||
kProto = 1 << 18,
|
||||
kKotlinKmp = 1 << 19,
|
||||
kMAX
|
||||
};
|
||||
|
||||
@@ -787,6 +797,7 @@ struct IDLOptions {
|
||||
binary_schema_comments(false),
|
||||
binary_schema_builtins(false),
|
||||
binary_schema_gen_embed(false),
|
||||
binary_schema_absolute_paths(false),
|
||||
protobuf_ascii_alike(false),
|
||||
size_prefixed(false),
|
||||
force_defaults(false),
|
||||
@@ -810,6 +821,7 @@ struct IDLOptions {
|
||||
keep_proto_id(false),
|
||||
python_no_type_prefix_suffix(false),
|
||||
python_typing(false),
|
||||
ts_omit_entrypoint(false),
|
||||
proto_id_gap_action(ProtoIdGapAction::WARNING),
|
||||
mini_reflect(IDLOptions::kNone),
|
||||
require_explicit_ids(false),
|
||||
@@ -952,6 +964,13 @@ class Parser : public ParserState {
|
||||
known_attributes_["native_default"] = true;
|
||||
known_attributes_["flexbuffer"] = true;
|
||||
known_attributes_["private"] = true;
|
||||
|
||||
// An attribute added to a field to indicate that is uses 64-bit addressing.
|
||||
known_attributes_["offset64"] = true;
|
||||
|
||||
// An attribute added to a vector field to indicate that it uses 64-bit
|
||||
// addressing and it has a 64-bit length.
|
||||
known_attributes_["vector64"] = true;
|
||||
}
|
||||
|
||||
// Copying is not allowed
|
||||
@@ -1062,7 +1081,7 @@ class Parser : public ParserState {
|
||||
FLATBUFFERS_CHECKED_ERROR ParseAnyValue(Value &val, FieldDef *field,
|
||||
size_t parent_fieldn,
|
||||
const StructDef *parent_struct_def,
|
||||
uoffset_t count,
|
||||
size_t count,
|
||||
bool inside_vector = false);
|
||||
template<typename F>
|
||||
FLATBUFFERS_CHECKED_ERROR ParseTableDelimiters(size_t &fieldn,
|
||||
@@ -1074,7 +1093,7 @@ class Parser : public ParserState {
|
||||
void SerializeStruct(FlatBufferBuilder &builder, const StructDef &struct_def,
|
||||
const Value &val);
|
||||
template<typename F>
|
||||
FLATBUFFERS_CHECKED_ERROR ParseVectorDelimiters(uoffset_t &count, F body);
|
||||
FLATBUFFERS_CHECKED_ERROR ParseVectorDelimiters(size_t &count, F body);
|
||||
FLATBUFFERS_CHECKED_ERROR ParseVector(const Type &type, uoffset_t *ovalue,
|
||||
FieldDef *field, size_t fieldn);
|
||||
FLATBUFFERS_CHECKED_ERROR ParseArray(Value &array);
|
||||
@@ -1139,6 +1158,8 @@ class Parser : public ParserState {
|
||||
bool SupportsAdvancedArrayFeatures() const;
|
||||
bool SupportsOptionalScalars() const;
|
||||
bool SupportsDefaultVectorsAndStrings() const;
|
||||
bool Supports64BitOffsets() const;
|
||||
bool SupportsUnionUnderlyingType() const;
|
||||
Namespace *UniqueNamespace(Namespace *ns);
|
||||
|
||||
FLATBUFFERS_CHECKED_ERROR RecurseError();
|
||||
@@ -1198,9 +1219,11 @@ class Parser : public ParserState {
|
||||
// if it is less than 0, no linefeeds will be generated either.
|
||||
// See idl_gen_text.cpp.
|
||||
// strict_json adds "quotes" around field names if true.
|
||||
// If the flatbuffer cannot be encoded in JSON (e.g., it contains non-UTF-8
|
||||
// byte arrays in String values), returns false.
|
||||
extern const char *GenerateTextFromTable(const Parser &parser, const void *table,
|
||||
// These functions return nullptr on success, or an error string,
|
||||
// which may happen if the flatbuffer cannot be encoded in JSON (e.g.,
|
||||
// it contains non-UTF-8 byte arrays in String values).
|
||||
extern bool GenerateTextFromTable(const Parser &parser,
|
||||
const void *table,
|
||||
const std::string &tablename,
|
||||
std::string *text);
|
||||
extern const char *GenerateText(const Parser &parser, const void *flatbuffer,
|
||||
@@ -1209,127 +1232,14 @@ extern const char *GenerateTextFile(const Parser &parser,
|
||||
const std::string &path,
|
||||
const std::string &file_name);
|
||||
|
||||
// Generate Json schema to string
|
||||
// See idl_gen_json_schema.cpp.
|
||||
extern bool GenerateJsonSchema(const Parser &parser, std::string *json);
|
||||
|
||||
// Generate binary files from a given FlatBuffer, and a given Parser
|
||||
// object that has been populated with the corresponding schema.
|
||||
// See code_generators.cpp.
|
||||
extern bool GenerateBinary(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name);
|
||||
|
||||
// Generate a C++ header from the definitions in the Parser object.
|
||||
// See idl_gen_cpp.
|
||||
extern bool GenerateCPP(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name);
|
||||
|
||||
// Generate C# files from the definitions in the Parser object.
|
||||
// See idl_gen_csharp.cpp.
|
||||
extern bool GenerateCSharp(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name);
|
||||
|
||||
extern bool GenerateDart(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name);
|
||||
|
||||
// Generate Java files from the definitions in the Parser object.
|
||||
// See idl_gen_java.cpp.
|
||||
extern bool GenerateJava(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name);
|
||||
|
||||
// Generate JavaScript or TypeScript code from the definitions in the Parser
|
||||
// object. See idl_gen_js.
|
||||
extern bool GenerateTS(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name);
|
||||
|
||||
// Generate Go files from the definitions in the Parser object.
|
||||
// See idl_gen_go.cpp.
|
||||
extern bool GenerateGo(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name);
|
||||
|
||||
// Generate Php code from the definitions in the Parser object.
|
||||
// See idl_gen_php.
|
||||
extern bool GeneratePhp(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name);
|
||||
|
||||
// Generate Python files from the definitions in the Parser object.
|
||||
// See idl_gen_python.cpp.
|
||||
extern bool GeneratePython(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name);
|
||||
|
||||
// Generate Lobster files from the definitions in the Parser object.
|
||||
// See idl_gen_lobster.cpp.
|
||||
extern bool GenerateLobster(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name);
|
||||
|
||||
// Generate Lua files from the definitions in the Parser object.
|
||||
// See idl_gen_lua.cpp.
|
||||
extern bool GenerateLua(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name);
|
||||
|
||||
// Generate Rust files from the definitions in the Parser object.
|
||||
// See idl_gen_rust.cpp.
|
||||
extern bool GenerateRust(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name);
|
||||
|
||||
// Generate Json schema file
|
||||
// See idl_gen_json_schema.cpp.
|
||||
extern bool GenerateJsonSchema(const Parser &parser, const std::string &path,
|
||||
extern const char *GenTextFromTable(const Parser &parser, const void *table,
|
||||
const std::string &tablename,
|
||||
std::string *text);
|
||||
extern const char *GenText(const Parser &parser, const void *flatbuffer,
|
||||
std::string *text);
|
||||
extern const char *GenTextFile(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name);
|
||||
|
||||
extern bool GenerateKotlin(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name);
|
||||
|
||||
// Generate Swift classes.
|
||||
// See idl_gen_swift.cpp
|
||||
extern bool GenerateSwift(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name);
|
||||
|
||||
// Generate a schema file from the internal representation, useful after
|
||||
// parsing a .proto schema.
|
||||
extern std::string GenerateFBS(const Parser &parser,
|
||||
const std::string &file_name,
|
||||
bool no_log);
|
||||
extern bool GenerateFBS(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name, bool no_log);
|
||||
|
||||
// Generate a make rule for the generated TypeScript code.
|
||||
// See idl_gen_ts.cpp.
|
||||
extern std::string TSMakeRule(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name);
|
||||
|
||||
// Generate a make rule for the generated C++ header.
|
||||
// See idl_gen_cpp.cpp.
|
||||
extern std::string CPPMakeRule(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name);
|
||||
|
||||
// Generate a make rule for the generated Dart code
|
||||
// see idl_gen_dart.cpp
|
||||
extern std::string DartMakeRule(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name);
|
||||
|
||||
// Generate a make rule for the generated Rust code.
|
||||
// See idl_gen_rust.cpp.
|
||||
extern std::string RustMakeRule(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name);
|
||||
|
||||
// Generate a make rule for generated Java or C# files.
|
||||
// See code_generators.cpp.
|
||||
extern std::string CSharpMakeRule(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name);
|
||||
extern std::string JavaMakeRule(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name);
|
||||
|
||||
// Generate a make rule for the generated text (JSON) files.
|
||||
// See idl_gen_text.cpp.
|
||||
extern std::string TextMakeRule(const Parser &parser, const std::string &path,
|
||||
const std::string &file_names);
|
||||
|
||||
// Generate a make rule for the generated binary files.
|
||||
// See code_generators.cpp.
|
||||
extern std::string BinaryMakeRule(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name);
|
||||
|
||||
// Generate GRPC Cpp interfaces.
|
||||
// See idl_gen_grpc.cpp.
|
||||
bool GenerateCppGRPC(const Parser &parser, const std::string &path,
|
||||
@@ -1357,9 +1267,6 @@ extern bool GenerateSwiftGRPC(const Parser &parser, const std::string &path,
|
||||
|
||||
extern bool GenerateTSGRPC(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name);
|
||||
|
||||
extern bool GenerateRustModuleRootFile(const Parser &parser,
|
||||
const std::string &path);
|
||||
} // namespace flatbuffers
|
||||
|
||||
#endif // FLATBUFFERS_IDL_H_
|
||||
|
||||
@@ -408,8 +408,9 @@ inline std::string FlatBufferToString(const uint8_t *buffer,
|
||||
const TypeTable *type_table,
|
||||
bool multi_line = false,
|
||||
bool vector_delimited = true,
|
||||
const std::string &indent = "") {
|
||||
ToStringVisitor tostring_visitor(multi_line ? "\n" : " ", false, indent,
|
||||
const std::string &indent = "",
|
||||
bool quotes = false) {
|
||||
ToStringVisitor tostring_visitor(multi_line ? "\n" : " ", quotes, indent,
|
||||
vector_delimited);
|
||||
IterateFlatBuffer(buffer, type_table, &tostring_visitor);
|
||||
return tostring_visitor.s;
|
||||
|
||||
@@ -66,6 +66,7 @@ inline size_t GetTypeSize(reflection::BaseType base_type) {
|
||||
4, // Union
|
||||
0, // Array. Only used in structs. 0 was chosen to prevent out-of-bounds
|
||||
// errors.
|
||||
8, // Vector64
|
||||
|
||||
0 // MaxBaseType. This must be kept the last entry in this array.
|
||||
};
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
|
||||
// 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 == 23 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 5 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 8,
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 24 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 3 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 7,
|
||||
"Non-compatible flatbuffers version included");
|
||||
|
||||
namespace reflection {
|
||||
@@ -64,10 +64,11 @@ enum BaseType {
|
||||
Obj = 15,
|
||||
Union = 16,
|
||||
Array = 17,
|
||||
MaxBaseType = 18
|
||||
Vector64 = 18,
|
||||
MaxBaseType = 19
|
||||
};
|
||||
|
||||
inline const BaseType (&EnumValuesBaseType())[19] {
|
||||
inline const BaseType (&EnumValuesBaseType())[20] {
|
||||
static const BaseType values[] = {
|
||||
None,
|
||||
UType,
|
||||
@@ -87,13 +88,14 @@ inline const BaseType (&EnumValuesBaseType())[19] {
|
||||
Obj,
|
||||
Union,
|
||||
Array,
|
||||
Vector64,
|
||||
MaxBaseType
|
||||
};
|
||||
return values;
|
||||
}
|
||||
|
||||
inline const char * const *EnumNamesBaseType() {
|
||||
static const char * const names[20] = {
|
||||
static const char * const names[21] = {
|
||||
"None",
|
||||
"UType",
|
||||
"Bool",
|
||||
@@ -112,6 +114,7 @@ inline const char * const *EnumNamesBaseType() {
|
||||
"Obj",
|
||||
"Union",
|
||||
"Array",
|
||||
"Vector64",
|
||||
"MaxBaseType",
|
||||
nullptr
|
||||
};
|
||||
@@ -601,7 +604,8 @@ struct Field FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
VT_ATTRIBUTES = 22,
|
||||
VT_DOCUMENTATION = 24,
|
||||
VT_OPTIONAL = 26,
|
||||
VT_PADDING = 28
|
||||
VT_PADDING = 28,
|
||||
VT_OFFSET64 = 30
|
||||
};
|
||||
const ::flatbuffers::String *name() const {
|
||||
return GetPointer<const ::flatbuffers::String *>(VT_NAME);
|
||||
@@ -649,6 +653,10 @@ struct Field FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
uint16_t padding() const {
|
||||
return GetField<uint16_t>(VT_PADDING, 0);
|
||||
}
|
||||
/// If the field uses 64-bit offsets.
|
||||
bool offset64() const {
|
||||
return GetField<uint8_t>(VT_OFFSET64, 0) != 0;
|
||||
}
|
||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyOffsetRequired(verifier, VT_NAME) &&
|
||||
@@ -670,6 +678,7 @@ struct Field FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
verifier.VerifyVectorOfStrings(documentation()) &&
|
||||
VerifyField<uint8_t>(verifier, VT_OPTIONAL, 1) &&
|
||||
VerifyField<uint16_t>(verifier, VT_PADDING, 2) &&
|
||||
VerifyField<uint8_t>(verifier, VT_OFFSET64, 1) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
@@ -717,6 +726,9 @@ struct FieldBuilder {
|
||||
void add_padding(uint16_t padding) {
|
||||
fbb_.AddElement<uint16_t>(Field::VT_PADDING, padding, 0);
|
||||
}
|
||||
void add_offset64(bool offset64) {
|
||||
fbb_.AddElement<uint8_t>(Field::VT_OFFSET64, static_cast<uint8_t>(offset64), 0);
|
||||
}
|
||||
explicit FieldBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
@@ -744,7 +756,8 @@ inline ::flatbuffers::Offset<Field> CreateField(
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<reflection::KeyValue>>> attributes = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<::flatbuffers::String>>> documentation = 0,
|
||||
bool optional = false,
|
||||
uint16_t padding = 0) {
|
||||
uint16_t padding = 0,
|
||||
bool offset64 = false) {
|
||||
FieldBuilder builder_(_fbb);
|
||||
builder_.add_default_real(default_real);
|
||||
builder_.add_default_integer(default_integer);
|
||||
@@ -755,6 +768,7 @@ inline ::flatbuffers::Offset<Field> CreateField(
|
||||
builder_.add_padding(padding);
|
||||
builder_.add_offset(offset);
|
||||
builder_.add_id(id);
|
||||
builder_.add_offset64(offset64);
|
||||
builder_.add_optional(optional);
|
||||
builder_.add_key(key);
|
||||
builder_.add_required(required);
|
||||
@@ -776,7 +790,8 @@ inline ::flatbuffers::Offset<Field> CreateFieldDirect(
|
||||
std::vector<::flatbuffers::Offset<reflection::KeyValue>> *attributes = nullptr,
|
||||
const std::vector<::flatbuffers::Offset<::flatbuffers::String>> *documentation = nullptr,
|
||||
bool optional = false,
|
||||
uint16_t padding = 0) {
|
||||
uint16_t padding = 0,
|
||||
bool offset64 = false) {
|
||||
auto name__ = name ? _fbb.CreateString(name) : 0;
|
||||
auto attributes__ = attributes ? _fbb.CreateVectorOfSortedTables<reflection::KeyValue>(attributes) : 0;
|
||||
auto documentation__ = documentation ? _fbb.CreateVector<::flatbuffers::Offset<::flatbuffers::String>>(*documentation) : 0;
|
||||
@@ -794,7 +809,8 @@ inline ::flatbuffers::Offset<Field> CreateFieldDirect(
|
||||
attributes__,
|
||||
documentation__,
|
||||
optional,
|
||||
padding);
|
||||
padding,
|
||||
offset64);
|
||||
}
|
||||
|
||||
struct Object FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
|
||||
@@ -52,10 +52,10 @@ class Registry {
|
||||
Parser parser;
|
||||
if (!LoadSchema(ident, &parser)) return false;
|
||||
// Now we're ready to generate text.
|
||||
auto err = GenerateText(parser, flatbuf, dest);
|
||||
auto err = GenText(parser, flatbuf, dest);
|
||||
if (err) {
|
||||
lasterror_ = "unable to generate text for FlatBuffer binary: " +
|
||||
std::string(err);
|
||||
lasterror_ =
|
||||
"unable to generate text for FlatBuffer binary: " + std::string(err);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -45,7 +45,8 @@
|
||||
// Testing __cpp_lib_span requires including either <version> or <span>,
|
||||
// both of which were added in C++20.
|
||||
// See: https://en.cppreference.com/w/cpp/utility/feature_test
|
||||
#if defined(__cplusplus) && __cplusplus >= 202002L
|
||||
#if defined(__cplusplus) && __cplusplus >= 202002L \
|
||||
|| (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
|
||||
#define FLATBUFFERS_USE_STD_SPAN 1
|
||||
#endif
|
||||
#endif // FLATBUFFERS_USE_STD_SPAN
|
||||
|
||||
@@ -31,6 +31,11 @@ struct String : public Vector<char> {
|
||||
flatbuffers::string_view string_view() const {
|
||||
return flatbuffers::string_view(c_str(), size());
|
||||
}
|
||||
|
||||
/* implicit */
|
||||
operator flatbuffers::string_view() const {
|
||||
return flatbuffers::string_view(c_str(), size());
|
||||
}
|
||||
#endif // FLATBUFFERS_HAS_STRING_VIEW
|
||||
// clang-format on
|
||||
|
||||
|
||||
@@ -47,14 +47,24 @@ class Table {
|
||||
return field_offset ? ReadScalar<T>(data_ + field_offset) : defaultval;
|
||||
}
|
||||
|
||||
template<typename P> P GetPointer(voffset_t field) {
|
||||
template<typename P, typename OffsetSize = uoffset_t>
|
||||
P GetPointer(voffset_t field) {
|
||||
auto field_offset = GetOptionalFieldOffset(field);
|
||||
auto p = data_ + field_offset;
|
||||
return field_offset ? reinterpret_cast<P>(p + ReadScalar<uoffset_t>(p))
|
||||
return field_offset ? reinterpret_cast<P>(p + ReadScalar<OffsetSize>(p))
|
||||
: nullptr;
|
||||
}
|
||||
template<typename P> P GetPointer(voffset_t field) const {
|
||||
return const_cast<Table *>(this)->GetPointer<P>(field);
|
||||
template<typename P, typename OffsetSize = uoffset_t>
|
||||
P GetPointer(voffset_t field) const {
|
||||
return const_cast<Table *>(this)->GetPointer<P, OffsetSize>(field);
|
||||
}
|
||||
|
||||
template<typename P> P GetPointer64(voffset_t field) {
|
||||
return GetPointer<P, uoffset64_t>(field);
|
||||
}
|
||||
|
||||
template<typename P> P GetPointer64(voffset_t field) const {
|
||||
return GetPointer<P, uoffset64_t>(field);
|
||||
}
|
||||
|
||||
template<typename P> P GetStruct(voffset_t field) const {
|
||||
@@ -131,15 +141,25 @@ class Table {
|
||||
}
|
||||
|
||||
// Versions for offsets.
|
||||
template<typename OffsetT = uoffset_t>
|
||||
bool VerifyOffset(const Verifier &verifier, voffset_t field) const {
|
||||
auto field_offset = GetOptionalFieldOffset(field);
|
||||
return !field_offset || verifier.VerifyOffset(data_, field_offset);
|
||||
return !field_offset || verifier.VerifyOffset<OffsetT>(data_, field_offset);
|
||||
}
|
||||
|
||||
template<typename OffsetT = uoffset_t>
|
||||
bool VerifyOffsetRequired(const Verifier &verifier, voffset_t field) const {
|
||||
auto field_offset = GetOptionalFieldOffset(field);
|
||||
return verifier.Check(field_offset != 0) &&
|
||||
verifier.VerifyOffset(data_, field_offset);
|
||||
verifier.VerifyOffset<OffsetT>(data_, field_offset);
|
||||
}
|
||||
|
||||
bool VerifyOffset64(const Verifier &verifier, voffset_t field) const {
|
||||
return VerifyOffset<uoffset64_t>(verifier, field);
|
||||
}
|
||||
|
||||
bool VerifyOffset64Required(const Verifier &verifier, voffset_t field) const {
|
||||
return VerifyOffsetRequired<uoffset64_t>(verifier, field);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -257,7 +257,7 @@ inline void strtoval_impl(double *val, const char *str, char **endptr) {
|
||||
}
|
||||
|
||||
// UBSAN: double to float is safe if numeric_limits<float>::is_iec559 is true.
|
||||
__suppress_ubsan__("float-cast-overflow")
|
||||
FLATBUFFERS_SUPPRESS_UBSAN("float-cast-overflow")
|
||||
inline void strtoval_impl(float *val, const char *str, char **endptr) {
|
||||
*val = __strtof_impl(str, endptr);
|
||||
}
|
||||
@@ -479,6 +479,11 @@ std::string PosixPath(const std::string &path);
|
||||
// creating dirs for any parts of the path that don't exist yet.
|
||||
void EnsureDirExists(const std::string &filepath);
|
||||
|
||||
// Obtains the relative or absolute path.
|
||||
std::string FilePath(const std::string &project,
|
||||
const std::string &filePath,
|
||||
bool absolute);
|
||||
|
||||
// Obtains the absolute path from any other path.
|
||||
// Returns the input path if the absolute path couldn't be resolved.
|
||||
std::string AbsolutePath(const std::string &filepath);
|
||||
@@ -623,7 +628,7 @@ inline bool EscapeString(const char *s, size_t length, std::string *_text,
|
||||
// we previously checked for non-UTF-8, so we shouldn't reach
|
||||
// here.
|
||||
//
|
||||
// 2) We reached here by someone calling GenerateText()
|
||||
// 2) We reached here by someone calling GenText()
|
||||
// on a previously-serialized flatbuffer. The data might have
|
||||
// non-UTF-8 Strings, or might be corrupt.
|
||||
//
|
||||
|
||||
@@ -27,7 +27,8 @@ struct String;
|
||||
|
||||
// An STL compatible iterator implementation for Vector below, effectively
|
||||
// calling Get() for every element.
|
||||
template<typename T, typename IT, typename Data = uint8_t *>
|
||||
template<typename T, typename IT, typename Data = uint8_t *,
|
||||
typename SizeT = uoffset_t>
|
||||
struct VectorIterator {
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
typedef IT value_type;
|
||||
@@ -35,8 +36,9 @@ struct VectorIterator {
|
||||
typedef IT *pointer;
|
||||
typedef IT &reference;
|
||||
|
||||
VectorIterator(Data data, uoffset_t i)
|
||||
: data_(data + IndirectHelper<T>::element_stride * i) {}
|
||||
static const SizeT element_stride = IndirectHelper<T>::element_stride;
|
||||
|
||||
VectorIterator(Data data, SizeT i) : data_(data + element_stride * i) {}
|
||||
VectorIterator(const VectorIterator &other) : data_(other.data_) {}
|
||||
VectorIterator() : data_(nullptr) {}
|
||||
|
||||
@@ -63,7 +65,7 @@ struct VectorIterator {
|
||||
}
|
||||
|
||||
difference_type operator-(const VectorIterator &other) const {
|
||||
return (data_ - other.data_) / IndirectHelper<T>::element_stride;
|
||||
return (data_ - other.data_) / element_stride;
|
||||
}
|
||||
|
||||
// Note: return type is incompatible with the standard
|
||||
@@ -75,44 +77,42 @@ struct VectorIterator {
|
||||
IT operator->() const { return IndirectHelper<T>::Read(data_, 0); }
|
||||
|
||||
VectorIterator &operator++() {
|
||||
data_ += IndirectHelper<T>::element_stride;
|
||||
data_ += element_stride;
|
||||
return *this;
|
||||
}
|
||||
|
||||
VectorIterator operator++(int) {
|
||||
VectorIterator temp(data_, 0);
|
||||
data_ += IndirectHelper<T>::element_stride;
|
||||
data_ += element_stride;
|
||||
return temp;
|
||||
}
|
||||
|
||||
VectorIterator operator+(const uoffset_t &offset) const {
|
||||
return VectorIterator(data_ + offset * IndirectHelper<T>::element_stride,
|
||||
0);
|
||||
VectorIterator operator+(const SizeT &offset) const {
|
||||
return VectorIterator(data_ + offset * element_stride, 0);
|
||||
}
|
||||
|
||||
VectorIterator &operator+=(const uoffset_t &offset) {
|
||||
data_ += offset * IndirectHelper<T>::element_stride;
|
||||
VectorIterator &operator+=(const SizeT &offset) {
|
||||
data_ += offset * element_stride;
|
||||
return *this;
|
||||
}
|
||||
|
||||
VectorIterator &operator--() {
|
||||
data_ -= IndirectHelper<T>::element_stride;
|
||||
data_ -= element_stride;
|
||||
return *this;
|
||||
}
|
||||
|
||||
VectorIterator operator--(int) {
|
||||
VectorIterator temp(data_, 0);
|
||||
data_ -= IndirectHelper<T>::element_stride;
|
||||
data_ -= element_stride;
|
||||
return temp;
|
||||
}
|
||||
|
||||
VectorIterator operator-(const uoffset_t &offset) const {
|
||||
return VectorIterator(data_ - offset * IndirectHelper<T>::element_stride,
|
||||
0);
|
||||
VectorIterator operator-(const SizeT &offset) const {
|
||||
return VectorIterator(data_ - offset * element_stride, 0);
|
||||
}
|
||||
|
||||
VectorIterator &operator-=(const uoffset_t &offset) {
|
||||
data_ -= offset * IndirectHelper<T>::element_stride;
|
||||
VectorIterator &operator-=(const SizeT &offset) {
|
||||
data_ -= offset * element_stride;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -120,8 +120,8 @@ struct VectorIterator {
|
||||
Data data_;
|
||||
};
|
||||
|
||||
template<typename T, typename IT>
|
||||
using VectorConstIterator = VectorIterator<T, IT, const uint8_t *>;
|
||||
template<typename T, typename IT, typename SizeT = uoffset_t>
|
||||
using VectorConstIterator = VectorIterator<T, IT, const uint8_t *, SizeT>;
|
||||
|
||||
template<typename Iterator>
|
||||
struct VectorReverseIterator : public std::reverse_iterator<Iterator> {
|
||||
@@ -145,11 +145,12 @@ struct VectorReverseIterator : public std::reverse_iterator<Iterator> {
|
||||
|
||||
// This is used as a helper type for accessing vectors.
|
||||
// Vector::data() assumes the vector elements start after the length field.
|
||||
template<typename T> class Vector {
|
||||
template<typename T, typename SizeT = uoffset_t> class Vector {
|
||||
public:
|
||||
typedef VectorIterator<T, typename IndirectHelper<T>::mutable_return_type>
|
||||
typedef VectorIterator<T, typename IndirectHelper<T>::mutable_return_type,
|
||||
uint8_t *, SizeT>
|
||||
iterator;
|
||||
typedef VectorConstIterator<T, typename IndirectHelper<T>::return_type>
|
||||
typedef VectorConstIterator<T, typename IndirectHelper<T>::return_type, SizeT>
|
||||
const_iterator;
|
||||
typedef VectorReverseIterator<iterator> reverse_iterator;
|
||||
typedef VectorReverseIterator<const_iterator> const_reverse_iterator;
|
||||
@@ -160,39 +161,40 @@ template<typename T> class Vector {
|
||||
static FLATBUFFERS_CONSTEXPR bool is_span_observable =
|
||||
scalar_tag::value && (FLATBUFFERS_LITTLEENDIAN || sizeof(T) == 1);
|
||||
|
||||
uoffset_t size() const { return EndianScalar(length_); }
|
||||
SizeT size() const { return EndianScalar(length_); }
|
||||
|
||||
// Deprecated: use size(). Here for backwards compatibility.
|
||||
FLATBUFFERS_ATTRIBUTE([[deprecated("use size() instead")]])
|
||||
uoffset_t Length() const { return size(); }
|
||||
SizeT Length() const { return size(); }
|
||||
|
||||
typedef SizeT size_type;
|
||||
typedef typename IndirectHelper<T>::return_type return_type;
|
||||
typedef typename IndirectHelper<T>::mutable_return_type mutable_return_type;
|
||||
typedef return_type value_type;
|
||||
|
||||
return_type Get(uoffset_t i) const {
|
||||
return_type Get(SizeT i) const {
|
||||
FLATBUFFERS_ASSERT(i < size());
|
||||
return IndirectHelper<T>::Read(Data(), i);
|
||||
}
|
||||
|
||||
return_type operator[](uoffset_t i) const { return Get(i); }
|
||||
return_type operator[](SizeT i) const { return Get(i); }
|
||||
|
||||
// If this is a Vector of enums, T will be its storage type, not the enum
|
||||
// type. This function makes it convenient to retrieve value with enum
|
||||
// type E.
|
||||
template<typename E> E GetEnum(uoffset_t i) const {
|
||||
template<typename E> E GetEnum(SizeT i) const {
|
||||
return static_cast<E>(Get(i));
|
||||
}
|
||||
|
||||
// If this a vector of unions, this does the cast for you. There's no check
|
||||
// to make sure this is the right type!
|
||||
template<typename U> const U *GetAs(uoffset_t i) const {
|
||||
template<typename U> const U *GetAs(SizeT i) const {
|
||||
return reinterpret_cast<const U *>(Get(i));
|
||||
}
|
||||
|
||||
// If this a vector of unions, this does the cast for you. There's no check
|
||||
// to make sure this is actually a string!
|
||||
const String *GetAsString(uoffset_t i) const {
|
||||
const String *GetAsString(SizeT i) const {
|
||||
return reinterpret_cast<const String *>(Get(i));
|
||||
}
|
||||
|
||||
@@ -226,7 +228,7 @@ template<typename T> class Vector {
|
||||
|
||||
// Change elements if you have a non-const pointer to this object.
|
||||
// Scalars only. See reflection.h, and the documentation.
|
||||
void Mutate(uoffset_t i, const T &val) {
|
||||
void Mutate(SizeT i, const T &val) {
|
||||
FLATBUFFERS_ASSERT(i < size());
|
||||
WriteScalar(data() + i, val);
|
||||
}
|
||||
@@ -234,15 +236,15 @@ template<typename T> class Vector {
|
||||
// Change an element of a vector of tables (or strings).
|
||||
// "val" points to the new table/string, as you can obtain from
|
||||
// e.g. reflection::AddFlatBuffer().
|
||||
void MutateOffset(uoffset_t i, const uint8_t *val) {
|
||||
void MutateOffset(SizeT i, const uint8_t *val) {
|
||||
FLATBUFFERS_ASSERT(i < size());
|
||||
static_assert(sizeof(T) == sizeof(uoffset_t), "Unrelated types");
|
||||
static_assert(sizeof(T) == sizeof(SizeT), "Unrelated types");
|
||||
WriteScalar(data() + i,
|
||||
static_cast<uoffset_t>(val - (Data() + i * sizeof(uoffset_t))));
|
||||
static_cast<SizeT>(val - (Data() + i * sizeof(SizeT))));
|
||||
}
|
||||
|
||||
// Get a mutable pointer to tables/strings inside this vector.
|
||||
mutable_return_type GetMutableObject(uoffset_t i) const {
|
||||
mutable_return_type GetMutableObject(SizeT i) const {
|
||||
FLATBUFFERS_ASSERT(i < size());
|
||||
return const_cast<mutable_return_type>(IndirectHelper<T>::Read(Data(), i));
|
||||
}
|
||||
@@ -280,7 +282,7 @@ template<typename T> class Vector {
|
||||
// try to construct these manually.
|
||||
Vector();
|
||||
|
||||
uoffset_t length_;
|
||||
SizeT length_;
|
||||
|
||||
private:
|
||||
// This class is a pointer. Copying will therefore create an invalid object.
|
||||
@@ -299,6 +301,8 @@ template<typename T> class Vector {
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T> using Vector64 = Vector<T, uoffset64_t>;
|
||||
|
||||
template<class U>
|
||||
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<U> make_span(Vector<U> &vec)
|
||||
FLATBUFFERS_NOEXCEPT {
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#define FLATBUFFERS_VECTOR_DOWNWARD_H_
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
|
||||
#include "flatbuffers/base.h"
|
||||
#include "flatbuffers/default_allocator.h"
|
||||
@@ -31,13 +32,15 @@ namespace flatbuffers {
|
||||
// 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.
|
||||
// Essentially, this supports 2 std::vectors in a single buffer.
|
||||
class vector_downward {
|
||||
template<typename SizeT = uoffset_t> class vector_downward {
|
||||
public:
|
||||
explicit vector_downward(size_t initial_size, Allocator *allocator,
|
||||
bool own_allocator, size_t buffer_minalign)
|
||||
bool own_allocator, size_t buffer_minalign,
|
||||
const SizeT max_size = FLATBUFFERS_MAX_BUFFER_SIZE)
|
||||
: allocator_(allocator),
|
||||
own_allocator_(own_allocator),
|
||||
initial_size_(initial_size),
|
||||
max_size_(max_size),
|
||||
buffer_minalign_(buffer_minalign),
|
||||
reserved_(0),
|
||||
size_(0),
|
||||
@@ -50,6 +53,7 @@ class vector_downward {
|
||||
: allocator_(other.allocator_),
|
||||
own_allocator_(other.own_allocator_),
|
||||
initial_size_(other.initial_size_),
|
||||
max_size_(other.max_size_),
|
||||
buffer_minalign_(other.buffer_minalign_),
|
||||
reserved_(other.reserved_),
|
||||
size_(other.size_),
|
||||
@@ -111,7 +115,7 @@ class vector_downward {
|
||||
uint8_t *release_raw(size_t &allocated_bytes, size_t &offset) {
|
||||
auto *buf = buf_;
|
||||
allocated_bytes = reserved_;
|
||||
offset = static_cast<size_t>(cur_ - buf_);
|
||||
offset = vector_downward::offset();
|
||||
|
||||
// release_raw only relinquishes the buffer ownership.
|
||||
// Does not deallocate or reset the allocator. Destructor will do that.
|
||||
@@ -136,10 +140,10 @@ class vector_downward {
|
||||
|
||||
size_t ensure_space(size_t len) {
|
||||
FLATBUFFERS_ASSERT(cur_ >= scratch_ && scratch_ >= buf_);
|
||||
if (len > static_cast<size_t>(cur_ - scratch_)) { reallocate(len); }
|
||||
// Beyond this, signed offsets may not have enough range:
|
||||
// (FlatBuffers > 2GB not supported).
|
||||
FLATBUFFERS_ASSERT(size() < FLATBUFFERS_MAX_BUFFER_SIZE);
|
||||
// If the length is larger than the unused part of the buffer, we need to
|
||||
// grow.
|
||||
if (len > unused_buffer_size()) { reallocate(len); }
|
||||
FLATBUFFERS_ASSERT(size() < max_size_);
|
||||
return len;
|
||||
}
|
||||
|
||||
@@ -147,7 +151,7 @@ class vector_downward {
|
||||
if (len) {
|
||||
ensure_space(len);
|
||||
cur_ -= len;
|
||||
size_ += static_cast<uoffset_t>(len);
|
||||
size_ += static_cast<SizeT>(len);
|
||||
}
|
||||
return cur_;
|
||||
}
|
||||
@@ -155,12 +159,20 @@ class vector_downward {
|
||||
// Returns nullptr if using the DefaultAllocator.
|
||||
Allocator *get_custom_allocator() { return allocator_; }
|
||||
|
||||
inline uoffset_t size() const { return size_; }
|
||||
// The current offset into the buffer.
|
||||
size_t offset() const { return cur_ - buf_; }
|
||||
|
||||
uoffset_t scratch_size() const {
|
||||
return static_cast<uoffset_t>(scratch_ - buf_);
|
||||
// The total size of the vector (both the buffer and scratch parts).
|
||||
inline SizeT size() const { return size_; }
|
||||
|
||||
// The size of the buffer part of the vector that is currently unused.
|
||||
SizeT unused_buffer_size() const {
|
||||
return static_cast<SizeT>(cur_ - scratch_);
|
||||
}
|
||||
|
||||
// The size of the scratch part of the vector.
|
||||
SizeT scratch_size() const { return static_cast<SizeT>(scratch_ - buf_); }
|
||||
|
||||
size_t capacity() const { return reserved_; }
|
||||
|
||||
uint8_t *data() const {
|
||||
@@ -211,7 +223,7 @@ class vector_downward {
|
||||
|
||||
void pop(size_t bytes_to_remove) {
|
||||
cur_ += bytes_to_remove;
|
||||
size_ -= static_cast<uoffset_t>(bytes_to_remove);
|
||||
size_ -= static_cast<SizeT>(bytes_to_remove);
|
||||
}
|
||||
|
||||
void scratch_pop(size_t bytes_to_remove) { scratch_ -= bytes_to_remove; }
|
||||
@@ -224,6 +236,7 @@ class vector_downward {
|
||||
swap(buffer_minalign_, other.buffer_minalign_);
|
||||
swap(reserved_, other.reserved_);
|
||||
swap(size_, other.size_);
|
||||
swap(max_size_, other.max_size_);
|
||||
swap(buf_, other.buf_);
|
||||
swap(cur_, other.cur_);
|
||||
swap(scratch_, other.scratch_);
|
||||
@@ -243,9 +256,12 @@ class vector_downward {
|
||||
Allocator *allocator_;
|
||||
bool own_allocator_;
|
||||
size_t initial_size_;
|
||||
|
||||
// The maximum size the vector can be.
|
||||
SizeT max_size_;
|
||||
size_t buffer_minalign_;
|
||||
size_t reserved_;
|
||||
uoffset_t size_;
|
||||
SizeT size_;
|
||||
uint8_t *buf_;
|
||||
uint8_t *cur_; // Points at location between empty (below) and used (above).
|
||||
uint8_t *scratch_; // Points to the end of the scratchpad in use.
|
||||
|
||||
@@ -34,12 +34,16 @@ class Verifier FLATBUFFERS_FINAL_CLASS {
|
||||
bool check_alignment = true;
|
||||
// If true, run verifier on nested flatbuffers
|
||||
bool check_nested_flatbuffers = true;
|
||||
// The maximum size of a buffer.
|
||||
size_t max_size = FLATBUFFERS_MAX_BUFFER_SIZE;
|
||||
// Use assertions to check for errors.
|
||||
bool assert = false;
|
||||
};
|
||||
|
||||
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);
|
||||
FLATBUFFERS_ASSERT(size_ < opts.max_size);
|
||||
}
|
||||
|
||||
// Deprecated API, please construct with Verifier::Options.
|
||||
@@ -58,7 +62,7 @@ class Verifier FLATBUFFERS_FINAL_CLASS {
|
||||
bool Check(const bool ok) const {
|
||||
// clang-format off
|
||||
#ifdef FLATBUFFERS_DEBUG_VERIFICATION_FAILURE
|
||||
FLATBUFFERS_ASSERT(ok);
|
||||
if (opts_.assert) { FLATBUFFERS_ASSERT(ok); }
|
||||
#endif
|
||||
#ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
|
||||
if (!ok)
|
||||
@@ -113,41 +117,43 @@ class Verifier FLATBUFFERS_FINAL_CLASS {
|
||||
}
|
||||
|
||||
// Verify a pointer (may be NULL) of any vector type.
|
||||
template<typename T> bool VerifyVector(const Vector<T> *const vec) const {
|
||||
return !vec || VerifyVectorOrString(reinterpret_cast<const uint8_t *>(vec),
|
||||
sizeof(T));
|
||||
template<int &..., typename T, typename LenT>
|
||||
bool VerifyVector(const Vector<T, LenT> *const vec) const {
|
||||
return !vec || VerifyVectorOrString<LenT>(
|
||||
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 *> *const vec) const {
|
||||
return VerifyVector(reinterpret_cast<const Vector<T> *>(vec));
|
||||
template<int &..., typename T, typename LenT>
|
||||
bool VerifyVector(const Vector<const T *, LenT> *const vec) const {
|
||||
return VerifyVector(reinterpret_cast<const Vector<T, LenT> *>(vec));
|
||||
}
|
||||
|
||||
// Verify a pointer (may be NULL) to string.
|
||||
bool VerifyString(const String *const str) const {
|
||||
size_t end;
|
||||
return !str || (VerifyVectorOrString(reinterpret_cast<const uint8_t *>(str),
|
||||
1, &end) &&
|
||||
return !str || (VerifyVectorOrString<uoffset_t>(
|
||||
reinterpret_cast<const uint8_t *>(str), 1, &end) &&
|
||||
Verify(end, 1) && // Must have terminator
|
||||
Check(buf_[end] == '\0')); // Terminating byte must be 0.
|
||||
}
|
||||
|
||||
// Common code between vectors and strings.
|
||||
template<typename LenT = uoffset_t>
|
||||
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_);
|
||||
const auto vec_offset = static_cast<size_t>(vec - buf_);
|
||||
// Check we can read the size field.
|
||||
if (!Verify<uoffset_t>(veco)) return false;
|
||||
if (!Verify<LenT>(vec_offset)) return false;
|
||||
// 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;
|
||||
const LenT size = ReadScalar<LenT>(vec);
|
||||
const auto max_elems = opts_.max_size / elem_size;
|
||||
if (!Check(size < max_elems))
|
||||
return false; // Protect against byte_size overflowing.
|
||||
const auto byte_size = sizeof(size) + elem_size * size;
|
||||
if (end) *end = veco + byte_size;
|
||||
return Verify(veco, byte_size);
|
||||
const auto byte_size = sizeof(LenT) + elem_size * size;
|
||||
if (end) *end = vec_offset + byte_size;
|
||||
return Verify(vec_offset, byte_size);
|
||||
}
|
||||
|
||||
// Special case for string contents, after the above has been called.
|
||||
@@ -171,8 +177,8 @@ class Verifier FLATBUFFERS_FINAL_CLASS {
|
||||
return true;
|
||||
}
|
||||
|
||||
__suppress_ubsan__("unsigned-integer-overflow") bool VerifyTableStart(
|
||||
const uint8_t *const table) {
|
||||
FLATBUFFERS_SUPPRESS_UBSAN("unsigned-integer-overflow")
|
||||
bool VerifyTableStart(const uint8_t *const table) {
|
||||
// Check the vtable offset.
|
||||
const auto tableo = static_cast<size_t>(table - buf_);
|
||||
if (!Verify<soffset_t>(tableo)) return false;
|
||||
@@ -203,7 +209,7 @@ class Verifier FLATBUFFERS_FINAL_CLASS {
|
||||
}
|
||||
|
||||
// Call T::Verify, which must be in the generated code for this type.
|
||||
const auto o = VerifyOffset(start);
|
||||
const auto o = VerifyOffset<uoffset_t>(start);
|
||||
return Check(o != 0) &&
|
||||
reinterpret_cast<const T *>(buf_ + start + o)->Verify(*this)
|
||||
// clang-format off
|
||||
@@ -214,8 +220,8 @@ class Verifier FLATBUFFERS_FINAL_CLASS {
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool VerifyNestedFlatBuffer(const Vector<uint8_t> *const buf,
|
||||
template<typename T, int &..., typename SizeT>
|
||||
bool VerifyNestedFlatBuffer(const Vector<uint8_t, SizeT> *const buf,
|
||||
const char *const identifier) {
|
||||
// Caller opted out of this.
|
||||
if (!opts_.check_nested_flatbuffers) return true;
|
||||
@@ -226,7 +232,7 @@ class Verifier FLATBUFFERS_FINAL_CLASS {
|
||||
// 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());
|
||||
Verifier nested_verifier(buf->data(), buf->size(), opts_);
|
||||
return nested_verifier.VerifyBuffer<T>(identifier);
|
||||
}
|
||||
|
||||
@@ -237,29 +243,32 @@ class Verifier FLATBUFFERS_FINAL_CLASS {
|
||||
return VerifyBufferFromStart<T>(identifier, 0);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename T, typename SizeT = uoffset_t>
|
||||
bool VerifySizePrefixedBuffer(const char *const identifier) {
|
||||
return Verify<uoffset_t>(0U) &&
|
||||
Check(ReadScalar<uoffset_t>(buf_) == size_ - sizeof(uoffset_t)) &&
|
||||
VerifyBufferFromStart<T>(identifier, sizeof(uoffset_t));
|
||||
return Verify<SizeT>(0U) &&
|
||||
// Ensure the prefixed size is within the bounds of the provided
|
||||
// length.
|
||||
Check(ReadScalar<SizeT>(buf_) + sizeof(SizeT) <= size_) &&
|
||||
VerifyBufferFromStart<T>(identifier, sizeof(SizeT));
|
||||
}
|
||||
|
||||
uoffset_t VerifyOffset(const size_t start) const {
|
||||
if (!Verify<uoffset_t>(start)) return 0;
|
||||
const auto o = ReadScalar<uoffset_t>(buf_ + start);
|
||||
template<typename OffsetT = uoffset_t, typename SOffsetT = soffset_t>
|
||||
size_t VerifyOffset(const size_t start) const {
|
||||
if (!Verify<OffsetT>(start)) return 0;
|
||||
const auto o = ReadScalar<OffsetT>(buf_ + start);
|
||||
// May not point to itself.
|
||||
if (!Check(o != 0)) return 0;
|
||||
// Can't wrap around / buffers are max 2GB.
|
||||
if (!Check(static_cast<soffset_t>(o) >= 0)) return 0;
|
||||
// Can't wrap around larger than the max size.
|
||||
if (!Check(static_cast<SOffsetT>(o) >= 0)) return 0;
|
||||
// Must be inside the buffer to create a pointer from it (pointer outside
|
||||
// buffer is UB).
|
||||
if (!Verify(start + o, 1)) return 0;
|
||||
return o;
|
||||
}
|
||||
|
||||
uoffset_t VerifyOffset(const uint8_t *const base,
|
||||
const voffset_t start) const {
|
||||
return VerifyOffset(static_cast<size_t>(base - buf_) + start);
|
||||
template<typename OffsetT = uoffset_t>
|
||||
size_t VerifyOffset(const uint8_t *const base, const voffset_t start) const {
|
||||
return VerifyOffset<OffsetT>(static_cast<size_t>(base - buf_) + start);
|
||||
}
|
||||
|
||||
// Called at the start of a table to increase counters measuring data
|
||||
@@ -312,6 +321,12 @@ class Verifier FLATBUFFERS_FINAL_CLASS {
|
||||
std::vector<uint8_t> *flex_reuse_tracker_ = nullptr;
|
||||
};
|
||||
|
||||
// Specialization for 64-bit offsets.
|
||||
template<>
|
||||
inline size_t Verifier::VerifyOffset<uoffset64_t>(const size_t start) const {
|
||||
return VerifyOffset<uoffset64_t, soffset64_t>(start);
|
||||
}
|
||||
|
||||
} // namespace flatbuffers
|
||||
|
||||
#endif // FLATBUFFERS_VERIFIER_H_
|
||||
|
||||
198
java/pom.xml
198
java/pom.xml
@@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.google.flatbuffers</groupId>
|
||||
<artifactId>flatbuffers-java</artifactId>
|
||||
<version>23.5.8</version>
|
||||
<version>24.3.7</version>
|
||||
<packaging>bundle</packaging>
|
||||
<name>FlatBuffers Java API</name>
|
||||
<description>
|
||||
@@ -59,15 +59,91 @@
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<release>8</release>
|
||||
<testExcludes>
|
||||
<testExclude>MyGame/Example/MonsterStorageGrpc.java</testExclude>
|
||||
<testExclude>MyGame/OtherNameSpace/TableBT.java</testExclude>
|
||||
</testExcludes>
|
||||
<includes>
|
||||
<include>**/*Test.java</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
<version>2.22.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<configuration>
|
||||
<additionalparam>-Xdoclint:none</additionalparam>
|
||||
<additionalOptions>-Xdoclint:none</additionalOptions>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<version>5.1.2</version>
|
||||
<extensions>true</extensions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.6.8</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<serverId>ossrh</serverId>
|
||||
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
|
||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<gpgArguments>
|
||||
<arg>--pinentry-mode</arg>
|
||||
<arg>loopback</arg>
|
||||
</gpgArguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>2.5.3</version>
|
||||
<configuration>
|
||||
<autoVersionSubmodules>true</autoVersionSubmodules>
|
||||
<useReleaseProfile>false</useReleaseProfile>
|
||||
<releaseProfiles>release</releaseProfiles>
|
||||
<goals>deploy</goals>
|
||||
</configuration>
|
||||
<version>3.8.1</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
@@ -80,91 +156,39 @@
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>**/*Test.java</include>
|
||||
</includes>
|
||||
<release>8</release>
|
||||
<testExcludes>
|
||||
<testExclude>MyGame/Example/MonsterStorageGrpc.java</testExclude>
|
||||
<testExclude>MyGame/OtherNameSpace/TableBT.java</testExclude>
|
||||
</testExcludes>
|
||||
</configuration>
|
||||
<version>2.22.2</version>
|
||||
<version>3.8.1</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>jdk8</id>
|
||||
<activation>
|
||||
<jdk>1.8</jdk>
|
||||
</activation>
|
||||
<properties>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<additionalparam>-Xdoclint:none</additionalparam>
|
||||
<additionalOptions>-Xdoclint:none</additionalOptions>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<version>5.1.2</version>
|
||||
<extensions>true</extensions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.6.8</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<serverId>ossrh</serverId>
|
||||
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
|
||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<gpgArguments>
|
||||
<arg>--pinentry-mode</arg>
|
||||
<arg>loopback</arg>
|
||||
</gpgArguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>2.5.3</version>
|
||||
<configuration>
|
||||
<autoVersionSubmodules>true</autoVersionSubmodules>
|
||||
<useReleaseProfile>false</useReleaseProfile>
|
||||
<releaseProfiles>release</releaseProfiles>
|
||||
<goals>deploy</goals>
|
||||
<testExcludes>
|
||||
<testExclude>MyGame/Example/MonsterStorageGrpc.java</testExclude>
|
||||
<testExclude>MyGame/OtherNameSpace/TableBT.java</testExclude>
|
||||
</testExcludes>
|
||||
</configuration>
|
||||
<version>3.8.1</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
@@ -46,7 +46,7 @@ public class Constants {
|
||||
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_23_5_8() {}
|
||||
public static void FLATBUFFERS_24_3_7() {}
|
||||
}
|
||||
|
||||
/// @endcond
|
||||
|
||||
@@ -42,8 +42,15 @@ public class Utf8Old extends Utf8 {
|
||||
}
|
||||
}
|
||||
|
||||
// ThreadLocal.withInitial() is not used to make the following code compatible with Android API
|
||||
// level 23.
|
||||
private static final ThreadLocal<Cache> CACHE =
|
||||
ThreadLocal.withInitial(() -> new Cache());
|
||||
new ThreadLocal<Cache>() {
|
||||
@Override
|
||||
protected Cache initialValue() {
|
||||
return new Cache();
|
||||
}
|
||||
};
|
||||
|
||||
// Play some games so that the old encoder doesn't pay twice for computing
|
||||
// the length of the encoded string.
|
||||
|
||||
@@ -23,9 +23,10 @@ public final class BaseType {
|
||||
public static final byte Obj = 15;
|
||||
public static final byte Union = 16;
|
||||
public static final byte Array = 17;
|
||||
public static final byte MaxBaseType = 18;
|
||||
public static final byte Vector64 = 18;
|
||||
public static final byte MaxBaseType = 19;
|
||||
|
||||
public static final String[] names = { "None", "UType", "Bool", "Byte", "UByte", "Short", "UShort", "Int", "UInt", "Long", "ULong", "Float", "Double", "String", "Vector", "Obj", "Union", "Array", "MaxBaseType", };
|
||||
public static final String[] names = { "None", "UType", "Bool", "Byte", "UByte", "Short", "UShort", "Int", "UInt", "Long", "ULong", "Float", "Double", "String", "Vector", "Obj", "Union", "Array", "Vector64", "MaxBaseType", };
|
||||
|
||||
public static String name(int e) { return names[e]; }
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class Enum extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_8(); }
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_7(); }
|
||||
public static Enum getRootAsEnum(ByteBuffer _bb) { return getRootAsEnum(_bb, new Enum()); }
|
||||
public static Enum getRootAsEnum(ByteBuffer _bb, Enum 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); }
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class EnumVal extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_8(); }
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_7(); }
|
||||
public static EnumVal getRootAsEnumVal(ByteBuffer _bb) { return getRootAsEnumVal(_bb, new EnumVal()); }
|
||||
public static EnumVal getRootAsEnumVal(ByteBuffer _bb, EnumVal 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); }
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class Field extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_8(); }
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_7(); }
|
||||
public static Field getRootAsField(ByteBuffer _bb) { return getRootAsField(_bb, new Field()); }
|
||||
public static Field getRootAsField(ByteBuffer _bb, Field 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); }
|
||||
@@ -55,6 +55,10 @@ public final class Field extends Table {
|
||||
* Number of padding octets to always add after this field. Structs only.
|
||||
*/
|
||||
public int padding() { int o = __offset(28); return o != 0 ? bb.getShort(o + bb_pos) & 0xFFFF : 0; }
|
||||
/**
|
||||
* If the field uses 64-bit offsets.
|
||||
*/
|
||||
public boolean offset64() { int o = __offset(30); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
|
||||
|
||||
public static int createField(FlatBufferBuilder builder,
|
||||
int nameOffset,
|
||||
@@ -69,8 +73,9 @@ public final class Field extends Table {
|
||||
int attributesOffset,
|
||||
int documentationOffset,
|
||||
boolean optional,
|
||||
int padding) {
|
||||
builder.startTable(13);
|
||||
int padding,
|
||||
boolean offset64) {
|
||||
builder.startTable(14);
|
||||
Field.addDefaultReal(builder, defaultReal);
|
||||
Field.addDefaultInteger(builder, defaultInteger);
|
||||
Field.addDocumentation(builder, documentationOffset);
|
||||
@@ -80,6 +85,7 @@ public final class Field extends Table {
|
||||
Field.addPadding(builder, padding);
|
||||
Field.addOffset(builder, offset);
|
||||
Field.addId(builder, id);
|
||||
Field.addOffset64(builder, offset64);
|
||||
Field.addOptional(builder, optional);
|
||||
Field.addKey(builder, key);
|
||||
Field.addRequired(builder, required);
|
||||
@@ -87,7 +93,7 @@ public final class Field extends Table {
|
||||
return Field.endField(builder);
|
||||
}
|
||||
|
||||
public static void startField(FlatBufferBuilder builder) { builder.startTable(13); }
|
||||
public static void startField(FlatBufferBuilder builder) { builder.startTable(14); }
|
||||
public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(nameOffset); builder.slot(0); }
|
||||
public static void addType(FlatBufferBuilder builder, int typeOffset) { builder.addOffset(1, typeOffset, 0); }
|
||||
public static void addId(FlatBufferBuilder builder, int id) { builder.addShort(2, (short) id, (short) 0); }
|
||||
@@ -105,6 +111,7 @@ public final class Field extends Table {
|
||||
public static void startDocumentationVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addOptional(FlatBufferBuilder builder, boolean optional) { builder.addBoolean(11, optional, false); }
|
||||
public static void addPadding(FlatBufferBuilder builder, int padding) { builder.addShort(12, (short) padding, (short) 0); }
|
||||
public static void addOffset64(FlatBufferBuilder builder, boolean offset64) { builder.addBoolean(13, offset64, false); }
|
||||
public static int endField(FlatBufferBuilder builder) {
|
||||
int o = builder.endTable();
|
||||
builder.required(o, 4); // name
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class KeyValue extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_8(); }
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_7(); }
|
||||
public static KeyValue getRootAsKeyValue(ByteBuffer _bb) { return getRootAsKeyValue(_bb, new KeyValue()); }
|
||||
public static KeyValue getRootAsKeyValue(ByteBuffer _bb, KeyValue 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); }
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class Object extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_8(); }
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_7(); }
|
||||
public static Object getRootAsObject(ByteBuffer _bb) { return getRootAsObject(_bb, new Object()); }
|
||||
public static Object getRootAsObject(ByteBuffer _bb, Object 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); }
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class RPCCall extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_8(); }
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_7(); }
|
||||
public static RPCCall getRootAsRPCCall(ByteBuffer _bb) { return getRootAsRPCCall(_bb, new RPCCall()); }
|
||||
public static RPCCall getRootAsRPCCall(ByteBuffer _bb, RPCCall 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); }
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user