Commit Graph

2561 Commits

Author SHA1 Message Date
Derek Bailey eee44bbb26
disable cpp-linter (#7229) 2022-04-06 15:03:43 -07:00
Derek Bailey a63fa51a15
Create cpp-linter.yml (#7208)
* Create cpp-linter.yml

* Update cpp-linter.yml

* Update cpp-linter.yml

* Update bfbs_gen_lua.cpp

make some ill-formed edits to see if the linter flags them.

* Update cpp-linter.yml

Configured tidy checks

* Update cpp-linter.yml

Build project before linting to get compile_commands.json

* Update cpp-linter.yml

* Update cpp-linter.yml

* Update cpp-linter.yml

* Update cpp-linter.yml

* Update cpp-linter.yml

* lines only
2022-04-06 14:18:36 -07:00
mustiikhalil 2049e52101
Adds a way to verify/exposes Entities ids (#7221) 2022-04-06 22:54:01 +02:00
mustiikhalil 832c618f5f
Adds implementation flag for swift (#7202)
* Adds implementation flag for swift

Forces internal flag when using @_implementationOnly in swift

Fixes access type for verifier functions & encoder functions

Updates generated code

* Addresses PR comments & adds a code gen dir within the swift tests

* Adds test case for no-include

* Fixes code gen script

Removes prefix
2022-04-06 13:31:38 -07:00
Derek Bailey 14615699fa
Started to migrate to target_compile_options (#7222)
* Started to migrate to target_compile_options

* combined compile options together. Added Mac CI builds

* remove arm build (not supported). Fixed old-style-casts

* moved to using a ProjectConfig interface library to specify options

* remove the explicit CMAKE_CXX_STANDARD
2022-04-06 13:25:43 -07:00
avaliente-bc 20aad0c41e
[C++] stl_emulation span::count_ is not const anymore (#7226) (#7227)
In C++ we cannot have both assignment operator and const member. Since
span::operator= is defined, span::count_ constness must be removed.
2022-04-06 12:27:37 -07:00
Derek Bailey f083b33f2a
code gen flexbuffer verifier (#7207)
* code gen flexbuffer verifier

* remove verify nested flexbuffers from flexbuffers

* made function static, and placed higher in file

* moved function to own header
2022-04-05 16:29:42 -07:00
Stefan F bf17df346e
[C++] generate sorted #include directives (#7213)
* [C++] generate sorted #include directives

* using stable_sort instead of sort.
2022-04-04 15:20:55 -07:00
Stefan F 35281dedb5
Fix for [C++] flatc generates invalid Code in the default constructor for structs, when --cpp-field-case-style is used #7209 (#7211)
* Typo in flatc options (warning-as-errors instead of warnings-as-errors)

* VerifySizePrefixed (reflection::Schema) and GetAnySizePrefixedRoot added

* some review comments

* more review comments

* Fix for https://github.com/google/flatbuffers/issues/7209

* Fixes [C++] flatc generates invalid Code for union field accessors, when --cpp-field-case-style is used #7210
2022-04-01 13:35:57 -07:00
Jamie-Jameson c9651b7420
Add overloads for C# ByteBuffer/FlatBufferBuilder to allow adding vector blocks from ArraySegments or IntPtr (#7193)
* Add overloads to Add/Put for ArraySegment and IntPtr

In order to allow using code to reduce memory allocations, add overloads to ByteBuffer's and FlatBuffersBuilder's Put/Add methods that take ArraySegment<T> or IntPtr respectively.
Also, adaptions to the c# code generator in flatc to emit corresponding CreateVectorBlock() overloads

* Add missing files generated with generate_code.py

The previous commit changed the C# code generate, but didn't contain the updated generated test files.

* Incorporate review findings

(1) Adhere to 80 characters limit.
(2) In FlatBufferBuilder.Add(IntPtr,int), move zero length check topmost and add sanity check against negative input
2022-04-01 13:35:07 -07:00
Derek Bailey 26c3b3adab
Update codeql.yml
Replaced autobuild with cmake and make.
2022-03-31 22:19:51 -07:00
Derek Bailey da6e1b9856
Update codeql.yml
Disable all languages other than c++
2022-03-31 21:44:17 -07:00
Derek Bailey ad27d751e3
Added Oss fuzz badge 2022-03-31 21:14:09 -07:00
Derek Bailey 0aab623cb1
Create codeql.yml 2022-03-31 21:08:30 -07:00
Derek Bailey 6a446bdd83
maximize parallel builds in CI (#7206) 2022-03-31 21:07:37 -07:00
Derek Bailey 21fb5cbbc9
Create scorecards.yml 2022-03-31 21:00:12 -07:00
Derek Bailey 0da6f94867
[C++] Static assert on Flatbuffers Version (#7203)
* Static assert on Flatbuffers Version

* add comment
2022-03-31 20:56:41 -07:00
Derek Bailey 59e9713081 reduce fuzzing time to 1 minute in CI 2022-03-31 16:28:53 -07:00
Derek Bailey 40866a8927
fixed padding in struct for annotated binary (#7199) 2022-03-30 16:43:22 -07:00
Casper b71d968fad
Apply Namer prefix/suffix to other generators (#7197)
* Apply Namer prefix/suffix to other generators

* unnecessary .name

Co-authored-by: Casper Neo <cneo@google.com>
2022-03-30 18:45:11 -04:00
Casper fac0d7be02
Apply Namer to Java. (#7194)
* Started applying Namer to Java.

- Java didn't previously have keyword escaping
- Added prefixes and suffixes to the Namer methods
- TODO: migrate previous namer applications to using pre/suffixes
- Java methods / functions are interesting, it's mostly camel case
  except when it involves a struct/enum name. That section is Keep case
- I changed the casing for some internal arguments/variables. This
  violates the "don't change genfiles" rule that I've been using but it
  shouldn't break user code.
- LegacyJavaMethod2 is interesting. Basically, Java has a "mixed" case
  convention where it's camel case, except for the type/variant name
  itself, which is keep case. So a type foo_bar would become getfoo_bar
  instead of getFooBar.

* small fix

* Namer for Namespaces

* removed unused parameter, add const everywhere

* Remove unused argument

* More unused args

* Use mutable reference out parameters

* Made more strings const and inlined const empty strings

* remove do not submit

Co-authored-by: Casper Neo <cneo@google.com>
2022-03-30 18:13:16 -04:00
tira-misu 6c5603fd98
[C#] Fix collision of field name and type name (#7149)
* 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)

* [TS] Fix generation of reserved words in object api (#7106)

* [TS] Fix generation of object api

* [TS] Fix MakeCamel -> ConvertCase

* [C#] Fix collision of field name and type name

* [TS] Add test for struct of struct of struct

* Update generated files

* Add missing files

* [TS] Fix query of null/undefined fields in object api

* Add example for type field name collision
2022-03-30 12:51:58 -07:00
Derek Bailey 2d21853a7e monster fuzzer fix for json default scalars 2022-03-30 12:29:41 -07:00
Keith Smiley fec1a8d015
[swift] Add bazel configuration for Swift (#7195)
* [swift] Add bazel configuration for Swift

This change adds a simple bazel BUILD file for consuming the Swift
support. This also bumps the platforms bazel repo to fix support for M1s
and bazel 5.1+ https://github.com/bazelbuild/bazel/issues/15099#issuecomment-1075368289

The rules_swift inclusion here must happen before gRPC to ensure we
don't pull in an older version.

* Add CC=clang which is a requirement for Swift on Linux

* Add Swift to PATH
2022-03-29 21:30:33 -07:00
Derek Bailey 7fd8576233
structured comments (#7192) 2022-03-29 10:01:32 -07:00
Casper a4cb1599d8
Namerdart (#7187)
* Apply Namer to Dart.

- Also refactor idl_gen_dart a bit
  - to use more const and references
  - out parameters should be the last argument

* Add keyword test

* minor fixes

* fix merge

* extra 's'

* move dart keyord into dart dir

* Address comments

* Use $ for escaping keywords
* Outparameters for namespace_map

* Escape dollar in toString

* Escape dollar in toString2

* Use UpperCamelCase for types and variants

* try to fix ToString

* namer Type fixes

* Remove path prefixing in imports

* gen code

Co-authored-by: Casper Neo <cneo@google.com>
2022-03-28 18:07:09 -04:00
Derek Bailey ae4ce72651
fuzzed binary annotator (#7188) 2022-03-25 22:58:15 -07:00
Derek Bailey e2be0c0b06
Handle root offset and root table vtable invalidation (#7177)
* Handle invalid root offset

* Handle vtable offset invalidation

* Added script generator. Add more cases through vtable ref table size

* review responses

* vtable offset validation

* Moved padding insertion to the end. Tests invalid field lenghts

* table offsets validated. Added type after field

* validate string length

* add todo

* invalid vector length

* invalid structs

* general cleanup

* reworded invalid offsets

* example for vector of structs

* invalid vector of tables

* invalid vector of strings

* invalid vector of scalars

* vector of unions

* validate union type value

* invalid vector union type values
2022-03-23 21:51:32 -07:00
tira-misu 2ad408697f
[TS] Fix generation of struct members in object api (#7148)
* 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)

* [TS] Fix generation of reserved words in object api (#7106)

* [TS] Fix generation of object api

* [TS] Fix MakeCamel -> ConvertCase

* [TS] Add test for struct of struct of struct

* Update generated files

* Add missing files

* [TS] Fix query of null/undefined fields in object api
2022-03-23 21:40:11 -07:00
Stefan F 4213d91054
VerifySizePrefixed (reflection::Schema) and GetAnySizePrefixedRoot added (#7181)
* Typo in flatc options (warning-as-errors instead of warnings-as-errors)

* VerifySizePrefixed (reflection::Schema) and GetAnySizePrefixedRoot added

* some review comments

* more review comments
2022-03-23 21:39:38 -07:00
Will Hughes 5a13f622cf
Correctly parse lists of enums in Dart generated code (#7157)
* Correctly parse lists of enums in Dart generated code

* Add a test for #6869

* Commit generated code

* Fixed missing newline-at-eof
2022-03-22 21:56:14 -07:00
mustiikhalil 23a7e4e0b0
Adds no-includes flags to the swift code generator (#7182) 2022-03-22 21:42:20 -07:00
James Kuszmaul eeb49c2757
Move flatbuffer_ts_library to typescript.bzl (#7183)
This makes it so that users of flatbuffer_cc_library don't need to have
rules_nodejs available in their WORKSPACE, addressing #7179.
2022-03-22 21:41:39 -07:00
Stefan F 824763b316
Typo in flatc options (warning-as-errors instead of warnings-as-errors) (#7180) 2022-03-21 18:08:14 -04:00
Derek Bailey d3aeee32bb
Annotated Flatbuffer Binary (#7174)
* Annotated Flatbuffer Binary

* Various fixes

* Handles old schema

* handle multiple missing fields

* minor edits

* bazel fix, spelling fix, ascii fix
2022-03-18 14:08:05 -07:00
Derek Bailey 0bceba24db
[Lua] Apply Namer to Lua (#7171)
* Apply Namer to Lua bfbs code gen

* refactor namer into IdlNamer to keep idl includes separate

* remove commented out code

* added bfbs_namer

* remove Enum case

* add to bazel
2022-03-15 21:48:42 -07:00
David Schneider b8c77d4041
Make inclusion of header <optional> opt-out via macro (#7168)
* Allow suppression of including <optional> via macro

* Combine preprocessor conditions

* Make inclusion of header <optional> opt-in

* Make inclusion of <optional> opt-out via macro

* Auto-detect C++17+ when defining macro

* Enclose macro expression in parentheses

* Check value of macro, not whether it's defined

* Fix parentheses

* Don't define macro with expression using other macros

The preprocessor doesn't seem to like it.

* Fix parentheses
2022-03-15 17:52:11 -07:00
Casper 8468eab83b
Namersw (#7167)
* Define and use Namer overloads

* more

* NamespacedType needs a public string-like overload

* Move Rust FieldOffsetName to Namer LegacyRustFieldOffsetName

* Started swift

* More Namer updates

* Remove more usage of the variable 'name' which was semantically overloaded

* unshadow varible

* Make ptr to bool explicit

Co-authored-by: Casper Neo <cneo@google.com>
2022-03-13 18:46:27 -04:00
Casper 2b2e8d4aec
Nameroverloads (#7164)
* Define and use Namer overloads

* more

* NamespacedType needs a public string-like overload

* Move Rust FieldOffsetName to Namer LegacyRustFieldOffsetName

Co-authored-by: Casper Neo <cneo@google.com>
2022-03-13 16:54:45 -04:00
Markus b80b32bfaf
Use DESCRIPTION only if CMake version >= 3.9 (#7166) 2022-03-13 12:49:18 -07:00
James Kuszmaul e5f331db99
[TS] Add single-file ts codegen & bazel rule for typescript (#7161)
The headline here is adding a flatbuffer_ts_library rule for generating
typescript code in bazel. This entails some non-trivial other changes,
but ideally none are user-visible.

In particular:
* Added a --ts-flat-file flag that generates a single *_generated.ts
  file instead of separate files for each typescript type. This makes
  bazel much happier.
* Import the bazel rules_nodejs stuff needed to support building
  typescript in bazel
* Move flatbuffers.ts to index.ts because I wasn't sure how to make
  bazel comprehend the "main" attribute of the package.json. Happy
  to take another stab at figuring that out if really needed.
* Fix another couple keyword escaping spots in typescript...
2022-03-10 10:08:13 -08:00
Casper 2f84c60385
Apply Namer to Go code gen (#7150)
* Refactor out a  class from Rust Codegen

* Convert GenerateRustModuleRootFile

* git-clang-format

* unused variable

* parenthesis

* update BUILD file

* buildifier

* Delete bfbs_gen_rust.h

* Delete bfbs_gen_rust.cpp

* Addressed some comments

* Namer::EnumVariant

* Remove do not submit; Add Namespace vector overload

* Unshadow variable

* removed redundant variables

* Apply Namer to Python

* Use more variables a bit

* Apply const a bunch

* More variables

* Fix ObjectTypes

* git clang format

* small thing

* Simplified code around nested flatbuffers

* Make more methods const.

* Python files are kKeep case

* Address DO NOT SUBMIT in SaveType

* ensure dir exists before saving files

* clang format

Co-authored-by: Casper Neo <cneo@google.com>
2022-03-08 20:53:05 -05:00
Wouter van Oortmerssen d648396515 [Lobster] file_identifier support 2022-03-08 15:39:12 -08:00
Wouter van Oortmerssen 777e78d8dd [Lobster] support unsigned integer reads
(depends on the latest Lobster version)
2022-03-08 15:13:34 -08:00
Casper 4016c549d3
Apply Namer to Python code gen (#7146)
* Refactor out a  class from Rust Codegen

* Convert GenerateRustModuleRootFile

* git-clang-format

* unused variable

* parenthesis

* update BUILD file

* buildifier

* Delete bfbs_gen_rust.h

* Delete bfbs_gen_rust.cpp

* Addressed some comments

* Namer::EnumVariant

* Remove do not submit; Add Namespace vector overload

* Unshadow variable

* removed redundant variables

* Apply Namer to Python

* Use more variables a bit

* Apply const a bunch

* More variables

* Fix ObjectTypes

* git clang format

* small thing

* Simplified code around nested flatbuffers

* Make more methods const.

* Python files are kKeep case

* Address DO NOT SUBMIT in SaveType

* ensure dir exists before saving files

* fix space

Co-authored-by: Casper Neo <cneo@google.com>
2022-03-07 19:24:46 -05:00
Casper 40827b21b2
Fix missing 'break' (#7151)
Co-authored-by: Casper Neo <cneo@google.com>
2022-03-07 11:53:20 -05:00
Casper 65a10b6e32
Implement a config based name manager and use it in Rust codegen (#7144)
* Refactor out a  class from Rust Codegen

* Convert GenerateRustModuleRootFile

* git-clang-format

* unused variable

* parenthesis

* update BUILD file

* buildifier

* Delete bfbs_gen_rust.h

* Delete bfbs_gen_rust.cpp

* Addressed some comments

* Namer::EnumVariant

* Remove do not submit; Add Namespace vector overload

* Unshadow variable

* removed redundant variables

* Warn if converting from kKeep case.

Co-authored-by: Casper Neo <cneo@google.com>
2022-03-05 20:43:57 -05:00
James Kuszmaul 8db2fef3f7
[TS] Escape keywords in typescript object names (#7137)
* Add Object to the list of reserved keywords.
* Properly escape keywords in type names.
* Properly escape keywords in enum names.
* Properly escape keywords in enum field names.
2022-03-05 09:39:59 -08:00
James Kuszmaul 9ed1323044
Fix 64-bit numeric enum values in typescript (#7135)
* Fix 64-bit default numeric enum values in typescript

If you had a default value that wasn't a valid enum value (e.g., a zero
if you used a bit_flag setting, like you get with AdvancedFeatures
in reflection.fbs), we weren't using BigInt.

* Run generate_code.py

* [DART] Handle deprecated fields & invalid enum defaults

* Update .NET test
2022-03-04 21:57:48 -08:00
Derek Bailey 1a4c405662 updated npm to 2.0.6 2022-02-24 22:21:36 -08:00