Commit Graph

2183 Commits

Author SHA1 Message Date
Conan Chen 0bdf2fa156
[C#] Fix and improve project files (#6142)
* [C#] Fix and improve project files

* "net35" target included for Unity 5
* "net46" target included for Unity 2017
* "netstandard2.0" target included for Unity 2018 and general use
* "netstandard2.1" target included for Span<T> support

Included project properties for defining UNSAFE_BYTEBUFFER, BYTEBUFFER_NO_BOUNDS_CHECK, and ENABLE_SPAN_T conditional compilation symbols.

* Add documentation on building for C#
2020-09-28 11:56:59 -07:00
Kamil Rojewski 2eedc769d5
possibility to create a vector from an iterator (#6135) 2020-09-28 09:45:48 -07:00
Stefan F ab01ae1620
flatc should output a warning, when an attribute is attached more than once (#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 09:28:47 -07:00
Anass Al 689bfafa7e
[Python/JS/TS] Codegen SizeOf method for structs (#6136)
* [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-28 08:54:50 -07:00
石晓伟 641309a5bf
unix2dos on tests/FlatBuffers.Test/FlatBuffers.Core.Test.csproj (#6133) 2020-09-28 08:10:06 -07:00
春条 52e3628794
SpanT is available in .Net Standard 2.0. (#6137) 2020-09-25 10:39:28 -07:00
Nat Jeffries dca12522a9
Add static cast to avoid implicit double promotion. (#6132)
Add static cast from float to double in flexbuffers.h to avoid implicit double promotion error. This error is surfacing during the tensorflow lite for microcontrollers build since we enabled -Werror and -Wdouble-promotion.
2020-09-24 09:35:29 -07:00
春条 e0bbaa6f9c
[C#]Change to ENABLE_SPAN_T that doesn't require UNSAFE_BYTEBUFFER. (#6073)
* ENABLE_SPAN_T doesn't require UNSAFE_BYTEBUFFER.

Change to ENABLE_SPAN_T that doesn't require UNSAFE_BYTEBUFFER.

* Selectable framework.

Changed target framework to allow selection of 2.0 or 2.1 (or higher)

* Added target framework version check.

* Add core test project.

* Added run on .Net Core.
2020-09-23 13:16:00 -07:00
Derek Bailey ab139d6bea
Revert "[C#] Fix and improve project files (#6116)" (#6130)
This reverts commit 750281630b.
2020-09-23 13:14:51 -07:00
Mark Nauwelaerts 34d67b425e
Minireflect fixed array (#6129)
* CMakeLists: also really generate optional_scalars as needed by test elsewhere

* [C++] Handle fixed-length array in minireflection

Fixes #6128
2020-09-22 17:57:01 -07:00
Björn Harrtell 96d5e35977
[JS/TS] fix flatbuffers default export (#6123)
* [TS/JS] Export flatbuffers namespace as default export

* [TS/JS] Fully qualified name

* Export as default and named
2020-09-21 09:46:24 -07:00
Vladimir Glavnyy eb686a86f3
Add missed file generated by optional_scalar.fbs (#6125) 2020-09-21 09:37:01 -07:00
Conan Chen 750281630b
[C#] Fix and improve project files (#6116)
* [C#] Fix and improve project files

* "net35" target included for Unity 5
* "net46" target included for Unity 2017
* "netstandard2.0" target included for Unity 2018 and general use
* "netstandard2.1" target included for Span<T> support

Included project properties for defining UNSAFE_BYTEBUFFER, BYTEBUFFER_NO_BOUNDS_CHECK, and ENABLE_SPAN_T conditional compiler constants.

* Add documentation on building for C#
2020-09-21 09:32:59 -07:00
Vladimir Glavnyy fb4e1c34f9
Add CharToLower and CharToUpper into util.s (#6126)
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-21 09:31:27 -07:00
Vladimir Glavnyy 8c67b5b129
Add support of Optional<T> scalars to C++ code generator (#6092) 2020-09-18 12:51:17 -07:00
Paulo Pinheiro 6228b66d3d
[Kotlin] Support for optional scalars. (#6115)
More information on #6014
2020-09-17 23:31:51 -07:00
mustiikhalil e1be8aaadd
Bump version for latest swift version (#6121) 2020-09-17 12:28:42 -07:00
Björn Harrtell 94873e595c
[JS/TS] Modernize TypeScript / JavaScript flatbuffers support (#6095) 2020-09-17 12:21:14 -07:00
Anass Al b8e87fafe4
[JS] Add getFullyQualifiedName() (#6119)
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 12:19:07 -07:00
Diogo Monteiro f96d1ef744
[Java] allowing larger buffer sizes when growing a byte buffer (#6118)
Related with issue #6113.

`(old_buf_size & 0xC0000000) != 0` checks if we can duplicate old_buf_size
 and still be under 2GB (by checking if bit 30 or 31 is 1). This doesn't
allow buffers larger than 1GB.

The strategy now is to allocate a buffer with the maximum array size
when we detect that we are overflowing the 2GB.

Also changed default buffer size to 1024.
2020-09-17 11:55:24 -07:00
mustiikhalil 89435303b7
[Swift] Migrates struct write APIS to write directly to the buffer (#6093)
* Migrates struct write APIS to in place APIS

* Fixes indentation in grpc swift
2020-09-17 17:10:59 +03:00
Casper c75ae24293
Optional-ness in reflection (#6097)
* Optional scalars in reflection

* fixed name collision

* Remove code duplicated by merge

Co-authored-by: Casper Neo <cneo@google.com>
2020-09-11 14:20:32 -07:00
Casper 338944d3d9
Rename Nullable scalars to Optional scalars (#6112)
Co-authored-by: Casper Neo <cneo@google.com>
2020-09-10 13:04:36 -07:00
Ruslan Burakov f5ab24bc41
Avoid memcpy call for empty vectors (#6111)
Co-authored-by: kuddai <kuddai92@gmail.com>
2020-09-10 13:03:15 -07:00
Maxim Zaks 92a8c1a0f2
[JS] FlexBuffers Fix for wrong type of offset and length values (#6107)
* Adding FlexBuffers support for Dart language

* Introduce snapshot method.

* Fix docu

* Replacing extension methods with static methods in order to support older Dart version

* Improving code based on PR feedback. Mainly rename refactoring.

* Addressing all PR feedback which does not need clarification

* exchange dynamic type with Object

* Adds better API documentation.
[] operator throws a very descriptive exception in case of a bad key.

* Implementation of JavaScript FlexBuffers decoder

* implements JS FlexBuffers builder

* replacing _toF32 with Math.fround

* Introducing test for BigInt number

* Moving functions from BitWitdth & ValueType object into BitWidthUtil and ValueTypeUtil accordingly.
Removing defensive checks.
Introducing fix for large int numbers by converting them to BigInt type.
Introducing handling for BigInt type in `add` method.
Using TextEncoder and Decoder to handle string / utf8 conversion.

* rename variable

* Lets user turn deduplication strategies for strings, keys and vector of keys off while building FlexBuffer.
Implements quick sort and choses quick sort if the number of keys is bigger then 20.
Removes unnecessary dict lookups in BitWidthUtil helper functions

* make iwidth and uwidth computation simpler and faster

* Making redInt and readUint a bit faster and shim the BigInt / BigUint usage

* Fixing a bug in FlexBuffers JS, where offsets and lengths are stored and read as int and not as uint values.

* Fixing a bug in FlexBuffers Dart, where offset and length values are stored and read as int values instead of uint values
2020-09-10 12:36:37 -07:00
mugisoba 6cea45dcd3
fix c# json serializer commandline argument docs (#6104) 2020-09-09 15:02:24 -07:00
Laurentiu Cristofor fec58aa129
Fix for issue 6100: incorrect shrinking logic in ResizeContext() (#6102) 2020-09-04 15:52:13 -07:00
Maxim Zaks 71aca81ff9
[JS] FlexBuffers Support (#5973)
* Adding FlexBuffers support for Dart language

* Introduce snapshot method.

* Fix docu

* Replacing extension methods with static methods in order to support older Dart version

* Improving code based on PR feedback. Mainly rename refactoring.

* Addressing all PR feedback which does not need clarification

* exchange dynamic type with Object

* Adds better API documentation.
[] operator throws a very descriptive exception in case of a bad key.

* Implementation of JavaScript FlexBuffers decoder

* implements JS FlexBuffers builder

* replacing _toF32 with Math.fround

* Introducing test for BigInt number

* Moving functions from BitWitdth & ValueType object into BitWidthUtil and ValueTypeUtil accordingly.
Removing defensive checks.
Introducing fix for large int numbers by converting them to BigInt type.
Introducing handling for BigInt type in `add` method.
Using TextEncoder and Decoder to handle string / utf8 conversion.

* rename variable

* Lets user turn deduplication strategies for strings, keys and vector of keys off while building FlexBuffer.
Implements quick sort and choses quick sort if the number of keys is bigger then 20.
Removes unnecessary dict lookups in BitWidthUtil helper functions

* make iwidth and uwidth computation simpler and faster

* Making redInt and readUint a bit faster and shim the BigInt / BigUint usage
2020-08-31 12:16:55 -07:00
Vladimir Glavnyy 04d87ffec3
[C++] Small refactoring of the C++ code generator (#6091)
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-31 12:13:23 -07:00
Navin Mohan bb25956f09
Wrap verify file id condition in Check call (#6085)
Run clang-format

Update testcase
2020-08-31 11:32:13 -07:00
Wybe Westra 49f4948f06
+ Add `removable-media` plug to the snapcraft config (#6083) 2020-08-24 09:55:38 -07:00
mustiikhalil eeacc53d22
Adds proper access types for swift object api & flatbuffers & grpc (#6081)
Fixes accessor in greeter.swift

Small fix for ci
2020-08-22 22:39:09 +03:00
Wouter van Oortmerssen f3003e08d0 [Lobster] missed a test 2020-08-18 14:29:44 -07:00
Wouter van Oortmerssen d713a00843 [CMake] enabled multi-core builds in VS projects 2020-08-18 14:00:22 -07:00
Wouter van Oortmerssen 77f966f89f [Lobster] optional scalars support 2020-08-18 14:00:02 -07:00
Yoon Kyong Sik e86d5b8e97
[Kotlin] Attach JvmStatic annotation to each method in companion object (#6052)
* 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-18 09:44:43 -07:00
Derek Bailey db2aa9b4ec
[C#] Cleaned up .NET testing script for Mono (#6016)
* Cleaned up .NET testing script for Mono

Cleaned up the .NET testing script to make it a little better. It
purposefully doesn't delete the .NET installer and SDk after running the
script, so that they can be used in subsequent invocations. This greatly
speeds up the script.

The downloaded files are ignored by git by default. They can be
explicitly cleaned up by runnning the clean script (clean.sh).

* Trying using older Version indicator

* Remove lins to monsterdata and reference it directly.

* Updated appveryor script to remove copying of files no longer needed

* Continue to update appveyor script to work. Disabled CS0169 in ByteBufferTest
2020-08-17 13:10:10 -07:00
mustiikhalil 63cc0eec4e
Adds a serialize helper function to native table (#6059)
* Adds a serialize helper function to native table
* Updated version
2020-08-04 13:53:40 +03:00
Max Burke c30a87de6f
[TS] Fix four bugs with imported types in TypeScript. (#6054)
* [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-08-03 12:08:52 -07:00
Liu Liu a0fb30575c
[Swift] Append namespace for Swift Grpc implementation (#6049)
* [Swift] Append namespace for Swift Grpc implementation
* Separate ServiceName from ServiceQualifiedName.
2020-07-31 10:07:45 +03:00
Omer Akram 77c18c1d69
export a __version__ variable for python module (#5309)
* export a __version__ variable for python module

* assign version to be used below

* better support python2

* Add copyright header
2020-07-30 15:56:21 -07:00
Kamil Rojewski f1f23d08ed
adding fb import when no other imports are present (#6030)
Co-authored-by: Kamil Rojewski <kamil.rojewski@gmail.com>
Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
2020-07-30 15:55:11 -07:00
mustiikhalil f1025b2847
[Feature] Checks for Nullable strings (#6050)
* Allows null strings in createString method c#

* Adds nullable strings to JS and swift

* Changes js checks

* Fixes typo
2020-07-27 09:57:50 -07:00
Liu Liu 5d052f4e55
[Swift] RFC: Switch Swift namespace from public enum to ordinary concat with _ (#6045)
This PR attempts to switch namespace from public enum back to ordinary
concat with _ in Swift. This kept style similar with protobuf, but
different from other popular style guide in Swift.

This is needed because previously, when we do `public enum`, we don't
really know when to declare and when to extend (extension). With namespace
implementation in this PR, there is no such ambiguity.
2020-07-27 11:06:11 +03:00
Casper 18b015d25a
Rust codegen improvements and lint fixes (#6046)
* Improve rust codegen

* one more unneeded lifetime

* Added a derive default

Co-authored-by: Casper Neo <cneo@google.com>
2020-07-25 13:46:20 -07:00
mustiikhalil d76e93f277
adds code gen for optional scalars in swift (#6038)
Adds swift test code

Replaces if statments

Adds swift to supported languages for optionals

Moved std::string to auto

Adds nullable scalars support in object api
2020-07-25 17:59:34 +03:00
jdess 82fac326c5
[C++] Fix compiler error from deleted assignment operator (#6036) (#6047)
* [C++] Fix compiler error from deleted assignment operator (#6036)

The assignment operator of the `buf_` member is deleted, we cannot call it from the assignment operator of the `TableKeyComparator` struct.

=> Also delete the assignment operator of the `TableKeyComparator` struct (already private anyhow).

* [C++] Fix compiler error from deleted assignment operator (#6036) - fix extraneous semicolon

The assignment operator of the `buf_` member is deleted, we cannot call it from the assignment operator of the `TableKeyComparator` struct.

=> Also delete the assignment operator of the `TableKeyComparator` struct (already private anyhow).
2020-07-24 10:35:27 -07:00
Casper 043b52bd4a
Optional Scalars support for Rust (#6034)
* First draft of rust optionals

* Code cleanup around ftBool and ftVectorOfBool

* Tests for Rust optional scalars

* test bools too

Co-authored-by: Casper Neo <cneo@google.com>
2020-07-23 16:30:27 -07:00
Shengzhe c8fa0afdfc
Allow to run cpp tests under grpc/tests/ using bazel. (#6040)
This is the first step to upgrade grpc dependency to the latest version.

- Patch protobuf 3.6.1. and grpc 1.15.1 to fix build errors when using the latest Bazel version (3.4.1).
- Add grpc/tests:grpc_test. One can kick off tests in Bazel by calling `bazel test grpc/tests/...`.
- Add missing build targets in tests/BUILD in order to support grpc/tests/BUILD
2020-07-21 11:08:01 -07:00
Olivier Le Doeuff 6d0aae73cd
Fix git command executed in wrong folder when doing cmake superbuild (#6039) 2020-07-20 12:26:01 -07:00