Commit Graph

40 Commits

Author SHA1 Message Date
Derek Bailey 203241ed32
FlatBuffers Version 22.10.26 (#7607) 2022-10-26 16:02:38 -07:00
Joshua Smith 043a24f2e4
[Python] Fixed the issue with nested unions relying on InitFromBuf. (#7576)
* feat: Fixed the issue with nested unions relying on InitFromBuf.
Problem: Issue #7569
Nested Unions were broken with the introduction of parsing buffers with an initial encoding offset.

Fix:
Revert the InitFromBuf method to the previous version and introduction of InitFromPackedBuf that allows
users to read types from packed buffers applying the offset automatically.

Test:
Added in TestNestedUnionTables to test the encoding and decoding ability using a nested table with a
union field.

* fix: Uncommented generate code command
2022-10-26 14:56:52 -07:00
Derek Bailey a54ca1e759
FlatBuffers Version 22.10.25 (#7604) 2022-10-26 00:03:49 -07:00
Dan Lapid 872a497464
[Nim] Bfbs Nim Generator (#7534)
* Bfbs Nim Generator

* Remove commented out tests

* add missing line to idl.h

* Commit python reflection changes

* Commit python reflection changes and move tests

* Remove default string addition

* Move tests to python file

* Fix element size check when element is table

* remove whitespace changes

* add element_type docs and commit further to namer and remove kkeep

* Bfbs Nim Generator

* Remove commented out tests

* add missing line to idl.h

* Commit python reflection changes

* Commit python reflection changes and move tests

* Remove default string addition

* Move tests to python file

* Fix element size check when element is table

* remove whitespace changes

* add element_type docs and commit further to namer and remove kkeep

* remove unused variables

* added tests to ci

* added tests to ci

* fixes

* Added reflection type Field, Variable to namer

* Moved reflection namer impl to bfbsnamer

* Remove whitespace at end of line

* Added nim to generated code

* Revert whitespace removal

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-10-21 14:30:04 -04:00
Björn Harrtell 4fca4dc60c
[TS/JS] Move TS tests to dedicated folder and deps upgrade (#7508)
* Move TS tests to dedicated folder and deps upgrade

* Attempt to fix generate_code

* Fix dir on CI

* Add js extension

* Fix missing extension

* Harmonize with test gen

* Unexplained code gen change

* Restore yarn.lock

* Naive attempt to fix bazel stuff

* Pin @bazel/typescript to 5.2.0

* Attempt to fix bazel

* More tweak

* Upgrade deps

* Tweak?

* Fix path

* Fix test package

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-09-12 20:03:23 -07:00
mustiikhalil a67e35aff9
Moves all of the swift test code into tests/swift (#7509)
Fixes failing tests by regenerating test cases
2022-09-09 22:35:42 -07:00
Derek Bailey c5a609dc20
[C#] Prepares for official Nuget release (#7496)
* Define nuget package

* C# Switch to Google.FlatBuffers namespace

* Add Source Link for nuget package

* Add Strong Name signing of Google.FlatBuffers
2022-09-01 10:17:34 -07:00
Derek Bailey 8367664f15
Flatbuffers Version 2.0.7 (#7462) 2022-08-22 21:42:15 -07:00
Derek Bailey 7aae0af305
Remove old GRPC bash script and convert to python3 (#7454)
* Remove old GRPC bash script and convert to python3

* updated checking gRPC script to python3
2022-08-16 23:44:50 -07:00
Derek Bailey 82b75407a3
Wrap types in namespace for --ts-flat-files and --gen-all (#7451)
* Wrap types in namespace for --ts-flat-files and --gen-all

* Fixes for escaping object types

* Added to generate_code
2022-08-16 12:52:26 -07:00
Aman Priyadarshi 468c00a3fe
Rebased: grpc/compiler: Respect filename suffix and extension during code generation (#7414)
* grpc/compiler: Respect filename suffix and extension during code generation

grpc compiler is not respecting filename suffix and extension passed to
flatc CLI. This causes compiler to spit out incorrect code, which then
cannot be compiled without modification.

Following patch fixes the problem.

Note, I ended up removing some code introduced #6954 ("Have grpc include
file with correct filename-suffix given to flatc") in favour of keeping
sanity of the generator code.

Signed-off-by: Aman Priyadarshi <aman.eureka@gmail.com>

* tests: Add filename-suffix and filename-ext test files

* Test 1: Filename extension changed to "hpp".
* Test 2: Filename suffix changed to "_suffix".
* Test 3: Filename extension changed to "hpp" and suffix changed to "_suffix"

Signed-off-by: Aman Priyadarshi <aman.eureka@gmail.com>
2022-08-07 11:32:53 -07:00
Derek Bailey 359e0f9d66
Revert "grpc/compiler: Respect filename suffix and extension during code generation (#7343)" (#7406)
This reverts commit 97e89c5acd.
2022-08-05 23:20:33 -07:00
Aman Priyadarshi 97e89c5acd
grpc/compiler: Respect filename suffix and extension during code generation (#7343)
* grpc/compiler: Respect filename suffix and extension during code generation

grpc compiler is not respecting filename suffix and extension passed to
flatc CLI. This causes compiler to spit out incorrect code, which then
cannot be compiled without modification.

Following patch fixes the problem.

Note, I ended up removing some code introduced #6954 ("Have grpc include
file with correct filename-suffix given to flatc") in favour of keeping
sanity of the generator code.

Signed-off-by: Aman Priyadarshi <aman.eureka@gmail.com>

* tests: Add filename-suffix and filename-ext test files

* Test 1: Filename extension changed to "hpp".
* Test 2: Filename suffix changed to "_suffix".
* Test 3: Filename extension changed to "hpp" and suffix changed to "_suffix"

Signed-off-by: Aman Priyadarshi <aman.eureka@gmail.com>
2022-08-05 22:11:45 -07:00
Caleb Zulawski 49e1ea3335
Implement optional scalars for Python (#7318)
* Implement optional scalars for Python

* Use == for integer comparison, remove empty line

* Fix optional type hint

Co-authored-by: Caleb Zulawski <caleb.zulawski@caci.com>
2022-06-13 09:16:00 -04:00
mustiikhalil 11a1988705
Started implementation for private flags in rust (#7269)
Adds flag to the cpp to fix bad annotations in all the languages

Addresses comments to the PR, and fixes logic for leaking annotations
2022-06-05 23:04:05 +02:00
mr-swifter 1ea2472f7a
[swift] add had<ArrayName> property for arrays to check presence in a message (#7280) 2022-05-11 15:35:53 +02:00
Derek Bailey 746c73b910 Add Annotations for Monster schema and example buffer 2022-04-21 20:43:55 -07:00
Paulo Pinheiro 7b5fd2bd05
[Kotlin] Fix key lookup returning null clashing with default value (#7237)
* [Java] Fix key lookup returning null clashing with default value

A field with key attribute must always be written on the message so it
can be looked up by key. There is a edge case where inserting a key
field with same value as default would prevent it to be written on
the message and later cannot be found when searched by key.

* [Kotlin] Fix key lookup returning null clashing with default value

A field with key attribute must always be written on the message so it
can be looked up by key. There is a edge case where inserting a key
field with same value as default would prevent it to be written on
the message and later cannot be found when searched by key.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-04-11 17:17:19 -07:00
Paulo Pinheiro 7181d77700
[Java] Fix key lookup returning null clashing with default value (#7236)
A field with key attribute must always be written on the message so it
can be looked up by key. There is a edge case where inserting a key
field with same value as default would prevent it to be written on
the message and later cannot be found when searched by key.
2022-04-11 17:16:41 -07:00
mustiikhalil 832c618f5f
Adds implementation flag for swift (#7202)
* Adds implementation flag for swift

Forces internal flag when using @_implementationOnly in swift

Fixes access type for verifier functions & encoder functions

Updates generated code

* Addresses PR comments & adds a code gen dir within the swift tests

* Adds test case for no-include

* Fixes code gen script

Removes prefix
2022-04-06 13:31:38 -07:00
Derek Bailey 40866a8927
fixed padding in struct for annotated binary (#7199) 2022-03-30 16:43:22 -07:00
tira-misu 6c5603fd98
[C#] Fix collision of field name and type name (#7149)
* 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 example for type field name collision
2022-03-30 12:51:58 -07:00
Casper a4cb1599d8
Namerdart (#7187)
* Apply Namer to Dart.

- Also refactor idl_gen_dart a bit
  - to use more const and references
  - out parameters should be the last argument

* Add keyword test

* minor fixes

* fix merge

* extra 's'

* move dart keyord into dart dir

* Address comments

* Use $ for escaping keywords
* Outparameters for namespace_map

* Escape dollar in toString

* Escape dollar in toString2

* Use UpperCamelCase for types and variants

* try to fix ToString

* namer Type fixes

* Remove path prefixing in imports

* gen code

Co-authored-by: Casper Neo <cneo@google.com>
2022-03-28 18:07:09 -04:00
mustiikhalil 23a7e4e0b0
Adds no-includes flags to the swift code generator (#7182) 2022-03-22 21:42:20 -07:00
Casper 615616cb55
Change Rust generated file defaults (#7101)
* Change Rust generated file defaults

After #6731, flatc changed its default behavior
for generating rust code to fix some importing issues.
This was a breaking change which invlidated the patch release,
`flatc 2.0.5` (#7081). This PR reverses the default so we can
release a patch update. However, does break Rust users who work at
HEAD.

* Bump flatc patch version (2.0.6)

Co-authored-by: Casper Neo <cneo@google.com>
2022-02-15 11:48:42 -05:00
qazwsxedcrfvtg14 b300691336
Add reflection support for python (#7026)
We already have the reflection.fbs file and the flatbuffers
python language support.

Adding this feature would give the python developers the
ability to parse the flatbuffers schema and write some tools.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-02-10 11:10:47 -08:00
Derek Bailey 826193ff68
skip generating reflection.fbs in generate_scripts (#7077) 2022-02-02 22:42:26 -08:00
nicked a2b238960f
Fixed default value of bool in struct for Swift (#7072) 2022-02-02 23:39:19 +03:00
Max Burke 1d294a31b8
Implement Serialize on generated rust types (#7022)
* 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
2022-01-30 19:29:18 -05:00
Derek Bailey dbbaeac85c
Use `${PYTHON_EXECUTABLE}` instead of `py` in cmake (#7042)
* Emit include for bfbs-gen-embed

* Use python3 explicitly

* bump min python version to 3.6

* Sort find_package for python

* try casting Path to string

* cast WindowsPath to string to please CI

* stringify the wrong thing

* another stringify path
2022-01-28 15:00:57 -08:00
Derek Bailey b78002ff3e
Validate C# json/object-api options (#6985) 2021-12-13 11:52:01 -08:00
lu-wang-g 5fc87f4c4b
Enable --gen-onefile in Python (#6953)
* 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
2021-12-09 15:47:09 -08:00
Derek Bailey 061d61f3f8
Lua Generator using IR. (#6940)
* initial hack to get new Lua generator into flatc

* Starting to output enum defs for Lua

* Continue to work on table generation for Lua

* Finished basic getter access for Lua

* Added ability to get object by index

* Finished struct builder

* aliased reflection to r

* finish table builder generation

* register requiring files

* better generated header info

* Tying up loose ends

* Updated reflection to handle struct padding

* Addd type sizes to reflection

* Fixed some vector indirect issues

* Lua tests passed

* Misc cleanup

* ci fixes 1

* ci fixes 2

* renaming

* up size of type sizes

* manually ran clang-format-11 -i src/idl_parser.cpp

* fixed some windows casting

* remove stupid auto import

* more static_casting

* remove std

* update other build environments

* remove scoped enums

* replaced std::to_string with NumToString

* more win fixes

* more win fixes

* replaced old lua with new

* removed auto import

* review responses

* more style fixes

* refactor bfbs_gen_len to use code +=

* added consts

* fix lambda capture for windows

* remove unused return type
2021-12-02 21:29:19 -08:00
Derek Bailey e47dc0e465
Removed test/generate_code.{sh|bat} (#6873)
* removed test/generate_code.{sh|bat}

remove c++0x from generate_code.py

added check generate code script in python

add windows specific call

added flags to generate_code.py

Set c++-0x on BUILD_LEGACY

Skip generating monster_extra if requested

* added option to skip monster extra

* add conditional to skip 2010 check gen
2021-11-30 23:13:24 -08:00
mustiikhalil 4c7a9c10d3
Adds JSON encoding to swift (#6874)
Updates generated code & removes unneeded protocol

Updates cpp to only generate code when flag is passed

Updates code gen script
2021-10-07 23:22:22 +02:00
Derek Bailey a592f4c89e
[Cmake] Add a post build command after flatc to run the new generate_code.py script. (#6866)
* starting to add python script

* finish first draft of script

* add windows-specific edits

* Add cmake post flatc build generated_code.py command

* fixed windows issue

* Provided flatc location to generate_code.py

* Allow relative flatc pathing and fix macro typo

* escape post build arguments

* change script and args quoting

* skip running generate_code.py on old MSVC compilers
2021-09-30 12:38:52 -07:00
Derek Bailey e2b26ee19b
Make and generate_code.sh generate same outputs (#6855)
* added --bfbs-builtins

* update generate_code.bat

* forgot the .

* updated checking scripts

* added bypass for the monster_test.bfbs and arrays_test.bfbs diff issue

* removed check on windows for now
2021-09-24 12:01:34 -07: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
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
mustiikhalil ffc2ef77ca
[CI] Adds Code Generation tests on Github Actions (#6482)
Moves check-grpc-generation to scripts
2021-02-23 08:51:39 +03:00