Multiple calls of e.g. CreateString inside a call to a CreateTable
could cause those strings to end up in different locations in the
wire format, since order or argument evaluation is undefined.
This is allowed by the FlatBuffer format, but it is not helpful,
especially when debugging the contents of binaries, or comparing
against a "golden" binary for tests etc.
Now making sure that all the CreateTableDirect calls first serialize
sub strings/vectors before calling CreateTable.
Also made similar changes to the serialization of "binary schemas".
Change-Id: I5747c4038b37a0d400aca2bc592bec751cf5c172
Some generic C++ and Rust code is not generated when unions use type
aliases because of potential ambiguity. Actually check for this
ambiguity and only disable offending code only if it is found.
This is because they are incompatible with C++ and possibly other
languages that make them minimum size 1 (to make sure multiple
such objects don't reside at the same address). Forcing them to size
1 was also not practical, as that is requires updating the logic
of a lot of implementations and thus possibly backwards incompatible.
More here: https://github.com/google/flatbuffers/issues/4122
Change-Id: I2bfdc8597b7cfd2235bb4074bb2ae06f81f8e57d
armeabi support was removed from the Android NDK so we should no
longer build it. Since this fixes the Android build failures this
commit also re-enables Travis Android builds.
While re-enabling Android builds, some recent changes broke C++98
support so this fixes those issues as well which include:
- Conditionally compiling use of move constructors, operators and
std::move.
- Changing sample to use flatbuffers::unique_ptr rather than
std::unique_ptr.
Finally, added the special "default_ptr_type" value for the
"cpp_ptr_type" attribute. This expands to the value passed to
the "--cpp-ptr-type" argument of flatc.
* Added Get<vector_name>Array() method for accessing vectors of structures in C# using Buffer.Blockcopy().
* Added Get<vector_name>Array() method for accessing vectors of structures in C# using Buffer.Blockcopy().
Added Create<Name>VectorBlock() method to add a typed array using Buffer.BlockCopy() to speed up creation of vector of arrays
New Lua files for namespace test
* fixed c++ style issue
* initial changes to support size prefixed buffers in Java
* add slice equivalent to CSharp ByteBuffer
* resolve TODO for slicing in CSharp code generation
* add newly generated Java and CSharp test sources
* fix typo in comment
* add FinishSizePrefixed methods to CSharp FlatBufferBuilder as well
* add option to allow writing the prefix as well
* generate size-prefixed monster binary as well
* extend JavaTest to test the size prefixed binary as well
* use constants for size prefix length
* fuse common code for getRootAs and getSizePrefixedRootAs
* pulled file identifier out of if
* add FinishSizePrefixed, GetSizePrefixedRootAs support for Python
* Revert "extend JavaTest to test the size prefixed binary as well"
This reverts commit 68be4420dd.
* Revert "generate size-prefixed monster binary as well"
This reverts commit 2939516fdf.
* fix ByteBuffer.cs Slice() method; add proper CSharp and Java tests
* fix unused parameter
* increment version number
* pulled out generated methods into separate utility class
* pulled out generated methods into separate utility class for Python
* fix indentation
* remove unnecessary comment
* fix newline and copyright
* add ByteBufferUtil to csproj compilation
* hide ByteBuffer's internal data; track offset into parent's array
* test unsafe versions as well; compile and run in debug mode
* clarify help text for size prefix
* move ByteBuffer slicing behavior to subclass
* fix protection levels
* add size prefix support for text generation
* add ByteBufferSlice to csproj compilation
* revert size prefix handling for nested buffers
* use duplicate instead of slice for removing size prefix
* remove slice subclass and use duplicate for removing size prefix
* remove slice specific tests
* remove superfluous command line option
* added intended use-cases to monster_test.fbs
* added check for `cpp_ptr_type` on hashed fields
added default value 'naked' to `cpp_ptr_type` on hashed fields
* added C++ generation of cpp_type vectors
removed ctor call for vector fields
added condition !vector for cpp_type check
added Pack() and UnPack() code generation for vector of hashes
added generation of correct resolve/rehash for cpp_type elements
* added attribute 'cpp_ptr_type_get' to hold accessor for pointer types possible where '.get()' does not work
use case: cpp_ptr_type:"std::weak_ptr", cpp_ptr_type_get:".lock().get()"
* run flatc to re-generate headers
* added bool param is_ctor to GetDefaultScalarValue() to differentiate between usage places
* modified monster_test.fbs to remove usage of shared_ptr/weak_ptr
reason: STLport does not support std::shared_ptr and std::weak_ptr
* run flatc again to re-generate headers
* fixed symbol unique_ptr not in namespace std when building with STLport
It was missing some helpers when we choose to use
size prefixed FlatBuffers.
* Add general helper : GetPrefixedSize
* Add generated helpers :
* GetSizePrefixedXXX
* VerfifySizePrefixedXXXBuffer
* FinishSizePrefixedXXXBuffer
* Eclipse ignore
* TypeScript support
* Prefixing enums
* Test results
* Merged JS and TS generators
* Fixed AppVeyor build problems
* Fixed more AppVeyor build problems
* Fixed more AppVeyor build problems
* Changed TS flag to options struct
* Storing options by value
* Removed unneeded const
* Re-export support for unions
* Uint support
* Casting bools to numbers for mutation
* TS shell tests
* Reverted generates js test file to original version
* Backing up js tests and properly generating test data
* Not importing flatbuffers for TS test generation
* Not overwriting generated js for tests
* AppVeyor test fixes
* Generating the most strict TS code possible
* Not returning null when creating vectors
* Not returning null from struct contructors
* Vector of unions for ts/js
* Sanity check for languages
* Indentation fix + output test files
* Vectors of unions for php
* Fixes to union vector handling + tests
* Fix for strictPropertyInitialization
A Namespace object is now guaranteed unique.
This cleaned up some old workarounds and latent bugs.
Change-Id: Ic3f12d89947871b03b2c449ba51b3186f953adde
Tested: on Linux.
Bug: 21336857
This is something the format supports, but none of the builders
were doing. Can save 10-20% on FlatBuffer binary size!
Also fixed the Go tests.
Change-Id: I616c56ce9bbcfcaee23aa24f0532fcb60b6a8c75
Tested: on Linux.
* Add numpy accessor to python flatbuffers scalar vectors
* Update python tests to test numpy vector accessor
* Update appveyor CI to run Python tests, save generated code as artifact
* Update example generated python code
* Add numpy info to python usage docs
* Update test schema and python tests w/ multi-byte vector
* did not mean to push profiling code
* adding float64 numpy tests
* Added internal - limited - implementation of flatbuffers::unique_ptr
for STLs that don't ship with std::unique_ptr. In C++11 and beyond
this is just an alias for std::unique_ptr.
* Aliased used type traits structs is_scalar is_floating_point is_unsigned
into flatbuffers namespace so they can be replaced in C++98 implementations.
Right now these point at stlport's TR1 implementations.
* Wrapped vector::data() in vector_data().
* Wrapped vector::emplace_back() in vector_emplace_back().
* Wrapper string::back() in string_back().
* Added variants of FlatBufferBuilder::CreateVector() and
FlatBufferBuilder::CreateVectorOfStructs() that allow the use of plain
function pointers.
Generated code has also been modified to use plain functions to build objects
rather than std::function() so all generated code will work in C++98
applications.
* Added flexbuffers::Builder::Vector(), flexbuffers::Builder::TypedVector()
and flexbuffers::Builder::Map() methods that allow the use of plain function
pointers.
* Changed Parser to internally use plain function pointers when parsing table
and vector delimiters.
* Added specializations of NumToString() for 64-bit types that aren't supported
by stringstream in stlport.
* Overloaded numeric_limits for 64-bit types not supported by stlport.
* Replaced build_apk.sh (which was broken by deprecation of the
"android" tool in the Android SDK) with build.gradle and the
appropriate gradle wrapper to build an APK.
* Switched Android build to build against all STL variants.
* Updated travis configuration to build Android test and sample.
Tested:
* Verified all tests continue to work on Linux, OSX and Android.
* Verified Travis build is green.
Change-Id: I9e634363793f85b9f141d21454b10686020a2065
* Added empty generator for json schema (idl_gen_json_schema.cpp)
#4360
* JsonSchemaGenerator: output of tables implemented
current problems:
- typenames are not correct
- array types need to be deduced
#4360
* JsonSchemaGenerator: Corrected generation of typenames
Current problems: enum types not written correctly
#4360
* JsonSchemaGenerator: Added generation of enum types
#4360
* idl_gen_json_schema.cpp: Write required properties to schema
#4360
* idl_gen_json_schema.cpp: Export Types including namespace
#4360
* idl_gen_json_schema.cpp: Fixed Json format
#4360
* idl_gen_json_schema.cpp: Formatted according to google code style
#4360
* Checked in monster_test.bfbs with changes from master
* Added idl_gen_json_schema.cpp in CMakeLists.txt
* generate_code.bat: Added generation of json schema
* Added todo.md
* generate_code.sh: Added generation of json schema
* Addressed some review issues
- removed command line arg -S
- removed new lines
- fixed codestyle in template functions
- removed usage of stringstream
- idented json schema
#4360
* removed auto in idl_gen_json_schema.cpp
* idl_gen_json_schema.cpp: changed iterator declarations to auto
#4360
* deleted todo.md
* idl_gen_json_schema.cpp: Removed keyword "override" so that vs2010 can compile
* idl_gen_json_schema.cpp: switch statement in GenType handeles all enum-members
* idl_gen_json_schema.cpp: Removed cerr output
* idl_gen_json_schema.cpp: Avoid vector copying
* idl_gen_json_schema.cpp: Fixed identation of json schema output
* idl_gen_json_schema.cpp: Do not output empty descriptions
* Eclipse ignore
* TypeScript support
* Prefixing enums
* Test results
* Merged JS and TS generators
* Fixed AppVeyor build problems
* Fixed more AppVeyor build problems
* Fixed more AppVeyor build problems
* Changed TS flag to options struct
* Storing options by value
* Removed unneeded const
* Re-export support for unions
* Uint support
* Casting bools to numbers for mutation
* TS shell tests
* Reverted generates js test file to original version
* Backing up js tests and properly generating test data
* Not importing flatbuffers for TS test generation
* Not overwriting generated js for tests
* AppVeyor test fixes
* Generating the most strict TS code possible
* Not returning null when creating vectors
* Not returning null from struct contructors
* Added <autogenerated> in cs generator file header comment
#4287
* CS: Added xml-correct file header comment including "<auto-generated>...</auto-generated>"
code_generators.cpp: FlatBuffersGeneratedWarning() function replaced by compile time constant "GeneratedWarning"
also removed extra newlines at end of GeneratedWarning to be able to generate a xml well formed file comment for cs files
#4291
* code_generators: Changed static string GeneratedWarning back to function FlatBuffersGeneratedWarning()
#4291
* Added modified Unit-Test files
#4291
* idl_gen_general: Add autogenerated only in C# code
#4291
* Don't fail the build on unused parameters
gRPC headers have unused parameters so this breaks the test build.
* Pull in updated compiler files from gRPC
There have been some API breaks in gRPC lately. This commit
pulls in the most recent version of the files in this repo
that are just copied from gRPC.
* Modify the gRPC files so that they can work with Flatbuffers
The files taken from gRPC do not work out-of-the-box with Flatbuffers.
This commit modifies them so that they work. Hopefully this commit
will be able to serve as a guide or maybe even be cherry-picked on
top of new versions of those files as newer versions from gRPC are
pulled in.
* Adjust the rest of Flatbuffers to work with the new gRPC
* Change idl_gen_grpc.cpp to work with the new API
* Add missing #include in flatbuffers/grpc.h
* Run tests/generate_code.sh and check in the results
* Don't link with grpc++_unsecure and (secure) grpc. That's just weird
* Revert unrelated JS/TS test changes
* Simplify compiler/config.h
There is no need to import this file from gRPC. In fact, it probably
makes sense to not do so, since it seems to be intended to have
project specific configuration in it.
* Don't emit C++ types in the Go gRPC code generator
* Don't emit C++ #includes in generated gRPC code
Before this PR, there was a Go-specific additional_includes method
in schema_interface.h, which is shared with the gRPC repo. The
additional parameter to FlatBufFile in idl_gen_grpc.cpp makes that
unnecessary, which means we need less Flatbuffer-specific changes
in gRPC.
(C++ only for now).
Also fixed vector of union support in the object API.
Bug: 36902939
Change-Id: I935f4cc2c303a4728e26c7916a8ec0adcd6f84cb
Tested: on Linux.
* 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
* 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
* 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.
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