Commit Graph

42 Commits

Author SHA1 Message Date
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
Wouter van Oortmerssen 21591916af Fixed missing code from @javax.annotation PR.
https://github.com/google/flatbuffers/pull/4986 missed part of the
implementation.

Change-Id: Ie41771eb018a550c289c77ebe9ef5c50d1ad6751
2018-11-02 11:40:21 -07:00
Thomas 33791dc7b0 Add compare operator to code generated for c++ (#4940)
* Add operator== for c++ genated code

New "--gen-compare" option for flatc to generate compare operators. The operators are defined based on object based api types.

Inspired by issue #263.

* Improve compare operator for c++.
Thanks for the code review.

- Improve robustness against future schema extensions
- Code style
- Fix --rust generation in generate_code.sh
2018-09-21 16:53:59 -07:00
Robert 3c54fd964b Port FlatBuffers to Rust (#4898)
This is a port of FlatBuffers to Rust. It provides code generation and a
runtime library derived from the C++ implementation. It utilizes the
Rust type system to provide safe and fast traversal of FlatBuffers data.

There are 188 tests, including many fuzz tests of roundtrips for various
serialization scenarios. Initial benchmarks indicate that the canonical
example payload can be written in ~700ns, and traversed in ~100ns.

Rustaceans may be interested in the Follow, Push, and SafeSliceAccess
traits. These traits lift traversals, reads, writes, and slice accesses
into the type system, providing abstraction with no runtime penalty.
2018-09-02 18:26:55 -07:00
aardappel 4898809eca FlatBuffers implementation for the Lobster programming language
Language, see: http://strlen.com/lobster/ and https://github.com/aardappel/lobster
2018-07-29 13:23:00 -07:00
shassani 51d9641de6 flatbuffer force-empty option (#4822) 2018-07-16 16:05:06 -07:00
Paul Reimer 741c63052d Add --force-defaults option to flatc [C++, parser] (#4729)
* Add --force-defaults option to flatc

To emit default values for fields which are not present or which are set
to the default value.

* flatc option --force-defaults should have a default value (false) and take action on the builder_ within the Parser constructor

* Add help text from flatc --force-defaults to Compiler.md doc

* Clarified docs for flatc --force-defaults, and imply that this behaviour is not normally needed.

* Updated docs and flatc help text for --force-defaults option
2018-06-27 09:12:52 -07:00
Nathan Mitchell b4ca4d3cde Javascript: Add suppport for ES6 style exports (#4754)
* Add suppport for ES6 style exports

Adds support for ECMAScript 6 module exports during Javascript
generation. This is useful as many development projects are
switching to this new standard and away from custom module
solutions. By integrating support into flatbuffers, users
do not need to perform additional post-processing of generated
files in order to use flatbuffers output directly in their
codebases.

Reference to ECMAScript 6 modules:
https://www.ecma-international.org/ecma-262/6.0/#sec-exports

Changes:
* Added `--es6-js-export` option to cli parser tool
* Added conditional code to generate a ES6 style export
  line, replacing the normal NodeJS/RequireJS line.

* Fixed missing export statements

Added exports for definition and struct names that were not inside namespaces

* Updated Compiler.md with new generator option

Added entry to Compiler.md in docs for the `--es6-js-export` flag, including a brief description of the effects and usefulness.
2018-05-31 08:29:58 -07:00
Dan Field 88912640d0 Add [Dart] support (#4676)
* Add [Dart] support

* fix enum vectors

* Allow for opt out of string interning

* fix comment style, make interning opt in

* remove Offset<T>, prefer int

* avoid creating unnecessary vtable objects

* start work on tests - do not generate builder if struct has 0 fields - add int64

* support reading structs properly

* correctly handle reading vectors of structs, dartfmt

* support structs, fix unnecessary prepares

* fix bool customizations

* undo unintentional removal of file

* docs updates, complete tutorial, bug fix for codegen

* more documentation

* Update docs, add to doxygen file

* update package structure, add samples script/code

* rearrange sample

* Tests

* Add readme for pub

* cleanup package for pub

* update docs for renamed file

* remove custom matcher, use `closeTo` instead

* remove unintentional file

* remove unintended file checkin

* use auto, move method, cleanup

* refactor to ObjectBuilders, add Builders

* Update tests, examples

* Add files missing from previous commit

* documentation and example updates

* Update LICENSE, make dartanalyzer happy, fix minor bugs, get rid of duplicate files, publish script

* fix sample for slightly different schema

* Update pubspec.yaml
2018-05-18 11:06:15 -07:00
Paul Reimer 6621424308 Add --root-type option to flatc [C++, parser, JSON] (#4728)
* Add --root-type option to flatc

To select or override a root_type

* Add help text from flatc --root-type to Compiler.md doc
2018-05-07 16:07:52 -07:00
Sergey Avseyev 6eb031de9a Text files should not have executable bit set (#4480) 2017-11-06 10:20:22 -08:00
Wouter van Oortmerssen 72a99abfb7 Added support for mini-reflection tables.
Change-Id: I83453d074685fa57bbf1c7c87b1d9392ce972085
Tested: on Linux.
2017-09-22 16:17:02 -07:00
Wouter van Oortmerssen 93c0960c3a Added --keep-prefix to not strip schema include path in C++ includes.
Change-Id: I3c6356fc6664072796f273096df64829108b4a34
Tested: on Linux.
2017-05-10 13:21:20 -07:00
Aaron Hudon d9bc5ec047 fixed flag for javascript (#4223)
--javascript flag does not work in the 1.6 flatc.exe, changed to --js
2017-03-15 15:16:43 -07:00
Wouter van Oortmerssen 1fb6b9ee6f Added doc comments to the binary schema.
Change-Id: I87f291ab6e07b1425850cae25ed500db594f17c8
Tested: on Linux.
2017-02-13 16:47:17 -08:00
Wouter van Oortmerssen 2272229983 Added --prefix-include option for generated includes.
Change-Id: I288cda33345362f9aec5cbe309e590bf64f328e1
Tested: on Linux.
2017-02-10 13:24:54 -08:00
Wouter van Oortmerssen d7ba17dfe5 Changes to make flatbuffers javascript compatible with the closure compiler.
Change-Id: Iab8d66a8f34910029deb8a5ff5ec7ba50c5b3421
2017-02-08 17:14:35 -08:00
Wouter van Oortmerssen 05b00c50ad Added way to test two schemas for safe evolution.
Change-Id: I1dfc867e6df5932ab61dad431eb3cb02f15d04df
Tested: on Linux.
Bug: 30202327
2016-07-20 17:56:59 -07:00
Wouter van Oortmerssen 3101e327c0 Added optional object based API for C++.
Change-Id: If927f3ea3fb3723088fa287f24bdd1ad43c8d1d1
Tested: on Linux.
2016-07-20 14:58:57 -07:00
Wouter van Oortmerssen 48f37f9e0a Added GRPC code generator to flatc.
Also added simple (in-process) test.

Change-Id: I38580d554dd52f590e3396ec4846e07546dcf07d
Tested: on Linux.
2016-06-29 15:51:44 -07:00
Mark Klara 69a31b807a Revamping the FlatBuffers docs.
Adding an API reference for the supported languages.

General docs cleanup, including a new `tutorial` section that
supports all of the supported languages.

Added samples for each supported language to mirror the new
tutorial page.

Cleaned up all the links by making them `@ref` style links,
instead of referencing the names of the generated `.html` files.

Removed all generated files that were unnecessarily committed.

Also fixed the C# tests (two were failing due to a missing file).

Bug: b/25801305

Tested: Tested all samples on Ubuntu, Mac, and Android. Docs were
generated using doxygen and viewed on Chrome.

Change-Id: I2acaba6e332a15ae2deff5f26a4a25da7bd2c954
2016-01-19 14:31:17 -08:00
Wouter van Oortmerssen 45bda6e08d Added --gen-all to generate code for a schema and all its includes.
Also refactored the way options are stored.

Change-Id: I709ac908cd2aba396c9c282725cf1d42ccce0882
Tested: on Linux.
2015-12-04 09:44:31 -08:00
Wouter van Oortmerssen 3881bbd651 Multiple schemas parsed by flatc are now parsed independently.
It used to be such that later schemas could depend on earlier
schemas. This was a convenience from days before include files
were implemented. Nowadays they cause subtle bugs rather than being
useful, so this functionality has been removed.

You now need to explicitly include files you depend upon.

Change-Id: Id8292c3c621fc38fbd796da2d2cbdd63efc230d1
Tested: on Linux.
2015-12-02 11:12:39 -08:00
Wouter van Oortmerssen d7b4a31e93 Added long form options for all generators (--cpp etc.)
Short-form versions are still supported, but are deprecated.

Change-Id: I15f70ca8d69ba5790368205caa9603b65e1b7fff
Tested: on Linux.
2015-12-02 11:12:39 -08:00
Wouter van Oortmerssen 7c60937806 Added -M flatc flag to the documentation.
Change-Id: Ie19af91ec5bf0b65297cba58c124bceaa58fd73e
2015-10-19 17:05:42 -07:00
Wouter van Oortmerssen 94680f5483 Added support for imports and many other .proto features.
Change-Id: I6600021b7ec8c486794349511232c3e604421c5b
Tested: on Linux.
2015-10-13 14:01:55 -07:00
Wouter van Oortmerssen 2abe24b9dd Made .proto parsing understand nested declarations.
Bug: 24401812
Change-Id: I196a03b8c5ef0bcd3c26178239c764e40ca1950d
Tested: on Linux.
2015-09-28 09:48:41 -07:00
vijairaj c02b16e195 Implemented option --scoped-enum for C++ generator
This generates C++11 style scoped and strongly typed enums.
Enabling this option also implies --no-prefix.
2015-09-15 16:13:52 +05:30
Stewart Miles 6aeb09b297 Clarified the use of the deprecated flatc --gen-includes flag.
Also, removed the flag from the Android makefile.

Tested:
Verified flatc builds successfully on Linux and regenerated the docs.

Change-Id: I7140daa10b7cb9a29b5ffd63c6b20489e72a5899
2015-08-05 13:26:13 -07:00
Amol Deshpande ad3fd6ecbf merge 2015-06-15 20:26:10 -07:00
Amol Deshpande 40fffc8fff fix code formatting and bug with losing enums when using --gen-onefile 2015-06-13 08:55:24 -07:00
Wouter van Oortmerssen ecf5a6a580 Added --defaults-json to output fields at default value.
Normal behavior is to not output fields that happen to have
the default value, since those will be reproduced anyway
when turned into a FlatBuffer binary. This however can be problematic
when using JSON to interop with other system since they might not
know this default value. This flatc option (and also flag
to GenerateText) will force those fields to be output anyway.

Tested: on Linux.
2015-05-27 16:42:15 -07:00
Wouter van Oortmerssen c49c6da803 Added extra checks for reading binaries in flatc
By default, disallow reading binaries that do not correspond to
the schema file_identifier. Override with --raw-binary

Change-Id: I24822c0e4c80dab4e5a238ae2b6e601a09025c27
Tested: on Linux.
2015-05-04 13:38:20 -07:00
Wouter van Oortmerssen 3ec5dddb00 Mutable FlatBuffers: in-place updates.
This commit contains the first step in providing mutable FlatBuffers,
non-const accessors and mutation functions for existing fields generated
from --gen-mutable.

Change-Id: Iebee3975f05c1001f8e22824725edeaa6d85fbee
Tested: on Linux.
Bug: 15777024
2015-04-29 10:58:45 -07:00
Wouter van Oortmerssen 6c2dc41e0d Parser will allow a table or vector to have a trailing comma.
Unless in --strict-json mode.
Also added strict_json option to the parser, which in
addition controls if field names without quotes are allowed.

Change-Id: Id56fe5c780bdb9170958050ffa8fa23cf2babe95
Tested: on Linux.
2015-01-21 11:18:01 -08:00
Wouter van Oortmerssen d38b9af243 Added .proto parsing and convertion to .fbs.
Bug: 15777858
Change-Id: Iabef9b8c8044e593bb89510feebdee00d2f1840b
Tested: on Linux and Windows.
2014-10-15 17:42:31 -07:00
Wouter van Oortmerssen 30642c5a6f Added option to flatc to generate dependent header statements.
Bug: 17322776
Change-Id: I3a4d3cb4ccd40bc3200a87653aa0ab8ecb90ce60
Tested: on Linux.
2014-09-23 14:13:35 -07:00
Wouter van Oortmerssen e57b86bb9f The parser and flatc now allow include directories to be specified.
Bug: 17139854
Change-Id: I0eac65d054951e00a8811ad1d80ba8c37012dbf0
Tested: on Linux.
2014-09-15 16:19:27 -07:00
Wouter van Oortmerssen ffb3dec573 Prefixing of enum value identifiers in C++ is now optional.
See -P option to flatc.

Bug: 16814856
Change-Id: I855973df6afa27e0efa27cf9c4b4aee8a1fcdd22
Tested: on OS X.
2014-08-22 14:02:32 -07:00
Wouter van Oortmerssen df2e0db63d flatc can now convert flatbuffer binary files into json.
Also removed it appending _wire to filenames, renamed the json golden
file to .golden to not clash with generated files.

Bug: 15781201
Change-Id: I8322861e50d1e5b6a5ab5e4b5e5d8ae13c356eb2
Tested: on Windows and Linux
2014-07-11 14:49:43 -07:00
Wouter van Oortmerssen 7fcbe723fc Added a "strict JSON" mode to the text generator and compiler
This will add quotes around field names, as required by the official
standard. By default it will leave quotes out, as it is more readable,
more compact, and is accepted by almost all JSON parsers.
The -S switch to flatc turns on strict mode.

As per rfc 7159.

Change-Id: Ibabe9c8162c47339d00ec581d18721a2ba40c6d0
Tested: on Windows.
2014-07-09 11:43:30 -07:00
Wouter van Oortmerssen 26a30738a4 Initial commit of the FlatBuffers code.
Change-Id: I4c9f0f722490b374257adb3fec63e44ae93da920
Tested: using VS2010 / Xcode / gcc on Linux.
2014-06-10 13:53:28 -07:00