mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 04:04:19 +00:00
Compare commits
144 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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,10 +1,11 @@
|
||||
---
|
||||
buildifier: latest
|
||||
bazel: 6.4.0
|
||||
platforms:
|
||||
ubuntu1804:
|
||||
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:
|
||||
@@ -18,7 +19,7 @@ platforms:
|
||||
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:
|
||||
@@ -30,7 +31,9 @@ platforms:
|
||||
test_targets:
|
||||
- "//..."
|
||||
macos:
|
||||
xcode_version: "14.3"
|
||||
build_targets:
|
||||
- "//..."
|
||||
- "//:flatbuffers"
|
||||
- "//:flatc"
|
||||
test_targets:
|
||||
- "//..."
|
||||
- "//tests:flatbuffers_test"
|
||||
|
||||
@@ -1 +1 @@
|
||||
node_modules
|
||||
ts/node_modules
|
||||
|
||||
12
.bazelrc
12
.bazelrc
@@ -1,4 +1,12 @@
|
||||
# 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
|
||||
1
.github/labeler.yml
vendored
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'
|
||||
|
||||
205
.github/workflows/build.yml
vendored
205
.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,42 +189,14 @@ jobs:
|
||||
shell: bash
|
||||
run: echo "hashes=$(sha256sum Windows.flatc.binary.zip | base64 -w0)" >> $GITHUB_OUTPUT
|
||||
|
||||
build-windows-2017:
|
||||
name: Build Windows 2017
|
||||
runs-on: windows-2019
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Add msbuild to PATH
|
||||
uses: microsoft/setup-msbuild@v1.1
|
||||
- name: cmake
|
||||
run: cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON .
|
||||
- name: build tool version 15 (VS 2017)
|
||||
run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64 /p:VisualStudioVersion=15.0
|
||||
- name: test
|
||||
run: Release\flattests.exe
|
||||
|
||||
build-windows-2015:
|
||||
name: Build Windows 2015
|
||||
runs-on: windows-2019
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Add msbuild to PATH
|
||||
uses: microsoft/setup-msbuild@v1.1
|
||||
- name: cmake
|
||||
run: cmake -G "Visual Studio 14 2015" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON .
|
||||
- name: build tool version 14 (VS 2015)
|
||||
run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64 /p:VisualStudioVersion=14.0
|
||||
- name: test
|
||||
run: Release\flattests.exe
|
||||
|
||||
build-dotnet-windows:
|
||||
name: Build .NET Windows
|
||||
runs-on: windows-2019
|
||||
runs-on: windows-2022-64core
|
||||
strategy:
|
||||
matrix:
|
||||
configuration: [
|
||||
'',
|
||||
'-p:UnsafeByteBuffer=true',
|
||||
'-p:UnsafeByteBuffer=true',
|
||||
# Fails two tests currently.
|
||||
#'-p:EnableSpanT=true,UnsafeByteBuffer=true'
|
||||
]
|
||||
@@ -233,18 +204,18 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup .NET Core SDK
|
||||
uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: '3.1.x'
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
- name: Build
|
||||
run: |
|
||||
cd tests\FlatBuffers.Test
|
||||
dotnet new sln --force --name FlatBuffers.Core.Test
|
||||
dotnet sln FlatBuffers.Core.Test.sln add FlatBuffers.Core.Test.csproj
|
||||
dotnet build -c Release ${{matrix.configuration}} -o out FlatBuffers.Core.Test.sln
|
||||
dotnet new sln --force --name FlatBuffers.Test
|
||||
dotnet sln FlatBuffers.Test.sln add FlatBuffers.Test.csproj
|
||||
dotnet build -c Release ${{matrix.configuration}} -o out FlatBuffers.Test.sln
|
||||
- name: Run
|
||||
run: |
|
||||
cd tests\FlatBuffers.Test
|
||||
out\FlatBuffers.Core.Test.exe
|
||||
out\FlatBuffers.Test.exe
|
||||
|
||||
build-mac-intel:
|
||||
permissions:
|
||||
@@ -252,11 +223,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 +241,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 +285,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 +305,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 +324,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 +355,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 +366,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 +382,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 +418,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 +432,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 +450,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 +462,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 +474,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 +488,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 +508,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 +541,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 +556,7 @@ jobs:
|
||||
|
||||
build-nim:
|
||||
name: Build Nim
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: flatc
|
||||
@@ -568,7 +565,7 @@ jobs:
|
||||
- uses: jiro4989/setup-nim-action@v1
|
||||
- name: install library
|
||||
working-directory: nim
|
||||
run: nimble -y develop
|
||||
run: nimble -y develop && nimble install
|
||||
- name: test
|
||||
working-directory: tests/nim
|
||||
run: python3 testnim.py
|
||||
@@ -578,7 +575,7 @@ jobs:
|
||||
needs: [build-linux, build-windows, build-mac-intel, build-mac-universal]
|
||||
outputs:
|
||||
digests: ${{ steps.hash.outputs.digests }}
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Merge results
|
||||
id: hash
|
||||
|
||||
4
.github/workflows/label.yml
vendored
4
.github/workflows/label.yml
vendored
@@ -19,6 +19,6 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/labeler@main
|
||||
- uses: actions/labeler@ee18d5d34efd9b4f7dafdb0e363cb688eb438044 # 4.1.0
|
||||
with:
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
|
||||
4
.github/workflows/main.yml
vendored
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
|
||||
|
||||
82
.github/workflows/release.yml
vendored
82
.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,7 +93,7 @@ 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:
|
||||
@@ -102,5 +101,52 @@ jobs:
|
||||
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
|
||||
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_USERNAME }}
|
||||
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
|
||||
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 }}
|
||||
|
||||
2
.github/workflows/scorecards.yml
vendored
2
.github/workflows/scorecards.yml
vendored
@@ -42,7 +42,7 @@ jobs:
|
||||
|
||||
# Upload the results as artifacts (optional).
|
||||
- name: "Upload artifact"
|
||||
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # v3.0.0
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: SARIF file
|
||||
path: results.sarif
|
||||
|
||||
8
.github/workflows/stale.yml
vendored
8
.github/workflows/stale.yml
vendored
@@ -28,10 +28,10 @@ jobs:
|
||||
days-before-issue-close: 14 # 2 weeks
|
||||
exempt-issue-labels: not-stale
|
||||
|
||||
stale-pr-message: 'This pull request is stale because it has been open 3 weeks with no activity. Please comment or label `not-stale`, or this will be closed in 7 days.'
|
||||
close-pr-message: 'This pull request was automatically closed due to no activity for 3 weeks plus the 7 day notice period.'
|
||||
days-before-pr-stale: 21 # 3 weeks
|
||||
days-before-pr-close: 7 # 1 week
|
||||
stale-pr-message: 'This pull request is stale because it has been open 6 months with no activity. Please comment or label `not-stale`, or this will be closed in 14 days.'
|
||||
close-pr-message: 'This pull request was automatically closed due to no activity for 6 months plus the 14 day notice period.'
|
||||
days-before-pr-stale: 182 # 6 months
|
||||
days-before-pr-close: 14 # 2 week
|
||||
exempt-pr-labels: not-stale
|
||||
exempt-draft-pr: false
|
||||
|
||||
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -151,3 +151,7 @@ flatbuffers.pc
|
||||
# https://cmake.org/cmake/help/latest/module/FetchContent.html#variable:FETCHCONTENT_BASE_DIR
|
||||
cmake-build-debug/
|
||||
_deps/
|
||||
**/.gradle/**
|
||||
kotlin/**/generated
|
||||
MODULE.bazel
|
||||
MODULE.bazel.lock
|
||||
|
||||
14
BUILD.bazel
14
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",
|
||||
"build_defs.bzl",
|
||||
"package.json",
|
||||
"pnpm-lock.yaml",
|
||||
"typescript.bzl",
|
||||
"//grpc/src/compiler:distribution",
|
||||
"//include/codegen:distribution",
|
||||
"//reflection:distribution",
|
||||
"//src:distribution",
|
||||
"//ts:distribution",
|
||||
|
||||
13
CHANGELOG.md
13
CHANGELOG.md
@@ -4,6 +4,19 @@ All major or breaking changes will be documented in this file, as well as any
|
||||
new features that should be highlighted. Minor fixes or improvements are not
|
||||
necessarily listed.
|
||||
|
||||
## [24.3.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 24)
|
||||
set(VERSION_MINOR 12)
|
||||
set(VERSION_PATCH 23)
|
||||
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 = '24.12.23'
|
||||
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
|
||||
|
||||
6
MODULE.bazel
Normal file
6
MODULE.bazel
Normal file
@@ -0,0 +1,6 @@
|
||||
###############################################################################
|
||||
# Bazel now uses Bzlmod by default to manage external dependencies.
|
||||
# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel.
|
||||
#
|
||||
# For more details, please check https://github.com/bazelbuild/bazel/issues/18958
|
||||
###############################################################################
|
||||
1632
MODULE.bazel.lock
generated
Normal file
1632
MODULE.bazel.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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"),
|
||||
])
|
||||
|
||||
@@ -18,7 +18,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 +98,7 @@ FlatBuffers does not follow traditional SemVer versioning (see [rationale](https
|
||||
|
||||
## Community
|
||||
|
||||
* [FlatBuffers Google Group][] to discuss FlatBuffers with other developers and users.
|
||||
* [Discord Server](https:///discord.gg/6qgKs3R)
|
||||
* [Gitter](https://gitter.im/google/flatbuffers)
|
||||
|
||||
|
||||
## Security
|
||||
|
||||
|
||||
108
WORKSPACE
108
WORKSPACE
@@ -4,13 +4,41 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file"
|
||||
|
||||
http_archive(
|
||||
name = "platforms",
|
||||
sha256 = "379113459b0feaf6bfbb584a91874c065078aa673222846ac765f86661c27407",
|
||||
sha256 = "3a561c99e7bdbe9173aa653fd579fe849f1d8d67395780ab4770b1f381431d51",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.5/platforms-0.0.5.tar.gz",
|
||||
"https://github.com/bazelbuild/platforms/releases/download/0.0.5/platforms-0.0.5.tar.gz",
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz",
|
||||
"https://github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
# Import our own version of skylib before other rule sets (e.g. rules_swift)
|
||||
# has a chance to import an old version.
|
||||
http_archive(
|
||||
name = "bazel_skylib",
|
||||
sha256 = "66ffd9315665bfaafc96b52278f57c7e2dd09f5ede279ea6d39b2be471e7e3aa",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.4.2/bazel-skylib-1.4.2.tar.gz",
|
||||
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.2/bazel-skylib-1.4.2.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
|
||||
|
||||
bazel_skylib_workspace()
|
||||
|
||||
http_archive(
|
||||
name = "build_bazel_rules_apple",
|
||||
sha256 = "34c41bfb59cdaea29ac2df5a2fa79e5add609c71bb303b2ebb10985f93fa20e7",
|
||||
url = "https://github.com/bazelbuild/rules_apple/releases/download/3.1.1/rules_apple.3.1.1.tar.gz",
|
||||
)
|
||||
|
||||
load(
|
||||
"@build_bazel_rules_apple//apple:repositories.bzl",
|
||||
"apple_rules_dependencies",
|
||||
)
|
||||
|
||||
apple_rules_dependencies()
|
||||
|
||||
http_archive(
|
||||
name = "build_bazel_rules_swift",
|
||||
sha256 = "a2fd565e527f83fb3f9eb07eb9737240e668c9242d3bc318712efa54a7deda97",
|
||||
@@ -33,10 +61,10 @@ swift_rules_extra_dependencies()
|
||||
|
||||
http_archive(
|
||||
name = "io_bazel_rules_go",
|
||||
sha256 = "ae013bf35bd23234d1dea46b079f1e05ba74ac0321423830119d3e787ec73483",
|
||||
sha256 = "278b7ff5a826f3dc10f04feaf0b70d48b68748ccd512d7f98bf442077f043fe3",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.36.0/rules_go-v0.36.0.zip",
|
||||
"https://github.com/bazelbuild/rules_go/releases/download/v0.36.0/rules_go-v0.36.0.zip",
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip",
|
||||
"https://github.com/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -55,6 +83,28 @@ http_archive(
|
||||
],
|
||||
)
|
||||
|
||||
#### Building boring ssl
|
||||
# Fetching boringssl within the flatbuffers repository, to patch the issue
|
||||
# of not being able to upgrade to Xcode 14.3 due to buildkite throwing errors
|
||||
# which was patched in the following below.
|
||||
# https://github.com/google/flatbuffers/commit/67eb95de9281087ccbba9aafd6e8ab1958d12045
|
||||
# The patch was copied from the following comment on the same issue within tensorflow
|
||||
# and fixed to adapt the already existing patch for boringssl.
|
||||
# https://github.com/tensorflow/tensorflow/issues/60191#issuecomment-1496073147
|
||||
http_archive(
|
||||
name = "boringssl",
|
||||
patch_args = ["-p1"],
|
||||
patches = ["//grpc:boringssl.patch"],
|
||||
# Use github mirror instead of https://boringssl.googlesource.com/boringssl
|
||||
# to obtain a boringssl archive with consistent sha256
|
||||
sha256 = "534fa658bd845fd974b50b10f444d392dfd0d93768c4a51b61263fd37d851c40",
|
||||
strip_prefix = "boringssl-b9232f9e27e5668bc0414879dcdedb2a59ea75f2",
|
||||
urls = [
|
||||
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/google/boringssl/archive/b9232f9e27e5668bc0414879dcdedb2a59ea75f2.tar.gz",
|
||||
"https://github.com/google/boringssl/archive/b9232f9e27e5668bc0414879dcdedb2a59ea75f2.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
##### GRPC
|
||||
_GRPC_VERSION = "1.49.0" # https://github.com/grpc/grpc/releases/tag/v1.48.0
|
||||
|
||||
@@ -79,24 +129,24 @@ grpc_extra_deps()
|
||||
|
||||
http_archive(
|
||||
name = "aspect_rules_js",
|
||||
sha256 = "124ed29fb0b3d0cba5b44f8f8e07897cf61b34e35e33b1f83d1a943dfd91b193",
|
||||
strip_prefix = "rules_js-1.24.0",
|
||||
url = "https://github.com/aspect-build/rules_js/releases/download/v1.24.0/rules_js-v1.24.0.tar.gz",
|
||||
sha256 = "76a04ef2120ee00231d85d1ff012ede23963733339ad8db81f590791a031f643",
|
||||
strip_prefix = "rules_js-1.34.1",
|
||||
url = "https://github.com/aspect-build/rules_js/releases/download/v1.34.1/rules_js-v1.34.1.tar.gz",
|
||||
)
|
||||
|
||||
load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")
|
||||
|
||||
rules_js_dependencies()
|
||||
|
||||
load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock", "pnpm_repository")
|
||||
load("@aspect_rules_js//npm:npm_import.bzl", "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",
|
||||
sha256 = "4c3f34fff9f96ffc9c26635d8235a32a23a6797324486c7d23c1dfa477e8b451",
|
||||
strip_prefix = "rules_ts-1.4.5",
|
||||
url = "https://github.com/aspect-build/rules_ts/releases/download/v1.4.5/rules_ts-v1.4.5.tar.gz",
|
||||
)
|
||||
|
||||
load("@aspect_rules_ts//ts:repositories.bzl", "rules_ts_dependencies")
|
||||
@@ -104,8 +154,8 @@ load("@aspect_rules_ts//ts:repositories.bzl", "rules_ts_dependencies")
|
||||
rules_ts_dependencies(
|
||||
# Since rules_ts doesn't always have the newest integrity hashes, we
|
||||
# compute it manually here.
|
||||
# $ curl --silent https://registry.npmjs.org/typescript/5.0.4 | jq ._integrity
|
||||
ts_integrity = "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==",
|
||||
# $ curl --silent https://registry.npmjs.org/typescript/5.3.3 | jq ._integrity
|
||||
ts_integrity = "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==",
|
||||
ts_version_from = "//:package.json",
|
||||
)
|
||||
|
||||
@@ -116,41 +166,37 @@ nodejs_register_toolchains(
|
||||
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("@com_github_google_flatbuffers//ts:repositories.bzl", "flatbuffers_npm")
|
||||
|
||||
flatbuffers_npm(
|
||||
name = "flatbuffers_npm",
|
||||
)
|
||||
|
||||
load("@npm//:repositories.bzl", "npm_repositories")
|
||||
load("@flatbuffers_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",
|
||||
sha256 = "098e38e5ee868c14a6484ba263b79e57d48afacfc361ba30137c757a9c4716d6",
|
||||
strip_prefix = "rules_esbuild-0.15.0",
|
||||
url = "https://github.com/aspect-build/rules_esbuild/releases/download/v0.15.0/rules_esbuild-v0.15.0.tar.gz",
|
||||
)
|
||||
|
||||
# Register a toolchain containing esbuild npm package and native bindings
|
||||
load("@aspect_rules_esbuild//esbuild:repositories.bzl", "LATEST_VERSION", "esbuild_register_toolchains")
|
||||
load("@aspect_rules_esbuild//esbuild:repositories.bzl", "LATEST_ESBUILD_VERSION", "esbuild_register_toolchains")
|
||||
|
||||
esbuild_register_toolchains(
|
||||
name = "esbuild",
|
||||
esbuild_version = LATEST_VERSION,
|
||||
esbuild_version = LATEST_ESBUILD_VERSION,
|
||||
)
|
||||
|
||||
http_file(
|
||||
name = "bazel_linux_x86_64",
|
||||
downloaded_file_path = "bazel",
|
||||
executable = True,
|
||||
sha256 = "e89747d63443e225b140d7d37ded952dacea73aaed896bca01ccd745827c6289",
|
||||
sha256 = "e78fc3394deae5408d6f49a15c7b1e615901969ecf6e50d55ef899996b0b8458",
|
||||
urls = [
|
||||
"https://github.com/bazelbuild/bazel/releases/download/6.1.2/bazel-6.1.2-linux-x86_64",
|
||||
"https://github.com/bazelbuild/bazel/releases/download/6.3.2/bazel-6.3.2-linux-x86_64",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
</natures>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1677235311958</id>
|
||||
<id>1672434305228</id>
|
||||
<name></name>
|
||||
<type>30</type>
|
||||
<matcher>
|
||||
|
||||
@@ -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_24_12_23()
|
||||
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
9
benchmarks/swift/README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# Benchmarks
|
||||
|
||||
To open the benchmarks in xcode use:
|
||||
|
||||
`open --env BENCHMARK_DISABLE_JEMALLOC=true Package.swift`
|
||||
|
||||
or running them directly within terminal using:
|
||||
|
||||
`swift package benchmark`
|
||||
@@ -87,6 +87,7 @@ def flatbuffer_library_public(
|
||||
optionally a Fileset([reflection_name]) with all generated reflection
|
||||
binaries.
|
||||
"""
|
||||
reflection_include_paths = include_paths
|
||||
if include_paths == None:
|
||||
include_paths = default_include_paths(flatc_path)
|
||||
include_paths_cmd = ["-I %s" % (s) for s in include_paths]
|
||||
@@ -124,13 +125,16 @@ def flatbuffer_library_public(
|
||||
**kwargs
|
||||
)
|
||||
if reflection_name:
|
||||
if reflection_include_paths == None:
|
||||
reflection_include_paths = default_include_paths(TRUE_FLATC_PATH)
|
||||
reflection_include_paths_cmd = ["-I %s" % (s) for s in reflection_include_paths]
|
||||
reflection_genrule_cmd = " ".join([
|
||||
"SRCS=($(SRCS));",
|
||||
"for f in $${SRCS[@]:0:%s}; do" % len(srcs),
|
||||
"$(location %s)" % (TRUE_FLATC_PATH),
|
||||
"-b --schema",
|
||||
" ".join(flatc_args),
|
||||
" ".join(include_paths_cmd),
|
||||
" ".join(reflection_include_paths_cmd),
|
||||
language_flag,
|
||||
output_directory,
|
||||
"$$f;",
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
# Changelog
|
||||
|
||||
## 23.5.26
|
||||
|
||||
- omit type annotationes for local variables (#7067, #7069, #7070)
|
||||
- remove BSD 3-clause license (#7073)
|
||||
- correctly parse lists of enums (#7157)
|
||||
- align naming conventions for generated code (#7187)
|
||||
- add `putBool` to fix errors when serializing structs with booleans (#7359)
|
||||
- fix handling of +/-inf defaults in codegen (#7588)
|
||||
- fix import issues in generated code (#7621)
|
||||
- Fix incorrect storage of floats as ints in some cases (#7703)
|
||||
- add final modifiers to the library implementation (#7943)
|
||||
|
||||
## 2.0.5
|
||||
|
||||
- switch to null safety (#6696)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
This package is used to read and write [FlatBuffers](https://google.github.io/flatbuffers/).
|
||||
|
||||
Most consumers will want to use the [`flatc` - FlatBuffer compiler](https://github.com/google/flatbuffers) binary for your platform.
|
||||
You can find it in the `generator/{Platform}` directory of the [released package archive](https://pub.dev/packages/flat_buffers/versions/2.0.5.tar.gz).
|
||||
You can download the flatc version matching your dart package version from [GitHub releases](https://github.com/google/flatbuffers/releases).
|
||||
|
||||
The FlatBuffer compiler `flatc` reads a FlatBuffers IDL schema and generates Dart code.
|
||||
The generated classes can be used to read or write binary data/files that are interoperable with
|
||||
@@ -13,11 +13,3 @@ examples folder.
|
||||
For more details and documentation, head over to the official site and read the
|
||||
[Tutorial](https://google.github.io/flatbuffers/flatbuffers_guide_tutorial.html) and how to
|
||||
[use FlatBuffers in Dart](https://google.github.io/flatbuffers/flatbuffers_guide_use_dart.html).
|
||||
|
||||
## Dart 2.0 notes
|
||||
Version 2.0.5 ships with it's own custom build of `flatc` because this is an extraordinary release to catch-up
|
||||
with FlatBuffers for other platforms. This generator can only generate dart code (to avoid generating code for other platforms which isn't released yet).
|
||||
On the other hand, the generated code still produces standard binary FlatBuffers compatible with other languages.
|
||||
In other words: only `flatc --dart ...` works with this generator, but your app will be able to produce and read standard binary (`Uint8List`) FlatBuffers that are fully compotible with other languages supporting FlatBuffers (e.g. Java, C++, ...).
|
||||
|
||||
In the future a common `flatc` binary for all platforms would be shipped through GitHub release page instead.
|
||||
|
||||
@@ -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: 24.12.23
|
||||
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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
|
||||
#ifndef FLATBUFFERS_GENERATED_BASIC_H_
|
||||
#define FLATBUFFERS_GENERATED_BASIC_H_
|
||||
#ifndef FLATBUFFERS_GENERATED_BASIC_FLATBUFFERS_GOLDENS_H_
|
||||
#define FLATBUFFERS_GENERATED_BASIC_FLATBUFFERS_GOLDENS_H_
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||
// generated, otherwise it may not be compatible.
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 23 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 5 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 9,
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 24 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 23,
|
||||
"Non-compatible flatbuffers version included");
|
||||
|
||||
namespace flatbuffers {
|
||||
namespace goldens {
|
||||
|
||||
struct Galaxy;
|
||||
struct GalaxyBuilder;
|
||||
|
||||
@@ -69,8 +72,8 @@ struct Universe FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
double age() const {
|
||||
return GetField<double>(VT_AGE, 0.0);
|
||||
}
|
||||
const ::flatbuffers::Vector<::flatbuffers::Offset<Galaxy>> *galaxies() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<Galaxy>> *>(VT_GALAXIES);
|
||||
const ::flatbuffers::Vector<::flatbuffers::Offset<flatbuffers::goldens::Galaxy>> *galaxies() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<flatbuffers::goldens::Galaxy>> *>(VT_GALAXIES);
|
||||
}
|
||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
@@ -89,7 +92,7 @@ struct UniverseBuilder {
|
||||
void add_age(double age) {
|
||||
fbb_.AddElement<double>(Universe::VT_AGE, age, 0.0);
|
||||
}
|
||||
void add_galaxies(::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<Galaxy>>> galaxies) {
|
||||
void add_galaxies(::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<flatbuffers::goldens::Galaxy>>> galaxies) {
|
||||
fbb_.AddOffset(Universe::VT_GALAXIES, galaxies);
|
||||
}
|
||||
explicit UniverseBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
@@ -106,7 +109,7 @@ struct UniverseBuilder {
|
||||
inline ::flatbuffers::Offset<Universe> CreateUniverse(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
double age = 0.0,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<Galaxy>>> galaxies = 0) {
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<flatbuffers::goldens::Galaxy>>> galaxies = 0) {
|
||||
UniverseBuilder builder_(_fbb);
|
||||
builder_.add_age(age);
|
||||
builder_.add_galaxies(galaxies);
|
||||
@@ -116,42 +119,45 @@ inline ::flatbuffers::Offset<Universe> CreateUniverse(
|
||||
inline ::flatbuffers::Offset<Universe> CreateUniverseDirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
double age = 0.0,
|
||||
const std::vector<::flatbuffers::Offset<Galaxy>> *galaxies = nullptr) {
|
||||
auto galaxies__ = galaxies ? _fbb.CreateVector<::flatbuffers::Offset<Galaxy>>(*galaxies) : 0;
|
||||
return CreateUniverse(
|
||||
const std::vector<::flatbuffers::Offset<flatbuffers::goldens::Galaxy>> *galaxies = nullptr) {
|
||||
auto galaxies__ = galaxies ? _fbb.CreateVector<::flatbuffers::Offset<flatbuffers::goldens::Galaxy>>(*galaxies) : 0;
|
||||
return flatbuffers::goldens::CreateUniverse(
|
||||
_fbb,
|
||||
age,
|
||||
galaxies__);
|
||||
}
|
||||
|
||||
inline const Universe *GetUniverse(const void *buf) {
|
||||
return ::flatbuffers::GetRoot<Universe>(buf);
|
||||
inline const flatbuffers::goldens::Universe *GetUniverse(const void *buf) {
|
||||
return ::flatbuffers::GetRoot<flatbuffers::goldens::Universe>(buf);
|
||||
}
|
||||
|
||||
inline const Universe *GetSizePrefixedUniverse(const void *buf) {
|
||||
return ::flatbuffers::GetSizePrefixedRoot<Universe>(buf);
|
||||
inline const flatbuffers::goldens::Universe *GetSizePrefixedUniverse(const void *buf) {
|
||||
return ::flatbuffers::GetSizePrefixedRoot<flatbuffers::goldens::Universe>(buf);
|
||||
}
|
||||
|
||||
inline bool VerifyUniverseBuffer(
|
||||
::flatbuffers::Verifier &verifier) {
|
||||
return verifier.VerifyBuffer<Universe>(nullptr);
|
||||
return verifier.VerifyBuffer<flatbuffers::goldens::Universe>(nullptr);
|
||||
}
|
||||
|
||||
inline bool VerifySizePrefixedUniverseBuffer(
|
||||
::flatbuffers::Verifier &verifier) {
|
||||
return verifier.VerifySizePrefixedBuffer<Universe>(nullptr);
|
||||
return verifier.VerifySizePrefixedBuffer<flatbuffers::goldens::Universe>(nullptr);
|
||||
}
|
||||
|
||||
inline void FinishUniverseBuffer(
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<Universe> root) {
|
||||
::flatbuffers::Offset<flatbuffers::goldens::Universe> root) {
|
||||
fbb.Finish(root);
|
||||
}
|
||||
|
||||
inline void FinishSizePrefixedUniverseBuffer(
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<Universe> root) {
|
||||
::flatbuffers::Offset<flatbuffers::goldens::Universe> root) {
|
||||
fbb.FinishSizePrefixed(root);
|
||||
}
|
||||
|
||||
#endif // FLATBUFFERS_GENERATED_BASIC_H_
|
||||
} // namespace goldens
|
||||
} // namespace flatbuffers
|
||||
|
||||
#endif // FLATBUFFERS_GENERATED_BASIC_FLATBUFFERS_GOLDENS_H_
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// </auto-generated>
|
||||
|
||||
namespace flatbuffers.goldens
|
||||
{
|
||||
|
||||
using global::System;
|
||||
using global::System.Collections.Generic;
|
||||
using global::Google.FlatBuffers;
|
||||
@@ -10,7 +13,7 @@ public struct Galaxy : IFlatbufferObject
|
||||
{
|
||||
private Table __p;
|
||||
public ByteBuffer ByteBuffer { get { return __p.bb; } }
|
||||
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_23_5_26(); }
|
||||
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_24_12_23(); }
|
||||
public static Galaxy GetRootAsGalaxy(ByteBuffer _bb) { return GetRootAsGalaxy(_bb, new Galaxy()); }
|
||||
public static Galaxy GetRootAsGalaxy(ByteBuffer _bb, Galaxy obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
|
||||
public void __init(int _i, ByteBuffer _bb) { __p = new Table(_i, _bb); }
|
||||
@@ -18,7 +21,7 @@ public struct Galaxy : IFlatbufferObject
|
||||
|
||||
public long NumStars { get { int o = __p.__offset(4); return o != 0 ? __p.bb.GetLong(o + __p.bb_pos) : (long)0; } }
|
||||
|
||||
public static Offset<Galaxy> CreateGalaxy(FlatBufferBuilder builder,
|
||||
public static Offset<flatbuffers.goldens.Galaxy> CreateGalaxy(FlatBufferBuilder builder,
|
||||
long num_stars = 0) {
|
||||
builder.StartTable(1);
|
||||
Galaxy.AddNumStars(builder, num_stars);
|
||||
@@ -27,9 +30,9 @@ public struct Galaxy : IFlatbufferObject
|
||||
|
||||
public static void StartGalaxy(FlatBufferBuilder builder) { builder.StartTable(1); }
|
||||
public static void AddNumStars(FlatBufferBuilder builder, long numStars) { builder.AddLong(0, numStars, 0); }
|
||||
public static Offset<Galaxy> EndGalaxy(FlatBufferBuilder builder) {
|
||||
public static Offset<flatbuffers.goldens.Galaxy> EndGalaxy(FlatBufferBuilder builder) {
|
||||
int o = builder.EndTable();
|
||||
return new Offset<Galaxy>(o);
|
||||
return new Offset<flatbuffers.goldens.Galaxy>(o);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,3 +46,5 @@ static public class GalaxyVerify
|
||||
&& verifier.VerifyTableEnd(tablePos);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,9 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// </auto-generated>
|
||||
|
||||
namespace flatbuffers.goldens
|
||||
{
|
||||
|
||||
using global::System;
|
||||
using global::System.Collections.Generic;
|
||||
using global::Google.FlatBuffers;
|
||||
@@ -10,7 +13,7 @@ public struct Universe : IFlatbufferObject
|
||||
{
|
||||
private Table __p;
|
||||
public ByteBuffer ByteBuffer { get { return __p.bb; } }
|
||||
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_23_5_26(); }
|
||||
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_24_12_23(); }
|
||||
public static Universe GetRootAsUniverse(ByteBuffer _bb) { return GetRootAsUniverse(_bb, new Universe()); }
|
||||
public static Universe GetRootAsUniverse(ByteBuffer _bb, Universe obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
|
||||
public static bool VerifyUniverse(ByteBuffer _bb) {Google.FlatBuffers.Verifier verifier = new Google.FlatBuffers.Verifier(_bb); return verifier.VerifyBuffer("", false, UniverseVerify.Verify); }
|
||||
@@ -18,10 +21,10 @@ public struct Universe : IFlatbufferObject
|
||||
public Universe __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
public double Age { get { int o = __p.__offset(4); return o != 0 ? __p.bb.GetDouble(o + __p.bb_pos) : (double)0.0; } }
|
||||
public Galaxy? Galaxies(int j) { int o = __p.__offset(6); return o != 0 ? (Galaxy?)(new Galaxy()).__assign(__p.__indirect(__p.__vector(o) + j * 4), __p.bb) : null; }
|
||||
public flatbuffers.goldens.Galaxy? Galaxies(int j) { int o = __p.__offset(6); return o != 0 ? (flatbuffers.goldens.Galaxy?)(new flatbuffers.goldens.Galaxy()).__assign(__p.__indirect(__p.__vector(o) + j * 4), __p.bb) : null; }
|
||||
public int GalaxiesLength { get { int o = __p.__offset(6); return o != 0 ? __p.__vector_len(o) : 0; } }
|
||||
|
||||
public static Offset<Universe> CreateUniverse(FlatBufferBuilder builder,
|
||||
public static Offset<flatbuffers.goldens.Universe> CreateUniverse(FlatBufferBuilder builder,
|
||||
double age = 0.0,
|
||||
VectorOffset galaxiesOffset = default(VectorOffset)) {
|
||||
builder.StartTable(2);
|
||||
@@ -33,17 +36,17 @@ public struct Universe : IFlatbufferObject
|
||||
public static void StartUniverse(FlatBufferBuilder builder) { builder.StartTable(2); }
|
||||
public static void AddAge(FlatBufferBuilder builder, double age) { builder.AddDouble(0, age, 0.0); }
|
||||
public static void AddGalaxies(FlatBufferBuilder builder, VectorOffset galaxiesOffset) { builder.AddOffset(1, galaxiesOffset.Value, 0); }
|
||||
public static VectorOffset CreateGalaxiesVector(FlatBufferBuilder builder, Offset<Galaxy>[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddOffset(data[i].Value); return builder.EndVector(); }
|
||||
public static VectorOffset CreateGalaxiesVectorBlock(FlatBufferBuilder builder, Offset<Galaxy>[] data) { builder.StartVector(4, data.Length, 4); builder.Add(data); return builder.EndVector(); }
|
||||
public static VectorOffset CreateGalaxiesVectorBlock(FlatBufferBuilder builder, ArraySegment<Offset<Galaxy>> data) { builder.StartVector(4, data.Count, 4); builder.Add(data); return builder.EndVector(); }
|
||||
public static VectorOffset CreateGalaxiesVectorBlock(FlatBufferBuilder builder, IntPtr dataPtr, int sizeInBytes) { builder.StartVector(1, sizeInBytes, 1); builder.Add<Offset<Galaxy>>(dataPtr, sizeInBytes); return builder.EndVector(); }
|
||||
public static VectorOffset CreateGalaxiesVector(FlatBufferBuilder builder, Offset<flatbuffers.goldens.Galaxy>[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddOffset(data[i].Value); return builder.EndVector(); }
|
||||
public static VectorOffset CreateGalaxiesVectorBlock(FlatBufferBuilder builder, Offset<flatbuffers.goldens.Galaxy>[] data) { builder.StartVector(4, data.Length, 4); builder.Add(data); return builder.EndVector(); }
|
||||
public static VectorOffset CreateGalaxiesVectorBlock(FlatBufferBuilder builder, ArraySegment<Offset<flatbuffers.goldens.Galaxy>> data) { builder.StartVector(4, data.Count, 4); builder.Add(data); return builder.EndVector(); }
|
||||
public static VectorOffset CreateGalaxiesVectorBlock(FlatBufferBuilder builder, IntPtr dataPtr, int sizeInBytes) { builder.StartVector(1, sizeInBytes, 1); builder.Add<Offset<flatbuffers.goldens.Galaxy>>(dataPtr, sizeInBytes); return builder.EndVector(); }
|
||||
public static void StartGalaxiesVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
|
||||
public static Offset<Universe> EndUniverse(FlatBufferBuilder builder) {
|
||||
public static Offset<flatbuffers.goldens.Universe> EndUniverse(FlatBufferBuilder builder) {
|
||||
int o = builder.EndTable();
|
||||
return new Offset<Universe>(o);
|
||||
return new Offset<flatbuffers.goldens.Universe>(o);
|
||||
}
|
||||
public static void FinishUniverseBuffer(FlatBufferBuilder builder, Offset<Universe> offset) { builder.Finish(offset.Value); }
|
||||
public static void FinishSizePrefixedUniverseBuffer(FlatBufferBuilder builder, Offset<Universe> offset) { builder.FinishSizePrefixed(offset.Value); }
|
||||
public static void FinishUniverseBuffer(FlatBufferBuilder builder, Offset<flatbuffers.goldens.Universe> offset) { builder.Finish(offset.Value); }
|
||||
public static void FinishSizePrefixedUniverseBuffer(FlatBufferBuilder builder, Offset<flatbuffers.goldens.Universe> offset) { builder.FinishSizePrefixed(offset.Value); }
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +56,9 @@ static public class UniverseVerify
|
||||
{
|
||||
return verifier.VerifyTableStart(tablePos)
|
||||
&& verifier.VerifyField(tablePos, 4 /*Age*/, 8 /*double*/, 8, false)
|
||||
&& verifier.VerifyVectorOfTables(tablePos, 6 /*Galaxies*/, GalaxyVerify.Verify, false)
|
||||
&& verifier.VerifyVectorOfTables(tablePos, 6 /*Galaxies*/, flatbuffers.goldens.GalaxyVerify.Verify, false)
|
||||
&& verifier.VerifyTableEnd(tablePos);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
// 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 flatbuffers.goldens;
|
||||
|
||||
import 'dart:typed_data' show Uint8List;
|
||||
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by the FlatBuffers compiler. DO NOT EDIT.
|
||||
|
||||
package Galaxy
|
||||
package goldens
|
||||
|
||||
import (
|
||||
flatbuffers "github.com/google/flatbuffers/go"
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by the FlatBuffers compiler. DO NOT EDIT.
|
||||
|
||||
package Universe
|
||||
package goldens
|
||||
|
||||
import (
|
||||
flatbuffers "github.com/google/flatbuffers/go"
|
||||
@@ -1,5 +1,7 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package flatbuffers.goldens;
|
||||
|
||||
import com.google.flatbuffers.BaseVector;
|
||||
import com.google.flatbuffers.BooleanVector;
|
||||
import com.google.flatbuffers.ByteVector;
|
||||
@@ -19,7 +21,7 @@ import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class Galaxy extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_26(); }
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_24_12_23(); }
|
||||
public static Galaxy getRootAsGalaxy(ByteBuffer _bb) { return getRootAsGalaxy(_bb, new Galaxy()); }
|
||||
public static Galaxy getRootAsGalaxy(ByteBuffer _bb, Galaxy obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||
@@ -1,5 +1,7 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package flatbuffers.goldens;
|
||||
|
||||
import com.google.flatbuffers.BaseVector;
|
||||
import com.google.flatbuffers.BooleanVector;
|
||||
import com.google.flatbuffers.ByteVector;
|
||||
@@ -19,18 +21,18 @@ import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class Universe extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_26(); }
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_24_12_23(); }
|
||||
public static Universe getRootAsUniverse(ByteBuffer _bb) { return getRootAsUniverse(_bb, new Universe()); }
|
||||
public static Universe getRootAsUniverse(ByteBuffer _bb, Universe obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||
public Universe __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
public double age() { int o = __offset(4); return o != 0 ? bb.getDouble(o + bb_pos) : 0.0; }
|
||||
public Galaxy galaxies(int j) { return galaxies(new Galaxy(), j); }
|
||||
public Galaxy galaxies(Galaxy obj, int j) { int o = __offset(6); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public flatbuffers.goldens.Galaxy galaxies(int j) { return galaxies(new flatbuffers.goldens.Galaxy(), j); }
|
||||
public flatbuffers.goldens.Galaxy galaxies(flatbuffers.goldens.Galaxy obj, int j) { int o = __offset(6); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int galaxiesLength() { int o = __offset(6); return o != 0 ? __vector_len(o) : 0; }
|
||||
public Galaxy.Vector galaxiesVector() { return galaxiesVector(new Galaxy.Vector()); }
|
||||
public Galaxy.Vector galaxiesVector(Galaxy.Vector obj) { int o = __offset(6); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public flatbuffers.goldens.Galaxy.Vector galaxiesVector() { return galaxiesVector(new flatbuffers.goldens.Galaxy.Vector()); }
|
||||
public flatbuffers.goldens.Galaxy.Vector galaxiesVector(flatbuffers.goldens.Galaxy.Vector obj) { int o = __offset(6); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
|
||||
public static int createUniverse(FlatBufferBuilder builder,
|
||||
double age,
|
||||
@@ -1,5 +1,7 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package flatbuffers.goldens
|
||||
|
||||
import com.google.flatbuffers.BaseVector
|
||||
import com.google.flatbuffers.BooleanVector
|
||||
import com.google.flatbuffers.ByteVector
|
||||
@@ -32,7 +34,7 @@ class Galaxy : Table() {
|
||||
return if(o != 0) bb.getLong(o + bb_pos) else 0L
|
||||
}
|
||||
companion object {
|
||||
fun validateVersion() = Constants.FLATBUFFERS_23_5_26()
|
||||
fun validateVersion() = Constants.FLATBUFFERS_24_12_23()
|
||||
fun getRootAsGalaxy(_bb: ByteBuffer): Galaxy = getRootAsGalaxy(_bb, Galaxy())
|
||||
fun getRootAsGalaxy(_bb: ByteBuffer, obj: Galaxy): Galaxy {
|
||||
_bb.order(ByteOrder.LITTLE_ENDIAN)
|
||||
@@ -1,5 +1,7 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package flatbuffers.goldens
|
||||
|
||||
import com.google.flatbuffers.BaseVector
|
||||
import com.google.flatbuffers.BooleanVector
|
||||
import com.google.flatbuffers.ByteVector
|
||||
@@ -31,8 +33,8 @@ class Universe : Table() {
|
||||
val o = __offset(4)
|
||||
return if(o != 0) bb.getDouble(o + bb_pos) else 0.0
|
||||
}
|
||||
fun galaxies(j: Int) : Galaxy? = galaxies(Galaxy(), j)
|
||||
fun galaxies(obj: Galaxy, j: Int) : Galaxy? {
|
||||
fun galaxies(j: Int) : flatbuffers.goldens.Galaxy? = galaxies(flatbuffers.goldens.Galaxy(), j)
|
||||
fun galaxies(obj: flatbuffers.goldens.Galaxy, j: Int) : flatbuffers.goldens.Galaxy? {
|
||||
val o = __offset(6)
|
||||
return if (o != 0) {
|
||||
obj.__assign(__indirect(__vector(o) + j * 4), bb)
|
||||
@@ -45,7 +47,7 @@ class Universe : Table() {
|
||||
val o = __offset(6); return if (o != 0) __vector_len(o) else 0
|
||||
}
|
||||
companion object {
|
||||
fun validateVersion() = Constants.FLATBUFFERS_23_5_26()
|
||||
fun validateVersion() = Constants.FLATBUFFERS_24_12_23()
|
||||
fun getRootAsUniverse(_bb: ByteBuffer): Universe = getRootAsUniverse(_bb, Universe())
|
||||
fun getRootAsUniverse(_bb: ByteBuffer, obj: Universe): Universe {
|
||||
_bb.order(ByteOrder.LITTLE_ENDIAN)
|
||||
@@ -1,18 +1,20 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
import flatbuffers
|
||||
|
||||
namespace flatbuffers.goldens
|
||||
|
||||
class Galaxy
|
||||
|
||||
class Universe
|
||||
|
||||
class Galaxy : flatbuffers_handle
|
||||
class Galaxy : flatbuffers.handle
|
||||
def num_stars() -> int:
|
||||
return buf_.flatbuffers_field_int64(pos_, 4, 0)
|
||||
return flatbuffers.field_int64(buf_, pos_, 4, 0)
|
||||
|
||||
def GetRootAsGalaxy(buf:string): return Galaxy { buf, buf.flatbuffers_indirect(0) }
|
||||
def GetRootAsGalaxy(buf:string): return Galaxy { buf, flatbuffers.indirect(buf, 0) }
|
||||
|
||||
struct GalaxyBuilder:
|
||||
b_:flatbuffers_builder
|
||||
b_:flatbuffers.builder
|
||||
def start():
|
||||
b_.StartObject(1)
|
||||
return this
|
||||
@@ -22,33 +24,33 @@ struct GalaxyBuilder:
|
||||
def end():
|
||||
return b_.EndObject()
|
||||
|
||||
class Universe : flatbuffers_handle
|
||||
class Universe : flatbuffers.handle
|
||||
def age() -> float:
|
||||
return buf_.flatbuffers_field_float64(pos_, 4, 0.0)
|
||||
def galaxies(i:int) -> Galaxy:
|
||||
return Galaxy { buf_, buf_.flatbuffers_indirect(buf_.flatbuffers_field_vector(pos_, 6) + i * 4) }
|
||||
return flatbuffers.field_float64(buf_, pos_, 4, 0.0)
|
||||
def galaxies(i:int) -> flatbuffers.goldens.Galaxy:
|
||||
return flatbuffers.goldens.Galaxy { buf_, flatbuffers.indirect(buf_, flatbuffers.field_vector(buf_, pos_, 6) + i * 4) }
|
||||
def galaxies_length() -> int:
|
||||
return buf_.flatbuffers_field_vector_len(pos_, 6)
|
||||
return flatbuffers.field_vector_len(buf_, pos_, 6)
|
||||
|
||||
def GetRootAsUniverse(buf:string): return Universe { buf, buf.flatbuffers_indirect(0) }
|
||||
def GetRootAsUniverse(buf:string): return Universe { buf, flatbuffers.indirect(buf, 0) }
|
||||
|
||||
struct UniverseBuilder:
|
||||
b_:flatbuffers_builder
|
||||
b_:flatbuffers.builder
|
||||
def start():
|
||||
b_.StartObject(2)
|
||||
return this
|
||||
def add_age(age:float):
|
||||
b_.PrependFloat64Slot(0, age, 0.0)
|
||||
return this
|
||||
def add_galaxies(galaxies:flatbuffers_offset):
|
||||
def add_galaxies(galaxies:flatbuffers.offset):
|
||||
b_.PrependUOffsetTRelativeSlot(1, galaxies)
|
||||
return this
|
||||
def end():
|
||||
return b_.EndObject()
|
||||
|
||||
def UniverseStartGalaxiesVector(b_:flatbuffers_builder, n_:int):
|
||||
def UniverseStartGalaxiesVector(b_:flatbuffers.builder, n_:int):
|
||||
b_.StartVector(4, n_, 4)
|
||||
def UniverseCreateGalaxiesVector(b_:flatbuffers_builder, v_:[flatbuffers_offset]):
|
||||
def UniverseCreateGalaxiesVector(b_:flatbuffers.builder, v_:[flatbuffers.offset]):
|
||||
b_.StartVector(4, v_.length, 4)
|
||||
reverse(v_) e_: b_.PrependUOffsetTRelative(e_)
|
||||
return b_.EndVector(v_.length)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Automatically generated by the FlatBuffers compiler, do not modify.
|
||||
Or modify. I'm a message, not a cop.
|
||||
|
||||
flatc version: 23.5.9
|
||||
flatc version: 23.5.26
|
||||
|
||||
Declared by : //basic.fbs
|
||||
Rooting type : Universe (//basic.fbs)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Automatically generated by the FlatBuffers compiler, do not modify.
|
||||
Or modify. I'm a message, not a cop.
|
||||
|
||||
flatc version: 23.5.9
|
||||
flatc version: 23.5.26
|
||||
|
||||
Declared by : //basic.fbs
|
||||
Rooting type : Universe (//basic.fbs)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Automatically generated by the FlatBuffers compiler, do not modify.
|
||||
Or modify. I'm a message, not a cop.
|
||||
|
||||
flatc version: 23.5.9
|
||||
flatc version: 23.5.26
|
||||
|
||||
Declared by : //basic.fbs
|
||||
Rooting type : Universe (//basic.fbs)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Automatically generated by the FlatBuffers compiler, do not modify.
|
||||
Or modify. I'm a message, not a cop.
|
||||
|
||||
flatc version: 23.5.9
|
||||
flatc version: 23.5.26
|
||||
|
||||
Declared by : //basic.fbs
|
||||
Rooting type : Universe (//basic.fbs)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace flatbuffers\goldens;
|
||||
|
||||
use \Google\FlatBuffers\Struct;
|
||||
use \Google\FlatBuffers\Table;
|
||||
use \Google\FlatBuffers\ByteBuffer;
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace flatbuffers\goldens;
|
||||
|
||||
use \Google\FlatBuffers\Struct;
|
||||
use \Google\FlatBuffers\Table;
|
||||
use \Google\FlatBuffers\ByteBuffer;
|
||||
0
goldens/py/flatbuffers/__init__.py
Normal file
0
goldens/py/flatbuffers/__init__.py
Normal file
@@ -1,6 +1,6 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace:
|
||||
# namespace: goldens
|
||||
|
||||
import flatbuffers
|
||||
from flatbuffers.compat import import_numpy
|
||||
@@ -40,7 +40,7 @@ def Start(builder):
|
||||
def GalaxyAddNumStars(builder, numStars):
|
||||
builder.PrependInt64Slot(0, numStars, 0)
|
||||
|
||||
def AddNumStars(builder: flatbuffers.Builder, numStars: int):
|
||||
def AddNumStars(builder, numStars):
|
||||
GalaxyAddNumStars(builder, numStars)
|
||||
|
||||
def GalaxyEnd(builder):
|
||||
@@ -1,6 +1,6 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace:
|
||||
# namespace: goldens
|
||||
|
||||
import flatbuffers
|
||||
from flatbuffers.compat import import_numpy
|
||||
@@ -38,7 +38,7 @@ class Universe(object):
|
||||
x = self._tab.Vector(o)
|
||||
x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
|
||||
x = self._tab.Indirect(x)
|
||||
from .Galaxy import Galaxy
|
||||
from flatbuffers.goldens.Galaxy import Galaxy
|
||||
obj = Galaxy()
|
||||
obj.Init(self._tab.Bytes, x)
|
||||
return obj
|
||||
@@ -65,19 +65,19 @@ def Start(builder):
|
||||
def UniverseAddAge(builder, age):
|
||||
builder.PrependFloat64Slot(0, age, 0.0)
|
||||
|
||||
def AddAge(builder: flatbuffers.Builder, age: float):
|
||||
def AddAge(builder, age):
|
||||
UniverseAddAge(builder, age)
|
||||
|
||||
def UniverseAddGalaxies(builder, galaxies):
|
||||
builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(galaxies), 0)
|
||||
|
||||
def AddGalaxies(builder: flatbuffers.Builder, galaxies: int):
|
||||
def AddGalaxies(builder, galaxies):
|
||||
UniverseAddGalaxies(builder, galaxies)
|
||||
|
||||
def UniverseStartGalaxiesVector(builder, numElems):
|
||||
return builder.StartVector(4, numElems, 4)
|
||||
|
||||
def StartGalaxiesVector(builder, numElems: int) -> int:
|
||||
def StartGalaxiesVector(builder, numElems):
|
||||
return UniverseStartGalaxiesVector(builder, numElems)
|
||||
|
||||
def UniverseEnd(builder):
|
||||
0
goldens/py/flatbuffers/goldens/__init__.py
Normal file
0
goldens/py/flatbuffers/goldens/__init__.py
Normal file
@@ -9,6 +9,23 @@ use core::cmp::Ordering;
|
||||
extern crate flatbuffers;
|
||||
use self::flatbuffers::{EndianScalar, Follow};
|
||||
|
||||
#[allow(unused_imports, dead_code)]
|
||||
pub mod flatbuffers {
|
||||
|
||||
use core::mem;
|
||||
use core::cmp::Ordering;
|
||||
|
||||
extern crate flatbuffers;
|
||||
use self::flatbuffers::{EndianScalar, Follow};
|
||||
#[allow(unused_imports, dead_code)]
|
||||
pub mod goldens {
|
||||
|
||||
use core::mem;
|
||||
use core::cmp::Ordering;
|
||||
|
||||
extern crate flatbuffers;
|
||||
use self::flatbuffers::{EndianScalar, Follow};
|
||||
|
||||
pub enum GalaxyOffset {}
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
|
||||
@@ -32,8 +49,8 @@ impl<'a> Galaxy<'a> {
|
||||
Galaxy { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||
args: &'args GalaxyArgs
|
||||
) -> flatbuffers::WIPOffset<Galaxy<'bldr>> {
|
||||
let mut builder = GalaxyBuilder::new(_fbb);
|
||||
@@ -75,17 +92,17 @@ impl<'a> Default for GalaxyArgs {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct GalaxyBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
pub struct GalaxyBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
|
||||
start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
|
||||
}
|
||||
impl<'a: 'b, 'b> GalaxyBuilder<'a, 'b> {
|
||||
impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> GalaxyBuilder<'a, 'b, A> {
|
||||
#[inline]
|
||||
pub fn add_num_stars(&mut self, num_stars: i64) {
|
||||
self.fbb_.push_slot::<i64>(Galaxy::VT_NUM_STARS, num_stars, 0);
|
||||
}
|
||||
#[inline]
|
||||
pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> GalaxyBuilder<'a, 'b> {
|
||||
pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> GalaxyBuilder<'a, 'b, A> {
|
||||
let start = _fbb.start_table();
|
||||
GalaxyBuilder {
|
||||
fbb_: _fbb,
|
||||
@@ -130,8 +147,8 @@ impl<'a> Universe<'a> {
|
||||
Universe { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||
args: &'args UniverseArgs<'args>
|
||||
) -> flatbuffers::WIPOffset<Universe<'bldr>> {
|
||||
let mut builder = UniverseBuilder::new(_fbb);
|
||||
@@ -184,11 +201,11 @@ impl<'a> Default for UniverseArgs<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct UniverseBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
pub struct UniverseBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
|
||||
start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
|
||||
}
|
||||
impl<'a: 'b, 'b> UniverseBuilder<'a, 'b> {
|
||||
impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> UniverseBuilder<'a, 'b, A> {
|
||||
#[inline]
|
||||
pub fn add_age(&mut self, age: f64) {
|
||||
self.fbb_.push_slot::<f64>(Universe::VT_AGE, age, 0.0);
|
||||
@@ -198,7 +215,7 @@ impl<'a: 'b, 'b> UniverseBuilder<'a, 'b> {
|
||||
self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Universe::VT_GALAXIES, galaxies);
|
||||
}
|
||||
#[inline]
|
||||
pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> UniverseBuilder<'a, 'b> {
|
||||
pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> UniverseBuilder<'a, 'b, A> {
|
||||
let start = _fbb.start_table();
|
||||
UniverseBuilder {
|
||||
fbb_: _fbb,
|
||||
@@ -281,13 +298,16 @@ pub unsafe fn size_prefixed_root_as_universe_unchecked(buf: &[u8]) -> Universe {
|
||||
flatbuffers::size_prefixed_root_unchecked::<Universe>(buf)
|
||||
}
|
||||
#[inline]
|
||||
pub fn finish_universe_buffer<'a, 'b>(
|
||||
fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
pub fn finish_universe_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(
|
||||
fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
|
||||
root: flatbuffers::WIPOffset<Universe<'a>>) {
|
||||
fbb.finish(root, None);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn finish_size_prefixed_universe_buffer<'a, 'b>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, root: flatbuffers::WIPOffset<Universe<'a>>) {
|
||||
pub fn finish_size_prefixed_universe_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, root: flatbuffers::WIPOffset<Universe<'a>>) {
|
||||
fbb.finish_size_prefixed(root, None);
|
||||
}
|
||||
} // pub mod goldens
|
||||
} // pub mod flatbuffers
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// This file should contain the basics of flatbuffers that all languages should
|
||||
// support.
|
||||
|
||||
namespace flatbuffers.goldens;
|
||||
|
||||
table Galaxy {
|
||||
num_stars:long;
|
||||
}
|
||||
|
||||
0
goldens/swift/__init__.py
Normal file
0
goldens/swift/__init__.py
Normal file
@@ -4,9 +4,9 @@
|
||||
|
||||
import FlatBuffers
|
||||
|
||||
public struct Galaxy: FlatBufferObject, Verifiable {
|
||||
public struct flatbuffers_goldens_Galaxy: FlatBufferObject, Verifiable {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_23_5_26() }
|
||||
static func validateVersion() { FlatBuffersVersion_24_12_23() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
private var _accessor: Table
|
||||
|
||||
@@ -27,9 +27,9 @@ public struct Galaxy: FlatBufferObject, Verifiable {
|
||||
_ fbb: inout FlatBufferBuilder,
|
||||
numStars: Int64 = 0
|
||||
) -> Offset {
|
||||
let __start = Galaxy.startGalaxy(&fbb)
|
||||
Galaxy.add(numStars: numStars, &fbb)
|
||||
return Galaxy.endGalaxy(&fbb, start: __start)
|
||||
let __start = flatbuffers_goldens_Galaxy.startGalaxy(&fbb)
|
||||
flatbuffers_goldens_Galaxy.add(numStars: numStars, &fbb)
|
||||
return flatbuffers_goldens_Galaxy.endGalaxy(&fbb, start: __start)
|
||||
}
|
||||
|
||||
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
|
||||
@@ -39,9 +39,9 @@ public struct Galaxy: FlatBufferObject, Verifiable {
|
||||
}
|
||||
}
|
||||
|
||||
public struct Universe: FlatBufferObject, Verifiable {
|
||||
public struct flatbuffers_goldens_Universe: FlatBufferObject, Verifiable {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_23_5_26() }
|
||||
static func validateVersion() { FlatBuffersVersion_24_12_23() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
private var _accessor: Table
|
||||
|
||||
@@ -58,7 +58,7 @@ public struct Universe: FlatBufferObject, Verifiable {
|
||||
public var age: Double { let o = _accessor.offset(VTOFFSET.age.v); return o == 0 ? 0.0 : _accessor.readBuffer(of: Double.self, at: o) }
|
||||
public var hasGalaxies: Bool { let o = _accessor.offset(VTOFFSET.galaxies.v); return o == 0 ? false : true }
|
||||
public var galaxiesCount: Int32 { let o = _accessor.offset(VTOFFSET.galaxies.v); return o == 0 ? 0 : _accessor.vector(count: o) }
|
||||
public func galaxies(at index: Int32) -> Galaxy? { let o = _accessor.offset(VTOFFSET.galaxies.v); return o == 0 ? nil : Galaxy(_accessor.bb, o: _accessor.indirect(_accessor.vector(at: o) + index * 4)) }
|
||||
public func galaxies(at index: Int32) -> flatbuffers_goldens_Galaxy? { let o = _accessor.offset(VTOFFSET.galaxies.v); return o == 0 ? nil : flatbuffers_goldens_Galaxy(_accessor.bb, o: _accessor.indirect(_accessor.vector(at: o) + index * 4)) }
|
||||
public static func startUniverse(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 2) }
|
||||
public static func add(age: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: age, def: 0.0, at: VTOFFSET.age.p) }
|
||||
public static func addVectorOf(galaxies: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: galaxies, at: VTOFFSET.galaxies.p) }
|
||||
@@ -68,16 +68,16 @@ public struct Universe: FlatBufferObject, Verifiable {
|
||||
age: Double = 0.0,
|
||||
galaxiesVectorOffset galaxies: Offset = Offset()
|
||||
) -> Offset {
|
||||
let __start = Universe.startUniverse(&fbb)
|
||||
Universe.add(age: age, &fbb)
|
||||
Universe.addVectorOf(galaxies: galaxies, &fbb)
|
||||
return Universe.endUniverse(&fbb, start: __start)
|
||||
let __start = flatbuffers_goldens_Universe.startUniverse(&fbb)
|
||||
flatbuffers_goldens_Universe.add(age: age, &fbb)
|
||||
flatbuffers_goldens_Universe.addVectorOf(galaxies: galaxies, &fbb)
|
||||
return flatbuffers_goldens_Universe.endUniverse(&fbb, start: __start)
|
||||
}
|
||||
|
||||
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
|
||||
var _v = try verifier.visitTable(at: position)
|
||||
try _v.visit(field: VTOFFSET.age.p, fieldName: "age", required: false, type: Double.self)
|
||||
try _v.visit(field: VTOFFSET.galaxies.p, fieldName: "galaxies", required: false, type: ForwardOffset<Vector<ForwardOffset<Galaxy>, Galaxy>>.self)
|
||||
try _v.visit(field: VTOFFSET.galaxies.p, fieldName: "galaxies", required: false, type: ForwardOffset<Vector<ForwardOffset<flatbuffers_goldens_Galaxy>, flatbuffers_goldens_Galaxy>>.self)
|
||||
_v.finish()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
export { Galaxy } from './galaxy.js';
|
||||
export { Universe } from './universe.js';
|
||||
|
||||
6
goldens/ts/flatbuffers/goldens.ts
Normal file
6
goldens/ts/flatbuffers/goldens.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
export { Galaxy } from './goldens/galaxy.js';
|
||||
export { Universe } from './goldens/universe.js';
|
||||
@@ -1,5 +1,7 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
export class Galaxy {
|
||||
@@ -1,8 +1,10 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
import { Galaxy } from './galaxy.js';
|
||||
import { Galaxy } from '../../flatbuffers/goldens/galaxy.js';
|
||||
|
||||
|
||||
export class Universe {
|
||||
@@ -11,3 +11,31 @@ index 1645a264a..12f8ca999 100644
|
||||
add_executable(
|
||||
bssl
|
||||
|
||||
diff --git a/src/crypto/x509/t_x509.c b/src/crypto/x509/t_x509.c
|
||||
index 7c32a8798..6e50d040e 100644
|
||||
--- a/src/crypto/x509/t_x509.c
|
||||
+++ b/src/crypto/x509/t_x509.c
|
||||
@@ -318,9 +318,7 @@ int X509_signature_print(BIO *bp, const X509_ALGOR *sigalg,
|
||||
int X509_NAME_print(BIO *bp, const X509_NAME *name, int obase)
|
||||
{
|
||||
char *s, *c, *b;
|
||||
- int ret = 0, l, i;
|
||||
-
|
||||
- l = 80 - 2 - obase;
|
||||
+ int ret = 0, i;
|
||||
|
||||
b = X509_NAME_oneline(name, NULL, 0);
|
||||
if (!b)
|
||||
@@ -347,12 +345,10 @@ int X509_NAME_print(BIO *bp, const X509_NAME *name, int obase)
|
||||
if (BIO_write(bp, ", ", 2) != 2)
|
||||
goto err;
|
||||
}
|
||||
- l--;
|
||||
}
|
||||
if (*s == '\0')
|
||||
break;
|
||||
s++;
|
||||
- l--;
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
|
||||
@@ -2,9 +2,12 @@ diff --git a/bazel/copts.bzl b/bazel/copts.bzl
|
||||
index 10be944f25..879518b92f 100644
|
||||
--- a/bazel/copts.bzl
|
||||
+++ b/bazel/copts.bzl
|
||||
@@ -59,4 +59,4 @@ GRPC_LLVM_WARNING_FLAGS = [
|
||||
@@ -59,4 +59,7 @@ GRPC_LLVM_WARNING_FLAGS = [
|
||||
GRPC_DEFAULT_COPTS = select({
|
||||
"//:use_strict_warning": GRPC_LLVM_WARNING_FLAGS + ["-DUSE_STRICT_WARNING=1"],
|
||||
"//conditions:default": [],
|
||||
-})
|
||||
+}) + ["-std=c++14"]
|
||||
+}) + select({
|
||||
+ "@bazel_tools//src/conditions:windows": ["/std:c++14"],
|
||||
+ "//conditions:default": ["-std=c++14"],
|
||||
+})
|
||||
|
||||
@@ -5,7 +5,7 @@ go 1.15
|
||||
replace github.com/google/flatbuffers/grpc/examples/go/greeter/models v0.0.0 => ../models
|
||||
|
||||
require (
|
||||
github.com/google/flatbuffers v1.12.0
|
||||
github.com/google/flatbuffers v2.0.8+incompatible
|
||||
github.com/google/flatbuffers/grpc/examples/go/greeter/models v0.0.0
|
||||
google.golang.org/grpc v1.35.0
|
||||
google.golang.org/grpc v1.56.3
|
||||
)
|
||||
|
||||
@@ -3,6 +3,6 @@ module github.com/google/flatbuffers/grpc/examples/go/greeter/models
|
||||
go 1.15
|
||||
|
||||
require (
|
||||
github.com/google/flatbuffers v1.12.0
|
||||
google.golang.org/grpc v1.35.0
|
||||
github.com/google/flatbuffers v2.0.8+incompatible
|
||||
google.golang.org/grpc v1.56.3
|
||||
)
|
||||
|
||||
@@ -5,7 +5,7 @@ go 1.15
|
||||
replace github.com/google/flatbuffers/grpc/examples/go/greeter/models v0.0.0 => ../models
|
||||
|
||||
require (
|
||||
github.com/google/flatbuffers v1.12.0
|
||||
github.com/google/flatbuffers v2.0.8+incompatible
|
||||
github.com/google/flatbuffers/grpc/examples/go/greeter/models v0.0.0
|
||||
google.golang.org/grpc v1.39.0-dev
|
||||
google.golang.org/grpc v1.56.3
|
||||
)
|
||||
|
||||
54
grpc/examples/python/greeter/greeter_grpc.fb.py
Normal file
54
grpc/examples/python/greeter/greeter_grpc.fb.py
Normal file
@@ -0,0 +1,54 @@
|
||||
# Generated by the gRPC FlatBuffers compiler. DO NOT EDIT!
|
||||
|
||||
import flatbuffers
|
||||
import grpc
|
||||
|
||||
from models.HelloReply import HelloReply
|
||||
from models.HelloRequest import HelloRequest
|
||||
|
||||
|
||||
class GreeterStub(object):
|
||||
'''Interface exported by the server.'''
|
||||
|
||||
def __init__(self, channel):
|
||||
'''Constructor.
|
||||
|
||||
Args:
|
||||
channel: A grpc.Channel.
|
||||
'''
|
||||
|
||||
self.SayHello = channel.unary_unary(
|
||||
method='/models.Greeter/SayHello')
|
||||
|
||||
self.SayManyHellos = channel.unary_stream(
|
||||
method='/models.Greeter/SayManyHellos')
|
||||
|
||||
|
||||
class GreeterServicer(object):
|
||||
'''Interface exported by the server.'''
|
||||
|
||||
def SayHello(self, request, context):
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def SayManyHellos(self, request, context):
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
|
||||
def add_GreeterServicer_to_server(servicer, server):
|
||||
rpc_method_handlers = {
|
||||
'SayHello': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.SayHello),
|
||||
'SayManyHellos': grpc.unary_stream_rpc_method_handler(
|
||||
servicer.SayManyHellos),
|
||||
}
|
||||
|
||||
generic_handler = grpc.method_handlers_generic_handler(
|
||||
'models.Greeter', rpc_method_handlers)
|
||||
|
||||
server.add_generic_rpc_handlers((generic_handler,))
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import FlatBuffers
|
||||
|
||||
public struct models_HelloReply: FlatBufferObject, Verifiable {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_23_5_26() }
|
||||
static func validateVersion() { FlatBuffersVersion_24_12_23() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
private var _accessor: Table
|
||||
|
||||
@@ -53,7 +53,7 @@ extension models_HelloReply: Encodable {
|
||||
|
||||
public struct models_HelloRequest: FlatBufferObject, Verifiable {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_23_5_26() }
|
||||
static func validateVersion() { FlatBuffersVersion_24_12_23() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
private var _accessor: Table
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2023 Google Inc. All rights reserved.
|
||||
* 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2023 Google Inc. All rights reserved.
|
||||
* 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.
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
export * as models from './models.js';
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
export { HelloReply } from './models/hello-reply.js';
|
||||
export { HelloRequest } from './models/hello-request.js';
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
</developer>
|
||||
</developers>
|
||||
<properties>
|
||||
<gRPC.version>1.36.0</gRPC.version>
|
||||
<gRPC.version>1.67.1</gRPC.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@@ -95,6 +95,8 @@ cc_library(
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
"//:flatbuffers",
|
||||
"//include/codegen:namer",
|
||||
"//include/codegen:python",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
namespace grpc_cpp_generator {
|
||||
namespace {
|
||||
|
||||
static grpc::string service_header_ext() { return ".grpc.fb.h"; }
|
||||
|
||||
template<class T>
|
||||
static grpc::string as_string(T x) {
|
||||
std::ostringstream out;
|
||||
@@ -1137,7 +1135,7 @@ grpc::string GetSourcePrologue(grpc_generator::File *file,
|
||||
vars["filename"] = file->filename();
|
||||
vars["filename_base"] = file->filename_without_ext();
|
||||
vars["message_header_ext"] = params.message_header_extension;
|
||||
vars["service_header_ext"] = service_header_ext();
|
||||
vars["service_header_ext"] = params.service_header_extension;
|
||||
|
||||
printer->Print(vars, "// Generated by the gRPC C++ plugin.\n");
|
||||
printer->Print(vars,
|
||||
@@ -1557,7 +1555,7 @@ grpc::string GetMockPrologue(grpc_generator::File *file,
|
||||
vars["filename"] = file->filename();
|
||||
vars["filename_base"] = file->filename_without_ext();
|
||||
vars["message_header_ext"] = params.message_header_extension;
|
||||
vars["service_header_ext"] = service_header_ext();
|
||||
vars["service_header_ext"] = params.service_header_extension;
|
||||
|
||||
printer->Print(vars, "// Generated by the gRPC C++ plugin.\n");
|
||||
printer->Print(vars,
|
||||
|
||||
@@ -35,6 +35,8 @@ struct Parameters {
|
||||
bool generate_mock_code;
|
||||
// By default, use "_generated.h"
|
||||
std::string message_header_extension;
|
||||
// Default: ".grpc.fb.h"
|
||||
std::string service_header_extension;
|
||||
};
|
||||
|
||||
// Return the prologue of the generated header file.
|
||||
|
||||
@@ -16,136 +16,365 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
|
||||
#include "flatbuffers/util.h"
|
||||
#include "src/compiler/python_generator.h"
|
||||
|
||||
namespace grpc_python_generator {
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "codegen/idl_namer.h"
|
||||
#include "codegen/namer.h"
|
||||
#include "codegen/python.h"
|
||||
#include "flatbuffers/idl.h"
|
||||
#include "flatbuffers/util.h"
|
||||
|
||||
namespace flatbuffers {
|
||||
namespace python {
|
||||
namespace grpc {
|
||||
namespace {
|
||||
|
||||
static grpc::string GenerateMethodType(const grpc_generator::Method *method) {
|
||||
|
||||
if (method->NoStreaming())
|
||||
return "unary_unary";
|
||||
|
||||
if (method->ServerStreaming())
|
||||
return "unary_stream";
|
||||
|
||||
if (method->ClientStreaming())
|
||||
return "stream_unary";
|
||||
|
||||
return "stream_stream";
|
||||
bool ClientStreaming(const RPCCall *method) {
|
||||
const Value *val = method->attributes.Lookup("streaming");
|
||||
return val != nullptr && (val->constant == "client" || val->constant == "bidi");
|
||||
}
|
||||
|
||||
grpc::string GenerateMethodInput(const grpc_generator::Method *method) {
|
||||
|
||||
if (method->NoStreaming() || method->ServerStreaming())
|
||||
return "self, request, context";
|
||||
|
||||
return "self, request_iterator, context";
|
||||
bool ServerStreaming(const RPCCall *method) {
|
||||
const Value *val = method->attributes.Lookup("streaming");
|
||||
return val != nullptr && (val->constant == "server" || val->constant == "bidi");
|
||||
}
|
||||
|
||||
void GenerateStub(const grpc_generator::Service *service,
|
||||
grpc_generator::Printer *printer,
|
||||
std::map<grpc::string, grpc::string> *dictonary) {
|
||||
auto vars = *dictonary;
|
||||
printer->Print(vars, "class $ServiceName$Stub(object):\n");
|
||||
printer->Indent();
|
||||
printer->Print("\"\"\" Interface exported by the server. \"\"\"");
|
||||
printer->Print("\n\n");
|
||||
printer->Print("def __init__(self, channel):\n");
|
||||
printer->Indent();
|
||||
printer->Print("\"\"\" Constructor. \n\n");
|
||||
printer->Print("Args: \n");
|
||||
printer->Print("channel: A grpc.Channel. \n");
|
||||
printer->Print("\"\"\"\n\n");
|
||||
|
||||
for (int j = 0; j < service->method_count(); j++) {
|
||||
auto method = service->method(j);
|
||||
vars["MethodName"] = method->name();
|
||||
vars["MethodType"] = GenerateMethodType(&*method);
|
||||
printer->Print(vars, "self.$MethodName$ = channel.$MethodType$(\n");
|
||||
printer->Indent();
|
||||
printer->Print(vars, "\"/$PATH$$ServiceName$/$MethodName$\"\n");
|
||||
printer->Print(")\n");
|
||||
printer->Outdent();
|
||||
printer->Print("\n");
|
||||
void FormatImports(std::stringstream &ss, const Imports &imports) {
|
||||
std::set<std::string> modules;
|
||||
std::map<std::string, std::set<std::string>> names_by_module;
|
||||
for (const Import &import : imports.imports) {
|
||||
if (import.IsLocal()) continue; // skip all local imports
|
||||
if (import.name == "") {
|
||||
modules.insert(import.module);
|
||||
} else {
|
||||
names_by_module[import.module].insert(import.name);
|
||||
}
|
||||
}
|
||||
printer->Outdent();
|
||||
printer->Outdent();
|
||||
printer->Print("\n");
|
||||
}
|
||||
|
||||
void GenerateServicer(const grpc_generator::Service *service,
|
||||
grpc_generator::Printer *printer,
|
||||
std::map<grpc::string, grpc::string> *dictonary) {
|
||||
auto vars = *dictonary;
|
||||
printer->Print(vars, "class $ServiceName$Servicer(object):\n");
|
||||
printer->Indent();
|
||||
printer->Print("\"\"\" Interface exported by the server. \"\"\"");
|
||||
printer->Print("\n\n");
|
||||
|
||||
for (int j = 0; j < service->method_count(); j++) {
|
||||
auto method = service->method(j);
|
||||
vars["MethodName"] = method->name();
|
||||
vars["MethodInput"] = GenerateMethodInput(&*method);
|
||||
printer->Print(vars, "def $MethodName$($MethodInput$):\n");
|
||||
printer->Indent();
|
||||
printer->Print("context.set_code(grpc.StatusCode.UNIMPLEMENTED)\n");
|
||||
printer->Print("context.set_details('Method not implemented!')\n");
|
||||
printer->Print("raise NotImplementedError('Method not implemented!')\n");
|
||||
printer->Outdent();
|
||||
printer->Print("\n\n");
|
||||
for (const std::string &module : modules) {
|
||||
ss << "import " << module << '\n';
|
||||
}
|
||||
printer->Outdent();
|
||||
printer->Print("\n");
|
||||
|
||||
}
|
||||
|
||||
void GenerateRegister(const grpc_generator::Service *service,
|
||||
grpc_generator::Printer *printer,
|
||||
std::map<grpc::string, grpc::string> *dictonary) {
|
||||
auto vars = *dictonary;
|
||||
printer->Print(vars, "def add_$ServiceName$Servicer_to_server(servicer, server):\n");
|
||||
printer->Indent();
|
||||
printer->Print("rpc_method_handlers = {\n");
|
||||
printer->Indent();
|
||||
for (int j = 0; j < service->method_count(); j++) {
|
||||
auto method = service->method(j);
|
||||
vars["MethodName"] = method->name();
|
||||
vars["MethodType"] = GenerateMethodType(&*method);
|
||||
printer->Print(vars, "'$MethodName$': grpc.$MethodType$_rpc_method_handler(\n");
|
||||
printer->Indent();
|
||||
printer->Print(vars, "servicer.$MethodName$\n");
|
||||
printer->Outdent();
|
||||
printer->Print("),\n");
|
||||
ss << '\n';
|
||||
for (const auto &import : names_by_module) {
|
||||
ss << "from " << import.first << " import ";
|
||||
size_t i = 0;
|
||||
for (const std::string &name : import.second) {
|
||||
if (i > 0) ss << ", ";
|
||||
ss << name;
|
||||
++i;
|
||||
}
|
||||
ss << '\n';
|
||||
}
|
||||
printer->Outdent();
|
||||
printer->Print("}\n");
|
||||
printer->Print(vars, "generic_handler = grpc.method_handlers_generic_handler(\n");
|
||||
printer->Indent();
|
||||
printer->Print(vars, "'$PATH$$ServiceName$', rpc_method_handlers)\n");
|
||||
printer->Outdent();
|
||||
printer->Print("server.add_generic_rpc_handlers((generic_handler,))");
|
||||
printer->Outdent();
|
||||
printer->Print("\n");
|
||||
}
|
||||
} // namespace
|
||||
|
||||
grpc::string Generate(grpc_generator::File *file,
|
||||
const grpc_generator::Service *service) {
|
||||
grpc::string output;
|
||||
std::map<grpc::string, grpc::string> vars;
|
||||
vars["PATH"] = file->package();
|
||||
if (!file->package().empty()) { vars["PATH"].append("."); }
|
||||
vars["ServiceName"] = service->name();
|
||||
auto printer = file->CreatePrinter(&output);
|
||||
GenerateStub(service, &*printer, &vars);
|
||||
GenerateServicer(service, &*printer, &vars);
|
||||
GenerateRegister(service, &*printer, &vars);
|
||||
return output;
|
||||
ss << "\n\n";
|
||||
}
|
||||
|
||||
} // namespace grpc_python_generator
|
||||
bool SaveStub(const std::string &filename, const Imports &imports,
|
||||
const std::string &content) {
|
||||
std::stringstream ss;
|
||||
ss << "# Generated by the gRPC FlatBuffers compiler. DO NOT EDIT!\n"
|
||||
<< '\n'
|
||||
<< "from __future__ import annotations\n"
|
||||
<< '\n';
|
||||
FormatImports(ss, imports);
|
||||
ss << content << '\n';
|
||||
|
||||
EnsureDirExists(StripFileName(filename));
|
||||
return flatbuffers::SaveFile(filename.c_str(), ss.str(), false);
|
||||
}
|
||||
|
||||
bool SaveService(const std::string &filename, const Imports &imports,
|
||||
const std::string &content) {
|
||||
std::stringstream ss;
|
||||
ss << "# Generated by the gRPC FlatBuffers compiler. DO NOT EDIT!\n" << '\n';
|
||||
FormatImports(ss, imports);
|
||||
ss << content << '\n';
|
||||
|
||||
EnsureDirExists(StripFileName(filename));
|
||||
return flatbuffers::SaveFile(filename.c_str(), ss.str(), false);
|
||||
}
|
||||
|
||||
class BaseGenerator {
|
||||
protected:
|
||||
BaseGenerator(const Parser &parser, const Namer::Config &config,
|
||||
const std::string &path, const Version &version)
|
||||
: parser_{parser},
|
||||
namer_{WithFlagOptions(config, parser.opts, path), Keywords(version)},
|
||||
version_{version} {}
|
||||
|
||||
protected:
|
||||
std::string ModuleForFile(const std::string &file) const {
|
||||
std::string module = parser_.opts.include_prefix + StripExtension(file) +
|
||||
parser_.opts.filename_suffix;
|
||||
std::replace(module.begin(), module.end(), '/', '.');
|
||||
return module;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string ModuleFor(const T *def) const {
|
||||
if (parser_.opts.one_file) return ModuleForFile(def->file);
|
||||
return namer_.NamespacedType(*def);
|
||||
}
|
||||
|
||||
const Parser &parser_;
|
||||
const IdlNamer namer_;
|
||||
const Version version_;
|
||||
};
|
||||
|
||||
class StubGenerator : public BaseGenerator {
|
||||
public:
|
||||
StubGenerator(const Parser &parser, const std::string &path,
|
||||
const Version &version)
|
||||
: BaseGenerator(parser, kStubConfig, path, version) {}
|
||||
|
||||
bool Generate() {
|
||||
Imports imports;
|
||||
std::stringstream stub;
|
||||
for (const ServiceDef *service : parser_.services_.vec) {
|
||||
Generate(stub, service, &imports);
|
||||
}
|
||||
|
||||
std::string filename =
|
||||
namer_.config_.output_path +
|
||||
StripPath(StripExtension(parser_.file_being_parsed_)) + "_grpc" +
|
||||
parser_.opts.grpc_filename_suffix + namer_.config_.filename_extension;
|
||||
|
||||
return SaveStub(filename, imports, stub.str());
|
||||
}
|
||||
|
||||
private:
|
||||
void Generate(std::stringstream &ss, const ServiceDef *service,
|
||||
Imports *imports) {
|
||||
imports->Import("grpc");
|
||||
|
||||
ss << "class " << service->name << "Stub(object):\n"
|
||||
<< " def __init__(self, channel: grpc.Channel) -> None: ...\n";
|
||||
|
||||
for (const RPCCall *method : service->calls.vec) {
|
||||
std::string request = "bytes";
|
||||
std::string response = "bytes";
|
||||
|
||||
if (parser_.opts.grpc_python_typed_handlers) {
|
||||
request = namer_.Type(*method->request);
|
||||
response = namer_.Type(*method->response);
|
||||
|
||||
imports->Import(ModuleFor(method->request), request);
|
||||
imports->Import(ModuleFor(method->response), response);
|
||||
}
|
||||
|
||||
ss << " def " << method->name << "(self, ";
|
||||
if (ClientStreaming(method)) {
|
||||
imports->Import("typing");
|
||||
ss << "request_iterator: typing.Iterator[" << request << "]";
|
||||
} else {
|
||||
ss << "request: " << request;
|
||||
}
|
||||
ss << ") -> ";
|
||||
if (ServerStreaming(method)) {
|
||||
imports->Import("typing");
|
||||
ss << "typing.Iterator[" << response << "]";
|
||||
} else {
|
||||
ss << response;
|
||||
}
|
||||
ss << ": ...\n";
|
||||
}
|
||||
|
||||
ss << "\n\n";
|
||||
ss << "class " << service->name << "Servicer(object):\n";
|
||||
|
||||
for (const RPCCall *method : service->calls.vec) {
|
||||
std::string request = "bytes";
|
||||
std::string response = "bytes";
|
||||
|
||||
if (parser_.opts.grpc_python_typed_handlers) {
|
||||
request = namer_.Type(*method->request);
|
||||
response = namer_.Type(*method->response);
|
||||
|
||||
imports->Import(ModuleFor(method->request), request);
|
||||
imports->Import(ModuleFor(method->response), response);
|
||||
}
|
||||
|
||||
ss << " def " << method->name << "(self, ";
|
||||
if (ClientStreaming(method)) {
|
||||
imports->Import("typing");
|
||||
ss << "request_iterator: typing.Iterator[" << request << "]";
|
||||
} else {
|
||||
ss << "request: " << request;
|
||||
}
|
||||
ss << ", context: grpc.ServicerContext) -> ";
|
||||
if (ServerStreaming(method)) {
|
||||
imports->Import("typing");
|
||||
ss << "typing.Iterator[" << response << "]";
|
||||
} else {
|
||||
ss << response;
|
||||
}
|
||||
ss << ": ...\n";
|
||||
}
|
||||
|
||||
ss << '\n'
|
||||
<< '\n'
|
||||
<< "def add_" << service->name
|
||||
<< "Servicer_to_server(servicer: " << service->name
|
||||
<< "Servicer, server: grpc.Server) -> None: ...\n";
|
||||
}
|
||||
};
|
||||
|
||||
class ServiceGenerator : public BaseGenerator {
|
||||
public:
|
||||
ServiceGenerator(const Parser &parser, const std::string &path,
|
||||
const Version &version)
|
||||
: BaseGenerator(parser, kConfig, path, version) {}
|
||||
|
||||
bool Generate() {
|
||||
Imports imports;
|
||||
std::stringstream ss;
|
||||
|
||||
imports.Import("flatbuffers");
|
||||
|
||||
if (parser_.opts.grpc_python_typed_handlers) {
|
||||
ss << "def _serialize_to_bytes(table):\n"
|
||||
<< " buf = table._tab.Bytes\n"
|
||||
<< " n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, 0)\n"
|
||||
<< " if table._tab.Pos != n:\n"
|
||||
<< " raise ValueError('must be a top-level table')\n"
|
||||
<< " return bytes(buf)\n"
|
||||
<< '\n'
|
||||
<< '\n';
|
||||
}
|
||||
|
||||
for (const ServiceDef *service : parser_.services_.vec) {
|
||||
GenerateStub(ss, service, &imports);
|
||||
GenerateServicer(ss, service, &imports);
|
||||
GenerateRegister(ss, service, &imports);
|
||||
}
|
||||
|
||||
std::string filename =
|
||||
namer_.config_.output_path +
|
||||
StripPath(StripExtension(parser_.file_being_parsed_)) + "_grpc" +
|
||||
parser_.opts.grpc_filename_suffix + namer_.config_.filename_extension;
|
||||
|
||||
return SaveService(filename, imports, ss.str());
|
||||
}
|
||||
|
||||
private:
|
||||
void GenerateStub(std::stringstream &ss, const ServiceDef *service,
|
||||
Imports *imports) {
|
||||
ss << "class " << service->name << "Stub";
|
||||
if (version_.major != 3) ss << "(object)";
|
||||
ss << ":\n"
|
||||
<< " '''Interface exported by the server.'''\n"
|
||||
<< '\n'
|
||||
<< " def __init__(self, channel):\n"
|
||||
<< " '''Constructor.\n"
|
||||
<< '\n'
|
||||
<< " Args:\n"
|
||||
<< " channel: A grpc.Channel.\n"
|
||||
<< " '''\n"
|
||||
<< '\n';
|
||||
|
||||
for (const RPCCall *method : service->calls.vec) {
|
||||
std::string response = namer_.Type(*method->response);
|
||||
|
||||
imports->Import(ModuleFor(method->response), response);
|
||||
|
||||
ss << " self." << method->name << " = channel."
|
||||
<< (ClientStreaming(method) ? "stream" : "unary") << "_"
|
||||
<< (ServerStreaming(method) ? "stream" : "unary") << "(\n"
|
||||
<< " method='/"
|
||||
<< service->defined_namespace->GetFullyQualifiedName(service->name)
|
||||
<< "/" << method->name << "'";
|
||||
|
||||
if (parser_.opts.grpc_python_typed_handlers) {
|
||||
ss << ",\n"
|
||||
<< " request_serializer=_serialize_to_bytes,\n"
|
||||
<< " response_deserializer=" << response << ".GetRootAs";
|
||||
}
|
||||
ss << ")\n\n";
|
||||
}
|
||||
|
||||
ss << '\n';
|
||||
}
|
||||
|
||||
void GenerateServicer(std::stringstream &ss, const ServiceDef *service,
|
||||
Imports *imports) {
|
||||
imports->Import("grpc");
|
||||
|
||||
ss << "class " << service->name << "Servicer";
|
||||
if (version_.major != 3) ss << "(object)";
|
||||
ss << ":\n"
|
||||
<< " '''Interface exported by the server.'''\n"
|
||||
<< '\n';
|
||||
|
||||
for (const RPCCall *method : service->calls.vec) {
|
||||
const std::string request_param =
|
||||
ClientStreaming(method) ? "request_iterator" : "request";
|
||||
ss << " def " << method->name << "(self, " << request_param
|
||||
<< ", context):\n"
|
||||
<< " context.set_code(grpc.StatusCode.UNIMPLEMENTED)\n"
|
||||
<< " context.set_details('Method not implemented!')\n"
|
||||
<< " raise NotImplementedError('Method not implemented!')\n"
|
||||
<< '\n';
|
||||
}
|
||||
|
||||
ss << '\n';
|
||||
}
|
||||
|
||||
void GenerateRegister(std::stringstream &ss, const ServiceDef *service,
|
||||
Imports *imports) {
|
||||
imports->Import("grpc");
|
||||
|
||||
ss << "def add_" << service->name
|
||||
<< "Servicer_to_server(servicer, server):\n"
|
||||
<< " rpc_method_handlers = {\n";
|
||||
|
||||
for (const RPCCall *method : service->calls.vec) {
|
||||
std::string request = namer_.Type(*method->request);
|
||||
|
||||
imports->Import(ModuleFor(method->request), request);
|
||||
|
||||
ss << " '" << method->name << "': grpc."
|
||||
<< (ClientStreaming(method) ? "stream" : "unary") << "_"
|
||||
<< (ServerStreaming(method) ? "stream" : "unary")
|
||||
<< "_rpc_method_handler(\n"
|
||||
<< " servicer." << method->name;
|
||||
|
||||
if (parser_.opts.grpc_python_typed_handlers) {
|
||||
ss << ",\n"
|
||||
<< " request_deserializer=" << request << ".GetRootAs,\n"
|
||||
<< " response_serializer=_serialize_to_bytes";
|
||||
}
|
||||
ss << "),\n";
|
||||
}
|
||||
ss << " }\n"
|
||||
<< '\n'
|
||||
<< " generic_handler = grpc.method_handlers_generic_handler(\n"
|
||||
<< " '"
|
||||
<< service->defined_namespace->GetFullyQualifiedName(service->name)
|
||||
<< "', rpc_method_handlers)\n"
|
||||
<< '\n'
|
||||
<< " server.add_generic_rpc_handlers((generic_handler,))\n"
|
||||
<< '\n';
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
bool Generate(const Parser &parser, const std::string &path,
|
||||
const Version &version) {
|
||||
ServiceGenerator generator{parser, path, version};
|
||||
return generator.Generate();
|
||||
}
|
||||
|
||||
bool GenerateStub(const Parser &parser, const std::string &path,
|
||||
const Version &version) {
|
||||
StubGenerator generator{parser, path, version};
|
||||
return generator.Generate();
|
||||
}
|
||||
|
||||
} // namespace grpc
|
||||
} // namespace python
|
||||
} // namespace flatbuffers
|
||||
|
||||
@@ -19,14 +19,21 @@
|
||||
#ifndef GRPC_INTERNAL_COMPILER_PYTHON_GENERATOR_H
|
||||
#define GRPC_INTERNAL_COMPILER_PYTHON_GENERATOR_H
|
||||
|
||||
#include <utility>
|
||||
#include <string>
|
||||
|
||||
#include "src/compiler/schema_interface.h"
|
||||
#include "codegen/python.h"
|
||||
#include "flatbuffers/idl.h"
|
||||
|
||||
namespace grpc_python_generator {
|
||||
namespace flatbuffers {
|
||||
namespace python {
|
||||
namespace grpc {
|
||||
bool Generate(const Parser &parser, const std::string &path,
|
||||
const Version &version);
|
||||
|
||||
grpc::string Generate(grpc_generator::File *file,
|
||||
const grpc_generator::Service *service);
|
||||
} // namespace grpc_python_generator
|
||||
bool GenerateStub(const Parser &parser, const std::string &path,
|
||||
const Version &version);
|
||||
} // namespace grpc
|
||||
} // namespace python
|
||||
} // namespace flatbuffers
|
||||
|
||||
#endif // GRPC_INTERNAL_COMPILER_PYTHON_GENERATOR_H
|
||||
|
||||
39
include/codegen/BUILD.bazel
Normal file
39
include/codegen/BUILD.bazel
Normal file
@@ -0,0 +1,39 @@
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library")
|
||||
|
||||
package(
|
||||
default_visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "distribution",
|
||||
srcs = [
|
||||
"BUILD.bazel",
|
||||
] + glob([
|
||||
"*.cc",
|
||||
"*.h",
|
||||
]),
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "namer",
|
||||
hdrs = [
|
||||
"idl_namer.h",
|
||||
"namer.h",
|
||||
],
|
||||
strip_include_prefix = "/include",
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = ["//:runtime_cc"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "python",
|
||||
srcs = ["python.cc"],
|
||||
hdrs = ["python.h"],
|
||||
strip_include_prefix = "/include",
|
||||
visibility = [
|
||||
"//grpc:__subpackages__",
|
||||
"//src:__subpackages__",
|
||||
],
|
||||
deps = [":namer"],
|
||||
)
|
||||
179
include/codegen/idl_namer.h
Normal file
179
include/codegen/idl_namer.h
Normal file
@@ -0,0 +1,179 @@
|
||||
#ifndef FLATBUFFERS_INCLUDE_CODEGEN_IDL_NAMER_H_
|
||||
#define FLATBUFFERS_INCLUDE_CODEGEN_IDL_NAMER_H_
|
||||
|
||||
#include "codegen/namer.h"
|
||||
#include "flatbuffers/idl.h"
|
||||
|
||||
namespace flatbuffers {
|
||||
|
||||
// Provides Namer capabilities to types defined in the flatbuffers IDL.
|
||||
class IdlNamer : public Namer {
|
||||
public:
|
||||
explicit IdlNamer(Config config, std::set<std::string> keywords)
|
||||
: Namer(config, std::move(keywords)) {}
|
||||
|
||||
using Namer::Constant;
|
||||
using Namer::Directories;
|
||||
using Namer::Field;
|
||||
using Namer::File;
|
||||
using Namer::Function;
|
||||
using Namer::Method;
|
||||
using Namer::Namespace;
|
||||
using Namer::NamespacedType;
|
||||
using Namer::ObjectType;
|
||||
using Namer::Type;
|
||||
using Namer::Variable;
|
||||
using Namer::Variant;
|
||||
|
||||
std::string Constant(const FieldDef &d) const { return Constant(d.name); }
|
||||
|
||||
// Types are always structs or enums so we can only expose these two
|
||||
// overloads.
|
||||
std::string Type(const StructDef &d) const { return Type(d.name); }
|
||||
std::string Type(const EnumDef &d) const { return Type(d.name); }
|
||||
|
||||
std::string Function(const Definition &s) const { return Function(s.name); }
|
||||
std::string Function(const std::string& prefix, const Definition &s) const {
|
||||
return Function(prefix + s.name);
|
||||
}
|
||||
|
||||
std::string Field(const FieldDef &s) const { return Field(s.name); }
|
||||
std::string Field(const FieldDef &d, const std::string &s) const {
|
||||
return Field(d.name + "_" + s);
|
||||
}
|
||||
|
||||
std::string Variable(const FieldDef &s) const { return Variable(s.name); }
|
||||
|
||||
std::string Variable(const StructDef &s) const { return Variable(s.name); }
|
||||
|
||||
std::string Variant(const EnumVal &s) const { return Variant(s.name); }
|
||||
|
||||
std::string EnumVariant(const EnumDef &e, const EnumVal &v) const {
|
||||
return Type(e) + config_.enum_variant_seperator + Variant(v);
|
||||
}
|
||||
|
||||
std::string ObjectType(const StructDef &d) const {
|
||||
return ObjectType(d.name);
|
||||
}
|
||||
std::string ObjectType(const EnumDef &d) const { return ObjectType(d.name); }
|
||||
|
||||
std::string Method(const FieldDef &d, const std::string &suffix) const {
|
||||
return Method(d.name, suffix);
|
||||
}
|
||||
std::string Method(const std::string &prefix, const StructDef &d) const {
|
||||
return Method(prefix, d.name);
|
||||
}
|
||||
std::string Method(const std::string &prefix, const FieldDef &d) const {
|
||||
return Method(prefix, d.name);
|
||||
}
|
||||
std::string Method(const std::string &prefix, const FieldDef &d,
|
||||
const std::string &suffix) const {
|
||||
return Method(prefix, d.name, suffix);
|
||||
}
|
||||
|
||||
std::string Namespace(const struct Namespace &ns) const {
|
||||
return Namespace(ns.components);
|
||||
}
|
||||
|
||||
std::string NamespacedEnumVariant(const EnumDef &e, const EnumVal &v) const {
|
||||
return NamespacedString(e.defined_namespace, EnumVariant(e, v));
|
||||
}
|
||||
|
||||
std::string NamespacedType(const Definition &def) const {
|
||||
return NamespacedString(def.defined_namespace, Type(def.name));
|
||||
}
|
||||
|
||||
std::string NamespacedObjectType(const Definition &def) const {
|
||||
return NamespacedString(def.defined_namespace, ObjectType(def.name));
|
||||
}
|
||||
|
||||
std::string Directories(const struct Namespace &ns,
|
||||
SkipDir skips = SkipDir::None,
|
||||
Case input_case = Case::kUpperCamel) const {
|
||||
return Directories(ns.components, skips, input_case);
|
||||
}
|
||||
|
||||
// Legacy fields do not really follow the usual config and should be
|
||||
// considered for deprecation.
|
||||
|
||||
std::string LegacyRustNativeVariant(const EnumVal &v) const {
|
||||
return ConvertCase(EscapeKeyword(v.name), Case::kUpperCamel);
|
||||
}
|
||||
|
||||
std::string LegacyRustFieldOffsetName(const FieldDef &field) const {
|
||||
return "VT_" + ConvertCase(EscapeKeyword(field.name), Case::kAllUpper);
|
||||
}
|
||||
std::string LegacyRustUnionTypeOffsetName(const FieldDef &field) const {
|
||||
return "VT_" + ConvertCase(EscapeKeyword(field.name + "_type"), Case::kAllUpper);
|
||||
}
|
||||
|
||||
|
||||
std::string LegacySwiftVariant(const EnumVal &ev) const {
|
||||
auto name = ev.name;
|
||||
if (isupper(name.front())) {
|
||||
std::transform(name.begin(), name.end(), name.begin(), CharToLower);
|
||||
}
|
||||
return EscapeKeyword(ConvertCase(name, Case::kLowerCamel));
|
||||
}
|
||||
|
||||
// Also used by Kotlin, lol.
|
||||
std::string LegacyJavaMethod2(const std::string &prefix, const StructDef &sd,
|
||||
const std::string &suffix) const {
|
||||
return prefix + sd.name + suffix;
|
||||
}
|
||||
|
||||
std::string LegacyKotlinVariant(EnumVal &ev) const {
|
||||
// Namer assumes the input case is snake case which is wrong...
|
||||
return ConvertCase(EscapeKeyword(ev.name), Case::kLowerCamel);
|
||||
}
|
||||
// Kotlin methods escapes keywords after case conversion but before
|
||||
// prefixing and suffixing.
|
||||
std::string LegacyKotlinMethod(const std::string &prefix, const FieldDef &d,
|
||||
const std::string &suffix) const {
|
||||
return prefix + ConvertCase(EscapeKeyword(d.name), Case::kUpperCamel) +
|
||||
suffix;
|
||||
}
|
||||
std::string LegacyKotlinMethod(const std::string &prefix, const StructDef &d,
|
||||
const std::string &suffix) const {
|
||||
return prefix + ConvertCase(EscapeKeyword(d.name), Case::kUpperCamel) +
|
||||
suffix;
|
||||
}
|
||||
|
||||
// This is a mix of snake case and keep casing, when Ts should be using
|
||||
// lower camel case.
|
||||
std::string LegacyTsMutateMethod(const FieldDef& d) {
|
||||
return "mutate_" + d.name;
|
||||
}
|
||||
|
||||
std::string LegacyRustUnionTypeMethod(const FieldDef &d) {
|
||||
// assert d is a union
|
||||
// d should convert case but not escape keywords due to historical reasons
|
||||
return ConvertCase(d.name, config_.fields, Case::kLowerCamel) + "_type";
|
||||
}
|
||||
|
||||
private:
|
||||
std::string NamespacedString(const struct Namespace *ns,
|
||||
const std::string &str) const {
|
||||
std::string ret;
|
||||
if (ns != nullptr) { ret += Namespace(ns->components); }
|
||||
if (!ret.empty()) ret += config_.namespace_seperator;
|
||||
return ret + str;
|
||||
}
|
||||
};
|
||||
|
||||
// This is a temporary helper function for code generators to call until all
|
||||
// flag-overriding logic into flatc.cpp
|
||||
inline Namer::Config WithFlagOptions(const Namer::Config &input,
|
||||
const IDLOptions &opts,
|
||||
const std::string &path) {
|
||||
Namer::Config result = input;
|
||||
result.object_prefix = opts.object_prefix;
|
||||
result.object_suffix = opts.object_suffix;
|
||||
result.output_path = path;
|
||||
result.filename_suffix = opts.filename_suffix;
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace flatbuffers
|
||||
|
||||
#endif // FLATBUFFERS_INCLUDE_CODEGEN_IDL_NAMER_H_
|
||||
270
include/codegen/namer.h
Normal file
270
include/codegen/namer.h
Normal file
@@ -0,0 +1,270 @@
|
||||
#ifndef FLATBUFFERS_INCLUDE_CODEGEN_NAMER_H_
|
||||
#define FLATBUFFERS_INCLUDE_CODEGEN_NAMER_H_
|
||||
|
||||
#include "flatbuffers/util.h"
|
||||
|
||||
namespace flatbuffers {
|
||||
|
||||
// Options for Namer::File.
|
||||
enum class SkipFile {
|
||||
None = 0,
|
||||
Suffix = 1,
|
||||
Extension = 2,
|
||||
SuffixAndExtension = 3,
|
||||
};
|
||||
inline SkipFile operator&(SkipFile a, SkipFile b) {
|
||||
return static_cast<SkipFile>(static_cast<int>(a) & static_cast<int>(b));
|
||||
}
|
||||
// Options for Namer::Directories
|
||||
enum class SkipDir {
|
||||
None = 0,
|
||||
// Skip prefixing the -o $output_path.
|
||||
OutputPath = 1,
|
||||
// Skip trailing path seperator.
|
||||
TrailingPathSeperator = 2,
|
||||
OutputPathAndTrailingPathSeparator = 3,
|
||||
};
|
||||
inline SkipDir operator&(SkipDir a, SkipDir b) {
|
||||
return static_cast<SkipDir>(static_cast<int>(a) & static_cast<int>(b));
|
||||
}
|
||||
|
||||
// `Namer` applies style configuration to symbols in generated code. It manages
|
||||
// casing, escapes keywords, and object API naming.
|
||||
// TODO: Refactor all code generators to use this.
|
||||
class Namer {
|
||||
public:
|
||||
struct Config {
|
||||
// Symbols in code.
|
||||
|
||||
// Case style for flatbuffers-defined types.
|
||||
// e.g. `class TableA {}`
|
||||
Case types;
|
||||
// Case style for flatbuffers-defined constants.
|
||||
// e.g. `uint64_t ENUM_A_MAX`;
|
||||
Case constants;
|
||||
// Case style for flatbuffers-defined methods.
|
||||
// e.g. `class TableA { int field_a(); }`
|
||||
Case methods;
|
||||
// Case style for flatbuffers-defined functions.
|
||||
// e.g. `TableA* get_table_a_root()`;
|
||||
Case functions;
|
||||
// Case style for flatbuffers-defined fields.
|
||||
// e.g. `struct Struct { int my_field; }`
|
||||
Case fields;
|
||||
// Case style for flatbuffers-defined variables.
|
||||
// e.g. `int my_variable = 2`
|
||||
Case variables;
|
||||
// Case style for flatbuffers-defined variants.
|
||||
// e.g. `enum class Enum { MyVariant, }`
|
||||
Case variants;
|
||||
// Seperator for qualified enum names.
|
||||
// e.g. `Enum::MyVariant` uses `::`.
|
||||
std::string enum_variant_seperator;
|
||||
|
||||
// Configures, when formatting code, whether symbols are checked against
|
||||
// keywords and escaped before or after case conversion. It does not make
|
||||
// sense to do so before, but its legacy behavior. :shrug:
|
||||
// TODO(caspern): Deprecate.
|
||||
enum class Escape {
|
||||
BeforeConvertingCase,
|
||||
AfterConvertingCase,
|
||||
};
|
||||
Escape escape_keywords;
|
||||
|
||||
// Namespaces
|
||||
|
||||
// e.g. `namespace my_namespace {}`
|
||||
Case namespaces;
|
||||
// The seperator between namespaces in a namespace path.
|
||||
std::string namespace_seperator;
|
||||
|
||||
// Object API.
|
||||
// Native versions flatbuffers types have this prefix.
|
||||
// e.g. "" (it's usually empty string)
|
||||
std::string object_prefix;
|
||||
// Native versions flatbuffers types have this suffix.
|
||||
// e.g. "T"
|
||||
std::string object_suffix;
|
||||
|
||||
// Keywords.
|
||||
// Prefix used to escape keywords. It is usually empty string.
|
||||
std::string keyword_prefix;
|
||||
// Suffix used to escape keywords. It is usually "_".
|
||||
std::string keyword_suffix;
|
||||
|
||||
// Files.
|
||||
|
||||
// Case style for filenames. e.g. `foo_bar_generated.rs`
|
||||
Case filenames;
|
||||
// Case style for directories, e.g. `output_files/foo_bar/baz/`
|
||||
Case directories;
|
||||
// The directory within which we will generate files.
|
||||
std::string output_path;
|
||||
// Suffix for generated file names, e.g. "_generated".
|
||||
std::string filename_suffix;
|
||||
// Extension for generated files, e.g. ".cpp" or ".rs".
|
||||
std::string filename_extension;
|
||||
};
|
||||
Namer(Config config, std::set<std::string> keywords)
|
||||
: config_(config), keywords_(std::move(keywords)) {}
|
||||
|
||||
virtual ~Namer() {}
|
||||
|
||||
template<typename T> std::string Method(const T &s) const {
|
||||
return Method(s.name);
|
||||
}
|
||||
|
||||
virtual std::string Method(const std::string &pre,
|
||||
const std::string &mid,
|
||||
const std::string &suf) const {
|
||||
return Format(pre + "_" + mid + "_" + suf, config_.methods);
|
||||
}
|
||||
virtual std::string Method(const std::string &pre,
|
||||
const std::string &suf) const {
|
||||
return Format(pre + "_" + suf, config_.methods);
|
||||
}
|
||||
virtual std::string Method(const std::string &s) const {
|
||||
return Format(s, config_.methods);
|
||||
}
|
||||
|
||||
virtual std::string Constant(const std::string &s) const {
|
||||
return Format(s, config_.constants);
|
||||
}
|
||||
|
||||
virtual std::string Function(const std::string &s) const {
|
||||
return Format(s, config_.functions);
|
||||
}
|
||||
|
||||
virtual std::string Variable(const std::string &s) const {
|
||||
return Format(s, config_.variables);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::string Variable(const std::string &p, const T &s) const {
|
||||
return Format(p + "_" + s.name, config_.variables);
|
||||
}
|
||||
virtual std::string Variable(const std::string &p,
|
||||
const std::string &s) const {
|
||||
return Format(p + "_" + s, config_.variables);
|
||||
}
|
||||
|
||||
virtual std::string Namespace(const std::string &s) const {
|
||||
return Format(s, config_.namespaces);
|
||||
}
|
||||
|
||||
virtual std::string Namespace(const std::vector<std::string> &ns) const {
|
||||
std::string result;
|
||||
for (auto it = ns.begin(); it != ns.end(); it++) {
|
||||
if (it != ns.begin()) result += config_.namespace_seperator;
|
||||
result += Namespace(*it);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
virtual std::string NamespacedType(const std::vector<std::string> &ns,
|
||||
const std::string &s) const {
|
||||
return (ns.empty() ? "" : (Namespace(ns) + config_.namespace_seperator)) +
|
||||
Type(s);
|
||||
}
|
||||
|
||||
// Returns `filename` with the right casing, suffix, and extension.
|
||||
virtual std::string File(const std::string &filename,
|
||||
SkipFile skips = SkipFile::None) const {
|
||||
const bool skip_suffix = (skips & SkipFile::Suffix) != SkipFile::None;
|
||||
const bool skip_ext = (skips & SkipFile::Extension) != SkipFile::None;
|
||||
return ConvertCase(filename, config_.filenames, Case::kUpperCamel) +
|
||||
(skip_suffix ? "" : config_.filename_suffix) +
|
||||
(skip_ext ? "" : config_.filename_extension);
|
||||
}
|
||||
template<typename T>
|
||||
std::string File(const T &f, SkipFile skips = SkipFile::None) const {
|
||||
return File(f.name, skips);
|
||||
}
|
||||
|
||||
// Formats `directories` prefixed with the output_path and joined with the
|
||||
// right seperator. Output path prefixing and the trailing separator may be
|
||||
// skiped using `skips`.
|
||||
// Callers may want to use `EnsureDirExists` with the result.
|
||||
// input_case is used to tell how to modify namespace. e.g. kUpperCamel will
|
||||
// add a underscode between case changes, so MyGame turns into My_Game
|
||||
// (depending also on the output_case).
|
||||
virtual std::string Directories(const std::vector<std::string> &directories,
|
||||
SkipDir skips = SkipDir::None,
|
||||
Case input_case = Case::kUpperCamel) const {
|
||||
const bool skip_output_path =
|
||||
(skips & SkipDir::OutputPath) != SkipDir::None;
|
||||
const bool skip_trailing_seperator =
|
||||
(skips & SkipDir::TrailingPathSeperator) != SkipDir::None;
|
||||
std::string result = skip_output_path ? "" : config_.output_path;
|
||||
for (auto d = directories.begin(); d != directories.end(); d++) {
|
||||
result += ConvertCase(*d, config_.directories, input_case);
|
||||
result.push_back(kPathSeparator);
|
||||
}
|
||||
if (skip_trailing_seperator && !result.empty()) result.pop_back();
|
||||
return result;
|
||||
}
|
||||
|
||||
virtual std::string EscapeKeyword(const std::string &name) const {
|
||||
if (keywords_.find(name) == keywords_.end()) {
|
||||
return name;
|
||||
} else {
|
||||
return config_.keyword_prefix + name + config_.keyword_suffix;
|
||||
}
|
||||
}
|
||||
|
||||
virtual std::string Type(const std::string &s) const {
|
||||
return Format(s, config_.types);
|
||||
}
|
||||
virtual std::string Type(const std::string &t, const std::string &s) const {
|
||||
return Format(t + "_" + s, config_.types);
|
||||
}
|
||||
|
||||
virtual std::string ObjectType(const std::string &s) const {
|
||||
return config_.object_prefix + Type(s) + config_.object_suffix;
|
||||
}
|
||||
|
||||
virtual std::string Field(const std::string &s) const {
|
||||
return Format(s, config_.fields);
|
||||
}
|
||||
|
||||
virtual std::string Variant(const std::string &s) const {
|
||||
return Format(s, config_.variants);
|
||||
}
|
||||
|
||||
virtual std::string Format(const std::string &s, Case casing) const {
|
||||
if (config_.escape_keywords == Config::Escape::BeforeConvertingCase) {
|
||||
return ConvertCase(EscapeKeyword(s), casing, Case::kLowerCamel);
|
||||
} else {
|
||||
return EscapeKeyword(ConvertCase(s, casing, Case::kLowerCamel));
|
||||
}
|
||||
}
|
||||
|
||||
// Denamespaces a string (e.g. The.Quick.Brown.Fox) by returning the last part
|
||||
// after the `delimiter` (Fox) and placing the rest in `namespace_prefix`
|
||||
// (The.Quick.Brown).
|
||||
virtual std::string Denamespace(const std::string &s,
|
||||
std::string &namespace_prefix,
|
||||
const char delimiter = '.') const {
|
||||
const size_t pos = s.find_last_of(delimiter);
|
||||
if (pos == std::string::npos) {
|
||||
namespace_prefix = "";
|
||||
return s;
|
||||
}
|
||||
namespace_prefix = s.substr(0, pos);
|
||||
return s.substr(pos + 1);
|
||||
}
|
||||
|
||||
// Same as above, but disregards the prefix.
|
||||
virtual std::string Denamespace(const std::string &s,
|
||||
const char delimiter = '.') const {
|
||||
std::string prefix;
|
||||
return Denamespace(s, prefix, delimiter);
|
||||
}
|
||||
|
||||
const Config config_;
|
||||
const std::set<std::string> keywords_;
|
||||
};
|
||||
|
||||
} // namespace flatbuffers
|
||||
|
||||
#endif // FLATBUFFERS_INCLUDE_CODEGEN_NAMER_H_
|
||||
63
include/codegen/python.cc
Normal file
63
include/codegen/python.cc
Normal file
@@ -0,0 +1,63 @@
|
||||
#include "codegen/python.h"
|
||||
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace flatbuffers {
|
||||
namespace python {
|
||||
Version::Version(const std::string &version) {
|
||||
std::stringstream ss(version);
|
||||
char dot;
|
||||
ss >> major >> dot >> minor >> dot >> micro;
|
||||
}
|
||||
|
||||
bool Version::IsValid() const {
|
||||
return (major == 0 || major == 2 || major == 3) && minor >= 0 && micro >= 0;
|
||||
}
|
||||
|
||||
std::set<std::string> Keywords(const Version &version) {
|
||||
switch (version.major) {
|
||||
case 2:
|
||||
// https://docs.python.org/2/reference/lexical_analysis.html#keywords
|
||||
return {
|
||||
"and", "as", "assert", "break", "class", "continue", "def",
|
||||
"del", "elif", "else", "except", "exec", "finally", "for",
|
||||
"from", "global", "if", "import", "in", "is", "lambda",
|
||||
"not", "or", "pass", "print", "raise", "return", "try",
|
||||
"while", "with", "yield",
|
||||
};
|
||||
case 0:
|
||||
case 3:
|
||||
// https://docs.python.org/3/reference/lexical_analysis.html#keywords
|
||||
return {
|
||||
"and", "as", "assert", "async", "await", "break",
|
||||
"class", "continue", "def", "del", "elif", "else",
|
||||
"except", "False", "finally", "for", "from", "global",
|
||||
"if", "import", "in", "is", "lambda", "None",
|
||||
"nonlocal", "not", "or", "pass", "raise", "return",
|
||||
"True", "try", "while", "with", "yield",
|
||||
};
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
const python::Import &python::Imports::Import(const std::string &module) {
|
||||
python::Import import;
|
||||
import.module = module;
|
||||
imports.push_back(std::move(import));
|
||||
return imports.back();
|
||||
}
|
||||
|
||||
const python::Import &python::Imports::Import(const std::string &module,
|
||||
const std::string &name) {
|
||||
python::Import import;
|
||||
import.module = module;
|
||||
import.name = name;
|
||||
imports.push_back(std::move(import));
|
||||
return imports.back();
|
||||
}
|
||||
} // namespace python
|
||||
} // namespace flatbuffers
|
||||
93
include/codegen/python.h
Normal file
93
include/codegen/python.h
Normal file
@@ -0,0 +1,93 @@
|
||||
#ifndef FLATBUFFERS_INCLUDE_CODEGEN_PYTHON_H_
|
||||
#define FLATBUFFERS_INCLUDE_CODEGEN_PYTHON_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "codegen/namer.h"
|
||||
|
||||
namespace flatbuffers {
|
||||
namespace python {
|
||||
static const Namer::Config kConfig = {
|
||||
/*types=*/Case::kKeep,
|
||||
/*constants=*/Case::kScreamingSnake,
|
||||
/*methods=*/Case::kUpperCamel,
|
||||
/*functions=*/Case::kUpperCamel,
|
||||
/*fields=*/Case::kLowerCamel,
|
||||
/*variable=*/Case::kLowerCamel,
|
||||
/*variants=*/Case::kKeep,
|
||||
/*enum_variant_seperator=*/".",
|
||||
/*escape_keywords=*/Namer::Config::Escape::AfterConvertingCase,
|
||||
/*namespaces=*/Case::kKeep, // Packages in python.
|
||||
/*namespace_seperator=*/".",
|
||||
/*object_prefix=*/"",
|
||||
/*object_suffix=*/"T",
|
||||
/*keyword_prefix=*/"",
|
||||
/*keyword_suffix=*/"_",
|
||||
/*filenames=*/Case::kKeep,
|
||||
/*directories=*/Case::kKeep,
|
||||
/*output_path=*/"",
|
||||
/*filename_suffix=*/"",
|
||||
/*filename_extension=*/".py",
|
||||
};
|
||||
|
||||
static const Namer::Config kStubConfig = {
|
||||
/*types=*/Case::kKeep,
|
||||
/*constants=*/Case::kScreamingSnake,
|
||||
/*methods=*/Case::kUpperCamel,
|
||||
/*functions=*/Case::kUpperCamel,
|
||||
/*fields=*/Case::kLowerCamel,
|
||||
/*variables=*/Case::kLowerCamel,
|
||||
/*variants=*/Case::kKeep,
|
||||
/*enum_variant_seperator=*/".",
|
||||
/*escape_keywords=*/Namer::Config::Escape::AfterConvertingCase,
|
||||
/*namespaces=*/Case::kKeep, // Packages in python.
|
||||
/*namespace_seperator=*/".",
|
||||
/*object_prefix=*/"",
|
||||
/*object_suffix=*/"T",
|
||||
/*keyword_prefix=*/"",
|
||||
/*keyword_suffix=*/"_",
|
||||
/*filenames=*/Case::kKeep,
|
||||
/*directories=*/Case::kKeep,
|
||||
/*output_path=*/"",
|
||||
/*filename_suffix=*/"",
|
||||
/*filename_extension=*/".pyi",
|
||||
};
|
||||
|
||||
// `Version` represent a Python version.
|
||||
//
|
||||
// The zero value (i.e. `Version{}`) represents both Python2 and Python3.
|
||||
//
|
||||
// https://docs.python.org/3/faq/general.html#how-does-the-python-version-numbering-scheme-work
|
||||
struct Version {
|
||||
explicit Version(const std::string &version);
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
int16_t major = 0;
|
||||
int16_t minor = 0;
|
||||
int16_t micro = 0;
|
||||
};
|
||||
|
||||
std::set<std::string> Keywords(const Version &version);
|
||||
|
||||
struct Import {
|
||||
bool IsLocal() const { return module == "."; }
|
||||
|
||||
std::string module;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
struct Imports {
|
||||
const python::Import &Import(const std::string &module);
|
||||
const python::Import &Import(const std::string &module,
|
||||
const std::string &name);
|
||||
|
||||
std::vector<python::Import> imports;
|
||||
};
|
||||
} // namespace python
|
||||
} // namespace flatbuffers
|
||||
|
||||
#endif // FLATBUFFERS_INCLUDE_CODEGEN_PYTHON_H_
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user