* Fix C/C++ Create<Type>Direct with sorted vectors
If a struct has a key the vector has to be sorted. To sort the vector
you can't use "const".
* Changes due to code review
* Improve code readability
* Add generate of JSON schema to string to lib
* option indent_step is supported
* Remove unused variables
* Fix break in test
* Fix style to be consistent with rest of the code
* [TS] Fix reserved words as arguments (#6955)
* [TS] Fix generation of reserved words in object api (#7106)
* [TS] Fix generation of object api
* [TS] Fix MakeCamel -> ConvertCase
* [C#] Fix collision of field name and type name
* [TS] Add test for struct of struct of struct
* Update generated files
* Add missing files
* [TS] Fix query of null/undefined fields in object api
* Add .Net verfier
* Add some fuzz tests for .Net
* Remove additional files
* Fix .net test
* Changes due to PR
* Fix generated files
---------
Co-authored-by: Derek Bailey <derekbailey@google.com>
* [TS/JS] Entry point per namespace
* Fix handling of outputpath and array_test
* Attempt to fix generate_code
* Fix cwd for ts in generate_code
* Attempt to fixup bazel and some docs
* Add --ts-flat-files to bazel build to get bundle
* Move to DEFAULT_FLATC_TS_ARGS
* Attempt to add esbuild
* Attempt to use npm instead
* Remove futile attempt to add esbuild
* Attempt to as bazel esbuild
* Shuffle
* Upgrade bazel deps
* Revert failed attempts to get bazel working
* Ignore flatc tests for now
* Add esbuild dependency
* `package.json` Include esbuild
* `WORKSPACE` Add fetching esbuild binary
* Update WORKSPACE
* Unfreeze Lockfile
* Update WORKSPACE
* Update BUILD.bazel
* Rework to suggest instead of running external bundler
* Add esbuild generation to test script
* Prelim bundle test
* Run test JavaScriptTest from flatbuffers 1.x
* Deps upgrade
* Clang format fix
* Revert bazel changes
* Fix newline
* Generate with type declarations
* Handle "empty" root namespace
* Adjust tests for typescript_keywords.ts
* Separate test procedure for old node resolution module output
* Fix rel path for root level re-exports
* Bazel support for esbuild-based flatc
Unfortunately, we lose typing information because the new esbuild method
of generating single files does not generate type information.
The method used here is a bit hack-ish because it relies on parsing the
console output of flatc to figure out what to do.
* Try to fix bazel build for when node isn't present on host
* Auto formatting fixes
* Fix missing generated code
Co-authored-by: Derek Bailey <derekbailey@google.com>
Co-authored-by: James Kuszmaul <jabukuszmaul+collab@gmail.com>
* Set an explicit 2018 edition for Rust tests
* Replace all `std` usage with `core` and `alloc` in Rust code generator
* Update the generated files
* Make Rust tests actually use no_std when the corresponding feature is enabled
* fix for rust build
* Rust: Implement Serialize on generated types
For debugging convenience it is really handy to be able to dump out
types as another format (ie: json). For example, if we are logging a
type to a structured logging system, or even printing it out in a
structured way to the console.
Right now we handle this by shelling out to `flatc` which is not ideal;
by implementing Serialize on the generated types we can use any of the
Serializer-implementing packages for our structured debug output.
* clang-format
* Make the flatbuffers Rust crate only have an optional dependency on the `serde` packages.
* fix warning
* fix rust test build
* Oh yeah this needs to be initialized
* fix toml syntax
* code review feedback
* rebuild test data
Augment the C++ generator to emit a C++ copy constructor and a by-value
copy assignment operator. This is enabled by default when the C++
standard is C++11 or later. These additional functions are only emitted
for objects that need it, typically tables containing other tables.
These new functions are declared in the object table type and are
defined as inline functions after table declarations.
When these new functions are declared, a user-defined
explicitly-defaulted default constructor and move constructor are also
emitted.
The copy assignment operator uses the copy-and-swap idiom to provide
strong exception safety, at the expense of keeping 2 full table copies
in memory temporarily.
fixes#5783
* Enable --gen-onefile in Python
Made it possible to generate all python code in one file. Modified
py_test.py so that it can switch between the multi-file code and
the one-file code.
Updated PythonTest.sh and py_test.py so that the multi-file code
and the one-file code can be tested based on the same test code.
* Sync with google/flatbuffers
* Add --gen-onefile to generate_code.py
* Keep methods with struct name and switch them to default
This PR can help fix the following two issues:
1): A set of simplified API (without struct name) was added in
https://github.com/google/flatbuffers/pull/6336. It causes name
conflict when merging all generated python file into a single one
(the primary usage senario in Google).
2): Flatbuffers 2.0 generates absolute import path, which may cause
name space conflicts. See more details in
https://github.com/google/flatbuffers/issues/5840.
The solution for both is to generate the merged Python code, similar
C++. The merged code will not contain the simplied API, but only the
method with struct name. For issue (1), it will mimic the exactly
usage pattern for Google internal. For issue (2), users can generate
the merged flatbuffer code, without worrying about the imports.
The above idea will be implemented in the following steps:
Step 1 (this PR): revert changes in https://github.com/google/flatbuffers/pull/6336
that set the simplified API as default. Remove statements that the
original API will be deprecated, and reset the original API as default.
Step 2 (the following PR): create a flag to generate the merged code.
The Simplified API will be removed from the merged code, otherwise it
will cause name conflict.
* Update the generated sample code
* Update the generated example code
* Reverst the changes of GetRootAs
* Update examples from grpc/example/generate.sh
* CPP Default Value Generation in Mutators
If the mutator is for a value that is compatible with having a default value, then the single parameter becomes a default parameter. With this, a value can be mutated to it's default value without storing the default value, as that will be stored with the mutate function.
Fixed Casting When Generating Default for Enum Value
Added support for typecasting an int default value into the correct enum type in the default parameter. This fixed the issue of trying to use set a strongly typed enum parameter to an int which fails type checking.
Fixed Boolean Edge Case
Boolean types generate 0 != 0 when generating the underlying type which appears to be unique to the boolean type so it is now checked and the proper default value generated. It may be beneficial to check if it is instead an enum type, however the seeming edge case nature is why boolean was chosen to be checked.
Updated Generated Files
Regenerated the auto generated files to reflect the new changes.
Updated Remaining Files
Should fix auto generated header files that were not updated.
* Unified Repeated Code
Relocated identical append code to outside of conditional. Also changed 'casted' default value name from FIELD to INTERFACE to more accurately describe it.
* Moved Field Name Outside Conditional
Removed duplicate _{{FIELD_NAME}} and moved to unified append.
* Remove dead code in idl_gen_rust
* Use 2space indentation in mod.rs
* use In/DecrementIdentValue in idl_gen_rust
Fix some whitespace too in generated code.
* make default fn 2space ident
* More 2space formatting
* git clang format
* make vs2015 happy
Co-authored-by: Casper Neo <cneo@google.com>
Causes generated code to check for existing pointers in an object (when using the object based api) and use UnPackTo(existingPointer) rather than just using UnPack() to replace the pointer. This is a performance issue when unpacking to existing objects when using large buffer fields (e.g. image frames)
Co-authored-by: RobWauson <robwauson@gmail.com>
* [C#] add union constructor utility.
* add union utility test.
* std::tolower -> CharToLower
* use std::transform instead
* rebase to master. and regenerate test code
* Refactored Rust Generated code into a module directory.
Each symbol will be generated into one file and then
imported into a module. This breaks the "out_dir"
pattern where some users would generate code in their
target/ directory. Also, these objects are best used
in their own module. It will be hard for users to share
their own module structure with flatbuffers namespaces.
There may be solutions to these drawbacks but that should
be discussed. I don't want to overengineer here.
* shadow error
* try fix .bat file
* fix .bat 2
* Restore accidentally deleted files
* Fixed some DONOTSUBMITs and made Rust outdir pattern use symlinks.
* fixed binary files
* git clang format
* make generated onefiles not public and fix .bat
* reduced diff with master in generate_code.sh
* fix shadowed variable
* add object api flags to .bat
* space
* Removed extern crate and extra &
* use statement
* more clippy lints
* format
* Undo extern crate -> use change, it actually matters to our tests
Co-authored-by: Casper Neo <cneo@google.com>