Commit Graph

955 Commits

Author SHA1 Message Date
Todd Hansen 067dce6e79
[C#] Handle keywords (#6775)
* Handle keywords in C#

C# should handle keywords similarly to other languages by appending an underscore after the keyword.

* Fix clang-format for idl_gen_csharp.cpp

* Fix spacing clang-format issue
2021-08-16 14:09:21 -04:00
bakinovsky-m 5d77820b34
[C++] Using calculated fields_number for field_names size (#6769)
* using already defined "fields_number" in "field_names" size calculation

* tests

* forgotten test
2021-08-05 11:41:49 -07:00
RWauson 909ce970ae
[C++] Use UnPackTo instead of UnPack if pointer exists (#6725)
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>
2021-08-05 11:40:03 -07:00
Casper 35e2cac6eb
Store vtables sorted in Rust builder (#6765)
* benchmark many vtables

* Rust: Store written_table rev-positions sorted.

The previous implementation was slow if there were too many tables.

Asymototically when inserting the n^th vtable: The old implementation
took O(n) lookup steps and O(1) insertion. The new implementation is
O(log n) lookup and O(n) insertion. This might be improved further by
using a balanced btree.

Benchmarking, create_many_tables is 7.5x faster (on my laptop):

// Simple vector cache
test create_many_tables ... bench: 728,875 ns/iter (+/- 12,279) = 44 MB/s

// Sorted vector cache
test create_many_tables ... bench: 97,843 ns/iter (+/- 4,430) = 334 MB/s

* Fix lints

Co-authored-by: Casper Neo <cneo@google.com>
2021-08-03 12:31:45 -07:00
mogemimi c39fc9dd9c
[C++] Use nullptr instead of 0 in generated headers (#6762) 2021-08-02 13:41:15 -07:00
Ivan Dlugos 97d9527f6c
Dart 2.0 release prep (#6759)
* Dart - pubspec.yaml shouldn't contain authors section anymore - it's unused

* Dart - update CHANGELOG.md

* Dart - update test and publish scripts
2021-08-02 13:31:36 -07:00
mugisoba e77926f0ed
[C#] Add Union Constructor Utility for ObjectAPI. (#6105)
* [C#] add union constructor utility.

* add union utility test.

* std::tolower -> CharToLower

* use std::transform instead

* rebase to master. and regenerate test code
2021-07-26 10:01:41 -07:00
Taiju Tsuiki 8be8a0a713
[C++] Fix union type handling on object api in C++17 (#6745) 2021-07-25 16:20:34 +07:00
Casper 12e341e4f8
Rework how Rust generated files are laid out (#6731)
* 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>
2021-07-22 19:02:28 -04:00
Ivan Dlugos 2bfc8e9f01
Dart - make writeString() argument non-nullable (#6737) 2021-07-20 07:54:48 -07:00
Casper 674a9f2aae
fix lints in rust tests (#6743)
Co-authored-by: Casper Neo <cneo@google.com>
2021-07-19 18:47:20 -04:00
Ivan Dlugos 65700441d3
Dart - make vTable fixed size (expect the number of fields when creating) (#6735) 2021-07-19 11:27:01 -07:00
Ivan Dlugos dd5bb55cad
Dart - make vTable deduplication optional (#6734) 2021-07-15 15:50:12 -07:00
Ivan Dlugos e73fab27d4
Dart - store empty vectors instead of NULL (#6728) 2021-07-09 12:44:40 -07:00
Ivan Dlugos 92ae532e43
Dart - finish/lowFinish/buffer changes (#6712)
* Dart - change Builder "lowFinish()" to "buffer" and "finish()" to not void return

Aligning the API with other languages, e.g. c++ and allowing custom use-cases to avoid creating a Uint8List

* Dart - change builder.buffer to check that finish() was already called

* Dart - builder - move !finished assertion to _prepare() which is run from all other functions
2021-07-09 11:45:45 -07:00
Ivan Dlugos 3f77dc9a0e
Dart - unpack() must use eager list reader (#6723) 2021-07-09 09:55:34 -07:00
Ivan Dlugos 838c93b843
Dart - fix flex-builder compilation error (#6722)
* Dart - fix flex-builder compilation error

* DartTest.sh - run all tests
2021-07-09 09:53:27 -07:00
Vladimir Glavnyy 22498cf3a9
[C++] add make_span for Array<T,N> (#6663)
* [C++] Add make_span for Array<T,N> and Vector<T>

* [C++] Add tests for make_span<T,N>(Array<T,N>)

* [C++] Add span iterators

* [C++] Checked span iterator (MSVC)

* Fix review notes
2021-06-28 10:22:02 -07:00
Ivan Dlugos a6ee335574
Dart null safety (#6696)
* Dart null-safety - prepare migration annotations in library files

* Dart null-safety - apply migration

* Dart null-safety - update flatc to generate valid code

* Dart null-safety - fix flatc generated code and adjust tests

* Dart null-safety - update example and the generated code in the tests folder

* Dart null safety - minor review changes

* Dart - apply `dartfmt -w .`
2021-06-22 08:54:57 -07:00
Casper 71d43f3be9
Make --bfbs-filenames default to location of first schema file. (#6705)
* 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>
2021-06-22 10:19:46 -04:00
schoetbi c8db1ca5d4
Jsonschema add prop comments (#6617)
* Add comments for properties

* regenerated test files

* Reverted changes in testfiles generated with generate_code.bat on windows

* fixed formatting in util.cpp because of failed .travis/format_check.sh

* removed the use of tuple

* util.cpp: Fixed format

* idl_gen_json_schema.cpp: removed extra comma in deprecated fields

* Corrected monster_test.schema.json

* idl_gen_json_schema: Inlined Trim function

* Fixed format

* PrepareDescription(): Avoid unnecessary string copy

* fixed formatting
2021-06-21 11:42:07 -07:00
Mika Raento 962751a6ec
Improve generated comparisons for tables (#6486)
* Improve generated comparisons for tables

Previously, the generated code called std::unique_ptr<>::operator== on
non-scalar members, which would be correct only if the member was null
on both sides. After this CL, comparison is done on the pointed-to
values (including using a default-constructed value if the pointer is
null).

* Don't equate null Tables with all defaults

Also removes the cost of default-constructing tables for comparisons.

* Regenerate code

* fix formatting
2021-06-21 11:37:56 -07:00
Casper 06fd6d640c
Replace filenames in reflection with filenames+includes. (#6703)
* Replace filenames in reflection with filenames+includes.

This is needed for some use cases and may be just useful metadata.

* deser files_included_per_file_

* check project_root

* fix bazel

* git clang format

Co-authored-by: Casper Neo <cneo@google.com>
2021-06-19 19:21:33 -04:00
Casper c58ae94225
Add the file a symbol is declared in to Reflection (#6613)
* Add the file a symbol is declared in to Reflection

If we move a code-generator to depend on Reflection,
it may need to know which file something was declared in
to properly name generated files.

* Doc comments in reflection, and more precise tests

* Add --project-root flag to flatc, normalize declaraion_file to this root

* fix --project-root stuff

* posixpath

* fix scripts

* format

* rename --project-root to --bfbs-filenames

Also, make it optional, rather than defaulting to `./`, if its not
specified, then don't serialize the filenames.

* bfbs generation

* fix some tests

* uncomment a thing

* add  to project root directory conditionally

* fix

* git clang format

* Added help description and removed != nullptr

* "

* Remove accidental change to docs

* Remove accidental change to docs

* Pool strings

Co-authored-by: Casper Neo <cneo@google.com>
2021-06-17 11:50:04 -04:00
Ivan Dlugos 4e3a66c141
Dart object API (#6682)
* 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
2021-06-14 10:15:56 -07:00
Alexander Dzyuba e1e9f93739
[C++/grpc] added hiding of unused variables in the generated code (#6677)
Co-authored-by: Alexander Dzyuba <a.dzyuba@seraphim.online>
2021-06-06 17:40:56 +07:00
ofirm93 7c3e267e1e
[Java] ObjectAPI implementation (#6521) (#6582)
* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)
2021-06-03 14:17:40 -07:00
Björn Harrtell eabdbda755
[TS] Generate entry point module (#6674) 2021-06-01 09:09:55 -07:00
Derek Bailey d84bccb0c7
Removed most heap allocations in builder (#6662)
* [C++] Removed most heap allocations in builder

* Updated API docs to indicate heap usage

* Override assertion for heap allocation in parser

* Cleaned up implemenations, enable heap alloc for tests

* Generalized CreateVectorOfStrings

* remove cmake option for heap alloc. reverted two heap removals

* Only use scratch space for vector of strings

* Override Windows SCL warning

* Changed std::transform to for loop to avoid MSCV warnings

* switched to const iterators

* Replaced iterator with for loop

* remove std::to_string in test to be compatible
2021-05-21 11:09:24 -07:00
Samir Ahmed 54c11932fa
[Java] Flexbuffers - Negative signed object length (#6651)
* retry with correct email

* update JavaTest.java
2021-05-20 11:57:10 -07:00
mustiikhalil fbcb3c4236
[TS/JS] Updates the grpc (#6654)
* Updates go lang support to allow other languages to communicate with it

* Update js grpc lib to use grpc-js

Reformat code
2021-05-20 11:34:17 -07:00
Derek Bailey 4867c94564
Fixed generation of c++ code with flags (#6637)
* Fixed generation of c++ code with flags

* tweaking const

* moved to CONSTEXPR_CP11
2021-05-15 13:27:24 -07:00
Derek Bailey ef0eb3701d
Ran clang-format-all.sh. Removed default --style=file parameter (#6639)
* Ran clang-format-all.sh. Removed default --style=file parameter

* Moved scripts to scripts/ location
2021-05-15 12:54:08 -07:00
Fraser Crossman f83ee1af59
[idl_parser] Check structs and enums do not clash in a namespace (#6562)
* [idl_parser] Check structs and enums do not clash in a namespace

Uses fully qualified names to check for clashes within a given namespace whether explicitly defined or in the global namespace.

* [idl_parser] Move type name clash check to ParseEnum and ParseDecl

Change point at which parsing error is returned to ensure error is caught more generally. This change means that the error is returned after parsing the entirety of the offending duplicate rather than at the start when parsing it's name.

* [idl_parser] Add single and multi file type name clash tests

Adds a selection of tests for valid single file schemas with types that have the same name but are in different namespaces.
Adds a test for an a valid schema that spans two files with two types that have the same name but are in different namespaces.
Adds a test for an an invalid schema that spans two files with two types that have the same name and are in the same namespace.
2021-05-14 13:56:52 -07:00
mustiikhalil a5175c513a
Implements verifier and code gen for swift (#6373)
Updates test cases on linux

Adhere to new protocol naming

Adds fuzzing

Adds documentation

Adds support for string unions

Updated fuzzer generated code
2021-05-14 20:59:28 +03:00
Casper 04b10f5a3a
Deprecate EnumVal.object (#6612)
Co-authored-by: Casper Neo <cneo@google.com>
2021-05-13 14:57:36 -07:00
Casper 8fd10606c1
Implement Serialize for flexbuffer::Reader (#6635)
* Implement Serialize for flexbuffer::Reader

* bump version

* Remove use of experimantal or-patterns

* Remove more use of experimantal or-patterns

Co-authored-by: Casper Neo <cneo@google.com>
2021-05-10 23:15:46 -04:00
Wouter van Oortmerssen a9a295fecf More missing version changes 2021-05-10 11:45:16 -07:00
Wouter van Oortmerssen 42ca1b9140 Swift/Kotlin generated code version updates
Change-Id: I035163cb5edd087a190bb518e686c79887241383
2021-05-10 11:30:26 -07:00
Wouter van Oortmerssen 6ed780dbd5 C++/Rust version changes 2021-05-10 11:29:32 -07:00
Wouter van Oortmerssen 3412fab8ee C#/Java generated code version updates 2021-05-10 11:17:31 -07:00
Vladimir Glavnyy c8c16de167
Fix reverse iterators for Vector and Array (#6626)
This commit fixes two serious issues connected with reverse iterators:
1. Vector's rbegin/rend was incompatible with std::reverse_iterator::base();
2. Array's rend() was incorrect, it based on end() instead of begin().
2021-05-10 09:07:56 -07:00
罗泽轩 4525cd9c56
[Lua] manipulate byte array as string (#6624)
* [Lua] manipulate byte array as string

Sometimes it would be more effective than reading byte by byte

* change according to the review

* update
2021-05-07 22:57:13 -07:00
罗泽轩 a4bb8f0c2e
[Lua] Avoid infinite loop when creating empty string (#6614)
* [Lua] Avoid infinite loop when creating empty string

* [Lua] Check empty string output
2021-05-05 19:39:42 -07:00
Derek Bailey 82aed82b84
Added support for Lua 5.1, 5.2 and 5.4 (#6606)
This adds basic support for different Lua versions.

For Lua 5.2 and Lua 5.3, both the Bit32 and Compat53 Lua modules must be
installed for it to work. You can typically get these on Linux using

apt install lua-compat53 lua-bit32

For Lua 5.4, it should work as is, as it is a clean superset of Lua 5.3,
which is what the original Lua Flatbuffers supported.
2021-05-05 16:36:49 -07:00
Björn Harrtell 60ff76630d
[TS] Remove wrong and obsolete NS prefix use (#6604) 2021-05-03 12:04:34 -07:00
Derek Bailey a27c7d8093
Fixed LuaJIT when not compiled with COMPAT mode (#6605)
LuaJIT as installed by apt doesn't include the COMPAT mode for using
Lua5.2 features. So this change just makes the flatbuffer code use a
common implementation.
2021-05-03 11:35:49 -07:00
Kamil Rojewski 3632208233
removed unneeded type prefixing (#6601) 2021-05-03 10:40:59 -07:00
罗泽轩 d3cd78a87c
[Lua] Add LuaJIT support (#6584)
* [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
2021-04-30 10:38:16 -07:00
Derek Bailey 14725d6c3b
[Lua] GetRootAs can accept strings. Made Luatest Benchmarks optional (#6593) 2021-04-27 13:02:13 -07:00