Compare commits

...

35 Commits

Author SHA1 Message Date
Derek Bailey
0100f6a577 FlatBuffers Version 23.5.26 (#7976) 2023-05-26 10:33:09 -07:00
swimar
e0a87e36d5 Update java pom.xml file to allow flatbuffers-java maven package to be compiled under java 8, and pulled in as a dependency to a project using java 8. (#7893) (#7894)
Co-authored-by: Derek Bailey <derekbailey@google.com>
Co-authored-by: Paulo Pinheiro <paulovictor.pinheiro@gmail.com>
2023-05-22 09:18:37 +02:00
Derek Bailey
b67f1ad6d0 don't emit flatbuffers include in bfbs generated output (#7968) 2023-05-17 21:13:16 -07:00
Derek Bailey
ae6753684e switch back to having T explicitly defined in CreateVector (#7967) 2023-05-17 13:23:34 -07:00
Chih-Hsuan Yen
a352bdbc34 Fix python tests (#7960)
* Don't generate types unless --python-typing specified

Fixes https://github.com/google/flatbuffers/issues/7944

* Fix incorrect import statements

Fixes https://github.com/google/flatbuffers/issues/7951

* Fix $PYTHONPATH in PythonTest.sh

Regressed from https://github.com/google/flatbuffers/pull/7529

* PythonTest: fail if something goes wrong

GitHub Actions runs `bash PythonTest.sh`, and thus failures were not
visible.

* Build flatc for Python tests

* Regenerate codes

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-05-17 13:10:51 -07:00
sssooonnnggg
cb14043f82 fix(rust): fixed rust namer isses, resolve #7865 and ##7782 (#7964)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-05-17 19:54:49 +02:00
Derek Bailey
d64dc6200a Switch to using alias instead of a typedef for FlatBufferBuilder (#7966) 2023-05-17 10:40:02 -07:00
sssooonnnggg
ea7cfcd591 chore: add rust windows test to CI, fix RustTest.bat (#7963)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-05-16 16:06:41 -07:00
Daniel Frederick Crisman
067553156a README.md: SemVer case typo (#7962)
SemVer (if we are capitalizing it) has a capital V. See the third
sub-header at
https://semver.org/#semantic-versioning-specification-semver
"Semantic Versioning Specification (SemVer)"

Update the text in Versioning section
2023-05-16 09:46:47 -07:00
sssooonnnggg
b128b802d9 feat: Support union underlying type for TS/JS (#7961) 2023-05-15 13:18:49 -07:00
sssooonnnggg
1d3afb90c5 feat(C++): Support underlying_type for union (#7954)
* feat(C++): support underlying type for union

* chore: add conform checks for underlying type changes
2023-05-14 21:22:38 -07:00
Derek Bailey
fe5e4c71c5 remove flatbuffers tests from android (#7959) 2023-05-12 21:49:33 -07:00
Derek Bailey
17b9eed4e1 switch to interface library for flatsample 2023-05-12 21:23:51 -07:00
Derek Bailey
cbc8872b99 fix Mac build about gen sources and multiple targets 2023-05-12 17:11:18 -07:00
Derek Bailey
05743591e1 remove and auto-generate arrays_test_generated.h 2023-05-12 16:44:28 -07:00
Derek Bailey
2bc2529245 remove and auto-generate alignment_test_generated.h 2023-05-12 16:26:21 -07:00
sssooonnnggg
18cadc79c1 fix(TS): fixed incorrect function name when importing unionTo functions (#7958) 2023-05-12 10:49:50 -07:00
Wouter van Oortmerssen
426f3b8bf2 Missing GenTextFile decl 2023-05-11 18:26:06 -07:00
Wouter van Oortmerssen
950a71ab89 Rename GenerateText
to make it a compile-time breaking change, to alert any users to the new meaning of the return value
2023-05-11 18:14:27 -07:00
Derek Bailey
86486a1735 run scripts/clang-format-all.sh 2023-05-11 12:23:49 -07:00
Derek Bailey
c2f764c22b add GetSizePrefixedBufferLength() 2023-05-11 12:22:05 -07:00
Derek Bailey
e97ff95970 Change SizedPrefixed verifier to be <= provided size 2023-05-11 12:22:05 -07:00
Derek Bailey
33212657ae Change SizedPrefixed verifier to be <= provided size (#7957)
* Change SizedPrefixed verifier to be <= provided size

* add GetSizePrefixedBufferLength()
2023-05-11 12:21:50 -07:00
Derek Bailey
66e9d9823a fixed other occurenace of big buffer 2023-05-11 09:39:54 -07:00
Derek Bailey
9fc153a8f8 remove large buffer creation in test to speed it up 2023-05-11 09:34:50 -07:00
Philipp Schrader
c2bf810638 Fix //tests/ts:bazel_repository_test (#7952)
The test was not actually invoking the bazel that was downloaded with
the `http_file` rule. I failed to add `executable = True` to the
`http_file` call. This caused the test to ignore that bazel binary and
went to the next one on the system.

This patch fixes the issue by adding the missing attribute. Also, this
patch changes the check in the test to make sure that the downloaded
file is indeed executable.
2023-05-10 21:35:58 -07:00
Derek Bailey
0ce6957763 remove unneeed grpc include 2023-05-10 16:41:39 -07:00
Derek Bailey
82c6712606 make loop variable final in dart 2023-05-10 16:30:12 -07:00
Derek Bailey
b5957975c5 rename __suppress_ubsan to FLATBUFFERS_SUPPRESS_UBSAN 2023-05-10 14:16:31 -07:00
Derek Bailey
85f71321fd Update README.md
Added Quick State to the main readme file
2023-05-10 13:56:13 -07:00
Derek Bailey
3e6cd51b63 fixed bfbs gen to pass extra options (#7949) 2023-05-09 22:42:31 -07:00
Derek Bailey
10b79d87c1 removed extern code generation declarations preferring direct includes (#7948)
* removed extern code generation definitions, preferring direct includes

* add static to functions

* remove idl_gen_lua
2023-05-09 21:50:28 -07:00
Derek Bailey
16a7df46f0 fix --conform raising No generators registered error 2023-05-09 20:37:32 -07:00
Derek Bailey
76f5e9816a fix out-of-source builds with cmake (#7946) 2023-05-09 20:33:54 -07:00
Björn Harrtell
368428cb94 Upgrade package.json dependencies (#7933)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-05-09 20:33:17 -07:00
302 changed files with 4321 additions and 3402 deletions

1
.github/labeler.yml vendored
View File

@@ -52,7 +52,6 @@ kotlin:
lua:
- '**/*.lua'
- lua/**/*
- src/idl_gen_lua.cpp
- src/bfbs_gen_lua.cpp
lobster:

View File

@@ -76,6 +76,28 @@ jobs:
- name: build
run: make -j
build-linux-out-of-source:
name: Build Linux with out-of-source build location
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: make build directory
run: mkdir build
- name: cmake
working-directory: build
run: >
CXX=clang++-12 cmake .. -G "Unix Makefiles" -DFLATBUFFERS_STRICT_MODE=ON
-DFLATBUFFERS_BUILD_CPP17=ON -DFLATBUFFERS_CPP_STD=17
- name: build
working-directory: build
run: make -j
- name: test
working-directory: build
run: pwd && ./flattests
- name: test C++17
working-directory: build
run: ./flattests_cpp17
build-linux-cpp-std:
name: Build Linux C++
runs-on: ubuntu-latest
@@ -422,20 +444,32 @@ jobs:
# gradlew
run: gradle jvmMainClasses jvmTest jsTest jsBrowserTest
build-rust:
name: Build Rust
build-rust-linux:
name: Build Rust Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: test
working-directory: tests
run: bash RustTest.sh
build-rust-windows:
name: Build Rust Windows
runs-on: windows-2019
steps:
- uses: actions/checkout@v3
- name: test
working-directory: tests
run: ./RustTest.bat
build-python:
name: Build Python
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: bash PythonTest.sh

View File

@@ -4,6 +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.
## [23.5.26 (May 26 2023)](https://github.com/google/flatbuffers/releases/tag/v23.5.26)
* Mostly bug fixing for 64-bit support
* Adds support for specifying underling type of unions in C++ and TS/JS (#7954)
## [23.5.9 (May 9 2023)](https://github.com/google/flatbuffers/releases/tag/v23.5.9)
* 64-bit support for C++ (#7935)

View File

@@ -1,6 +1,6 @@
set(VERSION_MAJOR 23)
set(VERSION_MINOR 5)
set(VERSION_PATCH 9)
set(VERSION_PATCH 26)
set(VERSION_COMMIT 0)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")

View File

@@ -166,7 +166,6 @@ set(FlatBuffers_Compiler_SRCS
src/idl_gen_php.cpp
src/idl_gen_python.cpp
src/idl_gen_lobster.cpp
src/idl_gen_lua.cpp
src/idl_gen_rust.cpp
src/idl_gen_fbs.cpp
src/idl_gen_grpc.cpp
@@ -248,7 +247,6 @@ set(FlatBuffers_Tests_CPP17_SRCS
)
set(FlatBuffers_Sample_Binary_SRCS
include/flatbuffers/flatbuffers.h
samples/sample_binary.cpp
)
@@ -492,12 +490,13 @@ endif()
function(compile_schema SRC_FBS OPT OUT_GEN_FILE)
get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH)
string(REGEX REPLACE "\\.fbs$" "_generated.h" GEN_HEADER ${SRC_FBS})
add_custom_command(TARGET flatc POST_BUILD
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}"
add_custom_command(
OUTPUT ${GEN_HEADER}
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}"
${OPT}
-o "${SRC_FBS_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
BYPRODUCTS ${GEN_HEADER}
DEPENDS flatc
COMMENT "flatc generation: `${SRC_FBS}` -> `${GEN_HEADER}`"
)
set(${OUT_GEN_FILE} ${GEN_HEADER} PARENT_SCOPE)
@@ -510,28 +509,38 @@ endfunction()
function(compile_schema_for_samples SRC_FBS OPT)
compile_schema("${SRC_FBS}" "${OPT}" GEN_FILE)
target_sources(flatsamplebinary PRIVATE ${GEN_FILE})
target_sources(flatsampletext PRIVATE ${GEN_FILE})
target_sources(flatsamplebfbs PRIVATE ${GEN_FILE})
target_sources(flatsample PRIVATE ${GEN_FILE})
endfunction()
if(FLATBUFFERS_BUILD_TESTS)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/tests)
add_executable(flattests ${FlatBuffers_Tests_SRCS})
target_link_libraries(flattests PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
target_include_directories(flattests PUBLIC src)
target_include_directories(flattests PUBLIC
# Ideally everything is fully qualified from the root directories
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
# TODO(derekbailey): update includes to fully qualify src/ and tests/
src
tests
${CMAKE_CURRENT_BINARY_DIR}/tests
)
# Have tests load data from the source directory, not the build directory.
add_definitions(-DFLATBUFFERS_TEST_PATH_PREFIX=${CMAKE_CURRENT_SOURCE_DIR}/)
# The flattest target needs some generated files
SET(FLATC_OPT --cpp --gen-mutable --gen-object-api --reflect-names)
SET(FLATC_OPT_COMP ${FLATC_OPT};--gen-compare)
compile_schema_for_test(tests/alignment_test.fbs "${FLATC_OPT_COMP}")
compile_schema_for_test(tests/arrays_test.fbs "${FLATC_OPT_COMP};--scoped-enums")
compile_schema_for_test(tests/native_inline_table_test.fbs "${FLATC_OPT_COMP}")
compile_schema_for_test(tests/native_type_test.fbs "${FLATC_OPT}")
compile_schema_for_test(tests/key_field/key_field_sample.fbs "${FLATC_OPT_COMP}")
compile_schema_for_test(tests/64bit/test_64bit.fbs "${FLATC_OPT_COMP};--bfbs-gen-embed")
compile_schema_for_test(tests/64bit/evolution/v1.fbs "${FLATC_OPT_COMP}")
compile_schema_for_test(tests/64bit/evolution/v2.fbs "${FLATC_OPT_COMP}")
compile_schema_for_test(tests/union_underlying_type_test.fbs "${FLATC_OPT_COMP}")
if(FLATBUFFERS_CODE_SANITIZE)
add_fsanitize_to_target(flattests ${FLATBUFFERS_CODE_SANITIZE})
@@ -542,16 +551,24 @@ if(FLATBUFFERS_BUILD_TESTS)
add_executable(flatsamplebinary ${FlatBuffers_Sample_Binary_SRCS})
add_executable(flatsampletext ${FlatBuffers_Sample_Text_SRCS})
add_executable(flatsamplebfbs ${FlatBuffers_Sample_BFBS_SRCS})
target_link_libraries(flatsamplebinary PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
target_link_libraries(flatsampletext PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
target_link_libraries(flatsamplebfbs PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
# Add a library so there is a single target that the generated samples can
# link too.
add_library(flatsample INTERFACE)
# Since flatsample has no sources, we have to explicitly set the linker lang.
set_target_properties(flatsample PROPERTIES LINKER_LANGUAGE CXX)
compile_schema_for_samples(samples/monster.fbs "${FLATC_OPT_COMP}")
target_link_libraries(flatsamplebinary PRIVATE $<BUILD_INTERFACE:ProjectConfig> flatsample)
target_link_libraries(flatsampletext PRIVATE $<BUILD_INTERFACE:ProjectConfig> flatsample)
target_link_libraries(flatsamplebfbs PRIVATE $<BUILD_INTERFACE:ProjectConfig> flatsample)
if(FLATBUFFERS_BUILD_CPP17)
add_executable(flattests_cpp17 ${FlatBuffers_Tests_CPP17_SRCS})
target_link_libraries(flattests_cpp17 PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
target_include_directories(flattests_cpp17 PUBLIC src tests)
target_compile_features(flattests_cpp17 PRIVATE cxx_std_17) # requires cmake 3.8
if(FLATBUFFERS_CODE_SANITIZE)

View File

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

View File

@@ -14,6 +14,47 @@
**FlatBuffers** is a cross platform serialization library architected for
maximum memory efficiency. It allows you to directly access serialized data without parsing/unpacking it first, while still having great forwards/backwards compatibility.
## Quick Start
1. Build the compiler for flatbuffers (`flatc`)
Use `cmake` to create the build files for your platform and then perform the compliation (Linux example).
```
cmake -G "Unix Makefiles"
make -j
```
2. Define your flatbuffer schema (`.fbs`)
Write the [schema](https://flatbuffers.dev/flatbuffers_guide_writing_schema.html) to define the data you want to serialize. See [monster.fbs](https://github.com/google/flatbuffers/blob/master/samples/monster.fbs) for an example.
3. Generate code for your language(s)
Use the `flatc` compiler to take your schema and generate language-specific code:
```
./flatc --cpp --rust monster.fbs
```
Which generates `monster_generated.h` and `monster_generated.rs` files.
4. Serialize data
Use the generated code, as well as the `FlatBufferBuilder` to construct your serialized buffer. ([`C++` example](https://github.com/google/flatbuffers/blob/master/samples/sample_binary.cpp#L24-L56))
5. Transmit/store/save Buffer
Use your serialized buffer however you want. Send it to someone, save it for later, etc...
6. Read the data
Use the generated accessors to read the data from the serialized buffer.
It doesn't need to be the same language/schema version, FlatBuffers ensures the data is readable across languages and schema versions. See the [`Rust` example](https://github.com/google/flatbuffers/blob/master/samples/sample_binary.rs#L92-L106) reading the data written by `C++`.
## Documentation
**Go to our [landing page][] to browse our documentation.**
## Supported operating systems
@@ -46,7 +87,7 @@ Code generation and runtime libraries for many popular languages.
## Versioning
FlatBuffers does not follow traditional Semver versioning (see [rationale](https://github.com/google/flatbuffers/wiki/Versioning)) but rather uses a format of the date of the release.
FlatBuffers does not follow traditional SemVer versioning (see [rationale](https://github.com/google/flatbuffers/wiki/Versioning)) but rather uses a format of the date of the release.
## Contribution

View File

@@ -148,6 +148,7 @@ esbuild_register_toolchains(
http_file(
name = "bazel_linux_x86_64",
downloaded_file_path = "bazel",
executable = True,
sha256 = "e89747d63443e225b140d7d37ded952dacea73aaed896bca01ccd745827c6289",
urls = [
"https://github.com/bazelbuild/bazel/releases/download/6.1.2/bazel-6.1.2-linux-x86_64",

View File

@@ -48,7 +48,6 @@ find_library( # Sets the name of the path variable.
target_link_libraries( # Specifies the target library.
native-lib
flatbuffers
flatbuffers_tests
# Links the target library to the log library
# included in the NDK.
${log-lib} )

View File

@@ -48,26 +48,9 @@ set(FlatBuffers_Library_SRCS
${FLATBUFFERS_SRC}/src/code_generators.cpp
)
set(FlatBuffers_Test_SRCS
${FLATBUFFERS_SRC}/tests/test.cpp
${FLATBUFFERS_SRC}/tests/test_assert.h
${FLATBUFFERS_SRC}/tests/test_builder.h
${FLATBUFFERS_SRC}/tests/test_assert.cpp
${FLATBUFFERS_SRC}/tests/test_builder.cpp
${FLATBUFFERS_SRC}/tests/native_type_test_impl.h
${FLATBUFFERS_SRC}/tests/native_type_test_impl.cpp
)
add_library( # Sets the name of the library.
flatbuffers
${FlatBuffers_Library_SRCS}
${FlatBuffers_Test_SRCS}
${Generated_SRCS}
)
add_library( # Sets the name of the library.
flatbuffers_tests
${FlatBuffers_Test_SRCS}
)

View File

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

View File

@@ -654,7 +654,7 @@ class Builder {
var tail = _tail;
_setUint32AtTail(tail, values.length);
tail -= _sizeofUint32;
for (var value in values) {
for (final value in values) {
_setInt8AtTail(tail, value);
tail -= _sizeofUint8;
}

View File

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

@@ -10,7 +10,7 @@ public struct Galaxy : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_23_5_9(); }
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_23_5_26(); }
public static Galaxy GetRootAsGalaxy(ByteBuffer _bb) { return GetRootAsGalaxy(_bb, new Galaxy()); }
public static Galaxy GetRootAsGalaxy(ByteBuffer _bb, Galaxy obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public void __init(int _i, ByteBuffer _bb) { __p = new Table(_i, _bb); }

View File

@@ -10,7 +10,7 @@ public struct Universe : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_23_5_9(); }
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_23_5_26(); }
public static Universe GetRootAsUniverse(ByteBuffer _bb) { return GetRootAsUniverse(_bb, new Universe()); }
public static Universe GetRootAsUniverse(ByteBuffer _bb, Universe obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public static bool VerifyUniverse(ByteBuffer _bb) {Google.FlatBuffers.Verifier verifier = new Google.FlatBuffers.Verifier(_bb); return verifier.VerifyBuffer("", false, UniverseVerify.Verify); }

View File

@@ -23,9 +23,8 @@ GenerateGo()
GenerateJava()
GenerateKotlin()
GenerateLobster()
# TODO these doesn't respect the output prefix, fix and reenable
# GenerateLua()
# GenerateNim()
GenerateLua()
GenerateNim()
GeneratePhp()
GeneratePython()
GenerateRust()

View File

@@ -19,7 +19,7 @@ import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class Galaxy extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_9(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_26(); }
public static Galaxy getRootAsGalaxy(ByteBuffer _bb) { return getRootAsGalaxy(_bb, new Galaxy()); }
public static Galaxy getRootAsGalaxy(ByteBuffer _bb, Galaxy obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }

View File

@@ -19,7 +19,7 @@ import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class Universe extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_9(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_26(); }
public static Universe getRootAsUniverse(ByteBuffer _bb) { return getRootAsUniverse(_bb, new Universe()); }
public static Universe getRootAsUniverse(ByteBuffer _bb, Universe obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }

View File

@@ -32,7 +32,7 @@ class Galaxy : Table() {
return if(o != 0) bb.getLong(o + bb_pos) else 0L
}
companion object {
fun validateVersion() = Constants.FLATBUFFERS_23_5_9()
fun validateVersion() = Constants.FLATBUFFERS_23_5_26()
fun getRootAsGalaxy(_bb: ByteBuffer): Galaxy = getRootAsGalaxy(_bb, Galaxy())
fun getRootAsGalaxy(_bb: ByteBuffer, obj: Galaxy): Galaxy {
_bb.order(ByteOrder.LITTLE_ENDIAN)

View File

@@ -45,7 +45,7 @@ class Universe : Table() {
val o = __offset(6); return if (o != 0) __vector_len(o) else 0
}
companion object {
fun validateVersion() = Constants.FLATBUFFERS_23_5_9()
fun validateVersion() = Constants.FLATBUFFERS_23_5_26()
fun getRootAsUniverse(_bb: ByteBuffer): Universe = getRootAsUniverse(_bb, Universe())
fun getRootAsUniverse(_bb: ByteBuffer, obj: Universe): Universe {
_bb.order(ByteOrder.LITTLE_ENDIAN)

48
goldens/lua/Galaxy.lua Normal file
View File

@@ -0,0 +1,48 @@
--[[ Galaxy
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 23.5.9
Declared by : //basic.fbs
Rooting type : Universe (//basic.fbs)
--]]
local flatbuffers = require('flatbuffers')
local Galaxy = {}
local mt = {}
function Galaxy.New()
local o = {}
setmetatable(o, {__index = mt})
return o
end
function mt:Init(buf, pos)
self.view = flatbuffers.view.New(buf, pos)
end
function mt:NumStars()
local o = self.view:Offset(4)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Int64, self.view.pos + o)
end
return 0
end
function Galaxy.Start(builder)
builder:StartObject(1)
end
function Galaxy.AddNumStars(builder, numStars)
builder:PrependInt64Slot(0, numStars, 0)
end
function Galaxy.End(builder)
return builder:EndObject()
end
return Galaxy

88
goldens/lua/Universe.lua Normal file
View File

@@ -0,0 +1,88 @@
--[[ Universe
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 23.5.9
Declared by : //basic.fbs
Rooting type : Universe (//basic.fbs)
--]]
local __Galaxy = require('Galaxy')
local flatbuffers = require('flatbuffers')
local Universe = {}
local mt = {}
function Universe.New()
local o = {}
setmetatable(o, {__index = mt})
return o
end
function Universe.GetRootAsUniverse(buf, offset)
if type(buf) == "string" then
buf = flatbuffers.binaryArray.New(buf)
end
local n = flatbuffers.N.UOffsetT:Unpack(buf, offset)
local o = Universe.New()
o:Init(buf, n + offset)
return o
end
function mt:Init(buf, pos)
self.view = flatbuffers.view.New(buf, pos)
end
function mt:Age()
local o = self.view:Offset(4)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Float64, self.view.pos + o)
end
return 0.0
end
function mt:Galaxies(j)
local o = self.view:Offset(6)
if o ~= 0 then
local x = self.view:Vector(o)
x = x + ((j-1) * 4)
x = self.view:Indirect(x)
local obj = __Galaxy.New()
obj:Init(self.view.bytes, x)
return obj
end
end
function mt:GalaxiesLength()
local o = self.view:Offset(6)
if o ~= 0 then
return self.view:VectorLen(o)
end
return 0
end
function Universe.Start(builder)
builder:StartObject(2)
end
function Universe.AddAge(builder, age)
builder:PrependFloat64Slot(0, age, 0.0)
end
function Universe.AddGalaxies(builder, galaxies)
builder:PrependUOffsetTRelativeSlot(1, galaxies, 0)
end
function Universe.StartGalaxiesVector(builder, numElems)
return builder:StartVector(4, numElems, 4)
end
function Universe.End(builder)
return builder:EndObject()
end
return Universe

26
goldens/nim/Galaxy.nim Normal file
View File

@@ -0,0 +1,26 @@
#[ Galaxy
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 23.5.9
Declared by : //basic.fbs
Rooting type : Universe (//basic.fbs)
]#
import flatbuffers
type Galaxy* = object of FlatObj
func numStars*(self: Galaxy): int64 =
let o = self.tab.Offset(4)
if o != 0:
return Get[int64](self.tab, self.tab.Pos + o)
return 0
func `numStars=`*(self: var Galaxy, n: int64): bool =
return self.tab.MutateSlot(4, n)
proc GalaxyStart*(builder: var Builder) =
builder.StartObject(1)
proc GalaxyAddnumStars*(builder: var Builder, numStars: int64) =
builder.PrependSlot(0, numStars, default(int64))
proc GalaxyEnd*(builder: var Builder): uoffset =
return builder.EndObject()

46
goldens/nim/Universe.nim Normal file
View File

@@ -0,0 +1,46 @@
#[ Universe
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 23.5.9
Declared by : //basic.fbs
Rooting type : Universe (//basic.fbs)
]#
import Galaxy as Galaxy
import flatbuffers
import std/options
type Universe* = object of FlatObj
func age*(self: Universe): float64 =
let o = self.tab.Offset(4)
if o != 0:
return Get[float64](self.tab, self.tab.Pos + o)
return 0.0
func `age=`*(self: var Universe, n: float64): bool =
return self.tab.MutateSlot(4, n)
func galaxiesLength*(self: Universe): int =
let o = self.tab.Offset(6)
if o != 0:
return self.tab.VectorLen(o)
func galaxies*(self: Universe, j: int): Galaxy.Galaxy =
let o = self.tab.Offset(6)
if o != 0:
var x = self.tab.Vector(o)
x += j.uoffset * 4.uoffset
return Galaxy.Galaxy(tab: Vtable(Bytes: self.tab.Bytes, Pos: x))
func galaxies*(self: Universe): seq[Galaxy.Galaxy] =
let len = self.galaxiesLength
for i in countup(0, len - 1):
result.add(self.galaxies(i))
proc UniverseStart*(builder: var Builder) =
builder.StartObject(2)
proc UniverseAddage*(builder: var Builder, age: float64) =
builder.PrependSlot(0, age, default(float64))
proc UniverseAddgalaxies*(builder: var Builder, galaxies: uoffset) =
builder.PrependSlot(1, galaxies, default(uoffset))
proc UniverseStartgalaxiesVector*(builder: var Builder, numElems: uoffset) =
builder.StartVector(4, numElems, 4)
proc UniverseEnd*(builder: var Builder): uoffset =
return builder.EndObject()

View File

@@ -6,7 +6,7 @@ import FlatBuffers
public struct Galaxy: FlatBufferObject, Verifiable {
static func validateVersion() { FlatBuffersVersion_23_5_9() }
static func validateVersion() { FlatBuffersVersion_23_5_26() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
@@ -41,7 +41,7 @@ public struct Galaxy: FlatBufferObject, Verifiable {
public struct Universe: FlatBufferObject, Verifiable {
static func validateVersion() { FlatBuffersVersion_23_5_9() }
static func validateVersion() { FlatBuffersVersion_23_5_26() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table

View File

@@ -40,7 +40,7 @@ def Start(builder):
def HelloReplyAddMessage(builder, message):
builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(message), 0)
def AddMessage(builder: flatbuffers.Builder, message: int):
def AddMessage(builder, message):
HelloReplyAddMessage(builder, message)
def HelloReplyEnd(builder):

View File

@@ -40,7 +40,7 @@ def Start(builder):
def HelloRequestAddName(builder, name):
builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0)
def AddName(builder: flatbuffers.Builder, name: int):
def AddName(builder, name):
HelloRequestAddName(builder, name)
def HelloRequestEnd(builder):

View File

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

View File

@@ -141,7 +141,7 @@
#define FLATBUFFERS_VERSION_MAJOR 23
#define FLATBUFFERS_VERSION_MINOR 5
#define FLATBUFFERS_VERSION_REVISION 9
#define FLATBUFFERS_VERSION_REVISION 26
#define FLATBUFFERS_STRING_EXPAND(X) #X
#define FLATBUFFERS_STRING(X) FLATBUFFERS_STRING_EXPAND(X)
namespace flatbuffers {
@@ -279,14 +279,14 @@ namespace flatbuffers {
#endif // !FLATBUFFERS_LOCALE_INDEPENDENT
// Suppress Undefined Behavior Sanitizer (recoverable only). Usage:
// - __suppress_ubsan__("undefined")
// - __suppress_ubsan__("signed-integer-overflow")
// - FLATBUFFERS_SUPPRESS_UBSAN("undefined")
// - FLATBUFFERS_SUPPRESS_UBSAN("signed-integer-overflow")
#if defined(__clang__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >=7))
#define __suppress_ubsan__(type) __attribute__((no_sanitize(type)))
#define FLATBUFFERS_SUPPRESS_UBSAN(type) __attribute__((no_sanitize(type)))
#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 409)
#define __suppress_ubsan__(type) __attribute__((no_sanitize_undefined))
#define FLATBUFFERS_SUPPRESS_UBSAN(type) __attribute__((no_sanitize_undefined))
#else
#define __suppress_ubsan__(type)
#define FLATBUFFERS_SUPPRESS_UBSAN(type)
#endif
// This is constexpr function used for checking compile-time constants.
@@ -422,7 +422,7 @@ template<typename T> T EndianScalar(T t) {
template<typename T>
// UBSAN: C++ aliasing type rules, see std::bit_cast<> for details.
__suppress_ubsan__("alignment")
FLATBUFFERS_SUPPRESS_UBSAN("alignment")
T ReadScalar(const void *p) {
return EndianScalar(*reinterpret_cast<const T *>(p));
}
@@ -436,13 +436,13 @@ T ReadScalar(const void *p) {
template<typename T>
// UBSAN: C++ aliasing type rules, see std::bit_cast<> for details.
__suppress_ubsan__("alignment")
FLATBUFFERS_SUPPRESS_UBSAN("alignment")
void WriteScalar(void *p, T t) {
*reinterpret_cast<T *>(p) = EndianScalar(t);
}
template<typename T> struct Offset;
template<typename T> __suppress_ubsan__("alignment") void WriteScalar(void *p, Offset<T> t) {
template<typename T> FLATBUFFERS_SUPPRESS_UBSAN("alignment") void WriteScalar(void *p, Offset<T> t) {
*reinterpret_cast<uoffset_t *>(p) = EndianScalar(t.o);
}
@@ -453,7 +453,7 @@ template<typename T> __suppress_ubsan__("alignment") void WriteScalar(void *p, O
// Computes how many bytes you'd have to pad to be able to write an
// "scalar_size" scalar if the buffer had grown to "buf_size" (downwards in
// memory).
__suppress_ubsan__("unsigned-integer-overflow")
FLATBUFFERS_SUPPRESS_UBSAN("unsigned-integer-overflow")
inline size_t PaddingBytes(size_t buf_size, size_t scalar_size) {
return ((~buf_size) + 1) & (scalar_size - 1);
}

View File

@@ -23,6 +23,10 @@
namespace flatbuffers {
struct CodeGenOptions {
std::string output_path;
};
// A code generator interface for producing converting flatbuffer schema into
// code.
class CodeGenerator {
@@ -44,9 +48,20 @@ class CodeGenerator {
virtual Status GenerateCode(const Parser &parser, const std::string &path,
const std::string &filename) = 0;
// Generate code from the provided `parser` and place it in the output.
virtual Status GenerateCodeString(const Parser &parser,
const std::string &filename,
std::string &output) {
(void)parser;
(void)filename;
(void)output;
return Status::NOT_IMPLEMENTED;
}
// Generate code from the provided `buffer` of given `length`. The buffer is a
// serialized reflection.fbs.
virtual Status GenerateCode(const uint8_t *buffer, int64_t length) = 0;
virtual Status GenerateCode(const uint8_t *buffer, int64_t length,
const CodeGenOptions &options) = 0;
virtual Status GenerateMakeRule(const Parser &parser, const std::string &path,
const std::string &filename,

View File

@@ -229,6 +229,10 @@ class TypedFloatConstantGenerator : public FloatConstantGenerator {
const std::string neg_inf_number_;
};
std::string JavaCSharpMakeRule(const bool java, const Parser &parser,
const std::string &path,
const std::string &file_name);
} // namespace flatbuffers
#endif // FLATBUFFERS_CODE_GENERATORS_H_

View File

@@ -722,9 +722,8 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl {
/// @param[in] len The number of elements to serialize.
/// @return Returns a typed `TOffset` into the serialized data indicating
/// where the vector is stored.
template<template<typename...> class OffsetT = Offset,
template<typename...> class VectorT = Vector,
int &...ExplicitArgumentBarrier, typename T>
template<typename T, template<typename...> class OffsetT = Offset,
template<typename...> class VectorT = Vector>
OffsetT<VectorT<T>> CreateVector(const T *v, size_t len) {
// The type of the length field in the vector.
typedef typename VectorT<T>::size_type LenT;
@@ -793,7 +792,7 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl {
template<template<typename...> class VectorT = Vector64,
int &...ExplicitArgumentBarrier, typename T>
Offset64<VectorT<T>> CreateVector64(const std::vector<T> &v) {
return CreateVector<Offset64, VectorT>(data(v), v.size());
return CreateVector<T, Offset64, VectorT>(data(v), v.size());
}
// vector<bool> may be implemented using a bit-set, so we can't access it as
@@ -1302,11 +1301,6 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl {
// This will remain 0 if no 64-bit offset types are added to the buffer.
size_t length_of_64_bit_region_;
// When true, 64-bit offsets can still be added to the builder. When false,
// only 32-bit offsets can be added, and attempts to add a 64-bit offset will
// raise an assertion. This is typically a compile-time error in ordering the
// serialization of 64-bit offset fields not at the tail of the buffer.
// Ensure objects are not nested.
bool nested;
@@ -1417,8 +1411,8 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl {
// Hack to `FlatBufferBuilder` mean `FlatBufferBuilder<false>` or
// `FlatBufferBuilder<>`, where the template < > syntax is required.
typedef FlatBufferBuilderImpl<false> FlatBufferBuilder;
typedef FlatBufferBuilderImpl<true> FlatBufferBuilder64;
using FlatBufferBuilder = FlatBufferBuilderImpl<false>;
using FlatBufferBuilder64 = FlatBufferBuilderImpl<true>;
// These are external due to GCC not allowing them in the class.
// See: https://stackoverflow.com/q/8061456/868247

View File

@@ -81,6 +81,17 @@ inline SizeT GetPrefixedSize(const uint8_t *buf) {
return ReadScalar<SizeT>(buf);
}
// Gets the total length of the buffer given a sized prefixed FlatBuffer.
//
// This includes the size of the prefix as well as the buffer:
//
// [size prefix][flatbuffer]
// |---------length--------|
template<typename SizeT = uoffset_t>
inline SizeT GetSizePrefixedBufferLength(const uint8_t *const buf) {
return ReadScalar<SizeT>(buf) + sizeof(SizeT);
}
// Base class for native objects (FlatBuffer data de-serialized into native
// C++ data structures).
// Contains no functionality, purely documentative.

View File

@@ -20,7 +20,6 @@
// Helper functionality to glue FlatBuffers and GRPC.
#include "flatbuffers/flatbuffers.h"
#include "grpc/byte_buffer_reader.h"
#include "grpcpp/support/byte_buffer.h"
#include "grpcpp/support/slice.h"

View File

@@ -1151,6 +1151,7 @@ class Parser : public ParserState {
bool SupportsOptionalScalars() const;
bool SupportsDefaultVectorsAndStrings() const;
bool Supports64BitOffsets() const;
bool SupportsUnionUnderlyingType() const;
Namespace *UniqueNamespace(Namespace *ns);
FLATBUFFERS_CHECKED_ERROR RecurseError();
@@ -1210,137 +1211,17 @@ class Parser : public ParserState {
// if it is less than 0, no linefeeds will be generated either.
// See idl_gen_text.cpp.
// strict_json adds "quotes" around field names if true.
// If the flatbuffer cannot be encoded in JSON (e.g., it contains non-UTF-8
// byte arrays in String values), returns false.
extern const char *GenerateTextFromTable(const Parser &parser, const void *table,
const std::string &tablename,
std::string *text);
extern const char *GenerateText(const Parser &parser, const void *flatbuffer,
std::string *text);
extern const char *GenerateTextFile(const Parser &parser,
const std::string &path,
const std::string &file_name);
// Generate Json schema to string
// See idl_gen_json_schema.cpp.
extern bool GenerateJsonSchema(const Parser &parser, std::string *json);
// Generate binary files from a given FlatBuffer, and a given Parser
// object that has been populated with the corresponding schema.
// See code_generators.cpp.
extern bool GenerateBinary(const Parser &parser, const std::string &path,
const std::string &file_name);
// Generate a C++ header from the definitions in the Parser object.
// See idl_gen_cpp.
extern bool GenerateCPP(const Parser &parser, const std::string &path,
const std::string &file_name);
// Generate C# files from the definitions in the Parser object.
// See idl_gen_csharp.cpp.
extern bool GenerateCSharp(const Parser &parser, const std::string &path,
const std::string &file_name);
extern bool GenerateDart(const Parser &parser, const std::string &path,
const std::string &file_name);
// Generate Java files from the definitions in the Parser object.
// See idl_gen_java.cpp.
extern bool GenerateJava(const Parser &parser, const std::string &path,
const std::string &file_name);
// Generate JavaScript or TypeScript code from the definitions in the Parser
// object. See idl_gen_js.
extern bool GenerateTS(const Parser &parser, const std::string &path,
const std::string &file_name);
// Generate Go files from the definitions in the Parser object.
// See idl_gen_go.cpp.
extern bool GenerateGo(const Parser &parser, const std::string &path,
const std::string &file_name);
// Generate Php code from the definitions in the Parser object.
// See idl_gen_php.
extern bool GeneratePhp(const Parser &parser, const std::string &path,
const std::string &file_name);
// Generate Python files from the definitions in the Parser object.
// See idl_gen_python.cpp.
extern bool GeneratePython(const Parser &parser, const std::string &path,
const std::string &file_name);
// Generate Lobster files from the definitions in the Parser object.
// See idl_gen_lobster.cpp.
extern bool GenerateLobster(const Parser &parser, const std::string &path,
const std::string &file_name);
// Generate Lua files from the definitions in the Parser object.
// See idl_gen_lua.cpp.
extern bool GenerateLua(const Parser &parser, const std::string &path,
const std::string &file_name);
// Generate Rust files from the definitions in the Parser object.
// See idl_gen_rust.cpp.
extern bool GenerateRust(const Parser &parser, const std::string &path,
const std::string &file_name);
// Generate Json schema file
// See idl_gen_json_schema.cpp.
extern bool GenerateJsonSchema(const Parser &parser, const std::string &path,
// These functions return nullptr on success, or an error string,
// which may happen if the flatbuffer cannot be encoded in JSON (e.g.,
// it contains non-UTF-8 byte arrays in String values).
extern const char *GenTextFromTable(const Parser &parser, const void *table,
const std::string &tablename,
std::string *text);
extern const char *GenText(const Parser &parser, const void *flatbuffer,
std::string *text);
extern const char *GenTextFile(const Parser &parser, const std::string &path,
const std::string &file_name);
extern bool GenerateKotlin(const Parser &parser, const std::string &path,
const std::string &file_name);
// Generate Swift classes.
// See idl_gen_swift.cpp
extern bool GenerateSwift(const Parser &parser, const std::string &path,
const std::string &file_name);
// Generate a schema file from the internal representation, useful after
// parsing a .proto schema.
extern std::string GenerateFBS(const Parser &parser,
const std::string &file_name, bool no_log);
extern bool GenerateFBS(const Parser &parser, const std::string &path,
const std::string &file_name, bool no_log);
// Generate a make rule for the generated TypeScript code.
// See idl_gen_ts.cpp.
extern std::string TSMakeRule(const Parser &parser, const std::string &path,
const std::string &file_name);
// Generate a make rule for the generated C++ header.
// See idl_gen_cpp.cpp.
extern std::string CPPMakeRule(const Parser &parser, const std::string &path,
const std::string &file_name);
// Generate a make rule for the generated Dart code
// see idl_gen_dart.cpp
extern std::string DartMakeRule(const Parser &parser, const std::string &path,
const std::string &file_name);
// Generate a make rule for the generated Rust code.
// See idl_gen_rust.cpp.
extern std::string RustMakeRule(const Parser &parser, const std::string &path,
const std::string &file_name);
// Generate a make rule for generated Java or C# files.
// See code_generators.cpp.
extern std::string CSharpMakeRule(const Parser &parser, const std::string &path,
const std::string &file_name);
extern std::string JavaMakeRule(const Parser &parser, const std::string &path,
const std::string &file_name);
// Generate a make rule for the generated text (JSON) files.
// See idl_gen_text.cpp.
extern std::string TextMakeRule(const Parser &parser, const std::string &path,
const std::string &file_names);
// Generate a make rule for the generated binary files.
// See code_generators.cpp.
extern std::string BinaryMakeRule(const Parser &parser, const std::string &path,
const std::string &file_name);
// Generate GRPC Cpp interfaces.
// See idl_gen_grpc.cpp.
bool GenerateCppGRPC(const Parser &parser, const std::string &path,
@@ -1368,9 +1249,6 @@ extern bool GenerateSwiftGRPC(const Parser &parser, const std::string &path,
extern bool GenerateTSGRPC(const Parser &parser, const std::string &path,
const std::string &file_name);
extern bool GenerateRustModuleRootFile(const Parser &parser,
const std::string &path);
} // namespace flatbuffers
#endif // FLATBUFFERS_IDL_H_

View File

@@ -10,7 +10,7 @@
// generated, otherwise it may not be compatible.
static_assert(FLATBUFFERS_VERSION_MAJOR == 23 &&
FLATBUFFERS_VERSION_MINOR == 5 &&
FLATBUFFERS_VERSION_REVISION == 9,
FLATBUFFERS_VERSION_REVISION == 26,
"Non-compatible flatbuffers version included");
namespace reflection {

View File

@@ -52,10 +52,10 @@ class Registry {
Parser parser;
if (!LoadSchema(ident, &parser)) return false;
// Now we're ready to generate text.
auto err = GenerateText(parser, flatbuf, dest);
auto err = GenText(parser, flatbuf, dest);
if (err) {
lasterror_ = "unable to generate text for FlatBuffer binary: " +
std::string(err);
lasterror_ =
"unable to generate text for FlatBuffer binary: " + std::string(err);
return false;
}
return true;

View File

@@ -153,7 +153,7 @@ class Table {
return verifier.Check(field_offset != 0) &&
verifier.VerifyOffset<OffsetT>(data_, field_offset);
}
bool VerifyOffset64(const Verifier &verifier, voffset_t field) const {
return VerifyOffset<uoffset64_t>(verifier, field);
}

View File

@@ -257,7 +257,7 @@ inline void strtoval_impl(double *val, const char *str, char **endptr) {
}
// UBSAN: double to float is safe if numeric_limits<float>::is_iec559 is true.
__suppress_ubsan__("float-cast-overflow")
FLATBUFFERS_SUPPRESS_UBSAN("float-cast-overflow")
inline void strtoval_impl(float *val, const char *str, char **endptr) {
*val = __strtof_impl(str, endptr);
}
@@ -623,7 +623,7 @@ inline bool EscapeString(const char *s, size_t length, std::string *_text,
// we previously checked for non-UTF-8, so we shouldn't reach
// here.
//
// 2) We reached here by someone calling GenerateText()
// 2) We reached here by someone calling GenText()
// on a previously-serialized flatbuffer. The data might have
// non-UTF-8 Strings, or might be corrupt.
//

View File

@@ -147,12 +147,10 @@ struct VectorReverseIterator : public std::reverse_iterator<Iterator> {
// Vector::data() assumes the vector elements start after the length field.
template<typename T, typename SizeT = uoffset_t> class Vector {
public:
typedef VectorIterator<T,
typename IndirectHelper<T>::mutable_return_type,
typedef VectorIterator<T, typename IndirectHelper<T>::mutable_return_type,
uint8_t *, SizeT>
iterator;
typedef VectorConstIterator<T, typename IndirectHelper<T>::return_type,
SizeT>
typedef VectorConstIterator<T, typename IndirectHelper<T>::return_type, SizeT>
const_iterator;
typedef VectorReverseIterator<iterator> reverse_iterator;
typedef VectorReverseIterator<const_iterator> const_reverse_iterator;
@@ -171,8 +169,7 @@ template<typename T, typename SizeT = uoffset_t> class Vector {
typedef SizeT size_type;
typedef typename IndirectHelper<T>::return_type return_type;
typedef typename IndirectHelper<T>::mutable_return_type
mutable_return_type;
typedef typename IndirectHelper<T>::mutable_return_type mutable_return_type;
typedef return_type value_type;
return_type Get(SizeT i) const {

View File

@@ -17,9 +17,8 @@
#ifndef FLATBUFFERS_VECTOR_DOWNWARD_H_
#define FLATBUFFERS_VECTOR_DOWNWARD_H_
#include <cstdint>
#include <algorithm>
#include <cstdint>
#include "flatbuffers/base.h"
#include "flatbuffers/default_allocator.h"
@@ -167,7 +166,9 @@ template<typename SizeT = uoffset_t> class vector_downward {
inline SizeT size() const { return size_; }
// The size of the buffer part of the vector that is currently unused.
SizeT unused_buffer_size() const { return static_cast<SizeT>(cur_ - scratch_); }
SizeT unused_buffer_size() const {
return static_cast<SizeT>(cur_ - scratch_);
}
// The size of the scratch part of the vector.
SizeT scratch_size() const { return static_cast<SizeT>(scratch_ - buf_); }

View File

@@ -177,8 +177,8 @@ class Verifier FLATBUFFERS_FINAL_CLASS {
return true;
}
__suppress_ubsan__("unsigned-integer-overflow") bool VerifyTableStart(
const uint8_t *const table) {
FLATBUFFERS_SUPPRESS_UBSAN("unsigned-integer-overflow")
bool VerifyTableStart(const uint8_t *const table) {
// Check the vtable offset.
const auto tableo = static_cast<size_t>(table - buf_);
if (!Verify<soffset_t>(tableo)) return false;
@@ -246,7 +246,9 @@ class Verifier FLATBUFFERS_FINAL_CLASS {
template<typename T, typename SizeT = uoffset_t>
bool VerifySizePrefixedBuffer(const char *const identifier) {
return Verify<SizeT>(0U) &&
Check(ReadScalar<SizeT>(buf_) == size_ - sizeof(SizeT)) &&
// Ensure the prefixed size is within the bounds of the provided
// length.
Check(ReadScalar<SizeT>(buf_) + sizeof(SizeT) <= size_) &&
VerifyBufferFromStart<T>(identifier, sizeof(SizeT));
}

View File

@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.flatbuffers</groupId>
<artifactId>flatbuffers-java</artifactId>
<version>23.5.9</version>
<version>23.5.26</version>
<packaging>bundle</packaging>
<name>FlatBuffers Java API</name>
<description>
@@ -59,15 +59,91 @@
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<release>8</release>
<testExcludes>
<testExclude>MyGame/Example/MonsterStorageGrpc.java</testExclude>
<testExclude>MyGame/OtherNameSpace/TableBT.java</testExclude>
</testExcludes>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
<version>2.22.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
<additionalOptions>-Xdoclint:none</additionalOptions>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>5.1.2</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<useReleaseProfile>false</useReleaseProfile>
<releaseProfiles>release</releaseProfiles>
<goals>deploy</goals>
</configuration>
<version>3.8.1</version>
</plugin>
</plugins>
</build>
@@ -80,91 +156,39 @@
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
<release>8</release>
<testExcludes>
<testExclude>MyGame/Example/MonsterStorageGrpc.java</testExclude>
<testExclude>MyGame/OtherNameSpace/TableBT.java</testExclude>
</testExcludes>
</configuration>
<version>2.22.2</version>
<version>3.8.1</version>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>jdk8</id>
<activation>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.source>8</maven.compiler.source>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.0</version>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
<additionalOptions>-Xdoclint:none</additionalOptions>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>5.1.2</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<useReleaseProfile>false</useReleaseProfile>
<releaseProfiles>release</releaseProfiles>
<goals>deploy</goals>
<testExcludes>
<testExclude>MyGame/Example/MonsterStorageGrpc.java</testExclude>
<testExclude>MyGame/OtherNameSpace/TableBT.java</testExclude>
</testExcludes>
</configuration>
<version>3.8.1</version>
</plugin>
</plugins>
</build>

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_23_5_9() {}
public static void FLATBUFFERS_23_5_26() {}
}
/// @endcond

View File

@@ -21,7 +21,7 @@ import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class Enum extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_9(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_26(); }
public static Enum getRootAsEnum(ByteBuffer _bb) { return getRootAsEnum(_bb, new Enum()); }
public static Enum getRootAsEnum(ByteBuffer _bb, Enum obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }

View File

@@ -21,7 +21,7 @@ import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class EnumVal extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_9(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_26(); }
public static EnumVal getRootAsEnumVal(ByteBuffer _bb) { return getRootAsEnumVal(_bb, new EnumVal()); }
public static EnumVal getRootAsEnumVal(ByteBuffer _bb, EnumVal obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }

View File

@@ -21,7 +21,7 @@ import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class Field extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_9(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_26(); }
public static Field getRootAsField(ByteBuffer _bb) { return getRootAsField(_bb, new Field()); }
public static Field getRootAsField(ByteBuffer _bb, Field obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }

View File

@@ -21,7 +21,7 @@ import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class KeyValue extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_9(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_26(); }
public static KeyValue getRootAsKeyValue(ByteBuffer _bb) { return getRootAsKeyValue(_bb, new KeyValue()); }
public static KeyValue getRootAsKeyValue(ByteBuffer _bb, KeyValue obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }

View File

@@ -21,7 +21,7 @@ import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class Object extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_9(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_26(); }
public static Object getRootAsObject(ByteBuffer _bb) { return getRootAsObject(_bb, new Object()); }
public static Object getRootAsObject(ByteBuffer _bb, Object obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }

View File

@@ -21,7 +21,7 @@ import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class RPCCall extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_9(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_26(); }
public static RPCCall getRootAsRPCCall(ByteBuffer _bb) { return getRootAsRPCCall(_bb, new RPCCall()); }
public static RPCCall getRootAsRPCCall(ByteBuffer _bb, RPCCall obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }

View File

@@ -21,7 +21,7 @@ import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class Schema extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_9(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_26(); }
public static Schema getRootAsSchema(ByteBuffer _bb) { return getRootAsSchema(_bb, new Schema()); }
public static Schema getRootAsSchema(ByteBuffer _bb, Schema obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public static boolean SchemaBufferHasIdentifier(ByteBuffer _bb) { return __has_identifier(_bb, "BFBS"); }

View File

@@ -26,7 +26,7 @@ import java.nio.ByteOrder;
*/
@SuppressWarnings("unused")
public final class SchemaFile extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_9(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_26(); }
public static SchemaFile getRootAsSchemaFile(ByteBuffer _bb) { return getRootAsSchemaFile(_bb, new SchemaFile()); }
public static SchemaFile getRootAsSchemaFile(ByteBuffer _bb, SchemaFile obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }

View File

@@ -21,7 +21,7 @@ import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class Service extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_9(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_26(); }
public static Service getRootAsService(ByteBuffer _bb) { return getRootAsService(_bb, new Service()); }
public static Service getRootAsService(ByteBuffer _bb, Service obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }

View File

@@ -21,7 +21,7 @@ import java.nio.ByteOrder;
@SuppressWarnings("unused")
public final class Type extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_9(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_26(); }
public static Type getRootAsType(ByteBuffer _bb) { return getRootAsType(_bb, new Type()); }
public static Type getRootAsType(ByteBuffer _bb, Type obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }

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_23_5_9() {}
public static void FLATBUFFERS_23_5_26() {}
}
}

View File

@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.1;netstandard2.0;net46</TargetFrameworks>
<Description>A cross-platform memory efficient serialization library</Description>
<PackageVersion>23.5.9</PackageVersion>
<PackageVersion>23.5.26</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": "23.5.9",
"version": "23.5.26",
"description": "Memory Efficient Serialization Library",
"files": [
"js/**/*.js",
@@ -36,11 +36,11 @@
"homepage": "https://google.github.io/flatbuffers/",
"dependencies": {},
"devDependencies": {
"@types/node": "18.15.11",
"@typescript-eslint/eslint-plugin": "^5.57.0",
"@typescript-eslint/parser": "^5.57.0",
"esbuild": "^0.17.14",
"eslint": "^8.37.0",
"@types/node": "18.16.3",
"@typescript-eslint/eslint-plugin": "^5.59.2",
"@typescript-eslint/parser": "^5.59.2",
"esbuild": "^0.17.18",
"eslint": "^8.39.0",
"typescript": "5.0.4"
}
}

302
pnpm-lock.yaml generated
View File

@@ -2,28 +2,28 @@ lockfileVersion: '6.0'
devDependencies:
'@types/node':
specifier: 18.15.11
version: 18.15.11
specifier: 18.16.3
version: 18.16.3
'@typescript-eslint/eslint-plugin':
specifier: ^5.57.0
version: 5.57.0(@typescript-eslint/parser@5.57.0)(eslint@8.37.0)(typescript@5.0.3)
specifier: ^5.59.2
version: 5.59.2(@typescript-eslint/parser@5.59.2)(eslint@8.39.0)(typescript@5.0.4)
'@typescript-eslint/parser':
specifier: ^5.57.0
version: 5.57.0(eslint@8.37.0)(typescript@5.0.3)
specifier: ^5.59.2
version: 5.59.2(eslint@8.39.0)(typescript@5.0.4)
esbuild:
specifier: ^0.17.14
version: 0.17.14
specifier: ^0.17.18
version: 0.17.18
eslint:
specifier: ^8.37.0
version: 8.37.0
specifier: ^8.39.0
version: 8.39.0
typescript:
specifier: 5.0.3
version: 5.0.3
specifier: 5.0.4
version: 5.0.4
packages:
/@esbuild/android-arm64@0.17.14:
resolution: {integrity: sha512-eLOpPO1RvtsP71afiFTvS7tVFShJBCT0txiv/xjFBo5a7R7Gjw7X0IgIaFoLKhqXYAXhahoXm7qAmRXhY4guJg==}
/@esbuild/android-arm64@0.17.18:
resolution: {integrity: sha512-/iq0aK0eeHgSC3z55ucMAHO05OIqmQehiGay8eP5l/5l+iEr4EIbh4/MI8xD9qRFjqzgkc0JkX0LculNC9mXBw==}
engines: {node: '>=12'}
cpu: [arm64]
os: [android]
@@ -31,8 +31,8 @@ packages:
dev: true
optional: true
/@esbuild/android-arm@0.17.14:
resolution: {integrity: sha512-0CnlwnjDU8cks0yJLXfkaU/uoLyRf9VZJs4p1PskBr2AlAHeEsFEwJEo0of/Z3g+ilw5mpyDwThlxzNEIxOE4g==}
/@esbuild/android-arm@0.17.18:
resolution: {integrity: sha512-EmwL+vUBZJ7mhFCs5lA4ZimpUH3WMAoqvOIYhVQwdIgSpHC8ImHdsRyhHAVxpDYUSm0lWvd63z0XH1IlImS2Qw==}
engines: {node: '>=12'}
cpu: [arm]
os: [android]
@@ -40,8 +40,8 @@ packages:
dev: true
optional: true
/@esbuild/android-x64@0.17.14:
resolution: {integrity: sha512-nrfQYWBfLGfSGLvRVlt6xi63B5IbfHm3tZCdu/82zuFPQ7zez4XjmRtF/wIRYbJQ/DsZrxJdEvYFE67avYXyng==}
/@esbuild/android-x64@0.17.18:
resolution: {integrity: sha512-x+0efYNBF3NPW2Xc5bFOSFW7tTXdAcpfEg2nXmxegm4mJuVeS+i109m/7HMiOQ6M12aVGGFlqJX3RhNdYM2lWg==}
engines: {node: '>=12'}
cpu: [x64]
os: [android]
@@ -49,8 +49,8 @@ packages:
dev: true
optional: true
/@esbuild/darwin-arm64@0.17.14:
resolution: {integrity: sha512-eoSjEuDsU1ROwgBH/c+fZzuSyJUVXQTOIN9xuLs9dE/9HbV/A5IqdXHU1p2OfIMwBwOYJ9SFVGGldxeRCUJFyw==}
/@esbuild/darwin-arm64@0.17.18:
resolution: {integrity: sha512-6tY+djEAdF48M1ONWnQb1C+6LiXrKjmqjzPNPWXhu/GzOHTHX2nh8Mo2ZAmBFg0kIodHhciEgUBtcYCAIjGbjQ==}
engines: {node: '>=12'}
cpu: [arm64]
os: [darwin]
@@ -58,8 +58,8 @@ packages:
dev: true
optional: true
/@esbuild/darwin-x64@0.17.14:
resolution: {integrity: sha512-zN0U8RWfrDttdFNkHqFYZtOH8hdi22z0pFm0aIJPsNC4QQZv7je8DWCX5iA4Zx6tRhS0CCc0XC2m7wKsbWEo5g==}
/@esbuild/darwin-x64@0.17.18:
resolution: {integrity: sha512-Qq84ykvLvya3dO49wVC9FFCNUfSrQJLbxhoQk/TE1r6MjHo3sFF2tlJCwMjhkBVq3/ahUisj7+EpRSz0/+8+9A==}
engines: {node: '>=12'}
cpu: [x64]
os: [darwin]
@@ -67,8 +67,8 @@ packages:
dev: true
optional: true
/@esbuild/freebsd-arm64@0.17.14:
resolution: {integrity: sha512-z0VcD4ibeZWVQCW1O7szaLxGsx54gcCnajEJMdYoYjLiq4g1jrP2lMq6pk71dbS5+7op/L2Aod+erw+EUr28/A==}
/@esbuild/freebsd-arm64@0.17.18:
resolution: {integrity: sha512-fw/ZfxfAzuHfaQeMDhbzxp9mc+mHn1Y94VDHFHjGvt2Uxl10mT4CDavHm+/L9KG441t1QdABqkVYwakMUeyLRA==}
engines: {node: '>=12'}
cpu: [arm64]
os: [freebsd]
@@ -76,8 +76,8 @@ packages:
dev: true
optional: true
/@esbuild/freebsd-x64@0.17.14:
resolution: {integrity: sha512-hd9mPcxfTgJlolrPlcXkQk9BMwNBvNBsVaUe5eNUqXut6weDQH8whcNaKNF2RO8NbpT6GY8rHOK2A9y++s+ehw==}
/@esbuild/freebsd-x64@0.17.18:
resolution: {integrity: sha512-FQFbRtTaEi8ZBi/A6kxOC0V0E9B/97vPdYjY9NdawyLd4Qk5VD5g2pbWN2VR1c0xhzcJm74HWpObPszWC+qTew==}
engines: {node: '>=12'}
cpu: [x64]
os: [freebsd]
@@ -85,8 +85,8 @@ packages:
dev: true
optional: true
/@esbuild/linux-arm64@0.17.14:
resolution: {integrity: sha512-FhAMNYOq3Iblcj9i+K0l1Fp/MHt+zBeRu/Qkf0LtrcFu3T45jcwB6A1iMsemQ42vR3GBhjNZJZTaCe3VFPbn9g==}
/@esbuild/linux-arm64@0.17.18:
resolution: {integrity: sha512-R7pZvQZFOY2sxUG8P6A21eq6q+eBv7JPQYIybHVf1XkQYC+lT7nDBdC7wWKTrbvMXKRaGudp/dzZCwL/863mZQ==}
engines: {node: '>=12'}
cpu: [arm64]
os: [linux]
@@ -94,8 +94,8 @@ packages:
dev: true
optional: true
/@esbuild/linux-arm@0.17.14:
resolution: {integrity: sha512-BNTl+wSJ1omsH8s3TkQmIIIQHwvwJrU9u1ggb9XU2KTVM4TmthRIVyxSp2qxROJHhZuW/r8fht46/QE8hU8Qvg==}
/@esbuild/linux-arm@0.17.18:
resolution: {integrity: sha512-jW+UCM40LzHcouIaqv3e/oRs0JM76JfhHjCavPxMUti7VAPh8CaGSlS7cmyrdpzSk7A+8f0hiedHqr/LMnfijg==}
engines: {node: '>=12'}
cpu: [arm]
os: [linux]
@@ -103,8 +103,8 @@ packages:
dev: true
optional: true
/@esbuild/linux-ia32@0.17.14:
resolution: {integrity: sha512-91OK/lQ5y2v7AsmnFT+0EyxdPTNhov3y2CWMdizyMfxSxRqHazXdzgBKtlmkU2KYIc+9ZK3Vwp2KyXogEATYxQ==}
/@esbuild/linux-ia32@0.17.18:
resolution: {integrity: sha512-ygIMc3I7wxgXIxk6j3V00VlABIjq260i967Cp9BNAk5pOOpIXmd1RFQJQX9Io7KRsthDrQYrtcx7QCof4o3ZoQ==}
engines: {node: '>=12'}
cpu: [ia32]
os: [linux]
@@ -112,8 +112,8 @@ packages:
dev: true
optional: true
/@esbuild/linux-loong64@0.17.14:
resolution: {integrity: sha512-vp15H+5NR6hubNgMluqqKza85HcGJgq7t6rMH7O3Y6ApiOWPkvW2AJfNojUQimfTp6OUrACUXfR4hmpcENXoMQ==}
/@esbuild/linux-loong64@0.17.18:
resolution: {integrity: sha512-bvPG+MyFs5ZlwYclCG1D744oHk1Pv7j8psF5TfYx7otCVmcJsEXgFEhQkbhNW8otDHL1a2KDINW20cfCgnzgMQ==}
engines: {node: '>=12'}
cpu: [loong64]
os: [linux]
@@ -121,8 +121,8 @@ packages:
dev: true
optional: true
/@esbuild/linux-mips64el@0.17.14:
resolution: {integrity: sha512-90TOdFV7N+fgi6c2+GO9ochEkmm9kBAKnuD5e08GQMgMINOdOFHuYLPQ91RYVrnWwQ5683sJKuLi9l4SsbJ7Hg==}
/@esbuild/linux-mips64el@0.17.18:
resolution: {integrity: sha512-oVqckATOAGuiUOa6wr8TXaVPSa+6IwVJrGidmNZS1cZVx0HqkTMkqFGD2HIx9H1RvOwFeWYdaYbdY6B89KUMxA==}
engines: {node: '>=12'}
cpu: [mips64el]
os: [linux]
@@ -130,8 +130,8 @@ packages:
dev: true
optional: true
/@esbuild/linux-ppc64@0.17.14:
resolution: {integrity: sha512-NnBGeoqKkTugpBOBZZoktQQ1Yqb7aHKmHxsw43NddPB2YWLAlpb7THZIzsRsTr0Xw3nqiPxbA1H31ZMOG+VVPQ==}
/@esbuild/linux-ppc64@0.17.18:
resolution: {integrity: sha512-3dLlQO+b/LnQNxgH4l9rqa2/IwRJVN9u/bK63FhOPB4xqiRqlQAU0qDU3JJuf0BmaH0yytTBdoSBHrb2jqc5qQ==}
engines: {node: '>=12'}
cpu: [ppc64]
os: [linux]
@@ -139,8 +139,8 @@ packages:
dev: true
optional: true
/@esbuild/linux-riscv64@0.17.14:
resolution: {integrity: sha512-0qdlKScLXA8MGVy21JUKvMzCYWovctuP8KKqhtE5A6IVPq4onxXhSuhwDd2g5sRCzNDlDjitc5sX31BzDoL5Fw==}
/@esbuild/linux-riscv64@0.17.18:
resolution: {integrity: sha512-/x7leOyDPjZV3TcsdfrSI107zItVnsX1q2nho7hbbQoKnmoeUWjs+08rKKt4AUXju7+3aRZSsKrJtaRmsdL1xA==}
engines: {node: '>=12'}
cpu: [riscv64]
os: [linux]
@@ -148,8 +148,8 @@ packages:
dev: true
optional: true
/@esbuild/linux-s390x@0.17.14:
resolution: {integrity: sha512-Hdm2Jo1yaaOro4v3+6/zJk6ygCqIZuSDJHdHaf8nVH/tfOuoEX5Riv03Ka15LmQBYJObUTNS1UdyoMk0WUn9Ww==}
/@esbuild/linux-s390x@0.17.18:
resolution: {integrity: sha512-cX0I8Q9xQkL/6F5zWdYmVf5JSQt+ZfZD2bJudZrWD+4mnUvoZ3TDDXtDX2mUaq6upMFv9FlfIh4Gfun0tbGzuw==}
engines: {node: '>=12'}
cpu: [s390x]
os: [linux]
@@ -157,8 +157,8 @@ packages:
dev: true
optional: true
/@esbuild/linux-x64@0.17.14:
resolution: {integrity: sha512-8KHF17OstlK4DuzeF/KmSgzrTWQrkWj5boluiiq7kvJCiQVzUrmSkaBvcLB2UgHpKENO2i6BthPkmUhNDaJsVw==}
/@esbuild/linux-x64@0.17.18:
resolution: {integrity: sha512-66RmRsPlYy4jFl0vG80GcNRdirx4nVWAzJmXkevgphP1qf4dsLQCpSKGM3DUQCojwU1hnepI63gNZdrr02wHUA==}
engines: {node: '>=12'}
cpu: [x64]
os: [linux]
@@ -166,8 +166,8 @@ packages:
dev: true
optional: true
/@esbuild/netbsd-x64@0.17.14:
resolution: {integrity: sha512-nVwpqvb3yyXztxIT2+VsxJhB5GCgzPdk1n0HHSnchRAcxqKO6ghXwHhJnr0j/B+5FSyEqSxF4q03rbA2fKXtUQ==}
/@esbuild/netbsd-x64@0.17.18:
resolution: {integrity: sha512-95IRY7mI2yrkLlTLb1gpDxdC5WLC5mZDi+kA9dmM5XAGxCME0F8i4bYH4jZreaJ6lIZ0B8hTrweqG1fUyW7jbg==}
engines: {node: '>=12'}
cpu: [x64]
os: [netbsd]
@@ -175,8 +175,8 @@ packages:
dev: true
optional: true
/@esbuild/openbsd-x64@0.17.14:
resolution: {integrity: sha512-1RZ7uQQ9zcy/GSAJL1xPdN7NDdOOtNEGiJalg/MOzeakZeTrgH/DoCkbq7TaPDiPhWqnDF+4bnydxRqQD7il6g==}
/@esbuild/openbsd-x64@0.17.18:
resolution: {integrity: sha512-WevVOgcng+8hSZ4Q3BKL3n1xTv5H6Nb53cBrtzzEjDbbnOmucEVcZeGCsCOi9bAOcDYEeBZbD2SJNBxlfP3qiA==}
engines: {node: '>=12'}
cpu: [x64]
os: [openbsd]
@@ -184,8 +184,8 @@ packages:
dev: true
optional: true
/@esbuild/sunos-x64@0.17.14:
resolution: {integrity: sha512-nqMjDsFwv7vp7msrwWRysnM38Sd44PKmW8EzV01YzDBTcTWUpczQg6mGao9VLicXSgW/iookNK6AxeogNVNDZA==}
/@esbuild/sunos-x64@0.17.18:
resolution: {integrity: sha512-Rzf4QfQagnwhQXVBS3BYUlxmEbcV7MY+BH5vfDZekU5eYpcffHSyjU8T0xucKVuOcdCsMo+Ur5wmgQJH2GfNrg==}
engines: {node: '>=12'}
cpu: [x64]
os: [sunos]
@@ -193,8 +193,8 @@ packages:
dev: true
optional: true
/@esbuild/win32-arm64@0.17.14:
resolution: {integrity: sha512-xrD0mccTKRBBIotrITV7WVQAwNJ5+1va6L0H9zN92v2yEdjfAN7864cUaZwJS7JPEs53bDTzKFbfqVlG2HhyKQ==}
/@esbuild/win32-arm64@0.17.18:
resolution: {integrity: sha512-Kb3Ko/KKaWhjeAm2YoT/cNZaHaD1Yk/pa3FTsmqo9uFh1D1Rfco7BBLIPdDOozrObj2sahslFuAQGvWbgWldAg==}
engines: {node: '>=12'}
cpu: [arm64]
os: [win32]
@@ -202,8 +202,8 @@ packages:
dev: true
optional: true
/@esbuild/win32-ia32@0.17.14:
resolution: {integrity: sha512-nXpkz9bbJrLLyUTYtRotSS3t5b+FOuljg8LgLdINWFs3FfqZMtbnBCZFUmBzQPyxqU87F8Av+3Nco/M3hEcu1w==}
/@esbuild/win32-ia32@0.17.18:
resolution: {integrity: sha512-0/xUMIdkVHwkvxfbd5+lfG7mHOf2FRrxNbPiKWg9C4fFrB8H0guClmaM3BFiRUYrznVoyxTIyC/Ou2B7QQSwmw==}
engines: {node: '>=12'}
cpu: [ia32]
os: [win32]
@@ -211,8 +211,8 @@ packages:
dev: true
optional: true
/@esbuild/win32-x64@0.17.14:
resolution: {integrity: sha512-gPQmsi2DKTaEgG14hc3CHXHp62k8g6qr0Pas+I4lUxRMugGSATh/Bi8Dgusoz9IQ0IfdrvLpco6kujEIBoaogA==}
/@esbuild/win32-x64@0.17.18:
resolution: {integrity: sha512-qU25Ma1I3NqTSHJUOKi9sAH1/Mzuvlke0ioMJRthLXKm7JiSKVwFghlGbDLOO2sARECGhja4xYfRAZNPAkooYg==}
engines: {node: '>=12'}
cpu: [x64]
os: [win32]
@@ -220,18 +220,18 @@ packages:
dev: true
optional: true
/@eslint-community/eslint-utils@4.4.0(eslint@8.37.0):
/@eslint-community/eslint-utils@4.4.0(eslint@8.39.0):
resolution: {integrity: sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
eslint: ^6.0.0 || ^7.0.0 || >=8.0.0
dependencies:
eslint: 8.37.0
eslint: 8.39.0
eslint-visitor-keys: 3.4.0
dev: true
/@eslint-community/regexpp@4.5.0:
resolution: {integrity: sha512-vITaYzIcNmjn5tF5uxcZ/ft7/RXGrMUIS9HalWckEOF6ESiwXKoMzAQf2UW0aVd6rnOeExTJVd5hmWXucBKGXQ==}
/@eslint-community/regexpp@4.5.1:
resolution: {integrity: sha512-Z5ba73P98O1KUYCCJTUeVpja9RcGoMdncZ6T49FCUl2lN38JtCJ+3WgIDBv0AuY4WChU5PmtJmOCTlN6FZTFKQ==}
engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0}
dev: true
@@ -252,8 +252,8 @@ packages:
- supports-color
dev: true
/@eslint/js@8.37.0:
resolution: {integrity: sha512-x5vzdtOOGgFVDCUs81QRB2+liax8rFg3+7hqM+QhBG0/G3F1ZsoYl97UrqgHgQ9KKT7G6c4V+aTUCgu/n22v1A==}
/@eslint/js@8.39.0:
resolution: {integrity: sha512-kf9RB0Fg7NZfap83B3QOqOGg9QmD9yBudqQXzzOtn3i4y7ZUXe5ONeW34Gwi+TxhH4mvj72R1Zc300KUMa9Bng==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
dev: true
@@ -302,16 +302,16 @@ packages:
resolution: {integrity: sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==}
dev: true
/@types/node@18.15.11:
resolution: {integrity: sha512-E5Kwq2n4SbMzQOn6wnmBjuK9ouqlURrcZDVfbo9ftDDTFt3nk7ZKK4GMOzoYgnpQJKcxwQw+lGaBvvlMo0qN/Q==}
/@types/node@18.16.3:
resolution: {integrity: sha512-OPs5WnnT1xkCBiuQrZA4+YAV4HEJejmHneyraIaxsbev5yCEr6KMwINNFP9wQeFIw8FWcoTqF3vQsa5CDaI+8Q==}
dev: true
/@types/semver@7.3.13:
resolution: {integrity: sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==}
dev: true
/@typescript-eslint/eslint-plugin@5.57.0(@typescript-eslint/parser@5.57.0)(eslint@8.37.0)(typescript@5.0.3):
resolution: {integrity: sha512-itag0qpN6q2UMM6Xgk6xoHa0D0/P+M17THnr4SVgqn9Rgam5k/He33MA7/D7QoJcdMxHFyX7U9imaBonAX/6qA==}
/@typescript-eslint/eslint-plugin@5.59.2(@typescript-eslint/parser@5.59.2)(eslint@8.39.0)(typescript@5.0.4):
resolution: {integrity: sha512-yVrXupeHjRxLDcPKL10sGQ/QlVrA8J5IYOEWVqk0lJaSZP7X5DfnP7Ns3cc74/blmbipQ1htFNVGsHX6wsYm0A==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
'@typescript-eslint/parser': ^5.0.0
@@ -321,25 +321,25 @@ packages:
typescript:
optional: true
dependencies:
'@eslint-community/regexpp': 4.5.0
'@typescript-eslint/parser': 5.57.0(eslint@8.37.0)(typescript@5.0.3)
'@typescript-eslint/scope-manager': 5.57.0
'@typescript-eslint/type-utils': 5.57.0(eslint@8.37.0)(typescript@5.0.3)
'@typescript-eslint/utils': 5.57.0(eslint@8.37.0)(typescript@5.0.3)
'@eslint-community/regexpp': 4.5.1
'@typescript-eslint/parser': 5.59.2(eslint@8.39.0)(typescript@5.0.4)
'@typescript-eslint/scope-manager': 5.59.2
'@typescript-eslint/type-utils': 5.59.2(eslint@8.39.0)(typescript@5.0.4)
'@typescript-eslint/utils': 5.59.2(eslint@8.39.0)(typescript@5.0.4)
debug: 4.3.4
eslint: 8.37.0
eslint: 8.39.0
grapheme-splitter: 1.0.4
ignore: 5.2.4
natural-compare-lite: 1.4.0
semver: 7.3.8
tsutils: 3.21.0(typescript@5.0.3)
typescript: 5.0.3
semver: 7.5.0
tsutils: 3.21.0(typescript@5.0.4)
typescript: 5.0.4
transitivePeerDependencies:
- supports-color
dev: true
/@typescript-eslint/parser@5.57.0(eslint@8.37.0)(typescript@5.0.3):
resolution: {integrity: sha512-orrduvpWYkgLCyAdNtR1QIWovcNZlEm6yL8nwH/eTxWLd8gsP+25pdLHYzL2QdkqrieaDwLpytHqycncv0woUQ==}
/@typescript-eslint/parser@5.59.2(eslint@8.39.0)(typescript@5.0.4):
resolution: {integrity: sha512-uq0sKyw6ao1iFOZZGk9F8Nro/8+gfB5ezl1cA06SrqbgJAt0SRoFhb9pXaHvkrxUpZaoLxt8KlovHNk8Gp6/HQ==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
eslint: ^6.0.0 || ^7.0.0 || ^8.0.0
@@ -348,26 +348,26 @@ packages:
typescript:
optional: true
dependencies:
'@typescript-eslint/scope-manager': 5.57.0
'@typescript-eslint/types': 5.57.0
'@typescript-eslint/typescript-estree': 5.57.0(typescript@5.0.3)
'@typescript-eslint/scope-manager': 5.59.2
'@typescript-eslint/types': 5.59.2
'@typescript-eslint/typescript-estree': 5.59.2(typescript@5.0.4)
debug: 4.3.4
eslint: 8.37.0
typescript: 5.0.3
eslint: 8.39.0
typescript: 5.0.4
transitivePeerDependencies:
- supports-color
dev: true
/@typescript-eslint/scope-manager@5.57.0:
resolution: {integrity: sha512-NANBNOQvllPlizl9LatX8+MHi7bx7WGIWYjPHDmQe5Si/0YEYfxSljJpoTyTWFTgRy3X8gLYSE4xQ2U+aCozSw==}
/@typescript-eslint/scope-manager@5.59.2:
resolution: {integrity: sha512-dB1v7ROySwQWKqQ8rEWcdbTsFjh2G0vn8KUyvTXdPoyzSL6lLGkiXEV5CvpJsEe9xIdKV+8Zqb7wif2issoOFA==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
dependencies:
'@typescript-eslint/types': 5.57.0
'@typescript-eslint/visitor-keys': 5.57.0
'@typescript-eslint/types': 5.59.2
'@typescript-eslint/visitor-keys': 5.59.2
dev: true
/@typescript-eslint/type-utils@5.57.0(eslint@8.37.0)(typescript@5.0.3):
resolution: {integrity: sha512-kxXoq9zOTbvqzLbdNKy1yFrxLC6GDJFE2Yuo3KqSwTmDOFjUGeWSakgoXT864WcK5/NAJkkONCiKb1ddsqhLXQ==}
/@typescript-eslint/type-utils@5.59.2(eslint@8.39.0)(typescript@5.0.4):
resolution: {integrity: sha512-b1LS2phBOsEy/T381bxkkywfQXkV1dWda/z0PhnIy3bC5+rQWQDS7fk9CSpcXBccPY27Z6vBEuaPBCKCgYezyQ==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
eslint: '*'
@@ -376,23 +376,23 @@ packages:
typescript:
optional: true
dependencies:
'@typescript-eslint/typescript-estree': 5.57.0(typescript@5.0.3)
'@typescript-eslint/utils': 5.57.0(eslint@8.37.0)(typescript@5.0.3)
'@typescript-eslint/typescript-estree': 5.59.2(typescript@5.0.4)
'@typescript-eslint/utils': 5.59.2(eslint@8.39.0)(typescript@5.0.4)
debug: 4.3.4
eslint: 8.37.0
tsutils: 3.21.0(typescript@5.0.3)
typescript: 5.0.3
eslint: 8.39.0
tsutils: 3.21.0(typescript@5.0.4)
typescript: 5.0.4
transitivePeerDependencies:
- supports-color
dev: true
/@typescript-eslint/types@5.57.0:
resolution: {integrity: sha512-mxsod+aZRSyLT+jiqHw1KK6xrANm19/+VFALVFP5qa/aiJnlP38qpyaTd0fEKhWvQk6YeNZ5LGwI1pDpBRBhtQ==}
/@typescript-eslint/types@5.59.2:
resolution: {integrity: sha512-LbJ/HqoVs2XTGq5shkiKaNTuVv5tTejdHgfdjqRUGdYhjW1crm/M7og2jhVskMt8/4wS3T1+PfFvL1K3wqYj4w==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
dev: true
/@typescript-eslint/typescript-estree@5.57.0(typescript@5.0.3):
resolution: {integrity: sha512-LTzQ23TV82KpO8HPnWuxM2V7ieXW8O142I7hQTxWIHDcCEIjtkat6H96PFkYBQqGFLW/G/eVVOB9Z8rcvdY/Vw==}
/@typescript-eslint/typescript-estree@5.59.2(typescript@5.0.4):
resolution: {integrity: sha512-+j4SmbwVmZsQ9jEyBMgpuBD0rKwi9RxRpjX71Brr73RsYnEr3Lt5QZ624Bxphp8HUkSKfqGnPJp1kA5nl0Sh7Q==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
typescript: '*'
@@ -400,43 +400,43 @@ packages:
typescript:
optional: true
dependencies:
'@typescript-eslint/types': 5.57.0
'@typescript-eslint/visitor-keys': 5.57.0
'@typescript-eslint/types': 5.59.2
'@typescript-eslint/visitor-keys': 5.59.2
debug: 4.3.4
globby: 11.1.0
is-glob: 4.0.3
semver: 7.3.8
tsutils: 3.21.0(typescript@5.0.3)
typescript: 5.0.3
semver: 7.5.0
tsutils: 3.21.0(typescript@5.0.4)
typescript: 5.0.4
transitivePeerDependencies:
- supports-color
dev: true
/@typescript-eslint/utils@5.57.0(eslint@8.37.0)(typescript@5.0.3):
resolution: {integrity: sha512-ps/4WohXV7C+LTSgAL5CApxvxbMkl9B9AUZRtnEFonpIxZDIT7wC1xfvuJONMidrkB9scs4zhtRyIwHh4+18kw==}
/@typescript-eslint/utils@5.59.2(eslint@8.39.0)(typescript@5.0.4):
resolution: {integrity: sha512-kSuF6/77TZzyGPhGO4uVp+f0SBoYxCDf+lW3GKhtKru/L8k/Hd7NFQxyWUeY7Z/KGB2C6Fe3yf2vVi4V9TsCSQ==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
eslint: ^6.0.0 || ^7.0.0 || ^8.0.0
dependencies:
'@eslint-community/eslint-utils': 4.4.0(eslint@8.37.0)
'@eslint-community/eslint-utils': 4.4.0(eslint@8.39.0)
'@types/json-schema': 7.0.11
'@types/semver': 7.3.13
'@typescript-eslint/scope-manager': 5.57.0
'@typescript-eslint/types': 5.57.0
'@typescript-eslint/typescript-estree': 5.57.0(typescript@5.0.3)
eslint: 8.37.0
'@typescript-eslint/scope-manager': 5.59.2
'@typescript-eslint/types': 5.59.2
'@typescript-eslint/typescript-estree': 5.59.2(typescript@5.0.4)
eslint: 8.39.0
eslint-scope: 5.1.1
semver: 7.3.8
semver: 7.5.0
transitivePeerDependencies:
- supports-color
- typescript
dev: true
/@typescript-eslint/visitor-keys@5.57.0:
resolution: {integrity: sha512-ery2g3k0hv5BLiKpPuwYt9KBkAp2ugT6VvyShXdLOkax895EC55sP0Tx5L0fZaQueiK3fBLvHVvEl3jFS5ia+g==}
/@typescript-eslint/visitor-keys@5.59.2:
resolution: {integrity: sha512-EEpsO8m3RASrKAHI9jpavNv9NlEUebV4qmF1OWxSTtKSFBpC1NCmWazDQHFivRf0O1DV11BA645yrLEVQ0/Lig==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
dependencies:
'@typescript-eslint/types': 5.57.0
'@typescript-eslint/types': 5.59.2
eslint-visitor-keys: 3.4.0
dev: true
@@ -569,34 +569,34 @@ packages:
esutils: 2.0.3
dev: true
/esbuild@0.17.14:
resolution: {integrity: sha512-vOO5XhmVj/1XQR9NQ1UPq6qvMYL7QFJU57J5fKBKBKxp17uDt5PgxFDb4A2nEiXhr1qQs4x0F5+66hVVw4ruNw==}
/esbuild@0.17.18:
resolution: {integrity: sha512-z1lix43jBs6UKjcZVKOw2xx69ffE2aG0PygLL5qJ9OS/gy0Ewd1gW/PUQIOIQGXBHWNywSc0floSKoMFF8aK2w==}
engines: {node: '>=12'}
hasBin: true
requiresBuild: true
optionalDependencies:
'@esbuild/android-arm': 0.17.14
'@esbuild/android-arm64': 0.17.14
'@esbuild/android-x64': 0.17.14
'@esbuild/darwin-arm64': 0.17.14
'@esbuild/darwin-x64': 0.17.14
'@esbuild/freebsd-arm64': 0.17.14
'@esbuild/freebsd-x64': 0.17.14
'@esbuild/linux-arm': 0.17.14
'@esbuild/linux-arm64': 0.17.14
'@esbuild/linux-ia32': 0.17.14
'@esbuild/linux-loong64': 0.17.14
'@esbuild/linux-mips64el': 0.17.14
'@esbuild/linux-ppc64': 0.17.14
'@esbuild/linux-riscv64': 0.17.14
'@esbuild/linux-s390x': 0.17.14
'@esbuild/linux-x64': 0.17.14
'@esbuild/netbsd-x64': 0.17.14
'@esbuild/openbsd-x64': 0.17.14
'@esbuild/sunos-x64': 0.17.14
'@esbuild/win32-arm64': 0.17.14
'@esbuild/win32-ia32': 0.17.14
'@esbuild/win32-x64': 0.17.14
'@esbuild/android-arm': 0.17.18
'@esbuild/android-arm64': 0.17.18
'@esbuild/android-x64': 0.17.18
'@esbuild/darwin-arm64': 0.17.18
'@esbuild/darwin-x64': 0.17.18
'@esbuild/freebsd-arm64': 0.17.18
'@esbuild/freebsd-x64': 0.17.18
'@esbuild/linux-arm': 0.17.18
'@esbuild/linux-arm64': 0.17.18
'@esbuild/linux-ia32': 0.17.18
'@esbuild/linux-loong64': 0.17.18
'@esbuild/linux-mips64el': 0.17.18
'@esbuild/linux-ppc64': 0.17.18
'@esbuild/linux-riscv64': 0.17.18
'@esbuild/linux-s390x': 0.17.18
'@esbuild/linux-x64': 0.17.18
'@esbuild/netbsd-x64': 0.17.18
'@esbuild/openbsd-x64': 0.17.18
'@esbuild/sunos-x64': 0.17.18
'@esbuild/win32-arm64': 0.17.18
'@esbuild/win32-ia32': 0.17.18
'@esbuild/win32-x64': 0.17.18
dev: true
/escape-string-regexp@4.0.0:
@@ -612,8 +612,8 @@ packages:
estraverse: 4.3.0
dev: true
/eslint-scope@7.1.1:
resolution: {integrity: sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==}
/eslint-scope@7.2.0:
resolution: {integrity: sha512-DYj5deGlHBfMt15J7rdtyKNq/Nqlv5KfU4iodrQ019XESsRnwXH9KAE0y3cwtUHDo2ob7CypAnCqefh6vioWRw==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
dependencies:
esrecurse: 4.3.0
@@ -625,15 +625,15 @@ packages:
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
dev: true
/eslint@8.37.0:
resolution: {integrity: sha512-NU3Ps9nI05GUoVMxcZx1J8CNR6xOvUT4jAUMH5+z8lpp3aEdPVCImKw6PWG4PY+Vfkpr+jvMpxs/qoE7wq0sPw==}
/eslint@8.39.0:
resolution: {integrity: sha512-mwiok6cy7KTW7rBpo05k6+p4YVZByLNjAZ/ACB9DRCu4YDRwjXI01tWHp6KAUWelsBetTxKK/2sHB0vdS8Z2Og==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
hasBin: true
dependencies:
'@eslint-community/eslint-utils': 4.4.0(eslint@8.37.0)
'@eslint-community/regexpp': 4.5.0
'@eslint-community/eslint-utils': 4.4.0(eslint@8.39.0)
'@eslint-community/regexpp': 4.5.1
'@eslint/eslintrc': 2.0.2
'@eslint/js': 8.37.0
'@eslint/js': 8.39.0
'@humanwhocodes/config-array': 0.11.8
'@humanwhocodes/module-importer': 1.0.1
'@nodelib/fs.walk': 1.2.8
@@ -643,7 +643,7 @@ packages:
debug: 4.3.4
doctrine: 3.0.0
escape-string-regexp: 4.0.0
eslint-scope: 7.1.1
eslint-scope: 7.2.0
eslint-visitor-keys: 3.4.0
espree: 9.5.1
esquery: 1.5.0
@@ -1064,8 +1064,8 @@ packages:
queue-microtask: 1.2.3
dev: true
/semver@7.3.8:
resolution: {integrity: sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==}
/semver@7.5.0:
resolution: {integrity: sha512-+XC0AD/R7Q2mPSRuy2Id0+CGTZ98+8f+KvwirxOKIEyid+XSx6HbC63p+O4IndTHuX5Z+JxQ0TghCkO5Cg/2HA==}
engines: {node: '>=10'}
hasBin: true
dependencies:
@@ -1123,14 +1123,14 @@ packages:
resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==}
dev: true
/tsutils@3.21.0(typescript@5.0.3):
/tsutils@3.21.0(typescript@5.0.4):
resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==}
engines: {node: '>= 6'}
peerDependencies:
typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta'
dependencies:
tslib: 1.14.1
typescript: 5.0.3
typescript: 5.0.4
dev: true
/type-check@0.4.0:
@@ -1145,8 +1145,8 @@ packages:
engines: {node: '>=10'}
dev: true
/typescript@5.0.3:
resolution: {integrity: sha512-xv8mOEDnigb/tN9PSMTwSEqAnUvkoXMQlicOb0IUVDBSQCgBSaAAROUZYy2IcUy5qU6XajK5jjjO7TMWqBTKZA==}
/typescript@5.0.4:
resolution: {integrity: sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==}
engines: {node: '>=12.20'}
hasBin: true
dev: true

View File

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

View File

@@ -42,7 +42,7 @@ class Enum(object):
x = self._tab.Vector(o)
x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
x = self._tab.Indirect(x)
from .reflection.EnumVal import EnumVal
from reflection.EnumVal import EnumVal
obj = EnumVal()
obj.Init(self._tab.Bytes, x)
return obj
@@ -72,7 +72,7 @@ class Enum(object):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
if o != 0:
x = self._tab.Indirect(o + self._tab.Pos)
from .reflection.Type import Type
from reflection.Type import Type
obj = Type()
obj.Init(self._tab.Bytes, x)
return obj
@@ -85,7 +85,7 @@ class Enum(object):
x = self._tab.Vector(o)
x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
x = self._tab.Indirect(x)
from .reflection.KeyValue import KeyValue
from reflection.KeyValue import KeyValue
obj = KeyValue()
obj.Init(self._tab.Bytes, x)
return obj
@@ -140,13 +140,13 @@ def Start(builder):
def EnumAddName(builder, name):
builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0)
def AddName(builder: flatbuffers.Builder, name: int):
def AddName(builder, name):
EnumAddName(builder, name)
def EnumAddValues(builder, values):
builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(values), 0)
def AddValues(builder: flatbuffers.Builder, values: int):
def AddValues(builder, values):
EnumAddValues(builder, values)
def EnumStartValuesVector(builder, numElems):
@@ -158,19 +158,19 @@ def StartValuesVector(builder, numElems: int) -> int:
def EnumAddIsUnion(builder, isUnion):
builder.PrependBoolSlot(2, isUnion, 0)
def AddIsUnion(builder: flatbuffers.Builder, isUnion: bool):
def AddIsUnion(builder, isUnion):
EnumAddIsUnion(builder, isUnion)
def EnumAddUnderlyingType(builder, underlyingType):
builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(underlyingType), 0)
def AddUnderlyingType(builder: flatbuffers.Builder, underlyingType: int):
def AddUnderlyingType(builder, underlyingType):
EnumAddUnderlyingType(builder, underlyingType)
def EnumAddAttributes(builder, attributes):
builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(attributes), 0)
def AddAttributes(builder: flatbuffers.Builder, attributes: int):
def AddAttributes(builder, attributes):
EnumAddAttributes(builder, attributes)
def EnumStartAttributesVector(builder, numElems):
@@ -182,7 +182,7 @@ def StartAttributesVector(builder, numElems: int) -> int:
def EnumAddDocumentation(builder, documentation):
builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(documentation), 0)
def AddDocumentation(builder: flatbuffers.Builder, documentation: int):
def AddDocumentation(builder, documentation):
EnumAddDocumentation(builder, documentation)
def EnumStartDocumentationVector(builder, numElems):
@@ -194,7 +194,7 @@ def StartDocumentationVector(builder, numElems: int) -> int:
def EnumAddDeclarationFile(builder, declarationFile):
builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(declarationFile), 0)
def AddDeclarationFile(builder: flatbuffers.Builder, declarationFile: int):
def AddDeclarationFile(builder, declarationFile):
EnumAddDeclarationFile(builder, declarationFile)
def EnumEnd(builder):

View File

@@ -47,7 +47,7 @@ class EnumVal(object):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
if o != 0:
x = self._tab.Indirect(o + self._tab.Pos)
from .reflection.Type import Type
from reflection.Type import Type
obj = Type()
obj.Init(self._tab.Bytes, x)
return obj
@@ -80,7 +80,7 @@ class EnumVal(object):
x = self._tab.Vector(o)
x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
x = self._tab.Indirect(x)
from .reflection.KeyValue import KeyValue
from reflection.KeyValue import KeyValue
obj = KeyValue()
obj.Init(self._tab.Bytes, x)
return obj
@@ -107,25 +107,25 @@ def Start(builder):
def EnumValAddName(builder, name):
builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0)
def AddName(builder: flatbuffers.Builder, name: int):
def AddName(builder, name):
EnumValAddName(builder, name)
def EnumValAddValue(builder, value):
builder.PrependInt64Slot(1, value, 0)
def AddValue(builder: flatbuffers.Builder, value: int):
def AddValue(builder, value):
EnumValAddValue(builder, value)
def EnumValAddUnionType(builder, unionType):
builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(unionType), 0)
def AddUnionType(builder: flatbuffers.Builder, unionType: int):
def AddUnionType(builder, unionType):
EnumValAddUnionType(builder, unionType)
def EnumValAddDocumentation(builder, documentation):
builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(documentation), 0)
def AddDocumentation(builder: flatbuffers.Builder, documentation: int):
def AddDocumentation(builder, documentation):
EnumValAddDocumentation(builder, documentation)
def EnumValStartDocumentationVector(builder, numElems):
@@ -137,7 +137,7 @@ def StartDocumentationVector(builder, numElems: int) -> int:
def EnumValAddAttributes(builder, attributes):
builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(attributes), 0)
def AddAttributes(builder: flatbuffers.Builder, attributes: int):
def AddAttributes(builder, attributes):
EnumValAddAttributes(builder, attributes)
def EnumValStartAttributesVector(builder, numElems):

View File

@@ -40,7 +40,7 @@ class Field(object):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
if o != 0:
x = self._tab.Indirect(o + self._tab.Pos)
from .reflection.Type import Type
from reflection.Type import Type
obj = Type()
obj.Init(self._tab.Bytes, x)
return obj
@@ -102,7 +102,7 @@ class Field(object):
x = self._tab.Vector(o)
x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
x = self._tab.Indirect(x)
from .reflection.KeyValue import KeyValue
from reflection.KeyValue import KeyValue
obj = KeyValue()
obj.Init(self._tab.Bytes, x)
return obj
@@ -172,61 +172,61 @@ def Start(builder):
def FieldAddName(builder, name):
builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0)
def AddName(builder: flatbuffers.Builder, name: int):
def AddName(builder, name):
FieldAddName(builder, name)
def FieldAddType(builder, type):
builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(type), 0)
def AddType(builder: flatbuffers.Builder, type: int):
def AddType(builder, type):
FieldAddType(builder, type)
def FieldAddId(builder, id):
builder.PrependUint16Slot(2, id, 0)
def AddId(builder: flatbuffers.Builder, id: int):
def AddId(builder, id):
FieldAddId(builder, id)
def FieldAddOffset(builder, offset):
builder.PrependUint16Slot(3, offset, 0)
def AddOffset(builder: flatbuffers.Builder, offset: int):
def AddOffset(builder, offset):
FieldAddOffset(builder, offset)
def FieldAddDefaultInteger(builder, defaultInteger):
builder.PrependInt64Slot(4, defaultInteger, 0)
def AddDefaultInteger(builder: flatbuffers.Builder, defaultInteger: int):
def AddDefaultInteger(builder, defaultInteger):
FieldAddDefaultInteger(builder, defaultInteger)
def FieldAddDefaultReal(builder, defaultReal):
builder.PrependFloat64Slot(5, defaultReal, 0.0)
def AddDefaultReal(builder: flatbuffers.Builder, defaultReal: float):
def AddDefaultReal(builder, defaultReal):
FieldAddDefaultReal(builder, defaultReal)
def FieldAddDeprecated(builder, deprecated):
builder.PrependBoolSlot(6, deprecated, 0)
def AddDeprecated(builder: flatbuffers.Builder, deprecated: bool):
def AddDeprecated(builder, deprecated):
FieldAddDeprecated(builder, deprecated)
def FieldAddRequired(builder, required):
builder.PrependBoolSlot(7, required, 0)
def AddRequired(builder: flatbuffers.Builder, required: bool):
def AddRequired(builder, required):
FieldAddRequired(builder, required)
def FieldAddKey(builder, key):
builder.PrependBoolSlot(8, key, 0)
def AddKey(builder: flatbuffers.Builder, key: bool):
def AddKey(builder, key):
FieldAddKey(builder, key)
def FieldAddAttributes(builder, attributes):
builder.PrependUOffsetTRelativeSlot(9, flatbuffers.number_types.UOffsetTFlags.py_type(attributes), 0)
def AddAttributes(builder: flatbuffers.Builder, attributes: int):
def AddAttributes(builder, attributes):
FieldAddAttributes(builder, attributes)
def FieldStartAttributesVector(builder, numElems):
@@ -238,7 +238,7 @@ def StartAttributesVector(builder, numElems: int) -> int:
def FieldAddDocumentation(builder, documentation):
builder.PrependUOffsetTRelativeSlot(10, flatbuffers.number_types.UOffsetTFlags.py_type(documentation), 0)
def AddDocumentation(builder: flatbuffers.Builder, documentation: int):
def AddDocumentation(builder, documentation):
FieldAddDocumentation(builder, documentation)
def FieldStartDocumentationVector(builder, numElems):
@@ -250,19 +250,19 @@ def StartDocumentationVector(builder, numElems: int) -> int:
def FieldAddOptional(builder, optional):
builder.PrependBoolSlot(11, optional, 0)
def AddOptional(builder: flatbuffers.Builder, optional: bool):
def AddOptional(builder, optional):
FieldAddOptional(builder, optional)
def FieldAddPadding(builder, padding):
builder.PrependUint16Slot(12, padding, 0)
def AddPadding(builder: flatbuffers.Builder, padding: int):
def AddPadding(builder, padding):
FieldAddPadding(builder, padding)
def FieldAddOffset64(builder, offset64):
builder.PrependBoolSlot(13, offset64, 0)
def AddOffset64(builder: flatbuffers.Builder, offset64: bool):
def AddOffset64(builder, offset64):
FieldAddOffset64(builder, offset64)
def FieldEnd(builder):

View File

@@ -51,13 +51,13 @@ def Start(builder):
def KeyValueAddKey(builder, key):
builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(key), 0)
def AddKey(builder: flatbuffers.Builder, key: int):
def AddKey(builder, key):
KeyValueAddKey(builder, key)
def KeyValueAddValue(builder, value):
builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(value), 0)
def AddValue(builder: flatbuffers.Builder, value: int):
def AddValue(builder, value):
KeyValueAddValue(builder, value)
def KeyValueEnd(builder):

View File

@@ -42,7 +42,7 @@ class Object(object):
x = self._tab.Vector(o)
x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
x = self._tab.Indirect(x)
from .reflection.Field import Field
from reflection.Field import Field
obj = Field()
obj.Init(self._tab.Bytes, x)
return obj
@@ -88,7 +88,7 @@ class Object(object):
x = self._tab.Vector(o)
x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
x = self._tab.Indirect(x)
from .reflection.KeyValue import KeyValue
from reflection.KeyValue import KeyValue
obj = KeyValue()
obj.Init(self._tab.Bytes, x)
return obj
@@ -143,13 +143,13 @@ def Start(builder):
def ObjectAddName(builder, name):
builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0)
def AddName(builder: flatbuffers.Builder, name: int):
def AddName(builder, name):
ObjectAddName(builder, name)
def ObjectAddFields(builder, fields):
builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(fields), 0)
def AddFields(builder: flatbuffers.Builder, fields: int):
def AddFields(builder, fields):
ObjectAddFields(builder, fields)
def ObjectStartFieldsVector(builder, numElems):
@@ -161,25 +161,25 @@ def StartFieldsVector(builder, numElems: int) -> int:
def ObjectAddIsStruct(builder, isStruct):
builder.PrependBoolSlot(2, isStruct, 0)
def AddIsStruct(builder: flatbuffers.Builder, isStruct: bool):
def AddIsStruct(builder, isStruct):
ObjectAddIsStruct(builder, isStruct)
def ObjectAddMinalign(builder, minalign):
builder.PrependInt32Slot(3, minalign, 0)
def AddMinalign(builder: flatbuffers.Builder, minalign: int):
def AddMinalign(builder, minalign):
ObjectAddMinalign(builder, minalign)
def ObjectAddBytesize(builder, bytesize):
builder.PrependInt32Slot(4, bytesize, 0)
def AddBytesize(builder: flatbuffers.Builder, bytesize: int):
def AddBytesize(builder, bytesize):
ObjectAddBytesize(builder, bytesize)
def ObjectAddAttributes(builder, attributes):
builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(attributes), 0)
def AddAttributes(builder: flatbuffers.Builder, attributes: int):
def AddAttributes(builder, attributes):
ObjectAddAttributes(builder, attributes)
def ObjectStartAttributesVector(builder, numElems):
@@ -191,7 +191,7 @@ def StartAttributesVector(builder, numElems: int) -> int:
def ObjectAddDocumentation(builder, documentation):
builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(documentation), 0)
def AddDocumentation(builder: flatbuffers.Builder, documentation: int):
def AddDocumentation(builder, documentation):
ObjectAddDocumentation(builder, documentation)
def ObjectStartDocumentationVector(builder, numElems):
@@ -203,7 +203,7 @@ def StartDocumentationVector(builder, numElems: int) -> int:
def ObjectAddDeclarationFile(builder, declarationFile):
builder.PrependUOffsetTRelativeSlot(7, flatbuffers.number_types.UOffsetTFlags.py_type(declarationFile), 0)
def AddDeclarationFile(builder: flatbuffers.Builder, declarationFile: int):
def AddDeclarationFile(builder, declarationFile):
ObjectAddDeclarationFile(builder, declarationFile)
def ObjectEnd(builder):

View File

@@ -40,7 +40,7 @@ class RPCCall(object):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
if o != 0:
x = self._tab.Indirect(o + self._tab.Pos)
from .reflection.Object import Object
from reflection.Object import Object
obj = Object()
obj.Init(self._tab.Bytes, x)
return obj
@@ -51,7 +51,7 @@ class RPCCall(object):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
if o != 0:
x = self._tab.Indirect(o + self._tab.Pos)
from .reflection.Object import Object
from reflection.Object import Object
obj = Object()
obj.Init(self._tab.Bytes, x)
return obj
@@ -64,7 +64,7 @@ class RPCCall(object):
x = self._tab.Vector(o)
x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
x = self._tab.Indirect(x)
from .reflection.KeyValue import KeyValue
from reflection.KeyValue import KeyValue
obj = KeyValue()
obj.Init(self._tab.Bytes, x)
return obj
@@ -111,25 +111,25 @@ def Start(builder):
def RPCCallAddName(builder, name):
builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0)
def AddName(builder: flatbuffers.Builder, name: int):
def AddName(builder, name):
RPCCallAddName(builder, name)
def RPCCallAddRequest(builder, request):
builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(request), 0)
def AddRequest(builder: flatbuffers.Builder, request: int):
def AddRequest(builder, request):
RPCCallAddRequest(builder, request)
def RPCCallAddResponse(builder, response):
builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(response), 0)
def AddResponse(builder: flatbuffers.Builder, response: int):
def AddResponse(builder, response):
RPCCallAddResponse(builder, response)
def RPCCallAddAttributes(builder, attributes):
builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(attributes), 0)
def AddAttributes(builder: flatbuffers.Builder, attributes: int):
def AddAttributes(builder, attributes):
RPCCallAddAttributes(builder, attributes)
def RPCCallStartAttributesVector(builder, numElems):
@@ -141,7 +141,7 @@ def StartAttributesVector(builder, numElems: int) -> int:
def RPCCallAddDocumentation(builder, documentation):
builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(documentation), 0)
def AddDocumentation(builder: flatbuffers.Builder, documentation: int):
def AddDocumentation(builder, documentation):
RPCCallAddDocumentation(builder, documentation)
def RPCCallStartDocumentationVector(builder, numElems):

View File

@@ -35,7 +35,7 @@ class Schema(object):
x = self._tab.Vector(o)
x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
x = self._tab.Indirect(x)
from .reflection.Object import Object
from reflection.Object import Object
obj = Object()
obj.Init(self._tab.Bytes, x)
return obj
@@ -60,7 +60,7 @@ class Schema(object):
x = self._tab.Vector(o)
x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
x = self._tab.Indirect(x)
from .reflection.Enum import Enum
from reflection.Enum import Enum
obj = Enum()
obj.Init(self._tab.Bytes, x)
return obj
@@ -97,7 +97,7 @@ class Schema(object):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
if o != 0:
x = self._tab.Indirect(o + self._tab.Pos)
from .reflection.Object import Object
from reflection.Object import Object
obj = Object()
obj.Init(self._tab.Bytes, x)
return obj
@@ -110,7 +110,7 @@ class Schema(object):
x = self._tab.Vector(o)
x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
x = self._tab.Indirect(x)
from .reflection.Service import Service
from reflection.Service import Service
obj = Service()
obj.Init(self._tab.Bytes, x)
return obj
@@ -144,7 +144,7 @@ class Schema(object):
x = self._tab.Vector(o)
x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
x = self._tab.Indirect(x)
from .reflection.SchemaFile import SchemaFile
from reflection.SchemaFile import SchemaFile
obj = SchemaFile()
obj.Init(self._tab.Bytes, x)
return obj
@@ -171,7 +171,7 @@ def Start(builder):
def SchemaAddObjects(builder, objects):
builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(objects), 0)
def AddObjects(builder: flatbuffers.Builder, objects: int):
def AddObjects(builder, objects):
SchemaAddObjects(builder, objects)
def SchemaStartObjectsVector(builder, numElems):
@@ -183,7 +183,7 @@ def StartObjectsVector(builder, numElems: int) -> int:
def SchemaAddEnums(builder, enums):
builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(enums), 0)
def AddEnums(builder: flatbuffers.Builder, enums: int):
def AddEnums(builder, enums):
SchemaAddEnums(builder, enums)
def SchemaStartEnumsVector(builder, numElems):
@@ -195,25 +195,25 @@ def StartEnumsVector(builder, numElems: int) -> int:
def SchemaAddFileIdent(builder, fileIdent):
builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(fileIdent), 0)
def AddFileIdent(builder: flatbuffers.Builder, fileIdent: int):
def AddFileIdent(builder, fileIdent):
SchemaAddFileIdent(builder, fileIdent)
def SchemaAddFileExt(builder, fileExt):
builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(fileExt), 0)
def AddFileExt(builder: flatbuffers.Builder, fileExt: int):
def AddFileExt(builder, fileExt):
SchemaAddFileExt(builder, fileExt)
def SchemaAddRootTable(builder, rootTable):
builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(rootTable), 0)
def AddRootTable(builder: flatbuffers.Builder, rootTable: int):
def AddRootTable(builder, rootTable):
SchemaAddRootTable(builder, rootTable)
def SchemaAddServices(builder, services):
builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(services), 0)
def AddServices(builder: flatbuffers.Builder, services: int):
def AddServices(builder, services):
SchemaAddServices(builder, services)
def SchemaStartServicesVector(builder, numElems):
@@ -225,13 +225,13 @@ def StartServicesVector(builder, numElems: int) -> int:
def SchemaAddAdvancedFeatures(builder, advancedFeatures):
builder.PrependUint64Slot(6, advancedFeatures, 0)
def AddAdvancedFeatures(builder: flatbuffers.Builder, advancedFeatures: int):
def AddAdvancedFeatures(builder, advancedFeatures):
SchemaAddAdvancedFeatures(builder, advancedFeatures)
def SchemaAddFbsFiles(builder, fbsFiles):
builder.PrependUOffsetTRelativeSlot(7, flatbuffers.number_types.UOffsetTFlags.py_type(fbsFiles), 0)
def AddFbsFiles(builder: flatbuffers.Builder, fbsFiles: int):
def AddFbsFiles(builder, fbsFiles):
SchemaAddFbsFiles(builder, fbsFiles)
def SchemaStartFbsFilesVector(builder, numElems):

View File

@@ -69,13 +69,13 @@ def Start(builder):
def SchemaFileAddFilename(builder, filename):
builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(filename), 0)
def AddFilename(builder: flatbuffers.Builder, filename: int):
def AddFilename(builder, filename):
SchemaFileAddFilename(builder, filename)
def SchemaFileAddIncludedFilenames(builder, includedFilenames):
builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(includedFilenames), 0)
def AddIncludedFilenames(builder: flatbuffers.Builder, includedFilenames: int):
def AddIncludedFilenames(builder, includedFilenames):
SchemaFileAddIncludedFilenames(builder, includedFilenames)
def SchemaFileStartIncludedFilenamesVector(builder, numElems):

View File

@@ -42,7 +42,7 @@ class Service(object):
x = self._tab.Vector(o)
x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
x = self._tab.Indirect(x)
from .reflection.RPCCall import RPCCall
from reflection.RPCCall import RPCCall
obj = RPCCall()
obj.Init(self._tab.Bytes, x)
return obj
@@ -67,7 +67,7 @@ class Service(object):
x = self._tab.Vector(o)
x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
x = self._tab.Indirect(x)
from .reflection.KeyValue import KeyValue
from reflection.KeyValue import KeyValue
obj = KeyValue()
obj.Init(self._tab.Bytes, x)
return obj
@@ -122,13 +122,13 @@ def Start(builder):
def ServiceAddName(builder, name):
builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0)
def AddName(builder: flatbuffers.Builder, name: int):
def AddName(builder, name):
ServiceAddName(builder, name)
def ServiceAddCalls(builder, calls):
builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(calls), 0)
def AddCalls(builder: flatbuffers.Builder, calls: int):
def AddCalls(builder, calls):
ServiceAddCalls(builder, calls)
def ServiceStartCallsVector(builder, numElems):
@@ -140,7 +140,7 @@ def StartCallsVector(builder, numElems: int) -> int:
def ServiceAddAttributes(builder, attributes):
builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(attributes), 0)
def AddAttributes(builder: flatbuffers.Builder, attributes: int):
def AddAttributes(builder, attributes):
ServiceAddAttributes(builder, attributes)
def ServiceStartAttributesVector(builder, numElems):
@@ -152,7 +152,7 @@ def StartAttributesVector(builder, numElems: int) -> int:
def ServiceAddDocumentation(builder, documentation):
builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(documentation), 0)
def AddDocumentation(builder: flatbuffers.Builder, documentation: int):
def AddDocumentation(builder, documentation):
ServiceAddDocumentation(builder, documentation)
def ServiceStartDocumentationVector(builder, numElems):
@@ -164,7 +164,7 @@ def StartDocumentationVector(builder, numElems: int) -> int:
def ServiceAddDeclarationFile(builder, declarationFile):
builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(declarationFile), 0)
def AddDeclarationFile(builder: flatbuffers.Builder, declarationFile: int):
def AddDeclarationFile(builder, declarationFile):
ServiceAddDeclarationFile(builder, declarationFile)
def ServiceEnd(builder):

View File

@@ -81,37 +81,37 @@ def Start(builder):
def TypeAddBaseType(builder, baseType):
builder.PrependInt8Slot(0, baseType, 0)
def AddBaseType(builder: flatbuffers.Builder, baseType: int):
def AddBaseType(builder, baseType):
TypeAddBaseType(builder, baseType)
def TypeAddElement(builder, element):
builder.PrependInt8Slot(1, element, 0)
def AddElement(builder: flatbuffers.Builder, element: int):
def AddElement(builder, element):
TypeAddElement(builder, element)
def TypeAddIndex(builder, index):
builder.PrependInt32Slot(2, index, -1)
def AddIndex(builder: flatbuffers.Builder, index: int):
def AddIndex(builder, index):
TypeAddIndex(builder, index)
def TypeAddFixedLength(builder, fixedLength):
builder.PrependUint16Slot(3, fixedLength, 0)
def AddFixedLength(builder: flatbuffers.Builder, fixedLength: int):
def AddFixedLength(builder, fixedLength):
TypeAddFixedLength(builder, fixedLength)
def TypeAddBaseSize(builder, baseSize):
builder.PrependUint32Slot(4, baseSize, 4)
def AddBaseSize(builder: flatbuffers.Builder, baseSize: int):
def AddBaseSize(builder, baseSize):
TypeAddBaseSize(builder, baseSize)
def TypeAddElementSize(builder, elementSize):
builder.PrependUint32Slot(5, elementSize, 0)
def AddElementSize(builder: flatbuffers.Builder, elementSize: int):
def AddElementSize(builder, elementSize):
TypeAddElementSize(builder, elementSize)
def TypeEnd(builder):

View File

@@ -16,7 +16,7 @@ from setuptools import setup
setup(
name='flatbuffers',
version='23.5.9',
version='23.5.26',
license='Apache 2.0',
license_files='../LICENSE',
author='Derek Bailey',

View File

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

View File

@@ -10,7 +10,7 @@
// generated, otherwise it may not be compatible.
static_assert(FLATBUFFERS_VERSION_MAJOR == 23 &&
FLATBUFFERS_VERSION_MINOR == 5 &&
FLATBUFFERS_VERSION_REVISION == 9,
FLATBUFFERS_VERSION_REVISION == 26,
"Non-compatible flatbuffers version included");
namespace MyGame {

View File

@@ -36,7 +36,7 @@ public enum MyGame_Sample_Equipment: UInt8, UnionEnum {
public struct MyGame_Sample_Vec3: NativeStruct, Verifiable, FlatbuffersInitializable {
static func validateVersion() { FlatBuffersVersion_23_5_9() }
static func validateVersion() { FlatBuffersVersion_23_5_26() }
private var _x: Float32
private var _y: Float32
@@ -72,7 +72,7 @@ public struct MyGame_Sample_Vec3: NativeStruct, Verifiable, FlatbuffersInitializ
public struct MyGame_Sample_Vec3_Mutable: FlatBufferObject {
static func validateVersion() { FlatBuffersVersion_23_5_9() }
static func validateVersion() { FlatBuffersVersion_23_5_26() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -88,7 +88,7 @@ public struct MyGame_Sample_Vec3_Mutable: FlatBufferObject {
public struct MyGame_Sample_Monster: FlatBufferObject, Verifiable {
static func validateVersion() { FlatBuffersVersion_23_5_9() }
static func validateVersion() { FlatBuffersVersion_23_5_26() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
@@ -200,7 +200,7 @@ public struct MyGame_Sample_Monster: FlatBufferObject, Verifiable {
public struct MyGame_Sample_Weapon: FlatBufferObject, Verifiable {
static func validateVersion() { FlatBuffersVersion_23_5_9() }
static func validateVersion() { FlatBuffersVersion_23_5_26() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table

View File

@@ -59,13 +59,13 @@ int main(int /*argc*/, const char * /*argv*/[]) {
// to ensure it is correct, we now generate text back from the binary,
// and compare the two:
std::string jsongen1;
if (GenerateText(parser1, parser1.builder_.GetBufferPointer(), &jsongen1)) {
if (GenText(parser1, parser1.builder_.GetBufferPointer(), &jsongen1)) {
printf("Couldn't serialize parsed data to JSON!\n");
return 1;
}
std::string jsongen2;
if (GenerateText(parser2, parser2.builder_.GetBufferPointer(), &jsongen2)) {
if (GenText(parser2, parser2.builder_.GetBufferPointer(), &jsongen2)) {
printf("Couldn't serialize parsed data to JSON!\n");
return 1;
}

View File

@@ -45,7 +45,7 @@ int main(int /*argc*/, const char * /*argv*/[]) {
// to ensure it is correct, we now generate text back from the binary,
// and compare the two:
std::string jsongen;
if (GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen)) {
if (GenText(parser, parser.builder_.GetBufferPointer(), &jsongen)) {
printf("Couldn't serialize parsed data to JSON!\n");
return 1;
}

View File

@@ -339,6 +339,12 @@ flatc(
schema="arrays_test.fbs",
)
flatc(
RUST_OPTS,
prefix="rust_namer_test",
schema="rust_namer_test.fbs",
)
flatc(
BASE_OPTS + PYTHON_OPTS,
schema="arrays_test.fbs",

View File

@@ -125,8 +125,6 @@ cc_library(
"idl_gen_kotlin.h",
"idl_gen_lobster.cpp",
"idl_gen_lobster.h",
"idl_gen_lua.cpp",
"idl_gen_lua.h",
"idl_gen_php.cpp",
"idl_gen_php.h",
"idl_gen_python.cpp",

View File

@@ -101,15 +101,15 @@ class BaseBfbsGenerator : public CodeGenerator {
virtual ~BaseBfbsGenerator() {}
BaseBfbsGenerator() : schema_(nullptr) {}
virtual Status GenerateFromSchema(
const reflection::Schema *schema) = 0;
virtual Status GenerateFromSchema(const reflection::Schema *schema,
const CodeGenOptions &options) = 0;
virtual uint64_t SupportedAdvancedFeatures() const = 0;
// Override of the Generator::GenerateCode method that does the initial
// deserialization and verification steps.
Status GenerateCode(const uint8_t *buffer,
int64_t length) FLATBUFFERS_OVERRIDE {
Status GenerateCode(const uint8_t *buffer, int64_t length,
const CodeGenOptions &options) FLATBUFFERS_OVERRIDE {
flatbuffers::Verifier verifier(buffer, static_cast<size_t>(length));
if (!reflection::VerifySchemaBuffer(verifier)) {
return FAILED_VERIFICATION;
@@ -124,7 +124,7 @@ class BaseBfbsGenerator : public CodeGenerator {
return FAILED_VERIFICATION;
}
Status status = GenerateFromSchema(schema_);
Status status = GenerateFromSchema(schema_, options);
schema_ = nullptr;
return status;
}

View File

@@ -28,6 +28,7 @@
#include "bfbs_namer.h"
// The intermediate representation schema.
#include "flatbuffers/code_generator.h"
#include "flatbuffers/reflection.h"
#include "flatbuffers/reflection_generated.h"
@@ -78,7 +79,10 @@ class LuaBfbsGenerator : public BaseBfbsGenerator {
flatc_version_(flatc_version),
namer_(LuaDefaultConfig(), LuaKeywords()) {}
Status GenerateFromSchema(const r::Schema *schema) FLATBUFFERS_OVERRIDE {
Status GenerateFromSchema(const r::Schema *schema,
const CodeGenOptions &options)
FLATBUFFERS_OVERRIDE {
options_ = options;
if (!GenerateEnums(schema->enums())) { return ERROR; }
if (!GenerateObjects(schema->objects(), schema->root_table())) {
return ERROR;
@@ -88,10 +92,9 @@ class LuaBfbsGenerator : public BaseBfbsGenerator {
using BaseBfbsGenerator::GenerateCode;
Status GenerateCode(const Parser &parser, const std::string &path,
const std::string &filename) FLATBUFFERS_OVERRIDE {
if (!GenerateLua(parser, path, filename)) { return ERROR; }
return OK;
Status GenerateCode(const Parser &, const std::string &,
const std::string &) override {
return Status::NOT_IMPLEMENTED;
}
Status GenerateMakeRule(const Parser &parser, const std::string &path,
@@ -653,12 +656,15 @@ class LuaBfbsGenerator : public BaseBfbsGenerator {
// TODO(derekbailey): figure out a save file without depending on util.h
EnsureDirExists(path);
const std::string file_name = path + "/" + namer_.File(name);
const std::string file_name =
options_.output_path + path + "/" + namer_.File(name);
SaveFile(file_name.c_str(), code, false);
}
std::unordered_set<std::string> keywords_;
std::map<std::string, std::string> requires_;
CodeGenOptions options_;
const r::Object *current_obj_;
const r::Enum *current_enum_;
const std::string flatc_version_;

View File

@@ -28,6 +28,7 @@
#include "bfbs_namer.h"
// The intermediate representation schema.
#include "flatbuffers/code_generator.h"
#include "flatbuffers/reflection.h"
#include "flatbuffers/reflection_generated.h"
@@ -95,7 +96,10 @@ class NimBfbsGenerator : public BaseBfbsGenerator {
flatc_version_(flatc_version),
namer_(NimDefaultConfig(), NimKeywords()) {}
Status GenerateFromSchema(const r::Schema *schema) FLATBUFFERS_OVERRIDE {
Status GenerateFromSchema(const r::Schema *schema,
const CodeGenOptions &options)
FLATBUFFERS_OVERRIDE {
options_ = options;
ForAllEnums(schema->enums(), [&](const r::Enum *enum_def) {
StartCodeBlock(enum_def);
GenerateEnum(enum_def);
@@ -671,12 +675,15 @@ class NimBfbsGenerator : public BaseBfbsGenerator {
// TODO(derekbailey): figure out a save file without depending on util.h
EnsureDirExists(path);
const std::string file_name = path + "/" + namer_.File(name);
const std::string file_name =
options_.output_path + path + "/" + namer_.File(name);
SaveFile(file_name.c_str(), code, false);
}
std::unordered_set<std::string> keywords_;
std::map<std::string, std::string> imports_;
CodeGenOptions options_;
const r::Object *current_obj_;
const r::Enum *current_enum_;
const std::string flatc_version_;

View File

@@ -30,9 +30,7 @@
namespace flatbuffers {
namespace {
static std::string JavaCSharpMakeRule(const bool java, const Parser &parser,
std::string JavaCSharpMakeRule(const bool java, const Parser &parser,
const std::string &path,
const std::string &file_name) {
const std::string file_extension = java ? ".java" : ".cs";
@@ -64,18 +62,6 @@ static std::string JavaCSharpMakeRule(const bool java, const Parser &parser,
return make_rule;
}
static std::string BinaryFileName(const Parser &parser, const std::string &path,
const std::string &file_name) {
auto ext = parser.file_extension_.length() ? parser.file_extension_ : "bin";
return path + file_name + "." + ext;
}
} // namespace
void CodeWriter::operator+=(std::string text) {
if (!ignore_ident_ && !text.empty()) AppendIdent(stream_);
@@ -346,48 +332,6 @@ std::string SimpleFloatConstantGenerator::NaN(float v) const {
return this->NaN(static_cast<double>(v));
}
std::string JavaMakeRule(const Parser &parser, const std::string &path,
const std::string &file_name) {
return JavaCSharpMakeRule(true, parser, path, file_name);
}
std::string CSharpMakeRule(const Parser &parser, const std::string &path,
const std::string &file_name) {
return JavaCSharpMakeRule(false, parser, path, file_name);
}
bool GenerateBinary(const Parser &parser, const std::string &path,
const std::string &file_name) {
if (parser.opts.use_flexbuffers) {
auto data_vec = parser.flex_builder_.GetBuffer();
auto data_ptr = reinterpret_cast<char *>(data(data_vec));
return !parser.flex_builder_.GetSize() ||
flatbuffers::SaveFile(
BinaryFileName(parser, path, file_name).c_str(), data_ptr,
parser.flex_builder_.GetSize(), true);
}
return !parser.builder_.GetSize() ||
flatbuffers::SaveFile(
BinaryFileName(parser, path, file_name).c_str(),
reinterpret_cast<char *>(parser.builder_.GetBufferPointer()),
parser.builder_.GetSize(), true);
}
std::string BinaryMakeRule(const Parser &parser, const std::string &path,
const std::string &file_name) {
if (!parser.builder_.GetSize()) return "";
std::string filebase =
flatbuffers::StripPath(flatbuffers::StripExtension(file_name));
std::string make_rule =
BinaryFileName(parser, path, filebase) + ": " + file_name;
auto included_files =
parser.GetIncludedFilesRecursive(parser.root_struct_def_->file);
for (auto it = included_files.begin(); it != included_files.end(); ++it) {
make_rule += " " + *it;
}
return make_rule;
}
} // namespace flatbuffers
#if defined(_MSC_VER)

View File

@@ -37,8 +37,8 @@ class FileNameSavingFileManager : public FileManager {
}
bool Loadfile(const std::string &absolute_file_name, std::string *content) {
(void) absolute_file_name;
(void) content;
(void)absolute_file_name;
(void)content;
return false;
}

View File

@@ -866,8 +866,11 @@ std::unique_ptr<Parser> FlatCompiler::GenerateCode(const FlatCOptions &options,
// Prefer bfbs generators if present.
if (code_generator->SupportsBfbsGeneration()) {
const CodeGenerator::Status status =
code_generator->GenerateCode(bfbs_buffer, bfbs_length);
CodeGenOptions code_gen_options;
code_gen_options.output_path = options.output_path;
const CodeGenerator::Status status = code_generator->GenerateCode(
bfbs_buffer, bfbs_length, code_gen_options);
if (status != CodeGenerator::Status::OK) {
Error("Unable to generate " + code_generator->LanguageName() +
" for " + filebase + code_generator->status_detail +
@@ -968,7 +971,7 @@ int FlatCompiler::Compile(const FlatCOptions &options) {
return 0;
}
if (options.generators.empty()) {
if (options.generators.empty() && options.conform_to_schema.empty()) {
Error("No generator registered");
return -1;
}

View File

@@ -31,9 +31,46 @@
#include "flatbuffers/util.h"
namespace flatbuffers {
namespace {
static std::string BinaryFileName(const Parser &parser, const std::string &path,
const std::string &file_name) {
auto ext = parser.file_extension_.length() ? parser.file_extension_ : "bin";
return path + file_name + "." + ext;
}
static bool GenerateBinary(const Parser &parser, const std::string &path,
const std::string &file_name) {
if (parser.opts.use_flexbuffers) {
auto data_vec = parser.flex_builder_.GetBuffer();
auto data_ptr = reinterpret_cast<char *>(data(data_vec));
return !parser.flex_builder_.GetSize() ||
flatbuffers::SaveFile(
BinaryFileName(parser, path, file_name).c_str(), data_ptr,
parser.flex_builder_.GetSize(), true);
}
return !parser.builder_.GetSize() ||
flatbuffers::SaveFile(
BinaryFileName(parser, path, file_name).c_str(),
reinterpret_cast<char *>(parser.builder_.GetBufferPointer()),
parser.builder_.GetSize(), true);
}
static std::string BinaryMakeRule(const Parser &parser, const std::string &path,
const std::string &file_name) {
if (!parser.builder_.GetSize()) return "";
std::string filebase =
flatbuffers::StripPath(flatbuffers::StripExtension(file_name));
std::string make_rule =
BinaryFileName(parser, path, filebase) + ": " + file_name;
auto included_files =
parser.GetIncludedFilesRecursive(parser.root_struct_def_->file);
for (auto it = included_files.begin(); it != included_files.end(); ++it) {
make_rule += " " + *it;
}
return make_rule;
}
class BinaryCodeGenerator : public CodeGenerator {
public:
Status GenerateCode(const Parser &parser, const std::string &path,
@@ -44,9 +81,8 @@ class BinaryCodeGenerator : public CodeGenerator {
// Generate code from the provided `buffer` of given `length`. The buffer is a
// serialized reflection.fbs.
Status GenerateCode(const uint8_t *buffer, int64_t length) override {
(void)buffer;
(void)length;
Status GenerateCode(const uint8_t *, int64_t,
const CodeGenOptions &) override {
return Status::NOT_IMPLEMENTED;
}

View File

@@ -377,10 +377,8 @@ class CppGenerator : public BaseGenerator {
code_ += "#pragma clang system_header\n\n";
}
code_ += "#include \"flatbuffers/flatbuffers.h\"";
code_ += "";
GenFlatbuffersVersionCheck();
code_ += "";
code_ += "#include <cstddef>";
code_ += "#include <cstdint>";
SetNameSpace(struct_def.defined_namespace);
auto name = Name(struct_def);
@@ -779,7 +777,12 @@ class CppGenerator : public BaseGenerator {
if (type.enum_def) return WrapInNameSpace(*type.enum_def);
if (type.base_type == BASE_TYPE_BOOL) return "bool";
}
return StringOf(type.base_type);
// Get real underlying type for union type
auto base_type = type.base_type;
if (type.base_type == BASE_TYPE_UTYPE && type.enum_def != nullptr) {
base_type = type.enum_def->underlying_type.base_type;
}
return StringOf(base_type);
}
// Return a C++ pointer type, specialized to the actual struct/table types,
@@ -1048,7 +1051,7 @@ class CppGenerator : public BaseGenerator {
std::string UnionVectorVerifySignature(const EnumDef &enum_def) {
const std::string name = Name(enum_def);
const std::string &type = opts_.scoped_enums ? name : "uint8_t";
const std::string &type = opts_.scoped_enums ? name : GenTypeBasic(enum_def.underlying_type, false);
return "bool Verify" + name + "Vector" +
"(::flatbuffers::Verifier &verifier, " +
"const ::flatbuffers::Vector<::flatbuffers::Offset<void>> "
@@ -3496,12 +3499,13 @@ class CppGenerator : public BaseGenerator {
}
case BASE_TYPE_UTYPE: {
value = StripUnionType(value);
auto underlying_type = GenTypeBasic(vector_type, false);
const std::string &type = opts_.scoped_enums
? Name(*field.value.type.enum_def)
: "uint8_t";
: underlying_type;
auto enum_value = "__va->_" + value + "[i].type";
if (!opts_.scoped_enums)
enum_value = "static_cast<uint8_t>(" + enum_value + ")";
enum_value = "static_cast<" + underlying_type + ">(" + enum_value + ")";
code += "_fbb.CreateVector<" + type + ">(" + value +
".size(), [](size_t i, _VectorArgs *__va) { return " +
@@ -4066,8 +4070,8 @@ class CppGenerator : public BaseGenerator {
} // namespace cpp
bool GenerateCPP(const Parser &parser, const std::string &path,
const std::string &file_name) {
static bool GenerateCPP(const Parser &parser, const std::string &path,
const std::string &file_name) {
cpp::IDLOptionsCpp opts(parser.opts);
// The '--cpp_std' argument could be extended (like ASAN):
// Example: "flatc --cpp_std c++17:option1:option2".
@@ -4105,8 +4109,8 @@ bool GenerateCPP(const Parser &parser, const std::string &path,
return generator.generate();
}
std::string CPPMakeRule(const Parser &parser, const std::string &path,
const std::string &file_name) {
static std::string CPPMakeRule(const Parser &parser, const std::string &path,
const std::string &file_name) {
const auto filebase = StripPath(StripExtension(file_name));
cpp::CppGenerator geneartor(parser, path, file_name, parser.opts);
const auto included_files = parser.GetIncludedFilesRecursive(file_name);
@@ -4130,9 +4134,8 @@ class CppCodeGenerator : public CodeGenerator {
// Generate code from the provided `buffer` of given `length`. The buffer is a
// serialized reflection.fbs.
Status GenerateCode(const uint8_t *buffer, int64_t length) override {
(void)buffer;
(void)length;
Status GenerateCode(const uint8_t *, int64_t,
const CodeGenOptions &) override {
return Status::NOT_IMPLEMENTED;
}

View File

@@ -625,7 +625,8 @@ class CSharpGenerator : public BaseGenerator {
}
// Get the value of a table verification function start
void GetStartOfTableVerifier(const StructDef &struct_def, std::string *code_ptr) {
void GetStartOfTableVerifier(const StructDef &struct_def,
std::string *code_ptr) {
std::string &code = *code_ptr;
code += "\n";
code += "static public class " + struct_def.name + "Verify\n";
@@ -645,17 +646,18 @@ class CSharpGenerator : public BaseGenerator {
}
std::string GetNestedFlatBufferName(const FieldDef &field) {
std::string name;
std::string name;
if (field.nested_flatbuffer) {
name = NamespacedName(*field.nested_flatbuffer);
} else {
name = "";
}
return name ;
return name;
}
// Generate the code to call the appropriate Verify function(s) for a field.
void GenVerifyCall(CodeWriter &code_, const FieldDef &field, const char *prefix) {
void GenVerifyCall(CodeWriter &code_, const FieldDef &field,
const char *prefix) {
code_.SetValue("PRE", prefix);
code_.SetValue("NAME", ConvertCase(field.name, Case::kUpperCamel));
code_.SetValue("REQUIRED", field.IsRequired() ? "Required" : "");
@@ -663,14 +665,16 @@ class CSharpGenerator : public BaseGenerator {
code_.SetValue("TYPE", GenTypeGet(field.value.type));
code_.SetValue("INLINESIZE", NumToString(InlineSize(field.value.type)));
code_.SetValue("OFFSET", NumToString(field.value.offset));
if (IsScalar(field.value.type.base_type) || IsStruct(field.value.type)) {
code_.SetValue("ALIGN", NumToString(InlineAlignment(field.value.type)));
code_ +=
"{{PRE}} && verifier.VerifyField(tablePos, "
"{{OFFSET}} /*{{NAME}}*/, {{INLINESIZE}} /*{{TYPE}}*/, {{ALIGN}}, {{REQUIRED_FLAG}})";
"{{PRE}} && verifier.VerifyField(tablePos, "
"{{OFFSET}} /*{{NAME}}*/, {{INLINESIZE}} /*{{TYPE}}*/, {{ALIGN}}, "
"{{REQUIRED_FLAG}})";
} else {
// TODO - probably code below should go to this 'else' - code_ += "{{PRE}}VerifyOffset{{REQUIRED}}(verifier, {{OFFSET}})\\";
// TODO - probably code below should go to this 'else' - code_ +=
// "{{PRE}}VerifyOffset{{REQUIRED}}(verifier, {{OFFSET}})\\";
}
switch (field.value.type.base_type) {
@@ -679,37 +683,47 @@ class CSharpGenerator : public BaseGenerator {
code_.SetValue("ENUM_NAME1", field.value.type.enum_def->name);
code_.SetValue("ENUM_NAME", union_name);
code_.SetValue("SUFFIX", UnionTypeFieldSuffix());
// Caution: This construction assumes, that UNION type id element has been created just before union data and
// its offset precedes union. Such assumption is common in flatbuffer implementation
code_.SetValue("TYPE_ID_OFFSET", NumToString(field.value.offset - sizeof(voffset_t)));
code_ += "{{PRE}} && verifier.VerifyUnion(tablePos, {{TYPE_ID_OFFSET}}, "
"{{OFFSET}} /*{{NAME}}*/, {{ENUM_NAME}}Verify.Verify, {{REQUIRED_FLAG}})";
// Caution: This construction assumes, that UNION type id element has
// been created just before union data and its offset precedes union.
// Such assumption is common in flatbuffer implementation
code_.SetValue("TYPE_ID_OFFSET",
NumToString(field.value.offset - sizeof(voffset_t)));
code_ +=
"{{PRE}} && verifier.VerifyUnion(tablePos, "
"{{TYPE_ID_OFFSET}}, "
"{{OFFSET}} /*{{NAME}}*/, {{ENUM_NAME}}Verify.Verify, "
"{{REQUIRED_FLAG}})";
break;
}
case BASE_TYPE_STRUCT: {
if (!field.value.type.struct_def->fixed) {
code_ += "{{PRE}} && verifier.VerifyTable(tablePos, "
"{{OFFSET}} /*{{NAME}}*/, {{TYPE}}Verify.Verify, {{REQUIRED_FLAG}})";
code_ +=
"{{PRE}} && verifier.VerifyTable(tablePos, "
"{{OFFSET}} /*{{NAME}}*/, {{TYPE}}Verify.Verify, "
"{{REQUIRED_FLAG}})";
}
break;
}
case BASE_TYPE_STRING: {
code_ += "{{PRE}} && verifier.VerifyString(tablePos, "
"{{OFFSET}} /*{{NAME}}*/, {{REQUIRED_FLAG}})";
code_ +=
"{{PRE}} && verifier.VerifyString(tablePos, "
"{{OFFSET}} /*{{NAME}}*/, {{REQUIRED_FLAG}})";
break;
}
case BASE_TYPE_VECTOR: {
switch (field.value.type.element) {
case BASE_TYPE_STRING: {
code_ += "{{PRE}} && verifier.VerifyVectorOfStrings(tablePos, "
"{{OFFSET}} /*{{NAME}}*/, {{REQUIRED_FLAG}})";
code_ +=
"{{PRE}} && verifier.VerifyVectorOfStrings(tablePos, "
"{{OFFSET}} /*{{NAME}}*/, {{REQUIRED_FLAG}})";
break;
}
case BASE_TYPE_STRUCT: {
if (!field.value.type.struct_def->fixed) {
code_ += "{{PRE}} && verifier.VerifyVectorOfTables(tablePos, "
"{{OFFSET}} /*{{NAME}}*/, {{TYPE}}Verify.Verify, {{REQUIRED_FLAG}})";
code_ +=
"{{PRE}} && verifier.VerifyVectorOfTables(tablePos, "
"{{OFFSET}} /*{{NAME}}*/, {{TYPE}}Verify.Verify, "
"{{REQUIRED_FLAG}})";
} else {
code_.SetValue(
"VECTOR_ELEM_INLINESIZE",
@@ -733,16 +747,22 @@ class CSharpGenerator : public BaseGenerator {
if (!nfn.empty()) {
code_.SetValue("CPP_NAME", nfn);
// FIXME: file_identifier.
code_ += "{{PRE}} && verifier.VerifyNestedBuffer(tablePos, "
"{{OFFSET}} /*{{NAME}}*/, {{CPP_NAME}}Verify.Verify, {{REQUIRED_FLAG}})";
} else if (field.flexbuffer) {
code_ += "{{PRE}} && verifier.VerifyNestedBuffer(tablePos, "
"{{OFFSET}} /*{{NAME}}*/, null, {{REQUIRED_FLAG}})";
} else {
code_.SetValue("VECTOR_ELEM_INLINESIZE", NumToString(InlineSize(field.value.type.VectorType())));
code_ +=
"{{PRE}} && verifier.VerifyVectorOfData(tablePos, "
"{{OFFSET}} /*{{NAME}}*/, {{VECTOR_ELEM_INLINESIZE}} /*{{TYPE}}*/, {{REQUIRED_FLAG}})";
"{{PRE}} && verifier.VerifyNestedBuffer(tablePos, "
"{{OFFSET}} /*{{NAME}}*/, {{CPP_NAME}}Verify.Verify, "
"{{REQUIRED_FLAG}})";
} else if (field.flexbuffer) {
code_ +=
"{{PRE}} && verifier.VerifyNestedBuffer(tablePos, "
"{{OFFSET}} /*{{NAME}}*/, null, {{REQUIRED_FLAG}})";
} else {
code_.SetValue(
"VECTOR_ELEM_INLINESIZE",
NumToString(InlineSize(field.value.type.VectorType())));
code_ +=
"{{PRE}} && verifier.VerifyVectorOfData(tablePos, "
"{{OFFSET}} /*{{NAME}}*/, {{VECTOR_ELEM_INLINESIZE}} "
"/*{{TYPE}}*/, {{REQUIRED_FLAG}})";
}
break;
}
@@ -758,7 +778,7 @@ class CSharpGenerator : public BaseGenerator {
// Generate table constructors, conditioned on its members' types.
void GenTableVerifier(const StructDef &struct_def, std::string *code_ptr) {
CodeWriter code_;
GetStartOfTableVerifier(struct_def, code_ptr);
// Generate struct fields accessors
@@ -771,7 +791,7 @@ class CSharpGenerator : public BaseGenerator {
}
*code_ptr += code_.ToString();
GetEndOfTableVerifier(code_ptr);
}
@@ -787,7 +807,7 @@ class CSharpGenerator : public BaseGenerator {
// verification - instead structure size is verified using VerifyField
} else {
// Create table verification function
GenTableVerifier(struct_def, code_ptr);
GenTableVerifier(struct_def, code_ptr);
}
}
@@ -826,7 +846,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_23_5_9(); ";
code += "FLATBUFFERS_23_5_26(); ";
code += "}\n";
// Generate a special accessor for the table that when used as the root
@@ -1602,8 +1622,7 @@ class CSharpGenerator : public BaseGenerator {
if (union_type.enum_def) {
const auto &enum_def = *union_type.enum_def;
auto ret =
"\n\nstatic public class " + enum_def.name + "Verify\n";
auto ret = "\n\nstatic public class " + enum_def.name + "Verify\n";
ret += "{\n";
ret +=
" static public bool Verify(Google.FlatBuffers.Verifier verifier, "
@@ -1615,25 +1634,26 @@ class CSharpGenerator : public BaseGenerator {
ret += " switch((" + enum_def.name + ")typeId)\n";
ret += " {\n";
for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end(); ++it) {
for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end();
++it) {
const auto &ev = **it;
if (ev.IsZero()) { continue; }
ret += " case " + Name(enum_def) + "." + Name(ev) + ":\n";
if (IsString(ev.union_type)) {
ret +=
" result = verifier.VerifyUnionString(tablePos);\n";
ret += " result = verifier.VerifyUnionString(tablePos);\n";
ret += " break;";
} else if (ev.union_type.base_type == BASE_TYPE_STRUCT) {
if (! ev.union_type.struct_def->fixed) {
if (!ev.union_type.struct_def->fixed) {
auto type = GenTypeGet(ev.union_type);
ret += " result = " + type + "Verify.Verify(verifier, tablePos);\n";
ret += " result = " + type +
"Verify.Verify(verifier, tablePos);\n";
} else {
ret += " result = verifier.VerifyUnionData(tablePos, " +
NumToString(InlineSize(ev.union_type)) + ", " +
NumToString(InlineAlignment(ev.union_type)) +
");\n";;
NumToString(InlineSize(ev.union_type)) + ", " +
NumToString(InlineAlignment(ev.union_type)) + ");\n";
;
}
ret += " break;";
} else {
@@ -1676,7 +1696,7 @@ class CSharpGenerator : public BaseGenerator {
// Type
code += " public " + enum_def.name + " Type { get; set; }\n";
// Value
code += " public object " + class_member + " { get; set; }\n";
code += " public object " + class_member + " { get; set; }\n";
code += "\n";
// Constructor
code += " public " + union_name + "() {\n";
@@ -1736,7 +1756,7 @@ class CSharpGenerator : public BaseGenerator {
code += "}\n\n";
code += GenUnionVerify(enum_def.underlying_type);
// JsonConverter
if (opts.cs_gen_json_serializer) {
if (enum_def.attributes.Lookup("private")) {
@@ -1773,7 +1793,7 @@ class CSharpGenerator : public BaseGenerator {
" _o, "
"Newtonsoft.Json.JsonSerializer serializer) {\n";
code += " if (_o == null) return;\n";
code += " serializer.Serialize(writer, _o." + class_member + ");\n";
code += " serializer.Serialize(writer, _o." + class_member + ");\n";
code += " }\n";
code +=
" public override object ReadJson(Newtonsoft.Json.JsonReader "
@@ -2498,8 +2518,8 @@ class CSharpGenerator : public BaseGenerator {
};
} // namespace csharp
bool GenerateCSharp(const Parser &parser, const std::string &path,
const std::string &file_name) {
static bool GenerateCSharp(const Parser &parser, const std::string &path,
const std::string &file_name) {
csharp::CSharpGenerator generator(parser, path, file_name);
return generator.generate();
}
@@ -2514,16 +2534,15 @@ class CSharpCodeGenerator : public CodeGenerator {
return Status::OK;
}
Status GenerateCode(const uint8_t *buffer, int64_t length) override {
(void)buffer;
(void)length;
Status GenerateCode(const uint8_t *, int64_t,
const CodeGenOptions &) override {
return Status::NOT_IMPLEMENTED;
}
Status GenerateMakeRule(const Parser &parser, const std::string &path,
const std::string &filename,
std::string &output) override {
output = CSharpMakeRule(parser, path, filename);
output = JavaCSharpMakeRule(false, parser, path, filename);
return Status::OK;
}

View File

@@ -90,8 +90,8 @@ class DartGenerator : public BaseGenerator {
template<typename T>
void import_generator(const std::vector<T *> &definitions,
const std::string &included,
std::set<std::string> &imports) {
const std::string &included,
std::set<std::string> &imports) {
for (const auto &item : definitions) {
if (item->file == included) {
std::string component = namer_.Namespace(*item->defined_namespace);
@@ -760,9 +760,7 @@ class DartGenerator : public BaseGenerator {
std::string getDefaultValue(const Value &value) const {
if (!value.constant.empty() && value.constant != "0") {
if (IsBool(value.type.base_type)) {
return "true";
}
if (IsBool(value.type.base_type)) { return "true"; }
if (IsScalar(value.type.base_type)) {
if (StringIsFlatbufferNan(value.constant)) {
return "double.nan";
@@ -1124,14 +1122,14 @@ class DartGenerator : public BaseGenerator {
};
} // namespace dart
bool GenerateDart(const Parser &parser, const std::string &path,
const std::string &file_name) {
static bool GenerateDart(const Parser &parser, const std::string &path,
const std::string &file_name) {
dart::DartGenerator generator(parser, path, file_name);
return generator.generate();
}
std::string DartMakeRule(const Parser &parser, const std::string &path,
const std::string &file_name) {
static std::string DartMakeRule(const Parser &parser, const std::string &path,
const std::string &file_name) {
auto filebase =
flatbuffers::StripPath(flatbuffers::StripExtension(file_name));
dart::DartGenerator generator(parser, path, file_name);
@@ -1154,9 +1152,8 @@ class DartCodeGenerator : public CodeGenerator {
return Status::OK;
}
Status GenerateCode(const uint8_t *buffer, int64_t length) override {
(void)buffer;
(void)length;
Status GenerateCode(const uint8_t *, int64_t,
const CodeGenOptions &) override {
return Status::NOT_IMPLEMENTED;
}

View File

@@ -28,6 +28,7 @@
#include "flatbuffers/util.h"
namespace flatbuffers {
namespace {
static std::string GenType(const Type &type, bool underlying = false) {
switch (type.base_type) {
@@ -252,8 +253,9 @@ static void GenNameSpace(const Namespace &name_space, std::string *_schema,
}
// Generate a flatbuffer schema from the Parser's internal representation.
std::string GenerateFBS(const Parser &parser, const std::string &file_name,
bool no_log = false) {
static std::string GenerateFBS(const Parser &parser,
const std::string &file_name,
bool no_log = false) {
// Proto namespaces may clash with table names, escape the ones that were
// generated from a table:
for (auto it = parser.namespaces_.begin(); it != parser.namespaces_.end();
@@ -374,8 +376,8 @@ std::string GenerateFBS(const Parser &parser, const std::string &file_name,
return schema;
}
bool GenerateFBS(const Parser &parser, const std::string &path,
const std::string &file_name, bool no_log = false) {
static bool GenerateFBS(const Parser &parser, const std::string &path,
const std::string &file_name, bool no_log = false) {
const std::string fbs = GenerateFBS(parser, file_name, no_log);
if (fbs.empty()) { return false; }
// TODO: Use LogCompilerWarn
@@ -387,8 +389,6 @@ bool GenerateFBS(const Parser &parser, const std::string &path,
return SaveFile((path + file_name + ".fbs").c_str(), fbs, false);
}
namespace {
class FBSCodeGenerator : public CodeGenerator {
public:
explicit FBSCodeGenerator(const bool no_log) : no_log_(no_log) {}
@@ -399,11 +399,16 @@ class FBSCodeGenerator : public CodeGenerator {
return Status::OK;
}
Status GenerateCodeString(const Parser &parser, const std::string &filename,
std::string &output) override {
output = GenerateFBS(parser, filename, no_log_);
return Status::OK;
}
// Generate code from the provided `buffer` of given `length`. The buffer is a
// serialized reflection.fbs.
Status GenerateCode(const uint8_t *buffer, int64_t length) override {
(void)buffer;
(void)length;
Status GenerateCode(const uint8_t *, int64_t,
const CodeGenOptions &) override {
return Status::NOT_IMPLEMENTED;
}

View File

@@ -1606,8 +1606,8 @@ class GoGenerator : public BaseGenerator {
};
} // namespace go
bool GenerateGo(const Parser &parser, const std::string &path,
const std::string &file_name) {
static bool GenerateGo(const Parser &parser, const std::string &path,
const std::string &file_name) {
go::GoGenerator generator(parser, path, file_name, parser.opts.go_namespace);
return generator.generate();
}
@@ -1622,9 +1622,8 @@ class GoCodeGenerator : public CodeGenerator {
return Status::OK;
}
Status GenerateCode(const uint8_t *buffer, int64_t length) override {
(void)buffer;
(void)length;
Status GenerateCode(const uint8_t *, int64_t,
const CodeGenOptions &) override {
return Status::NOT_IMPLEMENTED;
}

View File

@@ -69,9 +69,10 @@ static std::set<std::string> JavaKeywords() {
};
}
static const TypedFloatConstantGenerator JavaFloatGen("Double.", "Float.", "NaN",
"POSITIVE_INFINITY",
"NEGATIVE_INFINITY");
static const TypedFloatConstantGenerator JavaFloatGen("Double.", "Float.",
"NaN",
"POSITIVE_INFINITY",
"NEGATIVE_INFINITY");
static const CommentConfig comment_config = {
"/**",
@@ -79,7 +80,7 @@ static const CommentConfig comment_config = {
" */",
};
} // namespace
} // namespace
class JavaGenerator : public BaseGenerator {
struct FieldArrayLength {
@@ -89,16 +90,15 @@ class JavaGenerator : public BaseGenerator {
public:
JavaGenerator(const Parser &parser, const std::string &path,
const std::string &file_name,
const std::string &package_prefix)
const std::string &file_name, const std::string &package_prefix)
: BaseGenerator(parser, path, file_name, "", ".", "java"),
cur_name_space_(nullptr),
cur_name_space_(nullptr),
namer_(WithFlagOptions(JavaDefaultConfig(), parser.opts, path),
JavaKeywords()) {
if (!package_prefix.empty()) {
std::istringstream iss(package_prefix);
std::string component;
while(std::getline(iss, component, '.')) {
while (std::getline(iss, component, '.')) {
package_prefix_ns_.components.push_back(component);
}
package_prefix_ = package_prefix_ns_.GetFullyQualifiedName("") + ".";
@@ -184,10 +184,8 @@ class JavaGenerator : public BaseGenerator {
code = "// " + std::string(FlatBuffersGeneratedWarning()) + "\n\n";
Namespace combined_ns = package_prefix_ns_;
std::copy(
ns.components.begin(),
ns.components.end(),
std::back_inserter(combined_ns.components));
std::copy(ns.components.begin(), ns.components.end(),
std::back_inserter(combined_ns.components));
const std::string namespace_name = FullNamespace(".", combined_ns);
if (!namespace_name.empty()) {
@@ -368,9 +366,9 @@ class JavaGenerator : public BaseGenerator {
FLATBUFFERS_ASSERT(value.type.enum_def);
auto &enum_def = *value.type.enum_def;
auto enum_val = enum_def.FindByValue(value.constant);
return
enum_val ? Prefixed(namer_.NamespacedEnumVariant(enum_def, *enum_val))
: value.constant;
return enum_val
? Prefixed(namer_.NamespacedEnumVariant(enum_def, *enum_val))
: value.constant;
}
std::string GenDefaultValue(const FieldDef &field) const {
@@ -703,7 +701,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_23_5_9(); ";
code += "FLATBUFFERS_23_5_26(); ";
code += "}\n";
// Generate a special accessor for the table that when used as the root
@@ -1653,9 +1651,9 @@ class JavaGenerator : public BaseGenerator {
break;
case BASE_TYPE_UNION:
array_type = "int";
element_type =
Prefixed(namer_.NamespacedType(*field.value.type.enum_def))
+ "Union";
element_type = Prefixed(namer_.NamespacedType(
*field.value.type.enum_def)) +
"Union";
to_array = element_type + ".pack(builder, _o." +
namer_.Method("get", property_name) + "()[_j])";
break;
@@ -2007,8 +2005,7 @@ class JavaGenerator : public BaseGenerator {
case BASE_TYPE_UNION: {
if (wrap_in_namespace) {
type_name =
Prefixed(namer_.NamespacedType(*type.enum_def)) + "Union";
type_name = Prefixed(namer_.NamespacedType(*type.enum_def)) + "Union";
} else {
type_name = namer_.Type(*type.enum_def) + "Union";
}
@@ -2042,15 +2039,13 @@ class JavaGenerator : public BaseGenerator {
type_name.replace(type_name.length() - type_name_length,
type_name_length, new_type_name);
} else if (type.element == BASE_TYPE_UNION) {
type_name =
Prefixed(namer_.NamespacedType(*type.enum_def)) + "Union";
type_name = Prefixed(namer_.NamespacedType(*type.enum_def)) + "Union";
}
break;
}
case BASE_TYPE_UNION: {
type_name =
Prefixed(namer_.NamespacedType(*type.enum_def)) + "Union";
type_name = Prefixed(namer_.NamespacedType(*type.enum_def)) + "Union";
break;
}
default: break;
@@ -2192,12 +2187,11 @@ class JavaGenerator : public BaseGenerator {
std::string package_prefix_;
Namespace package_prefix_ns_;
};
} // namespace java
bool GenerateJava(const Parser &parser, const std::string &path,
const std::string &file_name) {
static bool GenerateJava(const Parser &parser, const std::string &path,
const std::string &file_name) {
java::JavaGenerator generator(parser, path, file_name,
parser.opts.java_package_prefix);
return generator.generate();
@@ -2213,16 +2207,15 @@ class JavaCodeGenerator : public CodeGenerator {
return Status::OK;
}
Status GenerateCode(const uint8_t *buffer, int64_t length) override {
(void)buffer;
(void)length;
Status GenerateCode(const uint8_t *, int64_t,
const CodeGenOptions &) override {
return Status::NOT_IMPLEMENTED;
}
Status GenerateMakeRule(const Parser &parser, const std::string &path,
const std::string &filename,
std::string &output) override {
output = JavaMakeRule(parser, path, filename);
output = JavaCSharpMakeRule(true, parser, path, filename);
return Status::OK;
}

View File

@@ -30,8 +30,7 @@ namespace jsons {
namespace {
template<class T>
static std::string GenFullName(const T *enum_def) {
template<class T> static std::string GenFullName(const T *enum_def) {
std::string full_name;
const auto &name_spaces = enum_def->defined_namespace->components;
for (auto ns = name_spaces.cbegin(); ns != name_spaces.cend(); ++ns) {
@@ -41,8 +40,7 @@ static std::string GenFullName(const T *enum_def) {
return full_name;
}
template<class T>
static std::string GenTypeRef(const T *enum_def) {
template<class T> static std::string GenTypeRef(const T *enum_def) {
return "\"$ref\" : \"#/definitions/" + GenFullName(enum_def) + "\"";
}
@@ -144,7 +142,7 @@ static std::string GenType(const Type &type) {
}
}
} // namespace
} // namespace
class JsonSchemaGenerator : public BaseGenerator {
private:
@@ -319,20 +317,13 @@ class JsonSchemaGenerator : public BaseGenerator {
};
} // namespace jsons
bool GenerateJsonSchema(const Parser &parser, const std::string &path,
const std::string &file_name) {
static bool GenerateJsonSchema(const Parser &parser, const std::string &path,
const std::string &file_name) {
jsons::JsonSchemaGenerator generator(parser, path, file_name);
if (!generator.generate()) { return false; }
return generator.save();
}
bool GenerateJsonSchema(const Parser &parser, std::string *json) {
jsons::JsonSchemaGenerator generator(parser, "", "");
if (!generator.generate()) { return false; }
*json = generator.getJson();
return true;
}
namespace {
class JsonSchemaCodeGenerator : public CodeGenerator {
@@ -343,9 +334,8 @@ class JsonSchemaCodeGenerator : public CodeGenerator {
return Status::OK;
}
Status GenerateCode(const uint8_t *buffer, int64_t length) override {
(void)buffer;
(void)length;
Status GenerateCode(const uint8_t *, int64_t,
const CodeGenOptions &) override {
return Status::NOT_IMPLEMENTED;
}

View File

@@ -70,7 +70,7 @@ static Namer::Config KotlinDefaultConfig() {
/*filename_suffix=*/"",
/*filename_extension=*/".kt" };
}
} // namespace
} // namespace
class KotlinGenerator : public BaseGenerator {
public:
@@ -524,7 +524,7 @@ class KotlinGenerator : public BaseGenerator {
// runtime.
GenerateFunOneLine(
writer, "validateVersion", "", "",
[&]() { writer += "Constants.FLATBUFFERS_23_5_9()"; },
[&]() { writer += "Constants.FLATBUFFERS_23_5_26()"; },
options.gen_jvmstatic);
GenerateGetRootAsAccessors(namer_.Type(struct_def), writer, options);
@@ -1593,8 +1593,8 @@ class KotlinGenerator : public BaseGenerator {
};
} // namespace kotlin
bool GenerateKotlin(const Parser &parser, const std::string &path,
const std::string &file_name) {
static bool GenerateKotlin(const Parser &parser, const std::string &path,
const std::string &file_name) {
kotlin::KotlinGenerator generator(parser, path, file_name);
return generator.generate();
}
@@ -1609,9 +1609,8 @@ class KotlinCodeGenerator : public CodeGenerator {
return Status::OK;
}
Status GenerateCode(const uint8_t *buffer, int64_t length) override {
(void)buffer;
(void)length;
Status GenerateCode(const uint8_t *, int64_t,
const CodeGenOptions &) override {
return Status::NOT_IMPLEMENTED;
}

View File

@@ -63,8 +63,10 @@ class LobsterGenerator : public BaseGenerator {
std::string GenTypeName(const Type &type) {
auto bits = NumToString(SizeOf(type.base_type) * 8);
if (IsInteger(type.base_type)) {
if (IsUnsigned(type.base_type)) return "uint" + bits;
else return "int" + bits;
if (IsUnsigned(type.base_type))
return "uint" + bits;
else
return "int" + bits;
}
if (IsFloat(type.base_type)) return "float" + bits;
if (IsString(type)) return "string";
@@ -120,16 +122,17 @@ class LobsterGenerator : public BaseGenerator {
auto defval = field.IsOptional() ? "0" : field.value.constant;
acc = "buf_.flatbuffers_field_" + GenTypeName(field.value.type) +
"(pos_, " + offsets + ", " + defval + ")";
if (IsBool(field.value.type.base_type))
acc = "bool(" + acc + ")";
if (IsBool(field.value.type.base_type)) acc = "bool(" + acc + ")";
}
if (field.value.type.enum_def)
acc = NormalizedName(*field.value.type.enum_def) + "(" + acc + ")";
if (field.IsOptional()) {
acc += ", buf_.flatbuffers_field_present(pos_, " + offsets + ")";
code += def + "() -> " + LobsterType(field.value.type) + ", bool:\n return " + acc + "\n";
code += def + "() -> " + LobsterType(field.value.type) +
", bool:\n return " + acc + "\n";
} else {
code += def + "() -> " + LobsterType(field.value.type) + ":\n return " + acc + "\n";
code += def + "() -> " + LobsterType(field.value.type) +
":\n return " + acc + "\n";
}
return;
}
@@ -150,7 +153,8 @@ class LobsterGenerator : public BaseGenerator {
}
case BASE_TYPE_STRING:
code += def +
"() -> string:\n return buf_.flatbuffers_field_string(pos_, " +
"() -> string:\n return "
"buf_.flatbuffers_field_string(pos_, " +
offsets + ")\n";
break;
case BASE_TYPE_VECTOR: {
@@ -161,7 +165,9 @@ class LobsterGenerator : public BaseGenerator {
if (!(vectortype.struct_def->fixed)) {
start = "buf_.flatbuffers_indirect(" + start + ")";
}
code += def + "(i:int) -> " + NamespacedName(*field.value.type.struct_def) + ":\n return ";
code += def + "(i:int) -> " +
NamespacedName(*field.value.type.struct_def) +
":\n return ";
code += NamespacedName(*field.value.type.struct_def) + " { buf_, " +
start + " }\n";
} else {
@@ -169,7 +175,8 @@ class LobsterGenerator : public BaseGenerator {
code += def + "(i:int) -> string:\n return ";
code += "buf_.flatbuffers_string";
} else {
code += def + "(i:int) -> " + LobsterType(vectortype) + ":\n return ";
code += def + "(i:int) -> " + LobsterType(vectortype) +
":\n return ";
code += "buf_.read_" + GenTypeName(vectortype) + "_le";
}
code += "(buf_.flatbuffers_field_vector(pos_, " + offsets +
@@ -398,8 +405,8 @@ class LobsterGenerator : public BaseGenerator {
} // namespace lobster
bool GenerateLobster(const Parser &parser, const std::string &path,
const std::string &file_name) {
static bool GenerateLobster(const Parser &parser, const std::string &path,
const std::string &file_name) {
lobster::LobsterGenerator generator(parser, path, file_name);
return generator.generate();
}
@@ -414,9 +421,8 @@ class LobsterCodeGenerator : public CodeGenerator {
return Status::OK;
}
Status GenerateCode(const uint8_t *buffer, int64_t length) override {
(void)buffer;
(void)length;
Status GenerateCode(const uint8_t *, int64_t,
const CodeGenOptions &) override {
return Status::NOT_IMPLEMENTED;
}

View File

@@ -1,806 +0,0 @@
/*
* Copyright 2014 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// independent from idl_parser, since this code is not needed for most clients
#include "idl_gen_lua.h"
#include <string>
#include <unordered_set>
#include "flatbuffers/code_generators.h"
#include "flatbuffers/flatbuffers.h"
#include "flatbuffers/idl.h"
#include "flatbuffers/util.h"
namespace flatbuffers {
namespace lua {
// Hardcode spaces per indentation.
const CommentConfig def_comment = { nullptr, "--", nullptr };
const char *Indent = " ";
const char *Comment = "-- ";
const char *End = "end\n";
const char *EndFunc = "end\n";
const char *SelfData = "self.view";
const char *SelfDataPos = "self.view.pos";
const char *SelfDataBytes = "self.view.bytes";
class LuaGenerator : public BaseGenerator {
public:
LuaGenerator(const Parser &parser, const std::string &path,
const std::string &file_name)
: BaseGenerator(parser, path, file_name, "" /* not used */,
"" /* not used */, "lua") {
static const char *const keywords[] = {
"and", "break", "do", "else", "elseif", "end", "false", "for",
"function", "goto", "if", "in", "local", "nil", "not", "or",
"repeat", "return", "then", "true", "until", "while"
};
keywords_.insert(std::begin(keywords), std::end(keywords));
}
// Most field accessors need to retrieve and test the field offset first,
// this is the prefix code for that.
std::string OffsetPrefix(const FieldDef &field) {
return std::string(Indent) + "local o = " + SelfData + ":Offset(" +
NumToString(field.value.offset) + ")\n" + Indent +
"if o ~= 0 then\n";
}
// Begin a class declaration.
void BeginClass(const StructDef &struct_def, std::string *code_ptr) {
std::string &code = *code_ptr;
code += "local " + NormalizedName(struct_def) + " = {} -- the module\n";
code += "local " + NormalizedMetaName(struct_def) +
" = {} -- the class metatable\n";
code += "\n";
}
// Begin enum code with a class declaration.
void BeginEnum(const std::string &class_name, std::string *code_ptr) {
std::string &code = *code_ptr;
code += "local " + class_name + " = {\n";
}
std::string EscapeKeyword(const std::string &name) const {
return keywords_.find(name) == keywords_.end() ? name : "_" + name;
}
std::string NormalizedName(const Definition &definition) const {
return EscapeKeyword(definition.name);
}
std::string NormalizedName(const EnumVal &ev) const {
return EscapeKeyword(ev.name);
}
std::string NormalizedMetaName(const Definition &definition) const {
return EscapeKeyword(definition.name) + "_mt";
}
// A single enum member.
void EnumMember(const EnumDef &enum_def, const EnumVal &ev,
std::string *code_ptr) {
std::string &code = *code_ptr;
code += std::string(Indent) + NormalizedName(ev) + " = " +
enum_def.ToString(ev) + ",\n";
}
// End enum code.
void EndEnum(std::string *code_ptr) {
std::string &code = *code_ptr;
code += "}\n";
}
void GenerateNewObjectPrototype(const StructDef &struct_def,
std::string *code_ptr) {
std::string &code = *code_ptr;
code += "function " + NormalizedName(struct_def) + ".New()\n";
code += std::string(Indent) + "local o = {}\n";
code += std::string(Indent) +
"setmetatable(o, {__index = " + NormalizedMetaName(struct_def) +
"})\n";
code += std::string(Indent) + "return o\n";
code += EndFunc;
}
// Initialize a new struct or table from existing data.
void NewRootTypeFromBuffer(const StructDef &struct_def,
std::string *code_ptr) {
std::string &code = *code_ptr;
code += "function " + NormalizedName(struct_def) + ".GetRootAs" +
NormalizedName(struct_def) + "(buf, offset)\n";
code += std::string(Indent) + "if type(buf) == \"string\" then\n";
code += std::string(Indent) + Indent +
"buf = flatbuffers.binaryArray.New(buf)\n";
code += std::string(Indent) + "end\n";
code += std::string(Indent) +
"local n = flatbuffers.N.UOffsetT:Unpack(buf, offset)\n";
code += std::string(Indent) + "local o = " + NormalizedName(struct_def) +
".New()\n";
code += std::string(Indent) + "o:Init(buf, n + offset)\n";
code += std::string(Indent) + "return o\n";
code += EndFunc;
}
// Initialize an existing object with other data, to avoid an allocation.
void InitializeExisting(const StructDef &struct_def, std::string *code_ptr) {
std::string &code = *code_ptr;
GenReceiver(struct_def, code_ptr);
code += "Init(buf, pos)\n";
code +=
std::string(Indent) + SelfData + " = flatbuffers.view.New(buf, pos)\n";
code += EndFunc;
}
// Get the length of a vector.
void GetVectorLen(const StructDef &struct_def, const FieldDef &field,
std::string *code_ptr) {
std::string &code = *code_ptr;
GenReceiver(struct_def, code_ptr);
code +=
ConvertCase(NormalizedName(field), Case::kUpperCamel) + "Length()\n";
code += OffsetPrefix(field);
code +=
std::string(Indent) + Indent + "return " + SelfData + ":VectorLen(o)\n";
code += std::string(Indent) + End;
code += std::string(Indent) + "return 0\n";
code += EndFunc;
}
// Get the value of a struct's scalar.
void GetScalarFieldOfStruct(const StructDef &struct_def,
const FieldDef &field, std::string *code_ptr) {
std::string &code = *code_ptr;
std::string getter = GenGetter(field.value.type);
GenReceiver(struct_def, code_ptr);
code += ConvertCase(NormalizedName(field), Case::kUpperCamel);
code += "()\n";
code += std::string(Indent) + "return " + getter;
code += std::string(SelfDataPos) + " + " + NumToString(field.value.offset) +
")\n";
code += EndFunc;
}
// Get the value of a table's scalar.
void GetScalarFieldOfTable(const StructDef &struct_def, const FieldDef &field,
std::string *code_ptr) {
std::string &code = *code_ptr;
std::string getter = GenGetter(field.value.type);
GenReceiver(struct_def, code_ptr);
code += ConvertCase(NormalizedName(field), Case::kUpperCamel);
code += "()\n";
code += OffsetPrefix(field);
getter += std::string("o + ") + SelfDataPos + ")";
auto is_bool = field.value.type.base_type == BASE_TYPE_BOOL;
if (is_bool) { getter = "(" + getter + " ~= 0)"; }
code += std::string(Indent) + Indent + "return " + getter + "\n";
code += std::string(Indent) + End;
std::string default_value;
if (is_bool) {
default_value = field.value.constant == "0" ? "false" : "true";
} else {
default_value = field.value.constant;
}
code += std::string(Indent) + "return " + default_value + "\n";
code += EndFunc;
}
// Get a struct by initializing an existing struct.
// Specific to Struct.
void GetStructFieldOfStruct(const StructDef &struct_def,
const FieldDef &field, std::string *code_ptr) {
std::string &code = *code_ptr;
GenReceiver(struct_def, code_ptr);
code += ConvertCase(NormalizedName(field), Case::kUpperCamel);
code += "(obj)\n";
code += std::string(Indent) + "obj:Init(" + SelfDataBytes + ", " +
SelfDataPos + " + ";
code += NumToString(field.value.offset) + ")\n";
code += std::string(Indent) + "return obj\n";
code += EndFunc;
}
// Get a struct by initializing an existing struct.
// Specific to Table.
void GetStructFieldOfTable(const StructDef &struct_def, const FieldDef &field,
std::string *code_ptr) {
std::string &code = *code_ptr;
GenReceiver(struct_def, code_ptr);
code += ConvertCase(NormalizedName(field), Case::kUpperCamel);
code += "()\n";
code += OffsetPrefix(field);
if (field.value.type.struct_def->fixed) {
code +=
std::string(Indent) + Indent + "local x = o + " + SelfDataPos + "\n";
} else {
code += std::string(Indent) + Indent + "local x = " + SelfData +
":Indirect(o + " + SelfDataPos + ")\n";
}
code += std::string(Indent) + Indent + "local obj = require('" +
TypeNameWithNamespace(field) + "').New()\n";
code +=
std::string(Indent) + Indent + "obj:Init(" + SelfDataBytes + ", x)\n";
code += std::string(Indent) + Indent + "return obj\n";
code += std::string(Indent) + End;
code += EndFunc;
}
// Get the value of a string.
void GetStringField(const StructDef &struct_def, const FieldDef &field,
std::string *code_ptr) {
std::string &code = *code_ptr;
GenReceiver(struct_def, code_ptr);
code += ConvertCase(NormalizedName(field), Case::kUpperCamel);
code += "()\n";
code += OffsetPrefix(field);
code +=
std::string(Indent) + Indent + "return " + GenGetter(field.value.type);
code += std::string("o + ") + SelfDataPos + ")\n";
code += std::string(Indent) + End;
code += EndFunc;
}
// Get the value of a union from an object.
void GetUnionField(const StructDef &struct_def, const FieldDef &field,
std::string *code_ptr) {
std::string &code = *code_ptr;
GenReceiver(struct_def, code_ptr);
code += ConvertCase(NormalizedName(field), Case::kUpperCamel) + "()\n";
code += OffsetPrefix(field);
// TODO(rw): this works and is not the good way to it:
// bool is_native_table = TypeName(field) == "*flatbuffers.Table";
// if (is_native_table) {
// code += std::string(Indent) + Indent + "from flatbuffers.table import
// Table\n";
//} else {
// code += std::string(Indent) + Indent +
// code += "from ." + TypeName(field) + " import " + TypeName(field) +
// "\n";
//}
code +=
std::string(Indent) + Indent +
"local obj = "
"flatbuffers.view.New(require('flatbuffers.binaryarray').New(0), 0)\n";
code += std::string(Indent) + Indent + GenGetter(field.value.type) +
"obj, o)\n";
code += std::string(Indent) + Indent + "return obj\n";
code += std::string(Indent) + End;
code += EndFunc;
}
// Get the value of a vector's struct member.
void GetMemberOfVectorOfStruct(const StructDef &struct_def,
const FieldDef &field, std::string *code_ptr) {
std::string &code = *code_ptr;
auto vectortype = field.value.type.VectorType();
GenReceiver(struct_def, code_ptr);
code += ConvertCase(NormalizedName(field), Case::kUpperCamel);
code += "(j)\n";
code += OffsetPrefix(field);
code +=
std::string(Indent) + Indent + "local x = " + SelfData + ":Vector(o)\n";
code += std::string(Indent) + Indent + "x = x + ((j-1) * ";
code += NumToString(InlineSize(vectortype)) + ")\n";
if (!(vectortype.struct_def->fixed)) {
code +=
std::string(Indent) + Indent + "x = " + SelfData + ":Indirect(x)\n";
}
code += std::string(Indent) + Indent + "local obj = require('" +
TypeNameWithNamespace(field) + "').New()\n";
code +=
std::string(Indent) + Indent + "obj:Init(" + SelfDataBytes + ", x)\n";
code += std::string(Indent) + Indent + "return obj\n";
code += std::string(Indent) + End;
code += EndFunc;
}
// Get the value of a vector's non-struct member. Uses a named return
// argument to conveniently set the zero value for the result.
void GetMemberOfVectorOfNonStruct(const StructDef &struct_def,
const FieldDef &field,
std::string *code_ptr) {
std::string &code = *code_ptr;
auto vectortype = field.value.type.VectorType();
GenReceiver(struct_def, code_ptr);
code += ConvertCase(NormalizedName(field), Case::kUpperCamel);
code += "(j)\n";
code += OffsetPrefix(field);
code +=
std::string(Indent) + Indent + "local a = " + SelfData + ":Vector(o)\n";
code += std::string(Indent) + Indent;
code += "return " + GenGetter(field.value.type);
code += "a + ((j-1) * ";
code += NumToString(InlineSize(vectortype)) + "))\n";
code += std::string(Indent) + End;
if (IsString(vectortype)) {
code += std::string(Indent) + "return ''\n";
} else {
code += std::string(Indent) + "return 0\n";
}
code += EndFunc;
}
// Access a byte/ubyte vector as a string
void AccessByteVectorAsString(const StructDef &struct_def,
const FieldDef &field, std::string *code_ptr) {
std::string &code = *code_ptr;
GenReceiver(struct_def, code_ptr);
code += ConvertCase(NormalizedName(field), Case::kUpperCamel);
code += "AsString(start, stop)\n";
code += std::string(Indent) + "return " + SelfData + ":VectorAsString(" +
NumToString(field.value.offset) + ", start, stop)\n";
code += EndFunc;
}
// Begin the creator function signature.
void BeginBuilderArgs(const StructDef &struct_def, std::string *code_ptr) {
std::string &code = *code_ptr;
code += "function " + NormalizedName(struct_def) + ".Create" +
NormalizedName(struct_def);
code += "(builder";
}
// Recursively generate arguments for a constructor, to deal with nested
// structs.
void StructBuilderArgs(const StructDef &struct_def, const char *nameprefix,
std::string *code_ptr) {
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
auto &field = **it;
if (IsStruct(field.value.type)) {
// Generate arguments for a struct inside a struct. To ensure names
// don't clash, and to make it obvious these arguments are constructing
// a nested struct, prefix the name with the field name.
StructBuilderArgs(*field.value.type.struct_def,
(nameprefix + (NormalizedName(field) + "_")).c_str(),
code_ptr);
} else {
std::string &code = *code_ptr;
code += std::string(", ") + nameprefix;
code += ConvertCase(NormalizedName(field), Case::kLowerCamel);
}
}
}
// End the creator function signature.
void EndBuilderArgs(std::string *code_ptr) {
std::string &code = *code_ptr;
code += ")\n";
}
// Recursively generate struct construction statements and instert manual
// padding.
void StructBuilderBody(const StructDef &struct_def, const char *nameprefix,
std::string *code_ptr) {
std::string &code = *code_ptr;
code += std::string(Indent) + "builder:Prep(" +
NumToString(struct_def.minalign) + ", ";
code += NumToString(struct_def.bytesize) + ")\n";
for (auto it = struct_def.fields.vec.rbegin();
it != struct_def.fields.vec.rend(); ++it) {
auto &field = **it;
if (field.padding)
code += std::string(Indent) + "builder:Pad(" +
NumToString(field.padding) + ")\n";
if (IsStruct(field.value.type)) {
StructBuilderBody(*field.value.type.struct_def,
(nameprefix + (NormalizedName(field) + "_")).c_str(),
code_ptr);
} else {
code +=
std::string(Indent) + "builder:Prepend" + GenMethod(field) + "(";
code += nameprefix +
ConvertCase(NormalizedName(field), Case::kLowerCamel) + ")\n";
}
}
}
void EndBuilderBody(std::string *code_ptr) {
std::string &code = *code_ptr;
code += std::string(Indent) + "return builder:Offset()\n";
code += EndFunc;
}
// Get the value of a table's starting offset.
void GetStartOfTable(const StructDef &struct_def, std::string *code_ptr) {
std::string &code = *code_ptr;
code += "function " + NormalizedName(struct_def) + ".Start";
code += "(builder) ";
code += "builder:StartObject(";
code += NumToString(struct_def.fields.vec.size());
code += ") end\n";
}
// Set the value of a table's field.
void BuildFieldOfTable(const StructDef &struct_def, const FieldDef &field,
const size_t offset, std::string *code_ptr) {
std::string &code = *code_ptr;
code += "function " + NormalizedName(struct_def) + ".Add" +
ConvertCase(NormalizedName(field), Case::kUpperCamel);
code += "(builder, ";
code += ConvertCase(NormalizedName(field), Case::kLowerCamel);
code += ") ";
code += "builder:Prepend";
code += GenMethod(field) + "Slot(";
code += NumToString(offset) + ", ";
// todo: i don't need to cast in Lua, but am I missing something?
// if (!IsScalar(field.value.type.base_type) && (!struct_def.fixed)) {
// code += "flatbuffers.N.UOffsetTFlags.py_type";
// code += "(";
// code += ConvertCase(NormalizedName(field), Case::kLowerCamel) + ")";
// } else {
code += ConvertCase(NormalizedName(field), Case::kLowerCamel);
// }
code += ", " + field.value.constant;
code += ") end\n";
}
// Set the value of one of the members of a table's vector.
void BuildVectorOfTable(const StructDef &struct_def, const FieldDef &field,
std::string *code_ptr) {
std::string &code = *code_ptr;
code += "function " + NormalizedName(struct_def) + ".Start";
code += ConvertCase(NormalizedName(field), Case::kUpperCamel);
code += "Vector(builder, numElems) return builder:StartVector(";
auto vector_type = field.value.type.VectorType();
auto alignment = InlineAlignment(vector_type);
auto elem_size = InlineSize(vector_type);
code += NumToString(elem_size);
code += ", numElems, " + NumToString(alignment);
code += ") end\n";
}
// Get the offset of the end of a table.
void GetEndOffsetOnTable(const StructDef &struct_def, std::string *code_ptr) {
std::string &code = *code_ptr;
code += "function " + NormalizedName(struct_def) + ".End";
code += "(builder) ";
code += "return builder:EndObject() end\n";
}
// Generate the receiver for function signatures.
void GenReceiver(const StructDef &struct_def, std::string *code_ptr) {
std::string &code = *code_ptr;
code += "function " + NormalizedMetaName(struct_def) + ":";
}
// Generate a struct field, conditioned on its child type(s).
void GenStructAccessor(const StructDef &struct_def, const FieldDef &field,
std::string *code_ptr) {
GenComment(field.doc_comment, code_ptr, &def_comment);
if (IsScalar(field.value.type.base_type)) {
if (struct_def.fixed) {
GetScalarFieldOfStruct(struct_def, field, code_ptr);
} else {
GetScalarFieldOfTable(struct_def, field, code_ptr);
}
} else {
switch (field.value.type.base_type) {
case BASE_TYPE_STRUCT:
if (struct_def.fixed) {
GetStructFieldOfStruct(struct_def, field, code_ptr);
} else {
GetStructFieldOfTable(struct_def, field, code_ptr);
}
break;
case BASE_TYPE_STRING:
GetStringField(struct_def, field, code_ptr);
break;
case BASE_TYPE_VECTOR: {
auto vectortype = field.value.type.VectorType();
if (vectortype.base_type == BASE_TYPE_STRUCT) {
GetMemberOfVectorOfStruct(struct_def, field, code_ptr);
} else {
GetMemberOfVectorOfNonStruct(struct_def, field, code_ptr);
if (vectortype.base_type == BASE_TYPE_CHAR ||
vectortype.base_type == BASE_TYPE_UCHAR) {
AccessByteVectorAsString(struct_def, field, code_ptr);
}
}
break;
}
case BASE_TYPE_UNION: GetUnionField(struct_def, field, code_ptr); break;
default: FLATBUFFERS_ASSERT(0);
}
}
if (IsVector(field.value.type)) {
GetVectorLen(struct_def, field, code_ptr);
}
}
// Generate table constructors, conditioned on its members' types.
void GenTableBuilders(const StructDef &struct_def, std::string *code_ptr) {
GetStartOfTable(struct_def, code_ptr);
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
auto &field = **it;
if (field.deprecated) continue;
auto offset = it - struct_def.fields.vec.begin();
BuildFieldOfTable(struct_def, field, offset, code_ptr);
if (IsVector(field.value.type)) {
BuildVectorOfTable(struct_def, field, code_ptr);
}
}
GetEndOffsetOnTable(struct_def, code_ptr);
}
// Generate struct or table methods.
void GenStruct(const StructDef &struct_def, std::string *code_ptr) {
if (struct_def.generated) return;
GenComment(struct_def.doc_comment, code_ptr, &def_comment);
BeginClass(struct_def, code_ptr);
GenerateNewObjectPrototype(struct_def, code_ptr);
if (!struct_def.fixed) {
// Generate a special accessor for the table that has been declared as
// the root type.
NewRootTypeFromBuffer(struct_def, code_ptr);
}
// Generate the Init method that sets the field in a pre-existing
// accessor object. This is to allow object reuse.
InitializeExisting(struct_def, code_ptr);
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
auto &field = **it;
if (field.deprecated) continue;
GenStructAccessor(struct_def, field, code_ptr);
}
if (struct_def.fixed) {
// create a struct constructor function
GenStructBuilder(struct_def, code_ptr);
} else {
// Create a set of functions that allow table construction.
GenTableBuilders(struct_def, code_ptr);
}
}
// Generate enum declarations.
void GenEnum(const EnumDef &enum_def, std::string *code_ptr) {
if (enum_def.generated) return;
GenComment(enum_def.doc_comment, code_ptr, &def_comment);
BeginEnum(NormalizedName(enum_def), code_ptr);
for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end(); ++it) {
auto &ev = **it;
GenComment(ev.doc_comment, code_ptr, &def_comment, Indent);
EnumMember(enum_def, ev, code_ptr);
}
EndEnum(code_ptr);
}
// Returns the function name that is able to read a value of the given type.
std::string GenGetter(const Type &type) {
switch (type.base_type) {
case BASE_TYPE_STRING: return std::string(SelfData) + ":String(";
case BASE_TYPE_UNION: return std::string(SelfData) + ":Union(";
case BASE_TYPE_VECTOR: return GenGetter(type.VectorType());
default:
return std::string(SelfData) + ":Get(flatbuffers.N." +
ConvertCase(GenTypeGet(type), Case::kUpperCamel) + ", ";
}
}
// Returns the method name for use with add/put calls.
std::string GenMethod(const FieldDef &field) {
return IsScalar(field.value.type.base_type)
? ConvertCase(GenTypeBasic(field.value.type), Case::kUpperCamel)
: (IsStruct(field.value.type) ? "Struct" : "UOffsetTRelative");
}
std::string GenTypeBasic(const Type &type) {
// clang-format off
static const char *ctypename[] = {
#define FLATBUFFERS_TD(ENUM, IDLTYPE, \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, ...) \
#PTYPE,
FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD)
#undef FLATBUFFERS_TD
};
// clang-format on
return ctypename[type.base_type];
}
std::string GenTypePointer(const Type &type) {
switch (type.base_type) {
case BASE_TYPE_STRING: return "string";
case BASE_TYPE_VECTOR: return GenTypeGet(type.VectorType());
case BASE_TYPE_STRUCT: return type.struct_def->name;
case BASE_TYPE_UNION:
// fall through
default: return "*flatbuffers.Table";
}
}
std::string GenTypeGet(const Type &type) {
return IsScalar(type.base_type) ? GenTypeBasic(type) : GenTypePointer(type);
}
std::string GetNamespace(const Type &type) {
return type.struct_def->defined_namespace->GetFullyQualifiedName(
type.struct_def->name);
}
std::string TypeName(const FieldDef &field) {
return GenTypeGet(field.value.type);
}
std::string TypeNameWithNamespace(const FieldDef &field) {
return GetNamespace(field.value.type);
}
// Create a struct with a builder and the struct's arguments.
void GenStructBuilder(const StructDef &struct_def, std::string *code_ptr) {
BeginBuilderArgs(struct_def, code_ptr);
StructBuilderArgs(struct_def, "", code_ptr);
EndBuilderArgs(code_ptr);
StructBuilderBody(struct_def, "", code_ptr);
EndBuilderBody(code_ptr);
}
bool generate() {
if (!generateEnums()) return false;
if (!generateStructs()) return false;
return true;
}
private:
bool generateEnums() {
for (auto it = parser_.enums_.vec.begin(); it != parser_.enums_.vec.end();
++it) {
auto &enum_def = **it;
std::string enumcode;
GenEnum(enum_def, &enumcode);
if (!SaveType(enum_def, enumcode, false)) return false;
}
return true;
}
bool generateStructs() {
for (auto it = parser_.structs_.vec.begin();
it != parser_.structs_.vec.end(); ++it) {
auto &struct_def = **it;
std::string declcode;
GenStruct(struct_def, &declcode);
if (!SaveType(struct_def, declcode, true)) return false;
}
return true;
}
// Begin by declaring namespace and imports.
void BeginFile(const std::string &name_space_name, const bool needs_imports,
std::string *code_ptr) {
std::string &code = *code_ptr;
code += std::string(Comment) + FlatBuffersGeneratedWarning() + "\n\n";
code += std::string(Comment) + "namespace: " + name_space_name + "\n\n";
if (needs_imports) {
code += "local flatbuffers = require('flatbuffers')\n\n";
}
}
// Save out the generated code for a Lua Table type.
bool SaveType(const Definition &def, const std::string &classcode,
bool needs_imports) {
if (!classcode.length()) return true;
std::string namespace_dir = path_;
auto &namespaces = def.defined_namespace->components;
for (auto it = namespaces.begin(); it != namespaces.end(); ++it) {
if (it != namespaces.begin()) namespace_dir += kPathSeparator;
namespace_dir += *it;
// std::string init_py_filename = namespace_dir + "/__init__.py";
// SaveFile(init_py_filename.c_str(), "", false);
}
std::string code = "";
BeginFile(LastNamespacePart(*def.defined_namespace), needs_imports, &code);
code += classcode;
code += "\n";
code +=
"return " + NormalizedName(def) + " " + Comment + "return the module";
std::string filename =
NamespaceDir(*def.defined_namespace) + NormalizedName(def) + ".lua";
return SaveFile(filename.c_str(), code, false);
}
private:
std::unordered_set<std::string> keywords_;
};
} // namespace lua
bool GenerateLua(const Parser &parser, const std::string &path,
const std::string &file_name) {
lua::LuaGenerator generator(parser, path, file_name);
return generator.generate();
}
namespace {
class LuaCodeGenerator : public CodeGenerator {
public:
Status GenerateCode(const Parser &parser, const std::string &path,
const std::string &filename) override {
if (!GenerateLua(parser, path, filename)) { return Status::ERROR; }
return Status::OK;
}
Status GenerateCode(const uint8_t *buffer, int64_t length) override {
(void)buffer;
(void)length;
return Status::NOT_IMPLEMENTED;
}
Status GenerateMakeRule(const Parser &parser, const std::string &path,
const std::string &filename,
std::string &output) override {
(void)parser;
(void)path;
(void)filename;
(void)output;
return Status::NOT_IMPLEMENTED;
}
Status GenerateGrpcCode(const Parser &parser, const std::string &path,
const std::string &filename) override {
(void)parser;
(void)path;
(void)filename;
return Status::NOT_IMPLEMENTED;
}
Status GenerateRootFile(const Parser &parser,
const std::string &path) override {
(void)parser;
(void)path;
return Status::NOT_IMPLEMENTED;
}
bool IsSchemaOnly() const override { return true; }
bool SupportsBfbsGeneration() const override { return true; }
bool SupportsRootFileGeneration() const override { return false; }
IDLOptions::Language Language() const override { return IDLOptions::kLua; }
std::string LanguageName() const override { return "Lua"; }
};
} // namespace
std::unique_ptr<CodeGenerator> NewLuaCodeGenerator() {
return std::unique_ptr<LuaCodeGenerator>(new LuaCodeGenerator());
}
} // namespace flatbuffers

View File

@@ -1,29 +0,0 @@
/*
* Copyright 2023 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FLATBUFFERS_IDL_GEN_LUA_H_
#define FLATBUFFERS_IDL_GEN_LUA_H_
#include "flatbuffers/code_generator.h"
namespace flatbuffers {
// Constructs a new Lua code generator.
std::unique_ptr<CodeGenerator> NewLuaCodeGenerator();
} // namespace flatbuffers
#endif // FLATBUFFERS_IDL_GEN_LUA_H_

View File

@@ -939,8 +939,8 @@ class PhpGenerator : public BaseGenerator {
};
} // namespace php
bool GeneratePhp(const Parser &parser, const std::string &path,
const std::string &file_name) {
static bool GeneratePhp(const Parser &parser, const std::string &path,
const std::string &file_name) {
php::PhpGenerator generator(parser, path, file_name);
return generator.generate();
}
@@ -955,9 +955,8 @@ class PhpCodeGenerator : public CodeGenerator {
return Status::OK;
}
Status GenerateCode(const uint8_t *buffer, int64_t length) override {
(void)buffer;
(void)length;
Status GenerateCode(const uint8_t *, int64_t,
const CodeGenOptions &) override {
return Status::NOT_IMPLEMENTED;
}

View File

@@ -74,7 +74,7 @@ static Namer::Config PythonDefaultConfig() {
static const CommentConfig def_comment = { nullptr, "#", nullptr };
static const std::string Indent = " ";
} // namespace
} // namespace
class PythonGenerator : public BaseGenerator {
public:
@@ -149,10 +149,11 @@ class PythonGenerator : public BaseGenerator {
if (!parser_.opts.python_no_type_prefix_suffix) {
// Add an alias with the old name
code += Indent + "@classmethod\n";
code += Indent + "def GetRootAs" + struct_type + "(cls, buf, offset=0):\n";
code +=
Indent + Indent +
"\"\"\"This method is deprecated. Please switch to GetRootAs.\"\"\"\n";
Indent + "def GetRootAs" + struct_type + "(cls, buf, offset=0):\n";
code += Indent + Indent +
"\"\"\"This method is deprecated. Please switch to "
"GetRootAs.\"\"\"\n";
code += Indent + Indent + "return cls.GetRootAs(buf, offset)\n";
}
}
@@ -179,16 +180,15 @@ class PythonGenerator : public BaseGenerator {
GenReceiver(struct_def, code_ptr);
code += namer_.Method(field) + "Length(self)";
if (parser_.opts.python_typing) {
code += " -> int";
}
if (parser_.opts.python_typing) { code += " -> int"; }
code += ":";
if(!IsArray(field.value.type)){
code += OffsetPrefix(field,false);
if (!IsArray(field.value.type)) {
code += OffsetPrefix(field, false);
code += GenIndents(3) + "return self._tab.VectorLen(o)";
code += GenIndents(2) + "return 0\n\n";
}else{
code += GenIndents(2) + "return "+NumToString(field.value.type.fixed_length)+"\n\n";
} else {
code += GenIndents(2) + "return " +
NumToString(field.value.type.fixed_length) + "\n\n";
}
}
@@ -199,17 +199,15 @@ class PythonGenerator : public BaseGenerator {
GenReceiver(struct_def, code_ptr);
code += namer_.Method(field) + "IsNone(self)";
if (parser_.opts.python_typing) {
code += " -> bool";
}
if (parser_.opts.python_typing) { code += " -> bool"; }
code += ":";
if(!IsArray(field.value.type)){
if (!IsArray(field.value.type)) {
code += GenIndents(2) +
"o = flatbuffers.number_types.UOffsetTFlags.py_type" +
"(self._tab.Offset(" + NumToString(field.value.offset) + "))";
code += GenIndents(2) + "return o == 0";
} else {
//assume that we always have an array as memory is preassigned
// assume that we always have an array as memory is preassigned
code += GenIndents(2) + "return False";
}
code += "\n\n";
@@ -277,7 +275,7 @@ class PythonGenerator : public BaseGenerator {
code += namer_.Method(field);
const ImportMapEntry import_entry = {
"." + GenPackageReference(field.value.type), TypeName(field)
GenPackageReference(field.value.type), TypeName(field)
};
if (parser_.opts.python_typing) {
@@ -290,7 +288,8 @@ class PythonGenerator : public BaseGenerator {
code += "(self, i):";
}
if (parser_.opts.include_dependence_headers && !parser_.opts.python_typing) {
if (parser_.opts.include_dependence_headers &&
!parser_.opts.python_typing) {
code += GenIndents(2);
code += "from " + import_entry.first + " import " + import_entry.second +
"\n";
@@ -317,8 +316,9 @@ class PythonGenerator : public BaseGenerator {
code += NumToString(field.value.offset) + " + i * ";
code += NumToString(InlineSize(field.value.type.VectorType()));
code += ")) for i in range(";
code += "self."+namer_.Method(field)+"Length()" + ")]";
code += GenIndents(2) +"elif j >= 0 and j < self."+namer_.Method(field)+"Length():";
code += "self." + namer_.Method(field) + "Length()" + ")]";
code += GenIndents(2) + "elif j >= 0 and j < self." + namer_.Method(field) +
"Length():";
code += GenIndents(3) + "return " + GenGetter(field.value.type);
code += "self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(";
code += NumToString(field.value.offset) + " + j * ";
@@ -337,7 +337,7 @@ class PythonGenerator : public BaseGenerator {
code += namer_.Method(field) + "(self)";
const ImportMapEntry import_entry = {
"." + GenPackageReference(field.value.type), TypeName(field)
GenPackageReference(field.value.type), TypeName(field)
};
if (parser_.opts.python_typing) {
@@ -355,7 +355,8 @@ class PythonGenerator : public BaseGenerator {
code += "x = self._tab.Indirect(o + self._tab.Pos)\n";
}
if (parser_.opts.include_dependence_headers && !parser_.opts.python_typing) {
if (parser_.opts.include_dependence_headers &&
!parser_.opts.python_typing) {
code += Indent + Indent + Indent;
code += "from " + import_entry.first + " import " + import_entry.second +
"\n";
@@ -445,7 +446,7 @@ class PythonGenerator : public BaseGenerator {
GenReceiver(struct_def, code_ptr);
code += namer_.Method(field);
const ImportMapEntry import_entry = {
"." + GenPackageReference(field.value.type), TypeName(field)
GenPackageReference(field.value.type), TypeName(field)
};
if (parser_.opts.python_typing) {
@@ -464,7 +465,8 @@ class PythonGenerator : public BaseGenerator {
if (!(vectortype.struct_def->fixed)) {
code += Indent + Indent + Indent + "x = self._tab.Indirect(x)\n";
}
if (parser_.opts.include_dependence_headers && !parser_.opts.python_typing) {
if (parser_.opts.include_dependence_headers &&
!parser_.opts.python_typing) {
code += Indent + Indent + Indent;
code += "from " + import_entry.first + " import " + import_entry.second +
"\n";
@@ -519,7 +521,7 @@ class PythonGenerator : public BaseGenerator {
GenReceiver(struct_def, code_ptr);
code += namer_.Method(field) + "AsNumpy(self):";
if(!IsArray(field.value.type)){
if (!IsArray(field.value.type)) {
code += OffsetPrefix(field, false);
code += GenIndents(3);
@@ -533,11 +535,13 @@ class PythonGenerator : public BaseGenerator {
} else {
code += GenIndents(2) + "return 0\n";
}
}else{
} else {
code += GenIndents(2) + "return ";
code += "self._tab.GetArrayAsNumpy(flatbuffers.number_types.";
code += namer_.Method(GenTypeGet(field.value.type.VectorType()));
code += "Flags, self._tab.Pos + "+NumToString(field.value.offset)+", "+NumToString("self."+namer_.Method(field)+"Length()")+")\n";
code += "Flags, self._tab.Pos + " + NumToString(field.value.offset) +
", " + NumToString("self." + namer_.Method(field) + "Length()") +
")\n";
}
code += "\n";
}
@@ -564,11 +568,9 @@ class PythonGenerator : public BaseGenerator {
const std::string unqualified_name = nested->constant;
std::string qualified_name = NestedFlatbufferType(unqualified_name);
if (qualified_name.empty()) {
qualified_name = nested->constant;
}
if (qualified_name.empty()) { qualified_name = nested->constant; }
const ImportMapEntry import_entry = { "." + qualified_name,
const ImportMapEntry import_entry = { qualified_name,
unqualified_name };
auto &code = *code_ptr;
@@ -704,7 +706,9 @@ class PythonGenerator : public BaseGenerator {
const auto struct_type = namer_.Type(struct_def);
// Generate method with struct name.
const auto name = parser_.opts.python_no_type_prefix_suffix ? "Start" : struct_type + "Start";
const auto name = parser_.opts.python_no_type_prefix_suffix
? "Start"
: struct_type + "Start";
code += "def " + name;
if (parser_.opts.python_typing) {
@@ -736,12 +740,14 @@ class PythonGenerator : public BaseGenerator {
const std::string field_method = namer_.Method(field);
const std::string field_ty = GenFieldTy(field);
const auto name = parser_.opts.python_no_type_prefix_suffix ? "Add" + field_method : namer_.Type(struct_def) + "Add" + field_method;
const auto name = parser_.opts.python_no_type_prefix_suffix
? "Add" + field_method
: namer_.Type(struct_def) + "Add" + field_method;
// Generate method with struct name.
code += "def " + name;
if (parser_.opts.python_typing) {
code += "(builder: flatbuffers.Builder, " + field_var + ": " + field_ty;
code += "(builder: flatbuffers.Builder, " + field_var + ": " + field_ty;
} else {
code += "(builder, " + field_var;
}
@@ -767,9 +773,14 @@ class PythonGenerator : public BaseGenerator {
if (!parser_.opts.one_file && !parser_.opts.python_no_type_prefix_suffix) {
// Generate method without struct name.
code += "def Add" + field_method + "(builder: flatbuffers.Builder, " + field_var + ": " + field_ty + "):\n";
code +=
Indent + namer_.Type(struct_def) + "Add" + field_method;
code += "def Add" + field_method;
if (parser_.opts.python_typing) {
code += "(builder: flatbuffers.Builder, " + field_var + ": " + field_ty;
} else {
code += "(builder, " + field_var;
}
code += "):\n";
code += Indent + namer_.Type(struct_def) + "Add" + field_method;
code += "(builder, ";
code += field_var;
code += ")\n\n";
@@ -784,7 +795,9 @@ class PythonGenerator : public BaseGenerator {
const std::string field_method = namer_.Method(field);
// Generate method with struct name.
const auto name = parser_.opts.python_no_type_prefix_suffix ? "Start" + field_method : struct_type + "Start" + field_method;
const auto name = parser_.opts.python_no_type_prefix_suffix
? "Start" + field_method
: struct_type + "Start" + field_method;
code += "def " + name;
if (parser_.opts.python_typing) {
code += "Vector(builder, numElems: int) -> int:\n";
@@ -802,7 +815,8 @@ class PythonGenerator : public BaseGenerator {
if (!parser_.opts.one_file && !parser_.opts.python_no_type_prefix_suffix) {
// Generate method without struct name.
code += "def Start" + field_method + "Vector(builder, numElems: int) -> int:\n";
code += "def Start" + field_method +
"Vector(builder, numElems: int) -> int:\n";
code += Indent + "return " + struct_type + "Start";
code += field_method + "Vector(builder, numElems)\n\n";
}
@@ -849,7 +863,9 @@ class PythonGenerator : public BaseGenerator {
std::string *code_ptr) const {
auto &code = *code_ptr;
const auto name = parser_.opts.python_no_type_prefix_suffix ? "End" : namer_.Type(struct_def) + "End";
const auto name = parser_.opts.python_no_type_prefix_suffix
? "End"
: namer_.Type(struct_def) + "End";
// Generate method with struct name.
if (parser_.opts.python_typing) {
code += "def " + name + "(builder: flatbuffers.Builder) -> int:\n";
@@ -921,7 +937,9 @@ class PythonGenerator : public BaseGenerator {
}
break;
}
case BASE_TYPE_UNION: GetUnionField(struct_def, field, code_ptr, imports); break;
case BASE_TYPE_UNION:
GetUnionField(struct_def, field, code_ptr, imports);
break;
default: FLATBUFFERS_ASSERT(0);
}
}
@@ -1255,14 +1273,15 @@ class PythonGenerator : public BaseGenerator {
}
void InitializeFromPackedBuf(const StructDef &struct_def,
std::string *code_ptr) const {
std::string *code_ptr) const {
auto &code = *code_ptr;
const auto struct_var = namer_.Variable(struct_def);
const auto struct_type = namer_.Type(struct_def);
code += GenIndents(1) + "@classmethod";
code += GenIndents(1) + "def InitFromPackedBuf(cls, buf, pos=0):";
code += GenIndents(2) + "n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)";
code += GenIndents(2) +
"n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)";
code += GenIndents(2) + "return cls.InitFromBuf(buf, pos+n)";
code += "\n";
}
@@ -1281,20 +1300,21 @@ class PythonGenerator : public BaseGenerator {
code += "\n";
}
void GenCompareOperator(const StructDef &struct_def,
void GenCompareOperator(const StructDef &struct_def,
std::string *code_ptr) const {
auto &code = *code_ptr;
code += GenIndents(1) + "def __eq__(self, other):";
code += GenIndents(2) + "return type(self) == type(other)";
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
auto &field = **it;
if (field.deprecated) continue;
it != struct_def.fields.vec.end(); ++it) {
auto &field = **it;
if (field.deprecated) continue;
// Wrties the comparison statement for this field.
const auto field_field = namer_.Field(field);
code += " and \\" + GenIndents(3) + "self." + field_field + " == " + "other." + field_field;
}
// Wrties the comparison statement for this field.
const auto field_field = namer_.Field(field);
code += " and \\" + GenIndents(3) + "self." + field_field +
" == " + "other." + field_field;
}
code += "\n";
}
@@ -1317,8 +1337,9 @@ class PythonGenerator : public BaseGenerator {
code += field_type + "()";
}
code += ") is not None:";
code += GenIndents(3) + "self." + field_field + " = " + namer_.ObjectType(field_type) +
+ ".InitFromObj(" + struct_var + "." + field_method + "(";
code += GenIndents(3) + "self." + field_field + " = " +
namer_.ObjectType(field_type) + +".InitFromObj(" + struct_var +
"." + field_method + "(";
// A struct's accessor requires a struct buf instance.
if (struct_def.fixed && field.value.type.base_type == BASE_TYPE_STRUCT) {
code += field_type + "()";
@@ -1368,8 +1389,9 @@ class PythonGenerator : public BaseGenerator {
"(i) is None:";
code += GenIndents(5) + "self." + field_field + ".append(None)";
code += GenIndents(4) + "else:";
code += GenIndents(5) + one_instance + " = " + namer_.ObjectType(field_type) +
".InitFromObj(" + struct_var + "." + field_method + "(i))";
code += GenIndents(5) + one_instance + " = " +
namer_.ObjectType(field_type) + ".InitFromObj(" + struct_var + "." +
field_method + "(i))";
code +=
GenIndents(5) + "self." + field_field + ".append(" + one_instance + ")";
}
@@ -1399,8 +1421,9 @@ class PythonGenerator : public BaseGenerator {
"(i) is None:";
code += GenIndents(5) + "self." + field_field + ".append(None)";
code += GenIndents(4) + "else:";
code += GenIndents(5) + one_instance + " = " + namer_.ObjectType(field_type) +
".InitFromObj(" + struct_var + "." + field_method + "(i))";
code += GenIndents(5) + one_instance + " = " +
namer_.ObjectType(field_type) + ".InitFromObj(" + struct_var + "." +
field_method + "(i))";
code +=
GenIndents(5) + "self." + field_field + ".append(" + one_instance + ")";
}
@@ -1780,9 +1803,7 @@ class PythonGenerator : public BaseGenerator {
InitializeFromObjForObject(struct_def, &code);
if (parser_.opts.gen_compare) {
GenCompareOperator(struct_def, &code);
}
if (parser_.opts.gen_compare) { GenCompareOperator(struct_def, &code); }
GenUnPack(struct_def, &code);
@@ -1891,17 +1912,11 @@ class PythonGenerator : public BaseGenerator {
std::string GenFieldTy(const FieldDef &field) const {
if (IsScalar(field.value.type.base_type) || IsArray(field.value.type)) {
const std::string ty = GenTypeBasic(field.value.type);
if (ty.find("int") != std::string::npos) {
return "int";
}
if (ty.find("int") != std::string::npos) { return "int"; }
if (ty.find("float") != std::string::npos) {
return "float";
}
if (ty.find("float") != std::string::npos) { return "float"; }
if (ty == "bool") {
return "bool";
}
if (ty == "bool") { return "bool"; }
return "Any";
} else {
@@ -2052,13 +2067,9 @@ class PythonGenerator : public BaseGenerator {
}
if (parser_.opts.one_file) {
if (!declcode.empty()) {
*one_file_code += declcode + "\n\n";
}
if (!declcode.empty()) { *one_file_code += declcode + "\n\n"; }
for (auto import_str: imports) {
one_file_imports.insert(import_str);
}
for (auto import_str : imports) { one_file_imports.insert(import_str); }
} else {
const std::string mod =
namer_.File(struct_def, SkipFile::SuffixAndExtension);
@@ -2135,8 +2146,8 @@ class PythonGenerator : public BaseGenerator {
} // namespace python
bool GeneratePython(const Parser &parser, const std::string &path,
const std::string &file_name) {
static bool GeneratePython(const Parser &parser, const std::string &path,
const std::string &file_name) {
python::PythonGenerator generator(parser, path, file_name);
return generator.generate();
}
@@ -2151,9 +2162,8 @@ class PythonCodeGenerator : public CodeGenerator {
return Status::OK;
}
Status GenerateCode(const uint8_t *buffer, int64_t length) override {
(void)buffer;
(void)length;
Status GenerateCode(const uint8_t *, int64_t,
const CodeGenOptions &) override {
return Status::NOT_IMPLEMENTED;
}

View File

@@ -277,10 +277,10 @@ static bool IsBitFlagsEnum(const EnumDef &enum_def) {
static bool IsOptionalToBuilder(const FieldDef &field) {
return field.IsOptional() || !IsScalar(field.value.type.base_type);
}
} // namespace
} // namespace
bool GenerateRustModuleRootFile(const Parser &parser,
const std::string &output_dir) {
static bool GenerateRustModuleRootFile(const Parser &parser,
const std::string &output_dir) {
if (!parser.opts.rust_module_root_file) {
// Don't generate a root file when generating one file. This isn't an error
// so return true.
@@ -708,7 +708,7 @@ class RustGenerator : public BaseGenerator {
// and an enum array of values
void GenEnum(const EnumDef &enum_def) {
const bool is_private = parser_.opts.no_leak_private_annotations &&
(enum_def.attributes.Lookup("private") != nullptr);
(enum_def.attributes.Lookup("private") != nullptr);
code_.SetValue("ACCESS_TYPE", is_private ? "pub(crate)" : "pub");
code_.SetValue("ENUM_TY", namer_.Type(enum_def));
code_.SetValue("BASE_TYPE", GetEnumTypeForDecl(enum_def.underlying_type));
@@ -842,15 +842,21 @@ class RustGenerator : public BaseGenerator {
code_ += " type Inner = Self;";
code_ += " #[inline]";
code_ += " unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {";
code_ += " let b = flatbuffers::read_scalar_at::<{{BASE_TYPE}}>(buf, loc);";
code_ +=
" let b = flatbuffers::read_scalar_at::<{{BASE_TYPE}}>(buf, loc);";
if (IsBitFlagsEnum(enum_def)) {
// Safety:
// This is safe because we know bitflags is implemented with a repr transparent uint of the correct size.
// from_bits_unchecked will be replaced by an equivalent but safe from_bits_retain in bitflags 2.0
// This is safe because we know bitflags is implemented with a repr
// transparent uint of the correct size. from_bits_unchecked will be
// replaced by an equivalent but safe from_bits_retain in bitflags 2.0
// https://github.com/bitflags/bitflags/issues/262
code_ += " // Safety:";
code_ += " // This is safe because we know bitflags is implemented with a repr transparent uint of the correct size.";
code_ += " // from_bits_unchecked will be replaced by an equivalent but safe from_bits_retain in bitflags 2.0";
code_ +=
" // This is safe because we know bitflags is implemented with a "
"repr transparent uint of the correct size.";
code_ +=
" // from_bits_unchecked will be replaced by an equivalent but "
"safe from_bits_retain in bitflags 2.0";
code_ += " // https://github.com/bitflags/bitflags/issues/262";
code_ += " Self::from_bits_unchecked(b)";
} else {
@@ -863,7 +869,9 @@ class RustGenerator : public BaseGenerator {
code_ += " type Output = {{ENUM_TY}};";
code_ += " #[inline]";
code_ += " unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {";
code_ += " flatbuffers::emplace_scalar::<{{BASE_TYPE}}>(dst, {{INTO_BASE}});";
code_ +=
" flatbuffers::emplace_scalar::<{{BASE_TYPE}}>(dst, "
"{{INTO_BASE}});";
code_ += " }";
code_ += "}";
code_ += "";
@@ -879,12 +887,17 @@ class RustGenerator : public BaseGenerator {
code_ += " let b = {{BASE_TYPE}}::from_le(v);";
if (IsBitFlagsEnum(enum_def)) {
// Safety:
// This is safe because we know bitflags is implemented with a repr transparent uint of the correct size.
// from_bits_unchecked will be replaced by an equivalent but safe from_bits_retain in bitflags 2.0
// This is safe because we know bitflags is implemented with a repr
// transparent uint of the correct size. from_bits_unchecked will be
// replaced by an equivalent but safe from_bits_retain in bitflags 2.0
// https://github.com/bitflags/bitflags/issues/262
code_ += " // Safety:";
code_ += " // This is safe because we know bitflags is implemented with a repr transparent uint of the correct size.";
code_ += " // from_bits_unchecked will be replaced by an equivalent but safe from_bits_retain in bitflags 2.0";
code_ +=
" // This is safe because we know bitflags is implemented with a "
"repr transparent uint of the correct size.";
code_ +=
" // from_bits_unchecked will be replaced by an equivalent but "
"safe from_bits_retain in bitflags 2.0";
code_ += " // https://github.com/bitflags/bitflags/issues/262";
code_ += " unsafe { Self::from_bits_unchecked(b) }";
} else {
@@ -1458,7 +1471,8 @@ class RustGenerator : public BaseGenerator {
case ftVectorOfBool:
case ftVectorOfFloat: {
const auto typname = GetTypeBasic(type.VectorType());
return WrapOption("flatbuffers::Vector<" + lifetime + ", " + typname + ">");
return WrapOption("flatbuffers::Vector<" + lifetime + ", " + typname +
">");
}
case ftVectorOfEnumKey: {
const auto typname = WrapInNameSpace(*type.enum_def);
@@ -1467,7 +1481,8 @@ class RustGenerator : public BaseGenerator {
}
case ftVectorOfStruct: {
const auto typname = WrapInNameSpace(*type.struct_def);
return WrapOption("flatbuffers::Vector<" + lifetime + ", " + typname + ">");
return WrapOption("flatbuffers::Vector<" + lifetime + ", " + typname +
">");
}
case ftVectorOfTable: {
const auto typname = WrapInNameSpace(*type.struct_def);
@@ -1585,8 +1600,9 @@ class RustGenerator : public BaseGenerator {
: "None";
const std::string unwrap = field.IsOptional() ? "" : ".unwrap()";
return "unsafe { self._tab.get::<" + typname + ">({{STRUCT_TY}}::" + vt_offset +
", " + default_value + ")" + unwrap + "}";
return "unsafe { self._tab.get::<" + typname +
">({{STRUCT_TY}}::" + vt_offset + ", " + default_value + ")" +
unwrap + "}";
}
// Generates a fully-qualified name getter for use with --gen-name-strings
@@ -1646,8 +1662,8 @@ class RustGenerator : public BaseGenerator {
// Generate an accessor struct, builder struct, and create function for a
// table.
void GenTable(const StructDef &struct_def) {
const bool is_private = parser_.opts.no_leak_private_annotations &&
const bool is_private =
parser_.opts.no_leak_private_annotations &&
(struct_def.attributes.Lookup("private") != nullptr);
code_.SetValue("ACCESS_TYPE", is_private ? "pub(crate)" : "pub");
code_.SetValue("STRUCT_TY", namer_.Type(struct_def));
@@ -1933,13 +1949,17 @@ class RustGenerator : public BaseGenerator {
code_ += " // Safety:";
code_ += " // Created from a valid Table for this object";
code_ += " // Which contains a valid union in this slot";
code_ += " Some(unsafe { {{U_ELEMENT_TABLE_TYPE}}::init_from_table(u) })";
code_ +=
" Some(unsafe { "
"{{U_ELEMENT_TABLE_TYPE}}::init_from_table(u) })";
} else {
code_ +=" self.{{FIELD}}().map(|t| {";
code_ += " self.{{FIELD}}().map(|t| {";
code_ += " // Safety:";
code_ += " // Created from a valid Table for this object";
code_ += " // Which contains a valid union in this slot";
code_ += " unsafe { {{U_ELEMENT_TABLE_TYPE}}::init_from_table(t) }";
code_ +=
" unsafe { {{U_ELEMENT_TABLE_TYPE}}::init_from_table(t) "
"}";
code_ += " })";
}
code_ += " } else {";
@@ -2264,7 +2284,8 @@ class RustGenerator : public BaseGenerator {
case ftUnionValue: {
code_.SetValue("ENUM_METHOD",
namer_.Method(*field.value.type.enum_def));
code_.SetValue("DISCRIMINANT", namer_.LegacyRustUnionTypeMethod(field));
code_.SetValue("DISCRIMINANT",
namer_.LegacyRustUnionTypeMethod(field));
code_ +=
" let {{DISCRIMINANT}} = "
"self.{{FIELD}}.{{ENUM_METHOD}}_type();";
@@ -2312,10 +2333,10 @@ class RustGenerator : public BaseGenerator {
// TODO(cneo): create_vector* should be more generic to avoid
// allocations.
MapNativeTableField(
field,
"let w: Vec<_> = x.iter().map(|s| _fbb.create_string(s)).collect();"
"_fbb.create_vector(&w)");
MapNativeTableField(field,
"let w: Vec<_> = x.iter().map(|s| "
"_fbb.create_string(s)).collect();"
"_fbb.create_vector(&w)");
return;
}
case ftVectorOfTable: {
@@ -2601,7 +2622,8 @@ class RustGenerator : public BaseGenerator {
}
// Generate an accessor struct with constructor for a flatbuffers struct.
void GenStruct(const StructDef &struct_def) {
const bool is_private = parser_.opts.no_leak_private_annotations &&
const bool is_private =
parser_.opts.no_leak_private_annotations &&
(struct_def.attributes.Lookup("private") != nullptr);
code_.SetValue("ACCESS_TYPE", is_private ? "pub(crate)" : "pub");
// Generates manual padding and alignment.
@@ -2665,7 +2687,9 @@ class RustGenerator : public BaseGenerator {
code_ += " type Output = {{STRUCT_TY}};";
code_ += " #[inline]";
code_ += " unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {";
code_ += " let src = ::core::slice::from_raw_parts(self as *const {{STRUCT_TY}} as *const u8, Self::size());";
code_ +=
" let src = ::core::slice::from_raw_parts(self as *const "
"{{STRUCT_TY}} as *const u8, Self::size());";
code_ += " dst.copy_from_slice(src);";
code_ += " }";
code_ += "}";
@@ -2759,7 +2783,9 @@ class RustGenerator : public BaseGenerator {
code_ += " // Safety:";
code_ += " // Created from a valid Table for this object";
code_ += " // Which contains a valid array in this slot";
code_ += " unsafe { flatbuffers::Array::follow(&self.0, {{FIELD_OFFSET}}) }";
code_ +=
" unsafe { flatbuffers::Array::follow(&self.0, {{FIELD_OFFSET}}) "
"}";
} else {
code_ += "pub fn {{FIELD}}(&self) -> {{FIELD_TYPE}} {";
code_ +=
@@ -2772,7 +2798,9 @@ class RustGenerator : public BaseGenerator {
code_ += " core::ptr::copy_nonoverlapping(";
code_ += " self.0[{{FIELD_OFFSET}}..].as_ptr(),";
code_ += " mem.as_mut_ptr() as *mut u8,";
code_ += " core::mem::size_of::<<{{FIELD_TYPE}} as EndianScalar>::Scalar>(),";
code_ +=
" core::mem::size_of::<<{{FIELD_TYPE}} as "
"EndianScalar>::Scalar>(),";
code_ += " );";
code_ += " mem.assume_init()";
code_ += " })";
@@ -2827,7 +2855,9 @@ class RustGenerator : public BaseGenerator {
code_ += " core::ptr::copy_nonoverlapping(";
code_ += " &x_le as *const _ as *const u8,";
code_ += " self.0[{{FIELD_OFFSET}}..].as_mut_ptr(),";
code_ += " core::mem::size_of::<<{{FIELD_TYPE}} as EndianScalar>::Scalar>(),";
code_ +=
" core::mem::size_of::<<{{FIELD_TYPE}} as "
"EndianScalar>::Scalar>(),";
code_ += " );";
code_ += " }";
}
@@ -2989,14 +3019,14 @@ class RustGenerator : public BaseGenerator {
} // namespace rust
bool GenerateRust(const Parser &parser, const std::string &path,
const std::string &file_name) {
static bool GenerateRust(const Parser &parser, const std::string &path,
const std::string &file_name) {
rust::RustGenerator generator(parser, path, file_name);
return generator.generate();
}
std::string RustMakeRule(const Parser &parser, const std::string &path,
const std::string &file_name) {
static std::string RustMakeRule(const Parser &parser, const std::string &path,
const std::string &file_name) {
std::string filebase =
flatbuffers::StripPath(flatbuffers::StripExtension(file_name));
rust::RustGenerator generator(parser, path, file_name);
@@ -3020,9 +3050,8 @@ class RustCodeGenerator : public CodeGenerator {
return Status::OK;
}
Status GenerateCode(const uint8_t *buffer, int64_t length) override {
(void)buffer;
(void)length;
Status GenerateCode(const uint8_t *, int64_t,
const CodeGenOptions &) override {
return Status::NOT_IMPLEMENTED;
}

View File

@@ -148,7 +148,7 @@ static std::string GenArrayMainBody(const std::string &optional) {
optional + " { ";
}
} // namespace
} // namespace
class SwiftGenerator : public BaseGenerator {
private:
@@ -261,8 +261,7 @@ class SwiftGenerator : public BaseGenerator {
code_ += "private var _{{FIELDVAR}}: " + valueType;
const auto accessing_value = IsEnum(field.value.type) ? ".value" : "";
const auto base_value =
IsStruct(field.value.type) ? (type + "()")
: SwiftConstant(field);
IsStruct(field.value.type) ? (type + "()") : SwiftConstant(field);
main_constructor.push_back("_" + field_var + " = " + field_var +
accessing_value);
@@ -720,8 +719,7 @@ class SwiftGenerator : public BaseGenerator {
if (IsBool(field.value.type.base_type)) {
std::string default_value =
field.IsOptional() ? "nil"
: SwiftConstant(field);
field.IsOptional() ? "nil" : SwiftConstant(field);
code_.SetValue("CONSTANT", default_value);
code_.SetValue("VALUETYPE", "Bool");
code_ += GenReaderMainBody(optional) + "\\";
@@ -984,8 +982,9 @@ class SwiftGenerator : public BaseGenerator {
} else if (IsEnum(type) && !field.IsOptional()) {
code_.SetValue("CONSTANT", GenEnumDefaultValue(field));
code_ += "if {{FIELDVAR}} != {{CONSTANT}} {";
} else if (IsFloat(type.base_type) && StringIsFlatbufferNan(field.value.constant)) {
code_ += "if !{{FIELDVAR}}.isNaN {";
} else if (IsFloat(type.base_type) &&
StringIsFlatbufferNan(field.value.constant)) {
code_ += "if !{{FIELDVAR}}.isNaN {";
} else if (IsScalar(type.base_type) && !IsEnum(type) &&
!IsBool(type.base_type) && !field.IsOptional()) {
code_ += "if {{FIELDVAR}} != {{CONSTANT}} {";
@@ -1158,8 +1157,9 @@ class SwiftGenerator : public BaseGenerator {
void GenEnum(const EnumDef &enum_def) {
if (enum_def.generated) return;
const bool is_private_access = parser_.opts.swift_implementation_only ||
enum_def.attributes.Lookup("private") != nullptr;
const bool is_private_access =
parser_.opts.swift_implementation_only ||
enum_def.attributes.Lookup("private") != nullptr;
code_.SetValue("ENUM_TYPE",
enum_def.is_union ? "UnionEnum" : "Enum, Verifiable");
code_.SetValue("ACCESS_TYPE", is_private_access ? "internal" : "public");
@@ -1579,7 +1579,8 @@ class SwiftGenerator : public BaseGenerator {
if (IsBool(field.value.type.base_type)) {
code_ += "{{ACCESS_TYPE}} var {{FIELDVAR}}: Bool" + nullable;
if (!field.IsOptional())
base_constructor.push_back(field_var + " = " + SwiftConstant(field));
base_constructor.push_back(field_var + " = " +
SwiftConstant(field));
}
}
}
@@ -1827,22 +1828,24 @@ class SwiftGenerator : public BaseGenerator {
}
}
std::string SwiftConstant(const FieldDef& field) {
std::string SwiftConstant(const FieldDef &field) {
const auto default_value =
StringIsFlatbufferNan(field.value.constant) ? ".nan" :
StringIsFlatbufferPositiveInfinity(field.value.constant) ? ".infinity" :
StringIsFlatbufferNegativeInfinity(field.value.constant) ? "-.infinity" :
IsBool(field.value.type.base_type) ? ("0" == field.value.constant ? "false" : "true") :
field.value.constant;
StringIsFlatbufferNan(field.value.constant) ? ".nan"
: StringIsFlatbufferPositiveInfinity(field.value.constant) ? ".infinity"
: StringIsFlatbufferNegativeInfinity(field.value.constant)
? "-.infinity"
: IsBool(field.value.type.base_type)
? ("0" == field.value.constant ? "false" : "true")
: field.value.constant;
return default_value;
}
}
std::string GenEnumConstructor(const std::string &at) {
return "{{VALUETYPE}}(rawValue: " + GenReader("BASEVALUE", at) + ") ";
}
std::string ValidateFunc() {
return "static func validateVersion() { FlatBuffersVersion_23_5_9() }";
return "static func validateVersion() { FlatBuffersVersion_23_5_26() }";
}
std::string GenType(const Type &type,
@@ -1899,8 +1902,9 @@ class SwiftGenerator : public BaseGenerator {
IdlNamer namer_;
};
} // namespace swift
bool GenerateSwift(const Parser &parser, const std::string &path,
const std::string &file_name) {
static bool GenerateSwift(const Parser &parser, const std::string &path,
const std::string &file_name) {
swift::SwiftGenerator generator(parser, path, file_name);
return generator.generate();
}
@@ -1915,9 +1919,8 @@ class SwiftCodeGenerator : public CodeGenerator {
return Status::OK;
}
Status GenerateCode(const uint8_t *buffer, int64_t length) override {
(void)buffer;
(void)length;
Status GenerateCode(const uint8_t *, int64_t,
const CodeGenOptions &) override {
return Status::NOT_IMPLEMENTED;
}

View File

@@ -30,8 +30,12 @@ namespace flatbuffers {
struct PrintScalarTag {};
struct PrintPointerTag {};
template<typename T> struct PrintTag { typedef PrintScalarTag type; };
template<> struct PrintTag<const void *> { typedef PrintPointerTag type; };
template<typename T> struct PrintTag {
typedef PrintScalarTag type;
};
template<> struct PrintTag<const void *> {
typedef PrintPointerTag type;
};
struct JsonPrinter {
// If indentation is less than 0, that indicates we don't want any newlines
@@ -104,7 +108,7 @@ struct JsonPrinter {
// "[]".
template<typename Container, typename SizeT = typename Container::size_type>
const char *PrintContainer(PrintScalarTag, const Container &c, SizeT size,
const Type &type, int indent, const uint8_t *) {
const Type &type, int indent, const uint8_t *) {
const auto elem_indent = indent + Indent();
text += '[';
AddNewLine();
@@ -126,7 +130,8 @@ struct JsonPrinter {
// "[]".
template<typename Container, typename SizeT = typename Container::size_type>
const char *PrintContainer(PrintPointerTag, const Container &c, SizeT size,
const Type &type, int indent, const uint8_t *prev_val) {
const Type &type, int indent,
const uint8_t *prev_val) {
const auto is_struct = IsStruct(type);
const auto elem_indent = indent + Indent();
text += '[';
@@ -152,7 +157,7 @@ struct JsonPrinter {
template<typename T, typename SizeT = uoffset_t>
const char *PrintVector(const void *val, const Type &type, int indent,
const uint8_t *prev_val) {
const uint8_t *prev_val) {
typedef Vector<T, SizeT> Container;
typedef typename PrintTag<typename Container::return_type>::type tag;
auto &vec = *reinterpret_cast<const Container *>(val);
@@ -163,8 +168,8 @@ struct JsonPrinter {
// Print an array a sequence of JSON values, comma separated, wrapped in "[]".
template<typename T>
const char *PrintArray(const void *val, uint16_t size, const Type &type,
int indent) {
int indent) {
typedef Array<T, 0xFFFF> Container;
typedef typename PrintTag<typename Container::return_type>::type tag;
auto &arr = *reinterpret_cast<const Container *>(val);
@@ -172,7 +177,7 @@ struct JsonPrinter {
}
const char *PrintOffset(const void *val, const Type &type, int indent,
const uint8_t *prev_val, soffset_t vector_index) {
const uint8_t *prev_val, soffset_t vector_index) {
switch (type.base_type) {
case BASE_TYPE_UNION: {
// If this assert hits, you have an corrupt buffer, a union type field
@@ -196,8 +201,8 @@ struct JsonPrinter {
indent);
case BASE_TYPE_STRING: {
auto s = reinterpret_cast<const String *>(val);
bool ok = EscapeString(s->c_str(), s->size(), &text, opts.allow_non_utf8,
opts.natural_utf8);
bool ok = EscapeString(s->c_str(), s->size(), &text,
opts.allow_non_utf8, opts.natural_utf8);
return ok ? nullptr : "string contains non-utf8 bytes";
}
case BASE_TYPE_VECTOR: {
@@ -235,9 +240,7 @@ struct JsonPrinter {
// clang-format on
return nullptr;
}
default:
FLATBUFFERS_ASSERT(0);
return "unknown type";
default: FLATBUFFERS_ASSERT(0); return "unknown type";
}
}
@@ -265,15 +268,14 @@ struct JsonPrinter {
text += "null";
}
} else {
PrintScalar(
table->GetField<T>(fd.value.offset, GetFieldDefault<T>(fd)),
fd.value.type, indent);
PrintScalar(table->GetField<T>(fd.value.offset, GetFieldDefault<T>(fd)),
fd.value.type, indent);
}
}
// Generate text for non-scalar field.
const char *GenFieldOffset(const FieldDef &fd, const Table *table, bool fixed,
int indent, const uint8_t *prev_val) {
int indent, const uint8_t *prev_val) {
const void *val = nullptr;
if (fixed) {
// The only non-scalar fields in structs are structs or arrays.
@@ -372,7 +374,8 @@ struct JsonPrinter {
};
static const char *GenerateTextImpl(const Parser &parser, const Table *table,
const StructDef &struct_def, std::string *_text) {
const StructDef &struct_def,
std::string *_text) {
JsonPrinter printer(parser, *_text);
auto err = printer.GenStruct(struct_def, table, 0);
if (err) return err;
@@ -381,8 +384,8 @@ static const char *GenerateTextImpl(const Parser &parser, const Table *table,
}
// Generate a text representation of a flatbuffer in JSON format.
const char *GenerateTextFromTable(const Parser &parser, const void *table,
const std::string &table_name, std::string *_text) {
const char *GenTextFromTable(const Parser &parser, const void *table,
const std::string &table_name, std::string *_text) {
auto struct_def = parser.LookupStruct(table_name);
if (struct_def == nullptr) { return "unknown struct"; }
auto root = static_cast<const Table *>(table);
@@ -390,8 +393,8 @@ const char *GenerateTextFromTable(const Parser &parser, const void *table,
}
// Generate a text representation of a flatbuffer in JSON format.
const char *GenerateText(const Parser &parser, const void *flatbuffer,
std::string *_text) {
const char *GenText(const Parser &parser, const void *flatbuffer,
std::string *_text) {
FLATBUFFERS_ASSERT(parser.root_struct_def_); // call SetRootType()
auto root = parser.opts.size_prefixed ? GetSizePrefixedRoot<Table>(flatbuffer)
: GetRoot<Table>(flatbuffer);
@@ -403,7 +406,7 @@ static std::string TextFileName(const std::string &path,
return path + file_name + ".json";
}
const char *GenerateTextFile(const Parser &parser, const std::string &path,
const char *GenTextFile(const Parser &parser, const std::string &path,
const std::string &file_name) {
if (parser.opts.use_flexbuffers) {
std::string json;
@@ -415,7 +418,7 @@ const char *GenerateTextFile(const Parser &parser, const std::string &path,
}
if (!parser.builder_.GetSize() || !parser.root_struct_def_) return nullptr;
std::string text;
auto err = GenerateText(parser, parser.builder_.GetBufferPointer(), &text);
auto err = GenText(parser, parser.builder_.GetBufferPointer(), &text);
if (err) return err;
return flatbuffers::SaveFile(TextFileName(path, file_name).c_str(), text,
false)
@@ -423,8 +426,8 @@ const char *GenerateTextFile(const Parser &parser, const std::string &path,
: "SaveFile failed";
}
std::string TextMakeRule(const Parser &parser, const std::string &path,
const std::string &file_name) {
static std::string TextMakeRule(const Parser &parser, const std::string &path,
const std::string &file_name) {
if (!parser.builder_.GetSize() || !parser.root_struct_def_) return "";
std::string filebase =
flatbuffers::StripPath(flatbuffers::StripExtension(file_name));
@@ -443,7 +446,7 @@ class TextCodeGenerator : public CodeGenerator {
public:
Status GenerateCode(const Parser &parser, const std::string &path,
const std::string &filename) override {
auto err = GenerateTextFile(parser, path, filename);
auto err = GenTextFile(parser, path, filename);
if (err) {
status_detail = " (" + std::string(err) + ")";
return Status::ERROR;
@@ -453,9 +456,8 @@ class TextCodeGenerator : public CodeGenerator {
// Generate code from the provided `buffer` of given `length`. The buffer is a
// serialized reflection.fbs.
Status GenerateCode(const uint8_t *buffer, int64_t length) override {
(void)buffer;
(void)length;
Status GenerateCode(const uint8_t *, int64_t,
const CodeGenOptions &) override {
return Status::NOT_IMPLEMENTED;
}

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