Commit Graph

2869 Commits

Author SHA1 Message Date
Bernie Innocenti a6f4194489
Fix std::span autodetection (#7805)
The current detection method fails on GCC 12.2 with -std=c++20 because
the __cpp_lib_span macro is undefined.

As per https://en.cppreference.com/w/cpp/utility/feature_test ,
__cpp_lib_span requires including either <version> or <span>.

Since both these headers were added in C++20, checking for C++20 is
sufficient (and simpler than using the library feature-test macro).

Signed-off-by: Bernie Innocenti <bernie@codewiz.org>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-30 21:59:17 -08:00
CodeMaster7000 7fb785fd89
Rename LICENSE.txt to LICENSE (#7808)
* Update PackageDebian.cmake

* Rename LICENSE.txt to LICENSE

* Update readme.md

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-30 21:36:30 -08:00
Ilya Lavrenov ca71fdfb9a
Supported cmake 3.8 (#7801) 2023-01-29 23:00:57 -08:00
Khanh Nguyen a105c26eca
Refactor usage message (#7803)
* Update usage string formation

* Rework help message to use code generator interface

* update

* refactor
2023-01-28 13:17:36 -06:00
Khanh Nguyen 5b7a02d037
Code generator refactor bug fix (#7802)
* Swift should use swift generator

* Swift should use swift generator

Co-authored-by: Mo (Khanh) Nguyen <khhn@google.com>
2023-01-26 10:57:47 -08:00
Wen Sun f5121615d9
Clean up extra white spaces (#7800)
* Clean up extra white spaces

* update

Co-authored-by: Wen Sun <sunwen@google.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-25 17:37:03 +00:00
Khanh Nguyen 34c821f4ad
Refactor languages to use CodeGenerator interface. (#7797)
* Refactor to use CodeGenerator interface.

- Move code to its own header file to be included in flatc_main.cpp
- Refactor code to use CodeGenerator interface for all languages

* Format all files

* remove lua code generator since it doesn't support bfbs generator

* Update CMakeLists file with new idl_gen_*.cpp and idl_gen_*.h files

* Add idl_gen_swift header file

* Add idl_gen_swift header file and update bazel file

* Remove CodeGenerator interface for idl_gen_text.*. Remove comments and extern declaration

* Reorder header and implementation files in CMakeLists.txt

* Add idl_gen_* header files to implementation files

* Update CMakeLists and remove unused import

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-25 09:05:48 -08:00
Wen Sun 802a3a056a
[C++] Enable using struct and array of struct as key (#7741)
* add unit tests for support struct as key

* make changes to parser and add helper function to generate comparator for struct

* implement

* add more unit tests

* format

* just a test

* test done

* rerun generator

* restore build file

* address comment

* format

* rebase

* rebase

* add more unit tests

* rerun generator

* address some comments

* address comment

* update

* format

* address comment

Co-authored-by: Wen Sun <sunwen@google.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-24 16:37:13 -08:00
Derek Bailey ee848a02e1
FlatBuffers Version 23.1.21 (#7796) 2023-01-21 12:46:57 -08:00
Björn Harrtell ef76b5ece4
[TS/JS] Entry point per namespace and reworked 1.x compatible single file build (#7510)
* [TS/JS] Entry point per namespace

* Fix handling of outputpath and array_test

* Attempt to fix generate_code

* Fix cwd for ts in generate_code

* Attempt to fixup bazel and some docs

* Add --ts-flat-files to bazel build to get bundle

* Move to DEFAULT_FLATC_TS_ARGS

* Attempt to add esbuild

* Attempt to use npm instead

* Remove futile attempt to add esbuild

* Attempt to as bazel esbuild

* Shuffle

* Upgrade bazel deps

* Revert failed attempts to get bazel working

* Ignore flatc tests for now

* Add esbuild dependency

* `package.json` Include esbuild

* `WORKSPACE` Add fetching esbuild binary

* Update WORKSPACE

* Unfreeze Lockfile

* Update WORKSPACE

* Update BUILD.bazel

* Rework to suggest instead of running external bundler

* Add esbuild generation to test script

* Prelim bundle test

* Run test JavaScriptTest from flatbuffers 1.x

* Deps upgrade

* Clang format fix

* Revert bazel changes

* Fix newline

* Generate with type declarations

* Handle "empty" root namespace

* Adjust tests for typescript_keywords.ts

* Separate test procedure for old node resolution module output

* Fix rel path for root level re-exports

* Bazel support for esbuild-based flatc

Unfortunately, we lose typing information because the new esbuild method
of generating single files does not generate type information.

The method used here is a bit hack-ish because it relies on parsing the
console output of flatc to figure out what to do.

* Try to fix bazel build for when node isn't present on host

* Auto formatting fixes

* Fix missing generated code

Co-authored-by: Derek Bailey <derekbailey@google.com>
Co-authored-by: James Kuszmaul <jabukuszmaul+collab@gmail.com>
2023-01-21 12:22:22 -08:00
Michael Le 1703662285
Flatbuffers Version 23.1.20 (#7794)
* Flatbuffers Version 23.1.20

* Fix warnings

* Fix warnings
2023-01-21 12:03:17 -08:00
liu 991b39edbe
Use CMAKE_CURRENT_SOURCE_DIR in benchmark cpp path (#7781)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-19 07:48:09 +00:00
Michael Le 81799203f1
Remove go.mod to resolve ambiguous import issue (#7783) 2023-01-18 23:40:50 -08:00
Saman 62e4d2e5b2
Fix binary output different in different platform (#7718)
* Fix binary output different in different platform, due to the nan serialization

* Add check generated code on windows ci

* Remove resdundant script

* Fix eof, and check script

* Minor bug in gen code script

* Fix windows script, remove redundant scripts

* Undelete redundante codes

* Fix github action

* Ignore eof generate grpc

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-10 12:04:25 -08:00
Ben Beasley 40758674b1
Fix some identity/equality confusion in Python tests (#7768)
Comparing short strings, small integers, and Booleans by identity
(memory address) can work due to optimizations in the Python
interpreter, but it is neither formally correct nor reliable. Use
equality comparisons instead.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-10 19:36:39 +00:00
Ben Beasley 4e75867bd2
Stop using deprecated imp package in Python tests (#7769)
It is deprecated in favour of importlib and slated for removal in Python
3.12. Since the return value of imp.find_module('numpy') is unused, the
only effect of calling this function is to raise an ImportError when
numpy is not available; importing numpy directly is already sufficient
to do this.

The imp package is still used in python/flatbuffers/compat.py, but only
on Python 2, where it is not deprecated and will not be removed.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-10 11:30:30 -08:00
José Luis Millán b17d59b18c
[TS]: builder, Fix requiredField(). Verity that the field is present in the vtable (#7739) (#7752)
* [TS]: Fix vtable creation for consecutive required fileds (#7739)

* handle feedback

* comment the schema

* comment change in builder.ts

* [TS]: builder, Fix requiredField()

Verifty that the field is present in the vtable.

* restore monsterdata binary file

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-10 10:43:17 -08:00
Ben Beasley b23493a7d2
Fix Python host-endianness dependencies (#7773)
* In Python tests, use host-endian-independent dtypes

* Fix host endianness dependence in Python flexbuffers

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-10 10:20:08 -08:00
Anton Bobukh b50b6be60a
[Kotlin] Control the generation of reflection with --reflect-names (#7775)
* [Kotlin] Control the generation of reflection with --reflect-names.
Tested:
```
$ cmake -G "Unix Makefiles" && make && ./tests/flatc/main.py
...
KotlinTests.EnumValAttributes
 [PASSED]
KotlinTests.EnumValAttributes_ReflectNames
 [PASSED]
KotlinTests: 2 of 2 passsed
...

35 of 35 tests passed
```

* [Kotlin] Fix SampleBinary by converting Byte to UByte for ubyte fields.

* [Kotlin] Annotate all generated classes with kotlin.ExperimentalUnsignedTypes.
2023-01-10 10:03:39 -08:00
Michał Górny 7bf83f5ea0
Use full project version as SOVERSION for the shared library (#7777)
Since flatbuffers is using calendar versioning and does not provide
any ABI stability guarantees, use the complete version as SOVERSION
for the shared library rather than just the major component. This
prevents breaking reverse dependencies on incompatible upgrades.

Fixes #7759
2023-01-10 09:31:49 -08:00
Ben Beasley ca6381bcc8
Fix a typo in a Python test name (#7774) 2023-01-09 10:32:50 -08:00
Derek Bailey 3b8644d32c
Defined CodeGenerator Interface and implement C++ (#7771) 2023-01-08 15:01:33 -08:00
Derek Bailey 641fbe4658
Refactor FlatC to receive `FlatCOptions` (#7770)
* Refactor FlatC to receive `FlatCOptions`

* switch to c++11 unique_ptr
2023-01-08 13:29:00 -08:00
Saman 5638a6a900
Minor improvement (#7766) 2023-01-07 19:40:03 -08:00
Chris c2668fc0e2
Add ts-no-import-ext flag (#7748)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-07 13:42:28 -08:00
Stefan F b5802b57f2
Fix [C#] Object API - Invalid Property Name used in UnPackTo for unio… (#7751)
* Fix [C#] Object API - Invalid Property Name used in UnPackTo for union fieldhttps://github.com/google/flatbuffers/issues/7750, also fixes invalid Code generated in WriteJson for Unions named Value.

* Test added: new schema union_value_collision.fbs with a Union named Value and a union field named value. The generated C# code now compiles when NetTest.bat. The Code generated with an older flatc.exe didn't compile because of a mismatch of the property name (Value vs. Value_).

* branch was not up-to-date with master

* BASE_OPTS + CPP_OPTS removed and union_value_collision_generated.h deleted

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-07 12:37:22 -08:00
Derek Bailey 06f2a3dce9 Increase float to string precision to 17 2023-01-07 12:21:25 -08:00
Derek Bailey 75af533e95
emit global scoped ::flatbuffers in c++ (#7764) 2023-01-07 12:17:07 -08:00
Derek Bailey c95cf661af
Annotated Binaries emit field names instead of type names (#7763) 2023-01-07 12:01:00 -08:00
jalitriver 920f3827a0
[C++] Add Command-Line Flag to Suppress MIN and MAX Enums (#7705)
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>
2023-01-07 10:33:11 -08:00
Max Burke 81724e5b20
Ensure that empty modules can build in TypeScript isolatedModules mode (#7726) 2023-01-06 16:42:26 -08:00
mustiikhalil 4d6a7aa8b7
Removes Dead code & regenerate code (#7744)
Formats the swift project

Update Sample files

Update docc documentation

Updates swift docs in the website

Updates code for Wasm
2023-01-06 16:40:40 -08:00
Florian Wagner e61b00359b
[Kotlin] Improve field nullability based on (required) (#7658)
* [Kotlin] Only generate nullable return types if the field is not required

* [Kotlin] Fix generated code formatting according to kotlin style guide

Co-authored-by: Derek Bailey <derekbailey@google.com>
Co-authored-by: Paulo Pinheiro <paulovictor.pinheiro@gmail.com>
2023-01-06 04:16:31 +00:00
Saman 74b5195089
Fix operator==() generated for field of fixed sized array (#7749)
* Fix operator==() generated for field of fixed sized array

* Compare address

* noexcept

* Grammer

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-05 20:11:11 -08:00
Anton Bobukh 07d9485146
Expand wildcard imports in the generated Kotlin files. (#7757)
Tested:

```
$ cmake -G "Unix Makefiles" && make && ./flattests
...
[ 99%] Linking CXX executable flatsamplebinary
[100%] Built target flatsamplebinary
ALL TESTS PASSED
```

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-05 14:34:44 -08:00
Derek Bailey 82da3da3f6
Update Readme.md for versioning
Updated the front readme doc about the non-semver versioning so that the rationale is more apparent to users.
2023-01-05 14:24:56 -08:00
Paulo Pinheiro a809a2d3f7
Add pointer reference to sibling union field on FieldDef (#7755)
To make it simple to map between a union field and its union type
field we are adding a pointer to FieldDef to point to each other. For
all other types the pointer will be nullptr.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-05 14:21:23 -08:00
Derek Bailey af9ceabeef
FlatBuffers Version 23.1.4 (#7758) 2023-01-04 15:22:46 -08:00
Michael Le 3b2eb77595
Fix go.mod name (#7756) 2023-01-04 09:27:44 -08:00
Michael Le 6420fa5c88
[Go]Add go.mod (#7720)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-03 20:56:11 -08:00
Robin Giese 01589630ba
Fix "'flatbuffers::FieldDef* field' shadows a parameter" (#7740) 2023-01-03 20:00:54 -08:00
RishabhDeep Singh e0d68bdda2
Add link to building guide (#7733) 2022-12-22 14:06:57 -08:00
James Kuszmaul e43a80c322
[TS] Fix getFullyQualifiedName codegen for typescript (#7730)
#7451 caused getFullyQualifiedName to return a name with underscores,
not periods. Because the fully qualified name is a property of
FlatBuffers, not the language being codegen'd for, it should use
periods. Fixes #7564.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-12-22 20:59:40 +00:00
RishabhDeep Singh 449d5649d6
Fixed test cases (#7732)
* Fix Cannot find symbol and test case

* Add generated tests

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-12-22 20:51:39 +00:00
Michael Le 96d438df47
Perform nil check on string fields when packing (#7719)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-12-22 20:28:00 +00:00
engedy 4e396d47bc
Add CI step to build with -DFLATBUFFERS_NO_FILE_TESTS. (#7729)
* Add CI step to build with -DFLATBUFFERS_NO_FILE_TESTS

* Fix cmake syntax

* Further fix cmake argumetns

* Add workaround for unused-parameter.

* Remove build matrix

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-12-22 08:48:48 -08:00
engedy b47ba1d5ff
Add include guards around DoNotRequireEofTest (#7728)
Guard DoNotRequireEofTest against -Wunused-function on platforms without file tests.
2022-12-21 14:59:34 -08:00
Casper a078130c87
Fix Rust codegen escaping field in tables. (#7659)
* Fix Rust codegen escaping  field in tables.

* other gencode

* gencode

* removed a debug print

* regen code

Co-authored-by: Casper Neo <cneo@google.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-12-15 06:04:57 +00:00
Saman 9ed76559df
Add clang-tidy, fix some bugpron problems. (#7708)
* Add clang-tidy, fix some bugpron problems.

* Fix more issues

* Fix some more issues :))

* Minimal pr to just add clang-tidy

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-12-14 21:58:55 -08:00
mogemimi 9927747d4e
[C++] Fix clang `-Wnewline-eof` warning (#7711)
* Fix clang -Wnewline-eof warning

* Enable -Wnewline-eof warning

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-12-14 21:35:54 -08:00