Commit Graph

583 Commits

Author SHA1 Message Date
Wouter van Oortmerssen 8468ea1ab4 Fixed LookupByKey for Java & C#
Change-Id: I05c02223675dee241d1ae8cb466e5186444058c8
Tested: on Linux.
2017-05-10 12:55:27 -07:00
Kamil Rojewski 86777bd66b Generating the most strict TS code possible (#4286)
* 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
2017-05-01 16:05:53 -07:00
Wouter van Oortmerssen 8b92122f33 Made the verifier catch zero-offsets.
Zero offsets are non-sensical in FlatBuffers (since offsets are
relative to themselves) but were allowed by the verifier. This could
cause buffers made up of all zeroes to be interpreted as correct
buffers with an empty root object.

Generally, not allowing such offsets will make the verifier more
likely to catch problems earlier.

Change-Id: I54010bea29721b326ff8e5348fcd9fe78e5e7506
Tested: on Linux.
2017-04-26 14:26:18 -07:00
Kamil Rojewski 808b44f87a TS tests fixes (#4265)
* 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
2017-04-21 09:29:42 -07:00
Wouter van Oortmerssen 523f3833eb VS fix for ambiguous union assignment operator.
Change-Id: I1c37db1ced462fd558d3e893a501341f3eca6379
2017-04-17 18:00:41 -07:00
Wouter van Oortmerssen e093f72d00 Improved union copy constructor.
It now at least works in simple cases.

Change-Id: I3af0738e676e62166b69accaa6bd19f531fbe5ee
Tested: on Linux.
2017-04-17 17:27:20 -07:00
Wouter van Oortmerssen 728bb64fed Fixed clang needing union copy constructor.
Move constructors are present, which it should use instead.

This is a temp fix to make it compile, but eventually we should
generate a proper copy constructor just in-case people want to
copy objects with unions.

Tested on: Linux, OS X.

Change-Id: Idf85419995c96f5959061882157541573e306083
2017-04-17 14:01:43 -07:00
Jason Stubbs a07f0d428d [C++] fix bounds checking on integer parsing (#4250)
* fix bounds checking on integer parsing

the previous code was allowing 255 for int8_t, similar for int16_t
and int32_t, and even negative values for unsignd types.

this patch fixes bounds checking for 8-bit, 16-bit and 32-bit types.
testing for both acceptable values and unacceptable values at the
boundaries are also improved.

bounds checking on 64-bit types isn't addressed by this patch.

* fix 'unary minus operator applied to unsigned type, result still unsigned'

* fix & placement
2017-04-17 11:19:43 -07:00
Wouter van Oortmerssen b0752e179b Added support for structs and strings in unions.
(C++ only for now).
Also fixed vector of union support in the object API.

Bug: 36902939
Change-Id: I935f4cc2c303a4728e26c7916a8ec0adcd6f84cb
Tested: on Linux.
2017-04-12 17:47:47 -07:00
chronoxor e6fa7b1133 Fix Visual Studio 2017 new warning (C4244: 'argument': conversion fro… (#4261)
* Fix Visual Studio 2017 new warning (C4244: 'argument': conversion from 'int' to 'const char', possible loss of data)

* Fix Visual Studio 2017 pedantic warnings

* Fix Visual Studio 2017 pedantic warnings
2017-04-12 13:13:10 -07:00
Kamil Rojewski 28e7dbd3d3 TypeScript support (#4232)
* 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
2017-04-10 10:01:13 -07:00
moti 2aec880347 [C++]Use noexcept in union type move ctor/Add move assingment (#4249)
* Use noexcept in union type move ctor/Add move assingment

* Add NOEXCEPT macro to deal with _MS_VER/Remove delegating ctor in union type class

* Add FLATBUFFERS_NOEXCEPT to generated union class
2017-03-29 18:00:20 -07:00
Wouter van Oortmerssen b4bb1b103f Fix flatc code gen.
Mutable functions should return a non-const reference to the member variable.

Change-Id: I833077d2c9a38a5d71868e43aca6b250d79b6625
2017-03-29 11:51:20 -07:00
Wouter van Oortmerssen cffd187fc7 Added missing generated code for C#
Change-Id: I1affced255eb96977119d8480793b5bba42f065f
2017-03-29 11:51:02 -07:00
Spencer Bench ccfa317486 C#: Fixed possible conflicts between usings and user-supplied namespace (#4247)
* C#: Fixed possible conflicts between usings and user-supplied namespace

C#: Added the global qualifier to using directives to prevent possible conflicts with the user-supplied namespace. Also prevents unintentional type hiding. Resolves issue #4242.

* Updated C# generated code files
2017-03-29 11:09:25 -07:00
tianyapiaozi a5cc2092a6 Support binary search for struct in cpp (#4245)
* Support binary search for struct in cpp

CreateVectorOfSortedStruct is provided for convenience.

* fix continuous-integration error

* add generated files

* compile Ability.cs in csharp test

* compile Ability.cs in csharp

* modify according to code review
2017-03-29 09:51:12 -07:00
Lawrence Chan 1a27c7017a C++: Add default value handling to mutation/SetField code (#4230)
* Add default value handling to mutation/SetField code

* Shorten reflection SetField impl

* Modify impl to work with C++03

* Add more mutation tests

* Fail SetField if non-scalar

* Add IsScalar/IsInteger/IsFloat for reflection::BaseType

* Use new IsScalar/IsInteger/IsFloat in reflection SetField

* Assume scalar is either int or float
2017-03-20 17:36:27 -07:00
Koichi Shiraishi c04c143cf0 tests: update monster_test.bfbs binary file with generate_code.sh (#4220)
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
2017-03-15 14:53:37 -07:00
Louis-Paul CORDIER bb223da258 C++ generator: Pre-allocating std::vector in UnPack methods. (#4187) 2017-02-25 22:10:17 -08:00
Andrei Lebedev 17c5f89d4f Fixed move constructor in generated union class (#4192)
* Fixed move constructor in generated union class

* Removed delegating constructor
2017-02-25 22:06:48 -08:00
Franken 037314a059 [C++] Additional accessors for fields of union types. (#4184)
* Additional accessors for fields of union types.

* Reveal the hidden parameter.

* External explicit specializations for templated accessors.

* Changes according to code style. Generated code included as well.
2017-02-25 21:23:32 -08:00
litianzhao ebcfbbadf0 fix #4180: Long.prototype.toFloat64() overflow (#4182) 2017-02-20 11:20:56 -08:00
Wouter van Oortmerssen 1fb6b9ee6f Added doc comments to the binary schema.
Change-Id: I87f291ab6e07b1425850cae25ed500db594f17c8
Tested: on Linux.
2017-02-13 16:47:17 -08:00
水樹素子 b7bfecb4ee Add move constructor to generated union class. (#4167)
* Add move constructor to generated union class.

* Unused default

* Add generated code
2017-02-10 10:32:34 -08:00
sjoblom65 c7c4bbfce2 Error C2668: 'Service::Version2::CreateServiceValues' : ambiguous call to overloaded function (#4161)
* Update idl_gen_cpp.cpp

Fix for: error C2668: 'Service::Version2::CreateServiceValues' : ambiguous call to overloaded function #4145

* Update idl_gen_cpp.cpp

Also needed the same change in the getPostTable

* Add files via upload

New generation from running generate_test.bat

* Add files via upload

Lets try this without added line feeds

* Added a test for a potential "ambiguous call to overloaded function"

* Change to a better name of the table.

Didn't like the Service in the name.

* Reverted back to the original
2017-02-10 10:25:11 -08:00
Wouter van Oortmerssen a9514de978 Fixed vector test on Windows 2017-02-08 15:59:52 -08:00
Wouter van Oortmerssen c57ab92e60 Fixes for Windows compiler errors.
Change-Id: I909ea6866089f36f9cb79d435bbecd29623fd8f7
2017-02-08 15:38:18 -08:00
Wouter van Oortmerssen aac6be1153 First attempt at SchemaLess FlatBuffers.
Change-Id: I86b9d002f3441ef9efdb70e059b8530ab2d74bb8
Tested: on Linux.
2017-02-08 15:13:56 -08:00
Wouter van Oortmerssen 29574282a2 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.
2017-02-01 14:18:28 -08:00
Wouter van Oortmerssen f9055ff9a7 Merge branch 'master' of https://github.com/google/flatbuffers 2017-01-27 15:30:27 -08:00
Wouter van Oortmerssen 9b3d8b318a Added tracking of order of types declared.
Change-Id: Iade313c99f119dcf1619674260648a33f61dc030
2017-01-27 15:30:08 -08:00
Wouter van Oortmerssen 87e29b25de Some small speed optimizations to the core copying functions.
Change-Id: Id8c1afb84f4ab0e2edca4290e3de5589fa06e578
Tested: on Linux.
2017-01-27 11:26:35 -08:00
Robert f7bc9bd51b Merge pull request #4146 from zchee/go-test-fix_struct
go: fix unknown field 'UOffset' to 'Pos'
2017-01-26 20:45:49 -08:00
Wouter van Oortmerssen 2fb25e2bb3 Moved union vector test to file dependent section.
Change-Id: I3a1fcf167eb0d0a51ef838e54246ef867e752218
2017-01-25 14:09:18 -08:00
gbeili fd61d70205 minor fixes to the union vector code styles (#4149) 2017-01-25 09:34:37 -08:00
Bei Li 68bbe983e9 Union Vector 2017-01-24 11:52:36 -08:00
Koichi Shiraishi 25c884158f
go: fix unknown field 'UOffset' to 'Pos'
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
2017-01-22 20:16:52 +09:00
Wouter van Oortmerssen 3f936c5655 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
2017-01-18 16:23:35 -08:00
Wouter van Oortmerssen 42a265b419 Add no-op for padding variables to prevent clang compiler warning.
Change-Id: I119ee7109bfa2b0be0f468d2b2be459f45d1bb11
2017-01-18 16:17:08 -08:00
Wouter van Oortmerssen 19101826a8 Fix unused field warning in clang.
Change-Id: I71d590a1e5b2709f0e2dcf97faaebda5cb918fc7
Tested: on Linux.
2017-01-13 18:30:57 -08:00
Wouter van Oortmerssen 7b94eab2b1 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
2017-01-13 17:44:42 -08:00
Pascal S. de Kloe b55f18649a Resolve Go fmt and vet warnings (#4134)
* Resolve Go fmt and vet warnings.

* Undo generated code gofmt.
2017-01-09 17:13:44 -08:00
Wouter van Oortmerssen 8c1a723ba5 Fixed GRPC method name generation.
Change-Id: I827b7e9aee1edb77752322455f7b6fafac16fb1d
Tested: on Linux.
2017-01-09 15:54:31 -08:00
Wouter van Oortmerssen 2c4dce5ba7 Re-applied reverted fix, adding missing codegen files.
Change-Id: I301d29835fb0baffd859950eb0fb3056e4f4d66b
2017-01-04 10:41:31 -08:00
Wouter van Oortmerssen cc84240098 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
2017-01-04 10:12:39 -08:00
CarsarSky 69dc71b5ed Fix C++ gRPC test with streaming method (#4123) 2016-12-28 11:50:41 -08:00
Zarian Waheed 84033ae035 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.
2016-12-21 17:48:21 -08:00
Wouter van Oortmerssen b9efbf6a3d Fixed more Windows build errors.
Change-Id: I556e1c103e8501dc144b16c8698463253de6f4fb
2016-12-21 17:45:27 -08:00
Wouter van Oortmerssen 03ee3db240 Fixed Windows build errors.
Change-Id: I11548bfa3cfe307598eb59c56412974c349d614d
2016-12-19 17:04:35 -08:00
Wouter van Oortmerssen cf825b8819 Added missing generated code from previous commits.
Change-Id: Id7053e4cb5a085a4b047c86ff1f2269329ff7f54
2016-12-19 16:28:06 -08:00
Wouter van Oortmerssen 377a8ba6b2 Merge branch 'master' of https://github.com/google/flatbuffers 2016-12-19 16:26:57 -08:00
Wouter van Oortmerssen e6fa14a08d Add default values (if they exist) to native tables.
From cl/142307012.

Change-Id: I54d550573f6506b92ad18e7cc90bcd8589259e52
2016-12-19 15:43:03 -08:00
Wouter van Oortmerssen c66683f27f 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
2016-12-19 15:21:08 -08:00
Zarian Waheed 6d6271db2f 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.
2016-12-16 08:46:30 -08:00
Robert 92a6ae93fa Merge pull request #3977 from gonzaloserrano/feature/go-generic-deserialitzation
Add a generic way to deserialize a flatbuffer in Go.
2016-12-07 11:17:55 -08:00
Ronak Jain a31ddd2bb3 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
2016-12-05 13:20:38 -08:00
Wouter van Oortmerssen bc2ec7119b 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
2016-12-02 14:25:39 -08:00
Wouter van Oortmerssen 641b397f8b 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
2016-12-02 14:25:08 -08:00
Wouter van Oortmerssen d342918790 Merge branch 'master' of https://github.com/google/flatbuffers
Change-Id: I02b00b22cdd2d1bd32de3273ff69185c9b0f4e5b
2016-11-21 15:20:33 -08:00
benssson 5608be0f96 Fixed javascript helper for typed arrays of scalars not taking into (#4068)
account underlying buffer's byte offset.
2016-11-18 11:42:50 -08:00
Michael Paulson d298adc4e6 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.
2016-11-07 10:27:26 -08:00
benssson cf0d7829a6 Fixed javascript helper for typed arrays of scalars not taking into (#4068)
account underlying buffer's byte offset.
2016-10-26 10:29:36 -07:00
Baptiste Lepilleur 5b5fcbfc00 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#.
2016-10-21 14:27:15 -07:00
Wouter van Oortmerssen 6862b2ff08 Added functionality to obtain a buffer pointer from a root.
Change-Id: Ia63e41d0304e8668ea4ce09a4c31dd999eb96994
Tested: on Linux.
Bug: 32218623
2016-10-19 16:24:24 -07:00
Wouter van Oortmerssen 22e87071dd Fixed lambda return value error on VS2010.
Change-Id: I6d0e8469bfa5b4c8a3f1cb119e186f4cf62c76ae
2016-10-17 15:04:12 -07:00
Wouter van Oortmerssen 606098cac8 Fixed unused variable warnings, and made sure they are on.
Tested on Linux.

Change-Id: Ie18d6857f9ae8b1c3953a116203b4a8bb70a2ede
2016-10-17 13:06:11 -07:00
Wouter van Oortmerssen d9fe4e2769 Allow other pointer types than unique_ptr for object API.
Change-Id: I945890ce667a2f5a6c0495e78fd5326ed33b9914
Tested: on Linux.
Bug: 30135763
2016-10-17 09:54:52 -07:00
Wouter van Oortmerssen c81239f6ea Fix lambda compilation error in VS.
Change-Id: I814008b6eeffec9bd4b8810e4b29db9ea6218bb8
2016-10-12 14:51:02 -07:00
Wouter van Oortmerssen b830dac266 Added missing generated code files.
Change-Id: Ifb977411b65f8721cf9db891d7a62798bd593c0c
2016-10-12 14:40:35 -07:00
Wouter van Oortmerssen dc38f93ca8 Merge branch 'master' of https://github.com/google/flatbuffers 2016-10-12 14:39:36 -07:00
Wouter van Oortmerssen 486c048a0d 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>
2016-10-12 14:30:31 -07:00
Wouter van Oortmerssen dc2fa215b8 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
2016-10-12 11:22:20 -07:00
Baptiste Lepilleur 199157e8f4 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.
2016-10-07 09:42:29 -07:00
jbrads b075b8c49d 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.
2016-10-03 14:14:25 -07:00
Wouter van Oortmerssen f6c1a1ebcf Merge pull request #4025 from paszea/reflection_fqn
serialize fully qualified struct & enum name in schema binary
2016-09-21 11:06:34 -07:00
Xun Liu df0991b7de serialize fully qualified struct & enum name in schema binary 2016-09-15 10:42:23 -07:00
Wouter van Oortmerssen 09ee46a83e Merge pull request #4020 from albertofem/feature/allow_public_accessor_net
Allow access to underlying ByteBuffer in C#
2016-09-12 10:35:16 -07:00
Alberto Fernández 02dfa64a89 Allow access to underlying ByteBuffer 2016-09-12 09:35:08 +02:00
Wouter van Oortmerssen edd77ae2f3 Merge pull request #4010 from rgilles/master
Isolate the complied Java classes into a target folder.
2016-09-09 15:28:37 -07:00
Romain Gilles 582fd90c4a Use the find -exec instead of find ... | xargs otherwise when there is error log in the output of the build. 2016-09-06 23:28:22 +02:00
Romain Gilles afd230af8d Remove commented line. Add a last step that remove the target folder after the build and the tests execution. 2016-09-01 13:01:07 +02:00
Wouter van Oortmerssen 52ca75506a Switched C# accessors from classes to structs 2016-08-31 17:34:51 -07:00
Romain Gilles 3bb9b839b8 Add remove of remaining class files before running the build 2016-08-30 10:18:47 +02:00
Romain Gilles 5e7bfd0461 Isolate the complied Java classes into a target folder + log java version.
It is a common practice to put all the compiled classes into a
dedicated folder in order to:
 - avoid to mix the code and the complied classes
 - to allow a simple way to remove the complied classes

Add log of java version in order to make it explicit to the end user.
2016-08-29 11:26:31 +02:00
Wouter van Oortmerssen 481d332e72 Fixed compile error in LookupByKey fix.
Change-Id: Ice94f09197235cf71b41a22d0767bd7b119284e1
2016-08-26 14:18:04 -07:00
Wouter van Oortmerssen ee56418cef Undo compile Java classes into target folder.
This was causing class loader errors on Java 1.6.

Change-Id: Id1d9e7e369aad639115664c43a867c4d3a82f9f1
Tested: on Linux.
2016-08-26 14:02:00 -07:00
Wouter van Oortmerssen e1f8037cb5 Fixed Java LookupByKey functionality for Java 1.6
Tested: on Linux.

Change-Id: Iea336f75a3b6e722743563813c3c9ed9db4d02fe
2016-08-26 13:58:16 -07:00
Wouter van Oortmerssen 49ee30a207 Merge pull request #3978 from TGIshib/key
Find by key on C# and Java (2)
2016-08-26 12:03:28 -07:00
TGIshib 7c69c5dc3d Fix lookupByKey, improve compareStrings 2016-08-26 19:41:32 +03:00
Romain Gilles f96eb472b3 Isolate the complied Java classes into a target folder.
It is a common practice to put all the compiled classes into a
dedicated folder in order to:
 - void to mixing the code and the complied classes
 - to allow a simple way to remove the complied classes
2016-08-25 10:40:41 +02:00
Wouter van Oortmerssen 79d127c863 Merge pull request #2133 from evolutional/cs-bounds-check
C#: added #define BYTEBUFFER_NO_BOUNDS_CHECK
2016-08-24 09:26:06 -07:00
gonzaloserrano 199a49b5b3 Add a generic way to deserialize a flatbuffer in Go.
Similar to what protobufs does with its `Message` interface, introduce here such interface and create a generic `GetRootAs` method to deserialize a flatbuffer.
2016-08-23 16:38:22 +02:00
Wouter van Oortmerssen 96ab6ade5a Merge pull request #3993 from bhamiltoncx/generate-text-failure
Allow GenerateText() to indicate failure to encode flatbuffer to JSON
2016-08-22 11:32:52 -07:00
TGIshib 9f16090f90 Improve `LookupByKey` , update docs 2016-08-22 18:10:52 +03:00
rw c4ba502f57 Remove invalid vector item heap alloc
Fixes #3986
2016-08-20 20:33:36 -07:00
Ben Hamilton 94d5643f97 Allow GenerateText() to indicate failure to encode flatbuffer to JSON (i.e., non-UTF-8 string data) 2016-08-18 10:23:26 -07:00
Artem Kazakov 726a5f523e add byte array and unintialized array creation to FlatBufferBuilder 2016-08-16 16:26:53 -04:00
TGIshib 8fdced4e11 Update 2016-08-14 14:58:51 +03:00
TGIshib 9031597f49 Merge remote-tracking branch 'refs/remotes/google/master' into key 2016-08-13 16:28:38 +03:00
Wouter van Oortmerssen a0b8f669ee Added "Direct" suffix to vector/string object creation functions.
They were overloaded, but also had default arguments, so would
become ambiguous when used with few arguments.

Change-Id: Ifac7f3ea3a6391d971dfeda8e33129c8c38d6f12
Tested: on Linux.
2016-08-12 11:12:12 -07:00
Wouter van Oortmerssen 205ddb175f Added union namespacing test case.
Change-Id: I9a4f90889c311c454a9c19e78c7db3c79800b44e
Tested: on Linux.
2016-08-10 11:52:09 -07:00
Wouter van Oortmerssen c96fc7fcef Added missing generated code from previous commits.
Change-Id: Ie2f1f65be451979d9f8d4da999b1c10737e867af
2016-08-08 12:18:07 -07:00
Wouter van Oortmerssen 026c6ddb17 Merge branch 'master' of https://github.com/google/flatbuffers 2016-08-08 12:17:10 -07:00
Wouter van Oortmerssen 3eebba789f Fixed incorrect generated code on convenient vector constructors.
Change-Id: Ib283eade157a436e0f3ca0e68d74e7dc6c51c65b
2016-08-08 12:16:10 -07:00
TGIshib dc7f5bc0d8 Remake 2016-08-03 13:29:50 +03:00
gonzaloserrano ec20233fab Make most of the Go code comply with gofmt (except enums).
Enums are not fixed because depending on they have comments or not they
will be aligned alogn the asssignment character.
2016-08-02 18:21:47 +02:00
Ben Hamilton f6416d8471 Validate UTF-8 by default when parsing IDL. Support Unicode values > U+FFFF in parse 2016-08-01 14:05:24 -07:00
Wouter van Oortmerssen c9b9fd0407 Merge remote-tracking branch 'mbp/mutable-js' into ghfix 2016-07-29 11:32:00 -07:00
Michael Paulson d268d11ca2 feat(test): Added mutation testing for scalar values.
This is a port of the tests found in test.cpp
2016-07-27 13:32:53 -07:00
Michael Paulson a351124cfd chore(generate-code): Generate the JS code after mutation has been added. 2016-07-25 20:00:22 -07:00
Kazuki Sakamoto 5f351a35a2 Add EnumNames to Go code
Tested: on Darwin
2016-07-25 19:37:16 -07:00
Wouter van Oortmerssen f98870715a Adding missing generated code from recent commits.
Also updated generated_code.sh to prevent this from happening in
the future.

Change-Id: Ib282e9b6c762a79d4b4e09bee06b14781cd2a4c1
2016-07-25 15:01:37 -07:00
Wouter van Oortmerssen f61f0449c7 Merge pull request #3935 from kazimuth/jsns
Add @namespace annotation to namespaces in javascript
2016-07-25 10:47:46 -07:00
Robert a56c6e5195 Merge pull request #363 from danring/fix-341
Emit GetRootAs methods for all types in Go and Python
2016-07-22 15:12:35 -07:00
Wouter van Oortmerssen 5efa22447e Fixed conversion warning in generated code. 2016-07-20 18:17:33 -07:00
Wouter van Oortmerssen bdd668df7b Fixed VS2010 build 2016-07-20 18:13:11 -07:00
Wouter van Oortmerssen 05b00c50ad Added way to test two schemas for safe evolution.
Change-Id: I1dfc867e6df5932ab61dad431eb3cb02f15d04df
Tested: on Linux.
Bug: 30202327
2016-07-20 17:56:59 -07:00
Wouter van Oortmerssen 77e9122681 Merge "This is a minimal amount of #ifdef's to make stlport work." into ub-games-master 2016-07-21 00:55:05 +00:00
Wouter van Oortmerssen e067040375 Fixed unused parameter warning.
Change-Id: I7a2576c6f366b89ef3e1f83941f90294ca7a07fd
2016-07-20 17:52:41 -07:00
Wouter van Oortmerssen 370e101a69 Added missing Go generated files.
Change-Id: I9d738e84ab2e01ec117c825ade44cc865cf5f1c2
2016-07-20 17:43:03 -07:00
Wouter van Oortmerssen 91f5cf357c Merge branch 'master' of https://github.com/google/flatbuffers into grpc2 2016-07-20 17:41:36 -07:00
Wouter van Oortmerssen 7c7c571bbe This is a minimal amount of #ifdef's to make stlport work.
Minimal, in the sense that this will only allow flatbuffers.h +
generated code to work. Everything else (tests, parsing, reflection
etc.) may still not compile with stlport.

Functionality has been reduced, some utility functions are not
available.

Tested: on Linux (no stlport), Android (stlport).

Change-Id: I3f8b6a88258c07d78964dd455fb9f99f65266301
2016-07-20 17:29:47 -07:00
Wouter van Oortmerssen 3101e327c0 Added optional object based API for C++.
Change-Id: If927f3ea3fb3723088fa287f24bdd1ad43c8d1d1
Tested: on Linux.
2016-07-20 14:58:57 -07:00
Wouter van Oortmerssen 46bf9f5177 Merge pull request #259 from kadirahq/golang-mutators
(Go) Add setter methods for scalar values.
2016-07-20 10:51:30 -07:00
Wouter van Oortmerssen ce3e7fbd72 VS2010 fixes 2016-07-20 10:41:26 -07:00
Muhammed Thanish 53e9606ea2 Implement mutators for Go 2016-07-20 22:58:22 +05:30
lakedaemon e750268f0c clang formating cpp code generator and add missing generated classes 2016-07-15 16:08:59 +02:00
Wouter van Oortmerssen b22db6e8eb Merge pull request #3905 from bog-dan-ro/master
Verifier computes the buffersize, useful when streaming multiple flatbuffers
2016-07-14 10:55:22 -07:00
Wouter van Oortmerssen 14e7e8260e Merge pull request #3939 from TGIshib/hex-bug
Fixed bug with negative hex constants (2).
2016-07-14 10:47:34 -07:00
BogDan Vatra 3a1f776132 Verify everything in one shot 2016-07-14 20:16:07 +03:00
BogDan Vatra 4b53762cf2 Verifier computes the buffersize, useful for streaming
Close #3898
2016-07-14 20:15:44 +03:00
Raman 0d56276102 Update test.cpp 2016-07-14 18:51:23 +02:00
Raman 98c7a0c169 Update test.cpp 2016-07-14 10:30:06 +02:00
Raman 676f0712fd Update test.cpp 2016-07-14 10:01:08 +02:00
Raman db99c1aa64 Update test.cpp 2016-07-12 19:55:35 +02:00
daksenik aade31b263 Fixed spaces. Removed redundant == nullptr. Vectors pointers made const. 2016-07-11 20:27:38 +03:00
James Gilles 4a49493e27 js:add @namespace annotation to namespaces 2016-07-11 01:40:38 -04:00
Raman 22697722d9 Update test.cpp 2016-07-09 12:51:06 +02:00
daksenik 1661f3a2e8 Added function GenSimpleParam. Tests added. 2016-07-09 13:00:21 +03:00
Raman 5043764247 Update test.cpp 2016-07-04 21:55:44 +02:00
Wouter van Oortmerssen 48f37f9e0a Added GRPC code generator to flatc.
Also added simple (in-process) test.

Change-Id: I38580d554dd52f590e3396ec4846e07546dcf07d
Tested: on Linux.
2016-06-29 15:51:44 -07:00
Wouter van Oortmerssen 57ba8a4d46 Merge branch 'master' of https://github.com/google/flatbuffers 2016-06-20 16:41:40 -07:00
Wouter van Oortmerssen 9e6c5f9f2c JSON Parser allows union type fields to come after unions.
This is useful because many JSON generators will sort the fields,
cause X_type to follow X.

Change-Id: I00ef3ac05418224fc05aee93e6b3b3597e73ffe3
Tested: on Linux.
Bug: 29221752
2016-06-20 16:30:14 -07:00
Wouter van Oortmerssen 3639032d1e Allow unions of table types with the same name but from different namespaces.
Also fixed most codegenerators using the wrong namespace when multiple
namespace were used in a file, with some files not being generated.

Change-Id: Ib42969221239d7244e431cbd667ef69200fc415f
Tested: on Linux.
Bug: 29338474
2016-06-20 11:47:04 -07:00
rw fd43d3709e Fix test using compat.binary_types (from March). 2016-06-18 01:12:56 -07:00
Wouter van Oortmerssen 6e177bf03f Merge branch 'master' of https://github.com/google/flatbuffers 2016-06-17 17:44:00 -07:00
Wouter van Oortmerssen d3ac0bc149 Added conversion operations that can be used inline in JSON.
e.g.: { myfield: cos(rad(180)) } is equivalent to writing { myfield: -1.0 }

Bug: 29338398
Change-Id: I6fc4ef1fd10bda3ba78cba464414dd071a2f50ca
Tested: on Linux.
2016-06-15 14:54:44 -07:00
Wouter van Oortmerssen afa276288c Added additional convenience overloads to CreateVector().
Bug: 29337887, 29336299
Change-Id: Iad8b3b2263f6cea7ee7e45994369194960df293b
Tested: on Linux.
2016-06-15 14:31:34 -07:00
Dan Ring 4832238708 Add tests for GetRootAs* in Go and Python 2016-06-14 18:41:33 -04:00
Dan Ring 1f8e3c13e6 Emit GetRootAs methods for all types in Go and Python 2016-06-14 18:41:33 -04:00
Wouter van Oortmerssen 5a401aef57 Merge pull request #3897 from Lakedaemon/namespaceWork
Namespace work
2016-06-13 15:16:28 -07:00
Wouter van Oortmerssen bafd48d96c Merge branch 'master' of https://github.com/google/flatbuffers into fuzzer2 2016-06-08 11:51:49 -07:00
Wouter van Oortmerssen 2bdf44a25d Added a way to get mutable tables out of a mutable vector of tables.
Change-Id: I8f9ef1d14f86671ced929c7a159115b1d8510327
Tested: on Linux.
2016-06-06 17:38:21 -07:00
lakedaemon a3a2bf890f Better C++ namespace management 2016-06-02 23:11:51 +02:00
lakedaemon a9194c4c68 cpp generator : pulling all methods inside the class 2016-06-02 21:56:27 +02:00
lakedaemon cd1493b082 sharing the Flatbuffers warning 2016-05-26 15:26:58 +02:00
Wouter van Oortmerssen a98bff3ea1 Add simple libfuzzer based test.
This tests the verifier and the parser.

Tested: on Linux.
Bug: 27230459
Change-Id: I3417faba9385dc941199c57a08d8a50c2faec1aa
2016-05-25 17:25:40 -07:00
Ben Gertzfield 6704b19db6 Handle \u-escaped surrogate pairs correctly in IDL parser 2016-05-23 16:38:55 -07:00
Wouter van Oortmerssen 64b91da9cf Uncomment the corpus attribute since b/28762769 is fixed,
add more items to the corpus (taken from the ClusterFuzz-generated corpus).

(mirrored from cl 122690857)

Change-Id: I98c7672169a9a27fe18bedae8501e6fb85a0681d
2016-05-23 16:37:57 -07:00
Wouter van Oortmerssen fe9787e58d Add a fuzzer for flatbuffers, derived from the one used in Chromium:
https://code.google.com/p/chromium/codesearch#chromium/src/testing/libfuzzer/fuzzers/flatbuffers_verifier_fuzzer.cc

(mirrored from cl 122676317)

Change-Id: I0074af435cf37f5e6368b040563c3733d9e02345
2016-05-23 16:35:20 -07:00
Wouter van Oortmerssen a42a99029f Made .sh files all have same comment formatting.
Change-Id: Ie7cc268a8823aec1d06c8b7cbef54068d832de3a
2016-05-23 14:08:21 -07:00
Wouter van Oortmerssen 8c0d56d55a Removed BOM marker from some files.
Also removed some trailing whitespace.

Change-Id: I40bf4f776ca4d467b7ee6f2c9a7500c13700f9d5
2016-05-23 12:24:44 -07:00
Wouter van Oortmerssen c41a0453c1 Merge branch 'master' of https://github.com/google/flatbuffers 2016-05-23 10:59:47 -07:00
Wouter van Oortmerssen 1a161a8333 Added missing licenses to some sh/cs/py files.
Bug: https://github.com/google/flatbuffers/issues/3872
Change-Id: I5d551168e9bc925e867e5e4ddf5d809418fd44eb
Tested: on Linux.
2016-05-23 09:51:41 -07:00
Ben Gertzfield 3400727fff Fix undefined behavior in CheckBitsFit bit-shift on size_t 2016-04-29 15:15:09 -07:00
Wouter van Oortmerssen fd542c71e3 Fixed float suffix not being added on implicit float defaults.
Change-Id: I8dcbb5e93836356511d411ef86452babd3dd3c0b
Tested: on Linux.
2016-04-20 12:06:32 -07:00
Wouter van Oortmerssen 4d7890c2c9 Fixed whole-number float default values missing a .0 suffix.
A previous commit that added "f" for C++/Java/C# would break
on gcc of constants like 3f, which are now output as 3.0f

Tested: on Linux

Change-Id: If9cabbe3c6d6948a5050b8b123bda9c06e181f52
2016-04-18 11:50:46 -07:00
Wouter van Oortmerssen 29d957ed5e Fixed missing "f" on float default values in C++/Java/C#
Bug: 28145201
Change-Id: I5a1818c40c2f4fbd00cfec3362040407976f7a39
Tested: on Linux.
2016-04-13 17:29:03 -07:00
Wouter van Oortmerssen 72fc45aa6a Made user-defined attributes available in the reflection data.
Tested: on Linux.

Bug: 27923233
Change-Id: Ic16675650e4a8e138c163f1e2131a3aad7008ada
2016-04-11 17:36:56 -07:00
Wouter van Oortmerssen e597ad8f0f Fixed pre-declarations of included types in generated code.
This was harmless, but unnecessary.

Change-Id: I1365a725e254d4ebbda081110a50277cb5118323
Tested: on Linux.
2016-04-11 11:05:42 -07:00
Wouter van Oortmerssen 5e3f9d5175 Merge branch 'master' of https://github.com/google/flatbuffers 2016-04-04 16:55:25 -07:00
Armen Baghumian 28a3c939e7 Implement __vector_as_bytes and methods to get [ubyte] efficiently
Currently in order to get a value type of [ubyte] in PHP, iteration is
necessary which is not efficient. Helper __vector_as_bytes has been
implemented in order to return the byte arrays in PHP efficiently.

Appropriate methods also been added to use aforementioned method to return
the byte array. (e.g. get*Bytes()).

The reason the methods are named get*Bytes() and not for instance
get*ByteArray() is the fact that PHP doesn't support byte arrays and the
binary safe string implementation in PHP is used to simulate byte arrays
and since there is chance for PHP users to confuse this with PHP arrays
the name get*Bytes() has been chosen.

In the future __vector_as_bytebuffer() method can also be implemented to
return PHP implementation of ByteBuffer.
2016-03-29 14:56:09 +11:00
Wouter van Oortmerssen e6b79f0002 Added stream & idempotent annotations for RPCs.
Change-Id: Ia8651c1051808fdda0dc0ba52ec991777f868e88
Tested: on Linux.
2016-03-09 15:03:05 -08:00
Wouter van Oortmerssen 1a63eb46bb Added RPC declarations to the schema parser.
This is the first step in RPC support. Actual code generation
to follow.

Change-Id: I96c40fec3db671d100dd9eb509a71c5cbe55bfb2
Tested: on Linux.
Bug: 20122696
2016-03-09 13:47:40 -08:00
Wouter van Oortmerssen fbc8af40e3 Allow JSON numeric fields to be specified by a numeric data in a string.
Change-Id: I6a3fae1e71434a7384edc39b8602bd84a0432edb
Tested: on Linux.
Bug: 24140897
2016-03-07 17:22:51 -08:00
Wouter van Oortmerssen 709e720839 Merge branch 'master' of https://github.com/google/flatbuffers 2016-03-07 15:04:18 -08:00
Wouter van Oortmerssen 958fc6ec49 Added support for easy string pooling.
Change-Id: I790cf681c1bffff800d77afb0e2f908d1c827679
Tested: on Linux.
Bug: 26186542
2016-03-07 12:58:36 -08:00
Wouter van Oortmerssen 617fedf349 Merge pull request #3765 from Mischanix/js-typed-arrays
Javascript helper to get typed array views
2016-02-26 09:51:50 -08:00
Evan Wallace 31b30335f6 Fix #3773: Generated JS now avoids the flatbuffers object 2016-02-25 01:06:16 -08:00
Nalinichandra Penke cbab26673b Fix #3775: Skip unknown field names if they're quoted 2016-02-22 14:34:20 -06:00
Wouter van Oortmerssen 20c0082ee5 Fixed namespace code generation for C++
The code generator was assuming all declarations for the current
file sit in the same namepace. Now uses the "on demand" namespace
switching we had for the forward declarations.

Also fixed a bug related to namespace lookup.

Change-Id: Ib54a3efbc752cbb9590302fa0707c0c73448db3d
Tested: on Linux.
2016-02-17 11:26:38 -08:00
Robert Nix 9d92aeb182 Add helper for javascript typed arrays
For scalar vector fields, emit an Array helper that
returns a typed array view of the underlying bytes buffer.
2016-02-12 12:41:28 -06:00
Robert Nix 2f5d7ae645 Fix javascript unicode test
The generated buffer should be tested for semantic equivalence
to the correct buffer, instead of being tested for bytewise
equality.
2016-02-12 12:31:25 -06:00
Oli Wilkinson dbf6702371 Added support for C# partial class generation when the `csharp_partial` attribute is used on a table/struct. 2016-01-21 15:42:30 +00:00
Wouter van Oortmerssen db0727e943 Merge pull request #3734 from evolutional/cs-forcedefaults
Implemented ForceDefaults option on C# FlatBufferBuilder.
2016-01-20 13:46:49 -08:00
Wouter van Oortmerssen 0afac8f75a Merge branch 'master' of https://github.com/google/flatbuffers 2016-01-20 13:30:09 -08:00
Wouter van Oortmerssen 519dcdd0b2 Fixed Python unit test breakage.
Test was testing for a field to be None, even though it is populated
in one particular instance.

Change-Id: Id19848d01498d4c0a684efdb2bf49ff12c5b6758
Tested: on Linux.
2016-01-20 13:04:03 -08:00
Oli Wilkinson fff4590faf Implemented ForceDefaults option on C# FlatBufferBuilder.
Tested on: Windows, Unit Tests
2016-01-20 17:25:58 +00:00
Robert b7d97ff3de Merge pull request #3491 from faizanrashid/master
[BUG FIX] [MINOR] Fix encoding with unicode characters.
2016-01-19 17:56:26 -08:00
Mark Klara 69a31b807a Revamping the FlatBuffers docs.
Adding an API reference for the supported languages.

General docs cleanup, including a new `tutorial` section that
supports all of the supported languages.

Added samples for each supported language to mirror the new
tutorial page.

Cleaned up all the links by making them `@ref` style links,
instead of referencing the names of the generated `.html` files.

Removed all generated files that were unnecessarily committed.

Also fixed the C# tests (two were failing due to a missing file).

Bug: b/25801305

Tested: Tested all samples on Ubuntu, Mac, and Android. Docs were
generated using doxygen and viewed on Chrome.

Change-Id: I2acaba6e332a15ae2deff5f26a4a25da7bd2c954
2016-01-19 14:31:17 -08:00
Wouter van Oortmerssen d75d29e2fe Merge branch 'master' of https://github.com/google/flatbuffers 2016-01-19 14:10:49 -08:00
Wouter van Oortmerssen 049f3f7907 Added support for parsing JSON null value.
These cause the field in question to be skipped.

Bug: 16550393
Change-Id: Id05104e89818ee773b8a91fdcc86e18061b9a82f
Tested: on Linux.
2016-01-19 14:05:27 -08:00
Wouter van Oortmerssen e848137ded Added min/max values for enums/unions.
Bug: 21642898
Change-Id: Ifaf0b3c4274fe30ef29507ba1c1216d700efe85b
Tested: on Linux.
2016-01-19 14:05:27 -08:00
Wouter van Oortmerssen 8472b5f224 Merge pull request #3513 from evolutional/fix-3500
Java/C#: generation of typed helpers when using nested_flatbuffers
2016-01-19 10:40:02 -08:00
Oli Wilkinson eaa2b414b2 Added generation of typed helpers when using nested_flatbuffers in Java/C#. Fixes #3500 2016-01-18 15:23:14 +00:00
Chandra Penke b63ebad49d Fix #3497: Add support for compiling in g++ 4.4 and 4.5
- Removed uses of lambda expressions

- Added custom defines for constexpr and nullptr

- Removed trailing comma of last value from generated enums
2016-01-09 06:30:50 -06:00
Faizan Rashid af23683311 [BUG FIX] [MINOR] Fix encoding with unicode characters.
When passing a unicode string to builder.CreateString, the
default encoding assumed all characters can be encoded
using ascii. Added a fix so a user can specify the
encoding and how to handle errors when creating strings.
2015-12-31 09:45:09 +05:00
Wouter van Oortmerssen 8f13c828f5 Merge pull request #2776 from ncpenke/skip-unknown-json-fields
Fix #2775: Add parser option to skip unknown JSON fields
2015-12-29 10:29:11 -08:00
Wouter van Oortmerssen e6240f4039 Merge pull request #2790 from chobie/php-table-fix
(PHP) fixes getting indirect table, also fixes getInt method on 32bit machine
2015-12-29 10:25:21 -08:00
Shuhei Tanuma 4691558ee3 (PHP) remove duplicate test 2015-12-24 15:50:03 +09:00
Shuhei Tanuma 7fbd9b8de4 (PHP) improve indirect buffer test 2015-12-24 15:35:28 +09:00
Nalinichandra Penke 13d0594b4c Fix #2775: Add parser option to skip unknown JSON fields 2015-12-22 00:02:19 -08:00
Wouter van Oortmerssen 1891537236 Fixed reflection setting string not changing size field.
Change-Id: I3c3e88a79667d1733b6c47e43b55d8b2604ca8e2
Tested: on Linux.
2015-12-21 16:20:03 -08:00
Wouter van Oortmerssen 995ee86a6e Added an IsFieldPresent helper function.
This is implemented as a template function, since Table::CheckField
is not reachable by subclasses of Table (private base class).

Change-Id: I1ed4d47ce7cb672460ccab61cf7442eb9136b0f1
Tested: on Linux.
Bug: 26273432
2015-12-21 12:17:59 -08:00
Shuhei Tanuma c9198dbbb8 (PHP) fixes getting indirect table, also fixes getInt method on 32bit machine. 2015-12-17 11:35:31 +09:00
Oli Wilkinson 4802e8a285 C# added BYTEBUFFER_NO_BOUNDS_CHECK #define
Removes the bounds checking on the ByteBuffer Get/Put operations. Can be dangerous when used with UNSAFE_BYTEBUFFER but results in increased performance. Use at your own risk!
2015-12-14 21:06:29 -05:00
Wouter van Oortmerssen a9909a0c18 Made sure all namespace test files get generated.
Also included them in the C++ test.

Change-Id: Ib0c8470f0aacdf16616c27494abdda57a010195d
Tested: on Linux.
2015-12-14 16:15:43 -08:00
Wouter van Oortmerssen c44bc6a719 Merge branch 'master' of https://github.com/google/flatbuffers 2015-12-09 12:57:12 -08:00
Wouter van Oortmerssen 6fba6b6e71 Fixed compiler warnings for cast to bool in generated code.
Change-Id: I7727aeb478feb23d8ef66fd1ba9499b142b3ea7d
Tested: on Linux.
2015-12-09 12:56:24 -08:00
Wouter van Oortmerssen 96cd275603 Merge pull request #288 from mfcollins3/csharp-byte-buffer
Add Get Bytes Method Generator for C#
2015-12-07 17:35:57 -08:00
Wouter van Oortmerssen 8e6758d205 Merge pull request #608 from evolutional/master
Fix to #360 - Fully qualified names outside of current NS
2015-12-07 10:33:38 -08:00
Armen Baghumian f622e5996c Optimize get* operation
It's slightly faster to convert the value to signed value in PHP as
opposed to use pack and unpack.

For 1M get operation the difference is:

    getShort in 3.3272678852081 seconds
    getInt in 3.8338589668274 seconds
    getLong in 5.6381590366364 seconds
    getLong (neg) in 5.6149101257324 seconds

vs

    getShort in 2.7564418315887 seconds
    getInt in 3.1612701416016 seconds
    getLong in 3.1369340419769 seconds
    getLong (neg) in 3.1478710174561 seconds

And since pack("P") and unpack("q") has been removed now ByteBuffer
works for PHP >= 5.4
2015-12-05 23:32:35 +00:00
Armen Baghumian 77fbdd28e2 Correct the max/min signed/unsigned 32-bit int
The test was trying to pack an unsigned int which couldn't fit as a
signed int and putInt() wasn't doing the validation in the correct range
2015-12-05 23:32:35 +00:00
Oli Wilkinson c9ad6d5496 Fix to #360 - Updated the general generator (Java/C#) to emit fully qualified names where the referenced object isn't directly in this namespace. Added test fbs files to verify compilation. 2015-12-05 13:42:09 -05:00
Michael Collins e083e466b8 Add Get Bytes Method Generator for C#
I updated idl_gen_general.cpp to add support for generating a Get Bytes
method for a vector to the generated C# source code. Given a byte vector
field named Foo, a method named GetFooBytes() will be generated in the
C# source code that will return an ArraySegment<byte> value referencing
the vector data in the underlying ByteBuffer.

I added a method to Table.cs named __vector_as_arraysegment that is used
by the code generated by the change to the C# generator.
__vector_as_arraysegment will take the offset of the vector and will
return the ArraySegment<byte> value corresponding to the bytes that
store the vector data.

I updated FlatBuffersExampleTests.cs to add tests to validate my
implementation of Table.__vector_as_arraysegment. I added tests to
demonstrate that the bytes for the monster's name can be extracted from
the underlying byte array. I also added tests to show that
Table.__vector_as_arraysegment returns a null value if the vector is not
present in the FlatBuffer.

I used the updated flatc.exe program to regenerate the C# source files
for the MyGame example. The new Monster class includes the GetXXXBytes
methods to return the byte arrays containing data for vectors.
2015-12-04 11:44:43 -07:00
Wouter van Oortmerssen 45bda6e08d Added --gen-all to generate code for a schema and all its includes.
Also refactored the way options are stored.

Change-Id: I709ac908cd2aba396c9c282725cf1d42ccce0882
Tested: on Linux.
2015-12-04 09:44:31 -08:00
Wouter van Oortmerssen 7b06041a7c C++ generated code now has constants for vtable offsets.
Besides making the generated code looking a lot more readable,
it also allows you to use these offsets in calls to
Table::CheckField, to see if a field is present in a table.

Change-Id: I1b4cc350c4f27c4e474c31add40c701ef4ae63b2
Tested: On Linux.
2015-12-02 11:12:39 -08:00
Wouter van Oortmerssen 3fc5387db7 Made C++ generated code use "bool" instead of uint8_t wire type.
Change-Id: I5756d15a758429ca67456264842017063d1f755e
Tested: on Linux.
2015-12-02 11:12:39 -08:00
Wouter van Oortmerssen d7b4a31e93 Added long form options for all generators (--cpp etc.)
Short-form versions are still supported, but are deprecated.

Change-Id: I15f70ca8d69ba5790368205caa9603b65e1b7fff
Tested: on Linux.
2015-12-02 11:12:39 -08:00
Wouter van Oortmerssen b7d8c2af1a Made generated C++ code respect gcc -Werror=shadow.
Change-Id: I17de0bcc462770124227a9967e2aab620467f6eb
Tested: on Linux.
2015-12-02 11:12:39 -08:00
Donnell 644bcbde91 Fix C# vector of enum code generation
Fixes a bug where the logic to determine when to use a C# enum flags
both enums and vectors of enums.  This causes the C# generator to
generate code that doesn't compile for tables that contain vectors of
enums.

The fix also consolidates type generation functions a bit and adds
some additional casting functions for clarity.
2015-11-23 09:19:43 -05:00
Wouter van Oortmerssen 6266b4f122 Merge pull request #308 from chobie/php
Add support for PHP code.
2015-11-18 09:31:17 -08:00
Shuhei Taunma 5ce8682671 (PHP) add experimental support for PHP language.
* codegen for all basic features: WIP (probably implemented all basic feature)
* JSON parsing: NO
* Simple mutation: NO
* Reflection: NO
* Buffer verifier: NO (will be add later)
* Testing: basic: Yes
* Testing: fuzz: Yes
* Performance: Not bad
* Platform: Supported Linux, OS X, Windows (has 32bit integer limitation)
* Engine Unity: No

flatc --php monster_test.fbs

  <?php
  //include neccessary files.
  $fbb = new Google\FlatBuffers\FlatBufferBuilder(1);
  $str = $fbb->createString("monster");
  \MyGame\Example\Monster::startMonster($fbb);
  \MyGame\Example\Monster::addHp($fbb, 80);
  \MyGame\Example\Monster::addName($fbb, $str);
  $mon = \MyGame\Example\Monster::endMonster($fbb);
  $fbb->finish($mon);
  echo $fbb->sizedByteArray();

PHP 5.4 higher

Currently, we do not register this library to packagist as still experimental and versioning problem.
If you intended to use flatbuffers with composer. add repostiories section to composer.json like below.

  "repositories": [{
    "type": "vcs",
    "url": "https://github.com/google/flatbuffers"
  }],

 and just put google/flatbuffers.

  "require": {
    "google/flatbuffers": "*"
  }

* PHP's integer is platform dependant. we strongly recommend use 64bit machine
  and don't use uint, ulong types as prevent overflow issue.
  ref: http://php.net/manual/en/language.types.integer.php

* php don't support float type. floating point numbers are always parsed as double precision internally.
  ref: http://php.net/manual/en/language.types.float.php

* ByteBuffer is little bit slow implemnentation due to many chr/ord function calls. Especially encoding objects.
  This is expected performance as PHP5 has parsing arguments overhead. probably we'll add C-extension.

Basically, PHP implementation respects Java and C# implementation.

Note: ByteBuffer and FlatBuffersBuilder class are not intended to use other purposes.
      we may change internal API foreseeable future.

PSR-2, PSR-4 standards.

Implemented simple assertion class (respect JavaScript testcase implementation) as we prefer small code base.
this also keeps CI iteration speed.

we'll choose phpunit or something when the test cases grown.
2015-11-18 00:26:39 +09:00
Shuhei Tanuma 37e28d98ea C# Unity can't cast integer represented enum value.
```
namespace MyGame;

enum CommandType : byte {
	None = 0,
}

table Command {
	id:int;
	type:CommandType;
}
```

then generate c# files. it'll output compile error like these.

```
Assets/MyGame/Command.cs(18,39): error CS1041: Identifier expected
Assets/MyGame/Command.cs(18,39): error CS1737: Optional parameter cannot precede required parameters

16:   public static Offset<Command> CreateCommand(FlatBufferBuilder builder,
17:   int id = 0,
18:   CommandType type = (CommandType)0) {
```
2015-11-17 18:02:59 +09:00
Robert 4725be015d Merge pull request #343 from rw/go-builder-ergonomics
Go: Improve Builder user interface.
2015-11-16 12:18:30 -08:00
rw 3232727ace Python: Improve Builder user interface.
+ Add state to the Builder object to track if we are inside a table,
  and if we are finished building the buffer.
+ Use this data to check that a buffer is being built correctly.
+ Raise an exception if a buffer is not being built correctly.
+ Test that the exceptions happen as expected.

Based on d236dea.
2015-11-11 19:43:53 -08:00
rw 2dfff15a9d Improve Builder user interface.
+ Add state to the Builder object to track if we are inside a table,
  and if we are finished building the buffer.
+ Use this data to check that a buffer is being built correctly.
+ Panic if a buffer is not being built correctly.
+ Test that the panics happen as expected.

Based on d236dea13d.
2015-11-11 17:08:16 -08:00
Wouter van Oortmerssen 4d7810424c Allow structs to be parsed in JSON with out of order fields.
Also simplified the code and made it faster.

Change-Id: I1d83b1165a4a9a4380d1bfb5538769c012d2d367
Tested: on Linux.
2015-10-28 17:54:11 -07:00
Wouter van Oortmerssen d236dea13d Improved C++ asserts for nesting and not finishing buffers.
Change-Id: I82a392bd262b13e978df748bc54b7ac43aec1e15
Tested: on Linux.
2015-10-28 11:57:16 -07:00
Robert 07478a6700 Merge pull request #204 from layzerar/fix_struct_comment
fix comment generation of struct
2015-10-20 13:25:53 -07:00
Wouter van Oortmerssen 525130765a Merge pull request #257 from evanw/javascript
Add support for JavaScript code generation with Google Closure Compiler type annotations
2015-10-19 12:49:16 -07:00
evolutional 9d66af6efc Ported some of the python fuzz tests to C#
* Refactored the test runner to use attribute based test discovery
* Ported value and vtable/object fuzzing tests from python to C#
2015-10-18 17:08:39 -04:00
Evan Wallace 4bef5e89c4 Add UTF-8 support to the JavaScript API
This adds an optional argument to generated getters for string fields to
specify the encoding type and overloads the createString() function. It's
now possible to use either JavaScript UTF-16 string objects or C-style
UTF-8 byte arrays (Uint8Array) for string data.
2015-10-14 23:07:40 -07:00
Evan Wallace 79222bf100 Update monster_test_generated.js baseline after rebase 2015-10-14 23:06:58 -07:00
Evan Wallace 00fd394d23 remove unnecessary return 2015-10-14 21:15:57 -07:00
Evan Wallace e1e8d53df6 Add low-level fuzzer, fix 64-bit issue it found 2015-10-14 21:15:57 -07:00
Evan Wallace 57a6dd472f Add a test for JavaScript UTF-8 <=> UTF-16 conversion
JavaScript uses UTF-16 but FlatBuffers uses UTF-8. This commit tests the code
that does the conversion between the two encodings. The last entry in the array
is tricky because each code point actually requires two UTF-16 code units,
unlike the other examples. The current JSON output of flatc actually handles
this case incorrectly (it generates invalid JSON with UTF-8 code units). The
generated JavaScript code passes these tests fine, however.
2015-10-14 21:15:57 -07:00
Evan Wallace 224e33ed09 Add support for JavaScript code generation
This adds a JavaScript language target. The generated JavaScript uses Google
Closure Compiler type annotations and can be compiled using the advanced
compilation mode, which performs type checking and optimizations such as
inlining and dead code elimination. The generated JavaScript also exports all
generated symbols for use with Node.js and RequireJS. This export behavior
can be turned off with the --no-js-exports flag for use with Google Closure
Compiler.
2015-10-14 21:15:57 -07:00
Wouter van Oortmerssen 94680f5483 Added support for imports and many other .proto features.
Change-Id: I6600021b7ec8c486794349511232c3e604421c5b
Tested: on Linux.
2015-10-13 14:01:55 -07:00
tguo-aa d9db48257b Add self.assertNotNested() in CreateString
And also add a test case.
If you try to nest CreateString you will get a clear exception.
2015-09-29 08:34:10 +08:00
Wouter van Oortmerssen 2abe24b9dd Made .proto parsing understand nested declarations.
Bug: 24401812
Change-Id: I196a03b8c5ef0bcd3c26178239c764e40ca1950d
Tested: on Linux.
2015-09-28 09:48:41 -07:00
Robert 781c39c708 Fix 32bit-system integer overflow (test only)
For #277
2015-09-25 13:57:17 -07:00
Wouter van Oortmerssen feb4816610 Fixed .proto translation making scalars into required fields.
Change-Id: If414d156b4e9bc7fead5f131823b2c419cdc4e2c
Tested: on Linux.
2015-09-25 09:21:31 -07:00
Bruno Bigras edb3b9c307 Remove duplicate Go test 2015-09-21 17:51:16 -04:00
Björn Reimer 5de28c74f9 serialize boolean in JSON to "true/false" instead of "0/1"
Change-Id: I90cf519c00eaf9ccd9fcab8035a91b9205587c3b
2015-09-16 10:31:38 -07:00
Melvi Ts 82a71b18f1 Python: Fix potential code generation issue of documentation comment. 2015-08-28 23:48:28 +08:00
Maxim Zaks ac10873e26 fixed code generator for array of bools
Change-Id: I3cdd801b641bf180222203a37634598350d340e3
2015-08-19 14:39:06 -07:00
Maor Itzkovitch fb7f27a7c9 Merge remote-tracking branch 'upstream/master' 2015-08-15 14:48:59 +03:00
Maor Itzkovitch 7bfed4b29a added vector mutators 2015-08-15 14:48:47 +03:00
Wouter van Oortmerssen e9202d85bd Add missing Python files from type cast commit.
Change-Id: I800119d8fe19f4c3e95772aba629ef8b2deb9e4b
2015-08-12 10:17:10 -07:00