platform/upstream/flatbuffers.git
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.

3 years agoBump version of rules_go to 0.24.5 (#6234)
Ivo List [Thu, 12 Nov 2020 18:04:34 +0000 (19:04 +0100)]
Bump version of rules_go to 0.24.5 (#6234)

Versions of rules_go below 0.24 include platforms repository, which are lacking
definitions of os:macos, cpu:arm64 constraints.

This definitions are needed to properly select toolchains in latest
bazel.

3 years agoUnion As Accessors for C# (#6251)
Derek Bailey [Thu, 12 Nov 2020 17:28:21 +0000 (09:28 -0800)]
Union As Accessors for C# (#6251)

* Union As Accessors for C#

* Changed loop to be compatible with older compilers

* errant change fix

3 years agoResets buffer without deallocating current pointer (#6247)
mustiikhalil [Mon, 9 Nov 2020 14:55:53 +0000 (17:55 +0300)]
Resets buffer without deallocating current pointer (#6247)

Resets buffer without deallocating current pointer & Bumps version

3 years agoAdd GetBufferSpan() function to bufferbuilder (#6235)
OptoCloud [Fri, 6 Nov 2020 02:09:01 +0000 (03:09 +0100)]
Add GetBufferSpan() function to bufferbuilder (#6235)

This will return the finished internal buffer data as a span

3 years agoModernize android build and sample (#6229)
Paulo Pinheiro [Thu, 5 Nov 2020 22:23:37 +0000 (23:23 +0100)]
Modernize android build and sample (#6229)

Android build was dated, using the Android.mk approach. Current
project configuration on Android encourages the usage of CMake, so we
are updating the android project as an example on how to use either the
Java/Kotlin generate code or the native C++ one.

3 years agoAdded required-nested-flatbuffer to monster_test and fixed rust (#6236)
Casper [Thu, 5 Nov 2020 21:58:06 +0000 (13:58 -0800)]
Added required-nested-flatbuffer to monster_test and fixed rust (#6236)

Co-authored-by: Casper Neo <cneo@google.com>
3 years agoNotify based on Labelling issues and PR (#6241)
Derek Bailey [Thu, 5 Nov 2020 21:40:01 +0000 (13:40 -0800)]
Notify based on Labelling issues and PR (#6241)

3 years agoConverted globs to use single quotes (#6240)
Derek Bailey [Thu, 5 Nov 2020 21:12:19 +0000 (13:12 -0800)]
Converted globs to use single quotes (#6240)

3 years agoMore adjustments to the auto labeler (#6239)
Derek Bailey [Thu, 5 Nov 2020 21:02:33 +0000 (13:02 -0800)]
More adjustments to the auto labeler (#6239)

3 years agoUpdated Lua labeller glob (#6238)
Derek Bailey [Thu, 5 Nov 2020 20:50:33 +0000 (12:50 -0800)]
Updated Lua labeller glob (#6238)

3 years agoSupport size-prefixed buffers and add tests for size-prefixed messages (#6232)
Charlie Yin [Thu, 5 Nov 2020 19:23:56 +0000 (11:23 -0800)]
Support size-prefixed buffers and add tests for size-prefixed messages (#6232)

3 years agoRemoves duplicate swift in labeler (#6228)
mustiikhalil [Sat, 31 Oct 2020 15:35:44 +0000 (18:35 +0300)]
Removes duplicate swift in labeler (#6228)

Removed grpc tag from swift label set & removes duplicate swift label

3 years agoAdded more labels for auto labeler (#6227)
Derek Bailey [Fri, 30 Oct 2020 21:01:35 +0000 (14:01 -0700)]
Added more labels for auto labeler (#6227)

3 years ago[C#] Optional Scalars (#6217)
Derek Bailey [Fri, 30 Oct 2020 20:18:59 +0000 (13:18 -0700)]
[C#] Optional Scalars (#6217)

* [C#] Optional Scalars

* Moved scalar optional check to avoid null enum conversion

3 years ago[Label Bot] Add Java and Kotlin support for the label bot (#6226)
Paulo Pinheiro [Fri, 30 Oct 2020 20:18:36 +0000 (21:18 +0100)]
[Label Bot] Add Java and Kotlin support for the label bot (#6226)

CI is an unrelated timeout.

3 years agoImplement `Debug` trait for Rust flatbuffers. (#6207)
Casper [Thu, 29 Oct 2020 19:57:29 +0000 (12:57 -0700)]
Implement `Debug` trait for Rust flatbuffers. (#6207)

* Refactor idl_gen_rust to a ForAllX continuation pattern.

* Removed unneeded SetValue and updated sample rust gencode

* Make Rust flatbuffers print right

* Generated code and removed unnecessary trait constraint

* bumped rust version. Release required

* removed an unwrap in Rust Debug-print unions

* Tested formatting flatbuffers in rust.

* Set float precision in flaky debug-print test

* impl Debug for structs too

Co-authored-by: Casper Neo <cneo@google.com>
3 years ago[Label Bot] Adds some languages to labeler bot (#6222)
mustiikhalil [Thu, 29 Oct 2020 06:05:25 +0000 (09:05 +0300)]
[Label Bot] Adds some languages to labeler bot (#6222)

* Adds swift, ts, go, py to labeler bot

* Removes unneeded dir search

3 years agoAuto Labeler Setup, Just C# for now (#6221)
Derek Bailey [Thu, 29 Oct 2020 05:02:32 +0000 (22:02 -0700)]
Auto Labeler Setup, Just C# for now (#6221)

3 years agoAuto Labeler Setup, Just C# for now (#6218)
Derek Bailey [Thu, 29 Oct 2020 04:25:02 +0000 (21:25 -0700)]
Auto Labeler Setup, Just C# for now (#6218)

* Auto Labeler Setup, Just C# for now

* Removed trailer comma as that might caused the issue

* Removed any[].

* Changed .cs glob

3 years agoUpdated comments and fixed a fundamental type error. (#6214)
Casper [Thu, 29 Oct 2020 02:23:22 +0000 (19:23 -0700)]
Updated comments and fixed a fundamental type error. (#6214)

* Updated comments and fixed a fundemental type error.

* bump rust flatbuffers semver

Co-authored-by: Casper Neo <cneo@google.com>
3 years agooptional scalars for ts/js (#6215)
Kamil Rojewski [Wed, 28 Oct 2020 16:45:23 +0000 (17:45 +0100)]
optional scalars for ts/js (#6215)

* optional scalars for ts/js

* removed range based for

* removed range based for

3 years agoAdds NetTest.bat to run .NET Core tests on Windows (#6216)
Derek Bailey [Wed, 28 Oct 2020 05:51:58 +0000 (22:51 -0700)]
Adds NetTest.bat to run .NET Core tests on Windows (#6216)

3 years ago[Java] Implement optional scalars (#6212)
Paulo Pinheiro [Tue, 27 Oct 2020 00:46:50 +0000 (01:46 +0100)]
[Java] Implement optional scalars (#6212)

Java implementation of optional scalars, following issue #6014.

3 years agoEmpties the sharedString map on reset on go and csharp (#6187)
mustiikhalil [Mon, 26 Oct 2020 19:38:24 +0000 (22:38 +0300)]
Empties the sharedString map on reset on go and csharp (#6187)

Fixes go tests

3 years agoRemoved C# references from java generator. Move annotations closer to definitions...
Derek Bailey [Mon, 26 Oct 2020 04:42:29 +0000 (21:42 -0700)]
Removed C# references from java generator. Move annotations closer to definitions (#6204)

3 years agoAdds readable size to asserts in read functions (#6210)
mustiikhalil [Sun, 25 Oct 2020 12:59:30 +0000 (15:59 +0300)]
Adds readable size to asserts in read functions (#6210)

3 years agoRefactor idl_gen_rust (#6206)
Casper [Sat, 24 Oct 2020 22:46:55 +0000 (15:46 -0700)]
Refactor idl_gen_rust (#6206)

* Refactor idl_gen_rust to a ForAllX continuation pattern.
* Updated rust sample code

Co-authored-by: Casper Neo <cneo@google.com>
3 years agoFix typo in flatbuffers::span declaration. (#6202)
Vladimir Glavnyy [Thu, 22 Oct 2020 21:07:29 +0000 (04:07 +0700)]
Fix typo in flatbuffers::span declaration. (#6202)

3 years agoKotlin test optional enum (#6201)
Paulo Pinheiro [Thu, 22 Oct 2020 20:36:02 +0000 (22:36 +0200)]
Kotlin test optional enum (#6201)

* Add test for optional enums in Kotlin

* Rename optional_scalars2.fbs into optional_scalars.fbs

Also updated all references in the project to point to
"optional_scalars.fbs" instead of "optional_scalars2.fbs".

3 years agoMass Refactoring to use `IsString` and other BASE_TYPE helpers (#6193)
Casper [Tue, 20 Oct 2020 15:00:31 +0000 (08:00 -0700)]
Mass Refactoring to use `IsString` and other BASE_TYPE helpers (#6193)

* Updated SupportsAdvancedUnionFeatures to look out for string

* Mass refactoring to use BASE_TYPE helper functions.

Co-authored-by: Casper Neo <cneo@google.com>
3 years agoUpdated SupportsAdvancedUnionFeatures to look out for string (#6190)
Casper [Mon, 19 Oct 2020 20:16:00 +0000 (13:16 -0700)]
Updated SupportsAdvancedUnionFeatures to look out for string (#6190)

Co-authored-by: Casper Neo <cneo@google.com>
3 years ago[JS/TS] Rewrite flexbuffers JS to TS (#6148)
Björn Harrtell [Mon, 19 Oct 2020 20:11:35 +0000 (22:11 +0200)]
[JS/TS] Rewrite flexbuffers JS to TS (#6148)

* Partial TS rewrite

* Completed port but bugs remain

* Expose builder function

* Break out and fix stack-value and formatting

3 years agoRework enums in rust. (#6098)
Casper [Mon, 19 Oct 2020 18:40:03 +0000 (11:40 -0700)]
Rework enums in rust. (#6098)

* Rework enums in rust.

They're now a unit struct, rather than an enum. This is a
backwards incompatible change but the previous version had UB
and was also backwards incompatible so...

* Update and test sample rust flatbuffers

* Use bitflags crate to properly support rust enums.

Previously, the bitflags attribute was just ignored. This is a breaking change
as the bitflgs API is not like a normal rust enum (duh).

* variant_name() -> Option<_>

* repr transparent

* Reexport bitflags from flatbuffers

* Make bitflags constants CamelCase, matching normal enums

* Deprecate c-style associated enum constants

Co-authored-by: Casper Neo <cneo@google.com>
3 years agoidl_gen_json_schema Fix generation of arrays of enums (#6184)
schoetbi [Fri, 16 Oct 2020 17:43:09 +0000 (19:43 +0200)]
idl_gen_json_schema Fix generation of arrays of enums (#6184)

* idl_gen_json_schema.cpp: Fixed generation of arrays of enums
#6175

* Fixed failing unit tests

* GenBaseType generate "integer".
Fixes #6066

* Ran tests/generate_code.

* Removed modern R"()" strings

* changed std::to_string to NumToString

3 years agofix(go_test): remove deprecated grpc call (#6183)
Niels Hofmans [Thu, 15 Oct 2020 22:47:06 +0000 (00:47 +0200)]
fix(go_test): remove deprecated grpc call (#6183)

3 years agoAdd generation of JSON Schema to library (#6165)
tira-misu [Thu, 15 Oct 2020 22:28:25 +0000 (00:28 +0200)]
Add generation of JSON Schema to library (#6165)

* 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

3 years agoBump junit from 4.12 to 4.13.1 in /grpc/tests (#6173)
dependabot[bot] [Tue, 13 Oct 2020 05:58:29 +0000 (22:58 -0700)]
Bump junit from 4.12 to 4.13.1 in /grpc/tests (#6173)

Bumps [junit](https://github.com/junit-team/junit4) from 4.12 to 4.13.1.
- [Release notes](https://github.com/junit-team/junit4/releases)
- [Changelog](https://github.com/junit-team/junit4/blob/main/doc/ReleaseNotes4.12.md)
- [Commits](https://github.com/junit-team/junit4/compare/r4.12...r4.13.1)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
3 years agoBump junit from 4.12 to 4.13.1 in /grpc (#6172)
dependabot[bot] [Tue, 13 Oct 2020 05:58:03 +0000 (22:58 -0700)]
Bump junit from 4.12 to 4.13.1 in /grpc (#6172)

Bumps [junit](https://github.com/junit-team/junit4) from 4.12 to 4.13.1.
- [Release notes](https://github.com/junit-team/junit4/releases)
- [Changelog](https://github.com/junit-team/junit4/blob/main/doc/ReleaseNotes4.12.md)
- [Commits](https://github.com/junit-team/junit4/compare/r4.12...r4.13.1)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
3 years ago[C++] Add option to not generate direct copy methods. (#6166)
astange [Mon, 12 Oct 2020 19:25:10 +0000 (15:25 -0400)]
[C++] Add option to not generate direct copy methods. (#6166)

* Add option to not generate direct copy methods.

The direct copy methods generated by flatc utilize std::vector which isn't allowed on some embedded systems. Permit users of the compiler to not generate these methods so they don't have to be stubbed out.

* Update docs for no-cpp-direct-copy option.

3 years agoAdd Array initialization from struct constructor (#5865) (#6147)
Vladimir Glavnyy [Mon, 12 Oct 2020 19:24:18 +0000 (02:24 +0700)]
Add Array initialization from struct constructor (#5865) (#6147)

- add flatbuffers::span
- add new constructor for `struct` with `array`
- add some test for flatbuffers::span and 'arrays_test.fbs'

3 years agoCast to right type for reserved_ subtraction (#6167)
astange [Mon, 12 Oct 2020 16:14:45 +0000 (12:14 -0400)]
Cast to right type for reserved_ subtraction (#6167)

reserved_ is a size_t so ensure that the output of cur_ - buf_ is cast to that to avoid compiler warnings.

3 years agoFixed rust nested flatbuffers for tables other than self (#6062)
Casper [Sat, 10 Oct 2020 18:49:02 +0000 (11:49 -0700)]
Fixed rust nested flatbuffers for tables other than self (#6062)

* Fixed rust nested flatbuffers for tables other than self

* replaced lifetimes

* Use WrapInNameSpace and also update samples

Co-authored-by: Casper Neo <cneo@google.com>
3 years ago[C++] Fix -Wnarrowing and -Woverflow due to signed bitfields on G++ ARM (#6163)
Anass Al [Thu, 8 Oct 2020 15:00:40 +0000 (08:00 -0700)]
[C++] Fix -Wnarrowing and -Woverflow due to signed bitfields on G++ ARM (#6163)

Older versions of GCC (at least on ARM) complain about narrowing conversions and
overflows when setting the reference index (defined as an 11-bit signed integer
bitfield) to -1:

```
error: narrowing conversion of '-1' from 'int' to 'short unsigned int' inside { } [-Wnarrowing]
error: conversion from 'short unsigned int' to 'short unsigned int:11' changes value from '65535' to '2047'
```

This is due to the signedness of integer bitfields (not explicitly signed or
unsigned) being implementation-defined. This addresses this issue by explicitly
defining the signedness of all the bitfields in `flatbuffers::TypeCode` in C++.

3 years ago[TS] GRPC Implementation (#6141)
mustiikhalil [Wed, 7 Oct 2020 16:56:30 +0000 (19:56 +0300)]
[TS] GRPC  Implementation (#6141)

* GRPC implementation for Typescript

* Fixes a couple of issues

* Finished implementing the typescript support for grpc

* Updated generated code

* Fixes CI

3 years agoMoved C++ to optional_scalars2 and added some tests. (#6162)
Casper [Wed, 7 Oct 2020 16:46:09 +0000 (09:46 -0700)]
Moved C++ to optional_scalars2 and added some tests. (#6162)

* Moved C++ to optional_scalars2 and added some tests.

Also deleted unused optional_scalars_generated.lobster

* Fixed whitespece in C++ gencode & fixed BUILD file

* Moved C++ onto optional_scalars2 in the .bat file

Co-authored-by: Casper Neo <cneo@google.com>
3 years ago[Rust] Upgrade flatbuffers library to 2018 edition (#6159)
ImmConCon [Tue, 6 Oct 2020 22:55:22 +0000 (00:55 +0200)]
[Rust] Upgrade flatbuffers library to 2018 edition (#6159)

* [Rust] Upgrade flatbuffers lib to 2018 edition

* Pushed version

3 years agoFlatbuffer C++ UnpackTo optimization for vectors of non-bool bytes. (#6154)
mrmarkwell [Tue, 6 Oct 2020 17:56:45 +0000 (10:56 -0700)]
Flatbuffer C++ UnpackTo optimization for vectors of non-bool bytes. (#6154)

UnpackTo copies vector elements one-by-one, which can be very inefficient depending on the quality of the compiler optimizations performed. This change updates the operation for vectors of bytes that aren't enums to use 'std::copy', which is usually highly optimized.

vectors of types that are more than one byte can't be optimized in this way because of the endianness of the serialized bytes vs. the target architecture endianness.

vectors of enums can't be optimized because they are required to be static_cast into the appropriate enum type when stored in the vector.

vectors of bools can be optimized in most cases, but since the standard
allows std::vector<bool> template specialization for space-savings,
std::copy doesn't work on every implementation (looking at you
Microsoft). Thus, this optimization is skipped for vector<bool>.

For a specific example, this improves the latency of unpacking large buffers on the Hexagon DSP by about 10x.

Co-authored-by: Matthew Markwell <markwell@google.com>
3 years agoEnables optional enums in swift (#6160)
mustiikhalil [Tue, 6 Oct 2020 16:00:14 +0000 (19:00 +0300)]
Enables optional enums in swift (#6160)

[Swift] Enables optional enums

3 years agoUpdated Lobster test for optional bools/enums
Wouter van Oortmerssen [Fri, 2 Oct 2020 17:53:47 +0000 (10:53 -0700)]
Updated Lobster test for optional bools/enums

The codegen for this was already correct, just added more tests

3 years agoRuopt enum (#6156)
Casper [Fri, 2 Oct 2020 17:30:39 +0000 (10:30 -0700)]
Ruopt enum (#6156)

* Rust support for optional enums

* make optional_scalars2 for languages that support optional enums

Co-authored-by: Casper Neo <cneo@google.com>
3 years agoFix generation of C++ code with Optional<Enum> (#6155)
Vladimir Glavnyy [Fri, 2 Oct 2020 17:27:30 +0000 (00:27 +0700)]
Fix generation of C++ code with Optional<Enum> (#6155)

3 years ago[C#] Fix and improve project files (#6142)
Conan Chen [Mon, 28 Sep 2020 18:56:59 +0000 (14:56 -0400)]
[C#] Fix and improve project files (#6142)

* [C#] Fix and improve project files

* "net35" target included for Unity 5
* "net46" target included for Unity 2017
* "netstandard2.0" target included for Unity 2018 and general use
* "netstandard2.1" target included for Span<T> support

Included project properties for defining UNSAFE_BYTEBUFFER, BYTEBUFFER_NO_BOUNDS_CHECK, and ENABLE_SPAN_T conditional compilation symbols.

* Add documentation on building for C#

3 years agopossibility to create a vector from an iterator (#6135)
Kamil Rojewski [Mon, 28 Sep 2020 16:45:48 +0000 (18:45 +0200)]
possibility to create a vector from an iterator (#6135)