Commit Graph

1812 Commits

Author SHA1 Message Date
Austin Schuh e9d9d64527 Add presubmit.yml for bazel CI configuration (#5193)
https://github.com/bazelbuild/continuous-integration/tree/master/buildkite#configuring-a-pipeline
2019-02-19 02:55:50 +01:00
Wouter van Oortmerssen 78c50e340b Fix AppVeyor script not including CMake dir
Change-Id: I737a74dd4d31ca6d1559958f4c76e61e1f0a2c64
2019-02-14 16:21:07 -08:00
Christopher Cifra 9d483a3f0b Changed the JavaScript generation to emit createX helper functions just like the TypeScript code generation. I also added code so that the create methods have documentation in both JavaScript and TypeScript. (#5168) 2019-02-15 01:00:33 +01:00
Eric Erhardt b650dfba49 [C#] Fix FlatBuffers.Tests when ENABLE_SPAN_T is defined (#5182)
There is a test code error that causes the CanReadCppGeneratedWireFile test to fail when ENABLE_SPAN_T is defined. When TestarrayofboolsLength is not 0, then the GetTestarrayofboolsBytes() should have a length.
2019-02-15 00:53:36 +01:00
Aleix Pol 6980818337 Install flatc as requested (#5180)
If FLATBUFFERS_BUILD_FLATC and FLATBUFFERS_INSTALL are set, flatc should
be installed regardless of the configuration.
2019-02-14 22:19:36 +01:00
Kamil Rojewski 224f7527e3 Generting imports for external enums in TS (#5175) 2019-02-14 22:08:55 +01:00
Austin Schuh a66a88034a Fix bazel build (#5174)
rules_go was out of date.  Update that.  Also, a dependency
monster_extra_cc_fbs snuck in.  So, let's add that.

Fixes: #5163
2019-02-14 22:05:46 +01:00
Gabriel Nützi e1defaae5e Add flag to make short names in JS/TS. (#5152)
* Add flag to make short names in JS/TS.

* Synced all missing docs in Compiler.md <-> flatc.cpp.

* Review changes.
2019-02-11 21:34:10 +01:00
Enrico Olivelli 78fdce28c7 Make ByteBufferFactory an abstract class in order to make FlatBuffers compatible with Java7. (#5155)
Introduce a HeapByteBufferFactory singleton instance in order to reduce allocations.
Clarify the usage of LITTLE_ENDIAN ByteBuffers in ByteBufferFactory.
2019-02-11 21:02:32 +01:00
iceboy 60e94cf083 Implement (shared) attribute for C++ (#5157)
* Implement native_shared attribute for C++.

Fixes #5141. See also #5145.

* Refine comment in idl.h

* Also refine docs

* Revert "Also refine docs"

This reverts commit 09dab7b45c.

* Also refine docs again.

* grumble
2019-02-11 20:53:45 +01:00
Wouter van Oortmerssen cf47f27164 Turn on -Werror=unused-private-field for Clang.
Change-Id: Ibabc1456baf190eba191ebe0b81e3d73a4acc98f
2019-02-11 09:55:48 -08:00
Wouter van Oortmerssen cc7f9b89f3 Made FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE #ifdef out less
This is to protect against cases where part of a project is
compiled with or without this flag, making for very fragile
and hard to find bugs, such as sizeof(Verifier) changing.

Change-Id: I01c895cdc5b44f860e4b0b9c9613bff1983e2b9d
See: https://bugs.chromium.org/p/chromium/issues/detail?id=929847
2019-02-07 16:34:25 -08:00
Wouter van Oortmerssen 600f3fbcd4 Reduced `force_align` in tests to 8, to work with --object-api.
More detail:
https://github.com/google/flatbuffers/projects/6#card-17401359

See also the .md changes in this commit.

Change-Id: Idfa68b2fd3bdb19979833737d3a3cf83ec1d6775
2019-02-07 14:51:04 -08:00
Charlie Harrison 76a024137f Removing 'using namespace' usage in test_builder (#5154)
* Removing 'using namespace' usage in test_builder

* Fix GRPC tests
2019-02-05 02:07:05 +01:00
Travis Staley 31e34faa15 Changing array to be an associative array so that the Name function can work with non-sequential enums as well as those beginning at something other than zero. (#5151)
Also including the resulting changes in php files.
2019-02-04 23:33:57 +01:00
Jon Kunkee 4d98faa515 Only use __movsb on architectures that support it (#5147)
With the introduction of Windows 10 on ARM (ARM64), code that assumes
that Windows targets are always x86 or x86_64 targets needs to be
updated.

The hot function ReadUInt64 has been optimized in MSVC builds using the
compiler intrinsic __movsb. Since this does not exist on ARM64 Windows,
this change uses the pure C++ path that other platforms use instead.
2019-02-04 18:57:34 +01:00
Henry Lee d8210d5a83 Make changes on the make_unsigned type trait (#5136)
Fix a typo in the static assert message in `make_unsigned`

Support more specifications for `make_unsigned`
2019-01-28 17:31:58 -08:00
Vladimir Glavnyy 7d3930a2fd Repair `fallthrough` was broken by d4493165 (#5115) (#5139)
- GCC: fixed broken `fallthrough` (checked with 7.3 and 8.2)
- Clang: added `fallthrough` support
- Clang: added `-Wimplicit-fallthrough` checking
2019-01-28 10:16:12 -08:00
find 347dba8501 delete zero width space characters <U+200B>'s to avoid MSVC warning C4819 (#5133) 2019-01-24 15:02:48 -08:00
Vladimir Glavnyy fcacb46d01 Replace deprecated Vector::Length() with Vector::size() (#5131)
- enable FLATBUFFERS_ATTRIBUTE if C++17 or higher
2019-01-24 13:33:19 -08:00
Vladimir Glavnyy 3f388ec747 Repair MSVC-CRT leakage detector and enable this detection with Appveyor-CI (#5105) 2019-01-24 13:30:11 -08:00
jean-airoldie 38bf4cfc03 [Rust] Added global namespace imports (#5121)
* [Rust] Added global namespace imports

* Documented the need for global imports

* Added white_space params to GenNamespaceImports

* Removed a \n from GenNamespaceImports
2019-01-24 13:25:56 -08:00
Henry Lee c2f40c37b2 [C++]Support reverse iterator in Vector (#5128)
* Add `const` keyword to the `operator-(const uoffset_t &)` function in
`VectorIterator`

* Support reverse iterator in Vector

Introduced a new VectorReverseIterator type. We cannot directly use
`std::reverse_iterator<VectorIterator>` because the signature of
`operator*` and `operator->` in the VectorIterator class are not
standard signatures.

Also added `rbegin()`, `rend()`, `cbegin()`, `cend()`, `crbegin()`
and `crend()` in the Vector class.
2019-01-24 13:24:01 -08:00
Vlad Frolov 63d51afd11 [docs] [rust] Add "Useful tools created by others" section (#5127) 2019-01-17 11:56:52 -08:00
Vladimir Glavnyy d44931656a Fix high certainty warnings from PVS-studio (#5115)
* Fix high certainty warnings from PVS-studio

- Introduced FLATBUFFERS_ATTRIBUTE macro to use [[attribute]] if modern C++ compiler used

* Update the note about __cplusplus usage in the MSVC
2019-01-17 09:49:27 -08:00
Robert bbfd12eb11
Docker tests for Zend PHP and Mono C#; Python coverage; TODO for HHVM PHP (#5125)
* Docker test for Zend PHP 7.3

* hhvm

* move failing hhvm test to TODO zone

* c# mono 5.18 test

* python coverage reports
2019-01-16 16:41:02 -08:00
cor3ntin 7c94ff6c30 Reference::ToString should be const (#5118) 2019-01-14 09:39:58 -08:00
Vladimir Glavnyy 4fa4d36706 Add default NaN/Inf to C#, Java, Python (#5107)
* Add default NaN/Inf to C#, Java, Python

* Python NaN/Inf test added

* Remove MSVC2010/13 dependent code
2019-01-14 09:23:42 -08:00
unintellisense 46208b1e91 JS- support clear() method on builder (#5109)
* support clearing flatBuffer builder in js

* remove unused member
 reset force_defaults
dont actually need to clear data in bytebuffer
2019-01-14 09:21:42 -08:00
Vladimir Glavnyy b99332efd7 Move all platform dependent headers and code to util.cpp module (#5106) 2019-01-07 10:12:57 -08:00
Vladimir Glavnyy dd288f71f3 Add `NaN` and `Inf` defaults to the C++ generated code. (#5102)
* Add `NaN` and `Inf` defaults to the C++ generated code.

* Refactoring: add FloatConstantGenerator

* Refactoring-2:

- remove isnan checking for all float/double values
- add most probable implementation of virtual methods of FloatConstantGenerator

* Add conditional (FLATBUFFERS_NAN_DEFAULTS) isnan checking
2019-01-07 10:04:44 -08:00
Yong Tang 155c55900f Add repository name to build_defs.bzl (#5104)
In flatbuffers, build_defs.bzl has been updated to have the
bazel rule `flatbuffer_cc_library` defined. Therefore, it should
be possible to build another application and using `flatbuffer_cc_library`
directly (by `load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")`)

However, when I tried to do the above, I saw the following errors in bazel:
```
ERROR: /root/.cache/bazel/_bazel_root/c27e9809996ce9a9c0ed8dd79ef0897b/external/arrow/BUILD.bazel:12:1: in deps attribute of cc_library rule @arrow//:arrow_format: target '@arrow//:runtime_cc' does not exist. Since this rule was created by the macro 'flatbuffer_cc_library', the error might have been caused by the macro implementation in /root/.cache/bazel/_bazel_root/c27e9809996ce9a9c0ed8dd79ef0897b/external/com_github_google_flatbuffers/build_defs.bzl:216:16
```

The reason for the bazel error was that `//:runtime_cc` and `//:flatc` does not have
the repo name prefixed.

By prefix `` the above bazel build error could be resolved.

This fix should help other programs to use flatbuffers directly through bazel.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2019-01-07 09:55:55 -08:00
Robert 0eb7b3beb0
[Go] Namespaced imports fix (#5097)
Track and emit required FlatBuffers namespace imports in generated Go code.

Update Go code generator by moving most functionality into the generator class, to facilitate namespace tracking. (Note that the git diff in this combined commit may appear large due to this refactoring, but very little code was actually changed.)
Update Go code generator by tracking namespace imports when generating FlatBuffers code.
Update Go code generator by emitting package imports to correctly reference code in other FlatBuffers namespaces.
Create Go test that checks the usage of InParentNamespace objects (as defined in the example schema).
Create Docker test that checks the Go language port.
Fixes #4883
Fixes #3927

Individual commits:

* remove "static" from soon-to-be method functions
* move almost all functions into class as methods
* set current namespace and emit package names if needed
* track imported namespaces
* parent namespaces work
* docker test for go ^1.11
* update base image name for go docker test
* remove cerr debugging
* formatting fixes
* re-run generate_code.sh
* explicitly test namespace imports and usage
2018-12-27 20:57:19 -05:00
Wouter van Oortmerssen a821b15634 Added -Werror=implicit-fallthrough=2 to GCC 7 build.
Change-Id: I3f23bb1478763334dbc7e43579555518fb2412c2
2018-12-26 16:03:07 -08:00
Peter Dillinger 87704e987e Performance improvement to generated+supporting PHP (#5080)
By avoiding redundant alignment+alloc checks (startVector does prep) and virtual calls
(by making the class final) in inner loops.
2018-12-20 16:10:20 -08:00
Owen O'Malley cb99116aca Java: Pulling in protobuf's faster UTF-8 encoder. (#5035)
* Pulling in protobuf's faster UTF-8 encoder.

* Remove Utf8 unsafe code.
2018-12-17 13:53:49 -08:00
Vladimir Glavnyy 9ad73bf5a7 Fix 'no_sanitize_undefined' attribute for GCC4.8 (#5090) 2018-12-17 11:50:31 -08:00
tira-misu dba962ebb8 Enable flatbuffer to initialize Parser from bfbs (#4283) (#5077)
* Enable flatbuffer to initialize Parser from bfbs (#4283)

Now its possible to generate json data from bfbs data type and flatbuffers data
and visa versa.

* add deserialize functionality in parser from bfbs
* add small usage sample

* Fix build break

* Merge branch 'pr/1' into fix-issue4283

* Fix buildbreak

* Build monster_test.bfbs with --bfbs-builtins

Attribute flexbuffer has be included in bfbs. Only with this attribute test
will run. By initialization a parser by a bfbs the attribute has to be known
for this filed. monsterdata_test.golden has a flexbuffer field so parse would
fail.

* Fix generate_code.sh

* Revert automatic indent changes by IDE

* Auto detect size prefixed binary schema files

* Use identifier (bfbs) to detect schema files
2018-12-13 11:59:27 -08:00
Christian Lang 60a0f35fbc generated cmake command for flatc generation should depend on source file (#5087) 2018-12-13 11:56:51 -08:00
Rob Agar 58e8552da0 Get rid of reproducible build warning by removing build date & time from flatc version (#5086)
* disable reproducible build warning due to date/time macros

* wrapped GCC pragmas in #ifdef _GNUC_

* removed __DATE__ and __TIME__ macros from flatc.cpp
2018-12-10 12:48:09 -08:00
Austin Schuh d56a4055da Add flatbuffer_cc library support (#5061)
* Add flatbuffer_cc library support

* Update flags so all the tests pass

Tests now all pass!

* Modify the tests to use the generated code

This should be a simple serialize/deserialize test of the new generated
code to make sure the bazel rules are doing something sane.

* Use generated monster_test.fb in testing/test.cpp

cmake drops it's generated code in tests/monster_test_generated.h
Instead of checking that in, let's generate it with bazel.

* Make grpc tests depend on monster_test_generated.h

* Remove redundant cmake dependency

This should address @aardappel's feedback.

* Run flatc for Android as well

This will fix the last travis.ci failure

* Add generated output folder and fix flags

* Move flatbuffers_header_build_rules to the library that uses it

* Use --cpp-ptr-type to fix android

Android was the only target using the STL emulation layer.  It needed
the --cpp-ptr-type flatbuffers::unique_ptr flag to work.  Add it!

* Roll back changes to use autogenerated monster_test_generated.

Flip tests/test.cpp to use the autogenerated file as well.
2018-12-10 12:23:40 -08:00
Kamil Rojewski 30c4948541 Renamed JS generator to explicitly state it generates TS too (#5043) 2018-12-06 11:12:06 -08:00
Simon.S.King 80d148b175 [net] Fix issue #5036 when write a double value into bytebuffer at big endian machine with unsafe mode. (#5076) 2018-12-03 09:50:26 -08:00
Matt Frantz 2aa0d9a54d Support nulls in String compare, CreateSharedString (#5060) 2018-12-03 09:48:50 -08:00
Robert 79cd55bd3a
CI: Dockerized language port tests (#5066)
This runs a script in TravisCI that executes a bunch of small Docker image
scripts to test the language ports in isolated environments. This allows us to
test multiple language versions with little additional complexity.

Covers:

+ Java OpenJDK 10.0.2
+ Java OpenJDK 11.0.1
+ Node 10.13.0
+ Node 11.2.0
+ Python CPython 2.7.15
+ Python CPython 3.7.1
+ Rust 1.30.1
2018-11-29 22:03:06 -08:00
Robert b378b8eb69
Fix create_vector_of_strings to use the stack, and test it. (#5074) 2018-11-29 11:47:28 -08:00
Sumant Tambe 9635d494b3 Fix Java generator bug that ignores bidi streaming attribute (#5063)
* Fix Java generator bug that ignores streaming: bidi attribute
Tests

* Java gRPC client streaming test

* Java gRPC Bidi Streaming Test
2018-11-29 10:33:17 -08:00
Robert 0143f4e364
disable unimportant RAM-heavy test b/c Windows (#5047) 2018-11-16 22:03:51 -08:00
Russell Chou e161ade68c Make Parser skip files it's seen already. (#5048)
The use case is so we can batch compile a bunch of schemas, some which can depend on each other, without caring about their order.
2018-11-16 17:11:23 -08:00
Wouter van Oortmerssen f575b02fda Make string/vector field serialization order not depend on optimizer.
Multiple calls of e.g. CreateString inside a call to a CreateTable
could cause those strings to end up in different locations in the
wire format, since order or argument evaluation is undefined.

This is allowed by the FlatBuffer format, but it is not helpful,
especially when debugging the contents of binaries, or comparing
against a "golden" binary for tests etc.

Now making sure that all the CreateTableDirect calls first serialize
sub strings/vectors before calling CreateTable.

Also made similar changes to the serialization of "binary schemas".

Change-Id: I5747c4038b37a0d400aca2bc592bec751cf5c172
2018-11-16 17:08:35 -08:00