summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2020-11-23[C++] Add ParseJson(), Parser(Parser&&), update fuzzers (#6284)Vladimir Glavnyy1-19/+38
- 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-23Fixed FlexBufferBuilder asserting on duplicate keysWouter van Oortmerssen1-0/+2
2020-11-19Add --require-explicit-ids to require explicit ids (#6277)Austin Schuh2-4/+14
* 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-19idl_gen_json_schema.cpp: Changed generation of array element types (#6253)schoetbi1-21/+30
* 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-16[Swift] Adds a format file and reformats the swift project (#6250)mustiikhalil1-2/+3
* Formats files & adds licence * Revert arrays * Keeps array indentation as is * Adds licence to code formatter * Updates code generators
2020-11-15Adds a fix for enum generation (#6263)mustiikhalil1-1/+0
2020-11-12Remove _POSIX_C_SOURCE and _XOPEN_SOURCE definitions when compiling o… (#6205)Jason Lenz1-0/+3
* 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-12flatc should support --binary --schema with optional scalar fields. (#6252)Stefan F1-1/+2
* 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-12Union As Accessors for C# (#6251)Derek Bailey1-2/+27
* Union As Accessors for C# * Changed loop to be compatible with older compilers * errant change fix
2020-11-05Added required-nested-flatbuffer to monster_test and fixed rust (#6236)Casper1-7/+15
Co-authored-by: Casper Neo <cneo@google.com>
2020-11-05Support size-prefixed buffers and add tests for size-prefixed messages (#6232)Charlie Yin1-11/+22
2020-10-30[C#] Optional Scalars (#6217)Derek Bailey2-20/+30
* [C#] Optional Scalars * Moved scalar optional check to avoid null enum conversion
2020-10-29Implement `Debug` trait for Rust flatbuffers. (#6207)Casper1-3/+56
* 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-28optional scalars for ts/js (#6215)Kamil Rojewski2-39/+65
* optional scalars for ts/js * removed range based for * removed range based for
2020-10-26[Java] Implement optional scalars (#6212)Paulo Pinheiro2-7/+20
Java implementation of optional scalars, following issue #6014.
2020-10-25Removed C# references from java generator. Move annotations closer to ↵Derek Bailey1-19/+13
definitions (#6204)
2020-10-24Refactor idl_gen_rust (#6206)Casper1-238/+153
* Refactor idl_gen_rust to a ForAllX continuation pattern. * Updated rust sample code Co-authored-by: Casper Neo <cneo@google.com>
2020-10-20Mass Refactoring to use `IsString` and other BASE_TYPE helpers (#6193)Casper15-128/+125
* Updated SupportsAdvancedUnionFeatures to look out for string * Mass refactoring to use BASE_TYPE helper functions. Co-authored-by: Casper Neo <cneo@google.com>
2020-10-19Updated SupportsAdvancedUnionFeatures to look out for string (#6190)Casper1-2/+2
Co-authored-by: Casper Neo <cneo@google.com>
2020-10-19Rework enums in rust. (#6098)Casper1-109/+169
* Rework enums in rust. They're now a unit struct, rather than an enum. This is a backwards incompatible change but the previous version had UB and was also backwards incompatible so... * Update and test sample rust flatbuffers * Use bitflags crate to properly support rust enums. Previously, the bitflags attribute was just ignored. This is a breaking change as the bitflgs API is not like a normal rust enum (duh). * variant_name() -> Option<_> * repr transparent * Reexport bitflags from flatbuffers * Make bitflags constants CamelCase, matching normal enums * Deprecate c-style associated enum constants Co-authored-by: Casper Neo <cneo@google.com>
2020-10-16idl_gen_json_schema Fix generation of arrays of enums (#6184)schoetbi1-34/+56
* idl_gen_json_schema.cpp: Fixed generation of arrays of enums #6175 * Fixed failing unit tests * GenBaseType generate "integer". Fixes #6066 * Ran tests/generate_code. * Removed modern R"()" strings * changed std::to_string to NumToString
2020-10-15Add generation of JSON Schema to library (#6165)tira-misu1-35/+64
* 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
2020-10-12[C++] Add option to not generate direct copy methods. (#6166)astange2-1/+3
* Add option to not generate direct copy methods. The direct copy methods generated by flatc utilize std::vector which isn't allowed on some embedded systems. Permit users of the compiler to not generate these methods so they don't have to be stubbed out. * Update docs for no-cpp-direct-copy option.
2020-10-12Add Array initialization from struct constructor (#5865) (#6147)Vladimir Glavnyy1-67/+136
- add flatbuffers::span - add new constructor for `struct` with `array` - add some test for flatbuffers::span and 'arrays_test.fbs'
2020-10-10Fixed rust nested flatbuffers for tables other than self (#6062)Casper1-13/+7
* Fixed rust nested flatbuffers for tables other than self * replaced lifetimes * Use WrapInNameSpace and also update samples Co-authored-by: Casper Neo <cneo@google.com>
2020-10-07[TS] GRPC Implementation (#6141)mustiikhalil10-151/+242
* GRPC implementation for Typescript * Fixes a couple of issues * Finished implementing the typescript support for grpc * Updated generated code * Fixes CI
2020-10-07Moved C++ to optional_scalars2 and added some tests. (#6162)Casper1-2/+2
* Moved C++ to optional_scalars2 and added some tests. Also deleted unused optional_scalars_generated.lobster * Fixed whitespece in C++ gencode & fixed BUILD file * Moved C++ onto optional_scalars2 in the .bat file Co-authored-by: Casper Neo <cneo@google.com>
2020-10-06Flatbuffer C++ UnpackTo optimization for vectors of non-bool bytes. (#6154)mrmarkwell1-44/+61
UnpackTo copies vector elements one-by-one, which can be very inefficient depending on the quality of the compiler optimizations performed. This change updates the operation for vectors of bytes that aren't enums to use 'std::copy', which is usually highly optimized. vectors of types that are more than one byte can't be optimized in this way because of the endianness of the serialized bytes vs. the target architecture endianness. vectors of enums can't be optimized because they are required to be static_cast into the appropriate enum type when stored in the vector. vectors of bools can be optimized in most cases, but since the standard allows std::vector<bool> template specialization for space-savings, std::copy doesn't work on every implementation (looking at you Microsoft). Thus, this optimization is skipped for vector<bool>. For a specific example, this improves the latency of unpacking large buffers on the Hexagon DSP by about 10x. Co-authored-by: Matthew Markwell <markwell@google.com>
2020-10-06Enables optional enums in swift (#6160)mustiikhalil1-4/+9
[Swift] Enables optional enums
2020-10-02Ruopt enum (#6156)Casper1-5/+14
* Rust support for optional enums * make optional_scalars2 for languages that support optional enums Co-authored-by: Casper Neo <cneo@google.com>
2020-10-02Fix generation of C++ code with Optional<Enum> (#6155)Vladimir Glavnyy1-8/+7
2020-09-28flatc should output a warning, when an attribute is attached more than once ↵Stefan F1-1/+1
(#6146) * 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;
2020-09-28[Python/JS/TS] Codegen SizeOf method for structs (#6136)Anass Al2-0/+25
* [Python] Codegen SizeOf classmethod for structs This codegens a `SizeOf()` classmethod for all structs since we can't determine the size of a FlatBuffer generated struct from Python otherwise. * [JS/TS] Codegen sizeOf static method for structs This codegens a `sizeOf()` static method for all structs since we can't determine the size of a FlatBuffer generated struct from JavaScript or TypeScript otherwise.
2020-09-22Minireflect fixed array (#6129)Mark Nauwelaerts1-2/+16
* CMakeLists: also really generate optional_scalars as needed by test elsewhere * [C++] Handle fixed-length array in minireflection Fixes #6128
2020-09-21Add CharToLower and CharToUpper into util.s (#6126)Vladimir Glavnyy6-28/+19
This commit adds replacement of `::tolower` and `::toupper`. Added CharToLower and CharToUpper routines reduce the number of cast operators that required for correct usage of standard C/C++ `::tolower/toupper` routines.
2020-09-18Add support of Optional<T> scalars to C++ code generator (#6092)Vladimir Glavnyy2-102/+159
2020-09-17[Kotlin] Support for optional scalars. (#6115)Paulo Pinheiro2-30/+68
More information on #6014
2020-09-17[JS] Add getFullyQualifiedName() (#6119)Anass Al1-0/+12
This optionally generates a static `getFullyQualifiedName()` function to get the fully-qualified name of a type in JavaScript and TypeScript in a similar fashion to the C++ codegen.
2020-09-17[Swift] Migrates struct write APIS to write directly to the buffer (#6093)mustiikhalil1-34/+54
* Migrates struct write APIS to in place APIS * Fixes indentation in grpc swift
2020-09-11Optional-ness in reflection (#6097)Casper2-18/+24
* Optional scalars in reflection * fixed name collision * Remove code duplicated by merge Co-authored-by: Casper Neo <cneo@google.com>
2020-09-10Rename Nullable scalars to Optional scalars (#6112)Casper4-27/+27
Co-authored-by: Casper Neo <cneo@google.com>
2020-09-04Fix for issue 6100: incorrect shrinking logic in ResizeContext() (#6102)Laurentiu Cristofor1-1/+1
2020-08-31[C++] Small refactoring of the C++ code generator (#6091)Vladimir Glavnyy1-96/+113
This commit performs refactoring (Extract Method) of the C++ code generator. It extracts code generation of a table getter/mutator into separated methods.
2020-08-22Adds proper access types for swift object api & flatbuffers & grpc (#6081)mustiikhalil2-55/+89
Fixes accessor in greeter.swift Small fix for ci
2020-08-18[Lobster] optional scalars supportWouter van Oortmerssen2-3/+7
2020-08-18[Kotlin] Attach JvmStatic annotation to each method in companion object (#6052)Yoon Kyong Sik2-43/+69
* Attach JvmStatic annotation to each method of companion object Kotlin does not have static accessor so companion object used instead of static. It's so natural. But when use kotlin companion object methods on java it is very inconvenient. ```java GeneratedClassByFlatBuffer.Companion.someMethod() ``` If use @JvmStatic annotation it can be shorten like below. ```java GeneratedClassByFlatBuffer.someMethod() ``` * Formatting by Idea Google C++ style * Add comments - Commit for missing cla Signed-off-by: Yoon KyongSik <sam1287@gmail.com> * Add comments - Commit for missing cla Signed-off-by: Yoon KyongSik <sam1287@gmail.com> * Reset code formatting except modified lines Signed-off-by: Yoon KyongSik <sam1287@gmail.com> * Pass missing flag to validateVersion method Signed-off-by: Yoon KyongSik <sam1287@gmail.com> * Add annotations to missing method in companion object * addVector * createVector * endVector * tableCreator And also I tried add compiler option for generate annotation who don't like this operation. Signed-off-by: Yoon KyongSik <sam1287@gmail.com> * Modify unmatched option name in compiler usage Signed-off-by: Yoon KyongSik <sam1287@gmail.com> * Add missing operation for finishSizePrefixed and finishStructBuffer method. Signed-off-by: Yoon KyongSik <sam1287@gmail.com> * Add compiled example with --kotlin-gen-jvmstatic option. Signed-off-by: Yoon KyongSik <sam1287@gmail.com> * Fix Compiler.md Change option name from --gen-jvm-static-annotation to --kotlin-gen-jvmstatic Signed-off-by: Yoon KyongSik <sam1287@gmail.com> * Use IDLOptions reference instead of bool parameter. Signed-off-by: Yoon KyongSik <sam1287@gmail.com> * Change option name - kotlin_gen_jvmstatic to gen_jvmstatic Signed-off-by: Yoon KyongSik <sam1287@gmail.com> * Use IDLOptions reference instead of bool parameter and missing process @JvmStatic as suffix. Signed-off-by: Yoon KyongSik <sam1287@gmail.com> * Add code generation for --gen-jvmstatic option Signed-off-by: Yoon KyongSik <sam1287@gmail.com> * Miss typo directory for including. Signed-off-by: Yoon KyongSik <sam1287@gmail.com> * Miss typo variable suffix for including. Signed-off-by: Yoon KyongSik <sam1287@gmail.com> * Fix camel case to snake case. Signed-off-by: Yoon KyongSik <sam1287@gmail.com> * Rollback generate code for gen_jvmstatic option. Signed-off-by: Yoon KyongSik <sam1287@gmail.com> * Delete generated test files. Signed-off-by: Yoon KyongSik <sam1287@gmail.com> * add missing new line at end of file. Signed-off-by: Yoon KyongSik <sam1287@gmail.com> * Remove generated test file by command line. Signed-off-by: Yoon KyongSik <sam1287@gmail.com> Co-authored-by: sam <sam@jennifersoft.com>
2020-08-04Adds a serialize helper function to native table (#6059)mustiikhalil1-20/+26
* Adds a serialize helper function to native table * Updated version
2020-08-03[TS] Fix four bugs with imported types in TypeScript. (#6054)Max Burke1-17/+72
* [TS] Fix four bugs with imported types in TypeScript. * When a type had a vector of imported enums: 1) the enum type's file wasn't added to the generated code's list of imports; and 2) the enum wasn't prefixed with the NS<hash> prefix and wasn't getting resolved; but 3) non-enum types (ie, "flatbuffers.Offset") were getting the NS<hash> prefix when they weren't. * Also, type name prefixes weren't properly attributed with imported structs in unions because the source definition passed to the typename prefixing method was for the union, not for the location of the imported struct. * clang fmt * Use of enum_def / struct_def for prefixing types needs to have the files added to imported files when not generating all types. * clang fmt
2020-07-31[Swift] Append namespace for Swift Grpc implementation (#6049)Liu Liu1-0/+8
* [Swift] Append namespace for Swift Grpc implementation * Separate ServiceName from ServiceQualifiedName.
2020-07-30adding fb import when no other imports are present (#6030)Kamil Rojewski1-1/+5
Co-authored-by: Kamil Rojewski <kamil.rojewski@gmail.com> Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>