Commit Graph

2463 Commits

Author SHA1 Message Date
Casper
4133a39df8 Rust structz (#6539)
* Rust structz

* struct of structs test

* swift tmp variables

Co-authored-by: Casper Neo <cneo@google.com>
2021-03-29 19:56:45 -04:00
Paulo Pinheiro
1c26d2a1a0 [Kotlin][FlexBuffers] JSON support for Flexbuffers (#6417)
* [Kotlin][FlexBuffers] Add JSON support for FlexBuffers

* [Kotlin][Flexbuffers] Re-implement JSON parser with a tokenizer.
2021-03-29 15:57:23 -07:00
Jeong YunWon
276b1bc342 [grpc] Support latest version of grpc PoC (#6338)
* use grpcpp rather than deprecated grpc++

* grpcpp Deserialize take ByteBuffer instead of grpc_byte_buffer

* grpc 1.36.0

* Fix to use grpc 1.36.0

* Fix CMakeLists to refer gRPC

* add find_package(Threads)

* Update bazel deps

* Apply workaround about boringssl build error

* Install latest cmake for osx on travis-ci

Co-authored-by: Yeom Gyusun <omniavinco@gmail.com>
2021-03-25 12:12:35 -07:00
Kamil Rojewski
124654ffc4 fixed packing structs (#6530)
* fixed packing structs in nested buffers

* fixed packing structs
2021-03-25 10:25:00 -07:00
mustiikhalil
3b7d1e86b4 [GO] Tries to add go format to the CI (#6518)
* Trys to add go format to the CI

Adds Gofmt to CI

* Adds formatting for go dir in grpc

* Small fix
2021-03-18 11:03:44 -07:00
Michael
78f0c0d1d9 [C++] #6501 - Problem when mapping a native type multiple times (#6514)
* [C++] #6501 - Problem when mapping a native type multiple times
- idl.h:
added "native_type_pack_name"
- flatbuffers.h:
added CreateVectorOfNativeStructs variants which receive a pointer to the serialization function
- idl_gen_cpp.cpp:
adapted code generation in case "native_type_pack_name" attribute is present
- extended tests & docs; improved surrounding native_type docs a little

* integrated review feedback
2021-03-18 11:01:50 -07:00
Vladimir Glavnyy
c992eafb5b [fuzzer] Add monster_debug target (#6513)
Add the `monster_debug` target for better troubleshooting.
Improve oss-fuzz logs.
2021-03-18 10:56:28 -07:00
mustiikhalil
ef8dd7792a [Swift] Removes allman rule (#6519) 2021-03-17 13:22:49 +03:00
Vladimir Glavnyy
69b329fc87 [flexbuffers, json] Parse nan and inf (#6512) 2021-03-15 11:44:42 -07:00
Kamil Rojewski
6543ba5297 fixed packing structs in nested buffers (#6509) 2021-03-11 11:14:23 -08:00
Vladimir Glavnyy
0e453ac352 [idl_parser] Add kTokenNumericConstant token (#6432)
* [idl_parser] Add kTokenNumericConstant token

This commit adds the new token for correct parsing of signed numeric constants.
Before this expressions `-nan` or `-inf` were treated as kTokenStringConstant.
This was ambiguous if a real string field parsed.
For example, `{ "text_field" : -name }` was accepted by the parser as valid JSON object.

Related oss-fuzz issue: 6200301176619008

* Add additional positive tests fo 'inf' and 'nan' as identifiers

* Rebase to HEAD

* Move processing of signed constants to ParseSingleValue method.

* Add missed `--cpp-static-reflection` (#6324) to pass CI

* Remove `flatbuffers.pc` from repository to unblock CI (#6455).

Probably the generated flatbuffers.pc should not be a part of repo.

* Fix FieldIdentifierTest()
2021-03-11 11:12:06 -08:00
Vladimir Glavnyy
e9b4ae69dc Remove flatbuffers.pc from the repository (#6508) 2021-03-11 11:11:04 -08:00
mustiikhalil
fc4fffea41 Bump grpc to 1.0.0 (#6507)
Adds void to keywords
2021-03-09 10:56:06 +03:00
dpacbach
b240ab704d Move Traits struct and Create method out of --cpp-static-reflection. (#6503) 2021-03-08 10:59:17 -08:00
Ben Niu
9a4f1f434b Disable x64-specific optimizations for ARM64EC ReadInt64 (#6506)
ARM64EC is a new ARM64 ABI designed by Microsoft to support x64 application emulation on ARM64 CPUs. When compiling for ARM64EC, both the _M_X64 and _M_ARM64EC macros are defined. However, that causes problem in compiling this file, because the __movsb intrinsic, which is lowered to rep movsb, is not supported on ARM64, so the optimization for native x64 should be disabled for ARM64EC.
2021-03-08 10:53:04 -08:00
dpacbach
fac64918dc Add --cpp-static-reflection to generate_code.bat. (#6502) 2021-03-06 22:28:27 +07:00
David P. Sicilia
a69815f72c [C++17] Add compile-time reflection for fields. (#6324)
* [C++17] Add compile-time reflection for fields.

Included in this commit is the following:

  - The C++ generator has been modified so that,
    when in C++17 mode, it will emit Table and
    Struct field traits that can be used at com-
    pile time as a form of static reflection. This
    includes field types, field names, and a tuple
    of field getter results.

  - Diffs to the cpp17 generated files. No other
    generated files are affected.

  - A unit test that also serves as an example. It
    demonstrates how to use the full power of this
    reflection to implement a full recursive
    JSON-like stringifier for Flatbuffers types,
    but without needing any runtime access to the
    *.fbs definition files; the computation is
    done using only static reflection.

Tested on Linux with gcc 10.2.0.

Fixes #6285.

* Fix int-conversion warning on MSVC.

* Try to fix std::to_string ambiguity on MSVC.

* Fix clang-format diffs.

* Fix more clang-format diffs.

* Fix last clang-format diff.

* Enable C++17 build/test for VC 19 platform in CI.

* Forgot to add value to cmake command line variable.

* Various fixes/changes in response to @vglavnyy's feedback.

* Replace "fields pack" with index-based getters.

* Fix MSVC error.

* Fix clang-format diffs.

* getter_for method returns result instead of address-of-getter.

* Next round of reviewer suggestions.

* Use type instead of hardcoded struct name.

* Fix clang-format diff.

* Add test for FieldType since it is not used in the stringify test.

* Add fields_number field to Traits struct.

* Add --cpp-static-reflection flag and put those features behind it.

* Fix clang-format diffs.

* Remove <tuple> include.
2021-03-05 10:01:40 -08:00
Kamil Rojewski
4033ff5892 fixed invalid TS call and added test files (#6495)
e581013e3d broke TS generation - please don't use "replace" to refactor function names :)
2021-03-04 12:12:44 -08:00
Casper
a083572512 disable clippy (#6494)
Co-authored-by: Casper Neo <cneo@google.com>
2021-03-01 13:51:22 -08:00
Vladimir Glavnyy
5319dedb1a [idl_parser, JSON] Disable parsing of JSON for incomplete schemes (#6493)
This commit disable JSON parsing for an incomplete scheme if JSON object is embedded into one file with the scheme.
This should improve the quality of OSS-Fuzz inputs for the parser_fuzzer target.
2021-03-01 13:40:58 -08:00
Mark Spatz
bd4e0b30a7 [idl_parser] Track included files by hash (#6434)
* [idl_gen] Delete ts::GenPrefixedImport()

I don't know what this is for, but it's the only piece of code external
to idl_parser.cpp that expects the key of Parser::included_files_ to be
a path. And it appears to be unused.

* [idl_parser] Track included files by hash

Parser::included_files_ is a map whose main purpose is to keep track of
which files have already been parsed in order to protect against
multiple inclusion. Its key is the path that the file was found at
during parsing (or, if it's an in-memory file, just its name).

This commit changes the key to be the 64 bit FNV-1a hash of the file's
name (just the name, not the complete path) xor'd with the hash of the
file's contents (unless it's an in-memory file, then we only hash the
name.)

This allows multiple include protection to function even in the face of
unique per-file include paths (fixes #6425).

* Ran tests/generate_code.sh

CI told me to do it.

* Gracefullt handle case where source_filename == nullptr

I just learned source_filename might also be null. In that case, we
should exclude it from the hash instead of hashing a zero length
string, just like we exclude source when it is null.

Presumably nameless files will never be included (they can't, can they?)
so this doesn't really matter, but I think it's prettier anyways.
2021-03-01 12:34:01 -08:00
Kamil Rojewski
bf90612007 fix for noUncheckedIndexedAccess in ts (#6474) 2021-02-25 14:57:10 -08:00
mustiikhalil
8142fedd19 Working on a python example plus fixing python grpc code (#6456)
Refactored python grpc code gen

Adds example server & client + fixes ci

Fixes generated code

Making sure we encode the reply string as utf8

Adds Readme details to clarify issue regarding encoding when python is sending/receiving
2021-02-25 14:38:12 -08:00
Colin
c0be1cb7a5 [rust] Remove debug code (#6475)
* Remove debug code

This was added for testing in the recent genericize PR for flexbuffer Reader.

* Added alloc tests -> MapReader::{is_empty, index_key, len}

* Added , accessible through Deref to deprecation warning
2021-02-24 13:00:18 -05:00
Derek Bailey
8cccdfba53 Revert "[C#] Fix truncated ArraySegment<byte> if elementSize != 1 (#6462)" (#6488)
This reverts commit cbbbaa61b3.
2021-02-23 11:30:07 -08:00
Björn Harrtell
cbbbaa61b3 [C#] Fix truncated ArraySegment<byte> if elementSize != 1 (#6462)
* WIP: Fix returned truncated ArraySegment<byte> if elementSize is not byte

* Fix

* Regenerated test code
2021-02-23 09:34:20 -08: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
Millian Poquet
1da6f4f18b [CMake] generate pkg-config flatbuffers.pc file (#6455)
This commit enables CMake to generate a flatbuffers.pc file on install.

pkg-config eases the utilization of software libraries by enabling the
developers of a library to define how the library should be used.

It can be used as a tool by build systems to find and manage dependencies,
this is notably the default Meson behavior and optionally used by CMake.
2021-02-22 10:23:38 -08:00
mustiikhalil
b5da526e6d [Swift] Moves grpc example to grpc/examples (#6479)
Updates generated Code

Removes grpc generation code from tests dir

Small fix to generate.sh
2021-02-20 23:07:48 +03:00
mustiikhalil
3b5365762d [TS] Moves grpc code to examples folder (#6476)
Adds readme
2021-02-20 20:31:00 +03:00
mustiikhalil
e2f5438ac1 Fixes grammer (#6477)
Updates docs
2021-02-19 12:16:38 -08:00
Richard A Hofer
5e3613f732 Fix sample_binary.py to use latest EndVector without a size. (#6478) 2021-02-19 12:13:50 -08:00
Kamil Rojewski
e6b911d40c updated JS docs to reflect current status (#6436) 2021-02-19 12:05:02 -08:00
mustiikhalil
0c7ae58164 [Go] Working on a go example plus fixing go grpc code (#6448)
Implemented server.go and half implemented client.go

Finishes implementation for greeter go example

Update grpc code for monster.fbs

Adds a couple of cpp methods

Adhere to gofmt standards

Adds a readme for issues with grpc
2021-02-19 12:47:59 +03:00
mustiikhalil
ae603b9770 [Swift] adds support for default vectors and strings (#6461)
Small fix

Adhere to the new protocol names
2021-02-19 12:47:28 +03:00
Arnaud LE CAM
7f47718b6d Update Building.md (#6473)
`cmake . -D FLATBUFFERS_CXX_FLAGS="Wno-error"` returns an error (file 'Wno-error' not found)
2021-02-18 19:51:41 -08:00
Thanabodee Charoenpiriyakij
54dc09e8ac GetUOffsetT must get value by GetUint32 not GetInt32 (#6072) 2021-02-18 18:38:25 -08:00
Liu Liu
334c6be496 Fix a typo in Swift codegen (#6470)
* Fix a typo in Swift codegen

* Fix code formatting.
2021-02-17 09:34:39 +03:00
Colin
4174c10e7a [rust] Genericize flexbuffer reader (#6450)
* feature/rust-tokio-bytes added feature name for tokio-bytes

* Added flexbuffer implementation, TODO: typecast to avoid recurse

* Converted codebase to utilize FlexBuffer implementation, need to resolve deserialization issues

* Added todo for lifetime issue, may use &'de [u8] for deserializer instead of current method

* Added proper &[u8] implementation

* Removed unused struct

* Added experimental fix to get_slice

* Added experimental fix to get_slice

* Avoided lifetime issues via ref structs, need to check if this hurts peformance

* Updated deserializer implementation to allow for borrowed data from Reader struct

* Fixed bug with str

* Removed unnecessary generic parameter

* Added unsafe to avoid lifetime complaints, current tests pass, need to review alternatives to unsafe

* Opinionated: Removed bytes crate as this implementation could be done in a separate crate

* Cleaned up flatbuffer

* Fixed sample / example

* Resolved PR feedback, need to resolve issues with tests

* Cleaned up FlexBuffer trait to be an auto impl

* Removed TODO

* Reverted Deserializer to only support &'de [u8]

* Cleaned up / renamed function for clarification

* Renamed FlexBuffer -> InternalBuffer for clarification on it's purpose

* Fixed issue with key bytes

* resolved issues with broken tests, confirming this is a breaking change

* Removed FIXME that's solved by splitting String and Key variants

* Implemented associated types approach

* Fixed backward slice logic

* Fixed MapReader compile error

* Added from_buffer for deserialization, removed  function since it's only needed for deserialization

* Removed dead code

* Cleaned up buffer, removed AsRef in favor of Deref

* Renamed Buffer::as_str -> Buffer::buffer_str

* Minor cleanup

* Updated documentation, need to fix tests

* Removed unnecessary &

* Removed unused lifetime

* removed unnecessary as_ref

* Minor optimization wrap-up

* resolved issue with Clone

* Added test to verify no deep-copy

* Added  for optimization

* Updated to use empty fn instead of default

* Updated comments / test name - plus the 0.3.0 version bump

* comment
2021-02-16 08:04:48 -05:00
mustiikhalil
a20f606c29 [Swift] Renaming protocols (#6469)
* Renaming protocols

* Updates Generated code

* format code
2021-02-16 14:55:47 +03:00
mustiikhalil
a72a208272 Update swift docs (#6460) 2021-02-14 10:09:11 +03:00
Casper
86401e078d Default strings and vectors: Parser + Rust support (#6421)
* Fix tests.cpp

* Parser support for vector/string defaults

* tests and default empty vectors

* addressed comments

* Default strings and vectors for Rust

* Tested Rust more_defaults

* git-clang-format

* add more_defaults_test

* fixed vector default

* removed commented out code

* more unreachable

Co-authored-by: Casper Neo <cneo@google.com>
2021-02-12 09:41:10 -05:00
mustiikhalil
6af37e6729 [CMake] Renames BUILD files (#6457)
* Renamed build to build.bazel to stop xcode from complaining about it

* Renamed all build to build.bazel

* Fixes small ci issue
2021-02-11 10:16:57 -08:00
Vladimir Glavnyy
1b88655b00 [Build, cmake] Add -Werror override option (#6429)
* [Build, cmake] Add -Werror override option

This commit adds FLATBUFFERS_CXX_FLAGS cmake option.
This option allows override the -Werror flag (or any other flags).
Related issues:  #6337, #5930

* Remove CMAKE_CXX_FLAGS replace option
2021-02-10 11:49:34 -08:00
blueshift155
0b15916e50 [C++]Fix extra char generation for byte type during json schema generation (#6276)
* Fix extra char generation for the byte type

* Fix unit tests for JSON
2021-02-10 11:48:24 -08:00
mustiikhalil
60eed0ca66 Updating working code (#6441)
Fixes issues with namespaces in grpc ts

Renamed welcome -> models
2021-02-10 11:46:45 -08:00
tira-misu
0f83367f57 JSON schema - tailing double quotes for maximum (#6452)
* 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

* Fix  double quotes for (u)int8 in json schema

* Fix reference file for JSON schema test

* Fix reference file for JSON schema test
2021-02-10 11:45:34 -08:00
Vladimir Glavnyy
fee095410b [idl_parser] Validate force_align on all possible paths (#6430)
* [idl_parser] Validate `force_align` on all possible paths

- added validation of `force_align` for `Vector`.
- added assertion to `flatbuffers::PreAlign` method

These changes should resolve following oss-fuzz issues:
- 6275816289861632
- 5713529908887552
- 4761242994606080

* size_t problem on Mac

* Fix review notes
2021-02-10 11:37:16 -08:00
Casper
6f3e45eca1 Implement Rust object API defaults (#6444)
* Implment Rust object API defaults

* satisfy return analysis

* git clang format

Co-authored-by: Casper Neo <cneo@google.com>
2021-02-07 16:51:33 -05:00
mustiikhalil
815d3e820d Upgrade swift grpc to alpha 24 (#6439)
Upgrade swift grpc to alpha 24
2021-02-04 02:01:18 +03:00