Compare commits
206 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0312061985 | ||
|
|
9f94ceedbc | ||
|
|
bcd2b9d039 | ||
|
|
82fefbf252 | ||
|
|
65e49faf76 | ||
|
|
50be3cfe8c | ||
|
|
026c243dc5 | ||
|
|
a9257b6963 | ||
|
|
fceafd438d | ||
|
|
33a15d63cf | ||
|
|
ad6d6638f3 | ||
|
|
69ac6a712d | ||
|
|
4b69b27d43 | ||
|
|
9318c6c981 | ||
|
|
df287ee6a7 | ||
|
|
0d7bf7e8a7 | ||
|
|
e67310bf1c | ||
|
|
121c4c99ae | ||
|
|
27f5a0fdae | ||
|
|
3592b19150 | ||
|
|
733e432bfd | ||
|
|
5414e04b45 | ||
|
|
c9a286bf29 | ||
|
|
f9a70c79f1 | ||
|
|
1eb4bd3ca7 | ||
|
|
41e47e4951 | ||
|
|
4999936289 | ||
|
|
8e2852fa73 | ||
|
|
7e52f59f14 | ||
|
|
1ff248739e | ||
|
|
2cffba28b4 | ||
|
|
34f0728ea2 | ||
|
|
569e6cb461 | ||
|
|
086097ff94 | ||
|
|
2b0ce37b12 | ||
|
|
67bf1084c0 | ||
|
|
f82c4ac904 | ||
|
|
9a40ab2495 | ||
|
|
5c14ee7e8b | ||
|
|
26e77dce41 | ||
|
|
6913c34e62 | ||
|
|
0222cd4a63 | ||
|
|
0042afa5e2 | ||
|
|
8852f10a84 | ||
|
|
a8df3c8f35 | ||
|
|
b8629d402e | ||
|
|
ccdab58c11 | ||
|
|
a96fe8f206 | ||
|
|
99fda81905 | ||
|
|
8694806f14 | ||
|
|
5a75ad407d | ||
|
|
2d86857bec | ||
|
|
0f90dc8290 | ||
|
|
c9125e6385 | ||
|
|
28ddfaeda7 | ||
|
|
7e59e0727c | ||
|
|
79d9e33ea3 | ||
|
|
bbb6b932fc | ||
|
|
46cc3d6432 | ||
|
|
fb3ccd36c0 | ||
|
|
492475a1b2 | ||
|
|
c75a0154eb | ||
|
|
a2cd1ea3b6 | ||
|
|
32e63af684 | ||
|
|
1f4a9038ce | ||
|
|
a9df44828d | ||
|
|
5f453ef738 | ||
|
|
49061f8c7c | ||
|
|
807adb73b2 | ||
|
|
2f59a0319b | ||
|
|
6a8898573c | ||
|
|
d7a70db6ac | ||
|
|
b127c57ff0 | ||
|
|
2436bd8175 | ||
|
|
69a53e495d | ||
|
|
c7a8102b12 | ||
|
|
2146bacd2e | ||
|
|
8db59321d9 | ||
|
|
42879f6ea6 | ||
|
|
7833affd7e | ||
|
|
c065e972db | ||
|
|
06b12d55ea | ||
|
|
baddf90599 | ||
|
|
8b35a6bc32 | ||
|
|
6cb4d671a8 | ||
|
|
fb9afbafc7 | ||
|
|
dafd2f1f29 | ||
|
|
6ede1ccc9e | ||
|
|
8755c35a18 | ||
|
|
75f05d6389 | ||
|
|
3b27f5396e | ||
|
|
58c8eb5847 | ||
|
|
0e034ecdba | ||
|
|
0f8b71180f | ||
|
|
a5a2da0161 | ||
|
|
28783927af | ||
|
|
a1378fbd16 | ||
|
|
dcacfc5b11 | ||
|
|
f9dabf511a | ||
|
|
5ba66f71c5 | ||
|
|
5adfac9fc3 | ||
|
|
c6fce30e9b | ||
|
|
ef30729a71 | ||
|
|
30ae5f189c | ||
|
|
299725fe2e | ||
|
|
a41fefa1a8 | ||
|
|
d89f611f6f | ||
|
|
150644d7f4 | ||
|
|
c696275eaf | ||
|
|
7106d86685 | ||
|
|
da6472013f | ||
|
|
e646392647 | ||
|
|
e040f4e975 | ||
|
|
f4a9c5325b | ||
|
|
8f2e1dbd88 | ||
|
|
595bf0007a | ||
|
|
0cfb7eb80b | ||
|
|
67eb95de92 | ||
|
|
b1f617fcb2 | ||
|
|
960cd4d635 | ||
|
|
6ff9e90e7e | ||
|
|
5b32e8f5c2 | ||
|
|
0bed8cd4a0 | ||
|
|
7cd216c51e | ||
|
|
129ef422e8 | ||
|
|
e5fc3b16d8 | ||
|
|
c0d16995a4 | ||
|
|
70c8292c29 | ||
|
|
d47cd10d77 | ||
|
|
66bd3d7400 | ||
|
|
0cc1edb3ad | ||
|
|
57375a9e1c | ||
|
|
0346535221 | ||
|
|
7d62dcc422 | ||
|
|
b3cd878dfe | ||
|
|
09486a9f97 | ||
|
|
dd79eed495 | ||
|
|
0e1305c8e2 | ||
|
|
88549130e1 | ||
|
|
6dfc59dfcc | ||
|
|
5ba80c24e0 | ||
|
|
da55ac3a27 | ||
|
|
c6f9e010bb | ||
|
|
94ff188a3e | ||
|
|
5a937f1ba1 | ||
|
|
e1c3690a2a | ||
|
|
b08abbbbf6 | ||
|
|
7d6d99c6be | ||
|
|
d3055a97e7 | ||
|
|
0dc5a75dc0 | ||
|
|
f175e60998 | ||
|
|
a632c3c004 | ||
|
|
11789e41b6 | ||
|
|
a9c0845504 | ||
|
|
526c92546f | ||
|
|
eb80ead90b | ||
|
|
386b6353ed | ||
|
|
d09696bbe6 | ||
|
|
a228e8c9b8 | ||
|
|
91a3172519 | ||
|
|
e0d4562782 | ||
|
|
49677b0b70 | ||
|
|
8e34ad5db7 | ||
|
|
eb64390080 | ||
|
|
46577d0d2f | ||
|
|
32029ac699 | ||
|
|
4354945727 | ||
|
|
755573bcda | ||
|
|
205285c35c | ||
|
|
f4e23bf91e | ||
|
|
1fdb5d263a | ||
|
|
c4211538bd | ||
|
|
bcb9ef1876 | ||
|
|
c5441dc199 | ||
|
|
7f417e3397 | ||
|
|
3c35a143ea | ||
|
|
56e2bc30b0 | ||
|
|
eb40a54672 | ||
|
|
15f16f149e | ||
|
|
053d39adaf | ||
|
|
6f71b76e6f | ||
|
|
4b7d8e0df9 | ||
|
|
0def91105f | ||
|
|
8176a204fc | ||
|
|
e8b2492cf1 | ||
|
|
5d4386b1bc | ||
|
|
a6a3989dd4 | ||
|
|
696f47f1f7 | ||
|
|
a3dfcf3326 | ||
|
|
d3e8cb60a1 | ||
|
|
0343396e49 | ||
|
|
f625ff3330 | ||
|
|
362dd663f8 | ||
|
|
5a8a395756 | ||
|
|
afafd206a3 | ||
|
|
48da238920 | ||
|
|
8836ddab41 | ||
|
|
23922e7eba | ||
|
|
f8fe811d5c | ||
|
|
0cc525b722 | ||
|
|
28861d1d7d | ||
|
|
204473cdb5 | ||
|
|
85088a196d | ||
|
|
6e214c3a49 | ||
|
|
96294e9f84 | ||
|
|
b7856f8e27 |
@@ -1,24 +1,16 @@
|
||||
---
|
||||
buildifier: latest
|
||||
platforms:
|
||||
ubuntu1804:
|
||||
matrix:
|
||||
bazel:
|
||||
- 7.x
|
||||
- 8.x
|
||||
tasks:
|
||||
verify_ubuntu2004:
|
||||
platform: ubuntu2004
|
||||
bazel: ${{ bazel }}
|
||||
environment:
|
||||
CC: clang
|
||||
SWIFT_VERSION: "5.5.3"
|
||||
SWIFT_HOME: "$HOME/swift-$SWIFT_VERSION"
|
||||
PATH: "$PATH:$SWIFT_HOME/usr/bin"
|
||||
shell_commands:
|
||||
- "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME"
|
||||
- "mkdir $SWIFT_HOME"
|
||||
- "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu1804/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu18.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME"
|
||||
build_targets:
|
||||
- "//..."
|
||||
test_targets:
|
||||
- "//..."
|
||||
ubuntu2004:
|
||||
environment:
|
||||
CC: clang
|
||||
SWIFT_VERSION: "5.5.3"
|
||||
SWIFT_VERSION: "5.8"
|
||||
SWIFT_HOME: "$HOME/swift-$SWIFT_VERSION"
|
||||
PATH: "$PATH:$SWIFT_HOME/usr/bin"
|
||||
shell_commands:
|
||||
@@ -29,8 +21,40 @@ platforms:
|
||||
- "//..."
|
||||
test_targets:
|
||||
- "//..."
|
||||
macos:
|
||||
verify_ubuntu2204:
|
||||
platform: ubuntu2204
|
||||
bazel: ${{ bazel }}
|
||||
environment:
|
||||
CC: clang
|
||||
SWIFT_VERSION: "5.8"
|
||||
SWIFT_HOME: "$HOME/swift-$SWIFT_VERSION"
|
||||
PATH: "$PATH:$SWIFT_HOME/usr/bin"
|
||||
shell_commands:
|
||||
- "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME"
|
||||
- "mkdir $SWIFT_HOME"
|
||||
- "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu2204/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu22.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME"
|
||||
build_targets:
|
||||
- "//..."
|
||||
test_targets:
|
||||
- "//..."
|
||||
test_module_cpp:
|
||||
platform: ubuntu2204
|
||||
bazel: ${{ bazel }}
|
||||
working_directory: tests/bazel_repository_test_dir
|
||||
build_targets:
|
||||
- "//..."
|
||||
test_module_ts:
|
||||
platform: ubuntu2204
|
||||
bazel: ${{ bazel }}
|
||||
working_directory: tests/ts/bazel_repository_test_dir
|
||||
test_targets:
|
||||
- "//..."
|
||||
verify_macos:
|
||||
platform: macos
|
||||
bazel: ${{ bazel }}
|
||||
xcode_version: "15.2"
|
||||
build_targets:
|
||||
- "//:flatbuffers"
|
||||
- "//:flatc"
|
||||
test_targets:
|
||||
- "//tests:flatbuffers_test"
|
||||
|
||||
@@ -1 +1,5 @@
|
||||
node_modules
|
||||
ts/node_modules
|
||||
|
||||
# Test workspaces
|
||||
tests/bazel_repository_test_dir
|
||||
tests/ts/bazel_repository_test_dir
|
||||
|
||||
18
.bazelrc
@@ -1,4 +1,18 @@
|
||||
# We cannot use "common" here because the "version" command doesn't support
|
||||
# --deleted_packages. We need to specify it for both build and query instead.
|
||||
build --deleted_packages=tests/ts/bazel_repository_test_dir
|
||||
query --deleted_packages=tests/ts/bazel_repository_test_dir
|
||||
build --deleted_packages=tests/bazel_repository_test_dir,tests/ts/bazel_repository_test_dir
|
||||
query --deleted_packages=tests/bazel_repository_test_dir,tests/ts/bazel_repository_test_dir
|
||||
# Point tools such as coursier (used in rules_jvm_external) to Bazel's internal JDK
|
||||
# suggested in https://github.com/bazelbuild/rules_jvm_external/issues/445
|
||||
common --repo_env=JAVA_HOME=../bazel_tools/jdk
|
||||
common --action_env=JAVA_HOME=../bazel_tools/jdk
|
||||
# Workaround "Error: need --enable_runfiles on Windows for to support rules_js"
|
||||
common:windows --enable_runfiles
|
||||
# Swift is not required on Windows
|
||||
common:windows --deleted_packages=swift
|
||||
# Ignore warnings in external dependencies
|
||||
build --per_file_copt=external/.*@-Wno-everything --host_per_file_copt=external/.*@-Wno-everything
|
||||
# Honor the setting of `skipLibCheck` in the tsconfig.json file.
|
||||
common --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig
|
||||
# Use "tsc" as the transpiler when ts_project has no `transpiler` set.
|
||||
common --@aspect_rules_ts//ts:default_to_tsc_transpiler
|
||||
|
||||
11
.github/ISSUE_TEMPLATE/404-doc.md
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
---
|
||||
name: 404 Doc
|
||||
about: To fix broken documentation links
|
||||
title: "[Doc 404]"
|
||||
labels: documentation
|
||||
assignees: dbaileychess
|
||||
|
||||
---
|
||||
|
||||
Target URL:
|
||||
[Optional] Source Site:
|
||||
1
.github/labeler.yml
vendored
@@ -48,6 +48,7 @@ java:
|
||||
kotlin:
|
||||
- '**/*.kt'
|
||||
- src/idl_gen_kotlin.cpp
|
||||
- src/idl_gen_kotlin_kmp.cpp
|
||||
|
||||
lua:
|
||||
- '**/*.lua'
|
||||
|
||||
231
.github/workflows/build.yml
vendored
@@ -9,10 +9,12 @@ on:
|
||||
- "*" # new tag version, like `0.8.4` or else
|
||||
branches:
|
||||
- master
|
||||
- flatbuffers-64
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
schedule:
|
||||
# Run daily at 4:45 A.M. to catch dependencies that break us.
|
||||
- cron: '45 4 * * *'
|
||||
|
||||
jobs:
|
||||
build-linux:
|
||||
@@ -22,10 +24,10 @@ jobs:
|
||||
digests-gcc: ${{ steps.hash-gcc.outputs.hashes }}
|
||||
digests-clang: ${{ steps.hash-clang.outputs.hashes }}
|
||||
name: Build Linux
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
matrix:
|
||||
cxx: [g++-10, clang++-12]
|
||||
cxx: [g++-13, clang++-18]
|
||||
fail-fast: false
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@@ -39,12 +41,8 @@ jobs:
|
||||
run: |
|
||||
chmod +x flatc
|
||||
./flatc --version
|
||||
# - name: flatc tests
|
||||
# run: |
|
||||
# yarn global add esbuild
|
||||
# python3 tests/flatc/main.py
|
||||
- name: upload build artifacts
|
||||
uses: actions/upload-artifact@v1
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Linux flatc binary ${{ matrix.cxx }}
|
||||
path: flatc
|
||||
@@ -58,27 +56,29 @@ jobs:
|
||||
with:
|
||||
files: Linux.flatc.binary.${{ matrix.cxx }}.zip
|
||||
- name: Generate SLSA subjects - clang
|
||||
if: matrix.cxx == 'clang++-12' && startsWith(github.ref, 'refs/tags/')
|
||||
if: matrix.cxx == 'clang++-18' && startsWith(github.ref, 'refs/tags/')
|
||||
id: hash-clang
|
||||
run: echo "hashes=$(sha256sum Linux.flatc.binary.${{ matrix.cxx }}.zip | base64 -w0)" >> $GITHUB_OUTPUT
|
||||
- name: Generate SLSA subjects - gcc
|
||||
if: matrix.cxx == 'g++-10' && startsWith(github.ref, 'refs/tags/')
|
||||
if: matrix.cxx == 'g++-13' && startsWith(github.ref, 'refs/tags/')
|
||||
id: hash-gcc
|
||||
run: echo "hashes=$(sha256sum Linux.flatc.binary.${{ matrix.cxx }}.zip | base64 -w0)" >> $GITHUB_OUTPUT
|
||||
|
||||
build-linux-no-file-tests:
|
||||
|
||||
build-linux-no-file-tests:
|
||||
name: Build Linux with -DFLATBUFFERS_NO_FILE_TESTS
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: CXX=clang++-12 cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON -DFLATBUFFERS_CXX_FLAGS="-DFLATBUFFERS_NO_FILE_TESTS" .
|
||||
run: CXX=clang++-18 cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON -DFLATBUFFERS_CXX_FLAGS="-DFLATBUFFERS_NO_FILE_TESTS" .
|
||||
- name: build
|
||||
run: make -j
|
||||
- name: test
|
||||
run: ./flattests
|
||||
|
||||
build-linux-out-of-source:
|
||||
build-linux-out-of-source:
|
||||
name: Build Linux with out-of-source build location
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: make build directory
|
||||
@@ -86,7 +86,7 @@ jobs:
|
||||
- name: cmake
|
||||
working-directory: build
|
||||
run: >
|
||||
CXX=clang++-12 cmake .. -G "Unix Makefiles" -DFLATBUFFERS_STRICT_MODE=ON
|
||||
CXX=clang++-18 cmake .. -G "Unix Makefiles" -DFLATBUFFERS_STRICT_MODE=ON
|
||||
-DFLATBUFFERS_BUILD_CPP17=ON -DFLATBUFFERS_CPP_STD=17
|
||||
- name: build
|
||||
working-directory: build
|
||||
@@ -100,22 +100,23 @@ jobs:
|
||||
|
||||
build-linux-cpp-std:
|
||||
name: Build Linux C++
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
std: [11, 14, 17, 20, 23]
|
||||
cxx: [g++-10, clang++-12]
|
||||
cxx: [g++-13, clang++-18]
|
||||
exclude:
|
||||
# GCC 10.3.0 doesn't support std 23
|
||||
- cxx: g++-10
|
||||
# Clang++15 10.3.0 stdlibc++ doesn't fully support std 23
|
||||
- cxx: clang++-18
|
||||
std: 23
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: >
|
||||
CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles"
|
||||
-DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON
|
||||
CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles"
|
||||
-DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON
|
||||
-DFLATBUFFERS_CPP_STD=${{ matrix.std }}
|
||||
-DFLATBUFFERS_BUILD_CPP17=${{ matrix.std >= 17 && 'On' || 'Off'}}
|
||||
- name: build
|
||||
@@ -126,7 +127,7 @@ jobs:
|
||||
if: matrix.std >= 17
|
||||
run: ./flattests_cpp17
|
||||
|
||||
build-windows-cpp-std:
|
||||
build-cpp-std:
|
||||
name: Build Windows C++
|
||||
runs-on: windows-2019
|
||||
strategy:
|
||||
@@ -139,8 +140,8 @@ jobs:
|
||||
uses: microsoft/setup-msbuild@v1.1
|
||||
- name: cmake
|
||||
run: >
|
||||
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release
|
||||
-DFLATBUFFERS_STRICT_MODE=ON
|
||||
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release
|
||||
-DFLATBUFFERS_STRICT_MODE=ON
|
||||
-DFLATBUFFERS_CPP_STD=${{ matrix.std }}
|
||||
-DFLATBUFFERS_BUILD_CPP17=${{ matrix.std >= 17 && 'On' || 'Off'}}
|
||||
- name: build
|
||||
@@ -156,7 +157,7 @@ jobs:
|
||||
contents: write
|
||||
outputs:
|
||||
digests: ${{ steps.hash.outputs.hashes }}
|
||||
name: Build Windows 2019
|
||||
name: Build Windows 2019
|
||||
runs-on: windows-2019
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@@ -168,10 +169,8 @@ jobs:
|
||||
run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64
|
||||
- name: test
|
||||
run: Release\flattests.exe
|
||||
# - name: flatc tests
|
||||
# run: python3 tests/flatc/main.py --flatc Release\flatc.exe
|
||||
- name: upload build artifacts
|
||||
uses: actions/upload-artifact@v1
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Windows flatc binary
|
||||
path: Release\flatc.exe
|
||||
@@ -190,61 +189,38 @@ jobs:
|
||||
shell: bash
|
||||
run: echo "hashes=$(sha256sum Windows.flatc.binary.zip | base64 -w0)" >> $GITHUB_OUTPUT
|
||||
|
||||
build-windows-2017:
|
||||
name: Build Windows 2017
|
||||
runs-on: windows-2019
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Add msbuild to PATH
|
||||
uses: microsoft/setup-msbuild@v1.1
|
||||
- name: cmake
|
||||
run: cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON .
|
||||
- name: build tool version 15 (VS 2017)
|
||||
run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64 /p:VisualStudioVersion=15.0
|
||||
- name: test
|
||||
run: Release\flattests.exe
|
||||
|
||||
build-windows-2015:
|
||||
name: Build Windows 2015
|
||||
runs-on: windows-2019
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Add msbuild to PATH
|
||||
uses: microsoft/setup-msbuild@v1.1
|
||||
- name: cmake
|
||||
run: cmake -G "Visual Studio 14 2015" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON .
|
||||
- name: build tool version 14 (VS 2015)
|
||||
run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64 /p:VisualStudioVersion=14.0
|
||||
- name: test
|
||||
run: Release\flattests.exe
|
||||
|
||||
build-dotnet-windows:
|
||||
name: Build .NET Windows
|
||||
runs-on: windows-2019
|
||||
runs-on: windows-2022-64core
|
||||
strategy:
|
||||
matrix:
|
||||
configuration: [
|
||||
'',
|
||||
'-p:UnsafeByteBuffer=true',
|
||||
'-p:UnsafeByteBuffer=true',
|
||||
# Fails two tests currently.
|
||||
#'-p:EnableSpanT=true,UnsafeByteBuffer=true'
|
||||
]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup .NET Core SDK
|
||||
uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: '3.1.x'
|
||||
uses: actions/setup-dotnet@v4.2.0
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
- name: Build
|
||||
run: |
|
||||
cd tests\FlatBuffers.Test
|
||||
dotnet new sln --force --name FlatBuffers.Core.Test
|
||||
dotnet sln FlatBuffers.Core.Test.sln add FlatBuffers.Core.Test.csproj
|
||||
dotnet build -c Release ${{matrix.configuration}} -o out FlatBuffers.Core.Test.sln
|
||||
- name: Run
|
||||
dotnet new sln --force --name FlatBuffers.Test
|
||||
dotnet sln FlatBuffers.Test.sln add FlatBuffers.Test.csproj
|
||||
dotnet build -c Release ${{matrix.configuration}} FlatBuffers.Test.sln
|
||||
- name: Run net6.0
|
||||
run: |
|
||||
cd tests\FlatBuffers.Test
|
||||
out\FlatBuffers.Core.Test.exe
|
||||
cd tests\FlatBuffers.Test\bin\Release\net6.0
|
||||
dir
|
||||
.\FlatBuffers.Test.exe
|
||||
- name: Run net8.0
|
||||
run: |
|
||||
cd tests\FlatBuffers.Test\bin\Release\net8.0
|
||||
.\FlatBuffers.Test.exe
|
||||
|
||||
build-mac-intel:
|
||||
permissions:
|
||||
@@ -252,11 +228,11 @@ jobs:
|
||||
outputs:
|
||||
digests: ${{ steps.hash.outputs.hashes }}
|
||||
name: Build Mac (for Intel)
|
||||
runs-on: macos-latest
|
||||
runs-on: macos-latest-large
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: cmake -G "Xcode" -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
|
||||
run: xcodebuild -toolchain clang -configuration Release -target flattests
|
||||
- name: check that the binary is x86_64
|
||||
@@ -270,12 +246,10 @@ jobs:
|
||||
run: |
|
||||
chmod +x Release/flatc
|
||||
Release/flatc --version
|
||||
# - name: flatc tests
|
||||
# run: python3 tests/flatc/main.py --flatc Release/flatc
|
||||
- name: upload build artifacts
|
||||
uses: actions/upload-artifact@v1
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Mac flatc binary
|
||||
name: Mac flatc binary Intel
|
||||
path: Release/flatc
|
||||
# Below if only for release.
|
||||
- name: Zip file
|
||||
@@ -316,9 +290,9 @@ jobs:
|
||||
chmod +x Release/flatc
|
||||
Release/flatc --version
|
||||
- name: upload build artifacts
|
||||
uses: actions/upload-artifact@v1
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Mac flatc binary
|
||||
name: Mac flatc binary Universal
|
||||
path: Release/flatc
|
||||
# Below if only for release.
|
||||
- name: Zip file
|
||||
@@ -336,7 +310,7 @@ jobs:
|
||||
|
||||
build-android:
|
||||
name: Build Android (on Linux)
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: set up Java
|
||||
@@ -355,10 +329,10 @@ jobs:
|
||||
|
||||
build-generator:
|
||||
name: Check Generated Code
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
matrix:
|
||||
cxx: [g++-10, clang++-12]
|
||||
cxx: [g++-13, clang++-18]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
@@ -386,10 +360,10 @@ jobs:
|
||||
|
||||
build-benchmarks:
|
||||
name: Build Benchmarks (on Linux)
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
matrix:
|
||||
cxx: [g++-10]
|
||||
cxx: [g++-13]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
@@ -397,14 +371,14 @@ jobs:
|
||||
- name: Run benchmarks
|
||||
run: ./flatbenchmark --benchmark_repetitions=5 --benchmark_display_aggregates_only=true --benchmark_out_format=console --benchmark_out=benchmarks/results_${{matrix.cxx}}
|
||||
- name: Upload benchmarks results
|
||||
uses: actions/upload-artifact@v1
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Linux flatbenchmark results ${{matrix.cxx}}
|
||||
path: benchmarks/results_${{matrix.cxx}}
|
||||
|
||||
build-java:
|
||||
name: Build Java
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: test
|
||||
@@ -413,22 +387,34 @@ jobs:
|
||||
|
||||
build-kotlin-macos:
|
||||
name: Build Kotlin MacOS
|
||||
runs-on: macos-latest
|
||||
runs-on: macos-13
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
# 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
|
||||
- uses: gradle/wrapper-validation-action@v1.0.5
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '11'
|
||||
- name: Build flatc
|
||||
run: |
|
||||
cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF .
|
||||
make -j
|
||||
echo "${PWD}" >> $GITHUB_PATH
|
||||
- name: Build
|
||||
working-directory: kotlin
|
||||
run: ./gradlew clean iosX64Test macosX64Test
|
||||
run: ./gradlew clean iosSimulatorArm64Test macosX64Test macosArm64Test
|
||||
|
||||
build-kotlin-linux:
|
||||
name: Build Kotlin Linux
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
@@ -437,6 +423,11 @@ jobs:
|
||||
distribution: 'temurin'
|
||||
java-version: '11'
|
||||
- uses: gradle/wrapper-validation-action@v1.0.5
|
||||
- name: Build flatc
|
||||
run: |
|
||||
cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF .
|
||||
make -j
|
||||
echo "${PWD}" >> $GITHUB_PATH
|
||||
- name: Build
|
||||
working-directory: kotlin
|
||||
# we are using docker's version of gradle
|
||||
@@ -446,16 +437,16 @@ jobs:
|
||||
|
||||
build-rust-linux:
|
||||
name: Build Rust Linux
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: test
|
||||
working-directory: tests
|
||||
run: bash RustTest.sh
|
||||
|
||||
|
||||
build-rust-windows:
|
||||
name: Build Rust Windows
|
||||
runs-on: windows-2019
|
||||
runs-on: windows-2022-64core
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: test
|
||||
@@ -464,7 +455,7 @@ jobs:
|
||||
|
||||
build-python:
|
||||
name: Build Python
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: flatc
|
||||
@@ -476,7 +467,7 @@ jobs:
|
||||
|
||||
build-go:
|
||||
name: Build Go
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: flatc
|
||||
@@ -488,7 +479,7 @@ jobs:
|
||||
|
||||
build-php:
|
||||
name: Build PHP
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: flatc
|
||||
@@ -502,9 +493,18 @@ jobs:
|
||||
|
||||
build-swift:
|
||||
name: Build Swift
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
swift: ["5.8", "5.9", "5.10"]
|
||||
# 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-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: swift-actions/setup-swift@v2
|
||||
with:
|
||||
swift-version: ${{ matrix.swift }}
|
||||
- name: Get swift version
|
||||
run: swift --version
|
||||
- name: test
|
||||
working-directory: tests/swift/tests
|
||||
run: |
|
||||
@@ -513,20 +513,22 @@ jobs:
|
||||
|
||||
build-swift-wasm:
|
||||
name: Build Swift Wasm
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
container:
|
||||
image: ghcr.io/swiftwasm/carton:0.15.3
|
||||
image: ghcr.io/swiftwasm/carton:0.20.1
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup Wasmer
|
||||
uses: wasmerio/setup-wasmer@v2
|
||||
- name: Test
|
||||
working-directory: tests/swift/Wasm.tests
|
||||
run: carton test
|
||||
- uses: actions/checkout@v3
|
||||
- uses: bytecodealliance/actions/wasmtime/setup@v1
|
||||
- uses: swiftwasm/setup-swiftwasm@v1
|
||||
with:
|
||||
swift-version: "wasm-6.0.2-RELEASE"
|
||||
- name: Test
|
||||
working-directory: tests/swift/Wasm.tests
|
||||
run: swift run carton test
|
||||
|
||||
build-ts:
|
||||
name: Build TS
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: flatc
|
||||
@@ -544,7 +546,7 @@ jobs:
|
||||
|
||||
build-dart:
|
||||
name: Build Dart
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: dart-lang/setup-dart@v1
|
||||
@@ -559,7 +561,7 @@ jobs:
|
||||
|
||||
build-nim:
|
||||
name: Build Nim
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: flatc
|
||||
@@ -568,17 +570,32 @@ jobs:
|
||||
- uses: jiro4989/setup-nim-action@v1
|
||||
- name: install library
|
||||
working-directory: nim
|
||||
run: nimble -y develop
|
||||
run: nimble -y develop && nimble install
|
||||
- name: test
|
||||
working-directory: tests/nim
|
||||
run: python3 testnim.py
|
||||
|
||||
bazel:
|
||||
name: Bazel
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: bazel build
|
||||
run: >
|
||||
bazel build
|
||||
//:flatc
|
||||
//:flatbuffers
|
||||
- name: bazel test
|
||||
run: >
|
||||
bazel test
|
||||
//tests:flatbuffers_test
|
||||
|
||||
release-digests:
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
needs: [build-linux, build-windows, build-mac-intel, build-mac-universal]
|
||||
outputs:
|
||||
digests: ${{ steps.hash.outputs.digests }}
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Merge results
|
||||
id: hash
|
||||
|
||||
71
.github/workflows/codeql.yml
vendored
@@ -1,71 +0,0 @@
|
||||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL"
|
||||
permissions: read-all
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ master ]
|
||||
schedule:
|
||||
- cron: '16 20 * * 0'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'cpp' ]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
||||
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
# - name: Autobuild
|
||||
# uses: github/codeql-action/autobuild@v2
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
- run: |
|
||||
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON .
|
||||
make -j
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
36
.github/workflows/docs.yml
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
name: docs
|
||||
on:
|
||||
# For manual pushes.
|
||||
workflow_dispatch:
|
||||
|
||||
# Pushes to main that touch the documentation directory.
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- 'docs/**'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Configure Git Credentials
|
||||
run: |
|
||||
git config user.name github-actions[bot]
|
||||
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: 3.x
|
||||
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
key: mkdocs-material-${{ env.cache_id }}
|
||||
path: .cache
|
||||
restore-keys: |
|
||||
mkdocs-material-
|
||||
- run: pip install mkdocs-material
|
||||
- run: pip install mkdocs-redirects
|
||||
- run: mkdocs gh-deploy --force -f docs/mkdocs.yml
|
||||
35
.github/workflows/extrabuild.yml
vendored
@@ -1,35 +0,0 @@
|
||||
name: Build and unit tests that are more time consuming
|
||||
permissions: read-all
|
||||
|
||||
on:
|
||||
# For manual tests.
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
types:
|
||||
- closed
|
||||
schedule:
|
||||
- cron: "30 20 * * *"
|
||||
|
||||
jobs:
|
||||
build-linux-s390x:
|
||||
name: Build Linux on s390x arch and run unit tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: uraimo/run-on-arch-action@v2
|
||||
name: Run commands
|
||||
id: runcmd
|
||||
with:
|
||||
arch: s390x
|
||||
distro: ubuntu_latest
|
||||
install: |
|
||||
apt-get update -q -y
|
||||
apt-get -y install cmake
|
||||
apt-get -y install make
|
||||
apt-get -y install g++
|
||||
run: |
|
||||
lscpu | grep Endian
|
||||
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
|
||||
make -j
|
||||
./flattests
|
||||
|
||||
4
.github/workflows/label.yml
vendored
@@ -19,6 +19,6 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/labeler@main
|
||||
- uses: actions/labeler@ee18d5d34efd9b4f7dafdb0e363cb688eb438044 # 4.1.0
|
||||
with:
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
|
||||
4
.github/workflows/main.yml
vendored
@@ -1,7 +1,7 @@
|
||||
name: OSS-Fuzz
|
||||
permissions: read-all
|
||||
|
||||
on:
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
language: c++
|
||||
fuzz-seconds: 60
|
||||
- name: Upload Crash
|
||||
uses: actions/upload-artifact@v1
|
||||
uses: actions/upload-artifact@v4
|
||||
if: failure() && steps.build.outcome == 'success'
|
||||
with:
|
||||
name: artifacts
|
||||
|
||||
86
.github/workflows/release.yml
vendored
@@ -5,23 +5,23 @@ on:
|
||||
# For manual tests.
|
||||
workflow_dispatch:
|
||||
release:
|
||||
types: [created]
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
publish-npm:
|
||||
name: Publish NPM
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '16.x'
|
||||
node-version: '20.x'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
|
||||
- run: npm publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
|
||||
publish-pypi:
|
||||
name: Publish PyPi
|
||||
runs-on: ubuntu-latest
|
||||
@@ -33,16 +33,16 @@ jobs:
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.10'
|
||||
|
||||
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
python3 -m pip install --upgrade pip
|
||||
python3 -m pip install setuptools wheel twine
|
||||
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
python3 setup.py sdist bdist_wheel
|
||||
|
||||
|
||||
- name: Upload to PyPi
|
||||
run: |
|
||||
python3 -m twine upload dist/*
|
||||
@@ -60,20 +60,19 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: '6.0.x'
|
||||
|
||||
dotnet-version: '8.0.x'
|
||||
- name: Build
|
||||
run: |
|
||||
dotnet build Google.FlatBuffers.csproj -c Release
|
||||
|
||||
|
||||
- name: Pack
|
||||
run: |
|
||||
dotnet pack Google.FlatBuffers.csproj -c Release
|
||||
|
||||
|
||||
- name: Upload to NuGet
|
||||
run: |
|
||||
dotnet nuget push .\bin\Release\Google.FlatBuffers.*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
|
||||
|
||||
dotnet nuget push .\bin\Release\Google.FlatBuffers.*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
|
||||
|
||||
publish-maven:
|
||||
name: Publish Maven
|
||||
runs-on: ubuntu-latest
|
||||
@@ -82,7 +81,7 @@ jobs:
|
||||
working-directory: ./java
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
|
||||
- name: Set up Maven Central Repository
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
@@ -94,13 +93,60 @@ jobs:
|
||||
server-password: OSSRH_PASSWORD
|
||||
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
|
||||
gpg-passphrase: MAVEN_GPG_PASSPHRASE # this needs to be an env var
|
||||
|
||||
|
||||
- name: Publish Maven
|
||||
run: mvn --batch-mode clean deploy
|
||||
env:
|
||||
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
|
||||
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
|
||||
OSSRH_USERNAME: ${{ secrets.OSSRH_USER_V2 }}
|
||||
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN_V2 }}
|
||||
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
|
||||
|
||||
|
||||
|
||||
publish-maven-kotlin:
|
||||
name: Publish Maven - Kotlin
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./kotlin
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Maven Central Repository
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '11'
|
||||
distribution: 'adopt'
|
||||
cache: 'maven'
|
||||
server-id: ossrh
|
||||
server-username: OSSRH_USERNAME
|
||||
server-password: OSSRH_PASSWORD
|
||||
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
|
||||
gpg-passphrase: MAVEN_GPG_PASSPHRASE # this needs to be an env var
|
||||
|
||||
- name: Publish Kotlin Library on Maven
|
||||
run: ./gradlew publishAllPublicationsToSonatypeRepository
|
||||
env:
|
||||
OSSRH_USERNAME: ${{ secrets.OSSRH_USER_V2 }}
|
||||
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN_V2 }}
|
||||
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
|
||||
|
||||
|
||||
publish-crates:
|
||||
name: Publish crates.io
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
|
||||
- name: Publish Flatbuffers
|
||||
uses: katyo/publish-crates@v2
|
||||
with:
|
||||
path: ./rust/flatbuffers
|
||||
registry-token: ${{ secrets.CARGO_TOKEN }}
|
||||
|
||||
- name: Publish Flexbuffers
|
||||
uses: katyo/publish-crates@v2
|
||||
with:
|
||||
path: ./rust/flexbuffers
|
||||
registry-token: ${{ secrets.CARGO_TOKEN }}
|
||||
|
||||
55
.github/workflows/scorecards.yml
vendored
@@ -1,55 +0,0 @@
|
||||
name: Scorecards supply-chain security
|
||||
on:
|
||||
# Only the default branch is supported.
|
||||
branch_protection_rule:
|
||||
schedule:
|
||||
- cron: '21 2 * * 5'
|
||||
push:
|
||||
branches: [ master ]
|
||||
|
||||
# Declare default permissions as read only.
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
analysis:
|
||||
name: Scorecards analysis
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
# Needed to upload the results to code-scanning dashboard.
|
||||
security-events: write
|
||||
actions: read
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # v3.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: "Run analysis"
|
||||
uses: ossf/scorecard-action@ce330fde6b1a5c9c75b417e7efc510b822a35564 # v1.1.2
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
# Read-only PAT token. To create it,
|
||||
# follow the steps in https://github.com/ossf/scorecard-action#pat-token-creation.
|
||||
repo_token: ${{ secrets.SCORECARD_READ_TOKEN }}
|
||||
# Publish the results to enable scorecard badges. For more details, see
|
||||
# https://github.com/ossf/scorecard-action#publishing-results.
|
||||
# For private repositories, `publish_results` will automatically be set to `false`,
|
||||
# regardless of the value entered here.
|
||||
publish_results: true
|
||||
|
||||
# Upload the results as artifacts (optional).
|
||||
- name: "Upload artifact"
|
||||
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # v3.0.0
|
||||
with:
|
||||
name: SARIF file
|
||||
path: results.sarif
|
||||
retention-days: 5
|
||||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@5f532563584d71fdef14ee64d17bafb34f751ce5 # v1.0.26
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
8
.github/workflows/stale.yml
vendored
@@ -28,10 +28,10 @@ jobs:
|
||||
days-before-issue-close: 14 # 2 weeks
|
||||
exempt-issue-labels: not-stale
|
||||
|
||||
stale-pr-message: 'This pull request is stale because it has been open 3 weeks with no activity. Please comment or label `not-stale`, or this will be closed in 7 days.'
|
||||
close-pr-message: 'This pull request was automatically closed due to no activity for 3 weeks plus the 7 day notice period.'
|
||||
days-before-pr-stale: 21 # 3 weeks
|
||||
days-before-pr-close: 7 # 1 week
|
||||
stale-pr-message: 'This pull request is stale because it has been open 6 months with no activity. Please comment or label `not-stale`, or this will be closed in 14 days.'
|
||||
close-pr-message: 'This pull request was automatically closed due to no activity for 6 months plus the 14 day notice period.'
|
||||
days-before-pr-stale: 182 # 6 months
|
||||
days-before-pr-close: 14 # 2 week
|
||||
exempt-pr-labels: not-stale
|
||||
exempt-draft-pr: false
|
||||
|
||||
|
||||
6
.gitignore
vendored
@@ -151,3 +151,9 @@ flatbuffers.pc
|
||||
# https://cmake.org/cmake/help/latest/module/FetchContent.html#variable:FETCHCONTENT_BASE_DIR
|
||||
cmake-build-debug/
|
||||
_deps/
|
||||
**/.gradle/**
|
||||
kotlin/**/generated
|
||||
MODULE.bazel.lock
|
||||
|
||||
# Ignore the generated docs
|
||||
docs/site
|
||||
26
BUILD.bazel
@@ -1,5 +1,3 @@
|
||||
load("@aspect_rules_js//npm:defs.bzl", "npm_link_package")
|
||||
load("@npm//:defs.bzl", "npm_link_all_packages")
|
||||
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
|
||||
|
||||
licenses(["notice"])
|
||||
@@ -8,13 +6,6 @@ package(
|
||||
default_visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
npm_link_all_packages(name = "node_modules")
|
||||
|
||||
npm_link_package(
|
||||
name = "node_modules/flatbuffers",
|
||||
src = "//ts:flatbuffers",
|
||||
)
|
||||
|
||||
exports_files([
|
||||
"LICENSE",
|
||||
"tsconfig.json",
|
||||
@@ -37,11 +28,16 @@ config_setting(
|
||||
filegroup(
|
||||
name = "distribution",
|
||||
srcs = [
|
||||
".bazelignore",
|
||||
".npmrc",
|
||||
"BUILD.bazel",
|
||||
"WORKSPACE",
|
||||
"MODULE.bazel",
|
||||
"build_defs.bzl",
|
||||
"package.json",
|
||||
"pnpm-lock.yaml",
|
||||
"typescript.bzl",
|
||||
"//grpc/src/compiler:distribution",
|
||||
"//include/codegen:distribution",
|
||||
"//reflection:distribution",
|
||||
"//src:distribution",
|
||||
"//ts:distribution",
|
||||
@@ -125,15 +121,7 @@ filegroup(
|
||||
# Library used by flatbuffer_cc_library rules.
|
||||
cc_library(
|
||||
name = "runtime_cc",
|
||||
hdrs = [
|
||||
"include/flatbuffers/base.h",
|
||||
"include/flatbuffers/flatbuffers.h",
|
||||
"include/flatbuffers/flexbuffers.h",
|
||||
"include/flatbuffers/stl_emulation.h",
|
||||
"include/flatbuffers/util.h",
|
||||
"include/flatbuffers/vector.h",
|
||||
"include/flatbuffers/verifier.h",
|
||||
],
|
||||
hdrs = ["//:public_headers"],
|
||||
linkstatic = 1,
|
||||
strip_include_prefix = "/include",
|
||||
)
|
||||
|
||||
24
CHANGELOG.md
@@ -4,6 +4,30 @@ All major or breaking changes will be documented in this file, as well as any
|
||||
new features that should be highlighted. Minor fixes or improvements are not
|
||||
necessarily listed.
|
||||
|
||||
## [25.1.24] (January 24 2024)(https://github.com/google/flatbuffers/releases/tag/v25.1.24))
|
||||
|
||||
* Mostly related to bazel build support.
|
||||
* Min bazel supported is now 7 or higher, as WORKSPACE files are removed (#8509)
|
||||
* Minor C++ codegen fix removing extra semicolon (#8488)
|
||||
|
||||
## [25.1.21] (January 21 2025)(https://github.com/google/flatbuffers/releases/tag/v25.1.21)
|
||||
|
||||
* Rust Full Reflection (#8102)
|
||||
* Mostly documentation updates hosted at https://flatbuffers.dev
|
||||
|
||||
## [24.3.25] (March 25 2024)(https://github.com/google/flatbuffers/releases/tag/v24.3.25)
|
||||
|
||||
* Fixed license metadata parsing (#8253)
|
||||
* [C++] Allow string_view in `LookUpByKey` in addition to null-terminated c-style strings (#8203)
|
||||
|
||||
## [24.3.7] (March 7 2024)(https://github.com/google/flatbuffers/releases/tag/v24.3.7)
|
||||
|
||||
* Just to fix some of the CI build issues from the 24.3.6 release.
|
||||
|
||||
## [24.3.6] (March 6 2024)(https://github.com/google/flatbuffers/releases/tag/v24.3.6)
|
||||
|
||||
* Fix typescript object API to allow 0 values for null-default scalars (#7864)
|
||||
|
||||
## [23.5.26 (May 26 2023)](https://github.com/google/flatbuffers/releases/tag/v23.5.26)
|
||||
|
||||
* Mostly bug fixing for 64-bit support
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
set(VERSION_MAJOR 23)
|
||||
set(VERSION_MINOR 5)
|
||||
set(VERSION_PATCH 26)
|
||||
set(VERSION_MAJOR 25)
|
||||
set(VERSION_MINOR 1)
|
||||
set(VERSION_PATCH 24)
|
||||
set(VERSION_COMMIT 0)
|
||||
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||
@@ -29,7 +29,7 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||
message(WARNING "\"${GIT_DESCRIBE_DIRTY}\" does not match pattern v<major>.<minor>.<patch>-<commit>")
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "git describe failed with exit code: ${GIT_DESCRIBE_RESULT}")
|
||||
message(WARNING "git describe failed with exit code: ${GIT_DESCRIBE_RESULT}\nMake sure you cloned with tags or run 'git fetch --tags'.")
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "git is not found")
|
||||
|
||||
@@ -160,6 +160,7 @@ set(FlatBuffers_Compiler_SRCS
|
||||
src/idl_gen_csharp.cpp
|
||||
src/idl_gen_dart.cpp
|
||||
src/idl_gen_kotlin.cpp
|
||||
src/idl_gen_kotlin_kmp.cpp
|
||||
src/idl_gen_go.cpp
|
||||
src/idl_gen_java.cpp
|
||||
src/idl_gen_ts.cpp
|
||||
@@ -182,6 +183,10 @@ set(FlatBuffers_Compiler_SRCS
|
||||
src/bfbs_gen_lua.h
|
||||
src/bfbs_gen_nim.h
|
||||
src/bfbs_namer.h
|
||||
include/codegen/idl_namer.h
|
||||
include/codegen/namer.h
|
||||
include/codegen/python.h
|
||||
include/codegen/python.cc
|
||||
include/flatbuffers/code_generators.h
|
||||
src/binary_annotator.h
|
||||
src/binary_annotator.cpp
|
||||
@@ -496,7 +501,7 @@ function(compile_schema SRC_FBS OPT OUT_GEN_FILE)
|
||||
${OPT}
|
||||
-o "${SRC_FBS_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
|
||||
DEPENDS flatc
|
||||
DEPENDS flatc ${SRC_FBS}
|
||||
COMMENT "flatc generation: `${SRC_FBS}` -> `${GEN_HEADER}`"
|
||||
)
|
||||
set(${OUT_GEN_FILE} ${GEN_HEADER} PARENT_SCOPE)
|
||||
@@ -531,16 +536,17 @@ if(FLATBUFFERS_BUILD_TESTS)
|
||||
# The flattest target needs some generated files
|
||||
SET(FLATC_OPT --cpp --gen-mutable --gen-object-api --reflect-names)
|
||||
SET(FLATC_OPT_COMP ${FLATC_OPT};--gen-compare)
|
||||
SET(FLATC_OPT_SCOPED_ENUMS ${FLATC_OPT_COMP};--scoped-enums)
|
||||
|
||||
compile_schema_for_test(tests/alignment_test.fbs "${FLATC_OPT_COMP}")
|
||||
compile_schema_for_test(tests/arrays_test.fbs "${FLATC_OPT_COMP};--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_type_test.fbs "${FLATC_OPT}")
|
||||
compile_schema_for_test(tests/key_field/key_field_sample.fbs "${FLATC_OPT_COMP}")
|
||||
compile_schema_for_test(tests/64bit/test_64bit.fbs "${FLATC_OPT_COMP};--bfbs-gen-embed")
|
||||
compile_schema_for_test(tests/64bit/evolution/v1.fbs "${FLATC_OPT_COMP}")
|
||||
compile_schema_for_test(tests/64bit/evolution/v2.fbs "${FLATC_OPT_COMP}")
|
||||
compile_schema_for_test(tests/union_underlying_type_test.fbs "${FLATC_OPT_COMP}")
|
||||
compile_schema_for_test(tests/union_underlying_type_test.fbs "${FLATC_OPT_SCOPED_ENUMS}")
|
||||
|
||||
if(FLATBUFFERS_CODE_SANITIZE)
|
||||
add_fsanitize_to_target(flattests ${FLATBUFFERS_CODE_SANITIZE})
|
||||
@@ -554,7 +560,11 @@ if(FLATBUFFERS_BUILD_TESTS)
|
||||
|
||||
# Add a library so there is a single target that the generated samples can
|
||||
# link too.
|
||||
add_library(flatsample INTERFACE)
|
||||
if(MSVC OR ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.20.0")
|
||||
add_library(flatsample INTERFACE)
|
||||
else()
|
||||
add_library(flatsample STATIC)
|
||||
endif()
|
||||
|
||||
# Since flatsample has no sources, we have to explicitly set the linker lang.
|
||||
set_target_properties(flatsample PROPERTIES LINKER_LANGUAGE CXX)
|
||||
@@ -592,7 +602,7 @@ if(FLATBUFFERS_BUILD_GRPCTEST)
|
||||
find_package(protobuf CONFIG REQUIRED)
|
||||
find_package(gRPC CONFIG REQUIRED)
|
||||
add_executable(grpctest ${FlatBuffers_GRPCTest_SRCS})
|
||||
target_link_libraries(grpctext
|
||||
target_link_libraries(grpctest
|
||||
PRIVATE
|
||||
$<BUILD_INTERFACE:ProjectConfig>
|
||||
gRPC::grpc++_unsecure
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'FlatBuffers'
|
||||
s.version = '23.5.26'
|
||||
s.version = '25.1.24'
|
||||
s.summary = 'FlatBuffers: Memory Efficient Serialization Library'
|
||||
|
||||
s.description = "FlatBuffers is a cross platform serialization library architected for
|
||||
@@ -10,12 +10,15 @@ Pod::Spec.new do |s|
|
||||
|
||||
s.homepage = 'https://github.com/google/flatbuffers'
|
||||
s.license = { :type => 'Apache2.0', :file => 'LICENSE' }
|
||||
s.author = { 'mustii' => 'mustii@mmk.one' }
|
||||
s.source = { :git => 'https://github.com/google/flatbuffers.git', :tag => s.version.to_s, :submodules => true }
|
||||
s.author = { 'mustii' => 'me@mustiikhalil.se' }
|
||||
s.source = { :git => 'https://github.com/google/flatbuffers.git', :tag => "v" + s.version.to_s, :submodules => true }
|
||||
|
||||
s.ios.deployment_target = '11.0'
|
||||
s.osx.deployment_target = '10.14'
|
||||
|
||||
s.swift_version = '5.0'
|
||||
s.source_files = 'swift/Sources/Flatbuffers/*.swift'
|
||||
s.pod_target_xcconfig = {
|
||||
'BUILD_LIBRARY_FOR_DISTRIBUTION' => 'YES'
|
||||
}
|
||||
end
|
||||
|
||||
73
MODULE.bazel
Normal file
@@ -0,0 +1,73 @@
|
||||
module(
|
||||
name = "flatbuffers",
|
||||
version = "25.1.24",
|
||||
compatibility_level = 1,
|
||||
repo_name = "com_github_google_flatbuffers",
|
||||
)
|
||||
|
||||
bazel_dep(
|
||||
name = "aspect_bazel_lib",
|
||||
version = "2.11.0",
|
||||
)
|
||||
bazel_dep(
|
||||
name = "aspect_rules_esbuild",
|
||||
version = "0.21.0",
|
||||
)
|
||||
bazel_dep(
|
||||
name = "aspect_rules_js",
|
||||
version = "2.1.3",
|
||||
)
|
||||
bazel_dep(
|
||||
name = "aspect_rules_ts",
|
||||
version = "3.4.0",
|
||||
)
|
||||
bazel_dep(
|
||||
name = "grpc",
|
||||
version = "1.69.0",
|
||||
repo_name = "com_github_grpc_grpc",
|
||||
)
|
||||
bazel_dep(
|
||||
name = "platforms",
|
||||
version = "0.0.10",
|
||||
)
|
||||
bazel_dep(
|
||||
name = "rules_cc",
|
||||
version = "0.0.16",
|
||||
)
|
||||
bazel_dep(
|
||||
name = "rules_go",
|
||||
version = "0.50.1",
|
||||
repo_name = "io_bazel_rules_go",
|
||||
)
|
||||
bazel_dep(
|
||||
name = "rules_nodejs",
|
||||
version = "6.3.3",
|
||||
)
|
||||
bazel_dep(
|
||||
name = "rules_swift",
|
||||
version = "1.18.0",
|
||||
repo_name = "build_bazel_rules_swift",
|
||||
)
|
||||
bazel_dep(
|
||||
name = "bazel_skylib",
|
||||
version = "1.7.1",
|
||||
)
|
||||
|
||||
npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")
|
||||
npm.npm_translate_lock(
|
||||
name = "flatbuffers_npm",
|
||||
npmrc = "//:.npmrc",
|
||||
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",
|
||||
)
|
||||
use_repo(npm, "flatbuffers_npm")
|
||||
|
||||
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
|
||||
use_repo(node, "nodejs_linux_amd64")
|
||||
|
||||
rules_ts_ext = use_extension("@aspect_rules_ts//ts:extensions.bzl", "ext")
|
||||
rules_ts_ext.deps()
|
||||
use_repo(rules_ts_ext, "npm_typescript")
|
||||
@@ -1,4 +1,4 @@
|
||||
// swift-tools-version:5.2
|
||||
// swift-tools-version:5.8
|
||||
/*
|
||||
* Copyright 2020 Google Inc. All rights reserved.
|
||||
*
|
||||
@@ -32,6 +32,5 @@ let package = Package(
|
||||
.target(
|
||||
name: "FlatBuffers",
|
||||
dependencies: [],
|
||||
path: "swift/Sources",
|
||||
exclude: ["Documentation.docc/Resources/code/swift"]),
|
||||
path: "swift/Sources"),
|
||||
])
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
// swift-tools-version:5.5
|
||||
/*
|
||||
* Copyright 2020 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "FlatBuffers",
|
||||
platforms: [
|
||||
.iOS(.v11),
|
||||
.macOS(.v10_14),
|
||||
],
|
||||
products: [
|
||||
.library(
|
||||
name: "FlatBuffers",
|
||||
targets: ["FlatBuffers"]),
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "FlatBuffers",
|
||||
dependencies: [],
|
||||
path: "swift/Sources"),
|
||||
])
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||

|
||||
[](https://buildkite.com/bazel/flatbuffers)
|
||||
[](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:flatbuffers)
|
||||
[](https://api.securityscorecards.dev/projects/github.com/google/flatbuffers)
|
||||
[](https://gitter.im/google/flatbuffers?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
[](https:///discord.gg/6qgKs3R)
|
||||
[](https://twitter.com/wvo)
|
||||
[](https://twitter.com/dbaileychess)
|
||||
@@ -18,7 +16,7 @@ maximum memory efficiency. It allows you to directly access serialized data with
|
||||
|
||||
1. Build the compiler for flatbuffers (`flatc`)
|
||||
|
||||
Use `cmake` to create the build files for your platform and then perform the compliation (Linux example).
|
||||
Use `cmake` to create the build files for your platform and then perform the compilation (Linux example).
|
||||
|
||||
```
|
||||
cmake -G "Unix Makefiles"
|
||||
@@ -98,10 +96,7 @@ FlatBuffers does not follow traditional SemVer versioning (see [rationale](https
|
||||
|
||||
## Community
|
||||
|
||||
* [FlatBuffers Google Group][] to discuss FlatBuffers with other developers and users.
|
||||
* [Discord Server](https:///discord.gg/6qgKs3R)
|
||||
* [Gitter](https://gitter.im/google/flatbuffers)
|
||||
|
||||
|
||||
## Security
|
||||
|
||||
|
||||
156
WORKSPACE
@@ -1,156 +0,0 @@
|
||||
workspace(name = "com_github_google_flatbuffers")
|
||||
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
|
||||
|
||||
http_archive(
|
||||
name = "platforms",
|
||||
sha256 = "379113459b0feaf6bfbb584a91874c065078aa673222846ac765f86661c27407",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.5/platforms-0.0.5.tar.gz",
|
||||
"https://github.com/bazelbuild/platforms/releases/download/0.0.5/platforms-0.0.5.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "build_bazel_rules_swift",
|
||||
sha256 = "a2fd565e527f83fb3f9eb07eb9737240e668c9242d3bc318712efa54a7deda97",
|
||||
url = "https://github.com/bazelbuild/rules_swift/releases/download/0.27.0/rules_swift.0.27.0.tar.gz",
|
||||
)
|
||||
|
||||
load(
|
||||
"@build_bazel_rules_swift//swift:repositories.bzl",
|
||||
"swift_rules_dependencies",
|
||||
)
|
||||
|
||||
swift_rules_dependencies()
|
||||
|
||||
load(
|
||||
"@build_bazel_rules_swift//swift:extras.bzl",
|
||||
"swift_rules_extra_dependencies",
|
||||
)
|
||||
|
||||
swift_rules_extra_dependencies()
|
||||
|
||||
http_archive(
|
||||
name = "io_bazel_rules_go",
|
||||
sha256 = "ae013bf35bd23234d1dea46b079f1e05ba74ac0321423830119d3e787ec73483",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.36.0/rules_go-v0.36.0.zip",
|
||||
"https://github.com/bazelbuild/rules_go/releases/download/v0.36.0/rules_go-v0.36.0.zip",
|
||||
],
|
||||
)
|
||||
|
||||
load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies")
|
||||
|
||||
go_rules_dependencies()
|
||||
|
||||
##### Protobuf
|
||||
_PROTOBUF_VERSION = "3.15.2"
|
||||
|
||||
http_archive(
|
||||
name = "com_google_protobuf",
|
||||
strip_prefix = "protobuf-" + _PROTOBUF_VERSION,
|
||||
urls = [
|
||||
"https://github.com/protocolbuffers/protobuf/archive/v" + _PROTOBUF_VERSION + ".tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
##### GRPC
|
||||
_GRPC_VERSION = "1.49.0" # https://github.com/grpc/grpc/releases/tag/v1.48.0
|
||||
|
||||
http_archive(
|
||||
name = "com_github_grpc_grpc",
|
||||
patch_args = ["-p1"],
|
||||
patches = ["//grpc:build_grpc_with_cxx14.patch"],
|
||||
sha256 = "15715e1847cc9e42014f02c727dbcb48e39dbdb90f79ad3d66fe4361709ff935",
|
||||
strip_prefix = "grpc-" + _GRPC_VERSION,
|
||||
urls = ["https://github.com/grpc/grpc/archive/refs/tags/v" + _GRPC_VERSION + ".tar.gz"],
|
||||
)
|
||||
|
||||
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
|
||||
|
||||
grpc_deps()
|
||||
|
||||
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
|
||||
|
||||
grpc_extra_deps()
|
||||
|
||||
# rules_go from https://github.com/bazelbuild/rules_go/releases/tag/v0.34.0
|
||||
|
||||
http_archive(
|
||||
name = "aspect_rules_js",
|
||||
sha256 = "124ed29fb0b3d0cba5b44f8f8e07897cf61b34e35e33b1f83d1a943dfd91b193",
|
||||
strip_prefix = "rules_js-1.24.0",
|
||||
url = "https://github.com/aspect-build/rules_js/releases/download/v1.24.0/rules_js-v1.24.0.tar.gz",
|
||||
)
|
||||
|
||||
load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")
|
||||
|
||||
rules_js_dependencies()
|
||||
|
||||
load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock", "pnpm_repository")
|
||||
|
||||
pnpm_repository(name = "pnpm")
|
||||
|
||||
http_archive(
|
||||
name = "aspect_rules_ts",
|
||||
sha256 = "8eb25d1fdafc0836f5778d33fb8eaac37c64176481d67872b54b0a05de5be5c0",
|
||||
strip_prefix = "rules_ts-1.3.3",
|
||||
url = "https://github.com/aspect-build/rules_ts/releases/download/v1.3.3/rules_ts-v1.3.3.tar.gz",
|
||||
)
|
||||
|
||||
load("@aspect_rules_ts//ts:repositories.bzl", "rules_ts_dependencies")
|
||||
|
||||
rules_ts_dependencies(
|
||||
# Since rules_ts doesn't always have the newest integrity hashes, we
|
||||
# compute it manually here.
|
||||
# $ curl --silent https://registry.npmjs.org/typescript/5.0.4 | jq ._integrity
|
||||
ts_integrity = "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==",
|
||||
ts_version_from = "//:package.json",
|
||||
)
|
||||
|
||||
load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains")
|
||||
|
||||
nodejs_register_toolchains(
|
||||
name = "nodejs",
|
||||
node_version = DEFAULT_NODE_VERSION,
|
||||
)
|
||||
|
||||
npm_translate_lock(
|
||||
name = "npm",
|
||||
npmrc = "//:.npmrc",
|
||||
pnpm_lock = "//:pnpm-lock.yaml",
|
||||
# Set this to True when the lock file needs to be updated, commit the
|
||||
# changes, then set to False again.
|
||||
update_pnpm_lock = False,
|
||||
verify_node_modules_ignored = "//:.bazelignore",
|
||||
)
|
||||
|
||||
load("@npm//:repositories.bzl", "npm_repositories")
|
||||
|
||||
npm_repositories()
|
||||
|
||||
http_archive(
|
||||
name = "aspect_rules_esbuild",
|
||||
sha256 = "2ea31bd97181a315e048be693ddc2815fddda0f3a12ca7b7cc6e91e80f31bac7",
|
||||
strip_prefix = "rules_esbuild-0.14.4",
|
||||
url = "https://github.com/aspect-build/rules_esbuild/releases/download/v0.14.4/rules_esbuild-v0.14.4.tar.gz",
|
||||
)
|
||||
|
||||
# Register a toolchain containing esbuild npm package and native bindings
|
||||
load("@aspect_rules_esbuild//esbuild:repositories.bzl", "LATEST_VERSION", "esbuild_register_toolchains")
|
||||
|
||||
esbuild_register_toolchains(
|
||||
name = "esbuild",
|
||||
esbuild_version = LATEST_VERSION,
|
||||
)
|
||||
|
||||
http_file(
|
||||
name = "bazel_linux_x86_64",
|
||||
downloaded_file_path = "bazel",
|
||||
executable = True,
|
||||
sha256 = "e89747d63443e225b140d7d37ded952dacea73aaed896bca01ccd745827c6289",
|
||||
urls = [
|
||||
"https://github.com/bazelbuild/bazel/releases/download/6.1.2/bazel-6.1.2-linux-x86_64",
|
||||
],
|
||||
)
|
||||
@@ -10,7 +10,7 @@
|
||||
</natures>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1677235311958</id>
|
||||
<id>1672434305228</id>
|
||||
<name></name>
|
||||
<type>30</type>
|
||||
<matcher>
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
|
||||
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||
// generated, otherwise it may not be compatible.
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 23 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 1 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 21,
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 24 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 23,
|
||||
"Non-compatible flatbuffers version included");
|
||||
|
||||
namespace com {
|
||||
|
||||
@@ -57,7 +57,7 @@ class Animal : Table() {
|
||||
return if(o != 0) bb.getShort(o + bb_pos).toUShort() else 0u
|
||||
}
|
||||
companion object {
|
||||
fun validateVersion() = Constants.FLATBUFFERS_23_5_26()
|
||||
fun validateVersion() = Constants.FLATBUFFERS_25_1_24()
|
||||
fun getRootAsAnimal(_bb: ByteBuffer): Animal = getRootAsAnimal(_bb, Animal())
|
||||
fun getRootAsAnimal(_bb: ByteBuffer, obj: Animal): Animal {
|
||||
_bb.order(ByteOrder.LITTLE_ENDIAN)
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
|
||||
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||
// generated, otherwise it may not be compatible.
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 2 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 0 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 6,
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 24 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 23,
|
||||
"Non-compatible flatbuffers version included");
|
||||
|
||||
namespace benchmarks_flatbuffers {
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
* Copyright 2024 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import Benchmark
|
||||
import CoreFoundation
|
||||
import FlatBuffers
|
||||
|
||||
@usableFromInline
|
||||
struct AA: NativeStruct {
|
||||
public init(a: Double, b: Double) {
|
||||
self.a = a
|
||||
self.b = b
|
||||
}
|
||||
var a: Double
|
||||
var b: Double
|
||||
}
|
||||
|
||||
let benchmarks = {
|
||||
let ints: [Int] = Array(repeating: 42, count: 100)
|
||||
let bytes: [UInt8] = Array(repeating: 42, count: 100)
|
||||
let str10 = (0...9).map { _ -> String in "x" }.joined()
|
||||
let str100 = (0...99).map { _ -> String in "x" }.joined()
|
||||
let array: [AA] = [
|
||||
AA(a: 2.4, b: 2.4),
|
||||
AA(a: 2.4, b: 2.4),
|
||||
AA(a: 2.4, b: 2.4),
|
||||
AA(a: 2.4, b: 2.4),
|
||||
AA(a: 2.4, b: 2.4),
|
||||
]
|
||||
|
||||
let metrics: [BenchmarkMetric] = [
|
||||
.cpuTotal,
|
||||
.wallClock,
|
||||
.mallocCountTotal,
|
||||
.releaseCount,
|
||||
.peakMemoryResident,
|
||||
]
|
||||
let maxIterations = 1_000_000
|
||||
let maxDuration: Duration = .seconds(3)
|
||||
let singleConfiguration: Benchmark.Configuration = .init(
|
||||
metrics: metrics,
|
||||
warmupIterations: 1,
|
||||
scalingFactor: .one,
|
||||
maxDuration: maxDuration,
|
||||
maxIterations: maxIterations)
|
||||
let kiloConfiguration: Benchmark.Configuration = .init(
|
||||
metrics: metrics,
|
||||
warmupIterations: 1,
|
||||
scalingFactor: .kilo,
|
||||
maxDuration: maxDuration,
|
||||
maxIterations: maxIterations)
|
||||
let megaConfiguration: Benchmark.Configuration = .init(
|
||||
metrics: metrics,
|
||||
warmupIterations: 1,
|
||||
scalingFactor: .mega,
|
||||
maxDuration: maxDuration,
|
||||
maxIterations: maxIterations)
|
||||
|
||||
Benchmark.defaultConfiguration = megaConfiguration
|
||||
|
||||
Benchmark("Allocating 1GB", configuration: singleConfiguration) { benchmark in
|
||||
for _ in benchmark.scaledIterations {
|
||||
blackHole(FlatBufferBuilder(initialSize: 1_024_000_000))
|
||||
}
|
||||
}
|
||||
|
||||
Benchmark("Clearing 1GB", configuration: singleConfiguration) { benchmark in
|
||||
var fb = FlatBufferBuilder(initialSize: 1_024_000_000)
|
||||
benchmark.startMeasurement()
|
||||
for _ in benchmark.scaledIterations {
|
||||
blackHole(fb.clear())
|
||||
}
|
||||
}
|
||||
|
||||
Benchmark("Strings 10") { benchmark in
|
||||
var fb = FlatBufferBuilder(initialSize: 1<<20)
|
||||
benchmark.startMeasurement()
|
||||
for _ in benchmark.scaledIterations {
|
||||
blackHole(fb.create(string: str10))
|
||||
}
|
||||
}
|
||||
|
||||
Benchmark("Strings 100") { benchmark in
|
||||
var fb = FlatBufferBuilder(initialSize: 1<<20)
|
||||
benchmark.startMeasurement()
|
||||
for _ in benchmark.scaledIterations {
|
||||
blackHole(fb.create(string: str100))
|
||||
}
|
||||
}
|
||||
|
||||
Benchmark("Vector 1 Bytes") { benchmark in
|
||||
var fb = FlatBufferBuilder(initialSize: 1<<20)
|
||||
benchmark.startMeasurement()
|
||||
for _ in benchmark.scaledIterations {
|
||||
blackHole(fb.createVector(bytes: bytes))
|
||||
}
|
||||
}
|
||||
|
||||
Benchmark("Vector 1 Ints") { benchmark in
|
||||
var fb = FlatBufferBuilder(initialSize: 1<<20)
|
||||
benchmark.startMeasurement()
|
||||
for _ in benchmark.scaledIterations {
|
||||
blackHole(fb.createVector(ints))
|
||||
}
|
||||
}
|
||||
|
||||
Benchmark("Vector 100 Ints") { benchmark in
|
||||
var fb = FlatBufferBuilder(initialSize: 1<<20)
|
||||
benchmark.startMeasurement()
|
||||
for i in benchmark.scaledIterations {
|
||||
blackHole(fb.createVector(ints))
|
||||
}
|
||||
}
|
||||
|
||||
Benchmark("Vector 100 Bytes") { benchmark in
|
||||
var fb = FlatBufferBuilder(initialSize: 1<<20)
|
||||
benchmark.startMeasurement()
|
||||
for i in benchmark.scaledIterations {
|
||||
blackHole(fb.createVector(bytes))
|
||||
}
|
||||
}
|
||||
|
||||
Benchmark("Vector 100 ContiguousBytes") { benchmark in
|
||||
var fb = FlatBufferBuilder(initialSize: 1<<20)
|
||||
benchmark.startMeasurement()
|
||||
for i in benchmark.scaledIterations {
|
||||
blackHole(fb.createVector(bytes: bytes))
|
||||
}
|
||||
}
|
||||
|
||||
Benchmark(
|
||||
"FlatBufferBuilder Add",
|
||||
configuration: kiloConfiguration)
|
||||
{ benchmark in
|
||||
var fb = FlatBufferBuilder(initialSize: 1024 * 1024 * 32)
|
||||
benchmark.startMeasurement()
|
||||
for _ in benchmark.scaledIterations {
|
||||
let off = fb.create(string: "T")
|
||||
let s = fb.startTable(with: 4)
|
||||
fb.add(element: 3.2, def: 0, at: 2)
|
||||
fb.add(element: 4.2, def: 0, at: 4)
|
||||
fb.add(element: 5.2, def: 0, at: 6)
|
||||
fb.add(offset: off, at: 8)
|
||||
blackHole(fb.endTable(at: s))
|
||||
}
|
||||
}
|
||||
|
||||
Benchmark("Structs") { benchmark in
|
||||
let rawSize = ((16 * 5) * benchmark.scaledIterations.count) / 1024
|
||||
var fb = FlatBufferBuilder(initialSize: Int32(rawSize * 1600))
|
||||
var offsets: [Offset] = []
|
||||
|
||||
benchmark.startMeasurement()
|
||||
for _ in benchmark.scaledIterations {
|
||||
let vector = fb.createVector(
|
||||
ofStructs: array)
|
||||
let start = fb.startTable(with: 1)
|
||||
fb.add(offset: vector, at: 4)
|
||||
offsets.append(Offset(offset: fb.endTable(at: start)))
|
||||
}
|
||||
|
||||
let vector = fb.createVector(ofOffsets: offsets)
|
||||
let start = fb.startTable(with: 1)
|
||||
fb.add(offset: vector, at: 4)
|
||||
let root = Offset(offset: fb.endTable(at: start))
|
||||
fb.finish(offset: root)
|
||||
}
|
||||
|
||||
Benchmark("Vector of Offsets") { benchmark in
|
||||
let rawSize = ((16 * 5) * benchmark.scaledIterations.count) / 1024
|
||||
var fb = FlatBufferBuilder(initialSize: Int32(rawSize * 1600))
|
||||
benchmark.startMeasurement()
|
||||
for _ in benchmark.scaledIterations {
|
||||
let offsets = [
|
||||
fb.create(string: "T"),
|
||||
fb.create(string: "2"),
|
||||
fb.create(string: "3"),
|
||||
]
|
||||
let off = fb.createVector(ofOffsets: [
|
||||
fb.createVector(ofOffsets: offsets),
|
||||
fb.createVector(ofOffsets: offsets),
|
||||
])
|
||||
let s = fb.startTable(with: 2)
|
||||
fb.add(offset: off, at: 2)
|
||||
blackHole(fb.endTable(at: s))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// swift-tools-version:5.1
|
||||
// swift-tools-version:5.8
|
||||
/*
|
||||
* Copyright 2020 Google Inc. All rights reserved.
|
||||
*
|
||||
@@ -20,15 +20,23 @@ import PackageDescription
|
||||
let package = Package(
|
||||
name: "benchmarks",
|
||||
platforms: [
|
||||
.macOS(.v10_14),
|
||||
.macOS(.v13),
|
||||
],
|
||||
dependencies: [
|
||||
.package(path: "../../.."),
|
||||
.package(url: "https://github.com/google/swift-benchmark", from: "0.1.0"),
|
||||
.package(path: "../.."),
|
||||
.package(
|
||||
url: "https://github.com/ordo-one/package-benchmark",
|
||||
from: "1.27.0"),
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "benchmarks",
|
||||
dependencies: ["FlatBuffers",
|
||||
.product(name: "Benchmark", package: "swift-benchmark")]),
|
||||
.executableTarget(
|
||||
name: "FlatbuffersBenchmarks",
|
||||
dependencies: [
|
||||
.product(name: "FlatBuffers", package: "flatbuffers"),
|
||||
.product(name: "Benchmark", package: "package-benchmark"),
|
||||
],
|
||||
path: "Benchmarks/FlatbuffersBenchmarks",
|
||||
plugins: [
|
||||
.plugin(name: "BenchmarkPlugin", package: "package-benchmark"),
|
||||
]),
|
||||
])
|
||||
9
benchmarks/swift/README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# Benchmarks
|
||||
|
||||
To open the benchmarks in xcode use:
|
||||
|
||||
`open --env BENCHMARK_DISABLE_JEMALLOC=true Package.swift`
|
||||
|
||||
or running them directly within terminal using:
|
||||
|
||||
`swift package benchmark`
|
||||
@@ -7,13 +7,13 @@ Rules for building C++ flatbuffers with Bazel.
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library")
|
||||
|
||||
TRUE_FLATC_PATH = "@com_github_google_flatbuffers//:flatc"
|
||||
TRUE_FLATC_PATH = Label("//:flatc")
|
||||
|
||||
DEFAULT_INCLUDE_PATHS = [
|
||||
"./",
|
||||
"$(GENDIR)",
|
||||
"$(BINDIR)",
|
||||
"$(execpath @com_github_google_flatbuffers//:flatc).runfiles/com_github_google_flatbuffers",
|
||||
"$(execpath %s).runfiles/%s" % (TRUE_FLATC_PATH, TRUE_FLATC_PATH.repo_name),
|
||||
]
|
||||
|
||||
def default_include_paths(flatc_path):
|
||||
@@ -21,7 +21,7 @@ def default_include_paths(flatc_path):
|
||||
"./",
|
||||
"$(GENDIR)",
|
||||
"$(BINDIR)",
|
||||
"$(execpath %s).runfiles/com_github_google_flatbuffers" % (flatc_path),
|
||||
"$(execpath %s).runfiles/%s" % (flatc_path, flatc_path.repo_name),
|
||||
]
|
||||
|
||||
DEFAULT_FLATC_ARGS = [
|
||||
@@ -47,7 +47,7 @@ def flatbuffer_library_public(
|
||||
compatible_with = None,
|
||||
restricted_to = None,
|
||||
target_compatible_with = None,
|
||||
flatc_path = "@com_github_google_flatbuffers//:flatc",
|
||||
flatc_path = None,
|
||||
output_to_bindir = False,
|
||||
tools = None,
|
||||
extra_env = None,
|
||||
@@ -87,6 +87,12 @@ def flatbuffer_library_public(
|
||||
optionally a Fileset([reflection_name]) with all generated reflection
|
||||
binaries.
|
||||
"""
|
||||
if flatc_path == None:
|
||||
flatc_path = TRUE_FLATC_PATH
|
||||
else:
|
||||
flatc_path = native.package_relative_label(flatc_path)
|
||||
|
||||
reflection_include_paths = include_paths
|
||||
if include_paths == None:
|
||||
include_paths = default_include_paths(flatc_path)
|
||||
include_paths_cmd = ["-I %s" % (s) for s in include_paths]
|
||||
@@ -124,22 +130,28 @@ def flatbuffer_library_public(
|
||||
**kwargs
|
||||
)
|
||||
if reflection_name:
|
||||
if reflection_include_paths == None:
|
||||
reflection_include_paths = default_include_paths(TRUE_FLATC_PATH)
|
||||
reflection_include_paths_cmd = ["-I %s" % (s) for s in reflection_include_paths]
|
||||
reflection_genrule_cmd = " ".join([
|
||||
"SRCS=($(SRCS));",
|
||||
"for f in $${SRCS[@]:0:%s}; do" % len(srcs),
|
||||
# Move the .fbs file into the current package if it is not there already
|
||||
'if [[ $$(dirname $$f) != "{0}" ]]; then s="$$f"; f="{0}/$$(basename "$$f")"; mkdir -p "{0}"; mv "$$s" "$$f"; fi;'.format(native.package_relative_label(":invalid").package),
|
||||
"$(location %s)" % (TRUE_FLATC_PATH),
|
||||
"-b --schema",
|
||||
" ".join(flatc_args),
|
||||
" ".join(include_paths_cmd),
|
||||
" ".join(reflection_include_paths_cmd),
|
||||
language_flag,
|
||||
output_directory,
|
||||
"$$f;",
|
||||
"done",
|
||||
])
|
||||
reflection_outs = [
|
||||
(out_prefix + "%s.bfbs") % (s.replace(".fbs", "").split("/")[-1])
|
||||
(out_prefix + "%s.bfbs") % (native.package_relative_label(s).name.removesuffix(".fbs"))
|
||||
for s in srcs
|
||||
]
|
||||
|
||||
native.genrule(
|
||||
name = "%s_srcs" % reflection_name,
|
||||
srcs = srcs + includes,
|
||||
@@ -258,8 +270,8 @@ def flatbuffer_cc_library(
|
||||
"-parse_headers",
|
||||
],
|
||||
deps = [
|
||||
"@com_github_google_flatbuffers//:runtime_cc",
|
||||
"@com_github_google_flatbuffers//:flatbuffers",
|
||||
Label("//:runtime_cc"),
|
||||
Label("//:flatbuffers"),
|
||||
] + deps,
|
||||
includes = cc_include_paths,
|
||||
compatible_with = compatible_with,
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
# Changelog
|
||||
|
||||
## 23.5.26
|
||||
|
||||
- omit type annotationes for local variables (#7067, #7069, #7070)
|
||||
- remove BSD 3-clause license (#7073)
|
||||
- correctly parse lists of enums (#7157)
|
||||
- align naming conventions for generated code (#7187)
|
||||
- add `putBool` to fix errors when serializing structs with booleans (#7359)
|
||||
- fix handling of +/-inf defaults in codegen (#7588)
|
||||
- fix import issues in generated code (#7621)
|
||||
- Fix incorrect storage of floats as ints in some cases (#7703)
|
||||
- add final modifiers to the library implementation (#7943)
|
||||
|
||||
## 2.0.5
|
||||
|
||||
- switch to null safety (#6696)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
This package is used to read and write [FlatBuffers](https://google.github.io/flatbuffers/).
|
||||
|
||||
Most consumers will want to use the [`flatc` - FlatBuffer compiler](https://github.com/google/flatbuffers) binary for your platform.
|
||||
You can find it in the `generator/{Platform}` directory of the [released package archive](https://pub.dev/packages/flat_buffers/versions/2.0.5.tar.gz).
|
||||
You can download the flatc version matching your dart package version from [GitHub releases](https://github.com/google/flatbuffers/releases).
|
||||
|
||||
The FlatBuffer compiler `flatc` reads a FlatBuffers IDL schema and generates Dart code.
|
||||
The generated classes can be used to read or write binary data/files that are interoperable with
|
||||
@@ -13,11 +13,3 @@ examples folder.
|
||||
For more details and documentation, head over to the official site and read the
|
||||
[Tutorial](https://google.github.io/flatbuffers/flatbuffers_guide_tutorial.html) and how to
|
||||
[use FlatBuffers in Dart](https://google.github.io/flatbuffers/flatbuffers_guide_use_dart.html).
|
||||
|
||||
## Dart 2.0 notes
|
||||
Version 2.0.5 ships with it's own custom build of `flatc` because this is an extraordinary release to catch-up
|
||||
with FlatBuffers for other platforms. This generator can only generate dart code (to avoid generating code for other platforms which isn't released yet).
|
||||
On the other hand, the generated code still produces standard binary FlatBuffers compatible with other languages.
|
||||
In other words: only `flatc --dart ...` works with this generator, but your app will be able to produce and read standard binary (`Uint8List`) FlatBuffers that are fully compotible with other languages supporting FlatBuffers (e.g. Java, C++, ...).
|
||||
|
||||
In the future a common `flatc` binary for all platforms would be shipped through GitHub release page instead.
|
||||
|
||||
@@ -386,7 +386,7 @@ class Builder {
|
||||
/// Updates the [offset] pointer. This method is intended for use when writing structs to the buffer.
|
||||
void putFloat64(double value) {
|
||||
_prepare(_sizeofFloat64, 1);
|
||||
_setFloat32AtTail(_tail, value);
|
||||
_setFloat64AtTail(_tail, value);
|
||||
}
|
||||
|
||||
/// Writes a Float32 to the tail of the buffer after preparing space for it.
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
name: flat_buffers
|
||||
version: 23.5.26
|
||||
version: 25.1.24
|
||||
description: FlatBuffers reading and writing library for Dart. Based on original work by Konstantin Scheglov and Paul Berry of the Dart SDK team.
|
||||
homepage: https://github.com/google/flatbuffers
|
||||
documentation: https://google.github.io/flatbuffers/index.html
|
||||
|
||||
environment:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
sdk: '>=2.17.0 <4.0.0'
|
||||
|
||||
dev_dependencies:
|
||||
test: ^1.17.7
|
||||
test_reflective_loader: ^0.2.0
|
||||
path: ^1.8.0
|
||||
lints: ^1.0.1
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable
|
||||
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable, constant_identifier_names
|
||||
|
||||
import 'dart:typed_data' show Uint8List;
|
||||
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||
|
||||
@@ -1,43 +1,33 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable
|
||||
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable, constant_identifier_names
|
||||
|
||||
import 'dart:typed_data' show Uint8List;
|
||||
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||
|
||||
|
||||
class OptionsEnum {
|
||||
enum OptionsEnum {
|
||||
A(1),
|
||||
B(2),
|
||||
C(3);
|
||||
|
||||
final int value;
|
||||
const OptionsEnum._(this.value);
|
||||
const OptionsEnum(this.value);
|
||||
|
||||
factory OptionsEnum.fromValue(int value) {
|
||||
final result = values[value];
|
||||
if (result == null) {
|
||||
throw StateError('Invalid value $value for bit flag enum OptionsEnum');
|
||||
switch (value) {
|
||||
case 1: return OptionsEnum.A;
|
||||
case 2: return OptionsEnum.B;
|
||||
case 3: return OptionsEnum.C;
|
||||
default: throw StateError('Invalid value $value for bit flag enum');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static OptionsEnum? _createOrNull(int? value) =>
|
||||
static OptionsEnum? _createOrNull(int? value) =>
|
||||
value == null ? null : OptionsEnum.fromValue(value);
|
||||
|
||||
static const int minValue = 1;
|
||||
static const int maxValue = 3;
|
||||
static bool containsValue(int value) => values.containsKey(value);
|
||||
|
||||
static const OptionsEnum A = OptionsEnum._(1);
|
||||
static const OptionsEnum B = OptionsEnum._(2);
|
||||
static const OptionsEnum C = OptionsEnum._(3);
|
||||
static const Map<int, OptionsEnum> values = {
|
||||
1: A,
|
||||
2: B,
|
||||
3: C};
|
||||
|
||||
static const fb.Reader<OptionsEnum> reader = _OptionsEnumReader();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OptionsEnum{value: $value}';
|
||||
}
|
||||
}
|
||||
|
||||
class _OptionsEnumReader extends fb.Reader<OptionsEnum> {
|
||||
@@ -9,9 +9,8 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import './monster_test_my_game.example_generated.dart' as example;
|
||||
import './monster_test_my_game.example2_generated.dart' as example2;
|
||||
import './list_of_enums_generated.dart' as example3;
|
||||
import 'enums_generated.dart' as example3;
|
||||
import './bool_structs_generated.dart' as example4;
|
||||
import './keyword_test_keyword_test_generated.dart' as keyword_test;
|
||||
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
@@ -62,92 +61,91 @@ class CheckOtherLangaugesData {
|
||||
|
||||
// this will fail if accessing any field fails.
|
||||
expect(
|
||||
mon.toString(),
|
||||
'Monster{'
|
||||
'pos: Vec3{x: 1.0, y: 2.0, z: 3.0, test1: 3.0, test2: Color{value: 2}, test3: Test{a: 5, b: 6}}, '
|
||||
'mana: 150, hp: 80, name: MyMonster, inventory: [0, 1, 2, 3, 4], '
|
||||
'color: Color{value: 8}, testType: AnyTypeId{value: 1}, '
|
||||
'test: Monster{pos: null, mana: 150, hp: 100, name: Fred, '
|
||||
'inventory: null, color: Color{value: 8}, testType: null, '
|
||||
'test: null, test4: null, testarrayofstring: null, '
|
||||
'testarrayoftables: null, enemy: null, testnestedflatbuffer: null, '
|
||||
'testempty: null, testbool: false, testhashs32Fnv1: 0, '
|
||||
'testhashu32Fnv1: 0, testhashs64Fnv1: 0, testhashu64Fnv1: 0, '
|
||||
'testhashs32Fnv1a: 0, testhashu32Fnv1a: 0, testhashs64Fnv1a: 0, '
|
||||
'testhashu64Fnv1a: 0, testarrayofbools: null, testf: 3.14159, '
|
||||
'testf2: 3.0, testf3: 0.0, testarrayofstring2: null, '
|
||||
'testarrayofsortedstruct: null, flex: null, test5: null, '
|
||||
'vectorOfLongs: null, vectorOfDoubles: null, parentNamespaceTest: null, '
|
||||
'vectorOfReferrables: null, singleWeakReference: 0, '
|
||||
'vectorOfWeakReferences: null, vectorOfStrongReferrables: null, '
|
||||
'coOwningReference: 0, vectorOfCoOwningReferences: null, '
|
||||
'nonOwningReference: 0, vectorOfNonOwningReferences: null, '
|
||||
'anyUniqueType: null, anyUnique: null, anyAmbiguousType: null, '
|
||||
'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race{value: -1}, '
|
||||
'testrequirednestedflatbuffer: null, scalarKeySortedTables: null, '
|
||||
'nativeInline: null, '
|
||||
'longEnumNonEnumDefault: LongEnum{value: 0}, '
|
||||
'longEnumNormalDefault: LongEnum{value: 2}, nanDefault: NaN, '
|
||||
'infDefault: Infinity, positiveInfDefault: Infinity, infinityDefault: '
|
||||
'Infinity, positiveInfinityDefault: Infinity, negativeInfDefault: '
|
||||
'-Infinity, negativeInfinityDefault: -Infinity, doubleInfDefault: Infinity}, '
|
||||
'test4: [Test{a: 10, b: 20}, Test{a: 30, b: 40}], '
|
||||
'testarrayofstring: [test1, test2], testarrayoftables: null, '
|
||||
'enemy: Monster{pos: null, mana: 150, hp: 100, name: Fred, '
|
||||
'inventory: null, color: Color{value: 8}, testType: null, '
|
||||
'test: null, test4: null, testarrayofstring: null, '
|
||||
'testarrayoftables: null, enemy: null, testnestedflatbuffer: null, '
|
||||
'testempty: null, testbool: false, testhashs32Fnv1: 0, '
|
||||
'testhashu32Fnv1: 0, testhashs64Fnv1: 0, testhashu64Fnv1: 0, '
|
||||
'testhashs32Fnv1a: 0, testhashu32Fnv1a: 0, testhashs64Fnv1a: 0, '
|
||||
'testhashu64Fnv1a: 0, testarrayofbools: null, testf: 3.14159, '
|
||||
'testf2: 3.0, testf3: 0.0, testarrayofstring2: null, '
|
||||
'testarrayofsortedstruct: null, flex: null, test5: null, '
|
||||
'vectorOfLongs: null, vectorOfDoubles: null, parentNamespaceTest: null, '
|
||||
'vectorOfReferrables: null, singleWeakReference: 0, '
|
||||
'vectorOfWeakReferences: null, vectorOfStrongReferrables: null, '
|
||||
'coOwningReference: 0, vectorOfCoOwningReferences: null, '
|
||||
'nonOwningReference: 0, vectorOfNonOwningReferences: null, '
|
||||
'anyUniqueType: null, anyUnique: null, anyAmbiguousType: null, '
|
||||
'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race{value: -1}, '
|
||||
'testrequirednestedflatbuffer: null, scalarKeySortedTables: null, '
|
||||
'nativeInline: null, '
|
||||
'longEnumNonEnumDefault: LongEnum{value: 0}, '
|
||||
'longEnumNormalDefault: LongEnum{value: 2}, nanDefault: NaN, '
|
||||
'infDefault: Infinity, positiveInfDefault: Infinity, infinityDefault: '
|
||||
'Infinity, positiveInfinityDefault: Infinity, negativeInfDefault: '
|
||||
'-Infinity, negativeInfinityDefault: -Infinity, doubleInfDefault: Infinity}, '
|
||||
'testnestedflatbuffer: null, testempty: null, testbool: true, '
|
||||
'testhashs32Fnv1: -579221183, testhashu32Fnv1: 3715746113, '
|
||||
'testhashs64Fnv1: 7930699090847568257, '
|
||||
'testhashu64Fnv1: 7930699090847568257, '
|
||||
'testhashs32Fnv1a: -1904106383, testhashu32Fnv1a: 2390860913, '
|
||||
'testhashs64Fnv1a: 4898026182817603057, '
|
||||
'testhashu64Fnv1a: 4898026182817603057, '
|
||||
'testarrayofbools: [true, false, true], testf: 3.14159, testf2: 3.0, '
|
||||
'testf3: 0.0, testarrayofstring2: null, testarrayofsortedstruct: ['
|
||||
'Ability{id: 0, distance: 45}, Ability{id: 1, distance: 21}, '
|
||||
'Ability{id: 5, distance: 12}], '
|
||||
'flex: null, test5: [Test{a: 10, b: 20}, Test{a: 30, b: 40}], '
|
||||
'vectorOfLongs: [1, 100, 10000, 1000000, 100000000], '
|
||||
'vectorOfDoubles: [-1.7976931348623157e+308, 0.0, 1.7976931348623157e+308], '
|
||||
'parentNamespaceTest: null, vectorOfReferrables: null, '
|
||||
'singleWeakReference: 0, vectorOfWeakReferences: null, '
|
||||
'vectorOfStrongReferrables: null, coOwningReference: 0, '
|
||||
'vectorOfCoOwningReferences: null, nonOwningReference: 0, '
|
||||
'vectorOfNonOwningReferences: null, '
|
||||
'anyUniqueType: null, anyUnique: null, '
|
||||
'anyAmbiguousType: null, '
|
||||
'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race{value: -1}, '
|
||||
'testrequirednestedflatbuffer: null, scalarKeySortedTables: [Stat{id: '
|
||||
'miss, val: 0, count: 0}, Stat{id: hit, val: 10, count: 1}], '
|
||||
'nativeInline: Test{a: 1, b: 2}, '
|
||||
'longEnumNonEnumDefault: LongEnum{value: 0}, '
|
||||
'longEnumNormalDefault: LongEnum{value: 2}, nanDefault: NaN, '
|
||||
'infDefault: Infinity, positiveInfDefault: Infinity, infinityDefault: '
|
||||
'Infinity, positiveInfinityDefault: Infinity, negativeInfDefault: '
|
||||
'-Infinity, negativeInfinityDefault: -Infinity, doubleInfDefault: Infinity}'
|
||||
);
|
||||
mon.toString(),
|
||||
'Monster{'
|
||||
'pos: Vec3{x: 1.0, y: 2.0, z: 3.0, test1: 3.0, test2: Color.Green, test3: Test{a: 5, b: 6}}, '
|
||||
'mana: 150, hp: 80, name: MyMonster, inventory: [0, 1, 2, 3, 4], '
|
||||
'color: Color.Blue, testType: AnyTypeId.Monster, '
|
||||
'test: Monster{pos: null, mana: 150, hp: 100, name: Fred, '
|
||||
'inventory: null, color: Color.Blue, testType: null, '
|
||||
'test: null, test4: null, testarrayofstring: null, '
|
||||
'testarrayoftables: null, enemy: null, testnestedflatbuffer: null, '
|
||||
'testempty: null, testbool: false, testhashs32Fnv1: 0, '
|
||||
'testhashu32Fnv1: 0, testhashs64Fnv1: 0, testhashu64Fnv1: 0, '
|
||||
'testhashs32Fnv1a: 0, testhashu32Fnv1a: 0, testhashs64Fnv1a: 0, '
|
||||
'testhashu64Fnv1a: 0, testarrayofbools: null, testf: 3.14159, '
|
||||
'testf2: 3.0, testf3: 0.0, testarrayofstring2: null, '
|
||||
'testarrayofsortedstruct: null, flex: null, test5: null, '
|
||||
'vectorOfLongs: null, vectorOfDoubles: null, parentNamespaceTest: null, '
|
||||
'vectorOfReferrables: null, singleWeakReference: 0, '
|
||||
'vectorOfWeakReferences: null, vectorOfStrongReferrables: null, '
|
||||
'coOwningReference: 0, vectorOfCoOwningReferences: null, '
|
||||
'nonOwningReference: 0, vectorOfNonOwningReferences: null, '
|
||||
'anyUniqueType: null, anyUnique: null, anyAmbiguousType: null, '
|
||||
'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race.None, '
|
||||
'testrequirednestedflatbuffer: null, scalarKeySortedTables: null, '
|
||||
'nativeInline: null, '
|
||||
'longEnumNonEnumDefault: LongEnum._default, '
|
||||
'longEnumNormalDefault: LongEnum.LongOne, nanDefault: NaN, '
|
||||
'infDefault: Infinity, positiveInfDefault: Infinity, infinityDefault: '
|
||||
'Infinity, positiveInfinityDefault: Infinity, negativeInfDefault: '
|
||||
'-Infinity, negativeInfinityDefault: -Infinity, doubleInfDefault: Infinity}, '
|
||||
'test4: [Test{a: 10, b: 20}, Test{a: 30, b: 40}], '
|
||||
'testarrayofstring: [test1, test2], testarrayoftables: null, '
|
||||
'enemy: Monster{pos: null, mana: 150, hp: 100, name: Fred, '
|
||||
'inventory: null, color: Color.Blue, testType: null, '
|
||||
'test: null, test4: null, testarrayofstring: null, '
|
||||
'testarrayoftables: null, enemy: null, testnestedflatbuffer: null, '
|
||||
'testempty: null, testbool: false, testhashs32Fnv1: 0, '
|
||||
'testhashu32Fnv1: 0, testhashs64Fnv1: 0, testhashu64Fnv1: 0, '
|
||||
'testhashs32Fnv1a: 0, testhashu32Fnv1a: 0, testhashs64Fnv1a: 0, '
|
||||
'testhashu64Fnv1a: 0, testarrayofbools: null, testf: 3.14159, '
|
||||
'testf2: 3.0, testf3: 0.0, testarrayofstring2: null, '
|
||||
'testarrayofsortedstruct: null, flex: null, test5: null, '
|
||||
'vectorOfLongs: null, vectorOfDoubles: null, parentNamespaceTest: null, '
|
||||
'vectorOfReferrables: null, singleWeakReference: 0, '
|
||||
'vectorOfWeakReferences: null, vectorOfStrongReferrables: null, '
|
||||
'coOwningReference: 0, vectorOfCoOwningReferences: null, '
|
||||
'nonOwningReference: 0, vectorOfNonOwningReferences: null, '
|
||||
'anyUniqueType: null, anyUnique: null, anyAmbiguousType: null, '
|
||||
'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race.None, '
|
||||
'testrequirednestedflatbuffer: null, scalarKeySortedTables: null, '
|
||||
'nativeInline: null, '
|
||||
'longEnumNonEnumDefault: LongEnum._default, '
|
||||
'longEnumNormalDefault: LongEnum.LongOne, nanDefault: NaN, '
|
||||
'infDefault: Infinity, positiveInfDefault: Infinity, infinityDefault: '
|
||||
'Infinity, positiveInfinityDefault: Infinity, negativeInfDefault: '
|
||||
'-Infinity, negativeInfinityDefault: -Infinity, doubleInfDefault: Infinity}, '
|
||||
'testnestedflatbuffer: null, testempty: null, testbool: true, '
|
||||
'testhashs32Fnv1: -579221183, testhashu32Fnv1: 3715746113, '
|
||||
'testhashs64Fnv1: 7930699090847568257, '
|
||||
'testhashu64Fnv1: 7930699090847568257, '
|
||||
'testhashs32Fnv1a: -1904106383, testhashu32Fnv1a: 2390860913, '
|
||||
'testhashs64Fnv1a: 4898026182817603057, '
|
||||
'testhashu64Fnv1a: 4898026182817603057, '
|
||||
'testarrayofbools: [true, false, true], testf: 3.14159, testf2: 3.0, '
|
||||
'testf3: 0.0, testarrayofstring2: null, testarrayofsortedstruct: ['
|
||||
'Ability{id: 0, distance: 45}, Ability{id: 1, distance: 21}, '
|
||||
'Ability{id: 5, distance: 12}], '
|
||||
'flex: null, test5: [Test{a: 10, b: 20}, Test{a: 30, b: 40}], '
|
||||
'vectorOfLongs: [1, 100, 10000, 1000000, 100000000], '
|
||||
'vectorOfDoubles: [-1.7976931348623157e+308, 0.0, 1.7976931348623157e+308], '
|
||||
'parentNamespaceTest: null, vectorOfReferrables: null, '
|
||||
'singleWeakReference: 0, vectorOfWeakReferences: null, '
|
||||
'vectorOfStrongReferrables: null, coOwningReference: 0, '
|
||||
'vectorOfCoOwningReferences: null, nonOwningReference: 0, '
|
||||
'vectorOfNonOwningReferences: null, '
|
||||
'anyUniqueType: null, anyUnique: null, '
|
||||
'anyAmbiguousType: null, '
|
||||
'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race.None, '
|
||||
'testrequirednestedflatbuffer: null, scalarKeySortedTables: [Stat{id: '
|
||||
'miss, val: 0, count: 0}, Stat{id: hit, val: 10, count: 1}], '
|
||||
'nativeInline: Test{a: 1, b: 2}, '
|
||||
'longEnumNonEnumDefault: LongEnum._default, '
|
||||
'longEnumNormalDefault: LongEnum.LongOne, nanDefault: NaN, '
|
||||
'infDefault: Infinity, positiveInfDefault: Infinity, infinityDefault: '
|
||||
'Infinity, positiveInfinityDefault: Infinity, negativeInfDefault: '
|
||||
'-Infinity, negativeInfinityDefault: -Infinity, doubleInfDefault: Infinity}');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,6 +215,10 @@ class BuilderTest {
|
||||
..addTestarrayofstringOffset(testArrayOfString);
|
||||
final mon = monBuilder.finish();
|
||||
fbBuilder.finish(mon);
|
||||
|
||||
final mon3 = example.Monster(fbBuilder.buffer);
|
||||
expect(mon3.name, 'MyMonster');
|
||||
expect(mon3.pos!.test1, 3.0);
|
||||
}
|
||||
|
||||
void test_error_addInt32_withoutStartTable([Builder? builder]) {
|
||||
@@ -769,7 +771,6 @@ class BuilderTest {
|
||||
class ObjectAPITest {
|
||||
void test_tableStat() {
|
||||
final object1 = example.StatT(count: 3, id: "foo", val: 4);
|
||||
expect(object1 is Packable, isTrue);
|
||||
final fbb = Builder();
|
||||
fbb.finish(object1.pack(fbb));
|
||||
final object2 = example.Stat(fbb.buffer).unpack();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable
|
||||
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable, constant_identifier_names
|
||||
|
||||
import 'dart:typed_data' show Uint8List;
|
||||
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable
|
||||
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable, constant_identifier_names
|
||||
|
||||
library my_game.other_name_space;
|
||||
|
||||
@@ -9,35 +9,25 @@ import 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||
|
||||
import './include_test1_generated.dart';
|
||||
|
||||
class FromInclude {
|
||||
enum FromInclude {
|
||||
IncludeVal(0);
|
||||
|
||||
final int value;
|
||||
const FromInclude._(this.value);
|
||||
const FromInclude(this.value);
|
||||
|
||||
factory FromInclude.fromValue(int value) {
|
||||
final result = values[value];
|
||||
if (result == null) {
|
||||
throw StateError('Invalid value $value for bit flag enum FromInclude');
|
||||
switch (value) {
|
||||
case 0: return FromInclude.IncludeVal;
|
||||
default: throw StateError('Invalid value $value for bit flag enum');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static FromInclude? _createOrNull(int? value) =>
|
||||
static FromInclude? _createOrNull(int? value) =>
|
||||
value == null ? null : FromInclude.fromValue(value);
|
||||
|
||||
static const int minValue = 0;
|
||||
static const int maxValue = 0;
|
||||
static bool containsValue(int value) => values.containsKey(value);
|
||||
|
||||
static const FromInclude IncludeVal = FromInclude._(0);
|
||||
static const Map<int, FromInclude> values = {
|
||||
0: IncludeVal};
|
||||
|
||||
static const fb.Reader<FromInclude> reader = _FromIncludeReader();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'FromInclude{value: $value}';
|
||||
}
|
||||
}
|
||||
|
||||
class _FromIncludeReader extends fb.Reader<FromInclude> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable
|
||||
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable, constant_identifier_names
|
||||
|
||||
library keyword_test;
|
||||
|
||||
@@ -7,39 +7,29 @@ import 'dart:typed_data' show Uint8List;
|
||||
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||
|
||||
|
||||
class Abc {
|
||||
enum Abc {
|
||||
$void(0),
|
||||
where(1),
|
||||
stackalloc(2);
|
||||
|
||||
final int value;
|
||||
const Abc._(this.value);
|
||||
const Abc(this.value);
|
||||
|
||||
factory Abc.fromValue(int value) {
|
||||
final result = values[value];
|
||||
if (result == null) {
|
||||
throw StateError('Invalid value $value for bit flag enum Abc');
|
||||
switch (value) {
|
||||
case 0: return Abc.$void;
|
||||
case 1: return Abc.where;
|
||||
case 2: return Abc.stackalloc;
|
||||
default: throw StateError('Invalid value $value for bit flag enum');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static Abc? _createOrNull(int? value) =>
|
||||
static Abc? _createOrNull(int? value) =>
|
||||
value == null ? null : Abc.fromValue(value);
|
||||
|
||||
static const int minValue = 0;
|
||||
static const int maxValue = 2;
|
||||
static bool containsValue(int value) => values.containsKey(value);
|
||||
|
||||
static const Abc $void = Abc._(0);
|
||||
static const Abc where = Abc._(1);
|
||||
static const Abc stackalloc = Abc._(2);
|
||||
static const Map<int, Abc> values = {
|
||||
0: $void,
|
||||
1: where,
|
||||
2: stackalloc};
|
||||
|
||||
static const fb.Reader<Abc> reader = _AbcReader();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Abc{value: $value}';
|
||||
}
|
||||
}
|
||||
|
||||
class _AbcReader extends fb.Reader<Abc> {
|
||||
@@ -53,35 +43,25 @@ class _AbcReader extends fb.Reader<Abc> {
|
||||
Abc.fromValue(const fb.Int32Reader().read(bc, offset));
|
||||
}
|
||||
|
||||
class Public {
|
||||
enum Public {
|
||||
NONE(0);
|
||||
|
||||
final int value;
|
||||
const Public._(this.value);
|
||||
const Public(this.value);
|
||||
|
||||
factory Public.fromValue(int value) {
|
||||
final result = values[value];
|
||||
if (result == null) {
|
||||
throw StateError('Invalid value $value for bit flag enum Public');
|
||||
switch (value) {
|
||||
case 0: return Public.NONE;
|
||||
default: throw StateError('Invalid value $value for bit flag enum');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static Public? _createOrNull(int? value) =>
|
||||
static Public? _createOrNull(int? value) =>
|
||||
value == null ? null : Public.fromValue(value);
|
||||
|
||||
static const int minValue = 0;
|
||||
static const int maxValue = 0;
|
||||
static bool containsValue(int value) => values.containsKey(value);
|
||||
|
||||
static const Public NONE = Public._(0);
|
||||
static const Map<int, Public> values = {
|
||||
0: NONE};
|
||||
|
||||
static const fb.Reader<Public> reader = _PublicReader();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Public{value: $value}';
|
||||
}
|
||||
}
|
||||
|
||||
class _PublicReader extends fb.Reader<Public> {
|
||||
@@ -95,39 +75,29 @@ class _PublicReader extends fb.Reader<Public> {
|
||||
Public.fromValue(const fb.Int32Reader().read(bc, offset));
|
||||
}
|
||||
|
||||
class KeywordsInUnionTypeId {
|
||||
enum KeywordsInUnionTypeId {
|
||||
NONE(0),
|
||||
$static(1),
|
||||
internal(2);
|
||||
|
||||
final int value;
|
||||
const KeywordsInUnionTypeId._(this.value);
|
||||
const KeywordsInUnionTypeId(this.value);
|
||||
|
||||
factory KeywordsInUnionTypeId.fromValue(int value) {
|
||||
final result = values[value];
|
||||
if (result == null) {
|
||||
throw StateError('Invalid value $value for bit flag enum KeywordsInUnionTypeId');
|
||||
switch (value) {
|
||||
case 0: return KeywordsInUnionTypeId.NONE;
|
||||
case 1: return KeywordsInUnionTypeId.$static;
|
||||
case 2: return KeywordsInUnionTypeId.internal;
|
||||
default: throw StateError('Invalid value $value for bit flag enum');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static KeywordsInUnionTypeId? _createOrNull(int? value) =>
|
||||
static KeywordsInUnionTypeId? _createOrNull(int? value) =>
|
||||
value == null ? null : KeywordsInUnionTypeId.fromValue(value);
|
||||
|
||||
static const int minValue = 0;
|
||||
static const int maxValue = 2;
|
||||
static bool containsValue(int value) => values.containsKey(value);
|
||||
|
||||
static const KeywordsInUnionTypeId NONE = KeywordsInUnionTypeId._(0);
|
||||
static const KeywordsInUnionTypeId $static = KeywordsInUnionTypeId._(1);
|
||||
static const KeywordsInUnionTypeId internal = KeywordsInUnionTypeId._(2);
|
||||
static const Map<int, KeywordsInUnionTypeId> values = {
|
||||
0: NONE,
|
||||
1: $static,
|
||||
2: internal};
|
||||
|
||||
static const fb.Reader<KeywordsInUnionTypeId> reader = _KeywordsInUnionTypeIdReader();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'KeywordsInUnionTypeId{value: $value}';
|
||||
}
|
||||
}
|
||||
|
||||
class _KeywordsInUnionTypeIdReader extends fb.Reader<KeywordsInUnionTypeId> {
|
||||
|
||||
@@ -59,8 +59,6 @@ struct Vec3 (force_align: 8) {
|
||||
test3:Test;
|
||||
}
|
||||
|
||||
// Stats for monster
|
||||
|
||||
struct Ability {
|
||||
id:uint(key);
|
||||
distance:uint;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable
|
||||
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable, constant_identifier_names
|
||||
|
||||
library my_game.example2;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable
|
||||
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable, constant_identifier_names
|
||||
|
||||
library my_game.example;
|
||||
|
||||
@@ -12,46 +12,29 @@ import './monster_test_my_game.example2_generated.dart' as my_game_example2;
|
||||
import './include_test1_generated.dart';
|
||||
|
||||
/// Composite components of Monster color.
|
||||
class Color {
|
||||
enum Color {
|
||||
Red(1),
|
||||
Green(2),
|
||||
Blue(8),
|
||||
_default(0);
|
||||
|
||||
final int value;
|
||||
const Color._(this.value);
|
||||
const Color(this.value);
|
||||
|
||||
factory Color.fromValue(int value) {
|
||||
final result = values[value];
|
||||
if (result == null) {
|
||||
if (value == 0) {
|
||||
return Color._(0);
|
||||
} else {
|
||||
throw StateError('Invalid value $value for bit flag enum Color');
|
||||
}
|
||||
switch (value) {
|
||||
case 1: return Color.Red;
|
||||
case 2: return Color.Green;
|
||||
case 8: return Color.Blue;
|
||||
case 0: return Color._default;
|
||||
default: throw StateError('Invalid value $value for bit flag enum');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static Color? _createOrNull(int? value) =>
|
||||
static Color? _createOrNull(int? value) =>
|
||||
value == null ? null : Color.fromValue(value);
|
||||
|
||||
static bool containsValue(int value) => values.containsKey(value);
|
||||
|
||||
static const Color Red = Color._(1);
|
||||
|
||||
/// \brief color Green
|
||||
/// Green is bit_flag with value (1u << 1)
|
||||
static const Color Green = Color._(2);
|
||||
|
||||
/// \brief color Blue (1u << 3)
|
||||
static const Color Blue = Color._(8);
|
||||
static const Map<int, Color> values = {
|
||||
1: Red,
|
||||
2: Green,
|
||||
8: Blue};
|
||||
|
||||
static const fb.Reader<Color> reader = _ColorReader();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Color{value: $value}';
|
||||
}
|
||||
}
|
||||
|
||||
class _ColorReader extends fb.Reader<Color> {
|
||||
@@ -65,41 +48,31 @@ class _ColorReader extends fb.Reader<Color> {
|
||||
Color.fromValue(const fb.Uint8Reader().read(bc, offset));
|
||||
}
|
||||
|
||||
class Race {
|
||||
enum Race {
|
||||
None(-1),
|
||||
Human(0),
|
||||
Dwarf(1),
|
||||
Elf(2);
|
||||
|
||||
final int value;
|
||||
const Race._(this.value);
|
||||
const Race(this.value);
|
||||
|
||||
factory Race.fromValue(int value) {
|
||||
final result = values[value];
|
||||
if (result == null) {
|
||||
throw StateError('Invalid value $value for bit flag enum Race');
|
||||
switch (value) {
|
||||
case -1: return Race.None;
|
||||
case 0: return Race.Human;
|
||||
case 1: return Race.Dwarf;
|
||||
case 2: return Race.Elf;
|
||||
default: throw StateError('Invalid value $value for bit flag enum');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static Race? _createOrNull(int? value) =>
|
||||
static Race? _createOrNull(int? value) =>
|
||||
value == null ? null : Race.fromValue(value);
|
||||
|
||||
static const int minValue = -1;
|
||||
static const int maxValue = 2;
|
||||
static bool containsValue(int value) => values.containsKey(value);
|
||||
|
||||
static const Race None = Race._(-1);
|
||||
static const Race Human = Race._(0);
|
||||
static const Race Dwarf = Race._(1);
|
||||
static const Race Elf = Race._(2);
|
||||
static const Map<int, Race> values = {
|
||||
-1: None,
|
||||
0: Human,
|
||||
1: Dwarf,
|
||||
2: Elf};
|
||||
|
||||
static const fb.Reader<Race> reader = _RaceReader();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Race{value: $value}';
|
||||
}
|
||||
}
|
||||
|
||||
class _RaceReader extends fb.Reader<Race> {
|
||||
@@ -113,41 +86,29 @@ class _RaceReader extends fb.Reader<Race> {
|
||||
Race.fromValue(const fb.Int8Reader().read(bc, offset));
|
||||
}
|
||||
|
||||
class LongEnum {
|
||||
enum LongEnum {
|
||||
LongOne(2),
|
||||
LongTwo(4),
|
||||
LongBig(1099511627776),
|
||||
_default(0);
|
||||
|
||||
final int value;
|
||||
const LongEnum._(this.value);
|
||||
const LongEnum(this.value);
|
||||
|
||||
factory LongEnum.fromValue(int value) {
|
||||
final result = values[value];
|
||||
if (result == null) {
|
||||
if (value == 0) {
|
||||
return LongEnum._(0);
|
||||
} else {
|
||||
throw StateError('Invalid value $value for bit flag enum LongEnum');
|
||||
}
|
||||
switch (value) {
|
||||
case 2: return LongEnum.LongOne;
|
||||
case 4: return LongEnum.LongTwo;
|
||||
case 1099511627776: return LongEnum.LongBig;
|
||||
case 0: return LongEnum._default;
|
||||
default: throw StateError('Invalid value $value for bit flag enum');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static LongEnum? _createOrNull(int? value) =>
|
||||
static LongEnum? _createOrNull(int? value) =>
|
||||
value == null ? null : LongEnum.fromValue(value);
|
||||
|
||||
static bool containsValue(int value) => values.containsKey(value);
|
||||
|
||||
static const LongEnum LongOne = LongEnum._(2);
|
||||
static const LongEnum LongTwo = LongEnum._(4);
|
||||
static const LongEnum LongBig = LongEnum._(1099511627776);
|
||||
static const Map<int, LongEnum> values = {
|
||||
2: LongOne,
|
||||
4: LongTwo,
|
||||
1099511627776: LongBig};
|
||||
|
||||
static const fb.Reader<LongEnum> reader = _LongEnumReader();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LongEnum{value: $value}';
|
||||
}
|
||||
}
|
||||
|
||||
class _LongEnumReader extends fb.Reader<LongEnum> {
|
||||
@@ -161,41 +122,31 @@ class _LongEnumReader extends fb.Reader<LongEnum> {
|
||||
LongEnum.fromValue(const fb.Uint64Reader().read(bc, offset));
|
||||
}
|
||||
|
||||
class AnyTypeId {
|
||||
enum AnyTypeId {
|
||||
NONE(0),
|
||||
Monster(1),
|
||||
TestSimpleTableWithEnum(2),
|
||||
MyGame_Example2_Monster(3);
|
||||
|
||||
final int value;
|
||||
const AnyTypeId._(this.value);
|
||||
const AnyTypeId(this.value);
|
||||
|
||||
factory AnyTypeId.fromValue(int value) {
|
||||
final result = values[value];
|
||||
if (result == null) {
|
||||
throw StateError('Invalid value $value for bit flag enum AnyTypeId');
|
||||
switch (value) {
|
||||
case 0: return AnyTypeId.NONE;
|
||||
case 1: return AnyTypeId.Monster;
|
||||
case 2: return AnyTypeId.TestSimpleTableWithEnum;
|
||||
case 3: return AnyTypeId.MyGame_Example2_Monster;
|
||||
default: throw StateError('Invalid value $value for bit flag enum');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static AnyTypeId? _createOrNull(int? value) =>
|
||||
static AnyTypeId? _createOrNull(int? value) =>
|
||||
value == null ? null : AnyTypeId.fromValue(value);
|
||||
|
||||
static const int minValue = 0;
|
||||
static const int maxValue = 3;
|
||||
static bool containsValue(int value) => values.containsKey(value);
|
||||
|
||||
static const AnyTypeId NONE = AnyTypeId._(0);
|
||||
static const AnyTypeId Monster = AnyTypeId._(1);
|
||||
static const AnyTypeId TestSimpleTableWithEnum = AnyTypeId._(2);
|
||||
static const AnyTypeId MyGame_Example2_Monster = AnyTypeId._(3);
|
||||
static const Map<int, AnyTypeId> values = {
|
||||
0: NONE,
|
||||
1: Monster,
|
||||
2: TestSimpleTableWithEnum,
|
||||
3: MyGame_Example2_Monster};
|
||||
|
||||
static const fb.Reader<AnyTypeId> reader = _AnyTypeIdReader();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AnyTypeId{value: $value}';
|
||||
}
|
||||
}
|
||||
|
||||
class _AnyTypeIdReader extends fb.Reader<AnyTypeId> {
|
||||
@@ -209,41 +160,31 @@ class _AnyTypeIdReader extends fb.Reader<AnyTypeId> {
|
||||
AnyTypeId.fromValue(const fb.Uint8Reader().read(bc, offset));
|
||||
}
|
||||
|
||||
class AnyUniqueAliasesTypeId {
|
||||
enum AnyUniqueAliasesTypeId {
|
||||
NONE(0),
|
||||
M(1),
|
||||
TS(2),
|
||||
M2(3);
|
||||
|
||||
final int value;
|
||||
const AnyUniqueAliasesTypeId._(this.value);
|
||||
const AnyUniqueAliasesTypeId(this.value);
|
||||
|
||||
factory AnyUniqueAliasesTypeId.fromValue(int value) {
|
||||
final result = values[value];
|
||||
if (result == null) {
|
||||
throw StateError('Invalid value $value for bit flag enum AnyUniqueAliasesTypeId');
|
||||
switch (value) {
|
||||
case 0: return AnyUniqueAliasesTypeId.NONE;
|
||||
case 1: return AnyUniqueAliasesTypeId.M;
|
||||
case 2: return AnyUniqueAliasesTypeId.TS;
|
||||
case 3: return AnyUniqueAliasesTypeId.M2;
|
||||
default: throw StateError('Invalid value $value for bit flag enum');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static AnyUniqueAliasesTypeId? _createOrNull(int? value) =>
|
||||
static AnyUniqueAliasesTypeId? _createOrNull(int? value) =>
|
||||
value == null ? null : AnyUniqueAliasesTypeId.fromValue(value);
|
||||
|
||||
static const int minValue = 0;
|
||||
static const int maxValue = 3;
|
||||
static bool containsValue(int value) => values.containsKey(value);
|
||||
|
||||
static const AnyUniqueAliasesTypeId NONE = AnyUniqueAliasesTypeId._(0);
|
||||
static const AnyUniqueAliasesTypeId M = AnyUniqueAliasesTypeId._(1);
|
||||
static const AnyUniqueAliasesTypeId TS = AnyUniqueAliasesTypeId._(2);
|
||||
static const AnyUniqueAliasesTypeId M2 = AnyUniqueAliasesTypeId._(3);
|
||||
static const Map<int, AnyUniqueAliasesTypeId> values = {
|
||||
0: NONE,
|
||||
1: M,
|
||||
2: TS,
|
||||
3: M2};
|
||||
|
||||
static const fb.Reader<AnyUniqueAliasesTypeId> reader = _AnyUniqueAliasesTypeIdReader();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AnyUniqueAliasesTypeId{value: $value}';
|
||||
}
|
||||
}
|
||||
|
||||
class _AnyUniqueAliasesTypeIdReader extends fb.Reader<AnyUniqueAliasesTypeId> {
|
||||
@@ -257,41 +198,31 @@ class _AnyUniqueAliasesTypeIdReader extends fb.Reader<AnyUniqueAliasesTypeId> {
|
||||
AnyUniqueAliasesTypeId.fromValue(const fb.Uint8Reader().read(bc, offset));
|
||||
}
|
||||
|
||||
class AnyAmbiguousAliasesTypeId {
|
||||
enum AnyAmbiguousAliasesTypeId {
|
||||
NONE(0),
|
||||
M1(1),
|
||||
M2(2),
|
||||
M3(3);
|
||||
|
||||
final int value;
|
||||
const AnyAmbiguousAliasesTypeId._(this.value);
|
||||
const AnyAmbiguousAliasesTypeId(this.value);
|
||||
|
||||
factory AnyAmbiguousAliasesTypeId.fromValue(int value) {
|
||||
final result = values[value];
|
||||
if (result == null) {
|
||||
throw StateError('Invalid value $value for bit flag enum AnyAmbiguousAliasesTypeId');
|
||||
switch (value) {
|
||||
case 0: return AnyAmbiguousAliasesTypeId.NONE;
|
||||
case 1: return AnyAmbiguousAliasesTypeId.M1;
|
||||
case 2: return AnyAmbiguousAliasesTypeId.M2;
|
||||
case 3: return AnyAmbiguousAliasesTypeId.M3;
|
||||
default: throw StateError('Invalid value $value for bit flag enum');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static AnyAmbiguousAliasesTypeId? _createOrNull(int? value) =>
|
||||
static AnyAmbiguousAliasesTypeId? _createOrNull(int? value) =>
|
||||
value == null ? null : AnyAmbiguousAliasesTypeId.fromValue(value);
|
||||
|
||||
static const int minValue = 0;
|
||||
static const int maxValue = 3;
|
||||
static bool containsValue(int value) => values.containsKey(value);
|
||||
|
||||
static const AnyAmbiguousAliasesTypeId NONE = AnyAmbiguousAliasesTypeId._(0);
|
||||
static const AnyAmbiguousAliasesTypeId M1 = AnyAmbiguousAliasesTypeId._(1);
|
||||
static const AnyAmbiguousAliasesTypeId M2 = AnyAmbiguousAliasesTypeId._(2);
|
||||
static const AnyAmbiguousAliasesTypeId M3 = AnyAmbiguousAliasesTypeId._(3);
|
||||
static const Map<int, AnyAmbiguousAliasesTypeId> values = {
|
||||
0: NONE,
|
||||
1: M1,
|
||||
2: M2,
|
||||
3: M3};
|
||||
|
||||
static const fb.Reader<AnyAmbiguousAliasesTypeId> reader = _AnyAmbiguousAliasesTypeIdReader();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AnyAmbiguousAliasesTypeId{value: $value}';
|
||||
}
|
||||
}
|
||||
|
||||
class _AnyAmbiguousAliasesTypeIdReader extends fb.Reader<AnyAmbiguousAliasesTypeId> {
|
||||
@@ -1461,7 +1392,7 @@ class MonsterT implements fb.Packable {
|
||||
this.testrequirednestedflatbuffer,
|
||||
this.scalarKeySortedTables,
|
||||
this.nativeInline,
|
||||
this.longEnumNonEnumDefault = const LongEnum._(0),
|
||||
this.longEnumNonEnumDefault = LongEnum._default,
|
||||
this.longEnumNormalDefault = LongEnum.LongOne,
|
||||
this.nanDefault = double.nan,
|
||||
this.infDefault = double.infinity,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable
|
||||
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable, constant_identifier_names
|
||||
|
||||
library my_game;
|
||||
|
||||
|
||||
3
docs-old/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
This is the source of the old docs that are being replaced. They are served
|
||||
from the `gh-pages-old` branch, while the new documentations (source in docs/)
|
||||
is served from the `gh-pages` branch.
|
||||
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
@@ -72,6 +72,7 @@ We generate [SLSA3 signatures](slsa.dev) using the OpenSSF's [slsa-framework/sls
|
||||
```shell
|
||||
$ slsa-verifier -artifact-path <downloaded.zip> -provenance attestation.intoto.jsonl -source github.com/google/flatbuffers -tag <version>
|
||||
PASSED: Verified SLSA provenance
|
||||
```
|
||||
|
||||
## Building for Android
|
||||
|
||||
@@ -23,31 +23,35 @@ For any schema input files, one or more generators can be specified:
|
||||
|
||||
- `--java`, `-j` : Generate Java code.
|
||||
|
||||
- `--kotlin`, `-k` : Generate Kotlin code.
|
||||
- `--kotlin` , `--kotlin-kmp` : Generate Kotlin code.
|
||||
|
||||
- `--csharp`, `-n` : Generate C# code.
|
||||
|
||||
- `--go`, `-g` : Generate Go code.
|
||||
|
||||
- `--python`, `-p`: Generate Python code.
|
||||
- `--python`, `-p` : Generate Python code.
|
||||
|
||||
- `--js`, `-s`: Generate JavaScript code.
|
||||
- `--js`, `-s` : Generate JavaScript code.
|
||||
|
||||
- `--ts`: Generate TypeScript code.
|
||||
- `--ts`, `-T` : Generate TypeScript code.
|
||||
|
||||
- `--php`: Generate PHP code.
|
||||
- `--php` : Generate PHP code.
|
||||
|
||||
- `--grpc`: Generate RPC stub code for GRPC.
|
||||
- `--grpc` : Generate RPC stub code for GRPC.
|
||||
|
||||
- `--dart`: Generate Dart code.
|
||||
- `--dart`, `-d` : Generate Dart code.
|
||||
|
||||
- `--lua`: Generate Lua code.
|
||||
- `--lua`, `-l` : Generate Lua code.
|
||||
|
||||
- `--lobster`: Generate Lobster code.
|
||||
- `--lobster` : Generate Lobster code.
|
||||
|
||||
- `--rust`, `-r` : Generate Rust code.
|
||||
|
||||
- `--swift`: Generate Swift code.
|
||||
- `--swift` : Generate Swift code.
|
||||
|
||||
- `--nim` : Generate Nim code.
|
||||
|
||||
|
||||
|
||||
For any data input files:
|
||||
|
||||
@@ -58,6 +62,8 @@ For any data input files:
|
||||
- `--json`, `-t` : If data is contained in this file, generate a
|
||||
`filename.json` representing the data in the flatbuffer.
|
||||
|
||||
- `--jsonschema` : Generate Json schema
|
||||
|
||||
Additional options:
|
||||
|
||||
- `-o PATH` : Output all generated files to PATH (either absolute, or
|
||||
@@ -90,10 +96,10 @@ Additional options:
|
||||
|
||||
- `--scoped-enums` : Use C++11 style scoped and strongly typed enums in
|
||||
generated C++. This also implies `--no-prefix`.
|
||||
|
||||
|
||||
- `--no-emit-min-max-enum-values` : Disable generation of MIN and MAX
|
||||
enumerated values for scoped enums and prefixed enums.
|
||||
|
||||
|
||||
- `--gen-includes` : (deprecated), this is the default behavior.
|
||||
If the original behavior is required (no include
|
||||
statements) use `--no-includes.`
|
||||
@@ -115,7 +121,7 @@ Additional options:
|
||||
|
||||
- `--gen-compare` : Generate operator== for object-based API types.
|
||||
|
||||
- `--gen-nullable` : Add Clang _Nullable for C++ pointer. or @Nullable for Java.
|
||||
- `--gen-nullable` : Add Clang \_Nullable for C++ pointer. or @Nullable for Java.
|
||||
|
||||
- `--gen-generated` : Add @Generated annotation for Java.
|
||||
|
||||
@@ -189,7 +195,7 @@ Additional options:
|
||||
`--conform PATH`.
|
||||
|
||||
- `--filename-suffix SUFFIX` : The suffix appended to the generated
|
||||
file names. Default is '_generated'.
|
||||
file names. Default is '\_generated'.
|
||||
|
||||
- `--filename-ext EXTENSION` : The extension appended to the generated
|
||||
file names. Default is language-specific (e.g. "h" for C++). This
|
||||
@@ -227,5 +233,49 @@ Additional options:
|
||||
vector of bytes in JSON, which is unsafe unless checked by a verifier
|
||||
afterwards.
|
||||
|
||||
- `--python-no-type-prefix-suffix` : Skip emission of Python functions that are prefixed
|
||||
with typenames
|
||||
|
||||
- `--python-typing` : Generate Python type annotations
|
||||
|
||||
Additional gRPC options:
|
||||
|
||||
- `--grpc-filename-suffix`: `[C++]` An optional suffix for the generated
|
||||
files' names. For example, compiling gRPC for C++ with
|
||||
`--grpc-filename-suffix=.fbs` will generate `{name}.fbs.h` and
|
||||
`{name}.fbs.cc` files.
|
||||
|
||||
- `--grpc-additional-header`: `[C++]` Additional headers to include in the
|
||||
generated files.
|
||||
|
||||
- `--grpc-search-path`: `[C++]` An optional prefix for the gRPC runtime path.
|
||||
For example, compiling gRPC for C++ with `--grpc-search-path=some/path` will
|
||||
generate the following includes:
|
||||
|
||||
```cpp
|
||||
#include "some/path/grpcpp/impl/codegen/async_stream.h"
|
||||
#include "some/path/grpcpp/impl/codegen/async_unary_call.h"
|
||||
#include "some/path/grpcpp/impl/codegen/method_handler.h"
|
||||
...
|
||||
```
|
||||
|
||||
- `--grpc-use-system-headers`: `[C++]` Whether to generate `#include <header>`
|
||||
instead of `#include "header.h"` for all headers when compiling gRPC for
|
||||
C++. For example, compiling gRPC for C++ with `--grpc-use-system-headers`
|
||||
will generate the following includes:
|
||||
|
||||
```cpp
|
||||
#include <some/path/grpcpp/impl/codegen/async_stream.h>
|
||||
#include <some/path/grpcpp/impl/codegen/async_unary_call.h>
|
||||
#include <some/path/grpcpp/impl/codegen/method_handler.h>
|
||||
...
|
||||
```
|
||||
|
||||
NOTE: This option can be negated with `--no-grpc-use-system-headers`.
|
||||
|
||||
- `--grpc-python-typed-handlers`: `[Python]` Whether to generate the typed
|
||||
handlers that use the generated Python classes instead of raw bytes for
|
||||
requests/responses.
|
||||
|
||||
NOTE: short-form options for generators are deprecated, use the long form
|
||||
whenever possible.
|
||||
@@ -24,17 +24,14 @@ FlatBuffers).
|
||||
## Building the FlatBuffers C# library
|
||||
|
||||
The `FlatBuffers.csproj` project contains multitargeting for .NET Standard 2.1,
|
||||
.NET Standard 2.0, and .NET Framework 4.6 (Unity 2017). Support for .NET
|
||||
Framework 3.5 (Unity 5) is provided by the `FlatBuffers.net35.csproj` project.
|
||||
In most cases (including Unity 2018 and newer), .NET Standard 2.0 is
|
||||
recommended.
|
||||
.NET 6 and .NET 8.
|
||||
|
||||
You can build for a specific framework target when using the cross-platform
|
||||
[.NET Core SDK](https://dotnet.microsoft.com/download) by adding the `-f`
|
||||
command line option:
|
||||
|
||||
~~~{.sh}
|
||||
dotnet build -f netstandard2.0 "FlatBuffers.csproj"
|
||||
dotnet build -f netstandard2.1 "FlatBuffers.csproj"
|
||||
~~~
|
||||
|
||||
The `FlatBuffers.csproj` project also provides support for defining various
|
||||
@@ -142,10 +139,10 @@ To use it:
|
||||
`ByKey` only works if the vector has been sorted, it will
|
||||
likely not find elements if it hasn't been sorted.
|
||||
|
||||
## Buffer verification
|
||||
## Buffer verification
|
||||
|
||||
As mentioned in [C++ Usage](@ref flatbuffers_guide_use_cpp) buffer
|
||||
accessor functions do not verify buffer offsets at run-time.
|
||||
accessor functions do not verify buffer offsets at run-time.
|
||||
If it is necessary, you can optionally use a buffer verifier before you
|
||||
access the data. This verifier will check all offsets, all sizes of
|
||||
fields, and null termination of strings to ensure that when a buffer
|
||||
@@ -158,17 +155,17 @@ e.g. `Monster.VerifyMonster`. This can be called as shown:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
if `ok` is true, the buffer is safe to read.
|
||||
|
||||
For a more detailed control of verification `MonsterVerify.Verify`
|
||||
for `Monster` type can be used:
|
||||
For a more detailed control of verification `MonsterVerify.Verify`
|
||||
for `Monster` type can be used:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cs}
|
||||
# Sequence of calls
|
||||
FlatBuffers.Verifier verifier = new FlatBuffers.Verifier(buf);
|
||||
var ok = verifier.VerifyBuffer("MONS", false, MonsterVerify.Verify);
|
||||
|
||||
# Or single line call
|
||||
|
||||
# Or single line call
|
||||
var ok = new FlatBuffers.Verifier(bb).setStringCheck(true).\
|
||||
VerifyBuffer("MONS", false, MonsterVerify.Verify);
|
||||
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
if `ok` is true, the buffer is safe to read.
|
||||
|
||||
@@ -181,7 +178,7 @@ Verifier supports options that can be set using appropriate fluent methods:
|
||||
* SetMaxTables - total amount of tables the verifier may encounter. Default: 64
|
||||
* SetAlignmentCheck - check content alignment. Default: True
|
||||
* SetStringCheck - check if strings contain termination '0' character. Default: true
|
||||
|
||||
|
||||
|
||||
## Text parsing
|
||||
|
||||
24
docs/README.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# Documentation
|
||||
|
||||
This is the source of the FlatBuffers documentation, that is served at
|
||||
https://flatbuffers.dev.
|
||||
|
||||
|
||||
## Local Building
|
||||
|
||||
The documentation can be built and served locally during development, see [https//flatbuffers.dev/contributing/#local-development] for full details.
|
||||
|
||||
__tl;dr__
|
||||
|
||||
Install:
|
||||
|
||||
```
|
||||
pip install mkdocs-material
|
||||
pip install mkdocs-redirects
|
||||
```
|
||||
|
||||
Build and Serve:
|
||||
|
||||
```
|
||||
mkdocs serve -f docs/mkdocs.yml
|
||||
```
|
||||
159
docs/mkdocs.yml
Normal file
@@ -0,0 +1,159 @@
|
||||
site_name: FlatBuffers Docs
|
||||
docs_dir: source
|
||||
site_url: https://flatbuffers.dev
|
||||
repo_name: google/FlatBuffers
|
||||
repo_url: https://github.com/google/flatbuffers
|
||||
edit_uri: edit/master/docs/source/
|
||||
copyright: Copyright © 2025 Google
|
||||
theme:
|
||||
name: material
|
||||
logo: assets/flatbuffers_logo.svg
|
||||
icon:
|
||||
repo: fontawesome/brands/github
|
||||
custom_dir: overrides
|
||||
palette:
|
||||
# Palette toggle for light mode
|
||||
- scheme: default
|
||||
toggle:
|
||||
icon: material/brightness-7
|
||||
name: Switch to dark mode
|
||||
|
||||
# Palette toggle for dark mode
|
||||
- scheme: slate
|
||||
toggle:
|
||||
icon: material/brightness-4
|
||||
name: Switch to light mode
|
||||
|
||||
features:
|
||||
# Allows code block annotations
|
||||
- content.code.annotate
|
||||
|
||||
# Allows content tabs to link together
|
||||
- content.tabs.link
|
||||
|
||||
# Expand nav folders by default
|
||||
- navigation.expand
|
||||
|
||||
# Enable the footer
|
||||
- navigation.footer
|
||||
|
||||
# Auto hide the header after scrolling
|
||||
- header.autohide
|
||||
|
||||
- content.action.edit
|
||||
|
||||
extra:
|
||||
social:
|
||||
- icon: fontawesome/brands/github
|
||||
link: https://github.com/google/flatbuffers
|
||||
|
||||
- icon: fontawesome/brands/discord
|
||||
link: https:///discord.gg/6qgKs3R
|
||||
|
||||
- icon: fontawesome/brands/x-twitter
|
||||
link: https://twitter.com/dbaileychess
|
||||
|
||||
plugins:
|
||||
# Use redirects to update links from the original docs to the new ones.
|
||||
#
|
||||
# https://github.com/mkdocs/mkdocs-redirects
|
||||
- redirects:
|
||||
# Note the .html are suffixed with .md to avoid warnings. Got from
|
||||
# https://github.com/mkdocs/mkdocs-redirects/issues/51#issuecomment-2408548029
|
||||
redirect_maps:
|
||||
'flatbuffers_guide_building.html.md': 'building.md'
|
||||
'flatbuffers_guide_tutorial.html.md': 'tutorial.md'
|
||||
'flatbuffers_guide_using_schema_compiler.html.md': 'flatc.md'
|
||||
'flatbuffers_guide_writing_schema.html.md': 'schema.md'
|
||||
'md__schemas.html.md': 'schema.md' # issue #8485
|
||||
'flatbuffers_guide_use_c.html.md': 'languages/c.md'
|
||||
'flatbuffers_guide_use_cpp.html.md': 'languages/cpp.md'
|
||||
'flatbuffers_guide_use_c-sharp.html.md': 'languages/c_sharp.md'
|
||||
'flatbuffers_guide_use_dart.html.md': 'languages/dart.md'
|
||||
'flatbuffers_guide_use_go.html.md': 'languages/go.md'
|
||||
'flatbuffers_guide_use_java.html.md': 'languages/java.md'
|
||||
'flatbuffers_guide_use_javascript.html.md': 'languages/javascript.md'
|
||||
'flatbuffers_guide_use_lobster.html.md': 'languages/lobster.md'
|
||||
'flatbuffers_guide_use_lua.html.md': 'languages/lua.md'
|
||||
'flatbuffers_guide_use_php.html.md': 'languages/php.md'
|
||||
'flatbuffers_guide_use_python.html.md': 'languages/python.md'
|
||||
'flatbuffers_guide_use_rust.html.md': 'languages/rust.md'
|
||||
'flatbuffers_guide_use_swift.html.md': 'languages/swift.md'
|
||||
'flatbuffers_guide_use_typescript.html.md': 'languages/typescript.md'
|
||||
'flatbuffers_grpc_guide_use_cpp.html.md' : "languages/cpp.md#grpc"
|
||||
'flatbuffers_support.html.md': 'support.md'
|
||||
'flatbuffers_white_paper.html.md': 'white_paper.md'
|
||||
'flatbuffers_grammar.html.md': 'grammar.md'
|
||||
'flatbuffers_internals.html.md': 'internals.md'
|
||||
'intermediate_representation.html.md': 'intermediate_representation.md'
|
||||
'flatbuffers_benchmarks.html.md': 'benchmarks.md'
|
||||
'flexbuffers.html.md': 'flexbuffers.md'
|
||||
'contributing.html.md': 'contributing.md'
|
||||
|
||||
|
||||
markdown_extensions:
|
||||
- admonition
|
||||
- attr_list
|
||||
- md_in_html
|
||||
- pymdownx.critic
|
||||
- pymdownx.details
|
||||
- pymdownx.emoji:
|
||||
emoji_index: !!python/name:material.extensions.emoji.twemoji
|
||||
emoji_generator: !!python/name:material.extensions.emoji.to_svg
|
||||
- pymdownx.snippets:
|
||||
# Allows direct embedded of remote files
|
||||
url_download: true
|
||||
- pymdownx.superfences
|
||||
- pymdownx.tabbed:
|
||||
alternate_style: true
|
||||
slugify: !!python/object/apply:pymdownx.slugs.slugify
|
||||
kwds:
|
||||
case: lower
|
||||
- pymdownx.highlight:
|
||||
extend_pygments_lang:
|
||||
# PHP wasn't highlighting correctly. This is a work around found
|
||||
# https://github.com/squidfunk/mkdocs-material/issues/138#issuecomment-2294025627
|
||||
- name: php
|
||||
lang: php
|
||||
options:
|
||||
startinline: true
|
||||
- tables
|
||||
|
||||
|
||||
|
||||
nav:
|
||||
- Overview: "index.md"
|
||||
- Quick Start: "quick_start.md"
|
||||
- Tutorial: "tutorial.md"
|
||||
- Compiler (flatc):
|
||||
- Building: "building.md"
|
||||
- Using: "flatc.md"
|
||||
- Schema (.fbs):
|
||||
- Overview: "schema.md"
|
||||
- Evolution: "evolution.md"
|
||||
- Grammar: "grammar.md"
|
||||
- Language Guides:
|
||||
- C: "languages/c.md"
|
||||
- C++: "languages/cpp.md"
|
||||
- C#: "languages/c_sharp.md"
|
||||
- Dart: "languages/dart.md"
|
||||
- Go: "languages/go.md"
|
||||
- Java: "languages/java.md"
|
||||
- JavasScript: "languages/javascript.md"
|
||||
- Kotlin: "languages/kotlin.md"
|
||||
- Lobster: "languages/lobster.md"
|
||||
- Lua: "languages/lua.md"
|
||||
- PHP: "languages/php.md"
|
||||
- Python: "languages/python.md"
|
||||
- Rust: "languages/rust.md"
|
||||
- Swift: "languages/swift.md"
|
||||
- TypeScript: "languages/typescript.md"
|
||||
- Supported Configurations: "support.md"
|
||||
- White Paper: "white_paper.md"
|
||||
- Advanced:
|
||||
- FlatBuffers Internals: "internals.md"
|
||||
- Intermediate Representation: "intermediate_representation.md"
|
||||
- Annotating Buffers (.afb): "annotation.md"
|
||||
- Benchmarks: "benchmarks.md"
|
||||
- FlexBuffers (Schema-less version): "flexbuffers.md"
|
||||
- Contributing: "contributing.md"
|
||||
11
docs/overrides/404.html
Normal file
@@ -0,0 +1,11 @@
|
||||
{% extends "main.html" %}
|
||||
|
||||
<!-- Content -->
|
||||
{% block content %}
|
||||
<h1>404 - Not found</h1>
|
||||
<br>
|
||||
FlatBuffers is currently migrating their documentation system and existing
|
||||
links may not work.
|
||||
|
||||
Please <a href="https://github.com/google/flatbuffers/issues/new?template=404-doc.md">file an issue</a> indicating the broken link.
|
||||
{% endblock %}
|
||||
6
docs/overrides/main.html
Normal file
@@ -0,0 +1,6 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
<!-- Announcement bar -->
|
||||
{% block announce %}
|
||||
Documentation migration in progress, view snapshot of the old documentation <a href="https://dbaileychess.github.io/flatbuffers">here.</a>
|
||||
{% endblock %}
|
||||
1
docs/source/CNAME
Normal file
@@ -0,0 +1 @@
|
||||
flatbuffers.dev
|
||||
149
docs/source/annotation.md
Normal file
@@ -0,0 +1,149 @@
|
||||
# Annotating FlatBuffers
|
||||
|
||||
This provides a way to annotate flatbuffer binary data, byte-by-byte, with a
|
||||
schema. It is useful for development purposes and understanding the details of
|
||||
the internal format.
|
||||
|
||||
## Annotating
|
||||
|
||||
Given a `schema`, as either a plain-text (`.fbs`) or a binary schema (`.bfbs`),
|
||||
and `binary` file(s) that were created by the `schema`. You can annotate them
|
||||
using:
|
||||
|
||||
```sh
|
||||
flatc --annotate SCHEMA -- BINARY_FILES...
|
||||
```
|
||||
|
||||
This will produce a set of annotated files (`.afb` Annotated FlatBuffer)
|
||||
corresponding to the input binary files.
|
||||
|
||||
### Example
|
||||
|
||||
Taken from the [tests/annotated_binary](https://github.com/google/flatbuffers/tree/master/tests/annotated_binary).
|
||||
|
||||
```sh
|
||||
cd tests/annotated_binary
|
||||
../../flatc --annotate annotated_binary.fbs -- annotated_binary.bin
|
||||
```
|
||||
|
||||
Which will produce a `annotated_binary.afb` file in the current directory.
|
||||
|
||||
The `annotated_binary.bin` is the flatbufer binary of the data contained within
|
||||
`annotated_binary.json`, which was made by the following command:
|
||||
|
||||
```sh
|
||||
..\..\flatc -b annotated_binary.fbs annotated_binary.json
|
||||
```
|
||||
|
||||
## .afb Text Format
|
||||
|
||||
Currently there is a built-in text-based format for outputting the annotations.
|
||||
A full example is shown here:
|
||||
[`annotated_binary.afb`](https://github.com/google/flatbuffers/blob/master/tests/annotated_binary/annotated_binary.afb)
|
||||
|
||||
The data is organized as a table with fixed [columns](#columns) grouped into
|
||||
Binary [sections](#binary-sections) and [regions](#binary-regions), starting
|
||||
from the beginning of the binary (offset `0`).
|
||||
|
||||
### Columns
|
||||
|
||||
The columns are as follows:
|
||||
|
||||
1. The offset from the start of the binary, expressed in hexadecimal format
|
||||
(e.g. `+0x003c`).
|
||||
|
||||
The prefix `+` is added to make searching for the offset (compared to some
|
||||
random value) a bit easier.
|
||||
|
||||
2. The raw binary data, expressed in hexadecimal format.
|
||||
|
||||
This is in the little endian format the buffer uses internally and what you
|
||||
would see with a normal binary text viewer.
|
||||
|
||||
3. The type of the data.
|
||||
|
||||
This may be the type specified in the schema or some internally defined
|
||||
types:
|
||||
|
||||
|
||||
| Internal Type | Purpose |
|
||||
|---------------|----------------------------------------------------|
|
||||
| `VOffset16` | Virtual table offset, relative to the table offset |
|
||||
| `UOffset32` | Unsigned offset, relative to the current offset |
|
||||
| `SOffset32` | Signed offset, relative to the current offset |
|
||||
|
||||
|
||||
4. The value of the data.
|
||||
|
||||
This is shown in big endian format that is generally written for humans to
|
||||
consume (e.g. `0x0013`). As well as the "casted" value (e.g. `0x0013 `is
|
||||
`19` in decimal) in parentheses.
|
||||
|
||||
5. Notes about the particular data.
|
||||
|
||||
This describes what the data is about, either some internal usage, or tied
|
||||
to the schema.
|
||||
|
||||
### Binary Sections
|
||||
|
||||
The file is broken up into Binary Sections, which are comprised of contiguous
|
||||
[binary regions](#binary-regions) that are logically grouped together. For
|
||||
example, a binary section may be a single instance of a flatbuffer `Table` or
|
||||
its `vtable`. The sections may be labelled with the name of the associated type,
|
||||
as defined in the input schema.
|
||||
|
||||
An example of a `vtable` Binary Section that is associated with the user-defined
|
||||
`AnnotateBinary.Bar` table.
|
||||
|
||||
```
|
||||
vtable (AnnotatedBinary.Bar):
|
||||
+0x00A0 | 08 00 | uint16_t | 0x0008 (8) | size of this vtable
|
||||
+0x00A2 | 13 00 | uint16_t | 0x0013 (19) | size of referring table
|
||||
+0x00A4 | 08 00 | VOffset16 | 0x0008 (8) | offset to field `a` (id: 0)
|
||||
+0x00A6 | 04 00 | VOffset16 | 0x0004 (4) | offset to field `b` (id: 1)
|
||||
```
|
||||
|
||||
These are purely annotative, there is no embedded information about these
|
||||
regions in the flatbuffer itself.
|
||||
|
||||
### Binary Regions
|
||||
|
||||
Binary regions are contiguous bytes regions that are grouped together to form
|
||||
some sort of value, e.g. a `scalar` or an array of scalars. A binary region may
|
||||
be split up over multiple text lines, if the size of the region is large.
|
||||
|
||||
#### Annotation Example
|
||||
|
||||
Looking at an example binary region:
|
||||
|
||||
```
|
||||
vtable (AnnotatedBinary.Bar):
|
||||
+0x00A0 | 08 00 | uint16_t | 0x0008 (8) | size of this vtable
|
||||
```
|
||||
|
||||
The first column (`+0x00A0`) is the offset to this region from the beginning of
|
||||
the buffer.
|
||||
|
||||
The second column are the raw bytes (hexadecimal) that make up this region.
|
||||
These are expressed in the little-endian format that flatbuffers uses for the
|
||||
wire format.
|
||||
|
||||
The third column is the type to interpret the bytes as. For the above example,
|
||||
the type is `uint16_t` which is a 16-bit unsigned integer type.
|
||||
|
||||
The fourth column shows the raw bytes as a compacted, big-endian value. The raw
|
||||
bytes are duplicated in this fashion since it is more intuitive to read the data
|
||||
in the big-endian format (e.g., `0x0008`). This value is followed by the decimal
|
||||
representation of the value (e.g., `(8)`). For strings, the raw string value is
|
||||
shown instead.
|
||||
|
||||
The fifth column is a textual comment on what the value is. As much metadata as
|
||||
known is provided.
|
||||
|
||||
### Offsets
|
||||
|
||||
If the type in the 3rd column is of an absolute offset (`SOffet32` or
|
||||
`Offset32`), the fourth column also shows an `Loc: +0x025A` value which shows
|
||||
where in the binary this region is pointing to. These values are absolute from
|
||||
the beginning of the file, their calculation from the raw value in the 4th
|
||||
column depends on the context.
|
||||
318
docs/source/assets/flatbuffers_logo.svg
Normal file
@@ -0,0 +1,318 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="48"
|
||||
height="48"
|
||||
viewBox="0 0 12.699999 12.699999"
|
||||
version="1.1"
|
||||
id="svg5"
|
||||
xml:space="preserve"
|
||||
inkscape:version="1.2.1 (9c6d41e410, 2022-07-14)"
|
||||
sodipodi:docname="flatbuffer_logo.svg"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
|
||||
id="namedview7"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:document-units="mm"
|
||||
showgrid="false"
|
||||
inkscape:zoom="16"
|
||||
inkscape:cx="30.03125"
|
||||
inkscape:cy="31.0625"
|
||||
inkscape:window-width="2560"
|
||||
inkscape:window-height="1377"
|
||||
inkscape:window-x="2552"
|
||||
inkscape:window-y="-8"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="layer1" /><defs
|
||||
id="defs2"><linearGradient
|
||||
inkscape:collect="always"
|
||||
id="linearGradient51996"><stop
|
||||
style="stop-color:#ff0c0c;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop51992" /><stop
|
||||
style="stop-color:#ffc402;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop51994" /></linearGradient><inkscape:path-effect
|
||||
effect="mirror_symmetry"
|
||||
start_point="78.68,115.48"
|
||||
end_point="78.68,120.48705"
|
||||
center_point="78.68,117.98353"
|
||||
id="path-effect36913"
|
||||
is_visible="true"
|
||||
lpeversion="1.2"
|
||||
lpesatellites=""
|
||||
mode="free"
|
||||
discard_orig_path="false"
|
||||
fuse_paths="true"
|
||||
oposite_fuse="true"
|
||||
split_items="false"
|
||||
split_open="false"
|
||||
link_styles="false" /><inkscape:path-effect
|
||||
effect="mirror_symmetry"
|
||||
start_point="78.68,115.48"
|
||||
end_point="78.68,120.48705"
|
||||
center_point="78.68,117.98353"
|
||||
id="path-effect36913-5"
|
||||
is_visible="true"
|
||||
lpeversion="1.2"
|
||||
lpesatellites=""
|
||||
mode="free"
|
||||
discard_orig_path="false"
|
||||
fuse_paths="true"
|
||||
oposite_fuse="true"
|
||||
split_items="false"
|
||||
split_open="false"
|
||||
link_styles="false" /><linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient51996"
|
||||
id="linearGradient51998"
|
||||
x1="78.572853"
|
||||
y1="121.57343"
|
||||
x2="78.605698"
|
||||
y2="123.67016"
|
||||
gradientUnits="userSpaceOnUse" /><linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient51996"
|
||||
id="linearGradient1071"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="78.572853"
|
||||
y1="121.57343"
|
||||
x2="78.605698"
|
||||
y2="123.67016" /><linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient51996"
|
||||
id="linearGradient1073"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="78.572853"
|
||||
y1="121.57343"
|
||||
x2="78.605698"
|
||||
y2="123.67016" /><linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient51996"
|
||||
id="linearGradient1075"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="78.572853"
|
||||
y1="121.57343"
|
||||
x2="78.579903"
|
||||
y2="124.25231" /><linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient51996"
|
||||
id="linearGradient1077"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="78.572853"
|
||||
y1="121.57343"
|
||||
x2="78.605698"
|
||||
y2="123.67016" /><linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient51996"
|
||||
id="linearGradient1079"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="78.572853"
|
||||
y1="121.57343"
|
||||
x2="78.605698"
|
||||
y2="123.67016" /><linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient51996"
|
||||
id="linearGradient1081"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="78.572853"
|
||||
y1="121.57343"
|
||||
x2="78.605698"
|
||||
y2="123.67016" /><linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient51996"
|
||||
id="linearGradient1083"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="78.572853"
|
||||
y1="121.57343"
|
||||
x2="78.605698"
|
||||
y2="123.67016" /><linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient51996"
|
||||
id="linearGradient1085"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="78.572853"
|
||||
y1="121.57343"
|
||||
x2="78.605698"
|
||||
y2="123.67016" /><linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient51996"
|
||||
id="linearGradient1087"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="78.572853"
|
||||
y1="121.57343"
|
||||
x2="78.605698"
|
||||
y2="123.67016" /><linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient51996"
|
||||
id="linearGradient1089"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="78.572853"
|
||||
y1="121.57343"
|
||||
x2="78.605698"
|
||||
y2="123.67016" /><linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient51996"
|
||||
id="linearGradient1091"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="78.572853"
|
||||
y1="121.57343"
|
||||
x2="78.605698"
|
||||
y2="123.67016" /><linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient51996"
|
||||
id="linearGradient1093"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="78.572853"
|
||||
y1="121.57343"
|
||||
x2="78.605698"
|
||||
y2="123.67016" /><linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient51996"
|
||||
id="linearGradient1095"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="78.572853"
|
||||
y1="121.57343"
|
||||
x2="78.605698"
|
||||
y2="123.67016" /><linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient51996"
|
||||
id="linearGradient1097"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="78.572853"
|
||||
y1="121.57343"
|
||||
x2="78.605698"
|
||||
y2="123.67016" /><linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient51996"
|
||||
id="linearGradient1099"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="78.572853"
|
||||
y1="121.57343"
|
||||
x2="78.605698"
|
||||
y2="123.67016" /><linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient51996"
|
||||
id="linearGradient1101"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="78.572853"
|
||||
y1="121.57343"
|
||||
x2="78.605698"
|
||||
y2="123.67016" /></defs><g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"><path
|
||||
style="fill:#ee2349;fill-opacity:1;stroke-width:0.264583"
|
||||
d="m 78.679688,115.50977 c -0.120712,0.0641 -0.42793,0.23077 -0.582032,0.34961 -0.183353,0.14139 -0.341667,0.2967 -0.496094,0.48632 -0.09316,0.11439 -0.175141,0.29861 -0.208984,0.46485 -0.05593,0.27473 -0.01958,0.56221 0.01953,0.83984 0.0674,0.47849 0.369141,1.40234 0.369141,1.40234 0,0 -0.370215,0.25236 -0.529297,0.40821 -0.08369,0.082 -0.134669,0.16526 -0.179687,0.27344 -0.06269,0.15064 -0.0906,0.32319 -0.09375,0.48632 -0.0016,0.0822 0.01367,0.26563 0.01367,0.26563 -10e-7,0 0.365376,-0.37098 0.609374,-0.45117 0.135542,-0.0445 0.296791,-0.0606 0.427735,-0.004 0.05341,0.0231 0.05909,0.12539 0.117187,0.12891 0.134803,0.008 0.418285,0.003 0.533204,0 0.114918,0.003 0.3984,0.008 0.533203,0 0.05809,-0.004 0.06378,-0.10581 0.117187,-0.12891 0.130944,-0.0567 0.294146,-0.0406 0.429688,0.004 0.243998,0.0802 0.607422,0.45117 0.607422,0.45117 0,0 0.01722,-0.18343 0.01562,-0.26563 -0.0031,-0.16313 -0.03106,-0.33569 -0.09375,-0.48632 -0.04502,-0.10818 -0.09795,-0.19144 -0.18164,-0.27344 -0.159082,-0.15585 -0.529297,-0.40821 -0.529297,-0.40821 0,0 0.303694,-0.92385 0.371094,-1.40234 0.03911,-0.27763 0.07351,-0.56511 0.01758,-0.83984 -0.03384,-0.16624 -0.115825,-0.35046 -0.208985,-0.46485 -0.154426,-0.18962 -0.31274,-0.34493 -0.496093,-0.48632 -0.154102,-0.11884 -0.46132,-0.28549 -0.582031,-0.34961 z"
|
||||
id="path36791-6"
|
||||
sodipodi:nodetypes="csssscssscssscc"
|
||||
class="UnoptimicedTransforms"
|
||||
transform="matrix(-1.5867841,0,0,1.5867841,131.19823,-183.26425)"
|
||||
inkscape:path-effect="#path-effect36913"
|
||||
inkscape:original-d="m 78.629702,115.48256 c 0,0 0.438268,0.22675 0.632602,0.37661 0.183353,0.1414 0.340934,0.29733 0.49536,0.48695 0.09316,0.11439 0.17524,0.29778 0.209083,0.46402 0.05593,0.27473 0.02088,0.56327 -0.01823,0.8409 -0.0674,0.47849 -0.370162,1.40159 -0.370162,1.40159 0,0 0.369865,0.25228 0.528947,0.40813 0.08369,0.082 0.136292,0.16564 0.18131,0.27381 0.06269,0.15064 0.09017,0.32334 0.09332,0.48647 0.0016,0.0822 -0.01413,0.26601 -0.01413,0.26601 0,0 -0.36491,-0.37107 -0.608908,-0.45126 -0.135542,-0.0445 -0.29706,-0.0607 -0.428004,-0.004 -0.05341,0.0231 -0.06025,0.12485 -0.118343,0.12837 -0.171522,0.0104 -0.582695,-0.002 -0.582695,-0.002 z" /><circle
|
||||
style="fill:#ffffff;fill-opacity:1;stroke-width:0.461723"
|
||||
id="path37027"
|
||||
cx="6.346231"
|
||||
cy="2.3943322"
|
||||
r="1.2447678" /><circle
|
||||
style="font-variation-settings:normal;vector-effect:none;fill:#ffc402;fill-opacity:1;stroke-width:0.141574;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000"
|
||||
id="path37568-5-9-1-3-6-1"
|
||||
cx="6.5362368"
|
||||
cy="12.559268"
|
||||
r="0.11592077" /><g
|
||||
id="g51228"
|
||||
style="fill:url(#linearGradient51998);fill-opacity:1"
|
||||
transform="matrix(1.5867841,0,0,1.5867841,-120.3592,-185.13424)"><circle
|
||||
style="fill:url(#linearGradient1071);fill-opacity:1;stroke-width:0.224809"
|
||||
id="path37568"
|
||||
cx="79.219589"
|
||||
cy="121.77583"
|
||||
r="0.18407404" /><circle
|
||||
style="font-variation-settings:normal;opacity:1;vector-effect:none;fill:url(#linearGradient1073);fill-opacity:1;stroke-width:0.377183;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000;stop-opacity:1"
|
||||
id="path37568-5"
|
||||
cx="79.928802"
|
||||
cy="121.81054"
|
||||
r="0.30883789" /><circle
|
||||
style="font-variation-settings:normal;vector-effect:none;fill:url(#linearGradient1075);fill-opacity:1;stroke-width:0.518098;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000"
|
||||
id="path37568-5-9"
|
||||
cx="79.265541"
|
||||
cy="122.34314"
|
||||
r="0.42421949" /><circle
|
||||
style="font-variation-settings:normal;vector-effect:none;fill:url(#linearGradient1077);fill-opacity:1;stroke-width:0.194865;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000"
|
||||
id="path37568-5-9-8"
|
||||
cx="78.911224"
|
||||
cy="122.55578"
|
||||
r="0.15955541" /><circle
|
||||
style="font-variation-settings:normal;vector-effect:none;fill:url(#linearGradient1079);fill-opacity:1;stroke-width:0.317766;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000"
|
||||
id="path37568-5-9-1"
|
||||
cx="79.634331"
|
||||
cy="122.87711"
|
||||
r="0.26018718" /><circle
|
||||
style="font-variation-settings:normal;vector-effect:none;fill:url(#linearGradient1081);fill-opacity:1;stroke-width:0.378906;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000"
|
||||
id="path37568-5-9-1-3"
|
||||
cx="80.265633"
|
||||
cy="123.65545"
|
||||
r="0.31024873" /><circle
|
||||
style="font-variation-settings:normal;vector-effect:none;fill:url(#linearGradient1083);fill-opacity:1;stroke-width:0.177006;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000"
|
||||
id="path37568-5-9-1-3-6"
|
||||
cx="79.914619"
|
||||
cy="124.27737"
|
||||
r="0.14493258" /><circle
|
||||
style="font-variation-settings:normal;vector-effect:none;fill:url(#linearGradient1085);fill-opacity:1;stroke-width:0.0989143;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000"
|
||||
id="path37568-5-9-1-3-6-6"
|
||||
cx="80.206474"
|
||||
cy="124.00723"
|
||||
r="0.080991074" /><circle
|
||||
style="font-variation-settings:normal;vector-effect:none;fill:url(#linearGradient1087);fill-opacity:1;stroke-width:0.221224;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000"
|
||||
id="path37568-5-9-1-3-6-0"
|
||||
cx="79.695312"
|
||||
cy="123.76383"
|
||||
r="0.18113838" /><ellipse
|
||||
style="font-variation-settings:normal;vector-effect:none;fill:url(#linearGradient1089);fill-opacity:1;stroke-width:0.271828;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000"
|
||||
id="path37568-5-9-1-3-6-0-6"
|
||||
cx="79.60508"
|
||||
cy="123.37116"
|
||||
rx="0.22375529"
|
||||
ry="0.22139755" /><ellipse
|
||||
style="font-variation-settings:normal;vector-effect:none;fill:url(#linearGradient1091);fill-opacity:1;stroke-width:0.271828;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000"
|
||||
id="path37568-5-9-1-3-6-0-6-7"
|
||||
cx="79.846291"
|
||||
cy="123.10796"
|
||||
rx="0.22375529"
|
||||
ry="0.22139755" /><ellipse
|
||||
style="font-variation-settings:normal;vector-effect:none;fill:url(#linearGradient1093);fill-opacity:1;stroke-width:0.244555;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000"
|
||||
id="path37568-5-9-1-3-6-0-6-2"
|
||||
cx="79.247681"
|
||||
cy="123.40287"
|
||||
rx="0.19959654"
|
||||
ry="0.20088845" /><circle
|
||||
style="font-variation-settings:normal;vector-effect:none;fill:url(#linearGradient1095);fill-opacity:1;stroke-width:0.243037;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000"
|
||||
id="path37568-5-9-1-2"
|
||||
cx="80.333969"
|
||||
cy="122.72621"
|
||||
r="0.19899905" /><circle
|
||||
style="font-variation-settings:normal;vector-effect:none;fill:url(#linearGradient1097);fill-opacity:1;stroke-width:0.282009;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000"
|
||||
id="path37568-5-9-1-2-0-9"
|
||||
cx="80.747818"
|
||||
cy="122.34882"
|
||||
r="0.23090924" /><circle
|
||||
style="font-variation-settings:normal;vector-effect:none;fill:url(#linearGradient1099);fill-opacity:1;stroke-width:0.313683;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;-inkscape-stroke:none;stop-color:#000000"
|
||||
id="path37568-5-9-1-2-7"
|
||||
cx="80.58844"
|
||||
cy="122.97715"
|
||||
r="0.25684434" /><circle
|
||||
style="fill:url(#linearGradient1101);fill-opacity:1;stroke-width:0.426803"
|
||||
id="path37568-5-6"
|
||||
cx="80.422928"
|
||||
cy="122.06255"
|
||||
r="0.34946665" /></g></g></svg>
|
||||
|
After Width: | Height: | Size: 16 KiB |
63
docs/source/benchmarks.md
Normal file
@@ -0,0 +1,63 @@
|
||||
C++ Benchmarks {#flatbuffers_benchmarks}
|
||||
==========
|
||||
|
||||
Comparing against other serialization solutions, running on Windows 7
|
||||
64bit. We use the LITE runtime for Protocol Buffers (less code / lower
|
||||
overhead), Rapid JSON (one of the fastest C++ JSON parsers around),
|
||||
and pugixml, also one of the fastest XML parsers.
|
||||
|
||||
We also compare against code that doesn't use a serialization library
|
||||
at all (the column "Raw structs"), which is what you get if you write
|
||||
hardcoded code that just writes structs. This is the fastest possible,
|
||||
but of course is not cross platform nor has any kind of forwards /
|
||||
backwards compatibility.
|
||||
|
||||
We compare against Flatbuffers with the binary wire format (as
|
||||
intended), and also with JSON as the wire format with the optional JSON
|
||||
parser (which, using a schema, parses JSON into a binary buffer that can
|
||||
then be accessed as before).
|
||||
|
||||
The benchmark object is a set of about 10 objects containing an array, 4
|
||||
strings, and a large variety of int/float scalar values of all sizes,
|
||||
meant to be representative of game data, e.g. a scene format.
|
||||
|
||||
| | FlatBuffers (binary) | Protocol Buffers LITE | Rapid JSON | FlatBuffers (JSON) | pugixml | Raw structs |
|
||||
|--------------------------------------------------------|-----------------------|-----------------------|-----------------------|------------------------| ----------------------| ----------------------|
|
||||
| Decode + Traverse + Dealloc (1 million times, seconds) | 0.08 | 302 | 583 | 105 | 196 | 0.02 |
|
||||
| Decode / Traverse / Dealloc (breakdown) | 0 / 0.08 / 0 | 220 / 0.15 / 81 | 294 / 0.9 / 287 | 70 / 0.08 / 35 | 41 / 3.9 / 150 | 0 / 0.02 / 0 |
|
||||
| Encode (1 million times, seconds) | 3.2 | 185 | 650 | 169 | 273 | 0.15 |
|
||||
| Wire format size (normal / zlib, bytes) | 344 / 220 | 228 / 174 | 1475 / 322 | 1029 / 298 | 1137 / 341 | 312 / 187 |
|
||||
| Memory needed to store decoded wire (bytes / blocks) | 0 / 0 | 760 / 20 | 65689 / 4 | 328 / 1 | 34194 / 3 | 0 / 0 |
|
||||
| Transient memory allocated during decode (KB) | 0 | 1 | 131 | 4 | 34 | 0 |
|
||||
| Generated source code size (KB) | 4 | 61 | 0 | 4 | 0 | 0 |
|
||||
| Field access in handwritten traversal code | typed accessors | typed accessors | manual error checking | typed accessors | manual error checking | typed but no safety |
|
||||
| Library source code (KB) | 15 | some subset of 3800 | 87 | 43 | 327 | 0 |
|
||||
|
||||
### Some other serialization systems we compared against but did not benchmark (yet), in rough order of applicability:
|
||||
|
||||
- Cap'n'Proto promises to reduce Protocol Buffers much like FlatBuffers does,
|
||||
though with a more complicated binary encoding and less flexibility (no
|
||||
optional fields to allow deprecating fields or serializing with missing
|
||||
fields for which defaults exist).
|
||||
It currently also isn't fully cross-platform portable (lack of VS support).
|
||||
- msgpack: has very minimal forwards/backwards compatibility support when used
|
||||
with the typed C++ interface. Also lacks VS2010 support.
|
||||
- Thrift: very similar to Protocol Buffers, but appears to be less efficient,
|
||||
and have more dependencies.
|
||||
- YAML: a superset of JSON and otherwise very similar. Used by e.g. Unity.
|
||||
- C# comes with built-in serialization functionality, as used by Unity also.
|
||||
Being tied to the language, and having no automatic versioning support
|
||||
limits its applicability.
|
||||
- Project Anarchy (the free mobile engine by Havok) comes with a serialization
|
||||
system, that however does no automatic versioning (have to code around new
|
||||
fields manually), is very much tied to the rest of the engine, and works
|
||||
without a schema to generate code (tied to your C++ class definition).
|
||||
|
||||
### Code for benchmarks
|
||||
|
||||
Code for these benchmarks sits in `benchmarks/` in git branch `benchmarks`.
|
||||
It sits in its own branch because it has submodule dependencies that the main
|
||||
project doesn't need, and the code standards do not meet those of the main
|
||||
project. Please read `benchmarks/cpp/README.txt` before working with the code.
|
||||
|
||||
<br>
|
||||
177
docs/source/building.md
Normal file
@@ -0,0 +1,177 @@
|
||||
# Building
|
||||
|
||||
## Building with CMake
|
||||
|
||||
The distribution main build system is configured by
|
||||
[`cmake`](https://www.cmake.org) which allows you to build the project for any
|
||||
platform.
|
||||
|
||||
### Configuration
|
||||
|
||||
Use `cmake` to configure a project based on your environment and platform.
|
||||
|
||||
=== "Unix"
|
||||
|
||||
```sh
|
||||
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
|
||||
```
|
||||
|
||||
To use `clang` instead of `gcc` you may need to set prepend some environment
|
||||
variables e.g. `CC=/usr/bin/clang CXX=/usr/bin/clang++ cmake -G "Unix
|
||||
MakeFiles"`
|
||||
|
||||
=== "Windows"
|
||||
|
||||
```sh
|
||||
cmake -G "Visual Studio 17 2022" -DCMAKE_BUILD_TYPE=Release
|
||||
```
|
||||
|
||||
=== "MacOS"
|
||||
|
||||
```sh
|
||||
cmake -G "Xcode" -DCMAKE_BUILD_TYPE=Release
|
||||
```
|
||||
|
||||
#### Strict Mode
|
||||
|
||||
By default, `cmake` will configure targets to **not** build with strict warnings
|
||||
on (e.g. `-Werror` or `/WX`). This may cause into issues when submitting code
|
||||
changes since our CI requires the code to compile in strict mode.
|
||||
|
||||
To enable the extra warnings, turn on strict mode with the
|
||||
`FLATBUFFERS_STRICT_MODE` cmake option.
|
||||
|
||||
```cmake
|
||||
cmake -DFLATBUFFERS_STRICT_MODE=ON
|
||||
```
|
||||
|
||||
|
||||
### Building
|
||||
|
||||
Once the project files are generated, build as normal for your platform.
|
||||
|
||||
=== "Unix"
|
||||
|
||||
```sh
|
||||
make -j
|
||||
```
|
||||
|
||||
=== "Windows"
|
||||
|
||||
```sh
|
||||
msbuild.exe FlatBuffers.sln
|
||||
```
|
||||
|
||||
=== "MacOS"
|
||||
|
||||
```sh
|
||||
xcodebuild -toolchain clang -configuration Release
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## Building with Bazel
|
||||
|
||||
You can use [Bazelisk](https://github.com/bazelbuild/bazelisk) to manage your Bazel environment.
|
||||
For Swift support, you also need Clang and [Swift SDK](https://download.swift.org/).
|
||||
|
||||
```sh
|
||||
curl -sL --fail https://github.com/bazelbuild/bazelisk/releases/download/v1.25.0/bazelisk-linux-amd64 -o bazelisk && chmod +x bazelisk
|
||||
sudo apt install -y clang
|
||||
SWIFT_VERSION="6.0.3"
|
||||
curl -L https://download.swift.org/swift-${SWIFT_VERSION}-release/debian12/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-debian12.tar.gz | tar xz
|
||||
CC=clang PATH=$PATH:$(pwd)/swift-${SWIFT_VERSION}-RELEASE-debian12/usr/bin bazel build //...
|
||||
CC=clang PATH=$PATH:$(pwd)/swift-${SWIFT_VERSION}-RELEASE-debian12/usr/bin bazel test //...
|
||||
```
|
||||
|
||||
If you are unsure which versions to use, check our CI config at `.bazelci/presubmit.yml`.
|
||||
|
||||
## Building with VCPKG
|
||||
|
||||
You can download and install flatbuffers using the [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager:
|
||||
|
||||
git clone https://github.com/Microsoft/vcpkg.git
|
||||
cd vcpkg
|
||||
./bootstrap-vcpkg.sh
|
||||
./vcpkg integrate install
|
||||
./vcpkg install flatbuffers
|
||||
|
||||
The flatbuffers port in vcpkg is kept up to date by Microsoft team members and community contributors.
|
||||
If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
|
||||
|
||||
|
||||
|
||||
## Building for Android
|
||||
|
||||
There is a `flatbuffers/android` directory that contains all you need to build
|
||||
the test executable on android (use the included `build_apk.sh` script, or use
|
||||
`ndk_build` / `adb` etc. as usual). Upon running, it will output to the log
|
||||
if tests succeeded or not.
|
||||
|
||||
You may also run an android sample from inside the `flatbuffers/samples`, by
|
||||
running the `android_sample.sh` script. Optionally, you may go to the
|
||||
`flatbuffers/samples/android` folder and build the sample with the
|
||||
`build_apk.sh` script or `ndk_build` / `adb` etc.
|
||||
|
||||
## Using FlatBuffers in your own projects
|
||||
|
||||
For C++, there is usually no runtime to compile, as the code consists of a
|
||||
single header, `include/flatbuffers/flatbuffers.h`. You should add the
|
||||
`include` folder to your include paths. If you wish to be
|
||||
able to load schemas and/or parse text into binary buffers at runtime,
|
||||
you additionally need the other headers in `include/flatbuffers`. You must
|
||||
also compile/link `src/idl_parser.cpp` (and `src/idl_gen_text.cpp` if you
|
||||
also want to be able convert binary to text).
|
||||
|
||||
To see how to include FlatBuffers in any of our supported languages, please
|
||||
view the [Tutorial](tutorial.md) and select your appropriate
|
||||
language using the radio buttons.
|
||||
|
||||
### Using in CMake-based projects
|
||||
If you want to use FlatBuffers in a project which already uses CMake, then a more
|
||||
robust and flexible approach is to build FlatBuffers as part of that project directly.
|
||||
This is done by making the FlatBuffers source code available to the main build
|
||||
and adding it using CMake's `add_subdirectory()` command. This has the
|
||||
significant advantage that the same compiler and linker settings are used
|
||||
between FlatBuffers and the rest of your project, so issues associated with using
|
||||
incompatible libraries (eg debug/release), etc. are avoided. This is
|
||||
particularly useful on Windows.
|
||||
|
||||
Suppose you put FlatBuffers source code in directory `${FLATBUFFERS_SRC_DIR}`.
|
||||
To build it as part of your project, add following code to your `CMakeLists.txt` file:
|
||||
```cmake
|
||||
# Add FlatBuffers directly to our build. This defines the `flatbuffers` target.
|
||||
add_subdirectory(${FLATBUFFERS_SRC_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/flatbuffers-build
|
||||
EXCLUDE_FROM_ALL)
|
||||
|
||||
# Now simply link against flatbuffers as needed to your already declared target.
|
||||
# The flatbuffers target carry header search path automatically if CMake > 2.8.11.
|
||||
target_link_libraries(own_project_target PRIVATE flatbuffers)
|
||||
```
|
||||
When build your project the `flatbuffers` library will be compiled and linked
|
||||
to a target as part of your project.
|
||||
|
||||
#### Override default depth limit of nested objects
|
||||
To override [the depth limit of recursion](languages/cpp.md),
|
||||
add this directive:
|
||||
```cmake
|
||||
set(FLATBUFFERS_MAX_PARSING_DEPTH 16)
|
||||
```
|
||||
to `CMakeLists.txt` file before `add_subdirectory(${FLATBUFFERS_SRC_DIR})` line.
|
||||
|
||||
## Downloading binaries
|
||||
You can download the binaries from the
|
||||
[GitHub release page](https://github.com/google/flatbuffers/releases).
|
||||
|
||||
We generate [SLSA3 signatures](http://slsa.dev) using the OpenSSF's [slsa-framework/slsa-github-generator](https://github.com/slsa-framework/slsa-github-generator). To verify the binaries:
|
||||
1. Install the verification tool from [slsa-framework/slsa-verifier#installation](https://github.com/slsa-framework/slsa-verifier#installation)
|
||||
1. Download the file named `attestation.intoto.jsonl` from the GitHub release
|
||||
1. Run:
|
||||
```shell
|
||||
$ slsa-verifier -artifact-path <downloaded.zip> -provenance attestation.intoto.jsonl -source github.com/google/flatbuffers -tag <version>
|
||||
PASSED: Verified SLSA provenance
|
||||
```
|
||||
80
docs/source/contributing.md
Normal file
@@ -0,0 +1,80 @@
|
||||
# Contributing
|
||||
|
||||
We encourage community contributions to FlatBuffers through pull requests at the
|
||||
main
|
||||
[http://github.com/google/flatbuffers](http://github.com/google/flatbuffers)
|
||||
repository.
|
||||
|
||||
!!! note
|
||||
|
||||
The FlatBuffers project is not staffed by any full time Google employee, and
|
||||
is managed by a small team of 20%ers. So response time and expertise vary.
|
||||
|
||||
## Before you contribute
|
||||
|
||||
Before we can use your contributions, you __must__ sign one of the following license agreements. The agreements are self-served at the following links.
|
||||
|
||||
Our code review process will automatically check if you have signed the CLA, so
|
||||
don't fret. Though it may be prudent to check before spending a lot of time on
|
||||
contribution.
|
||||
|
||||
### Individual Contributions
|
||||
|
||||
For individuals, the [Google Individual
|
||||
Contributor License Agreement
|
||||
(CLA)](https://cla.developers.google.com/about/google-individual?csw=1) which is
|
||||
self served at the link. The CLA is required since you own the copyright to your
|
||||
changes, even after your contribution becomes part of our codebase, so we need
|
||||
your permission to use and distribute your code.
|
||||
|
||||
### Corporate Contributions
|
||||
|
||||
Contributions made by corporations are covered by the [Google Software Grant and
|
||||
Corporate Contributor License
|
||||
Agreement](https://cla.developers.google.com/about/google-corporate).
|
||||
|
||||
## Code Reviews
|
||||
|
||||
All submissions require a code review via Github Pull Requests.
|
||||
|
||||
1. Please adhere to the [Google Style Guide](https://google.github.io/styleguide/cppguide.html) for the language(s) you are submitting in.
|
||||
2. Keep PRs small and focused. Its good practice and makes it more likely your PR will be approved.
|
||||
3. Please add tests if possible.
|
||||
4. Include descriptive commit messages and context to the change/issues fixed.
|
||||
|
||||
## Documentation
|
||||
|
||||
FlatBuffers uses [MkDocs](https://www.mkdocs.org/) to generate the static
|
||||
documentation pages served at
|
||||
[https://flatbuffers.dev](https://flatbuffers.dev). Specifically, we use the
|
||||
[Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) framework.
|
||||
|
||||
The documentation source is contained in the main repo under the
|
||||
[docs/](https://github.com/google/flatbuffers/tree/master/docs) directory. This
|
||||
[automatically](https://github.com/google/flatbuffers/blob/46cc3d6432da17cca7694777dcce12e49dd48387/.github/workflows/docs.yml#L6-L11) get built and published when the commit is made.
|
||||
|
||||
### Local Development
|
||||
|
||||
We encourage contributors to keep the documentation up-to-date as well, and it
|
||||
is easy to with `MkDocs` local building and serving tools.
|
||||
|
||||
First install `mkdocs-material` (see
|
||||
[Installation](https://squidfunk.github.io/mkdocs-material/getting-started/) for
|
||||
other ways)
|
||||
|
||||
```
|
||||
pip install mkdocs-material
|
||||
pip install mkdocs-redirects
|
||||
```
|
||||
|
||||
Then, in the `root` directory of flatbuffers, run
|
||||
|
||||
```
|
||||
mkdocs serve -f docs/mkdocs.yml
|
||||
```
|
||||
|
||||
This will continually watch the repo for changes to the documentation and serve
|
||||
the rendered pages locally.
|
||||
|
||||
Submit your documentation changes with your code changes and they will
|
||||
automatically get published when your code is submitted.
|
||||