platform/upstream/flatbuffers.git
6 years agoC# support for directly reading and writting to memory other than byte[]. For exampl...
Christopher Cifra [Thu, 23 Aug 2018 17:05:31 +0000 (12:05 -0500)]
C# support for directly reading and writting to memory other than byte[].  For example, ByteBuffer can be initialized with a custom allocator which uses shared memory / memory mapped files. (#4886)

Public access to the backing buffer uses Span<T> instead of ArraySegment<T>.

Writing to the buffer now supports Span<T> in addition to T[].

To maintain backwards compatibility ENABLE_SPAN_T must be defined.

6 years agoUpdated preprocessor check for template aliases. (#4888)
Derek Bailey [Thu, 23 Aug 2018 16:48:03 +0000 (09:48 -0700)]
Updated preprocessor check for template aliases. (#4888)

6 years agoMono Fix for Unsafe Mode (#4887)
Derek Bailey [Mon, 20 Aug 2018 23:31:44 +0000 (16:31 -0700)]
Mono Fix for Unsafe Mode (#4887)

* Added preprocessor define for C++ if Template Aliases are supported by the compiler

* Revert "Revert "Performance Increase of Vector of Structures using .NET BlockCopy (#4830)""

This reverts commit 1f5eae5d6a135ff6811724f6c57f911d1f46bb15.

* Put<T> method was inside #if UNSAFE_BYTEBUFFER which caused compilation failure when building in unsafe mode

* Revert "Added preprocessor define for C++ if Template Aliases are supported by the compiler"

This reverts commit a75af7352127c261baf0b6cca5cb823e13e78f11.

6 years agoRevert "Performance Increase of Vector of Structures using .NET BlockCopy (#4830)"
Wouter van Oortmerssen [Mon, 20 Aug 2018 19:08:21 +0000 (12:08 -0700)]
Revert "Performance Increase of Vector of Structures using .NET BlockCopy (#4830)"

This reverts commit 7b50004ec9a1b86db2b1b61a9906e52227f62b35.

Change-Id: I09d6869c16aa3c7fadc537fc9c76eaa3cf7ee7ea

6 years agoAdded missing dart/ts test changes.
Wouter van Oortmerssen [Mon, 20 Aug 2018 18:54:37 +0000 (11:54 -0700)]
Added missing dart/ts test changes.

Change-Id: I836091193485b890710f1df779d4d770f729a27a

6 years agoAdd C#/Java generator behaviour for 'private' attribute (#4882)
Andy Martin [Thu, 16 Aug 2018 22:25:33 +0000 (23:25 +0100)]
Add C#/Java generator behaviour for 'private' attribute (#4882)

* Added 'private' attribute, supported when generating C# and Java

* Added use of 'private' attribute in monster_test

6 years agoConan build packages on CI (#4590) (#4594)
Uilian Ries [Thu, 16 Aug 2018 19:17:52 +0000 (16:17 -0300)]
Conan build packages on CI (#4590) (#4594)

* Build Conan package on Travis CI (#4590)

- Added multi package support on Linux, running on Travis CI
- Only upload when branch is a tag and named "vX.Y.Z"
- Replace Conan injection by Conan wrapper
- Removed os_build os_arch -- Conan 1.0.1 hotfix

Signed-off-by: Uilian Ries <uilianries@gmail.com>
* Build Conan package on OSX (#4590)

- Added jobs to build Flatbuffers on OSX running on Travis

Signed-off-by: Uilian Ries <uilianries@gmail.com>
* Build Conan package on Windows (#4590)

- Added support necessary to build Flatbuffers on Windows (conan)
- Added Appveyor jobs to build Conan package
- Only build Conan package when release (tag)

Signed-off-by: Uilian Ries <uilianries@gmail.com>
* Reduce Conan CI support to simple scripts (#4590)

- Removed msvc 10 x86_64 workaround
- Updated conan remote address
- Added Bincrafters' package tools

Signed-off-by: Uilian Ries <uilianries@gmail.com>
* Add fPIC option on Conan recipe (#4590)

- Add fPIC as optional. It works on Linux and OSX
- Update recipe metadata: author, homepage, license
- Checking for flatc and flathash on Conan package

Signed-off-by: Uilian Ries <uilianries@gmail.com>
* Build Conan package on CI (#4590)

- Add rule to run conan job only for tags
- Run Conan on Linux, OSX and Windows
- Update package tool to new interface

Signed-off-by: Uilian Ries <uilianries@gmail.com>
* Update Conan username (#4590)

- Use google as default username

Signed-off-by: Uilian Ries <uilianries@gmail.com>
* Update OSX version on CI (#4590)

- Use latest OSX 9.3 version to build Conan package

Signed-off-by: Uilian Ries <uilianries@gmail.com>
6 years agoProposing use of C++ header files and functions (#4869)
kulswanand [Mon, 13 Aug 2018 23:36:11 +0000 (05:06 +0530)]
Proposing use of C++ header files and functions (#4869)

* Proposing use of C++ header files and functions

Proposing use of C++ header files and functions instead of C header file and functions.
Here are few examples for comparison :

C                            C++
<cstdio>                <iostream> & <fstream>
printf()                     cout
fopen()                    ifstream
etc ...

Please let me know if there are any comments.

* Updated diff based on review comments

6 years agoUse string_view if _HAS_CXX17 is true (#4876)
iceboy [Mon, 13 Aug 2018 23:19:51 +0000 (16:19 -0700)]
Use string_view if _HAS_CXX17 is true (#4876)

Current version of VC2017 is not setting __cplusplus to correct value, instead they use _MSC_VER, _MSVC_LANG and _HAS_CXX17 macros.

6 years agoFixed use of uoffset_t in verifier could cause wrap around.
Wouter van Oortmerssen [Mon, 13 Aug 2018 16:24:13 +0000 (09:24 -0700)]
Fixed use of uoffset_t in verifier could cause wrap around.

The verifier must be resilient against any corrupt data, so
now using size_t thru-out to ensure any 64-bit offsets can
be represented.

Also added verification of alignment.

Change-Id: I87a22aa6b045c2d83b69b47a47153f2e15ad7e06
Tested: on Linux, also with libfuzzer.

6 years ago Update JavaScript IDL generator to remove invalid Closure JSDoc comments (#4873)
Matias Cudich [Fri, 10 Aug 2018 22:27:51 +0000 (15:27 -0700)]
 Update JavaScript IDL generator to remove invalid Closure JSDoc comments (#4873)

* Update JavaScript IDL generator to remove invalid Closure JSDoc comments

* Revert erroneous changes

* A few more tweaks

* Updated generated code

6 years agoRemove FLATBUFFERS_COPTS from bazel BUILD (#4872)
iceboy [Fri, 10 Aug 2018 20:43:48 +0000 (13:43 -0700)]
Remove FLATBUFFERS_COPTS from bazel BUILD (#4872)

fixes #4868

6 years agoCorrectly generate identifier for enums. (#4871)
cubeleo [Fri, 10 Aug 2018 20:41:32 +0000 (13:41 -0700)]
Correctly generate identifier for enums. (#4871)

This should allow the EnumName* function to work with enums generated
using the --scoped-enum flag.

6 years agoClarify flatbuffer reflection struct sizes to be less error-prone. (#4870)
Andrew Selle [Fri, 10 Aug 2018 17:55:54 +0000 (10:55 -0700)]
Clarify flatbuffer reflection struct sizes to be less error-prone. (#4870)

6 years agoAdd licenses to BUILD (#4867)
iceboy [Fri, 10 Aug 2018 15:21:17 +0000 (08:21 -0700)]
Add licenses to BUILD (#4867)

This allows to build flatbuffers from third_party directory.

6 years agoEnsure strings are null terminated when written from Dart (#4862)
Dan Field [Thu, 9 Aug 2018 16:50:54 +0000 (12:50 -0400)]
Ensure strings are null terminated when written from Dart (#4862)

* Update for Dart 2.x constants

* Fix strings, update test, add CHANGELOG for Dart

6 years agoTemporarily disabled Android CI until fix.
Wouter van Oortmerssen [Mon, 6 Aug 2018 23:51:28 +0000 (16:51 -0700)]
Temporarily disabled Android CI until fix.

Change-Id: I0c6758db7b4007e84b7ab8daaecd233711df8cab

6 years agoAttach header directory information to the "flatbuffers" library target (#4849)
Vladimir Glavnyy [Mon, 6 Aug 2018 21:59:29 +0000 (04:59 +0700)]
Attach header directory information to the "flatbuffers" library target (#4849)

* Attach header directory information to the "flatbuffers" library target, if the CMake version supports it.

* Cleanup and documentation update

6 years agoPublishing flatc with conan (#4852)
Kamil Rojewski [Mon, 6 Aug 2018 19:45:35 +0000 (21:45 +0200)]
Publishing flatc with conan (#4852)

* Eclipse ignore

* TypeScript support

* Prefixing enums

* Test results

* Merged JS and TS generators

* Fixed AppVeyor build problems

* Fixed more AppVeyor build problems

* Fixed more AppVeyor build problems

* Changed TS flag to options struct

* Storing options by value

* Removed unneeded const

* Re-export support for unions

* Uint support

* Casting bools to numbers for mutation

* TS shell tests

* Reverted generates js test file to original version

* Backing up js tests and properly generating test data

* Not importing flatbuffers for TS test generation

* Not overwriting generated js for tests

* AppVeyor test fixes

* Generating the most strict TS code possible

* Not returning null when creating vectors

* Not returning null from struct contructors

* Vector of unions for ts/js

* Sanity check for languages

* Indentation fix + output test files

* Vectors of unions for php

* Fixes to union vector handling + tests

* Fix for strictPropertyInitialization

* Fix for new aligned operator new for gcc >= 7.1

* Not generating imports/ns prefixes with --gen-all

* TypeScript docs

* Missing imports of enums

* Missing TS links

* Enabled vector of unions for java, since it seems to work

* Added jitpack config

* Added obj to vector of unions getter

* Removed unneeded accessor

* Bumped jdk version in pom.xml

* Vector of unions support for c#

* Missing TypeScript doc processing

* Option to NOT force libc++ when building with clang

* Publishing flatc with conan

6 years agoRemove using namespace std; (#4851)
Charlie Harrison [Mon, 6 Aug 2018 19:08:49 +0000 (15:08 -0400)]
Remove using namespace std; (#4851)

6 years agoFixed VS2010 compile error.
Wouter van Oortmerssen [Mon, 6 Aug 2018 19:06:59 +0000 (12:06 -0700)]
Fixed VS2010 compile error.

Change-Id: Ibd970d30b51f77a2ac9c125e400c9f1b19a81cbc

6 years agoFlatBuffers implementation for the Lobster programming language
aardappel [Tue, 24 Jul 2018 02:03:11 +0000 (19:03 -0700)]
FlatBuffers implementation for the Lobster programming language

Language, see: http://strlen.com/lobster/ and https://github.com/aardappel/lobster

6 years agoAdds multi-line to FLatBufferToString (#4847)
shassani [Fri, 27 Jul 2018 19:45:12 +0000 (12:45 -0700)]
Adds multi-line to FLatBufferToString (#4847)

Adding multi-line option to FlatBufferToString method in minireflect to allow more readable output for larger flatbuffers.

6 years agoFixed FlatBufferBuilder::Required not checking vtable size.
Wouter van Oortmerssen [Fri, 27 Jul 2018 19:40:44 +0000 (12:40 -0700)]
Fixed FlatBufferBuilder::Required not checking vtable size.

As reported in: https://github.com/google/flatbuffers/issues/4846
Tested: on Linux.

Change-Id: Id5e82dc5a46a681119cfe5a15415d522aac0e1f2

6 years agoFor sparse enums, use a switch statement to generate EnumNameXXX(). (#4845)
cubeleo [Fri, 27 Jul 2018 15:32:19 +0000 (08:32 -0700)]
For sparse enums, use a switch statement to generate EnumNameXXX(). (#4845)

6 years agoMerge pull request #4843 from rw/2018-07--explicit-enumish-types
Robert [Thu, 26 Jul 2018 23:57:01 +0000 (16:57 -0700)]
Merge pull request #4843 from rw/2018-07--explicit-enumish-types

go: give enums their own scalar types

6 years agogo: give enums their own scalar types
rw [Thu, 26 Jul 2018 23:40:56 +0000 (16:40 -0700)]
go: give enums their own scalar types

6 years agoUpdate FLATBUFFERS_HAS_STRING_VIEW __cplusplus checks to the versions provided by...
Paul Reimer [Thu, 26 Jul 2018 22:40:41 +0000 (15:40 -0700)]
Update FLATBUFFERS_HAS_STRING_VIEW __cplusplus checks to the versions provided by the standard feature test macros. (#4841)

6 years agoMerge pull request #4820 from nairb774/master
Robert [Thu, 26 Jul 2018 22:35:45 +0000 (15:35 -0700)]
Merge pull request #4820 from nairb774/master

[Go] encode.go performance changes

6 years agoUpdate for Dart 2.x constants (#4842)
Dan Field [Thu, 26 Jul 2018 21:21:23 +0000 (17:21 -0400)]
Update for Dart 2.x constants (#4842)

6 years agoPerformance Increase of Vector of Structures using .NET BlockCopy (#4830)
Derek Bailey [Thu, 26 Jul 2018 20:44:40 +0000 (13:44 -0700)]
Performance Increase of Vector of Structures using .NET BlockCopy (#4830)

* Added Get<vector_name>Array() method for accessing vectors of structures in C# using Buffer.Blockcopy().

* Added Get<vector_name>Array() method for accessing vectors of structures in C# using Buffer.Blockcopy().

Added Create<Name>VectorBlock() method to add a typed array using Buffer.BlockCopy() to speed up creation of vector of arrays

New Lua files for namespace test

* fixed c++ style issue

6 years agoFixed minalign in Lua being reset on StartObject
Wouter van Oortmerssen [Mon, 23 Jul 2018 23:36:21 +0000 (16:36 -0700)]
Fixed minalign in Lua being reset on StartObject

Change-Id: I9cd62b38c8dc526f069726a88baef63e4b0dae57

6 years agogo: do not clobber minalign when we create objects (#4834)
Robert [Mon, 23 Jul 2018 23:34:08 +0000 (16:34 -0700)]
go: do not clobber minalign when we create objects (#4834)

6 years agopython: do not clobber minalign when we create objects (#4833)
Robert [Mon, 23 Jul 2018 23:29:45 +0000 (16:29 -0700)]
python: do not clobber minalign when we create objects (#4833)

6 years agoAdd missing public header `minireflect.h` to bazel build (#4832)
Evan Moran [Mon, 23 Jul 2018 23:28:49 +0000 (16:28 -0700)]
Add missing public header `minireflect.h` to bazel build (#4832)

6 years agoFixing bazel build's missing lua file (#4831)
Evan Moran [Mon, 23 Jul 2018 23:28:09 +0000 (16:28 -0700)]
Fixing bazel build's missing lua file (#4831)

6 years agoAdds ForceStringAlignment to flatbuffers. (#4828)
shassani [Thu, 19 Jul 2018 23:00:31 +0000 (16:00 -0700)]
Adds ForceStringAlignment to flatbuffers. (#4828)

ForceStringAlignment is useful for memory aligning string fields in flatbuffers.

6 years agoRestricting (typed=false, fixed=true) combination in flexbuffer CreateVector (#4825)
Shivendra Agarwal [Thu, 19 Jul 2018 21:59:06 +0000 (03:29 +0530)]
Restricting (typed=false, fixed=true) combination in flexbuffer CreateVector (#4825)

https://github.com/google/flatbuffers/issues/4815

6 years agoFixing an assert in flexbuffers CreateVector (#4824)
Shivendra Agarwal [Thu, 19 Jul 2018 21:55:06 +0000 (03:25 +0530)]
Fixing an assert in flexbuffers CreateVector (#4824)

An assert was blocking the creation of typedvectors. It was wrongly checking for limited types even though vector was not of fixedTyped.

6 years agoOption to NOT force libc++ when building with clang (#4826)
Kamil Rojewski [Thu, 19 Jul 2018 16:40:28 +0000 (18:40 +0200)]
Option to NOT force libc++ when building with clang (#4826)

* Eclipse ignore

* TypeScript support

* Prefixing enums

* Test results

* Merged JS and TS generators

* Fixed AppVeyor build problems

* Fixed more AppVeyor build problems

* Fixed more AppVeyor build problems

* Changed TS flag to options struct

* Storing options by value

* Removed unneeded const

* Re-export support for unions

* Uint support

* Casting bools to numbers for mutation

* TS shell tests

* Reverted generates js test file to original version

* Backing up js tests and properly generating test data

* Not importing flatbuffers for TS test generation

* Not overwriting generated js for tests

* AppVeyor test fixes

* Generating the most strict TS code possible

* Not returning null when creating vectors

* Not returning null from struct contructors

* Vector of unions for ts/js

* Sanity check for languages

* Indentation fix + output test files

* Vectors of unions for php

* Fixes to union vector handling + tests

* Fix for strictPropertyInitialization

* Fix for new aligned operator new for gcc >= 7.1

* Not generating imports/ns prefixes with --gen-all

* TypeScript docs

* Missing imports of enums

* Missing TS links

* Enabled vector of unions for java, since it seems to work

* Added jitpack config

* Added obj to vector of unions getter

* Removed unneeded accessor

* Bumped jdk version in pom.xml

* Vector of unions support for c#

* Missing TypeScript doc processing

* Option to NOT force libc++ when building with clang

6 years agoMissing Lua generated files
Wouter van Oortmerssen [Mon, 16 Jul 2018 23:44:49 +0000 (16:44 -0700)]
Missing Lua generated files

Change-Id: Id668ade474805dd9c7e108a478db3551d6a62b48

6 years agoRenamed Verifier methods
Wouter van Oortmerssen [Mon, 16 Jul 2018 23:41:38 +0000 (16:41 -0700)]
Renamed Verifier methods

The name Verify was getting too overloaded, and confused
the VS compiler

Change-Id: I26423a4d513e4def2f4e41d7f278bb683fc12518

6 years agoDart generated code changes
Wouter van Oortmerssen [Mon, 16 Jul 2018 23:39:33 +0000 (16:39 -0700)]
Dart generated code changes

Change-Id: I1110974a375acb9668552294632658d9d1779772

6 years agoflatbuffer force-empty option (#4822)
shassani [Mon, 16 Jul 2018 23:05:06 +0000 (16:05 -0700)]
flatbuffer force-empty option (#4822)

6 years agoUpdated fuzzer scripts
Wouter van Oortmerssen [Mon, 16 Jul 2018 22:51:01 +0000 (15:51 -0700)]
Updated fuzzer scripts

Point to new Chromium location
Also enable UBSan

Change-Id: I4ba182e3c6a967ad89090b776d05762fa9ae6e40

6 years agoFixed assert in ParseSingleValue (found by fuzzer)
Wouter van Oortmerssen [Mon, 16 Jul 2018 22:49:53 +0000 (15:49 -0700)]
Fixed assert in ParseSingleValue (found by fuzzer)

Change-Id: I84674eaab75b2b455e918b04e3027920430678ac

6 years agoC++ verifier now primarily uses offsets instead of pointers.
Wouter van Oortmerssen [Thu, 12 Jul 2018 23:26:17 +0000 (16:26 -0700)]
C++ verifier now primarily uses offsets instead of pointers.

Fix for: https://bugs.chromium.org/p/chromium/issues/detail?id=834710

Before, the verifier would create pointers to objects, and then
verify they are inside the buffer. But since even constructing pointers
that are outside a valid allocation is Undefinied Behavior in C++, this
can trigger UBSAN (with -fsanitize=pointer-overflow).

Now instead the bounds checking is first performed using offsets
before pointers are even created.

Change-Id: If4d376e90df9847e543247e70a062671914dae1b
Tested: on Linux.

6 years ago:memo: release mode in building doc (#4819)
xgdgsc [Mon, 16 Jul 2018 19:56:14 +0000 (03:56 +0800)]
:memo: release mode in building doc (#4819)

6 years agoConvert net/FlatBuffers project to be compatible with netstandard (#4811)
Damien Pontifex [Mon, 16 Jul 2018 16:13:36 +0000 (00:13 +0800)]
Convert net/FlatBuffers project to be compatible with netstandard (#4811)

6 years ago[Go] Force a single, early bounds check on read and write paths.
Brian Atkinson [Sun, 15 Jul 2018 23:38:56 +0000 (16:38 -0700)]
[Go] Force a single, early bounds check on read and write paths.

As an example, GetInt64 used to perform 8 bounds checks, one for each
slice access. By performing a bound check on the highest index, the
number of checks is reduced to one through bounds-check-elimination.

6 years ago[Go] Unroll WriteUint64 and WriteInt64.
Brian Atkinson [Sun, 15 Jul 2018 23:38:55 +0000 (16:38 -0700)]
[Go] Unroll WriteUint64 and WriteInt64.

This enables both WriteUint64 and WriteInt64 to both be inlined as
well as implemented with a single assembly instruction. The current Go
compiler refuses to inline functions with for loops. The compiler is
also not smart enough to produce a single assembly instruction for the
for-loop.

6 years agoFixed Uint() method actually storing a signed int.
Wouter van Oortmerssen [Fri, 6 Jul 2018 19:30:43 +0000 (12:30 -0700)]
Fixed Uint() method actually storing a signed int.

Also fixed two constructors missing explicit.

Change-Id: I147b2d2517bb660d92d4b0167992c115ed65dca7

6 years agoLua (5.3) Language addition (#4804)
Derek Bailey [Thu, 5 Jul 2018 22:55:57 +0000 (15:55 -0700)]
Lua (5.3) Language addition (#4804)

* starting Lua port of python implmention. Syncing commit

* Bulk of Lua module port from Python done. Not tested, only static analysis. Need to work on binary strings. Started work on flatc lua code generation

* Fixed all the basic errors to produced a binary output from the builder, don't know if it is generated correctly, but it contains data, so that must be good

* fixed binary set command that was extending the array improperly

* continued improvement

* Moved lua submodules down a directory so their names don't clash with potential other modules. Added compat module to provide Lua versioning logic

* Successful sample port from Python

* working on testing Lua code with formal tests

* continued to work on tests and fixes to code to make tests pass

* Added reading buffer test

* Changed binaryarray implmentation to use a temporary table for storing data, and then serialize it to a string when requested. This double the rate of building flatbuffers compared to the string approach.

* Didn't need encode module as it just added another layer of indirection that isn't need

* profiled reading buffers, optimizations to increase read performance of monster data to ~7 monster / millisecond

* Writing profiler improvments. Get about
~2 monsters/millisecond building rate

* removed Numpy generation from Lua (came from the Python port)

* math.pow is deprecated in Lua 5.3, so changed to ^ notation. Also added .bat script for starting Lua tests

* adding results of generate_code.bat

* simple edits for code review in PR.

* There was a buffer overflow in inserting the keywords into the unorder set for both the Lua and Python code gens. Changed insertion to use iterators.

* fixed spacing issue

* basic documenation/tutorial updates. Updated sample_binary.lua to reflect the tutorial better

* removed windows-specific build step in Lua tests

6 years agoIssue #4799 fixed. Generator for KeyCompareWithValue is extracted. (#4802)
Vladimir Glavnyy [Thu, 5 Jul 2018 16:23:40 +0000 (23:23 +0700)]
Issue #4799 fixed. Generator for KeyCompareWithValue is extracted. (#4802)

* Issue #4799 fixed. Generator for KeyCompareWithValue is extracted.

* format fix

6 years agoDart: Add missing imports (#4803)
Woody Guo [Tue, 3 Jul 2018 15:44:27 +0000 (23:44 +0800)]
Dart: Add missing imports (#4803)

6 years agoHelper function to get empty string on nullptr (#4800)
shassani [Mon, 2 Jul 2018 16:34:18 +0000 (09:34 -0700)]
Helper function to get empty string on nullptr (#4800)

Adds helper function to get empty string when String is nullptr.

This is to get over the fact that flat buffer builders will record null when data
is not present.

6 years agoDart: Fix default values (#4795)
Woody Guo [Thu, 28 Jun 2018 17:12:18 +0000 (01:12 +0800)]
Dart: Fix default values (#4795)

6 years agoGo GRPC generator Updates - Fixes #4787 (#4797)
Kapil Sharma [Wed, 27 Jun 2018 16:57:40 +0000 (11:57 -0500)]
Go GRPC generator Updates - Fixes #4787 (#4797)

* Fix for #4787

- Updated the grpc generator for go to use full namespace for service
rpc method names

* Formatting Fix

- Set to Google Style Formatting

6 years agoAdd --force-defaults option to flatc [C++, parser] (#4729)
Paul Reimer [Wed, 27 Jun 2018 16:12:52 +0000 (09:12 -0700)]
Add --force-defaults option to flatc [C++, parser] (#4729)

* Add --force-defaults option to flatc

To emit default values for fields which are not present or which are set
to the default value.

* flatc option --force-defaults should have a default value (false) and take action on the builder_ within the Parser constructor

* Add help text from flatc --force-defaults to Compiler.md doc

* Clarified docs for flatc --force-defaults, and imply that this behaviour is not normally needed.

* Updated docs and flatc help text for --force-defaults option

6 years agoAdded setup.cfg to default to python 2/3 wheels for pypi.
Wouter van Oortmerssen [Mon, 25 Jun 2018 22:07:26 +0000 (15:07 -0700)]
Added setup.cfg to default to python 2/3 wheels for pypi.

Change-Id: I64cf42aca79c32d21cd15c1415125ba97665d134

6 years agodocs: fix flatc instructions (#4794)
Polynomdivision [Mon, 25 Jun 2018 21:55:18 +0000 (23:55 +0200)]
docs: fix flatc instructions (#4794)

6 years agoFixed documentation comments at the start of a file.
Wouter van Oortmerssen [Mon, 25 Jun 2018 21:02:12 +0000 (14:02 -0700)]
Fixed documentation comments at the start of a file.

Change-Id: Ic24018a6cd604c71b4d8d3cd35dc7a583fb18394

6 years agoFixed empty structs generating bad constructor.
Wouter van Oortmerssen [Mon, 25 Jun 2018 19:26:04 +0000 (12:26 -0700)]
Fixed empty structs generating bad constructor.

This was fixed previously here:
https://github.com/google/flatbuffers/commit/5fd0fefab644caa2bb395cda79fbee6103035818
but somehow got undone in intermediate refactors.

Change-Id: I86e45a3f96f67a2b3d84d44081403baef6798921

6 years agoComment update for ForceDefaults. (#4788)
Shivendra Agarwal [Thu, 21 Jun 2018 15:50:36 +0000 (21:20 +0530)]
Comment update for ForceDefaults. (#4788)

Current comment is a bit ambiguous. Default values can be read either if field is not written (like in table), or if they are written explicitly by client but not serialized due to optimization. Impression from current comment is that all the default values which are coming during read are from binaries when we turn-on Force-Defaults. However, that will be a wrong interpretation.

Force_Defaults = true ensures to turn OFF later optimization. In case a field is not written, during read we will get default values but they will still not be serialized.

6 years agoCreateUnitializedVectorOfStructs and tests (#4781)
Shivendra Agarwal [Mon, 18 Jun 2018 17:12:26 +0000 (22:42 +0530)]
CreateUnitializedVectorOfStructs and tests (#4781)

* CreateUnitializedVectorOfStructs and tests

* Incorporating review comments

* snake_case variable names

6 years agoProtected parser against infinite recursion.
Wouter van Oortmerssen [Thu, 14 Jun 2018 23:17:19 +0000 (16:17 -0700)]
Protected parser against infinite recursion.

Will error-out after e.g. 64 levels of nested JSON tables.

Change-Id: I3ab66cdd509378bfab87b85f85c07ab42aded788
Tested: on Linux.

6 years agoFixed ASan array out of bounds.
Wouter van Oortmerssen [Thu, 14 Jun 2018 22:13:01 +0000 (15:13 -0700)]
Fixed ASan array out of bounds.

Change-Id: I53366bd14548aa41c3d25bcd187d7436d47e8665
Tested: on Linux.

6 years agoFix misaligned nested buffers (#4785)
zejal [Thu, 14 Jun 2018 16:21:42 +0000 (18:21 +0200)]
Fix misaligned nested buffers (#4785)

6 years agoFixed TypeScript links in docs (#4783)
Kamil Rojewski [Tue, 12 Jun 2018 18:37:10 +0000 (20:37 +0200)]
Fixed TypeScript links in docs (#4783)

* Eclipse ignore

* TypeScript support

* Prefixing enums

* Test results

* Merged JS and TS generators

* Fixed AppVeyor build problems

* Fixed more AppVeyor build problems

* Fixed more AppVeyor build problems

* Changed TS flag to options struct

* Storing options by value

* Removed unneeded const

* Re-export support for unions

* Uint support

* Casting bools to numbers for mutation

* TS shell tests

* Reverted generates js test file to original version

* Backing up js tests and properly generating test data

* Not importing flatbuffers for TS test generation

* Not overwriting generated js for tests

* AppVeyor test fixes

* Generating the most strict TS code possible

* Not returning null when creating vectors

* Not returning null from struct contructors

* Vector of unions for ts/js

* Sanity check for languages

* Indentation fix + output test files

* Vectors of unions for php

* Fixes to union vector handling + tests

* Fix for strictPropertyInitialization

* Fix for new aligned operator new for gcc >= 7.1

* Not generating imports/ns prefixes with --gen-all

* TypeScript docs

* Missing imports of enums

* Missing TS links

* Enabled vector of unions for java, since it seems to work

* Added jitpack config

* Added obj to vector of unions getter

* Removed unneeded accessor

* Bumped jdk version in pom.xml

* Vector of unions support for c#

* Missing TypeScript doc processing

6 years agoDart: Generate the enum from 0 if value is null and fix inconsistent naming when...
Woody Guo [Tue, 12 Jun 2018 18:35:40 +0000 (02:35 +0800)]
Dart: Generate the enum from 0 if value is null and fix inconsistent naming when generating object builder (#4782)

* Dart: Generate the enum from 0 if value is null

* Dart: Fix inconsistent naming when generating object builder

6 years agoRe-enable clang / os x in .travis
Wouter van Oortmerssen [Fri, 8 Jun 2018 18:10:41 +0000 (11:10 -0700)]
Re-enable clang / os x in .travis

Change-Id: I45f6326f1b7da2d83eeee72fe44fd9626a288b5b

6 years agoRemoved biicode from repo.
Wouter van Oortmerssen [Fri, 8 Jun 2018 18:03:34 +0000 (11:03 -0700)]
Removed biicode from repo.

Change-Id: I8b517fb8eaf02772052d95ca55bdaa0efbffa65a

6 years agoAdded missing Dart generated files.
Wouter van Oortmerssen [Fri, 8 Jun 2018 17:59:46 +0000 (10:59 -0700)]
Added missing Dart generated files.

Change-Id: I27986e8aaf2f672145af9beae6ab659b272c9721

6 years agoPython: Escape enum member names if they correspond to a Python keyword (#4772)
Michael Seifert [Fri, 8 Jun 2018 17:55:19 +0000 (19:55 +0200)]
Python: Escape enum member names if they correspond to a Python keyword (#4772)

* Python: Generated enum member names are now escaped if they correspond to a Python keyword.

* Keyword list in Python generator is now a const char* instead of an std::string array.

* Moved static functions and keyword list of Python generator into the PythonGenerator class.

* Python generator escapes keyword identifiers in all definitions.

6 years agoPython: fix default bool value. (#4773)
Tin Tvrtković [Thu, 7 Jun 2018 19:02:35 +0000 (21:02 +0200)]
Python: fix default bool value. (#4773)

* Python: fix default bool value.

* Small style tweak.

6 years agoEnforcing CreateUninitializedVector is only used with scalars.
Wouter van Oortmerssen [Thu, 7 Jun 2018 15:48:15 +0000 (08:48 -0700)]
Enforcing CreateUninitializedVector is only used with scalars.

This function cannot work with any offset types (since offsets
must always point forward) so this avoid possible mistakes.

Change-Id: I1b3dfbefc8d40da630345b9b04f9aff4a990e8e5

6 years agoMakes VectorIterator compatible with STL iterators. (#4768)
Vladimir Glavnyy [Mon, 4 Jun 2018 19:02:08 +0000 (02:02 +0700)]
Makes VectorIterator compatible with STL iterators. (#4768)

6 years agoFix a small problem with add_subdirectory(${FLATBUFFERS_DIR}) from top level project...
Vladimir Glavnyy [Fri, 1 Jun 2018 15:22:17 +0000 (22:22 +0700)]
Fix a small problem with add_subdirectory(${FLATBUFFERS_DIR}) from top level project. (#4764)

6 years agorenamed flexbuffers::Type enum values TYPE_ -> FBT_ (#4761)
Christian Helmich [Thu, 31 May 2018 18:06:44 +0000 (03:06 +0900)]
renamed flexbuffers::Type enum values TYPE_ -> FBT_ (#4761)

reason: TYPE_BOOL is a macro defined in some iOS build configurations.

6 years agoFixed typo in Java/C# tutorial.
Wouter van Oortmerssen [Thu, 31 May 2018 16:53:47 +0000 (09:53 -0700)]
Fixed typo in Java/C# tutorial.

Change-Id: I956b27f37b11988e67d0403a596c0569eacbfc2a

6 years agoFixed ASAN false positive.
Wouter van Oortmerssen [Thu, 31 May 2018 16:48:34 +0000 (09:48 -0700)]
Fixed ASAN false positive.

Change-Id: I79d9b2cddc61df5919bc4a93627fba2aa69e5d49
Tested: on Linux.

6 years agoadds https to landing page link so it resolves (#4757)
Steve Barman [Thu, 31 May 2018 16:37:51 +0000 (12:37 -0400)]
adds https to landing page link so it resolves (#4757)

6 years agoFix typo in tutorial for Go (#4756)
Gautham B A [Thu, 31 May 2018 16:17:34 +0000 (21:47 +0530)]
Fix typo in tutorial for Go (#4756)

Fixed a typo in serialising the inventory for Orc.

6 years agoJavascript: Add suppport for ES6 style exports (#4754)
Nathan Mitchell [Thu, 31 May 2018 15:29:58 +0000 (08:29 -0700)]
Javascript: Add suppport for ES6 style exports (#4754)

* Add suppport for ES6 style exports

Adds support for ECMAScript 6 module exports during Javascript
generation. This is useful as many development projects are
switching to this new standard and away from custom module
solutions. By integrating support into flatbuffers, users
do not need to perform additional post-processing of generated
files in order to use flatbuffers output directly in their
codebases.

Reference to ECMAScript 6 modules:
https://www.ecma-international.org/ecma-262/6.0/#sec-exports

Changes:
* Added `--es6-js-export` option to cli parser tool
* Added conditional code to generate a ES6 style export
  line, replacing the normal NodeJS/RequireJS line.

* Fixed missing export statements

Added exports for definition and struct names that were not inside namespaces

* Updated Compiler.md with new generator option

Added entry to Compiler.md in docs for the `--es6-js-export` flag, including a brief description of the effects and usefulness.

6 years agoChanged how the default allocator is handled.
Wouter van Oortmerssen [Fri, 18 May 2018 18:54:39 +0000 (11:54 -0700)]
Changed how the default allocator is handled.

This is to not need static variables, which could trip up users
with destruction order problems.

This potentially makes these operations slightly slower, but I
think they're infrequent enough that this should not be noticable.

Also there is one breaking API change, for a method that is not
used by any code in FlatBuffers and is assumed to affect very
few if any users. A namechange and comment ensures that those
affected, if any, will not run into trouble silently.

Change-Id: I16c1352d1dfc9092c816ddb7e353ed7f5f417444
Tested: on Linux.

6 years agoFix of namespace problem described in #4747 (#4752)
Vitaly Bondar [Fri, 18 May 2018 19:21:08 +0000 (22:21 +0300)]
Fix of namespace problem described in #4747 (#4752)

6 years agoAdd [Dart] support (#4676)
Dan Field [Fri, 18 May 2018 18:06:15 +0000 (14:06 -0400)]
Add [Dart] support (#4676)

* Add [Dart] support

* fix enum vectors

* Allow for opt out of string interning

* fix comment style, make interning opt in

* remove Offset<T>, prefer int

* avoid creating unnecessary vtable objects

* start work on tests - do not generate builder if struct has 0 fields - add int64

* support reading structs properly

* correctly handle reading vectors of structs, dartfmt

* support structs, fix unnecessary prepares

* fix bool customizations

* undo unintentional removal of file

* docs updates, complete tutorial, bug fix for codegen

* more documentation

* Update docs, add to doxygen file

* update package structure, add samples script/code

* rearrange sample

* Tests

* Add readme for pub

* cleanup package for pub

* update docs for renamed file

* remove custom matcher, use `closeTo` instead

* remove unintentional file

* remove unintended file checkin

* use auto, move method, cleanup

* refactor to ObjectBuilders, add Builders

* Update tests, examples

* Add files missing from previous commit

* documentation and example updates

* Update LICENSE, make dartanalyzer happy, fix minor bugs, get rid of duplicate files, publish script

* fix sample for slightly different schema

* Update pubspec.yaml

6 years agoFix undertermined execution behavior (#4751)
joligarson [Fri, 18 May 2018 16:15:20 +0000 (18:15 +0200)]
Fix undertermined execution behavior (#4751)

Fix for the issue #4744: Ambiguous side-effect execution on vector_downward::make_space() method.
C++ does not impose evaluation order on the two expressions on the right side of the assignment, so compiler can freely decide. As ensure_space() method can change the value of "cur_" variable, the result of the subtraction may be different depending on the evaluation order, which is ambiguous in C++.
In order to make this code deterministic and correct, cur_ must be evaluated after ensure_space() is called.

6 years ago[BREAKING CHANGE] Python: handle bool table fields properly. (#4736)
Tin Tvrtković [Mon, 14 May 2018 20:30:10 +0000 (22:30 +0200)]
[BREAKING CHANGE] Python: handle bool table fields properly. (#4736)

* Python: handle bool table fields properly.

* Small refactor.

* Use snake_case instead of camelCase. Use auto.

6 years agoVector of unions support for java and c# (#4735)
Kamil Rojewski [Mon, 14 May 2018 18:12:24 +0000 (20:12 +0200)]
Vector of unions support for java and c# (#4735)

* Eclipse ignore

* TypeScript support

* Prefixing enums

* Test results

* Merged JS and TS generators

* Fixed AppVeyor build problems

* Fixed more AppVeyor build problems

* Fixed more AppVeyor build problems

* Changed TS flag to options struct

* Storing options by value

* Removed unneeded const

* Re-export support for unions

* Uint support

* Casting bools to numbers for mutation

* TS shell tests

* Reverted generates js test file to original version

* Backing up js tests and properly generating test data

* Not importing flatbuffers for TS test generation

* Not overwriting generated js for tests

* AppVeyor test fixes

* Generating the most strict TS code possible

* Not returning null when creating vectors

* Not returning null from struct contructors

* Vector of unions for ts/js

* Sanity check for languages

* Indentation fix + output test files

* Vectors of unions for php

* Fixes to union vector handling + tests

* Fix for strictPropertyInitialization

* Fix for new aligned operator new for gcc >= 7.1

* Not generating imports/ns prefixes with --gen-all

* TypeScript docs

* Missing imports of enums

* Missing TS links

* Enabled vector of unions for java, since it seems to work

* Added jitpack config

* Added obj to vector of unions getter

* Removed unneeded accessor

* Bumped jdk version in pom.xml

* Vector of unions support for c#

6 years agoSet Working Directory for flatc commands (#4737)
Keef Aragon [Mon, 14 May 2018 16:20:49 +0000 (09:20 -0700)]
Set Working Directory for flatc commands (#4737)

6 years agoAdd define/ifdef blocks, alternate sprintf implementation via FLATBUFFERS_PREFER_PRIN...
Paul Reimer [Thu, 10 May 2018 20:31:02 +0000 (13:31 -0700)]
Add define/ifdef blocks, alternate sprintf implementation via FLATBUFFERS_PREFER_PRINTF [C++] (#4700)

* Add define/ifdef blocks for FLATBUFFERS_PREFER_PRINTF to avoid using std::*streams for idl_parser

* Use string::size() as limit in snprintf

* Refactored FLATBUFFERS_PREFER_PRINTF guarded feature into NumToStringImplWrapper around sprintf

* Remove '.0' where not needed from IntToDigitCount

* Remove leading dot from name in GetFullyQualifiedName when FLATBUFFERS_PREFER_PRINTF is enabled

* Return string directly from conversion functions where possible when FLATBUFFERS_PREFER_PRINTF is enabled

* Use string instead of stringstream for GetFullyQualifiedName

* Revert removing leading dot from GetFullyQualifiedName, it does need to be there for parity with the stringstream implementation

* Dot is single char in Namespace::GetFullyQualifiedName

* Remove trailing (duplicate) null-byte from NumToStringImplWrapper when using FLATBUFFERS_PREFER_PRINTF.

* Update preprocessor indenting (and use clang-format off/on) for FLATBUFFERS_PREFER_PRINTF

* Reduce whitespace, unneeded braces in FLATBUFFERS_PREFER_PRINTF string width functions

* Remove unneeded use of iostream from idl_parser.cpp, std::string is used instead

* Tell snprintf to use the trailing null byte expected at the end of std::string buffer

6 years agoAdd string view [C++] (#4730)
Paul Reimer [Thu, 10 May 2018 20:30:35 +0000 (13:30 -0700)]
Add string view [C++] (#4730)

* Add view() method on flatbuffers::String, to return a string_view type
if support for std::string_view (or alternately
std::experimental::string_view) is found

* Move detection/definition of FLATBUFFERS_STRING_VIEW to base.h, use the
macro (if it is defined) as the argument type for an overload of CreateString

* Rename String::view() to String::string_view() and use the existing c_str() method for the data pointer

* Add and explain minimum C++ standard version checks for FLATBUFFERS_STRING_VIEW implementations

* Updated preprocessor indenting for FLATBUFFERS_STRING_VIEW

* Convert FLATBUFFERS_STRING_VIEW macro to typedef in flatbuffers:: namespace, and boolean feature toggle macro FLATBUFFERS_HAS_STRING_VIEW

* Prepend flatbuffers:: namespace to disambiguate flatbuffers::string_view typedef from String::string_view()

* clang-format as-she-is-spoke for FLATBUFFERS_HAS_STRING_VIEW

6 years agoPython: return None for missing strings. (#4733)
Tin Tvrtković [Thu, 10 May 2018 17:34:20 +0000 (19:34 +0200)]
Python: return None for missing strings. (#4733)

[BREAKING CHANGE] Python: return None for missing strings.

6 years agoRemove @Nullable (Java) for required fields (fixes #4724) (#4726)
Mike Mansell [Thu, 10 May 2018 16:27:23 +0000 (09:27 -0700)]
Remove @Nullable (Java) for required fields (fixes #4724) (#4726)

@Nullable is only a compiler informational attribute.
Removing for required fields improves compiler warnings
but doesn't impact any running code.

6 years agoAdd --root-type option to flatc [C++, parser, JSON] (#4728)
Paul Reimer [Mon, 7 May 2018 23:07:52 +0000 (16:07 -0700)]
Add --root-type option to flatc [C++, parser, JSON] (#4728)

* Add --root-type option to flatc

To select or override a root_type

* Add help text from flatc --root-type to Compiler.md doc

6 years agoSeveral pom.xml files did not have their version bumped to 1.9.0
Wouter van Oortmerssen [Mon, 7 May 2018 15:46:34 +0000 (08:46 -0700)]
Several pom.xml files did not have their version bumped to 1.9.0

Change-Id: I7c9bb5406ae8df951afe12a008f0d071e0195bfa

6 years agoOutput JSON strings as natural UTF-8 text without escapes (#4710)
Vladimir Glavnyy [Thu, 3 May 2018 19:10:45 +0000 (02:10 +0700)]
Output JSON strings as natural UTF-8 text without escapes (#4710)

* Added support for the non-escaped print of utf-8 string.

* EscapeString: the first invalid symbol resets print_natural_utf8 flag to false.

* Move the test to ParseAndGenerateTextTest. Fixes.

* Removed dependence between `natural_utf8` and `allow_non_utf8` flags.

6 years agoFix union escaping order. (#4722)
iceboy [Thu, 3 May 2018 18:59:30 +0000 (11:59 -0700)]
Fix union escaping order. (#4722)

* Fix union escaping order.

Fixes #4712

* style

6 years agoDelete ByteBuffer.exe (#4721)
iceboy [Thu, 3 May 2018 18:58:29 +0000 (11:58 -0700)]
Delete ByteBuffer.exe (#4721)