Add the --no-minmax-values flag to prevent flatc from generating C++
enums with MIN and MAX enumerated values that otherwise would be set
to the inclusive lower and upper bound respectively of the enum.
This command-line flag is needed to avoid collisions when an enum that
is being ported to FlatBuffers already has a MIN or MAX enumerated
value.
It is also needed to work around a long-standing problem with
magic_enum that causes magic_enum to not see enumerated values that
are not unique. For example, if FlatBuffers sets MIN = FOO and MAX =
BAR, MIN and FOO share the same underlying value so they are not
unique. The same is true of MAX and BAR. This prevents magic_enum
from converting FOO and BAR to and from strings as well as causing
magic_enum to return a count of enumerated values that is two fewer
than it should be.
Co-authored-by: Paul Serice <paul@serice.net>
I think these changes reflect the current state, but I found it hard to
track the state of some of the planned work. Hence why it'd be good to
have it documented :)
I also expanded some sections that I found misleading, as somebody
familiar with Rust and FlatBuffers separately. Parts of these pages seem
to be aimed at people familiar with FlatBuffers (ie via the other
documentation pages) but not each language, which I'm trying to
preserve. However, Rust does some things differently, and as somebody
with expectations about how typical Rust APIs work the discussion of
threading made me wonder what was different.
Parsing as bytes produces buffers that are unsafe to access unless passed thru a verifier,
whereas users could reasonably assume that any JSON parsed without errors is safe to access.
Users that still have legacy JSON files with such bytes in it will get a helpful error point them
to the option to turn on to have it work again.
* 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
* Update idl_gen_csharp.cpp
Change csharp generator to use "global::" for it's qualifying_start_ to disambiguate namespaces
* regenerate testing files
regenerate testing files
* Missed TableInC.cs
updated with global prefix
* Remove "global::" from qualifying_start_ for csharp generator
* C# global alias
* Tests and docs for --cs-global-alias
Add tests for --cs-global-alias to demonstrate use case for why it's needed.
Add documentation to Compiler.md
* Add also to help text
Add also to help text
* Fixup CPP documentation's markdown errors
Note that I couldn't get the ~~~{.cpp} method to work,
so I switched to using ```cpp which did work.
* Fixup C++ docs, typo in repeated code example
Co-authored-by: Paul Harris <paulharris@computer.org>
* Make --bfbs-filenames default to location of first schema file.
Make RelativeToProjectRoot always work, applying "../" where needed. This is
needed for backwards compatibility. The first input file may be deeper in some
directory than the other files. Now, there will always be a declaration
file.
* documentation
* clang format
Co-authored-by: Casper Neo <cneo@google.com>
* dart test scripts - generate with `--gen-object-api`
* Dart object API, pack and unpack methods (WIP)
* Dart flatc - extract Builder code to separate functions to reuse it in Pack()
* Dart flatc - use builder field-building implementation in pack()
* Dart flatc - add pack() as an intance method of the "T" class
* Dart object API - make inner fields unpacked as well
* Dart object API - use pack() when collecting field offsets
* Dart object API - use packOnce() for fields that are structs or vectors of structs
* Dart object API - remove obsolete union support TODO
* Dart object API - minor review changes, test and fixes
* Dart object API - revert packOnce() - not supported by other object API implementations
* Dart object API - update docs
* update dart generated code in tests/ to fix CI failure on ./scripts/check-generated-code.sh
* Dart flatc - fix compilation for old MSVC and c++0x
* [Lua] Add LuaJIT support
Here is the output of LuaTest.sh:
Run with LuaJIT:
built 100 512-byte flatbuffers in 0.16sec: 0.63/msec, 0.31MB/sec
built 1000 512-byte flatbuffers in 0.08sec: 12.06/msec, 5.89MB/sec
built 10000 512-byte flatbuffers in 0.80sec: 12.44/msec, 6.07MB/sec
built 10000 512-byte flatbuffers in 0.33sec: 30.58/msec, 14.93MB/sec
traversed 100 592-byte flatbuffers in 0.04sec: 2.51/msec, 1.42MB/sec
traversed 1000 592-byte flatbuffers in 0.03sec: 31.52/msec, 17.79MB/sec
traversed 10000 592-byte flatbuffers in 0.21sec: 48.77/msec, 27.53MB/sec
Run with Lua 5.3:
built 100 512-byte flatbuffers in 0.02sec: 5.44/msec, 2.66MB/sec
built 1000 512-byte flatbuffers in 0.17sec: 5.74/msec, 2.80MB/sec
built 10000 512-byte flatbuffers in 1.75sec: 5.72/msec, 2.79MB/sec
built 10000 512-byte flatbuffers in 1.38sec: 7.26/msec, 3.55MB/sec
traversed 100 592-byte flatbuffers in 0.00sec: 27.64/msec, 15.60MB/sec
traversed 1000 592-byte flatbuffers in 0.03sec: 30.46/msec, 17.20MB/sec
traversed 10000 592-byte flatbuffers in 0.34sec: 29.62/msec, 16.72MB/sec
* [Lua] Better usage description
* update according to the review
* [C++] #6501 - Problem when mapping a native type multiple times
- idl.h:
added "native_type_pack_name"
- flatbuffers.h:
added CreateVectorOfNativeStructs variants which receive a pointer to the serialization function
- idl_gen_cpp.cpp:
adapted code generation in case "native_type_pack_name" attribute is present
- extended tests & docs; improved surrounding native_type docs a little
* integrated review feedback
* [Build, cmake] Add -Werror override option
This commit adds FLATBUFFERS_CXX_FLAGS cmake option.
This option allows override the -Werror flag (or any other flags).
Related issues: #6337, #5930
* Remove CMAKE_CXX_FLAGS replace option
* Remove a lot of redundancy from the Python generated code.
Update tutorial to reflect new Python generated code.
* Add aliases for newly deprecated Python generated methods.
This should help with backwards compatibility.
* Fix incorrect names in deprecated comments.
I'm also clarifying that while elements are not deduplicated, vectors
may contain more than one offset to the same value.
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
This is an attempt to explain how FlatBuffers encodes union types as an
extra section in the "FlatBuffers internals" document.
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
* TS/ES6 modules spike iteration 1
* Initial modularized dasherized output
* Remove obsoleted parts and namespace wrapping
* Use _flatbuffers_ prefix
* First part of imports logic
* Second part of imports logic
* Fix TS/JS code removal mixup
* Alias imported symbols if same name from different namespaces and some fixes
* Use star import for bare imports
* Fix messed up string concat
* var to const and remove not needed semi
* Remove some cases of ns prefixing
* Add missing space
* Cleanups
* Completed initial import tracking logic
* Compilable output
* Adjust TypeScriptTest and dependents to work
* Use local flatbuffers package for tests
* Refactor away use of any
* Remove obsolete imported_fileset and reexport_map
* Still need any and fix JavaScriptTest.sh
* Fix test runs out of the box
* Temp add generated files
* TypeScriptTest replaces JavaScriptTest and cleanups
* Also remove reference to JavaScriptTest in TestAll.sh
* Remove old generated ts/js files
* Remove use of --js in generate_code scripts
* idl_gen_js_ts to idl_gen_ts and removal of js gen
* Remove obsoleted options
* Fix obsolete ts test detection
* Tweak ts compilation be as strict as possible
* Remove jsdoc type annotation generation
* Generated test ts files
* Fix search and replace messup
* Regenerated ts test output
* Use CharToLower
* Use normal for loop
* Rework namespacedir
* Revert "Rework namespacedir"
This reverts commit 6f4eb0104ceeb86011bb076ebca901138c48e068.
* Revert "Use normal for loop"
This reverts commit 676b2135bfaa1853dfbb06c92b5c16a0d81bb13a.
* Revert "Use CharToLower"
This reverts commit 2d08648d0d72d0af201fad80d54cdc76412b35e9.
* Again do rework but correct
* Avoid runtime cast
* Fix test runs
* Also add npm install to get tsc
* Bump node test versions
* for range to std for loop
* Clang format
* Missed one clang format
* Move accessor to later
* Attempt to make windows version of TypeScriptTest
* Want to see the output
* Try to get newer node at appveyor
* Style changes
* Rebuild the way swift handles structs from scratch
* Updates docs, and sample binary
* Replaces InMemory to Mutable
* Migrates docs from inmemory
* use inline for some functions
* Renamed Mutable objects
* Updates documentation
* Add vectorNumElements attribute to Builder for simpler vector creation.
This adds a default to EndVector which should simplify its use.
* Update tutorial to reflect new default arg in Python EndVector.
* Remove optional argument to Python EndVector.
* Add generated files.
* Unset Builder.vectorNumElems when not in use.
* 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.