platform/upstream/flatbuffers.git
4 years agoAdd --force-empty-vectors option (#5653)
cryptocode [Fri, 6 Dec 2019 01:33:45 +0000 (02:33 +0100)]
Add --force-empty-vectors option (#5653)

The rationale for this option is that JSON clients typically want empty arrays (i.e [] in the JSON) instead of missing properties, but not empty strings when the value isn't set.
--force-empty is kept as-is, i.e. it will force both empty strings and vectors.

Closes #5652

4 years agoFixed enum min/max values not properly escaped.
Wouter van Oortmerssen [Thu, 5 Dec 2019 22:28:02 +0000 (14:28 -0800)]
Fixed enum min/max values not properly escaped.

Change-Id: I503fbfaff1d2579807ca71a07cca8363dff75e52

4 years agoSplit Bazel targets into multiple packages (#5640)
bttk [Mon, 2 Dec 2019 22:14:48 +0000 (14:14 -0800)]
Split Bazel targets into multiple packages (#5640)

* Split Bazel targets into multiple packages

* Merge /include/BUILD back into /BUILD

4 years agoRemove a static_assert (#5643)
Google AutoFuzz Team [Mon, 2 Dec 2019 22:13:28 +0000 (17:13 -0500)]
Remove a static_assert (#5643)

Having a static_assert on MSAN and ASAN prevents
the fuzzers from being used with different engines,
like TSAN, UBSAN, … but also with fuzzers that aren't
using MSAN/ASAN like afl for example.

4 years agoFlatbuffers Python Object API (#5616)
lu-wang-g [Mon, 2 Dec 2019 22:11:28 +0000 (14:11 -0800)]
Flatbuffers Python Object API (#5616)

* Flatbuffers Python Object API

Implement the logic to generate the Python object API that can
unpack the data from a buf class into an object class, and pack
the data of an object class to a buf class.

* Fix the build issues

Remove unused parameters and replace auto in the for-loop statement
with std::string to make it compatible with VS2010.

* Fix the build issues.

* Add support for Array type

Added logic to handle Array type in Python Object API. Updated the
generated code accordingly.

* Fix the old style casting from int to char

* Fixed another conversion from int to char

* Fixed the import for typing

Importing typing may cause errors when a machine do not have the
moduel typing installed. This PR fixes the issue by guarding
"import typing" with the "try/except" statement.

* Fix issue of iterating the vector of import list

* Update the generated examples using generate_code.sh

* Fix the import order for typing

The import list was stored in unordered_set, so that each generated
codes may have different import order. Therefore, it failed in the
consistency test where two generated copies need to have exactly the
same apperance.

* Optimize unpack using numpy

Use numpy to unpack vector whenever it is possible to improve unpack
performance.

Also, added codegen command for Python specificly in generate_code.sh,
because --no-includes cannot be turn on for Python.

* Fix the import order

* Update generate_code.bat for windows accordingly

* Replace error message with pass

Avoid printing error message for every Python2 users about typing.
Replace it with pass.

4 years ago[Clang 10]: definition of implicit copy constructor for 'TableKeyComparatoris depreca...
Ivan Shynkarenka [Mon, 2 Dec 2019 22:10:09 +0000 (01:10 +0300)]
[Clang 10]: definition of implicit copy constructor for 'TableKeyComparatoris deprecated #5649 (#5650)

4 years ago[docs]: add missing semicolon (#5648)
nilsocket [Mon, 2 Dec 2019 22:01:25 +0000 (22:01 +0000)]
[docs]: add missing semicolon (#5648)

Add missing semicolon for table field.

4 years ago[GO] Fix support for enums with underscores and Unions with imported members (#5600)
Tiago Silva [Tue, 26 Nov 2019 20:25:36 +0000 (20:25 +0000)]
[GO] Fix support for enums with underscores and Unions with imported members (#5600)

* Fix Enum Stringer method when Enum has underscores

Fixes #5481

* Fix go package importing itself when Union has imported members.

4 years agoFix ambiguity of a type deduction in TEST_EQ macro if arguments have `enum class...
Vladimir Glavnyy [Mon, 25 Nov 2019 20:56:47 +0000 (03:56 +0700)]
Fix ambiguity of a type deduction in TEST_EQ macro if arguments have `enum class` type. (#5630)

4 years agoSimplify declarations of x-macro FLATBUFFERS_TD (#5638)
Vladimir Glavnyy [Mon, 25 Nov 2019 20:54:59 +0000 (03:54 +0700)]
Simplify declarations of x-macro FLATBUFFERS_TD (#5638)

4 years agoread vtable size through ReadScalar() (#5636)
FujiZ [Mon, 25 Nov 2019 20:52:42 +0000 (04:52 +0800)]
read vtable size through ReadScalar() (#5636)

4 years agoChanged null checks in test. Removed verifier pointer usage (#5634)
Derek Bailey [Thu, 21 Nov 2019 18:25:31 +0000 (10:25 -0800)]
Changed null checks in test. Removed verifier pointer usage (#5634)

4 years agoAdd testing of C++ with sanitizers (CI-Docker) (#5631)
Vladimir Glavnyy [Mon, 18 Nov 2019 20:16:41 +0000 (03:16 +0700)]
Add testing of C++ with sanitizers (CI-Docker) (#5631)

* Add C++ build testing with clang and gcc

This adds Dockerfiles which test building flatc and the C++ library against clang
and gcc. See discussion at #5119.  It is derived from the Travis CI tooling.

The GRPC tests are failing due to #5099 so those are commented out.

These are run from the .travis.yml file rather than the tests/docker/languages
folder because the builds may each take longer than 30 minutes and were hitting
Travis timeouts.

Parallel builds and build caching attempt to keep the build times low.

* Add GCC 8.3 and Clang 7.0 with sanitizers into CI (based on #5130)

- Add a docker based on Debian Buster.
- Add C++ building scripts for the docker.
- Leak-sanitizer requires SYS_PTRACE.

4 years agoadd namespace prefix in FLATBUFFERS_MAX_BUFFER_SIZE (#5629)
FujiZ [Mon, 18 Nov 2019 20:02:14 +0000 (04:02 +0800)]
add namespace prefix in FLATBUFFERS_MAX_BUFFER_SIZE (#5629)

4 years agoSupport for python grpc - continuing the work from the pull request #4270 #4705 ...
Malar Kannan [Fri, 15 Nov 2019 00:58:35 +0000 (06:28 +0530)]
Support for python grpc - continuing the work from the pull request #4270 #4705 (#5613)

* Support for python grpc

* add few fixes

* Fixes build

* Fix python generator

* Add tests

* Fix grpc python test

* Fix tests and add incomplete python generator

* Fix python generator

* Add python generator methods

* Fix Appveyor build

* grpc python support v0.1

* Update tests

* update grpctest

* Remove duplicated code and fix a brace

* tests for flatbuffers grpc python

* Updated tests + removed SerializeToString, From String

* remove pickle import

* include missing files in ci - BUILD and generated test result

4 years agoRemoved idl_gen_general.cpp and move contents to code_generators.cpp (#5625)
Derek Bailey [Thu, 14 Nov 2019 23:47:58 +0000 (15:47 -0800)]
Removed idl_gen_general.cpp and move contents to code_generators.cpp (#5625)

4 years agoLua cleanup (#5624)
Derek Bailey [Thu, 14 Nov 2019 23:46:47 +0000 (15:46 -0800)]
Lua cleanup (#5624)

4 years ago[C++] Adds basic schema evolution tests (#5611)
Derek Bailey [Thu, 14 Nov 2019 23:44:18 +0000 (15:44 -0800)]
[C++] Adds basic schema evolution tests (#5611)

* Added basic schema evolution tests

* Add BUILD targets for evolution tests. Added to test/generate_code scripts

* Use vector.front() instead of vector.data()

* Added --scoped-enums option for evolution test

4 years ago[C++, C#, Java] Separated C# and Java generators into their own classes (#5618)
Derek Bailey [Mon, 11 Nov 2019 19:37:55 +0000 (11:37 -0800)]
[C++, C#, Java] Separated C# and Java generators into their own classes (#5618)

* Cloned idl_gen_general.cpp to idl_gen_csharp.cpp and removed java references

* Java generator changes

4 years agoadd check for root_type specified for json schema generation (#5622)
Dmitry [Mon, 11 Nov 2019 19:33:27 +0000 (22:33 +0300)]
add check for root_type specified for json schema generation (#5622)

4 years ago[Rust] Bump smallvec version to 1.0 (#5621)
messense [Mon, 11 Nov 2019 17:52:26 +0000 (01:52 +0800)]
[Rust] Bump smallvec version to 1.0 (#5621)

See https://github.com/servo/rust-smallvec/pull/175 for changelog.

4 years agoRan src/clang-format-all.sh (#5617)
Derek Bailey [Mon, 11 Nov 2019 17:29:37 +0000 (09:29 -0800)]
Ran src/clang-format-all.sh (#5617)

4 years agoImproved pull request & clang-format instructions.
Wouter van Oortmerssen [Thu, 7 Nov 2019 22:35:42 +0000 (14:35 -0800)]
Improved pull request & clang-format instructions.

Change-Id: Ia439bcc61bac5788792244d10e573b1fba54b347

4 years agoChange monster_extra generation to use flatbuffers::unique_ptr (#5612)
Derek Bailey [Thu, 7 Nov 2019 22:10:41 +0000 (14:10 -0800)]
Change monster_extra generation to use flatbuffers::unique_ptr (#5612)

4 years ago[C++] Refactor to conform to Google C++ style guide (#5608)
Derek Bailey [Thu, 7 Nov 2019 20:22:54 +0000 (12:22 -0800)]
[C++] Refactor to conform to Google C++ style guide (#5608)

* Automatic refractor of C++ headers to Google C++ style guide

* Automatic refractor of C++ source to Google C++ style guide

* Automatic refractor of C++ tests to Google C++ style guide

* Fixed clang-format issues by running clang-format twice to correct itself. Kotlin was missing clang-format on after turning it off, so it was changed,

4 years agoFixed deprecated method in GRPC Java test.
Wouter van Oortmerssen [Tue, 5 Nov 2019 01:23:01 +0000 (17:23 -0800)]
Fixed deprecated method in GRPC Java test.

Change-Id: Iccae8fe9409adbf3cd3013a5cf3368e068175ad3

4 years agoFixed Apache license not using canonical version.
Wouter van Oortmerssen [Tue, 5 Nov 2019 01:15:56 +0000 (17:15 -0800)]
Fixed Apache license not using canonical version.

Now identical to https://www.apache.org/licenses/LICENSE-2.0.txt

Change-Id: I6eab8bdee2472107dfc72265e204fdd16f3abc2e

4 years agoinclude/flatbuffers/base.h: fix no_sanitize issue with old clang (#5610)
Even Rouault [Mon, 4 Nov 2019 22:58:51 +0000 (23:58 +0100)]
include/flatbuffers/base.h: fix no_sanitize issue with old clang (#5610)

Older clang versions raise:
```
./flatbuffers/base.h:365:1: error: unknown attribute 'no_sanitize' ignored [-Werror,-Wattributes]
__supress_ubsan__("alignment")
^
./flatbuffers/base.h:246:50: note: expanded from macro '__supress_ubsan__'
  #define __supress_ubsan__(type) __attribute__((no_sanitize(type)))
                                                 ^
```

Comparing https://releases.llvm.org/3.6.0/tools/clang/docs/AttributeReference.html
with https://releases.llvm.org/3.7.0/tools/clang/docs/AttributeReference.html
shows that __attribute__((no_sanitize(type))) is available since 3.7.0

4 years ago[C++, Java, C#, TypeScript, JavaScript] Skip generation of mutable union types (...
Derek Bailey [Mon, 4 Nov 2019 22:54:44 +0000 (14:54 -0800)]
[C++, Java, C#, TypeScript, JavaScript] Skip generation of mutable union types (#5599)

* Skip generation of mutable union types

* Removed C# and Java unit tests that mutated a Union type

4 years agoflatbuffers.h: fix documentation warning (#5607)
Even Rouault [Mon, 4 Nov 2019 22:28:33 +0000 (23:28 +0100)]
flatbuffers.h: fix documentation warning (#5607)

Fixes following clang -Wdocumentation warning:
```
flatbuffers.h:1762:17: error: parameter ']' not found in the function declaration [-Werror,-Wdocumentation]
  /// @param[in]] v A const reference to the `std::vector` of structs to
```

4 years agoAdd Lua FlatbufferBuilder Clean() method to enable reuseable builders (#5606)
Derek Bailey [Mon, 4 Nov 2019 22:27:59 +0000 (14:27 -0800)]
Add Lua FlatbufferBuilder Clean() method to enable reuseable builders (#5606)

4 years ago[Kotlin] Fix union vector accessor after change in Java API (#5605)
Paulo Pinheiro [Mon, 4 Nov 2019 22:25:07 +0000 (23:25 +0100)]
[Kotlin] Fix union vector accessor after change in Java API (#5605)

Kolin uses java library as dependency, which changed the way it access union vector recently
(e365c502ffc659752f9b7a8d60b0052a07e33659).

This changes updates kotlin code generation to match Java's changes.

4 years ago[flatc] Remove an always true condition for flexbuffers (#5604)
Paulo Pinheiro [Mon, 4 Nov 2019 22:23:15 +0000 (23:23 +0100)]
[flatc] Remove an always true condition for flexbuffers (#5604)

The condition was unnecessary and Detected by

PVS-Studio
V560 [CWE-571] A part of conditional expression is always true: !opts.use_flexbuffers. flatc.cpp 438

4 years ago[Go] Add UnPackTo functions (#5598)
Lawrence Chan [Mon, 4 Nov 2019 20:12:25 +0000 (14:12 -0600)]
[Go] Add UnPackTo functions (#5598)

4 years ago[Go] Object API support (#5339)
iceboy [Thu, 31 Oct 2019 18:13:45 +0000 (11:13 -0700)]
[Go] Object API support (#5339)

* start

* works for current usages!

* unpack: vector of struct

* optimize byte slice

* support nested struct

* support null table

* support struct

* support union

* update generated code

* grumble

* fix compiler warning

* update generated code

* wrap type in namespace

* bug

* wrap in namespace

* enum byte arrays

* generate struct for unions

* basic testing

* remove branching

* fix assert

* pack vector of fixed structs correctly

* omit null vectors

* Refactor Union Pack and UnPack methods

Remove append usage to increase code efficiency when dealing with large vectors

* generate goldens

4 years agoRust: Add idiomatic iterator for Vector type (#5579)
Mathias Svensson [Mon, 28 Oct 2019 18:19:47 +0000 (19:19 +0100)]
Rust: Add idiomatic iterator for Vector type (#5579)

* Rust: Add idiomatic iterator for Vector type

* Add comments explaining some implementation details

4 years agoFix typos in comments (#5590)
Even Rouault [Mon, 28 Oct 2019 17:02:46 +0000 (18:02 +0100)]
Fix typos in comments (#5590)

Found by the https://github.com/OSGeo/gdal/blob/master/gdal/scripts/fix_typos.sh
script on the internal copy of flatbuffers inside GDAL

4 years agoC++ verifier for evolved union fields should return true (#5586)
Derek Bailey [Mon, 28 Oct 2019 16:43:33 +0000 (09:43 -0700)]
C++ verifier for evolved union fields should return true (#5586)

4 years agoAdd ByteBuffer copy for vector of bytes in Java (#5587)
Derek Bailey [Mon, 28 Oct 2019 16:30:31 +0000 (09:30 -0700)]
Add ByteBuffer copy for vector of bytes in Java (#5587)

4 years agoRust: Fix Copy and Clone impls for a few generic types (#5577)
Mathias Svensson [Mon, 28 Oct 2019 04:20:29 +0000 (05:20 +0100)]
Rust: Fix Copy and Clone impls for a few generic types (#5577)

* Rust: Fix Copy and Clone impls for a few generic types

* Add tests for Copy+Clone

* Wrap Copy+Clone checks in a #[test] function

4 years agoAdd `--clean-first` to the cmake-build command (travis) (#5574)
Vladimir Glavnyy [Mon, 21 Oct 2019 17:11:32 +0000 (00:11 +0700)]
Add `--clean-first` to the cmake-build command (travis) (#5574)

- `--clean-first` runs `clean` target to remove previously generated files
- missed `monster_extra_generated.h` file added to the `flattests` target

4 years agoFix Follow implementation for bool (#5554)
StackDoubleFlow [Sun, 20 Oct 2019 03:24:13 +0000 (22:24 -0500)]
Fix Follow implementation for bool (#5554)

4 years agoFix issue #5557 (#5573)
Vladimir Glavnyy [Fri, 18 Oct 2019 17:16:55 +0000 (00:16 +0700)]
Fix issue #5557 (#5573)

- remove not necessary file `monster_test_generated.h` from sample_bfbs.cpp

4 years agoAvoid intentional unsigned integer overflow getting caught by sanitizers (#5572)
Björn Harrtell [Thu, 17 Oct 2019 22:47:51 +0000 (00:47 +0200)]
Avoid intentional unsigned integer overflow getting caught by sanitizers (#5572)

* Avoid intentional unsigned integer overflow getting caught by sanitizers

* Adapt from suggested compiler compatible solution

* And a third way :)

4 years agoPython: Add forceDefaults opt to python Builder (#5564)
Bharat Tak [Thu, 17 Oct 2019 22:25:05 +0000 (00:25 +0200)]
Python: Add forceDefaults opt to python Builder (#5564)

* Add forceDefaults opt to python Builder

* Add test functions for force_default option for python builder

* Simplify

* Add force default test for UOffsetTFlags

4 years agoJava: Don't annotate vector-of-tables item getters with @nullable. (#5562)
Jacek Surazski [Thu, 17 Oct 2019 22:23:15 +0000 (15:23 -0700)]
Java: Don't annotate vector-of-tables item getters with @nullable. (#5562)

* Annotate getters with @Pure when --java-checkerframework is specified.

Together with @Nullable, this allows users to use static analysis tools
like CheckerFramework to catch NPEs caused by unset fields.

* Don't annotate vector-of-tables item getters with @Nullable.

Since Flatbuffers don't support null items in vectors of tables.

4 years agoFixed warnings generated by recent JSON sorting feature.
Wouter van Oortmerssen [Thu, 17 Oct 2019 22:16:00 +0000 (15:16 -0700)]
Fixed warnings generated by recent JSON sorting feature.

Change-Id: I6fd6283b616c7a39bb878b1610e4ddf6e208fa0a

4 years ago[Java] byte buffer factory returned buffer capcity is used instead of the requested...
Idan Sheinberg [Thu, 17 Oct 2019 22:11:33 +0000 (01:11 +0300)]
[Java] byte buffer factory returned buffer capcity is used instead of the requested size (#5558)

* byte buffer factory returned buffer is used instead of the requested capacity

* byte buffer factory returned buffer is used instead of the requested capacity

* Comment fix

4 years ago#5544 Fix of Array of table is not sorted if Create<type>Direct() is used (#5546)
tira-misu [Thu, 17 Oct 2019 21:22:21 +0000 (23:22 +0200)]
#5544 Fix of Array of table is not sorted if Create<type>Direct() is used (#5546)

* 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

4 years agoFix build with gcc version 7.4.0 (#5570)
Brian Harris [Tue, 15 Oct 2019 17:56:58 +0000 (12:56 -0500)]
Fix build with gcc version 7.4.0 (#5570)

4 years agoFixed JSON parser not sorting vectors of tables/structs with key.
Wouter van Oortmerssen [Thu, 10 Oct 2019 22:24:54 +0000 (15:24 -0700)]
Fixed JSON parser not sorting vectors of tables/structs with key.

Change-Id: Iacc0c8513af80a736700e6cbaf513ebdf8e3ac89

4 years ago[FlexBuffers][Java] Cache size of Sized objects in FlexBuffers (#5551)
Paulo Pinheiro [Thu, 3 Oct 2019 22:56:29 +0000 (00:56 +0200)]
[FlexBuffers][Java] Cache size of Sized objects in FlexBuffers (#5551)

In my benchmarks it shows deserialization performance improvements of
around 7%

4 years agoFix issue #5542 (#5543)
Paulo Pinheiro [Mon, 30 Sep 2019 21:05:19 +0000 (23:05 +0200)]
Fix issue #5542 (#5543)

Empty objects that inherit from Sized would try to access internal
ByteBuffer when Sized::size was called. So we add a single byte in
the empty buffer, so when size() is called it would return 0

4 years agoFixed Android STLPort related error.
Wouter van Oortmerssen [Mon, 30 Sep 2019 19:12:36 +0000 (12:12 -0700)]
Fixed Android STLPort related error.

Change-Id: I59ff072e526fc63b3215767a4d4a2a8944b65654

4 years agoFix namespaced struct/field name collision detection (#5540) (#5545)
Jack Zhou [Mon, 30 Sep 2019 18:50:03 +0000 (14:50 -0400)]
Fix namespaced struct/field name collision detection (#5540) (#5545)

Changes the use of `LookupStruct` to `LookupCreateStruct` in
`ParseField` to also detect when collisions happen in namespaces.

4 years ago[flac] Add FlexBuffers option for generating data (#5519)
Paulo Pinheiro [Thu, 26 Sep 2019 22:06:11 +0000 (00:06 +0200)]
[flac] Add FlexBuffers option for generating data (#5519)

Alongside --binary and --json, an additional
switch (--flexbuffers) can be passed to convert
data using FlexBuffers

4 years agoUpdate Rust versions under test from 1.30.1 to 1.37.0 (#5538)
Robert Winslow [Thu, 26 Sep 2019 21:31:11 +0000 (14:31 -0700)]
Update Rust versions under test from 1.30.1 to 1.37.0 (#5538)

Fixes build errors from using newer crate versions with an old Rust version.

4 years agoAdds XOPEN_SOURCE for PATH_MAX and POSIX 1993 for stat (#5529)
mjvk [Thu, 26 Sep 2019 16:40:14 +0000 (18:40 +0200)]
Adds XOPEN_SOURCE for PATH_MAX and POSIX 1993 for stat (#5529)

* Adds XOPEN_SOURCE for PATH_MAX and POSIX 1993 for stat

These are the only two required extension for compilation of
flatbuffers using -std=c++11 instead of gnu++11.

* Sets _XOPEN_SOURCE to 600 and enable POSIX2001 for fseeko

4 years ago[FlexBuffers][Java] Add override Key::toString (#5533)
Paulo Pinheiro [Wed, 25 Sep 2019 21:14:39 +0000 (23:14 +0200)]
[FlexBuffers][Java] Add override Key::toString (#5533)

4 years ago[FlexBuffers][Java] Fix wrong access to a string using Reference::asString(). (#5532)
Paulo Pinheiro [Wed, 25 Sep 2019 18:59:10 +0000 (20:59 +0200)]
[FlexBuffers][Java] Fix wrong access to a string using Reference::asString(). (#5532)

The real position of a string is  calculated by using the indirect() method,
which should be based on parentWidth and not byteWidth, as it was implemented.

We are also fixing the flag BUILDER_FLAG_SHARE_STRINGS on FlexBuffersBuilder
that was set as '1', same value as BUILDER_FLAG_SHARE_KEYS.

4 years agoFix Mutate() methods of Array<scalar/struct> (override 5508) (#5526)
Vladimir Glavnyy [Mon, 23 Sep 2019 16:31:51 +0000 (23:31 +0700)]
Fix Mutate() methods of Array<scalar/struct> (override 5508) (#5526)

* Draft with Array specialization (#5508)

* Array specialization + SFINAE to fold copy-paste (#5508)

* Add implicit specialization of Array<scalar> and Array<struct> (#5508)

- Tag dispatching is used for implicit specialization
- Array<scalar> and Array<struct> have different iterators and accessors
- Array<scalar> and Array<struct> have different Mutate() methods

* Add implicit specialization of Array<scalar> and Array<struct> (#5508)

- Tag dispatching is used for implicit specialization
- Array<scalar> and Array<struct> have different iterators and accessors
- Array<scalar> and Array<struct> have different Mutate() methods

4 years agoJava: Added access object for vector of struct and vector of tables. (#5233)
Kulikov Alexey [Mon, 23 Sep 2019 16:22:43 +0000 (23:22 +0700)]
Java: Added access object for vector of struct and vector of tables. (#5233)

* Java: Added access object for vector of struct and vector of tables.

* Java: Workarounds removed when accessing the union vector.

4 years agoFixed DetachedBuffer self move assignment (#5521)
mmoscicki2 [Thu, 19 Sep 2019 17:32:24 +0000 (19:32 +0200)]
Fixed DetachedBuffer self move assignment (#5521)

4 years agoFix buildifier warnings found in new bazel (#5517)
Austin Schuh [Thu, 19 Sep 2019 16:58:36 +0000 (09:58 -0700)]
Fix buildifier warnings found in new bazel (#5517)

Fixes warnings caught in:
https://buildkite.com/bazel/flatbuffers/builds/863#cff87e1d-b976-4734-8157-4b6d88c7b5e1

4 years agoFixed Reflection Verifier not handling vectors of unions.
Wouter van Oortmerssen [Tue, 17 Sep 2019 00:48:54 +0000 (17:48 -0700)]
Fixed Reflection Verifier not handling vectors of unions.

Change-Id: Ie94386ff8e10fd2a964bd9155139b50953746a37

4 years agoFixed GenerateText not handling vectors of unions.
Wouter van Oortmerssen [Mon, 16 Sep 2019 21:43:35 +0000 (14:43 -0700)]
Fixed GenerateText not handling vectors of unions.

Change-Id: Ie82abaf178495c4692e7d10be6b4a13f2fa1bee6

4 years agoAdd element size parameter to __vector_as_arraysegment [c#] (#5512)
Kevin Fort [Wed, 11 Sep 2019 00:07:46 +0000 (19:07 -0500)]
Add element size parameter to __vector_as_arraysegment [c#] (#5512)

* Add element size parameter to __vector_as_arraysegment

Add element size parameter to __vector_as_arraysegment fixing issue where VectorAsBytes returns incorrect size span for multibyte element types.

* Update codegen

Update codegen and Table to return typed span.

* update test files

update test files

4 years ago[Java][FlexBuffers] Improve documentation for FlexBuffers in Java. (#5506)
Paulo Pinheiro [Tue, 10 Sep 2019 17:06:47 +0000 (19:06 +0200)]
[Java][FlexBuffers] Improve documentation for FlexBuffers in Java. (#5506)

Also add a FlexBuffer constructor to simplify usage

4 years agoAnnotate getters with @Pure when --java-checkerframework is specified. (#5510)
jaceksur [Tue, 10 Sep 2019 17:01:27 +0000 (10:01 -0700)]
Annotate getters with @Pure when --java-checkerframework is specified. (#5510)

Together with @Nullable, this allows users to use static analysis tools
like CheckerFramework to catch NPEs caused by unset fields.

4 years ago[Dart]fix: segment fault with empty namespace when generating dart file (#5507)
Edward [Mon, 9 Sep 2019 21:40:33 +0000 (05:40 +0800)]
[Dart]fix: segment fault with empty namespace when generating dart file (#5507)

* fix: segment fault with empty namespace when generating dart file

* fix: compile err

* fix: compile err

* fix: imported file names

* fix test issues

* fix some language style issues

4 years agoRust: Fixed cargo clippy on non-generated code (#5485)
Casper [Mon, 9 Sep 2019 20:02:43 +0000 (13:02 -0700)]
Rust: Fixed cargo clippy on non-generated code (#5485)

* Cargo clippy lints

* more lints

* more lints

* Restored a doc comment

* Comment on float eps-eq and adjusted casting

4 years ago[Javascript] Fix syntax error for signed enum (#5503)
Jaemin Park [Thu, 5 Sep 2019 17:22:04 +0000 (02:22 +0900)]
[Javascript] Fix syntax error for signed enum (#5503)

* wrap quotes to enum name map to prevent syntax errorn when enum value is negative

* Add a test that covers signed enum case

4 years ago[C#] Fix retrieving enumeration vectors as arrays (#5457)
Nathan Williams [Tue, 3 Sep 2019 21:10:54 +0000 (07:10 +1000)]
[C#] Fix retrieving enumeration vectors as arrays (#5457)

* [C#] Fix retrieving enumeration vectors as arrays

* [C#] Don't generate CreateVectorBlock for enums

4 years agoDoc typo fixes (#5505)
Björn Harrtell [Tue, 3 Sep 2019 18:50:42 +0000 (20:50 +0200)]
Doc typo fixes (#5505)

4 years agoUse all of the available space in the buffer returned by ByteBufferFactory to allow...
Morten Grouleff [Tue, 3 Sep 2019 18:13:32 +0000 (20:13 +0200)]
Use all of the available space in the buffer returned by ByteBufferFactory to allow the factory to keep a pool of larger than initialsize sized buffers. (#5500)

4 years ago[FlexBuffers][Java] Implementation of FlexBuffers API (#5476)
Paulo Pinheiro [Thu, 29 Aug 2019 22:06:24 +0000 (00:06 +0200)]
[FlexBuffers][Java] Implementation of FlexBuffers API (#5476)

* [FlexBuffers][Java] Implementation of FlexBuffers API

This is the initial attemp to implement FlexBuffer on Java.

There is some limitations as compared to the C++ implementation:
  1 - No mutations implemented yet
  2 - Does not parse from json

Also, this initial implementation is not focused and performance, but
get the basics write. So there is many opportunities for optimization, for instance,
remove all enums, return CharSequence instead of Strings and object pooling.

* [FlexBuffers][Java] Optimizations and simplification of the Builder  API.

This change removes BitWidth enum in favor of static ints. Also
make all "reads" APIs closer to C++ implementation (try to cast or convert
as much as possible, assuming user knows what he is doing). Finally,
we remove the helper classes for building vectors and maps.

There is no official benchmarks, but the unit tests are running in less
than 50% for previous runs, which mean those optimizations are worth it.

* [FlexBuffers][Java] Fix Reference::asString behavior

There was a incorrect assumption that strings would be null-terminated, which
could lead to truncated strings. S now it relies size instead of null-termination.

Other minor improvements

4 years agoClarified value reuse in FlexBuffers
Wouter van Oortmerssen [Mon, 26 Aug 2019 21:59:21 +0000 (14:59 -0700)]
Clarified value reuse in FlexBuffers

Change-Id: Ib771bfa46ccdf38eff25be857b1b73f8b300c649

4 years agoFixed test build invocation of arrays_test.fbs
Wouter van Oortmerssen [Mon, 26 Aug 2019 21:33:38 +0000 (14:33 -0700)]
Fixed test build invocation of arrays_test.fbs

Change-Id: Idfc8d9cfbdefda44f803a6232700842ee6b6bffd

4 years agoFlexBuffers: allow any values to be shared.
Wouter van Oortmerssen [Mon, 26 Aug 2019 18:54:38 +0000 (11:54 -0700)]
FlexBuffers: allow any values to be shared.

(see comments in the code).

Change-Id: I5603abb0db436145739653692644bbcfd3c946e3

4 years agoAndroid: remove app_dummy() calls
Wouter van Oortmerssen [Fri, 23 Aug 2019 21:31:31 +0000 (14:31 -0700)]
Android: remove app_dummy() calls

Change-Id: I0ebd4502f98d009ce5afe8c8bafb629284f0366c

4 years agoFixed STLPort Android compile error
Wouter van Oortmerssen [Fri, 23 Aug 2019 21:17:33 +0000 (14:17 -0700)]
Fixed STLPort Android compile error

Change-Id: I3595b9c6803718f34ce61fdfc367da97b50dc444

4 years ago[bugfix]flexbuffers isvector bugfix (#5488)
Earlonus [Fri, 23 Aug 2019 17:51:36 +0000 (01:51 +0800)]
[bugfix]flexbuffers isvector bugfix (#5488)

* commit isvector bugfix (change email recommit to pass cla)

* commit IsUntypedVector

* delete isvectorormap function

4 years agoFix incorrect padding in arrays of structs (Issue #5484) (#5491)
svenk177 [Fri, 23 Aug 2019 17:46:47 +0000 (19:46 +0200)]
Fix incorrect padding in arrays of structs (Issue #5484) (#5491)

4 years agoFixed missing generated code.
Wouter van Oortmerssen [Tue, 20 Aug 2019 00:57:23 +0000 (17:57 -0700)]
Fixed missing generated code.

Change-Id: Iaa0633167c2a4d4543fc4de2af58112d60d5d1e6

4 years agoC++ IDL generation adds superfluous semicolon in GenTablePost, causing (#5483)
Wes McKinney [Tue, 20 Aug 2019 00:49:37 +0000 (19:49 -0500)]
C++ IDL generation adds superfluous semicolon in GenTablePost, causing (#5483)

-Wextra-semi-stmt warning when building with Clang 8.0.0. Update generated
files for testing

4 years ago[go]add Name() for ForceCodec interface (#5486)
Tsingson [Mon, 19 Aug 2019 22:32:04 +0000 (06:32 +0800)]
[go]add Name() for ForceCodec  interface (#5486)

* add Name() for ForceCodec  interface

// ForceCodec returns a CallOption that will set the given Codec to be
// used for all request and response messages for a call. The result of calling
// String() will be used as the content-subtype in a case-insensitive manner.
//

* Update grpc.go

4 years agoreflection: check for valid union enum value during object verification (#5475)
Mark Nauwelaerts [Mon, 19 Aug 2019 19:48:25 +0000 (21:48 +0200)]
reflection: check for valid union enum value during object verification (#5475)

... to avoid assertion failure or invalid access due to invalid vector index

4 years agohas_method support for primitive fields in java runtime. Changed: idl.h, FlatBufferBu...
Edward [Mon, 19 Aug 2019 19:46:48 +0000 (12:46 -0700)]
has_method support for primitive fields in java runtime. Changed: idl.h, FlatBufferBuilder.java ,  idl_gen_general.cpp, idl_parser.cpp, flatc.cpp (#5468)

* has_method support for primitive fields in java runtime

* adding the new flag to flatc

* addressing the review comments

4 years agoFix compilation error in tests. (#5472)
Max Burke [Mon, 5 Aug 2019 18:57:54 +0000 (11:57 -0700)]
Fix compilation error in tests. (#5472)

Local variables were shadowing member fields, causing errors.

4 years ago[C++] remove static_cast expression (#5440)
Alexey Geraskin [Thu, 1 Aug 2019 21:31:48 +0000 (00:31 +0300)]
[C++] remove static_cast expression (#5440)

* [C++] remove static_cast expression

* [C++] Add unit test for native_type usage

* [C++] Add flatc compilation for native_type_test.fbs

* [C++] update CMakeLists to compile native_type_test.fbs properly

* Update BUILD file for bazel

* [C++] Add generated native_type_test_generated.h and fix arguments for flatc according to CMakeList

* [C++] remove "= default" from constructor to support old compilers

* Update BUILD file for bazel, attempt 2

* [C++] Workaround for MSVC 2010 for the issue with std::vector and explicitly aligned custom data types

* Update BUILD file for bazel, attempt 3

* Update BUILD file for bazel, attempt 4

* Update BUILD file for bazel, attempt 5

* Update BUILD file for bazel, attempt 6

* [C++] Workaround for MSVC 2010 for the issue with std::vector and explicitly aligned custom data types Part 2

* [C++] Keep only one optional parameter to compile_flatbuffers_schema_to_cpp_opt

* native_type_test.fbs style corrected

* [C++] Code style modifications

* [C++] Fix flatc arguments in CMakeLists

* [C++] Remove --gen-compare from default parameters for flatc in CMakeLists

* [C++] Change Vector3D fields from double to float, to have alignment eq. 4 (to support MSVC 2010), plus minor review fix

* [C++] Remove one more #if !defined

* [C++] Restore version with correct static_cast, add the same fix for SortedStructs

* Revert "[C++] Restore version with correct static_cast, add the same fix for SortedStructs"

This reverts commit d61f4d6628cfce530c8b9a4c9e7af368d599f99f.

* [C++] Fix Android.mk

4 years ago[C++ ] Correctly serialize bit_flags enums to JSON with output_enum_identifiers optio...
ll-antn [Thu, 1 Aug 2019 21:16:44 +0000 (00:16 +0300)]
[C++ ] Correctly serialize bit_flags enums to JSON with output_enum_identifiers option (#5454)

* Support output_enum_identifiers for enums with multiple bit values

* Cast bit_flag enum val to uint64_t instead of int64_t

4 years agoFix for Boolean types (#5379) (#5466)
Derek Bailey [Thu, 1 Aug 2019 17:28:54 +0000 (10:28 -0700)]
Fix for Boolean types (#5379) (#5466)

The packing/unpacking steps for Boolean values was failing because the
code expected numerical values. I overrode the functions for the Boolean
metatable to account for this. I also had to exclude the Boolean
metatable from the GenerateTypes helper function, as that was overriding
the Pack/Unpack functions defined in its metatable.

Added Linux bash script to run Lua tests from the command line.

Bug: google/flatbuffers#5379

Tested: Added Lua tests that were failing and are now fixed with the
code changes.

4 years agoRenamed stale label from "wontfix" to "stale".
Wouter van Oortmerssen [Mon, 29 Jul 2019 18:43:28 +0000 (11:43 -0700)]
Renamed stale label from "wontfix" to "stale".

Change-Id: Iea88624d9d90e029a64cab9edf4e7c1cfc005e4a

4 years agoReplace '--cpp-include' brackets to quotes (#5438) (#5464)
Vladimir Glavnyy [Mon, 29 Jul 2019 18:38:52 +0000 (01:38 +0700)]
Replace '--cpp-include' brackets to quotes (#5438) (#5464)

4 years agoMade stale.yml friendlier.
Wouter van Oortmerssen [Sat, 27 Jul 2019 01:56:56 +0000 (18:56 -0700)]
Made stale.yml friendlier.

4 years agoExtend the error message if base type of parsed scalar not resolved (#5456)
Vladimir Glavnyy [Sat, 27 Jul 2019 00:56:41 +0000 (07:56 +0700)]
Extend the error message if base type of parsed scalar not resolved (#5456)

* Extend the error message if base type of parsed scalar not resolved #5447

* Resolve PR notes

4 years agoAdd .github/stale.yml to auto close stale issues and PRs.
Wouter van Oortmerssen [Sat, 27 Jul 2019 00:48:21 +0000 (17:48 -0700)]
Add .github/stale.yml to auto close stale issues and PRs.

See https://probot.github.io/apps/stale/

Change-Id: I8176eeb21dbcd516f1d6f7b1e8c28602cdd9332a

4 years agoPython: Added support for file_identifiers (#5123)
Joseph Pyott [Fri, 26 Jul 2019 18:06:25 +0000 (14:06 -0400)]
Python: Added support for file_identifiers (#5123)

* Python: Added support for file_identifiers

* Added tests. Fixed file_identifier code.

* Python: Fixed excessive padding of file_identifier. Repaired tests.

* Python: Made code compatible with python2.7

* Python: Typo fix in @endcond

* whitespace normaalization

* Stylistic change from if(not X is None) to if(X is not None). Added comment to type string.

* Python: Added support for automatic code generation of file_identifiers. Added tests for said code generation.

* converted sprintf to snprintf

* Bugfix, added snprint deffinition for MSVC

* changed snprint deffinition for MSVC to sprint_s

* changed scanf to IntToStringHex. Renamed HasFileIdentifier to GenHasFileIdentifier.

* Added updated genereated code to commit

* Python bugix: flatc no longer produces HasFileIdentfier for shcemas with no file identifier

* Added tests to verify `MonsterBufferHasIdentifier` returns false on no Identifier

* Python: added tests for GetBufferIdentifier and BufferHasIdentifier
Python: removed unessasary parenethesis in if statements
Minor format changes.

* Python : correceted instances of keyword arguments being called as positional arguments

* fixed typos and grammer in comments

* Minor style fixes

* Indentation fix

* Equals style changes

* Python: Fixed Alignment Issues. Changed test code to test against atual output

* Ran make(forgot to run make last commit)

* Python: Style changes

* Style changes

* indentation and style

* readded CONTRIBUTING.md

* Formatting tweak

Mostly to make CI run again

* More formatting fixes

* More formatting fixes

* More formatting fixes

* More formatting fixes

* Formatting fix

* More formatting fixes

* Formatting

* ran generate_code.sh

4 years agoFix numeric_limits<T>::max() to avoid conflict with windows.h header (#5462)
ll-antn [Fri, 26 Jul 2019 16:14:05 +0000 (19:14 +0300)]
Fix numeric_limits<T>::max() to avoid conflict with windows.h header (#5462)

4 years agoSupport nested_flatbuffer attribute when parsing bfbs schema (#5448)
ll-antn [Fri, 26 Jul 2019 16:13:11 +0000 (19:13 +0300)]
Support nested_flatbuffer attribute when parsing bfbs schema (#5448)