platform/upstream/flatbuffers.git
3 years agoSwift/Kotlin generated code version updates
Wouter van Oortmerssen [Mon, 10 May 2021 18:20:09 +0000 (11:20 -0700)]
Swift/Kotlin generated code version updates

Change-Id: I035163cb5edd087a190bb518e686c79887241383

3 years agoC++/Rust version changes
Wouter van Oortmerssen [Mon, 10 May 2021 18:27:06 +0000 (11:27 -0700)]
C++/Rust version changes

3 years agoC#/Java generated code version updates
Wouter van Oortmerssen [Mon, 10 May 2021 18:17:31 +0000 (11:17 -0700)]
C#/Java generated code version updates

3 years agoUpdated main version numbers to 2.0
Wouter van Oortmerssen [Mon, 10 May 2021 18:14:47 +0000 (11:14 -0700)]
Updated main version numbers to 2.0

3 years ago[Go] Add missing namespace when using Object API (#6633)
mogemimi [Mon, 10 May 2021 17:52:10 +0000 (02:52 +0900)]
[Go] Add missing namespace when using Object API (#6633)

3 years agoFix reverse iterators for Vector and Array (#6626)
Vladimir Glavnyy [Mon, 10 May 2021 16:07:56 +0000 (23:07 +0700)]
Fix reverse iterators for Vector and Array (#6626)

This commit fixes two serious issues connected with reverse iterators:
1. Vector's rbegin/rend was incompatible with std::reverse_iterator::base();
2. Array's rend() was incorrect, it based on end() instead of begin().

3 years ago[Lua] manipulate byte array as string (#6624)
罗泽轩 [Sat, 8 May 2021 05:57:13 +0000 (13:57 +0800)]
[Lua] manipulate byte array as string (#6624)

* [Lua] manipulate byte array as string

Sometimes it would be more effective than reading byte by byte

* change according to the review

* update

3 years ago[C++] Fix union copy constructor to work with nested structs (#6552) (#6607)
Piotr Dziwiński [Thu, 6 May 2021 21:42:44 +0000 (09:42 +1200)]
[C++] Fix union copy constructor to work with nested structs (#6552) (#6607)

3 years agoUpdates swift generated monster sample file (#6616)
mustiikhalil [Thu, 6 May 2021 04:55:03 +0000 (07:55 +0300)]
Updates swift generated monster sample file (#6616)

Updates swift generated monster sample file
Adds frozen attribute

3 years ago[Lua] Avoid infinite loop when creating empty string (#6614)
罗泽轩 [Thu, 6 May 2021 02:39:42 +0000 (10:39 +0800)]
[Lua] Avoid infinite loop when creating empty string (#6614)

* [Lua] Avoid infinite loop when creating empty string

* [Lua] Check empty string output

3 years agoAdded support for Lua 5.1, 5.2 and 5.4 (#6606)
Derek Bailey [Wed, 5 May 2021 23:36:49 +0000 (16:36 -0700)]
Added support for Lua 5.1, 5.2 and 5.4 (#6606)

This adds basic support for different Lua versions.

For Lua 5.2 and Lua 5.3, both the Bit32 and Compat53 Lua modules must be
installed for it to work. You can typically get these on Linux using

apt install lua-compat53 lua-bit32

For Lua 5.4, it should work as is, as it is a clean superset of Lua 5.3,
which is what the original Lua Flatbuffers supported.

3 years ago[TS] Remove wrong and obsolete NS prefix use (#6604)
Björn Harrtell [Mon, 3 May 2021 19:04:34 +0000 (21:04 +0200)]
[TS] Remove wrong and obsolete NS prefix use (#6604)

3 years agoFixed LuaJIT when not compiled with COMPAT mode (#6605)
Derek Bailey [Mon, 3 May 2021 18:35:49 +0000 (11:35 -0700)]
Fixed LuaJIT when not compiled with COMPAT mode (#6605)

LuaJIT as installed by apt doesn't include the COMPAT mode for using
Lua5.2 features. So this change just makes the flatbuffer code use a
common implementation.

3 years agoremoved unneeded type prefixing (#6601)
Kamil Rojewski [Mon, 3 May 2021 17:40:59 +0000 (19:40 +0200)]
removed unneeded type prefixing (#6601)

3 years agoBump Rust to 0.9.0 (#6610)
Casper [Sun, 2 May 2021 16:28:17 +0000 (12:28 -0400)]
Bump Rust to 0.9.0 (#6610)

Co-authored-by: Casper Neo <cneo@google.com>
3 years ago[Lua] Add LuaJIT support (#6584)
罗泽轩 [Fri, 30 Apr 2021 17:38:16 +0000 (01:38 +0800)]
[Lua] Add LuaJIT support (#6584)

* [Lua] Add LuaJIT support

Here is the output of LuaTest.sh:

Run with LuaJIT:
built 100 512-byte flatbuffers in 0.16sec: 0.63/msec, 0.31MB/sec
built 1000 512-byte flatbuffers in 0.08sec: 12.06/msec, 5.89MB/sec
built 10000 512-byte flatbuffers in 0.80sec: 12.44/msec, 6.07MB/sec
built 10000 512-byte flatbuffers in 0.33sec: 30.58/msec, 14.93MB/sec
traversed 100 592-byte flatbuffers in 0.04sec: 2.51/msec, 1.42MB/sec
traversed 1000 592-byte flatbuffers in 0.03sec: 31.52/msec, 17.79MB/sec
traversed 10000 592-byte flatbuffers in 0.21sec: 48.77/msec, 27.53MB/sec
Run with Lua 5.3:
built 100 512-byte flatbuffers in 0.02sec: 5.44/msec, 2.66MB/sec
built 1000 512-byte flatbuffers in 0.17sec: 5.74/msec, 2.80MB/sec
built 10000 512-byte flatbuffers in 1.75sec: 5.72/msec, 2.79MB/sec
built 10000 512-byte flatbuffers in 1.38sec: 7.26/msec, 3.55MB/sec
traversed 100 592-byte flatbuffers in 0.00sec: 27.64/msec, 15.60MB/sec
traversed 1000 592-byte flatbuffers in 0.03sec: 30.46/msec, 17.20MB/sec
traversed 10000 592-byte flatbuffers in 0.34sec: 29.62/msec, 16.72MB/sec

* [Lua] Better usage description

* update according to the review

3 years agoIntroduce new_from_vec in Rust (also fix formatting) (#6599)
Casper [Thu, 29 Apr 2021 22:23:22 +0000 (18:23 -0400)]
Introduce new_from_vec in Rust (also fix formatting) (#6599)

* Introduce new_from_vec in Rust (also fix formatting)

Also, rename `new_with_capacity` to `with_capacity` to match
how `Vec` does it.

* bump rust version

* mut_finished_buffer

Co-authored-by: Casper Neo <cneo@google.com>
3 years agofix typo in CppUsage.md (#6595)
shiyuge [Thu, 29 Apr 2021 17:05:55 +0000 (01:05 +0800)]
fix typo in CppUsage.md (#6595)

Thanks!

3 years ago[Lua] GetRootAs can accept strings. Made Luatest Benchmarks optional (#6593)
Derek Bailey [Tue, 27 Apr 2021 20:02:13 +0000 (13:02 -0700)]
[Lua] GetRootAs can accept strings. Made Luatest Benchmarks optional (#6593)

3 years agoAdd advance feature indicators to reflection (#6546)
Casper [Tue, 27 Apr 2021 14:10:59 +0000 (10:10 -0400)]
Add advance feature indicators to reflection (#6546)

* Add advance feature indicators to reflection

* deserialize too

* model advanced features as bitflags

* use uint64_t instead of AdvancedFeatures

* git clang format

* initialize advanced_features_

* remove whitespace

Co-authored-by: Casper Neo <cneo@google.com>
3 years agoRust Remove SafeSliceAccess for Arrays, and fix miri. (#6592)
Casper [Mon, 26 Apr 2021 23:28:25 +0000 (19:28 -0400)]
Rust Remove SafeSliceAccess for Arrays, and fix miri. (#6592)

* Fix Miri flag passing and bump Rust version.

* Fix Miri problems from Arrays PR.

SafeSliceAccess was removed for Arrays. It's kind of unsound.
It has two properties:
1. EndianSafe
2. Alignment 1

We only need 1. in create_vector_direct to memcpy data.
We both 1. and 2. for accessing things with slices as buffers are built on &[u8]
which is unaligned. Conditional compilation implements
SafeSliceAccess for >1byte scalars (like f32) on LittleEndian machines
which is wrong since they don't satisfy 2.

This UB is still accessible for Vectors (though not exercised our
tests) as it implements SafeSliceAccess. I'll fix this later by
splitting SafeSliceAccess into its 2 properties.

Co-authored-by: Casper Neo <cneo@google.com>
3 years agoMark endian_scalar as unsafe. (#6588)
Casper [Mon, 26 Apr 2021 13:18:58 +0000 (09:18 -0400)]
Mark endian_scalar as unsafe. (#6588)

* Mark endian_scalar as unsafe.

Also
- removed the deprecated flexbuffer slice from example
- fixed some cargo warnings

* Assertions and read_scalar made unsafe

* Clippy lints

* Add to Safety

Co-authored-by: Casper Neo <cneo@google.com>
3 years ago[swift] Implements union strings (#6589)
mustiikhalil [Sat, 24 Apr 2021 11:47:24 +0000 (14:47 +0300)]
[swift] Implements union strings (#6589)

3 years ago[Rust] Fix small mistyping (#6585)
Alexander Zaitsev [Thu, 22 Apr 2021 19:36:23 +0000 (22:36 +0300)]
[Rust] Fix small mistyping (#6585)

Hi!

Just a veeeeeery small fix in the Rust sample. No functionality is affected.

That's not important at all but annoying for my eyes :)

3 years ago[TS] Commit the generated tests code (#6579)
罗泽轩 [Thu, 22 Apr 2021 18:15:18 +0000 (02:15 +0800)]
[TS] Commit the generated tests code (#6579)

* [TS] Ignore generated monster_test_grpc files

* [TS] Commit the generated tests code

3 years agochore: ensure bash is used to generate code (#6577)
罗泽轩 [Mon, 19 Apr 2021 21:30:55 +0000 (05:30 +0800)]
chore: ensure bash is used to generate code (#6577)

In some platforms, like Ubuntu, `sh` is linked to `dash` but not `bash`.

3 years ago[Lua] Fix EnforceNumberAndPack for bool type (#6576)
罗泽轩 [Mon, 19 Apr 2021 21:30:20 +0000 (05:30 +0800)]
[Lua] Fix EnforceNumberAndPack for bool type (#6576)

3 years ago[TS] Remove duplicated build-ts ci (#6575)
罗泽轩 [Mon, 19 Apr 2021 21:28:26 +0000 (05:28 +0800)]
[TS] Remove duplicated build-ts ci (#6575)

Now we already have a real build-ts ci job, let's remove the commented
one.

3 years ago[Rust] Specify Minimum Supported Rust Version (#6573)
Ádám Lippai [Mon, 19 Apr 2021 20:43:11 +0000 (22:43 +0200)]
[Rust] Specify Minimum Supported Rust Version (#6573)

Related to #6572

3 years ago[Rust] Add support for fixed size arrays (#6548)
Eddie Linder [Fri, 16 Apr 2021 15:15:59 +0000 (18:15 +0300)]
[Rust] Add support for fixed size arrays (#6548)

* Add support for fixed size arrays

* clang-format

* Update rust image to 1.51 to support const generics

* Handle correctly big endian

* Add fuzz tests and clean code

* Add struct fuzz test and optimize struct arrays for api

* Bump flatbuffers crate version

3 years ago[Kotlin][FlexBuffers] Add support for Kotlin-iOS (#6564)
Paulo Pinheiro [Thu, 15 Apr 2021 18:29:51 +0000 (20:29 +0200)]
[Kotlin][FlexBuffers] Add support for Kotlin-iOS (#6564)

With this change, Flexbuffers for Kotlin now supports iOS(arm32, arm64, X64).
WatchOS and tvOS not supported.

3 years agosilenced clippy warning (#6565)
Kamil Rojewski [Thu, 15 Apr 2021 15:19:13 +0000 (17:19 +0200)]
silenced clippy warning (#6565)

3 years ago[Kotlin] Bump kotlinx.benchmark dependency to 0.3.0 (#6560)
Paulo Pinheiro [Mon, 12 Apr 2021 20:47:40 +0000 (22:47 +0200)]
[Kotlin] Bump kotlinx.benchmark dependency to 0.3.0 (#6560)

Kotlinx.benchmark project just abandoned bintray and moving to maven central,
removing the artifacts from bintray and causing missing dependencies in our build.
So we are updating the dependency to point to the new version on maven central.

More information in:

https://github.com/Kotlin/kotlinx-benchmark/commit/53ee45d0d914ceff111d3581ba3f5897fa897adc#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5

3 years ago[TS] Add Build TS to CI jobs (#6524)
Björn Harrtell [Mon, 12 Apr 2021 17:41:59 +0000 (19:41 +0200)]
[TS] Add Build TS to CI jobs (#6524)

* Add Build TS to CI jobs

* Add npm compile step

* Fix syntax

* Add required code gen for TS

* Exit on failure

* Make TS code gen identical to test run

* Remove duplicate TS code gen artifacts

* Remove bad gitignore

* Forgot parts of generate_code and make sure same settings for test run

* Don't forget about the bat

* Try and fix flatc args

* Another attempt to fix args

* Fix typo

* Commit up to date code gen

* Another attempt to fix sh/bat

* Move -o param to after -I

* Commit missing code gen file

* Fix grpc code gen and test

* Another grpc code gen fix

* Rework to not use ts folder

* Fix env vars in bat and make less churn

* Move TS code gen to dedicated folder

* Fix transpilation output folder and module paths

* Fixes to code gen

* Include generated js

* Moved ts code gen

* Remove test ts code gen folder

3 years ago[Kotlin][FlexBuffers] Add support for Kotlin-JS (#6554)
Paulo Pinheiro [Mon, 12 Apr 2021 17:30:15 +0000 (19:30 +0200)]
[Kotlin][FlexBuffers] Add support for Kotlin-JS (#6554)

Flexbuffers for Kotlin currently supports JVM and MacOS. This change
introduces support to JS as well.

3 years agoDefault-empty vectors of enums (#6505)
Casper [Tue, 6 Apr 2021 11:23:45 +0000 (07:23 -0400)]
Default-empty vectors of enums (#6505)

* disable clippy

* Vector of enum default

* swift and tests

* git clang format

* Rewrite enum parser checks

* Remove Voids from more_defaults

* vector enum swift

* remove vector accessor from swift

* clang format

Co-authored-by: Casper Neo <cneo@google.com>
3 years ago[CI] fixes buildkite (#6544)
mustiikhalil [Mon, 5 Apr 2021 09:34:42 +0000 (12:34 +0300)]
[CI] fixes buildkite (#6544)

3 years agoLimit formatter to pull requests only (#6540)
mustiikhalil [Thu, 1 Apr 2021 17:09:43 +0000 (20:09 +0300)]
Limit formatter to pull requests only (#6540)

3 years agoRust structz (#6539)
Casper [Mon, 29 Mar 2021 23:56:45 +0000 (19:56 -0400)]
Rust structz (#6539)

* Rust structz

* struct of structs test

* swift tmp variables

Co-authored-by: Casper Neo <cneo@google.com>
3 years ago[Kotlin][FlexBuffers] JSON support for Flexbuffers (#6417)
Paulo Pinheiro [Mon, 29 Mar 2021 22:57:23 +0000 (00:57 +0200)]
[Kotlin][FlexBuffers] JSON support for Flexbuffers (#6417)

* [Kotlin][FlexBuffers] Add JSON support for FlexBuffers

* [Kotlin][Flexbuffers] Re-implement JSON parser with a tokenizer.

3 years ago[grpc] Support latest version of grpc PoC (#6338)
Jeong YunWon [Thu, 25 Mar 2021 19:12:35 +0000 (04:12 +0900)]
[grpc] Support latest version of grpc PoC (#6338)

* use grpcpp rather than deprecated grpc++

* grpcpp Deserialize take ByteBuffer instead of grpc_byte_buffer

* grpc 1.36.0

* Fix to use grpc 1.36.0

* Fix CMakeLists to refer gRPC

* add find_package(Threads)

* Update bazel deps

* Apply workaround about boringssl build error

* Install latest cmake for osx on travis-ci

Co-authored-by: Yeom Gyusun <omniavinco@gmail.com>
3 years agofixed packing structs (#6530)
Kamil Rojewski [Thu, 25 Mar 2021 17:25:00 +0000 (18:25 +0100)]
fixed packing structs (#6530)

* fixed packing structs in nested buffers

* fixed packing structs

3 years ago[GO] Tries to add go format to the CI (#6518)
mustiikhalil [Thu, 18 Mar 2021 18:03:44 +0000 (21:03 +0300)]
[GO] Tries to add go format to the CI (#6518)

* Trys to add go format to the CI

Adds Gofmt to CI

* Adds formatting for go dir in grpc

* Small fix

3 years ago[C++] #6501 - Problem when mapping a native type multiple times (#6514)
Michael [Thu, 18 Mar 2021 18:01:50 +0000 (19:01 +0100)]
[C++] #6501 - Problem when mapping a native type multiple times (#6514)

* [C++] #6501 - Problem when mapping a native type multiple times
- idl.h:
added "native_type_pack_name"
- flatbuffers.h:
added CreateVectorOfNativeStructs variants which receive a pointer to the serialization function
- idl_gen_cpp.cpp:
adapted code generation in case "native_type_pack_name" attribute is present
- extended tests & docs; improved surrounding native_type docs a little

* integrated review feedback

3 years ago[fuzzer] Add `monster_debug` target (#6513)
Vladimir Glavnyy [Thu, 18 Mar 2021 17:56:28 +0000 (00:56 +0700)]
[fuzzer] Add `monster_debug` target (#6513)

Add the `monster_debug` target for better troubleshooting.
Improve oss-fuzz logs.

3 years ago[Swift] Removes allman rule (#6519)
mustiikhalil [Wed, 17 Mar 2021 10:22:49 +0000 (13:22 +0300)]
[Swift] Removes allman rule (#6519)

3 years ago[flexbuffers, json] Parse `nan` and `inf` (#6512)
Vladimir Glavnyy [Mon, 15 Mar 2021 18:44:42 +0000 (01:44 +0700)]
[flexbuffers, json] Parse `nan` and `inf` (#6512)

3 years agofixed packing structs in nested buffers (#6509)
Kamil Rojewski [Thu, 11 Mar 2021 19:14:23 +0000 (20:14 +0100)]
fixed packing structs in nested buffers (#6509)

3 years ago[idl_parser] Add kTokenNumericConstant token (#6432)
Vladimir Glavnyy [Thu, 11 Mar 2021 19:12:06 +0000 (02:12 +0700)]
[idl_parser] Add kTokenNumericConstant token (#6432)

* [idl_parser] Add kTokenNumericConstant token

This commit adds the new token for correct parsing of signed numeric constants.
Before this expressions `-nan` or `-inf` were treated as kTokenStringConstant.
This was ambiguous if a real string field parsed.
For example, `{ "text_field" : -name }` was accepted by the parser as valid JSON object.

Related oss-fuzz issue: 6200301176619008

* Add additional positive tests fo 'inf' and 'nan' as identifiers

* Rebase to HEAD

* Move processing of signed constants to ParseSingleValue method.

* Add missed `--cpp-static-reflection` (#6324) to pass CI

* Remove `flatbuffers.pc` from repository to unblock CI (#6455).

Probably the generated flatbuffers.pc should not be a part of repo.

* Fix FieldIdentifierTest()

3 years agoRemove `flatbuffers.pc` from the repository (#6508)
Vladimir Glavnyy [Thu, 11 Mar 2021 19:11:04 +0000 (02:11 +0700)]
Remove `flatbuffers.pc` from the repository (#6508)

3 years agoBump grpc to 1.0.0 (#6507)
mustiikhalil [Tue, 9 Mar 2021 07:56:06 +0000 (10:56 +0300)]
Bump grpc to 1.0.0 (#6507)

Adds void to keywords

3 years agoMove Traits struct and Create method out of --cpp-static-reflection. (#6503)
dpacbach [Mon, 8 Mar 2021 18:59:17 +0000 (13:59 -0500)]
Move Traits struct and Create method out of --cpp-static-reflection. (#6503)

3 years agoDisable x64-specific optimizations for ARM64EC ReadInt64 (#6506)
Ben Niu [Mon, 8 Mar 2021 18:53:04 +0000 (10:53 -0800)]
Disable x64-specific optimizations for ARM64EC ReadInt64 (#6506)

ARM64EC is a new ARM64 ABI designed by Microsoft to support x64 application emulation on ARM64 CPUs. When compiling for ARM64EC, both the _M_X64 and _M_ARM64EC macros are defined. However, that causes problem in compiling this file, because the __movsb intrinsic, which is lowered to rep movsb, is not supported on ARM64, so the optimization for native x64 should be disabled for ARM64EC.

3 years agoAdd --cpp-static-reflection to generate_code.bat. (#6502)
dpacbach [Sat, 6 Mar 2021 15:28:27 +0000 (10:28 -0500)]
Add --cpp-static-reflection to generate_code.bat. (#6502)

3 years ago[C++17] Add compile-time reflection for fields. (#6324)
David P. Sicilia [Fri, 5 Mar 2021 18:01:40 +0000 (13:01 -0500)]
[C++17] Add compile-time reflection for fields. (#6324)

* [C++17] Add compile-time reflection for fields.

Included in this commit is the following:

  - The C++ generator has been modified so that,
    when in C++17 mode, it will emit Table and
    Struct field traits that can be used at com-
    pile time as a form of static reflection. This
    includes field types, field names, and a tuple
    of field getter results.

  - Diffs to the cpp17 generated files. No other
    generated files are affected.

  - A unit test that also serves as an example. It
    demonstrates how to use the full power of this
    reflection to implement a full recursive
    JSON-like stringifier for Flatbuffers types,
    but without needing any runtime access to the
    *.fbs definition files; the computation is
    done using only static reflection.

Tested on Linux with gcc 10.2.0.

Fixes #6285.

* Fix int-conversion warning on MSVC.

* Try to fix std::to_string ambiguity on MSVC.

* Fix clang-format diffs.

* Fix more clang-format diffs.

* Fix last clang-format diff.

* Enable C++17 build/test for VC 19 platform in CI.

* Forgot to add value to cmake command line variable.

* Various fixes/changes in response to @vglavnyy's feedback.

* Replace "fields pack" with index-based getters.

* Fix MSVC error.

* Fix clang-format diffs.

* getter_for method returns result instead of address-of-getter.

* Next round of reviewer suggestions.

* Use type instead of hardcoded struct name.

* Fix clang-format diff.

* Add test for FieldType since it is not used in the stringify test.

* Add fields_number field to Traits struct.

* Add --cpp-static-reflection flag and put those features behind it.

* Fix clang-format diffs.

* Remove <tuple> include.

3 years agofixed invalid TS call and added test files (#6495)
Kamil Rojewski [Thu, 4 Mar 2021 20:12:44 +0000 (21:12 +0100)]
fixed invalid TS call and added test files (#6495)

e581013e3d42af13d2fe37b0ac46a3fd43f3638c broke TS generation - please don't use "replace" to refactor function names :)

3 years agodisable clippy (#6494)
Casper [Mon, 1 Mar 2021 21:51:22 +0000 (16:51 -0500)]
disable clippy (#6494)

Co-authored-by: Casper Neo <cneo@google.com>
3 years ago[idl_parser, JSON] Disable parsing of JSON for incomplete schemes (#6493)
Vladimir Glavnyy [Mon, 1 Mar 2021 21:40:58 +0000 (04:40 +0700)]
[idl_parser, JSON] Disable parsing of JSON for incomplete schemes (#6493)

This commit disable JSON parsing for an incomplete scheme if JSON object is embedded into one file with the scheme.
This should improve the quality of OSS-Fuzz inputs for the parser_fuzzer target.

3 years ago[idl_parser] Track included files by hash (#6434)
Mark Spatz [Mon, 1 Mar 2021 20:34:01 +0000 (14:34 -0600)]
[idl_parser] Track included files by hash (#6434)

* [idl_gen] Delete ts::GenPrefixedImport()

I don't know what this is for, but it's the only piece of code external
to idl_parser.cpp that expects the key of Parser::included_files_ to be
a path. And it appears to be unused.

* [idl_parser] Track included files by hash

Parser::included_files_ is a map whose main purpose is to keep track of
which files have already been parsed in order to protect against
multiple inclusion. Its key is the path that the file was found at
during parsing (or, if it's an in-memory file, just its name).

This commit changes the key to be the 64 bit FNV-1a hash of the file's
name (just the name, not the complete path) xor'd with the hash of the
file's contents (unless it's an in-memory file, then we only hash the
name.)

This allows multiple include protection to function even in the face of
unique per-file include paths (fixes #6425).

* Ran tests/generate_code.sh

CI told me to do it.

* Gracefullt handle case where source_filename == nullptr

I just learned source_filename might also be null. In that case, we
should exclude it from the hash instead of hashing a zero length
string, just like we exclude source when it is null.

Presumably nameless files will never be included (they can't, can they?)
so this doesn't really matter, but I think it's prettier anyways.

3 years agofix for noUncheckedIndexedAccess in ts (#6474)
Kamil Rojewski [Thu, 25 Feb 2021 22:57:10 +0000 (23:57 +0100)]
fix for noUncheckedIndexedAccess in ts (#6474)

3 years agoWorking on a python example plus fixing python grpc code (#6456)
mustiikhalil [Thu, 25 Feb 2021 22:38:12 +0000 (01:38 +0300)]
Working on a python example plus fixing python grpc code (#6456)

Refactored python grpc code gen

Adds example server & client + fixes ci

Fixes generated code

Making sure we encode the reply string as utf8

Adds Readme details to clarify issue regarding encoding when python is sending/receiving

3 years ago[rust] Remove debug code (#6475)
Colin [Wed, 24 Feb 2021 18:00:18 +0000 (13:00 -0500)]
[rust] Remove debug code (#6475)

* Remove debug code

This was added for testing in the recent genericize PR for flexbuffer Reader.

* Added alloc tests -> MapReader::{is_empty, index_key, len}

* Added , accessible through Deref to deprecation warning

3 years agoRevert "[C#] Fix truncated ArraySegment<byte> if elementSize != 1 (#6462)" (#6488)
Derek Bailey [Tue, 23 Feb 2021 19:30:07 +0000 (11:30 -0800)]
Revert "[C#] Fix truncated ArraySegment<byte> if elementSize != 1 (#6462)" (#6488)

This reverts commit cbbbaa61b34c31f17773c2fef354c31664e9562e.

3 years ago[C#] Fix truncated ArraySegment<byte> if elementSize != 1 (#6462)
Björn Harrtell [Tue, 23 Feb 2021 17:34:20 +0000 (18:34 +0100)]
[C#] Fix truncated ArraySegment<byte> if elementSize != 1 (#6462)

* WIP: Fix returned truncated ArraySegment<byte> if elementSize is not byte

* Fix

* Regenerated test code

3 years ago[CI] Adds Code Generation tests on Github Actions (#6482)
mustiikhalil [Tue, 23 Feb 2021 05:51:39 +0000 (08:51 +0300)]
[CI] Adds Code Generation tests on Github Actions (#6482)

Moves check-grpc-generation to scripts

3 years ago[CMake] generate pkg-config flatbuffers.pc file (#6455)
Millian Poquet [Mon, 22 Feb 2021 18:23:38 +0000 (19:23 +0100)]
[CMake] generate pkg-config flatbuffers.pc file (#6455)

This commit enables CMake to generate a flatbuffers.pc file on install.

pkg-config eases the utilization of software libraries by enabling the
developers of a library to define how the library should be used.

It can be used as a tool by build systems to find and manage dependencies,
this is notably the default Meson behavior and optionally used by CMake.

3 years ago[Swift] Moves grpc example to grpc/examples (#6479)
mustiikhalil [Sat, 20 Feb 2021 20:07:48 +0000 (23:07 +0300)]
[Swift] Moves grpc example to grpc/examples (#6479)

Updates generated Code

Removes grpc generation code from tests dir

Small fix to generate.sh

3 years ago[TS] Moves grpc code to examples folder (#6476)
mustiikhalil [Sat, 20 Feb 2021 17:31:00 +0000 (20:31 +0300)]
[TS] Moves grpc code to examples folder (#6476)

Adds readme

3 years agoFixes grammer (#6477)
mustiikhalil [Fri, 19 Feb 2021 20:16:38 +0000 (23:16 +0300)]
Fixes grammer (#6477)

Updates docs

3 years agoFix sample_binary.py to use latest EndVector without a size. (#6478)
Richard A Hofer [Fri, 19 Feb 2021 20:13:50 +0000 (15:13 -0500)]
Fix sample_binary.py to use latest EndVector without a size. (#6478)

3 years agoupdated JS docs to reflect current status (#6436)
Kamil Rojewski [Fri, 19 Feb 2021 20:05:02 +0000 (21:05 +0100)]
updated JS docs to reflect current status (#6436)

3 years ago[Go] Working on a go example plus fixing go grpc code (#6448)
mustiikhalil [Fri, 19 Feb 2021 09:47:59 +0000 (12:47 +0300)]
[Go] Working on a go example plus fixing go grpc code (#6448)

Implemented server.go and half implemented client.go

Finishes implementation for greeter go example

Update grpc code for monster.fbs

Adds a couple of cpp methods

Adhere to gofmt standards

Adds a readme for issues with grpc

3 years ago[Swift] adds support for default vectors and strings (#6461)
mustiikhalil [Fri, 19 Feb 2021 09:47:28 +0000 (12:47 +0300)]
[Swift] adds support for default vectors and strings (#6461)

Small fix

Adhere to the new protocol names

3 years agoUpdate Building.md (#6473)
Arnaud LE CAM [Fri, 19 Feb 2021 03:51:41 +0000 (04:51 +0100)]
Update Building.md (#6473)

`cmake . -D FLATBUFFERS_CXX_FLAGS="Wno-error"` returns an error (file 'Wno-error' not found)

3 years agoGetUOffsetT must get value by GetUint32 not GetInt32 (#6072)
Thanabodee Charoenpiriyakij [Fri, 19 Feb 2021 02:38:25 +0000 (09:38 +0700)]
GetUOffsetT must get value by GetUint32 not GetInt32 (#6072)

3 years agoFix a typo in Swift codegen (#6470)
Liu Liu [Wed, 17 Feb 2021 06:34:39 +0000 (22:34 -0800)]
Fix a typo in Swift codegen (#6470)

* Fix a typo in Swift codegen

* Fix code formatting.

3 years ago[rust] Genericize flexbuffer reader (#6450)
Colin [Tue, 16 Feb 2021 13:04:48 +0000 (08:04 -0500)]
[rust] Genericize flexbuffer reader (#6450)

* feature/rust-tokio-bytes added feature name for tokio-bytes

* Added flexbuffer implementation, TODO: typecast to avoid recurse

* Converted codebase to utilize FlexBuffer implementation, need to resolve deserialization issues

* Added todo for lifetime issue, may use &'de [u8] for deserializer instead of current method

* Added proper &[u8] implementation

* Removed unused struct

* Added experimental fix to get_slice

* Added experimental fix to get_slice

* Avoided lifetime issues via ref structs, need to check if this hurts peformance

* Updated deserializer implementation to allow for borrowed data from Reader struct

* Fixed bug with str

* Removed unnecessary generic parameter

* Added unsafe to avoid lifetime complaints, current tests pass, need to review alternatives to unsafe

* Opinionated: Removed bytes crate as this implementation could be done in a separate crate

* Cleaned up flatbuffer

* Fixed sample / example

* Resolved PR feedback, need to resolve issues with tests

* Cleaned up FlexBuffer trait to be an auto impl

* Removed TODO

* Reverted Deserializer to only support &'de [u8]

* Cleaned up / renamed function for clarification

* Renamed FlexBuffer -> InternalBuffer for clarification on it's purpose

* Fixed issue with key bytes

* resolved issues with broken tests, confirming this is a breaking change

* Removed FIXME that's solved by splitting String and Key variants

* Implemented associated types approach

* Fixed backward slice logic

* Fixed MapReader compile error

* Added from_buffer for deserialization, removed  function since it's only needed for deserialization

* Removed dead code

* Cleaned up buffer, removed AsRef in favor of Deref

* Renamed Buffer::as_str -> Buffer::buffer_str

* Minor cleanup

* Updated documentation, need to fix tests

* Removed unnecessary &

* Removed unused lifetime

* removed unnecessary as_ref

* Minor optimization wrap-up

* resolved issue with Clone

* Added test to verify no deep-copy

* Added  for optimization

* Updated to use empty fn instead of default

* Updated comments / test name - plus the 0.3.0 version bump

* comment

3 years ago[Swift] Renaming protocols (#6469)
mustiikhalil [Tue, 16 Feb 2021 11:55:47 +0000 (14:55 +0300)]
[Swift] Renaming protocols (#6469)

* Renaming protocols

* Updates Generated code

* format code

3 years agoUpdate swift docs (#6460)
mustiikhalil [Sun, 14 Feb 2021 07:09:11 +0000 (10:09 +0300)]
Update swift docs (#6460)

3 years agoDefault strings and vectors: Parser + Rust support (#6421)
Casper [Fri, 12 Feb 2021 14:41:10 +0000 (09:41 -0500)]
Default strings and vectors: Parser + Rust support (#6421)

* Fix tests.cpp

* Parser support for vector/string defaults

* tests and default empty vectors

* addressed comments

* Default strings and vectors for Rust

* Tested Rust more_defaults

* git-clang-format

* add more_defaults_test

* fixed vector default

* removed commented out code

* more unreachable

Co-authored-by: Casper Neo <cneo@google.com>
3 years ago[CMake] Renames BUILD files (#6457)
mustiikhalil [Thu, 11 Feb 2021 18:16:57 +0000 (21:16 +0300)]
[CMake] Renames BUILD files (#6457)

* Renamed build to build.bazel to stop xcode from complaining about it

* Renamed all build to build.bazel

* Fixes small ci issue

3 years ago[Build, cmake] Add -Werror override option (#6429)
Vladimir Glavnyy [Wed, 10 Feb 2021 19:49:34 +0000 (02:49 +0700)]
[Build, cmake] Add -Werror override option (#6429)

* [Build, cmake] Add -Werror override option

This commit adds FLATBUFFERS_CXX_FLAGS cmake option.
This option allows override the -Werror flag (or any other flags).
Related issues:  #6337, #5930

* Remove CMAKE_CXX_FLAGS replace option

3 years ago[C++]Fix extra char generation for byte type during json schema generation (#6276)
blueshift155 [Wed, 10 Feb 2021 19:48:24 +0000 (01:18 +0530)]
[C++]Fix extra char generation for byte type during json schema generation (#6276)

* Fix extra char generation for the byte type

* Fix unit tests for JSON

3 years agoUpdating working code (#6441)
mustiikhalil [Wed, 10 Feb 2021 19:46:45 +0000 (22:46 +0300)]
Updating working code (#6441)

Fixes issues with namespaces in grpc ts

Renamed welcome -> models

3 years agoJSON schema - tailing double quotes for maximum (#6452)
tira-misu [Wed, 10 Feb 2021 19:45:34 +0000 (20:45 +0100)]
JSON schema - tailing double quotes for maximum (#6452)

* Fix C/C++ Create<Type>Direct with sorted vectors

If a struct has a key the vector has to be sorted. To sort the vector
you can't use "const".

* Changes due to code review

* Improve code readability

* Add generate of JSON schema to string to lib

* option indent_step is supported

* Remove unused variables

* Fix break in test

* Fix style to be consistent with rest of the code

* Fix  double quotes for (u)int8 in json schema

* Fix reference file for JSON schema test

* Fix reference file for JSON schema test

3 years ago[idl_parser] Validate `force_align` on all possible paths (#6430)
Vladimir Glavnyy [Wed, 10 Feb 2021 19:37:16 +0000 (02:37 +0700)]
[idl_parser] Validate `force_align` on all possible paths (#6430)

* [idl_parser] Validate `force_align` on all possible paths

- added validation of `force_align` for `Vector`.
- added assertion to `flatbuffers::PreAlign` method

These changes should resolve following oss-fuzz issues:
6275816289861632
5713529908887552
4761242994606080

* size_t problem on Mac

* Fix review notes

3 years agoImplement Rust object API defaults (#6444)
Casper [Sun, 7 Feb 2021 21:51:33 +0000 (16:51 -0500)]
Implement Rust object API defaults (#6444)

* Implment Rust object API defaults

* satisfy return analysis

* git clang format

Co-authored-by: Casper Neo <cneo@google.com>
3 years agoUpgrade swift grpc to alpha 24 (#6439)
mustiikhalil [Wed, 3 Feb 2021 23:01:18 +0000 (02:01 +0300)]
Upgrade swift grpc to alpha 24 (#6439)

Upgrade swift grpc to alpha 24

3 years ago[fuzzer] Limit parser_fuzzer execution time (#6431)
Vladimir Glavnyy [Sat, 30 Jan 2021 14:43:31 +0000 (21:43 +0700)]
[fuzzer] Limit parser_fuzzer execution time (#6431)

Limit the length of the fuzzer input to 16384 characters to prevent timeout
in JSON parser (Vector of tables with key).

Related oss-fuzz issues:
5742497110294528

3 years agoThis commit contains the initial implementation of Flexbuffers in Kotlin. The code...
Paulo Pinheiro [Thu, 28 Jan 2021 22:49:25 +0000 (23:49 +0100)]
This commit contains the initial implementation of Flexbuffers in Kotlin. The code was ported based (#6387)

on the current Java Implementation.

The code dependencies related to JVM were removed and the project is able to target all available platforms.

The only requirement to implement to fully support a target is to implement functions described in `ByteArray.kt`.
Right now the code support JVM and native targets. JS port still missing, but just be trivial to introduce.

Currently, only the `jvm` and `macosX64` targets are enabled until we figure out how to enable tests on all
platforms on CI.

A submodule called "benchmark" is also introduced. It contains a series
of benchmarks comparing Java and Kotlin implementations of FlexBuffers and the UTF8 API.

Finally, this commit does not contain the scripts necessary to publish the artifacts. This will
be introduced at a later stage once the team has an agreement on how to rollout Kotlin releases.

3 years agoBetter python generated code naming (#6336)
Richard A Hofer [Thu, 28 Jan 2021 20:35:37 +0000 (15:35 -0500)]
Better python generated code naming (#6336)

* Remove a lot of redundancy from the Python generated code.

Update tutorial to reflect new Python generated code.

* Add aliases for newly deprecated Python generated methods.

This should help with backwards compatibility.

* Fix incorrect names in deprecated comments.

3 years agoRust: remove inner attributes (#6410)
Casper [Tue, 26 Jan 2021 16:09:29 +0000 (11:09 -0500)]
Rust: remove inner attributes (#6410)

* remove inner attributes

* Added test for outdir in Rust

* add bin/outdir

* Moved outdir test to its own package and only run it if flatc is available

Co-authored-by: Casper Neo <cneo@google.com>
3 years ago[Rust] Ensure unions are referenced with the correct path (#6422)
William Bain [Mon, 25 Jan 2021 17:33:47 +0000 (12:33 -0500)]
[Rust] Ensure unions are referenced with the correct path (#6422)

* Add codegen test for namespaced unions

* [Rust] Handle cross-namespace union use

* [Rust] Test namespace handling

* [Rust] Drop trailing whitespace in codegen

* [Rust] Set flags in generate_code.bat to match .sh

* [C#] Add additional namespace test file

3 years agoRefactor FieldDef to model presense as an enum rather than 2 bools. (#6420)
Casper [Mon, 25 Jan 2021 17:29:43 +0000 (12:29 -0500)]
Refactor FieldDef to model presense as an enum rather than 2 bools. (#6420)

* Define presence.

* Migrate to IsRequired and IsOptional methods

* moved stuff around

* Removed optional and required bools from FieldDef

* change assert to return error

* Fix tests.cpp

* MakeFieldPresence helper

* fmt

* old c++ compatibility stuff

Co-authored-by: Casper Neo <cneo@google.com>
3 years ago[c++] Apply NativeName before WrapInNameSpace in idl_gen_cpp.cpp (#6419)
Andreas Kabel [Mon, 25 Jan 2021 17:22:01 +0000 (09:22 -0800)]
[c++] Apply NativeName before WrapInNameSpace in idl_gen_cpp.cpp (#6419)

* Apply NativeName before WrapInNameSpace in idl_gen_cpp.cpp

* remove actual_type argument from GetUnionElement -- it's always true

* Merge GetUnionElement's native_type and wrap_native argument -- they always have the same value.

* Use convenience method WrapNativeNameInNameSpace

* Remove wrap_namespace argument from GetUnionElement

* Move declaration closer to first use.

3 years agoFormats cpp code (#6349)
mustiikhalil [Fri, 22 Jan 2021 18:46:53 +0000 (21:46 +0300)]
Formats cpp code (#6349)

3 years agoRust Object API (#6070)
Casper [Fri, 22 Jan 2021 18:07:32 +0000 (13:07 -0500)]
Rust Object API (#6070)

* inital commit of rust object api

* Required fields support.

* clang fallthrough

* Fix unused variables

* just don't fall through

* remove comment

* s/panic/unreachable

* Tests for object API

* Added defaults

* deleted unintentionally added files and updated .bat file

* fix bat file

* clang format

* Cargo clippy checks

* remove commented out code

* clippy allows

* Remove matches! macro since we're not yet at Rust v1.42

* install clippy in RustTest.sh

* move line

Co-authored-by: Casper Neo <cneo@google.com>
3 years agoClarify that (Flat|Flex)Buffers do not deduplicate vector elements (#6415)
Juan Cruz Viotti [Fri, 22 Jan 2021 00:09:35 +0000 (20:09 -0400)]
Clarify that (Flat|Flex)Buffers do not deduplicate vector elements (#6415)

I'm also clarifying that while elements are not deduplicated, vectors
may contain more than one offset to the same value.

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
3 years agoClarify that FlatBuffers unions do not support scalars (#6416)
Juan Cruz Viotti [Fri, 22 Jan 2021 00:08:29 +0000 (20:08 -0400)]
Clarify that FlatBuffers unions do not support scalars (#6416)

I mention that a common practice is to wrap the scalar value in a table
or a struct.

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
3 years agoExplain how FlatBuffers encodes unions (#6414)
Juan Cruz Viotti [Fri, 22 Jan 2021 00:07:34 +0000 (20:07 -0400)]
Explain how FlatBuffers encodes unions (#6414)

This is an attempt to explain how FlatBuffers encodes union types as an
extra section in the "FlatBuffers internals" document.

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>