mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-09 06:30:54 +00:00
Compare commits
144 Commits
v25.9.23
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
400711102f | ||
|
|
8396e00dd8 | ||
|
|
48babd417d | ||
|
|
22770f7e85 | ||
|
|
21b033227e | ||
|
|
93f587a6d3 | ||
|
|
8afb68f074 | ||
|
|
2e07f269b9 | ||
|
|
10c994155c | ||
|
|
fc9909c30a | ||
|
|
e35817577c | ||
|
|
9e3fe5d3f6 | ||
|
|
dc9217347e | ||
|
|
a7fed2ce67 | ||
|
|
de3b97355d | ||
|
|
8aa7084f01 | ||
|
|
0f469cad54 | ||
|
|
72e51c61f7 | ||
|
|
31590a8a3b | ||
|
|
24c2432d99 | ||
|
|
292870612c | ||
|
|
57659d9f38 | ||
|
|
2b8e4d3af0 | ||
|
|
08b6372a36 | ||
|
|
9c383559e0 | ||
|
|
c13c3bf956 | ||
|
|
47eeb8f4e9 | ||
|
|
e7c6874192 | ||
|
|
8d2c333b36 | ||
|
|
abc9bfebff | ||
|
|
94d6b8086b | ||
|
|
fa709636b4 | ||
|
|
60463e25a8 | ||
|
|
b8e3d215b8 | ||
|
|
d71c0ab4ac | ||
|
|
fcf75449b8 | ||
|
|
c21bda1649 | ||
|
|
03fffb25e2 | ||
|
|
1a7495a6dd | ||
|
|
3c1bb67ae1 | ||
|
|
5b9de8b6c0 | ||
|
|
ea0a73d168 | ||
|
|
4623cfa4bc | ||
|
|
9c2c56dc6a | ||
|
|
429c28c783 | ||
|
|
e5a9ff757f | ||
|
|
e53732b9b9 | ||
|
|
b84b676c89 | ||
|
|
3211f857d1 | ||
|
|
95ff1f1d80 | ||
|
|
af8997b567 | ||
|
|
0d67abde45 | ||
|
|
d74e2945f7 | ||
|
|
8914d06ab7 | ||
|
|
522f2379a6 | ||
|
|
7cb0bcb212 | ||
|
|
b1e7868db6 | ||
|
|
68e3c839c3 | ||
|
|
0723245085 | ||
|
|
9d64b9c0c0 | ||
|
|
d01f20f2fb | ||
|
|
7e163021e5 | ||
|
|
57fdd4f995 | ||
|
|
8cb53ccc95 | ||
|
|
fb55e0c9de | ||
|
|
d9fde67eb5 | ||
|
|
f74fda299d | ||
|
|
15802fa26c | ||
|
|
a86afae939 | ||
|
|
60910fb7f5 | ||
|
|
7bfaabc358 | ||
|
|
e1407e4341 | ||
|
|
c9a301e601 | ||
|
|
19b2300f93 | ||
|
|
e60c0ab9e2 | ||
|
|
541dd1a8f5 | ||
|
|
7711e84919 | ||
|
|
89430a14d6 | ||
|
|
cfce38ec99 | ||
|
|
5469bc9ef1 | ||
|
|
b39f79e5e9 | ||
|
|
dc623919bd | ||
|
|
a1e125af11 | ||
|
|
0b60686e3d | ||
|
|
17ceaae16e | ||
|
|
a5343d6116 | ||
|
|
4786322b90 | ||
|
|
646a8bc96a | ||
|
|
0e3471d6a7 | ||
|
|
b07589a0f9 | ||
|
|
2062c33cd4 | ||
|
|
adb7add87e | ||
|
|
29f99937c4 | ||
|
|
597e76a268 | ||
|
|
a577050817 | ||
|
|
31ab0bf6c8 | ||
|
|
e4775aa3fe | ||
|
|
97d26ab4ae | ||
|
|
7dd38fa23a | ||
|
|
7350c3668f | ||
|
|
49d2db93a7 | ||
|
|
807b43c0d7 | ||
|
|
4b823b1b98 | ||
|
|
4c47f4c11e | ||
|
|
2b107e20c5 | ||
|
|
84f4b83d3e | ||
|
|
185e41fac4 | ||
|
|
8b02fe6178 | ||
|
|
6e0dad8c5f | ||
|
|
e3e355d498 | ||
|
|
8e901ce17c | ||
|
|
7808ae5c88 | ||
|
|
20068cfa05 | ||
|
|
afd07bdec5 | ||
|
|
2951d5383a | ||
|
|
ba563de877 | ||
|
|
46a2f3f2c2 | ||
|
|
7675121eab | ||
|
|
ea2b5148e5 | ||
|
|
20548ff3b6 | ||
|
|
7ea8db05d8 | ||
|
|
c7b6b66ccb | ||
|
|
ac8b124496 | ||
|
|
88b033b964 | ||
|
|
e68355cb22 | ||
|
|
e3ee24830e | ||
|
|
2a8f4568e0 | ||
|
|
cbf0850828 | ||
|
|
7150dfb5c4 | ||
|
|
fa87eccd1a | ||
|
|
a62f45fed8 | ||
|
|
599847236c | ||
|
|
4173b84d4b | ||
|
|
5fe90a9160 | ||
|
|
78a3d59a65 | ||
|
|
5ed02dc04a | ||
|
|
592dc50037 | ||
|
|
dd77af75b7 | ||
|
|
051604aeb5 | ||
|
|
4b09586652 | ||
|
|
4c0eecd25a | ||
|
|
de25052c72 | ||
|
|
95053e6a47 | ||
|
|
27325e002a |
@@ -10,7 +10,7 @@ tasks:
|
|||||||
bazel: ${{ bazel }}
|
bazel: ${{ bazel }}
|
||||||
environment:
|
environment:
|
||||||
CC: clang
|
CC: clang
|
||||||
SWIFT_VERSION: "5.9"
|
SWIFT_VERSION: "5.10"
|
||||||
SWIFT_HOME: "$HOME/swift-$SWIFT_VERSION"
|
SWIFT_HOME: "$HOME/swift-$SWIFT_VERSION"
|
||||||
PATH: "$PATH:$SWIFT_HOME/usr/bin"
|
PATH: "$PATH:$SWIFT_HOME/usr/bin"
|
||||||
shell_commands:
|
shell_commands:
|
||||||
@@ -26,7 +26,7 @@ tasks:
|
|||||||
bazel: ${{ bazel }}
|
bazel: ${{ bazel }}
|
||||||
environment:
|
environment:
|
||||||
CC: clang
|
CC: clang
|
||||||
SWIFT_VERSION: "5.9"
|
SWIFT_VERSION: "5.10"
|
||||||
SWIFT_HOME: "$HOME/swift-$SWIFT_VERSION"
|
SWIFT_HOME: "$HOME/swift-$SWIFT_VERSION"
|
||||||
PATH: "$PATH:$SWIFT_HOME/usr/bin"
|
PATH: "$PATH:$SWIFT_HOME/usr/bin"
|
||||||
shell_commands:
|
shell_commands:
|
||||||
|
|||||||
5
.github/CODEOWNERS
vendored
Normal file
5
.github/CODEOWNERS
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# Default owner
|
||||||
|
* @dbaileychess derekbailey@google.com
|
||||||
|
|
||||||
|
# Prevent modification of this file
|
||||||
|
.github/CODEOWNERS @dbaileychess derekbailey@google.com
|
||||||
6
.github/dependabot.yml
vendored
Normal file
6
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
146
.github/labeler.yml
vendored
146
.github/labeler.yml
vendored
@@ -5,93 +5,133 @@
|
|||||||
#
|
#
|
||||||
# See .github/workflows/label.yml for Github Action workflow script
|
# See .github/workflows/label.yml for Github Action workflow script
|
||||||
|
|
||||||
c#:
|
"c#":
|
||||||
- '**/*.cs'
|
- changed-files:
|
||||||
- net/**/*
|
- any-glob-to-any-file:
|
||||||
- tests/FlatBuffers.Test/**/*
|
- '**/*.cs'
|
||||||
- tests/FlatBuffers.Benchmarks/**/*
|
- 'net/**/*'
|
||||||
- src/idl_gen_csharp.cpp
|
- 'tests/FlatBuffers.Test/**/*'
|
||||||
|
- 'tests/FlatBuffers.Benchmarks/**/*'
|
||||||
|
- 'src/idl_gen_csharp.cpp'
|
||||||
|
|
||||||
swift:
|
swift:
|
||||||
- '**/*.swift'
|
- changed-files:
|
||||||
- swift/**/*
|
- any-glob-to-any-file:
|
||||||
- tests/swift/**
|
- '**/*.swift'
|
||||||
- src/idl_gen_swift.cpp
|
- 'swift/**/*'
|
||||||
|
- 'tests/swift/**'
|
||||||
|
- 'src/idl_gen_swift.cpp'
|
||||||
|
|
||||||
nim:
|
nim:
|
||||||
- '**/*.nim'
|
- changed-files:
|
||||||
- nim/**/*
|
- any-glob-to-any-file:
|
||||||
- src/idl_gen_nim.cpp
|
- '**/*.nim'
|
||||||
- src/bfbs_gen_nim.cpp
|
- 'nim/**/*'
|
||||||
|
- 'src/idl_gen_nim.cpp'
|
||||||
|
- 'src/bfbs_gen_nim.cpp'
|
||||||
|
|
||||||
javascript:
|
javascript:
|
||||||
- '**/*.js'
|
- changed-files:
|
||||||
- src/idl_gen_ts.cpp
|
- any-glob-to-any-file:
|
||||||
|
- '**/*.js'
|
||||||
|
- 'src/idl_gen_ts.cpp'
|
||||||
|
|
||||||
typescript:
|
typescript:
|
||||||
- '**/*.ts'
|
- changed-files:
|
||||||
- src/idl_gen_ts.cpp
|
- any-glob-to-any-file:
|
||||||
- grpc/flatbuffers-js-grpc/**/*.ts
|
- '**/*.ts'
|
||||||
|
- 'src/idl_gen_ts.cpp'
|
||||||
|
- 'grpc/flatbuffers-js-grpc/**/*.ts'
|
||||||
|
|
||||||
golang:
|
golang:
|
||||||
- '**/*.go'
|
- changed-files:
|
||||||
- src/idl_gen_go.cpp
|
- any-glob-to-any-file:
|
||||||
|
- '**/*.go'
|
||||||
|
- 'src/idl_gen_go.cpp'
|
||||||
|
|
||||||
python:
|
python:
|
||||||
- '**/*.py'
|
- changed-files:
|
||||||
- src/idl_gen_python.cpp
|
- any-glob-to-any-file:
|
||||||
|
- '**/*.py'
|
||||||
|
- 'src/idl_gen_python.cpp'
|
||||||
|
|
||||||
java:
|
java:
|
||||||
- '**/*.java'
|
- changed-files:
|
||||||
- src/idl_gen_java.cpp
|
- any-glob-to-any-file:
|
||||||
|
- '**/*.java'
|
||||||
|
- 'src/idl_gen_java.cpp'
|
||||||
|
|
||||||
kotlin:
|
kotlin:
|
||||||
- '**/*.kt'
|
- changed-files:
|
||||||
- src/idl_gen_kotlin.cpp
|
- any-glob-to-any-file:
|
||||||
- src/idl_gen_kotlin_kmp.cpp
|
- '**/*.kt'
|
||||||
|
- 'src/idl_gen_kotlin.cpp'
|
||||||
|
- 'src/idl_gen_kotlin_kmp.cpp'
|
||||||
|
|
||||||
lua:
|
lua:
|
||||||
- '**/*.lua'
|
- changed-files:
|
||||||
- lua/**/*
|
- any-glob-to-any-file:
|
||||||
- src/bfbs_gen_lua.cpp
|
- '**/*.lua'
|
||||||
|
- 'lua/**/*'
|
||||||
|
- 'src/bfbs_gen_lua.cpp'
|
||||||
|
|
||||||
lobster:
|
lobster:
|
||||||
- '**/*.lobster'
|
- changed-files:
|
||||||
- src/idl_gen_lobster.cpp
|
- any-glob-to-any-file:
|
||||||
|
- '**/*.lobster'
|
||||||
|
- 'src/idl_gen_lobster.cpp'
|
||||||
|
|
||||||
php:
|
php:
|
||||||
- '**/*.php'
|
- changed-files:
|
||||||
- src/idl_gen_php.cpp
|
- any-glob-to-any-file:
|
||||||
|
- '**/*.php'
|
||||||
|
- 'src/idl_gen_php.cpp'
|
||||||
|
|
||||||
rust:
|
rust:
|
||||||
- '**/*.rs'
|
- changed-files:
|
||||||
- rust/**/*
|
- any-glob-to-any-file:
|
||||||
- src/idl_gen_rust.cpp
|
- '**/*.rs'
|
||||||
|
- 'rust/**/*'
|
||||||
|
- 'src/idl_gen_rust.cpp'
|
||||||
|
|
||||||
dart:
|
dart:
|
||||||
- '**/*.dart'
|
- changed-files:
|
||||||
- src/idl_gen_dart.cpp
|
- any-glob-to-any-file:
|
||||||
|
- '**/*.dart'
|
||||||
|
- 'src/idl_gen_dart.cpp'
|
||||||
|
|
||||||
c++:
|
"c++":
|
||||||
- '**/*.cc'
|
- changed-files:
|
||||||
- '**/*.cpp'
|
- any-glob-to-any-file:
|
||||||
- '**/*.h'
|
- '**/*.cc'
|
||||||
|
- '**/*.cpp'
|
||||||
|
- '**/*.h'
|
||||||
|
|
||||||
json:
|
json:
|
||||||
- '**/*.json'
|
- changed-files:
|
||||||
- src/idl_gen_json_schema.cpp
|
- any-glob-to-any-file:
|
||||||
|
- '**/*.json'
|
||||||
|
- 'src/idl_gen_json_schema.cpp'
|
||||||
|
|
||||||
codegen:
|
codegen:
|
||||||
- src/**/*
|
- changed-files:
|
||||||
|
- any-glob-to-any-file:
|
||||||
|
- 'src/**/*'
|
||||||
|
|
||||||
documentation:
|
documentation:
|
||||||
- docs/**/*
|
- changed-files:
|
||||||
- '**/*.md'
|
- any-glob-to-any-file:
|
||||||
|
- 'docs/**/*'
|
||||||
|
- '**/*.md'
|
||||||
|
|
||||||
CI:
|
CI:
|
||||||
- '.github/**/*'
|
- changed-files:
|
||||||
- '.bazelci/**/*'
|
- any-glob-to-any-file:
|
||||||
|
- '.github/**/*'
|
||||||
|
- '.bazelci/**/*'
|
||||||
|
|
||||||
grpc:
|
grpc:
|
||||||
- grpc/**/*
|
- changed-files:
|
||||||
- src/idl_gen_grpc.cpp
|
- any-glob-to-any-file:
|
||||||
|
- 'grpc/**/*'
|
||||||
|
- 'src/idl_gen_grpc.cpp'
|
||||||
|
|||||||
154
.github/workflows/build.yml
vendored
154
.github/workflows/build.yml
vendored
@@ -30,7 +30,7 @@ jobs:
|
|||||||
cxx: [g++-13, clang++-18]
|
cxx: [g++-13, clang++-18]
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: cmake
|
- name: cmake
|
||||||
run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON -DFLATBUFFERS_STATIC_FLATC=ON .
|
run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON -DFLATBUFFERS_STATIC_FLATC=ON .
|
||||||
- name: build
|
- name: build
|
||||||
@@ -42,7 +42,7 @@ jobs:
|
|||||||
chmod +x flatc
|
chmod +x flatc
|
||||||
./flatc --version
|
./flatc --version
|
||||||
- name: upload build artifacts
|
- name: upload build artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: Linux flatc binary ${{ matrix.cxx }}
|
name: Linux flatc binary ${{ matrix.cxx }}
|
||||||
path: flatc
|
path: flatc
|
||||||
@@ -51,7 +51,7 @@ jobs:
|
|||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
run: zip Linux.flatc.binary.${{ matrix.cxx }}.zip flatc
|
run: zip Linux.flatc.binary.${{ matrix.cxx }}.zip flatc
|
||||||
- name: Release zip file
|
- name: Release zip file
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v2
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
with:
|
with:
|
||||||
files: Linux.flatc.binary.${{ matrix.cxx }}.zip
|
files: Linux.flatc.binary.${{ matrix.cxx }}.zip
|
||||||
@@ -68,7 +68,7 @@ jobs:
|
|||||||
name: Build Linux with -DFLATBUFFERS_NO_FILE_TESTS
|
name: Build Linux with -DFLATBUFFERS_NO_FILE_TESTS
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: cmake
|
- name: cmake
|
||||||
run: CXX=clang++-18 cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON -DFLATBUFFERS_CXX_FLAGS="-DFLATBUFFERS_NO_FILE_TESTS" .
|
run: CXX=clang++-18 cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON -DFLATBUFFERS_CXX_FLAGS="-DFLATBUFFERS_NO_FILE_TESTS" .
|
||||||
- name: build
|
- name: build
|
||||||
@@ -80,7 +80,7 @@ jobs:
|
|||||||
name: Build Linux with out-of-source build location
|
name: Build Linux with out-of-source build location
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: make build directory
|
- name: make build directory
|
||||||
run: mkdir build
|
run: mkdir build
|
||||||
- name: cmake
|
- name: cmake
|
||||||
@@ -112,7 +112,7 @@ jobs:
|
|||||||
std: 23
|
std: 23
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: cmake
|
- name: cmake
|
||||||
run: >
|
run: >
|
||||||
CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles"
|
CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles"
|
||||||
@@ -135,9 +135,9 @@ jobs:
|
|||||||
std: [11, 14, 17, 20, 23]
|
std: [11, 14, 17, 20, 23]
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: Add msbuild to PATH
|
- name: Add msbuild to PATH
|
||||||
uses: microsoft/setup-msbuild@v1.1
|
uses: microsoft/setup-msbuild@v3
|
||||||
- name: cmake
|
- name: cmake
|
||||||
run: >
|
run: >
|
||||||
cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release
|
cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release
|
||||||
@@ -160,9 +160,9 @@ jobs:
|
|||||||
name: Build Windows 2022
|
name: Build Windows 2022
|
||||||
runs-on: windows-2022
|
runs-on: windows-2022
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: Add msbuild to PATH
|
- name: Add msbuild to PATH
|
||||||
uses: microsoft/setup-msbuild@v1.1
|
uses: microsoft/setup-msbuild@v3
|
||||||
- name: cmake
|
- name: cmake
|
||||||
run: cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_CPP17=ON -DFLATBUFFERS_STRICT_MODE=ON .
|
run: cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_CPP17=ON -DFLATBUFFERS_STRICT_MODE=ON .
|
||||||
- name: build
|
- name: build
|
||||||
@@ -170,7 +170,7 @@ jobs:
|
|||||||
- name: test
|
- name: test
|
||||||
run: Release\flattests.exe
|
run: Release\flattests.exe
|
||||||
- name: upload build artifacts
|
- name: upload build artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: Windows flatc binary
|
name: Windows flatc binary
|
||||||
path: Release\flatc.exe
|
path: Release\flatc.exe
|
||||||
@@ -179,7 +179,7 @@ jobs:
|
|||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
run: move Release/flatc.exe . && Compress-Archive flatc.exe Windows.flatc.binary.zip
|
run: move Release/flatc.exe . && Compress-Archive flatc.exe Windows.flatc.binary.zip
|
||||||
- name: Release binary
|
- name: Release binary
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v2
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
with:
|
with:
|
||||||
files: Windows.flatc.binary.zip
|
files: Windows.flatc.binary.zip
|
||||||
@@ -191,25 +191,24 @@ jobs:
|
|||||||
|
|
||||||
build-dotnet-windows:
|
build-dotnet-windows:
|
||||||
name: Build .NET Windows
|
name: Build .NET Windows
|
||||||
runs-on: windows-2022-64core
|
runs-on: windows-2022
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
configuration: [
|
configuration: [
|
||||||
'',
|
'',
|
||||||
'-p:UnsafeByteBuffer=true',
|
'-p:UnsafeByteBuffer=true',
|
||||||
# Fails two tests currently.
|
'-p:EnableSpanT=true,UnsafeByteBuffer=true'
|
||||||
#'-p:EnableSpanT=true,UnsafeByteBuffer=true'
|
|
||||||
]
|
]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: Setup .NET Core SDK
|
- name: Setup .NET Core SDK
|
||||||
uses: actions/setup-dotnet@v4.2.0
|
uses: actions/setup-dotnet@v5
|
||||||
with:
|
with:
|
||||||
dotnet-version: '8.0.x'
|
dotnet-version: '8.0.x'
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
cd tests\FlatBuffers.Test
|
cd tests\FlatBuffers.Test
|
||||||
dotnet new sln --force --name FlatBuffers.Test
|
dotnet new sln --force --name FlatBuffers.Test --format sln
|
||||||
dotnet sln FlatBuffers.Test.sln add FlatBuffers.Test.csproj
|
dotnet sln FlatBuffers.Test.sln add FlatBuffers.Test.csproj
|
||||||
dotnet build -c Release ${{matrix.configuration}} FlatBuffers.Test.sln
|
dotnet build -c Release ${{matrix.configuration}} FlatBuffers.Test.sln
|
||||||
- name: Run net6.0
|
- name: Run net6.0
|
||||||
@@ -228,9 +227,9 @@ jobs:
|
|||||||
outputs:
|
outputs:
|
||||||
digests: ${{ steps.hash.outputs.hashes }}
|
digests: ${{ steps.hash.outputs.hashes }}
|
||||||
name: Build Mac (for Intel)
|
name: Build Mac (for Intel)
|
||||||
runs-on: macos-latest-large
|
runs-on: macos-15-intel
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: cmake
|
- name: cmake
|
||||||
run: cmake -G "Xcode" -DCMAKE_OSX_ARCHITECTURES="x86_64" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON .
|
run: cmake -G "Xcode" -DCMAKE_OSX_ARCHITECTURES="x86_64" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON .
|
||||||
- name: build
|
- name: build
|
||||||
@@ -247,7 +246,7 @@ jobs:
|
|||||||
chmod +x Release/flatc
|
chmod +x Release/flatc
|
||||||
Release/flatc --version
|
Release/flatc --version
|
||||||
- name: upload build artifacts
|
- name: upload build artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: Mac flatc binary Intel
|
name: Mac flatc binary Intel
|
||||||
path: Release/flatc
|
path: Release/flatc
|
||||||
@@ -256,7 +255,7 @@ jobs:
|
|||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
run: mv Release/flatc . && zip MacIntel.flatc.binary.zip flatc
|
run: mv Release/flatc . && zip MacIntel.flatc.binary.zip flatc
|
||||||
- name: Release binary
|
- name: Release binary
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v2
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
with:
|
with:
|
||||||
files: MacIntel.flatc.binary.zip
|
files: MacIntel.flatc.binary.zip
|
||||||
@@ -273,7 +272,7 @@ jobs:
|
|||||||
name: Build Mac (universal build)
|
name: Build Mac (universal build)
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: cmake
|
- name: cmake
|
||||||
run: cmake -G "Xcode" -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON .
|
run: cmake -G "Xcode" -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON .
|
||||||
- name: build
|
- name: build
|
||||||
@@ -290,7 +289,7 @@ jobs:
|
|||||||
chmod +x Release/flatc
|
chmod +x Release/flatc
|
||||||
Release/flatc --version
|
Release/flatc --version
|
||||||
- name: upload build artifacts
|
- name: upload build artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: Mac flatc binary Universal
|
name: Mac flatc binary Universal
|
||||||
path: Release/flatc
|
path: Release/flatc
|
||||||
@@ -299,7 +298,7 @@ jobs:
|
|||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
run: mv Release/flatc . && zip Mac.flatc.binary.zip flatc
|
run: mv Release/flatc . && zip Mac.flatc.binary.zip flatc
|
||||||
- name: Release binary
|
- name: Release binary
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v2
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
with:
|
with:
|
||||||
files: Mac.flatc.binary.zip
|
files: Mac.flatc.binary.zip
|
||||||
@@ -313,14 +312,14 @@ jobs:
|
|||||||
if: false #disabled due to continual failure
|
if: false #disabled due to continual failure
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: set up Java
|
- name: set up Java
|
||||||
uses: actions/setup-java@v4
|
uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17
|
java-version: 17
|
||||||
- name: set up Gradle
|
- name: set up Gradle
|
||||||
uses: gradle/actions/setup-gradle@v4
|
uses: gradle/actions/setup-gradle@v5
|
||||||
- name: set up flatc
|
- name: set up flatc
|
||||||
run: |
|
run: |
|
||||||
cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_STRICT_MODE=ON .
|
cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_STRICT_MODE=ON .
|
||||||
@@ -337,7 +336,7 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
cxx: [g++-13, clang++-18]
|
cxx: [g++-13, clang++-18]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: cmake
|
- name: cmake
|
||||||
run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON . && make -j
|
run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON . && make -j
|
||||||
- name: Generate
|
- name: Generate
|
||||||
@@ -349,9 +348,9 @@ jobs:
|
|||||||
name: Check Generated Code on Windows
|
name: Check Generated Code on Windows
|
||||||
runs-on: windows-2022
|
runs-on: windows-2022
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: Add msbuild to PATH
|
- name: Add msbuild to PATH
|
||||||
uses: microsoft/setup-msbuild@v1.1
|
uses: microsoft/setup-msbuild@v3
|
||||||
- name: cmake
|
- name: cmake
|
||||||
run: cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_CPP17=ON -DFLATBUFFERS_STRICT_MODE=ON .
|
run: cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_CPP17=ON -DFLATBUFFERS_STRICT_MODE=ON .
|
||||||
- name: build
|
- name: build
|
||||||
@@ -368,13 +367,13 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
cxx: [g++-13]
|
cxx: [g++-13]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: cmake
|
- name: cmake
|
||||||
run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DFLATBUFFERS_CXX_FLAGS="-Wno-unused-parameter -fno-aligned-new" -DFLATBUFFERS_BUILD_BENCHMARKS=ON -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON . && make -j
|
run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DFLATBUFFERS_CXX_FLAGS="-Wno-unused-parameter -fno-aligned-new" -DFLATBUFFERS_BUILD_BENCHMARKS=ON -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON . && make -j
|
||||||
- name: Run benchmarks
|
- name: Run benchmarks
|
||||||
run: ./flatbenchmark --benchmark_repetitions=5 --benchmark_display_aggregates_only=true --benchmark_out_format=console --benchmark_out=benchmarks/results_${{matrix.cxx}}
|
run: ./flatbenchmark --benchmark_repetitions=5 --benchmark_display_aggregates_only=true --benchmark_out_format=console --benchmark_out=benchmarks/results_${{matrix.cxx}}
|
||||||
- name: Upload benchmarks results
|
- name: Upload benchmarks results
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: Linux flatbenchmark results ${{matrix.cxx}}
|
name: Linux flatbenchmark results ${{matrix.cxx}}
|
||||||
path: benchmarks/results_${{matrix.cxx}}
|
path: benchmarks/results_${{matrix.cxx}}
|
||||||
@@ -383,31 +382,24 @@ jobs:
|
|||||||
name: Build Java
|
name: Build Java
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: test
|
- name: test
|
||||||
working-directory: java
|
working-directory: java
|
||||||
run: mvn test
|
run: mvn test
|
||||||
|
|
||||||
build-kotlin-macos:
|
build-kotlin-macos:
|
||||||
name: Build Kotlin MacOS
|
name: Build Kotlin MacOS
|
||||||
runs-on: macos-13
|
runs-on: macos-15
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v6
|
||||||
# Force Xcode 14.3 since Xcode 15 doesnt support older versions of
|
|
||||||
# kotlin. For Xcode 15, kotlin should be bumpped to 1.9.10
|
|
||||||
# https://stackoverflow.com/a/77150623
|
|
||||||
# For now, run with macos-13 which has this 14.3 installed:
|
|
||||||
# https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md#xcode
|
|
||||||
- name: Set up Xcode version
|
|
||||||
run: sudo xcode-select -s /Applications/Xcode_14.3.app/Contents/Developer
|
|
||||||
- name: set up Java
|
- name: set up Java
|
||||||
uses: actions/setup-java@v4
|
uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17
|
java-version: 17
|
||||||
- name: set up Gradle
|
- name: set up Gradle
|
||||||
uses: gradle/actions/setup-gradle@v4
|
uses: gradle/actions/setup-gradle@v5
|
||||||
- name: Build flatc
|
- name: Build flatc
|
||||||
run: |
|
run: |
|
||||||
cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF .
|
cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF .
|
||||||
@@ -423,14 +415,14 @@ jobs:
|
|||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v6
|
||||||
- name: set up Java
|
- name: set up Java
|
||||||
uses: actions/setup-java@v4
|
uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17
|
java-version: 17
|
||||||
- name: set up Gradle
|
- name: set up Gradle
|
||||||
uses: gradle/actions/setup-gradle@v4
|
uses: gradle/actions/setup-gradle@v5
|
||||||
- name: Build flatc
|
- name: Build flatc
|
||||||
run: |
|
run: |
|
||||||
cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF .
|
cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF .
|
||||||
@@ -447,16 +439,16 @@ jobs:
|
|||||||
name: Build Rust Linux
|
name: Build Rust Linux
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: test
|
- name: test
|
||||||
working-directory: tests
|
working-directory: tests
|
||||||
run: bash RustTest.sh
|
run: bash RustTest.sh
|
||||||
|
|
||||||
build-rust-windows:
|
build-rust-windows:
|
||||||
name: Build Rust Windows
|
name: Build Rust Windows
|
||||||
runs-on: windows-2022-64core
|
runs-on: windows-2022
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: test
|
- name: test
|
||||||
working-directory: tests
|
working-directory: tests
|
||||||
run: ./RustTest.bat
|
run: ./RustTest.bat
|
||||||
@@ -465,7 +457,7 @@ jobs:
|
|||||||
name: Build Python
|
name: Build Python
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: flatc
|
- name: flatc
|
||||||
# FIXME: make test script not rely on 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
|
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
|
||||||
@@ -477,7 +469,7 @@ jobs:
|
|||||||
name: Build Go
|
name: Build Go
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: flatc
|
- name: flatc
|
||||||
# FIXME: make test script not rely on 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
|
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
|
||||||
@@ -489,7 +481,7 @@ jobs:
|
|||||||
name: Build PHP
|
name: Build PHP
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: flatc
|
- name: flatc
|
||||||
# FIXME: make test script not rely on 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
|
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
|
||||||
@@ -500,29 +492,26 @@ jobs:
|
|||||||
sh phpUnionVectorTest.sh
|
sh phpUnionVectorTest.sh
|
||||||
|
|
||||||
build-swift:
|
build-swift:
|
||||||
name: Test Swift
|
name: Test Swift Linux
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
swift: ["5.9", "5.10", "6.1"]
|
swift: ["5.10", "6.1", "6.2"]
|
||||||
# Only 22.04 has swift at the moment https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md?plain=1#L30
|
runs-on: ubuntu-24.04
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- uses: vapor/swiftly-action@v0.2
|
- uses: swift-actions/setup-swift@v2
|
||||||
with:
|
with:
|
||||||
toolchain: ${{ matrix.swift }}
|
swift-version: ${{ matrix.swift }}
|
||||||
- name: Get swift version
|
- name: Get swift version
|
||||||
run: swift --version
|
run: swift --version
|
||||||
- name: test
|
- name: test
|
||||||
run: |
|
run: swift test
|
||||||
swift build --build-tests
|
|
||||||
swift test
|
|
||||||
|
|
||||||
build-swift-windows:
|
build-swift-windows:
|
||||||
name: Test swift windows
|
name: Test swift windows
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- uses: SwiftyLab/setup-swift@latest
|
- uses: SwiftyLab/setup-swift@latest
|
||||||
with:
|
with:
|
||||||
swift-version: '6.1'
|
swift-version: '6.1'
|
||||||
@@ -532,23 +521,26 @@ jobs:
|
|||||||
build-swift-wasm:
|
build-swift-wasm:
|
||||||
name: Test Swift Wasm
|
name: Test Swift Wasm
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
container:
|
|
||||||
image: ghcr.io/swiftwasm/carton:0.20.1
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- uses: bytecodealliance/actions/wasmtime/setup@v1
|
- uses: swift-actions/setup-swift@v2
|
||||||
- uses: swiftwasm/setup-swiftwasm@v1
|
|
||||||
with:
|
with:
|
||||||
swift-version: "wasm-6.0.2-RELEASE"
|
swift-version: 6.2.1
|
||||||
|
- uses: bytecodealliance/actions/wasmtime/setup@v1
|
||||||
|
- name: Install Swift SDK
|
||||||
|
run: swift sdk install https://download.swift.org/swift-6.2.1-release/wasm-sdk/swift-6.2.1-RELEASE/swift-6.2.1-RELEASE_wasm.artifactbundle.tar.gz --checksum 482b9f95462b87bedfafca94a092cf9ec4496671ca13b43745097122d20f18af
|
||||||
- name: Test
|
- name: Test
|
||||||
working-directory: tests/swift/Wasm.tests
|
working-directory: tests/swift/Wasm.tests
|
||||||
run: swift run carton test
|
run: |
|
||||||
|
swift sdk list
|
||||||
|
swift build --build-tests --swift-sdk swift-6.2.1-RELEASE_wasm
|
||||||
|
wasmtime --dir . .build/wasm32-unknown-wasip1/debug/FlatBuffers.Test.Swift.WasmPackageTests.xctest
|
||||||
|
|
||||||
build-ts:
|
build-ts:
|
||||||
name: Build TS
|
name: Build TS
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: flatc
|
- name: flatc
|
||||||
# FIXME: make test script not rely on flatc
|
# FIXME: make test script not rely on flatc
|
||||||
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF . && make -j
|
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF . && make -j
|
||||||
@@ -567,7 +559,7 @@ jobs:
|
|||||||
name: Build Dart
|
name: Build Dart
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- uses: dart-lang/setup-dart@v1
|
- uses: dart-lang/setup-dart@v1
|
||||||
with:
|
with:
|
||||||
sdk: stable
|
sdk: stable
|
||||||
@@ -582,11 +574,11 @@ jobs:
|
|||||||
name: Build Nim
|
name: Build Nim
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: flatc
|
- name: flatc
|
||||||
# FIXME: make test script not rely on flatc
|
# FIXME: make test script not rely on flatc
|
||||||
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF . && make -j
|
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF . && make -j
|
||||||
- uses: jiro4989/setup-nim-action@v1
|
- uses: jiro4989/setup-nim-action@v2
|
||||||
- name: install library
|
- name: install library
|
||||||
working-directory: nim
|
working-directory: nim
|
||||||
run: nimble -y develop && nimble install
|
run: nimble -y develop && nimble install
|
||||||
@@ -598,12 +590,17 @@ jobs:
|
|||||||
name: Bazel
|
name: Bazel
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
|
# Explicitly use 8.5.1 until we can update or https://github.com/actions/runner-images/issues/13564 is fixed.
|
||||||
|
- name: Set env
|
||||||
|
run: >
|
||||||
|
echo "USE_BAZEL_VERSION=8.5.1" >> $GITHUB_ENV
|
||||||
- name: bazel build
|
- name: bazel build
|
||||||
run: >
|
run: >
|
||||||
bazel build
|
bazel build
|
||||||
//:flatc
|
//:flatc
|
||||||
//:flatbuffers
|
//:flatbuffers
|
||||||
|
//tests:flatbuffers_test
|
||||||
- name: bazel test
|
- name: bazel test
|
||||||
run: >
|
run: >
|
||||||
bazel test
|
bazel test
|
||||||
@@ -640,8 +637,7 @@ jobs:
|
|||||||
actions: read # To read the workflow path.
|
actions: read # To read the workflow path.
|
||||||
id-token: write # To sign the provenance.
|
id-token: write # To sign the provenance.
|
||||||
contents: write # To add assets to a release.
|
contents: write # To add assets to a release.
|
||||||
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.2.1
|
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.1.0
|
||||||
with:
|
with:
|
||||||
base64-subjects: "${{ needs.release-digests.outputs.digests }}"
|
base64-subjects: "${{ needs.release-digests.outputs.digests }}"
|
||||||
upload-assets: true # Optional: Upload to a new release
|
upload-assets: true # Optional: Upload to a new release
|
||||||
compile-generator: true # Workaround for https://github.com/slsa-framework/slsa-github-generator/issues/1163
|
|
||||||
|
|||||||
6
.github/workflows/docs.yml
vendored
6
.github/workflows/docs.yml
vendored
@@ -16,16 +16,16 @@ jobs:
|
|||||||
deploy:
|
deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
- name: Configure Git Credentials
|
- name: Configure Git Credentials
|
||||||
run: |
|
run: |
|
||||||
git config user.name github-actions[bot]
|
git config user.name github-actions[bot]
|
||||||
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
|
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
|
||||||
- uses: actions/setup-python@v5
|
- uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
python-version: 3.x
|
python-version: 3.x
|
||||||
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
|
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
|
||||||
- uses: actions/cache@v4
|
- uses: actions/cache@v5
|
||||||
with:
|
with:
|
||||||
key: mkdocs-material-${{ env.cache_id }}
|
key: mkdocs-material-${{ env.cache_id }}
|
||||||
path: .cache
|
path: .cache
|
||||||
|
|||||||
2
.github/workflows/label.yml
vendored
2
.github/workflows/label.yml
vendored
@@ -19,6 +19,6 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/labeler@ee18d5d34efd9b4f7dafdb0e363cb688eb438044 # 4.1.0
|
- uses: actions/labeler@v6
|
||||||
with:
|
with:
|
||||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
|
|||||||
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@@ -27,7 +27,7 @@ jobs:
|
|||||||
language: c++
|
language: c++
|
||||||
fuzz-seconds: 60
|
fuzz-seconds: 60
|
||||||
- name: Upload Crash
|
- name: Upload Crash
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v7
|
||||||
if: failure() && steps.build.outcome == 'success'
|
if: failure() && steps.build.outcome == 'success'
|
||||||
with:
|
with:
|
||||||
name: artifacts
|
name: artifacts
|
||||||
|
|||||||
26
.github/workflows/release.yml
vendored
26
.github/workflows/release.yml
vendored
@@ -12,8 +12,8 @@ jobs:
|
|||||||
name: Publish NPM
|
name: Publish NPM
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: '20.x'
|
node-version: '20.x'
|
||||||
registry-url: 'https://registry.npmjs.org'
|
registry-url: 'https://registry.npmjs.org'
|
||||||
@@ -29,19 +29,19 @@ jobs:
|
|||||||
run:
|
run:
|
||||||
working-directory: ./python
|
working-directory: ./python
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- uses: actions/setup-python@v4
|
- uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
python-version: '3.10'
|
python-version: '3.10'
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: |
|
run: |
|
||||||
python3 -m pip install --upgrade pip
|
python3 -m pip install --upgrade pip
|
||||||
python3 -m pip install setuptools wheel twine
|
python3 -m pip install build twine
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
python3 setup.py sdist bdist_wheel
|
python3 -m build .
|
||||||
|
|
||||||
- name: Upload to PyPi
|
- name: Upload to PyPi
|
||||||
run: |
|
run: |
|
||||||
@@ -57,8 +57,8 @@ jobs:
|
|||||||
run:
|
run:
|
||||||
working-directory: ./net/flatbuffers
|
working-directory: ./net/flatbuffers
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- uses: actions/setup-dotnet@v3
|
- uses: actions/setup-dotnet@v5
|
||||||
with:
|
with:
|
||||||
dotnet-version: '8.0.x'
|
dotnet-version: '8.0.x'
|
||||||
- name: Build
|
- name: Build
|
||||||
@@ -80,10 +80,10 @@ jobs:
|
|||||||
run:
|
run:
|
||||||
working-directory: ./java
|
working-directory: ./java
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Set up Maven Central Repository
|
- name: Set up Maven Central Repository
|
||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
java-version: '11'
|
java-version: '11'
|
||||||
distribution: 'adopt'
|
distribution: 'adopt'
|
||||||
@@ -108,9 +108,9 @@ jobs:
|
|||||||
run:
|
run:
|
||||||
working-directory: ./kotlin
|
working-directory: ./kotlin
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- name: Set up Maven Central Repository
|
- name: Set up Maven Central Repository
|
||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
java-version: '11'
|
java-version: '11'
|
||||||
distribution: 'adopt'
|
distribution: 'adopt'
|
||||||
@@ -133,7 +133,7 @@ jobs:
|
|||||||
name: Publish crates.io
|
name: Publish crates.io
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: stable
|
toolchain: stable
|
||||||
|
|||||||
2
.github/workflows/stale.yml
vendored
2
.github/workflows/stale.yml
vendored
@@ -15,7 +15,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/stale@v7.0.0
|
- uses: actions/stale@v10
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
operations-per-run: 500
|
operations-per-run: 500
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -157,3 +157,6 @@ MODULE.bazel.lock
|
|||||||
|
|
||||||
# Ignore the generated docs
|
# Ignore the generated docs
|
||||||
docs/site
|
docs/site
|
||||||
|
|
||||||
|
# Ignore generated files
|
||||||
|
*.fbs.h
|
||||||
|
|||||||
12
CHANGELOG.md
12
CHANGELOG.md
@@ -4,12 +4,22 @@ 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
|
new features that should be highlighted. Minor fixes or improvements are not
|
||||||
necessarily listed.
|
necessarily listed.
|
||||||
|
|
||||||
|
## [25.12.19] (December 19 2025)(https://github.com/google/flatbuffers/releases/tag/v25.12.19)
|
||||||
|
|
||||||
|
* [C++] Default emptry vector support (#8870)
|
||||||
|
* [C++] Add --gen-absl-hash option (#8868)
|
||||||
|
* [Kotlin] Upgrade to MacOS 15 (#8845)
|
||||||
|
* [C++] Fix vector of table with naked ptrs (#8830)
|
||||||
|
* [Python] Optimize Offset/Pad/Prep (#8808)
|
||||||
|
* Implement `--file-names-only` (#8788)
|
||||||
|
* [C++] Fix size verifer (#8740)
|
||||||
|
|
||||||
## [25.9.23] (September 23 2025)(https://github.com/google/flatbuffers/releases/tag/v25.9.23)
|
## [25.9.23] (September 23 2025)(https://github.com/google/flatbuffers/releases/tag/v25.9.23)
|
||||||
|
|
||||||
* flatc: `--grpc-callback-api` flag generates C++ gRPC Callback API server `CallbackService` skeletons AND client native callback/async stubs (unary + all streaming reactor forms) (opt-in, non-breaking, issue #8596).
|
* flatc: `--grpc-callback-api` flag generates C++ gRPC Callback API server `CallbackService` skeletons AND client native callback/async stubs (unary + all streaming reactor forms) (opt-in, non-breaking, issue #8596).
|
||||||
* Swift - Adds new API to reduce memory copying within swift (#8484)
|
* Swift - Adds new API to reduce memory copying within swift (#8484)
|
||||||
* Rust - Support Rust edition 2024 (#8638)
|
* Rust - Support Rust edition 2024 (#8638)
|
||||||
# [:C++] - Use the Google Style for clang-format without exceptions (#8706)
|
* [C++] - Use the Google Style for clang-format without exceptions (#8706)
|
||||||
|
|
||||||
## [25.2.10] (February 10 2025)(https://github.com/google/flatbuffers/releases/tag/v25.2.10)
|
## [25.2.10] (February 10 2025)(https://github.com/google/flatbuffers/releases/tag/v25.2.10)
|
||||||
|
|
||||||
|
|||||||
@@ -305,8 +305,7 @@ function(flatbuffers_generate_headers)
|
|||||||
${FLATBUFFERS_GENERATE_HEADERS_SCHEMAS})
|
${FLATBUFFERS_GENERATE_HEADERS_SCHEMAS})
|
||||||
add_dependencies(
|
add_dependencies(
|
||||||
${FLATBUFFERS_GENERATE_HEADERS_TARGET}
|
${FLATBUFFERS_GENERATE_HEADERS_TARGET}
|
||||||
${FLATC}
|
${FLATC_TARGET})
|
||||||
${FLATBUFFERS_GENERATE_HEADERS_SCHEMAS})
|
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
${FLATBUFFERS_GENERATE_HEADERS_TARGET}
|
${FLATBUFFERS_GENERATE_HEADERS_TARGET}
|
||||||
INTERFACE ${generated_target_dir})
|
INTERFACE ${generated_target_dir})
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
set(VERSION_MAJOR 25)
|
set(VERSION_MAJOR 25)
|
||||||
set(VERSION_MINOR 9)
|
set(VERSION_MINOR 12)
|
||||||
set(VERSION_PATCH 23)
|
set(VERSION_PATCH 19)
|
||||||
set(VERSION_COMMIT 0)
|
set(VERSION_COMMIT 0)
|
||||||
|
|
||||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||||
|
|||||||
@@ -147,6 +147,8 @@ set(FlatBuffers_Library_SRCS
|
|||||||
include/flatbuffers/vector.h
|
include/flatbuffers/vector.h
|
||||||
include/flatbuffers/vector_downward.h
|
include/flatbuffers/vector_downward.h
|
||||||
include/flatbuffers/verifier.h
|
include/flatbuffers/verifier.h
|
||||||
|
src/file_manager.cpp
|
||||||
|
src/file_name_manager.cpp
|
||||||
src/idl_parser.cpp
|
src/idl_parser.cpp
|
||||||
src/idl_gen_text.cpp
|
src/idl_gen_text.cpp
|
||||||
src/reflection.cpp
|
src/reflection.cpp
|
||||||
@@ -173,9 +175,6 @@ set(FlatBuffers_Compiler_SRCS
|
|||||||
src/idl_gen_grpc.cpp
|
src/idl_gen_grpc.cpp
|
||||||
src/idl_gen_json_schema.cpp
|
src/idl_gen_json_schema.cpp
|
||||||
src/idl_gen_swift.cpp
|
src/idl_gen_swift.cpp
|
||||||
src/file_name_saving_file_manager.cpp
|
|
||||||
src/file_binary_writer.cpp
|
|
||||||
src/file_writer.cpp
|
|
||||||
src/idl_namer.h
|
src/idl_namer.h
|
||||||
src/namer.h
|
src/namer.h
|
||||||
src/flatc.cpp
|
src/flatc.cpp
|
||||||
@@ -219,6 +218,8 @@ set(FlatHash_SRCS
|
|||||||
set(FlatBuffers_Tests_SRCS
|
set(FlatBuffers_Tests_SRCS
|
||||||
${FlatBuffers_Library_SRCS}
|
${FlatBuffers_Library_SRCS}
|
||||||
src/idl_gen_fbs.cpp
|
src/idl_gen_fbs.cpp
|
||||||
|
tests/default_vectors_strings_test.cpp
|
||||||
|
tests/default_vectors_strings_test.h
|
||||||
tests/evolution_test.cpp
|
tests/evolution_test.cpp
|
||||||
tests/flexbuffers_test.cpp
|
tests/flexbuffers_test.cpp
|
||||||
tests/fuzz_test.cpp
|
tests/fuzz_test.cpp
|
||||||
@@ -235,6 +236,8 @@ set(FlatBuffers_Tests_SRCS
|
|||||||
tests/test_builder.h
|
tests/test_builder.h
|
||||||
tests/test_builder.cpp
|
tests/test_builder.cpp
|
||||||
tests/util_test.cpp
|
tests/util_test.cpp
|
||||||
|
tests/vector_table_naked_ptr_test.h
|
||||||
|
tests/vector_table_naked_ptr_test.cpp
|
||||||
tests/native_type_test_impl.h
|
tests/native_type_test_impl.h
|
||||||
tests/native_type_test_impl.cpp
|
tests/native_type_test_impl.cpp
|
||||||
tests/alignment_test.h
|
tests/alignment_test.h
|
||||||
@@ -495,28 +498,34 @@ if(FLATBUFFERS_BUILD_SHAREDLIB)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
function(compile_schema SRC_FBS OPT OUT_GEN_FILE)
|
function(compile_schema SRC_FBS OPT SUFFIX OUT_GEN_FILE)
|
||||||
get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH)
|
get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH)
|
||||||
string(REGEX REPLACE "\\.fbs$" "_generated.h" GEN_HEADER ${SRC_FBS})
|
string(REGEX REPLACE "\\.fbs$" "${SUFFIX}.h" GEN_HEADER ${SRC_FBS})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${GEN_HEADER}
|
OUTPUT ${GEN_HEADER}
|
||||||
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}"
|
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}"
|
||||||
${OPT}
|
${OPT}
|
||||||
|
--filename-suffix ${SUFFIX}
|
||||||
-o "${SRC_FBS_DIR}"
|
-o "${SRC_FBS_DIR}"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
|
"${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
|
||||||
DEPENDS flatc ${SRC_FBS}
|
DEPENDS flatc ${SRC_FBS}
|
||||||
COMMENT "flatc generation: `${SRC_FBS}` -> `${GEN_HEADER}`"
|
COMMENT "flatc generation: `${SRC_FBS}` -> `${GEN_HEADER}`"
|
||||||
)
|
)
|
||||||
set(${OUT_GEN_FILE} ${GEN_HEADER} PARENT_SCOPE)
|
set(${OUT_GEN_FILE} ${GEN_HEADER} PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(compile_schema_for_test SRC_FBS OPT)
|
function(compile_schema_for_test SRC_FBS OPT)
|
||||||
compile_schema("${SRC_FBS}" "${OPT}" GEN_FILE)
|
compile_schema("${SRC_FBS}" "${OPT}" "_generated" GEN_FILE)
|
||||||
|
target_sources(flattests PRIVATE ${GEN_FILE})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(compile_schema_for_test_fbsh SRC_FBS OPT)
|
||||||
|
compile_schema("${SRC_FBS}" "${OPT}" ".fbs" GEN_FILE)
|
||||||
target_sources(flattests PRIVATE ${GEN_FILE})
|
target_sources(flattests PRIVATE ${GEN_FILE})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(compile_schema_for_samples SRC_FBS OPT)
|
function(compile_schema_for_samples SRC_FBS OPT)
|
||||||
compile_schema("${SRC_FBS}" "${OPT}" GEN_FILE)
|
compile_schema("${SRC_FBS}" "${OPT}" "_generated" GEN_FILE)
|
||||||
target_sources(flatsample PRIVATE ${GEN_FILE})
|
target_sources(flatsample PRIVATE ${GEN_FILE})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
@@ -537,19 +546,20 @@ if(FLATBUFFERS_BUILD_TESTS)
|
|||||||
add_definitions(-DFLATBUFFERS_TEST_PATH_PREFIX=${CMAKE_CURRENT_SOURCE_DIR}/)
|
add_definitions(-DFLATBUFFERS_TEST_PATH_PREFIX=${CMAKE_CURRENT_SOURCE_DIR}/)
|
||||||
|
|
||||||
# The flattest target needs some generated files
|
# The flattest target needs some generated files
|
||||||
SET(FLATC_OPT --cpp --gen-mutable --gen-object-api --reflect-names)
|
SET(FLATC_OPT_COMP --cpp --gen-compare --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)
|
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/alignment_test.fbs "${FLATC_OPT_COMP}")
|
||||||
|
compile_schema_for_test_fbsh(tests/default_vectors_strings_test.fbs "${FLATC_OPT_COMP}")
|
||||||
compile_schema_for_test(tests/arrays_test.fbs "${FLATC_OPT_SCOPED_ENUMS}")
|
compile_schema_for_test(tests/arrays_test.fbs "${FLATC_OPT_SCOPED_ENUMS}")
|
||||||
compile_schema_for_test(tests/native_inline_table_test.fbs "${FLATC_OPT_COMP}")
|
compile_schema_for_test(tests/native_inline_table_test.fbs "${FLATC_OPT_COMP}")
|
||||||
compile_schema_for_test(tests/native_type_test.fbs "${FLATC_OPT}")
|
compile_schema_for_test(tests/native_type_test.fbs "${FLATC_OPT_COMP}")
|
||||||
compile_schema_for_test(tests/key_field/key_field_sample.fbs "${FLATC_OPT_COMP}")
|
compile_schema_for_test(tests/key_field/key_field_sample.fbs "${FLATC_OPT_COMP}")
|
||||||
compile_schema_for_test(tests/64bit/test_64bit.fbs "${FLATC_OPT_COMP};--bfbs-gen-embed")
|
compile_schema_for_test(tests/64bit/test_64bit.fbs "${FLATC_OPT_COMP};--bfbs-gen-embed")
|
||||||
compile_schema_for_test(tests/64bit/evolution/v1.fbs "${FLATC_OPT_COMP}")
|
compile_schema_for_test(tests/64bit/evolution/v1.fbs "${FLATC_OPT_COMP}")
|
||||||
compile_schema_for_test(tests/64bit/evolution/v2.fbs "${FLATC_OPT_COMP}")
|
compile_schema_for_test(tests/64bit/evolution/v2.fbs "${FLATC_OPT_COMP}")
|
||||||
compile_schema_for_test(tests/union_underlying_type_test.fbs "${FLATC_OPT_SCOPED_ENUMS}")
|
compile_schema_for_test(tests/union_underlying_type_test.fbs "${FLATC_OPT_SCOPED_ENUMS}")
|
||||||
|
compile_schema_for_test(tests/cross_namespace_pack_test.fbs "${FLATC_OPT_COMP}")
|
||||||
|
|
||||||
if(FLATBUFFERS_CODE_SANITIZE)
|
if(FLATBUFFERS_CODE_SANITIZE)
|
||||||
add_fsanitize_to_target(flattests ${FLATBUFFERS_CODE_SANITIZE})
|
add_fsanitize_to_target(flattests ${FLATBUFFERS_CODE_SANITIZE})
|
||||||
@@ -572,8 +582,6 @@ if(FLATBUFFERS_BUILD_TESTS)
|
|||||||
# Since flatsample has no sources, we have to explicitly set the linker lang.
|
# Since flatsample has no sources, we have to explicitly set the linker lang.
|
||||||
set_target_properties(flatsample PROPERTIES LINKER_LANGUAGE CXX)
|
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(flatsamplebinary PRIVATE $<BUILD_INTERFACE:ProjectConfig> flatsample)
|
||||||
target_link_libraries(flatsampletext PRIVATE $<BUILD_INTERFACE:ProjectConfig> flatsample)
|
target_link_libraries(flatsampletext PRIVATE $<BUILD_INTERFACE:ProjectConfig> flatsample)
|
||||||
target_link_libraries(flatsamplebfbs PRIVATE $<BUILD_INTERFACE:ProjectConfig> flatsample)
|
target_link_libraries(flatsamplebfbs PRIVATE $<BUILD_INTERFACE:ProjectConfig> flatsample)
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ Some tips for good pull requests:
|
|||||||
* Write a descriptive commit message. What problem are you solving and what
|
* Write a descriptive commit message. What problem are you solving and what
|
||||||
are the consequences? Where and what did you test? Some good tips:
|
are the consequences? Where and what did you test? Some good tips:
|
||||||
[here](http://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message)
|
[here](http://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message)
|
||||||
and [here](https://www.kernel.org/doc/Documentation/SubmittingPatches).
|
and [here](https://www.kernel.org/doc/Documentation/process/submitting-patches.rst).
|
||||||
* If your PR consists of multiple commits which are successive improvements /
|
* If your PR consists of multiple commits which are successive improvements /
|
||||||
fixes to your first commit, consider squashing them into a single commit
|
fixes to your first commit, consider squashing them into a single commit
|
||||||
(`git rebase -i`) such that your PR is a single commit on top of the current
|
(`git rebase -i`) such that your PR is a single commit on top of the current
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
Pod::Spec.new do |s|
|
Pod::Spec.new do |s|
|
||||||
s.name = 'FlatBuffers'
|
s.name = 'FlatBuffers'
|
||||||
s.version = '25.9.23'
|
s.version = '25.12.19'
|
||||||
s.summary = 'FlatBuffers: Memory Efficient Serialization Library'
|
s.summary = 'FlatBuffers: Memory Efficient Serialization Library'
|
||||||
|
|
||||||
s.description = "FlatBuffers is a cross platform serialization library architected for
|
s.description = "FlatBuffers is a cross platform serialization library architected for
|
||||||
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
|
|||||||
s.ios.deployment_target = '11.0'
|
s.ios.deployment_target = '11.0'
|
||||||
s.osx.deployment_target = '10.14'
|
s.osx.deployment_target = '10.14'
|
||||||
|
|
||||||
s.swift_version = '5.0'
|
s.swift_version = '5.10'
|
||||||
s.source_files = 'swift/Sources/Flatbuffers/*.swift'
|
s.source_files = 'swift/Sources/Flatbuffers/*.swift'
|
||||||
s.pod_target_xcconfig = {
|
s.pod_target_xcconfig = {
|
||||||
'BUILD_LIBRARY_FOR_DISTRIBUTION' => 'YES'
|
'BUILD_LIBRARY_FOR_DISTRIBUTION' => 'YES'
|
||||||
|
|||||||
18
MODULE.bazel
18
MODULE.bazel
@@ -1,13 +1,13 @@
|
|||||||
module(
|
module(
|
||||||
name = "flatbuffers",
|
name = "flatbuffers",
|
||||||
version = "25.9.23",
|
version = "25.12.19",
|
||||||
compatibility_level = 1,
|
compatibility_level = 1,
|
||||||
repo_name = "com_github_google_flatbuffers",
|
repo_name = "com_github_google_flatbuffers",
|
||||||
)
|
)
|
||||||
|
|
||||||
bazel_dep(
|
bazel_dep(
|
||||||
name = "aspect_bazel_lib",
|
name = "aspect_bazel_lib",
|
||||||
version = "2.11.0",
|
version = "2.14.0",
|
||||||
)
|
)
|
||||||
bazel_dep(
|
bazel_dep(
|
||||||
name = "aspect_rules_esbuild",
|
name = "aspect_rules_esbuild",
|
||||||
@@ -23,16 +23,16 @@ bazel_dep(
|
|||||||
)
|
)
|
||||||
bazel_dep(
|
bazel_dep(
|
||||||
name = "grpc",
|
name = "grpc",
|
||||||
version = "1.70.1",
|
version = "1.76.0",
|
||||||
repo_name = "com_github_grpc_grpc",
|
repo_name = "com_github_grpc_grpc",
|
||||||
)
|
)
|
||||||
bazel_dep(
|
bazel_dep(
|
||||||
name = "platforms",
|
name = "platforms",
|
||||||
version = "0.0.10",
|
version = "0.0.11",
|
||||||
)
|
)
|
||||||
bazel_dep(
|
bazel_dep(
|
||||||
name = "rules_cc",
|
name = "rules_cc",
|
||||||
version = "0.0.16",
|
version = "0.1.1",
|
||||||
)
|
)
|
||||||
bazel_dep(
|
bazel_dep(
|
||||||
name = "rules_go",
|
name = "rules_go",
|
||||||
@@ -49,7 +49,8 @@ bazel_dep(
|
|||||||
)
|
)
|
||||||
bazel_dep(
|
bazel_dep(
|
||||||
name = "rules_swift",
|
name = "rules_swift",
|
||||||
version = "2.1.1",
|
version = "3.1.2",
|
||||||
|
max_compatibility_level = 3,
|
||||||
repo_name = "build_bazel_rules_swift",
|
repo_name = "build_bazel_rules_swift",
|
||||||
)
|
)
|
||||||
bazel_dep(
|
bazel_dep(
|
||||||
@@ -62,9 +63,6 @@ npm.npm_translate_lock(
|
|||||||
name = "flatbuffers_npm",
|
name = "flatbuffers_npm",
|
||||||
npmrc = "//:.npmrc",
|
npmrc = "//:.npmrc",
|
||||||
pnpm_lock = "//ts:pnpm-lock.yaml",
|
pnpm_lock = "//ts:pnpm-lock.yaml",
|
||||||
# Override the Bazel package where pnpm-lock.yaml is located and link
|
|
||||||
# to the specified package instead.
|
|
||||||
root_package = "ts",
|
|
||||||
verify_node_modules_ignored = "//:.bazelignore",
|
verify_node_modules_ignored = "//:.bazelignore",
|
||||||
)
|
)
|
||||||
use_repo(npm, "flatbuffers_npm")
|
use_repo(npm, "flatbuffers_npm")
|
||||||
@@ -72,6 +70,6 @@ use_repo(npm, "flatbuffers_npm")
|
|||||||
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
|
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
|
||||||
use_repo(node, "nodejs_linux_amd64")
|
use_repo(node, "nodejs_linux_amd64")
|
||||||
|
|
||||||
rules_ts_ext = use_extension("@aspect_rules_ts//ts:extensions.bzl", "ext")
|
rules_ts_ext = use_extension("@aspect_rules_ts//ts:extensions.bzl", "ext", dev_dependency = True)
|
||||||
rules_ts_ext.deps()
|
rules_ts_ext.deps()
|
||||||
use_repo(rules_ts_ext, "npm_typescript")
|
use_repo(rules_ts_ext, "npm_typescript")
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// swift-tools-version:5.9
|
// swift-tools-version:5.10
|
||||||
/*
|
/*
|
||||||
* Copyright 2020 Google Inc. All rights reserved.
|
* Copyright 2020 Google Inc. All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -57,10 +57,10 @@ let package = Package(
|
|||||||
extension Array where Element == Package.Dependency {
|
extension Array where Element == Package.Dependency {
|
||||||
static var dependencies: [Package.Dependency] {
|
static var dependencies: [Package.Dependency] {
|
||||||
#if os(Windows)
|
#if os(Windows)
|
||||||
[]
|
[]
|
||||||
#else
|
#else
|
||||||
// Test only Dependency
|
// Test only Dependency
|
||||||
[.package(url: "https://github.com/grpc/grpc-swift.git", from: "1.4.1")]
|
[.package(url: "https://github.com/grpc/grpc-swift.git", from: "1.4.1")]
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -68,13 +68,13 @@ extension Array where Element == Package.Dependency {
|
|||||||
extension Array where Element == PackageDescription.Target.Dependency {
|
extension Array where Element == PackageDescription.Target.Dependency {
|
||||||
static var dependencies: [PackageDescription.Target.Dependency] {
|
static var dependencies: [PackageDescription.Target.Dependency] {
|
||||||
#if os(Windows)
|
#if os(Windows)
|
||||||
["FlatBuffers"]
|
["FlatBuffers"]
|
||||||
#else
|
#else
|
||||||
// Test only Dependency
|
// Test only Dependency
|
||||||
[
|
[
|
||||||
.product(name: "GRPC", package: "grpc-swift"),
|
.product(name: "GRPC", package: "grpc-swift"),
|
||||||
"FlatBuffers",
|
"FlatBuffers",
|
||||||
]
|
]
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
21
android/app/proguard-rules.pro
vendored
21
android/app/proguard-rules.pro
vendored
@@ -1,21 +0,0 @@
|
|||||||
# Add project specific ProGuard rules here.
|
|
||||||
# You can control the set of applied configuration files using the
|
|
||||||
# proguardFiles setting in build.gradle.
|
|
||||||
#
|
|
||||||
# For more details, see
|
|
||||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
|
||||||
|
|
||||||
# If your project uses WebView with JS, uncomment the following
|
|
||||||
# and specify the fully qualified class name to the JavaScript interface
|
|
||||||
# class:
|
|
||||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
|
||||||
# public *;
|
|
||||||
#}
|
|
||||||
|
|
||||||
# Uncomment this to preserve the line number information for
|
|
||||||
# debugging stack traces.
|
|
||||||
#-keepattributes SourceFile,LineNumberTable
|
|
||||||
|
|
||||||
# If you keep the line number information, uncomment this to
|
|
||||||
# hide the original source file name.
|
|
||||||
#-renamesourcefileattribute SourceFile
|
|
||||||
@@ -15,25 +15,27 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
#include <string>
|
|
||||||
#include <search.h>
|
#include <search.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "generated/animal_generated.h"
|
#include "generated/animal_generated.h"
|
||||||
|
|
||||||
using namespace com::fbs::app;
|
using namespace com::fbs::app;
|
||||||
using namespace flatbuffers;
|
using namespace flatbuffers;
|
||||||
|
|
||||||
extern "C" JNIEXPORT jbyteArray JNICALL Java_com_flatbuffers_app_MainActivity_createAnimalFromJNI(
|
extern "C" JNIEXPORT jbyteArray JNICALL
|
||||||
JNIEnv* env,
|
Java_com_flatbuffers_app_MainActivity_createAnimalFromJNI(JNIEnv* env,
|
||||||
jobject /* this */) {
|
jobject /* this */) {
|
||||||
// create a new animal flatbuffers
|
// create a new animal flatbuffers
|
||||||
auto fb = FlatBufferBuilder(1024);
|
auto fb = FlatBufferBuilder(1024);
|
||||||
auto tiger = CreateAnimalDirect(fb, "Tiger", "Roar", 300);
|
auto tiger = CreateAnimalDirect(fb, "Tiger", "Roar", 300);
|
||||||
fb.Finish(tiger);
|
fb.Finish(tiger);
|
||||||
|
|
||||||
// copies it to a Java byte array.
|
// copies it to a Java byte array.
|
||||||
auto buf = reinterpret_cast<jbyte*>(fb.GetBufferPointer());
|
auto buf = reinterpret_cast<jbyte*>(fb.GetBufferPointer());
|
||||||
int size = fb.GetSize();
|
int size = fb.GetSize();
|
||||||
auto ret = env->NewByteArray(size);
|
auto ret = env->NewByteArray(size);
|
||||||
env->SetByteArrayRegion (ret, 0, fb.GetSize(), buf);
|
env->SetByteArrayRegion(ret, 0, fb.GetSize(), buf);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class Animal : Table() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun validateVersion() = Constants.FLATBUFFERS_25_9_23()
|
fun validateVersion() = Constants.FLATBUFFERS_25_12_19()
|
||||||
|
|
||||||
fun getRootAsAnimal(_bb: ByteBuffer): Animal = getRootAsAnimal(_bb, Animal())
|
fun getRootAsAnimal(_bb: ByteBuffer): Animal = getRootAsAnimal(_bb, Animal())
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
#include "benchmarks/cpp/flatbuffers/fb_bench.h"
|
#include "benchmarks/cpp/flatbuffers/fb_bench.h"
|
||||||
#include "benchmarks/cpp/raw/raw_bench.h"
|
#include "benchmarks/cpp/raw/raw_bench.h"
|
||||||
|
|
||||||
static inline void Encode(benchmark::State &state,
|
static inline void Encode(benchmark::State& state,
|
||||||
std::unique_ptr<Bench> &bench, uint8_t *buffer) {
|
std::unique_ptr<Bench>& bench, uint8_t* buffer) {
|
||||||
int64_t length;
|
int64_t length;
|
||||||
for (auto _ : state) {
|
for (auto _ : state) {
|
||||||
bench->Encode(buffer, length);
|
bench->Encode(buffer, length);
|
||||||
@@ -14,31 +14,33 @@ static inline void Encode(benchmark::State &state,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void Decode(benchmark::State &state,
|
static inline void Decode(benchmark::State& state,
|
||||||
std::unique_ptr<Bench> &bench, uint8_t *buffer) {
|
std::unique_ptr<Bench>& bench, uint8_t* buffer) {
|
||||||
int64_t length;
|
int64_t length;
|
||||||
uint8_t *encoded = bench->Encode(buffer, length);
|
uint8_t* encoded = bench->Encode(buffer, length);
|
||||||
|
|
||||||
for (auto _ : state) {
|
for (auto _ : state) {
|
||||||
void *decoded = bench->Decode(encoded, length);
|
void* decoded = bench->Decode(encoded, length);
|
||||||
benchmark::DoNotOptimize(decoded);
|
benchmark::DoNotOptimize(decoded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void Use(benchmark::State &state, std::unique_ptr<Bench> &bench,
|
static inline void Use(benchmark::State& state, std::unique_ptr<Bench>& bench,
|
||||||
uint8_t *buffer, int64_t check_sum) {
|
uint8_t* buffer, int64_t check_sum) {
|
||||||
int64_t length;
|
int64_t length;
|
||||||
uint8_t *encoded = bench->Encode(buffer, length);
|
uint8_t* encoded = bench->Encode(buffer, length);
|
||||||
void *decoded = bench->Decode(encoded, length);
|
void* decoded = bench->Decode(encoded, length);
|
||||||
|
|
||||||
int64_t sum = 0;
|
int64_t sum = 0;
|
||||||
|
|
||||||
for (auto _ : state) { sum = bench->Use(decoded); }
|
for (auto _ : state) {
|
||||||
|
sum = bench->Use(decoded);
|
||||||
|
}
|
||||||
|
|
||||||
EXPECT_EQ(sum, check_sum);
|
EXPECT_EQ(sum, check_sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BM_Flatbuffers_Encode(benchmark::State &state) {
|
static void BM_Flatbuffers_Encode(benchmark::State& state) {
|
||||||
const int64_t kBufferLength = 1024;
|
const int64_t kBufferLength = 1024;
|
||||||
uint8_t buffer[kBufferLength];
|
uint8_t buffer[kBufferLength];
|
||||||
|
|
||||||
@@ -48,7 +50,7 @@ static void BM_Flatbuffers_Encode(benchmark::State &state) {
|
|||||||
}
|
}
|
||||||
BENCHMARK(BM_Flatbuffers_Encode);
|
BENCHMARK(BM_Flatbuffers_Encode);
|
||||||
|
|
||||||
static void BM_Flatbuffers_Decode(benchmark::State &state) {
|
static void BM_Flatbuffers_Decode(benchmark::State& state) {
|
||||||
const int64_t kBufferLength = 1024;
|
const int64_t kBufferLength = 1024;
|
||||||
uint8_t buffer[kBufferLength];
|
uint8_t buffer[kBufferLength];
|
||||||
|
|
||||||
@@ -58,7 +60,7 @@ static void BM_Flatbuffers_Decode(benchmark::State &state) {
|
|||||||
}
|
}
|
||||||
BENCHMARK(BM_Flatbuffers_Decode);
|
BENCHMARK(BM_Flatbuffers_Decode);
|
||||||
|
|
||||||
static void BM_Flatbuffers_Use(benchmark::State &state) {
|
static void BM_Flatbuffers_Use(benchmark::State& state) {
|
||||||
const int64_t kBufferLength = 1024;
|
const int64_t kBufferLength = 1024;
|
||||||
uint8_t buffer[kBufferLength];
|
uint8_t buffer[kBufferLength];
|
||||||
|
|
||||||
@@ -68,7 +70,7 @@ static void BM_Flatbuffers_Use(benchmark::State &state) {
|
|||||||
}
|
}
|
||||||
BENCHMARK(BM_Flatbuffers_Use);
|
BENCHMARK(BM_Flatbuffers_Use);
|
||||||
|
|
||||||
static void BM_Raw_Encode(benchmark::State &state) {
|
static void BM_Raw_Encode(benchmark::State& state) {
|
||||||
const int64_t kBufferLength = 1024;
|
const int64_t kBufferLength = 1024;
|
||||||
uint8_t buffer[kBufferLength];
|
uint8_t buffer[kBufferLength];
|
||||||
|
|
||||||
@@ -77,7 +79,7 @@ static void BM_Raw_Encode(benchmark::State &state) {
|
|||||||
}
|
}
|
||||||
BENCHMARK(BM_Raw_Encode);
|
BENCHMARK(BM_Raw_Encode);
|
||||||
|
|
||||||
static void BM_Raw_Decode(benchmark::State &state) {
|
static void BM_Raw_Decode(benchmark::State& state) {
|
||||||
const int64_t kBufferLength = 1024;
|
const int64_t kBufferLength = 1024;
|
||||||
uint8_t buffer[kBufferLength];
|
uint8_t buffer[kBufferLength];
|
||||||
|
|
||||||
@@ -86,7 +88,7 @@ static void BM_Raw_Decode(benchmark::State &state) {
|
|||||||
}
|
}
|
||||||
BENCHMARK(BM_Raw_Decode);
|
BENCHMARK(BM_Raw_Decode);
|
||||||
|
|
||||||
static void BM_Raw_Use(benchmark::State &state) {
|
static void BM_Raw_Use(benchmark::State& state) {
|
||||||
const int64_t kBufferLength = 1024;
|
const int64_t kBufferLength = 1024;
|
||||||
uint8_t buffer[kBufferLength];
|
uint8_t buffer[kBufferLength];
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ using namespace benchmarks_flatbuffers;
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
struct FlatBufferBench : Bench {
|
struct FlatBufferBench : Bench {
|
||||||
explicit FlatBufferBench(int64_t initial_size, Allocator *allocator)
|
explicit FlatBufferBench(int64_t initial_size, Allocator* allocator)
|
||||||
: fbb(initial_size, allocator, false) {}
|
: fbb(initial_size, allocator, false) {}
|
||||||
|
|
||||||
uint8_t *Encode(void *, int64_t &len) override {
|
uint8_t* Encode(void*, int64_t& len) override {
|
||||||
fbb.Clear();
|
fbb.Clear();
|
||||||
|
|
||||||
const int kVectorLength = 3;
|
const int kVectorLength = 3;
|
||||||
@@ -40,7 +40,7 @@ struct FlatBufferBench : Bench {
|
|||||||
return fbb.GetBufferPointer();
|
return fbb.GetBufferPointer();
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t Use(void *decoded) override {
|
int64_t Use(void* decoded) override {
|
||||||
sum = 0;
|
sum = 0;
|
||||||
auto foobarcontainer = GetFooBarContainer(decoded);
|
auto foobarcontainer = GetFooBarContainer(decoded);
|
||||||
sum = 0;
|
sum = 0;
|
||||||
@@ -56,7 +56,7 @@ struct FlatBufferBench : Bench {
|
|||||||
Add(static_cast<int64_t>(bar->ratio()));
|
Add(static_cast<int64_t>(bar->ratio()));
|
||||||
Add(bar->size());
|
Add(bar->size());
|
||||||
Add(bar->time());
|
Add(bar->time());
|
||||||
auto &foo = bar->parent();
|
auto& foo = bar->parent();
|
||||||
Add(foo.count());
|
Add(foo.count());
|
||||||
Add(foo.id());
|
Add(foo.id());
|
||||||
Add(foo.length());
|
Add(foo.length());
|
||||||
@@ -65,8 +65,8 @@ struct FlatBufferBench : Bench {
|
|||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *Decode(void *buffer, int64_t) override { return buffer; }
|
void* Decode(void* buffer, int64_t) override { return buffer; }
|
||||||
void Dealloc(void *) override {};
|
void Dealloc(void*) override {};
|
||||||
|
|
||||||
FlatBufferBuilder fbb;
|
FlatBufferBuilder fbb;
|
||||||
};
|
};
|
||||||
@@ -74,7 +74,7 @@ struct FlatBufferBench : Bench {
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
std::unique_ptr<Bench> NewFlatBuffersBench(int64_t initial_size,
|
std::unique_ptr<Bench> NewFlatBuffersBench(int64_t initial_size,
|
||||||
Allocator *allocator) {
|
Allocator* allocator) {
|
||||||
return std::unique_ptr<FlatBufferBench>(
|
return std::unique_ptr<FlatBufferBench>(
|
||||||
new FlatBufferBench(initial_size, allocator));
|
new FlatBufferBench(initial_size, allocator));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ struct FooBarContainer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct RawBench : Bench {
|
struct RawBench : Bench {
|
||||||
uint8_t *Encode(void *buf, int64_t &len) override {
|
uint8_t* Encode(void* buf, int64_t& len) override {
|
||||||
FooBarContainer *fbc = new (buf) FooBarContainer;
|
FooBarContainer* fbc = new (buf) FooBarContainer;
|
||||||
strcpy(fbc->location, "http://google.com/flatbuffers/"); // Unsafe eek!
|
strcpy(fbc->location, "http://google.com/flatbuffers/"); // Unsafe eek!
|
||||||
fbc->location_len = (int)strlen(fbc->location);
|
fbc->location_len = (int)strlen(fbc->location);
|
||||||
fbc->fruit = Bananas;
|
fbc->fruit = Bananas;
|
||||||
@@ -54,16 +54,16 @@ struct RawBench : Bench {
|
|||||||
for (int i = 0; i < kVectorLength; i++) {
|
for (int i = 0; i < kVectorLength; i++) {
|
||||||
// We add + i to not make these identical copies for a more realistic
|
// We add + i to not make these identical copies for a more realistic
|
||||||
// compression test.
|
// compression test.
|
||||||
auto &foobar = fbc->list[i];
|
auto& foobar = fbc->list[i];
|
||||||
foobar.rating = 3.1415432432445543543 + i;
|
foobar.rating = 3.1415432432445543543 + i;
|
||||||
foobar.postfix = '!' + i;
|
foobar.postfix = '!' + i;
|
||||||
strcpy(foobar.name, "Hello, World!");
|
strcpy(foobar.name, "Hello, World!");
|
||||||
foobar.name_len = (int)strlen(foobar.name);
|
foobar.name_len = (int)strlen(foobar.name);
|
||||||
auto &bar = foobar.sibling;
|
auto& bar = foobar.sibling;
|
||||||
bar.ratio = 3.14159f + i;
|
bar.ratio = 3.14159f + i;
|
||||||
bar.size = 10000 + i;
|
bar.size = 10000 + i;
|
||||||
bar.time = 123456 + i;
|
bar.time = 123456 + i;
|
||||||
auto &foo = bar.parent;
|
auto& foo = bar.parent;
|
||||||
foo.id = 0xABADCAFEABADCAFE + i;
|
foo.id = 0xABADCAFEABADCAFE + i;
|
||||||
foo.count = 10000 + i;
|
foo.count = 10000 + i;
|
||||||
foo.length = 1000000 + i;
|
foo.length = 1000000 + i;
|
||||||
@@ -71,11 +71,11 @@ struct RawBench : Bench {
|
|||||||
}
|
}
|
||||||
|
|
||||||
len = sizeof(FooBarContainer);
|
len = sizeof(FooBarContainer);
|
||||||
return reinterpret_cast<uint8_t *>(fbc);
|
return reinterpret_cast<uint8_t*>(fbc);
|
||||||
};
|
};
|
||||||
|
|
||||||
int64_t Use(void *decoded) override {
|
int64_t Use(void* decoded) override {
|
||||||
auto foobarcontainer = reinterpret_cast<FooBarContainer *>(decoded);
|
auto foobarcontainer = reinterpret_cast<FooBarContainer*>(decoded);
|
||||||
sum = 0;
|
sum = 0;
|
||||||
Add(foobarcontainer->initialized);
|
Add(foobarcontainer->initialized);
|
||||||
Add(foobarcontainer->location_len);
|
Add(foobarcontainer->location_len);
|
||||||
@@ -89,7 +89,7 @@ struct RawBench : Bench {
|
|||||||
Add(static_cast<int64_t>(bar->ratio));
|
Add(static_cast<int64_t>(bar->ratio));
|
||||||
Add(bar->size);
|
Add(bar->size);
|
||||||
Add(bar->time);
|
Add(bar->time);
|
||||||
auto &foo = bar->parent;
|
auto& foo = bar->parent;
|
||||||
Add(foo.count);
|
Add(foo.count);
|
||||||
Add(foo.id);
|
Add(foo.id);
|
||||||
Add(foo.length);
|
Add(foo.length);
|
||||||
@@ -98,8 +98,8 @@ struct RawBench : Bench {
|
|||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *Decode(void *buf, int64_t) override { return buf; }
|
void* Decode(void* buf, int64_t) override { return buf; }
|
||||||
void Dealloc(void *) override{};
|
void Dealloc(void*) override {};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -88,8 +88,8 @@ let benchmarks = {
|
|||||||
|
|
||||||
Benchmark(
|
Benchmark(
|
||||||
"Allocating ByteBuffer 1GB",
|
"Allocating ByteBuffer 1GB",
|
||||||
configuration: singleConfiguration
|
configuration: singleConfiguration)
|
||||||
) { benchmark in
|
{ benchmark in
|
||||||
let memory = UnsafeMutableRawPointer.allocate(
|
let memory = UnsafeMutableRawPointer.allocate(
|
||||||
byteCount: 1_024_000_000,
|
byteCount: 1_024_000_000,
|
||||||
alignment: 1)
|
alignment: 1)
|
||||||
@@ -165,8 +165,8 @@ let benchmarks = {
|
|||||||
|
|
||||||
Benchmark(
|
Benchmark(
|
||||||
"FlatBufferBuilder Add",
|
"FlatBufferBuilder Add",
|
||||||
configuration: kiloConfiguration
|
configuration: kiloConfiguration)
|
||||||
) { benchmark in
|
{ benchmark in
|
||||||
var fb = FlatBufferBuilder(initialSize: 1024 * 1024 * 32)
|
var fb = FlatBufferBuilder(initialSize: 1024 * 1024 * 32)
|
||||||
benchmark.startMeasurement()
|
benchmark.startMeasurement()
|
||||||
for _ in benchmark.scaledIterations {
|
for _ in benchmark.scaledIterations {
|
||||||
@@ -182,8 +182,8 @@ let benchmarks = {
|
|||||||
|
|
||||||
Benchmark(
|
Benchmark(
|
||||||
"FlatBufferBuilder Start table",
|
"FlatBufferBuilder Start table",
|
||||||
configuration: kiloConfiguration
|
configuration: kiloConfiguration)
|
||||||
) { benchmark in
|
{ benchmark in
|
||||||
var fb = FlatBufferBuilder(initialSize: 1024 * 1024 * 32)
|
var fb = FlatBufferBuilder(initialSize: 1024 * 1024 * 32)
|
||||||
benchmark.startMeasurement()
|
benchmark.startMeasurement()
|
||||||
for _ in benchmark.scaledIterations {
|
for _ in benchmark.scaledIterations {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// swift-tools-version:5.9
|
// swift-tools-version:5.10
|
||||||
/*
|
/*
|
||||||
* Copyright 2020 Google Inc. All rights reserved.
|
* Copyright 2020 Google Inc. All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -20,7 +20,7 @@ import PackageDescription
|
|||||||
let package = Package(
|
let package = Package(
|
||||||
name: "benchmarks",
|
name: "benchmarks",
|
||||||
platforms: [
|
platforms: [
|
||||||
.macOS(.v13)
|
.macOS(.v13),
|
||||||
],
|
],
|
||||||
dependencies: [
|
dependencies: [
|
||||||
.package(path: "../.."),
|
.package(path: "../.."),
|
||||||
@@ -37,6 +37,6 @@ let package = Package(
|
|||||||
],
|
],
|
||||||
path: "Benchmarks/FlatbuffersBenchmarks",
|
path: "Benchmarks/FlatbuffersBenchmarks",
|
||||||
plugins: [
|
plugins: [
|
||||||
.plugin(name: "BenchmarkPlugin", package: "package-benchmark")
|
.plugin(name: "BenchmarkPlugin", package: "package-benchmark"),
|
||||||
])
|
]),
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -187,6 +187,7 @@ def flatbuffer_cc_library(
|
|||||||
visibility = None,
|
visibility = None,
|
||||||
compatible_with = None,
|
compatible_with = None,
|
||||||
restricted_to = None,
|
restricted_to = None,
|
||||||
|
filename_suffix = "_generated",
|
||||||
target_compatible_with = None,
|
target_compatible_with = None,
|
||||||
srcs_filegroup_visibility = None,
|
srcs_filegroup_visibility = None,
|
||||||
gen_reflections = False):
|
gen_reflections = False):
|
||||||
@@ -230,10 +231,13 @@ def flatbuffer_cc_library(
|
|||||||
Fileset([name]_reflection): (Optional) all generated reflection binaries.
|
Fileset([name]_reflection): (Optional) all generated reflection binaries.
|
||||||
cc_library([name]): library with sources and flatbuffers deps.
|
cc_library([name]): library with sources and flatbuffers deps.
|
||||||
"""
|
"""
|
||||||
output_headers = [
|
|
||||||
(out_prefix + "%s_generated.h") % (s.replace(".fbs", "").split("/")[-1].split(":")[-1])
|
output_headers = []
|
||||||
for s in srcs
|
for s in srcs:
|
||||||
]
|
base_name = s.split("/")[-1].split(":")[-1].replace(".fbs", "")
|
||||||
|
header = out_prefix + base_name + filename_suffix + ".h"
|
||||||
|
output_headers.append(header)
|
||||||
|
|
||||||
if deps and includes:
|
if deps and includes:
|
||||||
# There is no inherent reason we couldn't support both, but this discourages
|
# There is no inherent reason we couldn't support both, but this discourages
|
||||||
# use of includes without good reason.
|
# use of includes without good reason.
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 2.8)
|
|
||||||
|
|
||||||
message(STATUS "Conan FlatBuffers Wrapper")
|
|
||||||
|
|
||||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
|
||||||
conan_basic_setup()
|
|
||||||
|
|
||||||
if (WIN32 AND MSVC_LIKE AND FLATBUFFERS_BUILD_SHAREDLIB)
|
|
||||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
|
||||||
endif(WIN32 AND MSVC_LIKE AND FLATBUFFERS_BUILD_SHAREDLIB)
|
|
||||||
|
|
||||||
include(${CMAKE_SOURCE_DIR}/CMakeListsOriginal.txt)
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
import subprocess
|
|
||||||
from cpt.packager import ConanMultiPackager
|
|
||||||
|
|
||||||
|
|
||||||
def get_branch():
|
|
||||||
try:
|
|
||||||
for line in (
|
|
||||||
subprocess.check_output("git branch", shell=True).decode().splitlines()
|
|
||||||
):
|
|
||||||
line = line.strip()
|
|
||||||
if line.startswith("*") and " (HEAD detached" not in line:
|
|
||||||
return line.replace("*", "", 1).strip()
|
|
||||||
return ""
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
return ""
|
|
||||||
|
|
||||||
|
|
||||||
def get_version():
|
|
||||||
version = get_branch()
|
|
||||||
match = re.search(r"v(\d+\.\d+\.\d+.*)", version)
|
|
||||||
if match:
|
|
||||||
return match.group(1)
|
|
||||||
return version
|
|
||||||
|
|
||||||
|
|
||||||
def get_reference(username):
|
|
||||||
return "flatbuffers/{}@google/stable".format(get_version())
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
login_username = os.getenv("CONAN_LOGIN_USERNAME", "aardappel")
|
|
||||||
username = os.getenv("CONAN_USERNAME", "google")
|
|
||||||
upload = os.getenv(
|
|
||||||
"CONAN_UPLOAD", "https://api.bintray.com/conan/aardappel/flatbuffers"
|
|
||||||
)
|
|
||||||
stable_branch_pattern = os.getenv(
|
|
||||||
"CONAN_STABLE_BRANCH_PATTERN", r"v\d+\.\d+\.\d+.*"
|
|
||||||
)
|
|
||||||
test_folder = os.getenv(
|
|
||||||
"CPT_TEST_FOLDER", os.path.join("conan", "test_package")
|
|
||||||
)
|
|
||||||
upload_only_when_stable = os.getenv("CONAN_UPLOAD_ONLY_WHEN_STABLE", True)
|
|
||||||
|
|
||||||
builder = ConanMultiPackager(
|
|
||||||
reference=get_reference(username),
|
|
||||||
username=username,
|
|
||||||
login_username=login_username,
|
|
||||||
upload=upload,
|
|
||||||
stable_branch_pattern=stable_branch_pattern,
|
|
||||||
upload_only_when_stable=upload_only_when_stable,
|
|
||||||
test_folder=test_folder,
|
|
||||||
)
|
|
||||||
builder.add_common_builds(pure_c=False)
|
|
||||||
builder.run()
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
project(test_package CXX)
|
|
||||||
cmake_minimum_required(VERSION 2.8.11)
|
|
||||||
|
|
||||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
|
||||||
conan_basic_setup()
|
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME} test_package.cpp)
|
|
||||||
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
|
|
||||||
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
import os
|
|
||||||
from conans import CMake, ConanFile
|
|
||||||
|
|
||||||
|
|
||||||
class TestPackageConan(ConanFile):
|
|
||||||
settings = "os", "compiler", "build_type", "arch"
|
|
||||||
generators = "cmake"
|
|
||||||
|
|
||||||
def build(self):
|
|
||||||
cmake = CMake(self)
|
|
||||||
cmake.configure()
|
|
||||||
cmake.build()
|
|
||||||
|
|
||||||
def test(self):
|
|
||||||
bin_path = os.path.join("bin", "test_package")
|
|
||||||
self.run(bin_path, run_environment=True)
|
|
||||||
self.run("flatc --version", run_environment=True)
|
|
||||||
self.run("flathash fnv1_16 conan", run_environment=True)
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2018 Google Inc. All rights reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <iostream>
|
|
||||||
#include "flatbuffers/util.h"
|
|
||||||
|
|
||||||
// Test to validate Conan package generated
|
|
||||||
|
|
||||||
int main(int /*argc*/, const char * /*argv*/ []) {
|
|
||||||
|
|
||||||
const std::string filename("conanbuildinfo.cmake");
|
|
||||||
|
|
||||||
if (flatbuffers::FileExists(filename.c_str())) {
|
|
||||||
std::cout << "File " << filename << " exists.\n";
|
|
||||||
} else {
|
|
||||||
std::cout << "File " << filename << " does not exist.\n";
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
83
conanfile.py
83
conanfile.py
@@ -1,83 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
"""Conan recipe package for Google FlatBuffers"""
|
|
||||||
import os
|
|
||||||
import shutil
|
|
||||||
from conans import CMake, ConanFile, tools
|
|
||||||
|
|
||||||
|
|
||||||
class FlatbuffersConan(ConanFile):
|
|
||||||
name = "flatbuffers"
|
|
||||||
license = "Apache-2.0"
|
|
||||||
url = "https://github.com/google/flatbuffers"
|
|
||||||
homepage = "http://google.github.io/flatbuffers/"
|
|
||||||
author = "Wouter van Oortmerssen"
|
|
||||||
topics = ("conan", "flatbuffers", "serialization", "rpc", "json-parser")
|
|
||||||
description = "Memory Efficient Serialization Library"
|
|
||||||
settings = "os", "compiler", "build_type", "arch"
|
|
||||||
options = {"shared": [True, False], "fPIC": [True, False]}
|
|
||||||
default_options = {"shared": False, "fPIC": True}
|
|
||||||
generators = "cmake"
|
|
||||||
exports = "LICENSE"
|
|
||||||
exports_sources = [
|
|
||||||
"CMake/*",
|
|
||||||
"include/*",
|
|
||||||
"src/*",
|
|
||||||
"grpc/*",
|
|
||||||
"CMakeLists.txt",
|
|
||||||
"conan/CMakeLists.txt",
|
|
||||||
]
|
|
||||||
|
|
||||||
def source(self):
|
|
||||||
"""Wrap the original CMake file to call conan_basic_setup"""
|
|
||||||
shutil.move("CMakeLists.txt", "CMakeListsOriginal.txt")
|
|
||||||
shutil.move(os.path.join("conan", "CMakeLists.txt"), "CMakeLists.txt")
|
|
||||||
|
|
||||||
def config_options(self):
|
|
||||||
"""Remove fPIC option on Windows platform"""
|
|
||||||
if self.settings.os == "Windows":
|
|
||||||
self.options.remove("fPIC")
|
|
||||||
|
|
||||||
def configure_cmake(self):
|
|
||||||
"""Create CMake instance and execute configure step"""
|
|
||||||
cmake = CMake(self)
|
|
||||||
cmake.definitions["FLATBUFFERS_BUILD_TESTS"] = False
|
|
||||||
cmake.definitions["FLATBUFFERS_BUILD_SHAREDLIB"] = self.options.shared
|
|
||||||
cmake.definitions["FLATBUFFERS_BUILD_FLATLIB"] = not self.options.shared
|
|
||||||
cmake.configure()
|
|
||||||
return cmake
|
|
||||||
|
|
||||||
def build(self):
|
|
||||||
"""Configure, build and install FlatBuffers using CMake."""
|
|
||||||
cmake = self.configure_cmake()
|
|
||||||
cmake.build()
|
|
||||||
|
|
||||||
def package(self):
|
|
||||||
"""Copy Flatbuffers' artifacts to package folder"""
|
|
||||||
cmake = self.configure_cmake()
|
|
||||||
cmake.install()
|
|
||||||
self.copy(pattern="LICENSE", dst="licenses")
|
|
||||||
self.copy(
|
|
||||||
pattern="FindFlatBuffers.cmake",
|
|
||||||
dst=os.path.join("lib", "cmake", "flatbuffers"),
|
|
||||||
src="CMake",
|
|
||||||
)
|
|
||||||
self.copy(pattern="flathash*", dst="bin", src="bin")
|
|
||||||
self.copy(pattern="flatc*", dst="bin", src="bin")
|
|
||||||
if self.settings.os == "Windows" and self.options.shared:
|
|
||||||
if self.settings.compiler == "Visual Studio":
|
|
||||||
shutil.move(
|
|
||||||
os.path.join(self.package_folder, "lib", "%s.dll" % self.name),
|
|
||||||
os.path.join(self.package_folder, "bin", "%s.dll" % self.name),
|
|
||||||
)
|
|
||||||
elif self.settings.compiler == "gcc":
|
|
||||||
shutil.move(
|
|
||||||
os.path.join(self.package_folder, "lib", "lib%s.dll" % self.name),
|
|
||||||
os.path.join(self.package_folder, "bin", "lib%s.dll" % self.name),
|
|
||||||
)
|
|
||||||
|
|
||||||
def package_info(self):
|
|
||||||
"""Collect built libraries names and solve flatc path."""
|
|
||||||
self.cpp_info.libs = tools.collect_libs(self)
|
|
||||||
self.user_info.flatc = os.path.join(self.package_folder, "bin", "flatc")
|
|
||||||
@@ -1,5 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 25.9.23
|
||||||
|
|
||||||
|
- use enhanced enums (#8313)
|
||||||
|
- fix incorrect write in Float64 write method (#8290)
|
||||||
|
- code format improvements (#8707)
|
||||||
|
|
||||||
## 23.5.26
|
## 23.5.26
|
||||||
|
|
||||||
- omit type annotationes for local variables (#7067, #7069, #7070)
|
- omit type annotationes for local variables (#7067, #7069, #7070)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import 'types.dart';
|
|||||||
|
|
||||||
/// The main builder class for creation of a FlexBuffer.
|
/// The main builder class for creation of a FlexBuffer.
|
||||||
class Builder {
|
class Builder {
|
||||||
final ByteData _buffer;
|
ByteData _buffer;
|
||||||
List<_StackValue> _stack = [];
|
List<_StackValue> _stack = [];
|
||||||
List<_StackPointer> _stackPointers = [];
|
List<_StackPointer> _stackPointers = [];
|
||||||
int _offset = 0;
|
int _offset = 0;
|
||||||
@@ -506,6 +506,7 @@ class Builder {
|
|||||||
if (prevSize < size) {
|
if (prevSize < size) {
|
||||||
final newBuf = ByteData(size);
|
final newBuf = ByteData(size);
|
||||||
newBuf.buffer.asUint8List().setAll(0, _buffer.buffer.asUint8List());
|
newBuf.buffer.asUint8List().setAll(0, _buffer.buffer.asUint8List());
|
||||||
|
_buffer = newBuf;
|
||||||
}
|
}
|
||||||
return newOffset;
|
return newOffset;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
name: flat_buffers
|
name: flat_buffers
|
||||||
version: 25.9.23
|
version: 25.12.19
|
||||||
description: FlatBuffers reading and writing library for Dart. Based on original work by Konstantin Scheglov and Paul Berry of the Dart SDK team.
|
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
|
homepage: https://github.com/google/flatbuffers
|
||||||
documentation: https://google.github.io/flatbuffers/index.html
|
documentation: https://google.github.io/flatbuffers/index.html
|
||||||
|
|||||||
@@ -868,15 +868,14 @@ class ObjectAPITest {
|
|||||||
..name = 'Monstrous'
|
..name = 'Monstrous'
|
||||||
..inventory = [24, 42]
|
..inventory = [24, 42]
|
||||||
..color = example.Color.Green
|
..color = example.Color.Green
|
||||||
// TODO be smarter for unions and automatically set the `type` field?
|
|
||||||
..testType = example.AnyTypeId.MyGame_Example2_Monster
|
..testType = example.AnyTypeId.MyGame_Example2_Monster
|
||||||
..test = example2.MonsterT()
|
..test = example2.MonsterT()
|
||||||
..test4 = [example.TestT(a: 3, b: 4), example.TestT(a: 5, b: 6)]
|
..test4 = [example.TestT(a: 3, b: 4), example.TestT(a: 5, b: 6)]
|
||||||
..testarrayofstring = ["foo", "bar"]
|
..testarrayofstring = ["foo", "bar"]
|
||||||
..testarrayoftables = [example.MonsterT(name: 'Oof')]
|
..testarrayoftables = [example.MonsterT(name: 'Oof', testf: 2.75)]
|
||||||
..enemy = example.MonsterT(name: 'Enemy')
|
..enemy = example.MonsterT(name: 'Enemy', testf: 2.5)
|
||||||
..testarrayofbools = [false, true, false]
|
..testarrayofbools = [false, true, false]
|
||||||
..testf = 42.24
|
..testf = 42.25
|
||||||
..testarrayofsortedstruct = [
|
..testarrayofsortedstruct = [
|
||||||
example.AbilityT(id: 1, distance: 5),
|
example.AbilityT(id: 1, distance: 5),
|
||||||
example.AbilityT(id: 3, distance: 7),
|
example.AbilityT(id: 3, distance: 7),
|
||||||
@@ -894,16 +893,15 @@ class ObjectAPITest {
|
|||||||
fbBuilder.finish(offset);
|
fbBuilder.finish(offset);
|
||||||
final data = fbBuilder.buffer;
|
final data = fbBuilder.buffer;
|
||||||
|
|
||||||
// TODO currently broken because of struct builder issue, see #6688
|
final monster2 = example.Monster(data); // Monster (reader)
|
||||||
// final monster2 = example.Monster(data); // Monster (reader)
|
expect(
|
||||||
// expect(
|
// map Monster => MonsterT, Vec3 => Vec3T, ...
|
||||||
// // map Monster => MonsterT, Vec3 => Vec3T, ...
|
monster2.toString().replaceAllMapped(
|
||||||
// monster2.toString().replaceAllMapped(
|
RegExp('([a-zA-z0-9]+){'), (match) => match.group(1)! + 'T{'),
|
||||||
// RegExp('([a-zA-z0-9]+){'), (match) => match.group(1) + 'T{'),
|
monster.toString());
|
||||||
// monster.toString());
|
|
||||||
//
|
final monster3 = monster2.unpack(); // MonsterT
|
||||||
// final monster3 = monster2.unpack(); // MonsterT
|
expect(monster3.toString(), monster.toString());
|
||||||
// expect(monster3.toString(), monster.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_Lists() {
|
void test_Lists() {
|
||||||
|
|||||||
@@ -318,6 +318,21 @@ void main() {
|
|||||||
1,
|
1,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
// Default buffer is 2048 bytes, add 2300 bytes of strings that force it
|
||||||
|
// to grow.
|
||||||
|
final s1 = 'A' * 1000;
|
||||||
|
final s2 = 'B' * 800;
|
||||||
|
final s3 = 'C' * 500;
|
||||||
|
|
||||||
|
var flx = Builder()
|
||||||
|
..startVector()
|
||||||
|
..addString(s1)
|
||||||
|
..addString(s2)
|
||||||
|
..addString(s3)
|
||||||
|
..end();
|
||||||
|
expect(flx.finish().length, 2323);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('build map', () {
|
test('build map', () {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import 'dart:typed_data' show Uint8List;
|
|||||||
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum Abc {
|
enum Abc {
|
||||||
$void(0),
|
$void(0),
|
||||||
where(1),
|
where(1),
|
||||||
@@ -276,7 +277,7 @@ class Table2 {
|
|||||||
|
|
||||||
Table2T unpack() => Table2T(
|
Table2T unpack() => Table2T(
|
||||||
typeType: typeType,
|
typeType: typeType,
|
||||||
type: type);
|
type: type?.unpack());
|
||||||
|
|
||||||
static int pack(fb.Builder fbBuilder, Table2T? object) {
|
static int pack(fb.Builder fbBuilder, Table2T? object) {
|
||||||
if (object == null) return 0;
|
if (object == null) return 0;
|
||||||
|
|||||||
@@ -1332,22 +1332,15 @@ class Monster {
|
|||||||
mana: mana,
|
mana: mana,
|
||||||
hp: hp,
|
hp: hp,
|
||||||
name: name,
|
name: name,
|
||||||
inventory: const fb.Uint8ListReader(
|
inventory: inventory?.toList(),
|
||||||
lazy: false,
|
|
||||||
).vTableGetNullable(_bc, _bcOffset, 14),
|
|
||||||
color: color,
|
color: color,
|
||||||
testType: testType,
|
testType: testType,
|
||||||
test: test,
|
test: test?.unpack(),
|
||||||
test4: test4?.map((e) => e.unpack()).toList(),
|
test4: test4?.map((e) => e.unpack()).toList(),
|
||||||
testarrayofstring: const fb.ListReader<String>(
|
testarrayofstring: testarrayofstring?.toList(),
|
||||||
fb.StringReader(),
|
|
||||||
lazy: false,
|
|
||||||
).vTableGetNullable(_bc, _bcOffset, 24),
|
|
||||||
testarrayoftables: testarrayoftables?.map((e) => e.unpack()).toList(),
|
testarrayoftables: testarrayoftables?.map((e) => e.unpack()).toList(),
|
||||||
enemy: enemy?.unpack(),
|
enemy: enemy?.unpack(),
|
||||||
testnestedflatbuffer: const fb.Uint8ListReader(
|
testnestedflatbuffer: testnestedflatbuffer?.toList(),
|
||||||
lazy: false,
|
|
||||||
).vTableGetNullable(_bc, _bcOffset, 30),
|
|
||||||
testempty: testempty?.unpack(),
|
testempty: testempty?.unpack(),
|
||||||
testbool: testbool,
|
testbool: testbool,
|
||||||
testhashs32Fnv1: testhashs32Fnv1,
|
testhashs32Fnv1: testhashs32Fnv1,
|
||||||
@@ -1358,67 +1351,33 @@ class Monster {
|
|||||||
testhashu32Fnv1a: testhashu32Fnv1a,
|
testhashu32Fnv1a: testhashu32Fnv1a,
|
||||||
testhashs64Fnv1a: testhashs64Fnv1a,
|
testhashs64Fnv1a: testhashs64Fnv1a,
|
||||||
testhashu64Fnv1a: testhashu64Fnv1a,
|
testhashu64Fnv1a: testhashu64Fnv1a,
|
||||||
testarrayofbools: const fb.ListReader<bool>(
|
testarrayofbools: testarrayofbools?.toList(),
|
||||||
fb.BoolReader(),
|
|
||||||
lazy: false,
|
|
||||||
).vTableGetNullable(_bc, _bcOffset, 52),
|
|
||||||
testf: testf,
|
testf: testf,
|
||||||
testf2: testf2,
|
testf2: testf2,
|
||||||
testf3: testf3,
|
testf3: testf3,
|
||||||
testarrayofstring2: const fb.ListReader<String>(
|
testarrayofstring2: testarrayofstring2?.toList(),
|
||||||
fb.StringReader(),
|
testarrayofsortedstruct: testarrayofsortedstruct?.map((e) => e.unpack()).toList(),
|
||||||
lazy: false,
|
flex: flex?.toList(),
|
||||||
).vTableGetNullable(_bc, _bcOffset, 60),
|
|
||||||
testarrayofsortedstruct: testarrayofsortedstruct
|
|
||||||
?.map((e) => e.unpack())
|
|
||||||
.toList(),
|
|
||||||
flex: const fb.Uint8ListReader(
|
|
||||||
lazy: false,
|
|
||||||
).vTableGetNullable(_bc, _bcOffset, 64),
|
|
||||||
test5: test5?.map((e) => e.unpack()).toList(),
|
test5: test5?.map((e) => e.unpack()).toList(),
|
||||||
vectorOfLongs: const fb.ListReader<int>(
|
vectorOfLongs: vectorOfLongs?.toList(),
|
||||||
fb.Int64Reader(),
|
vectorOfDoubles: vectorOfDoubles?.toList(),
|
||||||
lazy: false,
|
|
||||||
).vTableGetNullable(_bc, _bcOffset, 68),
|
|
||||||
vectorOfDoubles: const fb.ListReader<double>(
|
|
||||||
fb.Float64Reader(),
|
|
||||||
lazy: false,
|
|
||||||
).vTableGetNullable(_bc, _bcOffset, 70),
|
|
||||||
parentNamespaceTest: parentNamespaceTest?.unpack(),
|
parentNamespaceTest: parentNamespaceTest?.unpack(),
|
||||||
vectorOfReferrables: vectorOfReferrables?.map((e) => e.unpack()).toList(),
|
vectorOfReferrables: vectorOfReferrables?.map((e) => e.unpack()).toList(),
|
||||||
singleWeakReference: singleWeakReference,
|
singleWeakReference: singleWeakReference,
|
||||||
vectorOfWeakReferences: const fb.ListReader<int>(
|
vectorOfWeakReferences: vectorOfWeakReferences?.toList(),
|
||||||
fb.Uint64Reader(),
|
vectorOfStrongReferrables: vectorOfStrongReferrables?.map((e) => e.unpack()).toList(),
|
||||||
lazy: false,
|
|
||||||
).vTableGetNullable(_bc, _bcOffset, 78),
|
|
||||||
vectorOfStrongReferrables: vectorOfStrongReferrables
|
|
||||||
?.map((e) => e.unpack())
|
|
||||||
.toList(),
|
|
||||||
coOwningReference: coOwningReference,
|
coOwningReference: coOwningReference,
|
||||||
vectorOfCoOwningReferences: const fb.ListReader<int>(
|
vectorOfCoOwningReferences: vectorOfCoOwningReferences?.toList(),
|
||||||
fb.Uint64Reader(),
|
|
||||||
lazy: false,
|
|
||||||
).vTableGetNullable(_bc, _bcOffset, 84),
|
|
||||||
nonOwningReference: nonOwningReference,
|
nonOwningReference: nonOwningReference,
|
||||||
vectorOfNonOwningReferences: const fb.ListReader<int>(
|
vectorOfNonOwningReferences: vectorOfNonOwningReferences?.toList(),
|
||||||
fb.Uint64Reader(),
|
|
||||||
lazy: false,
|
|
||||||
).vTableGetNullable(_bc, _bcOffset, 88),
|
|
||||||
anyUniqueType: anyUniqueType,
|
anyUniqueType: anyUniqueType,
|
||||||
anyUnique: anyUnique,
|
anyUnique: anyUnique?.unpack(),
|
||||||
anyAmbiguousType: anyAmbiguousType,
|
anyAmbiguousType: anyAmbiguousType,
|
||||||
anyAmbiguous: anyAmbiguous,
|
anyAmbiguous: anyAmbiguous?.unpack(),
|
||||||
vectorOfEnums: const fb.ListReader<Color>(
|
vectorOfEnums: vectorOfEnums?.toList(),
|
||||||
Color.reader,
|
|
||||||
lazy: false,
|
|
||||||
).vTableGetNullable(_bc, _bcOffset, 98),
|
|
||||||
signedEnum: signedEnum,
|
signedEnum: signedEnum,
|
||||||
testrequirednestedflatbuffer: const fb.Uint8ListReader(
|
testrequirednestedflatbuffer: testrequirednestedflatbuffer?.toList(),
|
||||||
lazy: false,
|
scalarKeySortedTables: scalarKeySortedTables?.map((e) => e.unpack()).toList(),
|
||||||
).vTableGetNullable(_bc, _bcOffset, 102),
|
|
||||||
scalarKeySortedTables: scalarKeySortedTables
|
|
||||||
?.map((e) => e.unpack())
|
|
||||||
.toList(),
|
|
||||||
nativeInline: nativeInline?.unpack(),
|
nativeInline: nativeInline?.unpack(),
|
||||||
longEnumNonEnumDefault: longEnumNonEnumDefault,
|
longEnumNonEnumDefault: longEnumNonEnumDefault,
|
||||||
longEnumNormalDefault: longEnumNormalDefault,
|
longEnumNormalDefault: longEnumNormalDefault,
|
||||||
@@ -1578,7 +1537,7 @@ class MonsterT implements fb.Packable {
|
|||||||
final int? testOffset = test?.pack(fbBuilder);
|
final int? testOffset = test?.pack(fbBuilder);
|
||||||
int? test4Offset;
|
int? test4Offset;
|
||||||
if (test4 != null) {
|
if (test4 != null) {
|
||||||
for (var e in test4!) {
|
for (var e in test4!.reversed) {
|
||||||
e.pack(fbBuilder);
|
e.pack(fbBuilder);
|
||||||
}
|
}
|
||||||
test4Offset = fbBuilder.endStructVector(test4!.length);
|
test4Offset = fbBuilder.endStructVector(test4!.length);
|
||||||
@@ -1608,7 +1567,7 @@ class MonsterT implements fb.Packable {
|
|||||||
);
|
);
|
||||||
int? testarrayofsortedstructOffset;
|
int? testarrayofsortedstructOffset;
|
||||||
if (testarrayofsortedstruct != null) {
|
if (testarrayofsortedstruct != null) {
|
||||||
for (var e in testarrayofsortedstruct!) {
|
for (var e in testarrayofsortedstruct!.reversed) {
|
||||||
e.pack(fbBuilder);
|
e.pack(fbBuilder);
|
||||||
}
|
}
|
||||||
testarrayofsortedstructOffset = fbBuilder.endStructVector(
|
testarrayofsortedstructOffset = fbBuilder.endStructVector(
|
||||||
@@ -1620,7 +1579,7 @@ class MonsterT implements fb.Packable {
|
|||||||
: fbBuilder.writeListUint8(flex!);
|
: fbBuilder.writeListUint8(flex!);
|
||||||
int? test5Offset;
|
int? test5Offset;
|
||||||
if (test5 != null) {
|
if (test5 != null) {
|
||||||
for (var e in test5!) {
|
for (var e in test5!.reversed) {
|
||||||
e.pack(fbBuilder);
|
e.pack(fbBuilder);
|
||||||
}
|
}
|
||||||
test5Offset = fbBuilder.endStructVector(test5!.length);
|
test5Offset = fbBuilder.endStructVector(test5!.length);
|
||||||
@@ -2478,13 +2437,8 @@ class TypeAliases {
|
|||||||
u64: u64,
|
u64: u64,
|
||||||
f32: f32,
|
f32: f32,
|
||||||
f64: f64,
|
f64: f64,
|
||||||
v8: const fb.Int8ListReader(
|
v8: v8?.toList(),
|
||||||
lazy: false,
|
vf64: vf64?.toList(),
|
||||||
).vTableGetNullable(_bc, _bcOffset, 24),
|
|
||||||
vf64: const fb.ListReader<double>(
|
|
||||||
fb.Float64Reader(),
|
|
||||||
lazy: false,
|
|
||||||
).vTableGetNullable(_bc, _bcOffset, 26),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
static int pack(fb.Builder fbBuilder, TypeAliasesT? object) {
|
static int pack(fb.Builder fbBuilder, TypeAliasesT? object) {
|
||||||
|
|||||||
@@ -89,6 +89,17 @@ CC=clang PATH=$PATH:$(pwd)/swift-${SWIFT_VERSION}-RELEASE-debian12/usr/bin bazel
|
|||||||
|
|
||||||
If you are unsure which versions to use, check our CI config at `.bazelci/presubmit.yml`.
|
If you are unsure which versions to use, check our CI config at `.bazelci/presubmit.yml`.
|
||||||
|
|
||||||
|
## Building with Conan
|
||||||
|
|
||||||
|
You can download and install flatbuffers using the [Conan](https://conan.io/) dependency manager:
|
||||||
|
|
||||||
|
conan install --requires="flatbuffers/[*]" --build=missing
|
||||||
|
|
||||||
|
The flatbuffers package in Conan Center is maintained by
|
||||||
|
[ConanCenterIndex](https://github.com/conan-io/conan-center-index) community.
|
||||||
|
If the version is out of date or the package does not work,
|
||||||
|
please create an issue or pull request on the [Conan Center Index repository](https://github.com/conan-io/conan-center-index).
|
||||||
|
|
||||||
## Building with VCPKG
|
## Building with VCPKG
|
||||||
|
|
||||||
You can download and install flatbuffers using the [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager:
|
You can download and install flatbuffers using the [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager:
|
||||||
|
|||||||
@@ -79,11 +79,12 @@ list of `FILES...`.
|
|||||||
`myschema.fbs` to JSON:
|
`myschema.fbs` to JSON:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
flatc --json myschema.fbs mydata.bin
|
flatc --json myschema.fbs -- mydata.bin
|
||||||
```
|
```
|
||||||
|
|
||||||
This will generate a `mydata.json` file.
|
This will generate a `mydata.json` file. If there is no
|
||||||
|
[`file_identifier`](schema.md/#file-identification-and-extension) defined
|
||||||
|
for this schema, you will need to use the `--raw-binary` option.
|
||||||
|
|
||||||
### Additional options
|
### Additional options
|
||||||
|
|
||||||
@@ -261,6 +262,9 @@ list of `FILES...`.
|
|||||||
|
|
||||||
- `--python-decode-obj-api-strings` : Decode bytes automaticaly with utf-8
|
- `--python-decode-obj-api-strings` : Decode bytes automaticaly with utf-8
|
||||||
|
|
||||||
|
- `--file-names-only` : Prints out files which would be generated by this command, one per
|
||||||
|
line, to `stdout`. No actual files are generated. This is useful for various CI checks.
|
||||||
|
|
||||||
Additional gRPC options:
|
Additional gRPC options:
|
||||||
|
|
||||||
- `--grpc-filename-suffix`: `[C++]` An optional suffix for the generated
|
- `--grpc-filename-suffix`: `[C++]` An optional suffix for the generated
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ FlatBuffers).
|
|||||||
|
|
||||||
## Building the FlatBuffers C# library
|
## Building the FlatBuffers C# library
|
||||||
|
|
||||||
The `FlatBuffers.csproj` project contains multitargeting for .NET Standard 2.1,
|
The `FlatBuffers.csproj` project contains multitargeting for .NET Standard 2.0, 2.1,
|
||||||
.NET 6 and .NET 8.
|
.NET 6 and .NET 8.
|
||||||
|
|
||||||
You can build for a specific framework target when using the cross-platform
|
You can build for a specific framework target when using the cross-platform
|
||||||
|
|||||||
@@ -242,6 +242,41 @@ provide the following functions to aide in the serialization process:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- `native_type("type")` (on a table): Tables can also be represented with
|
||||||
|
native types. For example, the following schema:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
table Matrix (native_type: "NativeMatrix") {
|
||||||
|
rows: int32;
|
||||||
|
columns: int32;
|
||||||
|
values: [float];
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Would be represented by a user-defined C++ class:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
class NativeMatrix { ... }
|
||||||
|
```
|
||||||
|
|
||||||
|
In this case, the following function declarations are generated by the compiler.
|
||||||
|
The user must provide and link the matching function definitions:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
struct Matrix FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||||
|
// ...
|
||||||
|
|
||||||
|
static ::flatbuffers::Offset<Matrix> Pack(
|
||||||
|
::flatbuffers::FlatBufferBuilder& _fbb,
|
||||||
|
const NativeMatrix* _o,
|
||||||
|
const ::flatbuffers::rehasher_function_t* _rehasher = nullptr);
|
||||||
|
|
||||||
|
void UnPackTo(
|
||||||
|
NativeMatrix* _o,
|
||||||
|
const ::flatbuffers::resolver_function_t* _resolver = nullptr) const;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
Finally, the following top-level attributes:
|
Finally, the following top-level attributes:
|
||||||
|
|
||||||
- `native_include("path")` (at file level): Because the `native_type` attribute
|
- `native_include("path")` (at file level): Because the `native_type` attribute
|
||||||
|
|||||||
@@ -205,6 +205,47 @@ And example of usage, for the time being, can be found in
|
|||||||
- Safe getters in [SafeBuffer](https://docs.rs/flatbuffers-reflection/latest/flatbuffers_reflection/struct.SafeBuffer.html),
|
- Safe getters in [SafeBuffer](https://docs.rs/flatbuffers-reflection/latest/flatbuffers_reflection/struct.SafeBuffer.html),
|
||||||
which does verification when constructed so you can use it for any data source
|
which does verification when constructed so you can use it for any data source
|
||||||
|
|
||||||
|
## Buffer pre allocation in a latency-sensitive context
|
||||||
|
|
||||||
|
In latency-sensitive applications, dynamic memory allocations can introduce unpredictable latency spikes. The `FlatBufferBuilder` internally uses several `Vec`s that may reallocate during serialization:
|
||||||
|
|
||||||
|
- The backing buffer for the FlatBuffer data
|
||||||
|
- `field_locs` for tracking field locations within tables
|
||||||
|
- `written_vtable_revpos` for deduplicating vtables
|
||||||
|
- `strings_pool` for shared string interning
|
||||||
|
|
||||||
|
To avoid allocations during serialization, you can preallocate all internal vectors upfront using the `with_internal_capacity` constructor:
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.rs}
|
||||||
|
// Preallocate: 1KB buffer, 8 field locations, 16 vtables, 32 shared strings
|
||||||
|
let mut builder = FlatBufferBuilder::with_internal_capacity(1024, 8, 16, 32);
|
||||||
|
|
||||||
|
// All subsequent operations will not allocate (if capacities are sufficient)
|
||||||
|
let name = builder.create_shared_string("MyMonster");
|
||||||
|
// ... build your FlatBuffer ...
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
There are three variants available:
|
||||||
|
|
||||||
|
- `with_internal_capacity(size, field_locs, vtables, strings)` - Creates a new builder with all capacities preallocated
|
||||||
|
- `from_vec_with_internal_capacity(buffer, field_locs, vtables, strings)` - Reuses an existing `Vec<u8>` as the backing buffer
|
||||||
|
- `new_in_with_internal_capacity(allocator, field_locs, vtables, strings)` - Uses a custom `Allocator` with preallocated internal vecs
|
||||||
|
|
||||||
|
When combined with `reset()`, you can reuse the same builder across multiple serializations without any allocations after the initial setup:
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.rs}
|
||||||
|
let mut builder = FlatBufferBuilder::with_internal_capacity(1024, 8, 16, 32);
|
||||||
|
|
||||||
|
loop {
|
||||||
|
// Build a FlatBuffer (allocation-free if capacities are sufficient)
|
||||||
|
let data = build_message(&mut builder);
|
||||||
|
send(data);
|
||||||
|
|
||||||
|
// Reset for reuse - clears state but retains allocated capacity
|
||||||
|
builder.reset();
|
||||||
|
}
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
## Useful tools created by others
|
## Useful tools created by others
|
||||||
|
|
||||||
* [flatc-rust](https://github.com/frol/flatc-rust) - FlatBuffers compiler
|
* [flatc-rust](https://github.com/frol/flatc-rust) - FlatBuffers compiler
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ See the [Tutorial](tutorial.md) for a more in depth guide.
|
|||||||
|
|
||||||
5. **Transmit/Store the serialized FlatBuffer**
|
5. **Transmit/Store the serialized FlatBuffer**
|
||||||
|
|
||||||
Use your serialized buffer however you want. Send it to someone, save if for
|
Use your serialized buffer however you want. Send it to someone, save it for
|
||||||
later, etc...
|
later, etc...
|
||||||
|
|
||||||
```c++ title="my_monster_factory.cc" linenums="13"
|
```c++ title="my_monster_factory.cc" linenums="13"
|
||||||
|
|||||||
@@ -427,9 +427,6 @@ Current understood attributes:
|
|||||||
it won't be accessible anymore by newer code. Note that if you deprecate a
|
it won't be accessible anymore by newer code. Note that if you deprecate a
|
||||||
field that was previous required, old code may fail to validate new data (when
|
field that was previous required, old code may fail to validate new data (when
|
||||||
using the optional verifier).
|
using the optional verifier).
|
||||||
|
|
||||||
### `required`
|
|
||||||
|
|
||||||
- `required` (on a non-scalar table field): this field must always be set. By
|
- `required` (on a non-scalar table field): this field must always be set. By
|
||||||
default, fields do not need to be present in the binary. This is desirable, as
|
default, fields do not need to be present in the binary. This is desirable, as
|
||||||
it helps with forwards/backwards compatibility, and flexibility of data
|
it helps with forwards/backwards compatibility, and flexibility of data
|
||||||
|
|||||||
@@ -24,14 +24,14 @@ Codegen for all basic features | Yes | Yes | Yes | Yes | Yes | Ye
|
|||||||
JSON parsing | Yes | No | No | No | No | No | No | Yes | No | No | Yes | No | No
|
JSON parsing | Yes | No | No | No | No | No | No | Yes | No | No | Yes | No | No
|
||||||
Simple mutation | Yes | Yes | Yes | Yes | No | No | No | No | No | No | No | No | Yes
|
Simple mutation | Yes | Yes | Yes | Yes | No | No | No | No | No | No | No | No | Yes
|
||||||
Reflection | Yes | No | No | No | No | No | No | Basic | No | No | No | No | No
|
Reflection | Yes | No | No | No | No | No | No | Basic | No | No | No | No | No
|
||||||
Buffer verifier | Yes | No | No | No | No | No | No | Yes | No | No | No | No | No
|
Buffer verifier | Yes | No | No | No | No | No | No | Yes | No | No | No | No | Yes
|
||||||
Native Object API | Yes | No | Yes | Yes | Yes | Yes | Yes | No | No | Yes | No | No | No
|
Native Object API | Yes | No | Yes | Yes | Yes | Yes | Yes | No | No | Yes | No | No | Yes
|
||||||
Optional Scalars | Yes | Yes | Yes | No | No | Yes | Yes | Yes | No | No | Yes | Yes | Yes
|
Optional Scalars | Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | No | No | Yes | Yes | Yes
|
||||||
Flexbuffers | Yes | Yes | ? | ? | ? | ? | ? | ? | ? | ? | ? | Yes | ?
|
Flexbuffers | Yes | Yes | ? | ? | ? | ? | ? | ? | ? | ? | ? | Yes | Yes
|
||||||
Testing: basic | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | ? | Yes | Yes | Yes | Yes
|
Testing: basic | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | ? | Yes | Yes | Yes | Yes
|
||||||
Testing: fuzz | Yes | No | No | Yes | Yes | No | No | No | ? | No | No | Yes | No
|
Testing: fuzz | Yes | No | No | Yes | Yes | No | No | No | ? | No | No | Yes | No
|
||||||
Performance: | Superb | Great | Great | Great | Ok | ? | ? | Superb | ? | ? | Great | Superb | Great
|
Performance: | Superb | Great | Great | Great | Ok | ? | ? | Superb | ? | ? | Great | Superb | Great
|
||||||
Platform: Windows | VS2010 | Yes | Yes | ? | ? | ? | Yes | VS2010 | ? | Yes | Yes | Yes | No
|
Platform: Windows | VS2010 | Yes | Yes | ? | ? | ? | Yes | VS2010 | ? | Yes | Yes | Yes | Yes
|
||||||
Platform: Linux | GCC282 | Yes | ? | Yes | Yes | ? | Yes | Yes | ? | Yes | Yes | Yes | Yes
|
Platform: Linux | GCC282 | Yes | ? | Yes | Yes | ? | Yes | Yes | ? | Yes | Yes | Yes | Yes
|
||||||
Platform: OS X | Xcode4 | ? | ? | ? | Yes | ? | Yes | Yes | ? | Yes | Yes | Yes | Yes
|
Platform: OS X | Xcode4 | ? | ? | ? | Yes | ? | Yes | Yes | ? | Yes | Yes | Yes | Yes
|
||||||
Platform: Android | NDK10d | Yes | ? | ? | ? | ? | ? | ? | ? | Flutter | Yes | ? | No
|
Platform: Android | NDK10d | Yes | ? | ? | ? | ? | ? | ? | ? | Flutter | Yes | ? | No
|
||||||
|
|||||||
@@ -1134,12 +1134,8 @@ The Builder provides multiple ways to create `vectors`.
|
|||||||
=== "Python"
|
=== "Python"
|
||||||
|
|
||||||
```py
|
```py
|
||||||
# Create a FlatBuffer vector and prepend the weapons.
|
# Use the generated helper to create the weapons vector from offsets.
|
||||||
# Note: Since we prepend the data, prepend them in reverse order.
|
weapons = MyGame.Sample.Monster.CreateWeaponsVector(builder, [sword, axe])
|
||||||
MyGame.Sample.Monster.StartWeaponsVector(builder, 2)
|
|
||||||
builder.PrependUOffsetTRelative(axe)
|
|
||||||
builder.PrependUOffsetTRelative(sword)
|
|
||||||
weapons = builder.EndVector()
|
|
||||||
```
|
```
|
||||||
|
|
||||||
=== "Rust"
|
=== "Rust"
|
||||||
@@ -1352,16 +1348,13 @@ bit more directly.
|
|||||||
```py
|
```py
|
||||||
# Create a `vector` representing the inventory of the Orc. Each number
|
# Create a `vector` representing the inventory of the Orc. Each number
|
||||||
# could correspond to an item that can be claimed after he is slain.
|
# could correspond to an item that can be claimed after he is slain.
|
||||||
# Note: Since we prepend the bytes, this loop iterates in reverse.
|
inv = MyGame.Sample.Monster.CreateInventoryVector(builder, range(0, 10))
|
||||||
MyGame.Sample.Monster.StartInventoryVector(builder, 10)
|
|
||||||
for i in reversed(range(0, 10)):
|
|
||||||
builder.PrependByte(i)
|
|
||||||
inv = builder.EndVector()
|
|
||||||
|
|
||||||
MyGame.Sample.Monster.StartPathVector(builder, 2)
|
path_points = [
|
||||||
MyGame.Sample.Vec3.CreateVec3(builder, 1.0, 2.0, 3.0)
|
MyGame.Sample.Vec3T(x=1.0, y=2.0, z=3.0),
|
||||||
MyGame.Sample.Vec3.CreateVec3(builder, 4.0, 5.0, 6.0)
|
MyGame.Sample.Vec3T(x=4.0, y=5.0, z=6.0),
|
||||||
path = builder.EndVector()
|
]
|
||||||
|
path = MyGame.Sample.Monster.CreatePathVector(builder, path_points)
|
||||||
```
|
```
|
||||||
|
|
||||||
=== "Rust"
|
=== "Rust"
|
||||||
@@ -2056,7 +2049,7 @@ functions to get the root object given the buffer.
|
|||||||
```c++
|
```c++
|
||||||
uint8_t *buffer_pointer = /* the data you just read */;
|
uint8_t *buffer_pointer = /* the data you just read */;
|
||||||
|
|
||||||
// Get an view to the root object inside the buffer.
|
// Get a view to the root object inside the buffer.
|
||||||
Monster monster = GetMonster(buffer_pointer);
|
Monster monster = GetMonster(buffer_pointer);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -2076,7 +2069,7 @@ functions to get the root object given the buffer.
|
|||||||
```c#
|
```c#
|
||||||
byte[] bytes = /* the data you just read */
|
byte[] bytes = /* the data you just read */
|
||||||
|
|
||||||
// Get an view to the root object inside the buffer.
|
// Get a view to the root object inside the buffer.
|
||||||
Monster monster = Monster.GetRootAsMonster(new ByteBuffer(bytes));
|
Monster monster = Monster.GetRootAsMonster(new ByteBuffer(bytes));
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ func GetByte(buf []byte) byte {
|
|||||||
|
|
||||||
// GetBool decodes a little-endian bool from a byte slice.
|
// GetBool decodes a little-endian bool from a byte slice.
|
||||||
func GetBool(buf []byte) bool {
|
func GetBool(buf []byte) bool {
|
||||||
return buf[0] == 1
|
return buf[0] != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUint8 decodes a little-endian uint8 from a byte slice.
|
// GetUint8 decodes a little-endian uint8 from a byte slice.
|
||||||
|
|||||||
15
go/table.go
15
go/table.go
@@ -31,10 +31,25 @@ func (t *Table) String(off UOffsetT) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ByteVector gets a byte slice from data stored inside the flatbuffer.
|
// ByteVector gets a byte slice from data stored inside the flatbuffer.
|
||||||
|
// If the offset is invalid or out of bounds, returns nil to prevent crashes.
|
||||||
func (t *Table) ByteVector(off UOffsetT) []byte {
|
func (t *Table) ByteVector(off UOffsetT) []byte {
|
||||||
|
n := UOffsetT(len(t.Bytes))
|
||||||
|
// Need at least SizeUOffsetT bytes to read the relative vector offset.
|
||||||
|
u := UOffsetT(SizeUOffsetT)
|
||||||
|
if n < u || off > n-u {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
off += GetUOffsetT(t.Bytes[off:])
|
off += GetUOffsetT(t.Bytes[off:])
|
||||||
|
// Need at least SizeUOffsetT bytes to read the vector length.
|
||||||
|
if n < u || off > n-u {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
start := off + UOffsetT(SizeUOffsetT)
|
start := off + UOffsetT(SizeUOffsetT)
|
||||||
length := GetUOffsetT(t.Bytes[off:])
|
length := GetUOffsetT(t.Bytes[off:])
|
||||||
|
// Avoid overflow by checking the length against the remaining buffer space.
|
||||||
|
if length > n-start {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return t.Bytes[start : start+length]
|
return t.Bytes[start : start+length]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,8 @@
|
|||||||
// Ensure the included flatbuffers.h is the same version as when this file was
|
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||||
// generated, otherwise it may not be compatible.
|
// generated, otherwise it may not be compatible.
|
||||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
||||||
FLATBUFFERS_VERSION_MINOR == 9 &&
|
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||||
FLATBUFFERS_VERSION_REVISION == 23,
|
FLATBUFFERS_VERSION_REVISION == 19,
|
||||||
"Non-compatible flatbuffers version included");
|
"Non-compatible flatbuffers version included");
|
||||||
|
|
||||||
namespace flatbuffers {
|
namespace flatbuffers {
|
||||||
@@ -30,7 +30,8 @@ struct Galaxy FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
int64_t num_stars() const {
|
int64_t num_stars() const {
|
||||||
return GetField<int64_t>(VT_NUM_STARS, 0);
|
return GetField<int64_t>(VT_NUM_STARS, 0);
|
||||||
}
|
}
|
||||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
template <bool B = false>
|
||||||
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
return VerifyTableStart(verifier) &&
|
return VerifyTableStart(verifier) &&
|
||||||
VerifyField<int64_t>(verifier, VT_NUM_STARS, 8) &&
|
VerifyField<int64_t>(verifier, VT_NUM_STARS, 8) &&
|
||||||
verifier.EndTable();
|
verifier.EndTable();
|
||||||
@@ -75,7 +76,8 @@ struct Universe FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const ::flatbuffers::Vector<::flatbuffers::Offset<flatbuffers::goldens::Galaxy>> *galaxies() const {
|
const ::flatbuffers::Vector<::flatbuffers::Offset<flatbuffers::goldens::Galaxy>> *galaxies() const {
|
||||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<flatbuffers::goldens::Galaxy>> *>(VT_GALAXIES);
|
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<flatbuffers::goldens::Galaxy>> *>(VT_GALAXIES);
|
||||||
}
|
}
|
||||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
template <bool B = false>
|
||||||
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
return VerifyTableStart(verifier) &&
|
return VerifyTableStart(verifier) &&
|
||||||
VerifyField<double>(verifier, VT_AGE, 8) &&
|
VerifyField<double>(verifier, VT_AGE, 8) &&
|
||||||
VerifyOffset(verifier, VT_GALAXIES) &&
|
VerifyOffset(verifier, VT_GALAXIES) &&
|
||||||
@@ -135,14 +137,16 @@ inline const flatbuffers::goldens::Universe *GetSizePrefixedUniverse(const void
|
|||||||
return ::flatbuffers::GetSizePrefixedRoot<flatbuffers::goldens::Universe>(buf);
|
return ::flatbuffers::GetSizePrefixedRoot<flatbuffers::goldens::Universe>(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <bool B = false>
|
||||||
inline bool VerifyUniverseBuffer(
|
inline bool VerifyUniverseBuffer(
|
||||||
::flatbuffers::Verifier &verifier) {
|
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||||
return verifier.VerifyBuffer<flatbuffers::goldens::Universe>(nullptr);
|
return verifier.template VerifyBuffer<flatbuffers::goldens::Universe>(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <bool B = false>
|
||||||
inline bool VerifySizePrefixedUniverseBuffer(
|
inline bool VerifySizePrefixedUniverseBuffer(
|
||||||
::flatbuffers::Verifier &verifier) {
|
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||||
return verifier.VerifySizePrefixedBuffer<flatbuffers::goldens::Universe>(nullptr);
|
return verifier.template VerifySizePrefixedBuffer<flatbuffers::goldens::Universe>(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void FinishUniverseBuffer(
|
inline void FinishUniverseBuffer(
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public struct Galaxy : IFlatbufferObject
|
|||||||
{
|
{
|
||||||
private Table __p;
|
private Table __p;
|
||||||
public ByteBuffer ByteBuffer { get { return __p.bb; } }
|
public ByteBuffer ByteBuffer { get { return __p.bb; } }
|
||||||
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_25_9_23(); }
|
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_25_12_19(); }
|
||||||
public static Galaxy GetRootAsGalaxy(ByteBuffer _bb) { return GetRootAsGalaxy(_bb, new Galaxy()); }
|
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 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); }
|
public void __init(int _i, ByteBuffer _bb) { __p = new Table(_i, _bb); }
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public struct Universe : IFlatbufferObject
|
|||||||
{
|
{
|
||||||
private Table __p;
|
private Table __p;
|
||||||
public ByteBuffer ByteBuffer { get { return __p.bb; } }
|
public ByteBuffer ByteBuffer { get { return __p.bb; } }
|
||||||
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_25_9_23(); }
|
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_25_12_19(); }
|
||||||
public static Universe GetRootAsUniverse(ByteBuffer _bb) { return GetRootAsUniverse(_bb, new Universe()); }
|
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 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); }
|
public static bool VerifyUniverse(ByteBuffer _bb) {Google.FlatBuffers.Verifier verifier = new Google.FlatBuffers.Verifier(_bb); return verifier.VerifyBuffer("", false, UniverseVerify.Verify); }
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import 'dart:typed_data' show Uint8List;
|
|||||||
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Galaxy {
|
class Galaxy {
|
||||||
Galaxy._(this._bc, this._bcOffset);
|
Galaxy._(this._bc, this._bcOffset);
|
||||||
factory Galaxy(List<int> bytes) {
|
factory Galaxy(List<int> bytes) {
|
||||||
|
|||||||
@@ -14,14 +14,13 @@ import com.google.flatbuffers.LongVector;
|
|||||||
import com.google.flatbuffers.ShortVector;
|
import com.google.flatbuffers.ShortVector;
|
||||||
import com.google.flatbuffers.StringVector;
|
import com.google.flatbuffers.StringVector;
|
||||||
import com.google.flatbuffers.Struct;
|
import com.google.flatbuffers.Struct;
|
||||||
import com.google.flatbuffers.Table;
|
|
||||||
import com.google.flatbuffers.UnionVector;
|
import com.google.flatbuffers.UnionVector;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public final class Galaxy extends Table {
|
public final class Galaxy extends com.google.flatbuffers.Table {
|
||||||
public static void ValidateVersion() { Constants.FLATBUFFERS_25_9_23(); }
|
public static void ValidateVersion() { Constants.FLATBUFFERS_25_12_19(); }
|
||||||
public static Galaxy getRootAsGalaxy(ByteBuffer _bb) { return getRootAsGalaxy(_bb, new Galaxy()); }
|
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 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); }
|
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||||
|
|||||||
@@ -14,14 +14,13 @@ import com.google.flatbuffers.LongVector;
|
|||||||
import com.google.flatbuffers.ShortVector;
|
import com.google.flatbuffers.ShortVector;
|
||||||
import com.google.flatbuffers.StringVector;
|
import com.google.flatbuffers.StringVector;
|
||||||
import com.google.flatbuffers.Struct;
|
import com.google.flatbuffers.Struct;
|
||||||
import com.google.flatbuffers.Table;
|
|
||||||
import com.google.flatbuffers.UnionVector;
|
import com.google.flatbuffers.UnionVector;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public final class Universe extends Table {
|
public final class Universe extends com.google.flatbuffers.Table {
|
||||||
public static void ValidateVersion() { Constants.FLATBUFFERS_25_9_23(); }
|
public static void ValidateVersion() { Constants.FLATBUFFERS_25_12_19(); }
|
||||||
public static Universe getRootAsUniverse(ByteBuffer _bb) { return getRootAsUniverse(_bb, new Universe()); }
|
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 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 void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class Galaxy : Table() {
|
|||||||
return if(o != 0) bb.getLong(o + bb_pos) else 0L
|
return if(o != 0) bb.getLong(o + bb_pos) else 0L
|
||||||
}
|
}
|
||||||
companion object {
|
companion object {
|
||||||
fun validateVersion() = Constants.FLATBUFFERS_25_9_23()
|
fun validateVersion() = Constants.FLATBUFFERS_25_12_19()
|
||||||
fun getRootAsGalaxy(_bb: ByteBuffer): Galaxy = getRootAsGalaxy(_bb, Galaxy())
|
fun getRootAsGalaxy(_bb: ByteBuffer): Galaxy = getRootAsGalaxy(_bb, Galaxy())
|
||||||
fun getRootAsGalaxy(_bb: ByteBuffer, obj: Galaxy): Galaxy {
|
fun getRootAsGalaxy(_bb: ByteBuffer, obj: Galaxy): Galaxy {
|
||||||
_bb.order(ByteOrder.LITTLE_ENDIAN)
|
_bb.order(ByteOrder.LITTLE_ENDIAN)
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class Universe : Table() {
|
|||||||
val o = __offset(6); return if (o != 0) __vector_len(o) else 0
|
val o = __offset(6); return if (o != 0) __vector_len(o) else 0
|
||||||
}
|
}
|
||||||
companion object {
|
companion object {
|
||||||
fun validateVersion() = Constants.FLATBUFFERS_25_9_23()
|
fun validateVersion() = Constants.FLATBUFFERS_25_12_19()
|
||||||
fun getRootAsUniverse(_bb: ByteBuffer): Universe = getRootAsUniverse(_bb, Universe())
|
fun getRootAsUniverse(_bb: ByteBuffer): Universe = getRootAsUniverse(_bb, Universe())
|
||||||
fun getRootAsUniverse(_bb: ByteBuffer, obj: Universe): Universe {
|
fun getRootAsUniverse(_bb: ByteBuffer, obj: Universe): Universe {
|
||||||
_bb.order(ByteOrder.LITTLE_ENDIAN)
|
_bb.order(ByteOrder.LITTLE_ENDIAN)
|
||||||
|
|||||||
@@ -80,6 +80,12 @@ def UniverseStartGalaxiesVector(builder, numElems):
|
|||||||
def StartGalaxiesVector(builder, numElems):
|
def StartGalaxiesVector(builder, numElems):
|
||||||
return UniverseStartGalaxiesVector(builder, numElems)
|
return UniverseStartGalaxiesVector(builder, numElems)
|
||||||
|
|
||||||
|
def UniverseCreateGalaxiesVector(builder, data):
|
||||||
|
return builder.CreateVectorOfTables(data)
|
||||||
|
|
||||||
|
def CreateGalaxiesVector(builder, data):
|
||||||
|
UniverseCreateGalaxiesVector(builder, data)
|
||||||
|
|
||||||
def UniverseEnd(builder):
|
def UniverseEnd(builder):
|
||||||
return builder.EndObject()
|
return builder.EndObject()
|
||||||
|
|
||||||
|
|||||||
@@ -1,313 +1,322 @@
|
|||||||
// automatically generated by the FlatBuffers compiler, do not modify
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
|
||||||
|
|
||||||
// @generated
|
// @generated
|
||||||
|
extern crate alloc;
|
||||||
use core::mem;
|
|
||||||
use core::cmp::Ordering;
|
|
||||||
|
|
||||||
extern crate flatbuffers;
|
|
||||||
use self::flatbuffers::{EndianScalar, Follow};
|
|
||||||
|
|
||||||
#[allow(unused_imports, dead_code)]
|
#[allow(unused_imports, dead_code)]
|
||||||
pub mod flatbuffers {
|
pub mod flatbuffers {
|
||||||
|
extern crate alloc;
|
||||||
|
|
||||||
use core::mem;
|
#[allow(unused_imports, dead_code)]
|
||||||
use core::cmp::Ordering;
|
pub mod goldens {
|
||||||
|
extern crate alloc;
|
||||||
|
|
||||||
extern crate flatbuffers;
|
pub enum GalaxyOffset {}
|
||||||
use self::flatbuffers::{EndianScalar, Follow};
|
|
||||||
#[allow(unused_imports, dead_code)]
|
|
||||||
pub mod goldens {
|
|
||||||
|
|
||||||
use core::mem;
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
use core::cmp::Ordering;
|
pub struct Galaxy<'a> {
|
||||||
|
pub _tab: ::flatbuffers::Table<'a>,
|
||||||
|
}
|
||||||
|
|
||||||
extern crate flatbuffers;
|
impl<'a> ::flatbuffers::Follow<'a> for Galaxy<'a> {
|
||||||
use self::flatbuffers::{EndianScalar, Follow};
|
type Inner = Galaxy<'a>;
|
||||||
|
|
||||||
pub enum GalaxyOffset {}
|
#[inline]
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
|
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct Galaxy<'a> {
|
impl<'a> Galaxy<'a> {
|
||||||
pub _tab: flatbuffers::Table<'a>,
|
pub const VT_NUM_STARS: ::flatbuffers::VOffsetT = 4;
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> flatbuffers::Follow<'a> for Galaxy<'a> {
|
#[inline]
|
||||||
type Inner = Galaxy<'a>;
|
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||||
#[inline]
|
Galaxy { _tab: table }
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
}
|
||||||
Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> Galaxy<'a> {
|
#[allow(unused_mut)]
|
||||||
pub const VT_NUM_STARS: flatbuffers::VOffsetT = 4;
|
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||||
|
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||||
#[inline]
|
args: &'args GalaxyArgs
|
||||||
pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
) -> ::flatbuffers::WIPOffset<Galaxy<'bldr>> {
|
||||||
Galaxy { _tab: table }
|
let mut builder = GalaxyBuilder::new(_fbb);
|
||||||
}
|
builder.add_num_stars(args.num_stars);
|
||||||
#[allow(unused_mut)]
|
builder.finish()
|
||||||
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);
|
|
||||||
builder.add_num_stars(args.num_stars);
|
|
||||||
builder.finish()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn num_stars(&self) -> i64 {
|
pub fn num_stars(&self) -> i64 {
|
||||||
// Safety:
|
// Safety:
|
||||||
// Created from valid Table for this object
|
// Created from valid Table for this object
|
||||||
// which contains a valid value in this slot
|
// which contains a valid value in this slot
|
||||||
unsafe { self._tab.get::<i64>(Galaxy::VT_NUM_STARS, Some(0)).unwrap()}
|
unsafe { self._tab.get::<i64>(Galaxy::VT_NUM_STARS, Some(0)).unwrap()}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl flatbuffers::Verifiable for Galaxy<'_> {
|
impl ::flatbuffers::Verifiable for Galaxy<'_> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn run_verifier(
|
fn run_verifier(
|
||||||
v: &mut flatbuffers::Verifier, pos: usize
|
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||||
) -> Result<(), flatbuffers::InvalidFlatbuffer> {
|
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||||
use self::flatbuffers::Verifiable;
|
v.visit_table(pos)?
|
||||||
v.visit_table(pos)?
|
.visit_field::<i64>("num_stars", Self::VT_NUM_STARS, false)?
|
||||||
.visit_field::<i64>("num_stars", Self::VT_NUM_STARS, false)?
|
.finish();
|
||||||
.finish();
|
Ok(())
|
||||||
Ok(())
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
pub struct GalaxyArgs {
|
|
||||||
pub num_stars: i64,
|
|
||||||
}
|
|
||||||
impl<'a> Default for GalaxyArgs {
|
|
||||||
#[inline]
|
|
||||||
fn default() -> Self {
|
|
||||||
GalaxyArgs {
|
|
||||||
num_stars: 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct GalaxyBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
|
pub struct GalaxyArgs {
|
||||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
|
pub num_stars: i64,
|
||||||
start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
|
}
|
||||||
}
|
|
||||||
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, A>) -> GalaxyBuilder<'a, 'b, A> {
|
|
||||||
let start = _fbb.start_table();
|
|
||||||
GalaxyBuilder {
|
|
||||||
fbb_: _fbb,
|
|
||||||
start_: start,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[inline]
|
|
||||||
pub fn finish(self) -> flatbuffers::WIPOffset<Galaxy<'a>> {
|
|
||||||
let o = self.fbb_.end_table(self.start_);
|
|
||||||
flatbuffers::WIPOffset::new(o.value())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl core::fmt::Debug for Galaxy<'_> {
|
impl<'a> Default for GalaxyArgs {
|
||||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
#[inline]
|
||||||
let mut ds = f.debug_struct("Galaxy");
|
fn default() -> Self {
|
||||||
ds.field("num_stars", &self.num_stars());
|
GalaxyArgs {
|
||||||
ds.finish()
|
num_stars: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub enum UniverseOffset {}
|
}
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
|
||||||
|
|
||||||
pub struct Universe<'a> {
|
pub struct GalaxyBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
|
||||||
pub _tab: flatbuffers::Table<'a>,
|
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||||
}
|
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a> flatbuffers::Follow<'a> for Universe<'a> {
|
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> GalaxyBuilder<'a, 'b, A> {
|
||||||
type Inner = Universe<'a>;
|
#[inline]
|
||||||
#[inline]
|
pub fn add_num_stars(&mut self, num_stars: i64) {
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
self.fbb_.push_slot::<i64>(Galaxy::VT_NUM_STARS, num_stars, 0);
|
||||||
Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } }
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> Universe<'a> {
|
#[inline]
|
||||||
pub const VT_AGE: flatbuffers::VOffsetT = 4;
|
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> GalaxyBuilder<'a, 'b, A> {
|
||||||
pub const VT_GALAXIES: flatbuffers::VOffsetT = 6;
|
let start = _fbb.start_table();
|
||||||
|
GalaxyBuilder {
|
||||||
|
fbb_: _fbb,
|
||||||
|
start_: start,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
pub fn finish(self) -> ::flatbuffers::WIPOffset<Galaxy<'a>> {
|
||||||
Universe { _tab: table }
|
let o = self.fbb_.end_table(self.start_);
|
||||||
}
|
::flatbuffers::WIPOffset::new(o.value())
|
||||||
#[allow(unused_mut)]
|
}
|
||||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
|
}
|
||||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
|
|
||||||
args: &'args UniverseArgs<'args>
|
impl ::core::fmt::Debug for Galaxy<'_> {
|
||||||
) -> flatbuffers::WIPOffset<Universe<'bldr>> {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
||||||
let mut builder = UniverseBuilder::new(_fbb);
|
let mut ds = f.debug_struct("Galaxy");
|
||||||
builder.add_age(args.age);
|
ds.field("num_stars", &self.num_stars());
|
||||||
if let Some(x) = args.galaxies { builder.add_galaxies(x); }
|
ds.finish()
|
||||||
builder.finish()
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub enum UniverseOffset {}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
|
pub struct Universe<'a> {
|
||||||
|
pub _tab: ::flatbuffers::Table<'a>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> ::flatbuffers::Follow<'a> for Universe<'a> {
|
||||||
|
type Inner = Universe<'a>;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
|
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Universe<'a> {
|
||||||
|
pub const VT_AGE: ::flatbuffers::VOffsetT = 4;
|
||||||
|
pub const VT_GALAXIES: ::flatbuffers::VOffsetT = 6;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||||
|
Universe { _tab: table }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(unused_mut)]
|
||||||
|
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||||
|
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||||
|
args: &'args UniverseArgs<'args>
|
||||||
|
) -> ::flatbuffers::WIPOffset<Universe<'bldr>> {
|
||||||
|
let mut builder = UniverseBuilder::new(_fbb);
|
||||||
|
builder.add_age(args.age);
|
||||||
|
if let Some(x) = args.galaxies { builder.add_galaxies(x); }
|
||||||
|
builder.finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn age(&self) -> f64 {
|
pub fn age(&self) -> f64 {
|
||||||
// Safety:
|
// Safety:
|
||||||
// Created from valid Table for this object
|
// Created from valid Table for this object
|
||||||
// which contains a valid value in this slot
|
// which contains a valid value in this slot
|
||||||
unsafe { self._tab.get::<f64>(Universe::VT_AGE, Some(0.0)).unwrap()}
|
unsafe { self._tab.get::<f64>(Universe::VT_AGE, Some(0.0)).unwrap()}
|
||||||
}
|
}
|
||||||
#[inline]
|
|
||||||
pub fn galaxies(&self) -> Option<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Galaxy<'a>>>> {
|
|
||||||
// Safety:
|
|
||||||
// Created from valid Table for this object
|
|
||||||
// which contains a valid value in this slot
|
|
||||||
unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Galaxy>>>>(Universe::VT_GALAXIES, None)}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl flatbuffers::Verifiable for Universe<'_> {
|
#[inline]
|
||||||
#[inline]
|
pub fn galaxies(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Galaxy<'a>>>> {
|
||||||
fn run_verifier(
|
// Safety:
|
||||||
v: &mut flatbuffers::Verifier, pos: usize
|
// Created from valid Table for this object
|
||||||
) -> Result<(), flatbuffers::InvalidFlatbuffer> {
|
// which contains a valid value in this slot
|
||||||
use self::flatbuffers::Verifiable;
|
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Galaxy>>>>(Universe::VT_GALAXIES, None)}
|
||||||
v.visit_table(pos)?
|
}
|
||||||
.visit_field::<f64>("age", Self::VT_AGE, false)?
|
}
|
||||||
.visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, flatbuffers::ForwardsUOffset<Galaxy>>>>("galaxies", Self::VT_GALAXIES, false)?
|
|
||||||
.finish();
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub struct UniverseArgs<'a> {
|
|
||||||
pub age: f64,
|
|
||||||
pub galaxies: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Galaxy<'a>>>>>,
|
|
||||||
}
|
|
||||||
impl<'a> Default for UniverseArgs<'a> {
|
|
||||||
#[inline]
|
|
||||||
fn default() -> Self {
|
|
||||||
UniverseArgs {
|
|
||||||
age: 0.0,
|
|
||||||
galaxies: None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct UniverseBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
|
impl ::flatbuffers::Verifiable for Universe<'_> {
|
||||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
|
#[inline]
|
||||||
start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
|
fn run_verifier(
|
||||||
}
|
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||||
impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> UniverseBuilder<'a, 'b, A> {
|
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||||
#[inline]
|
v.visit_table(pos)?
|
||||||
pub fn add_age(&mut self, age: f64) {
|
.visit_field::<f64>("age", Self::VT_AGE, false)?
|
||||||
self.fbb_.push_slot::<f64>(Universe::VT_AGE, age, 0.0);
|
.visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<Galaxy>>>>("galaxies", Self::VT_GALAXIES, false)?
|
||||||
}
|
.finish();
|
||||||
#[inline]
|
Ok(())
|
||||||
pub fn add_galaxies(&mut self, galaxies: flatbuffers::WIPOffset<flatbuffers::Vector<'b , flatbuffers::ForwardsUOffset<Galaxy<'b >>>>) {
|
}
|
||||||
self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Universe::VT_GALAXIES, galaxies);
|
}
|
||||||
}
|
|
||||||
#[inline]
|
|
||||||
pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> UniverseBuilder<'a, 'b, A> {
|
|
||||||
let start = _fbb.start_table();
|
|
||||||
UniverseBuilder {
|
|
||||||
fbb_: _fbb,
|
|
||||||
start_: start,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[inline]
|
|
||||||
pub fn finish(self) -> flatbuffers::WIPOffset<Universe<'a>> {
|
|
||||||
let o = self.fbb_.end_table(self.start_);
|
|
||||||
flatbuffers::WIPOffset::new(o.value())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl core::fmt::Debug for Universe<'_> {
|
pub struct UniverseArgs<'a> {
|
||||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
pub age: f64,
|
||||||
let mut ds = f.debug_struct("Universe");
|
pub galaxies: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Galaxy<'a>>>>>,
|
||||||
ds.field("age", &self.age());
|
}
|
||||||
ds.field("galaxies", &self.galaxies());
|
|
||||||
ds.finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[inline]
|
|
||||||
/// Verifies that a buffer of bytes contains a `Universe`
|
|
||||||
/// and returns it.
|
|
||||||
/// Note that verification is still experimental and may not
|
|
||||||
/// catch every error, or be maximally performant. For the
|
|
||||||
/// previous, unchecked, behavior use
|
|
||||||
/// `root_as_universe_unchecked`.
|
|
||||||
pub fn root_as_universe(buf: &[u8]) -> Result<Universe, flatbuffers::InvalidFlatbuffer> {
|
|
||||||
flatbuffers::root::<Universe>(buf)
|
|
||||||
}
|
|
||||||
#[inline]
|
|
||||||
/// Verifies that a buffer of bytes contains a size prefixed
|
|
||||||
/// `Universe` and returns it.
|
|
||||||
/// Note that verification is still experimental and may not
|
|
||||||
/// catch every error, or be maximally performant. For the
|
|
||||||
/// previous, unchecked, behavior use
|
|
||||||
/// `size_prefixed_root_as_universe_unchecked`.
|
|
||||||
pub fn size_prefixed_root_as_universe(buf: &[u8]) -> Result<Universe, flatbuffers::InvalidFlatbuffer> {
|
|
||||||
flatbuffers::size_prefixed_root::<Universe>(buf)
|
|
||||||
}
|
|
||||||
#[inline]
|
|
||||||
/// Verifies, with the given options, that a buffer of bytes
|
|
||||||
/// contains a `Universe` and returns it.
|
|
||||||
/// Note that verification is still experimental and may not
|
|
||||||
/// catch every error, or be maximally performant. For the
|
|
||||||
/// previous, unchecked, behavior use
|
|
||||||
/// `root_as_universe_unchecked`.
|
|
||||||
pub fn root_as_universe_with_opts<'b, 'o>(
|
|
||||||
opts: &'o flatbuffers::VerifierOptions,
|
|
||||||
buf: &'b [u8],
|
|
||||||
) -> Result<Universe<'b>, flatbuffers::InvalidFlatbuffer> {
|
|
||||||
flatbuffers::root_with_opts::<Universe<'b>>(opts, buf)
|
|
||||||
}
|
|
||||||
#[inline]
|
|
||||||
/// Verifies, with the given verifier options, that a buffer of
|
|
||||||
/// bytes contains a size prefixed `Universe` and returns
|
|
||||||
/// it. Note that verification is still experimental and may not
|
|
||||||
/// catch every error, or be maximally performant. For the
|
|
||||||
/// previous, unchecked, behavior use
|
|
||||||
/// `root_as_universe_unchecked`.
|
|
||||||
pub fn size_prefixed_root_as_universe_with_opts<'b, 'o>(
|
|
||||||
opts: &'o flatbuffers::VerifierOptions,
|
|
||||||
buf: &'b [u8],
|
|
||||||
) -> Result<Universe<'b>, flatbuffers::InvalidFlatbuffer> {
|
|
||||||
flatbuffers::size_prefixed_root_with_opts::<Universe<'b>>(opts, buf)
|
|
||||||
}
|
|
||||||
#[inline]
|
|
||||||
/// Assumes, without verification, that a buffer of bytes contains a Universe and returns it.
|
|
||||||
/// # Safety
|
|
||||||
/// Callers must trust the given bytes do indeed contain a valid `Universe`.
|
|
||||||
pub unsafe fn root_as_universe_unchecked(buf: &[u8]) -> Universe {
|
|
||||||
unsafe { flatbuffers::root_unchecked::<Universe>(buf) }
|
|
||||||
}
|
|
||||||
#[inline]
|
|
||||||
/// Assumes, without verification, that a buffer of bytes contains a size prefixed Universe and returns it.
|
|
||||||
/// # Safety
|
|
||||||
/// Callers must trust the given bytes do indeed contain a valid size prefixed `Universe`.
|
|
||||||
pub unsafe fn size_prefixed_root_as_universe_unchecked(buf: &[u8]) -> Universe {
|
|
||||||
unsafe { flatbuffers::size_prefixed_root_unchecked::<Universe>(buf) }
|
|
||||||
}
|
|
||||||
#[inline]
|
|
||||||
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]
|
impl<'a> Default for UniverseArgs<'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>>) {
|
#[inline]
|
||||||
fbb.finish_size_prefixed(root, None);
|
fn default() -> Self {
|
||||||
}
|
UniverseArgs {
|
||||||
} // pub mod goldens
|
age: 0.0,
|
||||||
} // pub mod flatbuffers
|
galaxies: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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, 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn add_galaxies(&mut self, galaxies: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<Galaxy<'b >>>>) {
|
||||||
|
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Universe::VT_GALAXIES, galaxies);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> UniverseBuilder<'a, 'b, A> {
|
||||||
|
let start = _fbb.start_table();
|
||||||
|
UniverseBuilder {
|
||||||
|
fbb_: _fbb,
|
||||||
|
start_: start,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn finish(self) -> ::flatbuffers::WIPOffset<Universe<'a>> {
|
||||||
|
let o = self.fbb_.end_table(self.start_);
|
||||||
|
::flatbuffers::WIPOffset::new(o.value())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::core::fmt::Debug for Universe<'_> {
|
||||||
|
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
||||||
|
let mut ds = f.debug_struct("Universe");
|
||||||
|
ds.field("age", &self.age());
|
||||||
|
ds.field("galaxies", &self.galaxies());
|
||||||
|
ds.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Verifies that a buffer of bytes contains a `Universe`
|
||||||
|
/// and returns it.
|
||||||
|
/// Note that verification is still experimental and may not
|
||||||
|
/// catch every error, or be maximally performant. For the
|
||||||
|
/// previous, unchecked, behavior use
|
||||||
|
/// `root_as_universe_unchecked`.
|
||||||
|
#[inline]
|
||||||
|
pub fn root_as_universe(buf: &[u8]) -> Result<Universe<'_>, ::flatbuffers::InvalidFlatbuffer> {
|
||||||
|
::flatbuffers::root::<Universe>(buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Verifies that a buffer of bytes contains a size prefixed
|
||||||
|
/// `Universe` and returns it.
|
||||||
|
/// Note that verification is still experimental and may not
|
||||||
|
/// catch every error, or be maximally performant. For the
|
||||||
|
/// previous, unchecked, behavior use
|
||||||
|
/// `size_prefixed_root_as_universe_unchecked`.
|
||||||
|
#[inline]
|
||||||
|
pub fn size_prefixed_root_as_universe(buf: &[u8]) -> Result<Universe<'_>, ::flatbuffers::InvalidFlatbuffer> {
|
||||||
|
::flatbuffers::size_prefixed_root::<Universe>(buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Verifies, with the given options, that a buffer of bytes
|
||||||
|
/// contains a `Universe` and returns it.
|
||||||
|
/// Note that verification is still experimental and may not
|
||||||
|
/// catch every error, or be maximally performant. For the
|
||||||
|
/// previous, unchecked, behavior use
|
||||||
|
/// `root_as_universe_unchecked`.
|
||||||
|
#[inline]
|
||||||
|
pub fn root_as_universe_with_opts<'b, 'o>(
|
||||||
|
opts: &'o ::flatbuffers::VerifierOptions,
|
||||||
|
buf: &'b [u8],
|
||||||
|
) -> Result<Universe<'b>, ::flatbuffers::InvalidFlatbuffer> {
|
||||||
|
::flatbuffers::root_with_opts::<Universe<'b>>(opts, buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Verifies, with the given verifier options, that a buffer of
|
||||||
|
/// bytes contains a size prefixed `Universe` and returns
|
||||||
|
/// it. Note that verification is still experimental and may not
|
||||||
|
/// catch every error, or be maximally performant. For the
|
||||||
|
/// previous, unchecked, behavior use
|
||||||
|
/// `root_as_universe_unchecked`.
|
||||||
|
#[inline]
|
||||||
|
pub fn size_prefixed_root_as_universe_with_opts<'b, 'o>(
|
||||||
|
opts: &'o ::flatbuffers::VerifierOptions,
|
||||||
|
buf: &'b [u8],
|
||||||
|
) -> Result<Universe<'b>, ::flatbuffers::InvalidFlatbuffer> {
|
||||||
|
::flatbuffers::size_prefixed_root_with_opts::<Universe<'b>>(opts, buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Assumes, without verification, that a buffer of bytes contains a Universe and returns it.
|
||||||
|
/// # Safety
|
||||||
|
/// Callers must trust the given bytes do indeed contain a valid `Universe`.
|
||||||
|
#[inline]
|
||||||
|
pub unsafe fn root_as_universe_unchecked(buf: &[u8]) -> Universe<'_> {
|
||||||
|
unsafe { ::flatbuffers::root_unchecked::<Universe>(buf) }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Assumes, without verification, that a buffer of bytes contains a size prefixed Universe and returns it.
|
||||||
|
/// # Safety
|
||||||
|
/// Callers must trust the given bytes do indeed contain a valid size prefixed `Universe`.
|
||||||
|
#[inline]
|
||||||
|
pub unsafe fn size_prefixed_root_as_universe_unchecked(buf: &[u8]) -> Universe<'_> {
|
||||||
|
unsafe { ::flatbuffers::size_prefixed_root_unchecked::<Universe>(buf) }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
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, 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
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ import Common
|
|||||||
|
|
||||||
import FlatBuffers
|
import FlatBuffers
|
||||||
|
|
||||||
public struct flatbuffers_goldens_Galaxy: FlatBufferObject, Verifiable {
|
public struct flatbuffers_goldens_Galaxy: FlatBufferTable, FlatbuffersVectorInitializable, Verifiable {
|
||||||
|
|
||||||
static func validateVersion() { FlatBuffersVersion_25_9_23() }
|
static func validateVersion() { FlatBuffersVersion_25_12_19() }
|
||||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||||
private var _accessor: Table
|
private var _accessor: Table
|
||||||
|
|
||||||
@@ -43,9 +43,9 @@ public struct flatbuffers_goldens_Galaxy: FlatBufferObject, Verifiable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct flatbuffers_goldens_Universe: FlatBufferObject, Verifiable {
|
public struct flatbuffers_goldens_Universe: FlatBufferTable, FlatbuffersVectorInitializable, Verifiable {
|
||||||
|
|
||||||
static func validateVersion() { FlatBuffersVersion_25_9_23() }
|
static func validateVersion() { FlatBuffersVersion_25_12_19() }
|
||||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||||
private var _accessor: Table
|
private var _accessor: Table
|
||||||
|
|
||||||
@@ -60,9 +60,7 @@ public struct flatbuffers_goldens_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 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 galaxies: FlatbufferVector<flatbuffers_goldens_Galaxy> { return _accessor.vector(at: VTOFFSET.galaxies.v, byteSize: 4) }
|
||||||
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) -> 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 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 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) }
|
public static func addVectorOf(galaxies: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: galaxies, at: VTOFFSET.galaxies.p) }
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
import * as flatbuffers from 'flatbuffers';
|
import * as flatbuffers from 'flatbuffers';
|
||||||
|
|
||||||
import { Galaxy } from '../../flatbuffers/goldens/galaxy.js';
|
import { Galaxy } from './galaxy.js';
|
||||||
|
|
||||||
|
|
||||||
export class Universe {
|
export class Universe {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// swift-tools-version:5.9
|
// swift-tools-version:5.10
|
||||||
/*
|
/*
|
||||||
* Copyright 2020 Google Inc. All rights reserved.
|
* Copyright 2020 Google Inc. All rights reserved.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -8,25 +8,23 @@ import Common
|
|||||||
|
|
||||||
import FlatBuffers
|
import FlatBuffers
|
||||||
|
|
||||||
public struct models_HelloReply: FlatBufferObject, Verifiable {
|
public struct models_HelloReply: FlatBufferTable, FlatbuffersVectorInitializable, Verifiable {
|
||||||
|
|
||||||
static func validateVersion() { FlatBuffersVersion_25_9_23() }
|
static func validateVersion() { FlatBuffersVersion_25_12_19() }
|
||||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||||
private var _accessor: Table
|
private var _accessor: Table
|
||||||
|
|
||||||
private init(_ t: Table) { _accessor = t }
|
private init(_ t: Table) { _accessor = t }
|
||||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||||
|
|
||||||
private enum VTOFFSET: VOffset {
|
private struct VT {
|
||||||
case message = 4
|
static let message: VOffset = 4
|
||||||
var v: Int32 { Int32(self.rawValue) }
|
|
||||||
var p: VOffset { self.rawValue }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public var message: String? { let o = _accessor.offset(VTOFFSET.message.v); return o == 0 ? nil : _accessor.string(at: o) }
|
public var message: String? { let o = _accessor.offset(VT.message); return o == 0 ? nil : _accessor.string(at: o) }
|
||||||
public var messageSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.message.v) }
|
public var messageSegmentArray: [UInt8]? { return _accessor.getVector(at: VT.message) }
|
||||||
public static func startHelloReply(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
|
public static func startHelloReply(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
|
||||||
public static func add(message: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: message, at: VTOFFSET.message.p) }
|
public static func add(message: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: message, at: VT.message) }
|
||||||
public static func endHelloReply(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
public static func endHelloReply(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||||
public static func createHelloReply(
|
public static func createHelloReply(
|
||||||
_ fbb: inout FlatBufferBuilder,
|
_ fbb: inout FlatBufferBuilder,
|
||||||
@@ -39,41 +37,39 @@ public struct models_HelloReply: FlatBufferObject, Verifiable {
|
|||||||
|
|
||||||
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
|
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
|
||||||
var _v = try verifier.visitTable(at: position)
|
var _v = try verifier.visitTable(at: position)
|
||||||
try _v.visit(field: VTOFFSET.message.p, fieldName: "message", required: false, type: ForwardOffset<String>.self)
|
try _v.visit(field: VT.message, fieldName: "message", required: false, type: ForwardOffset<String>.self)
|
||||||
_v.finish()
|
_v.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension models_HelloReply: Encodable {
|
extension models_HelloReply: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case message = "message"
|
case message = "message"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encodeIfPresent(message, forKey: .message)
|
try container.encodeIfPresent(message, forKey: .message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct models_HelloRequest: FlatBufferObject, Verifiable {
|
public struct models_HelloRequest: FlatBufferTable, FlatbuffersVectorInitializable, Verifiable {
|
||||||
|
|
||||||
static func validateVersion() { FlatBuffersVersion_25_9_23() }
|
static func validateVersion() { FlatBuffersVersion_25_12_19() }
|
||||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||||
private var _accessor: Table
|
private var _accessor: Table
|
||||||
|
|
||||||
private init(_ t: Table) { _accessor = t }
|
private init(_ t: Table) { _accessor = t }
|
||||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||||
|
|
||||||
private enum VTOFFSET: VOffset {
|
private struct VT {
|
||||||
case name = 4
|
static let name: VOffset = 4
|
||||||
var v: Int32 { Int32(self.rawValue) }
|
|
||||||
var p: VOffset { self.rawValue }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public var name: String? { let o = _accessor.offset(VTOFFSET.name.v); return o == 0 ? nil : _accessor.string(at: o) }
|
public var name: String? { let o = _accessor.offset(VT.name); return o == 0 ? nil : _accessor.string(at: o) }
|
||||||
public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.name.v) }
|
public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: VT.name) }
|
||||||
public static func startHelloRequest(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
|
public static func startHelloRequest(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
|
||||||
public static func add(name: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: name, at: VTOFFSET.name.p) }
|
public static func add(name: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: name, at: VT.name) }
|
||||||
public static func endHelloRequest(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
public static func endHelloRequest(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||||
public static func createHelloRequest(
|
public static func createHelloRequest(
|
||||||
_ fbb: inout FlatBufferBuilder,
|
_ fbb: inout FlatBufferBuilder,
|
||||||
@@ -86,16 +82,16 @@ public struct models_HelloRequest: FlatBufferObject, Verifiable {
|
|||||||
|
|
||||||
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
|
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
|
||||||
var _v = try verifier.visitTable(at: position)
|
var _v = try verifier.visitTable(at: position)
|
||||||
try _v.visit(field: VTOFFSET.name.p, fieldName: "name", required: false, type: ForwardOffset<String>.self)
|
try _v.visit(field: VT.name, fieldName: "name", required: false, type: ForwardOffset<String>.self)
|
||||||
_v.finish()
|
_v.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension models_HelloRequest: Encodable {
|
extension models_HelloRequest: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case name = "name"
|
case name = "name"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encodeIfPresent(name, forKey: .name)
|
try container.encodeIfPresent(name, forKey: .name)
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ func greet(name: String, client greeter: models_GreeterServiceClient) {
|
|||||||
// Make the RPC call to the server.
|
// Make the RPC call to the server.
|
||||||
let sayHello =
|
let sayHello =
|
||||||
greeter
|
greeter
|
||||||
.SayHello(Message<models_HelloRequest>(builder: &builder))
|
.SayHello(Message<models_HelloRequest>(builder: &builder))
|
||||||
|
|
||||||
// wait() on the response to stop the program from exiting before the response is received.
|
// wait() on the response to stop the program from exiting before the response is received.
|
||||||
do {
|
do {
|
||||||
|
|||||||
@@ -32,8 +32,7 @@ class Greeter: models_GreeterProvider {
|
|||||||
|
|
||||||
func SayHello(
|
func SayHello(
|
||||||
request: Message<models_HelloRequest>,
|
request: Message<models_HelloRequest>,
|
||||||
context: StatusOnlyCallContext
|
context: StatusOnlyCallContext)
|
||||||
)
|
|
||||||
-> EventLoopFuture<Message<models_HelloReply>>
|
-> EventLoopFuture<Message<models_HelloReply>>
|
||||||
{
|
{
|
||||||
let recipient = request.object.name ?? "Stranger"
|
let recipient = request.object.name ?? "Stranger"
|
||||||
@@ -48,15 +47,14 @@ class Greeter: models_GreeterProvider {
|
|||||||
|
|
||||||
func SayManyHellos(
|
func SayManyHellos(
|
||||||
request: Message<models_HelloRequest>,
|
request: Message<models_HelloRequest>,
|
||||||
context: StreamingResponseCallContext<Message<models_HelloReply>>
|
context: StreamingResponseCallContext<Message<models_HelloReply>>)
|
||||||
)
|
|
||||||
-> EventLoopFuture<GRPCStatus>
|
-> EventLoopFuture<GRPCStatus>
|
||||||
{
|
{
|
||||||
for name in greetings {
|
for name in greetings {
|
||||||
var builder = FlatBufferBuilder()
|
var builder = FlatBufferBuilder()
|
||||||
let off =
|
let off =
|
||||||
builder
|
builder
|
||||||
.create(string: "\(name) \(request.object.name ?? "Unknown")")
|
.create(string: "\(name) \(request.object.name ?? "Unknown")")
|
||||||
let root = models_HelloReply.createHelloReply(
|
let root = models_HelloReply.createHelloReply(
|
||||||
&builder,
|
&builder,
|
||||||
messageOffset: off)
|
messageOffset: off)
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
#include "greeter.grpc.fb.h"
|
|
||||||
#include "greeter_generated.h"
|
|
||||||
|
|
||||||
#include <grpcpp/grpcpp.h>
|
#include <grpcpp/grpcpp.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "greeter.grpc.fb.h"
|
||||||
|
#include "greeter_generated.h"
|
||||||
|
|
||||||
class GreeterClient {
|
class GreeterClient {
|
||||||
public:
|
public:
|
||||||
GreeterClient(std::shared_ptr<grpc::Channel> channel)
|
GreeterClient(std::shared_ptr<grpc::Channel> channel)
|
||||||
: stub_(Greeter::NewStub(channel)) {}
|
: stub_(Greeter::NewStub(channel)) {}
|
||||||
|
|
||||||
std::string SayHello(const std::string &name) {
|
std::string SayHello(const std::string& name) {
|
||||||
flatbuffers::grpc::MessageBuilder mb;
|
flatbuffers::grpc::MessageBuilder mb;
|
||||||
auto name_offset = mb.CreateString(name);
|
auto name_offset = mb.CreateString(name);
|
||||||
auto request_offset = CreateHelloRequest(mb, name_offset);
|
auto request_offset = CreateHelloRequest(mb, name_offset);
|
||||||
@@ -25,7 +25,7 @@ class GreeterClient {
|
|||||||
|
|
||||||
auto status = stub_->SayHello(&context, request_msg, &response_msg);
|
auto status = stub_->SayHello(&context, request_msg, &response_msg);
|
||||||
if (status.ok()) {
|
if (status.ok()) {
|
||||||
const HelloReply *response = response_msg.GetRoot();
|
const HelloReply* response = response_msg.GetRoot();
|
||||||
return response->message()->str();
|
return response->message()->str();
|
||||||
} else {
|
} else {
|
||||||
std::cerr << status.error_code() << ": " << status.error_message()
|
std::cerr << status.error_code() << ": " << status.error_message()
|
||||||
@@ -34,8 +34,8 @@ class GreeterClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SayManyHellos(const std::string &name, int num_greetings,
|
void SayManyHellos(const std::string& name, int num_greetings,
|
||||||
std::function<void(const std::string &)> callback) {
|
std::function<void(const std::string&)> callback) {
|
||||||
flatbuffers::grpc::MessageBuilder mb;
|
flatbuffers::grpc::MessageBuilder mb;
|
||||||
auto name_offset = mb.CreateString(name);
|
auto name_offset = mb.CreateString(name);
|
||||||
auto request_offset =
|
auto request_offset =
|
||||||
@@ -49,7 +49,7 @@ class GreeterClient {
|
|||||||
|
|
||||||
auto stream = stub_->SayManyHellos(&context, request_msg);
|
auto stream = stub_->SayManyHellos(&context, request_msg);
|
||||||
while (stream->Read(&response_msg)) {
|
while (stream->Read(&response_msg)) {
|
||||||
const HelloReply *response = response_msg.GetRoot();
|
const HelloReply* response = response_msg.GetRoot();
|
||||||
callback(response->message()->str());
|
callback(response->message()->str());
|
||||||
}
|
}
|
||||||
auto status = stream->Finish();
|
auto status = stream->Finish();
|
||||||
@@ -64,7 +64,7 @@ class GreeterClient {
|
|||||||
std::unique_ptr<Greeter::Stub> stub_;
|
std::unique_ptr<Greeter::Stub> stub_;
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char** argv) {
|
||||||
std::string server_address("localhost:50051");
|
std::string server_address("localhost:50051");
|
||||||
|
|
||||||
auto channel =
|
auto channel =
|
||||||
@@ -77,7 +77,7 @@ int main(int argc, char **argv) {
|
|||||||
std::cerr << "Greeter received: " << message << std::endl;
|
std::cerr << "Greeter received: " << message << std::endl;
|
||||||
|
|
||||||
int num_greetings = 10;
|
int num_greetings = 10;
|
||||||
greeter.SayManyHellos(name, num_greetings, [](const std::string &message) {
|
greeter.SayManyHellos(name, num_greetings, [](const std::string& message) {
|
||||||
std::cerr << "Greeter received: " << message << std::endl;
|
std::cerr << "Greeter received: " << message << std::endl;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
#include "greeter.grpc.fb.h"
|
|
||||||
#include "greeter_generated.h"
|
|
||||||
|
|
||||||
#include <grpcpp/grpcpp.h>
|
#include <grpcpp/grpcpp.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "greeter.grpc.fb.h"
|
||||||
|
#include "greeter_generated.h"
|
||||||
|
|
||||||
class GreeterServiceImpl final : public Greeter::Service {
|
class GreeterServiceImpl final : public Greeter::Service {
|
||||||
virtual grpc::Status SayHello(
|
virtual grpc::Status SayHello(
|
||||||
grpc::ServerContext *context,
|
grpc::ServerContext* context,
|
||||||
const flatbuffers::grpc::Message<HelloRequest> *request_msg,
|
const flatbuffers::grpc::Message<HelloRequest>* request_msg,
|
||||||
flatbuffers::grpc::Message<HelloReply> *response_msg) override {
|
flatbuffers::grpc::Message<HelloReply>* response_msg) override {
|
||||||
flatbuffers::grpc::MessageBuilder mb_;
|
flatbuffers::grpc::MessageBuilder mb_;
|
||||||
|
|
||||||
// We call GetRoot to "parse" the message. Verification is already
|
// We call GetRoot to "parse" the message. Verification is already
|
||||||
// performed by default. See the notes below for more details.
|
// performed by default. See the notes below for more details.
|
||||||
const HelloRequest *request = request_msg->GetRoot();
|
const HelloRequest* request = request_msg->GetRoot();
|
||||||
|
|
||||||
// Fields are retrieved as usual with FlatBuffers
|
// Fields are retrieved as usual with FlatBuffers
|
||||||
const std::string &name = request->name()->str();
|
const std::string& name = request->name()->str();
|
||||||
|
|
||||||
// `flatbuffers::grpc::MessageBuilder` is a `FlatBufferBuilder` with a
|
// `flatbuffers::grpc::MessageBuilder` is a `FlatBufferBuilder` with a
|
||||||
// special allocator for efficient gRPC buffer transfer, but otherwise
|
// special allocator for efficient gRPC buffer transfer, but otherwise
|
||||||
@@ -39,14 +39,14 @@ class GreeterServiceImpl final : public Greeter::Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual grpc::Status SayManyHellos(
|
virtual grpc::Status SayManyHellos(
|
||||||
grpc::ServerContext *context,
|
grpc::ServerContext* context,
|
||||||
const flatbuffers::grpc::Message<ManyHellosRequest> *request_msg,
|
const flatbuffers::grpc::Message<ManyHellosRequest>* request_msg,
|
||||||
grpc::ServerWriter<flatbuffers::grpc::Message<HelloReply>> *writer)
|
grpc::ServerWriter<flatbuffers::grpc::Message<HelloReply>>* writer)
|
||||||
override {
|
override {
|
||||||
// The streaming usage below is simply a combination of standard gRPC
|
// The streaming usage below is simply a combination of standard gRPC
|
||||||
// streaming with the FlatBuffers usage shown above.
|
// streaming with the FlatBuffers usage shown above.
|
||||||
const ManyHellosRequest *request = request_msg->GetRoot();
|
const ManyHellosRequest* request = request_msg->GetRoot();
|
||||||
const std::string &name = request->name()->str();
|
const std::string& name = request->name()->str();
|
||||||
int num_greetings = request->num_greetings();
|
int num_greetings = request->num_greetings();
|
||||||
|
|
||||||
for (int i = 0; i < num_greetings; i++) {
|
for (int i = 0; i < num_greetings; i++) {
|
||||||
@@ -75,7 +75,7 @@ void RunServer() {
|
|||||||
server->Wait();
|
server->Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char *argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
RunServer();
|
RunServer();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,31 +76,6 @@ void FormatImports(std::stringstream& ss, const Imports& imports) {
|
|||||||
ss << "\n\n";
|
ss << "\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SaveStub(const std::string& filename, const Imports& imports,
|
|
||||||
const std::string& content) {
|
|
||||||
std::stringstream ss;
|
|
||||||
ss << "# Generated by the gRPC FlatBuffers compiler. DO NOT EDIT!\n"
|
|
||||||
<< '\n'
|
|
||||||
<< "from __future__ import annotations\n"
|
|
||||||
<< '\n';
|
|
||||||
FormatImports(ss, imports);
|
|
||||||
ss << content << '\n';
|
|
||||||
|
|
||||||
EnsureDirExists(StripFileName(filename));
|
|
||||||
return flatbuffers::SaveFile(filename.c_str(), ss.str(), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SaveService(const std::string& filename, const Imports& imports,
|
|
||||||
const std::string& content) {
|
|
||||||
std::stringstream ss;
|
|
||||||
ss << "# Generated by the gRPC FlatBuffers compiler. DO NOT EDIT!\n" << '\n';
|
|
||||||
FormatImports(ss, imports);
|
|
||||||
ss << content << '\n';
|
|
||||||
|
|
||||||
EnsureDirExists(StripFileName(filename));
|
|
||||||
return flatbuffers::SaveFile(filename.c_str(), ss.str(), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
class BaseGenerator {
|
class BaseGenerator {
|
||||||
protected:
|
protected:
|
||||||
BaseGenerator(const Parser& parser, const Namer::Config& config,
|
BaseGenerator(const Parser& parser, const Namer::Config& config,
|
||||||
@@ -175,6 +150,20 @@ class StubGenerator : public BaseGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool SaveStub(const std::string& filename, const Imports& imports,
|
||||||
|
const std::string& content) {
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "# Generated by the gRPC FlatBuffers compiler. DO NOT EDIT!\n"
|
||||||
|
<< '\n'
|
||||||
|
<< "from __future__ import annotations\n"
|
||||||
|
<< '\n';
|
||||||
|
FormatImports(ss, imports);
|
||||||
|
ss << content << '\n';
|
||||||
|
|
||||||
|
EnsureDirExists(StripFileName(filename));
|
||||||
|
return parser_.opts.file_saver->SaveFile(filename.c_str(), ss.str(), false);
|
||||||
|
}
|
||||||
|
|
||||||
void Generate(std::stringstream& ss, const ServiceDef* service,
|
void Generate(std::stringstream& ss, const ServiceDef* service,
|
||||||
Imports* imports) {
|
Imports* imports) {
|
||||||
imports->Import("grpc");
|
imports->Import("grpc");
|
||||||
@@ -293,6 +282,18 @@ class ServiceGenerator : public BaseGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool SaveService(const std::string& filename, const Imports& imports,
|
||||||
|
const std::string& content) {
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "# Generated by the gRPC FlatBuffers compiler. DO NOT EDIT!\n"
|
||||||
|
<< '\n';
|
||||||
|
FormatImports(ss, imports);
|
||||||
|
ss << content << '\n';
|
||||||
|
|
||||||
|
EnsureDirExists(StripFileName(filename));
|
||||||
|
return parser_.opts.file_saver->SaveFile(filename.c_str(), ss.str(), false);
|
||||||
|
}
|
||||||
|
|
||||||
void GenerateStub(std::stringstream& ss, const ServiceDef* service,
|
void GenerateStub(std::stringstream& ss, const ServiceDef* service,
|
||||||
Imports* imports) {
|
Imports* imports) {
|
||||||
ss << "class " << service->name << "Stub";
|
ss << "class " << service->name << "Stub";
|
||||||
|
|||||||
@@ -91,6 +91,14 @@ class Namer {
|
|||||||
std::string keyword_prefix;
|
std::string keyword_prefix;
|
||||||
// Suffix used to escape keywords. It is usually "_".
|
// Suffix used to escape keywords. It is usually "_".
|
||||||
std::string keyword_suffix;
|
std::string keyword_suffix;
|
||||||
|
// The casing used for keywords when escaping. For most languages, keywords
|
||||||
|
// are case sensitive. PHP is an instance where some keywords are case
|
||||||
|
// insensitive.
|
||||||
|
enum class KeywordsCasing {
|
||||||
|
CaseSensitive,
|
||||||
|
CaseInsensitive,
|
||||||
|
};
|
||||||
|
KeywordsCasing keywords_casing;
|
||||||
|
|
||||||
// Files.
|
// Files.
|
||||||
|
|
||||||
@@ -204,8 +212,16 @@ class Namer {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual std::string NormalizeKeywordCase(const std::string& name) const {
|
||||||
|
if (config_.keywords_casing == Config::KeywordsCasing::CaseInsensitive) {
|
||||||
|
return ConvertCase(name, Case::kAllLower);
|
||||||
|
} else {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
virtual std::string EscapeKeyword(const std::string& name) const {
|
virtual std::string EscapeKeyword(const std::string& name) const {
|
||||||
if (keywords_.find(name) == keywords_.end()) {
|
if (keywords_.find(NormalizeKeywordCase(name)) == keywords_.end()) {
|
||||||
return name;
|
return name;
|
||||||
} else {
|
} else {
|
||||||
return config_.keyword_prefix + name + config_.keyword_suffix;
|
return config_.keyword_prefix + name + config_.keyword_suffix;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ static const Namer::Config kConfig = {
|
|||||||
/*object_suffix=*/"T",
|
/*object_suffix=*/"T",
|
||||||
/*keyword_prefix=*/"",
|
/*keyword_prefix=*/"",
|
||||||
/*keyword_suffix=*/"_",
|
/*keyword_suffix=*/"_",
|
||||||
|
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||||
/*filenames=*/Case::kKeep,
|
/*filenames=*/Case::kKeep,
|
||||||
/*directories=*/Case::kKeep,
|
/*directories=*/Case::kKeep,
|
||||||
/*output_path=*/"",
|
/*output_path=*/"",
|
||||||
@@ -49,6 +50,7 @@ static const Namer::Config kStubConfig = {
|
|||||||
/*object_suffix=*/"T",
|
/*object_suffix=*/"T",
|
||||||
/*keyword_prefix=*/"",
|
/*keyword_prefix=*/"",
|
||||||
/*keyword_suffix=*/"_",
|
/*keyword_suffix=*/"_",
|
||||||
|
/*keywords_casing=*/Namer::Config::KeywordsCasing::CaseSensitive,
|
||||||
/*filenames=*/Case::kKeep,
|
/*filenames=*/Case::kKeep,
|
||||||
/*directories=*/Case::kKeep,
|
/*directories=*/Case::kKeep,
|
||||||
/*output_path=*/"",
|
/*output_path=*/"",
|
||||||
|
|||||||
@@ -39,10 +39,11 @@ class Array {
|
|||||||
typedef VectorConstIterator<T, return_type, uoffset_t> const_iterator;
|
typedef VectorConstIterator<T, return_type, uoffset_t> const_iterator;
|
||||||
typedef VectorReverseIterator<const_iterator> const_reverse_iterator;
|
typedef VectorReverseIterator<const_iterator> const_reverse_iterator;
|
||||||
|
|
||||||
// If T is a LE-scalar or a struct (!scalar_tag::value).
|
// If T is a non-pointer and a LE-scalar or a struct (!scalar_tag::value).
|
||||||
static FLATBUFFERS_CONSTEXPR bool is_span_observable =
|
static FLATBUFFERS_CONSTEXPR bool is_span_observable =
|
||||||
(scalar_tag::value && (FLATBUFFERS_LITTLEENDIAN || sizeof(T) == 1)) ||
|
!std::is_pointer<T>::value &&
|
||||||
!scalar_tag::value;
|
((scalar_tag::value && (FLATBUFFERS_LITTLEENDIAN || sizeof(T) == 1)) ||
|
||||||
|
!scalar_tag::value);
|
||||||
|
|
||||||
FLATBUFFERS_CONSTEXPR uint16_t size() const { return length; }
|
FLATBUFFERS_CONSTEXPR uint16_t size() const { return length; }
|
||||||
|
|
||||||
|
|||||||
@@ -140,8 +140,8 @@
|
|||||||
#endif // !defined(FLATBUFFERS_LITTLEENDIAN)
|
#endif // !defined(FLATBUFFERS_LITTLEENDIAN)
|
||||||
|
|
||||||
#define FLATBUFFERS_VERSION_MAJOR 25
|
#define FLATBUFFERS_VERSION_MAJOR 25
|
||||||
#define FLATBUFFERS_VERSION_MINOR 9
|
#define FLATBUFFERS_VERSION_MINOR 12
|
||||||
#define FLATBUFFERS_VERSION_REVISION 23
|
#define FLATBUFFERS_VERSION_REVISION 19
|
||||||
#define FLATBUFFERS_STRING_EXPAND(X) #X
|
#define FLATBUFFERS_STRING_EXPAND(X) #X
|
||||||
#define FLATBUFFERS_STRING(X) FLATBUFFERS_STRING_EXPAND(X)
|
#define FLATBUFFERS_STRING(X) FLATBUFFERS_STRING_EXPAND(X)
|
||||||
namespace flatbuffers {
|
namespace flatbuffers {
|
||||||
@@ -267,11 +267,11 @@ namespace flatbuffers {
|
|||||||
|
|
||||||
#ifndef FLATBUFFERS_LOCALE_INDEPENDENT
|
#ifndef FLATBUFFERS_LOCALE_INDEPENDENT
|
||||||
// Enable locale independent functions {strtof_l, strtod_l,strtoll_l,
|
// Enable locale independent functions {strtof_l, strtod_l,strtoll_l,
|
||||||
// strtoull_l}.
|
// strtoull_l} on platforms that support them.
|
||||||
#if (defined(_MSC_VER) && _MSC_VER >= 1800) || \
|
#if (defined(_MSC_VER) && _MSC_VER >= 1800) || \
|
||||||
(defined(__ANDROID_API__) && __ANDROID_API__>= 21) || \
|
(defined(__ANDROID__) && defined(__ANDROID_API__) && __ANDROID_API__>= 26) || \
|
||||||
(defined(_XOPEN_VERSION) && (_XOPEN_VERSION >= 700)) && \
|
(defined(_XOPEN_VERSION) && (_XOPEN_VERSION >= 700)) && \
|
||||||
(!defined(__Fuchsia__) && !defined(__ANDROID_API__))
|
!defined(__Fuchsia__)
|
||||||
#define FLATBUFFERS_LOCALE_INDEPENDENT 1
|
#define FLATBUFFERS_LOCALE_INDEPENDENT 1
|
||||||
#else
|
#else
|
||||||
#define FLATBUFFERS_LOCALE_INDEPENDENT 0
|
#define FLATBUFFERS_LOCALE_INDEPENDENT 0
|
||||||
|
|||||||
@@ -19,12 +19,14 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "flatbuffers/file_manager.h"
|
||||||
#include "flatbuffers/idl.h"
|
#include "flatbuffers/idl.h"
|
||||||
|
|
||||||
namespace flatbuffers {
|
namespace flatbuffers {
|
||||||
|
|
||||||
struct CodeGenOptions {
|
struct CodeGenOptions {
|
||||||
std::string output_path;
|
std::string output_path;
|
||||||
|
FileSaver* file_saver{nullptr};
|
||||||
};
|
};
|
||||||
|
|
||||||
// A code generator interface for producing converting flatbuffer schema into
|
// A code generator interface for producing converting flatbuffer schema into
|
||||||
|
|||||||
@@ -17,30 +17,52 @@
|
|||||||
#ifndef FLATBUFFERS_FILE_MANAGER_H_
|
#ifndef FLATBUFFERS_FILE_MANAGER_H_
|
||||||
#define FLATBUFFERS_FILE_MANAGER_H_
|
#define FLATBUFFERS_FILE_MANAGER_H_
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "flatbuffers/util.h"
|
|
||||||
|
|
||||||
namespace flatbuffers {
|
namespace flatbuffers {
|
||||||
|
|
||||||
// A File interface to write data to file by default or
|
// A File interface to write data to file by default or
|
||||||
// save only file names
|
// save only file names
|
||||||
class FileManager {
|
class FileSaver {
|
||||||
public:
|
public:
|
||||||
FileManager() = default;
|
FileSaver() = default;
|
||||||
virtual ~FileManager() = default;
|
virtual ~FileSaver() = default;
|
||||||
|
|
||||||
virtual bool SaveFile(const std::string& absolute_file_name,
|
virtual bool SaveFile(const char* name, const char* buf, size_t len,
|
||||||
const std::string& content) = 0;
|
bool binary) = 0;
|
||||||
|
|
||||||
virtual bool LoadFile(const std::string& absolute_file_name,
|
bool SaveFile(const char* name, const std::string& buf, bool binary) {
|
||||||
std::string* buf) = 0;
|
return SaveFile(name, buf.c_str(), buf.size(), binary);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void Finish() {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Copying is not supported.
|
// Copying is not supported.
|
||||||
FileManager(const FileManager&) = delete;
|
FileSaver(const FileSaver&) = delete;
|
||||||
FileManager& operator=(const FileManager&) = delete;
|
FileSaver& operator=(const FileSaver&) = delete;
|
||||||
|
// Rule of 5
|
||||||
|
FileSaver(FileSaver&&) = default;
|
||||||
|
FileSaver& operator=(FileSaver&&) = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
class RealFileSaver final : public FileSaver {
|
||||||
|
public:
|
||||||
|
bool SaveFile(const char* name, const char* buf, size_t len,
|
||||||
|
bool binary) final;
|
||||||
|
};
|
||||||
|
|
||||||
|
class FileNameSaver final : public FileSaver {
|
||||||
|
public:
|
||||||
|
bool SaveFile(const char* name, const char* buf, size_t len,
|
||||||
|
bool binary) final;
|
||||||
|
|
||||||
|
void Finish() final;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::set<std::string> file_names_{};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace flatbuffers
|
} // namespace flatbuffers
|
||||||
|
|||||||
@@ -470,7 +470,8 @@ class FlatBufferBuilderImpl {
|
|||||||
for (auto it = buf_.scratch_data(); it < buf_.scratch_end();
|
for (auto it = buf_.scratch_data(); it < buf_.scratch_end();
|
||||||
it += sizeof(uoffset_t)) {
|
it += sizeof(uoffset_t)) {
|
||||||
auto vt_offset_ptr = reinterpret_cast<uoffset_t*>(it);
|
auto vt_offset_ptr = reinterpret_cast<uoffset_t*>(it);
|
||||||
auto vt2 = reinterpret_cast<voffset_t*>(buf_.data_at(*vt_offset_ptr));
|
auto vt2 = reinterpret_cast<voffset_t*>(
|
||||||
|
buf_.data_at(*vt_offset_ptr + length_of_64_bit_region_));
|
||||||
auto vt2_size = ReadScalar<voffset_t>(vt2);
|
auto vt2_size = ReadScalar<voffset_t>(vt2);
|
||||||
if (vt1_size != vt2_size || 0 != memcmp(vt2, vt1, vt1_size)) continue;
|
if (vt1_size != vt2_size || 0 != memcmp(vt2, vt1, vt1_size)) continue;
|
||||||
vt_use = *vt_offset_ptr;
|
vt_use = *vt_offset_ptr;
|
||||||
@@ -834,6 +835,16 @@ class FlatBufferBuilderImpl {
|
|||||||
return Offset<Vector<uint8_t>>(EndVector(v.size()));
|
return Offset<Vector<uint8_t>>(EndVector(v.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Offset64<Vector64<uint8_t>> CreateVector64(const std::vector<bool>& v) {
|
||||||
|
StartVector<uint8_t, Offset64, Vector64<uint8_t>::size_type>(v.size());
|
||||||
|
for (auto i = v.size(); i > 0;) {
|
||||||
|
PushElement(static_cast<uint8_t>(v[--i]));
|
||||||
|
}
|
||||||
|
return Offset64<Vector64<uint8_t>>(
|
||||||
|
EndVector<Vector64<uint8_t>::size_type,
|
||||||
|
Offset64<Vector64<uint8_t>>::offset_type>(v.size()));
|
||||||
|
}
|
||||||
|
|
||||||
/// @brief Serialize values returned by a function into a FlatBuffer `vector`.
|
/// @brief Serialize values returned by a function into a FlatBuffer `vector`.
|
||||||
/// This is a convenience function that takes care of iteration for you.
|
/// This is a convenience function that takes care of iteration for you.
|
||||||
/// @tparam T The data type of the `std::vector` elements.
|
/// @tparam T The data type of the `std::vector` elements.
|
||||||
|
|||||||
@@ -260,15 +260,15 @@ inline const char* flatbuffers_version_string() {
|
|||||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator ~ (E lhs){\
|
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator ~ (E lhs){\
|
||||||
return E(~T(lhs));\
|
return E(~T(lhs));\
|
||||||
}\
|
}\
|
||||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator |= (E &lhs, E rhs){\
|
inline FLATBUFFERS_CONSTEXPR_CPP14 E operator |= (E &lhs, E rhs){\
|
||||||
lhs = lhs | rhs;\
|
lhs = lhs | rhs;\
|
||||||
return lhs;\
|
return lhs;\
|
||||||
}\
|
}\
|
||||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator &= (E &lhs, E rhs){\
|
inline FLATBUFFERS_CONSTEXPR_CPP14 E operator &= (E &lhs, E rhs){\
|
||||||
lhs = lhs & rhs;\
|
lhs = lhs & rhs;\
|
||||||
return lhs;\
|
return lhs;\
|
||||||
}\
|
}\
|
||||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator ^= (E &lhs, E rhs){\
|
inline FLATBUFFERS_CONSTEXPR_CPP14 E operator ^= (E &lhs, E rhs){\
|
||||||
lhs = lhs ^ rhs;\
|
lhs = lhs ^ rhs;\
|
||||||
return lhs;\
|
return lhs;\
|
||||||
}\
|
}\
|
||||||
|
|||||||
@@ -23,9 +23,10 @@
|
|||||||
namespace flexbuffers {
|
namespace flexbuffers {
|
||||||
|
|
||||||
// Verifies the `nested` flexbuffer within a flatbuffer vector is valid.
|
// Verifies the `nested` flexbuffer within a flatbuffer vector is valid.
|
||||||
|
template <bool B>
|
||||||
inline bool VerifyNestedFlexBuffer(
|
inline bool VerifyNestedFlexBuffer(
|
||||||
const flatbuffers::Vector<uint8_t>* const nested,
|
const flatbuffers::Vector<uint8_t>* const nested,
|
||||||
flatbuffers::Verifier& verifier) {
|
flatbuffers::VerifierTemplate<B>& verifier) {
|
||||||
if (!nested) return true;
|
if (!nested) return true;
|
||||||
return verifier.Check(flexbuffers::VerifyBuffer(
|
return verifier.Check(flexbuffers::VerifyBuffer(
|
||||||
nested->data(), nested->size(), verifier.GetFlexReuseTracker()));
|
nested->data(), nested->size(), verifier.GetFlexReuseTracker()));
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "flatbuffers/base.h"
|
#include "flatbuffers/base.h"
|
||||||
|
#include "flatbuffers/file_manager.h"
|
||||||
#include "flatbuffers/flatbuffers.h"
|
#include "flatbuffers/flatbuffers.h"
|
||||||
#include "flatbuffers/flexbuffers.h"
|
#include "flatbuffers/flexbuffers.h"
|
||||||
#include "flatbuffers/hash.h"
|
#include "flatbuffers/hash.h"
|
||||||
@@ -222,7 +223,7 @@ struct Type {
|
|||||||
uint16_t fixed_length; // only set if t == BASE_TYPE_ARRAY
|
uint16_t fixed_length; // only set if t == BASE_TYPE_ARRAY
|
||||||
};
|
};
|
||||||
|
|
||||||
// Represents a parsed scalar value, it's type, and field offset.
|
// Represents a parsed scalar value, its type, and field offset.
|
||||||
struct Value {
|
struct Value {
|
||||||
Value()
|
Value()
|
||||||
: constant("0"),
|
: constant("0"),
|
||||||
@@ -394,13 +395,20 @@ struct FieldDef : public Definition {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct StructDef : public Definition {
|
struct StructDef : public Definition {
|
||||||
|
enum class CycleStatus {
|
||||||
|
NotChecked,
|
||||||
|
InProgress,
|
||||||
|
Checked,
|
||||||
|
};
|
||||||
|
|
||||||
StructDef()
|
StructDef()
|
||||||
: fixed(false),
|
: fixed(false),
|
||||||
predecl(true),
|
predecl(true),
|
||||||
sortbysize(true),
|
sortbysize(true),
|
||||||
has_key(false),
|
has_key(false),
|
||||||
minalign(1),
|
minalign(1),
|
||||||
bytesize(0) {}
|
bytesize(0),
|
||||||
|
cycle_status{CycleStatus::NotChecked} {}
|
||||||
|
|
||||||
void PadLastField(size_t min_align) {
|
void PadLastField(size_t min_align) {
|
||||||
auto padding = PaddingBytes(bytesize, min_align);
|
auto padding = PaddingBytes(bytesize, min_align);
|
||||||
@@ -422,6 +430,8 @@ struct StructDef : public Definition {
|
|||||||
size_t minalign; // What the whole object needs to be aligned to.
|
size_t minalign; // What the whole object needs to be aligned to.
|
||||||
size_t bytesize; // Size if fixed.
|
size_t bytesize; // Size if fixed.
|
||||||
|
|
||||||
|
CycleStatus cycle_status; // used for determining if we have circular references
|
||||||
|
|
||||||
flatbuffers::unique_ptr<std::string> original_location;
|
flatbuffers::unique_ptr<std::string> original_location;
|
||||||
std::vector<voffset_t> reserved_ids;
|
std::vector<voffset_t> reserved_ids;
|
||||||
};
|
};
|
||||||
@@ -634,6 +644,10 @@ inline bool operator<(const IncludedFile& a, const IncludedFile& b) {
|
|||||||
|
|
||||||
// Container of options that may apply to any of the source/text generators.
|
// Container of options that may apply to any of the source/text generators.
|
||||||
struct IDLOptions {
|
struct IDLOptions {
|
||||||
|
// file saver
|
||||||
|
// shared pointer since this object gets copied and modified.
|
||||||
|
FileSaver* file_saver = nullptr;
|
||||||
|
|
||||||
// field case style options for C++
|
// field case style options for C++
|
||||||
enum CaseStyle { CaseStyle_Unchanged = 0, CaseStyle_Upper, CaseStyle_Lower };
|
enum CaseStyle { CaseStyle_Unchanged = 0, CaseStyle_Upper, CaseStyle_Lower };
|
||||||
enum class ProtoIdGapAction { NO_OP, WARNING, ERROR };
|
enum class ProtoIdGapAction { NO_OP, WARNING, ERROR };
|
||||||
@@ -659,6 +673,7 @@ struct IDLOptions {
|
|||||||
bool generate_name_strings;
|
bool generate_name_strings;
|
||||||
bool generate_object_based_api;
|
bool generate_object_based_api;
|
||||||
bool gen_compare;
|
bool gen_compare;
|
||||||
|
bool gen_absl_hash;
|
||||||
std::string cpp_object_api_pointer_type;
|
std::string cpp_object_api_pointer_type;
|
||||||
std::string cpp_object_api_string_type;
|
std::string cpp_object_api_string_type;
|
||||||
bool cpp_object_api_string_flexible_constructor;
|
bool cpp_object_api_string_flexible_constructor;
|
||||||
@@ -702,8 +717,6 @@ struct IDLOptions {
|
|||||||
bool json_nested_flatbuffers;
|
bool json_nested_flatbuffers;
|
||||||
bool json_nested_flexbuffers;
|
bool json_nested_flexbuffers;
|
||||||
bool json_nested_legacy_flatbuffers;
|
bool json_nested_legacy_flatbuffers;
|
||||||
bool ts_flat_files;
|
|
||||||
bool ts_entry_points;
|
|
||||||
bool ts_no_import_ext;
|
bool ts_no_import_ext;
|
||||||
bool no_leak_private_annotations;
|
bool no_leak_private_annotations;
|
||||||
bool require_json_eof;
|
bool require_json_eof;
|
||||||
@@ -730,6 +743,7 @@ struct IDLOptions {
|
|||||||
bool python_gen_numpy;
|
bool python_gen_numpy;
|
||||||
|
|
||||||
bool ts_omit_entrypoint;
|
bool ts_omit_entrypoint;
|
||||||
|
bool ts_undefined_for_optionals;
|
||||||
ProtoIdGapAction proto_id_gap_action;
|
ProtoIdGapAction proto_id_gap_action;
|
||||||
|
|
||||||
// Possible options for the more general generator below.
|
// Possible options for the more general generator below.
|
||||||
@@ -815,6 +829,7 @@ struct IDLOptions {
|
|||||||
generate_name_strings(false),
|
generate_name_strings(false),
|
||||||
generate_object_based_api(false),
|
generate_object_based_api(false),
|
||||||
gen_compare(false),
|
gen_compare(false),
|
||||||
|
gen_absl_hash(false),
|
||||||
cpp_object_api_pointer_type("std::unique_ptr"),
|
cpp_object_api_pointer_type("std::unique_ptr"),
|
||||||
cpp_object_api_string_flexible_constructor(false),
|
cpp_object_api_string_flexible_constructor(false),
|
||||||
cpp_object_api_field_case_style(CaseStyle_Unchanged),
|
cpp_object_api_field_case_style(CaseStyle_Unchanged),
|
||||||
@@ -847,8 +862,6 @@ struct IDLOptions {
|
|||||||
json_nested_flatbuffers(true),
|
json_nested_flatbuffers(true),
|
||||||
json_nested_flexbuffers(true),
|
json_nested_flexbuffers(true),
|
||||||
json_nested_legacy_flatbuffers(false),
|
json_nested_legacy_flatbuffers(false),
|
||||||
ts_flat_files(false),
|
|
||||||
ts_entry_points(false),
|
|
||||||
ts_no_import_ext(false),
|
ts_no_import_ext(false),
|
||||||
no_leak_private_annotations(false),
|
no_leak_private_annotations(false),
|
||||||
require_json_eof(true),
|
require_json_eof(true),
|
||||||
@@ -857,6 +870,7 @@ struct IDLOptions {
|
|||||||
python_typing(false),
|
python_typing(false),
|
||||||
python_gen_numpy(true),
|
python_gen_numpy(true),
|
||||||
ts_omit_entrypoint(false),
|
ts_omit_entrypoint(false),
|
||||||
|
ts_undefined_for_optionals(false),
|
||||||
proto_id_gap_action(ProtoIdGapAction::WARNING),
|
proto_id_gap_action(ProtoIdGapAction::WARNING),
|
||||||
mini_reflect(IDLOptions::kNone),
|
mini_reflect(IDLOptions::kNone),
|
||||||
require_explicit_ids(false),
|
require_explicit_ids(false),
|
||||||
@@ -1096,6 +1110,8 @@ class Parser : public ParserState {
|
|||||||
// others includes.
|
// others includes.
|
||||||
std::vector<IncludedFile> GetIncludedFiles() const;
|
std::vector<IncludedFile> GetIncludedFiles() const;
|
||||||
|
|
||||||
|
bool HasCircularStructDependency();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class ParseDepthGuard;
|
class ParseDepthGuard;
|
||||||
|
|
||||||
|
|||||||
@@ -30,50 +30,52 @@ namespace flatbuffers {
|
|||||||
|
|
||||||
// ------------------------- GETTERS -------------------------
|
// ------------------------- GETTERS -------------------------
|
||||||
|
|
||||||
inline bool IsScalar(reflection::BaseType t) {
|
constexpr bool IsScalar(reflection::BaseType t) {
|
||||||
return t >= reflection::UType && t <= reflection::Double;
|
return t >= reflection::UType && t <= reflection::Double;
|
||||||
}
|
}
|
||||||
inline bool IsInteger(reflection::BaseType t) {
|
constexpr bool IsInteger(reflection::BaseType t) {
|
||||||
return t >= reflection::UType && t <= reflection::ULong;
|
return t >= reflection::UType && t <= reflection::ULong;
|
||||||
}
|
}
|
||||||
inline bool IsFloat(reflection::BaseType t) {
|
constexpr bool IsFloat(reflection::BaseType t) {
|
||||||
return t == reflection::Float || t == reflection::Double;
|
return t == reflection::Float || t == reflection::Double;
|
||||||
}
|
}
|
||||||
inline bool IsLong(reflection::BaseType t) {
|
constexpr bool IsLong(reflection::BaseType t) {
|
||||||
return t == reflection::Long || t == reflection::ULong;
|
return t == reflection::Long || t == reflection::ULong;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Size of a basic type, don't use with structs.
|
// This needs to correspond to the BaseType enum.
|
||||||
inline size_t GetTypeSize(reflection::BaseType base_type) {
|
constexpr size_t kBaseTypeSize[] = {
|
||||||
// This needs to correspond to the BaseType enum.
|
0, // None
|
||||||
static size_t sizes[] = {
|
1, // UType
|
||||||
0, // None
|
1, // Bool
|
||||||
1, // UType
|
1, // Byte
|
||||||
1, // Bool
|
1, // UByte
|
||||||
1, // Byte
|
2, // Short
|
||||||
1, // UByte
|
2, // UShort
|
||||||
2, // Short
|
4, // Int
|
||||||
2, // UShort
|
4, // UInt
|
||||||
4, // Int
|
8, // Long
|
||||||
4, // UInt
|
8, // ULong
|
||||||
8, // Long
|
4, // Float
|
||||||
8, // ULong
|
8, // Double
|
||||||
4, // Float
|
4, // String
|
||||||
8, // Double
|
4, // Vector
|
||||||
4, // String
|
4, // Obj
|
||||||
4, // Vector
|
4, // Union
|
||||||
4, // Obj
|
0, // Array. Only used in structs. 0 was chosen to prevent out-of-bounds
|
||||||
4, // Union
|
// errors.
|
||||||
0, // Array. Only used in structs. 0 was chosen to prevent out-of-bounds
|
8, // Vector64
|
||||||
// errors.
|
|
||||||
8, // Vector64
|
|
||||||
|
|
||||||
0 // MaxBaseType. This must be kept the last entry in this array.
|
0 // MaxBaseType. This must be kept the last entry in this array.
|
||||||
};
|
};
|
||||||
static_assert(sizeof(sizes) / sizeof(size_t) == reflection::MaxBaseType + 1,
|
static_assert(sizeof(kBaseTypeSize) / sizeof(size_t) ==
|
||||||
"Size of sizes[] array does not match the count of BaseType "
|
reflection::MaxBaseType + 1,
|
||||||
"enum values.");
|
"Size of sizes[] array does not match the count of BaseType "
|
||||||
return sizes[base_type];
|
"enum values.");
|
||||||
|
|
||||||
|
// Size of a basic type, don't use with structs.
|
||||||
|
constexpr size_t GetTypeSize(reflection::BaseType base_type) {
|
||||||
|
return kBaseTypeSize[base_type];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Same as above, but now correctly returns the size of a struct if
|
// Same as above, but now correctly returns the size of a struct if
|
||||||
@@ -420,7 +422,7 @@ pointer_inside_vector<T, U> piv(T* ptr, std::vector<U>& vec) {
|
|||||||
return pointer_inside_vector<T, U>(ptr, vec);
|
return pointer_inside_vector<T, U>(ptr, vec);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const char* UnionTypeFieldSuffix() { return "_type"; }
|
constexpr const char* UnionTypeFieldSuffix() { return "_type"; }
|
||||||
|
|
||||||
// Helper to figure out the actual table type a union refers to.
|
// Helper to figure out the actual table type a union refers to.
|
||||||
inline const reflection::Object& GetUnionType(
|
inline const reflection::Object& GetUnionType(
|
||||||
|
|||||||
@@ -9,8 +9,8 @@
|
|||||||
// Ensure the included flatbuffers.h is the same version as when this file was
|
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||||
// generated, otherwise it may not be compatible.
|
// generated, otherwise it may not be compatible.
|
||||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
||||||
FLATBUFFERS_VERSION_MINOR == 9 &&
|
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||||
FLATBUFFERS_VERSION_REVISION == 23,
|
FLATBUFFERS_VERSION_REVISION == 19,
|
||||||
"Non-compatible flatbuffers version included");
|
"Non-compatible flatbuffers version included");
|
||||||
|
|
||||||
namespace reflection {
|
namespace reflection {
|
||||||
@@ -196,7 +196,8 @@ struct Type FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
uint32_t element_size() const {
|
uint32_t element_size() const {
|
||||||
return GetField<uint32_t>(VT_ELEMENT_SIZE, 0);
|
return GetField<uint32_t>(VT_ELEMENT_SIZE, 0);
|
||||||
}
|
}
|
||||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
template <bool B = false>
|
||||||
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
return VerifyTableStart(verifier) &&
|
return VerifyTableStart(verifier) &&
|
||||||
VerifyField<int8_t>(verifier, VT_BASE_TYPE, 1) &&
|
VerifyField<int8_t>(verifier, VT_BASE_TYPE, 1) &&
|
||||||
VerifyField<int8_t>(verifier, VT_ELEMENT, 1) &&
|
VerifyField<int8_t>(verifier, VT_ELEMENT, 1) &&
|
||||||
@@ -283,7 +284,8 @@ struct KeyValue FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const ::flatbuffers::String *value() const {
|
const ::flatbuffers::String *value() const {
|
||||||
return GetPointer<const ::flatbuffers::String *>(VT_VALUE);
|
return GetPointer<const ::flatbuffers::String *>(VT_VALUE);
|
||||||
}
|
}
|
||||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
template <bool B = false>
|
||||||
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
return VerifyTableStart(verifier) &&
|
return VerifyTableStart(verifier) &&
|
||||||
VerifyOffsetRequired(verifier, VT_KEY) &&
|
VerifyOffsetRequired(verifier, VT_KEY) &&
|
||||||
verifier.VerifyString(key()) &&
|
verifier.VerifyString(key()) &&
|
||||||
@@ -367,7 +369,8 @@ struct EnumVal FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const ::flatbuffers::Vector<::flatbuffers::Offset<reflection::KeyValue>> *attributes() const {
|
const ::flatbuffers::Vector<::flatbuffers::Offset<reflection::KeyValue>> *attributes() const {
|
||||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<reflection::KeyValue>> *>(VT_ATTRIBUTES);
|
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<reflection::KeyValue>> *>(VT_ATTRIBUTES);
|
||||||
}
|
}
|
||||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
template <bool B = false>
|
||||||
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
return VerifyTableStart(verifier) &&
|
return VerifyTableStart(verifier) &&
|
||||||
VerifyOffsetRequired(verifier, VT_NAME) &&
|
VerifyOffsetRequired(verifier, VT_NAME) &&
|
||||||
verifier.VerifyString(name()) &&
|
verifier.VerifyString(name()) &&
|
||||||
@@ -495,7 +498,8 @@ struct Enum FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const ::flatbuffers::String *declaration_file() const {
|
const ::flatbuffers::String *declaration_file() const {
|
||||||
return GetPointer<const ::flatbuffers::String *>(VT_DECLARATION_FILE);
|
return GetPointer<const ::flatbuffers::String *>(VT_DECLARATION_FILE);
|
||||||
}
|
}
|
||||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
template <bool B = false>
|
||||||
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
return VerifyTableStart(verifier) &&
|
return VerifyTableStart(verifier) &&
|
||||||
VerifyOffsetRequired(verifier, VT_NAME) &&
|
VerifyOffsetRequired(verifier, VT_NAME) &&
|
||||||
verifier.VerifyString(name()) &&
|
verifier.VerifyString(name()) &&
|
||||||
@@ -675,7 +679,8 @@ struct Field FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
bool offset64() const {
|
bool offset64() const {
|
||||||
return GetField<uint8_t>(VT_OFFSET64, 0) != 0;
|
return GetField<uint8_t>(VT_OFFSET64, 0) != 0;
|
||||||
}
|
}
|
||||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
template <bool B = false>
|
||||||
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
return VerifyTableStart(verifier) &&
|
return VerifyTableStart(verifier) &&
|
||||||
VerifyOffsetRequired(verifier, VT_NAME) &&
|
VerifyOffsetRequired(verifier, VT_NAME) &&
|
||||||
verifier.VerifyString(name()) &&
|
verifier.VerifyString(name()) &&
|
||||||
@@ -880,7 +885,8 @@ struct Object FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const ::flatbuffers::String *declaration_file() const {
|
const ::flatbuffers::String *declaration_file() const {
|
||||||
return GetPointer<const ::flatbuffers::String *>(VT_DECLARATION_FILE);
|
return GetPointer<const ::flatbuffers::String *>(VT_DECLARATION_FILE);
|
||||||
}
|
}
|
||||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
template <bool B = false>
|
||||||
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
return VerifyTableStart(verifier) &&
|
return VerifyTableStart(verifier) &&
|
||||||
VerifyOffsetRequired(verifier, VT_NAME) &&
|
VerifyOffsetRequired(verifier, VT_NAME) &&
|
||||||
verifier.VerifyString(name()) &&
|
verifier.VerifyString(name()) &&
|
||||||
@@ -1028,7 +1034,8 @@ struct RPCCall FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const ::flatbuffers::Vector<::flatbuffers::Offset<::flatbuffers::String>> *documentation() const {
|
const ::flatbuffers::Vector<::flatbuffers::Offset<::flatbuffers::String>> *documentation() const {
|
||||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<::flatbuffers::String>> *>(VT_DOCUMENTATION);
|
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<::flatbuffers::String>> *>(VT_DOCUMENTATION);
|
||||||
}
|
}
|
||||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
template <bool B = false>
|
||||||
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
return VerifyTableStart(verifier) &&
|
return VerifyTableStart(verifier) &&
|
||||||
VerifyOffsetRequired(verifier, VT_NAME) &&
|
VerifyOffsetRequired(verifier, VT_NAME) &&
|
||||||
verifier.VerifyString(name()) &&
|
verifier.VerifyString(name()) &&
|
||||||
@@ -1151,7 +1158,8 @@ struct Service FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const ::flatbuffers::String *declaration_file() const {
|
const ::flatbuffers::String *declaration_file() const {
|
||||||
return GetPointer<const ::flatbuffers::String *>(VT_DECLARATION_FILE);
|
return GetPointer<const ::flatbuffers::String *>(VT_DECLARATION_FILE);
|
||||||
}
|
}
|
||||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
template <bool B = false>
|
||||||
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
return VerifyTableStart(verifier) &&
|
return VerifyTableStart(verifier) &&
|
||||||
VerifyOffsetRequired(verifier, VT_NAME) &&
|
VerifyOffsetRequired(verifier, VT_NAME) &&
|
||||||
verifier.VerifyString(name()) &&
|
verifier.VerifyString(name()) &&
|
||||||
@@ -1267,7 +1275,8 @@ struct SchemaFile FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const ::flatbuffers::Vector<::flatbuffers::Offset<::flatbuffers::String>> *included_filenames() const {
|
const ::flatbuffers::Vector<::flatbuffers::Offset<::flatbuffers::String>> *included_filenames() const {
|
||||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<::flatbuffers::String>> *>(VT_INCLUDED_FILENAMES);
|
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<::flatbuffers::String>> *>(VT_INCLUDED_FILENAMES);
|
||||||
}
|
}
|
||||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
template <bool B = false>
|
||||||
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
return VerifyTableStart(verifier) &&
|
return VerifyTableStart(verifier) &&
|
||||||
VerifyOffsetRequired(verifier, VT_FILENAME) &&
|
VerifyOffsetRequired(verifier, VT_FILENAME) &&
|
||||||
verifier.VerifyString(filename()) &&
|
verifier.VerifyString(filename()) &&
|
||||||
@@ -1360,7 +1369,8 @@ struct Schema FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const ::flatbuffers::Vector<::flatbuffers::Offset<reflection::SchemaFile>> *fbs_files() const {
|
const ::flatbuffers::Vector<::flatbuffers::Offset<reflection::SchemaFile>> *fbs_files() const {
|
||||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<reflection::SchemaFile>> *>(VT_FBS_FILES);
|
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<reflection::SchemaFile>> *>(VT_FBS_FILES);
|
||||||
}
|
}
|
||||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
template <bool B = false>
|
||||||
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
return VerifyTableStart(verifier) &&
|
return VerifyTableStart(verifier) &&
|
||||||
VerifyOffsetRequired(verifier, VT_OBJECTS) &&
|
VerifyOffsetRequired(verifier, VT_OBJECTS) &&
|
||||||
verifier.VerifyVector(objects()) &&
|
verifier.VerifyVector(objects()) &&
|
||||||
@@ -1498,14 +1508,16 @@ inline bool SizePrefixedSchemaBufferHasIdentifier(const void *buf) {
|
|||||||
buf, SchemaIdentifier(), true);
|
buf, SchemaIdentifier(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <bool B = false>
|
||||||
inline bool VerifySchemaBuffer(
|
inline bool VerifySchemaBuffer(
|
||||||
::flatbuffers::Verifier &verifier) {
|
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||||
return verifier.VerifyBuffer<reflection::Schema>(SchemaIdentifier());
|
return verifier.template VerifyBuffer<reflection::Schema>(SchemaIdentifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <bool B = false>
|
||||||
inline bool VerifySizePrefixedSchemaBuffer(
|
inline bool VerifySizePrefixedSchemaBuffer(
|
||||||
::flatbuffers::Verifier &verifier) {
|
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||||
return verifier.VerifySizePrefixedBuffer<reflection::Schema>(SchemaIdentifier());
|
return verifier.template VerifySizePrefixedBuffer<reflection::Schema>(SchemaIdentifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const char *SchemaExtension() {
|
inline const char *SchemaExtension() {
|
||||||
|
|||||||
@@ -47,7 +47,9 @@
|
|||||||
// See: https://en.cppreference.com/w/cpp/utility/feature_test
|
// 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)
|
|| (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
|
||||||
#define FLATBUFFERS_USE_STD_SPAN 1
|
#if __has_include(<span>)
|
||||||
|
#define FLATBUFFERS_USE_STD_SPAN 1
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif // FLATBUFFERS_USE_STD_SPAN
|
#endif // FLATBUFFERS_USE_STD_SPAN
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#define FLATBUFFERS_TABLE_H_
|
#define FLATBUFFERS_TABLE_H_
|
||||||
|
|
||||||
#include "flatbuffers/base.h"
|
#include "flatbuffers/base.h"
|
||||||
|
#include "flatbuffers/vector.h"
|
||||||
#include "flatbuffers/verifier.h"
|
#include "flatbuffers/verifier.h"
|
||||||
|
|
||||||
namespace flatbuffers {
|
namespace flatbuffers {
|
||||||
@@ -70,6 +71,32 @@ class Table {
|
|||||||
return GetPointer<P, uoffset64_t>(field);
|
return GetPointer<P, uoffset64_t>(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename P, typename SizeT = uoffset_t,
|
||||||
|
typename OffsetSize = uoffset_t>
|
||||||
|
const Vector<P, SizeT>* GetVectorPointerOrEmpty(voffset_t field) const {
|
||||||
|
auto* ptr = GetPointer<const Vector<P, SizeT>*, OffsetSize>(field);
|
||||||
|
return ptr ? ptr : EmptyVector<P, SizeT>();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename P, typename SizeT = uoffset_t>
|
||||||
|
const Vector<P, SizeT>* GetVectorPointer64OrEmpty(voffset_t field) const {
|
||||||
|
return GetVectorPointerOrEmpty<P, SizeT, uoffset64_t>(field);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename P, typename SizeT = uoffset_t,
|
||||||
|
typename OffsetSize = uoffset_t>
|
||||||
|
Vector<P, SizeT>* GetMutableVectorPointerOrEmpty(voffset_t field) {
|
||||||
|
auto* ptr = GetPointer<Vector<P, SizeT>*, OffsetSize>(field);
|
||||||
|
// This is a const_cast, but safe, since all mutable operations on an
|
||||||
|
// empty vector are NOPs.
|
||||||
|
return ptr ? ptr : const_cast<Vector<P, SizeT>*>(EmptyVector<P, SizeT>());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename P, typename SizeT = uoffset_t>
|
||||||
|
Vector<P, SizeT>* GetMutableVectorPointer64OrEmpty(voffset_t field) {
|
||||||
|
return GetMutableVectorPointerOrEmpty<P, SizeT, uoffset64_t>(field);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename P>
|
template <typename P>
|
||||||
P GetStruct(voffset_t field) const {
|
P GetStruct(voffset_t field) const {
|
||||||
auto field_offset = GetOptionalFieldOffset(field);
|
auto field_offset = GetOptionalFieldOffset(field);
|
||||||
@@ -122,52 +149,94 @@ class Table {
|
|||||||
|
|
||||||
// Verify the vtable of this table.
|
// Verify the vtable of this table.
|
||||||
// Call this once per table, followed by VerifyField once per field.
|
// Call this once per table, followed by VerifyField once per field.
|
||||||
bool VerifyTableStart(Verifier& verifier) const {
|
template <bool B>
|
||||||
|
bool VerifyTableStart(VerifierTemplate<B>& verifier) const {
|
||||||
return verifier.VerifyTableStart(data_);
|
return verifier.VerifyTableStart(data_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify a particular field.
|
// Verify a particular field.
|
||||||
template <typename T>
|
template <typename T, bool B>
|
||||||
bool VerifyField(const Verifier& verifier, voffset_t field,
|
bool VerifyField(const VerifierTemplate<B>& verifier, voffset_t field,
|
||||||
size_t align) const {
|
size_t align) const {
|
||||||
// Calling GetOptionalFieldOffset should be safe now thanks to
|
// Calling GetOptionalFieldOffset should be safe now thanks to
|
||||||
// VerifyTable().
|
// VerifyTable().
|
||||||
auto field_offset = GetOptionalFieldOffset(field);
|
auto field_offset = GetOptionalFieldOffset(field);
|
||||||
// Check the actual field.
|
// Check the actual field.
|
||||||
return !field_offset || verifier.VerifyField<T>(data_, field_offset, align);
|
return !field_offset ||
|
||||||
|
verifier.template VerifyField<T>(data_, field_offset, align);
|
||||||
}
|
}
|
||||||
|
|
||||||
// VerifyField for required fields.
|
// VerifyField for required fields.
|
||||||
template <typename T>
|
template <typename T, bool B>
|
||||||
bool VerifyFieldRequired(const Verifier& verifier, voffset_t field,
|
bool VerifyFieldRequired(const VerifierTemplate<B>& verifier, voffset_t field,
|
||||||
size_t align) const {
|
size_t align) const {
|
||||||
auto field_offset = GetOptionalFieldOffset(field);
|
auto field_offset = GetOptionalFieldOffset(field);
|
||||||
return verifier.Check(field_offset != 0) &&
|
return verifier.Check(field_offset != 0) &&
|
||||||
verifier.VerifyField<T>(data_, field_offset, align);
|
verifier.template VerifyField<T>(data_, field_offset, align);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Versions for offsets.
|
// Versions for offsets.
|
||||||
template <typename OffsetT = uoffset_t>
|
template <typename OffsetT = uoffset_t, bool B = false>
|
||||||
bool VerifyOffset(const Verifier& verifier, voffset_t field) const {
|
bool VerifyOffset(const VerifierTemplate<B>& verifier,
|
||||||
|
voffset_t field) const {
|
||||||
auto field_offset = GetOptionalFieldOffset(field);
|
auto field_offset = GetOptionalFieldOffset(field);
|
||||||
return !field_offset || verifier.VerifyOffset<OffsetT>(data_, field_offset);
|
return !field_offset ||
|
||||||
|
verifier.template VerifyOffset<OffsetT>(data_, field_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename OffsetT = uoffset_t>
|
template <typename OffsetT = uoffset_t, bool B = false>
|
||||||
bool VerifyOffsetRequired(const Verifier& verifier, voffset_t field) const {
|
bool VerifyOffsetRequired(const VerifierTemplate<B>& verifier,
|
||||||
|
voffset_t field) const {
|
||||||
auto field_offset = GetOptionalFieldOffset(field);
|
auto field_offset = GetOptionalFieldOffset(field);
|
||||||
return verifier.Check(field_offset != 0) &&
|
return verifier.Check(field_offset != 0) &&
|
||||||
verifier.VerifyOffset<OffsetT>(data_, field_offset);
|
verifier.template VerifyOffset<OffsetT>(data_, field_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VerifyOffset64(const Verifier& verifier, voffset_t field) const {
|
template <bool B>
|
||||||
|
bool VerifyOffset64(const VerifierTemplate<B>& verifier,
|
||||||
|
voffset_t field) const {
|
||||||
return VerifyOffset<uoffset64_t>(verifier, field);
|
return VerifyOffset<uoffset64_t>(verifier, field);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VerifyOffset64Required(const Verifier& verifier, voffset_t field) const {
|
template <bool B>
|
||||||
|
bool VerifyOffset64Required(const VerifierTemplate<B>& verifier,
|
||||||
|
voffset_t field) const {
|
||||||
return VerifyOffsetRequired<uoffset64_t>(verifier, field);
|
return VerifyOffsetRequired<uoffset64_t>(verifier, field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Verify a string that may have a default value.
|
||||||
|
template <typename OffsetT = uoffset_t>
|
||||||
|
bool VerifyStringWithDefault(const Verifier& verifier,
|
||||||
|
voffset_t field) const {
|
||||||
|
auto field_offset = GetOptionalFieldOffset(field);
|
||||||
|
return field_offset == 0 ||
|
||||||
|
verifier.VerifyString(GetPointer<const String*, OffsetT>(field));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify a vector that has a default empty value.
|
||||||
|
template <typename P, typename SizeT = uoffset_t,
|
||||||
|
typename OffsetSize = uoffset_t>
|
||||||
|
bool VerifyVectorWithDefault(const Verifier& verifier,
|
||||||
|
voffset_t field) const {
|
||||||
|
auto field_offset = GetOptionalFieldOffset(field);
|
||||||
|
return field_offset == 0 ||
|
||||||
|
verifier.VerifyVector(
|
||||||
|
GetPointer<const Vector<P, SizeT>*, OffsetSize>(field));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename P, typename SizeT = uoffset_t>
|
||||||
|
bool VerifyVector64WithDefault(const Verifier& verifier,
|
||||||
|
voffset_t field) const {
|
||||||
|
return VerifyVectorWithDefault<P, SizeT, uoffset64_t>(verifier, field);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
template <typename T, typename SizeT = uoffset_t>
|
||||||
|
static const Vector<T, SizeT>* EmptyVector() {
|
||||||
|
static const SizeT empty_vector_length = 0;
|
||||||
|
return reinterpret_cast<const Vector<T, SizeT>*>(&empty_vector_length);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// private constructor & copy constructor: you obtain instances of this
|
// private constructor & copy constructor: you obtain instances of this
|
||||||
// class by pointing to existing data only
|
// class by pointing to existing data only
|
||||||
|
|||||||
@@ -448,12 +448,16 @@ bool LoadFile(const char* name, bool binary, std::string* buf);
|
|||||||
// If "binary" is false data is written using ifstream's
|
// If "binary" is false data is written using ifstream's
|
||||||
// text mode, otherwise data is written with no
|
// text mode, otherwise data is written with no
|
||||||
// transcoding.
|
// transcoding.
|
||||||
|
// NOTE: this function is deprecated in favor of FileSaver class,
|
||||||
|
// but left here for compatibility.
|
||||||
bool SaveFile(const char* name, const char* buf, size_t len, bool binary);
|
bool SaveFile(const char* name, const char* buf, size_t len, bool binary);
|
||||||
|
|
||||||
// Save data "buf" into file "name" returning true if
|
// Save data "buf" into file "name" returning true if
|
||||||
// successful, false otherwise. If "binary" is false
|
// successful, false otherwise. If "binary" is false
|
||||||
// data is written using ifstream's text mode, otherwise
|
// data is written using ifstream's text mode, otherwise
|
||||||
// data is written with no transcoding.
|
// data is written with no transcoding.
|
||||||
|
// NOTE: this function is deprecated in favor of FileSaver class,
|
||||||
|
// but left here for compatibility.
|
||||||
inline bool SaveFile(const char* name, const std::string& buf, bool binary) {
|
inline bool SaveFile(const char* name, const std::string& buf, bool binary) {
|
||||||
return SaveFile(name, buf.c_str(), buf.size(), binary);
|
return SaveFile(name, buf.c_str(), buf.size(), binary);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,7 +172,8 @@ class Vector {
|
|||||||
scalar_tag;
|
scalar_tag;
|
||||||
|
|
||||||
static FLATBUFFERS_CONSTEXPR bool is_span_observable =
|
static FLATBUFFERS_CONSTEXPR bool is_span_observable =
|
||||||
scalar_tag::value && (FLATBUFFERS_LITTLEENDIAN || sizeof(T) == 1);
|
scalar_tag::value && !std::is_pointer<T>::value &&
|
||||||
|
(FLATBUFFERS_LITTLEENDIAN || sizeof(T) == 1);
|
||||||
|
|
||||||
SizeT size() const { return EndianScalar(length_); }
|
SizeT size() const { return EndianScalar(length_); }
|
||||||
|
|
||||||
@@ -359,6 +360,22 @@ FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<const uint8_t> make_bytes_span(
|
|||||||
return span<const uint8_t>(vec.Data(), vec.size() * sizeof(U));
|
return span<const uint8_t>(vec.Data(), vec.size() * sizeof(U));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if FLATBUFFERS_LITTLEENDIAN
|
||||||
|
|
||||||
|
template <class U>
|
||||||
|
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<U> make_structs_span(
|
||||||
|
Vector<const U*>& vec) FLATBUFFERS_NOEXCEPT {
|
||||||
|
return span<U>(reinterpret_cast<U*>(vec.data()), vec.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class U>
|
||||||
|
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<const U> make_structs_span(
|
||||||
|
const Vector<const U*>& vec) FLATBUFFERS_NOEXCEPT {
|
||||||
|
return span<const U>(reinterpret_cast<const U*>(vec.data()), vec.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// Convenient helper functions to get a span of any vector, regardless
|
// Convenient helper functions to get a span of any vector, regardless
|
||||||
// of whether it is null or not (the field is not set).
|
// of whether it is null or not (the field is not set).
|
||||||
template <class U>
|
template <class U>
|
||||||
@@ -377,6 +394,22 @@ FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<const U> make_span(
|
|||||||
return ptr ? make_span(*ptr) : span<const U>();
|
return ptr ? make_span(*ptr) : span<const U>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if FLATBUFFERS_LITTLEENDIAN
|
||||||
|
|
||||||
|
template <class U>
|
||||||
|
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<U> make_structs_span(
|
||||||
|
Vector<const U*>* ptr) FLATBUFFERS_NOEXCEPT {
|
||||||
|
return ptr ? make_span(*ptr) : span<U>();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class U>
|
||||||
|
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<const U> make_structs_span(
|
||||||
|
const Vector<const U*>* ptr) FLATBUFFERS_NOEXCEPT {
|
||||||
|
return ptr ? make_span(*ptr) : span<const U>();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// Represent a vector much like the template above, but in this case we
|
// Represent a vector much like the template above, but in this case we
|
||||||
// don't know what the element types are (used with reflection.h).
|
// don't know what the element types are (used with reflection.h).
|
||||||
class VectorOfAny {
|
class VectorOfAny {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.google.flatbuffers</groupId>
|
<groupId>com.google.flatbuffers</groupId>
|
||||||
<artifactId>flatbuffers-java</artifactId>
|
<artifactId>flatbuffers-java</artifactId>
|
||||||
<version>25.9.23</version>
|
<version>25.12.19</version>
|
||||||
<packaging>bundle</packaging>
|
<packaging>bundle</packaging>
|
||||||
<name>FlatBuffers Java API</name>
|
<name>FlatBuffers Java API</name>
|
||||||
<description>
|
<description>
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public class Constants {
|
|||||||
* and generated code are modified in sync. Changes to the Java implementation need to be sure to
|
* and generated code are modified in sync. Changes to the Java implementation need to be sure to
|
||||||
* change the version here and in the code generator on every possible incompatible change
|
* change the version here and in the code generator on every possible incompatible change
|
||||||
*/
|
*/
|
||||||
public static void FLATBUFFERS_25_9_23() {}
|
public static void FLATBUFFERS_25_12_19() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @endcond
|
/// @endcond
|
||||||
|
|||||||
@@ -14,14 +14,13 @@ import com.google.flatbuffers.LongVector;
|
|||||||
import com.google.flatbuffers.ShortVector;
|
import com.google.flatbuffers.ShortVector;
|
||||||
import com.google.flatbuffers.StringVector;
|
import com.google.flatbuffers.StringVector;
|
||||||
import com.google.flatbuffers.Struct;
|
import com.google.flatbuffers.Struct;
|
||||||
import com.google.flatbuffers.Table;
|
|
||||||
import com.google.flatbuffers.UnionVector;
|
import com.google.flatbuffers.UnionVector;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public final class Enum extends Table {
|
public final class Enum extends com.google.flatbuffers.Table {
|
||||||
public static void ValidateVersion() { Constants.FLATBUFFERS_25_9_23(); }
|
public static void ValidateVersion() { Constants.FLATBUFFERS_25_12_19(); }
|
||||||
public static Enum getRootAsEnum(ByteBuffer _bb) { return getRootAsEnum(_bb, new Enum()); }
|
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 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); }
|
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||||
|
|||||||
@@ -14,14 +14,13 @@ import com.google.flatbuffers.LongVector;
|
|||||||
import com.google.flatbuffers.ShortVector;
|
import com.google.flatbuffers.ShortVector;
|
||||||
import com.google.flatbuffers.StringVector;
|
import com.google.flatbuffers.StringVector;
|
||||||
import com.google.flatbuffers.Struct;
|
import com.google.flatbuffers.Struct;
|
||||||
import com.google.flatbuffers.Table;
|
|
||||||
import com.google.flatbuffers.UnionVector;
|
import com.google.flatbuffers.UnionVector;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public final class EnumVal extends Table {
|
public final class EnumVal extends com.google.flatbuffers.Table {
|
||||||
public static void ValidateVersion() { Constants.FLATBUFFERS_25_9_23(); }
|
public static void ValidateVersion() { Constants.FLATBUFFERS_25_12_19(); }
|
||||||
public static EnumVal getRootAsEnumVal(ByteBuffer _bb) { return getRootAsEnumVal(_bb, new EnumVal()); }
|
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 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); }
|
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||||
|
|||||||
@@ -14,14 +14,13 @@ import com.google.flatbuffers.LongVector;
|
|||||||
import com.google.flatbuffers.ShortVector;
|
import com.google.flatbuffers.ShortVector;
|
||||||
import com.google.flatbuffers.StringVector;
|
import com.google.flatbuffers.StringVector;
|
||||||
import com.google.flatbuffers.Struct;
|
import com.google.flatbuffers.Struct;
|
||||||
import com.google.flatbuffers.Table;
|
|
||||||
import com.google.flatbuffers.UnionVector;
|
import com.google.flatbuffers.UnionVector;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public final class Field extends Table {
|
public final class Field extends com.google.flatbuffers.Table {
|
||||||
public static void ValidateVersion() { Constants.FLATBUFFERS_25_9_23(); }
|
public static void ValidateVersion() { Constants.FLATBUFFERS_25_12_19(); }
|
||||||
public static Field getRootAsField(ByteBuffer _bb) { return getRootAsField(_bb, new Field()); }
|
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 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); }
|
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||||
|
|||||||
@@ -14,14 +14,13 @@ import com.google.flatbuffers.LongVector;
|
|||||||
import com.google.flatbuffers.ShortVector;
|
import com.google.flatbuffers.ShortVector;
|
||||||
import com.google.flatbuffers.StringVector;
|
import com.google.flatbuffers.StringVector;
|
||||||
import com.google.flatbuffers.Struct;
|
import com.google.flatbuffers.Struct;
|
||||||
import com.google.flatbuffers.Table;
|
|
||||||
import com.google.flatbuffers.UnionVector;
|
import com.google.flatbuffers.UnionVector;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public final class KeyValue extends Table {
|
public final class KeyValue extends com.google.flatbuffers.Table {
|
||||||
public static void ValidateVersion() { Constants.FLATBUFFERS_25_9_23(); }
|
public static void ValidateVersion() { Constants.FLATBUFFERS_25_12_19(); }
|
||||||
public static KeyValue getRootAsKeyValue(ByteBuffer _bb) { return getRootAsKeyValue(_bb, new KeyValue()); }
|
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 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); }
|
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||||
|
|||||||
@@ -14,14 +14,13 @@ import com.google.flatbuffers.LongVector;
|
|||||||
import com.google.flatbuffers.ShortVector;
|
import com.google.flatbuffers.ShortVector;
|
||||||
import com.google.flatbuffers.StringVector;
|
import com.google.flatbuffers.StringVector;
|
||||||
import com.google.flatbuffers.Struct;
|
import com.google.flatbuffers.Struct;
|
||||||
import com.google.flatbuffers.Table;
|
|
||||||
import com.google.flatbuffers.UnionVector;
|
import com.google.flatbuffers.UnionVector;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public final class Object extends Table {
|
public final class Object extends com.google.flatbuffers.Table {
|
||||||
public static void ValidateVersion() { Constants.FLATBUFFERS_25_9_23(); }
|
public static void ValidateVersion() { Constants.FLATBUFFERS_25_12_19(); }
|
||||||
public static Object getRootAsObject(ByteBuffer _bb) { return getRootAsObject(_bb, new Object()); }
|
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 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); }
|
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||||
|
|||||||
@@ -14,14 +14,13 @@ import com.google.flatbuffers.LongVector;
|
|||||||
import com.google.flatbuffers.ShortVector;
|
import com.google.flatbuffers.ShortVector;
|
||||||
import com.google.flatbuffers.StringVector;
|
import com.google.flatbuffers.StringVector;
|
||||||
import com.google.flatbuffers.Struct;
|
import com.google.flatbuffers.Struct;
|
||||||
import com.google.flatbuffers.Table;
|
|
||||||
import com.google.flatbuffers.UnionVector;
|
import com.google.flatbuffers.UnionVector;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public final class RPCCall extends Table {
|
public final class RPCCall extends com.google.flatbuffers.Table {
|
||||||
public static void ValidateVersion() { Constants.FLATBUFFERS_25_9_23(); }
|
public static void ValidateVersion() { Constants.FLATBUFFERS_25_12_19(); }
|
||||||
public static RPCCall getRootAsRPCCall(ByteBuffer _bb) { return getRootAsRPCCall(_bb, new RPCCall()); }
|
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 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); }
|
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||||
|
|||||||
@@ -14,14 +14,13 @@ import com.google.flatbuffers.LongVector;
|
|||||||
import com.google.flatbuffers.ShortVector;
|
import com.google.flatbuffers.ShortVector;
|
||||||
import com.google.flatbuffers.StringVector;
|
import com.google.flatbuffers.StringVector;
|
||||||
import com.google.flatbuffers.Struct;
|
import com.google.flatbuffers.Struct;
|
||||||
import com.google.flatbuffers.Table;
|
|
||||||
import com.google.flatbuffers.UnionVector;
|
import com.google.flatbuffers.UnionVector;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public final class Schema extends Table {
|
public final class Schema extends com.google.flatbuffers.Table {
|
||||||
public static void ValidateVersion() { Constants.FLATBUFFERS_25_9_23(); }
|
public static void ValidateVersion() { Constants.FLATBUFFERS_25_12_19(); }
|
||||||
public static Schema getRootAsSchema(ByteBuffer _bb) { return getRootAsSchema(_bb, new Schema()); }
|
public static Schema getRootAsSchema(ByteBuffer _bb) { return getRootAsSchema(_bb, new Schema()); }
|
||||||
public static Schema getRootAsSchema(ByteBuffer _bb, Schema obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
public static Schema getRootAsSchema(ByteBuffer _bb, Schema obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||||
public static boolean SchemaBufferHasIdentifier(ByteBuffer _bb) { return __has_identifier(_bb, "BFBS"); }
|
public static boolean SchemaBufferHasIdentifier(ByteBuffer _bb) { return __has_identifier(_bb, "BFBS"); }
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import com.google.flatbuffers.LongVector;
|
|||||||
import com.google.flatbuffers.ShortVector;
|
import com.google.flatbuffers.ShortVector;
|
||||||
import com.google.flatbuffers.StringVector;
|
import com.google.flatbuffers.StringVector;
|
||||||
import com.google.flatbuffers.Struct;
|
import com.google.flatbuffers.Struct;
|
||||||
import com.google.flatbuffers.Table;
|
|
||||||
import com.google.flatbuffers.UnionVector;
|
import com.google.flatbuffers.UnionVector;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
@@ -25,8 +24,8 @@ import java.nio.ByteOrder;
|
|||||||
* symbols and examining the `declaration_file` field.
|
* symbols and examining the `declaration_file` field.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public final class SchemaFile extends Table {
|
public final class SchemaFile extends com.google.flatbuffers.Table {
|
||||||
public static void ValidateVersion() { Constants.FLATBUFFERS_25_9_23(); }
|
public static void ValidateVersion() { Constants.FLATBUFFERS_25_12_19(); }
|
||||||
public static SchemaFile getRootAsSchemaFile(ByteBuffer _bb) { return getRootAsSchemaFile(_bb, new SchemaFile()); }
|
public static SchemaFile getRootAsSchemaFile(ByteBuffer _bb) { return getRootAsSchemaFile(_bb, new SchemaFile()); }
|
||||||
public static SchemaFile getRootAsSchemaFile(ByteBuffer _bb, SchemaFile obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
public static SchemaFile getRootAsSchemaFile(ByteBuffer _bb, SchemaFile 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 void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||||
|
|||||||
@@ -14,14 +14,13 @@ import com.google.flatbuffers.LongVector;
|
|||||||
import com.google.flatbuffers.ShortVector;
|
import com.google.flatbuffers.ShortVector;
|
||||||
import com.google.flatbuffers.StringVector;
|
import com.google.flatbuffers.StringVector;
|
||||||
import com.google.flatbuffers.Struct;
|
import com.google.flatbuffers.Struct;
|
||||||
import com.google.flatbuffers.Table;
|
|
||||||
import com.google.flatbuffers.UnionVector;
|
import com.google.flatbuffers.UnionVector;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public final class Service extends Table {
|
public final class Service extends com.google.flatbuffers.Table {
|
||||||
public static void ValidateVersion() { Constants.FLATBUFFERS_25_9_23(); }
|
public static void ValidateVersion() { Constants.FLATBUFFERS_25_12_19(); }
|
||||||
public static Service getRootAsService(ByteBuffer _bb) { return getRootAsService(_bb, new Service()); }
|
public static Service getRootAsService(ByteBuffer _bb) { return getRootAsService(_bb, new Service()); }
|
||||||
public static Service getRootAsService(ByteBuffer _bb, Service obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
public static Service getRootAsService(ByteBuffer _bb, Service 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 void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||||
|
|||||||
@@ -14,14 +14,13 @@ import com.google.flatbuffers.LongVector;
|
|||||||
import com.google.flatbuffers.ShortVector;
|
import com.google.flatbuffers.ShortVector;
|
||||||
import com.google.flatbuffers.StringVector;
|
import com.google.flatbuffers.StringVector;
|
||||||
import com.google.flatbuffers.Struct;
|
import com.google.flatbuffers.Struct;
|
||||||
import com.google.flatbuffers.Table;
|
|
||||||
import com.google.flatbuffers.UnionVector;
|
import com.google.flatbuffers.UnionVector;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public final class Type extends Table {
|
public final class Type extends com.google.flatbuffers.Table {
|
||||||
public static void ValidateVersion() { Constants.FLATBUFFERS_25_9_23(); }
|
public static void ValidateVersion() { Constants.FLATBUFFERS_25_12_19(); }
|
||||||
public static Type getRootAsType(ByteBuffer _bb) { return getRootAsType(_bb, new Type()); }
|
public static Type getRootAsType(ByteBuffer _bb) { return getRootAsType(_bb, new Type()); }
|
||||||
public static Type getRootAsType(ByteBuffer _bb, Type obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
public static Type getRootAsType(ByteBuffer _bb, Type 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 void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||||
|
|||||||
@@ -14,9 +14,12 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
@file:Suppress("NOTHING_TO_INLINE")
|
@file:Suppress("NOTHING_TO_INLINE")
|
||||||
|
@file:OptIn(ExperimentalNativeApi::class)
|
||||||
|
|
||||||
package com.google.flatbuffers.kotlin
|
package com.google.flatbuffers.kotlin
|
||||||
|
|
||||||
|
import kotlin.experimental.ExperimentalNativeApi
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This implementation assumes that of native macOSX64 the byte order of the implementation is
|
* This implementation assumes that of native macOSX64 the byte order of the implementation is
|
||||||
* Little Endian.
|
* Little Endian.
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user