Commit Graph

2997 Commits

Author SHA1 Message Date
Wouter van Oortmerssen a3dfcf3326 Update Lobster monster sample 2023-09-17 21:18:03 -07:00
Wouter van Oortmerssen d3e8cb60a1 Lobster namespace change 2023-09-17 10:21:58 -07:00
Anton Bobukh 0343396e49
Fully qualify the offset type in FLATBUFFERS_VTABLE_UNDERLYING_TYPE (#8094) 2023-09-13 10:23:39 -07:00
jviel-beta f625ff3330
[TS] Allows object API to set 0 for a null-default scalar. (#7864)
* Fixes bug where null default allows 0 as a value.

* Undoes one bit, adds null type allowance to addField<> default.

* Undoes IDE auto-format of imports.

* Adds generated changes after scripts/generate_code.py

* Removes unused symbol.

* Revert "Removes unused symbol."

This reverts commit 9cece17325.

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-09-12 19:58:55 +02:00
Philipp Schrader 362dd663f8
Fix BUILD.bazel style violations (#8081)
`buildifier` was complaining as follows:

    #### :bazel: buildifier: found 2 lint issues in your WORKSPACE, BUILD and *.bzl files
    <pre><code>tests/ts/bazel_repository_test_dir/BUILD:3:1: <a href="https://github.com/bazelbuild/buildtools/blob/master/WARNINGS.md#out-of-order-load">out-of-order-load</a>: Load statement is out of its lexicographical order.
    ts/BUILD.bazel:2:1: <a href="https://github.com/bazelbuild/buildtools/blob/master/WARNINGS.md#out-of-order-load">out-of-order-load</a>: Load statement is out of its lexicographical order.</pre></code>

This can be fixed locally like so:

    $ buildifier -lint fix $(git ls-files | grep -e '/BUILD.bazel$' -e '/BUILD$' -e '\<WORKSPACE$')

I also took this opportunity to fix one of the filenames.

I accidentally introduced these errors in #8078.
2023-08-28 09:20:10 +02:00
Philipp Schrader 5a8a395756
Upgrade the bazel-related dependencies (#8078)
This patch updates all the bazel-related dependencies to their latest
available versions. All tests still pass.

Fixes: #8076
2023-08-25 18:15:12 +02:00
Max Burke afafd206a3
Optional omission of Typescript entrypoint (#8057) 2023-08-20 10:28:47 +02:00
OptoCloud 48da238920
Make eslint less pedantic (#8012)
* Disable eslint spam

* Generate TS example files
2023-07-10 15:48:16 +00:00
Derek Bailey 8836ddab41
Update stale.yml 2023-07-08 15:18:47 -07:00
Wouter van Oortmerssen 23922e7eba FlexBuffers: JSON output supports indentation 2023-06-14 18:12:55 -07:00
Wouter van Oortmerssen f8fe811d5c FlexBuffers: allow getting size & undo of map in progress 2023-06-14 17:12:37 -07:00
Derek Bailey 0cc525b722 fix android typo 2023-05-31 19:31:47 +00:00
Derek Bailey 28861d1d7d
various fixes (#7986) 2023-05-31 11:52:05 -07:00
James Kuszmaul 204473cdb5
[Bazel] Fix gen_reflections for flatbuffers_ts_library (#7981)
If you used flatbuffers_ts_library with gen_reflections = True then it
attempted to use the flat-file compiler rather than flatc itself.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-05-31 18:07:37 +00:00
Paulo Pinheiro 85088a196d
Small optimization on "deserialization" and fix on benchmarks again (#7982)
* [Kotlin] Small optimizations and benchmark on deserialization

* [Kotlin] Remove redudant assign() method (use init() instead)

* [Kotlin] Fix benchmark run after change in flatbuffers-java deps

Commit 6e214c3a49 fixes Kotlin build,
but makes the kotlin-benchmark plugin misses the java classes at
runtime, causing NotClassFoundError. The alternative to solve the issue
is to read java's pom.xml to get the latest java version and use it
as dependency. With that we avoid compilation errors on a new version and
keep benchmark plugin happy.
2023-05-31 11:02:39 -07:00
Paulo Pinheiro 6e214c3a49
[Kotlin] Add java source on benchmark module instead of using version jar (#7978)
By using specific jar version to use java's runtime on the benchmark
module we let CI break when new versions are released. So we are using
source directly instead
2023-05-26 14:07:18 -07:00
Derek Bailey 96294e9f84
Add `ForceVectorAlignment64` and test (#7977) 2023-05-26 11:49:06 -07:00
Paulo Pinheiro b7856f8e27
Add Kotlin multiplatform support (#7969)
* [Kotlin] Introduction to Kotlin Multiplaform

The first implementation of the Kotlin code generation was made years
ago at the time Kotlin Multiplaform was not stable and Kotlin is mostly
used on JVM-based targets. For this reason the generated code uses java
based runtime.

That design decision comes with many drawbacks, leaving the code
generated more java-like and making it impossible to use more advanced
features of the Kotlin language.

In this change we are adding two parts: A pure, multi-plaform, Kotlin
runtime and a new code generator to accompany it.

* [Kotlin] Remove scalar sign cast from code generation

Now that we have a new runtime the accepts unsigned types, we don't
need to code generate casting back and from signed scalars. This
MR removes this from both code generations and adds the necessary
API to the runtime.

* [Kotlin] Use offset on public API to represent buffer position

Currently, kotlin was following Java's approach of representing objects,
vectors, tables as "Int" (the position of it in the buffer). This change
replaces naked Int with Offset<T>, offering a type-safe API. So,
instead of

fun Table.createTable(b: FlatBufferBuilder, subTable: Int)

We will have

fun Table.createTable(b: FlatBufferBuilder, subTable: Offset<SubTable>)

Making impossible to accidentally switch parameters.

The performance should be similar to use Int as we are using value
class for Offset and ArrayOffset, which most of the time translate to
Int in the bytecode.

* [Kotlin] Add builder for tables

Add builder constructor to make create of table more ergonomic.
For example the movie sample for the test set could be written as:

Movie.createMovie(fbb,
    mainCharacterType = Character_.MuLan,
    mainCharacter = att) {
    charactersType = charsType
    this.characters = characters
}

instead of:

Movie.startMovie(fbb)
Movie.addMainCharacterType(fbb, Character_.MuLan)
Movie.addMainCharacter(fbb, att as Offset<Any>)
Movie.addCharactersType(fbb, charsType)
Movie.addCharacters(fbb, charsVec)
Movie.endMovie(fbb)

* [Kotlin] Move enum types to value class

Moving to flatbuffer enums to value class adds type safety for parameters
with minimum to no performance impact.

* [Kotlin] Simplify Union parameters to avoid naked casting

Just a small change on the APIs that receive union as parameters,
creating a typealias UnionOffset to avoid using Offset<Any>. To "convert"
an table offset to an union, one just call Offset.toUnion().

* [Kotlin] Apply clang-format on kotlin code generators

* [Kotlin] Update kotlin generator to follow official naming conventions

Updating directory, package and enum naming to follow Kotlin official
convention.

https://kotlinlang.org/docs/coding-conventions.html#naming-rules

* [Kotlin] Add fixes to improve performance

1 - Add benchmark comparing serialization between Java & Kotlin
2 - ReadWriteBuffer does not auto-grow (thus avoid check size in every op)
3 - Add specialized add functions on FlatBufferBuilder to avoid boxing
offsets.
4 - Remove a few Kotlin syntax sugar that generated performance penalties.

* [Kotlin] Remove builder from Kotlin KMP and add some optimizations
to avoid boxing of Offset classes

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-05-26 11:00:33 -07:00
Derek Bailey 0100f6a577
FlatBuffers Version 23.5.26 (#7976) 2023-05-26 10:33:09 -07:00
swimar e0a87e36d5
Update java pom.xml file to allow flatbuffers-java maven package to be compiled under java 8, and pulled in as a dependency to a project using java 8. (#7893) (#7894)
Co-authored-by: Derek Bailey <derekbailey@google.com>
Co-authored-by: Paulo Pinheiro <paulovictor.pinheiro@gmail.com>
2023-05-22 09:18:37 +02:00
Derek Bailey b67f1ad6d0
don't emit flatbuffers include in bfbs generated output (#7968) 2023-05-17 21:13:16 -07:00
Derek Bailey ae6753684e
switch back to having T explicitly defined in CreateVector (#7967) 2023-05-17 13:23:34 -07:00
Chih-Hsuan Yen a352bdbc34
Fix python tests (#7960)
* Don't generate types unless --python-typing specified

Fixes https://github.com/google/flatbuffers/issues/7944

* Fix incorrect import statements

Fixes https://github.com/google/flatbuffers/issues/7951

* Fix $PYTHONPATH in PythonTest.sh

Regressed from https://github.com/google/flatbuffers/pull/7529

* PythonTest: fail if something goes wrong

GitHub Actions runs `bash PythonTest.sh`, and thus failures were not
visible.

* Build flatc for Python tests

* Regenerate codes

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-05-17 13:10:51 -07:00
sssooonnnggg cb14043f82
fix(rust): fixed rust namer isses, resolve #7865 and ##7782 (#7964)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-05-17 19:54:49 +02:00
Derek Bailey d64dc6200a
Switch to using alias instead of a typedef for FlatBufferBuilder (#7966) 2023-05-17 10:40:02 -07:00
sssooonnnggg ea7cfcd591
chore: add rust windows test to CI, fix RustTest.bat (#7963)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-05-16 16:06:41 -07:00
Daniel Frederick Crisman 067553156a
README.md: SemVer case typo (#7962)
SemVer (if we are capitalizing it) has a capital V. See the third
sub-header at
https://semver.org/#semantic-versioning-specification-semver
"Semantic Versioning Specification (SemVer)"

Update the text in Versioning section
2023-05-16 09:46:47 -07:00
sssooonnnggg b128b802d9
feat: Support union underlying type for TS/JS (#7961) 2023-05-15 13:18:49 -07:00
sssooonnnggg 1d3afb90c5
feat(C++): Support underlying_type for union (#7954)
* feat(C++): support underlying type for union

* chore: add conform checks for underlying type changes
2023-05-14 21:22:38 -07:00
Derek Bailey fe5e4c71c5
remove flatbuffers tests from android (#7959) 2023-05-12 21:49:33 -07:00
Derek Bailey 17b9eed4e1 switch to interface library for flatsample 2023-05-12 21:23:51 -07:00
Derek Bailey cbc8872b99 fix Mac build about gen sources and multiple targets 2023-05-12 17:11:18 -07:00
Derek Bailey 05743591e1 remove and auto-generate arrays_test_generated.h 2023-05-12 16:44:28 -07:00
Derek Bailey 2bc2529245 remove and auto-generate alignment_test_generated.h 2023-05-12 16:26:21 -07:00
sssooonnnggg 18cadc79c1
fix(TS): fixed incorrect function name when importing unionTo functions (#7958) 2023-05-12 10:49:50 -07:00
Wouter van Oortmerssen 426f3b8bf2 Missing GenTextFile decl 2023-05-11 18:26:06 -07:00
Wouter van Oortmerssen 950a71ab89 Rename GenerateText
to make it a compile-time breaking change, to alert any users to the new meaning of the return value
2023-05-11 18:14:27 -07:00
Derek Bailey 86486a1735 run `scripts/clang-format-all.sh` 2023-05-11 12:23:49 -07:00
Derek Bailey c2f764c22b add GetSizePrefixedBufferLength() 2023-05-11 12:22:05 -07:00
Derek Bailey e97ff95970 Change SizedPrefixed verifier to be <= provided size 2023-05-11 12:22:05 -07:00
Derek Bailey 33212657ae
Change SizedPrefixed verifier to be <= provided size (#7957)
* Change SizedPrefixed verifier to be <= provided size

* add GetSizePrefixedBufferLength()
2023-05-11 12:21:50 -07:00
Derek Bailey 66e9d9823a fixed other occurenace of big buffer 2023-05-11 09:39:54 -07:00
Derek Bailey 9fc153a8f8 remove large buffer creation in test to speed it up 2023-05-11 09:34:50 -07:00
Philipp Schrader c2bf810638
Fix //tests/ts:bazel_repository_test (#7952)
The test was not actually invoking the bazel that was downloaded with
the `http_file` rule. I failed to add `executable = True` to the
`http_file` call. This caused the test to ignore that bazel binary and
went to the next one on the system.

This patch fixes the issue by adding the missing attribute. Also, this
patch changes the check in the test to make sure that the downloaded
file is indeed executable.
2023-05-10 21:35:58 -07:00
Derek Bailey 0ce6957763 remove unneeed grpc include 2023-05-10 16:41:39 -07:00
Derek Bailey 82c6712606 make loop variable final in dart 2023-05-10 16:30:12 -07:00
Derek Bailey b5957975c5 rename __suppress_ubsan to FLATBUFFERS_SUPPRESS_UBSAN 2023-05-10 14:16:31 -07:00
Derek Bailey 85f71321fd
Update README.md
Added Quick State to the main readme file
2023-05-10 13:56:13 -07:00
Derek Bailey 3e6cd51b63
fixed bfbs gen to pass extra options (#7949) 2023-05-09 22:42:31 -07:00
Derek Bailey 10b79d87c1
removed extern code generation declarations preferring direct includes (#7948)
* removed extern code generation definitions, preferring direct includes

* add static to functions

* remove idl_gen_lua
2023-05-09 21:50:28 -07:00