Commit Graph

2210 Commits

Author SHA1 Message Date
Richard A Hofer aafc5dc950
Set default initialSize for Builder to 0 (#6310)
* Set default initialSize for Builder to 0

* Change default size of builder to 1024.

This matches what the C++ and Java versions do.
2020-12-07 16:20:26 -08:00
Casper 442949bc11
Rust Flatbuffers Verifier (#6269)
* Updated comments and fixed a fundemental type error.

* bump rust flatbuffers semver

* Initial commit with verifier, need to clean up

* Verifier tested. Needs clean up and refactoring.

* Display for InvalidFlatbuffer and better errors for strings

* SimpleToVerify, some refactoring

* Combined VerifierType TableAccessorFuncBody into FollowType

* scrub todos

* Update Rust get_root functions.

There are 6 variants, with verifier options, default verifier options
and no verification "fast".

* Rename root fns

* inline

* Update to use thiserror

* fix for bad compiler

* improve error formatting

* Replace multiply with saturating_multiply

* saturating adds too

* Add docs disclaiming experimental verification system

Co-authored-by: Casper Neo <cneo@google.com>
2020-12-07 18:37:51 -05:00
David P. Sicilia 9064072e8c
Version message should be a "STATUS" to avoid going to stderr. (#6316) 2020-12-07 11:50:29 -08:00
Austin Schuh fd4c1b5ff7
Replace std::string and const char* CreateSharedString with string_view (#6315)
It is useful to be able to call CreateSharedString with a string_view.
A string_view can be implicitly converted from a std::string or a const
char*.  This means if string_view is available, we can use it instead of
both other functions and get all 3.
2020-12-07 11:49:24 -08:00
Vladimir Glavnyy bc7eb8adeb
[fuzzer] Fix mistakes in the `parser` and `scalar` fuzzers. (#6314)
The flatbuffers::Parser::Parse() isn't an idempotent method for schema parsing.
This commit removes a wrong for-loop that tried to check the same schema twice.
2020-12-07 11:47:33 -08:00
Richard A Hofer fc960f3670
Add default to offset param of Python generated GetRootAs (#6312) 2020-12-07 11:34:07 -08:00
Vladimir Glavnyy f437f0f7ed
[fuzzer] Fix loading of schema in monster_fuzzer (#6308)
This is fix for (https://oss-fuzz.com/testcase-detail/6251772204810240)
2020-12-07 11:21:23 -08:00
Vladimir Glavnyy 7f33cf682a
[C++] Switch `flatc` to `--cpp-std c++11` C++ code generator (#6306)
Prior to this commit the default C++ code generator was `c++0x`.
A code generated with `c++0x` code-gen might have a vulnerability (undefined behavior) connected evolution of enums in a schema. This UB could break the backward compatibility if previously generated code casts an unknown enumerator to enum type that knows nothing about future enumerators added to the schema.

The main differences between `c++0x` and `c++11`:

- generated enums use explicitly declared underlying type;
- generated object-API tables don't declare default ctor() explicitly, instead of it default data member initializers are generated.

Please use `flatc --cpp-std c++0x` option for backward compatibility with old compilers.
2020-12-07 11:19:36 -08:00
Vladimir Glavnyy 8d9eae9ac9
[idl_parser] Unify parsing of NaN values read from .fbs and .json files (#6296)
This commit unifies parsing of NaN values read
from .fbs and .json files by converting them to unsigned NaN.
2020-12-07 11:12:58 -08:00
Wouter van Oortmerssen 2046bffa40
Moved various language tests from AppVeyor to GitHub Actions (#6300) 2020-12-03 11:26:27 -08:00
Casper 338393f854
Documentation updates for Optional Scalars (#6014) (#6270)
* Documentation updates for Optional Scalars

* Updated Support

* Reword stuff

* s/NULL/null

Co-authored-by: Casper Neo <cneo@google.com>
2020-11-24 14:05:39 -05:00
Vladimir Glavnyy c27bc2d76f
[C++] Add ParseJson(), Parser(Parser&&), update fuzzers (#6284)
- add a new method ParseJson to minimize failures during fuzzing
- add default (conditional) move-constructor for Parser
- add a new monster_fuzzer
- switch fuzzers to C++17 and `test/cpp17` generated code
2020-11-23 10:17:44 -08:00
Wouter van Oortmerssen bc518a5127 Fixed FlexBufferBuilder asserting on duplicate keys 2020-11-23 09:02:40 -08:00
Derek Bailey 100c59054c
Added a few more paths for auto labeler (#6281) 2020-11-19 22:13:19 -08:00
Austin Schuh e58c182443
Add --require-explicit-ids to require explicit ids (#6277)
* Add --require-explicit-ids to require explicit ids

We just got bit by a well intentioned developer forgetting that field
order by default is the field index.  3 people missed it in review.

I'm looking at ways to make it harder to mess up.  We are requesting
that developers explicitly id all fields in tables.  Automatic (opt in
for others) enforcement of this will help the effort succeed.  This
patch adds a command line flag which lets the user require ids on all
fields in tables.

* Added docs to Compiler.md as well
2020-11-19 17:16:45 -08:00
schoetbi 69a8b2a579
idl_gen_json_schema.cpp: Changed generation of array element types (#6253)
* idl_gen_json_schema.cpp: Changed generation of array element types
#6175

* idl_gen_json_schema.cpp: Simplified indent generation as suggested by @vglavnyy
#6175
2020-11-19 16:17:03 -08:00
Kelvin Hu 25eba6f35f
fix typo (#6280) 2020-11-19 09:08:52 -08:00
Derek Bailey e1f0f75ba6
Updated Ms build Action to fix build issue (#6279) 2020-11-19 00:20:47 -08:00
James Kuszmaul faeb04fbe1
Add type annotation to unspecified array (#6264)
The lack of any type on the `ret` variable was causing our typescript compiler to complain.
2020-11-16 10:49:53 -08:00
mustiikhalil 537212afee
[Swift] Adds a format file and reformats the swift project (#6250)
* Formats files & adds licence

* Revert arrays

* Keeps array indentation as is

* Adds licence to code formatter

* Updates code generators
2020-11-16 19:52:38 +03:00
mustiikhalil 6764f25d91
Adds a fix for enum generation (#6263) 2020-11-15 17:50:12 +03:00
AdamKorcz d6a8dbd26f
Experimental fix for failing oss-fuzz coverage build (#6259) 2020-11-13 15:48:05 -08:00
Casper ed391e1777
BREAKING: Rust flexbuffers serde human readable set to false (#6257)
Co-authored-by: Casper Neo <cneo@google.com>
2020-11-13 07:53:01 -08:00
AdamKorcz a49531414b
Update to flags in fuzzing-cmake file (#6256) 2020-11-12 10:21:34 -08:00
Jason Lenz de1f0342c8
Remove _POSIX_C_SOURCE and _XOPEN_SOURCE definitions when compiling o… (#6205)
* Remove _POSIX_C_SOURCE and _XOPEN_SOURCE definitions when compiling on OpenBSD

* Only define _POSIX_C_SOURCE and _XOPEN_SOURCE for mingw/cygwin platforms

* Only define POSIX statements for mingw/cygwin/qnx platforms
2020-11-12 10:12:32 -08:00
Stefan F d0d51e2a5c
flatc should support --binary --schema with optional scalar fields. (#6252)
* Added missing EndTable() call to VerifyObject()

VerifyObject called VerifyTableStart() but not EndTable(). This made Verifier::VerifyComplexity() increase depth_ with each table, not with the depth of tables.

https://groups.google.com/forum/#!topic/flatbuffers/OpxtW5UFAdg

* Added Check to VerifyAlignment

https://stackoverflow.com/questions/59376308/flatbuffers-verifier-returns-false-without-any-assertion-flatbuffers-debug-veri

* Add GetStringView (Convenience function to get string_view from a String returning an empty string_view on null pointer) like GetString, GetCstring

* flatc should warn, when an attribute is attached more than once.

flatc.exe -b duplicate.fbs
warning: duplicate.fbs(5, 36): warning: attribute already found: priority

duplicate.fbs:

namespace MyGame;

attribute "priority";

table Monster (priority:1, priority:2) {
}

root_type Monster;

* flatc should support --binary --schema with optional scalar fields.

This fixes 'error: Optional scalars are not yet supported in at least one the of the specified programming languages.' when calling flatc.exe --binary --schema with a schema containing optional scalars.
2020-11-12 10:06:09 -08:00
Ivo List 33ab26017d
Bump version of rules_go to 0.24.5 (#6234)
Versions of rules_go below 0.24 include platforms repository, which are lacking
definitions of os:macos, cpu:arm64 constraints.

This definitions are needed to properly select toolchains in latest
bazel.
2020-11-12 10:04:34 -08:00
Derek Bailey febb9d87c9
Union As Accessors for C# (#6251)
* Union As Accessors for C#

* Changed loop to be compatible with older compilers

* errant change fix
2020-11-12 09:28:21 -08:00
mustiikhalil 8778dc7c2b
Resets buffer without deallocating current pointer (#6247)
Resets buffer without deallocating current pointer & Bumps version
2020-11-09 17:55:53 +03:00
OptoCloud aae376e9a8
Add GetBufferSpan() function to bufferbuilder (#6235)
This will return the finished internal buffer data as a span
2020-11-05 18:09:01 -08:00
Paulo Pinheiro 0ff0471488
Modernize android build and sample (#6229)
Android build was dated, using the Android.mk approach. Current
project configuration on Android encourages the usage of CMake, so we
are updating the android project as an example on how to use either the
Java/Kotlin generate code or the native C++ one.
2020-11-05 14:23:37 -08:00
Casper 46a8c7e958
Added required-nested-flatbuffer to monster_test and fixed rust (#6236)
Co-authored-by: Casper Neo <cneo@google.com>
2020-11-05 13:58:06 -08:00
Derek Bailey bc56c553ec
Notify based on Labelling issues and PR (#6241) 2020-11-05 13:40:01 -08:00
Derek Bailey 07d7cd78a7
Converted globs to use single quotes (#6240) 2020-11-05 13:12:19 -08:00
Derek Bailey cdef70e246
More adjustments to the auto labeler (#6239) 2020-11-05 13:02:33 -08:00
Derek Bailey 9dd44df35c
Updated Lua labeller glob (#6238) 2020-11-05 12:50:33 -08:00
Charlie Yin c9b29d0885
Support size-prefixed buffers and add tests for size-prefixed messages (#6232) 2020-11-05 11:23:56 -08:00
mustiikhalil fba93e0abb
Removes duplicate swift in labeler (#6228)
Removed grpc tag from swift label set & removes duplicate swift label
2020-10-31 18:35:44 +03:00
Derek Bailey d1a545b1fb
Added more labels for auto labeler (#6227) 2020-10-30 14:01:35 -07:00
Derek Bailey ea92a668d8
[C#] Optional Scalars (#6217)
* [C#] Optional Scalars

* Moved scalar optional check to avoid null enum conversion
2020-10-30 13:18:59 -07:00
Paulo Pinheiro 6034de286a
[Label Bot] Add Java and Kotlin support for the label bot (#6226)
CI is an unrelated timeout.
2020-10-30 13:18:36 -07:00
Casper b08b0a4402
Implement `Debug` trait for Rust flatbuffers. (#6207)
* Refactor idl_gen_rust to a ForAllX continuation pattern.

* Removed unneeded SetValue and updated sample rust gencode

* Make Rust flatbuffers print right

* Generated code and removed unnecessary trait constraint

* bumped rust version. Release required

* removed an unwrap in Rust Debug-print unions

* Tested formatting flatbuffers in rust.

* Set float precision in flaky debug-print test

* impl Debug for structs too

Co-authored-by: Casper Neo <cneo@google.com>
2020-10-29 12:57:29 -07:00
mustiikhalil 17ae48decc
[Label Bot] Adds some languages to labeler bot (#6222)
* Adds swift, ts, go, py to labeler bot

* Removes unneeded dir search
2020-10-29 09:05:25 +03:00
Derek Bailey fc80979253
Auto Labeler Setup, Just C# for now (#6221) 2020-10-28 22:02:32 -07:00
Derek Bailey 55658f523a
Auto Labeler Setup, Just C# for now (#6218)
* Auto Labeler Setup, Just C# for now

* Removed trailer comma as that might caused the issue

* Removed any[].

* Changed .cs glob
2020-10-28 21:25:02 -07:00
Casper 14ecfe4236
Updated comments and fixed a fundamental type error. (#6214)
* Updated comments and fixed a fundemental type error.

* bump rust flatbuffers semver

Co-authored-by: Casper Neo <cneo@google.com>
2020-10-28 19:23:22 -07:00
Kamil Rojewski a0182cdb11
optional scalars for ts/js (#6215)
* optional scalars for ts/js

* removed range based for

* removed range based for
2020-10-28 09:45:23 -07:00
Derek Bailey 0dfcc0a378
Adds NetTest.bat to run .NET Core tests on Windows (#6216) 2020-10-27 22:51:58 -07:00
Paulo Pinheiro f9a18ea635
[Java] Implement optional scalars (#6212)
Java implementation of optional scalars, following issue #6014.
2020-10-26 17:46:50 -07:00
mustiikhalil c7586e85aa
Empties the sharedString map on reset on go and csharp (#6187)
Fixes go tests
2020-10-26 12:38:24 -07:00