Compare commits

...

18 Commits

Author SHA1 Message Date
Derek Bailey
06c5c7ed0b FlatBuffers Version 2.0.8 (#7492) 2022-08-29 20:43:36 -07:00
Derek Bailey
b190ce11b0 Verifier Refinements (#7490) 2022-08-29 19:21:42 -07:00
Casper
bf5d23230a Namer applied to Typescript generator (#7488)
* Namer applied to Typescript generator

* fixes

* More fixes

Co-authored-by: Casper Neo <cneo@google.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-08-29 16:44:35 -07:00
Björn Harrtell
ce382d6dd3 [TS/JS] Add rollup and config to generate iife flatbuffers bundle (#7449)
* Add rollup and config to generate iife flatbuffers bundle

* Atempt to use yarn and add deps

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-08-29 16:37:43 -07:00
Casper
41d9add7ef C++: Add option to skip verifying nested flatbuffers (#7489)
* C++: Add option to skip verifying nested flatbuffers

Additionally, add an options struct to the verifier for those
who prefer designated initializers to default arguments. The former
constructor is defined in terms of the latter because in old c++,
having default values for members removes list initialization, making
defining constructors in the other way a lot more challenging to write.

* fixes

* fmt

* formatting, and remove an argument

* fix

Co-authored-by: Casper Neo <cneo@google.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-08-29 16:25:57 -07:00
sssooonnnggg
6a87427540 [C++] support native_inline attribute for vector of tables (#7479) 2022-08-29 12:48:10 -07:00
Derek Bailey
694add668b Refactor test.cpp (#7487)
* Add timing command to cmakelist

* Start to split test.cpp. Move flexbuffers tests

* Move monster related tests to own file

* Move parser related tests to own file

* Move json related tests to own file

* Move proto related tests to own file

* moved more functions to parser test

* moved more functions to parser test2

* move monster extra tests to monster test

* move evolution tests to own file

* move reflection tests to own file

* move util tests to own file

* rehomed various tests

* move optional scalars test to own file:

* rehome more tests

* move fuzz tests. Got rid of global test_data_path

* fixes for CI failures

* add bazel files
2022-08-28 16:54:58 -07:00
Derek Bailey
7edf8c9084 Update scorecard to 1.1.2 2022-08-26 14:40:36 -07:00
Derek Bailey
b86387442e Fix typos (#7483) 2022-08-26 14:35:21 -07:00
Derek Bailey
e2eb5ee670 Include <array> head in stl_emulation.h (#7480)
* Add C++ standard builds for windows CI

* Allow C++std to be specified in cmake

* Include <array> in stl_emulation

* Add linux std CI builds
2022-08-26 00:22:27 -07:00
Axel Sommerfeldt
994502b6dd Version number in file package.json updated to 2.0.7 (#7476)
Co-authored-by: Axel Sommerfeldt <axel.sommerfeldt@gmail.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-08-25 20:40:50 -07:00
sssooonnnggg
fa41e83679 [C++] Fixed crash when copying table with empty shared strings (#7477) 2022-08-25 16:50:17 -07:00
Derek Bailey
799cc8f7b9 Use type traits for specialization (#7475) 2022-08-24 12:16:44 -07:00
Derek Bailey
b7eb441470 Disable RTTI and rework use in idl_gen_ts.cpp (#7474) 2022-08-24 10:36:11 -07:00
Axel Sommerfeldt
8d01c5859c CMake project version detection made more robust (#7473)
This fixes two problems:
1. The project could be build when using own tags which does not follow the pattern v<major>.<minor>.<patch>.
2. The case "tag points to the commit" will be handled correctly by setting VERSION_COMMIT to 0.

This commit resolves https://github.com/google/flatbuffers/issues/7472

Co-authored-by: Axel Sommerfeldt <axel.sommerfeldt@gmail.com>
2022-08-24 09:28:52 -07:00
Derek Bailey
237e8b71fe Moved compiler warnings around (#7471) 2022-08-23 23:23:24 -07:00
Derek Bailey
eeb8fd60d5 Include builder.addOffset for vector of structs (#7470) 2022-08-23 23:17:35 -07:00
Derek Bailey
fef2ffc4d0 Use schema include name for keep-prefix (#7469) 2022-08-23 21:29:17 -07:00
170 changed files with 4762 additions and 3924 deletions

View File

@@ -63,6 +63,51 @@ jobs:
id: hash-gcc
run: echo "::set-output name=hashes::$(sha256sum Linux.flatc.binary.${{ matrix.cxx }}.zip | base64 -w0)"
build-linux-cpp-std:
name: Build Linux C++
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
std: [11, 14, 17, 20, 23]
cxx: [g++-10, clang++-12]
exclude:
# GCC 10.3.0 doesn't support std 23
- cxx: g++-10
std: 23
steps:
- uses: actions/checkout@v2
- name: cmake
run: >
CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles"
-DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON
-DFLATBUFFERS_CPP_STD=${{ matrix.std }}
- name: build
run: make -j
- name: test
run: ./flattests
build-windows-cpp-std:
name: Build Windows C++
runs-on: windows-2019
strategy:
matrix:
std: [11, 14, 17, 20, 23]
fail-fast: false
steps:
- uses: actions/checkout@v2
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
- name: cmake
run: >
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release
-DFLATBUFFERS_STRICT_MODE=ON
-DFLATBUFFERS_CPP_STD=${{ matrix.std }}
- name: build
run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64
- name: test
run: Release\flattests.exe
build-windows:
permissions:
contents: write
@@ -401,8 +446,10 @@ jobs:
- name: flatc
# FIXME: make test script not rely on flatc
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF . && make -j
- name: deps
run: yarn
- name: compile
run: npm run compile
run: yarn compile
- name: test
working-directory: tests
run: python3 TypeScriptTest.py

View File

@@ -27,7 +27,7 @@ jobs:
persist-credentials: false
- name: "Run analysis"
uses: ossf/scorecard-action@c1aec4ac820532bab364f02a81873c555a0ba3a1 # v1.0.4
uses: ossf/scorecard-action@ce330fde6b1a5c9c75b417e7efc510b822a35564 # v1.1.2
with:
results_file: results.sarif
results_format: sarif

View File

@@ -4,6 +4,20 @@ 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.
## 2.0.8 (Aug 29 2022)
* Fix for `--keep-prefix` the was generating the wrong include statements for
C++ (#7469). The bug was introduced in 2.0.7.
* Added the `Verifier::Options` option struct to allow specifying runtime
configuration settings for the verifier (#7489). This allows to skip verifying
nested flatbuffers, a on-by-default change that was introduced in 2.0.7. This
deprecates the existing `Verifier` constructor, which may be removed in a future
version.
* Refactor of `tests/test.cpp` that lead to ~10% speedup in compilation of the
entire project (#7487).
## 2.0.7 (Aug 22 2022)
* This is the first version with an explicit change log, so all the previous

View File

@@ -1,6 +1,6 @@
set(VERSION_MAJOR 2)
set(VERSION_MINOR 0)
set(VERSION_PATCH 7)
set(VERSION_PATCH 8)
set(VERSION_COMMIT 0)
find_program(GIT git)
@@ -14,10 +14,19 @@ if(GIT AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
)
if(GIT_DESCRIBE_RESULT EQUAL 0)
string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${GIT_DESCRIBE_DIRTY}")
string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${GIT_DESCRIBE_DIRTY}")
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${GIT_DESCRIBE_DIRTY}")
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+).*" "\\1" VERSION_COMMIT "${GIT_DESCRIBE_DIRTY}")
# Test if the most recent Git tag matches the pattern "v<major>.<minor>.<patch>*"
if(GIT_DESCRIBE_DIRTY MATCHES "^v[0-9]+\\.[0-9]+\\.[0-9]+.*")
string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${GIT_DESCRIBE_DIRTY}")
string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${GIT_DESCRIBE_DIRTY}")
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${GIT_DESCRIBE_DIRTY}")
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+).*" "\\1" VERSION_COMMIT "${GIT_DESCRIBE_DIRTY}")
# If the tag points to the commit, then only the tag is shown in "git describe"
if(VERSION_COMMIT STREQUAL GIT_DESCRIBE_DIRTY)
set(VERSION_COMMIT 0)
endif()
else()
message(WARNING "\"${GIT_DESCRIBE_DIRTY}\" does not match pattern v<major>.<minor>.<patch>-<commit>")
endif()
else()
message(WARNING "git describe failed with exit code: ${GIT_DESCRIBE_RESULT}")
endif()

View File

@@ -78,11 +78,23 @@ option(FLATBUFFERS_STRICT_MODE
"Build flatbuffers with all warnings as errors (-Werror or /WX)."
OFF)
if(NOT DEFINED FLATBUFFERS_CPP_STD)
set(FLATBUFFERS_CPP_STD 11)
endif()
set(MSVC_LIKE OFF)
if(MSVC OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
set(MSVC_LIKE ON)
endif()
if(DEFINED FLATBUFFERS_COMPILATION_TIMINGS)
message("Recording Compilation Timings to ${FLATBUFFERS_COMPILATION_TIMINGS}")
file(REMOVE ${FLATBUFFERS_COMPILATION_TIMINGS})
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "time -f 'Wall: %E User: %U Sys: %S | %C' -q -a -o ${FLATBUFFERS_COMPILATION_TIMINGS}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_CUSTOM "time -f 'Wall: %E User: %U Sys: %S | %C' -q -a -o ${FLATBUFFERS_COMPILATION_TIMINGS}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "time -f 'Wall: %E User: %U Sys: %S | %C' -q -a -o ${FLATBUFFERS_COMPILATION_TIMINGS}")
endif()
if(NOT FLATBUFFERS_BUILD_FLATC AND FLATBUFFERS_BUILD_TESTS)
message(WARNING
"Cannot build tests without building the compiler. Tests will be disabled.")
@@ -201,11 +213,21 @@ set(FlatHash_SRCS
set(FlatBuffers_Tests_SRCS
${FlatBuffers_Library_SRCS}
src/idl_gen_fbs.cpp
tests/evolution_test.cpp
tests/flexbuffers_test.cpp
tests/fuzz_test.cpp
tests/json_test.cpp
tests/monster_test.cpp
tests/optional_scalars_test.cpp
tests/parser_test.cpp
tests/proto_test.cpp
tests/reflection_test.cpp
tests/test.cpp
tests/test_assert.h
tests/test_assert.cpp
tests/test_builder.h
tests/test_builder.cpp
tests/util_test.cpp
tests/native_type_test_impl.h
tests/native_type_test_impl.cpp
include/flatbuffers/code_generators.h
@@ -227,6 +249,8 @@ set(FlatBuffers_Tests_SRCS
${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_bfbs_generated.h
# file generate by running compiler on tests/optional_scalars.fbs
${CMAKE_CURRENT_BINARY_DIR}/tests/optional_scalars_generated.h
# file generate by running compiler on tests/native_inline_table_test.fbs
${CMAKE_CURRENT_BINARY_DIR}/tests/native_inline_table_test_generated.h
)
set(FlatBuffers_Tests_CPP17_SRCS
@@ -334,7 +358,7 @@ include_directories(grpc)
add_library(ProjectConfig INTERFACE)
target_compile_features(ProjectConfig
INTERFACE
cxx_std_11
cxx_std_${FLATBUFFERS_CPP_STD}
)
# Force the standard to be met.
@@ -358,26 +382,35 @@ if(MSVC_LIKE)
>
)
else()
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(IS_CLANG ON)
else()
set(IS_CLANG OFF)
endif()
target_compile_options(ProjectConfig
INTERFACE
-Wall
-Wno-unknown-warning-option
$<$<BOOL:${FLATBUFFERS_STRICT_MODE}>:
-Werror # Treat all compiler warnings as errors
# False positive string overflow
# https://github.com/google/flatbuffers/issues/7366
-Wno-error=stringop-overflow
-fno-rtti # Disable runtime type information
$<$<CXX_COMPILER_ID:GNU>:
# False positive string overflow
# https://github.com/google/flatbuffers/issues/7366
-Wno-error=stringop-overflow
>
>
-pedantic
-Wextra
-Wno-unused-parameter
-Wold-style-cast
-Wimplicit-fallthrough
-fsigned-char
-Wnon-virtual-dtor
$<$<CXX_COMPILER_ID:CLANG>:
# This isn't working for some reason: $<$<CXX_COMPILER_ID:CLANG>:
$<$<BOOL:${IS_CLANG}>:
-Wno-unknown-warning-option
-Wmissing-declarations
-Wzero-as-null-pointer-constant
$<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,3.8>:
@@ -589,6 +622,7 @@ if(FLATBUFFERS_BUILD_TESTS)
compile_flatbuffers_schema_to_cpp_opt(tests/arrays_test.fbs "--scoped-enums;--gen-compare")
compile_flatbuffers_schema_to_binary(tests/arrays_test.fbs)
compile_flatbuffers_schema_to_embedded_binary(tests/monster_test.fbs "--no-includes;--gen-compare")
compile_flatbuffers_schema_to_cpp(tests/native_inline_table_test.fbs "--gen-compare")
if(NOT (MSVC AND (MSVC_VERSION LESS 1900)))
compile_flatbuffers_schema_to_cpp(tests/monster_extra.fbs) # Test floating-point NAN/INF.
endif()

View File

@@ -17,7 +17,7 @@ class Builder {
final Map<double, _StackValue> _indirectDoubleCache = {};
/// Instantiate the builder if you intent to gradually build up the buffer by calling
/// add... methods and calling [finish] to receive the the resulting byte array.
/// add... methods and calling [finish] to receive the resulting byte array.
///
/// The default size of internal buffer is set to 2048. Provide a different value in order to avoid buffer copies.
Builder({int size = 2048}) : _buffer = ByteData(size);

View File

@@ -199,7 +199,7 @@ class Reference {
return _MapValueIterator(this);
}
/// Returns the length of the the underlying FlexBuffer value.
/// Returns the length of the underlying FlexBuffer value.
/// If the underlying value is [null] the length is 0.
/// If the underlying value is a number, or a bool, the length is 1.
/// If the underlying value is a vector, or map, the length reflects number of elements / element pairs.

View File

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

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

View File

@@ -140,7 +140,7 @@
#define FLATBUFFERS_VERSION_MAJOR 2
#define FLATBUFFERS_VERSION_MINOR 0
#define FLATBUFFERS_VERSION_REVISION 7
#define FLATBUFFERS_VERSION_REVISION 8
#define FLATBUFFERS_STRING_EXPAND(X) #X
#define FLATBUFFERS_STRING(X) FLATBUFFERS_STRING_EXPAND(X)
namespace flatbuffers {
@@ -273,14 +273,14 @@ namespace flatbuffers {
#endif // !FLATBUFFERS_LOCALE_INDEPENDENT
// Suppress Undefined Behavior Sanitizer (recoverable only). Usage:
// - __supress_ubsan__("undefined")
// - __supress_ubsan__("signed-integer-overflow")
// - __suppress_ubsan__("undefined")
// - __suppress_ubsan__("signed-integer-overflow")
#if defined(__clang__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >=7))
#define __supress_ubsan__(type) __attribute__((no_sanitize(type)))
#define __suppress_ubsan__(type) __attribute__((no_sanitize(type)))
#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 409)
#define __supress_ubsan__(type) __attribute__((no_sanitize_undefined))
#define __suppress_ubsan__(type) __attribute__((no_sanitize_undefined))
#else
#define __supress_ubsan__(type)
#define __suppress_ubsan__(type)
#endif
// This is constexpr function used for checking compile-time constants.
@@ -413,7 +413,7 @@ template<typename T> T EndianScalar(T t) {
template<typename T>
// UBSAN: C++ aliasing type rules, see std::bit_cast<> for details.
__supress_ubsan__("alignment")
__suppress_ubsan__("alignment")
T ReadScalar(const void *p) {
return EndianScalar(*reinterpret_cast<const T *>(p));
}
@@ -427,13 +427,13 @@ T ReadScalar(const void *p) {
template<typename T>
// UBSAN: C++ aliasing type rules, see std::bit_cast<> for details.
__supress_ubsan__("alignment")
__suppress_ubsan__("alignment")
void WriteScalar(void *p, T t) {
*reinterpret_cast<T *>(p) = EndianScalar(t);
}
template<typename T> struct Offset;
template<typename T> __supress_ubsan__("alignment") void WriteScalar(void *p, Offset<T> t) {
template<typename T> __suppress_ubsan__("alignment") void WriteScalar(void *p, Offset<T> t) {
*reinterpret_cast<uoffset_t *>(p) = EndianScalar(t.o);
}
@@ -444,7 +444,7 @@ template<typename T> __supress_ubsan__("alignment") void WriteScalar(void *p, Of
// 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).
__supress_ubsan__("unsigned-integer-overflow")
__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

@@ -95,7 +95,7 @@ template<typename T> struct IndirectHelper<const T *> {
}
};
/// @brief Get a pointer to the the file_identifier section of the buffer.
/// @brief Get a pointer to the file_identifier section of the buffer.
/// @return Returns a const char pointer to the start of the file_identifier
/// characters in the buffer. The returned char * has length
/// 'flatbuffers::FlatBufferBuilder::kFileIdentifierLength'.

View File

@@ -358,7 +358,7 @@ class FlatBufferBuilder {
// If you get this assert, a corresponding StartTable wasn't called.
FLATBUFFERS_ASSERT(nested);
// Write the vtable offset, which is the start of any Table.
// We fill it's value later.
// We fill its value later.
auto vtableoffsetloc = PushElement<soffset_t>(0);
// Write a vtable, which consists entirely of voffset_t elements.
// It starts with the number of offsets, followed by a type id, followed
@@ -579,7 +579,7 @@ class FlatBufferBuilder {
/// @param[in] str A const pointer to a `String` struct to add to the buffer.
/// @return Returns the offset in the buffer where the string starts
Offset<String> CreateSharedString(const String *str) {
return CreateSharedString(str->c_str(), str->size());
return str ? CreateSharedString(str->c_str(), str->size()) : 0;
}
/// @cond FLATBUFFERS_INTERNAL
@@ -747,7 +747,7 @@ class FlatBufferBuilder {
/// @brief Serialize a collection of Strings into a FlatBuffer `vector`.
/// This is a convenience function for a common case.
/// @param begin The begining iterator of the collection
/// @param begin The beginning iterator of the collection
/// @param end The ending iterator of the collection
/// @return Returns a typed `Offset` into the serialized data indicating
/// where the vector is stored.
@@ -757,7 +757,7 @@ class FlatBufferBuilder {
auto scratch_buffer_usage = size * sizeof(Offset<String>);
// If there is not enough space to store the offsets, there definitely won't
// be enough space to store all the strings. So ensuring space for the
// scratch region is OK, for it it fails, it would have failed later.
// scratch region is OK, for if it fails, it would have failed later.
buf_.ensure_space(scratch_buffer_usage);
for (auto it = begin; it != end; ++it) {
buf_.scratch_push_small(CreateString(*it));

View File

@@ -1871,7 +1871,7 @@ class Verifier FLATBUFFERS_FINAL_CLASS {
std::vector<uint8_t> *reuse_tracker_;
};
// Utility function that contructs the Verifier for you, see above for
// Utility function that constructs the Verifier for you, see above for
// parameters.
inline bool VerifyBuffer(const uint8_t *buf, size_t buf_len,
std::vector<uint8_t> *reuse_tracker = nullptr) {

View File

@@ -464,6 +464,10 @@ inline bool IsStruct(const Type &type) {
return type.base_type == BASE_TYPE_STRUCT && type.struct_def->fixed;
}
inline bool IsTable(const Type &type) {
return type.base_type == BASE_TYPE_STRUCT && !type.struct_def->fixed;
}
inline bool IsUnion(const Type &type) {
return type.enum_def != nullptr && type.enum_def->is_union;
}
@@ -476,6 +480,14 @@ inline bool IsVector(const Type &type) {
return type.base_type == BASE_TYPE_VECTOR;
}
inline bool IsVectorOfStruct(const Type& type) {
return IsVector(type) && IsStruct(type.VectorType());
}
inline bool IsVectorOfTable(const Type& type) {
return IsVector(type) && IsTable(type.VectorType());
}
inline bool IsArray(const Type &type) {
return type.base_type == BASE_TYPE_ARRAY;
}
@@ -537,6 +549,24 @@ struct ServiceDef : public Definition {
SymbolTable<RPCCall> calls;
};
struct IncludedFile {
// The name of the schema file being included, as defined in the .fbs file.
// This includes the prefix (e.g., include "foo/bar/baz.fbs" would mean this
// value is "foo/bar/baz.fbs").
std::string schema_name;
// The filename of where the included file was found, after searching the
// relative paths plus any other paths included with `flatc -I ...`. Note,
// while this is sometimes the same as schema_name, it is not always, since it
// can be defined relative to where flatc was invoked.
std::string filename;
};
// Since IncludedFile is contained within a std::set, need to provide ordering.
inline bool operator<(const IncludedFile &a, const IncludedFile &b) {
return a.filename < b.filename;
}
// Container of options that may apply to any of the source/text generators.
struct IDLOptions {
// field case style options for C++
@@ -914,7 +944,7 @@ class Parser : public ParserState {
// Get the set of included files that are directly referenced by the file
// being parsed. This does not include files that are transitively included by
// others includes.
std::vector<std::string> GetIncludedFiles() const;
std::vector<IncludedFile> GetIncludedFiles() const;
private:
class ParseDepthGuard;
@@ -1043,7 +1073,7 @@ class Parser : public ParserState {
std::string file_extension_;
std::map<uint64_t, std::string> included_files_;
std::map<std::string, std::set<std::string>> files_included_per_file_;
std::map<std::string, std::set<IncludedFile>> files_included_per_file_;
std::vector<std::string> native_included_files_;
std::map<std::string, bool> known_attributes_;

View File

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

View File

@@ -46,6 +46,7 @@
#include <span>
#elif defined(__cpp_lib_span) && defined(__has_include)
#if __has_include(<span>)
#include <array>
#include <span>
#define FLATBUFFERS_USE_STD_SPAN
#endif
@@ -292,7 +293,7 @@ namespace internal {
// > to a pointer to an array of To.
// This helper is used for checking of 'From -> const From'.
template<class To, std::size_t Extent, class From, std::size_t N>
struct is_span_convertable {
struct is_span_convertible {
using type =
typename std::conditional<std::is_convertible<From (*)[], To (*)[]>::value
&& (Extent == dynamic_extent || N == Extent),
@@ -414,7 +415,7 @@ class span FLATBUFFERS_FINAL_CLASS {
// extent == 0 || extent == flatbuffers::dynamic_extent.
// A dummy template argument N is need dependency for SFINAE.
template<std::size_t N = 0,
typename internal::is_span_convertable<element_type, Extent, element_type, (N - N)>::type = 0>
typename internal::is_span_convertible<element_type, Extent, element_type, (N - N)>::type = 0>
FLATBUFFERS_CONSTEXPR_CPP11 span() FLATBUFFERS_NOEXCEPT : data_(nullptr),
count_(0) {
static_assert(extent == 0 || extent == dynamic_extent, "invalid span");
@@ -427,12 +428,12 @@ class span FLATBUFFERS_FINAL_CLASS {
// std::remove_pointer_t<decltype(std::data(arr))>(*)[]
// is convertible to element_type (*)[].
template<std::size_t N,
typename internal::is_span_convertable<element_type, Extent, element_type, N>::type = 0>
typename internal::is_span_convertible<element_type, Extent, element_type, N>::type = 0>
FLATBUFFERS_CONSTEXPR_CPP11 span(element_type (&arr)[N]) FLATBUFFERS_NOEXCEPT
: data_(arr), count_(N) {}
template<class U, std::size_t N,
typename internal::is_span_convertable<element_type, Extent, U, N>::type = 0>
typename internal::is_span_convertible<element_type, Extent, U, N>::type = 0>
FLATBUFFERS_CONSTEXPR_CPP11 span(std::array<U, N> &arr) FLATBUFFERS_NOEXCEPT
: data_(arr.data()), count_(N) {}
@@ -442,7 +443,7 @@ class span FLATBUFFERS_FINAL_CLASS {
// : data_(arr.data()), count_(N) {}
template<class U, std::size_t N,
typename internal::is_span_convertable<element_type, Extent, U, N>::type = 0>
typename internal::is_span_convertible<element_type, Extent, U, N>::type = 0>
FLATBUFFERS_CONSTEXPR_CPP11 span(const std::array<U, N> &arr) FLATBUFFERS_NOEXCEPT
: data_(arr.data()), count_(N) {}
@@ -452,7 +453,7 @@ class span FLATBUFFERS_FINAL_CLASS {
// if extent == std::dynamic_extent || N == extent is true and U (*)[]
// is convertible to element_type (*)[].
template<class U, std::size_t N,
typename internal::is_span_convertable<element_type, Extent, U, N>::type = 0>
typename internal::is_span_convertible<element_type, Extent, U, N>::type = 0>
FLATBUFFERS_CONSTEXPR_CPP11 span(const flatbuffers::span<U, N> &s) FLATBUFFERS_NOEXCEPT
: span(s.data(), s.size()) {
}

View File

@@ -255,7 +255,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.
__supress_ubsan__("float-cast-overflow")
__suppress_ubsan__("float-cast-overflow")
inline void strtoval_impl(float *val, const char *str, char **endptr) {
*val = __strtof_impl(str, endptr);
}

View File

@@ -24,7 +24,7 @@
namespace flatbuffers {
// This is a minimal replication of std::vector<uint8_t> functionality,
// except growing from higher to lower addresses. i.e push_back() inserts data
// except growing from higher to lower addresses. i.e. push_back() inserts data
// in the lowest address in the vector.
// Since this vector leaves the lower part unused, we support a "scratch-pad"
// that can be stored there for temporary data, to share the allocated space.

View File

@@ -25,22 +25,35 @@ namespace flatbuffers {
// Helper class to verify the integrity of a FlatBuffer
class Verifier FLATBUFFERS_FINAL_CLASS {
public:
Verifier(const uint8_t *const buf, const size_t buf_len,
const uoffset_t _max_depth = 64,
const uoffset_t _max_tables = 1000000,
const bool _check_alignment = true)
: buf_(buf),
size_(buf_len),
max_depth_(_max_depth),
max_tables_(_max_tables),
check_alignment_(_check_alignment),
upper_bound_(0),
depth_(0),
num_tables_(0),
flex_reuse_tracker_(nullptr) {
struct Options {
// The maximum nesting of tables and vectors before we call it invalid.
uoffset_t max_depth = 64;
// The maximum number of tables we will verify before we call it invalid.
uoffset_t max_tables = 1000000;
// If true, verify all data is aligned.
bool check_alignment = true;
// If true, run verifier on nested flatbuffers
bool check_nested_flatbuffers = true;
};
explicit Verifier(const uint8_t *const buf, const size_t buf_len,
const Options &opts)
: buf_(buf), size_(buf_len), opts_(opts) {
FLATBUFFERS_ASSERT(size_ < FLATBUFFERS_MAX_BUFFER_SIZE);
}
// Deprecated API, please construct with Verifier::Options.
Verifier(const uint8_t *const buf, const size_t buf_len,
const uoffset_t max_depth = 64, const uoffset_t max_tables = 1000000,
const bool check_alignment = true)
: Verifier(buf, buf_len, [&] {
Options opts;
opts.max_depth = max_depth;
opts.max_tables = max_tables;
opts.check_alignment = check_alignment;
return opts;
}()) {}
// Central location where any verification failures register.
bool Check(const bool ok) const {
// clang-format off
@@ -68,7 +81,7 @@ class Verifier FLATBUFFERS_FINAL_CLASS {
}
bool VerifyAlignment(const size_t elem, const size_t align) const {
return Check((elem & (align - 1)) == 0 || !check_alignment_);
return Check((elem & (align - 1)) == 0 || !opts_.check_alignment);
}
// Verify a range indicated by sizeof(T).
@@ -126,8 +139,8 @@ class Verifier FLATBUFFERS_FINAL_CLASS {
const auto veco = static_cast<size_t>(vec - buf_);
// Check we can read the size field.
if (!Verify<uoffset_t>(veco)) return false;
// Check the whole array. If this is a string, the byte past the array
// must be 0.
// Check the whole array. If this is a string, the byte past the array must
// be 0.
const auto size = ReadScalar<uoffset_t>(vec);
const auto max_elems = FLATBUFFERS_MAX_BUFFER_SIZE / elem_size;
if (!Check(size < max_elems))
@@ -158,7 +171,7 @@ class Verifier FLATBUFFERS_FINAL_CLASS {
return true;
}
__supress_ubsan__("unsigned-integer-overflow") bool VerifyTableStart(
__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_);
@@ -204,11 +217,14 @@ class Verifier FLATBUFFERS_FINAL_CLASS {
template<typename T>
bool VerifyNestedFlatBuffer(const Vector<uint8_t> *const buf,
const char *const identifier) {
// Caller opted out of this.
if (!opts_.check_nested_flatbuffers) return true;
// An empty buffer is OK as it indicates not present.
if (!buf) return true;
// If there is a nested buffer, it must be greater than the min size.
if(!Check(buf->size() >= FLATBUFFERS_MIN_BUFFER_SIZE)) return false;
if (!Check(buf->size() >= FLATBUFFERS_MIN_BUFFER_SIZE)) return false;
Verifier nested_verifier(buf->data(), buf->size());
return nested_verifier.VerifyBuffer<T>(identifier);
@@ -247,13 +263,12 @@ class Verifier FLATBUFFERS_FINAL_CLASS {
}
// Called at the start of a table to increase counters measuring data
// structure depth and amount, and possibly bails out with false if
// limits set by the constructor have been hit. Needs to be balanced
// with EndTable().
// structure depth and amount, and possibly bails out with false if limits set
// by the constructor have been hit. Needs to be balanced with EndTable().
bool VerifyComplexity() {
depth_++;
num_tables_++;
return Check(depth_ <= max_depth_ && num_tables_ <= max_tables_);
return Check(depth_ <= opts_.max_depth && num_tables_ <= opts_.max_tables);
}
// Called at the end of a table to pop the depth count.
@@ -288,15 +303,13 @@ class Verifier FLATBUFFERS_FINAL_CLASS {
private:
const uint8_t *buf_;
const size_t size_;
const uoffset_t max_depth_;
const uoffset_t max_tables_;
const bool check_alignment_;
const Options opts_;
mutable size_t upper_bound_;
mutable size_t upper_bound_ = 0;
uoffset_t depth_;
uoffset_t num_tables_;
std::vector<uint8_t> *flex_reuse_tracker_;
uoffset_t depth_ = 0;
uoffset_t num_tables_ = 0;
std::vector<uint8_t> *flex_reuse_tracker_ = nullptr;
};
} // namespace flatbuffers

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

View File

@@ -451,7 +451,7 @@ public class FlexBuffersBuilder {
/**
* Finishes a vector, but writing the information in the buffer
* @param key key used to store element in map
* @param start reference for begining of the vector. Returned by {@link startVector()}
* @param start reference for beginning of the vector. Returned by {@link startVector()}
* @param typed boolean indicating whether vector is typed
* @param fixed boolean indicating whether vector is fixed
* @return Reference to the vector
@@ -602,7 +602,7 @@ public class FlexBuffersBuilder {
/**
* Finishes a map, but writing the information in the buffer
* @param key key used to store element in map
* @param start reference for begining of the map. Returned by {@link startMap()}
* @param start reference for beginning of the map. Returned by {@link startMap()}
* @return Reference to the map
*/
public int endMap(String key, int start) {

View File

@@ -32,6 +32,6 @@ namespace 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_2_0_0() {}
public static void FLATBUFFERS_2_0_8() {}
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "flatbuffers",
"version": "2.0.6",
"version": "2.0.8",
"description": "Memory Efficient Serialization Library",
"files": [
"js/**/*.js",
@@ -17,7 +17,7 @@
},
"scripts": {
"test": "npm run compile && cd tests && python3 ./TypeScriptTest.py",
"compile": "tsc && tsc -p tsconfig.mjs.json",
"compile": "tsc && tsc -p tsconfig.mjs.json && rollup -c",
"prepublishOnly": "npm install --only=dev && npm run compile"
},
"repository": {
@@ -40,6 +40,7 @@
"@typescript-eslint/eslint-plugin": "^4.12.0",
"@typescript-eslint/parser": "^4.12.0",
"eslint": "^7.17.0",
"rollup": "^2.78.0",
"typescript": "^4.5.5"
}
}

View File

@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.flatbuffers</groupId>
<artifactId>flatbuffers-java</artifactId>
<version>2.0.3</version>
<version>2.0.8</version>
<packaging>bundle</packaging>
<name>FlatBuffers Java API</name>
<description>
@@ -13,6 +13,10 @@
<developer>
<name>Wouter van Oortmerssen</name>
</developer>
<developer>
<name>Derek Bailey</name>
<email>dbaileychess@gmail.com</email>
</developer>
</developers>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

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

8
rollup.config.js Normal file
View File

@@ -0,0 +1,8 @@
export default {
input: 'mjs/index.js',
output: {
file: 'flatbuffers.js',
format: 'iife',
name: 'flatbuffers'
}
}

View File

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

View File

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

View File

@@ -74,6 +74,15 @@ static std::string GenIncludeGuard(const std::string &file_name,
return guard;
}
static bool IsVectorOfPointers(const FieldDef& field) {
const auto& type = field.value.type;
const auto& vector_type = type.VectorType();
return type.base_type == BASE_TYPE_VECTOR &&
vector_type.base_type == BASE_TYPE_STRUCT &&
!vector_type.struct_def->fixed &&
!field.native_inline;
}
namespace cpp {
enum CppStandard { CPP_STD_X0 = 0, CPP_STD_11, CPP_STD_17 };
@@ -233,37 +242,24 @@ class CppGenerator : public BaseGenerator {
}
// Get the directly included file of the file being parsed.
std::vector<std::string> included_files(parser_.GetIncludedFiles());
std::vector<IncludedFile> included_files(parser_.GetIncludedFiles());
// We are safe to sort them alphabetically, since there shouldn't be any
// interdependence between them.
std::stable_sort(included_files.begin(), included_files.end());
// The absolute path of the file being parsed.
const std::string parsed_path =
flatbuffers::StripFileName(AbsolutePath(parser_.file_being_parsed_));
for (const IncludedFile &included_file : included_files) {
// Get the name of the included file as defined by the schema, and strip
// the .fbs extension.
const std::string name_without_ext =
flatbuffers::StripExtension(included_file.schema_name);
for (const std::string &included_file : included_files) {
// The base name of the file, without path or extensions.
std::string basename =
flatbuffers::StripPath(flatbuffers::StripExtension(included_file));
// If we are keeping the prefix
if (opts_.keep_prefix) {
// The absolute path of the included file.
const std::string included_path =
flatbuffers::StripFileName(AbsolutePath(included_file));
// The relative path of the parsed file to the included file.
const std::string relative_path =
RelativeToRootPath(parsed_path, included_path).substr(2);
// Only consider cases where the included path is a subdirectory of the
// parsed path.
if (strncmp("..", relative_path.c_str(), 2) != 0) {
basename = relative_path + kPathSeparator + basename;
}
}
// If we are told to keep the prefix of the included schema, leave it
// unchanged, otherwise strip the leading path off so just the "basename"
// of the include is retained.
const std::string basename =
opts_.keep_prefix ? name_without_ext
: flatbuffers::StripPath(name_without_ext);
code_ += "#include \"" +
GeneratedFileName(opts_.include_prefix, basename, opts_) + "\"";
@@ -898,7 +894,9 @@ class CppGenerator : public BaseGenerator {
}
} else {
const auto nn = WrapNativeNameInNameSpace(*type.struct_def, opts_);
return forcopy ? nn : GenTypeNativePtr(nn, &field, false);
return (forcopy || field.native_inline)
? nn
: GenTypeNativePtr(nn, &field, false);
}
}
case BASE_TYPE_UNION: {
@@ -1884,9 +1882,7 @@ class CppGenerator : public BaseGenerator {
if (vec_type.base_type == BASE_TYPE_UTYPE) continue;
const auto cpp_type = field.attributes.Lookup("cpp_type");
const auto cpp_ptr_type = field.attributes.Lookup("cpp_ptr_type");
const bool is_ptr =
(vec_type.base_type == BASE_TYPE_STRUCT && !IsStruct(vec_type)) ||
(cpp_type && cpp_ptr_type->constant != "naked");
const bool is_ptr = IsVectorOfPointers(field) || (cpp_type && cpp_ptr_type->constant != "naked");
if (is_ptr) { return true; }
}
}
@@ -2010,9 +2006,7 @@ class CppGenerator : public BaseGenerator {
? cpp_type->constant
: GenTypeNative(vec_type, /*invector*/ true,
field, /*forcopy*/ true);
const bool is_ptr =
(vec_type.base_type == BASE_TYPE_STRUCT && !IsStruct(vec_type)) ||
(cpp_type && cpp_ptr_type->constant != "naked");
const bool is_ptr = IsVectorOfPointers(field) || (cpp_type && cpp_ptr_type->constant != "naked");
CodeWriter cw(" ");
cw.SetValue("FIELD", Name(field));
cw.SetValue("TYPE", type_name);
@@ -2091,9 +2085,7 @@ class CppGenerator : public BaseGenerator {
// If the field is a vector of tables, the table need to be compared
// by value, instead of by the default unique_ptr == operator which
// compares by address.
if (field.value.type.base_type == BASE_TYPE_VECTOR &&
field.value.type.element == BASE_TYPE_STRUCT &&
!field.value.type.struct_def->fixed) {
if (IsVectorOfPointers(field)) {
const auto type =
GenTypeNative(field.value.type.VectorType(), true, field);
const auto equal_length =
@@ -2992,7 +2984,8 @@ class CppGenerator : public BaseGenerator {
return ptype + "(new " + name + "(*" + val + "))";
}
} else {
const auto ptype = GenTypeNativePtr(
std::string ptype = afield.native_inline ? "*" : "";
ptype += GenTypeNativePtr(
WrapNativeNameInNameSpace(*type.struct_def, opts_), &afield,
true);
return ptype + "(" + val + "->UnPack(_resolver))";
@@ -3079,9 +3072,7 @@ class CppGenerator : public BaseGenerator {
} else {
// clang-format off
#if FLATBUFFERS_CPP_OBJECT_UNPACKTO
const bool is_pointer =
field.value.type.VectorType().base_type == BASE_TYPE_STRUCT &&
!IsStruct(field.value.type.VectorType());
const bool is_pointer = IsVectorOfPointers(field);
if (is_pointer) {
code += "if(_o->" + name + "[_i]" + ") { ";
code += indexing + "->UnPackTo(_o->" + name +
@@ -3144,9 +3135,7 @@ class CppGenerator : public BaseGenerator {
// _o->field = value;
// clang-format off
#if FLATBUFFERS_CPP_OBJECT_UNPACKTO
const bool is_pointer =
field.value.type.base_type == BASE_TYPE_STRUCT &&
!IsStruct(field.value.type);
const bool is_pointer = IsVectorOfPointers(field);
if (is_pointer) {
code += "{ if(_o->" + Name(field) + ") { ";
code += "_e->UnPackTo(_o->" + Name(field) + ".get(), _resolver);";
@@ -3264,9 +3253,13 @@ class CppGenerator : public BaseGenerator {
code += "(" + value + ".size(), ";
code += "[](size_t i, _VectorArgs *__va) { ";
code += "return Create" + vector_type.struct_def->name;
code += "(*__va->__fbb, __va->_" + value + "[i]" +
GenPtrGet(field) + ", ";
code += "__va->__rehasher); }, &_va )";
code += "(*__va->__fbb, ";
if (field.native_inline) {
code += "&(__va->_" + value + "[i])";
} else {
code += "__va->_" + value + "[i]" + GenPtrGet(field);
}
code += ", __va->__rehasher); }, &_va )";
}
break;
}
@@ -3355,8 +3348,9 @@ class CppGenerator : public BaseGenerator {
// _o->field ? CreateT(_fbb, _o->field.get(), _rehasher);
const auto type = field.value.type.struct_def->name;
code += value + " ? Create" + type;
code += "(_fbb, " + value + GenPtrGet(field) + ", _rehasher)";
code += " : 0";
code += "(_fbb, " + value;
if (!field.native_inline) code += GenPtrGet(field);
code += ", _rehasher) : 0";
}
break;
}

View File

@@ -651,11 +651,11 @@ class CSharpGenerator : public BaseGenerator {
code += " public ByteBuffer ByteBuffer { get { return __p.bb; } }\n";
if (!struct_def.fixed) {
// Generate verson check method.
// Generate version check method.
// Force compile time error if not using the same version runtime.
code += " public static void ValidateVersion() {";
code += " FlatBufferConstants.";
code += "FLATBUFFERS_2_0_0(); ";
code += "FLATBUFFERS_2_0_8(); ";
code += "}\n";
// Generate a special accessor for the table that when used as the root

View File

@@ -661,11 +661,11 @@ class JavaGenerator : public BaseGenerator {
code += " {\n";
if (!struct_def.fixed) {
// Generate verson check method.
// Generate version check method.
// Force compile time error if not using the same version runtime.
code += " public static void ValidateVersion() {";
code += " Constants.";
code += "FLATBUFFERS_2_0_0(); ";
code += "FLATBUFFERS_2_0_8(); ";
code += "}\n";
// Generate a special accessor for the table that when used as the root
@@ -1658,11 +1658,15 @@ class JavaGenerator : public BaseGenerator {
field.value.type.struct_def == nullptr
? "builder.add" + GenMethod(field.value.type.VectorType()) +
"(" + variable + "[_j]);"
: type_name + ".pack(builder, " + variable + "[_j]);";
: "_unused_offset = " + type_name + ".pack(builder, " +
variable + "[_j]);";
code += " int _" + field_name + " = 0;\n";
code += " " + element_type_name + "[] " + variable + " = _o." +
get_field + "();\n";
code += " if (" + variable + " != null) {\n";
if (field.value.type.struct_def != nullptr) {
code += " int _unused_offset = 0;\n";
}
code += " " + namer_.Method("start", field) +
"Vector(builder, " + variable + ".length);\n";
code += " for (int _j = " + variable +

View File

@@ -500,12 +500,12 @@ class KotlinGenerator : public BaseGenerator {
if (!struct_def.fixed) {
FieldDef *key_field = nullptr;
// Generate verson check method.
// Generate version check method.
// Force compile time error if not using the same version
// runtime.
GenerateFunOneLine(
writer, "validateVersion", "", "",
[&]() { writer += "Constants.FLATBUFFERS_2_0_0()"; },
[&]() { writer += "Constants.FLATBUFFERS_2_0_8()"; },
options.gen_jvmstatic);
GenerateGetRootAsAccessors(namer_.Type(struct_def), writer, options);

View File

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

View File

@@ -23,6 +23,7 @@
#include "flatbuffers/flatbuffers.h"
#include "flatbuffers/idl.h"
#include "flatbuffers/util.h"
#include "idl_namer.h"
namespace flatbuffers {
namespace {
@@ -37,7 +38,50 @@ struct ImportDefinition {
const Definition *dependency = nullptr;
};
Namer::Config TypeScriptDefaultConfig() {
return { /*types=*/Case::kKeep,
/*constants=*/Case::kUnknown,
/*methods=*/Case::kLowerCamel,
/*functions=*/Case::kLowerCamel,
/*fields=*/Case::kLowerCamel,
/*variables=*/Case::kLowerCamel,
/*variants=*/Case::kKeep,
/*enum_variant_seperator=*/"::",
/*escape_keywords=*/Namer::Config::Escape::AfterConvertingCase,
/*namespaces=*/Case::kKeep,
/*namespace_seperator=*/"_",
/*object_prefix=*/"",
/*object_suffix=*/"T",
/*keyword_prefix=*/"",
/*keyword_suffix=*/"_",
/*filenames=*/Case::kDasher,
/*directories=*/Case::kDasher,
/*output_path=*/"",
/*filename_suffix=*/"_generated",
/*filename_extension=*/".ts" };
}
std::set<std::string> TypescriptKeywords() {
// List of keywords retrieved from here:
// https://github.com/microsoft/TypeScript/issues/2536
return {
"arguments", "break", "case", "catch", "class", "const",
"continue", "debugger", "default", "delete", "do", "else",
"enum", "export", "extends", "false", "finally", "for",
"function", "if", "import", "in", "instanceof", "new",
"null", "Object", "return", "super", "switch", "this",
"throw", "true", "try", "typeof", "var", "void",
"while", "with", "as", "implements", "interface", "let",
"package", "private", "protected", "public", "static", "yield",
};
}
enum AnnotationType { kParam = 0, kType = 1, kReturns = 2 };
template<typename T> struct SupportsObjectAPI : std::false_type {};
template<> struct SupportsObjectAPI<StructDef> : std::true_type {};
} // namespace
namespace ts {
@@ -49,67 +93,10 @@ class TsGenerator : public BaseGenerator {
TsGenerator(const Parser &parser, const std::string &path,
const std::string &file_name)
: BaseGenerator(parser, path, file_name, "", "_", "ts") {
// clang-format off
: BaseGenerator(parser, path, file_name, "", "_", "ts"),
namer_(WithFlagOptions(TypeScriptDefaultConfig(), parser.opts, path),
TypescriptKeywords()) {}
// List of keywords retrieved from here:
// https://github.com/microsoft/TypeScript/issues/2536
// One per line to ease comparisons to that list are easier
static const char *const keywords[] = {
"arguments",
"break",
"case",
"catch",
"class",
"const",
"continue",
"debugger",
"default",
"delete",
"do",
"else",
"enum",
"export",
"extends",
"false",
"finally",
"for",
"function",
"if",
"import",
"in",
"instanceof",
"new",
"null",
"Object",
"return",
"super",
"switch",
"this",
"throw",
"true",
"try",
"typeof",
"var",
"void",
"while",
"with",
"as",
"implements",
"interface",
"let",
"package",
"private",
"protected",
"public",
"static",
"yield",
nullptr,
// clang-format on
};
for (auto kw = keywords; *kw; kw++) keywords_.insert(*kw);
}
bool generate() {
generateEnums();
generateStructs();
@@ -125,29 +112,27 @@ class TsGenerator : public BaseGenerator {
std::string GetTypeName(const EnumDef &def, const bool = false,
const bool force_ns_wrap = false) {
std::string base_name = def.name;
if (IncludeNamespace() || force_ns_wrap) {
base_name = WrapInNameSpace(def.defined_namespace, base_name);
return namer_.NamespacedType(def);
}
return EscapeKeyword(base_name);
return namer_.Type(def);
}
std::string GetTypeName(const StructDef &def, const bool object_api = false,
const bool force_ns_wrap = false) {
std::string base_name = def.name;
if (object_api && parser_.opts.generate_object_based_api) {
base_name =
parser_.opts.object_prefix + base_name + parser_.opts.object_suffix;
if (IncludeNamespace() || force_ns_wrap) {
return namer_.NamespacedObjectType(def);
} else {
return namer_.ObjectType(def);
}
} else {
if (IncludeNamespace() || force_ns_wrap) {
return namer_.NamespacedType(def);
} else {
return namer_.Type(def);
}
}
if (IncludeNamespace() || force_ns_wrap) {
base_name = WrapInNameSpace(def.defined_namespace, base_name);
}
return EscapeKeyword(base_name);
}
// Save out the generated code for a single class while adding
@@ -182,20 +167,16 @@ class TsGenerator : public BaseGenerator {
flat_file_definitions_.insert(&definition);
return true;
} else {
auto basename =
NamespaceDir(*definition.defined_namespace, true) +
ConvertCase(definition.name, Case::kDasher, Case::kUpperCamel);
auto dirs = namer_.Directories(*definition.defined_namespace);
EnsureDirExists(dirs);
auto basename = dirs + namer_.File(definition, SkipFile::Suffix);
return SaveFile((basename + ".ts").c_str(), code, false);
return SaveFile(basename.c_str(), code, false);
}
}
private:
std::unordered_set<std::string> keywords_;
std::string EscapeKeyword(const std::string &name) const {
return keywords_.find(name) == keywords_.end() ? name : name + "_";
}
IdlNamer namer_;
import_set imports_all_;
@@ -278,8 +259,8 @@ class TsGenerator : public BaseGenerator {
"./" + flatbuffers::StripExtension(include_file);
code += "import {";
for (const auto &pair : it.second) {
code += EscapeKeyword(pair.first) + " as " +
EscapeKeyword(pair.second) + ", ";
code += namer_.EscapeKeyword(pair.first) + " as " +
namer_.EscapeKeyword(pair.second) + ", ";
}
code.resize(code.size() - 2);
code += "} from '" + include_name + "';\n";
@@ -342,15 +323,13 @@ class TsGenerator : public BaseGenerator {
GenDocComment(ev.doc_comment, code_ptr, " ");
}
const std::string escaped_name = EscapeKeyword(ev.name);
// Generate mapping between EnumName: EnumValue(int)
if (reverse) {
code += " '" + enum_def.ToString(ev) + "'";
code += " = ";
code += "'" + escaped_name + "'";
code += "'" + namer_.Variant(ev) + "'";
} else {
code += " " + escaped_name;
code += " " + namer_.Variant(ev);
code += " = ";
// Unfortunately, because typescript does not support bigint enums,
// for 64-bit enums, we instead map the enum names to strings.
@@ -407,8 +386,8 @@ class TsGenerator : public BaseGenerator {
return GenBBAccess() + ".__union_with_string" + arguments;
case BASE_TYPE_VECTOR: return GenGetter(type.VectorType(), arguments);
default: {
auto getter = GenBBAccess() + ".read" +
ConvertCase(GenType(type), Case::kUpperCamel) + arguments;
auto getter = GenBBAccess() + "." +
namer_.Method("read_" + GenType(type)) + arguments;
if (type.base_type == BASE_TYPE_BOOL) { getter = "!!" + getter; }
return getter;
}
@@ -436,7 +415,7 @@ class TsGenerator : public BaseGenerator {
return AddImport(imports, *value.type.enum_def,
*value.type.enum_def)
.name +
"." + EscapeKeyword(val->name);
"." + namer_.Variant(*val);
} else {
return value.constant;
}
@@ -497,7 +476,7 @@ class TsGenerator : public BaseGenerator {
}
// Returns the method name for use with add/put calls.
static std::string GenWriteMethod(const Type &type) {
std::string GenWriteMethod(const Type &type) {
// Forward to signed versions since unsigned versions don't exist
switch (type.base_type) {
case BASE_TYPE_UTYPE:
@@ -508,9 +487,8 @@ class TsGenerator : public BaseGenerator {
default: break;
}
return IsScalar(type.base_type)
? ConvertCase(GenType(type), Case::kUpperCamel)
: (IsStruct(type) ? "Struct" : "Offset");
return IsScalar(type.base_type) ? namer_.Type(GenType(type))
: (IsStruct(type) ? "Struct" : "Offset");
}
template<typename T> static std::string MaybeAdd(T value) {
@@ -540,8 +518,8 @@ class TsGenerator : public BaseGenerator {
}
}
static void GenStructBody(const StructDef &struct_def, std::string *body,
const std::string &nameprefix) {
void GenStructBody(const StructDef &struct_def, std::string *body,
const std::string &nameprefix) {
*body += " builder.prep(";
*body += NumToString(struct_def.minalign) + ", ";
*body += NumToString(struct_def.bytesize) + ");\n";
@@ -567,7 +545,7 @@ class TsGenerator : public BaseGenerator {
}
std::string GenerateNewExpression(const std::string &object_name) {
return "new " + EscapeKeyword(object_name) + "()";
return "new " + namer_.Type(object_name) + "()";
}
void GenerateRootAccessor(StructDef &struct_def, std::string *code_ptr,
@@ -712,9 +690,9 @@ class TsGenerator : public BaseGenerator {
return symbols_expression;
}
template<typename DefintionT>
template<typename DefinitionT>
ImportDefinition AddImport(import_set &imports, const Definition &dependent,
const DefintionT &dependency) {
const DefinitionT &dependency) {
// The unique name of the dependency, fully qualified in its namespace.
const std::string unique_name = GetTypeName(
dependency, /*object_api = */ false, /*force_ns_wrap=*/true);
@@ -748,8 +726,9 @@ class TsGenerator : public BaseGenerator {
// Strip the leading //
.substr(2);
flat_file_import_declarations_[file][import_name] = name;
if (parser_.opts.generate_object_based_api &&
typeid(dependency) == typeid(StructDef)) {
SupportsObjectAPI<DefinitionT>::value) {
flat_file_import_declarations_[file][import_name + "T"] = object_name;
}
}
@@ -766,14 +745,11 @@ class TsGenerator : public BaseGenerator {
}
if (dep_comps.size() == 0) { rel_file_path += "."; }
const auto &depc_comps = dependency.defined_namespace->components;
for (auto it = depc_comps.begin(); it != depc_comps.end(); it++) {
bare_file_path +=
kPathSeparator + ConvertCase(*it, Case::kDasher, Case::kUpperCamel);
}
bare_file_path +=
kPathSeparator +
ConvertCase(dependency.name, Case::kDasher, Case::kUpperCamel);
namer_.Directories(dependency.defined_namespace->components,
SkipDir::OutputPath) +
namer_.File(dependency, SkipFile::SuffixAndExtension);
rel_file_path += bare_file_path;
ImportDefinition import;
@@ -837,11 +813,11 @@ class TsGenerator : public BaseGenerator {
}
std::string GenUnionConvFuncName(const EnumDef &enum_def) {
return "unionTo" + enum_def.name;
return namer_.Function("unionTo", enum_def);
}
std::string GenUnionListConvFuncName(const EnumDef &enum_def) {
return "unionListTo" + enum_def.name;
return namer_.Function("unionListTo", enum_def);
}
std::string GenUnionConvFunc(const Type &union_type, import_set &imports) {
@@ -868,7 +844,7 @@ class TsGenerator : public BaseGenerator {
const auto &ev = **it;
if (ev.IsZero()) { continue; }
ret += " case '" + ev.name + "': ";
ret += " case '" + namer_.Variant(ev) + "': ";
if (IsString(ev.union_type)) {
ret += "return " + accessor_str + "'') as string;";
@@ -923,11 +899,11 @@ class TsGenerator : public BaseGenerator {
if (!is_array) {
const auto conversion_function = GenUnionConvFuncName(enum_def);
const auto target_enum = "this." + field_name + "Type()";
ret = "(() => {\n";
ret += " let temp = " + conversion_function + "(" + target_enum +
", " + field_binded_method + ");\n";
ret += " let temp = " + conversion_function + "(this." +
namer_.Method(field_name, "Type") + "(), " +
field_binded_method + ");\n";
ret += " if(temp === null) { return null; }\n";
ret += union_has_string
? " if(typeof temp === 'string') { return temp; }\n"
@@ -936,17 +912,15 @@ class TsGenerator : public BaseGenerator {
ret += " })()";
} else {
const auto conversion_function = GenUnionListConvFuncName(enum_def);
const auto target_enum_accesor = "this." + field_name + "Type";
const auto target_enum_length = target_enum_accesor + "Length()";
ret = "(() => {\n";
ret += " let ret = [];\n";
ret += " for(let targetEnumIndex = 0; targetEnumIndex < " +
target_enum_length +
ret += " for(let targetEnumIndex = 0; targetEnumIndex < this." +
namer_.Method(field_name, "TypeLength") + "()" +
"; "
"++targetEnumIndex) {\n";
ret += " let targetEnum = " + target_enum_accesor +
"(targetEnumIndex);\n";
ret += " let targetEnum = this." +
namer_.Method(field_name, "Type") + "(targetEnumIndex);\n";
ret += " if(targetEnum === null || " + enum_type +
"[targetEnum!] === 'NONE') { "
"continue; }\n\n";
@@ -985,11 +959,9 @@ class TsGenerator : public BaseGenerator {
it != struct_def.fields.vec.end(); ++it) {
auto &field = **it;
auto curr_member_accessor =
prefix + "." + ConvertCase(field.name, Case::kLowerCamel);
auto curr_member_accessor = prefix + "." + namer_.Method(field);
if (prefix != "this") {
curr_member_accessor =
prefix + "?." + ConvertCase(field.name, Case::kLowerCamel);
curr_member_accessor = prefix + "?." + namer_.Method(field);
}
if (IsStruct(field.value.type)) {
ret += GenStructMemberValueTS(*field.value.type.struct_def,
@@ -1058,10 +1030,10 @@ class TsGenerator : public BaseGenerator {
auto &field = **it;
if (field.deprecated) continue;
const auto field_name = ConvertCase(field.name, Case::kLowerCamel);
const auto field_name_escaped = EscapeKeyword(field_name);
const auto field_method = namer_.Method(field);
const auto field_field = namer_.Field(field);
const std::string field_binded_method =
"this." + field_name + ".bind(this)";
"this." + field_method + ".bind(this)";
std::string field_val;
std::string field_type;
@@ -1081,14 +1053,14 @@ class TsGenerator : public BaseGenerator {
field_type += GenTypeName(imports, field, field.value.type, false,
has_null_default);
field_val = "this." + field_name + "()";
field_val = "this." + namer_.Method(field) + "()";
if (field.value.type.base_type != BASE_TYPE_STRING) {
field_offset_val = "this." + field_name_escaped;
field_offset_val = "this." + namer_.Field(field);
} else {
field_offset_decl = GenNullCheckConditional(
"this." + field_name_escaped,
"builder.createString(this." + field_name_escaped + "!)", "0");
"this." + namer_.Field(field),
"builder.createString(this." + field_field + "!)", "0");
}
}
@@ -1100,12 +1072,13 @@ class TsGenerator : public BaseGenerator {
const auto &sd = *field.value.type.struct_def;
field_type += AddImport(imports, struct_def, sd).object_name;
const std::string field_accessor = "this." + field_name + "()";
const std::string field_accessor =
"this." + namer_.Method(field) + "()";
field_val = GenNullCheckConditional(field_accessor,
field_accessor + "!.unpack()");
auto packing = GenNullCheckConditional(
"this." + field_name_escaped,
"this." + field_name_escaped + "!.pack(builder)", "0");
"this." + field_field,
"this." + field_field + "!.pack(builder)", "0");
if (sd.fixed) {
field_offset_val = std::move(packing);
@@ -1132,22 +1105,20 @@ class TsGenerator : public BaseGenerator {
field_type += ")[]";
field_val = GenBBAccess() + ".createObjList(" +
field_binded_method + ", this." + field_name +
"Length())";
field_binded_method + ", this." +
namer_.Method(field, "Length") + "())";
if (sd.fixed) {
field_offset_decl =
"builder.createStructOffsetList(this." +
field_name_escaped + ", " +
AddImport(imports, struct_def, struct_def).name +
".start" + ConvertCase(field_name, Case::kUpperCamel) +
"Vector)";
"builder.createStructOffsetList(this." + field_field +
", " + AddImport(imports, struct_def, struct_def).name +
"." + namer_.Method("start", field, "Vector") + ")";
} else {
field_offset_decl =
AddImport(imports, struct_def, struct_def).name +
".create" + ConvertCase(field_name, Case::kUpperCamel) +
"Vector(builder, builder.createObjectOffsetList(" +
"this." + field_name_escaped + "))";
AddImport(imports, struct_def, struct_def).name + "." +
namer_.Method("create", field, "Vector") +
"(builder, builder.createObjectOffsetList(" + "this." +
field_field + "))";
}
break;
@@ -1156,13 +1127,13 @@ class TsGenerator : public BaseGenerator {
case BASE_TYPE_STRING: {
field_type += "string)[]";
field_val = GenBBAccess() + ".createScalarList(" +
field_binded_method + ", this." + field_name +
"Length())";
field_binded_method + ", this." +
namer_.Field(field, "Length") + "())";
field_offset_decl =
AddImport(imports, struct_def, struct_def).name +
".create" + ConvertCase(field_name, Case::kUpperCamel) +
"Vector(builder, builder.createObjectOffsetList(" +
"this." + field_name_escaped + "))";
AddImport(imports, struct_def, struct_def).name + "." +
namer_.Method("create", field, "Vector") +
"(builder, builder.createObjectOffsetList(" + "this." +
namer_.Field(field) + "))";
break;
}
@@ -1170,14 +1141,14 @@ class TsGenerator : public BaseGenerator {
field_type += GenObjApiUnionTypeTS(
imports, struct_def, parser.opts, *(vectortype.enum_def));
field_type += ")[]";
field_val = GenUnionValTS(imports, struct_def, field_name,
field_val = GenUnionValTS(imports, struct_def, field_method,
vectortype, true);
field_offset_decl =
AddImport(imports, struct_def, struct_def).name +
".create" + ConvertCase(field_name, Case::kUpperCamel) +
"Vector(builder, builder.createObjectOffsetList(" +
"this." + field_name_escaped + "))";
AddImport(imports, struct_def, struct_def).name + "." +
namer_.Method("create", field, "Vector") +
"(builder, builder.createObjectOffsetList(" + "this." +
namer_.Field(field) + "))";
break;
}
@@ -1190,13 +1161,13 @@ class TsGenerator : public BaseGenerator {
}
field_type += ")[]";
field_val = GenBBAccess() + ".createScalarList(" +
field_binded_method + ", this." + field_name +
"Length())";
field_binded_method + ", this." +
namer_.Method(field, "Length") + "())";
field_offset_decl =
AddImport(imports, struct_def, struct_def).name +
".create" + ConvertCase(field_name, Case::kUpperCamel) +
"Vector(builder, this." + field_name_escaped + ")";
AddImport(imports, struct_def, struct_def).name + "." +
namer_.Method("create", field, "Vector") +
"(builder, this." + field_field + ")";
break;
}
@@ -1209,10 +1180,10 @@ class TsGenerator : public BaseGenerator {
field_type += GenObjApiUnionTypeTS(imports, struct_def, parser.opts,
*(field.value.type.enum_def));
field_val = GenUnionValTS(imports, struct_def, field_name,
field_val = GenUnionValTS(imports, struct_def, field_method,
field.value.type);
field_offset_decl =
"builder.createObjectOffset(this." + field_name_escaped + ")";
"builder.createObjectOffset(this." + field_field + ")";
break;
}
@@ -1225,16 +1196,16 @@ class TsGenerator : public BaseGenerator {
if (!field_offset_decl.empty()) {
field_offset_decl =
" const " + field_name_escaped + " = " + field_offset_decl + ";";
" const " + field_field + " = " + field_offset_decl + ";";
}
if (field_offset_val.empty()) { field_offset_val = field_name_escaped; }
if (field_offset_val.empty()) { field_offset_val = field_field; }
unpack_func += " " + field_val;
unpack_to_func += " _o." + field_name_escaped + " = " + field_val + ";";
unpack_to_func += " _o." + field_field + " = " + field_val + ";";
// FIXME: if field_type and field_name_escaped are identical, then
// FIXME: if field_type and field_field are identical, then
// this generates invalid typescript.
constructor_func += " public " + field_name_escaped + ": " + field_type +
constructor_func += " public " + field_field + ": " + field_type +
" = " + field_default_val;
if (!struct_def.fixed) {
@@ -1249,9 +1220,9 @@ class TsGenerator : public BaseGenerator {
pack_func_create_call +=
" if (" + field_offset_val + " !== null)\n ";
}
pack_func_create_call += " " + struct_name + ".add" +
ConvertCase(field.name, Case::kUpperCamel) +
"(builder, " + field_offset_val + ");\n";
pack_func_create_call += " " + struct_name + "." +
namer_.Method("add", field) + "(builder, " +
field_offset_val + ");\n";
}
}
@@ -1374,7 +1345,7 @@ class TsGenerator : public BaseGenerator {
const auto has_null_default = is_string || HasNullDefault(field);
GenDocComment(field.doc_comment, code_ptr);
std::string prefix = ConvertCase(field.name, Case::kLowerCamel) + "(";
std::string prefix = namer_.Method(field) + "(";
if (is_string) {
code += prefix + "):string|null\n";
code +=
@@ -1421,7 +1392,7 @@ class TsGenerator : public BaseGenerator {
AddImport(imports, struct_def, *field.value.type.struct_def)
.name;
GenDocComment(field.doc_comment, code_ptr);
code += ConvertCase(field.name, Case::kLowerCamel);
code += namer_.Method(field);
code += "(obj?:" + type + "):" + type + "|null {\n";
if (struct_def.fixed) {
@@ -1461,7 +1432,7 @@ class TsGenerator : public BaseGenerator {
default: ret_type = vectortypename;
}
GenDocComment(field.doc_comment, code_ptr);
std::string prefix = ConvertCase(field.name, Case::kLowerCamel);
std::string prefix = namer_.Method(field);
// TODO: make it work without any
// if (is_union) { prefix += "<T extends flatbuffers.Table>"; }
if (is_union) { prefix += ""; }
@@ -1521,7 +1492,7 @@ class TsGenerator : public BaseGenerator {
case BASE_TYPE_UNION: {
GenDocComment(field.doc_comment, code_ptr);
code += ConvertCase(field.name, Case::kLowerCamel);
code += namer_.Method(field);
const auto &union_enum = *(field.value.type.enum_def);
const auto union_type = GenUnionGenericTypeTS(union_enum);
@@ -1546,12 +1517,15 @@ class TsGenerator : public BaseGenerator {
std::string type =
GenTypeName(imports, struct_def, field.value.type, true);
code += "mutate_" + field.name + "(value:" + type + "):boolean {\n";
code += namer_.LegacyTsMutateMethod(field) + "(value:" + type +
"):boolean {\n";
const std::string write_method =
"." + namer_.Method("write", GenType(field.value.type));
if (struct_def.fixed) {
code += " " + GenBBAccess() + ".write" +
ConvertCase(GenType(field.value.type), Case::kUpperCamel) +
"(this.bb_pos + " + NumToString(field.value.offset) + ", ";
code += " " + GenBBAccess() + write_method + "(this.bb_pos + " +
NumToString(field.value.offset) + ", ";
} else {
code += " const offset = " + GenBBAccess() +
".__offset(this.bb_pos, " + NumToString(field.value.offset) +
@@ -1561,9 +1535,8 @@ class TsGenerator : public BaseGenerator {
code += " }\n\n";
// special case for bools, which are treated as uint8
code += " " + GenBBAccess() + ".write" +
ConvertCase(GenType(field.value.type), Case::kUpperCamel) +
"(this.bb_pos + offset, ";
code +=
" " + GenBBAccess() + write_method + "(this.bb_pos + offset, ";
if (field.value.type.base_type == BASE_TYPE_BOOL) { code += "+"; }
}
@@ -1576,8 +1549,8 @@ class TsGenerator : public BaseGenerator {
if (IsVector(field.value.type)) {
// Emit a length helper
GenDocComment(code_ptr);
code += ConvertCase(field.name, Case::kLowerCamel);
code += "Length():number {\n" + offset_prefix;
code += namer_.Method(field, "Length");
code += "():number {\n" + offset_prefix;
code +=
GenBBAccess() + ".__vector_len(this.bb_pos + offset) : 0;\n}\n\n";
@@ -1587,9 +1560,9 @@ class TsGenerator : public BaseGenerator {
if (IsScalar(vectorType.base_type) && !IsLong(vectorType.base_type)) {
GenDocComment(code_ptr);
code += ConvertCase(field.name, Case::kLowerCamel);
code += "Array():" + GenType(vectorType) + "Array|null {\n" +
offset_prefix;
code += namer_.Method(field, "Array");
code +=
"():" + GenType(vectorType) + "Array|null {\n" + offset_prefix;
code += "new " + GenType(vectorType) + "Array(" + GenBBAccess() +
".bytes().buffer, " + GenBBAccess() +
@@ -1648,7 +1621,7 @@ class TsGenerator : public BaseGenerator {
// Generate the field insertion method
GenDocComment(code_ptr);
code += "static add" + ConvertCase(field.name, Case::kUpperCamel);
code += "static " + namer_.Method("add", field);
code += "(builder:flatbuffers.Builder, " + argname + ":" +
GetArgType(imports, struct_def, field, false) + ") {\n";
code += " builder.addField" + GenWriteMethod(field.value.type) + "(";
@@ -1679,8 +1652,8 @@ class TsGenerator : public BaseGenerator {
GenDocComment(code_ptr);
const std::string sig_begin =
"static create" + ConvertCase(field.name, Case::kUpperCamel) +
"Vector(builder:flatbuffers.Builder, data:";
"static " + namer_.Method("create", field, "Vector") +
"(builder:flatbuffers.Builder, data:";
const std::string sig_end = "):flatbuffers.Offset";
std::string type =
GenTypeName(imports, struct_def, vector_type, true) + "[]";
@@ -1717,8 +1690,9 @@ class TsGenerator : public BaseGenerator {
// after
GenDocComment(code_ptr);
code += "static start" + ConvertCase(field.name, Case::kUpperCamel);
code += "Vector(builder:flatbuffers.Builder, numElems:number) {\n";
code += "static ";
code += namer_.Method("start", field, "Vector");
code += "(builder:flatbuffers.Builder, numElems:number) {\n";
code += " builder.startVector(" + NumToString(elem_size);
code += ", numElems, " + NumToString(alignment) + ");\n";
code += "}\n\n";
@@ -1776,8 +1750,7 @@ class TsGenerator : public BaseGenerator {
code += " if (" + arg_name + " !== null)\n ";
}
code += " " + methodPrefix + ".add" +
ConvertCase(field.name, Case::kUpperCamel) + "(";
code += " " + methodPrefix + "." + namer_.Method("add", field) + "(";
code += "builder, " + arg_name + ");\n";
}
@@ -1795,8 +1768,8 @@ class TsGenerator : public BaseGenerator {
code += "}\n";
code += "\n";
code += "static deserialize(buffer: Uint8Array):" + EscapeKeyword(name) +
" {\n";
code += "static deserialize(buffer: Uint8Array):" +
namer_.EscapeKeyword(name) + " {\n";
code += " return " + AddImport(imports, struct_def, struct_def).name +
".getRootAs" + name + "(new flatbuffers.ByteBuffer(buffer))\n";
code += "}\n";
@@ -1825,12 +1798,8 @@ class TsGenerator : public BaseGenerator {
}
std::string GetArgName(const FieldDef &field) {
auto argname = ConvertCase(field.name, Case::kLowerCamel);
if (!IsScalar(field.value.type.base_type)) {
argname += "Offset";
} else {
argname = EscapeKeyword(argname);
}
auto argname = namer_.Variable(field);
if (!IsScalar(field.value.type.base_type)) { argname += "Offset"; }
return argname;
}

View File

@@ -33,6 +33,9 @@ class IdlNamer : public Namer {
std::string Type(const EnumDef &d) const { return Type(d.name); }
std::string Function(const Definition &s) const { return Function(s.name); }
std::string Function(const std::string& prefix, const Definition &s) const {
return Function(prefix + s.name);
}
std::string Field(const FieldDef &s) const { return Field(s.name); }
std::string Field(const FieldDef &d, const std::string &s) const {
@@ -131,6 +134,12 @@ class IdlNamer : public Namer {
suffix;
}
// This is a mix of snake case and keep casing, when Ts should be using
// lower camel case.
std::string LegacyTsMutateMethod(const FieldDef& d) {
return "mutate_" + d.name;
}
private:
std::string NamespacedString(const struct Namespace *ns,
const std::string &str) const {

View File

@@ -1153,8 +1153,12 @@ CheckedError Parser::ParseField(StructDef &struct_def) {
"definition");
field->native_inline = field->attributes.Lookup("native_inline") != nullptr;
if (field->native_inline && !IsStruct(field->value.type))
return Error("native_inline can only be defined on structs");
if (field->native_inline && !IsStruct(field->value.type) &&
!IsVectorOfStruct(field->value.type) &&
!IsVectorOfTable(field->value.type))
return Error(
"'native_inline' can only be defined on structs, vector of structs or "
"vector of tables");
auto nested = field->attributes.Lookup("nested_flatbuffer");
if (nested) {
@@ -2545,7 +2549,7 @@ CheckedError Parser::CheckClash(std::vector<FieldDef *> &fields,
return NoError();
}
std::vector<std::string> Parser::GetIncludedFiles() const {
std::vector<IncludedFile> Parser::GetIncludedFiles() const {
const auto it = files_included_per_file_.find(file_being_parsed_);
if (it == files_included_per_file_.end()) { return {}; }
@@ -3435,7 +3439,7 @@ CheckedError Parser::DoParse(const char *source, const char **include_paths,
if (included_files_.find(source_hash) == included_files_.end()) {
included_files_[source_hash] = include_filename ? include_filename : "";
files_included_per_file_[source_filename] = std::set<std::string>();
files_included_per_file_[source_filename] = std::set<IncludedFile>();
} else {
return NoError();
}
@@ -3483,8 +3487,12 @@ CheckedError Parser::DoParse(const char *source, const char **include_paths,
}
if (filepath.empty())
return Error("unable to locate include file: " + name);
if (source_filename)
files_included_per_file_[source_filename].insert(filepath);
if (source_filename) {
IncludedFile included_file;
included_file.filename = filepath;
included_file.schema_name = name;
files_included_per_file_[source_filename].insert(included_file);
}
std::string contents;
bool file_loaded = LoadFile(filepath.c_str(), true, &contents);
@@ -3621,11 +3629,11 @@ std::set<std::string> Parser::GetIncludedFilesRecursive(
// Workaround the lack of const accessor in C++98 maps.
auto &new_files =
(*const_cast<std::map<std::string, std::set<std::string>> *>(
(*const_cast<std::map<std::string, std::set<IncludedFile>> *>(
&files_included_per_file_))[current];
for (auto it = new_files.begin(); it != new_files.end(); ++it) {
if (included_files.find(*it) == included_files.end())
to_process.push_back(*it);
if (included_files.find(it->filename) == included_files.end())
to_process.push_back(it->filename);
}
}
@@ -3675,7 +3683,7 @@ void Parser::Serialize() {
RelativeToRootPath(opts.project_root, f->first));
for (auto i = f->second.begin(); i != f->second.end(); i++) {
included_files.push_back(builder_.CreateSharedString(
RelativeToRootPath(opts.project_root, *i)));
RelativeToRootPath(opts.project_root, i->filename)));
}
const auto included_files__ = builder_.CreateVector(included_files);
included_files.clear();
@@ -4107,7 +4115,9 @@ bool Parser::Deserialize(const reflection::Schema *schema) {
++s) {
for (auto f = s->included_filenames()->begin();
f != s->included_filenames()->end(); ++f) {
files_included_per_file_[s->filename()->str()].insert(f->str());
IncludedFile included_file;
included_file.filename = f->str();
files_included_per_file_[s->filename()->str()].insert(included_file);
}
}

View File

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

View File

@@ -9,20 +9,42 @@ cc_test(
name = "flatbuffers_test",
testonly = 1,
srcs = [
"evolution_test.cpp",
"evolution_test.h",
"evolution_test/evolution_v1_generated.h",
"evolution_test/evolution_v2_generated.h",
"flexbuffers_test.cpp",
"flexbuffers_test.h",
"fuzz_test.cpp",
"fuzz_test.h",
"is_quiet_nan.h",
"json_test.cpp",
"json_test.h",
"monster_test.cpp",
"monster_test.h",
"monster_test_bfbs_generated.h",
"namespace_test/namespace_test1_generated.h",
"namespace_test/namespace_test2_generated.h",
"native_inline_table_test_generated.h",
"native_type_test_impl.cpp",
"native_type_test_impl.h",
"optional_scalars_generated.h",
"optional_scalars_test.cpp",
"optional_scalars_test.h",
"parser_test.cpp",
"parser_test.h",
"proto_test.cpp",
"proto_test.h",
"reflection_test.cpp",
"reflection_test.h",
"test.cpp",
"test_assert.cpp",
"test_assert.h",
"test_builder.cpp",
"test_builder.h",
"union_vector/union_vector_generated.h",
"util_test.cpp",
"util_test.h",
],
copts = [
"-DFLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE",

View File

@@ -9,7 +9,7 @@ import com.google.flatbuffers.*;
@SuppressWarnings("unused")
public final class LongFloatEntry extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static LongFloatEntry getRootAsLongFloatEntry(ByteBuffer _bb) { return getRootAsLongFloatEntry(_bb, new LongFloatEntry()); }
public static LongFloatEntry getRootAsLongFloatEntry(ByteBuffer _bb, LongFloatEntry obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }

View File

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

View File

@@ -9,7 +9,7 @@ import com.google.flatbuffers.*;
@SuppressWarnings("unused")
public final class LongFloatMap extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static LongFloatMap getRootAsLongFloatMap(ByteBuffer _bb) { return getRootAsLongFloatMap(_bb, new LongFloatMap()); }
public static LongFloatMap getRootAsLongFloatMap(ByteBuffer _bb, LongFloatMap obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }

View File

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

View File

@@ -237,7 +237,7 @@ public struct MyGame_Example_AnyAmbiguousAliasesUnion {
}
public struct MyGame_Example_Test: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _a: Int16
private var _b: Int8
@@ -291,7 +291,7 @@ extension MyGame_Example_Test: Encodable {
public struct MyGame_Example_Test_Mutable: FlatBufferObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -318,7 +318,7 @@ public struct MyGame_Example_Test_Mutable: FlatBufferObject {
public struct MyGame_Example_Vec3: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _x: Float32
private var _y: Float32
@@ -413,7 +413,7 @@ extension MyGame_Example_Vec3: Encodable {
public struct MyGame_Example_Vec3_Mutable: FlatBufferObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -447,7 +447,7 @@ public struct MyGame_Example_Vec3_Mutable: FlatBufferObject {
public struct MyGame_Example_Ability: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _id: UInt32
private var _distance: UInt32
@@ -500,7 +500,7 @@ extension MyGame_Example_Ability: Encodable {
public struct MyGame_Example_Ability_Mutable: FlatBufferObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -527,7 +527,7 @@ public struct MyGame_Example_Ability_Mutable: FlatBufferObject {
public struct MyGame_Example_StructOfStructs: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _a: MyGame_Example_Ability
private var _b: MyGame_Example_Test
@@ -587,7 +587,7 @@ extension MyGame_Example_StructOfStructs: Encodable {
public struct MyGame_Example_StructOfStructs_Mutable: FlatBufferObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -613,7 +613,7 @@ public struct MyGame_Example_StructOfStructs_Mutable: FlatBufferObject {
public struct MyGame_Example_StructOfStructsOfStructs: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _a: MyGame_Example_StructOfStructs
@@ -655,7 +655,7 @@ extension MyGame_Example_StructOfStructsOfStructs: Encodable {
public struct MyGame_Example_StructOfStructsOfStructs_Mutable: FlatBufferObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -679,7 +679,7 @@ public struct MyGame_Example_StructOfStructsOfStructs_Mutable: FlatBufferObject
public struct MyGame_InParentNamespace: FlatBufferObject, Verifiable, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
@@ -733,7 +733,7 @@ public class MyGame_InParentNamespaceT: NativeObject {
}
public struct MyGame_Example2_Monster: FlatBufferObject, Verifiable, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
@@ -787,7 +787,7 @@ public class MyGame_Example2_MonsterT: NativeObject {
}
internal struct MyGame_Example_TestSimpleTableWithEnum: FlatBufferObject, Verifiable, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
internal var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
@@ -870,7 +870,7 @@ internal class MyGame_Example_TestSimpleTableWithEnumT: NativeObject {
}
public struct MyGame_Example_Stat: FlatBufferObject, Verifiable, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
@@ -1011,7 +1011,7 @@ public class MyGame_Example_StatT: NativeObject {
}
public struct MyGame_Example_Referrable: FlatBufferObject, Verifiable, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
@@ -1119,7 +1119,7 @@ public class MyGame_Example_ReferrableT: NativeObject {
/// an example documentation comment: "monster object"
public struct MyGame_Example_Monster: FlatBufferObject, Verifiable, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
@@ -2297,7 +2297,7 @@ public class MyGame_Example_MonsterT: NativeObject {
}
public struct MyGame_Example_TypeAliases: FlatBufferObject, Verifiable, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table

View File

@@ -6,7 +6,7 @@
internal struct Message: FlatBufferObject, Verifiable, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
internal var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table

View File

@@ -4,7 +4,7 @@
public struct BytesCount: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _x: Int64
@@ -47,7 +47,7 @@ extension BytesCount: Encodable {
public struct BytesCount_Mutable: FlatBufferObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -72,7 +72,7 @@ public struct BytesCount_Mutable: FlatBufferObject {
public struct InternalMessage: FlatBufferObject, Verifiable, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
@@ -157,7 +157,7 @@ public class InternalMessageT: NativeObject {
}
public struct Message: FlatBufferObject, Verifiable, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table

View File

@@ -32,7 +32,7 @@ extension Color: Encodable {
public struct Test: NativeStruct, Verifiable, FlatbuffersInitializable {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _a: Int16
private var _b: Int8
@@ -81,7 +81,7 @@ extension Test: Encodable {
public struct Test_Mutable: FlatBufferObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -93,7 +93,7 @@ public struct Test_Mutable: FlatBufferObject {
public struct Vec3: NativeStruct, Verifiable, FlatbuffersInitializable {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _x: Float32
private var _y: Float32
@@ -178,7 +178,7 @@ extension Vec3: Encodable {
public struct Vec3_Mutable: FlatBufferObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -195,7 +195,7 @@ public struct Vec3_Mutable: FlatBufferObject {
/// an example documentation comment: "monster object"
public struct Monster: FlatBufferObject, Verifiable {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table

View File

@@ -6,7 +6,7 @@ import FlatBuffers
public struct Property: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _property: Bool
@@ -49,7 +49,7 @@ extension Property: Encodable {
public struct Property_Mutable: FlatBufferObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -74,7 +74,7 @@ public struct Property_Mutable: FlatBufferObject {
public struct TestMutatingBool: FlatBufferObject, Verifiable, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table

View File

@@ -237,7 +237,7 @@ public struct MyGame_Example_AnyAmbiguousAliasesUnion {
}
public struct MyGame_Example_Test: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _a: Int16
private var _b: Int8
@@ -291,7 +291,7 @@ extension MyGame_Example_Test: Encodable {
public struct MyGame_Example_Test_Mutable: FlatBufferObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -318,7 +318,7 @@ public struct MyGame_Example_Test_Mutable: FlatBufferObject {
public struct MyGame_Example_Vec3: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _x: Float32
private var _y: Float32
@@ -413,7 +413,7 @@ extension MyGame_Example_Vec3: Encodable {
public struct MyGame_Example_Vec3_Mutable: FlatBufferObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -447,7 +447,7 @@ public struct MyGame_Example_Vec3_Mutable: FlatBufferObject {
public struct MyGame_Example_Ability: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _id: UInt32
private var _distance: UInt32
@@ -500,7 +500,7 @@ extension MyGame_Example_Ability: Encodable {
public struct MyGame_Example_Ability_Mutable: FlatBufferObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -527,7 +527,7 @@ public struct MyGame_Example_Ability_Mutable: FlatBufferObject {
public struct MyGame_Example_StructOfStructs: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _a: MyGame_Example_Ability
private var _b: MyGame_Example_Test
@@ -587,7 +587,7 @@ extension MyGame_Example_StructOfStructs: Encodable {
public struct MyGame_Example_StructOfStructs_Mutable: FlatBufferObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -613,7 +613,7 @@ public struct MyGame_Example_StructOfStructs_Mutable: FlatBufferObject {
public struct MyGame_Example_StructOfStructsOfStructs: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _a: MyGame_Example_StructOfStructs
@@ -655,7 +655,7 @@ extension MyGame_Example_StructOfStructsOfStructs: Encodable {
public struct MyGame_Example_StructOfStructsOfStructs_Mutable: FlatBufferObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -679,7 +679,7 @@ public struct MyGame_Example_StructOfStructsOfStructs_Mutable: FlatBufferObject
public struct MyGame_InParentNamespace: FlatBufferObject, Verifiable, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
@@ -733,7 +733,7 @@ public class MyGame_InParentNamespaceT: NativeObject {
}
public struct MyGame_Example2_Monster: FlatBufferObject, Verifiable, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
@@ -787,7 +787,7 @@ public class MyGame_Example2_MonsterT: NativeObject {
}
internal struct MyGame_Example_TestSimpleTableWithEnum: FlatBufferObject, Verifiable, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
internal var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
@@ -870,7 +870,7 @@ internal class MyGame_Example_TestSimpleTableWithEnumT: NativeObject {
}
public struct MyGame_Example_Stat: FlatBufferObject, Verifiable, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
@@ -1011,7 +1011,7 @@ public class MyGame_Example_StatT: NativeObject {
}
public struct MyGame_Example_Referrable: FlatBufferObject, Verifiable, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
@@ -1119,7 +1119,7 @@ public class MyGame_Example_ReferrableT: NativeObject {
/// an example documentation comment: "monster object"
public struct MyGame_Example_Monster: FlatBufferObject, Verifiable, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
@@ -2297,7 +2297,7 @@ public class MyGame_Example_MonsterT: NativeObject {
}
public struct MyGame_Example_TypeAliases: FlatBufferObject, Verifiable, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table

View File

@@ -29,7 +29,7 @@ extension ABC: Encodable {
public struct MoreDefaults: FlatBufferObject, Verifiable, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table

View File

@@ -29,7 +29,7 @@ extension optional_scalars_OptionalByte: Encodable {
public struct optional_scalars_ScalarStuff: FlatBufferObject, Verifiable {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table

View File

@@ -120,7 +120,7 @@ public struct GadgetUnion {
}
public struct Rapunzel: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _hairLength: Int32
@@ -163,7 +163,7 @@ extension Rapunzel: Encodable {
public struct Rapunzel_Mutable: FlatBufferObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -188,7 +188,7 @@ public struct Rapunzel_Mutable: FlatBufferObject {
public struct BookReader: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _booksRead: Int32
@@ -231,7 +231,7 @@ extension BookReader: Encodable {
public struct BookReader_Mutable: FlatBufferObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -256,7 +256,7 @@ public struct BookReader_Mutable: FlatBufferObject {
public struct FallingTub: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _weight: Int32
@@ -299,7 +299,7 @@ extension FallingTub: Encodable {
public struct FallingTub_Mutable: FlatBufferObject {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
@@ -324,7 +324,7 @@ public struct FallingTub_Mutable: FlatBufferObject {
public struct Attacker: FlatBufferObject, Verifiable, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
@@ -407,7 +407,7 @@ public class AttackerT: NativeObject {
}
public struct HandFan: FlatBufferObject, Verifiable, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
@@ -490,7 +490,7 @@ public class HandFanT: NativeObject {
}
public struct Movie: FlatBufferObject, Verifiable, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table

View File

@@ -6,7 +6,7 @@ import FlatBuffers
public struct Swift_Tests_Vectors: FlatBufferObject, Verifiable {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -9,7 +9,7 @@ import com.google.flatbuffers.*;
@SuppressWarnings("unused")
public final class ArrayTable extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static ArrayTable getRootAsArrayTable(ByteBuffer _bb) { return getRootAsArrayTable(_bb, new ArrayTable()); }
public static ArrayTable getRootAsArrayTable(ByteBuffer _bb, ArrayTable obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public static boolean ArrayTableBufferHasIdentifier(ByteBuffer _bb) { return __has_identifier(_bb, "ARRT"); }

View File

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

View File

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

View File

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

View File

@@ -12,7 +12,7 @@ import com.google.flatbuffers.*;
*/
@SuppressWarnings("unused")
public final class Monster extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static Monster getRootAsMonster(ByteBuffer _bb) { return getRootAsMonster(_bb, new Monster()); }
public static Monster getRootAsMonster(ByteBuffer _bb, Monster obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public static boolean MonsterBufferHasIdentifier(ByteBuffer _bb) { return __has_identifier(_bb, "MONS"); }
@@ -549,8 +549,9 @@ public final class Monster extends Table {
int _test4 = 0;
MyGame.Example.TestT[] _oTest4 = _o.getTest4();
if (_oTest4 != null) {
int _unused_offset = 0;
startTest4Vector(builder, _oTest4.length);
for (int _j = _oTest4.length - 1; _j >=0; _j--) { MyGame.Example.Test.pack(builder, _oTest4[_j]);}
for (int _j = _oTest4.length - 1; _j >=0; _j--) { _unused_offset = MyGame.Example.Test.pack(builder, _oTest4[_j]);}
_test4 = builder.endVector();
}
int _testarrayofstring = 0;
@@ -590,8 +591,9 @@ public final class Monster extends Table {
int _testarrayofsortedstruct = 0;
MyGame.Example.AbilityT[] _oTestarrayofsortedstruct = _o.getTestarrayofsortedstruct();
if (_oTestarrayofsortedstruct != null) {
int _unused_offset = 0;
startTestarrayofsortedstructVector(builder, _oTestarrayofsortedstruct.length);
for (int _j = _oTestarrayofsortedstruct.length - 1; _j >=0; _j--) { MyGame.Example.Ability.pack(builder, _oTestarrayofsortedstruct[_j]);}
for (int _j = _oTestarrayofsortedstruct.length - 1; _j >=0; _j--) { _unused_offset = MyGame.Example.Ability.pack(builder, _oTestarrayofsortedstruct[_j]);}
_testarrayofsortedstruct = builder.endVector();
}
int _flex = 0;
@@ -604,8 +606,9 @@ public final class Monster extends Table {
int _test5 = 0;
MyGame.Example.TestT[] _oTest5 = _o.getTest5();
if (_oTest5 != null) {
int _unused_offset = 0;
startTest5Vector(builder, _oTest5.length);
for (int _j = _oTest5.length - 1; _j >=0; _j--) { MyGame.Example.Test.pack(builder, _oTest5[_j]);}
for (int _j = _oTest5.length - 1; _j >=0; _j--) { _unused_offset = MyGame.Example.Test.pack(builder, _oTest5[_j]);}
_test5 = builder.endVector();
}
int _vectorOfLongs = 0;

View File

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

View File

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

View File

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

View File

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

View File

@@ -9,7 +9,7 @@ import com.google.flatbuffers.*;
@SuppressWarnings("unused")
public final class Referrable extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static Referrable getRootAsReferrable(ByteBuffer _bb) { return getRootAsReferrable(_bb, new Referrable()); }
public static Referrable getRootAsReferrable(ByteBuffer _bb, Referrable obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }

View File

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

View File

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

View File

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

View File

@@ -9,7 +9,7 @@ import com.google.flatbuffers.*;
@SuppressWarnings("unused")
public final class Stat extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static Stat getRootAsStat(ByteBuffer _bb) { return getRootAsStat(_bb, new Stat()); }
public static Stat getRootAsStat(ByteBuffer _bb, Stat obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -13,7 +13,7 @@ internal partial struct TestSimpleTableWithEnum : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_0(); }
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_8(); }
public static TestSimpleTableWithEnum GetRootAsTestSimpleTableWithEnum(ByteBuffer _bb) { return GetRootAsTestSimpleTableWithEnum(_bb, new TestSimpleTableWithEnum()); }
public static TestSimpleTableWithEnum GetRootAsTestSimpleTableWithEnum(ByteBuffer _bb, TestSimpleTableWithEnum 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

@@ -9,7 +9,7 @@ import com.google.flatbuffers.*;
@SuppressWarnings("unused")
final class TestSimpleTableWithEnum extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static TestSimpleTableWithEnum getRootAsTestSimpleTableWithEnum(ByteBuffer _bb) { return getRootAsTestSimpleTableWithEnum(_bb, new TestSimpleTableWithEnum()); }
public static TestSimpleTableWithEnum getRootAsTestSimpleTableWithEnum(ByteBuffer _bb, TestSimpleTableWithEnum 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

@@ -31,7 +31,7 @@ class TestSimpleTableWithEnum : Table() {
}
}
companion object {
fun validateVersion() = Constants.FLATBUFFERS_2_0_0()
fun validateVersion() = Constants.FLATBUFFERS_2_0_8()
fun getRootAsTestSimpleTableWithEnum(_bb: ByteBuffer): TestSimpleTableWithEnum = getRootAsTestSimpleTableWithEnum(_bb, TestSimpleTableWithEnum())
fun getRootAsTestSimpleTableWithEnum(_bb: ByteBuffer, obj: TestSimpleTableWithEnum): TestSimpleTableWithEnum {
_bb.order(ByteOrder.LITTLE_ENDIAN)

View File

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

View File

@@ -13,7 +13,7 @@ public struct TypeAliases : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_0(); }
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_8(); }
public static TypeAliases GetRootAsTypeAliases(ByteBuffer _bb) { return GetRootAsTypeAliases(_bb, new TypeAliases()); }
public static TypeAliases GetRootAsTypeAliases(ByteBuffer _bb, TypeAliases 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

@@ -9,7 +9,7 @@ import com.google.flatbuffers.*;
@SuppressWarnings("unused")
public final class TypeAliases extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static TypeAliases getRootAsTypeAliases(ByteBuffer _bb) { return getRootAsTypeAliases(_bb, new TypeAliases()); }
public static TypeAliases getRootAsTypeAliases(ByteBuffer _bb, TypeAliases 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

@@ -203,7 +203,7 @@ class TypeAliases : Table() {
}
}
companion object {
fun validateVersion() = Constants.FLATBUFFERS_2_0_0()
fun validateVersion() = Constants.FLATBUFFERS_2_0_8()
fun getRootAsTypeAliases(_bb: ByteBuffer): TypeAliases = getRootAsTypeAliases(_bb, TypeAliases())
fun getRootAsTypeAliases(_bb: ByteBuffer, obj: TypeAliases): TypeAliases {
_bb.order(ByteOrder.LITTLE_ENDIAN)

View File

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

View File

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

View File

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

View File

@@ -9,7 +9,7 @@ import com.google.flatbuffers.*;
@SuppressWarnings("unused")
public final class Monster extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static Monster getRootAsMonster(ByteBuffer _bb) { return getRootAsMonster(_bb, new Monster()); }
public static Monster getRootAsMonster(ByteBuffer _bb, Monster obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }

View File

@@ -17,7 +17,7 @@ class Monster : Table() {
return this
}
companion object {
fun validateVersion() = Constants.FLATBUFFERS_2_0_0()
fun validateVersion() = Constants.FLATBUFFERS_2_0_8()
fun getRootAsMonster(_bb: ByteBuffer): Monster = getRootAsMonster(_bb, Monster())
fun getRootAsMonster(_bb: ByteBuffer, obj: Monster): Monster {
_bb.order(ByteOrder.LITTLE_ENDIAN)

View File

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

View File

@@ -13,7 +13,7 @@ public struct InParentNamespace : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_0(); }
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_8(); }
public static InParentNamespace GetRootAsInParentNamespace(ByteBuffer _bb) { return GetRootAsInParentNamespace(_bb, new InParentNamespace()); }
public static InParentNamespace GetRootAsInParentNamespace(ByteBuffer _bb, InParentNamespace 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

@@ -9,7 +9,7 @@ import com.google.flatbuffers.*;
@SuppressWarnings("unused")
public final class InParentNamespace extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static InParentNamespace getRootAsInParentNamespace(ByteBuffer _bb) { return getRootAsInParentNamespace(_bb, new InParentNamespace()); }
public static InParentNamespace getRootAsInParentNamespace(ByteBuffer _bb, InParentNamespace 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

@@ -17,7 +17,7 @@ class InParentNamespace : Table() {
return this
}
companion object {
fun validateVersion() = Constants.FLATBUFFERS_2_0_0()
fun validateVersion() = Constants.FLATBUFFERS_2_0_8()
fun getRootAsInParentNamespace(_bb: ByteBuffer): InParentNamespace = getRootAsInParentNamespace(_bb, InParentNamespace())
fun getRootAsInParentNamespace(_bb: ByteBuffer, obj: InParentNamespace): InParentNamespace {
_bb.order(ByteOrder.LITTLE_ENDIAN)

View File

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

View File

@@ -13,7 +13,7 @@ public struct MonsterExtra : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_0(); }
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_2_0_8(); }
public static MonsterExtra GetRootAsMonsterExtra(ByteBuffer _bb) { return GetRootAsMonsterExtra(_bb, new MonsterExtra()); }
public static MonsterExtra GetRootAsMonsterExtra(ByteBuffer _bb, MonsterExtra obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public static bool MonsterExtraBufferHasIdentifier(ByteBuffer _bb) { return Table.__has_identifier(_bb, "MONE"); }

View File

@@ -9,7 +9,7 @@ import com.google.flatbuffers.*;
@SuppressWarnings("unused")
public final class MonsterExtra extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
public static MonsterExtra getRootAsMonsterExtra(ByteBuffer _bb) { return getRootAsMonsterExtra(_bb, new MonsterExtra()); }
public static MonsterExtra getRootAsMonsterExtra(ByteBuffer _bb, MonsterExtra obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public static boolean MonsterExtraBufferHasIdentifier(ByteBuffer _bb) { return __has_identifier(_bb, "MONE"); }

View File

@@ -175,7 +175,7 @@ class MonsterExtra : Table() {
}
}
companion object {
fun validateVersion() = Constants.FLATBUFFERS_2_0_0()
fun validateVersion() = Constants.FLATBUFFERS_2_0_8()
fun getRootAsMonsterExtra(_bb: ByteBuffer): MonsterExtra = getRootAsMonsterExtra(_bb, MonsterExtra())
fun getRootAsMonsterExtra(_bb: ByteBuffer, obj: MonsterExtra): MonsterExtra {
_bb.order(ByteOrder.LITTLE_ENDIAN)

View File

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

View File

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

View File

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

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