Compare commits

..

23 Commits

Author SHA1 Message Date
Derek Bailey
acf39ff056 FlatBuffers Version 22.12.06 (#7702) 2022-12-06 22:54:49 -08:00
Derek Bailey
0e79e56427 inline initialize byte_width 2022-12-06 22:18:11 -08:00
郭浩伟
aadc4cb8be fix: byte_width_ = 1U << static_cast<BitWidth>(packed_type & 3) implicit conversion loses integer precision: 'unsigned int' to 'uint8_t' (aka 'unsigned char') [-Werror,-Wimplicit-int-conversion] (#7697)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-12-06 21:19:54 -08:00
Wen Sun
b5ebd3fd78 [C++] Update to address comparator failure in big endian (#7681)
* update unit test and generated file to test is extra endianswap can help resolve issue

* remove EndianScalar wrapper from Get method

* remove endianscalar wrapper

* update

* update

* use Array instead

* clang format

* address error

* clang

* update

* manually generate

* Move Nim to completed language

* Add swift link

* address comments

* update unit test

* address comment

* address comment

* regenerate file

* use auto instead of size_t

* use uint32_t instead

* update

* format

* delete extra whitespace

Co-authored-by: Wen Sun <sunwen@google.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-12-06 14:02:16 -08:00
Michael Mickelson
11394575bc Fix "Download Doxygen" URL (#7699) 2022-12-06 14:01:12 -08:00
James Kuszmaul
5b7b36e8be Upgrade rules_go for Bazel 7.0 support (#7691)
Fixes: #7664 (hopefully)

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-12-05 16:56:02 -08:00
RishabhDeep Singh
c0230d839b Refactor src/idl_gen_cpp.cpp (#7693)
* Refactor for loops and simplify code

* Refactor for loops and simplify code

* Fix for loop and reformat

* reformat code
2022-12-06 00:43:38 +00:00
RishabhDeep Singh
a8d49f2972 Add LICENSE.txt to python (#7692)
* Add LICENSE.txt to python

* Remove LICENSE.txt from python path and used the root LICENSE.txt file
2022-12-05 16:37:21 -08:00
Derek Bailey
416c6020eb Add swift link 2022-12-02 20:52:20 -08:00
Derek Bailey
6d95867a8f Move Nim to completed language 2022-12-02 20:49:03 -08:00
Derek Bailey
2eaf790638 Fix confrom failure for nullptr dereference. (#7688) 2022-12-01 20:21:48 -08:00
Derek Bailey
3b2ced0131 Update missing C# namespace to Google.FlatBuffers 2022-12-01 20:04:49 -08:00
Michael Le
00af4e23b3 Remove --gen-name-strings flag from cmake command for generating union_vector_generated.h (#7684)
* Sync make outputs with master

* Remove --gen-name-string flag from CMAKE
2022-11-30 20:57:06 -08:00
Sergei Trofimovich
7e00b754f0 tests/reflection_test.h: add missing <stdint.h> include (#7680)
Without the change build fails on weekly `gcc-13` snapshots as:

    In file included from /build/flatbuffers/tests/reflection_test.cpp:1:
    tests/reflection_test.h:9:57: error: 'uint8_t' has not been declared
        9 | void ReflectionTest(const std::string& tests_data_path, uint8_t *flatbuf, size_t length);
          |                                                         ^~~~~~~
2022-11-30 18:47:10 -08:00
Louis Laugesen
cf89d1e756 Fix PHP byte validation and reenable builds (#7670)
* Fix PHP byte validation and reenable builds

* Use checkout@v3

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-11-29 08:12:28 -08:00
sssooonnnggg
ad6054c600 chore: emit more reasonable error message when using incomplete type in struct (#7678)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-11-29 04:59:53 +00:00
Michael Le
c3a01c7228 Use FinshedBytes() in go-echo example instead of manually encoding offset (#7660)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-11-29 02:29:48 +00:00
Saman
533f75d91b Fix java import wild card (#7672)
* Fix java import wild card

* fix java include

* Fix some import problems

* clang-format

* Sort imports

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-11-28 17:27:55 -08:00
Derek Bailey
fcab80f1bb build.yml: MacOs Build Inplace (#7677)
* `build.yml`: MacOs Build Inplace

* Update build.yml
2022-11-28 16:38:56 -08:00
Derek Bailey
5d2d0b92b1 build.yml Update dependencies (#7674)
* `build.yml` Update dependencies

* Update build.yml

* Update build.yml

* `build.yml`: Use macos-11

* Update build.yml
2022-11-28 15:34:32 -08:00
Derek Bailey
ae6662374d add buildkite badge 2022-11-23 13:11:56 -08:00
Casper
7b6c9f4a3c Rurel (#7663)
* Update release script to update Rust version (it still needs to be published after)

* Also update rust while I'm at it

Co-authored-by: Casper Neo <cneo@google.com>
2022-11-23 12:03:54 -08:00
Derek Bailey
5a42b2c76c Specify min android SDK version of 14 2022-11-23 11:54:36 -08:00
216 changed files with 1301 additions and 825 deletions

View File

@@ -27,7 +27,7 @@ jobs:
cxx: [g++-10, clang++-12]
fail-fast: false
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: cmake
run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON .
- name: build
@@ -76,7 +76,7 @@ jobs:
- cxx: g++-10
std: 23
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: cmake
run: >
CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles"
@@ -99,7 +99,7 @@ jobs:
std: [11, 14, 17, 20, 23]
fail-fast: false
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
- name: cmake
@@ -124,7 +124,7 @@ jobs:
name: Build Windows 2019
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
- name: cmake
@@ -159,7 +159,7 @@ jobs:
name: Build Windows 2017
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
- name: cmake
@@ -173,7 +173,7 @@ jobs:
name: Build Windows 2015
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
- name: cmake
@@ -195,9 +195,9 @@ jobs:
#'-p:EnableSpanT=true,UnsafeByteBuffer=true'
]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v1.9.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: '3.1.x'
- name: Build
@@ -219,34 +219,33 @@ jobs:
name: Build Mac (for Intel)
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: cmake
run: cmake -G "Xcode" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_FLATC_EXECUTABLE=_build/Release/flatc -DFLATBUFFERS_STRICT_MODE=ON .
run: cmake -G "Xcode" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON .
- name: build
# NOTE: we need this _build dir to not have xcodebuild's default ./build dir clash with the BUILD file.
run: xcodebuild -toolchain clang -configuration Release -target flattests SYMROOT=$(PWD)/_build
run: xcodebuild -toolchain clang -configuration Release -target flattests
- name: check that the binary is x86_64
run: |
info=$(file _build/Release/flatc)
info=$(file Release/flatc)
echo $info
echo $info | grep "Mach-O 64-bit executable x86_64"
- name: test
run: _build/Release/flattests
run: Release/flattests
- name: make flatc executable
run: |
chmod +x _build/Release/flatc
./_build/Release/flatc --version
chmod +x Release/flatc
Release/flatc --version
- name: flatc tests
run: python3 tests/flatc/main.py --flatc ./_build/Release/flatc
run: python3 tests/flatc/main.py --flatc Release/flatc
- name: upload build artifacts
uses: actions/upload-artifact@v1
with:
name: Mac flatc binary
path: _build/Release/flatc
path: Release/flatc
# Below if only for release.
- name: Zip file
if: startsWith(github.ref, 'refs/tags/')
run: mv _build/Release/flatc . && zip MacIntel.flatc.binary.zip flatc
run: mv Release/flatc . && zip MacIntel.flatc.binary.zip flatc
- name: Release binary
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
@@ -265,32 +264,31 @@ jobs:
name: Build Mac (universal build)
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: cmake
run: cmake -G "Xcode" -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_FLATC_EXECUTABLE=_build/Release/flatc -DFLATBUFFERS_STRICT_MODE=ON .
run: cmake -G "Xcode" -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON .
- name: build
# NOTE: we need this _build dir to not have xcodebuild's default ./build dir clash with the BUILD file.
run: xcodebuild -toolchain clang -configuration Release -target flattests SYMROOT=$(PWD)/_build
run: xcodebuild -toolchain clang -configuration Release -target flattests
- name: check that the binary is "universal"
run: |
info=$(file _build/Release/flatc)
info=$(file Release/flatc)
echo $info
echo $info | grep "Mach-O universal binary with 2 architectures"
- name: test
run: _build/Release/flattests
run: Release/flattests
- name: make flatc executable
run: |
chmod +x _build/Release/flatc
./_build/Release/flatc --version
chmod +x Release/flatc
Release/flatc --version
- name: upload build artifacts
uses: actions/upload-artifact@v1
with:
name: Mac flatc binary
path: _build/Release/flatc
path: Release/flatc
# Below if only for release.
- name: Zip file
if: startsWith(github.ref, 'refs/tags/')
run: mv _build/Release/flatc . && zip Mac.flatc.binary.zip flatc
run: mv Release/flatc . && zip Mac.flatc.binary.zip flatc
- name: Release binary
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
@@ -305,11 +303,12 @@ jobs:
name: Build Android (on Linux)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: set up JDK 1.8
uses: actions/setup-java@v1
- uses: actions/checkout@v3
- name: set up Java
uses: actions/setup-java@v3
with:
java-version: 1.8
distribution: 'temurin'
java-version: '11'
- name: set up flatc
run: |
cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_STRICT_MODE=ON .
@@ -326,7 +325,7 @@ jobs:
matrix:
cxx: [g++-10, clang++-12]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: cmake
run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON . && make -j
- name: Generate
@@ -341,7 +340,7 @@ jobs:
matrix:
cxx: [g++-10]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: cmake
run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DFLATBUFFERS_CXX_FLAGS="-Wno-unused-parameter -fno-aligned-new" -DFLATBUFFERS_BUILD_BENCHMARKS=ON -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON . && make -j
- name: Run benchmarks
@@ -356,7 +355,7 @@ jobs:
name: Build Java
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: test
working-directory: java
run: mvn test
@@ -366,11 +365,11 @@ jobs:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- uses: gradle/wrapper-validation-action@v1.0.5
- uses: actions/setup-java@v2
- uses: actions/setup-java@v3
with:
distribution: 'adopt-hotspot'
distribution: 'temurin'
java-version: '11'
- name: Build
working-directory: kotlin
@@ -381,10 +380,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-java@v2
uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'adopt-hotspot'
distribution: 'temurin'
java-version: '11'
- uses: gradle/wrapper-validation-action@v1.0.5
- name: Build
@@ -398,7 +397,7 @@ jobs:
name: Build Rust
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: test
working-directory: tests
run: bash RustTest.sh
@@ -407,7 +406,7 @@ jobs:
name: Build Python
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: test
working-directory: tests
run: bash PythonTest.sh
@@ -416,7 +415,7 @@ jobs:
name: Build Go
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: flatc
# FIXME: make test script not rely on flatc
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_STRICT_MODE=ON . && make -j
@@ -424,11 +423,25 @@ jobs:
working-directory: tests
run: bash GoTest.sh
build-php:
name: Build PHP
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: flatc
# FIXME: make test script not rely on flatc
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_STRICT_MODE=ON . && make -j
- name: test
working-directory: tests
run: |
php phpTest.php
sh phpUnionVectorTest.sh
build-swift:
name: Build Swift
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: test
working-directory: tests/swift/tests
run: |
@@ -441,9 +454,9 @@ jobs:
container:
image: ghcr.io/swiftwasm/carton:0.15.3
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup Wasmer
uses: wasmerio/setup-wasmer@v1
uses: wasmerio/setup-wasmer@v2
- name: Test
working-directory: tests/swift/Wasm.tests
run: carton test
@@ -452,7 +465,7 @@ jobs:
name: Build TS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: flatc
# FIXME: make test script not rely on flatc
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF . && make -j
@@ -468,7 +481,7 @@ jobs:
name: Build Dart
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
with:
sdk: stable
@@ -483,7 +496,7 @@ jobs:
name: Build Nim
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: flatc
# FIXME: make test script not rely on flatc
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF . && make -j

View File

@@ -4,7 +4,11 @@ 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.
## 22.10.25 (Oct 25 2002)
## 22.12.06 (Dec 06 2022)
* Bug fixing release, no major changes.
## 22.10.25 (Oct 25 2022)
* Added Nim language support with generator and runtime libraries (#7534).

View File

@@ -1,6 +1,6 @@
set(VERSION_MAJOR 22)
set(VERSION_MINOR 11)
set(VERSION_PATCH 23)
set(VERSION_MINOR 12)
set(VERSION_PATCH 06)
set(VERSION_COMMIT 0)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")

View File

@@ -632,7 +632,7 @@ if(FLATBUFFERS_BUILD_TESTS)
compile_flatbuffers_schema_to_binary(tests/monster_test.fbs)
compile_flatbuffers_schema_to_cpp_opt(tests/namespace_test/namespace_test1.fbs "--no-includes;--gen-compare;--gen-name-strings")
compile_flatbuffers_schema_to_cpp_opt(tests/namespace_test/namespace_test2.fbs "--no-includes;--gen-compare;--gen-name-strings")
compile_flatbuffers_schema_to_cpp_opt(tests/union_vector/union_vector.fbs "--no-includes;--gen-compare;--gen-name-strings")
compile_flatbuffers_schema_to_cpp_opt(tests/union_vector/union_vector.fbs "--no-includes;--gen-compare;")
compile_flatbuffers_schema_to_cpp(tests/optional_scalars.fbs)
compile_flatbuffers_schema_to_cpp_opt(tests/native_type_test.fbs "")
compile_flatbuffers_schema_to_cpp_opt(tests/arrays_test.fbs "--scoped-enums;--gen-compare")

View File

@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'FlatBuffers'
s.version = '22.11.23'
s.version = '22.12.06'
s.summary = 'FlatBuffers: Memory Efficient Serialization Library'
s.description = "FlatBuffers is a cross platform serialization library architected for

View File

@@ -33,10 +33,10 @@ swift_rules_extra_dependencies()
http_archive(
name = "io_bazel_rules_go",
sha256 = "16e9fca53ed6bd4ff4ad76facc9b7b651a89db1689a2877d6fd7b82aa824e366",
sha256 = "ae013bf35bd23234d1dea46b079f1e05ba74ac0321423830119d3e787ec73483",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.34.0/rules_go-v0.34.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.34.0/rules_go-v0.34.0.zip",
"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",
],
)

View File

@@ -3,6 +3,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.FlatBufferTest">
<uses-sdk android:minSdkVersion="14"/>
<uses-feature android:glEsVersion="0x00020000"></uses-feature>
<!-- This .apk has no Java code itself, so set hasCode to false. -->

View File

@@ -36,7 +36,7 @@ class Animal : Table() {
return if(o != 0) bb.getShort(o + bb_pos).toUShort() else 0u
}
companion object {
fun validateVersion() = Constants.FLATBUFFERS_22_11_23()
fun validateVersion() = Constants.FLATBUFFERS_22_12_06()
fun getRootAsAnimal(_bb: ByteBuffer): Animal = getRootAsAnimal(_bb, Animal())
fun getRootAsAnimal(_bb: ByteBuffer, obj: Animal): Animal {
_bb.order(ByteOrder.LITTLE_ENDIAN)

View File

@@ -1,5 +1,5 @@
name: flat_buffers
version: 22.11.23
version: 22.12.06
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

View File

@@ -82,7 +82,7 @@ pass to the `GetRootAsMyRootType` function:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cs}
using MyGame.Example;
using FlatBuffers;
using Google.FlatBuffers;
// This snippet ignores exceptions for brevity.
byte[] data = File.ReadAllBytes("monsterdata_test.mon");

View File

@@ -4,7 +4,7 @@ To generate the docs for FlatBuffers from the source files, you
will first need to install two programs.
1. You will need to install `doxygen`. See
[Download Doxygen](http://www.stack.nl/~dimitri/doxygen/download.html).
[Download Doxygen](https://doxygen.nl/download.html).
2. You will need to install `doxypypy` to format python comments appropriately.
Install it from [here](https://github.com/Feneric/doxypypy).

View File

@@ -415,7 +415,7 @@ The first step is to import/include the library, generated files, etc.
</div>
<div class="language-csharp">
~~~{.cs}
using FlatBuffers;
using Google.FlatBuffers;
using MyGame.Sample; // The `flatc` generated files. (Monster, Vec3, etc.)
~~~
</div>
@@ -2200,7 +2200,7 @@ before:
</div>
<div class="language-csharp">
~~~{.cs}
using FlatBuffers;
using Google.FlatBuffers;
using MyGame.Sample; // The `flatc` generated files. (Monster, Vec3, etc.)
~~~
</div>
@@ -3449,7 +3449,7 @@ Java supports vectors of unions, but it isn't currently documented.
</div>
<div class="language-csharp">
~~~{.cs}
using FlatBuffers;
using Google.FlatBuffers;
using Example.VectorOfUnions;
var fbb = new FlatBufferBuilder(100);

View File

@@ -16,13 +16,7 @@ func RequestBody() *bytes.Reader {
b := flatbuffers.NewBuilder(0)
r := net.RequestT{Player: &hero.WarriorT{Name: "Krull", Hp: 100}}
b.Finish(r.Pack(b))
// Encode builder head in last 4 bytes of request body
buf := make([]byte, 4)
flatbuffers.WriteUOffsetT(buf, b.Head())
buf = append(b.Bytes, buf...)
return bytes.NewReader(buf)
return bytes.NewReader(b.FinishedBytes())
}
func ReadResponse(r *http.Response) {
@@ -32,18 +26,13 @@ func ReadResponse(r *http.Response) {
return
}
// Last 4 bytes is offset.
off := flatbuffers.GetUOffsetT(body[len(body)-4:])
buf := body[:len(body) - 4]
res := net.GetRootAsResponse(buf, off)
res := net.GetRootAsResponse(body, 0)
player := res.Player(nil)
fmt.Printf("Got response (name: %v, hp: %v)\n", string(player.Name()), player.Hp())
}
func main() {
body := RequestBody()
req, err := http.NewRequest("POST", "http://localhost:8080/echo", body)
if err != nil {

View File

@@ -5,8 +5,6 @@ import (
"fmt"
"io/ioutil"
"net/http"
flatbuffers "github.com/google/flatbuffers/go"
)
func echo(w http.ResponseWriter, r *http.Request) {
@@ -16,11 +14,7 @@ func echo(w http.ResponseWriter, r *http.Request) {
return
}
// Last 4 bytes is offset. See client.go.
off := flatbuffers.GetUOffsetT(body[len(body)-4:])
buf := body[:len(body) - 4]
req := net.GetRootAsRequest(buf, off)
req := net.GetRootAsRequest(body, 0)
player := req.Player(nil)
fmt.Printf("Got request (name: %v, hp: %v)\n", string(player.Name()), player.Hp())

View File

@@ -6,7 +6,7 @@ import FlatBuffers
public struct models_HelloReply: FlatBufferObject, Verifiable {
static func validateVersion() { FlatBuffersVersion_22_11_23() }
static func validateVersion() { FlatBuffersVersion_22_12_06() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
@@ -55,7 +55,7 @@ extension models_HelloReply: Encodable {
public struct models_HelloRequest: FlatBufferObject, Verifiable {
static func validateVersion() { FlatBuffersVersion_22_11_23() }
static func validateVersion() { FlatBuffersVersion_22_12_06() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table

View File

@@ -139,8 +139,8 @@
#endif // !defined(FLATBUFFERS_LITTLEENDIAN)
#define FLATBUFFERS_VERSION_MAJOR 22
#define FLATBUFFERS_VERSION_MINOR 11
#define FLATBUFFERS_VERSION_REVISION 23
#define FLATBUFFERS_VERSION_MINOR 12
#define FLATBUFFERS_VERSION_REVISION 06
#define FLATBUFFERS_STRING_EXPAND(X) #X
#define FLATBUFFERS_STRING(X) FLATBUFFERS_STRING_EXPAND(X)
namespace flatbuffers {

View File

@@ -383,9 +383,10 @@ class Reference {
type_(type) {}
Reference(const uint8_t *data, uint8_t parent_width, uint8_t packed_type)
: data_(data), parent_width_(parent_width) {
byte_width_ = 1U << static_cast<BitWidth>(packed_type & 3);
type_ = static_cast<Type>(packed_type >> 2);
: data_(data),
parent_width_(parent_width),
byte_width_(1 << (packed_type & 3)),
type_(static_cast<Type>(packed_type >> 2)) {
}
Type GetType() const { return type_; }

View File

@@ -473,6 +473,10 @@ inline bool IsStruct(const Type &type) {
return type.base_type == BASE_TYPE_STRUCT && type.struct_def->fixed;
}
inline bool IsIncompleteStruct(const Type &type) {
return type.base_type == BASE_TYPE_STRUCT && type.struct_def->predecl;
}
inline bool IsTable(const Type &type) {
return type.base_type == BASE_TYPE_STRUCT && !type.struct_def->fixed;
}
@@ -537,8 +541,11 @@ inline bool operator!=(const EnumVal &lhs, const EnumVal &rhs) {
inline bool EqualByName(const Type &a, const Type &b) {
return a.base_type == b.base_type && a.element == b.element &&
(a.struct_def == b.struct_def ||
a.struct_def->name == b.struct_def->name) &&
(a.enum_def == b.enum_def || a.enum_def->name == b.enum_def->name);
(a.struct_def != nullptr && b.struct_def != nullptr &&
a.struct_def->name == b.struct_def->name)) &&
(a.enum_def == b.enum_def ||
(a.enum_def != nullptr && b.enum_def != nullptr &&
a.enum_def->name == b.enum_def->name));
}
struct RPCCall : public Definition {

View File

@@ -9,8 +9,8 @@
// 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 == 22 &&
FLATBUFFERS_VERSION_MINOR == 11 &&
FLATBUFFERS_VERSION_REVISION == 23,
FLATBUFFERS_VERSION_MINOR == 12 &&
FLATBUFFERS_VERSION_REVISION == 6,
"Non-compatible flatbuffers version included");
namespace reflection {

View File

@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.flatbuffers</groupId>
<artifactId>flatbuffers-java</artifactId>
<version>22.11.23</version>
<version>22.12.06</version>
<packaging>bundle</packaging>
<name>FlatBuffers Java API</name>
<description>

View File

@@ -46,7 +46,7 @@ public class Constants {
Changes to the Java implementation need to be sure to change
the version here and in the code generator on every possible
incompatible change */
public static void FLATBUFFERS_22_11_23() {}
public static void FLATBUFFERS_22_12_06() {}
}
/// @endcond

View File

@@ -32,6 +32,6 @@ namespace Google.FlatBuffers
Changes to the C# implementation need to be sure to change
the version here and in the code generator on every possible
incompatible change */
public static void FLATBUFFERS_22_11_23() {}
public static void FLATBUFFERS_22_12_06() {}
}
}

View File

@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.1;netstandard2.0;net46</TargetFrameworks>
<Description>A cross-platform memory efficient serialization library</Description>
<PackageVersion>22.11.23</PackageVersion>
<PackageVersion>22.12.06</PackageVersion>
<Authors>Google LLC</Authors>
<PackageProjectUrl>https://github.com/google/flatbuffers</PackageProjectUrl>
<RepositoryUrl>https://github.com/google/flatbuffers</RepositoryUrl>

View File

@@ -1,6 +1,6 @@
{
"name": "flatbuffers",
"version": "22.11.23",
"version": "22.12.06",
"description": "Memory Efficient Serialization Library",
"files": [
"js/**/*.js",

View File

@@ -486,7 +486,12 @@ class ByteBuffer
}
private static function validateValue($min, $max, $value, $type, $additional_notes = "") {
if(!($min <= $value && $value <= $max)) {
if (
!(
($type === "byte" && $min <= ord($value) && ord($value) <= $max) ||
($min <= $value && $value <= $max)
)
) {
throw new \InvalidArgumentException(sprintf("bad number %s for type %s.%s", $value, $type, $additional_notes));
}
}

View File

@@ -14,4 +14,4 @@
# Placeholder, to be updated during the release process
# by the setup.py
__version__ = u"22.11.23"
__version__ = u"22.12.06"

View File

@@ -1,2 +1,6 @@
[bdist_wheel]
universal=1
[metadata]
license_files =
../license.txt

View File

@@ -16,8 +16,9 @@ from setuptools import setup
setup(
name='flatbuffers',
version='22.11.23',
version='22.12.06',
license='Apache 2.0',
license_files='../LICENSE.txt',
author='Derek Bailey',
author_email='derekbailey@google.com',
url='https://google.github.io/flatbuffers/',

View File

@@ -2,6 +2,7 @@
===========
![Build status](https://github.com/google/flatbuffers/actions/workflows/build.yml/badge.svg?branch=master)
[![BuildKite status](https://badge.buildkite.com/7979d93bc6279aa539971f271253c65d5e8fe2fe43c90bbb25.svg)](https://buildkite.com/bazel/flatbuffers)
[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/flatbuffers.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:flatbuffers)
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/google/flatbuffers/badge)](https://api.securityscorecards.dev/projects/github.com/google/flatbuffers)
[![Join the chat at https://gitter.im/google/flatbuffers](https://badges.gitter.im/google/flatbuffers.svg)](https://gitter.im/google/flatbuffers?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
@@ -39,12 +40,9 @@ Code generation and runtime libraries for many popular languages.
1. PHP
1. Python - [PyPi](https://pypi.org/project/flatbuffers/)
1. Rust - [crates.io](https://crates.io/crates/flatbuffers)
1. Swift
1. Swift - [swiftpackageindex](https://swiftpackageindex.com/google/flatbuffers)
1. TypeScript - [NPM](https://www.npmjs.com/package/flatbuffers)
*and more in progress...*
1. [Nim](https://github.com/google/flatbuffers/pull/7362)
1. Nim
## Contribution

View File

@@ -1,6 +1,6 @@
[package]
name = "flatbuffers"
version = "22.10.26"
version = "22.12.6"
edition = "2018"
authors = ["Robert Winslow <hello@rwinslow.com>", "FlatBuffers Maintainers"]
license = "Apache-2.0"

View File

@@ -17,7 +17,7 @@
// To run, use the `csharp_sample.sh` script.
using System;
using FlatBuffers;
using Google.FlatBuffers;
using MyGame.Sample;
class SampleBinary

View File

@@ -9,8 +9,8 @@
// 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 == 22 &&
FLATBUFFERS_VERSION_MINOR == 11 &&
FLATBUFFERS_VERSION_REVISION == 23,
FLATBUFFERS_VERSION_MINOR == 12 &&
FLATBUFFERS_VERSION_REVISION == 6,
"Non-compatible flatbuffers version included");
namespace MyGame {

View File

@@ -31,7 +31,7 @@ public enum MyGame_Sample_Equipment: UInt8, Enum {
public struct MyGame_Sample_Vec3: NativeStruct {
static func validateVersion() { FlatBuffersVersion_22_11_23() }
static func validateVersion() { FlatBuffersVersion_22_12_06() }
private var _x: Float32
private var _y: Float32
@@ -56,7 +56,7 @@ public struct MyGame_Sample_Vec3: NativeStruct {
public struct MyGame_Sample_Vec3_Mutable: FlatBufferObject {
static func validateVersion() { FlatBuffersVersion_22_11_23() }
static func validateVersion() { FlatBuffersVersion_22_12_06() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -72,7 +72,7 @@ public struct MyGame_Sample_Vec3_Mutable: FlatBufferObject {
public struct MyGame_Sample_Monster: FlatBufferObject {
static func validateVersion() { FlatBuffersVersion_22_11_23() }
static func validateVersion() { FlatBuffersVersion_22_12_06() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
@@ -162,7 +162,7 @@ public struct MyGame_Sample_Monster: FlatBufferObject {
public struct MyGame_Sample_Weapon: FlatBufferObject {
static func validateVersion() { FlatBuffersVersion_22_11_23() }
static func validateVersion() { FlatBuffersVersion_22_12_06() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table

View File

@@ -63,6 +63,11 @@ sed -i \
-e "s/\(version='\).*/\1$version',/" \
python/setup.py
echo "Updating rust/flatbuffers/Cargo.toml..."
sed -i \
"s/^version = \".*\"$/version = \"$version\"/g" \
rust/flatbuffers/Cargo.toml
echo "Updating FlatBuffers.podspec..."
sed -i \
-e "s/\(s.version\s*= \).*/\1'$version'/" \
@@ -78,4 +83,4 @@ echo "Updating FLATBUFFERS_X_X_X() version check...."
grep -rl 'FLATBUFFERS_\d*' * --exclude=release.sh | xargs -i@ \
sed -i \
-e "s/\(FLATBUFFERS_\)[0-9]\{2\}.*()/\1$version_underscore()/g" \
@
@

View File

@@ -60,9 +60,8 @@ static std::string GenIncludeGuard(const std::string &file_name,
guard = "FLATBUFFERS_GENERATED_" + guard;
guard += "_";
// For further uniqueness, also add the namespace.
for (auto it = name_space.components.begin();
it != name_space.components.end(); ++it) {
guard += *it + "_";
for (const std::string &component : name_space.components) {
guard += component + "_";
}
// Anything extra to add to the guard?
if (!postfix.empty()) { guard += postfix + "_"; }
@@ -236,9 +235,9 @@ class CppGenerator : public BaseGenerator {
void GenIncludeDependencies() {
if (opts_.generate_object_based_api) {
for (auto it = parser_.native_included_files_.begin();
it != parser_.native_included_files_.end(); ++it) {
code_ += "#include \"" + *it + "\"";
for (const std::string &native_included_file :
parser_.native_included_files_) {
code_ += "#include \"" + native_included_file + "\"";
}
}
@@ -272,8 +271,8 @@ class CppGenerator : public BaseGenerator {
}
void GenExtraIncludes() {
for (std::size_t i = 0; i < opts_.cpp_includes.size(); ++i) {
code_ += "#include \"" + opts_.cpp_includes[i] + "\"";
for (const std::string &cpp_include : opts_.cpp_includes) {
code_ += "#include \"" + cpp_include + "\"";
}
if (!opts_.cpp_includes.empty()) { code_ += ""; }
}
@@ -411,18 +410,16 @@ class CppGenerator : public BaseGenerator {
// Generate forward declarations for all structs/tables, since they may
// have circular references.
for (auto it = parser_.structs_.vec.begin();
it != parser_.structs_.vec.end(); ++it) {
const auto &struct_def = **it;
if (!struct_def.generated) {
SetNameSpace(struct_def.defined_namespace);
code_ += "struct " + Name(struct_def) + ";";
if (!struct_def.fixed) {
code_ += "struct " + Name(struct_def) + "Builder;";
for (const auto &struct_def : parser_.structs_.vec) {
if (!struct_def->generated) {
SetNameSpace(struct_def->defined_namespace);
code_ += "struct " + Name(*struct_def) + ";";
if (!struct_def->fixed) {
code_ += "struct " + Name(*struct_def) + "Builder;";
}
if (opts_.generate_object_based_api) {
auto nativeName = NativeName(Name(struct_def), &struct_def, opts_);
if (!struct_def.fixed) { code_ += "struct " + nativeName + ";"; }
auto nativeName = NativeName(Name(*struct_def), struct_def, opts_);
if (!struct_def->fixed) { code_ += "struct " + nativeName + ";"; }
}
code_ += "";
}
@@ -430,12 +427,10 @@ class CppGenerator : public BaseGenerator {
// Generate forward declarations for all equal operators
if (opts_.generate_object_based_api && opts_.gen_compare) {
for (auto it = parser_.structs_.vec.begin();
it != parser_.structs_.vec.end(); ++it) {
const auto &struct_def = **it;
if (!struct_def.generated) {
SetNameSpace(struct_def.defined_namespace);
auto nativeName = NativeName(Name(struct_def), &struct_def, opts_);
for (const auto &struct_def : parser_.structs_.vec) {
if (!struct_def->generated) {
SetNameSpace(struct_def->defined_namespace);
auto nativeName = NativeName(Name(*struct_def), struct_def, opts_);
code_ += "bool operator==(const " + nativeName + " &lhs, const " +
nativeName + " &rhs);";
code_ += "bool operator!=(const " + nativeName + " &lhs, const " +
@@ -448,18 +443,16 @@ class CppGenerator : public BaseGenerator {
// Generate preablmle code for mini reflection.
if (opts_.mini_reflect != IDLOptions::kNone) {
// To break cyclic dependencies, first pre-declare all tables/structs.
for (auto it = parser_.structs_.vec.begin();
it != parser_.structs_.vec.end(); ++it) {
const auto &struct_def = **it;
if (!struct_def.generated) {
SetNameSpace(struct_def.defined_namespace);
GenMiniReflectPre(&struct_def);
for (const auto &struct_def : parser_.structs_.vec) {
if (!struct_def->generated) {
SetNameSpace(struct_def->defined_namespace);
GenMiniReflectPre(struct_def);
}
}
}
// Generate code for all the enum declarations.
for (const auto enum_def : parser_.enums_.vec) {
for (const auto &enum_def : parser_.enums_.vec) {
if (!enum_def->generated) {
SetNameSpace(enum_def->defined_namespace);
GenEnum(*enum_def);
@@ -467,59 +460,47 @@ class CppGenerator : public BaseGenerator {
}
// Generate code for all structs, then all tables.
for (auto it = parser_.structs_.vec.begin();
it != parser_.structs_.vec.end(); ++it) {
const auto &struct_def = **it;
if (struct_def.fixed && !struct_def.generated) {
SetNameSpace(struct_def.defined_namespace);
GenStruct(struct_def);
for (const auto &struct_def : parser_.structs_.vec) {
if (struct_def->fixed && !struct_def->generated) {
SetNameSpace(struct_def->defined_namespace);
GenStruct(*struct_def);
}
}
for (auto it = parser_.structs_.vec.begin();
it != parser_.structs_.vec.end(); ++it) {
const auto &struct_def = **it;
if (!struct_def.fixed && !struct_def.generated) {
SetNameSpace(struct_def.defined_namespace);
GenTable(struct_def);
for (const auto &struct_def : parser_.structs_.vec) {
if (!struct_def->fixed && !struct_def->generated) {
SetNameSpace(struct_def->defined_namespace);
GenTable(*struct_def);
}
}
for (auto it = parser_.structs_.vec.begin();
it != parser_.structs_.vec.end(); ++it) {
const auto &struct_def = **it;
if (!struct_def.fixed && !struct_def.generated) {
SetNameSpace(struct_def.defined_namespace);
GenTablePost(struct_def);
for (const auto &struct_def : parser_.structs_.vec) {
if (!struct_def->fixed && !struct_def->generated) {
SetNameSpace(struct_def->defined_namespace);
GenTablePost(*struct_def);
}
}
// Generate code for union verifiers.
for (auto it = parser_.enums_.vec.begin(); it != parser_.enums_.vec.end();
++it) {
const auto &enum_def = **it;
if (enum_def.is_union && !enum_def.generated) {
SetNameSpace(enum_def.defined_namespace);
GenUnionPost(enum_def);
for (const auto &enum_def : parser_.enums_.vec) {
if (enum_def->is_union && !enum_def->generated) {
SetNameSpace(enum_def->defined_namespace);
GenUnionPost(*enum_def);
}
}
// Generate code for mini reflection.
if (opts_.mini_reflect != IDLOptions::kNone) {
// Then the unions/enums that may refer to them.
for (auto it = parser_.enums_.vec.begin(); it != parser_.enums_.vec.end();
++it) {
const auto &enum_def = **it;
if (!enum_def.generated) {
SetNameSpace(enum_def.defined_namespace);
GenMiniReflect(nullptr, &enum_def);
for (const auto &enum_def : parser_.enums_.vec) {
if (!enum_def->generated) {
SetNameSpace(enum_def->defined_namespace);
GenMiniReflect(nullptr, enum_def);
}
}
// Then the full tables/structs.
for (auto it = parser_.structs_.vec.begin();
it != parser_.structs_.vec.end(); ++it) {
const auto &struct_def = **it;
if (!struct_def.generated) {
SetNameSpace(struct_def.defined_namespace);
GenMiniReflect(&struct_def, nullptr);
for (const auto &struct_def : parser_.structs_.vec) {
if (!struct_def->generated) {
SetNameSpace(struct_def->defined_namespace);
GenMiniReflect(struct_def, nullptr);
}
}
}
@@ -714,10 +695,8 @@ class CppGenerator : public BaseGenerator {
bool TypeHasKey(const Type &type) {
if (type.base_type != BASE_TYPE_STRUCT) { return false; }
for (auto it = type.struct_def->fields.vec.begin();
it != type.struct_def->fields.vec.end(); ++it) {
const auto &field = **it;
if (field.key) { return true; }
for (auto &field : type.struct_def->fields.vec) {
if (field->key) { return true; }
}
return false;
}
@@ -828,9 +807,7 @@ class CppGenerator : public BaseGenerator {
}
bool FlexibleStringConstructor(const FieldDef *field) {
auto attr = field
? (field->attributes.Lookup("cpp_str_flex_ctor") != nullptr)
: false;
auto attr = field != nullptr && (field->attributes.Lookup("cpp_str_flex_ctor") != nullptr);
auto ret = attr ? attr : opts_.cpp_object_api_string_flexible_constructor;
return ret && NativeString(field) !=
"std::string"; // Only for custom string types.
@@ -1085,11 +1062,9 @@ class CppGenerator : public BaseGenerator {
std::vector<Type> types;
if (struct_def) {
for (auto it = struct_def->fields.vec.begin();
it != struct_def->fields.vec.end(); ++it) {
const auto &field = **it;
names.push_back(Name(field));
types.push_back(field.value.type);
for (const auto &field : struct_def->fields.vec) {
names.push_back(Name(*field));
types.push_back(field->value.type);
}
} else {
for (auto it = enum_def->Vals().begin(); it != enum_def->Vals().end();
@@ -1103,8 +1078,7 @@ class CppGenerator : public BaseGenerator {
std::string ts;
std::vector<std::string> type_refs;
std::vector<uint16_t> array_sizes;
for (auto it = types.begin(); it != types.end(); ++it) {
auto &type = *it;
for (auto &type : types) {
if (!ts.empty()) ts += ",\n ";
auto is_vector = IsVector(type);
auto is_array = IsArray(type);
@@ -1135,19 +1109,19 @@ class CppGenerator : public BaseGenerator {
" }";
}
std::string rs;
for (auto it = type_refs.begin(); it != type_refs.end(); ++it) {
for (auto &type_ref : type_refs) {
if (!rs.empty()) rs += ",\n ";
rs += *it + "TypeTable";
rs += type_ref + "TypeTable";
}
std::string as;
for (auto it = array_sizes.begin(); it != array_sizes.end(); ++it) {
as += NumToString(*it);
for (auto &array_size : array_sizes) {
as += NumToString(array_size);
as += ", ";
}
std::string ns;
for (auto it = names.begin(); it != names.end(); ++it) {
for (auto &name : names) {
if (!ns.empty()) ns += ",\n ";
ns += "\"" + *it + "\"";
ns += "\"" + name + "\"";
}
std::string vs;
const auto consecutive_enum_from_zero =
@@ -1162,10 +1136,8 @@ class CppGenerator : public BaseGenerator {
enum_def->underlying_type.base_type);
}
} else if (struct_def && struct_def->fixed) {
for (auto it = struct_def->fields.vec.begin();
it != struct_def->fields.vec.end(); ++it) {
const auto &field = **it;
vs += NumToString(field.value.offset);
for (const auto field : struct_def->fields.vec) {
vs += NumToString(field->value.offset);
vs += ", ";
}
vs += NumToString(struct_def->bytesize);
@@ -1409,12 +1381,10 @@ class CppGenerator : public BaseGenerator {
code_ += " if (lhs.type != rhs.type) return false;";
code_ += " switch (lhs.type) {";
for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end();
++it) {
const auto &ev = **it;
code_.SetValue("NATIVE_ID", GetEnumValUse(enum_def, ev));
if (ev.IsNonZero()) {
const auto native_type = GetUnionElement(ev, true, opts_);
for (const auto &ev: enum_def.Vals()) {
code_.SetValue("NATIVE_ID", GetEnumValUse(enum_def, *ev));
if (ev->IsNonZero()) {
const auto native_type = GetUnionElement(*ev, true, opts_);
code_.SetValue("NATIVE_TYPE", native_type);
code_ += " case {{NATIVE_ID}}: {";
code_ +=
@@ -1479,12 +1449,12 @@ class CppGenerator : public BaseGenerator {
NumToString(range + 1 + 1) + "] = {";
auto val = enum_def.Vals().front();
for (const auto &ev : enum_def.Vals()) {
for (auto k = enum_def.Distance(val, ev); k > 1; --k) {
for (const auto &enum_value : enum_def.Vals()) {
for (auto k = enum_def.Distance(val, enum_value); k > 1; --k) {
code_ += " \"\",";
}
val = ev;
code_ += " \"" + Name(*ev) + "\",";
val = enum_value;
code_ += " \"" + Name(*enum_value) + "\",";
}
code_ += " nullptr";
code_ += " };";
@@ -1656,24 +1626,20 @@ class CppGenerator : public BaseGenerator {
"inline {{ENUM_NAME}}Union::{{ENUM_NAME}}Union(const "
"{{ENUM_NAME}}Union &u) : type(u.type), value(nullptr) {";
code_ += " switch (type) {";
for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end();
++it) {
const auto &ev = **it;
if (ev.IsZero()) { continue; }
code_.SetValue("LABEL", GetEnumValUse(enum_def, ev));
code_.SetValue("TYPE", GetUnionElement(ev, true, opts_));
for (const auto &ev: enum_def.Vals()) {
if (ev->IsZero()) { continue; }
code_.SetValue("LABEL", GetEnumValUse(enum_def, *ev));
code_.SetValue("TYPE", GetUnionElement(*ev, true, opts_));
code_ += " case {{LABEL}}: {";
bool copyable = true;
if (opts_.g_cpp_std < cpp::CPP_STD_11 &&
ev.union_type.base_type == BASE_TYPE_STRUCT &&
!ev.union_type.struct_def->fixed) {
ev->union_type.base_type == BASE_TYPE_STRUCT &&
!ev->union_type.struct_def->fixed) {
// Don't generate code to copy if table is not copyable.
// TODO(wvo): make tables copyable instead.
for (auto fit = ev.union_type.struct_def->fields.vec.begin();
fit != ev.union_type.struct_def->fields.vec.end(); ++fit) {
const auto &field = **fit;
if (!field.deprecated && field.value.type.struct_def &&
!field.native_inline) {
for (const auto &field : ev->union_type.struct_def->fields.vec) {
if (!field->deprecated && field->value.type.struct_def &&
!field->native_inline) {
copyable = false;
break;
}
@@ -1846,7 +1812,7 @@ class CppGenerator : public BaseGenerator {
: GenTypeNativePtr(cpp_type->constant, &field, false))
: type + " ");
// Generate default member initializers for >= C++11.
std::string field_di = "";
std::string field_di;
if (opts_.g_cpp_std >= cpp::CPP_STD_11) {
field_di = "{}";
auto native_default = field.attributes.Lookup("native_default");
@@ -1872,23 +1838,21 @@ class CppGenerator : public BaseGenerator {
// operator because it has one or more table members, struct members with a
// custom cpp_type and non-naked pointer type, or vector members of those.
bool NeedsCopyCtorAssignOp(const StructDef &struct_def) {
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
const auto &field = **it;
const auto &type = field.value.type;
if (field.deprecated) continue;
for (const auto &field : struct_def.fields.vec) {
const auto &type = field->value.type;
if (field->deprecated) continue;
if (type.base_type == BASE_TYPE_STRUCT) {
const auto cpp_type = field.attributes.Lookup("cpp_type");
const auto cpp_ptr_type = field.attributes.Lookup("cpp_ptr_type");
const bool is_ptr = !(IsStruct(type) && field.native_inline) ||
const auto cpp_type = field->attributes.Lookup("cpp_type");
const auto cpp_ptr_type = field->attributes.Lookup("cpp_ptr_type");
const bool is_ptr = !(IsStruct(type) && field->native_inline) ||
(cpp_type && cpp_ptr_type->constant != "naked");
if (is_ptr) { return true; }
} else if (IsVector(type)) {
const auto vec_type = type.VectorType();
if (vec_type.base_type == BASE_TYPE_UTYPE) continue;
const auto cpp_type = field.attributes.Lookup("cpp_type");
const auto cpp_ptr_type = field.attributes.Lookup("cpp_ptr_type");
const bool is_ptr = IsVectorOfPointers(field) ||
const auto cpp_type = field->attributes.Lookup("cpp_type");
const auto cpp_ptr_type = field->attributes.Lookup("cpp_ptr_type");
const bool is_ptr = IsVectorOfPointers(*field) ||
(cpp_type && cpp_ptr_type->constant != "naked");
if (is_ptr) { return true; }
}
@@ -1978,22 +1942,20 @@ class CppGenerator : public BaseGenerator {
std::string initializer_list;
std::string vector_copies;
std::string swaps;
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
const auto &field = **it;
const auto &type = field.value.type;
if (field.deprecated || type.base_type == BASE_TYPE_UTYPE) continue;
for (const auto &field: struct_def.fields.vec) {
const auto &type = field->value.type;
if (field->deprecated || type.base_type == BASE_TYPE_UTYPE) continue;
if (type.base_type == BASE_TYPE_STRUCT) {
if (!initializer_list.empty()) { initializer_list += ",\n "; }
const auto cpp_type = field.attributes.Lookup("cpp_type");
const auto cpp_ptr_type = field.attributes.Lookup("cpp_ptr_type");
const auto cpp_type = field->attributes.Lookup("cpp_type");
const auto cpp_ptr_type = field->attributes.Lookup("cpp_ptr_type");
auto type_name = (cpp_type) ? cpp_type->constant
: GenTypeNative(type, /*invector*/ false,
field, /*forcopy*/ true);
const bool is_ptr = !(IsStruct(type) && field.native_inline) ||
*field, /*forcopy*/ true);
const bool is_ptr = !(IsStruct(type) && field->native_inline) ||
(cpp_type && cpp_ptr_type->constant != "naked");
CodeWriter cw;
cw.SetValue("FIELD", Name(field));
cw.SetValue("FIELD", Name(*field));
cw.SetValue("TYPE", type_name);
if (is_ptr) {
cw +=
@@ -2007,16 +1969,16 @@ class CppGenerator : public BaseGenerator {
} else if (IsVector(type)) {
const auto vec_type = type.VectorType();
if (vec_type.base_type == BASE_TYPE_UTYPE) continue;
const auto cpp_type = field.attributes.Lookup("cpp_type");
const auto cpp_ptr_type = field.attributes.Lookup("cpp_ptr_type");
const auto cpp_type = field->attributes.Lookup("cpp_type");
const auto cpp_ptr_type = field->attributes.Lookup("cpp_ptr_type");
const auto type_name = (cpp_type)
? cpp_type->constant
: GenTypeNative(vec_type, /*invector*/ true,
field, /*forcopy*/ true);
const bool is_ptr = IsVectorOfPointers(field) ||
*field, /*forcopy*/ true);
const bool is_ptr = IsVectorOfPointers(*field) ||
(cpp_type && cpp_ptr_type->constant != "naked");
CodeWriter cw(" ");
cw.SetValue("FIELD", Name(field));
cw.SetValue("FIELD", Name(*field));
cw.SetValue("TYPE", type_name);
if (is_ptr) {
// Use emplace_back to construct the potentially-smart pointer element
@@ -2039,14 +2001,14 @@ class CppGenerator : public BaseGenerator {
} else {
if (!initializer_list.empty()) { initializer_list += ",\n "; }
CodeWriter cw;
cw.SetValue("FIELD", Name(field));
cw.SetValue("FIELD", Name(*field));
cw += "{{FIELD}}(o.{{FIELD}})\\";
initializer_list += cw.ToString();
}
{
if (!swaps.empty()) { swaps += "\n "; }
CodeWriter cw;
cw.SetValue("FIELD", Name(field));
cw.SetValue("FIELD", Name(*field));
cw += "std::swap({{FIELD}}, o.{{FIELD}});\\";
swaps += cw.ToString();
}
@@ -2074,7 +2036,7 @@ class CppGenerator : public BaseGenerator {
}
void GenCompareOperator(const StructDef &struct_def,
std::string accessSuffix = "") {
const std::string& accessSuffix = "") {
std::string compare_op;
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
@@ -2175,9 +2137,8 @@ class CppGenerator : public BaseGenerator {
code_ += "struct {{NATIVE_NAME}} : public flatbuffers::NativeTable {";
code_ += " typedef {{STRUCT_NAME}} TableType;";
GenFullyQualifiedNameGetter(struct_def, native_name);
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
GenMember(**it);
for (const auto field : struct_def.fields.vec) {
GenMember(*field);
}
GenOperatorNewDelete(struct_def);
GenDefaultConstructor(struct_def);
@@ -2308,15 +2269,18 @@ class CppGenerator : public BaseGenerator {
code_.SetValue("INPUT_TYPE", input_type);
code_ +=
" int KeyCompareWithValue(const {{INPUT_TYPE}} *_{{FIELD_NAME}}"
") const { ";
code_ += " for (auto i = 0; i < {{FIELD_NAME}}()->size(); i++) {";
code_ += " const auto {{FIELD_NAME}}_l = {{FIELD_NAME}}_[i];";
code_ += " const auto {{FIELD_NAME}}_r = _{{FIELD_NAME}}->Get(i);";
code_ += " if({{FIELD_NAME}}_l != {{FIELD_NAME}}_r) ";
") const {";
code_ +=
" return static_cast<int>({{FIELD_NAME}}_l > "
"{{FIELD_NAME}}_r)"
" - static_cast<int>({{FIELD_NAME}}_l < {{FIELD_NAME}}_r);";
" const {{INPUT_TYPE}} *curr_{{FIELD_NAME}} = {{FIELD_NAME}}();";
code_ +=
" for (flatbuffers::uoffset_t i = 0; i < "
"curr_{{FIELD_NAME}}->size(); i++) {";
code_ += " const auto lhs = curr_{{FIELD_NAME}}->Get(i);";
code_ += " const auto rhs = _{{FIELD_NAME}}->Get(i);";
code_ += " if(lhs != rhs)";
code_ +=
" return static_cast<int>(lhs > rhs)"
" - static_cast<int>(lhs < rhs);";
code_ += " }";
code_ += " return 0;";
}
@@ -2377,7 +2341,7 @@ class CppGenerator : public BaseGenerator {
GenComment(field.doc_comment, " ");
// Call a different accessor for pointers, that indirects.
if (false == field.IsScalarOptional()) {
if (!field.IsScalarOptional()) {
const bool is_scalar = IsScalar(type.base_type);
std::string accessor;
if (is_scalar)
@@ -2452,14 +2416,12 @@ class CppGenerator : public BaseGenerator {
size_t index = 0;
bool need_else = false;
// Generate one index-based getter for each field.
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
const auto &field = **it;
if (field.deprecated) {
for (const auto &field : struct_def.fields.vec) {
if (field->deprecated) {
// Deprecated fields won't be accessible.
continue;
}
code_.SetValue("FIELD_NAME", Name(field));
code_.SetValue("FIELD_NAME", Name(*field));
code_.SetValue("FIELD_INDEX",
std::to_string(static_cast<long long>(index++)));
if (need_else) {
@@ -2500,7 +2462,7 @@ class CppGenerator : public BaseGenerator {
continue;
}
code_.SetValue("FIELD_NAME", Name(field));
code_ += " \"{{FIELD_NAME}}\"\\";
code_ += R"( "{{FIELD_NAME}}"\)";
if (it + 1 != struct_def.fields.vec.end()) { code_ += ","; }
}
code_ += "\n };";
@@ -2555,7 +2517,7 @@ class CppGenerator : public BaseGenerator {
GenUnderlyingCast(field, false, "_" + Name(field)));
code_ += " bool mutate_{{FIELD_NAME}}({{FIELD_TYPE}} _{{FIELD_NAME}}\\";
if (false == field.IsScalarOptional()) {
if (!field.IsScalarOptional()) {
code_.SetValue("DEFAULT_VALUE", GenDefaultConstant(field));
code_.SetValue(
"INTERFACE_DEFAULT_VALUE",
@@ -2632,22 +2594,20 @@ class CppGenerator : public BaseGenerator {
GenFullyQualifiedNameGetter(struct_def, Name(struct_def));
// Generate field id constants.
if (struct_def.fields.vec.size() > 0) {
if (!struct_def.fields.vec.empty()) {
// We need to add a trailing comma to all elements except the last one as
// older versions of gcc complain about this.
code_.SetValue("SEP", "");
code_ +=
" enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {";
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
const auto &field = **it;
if (field.deprecated) {
for (const auto &field : struct_def.fields.vec) {
if (field->deprecated) {
// Deprecated fields won't be accessible.
continue;
}
code_.SetValue("OFFSET_NAME", GenFieldOffsetName(field));
code_.SetValue("OFFSET_VALUE", NumToString(field.value.offset));
code_.SetValue("OFFSET_NAME", GenFieldOffsetName(*field));
code_.SetValue("OFFSET_VALUE", NumToString(field->value.offset));
code_ += "{{SEP}} {{OFFSET_NAME}} = {{OFFSET_VALUE}}\\";
code_.SetValue("SEP", ",\n");
}
@@ -2656,19 +2616,17 @@ class CppGenerator : public BaseGenerator {
}
// Generate the accessors.
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
const auto &field = **it;
if (field.deprecated) {
for (const auto &field : struct_def.fields.vec) {
if (field->deprecated) {
// Deprecated fields won't be accessible.
continue;
}
code_.SetValue("FIELD_NAME", Name(field));
GenTableFieldGetter(field);
if (opts_.mutable_buffer) { GenTableFieldSetter(field); }
code_.SetValue("FIELD_NAME", Name(*field));
GenTableFieldGetter(*field);
if (opts_.mutable_buffer) { GenTableFieldSetter(*field); }
auto nfn = GetNestedFlatBufferName(field);
auto nfn = GetNestedFlatBufferName(*field);
if (!nfn.empty()) {
code_.SetValue("CPP_NAME", nfn);
code_ += " const {{CPP_NAME}} *{{FIELD_NAME}}_nested_root() const {";
@@ -2678,7 +2636,7 @@ class CppGenerator : public BaseGenerator {
code_ += " }";
}
if (field.flexbuffer) {
if (field->flexbuffer) {
code_ +=
" flexbuffers::Reference {{FIELD_NAME}}_flexbuffer_root()"
" const {";
@@ -2691,7 +2649,7 @@ class CppGenerator : public BaseGenerator {
}
// Generate a comparison function for this field if it is a key.
if (field.key) { GenKeyFieldMethods(field); }
if (field->key) { GenKeyFieldMethods(*field); }
}
if (opts_.cpp_static_reflection) { GenIndexBasedFieldGetter(struct_def); }
@@ -2700,11 +2658,9 @@ class CppGenerator : public BaseGenerator {
// source will never cause reads outside the buffer.
code_ += " bool Verify(flatbuffers::Verifier &verifier) const {";
code_ += " return VerifyTableStart(verifier)\\";
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
const auto &field = **it;
if (field.deprecated) { continue; }
GenVerifyCall(field, " &&\n ");
for (const auto &field : struct_def.fields.vec) {
if (field->deprecated) { continue; }
GenVerifyCall(*field, " &&\n ");
}
code_ += " &&\n verifier.EndTable();";
@@ -2721,17 +2677,15 @@ class CppGenerator : public BaseGenerator {
code_ += "";
// Explicit specializations for union accessors
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
const auto &field = **it;
if (field.deprecated || field.value.type.base_type != BASE_TYPE_UNION) {
for (const auto &field : struct_def.fields.vec) {
if (field->deprecated || field->value.type.base_type != BASE_TYPE_UNION) {
continue;
}
auto u = field.value.type.enum_def;
auto u = field->value.type.enum_def;
if (u->uses_multiple_type_instances) continue;
code_.SetValue("FIELD_NAME", Name(field));
code_.SetValue("FIELD_NAME", Name(*field));
for (auto u_it = u->Vals().begin(); u_it != u->Vals().end(); ++u_it) {
auto &ev = **u_it;
@@ -2744,7 +2698,7 @@ class CppGenerator : public BaseGenerator {
WrapInNameSpace(u->defined_namespace, GetEnumValUse(*u, ev)));
code_.SetValue("U_FIELD_TYPE", "const " + full_struct_name + " *");
code_.SetValue("U_ELEMENT_NAME", full_struct_name);
code_.SetValue("U_FIELD_NAME", Name(field) + "_as_" + Name(ev));
code_.SetValue("U_FIELD_NAME", Name(*field) + "_as_" + Name(ev));
// `template<> const T *union_name_as<T>() const` accessor.
code_ +=
@@ -2851,12 +2805,10 @@ class CppGenerator : public BaseGenerator {
code_ += " const auto end = fbb_.EndTable(start_);";
code_ += " auto o = flatbuffers::Offset<{{STRUCT_NAME}}>(end);";
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
const auto &field = **it;
if (!field.deprecated && field.IsRequired()) {
code_.SetValue("FIELD_NAME", Name(field));
code_.SetValue("OFFSET_NAME", GenFieldOffsetName(field));
for (const auto &field: struct_def.fields.vec) {
if (!field->deprecated && field->IsRequired()) {
code_.SetValue("FIELD_NAME", Name(*field));
code_.SetValue("OFFSET_NAME", GenFieldOffsetName(*field));
code_ += " fbb_.Required(o, {{STRUCT_NAME}}::{{OFFSET_NAME}});";
}
}
@@ -2871,10 +2823,10 @@ class CppGenerator : public BaseGenerator {
"inline flatbuffers::Offset<{{STRUCT_NAME}}> "
"Create{{STRUCT_NAME}}(";
code_ += " flatbuffers::FlatBufferBuilder &_fbb\\";
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
const auto &field = **it;
if (!field.deprecated) { GenParam(field, false, ",\n "); }
for (const auto &field : struct_def.fields.vec) {
if (!field->deprecated) {
GenParam(*field, false, ",\n ");
}
}
code_ += ") {";
@@ -2911,23 +2863,19 @@ class CppGenerator : public BaseGenerator {
"inline flatbuffers::Offset<{{STRUCT_NAME}}> "
"Create{{STRUCT_NAME}}Direct(";
code_ += " flatbuffers::FlatBufferBuilder &_fbb\\";
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
const auto &field = **it;
if (!field.deprecated) { GenParam(field, true, ",\n "); }
for (const auto &field : struct_def.fields.vec) {
if (!field->deprecated) { GenParam(*field, true, ",\n "); }
}
// Need to call "Create" with the struct namespace.
const auto qualified_create_name =
struct_def.defined_namespace->GetFullyQualifiedName("Create");
code_.SetValue("CREATE_NAME", TranslateNameSpace(qualified_create_name));
code_ += ") {";
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
const auto &field = **it;
if (!field.deprecated) {
code_.SetValue("FIELD_NAME", Name(field));
if (IsString(field.value.type)) {
if (!field.shared) {
for (const auto &field : struct_def.fields.vec) {
if (!field->deprecated) {
code_.SetValue("FIELD_NAME", Name(*field));
if (IsString(field->value.type)) {
if (!field->shared) {
code_.SetValue("CREATE_STRING", "CreateString");
} else {
code_.SetValue("CREATE_STRING", "CreateSharedString");
@@ -2935,14 +2883,14 @@ class CppGenerator : public BaseGenerator {
code_ +=
" auto {{FIELD_NAME}}__ = {{FIELD_NAME}} ? "
"_fbb.{{CREATE_STRING}}({{FIELD_NAME}}) : 0;";
} else if (IsVector(field.value.type)) {
} else if (IsVector(field->value.type)) {
const std::string force_align_code =
GenVectorForceAlign(field, Name(field) + "->size()");
GenVectorForceAlign(*field, Name(*field) + "->size()");
if (!force_align_code.empty()) {
code_ += " if ({{FIELD_NAME}}) { " + force_align_code + " }";
}
code_ += " auto {{FIELD_NAME}}__ = {{FIELD_NAME}} ? \\";
const auto vtype = field.value.type.VectorType();
const auto vtype = field->value.type.VectorType();
const auto has_key = TypeHasKey(vtype);
if (IsStruct(vtype)) {
const auto type = WrapInNameSpace(*vtype.struct_def);
@@ -2964,13 +2912,11 @@ class CppGenerator : public BaseGenerator {
}
code_ += " return {{CREATE_NAME}}{{STRUCT_NAME}}(";
code_ += " _fbb\\";
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
const auto &field = **it;
if (!field.deprecated) {
code_.SetValue("FIELD_NAME", Name(field));
for (const auto &field : struct_def.fields.vec) {
if (!field->deprecated) {
code_.SetValue("FIELD_NAME", Name(*field));
code_ += ",\n {{FIELD_NAME}}\\";
if (IsString(field.value.type) || IsVector(field.value.type)) {
if (IsString(field->value.type) || IsVector(field->value.type)) {
code_ += "__\\";
}
}
@@ -3491,25 +3437,23 @@ class CppGenerator : public BaseGenerator {
code_ += " return {{CREATE_NAME}}{{STRUCT_NAME}}(";
code_ += " _fbb\\";
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
auto &field = **it;
if (field.deprecated) { continue; }
for (const auto &field : struct_def.fields.vec) {
if (field->deprecated) { continue; }
bool pass_by_address = false;
if (field.value.type.base_type == BASE_TYPE_STRUCT) {
if (IsStruct(field.value.type)) {
if (field->value.type.base_type == BASE_TYPE_STRUCT) {
if (IsStruct(field->value.type)) {
auto native_type =
field.value.type.struct_def->attributes.Lookup("native_type");
field->value.type.struct_def->attributes.Lookup("native_type");
if (native_type) { pass_by_address = true; }
}
}
// Call the CreateX function using values from |_o|.
if (pass_by_address) {
code_ += ",\n &_" + Name(field) + "\\";
code_ += ",\n &_" + Name(*field) + "\\";
} else {
code_ += ",\n _" + Name(field) + "\\";
code_ += ",\n _" + Name(*field) + "\\";
}
}
code_ += ");";
@@ -3554,9 +3498,7 @@ class CppGenerator : public BaseGenerator {
bool first_in_init_list = true;
int padding_initializer_id = 0;
int padding_body_id = 0;
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
const auto field = *it;
for (const auto &field : struct_def.fields.vec) {
const auto field_name = Name(*field) + "_";
if (first_in_init_list) {
@@ -3646,10 +3588,8 @@ class CppGenerator : public BaseGenerator {
code_ += " {{STRUCT_NAME}}({{ARG_LIST}}) {";
}
padding_id = 0;
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
const auto &field = **it;
const auto &type = field.value.type;
for (const auto &field : struct_def.fields.vec) {
const auto &type = field->value.type;
if (IsArray(type) && init_arrays) {
const auto &element_type = type.VectorType();
const auto is_enum = IsEnum(element_type);
@@ -3659,14 +3599,14 @@ class CppGenerator : public BaseGenerator {
const auto face_type = GenTypeGet(type, " ", "", "", is_enum);
std::string get_array =
is_enum ? "CastToArrayOfEnum<" + face_type + ">" : "CastToArray";
const auto field_name = Name(field) + "_";
const auto arg_name = "_" + Name(field);
const auto field_name = Name(*field) + "_";
const auto arg_name = "_" + Name(*field);
code_ += " flatbuffers::" + get_array + "(" + field_name +
").CopyFromSpan(" + arg_name + ");";
}
if (field.padding) {
if (field->padding) {
std::string padding;
GenPadding(field, &padding, &padding_id, PaddingNoop);
GenPadding(*field, &padding, &padding_id, PaddingNoop);
code_ += padding;
}
}
@@ -3711,21 +3651,19 @@ class CppGenerator : public BaseGenerator {
code_ += " private:";
int padding_id = 0;
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
const auto &field = **it;
const auto &field_type = field.value.type;
for (const auto &field: struct_def.fields.vec) {
const auto &field_type = field->value.type;
code_.SetValue("FIELD_TYPE", GenTypeGet(field_type, " ", "", " ", false));
code_.SetValue("FIELD_NAME", Name(field));
code_.SetValue("FIELD_NAME", Name(*field));
code_.SetValue("ARRAY",
IsArray(field_type)
? "[" + NumToString(field_type.fixed_length) + "]"
: "");
code_ += (" {{FIELD_TYPE}}{{FIELD_NAME}}_{{ARRAY}};");
if (field.padding) {
if (field->padding) {
std::string padding;
GenPadding(field, &padding, &padding_id, PaddingDefinition);
GenPadding(*field, &padding, &padding_id, PaddingDefinition);
code_ += padding;
}
}
@@ -3764,24 +3702,22 @@ class CppGenerator : public BaseGenerator {
// Generate accessor methods of the form:
// type name() const { return flatbuffers::EndianScalar(name_); }
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
const auto &field = **it;
const auto &type = field.value.type;
for (const auto &field : struct_def.fields.vec) {
const auto &type = field->value.type;
const auto is_scalar = IsScalar(type.base_type);
const auto is_array = IsArray(type);
const auto field_type = GenTypeGet(type, " ", is_array ? "" : "const ",
is_array ? "" : " &", true);
auto member = Name(field) + "_";
auto member = Name(*field) + "_";
auto value =
is_scalar ? "flatbuffers::EndianScalar(" + member + ")" : member;
code_.SetValue("FIELD_NAME", Name(field));
code_.SetValue("FIELD_NAME", Name(*field));
code_.SetValue("FIELD_TYPE", field_type);
code_.SetValue("FIELD_VALUE", GenUnderlyingCast(field, true, value));
code_.SetValue("FIELD_VALUE", GenUnderlyingCast(*field, true, value));
GenComment(field.doc_comment, " ");
GenComment(field->doc_comment, " ");
// Generate a const accessor function.
if (is_array) {
@@ -3800,7 +3736,7 @@ class CppGenerator : public BaseGenerator {
if (is_scalar) {
code_.SetValue("ARG", GenTypeBasic(type, true));
code_.SetValue("FIELD_VALUE",
GenUnderlyingCast(field, false, "_" + Name(field)));
GenUnderlyingCast(*field, false, "_" + Name(*field)));
code_ += " void mutate_{{FIELD_NAME}}({{ARG}} _{{FIELD_NAME}}) {";
code_ +=
@@ -3817,7 +3753,7 @@ class CppGenerator : public BaseGenerator {
}
// Generate a comparison function for this field if it is a key.
if (field.key) { GenKeyFieldMethods(field); }
if (field->key) { GenKeyFieldMethods(*field); }
}
code_.SetValue("NATIVE_NAME", Name(struct_def));
GenOperatorNewDelete(struct_def);
@@ -3925,8 +3861,8 @@ std::string CPPMakeRule(const Parser &parser, const std::string &path,
const auto included_files = parser.GetIncludedFilesRecursive(file_name);
std::string make_rule =
geneartor.GeneratedFileName(path, filebase, parser.opts) + ": ";
for (auto it = included_files.begin(); it != included_files.end(); ++it) {
make_rule += " " + *it;
for (const std::string &included_file : included_files) {
make_rule += " " + included_file;
}
return make_rule;
}

View File

@@ -655,7 +655,7 @@ class CSharpGenerator : public BaseGenerator {
// Force compile time error if not using the same version runtime.
code += " public static void ValidateVersion() {";
code += " FlatBufferConstants.";
code += "FLATBUFFERS_22_11_23(); ";
code += "FLATBUFFERS_22_12_06(); ";
code += "}\n";
// Generate a special accessor for the table that when used as the root

View File

@@ -178,8 +178,20 @@ class JavaGenerator : public BaseGenerator {
}
if (needs_includes) {
code +=
"import java.nio.*;\nimport java.lang.*;\nimport "
"java.util.*;\nimport com.google.flatbuffers.*;\n";
"import com.google.flatbuffers.BaseVector;\n"
"import com.google.flatbuffers.BooleanVector;\n"
"import com.google.flatbuffers.ByteVector;\n"
"import com.google.flatbuffers.Constants;\n"
"import com.google.flatbuffers.DoubleVector;\n"
"import com.google.flatbuffers.FlatBufferBuilder;\n"
"import com.google.flatbuffers.FloatVector;\n"
"import com.google.flatbuffers.LongVector;\n"
"import com.google.flatbuffers.StringVector;\n"
"import com.google.flatbuffers.Struct;\n"
"import com.google.flatbuffers.Table;\n"
"import com.google.flatbuffers.UnionVector;\n"
"import java.nio.ByteBuffer;\n"
"import java.nio.ByteOrder;\n";
if (parser_.opts.gen_nullable) {
code += "\nimport javax.annotation.Nullable;\n";
}
@@ -669,7 +681,7 @@ class JavaGenerator : public BaseGenerator {
// Force compile time error if not using the same version runtime.
code += " public static void ValidateVersion() {";
code += " Constants.";
code += "FLATBUFFERS_22_11_23(); ";
code += "FLATBUFFERS_22_12_06(); ";
code += "}\n";
// Generate a special accessor for the table that when used as the root

View File

@@ -505,7 +505,7 @@ class KotlinGenerator : public BaseGenerator {
// runtime.
GenerateFunOneLine(
writer, "validateVersion", "", "",
[&]() { writer += "Constants.FLATBUFFERS_22_11_23()"; },
[&]() { writer += "Constants.FLATBUFFERS_22_12_06()"; },
options.gen_jvmstatic);
GenerateGetRootAsAccessors(namer_.Type(struct_def), writer, options);

View File

@@ -1846,7 +1846,7 @@ class SwiftGenerator : public BaseGenerator {
}
std::string ValidateFunc() {
return "static func validateVersion() { FlatBuffersVersion_22_11_23() }";
return "static func validateVersion() { FlatBuffersVersion_22_12_06() }";
}
std::string GenType(const Type &type,

View File

@@ -918,6 +918,12 @@ CheckedError Parser::ParseField(StructDef &struct_def) {
ECHECK(ParseType(type));
if (struct_def.fixed) {
if (IsIncompleteStruct(type) ||
(IsArray(type) && IsIncompleteStruct(type.VectorType()))) {
std::string type_name = IsArray(type) ? type.VectorType().struct_def->name : type.struct_def->name;
return Error(std::string("Incomplete type in struct is not allowed, type name: ") + type_name);
}
auto valid = IsScalar(type.base_type) || IsStruct(type);
if (!valid && IsArray(type)) {
const auto &elem_type = type.VectorType();
@@ -4233,8 +4239,13 @@ std::string Parser::ConformTo(const Parser &base) {
field_base = *fbit;
if (field.value.offset == field_base->value.offset) {
renamed_fields.insert(field_base);
if (!EqualByName(field.value.type, field_base->value.type))
return "field renamed to different type: " + qualified_field_name;
if (!EqualByName(field.value.type, field_base->value.type)) {
const auto qualified_field_base =
qualified_name + "." + field_base->name;
return "field renamed to different type: " +
qualified_field_name + " (renamed from " +
qualified_field_base + ")";
}
break;
}
}

View File

@@ -119,4 +119,4 @@ extension UInt64: Scalar, Verifiable {
public typealias NumericValue = UInt64
}
public func FlatBuffersVersion_22_11_23() {}
public func FlatBuffersVersion_22_12_06() {}

View File

@@ -2,7 +2,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by :
]#

View File

@@ -2,14 +2,24 @@
package DictionaryLookup;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import com.google.flatbuffers.BaseVector;
import com.google.flatbuffers.BooleanVector;
import com.google.flatbuffers.ByteVector;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.DoubleVector;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.FloatVector;
import com.google.flatbuffers.LongVector;
import com.google.flatbuffers.StringVector;
import com.google.flatbuffers.Struct;
import com.google.flatbuffers.Table;
import com.google.flatbuffers.UnionVector;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class LongFloatEntry extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_22_11_23(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_22_12_06(); }
public static LongFloatEntry getRootAsLongFloatEntry(ByteBuffer _bb) { return getRootAsLongFloatEntry(_bb, new LongFloatEntry()); }
public static LongFloatEntry getRootAsLongFloatEntry(ByteBuffer _bb, LongFloatEntry obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }

View File

@@ -32,7 +32,7 @@ class LongFloatEntry : Table() {
return (val_1 - val_2).sign
}
companion object {
fun validateVersion() = Constants.FLATBUFFERS_22_11_23()
fun validateVersion() = Constants.FLATBUFFERS_22_12_06()
fun getRootAsLongFloatEntry(_bb: ByteBuffer): LongFloatEntry = getRootAsLongFloatEntry(_bb, LongFloatEntry())
fun getRootAsLongFloatEntry(_bb: ByteBuffer, obj: LongFloatEntry): LongFloatEntry {
_bb.order(ByteOrder.LITTLE_ENDIAN)

View File

@@ -2,14 +2,24 @@
package DictionaryLookup;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import com.google.flatbuffers.BaseVector;
import com.google.flatbuffers.BooleanVector;
import com.google.flatbuffers.ByteVector;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.DoubleVector;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.FloatVector;
import com.google.flatbuffers.LongVector;
import com.google.flatbuffers.StringVector;
import com.google.flatbuffers.Struct;
import com.google.flatbuffers.Table;
import com.google.flatbuffers.UnionVector;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class LongFloatMap extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_22_11_23(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_22_12_06(); }
public static LongFloatMap getRootAsLongFloatMap(ByteBuffer _bb) { return getRootAsLongFloatMap(_bb, new LongFloatMap()); }
public static LongFloatMap getRootAsLongFloatMap(ByteBuffer _bb, LongFloatMap obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }

View File

@@ -46,7 +46,7 @@ class LongFloatMap : Table() {
}
}
companion object {
fun validateVersion() = Constants.FLATBUFFERS_22_11_23()
fun validateVersion() = Constants.FLATBUFFERS_22_12_06()
fun getRootAsLongFloatMap(_bb: ByteBuffer): LongFloatMap = getRootAsLongFloatMap(_bb, LongFloatMap())
fun getRootAsLongFloatMap(_bb: ByteBuffer, obj: LongFloatMap): LongFloatMap {
_bb.order(ByteOrder.LITTLE_ENDIAN)

View File

@@ -13,7 +13,7 @@ public struct KeywordsInTable : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_22_11_23(); }
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_22_12_06(); }
public static KeywordsInTable GetRootAsKeywordsInTable(ByteBuffer _bb) { return GetRootAsKeywordsInTable(_bb, new KeywordsInTable()); }
public static KeywordsInTable GetRootAsKeywordsInTable(ByteBuffer _bb, KeywordsInTable obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public void __init(int _i, ByteBuffer _bb) { __p = new Table(_i, _bb); }

View File

@@ -2,7 +2,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by :
]#

View File

@@ -2,10 +2,20 @@
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import com.google.flatbuffers.BaseVector;
import com.google.flatbuffers.BooleanVector;
import com.google.flatbuffers.ByteVector;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.DoubleVector;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.FloatVector;
import com.google.flatbuffers.LongVector;
import com.google.flatbuffers.StringVector;
import com.google.flatbuffers.Struct;
import com.google.flatbuffers.Table;
import com.google.flatbuffers.UnionVector;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class Ability extends Struct {

View File

@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)

View File

@@ -2,7 +2,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by :
Rooting type : MyGame.Example.Monster ()

View File

@@ -2,10 +2,20 @@
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import com.google.flatbuffers.BaseVector;
import com.google.flatbuffers.BooleanVector;
import com.google.flatbuffers.ByteVector;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.DoubleVector;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.FloatVector;
import com.google.flatbuffers.LongVector;
import com.google.flatbuffers.StringVector;
import com.google.flatbuffers.Struct;
import com.google.flatbuffers.Table;
import com.google.flatbuffers.UnionVector;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public class AbilityT {
private long id;

View File

@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)

View File

@@ -2,7 +2,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by :
Rooting type : MyGame.Example.Monster ()

View File

@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)

View File

@@ -2,7 +2,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by :
Rooting type : MyGame.Example.Monster ()

View File

@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)

View File

@@ -2,7 +2,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by :
Rooting type : MyGame.Example.Monster ()

View File

@@ -2,10 +2,20 @@
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import com.google.flatbuffers.BaseVector;
import com.google.flatbuffers.BooleanVector;
import com.google.flatbuffers.ByteVector;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.DoubleVector;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.FloatVector;
import com.google.flatbuffers.LongVector;
import com.google.flatbuffers.StringVector;
import com.google.flatbuffers.Struct;
import com.google.flatbuffers.Table;
import com.google.flatbuffers.UnionVector;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class ArrayStruct extends Struct {

View File

@@ -2,10 +2,20 @@
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import com.google.flatbuffers.BaseVector;
import com.google.flatbuffers.BooleanVector;
import com.google.flatbuffers.ByteVector;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.DoubleVector;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.FloatVector;
import com.google.flatbuffers.LongVector;
import com.google.flatbuffers.StringVector;
import com.google.flatbuffers.Struct;
import com.google.flatbuffers.Table;
import com.google.flatbuffers.UnionVector;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public class ArrayStructT {
private float a;

View File

@@ -13,7 +13,7 @@ public struct ArrayTable : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_22_11_23(); }
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_22_12_06(); }
public static ArrayTable GetRootAsArrayTable(ByteBuffer _bb) { return GetRootAsArrayTable(_bb, new ArrayTable()); }
public static ArrayTable GetRootAsArrayTable(ByteBuffer _bb, ArrayTable obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public static bool ArrayTableBufferHasIdentifier(ByteBuffer _bb) { return Table.__has_identifier(_bb, "ARRT"); }

View File

@@ -2,14 +2,24 @@
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import com.google.flatbuffers.BaseVector;
import com.google.flatbuffers.BooleanVector;
import com.google.flatbuffers.ByteVector;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.DoubleVector;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.FloatVector;
import com.google.flatbuffers.LongVector;
import com.google.flatbuffers.StringVector;
import com.google.flatbuffers.Struct;
import com.google.flatbuffers.Table;
import com.google.flatbuffers.UnionVector;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class ArrayTable extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_22_11_23(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_22_12_06(); }
public static ArrayTable getRootAsArrayTable(ByteBuffer _bb) { return getRootAsArrayTable(_bb, new ArrayTable()); }
public static ArrayTable getRootAsArrayTable(ByteBuffer _bb, ArrayTable obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public static boolean ArrayTableBufferHasIdentifier(ByteBuffer _bb) { return __has_identifier(_bb, "ARRT"); }

View File

@@ -2,10 +2,20 @@
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import com.google.flatbuffers.BaseVector;
import com.google.flatbuffers.BooleanVector;
import com.google.flatbuffers.ByteVector;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.DoubleVector;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.FloatVector;
import com.google.flatbuffers.LongVector;
import com.google.flatbuffers.StringVector;
import com.google.flatbuffers.Struct;
import com.google.flatbuffers.Table;
import com.google.flatbuffers.UnionVector;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public class ArrayTableT {
private MyGame.Example.ArrayStructT a;

View File

@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)

View File

@@ -2,7 +2,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by :
Rooting type : MyGame.Example.Monster ()

View File

@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)

View File

@@ -2,7 +2,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by :
Rooting type : MyGame.Example.Monster ()

View File

@@ -14,7 +14,7 @@ public struct Monster : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_22_11_23(); }
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_22_12_06(); }
public static Monster GetRootAsMonster(ByteBuffer _bb) { return GetRootAsMonster(_bb, new Monster()); }
public static Monster GetRootAsMonster(ByteBuffer _bb, Monster obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public static bool MonsterBufferHasIdentifier(ByteBuffer _bb) { return Table.__has_identifier(_bb, "MONS"); }

View File

@@ -2,17 +2,27 @@
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import com.google.flatbuffers.BaseVector;
import com.google.flatbuffers.BooleanVector;
import com.google.flatbuffers.ByteVector;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.DoubleVector;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.FloatVector;
import com.google.flatbuffers.LongVector;
import com.google.flatbuffers.StringVector;
import com.google.flatbuffers.Struct;
import com.google.flatbuffers.Table;
import com.google.flatbuffers.UnionVector;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
/**
* an example documentation comment: "monster object"
*/
@SuppressWarnings("unused")
public final class Monster extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_22_11_23(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_22_12_06(); }
public static Monster getRootAsMonster(ByteBuffer _bb) { return getRootAsMonster(_bb, new Monster()); }
public static Monster getRootAsMonster(ByteBuffer _bb, Monster obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public static boolean MonsterBufferHasIdentifier(ByteBuffer _bb) { return __has_identifier(_bb, "MONS"); }

View File

@@ -986,7 +986,7 @@ class Monster : Table() {
return compareStrings(__offset(10, o1, _bb), __offset(10, o2, _bb), _bb)
}
companion object {
fun validateVersion() = Constants.FLATBUFFERS_22_11_23()
fun validateVersion() = Constants.FLATBUFFERS_22_12_06()
fun getRootAsMonster(_bb: ByteBuffer): Monster = getRootAsMonster(_bb, Monster())
fun getRootAsMonster(_bb: ByteBuffer, obj: Monster): Monster {
_bb.order(ByteOrder.LITTLE_ENDIAN)

View File

@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)

View File

@@ -2,7 +2,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by :
Rooting type : MyGame.Example.Monster ()

View File

@@ -2,10 +2,20 @@
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import com.google.flatbuffers.BaseVector;
import com.google.flatbuffers.BooleanVector;
import com.google.flatbuffers.ByteVector;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.DoubleVector;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.FloatVector;
import com.google.flatbuffers.LongVector;
import com.google.flatbuffers.StringVector;
import com.google.flatbuffers.Struct;
import com.google.flatbuffers.Table;
import com.google.flatbuffers.UnionVector;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public class MonsterT {
private MyGame.Example.Vec3T pos;

View File

@@ -2,10 +2,20 @@
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import com.google.flatbuffers.BaseVector;
import com.google.flatbuffers.BooleanVector;
import com.google.flatbuffers.ByteVector;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.DoubleVector;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.FloatVector;
import com.google.flatbuffers.LongVector;
import com.google.flatbuffers.StringVector;
import com.google.flatbuffers.Struct;
import com.google.flatbuffers.Table;
import com.google.flatbuffers.UnionVector;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class NestedStruct extends Struct {

View File

@@ -2,10 +2,20 @@
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import com.google.flatbuffers.BaseVector;
import com.google.flatbuffers.BooleanVector;
import com.google.flatbuffers.ByteVector;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.DoubleVector;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.FloatVector;
import com.google.flatbuffers.LongVector;
import com.google.flatbuffers.StringVector;
import com.google.flatbuffers.Struct;
import com.google.flatbuffers.Table;
import com.google.flatbuffers.UnionVector;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public class NestedStructT {
private int[] a;

View File

@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)

View File

@@ -2,7 +2,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by :
Rooting type : MyGame.Example.Monster ()

View File

@@ -13,7 +13,7 @@ public struct Referrable : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_22_11_23(); }
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_22_12_06(); }
public static Referrable GetRootAsReferrable(ByteBuffer _bb) { return GetRootAsReferrable(_bb, new Referrable()); }
public static Referrable GetRootAsReferrable(ByteBuffer _bb, Referrable obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public void __init(int _i, ByteBuffer _bb) { __p = new Table(_i, _bb); }

View File

@@ -2,14 +2,24 @@
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import com.google.flatbuffers.BaseVector;
import com.google.flatbuffers.BooleanVector;
import com.google.flatbuffers.ByteVector;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.DoubleVector;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.FloatVector;
import com.google.flatbuffers.LongVector;
import com.google.flatbuffers.StringVector;
import com.google.flatbuffers.Struct;
import com.google.flatbuffers.Table;
import com.google.flatbuffers.UnionVector;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class Referrable extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_22_11_23(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_22_12_06(); }
public static Referrable getRootAsReferrable(ByteBuffer _bb) { return getRootAsReferrable(_bb, new Referrable()); }
public static Referrable getRootAsReferrable(ByteBuffer _bb, Referrable obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }

View File

@@ -36,7 +36,7 @@ class Referrable : Table() {
return (val_1 - val_2).sign
}
companion object {
fun validateVersion() = Constants.FLATBUFFERS_22_11_23()
fun validateVersion() = Constants.FLATBUFFERS_22_12_06()
fun getRootAsReferrable(_bb: ByteBuffer): Referrable = getRootAsReferrable(_bb, Referrable())
fun getRootAsReferrable(_bb: ByteBuffer, obj: Referrable): Referrable {
_bb.order(ByteOrder.LITTLE_ENDIAN)

View File

@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)

View File

@@ -2,7 +2,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by :
Rooting type : MyGame.Example.Monster ()

View File

@@ -2,10 +2,20 @@
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import com.google.flatbuffers.BaseVector;
import com.google.flatbuffers.BooleanVector;
import com.google.flatbuffers.ByteVector;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.DoubleVector;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.FloatVector;
import com.google.flatbuffers.LongVector;
import com.google.flatbuffers.StringVector;
import com.google.flatbuffers.Struct;
import com.google.flatbuffers.Table;
import com.google.flatbuffers.UnionVector;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public class ReferrableT {
private long id;

View File

@@ -13,7 +13,7 @@ public struct Stat : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_22_11_23(); }
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_22_12_06(); }
public static Stat GetRootAsStat(ByteBuffer _bb) { return GetRootAsStat(_bb, new Stat()); }
public static Stat GetRootAsStat(ByteBuffer _bb, Stat obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public void __init(int _i, ByteBuffer _bb) { __p = new Table(_i, _bb); }

View File

@@ -2,14 +2,24 @@
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import com.google.flatbuffers.BaseVector;
import com.google.flatbuffers.BooleanVector;
import com.google.flatbuffers.ByteVector;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.DoubleVector;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.FloatVector;
import com.google.flatbuffers.LongVector;
import com.google.flatbuffers.StringVector;
import com.google.flatbuffers.Struct;
import com.google.flatbuffers.Table;
import com.google.flatbuffers.UnionVector;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class Stat extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_22_11_23(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_22_12_06(); }
public static Stat getRootAsStat(ByteBuffer _bb) { return getRootAsStat(_bb, new Stat()); }
public static Stat getRootAsStat(ByteBuffer _bb, Stat obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }

View File

@@ -57,7 +57,7 @@ class Stat : Table() {
return (val_1 - val_2).sign
}
companion object {
fun validateVersion() = Constants.FLATBUFFERS_22_11_23()
fun validateVersion() = Constants.FLATBUFFERS_22_12_06()
fun getRootAsStat(_bb: ByteBuffer): Stat = getRootAsStat(_bb, Stat())
fun getRootAsStat(_bb: ByteBuffer, obj: Stat): Stat {
_bb.order(ByteOrder.LITTLE_ENDIAN)

View File

@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)

View File

@@ -2,7 +2,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by :
Rooting type : MyGame.Example.Monster ()

View File

@@ -2,10 +2,20 @@
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import com.google.flatbuffers.BaseVector;
import com.google.flatbuffers.BooleanVector;
import com.google.flatbuffers.ByteVector;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.DoubleVector;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.FloatVector;
import com.google.flatbuffers.LongVector;
import com.google.flatbuffers.StringVector;
import com.google.flatbuffers.Struct;
import com.google.flatbuffers.Table;
import com.google.flatbuffers.UnionVector;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public class StatT {
private String id;

View File

@@ -2,10 +2,20 @@
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import com.google.flatbuffers.BaseVector;
import com.google.flatbuffers.BooleanVector;
import com.google.flatbuffers.ByteVector;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.DoubleVector;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.FloatVector;
import com.google.flatbuffers.LongVector;
import com.google.flatbuffers.StringVector;
import com.google.flatbuffers.Struct;
import com.google.flatbuffers.Table;
import com.google.flatbuffers.UnionVector;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class StructOfStructs extends Struct {

View File

@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)

View File

@@ -2,7 +2,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by :
Rooting type : MyGame.Example.Monster ()

View File

@@ -2,10 +2,20 @@
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import com.google.flatbuffers.BaseVector;
import com.google.flatbuffers.BooleanVector;
import com.google.flatbuffers.ByteVector;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.DoubleVector;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.FloatVector;
import com.google.flatbuffers.LongVector;
import com.google.flatbuffers.StringVector;
import com.google.flatbuffers.Struct;
import com.google.flatbuffers.Table;
import com.google.flatbuffers.UnionVector;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class StructOfStructsOfStructs extends Struct {

View File

@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)

View File

@@ -2,7 +2,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by :
Rooting type : MyGame.Example.Monster ()

View File

@@ -2,10 +2,20 @@
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import com.google.flatbuffers.BaseVector;
import com.google.flatbuffers.BooleanVector;
import com.google.flatbuffers.ByteVector;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.DoubleVector;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.FloatVector;
import com.google.flatbuffers.LongVector;
import com.google.flatbuffers.StringVector;
import com.google.flatbuffers.Struct;
import com.google.flatbuffers.Table;
import com.google.flatbuffers.UnionVector;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public class StructOfStructsOfStructsT {
private MyGame.Example.StructOfStructsT a;

View File

@@ -2,10 +2,20 @@
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import com.google.flatbuffers.BaseVector;
import com.google.flatbuffers.BooleanVector;
import com.google.flatbuffers.ByteVector;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.DoubleVector;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.FloatVector;
import com.google.flatbuffers.LongVector;
import com.google.flatbuffers.StringVector;
import com.google.flatbuffers.Struct;
import com.google.flatbuffers.Table;
import com.google.flatbuffers.UnionVector;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public class StructOfStructsT {
private MyGame.Example.AbilityT a;

View File

@@ -2,10 +2,20 @@
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import com.google.flatbuffers.BaseVector;
import com.google.flatbuffers.BooleanVector;
import com.google.flatbuffers.ByteVector;
import com.google.flatbuffers.Constants;
import com.google.flatbuffers.DoubleVector;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.FloatVector;
import com.google.flatbuffers.LongVector;
import com.google.flatbuffers.StringVector;
import com.google.flatbuffers.Struct;
import com.google.flatbuffers.Table;
import com.google.flatbuffers.UnionVector;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class Test extends Struct {

View File

@@ -3,7 +3,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)

View File

@@ -2,7 +2,7 @@
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 22.11.23
flatc version: 22.12.06
Declared by :
Rooting type : MyGame.Example.Monster ()

Some files were not shown because too many files have changed in this diff Show More