platform/upstream/flatbuffers.git
5 years agodocs: Fix where to find the Typescript typings (#5298)
Damien Lespiau [Fri, 19 Apr 2019 20:09:26 +0000 (21:09 +0100)]
docs: Fix where to find the Typescript typings (#5298)

This is what currently rendered:

  /flatubffers

in https://google.github.io/flatbuffers/flatbuffers_guide_use_typescript.html

Besides the typo, @types is being swallowed, the hope is that puting it between
backticks will improve the situation.

5 years agoFix heap-buffer-overflow if there is a struct within a union
Wouter van Oortmerssen [Fri, 19 Apr 2019 18:49:49 +0000 (11:49 -0700)]
Fix heap-buffer-overflow if there is a struct within a union

The validator previously did not check if a struct within a union was
valid, causing a heap buffer overflow.  Add a check to make sure that
the struct is valid in this case.

Change-Id: I87d41b12fdfc2a99406789531ba92b841c063c76

5 years agoUpdate snap include path instruction (#5297)
Omer Akram [Thu, 18 Apr 2019 22:15:21 +0000 (03:15 +0500)]
Update snap include path instruction (#5297)

5 years agoUpdate snap to use "flatbuffers" as name
Wouter van Oortmerssen [Thu, 18 Apr 2019 20:50:04 +0000 (13:50 -0700)]
Update snap to use "flatbuffers" as name

5 years agoAdd Linux Snap Packaging (#5293)
Omer Akram [Thu, 18 Apr 2019 19:22:43 +0000 (00:22 +0500)]
Add Linux Snap Packaging (#5293)

* SNAP: cleanup

* Lets keep it in devel mode as it requires more testing

* add better description

5 years agofix check for Enum defaults (#5292)
Nils Berg [Mon, 15 Apr 2019 18:38:44 +0000 (20:38 +0200)]
fix check for Enum defaults (#5292)

fixes #5288

5 years agoStruct typetable (#5291)
Nils Berg [Mon, 15 Apr 2019 18:38:00 +0000 (20:38 +0200)]
Struct typetable (#5291)

* C++: Generate MiniReflectTypeTable for Structs as well as Tables

* Update generated code

* add test

5 years agoAdd logging of warnings from the flatc compiler (#5289)
Vladimir Glavnyy [Mon, 15 Apr 2019 18:34:09 +0000 (01:34 +0700)]
Add logging of warnings from the flatc compiler (#5289)

5 years agoFixed VS2010 build.
Wouter van Oortmerssen [Thu, 11 Apr 2019 23:14:38 +0000 (16:14 -0700)]
Fixed VS2010 build.

Change-Id: I3ee68c5f250d6baa02060ab2ecbc0f0fe254a9d8

5 years agoAllow Set() methods to handle reference types
Wouter van Oortmerssen [Thu, 11 Apr 2019 21:18:21 +0000 (14:18 -0700)]
Allow Set() methods to handle reference types

Change-Id: I487ded77d28490189dd5d38236cb04bffaf5f11a

5 years agoFix the proto-enum leaking issue (#5286)
Vladimir Glavnyy [Thu, 11 Apr 2019 20:52:01 +0000 (03:52 +0700)]
Fix the proto-enum leaking issue (#5286)

* Detect leak with sanitizer

* Fix proto-enum leak issue

5 years agoDetect leak with sanitizer (#5283)
Vladimir Glavnyy [Thu, 11 Apr 2019 17:15:11 +0000 (00:15 +0700)]
Detect leak with sanitizer (#5283)

5 years agoAdd basic test for enum defaults (#5280)
Vladimir Glavnyy [Mon, 8 Apr 2019 17:21:30 +0000 (00:21 +0700)]
Add basic test for enum defaults (#5280)

5 years agoPart of #5265, neutral changes (#5281)
Vladimir Glavnyy [Mon, 8 Apr 2019 17:05:50 +0000 (00:05 +0700)]
Part of #5265, neutral changes (#5281)

5 years agoEnable MSVC assert report box [Abort|Retry|Ignore] if a debugger is present (#5279)
Vladimir Glavnyy [Mon, 8 Apr 2019 17:01:41 +0000 (00:01 +0700)]
Enable MSVC assert report box [Abort|Retry|Ignore] if a debugger is present (#5279)

5 years agoAdd files generated by CMake to git ignore (#5278)
Henry Lee [Fri, 5 Apr 2019 19:35:40 +0000 (06:35 +1100)]
Add files generated by CMake to git ignore (#5278)

5 years ago[C++]Sync the sample monster.fbs file with the tutorial (#5277)
Henry Lee [Fri, 5 Apr 2019 19:34:53 +0000 (06:34 +1100)]
[C++]Sync the sample monster.fbs file with the tutorial (#5277)

* Fix the header file path in the tutorial doc

* Add the path field in sample/monster.fbs to match the tutorial

* Update the lobster sample file

* Update the binary sample file

5 years agoEnsure we don't subtract with underflow getting enum names (#5246)
Matt Mastracci [Fri, 5 Apr 2019 19:30:58 +0000 (13:30 -0600)]
Ensure we don't subtract with underflow getting enum names (#5246)

* Ensure we don't subtract with underflow getting enum names

* Yep - forgot to run this

5 years agoAdd method GenerateTextFromTable issue #5249 (#5266)
Anthony Liot [Fri, 5 Apr 2019 18:51:29 +0000 (11:51 -0700)]
Add method GenerateTextFromTable issue #5249 (#5266)

* Create a function GenerateGenerateTextFromTable in order to create a json from any Table

Signed-off-by: Anthony Liot <anthony.liot@gmail.com>
* Update the test to failed if loadfile or parser return false

Signed-off-by: Anthony Liot <anthony.liot@gmail.com>
* Fix snake_case name typo + space before &/*

Signed-off-by: Anthony Liot <anthony.liot@gmail.com>
* use auto

Signed-off-by: Anthony Liot <anthony.liot@gmail.com>
* Use clang-format on the added code

Signed-off-by: Anthony Liot <anthony.liot@gmail.com>
5 years agoFix for build break in c# vector of unions (#5271)
Kamil Rojewski [Fri, 5 Apr 2019 18:49:12 +0000 (20:49 +0200)]
Fix for build break in c# vector of unions (#5271)

5 years agoFix typo in Go tutorial (#5274)
unexge [Thu, 4 Apr 2019 19:28:09 +0000 (22:28 +0300)]
Fix typo in Go tutorial (#5274)

5 years agoAdd compile-time checking of numerical limits in C++ code. (#5270)
Vladimir Glavnyy [Mon, 1 Apr 2019 19:03:51 +0000 (02:03 +0700)]
Add compile-time checking of numerical limits in C++ code. (#5270)

* Add checking of numerical_limits<T> in C++ code.

* Add integer suffixes (LL/ULL) to int64 values in the IntegerBoundaryTest

5 years agoUpdate grammar to reflect required type signature for enum declarations. (#5269)
tymcauley [Thu, 28 Mar 2019 17:48:40 +0000 (13:48 -0400)]
Update grammar to reflect required type signature for enum declarations. (#5269)

5 years agoAdd missing test data file to BUILD file (#5264)
Austin Schuh [Mon, 25 Mar 2019 23:17:18 +0000 (16:17 -0700)]
Add missing test data file to BUILD file (#5264)

$ cat
/home/austin/.cache/bazel/_bazel_austin/4b3182bfa237d7e256d9f18ffe58322f/execroot/com_github_google_flatbuffers/bazel-out/k8-opt/testlogs/flatbuffers_test/test.log
exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //:flatbuffers_test
-----------------------------------------------------------------------------
VALUE: "0"
EXPECTED: "1"
TEST FAILED: tests/test.cpp:2029, flatbuffers::LoadFile( (test_data_path
+ "union_vector/union_vector.json").c_str(), false, &jsonfile) in
VALUE: "0"
EXPECTED: "1"
TEST FAILED: tests/test.cpp:2100, parser.Parse(jsonfile.c_str()) in
VALUE: "0"
EXPECTED: "1"
TEST FAILED: tests/test.cpp:2103, VerifyMovieBuffer(jverifier) in

5 years agoBazel CI: fix bad value in yml (#5262)
László Csomor [Mon, 25 Mar 2019 19:27:35 +0000 (20:27 +0100)]
Bazel CI: fix bad value in yml (#5262)

Use the "simple format" defined here:
https://github.com/bazelbuild/continuous-integration/blob/69cf7ec23d984dcbb41fffe946e07ebf5ab7e0f1/buildkite/bazelci.py#L1453

This will unbreak the "Bazel / FlatBuffers"
pipeline on Bazel CI, see
https://buildkite.com/bazel/flatbuffers

5 years agoFix a warning on compiling with clang (#5258)
Nikolay Kuznetsov [Mon, 25 Mar 2019 19:06:00 +0000 (22:06 +0300)]
Fix a warning on compiling with clang (#5258)

5 years agoAdd inequality operator (inspired from #263) (#5257)
LouisP [Mon, 25 Mar 2019 19:04:51 +0000 (20:04 +0100)]
Add inequality operator (inspired from #263) (#5257)

5 years ago[C++] Changes in the flathash program (#5255)
Henry Lee [Thu, 21 Mar 2019 23:23:32 +0000 (10:23 +1100)]
[C++] Changes in the flathash program (#5255)

* Correct the usage in the flathash program

As it is possible to have -- before the occurrence of the first
input STRING.

* Exit with 1 in the flathash program when an error occurs

5 years agoFixed tutorial markdown file (#5248)
Ashay Shirwadkar [Thu, 21 Mar 2019 22:51:51 +0000 (04:21 +0530)]
Fixed tutorial markdown file (#5248)

Path specified in tutorial file was pointing to invalid location.

5 years agoFurther fixes to make minireflect compatible with old behavior.
Wouter van Oortmerssen [Thu, 21 Mar 2019 22:07:24 +0000 (15:07 -0700)]
Further fixes to make minireflect compatible with old behavior.

Change-Id: I92c257ec4ab4a0cf4676bd98523b766ce25bf4f6

5 years agoUnify line ending rules in '.editorconfig' and '.gitattributes' (#5231)
Vladimir Glavnyy [Mon, 18 Mar 2019 19:47:07 +0000 (02:47 +0700)]
Unify line ending rules in '.editorconfig' and '.gitattributes' (#5231)

* Unify line ending rules in '.editorconfig' and '.gitattributes'

* Revert '.gitattributes'

- fix invalid comments in the check-source.py

5 years agoFixed vector_delimited excluding delimiter
Wouter van Oortmerssen [Mon, 18 Mar 2019 19:07:36 +0000 (12:07 -0700)]
Fixed vector_delimited excluding delimiter

Change-Id: I3e758d44b9845d6df91332bb609b4b7ad88659ac

5 years agoFixed shadowing warning in older gcc for vector_delimited
Wouter van Oortmerssen [Mon, 18 Mar 2019 17:03:43 +0000 (10:03 -0700)]
Fixed shadowing warning in older gcc for vector_delimited

Change-Id: Ia4d56a5eb086f86eb5d1ad6ddae64e4a51bf3aa3

5 years agoMade ToStringVisitor backwards compatible with older behavior.
Wouter van Oortmerssen [Thu, 14 Mar 2019 19:00:44 +0000 (12:00 -0700)]
Made ToStringVisitor backwards compatible with older behavior.

This to support code that relied on tables being multiline,
but not vectors.

This behavior was changed in:
https://github.com/google/flatbuffers/commit/b1a925dfc2ac78508aee89029e950057405f0a0a#diff-c45c8fbffbc64f7ff4aa2978612b10d8

Change-Id: I4c95471b643b2b3fab95e06b1294e19d686b492c

5 years agoMade JS enum declarations compatible with google closure
Wouter van Oortmerssen [Mon, 11 Mar 2019 21:33:07 +0000 (14:33 -0700)]
Made JS enum declarations compatible with google closure

Original change by: https://github.com/alexames

Change-Id: Ib65bd02156d1c3637ed278a8334a2307caacaa44

5 years agoDisabled constexpr for hashing functions.
Wouter van Oortmerssen [Mon, 11 Mar 2019 21:01:07 +0000 (14:01 -0700)]
Disabled constexpr for hashing functions.

This was incompatible with -Wc++98-c++11-compat on some platforms,
due to local variables in the function.

Change-Id: Idef510c2cefe944eef2e0656f5a219c2158063e6

5 years agoNarrows template ascii routines to prevent a possible signed overflow in generic...
Vladimir Glavnyy [Mon, 11 Mar 2019 17:26:28 +0000 (00:26 +0700)]
Narrows template ascii routines to prevent a possible signed overflow in generic code. (#5232)

5 years agoFix typo in dart documentation (#5230)
Randal Stevens [Mon, 11 Mar 2019 16:49:17 +0000 (09:49 -0700)]
Fix typo in dart documentation (#5230)

5 years ago[C++] Object API: document custom string type requirements,
Wouter van Oortmerssen [Mon, 11 Mar 2019 16:42:02 +0000 (09:42 -0700)]
[C++] Object API: document custom string type requirements,

implement better custom string type constructor alternative
for Unpack() and fix bug with vector of custom string types
in Pack().

Squashed commit of the following:

commit e9519c647ef949b22756ed660839dd3af854881c
Author: Luca Longinotti <luca.longinotti@inivation.com>
Date:   Tue Mar 5 18:24:49 2019 +0100

    tests: regenerate code, reverts change to CreateVectorOfStrings().

commit 117e3b0679209f2aa55cbee18c4036e7da4bd4b3
Author: Luca Longinotti <luca.longinotti@inivation.com>
Date:   Tue Mar 5 18:15:05 2019 +0100

    idl_gen_cpp.cpp: move clang-format on/off outside of declaration, so they are kept properly aligned automatically.

commit 4791923806965637d5b13f7003329bfbb2fdf18b
Author: Luca Longinotti <luca.longinotti@inivation.com>
Date:   Tue Mar 5 18:11:40 2019 +0100

    idl_gen_cpp.cpp: full clang-format run with provided Google format file, enforce 80 lines width.

commit 2f0402f9ff43b1af0a29806932e08e6d64373345
Author: Luca Longinotti <luca.longinotti@inivation.com>
Date:   Tue Mar 5 18:09:32 2019 +0100

    CppUsage: address requested changes.
    idl_gen_cpp.cpp: fix formatting, keep CreateVectorOfStrings for normal string cases.

commit 371d4e0b7972a59e5cff418c44e4043c016ce56a
Author: Luca Longinotti <luca.longinotti@inivation.com>
Date:   Fri Mar 1 16:35:29 2019 +0100

    Fix compile error with a vector of non-std::strings. CreateVectorOfStrings() expects a vector of std::string types, but that's not always the case.

commit 92b90d7f0fbcfc837a94aa06bedccec0f7b4bb62
Author: Luca Longinotti <luca.longinotti@inivation.com>
Date:   Fri Mar 1 16:15:36 2019 +0100

    Document requirement for custom string types to implement empty() and be constructible from std::string.
    Add new option --cpp-str-flex-ctor to construct custom string types not via std::string, but (char * + length).

commit 28cb2e92d5b7684b5df5184da3a3fad2d0cda733
Author: Luca Longinotti <luca.longinotti@inivation.com>
Date:   Fri Mar 1 14:31:17 2019 +0100

    idl_gen_cpp.cpp: clang-format run, to better separate changes in content from formatting.

Change-Id: I4887ba2f2c632b9e7a8c938659b088cd95690870

5 years ago[Rust] Don't use inner attributes for `allow` (#5212)
bspeice [Sat, 9 Mar 2019 20:58:27 +0000 (14:58 -0600)]
[Rust] Don't use inner attributes for `allow` (#5212)

* Don't use inner attributes for `allow`
Messes with being able to easily include elsewhere

* Regenerate tests

* No-op to retrigger CI

* Add the rest of the `allow` attributes

5 years agoSmall usability tweaks to the rust codegen. (#5213)
Mathias Svensson [Fri, 8 Mar 2019 21:54:57 +0000 (22:54 +0100)]
Small usability tweaks to the rust codegen. (#5213)

5 years agoFix rust crate for big-endian targets (#5229)
tymcauley [Fri, 8 Mar 2019 09:06:25 +0000 (04:06 -0500)]
Fix rust crate for big-endian targets (#5229)

Thanks for tackling this, @tymcauley !

* big endian docker test -- wip

* tweaks

* tweaks

* tweaks

* docker tweaks

* fix conditional compilation issues

* reactivate other docker tests

* try some more cross-platform config (from tymcauley)

* Update tests/docker/languages/Dockerfile.testing.rust.big_endian.1_30_1

Co-Authored-By: rw <rw@users.noreply.github.com>
* Update tests/docker/languages/Dockerfile.testing.rust.big_endian.1_30_1

Co-Authored-By: rw <rw@users.noreply.github.com>
* Update tests/docker/languages/Dockerfile.testing.rust.big_endian.1_30_1

Co-Authored-By: rw <rw@users.noreply.github.com>
* Resolved Rust warnings during big-endian builds.

* Unify Rust test suites for x86 and MIPS builds.

Note that I had to add four extra packages to the MIPS `Dockerfile`:
`libexpat1`, `libmagic1`, `libmpdec2`, and `libreadline7`. For a reason
I couldn't identify, even the simplest Rust MIPS binaries run with
`qemu-mips` would fail with a segfault when run through this
`Dockerfile`. After installing the `gdb-multiarch` package to attempt to
debug the issue, the binaries ran successfully. I pared down the
packages installed by `gdb-multiarch`, and these four packages are the
minimum subset necessary to get Rust MIPS binaries running under
`qemu-mips`.

* Changed Rust tests to use `Vector`s instead of direct-slice-access.

The direct-slice-access method is not available on big-endian targets,
but `flatbuffers::Vector`s provide an array interface that is available
on all platforms.

* Resolved FooStruct endianness issues using explicit struct constructor.

This more closely resembles how FlatBuffers structs are constructed in
generated Rust code.

* Added explanation of how `FooStruct` parallels generated struct code.

Also collected duplicate implementations of `FooStruct` into a common
location.

5 years agoRemoved -Wc++98-compat-extra-semi for compatibility with older clang.
Wouter van Oortmerssen [Thu, 7 Mar 2019 23:14:40 +0000 (15:14 -0800)]
Removed -Wc++98-compat-extra-semi for compatibility with older clang.

Change-Id: I6dfadb5289a4396ad2f3d16baf1bdb99c7534174

5 years agoBazel ci (#5228)
Austin Schuh [Thu, 7 Mar 2019 23:09:30 +0000 (15:09 -0800)]
Bazel ci (#5228)

* Stop building for Windows until the build passes

ERROR: D:/b/bk-windows-java8-bd0z/bazel/flatbuffers/BUILD:123:1: Couldn't build file _objs/flatbuffers_test/test.obj: undeclared inclusion(s) in rule '//:flatbuffers_test':
this rule is missing dependency declarations for the following files included by 'tests/test.cpp':
  'tests/monster_test_generated.h'
  'tests/monster_extra_generated.h'

The files in tests are being found instead of the generated files since
Windows doesn't have any sandboxing.  For now, let's disable the rules
and come back to it.

* Fix buildifier warnings

Clean up docstrings and add a module docstring.

5 years agoFixed vector of union JSON parsing.
Wouter van Oortmerssen [Mon, 4 Mar 2019 22:56:07 +0000 (14:56 -0800)]
Fixed vector of union JSON parsing.

This for some reason never had a test case, and was broken.

Change-Id: If832f5eb8b6c5ba8a75257464892634b38719c55

5 years ago[Rust] Fixed codegen documentation for Tables (#5227)
jean-airoldie [Wed, 6 Mar 2019 20:00:58 +0000 (15:00 -0500)]
[Rust] Fixed codegen documentation for Tables (#5227)

5 years ago[Go] Add mutation functions for vector elements (#5221)
David Reiss [Wed, 6 Mar 2019 05:16:26 +0000 (21:16 -0800)]
[Go] Add mutation functions for vector elements (#5221)

Fixes #5206

5 years agoClean-up nested_parser on all paths (#5179) (#5184)
ll-antn [Mon, 4 Mar 2019 19:35:10 +0000 (22:35 +0300)]
Clean-up nested_parser on all paths (#5179) (#5184)

* Clean-up nested_parser on all paths (#5179)

* Added test for parsing json with invalid nested flatbuffer

* Removed utf-8 BOM from test.cpp

5 years ago[Fix #5112] flatc generates constructors with memset for non-trivial types (#5222)
Laurent Stacul [Mon, 4 Mar 2019 19:10:18 +0000 (20:10 +0100)]
[Fix #5112] flatc generates constructors with memset for non-trivial types (#5222)

5 years ago[doc] fix typos in doc. (#5217)
csukuangfj [Thu, 28 Feb 2019 20:39:26 +0000 (04:39 +0800)]
[doc] fix typos in doc. (#5217)

5 years agoRust: Fix lifetime in union _as_ accessors (#5140)
naure [Wed, 27 Feb 2019 07:48:54 +0000 (08:48 +0100)]
Rust: Fix lifetime in union _as_ accessors (#5140)

* Fix lifetime in union _as_ accessors

In the accessors for union field, the return value is implicitly taking the lifetime of &self.
This is irrelevant and prevents usages of the returned value, because it is needlessly bound to the parent field lifetime.

This patch makes the return value inherit the lifetime of the data, like other methods do.

5 years agoJava: Calculation of vtable and vtable size moved to the __init method. (#5210)
Kulikov Alexey [Mon, 25 Feb 2019 22:45:29 +0000 (05:45 +0700)]
Java: Calculation of vtable and vtable size moved to the __init method. (#5210)

vtable and vtable size depends only on `Table#bb_pos` but calculated in
`Table#_offset` method on each field lookup.
Doing this with every call of `Table#__offset` is redundant.

These values can be read once with change of `Table#bb_pos` and reused
for any field lookup.

5 years agoJava: Removed unused duplicate of bytebuffer from "Table#__string" method. (#5211)
Kulikov Alexey [Mon, 25 Feb 2019 22:28:13 +0000 (05:28 +0700)]
Java: Removed unused duplicate of bytebuffer from "Table#__string" method. (#5211)

5 years agoLua library: fix vtable reuse. (#5214)
Искандаров Егор [Mon, 25 Feb 2019 22:27:42 +0000 (01:27 +0300)]
Lua library: fix vtable reuse. (#5214)

Fixed a bug that prevented vtable reuse during buffer construction in the lua library.

Also fixed a bug in vtable equality check that was revealed after the first fix.

5 years agoAttempting to make travis not kill the Android build.
Wouter van Oortmerssen [Mon, 25 Feb 2019 22:10:56 +0000 (14:10 -0800)]
Attempting to make travis not kill the Android build.

Change-Id: Icdff8a90338bd2ff79ff76fe1ebaa3481da8dea4

5 years agoIterateValue: Use ReadScalar instead of unportable reinterpret_casts (#5209)
Marcus Comstedt [Mon, 25 Feb 2019 20:45:11 +0000 (21:45 +0100)]
IterateValue: Use ReadScalar instead of unportable reinterpret_casts (#5209)

This fixes the testcase MiniReflectFlatBuffersTest.

5 years agoFix incorrect code generation on Solaris Sparc. (#5208)
Brian Wellington [Mon, 25 Feb 2019 20:41:31 +0000 (12:41 -0800)]
Fix incorrect code generation on Solaris Sparc. (#5208)

On Solaris Sparc, calling NumToString() with a char called the primary
version, not the signed char or unsigned char specializations, which
caused integer to string conversions to be missed.

5 years agoAdded -Wc++98-compat-extra-semi
Wouter van Oortmerssen [Mon, 25 Feb 2019 19:42:37 +0000 (11:42 -0800)]
Added -Wc++98-compat-extra-semi

And fixed 2 more extra semi-colons.

Change-Id: I1ee08e5b2f67cd0c886847c05cd4d63cfcafec3e

5 years agoAdded -Wextra-semi to Clang build.
Wouter van Oortmerssen [Mon, 25 Feb 2019 17:14:06 +0000 (09:14 -0800)]
Added -Wextra-semi to Clang build.

Also fixed warnings this generated.

Change-Id: If3607907b2dd609f854b7b81225d9cf66af75a60

5 years agoFix big-endian build. (#5205)
Brian Wellington [Fri, 22 Feb 2019 00:50:05 +0000 (16:50 -0800)]
Fix big-endian build. (#5205)

For some reason, Offset<T> is being considered a scalar, which
causes EndianSwap to be passed an Offset<T>.  This doesn't work,
as it does not support types with non-trivial constructors.  This
change adds an overload to WriteScalar(), which works around this.

5 years agoRemove byte* property in ByteBufferAllocator (#5191)
Eric Erhardt [Thu, 21 Feb 2019 22:36:55 +0000 (16:36 -0600)]
Remove byte* property in ByteBufferAllocator (#5191)

* Remove byte* property in ByteBufferAllocator.

This allows consumers to read/write into native memory, but without
having to always pin the managed `byte[]` when working with managed
memory. This allows for users to not need to Dispose() ByteBuffers
when they are using the default ByteArrayAllocator class.

Instead, we use `Span<byte> GetSpan()` methods to get access to the
underlying memory buffer.

Fix #5181

* Add a set of benchmark tests.

* Add ReadOnly spans.

This allows consumers to use ReadOnlyMemory<byte> as the backing storage
for ByteBuffers, which is useful in read-only scenarios.

* Run tests using ENABLE_SPAN_T in appveyor.

* Fix FlatBuffers.Test.csproj to work on older MSBuild versions.

* Change the test script to test UNSAFE_BYTEBUFFER

* Address PR feedback.

Remove IDisposable from ByteBuffer.

* Respond to PR feedback.

5 years agoImprove endian detection. (#5204)
bwelling [Thu, 21 Feb 2019 21:45:11 +0000 (13:45 -0800)]
Improve endian detection. (#5204)

Add support for using __BYTE_ORDER__, to support platforms where g++
doesn't explicitly define __BIG_ENDIAN__, like Solaris Sparc.

5 years agoAdd RPM packaging support (#5177)
Marc Butler [Thu, 21 Feb 2019 19:06:04 +0000 (06:06 +1100)]
Add RPM packaging support (#5177)

* Add RPM packaging support

Using the existing PackageDebian as template add support for
generating an rpm with the package target.

* Restore debian package target

Also add an option to advertise the fact.

* Update package description

C-n-p from README.md

* Update rpm package maintainer

5 years agoFixed vector of unions crash in java (#5190)
Kamil Rojewski [Thu, 21 Feb 2019 18:50:13 +0000 (19:50 +0100)]
Fixed vector of unions crash in java (#5190)

* Fixed vector of unions crash in java

* Regenerated test code

* Fixed windows tests

5 years agoAdded .net core project (#5187)
Efe Burak [Thu, 21 Feb 2019 18:47:19 +0000 (13:47 -0500)]
Added .net core project (#5187)

5 years agoFix an error in cpp code. (#5189)
csukuangfj [Tue, 19 Feb 2019 19:23:10 +0000 (03:23 +0800)]
Fix an error in cpp code. (#5189)

Change monster_generate.h to monster_generated.h

5 years agoUtility for checking the encoding and line ending of source files (#5188)
Vladimir Glavnyy [Tue, 19 Feb 2019 19:22:25 +0000 (02:22 +0700)]
Utility for checking the encoding and line ending of source files (#5188)

* Add utility for checking the encoding of source files

- accept source files with ASCII or UTF-8 without BOM
- accept only CRLF line ending

* Fix non-ascii symbol in idl_parcer.cpp

* Remove BOM from test.cpp

5 years agoFixed use of WIN32 needs to be _WIN32.
Wouter van Oortmerssen [Tue, 19 Feb 2019 18:49:23 +0000 (10:49 -0800)]
Fixed use of WIN32 needs to be _WIN32.

Change-Id: Ie1f88ac5613cc09ed1074608dd6517ae20c7973d

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>