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

3 years ago[Lobster] optional scalars support
Wouter van Oortmerssen [Tue, 18 Aug 2020 21:00:02 +0000 (14:00 -0700)]
[Lobster] optional scalars support

3 years ago[Kotlin] Attach JvmStatic annotation to each method in companion object (#6052)
Yoon Kyong Sik [Tue, 18 Aug 2020 16:44:43 +0000 (01:44 +0900)]
[Kotlin] Attach JvmStatic annotation to each method in companion object (#6052)

* Attach JvmStatic annotation to each method of companion object

Kotlin does not have static accessor so companion object used instead of static.
It's so natural. But when use kotlin companion object methods on java it is very inconvenient.
```java
GeneratedClassByFlatBuffer.Companion.someMethod()
```

If use @JvmStatic annotation it can be shorten like below.
```java
GeneratedClassByFlatBuffer.someMethod()
```

* Formatting by Idea Google C++ style

* Add comments - Commit for missing cla

Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Add comments - Commit for missing cla

Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Reset code formatting except modified lines

Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Pass missing flag to validateVersion method

Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Add annotations to missing method in companion object

* addVector
* createVector
* endVector
* tableCreator

And also I tried add compiler option for generate annotation who don't like this operation.

Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Modify unmatched option name in compiler usage

Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Add missing operation for finishSizePrefixed and finishStructBuffer method.

Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Add compiled example with --kotlin-gen-jvmstatic option.

Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Fix Compiler.md

Change option name from --gen-jvm-static-annotation to --kotlin-gen-jvmstatic

Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Use IDLOptions reference instead of bool parameter.

Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Change option name - kotlin_gen_jvmstatic to gen_jvmstatic

Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Use IDLOptions reference instead of bool parameter and missing process @JvmStatic as suffix.

Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Add code generation for --gen-jvmstatic option

Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Miss typo directory for including.

Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Miss typo variable suffix for including.

Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Fix camel case to snake case.

Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Rollback generate code for gen_jvmstatic option.

Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Delete generated test files.

Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* add missing new line at end of file.

Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Remove generated test file by command line.

Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
Co-authored-by: sam <sam@jennifersoft.com>
3 years ago[C#] Cleaned up .NET testing script for Mono (#6016)
Derek Bailey [Mon, 17 Aug 2020 20:10:10 +0000 (13:10 -0700)]
[C#] Cleaned up .NET testing script for Mono (#6016)

* Cleaned up .NET testing script for Mono

Cleaned up the .NET testing script to make it a little better. It
purposefully doesn't delete the .NET installer and SDk after running the
script, so that they can be used in subsequent invocations. This greatly
speeds up the script.

The downloaded files are ignored by git by default. They can be
explicitly cleaned up by runnning the clean script (clean.sh).

* Trying using older Version indicator

* Remove lins to monsterdata and reference it directly.

* Updated appveryor script to remove copying of files no longer needed

* Continue to update appveyor script to work. Disabled CS0169 in ByteBufferTest

4 years agoAdds a serialize helper function to native table (#6059)
mustiikhalil [Tue, 4 Aug 2020 10:53:40 +0000 (13:53 +0300)]
Adds a serialize helper function to native table (#6059)

* Adds a serialize helper function to native table
* Updated version

4 years ago[TS] Fix four bugs with imported types in TypeScript. (#6054)
Max Burke [Mon, 3 Aug 2020 19:08:52 +0000 (12:08 -0700)]
[TS] Fix four bugs with imported types in TypeScript. (#6054)

* [TS] Fix four bugs with imported types in TypeScript.

* When a type had a vector of imported enums:

1) the enum type's file wasn't added to the generated code's list of
imports; and

2) the enum wasn't prefixed with the NS<hash> prefix and wasn't getting
resolved; but

3) non-enum types (ie, "flatbuffers.Offset") were getting the NS<hash>
prefix when they weren't.

* Also, type name prefixes weren't properly attributed with imported
structs in unions because the source definition passed to the typename
prefixing method was for the union, not for the location of the imported
struct.

* clang fmt

* Use of enum_def / struct_def for prefixing types needs to have the files
added to imported files when not generating all types.

* clang fmt

4 years ago[Swift] Append namespace for Swift Grpc implementation (#6049)
Liu Liu [Fri, 31 Jul 2020 07:07:45 +0000 (00:07 -0700)]
[Swift] Append namespace for Swift Grpc implementation (#6049)

* [Swift] Append namespace for Swift Grpc implementation
* Separate ServiceName from ServiceQualifiedName.

4 years agoexport a __version__ variable for python module (#5309)
Omer Akram [Thu, 30 Jul 2020 22:56:21 +0000 (03:56 +0500)]
export a __version__ variable for python module (#5309)

* export a __version__ variable for python module

* assign version to be used below

* better support python2

* Add copyright header

4 years agoadding fb import when no other imports are present (#6030)
Kamil Rojewski [Thu, 30 Jul 2020 22:55:11 +0000 (00:55 +0200)]
adding fb import when no other imports are present (#6030)

Co-authored-by: Kamil Rojewski <kamil.rojewski@gmail.com>
Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
4 years ago[Feature] Checks for Nullable strings (#6050)
mustiikhalil [Mon, 27 Jul 2020 16:57:50 +0000 (19:57 +0300)]
[Feature] Checks for Nullable strings (#6050)

* Allows null strings in createString method c#

* Adds nullable strings to JS and swift

* Changes js checks

* Fixes typo

4 years ago[Swift] RFC: Switch Swift namespace from public enum to ordinary concat with _ (...
Liu Liu [Mon, 27 Jul 2020 08:06:11 +0000 (01:06 -0700)]
[Swift] RFC: Switch Swift namespace from public enum to ordinary concat with _ (#6045)

This PR attempts to switch namespace from public enum back to ordinary
concat with _ in Swift. This kept style similar with protobuf, but
different from other popular style guide in Swift.

This is needed because previously, when we do `public enum`, we don't
really know when to declare and when to extend (extension). With namespace
implementation in this PR, there is no such ambiguity.

4 years agoRust codegen improvements and lint fixes (#6046)
Casper [Sat, 25 Jul 2020 20:46:20 +0000 (13:46 -0700)]
Rust codegen improvements and lint fixes (#6046)

* Improve rust codegen

* one more unneeded lifetime

* Added a derive default

Co-authored-by: Casper Neo <cneo@google.com>
4 years agoadds code gen for optional scalars in swift (#6038)
mustiikhalil [Sat, 25 Jul 2020 14:59:34 +0000 (17:59 +0300)]
adds code gen for optional scalars in swift (#6038)

Adds swift test code

Replaces if statments

Adds swift to supported languages for optionals

Moved std::string to auto

Adds nullable scalars support in object api

4 years ago[C++] Fix compiler error from deleted assignment operator (#6036) (#6047)
jdess [Fri, 24 Jul 2020 17:35:27 +0000 (19:35 +0200)]
[C++] Fix compiler error from deleted assignment operator (#6036) (#6047)

* [C++] Fix compiler error from deleted assignment operator (#6036)

The assignment operator of the `buf_` member is deleted, we cannot call it from the assignment operator of the `TableKeyComparator` struct.

=> Also delete the assignment operator of the `TableKeyComparator` struct (already private anyhow).

* [C++] Fix compiler error from deleted assignment operator (#6036) - fix extraneous semicolon

The assignment operator of the `buf_` member is deleted, we cannot call it from the assignment operator of the `TableKeyComparator` struct.

=> Also delete the assignment operator of the `TableKeyComparator` struct (already private anyhow).

4 years agoOptional Scalars support for Rust (#6034)
Casper [Thu, 23 Jul 2020 23:30:27 +0000 (16:30 -0700)]
Optional Scalars support for Rust (#6034)

* First draft of rust optionals

* Code cleanup around ftBool and ftVectorOfBool

* Tests for Rust optional scalars

* test bools too

Co-authored-by: Casper Neo <cneo@google.com>
4 years agoAllow to run cpp tests under grpc/tests/ using bazel. (#6040)
Shengzhe [Tue, 21 Jul 2020 18:08:01 +0000 (11:08 -0700)]
Allow to run cpp tests under grpc/tests/ using bazel. (#6040)

This is the first step to upgrade grpc dependency to the latest version.

- Patch protobuf 3.6.1. and grpc 1.15.1 to fix build errors when using the latest Bazel version (3.4.1).
- Add grpc/tests:grpc_test. One can kick off tests in Bazel by calling `bazel test grpc/tests/...`.
- Add missing build targets in tests/BUILD in order to support grpc/tests/BUILD

4 years agoFix git command executed in wrong folder when doing cmake superbuild (#6039)
Olivier Le Doeuff [Mon, 20 Jul 2020 19:26:01 +0000 (21:26 +0200)]
Fix git command executed in wrong folder when doing cmake superbuild (#6039)

4 years ago[Swift] Optional Scalars Preparation (#6028)
mustiikhalil [Mon, 20 Jul 2020 17:38:50 +0000 (20:38 +0300)]
[Swift] Optional Scalars Preparation (#6028)

* Perpares swift to take optional scalars + adds optional string helper method + disables linters in generated code

* Small fix for generated code

* Update grpc support to alpha 17 for swift

4 years agotests: Check for both quiet and signaling NaN on mipsel/hppa (#6029)
Vasyl Gello [Mon, 20 Jul 2020 17:18:02 +0000 (20:18 +0300)]
tests: Check for both quiet and signaling NaN on mipsel/hppa (#6029)

MIPSEL, MIPS64EL and HP-PA architectures have quiet and
signaling NaNs swapped. The test assumes correct values
for i386 / amd64 but obviously fails on these architectures.
It is documented in many places, like

https://software.llnl.gov/yorick-doc/stdlib/ieee.html :

Warning-- apparently there is no universal standard for what
  constitutes signalling versus quiet NaN
  on MIPS and HPPA architectures, qNaN and sNaN are reversed

https://gcc.gnu.org/onlinedocs/gcc/MIPS-Options.html :

  -mnan=2008
  -mnan=legacy

  These options control the encoding of the special
  not-a-number (NaN) IEEE 754 floating-point data.

  The -mnan=legacy option selects the legacy encoding.
  In this case quiet NaNs (qNaNs) are denoted by the first
  bit of their trailing significand field being 0, whereas
  signaling NaNs (sNaNs) are denoted by the first bit of
  their trailing significand field being 1.

  The -mnan=2008 option selects the IEEE 754-2008 encoding.
  In this case qNaNs are denoted by the first bit of their
  trailing significand field being 1, whereas sNaNs are
  denoted by the first bit of their trailing significand
  field being 0.

  The default is -mnan=legacy unless GCC has been configured
  with --with-nan=2008.

The behavior mentioned above causes FTBFS in Debian starting
with 1.12.0:

https://buildd.debian.org/status/fetch.php?pkg=flatbuffers&arch=mips64el&ver=1.12.1%7Egit20200711.33e2d80%2Bdfsg1-0.1&stamp=1594830681&raw=0
https://buildd.debian.org/status/fetch.php?pkg=flatbuffers&arch=mipsel&ver=1.12.1%7Egit20200711.33e2d80%2Bdfsg1-0.1&stamp=1594832647&raw=0
https://buildd.debian.org/status/fetch.php?pkg=flatbuffers&arch=hppa&ver=1.12.1%7Egit20200711.33e2d80%2Bdfsg1-0.1&stamp=1594830726&raw=0

For HP-PA (PA-RISC) there is no way to override the reversal,
and for MIPSEL/MIPS64EL there is no macro defining the '-mnan'
choice, so both variants were added with OR boolean operator.

Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
4 years agosupport deprecated flag in json schema (#6022)
Dmitry [Thu, 16 Jul 2020 20:49:42 +0000 (23:49 +0300)]
support deprecated flag in json schema (#6022)

4 years agoFlatc parser support for nullable scalars (#6026)
Casper [Thu, 16 Jul 2020 20:43:47 +0000 (13:43 -0700)]
Flatc parser support for nullable scalars (#6026)

* Parser support for nullable scalars

* Use older C++ features

* use default element

* Add a test for json, flexbuffers, and null

* test comments and names

Co-authored-by: Casper Neo <cneo@google.com>
4 years ago[Dart] Generate constant values map for enums (#6025)
Zhaoxuan Jiang [Sat, 11 Jul 2020 00:42:22 +0000 (08:42 +0800)]
[Dart] Generate constant values map for enums (#6025)

Dart schema compiler generated a static getter for enum values, which
always created a new map instance for its callers. See #5819.
Now it generates const map for better performance
and readability.

4 years agoUsing proper symbol name for reexport (#6021)
Kamil Rojewski [Mon, 6 Jul 2020 15:40:56 +0000 (17:40 +0200)]
Using proper symbol name for reexport (#6021)

Co-authored-by: Kamil Rojewski <kamil.rojewski@gmail.com>
4 years agoSilence false positive "-Wstringop-overflow" on GCC 10.0 to 11.0 (#6020)
Vasyl Gello [Mon, 6 Jul 2020 15:38:06 +0000 (18:38 +0300)]
Silence false positive "-Wstringop-overflow" on GCC 10.0 to 11.0 (#6020)

4 years agoUpdated FB import (#6019)
Kamil Rojewski [Thu, 2 Jul 2020 19:44:55 +0000 (21:44 +0200)]
Updated FB import (#6019)

Previous FB import was based on the original early TS implementation
and did not take into accout NPM. There doesn't seem to be a use
for current implemenentation anymore, while NPM compatibility is
needed.

Co-authored-by: Kamil Rojewski <kamil.rojewski@gmail.com>
4 years ago[Java] Add support for shared strings on FlatBufferBuilder. (#6012)
Paulo Pinheiro [Thu, 2 Jul 2020 19:40:56 +0000 (21:40 +0200)]
[Java] Add support for shared strings on FlatBufferBuilder. (#6012)

Added a method FlatBufferBuilder::createSharedString that
enable string sharing for building messages on java.

The shared pool will only contains strings inserted by
this methods.

4 years agoNot using non-existent create method for obj api (#6015)
Kamil Rojewski [Thu, 2 Jul 2020 19:18:21 +0000 (21:18 +0200)]
Not using non-existent create method for obj api (#6015)

Co-authored-by: Kamil Rojewski <kamil.rojewski@gmail.com>
4 years agoCode cleanup + updates test and readme (#6004)
mustiikhalil [Tue, 30 Jun 2020 18:37:43 +0000 (21:37 +0300)]
Code cleanup + updates test and readme (#6004)

Updates Readme + adds asserts

Fixes documentation

4 years agoSerde with bytes maps to Blob (#6009)
Casper [Mon, 29 Jun 2020 02:58:08 +0000 (19:58 -0700)]
Serde with bytes maps to Blob (#6009)

* Serde with_bytes maps to Blob

* Bump rust flexbuffers minor version number

Co-authored-by: Casper Neo <cneo@google.com>
4 years ago[Swift] FlatBuffers createMonster method doesn't treat struct properly (#5992)
Liu Liu [Sun, 28 Jun 2020 09:36:55 +0000 (02:36 -0700)]
[Swift] FlatBuffers createMonster method doesn't treat struct properly (#5992)

* [Swift] FlatBuffers createMonster method doesn't treat struct properly

This PR fixed a issue where a struct is not treated properly when use
create inside.

A example would be the pos inside Monster. The createMonster method
takes an Offset for pos. However, FlatBuffersBuilder.add(struct:)
doesn't really take Offset argument. That means we don't really add a
struct at all for Monster.

It will show up as the pos never set.

This doesn't show up in FlatBuffersMonsterWriterTests.swift because it
implements its own createMonster method, which happens do the dance
properly (i.e. first call create(struct) and then immediately call
add:).

This PR modified the `add(pos:)` interface such that it takes the
UnsafeMutableRawPointer directly, calling `create(struct:)` under the hood.

I can add unit tests once the direction of this PR approved.

* Fix object api pack method codegen.

* Add unit tests that uses Monster.createMonster method to serialize.

* Updated sample_binary.swift

4 years agoManage grpc dependency in Bazel's WORKSPACE file. (#5995)
Shengzhe [Fri, 26 Jun 2020 22:39:23 +0000 (15:39 -0700)]
Manage grpc dependency in Bazel's WORKSPACE file. (#5995)

flatbuffers project currently depends on an old version of GRPC library and has known issues working with the latest version (issue #5836). Therefore, a patch file is created and put under bazel/ directory before supporting the latest GRPC version.

4 years agoAdd warning to schema parser if field name is not snake_case. (#6005)
Derek Bailey [Fri, 26 Jun 2020 18:16:02 +0000 (11:16 -0700)]
Add warning to schema parser if field name is not snake_case. (#6005)

* Added code gen for evolution tests back in.

* General generate code and clang format

* Added code gen for evolution tests back in.

* General generate code and clang format

* reran generate_code.sh

* Added code gen for evolution tests back in.

* General generate code and clang format

* Added code gen for evolution tests back in.

* General generate code and clang format

* Enforce snake_case for schema field names

* Switched to basic for loop, Fixed warning message

4 years ago[Rust] Flexbuffers dependency cleanup and fixes (#5998)
Johan Andersson [Fri, 26 Jun 2020 00:12:10 +0000 (02:12 +0200)]
[Rust] Flexbuffers dependency cleanup and fixes (#5998)

* Fix doc comment warnings

Can't use doc comment "///" syntax on macros, that generates the following warning:

warning: unused doc comment
   --> src\flexbuffer_type.rs:236:5
    |
236 |     /// returns true if and only if the flexbuffer type is `VectorFloat4`.
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ rustdoc does not generate documentation for macros
    |
    = help: to document an item produced by a macro, the macro must produce the documentation as part of its expansion

So switched to just use ordinary "//" comments on these to be warning free

* Upgrade num_enum 0.4.1 -> 0.5.0

* Remove unused and non-working usage of test crates

* Remove usage of abandoned debug_stub_derive crate

Which brought in old pre-v1 syn and quote crates.

This replaces it with just manual Debug trait implementation instead for the 2 cases

4 years agoRe-added Evolution Schema Code Generation Command (#5999)
Derek Bailey [Thu, 25 Jun 2020 22:35:23 +0000 (15:35 -0700)]
Re-added Evolution Schema Code Generation Command (#5999)

* Fixed refractoring issue in reflection/generate_code.sh. Also, mv deletes the original file, so I don't need to clean it up manually in that case.

* Fixed Dart Tests by removing code-gen for included files.

* Added code gen for evolution tests back in.

* General generate code and clang format

* Added evolution schema generation to .bat file

* Added code gen for evolution tests back in.

* General generate code and clang format

* Added evolution schema generation to .bat file

* reran generate_code.sh

* Removed wildcard from generate_code.bat that doesn't work

4 years agoFix RPM install conflict (#6003)
martind1111 [Thu, 25 Jun 2020 22:33:58 +0000 (17:33 -0500)]
Fix RPM install conflict (#6003)