platform/upstream/flatbuffers.git
5 years agoAdd presubmit.yml for bazel CI configuration (#5193)
Austin Schuh [Tue, 19 Feb 2019 01:55:50 +0000 (17:55 -0800)]
Add presubmit.yml for bazel CI configuration (#5193)

https://github.com/bazelbuild/continuous-integration/tree/master/buildkite#configuring-a-pipeline

5 years agoFix AppVeyor script not including CMake dir
Wouter van Oortmerssen [Fri, 15 Feb 2019 00:20:27 +0000 (16:20 -0800)]
Fix AppVeyor script not including CMake dir

Change-Id: I737a74dd4d31ca6d1559958f4c76e61e1f0a2c64

5 years agoChanged the JavaScript generation to emit createX helper functions just like the...
Christopher Cifra [Fri, 15 Feb 2019 00:00:33 +0000 (18:00 -0600)]
Changed the JavaScript generation to emit createX helper functions just like the TypeScript code generation. I also added code so that the create methods have documentation in both JavaScript and TypeScript. (#5168)

5 years ago[C#] Fix FlatBuffers.Tests when ENABLE_SPAN_T is defined (#5182)
Eric Erhardt [Thu, 14 Feb 2019 23:53:36 +0000 (17:53 -0600)]
[C#] Fix FlatBuffers.Tests when ENABLE_SPAN_T is defined (#5182)

There is a test code error that causes the CanReadCppGeneratedWireFile test to fail when ENABLE_SPAN_T is defined. When TestarrayofboolsLength is not 0, then the GetTestarrayofboolsBytes() should have a length.

5 years agoInstall flatc as requested (#5180)
Aleix Pol [Thu, 14 Feb 2019 21:19:36 +0000 (22:19 +0100)]
Install flatc as requested (#5180)

If FLATBUFFERS_BUILD_FLATC and FLATBUFFERS_INSTALL are set, flatc should
be installed regardless of the configuration.

5 years agoGenerting imports for external enums in TS (#5175)
Kamil Rojewski [Thu, 14 Feb 2019 21:08:55 +0000 (22:08 +0100)]
Generting imports for external enums in TS (#5175)

5 years agoFix bazel build (#5174)
Austin Schuh [Thu, 14 Feb 2019 21:05:46 +0000 (13:05 -0800)]
Fix bazel build (#5174)

rules_go was out of date.  Update that.  Also, a dependency
monster_extra_cc_fbs snuck in.  So, let's add that.

Fixes: #5163

5 years agoAdd flag to make short names in JS/TS. (#5152)
Gabriel Nützi [Mon, 11 Feb 2019 20:34:10 +0000 (21:34 +0100)]
Add flag to make short names in JS/TS. (#5152)

* Add flag to make short names in JS/TS.

* Synced all missing docs in Compiler.md <-> flatc.cpp.

* Review changes.

5 years agoMake ByteBufferFactory an abstract class in order to make FlatBuffers compatible...
Enrico Olivelli [Mon, 11 Feb 2019 20:02:32 +0000 (21:02 +0100)]
Make ByteBufferFactory an abstract class in order to make FlatBuffers compatible with Java7. (#5155)

Introduce a HeapByteBufferFactory singleton instance in order to reduce allocations.
Clarify the usage of LITTLE_ENDIAN ByteBuffers in ByteBufferFactory.

5 years agoImplement (shared) attribute for C++ (#5157)
iceboy [Mon, 11 Feb 2019 19:53:45 +0000 (11:53 -0800)]
Implement (shared) attribute for C++ (#5157)

* Implement native_shared attribute for C++.

Fixes #5141. See also #5145.

* Refine comment in idl.h

* Also refine docs

* Revert "Also refine docs"

This reverts commit 09dab7b45c56c2d17eac493203adc8caaa0df2cc.

* Also refine docs again.

* grumble

5 years agoTurn on -Werror=unused-private-field for Clang.
Wouter van Oortmerssen [Mon, 11 Feb 2019 17:54:46 +0000 (09:54 -0800)]
Turn on -Werror=unused-private-field for Clang.

Change-Id: Ibabc1456baf190eba191ebe0b81e3d73a4acc98f

5 years agoMade FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE #ifdef out less
Wouter van Oortmerssen [Fri, 8 Feb 2019 00:34:25 +0000 (16:34 -0800)]
Made FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE #ifdef out less

This is to protect against cases where part of a project is
compiled with or without this flag, making for very fragile
and hard to find bugs, such as sizeof(Verifier) changing.

Change-Id: I01c895cdc5b44f860e4b0b9c9613bff1983e2b9d
See: https://bugs.chromium.org/p/chromium/issues/detail?id=929847

5 years agoReduced `force_align` in tests to 8, to work with --object-api.
Wouter van Oortmerssen [Thu, 7 Feb 2019 22:35:27 +0000 (14:35 -0800)]
Reduced `force_align` in tests to 8, to work with --object-api.

More detail:
https://github.com/google/flatbuffers/projects/6#card-17401359

See also the .md changes in this commit.

Change-Id: Idfa68b2fd3bdb19979833737d3a3cf83ec1d6775

5 years agoRemoving 'using namespace' usage in test_builder (#5154)
Charlie Harrison [Tue, 5 Feb 2019 01:07:05 +0000 (20:07 -0500)]
Removing 'using namespace' usage in test_builder (#5154)

* Removing 'using namespace' usage in test_builder

* Fix GRPC tests

5 years agoChanging array to be an associative array so that the Name function can work with...
Travis Staley [Mon, 4 Feb 2019 22:33:57 +0000 (17:33 -0500)]
Changing array to be an associative array so that the Name function can work with non-sequential enums as well as those beginning at something other than zero. (#5151)

Also including the resulting changes in php files.

5 years agoOnly use __movsb on architectures that support it (#5147)
Jon Kunkee [Mon, 4 Feb 2019 17:57:34 +0000 (09:57 -0800)]
Only use __movsb on architectures that support it (#5147)

With the introduction of Windows 10 on ARM (ARM64), code that assumes
that Windows targets are always x86 or x86_64 targets needs to be
updated.

The hot function ReadUInt64 has been optimized in MSVC builds using the
compiler intrinsic __movsb. Since this does not exist on ARM64 Windows,
this change uses the pure C++ path that other platforms use instead.

5 years agoMake changes on the make_unsigned type trait (#5136)
Henry Lee [Tue, 29 Jan 2019 01:31:58 +0000 (12:31 +1100)]
Make changes on the make_unsigned type trait (#5136)

Fix a typo in the static assert message in `make_unsigned`

Support more specifications for `make_unsigned`

5 years agoRepair `fallthrough` was broken by d4493165 (#5115) (#5139)
Vladimir Glavnyy [Mon, 28 Jan 2019 18:16:12 +0000 (01:16 +0700)]
Repair `fallthrough` was broken by d4493165 (#5115) (#5139)

- GCC: fixed broken `fallthrough` (checked with 7.3 and 8.2)
- Clang: added `fallthrough` support
- Clang: added `-Wimplicit-fallthrough` checking

5 years agodelete zero width space characters <U+200B>'s to avoid MSVC warning C4819 (#5133)
find [Thu, 24 Jan 2019 23:02:48 +0000 (07:02 +0800)]
delete zero width space characters <U+200B>'s to avoid MSVC warning C4819 (#5133)

5 years agoReplace deprecated Vector::Length() with Vector::size() (#5131)
Vladimir Glavnyy [Thu, 24 Jan 2019 21:33:19 +0000 (04:33 +0700)]
Replace deprecated Vector::Length() with Vector::size() (#5131)

- enable FLATBUFFERS_ATTRIBUTE if C++17 or higher

5 years agoRepair MSVC-CRT leakage detector and enable this detection with Appveyor-CI (#5105)
Vladimir Glavnyy [Thu, 24 Jan 2019 21:30:11 +0000 (04:30 +0700)]
Repair MSVC-CRT leakage detector and enable this detection with Appveyor-CI (#5105)

5 years ago[Rust] Added global namespace imports (#5121)
jean-airoldie [Thu, 24 Jan 2019 21:25:56 +0000 (16:25 -0500)]
[Rust] Added global namespace imports (#5121)

* [Rust] Added global namespace imports

* Documented the need for global imports

* Added white_space params to GenNamespaceImports

* Removed a \n from GenNamespaceImports

5 years ago[C++]Support reverse iterator in Vector (#5128)
Henry Lee [Thu, 24 Jan 2019 21:24:01 +0000 (08:24 +1100)]
[C++]Support reverse iterator in Vector (#5128)

* Add `const` keyword to the `operator-(const uoffset_t &)` function in
`VectorIterator`

* Support reverse iterator in Vector

Introduced a new VectorReverseIterator type. We cannot directly use
`std::reverse_iterator<VectorIterator>` because the signature of
`operator*` and `operator->` in the VectorIterator class are not
standard signatures.

Also added `rbegin()`, `rend()`, `cbegin()`, `cend()`, `crbegin()`
and `crend()` in the Vector class.

5 years ago[docs] [rust] Add "Useful tools created by others" section (#5127)
Vlad Frolov [Thu, 17 Jan 2019 19:56:52 +0000 (21:56 +0200)]
[docs] [rust] Add "Useful tools created by others" section (#5127)

5 years agoFix high certainty warnings from PVS-studio (#5115)
Vladimir Glavnyy [Thu, 17 Jan 2019 17:49:27 +0000 (00:49 +0700)]
Fix high certainty warnings from PVS-studio (#5115)

* Fix high certainty warnings from PVS-studio

- Introduced FLATBUFFERS_ATTRIBUTE macro to use [[attribute]] if modern C++ compiler used

* Update the note about __cplusplus usage in the MSVC

5 years agoDocker tests for Zend PHP and Mono C#; Python coverage; TODO for HHVM PHP (#5125)
Robert [Thu, 17 Jan 2019 00:41:02 +0000 (16:41 -0800)]
Docker tests for Zend PHP and Mono C#; Python coverage; TODO for HHVM PHP (#5125)

* Docker test for Zend PHP 7.3

* hhvm

* move failing hhvm test to TODO zone

* c# mono 5.18 test

* python coverage reports

5 years agoReference::ToString should be const (#5118)
cor3ntin [Mon, 14 Jan 2019 17:39:58 +0000 (18:39 +0100)]
Reference::ToString should be const (#5118)

5 years agoAdd default NaN/Inf to C#, Java, Python (#5107)
Vladimir Glavnyy [Mon, 14 Jan 2019 17:23:42 +0000 (00:23 +0700)]
Add default NaN/Inf to C#, Java, Python (#5107)

* Add default NaN/Inf to C#, Java, Python

* Python NaN/Inf test added

* Remove MSVC2010/13 dependent code

5 years agoJS- support clear() method on builder (#5109)
unintellisense [Mon, 14 Jan 2019 17:21:42 +0000 (09:21 -0800)]
JS- support clear() method on builder (#5109)

* support clearing flatBuffer builder in js

* remove unused member
 reset force_defaults
dont actually need to clear data in bytebuffer

5 years agoMove all platform dependent headers and code to util.cpp module (#5106)
Vladimir Glavnyy [Mon, 7 Jan 2019 18:12:57 +0000 (01:12 +0700)]
Move all platform dependent headers and code to util.cpp module (#5106)

5 years agoAdd `NaN` and `Inf` defaults to the C++ generated code. (#5102)
Vladimir Glavnyy [Mon, 7 Jan 2019 18:04:44 +0000 (01:04 +0700)]
Add `NaN` and `Inf` defaults to the C++ generated code. (#5102)

* Add `NaN` and `Inf` defaults to the C++ generated code.

* Refactoring: add FloatConstantGenerator

* Refactoring-2:

- remove isnan checking for all float/double values
- add most probable implementation of virtual methods of FloatConstantGenerator

* Add conditional (FLATBUFFERS_NAN_DEFAULTS) isnan checking

5 years agoAdd repository name to build_defs.bzl (#5104)
Yong Tang [Mon, 7 Jan 2019 17:55:55 +0000 (09:55 -0800)]
Add repository name to build_defs.bzl (#5104)

In flatbuffers, build_defs.bzl has been updated to have the
bazel rule `flatbuffer_cc_library` defined. Therefore, it should
be possible to build another application and using `flatbuffer_cc_library`
directly (by `load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")`)

However, when I tried to do the above, I saw the following errors in bazel:
```
ERROR: /root/.cache/bazel/_bazel_root/c27e9809996ce9a9c0ed8dd79ef0897b/external/arrow/BUILD.bazel:12:1: in deps attribute of cc_library rule @arrow//:arrow_format: target '@arrow//:runtime_cc' does not exist. Since this rule was created by the macro 'flatbuffer_cc_library', the error might have been caused by the macro implementation in /root/.cache/bazel/_bazel_root/c27e9809996ce9a9c0ed8dd79ef0897b/external/com_github_google_flatbuffers/build_defs.bzl:216:16
```

The reason for the bazel error was that `//:runtime_cc` and `//:flatc` does not have
the repo name prefixed.

By prefix `` the above bazel build error could be resolved.

This fix should help other programs to use flatbuffers directly through bazel.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
5 years ago[Go] Namespaced imports fix (#5097)
Robert [Fri, 28 Dec 2018 01:57:19 +0000 (20:57 -0500)]
[Go] Namespaced imports fix (#5097)

Track and emit required FlatBuffers namespace imports in generated Go code.

Update Go code generator by moving most functionality into the generator class, to facilitate namespace tracking. (Note that the git diff in this combined commit may appear large due to this refactoring, but very little code was actually changed.)
Update Go code generator by tracking namespace imports when generating FlatBuffers code.
Update Go code generator by emitting package imports to correctly reference code in other FlatBuffers namespaces.
Create Go test that checks the usage of InParentNamespace objects (as defined in the example schema).
Create Docker test that checks the Go language port.
Fixes #4883
Fixes #3927

Individual commits:

* remove "static" from soon-to-be method functions
* move almost all functions into class as methods
* set current namespace and emit package names if needed
* track imported namespaces
* parent namespaces work
* docker test for go ^1.11
* update base image name for go docker test
* remove cerr debugging
* formatting fixes
* re-run generate_code.sh
* explicitly test namespace imports and usage

5 years agoAdded -Werror=implicit-fallthrough=2 to GCC 7 build.
Wouter van Oortmerssen [Thu, 27 Dec 2018 00:02:14 +0000 (16:02 -0800)]
Added -Werror=implicit-fallthrough=2 to GCC 7 build.

Change-Id: I3f23bb1478763334dbc7e43579555518fb2412c2

5 years agoPerformance improvement to generated+supporting PHP (#5080)
Peter Dillinger [Fri, 21 Dec 2018 00:10:20 +0000 (16:10 -0800)]
Performance improvement to generated+supporting PHP (#5080)

By avoiding redundant alignment+alloc checks (startVector does prep) and virtual calls
(by making the class final) in inner loops.

5 years agoJava: Pulling in protobuf's faster UTF-8 encoder. (#5035)
Owen O'Malley [Mon, 17 Dec 2018 21:53:49 +0000 (13:53 -0800)]
Java: Pulling in protobuf's faster UTF-8 encoder. (#5035)

* Pulling in protobuf's faster UTF-8 encoder.

* Remove Utf8 unsafe code.

5 years agoFix 'no_sanitize_undefined' attribute for GCC4.8 (#5090)
Vladimir Glavnyy [Mon, 17 Dec 2018 19:50:31 +0000 (02:50 +0700)]
Fix 'no_sanitize_undefined' attribute for GCC4.8 (#5090)

5 years agoEnable flatbuffer to initialize Parser from bfbs (#4283) (#5077)
tira-misu [Thu, 13 Dec 2018 19:59:27 +0000 (20:59 +0100)]
Enable flatbuffer to initialize Parser from bfbs (#4283) (#5077)

* Enable flatbuffer to initialize Parser from bfbs (#4283)

Now its possible to generate json data from bfbs data type and flatbuffers data
and visa versa.

* add deserialize functionality in parser from bfbs
* add small usage sample

* Fix build break

* Merge branch 'pr/1' into fix-issue4283

* Fix buildbreak

* Build monster_test.bfbs with --bfbs-builtins

Attribute flexbuffer has be included in bfbs. Only with this attribute test
will run. By initialization a parser by a bfbs the attribute has to be known
for this filed. monsterdata_test.golden has a flexbuffer field so parse would
fail.

* Fix generate_code.sh

* Revert automatic indent changes by IDE

* Auto detect size prefixed binary schema files

* Use identifier (bfbs) to detect schema files

5 years agogenerated cmake command for flatc generation should depend on source file (#5087)
Christian Lang [Thu, 13 Dec 2018 19:56:51 +0000 (20:56 +0100)]
generated cmake command for flatc generation should depend on source file (#5087)

5 years agoGet rid of reproducible build warning by removing build date & time from flatc versio...
Rob Agar [Mon, 10 Dec 2018 20:48:09 +0000 (20:48 +0000)]
Get rid of reproducible build warning by removing build date & time from flatc version (#5086)

* disable reproducible build warning due to date/time macros

* wrapped GCC pragmas in #ifdef _GNUC_

* removed __DATE__ and __TIME__ macros from flatc.cpp

5 years agoAdd flatbuffer_cc library support (#5061)
Austin Schuh [Mon, 10 Dec 2018 20:23:40 +0000 (07:23 +1100)]
Add flatbuffer_cc library support (#5061)

* Add flatbuffer_cc library support

* Update flags so all the tests pass

Tests now all pass!

* Modify the tests to use the generated code

This should be a simple serialize/deserialize test of the new generated
code to make sure the bazel rules are doing something sane.

* Use generated monster_test.fb in testing/test.cpp

cmake drops it's generated code in tests/monster_test_generated.h
Instead of checking that in, let's generate it with bazel.

* Make grpc tests depend on monster_test_generated.h

* Remove redundant cmake dependency

This should address @aardappel's feedback.

* Run flatc for Android as well

This will fix the last travis.ci failure

* Add generated output folder and fix flags

* Move flatbuffers_header_build_rules to the library that uses it

* Use --cpp-ptr-type to fix android

Android was the only target using the STL emulation layer.  It needed
the --cpp-ptr-type flatbuffers::unique_ptr flag to work.  Add it!

* Roll back changes to use autogenerated monster_test_generated.

Flip tests/test.cpp to use the autogenerated file as well.

5 years agoRenamed JS generator to explicitly state it generates TS too (#5043)
Kamil Rojewski [Thu, 6 Dec 2018 19:12:06 +0000 (20:12 +0100)]
Renamed JS generator to explicitly state it generates TS too (#5043)

5 years ago[net] Fix issue #5036 when write a double value into bytebuffer at big endian machine...
Simon.S.King [Mon, 3 Dec 2018 17:50:26 +0000 (01:50 +0800)]
[net] Fix issue #5036 when write a double value into bytebuffer at big endian machine with unsafe mode. (#5076)

5 years agoSupport nulls in String compare, CreateSharedString (#5060)
Matt Frantz [Mon, 3 Dec 2018 17:48:50 +0000 (09:48 -0800)]
Support nulls in String compare, CreateSharedString (#5060)

5 years agoCI: Dockerized language port tests (#5066)
Robert [Fri, 30 Nov 2018 06:03:06 +0000 (22:03 -0800)]
CI: Dockerized language port tests (#5066)

This runs a script in TravisCI that executes a bunch of small Docker image
scripts to test the language ports in isolated environments. This allows us to
test multiple language versions with little additional complexity.

Covers:

+ Java OpenJDK 10.0.2
+ Java OpenJDK 11.0.1
+ Node 10.13.0
+ Node 11.2.0
+ Python CPython 2.7.15
+ Python CPython 3.7.1
+ Rust 1.30.1

5 years agoFix create_vector_of_strings to use the stack, and test it. (#5074)
Robert [Thu, 29 Nov 2018 19:47:28 +0000 (11:47 -0800)]
Fix create_vector_of_strings to use the stack, and test it. (#5074)

5 years agoFix Java generator bug that ignores bidi streaming attribute (#5063)
Sumant Tambe [Thu, 29 Nov 2018 18:33:17 +0000 (10:33 -0800)]
Fix Java generator bug that ignores bidi streaming attribute (#5063)

* Fix Java generator bug that ignores streaming: bidi attribute
Tests

* Java gRPC client streaming test

* Java gRPC Bidi Streaming Test

5 years agodisable unimportant RAM-heavy test b/c Windows (#5047)
Robert [Sat, 17 Nov 2018 06:03:51 +0000 (22:03 -0800)]
disable unimportant RAM-heavy test b/c Windows (#5047)

5 years agoMake Parser skip files it's seen already. (#5048)
Russell Chou [Sat, 17 Nov 2018 01:11:23 +0000 (17:11 -0800)]
Make Parser skip files it's seen already. (#5048)

The use case is so we can batch compile a bunch of schemas, some which can depend on each other, without caring about their order.

5 years agoMake string/vector field serialization order not depend on optimizer.
Wouter van Oortmerssen [Sat, 17 Nov 2018 00:22:18 +0000 (16:22 -0800)]
Make string/vector field serialization order not depend on optimizer.

Multiple calls of e.g. CreateString inside a call to a CreateTable
could cause those strings to end up in different locations in the
wire format, since order or argument evaluation is undefined.

This is allowed by the FlatBuffer format, but it is not helpful,
especially when debugging the contents of binaries, or comparing
against a "golden" binary for tests etc.

Now making sure that all the CreateTableDirect calls first serialize
sub strings/vectors before calling CreateTable.

Also made similar changes to the serialization of "binary schemas".

Change-Id: I5747c4038b37a0d400aca2bc592bec751cf5c172

5 years agoMake the Parser independent from the global C-locale (#5028)
Vladimir Glavnyy [Fri, 16 Nov 2018 17:24:06 +0000 (00:24 +0700)]
Make the Parser independent from the global C-locale (#5028)

* Make the Parser independent from the global C-locale

* Set a specific test locale using the environment variable FLATBUFFERS_TEST_LOCALE

* Remove redundant static qualifiers

5 years agoFixed double generated file name postfix (#5046)
Kamil Rojewski [Fri, 16 Nov 2018 17:20:29 +0000 (18:20 +0100)]
Fixed double generated file name postfix (#5046)

* Fixed double generated file name postfix

* Fixed missing file postfix on imports without reexports

5 years agoMake flatbuffer C++ tests work when vendored with bazel (#5040)
Austin Schuh [Fri, 16 Nov 2018 17:19:34 +0000 (09:19 -0800)]
Make flatbuffer C++ tests work when vendored with bazel (#5040)

Tests for third_party code are run out of the main workspace.  This
isn't an issue when the main workspace is the
com_github_google_flatbuffers workspace, but is an issue when you are
running the tests from another repository.

To reproduce, use "git_repository" to add flatbuffers to a project and
then run:
  bazel test @com_github_google_flatbuffers//:flatbuffers_test

5 years agoConvenient createX methods for TS (#5044)
Kamil Rojewski [Fri, 16 Nov 2018 17:17:54 +0000 (18:17 +0100)]
Convenient createX methods for TS (#5044)

5 years agoflexbuffers blob to string implementation (#5039)
Shivendra Agarwal [Thu, 15 Nov 2018 22:57:05 +0000 (04:27 +0530)]
flexbuffers blob to string implementation (#5039)

5 years agoFix missing doxygen link to Rust docs
Robert [Tue, 13 Nov 2018 19:10:03 +0000 (11:10 -0800)]
Fix missing doxygen link to Rust docs

5 years agoWrong int32 min-max range definition on numTypes.lua (#5031)
Antonio Park [Mon, 12 Nov 2018 17:40:24 +0000 (02:40 +0900)]
Wrong int32 min-max range definition on numTypes.lua (#5031)

* Update numTypes.lua

int32 range was wrongly defined.

* Update numTypes.lua

Fix number 32 to 31

5 years agoUpdate Conan version Automatically (#5027)
Uilian Ries [Mon, 12 Nov 2018 16:49:42 +0000 (14:49 -0200)]
Update Conan version Automatically (#5027)

* #5026 Add FindFlatBuffers.cmake to Conan Package

Signed-off-by: Uilian Ries <uilianries@gmail.com>
* #5026 Build Flatbuffers on OSX 10

Signed-off-by: Uilian Ries <uilianries@gmail.com>
* #5026 Auto update Conan package version

Signed-off-by: Uilian Ries <uilianries@gmail.com>
* #5026 Update Conan docker images

Signed-off-by: Uilian Ries <uilianries@gmail.com>
* #5026 Update tag var on Appveyor

Signed-off-by: Uilian Ries <uilianries@gmail.com>
* #5026 Filter appveyor brach name

Signed-off-by: Uilian Ries <uilianries@gmail.com>
5 years agoFlexBuffer to JSON convertor for typed and fixedTypedvectors (#4947)
Shivendra Agarwal [Mon, 12 Nov 2018 16:49:11 +0000 (22:19 +0530)]
FlexBuffer to JSON convertor for typed and fixedTypedvectors (#4947)

* FlexBuffer to JSON convertor for typed and fixedTypedvectors

* moving the common implementation to template

* signed unsigned comparison fix

* fix a formatting ({

* changing logic to append comma in vector of elements in json

5 years agoFixed STLPort build
Wouter van Oortmerssen [Tue, 6 Nov 2018 00:33:06 +0000 (16:33 -0800)]
Fixed STLPort build

Change-Id: I2b9508f547667695475be64fa56f64f129603fd4

5 years agoFixed vectors of enums in object API serialized incorrectly.
Wouter van Oortmerssen [Mon, 5 Nov 2018 22:33:36 +0000 (14:33 -0800)]
Fixed vectors of enums in object API serialized incorrectly.

And also added tests for them.

Change-Id: I91af1904105435601287291412e82d5066f476a5
Tested: on Linux.

5 years agoFixed missing code from @javax.annotation PR.
Wouter van Oortmerssen [Fri, 2 Nov 2018 18:40:21 +0000 (11:40 -0700)]
Fixed missing code from @javax.annotation PR.

https://github.com/google/flatbuffers/pull/4986 missed part of the
implementation.

Change-Id: Ie41771eb018a550c289c77ebe9ef5c50d1ad6751

5 years agoFix a memory leak in builder test (#5021)
Sumant Tambe [Fri, 2 Nov 2018 17:04:58 +0000 (10:04 -0700)]
Fix a memory leak in builder test (#5021)

* Fix a memory leak in builder test

* using RAII to free memory

5 years ago--keep-prefix for JS generator (#5018)
Gabriel Nützi [Fri, 2 Nov 2018 15:54:43 +0000 (16:54 +0100)]
--keep-prefix for JS generator (#5018)

* keep include path

* add option --keep-prefix for js

* format contribution (format whole files before merge!)

* revert util.h : IsAbsPath ...

* JS Generator: only support relatives paths (keep it as it was)

5 years agomake unions with type aliases more usable (#5019)
Frank Benkstein [Thu, 1 Nov 2018 19:51:25 +0000 (20:51 +0100)]
make unions with type aliases more usable (#5019)

Some generic C++ and Rust code is not generated when unions use type
aliases because of potential ambiguity. Actually check for this
ambiguity and only disable offending code only if it is found.

5 years agoRust: test that no heap allocs happen on hot paths (#5022)
Robert [Thu, 1 Nov 2018 01:08:14 +0000 (18:08 -0700)]
Rust: test that no heap allocs happen on hot paths (#5022)

5 years agoDisallowed 0 byte structs.
Wouter van Oortmerssen [Tue, 30 Oct 2018 00:40:19 +0000 (17:40 -0700)]
Disallowed 0 byte structs.

This is because they are incompatible with C++ and possibly other
languages that make them minimum size 1 (to make sure multiple
such objects don't reside at the same address). Forcing them to size
1 was also not practical, as that is requires updating the logic
of a lot of implementations and thus possibly backwards incompatible.

More here: https://github.com/google/flatbuffers/issues/4122

Change-Id: I2bfdc8597b7cfd2235bb4074bb2ae06f81f8e57d

5 years agoRevert "Convert net/FlatBuffers project to be compatible with netstandard (#4811)"
Wouter van Oortmerssen [Tue, 30 Oct 2018 00:21:30 +0000 (17:21 -0700)]
Revert "Convert net/FlatBuffers project to be compatible with netstandard (#4811)"

This reverts commit 72b05bc8653c30d988d101de6b3fa90c93192081.

Change-Id: I17510b7fa49b9861ce0a870b16f5c14a41082db5

5 years agoAdd 'fsanitize=address,undefined' to tests and flatc targets (#5009)
Vladimir Glavnyy [Mon, 29 Oct 2018 18:29:05 +0000 (01:29 +0700)]
Add 'fsanitize=address,undefined' to tests and flatc targets (#5009)

* Add '-fsanitize' optional flags to flattests and flatc targets

Control: -DFLATBUFFERS_CODE_SANITIZE=(ON | OFF | "=memory,undefined")
Travis-CI: building with -DFLATBUFFERS_CODE_SANITIZE=ON

* Fix -pie flag

* Cleanup

5 years agoFixed Java gRPC version numbers.
Wouter van Oortmerssen [Thu, 25 Oct 2018 20:48:09 +0000 (13:48 -0700)]
Fixed Java gRPC version numbers.

Change-Id: Iff00a48b370f45f80d68e6c6929483d608ce1885

5 years agoFixed npm publish appending multiple copies into .mjs
Wouter van Oortmerssen [Thu, 25 Oct 2018 20:47:08 +0000 (13:47 -0700)]
Fixed npm publish appending multiple copies into .mjs

Change-Id: Id8c373b0f77d9a0f4922257339abb4e01e06c2d4

5 years agoclean up unnecessary outer rust gen-snippet (#5013)
csmoe [Wed, 24 Oct 2018 03:16:18 +0000 (11:16 +0800)]
clean up unnecessary outer rust gen-snippet (#5013)

* clean up unneeded outer rust gen-snippet

* update generated rust file

5 years agoUse stdlib context in generated Go files (#4904)
Felix Hanley [Mon, 22 Oct 2018 23:28:58 +0000 (10:28 +1100)]
Use stdlib context in generated Go files (#4904)

5 years agoMake alignment checking optional. (#5011)
Doug Muir [Mon, 22 Oct 2018 23:14:44 +0000 (16:14 -0700)]
Make alignment checking optional. (#5011)

5 years agomake flatbuffers::IsFieldPresent safer (#4988)
Frank Benkstein [Mon, 22 Oct 2018 22:57:45 +0000 (15:57 -0700)]
make flatbuffers::IsFieldPresent safer (#4988)

Give the vtable offset enum inside each table the name
"FlatBuffersVTableOffset" and base type voffset_t so it can be used as a
dependent type in IsFieldPresent. This makes that function slightly
safer since it prevents calling it with arbitrary, non-table types.
Now, the only way to use IsFieldPresent incorrectly is to create your
own type which does not inherit from flatbuffers::Table but has a
dependent voffset convertible type "FlatBuffersVTableOffset".

5 years agoAdd fuzzer test for scalar numbers in json. (#4996)
Vladimir Glavnyy [Mon, 22 Oct 2018 22:44:18 +0000 (05:44 +0700)]
Add fuzzer test for scalar numbers in json.  (#4996)

* Add fuzzer test for scalar numbers in json. Grammar-based regex used to check correctness.

* Fix conversation

5 years agoCI check generate code (#4998)
Frank Benkstein [Mon, 22 Oct 2018 22:41:12 +0000 (15:41 -0700)]
CI check generate code (#4998)

* call reflection code generation from tests

This simplifies instructions to contributors so they don't forget to update
reflection code.

* add error handling to generate_code scripts

Let them propagate their errors instead of swallowing them so they show
up when called in CI.

* apply editorconfig to shell scripts

* use ordered map in dart codegen

Using an unordered map in the codegen can lead to spurious diffs in the
generated dart code.

* add CI check for generate_code being run

* update reflection_generated.h

* disable diff-check for monster_test.bfbs

Work around #5008.

5 years agoforbid enum values that are out of range (#4977)
Frank Benkstein [Thu, 18 Oct 2018 17:39:08 +0000 (19:39 +0200)]
forbid enum values that are out of range (#4977)

* forbid enum values that are out of range

Enum values that are out of range can lead to generated C++ code that does
not compile.  Also forbid boolean enums.

* update enum and union documentation slightly

5 years agoEfficient Conversion of a FlatBufferBuilder to a MessageBuilder (#4980)
Sumant Tambe [Thu, 18 Oct 2018 17:32:59 +0000 (10:32 -0700)]
Efficient Conversion of a FlatBufferBuilder to a MessageBuilder (#4980)

* Efficient conversion of FlatBufferBuilder to grpc::MessageBuilder

* Added a variety of tests to validate correctness of the MessageBuilder move operations.
Disable MessageBuilder half-n-half tests on MacOS.

* Fix failing Android build

* Generalized the MessageBuilder move constructor to accept a deallocator

5 years ago[Python] Fast serialization of numpy vectors (#4829)
Felix Frank [Tue, 16 Oct 2018 00:07:08 +0000 (02:07 +0200)]
[Python] Fast serialization of numpy vectors (#4829)

[Python] Fast serialization of numpy vectors (#4829)

5 years agoGo - Use Go bool type for bool fields (#4962)
kostya-sh [Mon, 15 Oct 2018 23:55:59 +0000 (00:55 +0100)]
Go - Use Go bool type for bool fields (#4962)

* Use Go bool type for bool fields, and store non-default bool field to test data

5 years agodisallow c style casts (#4981)
Frank Benkstein [Mon, 15 Oct 2018 22:11:31 +0000 (00:11 +0200)]
disallow c style casts (#4981)

Fixes #4857.

5 years agodon't use std::function in flatbuffers::Parser (#4995)
Frank Benkstein [Mon, 15 Oct 2018 19:26:35 +0000 (21:26 +0200)]
don't use std::function in flatbuffers::Parser (#4995)

std::function makes code harder to debug because it requires stepping
through a separate destructor and call operator.  It's use unnecessary
in the Parser since the functions taking functors are private and are
only used within idl_parser.cpp.  Therefore the definitions can stay in
idl_parser.cpp as well.  Only care must be taken that the definitions
appear before use but that's already true and all compilers will
complain equally if it get's violated.  This change might also improve
performance since it might allow inlining where it wasn't possible
before but I haven't measured that.

5 years agoadd :runtime_cc target (#4994)
iceboy [Mon, 15 Oct 2018 19:18:15 +0000 (12:18 -0700)]
add :runtime_cc target (#4994)

5 years agofix missing newline in flatc help message (#4992)
Frank Benkstein [Thu, 11 Oct 2018 22:54:01 +0000 (00:54 +0200)]
fix missing newline in flatc help message (#4992)

5 years agofix #4974 (#4989)
Frank Benkstein [Thu, 11 Oct 2018 19:40:41 +0000 (21:40 +0200)]
fix #4974 (#4989)

5 years agoRefactoring of idl_parser (#4948)
Vladimir Glavnyy [Thu, 11 Oct 2018 17:37:47 +0000 (00:37 +0700)]
Refactoring of idl_parser (#4948)

* Refactoring of numbers parser

More accurate parse of float and double.
Hexadecimal floats.
Check "out-of-range" of uint64 fields.
Check correctness of default values and metadata.

* Remove locale-independent code strtod/strtof from PR #4948.

* small optimization

* Add is_(ascii) functions

* is_ascii cleanup

* Fix format conversation

* Refine number parser

* Make code compatible with Android build

* Remove unnecessary suppression of warning C4127

5 years agobetter output on TestError (#4979)
Frank Benkstein [Thu, 11 Oct 2018 17:33:12 +0000 (19:33 +0200)]
better output on TestError (#4979)

Print a slightly better error message when a TestError fails.

5 years agoAdd @javax.annotation.Generated to generated flatbuffer Java types (#4986)
Rikard Lundmark [Mon, 8 Oct 2018 22:29:22 +0000 (23:29 +0100)]
Add @javax.annotation.Generated to generated flatbuffer Java types (#4986)

* Add @javax.annotation.Generated to generated flatbuffer Java types.

* Updating test goldens.

5 years agodon't crash when calling EnumNameXXX on sparse enum (#4982)
Frank Benkstein [Mon, 8 Oct 2018 21:37:35 +0000 (23:37 +0200)]
don't crash when calling EnumNameXXX on sparse enum (#4982)

Make an out-of-bounds check for enum values before using them to index the
names array.  For consistency with non-sparse enums an empty string is
returned.

Fixes #4821

5 years agoFix expected type of enum values in reflection tables (#4944)
Michael Edwards [Mon, 8 Oct 2018 21:29:29 +0000 (23:29 +0200)]
Fix expected type of enum values in reflection tables (#4944)

Fixes #4930

5 years agoUse enum types in generated read/mutate methods for Go (#4978)
kostya-sh [Mon, 8 Oct 2018 21:25:37 +0000 (22:25 +0100)]
Use enum types in generated read/mutate methods for Go (#4978)

5 years agoAdd missing const on Reference::As<> (#4975)
cor3ntin [Mon, 8 Oct 2018 19:52:01 +0000 (21:52 +0200)]
Add missing const on Reference::As<> (#4975)

Reference::As<> was needlessly mutable wich made them
less safe and harder to use

5 years agoDisable armeabi builds for Android and re-enable CI builds. (#4970)
Stewart Miles [Mon, 8 Oct 2018 19:43:57 +0000 (12:43 -0700)]
Disable armeabi builds for Android and re-enable CI builds. (#4970)

armeabi support was removed from the Android NDK so we should no
longer build it.  Since this fixes the Android build failures this
commit also re-enables Travis Android builds.

While re-enabling Android builds, some recent changes broke C++98
support so this fixes those issues as well which include:
- Conditionally compiling use of move constructors, operators and
  std::move.
- Changing sample to use flatbuffers::unique_ptr rather than
  std::unique_ptr.

Finally, added the special "default_ptr_type" value for the
"cpp_ptr_type" attribute.  This expands to the value passed to
the "--cpp-ptr-type" argument of flatc.

5 years agoIn Javascript, generate bidirectional mappings for enums, between Name: Value and...
Taj Morton [Thu, 4 Oct 2018 17:37:22 +0000 (10:37 -0700)]
In Javascript, generate bidirectional mappings for enums, between Name: Value and between Value: Name. (#4960)

5 years agoFix recursion counter check. Add control to override depth of nested … (#4953)
Vladimir Glavnyy [Thu, 4 Oct 2018 16:27:37 +0000 (23:27 +0700)]
Fix recursion counter check. Add control to override depth of nested … (#4953)

* Fix recursion counter check. Add control to override depth of nested objects.

* Change if-condition to `>=`

5 years agoBumped version to 1.10.1 for all languages. v1.10.0
Wouter van Oortmerssen [Wed, 3 Oct 2018 19:48:47 +0000 (12:48 -0700)]
Bumped version to 1.10.1 for all languages.

Change-Id: I9a6256d90ea800834a887afdcf888df412018933

5 years agoUpdated TestAll.sh with Rust.
Wouter van Oortmerssen [Wed, 3 Oct 2018 19:27:27 +0000 (12:27 -0700)]
Updated TestAll.sh with Rust.

Change-Id: I751f3bbd85eb1b521e1533c68f95442af0d18b8a

5 years agoAdds __reset method to Struct and Table (#4966)
Jason Neufeld [Wed, 3 Oct 2018 19:09:30 +0000 (12:09 -0700)]
Adds __reset method to Struct and Table (#4966)

This allow recycling/pooling instances without leaking ByteBuffers, by
providing a mechanism to reset instance to newly constructed state.

5 years agoAssert tests on the first failure. (#4952)
Vladimir Glavnyy [Wed, 3 Oct 2018 19:04:14 +0000 (02:04 +0700)]
Assert tests on the first failure. (#4952)

* Assert tests on the first failure. Disable pop-up message box on assertion.

* Fix format and code style

* Move MSVC dependent code to ifdef