Commit Graph

2456 Commits

Author SHA1 Message Date
Max Burke 5993338ee3
[ts] Builder incorrectly serializing empty strings (#7047)
* [ts] Builder incorrectly serializing empty strings

The builder was returning an offset of zero for empty strings. This is
leading to flatbuffers which fail verification in other languages, such
as Rust.

* tests expect 0 offset for null or undefined strings
2022-01-29 14:23:57 -08:00
Justin T Conroy 19920db39f
Include a SizePrefixed..HasIdentifier for c++. (#6871)
* Include a SizePrefixed..HasIdentifier for c++.

* Add updated generated code.
2022-01-28 20:52:32 -08: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 028f0fde62
'flattest': Add --test_path option (#7041) 2022-01-27 14:21:01 -08:00
MS 87343631b9
Added support for clang-cl on windows (CMake) (#7038)
* Moved the CMake check for Clang *after* the one for MSVC, as clang-cl
  matches both Clang and MSVC.
* Removed /MP definition - controlled by CMake
* Added CPP define for _CRT_SECURE_NO_WARNINGS so clang can see it
  (it seems it doesnt pick up the pragma in util.cpp)
2022-01-27 10:48:01 -08:00
LouisP 1fbfaf5c5e
Fix/cmake build grpc (#7028)
* BuildFlatbuffers.cmake: add verbose on build

* BuildFlatbuffers.cmake: properly add *.fb.* files with --grpc argument

When "--grpc" argument is provided as an extra flag, resulting grpc files
should be added as part of the interface library.
This prevent adding .fb.cc files manually to the build.

V2: fix dependency on grpc files
2022-01-25 20:57:31 -08:00
BogDan Vatra 4421375bb6
Add FlatBuffers::FlatBuffers interface, needed for FetchContent_Declare (#7023) 2022-01-25 20:51:00 -08:00
Jon Simantov 162ad7a37e
Fix comment with line orders - Rust should be last. (#7037)
Fix for #6867.
2022-01-25 16:43:08 -08:00
Jon Simantov a0a6c3f8c6
Use actions/checkout@v2, which fixes security vulnerability. (#7036)
Fix for issue #6999.
2022-01-25 16:19:05 -08:00
Jon Simantov a2d38fbb98
Add --warnings-as-errors to flatc compiler. (#7034)
* Add --warnings-as-errors to flatc compiler.

With this option set, flatc will return an error on parsing if
any warnings occurred.

* Add unit test for opts.warnings_as_errors.

* Change explicit option setting to default.
2022-01-25 14:01:16 -08:00
Derek Bailey 9ef1524d3f
Emit include for bfbs-gen-embed (#7031) 2022-01-25 10:43:16 -08:00
Derek Bailey 0c9de0352a
Upgraded GRPC version to 1.42.0 (#7033) 2022-01-25 09:59:29 -08:00
Ivan Dlugos a783bc9267
chore: dart 2.0.5 release changes (#6983) 2022-01-20 13:30:03 -08:00
Marcin Witkowski aff818cebf
rust: Allow for usage in no_std environment (#6989) 2022-01-20 11:49:02 -05:00
Danila Kutenin d7b75417fc
Make flatbuffer builder deterministic (#6993) 2022-01-14 15:37:27 -08:00
Wouter van Oortmerssen a42e898979
Added verifier alignment checking to table fields (#7018) 2022-01-14 14:39:15 -08:00
LouisP 96cc2f3ee3
BuildFlatBuffers.cmake: fix arguments not passed properly to flatc (#7013)
Fix regression introduced by commit e9d4532401
2022-01-14 14:38:04 -08:00
Richard A Hofer 3250a1f8dd
Add initial C# vector of unions support to the documentation. (#6880)
* Add initial C# vector of unions support to the documentation.

* Add notes about missing documentation for vector of unions.
2022-01-13 22:15:35 -08:00
Alex E ace4a37f22
[TS/JS] BigInt implementation (#6998)
* BigInt implementation

* Unit test reading long from existing bytebuffer

* Code review
2022-01-06 20:35:37 -06:00
Advait Jain f28c2b2936
Avoid implicit conversion from float to double. (#7003)
https://github.com/tensorflow/tflite-micro makes use of flatbuffers with
a variety of DSP toolchains.

Without the change from this PR, we can get a double-promotion warning
with some of these DSP toolchains:
```
flatbuffers/include/flatbuffers/util.h:104:11: error: implicit conversion increases floating-point precision: 'std::numeric_limits<float>::_Ty' (aka 'float') to 'double' [-Werror,-Wdouble-promotion]
  T eps = std::numeric_limits<float>::epsilon();
    ~~~   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
2021-12-23 20:31:30 -06:00
Shlomi Regev 96f3cf690f
Rearrange #include directives to pass to compilation with a particular DSP toolchain (#7000)
iomanip isn't available for our DSP. Luckily, we compile with FLATBUFFERS_PREFER_PRINTF, so moved the #include directive there.
ctype.h has to be included explicilty for tolower() and toupper().
2021-12-22 10:40:38 -06:00
Panagiotis Gourgaris b3edfdbfb7
Reverting grpc generated file suffix (#6995)
* Reverting grpc generated file suffix

* - Setting the greeter sample as it was
- Reverting the include of the generated message in grpc.cc file
2021-12-18 18:23:28 -08:00
Wouter van Oortmerssen b8aaccee82 Disable parsing of nested_flatbuffers as bytes by default
Parsing as bytes produces buffers that are unsafe to access unless passed thru a verifier,
whereas users could reasonably assume that any JSON parsed without errors is safe to access.
Users that still have legacy JSON files with such bytes in it will get a helpful error point them
to the option to turn on to have it work again.
2021-12-15 10:41:29 -08:00
Wouter van Oortmerssen 2dc8ae7742 Enable OSS-Fuzz on CI 2021-12-14 12:10:43 -08:00
Wouter van Oortmerssen 5b0d491127 Updated FlexBuffers fuzzer 2021-12-14 11:57:42 -08:00
Wouter van Oortmerssen d8b7041d7e Added alignment checking to FlexBuffers verifier 2021-12-14 11:20:23 -08:00
Wouter van Oortmerssen 5a0c3366c3 FlexBuffers verifier additionally checks for nesting 2021-12-14 11:20:23 -08:00
Wouter van Oortmerssen f8148b8dad Made FlexBuffers reuse tracker track types 2021-12-14 11:20:23 -08:00
Derek Bailey a22b1b6267
Prevent shadow with _{{FIELD_NAME}} (#6991) 2021-12-13 21:27:36 -08:00
Wouter van Oortmerssen 4264daadd2 FlexBuffers fuzzer fixes
- String dedup wasn't handling internal nulls correctly.
- Verifier wasn't recursing for certain types.
- Vector self-reference could create inf recursion.
2021-12-13 15:47:06 -08:00
Derek Bailey 3cbc120a08
Refractor Flatc Options (#6987)
* Moved error/warnings to bottom of std error

* Refactor flatc options

* pass program name to flatc

* extra -- in one option

* merge of upstream
2021-12-13 13:56:47 -08:00
Vadim-Valdis Yudaev 8dcd2682c7
[CMake] Add option for disable universal on OSX (#6990)
See https://github.com/google/flatbuffers/issues/6988
2021-12-13 13:32:58 -08:00
Derek Bailey b78002ff3e
Validate C# json/object-api options (#6985) 2021-12-13 11:52:01 -08:00
Derek Bailey c555ee8fac
Add .NET test to github workflows (#6982) 2021-12-13 11:51:27 -08:00
Biswapriyo Nath b92bb0584d
[CMake]: Fix version in pkgconfig file (#6986)
This change checks if the current source directory is a git repository.
If this is not checked the git command picks the commit hash from
parent directory. e.g. when tarball is extracted in a packaging repository.
2021-12-10 15:40:21 -08:00
Wouter van Oortmerssen 956d11569e re-enabled FlexBuffer JSON in fuzzer 2021-12-10 15:22:06 -08:00
Wouter van Oortmerssen e367ca32ad
Verifier for FlexBuffers (#6977)
* Verifier for FlexBuffers

* Verifier improvements & fuzzer
2021-12-10 14:59:08 -08:00
Biswapriyo Nath 705f27f6ee
[CMake]: Fix python command for mingw environment (#6984)
In mingw build environment, this fixes the build error:
'py' is not recognized as an internal or external command
The 'py' launcher is available for MSVC python only. More
https://docs.python.org/3/using/windows.html#from-the-command-line
2021-12-10 11:28:24 -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
Danila Kutenin 11749095a1
Make idl_parser deterministic (#6976)
* Make idl_parser deterministic

Some golden tests even exercise this [logic](df2df21ec1/tests/prototest/test.golden (L8)). Let's make the parser fully stable not depending on the implementation of std::sort

* Retry the ci
2021-12-09 13:07:29 -08:00
Derek Bailey d0cede9c90
Bumping to Version 2.0.5 (#6967) 2021-12-09 10:31:57 -08:00
David Sanders fcc2bee0b6
Fix typo in variable name (#6973) 2021-12-09 10:30:15 -08:00
Derek Bailey e08da4dea2
remove Appveyor's Vs2010 and 13 builds (#6969) 2021-12-06 14:18:22 -08:00
tira-misu 18538c401c
[TS] Fix reserved words as arguments (#6955) (#6956)
* 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)
2021-12-06 14:16:04 -08:00
Derek Bailey e57f4ab2d2
Update stale bot version and provide away to exempt issues with the not-stale label (#6968) 2021-12-03 13:51:05 -08:00
Derek Bailey deed68db5d
missing generated files (#6966)
These shouldn't be used, so short circuiting CI.
2021-12-03 11:23:58 -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
Markus Junginger cffe0c4546
FixedTypedVector: add const to ElementType() and size() (#6965) 2021-12-02 20:32:51 -08:00
Panagiotis Gourgaris fadd40e402
Have grpc include file with correct filename-suffix given to flatc (#6954)
When generating code with --grpc,  --cpp and using filename-suffix, the generated grpc files where not including the correct header that had the filename-suffix. As a suffix, they used the default "_generated".
Free functions for these were used to get the suffix. FlatBufFile had such methods, but also needed to be into its base File and use these.
- grpc generated files include the correct message header.
- grpc generated files also have the suffix
- grpc generated cc file does not include initial message header
2021-12-02 09:49:12 -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