Commit Graph

2947 Commits

Author SHA1 Message Date
Derek Bailey 16a7df46f0 fix --conform raising `No generators registered` error 2023-05-09 20:37:32 -07:00
Derek Bailey 76f5e9816a
fix out-of-source builds with cmake (#7946) 2023-05-09 20:33:54 -07:00
Björn Harrtell 368428cb94
Upgrade package.json dependencies (#7933)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-05-09 20:33:17 -07:00
Derek Bailey 72b56fd081
FlatBuffers Version 23.5.9 (#7945) 2023-05-09 09:33:30 -07:00
Derek Bailey 63b7b25289
FlatBuffers 64 for C++ (#7935)
* First working hack of adding 64-bit. Don't judge :)

* Made vector_downward work on 64 bit types

* vector_downward uses size_t, added offset64 to reflection

* cleaned up adding offset64 in parser

* Add C++ testing skeleton for 64-bit

* working test for CreateVector64

* working >2 GiB buffers

* support for large strings

* simplified CreateString<> to just provide the offset type

* generalize CreateVector template

* update test_64.afb due to upstream format change

* Added Vector64 type, which is just an alias for vector ATM

* Switch to Offset64 for Vector64

* Update for reflection bfbs output change

* Starting to add support for vector64 type in C++

* made a generic CreateVector that can handle different offsets and vector types

* Support for 32-vector with 64-addressing

* Vector64 basic builder + tests working

* basic support for json vector64 support

* renamed fields in test_64bit.fbs to better reflect their use

* working C++ vector64 builder

* Apply --annotate-sparse-vector to 64-bit tests

* Enable Vector64 for --annotate-sparse-vectors

* Merged from upstream

* Add `near_string` field for testing 32-bit offsets alongside

* keep track of where the 32-bit and 64-bit regions are for flatbufferbuilder

* move template<> outside class body for GCC

* update run.sh to build and run tests

* basic assertion for adding 64-bit offset at the wrong time

* started to separate `FlatBufferBuilder` into two classes, 1 64-bit aware, the other not

* add test for nested flatbuffer vector64, fix bug in alignment of big vectors

* fixed CreateDirect method by iterating by Offset64 first

* internal refactoring of flatbufferbuilder

* block not supported languages in the parser from using 64-bit

* evolution tests for adding a vector64 field

* conformity tests for adding/removing offset64 attributes

* ensure test is for a big buffer

* add parser error tests for `offset64` and `vector64` attributes

* add missing static that GCC only complains about

* remove stdint-uintn.h header that gets automatically added

* move 64-bit CalculateOffset internal

* fixed return size of EndVector

* various fixes on windows

* add SizeT to vector_downward

* minimze range of size changes in vector and builder

* reworked how tracking if 64-offsets are added

* Add ReturnT to EndVector

* small cleanups

* remove need for second Array definition

* combine IndirectHelpers into one definition

* started support for vector of struct

* Support for 32/64-vectors of structs + Offset64

* small cleanups

* add verification for vector64

* add sized prefix for 64-bit buffers

* add fuzzer for 64-bit

* add example of adding many vectors using a wrapper table

* run the new -bfbs-gen-embed logic on the 64-bit tests

* remove run.sh and fix cmakelist issue

* fixed bazel rules

* fixed some PR comments

* add 64-bit tests to cmakelist
2023-05-09 09:16:30 -07:00
RishabhDeep Singh 13fc75cb6b
FlatBuffers Version 23.5.8 (#7943) 2023-05-09 08:05:25 -07:00
RishabhDeep Singh e6e38a8d17
Add #!/usr/bin/bash to release.sh (#7942) 2023-05-08 14:20:14 -07:00
Derek Bailey d9f2cc2d62 add key_field to compiled tests 2023-05-08 13:54:24 -07:00
Derek Bailey 197ae6cc7e add rest of golden language directories 2023-05-05 14:22:55 -07:00
Derek Bailey 489d9735e9 add rest of golden language directories 2023-05-05 14:15:48 -07:00
Derek Bailey 3308444147 Add goldens directory 2023-05-05 13:43:07 -07:00
Derek Bailey ef5ae488dd
Rework cmake flatc codegeneration (#7938)
* start fixing the code generation steps

* reworked flatc generation in cmake
2023-05-05 12:08:09 -07:00
Derek Bailey 08efe60954 remove defining generated files in test srcs 2023-05-04 16:25:50 -07:00
Derek Bailey 01a7bc3c58
Add binary schema reflection (#7932)
* Add binary schema reflection

* remove not-used parameter

* move logic from object API to base API

* forward declare

* remove duplicate code gen that was stompping on the edits

* reduce to just typedef generation

* fixed bazel rules to not stomp

* more bazel fixes to support additional generated files
2023-05-04 16:12:45 -07:00
Wouter van Oortmerssen 67084b9921 Fix missing return error string for GenerateText 2023-05-03 13:23:53 -07:00
Wouter van Oortmerssen ed11b08fc9 GenerateText gives text error on failure 2023-05-03 13:03:00 -07:00
Philipp Schrader c1e7aee489
Migrate from rules_nodejs to rules_js/rules_ts (take 2) (#7928)
* Migrate from rules_nodejs to rules_js/rules_ts (take 2)

This is the second version of patch #7923. The first version got
reverted because bazel query was failing:

    $ bazel --nosystem_rc --nohome_rc query tests(set('//...')) except tests(attr("tags", "manual", set('//...')))
    ERROR: Traceback (most recent call last):
    	File "/workdir/tests/ts/bazel_repository_test_dir/BUILD", line 6, column 22, in <toplevel>
    		npm_link_all_packages(name = "node_modules")
    	File "/var/lib/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/ec321eb2cc2d0f8f91b676b6d4c66c29/external/npm/defs.bzl", line 188, column 13, in npm_link_all_packages
    		fail(msg)
    Error in fail: The npm_link_all_packages() macro loaded from @npm//:defs.bzl and called in bazel package 'tests/ts/bazel_repository_test_dir' may only be called in bazel packages that correspond to the pnpm root package '' and pnpm workspace projects ''

This was happening because the `.bazelrc` file only added
`--deleted_packages` to the `build` command. We also need it for the
`query` command. This second version of the patch fixes that.

Original commit message:

This patch migrates the current use of rules_nodejs to the new rules_js.
rules_js is the intended replacement of rules_nodejs as per this note:
https://github.com/aspect-build/rules_js#relationship-to-rules_nodejs

> rules_js is an alternative to the build_bazel_rules_nodejs Bazel module
> and accompanying npm packages hosted in
> https://github.com/bazelbuild/rules_nodejs, which is now
> unmaintained. All users are recommended to use rules_js instead.

There are a few notable changes in this patch:
1. The `flatbuffer_ts_library` macro no longer accepts a `package_name`
   attribute. This is because rules_js appears to manage the import
   naming of dependencies via top-level `npm_link_package` targets.
   Users will have to migrate.
2. I added a few more arguments to `flatbuffer_library_public()`. These
   helped with exposing esbuild to `ts/compile_flat_file.sh`.
3. I pinned the version of `typescript` in `package.json` so that
   rules_ts can download the exact same version. rules_ts doesn't know
   what to do if the version isn't exact.
4. Since rules_js uses the pnpm locking mechanism, we now have a
   `pnpm-lock.yaml` file instead of a yarn lock file.
4. I added bazel targets for a few of the existing tests in `tests/ts`.
   They can be run with `bazel test //test/ts:all`. Since there is no
   flexbuffers bazel target, I did not add a bazel target for the
   corresponding test.
5. I added a separate workspace in `tests/ts/bazel_repository_test_dir/`
   to validate that the flatbuffers code can be imported as an external
   repository. You can run the test with
   `bazel test //test/ts:bazel_repository_test`. For this to work, I
   needed to expose a non-trivial chunk of the flatbuffers code to the
   test. I achieved this through some recursive `distribution`
   filegroups. This is inspired by rules_python's workspace tests.

I did not do anything special to validate that the `gen_reflections`
parameter works the same. This patch doesn't change anything about
the TypeScript generation.

As a side note: I am not an expert with rules_js. This patch is my
attempt based on my limited understanding of the rule set.

Fixes #7817

* Fix the query

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-05-03 11:48:15 -07:00
Derek Bailey 75143f836b fix possible null dereference for nested_root accessor 2023-05-03 00:14:27 -07:00
Derek Bailey fb4f6fb894 fix possible null dereference for nested_root accessor 2023-05-02 23:50:20 -07:00
Derek Bailey 19d8942943 `flat_buffers.dart`: mark const variable finals for internal Dart linters 2023-05-01 09:55:47 -07:00
Derek Bailey dbce69c63b more window fixes 2023-04-29 00:43:34 -07:00
Derek Bailey aeba096403
fixed some windows warnings (#7929) 2023-04-28 23:22:41 -07:00
Derek Bailey 966aae2144
inject no long for FBS generation to remove logs in flattests (#7926)
* inject no long for FBS generation to remove logs in flattests

* updated blaze rules
2023-04-28 13:40:38 -07:00
Derek Bailey e7dc252b0e
Revert "Migrate from rules_nodejs to rules_js/rules_ts (#7923)" (#7927)
This reverts commit 4172c3f0bd.
2023-04-28 12:58:49 -07:00
Philipp Schrader 4172c3f0bd
Migrate from rules_nodejs to rules_js/rules_ts (#7923)
* Start using pnpm

* Add @npm

* get more stuff set up

* Get the analysis phase passing.

* Get esbuild working?

* Get it compiling?

    $ bazel build //tests/ts/...

* Try to get the test working

* test is passing

* Get the other tests working

* clarify comment

* clean up a bit

* Try to add another test

* Add another test

* clean up more

* remove unused reference

* Add e2e test

* Get more of the test working

* add lock file

* Get test working on its own

* Get e2e test passing

* fix infinite recursion

* Add comments

* clean up some more

* clean up more again

* Source typescript version from package.json

* run buildifier

* lint

* Fix unset `extra_env`

* Incorporate feedback

* run buildifier

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-04-28 18:17:45 +00:00
Aaron Riekenberg 417821fdd7
Only generate @kotlin.ExperimentalUnsigned annotation on create*Vector methods having an unsigned array type parameter. (#7881)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-04-28 17:10:01 +00:00
Berke c192ab423b
additional check for absl::string_view availability (#7897)
absl::string_view is uses std::string_view when available. It already checks if std::string_view is available in the earlier code.
It should only use absl::string_view implementation.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-04-28 16:51:11 +00:00
Max Burke a397dd7e8c
Optionally generate Python type annotations (#7858)
* optionally generate type prefixes and suffixes for python code

* fix codegen error when qualified name is empty

* WIP: Python typing

* more progress towards python typing

* Further iterate on Python generated code typing

* clang-format

* Regenerate code

* add documentation for Python type annotations option

* generate code with Python type annotations

* handle forward references

* clang-format
2023-04-28 09:38:29 -07:00
Jongwoo Han 6eae49a79a
Replace deprecated command with environment file (#7921)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-04-25 22:50:37 -07:00
Nikita Sokolov f6af2087ee
drop glibc from runtime dependencies (#7906)
https://github.com/google/flatbuffers/issues/7696
The binary size grows from 5.8MB to 7.2MB, but this way it works on Ubuntu 18.04 and amazonlinux.
2023-04-25 22:39:37 -07:00
Adam Oleksy ab716ee41d
Make JSON supporting advanced union features (#7869)
This change allows user to decode binary with given schema to JSON
representation when schema defines union with struct.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-04-26 05:37:06 +00:00
KerstinKeller d6d83c3a92
Allow to use functions from `BuildFlatBuffers.cmake` from a flatbuffers installation installed with CMake. (#7912)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-04-26 05:27:14 +00:00
José Luis Millán aa6848fbf6
TS/JS: Use TypeError instead of Error when appropriate (#7910)
Ie: when the needed conditions are not satisfied in order to perform a
 given action.
2023-04-25 22:22:06 -07:00
Jeroen Demeyer 6c8a8d054d
Go: make generated code more compliant to "go fmt" (#7907)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-04-26 05:19:07 +00:00
Jeroen Demeyer 63495b935a
Support file_identifier in Go (#7904)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-04-26 05:15:09 +00:00
Max Burke 56ecc1f548
Optionally generate type prefixes and suffixes for python code (#7857)
* optionally generate type prefixes and suffixes for python code

* fix codegen error when qualified name is empty

* generated code updated
2023-04-25 21:38:16 -07:00
Jeroen Demeyer 3fda20d7c7
Go: add test for FinishWithFileIdentifier (#7905)
Co-authored-by: Michael Le <michael.le647@gmail.com>
2023-04-11 17:08:04 -07:00
Jeroen Demeyer fa3fa91936
Fix go_sample.sh (#7903) 2023-04-11 12:40:00 -07:00
Björn Harrtell 52f2596e15
[TS/JS] Upgrade dependencies (#7889)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-04-06 02:00:23 +00:00
Khanh Nguyen 0916f1c87e
Add a FileWriter interface (#7821)
* Add a FileWriter interface

* Change interface

* Provide 2 impl for File interface: FileManager & FileNameManager

* Update

* update

* Update

* Add file_writer file

* Update

* Format files

* Update based on review

* Update

* Format bzl file

* Add LoadFile function

* Format

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-04-06 01:49:29 +00:00
Björn Harrtell 0888e7cb4d
TS/JS: Use minvalue from enum if not found (#7888)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-04-06 01:26:05 +00:00
tira-misu 876a64aae1
[CS] Verifier (#7850)
* 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>
2023-04-06 00:29:14 +02:00
Daniel Frederick Crisman 2803983c70
README.md: PyPI case typo (#7880)
PyPI has three capital letters. See the front page of the service:
https://pypi.org/
"The Python Package Index (PyPI) ..."

Update the Python link under "Supported programming languages"

Co-authored-by: Michael Le <michael.le647@gmail.com>
2023-03-30 13:32:16 -07:00
Michael Le 88dd92de40
Update go documentation link to point to root module (#7879)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-03-29 10:50:54 -07:00
blindspotbounty 477b1b5d13
use Bool for flatbuffers bool instead of Byte (#7876)
Add test for Bool type in swift

Co-authored-by: mustiikhalil <26250654+mustiikhalil@users.noreply.github.com>
2023-03-27 01:45:48 +02:00
phenixxy 1cb1c4baee
fix using null string in vector (#7872)
Use 0 offset as special value. 0 offset is not a valid relative offset, so it's safe to use 0 offset to indicate value is null.

https://github.com/google/flatbuffers/issues/7846
2023-03-24 03:15:34 +00:00
Derek Bailey 50cdf92e1e
Add `flatbuffers-64` branch to CI for pushes 2023-03-15 23:58:26 -07:00
Jeffrey Smith 9a7fb4d68a
made changes to the rust docs so they would compile. new_with_capacity is deprecated should use with_capacity, get_root_as_monster should be root_as_monster (#7871) 2023-03-16 00:29:57 +00:00
SmashedFrenzy16 3cb27fa241
Adding comment for code clarification (#7856)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-03-14 20:14:05 -05:00
Paulo Pinheiro d3d7e2ef99
ToCamelCase() when kLowerCamel now converts first char to lower. (#7838)
ToCamelCase(input, true) converts first char to upper case, but
ToCamelCase(input, false) keeps the case of the first char. We are
changing its behavior to force a lower case.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-03-15 01:09:24 +00:00