platform/upstream/flatbuffers.git
7 years agoFixed the Android build.
Wouter van Oortmerssen [Wed, 8 Feb 2017 22:57:31 +0000 (14:57 -0800)]
Fixed the Android build.

Change-Id: Iabb9448b4f161bba465d455c28bb826529649d30
Tested: on Android.

7 years agoFirst attempt at SchemaLess FlatBuffers.
Wouter van Oortmerssen [Tue, 2 Feb 2016 02:00:30 +0000 (18:00 -0800)]
First attempt at SchemaLess FlatBuffers.

Change-Id: I86b9d002f3441ef9efdb70e059b8530ab2d74bb8
Tested: on Linux.

7 years agoAdded PULL_REQUEST_TEMPLATE.md
Wouter van Oortmerssen [Wed, 8 Feb 2017 18:15:26 +0000 (10:15 -0800)]
Added PULL_REQUEST_TEMPLATE.md

Change-Id: Iad9c09434f87219e384b294d6221f4cac7a839eb

7 years agoJSON parser wasn't handling ulong values correctly.
Wouter van Oortmerssen [Tue, 31 Jan 2017 01:07:55 +0000 (17:07 -0800)]
JSON parser wasn't handling ulong values correctly.

It passed all scalar ints thru a int64_t, which would truncate
uint64_t values with the upper bit set.

Change-Id: I38fb8c68c911ae44d9863f8e35c2429ca0ab51e5
Tested: on Linux.

