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

3 years agoflatc should output a warning, when an attribute is attached more than once (#6146)
Stefan F [Mon, 28 Sep 2020 16:28:47 +0000 (18:28 +0200)]
flatc should output a warning, when an attribute is attached more than once (#6146)

* 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;

3 years ago[Python/JS/TS] Codegen SizeOf method for structs (#6136)
Anass Al [Mon, 28 Sep 2020 15:54:50 +0000 (08:54 -0700)]
[Python/JS/TS] Codegen SizeOf method for structs (#6136)

* [Python] Codegen SizeOf classmethod for structs

This codegens a `SizeOf()` classmethod for all structs since we can't
determine the size of a FlatBuffer generated struct from Python otherwise.

* [JS/TS] Codegen sizeOf static method for structs

This codegens a `sizeOf()` static method for all structs since we can't
determine the size of a FlatBuffer generated struct from JavaScript or
TypeScript otherwise.

3 years agounix2dos on tests/FlatBuffers.Test/FlatBuffers.Core.Test.csproj (#6133)
石晓伟 [Mon, 28 Sep 2020 15:10:06 +0000 (23:10 +0800)]
unix2dos on tests/FlatBuffers.Test/FlatBuffers.Core.Test.csproj (#6133)

3 years agoSpanT is available in .Net Standard 2.0. (#6137)
春条 [Fri, 25 Sep 2020 17:39:28 +0000 (02:39 +0900)]
SpanT is available in .Net Standard 2.0. (#6137)

3 years agoAdd static cast to avoid implicit double promotion. (#6132)
Nat Jeffries [Thu, 24 Sep 2020 16:35:29 +0000 (09:35 -0700)]
Add static cast to avoid implicit double promotion. (#6132)

Add static cast from float to double in flexbuffers.h to avoid implicit double promotion error. This error is surfacing during the tensorflow lite for microcontrollers build since we enabled -Werror and -Wdouble-promotion.

3 years ago[C#]Change to ENABLE_SPAN_T that doesn't require UNSAFE_BYTEBUFFER. (#6073)
春条 [Wed, 23 Sep 2020 20:16:00 +0000 (05:16 +0900)]
[C#]Change to ENABLE_SPAN_T that doesn't require UNSAFE_BYTEBUFFER. (#6073)

* ENABLE_SPAN_T doesn't require UNSAFE_BYTEBUFFER.

Change to ENABLE_SPAN_T that doesn't require UNSAFE_BYTEBUFFER.

* Selectable framework.

Changed target framework to allow selection of 2.0 or 2.1 (or higher)

* Added target framework version check.

* Add core test project.

* Added run on .Net Core.

3 years agoRevert "[C#] Fix and improve project files (#6116)" (#6130)
Derek Bailey [Wed, 23 Sep 2020 20:14:51 +0000 (13:14 -0700)]
Revert "[C#] Fix and improve project files (#6116)" (#6130)

This reverts commit 750281630b097dc311b3a18578c82e98ba2438db.

3 years agoMinireflect fixed array (#6129)
Mark Nauwelaerts [Wed, 23 Sep 2020 00:57:01 +0000 (02:57 +0200)]
Minireflect fixed array (#6129)

* CMakeLists: also really generate optional_scalars as needed by test elsewhere

* [C++] Handle fixed-length array in minireflection

Fixes #6128

3 years ago[JS/TS] fix flatbuffers default export (#6123)
Björn Harrtell [Mon, 21 Sep 2020 16:46:24 +0000 (18:46 +0200)]
[JS/TS] fix flatbuffers default export (#6123)

* [TS/JS] Export flatbuffers namespace as default export

* [TS/JS] Fully qualified name

* Export as default and named

3 years agoAdd missed file generated by optional_scalar.fbs (#6125)
Vladimir Glavnyy [Mon, 21 Sep 2020 16:37:01 +0000 (23:37 +0700)]
Add missed file generated by optional_scalar.fbs (#6125)

3 years ago[C#] Fix and improve project files (#6116)
Conan Chen [Mon, 21 Sep 2020 16:32:59 +0000 (12:32 -0400)]
[C#] Fix and improve project files (#6116)

* [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 compiler constants.

* Add documentation on building for C#

3 years agoAdd CharToLower and CharToUpper into util.s (#6126)
Vladimir Glavnyy [Mon, 21 Sep 2020 16:31:27 +0000 (23:31 +0700)]
Add CharToLower and CharToUpper into util.s (#6126)

This commit adds replacement of `::tolower` and `::toupper`.
Added CharToLower and CharToUpper routines reduce the number of cast operators
that required for correct usage of standard C/C++ `::tolower/toupper` routines.

3 years agoAdd support of Optional<T> scalars to C++ code generator (#6092)
Vladimir Glavnyy [Fri, 18 Sep 2020 19:51:17 +0000 (02:51 +0700)]
Add support of Optional<T> scalars to C++ code generator (#6092)

3 years ago[Kotlin] Support for optional scalars. (#6115)
Paulo Pinheiro [Fri, 18 Sep 2020 06:31:51 +0000 (08:31 +0200)]
[Kotlin] Support for optional scalars. (#6115)

More information on #6014

3 years agoBump version for latest swift version (#6121)
mustiikhalil [Thu, 17 Sep 2020 19:28:42 +0000 (22:28 +0300)]
Bump version for latest swift version (#6121)

3 years ago[JS/TS] Modernize TypeScript / JavaScript flatbuffers support (#6095)
Björn Harrtell [Thu, 17 Sep 2020 19:21:14 +0000 (21:21 +0200)]
[JS/TS] Modernize TypeScript / JavaScript flatbuffers support (#6095)

3 years ago[JS] Add getFullyQualifiedName() (#6119)
Anass Al [Thu, 17 Sep 2020 19:19:07 +0000 (12:19 -0700)]
[JS] Add getFullyQualifiedName() (#6119)

This optionally generates a static `getFullyQualifiedName()` function to get
the fully-qualified name of a type in JavaScript and TypeScript in a similar
fashion to the C++ codegen.

3 years ago[Java] allowing larger buffer sizes when growing a byte buffer (#6118)
Diogo Monteiro [Thu, 17 Sep 2020 18:55:24 +0000 (19:55 +0100)]
[Java] allowing larger buffer sizes when growing a byte buffer (#6118)

Related with issue #6113.

`(old_buf_size & 0xC0000000) != 0` checks if we can duplicate old_buf_size
 and still be under 2GB (by checking if bit 30 or 31 is 1). This doesn't
allow buffers larger than 1GB.

The strategy now is to allocate a buffer with the maximum array size
when we detect that we are overflowing the 2GB.

Also changed default buffer size to 1024.

3 years ago[Swift] Migrates struct write APIS to write directly to the buffer (#6093)
mustiikhalil [Thu, 17 Sep 2020 14:10:59 +0000 (17:10 +0300)]
[Swift] Migrates struct write APIS to write directly to the buffer (#6093)

* Migrates struct write APIS to in place APIS

* Fixes indentation in grpc swift

3 years agoOptional-ness in reflection (#6097)
Casper [Fri, 11 Sep 2020 21:20:32 +0000 (14:20 -0700)]
Optional-ness in reflection (#6097)

* Optional scalars in reflection

* fixed name collision

* Remove code duplicated by merge

Co-authored-by: Casper Neo <cneo@google.com>
3 years agoRename Nullable scalars to Optional scalars (#6112)
Casper [Thu, 10 Sep 2020 20:04:36 +0000 (16:04 -0400)]
Rename Nullable scalars to Optional scalars (#6112)

Co-authored-by: Casper Neo <cneo@google.com>
3 years agoAvoid memcpy call for empty vectors (#6111)
Ruslan Burakov [Thu, 10 Sep 2020 20:03:15 +0000 (23:03 +0300)]
Avoid memcpy call for empty vectors (#6111)

Co-authored-by: kuddai <kuddai92@gmail.com>
3 years ago[JS] FlexBuffers Fix for wrong type of offset and length values (#6107)
Maxim Zaks [Thu, 10 Sep 2020 19:36:37 +0000 (21:36 +0200)]
[JS] FlexBuffers Fix for wrong type of offset and length values (#6107)

* Adding FlexBuffers support for Dart language

* Introduce snapshot method.

* Fix docu

* Replacing extension methods with static methods in order to support older Dart version

* Improving code based on PR feedback. Mainly rename refactoring.

* Addressing all PR feedback which does not need clarification

* exchange dynamic type with Object

* Adds better API documentation.
[] operator throws a very descriptive exception in case of a bad key.

* Implementation of JavaScript FlexBuffers decoder

* implements JS FlexBuffers builder

* replacing _toF32 with Math.fround

* Introducing test for BigInt number

* Moving functions from BitWitdth & ValueType object into BitWidthUtil and ValueTypeUtil accordingly.
Removing defensive checks.
Introducing fix for large int numbers by converting them to BigInt type.
Introducing handling for BigInt type in `add` method.
Using TextEncoder and Decoder to handle string / utf8 conversion.

* rename variable

* Lets user turn deduplication strategies for strings, keys and vector of keys off while building FlexBuffer.
Implements quick sort and choses quick sort if the number of keys is bigger then 20.
Removes unnecessary dict lookups in BitWidthUtil helper functions

* make iwidth and uwidth computation simpler and faster

* Making redInt and readUint a bit faster and shim the BigInt / BigUint usage

* Fixing a bug in FlexBuffers JS, where offsets and lengths are stored and read as int and not as uint values.

* Fixing a bug in FlexBuffers Dart, where offset and length values are stored and read as int values instead of uint values

3 years agofix c# json serializer commandline argument docs (#6104)
mugisoba [Wed, 9 Sep 2020 22:02:24 +0000 (07:02 +0900)]
fix c# json serializer commandline argument docs (#6104)

3 years agoFix for issue 6100: incorrect shrinking logic in ResizeContext() (#6102)
Laurentiu Cristofor [Fri, 4 Sep 2020 22:52:13 +0000 (15:52 -0700)]
Fix for issue 6100: incorrect shrinking logic in ResizeContext() (#6102)

3 years ago[JS] FlexBuffers Support (#5973)
Maxim Zaks [Mon, 31 Aug 2020 19:16:55 +0000 (21:16 +0200)]
[JS] FlexBuffers Support (#5973)

* Adding FlexBuffers support for Dart language

* Introduce snapshot method.

* Fix docu

* Replacing extension methods with static methods in order to support older Dart version

* Improving code based on PR feedback. Mainly rename refactoring.

* Addressing all PR feedback which does not need clarification

* exchange dynamic type with Object

* Adds better API documentation.
[] operator throws a very descriptive exception in case of a bad key.

* Implementation of JavaScript FlexBuffers decoder

* implements JS FlexBuffers builder

* replacing _toF32 with Math.fround

* Introducing test for BigInt number

* Moving functions from BitWitdth & ValueType object into BitWidthUtil and ValueTypeUtil accordingly.
Removing defensive checks.
Introducing fix for large int numbers by converting them to BigInt type.
Introducing handling for BigInt type in `add` method.
Using TextEncoder and Decoder to handle string / utf8 conversion.

* rename variable

* Lets user turn deduplication strategies for strings, keys and vector of keys off while building FlexBuffer.
Implements quick sort and choses quick sort if the number of keys is bigger then 20.
Removes unnecessary dict lookups in BitWidthUtil helper functions

* make iwidth and uwidth computation simpler and faster

* Making redInt and readUint a bit faster and shim the BigInt / BigUint usage

3 years ago[C++] Small refactoring of the C++ code generator (#6091)
Vladimir Glavnyy [Mon, 31 Aug 2020 19:13:23 +0000 (02:13 +0700)]
[C++] Small refactoring of the C++ code generator (#6091)

This commit performs refactoring (Extract Method) of the C++ code generator.
It extracts code generation of a table getter/mutator into separated methods.

3 years agoWrap verify file id condition in Check call (#6085)
Navin Mohan [Mon, 31 Aug 2020 18:32:13 +0000 (00:02 +0530)]
Wrap verify file id condition in Check call (#6085)

Run clang-format

Update testcase

3 years ago+ Add `removable-media` plug to the snapcraft config (#6083)
Wybe Westra [Mon, 24 Aug 2020 16:55:38 +0000 (18:55 +0200)]
+ Add `removable-media` plug to the snapcraft config (#6083)

3 years agoAdds proper access types for swift object api & flatbuffers & grpc (#6081)
mustiikhalil [Sat, 22 Aug 2020 19:39:09 +0000 (22:39 +0300)]
Adds proper access types for swift object api & flatbuffers & grpc (#6081)

Fixes accessor in greeter.swift

Small fix for ci

3 years ago[Lobster] missed a test
Wouter van Oortmerssen [Tue, 18 Aug 2020 21:29:44 +0000 (14:29 -0700)]
[Lobster] missed a test

3 years ago[CMake] enabled multi-core builds in VS projects
Wouter van Oortmerssen [Tue, 18 Aug 2020 21:00:22 +0000 (14:00 -0700)]
[CMake] enabled multi-core builds in VS projects