platform/upstream/flatbuffers.git
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>
3 years agodart Builder - expose finished buffer size (#6403)
Ivan Dlugos [Fri, 22 Jan 2021 00:06:11 +0000 (01:06 +0100)]
dart Builder - expose finished buffer size (#6403)

3 years agoRemove invalid claim that Protocol Buffers does not support unions (#6413)
Juan Cruz Viotti [Thu, 21 Jan 2021 20:23:54 +0000 (16:23 -0400)]
Remove invalid claim that Protocol Buffers does not support unions (#6413)

Protocol Buffers v3 supports the `oneof` operator:
https://developers.google.com/protocol-buffers/docs/proto3#oneof

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
3 years ago[TS/JS] New gen TS code gen (#6302)
Björn Harrtell [Tue, 19 Jan 2021 20:51:13 +0000 (21:51 +0100)]
[TS/JS] New gen TS code gen (#6302)

* TS/ES6 modules spike iteration 1

* Initial modularized dasherized output

* Remove obsoleted parts and namespace wrapping

* Use _flatbuffers_ prefix

* First part of imports logic

* Second part of imports logic

* Fix TS/JS code removal mixup

* Alias imported symbols if same name from different namespaces and some fixes

* Use star import for bare imports

* Fix messed up string concat

* var to const and remove not needed semi

* Remove some cases of ns prefixing

* Add missing space

* Cleanups

* Completed initial import tracking logic

* Compilable output

* Adjust TypeScriptTest and dependents to work

* Use local flatbuffers package for tests

* Refactor away use of any

* Remove obsolete imported_fileset and reexport_map

* Still need any and fix JavaScriptTest.sh

* Fix test runs out of the box

* Temp add generated files

* TypeScriptTest replaces JavaScriptTest and cleanups

* Also remove reference to JavaScriptTest in TestAll.sh

* Remove old generated ts/js files

* Remove use of --js in generate_code scripts

* idl_gen_js_ts to idl_gen_ts and removal of js gen

* Remove obsoleted options

* Fix obsolete ts test detection

* Tweak ts compilation be as strict as possible

* Remove jsdoc type annotation generation

* Generated test ts files

* Fix search and replace messup

* Regenerated ts test output

* Use CharToLower

* Use normal for loop

* Rework namespacedir

* Revert "Rework namespacedir"

This reverts commit 6f4eb0104ceeb86011bb076ebca901138c48e068.

* Revert "Use normal for loop"

This reverts commit 676b2135bfaa1853dfbb06c92b5c16a0d81bb13a.

* Revert "Use CharToLower"

This reverts commit 2d08648d0d72d0af201fad80d54cdc76412b35e9.

* Again do rework but correct

* Avoid runtime cast

* Fix test runs

* Also add npm install to get tsc

* Bump node test versions

* for range to std for loop

* Clang format

* Missed one clang format

* Move accessor to later

* Attempt to make windows version of TypeScriptTest

* Want to see the output

* Try to get newer node at appveyor

* Style changes

3 years ago[idl_parser] Improve symbols lookup thru parent namespaces (#6407)
Vladimir Glavnyy [Tue, 19 Jan 2021 20:49:24 +0000 (03:49 +0700)]
[idl_parser] Improve symbols lookup thru parent namespaces (#6407)

Added the new method LookupTableByName for searching symbols in parent namespaces.
This method speedup (x50 or greater) symbol resolution (enum or struct) in parent namespaces.
The speedup was measured without `table.empty()` guard condition.

This method should suppress fuzzer timeout issue without artificial limits for nested namespaces (https://oss-fuzz.com/testcase-detail/6244168439169024).

Additionally, this commit speedup (x5) the GetFullyQualifiedName method by removing unnecessary temporary std::string object.

3 years agoSearch for includes in the directory containg the current file (#6371)
Mark Spatz [Tue, 19 Jan 2021 20:26:34 +0000 (12:26 -0800)]
Search for includes in the directory containg the current file (#6371)

* [codegen] Search for includes in the directory containg the current file

This matches the behavior of a C preprocessor, see:
https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html

* Skip FileExists() when file is guaranteed to not exist

* end comment with period to match others

3 years agoUpgrade Rust dependencies (#6406)
Casper [Tue, 19 Jan 2021 18:39:29 +0000 (13:39 -0500)]
Upgrade Rust dependencies (#6406)

Co-authored-by: Casper Neo <cneo@google.com>
3 years ago[TS/JS] New gen TS code gen prequel to preserve history (#6404)
Björn Harrtell [Thu, 14 Jan 2021 19:34:44 +0000 (20:34 +0100)]
[TS/JS] New gen TS code gen prequel to preserve history (#6404)

* Rename idl_gen_js_ts to idl_gen_ts to preserve history

* Change build related files

3 years agoUnset FieldDef.optional if its key (#6402)
Casper [Tue, 12 Jan 2021 19:06:43 +0000 (14:06 -0500)]
Unset FieldDef.optional if its key (#6402)

* Unset FieldDef.optional if its key

* removed StringKey table, just removed an extra "required, key"

* removed extra newline

Co-authored-by: Casper Neo <cneo@google.com>
3 years ago[fuzzer] Fix the binary schema loading in the monster_fuzzer (#6396)
Vladimir Glavnyy [Tue, 12 Jan 2021 18:20:47 +0000 (01:20 +0700)]
[fuzzer] Fix the binary schema loading in the monster_fuzzer (#6396)

This commit should fix issue 29374 in oss-fuzz.

3 years agoFix Rust UB problems (#6393)
Casper [Mon, 11 Jan 2021 20:24:52 +0000 (15:24 -0500)]
Fix Rust UB problems (#6393)

* Fix miri problems by assuming alignment is 1 in rust

* Removed is_aligned fn from rust verifier.

* Add back is_aligned, but make it w.r.t. buffer[0]

* touch unused variable

* touch unused variable

* +nightly

* Move Rust miri testing into its own docker

* fix bash

* missing one endian conversion

* fix endianness2

* format stuff

Co-authored-by: Casper Neo <cneo@google.com>
3 years agoDefine Vector::value_type for STL compatibility (#6394)
brian-brt [Fri, 8 Jan 2021 19:35:55 +0000 (11:35 -0800)]
Define Vector::value_type for STL compatibility (#6394)

Specifically, this lets the googlemock container matchers work with a
flatbuffers::Vector.

https://github.com/google/googletest/blob/master/googlemock/docs/cheat_sheet.md#container-matchers

3 years ago[fuzzer] Debug the monster_tets.bfbs on clusterfuzz server (#6392)
Vladimir Glavnyy [Fri, 8 Jan 2021 19:09:41 +0000 (02:09 +0700)]
[fuzzer] Debug the monster_tets.bfbs on clusterfuzz server (#6392)

For some reason, this fuzzer failed to load the binary schema file
when run on the `/clusterfuzz` server.
Issue: https://oss-fuzz.com/testcase-detail/6215075358703616
This issue doesn't reproduce locally with the latest oss-fuzz docker image.

3 years agoFix up scripts, fix generated enum value for strong mode, regenerate files (#6389)
Dan Field [Thu, 7 Jan 2021 22:51:52 +0000 (14:51 -0800)]
Fix up scripts, fix generated enum value for strong mode, regenerate files (#6389)

* Fix up scripts, fix generated enum value for strong mode, regenerate files

* missing files

* GH action

* remove action

3 years ago[go] tests/GoTest.sh: Fix flags.Parse location to work on new go SDKs. (#6388)
Aaron Son [Thu, 7 Jan 2021 19:54:00 +0000 (11:54 -0800)]
[go] tests/GoTest.sh: Fix flags.Parse location to work on new go SDKs. (#6388)

* tests/GoTest.sh: Fix flags.Parse location to work on new go SDKs.

Calling flags.Parse() within init() races with other packages which register
flags in their init(), and in particular with the testing package itself. It is
more reliable to call flags.Parse() from a TestMain implementation.

See https://github.com/golang/go/issues/31859,
https://github.com/golang/go/issues/33869.

* .github: Enable build-go action in build.yaml workflow.

3 years agofix Dart Builder._writeString() - always write trailing zero byte (#6390)
Ivan Dlugos [Thu, 7 Jan 2021 19:40:47 +0000 (20:40 +0100)]
fix Dart Builder._writeString() - always write trailing zero byte (#6390)

3 years agofix Dart Builder.reset() - clear vTables (#6386)
Ivan Dlugos [Thu, 7 Jan 2021 19:28:33 +0000 (20:28 +0100)]
fix Dart Builder.reset() - clear vTables (#6386)

3 years ago[C++, JSON] Fix nullptr access when reading a key with a default value. (#6375)
Vladimir Glavnyy [Thu, 7 Jan 2021 19:24:59 +0000 (02:24 +0700)]
[C++, JSON] Fix nullptr access when reading a key with a default value. (#6375)

This commit fixes handling of default and NULL `key` fields in `Parser::ParseVector` (#5928).

The JSON generator updated. It outputs `key` fields even if the `--force-defaults` option is inactive.

Additional test cases for `key` added.

3 years agoFix generated EndVector. (#6385)
Richard A Hofer [Tue, 5 Jan 2021 22:45:23 +0000 (17:45 -0500)]
Fix generated EndVector. (#6385)

3 years agoImplements type promotion for Java enum (#6382)
Stefan de Konink [Tue, 5 Jan 2021 19:11:29 +0000 (20:11 +0100)]
Implements type promotion for Java enum  (#6382)

* Implements type promotion for Java enum as suggested in #3890, #5111, #6369

* After generate_code.sh

3 years agoDelete label_notify.yml
Derek Bailey [Tue, 5 Jan 2021 18:06:33 +0000 (10:06 -0800)]
Delete label_notify.yml

Removing this workflow as it isn't used.

3 years agoDisabled PHP CI (#6381)
Wouter van Oortmerssen [Mon, 4 Jan 2021 22:50:56 +0000 (14:50 -0800)]
Disabled PHP CI (#6381)

It errors with "Fatal error: Uncaught exception 'InvalidArgumentException' with message 'bad number  for type byte.. in /home/runner/work/flatbuffers/flatbuffers/php/ByteBuffer.php:490" which I can't reproduce locally, and trying to fix it on CI runs into PHP's insane handling of numbers vs strings.

3 years agofixed warnings (#6355)
Kamil Rojewski [Mon, 4 Jan 2021 22:11:59 +0000 (23:11 +0100)]
fixed warnings (#6355)

* semver-compatible deprecations

* removed unneeded lifetimes (+ clippy warnings)

* silenced too many args warning

3 years agoFix multiple fbs code generation failure (#6365)
Bruno ZIKI Kongawi [Mon, 4 Jan 2021 21:29:32 +0000 (13:29 -0800)]
Fix multiple fbs code generation failure (#6365)

3 years ago[idl_parser] Improve stack overflow protection (#6364)
Vladimir Glavnyy [Mon, 4 Jan 2021 20:39:12 +0000 (03:39 +0700)]
[idl_parser] Improve stack overflow protection (#6364)

* [idl_parser] Improve stack overflow protection

Add stack overflow protection for Flexbuffer and nested Flatbuffer parsers.
Replaces the `Recurse()` method by the new ParseDepthGuard RAII class.

* Remove move operator from Parser.

It was wrong decision to add move ctor and assignment into Parser class.
These operators will make it extremely difficult to add constant or reference fields in the future.

* Remove ';' from definition of FLATBUFFERS_DELETE_FUNC

* Format code

* Make this PR compatible with MSVC2010 (it doesn't support inherited ctor)

3 years ago[idl_parser] Check the range of explicitly set field's id value (#6363)
Vladimir Glavnyy [Mon, 4 Jan 2021 20:33:31 +0000 (03:33 +0700)]
[idl_parser] Check the range of explicitly set field's id value (#6363)

* [idl_parser] Check the range of explicitly set field's id value

The explicitly set `id` attribute should be a non-negative value of the `voffset_t` type.

* Format FieldIdentifierTest()

3 years agoGenerate code to encode and decode nested flatbuffers in Python. (#6354)
Richard A Hofer [Mon, 4 Jan 2021 20:18:19 +0000 (15:18 -0500)]
Generate code to encode and decode nested flatbuffers in Python. (#6354)

* Generate code to encode and decode nested flatbuffers in Python.

* Delete accidental trailing whitespace.

* Fully delete trailing whitespace.

3 years ago[Rust] Shared String (#6367)
mustiikhalil [Mon, 4 Jan 2021 14:18:35 +0000 (17:18 +0300)]
[Rust] Shared String (#6367)

* Adds shared strings and tests for shared strings

* Adds resets on string_map

* Moved shared strings to use vector instead of hashmap

* Addresses all the issues

* Resolves some comments

3 years agoUpdates license date to 2021 (#6378)
mustiikhalil [Sat, 2 Jan 2021 08:46:46 +0000 (11:46 +0300)]
Updates license  date to 2021 (#6378)

3 years agoinclude_prefix support for rust (#6330)
Kamil Rojewski [Wed, 30 Dec 2020 20:02:36 +0000 (21:02 +0100)]
include_prefix support for rust (#6330)

* include_prefix support for rust

* include_prefix support for java

* formatting fixes

* Revert "include_prefix support for java"

* style fix

3 years ago[Swift] Rebuild the way swift handles structs from scratch (#6326)
mustiikhalil [Thu, 17 Dec 2020 22:55:32 +0000 (01:55 +0300)]
[Swift] Rebuild the way swift handles structs from scratch (#6326)

* Rebuild the way swift handles structs from scratch

* Updates docs, and sample binary

* Replaces InMemory to Mutable

* Migrates docs from inmemory

* use inline for some functions

* Renamed Mutable objects

* Updates documentation

3 years agoFix typos in usage/comments; Make rust generator respect to --filenam… (#6342)
mqy [Thu, 17 Dec 2020 21:15:27 +0000 (05:15 +0800)]
Fix typos in usage/comments; Make rust generator respect to --filenam… (#6342)

* Fix typos in usage/comments; Make rust generator respect to --filename-suffix

* run clang format

3 years agoRenaming infinity variables in test.cpp (#6340)
Kjetil Østerås [Thu, 17 Dec 2020 21:08:23 +0000 (22:08 +0100)]
Renaming infinity variables in test.cpp (#6340)

The infinityf symbol is causing a conflict when building for cygwin. In
the cygwin math.h header there is also a symbol called infinityf. So
this patch is needed to be able to build the flatbuffer tests in a
cygwin environment.

3 years agoAdd vectorNumElements attribute to Builder for simpler vector creation. (#6328)
Richard A Hofer [Mon, 14 Dec 2020 20:00:28 +0000 (15:00 -0500)]
Add vectorNumElements attribute to Builder for simpler vector creation. (#6328)

* Add vectorNumElements attribute to Builder for simpler vector creation.

This adds a default to EndVector which should simplify its use.

* Update tutorial to reflect new default arg in Python EndVector.

* Remove optional argument to Python EndVector.

* Add generated files.

* Unset Builder.vectorNumElems when not in use.

3 years ago[CI] Adds formatter to CI (#6272)
mustiikhalil [Fri, 11 Dec 2020 18:46:10 +0000 (21:46 +0300)]
[CI] Adds formatter to CI (#6272)

* Adds formatters CI

Adds Error message & setup formatting like cpp

Adds Swift

Adds typescript

Adds python

tests yarn

Adds format.md

* Removes unneeded scripts + moves install script to install phase

* Adds format.md content

* Adds cpp to the formatter.md and fixes ci

* Adds cpp to formatter ci

3 years agoFix Max CI build path (#6333)
Wouter van Oortmerssen [Fri, 11 Dec 2020 18:31:20 +0000 (10:31 -0800)]
Fix Max CI build path (#6333)

apparently the default xcodebuild path of ./build clashes with the BUILD file present (case insensitive file system?)

3 years agoGenerate nullable properties in C# object-based API for optional scalars. (without...
Stefan F [Fri, 11 Dec 2020 00:50:30 +0000 (01:50 +0100)]
Generate nullable properties in C# object-based API for optional scalars. (without -gen-mutable) (#6273)

* Added missing EndTable() call to VerifyObject()

VerifyObject called VerifyTableStart() but not EndTable(). This made Verifier::VerifyComplexity() increase depth_ with each table, not with the depth of tables.

https://groups.google.com/forum/#!topic/flatbuffers/OpxtW5UFAdg

* Added Check to VerifyAlignment

https://stackoverflow.com/questions/59376308/flatbuffers-verifier-returns-false-without-any-assertion-flatbuffers-debug-veri

* Add GetStringView (Convenience function to get string_view from a String returning an empty string_view on null pointer) like GetString, GetCstring

* flatc should warn, when an attribute is attached more than once.

flatc.exe -b duplicate.fbs
warning: duplicate.fbs(5, 36): warning: attribute already found: priority

duplicate.fbs:

namespace MyGame;

attribute "priority";

table Monster (priority:1, priority:2) {
}

root_type Monster;

* flatc should support --binary --schema with optional scalar fields.

This fixes 'error: Optional scalars are not yet supported in at least one the of the specified programming languages.' when calling flatc.exe --binary --schema with a schema containing optional scalars.

* Generate nullable properties in C# object-based API for optional scalars.
tests\generate_code.bat extended to test this.

Ran tests\generate_code.bat
Ran tests\Flatbuffers.Test\NetTest.bat

* %TEST_BASE_FLAGS% replaced with --gen-object-api in generate_code.bat, because only this is part of this PR. Added this same flag to generate_code.sh

* generate_code.bat and generate_code.sh changed to only test c# with object based api.

3 years ago[Python] Commit some orphan python genfile diffs. (#6325)
David P. Sicilia [Fri, 11 Dec 2020 00:43:40 +0000 (19:43 -0500)]
[Python] Commit some orphan python genfile diffs. (#6325)

3 years agoFixed missing ending quotes in labeller (#6327)
Derek Bailey [Thu, 10 Dec 2020 22:19:46 +0000 (14:19 -0800)]
Fixed missing ending quotes in labeller (#6327)

3 years agoAdd flatc option to inhibit all warnings #6005 (#6301)
tira-misu [Thu, 10 Dec 2020 22:03:53 +0000 (23:03 +0100)]
Add flatc option to inhibit all warnings #6005 (#6301)

* 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

* Add option --no-warnings to inhibit all warnings

* Fix order of member initialization

* Add documentation for --no-warnings

3 years ago[fuzzer] Rename fuzzing dictionaries for `oss-fuzz` (#6318)
Vladimir Glavnyy [Thu, 10 Dec 2020 22:02:01 +0000 (05:02 +0700)]
[fuzzer] Rename fuzzing dictionaries for `oss-fuzz` (#6318)

This commit makes the names of fuzzing dictionaries the same as the target binary names.
Also it explicitly limits size of test inputs to prevent failures in `regex` and fuzzing time-outs.

3 years agobumprust (#6322)
Casper [Wed, 9 Dec 2020 19:34:19 +0000 (14:34 -0500)]
bumprust (#6322)

Co-authored-by: Casper Neo <cneo@google.com>
3 years agoSet default initialSize for Builder to 0 (#6310)
Richard A Hofer [Tue, 8 Dec 2020 00:20:26 +0000 (19:20 -0500)]
Set default initialSize for Builder to 0 (#6310)

* Set default initialSize for Builder to 0

* Change default size of builder to 1024.

This matches what the C++ and Java versions do.

3 years agoRust Flatbuffers Verifier (#6269)
Casper [Mon, 7 Dec 2020 23:37:51 +0000 (18:37 -0500)]
Rust Flatbuffers Verifier (#6269)

* Updated comments and fixed a fundemental type error.

* bump rust flatbuffers semver

* Initial commit with verifier, need to clean up

* Verifier tested. Needs clean up and refactoring.

* Display for InvalidFlatbuffer and better errors for strings

* SimpleToVerify, some refactoring

* Combined VerifierType TableAccessorFuncBody into FollowType

* scrub todos

* Update Rust get_root functions.

There are 6 variants, with verifier options, default verifier options
and no verification "fast".

* Rename root fns

* inline

* Update to use thiserror

* fix for bad compiler

* improve error formatting

* Replace multiply with saturating_multiply

* saturating adds too

* Add docs disclaiming experimental verification system

Co-authored-by: Casper Neo <cneo@google.com>
3 years agoVersion message should be a "STATUS" to avoid going to stderr. (#6316)
David P. Sicilia [Mon, 7 Dec 2020 19:50:29 +0000 (14:50 -0500)]
Version message should be a "STATUS" to avoid going to stderr. (#6316)

3 years agoReplace std::string and const char* CreateSharedString with string_view (#6315)
Austin Schuh [Mon, 7 Dec 2020 19:49:24 +0000 (11:49 -0800)]
Replace std::string and const char* CreateSharedString with string_view (#6315)

It is useful to be able to call CreateSharedString with a string_view.
A string_view can be implicitly converted from a std::string or a const
char*.  This means if string_view is available, we can use it instead of
both other functions and get all 3.

3 years ago[fuzzer] Fix mistakes in the `parser` and `scalar` fuzzers. (#6314)
Vladimir Glavnyy [Mon, 7 Dec 2020 19:47:33 +0000 (02:47 +0700)]
[fuzzer] Fix mistakes in the `parser` and `scalar` fuzzers. (#6314)

The flatbuffers::Parser::Parse() isn't an idempotent method for schema parsing.
This commit removes a wrong for-loop that tried to check the same schema twice.

3 years agoAdd default to offset param of Python generated GetRootAs (#6312)
Richard A Hofer [Mon, 7 Dec 2020 19:34:07 +0000 (14:34 -0500)]
Add default to offset param of Python generated GetRootAs (#6312)

3 years ago[fuzzer] Fix loading of schema in monster_fuzzer (#6308)
Vladimir Glavnyy [Mon, 7 Dec 2020 19:21:23 +0000 (02:21 +0700)]
[fuzzer] Fix loading of schema in monster_fuzzer (#6308)

This is fix for (https://oss-fuzz.com/testcase-detail/6251772204810240)

3 years ago[C++] Switch `flatc` to `--cpp-std c++11` C++ code generator (#6306)
Vladimir Glavnyy [Mon, 7 Dec 2020 19:19:36 +0000 (02:19 +0700)]
[C++] Switch `flatc` to `--cpp-std c++11` C++ code generator (#6306)

Prior to this commit the default C++ code generator was `c++0x`.
A code generated with `c++0x` code-gen might have a vulnerability (undefined behavior) connected evolution of enums in a schema. This UB could break the backward compatibility if previously generated code casts an unknown enumerator to enum type that knows nothing about future enumerators added to the schema.

The main differences between `c++0x` and `c++11`:

- generated enums use explicitly declared underlying type;
- generated object-API tables don't declare default ctor() explicitly, instead of it default data member initializers are generated.

Please use `flatc --cpp-std c++0x` option for backward compatibility with old compilers.

3 years ago[idl_parser] Unify parsing of NaN values read from .fbs and .json files (#6296)
Vladimir Glavnyy [Mon, 7 Dec 2020 19:12:58 +0000 (02:12 +0700)]
[idl_parser] Unify parsing of NaN values read from .fbs and .json files (#6296)

This commit unifies parsing of NaN values read
from .fbs and .json files by converting them to unsigned NaN.

3 years agoMoved various language tests from AppVeyor to GitHub Actions (#6300)
Wouter van Oortmerssen [Thu, 3 Dec 2020 19:26:27 +0000 (11:26 -0800)]
Moved various language tests from AppVeyor to GitHub Actions (#6300)

3 years agoDocumentation updates for Optional Scalars (#6014) (#6270)
Casper [Tue, 24 Nov 2020 19:05:39 +0000 (11:05 -0800)]
Documentation updates for Optional Scalars (#6014) (#6270)

* Documentation updates for Optional Scalars

* Updated Support

* Reword stuff

* s/NULL/null

Co-authored-by: Casper Neo <cneo@google.com>
3 years ago[C++] Add ParseJson(), Parser(Parser&&), update fuzzers (#6284)
Vladimir Glavnyy [Mon, 23 Nov 2020 18:17:44 +0000 (01:17 +0700)]
[C++] Add ParseJson(), Parser(Parser&&), update fuzzers (#6284)

- add a new method ParseJson to minimize failures during fuzzing
- add default (conditional) move-constructor for Parser
- add a new monster_fuzzer
- switch fuzzers to C++17 and `test/cpp17` generated code

3 years agoFixed FlexBufferBuilder asserting on duplicate keys
Wouter van Oortmerssen [Mon, 23 Nov 2020 17:02:40 +0000 (09:02 -0800)]
Fixed FlexBufferBuilder asserting on duplicate keys

3 years agoAdded a few more paths for auto labeler (#6281)
Derek Bailey [Fri, 20 Nov 2020 06:13:19 +0000 (22:13 -0800)]
Added a few more paths for auto labeler (#6281)

3 years agoAdd --require-explicit-ids to require explicit ids (#6277)
Austin Schuh [Fri, 20 Nov 2020 01:16:45 +0000 (17:16 -0800)]
Add --require-explicit-ids to require explicit ids (#6277)

* Add --require-explicit-ids to require explicit ids

We just got bit by a well intentioned developer forgetting that field
order by default is the field index.  3 people missed it in review.

I'm looking at ways to make it harder to mess up.  We are requesting
that developers explicitly id all fields in tables.  Automatic (opt in
for others) enforcement of this will help the effort succeed.  This
patch adds a command line flag which lets the user require ids on all
fields in tables.

* Added docs to Compiler.md as well

3 years agoidl_gen_json_schema.cpp: Changed generation of array element types (#6253)
schoetbi [Fri, 20 Nov 2020 00:17:03 +0000 (01:17 +0100)]
idl_gen_json_schema.cpp: Changed generation of array element types (#6253)

* idl_gen_json_schema.cpp: Changed generation of array element types
#6175

* idl_gen_json_schema.cpp: Simplified indent generation as suggested by @vglavnyy
#6175

3 years agofix typo (#6280)
Kelvin Hu [Thu, 19 Nov 2020 17:08:52 +0000 (01:08 +0800)]
fix typo (#6280)

3 years agoUpdated Ms build Action to fix build issue (#6279)
Derek Bailey [Thu, 19 Nov 2020 08:20:47 +0000 (00:20 -0800)]
Updated Ms build Action to fix build issue (#6279)

3 years agoAdd type annotation to unspecified array (#6264)
James Kuszmaul [Mon, 16 Nov 2020 18:49:53 +0000 (10:49 -0800)]
Add type annotation to unspecified array (#6264)

The lack of any type on the `ret` variable was causing our typescript compiler to complain.

3 years ago[Swift] Adds a format file and reformats the swift project (#6250)
mustiikhalil [Mon, 16 Nov 2020 16:52:38 +0000 (19:52 +0300)]
[Swift] Adds a format file and reformats the swift project (#6250)

* Formats files & adds licence

* Revert arrays

* Keeps array indentation as is

* Adds licence to code formatter

* Updates code generators

3 years agoAdds a fix for enum generation (#6263)
mustiikhalil [Sun, 15 Nov 2020 14:50:12 +0000 (17:50 +0300)]
Adds a fix for enum generation (#6263)

3 years agoExperimental fix for failing oss-fuzz coverage build (#6259)
AdamKorcz [Fri, 13 Nov 2020 23:48:05 +0000 (23:48 +0000)]
Experimental fix for failing oss-fuzz coverage build (#6259)

3 years agoBREAKING: Rust flexbuffers serde human readable set to false (#6257)
Casper [Fri, 13 Nov 2020 15:53:01 +0000 (07:53 -0800)]
BREAKING: Rust flexbuffers serde human readable set to false (#6257)

Co-authored-by: Casper Neo <cneo@google.com>
3 years agoUpdate to flags in fuzzing-cmake file (#6256)
AdamKorcz [Thu, 12 Nov 2020 18:21:34 +0000 (18:21 +0000)]
Update to flags in fuzzing-cmake file (#6256)

3 years agoRemove _POSIX_C_SOURCE and _XOPEN_SOURCE definitions when compiling o… (#6205)
Jason Lenz [Thu, 12 Nov 2020 18:12:32 +0000 (12:12 -0600)]
Remove _POSIX_C_SOURCE and _XOPEN_SOURCE definitions when compiling o… (#6205)

* Remove _POSIX_C_SOURCE and _XOPEN_SOURCE definitions when compiling on OpenBSD

* Only define _POSIX_C_SOURCE and _XOPEN_SOURCE for mingw/cygwin platforms

* Only define POSIX statements for mingw/cygwin/qnx platforms

3 years agoflatc should support --binary --schema with optional scalar fields. (#6252)
Stefan F [Thu, 12 Nov 2020 18:06:09 +0000 (19:06 +0100)]
flatc should support --binary --schema with optional scalar fields. (#6252)

* Added missing EndTable() call to VerifyObject()

VerifyObject called VerifyTableStart() but not EndTable(). This made Verifier::VerifyComplexity() increase depth_ with each table, not with the depth of tables.

https://groups.google.com/forum/#!topic/flatbuffers/OpxtW5UFAdg

* Added Check to VerifyAlignment

https://stackoverflow.com/questions/59376308/flatbuffers-verifier-returns-false-without-any-assertion-flatbuffers-debug-veri

* Add GetStringView (Convenience function to get string_view from a String returning an empty string_view on null pointer) like GetString, GetCstring

* flatc should warn, when an attribute is attached more than once.

flatc.exe -b duplicate.fbs
warning: duplicate.fbs(5, 36): warning: attribute already found: priority

duplicate.fbs:

namespace MyGame;

attribute "priority";

table Monster (priority:1, priority:2) {
}

root_type Monster;

* flatc should support --binary --schema with optional scalar fields.

This fixes 'error: Optional scalars are not yet supported in at least one the of the specified programming languages.' when calling flatc.exe --binary --schema with a schema containing optional scalars.