7 years agoAdd utility method to build a vector of struct in-place. (#4153)
Benjamin Lerman [Wed, 1 Feb 2017 17:22:56 +0000 (18:22 +0100)]
Add utility method to build a vector of struct in-place. (#4153)

Change-Id: I6df195cbae621cf2bf6b4f3b56f68be80dc23152

7 years agoRemove max_message_size arg, which is not passed to Deserialize func.
Wouter van Oortmerssen [Mon, 30 Jan 2017 22:54:51 +0000 (14:54 -0800)]
Remove max_message_size arg, which is not passed to Deserialize func.

Change-Id: Icc7b4c1cf626f49d0529ff4f66503ea8381bf67c

7 years agoA bug fix to the union vector feature in FlatBuffers.
Wouter van Oortmerssen [Mon, 30 Jan 2017 22:02:40 +0000 (14:02 -0800)]
A bug fix to the union vector feature in FlatBuffers.

Change-Id: I302245969f6ec2443572799732fce2aa7c071879

7 years agoMerge branch 'master' of https://github.com/google/flatbuffers
Wouter van Oortmerssen [Fri, 27 Jan 2017 23:30:27 +0000 (15:30 -0800)]
Merge branch 'master' of https://github.com/google/flatbuffers

7 years agoAdded tracking of order of types declared.
Wouter van Oortmerssen [Fri, 27 Jan 2017 23:28:57 +0000 (15:28 -0800)]
Added tracking of order of types declared.

Change-Id: Iade313c99f119dcf1619674260648a33f61dc030

7 years agoSome small speed optimizations to the core copying functions.
Wouter van Oortmerssen [Fri, 27 Jan 2017 19:26:35 +0000 (11:26 -0800)]
Some small speed optimizations to the core copying functions.

Change-Id: Id8c1afb84f4ab0e2edca4290e3de5589fa06e578
Tested: on Linux.

7 years agoMerge pull request #4146 from zchee/go-test-fix_struct
Robert [Fri, 27 Jan 2017 04:45:49 +0000 (20:45 -0800)]
Merge pull request #4146 from zchee/go-test-fix_struct

go: fix unknown field 'UOffset' to 'Pos'

7 years agoFix unused variable build warning on Mac.
Wouter van Oortmerssen [Wed, 25 Jan 2017 22:39:14 +0000 (14:39 -0800)]
Fix unused variable build warning on Mac.

Change-Id: I330187be6a96bfd388c2776f676d47a9145d5e4a

7 years agoMoved union vector test to file dependent section.
Wouter van Oortmerssen [Wed, 25 Jan 2017 22:09:18 +0000 (14:09 -0800)]
Moved union vector test to file dependent section.

Change-Id: I3a1fcf167eb0d0a51ef838e54246ef867e752218

7 years agoAllow the flatbuffer compiler (flatc) to be built as a library.
Wouter van Oortmerssen [Wed, 25 Jan 2017 21:41:34 +0000 (13:41 -0800)]
Allow the flatbuffer compiler (flatc) to be built as a library.

Change-Id: I71baff427243f96be1596b01ff3405fdf39386d7

7 years agominor fixes to the union vector code styles (#4149)
gbeili [Wed, 25 Jan 2017 17:34:37 +0000 (09:34 -0800)]
minor fixes to the union vector code styles (#4149)

7 years agoMerge pull request #4148 from gbeili/vector_unions
jsanmiya [Tue, 24 Jan 2017 22:33:32 +0000 (14:33 -0800)]
Merge pull request #4148 from gbeili/vector_unions

C++ Union Vector

7 years agoUnion Vector
Bei Li [Tue, 24 Jan 2017 19:52:36 +0000 (11:52 -0800)]
Union Vector

7 years agoReword comment so that code editors can mark deprecation correctly (#4147)
Florin Pățan [Mon, 23 Jan 2017 21:40:50 +0000 (21:40 +0000)]
Reword comment so that code editors can mark deprecation correctly (#4147)

7 years agogo: fix unknown field 'UOffset' to 'Pos'
Koichi Shiraishi [Sun, 22 Jan 2017 11:16:52 +0000 (20:16 +0900)]
go: fix unknown field 'UOffset' to 'Pos'

Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
7 years agoMore native code gen functionality.
Wouter van Oortmerssen [Thu, 19 Jan 2017 00:23:35 +0000 (16:23 -0800)]
More native code gen functionality.

Allow tables to be mapped to native types directly.  For example, a table
representing a vector3 (eg. table Vec3 { x:float; y:float; z:float; }) can
be mapped to a "mathfu::vec3" native type in NativeTables.  This requires
users to provide Pack and UnPack functions that convert between the
Table and native types.  This is done by adding the "native_type" attribute
to the table definition.

To support user-defined flatbuffers::Pack and flatbuffers::UnPack functions,
support a "native_include" markup that will generate a corresponding

Also add an UnPackTo function which allows users to pass in a pointer to
a NativeTable object into which to UnPack the Table.  The existing UnPack
function is now simply:

  NativeTable* UnPack() {
    NativeTable* obj = new NativeTable();
    Table::UnPackTo(obj);
    return obj;
  }

Finally, allow native types to be given a default value as well which are
set in the NativeTable constructor.  This is done by providing a
"native_default" attribute to the member of a table.

Change-Id: Ic45cb48b0e6d7cfa5734b24819e54aa96d847cfd

7 years agoAdd no-op for padding variables to prevent clang compiler warning.
Wouter van Oortmerssen [Thu, 19 Jan 2017 00:16:17 +0000 (16:16 -0800)]
Add no-op for padding variables to prevent clang compiler warning.

Change-Id: I119ee7109bfa2b0be0f468d2b2be459f45d1bb11

7 years agoFix compiler warning on Visual Studio.
Wouter van Oortmerssen [Thu, 19 Jan 2017 00:09:35 +0000 (16:09 -0800)]
Fix compiler warning on Visual Studio.

Change-Id: Ifda5f2c32c6484508d5e12a463d6373798f1f523

7 years agoMerge branch 'master' of https://github.com/google/flatbuffers
Wouter van Oortmerssen [Wed, 18 Jan 2017 22:58:09 +0000 (14:58 -0800)]
Merge branch 'master' of https://github.com/google/flatbuffers

7 years agoFixed unions not being parsed correctly in JSON.
Wouter van Oortmerssen [Wed, 18 Jan 2017 20:02:31 +0000 (12:02 -0800)]
Fixed unions not being parsed correctly in JSON.

This would happen if they were supplied in an order that does not match
the schema relative to other fields. It now supports any ordering.

Change-Id: I9d309cd4e6e5c470f01d9d431806eba4f9f46559
Tested: on Linux.

7 years agoGenEnum: bit_flags: Remove useless conditions (#4141)
Georges Savoundararadj [Wed, 18 Jan 2017 17:59:13 +0000 (09:59 -0800)]
GenEnum: bit_flags: Remove useless conditions (#4141)

The conditions to add the "NONE" or "ANY" value in the enum were useless
because the user cannot provide a zero value or a bitmask (for "ANY") in
the bit_flags enum type.

7 years agoFix unused field warning in clang.
Wouter van Oortmerssen [Sat, 14 Jan 2017 02:30:57 +0000 (18:30 -0800)]
Fix unused field warning in clang.

Change-Id: I71d590a1e5b2709f0e2dcf97faaebda5cb918fc7
Tested: on Linux.

7 years agoAdd CodeWriter utility class.
Wouter van Oortmerssen [Sat, 14 Jan 2017 01:44:42 +0000 (17:44 -0800)]
Add CodeWriter utility class.

Helps simplify code generation code.  Instead of this:
  code += "inline const " + cpp_qualified_name + " *Get";
  code += name;
  code += "(const void *buf) {\n  return flatbuffers::GetRoot<";
  code += cpp_qualified_name + ">(buf);\n}\n\n";

You do this:
  code.SetValue("NAME", struct_def.name);
  code.SetValue("CPP_NAME", cpp_qualified_name);
  code += "inline const {{CPP_NAME}} *Get{{NAME}}(const void *buf) {";
  code += "  return flatbuffers::GetRoot<{{CPP_NAME}}>(buf);";
  code += "}";
  code += "";

Updated the CPP code generator to use the CodeWriter class.  Most of the
changes in the generated code are white-space changes, esp. around new
lines (since the code generator class automatically appends new lines
when appending a string).  Actual code changes include:

* Renamed "rehasher" to "_rehasher" for consistency with other args in
  Pack function.

* Renamed "union_obj" to "obj: in UnPack function.

* Always do "(void)_o;" to prevent unused variable warning in Create
  function (instead of only doing it if there are no fields) in order
  to avoid two-passes.

* Renamed padding variables from __paddingX to paddingX__.
  "Each name that contains a double underscore (_ _) [...] is reserved
   to the implementation for any use."  C++ standards 17.4.3.1.2.

* Add braces around switch cases.

* Calculate index as a separate statement in EnumName function, eg.
    const size_t index = ...;
    return EnumNamesX()[index];
  vs.
    return EnumNamesX()[...];

* Stored end table offset in variable in Finish() functions, eg.
    const auto end = fbb_.EndTable(start_, ...);
    auto o = flatbuffers::Offset<T>(end);
  vs.
    auto o = flatbuffers::Offset<T>(fbb_.EndTable(start, ...));

* Separate reinterpret_cast calls from function calls in Union
  functions, eg.
    auto ptr = reinterpret_cast<const T *>(obj);
    return ptr->UnPack(resolver);
  vs.
    return reinterpret_cast<const T *>(obj)->UnPack(resolver);

* Removed unecessary (void)(padding__X) no-ops from constructors, eg.
    Test(int16_t a, int8_t b) : ... {
      (void)__padding0;  // <-- Removed this line.
    }

In the idl_gen_cpp.cpp file itself, I refactored some code generation into
new functions: GenParam, GenNativeTable, GenVerifyCall, GenBuilders,
GenUnpackFieldStatement, and GenCreateParam.

Change-Id: I727b1bd8719d05b7ce33cbce00eb58fda817b25d

7 years agoAdd a builder option to enable/disable vtables deduplication. (#4132)
gbeili [Wed, 11 Jan 2017 18:36:18 +0000 (10:36 -0800)]
Add a builder option to enable/disable vtables deduplication. (#4132)

* Add a builder option to enable/disable vtables deduplication.

* address code review comments

7 years agoResolve Go fmt and vet warnings (#4134)
Pascal S. de Kloe [Tue, 10 Jan 2017 01:13:44 +0000 (02:13 +0100)]
Resolve Go fmt and vet warnings (#4134)

* Resolve Go fmt and vet warnings.

* Undo generated code gofmt.

7 years agoMerge branch 'master' of https://github.com/google/flatbuffers
Wouter van Oortmerssen [Mon, 9 Jan 2017 23:55:18 +0000 (15:55 -0800)]
Merge branch 'master' of https://github.com/google/flatbuffers

7 years agoFixed GRPC method name generation.
Wouter van Oortmerssen [Mon, 9 Jan 2017 23:54:31 +0000 (15:54 -0800)]
Fixed GRPC method name generation.

Change-Id: I827b7e9aee1edb77752322455f7b6fafac16fb1d
Tested: on Linux.

7 years agoCold part of make_space() code moved to reallocate member function. (#4130)
Mateusz Pusz [Mon, 9 Jan 2017 18:10:11 +0000 (19:10 +0100)]
Cold part of make_space() code moved to reallocate member function. (#4130)

Change makes make_space() code much friendlier for the compiler to inline which makes significant (measurable) performance improvements.

7 years agoRe-applied reverted fix, adding missing codegen files.
Wouter van Oortmerssen [Wed, 4 Jan 2017 18:41:31 +0000 (10:41 -0800)]
Re-applied reverted fix, adding missing codegen files.

Change-Id: I301d29835fb0baffd859950eb0fb3056e4f4d66b

7 years agoMisc idl_gen_cpp cleanup
Wouter van Oortmerssen [Wed, 4 Jan 2017 18:12:39 +0000 (10:12 -0800)]
Misc idl_gen_cpp cleanup

- Update to be const-correct where possible.
- Consistently pass |code| as pointer instead of non-const-ref.
- No newlines (\n) characters in the middle of code strings.
- Use if-else if-else statements instead of nested ternary operators.
- Ensure all lines end at 80 chars.
- Make utility functions static.

From cl/143505731.

Change-Id: If0fab9ee75de5af963367a948dddf53af93f73b4

7 years agoUpdated version to 1.5 v1.5.0
Wouter van Oortmerssen [Tue, 3 Jan 2017 22:56:44 +0000 (14:56 -0800)]
Updated version to 1.5

Change-Id: I34007829cdd3ad024df21f68bb369016d5d21131

7 years agofix memory leak (#4126)
Yonggang Li [Tue, 3 Jan 2017 21:54:15 +0000 (13:54 -0800)]
fix memory leak (#4126)

7 years agoFix C++ gRPC test with streaming method (#4123)
CarsarSky [Wed, 28 Dec 2016 19:50:41 +0000 (03:50 +0800)]
Fix C++ gRPC test with streaming method (#4123)

7 years agoMerge branch 'master' of https://github.com/google/flatbuffers
Wouter van Oortmerssen [Thu, 22 Dec 2016 02:06:10 +0000 (18:06 -0800)]
Merge branch 'master' of https://github.com/google/flatbuffers

7 years agoFixed empty structs generating illegal constructor in C++.
Wouter van Oortmerssen [Thu, 22 Dec 2016 02:04:31 +0000 (18:04 -0800)]
Fixed empty structs generating illegal constructor in C++.

Change-Id: I60418d597b497c3cfa655ad76b3128351e9139f2

7 years agoFix call to Verifier::VerifyBuffer from BufferRef (#4124)
Ankur Dave [Thu, 22 Dec 2016 01:49:45 +0000 (17:49 -0800)]
Fix call to Verifier::VerifyBuffer from BufferRef (#4124)

3a1f776132cf9377e3a85a888e6ff2bc12c7248c added a required identifier parameter
to Verifier::VerifyBuffer but did not update the templated call site in
BufferRef. This causes errors like the following when trying to instantiate the
call site by calling BufferRef::Verify():

    include/flatbuffers/flatbuffers.h: In instantiation of ‘bool flatbuffers::BufferRef<T>::Verify() [with T = MyType]’:
    MyApp.cpp:16:3:   required from here
    include/flatbuffers/flatbuffers.h:1421:37: error: no matching function for call to ‘flatbuffers::Verifier::VerifyBuffer()’
         return verifier.VerifyBuffer<T>();
                                         ^
    include/flatbuffers/flatbuffers.h:1421:37: note: candidate is:
    include/flatbuffers/flatbuffers.h:1352:29: note: template<class T> bool flatbuffers::Verifier::VerifyBuffer(const char*)
       template<typename T> bool VerifyBuffer(const char *identifier) {
                                 ^
    include/flatbuffers/flatbuffers.h:1352:29: note:   template argument deduction/substitution failed:
    include/flatbuffers/flatbuffers.h:1421:37: note:   candidate expects 1 argument, 0 provided
         return verifier.VerifyBuffer<T>();
                                         ^

This commit fixes the BufferRef call site by adding a nullptr argument.

7 years agoAdded helper methods to access struct through reflection. (#4120)
Zarian Waheed [Thu, 22 Dec 2016 01:48:21 +0000 (17:48 -0800)]
Added helper methods to access struct through reflection. (#4120)

* Added helper methods to access struct through reflection. Also added unit test for it.

* Added a TODO comment to check for the is_struct flag.

7 years agoFixed more Windows build errors.
Wouter van Oortmerssen [Thu, 22 Dec 2016 01:45:27 +0000 (17:45 -0800)]
Fixed more Windows build errors.

Change-Id: I556e1c103e8501dc144b16c8698463253de6f4fb

7 years agoFixed Windows compiler warning.
Wouter van Oortmerssen [Thu, 22 Dec 2016 00:16:52 +0000 (16:16 -0800)]
Fixed Windows compiler warning.

Change-Id: I12b31227d4545a8897f638754d6a9ccd029f177e

7 years agoGo related style fixes.
wvo [Wed, 21 Dec 2016 21:57:10 +0000 (21:57 +0000)]
Go related style fixes.

Change-Id: Ie854ace69a21ef685e1ade5584f9d9ce4e8b41f1

7 years agoFixed Windows build errors.
Wouter van Oortmerssen [Tue, 20 Dec 2016 01:04:35 +0000 (17:04 -0800)]
Fixed Windows build errors.

Change-Id: I11548bfa3cfe307598eb59c56412974c349d614d

7 years agoAdded missing generated code from previous commits.
Wouter van Oortmerssen [Tue, 20 Dec 2016 00:28:06 +0000 (16:28 -0800)]
Added missing generated code from previous commits.

Change-Id: Id7053e4cb5a085a4b047c86ff1f2269329ff7f54

7 years agoMerge branch 'master' of https://github.com/google/flatbuffers
Wouter van Oortmerssen [Tue, 20 Dec 2016 00:26:57 +0000 (16:26 -0800)]
Merge branch 'master' of https://github.com/google/flatbuffers

7 years agoMerge "Documentation improvements: style guide & guide lines." into ub-games-master
Wouter van Oortmerssen [Tue, 20 Dec 2016 00:25:31 +0000 (00:25 +0000)]
Merge "Documentation improvements: style guide & guide lines." into ub-games-master

7 years agoDocumentation improvements: style guide & guide lines.
Wouter van Oortmerssen [Fri, 16 Dec 2016 23:59:05 +0000 (15:59 -0800)]
Documentation improvements: style guide & guide lines.

Bug: 22346508
Change-Id: I3f6e6b2811adaaf9d79faca8cdd00af3927299b5

7 years agoAdd default values (if they exist) to native tables.
Wouter van Oortmerssen [Mon, 19 Dec 2016 23:21:41 +0000 (15:21 -0800)]
Add default values (if they exist) to native tables.

From cl/142307012.

Change-Id: I54d550573f6506b92ad18e7cc90bcd8589259e52

7 years agoAdd ::Set function to Unions to make memory ownership clear.
Wouter van Oortmerssen [Mon, 19 Dec 2016 23:21:08 +0000 (15:21 -0800)]
Add ::Set function to Unions to make memory ownership clear.

Unions own the NativeTable* value member because they need to destroy them
when the Union goes out of scope.  Currently, the data is destroyed by calling
delete, which means that the member needs to be allocated with new.  However,
making the allocation the responsibility of the client and the destruction
the responsibility of the Union can lead to potential errors.  Adding a
Set function will ensure that the memory is allocated correctly so that it
can be deleted later.

From cl/142161569.

Change-Id: I4605f26d2749164819bfae0140e5fae08442b50a

7 years agoChanges for verifying a buffer dynamically using reflection. (#4102)
Zarian Waheed [Fri, 16 Dec 2016 16:46:30 +0000 (08:46 -0800)]
Changes for verifying a buffer dynamically using reflection. (#4102)

* Changes for verifying a buffer dynamically using reflection.

* Fixing build issues on linux and applied code reformatting.

* Fixing the file order in cmake file that was messing up the macro based code inclusion.

Added tests for reflection based verification.

* Changes for verifying a buffer dynamically using reflection.

Fixing build issues on linux and applied code reformatting.

Fixing the file order in cmake file that was messing up the macro based code inclusion.

Added tests for reflection based verification.

* Incorporated the code review changes that were requested:

1. Changed the Verify function signature.
2. Changed the variable names to use snake_case.
3. Added better comments.
4. Refactored duplicate code.
5. Changed the verifier class so that it has the same size when compiled with or without FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE macro.

* Setting FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE and FLATBUFFERS_DEBUG_VERIFICATION_FAILURE through cmake for flattests so that it gets propagted to all translation units of flattests.

* Making the Verifier struct fields the same in all cases. Also reverting the target_compile_definitions change in cmake file because build machine on travis does not have cmake version 3.0 or higher which was the version when target_compile_definitions was added in cmake.

* Defining macros through cmake in a portable way using functions that are available in cmake 2.8.

7 years agorandom access iterator for vector added (#4119)
krupnov [Fri, 16 Dec 2016 16:37:04 +0000 (20:37 +0400)]
random access iterator for vector added (#4119)

* random access iterator for vector added

* Style changes

7 years agoFixed JS outputting helper for Int64Array.
Wouter van Oortmerssen [Wed, 14 Dec 2016 18:35:26 +0000 (10:35 -0800)]
Fixed JS outputting helper for Int64Array.

Change-Id: I7d23fa3416feb78ea18d2c451e7b4e1d9be11bfc

7 years agoMade GRPC generator missing into a warning.
Wouter van Oortmerssen [Wed, 14 Dec 2016 18:32:44 +0000 (10:32 -0800)]
Made GRPC generator missing into a warning.

Change-Id: Iceb1f5b78cff6227905b8a23eb70e9ef6ce909ed

7 years agoImproving AppVeyor CI with other languages.
Wouter van Oortmerssen [Mon, 12 Dec 2016 23:43:49 +0000 (15:43 -0800)]
Improving AppVeyor CI with other languages.

Change-Id: Iff630905b5f90814c5f728e3c0e10f7fcd67c7fe

7 years agoadd weapon + equipment to json example (#4114)
Ricardo Quesada [Mon, 12 Dec 2016 22:12:56 +0000 (14:12 -0800)]
add weapon + equipment to json example (#4114)

update json with documentation

removed comments

7 years agoMerge pull request #4112 from manolama/tweaks
Robert [Fri, 9 Dec 2016 22:29:57 +0000 (14:29 -0800)]
Merge pull request #4112 from manolama/tweaks

Restore the ''import "unsafe'' removed in 36daedf35fd0cc2ad0e5e24d187

7 years agoRestore the ''import "unsafe'' removed in 36daedf35fd0cc2ad0e5e24d187b25613c13660e.
Manolama [Fri, 9 Dec 2016 06:15:20 +0000 (22:15 -0800)]
Restore the ''import "unsafe'' removed in 36daedf35fd0cc2ad0e5e24d187b25613c13660e.
This was causing build failures with tools dependent on Flatbuffers in Go.
E.g.
go/src/github.com/google/flatbuffers/go/sizes.go:50: undefined: unsafe in unsafe.Pointer

7 years agoCreate basic issue template (#4107)
Robert [Wed, 7 Dec 2016 22:17:30 +0000 (14:17 -0800)]
Create basic issue template (#4107)

* Create basic issue template

* Update ISSUE_TEMPLATE.md

7 years agoMerge pull request #3791 from mmastrac/master
Robert [Wed, 7 Dec 2016 19:51:11 +0000 (11:51 -0800)]
Merge pull request #3791 from mmastrac/master

Avoid unsafe when sizing types

7 years agoMerge pull request #3977 from gonzaloserrano/feature/go-generic-deserialitzation
Robert [Wed, 7 Dec 2016 19:17:55 +0000 (11:17 -0800)]
Merge pull request #3977 from gonzaloserrano/feature/go-generic-deserialitzation

Add a generic way to deserialize a flatbuffer in Go.

7 years agoSupport for Golang GRPC (Experimental) (#4082)
Ronak Jain [Mon, 5 Dec 2016 21:20:38 +0000 (02:50 +0530)]
Support for Golang GRPC (Experimental) (#4082)

* support for grpc golang

* refactored grpc go generator

* added grpc-go test and refactored

* refactored idl_gen_grpc.cpp

* fixed grpc generate method name

* refactored flatc and fixed line length issue

* added codec to go lib and fixed formatting issues

* fixed spacing issues

7 years agoAdds typedefs and functions to help write generic code.
Wouter van Oortmerssen [Fri, 2 Dec 2016 22:25:39 +0000 (14:25 -0800)]
Adds typedefs and functions to help write generic code.

The following changes have been made to the C++ codegen to enable writing generic code
that uses the Table and NativeTable types.

- Adds TableType and NativeTableType typedefs to NativeTable and Table structs.
- Adds GetFullyQualifiedName() to NativeTables if --gen-name-strings is set.
- Adds a static Pack function to Tables that simply calls the global CreateX functions.

See cr/140391505 as an example of improved usage.

From cl/140529288.

Change-Id: Idec137c16129e15c1783f94fabdcea24aeeaaef6

7 years agoAllows structs to be stored directly as member variables.
Wouter van Oortmerssen [Fri, 2 Dec 2016 22:25:08 +0000 (14:25 -0800)]
Allows structs to be stored directly as member variables.

Introduce a "native_inline" attribute that can be applied on fields that are structs.
This results in NativeTable code generation that sets the struct "inline" rather than
storing it in a pointer.

From cl/140527470.

Change-Id: I208724f552b8b921b20923e0bf82f42cb3582416

7 years agoMerge branch 'master' of https://github.com/google/flatbuffers
Wouter van Oortmerssen [Mon, 21 Nov 2016 23:20:33 +0000 (15:20 -0800)]
Merge branch 'master' of https://github.com/google/flatbuffers

Change-Id: I02b00b22cdd2d1bd32de3273ff69185c9b0f4e5b

7 years agoAdd Gitter badge (#4075)
The Gitter Badger [Wed, 2 Nov 2016 21:05:31 +0000 (16:05 -0500)]
Add Gitter badge (#4075)

7 years agoFixed javascript helper for typed arrays of scalars not taking into (#4068)
benssson [Wed, 26 Oct 2016 17:29:36 +0000 (18:29 +0100)]
Fixed javascript helper for typed arrays of scalars not taking into (#4068)

account underlying buffer's byte offset.

7 years ago[PHP] Use mb_detect_encoding when available (#3952)
Antoine Descamps [Wed, 16 Nov 2016 17:54:57 +0000 (18:54 +0100)]
[PHP] Use mb_detect_encoding when available (#3952)

I've faced an issue where I want to serialize UTF-8 emojis and FlatBufferBuilder::is_utf8 would return false on them.
I was not able to add the corresponding hexadecimal code because I don't understand how the whole thing works but what i've done is using the `mb_detect_encoding` function which handles correctly all supposed UTF-8 characters.

7 years agoMaking flatbuffers JSON parsing deal with unexpected null values when unknown JSON...
garretmcgraw [Wed, 9 Nov 2016 22:38:48 +0000 (17:38 -0500)]
Making flatbuffers JSON parsing deal with unexpected null values when unknown JSON is allowed. (#4083)

7 years agochore(lint) (#4079)
Michael Paulson [Mon, 7 Nov 2016 18:27:26 +0000 (10:27 -0800)]
chore(lint) (#4079)

* chore(lint)

I accidentally let 2 pieces of lint in with my generated code.

* fix(generate-code): I did not generate all the required code for tests.

7 years agoMerge branch 'master' of https://github.com/google/flatbuffers
Wouter van Oortmerssen [Mon, 7 Nov 2016 18:09:42 +0000 (10:09 -0800)]
Merge branch 'master' of https://github.com/google/flatbuffers

7 years agoFixes to support GCC 4.4.7
Wouter van Oortmerssen [Mon, 7 Nov 2016 17:51:28 +0000 (09:51 -0800)]
Fixes to support GCC 4.4.7

Fixed generation of a trailing comma and removed unnecessary use of a lambda.

Change-Id: I9993f6eb83e2ebc36fc40295a2059c340c1fbe03
Tested: on Linux.

7 years agoAdd Gitter badge (#4075)
The Gitter Badger [Wed, 2 Nov 2016 21:05:31 +0000 (16:05 -0500)]
Add Gitter badge (#4075)

7 years agoFixed javascript helper for typed arrays of scalars not taking into (#4068)
benssson [Wed, 26 Oct 2016 17:29:36 +0000 (18:29 +0100)]
Fixed javascript helper for typed arrays of scalars not taking into (#4068)

account underlying buffer's byte offset.

7 years agoChange docs to not encourage use of 1 byte buffers.
Wouter van Oortmerssen [Mon, 24 Oct 2016 17:29:09 +0000 (10:29 -0700)]
Change docs to not encourage use of 1 byte buffers.

Change-Id: Ib0b1692044f35e374a0f7c0359c94319f4a25619

7 years agoFixed STLPort error for missing vector::data()
Wouter van Oortmerssen [Sat, 22 Oct 2016 00:35:41 +0000 (17:35 -0700)]
Fixed STLPort error for missing vector::data()

Change-Id: I06fb61edf018adf0f26a81de4596b4972226e466
Tested: on Android.
Bug: 30263829

7 years agoMerge branch 'master' of https://github.com/google/flatbuffers
Wouter van Oortmerssen [Fri, 21 Oct 2016 23:57:50 +0000 (16:57 -0700)]
Merge branch 'master' of https://github.com/google/flatbuffers

7 years agoMade nesting vs inline clearer in the docs.
Wouter van Oortmerssen [Fri, 21 Oct 2016 22:22:14 +0000 (15:22 -0700)]
Made nesting vs inline clearer in the docs.

Also fixed structs not being created inline in the tutorial,
which would actually have bad consequences if used.

Change-Id: Idce215c61a1b24a297cee76f625052bb2722e970

7 years agoFix Closure Compiler warnings (#4067)
cajun-rat [Fri, 21 Oct 2016 21:52:42 +0000 (23:52 +0200)]
Fix Closure Compiler warnings (#4067)

* Make parameter order in jsdocs match function

When the order doesn't match the Google Closure Javascript compiler generates
warnings

* Prefix optional parameters with opt_

The Closure Compiler emits warnings when this isn't the case

7 years agoJava: fix unsigned default value code generation and add 'L' suffix for long default...
Baptiste Lepilleur [Fri, 21 Oct 2016 21:27:15 +0000 (23:27 +0200)]
Java: fix unsigned default value code generation and add 'L' suffix for long default value (#4051)

* Java: emit "signed" equivalent of unsigned default value in generated code and add "L" suffix to long default value.

* Updated generated code

* Only convert ulong to "signed" equivalent. ubyte and ushort don't need specific handling as "user facing" type is int. uint need 'L' suffix as "user facing" type is long.

* Added missing cast to primitive type of default value which is in "user facing" type in builder.add<type>() calls.

* Do not cast default value to actual type in C#.

7 years agoAdded functionality to obtain a buffer pointer from a root.
Wouter van Oortmerssen [Tue, 18 Oct 2016 01:02:19 +0000 (18:02 -0700)]
Added functionality to obtain a buffer pointer from a root.

Change-Id: Ia63e41d0304e8668ea4ce09a4c31dd999eb96994
Tested: on Linux.
Bug: 32218623

7 years agoFixed lambda return value error on VS2010.
Wouter van Oortmerssen [Mon, 17 Oct 2016 22:04:12 +0000 (15:04 -0700)]
Fixed lambda return value error on VS2010.

Change-Id: I6d0e8469bfa5b4c8a3f1cb119e186f4cf62c76ae

7 years agoFixed unused variable warnings, and made sure they are on.
Wouter van Oortmerssen [Mon, 17 Oct 2016 20:06:11 +0000 (13:06 -0700)]
Fixed unused variable warnings, and made sure they are on.

Tested on Linux.

Change-Id: Ie18d6857f9ae8b1c3953a116203b4a8bb70a2ede

7 years agoFixed broken traits codegen for --scoped-enums.
Wouter van Oortmerssen [Mon, 17 Oct 2016 18:53:28 +0000 (11:53 -0700)]
Fixed broken traits codegen for --scoped-enums.

Change-Id: I5f538d12ea37d11d2e239ddde32eefcdd91e347b
Tested: on Linux.

7 years agoMerge branch 'master' of https://github.com/google/flatbuffers
Wouter van Oortmerssen [Mon, 17 Oct 2016 17:46:14 +0000 (10:46 -0700)]
Merge branch 'master' of https://github.com/google/flatbuffers

7 years agoAdd missing include (#4052)
Zhe Wang [Mon, 17 Oct 2016 16:57:46 +0000 (11:57 -0500)]
Add missing include (#4052)

7 years agoAllow other pointer types than unique_ptr for object API.
Wouter van Oortmerssen [Wed, 12 Oct 2016 23:46:03 +0000 (16:46 -0700)]
Allow other pointer types than unique_ptr for object API.

Change-Id: I945890ce667a2f5a6c0495e78fd5326ed33b9914
Tested: on Linux.
Bug: 30135763

7 years agoFixed inconsistent use of namespace directory prefixing.
Wouter van Oortmerssen [Wed, 12 Oct 2016 23:05:57 +0000 (16:05 -0700)]
Fixed inconsistent use of namespace directory prefixing.

Change-Id: I2cab7a1f68b8e643c1057e0a366572421a94ed41
Tested: on Linux.

7 years agoFix lambda compilation error in VS.
Wouter van Oortmerssen [Wed, 12 Oct 2016 21:51:02 +0000 (14:51 -0700)]
Fix lambda compilation error in VS.

Change-Id: I814008b6eeffec9bd4b8810e4b29db9ea6218bb8

7 years agoAdded missing generated code files.
Wouter van Oortmerssen [Wed, 12 Oct 2016 21:40:35 +0000 (14:40 -0700)]
Added missing generated code files.

Change-Id: Ifb977411b65f8721cf9db891d7a62798bd593c0c

7 years agoMerge branch 'master' of https://github.com/google/flatbuffers
Wouter van Oortmerssen [Wed, 12 Oct 2016 21:39:36 +0000 (14:39 -0700)]
Merge branch 'master' of https://github.com/google/flatbuffers

7 years agoClarified tutorial w.r.t reading/writing buffers.
Wouter van Oortmerssen [Tue, 11 Oct 2016 00:09:37 +0000 (17:09 -0700)]
Clarified tutorial w.r.t reading/writing buffers.

Bug: 30736848

Signed-off-by: Wouter van Oortmerssen <wvo@google.com>
7 years agoAdded support for size prefixed buffers.
Wouter van Oortmerssen [Mon, 10 Oct 2016 22:55:26 +0000 (15:55 -0700)]
Added support for size prefixed buffers.

These are useful for streaming FlatBuffers. The functionality
ensures proper alignment of the whole buffer.

Tested: on OS X.
Bug: 27123865

Change-Id: Ic7d75a618c1bb470ea44c4dcf202ff71f2b3f4f1
Signed-off-by: Wouter van Oortmerssen <wvo@google.com>
7 years agoFixed line numbers being off in multi-line comments.
Wouter van Oortmerssen [Sat, 8 Oct 2016 00:07:39 +0000 (17:07 -0700)]
Fixed line numbers being off in multi-line comments.

Change-Id: I4c27892c249527980d8f52a2cca801dace70289f

7 years agoExternal references for the object API thru a resolver function.
Wouter van Oortmerssen [Wed, 5 Oct 2016 23:59:15 +0000 (16:59 -0700)]
External references for the object API thru a resolver function.

This allows hashed string fields to be used for lookup of any
C++ objects, a pointer to which are then stored in the object
besides the original hash for easy access.

Change-Id: I2247a13c349b905f1c54660becde2c818ad23e97
Tested: on Linux.
Bug: 30204449

7 years agoflatc java generator: namespace_test2.fbs is missing namespace prefix for referToA2...
Baptiste Lepilleur [Fri, 7 Oct 2016 16:42:29 +0000 (18:42 +0200)]
flatc java generator: namespace_test2.fbs is missing namespace prefix for referToA2() return type (#4040)

* Fix flatc generating incorrect java/c# code for namespace_test2.fbs. In code for TableInC, method referToA2() returned type SecondTableInA instead of NamespaceA.SecondTableInA.

* Updated generated code.

* Fixed indendation.

7 years agoCMake now accepts external toolchain configuration (#4045)
Andrew Hundt [Wed, 5 Oct 2016 20:20:30 +0000 (16:20 -0400)]
CMake now accepts external toolchain configuration (#4045)

Resolves #4038
Related to https://github.com/ruslo/hunter/pull/529

7 years ago Generate type traits for unions to map a type to the corresponding u… (#4032)
jbrads [Mon, 3 Oct 2016 21:14:25 +0000 (22:14 +0100)]
 Generate type traits for unions to map a type to the corresponding u… (#4032)

*  Generate type traits for unions to map a type to the corresponding union enum value.

* Fixed break with union enum type traits when type is in a namespace.

* Fixed spacing and variable names in type traits generation to match style guidelines.

*  Fixed spacing in type traits generation to match style guidelines.

* Regenerated test schema header.

7 years agoMerge pull request #4025 from paszea/reflection_fqn
Wouter van Oortmerssen [Wed, 21 Sep 2016 18:06:34 +0000 (11:06 -0700)]
Merge pull request #4025 from paszea/reflection_fqn

serialize fully qualified struct & enum name in schema binary