Commit Graph

1812 Commits

Author SHA1 Message Date
Light Lin ce3a1c43a2 [Dart] Fix prepare space for writeListInt64 and writeListUint64 (#5654)
* Fix prepare space for writeListInt64 and 

writeListUint64

* Fix align issues
2019-12-18 11:23:54 -08:00
Matt Brubeck aa75e5734b Make Rust constants public (#5659)
* Make Rust constants public

Otherwise they cannot be accessed by code that consumes the generated
bindings.

* Re-generate test code

* Add a test for enum constants
2019-12-17 12:18:59 -08:00
cryptocode 2790fee257 Add namespace qualification to union types (#5666) 2019-12-17 09:11:26 -08:00
Max Burke eddebec1b6 Bugfix for Rust generation of union fields named with language keywords (#5592)
* Bugfix for Rust generation of union fields named with language keywords

Looking at ParseField, it appears that in the case of unions, an extra field with a `UnionTypeFieldSuffix` is added to the type definition, however, if the name of this field is a keyword in the target language, it isn't escaped.

For example, if generating code for rust for a union field named `type`, flatc will generate a (non-keyword escaped) field named `type_type` for this hidden union field, and one (keyword escaped) called `type_` for the actual union contents.

When the union accessors are generated, they refer to this `type_type` field, but they will escape it mistakenly, generating code like this:

```
  #[inline]
  #[allow(non_snake_case)]
  pub fn type__as_int(&self) -> Option<Int<'a>> {
    if self.type__type() == Type::Int {
      self.type_().map(|u| Int::init_from_table(u))
    } else {
      None
    }
  }
```

Which will fail to build because the field is called `self.type_type()`, not `self.type__type()`.

* [Rust] Add crate-relative use statements for FBS includes.

At present if a flatbuffer description includes a reference to a type in
another file, the generated Rust code needs to be hand-modified to add
the appropriate `use` statements.

This assumes that the dependencies are built into the same crate, which
I think is a reasonable assumption?

* Revert "[Rust] Add crate-relative use statements for FBS includes."

This reverts commit d554d79fec.

* Address comments raised in PR

* Update documentation comments per feedback

* Fix typo
2019-12-15 15:18:22 -08:00
FujiZ 030fee36ab wrap multiple statements in do {} while(!IsConstTrue(true)) (#5655) 2019-12-13 10:14:14 -08:00
Gautham B A f9724d1bde [gRPC] Uncomment MessageBuilder (#5658)
The line where the MessageBuilder was
constructed was commented out (perhaps
an oversight).
2019-12-09 10:28:31 -08:00
Björn Harrtell b20801ca40 Supress unsigned-integer-overflow for PaddingBytes (#5647) 2019-12-09 10:06:04 -08:00
cryptocode a8e800bd7c Add --force-empty-vectors option (#5653)
The rationale for this option is that JSON clients typically want empty arrays (i.e [] in the JSON) instead of missing properties, but not empty strings when the value isn't set.
--force-empty is kept as-is, i.e. it will force both empty strings and vectors.

Closes #5652
2019-12-05 17:33:45 -08:00
Wouter van Oortmerssen d7530ae961 Fixed enum min/max values not properly escaped.
Change-Id: I503fbfaff1d2579807ca71a07cca8363dff75e52
2019-12-05 14:28:36 -08:00
bttk 99d11e279f Split Bazel targets into multiple packages (#5640)
* Split Bazel targets into multiple packages

* Merge /include/BUILD back into /BUILD
2019-12-02 14:14:48 -08:00
Google AutoFuzz Team 4fd8eb214b Remove a static_assert (#5643)
Having a static_assert on MSAN and ASAN prevents
the fuzzers from being used with different engines,
like TSAN, UBSAN, … but also with fuzzers that aren't
using MSAN/ASAN like afl for example.
2019-12-02 14:13:28 -08:00
lu-wang-g 65f8703572 Flatbuffers Python Object API (#5616)
* Flatbuffers Python Object API

Implement the logic to generate the Python object API that can
unpack the data from a buf class into an object class, and pack
the data of an object class to a buf class.

* Fix the build issues

Remove unused parameters and replace auto in the for-loop statement
with std::string to make it compatible with VS2010.

* Fix the build issues.

* Add support for Array type

Added logic to handle Array type in Python Object API. Updated the
generated code accordingly.

* Fix the old style casting from int to char

* Fixed another conversion from int to char

* Fixed the import for typing

Importing typing may cause errors when a machine do not have the
moduel typing installed. This PR fixes the issue by guarding
"import typing" with the "try/except" statement.

* Fix issue of iterating the vector of import list

* Update the generated examples using generate_code.sh

* Fix the import order for typing

The import list was stored in unordered_set, so that each generated
codes may have different import order. Therefore, it failed in the
consistency test where two generated copies need to have exactly the
same apperance.

* Optimize unpack using numpy

Use numpy to unpack vector whenever it is possible to improve unpack
performance.

Also, added codegen command for Python specificly in generate_code.sh,
because --no-includes cannot be turn on for Python.

* Fix the import order

* Update generate_code.bat for windows accordingly

* Replace error message with pass

Avoid printing error message for every Python2 users about typing.
Replace it with pass.
2019-12-02 14:11:28 -08:00
Ivan Shynkarenka 75823cc275 [Clang 10]: definition of implicit copy constructor for 'TableKeyComparatoris deprecated #5649 (#5650) 2019-12-02 14:10:09 -08:00
nilsocket 58e279244c [docs]: add missing semicolon (#5648)
Add missing semicolon for table field.
2019-12-02 14:01:25 -08:00
Tiago Silva 3c964e10ab [GO] Fix support for enums with underscores and Unions with imported members (#5600)
* Fix Enum Stringer method when Enum has underscores

Fixes #5481

* Fix go package importing itself when Union has imported members.
2019-11-26 12:25:36 -08:00
Vladimir Glavnyy c3c32ec942 Fix ambiguity of a type deduction in TEST_EQ macro if arguments have `enum class` type. (#5630) 2019-11-25 12:56:47 -08:00
Vladimir Glavnyy 075e8d676b Simplify declarations of x-macro FLATBUFFERS_TD (#5638) 2019-11-25 12:54:59 -08:00
FujiZ bcf1bd5c9e read vtable size through ReadScalar() (#5636) 2019-11-25 12:52:42 -08:00
Derek Bailey 136d75fa65 Changed null checks in test. Removed verifier pointer usage (#5634) 2019-11-21 10:25:31 -08:00
Vladimir Glavnyy 091fa1fd1b Add testing of C++ with sanitizers (CI-Docker) (#5631)
* Add C++ build testing with clang and gcc

This adds Dockerfiles which test building flatc and the C++ library against clang
and gcc. See discussion at #5119.  It is derived from the Travis CI tooling.

The GRPC tests are failing due to #5099 so those are commented out.

These are run from the .travis.yml file rather than the tests/docker/languages
folder because the builds may each take longer than 30 minutes and were hitting
Travis timeouts.

Parallel builds and build caching attempt to keep the build times low.

* Add GCC 8.3 and Clang 7.0 with sanitizers into CI (based on #5130)

- Add a docker based on Debian Buster.
- Add C++ building scripts for the docker.
- Leak-sanitizer requires SYS_PTRACE.
2019-11-18 12:16:41 -08:00
FujiZ ff3781dc2d add namespace prefix in FLATBUFFERS_MAX_BUFFER_SIZE (#5629) 2019-11-18 12:02:14 -08:00
Malar Kannan 6beb9f49cb Support for python grpc - continuing the work from the pull request #4270 #4705 (#5613)
* Support for python grpc

* add few fixes

* Fixes build

* Fix python generator

* Add tests

* Fix grpc python test

* Fix tests and add incomplete python generator

* Fix python generator

* Add python generator methods

* Fix Appveyor build

* grpc python support v0.1

* Update tests

* update grpctest

* Remove duplicated code and fix a brace

* tests for flatbuffers grpc python

* Updated tests + removed SerializeToString, From String

* remove pickle import

* include missing files in ci - BUILD and generated test result
2019-11-14 16:58:35 -08:00
Derek Bailey 80988ea869 Removed idl_gen_general.cpp and move contents to code_generators.cpp (#5625) 2019-11-14 15:47:58 -08:00
Derek Bailey 0f2ff7eaa9 Lua cleanup (#5624) 2019-11-14 15:46:46 -08:00
Derek Bailey dda095023d [C++] Adds basic schema evolution tests (#5611)
* Added basic schema evolution tests

* Add BUILD targets for evolution tests. Added to test/generate_code scripts

* Use vector.front() instead of vector.data()

* Added --scoped-enums option for evolution test
2019-11-14 15:44:18 -08:00
Derek Bailey adbcbba5d1 [C++, C#, Java] Separated C# and Java generators into their own classes (#5618)
* Cloned idl_gen_general.cpp to idl_gen_csharp.cpp and removed java references

* Java generator changes
2019-11-11 11:37:55 -08:00
Dmitry cbbd6aca04 add check for root_type specified for json schema generation (#5622) 2019-11-11 11:33:27 -08:00
messense 405c64e07d [Rust] Bump smallvec version to 1.0 (#5621)
See https://github.com/servo/rust-smallvec/pull/175 for changelog.
2019-11-11 09:52:26 -08:00
Derek Bailey 42c08cbca6 Ran src/clang-format-all.sh (#5617) 2019-11-11 09:29:37 -08:00
Wouter van Oortmerssen 33d5dd9bdd Improved pull request & clang-format instructions.
Change-Id: Ia439bcc61bac5788792244d10e573b1fba54b347
2019-11-07 14:37:33 -08:00
Derek Bailey 105dd528e9 Change monster_extra generation to use flatbuffers::unique_ptr (#5612) 2019-11-07 14:10:41 -08:00
Derek Bailey f0f0efe7b8 [C++] Refactor to conform to Google C++ style guide (#5608)
* Automatic refractor of C++ headers to Google C++ style guide

* Automatic refractor of C++ source to Google C++ style guide

* Automatic refractor of C++ tests to Google C++ style guide

* Fixed clang-format issues by running clang-format twice to correct itself. Kotlin was missing clang-format on after turning it off, so it was changed,
2019-11-07 12:22:54 -08:00
Wouter van Oortmerssen e837d5a296 Fixed deprecated method in GRPC Java test.
Change-Id: Iccae8fe9409adbf3cd3013a5cf3368e068175ad3
2019-11-04 17:23:01 -08:00
Wouter van Oortmerssen 9834ee9787 Fixed Apache license not using canonical version.
Now identical to https://www.apache.org/licenses/LICENSE-2.0.txt

Change-Id: I6eab8bdee2472107dfc72265e204fdd16f3abc2e
2019-11-04 17:15:56 -08:00
Even Rouault 44b2ab087c include/flatbuffers/base.h: fix no_sanitize issue with old clang (#5610)
Older clang versions raise:
```
./flatbuffers/base.h:365:1: error: unknown attribute 'no_sanitize' ignored [-Werror,-Wattributes]
__supress_ubsan__("alignment")
^
./flatbuffers/base.h:246:50: note: expanded from macro '__supress_ubsan__'
  #define __supress_ubsan__(type) __attribute__((no_sanitize(type)))
                                                 ^
```

Comparing https://releases.llvm.org/3.6.0/tools/clang/docs/AttributeReference.html
with https://releases.llvm.org/3.7.0/tools/clang/docs/AttributeReference.html
shows that __attribute__((no_sanitize(type))) is available since 3.7.0
2019-11-04 14:58:51 -08:00
Derek Bailey 46ae3f80a6 [C++, Java, C#, TypeScript, JavaScript] Skip generation of mutable union types (#5599)
* Skip generation of mutable union types

* Removed C# and Java unit tests that mutated a Union type
2019-11-04 14:54:44 -08:00
Even Rouault 7b38aa71e6 flatbuffers.h: fix documentation warning (#5607)
Fixes following clang -Wdocumentation warning:
```
flatbuffers.h:1762:17: error: parameter ']' not found in the function declaration [-Werror,-Wdocumentation]
  /// @param[in]] v A const reference to the `std::vector` of structs to
```
2019-11-04 14:28:33 -08:00
Derek Bailey 661bedd837 Add Lua FlatbufferBuilder Clean() method to enable reuseable builders (#5606) 2019-11-04 14:27:59 -08:00
Paulo Pinheiro 8526e12d73 [Kotlin] Fix union vector accessor after change in Java API (#5605)
Kolin uses java library as dependency, which changed the way it access union vector recently
(e365c502ff).

This changes updates kotlin code generation to match Java's changes.
2019-11-04 14:25:07 -08:00
Paulo Pinheiro 3c7b660d62 [flatc] Remove an always true condition for flexbuffers (#5604)
The condition was unnecessary and Detected by

PVS-Studio
V560 [CWE-571] A part of conditional expression is always true: !opts.use_flexbuffers. flatc.cpp 438
2019-11-04 14:23:15 -08:00
Lawrence Chan 964365ba69 [Go] Add UnPackTo functions (#5598) 2019-11-04 12:12:25 -08:00
iceboy 32254b7acd [Go] Object API support (#5339)
* start

* works for current usages!

* unpack: vector of struct

* optimize byte slice

* support nested struct

* support null table

* support struct

* support union

* update generated code

* grumble

* fix compiler warning

* update generated code

* wrap type in namespace

* bug

* wrap in namespace

* enum byte arrays

* generate struct for unions

* basic testing

* remove branching

* fix assert

* pack vector of fixed structs correctly

* omit null vectors

* Refactor Union Pack and UnPack methods

Remove append usage to increase code efficiency when dealing with large vectors

* generate goldens
2019-10-31 11:13:45 -07:00
Mathias Svensson 521e255ad9 Rust: Add idiomatic iterator for Vector type (#5579)
* Rust: Add idiomatic iterator for Vector type

* Add comments explaining some implementation details
2019-10-28 14:19:47 -04:00
Even Rouault 1b85292fd3 Fix typos in comments (#5590)
Found by the https://github.com/OSGeo/gdal/blob/master/gdal/scripts/fix_typos.sh
script on the internal copy of flatbuffers inside GDAL
2019-10-28 10:02:46 -07:00
Derek Bailey 480815447a C++ verifier for evolved union fields should return true (#5586) 2019-10-28 09:43:33 -07:00
Derek Bailey 8d5e424c65 Add ByteBuffer copy for vector of bytes in Java (#5587) 2019-10-28 09:30:31 -07:00
Mathias Svensson b4774d2354 Rust: Fix Copy and Clone impls for a few generic types (#5577)
* Rust: Fix Copy and Clone impls for a few generic types

* Add tests for Copy+Clone

* Wrap Copy+Clone checks in a #[test] function
2019-10-28 00:20:29 -04:00
Vladimir Glavnyy 26f238c248 Add `--clean-first` to the cmake-build command (travis) (#5574)
- `--clean-first` runs `clean` target to remove previously generated files
- missed `monster_extra_generated.h` file added to the `flattests` target
2019-10-21 10:11:32 -07:00
StackDoubleFlow e93c8c46e6 Fix Follow implementation for bool (#5554) 2019-10-19 23:24:13 -04:00
Vladimir Glavnyy e21516b9d7 Fix issue #5557 (#5573)
- remove not necessary file `monster_test_generated.h` from sample_bfbs.cpp
2019-10-18 10:16:55 -07:00