* 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
* Add option --no-warnings to inhibit all warnings
* Fix order of member initialization
* Add documentation for --no-warnings
Prior to this commit the default C++ code generator was `c++0x`.
A code generated with `c++0x` code-gen might have a vulnerability (undefined behavior) connected evolution of enums in a schema. This UB could break the backward compatibility if previously generated code casts an unknown enumerator to enum type that knows nothing about future enumerators added to the schema.
The main differences between `c++0x` and `c++11`:
- generated enums use explicitly declared underlying type;
- generated object-API tables don't declare default ctor() explicitly, instead of it default data member initializers are generated.
Please use `flatc --cpp-std c++0x` option for backward compatibility with old compilers.
* Add --require-explicit-ids to require explicit ids
We just got bit by a well intentioned developer forgetting that field
order by default is the field index. 3 people missed it in review.
I'm looking at ways to make it harder to mess up. We are requesting
that developers explicitly id all fields in tables. Automatic (opt in
for others) enforcement of this will help the effort succeed. This
patch adds a command line flag which lets the user require ids on all
fields in tables.
* Added docs to Compiler.md as well
* Add option to not generate direct copy methods.
The direct copy methods generated by flatc utilize std::vector which isn't allowed on some embedded systems. Permit users of the compiler to not generate these methods so they don't have to be stubbed out.
* Update docs for no-cpp-direct-copy option.
* [C#] Fix and improve project files
* "net35" target included for Unity 5
* "net46" target included for Unity 2017
* "netstandard2.0" target included for Unity 2018 and general use
* "netstandard2.1" target included for Span<T> support
Included project properties for defining UNSAFE_BYTEBUFFER, BYTEBUFFER_NO_BOUNDS_CHECK, and ENABLE_SPAN_T conditional compilation symbols.
* Add documentation on building for C#
* [C#] Fix and improve project files
* "net35" target included for Unity 5
* "net46" target included for Unity 2017
* "netstandard2.0" target included for Unity 2018 and general use
* "netstandard2.1" target included for Span<T> support
Included project properties for defining UNSAFE_BYTEBUFFER, BYTEBUFFER_NO_BOUNDS_CHECK, and ENABLE_SPAN_T conditional compiler constants.
* Add documentation on building for C#
* Attach JvmStatic annotation to each method of companion object
Kotlin does not have static accessor so companion object used instead of static.
It's so natural. But when use kotlin companion object methods on java it is very inconvenient.
```java
GeneratedClassByFlatBuffer.Companion.someMethod()
```
If use @JvmStatic annotation it can be shorten like below.
```java
GeneratedClassByFlatBuffer.someMethod()
```
* Formatting by Idea Google C++ style
* Add comments - Commit for missing cla
Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Add comments - Commit for missing cla
Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Reset code formatting except modified lines
Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Pass missing flag to validateVersion method
Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Add annotations to missing method in companion object
* addVector
* createVector
* endVector
* tableCreator
And also I tried add compiler option for generate annotation who don't like this operation.
Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Modify unmatched option name in compiler usage
Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Add missing operation for finishSizePrefixed and finishStructBuffer method.
Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Add compiled example with --kotlin-gen-jvmstatic option.
Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Fix Compiler.md
Change option name from --gen-jvm-static-annotation to --kotlin-gen-jvmstatic
Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Use IDLOptions reference instead of bool parameter.
Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Change option name - kotlin_gen_jvmstatic to gen_jvmstatic
Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Use IDLOptions reference instead of bool parameter and missing process @JvmStatic as suffix.
Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Add code generation for --gen-jvmstatic option
Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Miss typo directory for including.
Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Miss typo variable suffix for including.
Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Fix camel case to snake case.
Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Rollback generate code for gen_jvmstatic option.
Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Delete generated test files.
Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* add missing new line at end of file.
Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
* Remove generated test file by command line.
Signed-off-by: Yoon KyongSik <sam1287@gmail.com>
Co-authored-by: sam <sam@jennifersoft.com>
* use correct language formatter for TypeScript examples
* fixes typo in JS/TS copied from PHP (apparently)
the variables are not named with a prefixed `$`
* fixes bizarre line breaks in markdown examples
* fixes snake case typo to fit JS/TS conventions
* makes example of Uint8Array usage explicit
* removes random extra lines between language blocks
* adds simple example for writing to file in node
* typo: flabuffers => flatbuffers
* adds (previously missing) code blocks to TypeScript code block
* adds context about where `monster_generated` comes from
to the uninitiated, a bit of help like this is welcome
* Moves addition to overflow addition in swift by using &+
Moves code to use Int instead of UInt32 & fixes functions
Updates swift performance to great
Updated version to 0.5.2
Updated swift package version to 5.2
Updated docker to swift 5.2
Removed all none & arithmetic operations
* Small refactoring
* updates monsterdata.json to be valid json
the same monster.json file was not valid json
* updates reference to monsterdata.json in docs to also be valid json
* added basic code
* backup work
* got class property to work
* backup progress
* implementented fmt for creating code
* added docs for genFieldUtils
* back up work
* added base helper js func
* added union js code
* added unpackTo and base for pack
* added pack code
* added null check for packing struct list
* passes compile test
* fixed some spacing of generated functions
* added annotations for constructors
* added obj api unpack test
* tested pack to work
* merge branch
* separated js and ts test
* fixed union signature to include string
* fixed generator to support string union
* hardcoded fb builder name
* refactored struct vector creation
* work around createLong
* handle default value in constructor
* update typescript docs
* added notes about import flag
* fixed formatting stuffs
* undo TypescriptTest change
* refactored fmt
* updated generated code
* remove ignoring union_vector for js
* revert changes for .project
* revert changes for package.json
* don't generate js in ts test
* fixed android project file
* removed unused js function
* removed package-lock.json
* adjust createObjList to new signature
* changed regex to callback style
* fixed package.json
* used existing func for generating annotation
* changed ternary to !!
* added return type for lambda
* removed callback style for obj api generator
* fixed js file indentation
* removed unused header
* added tests for string only union
* handle string only union and refactor union conv func
* updated generated ts files
* renamed union conv func
* made js test create files like other languages
* removed union string only handling
* don't allow null in createObjectOffsetList
* updated generated ts code
* changed the line that triggers Windows build errors
* hopefully fix CI error
* [Flatbuffer] Generate code for force_align with CreateXDirect and Pack functions.
* Fixed Visual Studio 10.0 compile error for std::to_string.
* Fixed Visual Studio 10.0 compile error for std::to_string.
* Fixed refractoring issue in reflection/generate_code.sh. Also, mv deletes the original file, so I don't need to clean it up manually in that case.
* Added --filename-suffix and --filename-ext to flatc
* Fixed typo and added example generation of suffix and extension for C++
* Removed extra ;
* Removed clang-format block from a region that didn't need it. Fixed an auto format of another clang-format block
* Added docs, fixed pointer alignment, removed suffix test file
* [C#] support Object API
* fix sign-compare
* fix indent
* add new line before for loop.
* using auto whenever possible
* reduce the amout of blank lines.
* wip: support vectors of union
* done: support unions of vectors
* set C# version to 4.0
* remove null propagation operator
* remove auto property initializer
* remove expression-bodied method
* remove pattern matching
* add Example2 to NetTest.sh
* separate JavaUsage.md and CsharpUsage.md from JavaCsharpUsage.md
* add C# Object based API notes.
* support vs2010.
* remove range based for loop.
* remove System.Linq
* fix indent
* CreateSharedString to CreateString
* check shared attribute
* snake case
* Implemented the swift version of Flatbuffers
Implemented serailzing, reading, and mutating data from object monster
Fixes mis-aligned pointer issue
Fixes issue when shared strings are removed from table
Adds swift enum, structs code gen
Fixed namespace issues + started implementing the table gen
Added Mutate function to the code generator
Generated linux test cases
Fixed an issue with bools, and structs readers in table writer
Swift docker image added
Updated the test cases, and removed a method parameters in swift
Fixed createVector api when called with scalars
Fixed issues with scalar arrays, and fixed the code gen namespaces, added sample_binary.swift
Cleaned up project
Added enum vectors, and their readers
Refactored code
Added swift into the support document
Added documentation in docs, and fixed a small issue with Data() not being returned correctly
Fixes Lowercase issue, and prevents generating lookups for deprecated keys
* Made all the required funcs to have const + removed unneeded code + fix lowercase func
* Removed transform from lowercased and moved it to function
* Fixes an issue with iOS allocation from read
* Refactored cpp code to be more readable
* casts position into int for position
* Fix enums issue, moves scalar writer code to use memcpy
* Removed c_str from struct function
* Fixed script to generate new objects when ran on travis ci: fix
* Handles deallocating space allocated for structs
* Updated the test cases to adhere to the fileprivate lookup, no mutation for unions, and updated the names of the vector functions
* Add flatc '--cpp_std' switch and sandbox for C++17 code generator
- Added 'flac --cpp_std legacy' for compatibility with old compilers (VS2010);
- Added experimental switch 'flac --cpp_std c++17' for future development;
- Added C++17 sandbox test_cpp17.cpp;
- C++ code generator generates enums with explicit underlying type to avoid problems with the forward and backward schema compatibility;
- Adjusted CMakeLists.txt, CI and generate code scripts to support of introduced '--cpp_std';
* Fix --cpp_std values: c++0x, c++11, c++17
* Add 'cpp::CppStandard' enum
* Add testing engine into test_cpp17
* Rebase to upstream/master
* Set default '--cpp-std C++0x'
* Fix code generation (--cpp_std C++11) in CMakeLists.txt
- Fix dependency declaration of grpctest target
* Revert --cpp-std for the tests from explicit C++11 to flatc default value (C++0x)
The rationale for this option is that JSON clients typically want empty arrays (i.e [] in the JSON) instead of missing properties, but not empty strings when the value isn't set.
--force-empty is kept as-is, i.e. it will force both empty strings and vectors.
Closes#5652
* Flatbuffers Python Object API
Implement the logic to generate the Python object API that can
unpack the data from a buf class into an object class, and pack
the data of an object class to a buf class.
* Fix the build issues
Remove unused parameters and replace auto in the for-loop statement
with std::string to make it compatible with VS2010.
* Fix the build issues.
* Add support for Array type
Added logic to handle Array type in Python Object API. Updated the
generated code accordingly.
* Fix the old style casting from int to char
* Fixed another conversion from int to char
* Fixed the import for typing
Importing typing may cause errors when a machine do not have the
moduel typing installed. This PR fixes the issue by guarding
"import typing" with the "try/except" statement.
* Fix issue of iterating the vector of import list
* Update the generated examples using generate_code.sh
* Fix the import order for typing
The import list was stored in unordered_set, so that each generated
codes may have different import order. Therefore, it failed in the
consistency test where two generated copies need to have exactly the
same apperance.
* Optimize unpack using numpy
Use numpy to unpack vector whenever it is possible to improve unpack
performance.
Also, added codegen command for Python specificly in generate_code.sh,
because --no-includes cannot be turn on for Python.
* Fix the import order
* Update generate_code.bat for windows accordingly
* Replace error message with pass
Avoid printing error message for every Python2 users about typing.
Replace it with pass.
* [Kotlin] Add kotlin generate code for tests and add
kotlin test to TestAll.sh
* [Kotlin] Add Kotlin generator
This change adds support for generating Kotlin classes.
The approach of this generator is to keep it as close
as possible to the java generator for now, in order
to keep the change simple.
It uses the already implemented java runtime,
so we don't support cross-platform nor js Kotlin yet.
Kotlin tests are just a copy of the java tests.
* Add optional ident support for CodeWriter
Identation is important for some languages and
different projects have different ways of ident
code, e.g. tabs vs spaces, so we are adding optional
support on CodeWriter for identation.
* [Kotlin] Add Documentation for Kotlin
* [Kotlin] Modify generated code to use experimental Unsigned types.
* Extend the test of MonsterExtra
- Extend C++ test of MonsterExtra
- Add conversion of fbs/json NaNs to unsigned quiet-NaN
- Update documentation (cross-platform interoperability)
* Fix declaration of infinity constants int the test
* [docs] Added an example on how to convert a FlatBuffer binary to JSON
Slightly adjusted section on "Using flatc as a conversion tool".
Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
* [docs] Updated obsolete JSON data in example showing how to convert JSON to FlatBuffer binaries.
Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
* c++: Add command line option to add extra includes to gen files
Fixes#5351
We have an ability to pass custom types for strings, allocators, etc
but have no way to tell the generator to include the classes in gen code
* c++: remove std::strtok for std::string methods. passes msvc compile
* generate_code.sh: add --cpp-includes to the test gen script
* tests:generate.bat: update code gen scripts w/ --cpp-includes
* cpp: use command line parsing for extra includes
s/--cpp-includes/--cpp-include/g
Simplify command line parsing of includes by using a std::vector.
* cpp: idl.h: move std::vector for cpp_includes as the last member
msvc does not understand initalization list on our CI server
* cpp:msvc: CI fails on for-range loops
* cpp:codegen: fix error reporting on flatcc
* as per code review: remove unwated --cpp-include in the
tests/generate_code.{sh,bat}