Compare commits

...

3199 Commits

Author SHA1 Message Date
Jakob Kordež
38df29380a [Dart] Fix namespace alias from union type (#9088)
* Fix namespace alias from union type

* Fix namespace alias from union type
2026-05-24 21:13:42 -04:00
Ali Sherif
1f438bd40f [Swift] Fix verifier accepting truncated scalar vectors (OOB read/write, RCE) (#9081) 2026-05-08 10:16:10 +02:00
mustiikhalil
392165432a [Swift] Migrate to use Swift Testing (#9076)
* Migrating from Xctests to swift testing

This migrates to the new Swift testing framework,
which would allow us to always use the latest tech
from swift moving forward.

* Updates flag to make sure that Wasm testing works
2026-05-07 21:49:41 -04:00
mustiikhalil
e6bbb3d22e [Swift] Migrate to swift 6.0 and Implements support gRPC v2 (#8983)
* Migrate to swift 6.0 & swift-gRPC 2.0

The following migrates to swift 6.0, and also
migrate to swift-grpc 2.0 that uses swift-nio
under the hood to provide nicer API and async await

Adds sendable to enum & update @_implementationOnly imports to use internal imports

* Address PR comments regarding misspelling & proper method naming.
2026-05-06 04:39:53 +02:00
Rifat Al Jubayer
a6979fe14a Fix logic inversion in FlexBuffers VerifyKey() (#9072)
VerifyKey() returns true on the first non-zero byte instead of
checking for a null terminator. This causes VerifyBuffer() to accept
FlexBuffers with non-null-terminated keys. Subsequent access to those
keys via strlen()/strcmp() reads out of bounds.

The condition if (*p++) should be if (!*p++) — return true
when a null terminator is found, not when any non-zero byte is found.

Confirmed with AddressSanitizer: heap-buffer-overflow in strlen()
after VerifyBuffer() returns true on a corrupted buffer.
2026-05-04 22:11:30 -04:00
Zen Dodd
bab10754d9 Stage the Python license file during builds (#9015)
Copy the repo-root LICENSE into the Python package directory for the duration of setup() so license_files = LICENSE remains valid without using deprecated parent-directory paths.

Remove the staged copy after the build completes.
2026-04-17 20:30:06 -04:00
Felix
ac7ef1176a Fix typo in generated header name (#9034) 2026-04-18 00:09:10 +00:00
Felix
d6444fb7fc Fix indention level for --no-python-gen-numpy (#9049) 2026-04-17 16:50:03 -04:00
Felix
e223d69b36 [Python] Extend GRPC Typing (#9007)
Extend function calls with optional type infos for checking
and discovering.

e838ba8a71/src/python/grpcio/grpc/__init__.py (L680)
2026-04-03 14:12:08 +00:00
Tulgaaaaaaaa
05cc7a2eff fix: correct operator precedence in ForAllFields reverse iteration (#8991)
* fix: correct operator precedence in ForAllFields reverse iteration

The expression `size() - i + 1` evaluates as `(size() - i) + 1` due to
left-to-right associativity, producing an out-of-bounds index when
reverse=true. For a vector of size N, the first iteration (i=0) accesses
index N+1, which is 2 past the last valid index.

Changed to `size() - (i + 1)` to match the correct implementation
already present in bfbs_gen.h:192.

Bug: CWE-125 (Out-of-bounds Read), CWE-783 (Operator Precedence Error)

* test: add ForAllFieldsReverseTest for reverse iteration correctness

Verify that ForAllFields with reverse=true iterates fields in
descending ID order. Tests both Stat (3 fields) and Monster
(many fields with non-sequential definition order) tables.

---------

Co-authored-by: Tulgaa <tulgaa.kek@gmail.com>
2026-04-02 10:14:27 +00:00
Noam ismach moshe
8a12183c3b Fix out-of-bounds vector access in StructDef::Deserialize (#8988)
* Fix out-of-bounds vector access in StructDef::Deserialize

* Fix syntax: use error_ instead of error()
2026-04-02 08:03:03 +00:00
Renzo
21b706b62d fix: swapped argument order in new_inconsistent_union calls (#9001) (#9010) 2026-04-02 07:05:58 +00:00
Tomasz Andrzejak
c5f151ab33 Add fallible try_* API for rust FlatBufferBuilder (#8918)
* Add fallible try_* API for FlatBufferBuilder

This is to support error propagation from Allocator trait. The Allocator
grow_downwards() method returns Result<(), Self::Error>, but
FlatBufferBuilder panics via .expect() when allocation fails instead of
propagating the error.

* Add rust fallible API docs
2026-04-02 06:49:51 +00:00
Björn Harrtell
3860f1cf7f [TS] Fixup TS test run at CI (#9004) 2026-03-30 13:32:24 +01:00
Thomas Köppe
4e582b0c1d [flexbuffers] Add "AlignedBlob", a version of "Blob" with explicit alignment. (#8993)
A blob is an array of bytes and has no intrinsic alignment (i.e. the
alignment is 1). The alignment of the existing flexbuffers blob is
solely affected by the width of the integer needed to store the blob's
size: that integer's width becomes the alignment of the blob.

The proposed AlignedBlob function here piggybacks on this effect and
simply uses a user-defined alignment for the width of the integer that
stores the blob's size; this automatically imparts that same alignment
on the blob itself. (The width is bounded below by the actual width
needed to store the blob's size.)

The ability to control the alignment of a blob is important for use
cases in which the blob itself stores structured data that we want to
access without further copies (e.g. other flatbuffer messages).
2026-03-23 10:28:03 -07:00
Fedor Osetrov
8396e00dd8 allow to use reflection in constant time evaluation (#8978)
* Update reflection.h

allow to use reflection in constant time evaluation

* make GetTypeSize constexpr

* fix clang-format
2026-03-20 02:01:45 +00:00
dependabot[bot]
48babd417d Bump flatted in the npm_and_yarn group across 1 directory (#8989)
Bumps the npm_and_yarn group with 1 update in the / directory: [flatted](https://github.com/WebReflection/flatted).


Updates `flatted` from 3.3.1 to 3.4.2
- [Commits](https://github.com/WebReflection/flatted/compare/v3.3.1...v3.4.2)

---
updated-dependencies:
- dependency-name: flatted
  dependency-version: 3.4.2
  dependency-type: indirect
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-19 21:48:28 -04:00
tmimmanuel
22770f7e85 Fix inconsistent Python union creator function naming (#8981) 2026-03-19 12:36:37 +00:00
Dexter.k
21b033227e Add bounds check for root offset in AddFlatBuffer (#8982) 2026-03-19 08:22:26 -04:00
dataCenter430
93f587a6d3 fix: annotated output for size-prefixed binaries (#8976) 2026-03-18 22:54:46 -04:00
Kevin Zhao
8afb68f074 codegen: escape string default values to prevent code injection (#8964)
String default values parsed from .fbs schemas are un-escaped by the IDL
parser (e.g., \x22 becomes a raw " byte), but code generators embed these
raw values directly into generated source code string literals. This allows
specially crafted .fbs files to break out of string literals and inject
arbitrary code into generated C++, Rust, TypeScript, and Swift source.

Fix by adding EscapeCodeGenString() helper that re-escapes string content
before embedding, and applying it to all 7 affected injection points across
5 code generators (C++, Rust, TypeScript, Swift, FBS).

Resolves the TODO comments in idl_gen_cpp.cpp and idl_gen_rust.cpp.
2026-03-18 22:01:23 -04:00
Derek Bailey
2e07f269b9 Update build.yml
Remove 64-core windows github action runner as it is a charged product we need to do expense
2026-03-17 09:58:26 -07:00
Renzo
10c994155c Fix: allow flexbuffers alloc check test (#8972)
* Fix: allow flexbuffers alloc check test

* fix: flaky CI failure

* fix: set flexbuffers alloc check false
2026-03-12 09:44:32 -04:00
dataCenter430
fc9909c30a fix: infinite loop in proto reserved range parser (CWE-835) (#8966) 2026-03-11 22:23:32 -04:00
tmimmanuel
e35817577c Fix missing namespace qualifier in Pack() (#8967)
* Fix missing namespace qualifier in Pack() for cross-namespace table references

* Fix missing namespace qualifier in Pack()

* Add cross_namespace_pack_test to Bazel build
2026-03-11 22:11:06 -04:00
Moritz Walker
9e3fe5d3f6 rust: add secondary function with preallocated internal vecs (#8936)
* rust: add secondary function with preallocated internal vecs

* docs: document pre allocation feature for rust implementation
2026-03-11 15:26:23 +00:00
statxc
dc9217347e fix: add missing bracket (#8969) 2026-03-11 02:42:46 +00:00
statxc
a7fed2ce67 feat: add lookup_index_by_key to Rust Vector for index-based search (#8959)
* feat: add lookup_index_by_key to Rust Vector for index-based binary search

* fix: remove duplicated code
2026-03-11 02:15:21 +00:00
statxc
de3b97355d feat: use HashMap for create_shared_string to fix O(N²) performance (#8958)
* feat: use HashMap for create_shared_string to fix O(N²) performance

* refactor: clean up no_std binary_search_by with direct slice comparison
2026-03-10 21:56:34 -04:00
Renzo
8aa7084f01 Fix flaky flexbuffers_alloc_check test in cargo test (#8965) 2026-03-08 23:43:07 -04:00
Justin Davis
0f469cad54 Revert "fix using null string in vector (#7872)" (#8879)
This reverts commit 1cb1c4baee.
2026-03-07 13:19:34 +00:00
dependabot[bot]
72e51c61f7 Bump actions/upload-artifact from 6 to 7 (#8963)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 6 to 7.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-06 22:18:54 -05:00
Sutou Kouhei
31590a8a3b Enable Dependabot for GitHub Actions (#8778)
Our workflows use old GitHub Actions. For example, we use
`actions/checkout@v3` but `actions/checkout@v5` is the latest version:

599847236c/.github/workflows/build.yml (L33)

https://github.com/actions/checkout/releases

How about enabling Dependabot? If we enable Dependabot, Dependabot
opens PRs that update old GitHub Actions.

Dependabot document:
https://docs.github.com/en/code-security/dependabot

Dependabot configuration document:
https://docs.github.com/en/code-security/dependabot/working-with-dependabot/dependabot-options-reference
2026-03-06 22:12:18 -05:00
Felix
24c2432d99 [Python]: Modernize setup and drop Python 2 (#8955) 2026-03-06 20:49:58 +00:00
Renzo
292870612c fix(flatbuffers): use manual impl Default for struct object types (#8947)
* fix(flatbuffers): use manual impl Default for struct object types

* fix: handle bool and float zero literals in struct object Default impl

* fix: regenerate all test bindings with generate_code.py

* fix: data type check on swift build

* fix: test large array on struct and enum
2026-03-06 11:20:32 -08:00
Cameron Mulhern
57659d9f38 Updates Rust codegen to use proper indentation (#8952)
* Fixes identation of generated Rust code

* Regenerates generated schemas
2026-03-05 14:04:55 +00:00
Udaya Prakash
2b8e4d3af0 build: Upgrade rules_swift to 3.1.2 and grpc to 1.76.0 (#8909) 2026-03-05 13:26:33 +00:00
Cameron Mulhern
08b6372a36 Generate better formatted Rust code (#8919)
* Cleans up Rust formatting

* Regenerates generated schemas
2026-03-05 02:49:46 +00:00
dependabot[bot]
9c383559e0 Bump minimatch in the npm_and_yarn group across 1 directory (#8951)
Bumps the npm_and_yarn group with 1 update in the / directory: [minimatch](https://github.com/isaacs/minimatch).


Updates `minimatch` from 3.1.2 to 3.1.5
- [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md)
- [Commits](https://github.com/isaacs/minimatch/compare/v3.1.2...v3.1.5)

---
updated-dependencies:
- dependency-name: minimatch
  dependency-version: 3.1.5
  dependency-type: indirect
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-05 02:43:14 +00:00
Salman Chishti
c13c3bf956 Upgrade GitHub Actions for Node 24 compatibility (#8934)
Signed-off-by: Salman Muin Kayser Chishti <13schishti@gmail.com>
2026-03-04 21:36:59 -05:00
dependabot[bot]
47eeb8f4e9 Bump ajv in the npm_and_yarn group across 1 directory (#8933)
Bumps the npm_and_yarn group with 1 update in the / directory: [ajv](https://github.com/ajv-validator/ajv).


Updates `ajv` from 6.12.6 to 6.14.0
- [Release notes](https://github.com/ajv-validator/ajv/releases)
- [Commits](https://github.com/ajv-validator/ajv/compare/v6.12.6...v6.14.0)

---
updated-dependencies:
- dependency-name: ajv
  dependency-version: 6.14.0
  dependency-type: indirect
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-05 02:28:53 +00:00
Uwe (ObjectBox)
e7c6874192 [Dart] Actually use resized FlexBuffers buffer (#8935)
When building a FlexBuffer using the Builder and adding data that exceeds the default buffer size (2048 bytes), in _newOffset() a larger buffer is created, but never used. This results in a RangeError.

Resolve by actually replacing the too small with the new larger buffer. Add a test that verifies this by adding multiple large strings to a vector.
2026-03-05 02:15:45 +00:00
RCRalph
8d2c333b36 fix: Added return value to non type-prefixed create vector function (#8945)
* fix: Added return value to non type-prefixed create vector function

* chore: Added generated code
2026-03-05 02:09:09 +00:00
Damian Sypniewski
abc9bfebff Update Go support for Optional Scalars (#8946) 2026-03-04 21:03:49 -05:00
Abhay Agarwal
94d6b8086b Ensure optional arrays, arrays with defaults, and strings with defaults are supported (#8896)
Fixing issues with generated ts/js
2026-02-23 08:55:37 +01:00
dependabot[bot]
fa709636b4 Bump lodash (#8913)
Bumps the npm_and_yarn group with 1 update in the /tests/ts/bazel_repository_test_dir directory: [lodash](https://github.com/lodash/lodash).


Updates `lodash` from 4.17.21 to 4.17.23
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.21...4.17.23)

---
updated-dependencies:
- dependency-name: lodash
  dependency-version: 4.17.23
  dependency-type: direct:development
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-02-19 01:09:46 +00:00
Stevan Coroller
60463e25a8 Remove empty 'required' section from schema.md (#8900)
There is a typo in the schema.md file in documentation. An empty 'required' section was added right before the 'required' item in the middle of the attributes list. It even appears in the table of content, which might confuse readers, making it look like following attributes might be required while they are not. You can notice the issue there: https://flatbuffers.dev/schema/#attributes.

I did check that `mkdocs serve -f mkdocs.yml` does produce the expected output (the same attributes list without that extra empty `required` section in the middle) with my changes.
2026-02-18 20:03:01 -05:00
Austin Chick
b8e3d215b8 [TS] Fix relative import paths of generated TypeScript code (#8880)
* Refactor logic that generates import paths in AddImport

* Add new tests to validate relative import path fix

* Generate goldens

* Generate example code

* Format TS generator file

* Revert "Format TS generator file"

This reverts commit 0f0b24aee9.

* Fix merge conflicts

---------

Co-authored-by: Björn Harrtell <bjornharrtell@users.noreply.github.com>
2026-02-17 10:22:32 +01:00
mustiikhalil
d71c0ab4ac Moves the internal stack to use a pointer stack instead of the native array for improved performance (#8891)
Remove custom flags for native arrays when using flexbuffers on Wasm

Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
2026-02-12 19:42:21 +01:00
mustiikhalil
fcf75449b8 [Swift] Moves VTs from enums to structs to prevent empty enum generation
Moves VTs from enums to structs to prevent empty enum generation, which would usually cause a compilation error.
2026-02-12 08:04:26 -10:00
Sebastian Barfurth
c21bda1649 Remove root_package from npm_translate_lock. (#8921)
This attribute is removed in the next major version of `aspect_rules_js`. It's
not actually needed here [according to](https://github.com/aspect-build/rules_js/pull/2709#issuecomment-3855183151)
a maintainer of `aspect_rules_js`.
2026-02-07 08:04:22 +00:00
Marcel
03fffb25e2 Set max_compatibility_level=3 for rules_swift (#8920)
This is necessary to be compatible with both rules_swift 2.x and 3.x.
2026-02-05 09:57:00 -08:00
bigjt
1a7495a6dd [C#] Add GetBytes methods for fixed arrays (#8633)
* [C#] Add GetBytes methods for fixed arrays

I wanted to direct access to fixed array bytes. I made some changes to the idl generator to create GetBytes functions following the same naming conventions used for vectors of scalar types. There was not a 'Length' field present to bound the existing index accessor so I added that too.

+ Add generic GetBytes for fixed length arrays of scalar types
+ Implement conditional compilation for ENABLE_SPAN_T:
  - ENABLE_SPAN_T: Returns `Span<T>` using `MemoryMarshal.Cast<byte, T>()` as needed.
  - Else: Returns `ArraySegment<byte>?` for raw byte access
+ Added tests reusing arrays_test.fbs definitions
+ Added const int Length field to support existing index based accessors

* [C#] Sync generated code for after adding GetBytes methods for fixed arrays

---------

Co-authored-by: Björn Harrtell <bjornharrtell@users.noreply.github.com>
2026-02-04 23:13:32 +00:00
Fawdlstty
3c1bb67ae1 sync human-readable value (#8859)
Co-authored-by: Justin Davis <jtdavis777@gmail.com>
2026-02-04 15:43:19 +00:00
Cameron Mulhern
5b9de8b6c0 Fixes Rust code generation for single file output when using namespaces (#8877)
* Adds tests for Rust single file mode

All existing tests only compile Rust code using --rust-module-root-file.

* Adds standalone include tests for Rust

The imports for these tests have been moved to their own file, as the existing intergration_test.rs file hides compilation issues from code generation due to symbols brought into scope outside of the generated code (e.g. `extern crate alloc`).

* Declare alloc crate in every Rust namespace

When performing code generation within a single file, extern crate alloc needs to be delcared to bring alloc into scope within every inner namespace.

* Regenerates generated schemas
2026-02-04 15:28:18 +00:00
Justin Davis
ea0a73d168 disallow circular struct references (#8851)
* detect and fail for circular struct dependencies

* pr comments

* pr comment
2026-02-04 15:15:05 +00:00
souma987
4623cfa4bc Opt in to using experimental Kotlin Native APIs to suppress build warnings (#8885)
- fixes #8846
2026-02-04 14:54:08 +00:00
Peter Shih
9c2c56dc6a Fix typo in comment in idl.h (#8907)
Co-authored-by: Justin Davis <jtdavis777@gmail.com>
2026-02-04 14:12:50 +00:00
brianmacy
429c28c783 fix(rust): Zero vtable memory in write_vtable to prevent uninitialized data (#8898)
The write_vtable() function's comment claimed to "fill the WIP vtable
with zeros" but make_space() only reserves memory without initializing
it. When using custom allocators with non-zeroed buffers, unset vtable
field entries would contain garbage instead of zero (which indicates
"use default value").

This fix explicitly zeros the vtable memory after reserving space,
matching the C++ implementation's buf_.fill_big() behavior.

Added regression test using a garbage-filled allocator (0xAA) that
verifies vtable entries for unset fields are properly zeroed.

Fixes #8894
2026-02-04 09:00:44 -05:00
Markus Junginger
e5a9ff757f flatbuffers.h: fix C++11 compilation (#8857) (#8858)
This constexpr officially works only with C++14 (assignment to lhs, 2 statements) and actually broke some C++11 compilers
2026-02-04 13:34:55 +00:00
Justin Davis
e53732b9b9 Feature: lua now file_ident aware (#8850)
* lua code not file ident aware

* update genned code

* make mac happy

* pr comments
2026-02-04 13:05:08 +00:00
Thiébaud Weksteen
b84b676c89 Fix example of JSON export with flatc (#8892)
Binary files should be placed after "--". Also add a note about missing
file_identifier and --raw-binary.
2026-02-04 07:51:49 -05:00
Iñaki Baz Castillo
3211f857d1 Add --ts-undefined-for-optionals command line option (#8861)
* Add --ts-undefined-for-optionals command line option

# Details

- Fixes #7656
- Added a new `--ts-undefined-for-optionals` command line option for `flatc`.
- If enabled, generated TypeScript code uses `undefined` for optional fields rather than `null`.

* Also add TS generated test files

* Run `sh scripts/clang-format-git.sh`

* also add tests/ts/lalala-options.ts to the repo

* move new tests to tests/ts/optional_values dir

* add tests/ts/optional_values/optional_values_generated.cjs to the repo

* reuse existing optional_scalars.fbs and add new test

* add comma

* sh scripts/clang-format-git.sh

* remove comma

* sh scripts/clang-format-git.sh

* trying things

* sh scripts/clang-format-git.sh

* done

* address feedback

* sh scripts/clang-format-git.sh

* run `sh scripts/clang-format-git.sh`

* remove uneeded `eslint-disable @typescript-eslint/no-namespace` line

---------

Co-authored-by: José Luis Millán <jmillan@aliax.net>
2026-02-04 13:37:41 +01:00
Stefan F.
95ff1f1d80 [c#] Fix Table __vector_as_array correct len calc (#8911)
* fix for https://github.com/google/flatbuffers/issues/8759
__vector_as_array<T> calling ByteBuffer.ToArray<T> with the length in bytes by multiplying len with ByteBuffer.Sizeof<T> and FlatBuffersExampleTests extended to call GetVectorOfLongsArray/GetVectorOfDoublesArray which failed without the fix

* first try to repair build-dotnet-windows

* syntax error fixed

* Update solution creation command in build workflow

add --format sln to the dotnet new command, maybe it is currently creating a .slnx instead?
2026-02-04 13:13:01 +01:00
Jacob Abrams
af8997b567 [Python] Improve python API (#8781)
* Fix generate_code script path

* [Python] Make StartVector public

Make StartVector vector public since it is already being used in
generated code

* [Python] Improve vector creation for Python API

Makes Python API for vectors cleaner like Rust and Swift

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2026-01-21 01:01:20 +00:00
Derek Bailey
0d67abde45 MODULE.bazel: Upgrade rules_swift version (#8908) 2026-01-20 16:56:11 -08:00
razvanalex
d74e2945f7 [C++] Check for case insensitive keywords (#8420)
* chore(idl): Check for case insensitive keywords

Most languages are not affected by this change. In PHP, some names such
as Bool cannot be used because it is a reserved keyword for to the bool
data type. The field `keywords_casing` in the configs enables checking
all characters in lowercase against every keyword. This should be safe
as flatbuffers does not allow non-ASCII characters in its grammar.

* chore: Fix formatting to follow google's coding style for enums

* chore: Extract convert case to lower when CaseInsensitive

---------

Co-authored-by: Justin Davis <jtdavis777@gmail.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2026-01-20 16:06:07 -08:00
Nicolas Ulrich
8914d06ab7 Remove invalid dependency on FLATBUFFERS_GENERATE_HEADERS_SCHEMAS (#8834)
* Remove invalid dependency on FLATBUFFERS_GENERATE_HEADERS_SCHEMAS

add_dependencies() is for targets.

CMake 4.2.0 fails because of this (it shouldn't crash though, but that's another topic). See https://gitlab.kitware.com/cmake/cmake/-/issues/27415

* Use FLATC_TARGET

---------

Co-authored-by: Justin Davis <jtdavis777@gmail.com>
2025-12-22 02:25:14 +00:00
Derek Bailey
522f2379a6 Update CODEOWNERS 2025-12-21 16:10:34 -08:00
Justin Davis
7cb0bcb212 C++ Feature: Mutable union getters (#8852)
* generate mutable union accessors

* add test

* Revert "add test"

This reverts commit 45e352b18f.

* update file

* formatter got in the way

* merge conflicts

* updated genned code

* manually fix code gen bc I can't figure out why this file won't code gen

---------

Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
2025-12-21 17:36:47 -05:00
Justin Davis
b1e7868db6 add verification that type_vec.size == vec.size() (#8853)
Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
2025-12-21 21:55:54 +00:00
Justin Davis
68e3c839c3 update provenance (#8873) 2025-12-21 21:50:57 +00:00
mustiikhalil
0723245085 [Swift] Fixes bazel.build file allowing it to find Vectors folder in 8.5.0 (#8875) 2025-12-21 21:22:49 +00:00
Ville Vesilehto
9d64b9c0c0 fix(go): add bounds checking to ByteVector (#8776)
Add missing bounds checking to ByteVector before slice
operations in the Go FlatBuffers implementation. Relative offset and
vector length are now checked against the buffer size. Instead of
panicking, the code now returns nil. Regression test added.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
Co-authored-by: Justin Davis <jtdavis777@gmail.com>
2025-12-21 20:25:30 +00:00
Justin Davis
d01f20f2fb Fix python generation with nested flatbuffers (#8854)
* implement fix from issue

* implement actual fix
2025-12-21 11:18:05 -08:00
Derek Bailey
7e163021e5 FlatBuffers Version 25.12.19 (#8871) 2025-12-19 15:06:07 -08:00
Derek Bailey
57fdd4f995 Default Vector Support C++ (#8870) 2025-12-19 14:32:51 -08:00
Derek Bailey
8cb53ccc95 Add --gen-absl-hash option to generate AbslHashValue for structs. (#8868) 2025-12-19 11:49:50 -08:00
Derek Bailey
fb55e0c9de Run clang-format -i **/*.cpp (#8865) 2025-12-19 10:42:57 -08:00
Derek Bailey
d9fde67eb5 Remove progaurd-rules.pro (#8866) 2025-12-19 09:54:43 -08:00
Derek Bailey
f74fda299d Update CODEOWNERS
Ensure no-one can add to owners other than myself as the official Google representative of this repo.
2025-12-18 17:14:33 -08:00
Derek Bailey
15802fa26c Create CODEOWNERS
Add a CODEOWNERS files to assign ownership to different parts of the code base
2025-12-18 17:03:50 -08:00
souma987
a86afae939 Fix casing in generated Kotlin struct constructor function (#8849)
* fixes #8419
2025-12-14 23:59:17 +00:00
souma987
60910fb7f5 Fix nullability of generated Kotlin ByteBuffer accessors (#8844)
* fixes #8691
2025-12-14 18:56:40 -05:00
Justin Davis
7bfaabc358 [TS] Flexbuffers root vector fix (#8847)
* fix and test

* chatgpt help

* consistent throws in reference.ts
2025-12-14 22:59:27 +01:00
Justin Davis
e1407e4341 Upgrade Kotlin to MacOS 15 (#8845)
* upgrade kotlin and macos

* remove xcode version selection
2025-12-14 13:28:24 -05:00
Justin Davis
c9a301e601 Arrays of Enumerations without a value for 0 are no longer valid (#8836)
* arrays of enums with no value for 0 now throw errors

* move setting key field outside struct check

* set to default instead of required

* unsure of why these bfbs files have changed at this time, checking them in to run the pipelines.

* remove known bad test
2025-12-13 18:40:58 -05:00
James Thompson
19b2300f93 chore: switch package to license expression (#8840)
* switch package to license expression

* Remove license file from package
2025-12-10 09:50:50 -05:00
Justin Davis
e60c0ab9e2 deprecate the two options which have no effect of their own (#8831) 2025-12-08 06:03:11 -05:00
Justin Davis
541dd1a8f5 Fix vector of table with naked ptr (#8830)
* create test that fails to compile

* fix the issue

* add test body

* force commit gneerated header

* build failures

* fix bazel some more
2025-12-07 11:05:54 -08:00
Justin Davis
7711e84919 Fix TS object API generation of schema containing array of enumeration having no zero default (#8832)
* set the array constructor to fill with minvalue

* add regression generation test
2025-12-07 07:35:38 -05:00
Kende Gömöri
89430a14d6 Fix docs: typo & dead link (#8826)
* Fix CHANGELOG.md

* Fix broken doc link
2025-12-05 20:31:04 -05:00
Cameron Mulhern
cfce38ec99 Fixes unused imports in Rust code generator (#8828)
* Fixes unused imports in Rust code generator

* Regenerates generated schemas
2025-12-04 21:59:47 -08:00
Justin Davis
5469bc9ef1 Update flatc.md (#8821) 2025-12-03 14:16:59 +01:00
Ky0toFu
b39f79e5e9 Fix(ts): escape doc comment terminator in generated JSDoc (#8820) 2025-12-03 12:26:13 +00:00
Justin Davis
dc623919bd update docs (#8819)
Fixes #8733
2025-12-03 07:31:49 +01:00
Justin Davis
a1e125af11 Implement --file-names-only (#8788)
* flatc builds and seems to work, some of the extra targets are having linker errors

* fix build system

* pipeline failures

* un-rename files

* refactor to use unique_ptr

* typo

* rm make_unique, add comments

* fix cmake

---------

Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
2025-12-03 04:37:06 +00:00
Richard Patel
0b60686e3d rust: impl TrustedLen for VectorIter (#8797)
Improves unpack performance for vectors by allowing the compiler
to vectorize flatbuffers::Vector to std::vec::Vec conversions,
using the unstable trusted_len feature.

Internally, enables an optimization in src/alloc/vec/spec_extend.rs:
Previously, unpacking a flatbuffers::Vector called
SpecExtend::extend_desugared fallback, which inhibits vectorization
(due to a branch before every element move).  Declaring TrustedLen
allows SpecExtend::extend_trusted, which LLVM can often vectorize
into a memcpy.

For [ubyte] vectors in particular, this turns a rather expensive
loop of 'mov BYTE PTR [rax+r13*1], bpl' into a `call memcpy`.
2025-12-03 04:21:16 +00:00
Fawdlstty
17ceaae16e [rust] add deser support for enum type (#8803)
* add deser support for enum type

* update generated files

* remove deser generator when bitflag enable

* add deser test

* Restore the Rust editions version

* Remove unnecessary modifications
2025-12-02 22:48:45 -05:00
Rob Jellinghaus
a5343d6116 fix(idl_gen_rust): Fix lifetime warning added in Rust 1.89 (#8709)
Rust 1.89 added a new lifetime-related warning:
<https://blog.rust-lang.org/2025/08/07/Rust-1.89.0/#mismatched-lifetime-syntaxes-lint>

The Rust code generator currently emits code which trips this warning. This very small PR
fixes the issue for the relevant generated functions and for the Rust flexbuffers code.

Fixes #8705
2025-12-02 22:27:40 -05:00
Justin Davis
4786322b90 update labeler.yml to v5+ format (#8818) 2025-12-02 21:21:25 -05:00
Cameron Mulhern
646a8bc96a Improves Rust code generation (#8564)
* Fixes checks for serde features in flexbuffers crate

* Removes unused MapReaderIndexer use statement

* Fixes warning about nightly cfg usage

Enabling a cfg attribute through cargo::rustc-cfg in build.rs should be coupled with a cargo::rust-check-cfg value so that the compiler knows about the custom cfg. See: https://doc.rust-lang.org/rustc/check-cfg/cargo-specifics.html#cargorustc-check-cfg-for-buildrsbuild-script.

* Migrates usage of deprecated float constants

This update fixes a compiler warning from use of the old constants.

Constants like EPSILON are now directly on the float primitives (e.g. f32::EPSILON) rather than in the f32 module (std::f32::EPSILON).

The new constants have existed since 1.43.0, which appears to be below the MSRV for the flatbuffers crate.

* Fixes incorrect key in flatbuffers Cargo.toml

The old code was using package.rust, which triggered a warning about an unused key:

warning: flatbuffers/rust/flatbuffers/Cargo.toml: unused manifest key: package.rust

The correct key for specifying MSRV is rust-version. See: https://doc.rust-lang.org/cargo/reference/rust-version.html#rust-version.

---------

Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
2025-12-02 18:06:24 -08:00
Felix
0e3471d6a7 WIP error messages (#8764)
Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
2025-12-02 17:52:30 -08:00
Felix
b07589a0f9 CI: Fix typo in version (#8817) 2025-12-02 16:14:43 -05:00
mustiikhalil
2062c33cd4 Add support for Flexbuffers in wasm (#8815) 2025-12-02 16:18:24 +01:00
Felix
adb7add87e Modernize GitHub CI actions (#8812)
* CI: Modernize actions/checkout

* CI: Modernize actions/stale

* CI: Modernize softprops/action-gh-release

* CI: Modernize microsoft/setup-msbuild

* CI: Modernize gradle/actions/setup-gradle

* CI: Modernize actions/setup-dotnet

* CI: Modernize actions/setup-java

* CI: Modernize jiro4989/setup-nim-action

* CI: Update to latest image seems to be fixed

The readme list swift now for 24.04

* CI: Update to latest actions/labeler tag instead of sha
2025-12-02 10:11:55 -05:00
mustiikhalil
29f99937c4 Migrating to swift wasm on for github actions (#8814)
Migrate to use the native SDK for Wasm that's built for swift
2025-12-02 02:13:22 +01:00
Jacob Abrams
597e76a268 Optimize Offset/Pad/Prep: use cached head and slicing, reduce casting (#8808) 2025-12-01 19:00:20 -05:00
Wakahisa
a577050817 [Java] Use Table's fully qualified path (#8729)
* [Java] Use Table's fully qualified path

When a table's name is called `Table`, the Java bindings generated result in an error due to there being  2 Tables. This fixes the issue by fully qualifyng the flatbuffers Table import.

* Update codegen

* Update generated Java code

---------

Co-authored-by: Neville Dipale <neville@urbanlogiq.com>
2025-12-01 11:28:50 -05:00
razvanalex
31ab0bf6c8 [Go] Write required string fields into the buffer when using Object API (#8402)
* [Go] Write required string fields into the buffer when using Object API

In C++, CreateX allows to write the default "" value of a required
string, when the string is not explicitly set. Object API Pack method
uses this implementation of CreateX.

However, in go, despite whether the field is optional or required, it is
always checked against empty string allowing to create messages that
fail to pass the verifier. This commits partially reverts #7719 when the
string field is required.

* Add test for serializing required string fields using Object API

* Update generated code

The Monster schema contains a key string field. For historical
convenience reasons, string keys are assumed required.
2025-12-01 09:50:03 -05:00
Jeroen Demeyer
e4775aa3fe [Go] add BenchmarkBuildAllocations (#8287) 2025-11-30 22:12:12 -05:00
whiteye
97d26ab4ae fix CScript string.compare (#8547)
* fix CScript string.compare

Because the default compare sorting rules of c# string are different from those of cpp, the binary file exported by flatc -b cannot use LookupByKey

* run generate_code.py

---------
2025-11-30 22:06:41 -05:00
James Robinson
7dd38fa23a Fix platform ifdefs for locale independent str functions (#8678)
Android libraries include <android/api-level.h> which defines the __ANDROID_API__ symbol even when targeting non-Android platforms and not using Android's libc. This updates the FLATBUFFERS_LOCALE_INDEPENDENT ifdef to check for __ANDROID__ before checking the Android API level.

Removes an extra check from the __Fuchsia__ branch. Fuchsia's libc does not support locales or the locale independent entry points.

Updates the Android API check to check for an API level >= 26 instead of 21. This matches the Android header file's availability macros and Bionic documentation:

https://android.googlesource.com/platform/bionic/+/HEAD/docs/status.md
2025-11-30 21:38:37 -05:00
Jacob Abrams
7350c3668f Optimize Builder startup: lazy sharedStrings and fast vtable init (#8807) 2025-11-30 23:33:34 +00:00
Felix
49d2db93a7 [Python] Fix generating __init__.py for invalid path (#8810)
This tried to generate from a directories "MyGame/Sample/"
for a empty path_ in M, MyGame & MyGame/Sample.
Which is incorrect since we want to start with the first
kPathSeparator `/` and not position 1.
2025-11-30 23:30:55 +00:00
Uilian Ries
807b43c0d7 Remove legacy Conan recipe and update documentation (#8712)
* Remove legacy Conan recipe

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Document how to install flatbuffers with Conan

Signed-off-by: Uilian Ries <uilianries@gmail.com>

---------

Signed-off-by: Uilian Ries <uilianries@gmail.com>
Co-authored-by: Justin Davis <jtdavis777@gmail.com>
2025-11-30 11:35:02 +00:00
peter-soos
4b823b1b98 [Python] Fix inconsistent creator function naming in generated code (#8791) (#8792) 2025-11-29 16:48:53 -05:00
mustiikhalil
4c47f4c11e Revert back to using swift-actions (#8806)
Reverting to swift-actions since they seem to have fixed the issue with GPG keys
2025-11-27 21:56:20 -05:00
coder7695
2b107e20c5 [fuzzer] Adds code generation target. (#8795)
* adds code generation fuzzer target.

* add buffer verification

* add table verification in codegen fuzzer

---------

Co-authored-by: Björn Harrtell <bjornharrtell@users.noreply.github.com>
2025-11-27 15:52:28 +00:00
Jacob Bandes-Storch
84f4b83d3e TypeScript: read vtable entries as uint16 (#8435)
Co-authored-by: Björn Harrtell <bjornharrtell@users.noreply.github.com>
2025-11-27 10:55:34 +00:00
dependabot[bot]
185e41fac4 Bump js-yaml in the npm_and_yarn group across 1 directory (#8779)
Bumps the npm_and_yarn group with 1 update in the / directory: [js-yaml](https://github.com/nodeca/js-yaml).


Updates `js-yaml` from 4.1.0 to 4.1.1
- [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/compare/4.1.0...4.1.1)

---
updated-dependencies:
- dependency-name: js-yaml
  dependency-version: 4.1.1
  dependency-type: indirect
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Björn Harrtell <bjornharrtell@users.noreply.github.com>
2025-11-27 11:50:31 +01:00
Grzegorz Owsiany
8b02fe6178 [C++] Fix vtable deduplication for 64-bit buffers >2GB (#8591)
Fixes #8590
2025-11-26 21:12:24 -05:00
Sutou Kouhei
6e0dad8c5f Use macos-15-intel not macos-latest-large for Intel macOS (#8777)
We can't use macos-latest-large in non paid GitHub account but we can
use macos-15-intel in public repositories. If we use macos-15-intel,
we can run CI jobs for Intel macOS in fork repositories.
2025-11-26 19:31:24 -05:00
obones
e3e355d498 feat: library definition for PlatformIO (#8261)
* feat: library definition for PlatformIO

* Update library.json version with release.sh

---------

Co-authored-by: Flávio Zanoni <flaviozg888@gmail.com>
2025-11-26 19:18:13 -05:00
Jakob Kordež
8e901ce17c Fix dart object api test (#8751) 2025-11-26 17:36:08 -05:00
Yuanyuan Chen
7808ae5c88 More robust <span> check (#8631) 2025-11-26 17:33:06 -05:00
Wakahisa
20068cfa05 [Java] Add notify to Java keywords (#8724)
Fixes #8723

Co-authored-by: Neville Dipale <neville@urbanlogiq.com>
Co-authored-by: Max Burke <max@urbanlogiq.com>
2025-11-26 07:59:18 -08:00
Wakahisa
afd07bdec5 [Java] Generate Longs from uint enums (#8727)
Co-authored-by: Neville Dipale <neville@urbanlogiq.com>
Co-authored-by: Max Burke <max@urbanlogiq.com>
2025-11-26 07:58:25 -08:00
Hjalti Leifsson
2951d5383a chore: fix quick start typos (#8520)
* chore: fix another typo

* chore: undo overzealous IDE changes
2025-11-25 16:24:23 -05:00
Glenn Fiedler
ba563de877 add assert to fix GCC warning on Ubuntu 24.04 LTS (#8804) 2025-11-25 14:08:51 -05:00
Fawdlstty
46a2f3f2c2 [dart] fix bug which generated wrong code (#8780) 2025-11-24 10:54:43 -05:00
Ivan Dlugos
7675121eab Add Dart changelog entry for v25.9.23 (#8785)
Documents changes included in the Dart package v25.9.23 release,
which was published to pub.dev.
2025-11-24 09:18:23 -05:00
Benjamin Kietzman
ea2b5148e5 Fix issue #8389: any nonzero byte is truthy (#8690) 2025-11-24 07:26:39 -05:00
Fergus Henderson
20548ff3b6 Size verifier fix 2 (#8740)
* Fixes to make SizeVerifier work.

In particular change all the places in the Flatbuffers library
and generated code that were using `Verifier` to instead use
`VerifierTemplate<TrackBufferSize>` and wrap them all inside
`template <bool TrackBufferSize = false>`.

Also add unit tests for SizeVerifier.

* Format using `sh scripts/clang-format-git.sh`

* Use `B` rather than `TrackBufferSize` for the name of the template parameter.

* Update generated files.
2025-11-24 07:11:32 -05:00
Jacob Abrams
7ea8db05d8 [Python] Add unit test for github issue 8653 (#8786) 2025-11-24 06:41:50 -05:00
Justin Davis
c7b6b66ccb fix: remove a single type hint to retain 2.7.x compatibility (#8799)
Co-authored-by: Hjalti Leifsson <hjaltileifsson@gmail.com>
2025-11-23 12:00:21 -08:00
Justin Davis
ac8b124496 don't crash on a lua file with no root table (#8770)
Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
2025-11-17 22:31:32 +00:00
Justin Davis
88b033b964 add proposed fixes from #8731 (#8771)
Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
2025-11-17 13:46:41 -08:00
Justin Davis
e68355cb22 [C++] Add Vector64 specialization for std::vector<bool> (#8757)
* add vector64 specialization for vector<bool>

* fix generated code

---------

Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
2025-11-17 13:44:28 -08:00
Justin Davis
e3ee24830e Fix Issue #8653 - Python vtables not considering object size (#8683)
* have vtables consider size

* simplification from comment

---------

Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
2025-11-17 13:43:28 -08:00
Felix
2a8f4568e0 Replace usage of make_unique with unique_ptr for cpp11 (#8763) 2025-11-17 13:42:06 -08:00
mustiikhalil
cbf0850828 [Swift] Inline arrays (#8755)
Implements InlineArrays which allow us to use Flatbuffers arrays within
Structs natively, and also implements FlatbufferVectors as a secondary API
when using mutable Structs

Fixes mutations within fixed sizes arrays

Adds tests and remove inout and mutating from generated objects in favor of borrowing

---------

Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
2025-11-15 00:33:16 +01:00
mustiikhalil
7150dfb5c4 [Swift] Bump minimum supported version of swift to 5.10 (#8758) 2025-11-14 15:07:49 -08:00
mustiikhalil
fa87eccd1a Update swift supported features (#8769) 2025-11-14 15:07:25 -08:00
mustiikhalil
a62f45fed8 Improves the performance of the string imp (#8772)
Improves the performance of the implementation in Swift
by using withCString instead of the contigiousString
2025-11-14 15:06:52 -08:00
cosmith-nvidia
599847236c Support native_type for tables when using the C++ object API. (#8668)
* Support native_type for tables when using the C++ object API.

If native_type is specified on a table:
- No object API struct type is generated.
- The object API refers to the table by its native_type.
- UnPack and Create<TableName> methods are declared but not defined; as they
  must be user-provided.

* Add tests for native_type on tables.

* Add documentation for native_type on tables.
2025-11-05 07:50:10 -08:00
cosmith-nvidia
4173b84d4b Fix --gen-compare to not generate comparators for native types. (#8681)
Per the definition of --gen-compare: only generate comparators for object API
generated structs. Types annoated with native_type must define their own
comparators if `--gen-compare` is enabled.

Also enables --gen-compare for native_type_test and fixes the test by adding a
comparator for the Native::Vector3D type.
2025-11-05 00:43:00 +00:00
mustiikhalil
5fe90a9160 [Swift] Implements FlatbuffersVector which confirms to RandomAccessCollection (#8752)
* Implements FlatbuffersVector in swift

Implements FlatbuffersVector which confirms to RandomAccessCollection,
this would give us semi-native sugary syntax to all the arrays in swift port.

This work will also be the foundation of using arrays in swift

* Fix failing tests for Swift
2025-11-04 23:53:59 +00:00
cosmith-nvidia
78a3d59a65 Swap the dependency of CreateX and X::Pack object API functions. (#8754)
Previously: X::Pack forwarded to CreateX.

Now: CreateX will forward to X::Pack.

This is a step toward enabling using native types for tables when using the
object API. When defining a native table, the user will be able to define a
custom X::Pack method (which is more consistent with the existing native_type
functionality for structs). By reversing the order of the dependencies, CreateX
can continue to be auto-generated and will use the custom X::Pack method when
overriden for native_type tables.
2025-11-04 15:42:16 -08:00
are-you-tilted-already
5ed02dc04a Prevent make_span from working with vectors and arrays of pointers (#8735)
* Prevent `make_span` from working with vectors and arrays of pointers

* support `make_structs_span` for little-endian

* fix build: add the required parentheses

---------

Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
2025-11-04 13:47:44 -08:00
Jakob Kordež
592dc50037 Refactor lazy list unpacking (#8746)
Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
2025-10-31 13:41:59 -07:00
coder7695
dd77af75b7 Add conditional check (#8736)
* resolve windows compile error

* add conditional for undef new

---------

Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
2025-10-31 11:20:18 -07:00
Jakob Kordež
051604aeb5 Fix struct vector ordering in pack function (#8747) 2025-10-31 09:59:01 -07:00
Jakob Kordež
4b09586652 Fix union unpacking (#8748) 2025-10-31 09:58:30 -07:00
David Sanderson
4c0eecd25a treat npm_typescript as a dev dependency (#8719)
Treat flatbuffers' definition of npm_typescript as a dev dependency, in order to avoid conflicts when consuming flatbuffers in a repo that also depends on aspect_rules_ts.
2025-10-30 07:49:54 -07:00
mustiikhalil
de25052c72 Fixes failing tests on macOS due to file loading (#8742)
Fixes failing tests due to the usage of URL(fileURLWithPath:isDirectory:) instead of URL(string:)
2025-10-29 11:36:47 -07:00
vsmcea
95053e6a47 Correct span and non-span versions of ToArray() and ToArrayPadded() methods (#8734)
* Correction of bug inside ToArray<T> methods

Avoid allocating too large buffers (len is expressed in bytes, not in Ts).
Added validation to ensure len is a multiple of SizeOf<T>() before converting to array.

* Update ByteBuffer.cs

* Refactor ToArray and ToArrayPadded methods

I understand from failed test that pos, len, padLeft and padRight are expressed in Ts

* Refactor ToArray and ToArrayPadded methods

* Final correction
All functions parameters expressed in bytes for homogeneity
Tests run:
  - UNSAFE_BYTEBUFFER=true/ENABLE_SPAN_T=true: passed
  - UNSAFE_BYTEBUFFER=true/ENABLE_SPAN_T=false: passed
  - UNSAFE_BYTEBUFFER=false/ENABLE_SPAN_T=false: passed
  - UNSAFE_BYTEBUFFER=false/ENABLE_SPAN_T=true: configuration forbidden by compilation
Correction of FlatBuffers.Test.csproj to allow UNSAFE_BYTEBUFFER/ENABLE_SPAN_T tests
Correction of FlatBuffersExampleTests.cs: I think the test was not run because it could not pass (to be reviewed carefully)
2025-10-25 11:58:05 -07:00
Daniel Nguyen
27325e002a docs: clean up whitespace and fix typo in tutorial.md (#8695)
* docs: remove trailing whitespace

* docs: fix typo in tutorial.md
2025-09-25 09:02:22 -07:00
Derek Bailey
1872409707 FlatBuffers Version 25.9.23 (#8708) 2025-09-23 22:18:02 -07:00
dependabot[bot]
c427e1a65d Bump the npm_and_yarn group across 1 directory with 2 updates (#8704)
Bumps the npm_and_yarn group with 2 updates in the / directory: [@eslint/plugin-kit](https://github.com/eslint/rewrite/tree/HEAD/packages/plugin-kit) and [brace-expansion](https://github.com/juliangruber/brace-expansion).


Updates `@eslint/plugin-kit` from 0.3.2 to 0.3.5
- [Release notes](https://github.com/eslint/rewrite/releases)
- [Changelog](https://github.com/eslint/rewrite/blob/main/packages/plugin-kit/CHANGELOG.md)
- [Commits](https://github.com/eslint/rewrite/commits/plugin-kit-v0.3.5/packages/plugin-kit)

Updates `brace-expansion` from 1.1.11 to 1.1.12
- [Release notes](https://github.com/juliangruber/brace-expansion/releases)
- [Commits](https://github.com/juliangruber/brace-expansion/compare/1.1.11...v1.1.12)

---
updated-dependencies:
- dependency-name: "@eslint/plugin-kit"
  dependency-version: 0.3.5
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: brace-expansion
  dependency-version: 1.1.12
  dependency-type: indirect
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2025-09-23 21:54:56 -07:00
Derek Bailey
caf3b494db bulk code format fix (#8707) 2025-09-23 21:50:27 -07:00
Derek Bailey
0e047869da Use the Google Style for clang-format without exceptions (#8706)
This reduces the friction when merging from github and google repos by
using the exact same clang style guide.

MARKDOWN=true
2025-09-23 21:19:33 -07:00
mustiikhalil
881eaab706 Revert back to use the latest from the swiftly ci (#8702) 2025-09-21 21:47:05 -07:00
nurbo
48eccb83db fix(idl_gen_ts): bool to number conversion in mutable API (#8677)
Co-authored-by: Björn Harrtell <bjornharrtell@users.noreply.github.com>
2025-09-11 08:36:15 -07:00
Peter Petrov
3c0511fa6a [C#] Added ToSizedArrayPadded(int padLeft, int padRight) to ByteBuffers to avoid unnecessary copying. (#8658)
* Added ToSizedArrayPadded(int padLeft, int padRight) + ToArrayPadded(pos, len, padLeft, padRight) to the byteBuffers.
This is for API completion and to avoid unnecessary copy when framing my packets. I needed this to create a flat buffer with space in front of it for header / metadata.

* Fix indentation

---------

Co-authored-by: Björn Harrtell <bjornharrtell@users.noreply.github.com>
Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
2025-09-09 11:38:15 -07:00
bigjt
82396fa0fe [C#] Improve Span<> utilization (#8588)
There are a couple instances where the ByteBuffer's Span property was accessed in a loop.
 + Extracted the use of the property outside of the loop to save a few cpu cycles.

Access to the allocator's internal buffer isn't exposed as a ReadOnlySpan<byte> from the ByteBuffer
or the FlatBufferBuilder.
 + Added a few convenience functions to access the buffer using a ReadOnlySpan<byte>.

There are a few cases where built in Span extensions can be used to run optimized code.
 + Added the use of Span.Fill() and ReadOnlySpan.SequenceCompareTo to replace existing loops.

Co-authored-by: Björn Harrtell <bjornharrtell@users.noreply.github.com>
Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
2025-08-28 16:06:18 -07:00
Curt Hagenlocher
a6b337f803 Add bounds checking to a method where it was missing (#8673)
Co-authored-by: Björn Harrtell <bjornharrtell@users.noreply.github.com>
Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
2025-08-28 16:06:03 -07:00
TorsteinTenstadNorsonic
35230bd70c [C#] Fix union verifier (#8593)
* [C#] Add test verifying unions

* [C#] Fix verifying unions

---------

Co-authored-by: Björn Harrtell <bjornharrtell@users.noreply.github.com>
Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
2025-08-28 16:05:42 -07:00
Shashank
deb3d93454 gRPC callbackService support added (#8666)
* grpc callbackService support added

Signed-off-by: shankeleven <shashanksati11@gmail.com>

* tests: regenerate C++ gRPC golden with --grpc-callback-api (CallbackService & async_ reactor APIs); update formatting and method placement

---------

Signed-off-by: shankeleven <shashanksati11@gmail.com>
Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
2025-08-28 15:49:27 -07:00
Felix
b87d04af8c Bugfix: grpc supress incorrect warning (#8669)
new_p is a local addr but is owned now by slice_
thus the life time does not end at the end of the function

Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
2025-08-28 14:27:31 -07:00
Ville Vesilehto
1e6c851dba fix(go/grpc): avoid panic on short FlatBuffers input (#8684)
* fix(go/grpc): avoid panic on short FlatBuffers input

The gRPC codec read the root UOffsetT without checking input size. On
buffers shorter than SizeUOffsetT, GetUint32 touched data[3] and the
process panics.

Add a simple length check and validate the root offset stays within the
buffer. Return clear errors (insufficient data / invalid root offset)
instead of panicking.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>

* fix(go/grpc): avoid signed overflow in offset

Keep the bounds check in the unsigned domain (UOffsetT) to avoid
signedness pitfalls.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>

* chore: clarify comment regarding offset

A full FlatBuffer structure would be:

- uoffset_t: root table offset (4 bytes)
- soffset_t: vtable offset in root table (4 bytes)
- uint16_t: vtable size (2 bytes)
- uint16_t: table size (2 bytes)

In total 12 bytes. We are only validating the data length
before trying to read the uoffset_t, not the full structure.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>

---------

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2025-08-28 00:31:57 -07:00
mustiikhalil
6164edf558 Fixes swift windows CI (#8685)
Fixes ci failing to a missing component on the github actions side, and
this is enabled until its fixed from the swiftlylab side

Enables swift ci
2025-08-27 23:49:50 -07:00
Derek Bailey
ef1030ff0b Update build.yml - disable gradle CI failures
Both of this are failing and blocking other non-related PRs, disabling for now.
2025-08-27 23:22:12 -07:00
Derek Bailey
53c8c2ef16 Update build.yml - disable Test Swift Windows
This continually fails and the error message is cryptic enough that I don't know how to fix it without an expert.
2025-08-27 23:11:24 -07:00
Derek Bailey
f83525fe67 Update build.yml - update gradle actions
This follows the recommendation here: https://github.com/gradle/actions/blob/main/docs/setup-gradle.md#general-usage
2025-08-27 22:55:17 -07:00
Derek Bailey
b2cce474ba Update build.yml - use java-version 21
Our CI is broken and this is the error:

```
FAILURE: Build failed with an exception.

* What went wrong:
Gradle requires JVM 17 or later to run. Your build is currently configured to use JVM 11.
```

So updating our java-versions to the latest stable version which is 21 apparently.
2025-08-27 22:41:07 -07:00
Jason
067bfdbde9 Update ts codegen (#8421)
Makes the return type of `static getFullyQualifiedName()` be a string literal instead of just the string type

Update tests

Co-authored-by: Björn Harrtell <bjornharrtell@users.noreply.github.com>
2025-08-17 20:19:08 -07:00
Justin Davis
5218e29aa4 Fix: Actually call ValidateOptions (#8665)
* fix: actually call ValidateOptions

* convert error to warning in validateoptions
2025-08-12 15:30:35 -07:00
vzjc
957e09d684 CMakeLists: include(CheckSymbolExists) so check_symbol_exists() will work (#8580)
CMake 3.6 and earlier included this implicitly. Newer versions require
it to be explicit.

Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
2025-08-11 23:11:14 -07:00
Chan Wang
af4b99a1d7 Add Rust reflection documentation (#8536)
* Add Rust reflection documentation

* Update rust.md
2025-08-08 10:18:17 -07:00
Isaiah Pettingill
b85b90e346 Fix typo in word JavaScript (#8530)
Noticed this on the site. I'm not sure if you have to change it anywhere else, but this looks like the only place the typo occurs
2025-08-08 10:16:52 -07:00
Nugine
ae3821233c docs: fix broken link in readme (#8656) 2025-08-06 22:06:44 -07:00
Felix
ff9cba2bff Doc fix verifier example code for cpp (#8664) 2025-08-06 13:53:44 -07:00
Felix
1759061908 Remove stray required in docs (#8663) 2025-08-06 13:52:57 -07:00
Sourya Kovvali
34af7fff70 Fix native_type non-native_inline fields, add tests (#8655)
* Fix native_type non-native_inline fields, add tests

* Format

* Add 'native_type_test' and 'native_inline_table_test' to generate_code.py

* Remove '--gen-compare' from native_type_test generation
2025-08-03 15:06:01 -07:00
mustiikhalil
518bf42df8 Fixes misaligned pointer by reading from the buffer instead of loading the memory separately (#8649) 2025-07-29 21:26:30 +00:00
mustiikhalil
575d616e60 [Swift] Moves capacity outside of Storage (#8650)
- Cleans up capacity usage within the lib and moves it outside of the Storage

-  Use overflow operators
2025-07-29 14:21:20 -07:00
Felix
f32a7dcbd2 Bugfix __eq__ for numpy data types (#8646)
* [Python] Sync PythonTest.sh flags with generate_code.py

* [Python] Update generated code to latest flatc version for tests

* [Python] Fix test support for numpy newer than 2.0.0

* [Python] Remove unused variable

* [Python] Fix __eq__ for numpy arrays

* [Python] Run clang-format over the entire file
2025-07-26 10:31:38 -07:00
Alex Băluț
860d645349 Support Rust edition 2024 (#8638)
* Developers intro how to contribute

* Fix Rust code generation for Rust edition 2024

The errors look like:

```
warning[E0133]: call to unsafe function `fbs::flatbuffers::emplace_scalar` is unsafe and requires unsafe block
warning[E0133]: call to unsafe function `fbs::flatbuffers::follow_cast_ref` is unsafe and requires unsafe block
warning[E0133]: call to unsafe function `fbs::flatbuffers::Follow::follow` is unsafe and requires unsafe block
warning[E0133]: call to unsafe function `fbs::flatbuffers::read_scalar_at` is unsafe and requires unsafe block
warning[E0133]: call to unsafe function `fbs::flatbuffers::root_unchecked` is unsafe and requires unsafe block
warning[E0133]: call to unsafe function `fbs::flatbuffers::size_prefixed_root_unchecked` is unsafe and requires unsafe block
warning[E0133]: call to unsafe function `fbs::flatbuffers::Table::<'a>::new` is unsafe and requires unsafe block
warning[E0133]: call to unsafe function `std::slice::from_raw_parts` is unsafe and requires unsafe block
```

* Update goldens

Ran `goldens/generate_goldens.py`

* Regenerate code files

Ran `scripts/generate_code.py`
2025-07-25 23:12:52 +00:00
Felix
06a53df0d3 Fix start page: Backwards and Forwards Compatibility (#8645) 2025-07-25 16:06:50 -07:00
Łukasz Kurowski
c526cb640b [Python] Enhance object API __init__ with typed keyword arguments (#8615)
This commit significantly improves the developer experience for the Python Object-Based API by overhauling the generated `__init__` method for `T`-suffixed classes.

Previously, `T` objects had to be instantiated with an empty constructor, and their fields had to be populated manually one by one. This was verbose and not idiomatic Python.

This change modifies the Python code generator (`GenInitialize`) to produce `__init__` methods that are:

1.  **Keyword-Argument-Friendly**: The constructor now accepts all table/struct fields as keyword arguments, allowing for concise, single-line object creation.

2.  **Fully Typed**: The signature of the `__init__` method is now annotated with Python type hints. This provides immediate benefits for static analysis tools (like Mypy) and IDEs, enabling better autocompletion and type checking.

3.  **Correctly Optional**: The generator now correctly wraps types in `Optional[...]` if their default value is `None`. This applies to strings, vectors, and other nullable fields, ensuring strict type safety.

The new approach remains **fully backward-compatible**, as all arguments have default values. Existing code that uses the empty constructor will continue to work without modification.

#### Example of a Generated `__init__`

**Before:**

```python
class KeyValueT(object):
    def __init__(self):
        self.key = None  # type: str
        self.value = None  # type: str
```

**After:**

```python
class KeyValueT(object):
    def __init__(self, key: Optional[str] = None, value: Optional[str] = None):
        self.key = key
        self.value = value
```

#### Example of User Code

**Before:**

```python
# Old, verbose way
kv = KeyValueT()
kv.key = "instrument"
kv.value = "EUR/USD"
```

**After:**

```python
# New, Pythonic way
kv = KeyValueT(key="instrument", value="EUR/USD")
```
2025-07-22 23:57:39 -07:00
mustiikhalil
ca73ff34b7 [Swift] Memory usage fix (#8643)
Allows a complete reset for the underlying memory of the
_InternalByteBuffers within FlatBuffers and FlexBuffers.
2025-07-18 09:37:58 -07:00
Rogério Lino
2e49b3ba60 docs: Fixing typo on PHP sample (#8566) 2025-07-17 19:42:14 +00:00
Felix
f830c47d68 [Python] Avoid double flatbuffers include in pyi files (#8626) 2025-07-17 12:37:19 -07:00
Emma
501810f4d1 Fix JavaScript typo in mkdocs.yml (#8515) 2025-07-17 17:53:12 +00:00
Felix
1047d7ec13 Fix Enum type definition (#8624)
Using the : syntax leads to non member attributes.

> If an attribute is defined in the class body with a type annotation
> but with no assigned value, a type checker should assume this is a non-member attribute

```
class Pet(Enum):
    genus: str  # Non-member attribute
    species: str  # Non-member attribute

    CAT = 1  # Member attribute
    DOG = 2  # Member attribute
```

https://typing.python.org/en/latest/spec/enums.html#defining-members
2025-07-16 12:22:45 -07:00
mustiikhalil
07c2eb5fe7 Moves away from @_exported import to add the import in the generated code (#8637) 2025-07-16 12:07:08 -07:00
Felix
c7b9dc83f5 [Python] Avoid include own type (#8625)
This prevents the include of the type defined in the pyi,
otherwise this leads to error message like this:
error: Name XYZ already defined (possibly by an import)  [no-redef]
2025-07-15 11:20:09 -07:00
Gio
4c9079e31b Update logo path (#8602) 2025-07-14 16:09:05 -07:00
Felix
64e5252b4e Fix typo in code comment (#8549) 2025-07-07 12:03:14 -07:00
Dylan Gallagher
00c30807ff Fixed typo in quick_start.md (#8592) 2025-07-07 12:02:40 -07:00
Felix
c15fe421ba Use correct default type for str (#8623)
* [Python] Use correct type for str with None

Otherwise mypy will correctly flag code like this

def __init__(self):
  self.fooBar = None  # type: Optional[str]

error: Incompatible types in assignment (expression has type "None", variable has type "str")

* [Python] Make list type optional as they can contain None
2025-07-04 23:47:36 +00:00
Felix
6b251aa1cf Bugfix/new decode flag (#8634)
* Add docs for new python-decode-obj-api-strings flag

* Fix generate_code by adding missing s to flag
2025-07-04 16:46:28 -07:00
mustiikhalil
6fe8afb3b6 [CI] Moves swift actions to use next (#8632)
* Moves to use swift-actions@next until final release is out

* Migrates to vapor that uses swiftly actions

* Trying to use windows 2022
2025-07-01 13:46:06 -07:00
Truman Mulholland
00eec2445b [TS] Fix relative paths for exports (#8517)
Fixes an issue where exports were using incorrect relative paths for
>=3 namespace levels. This is fixed by making the starting range of the
namespace components relative to the amount of components.

Co-authored-by: Björn Harrtell <bjornharrtell@users.noreply.github.com>
2025-07-01 08:38:02 -07:00
mustiikhalil
b8db3a9a6a Adds windows swift support (#8622)
Adding support for windows requires the code generations
to add a compiler statement to completely ignore GRPC code
generation on windows

Cleanup the project to use the main Package.swift to run tests
instead of having it separate and includes the imports for GRPC
within it.

Adds windows swift ci
2025-06-30 05:45:48 -07:00
Seth Raymond
75556437cc Decode bytes to strings in Python Object API (#8551) 2025-06-29 01:40:10 -07:00
Felix
31beb0fb2f Bugfix: grpc python code generation location and file suffix (#8359)
* clang-format

* [Python] Replace . with _ in grpc filename suffix

Having filenames with . like `file.fb.grcp`
is not great for Python. Since dots are used for namespaces.
Replacing all of them with _ eg suffix `foo.bar.baz` will become
`foo_bar_baz`.

Restoring the previous default `_fb` suffix.

* [Python] Use namespace in path

This fixes a regression introduced with:
fb9afbafc7
And generates the grpc file in the namespace folder again.

* Sync commandline docs with web docs
2025-06-24 22:52:40 -07:00
Aaron Barany
dfd92124aa Avoid outputting Python files for already generated types (#8500)
This may overwrite types that have already been generated and can create
unwanted empty files. Fixes #8490
2025-06-23 12:00:37 -07:00
Björn Harrtell
a2916d37e7 [TS] Upgrade deps (#8620) 2025-06-22 08:59:42 -07:00
mustiikhalil
5a95b7b6bc [Swift] Flexbuffers native swift port (#8577)
* Offical Swift port for FlexBuffers

This is the offical port for FlexBuffers within
swift, and it introcudes a Common Module where code
is shared between flatbuffers and flexbuffers.

Writing most supported values like maps, vectors,
nil and scalars into a flexbuffer buffer. And includes
tests to verify that its similar to cpp

* Reading a flexbuffer

Implementing reading from a flexbuffer, enabling
most of the buffers features, like most types, maps, vectors,
typedvectors, and fixedtypedvectors.

Currently, if an offset/object cant be read we default to a swift
nil instead of the default flexbuffers 'null' with all values.

* Fixes bazel breaking due to new project structure

Address warnings within the library

* Adds comment on why we added the code & properly enforce the amout of bytes needed
2025-06-22 08:36:38 +02:00
Björn Harrtell
595ac94a6a [TS] Enum value default null (#8619)
* [TS] Enum value default null

* Re-gen
2025-06-21 22:25:56 -07:00
Adam Oleksy
5822c1c8dd Fix dereference operator of VectorIterator to structures (#8425)
For Vector or Array of structures the dereference operator of an
iterator returns the pointer to the structure. However, IndirectHelper,
which is used in the implementation of this operator, is instantiated
in the way that the IndirectHelper::Read returns structure by value.

This is because, Vector and Array instantiate IndirectHelper with
const T*, but VectorIterator instantiates IndirectHelper with T. There
are three IndirectHelper template definition: first for T, second for
Offset<T> and the last one for const T*. Those have different
IndirectHelper:Read implementations and (more importantly) return type.
This is the reason of mismatch in VectorIterator::operator* between
return type declaration and what was exactly returned.

That is, for Array<T,...> where T is scalar the VectorIterator is
instantiated as VectorIterator<T, T>, dereference operator returns T
and its implementation uses IndirectHelper<T> which Read function
returns T.
When T is not scalar, then VectorIterator is instantiated as
VectorIterator<T, const T *>, dereference operator returns const T * and
its implementation uses IndirectHelper<T> which Read function returns T.

The fix is done as follows:
* implement type trait is_specialization_of_Offset and
 is_specialization_of_Offset64,
* change partial specialization of IndirectHelper with const T * that
 it is instantiated by T and enabled only if T is not scalar and not
 specialization of Offset or Offset64,
* remove type differentiation (due to scalar) from Array..

The above makes the IndirectHelper able to correctly instantiate itself
basing only on T. Thus, the instantiation in VectorIterator correctly
instantiate IndirectHelper::Read function, especially the return type.
2025-05-17 22:01:09 -07:00
Maurice Sotzny
609c72ca1a [C++] Fixes #8446 (#8447)
Fixes access to union members when generating code with options "--cpp-field-case-style upper" and "--gen-object-api"

Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
2025-04-14 08:54:10 -07:00
mustiikhalil
bd1b2d0baf [Swift] Adds new API to reduce memory copying within swift (#8484)
* Adds new API to reduce memory copying within swift

Adds new storage container _InternalByteBuffer which
will be holding the data that will be created within the swift
lib, however reading data will be redirected to ByteBuffer, which
should be able to handle all types of data that swift provide without
the need to copy the data itself. This is due to holding a reference to
the data.

Replaces assumingMemoryBinding with bindMemory which is safer

Adds function that provides access to a UnsafeBufferPointer for
scalars and NativeStructs within swift

Updates docs

Suppress compilation warnings by replacing var with let

Using overflow operators within swift to improve performance

Adds tests for GRPC message creation from a retained _InternalByteBuffer
2025-03-18 07:48:39 +01:00
Derek Bailey
1c514626e8 FlatBuffers Version 25.2.10 2025-02-10 20:25:03 -08:00
Derek Bailey
820a7f277f Remove old documentation 2025-02-10 20:13:39 -08:00
Marcel
396c3f56df Upgrade dependencies (#8516)
As rules_swift bumped the compatibility level, this is required if any dependent repo wants to use the newer version.
2025-02-05 09:01:46 -08:00
mustiikhalil
c49e81d6ec Adds swift 6 to the build matrix (#8414)
Bump min version of swift to be 5.9
2025-02-04 09:11:46 -08:00
Marcin Radomski
a285e7ef1a Rust reflection: simplify dependencies, fix Android build compatibility (#8512)
* flatbuffers Rust reflection: replace num with num-traits

num crate is a wrapper over num-traits and a few other crates, that
reexports the APIs from all of them. We only need num-traits.

Signed-off-by: Marcin Radomski <dextero@google.com>

* Rust reflection: drop dependency on stdint crate

We only use it to get intmax_t for deriving alignment, which is an alias
for `core::ffi::c_long` [1]. We can use that directly instead.

[1] https://docs.rs/stdint/1.0.0/stdint/type.intmax_t.html

Signed-off-by: Marcin Radomski <dextero@google.com>

* Rust reflection: drop dependency on escape_string crate

It's used to format a string used for debugging only, so we might as
well use the builtin Debug representation of a string.

Signed-off-by: Marcin Radomski <dextero@google.com>

* Rust codegen: add derives on generated bitflags

Otherwise it limits the use of structs generated for reflection.fbs
in Rust reflection API.

Signed-off-by: Marcin Radomski <dextero@google.com>

* Rust flatbuffers: update bitflags dependency to 2.8

Signed-off-by: Marcin Radomski <dextero@google.com>

* Rust codegen: use bitflags v2 API for converting from bits

from_bits_unchecked was replaced with safe from_bits_retain.

Signed-off-by: Marcin Radomski <dextero@google.com>

* Regenerate Rust code after idl change

Signed-off-by: Marcin Radomski <dextero@google.com>

* Regenerate reflection_generated.rs

With flatc --rust ../../../reflection/reflection.fbs

Signed-off-by: Marcin Radomski <dextero@google.com>

* ts/BUILD.bazel: add missing import

Found by Buildifire presubmit:

  Function "sh_binary" is not global anymore and needs to be loaded from
  "@rules_shell//shell:sh_binary.bzl".

Signed-off-by: Marcin Radomski <dextero@google.com>

* Update expected value in generated_code_debug_prints_correctly test

In bitflags v2, the debug string representation of enum values is
different than it was in v1:
  Blue -> Color(Blue)
  (empty) -> LongEnum(0x0)

This change adjusts the expected test value.

Signed-off-by: Marcin Radomski <dextero@google.com>

* Fix tests build on Swift 5.8

grpc-swift 1.4.1 depends on swift-nio-ssl 2.14.0+ [1]. swift-nio-ssl 2.29.1
published on 2025-01-30, introduced some code [2] that uses a "switch
expression syntax" supported since Swift 5.9 [3]. Attempts to compile it with
Swift 5.8 cause build errors.

swift-nio-ssl project doesn't seem to support Swift 5.8. A commit from
2024-10-29 removes a "deprecated reference to a Swift 5.8 pipeline" [4].

swift-nio-ssl 2.29.0 is the last version that can be compiled with Swift
5.8. This commit pins it to that exact version.

[1] 66e27d7e84/Package.swift (L33)
[2] 3cb4d5ad12 (diff-bc1db1321ff689c2819245dcce1a3080554f0fc13f81b8d326c97e7d42717c8fR54)
[3] https://github.com/swiftlang/swift-evolution/blob/main/proposals/0380-if-switch-expressions.md
[4] 8a6b89d9a4

---------

Signed-off-by: Marcin Radomski <dextero@google.com>
Co-authored-by: Marcin Radomski <dextero@google.com>
2025-02-04 08:40:31 -08:00
Derek Bailey
0312061985 FlatBuffers Version 25.1.24 2025-01-24 16:36:11 -08:00
Taiju Tsuiki
9f94ceedbc [C++] Avoid adding semicolon after a statement (#8488)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2025-01-24 11:00:18 -08:00
Marcel
bcd2b9d039 Add Bazel docs (#8510) 2025-01-24 10:57:52 -08:00
Marcel
82fefbf252 Remove Bazel WORKSPACE setup. (#8509) 2025-01-24 18:16:10 +00:00
Sebastian Barfurth
65e49faf76 Bump the versions of all aspect Bazel dependencies (#8508)
* bump all aspect dependency versions to latest

* add workspace file to test bazel repo
2025-01-24 10:09:22 -08:00
Marcel
50be3cfe8c Test external modules explicitly in CI (#8507)
This setup is much simpler than calling Bazel from within Bazel
and making sure files and flags are set up correctly.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2025-01-23 23:04:06 +00:00
Marcel
026c243dc5 Add support for Bazel 7 and 8 in Bazel CI (#8505)
* Add missing file to filegroup for bazel integration tests

Fixup after a9257b6963.

* Align versions in bazel_respository_test_dir with root

* Update XCode version to 15.2

This is the oldest available version.

* Add WORKSPACE.bzlmod

* Add support for Bazel 7

* Add support for Bazel 8 in CI
2025-01-23 14:59:14 -08:00
Marcel
a9257b6963 Fix npm bzlmod (#8506)
* Restrict visibility of exported file

* Align npm_translate_lock attrs

* Remove defs_bzl_filename attr

* Align root_package with pnpm-lock.yaml location

Use a symlink to avoid copying the file.
2025-01-23 21:01:31 +00:00
Marcel
fceafd438d Improve Bazel CI (#8502)
* Update Buildkite Bazel CI

Restructure presubmit.yml to support matrix.

* Remove testing Ubuntu 18.04

The available LLVM 6.0 is too old to support std::filesystem.

* Add testing in Ubuntu 22.04

* Use Bazel version 6.5.0 in integration test
2025-01-23 12:10:27 -08:00
Marcel
33a15d63cf Fix reflection.fbs import path (#8499)
We need to copy the .fbs files into the package used for .bfbs files.
This is necessary as flatc doesn't provide support to specify the full
output file name for an .fbs file in a different folder.
I tried OUTPUT_FILE env var but this doesn't seem to be honored by
flatc.
2025-01-23 19:43:23 +00:00
Marcel
ad6d6638f3 Fix Bzlmod (#8503)
* Fix Bzlmod npm repo name

* Fix Bazel integration tests with Bzlmod
2025-01-23 08:52:48 -08:00
Derek Bailey
69ac6a712d Add bazel ci (#8497) 2025-01-22 13:41:45 -08:00
Marcel
4b69b27d43 Also use rules_bazel_bazel_integration_test dependency with Bzlmod (#8498)
* Also use rules_bazel_bazel_integration_test dependency with Bzlmod

* Update versions
2025-01-22 08:22:53 -08:00
Derek Bailey
9318c6c981 Update Evolution doc 2025-01-21 21:28:32 -08:00
Derek Bailey
df287ee6a7 FlatBuffers Version 25.1.21 2025-01-21 17:22:30 -08:00
Marcel
0d7bf7e8a7 Add support for Bzlmod (#8494) 2025-01-21 16:53:46 -08:00
Marcel
e67310bf1c Use rules_bazel_integration_test to download Bazel binary (#8495) 2025-01-21 16:51:08 -08:00
Marcel
121c4c99ae Use Label() to resolve repo name (#8493)
This makes sure it doesn't break users when they choose a different repo_name.
2025-01-21 16:49:57 -08:00
Marcel
27f5a0fdae Add missing headers to runtime_cc target (#8492)
Transitive headers like array.h have not been available in the runtime_cc target causing the build to fail. Adding all public headers to make sure transitive headers of flatbuffers.h are available.
2025-01-21 08:06:12 -08:00
Ben Beasley
3592b19150 Fix a minor typo in flatc --help output (#8468) 2025-01-16 07:10:25 +00:00
Chan Wang
733e432bfd Rust full reflection (#8102)
* #Rust Create a crate for reflection

* #Rust Add a crate for reflection tests and helper to access schema

* #Rust Get root table of a buffer and access field with schema

* #Rust Add 'Struct' struct and corresponding getter

* #Rust Add functions of getting any table/struct field value as integer/float/string

* #Rust Add setters for scalar fields

* #Rust Add setter for string fields

* #Rust Add getter for Table/Vector fields

* #Rust Add buffer verification

* Add a 'SafeBuffer' struct which provides safe methods for reflection

It verifies buffer against schema during construction and provides all the unsafe getters in lib.rs in a safe way

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2025-01-15 10:03:10 -08:00
Derek Bailey
5414e04b45 Add imports for bazel (#8486) 2025-01-15 09:24:34 -08:00
Derek Bailey
c9a286bf29 Update mkdocs.yml redirect
Fixes #8485
2025-01-15 08:21:09 -08:00
Derek Bailey
f9a70c79f1 Update release.yml for Maven 2025-01-13 22:35:04 -08:00
Derek Bailey
1eb4bd3ca7 cleanup github ci 2025-01-13 22:07:54 -08:00
Derek Bailey
41e47e4951 update copyright date 2025-01-13 21:45:22 -08:00
Derek Bailey
4999936289 add 404 info 2025-01-13 21:31:41 -08:00
Derek Bailey
8e2852fa73 Update issue templates 2025-01-13 21:28:41 -08:00
Derek Bailey
7e52f59f14 finish porting over languages in tutorial 2025-01-13 21:11:50 -08:00
Derek Bailey
1ff248739e format the tutorial for all the languages 2025-01-11 10:43:50 -08:00
Derek Bailey
2cffba28b4 Start to support all languages in tutorial 2025-01-10 15:15:40 -08:00
Derek Bailey
34f0728ea2 fix c++ style in embedded content 2025-01-10 12:57:24 -08:00
Derek Bailey
569e6cb461 Fixed broken links 2025-01-10 12:55:35 -08:00
Bhargava Srinarasi
086097ff94 A couple of small updates to the docs (#8477)
* Mention uint8 as an alias to ubyte

as it's referenced in the note below

* Remove an unfinished sentence.
2025-01-10 19:02:09 +00:00
Derek Bailey
2b0ce37b12 Quick copy of all pages 2025-01-09 23:36:46 -08:00
Derek Bailey
67bf1084c0 Update docs.yml to install mkdocs-redirects 2025-01-09 22:13:28 -08:00
Shynur
f82c4ac904 fix typo in tutorial (#8476) 2025-01-10 05:53:27 +00:00
Derek Bailey
9a40ab2495 Remove Resource path 2025-01-09 21:30:01 -08:00
Derek Bailey
5c14ee7e8b Update copy location 2025-01-09 21:27:04 -08:00
Derek Bailey
26e77dce41 Update copy location 2025-01-09 21:25:03 -08:00
Derek Bailey
6913c34e62 Update data location in tests 2025-01-09 21:20:27 -08:00
Derek Bailey
0222cd4a63 Missing .exe 2025-01-09 20:59:30 -08:00
Derek Bailey
0042afa5e2 Update output location with net6.0 and net8.0 2025-01-09 20:52:58 -08:00
Derek Bailey
8852f10a84 Update output location 2025-01-09 20:41:40 -08:00
Derek Bailey
a8df3c8f35 Remove outpath altogether 2025-01-09 20:32:43 -08:00
Derek Bailey
b8629d402e Use OutputPath instead of PublishDir 2025-01-09 20:22:13 -08:00
Derek Bailey
ccdab58c11 Go to setup-donet@v4.2.0 2025-01-09 20:16:36 -08:00
Derek Bailey
a96fe8f206 Fix warnings on Build .NET Windows 2025-01-09 20:13:24 -08:00
Fergus Henderson
99fda81905 Fix crash for TypeScript enum in substruct (#8430)
See https://github.com/google/flatbuffers/issues/8299.
2025-01-08 01:38:34 +00:00
Derek Bailey
8694806f14 schema.md Fixed some warnings (#8472) 2024-12-27 12:29:22 -08:00
Derek Bailey
5a75ad407d mkdocs.yml add footer and other info (#8471) 2024-12-27 11:47:49 -08:00
Derek Bailey
2d86857bec Add Annotating Docs (#8470)
* `quick_start.md`: Add quick start guide

* `annotation.md`: Add section on annotating flatbuffers
2024-12-27 11:25:21 -08:00
Derek Bailey
0f90dc8290 quick_start.md: Add quick start guide (#8469) 2024-12-27 08:52:22 -08:00
Derek Bailey
c9125e6385 flatc.md Add more documentation (#8467)
* CNAME: add custom domain

* `flatc.md`: Add more documentation
2024-12-24 12:15:14 -08:00
mustiikhalil
28ddfaeda7 Fixes a bug that made a copy of the changing vars within the verifier leading to an incorrect count (#8451)
Removes all the unneeded keyword (mutating) from verifier

Adds tests to verify depth
2024-12-23 22:29:09 -08:00
Derek Bailey
7e59e0727c CNAME: add custom domain (#8465) 2024-12-23 22:22:24 -08:00
Derek Bailey
79d9e33ea3 Update docs.yml
replace `main` with `master` that we are still using
2024-12-23 22:07:28 -08:00
Derek Bailey
bbb6b932fc contributions.md Add doc about how to contribute to flatbuffers (#8464) 2024-12-23 22:06:04 -08:00
Derek Bailey
46cc3d6432 docs.yml enable for pushes to main branch (#8463) 2024-12-23 20:49:27 -08:00
Derek Bailey
fb3ccd36c0 docs.yml Add workflow for updating docs (#8462) 2024-12-23 16:04:15 -08:00
Derek Bailey
492475a1b2 Add new Docs source files (#8461) 2024-12-23 15:55:56 -08:00
Derek Bailey
c75a0154eb Move docs/ to docs-old/ 2024-12-23 15:32:19 -08:00
Derek Bailey
a2cd1ea3b6 FlatBuffers Version 24.12.23 (#8459)
* FlatBuffers Release 24.12.23

* Fixed missing generated file version checks

* Run generate_code and fix cpp17 tests
2024-12-23 12:55:07 -08:00
Derek Bailey
32e63af684 Kotlin MacOs switch to macos-13
Switch off of macos-latest which no longer has the 14.3 xcode installed. Version macos-13 does.

We should probably update our kotlin though.
2024-12-23 09:10:46 -08:00
mustiikhalil
1f4a9038ce [Swift] Improves vectors performance & arrays within lib (#8415)
* Improves vectors performance and adds a benchmark to vectors of offsets in swift

Improves performance for all arrays and for loops

Uses a tuple instead of allocating a struct each time we start iterating over fieldloc

Updates benchmark library

* Fixing swift Wasm ci
2024-11-19 07:02:47 +01:00
Ivan Dlugos
a9df44828d dart: use enhanced enums (#8313)
* dart: rename enums.fbs

* feat: use dart enhanced enums

* generate code

---------

Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
2024-11-18 17:31:19 +00:00
Cameron Mulhern
5f453ef738 Removes 'size' and 'alignment' as Rust keywords (#8139)
* Adds fields for possibly reserved words to rust_namer_test

* Removes size and alignment as rust reserved words
2024-11-12 05:13:02 +00:00
Benjamin Kietzman
49061f8c7c use ALIGN for Push::alignment in struct types (#8398)
* use ALIGN for Push::alignment in struct types

* regenerate and add a test for struct alignment
2024-10-28 08:42:55 -07:00
Wouter van Oortmerssen
807adb73b2 FlexBuffers: support "natural utf8" output in ToString (#8426) 2024-10-12 14:34:06 -07:00
Mikhail
2f59a0319b Update grpc-core version (#8412)
* Update grpc-core version

io.grpc:grpc-core package in version 1.36.0 contains multiple [CVE's](https://mvnrepository.com/artifact/io.grpc/grpc-core/1.36.0).
Bump grpc-core version to latest 1.68.0 version to mitigate potential vulnerabilities.

* Update grpc version to 1.67.1

grpc was mistakenly released to maven under version 1.68.0 whenever a real release was done for version 1.67.1 [1]. The mistake was fixed later.

[1] https://github.com/grpc/grpc-java/releases
2024-10-05 18:24:05 -07:00
mustiikhalil
6a8898573c [Swift] Updates CocoaPods author info & fixes bug with versioning not working as expected (#8328)
* Fix versioning not being able to parse vX.Y.Z and updates author

* Adds BUILD_LIBRARY_FOR_DISTRIBUTION flag for cocoapods
2024-10-05 00:17:05 +02:00
mustiikhalil
d7a70db6ac (fix): #8408 fixes a bug where the capacity of the buffer isnt verified before trying to verify the ID (#8413) 2024-10-05 00:16:41 +02:00
mustiikhalil
b127c57ff0 Fixes spelling mistake in the word position (#8330) 2024-10-05 00:16:28 +02:00
Wouter van Oortmerssen
2436bd8175 Attempt to fix Rust CI (#8411)
by undoing what appears to have broken it: https://github.com/google/flatbuffers/pull/8372
2024-09-30 09:39:38 -07:00
Wouter van Oortmerssen
69a53e495d Use actions/upload-artifact@v4 on CI (#8410) 2024-09-27 15:39:44 -07:00
Ikko Eltociear Ashimine
c7a8102b12 docs: update README.md (#8383)
compliation -> compilation
2024-09-05 18:50:35 -07:00
Mikhail
2146bacd2e Update libs.versions.toml (#8387)
Fix CVE-2022-25647

The package com.google.code.gson:gson before 2.8.9 is vulnerable to Deserialization of Untrusted Data via the writeReplace() method in internal classes, which may lead to denial of service attacks.

Bump up version of the gson package.

https://github.com/advisories/GHSA-4jrv-ppp4-jm57
2024-09-06 01:26:51 +00:00
nolen777
8db59321d9 Add a unit test for odd-sized small structs (for #8117) (#8363)
* add an odd sized test

* formatting

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2024-08-20 00:27:32 -04:00
pkasting
42879f6ea6 [jumbo] Add begin()/end() to DetachedBuffer. (#8370)
This allows this type to meet the requirements of e.g.
std::ranges::range, which is necessary for it to work with the
std::span range constructor, or the "non-legacy" constructor for
Chromium's base::span.

Bug: none

Co-authored-by: Derek Bailey <derekbailey@google.com>
2024-08-20 04:12:35 +00:00
Gunnar Schulze
7833affd7e Upgrade Rust dependencies (#8372)
* [Rust] Upgrade bitflags to version 2.6.0

* [Rust] Upgrade num_enum to version 0.7.3

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2024-08-20 04:04:09 +00:00
LamTrinh.Dev
c065e972db Remove unused comment and fix typo. (#8366)
* Update NativeObject.swift

Correct the word.

* Update ByteBuffer.swift

Type parameter does not existing, remove it.

* Update ByteBuffer.swift

Correct the word.
2024-08-19 23:22:00 -04:00
alphalex-google
06b12d55ea Add "empty()" to vector (#8369)
This is just another `std`-ism that is being added.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2024-08-19 20:22:30 -04:00
Marcin Lewandowski
baddf90599 Add parentheses in FLATBUFFERS_MAX_BUFFER_SIZE, FLATBUFFERS_MAX_64_BUFFER_SIZE to avoid preprocessor definition collision (#8377)
In case when flatbuffers are being used along with other project that defines "max" preprocessor macro, the ::max() in FLATBUFFERS_MAX_BUFFER_SIZE and FLATBUFFERS_MAX_64_BUFFER_SIZE is incorrectly being expanded to the macro. Adding parentheses enforces function-like interpretation.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2024-08-19 19:51:15 -04:00
Derek Bailey
8b35a6bc32 Bazel: Just target flatc and flatbuffers_test for presubmit 2024-08-19 16:42:51 -07:00
Derek Bailey
6cb4d671a8 Fixes LICENSE file in python
Fixes: #8376
2024-08-19 16:09:27 -07:00
Anton Bobukh
fb9afbafc7 [gRPC] Update the code generator for Python to produce typed handlers (#8326)
* Move `namer.h` and `idl_namer.h` to `include/codegen` so they can be reused from `grpc` dirqectory.

* [gRPC] Update the Python generator to produce typed handlers and Python stubs if requested.

* [gRPC] Document the newly added compiler flags.
2024-06-18 16:02:57 -07:00
Felix
dafd2f1f29 [Python] Render enums as Python IntEnum (#8145)
This allows enums to be type check with mypy.
They will still behave like ints ->
> IntEnum is the same as Enum,
> but its members are also integers and can be used anywhere
> that an integer can be used.
> If any integer operation is performed with an IntEnum member,
> the resulting value loses its enumeration status.
https://docs.python.org/3/library/enum.html#enum.IntEnum

Only if the --python-typing flag is set.
2024-06-03 08:39:14 -07:00
Anton Bobukh
6ede1ccc9e [BinaryAnnotator] Add more options that control the generation of .afb files (#8323)
* [BinaryAnnotator] Add more options that control the generation of `.afb` files.

* [BinaryAnnotator] Update the include paths.
2024-05-29 13:34:38 -07:00
Anton Bobukh
8755c35a18 [C++] Update the validator to skip structs in namespaces other than the current one. (#8324)
* [Python] Generate `.pyi` stub files when `--python-typing` is on.

To support this change, the following modifications were made:

-  added a new option to disable `numpy` helpers generation;
-  added a new flag to control the target Python version:

   `--python-version` can be one of the following:

   - `0.x.x` – compatible with any Python version;
   - `2.x.x` – compatible with Python 2;
   - `3.x.x` – compatible with Python 3.
-  added codegen utilities for Python;
-  added a note that the generated .py file is empty.

* [C++] Update the validator to skip structs in namespaces other than the current one.
2024-05-29 13:16:37 -07:00
mustiikhalil
75f05d6389 Sets Swift minimum version to 5.8 (#8228)
Updates copyright from 2023 to 2024 & formats code - updates formatting rules

Updates CI to run with swift 5.8

Adds wasmer & updates command to run carton as a swift plugin

Update bazelci to also accept swift 5.8

Adds swift 5.10 to the test matrix
2024-05-29 13:07:54 -07:00
Anton Bobukh
3b27f5396e [Python] Generate .pyi stub files when --python-typing is on. (#8312)
* [Python] Generate `.pyi` stub files when `--python-typing` is on.

To support this change, the following modifications were made:

-  added a new option to disable `numpy` helpers generation;
-  added a new flag to control the target Python version:

   `--python-version` can be one of the following:

   - `0.x.x` – compatible with any Python version;
   - `2.x.x` – compatible with Python 2;
   - `3.x.x` – compatible with Python 3.
-  added codegen utilities for Python;
-  added a note that the generated .py file is empty.

* [Python] Update Bazel build rules.

* [Python] Update Bazel build rules.

* [Python] Run buildifier on BUILD.bazel files.

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2024-05-29 12:47:29 -07:00
Dominik Lohmann
58c8eb5847 [C++] Allow using FLATBUFFERS_MIN_BUFFER_SIZE in other namespaces (#8229)
This is a small change that makes `FLATBUFFERS_MIN_BUFFER_SIZE` usable
outside of the `flatbuffers` namespace.
2024-05-29 03:59:03 +00:00
Felix
0e034ecdba [C++] Make code compile with -Wfloat-equal (#8221)
This will allow the code to be compiled with `-Wfloat-equal`
as this would result in the folowing warning/error:
vendor/flatbuffers/include/flatbuffers/base.h:465:69:
  error: comparing floating point with == or != is unsafe [-Werror,-Wfloat-equal]
template<typename T> inline bool IsTheSameAs(T e, T def) { return e == def; }

But the way it is used in flatbuffers it is ok to compare floating
points with ==.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2024-05-29 02:52:14 +00:00
iS_lANDER
0f8b71180f [FIX] fix the behavior of flatbuffers::Optional to match std::optional when lhs and rhs are both nullopt (#8223)
Co-authored-by: islander <mikudehuane@gmail.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2024-05-29 02:40:04 +00:00
Derek Bailey
a5a2da0161 Update release.sh (#8322)
* Update release.sh

Update release script to update rust flexbuffers

* Update Cargo.toml
2024-05-28 18:44:37 -07:00
Derek Bailey
28783927af Update release.yml
Fix pathing in Crates.io publishing.
2024-05-28 18:36:11 -07:00
Derek Bailey
a1378fbd16 Update release.yml
Remove extra -
2024-05-28 18:34:26 -07:00
Derek Bailey
dcacfc5b11 Update release.yml
Use explicit paths in publish-crates. Also adds flexbuffers publishing.
2024-05-28 18:33:04 -07:00
Derek Bailey
f9dabf511a Update release.yml
Update working directory of crates.io publishing
2024-05-28 18:28:18 -07:00
Ricardo Delfin
5ba66f71c5 Added automatic publishing to crates.io on publish (#8263)
* Added automatic publishing to crates.io on publish

* Fixed indentation

* Update release.yml

Change secret name.

* Update release.yml

remove extra space added in merge

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2024-05-29 01:19:41 +00:00
Tyler Dunn
5adfac9fc3 dart: Fix incorrect write in Float64 write method (#8290)
Co-authored-by: Llamadmiral <Llamadmiral@users.noreply.github.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2024-05-29 01:13:10 +00:00
Paulo Pinheiro
c6fce30e9b [Kotlin] Update to kotlin 1.9.10 (#8307)
Update was needed to fix compilation issues on XCode 15.
See more:
https://youtrack.jetbrains.com/issue/KT-60230/Native-unknown-options-iossimulatorversionmin-sdkversion-with-Xcode-15-beta-3

Co-authored-by: Derek Bailey <derekbailey@google.com>
2024-05-28 18:08:01 -07:00
Björn Harrtell
ef30729a71 [.NET] Add netstandard2.0 as target (#8295)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2024-05-28 18:07:43 -07:00
Ben J
30ae5f189c Add more operators. (#8309)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2024-05-29 01:07:34 +00:00
Derek Bailey
299725fe2e Update build.yml (#8321)
Add a scheduled cron job to run all the main tests at 4:45 A.M. to catch dependency regressions.
2024-05-28 18:01:00 -07:00
mustiikhalil
a41fefa1a8 Trying to fix bazel on macOS and Xcode 14.3 (#8304)
* Fixes Bazel issues for windows and ci

Fetching boringssl within the flatbuffers repository, to patch the issues
of not being able to upgrade to Xcode 14.3 due to buildkite throwing
errors. The patch was inspired by the tenserflow patch
https://github.com/tensorflow/tensorflow/issues/60191#issuecomment-1496073147

Removes references of swift from the windows pipeline for bazel

Sets github actions to use xcode 14.3 for kotlin and sets the macOS
build for intel cpus.

* Update build.yml

Remove comment that is not relevant any longer.

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2024-05-28 17:29:41 -07:00
Derek Bailey
d89f611f6f Update build.yml to ubuntu-24.04 (#8319)
* Update build.yml to ubuntu-24.04

Apparently g++-13 was removed from the ubuntu-22.04 runners.

We also don't have enterprise runners at 24.04 yet, so just use the free ones for now until we get support for those. CI builds might take longer now.

* Update build.yml

Downgrade to g++12 and revert change to using normal runners

* Update build.yml

Go back to ubuntu-24.04 and update both gcc and clang to their latest versions according to [this](https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md?plain=1#L16-L20).

* Update build.yml

Go back to g++13 for now, as we get some exotic warning in g++14 for newer C++ standards.

* Update build.yml

Fix the other issues with `macos-latest` going to arm: https://github.com/actions/runner-images/tree/main?tab=readme-ov-file#available-images and that Swift wasn't installed in the ubuntu-24.04 by default.

* Update build.yml

Disable Kotlin MacOs CI
2024-05-28 17:18:00 -07:00
Anton Bobukh
150644d7f4 [gRPC] Add new options to control the gRPC code generation. (#8298)
The new options are:

-  `--grpc-filename-suffix` controls the suffix of the generated files;
-  `--grpc-use-system-headers` controls the type of C++ includes generated;
-  `--grpc-search-path` controls the directory that contains gRPC runtime;
-  `--grpc-additional-header` allows to provide additional dependencies for the generated code.
2024-05-15 08:17:40 -07:00
Anton Bobukh
c696275eaf [Python] Fix various codegen problems (#8292)
* [Python] Fix various codegen problems.

This includes:

-  escaping keywords happens **after** converting the case:
   - currently, `table ClassT` generate `class = Class()` which is invalid Python;
-  imports in `one_file` mode use the filename rather than the type name when resolving module names;
-  use `filename_suffix` instead of the hardcoded `_generated` one;
-  generate empty files if no structs or enums are available. This makes the set of output files more predictable for Bazel.

* [Python] Fix various codegen problems.

This includes:

-  escaping keywords happens **after** converting the case:
   - currently, `table ClassT` generate `class = Class()` which is invalid Python;
-  imports in `one_file` mode use the filename rather than the type name when resolving module names;
-  use `filename_suffix` instead of the hardcoded `_generated` one;
-  generate empty files if no structs or enums are available. This makes the set of output files more predictable for Bazel.
2024-05-01 14:39:47 -07:00
Philipp Schrader
7106d86685 Remove npm/rules_js dependency for C++ only use cases (#7990)
When flatbuffers is being used from a project that has no use for
JavaScript, users encounter an error similar to the following:

    ERROR: Skipping '@com_github_google_flatbuffers//:flatbuffers': error loading package '@com_github_google_flatbuffers//': Unable to find package for @npm//:defs.bzl: The repository '@npm' could not be resolved: Repository '@npm' is not defined.
    WARNING: Target pattern parsing failed.
    ERROR: error loading package '@com_github_google_flatbuffers//': Unable to find package for @npm//:defs.bzl: The repository '@npm' could not be resolved: Repository '@npm' is not defined.
    INFO: Elapsed time: 0.023s
    INFO: 0 processes.
    FAILED: Build did NOT complete successfully (0 packages loaded)
        currently loading: @com_github_google_flatbuffers//

That's not ideal. Users that only care about C++ for example
shouldn't be forced to deal with rules_js and friends.

This patch attempts to fix that by moving the rules_js-specific things
into the `ts` and `tests/ts` directories. This should allow
non-JavaScript projects to ignore rules_js and friends completely.

Here I basically followed the `rules_foo` example from rules_js:
https://github.com/aspect-build/rules_js/tree/main/e2e/rules_foo

The idea is that flatbuffers has its own npm dependencies regardless
of what other projects may have. This means we should not force the
user to import flatbuffers's npm dependencies. The new
`ts/repositories.bzl` file is used by dependents to import
flatbuffers's dependencies. They can still import their own
dependencies. This cleanup allowed me to move all
JavaScript-specific stuff from the top-level directory into
subdirectories.

There should be no changes in this patch in terms of functionality.
It's just a refactor of the rules_js call sites. Users will have to
add a call to the function in `ts/repositories.bzl` in their own
`WORKSPACE` file. They can use
`tests/ts/bazel_repository_test/WORKSPACE` as an example.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2024-04-18 05:06:06 +00:00
Paulo Pinheiro
da6472013f [Kotlin] Add workflow to release kotlin multiplatform version (#8014)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2024-04-17 17:10:39 -07:00
Derek Bailey
e646392647 flatbuffer_builder: Fix GetTemporaryPointer constantness 2024-04-17 16:06:26 +00:00
Michael Beardsworth
e040f4e975 Improve error handling on Object API name collision. (#8275)
If a schema contains a message named e.g. FooT and a message named Foo
while the Object API suffix is T, then two classes with colliding names
will be generated. This scenario will produce a C++ compiler error, but
it's confusing.

This patch moves the error to the compiler, allowing the user to more
readily act to correct the issue.

Co-authored-by: Michael Beardsworth <beardsworth@intrinsic.ai>
2024-04-05 12:27:43 -07:00
Fergus Henderson
f4a9c5325b Avoid ODR violations with flatbuffers::Verifier. (#8274)
Fix "One Definition Rule" violation when using flatbuffers::Verifier with
FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE defined in some compilation units
and not defined in other compilation units.

The fix is to make Verifier a template class, with a boolean template
parameter replacing the "#ifdef" conditionals; to rename it as
VerifierTemplate; and then to use "#ifdef" only for a "using" declaration
that defines the original name Verifier an an alias for the instantiated
template.  In this way, even if FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE is
defined in some compilation units and not in others, as long as clients
only reference flatbuffers::Verifier in .cc files, not header files, there
will be no ODR violation, since the only part whose definition varies is the
"using" declaration, which does not have external linkage.

There is still some possibility of clients creating ODR violations
if the client header files (rather than .cc files) reference
flatbuffers::Verifier.  To avoid that, this change also deprecates
FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE, and instead introduces
flatbuffers::SizeVerifier as a public name for the template instance with
the boolean parameter set to true, so that clients don't need to define
the macro at all.
2024-04-02 12:50:15 -07:00
Derek Bailey
8f2e1dbd88 Start Release workflow when published 2024-03-26 05:31:50 +00:00
Derek Bailey
595bf0007a FlatBuffers Version v24.3.25 2024-03-26 05:18:07 +00:00
mpawlowski-eyeo
0cfb7eb80b Fix handling non null-terminated string_views in LookupByKey (#8203)
* Reproduce the error in a unit test

Reproduces #8200

* Overload KeyCompareWithValue to work for string-like objects

This fixes #8200.

* Extra tests

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2024-03-25 10:39:51 -07:00
Derek Bailey
67eb95de92 presubmit.yml: Use xcode 14.2
It appears the upgrade to xcode 14.3 broke the macos build on builkite.
The last good build was using xcode 14.2, so go back to this version
until the issue is resolved.
2024-03-12 00:16:04 +00:00
Thomas Hartwig
b1f617fcb2 Fix License (#8253)
The previous license value was not suitable for most software license scanners. Listing the actual license string in the package.json fixes this
2024-03-11 16:45:30 -07:00
Wouter van Oortmerssen
960cd4d635 Lobster: Support required fields 2024-03-08 21:31:55 -08:00
Derek Bailey
6ff9e90e7e FlatBuffers Version v24.3.7 2024-03-07 15:16:33 -08:00
Derek Bailey
5b32e8f5c2 : Don't depend on java version 2024-03-07 14:56:09 -08:00
Derek Bailey
0bed8cd4a0 FlatBuffers Version v24.3.6 2024-03-07 07:23:33 +00:00
Derek Bailey
7cd216c51e FlatBuffers Version v24.3.6 2024-03-07 06:52:51 +00:00
Björn Harrtell
129ef422e8 Target .NET Standard 2.1, .NET 6, .NET 8 only (#8184)
* Target .NET Standard 2.1, .NET 6, .NET 8 only

* Remove mono usage

* Fix bat name ref

* Up deps

* Up deps

* Reinstate build-windows

* Fix name

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-12-19 14:43:55 -08:00
Derek Bailey
e5fc3b16d8 flatbuffer_builder: Prevent Finish() from being called twice 2023-12-19 18:41:26 +00:00
razvanalex
c0d16995a4 [TS/JS] Create byte vectors (#8185)
* Add createByteVector and use set in createString

* Add test for CreateByteVector

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-12-19 06:42:21 +00:00
Derek Bailey
70c8292c29 Update README.md
Remove Google Groups and Gitter links
2023-12-18 19:39:10 -08:00
razvanalex
d47cd10d77 Add Clear() for python Builder (#8186)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-12-17 22:18:11 -08:00
Derek Bailey
66bd3d7400 WORKSPACE: Run Buildifier 2023-12-18 05:47:56 +00:00
Derek Bailey
0cc1edb3ad WORKSPACE: go back to version that was working 2023-12-18 05:42:30 +00:00
Derek Bailey
57375a9e1c WORKSPACE: fix swift 2023-12-18 05:37:38 +00:00
Derek Bailey
0346535221 presubmit.yml: Explicitly use bazel 6.4.0 2023-12-18 05:33:39 +00:00
Derek Bailey
7d62dcc422 WORKSPACE: include latst build_bazel_rules_swift 2023-12-17 07:19:20 +00:00
Derek Bailey
b3cd878dfe WORKSPACE: remove old swift download 2023-12-17 07:12:14 +00:00
Derek Bailey
09486a9f97 WORKSPACE: update apple and rule_js 2023-12-17 07:07:30 +00:00
Yuriy Chernyshov
dd79eed495 Introduce convenient implicit operator string_view (#8181)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-12-16 22:30:21 -08:00
Derek Bailey
0e1305c8e2 Update label.yml
copy paste issue with last commit
2023-12-16 22:22:07 -08:00
Derek Bailey
88549130e1 Update label.yml
Go to version 4.1.0 as version main has breaking changes.
2023-12-16 22:17:46 -08:00
Björn Harrtell
6dfc59dfcc [TS/JS] Upgrade dependencies (#7996) 2023-12-13 16:57:46 -08:00
Aaron Barany
5ba80c24e0 Fix python type annotation output when not enabled (#7983)
Fixes #7971

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-11-29 09:58:21 -08:00
blindspotbounty
da55ac3a27 copy properties for conformance parser (#8174) 2023-11-26 11:35:58 -08:00
Felix
c6f9e010bb Fix cmake build for old versions (#8173)
Adresses all these issues ->
https://github.com/google/flatbuffers/issues/7994
https://github.com/google/flatbuffers/issues/7979
https://github.com/google/flatbuffers/issues/8049

Fix 7994, Fix 7979, Fix 8049

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-11-22 19:32:02 -05:00
mustiikhalil
94ff188a3e [Swift] Migrating benchmarks to a newer lib. (#8168)
* Adds Nativestructs pointer push into ByteBuffer

Updates benchmarks & cleanup

Adds native struct vector tests

* Address PR comments

* Add more benchmarks

* Some benchmark cleanup

* Return back to 1M structs

* Tweak Structs benchmark

* Moves swift Benchmarks folder from /tests to /benchmarks

---------

Co-authored-by: Joakim Hassila <jocke@ordo.one>
2023-11-22 16:08:55 -08:00
abandy
5a937f1ba1 [Swift] Add allowReadingUnalignedBuffers to most ByteBuffer init methods (#8134) 2023-11-20 22:52:19 +00:00
DoppelDe
e1c3690a2a Fix typo in CMakeLists.txt (#8167)
When building with make, it was failing for me because the target grpctext doesn't exist. I strongly assume this was meant to be grpctest.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-11-20 10:35:56 -08:00
Taylor Holliday
b08abbbbf6 [Swift] Push contiguous bytes (#8157)
* Add version of push which takes ContiguousBytes

* Ensure overloads aren't ambiguous

* Add version of createVector

* Add version of push which takes ContiguousBytes

* Ensure overloads aren't ambiguous

* Add version of createVector

* Add similar conditional to other use of ContiguousBytes

* Attempt CI fix

* Use memcpy instead of copyMemory

memcpy is faster in tests

* Add testContiguousBytes

* Add benchmarks

* Add version of createVector

* Add benchmarks

* Update push to copy memory

Since we don't care about endianness, we can simply memcpy the array of scalars

* Remove function and benchmarks

Since we don't care about endianness, a FixedWidthInteger version of createVector isn't needed

* Improve naming

* Add doc comment
2023-11-20 17:47:11 +01:00
James Courtney
7d6d99c6be Add absolute file names option to BFBS (#8055)
* Add absolute file names option (#1)

* Use ternary style for if

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-11-19 18:58:03 +00:00
Derek Bailey
d3055a97e7 update goldens with namespace 2023-11-19 07:51:36 +00:00
mustiikhalil
0dc5a75dc0 Update testReadFromOtherLanguages test to also run on macos (#8044) 2023-11-19 07:18:49 +00:00
tira-misu
f175e60998 [GO] compiles to much files (#8118)
* 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

* [TS] Fix reserved words as arguments (#6955)

* [TS] Fix generation of reserved words in object api (#7106)

* [TS] Fix generation of object api

* [TS] Fix MakeCamel -> ConvertCase

* [C#] Fix collision of field name and type name

* [TS] Add test for struct of struct of struct

* Update generated files

* Add missing files

* [TS] Fix query of null/undefined fields in object api

* Generate only files for comiled fbs (not for dependend ones)

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-11-18 19:23:09 -08:00
Derek Bailey
a632c3c004 Update build.yml (#8163)
* Update build.yml

Use our enterprise runners

* Make a default runs-on

* Update build.yml

Use the latest 64-core runners

* Update build.yml

Fix windows runner that don't have visual studios

* Update build.yml

use windows-2019 as the 2022 doesn't seem to have visual studios installed
2023-11-18 15:04:24 -08:00
Aleksandr Smolin
11789e41b6 Add argument to FlatBufferToString for quotes around field names, default false (#8090)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-11-18 21:29:41 +00:00
dependabot[bot]
a9c0845504 Bump word-wrap from 1.2.3 to 1.2.4 (#8042)
Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4.
- [Release notes](https://github.com/jonschlinkert/word-wrap/releases)
- [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4)

---
updated-dependencies:
- dependency-name: word-wrap
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-18 13:23:28 -08:00
mustiikhalil
526c92546f Fixes forward offset verifiable objects within arrays (#8135)
Fixes failing tests & removes XCTestsManifests

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-11-18 21:14:55 +00:00
Derek Bailey
eb80ead90b Update build.yml (#8162)
Removes some old comments from the CI builds.
2023-11-18 13:09:02 -08:00
Artem Shilkin
386b6353ed data() instead of c_str() (#8069) 2023-11-18 12:50:51 -08:00
Peter Dye
d09696bbe6 Fix spelling mistake in FlatBufferBuilder.cs doc comments (#8120)
No change to code. Very simple spelling mistake/typo fix.
2023-11-18 12:14:25 -08:00
Lukas
a228e8c9b8 Add help text to cmake git describe error message (#8123) 2023-11-18 12:13:54 -08:00
dependabot[bot]
91a3172519 Bump google.golang.org/grpc in /grpc/examples/go/greeter/client (#8131)
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.53.0 to 1.56.3.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.53.0...v1.56.3)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-18 12:12:44 -08:00
dependabot[bot]
e0d4562782 Bump google.golang.org/grpc in /grpc/examples/go/greeter/server (#8132)
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.53.0 to 1.56.3.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.53.0...v1.56.3)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-18 12:12:16 -08:00
dependabot[bot]
49677b0b70 Bump google.golang.org/grpc in /grpc/examples/go/greeter/models (#8130)
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.53.0 to 1.56.3.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.53.0...v1.56.3)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-18 12:11:35 -08:00
Lukas
8e34ad5db7 Remove pragma warning disable C4351 as it is undocumented (#8124)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-11-18 12:09:47 -08:00
Felix
eb64390080 Update Compiler.md docs (#8153)
* Escape singel underscores in markdown

* Update language generator flags in docs

* Complet the list of Python options
2023-11-18 12:08:04 -08:00
Gleb Lamm
46577d0d2f Fix: detect c++ standard on MSVC for span (#8155) 2023-11-18 12:06:18 -08:00
Ivan Dlugos
32029ac699 chore: Dart 23.5.26 release (#8160)
* chore: update generated test code

* chore: update changelog

* update sdk constraints

* chore: update readme

* minor linter issues
2023-11-18 11:56:54 -08:00
Derek Bailey
4354945727 Fix CI builds (#8161)
* Update build.yml

Upgrade to gcc 13 and clang 15

* switch to __is_trivially_copyable

* fix cmake issue and warning about sign comparison

* Use libc++ for C++23 on clang for now

* Use libc++ for C++23 on clang for now

* exclude clang+15 for C++13 builds
2023-11-18 00:19:03 -08:00
Steven Toribio
755573bcda wow (#8158) 2023-11-16 10:22:29 -08:00
adsnaider
205285c35c [Rust] Add the Allocator trait for the builder API (#8106)
* Add an Allocator trait for FlatBufferBuilder

* Update rust generated code
2023-10-07 15:28:52 -04:00
Curt Hagenlocher
f4e23bf91e Fix verification for C# unions (#7970)
* Fix verification for unions

* Run scripts\generate_code.py

---------

Co-authored-by: Michael Le <michael.le647@gmail.com>
2023-09-30 18:54:48 -07:00
Lukas
1fdb5d263a Add const qualifier to non-mutated FlatbufferBuilder parameter (#8101)
Co-authored-by: Michael Le <michael.le647@gmail.com>
2023-09-30 23:52:56 +00:00
Björn Harrtell
c4211538bd TS: Add missing generate files (#8075)
Co-authored-by: Michael Le <michael.le647@gmail.com>
2023-09-30 10:51:32 -07:00
Artem Shilkin
bcb9ef1876 moved function to namespace (#8068) 2023-09-29 07:50:06 -07:00
Elior Schneider
c5441dc199 corrected a typo (#8063) 2023-09-29 07:40:02 -07:00
Artem Shilkin
7f417e3397 added explicit cast (#8066)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-09-29 07:39:38 -07:00
Artem Shilkin
3c35a143ea removed decrement of rvalue-pointer (#8067)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-09-29 07:34:16 -07:00
Markus Junginger
56e2bc30b0 C++ strict conversion fixes for flatbuffer_builder.h (#8062) (#8065)
Enables to compile flatbuffer_builder.h with strict settings -Wconversion -Wsign-conversion.
Also, add asserts to verify the conversions.
2023-09-29 07:30:23 -07:00
xaphier
eb40a54672 Add constexpr for bitmask operators (#8037)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-09-28 23:17:52 -07:00
Pavlo Bashmakov
15f16f149e Fix misalignment of small structs in a Vector (C++) (#7883)
* Rare fix: kick fix test

* Rare fix: real fix

* Rare fix: separate test

* Rare fix: remove comments

* Rare fix: updates

* Rare fix: less

* Rare fix: size_t switch to uoffset_t

* Rare fix: swap exp/val

* Rare fix: add annotated before/after

* Rare fix: remove unnecessary changes

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-09-28 22:53:50 -07:00
Derek Bailey
053d39adaf Update build.yml
Update to clang-14 as clang-12 is no longer supported
2023-09-28 22:26:28 -07:00
mustiikhalil
6f71b76e6f Allow reading unaligned buffers starting from swift 5.7, while keeping the creating aligned since its created by the library (#8061)
Addresses a warning on xcode 15 regarding copying a pointer without safeguards

Address PR comments regarding initializing buffers with flag

Adds a test case for copying unaligned buffers

Formatting code
2023-09-27 01:50:03 -04:00
Michael Le
4b7d8e0df9 Fix nim workflow (#8098)
* Fix nim workflow

* Fix yaml
2023-09-22 22:18:30 -07:00
dependabot[bot]
0def91105f Bump google.golang.org/grpc in /grpc/examples/go/greeter/models (#8025)
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.35.0 to 1.53.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.35.0...v1.53.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Michael Le <michael.le647@gmail.com>
2023-09-21 20:41:18 +00:00
dependabot[bot]
8176a204fc Bump google.golang.org/grpc in /grpc/examples/go/greeter/client (#8026)
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.35.0 to 1.53.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.35.0...v1.53.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Michael Le <michael.le647@gmail.com>
2023-09-20 22:04:44 -04:00
Ivo List
e8b2492cf1 Upgrade rules_go (#8092)
* Upgrade rules_go

* Revert go toolchain

---------

Co-authored-by: Michael Le <michael.le647@gmail.com>
2023-09-20 23:32:11 +00:00
dependabot[bot]
5d4386b1bc Bump google.golang.org/grpc in /grpc/examples/go/greeter/server (#8027)
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.39.0-dev to 1.53.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.39.0-dev...v1.53.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Michael Le <michael.le647@gmail.com>
2023-09-20 23:27:39 +00:00
Gowroji Sunil
a6a3989dd4 [bazel] Update Platforms (#8083)
* Update Platforms

* Update WORKSPACE

* indentation

* Update WORKSPACE

---------

Co-authored-by: Michael Le <michael.le647@gmail.com>
2023-09-20 16:22:25 -07:00
Wouter van Oortmerssen
696f47f1f7 Fix Nim warning 2023-09-17 21:19:28 -07:00
Wouter van Oortmerssen
a3dfcf3326 Update Lobster monster sample 2023-09-17 21:18:03 -07:00
Wouter van Oortmerssen
d3e8cb60a1 Lobster namespace change 2023-09-17 10:21:58 -07:00
Anton Bobukh
0343396e49 Fully qualify the offset type in FLATBUFFERS_VTABLE_UNDERLYING_TYPE (#8094) 2023-09-13 10:23:39 -07:00
jviel-beta
f625ff3330 [TS] Allows object API to set 0 for a null-default scalar. (#7864)
* Fixes bug where null default allows 0 as a value.

* Undoes one bit, adds null type allowance to addField<> default.

* Undoes IDE auto-format of imports.

* Adds generated changes after scripts/generate_code.py

* Removes unused symbol.

* Revert "Removes unused symbol."

This reverts commit 9cece17325.

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-09-12 19:58:55 +02:00
Philipp Schrader
362dd663f8 Fix BUILD.bazel style violations (#8081)
`buildifier` was complaining as follows:

    #### :bazel: buildifier: found 2 lint issues in your WORKSPACE, BUILD and *.bzl files
    <pre><code>tests/ts/bazel_repository_test_dir/BUILD:3:1: <a href="https://github.com/bazelbuild/buildtools/blob/master/WARNINGS.md#out-of-order-load">out-of-order-load</a>: Load statement is out of its lexicographical order.
    ts/BUILD.bazel:2:1: <a href="https://github.com/bazelbuild/buildtools/blob/master/WARNINGS.md#out-of-order-load">out-of-order-load</a>: Load statement is out of its lexicographical order.</pre></code>

This can be fixed locally like so:

    $ buildifier -lint fix $(git ls-files | grep -e '/BUILD.bazel$' -e '/BUILD$' -e '\<WORKSPACE$')

I also took this opportunity to fix one of the filenames.

I accidentally introduced these errors in #8078.
2023-08-28 09:20:10 +02:00
Philipp Schrader
5a8a395756 Upgrade the bazel-related dependencies (#8078)
This patch updates all the bazel-related dependencies to their latest
available versions. All tests still pass.

Fixes: #8076
2023-08-25 18:15:12 +02:00
Max Burke
afafd206a3 Optional omission of Typescript entrypoint (#8057) 2023-08-20 10:28:47 +02:00
OptoCloud
48da238920 Make eslint less pedantic (#8012)
* Disable eslint spam

* Generate TS example files
2023-07-10 15:48:16 +00:00
Derek Bailey
8836ddab41 Update stale.yml 2023-07-08 15:18:47 -07:00
Wouter van Oortmerssen
23922e7eba FlexBuffers: JSON output supports indentation 2023-06-14 18:12:55 -07:00
Wouter van Oortmerssen
f8fe811d5c FlexBuffers: allow getting size & undo of map in progress 2023-06-14 17:12:37 -07:00
Derek Bailey
0cc525b722 fix android typo 2023-05-31 19:31:47 +00:00
Derek Bailey
28861d1d7d various fixes (#7986) 2023-05-31 11:52:05 -07:00
James Kuszmaul
204473cdb5 [Bazel] Fix gen_reflections for flatbuffers_ts_library (#7981)
If you used flatbuffers_ts_library with gen_reflections = True then it
attempted to use the flat-file compiler rather than flatc itself.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-05-31 18:07:37 +00:00
Paulo Pinheiro
85088a196d Small optimization on "deserialization" and fix on benchmarks again (#7982)
* [Kotlin] Small optimizations and benchmark on deserialization

* [Kotlin] Remove redudant assign() method (use init() instead)

* [Kotlin] Fix benchmark run after change in flatbuffers-java deps

Commit 6e214c3a49 fixes Kotlin build,
but makes the kotlin-benchmark plugin misses the java classes at
runtime, causing NotClassFoundError. The alternative to solve the issue
is to read java's pom.xml to get the latest java version and use it
as dependency. With that we avoid compilation errors on a new version and
keep benchmark plugin happy.
2023-05-31 11:02:39 -07:00
Paulo Pinheiro
6e214c3a49 [Kotlin] Add java source on benchmark module instead of using version jar (#7978)
By using specific jar version to use java's runtime on the benchmark
module we let CI break when new versions are released. So we are using
source directly instead
2023-05-26 14:07:18 -07:00
Derek Bailey
96294e9f84 Add ForceVectorAlignment64 and test (#7977) 2023-05-26 11:49:06 -07:00
Paulo Pinheiro
b7856f8e27 Add Kotlin multiplatform support (#7969)
* [Kotlin] Introduction to Kotlin Multiplaform

The first implementation of the Kotlin code generation was made years
ago at the time Kotlin Multiplaform was not stable and Kotlin is mostly
used on JVM-based targets. For this reason the generated code uses java
based runtime.

That design decision comes with many drawbacks, leaving the code
generated more java-like and making it impossible to use more advanced
features of the Kotlin language.

In this change we are adding two parts: A pure, multi-plaform, Kotlin
runtime and a new code generator to accompany it.

* [Kotlin] Remove scalar sign cast from code generation

Now that we have a new runtime the accepts unsigned types, we don't
need to code generate casting back and from signed scalars. This
MR removes this from both code generations and adds the necessary
API to the runtime.

* [Kotlin] Use offset on public API to represent buffer position

Currently, kotlin was following Java's approach of representing objects,
vectors, tables as "Int" (the position of it in the buffer). This change
replaces naked Int with Offset<T>, offering a type-safe API. So,
instead of

fun Table.createTable(b: FlatBufferBuilder, subTable: Int)

We will have

fun Table.createTable(b: FlatBufferBuilder, subTable: Offset<SubTable>)

Making impossible to accidentally switch parameters.

The performance should be similar to use Int as we are using value
class for Offset and ArrayOffset, which most of the time translate to
Int in the bytecode.

* [Kotlin] Add builder for tables

Add builder constructor to make create of table more ergonomic.
For example the movie sample for the test set could be written as:

Movie.createMovie(fbb,
    mainCharacterType = Character_.MuLan,
    mainCharacter = att) {
    charactersType = charsType
    this.characters = characters
}

instead of:

Movie.startMovie(fbb)
Movie.addMainCharacterType(fbb, Character_.MuLan)
Movie.addMainCharacter(fbb, att as Offset<Any>)
Movie.addCharactersType(fbb, charsType)
Movie.addCharacters(fbb, charsVec)
Movie.endMovie(fbb)

* [Kotlin] Move enum types to value class

Moving to flatbuffer enums to value class adds type safety for parameters
with minimum to no performance impact.

* [Kotlin] Simplify Union parameters to avoid naked casting

Just a small change on the APIs that receive union as parameters,
creating a typealias UnionOffset to avoid using Offset<Any>. To "convert"
an table offset to an union, one just call Offset.toUnion().

* [Kotlin] Apply clang-format on kotlin code generators

* [Kotlin] Update kotlin generator to follow official naming conventions

Updating directory, package and enum naming to follow Kotlin official
convention.

https://kotlinlang.org/docs/coding-conventions.html#naming-rules

* [Kotlin] Add fixes to improve performance

1 - Add benchmark comparing serialization between Java & Kotlin
2 - ReadWriteBuffer does not auto-grow (thus avoid check size in every op)
3 - Add specialized add functions on FlatBufferBuilder to avoid boxing
offsets.
4 - Remove a few Kotlin syntax sugar that generated performance penalties.

* [Kotlin] Remove builder from Kotlin KMP and add some optimizations
to avoid boxing of Offset classes

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-05-26 11:00:33 -07:00
Derek Bailey
0100f6a577 FlatBuffers Version 23.5.26 (#7976) 2023-05-26 10:33:09 -07:00
swimar
e0a87e36d5 Update java pom.xml file to allow flatbuffers-java maven package to be compiled under java 8, and pulled in as a dependency to a project using java 8. (#7893) (#7894)
Co-authored-by: Derek Bailey <derekbailey@google.com>
Co-authored-by: Paulo Pinheiro <paulovictor.pinheiro@gmail.com>
2023-05-22 09:18:37 +02:00
Derek Bailey
b67f1ad6d0 don't emit flatbuffers include in bfbs generated output (#7968) 2023-05-17 21:13:16 -07:00
Derek Bailey
ae6753684e switch back to having T explicitly defined in CreateVector (#7967) 2023-05-17 13:23:34 -07:00
Chih-Hsuan Yen
a352bdbc34 Fix python tests (#7960)
* Don't generate types unless --python-typing specified

Fixes https://github.com/google/flatbuffers/issues/7944

* Fix incorrect import statements

Fixes https://github.com/google/flatbuffers/issues/7951

* Fix $PYTHONPATH in PythonTest.sh

Regressed from https://github.com/google/flatbuffers/pull/7529

* PythonTest: fail if something goes wrong

GitHub Actions runs `bash PythonTest.sh`, and thus failures were not
visible.

* Build flatc for Python tests

* Regenerate codes

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-05-17 13:10:51 -07:00
sssooonnnggg
cb14043f82 fix(rust): fixed rust namer isses, resolve #7865 and ##7782 (#7964)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-05-17 19:54:49 +02:00
Derek Bailey
d64dc6200a Switch to using alias instead of a typedef for FlatBufferBuilder (#7966) 2023-05-17 10:40:02 -07:00
sssooonnnggg
ea7cfcd591 chore: add rust windows test to CI, fix RustTest.bat (#7963)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-05-16 16:06:41 -07:00
Daniel Frederick Crisman
067553156a README.md: SemVer case typo (#7962)
SemVer (if we are capitalizing it) has a capital V. See the third
sub-header at
https://semver.org/#semantic-versioning-specification-semver
"Semantic Versioning Specification (SemVer)"

Update the text in Versioning section
2023-05-16 09:46:47 -07:00
sssooonnnggg
b128b802d9 feat: Support union underlying type for TS/JS (#7961) 2023-05-15 13:18:49 -07:00
sssooonnnggg
1d3afb90c5 feat(C++): Support underlying_type for union (#7954)
* feat(C++): support underlying type for union

* chore: add conform checks for underlying type changes
2023-05-14 21:22:38 -07:00
Derek Bailey
fe5e4c71c5 remove flatbuffers tests from android (#7959) 2023-05-12 21:49:33 -07:00
Derek Bailey
17b9eed4e1 switch to interface library for flatsample 2023-05-12 21:23:51 -07:00
Derek Bailey
cbc8872b99 fix Mac build about gen sources and multiple targets 2023-05-12 17:11:18 -07:00
Derek Bailey
05743591e1 remove and auto-generate arrays_test_generated.h 2023-05-12 16:44:28 -07:00
Derek Bailey
2bc2529245 remove and auto-generate alignment_test_generated.h 2023-05-12 16:26:21 -07:00
sssooonnnggg
18cadc79c1 fix(TS): fixed incorrect function name when importing unionTo functions (#7958) 2023-05-12 10:49:50 -07:00
Wouter van Oortmerssen
426f3b8bf2 Missing GenTextFile decl 2023-05-11 18:26:06 -07:00
Wouter van Oortmerssen
950a71ab89 Rename GenerateText
to make it a compile-time breaking change, to alert any users to the new meaning of the return value
2023-05-11 18:14:27 -07:00
Derek Bailey
86486a1735 run scripts/clang-format-all.sh 2023-05-11 12:23:49 -07:00
Derek Bailey
c2f764c22b add GetSizePrefixedBufferLength() 2023-05-11 12:22:05 -07:00
Derek Bailey
e97ff95970 Change SizedPrefixed verifier to be <= provided size 2023-05-11 12:22:05 -07:00
Derek Bailey
33212657ae Change SizedPrefixed verifier to be <= provided size (#7957)
* Change SizedPrefixed verifier to be <= provided size

* add GetSizePrefixedBufferLength()
2023-05-11 12:21:50 -07:00
Derek Bailey
66e9d9823a fixed other occurenace of big buffer 2023-05-11 09:39:54 -07:00
Derek Bailey
9fc153a8f8 remove large buffer creation in test to speed it up 2023-05-11 09:34:50 -07:00
Philipp Schrader
c2bf810638 Fix //tests/ts:bazel_repository_test (#7952)
The test was not actually invoking the bazel that was downloaded with
the `http_file` rule. I failed to add `executable = True` to the
`http_file` call. This caused the test to ignore that bazel binary and
went to the next one on the system.

This patch fixes the issue by adding the missing attribute. Also, this
patch changes the check in the test to make sure that the downloaded
file is indeed executable.
2023-05-10 21:35:58 -07:00
Derek Bailey
0ce6957763 remove unneeed grpc include 2023-05-10 16:41:39 -07:00
Derek Bailey
82c6712606 make loop variable final in dart 2023-05-10 16:30:12 -07:00
Derek Bailey
b5957975c5 rename __suppress_ubsan to FLATBUFFERS_SUPPRESS_UBSAN 2023-05-10 14:16:31 -07:00
Derek Bailey
85f71321fd Update README.md
Added Quick State to the main readme file
2023-05-10 13:56:13 -07:00
Derek Bailey
3e6cd51b63 fixed bfbs gen to pass extra options (#7949) 2023-05-09 22:42:31 -07:00
Derek Bailey
10b79d87c1 removed extern code generation declarations preferring direct includes (#7948)
* removed extern code generation definitions, preferring direct includes

* add static to functions

* remove idl_gen_lua
2023-05-09 21:50:28 -07:00
Derek Bailey
16a7df46f0 fix --conform raising No generators registered error 2023-05-09 20:37:32 -07:00
Derek Bailey
76f5e9816a fix out-of-source builds with cmake (#7946) 2023-05-09 20:33:54 -07:00
Björn Harrtell
368428cb94 Upgrade package.json dependencies (#7933)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-05-09 20:33:17 -07:00
Derek Bailey
72b56fd081 FlatBuffers Version 23.5.9 (#7945) 2023-05-09 09:33:30 -07:00
Derek Bailey
63b7b25289 FlatBuffers 64 for C++ (#7935)
* First working hack of adding 64-bit. Don't judge :)

* Made vector_downward work on 64 bit types

* vector_downward uses size_t, added offset64 to reflection

* cleaned up adding offset64 in parser

* Add C++ testing skeleton for 64-bit

* working test for CreateVector64

* working >2 GiB buffers

* support for large strings

* simplified CreateString<> to just provide the offset type

* generalize CreateVector template

* update test_64.afb due to upstream format change

* Added Vector64 type, which is just an alias for vector ATM

* Switch to Offset64 for Vector64

* Update for reflection bfbs output change

* Starting to add support for vector64 type in C++

* made a generic CreateVector that can handle different offsets and vector types

* Support for 32-vector with 64-addressing

* Vector64 basic builder + tests working

* basic support for json vector64 support

* renamed fields in test_64bit.fbs to better reflect their use

* working C++ vector64 builder

* Apply --annotate-sparse-vector to 64-bit tests

* Enable Vector64 for --annotate-sparse-vectors

* Merged from upstream

* Add `near_string` field for testing 32-bit offsets alongside

* keep track of where the 32-bit and 64-bit regions are for flatbufferbuilder

* move template<> outside class body for GCC

* update run.sh to build and run tests

* basic assertion for adding 64-bit offset at the wrong time

* started to separate `FlatBufferBuilder` into two classes, 1 64-bit aware, the other not

* add test for nested flatbuffer vector64, fix bug in alignment of big vectors

* fixed CreateDirect method by iterating by Offset64 first

* internal refactoring of flatbufferbuilder

* block not supported languages in the parser from using 64-bit

* evolution tests for adding a vector64 field

* conformity tests for adding/removing offset64 attributes

* ensure test is for a big buffer

* add parser error tests for `offset64` and `vector64` attributes

* add missing static that GCC only complains about

* remove stdint-uintn.h header that gets automatically added

* move 64-bit CalculateOffset internal

* fixed return size of EndVector

* various fixes on windows

* add SizeT to vector_downward

* minimze range of size changes in vector and builder

* reworked how tracking if 64-offsets are added

* Add ReturnT to EndVector

* small cleanups

* remove need for second Array definition

* combine IndirectHelpers into one definition

* started support for vector of struct

* Support for 32/64-vectors of structs + Offset64

* small cleanups

* add verification for vector64

* add sized prefix for 64-bit buffers

* add fuzzer for 64-bit

* add example of adding many vectors using a wrapper table

* run the new -bfbs-gen-embed logic on the 64-bit tests

* remove run.sh and fix cmakelist issue

* fixed bazel rules

* fixed some PR comments

* add 64-bit tests to cmakelist
2023-05-09 09:16:30 -07:00
RishabhDeep Singh
13fc75cb6b FlatBuffers Version 23.5.8 (#7943) 2023-05-09 08:05:25 -07:00
RishabhDeep Singh
e6e38a8d17 Add #!/usr/bin/bash to release.sh (#7942) 2023-05-08 14:20:14 -07:00
Derek Bailey
d9f2cc2d62 add key_field to compiled tests 2023-05-08 13:54:24 -07:00
Derek Bailey
197ae6cc7e add rest of golden language directories 2023-05-05 14:22:55 -07:00
Derek Bailey
489d9735e9 add rest of golden language directories 2023-05-05 14:15:48 -07:00
Derek Bailey
3308444147 Add goldens directory 2023-05-05 13:43:07 -07:00
Derek Bailey
ef5ae488dd Rework cmake flatc codegeneration (#7938)
* start fixing the code generation steps

* reworked flatc generation in cmake
2023-05-05 12:08:09 -07:00
Derek Bailey
08efe60954 remove defining generated files in test srcs 2023-05-04 16:25:50 -07:00
Derek Bailey
01a7bc3c58 Add binary schema reflection (#7932)
* Add binary schema reflection

* remove not-used parameter

* move logic from object API to base API

* forward declare

* remove duplicate code gen that was stompping on the edits

* reduce to just typedef generation

* fixed bazel rules to not stomp

* more bazel fixes to support additional generated files
2023-05-04 16:12:45 -07:00
Wouter van Oortmerssen
67084b9921 Fix missing return error string for GenerateText 2023-05-03 13:23:53 -07:00
Wouter van Oortmerssen
ed11b08fc9 GenerateText gives text error on failure 2023-05-03 13:03:00 -07:00
Philipp Schrader
c1e7aee489 Migrate from rules_nodejs to rules_js/rules_ts (take 2) (#7928)
* Migrate from rules_nodejs to rules_js/rules_ts (take 2)

This is the second version of patch #7923. The first version got
reverted because bazel query was failing:

    $ bazel --nosystem_rc --nohome_rc query tests(set('//...')) except tests(attr("tags", "manual", set('//...')))
    ERROR: Traceback (most recent call last):
    	File "/workdir/tests/ts/bazel_repository_test_dir/BUILD", line 6, column 22, in <toplevel>
    		npm_link_all_packages(name = "node_modules")
    	File "/var/lib/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/ec321eb2cc2d0f8f91b676b6d4c66c29/external/npm/defs.bzl", line 188, column 13, in npm_link_all_packages
    		fail(msg)
    Error in fail: The npm_link_all_packages() macro loaded from @npm//:defs.bzl and called in bazel package 'tests/ts/bazel_repository_test_dir' may only be called in bazel packages that correspond to the pnpm root package '' and pnpm workspace projects ''

This was happening because the `.bazelrc` file only added
`--deleted_packages` to the `build` command. We also need it for the
`query` command. This second version of the patch fixes that.

Original commit message:

This patch migrates the current use of rules_nodejs to the new rules_js.
rules_js is the intended replacement of rules_nodejs as per this note:
https://github.com/aspect-build/rules_js#relationship-to-rules_nodejs

> rules_js is an alternative to the build_bazel_rules_nodejs Bazel module
> and accompanying npm packages hosted in
> https://github.com/bazelbuild/rules_nodejs, which is now
> unmaintained. All users are recommended to use rules_js instead.

There are a few notable changes in this patch:
1. The `flatbuffer_ts_library` macro no longer accepts a `package_name`
   attribute. This is because rules_js appears to manage the import
   naming of dependencies via top-level `npm_link_package` targets.
   Users will have to migrate.
2. I added a few more arguments to `flatbuffer_library_public()`. These
   helped with exposing esbuild to `ts/compile_flat_file.sh`.
3. I pinned the version of `typescript` in `package.json` so that
   rules_ts can download the exact same version. rules_ts doesn't know
   what to do if the version isn't exact.
4. Since rules_js uses the pnpm locking mechanism, we now have a
   `pnpm-lock.yaml` file instead of a yarn lock file.
4. I added bazel targets for a few of the existing tests in `tests/ts`.
   They can be run with `bazel test //test/ts:all`. Since there is no
   flexbuffers bazel target, I did not add a bazel target for the
   corresponding test.
5. I added a separate workspace in `tests/ts/bazel_repository_test_dir/`
   to validate that the flatbuffers code can be imported as an external
   repository. You can run the test with
   `bazel test //test/ts:bazel_repository_test`. For this to work, I
   needed to expose a non-trivial chunk of the flatbuffers code to the
   test. I achieved this through some recursive `distribution`
   filegroups. This is inspired by rules_python's workspace tests.

I did not do anything special to validate that the `gen_reflections`
parameter works the same. This patch doesn't change anything about
the TypeScript generation.

As a side note: I am not an expert with rules_js. This patch is my
attempt based on my limited understanding of the rule set.

Fixes #7817

* Fix the query

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-05-03 11:48:15 -07:00
Derek Bailey
75143f836b fix possible null dereference for nested_root accessor 2023-05-03 00:14:27 -07:00
Derek Bailey
fb4f6fb894 fix possible null dereference for nested_root accessor 2023-05-02 23:50:20 -07:00
Derek Bailey
19d8942943 flat_buffers.dart: mark const variable finals for internal Dart linters 2023-05-01 09:55:47 -07:00
Derek Bailey
dbce69c63b more window fixes 2023-04-29 00:43:34 -07:00
Derek Bailey
aeba096403 fixed some windows warnings (#7929) 2023-04-28 23:22:41 -07:00
Derek Bailey
966aae2144 inject no long for FBS generation to remove logs in flattests (#7926)
* inject no long for FBS generation to remove logs in flattests

* updated blaze rules
2023-04-28 13:40:38 -07:00
Derek Bailey
e7dc252b0e Revert "Migrate from rules_nodejs to rules_js/rules_ts (#7923)" (#7927)
This reverts commit 4172c3f0bd.
2023-04-28 12:58:49 -07:00
Philipp Schrader
4172c3f0bd Migrate from rules_nodejs to rules_js/rules_ts (#7923)
* Start using pnpm

* Add @npm

* get more stuff set up

* Get the analysis phase passing.

* Get esbuild working?

* Get it compiling?

    $ bazel build //tests/ts/...

* Try to get the test working

* test is passing

* Get the other tests working

* clarify comment

* clean up a bit

* Try to add another test

* Add another test

* clean up more

* remove unused reference

* Add e2e test

* Get more of the test working

* add lock file

* Get test working on its own

* Get e2e test passing

* fix infinite recursion

* Add comments

* clean up some more

* clean up more again

* Source typescript version from package.json

* run buildifier

* lint

* Fix unset `extra_env`

* Incorporate feedback

* run buildifier

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-04-28 18:17:45 +00:00
Aaron Riekenberg
417821fdd7 Only generate @kotlin.ExperimentalUnsigned annotation on create*Vector methods having an unsigned array type parameter. (#7881)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-04-28 17:10:01 +00:00
Berke
c192ab423b additional check for absl::string_view availability (#7897)
absl::string_view is uses std::string_view when available. It already checks if std::string_view is available in the earlier code.
It should only use absl::string_view implementation.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-04-28 16:51:11 +00:00
Max Burke
a397dd7e8c Optionally generate Python type annotations (#7858)
* optionally generate type prefixes and suffixes for python code

* fix codegen error when qualified name is empty

* WIP: Python typing

* more progress towards python typing

* Further iterate on Python generated code typing

* clang-format

* Regenerate code

* add documentation for Python type annotations option

* generate code with Python type annotations

* handle forward references

* clang-format
2023-04-28 09:38:29 -07:00
Jongwoo Han
6eae49a79a Replace deprecated command with environment file (#7921)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-04-25 22:50:37 -07:00
Nikita Sokolov
f6af2087ee drop glibc from runtime dependencies (#7906)
https://github.com/google/flatbuffers/issues/7696
The binary size grows from 5.8MB to 7.2MB, but this way it works on Ubuntu 18.04 and amazonlinux.
2023-04-25 22:39:37 -07:00
Adam Oleksy
ab716ee41d Make JSON supporting advanced union features (#7869)
This change allows user to decode binary with given schema to JSON
representation when schema defines union with struct.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-04-26 05:37:06 +00:00
KerstinKeller
d6d83c3a92 Allow to use functions from BuildFlatBuffers.cmake from a flatbuffers installation installed with CMake. (#7912)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-04-26 05:27:14 +00:00
José Luis Millán
aa6848fbf6 TS/JS: Use TypeError instead of Error when appropriate (#7910)
Ie: when the needed conditions are not satisfied in order to perform a
 given action.
2023-04-25 22:22:06 -07:00
Jeroen Demeyer
6c8a8d054d Go: make generated code more compliant to "go fmt" (#7907)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-04-26 05:19:07 +00:00
Jeroen Demeyer
63495b935a Support file_identifier in Go (#7904)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-04-26 05:15:09 +00:00
Max Burke
56ecc1f548 Optionally generate type prefixes and suffixes for python code (#7857)
* optionally generate type prefixes and suffixes for python code

* fix codegen error when qualified name is empty

* generated code updated
2023-04-25 21:38:16 -07:00
Jeroen Demeyer
3fda20d7c7 Go: add test for FinishWithFileIdentifier (#7905)
Co-authored-by: Michael Le <michael.le647@gmail.com>
2023-04-11 17:08:04 -07:00
Jeroen Demeyer
fa3fa91936 Fix go_sample.sh (#7903) 2023-04-11 12:40:00 -07:00
Björn Harrtell
52f2596e15 [TS/JS] Upgrade dependencies (#7889)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-04-06 02:00:23 +00:00
Khanh Nguyen
0916f1c87e Add a FileWriter interface (#7821)
* Add a FileWriter interface

* Change interface

* Provide 2 impl for File interface: FileManager & FileNameManager

* Update

* update

* Update

* Add file_writer file

* Update

* Format files

* Update based on review

* Update

* Format bzl file

* Add LoadFile function

* Format

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-04-06 01:49:29 +00:00
Björn Harrtell
0888e7cb4d TS/JS: Use minvalue from enum if not found (#7888)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-04-06 01:26:05 +00:00
tira-misu
876a64aae1 [CS] Verifier (#7850)
* 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

* [TS] Fix reserved words as arguments (#6955)

* [TS] Fix generation of reserved words in object api (#7106)

* [TS] Fix generation of object api

* [TS] Fix MakeCamel -> ConvertCase

* [C#] Fix collision of field name and type name

* [TS] Add test for struct of struct of struct

* Update generated files

* Add missing files

* [TS] Fix query of null/undefined fields in object api

* Add .Net verfier

* Add some fuzz tests for .Net

* Remove additional files

* Fix .net test

* Changes due to PR

* Fix generated files

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-04-06 00:29:14 +02:00
Daniel Frederick Crisman
2803983c70 README.md: PyPI case typo (#7880)
PyPI has three capital letters. See the front page of the service:
https://pypi.org/
"The Python Package Index (PyPI) ..."

Update the Python link under "Supported programming languages"

Co-authored-by: Michael Le <michael.le647@gmail.com>
2023-03-30 13:32:16 -07:00
Michael Le
88dd92de40 Update go documentation link to point to root module (#7879)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-03-29 10:50:54 -07:00
blindspotbounty
477b1b5d13 use Bool for flatbuffers bool instead of Byte (#7876)
Add test for Bool type in swift

Co-authored-by: mustiikhalil <26250654+mustiikhalil@users.noreply.github.com>
2023-03-27 01:45:48 +02:00
phenixxy
1cb1c4baee fix using null string in vector (#7872)
Use 0 offset as special value. 0 offset is not a valid relative offset, so it's safe to use 0 offset to indicate value is null.

https://github.com/google/flatbuffers/issues/7846
2023-03-24 03:15:34 +00:00
Derek Bailey
50cdf92e1e Add flatbuffers-64 branch to CI for pushes 2023-03-15 23:58:26 -07:00
Jeffrey Smith
9a7fb4d68a made changes to the rust docs so they would compile. new_with_capacity is deprecated should use with_capacity, get_root_as_monster should be root_as_monster (#7871) 2023-03-16 00:29:57 +00:00
SmashedFrenzy16
3cb27fa241 Adding comment for code clarification (#7856)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-03-14 20:14:05 -05:00
Paulo Pinheiro
d3d7e2ef99 ToCamelCase() when kLowerCamel now converts first char to lower. (#7838)
ToCamelCase(input, true) converts first char to upper case, but
ToCamelCase(input, false) keeps the case of the first char. We are
changing its behavior to force a lower case.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-03-15 01:09:24 +00:00
Ben Beasley
d4d355d883 Fix help output for --java-checkerframework (#7854) 2023-03-09 06:53:37 +00:00
SmashedFrenzy16
0fde16e426 Update filename to README.md and improve formatting (#7855) 2023-03-09 04:55:13 +00:00
Derek Bailey
32a6744286 Increase limit on stale.yml items processed 2023-03-03 17:02:14 -08:00
Derek Bailey
42ee479c31 Allow manual runs of stale.yml 2023-03-03 16:59:45 -08:00
Derek Bailey
df007dfde8 Update stale.yml
Shorten the PR staleness from 6 months to 3 weeks + 1 week notice. PRs become much harder to deal with the old they become due to merge conflicts and divergence.

Updated to stale@v7.0.0
2023-03-03 16:52:14 -08:00
Derek Bailey
d44ce00af1 Updated remaining usages of LICENSE.txt 2023-03-03 12:01:08 -08:00
Derek Bailey
01834de25e FlatBuffers Version 23.3.3 (#7852) 2023-03-03 11:46:55 -08:00
Chuck Atkins
6f9ea7c23c Add Java reflection bindings to the distribution (#7851)
The distributions for C++ and Python include the generated reflection
bindings but are currently missing from the other language packages.
This will bring the Java package generated for releases closer to
feature parity with the C++ and Python release artifacts.
2023-03-03 11:14:07 -08:00
CodeMaster7000
de9791e0a9 Update pom.xml (#7849)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-03-02 23:47:54 -08:00
José Luis Millán
3e778aca4d TS/JS: Export object based classes on entry (#7822)
* TS/JS: Export object based classes on entry

Along with the non object ones, for consistency. This is a regression
introduced recently.

Before:
 `export { UpdateSettingsRequest } from './worker/update-settings-request.js';`

Now:
 `export { UpdateSettingsRequest, UpdateSettingsRequestT } from './worker/update-settings-request.js';`

* only export object based classes for structs

Enums are not elegible.

---------

Co-authored-by: Björn Harrtell <bjornharrtell@users.noreply.github.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-03-02 23:35:59 -08:00
Paulo Pinheiro
01f4138618 [Android][Kotlin] fixed build after decomission of jcenter and gradle update (#7840)
* [Android] fixed build after decomission of jcenter

JCenter[1] has been removed and now is failing android build. This
change updates the configuration to remove this and few other warnings.

1 - https://developer.android.com/studio/build/jcenter-migration

* [Kotlin] fix build for latest gradle version 8.0.1

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-03-02 23:27:06 -08:00
Chuck Atkins
b90cc35a10 Add a --java-package-prefix option to flatc (#7848)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-03-02 21:52:03 -08:00
Cedric Schmeits
79d6abb42e Added GENERATE_<TARGET> to flatbuffers_generate_headers (#7845)
The generation of the library interface supplied by this function only
works within the same directory as that the target was defined. By
adding a custom target named GENERATE_<TARGET> now also interface files
will be generated by making a target dependend on the generate target.

Example:
/CMakeLists.txt
  set(MY_INCL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/fbs/my_incl.fbs)
  flatbuffers_generate_headers(TARGET my_incl
                               SCHEMAS ${MY_INCL_SRC})

  add_subdirectory(app)

/app/CMakeLists.txt
  add_executable(app src/test.cpp)
  target_link_libraries(app my_incl)
  add_dependencies(app GENERATE_my_incl)

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-03-02 21:47:18 -08:00
tira-misu
d1e4daa178 [CS] Naming collision if field has same name as table and used as key (#7842)
* 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

* [TS] Fix reserved words as arguments (#6955)

* [TS] Fix generation of reserved words in object api (#7106)

* [TS] Fix generation of object api

* [TS] Fix MakeCamel -> ConvertCase

* [C#] Fix collision of field name and type name

* [TS] Add test for struct of struct of struct

* Update generated files

* Add missing files

* [TS] Fix query of null/undefined fields in object api

* Fix collision if field name is equal to table name and used as key in an array

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-03-02 21:42:27 -08:00
Khanh Nguyen
4a34cd70dc Add Code Generator for idl_gen_fbs to parse .proto files (#7832)
* Add code generator for proto files

* Update

* Add --proto to script

* Remove cmt

* Move proto parsing logic into else block to share same set up logic for code_generator

* Remove IsValidCodeGenerator
2023-03-02 10:01:44 -08:00
Henner Zeller
6a9cd4411f Editorconfig: als configure to trim whitespaces end EOL. (#7833)
Signed-off-by: Henner Zeller <hzeller@google.com>
2023-02-27 19:56:18 -08:00
Saman
f7a75173f1 Move defined part to idl.h (#7823) 2023-02-17 20:34:32 -08:00
Even Rouault
a56f9ec50e Only use absl headers if C++14 is available. (#7824)
If flatbuffers is built in C++11 mode, but there is a recent version of
absl which requires C++14, the build will fail.
Cf https://github.com/MapServer/MapServer/issues/6822 for the use case
that triggered this.
2023-02-15 10:56:16 -08:00
Derek Bailey
4c71f87619 fixed bad math for --annotate-sparse-vectors 2023-02-06 22:08:09 -08:00
chrismue
6af83a7d05 Sample adjusted for Python3 (#7819)
Co-authored-by: chrismue <chrismue.gitlab@gmail.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-02-06 21:47:39 -08:00
Derek Bailey
535ead8d8c [Annotated Buffers] Improve efficiency (#7820)
* AnnotatedBinaryTextGen switch to ofstream instead of building giant string

* Add --annotate-sparse-vectors to reduce AFB size
2023-02-06 21:42:44 -08:00
Björn Harrtell
85aee1f5c3 Simplify and fix TypeScript compilation output (#7815)
* Simplify and fix TypeScript compilation output

* Revert deps upgrade
2023-02-06 13:10:20 -08:00
Derek Bailey
f3a3f45159 use switch statements for BASE_TYPE_ lookups (#7813) 2023-02-05 12:29:09 -08:00
Derek Bailey
02d7859f8b explicitly declare enum values (#7811) 2023-02-03 15:33:04 -08:00
Derek Bailey
5785784c8a proto_test.cpp don't warn about gaps 2023-02-02 15:57:55 -08:00
Derek Bailey
0fb5519585 Fixed vtable duplication for binary annotator (#7809) 2023-02-02 10:39:39 -08:00
Saman
f838017860 Parsing from proto should keep field ID. (fixes #7645) (#7655)
* Parsing from proto should keep field ID. (fixes #7645)

* Fix failed tests

* Fix windows warning

* Improve attribute generation in proto to fbs

* Check if id is used twice. fix Some clang-format problems

* Test if fake id can solve the test problem

* Validate proto file in proto -> fbs generation.

* Fix error messages

* Ignore id in union

* Add keep proto id for legacy and check gap flag have been added. Reserved id will be checked.

* Add needed flags

* unit tests

* fix fromat problem. fix comments and error messages.

* clear

* More unit tests

* Fix windows build

* Fix include problems

* Fake commit to invoke rebuild

* Fix buzel build

* Fix some issues

* Fix comments, fix return value and sort for android NDK

* Fix return type

* Break down big function

* Place todo

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-02-01 11:17:35 -08:00
Khanh Nguyen
08ebd202e2 Final refactor for bfsb_generator* and text generator (#7806)
* Refactor BfbsGenerator to use CodeGenerator interface

* Update

* Refactor bfbs generator

* Refactor bfbs generator for lua and nim. Remove old code that use Generator
interface.

* Update import

* Update CMakeLists

* Update BUILD file

* Update BUILD file for src

* Remove from Android CMakeLists and add error message

* Update

* Add generate root file function to Code Generator interface

* Update

* Update

* Minor format fix
2023-01-31 09:35:34 -08:00
Bernie Innocenti
a6f4194489 Fix std::span autodetection (#7805)
The current detection method fails on GCC 12.2 with -std=c++20 because
the __cpp_lib_span macro is undefined.

As per https://en.cppreference.com/w/cpp/utility/feature_test ,
__cpp_lib_span requires including either <version> or <span>.

Since both these headers were added in C++20, checking for C++20 is
sufficient (and simpler than using the library feature-test macro).

Signed-off-by: Bernie Innocenti <bernie@codewiz.org>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-30 21:59:17 -08:00
CodeMaster7000
7fb785fd89 Rename LICENSE.txt to LICENSE (#7808)
* Update PackageDebian.cmake

* Rename LICENSE.txt to LICENSE

* Update readme.md

---------

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-30 21:36:30 -08:00
Ilya Lavrenov
ca71fdfb9a Supported cmake 3.8 (#7801) 2023-01-29 23:00:57 -08:00
Khanh Nguyen
a105c26eca Refactor usage message (#7803)
* Update usage string formation

* Rework help message to use code generator interface

* update

* refactor
2023-01-28 13:17:36 -06:00
Khanh Nguyen
5b7a02d037 Code generator refactor bug fix (#7802)
* Swift should use swift generator

* Swift should use swift generator

Co-authored-by: Mo (Khanh) Nguyen <khhn@google.com>
2023-01-26 10:57:47 -08:00
Wen Sun
f5121615d9 Clean up extra white spaces (#7800)
* Clean up extra white spaces

* update

Co-authored-by: Wen Sun <sunwen@google.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-25 17:37:03 +00:00
Khanh Nguyen
34c821f4ad Refactor languages to use CodeGenerator interface. (#7797)
* Refactor to use CodeGenerator interface.

- Move code to its own header file to be included in flatc_main.cpp
- Refactor code to use CodeGenerator interface for all languages

* Format all files

* remove lua code generator since it doesn't support bfbs generator

* Update CMakeLists file with new idl_gen_*.cpp and idl_gen_*.h files

* Add idl_gen_swift header file

* Add idl_gen_swift header file and update bazel file

* Remove CodeGenerator interface for idl_gen_text.*. Remove comments and extern declaration

* Reorder header and implementation files in CMakeLists.txt

* Add idl_gen_* header files to implementation files

* Update CMakeLists and remove unused import

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-25 09:05:48 -08:00
Wen Sun
802a3a056a [C++] Enable using struct and array of struct as key (#7741)
* add unit tests for support struct as key

* make changes to parser and add helper function to generate comparator for struct

* implement

* add more unit tests

* format

* just a test

* test done

* rerun generator

* restore build file

* address comment

* format

* rebase

* rebase

* add more unit tests

* rerun generator

* address some comments

* address comment

* update

* format

* address comment

Co-authored-by: Wen Sun <sunwen@google.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-24 16:37:13 -08:00
Derek Bailey
ee848a02e1 FlatBuffers Version 23.1.21 (#7796) 2023-01-21 12:46:57 -08:00
Björn Harrtell
ef76b5ece4 [TS/JS] Entry point per namespace and reworked 1.x compatible single file build (#7510)
* [TS/JS] Entry point per namespace

* Fix handling of outputpath and array_test

* Attempt to fix generate_code

* Fix cwd for ts in generate_code

* Attempt to fixup bazel and some docs

* Add --ts-flat-files to bazel build to get bundle

* Move to DEFAULT_FLATC_TS_ARGS

* Attempt to add esbuild

* Attempt to use npm instead

* Remove futile attempt to add esbuild

* Attempt to as bazel esbuild

* Shuffle

* Upgrade bazel deps

* Revert failed attempts to get bazel working

* Ignore flatc tests for now

* Add esbuild dependency

* `package.json` Include esbuild

* `WORKSPACE` Add fetching esbuild binary

* Update WORKSPACE

* Unfreeze Lockfile

* Update WORKSPACE

* Update BUILD.bazel

* Rework to suggest instead of running external bundler

* Add esbuild generation to test script

* Prelim bundle test

* Run test JavaScriptTest from flatbuffers 1.x

* Deps upgrade

* Clang format fix

* Revert bazel changes

* Fix newline

* Generate with type declarations

* Handle "empty" root namespace

* Adjust tests for typescript_keywords.ts

* Separate test procedure for old node resolution module output

* Fix rel path for root level re-exports

* Bazel support for esbuild-based flatc

Unfortunately, we lose typing information because the new esbuild method
of generating single files does not generate type information.

The method used here is a bit hack-ish because it relies on parsing the
console output of flatc to figure out what to do.

* Try to fix bazel build for when node isn't present on host

* Auto formatting fixes

* Fix missing generated code

Co-authored-by: Derek Bailey <derekbailey@google.com>
Co-authored-by: James Kuszmaul <jabukuszmaul+collab@gmail.com>
2023-01-21 12:22:22 -08:00
Michael Le
1703662285 Flatbuffers Version 23.1.20 (#7794)
* Flatbuffers Version 23.1.20

* Fix warnings

* Fix warnings
2023-01-21 12:03:17 -08:00
liu
991b39edbe Use CMAKE_CURRENT_SOURCE_DIR in benchmark cpp path (#7781)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-19 07:48:09 +00:00
Michael Le
81799203f1 Remove go.mod to resolve ambiguous import issue (#7783) 2023-01-18 23:40:50 -08:00
Saman
62e4d2e5b2 Fix binary output different in different platform (#7718)
* Fix binary output different in different platform, due to the nan serialization

* Add check generated code on windows ci

* Remove resdundant script

* Fix eof, and check script

* Minor bug in gen code script

* Fix windows script, remove redundant scripts

* Undelete redundante codes

* Fix github action

* Ignore eof generate grpc

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-10 12:04:25 -08:00
Ben Beasley
40758674b1 Fix some identity/equality confusion in Python tests (#7768)
Comparing short strings, small integers, and Booleans by identity
(memory address) can work due to optimizations in the Python
interpreter, but it is neither formally correct nor reliable. Use
equality comparisons instead.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-10 19:36:39 +00:00
Ben Beasley
4e75867bd2 Stop using deprecated imp package in Python tests (#7769)
It is deprecated in favour of importlib and slated for removal in Python
3.12. Since the return value of imp.find_module('numpy') is unused, the
only effect of calling this function is to raise an ImportError when
numpy is not available; importing numpy directly is already sufficient
to do this.

The imp package is still used in python/flatbuffers/compat.py, but only
on Python 2, where it is not deprecated and will not be removed.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-10 11:30:30 -08:00
José Luis Millán
b17d59b18c [TS]: builder, Fix requiredField(). Verity that the field is present in the vtable (#7739) (#7752)
* [TS]: Fix vtable creation for consecutive required fileds (#7739)

* handle feedback

* comment the schema

* comment change in builder.ts

* [TS]: builder, Fix requiredField()

Verifty that the field is present in the vtable.

* restore monsterdata binary file

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-10 10:43:17 -08:00
Ben Beasley
b23493a7d2 Fix Python host-endianness dependencies (#7773)
* In Python tests, use host-endian-independent dtypes

* Fix host endianness dependence in Python flexbuffers

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-10 10:20:08 -08:00
Anton Bobukh
b50b6be60a [Kotlin] Control the generation of reflection with --reflect-names (#7775)
* [Kotlin] Control the generation of reflection with --reflect-names.
Tested:
```
$ cmake -G "Unix Makefiles" && make && ./tests/flatc/main.py
...
KotlinTests.EnumValAttributes
 [PASSED]
KotlinTests.EnumValAttributes_ReflectNames
 [PASSED]
KotlinTests: 2 of 2 passsed
...

35 of 35 tests passed
```

* [Kotlin] Fix SampleBinary by converting Byte to UByte for ubyte fields.

* [Kotlin] Annotate all generated classes with kotlin.ExperimentalUnsignedTypes.
2023-01-10 10:03:39 -08:00
Michał Górny
7bf83f5ea0 Use full project version as SOVERSION for the shared library (#7777)
Since flatbuffers is using calendar versioning and does not provide
any ABI stability guarantees, use the complete version as SOVERSION
for the shared library rather than just the major component. This
prevents breaking reverse dependencies on incompatible upgrades.

Fixes #7759
2023-01-10 09:31:49 -08:00
Ben Beasley
ca6381bcc8 Fix a typo in a Python test name (#7774) 2023-01-09 10:32:50 -08:00
Derek Bailey
3b8644d32c Defined CodeGenerator Interface and implement C++ (#7771) 2023-01-08 15:01:33 -08:00
Derek Bailey
641fbe4658 Refactor FlatC to receive FlatCOptions (#7770)
* Refactor FlatC to receive `FlatCOptions`

* switch to c++11 unique_ptr
2023-01-08 13:29:00 -08:00
Saman
5638a6a900 Minor improvement (#7766) 2023-01-07 19:40:03 -08:00
Chris
c2668fc0e2 Add ts-no-import-ext flag (#7748)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-07 13:42:28 -08:00
Stefan F
b5802b57f2 Fix [C#] Object API - Invalid Property Name used in UnPackTo for unio… (#7751)
* Fix [C#] Object API - Invalid Property Name used in UnPackTo for union fieldhttps://github.com/google/flatbuffers/issues/7750, also fixes invalid Code generated in WriteJson for Unions named Value.

* Test added: new schema union_value_collision.fbs with a Union named Value and a union field named value. The generated C# code now compiles when NetTest.bat. The Code generated with an older flatc.exe didn't compile because of a mismatch of the property name (Value vs. Value_).

* branch was not up-to-date with master

* BASE_OPTS + CPP_OPTS removed and union_value_collision_generated.h deleted

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-07 12:37:22 -08:00
Derek Bailey
06f2a3dce9 Increase float to string precision to 17 2023-01-07 12:21:25 -08:00
Derek Bailey
75af533e95 emit global scoped ::flatbuffers in c++ (#7764) 2023-01-07 12:17:07 -08:00
Derek Bailey
c95cf661af Annotated Binaries emit field names instead of type names (#7763) 2023-01-07 12:01:00 -08:00
jalitriver
920f3827a0 [C++] Add Command-Line Flag to Suppress MIN and MAX Enums (#7705)
Add the --no-minmax-values flag to prevent flatc from generating C++
enums with MIN and MAX enumerated values that otherwise would be set
to the inclusive lower and upper bound respectively of the enum.

This command-line flag is needed to avoid collisions when an enum that
is being ported to FlatBuffers already has a MIN or MAX enumerated
value.

It is also needed to work around a long-standing problem with
magic_enum that causes magic_enum to not see enumerated values that
are not unique.  For example, if FlatBuffers sets MIN = FOO and MAX =
BAR, MIN and FOO share the same underlying value so they are not
unique.  The same is true of MAX and BAR.  This prevents magic_enum
from converting FOO and BAR to and from strings as well as causing
magic_enum to return a count of enumerated values that is two fewer
than it should be.

Co-authored-by: Paul Serice <paul@serice.net>
2023-01-07 10:33:11 -08:00
Max Burke
81724e5b20 Ensure that empty modules can build in TypeScript isolatedModules mode (#7726) 2023-01-06 16:42:26 -08:00
mustiikhalil
4d6a7aa8b7 Removes Dead code & regenerate code (#7744)
Formats the swift project

Update Sample files

Update docc documentation

Updates swift docs in the website

Updates code for Wasm
2023-01-06 16:40:40 -08:00
Florian Wagner
e61b00359b [Kotlin] Improve field nullability based on (required) (#7658)
* [Kotlin] Only generate nullable return types if the field is not required

* [Kotlin] Fix generated code formatting according to kotlin style guide

Co-authored-by: Derek Bailey <derekbailey@google.com>
Co-authored-by: Paulo Pinheiro <paulovictor.pinheiro@gmail.com>
2023-01-06 04:16:31 +00:00
Saman
74b5195089 Fix operator==() generated for field of fixed sized array (#7749)
* Fix operator==() generated for field of fixed sized array

* Compare address

* noexcept

* Grammer

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-05 20:11:11 -08:00
Anton Bobukh
07d9485146 Expand wildcard imports in the generated Kotlin files. (#7757)
Tested:

```
$ cmake -G "Unix Makefiles" && make && ./flattests
...
[ 99%] Linking CXX executable flatsamplebinary
[100%] Built target flatsamplebinary
ALL TESTS PASSED
```

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-05 14:34:44 -08:00
Derek Bailey
82da3da3f6 Update Readme.md for versioning
Updated the front readme doc about the non-semver versioning so that the rationale is more apparent to users.
2023-01-05 14:24:56 -08:00
Paulo Pinheiro
a809a2d3f7 Add pointer reference to sibling union field on FieldDef (#7755)
To make it simple to map between a union field and its union type
field we are adding a pointer to FieldDef to point to each other. For
all other types the pointer will be nullptr.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-05 14:21:23 -08:00
Derek Bailey
af9ceabeef FlatBuffers Version 23.1.4 (#7758) 2023-01-04 15:22:46 -08:00
Michael Le
3b2eb77595 Fix go.mod name (#7756) 2023-01-04 09:27:44 -08:00
Michael Le
6420fa5c88 [Go]Add go.mod (#7720)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-03 20:56:11 -08:00
Robin Giese
01589630ba Fix "'flatbuffers::FieldDef* field' shadows a parameter" (#7740) 2023-01-03 20:00:54 -08:00
RishabhDeep Singh
e0d68bdda2 Add link to building guide (#7733) 2022-12-22 14:06:57 -08:00
James Kuszmaul
e43a80c322 [TS] Fix getFullyQualifiedName codegen for typescript (#7730)
#7451 caused getFullyQualifiedName to return a name with underscores,
not periods. Because the fully qualified name is a property of
FlatBuffers, not the language being codegen'd for, it should use
periods. Fixes #7564.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-12-22 20:59:40 +00:00
RishabhDeep Singh
449d5649d6 Fixed test cases (#7732)
* Fix Cannot find symbol and test case

* Add generated tests

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-12-22 20:51:39 +00:00
Michael Le
96d438df47 Perform nil check on string fields when packing (#7719)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-12-22 20:28:00 +00:00
engedy
4e396d47bc Add CI step to build with -DFLATBUFFERS_NO_FILE_TESTS. (#7729)
* Add CI step to build with -DFLATBUFFERS_NO_FILE_TESTS

* Fix cmake syntax

* Further fix cmake argumetns

* Add workaround for unused-parameter.

* Remove build matrix

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-12-22 08:48:48 -08:00
engedy
b47ba1d5ff Add include guards around DoNotRequireEofTest (#7728)
Guard DoNotRequireEofTest against -Wunused-function on platforms without file tests.
2022-12-21 14:59:34 -08:00
Casper
a078130c87 Fix Rust codegen escaping field in tables. (#7659)
* Fix Rust codegen escaping  field in tables.

* other gencode

* gencode

* removed a debug print

* regen code

Co-authored-by: Casper Neo <cneo@google.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-12-15 06:04:57 +00:00
Saman
9ed76559df Add clang-tidy, fix some bugpron problems. (#7708)
* Add clang-tidy, fix some bugpron problems.

* Fix more issues

* Fix some more issues :))

* Minimal pr to just add clang-tidy

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-12-14 21:58:55 -08:00
mogemimi
9927747d4e [C++] Fix clang -Wnewline-eof warning (#7711)
* Fix clang -Wnewline-eof warning

* Enable -Wnewline-eof warning

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-12-14 21:35:54 -08:00
Wen Sun
52d1b77941 Add CI job to build linux and run unit test on s390x (#7707)
* create job to build linux and run unit test on s390x

* update

* update

* update

* update

* update

* print out machine type

* create regression test to build a big endian arch and run unit tests daily

* rename and schedule run on pr merged and on request

* udpate

Co-authored-by: Wen Sun <sunwen@google.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-12-14 14:56:31 -08:00
Jared Junyoung Lim
40aa964057 Add Ref.AsStringBytes to flatbuffers.flexbuffers Python API (#7713)
* Add Ref.AsStringBytes to flatbuffers.flexbuffers Python API

* Append Bytes to AsStringBytes return value

Co-authored-by: Jared Junyoung Lim <jaredlim@google.com>
2022-12-14 14:42:56 -08:00
Michael Le
e1a2f688e0 [Go] Fix bug where bytes wasn't being imported when using --gen-onefile flag (#7706)
* Fix bug one file import bug

* Create reset import function and add braces
2022-12-12 23:06:48 -08:00
Saman
c0797b22ae fix clang format plus implicit cast error. (#7704) 2022-12-12 21:22:24 -08:00
Maxim Zaks
97ee210826 Fix a bug where a floating point number was cast to int and the value was stored incorrectly because of low byte width. (#7703)
Reported in https://github.com/google/flatbuffers/issues/7690
2022-12-12 21:20:26 -08:00
Max Burke
3be296ec8a [Rust] Restore public visibility of previously-public fields (#7700)
* Restore public visibility of previously-public fields

* code review feedback
2022-12-08 18:20:14 -05:00
Derek Bailey
acf39ff056 FlatBuffers Version 22.12.06 (#7702) 2022-12-06 22:54:49 -08:00
Derek Bailey
0e79e56427 inline initialize byte_width 2022-12-06 22:18:11 -08:00
郭浩伟
aadc4cb8be fix: byte_width_ = 1U << static_cast<BitWidth>(packed_type & 3) implicit conversion loses integer precision: 'unsigned int' to 'uint8_t' (aka 'unsigned char') [-Werror,-Wimplicit-int-conversion] (#7697)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-12-06 21:19:54 -08:00
Wen Sun
b5ebd3fd78 [C++] Update to address comparator failure in big endian (#7681)
* update unit test and generated file to test is extra endianswap can help resolve issue

* remove EndianScalar wrapper from Get method

* remove endianscalar wrapper

* update

* update

* use Array instead

* clang format

* address error

* clang

* update

* manually generate

* Move Nim to completed language

* Add swift link

* address comments

* update unit test

* address comment

* address comment

* regenerate file

* use auto instead of size_t

* use uint32_t instead

* update

* format

* delete extra whitespace

Co-authored-by: Wen Sun <sunwen@google.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-12-06 14:02:16 -08:00
Michael Mickelson
11394575bc Fix "Download Doxygen" URL (#7699) 2022-12-06 14:01:12 -08:00
James Kuszmaul
5b7b36e8be Upgrade rules_go for Bazel 7.0 support (#7691)
Fixes: #7664 (hopefully)

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-12-05 16:56:02 -08:00
RishabhDeep Singh
c0230d839b Refactor src/idl_gen_cpp.cpp (#7693)
* Refactor for loops and simplify code

* Refactor for loops and simplify code

* Fix for loop and reformat

* reformat code
2022-12-06 00:43:38 +00:00
RishabhDeep Singh
a8d49f2972 Add LICENSE.txt to python (#7692)
* Add LICENSE.txt to python

* Remove LICENSE.txt from python path and used the root LICENSE.txt file
2022-12-05 16:37:21 -08:00
Derek Bailey
416c6020eb Add swift link 2022-12-02 20:52:20 -08:00
Derek Bailey
6d95867a8f Move Nim to completed language 2022-12-02 20:49:03 -08:00
Derek Bailey
2eaf790638 Fix confrom failure for nullptr dereference. (#7688) 2022-12-01 20:21:48 -08:00
Derek Bailey
3b2ced0131 Update missing C# namespace to Google.FlatBuffers 2022-12-01 20:04:49 -08:00
Michael Le
00af4e23b3 Remove --gen-name-strings flag from cmake command for generating union_vector_generated.h (#7684)
* Sync make outputs with master

* Remove --gen-name-string flag from CMAKE
2022-11-30 20:57:06 -08:00
Sergei Trofimovich
7e00b754f0 tests/reflection_test.h: add missing <stdint.h> include (#7680)
Without the change build fails on weekly `gcc-13` snapshots as:

    In file included from /build/flatbuffers/tests/reflection_test.cpp:1:
    tests/reflection_test.h:9:57: error: 'uint8_t' has not been declared
        9 | void ReflectionTest(const std::string& tests_data_path, uint8_t *flatbuf, size_t length);
          |                                                         ^~~~~~~
2022-11-30 18:47:10 -08:00
Louis Laugesen
cf89d1e756 Fix PHP byte validation and reenable builds (#7670)
* Fix PHP byte validation and reenable builds

* Use checkout@v3

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-11-29 08:12:28 -08:00
sssooonnnggg
ad6054c600 chore: emit more reasonable error message when using incomplete type in struct (#7678)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-11-29 04:59:53 +00:00
Michael Le
c3a01c7228 Use FinshedBytes() in go-echo example instead of manually encoding offset (#7660)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-11-29 02:29:48 +00:00
Saman
533f75d91b Fix java import wild card (#7672)
* Fix java import wild card

* fix java include

* Fix some import problems

* clang-format

* Sort imports

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-11-28 17:27:55 -08:00
Derek Bailey
fcab80f1bb build.yml: MacOs Build Inplace (#7677)
* `build.yml`: MacOs Build Inplace

* Update build.yml
2022-11-28 16:38:56 -08:00
Derek Bailey
5d2d0b92b1 build.yml Update dependencies (#7674)
* `build.yml` Update dependencies

* Update build.yml

* Update build.yml

* `build.yml`: Use macos-11

* Update build.yml
2022-11-28 15:34:32 -08:00
Derek Bailey
ae6662374d add buildkite badge 2022-11-23 13:11:56 -08:00
Casper
7b6c9f4a3c Rurel (#7663)
* Update release script to update Rust version (it still needs to be published after)

* Also update rust while I'm at it

Co-authored-by: Casper Neo <cneo@google.com>
2022-11-23 12:03:54 -08:00
Derek Bailey
5a42b2c76c Specify min android SDK version of 14 2022-11-23 11:54:36 -08:00
Derek Bailey
8f625561d0 FlatBuffers Version 22.11.23 (#7662) 2022-11-23 11:32:19 -08:00
Derek Bailey
9d2c04d629 FlatBuffers Version 22.11.22 2022-11-22 14:40:01 -08:00
Michael Le
e000458bb1 Add --go-module-name flag to support generating Go module compatible code (#7651)
* Add --go-module-name flag to support generating code for go modules

* Rename echo example folder

* Grammar

* Update readme for go-echo example

* Update readme for go-echo example

* Re-enable go modules after test is done
2022-11-22 14:28:01 -08:00
Michael Le
60975d6f7e Add key lookup support for tables in Go (#7644)
* Add support for key lookup for tables in Go

* Run clang format

* Run go fmt on tests

* Remove TODO in tests

* Update LookupByKey API

* Update LookupByKey API

* Don't use resolvePointer in expectEq

* Use generated getters instead of reading values directly from buffer

* Fix typo

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-11-22 14:08:19 -08:00
Saman
1cba8b2b49 Fix go generator undefined Package name, also throwing exception (#7632)
* Fix go generator undefined Package, also throw exception in specific examples.

* Add test for go generator import problem

* Add new version of generated go file. Fix conflict.

* Add executable permission to generate_code.py script.

* Improve test quality, remove unwanted generated files, better naming

* Fix comments

* clang format

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-11-22 13:21:25 -08:00
TJKoury
eead6c6219 updated method call (#7642) 2022-11-22 13:01:32 -08:00
Alex Ames
bb9b9dad5f Fixed the BytesConsumed function, which was pointing slightly ahead. (#7657)
The BytesConsumed function uses the `cursor_` to determine how many
bytes have been consumed by the parser, in case the user of the Parser
object wants to step over the parsed flatbuffer that is embedded in some
larger string. However, the `cursor_` is always one token ahead, so that
it can determine how to consume it. It points at the token that is about
to be consumed, which is ahead of the last byte consumed.

For example, if you had a string containing these two json objects and
parsed them...

    "{\"key\":\"value\"},{\"key\":\"value\"}"

...then the `cursor_` would be pointing at the comma between the two
tables. If you were to hold a pointer to the beginning of the string and
add `BytesConsumed()` to it like so:

    const char* json = // ...
    parser.ParseJson(json);
    json += parser.BytesConsumed();

then the pointer would skip over the comma, which is not the expected
behavior. It should only consume the table itself.

The solution is simple: Just hold onto a previous cursor location and
use that for the `BytesConsumed()` call. The previous cursor location
just needs to be set to the cursor_ location each time the cursor_ is
about to be updated. This will result in `BytesConsumed()` returning
the correct number of bytes without the off-by-one-token error.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-11-22 20:11:14 +00:00
tira-misu
ade9e19be0 [C#] Fix collision of member if union name is "Value" (#7648)
* 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

* [TS] Fix reserved words as arguments (#6955)

* [TS] Fix generation of reserved words in object api (#7106)

* [TS] Fix generation of object api

* [TS] Fix MakeCamel -> ConvertCase

* [C#] Fix collision of field name and type name

* [TS] Add test for struct of struct of struct

* Update generated files

* Add missing files

* [TS] Fix query of null/undefined fields in object api

* [C#] Fix collision of member if enum name is "Value"

* Fix due to style guide

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-11-22 20:00:13 +00:00
Wen Sun
eb1abb51ea Add support for using array of scalar as key field in Cpp (#7623)
* add support for using array of scalar as key field

* update cmakelist and test.cpp to include the tests

* update bazel rule

* address comments

* clang format

* delete comment

* delete comment

* address the rest of the commnets

* address comments

* update naming in test file

* format build file

* buildifier

* make keycomparelessthan call keycomparewithvalue

* update to use flatbuffer array instead of raw pointer

* clang

* format

* revert format

* revert format

* update

* run generate_code.py

* run code generator

* revert changes by generate_code.py

* fist run make flatc and then run generate_code.py

Co-authored-by: Wen Sun <sunwen@google.com>
2022-11-18 11:04:46 -08:00
Saman
1fa6091000 Fix schema to binary test, when build and run from all directories. specially when add to other projects. (#7650) 2022-11-17 20:24:48 -08:00
tira-misu
634c2ee7e3 Put documentation to bfbs if it is not empty (#7649)
* 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

* [TS] Fix reserved words as arguments (#6955)

* [TS] Fix generation of reserved words in object api (#7106)

* [TS] Fix generation of object api

* [TS] Fix MakeCamel -> ConvertCase

* [C#] Fix collision of field name and type name

* [TS] Add test for struct of struct of struct

* Update generated files

* Add missing files

* [TS] Fix query of null/undefined fields in object api

* Put documentation to bfbs if it is not empty

* Fix monster test bfbs reference files

* Fix generated monster test files

Why they are different when generating it with linux and windows executable?
2022-11-17 15:55:42 -08:00
Derek Bailey
6f895f54c2 Add _deps/ to gitignore 2022-11-13 12:00:07 -08:00
Gh0u1L5
41d6903294 [Go] Fix GenNativeUnionUnPack for imported union type. (#7579)
* Fix GenNativeUnionUnPack for imported union type.

* Update test results.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-11-13 11:52:02 -08:00
Saman
7b038e3277 Fix import problem in dart generated files. (fixes #7609). (#7621)
* Fix import problem in dart generated files. (fixes #7609).

* Fix naming.

* Fix minor changes in generated files.

* Add some tests. Fix minor problems.

* Fix minor format problem plus import alias issue.

* Minor fix in dart code generator, remove java from examples

* remove java and go generated files

* Fix dart tests.

* Fix spell problem.

* Remove excessive tests :))

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-11-13 19:21:57 +00:00
mr-swifter
74756e5d1b [swift] fix broken swift test build (#7633) (#7634)
* [swift] fix broken swift test build (#7633)

* [swift] fix unused variable (#7633)

* [swift] update generated code (#7633)

* [swift] add binary & json test for nan, inf, -inf for swift (#7633)

* [swift] use just '.infinity' instead of '+.infinity' (#7633)

* [swift] remove commented code (#7633)

Co-authored-by: Derek Bailey <derekbailey@google.com>
Co-authored-by: mustiikhalil <26250654+mustiikhalil@users.noreply.github.com>
2022-11-11 18:36:47 +01:00
RishabhDeep Singh
879622fc57 Fixes #7345 to add the option to minify enums (#7566)
* Added cpp minified enums

* Update generated files

* remove initializer and fix comma

* Fix .gitignore

* Fix comma

* Add tests for cpp minify enums
2022-11-11 04:47:28 +00:00
M. Şamil Ateşoğlu
83e7a98f69 [C++] Minireflect: Add option to indent when converting table to string (#7602)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-11-11 02:57:29 +00:00
Alex-Ratcliffe
f20b0a45b3 Add comparison operator to python objects under --gen-compare option (#7610)
* Add comparison operator to python code generator

* Missing semi-colon

* Regenerate test examples

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-11-11 02:47:53 +00:00
Rudi Heitbaum
207708efef [CMake]: only warn when the working directory in a git worktree (#7562)
Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com>

Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-11-11 02:21:38 +00:00
laurentsimon
225578a8b3 Temporary fix for SLSA generators (#7636)
* Temporary fix for SLSA generators

Sigstore made a breaking change as part of their recent GA announcement. We need a temporary fix to avoid builder failure (see slsa-framework/slsa-github-generator#1163)

/cc @asraa

* Update build.yml
2022-11-10 20:09:01 -06:00
mustiikhalil
459e8acc37 Uses swift build command directly in the CI (#7635) 2022-11-10 14:16:42 -08:00
James Kuszmaul
8aa8b9139e Fix handling of +/-inf defaults in TS/rust/go/dart codegen (#7588)
+/-inf were not being handled, and so invalid typescript was being
generated when a float/double had an infinite default value. NaN was
being handled correctly.

Co-authored-by: Derek Bailey <derekbailey@google.com>
Co-authored-by: Casper <casperneo@uchicago.edu>
2022-11-08 10:59:46 -08:00
Michael Le
001adf782d Add support for parsing proto map fields (#7613)
* Add support for proto 3 map to fbs gen

* Run clang-format

* Update proto golden test

* Rename variables

* Remove iostream

* Remove iostream

* Run clang format

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-11-08 10:51:24 -08:00
Ben Beasley
dbc58ab77c Fix help output for --gen-includes (#7611)
Fixes the --help output documenting the deprecated --gen-includes
option, in which the option name contained a typo (--gen-inclues).
2022-11-08 18:16:17 +00:00
Ben Beasley
2facfeec7e Fix missing spaces in flatc help text (#7612)
* Fix error in --json-nested-bytes help text

Correct “bytesin” to “bytes in”

* Fix missing space in --no-leak-private-annotation help text
2022-11-08 17:59:48 +00:00
刘帅
4de2814c7b Fix: arduino platform build (#7625) 2022-11-08 09:53:53 -08:00
Valeriy Van
37b1acdaff Fix current official name of macOS (#7627)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-11-08 09:49:27 -08:00
Even Rouault
a22434e2a1 Add missing #include <algorithm> for std::min/std::max uses, and #include <limits> for std::numeric_limits<> (#7624) 2022-11-08 09:36:35 -08:00
Casper
214cc94681 Bump Rust version to 22.10.26 before publication (#7622) 2022-11-03 16:24:00 +00:00
Alex Ames
a4ff275d9b Added option to not requires an EoF token when parsing JSON (#7620)
Previously when parsing a JSON representation of a Flatbuffer, the
parser required that the input string contain one and only one root
table. This change adds a flag that removes that requirement, so that
if a Flatbuffer table is embedded in some larger string the parser will
simply stop parsing once it reaches the end of the root table, and does
not validate that it has reached the end of the string.

This change also adds a BytesConsumed function, which returns the number
of bytes the parser consumed. This is useful if the table embedded in
some larger string that is being parsed, and that outer parser needs to
know how many bytes the table was so that it can step over it.
2022-11-03 11:57:46 -04:00
inaryart
15f32c6907 python: object generation prefix and suffix (#7565)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-10-29 00:37:27 +00:00
Michael Le
051afd8825 Add CreateSharedString to python builder (#7608)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-10-29 00:28:35 +00:00
Alejandro Ramallo
728c033ad6 Add check for presence of realpath to CMakeLists.txt to support more platforms (#7603)
* add automatic check for realpath in CMakeLists

* added win32 check

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-10-29 00:23:36 +00:00
Michael Le
4c514483d8 Update DartTest.sh golden files (#7606) 2022-10-29 00:15:14 +00:00
Bulent Vural
c2d9c20803 [TS] Add support for fixed length arrays on Typescript (#5864) (#7021) (#7581)
* [TS] Add support for fixed length arrays on Typescript (#5864) (#7021)

    * Typescript / Javascript don't have fixed arrays but it is important to support these languages for compatibility.

    * Generated TS code checks the length of the given array and do truncating / padding to conform to the schema.

    * Supports the both standard API and Object Based API.

    * Added a test.

    Co-authored-by: Mehmet Baker <mehmet.baker@zerodensity.tv>
    Signed-off-by: Bulent Vural <bulent.vural@zerodensity.tv>

Signed-off-by: Bülent Vural <bulent.vural@zerodensity.tv>

* Formatting & readability fixes on idl_gen_ts.cpp

Signed-off-by: Bülent Vural <bulent.vural@zerodensity.tv>

* Added array_test_complex.bfbs

Signed-off-by: Bülent Vural <bulent.vural@zerodensity.tv>

* TS arrays_test_complex: Remove bfbs and use  fbs directly

Signed-off-by: Bülent Vural <bulent.vural@zerodensity.tv>

Signed-off-by: Bülent Vural <bulent.vural@zerodensity.tv>
2022-10-28 17:00:24 -07:00
Derek Bailey
e34ae4c6b6 build.yml: Fix missing 'v' in version 2022-10-27 16:14:26 -07:00
Derek Bailey
e54536127c build.yml Update to Kotlin Wrapper 1.0.5 2022-10-27 13:55:41 -07:00
Derek Bailey
49d9f941c0 release.yml Use env var for passphrase 2022-10-26 22:50:05 -07:00
Derek Bailey
cefc21c1f9 release.yml Add GPG key for Maven 2022-10-26 22:37:11 -07:00
Derek Bailey
3e64fa7246 release.yml: Add Maven Steps 2022-10-26 22:27:20 -07:00
Derek Bailey
b15f3c57ea release_yml Use new dotnet version 2022-10-26 17:15:51 -07:00
Derek Bailey
ff802c6802 release.yml Use NuGet Key directly 2022-10-26 17:05:08 -07:00
Derek Bailey
b401957d5f release.yml Changed Push to follow examples 2022-10-26 17:01:11 -07:00
Derek Bailey
8c8151f8f9 release.yml Fix nuget push command 2022-10-26 16:41:17 -07:00
Derek Bailey
ebb7c203d3 release.yml Add Nuget support 2022-10-26 16:36:35 -07:00
Derek Bailey
203241ed32 FlatBuffers Version 22.10.26 (#7607) 2022-10-26 16:02:38 -07:00
Derek Bailey
ac485609c4 setup.py: Define version directly
Define the version directly instead of loading from an environment variable and writing to a file.
2022-10-26 15:31:02 -07:00
Derek Bailey
de5b85aa66 release.yml: Switch to python directory 2022-10-26 15:29:02 -07:00
Derek Bailey
de3df2d88b release.yml: Add publishing to PyPi 2022-10-26 15:17:21 -07:00
Joshua Smith
043a24f2e4 [Python] Fixed the issue with nested unions relying on InitFromBuf. (#7576)
* feat: Fixed the issue with nested unions relying on InitFromBuf.
Problem: Issue #7569
Nested Unions were broken with the introduction of parsing buffers with an initial encoding offset.

Fix:
Revert the InitFromBuf method to the previous version and introduction of InitFromPackedBuf that allows
users to read types from packed buffers applying the offset automatically.

Test:
Added in TestNestedUnionTables to test the encoding and decoding ability using a nested table with a
union field.

* fix: Uncommented generate code command
2022-10-26 14:56:52 -07:00
Derek Bailey
5a48b0d7d6 release.yml: Typo 2022-10-26 00:40:43 -07:00
Derek Bailey
ce307556fb release.yml: Remove npm ci
This command [was suggested](https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages#publishing-packages-to-the-npm-registry) in the github docs, but not in our release steps.
2022-10-26 00:35:11 -07:00
Derek Bailey
cb616e27cb Create release.yml (#7605)
Create a new `release.yml` for defining automatic publishing to package managers on releases.

Adds the NPM publishing steps as it is the most straightforward.
2022-10-26 00:30:16 -07:00
Derek Bailey
a54ca1e759 FlatBuffers Version 22.10.25 (#7604) 2022-10-26 00:03:49 -07:00
ArnaudD-FR
5b3fadcc16 [vector] Allow to iterate with mutables (#7586)
Co-authored-by: ArnaudD-FR <arnaud.desmier@gmail.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-10-21 12:10:18 -07:00
Dan Lapid
872a497464 [Nim] Bfbs Nim Generator (#7534)
* Bfbs Nim Generator

* Remove commented out tests

* add missing line to idl.h

* Commit python reflection changes

* Commit python reflection changes and move tests

* Remove default string addition

* Move tests to python file

* Fix element size check when element is table

* remove whitespace changes

* add element_type docs and commit further to namer and remove kkeep

* Bfbs Nim Generator

* Remove commented out tests

* add missing line to idl.h

* Commit python reflection changes

* Commit python reflection changes and move tests

* Remove default string addition

* Move tests to python file

* Fix element size check when element is table

* remove whitespace changes

* add element_type docs and commit further to namer and remove kkeep

* remove unused variables

* added tests to ci

* added tests to ci

* fixes

* Added reflection type Field, Variable to namer

* Moved reflection namer impl to bfbsnamer

* Remove whitespace at end of line

* Added nim to generated code

* Revert whitespace removal

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-10-21 14:30:04 -04:00
Dominic Battre
e301702964 Make type conversions explicit. (#7595)
As Java does not support unsigned integer types, the value types
are "rounded up" (an uint32 is represented as a long) but persisted
correctly (an uint32 is persisted as 4 bytes).

This CL makes a cast operation explicit so that the compiler
does not throw warning messages.

Co-authored-by: Dominic Battre <battre@chromium.org>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-10-21 09:09:28 -07:00
Dominic Battre
f7b734438d Fix LongEnum definitions (#7596)
The MyGame/Example/LongEnum.java class did not compile because
Java expects an "L" suffix for literals of type long.

This CL fixes the code generation to include such a suffix.

Co-authored-by: Dominic Battre <battre@chromium.org>
2022-10-20 18:15:00 -07:00
Dan Lapid
5792623df4 Rust fix compilation for no_std targets #2 (#7553)
* Fix nightly no_std

* Fix nightly no_std
2022-10-19 09:14:41 -04:00
Casper
0edb275285 Update Rust version (#7574)
Co-authored-by: Casper Neo <cneo@google.com>
2022-10-18 20:37:12 +00:00
Dominic Battre
acc6a20d39 tests/test.cpp contains a couple of tests that are only executed (#7571)
on a subset of platforms. The test calls are guarded via #ifndef
FLATBUFFERS_NO_FILE_TEST.

Embedders of flatbuffers that rely on -Werror,-Wunused-function
compiler flags (like chromium) complain about the exsitence of these
tests in the anonymous namespace.

This CL guards the test definitions as well (not just the test
calls).

Co-authored-by: Dominic Battre <battre@chromium.org>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-10-18 12:37:06 -07:00
Casper
04cd037ba2 Fix #7580 by documenting union schema evolution rules (#7585)
Co-authored-by: Casper Neo <cneo@google.com>
2022-10-17 17:49:28 -04:00
Casper
e1c5db988a Turn on clippy for Rust and fix lints for non-generated code (#7575)
Co-authored-by: Casper Neo <cneo@google.com>
2022-10-10 21:26:35 -04:00
Piotr Dziwiński
b80142b901 Update documentation to mention enum value attributes (#7570) 2022-10-08 19:52:38 -04:00
Piotr Dziwiński
54418f371b Add support for metadata attributes for enum values (#7567) (#7568)
* Add support for metadata attributes for enum values (#7567)

* Fix path lookup in flatc test

* Try a fix for Windows paths

* Convert path to string to fix Windows error
2022-10-06 20:18:00 -04:00
Derek Bailey
c92e78a9f8 FlatBuffers Version 22.9.29 (#7557) 2022-09-29 22:12:07 -07:00
Björn Harrtell
d243b904cc [TS] Make strict compliant and improve typings (#7549)
* [TS] Make strict compliant and improve typings

* clang-format

* Code gen harmonize

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-09-29 15:03:35 -07:00
Raphael Taylor-Davies
374f8fb5fb Rust soundness fixes (#7518)
* Rust soundness fixes

* Second pass

* Make init_from_table unsafe

* Remove SafeSliceAccess

* Clippy

* Remove create_vector_of_strings

* More clippy

* Remove deprecated root type accessors

* More soundness fixes

* Fix EndianScalar for bool

* Add TriviallyTransmutable

* Add debug assertions

* Review comments

* Review feedback
2022-09-29 09:58:49 -04:00
mustiikhalil
dadbff5714 Moves swift package to root of repository so it can be used directly … (#7548)
* Moves swift package to root of repository so it can be used directly from the main repo

Fixing paths for swift directory

* Update swift readme
2022-09-27 14:32:05 -07:00
Derek Bailey
76ddae006f FlatBuffers Version 22.9.24 (#7547) 2022-09-27 11:55:25 -07:00
Mark Pauley
cfe157ec56 Emit internal enums when swift_implementation_only (#7545)
- Copy the same pattern as structs and tables
- Fixes google#7542
2022-09-24 20:15:39 +02:00
Joshua Smith
413115858c [Python] Python fixed size array (#7529)
* feat: Added support for fixed sized arrays to python

Problem:
We encountered that using fixed arrays from C++ to python that python would
not read those arrays correctly due to no size information being encoded in the byte
array itself.

Fix:
Encode the sizes within the generated python file during code generation.
Specfically we add GetArrayAsNumpy to the python version of table, which takes as input
the length of the vector. When generating the python message files we include this length
from the VectorType().fixed_length.

* fix: added digit support for camel case to snake case conversion

Problem:
When including a number in the message name we would encounter cases where SnakeCase would
not add the appropirate breaks. e.g. Int32Stamped -> int_32stamped rather than int_32_stamped.

Fix:
To fix this we can add the condition that we check if the current character is not lower and
not a digit, that we check if the previous character was a lower or digit. If it was a lower
or digit then we add the break.

* fix: Array support for structures

Problem:
The python generated code for handling non-struct and struct vectors
and arrays was inconsistent. The calls to populate the obj api was
creating incorrect code.

Solution:
To fix this the VectorOfStruct and VectorOfNonStruct was rewritten
to handle array cases and bring the two methods in line which each
other.

Testing:
PythonTesting.sh now correctly runs and generates the code for
array_test.fbs.
Minor modifications were done on the test to use the new index
accessor for struct arrays and the script correctly sources the
location of the python code.

* chore: clang format changes

* Added code generated by scripts/generate_code. Modified GetArrayOfNonStruct slightly
to allow for function overloading allowing the user to get a single element of an array
or the whole array.

* Added new_line parameter to OffsetPrefix to allow optional new lines to be added.
This allows us to use the GenIndents method that automatically adds new lines instead.

* Reupload of generated code from the scripts/generate_code.py

* Removed new line in GetVectorAsNumpy.

* Updated Array lengths to use Length methods where possible. Added fallthrough for GenTypePointer. Added digit check to CamelToSnake method. Added and modified tests for ToSnakeCase and CamelToSnake.

* Added range check on the getter methods for vector and array types. Renamed == as is for python
2022-09-22 11:08:09 -07:00
Yun Peng
88046190ee Upgrade grpc to 1.49.0 and make sure it builds (#7538)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-09-21 12:53:03 -07:00
Denis Blank
72aa85a759 [C++] Rare bad buffer content alignment if sizeof(T) != alignof(T) (#7520)
* [C++] Add a failing unit test for #7516 (Rare bad buffer content alignment if sizeof(T) != alignof(T))

* [C++] Fix final buffer alignment when using an array of structs
* A struct can have an arbitrary size and therefore sizeof(struct) == alignof(struct)
  does not hold anymore as for value primitives.
* This patch fixes this by introducing alignment parameters to various
  CreateVector*/StartVector calls.
* Closes #7516
2022-09-21 11:05:05 -07:00
Dorochi
bfceebb7fb Fix conform (#7532)
* Fix conform;
Make sure the command fails when tail fields are removed;

* Fix last commit according to dbaileychess' comment
2022-09-14 21:45:40 -07:00
Derek Bailey
bc44fad352 UnPackTo disable merge by default (#7527)
* UnPackTo disable merge by default

* avoid double free in test

* remove merge parameter

* remove shrink to fit
2022-09-13 22:00:01 -07:00
Björn Harrtell
4fca4dc60c [TS/JS] Move TS tests to dedicated folder and deps upgrade (#7508)
* Move TS tests to dedicated folder and deps upgrade

* Attempt to fix generate_code

* Fix dir on CI

* Add js extension

* Fix missing extension

* Harmonize with test gen

* Unexplained code gen change

* Restore yarn.lock

* Naive attempt to fix bazel stuff

* Pin @bazel/typescript to 5.2.0

* Attempt to fix bazel

* More tweak

* Upgrade deps

* Tweak?

* Fix path

* Fix test package

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-09-12 20:03:23 -07:00
dependabot[bot]
036032373b Bump junit from 4.13 to 4.13.1 in /java (#7526)
Bumps [junit](https://github.com/junit-team/junit4) from 4.13 to 4.13.1.
- [Release notes](https://github.com/junit-team/junit4/releases)
- [Changelog](https://github.com/junit-team/junit4/blob/main/doc/ReleaseNotes4.13.1.md)
- [Commits](https://github.com/junit-team/junit4/compare/r4.13...r4.13.1)

---
updated-dependencies:
- dependency-name: junit:junit
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-11 19:56:51 -07:00
Nick
89dfb43f3b Replace bash JavaTest.sh with mvn test (#7500)
* Start of mvn-ification of the test

* move to right locations

* Update the IO done in the test to read from resources / write to temp folders

* Add github workflow attempt to mvn test it instead of JavaTest.sh

* Pin the Kotlin benchmark's symlink for /java to the right location

* Inline equality assertions and format JavaTest.java

* fix android gradle source directory

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-09-11 17:46:46 -07:00
Derek Bailey
c49aff4b6f enabled cpp17 tests in CI (#7524) 2022-09-11 16:08:07 -07:00
Derek Bailey
56e60223c3 prevent force_align attribute on enums (#7523) 2022-09-10 13:41:58 -07:00
Derek Bailey
89b1f5aa1b remove travis config (#7522)
* remove travis config

* remove more travis and appveyor stuff

* remove appveyor specific things
2022-09-10 12:36:51 -07:00
Paulo Pinheiro
b901598233 [Java][Flexbuffers] Add API to add nullables into the buffer. (#7521)
Fix #7517
2022-09-10 09:13:01 -07:00
Derek Bailey
8cdc6a2885 Install BuildFlatBuffers.cmake (#7519) 2022-09-10 00:30:47 -07:00
mustiikhalil
a67e35aff9 Moves all of the swift test code into tests/swift (#7509)
Fixes failing tests by regenerating test cases
2022-09-09 22:35:42 -07:00
Derek Bailey
f124e41ae6 Updated Readme
Added links to runtime packages for variety of languages.
2022-09-03 08:05:36 -07:00
Paulo Pinheiro
4c954181cd [Java][FlexBuffers] throwing exception for untyped fixed vectors (#7507)
Untyped fixed vectors are not supported in FlexBuffers. There
was an assert to check for it, but on java, asserts are optional. This
change converts the assertion into a runtime exception.

Fixes #7358

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-09-01 22:04:18 -07:00
Paulo Pinheiro
7f7547737e [Android] Remove maven dependency of flatbuffers and use source folder (#7503) 2022-09-01 14:58:25 -07:00
mustiikhalil
a79d61ea85 Fixes issue with cocoapods failing to be published because of docc (#7505)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-09-01 11:44:13 -07:00
Chris Langhans
d465b39c3e [CMake]: fix breaking find_package change (#7499) (#7502)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-09-01 10:28:59 -07:00
Derek Bailey
c5a609dc20 [C#] Prepares for official Nuget release (#7496)
* Define nuget package

* C# Switch to Google.FlatBuffers namespace

* Add Source Link for nuget package

* Add Strong Name signing of Google.FlatBuffers
2022-09-01 10:17:34 -07:00
Ivan Zakharchanka
5634dc3d0d [ISSUE-6268] returns NaN insteadof nan (#7498)
* returns NaN insteadof nan

* clang-format-git
2022-08-31 16:22:17 -07:00
mustiikhalil
37e37b8cad Updates cocoapods version (#7497) 2022-08-31 10:20:11 -07:00
Derek Bailey
8fd4534fbe update android multidex setting (#7495) 2022-08-30 14:32:16 -07:00
Derek Bailey
d5427da52f Disable Android Build (#7494) 2022-08-29 22:16:04 -07:00
Derek Bailey
06c5c7ed0b FlatBuffers Version 2.0.8 (#7492) 2022-08-29 20:43:36 -07:00
Derek Bailey
b190ce11b0 Verifier Refinements (#7490) 2022-08-29 19:21:42 -07:00
Casper
bf5d23230a Namer applied to Typescript generator (#7488)
* Namer applied to Typescript generator

* fixes

* More fixes

Co-authored-by: Casper Neo <cneo@google.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-08-29 16:44:35 -07:00
Björn Harrtell
ce382d6dd3 [TS/JS] Add rollup and config to generate iife flatbuffers bundle (#7449)
* Add rollup and config to generate iife flatbuffers bundle

* Atempt to use yarn and add deps

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-08-29 16:37:43 -07:00
Casper
41d9add7ef C++: Add option to skip verifying nested flatbuffers (#7489)
* C++: Add option to skip verifying nested flatbuffers

Additionally, add an options struct to the verifier for those
who prefer designated initializers to default arguments. The former
constructor is defined in terms of the latter because in old c++,
having default values for members removes list initialization, making
defining constructors in the other way a lot more challenging to write.

* fixes

* fmt

* formatting, and remove an argument

* fix

Co-authored-by: Casper Neo <cneo@google.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-08-29 16:25:57 -07:00
sssooonnnggg
6a87427540 [C++] support native_inline attribute for vector of tables (#7479) 2022-08-29 12:48:10 -07:00
Derek Bailey
694add668b Refactor test.cpp (#7487)
* Add timing command to cmakelist

* Start to split test.cpp. Move flexbuffers tests

* Move monster related tests to own file

* Move parser related tests to own file

* Move json related tests to own file

* Move proto related tests to own file

* moved more functions to parser test

* moved more functions to parser test2

* move monster extra tests to monster test

* move evolution tests to own file

* move reflection tests to own file

* move util tests to own file

* rehomed various tests

* move optional scalars test to own file:

* rehome more tests

* move fuzz tests. Got rid of global test_data_path

* fixes for CI failures

* add bazel files
2022-08-28 16:54:58 -07:00
Derek Bailey
7edf8c9084 Update scorecard to 1.1.2 2022-08-26 14:40:36 -07:00
Derek Bailey
b86387442e Fix typos (#7483) 2022-08-26 14:35:21 -07:00
Derek Bailey
e2eb5ee670 Include <array> head in stl_emulation.h (#7480)
* Add C++ standard builds for windows CI

* Allow C++std to be specified in cmake

* Include <array> in stl_emulation

* Add linux std CI builds
2022-08-26 00:22:27 -07:00
Axel Sommerfeldt
994502b6dd Version number in file package.json updated to 2.0.7 (#7476)
Co-authored-by: Axel Sommerfeldt <axel.sommerfeldt@gmail.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-08-25 20:40:50 -07:00
sssooonnnggg
fa41e83679 [C++] Fixed crash when copying table with empty shared strings (#7477) 2022-08-25 16:50:17 -07:00
Derek Bailey
799cc8f7b9 Use type traits for specialization (#7475) 2022-08-24 12:16:44 -07:00
Derek Bailey
b7eb441470 Disable RTTI and rework use in idl_gen_ts.cpp (#7474) 2022-08-24 10:36:11 -07:00
Axel Sommerfeldt
8d01c5859c CMake project version detection made more robust (#7473)
This fixes two problems:
1. The project could be build when using own tags which does not follow the pattern v<major>.<minor>.<patch>.
2. The case "tag points to the commit" will be handled correctly by setting VERSION_COMMIT to 0.

This commit resolves https://github.com/google/flatbuffers/issues/7472

Co-authored-by: Axel Sommerfeldt <axel.sommerfeldt@gmail.com>
2022-08-24 09:28:52 -07:00
Derek Bailey
237e8b71fe Moved compiler warnings around (#7471) 2022-08-23 23:23:24 -07:00
Derek Bailey
eeb8fd60d5 Include builder.addOffset for vector of structs (#7470) 2022-08-23 23:17:35 -07:00
Derek Bailey
fef2ffc4d0 Use schema include name for keep-prefix (#7469) 2022-08-23 21:29:17 -07:00
Derek Bailey
8367664f15 Flatbuffers Version 2.0.7 (#7462) 2022-08-22 21:42:15 -07:00
Derek Bailey
d6f06c33f7 Reworked keep prefix (#7456)
* reworked keep prefix

* checking in missing schema

* fix flatc path for build scripts
2022-08-22 18:59:24 -07:00
Xùdōng Yáng
627e8bf364 update grpc version (#7457)
* update grpc version

this in turn updates the upb version, which fixes Flatbuffers' failure in Bazel CI: https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/2586#0182a995-a528-4e87-90a0-1604a5e9f7eb

* also update rules_go version

* the new rules_go actually needs a version

* grpc_extra_deps() also registers go toolchains

* make buildifier happy

* address review comments
2022-08-22 16:53:28 -07:00
Derek Bailey
883c42b7db disabling unpackto optimization (#7459) 2022-08-18 20:51:18 -07:00
Derek Bailey
7aae0af305 Remove old GRPC bash script and convert to python3 (#7454)
* Remove old GRPC bash script and convert to python3

* updated checking gRPC script to python3
2022-08-16 23:44:50 -07:00
Paul Harris
b057aa917f Grouped anonymous namespaces together, (#7455)
A follow-up PR to #7212
2022-08-16 22:45:21 -07:00
Derek Bailey
f1b26ff7fb Change to GetTypeName (#7453) 2022-08-16 20:32:53 -07:00
laurentsimon
9610a666b1 Generate SLSA signatures for Released zip files (#7450)
* update

* update

* update

* update

* update

* update

* update
2022-08-16 16:30:37 -07:00
Paulo Pinheiro
1e0f75a647 [WIP] speedup (#7452) 2022-08-16 13:47:08 -07:00
Derek Bailey
82b75407a3 Wrap types in namespace for --ts-flat-files and --gen-all (#7451)
* Wrap types in namespace for --ts-flat-files and --gen-all

* Fixes for escaping object types

* Added to generate_code
2022-08-16 12:52:26 -07:00
Paul Harris
f7c511957f Audit and fixups for GCC and Clang (#7212)
Added (for compiler versions that support it):
-Wmissing-declarations
-Wzero-as-null-pointer-constant

Then, fixes to problems identified by the extra warnings
Tested only on GCC 9.4.0

Adjusted the CPP code generator to output nullptr where appropriate,
to satisfy -Wzero-as-null-pointer-constant

Added a lot of 'static' declarations in front of functions,
to satisfy -Wmissing-declarations,
and wrap static function defs in anonymous namespaces.

There are advantages to both anonymous namespaces and static,
it seems that marking a function as static will not publish the name in
the symbol table at all, thus giving the linker less work to do.
2022-08-16 10:48:41 -07:00
Derek Bailey
a66de58af9 Partial support for --ts-flat-files and --gen-all (#7446)
* Partial support for --ts-flat-files and --gen-all

* Add generated code changes

* remove some debugging code left over

* missed grpc files
2022-08-15 16:11:45 -07:00
Paulo Pinheiro
a3508f36d5 [Kotlin] Make sure namespace path exist for code generation (#7357)
With a change introduce in 385dda5c3785ed8d6a35868bc169f07e40e889087fd2edc66,
flatc was not able to emit code for Kotlin if a namespace is specified
and the folders do not exist. The fix create folders if neded.

Additional changes are introduced in gradle files to bring more visibility
to the error messages.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-08-15 10:13:27 -07:00
Mirko Bonadei
137fec7164 Stop using __has_trivial_copy on recent clang versions. (#7443)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-08-15 09:49:59 -07:00
Derek Bailey
214125e417 [C#] Rework how sorted vectors are looked up (#7441) 2022-08-15 09:33:07 -07:00
Derek Bailey
44a7dc9995 Define minimum buffer size (#7440)
* add check for zero sized buffers

* Define minimum flatbuffer size
2022-08-14 12:40:57 -07:00
Stefan F
3cc2daa78f make_span overloads for pointer to vector (#7374) (#7435)
* make_span overloads for pointer to vector (#7374)

* findings from the review

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-08-14 12:21:55 -07:00
Derek Bailey
fa1174aa7b [TypeScript] Fix namespaceless schema generation (#7432)
* Add tests for ts flatc

* fix typescript generation of namespaceless file

* Add typescript genereated code from generate_code.py

* Support multiple module flatc testing
2022-08-14 11:34:19 -07:00
Derek Bailey
83d4e2a100 Add checks to verifier (#7438) 2022-08-13 23:44:13 -07:00
Maxim Zaks
8a09f3fb0b Fix FlexBuffers JS/TS bug https://github.com/google/flatbuffers/issues/6934 (#7434)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-08-13 18:29:28 -07:00
Derek Bailey
9dbe819efd Add flatc python tests to CI (#7437) 2022-08-13 17:30:51 -07:00
Derek Bailey
67c4149588 Update TypeScriptTest.py to work better cross platform (#7436) 2022-08-13 17:01:32 -07:00
Derek Bailey
8b8c7dbdfc Update gitingore to reflect name change (#7431) 2022-08-12 21:02:24 -07:00
Derek Bailey
2ee20a5f3d Remove auto including locale functions (#7430) 2022-08-12 15:23:46 -07:00
sssooonnnggg
4be605604e [C++] Set StructDef::has_key property when deserializing from binary schema (#7386) (#7428) 2022-08-12 09:27:17 -07:00
Marcel Krüger
fc5d86f1e7 [C++] Make template parameter in stl_emulation.h more explicit to avoid conflicts with cpprestsdk U macro (#7424)
* [C++] Rename template parameter U in make_span of stl_emulation.h

CPPRESTSDK defines a U macro therefore, calls to U() are problematic.
Rename U to W to avoid conflict.

* [C++] Make typenames of span_convertable and make_span more expressive

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-08-10 13:22:08 -07:00
Yashasvi Chaurasia
9dce287adb Issue#6959 :Updated Automatically generated rust files. (#7425)
* test

* only rust files

* updated idl_gen_rust.cpp
2022-08-10 09:15:35 -04:00
sssooonnnggg
7798be3bb6 avoid zero-as-null-pointer warning (#7423)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-08-08 21:32:13 -07:00
Derek Bailey
966362e074 [C++] Vector of Tables equality (#7415)
* Vector of Tables equality

* support nullptr and fix for not being able to use auto in lambda

* use different std::equal overload

* use flatbuffers::unique_ptr

* go back to auto and clang-format fix
2022-08-08 21:22:57 -07:00
Andrei Burdulescu
a89c279ed6 [golang] Perform keyword escaping after case conversion (#7421)
Change config.escape_keywords to AfterConvertingCase.

It avoids unecessay escaping since the generated native
structs have fields starting with a uppercase letter
and Go's keywords start with lowercase letters.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-08-08 20:46:35 -07:00
Derek Bailey
a212b3c036 Turn of fail fast for C++ CI
Prevent failing fast if one of the two c++ compilers fail
2022-08-08 19:12:18 -07:00
Derek Bailey
9230f600d7 Remove stringop-overflow from error (#7422) 2022-08-08 19:08:32 -07:00
Andrei Burdulescu
c793621567 [golang] Add support for text parsing with json struct tags (#7353)
* [golang] Add support for text parsing with json struct tags

Add struct tags to Go native structs generated when object API is used.

This allows to use the same JSON file as for C++ text
parsing(i.e. snake_case vs CamelCase) and thus enabling text parsing
for Go(when using object API).

* [golang] Add test for text parsing

Added small test to check and demonstrate text parsing in Go.
Also, ran clang-format on cpp file changes.
2022-08-08 11:30:06 -07:00
Derek Bailey
ee2ced236d Moved TypeScriptTests to python script (#7411)
* Moved TypeScriptTests to python script

* fixed CI issue with out-dated generated file

* Build flatc for TS CI

* reverting yarn.lock
2022-08-07 11:42:02 -07:00
Aman Priyadarshi
468c00a3fe Rebased: grpc/compiler: Respect filename suffix and extension during code generation (#7414)
* grpc/compiler: Respect filename suffix and extension during code generation

grpc compiler is not respecting filename suffix and extension passed to
flatc CLI. This causes compiler to spit out incorrect code, which then
cannot be compiled without modification.

Following patch fixes the problem.

Note, I ended up removing some code introduced #6954 ("Have grpc include
file with correct filename-suffix given to flatc") in favour of keeping
sanity of the generator code.

Signed-off-by: Aman Priyadarshi <aman.eureka@gmail.com>

* tests: Add filename-suffix and filename-ext test files

* Test 1: Filename extension changed to "hpp".
* Test 2: Filename suffix changed to "_suffix".
* Test 3: Filename extension changed to "hpp" and suffix changed to "_suffix"

Signed-off-by: Aman Priyadarshi <aman.eureka@gmail.com>
2022-08-07 11:32:53 -07:00
Derek Bailey
47c757f714 Add tests for flatc (#7405) 2022-08-06 21:11:03 -07:00
Derek Bailey
9a5ff89003 Add FLATBUFFERS_STRICT_MODE (#7408) 2022-08-06 21:06:14 -07:00
Björn Harrtell
950444a343 [TS] Use TextEncoder and TextDecoder (#7400)
* [TS] Use TextEncoder

TextEncoder is well supported these days, see https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder#browser_compatibility.

* Reuse instance

* Also use TextDecoder

* Forgot to add text_decoder_ member

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-08-06 22:00:30 +00:00
Ivan Shynkarenka
30d76198c7 Compilation issue msys2 #7399 (#7409)
* Compilation issue msys2 #7399

* Compilation issue msys2 #7399
2022-08-06 14:56:22 -07:00
Derek Bailey
cce3a66f0d Delete .travis directory
We don't use travis anymore.
2022-08-06 12:30:13 -07:00
Derek Bailey
8d1cc6ac7d Revert "Compilation issue msys2 (#7403)" (#7407)
This reverts commit da702cfd8f.
2022-08-06 10:19:50 -07:00
Derek Bailey
5b207639a1 Update readme.md
Add scorecard badge via: https://github.com/ossf/scorecard-action#view-results
2022-08-05 23:41:06 -07:00
Derek Bailey
359e0f9d66 Revert "grpc/compiler: Respect filename suffix and extension during code generation (#7343)" (#7406)
This reverts commit 97e89c5acd.
2022-08-05 23:20:33 -07:00
Derek Bailey
ebbed05137 Delete cpp-linter.yml
Linter was not that useful, so removing it.
2022-08-05 22:56:00 -07:00
Chris Langhans
aa395e5a59 (#7323) Rename CMake files according to project name (#7378)
* CMake find_package fixes (#7323)

Rename FlatbuffersConfigVersion.cmake to match CMake project name

* CMake find_package fixes (#7323)

Rename FlatBuffersTargets to match CMake project name
2022-08-05 22:19:17 -07:00
SF-Zhou
32328075d8 Fix error msg format when generate GRPC failed (#7350) 2022-08-05 22:12:15 -07:00
Aman Priyadarshi
97e89c5acd grpc/compiler: Respect filename suffix and extension during code generation (#7343)
* grpc/compiler: Respect filename suffix and extension during code generation

grpc compiler is not respecting filename suffix and extension passed to
flatc CLI. This causes compiler to spit out incorrect code, which then
cannot be compiled without modification.

Following patch fixes the problem.

Note, I ended up removing some code introduced #6954 ("Have grpc include
file with correct filename-suffix given to flatc") in favour of keeping
sanity of the generator code.

Signed-off-by: Aman Priyadarshi <aman.eureka@gmail.com>

* tests: Add filename-suffix and filename-ext test files

* Test 1: Filename extension changed to "hpp".
* Test 2: Filename suffix changed to "_suffix".
* Test 3: Filename extension changed to "hpp" and suffix changed to "_suffix"

Signed-off-by: Aman Priyadarshi <aman.eureka@gmail.com>
2022-08-05 22:11:45 -07:00
06393993
5f6672be44 Fix Clang-Cl compile on Windows (#7308)
Introduce a MSVC_LIKE variable in the CMake scripts, set that variable to
true only if the compiler is either MSVC or tries to emulate the MSVC
command line, and test that variable when setting compiler arguments.

Tested with cmake .. -G Ninja -DCMAKE_C_COMPILER:PATH="clang-cl.exe" -DCMAKE_CXX_COMPILER:PATH="clang-cl.exe" -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_CPP17=ON

Co-authored-by: Kaiyi Li <kaiyili@google.com>
2022-08-05 22:08:36 -07:00
James Kuszmaul
28e858c855 [TS/Bazel] Minor improvements to typescript.bzl (#7300)
* Move reflection_ts_fbs into a separate directory (#7342)

Right now, reflection_ts_fbs target is in reflection/BUILD.bazel.

This is not ideal because reflection:reflection_fbs_schema is referenced
from :flatc in the root. Thus, for any Bazel projects that want to
include flatbuffers, they need to include npm / yarn_install and nodejs
support all because reflection/BUILD.bazel loads typescript.bzl and that
requires all TypeScript things.

This PR separated that target into a different subdirectory, freeing
root BUILD.bazel from that dependency.

* Minor improvements to typescript.bzl

* Uses @...// dependencies so that flatbuffers can actually
  be used as an external repo (had forgotten to upstream this earlier).
* Allows using flatbuffer_ts_library to generate reflection schemas
  in the same way that flatbuffer_cc_library does (but default it
  to off to avoid behavioral changes).
* Pass through a package_name attribute to flatbuffer_ts_library to
  allow non-relative imports of generated typescript code.

Co-authored-by: Liu Liu <i@liuliu.me>
2022-08-05 22:04:05 -07:00
sssooonnnggg
987bebe678 [TS] fix incorrect reverse when writting array of structs (#7271) 2022-08-05 22:00:16 -07:00
Wouter van Oortmerssen
ec0129369c Fix FlexBuffers Verifier tracking vectors reuse at wrong offset
See test for an example.
Found in: https://github.com/aardappel/lobster/pull/193
2022-08-05 10:45:01 -07:00
Atil Kurtulmus
50dd385b30 Add missing const (#7401) 2022-08-05 11:11:00 -04:00
Ivan Shynkarenka
da702cfd8f Compilation issue msys2 (#7403)
* Compilation issue msys2 #7399

* Fix flatbuffers compilation issue
2022-08-05 10:10:58 -04:00
Derek Bailey
6e2791640e keep-prefix keeps relative pathing (#7394) 2022-07-26 15:11:54 -07:00
godcong
52fce5e532 fix(#7360): grpc used deprecated functions (#7361) 2022-07-26 15:10:13 -07:00
Yasser Shalabi
b7f13cd8e8 cpp_generator: comment out unused parameter to avoid warnings (#7381)
Presently flatc generates a placeholder for the unused synchronous varient of client-side streaming gRPCs which includes the name of an unused parameter in the method.

To avoid warnings, comment out the parameter name (in a manner similar to other gRPCS).
2022-07-26 15:05:01 -07:00
Derek Bailey
e42985e5aa Updated Newtonsoft.Json to 13.0.1 (#7393) 2022-07-26 13:22:18 -07:00
Ian Hickson
0a80646371 Fix references to LICENSE file (#7377)
* Fix references to LICENSE file

This was broken by https://github.com/google/flatbuffers/pull/7073

* Update flat_buffers_test.dart
2022-07-07 16:06:19 -07:00
Will Hughes
b9eea76a86 [Dart] Implement putBool to fix errors when serializing structs with bools (#7359)
* [Dart] Implement putBool to fix errors when serializing structs with bools

* Add tests
2022-06-28 11:16:47 -04:00
dependabot[bot]
1b90300150 Bump Newtonsoft.Json from 12.0.3 to 13.0.1 in /tests/FlatBuffers.Test (#7363)
Bumps [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) from 12.0.3 to 13.0.1.
- [Release notes](https://github.com/JamesNK/Newtonsoft.Json/releases)
- [Commits](https://github.com/JamesNK/Newtonsoft.Json/compare/12.0.3...13.0.1)

---
updated-dependencies:
- dependency-name: Newtonsoft.Json
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-23 15:03:07 -04:00
Caleb Zulawski
83a43fc797 Reenable optional json (#7352)
* Revert "Revert "Implement optional scalars for JSON (#7322)" (#7351)"

This reverts commit 9a1913a87a.

* Add optional scalars json to bazel

Co-authored-by: Caleb Zulawski <caleb.zulawski@caci.com>
2022-06-16 09:26:44 -07:00
Derek Bailey
5f01376027 Only include direct included filed (#7348) 2022-06-15 12:10:39 -07:00
Derek Bailey
9a1913a87a Revert "Implement optional scalars for JSON (#7322)" (#7351)
This reverts commit a18ea40d6a.
2022-06-15 00:32:28 -07:00
Derek Bailey
b4647beb8f Revert "Move reflection_ts_fbs into a separate directory (#7342)" (#7349)
This reverts commit 090caa2809.
2022-06-14 20:58:00 -07:00
Derek Bailey
d6060977ad Remove asserting in verifier for flattests 2022-06-14 20:53:28 -07:00
Derek Bailey
987aa5b5ee move -Wextra-semi to GCC 8.0+ 2022-06-14 16:32:10 -07:00
James Kuszmaul
42acdb63c3 [TS] Don't generate self-imports with --ts-flat-file (#7340)
The logic to manage generating typescript in a single file was
generating self imports and unused local names, which triggered some
linters.

This resolves #7191
2022-06-14 15:51:12 -07:00
Timo Sturm
0cc1aeb8ca [golang] Create missing namespace directory structure (#7324) (#7325) 2022-06-14 15:50:05 -07:00
Paulo Pinheiro
ba6c671705 [Kotlin] Remove download benchmark files dependency (#7314)
There was a step in the compilation process where benchmark data is
downloaded before starting the kotlin compilation process.

Since we are not running benchmark on CI anymore, we remove the
dependency. To run benchmarks the download task needs to be executed
manually.
2022-06-14 15:49:42 -07:00
Derek Bailey
d2f33fc454 Disable Android on Linux CI build 2022-06-14 15:46:48 -07:00
sssooonnnggg
0d1b72cbc2 [TS] fix ts import path issue (#7298) 2022-06-14 15:25:35 -07:00
Koya IWAMURA
9fce2fbf2a replace io/ioutil to os (#7281) 2022-06-14 15:10:57 -07:00
Caleb Zulawski
a18ea40d6a Implement optional scalars for JSON (#7322)
* Implement optional scalars for JSON

* Add optional scalars JSON test

* Extend JSON optional scalars test to test without defaults

* Fix optional scalars in JSON for binary schema

Co-authored-by: Caleb Zulawski <caleb.zulawski@caci.com>
2022-06-14 18:00:24 -04:00
Liu Liu
090caa2809 Move reflection_ts_fbs into a separate directory (#7342)
Right now, reflection_ts_fbs target is in reflection/BUILD.bazel.

This is not ideal because reflection:reflection_fbs_schema is referenced
from :flatc in the root. Thus, for any Bazel projects that want to
include flatbuffers, they need to include npm / yarn_install and nodejs
support all because reflection/BUILD.bazel loads typescript.bzl and that
requires all TypeScript things.

This PR separated that target into a different subdirectory, freeing
root BUILD.bazel from that dependency.
2022-06-13 09:36:52 -04:00
Caleb Zulawski
49e1ea3335 Implement optional scalars for Python (#7318)
* Implement optional scalars for Python

* Use == for integer comparison, remove empty line

* Fix optional type hint

Co-authored-by: Caleb Zulawski <caleb.zulawski@caci.com>
2022-06-13 09:16:00 -04:00
mustiikhalil
11a1988705 Started implementation for private flags in rust (#7269)
Adds flag to the cpp to fix bad annotations in all the languages

Addresses comments to the PR, and fixes logic for leaking annotations
2022-06-05 23:04:05 +02:00
mustiikhalil
967df08b1d Adds full supposed for Wasm in the swift lib (#7328)
Adds tests for wasm module & github action
2022-05-29 20:56:33 +02:00
Casper
9aa08a429e Use keep case for Rust union discriminant type. (#7321)
Fixes #7320.

I realize that Rust doesn't really follow the Namer convention, since
it uses Field case for methods... that's a future problem.

Co-authored-by: Casper Neo <cneo@google.com>
2022-05-23 15:53:00 -04:00
Bart van der Werf
9e8c758f54 Add explicit return types to lobster generated code (#7312)
* Add explicit return types to lobster generated code

* Add support for optional fields.

Convert to bool explicitly from int8 to match type signature
Fix whitespace
2022-05-23 10:50:01 -07:00
Björn Harrtell
74a25536be Add size check to fix out of bounds read risk (#7304) 2022-05-13 15:15:00 -07:00
Brian Silverman
12917af8a2 Update Rust docs page (#7296)
I think these changes reflect the current state, but I found it hard to
track the state of some of the planned work. Hence why it'd be good to
have it documented :)

I also expanded some sections that I found misleading, as somebody
familiar with Rust and FlatBuffers separately. Parts of these pages seem
to be aimed at people familiar with FlatBuffers (ie via the other
documentation pages) but not each language, which I'm trying to
preserve. However, Rust does some things differently, and as somebody
with expectations about how typical Rust APIs work the discussion of
threading made me wonder what was different.
2022-05-12 10:02:14 -07:00
mr-swifter
1ea2472f7a [swift] add had<ArrayName> property for arrays to check presence in a message (#7280) 2022-05-11 15:35:53 +02:00
pkasting
0fe13cb28c Remove span ConstIterator/cbegin()/cend(). (#7295)
std::span lacks these; make  the flatbuffers STL emulation and tests
match.  This fixes a compile error in C++20 mode when using std::span.

Bug: chromium:1284275
2022-05-10 13:53:38 -07:00
Casper
385dddc66a Namerkot (#7245)
* Namer for Kotlin

* delete unread cur_name_space_ and apply Namer to filename

Co-authored-by: Casper Neo <cneo@google.com>
2022-04-26 21:54:49 -04:00
Bogdan Opanchuk
750dde7669 Make flatc generate Rust files not requiring std (#7273)
* Set an explicit 2018 edition for Rust tests

* Replace all `std` usage with `core` and `alloc` in Rust code generator

* Update the generated files

* Make Rust tests actually use no_std when the corresponding feature is enabled
2022-04-26 21:40:03 -04:00
Keith Smiley
9917a168cd [swift] Make swift module public (#7274) 2022-04-26 18:58:51 +02:00
Bogdan Opanchuk
76d3cca19c Rust: fix a name conflict when building with "no_std" feature (#7268)
* Fix a name conflict when building with "no_std" feature

* Bump patch version
2022-04-25 13:09:41 -04:00
Derek Bailey
c86e6d0e30 json inf parsing 2022-04-22 12:24:26 -07:00
Derek Bailey
d34dc32c20 fix include order 2022-04-22 11:19:04 -07:00
Derek Bailey
234d86c92a fixed off-by-one in parser 2022-04-21 21:22:20 -07:00
Derek Bailey
746c73b910 Add Annotations for Monster schema and example buffer 2022-04-21 20:43:55 -07:00
Derek Bailey
0bbfd4b2e3 fixes for annotator 2022-04-21 11:46:16 -07:00
Joakim Hassila
7165219535 Update readme.md (#7257)
Added Swift to supported languages.
2022-04-20 09:49:35 -07:00
Joakim Hassila
a45f564cf1 [performance] Add aggressive systematic inlining in ByteBuffer and FlatBufferBuilder (#7253)
Co-authored-by: Joakim Hassila <hassila@users.noreply.github.com>
2022-04-20 08:59:47 +02:00
Derek Bailey
9d45a64036 more google merge fixes 2022-04-19 14:35:20 -07:00
Derek Bailey
ccfb4c20bf Handle +/-inf in protos (#7256)
* Handle +/-inf in protos

* Check for digit in 4th pos
2022-04-19 13:07:26 -07:00
Derek Bailey
7bcd857b87 Specialize CreateVector with std::initializer_list (#7254) 2022-04-19 13:06:50 -07:00
Joakim Hassila
23c8ab34c1 Swift update performance benchmark infrastructure (#7255)
* Keep the underlying storage capacity when clearing the FlatBufferBuilder. Gives a significant performance boost for serialisation of many small messages.

* Use Googles Swift benchmark library for more consistent results and dynamic number of iterations, simplification of tests as result.

Co-authored-by: Joakim Hassila <hassila@users.noreply.github.com>
2022-04-19 10:52:10 +02:00
Derek Bailey
70002dc5ca various fixes for google merge 2022-04-18 21:15:35 -07:00
Derek Bailey
6e0e79f24f Add test for nested buffer verifier (#7252)
* Add test for nested buffer verifier

* switch to base API
2022-04-18 10:20:06 -07:00
mustiikhalil
b856368d75 Turn off go modules temporary until we get a proper fix (#7251) 2022-04-16 15:29:18 -07:00
Joakim Hassila
e37156a305 Keep the underlying storage capacity when clearing the FlatBufferBuilder. Gives a significant performance boost for serialisation of many small messages. (#7250) 2022-04-16 11:25:44 +02:00
Derek Bailey
a10b0e5464 Java namer variable keep case (#7249) 2022-04-15 16:33:35 -07:00
Derek Bailey
275b739944 allow overriding FLATBUFFERS_MAX_ALIGNMENT 2022-04-15 11:56:34 -07:00
Derek Bailey
9d1ce9a100 Add parameter back to EndVector (#7246) 2022-04-15 11:24:05 -07:00
Casper
79afe6c3d2 Make Java namespaces keep case by default (#7243)
Co-authored-by: Casper Neo <cneo@google.com>
2022-04-13 16:01:48 -07:00
Derek Bailey
c6dbb22300 Add write permissions for labeller 2022-04-13 14:15:38 -07:00
Henner Zeller
18bacd3ea5 Expand test to make sure {}-initializers are properly understood by template. (#7242)
Since CreateVectorOfStrings() takes a templated container, make sure that
the default template deduction from just an initializer list will
still work.

Signed-off-by: Henner Zeller <hzeller@google.com>
2022-04-13 14:13:32 -07:00
Derek Bailey
a2c913aec3 Add -Wnon-virtual-dtor 2022-04-12 16:22:39 -07:00
Derek Bailey
67b33b2942 set workflows permissions to read-only (#7239) 2022-04-11 20:01:00 -07:00
Paulo Pinheiro
7b5fd2bd05 [Kotlin] Fix key lookup returning null clashing with default value (#7237)
* [Java] Fix key lookup returning null clashing with default value

A field with key attribute must always be written on the message so it
can be looked up by key. There is a edge case where inserting a key
field with same value as default would prevent it to be written on
the message and later cannot be found when searched by key.

* [Kotlin] Fix key lookup returning null clashing with default value

A field with key attribute must always be written on the message so it
can be looked up by key. There is a edge case where inserting a key
field with same value as default would prevent it to be written on
the message and later cannot be found when searched by key.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-04-11 17:17:19 -07:00
Paulo Pinheiro
7181d77700 [Java] Fix key lookup returning null clashing with default value (#7236)
A field with key attribute must always be written on the message so it
can be looked up by key. There is a edge case where inserting a key
field with same value as default would prevent it to be written on
the message and later cannot be found when searched by key.
2022-04-11 17:16:41 -07:00
Henner Zeller
7f663b1204 Allow CreateVectorOfStrings() to work with any string-type. (#7238)
Any string type that is supported by CreateString(), e.g.
const char* or string_view will now also work.

Signed-off-by: Henner Zeller <hzeller@google.com>
2022-04-11 17:02:19 -07:00
mustiikhalil
173ebb6944 Fixes a bug where the create function doesnt optional + required items (#7228)
Format sh file
2022-04-08 15:28:54 -07:00
Paulo Pinheiro
d658239484 [Kotlin] Update gradle to 7.4.1 and simplify config files. (#7231)
* [Kotlin] Update gradle to 7.4.1 and simplify config files.

* [Kotlin] Add wrapper-validation-action to Kotlin Linux

* [Kotlin] Remove benchmark actions to reduce CI time

* [Kotlin] Move CI js test to Linux action, to increase Mac action speed

* [Kotlin] Generate gradle wrapper in order to be validate

Gradle wrapper from 3.3 to 4.0 are not verifiable because those files
were dynamically generated by Gradle in a non-reproducible way.

So they are now regenerated and will be checked using gitlab action:
gradle/wrapper-validation-action@v1
2022-04-08 11:23:13 -07:00
Derek Bailey
ab4bf59e8c remove toascii (#7234) 2022-04-07 20:48:26 -07:00
Derek Bailey
eee44bbb26 disable cpp-linter (#7229) 2022-04-06 15:03:43 -07:00
Derek Bailey
a63fa51a15 Create cpp-linter.yml (#7208)
* Create cpp-linter.yml

* Update cpp-linter.yml

* Update cpp-linter.yml

* Update bfbs_gen_lua.cpp

make some ill-formed edits to see if the linter flags them.

* Update cpp-linter.yml

Configured tidy checks

* Update cpp-linter.yml

Build project before linting to get compile_commands.json

* Update cpp-linter.yml

* Update cpp-linter.yml

* Update cpp-linter.yml

* Update cpp-linter.yml

* Update cpp-linter.yml

* lines only
2022-04-06 14:18:36 -07:00
mustiikhalil
2049e52101 Adds a way to verify/exposes Entities ids (#7221) 2022-04-06 22:54:01 +02:00
mustiikhalil
832c618f5f Adds implementation flag for swift (#7202)
* Adds implementation flag for swift

Forces internal flag when using @_implementationOnly in swift

Fixes access type for verifier functions & encoder functions

Updates generated code

* Addresses PR comments & adds a code gen dir within the swift tests

* Adds test case for no-include

* Fixes code gen script

Removes prefix
2022-04-06 13:31:38 -07:00
Derek Bailey
14615699fa Started to migrate to target_compile_options (#7222)
* Started to migrate to target_compile_options

* combined compile options together. Added Mac CI builds

* remove arm build (not supported). Fixed old-style-casts

* moved to using a ProjectConfig interface library to specify options

* remove the explicit CMAKE_CXX_STANDARD
2022-04-06 13:25:43 -07:00
avaliente-bc
20aad0c41e [C++] stl_emulation span::count_ is not const anymore (#7226) (#7227)
In C++ we cannot have both assignment operator and const member. Since
span::operator= is defined, span::count_ constness must be removed.
2022-04-06 12:27:37 -07:00
Derek Bailey
f083b33f2a code gen flexbuffer verifier (#7207)
* code gen flexbuffer verifier

* remove verify nested flexbuffers from flexbuffers

* made function static, and placed higher in file

* moved function to own header
2022-04-05 16:29:42 -07:00
Stefan F
bf17df346e [C++] generate sorted #include directives (#7213)
* [C++] generate sorted #include directives

* using stable_sort instead of sort.
2022-04-04 15:20:55 -07:00
Stefan F
35281dedb5 Fix for [C++] flatc generates invalid Code in the default constructor for structs, when --cpp-field-case-style is used #7209 (#7211)
* Typo in flatc options (warning-as-errors instead of warnings-as-errors)

* VerifySizePrefixed (reflection::Schema) and GetAnySizePrefixedRoot added

* some review comments

* more review comments

* Fix for https://github.com/google/flatbuffers/issues/7209

* Fixes [C++] flatc generates invalid Code for union field accessors, when --cpp-field-case-style is used #7210
2022-04-01 13:35:57 -07:00
Jamie-Jameson
c9651b7420 Add overloads for C# ByteBuffer/FlatBufferBuilder to allow adding vector blocks from ArraySegments or IntPtr (#7193)
* Add overloads to Add/Put for ArraySegment and IntPtr

In order to allow using code to reduce memory allocations, add overloads to ByteBuffer's and FlatBuffersBuilder's Put/Add methods that take ArraySegment<T> or IntPtr respectively.
Also, adaptions to the c# code generator in flatc to emit corresponding CreateVectorBlock() overloads

* Add missing files generated with generate_code.py

The previous commit changed the C# code generate, but didn't contain the updated generated test files.

* Incorporate review findings

(1) Adhere to 80 characters limit.
(2) In FlatBufferBuilder.Add(IntPtr,int), move zero length check topmost and add sanity check against negative input
2022-04-01 13:35:07 -07:00
Derek Bailey
26c3b3adab Update codeql.yml
Replaced autobuild with cmake and make.
2022-03-31 22:19:51 -07:00
Derek Bailey
da6e1b9856 Update codeql.yml
Disable all languages other than c++
2022-03-31 21:44:17 -07:00
Derek Bailey
ad27d751e3 Added Oss fuzz badge 2022-03-31 21:14:09 -07:00
Derek Bailey
0aab623cb1 Create codeql.yml 2022-03-31 21:08:30 -07:00
Derek Bailey
6a446bdd83 maximize parallel builds in CI (#7206) 2022-03-31 21:07:37 -07:00
Derek Bailey
21fb5cbbc9 Create scorecards.yml 2022-03-31 21:00:12 -07:00
Derek Bailey
0da6f94867 [C++] Static assert on Flatbuffers Version (#7203)
* Static assert on Flatbuffers Version

* add comment
2022-03-31 20:56:41 -07:00
Derek Bailey
59e9713081 reduce fuzzing time to 1 minute in CI 2022-03-31 16:28:53 -07:00
Derek Bailey
40866a8927 fixed padding in struct for annotated binary (#7199) 2022-03-30 16:43:22 -07:00
Casper
b71d968fad Apply Namer prefix/suffix to other generators (#7197)
* Apply Namer prefix/suffix to other generators

* unnecessary .name

Co-authored-by: Casper Neo <cneo@google.com>
2022-03-30 18:45:11 -04:00
Casper
fac0d7be02 Apply Namer to Java. (#7194)
* Started applying Namer to Java.

- Java didn't previously have keyword escaping
- Added prefixes and suffixes to the Namer methods
- TODO: migrate previous namer applications to using pre/suffixes
- Java methods / functions are interesting, it's mostly camel case
  except when it involves a struct/enum name. That section is Keep case
- I changed the casing for some internal arguments/variables. This
  violates the "don't change genfiles" rule that I've been using but it
  shouldn't break user code.
- LegacyJavaMethod2 is interesting. Basically, Java has a "mixed" case
  convention where it's camel case, except for the type/variant name
  itself, which is keep case. So a type foo_bar would become getfoo_bar
  instead of getFooBar.

* small fix

* Namer for Namespaces

* removed unused parameter, add const everywhere

* Remove unused argument

* More unused args

* Use mutable reference out parameters

* Made more strings const and inlined const empty strings

* remove do not submit

Co-authored-by: Casper Neo <cneo@google.com>
2022-03-30 18:13:16 -04:00
tira-misu
6c5603fd98 [C#] Fix collision of field name and type name (#7149)
* 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

* [TS] Fix reserved words as arguments (#6955)

* [TS] Fix generation of reserved words in object api (#7106)

* [TS] Fix generation of object api

* [TS] Fix MakeCamel -> ConvertCase

* [C#] Fix collision of field name and type name

* [TS] Add test for struct of struct of struct

* Update generated files

* Add missing files

* [TS] Fix query of null/undefined fields in object api

* Add example for type field name collision
2022-03-30 12:51:58 -07:00
Derek Bailey
2d21853a7e monster fuzzer fix for json default scalars 2022-03-30 12:29:41 -07:00
Keith Smiley
fec1a8d015 [swift] Add bazel configuration for Swift (#7195)
* [swift] Add bazel configuration for Swift

This change adds a simple bazel BUILD file for consuming the Swift
support. This also bumps the platforms bazel repo to fix support for M1s
and bazel 5.1+ https://github.com/bazelbuild/bazel/issues/15099#issuecomment-1075368289

The rules_swift inclusion here must happen before gRPC to ensure we
don't pull in an older version.

* Add CC=clang which is a requirement for Swift on Linux

* Add Swift to PATH
2022-03-29 21:30:33 -07:00
Derek Bailey
7fd8576233 structured comments (#7192) 2022-03-29 10:01:32 -07:00
Casper
a4cb1599d8 Namerdart (#7187)
* Apply Namer to Dart.

- Also refactor idl_gen_dart a bit
  - to use more const and references
  - out parameters should be the last argument

* Add keyword test

* minor fixes

* fix merge

* extra 's'

* move dart keyord into dart dir

* Address comments

* Use $ for escaping keywords
* Outparameters for namespace_map

* Escape dollar in toString

* Escape dollar in toString2

* Use UpperCamelCase for types and variants

* try to fix ToString

* namer Type fixes

* Remove path prefixing in imports

* gen code

Co-authored-by: Casper Neo <cneo@google.com>
2022-03-28 18:07:09 -04:00
Derek Bailey
ae4ce72651 fuzzed binary annotator (#7188) 2022-03-25 22:58:15 -07:00
Derek Bailey
e2be0c0b06 Handle root offset and root table vtable invalidation (#7177)
* Handle invalid root offset

* Handle vtable offset invalidation

* Added script generator. Add more cases through vtable ref table size

* review responses

* vtable offset validation

* Moved padding insertion to the end. Tests invalid field lenghts

* table offsets validated. Added type after field

* validate string length

* add todo

* invalid vector length

* invalid structs

* general cleanup

* reworded invalid offsets

* example for vector of structs

* invalid vector of tables

* invalid vector of strings

* invalid vector of scalars

* vector of unions

* validate union type value

* invalid vector union type values
2022-03-23 21:51:32 -07:00
tira-misu
2ad408697f [TS] Fix generation of struct members in object api (#7148)
* 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

* [TS] Fix reserved words as arguments (#6955)

* [TS] Fix generation of reserved words in object api (#7106)

* [TS] Fix generation of object api

* [TS] Fix MakeCamel -> ConvertCase

* [TS] Add test for struct of struct of struct

* Update generated files

* Add missing files

* [TS] Fix query of null/undefined fields in object api
2022-03-23 21:40:11 -07:00
Stefan F
4213d91054 VerifySizePrefixed (reflection::Schema) and GetAnySizePrefixedRoot added (#7181)
* Typo in flatc options (warning-as-errors instead of warnings-as-errors)

* VerifySizePrefixed (reflection::Schema) and GetAnySizePrefixedRoot added

* some review comments

* more review comments
2022-03-23 21:39:38 -07:00
Will Hughes
5a13f622cf Correctly parse lists of enums in Dart generated code (#7157)
* Correctly parse lists of enums in Dart generated code

* Add a test for #6869

* Commit generated code

* Fixed missing newline-at-eof
2022-03-22 21:56:14 -07:00
mustiikhalil
23a7e4e0b0 Adds no-includes flags to the swift code generator (#7182) 2022-03-22 21:42:20 -07:00
James Kuszmaul
eeb49c2757 Move flatbuffer_ts_library to typescript.bzl (#7183)
This makes it so that users of flatbuffer_cc_library don't need to have
rules_nodejs available in their WORKSPACE, addressing #7179.
2022-03-22 21:41:39 -07:00
Stefan F
824763b316 Typo in flatc options (warning-as-errors instead of warnings-as-errors) (#7180) 2022-03-21 18:08:14 -04:00
Derek Bailey
d3aeee32bb Annotated Flatbuffer Binary (#7174)
* Annotated Flatbuffer Binary

* Various fixes

* Handles old schema

* handle multiple missing fields

* minor edits

* bazel fix, spelling fix, ascii fix
2022-03-18 14:08:05 -07:00
Derek Bailey
0bceba24db [Lua] Apply Namer to Lua (#7171)
* Apply Namer to Lua bfbs code gen

* refactor namer into IdlNamer to keep idl includes separate

* remove commented out code

* added bfbs_namer

* remove Enum case

* add to bazel
2022-03-15 21:48:42 -07:00
David Schneider
b8c77d4041 Make inclusion of header <optional> opt-out via macro (#7168)
* Allow suppression of including <optional> via macro

* Combine preprocessor conditions

* Make inclusion of header <optional> opt-in

* Make inclusion of <optional> opt-out via macro

* Auto-detect C++17+ when defining macro

* Enclose macro expression in parentheses

* Check value of macro, not whether it's defined

* Fix parentheses

* Don't define macro with expression using other macros

The preprocessor doesn't seem to like it.

* Fix parentheses
2022-03-15 17:52:11 -07:00
Casper
8468eab83b Namersw (#7167)
* Define and use Namer overloads

* more

* NamespacedType needs a public string-like overload

* Move Rust FieldOffsetName to Namer LegacyRustFieldOffsetName

* Started swift

* More Namer updates

* Remove more usage of the variable 'name' which was semantically overloaded

* unshadow varible

* Make ptr to bool explicit

Co-authored-by: Casper Neo <cneo@google.com>
2022-03-13 18:46:27 -04:00
Casper
2b2e8d4aec Nameroverloads (#7164)
* Define and use Namer overloads

* more

* NamespacedType needs a public string-like overload

* Move Rust FieldOffsetName to Namer LegacyRustFieldOffsetName

Co-authored-by: Casper Neo <cneo@google.com>
2022-03-13 16:54:45 -04:00
Markus
b80b32bfaf Use DESCRIPTION only if CMake version >= 3.9 (#7166) 2022-03-13 12:49:18 -07:00
James Kuszmaul
e5f331db99 [TS] Add single-file ts codegen & bazel rule for typescript (#7161)
The headline here is adding a flatbuffer_ts_library rule for generating
typescript code in bazel. This entails some non-trivial other changes,
but ideally none are user-visible.

In particular:
* Added a --ts-flat-file flag that generates a single *_generated.ts
  file instead of separate files for each typescript type. This makes
  bazel much happier.
* Import the bazel rules_nodejs stuff needed to support building
  typescript in bazel
* Move flatbuffers.ts to index.ts because I wasn't sure how to make
  bazel comprehend the "main" attribute of the package.json. Happy
  to take another stab at figuring that out if really needed.
* Fix another couple keyword escaping spots in typescript...
2022-03-10 10:08:13 -08:00
Casper
2f84c60385 Apply Namer to Go code gen (#7150)
* Refactor out a  class from Rust Codegen

* Convert GenerateRustModuleRootFile

* git-clang-format

* unused variable

* parenthesis

* update BUILD file

* buildifier

* Delete bfbs_gen_rust.h

* Delete bfbs_gen_rust.cpp

* Addressed some comments

* Namer::EnumVariant

* Remove do not submit; Add Namespace vector overload

* Unshadow variable

* removed redundant variables

* Apply Namer to Python

* Use more variables a bit

* Apply const a bunch

* More variables

* Fix ObjectTypes

* git clang format

* small thing

* Simplified code around nested flatbuffers

* Make more methods const.

* Python files are kKeep case

* Address DO NOT SUBMIT in SaveType

* ensure dir exists before saving files

* clang format

Co-authored-by: Casper Neo <cneo@google.com>
2022-03-08 20:53:05 -05:00
Wouter van Oortmerssen
d648396515 [Lobster] file_identifier support 2022-03-08 15:39:12 -08:00
Wouter van Oortmerssen
777e78d8dd [Lobster] support unsigned integer reads
(depends on the latest Lobster version)
2022-03-08 15:13:34 -08:00
Casper
4016c549d3 Apply Namer to Python code gen (#7146)
* Refactor out a  class from Rust Codegen

* Convert GenerateRustModuleRootFile

* git-clang-format

* unused variable

* parenthesis

* update BUILD file

* buildifier

* Delete bfbs_gen_rust.h

* Delete bfbs_gen_rust.cpp

* Addressed some comments

* Namer::EnumVariant

* Remove do not submit; Add Namespace vector overload

* Unshadow variable

* removed redundant variables

* Apply Namer to Python

* Use more variables a bit

* Apply const a bunch

* More variables

* Fix ObjectTypes

* git clang format

* small thing

* Simplified code around nested flatbuffers

* Make more methods const.

* Python files are kKeep case

* Address DO NOT SUBMIT in SaveType

* ensure dir exists before saving files

* fix space

Co-authored-by: Casper Neo <cneo@google.com>
2022-03-07 19:24:46 -05:00
Casper
40827b21b2 Fix missing 'break' (#7151)
Co-authored-by: Casper Neo <cneo@google.com>
2022-03-07 11:53:20 -05:00
Casper
65a10b6e32 Implement a config based name manager and use it in Rust codegen (#7144)
* Refactor out a  class from Rust Codegen

* Convert GenerateRustModuleRootFile

* git-clang-format

* unused variable

* parenthesis

* update BUILD file

* buildifier

* Delete bfbs_gen_rust.h

* Delete bfbs_gen_rust.cpp

* Addressed some comments

* Namer::EnumVariant

* Remove do not submit; Add Namespace vector overload

* Unshadow variable

* removed redundant variables

* Warn if converting from kKeep case.

Co-authored-by: Casper Neo <cneo@google.com>
2022-03-05 20:43:57 -05:00
James Kuszmaul
8db2fef3f7 [TS] Escape keywords in typescript object names (#7137)
* Add Object to the list of reserved keywords.
* Properly escape keywords in type names.
* Properly escape keywords in enum names.
* Properly escape keywords in enum field names.
2022-03-05 09:39:59 -08:00
James Kuszmaul
9ed1323044 Fix 64-bit numeric enum values in typescript (#7135)
* Fix 64-bit default numeric enum values in typescript

If you had a default value that wasn't a valid enum value (e.g., a zero
if you used a bit_flag setting, like you get with AdvancedFeatures
in reflection.fbs), we weren't using BigInt.

* Run generate_code.py

* [DART] Handle deprecated fields & invalid enum defaults

* Update .NET test
2022-03-04 21:57:48 -08:00
Derek Bailey
1a4c405662 updated npm to 2.0.6 2022-02-24 22:21:36 -08:00
Derek Bailey
318594e4b4 prevent name clash (#7133) 2022-02-24 22:01:25 -08:00
Casper
3d903302c3 [Rust] Add length checks to arrays and vectors. (#7130)
* [Rust] Add length checks to arrays and vectors.

The previous behavior allowed for out of bounds access in
the public API (#7011).

* bump semver and test warning

Co-authored-by: Casper Neo <cneo@google.com>
2022-02-24 13:49:59 -05:00
Derek Bailey
c9571d9897 Replaced ToDasherCase with ConvertCase (#7131) 2022-02-23 22:31:40 -06:00
Derek Bailey
3694b830a2 Use ConvertCase instead of Make{Upper,Lower,Snake} implementations (#7127)
* Unified name case conversion to single method

* Convert bfbs_gen to use ConvertCase

* convert rust to use ConvertCase

* Convert idl_parser to use ConvertCase

* Convert MakeScreamingCamel to ConvertCase

* Replaced MakeCamel with ConvertCase

* minor fixes
2022-02-23 18:08:11 -06:00
Derek Bailey
0471fa807c remove stall reference to version 2022-02-22 16:41:42 -08:00
Derek Bailey
914344ea9b some minor help edits 2022-02-22 15:52:51 -08:00
Derek Bailey
b40266c56f Use target_compile_features to target C++11 (#7122) 2022-02-22 17:12:11 -06:00
Derek Bailey
8a9303d464 update proto tests with alaised enum (#7121) 2022-02-22 01:03:46 -06:00
Derek Bailey
30c4bf47f9 Trigger fuzzing CI only on relevant changes (#7120) 2022-02-21 23:44:04 -06:00
Derek Bailey
46ce45601b remove auto generate code from cmakelists (#7119) 2022-02-21 23:33:42 -06:00
anov21
433312c55a add the missing checkNullConditionnal code in the "GenObjApi" function when the field is scalar optional (#7114) 2022-02-21 22:34:37 -06:00
James Kuszmaul
9c52ec3744 Add deps attribute to flatbuffer_cc_library (#7107)
I'm not seeing the reason why we didn't attempt to support transitive
dependencies for flatbuffer_cc_library, and the current setup makes
having to propagate new dependencies to all of their recursive
dependents obnoxious.
2022-02-21 22:33:47 -06:00
Derek Bailey
70e2f49bff fixed string-json -> strict-json typo 2022-02-21 20:26:40 -08:00
tira-misu
5ac0367ed3 [TS] Fix generation of reserved words in object api (#7106) (#7115)
* 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

* [TS] Fix reserved words as arguments (#6955)

* [TS] Fix generation of reserved words in object api (#7106)
2022-02-21 22:13:40 -06:00
Meer Suri
5d101afb52 Fix minor typo in WhitePaper.md (#7108) 2022-02-18 21:29:21 -08:00
Christopher Crawford
06f4af11b6 Go optional scalars (#7104)
* [go] always write required types

* support optional scalars in go

* generate optional_scalars and monster_test

* restore original behavior for non-optional scalars

* add tests
2022-02-16 15:02:54 -05:00
Derek Bailey
57e338f819 explicitly use windows-2019 to unblock ci (#7105) 2022-02-15 18:10:53 -08:00
Casper
615616cb55 Change Rust generated file defaults (#7101)
* Change Rust generated file defaults

After #6731, flatc changed its default behavior
for generating rust code to fix some importing issues.
This was a breaking change which invlidated the patch release,
`flatc 2.0.5` (#7081). This PR reverses the default so we can
release a patch update. However, does break Rust users who work at
HEAD.

* Bump flatc patch version (2.0.6)

Co-authored-by: Casper Neo <cneo@google.com>
2022-02-15 11:48:42 -05:00
Wouter van Oortmerssen
3413c33004 Fixed FlexBuffers verifier fuzzer timing out
Change-Id: I3a408da08676e522069adf83730d6bcc2b5493b3
2022-02-14 12:01:52 -08:00
Wouter van Oortmerssen
69f5660a44 Fixed Parser not checking size of union types vector
Change-Id: Ibcfc49a9c9376372bd15da2ed3a7f7a298863ccc
2022-02-14 11:48:46 -08:00
Wouter van Oortmerssen
d5add9fca5 Fixed FlexBuffers ToString unquoted non-ident keys
Change-Id: I0a17ee292c9eebbb1e9b2530c07d37d63b4dda24
2022-02-14 11:28:31 -08:00
Aaron Riekenberg
15df50eb7f Remove @ExperimentalUnsignedTypes annotation from kotlin code generator. (#7092) 2022-02-13 20:29:36 -08:00
Matt Grippaldi
a94132a45f Swift FlatBufferBuilder.sizedByteArray to ByteBuffer.toArray() (#7093)
* Moved code from FlatBufferBuilder.sizedByteArray to ByteBuffer.toArray() in Swift

* ByteBuffer.toArray() to  ByteBuffer.underlyingBytes
2022-02-11 13:26:16 -08:00
Björn Harrtell
48befb6bef [TS] Refactor away circular ref (#7099) 2022-02-11 09:40:09 -08:00
qazwsxedcrfvtg14
b300691336 Add reflection support for python (#7026)
We already have the reflection.fbs file and the flatbuffers
python language support.

Adding this feature would give the python developers the
ability to parse the flatbuffers schema and write some tools.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-02-10 11:10:47 -08:00
Derek Bailey
faadbc10ea Add CreateVector overload to accept array like (#7095) 2022-02-09 22:16:46 -08:00
Derek Bailey
ed6ae8d322 explicitly defined std::allocator (#7094) 2022-02-09 15:09:52 -08:00
Timo Sturm
e910bddbcc [JS] Add ".js" suffix to all import statements to generate a browser compatible mjs version. (#7086) 2022-02-08 12:21:20 -08:00
Derek Bailey
c85fb690f4 Add Parsing Completed function for Rust (#7084) 2022-02-08 07:40:55 -08:00
Marcin Witkowski
c1daa6ba0c rust: Bump thiserror version and remove git dependency (#7080) 2022-02-04 16:02:02 -05:00
Derek Bailey
4c71c7b023 replace framework include of flatbuffers (#7079) 2022-02-03 17:40:15 -08:00
godcong
f5664d33fb fix go_test implement error (#7012)
* fix(grpc): fix go_test implement error

* fix(grpc): fix go_test implement error
2022-02-03 08:43:28 -08:00
Derek Bailey
39c8a19ce2 fixed comparator for native_inline (#7076)
* fixed comparator for native_inline

* added native_inline data

* updated more tests for the new field

* more fixes
2022-02-02 23:44:43 -08:00
Derek Bailey
826193ff68 skip generating reflection.fbs in generate_scripts (#7077) 2022-02-02 22:42:26 -08:00
Derek Bailey
fd0d1ed929 update C++ generator to emit scoped enums in vector of unions (#7075) 2022-02-02 22:29:21 -08:00
Derek Bailey
424988f308 replaced removed xml tag 2022-02-02 15:15:50 -08:00
Derek Bailey
b2550dbaa9 removed BSD-3-Clause license and Zlib licenses (#7073) 2022-02-02 13:12:01 -08:00
nicked
a2b238960f Fixed default value of bool in struct for Swift (#7072) 2022-02-02 23:39:19 +03:00
Derek Bailey
619b784374 one last dart omit local (#7070) 2022-02-01 22:25:52 -08:00
Derek Bailey
68a7661546 more omit type annotations for dart local variables (#7069) 2022-02-01 21:48:36 -08:00
Derek Bailey
7dac9961f0 omit type annotations for dart local variables (#7067)
* omit type annotations for dart local variables

* fixed some errors
2022-02-01 21:24:04 -08:00
Derek Bailey
c65c389c6d add xmlns to .Net (#7066) 2022-02-01 20:57:13 -08:00
mustiikhalil
6446dcf3d6 Updates swift gen licence for grpc code (#7063) 2022-02-01 14:23:38 -08:00
Derek Bailey
e090d8da17 Fixed long cast to int in flexbufferbuilder.java (#7059) 2022-02-01 12:58:10 -08:00
Derek Bailey
bc901436db clang format on codebase (#7058) 2022-02-01 11:23:18 -08:00
Derek Bailey
240be9b5ae attempt to remove appveyor (#7056) 2022-01-31 21:52:15 -08:00
Derek Bailey
bc366a7f9e Provide a short help text and default in error case (#6992)
* Provide a short help text and default in error case

* clean up short options a bit
2022-01-31 21:24:48 -08:00
Derek Bailey
14b19d446f Use FindPython3 (#7055) 2022-01-31 20:47:12 -08:00
Derek Bailey
9e6f17b94d remove BIICODE 2022-01-31 19:01:55 -08:00
Derek Bailey
c3801ad375 Update readme.md
Remove travis badge
Added Github action badge
Add dbaileychess twitter
2022-01-31 17:00:24 -08:00
mustiikhalil
4f3b24db09 Fixes a bug where bools arent being nil when marked optional (#7051) 2022-01-31 18:12:57 +03:00
Max Burke
1d294a31b8 Implement Serialize on generated rust types (#7022)
* fix for rust build

* Rust: Implement Serialize on generated types

For debugging convenience it is really handy to be able to dump out
types as another format (ie: json). For example, if we are logging a
type to a structured logging system, or even printing it out in a
structured way to the console.

Right now we handle this by shelling out to `flatc` which is not ideal;
by implementing Serialize on the generated types we can use any of the
Serializer-implementing packages for our structured debug output.

* clang-format

* Make the flatbuffers Rust crate only have an optional dependency on the `serde` packages.

* fix warning

* fix rust test build

* Oh yeah this needs to be initialized

* fix toml syntax

* code review feedback

* rebuild test data
2022-01-30 19:29:18 -05:00
Derek Bailey
dd8fccfb1b Cmake 3.16 de-facto minimum version (#7049) 2022-01-30 12:56:16 -08:00
Derek Bailey
7089c9ecdd Convert flatbuffers_version_string to inline function (#7046)
* Skip conditional for python executable

* replaced flatbuffers_version_string with inline function

* use const char* instead of string
2022-01-29 19:42:56 -08:00
Jean-François Roy
43203984f7 [C++] Support C++ object copies and moves (#5988)
Augment the C++ generator to emit a C++ copy constructor and a by-value
copy assignment operator. This is enabled by default when the C++
standard is C++11 or later. These additional functions are only emitted
for objects that need it, typically tables containing other tables.

These new functions are declared in the object table type and are
defined as inline functions after table declarations.

When these new functions are declared, a user-defined
explicitly-defaulted default constructor and move constructor are also
emitted.

The copy assignment operator uses the copy-and-swap idiom to provide
strong exception safety, at the expense of keeping 2 full table copies
in memory temporarily.

fixes #5783
2022-01-29 14:24:24 -08:00
Max Burke
5993338ee3 [ts] Builder incorrectly serializing empty strings (#7047)
* [ts] Builder incorrectly serializing empty strings

The builder was returning an offset of zero for empty strings. This is
leading to flatbuffers which fail verification in other languages, such
as Rust.

* tests expect 0 offset for null or undefined strings
2022-01-29 14:23:57 -08:00
Justin T Conroy
19920db39f Include a SizePrefixed..HasIdentifier for c++. (#6871)
* Include a SizePrefixed..HasIdentifier for c++.

* Add updated generated code.
2022-01-28 20:52:32 -08:00
Derek Bailey
dbbaeac85c Use ${PYTHON_EXECUTABLE} instead of py in cmake (#7042)
* Emit include for bfbs-gen-embed

* Use python3 explicitly

* bump min python version to 3.6

* Sort find_package for python

* try casting Path to string

* cast WindowsPath to string to please CI

* stringify the wrong thing

* another stringify path
2022-01-28 15:00:57 -08:00
Derek Bailey
028f0fde62 'flattest': Add --test_path option (#7041) 2022-01-27 14:21:01 -08:00
MS
87343631b9 Added support for clang-cl on windows (CMake) (#7038)
* Moved the CMake check for Clang *after* the one for MSVC, as clang-cl
  matches both Clang and MSVC.
* Removed /MP definition - controlled by CMake
* Added CPP define for _CRT_SECURE_NO_WARNINGS so clang can see it
  (it seems it doesnt pick up the pragma in util.cpp)
2022-01-27 10:48:01 -08:00
LouisP
1fbfaf5c5e Fix/cmake build grpc (#7028)
* BuildFlatbuffers.cmake: add verbose on build

* BuildFlatbuffers.cmake: properly add *.fb.* files with --grpc argument

When "--grpc" argument is provided as an extra flag, resulting grpc files
should be added as part of the interface library.
This prevent adding .fb.cc files manually to the build.

V2: fix dependency on grpc files
2022-01-25 20:57:31 -08:00
BogDan Vatra
4421375bb6 Add FlatBuffers::FlatBuffers interface, needed for FetchContent_Declare (#7023) 2022-01-25 20:51:00 -08:00
Jon Simantov
162ad7a37e Fix comment with line orders - Rust should be last. (#7037)
Fix for #6867.
2022-01-25 16:43:08 -08:00
Jon Simantov
a0a6c3f8c6 Use actions/checkout@v2, which fixes security vulnerability. (#7036)
Fix for issue #6999.
2022-01-25 16:19:05 -08:00
Jon Simantov
a2d38fbb98 Add --warnings-as-errors to flatc compiler. (#7034)
* Add --warnings-as-errors to flatc compiler.

With this option set, flatc will return an error on parsing if
any warnings occurred.

* Add unit test for opts.warnings_as_errors.

* Change explicit option setting to default.
2022-01-25 14:01:16 -08:00
Derek Bailey
9ef1524d3f Emit include for bfbs-gen-embed (#7031) 2022-01-25 10:43:16 -08:00
Derek Bailey
0c9de0352a Upgraded GRPC version to 1.42.0 (#7033) 2022-01-25 09:59:29 -08:00
Ivan Dlugos
a783bc9267 chore: dart 2.0.5 release changes (#6983) 2022-01-20 13:30:03 -08:00
Marcin Witkowski
aff818cebf rust: Allow for usage in no_std environment (#6989) 2022-01-20 11:49:02 -05:00
Danila Kutenin
d7b75417fc Make flatbuffer builder deterministic (#6993) 2022-01-14 15:37:27 -08:00
Wouter van Oortmerssen
a42e898979 Added verifier alignment checking to table fields (#7018) 2022-01-14 14:39:15 -08:00
LouisP
96cc2f3ee3 BuildFlatBuffers.cmake: fix arguments not passed properly to flatc (#7013)
Fix regression introduced by commit e9d4532401
2022-01-14 14:38:04 -08:00
Richard A Hofer
3250a1f8dd Add initial C# vector of unions support to the documentation. (#6880)
* Add initial C# vector of unions support to the documentation.

* Add notes about missing documentation for vector of unions.
2022-01-13 22:15:35 -08:00
Alex E
ace4a37f22 [TS/JS] BigInt implementation (#6998)
* BigInt implementation

* Unit test reading long from existing bytebuffer

* Code review
2022-01-06 20:35:37 -06:00
Advait Jain
f28c2b2936 Avoid implicit conversion from float to double. (#7003)
https://github.com/tensorflow/tflite-micro makes use of flatbuffers with
a variety of DSP toolchains.

Without the change from this PR, we can get a double-promotion warning
with some of these DSP toolchains:
```
flatbuffers/include/flatbuffers/util.h:104:11: error: implicit conversion increases floating-point precision: 'std::numeric_limits<float>::_Ty' (aka 'float') to 'double' [-Werror,-Wdouble-promotion]
  T eps = std::numeric_limits<float>::epsilon();
    ~~~   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
2021-12-23 20:31:30 -06:00
Shlomi Regev
96f3cf690f Rearrange #include directives to pass to compilation with a particular DSP toolchain (#7000)
iomanip isn't available for our DSP. Luckily, we compile with FLATBUFFERS_PREFER_PRINTF, so moved the #include directive there.
ctype.h has to be included explicilty for tolower() and toupper().
2021-12-22 10:40:38 -06:00
Panagiotis Gourgaris
b3edfdbfb7 Reverting grpc generated file suffix (#6995)
* Reverting grpc generated file suffix

* - Setting the greeter sample as it was
- Reverting the include of the generated message in grpc.cc file
2021-12-18 18:23:28 -08:00
Wouter van Oortmerssen
b8aaccee82 Disable parsing of nested_flatbuffers as bytes by default
Parsing as bytes produces buffers that are unsafe to access unless passed thru a verifier,
whereas users could reasonably assume that any JSON parsed without errors is safe to access.
Users that still have legacy JSON files with such bytes in it will get a helpful error point them
to the option to turn on to have it work again.
2021-12-15 10:41:29 -08:00
Wouter van Oortmerssen
2dc8ae7742 Enable OSS-Fuzz on CI 2021-12-14 12:10:43 -08:00
Wouter van Oortmerssen
5b0d491127 Updated FlexBuffers fuzzer 2021-12-14 11:57:42 -08:00
Wouter van Oortmerssen
d8b7041d7e Added alignment checking to FlexBuffers verifier 2021-12-14 11:20:23 -08:00
Wouter van Oortmerssen
5a0c3366c3 FlexBuffers verifier additionally checks for nesting 2021-12-14 11:20:23 -08:00
Wouter van Oortmerssen
f8148b8dad Made FlexBuffers reuse tracker track types 2021-12-14 11:20:23 -08:00
Derek Bailey
a22b1b6267 Prevent shadow with _{{FIELD_NAME}} (#6991) 2021-12-13 21:27:36 -08:00
Wouter van Oortmerssen
4264daadd2 FlexBuffers fuzzer fixes
- String dedup wasn't handling internal nulls correctly.
- Verifier wasn't recursing for certain types.
- Vector self-reference could create inf recursion.
2021-12-13 15:47:06 -08:00
Derek Bailey
3cbc120a08 Refractor Flatc Options (#6987)
* Moved error/warnings to bottom of std error

* Refactor flatc options

* pass program name to flatc

* extra -- in one option

* merge of upstream
2021-12-13 13:56:47 -08:00
Vadim-Valdis Yudaev
8dcd2682c7 [CMake] Add option for disable universal on OSX (#6990)
See https://github.com/google/flatbuffers/issues/6988
2021-12-13 13:32:58 -08:00
Derek Bailey
b78002ff3e Validate C# json/object-api options (#6985) 2021-12-13 11:52:01 -08:00
Derek Bailey
c555ee8fac Add .NET test to github workflows (#6982) 2021-12-13 11:51:27 -08:00
Biswapriyo Nath
b92bb0584d [CMake]: Fix version in pkgconfig file (#6986)
This change checks if the current source directory is a git repository.
If this is not checked the git command picks the commit hash from
parent directory. e.g. when tarball is extracted in a packaging repository.
2021-12-10 15:40:21 -08:00
Wouter van Oortmerssen
956d11569e re-enabled FlexBuffer JSON in fuzzer 2021-12-10 15:22:06 -08:00
Wouter van Oortmerssen
e367ca32ad Verifier for FlexBuffers (#6977)
* Verifier for FlexBuffers

* Verifier improvements & fuzzer
2021-12-10 14:59:08 -08:00
Biswapriyo Nath
705f27f6ee [CMake]: Fix python command for mingw environment (#6984)
In mingw build environment, this fixes the build error:
'py' is not recognized as an internal or external command
The 'py' launcher is available for MSVC python only. More
https://docs.python.org/3/using/windows.html#from-the-command-line
2021-12-10 11:28:24 -08:00
lu-wang-g
5fc87f4c4b Enable --gen-onefile in Python (#6953)
* Enable --gen-onefile in Python

Made it possible to generate all python code in one file. Modified
py_test.py so that it can switch between the multi-file code and
the one-file code.

Updated PythonTest.sh and py_test.py so that the multi-file code
and the one-file code can be tested based on the same test code.

* Sync with google/flatbuffers

* Add --gen-onefile to generate_code.py
2021-12-09 15:47:09 -08:00
Danila Kutenin
11749095a1 Make idl_parser deterministic (#6976)
* Make idl_parser deterministic

Some golden tests even exercise this [logic](df2df21ec1/tests/prototest/test.golden (L8)). Let's make the parser fully stable not depending on the implementation of std::sort

* Retry the ci
2021-12-09 13:07:29 -08:00
Derek Bailey
d0cede9c90 Bumping to Version 2.0.5 (#6967) 2021-12-09 10:31:57 -08:00
David Sanders
fcc2bee0b6 Fix typo in variable name (#6973) 2021-12-09 10:30:15 -08:00
Derek Bailey
e08da4dea2 remove Appveyor's Vs2010 and 13 builds (#6969) 2021-12-06 14:18:22 -08:00
tira-misu
18538c401c [TS] Fix reserved words as arguments (#6955) (#6956)
* 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

* [TS] Fix reserved words as arguments (#6955)
2021-12-06 14:16:04 -08:00
Derek Bailey
e57f4ab2d2 Update stale bot version and provide away to exempt issues with the not-stale label (#6968) 2021-12-03 13:51:05 -08:00
Derek Bailey
deed68db5d missing generated files (#6966)
These shouldn't be used, so short circuiting CI.
2021-12-03 11:23:58 -08:00
Derek Bailey
061d61f3f8 Lua Generator using IR. (#6940)
* initial hack to get new Lua generator into flatc

* Starting to output enum defs for Lua

* Continue to work on table generation for Lua

* Finished basic getter access for Lua

* Added ability to get object by index

* Finished struct builder

* aliased reflection to r

* finish table builder generation

* register requiring files

* better generated header info

* Tying up loose ends

* Updated reflection to handle struct padding

* Addd type sizes to reflection

* Fixed some vector indirect issues

* Lua tests passed

* Misc cleanup

* ci fixes 1

* ci fixes 2

* renaming

* up size of type sizes

* manually ran clang-format-11 -i src/idl_parser.cpp

* fixed some windows casting

* remove stupid auto import

* more static_casting

* remove std

* update other build environments

* remove scoped enums

* replaced std::to_string with NumToString

* more win fixes

* more win fixes

* replaced old lua with new

* removed auto import

* review responses

* more style fixes

* refactor bfbs_gen_len to use code +=

* added consts

* fix lambda capture for windows

* remove unused return type
2021-12-02 21:29:19 -08:00
Markus Junginger
cffe0c4546 FixedTypedVector: add const to ElementType() and size() (#6965) 2021-12-02 20:32:51 -08:00
Panagiotis Gourgaris
fadd40e402 Have grpc include file with correct filename-suffix given to flatc (#6954)
When generating code with --grpc,  --cpp and using filename-suffix, the generated grpc files where not including the correct header that had the filename-suffix. As a suffix, they used the default "_generated".
Free functions for these were used to get the suffix. FlatBufFile had such methods, but also needed to be into its base File and use these.
- grpc generated files include the correct message header.
- grpc generated files also have the suffix
- grpc generated cc file does not include initial message header
2021-12-02 09:49:12 -08:00
Derek Bailey
e47dc0e465 Removed test/generate_code.{sh|bat} (#6873)
* removed test/generate_code.{sh|bat}

remove c++0x from generate_code.py

added check generate code script in python

add windows specific call

added flags to generate_code.py

Set c++-0x on BUILD_LEGACY

Skip generating monster_extra if requested

* added option to skip monster extra

* add conditional to skip 2010 check gen
2021-11-30 23:13:24 -08:00
Derek Bailey
5c54754790 switched to windows-lastest, removed deadcode (#6948) 2021-11-30 23:12:57 -08:00
engedy
4f7f6dc301 Restore FlatBufferBuilder::kFileIdentifierLength. (#6960)
Restore flatbuffers::FlatBufferBuilder::kFileIdentifierLength, which was a documented part of the public API, but the identifier was lost during the refactoring effected by comment commit 6c8c291559.
2021-11-30 23:06:19 -08:00
Wouter van Oortmerssen
0fadaf391d Enable verifier on nested_flatbuffers 2021-11-29 15:05:59 -08:00
Wouter van Oortmerssen
4d0e9a8706 Turn off nested FlatBuffers/FlexBuffers for the fuzzer
this is a temporary fix to allow the fuzzer to work until the real fix of adding a verifier for this is added.
2021-11-29 09:19:29 -08:00
Derek Bailey
c05f6783a6 invalid conditional running genrate_code.py (#6952) 2021-11-23 22:32:06 -08:00
Élie ROUDNINSKI
a14f4052cf rust: remove needless borrow (#6922)
This was discovered by running clippy.
2021-11-23 10:46:56 -06:00
Derek Bailey
9e4ca857b6 Vector Downward GetSize optimization (#6925)
* Added Google benchmarks (and gtests)

* Separate benchmark CMakeLists.txt to its own file

* Move output directory to target just flatbenchmark

* Reduced from encoding 210ns -> 188ns

* store size_ as uoffset_t

* fixed windows c4267 warning
2021-11-22 19:50:42 -08:00
jonathan-conder-sm
a2b99084b4 Fix flexbuffers clang-analyzer warning (#6947) 2021-11-22 13:37:36 -08:00
Sergei Trofimovich
85b4effac6 test: fix undefined order of functio parameters. (#6946)
Detected instability when built `flatbuffers-2.0.0` on `gcc-12`:

    [ 75%] Building CXX object CMakeFiles/flattests.dir/tests/test_builder.cpp.o
    .../c++/12.0.0/bits/shared_ptr_base.h:397:45: error: 'size' may be used uninitialized [-Werror=maybe-uninitialized]
      397 |       explicit _Sp_ebo_helper(_Tp&& __tp) : _M_tp(std::move(__tp)) { }
          |                                             ^~~~~~~~~~~~~~~~~~~~~~
    In file included from flatbuffers/tests/test_builder.cpp:1:
    flatbuffers/tests/test_builder.h: In function 'void builder_move_assign_after_releaseraw_test(Builder) [with Builder = flatbuffers::FlatBufferBuilder]':
    flatbuffers/tests/test_builder.h:63:10: note: 'size' was declared here
       63 |   size_t size, offset;
          |          ^~~~
    ...
    In file included from flatbuffers/tests/test_builder.cpp:1:
    flatbuffers/tests/test_builder.h: In function 'void builder_move_assign_after_releaseraw_test(Builder) [with Builder = GrpcLikeMessageBuilder]':
    flatbuffers/tests/test_builder.h:63:10: note: 'size' was declared here
       63 |   size_t size, offset;
          |          ^~~~
    cc1plus: all warnings being treated as errors

Here is the relevant bit of test:

    template<class Builder>
    void builder_move_assign_after_releaseraw_test(Builder b1) {
      auto root_offset1 = populate1(b1);
      b1.Finish(root_offset1);
      size_t size, offset;
      std::shared_ptr<uint8_t> raw(
          b1.ReleaseRaw(size, offset), [size](uint8_t *ptr) {
            flatbuffers::DefaultAllocator::dealloc(ptr, size);
          });

Note how `b1.ReleaseRaw(size, offset)` is expected to populate `size`
and `[size](uint8_t *ptr) {` captures the result. But both are parameters
to the same function call and thus evaluation order is unspecified.
2021-11-22 12:14:31 -08:00
Denis Protivensky
790f411542 [cmake] Fix getting version info from tags during the build (#6936)
Use `git describe --tags` to query for lightweight tags along with
the annotated ones.
2021-11-22 11:53:50 -08:00
Derek Bailey
e89de4411d clang-all (#6941) 2021-11-19 17:01:48 -08:00
Ivan Dlugos
256ab3798d WIP: Dart release 2.0 (#6927)
* chore: make flatc artifacts from CI executable

* chore: prepare dart 2.0.0 release

* refactor: update description in pubspec.yaml to make pub.dev happy

"The package description is too long.
Search engines display only the first part of the description. Try to keep the value of the description field in your package's pubspec.yaml file between 60 and 180 characters."
2021-11-18 10:56:29 -08:00
Derek Bailey
a59288a019 Add benchmarks to Linux CI (#6928) 2021-11-18 10:55:57 -08:00
Taiju Tsuiki
587bbd49a7 [C++] Fix compile failure on Object API union construction for struct member (#6923)
* Add dedicated traits to Object API version of unions.

* Add suppression for unused parameters on unions of structs.
2021-11-18 10:55:11 -08:00
Wouter van Oortmerssen
a9c341545f Fix integer overflow warnings 2021-11-18 09:41:44 -08:00
Derek Bailey
8aa18b6291 fixed cmp0048 error (#6932) 2021-11-17 20:22:23 -08:00
Catena cyber
d727579b6d fuzzers: fix typo in file path (#6931) 2021-11-17 14:43:56 -08:00
Derek Bailey
97a30171cb Added Raw C++ benchmarks (#6924) 2021-11-15 15:19:03 -08:00
Derek Bailey
0989fc5e59 Added Google benchmarks (and gtests) (#6920)
* Added Google benchmarks (and gtests)

* Default building benchmarks to OFF as it requires c++11

* Separate benchmark CMakeLists.txt to its own file

* Move output directory to target just flatbenchmark
2021-11-15 13:41:22 -08:00
taroplus
927175ea20 [Java] lookup by byteArray is giving back wrong entry (#6915) 2021-11-15 11:16:45 -08:00
Wouter van Oortmerssen
6748c373be Removal of support for FLATBUFFERS_CPP98_STL (#6918)
* Removal of support for FLATBUFFERS_CPP98_STL

For context, see https://github.com/google/flatbuffers/issues/6704

* Also removed vector_data
2021-11-12 14:01:11 -08:00
Derek Bailey
3fab0c6ee4 move [[ ]] to calling sites (#6914) 2021-11-11 10:31:15 -08:00
Derek Bailey
6c8c291559 [C++] Split flatbuffers.h into separate files (#6868)
* split flatbuffers.h into separate files

* wrong variable in cmakelists for android

* readded two accidentally deleted includes

* created buffer.h and moved buffer related things over
2021-11-10 22:26:09 -08:00
lu-wang-g
fd4ff23da0 Keep methods with struct name and switch them to default (#6879)
* Keep methods with struct name and switch them to default

This PR can help fix the following two issues:
1): A set of simplified API (without struct name) was added in
https://github.com/google/flatbuffers/pull/6336. It causes name
conflict when merging all generated python file into a single one
(the primary usage senario in Google).
2): Flatbuffers 2.0 generates absolute import path, which may cause
name space conflicts. See more details in
https://github.com/google/flatbuffers/issues/5840.

The solution for both is to generate the merged Python code, similar
C++. The merged code will not contain the simplied API, but only the
method with struct name. For issue (1), it will mimic the exactly
usage pattern for Google internal. For issue (2), users can generate
the merged flatbuffer code, without worrying about the imports.

The above idea will be implemented in the following steps:
Step 1 (this PR): revert changes in https://github.com/google/flatbuffers/pull/6336
that set the simplified API as default. Remove statements that the
original API will be deprecated, and reset the original API as default.
Step 2 (the following PR): create a flag to generate the merged code.
The Simplified API will be removed from the merged code, otherwise it
will cause name conflict.

* Update the generated sample code

* Update the generated example code

* Reverst the changes of GetRootAs

* Update examples from grpc/example/generate.sh
2021-11-04 15:12:25 -07:00
Tom Miller
f8b69e3308 [Python] Verify EnumDef is not generated in GenUnionCreator (#6903)
* [Python] Verify EnumDef is not generated in GenUnionCreator

* update test output
2021-11-04 14:21:31 -07:00
Alec Theriault
c0394bb09c Support --conform for vector of unions (#6883)
It seems like `--conform` already works for vectors of unions - there is
just a spurious check that prevents it from running. Fixes #6882

Also, if schemas do not conform, `flatc` no longer prints out the usage
(since the error is not due to bad usage). Fixes #6496
2021-11-01 11:26:36 -07:00
Even Rouault
8433eb108c Typo fixes in comments of flatbuffers.h and flexbuffers.h (#6901) 2021-10-28 13:03:03 -07:00
Fraser Crossman
f2f9380c86 [Java] Prevent generation of enum names when underlying type is long (#6781) (#6895) 2021-10-18 15:18:36 -07:00
xuyatian
e672dabfea [C++] Fix memory leak when using grpc (#6896) (#6897) 2021-10-18 11:24:52 -07:00
Brian King
9a4ca2764c Output errors / warnings on stderr instead of stdout (#6881) 2021-10-07 14:58:10 -07:00
mustiikhalil
4c7a9c10d3 Adds JSON encoding to swift (#6874)
Updates generated code & removes unneeded protocol

Updates cpp to only generate code when flag is passed

Updates code gen script
2021-10-07 23:22:22 +02:00
Paulo Pinheiro
38295a1873 [Kotlin] Fix missing escape for struct construction statements (#6877)
An escaping was missing leading to wrong generation when using
kotlin keywords.
2021-10-07 13:00:07 -07:00
Derek Bailey
31bb0b9726 add working directory (#6878) 2021-10-05 18:24:00 -07:00
T Sprecher
45e5642e91 Default Arguments for Mutators C++ [Updated] (#6872)
* CPP Default Value Generation in Mutators

If the mutator is for a value that is compatible with having a default value, then the single parameter becomes a default parameter. With this, a value can be mutated to it's default value without storing the default value, as that will be stored with the mutate function.
Fixed Casting When Generating Default for Enum Value

Added support for typecasting an int default value into the correct enum type in the default parameter. This fixed the issue of trying to use set a strongly typed enum parameter to an int which fails type checking.
Fixed Boolean Edge Case

Boolean types generate 0 != 0 when generating the underlying type which appears to be unique to the boolean type so it is now checked and the proper default value generated. It may be beneficial to check if it is instead an enum type, however the seeming edge case nature is why boolean was chosen to be checked.
Updated Generated Files

Regenerated the auto generated files to reflect the new changes.
Updated Remaining Files

Should fix auto generated header files that were not updated.

* Unified Repeated Code

Relocated identical append code to outside of conditional. Also changed 'casted' default value name from FIELD to INTERFACE to more accurately describe it.

* Moved Field Name Outside Conditional

Removed duplicate _{{FIELD_NAME}} and moved to unified append.
2021-09-30 16:44:39 -07:00
Derek Bailey
a592f4c89e [Cmake] Add a post build command after flatc to run the new generate_code.py script. (#6866)
* starting to add python script

* finish first draft of script

* add windows-specific edits

* Add cmake post flatc build generated_code.py command

* fixed windows issue

* Provided flatc location to generate_code.py

* Allow relative flatc pathing and fix macro typo

* escape post build arguments

* change script and args quoting

* skip running generate_code.py on old MSVC compilers
2021-09-30 12:38:52 -07:00
Ivan Dlugos
b9d43a557c dart - add Packable interface (#6846) 2021-09-28 13:23:30 -07:00
Wouter van Oortmerssen
2ece9e25b4 Bumped package.json to 2.0.4
See https://github.com/google/flatbuffers/pull/6850 for context
2021-09-27 15:49:45 -07:00
Yesudeep Mangalapilly
2dd2126379 Fix linker errors on (Free|Open)BSD. (#6860)
* Fix linker errors on (Free|Open)BSD.

* Adds a TODO for the FreeBSD linker flags: -lm and moves platform config to main BUILD.bazel
2021-09-27 12:07:04 -07:00
mustiikhalil
f63c130c28 Improves documentation, and adding DocC (#6784)
Finished documenting flatbuffersbuilder

Replaces swift 5.5 with 5.2 packages

Starts building the tutorial for xcode 13

Finishes building the tutorial for xcode 13

Removes docc files from old swift versions

Updates swift style guide
2021-09-27 20:59:19 +02:00
Derek Bailey
e2b26ee19b Make and generate_code.sh generate same outputs (#6855)
* added --bfbs-builtins

* update generate_code.bat

* forgot the .

* updated checking scripts

* added bypass for the monster_test.bfbs and arrays_test.bfbs diff issue

* removed check on windows for now
2021-09-24 12:01:34 -07:00
Louis DeScioli
9d686bf433 Include subdirectories in published npm package (#6850)
Updates the `files` globs in package.json to include subdirectories in order to also include the flexbuffers directory in the published npm package.

Updates .gitignore to include the tsc-generated JS files.
2021-09-23 16:22:49 -07:00
Louis DeScioli
1d26daff3e Use ArrayBuffer type for JS flexbuffer's toObject (#6851) 2021-09-23 16:22:13 -07:00
Ivan Dlugos
e72e18d9fd feat(build): compile "universal" libraries and executables for Mac (#6852)
to support both x86_64 and arm64 with a single artifact
2021-09-23 12:36:20 -07:00
Derek Bailey
354d97f6da fixed errant itemgroup element in C# test project (#6854)
errant save
2021-09-21 15:01:29 -07:00
Todd Hansen
6f7a57eaa0 [C#] Using 'global::' as qualifying_start_ within BaseGenerator (#6767)
* Update idl_gen_csharp.cpp

Change csharp generator to use "global::" for it's qualifying_start_ to disambiguate namespaces

* regenerate testing files

regenerate testing files

* Missed TableInC.cs

updated with global prefix

* Remove "global::" from qualifying_start_ for csharp generator

* C# global alias

* Tests and docs for --cs-global-alias

Add tests for --cs-global-alias to demonstrate use case for why it's needed.

Add documentation to Compiler.md

* Add also to help text

Add also to help text
2021-09-15 16:57:29 -05:00
Ivan Dlugos
90baa1444b Dart: binary lists (typed_data) (#6839)
* Dart - add eager mode to Uint8ListReader

* Dart - add Int8ListReader

* Dart - use binary reader where useful

* Dart - test binary list reader laziness

* Dart - update generated code
2021-09-15 08:50:57 -07:00
Casper
0a3b017f09 Delete IDLOptions::lang (#6841)
Co-authored-by: Casper Neo <cneo@google.com>
2021-09-13 18:18:00 -04:00
Artavazd Balaian
47d35f1053 BugFix: Optional enum when it is null (#6835)
* Test to make sure optional enum is written properly

* Handle optional enum codegen: when cast optional enum add `?`

* Run `tests/generate_code.sh` to generate code from schema

* Fix type casting in case of CreateXXXTypeVector

* Reason why vector's type is not optional
2021-09-10 12:55:46 -04:00
Derek Bailey
8fb8c2ce1d [C#] Use @ for keyword escaping (#6834) 2021-09-09 10:29:27 -07:00
Maksim Ivanov
1d063d87cf [C++] Let builder accept custom-alloc std::vector (#6814)
Change the FlatBufferBuilder's methods to accept std::vector parameters
with non-default allocator, by adding another template parameter to
them. This should make using the builder slightly more convenient, as
one won't need to manually pass data() and size() separately.
2021-09-08 13:25:06 -07:00
Herr Frei
338331b55b Changes to support binary schema file loading and parsing (flatc) (#6823)
* Changes to support binary schema file loading and parsing (flatc)
- parser.reset() is also called if binary schema file is given
- code flow changed to not try to load a binary schema as textual schema

* Removed unneeded braces
2021-09-08 13:19:00 -07:00
Rafal Kapuscik
156a30c753 Move Apple-specific build flags to Clang section (#6802)
This allows building FlatBuffers with gcc on macOS:
- avoid linking libc++ when not using clang
- look at compiler first, then OS-specific options

Signed-off-by: Rafal Kapuscik <rkapuscik@antmicro.com>
2021-09-08 13:14:53 -07:00
schoetbi
550d2f9048 Issue error if jsonschema has no root type defined #6821 (#6831) 2021-09-02 14:24:47 -07:00
SaintMalik
c3a38242e6 Fix typos in docs (#6829) 2021-09-02 11:38:45 -04:00
Tyler Denniston
74c3d7eba2 [C++] Add mutable version of LookupByKey and test (#6826)
* [C++] Add mutable version of LookupByKey and test

This adds an overload of LookupByKey to allow lookup in sorted Vectors to
return a mutable instance of the object (or nullptr if not found).

* Fix naming
2021-08-31 17:17:20 -04:00
Casper
db6eae5c42 Add html and latex to gitignore (#6819)
Co-authored-by: Casper Neo <cneo@google.com>
2021-08-30 16:36:00 -07:00
Björn Harrtell
0e9d79c355 [Java] Avoid casting ByteBuffer to Buffer (#6785)
* Revert "avoiding even more NoSuchMethod exceptions (#6729)"

This reverts commit 6fb2c90d9e.

* Revert "avoiding more NoSuchMethod exceptions (#6671)"

This reverts commit 752c7b576d.

* Revert "avoiding NoSuchMethod exception (#6658)"

This reverts commit 813d3632ec.

* Use Java 8 for Kotlin Linux builds to verify
2021-08-30 15:51:06 -07:00
Stefan F
b20c4d3aad [C++] Add GetMutableSizePrefixedRoot and generate GetMutableSizePrefixedXxx functions (#6815)
* flattests_cpp17 doesn't compile with Visual Studio 2017: warning C4100: 'indent': unreferenced formal parameter

stringify_util.h(127): error C2220: warning treated as error - no 'object' file generated
stringify_util.h(127): warning C4100: 'indent': unreferenced formal parameter
stringify_util.h(85): warning C4100: 'indent': unreferenced formal parameter
stringify_util.h(85): warning C4100: 'fbs': unreferenced formal parameter

* [C++] Add GetMutableSizePrefixedRoot() and generate a GetMutableSizePrefixed function
When using the mutable API together with size prefixed buffers these functions should be present.

* clang-format

* Cleanup branch for PR
Revert "flattests_cpp17 doesn't compile with Visual Studio 2017: warning C4100: 'indent': unreferenced formal parameter"

This reverts commit a92055203e.
2021-08-30 15:34:42 -07:00
Stefan F
ae145293cc flattests_cpp17 doesn't compile with Visual Studio 2017: warning C4100: 'indent': unreferenced formal parameter (#6811)
stringify_util.h(127): error C2220: warning treated as error - no 'object' file generated
stringify_util.h(127): warning C4100: 'indent': unreferenced formal parameter
stringify_util.h(85): warning C4100: 'indent': unreferenced formal parameter
stringify_util.h(85): warning C4100: 'fbs': unreferenced formal parameter
2021-08-30 15:32:36 -07:00
Ivan Dlugos
e3c76a5cde Dart lints (#6808)
* Dart - add analysis options with the recommended lints

* Dart - generate code without linter issues

* Dart - remove linter issues in example and test code

* Dart - remove linter issues in lib code

* Dart - update generate code in /tests/
2021-08-30 12:54:59 -07:00
Casper
4b9123baff fix parser string=null (#6810)
Co-authored-by: Casper Neo <cneo@google.com>
2021-08-24 09:41:39 -04:00
Casper
f89e0b1a6c Refactor idl_gen_rust and Rust generated code to use consistent whitespace (#6809)
* Remove dead code in idl_gen_rust

* Use 2space indentation in mod.rs

* use In/DecrementIdentValue in idl_gen_rust

Fix some whitespace too in generated code.

* make default fn 2space ident

* More 2space formatting

* git clang format

* make vs2015 happy

Co-authored-by: Casper Neo <cneo@google.com>
2021-08-23 18:53:10 -04:00
Casper
273f6084e5 Fix Rust keyword inconsistency (#6794)
* Make Rust keyword escaping more consistent

* fix comment

* git clang format

Co-authored-by: Casper Neo <cneo@google.com>
2021-08-18 15:37:44 -04:00
Todd Hansen
4a0879458d [C#] Remove superfluous semicolon in C# structs (#6791)
Aims to resolve #6788

-Remove superfluous semicolon in C# structs
2021-08-17 11:02:57 -04:00
Casper
d6f51ea16d fix ptr in flatbuffers cpp tutorial (#6787)
Co-authored-by: Casper Neo <cneo@google.com>
2021-08-16 14:43:26 -04:00
Todd Hansen
067dce6e79 [C#] Handle keywords (#6775)
* Handle keywords in C#

C# should handle keywords similarly to other languages by appending an underscore after the keyword.

* Fix clang-format for idl_gen_csharp.cpp

* Fix spacing clang-format issue
2021-08-16 14:09:21 -04:00
Todd Hansen
2ca5f0e72b [C#] Respect command line parameter for file name extension and suffix (#6779)
* Make CSharp use the command line parameter for file name extension and suffix

* Default file name now has _generated in it,
so we need to rename all the generated test files

tests/namespace_test/NamespaceA/TableInC.* are no
longer used, so these can be deleted

* Fix C# testing projects so that they reference
the new _generated.cs files

* Revert "Fix C# testing projects so that they reference"

This reverts commit cf62b9c5d4.

* Revert "Default file name now has _generated in it,"

This reverts commit 042aa81f10.

* Revert "Make CSharp use the command line parameter for file name extension and suffix"

This reverts commit ba8cd06646.

* Make CSharp use the command line parameter for file name extension and suffix

* Fixup clang tidy

* Fix more clang-tidy
2021-08-15 15:51:58 -04:00
Wouter van Oortmerssen
f20d2253ae update Java version to 2.0.3 2021-08-14 09:01:54 -07:00
Paulo Pinheiro
390d438e2a [Kotlin] Fix CI by changing compiler to Java 11 (#6783)
With the changes introduced on #6729, #6671, #6658 it seems that using java
compiler version 8 is no longer possible. We are adjusting our CI build for
Kotlin to use Java 11 as compiler, while still emiting 1.8 bytecode.

The Kotlin CI action is also being breakdown into two: Mac & Linux.
Kotlin mac will test ios & mac builds while Linux will test js and JVM.
This change will improve build times for Kotlin on CI, which is currently
taking long times.
2021-08-14 08:57:38 -07:00
Kamil Rojewski
6fb2c90d9e avoiding even more NoSuchMethod exceptions (#6729)
* avoiding more NoSuchMethod exceptions

refs #6657

* avoiding even more NoSuchMethod exceptions

refs #6657
2021-08-05 12:25:23 -07:00
Björn Harrtell
a7b527d942 java: Use maven profile to target Java 8 bytecode (#6764) 2021-08-05 11:44:13 -07:00
bakinovsky-m
5d77820b34 [C++] Using calculated fields_number for field_names size (#6769)
* using already defined "fields_number" in "field_names" size calculation

* tests

* forgotten test
2021-08-05 11:41:49 -07:00
RWauson
909ce970ae [C++] Use UnPackTo instead of UnPack if pointer exists (#6725)
Causes generated code to check for existing pointers in an object (when using the object based api) and use UnPackTo(existingPointer) rather than just using UnPack() to replace the pointer. This is a performance issue when unpacking to existing objects when using large buffer fields (e.g. image frames)

Co-authored-by: RobWauson <robwauson@gmail.com>
2021-08-05 11:40:03 -07:00
Casper
35e2cac6eb Store vtables sorted in Rust builder (#6765)
* benchmark many vtables

* Rust: Store written_table rev-positions sorted.

The previous implementation was slow if there were too many tables.

Asymototically when inserting the n^th vtable: The old implementation
took O(n) lookup steps and O(1) insertion. The new implementation is
O(log n) lookup and O(n) insertion. This might be improved further by
using a balanced btree.

Benchmarking, create_many_tables is 7.5x faster (on my laptop):

// Simple vector cache
test create_many_tables ... bench: 728,875 ns/iter (+/- 12,279) = 44 MB/s

// Sorted vector cache
test create_many_tables ... bench: 97,843 ns/iter (+/- 4,430) = 334 MB/s

* Fix lints

Co-authored-by: Casper Neo <cneo@google.com>
2021-08-03 12:31:45 -07:00
mogemimi
c39fc9dd9c [C++] Use nullptr instead of 0 in generated headers (#6762) 2021-08-02 13:41:15 -07:00
mogemimi
775c6567d1 [C++] Fix compiler warning -Wredundant-parens in clang (#6761) 2021-08-02 13:40:17 -07:00
Ivan Dlugos
97d9527f6c Dart 2.0 release prep (#6759)
* Dart - pubspec.yaml shouldn't contain authors section anymore - it's unused

* Dart - update CHANGELOG.md

* Dart - update test and publish scripts
2021-08-02 13:31:36 -07:00
Esun Kim
e012054667 [C++] Use proper gRPC C++ API when using MemoryBuffer Slice (#6756)
* Use ByteBuffer

* Use Slice

* Upgrade gRPC to 1.39.0

* Update gRPC build script

* Reformat

* Added CMAKE_CXX_STANDARD=11 when building Abseil

* Enabled ABSL_ENABLE_INSTALL

* Added absl to grpctest deps
2021-07-29 10:41:51 -07:00
Ivan Dlugos
5235133f32 Dart - make ascii optimization optional in StringReader, same as in writeString() (#6758) 2021-07-29 10:39:03 -07:00
Ivan Dlugos
c871df7702 Dart - change table building to assert() instead of exceptions (#6754) 2021-07-26 11:42:42 -07:00
Ivan Dlugos
a6eeeb3b9c Dart - inline small functions to increase performance (#6755)
~25 % for reading
~30-35 % for writing
2021-07-26 10:09:46 -07:00
tira-misu
3dd02144d5 [C#] Fix field name struct name collision (#6744) (#6757)
* 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

* [C#] Fix field name struct name collision (#6744)
2021-07-26 10:02:27 -07:00
mugisoba
e77926f0ed [C#] Add Union Constructor Utility for ObjectAPI. (#6105)
* [C#] add union constructor utility.

* add union utility test.

* std::tolower -> CharToLower

* use std::transform instead

* rebase to master. and regenerate test code
2021-07-26 10:01:41 -07:00
Ivan Dlugos
ac23482022 Dart - fixup writeString() return type after previous merges (#6753) 2021-07-26 09:54:13 -07:00
Taiju Tsuiki
8be8a0a713 [C++] Fix union type handling on object api in C++17 (#6745) 2021-07-25 16:20:34 +07:00
Casper
12e341e4f8 Rework how Rust generated files are laid out (#6731)
* Refactored Rust Generated code into a module directory.

Each symbol will be generated into one file and then
imported into a module. This breaks the "out_dir"
pattern where some users would generate code in their
target/ directory. Also, these objects are best used
in their own module. It will be hard for users to share
their own module structure with flatbuffers namespaces.

There may be solutions to these drawbacks but that should
be discussed. I don't want to overengineer here.

* shadow error

* try fix .bat file

* fix .bat 2

* Restore accidentally deleted files

* Fixed some DONOTSUBMITs and made Rust outdir pattern use symlinks.

* fixed binary files

* git clang format

* make generated onefiles not public and fix .bat

* reduced diff with master in generate_code.sh

* fix shadowed variable

* add object api flags to .bat

* space

* Removed extern crate and extra &

* use statement

* more clippy lints

* format

* Undo extern crate -> use change, it actually matters to our tests

Co-authored-by: Casper Neo <cneo@google.com>
2021-07-22 19:02:28 -04:00
Ivan Dlugos
c36672d803 Dart - optimize writeString for ASCII (#6736)
* Dart - optimize writeString for ASCII

* Dart - writeString() ASCII optimization optional
2021-07-22 10:36:37 -07:00
Ivan Dlugos
2bfc8e9f01 Dart - make writeString() argument non-nullable (#6737) 2021-07-20 07:54:48 -07:00
Casper
674a9f2aae fix lints in rust tests (#6743)
Co-authored-by: Casper Neo <cneo@google.com>
2021-07-19 18:47:20 -04:00
Sam Sobell
016e6aa13f Add a split on ':' to build_defs.bzl (#6742) 2021-07-19 16:42:27 -04:00
Ivan Dlugos
65700441d3 Dart - make vTable fixed size (expect the number of fields when creating) (#6735) 2021-07-19 11:27:01 -07:00
Ivan Dlugos
dd5bb55cad Dart - make vTable deduplication optional (#6734) 2021-07-15 15:50:12 -07:00
Ivan Dlugos
e8423da1b7 Dart - regenerate example after recent flatc changes (#6733) 2021-07-15 13:03:27 -07:00
Shlomi Regev
0980e39c9b flexbuffers: Add variant of Blob() that takes a key (#6730) 2021-07-12 09:42:55 -07:00
Ivan Dlugos
e73fab27d4 Dart - store empty vectors instead of NULL (#6728) 2021-07-09 12:44:40 -07:00
Ivan Dlugos
92ae532e43 Dart - finish/lowFinish/buffer changes (#6712)
* Dart - change Builder "lowFinish()" to "buffer" and "finish()" to not void return

Aligning the API with other languages, e.g. c++ and allowing custom use-cases to avoid creating a Uint8List

* Dart - change builder.buffer to check that finish() was already called

* Dart - builder - move !finished assertion to _prepare() which is run from all other functions
2021-07-09 11:45:45 -07:00
Philipp Wollermann
7482b25f8b Remove ubuntu1604 from presubmit.yml (#6715)
* Remove ubuntu1604 from presubmit.yml

Ubuntu 16.04 is end-of-life, we're going to remove it from Bazel CI.

If you like you can add testing on `ubuntu2004` platform which we also support.

* Add ubuntu2004 to presubmit.yml
2021-07-09 09:59:30 -07:00
Ivan Dlugos
3f77dc9a0e Dart - unpack() must use eager list reader (#6723) 2021-07-09 09:55:34 -07:00
Ivan Dlugos
838c93b843 Dart - fix flex-builder compilation error (#6722)
* Dart - fix flex-builder compilation error

* DartTest.sh - run all tests
2021-07-09 09:53:27 -07:00
Ivan Dlugos
089f48a4a6 Dart - make sure added padding is zeroed, same as in C++ (#6716) 2021-07-09 09:06:40 -07:00
Daniil Nikolenko
bf3470c161 Fix UB in CreateVectorOfStructs in case of an empty vector: avoid calling memcpy in this case (#6726) 2021-07-08 13:40:53 -07:00
paulharris
8f8196e136 Fix 6348 (#6717)
* Fixup CPP documentation's markdown errors

Note that I couldn't get the ~~~{.cpp} method to work,
so I switched to using ```cpp which did work.

* Fixup C++ docs, typo in repeated code example

Co-authored-by: Paul Harris <paulharris@computer.org>
2021-07-08 13:29:00 -07:00
Ivan Dlugos
8ab35b2a5f Dart - add custom allocator support (#6711)
* Dart - add custom allocator support

* Dart - only copy written bytes during resize, not the whole old buffer.
2021-07-08 13:02:09 -07:00
jdees
c0ba2870c9 Fix typo in docu (#6714)
wether => whether
2021-06-30 14:55:56 -04:00
Vladimir Glavnyy
22498cf3a9 [C++] add make_span for Array<T,N> (#6663)
* [C++] Add make_span for Array<T,N> and Vector<T>

* [C++] Add tests for make_span<T,N>(Array<T,N>)

* [C++] Add span iterators

* [C++] Checked span iterator (MSVC)

* Fix review notes
2021-06-28 10:22:02 -07:00
pkasting
bd37e67ac0 [C++] Fix a -Wdeprecated-copy warning. (#6708)
* Fix incorrect assertion usage.

* Fix a -Wdeprecated-copy warning.

Bug: chromium:1221591

* Just remove constructors/assignment
2021-06-27 09:50:12 +07:00
Ivan Dlugos
a6ee335574 Dart null safety (#6696)
* Dart null-safety - prepare migration annotations in library files

* Dart null-safety - apply migration

* Dart null-safety - update flatc to generate valid code

* Dart null-safety - fix flatc generated code and adjust tests

* Dart null-safety - update example and the generated code in the tests folder

* Dart null safety - minor review changes

* Dart - apply `dartfmt -w .`
2021-06-22 08:54:57 -07:00
Casper
71d43f3be9 Make --bfbs-filenames default to location of first schema file. (#6705)
* Make --bfbs-filenames default to location of first schema file.

Make RelativeToProjectRoot always work, applying "../" where needed. This is
needed for backwards compatibility. The first input file may be deeper in some
directory than the other files. Now, there will always be a declaration
file.

* documentation

* clang format

Co-authored-by: Casper Neo <cneo@google.com>
2021-06-22 10:19:46 -04:00
schoetbi
c8db1ca5d4 Jsonschema add prop comments (#6617)
* Add comments for properties

* regenerated test files

* Reverted changes in testfiles generated with generate_code.bat on windows

* fixed formatting in util.cpp because of failed .travis/format_check.sh

* removed the use of tuple

* util.cpp: Fixed format

* idl_gen_json_schema.cpp: removed extra comma in deprecated fields

* Corrected monster_test.schema.json

* idl_gen_json_schema: Inlined Trim function

* Fixed format

* PrepareDescription(): Avoid unnecessary string copy

* fixed formatting
2021-06-21 11:42:07 -07:00
Mika Raento
962751a6ec Improve generated comparisons for tables (#6486)
* Improve generated comparisons for tables

Previously, the generated code called std::unique_ptr<>::operator== on
non-scalar members, which would be correct only if the member was null
on both sides. After this CL, comparison is done on the pointed-to
values (including using a default-constructed value if the pointer is
null).

* Don't equate null Tables with all defaults

Also removes the cost of default-constructing tables for comparisons.

* Regenerate code

* fix formatting
2021-06-21 11:37:56 -07:00
Casper
06fd6d640c Replace filenames in reflection with filenames+includes. (#6703)
* Replace filenames in reflection with filenames+includes.

This is needed for some use cases and may be just useful metadata.

* deser files_included_per_file_

* check project_root

* fix bazel

* git clang format

Co-authored-by: Casper Neo <cneo@google.com>
2021-06-19 19:21:33 -04:00
pkasting
acce4ac3f0 Fix incorrect assertion usage. (#6702) 2021-06-18 15:49:55 -04:00
Neil Girdhar
8fd7861b75 Fix warning about deprecated module: imp (#6362) 2021-06-17 13:02:22 -07:00
Casper
c58ae94225 Add the file a symbol is declared in to Reflection (#6613)
* Add the file a symbol is declared in to Reflection

If we move a code-generator to depend on Reflection,
it may need to know which file something was declared in
to properly name generated files.

* Doc comments in reflection, and more precise tests

* Add --project-root flag to flatc, normalize declaraion_file to this root

* fix --project-root stuff

* posixpath

* fix scripts

* format

* rename --project-root to --bfbs-filenames

Also, make it optional, rather than defaulting to `./`, if its not
specified, then don't serialize the filenames.

* bfbs generation

* fix some tests

* uncomment a thing

* add  to project root directory conditionally

* fix

* git clang format

* Added help description and removed != nullptr

* "

* Remove accidental change to docs

* Remove accidental change to docs

* Pool strings

Co-authored-by: Casper Neo <cneo@google.com>
2021-06-17 11:50:04 -04:00
Casper
2cf7bb7966 Intermediate Representation docs (#6685)
* Intermediate Representation docs

* minor rewording

* addressing comments

* move IR to bottom

Co-authored-by: Casper Neo <cneo@google.com>
2021-06-17 11:46:34 -04:00
Ivan Dlugos
4e3a66c141 Dart object API (#6682)
* dart test scripts - generate with `--gen-object-api`

* Dart object API, pack and unpack methods (WIP)

* Dart flatc - extract Builder code to separate functions to reuse it in Pack()

* Dart flatc - use builder field-building implementation in pack()

* Dart flatc - add pack() as an intance method of the "T" class

* Dart object API - make inner fields unpacked as well

* Dart object API - use pack() when collecting field offsets

* Dart object API - use packOnce() for fields that are structs or vectors of structs

* Dart object API - remove obsolete union support TODO

* Dart object API - minor review changes, test and fixes

* Dart object API - revert packOnce() - not supported by other object API implementations

* Dart object API - update docs

* update dart generated code in tests/ to fix CI failure on ./scripts/check-generated-code.sh

* Dart flatc - fix compilation for old MSVC and c++0x
2021-06-14 10:15:56 -07:00
Ivan Dlugos
d959e23208 dart - change Builder.reset() to reuse an existing buffer (#6661) 2021-06-13 08:07:08 -07:00
Omer Akram
a9fb540884 use improved versioning (#6691) 2021-06-11 15:27:59 -07:00
Ivan Dlugos
337eb8b8f7 update docs - structs can't be roots (#6690) 2021-06-11 15:20:10 -07:00
Russell Chreptyk
6415ef05d3 [Python] [Codegen] Fixes nested structs with underscore names (#6686)
Fixes #6648
2021-06-10 12:52:19 -07:00
Huw Rogers
f069396d1b [C++] flatc --cpp-field-case-style option to permit camel-case field names in C++ (#6669)
* flatc --cpp-field-case option to permit camel-case field names in C++

* fixed option name; cleaned up tabs

* formatting fixed to conform to CI

* resolved comments

* fixed white space indentation

* per PR comments

* rename snake case option to unchanged for clarity, per PR comments

* cleanup of unchanged case option in C++ codegen, per PR 6669 comments

* incorporated PR feedback from vglavnyy

* cleaned up to pass Travis CI / clang format

* bumped PR to retry transient CI failure

* bumped PR to retry transient CI failure

* bump PR

* assert union type field name length > suffix, per PR 6669 comments
2021-06-08 11:23:05 -07:00
Omer Akram
021177af0d Fix snap version formatting (#6683) 2021-06-07 09:16:13 -07:00
Alexander Dzyuba
e1e9f93739 [C++/grpc] added hiding of unused variables in the generated code (#6677)
Co-authored-by: Alexander Dzyuba <a.dzyuba@seraphim.online>
2021-06-06 17:40:56 +07:00
Wouter van Oortmerssen
15110094eb Fix GitHub Actions CI gcc/clang versions 2021-06-04 13:32:16 -07:00
Jared Duke
093badb0a0 Use unoptimized path for ReadUInt64 for win32 build as the optimized path crashes. (#6681)
FlexBuffers are used by custom op handlers for TFLite. Using the optimized path for ReadUInt64 in FlexBuffers causes a crash in models using custom ops on win32 build. This change fixes the problem by using unoptimized implementation of ReadUInt64 for win32.
2021-06-04 13:27:47 -07:00
Kamil Rojewski
752c7b576d avoiding more NoSuchMethod exceptions (#6671)
refs #6657
2021-06-03 14:18:45 -07:00
ofirm93
7c3e267e1e [Java] ObjectAPI implementation (#6521) (#6582)
* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)
2021-06-03 14:17:40 -07:00
Wouter van Oortmerssen
baaffbaedd npm update to 2.0.3 and script fix
Change-Id: Idacbc5973e9c1f713f5c8e03513a83590e336fdb
2021-06-03 13:40:35 -07:00
Björn Harrtell
4cb3f222b1 [TS] Fix module reference in package.json (#6676) 2021-06-01 09:10:55 -07:00
Björn Harrtell
eabdbda755 [TS] Generate entry point module (#6674) 2021-06-01 09:09:55 -07:00
Wouter van Oortmerssen
bec23700fc Prepare for Java 2.0.1 release
see https://github.com/google/flatbuffers/pull/6658
2021-05-24 12:20:45 -07:00
Wouter van Oortmerssen
12f2eedadc Update CI to GCC/Clang 11 2021-05-24 11:55:40 -07:00
kalabukdima
221eeb2312 Fix typo in C++ doc (#6664) 2021-05-24 11:22:01 -07:00
Kamil Rojewski
813d3632ec avoiding NoSuchMethod exception (#6658) 2021-05-24 11:09:45 -07:00
Derek Bailey
d84bccb0c7 Removed most heap allocations in builder (#6662)
* [C++] Removed most heap allocations in builder

* Updated API docs to indicate heap usage

* Override assertion for heap allocation in parser

* Cleaned up implemenations, enable heap alloc for tests

* Generalized CreateVectorOfStrings

* remove cmake option for heap alloc. reverted two heap removals

* Only use scratch space for vector of strings

* Override Windows SCL warning

* Changed std::transform to for loop to avoid MSCV warnings

* switched to const iterators

* Replaced iterator with for loop

* remove std::to_string in test to be compatible
2021-05-21 11:09:24 -07:00
Ivan Dlugos
b4e67f9bf0 Dart test fix (#6660)
* Dart cppData test - fix path on Dart v2.12 (Linux)

* Dart cppData test - fix expected data mismatch

* add Dart CI test in GH Actions
2021-05-20 12:00:51 -07:00
Samir Ahmed
54c11932fa [Java] Flexbuffers - Negative signed object length (#6651)
* retry with correct email

* update JavaTest.java
2021-05-20 11:57:10 -07:00
mustiikhalil
fbcb3c4236 [TS/JS] Updates the grpc (#6654)
* Updates go lang support to allow other languages to communicate with it

* Update js grpc lib to use grpc-js

Reformat code
2021-05-20 11:34:17 -07:00
mustiikhalil
8937dcfd78 Updates go lang support to allow other languages to communicate with it (#6653) 2021-05-20 11:32:56 -07:00
Derek Bailey
512d5a6897 Update readme.md to point to security policy 2021-05-19 11:59:58 -07:00
Derek Bailey
a92cb5dd7b Create Security.md
Defining our security reporting process.
2021-05-19 11:55:50 -07:00
Derek Bailey
d151dcbb9d Revert "[C++] Removed most heap allocations in builder (#6620)" (#6659)
This reverts commit 72730ecd8a.
2021-05-19 10:53:46 -07:00
Richard A Hofer
f1884c66f4 Fix gRPC test to use EndVector without specifying the length. (#6646) 2021-05-17 11:27:49 -07:00
Derek Bailey
72730ecd8a [C++] Removed most heap allocations in builder (#6620)
* [C++] Removed most heap allocations in builder

* Updated API docs to indicate heap usage

* Override assertion for heap allocation in parser

* Cleaned up implemenations, enable heap alloc for tests

* Generalized CreateVectorOfStrings

* remove cmake option for heap alloc. reverted two heap removals

* Only use scratch space for vector of strings

* Override Windows SCL warning

* Changed std::transform to for loop to avoid MSCV warnings

* switched to const iterators
2021-05-17 10:53:32 -07:00
Casper
fe2bc2b0a7 Added README for Rust Flatbuffers (before publishing v=2.0) (#6652)
Co-authored-by: Casper Neo <cneo@google.com>
2021-05-16 10:37:16 -04:00
Derek Bailey
4867c94564 Fixed generation of c++ code with flags (#6637)
* Fixed generation of c++ code with flags

* tweaking const

* moved to CONSTEXPR_CP11
2021-05-15 13:27:24 -07:00
Derek Bailey
ef0eb3701d Ran clang-format-all.sh. Removed default --style=file parameter (#6639)
* Ran clang-format-all.sh. Removed default --style=file parameter

* Moved scripts to scripts/ location
2021-05-15 12:54:08 -07:00
Fraser Crossman
f83ee1af59 [idl_parser] Check structs and enums do not clash in a namespace (#6562)
* [idl_parser] Check structs and enums do not clash in a namespace

Uses fully qualified names to check for clashes within a given namespace whether explicitly defined or in the global namespace.

* [idl_parser] Move type name clash check to ParseEnum and ParseDecl

Change point at which parsing error is returned to ensure error is caught more generally. This change means that the error is returned after parsing the entirety of the offending duplicate rather than at the start when parsing it's name.

* [idl_parser] Add single and multi file type name clash tests

Adds a selection of tests for valid single file schemas with types that have the same name but are in different namespaces.
Adds a test for an a valid schema that spans two files with two types that have the same name but are in different namespaces.
Adds a test for an an invalid schema that spans two files with two types that have the same name and are in the same namespace.
2021-05-14 13:56:52 -07:00
mustiikhalil
a5175c513a Implements verifier and code gen for swift (#6373)
Updates test cases on linux

Adhere to new protocol naming

Adds fuzzing

Adds documentation

Adds support for string unions

Updated fuzzer generated code
2021-05-14 20:59:28 +03:00
Casper
04b10f5a3a Deprecate EnumVal.object (#6612)
Co-authored-by: Casper Neo <cneo@google.com>
2021-05-13 14:57:36 -07:00
Wouter van Oortmerssen
c121c03456 Fixed Java gRPC version number dependency
Change-Id: I6c4ed59ab4bb06edcef4b33c179f6e02ec86fdbb
2021-05-13 13:32:13 -07:00
Casper
8fd10606c1 Implement Serialize for flexbuffer::Reader (#6635)
* Implement Serialize for flexbuffer::Reader

* bump version

* Remove use of experimantal or-patterns

* Remove more use of experimantal or-patterns

Co-authored-by: Casper Neo <cneo@google.com>
2021-05-10 23:15:46 -04:00
mustiikhalil
a1730fcea8 [Swift] Updated cocoapods to 2.0.0 (#6634) 2021-05-11 00:13:41 +03:00
Wouter van Oortmerssen
a9a295fecf More missing version changes 2021-05-10 11:45:16 -07:00
Wouter van Oortmerssen
5c01ad387f Dart generated code update
Change-Id: I317d731d17d733088cad608364b614bff8151c36
2021-05-10 11:35:00 -07:00
Wouter van Oortmerssen
42ca1b9140 Swift/Kotlin generated code version updates
Change-Id: I035163cb5edd087a190bb518e686c79887241383
2021-05-10 11:30:26 -07:00
Wouter van Oortmerssen
6ed780dbd5 C++/Rust version changes 2021-05-10 11:29:32 -07:00
Wouter van Oortmerssen
3412fab8ee C#/Java generated code version updates 2021-05-10 11:17:31 -07:00
Wouter van Oortmerssen
8a7d013f85 Updated main version numbers to 2.0 2021-05-10 11:14:47 -07:00
mogemimi
170af59788 [Go] Add missing namespace when using Object API (#6633) 2021-05-10 10:52:10 -07:00
Vladimir Glavnyy
c8c16de167 Fix reverse iterators for Vector and Array (#6626)
This commit fixes two serious issues connected with reverse iterators:
1. Vector's rbegin/rend was incompatible with std::reverse_iterator::base();
2. Array's rend() was incorrect, it based on end() instead of begin().
2021-05-10 09:07:56 -07:00
罗泽轩
4525cd9c56 [Lua] manipulate byte array as string (#6624)
* [Lua] manipulate byte array as string

Sometimes it would be more effective than reading byte by byte

* change according to the review

* update
2021-05-07 22:57:13 -07:00
Piotr Dziwiński
47361baf61 [C++] Fix union copy constructor to work with nested structs (#6552) (#6607) 2021-05-06 14:42:44 -07:00
mustiikhalil
8a582883ac Updates swift generated monster sample file (#6616)
Updates swift generated monster sample file
Adds frozen attribute
2021-05-06 07:55:03 +03:00
罗泽轩
a4bb8f0c2e [Lua] Avoid infinite loop when creating empty string (#6614)
* [Lua] Avoid infinite loop when creating empty string

* [Lua] Check empty string output
2021-05-05 19:39:42 -07:00
Derek Bailey
82aed82b84 Added support for Lua 5.1, 5.2 and 5.4 (#6606)
This adds basic support for different Lua versions.

For Lua 5.2 and Lua 5.3, both the Bit32 and Compat53 Lua modules must be
installed for it to work. You can typically get these on Linux using

apt install lua-compat53 lua-bit32

For Lua 5.4, it should work as is, as it is a clean superset of Lua 5.3,
which is what the original Lua Flatbuffers supported.
2021-05-05 16:36:49 -07:00
Björn Harrtell
60ff76630d [TS] Remove wrong and obsolete NS prefix use (#6604) 2021-05-03 12:04:34 -07:00
Derek Bailey
a27c7d8093 Fixed LuaJIT when not compiled with COMPAT mode (#6605)
LuaJIT as installed by apt doesn't include the COMPAT mode for using
Lua5.2 features. So this change just makes the flatbuffer code use a
common implementation.
2021-05-03 11:35:49 -07:00
Kamil Rojewski
3632208233 removed unneeded type prefixing (#6601) 2021-05-03 10:40:59 -07:00
Casper
6b44c605b8 Bump Rust to 0.9.0 (#6610)
Co-authored-by: Casper Neo <cneo@google.com>
2021-05-02 12:28:17 -04:00
罗泽轩
d3cd78a87c [Lua] Add LuaJIT support (#6584)
* [Lua] Add LuaJIT support

Here is the output of LuaTest.sh:

Run with LuaJIT:
built 100 512-byte flatbuffers in 0.16sec: 0.63/msec, 0.31MB/sec
built 1000 512-byte flatbuffers in 0.08sec: 12.06/msec, 5.89MB/sec
built 10000 512-byte flatbuffers in 0.80sec: 12.44/msec, 6.07MB/sec
built 10000 512-byte flatbuffers in 0.33sec: 30.58/msec, 14.93MB/sec
traversed 100 592-byte flatbuffers in 0.04sec: 2.51/msec, 1.42MB/sec
traversed 1000 592-byte flatbuffers in 0.03sec: 31.52/msec, 17.79MB/sec
traversed 10000 592-byte flatbuffers in 0.21sec: 48.77/msec, 27.53MB/sec
Run with Lua 5.3:
built 100 512-byte flatbuffers in 0.02sec: 5.44/msec, 2.66MB/sec
built 1000 512-byte flatbuffers in 0.17sec: 5.74/msec, 2.80MB/sec
built 10000 512-byte flatbuffers in 1.75sec: 5.72/msec, 2.79MB/sec
built 10000 512-byte flatbuffers in 1.38sec: 7.26/msec, 3.55MB/sec
traversed 100 592-byte flatbuffers in 0.00sec: 27.64/msec, 15.60MB/sec
traversed 1000 592-byte flatbuffers in 0.03sec: 30.46/msec, 17.20MB/sec
traversed 10000 592-byte flatbuffers in 0.34sec: 29.62/msec, 16.72MB/sec

* [Lua] Better usage description

* update according to the review
2021-04-30 10:38:16 -07:00
Casper
8fa3dfdb5d Introduce new_from_vec in Rust (also fix formatting) (#6599)
* Introduce new_from_vec in Rust (also fix formatting)

Also, rename `new_with_capacity` to `with_capacity` to match
how `Vec` does it.

* bump rust version

* mut_finished_buffer

Co-authored-by: Casper Neo <cneo@google.com>
2021-04-29 18:23:22 -04:00
shiyuge
29379e8e49 fix typo in CppUsage.md (#6595)
Thanks!
2021-04-29 10:05:55 -07:00
Derek Bailey
14725d6c3b [Lua] GetRootAs can accept strings. Made Luatest Benchmarks optional (#6593) 2021-04-27 13:02:13 -07:00
Casper
16836ff95a Add advance feature indicators to reflection (#6546)
* Add advance feature indicators to reflection

* deserialize too

* model advanced features as bitflags

* use uint64_t instead of AdvancedFeatures

* git clang format

* initialize advanced_features_

* remove whitespace

Co-authored-by: Casper Neo <cneo@google.com>
2021-04-27 10:10:59 -04:00
Casper
c87179e73e Rust Remove SafeSliceAccess for Arrays, and fix miri. (#6592)
* Fix Miri flag passing and bump Rust version.

* Fix Miri problems from Arrays PR.

SafeSliceAccess was removed for Arrays. It's kind of unsound.
It has two properties:
1. EndianSafe
2. Alignment 1

We only need 1. in create_vector_direct to memcpy data.
We both 1. and 2. for accessing things with slices as buffers are built on &[u8]
which is unaligned. Conditional compilation implements
SafeSliceAccess for >1byte scalars (like f32) on LittleEndian machines
which is wrong since they don't satisfy 2.

This UB is still accessible for Vectors (though not exercised our
tests) as it implements SafeSliceAccess. I'll fix this later by
splitting SafeSliceAccess into its 2 properties.

Co-authored-by: Casper Neo <cneo@google.com>
2021-04-26 19:28:25 -04:00
Casper
c24031c36b Mark endian_scalar as unsafe. (#6588)
* Mark endian_scalar as unsafe.

Also
- removed the deprecated flexbuffer slice from example
- fixed some cargo warnings

* Assertions and read_scalar made unsafe

* Clippy lints

* Add to Safety

Co-authored-by: Casper Neo <cneo@google.com>
2021-04-26 09:18:58 -04:00
mustiikhalil
4ccc52c7a0 [swift] Implements union strings (#6589) 2021-04-24 14:47:24 +03:00
Alexander Zaitsev
b82fe07384 [Rust] Fix small mistyping (#6585)
Hi!

Just a veeeeeery small fix in the Rust sample. No functionality is affected.

That's not important at all but annoying for my eyes :)
2021-04-22 12:36:23 -07:00
罗泽轩
1e7f6c8c7c [TS] Commit the generated tests code (#6579)
* [TS] Ignore generated monster_test_grpc files

* [TS] Commit the generated tests code
2021-04-22 11:15:18 -07:00
罗泽轩
84714b109b chore: ensure bash is used to generate code (#6577)
In some platforms, like Ubuntu, `sh` is linked to `dash` but not `bash`.
2021-04-19 14:30:55 -07:00
罗泽轩
1045d7dd44 [Lua] Fix EnforceNumberAndPack for bool type (#6576) 2021-04-19 14:30:20 -07:00
罗泽轩
0c77775966 [TS] Remove duplicated build-ts ci (#6575)
Now we already have a real build-ts ci job, let's remove the commented
one.
2021-04-19 14:28:26 -07:00
Ádám Lippai
c43ba17520 [Rust] Specify Minimum Supported Rust Version (#6573)
Related to #6572
2021-04-19 16:43:11 -04:00
Eddie Linder
da3bb64ef6 [Rust] Add support for fixed size arrays (#6548)
* Add support for fixed size arrays

* clang-format

* Update rust image to 1.51 to support const generics

* Handle correctly big endian

* Add fuzz tests and clean code

* Add struct fuzz test and optimize struct arrays for api

* Bump flatbuffers crate version
2021-04-16 11:15:59 -04:00
Paulo Pinheiro
151900ba96 [Kotlin][FlexBuffers] Add support for Kotlin-iOS (#6564)
With this change, Flexbuffers for Kotlin now supports iOS(arm32, arm64, X64).
WatchOS and tvOS not supported.
2021-04-15 11:29:51 -07:00
Kamil Rojewski
c012f29f91 silenced clippy warning (#6565) 2021-04-15 11:19:13 -04:00
Paulo Pinheiro
df2df21ec1 [Kotlin] Bump kotlinx.benchmark dependency to 0.3.0 (#6560)
Kotlinx.benchmark project just abandoned bintray and moving to maven central,
removing the artifacts from bintray and causing missing dependencies in our build.
So we are updating the dependency to point to the new version on maven central.

More information in:

53ee45d0d9 (diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5)
2021-04-12 13:47:40 -07:00
Björn Harrtell
408e4db4af [TS] Add Build TS to CI jobs (#6524)
* Add Build TS to CI jobs

* Add npm compile step

* Fix syntax

* Add required code gen for TS

* Exit on failure

* Make TS code gen identical to test run

* Remove duplicate TS code gen artifacts

* Remove bad gitignore

* Forgot parts of generate_code and make sure same settings for test run

* Don't forget about the bat

* Try and fix flatc args

* Another attempt to fix args

* Fix typo

* Commit up to date code gen

* Another attempt to fix sh/bat

* Move -o param to after -I

* Commit missing code gen file

* Fix grpc code gen and test

* Another grpc code gen fix

* Rework to not use ts folder

* Fix env vars in bat and make less churn

* Move TS code gen to dedicated folder

* Fix transpilation output folder and module paths

* Fixes to code gen

* Include generated js

* Moved ts code gen

* Remove test ts code gen folder
2021-04-12 10:41:59 -07:00
Paulo Pinheiro
4d2364f342 [Kotlin][FlexBuffers] Add support for Kotlin-JS (#6554)
Flexbuffers for Kotlin currently supports JVM and MacOS. This change
introduces support to JS as well.
2021-04-12 10:30:15 -07:00
Casper
261cf3b204 Default-empty vectors of enums (#6505)
* disable clippy

* Vector of enum default

* swift and tests

* git clang format

* Rewrite enum parser checks

* Remove Voids from more_defaults

* vector enum swift

* remove vector accessor from swift

* clang format

Co-authored-by: Casper Neo <cneo@google.com>
2021-04-06 07:23:45 -04:00
mustiikhalil
cd67261bba [CI] fixes buildkite (#6544) 2021-04-05 12:34:42 +03:00
mustiikhalil
1aa0c2f6a9 Limit formatter to pull requests only (#6540) 2021-04-01 20:09:43 +03:00
Casper
4133a39df8 Rust structz (#6539)
* Rust structz

* struct of structs test

* swift tmp variables

Co-authored-by: Casper Neo <cneo@google.com>
2021-03-29 19:56:45 -04:00
Paulo Pinheiro
1c26d2a1a0 [Kotlin][FlexBuffers] JSON support for Flexbuffers (#6417)
* [Kotlin][FlexBuffers] Add JSON support for FlexBuffers

* [Kotlin][Flexbuffers] Re-implement JSON parser with a tokenizer.
2021-03-29 15:57:23 -07:00
Jeong YunWon
276b1bc342 [grpc] Support latest version of grpc PoC (#6338)
* use grpcpp rather than deprecated grpc++

* grpcpp Deserialize take ByteBuffer instead of grpc_byte_buffer

* grpc 1.36.0

* Fix to use grpc 1.36.0

* Fix CMakeLists to refer gRPC

* add find_package(Threads)

* Update bazel deps

* Apply workaround about boringssl build error

* Install latest cmake for osx on travis-ci

Co-authored-by: Yeom Gyusun <omniavinco@gmail.com>
2021-03-25 12:12:35 -07:00
Kamil Rojewski
124654ffc4 fixed packing structs (#6530)
* fixed packing structs in nested buffers

* fixed packing structs
2021-03-25 10:25:00 -07:00
mustiikhalil
3b7d1e86b4 [GO] Tries to add go format to the CI (#6518)
* Trys to add go format to the CI

Adds Gofmt to CI

* Adds formatting for go dir in grpc

* Small fix
2021-03-18 11:03:44 -07:00
Michael
78f0c0d1d9 [C++] #6501 - Problem when mapping a native type multiple times (#6514)
* [C++] #6501 - Problem when mapping a native type multiple times
- idl.h:
added "native_type_pack_name"
- flatbuffers.h:
added CreateVectorOfNativeStructs variants which receive a pointer to the serialization function
- idl_gen_cpp.cpp:
adapted code generation in case "native_type_pack_name" attribute is present
- extended tests & docs; improved surrounding native_type docs a little

* integrated review feedback
2021-03-18 11:01:50 -07:00
Vladimir Glavnyy
c992eafb5b [fuzzer] Add monster_debug target (#6513)
Add the `monster_debug` target for better troubleshooting.
Improve oss-fuzz logs.
2021-03-18 10:56:28 -07:00
mustiikhalil
ef8dd7792a [Swift] Removes allman rule (#6519) 2021-03-17 13:22:49 +03:00
Vladimir Glavnyy
69b329fc87 [flexbuffers, json] Parse nan and inf (#6512) 2021-03-15 11:44:42 -07:00
Kamil Rojewski
6543ba5297 fixed packing structs in nested buffers (#6509) 2021-03-11 11:14:23 -08:00
Vladimir Glavnyy
0e453ac352 [idl_parser] Add kTokenNumericConstant token (#6432)
* [idl_parser] Add kTokenNumericConstant token

This commit adds the new token for correct parsing of signed numeric constants.
Before this expressions `-nan` or `-inf` were treated as kTokenStringConstant.
This was ambiguous if a real string field parsed.
For example, `{ "text_field" : -name }` was accepted by the parser as valid JSON object.

Related oss-fuzz issue: 6200301176619008

* Add additional positive tests fo 'inf' and 'nan' as identifiers

* Rebase to HEAD

* Move processing of signed constants to ParseSingleValue method.

* Add missed `--cpp-static-reflection` (#6324) to pass CI

* Remove `flatbuffers.pc` from repository to unblock CI (#6455).

Probably the generated flatbuffers.pc should not be a part of repo.

* Fix FieldIdentifierTest()
2021-03-11 11:12:06 -08:00
Vladimir Glavnyy
e9b4ae69dc Remove flatbuffers.pc from the repository (#6508) 2021-03-11 11:11:04 -08:00
mustiikhalil
fc4fffea41 Bump grpc to 1.0.0 (#6507)
Adds void to keywords
2021-03-09 10:56:06 +03:00
dpacbach
b240ab704d Move Traits struct and Create method out of --cpp-static-reflection. (#6503) 2021-03-08 10:59:17 -08:00
Ben Niu
9a4f1f434b Disable x64-specific optimizations for ARM64EC ReadInt64 (#6506)
ARM64EC is a new ARM64 ABI designed by Microsoft to support x64 application emulation on ARM64 CPUs. When compiling for ARM64EC, both the _M_X64 and _M_ARM64EC macros are defined. However, that causes problem in compiling this file, because the __movsb intrinsic, which is lowered to rep movsb, is not supported on ARM64, so the optimization for native x64 should be disabled for ARM64EC.
2021-03-08 10:53:04 -08:00
dpacbach
fac64918dc Add --cpp-static-reflection to generate_code.bat. (#6502) 2021-03-06 22:28:27 +07:00
David P. Sicilia
a69815f72c [C++17] Add compile-time reflection for fields. (#6324)
* [C++17] Add compile-time reflection for fields.

Included in this commit is the following:

  - The C++ generator has been modified so that,
    when in C++17 mode, it will emit Table and
    Struct field traits that can be used at com-
    pile time as a form of static reflection. This
    includes field types, field names, and a tuple
    of field getter results.

  - Diffs to the cpp17 generated files. No other
    generated files are affected.

  - A unit test that also serves as an example. It
    demonstrates how to use the full power of this
    reflection to implement a full recursive
    JSON-like stringifier for Flatbuffers types,
    but without needing any runtime access to the
    *.fbs definition files; the computation is
    done using only static reflection.

Tested on Linux with gcc 10.2.0.

Fixes #6285.

* Fix int-conversion warning on MSVC.

* Try to fix std::to_string ambiguity on MSVC.

* Fix clang-format diffs.

* Fix more clang-format diffs.

* Fix last clang-format diff.

* Enable C++17 build/test for VC 19 platform in CI.

* Forgot to add value to cmake command line variable.

* Various fixes/changes in response to @vglavnyy's feedback.

* Replace "fields pack" with index-based getters.

* Fix MSVC error.

* Fix clang-format diffs.

* getter_for method returns result instead of address-of-getter.

* Next round of reviewer suggestions.

* Use type instead of hardcoded struct name.

* Fix clang-format diff.

* Add test for FieldType since it is not used in the stringify test.

* Add fields_number field to Traits struct.

* Add --cpp-static-reflection flag and put those features behind it.

* Fix clang-format diffs.

* Remove <tuple> include.
2021-03-05 10:01:40 -08:00
Kamil Rojewski
4033ff5892 fixed invalid TS call and added test files (#6495)
e581013e3d broke TS generation - please don't use "replace" to refactor function names :)
2021-03-04 12:12:44 -08:00
Casper
a083572512 disable clippy (#6494)
Co-authored-by: Casper Neo <cneo@google.com>
2021-03-01 13:51:22 -08:00
Vladimir Glavnyy
5319dedb1a [idl_parser, JSON] Disable parsing of JSON for incomplete schemes (#6493)
This commit disable JSON parsing for an incomplete scheme if JSON object is embedded into one file with the scheme.
This should improve the quality of OSS-Fuzz inputs for the parser_fuzzer target.
2021-03-01 13:40:58 -08:00
Mark Spatz
bd4e0b30a7 [idl_parser] Track included files by hash (#6434)
* [idl_gen] Delete ts::GenPrefixedImport()

I don't know what this is for, but it's the only piece of code external
to idl_parser.cpp that expects the key of Parser::included_files_ to be
a path. And it appears to be unused.

* [idl_parser] Track included files by hash

Parser::included_files_ is a map whose main purpose is to keep track of
which files have already been parsed in order to protect against
multiple inclusion. Its key is the path that the file was found at
during parsing (or, if it's an in-memory file, just its name).

This commit changes the key to be the 64 bit FNV-1a hash of the file's
name (just the name, not the complete path) xor'd with the hash of the
file's contents (unless it's an in-memory file, then we only hash the
name.)

This allows multiple include protection to function even in the face of
unique per-file include paths (fixes #6425).

* Ran tests/generate_code.sh

CI told me to do it.

* Gracefullt handle case where source_filename == nullptr

I just learned source_filename might also be null. In that case, we
should exclude it from the hash instead of hashing a zero length
string, just like we exclude source when it is null.

Presumably nameless files will never be included (they can't, can they?)
so this doesn't really matter, but I think it's prettier anyways.
2021-03-01 12:34:01 -08:00
Kamil Rojewski
bf90612007 fix for noUncheckedIndexedAccess in ts (#6474) 2021-02-25 14:57:10 -08:00
mustiikhalil
8142fedd19 Working on a python example plus fixing python grpc code (#6456)
Refactored python grpc code gen

Adds example server & client + fixes ci

Fixes generated code

Making sure we encode the reply string as utf8

Adds Readme details to clarify issue regarding encoding when python is sending/receiving
2021-02-25 14:38:12 -08:00
Colin
c0be1cb7a5 [rust] Remove debug code (#6475)
* Remove debug code

This was added for testing in the recent genericize PR for flexbuffer Reader.

* Added alloc tests -> MapReader::{is_empty, index_key, len}

* Added , accessible through Deref to deprecation warning
2021-02-24 13:00:18 -05:00
Derek Bailey
8cccdfba53 Revert "[C#] Fix truncated ArraySegment<byte> if elementSize != 1 (#6462)" (#6488)
This reverts commit cbbbaa61b3.
2021-02-23 11:30:07 -08:00
Björn Harrtell
cbbbaa61b3 [C#] Fix truncated ArraySegment<byte> if elementSize != 1 (#6462)
* WIP: Fix returned truncated ArraySegment<byte> if elementSize is not byte

* Fix

* Regenerated test code
2021-02-23 09:34:20 -08:00
mustiikhalil
ffc2ef77ca [CI] Adds Code Generation tests on Github Actions (#6482)
Moves check-grpc-generation to scripts
2021-02-23 08:51:39 +03:00
Millian Poquet
1da6f4f18b [CMake] generate pkg-config flatbuffers.pc file (#6455)
This commit enables CMake to generate a flatbuffers.pc file on install.

pkg-config eases the utilization of software libraries by enabling the
developers of a library to define how the library should be used.

It can be used as a tool by build systems to find and manage dependencies,
this is notably the default Meson behavior and optionally used by CMake.
2021-02-22 10:23:38 -08:00
mustiikhalil
b5da526e6d [Swift] Moves grpc example to grpc/examples (#6479)
Updates generated Code

Removes grpc generation code from tests dir

Small fix to generate.sh
2021-02-20 23:07:48 +03:00
mustiikhalil
3b5365762d [TS] Moves grpc code to examples folder (#6476)
Adds readme
2021-02-20 20:31:00 +03:00
mustiikhalil
e2f5438ac1 Fixes grammer (#6477)
Updates docs
2021-02-19 12:16:38 -08:00
Richard A Hofer
5e3613f732 Fix sample_binary.py to use latest EndVector without a size. (#6478) 2021-02-19 12:13:50 -08:00
Kamil Rojewski
e6b911d40c updated JS docs to reflect current status (#6436) 2021-02-19 12:05:02 -08:00
mustiikhalil
0c7ae58164 [Go] Working on a go example plus fixing go grpc code (#6448)
Implemented server.go and half implemented client.go

Finishes implementation for greeter go example

Update grpc code for monster.fbs

Adds a couple of cpp methods

Adhere to gofmt standards

Adds a readme for issues with grpc
2021-02-19 12:47:59 +03:00
mustiikhalil
ae603b9770 [Swift] adds support for default vectors and strings (#6461)
Small fix

Adhere to the new protocol names
2021-02-19 12:47:28 +03:00
Arnaud LE CAM
7f47718b6d Update Building.md (#6473)
`cmake . -D FLATBUFFERS_CXX_FLAGS="Wno-error"` returns an error (file 'Wno-error' not found)
2021-02-18 19:51:41 -08:00
Thanabodee Charoenpiriyakij
54dc09e8ac GetUOffsetT must get value by GetUint32 not GetInt32 (#6072) 2021-02-18 18:38:25 -08:00
Liu Liu
334c6be496 Fix a typo in Swift codegen (#6470)
* Fix a typo in Swift codegen

* Fix code formatting.
2021-02-17 09:34:39 +03:00
Colin
4174c10e7a [rust] Genericize flexbuffer reader (#6450)
* feature/rust-tokio-bytes added feature name for tokio-bytes

* Added flexbuffer implementation, TODO: typecast to avoid recurse

* Converted codebase to utilize FlexBuffer implementation, need to resolve deserialization issues

* Added todo for lifetime issue, may use &'de [u8] for deserializer instead of current method

* Added proper &[u8] implementation

* Removed unused struct

* Added experimental fix to get_slice

* Added experimental fix to get_slice

* Avoided lifetime issues via ref structs, need to check if this hurts peformance

* Updated deserializer implementation to allow for borrowed data from Reader struct

* Fixed bug with str

* Removed unnecessary generic parameter

* Added unsafe to avoid lifetime complaints, current tests pass, need to review alternatives to unsafe

* Opinionated: Removed bytes crate as this implementation could be done in a separate crate

* Cleaned up flatbuffer

* Fixed sample / example

* Resolved PR feedback, need to resolve issues with tests

* Cleaned up FlexBuffer trait to be an auto impl

* Removed TODO

* Reverted Deserializer to only support &'de [u8]

* Cleaned up / renamed function for clarification

* Renamed FlexBuffer -> InternalBuffer for clarification on it's purpose

* Fixed issue with key bytes

* resolved issues with broken tests, confirming this is a breaking change

* Removed FIXME that's solved by splitting String and Key variants

* Implemented associated types approach

* Fixed backward slice logic

* Fixed MapReader compile error

* Added from_buffer for deserialization, removed  function since it's only needed for deserialization

* Removed dead code

* Cleaned up buffer, removed AsRef in favor of Deref

* Renamed Buffer::as_str -> Buffer::buffer_str

* Minor cleanup

* Updated documentation, need to fix tests

* Removed unnecessary &

* Removed unused lifetime

* removed unnecessary as_ref

* Minor optimization wrap-up

* resolved issue with Clone

* Added test to verify no deep-copy

* Added  for optimization

* Updated to use empty fn instead of default

* Updated comments / test name - plus the 0.3.0 version bump

* comment
2021-02-16 08:04:48 -05:00
mustiikhalil
a20f606c29 [Swift] Renaming protocols (#6469)
* Renaming protocols

* Updates Generated code

* format code
2021-02-16 14:55:47 +03:00
mustiikhalil
a72a208272 Update swift docs (#6460) 2021-02-14 10:09:11 +03:00
Casper
86401e078d Default strings and vectors: Parser + Rust support (#6421)
* Fix tests.cpp

* Parser support for vector/string defaults

* tests and default empty vectors

* addressed comments

* Default strings and vectors for Rust

* Tested Rust more_defaults

* git-clang-format

* add more_defaults_test

* fixed vector default

* removed commented out code

* more unreachable

Co-authored-by: Casper Neo <cneo@google.com>
2021-02-12 09:41:10 -05:00
mustiikhalil
6af37e6729 [CMake] Renames BUILD files (#6457)
* Renamed build to build.bazel to stop xcode from complaining about it

* Renamed all build to build.bazel

* Fixes small ci issue
2021-02-11 10:16:57 -08:00
Vladimir Glavnyy
1b88655b00 [Build, cmake] Add -Werror override option (#6429)
* [Build, cmake] Add -Werror override option

This commit adds FLATBUFFERS_CXX_FLAGS cmake option.
This option allows override the -Werror flag (or any other flags).
Related issues:  #6337, #5930

* Remove CMAKE_CXX_FLAGS replace option
2021-02-10 11:49:34 -08:00
blueshift155
0b15916e50 [C++]Fix extra char generation for byte type during json schema generation (#6276)
* Fix extra char generation for the byte type

* Fix unit tests for JSON
2021-02-10 11:48:24 -08:00
mustiikhalil
60eed0ca66 Updating working code (#6441)
Fixes issues with namespaces in grpc ts

Renamed welcome -> models
2021-02-10 11:46:45 -08:00
tira-misu
0f83367f57 JSON schema - tailing double quotes for maximum (#6452)
* 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

* Fix  double quotes for (u)int8 in json schema

* Fix reference file for JSON schema test

* Fix reference file for JSON schema test
2021-02-10 11:45:34 -08:00
Vladimir Glavnyy
fee095410b [idl_parser] Validate force_align on all possible paths (#6430)
* [idl_parser] Validate `force_align` on all possible paths

- added validation of `force_align` for `Vector`.
- added assertion to `flatbuffers::PreAlign` method

These changes should resolve following oss-fuzz issues:
- 6275816289861632
- 5713529908887552
- 4761242994606080

* size_t problem on Mac

* Fix review notes
2021-02-10 11:37:16 -08:00
Casper
6f3e45eca1 Implement Rust object API defaults (#6444)
* Implment Rust object API defaults

* satisfy return analysis

* git clang format

Co-authored-by: Casper Neo <cneo@google.com>
2021-02-07 16:51:33 -05:00
mustiikhalil
815d3e820d Upgrade swift grpc to alpha 24 (#6439)
Upgrade swift grpc to alpha 24
2021-02-04 02:01:18 +03:00
Vladimir Glavnyy
76e7a0ff55 [fuzzer] Limit parser_fuzzer execution time (#6431)
Limit the length of the fuzzer input to 16384 characters to prevent timeout
in JSON parser (Vector of tables with key).

Related oss-fuzz issues:
- 5742497110294528
2021-01-30 21:43:31 +07:00
Paulo Pinheiro
6d91096a2f This commit contains the initial implementation of Flexbuffers in Kotlin. The code was ported based (#6387)
on the current Java Implementation.

The code dependencies related to JVM were removed and the project is able to target all available platforms.

The only requirement to implement to fully support a target is to implement functions described in `ByteArray.kt`.
Right now the code support JVM and native targets. JS port still missing, but just be trivial to introduce.

Currently, only the `jvm` and `macosX64` targets are enabled until we figure out how to enable tests on all
platforms on CI.

A submodule called "benchmark" is also introduced. It contains a series
of benchmarks comparing Java and Kotlin implementations of FlexBuffers and the UTF8 API.

Finally, this commit does not contain the scripts necessary to publish the artifacts. This will
be introduced at a later stage once the team has an agreement on how to rollout Kotlin releases.
2021-01-28 14:49:25 -08:00
Richard A Hofer
13d9e35858 Better python generated code naming (#6336)
* Remove a lot of redundancy from the Python generated code.

Update tutorial to reflect new Python generated code.

* Add aliases for newly deprecated Python generated methods.

This should help with backwards compatibility.

* Fix incorrect names in deprecated comments.
2021-01-28 12:35:37 -08:00
Casper
6effe431bb Rust: remove inner attributes (#6410)
* remove inner attributes

* Added test for outdir in Rust

* add bin/outdir

* Moved outdir test to its own package and only run it if flatc is available

Co-authored-by: Casper Neo <cneo@google.com>
2021-01-26 11:09:29 -05:00
William Bain
efcbdc7698 [Rust] Ensure unions are referenced with the correct path (#6422)
* Add codegen test for namespaced unions

* [Rust] Handle cross-namespace union use

* [Rust] Test namespace handling

* [Rust] Drop trailing whitespace in codegen

* [Rust] Set flags in generate_code.bat to match .sh

* [C#] Add additional namespace test file
2021-01-25 09:33:47 -08:00
Casper
e581013e3d Refactor FieldDef to model presense as an enum rather than 2 bools. (#6420)
* Define presence.

* Migrate to IsRequired and IsOptional methods

* moved stuff around

* Removed optional and required bools from FieldDef

* change assert to return error

* Fix tests.cpp

* MakeFieldPresence helper

* fmt

* old c++ compatibility stuff

Co-authored-by: Casper Neo <cneo@google.com>
2021-01-25 09:29:43 -08:00
Andreas Kabel
0984d4328d [c++] Apply NativeName before WrapInNameSpace in idl_gen_cpp.cpp (#6419)
* Apply NativeName before WrapInNameSpace in idl_gen_cpp.cpp

* remove actual_type argument from GetUnionElement -- it's always true

* Merge GetUnionElement's native_type and wrap_native argument -- they always have the same value.

* Use convenience method WrapNativeNameInNameSpace

* Remove wrap_namespace argument from GetUnionElement

* Move declaration closer to first use.
2021-01-25 09:22:01 -08:00
mustiikhalil
786f69b248 Formats cpp code (#6349) 2021-01-22 10:46:53 -08:00
Casper
1da0a2dfac Rust Object API (#6070)
* inital commit of rust object api

* Required fields support.

* clang fallthrough

* Fix unused variables

* just don't fall through

* remove comment

* s/panic/unreachable

* Tests for object API

* Added defaults

* deleted unintentionally added files and updated .bat file

* fix bat file

* clang format

* Cargo clippy checks

* remove commented out code

* clippy allows

* Remove matches! macro since we're not yet at Rust v1.42

* install clippy in RustTest.sh

* move line

Co-authored-by: Casper Neo <cneo@google.com>
2021-01-22 13:07:32 -05:00
Juan Cruz Viotti
796ed68faf Clarify that (Flat|Flex)Buffers do not deduplicate vector elements (#6415)
I'm also clarifying that while elements are not deduplicated, vectors
may contain more than one offset to the same value.

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
2021-01-21 16:09:35 -08:00
Juan Cruz Viotti
7b1ee31d80 Clarify that FlatBuffers unions do not support scalars (#6416)
I mention that a common practice is to wrap the scalar value in a table
or a struct.

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
2021-01-21 16:08:29 -08:00
Juan Cruz Viotti
4aff1198dd Explain how FlatBuffers encodes unions (#6414)
This is an attempt to explain how FlatBuffers encodes union types as an
extra section in the "FlatBuffers internals" document.

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
2021-01-21 16:07:34 -08:00
Ivan Dlugos
ad3a729f96 dart Builder - expose finished buffer size (#6403) 2021-01-21 16:06:11 -08:00
Juan Cruz Viotti
52e2177069 Remove invalid claim that Protocol Buffers does not support unions (#6413)
Protocol Buffers v3 supports the `oneof` operator:
https://developers.google.com/protocol-buffers/docs/proto3#oneof

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
2021-01-21 12:23:54 -08:00
Björn Harrtell
760c657551 [TS/JS] New gen TS code gen (#6302)
* TS/ES6 modules spike iteration 1

* Initial modularized dasherized output

* Remove obsoleted parts and namespace wrapping

* Use _flatbuffers_ prefix

* First part of imports logic

* Second part of imports logic

* Fix TS/JS code removal mixup

* Alias imported symbols if same name from different namespaces and some fixes

* Use star import for bare imports

* Fix messed up string concat

* var to const and remove not needed semi

* Remove some cases of ns prefixing

* Add missing space

* Cleanups

* Completed initial import tracking logic

* Compilable output

* Adjust TypeScriptTest and dependents to work

* Use local flatbuffers package for tests

* Refactor away use of any

* Remove obsolete imported_fileset and reexport_map

* Still need any and fix JavaScriptTest.sh

* Fix test runs out of the box

* Temp add generated files

* TypeScriptTest replaces JavaScriptTest and cleanups

* Also remove reference to JavaScriptTest in TestAll.sh

* Remove old generated ts/js files

* Remove use of --js in generate_code scripts

* idl_gen_js_ts to idl_gen_ts and removal of js gen

* Remove obsoleted options

* Fix obsolete ts test detection

* Tweak ts compilation be as strict as possible

* Remove jsdoc type annotation generation

* Generated test ts files

* Fix search and replace messup

* Regenerated ts test output

* Use CharToLower

* Use normal for loop

* Rework namespacedir

* Revert "Rework namespacedir"

This reverts commit 6f4eb0104ceeb86011bb076ebca901138c48e068.

* Revert "Use normal for loop"

This reverts commit 676b2135bfaa1853dfbb06c92b5c16a0d81bb13a.

* Revert "Use CharToLower"

This reverts commit 2d08648d0d72d0af201fad80d54cdc76412b35e9.

* Again do rework but correct

* Avoid runtime cast

* Fix test runs

* Also add npm install to get tsc

* Bump node test versions

* for range to std for loop

* Clang format

* Missed one clang format

* Move accessor to later

* Attempt to make windows version of TypeScriptTest

* Want to see the output

* Try to get newer node at appveyor

* Style changes
2021-01-19 12:51:13 -08:00
Vladimir Glavnyy
75c859e98f [idl_parser] Improve symbols lookup thru parent namespaces (#6407)
Added the new method LookupTableByName for searching symbols in parent namespaces.
This method speedup (x50 or greater) symbol resolution (enum or struct) in parent namespaces.
The speedup was measured without `table.empty()` guard condition.

This method should suppress fuzzer timeout issue without artificial limits for nested namespaces (https://oss-fuzz.com/testcase-detail/6244168439169024).

Additionally, this commit speedup (x5) the GetFullyQualifiedName method by removing unnecessary temporary std::string object.
2021-01-19 12:49:24 -08:00
Mark Spatz
91b0958c43 Search for includes in the directory containg the current file (#6371)
* [codegen] Search for includes in the directory containg the current file

This matches the behavior of a C preprocessor, see:
https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html

* Skip FileExists() when file is guaranteed to not exist

* end comment with period to match others
2021-01-19 12:26:34 -08:00
Casper
8008dde117 Upgrade Rust dependencies (#6406)
Co-authored-by: Casper Neo <cneo@google.com>
2021-01-19 13:39:29 -05:00
Björn Harrtell
c81cf82492 [TS/JS] New gen TS code gen prequel to preserve history (#6404)
* Rename idl_gen_js_ts to idl_gen_ts to preserve history

* Change build related files
2021-01-14 11:34:44 -08:00
Casper
8573108bbe Unset FieldDef.optional if its key (#6402)
* Unset FieldDef.optional if its key

* removed StringKey table, just removed an extra "required, key"

* removed extra newline

Co-authored-by: Casper Neo <cneo@google.com>
2021-01-12 14:06:43 -05:00
Vladimir Glavnyy
7abe612b59 [fuzzer] Fix the binary schema loading in the monster_fuzzer (#6396)
This commit should fix issue 29374 in oss-fuzz.
2021-01-12 10:20:47 -08:00
Casper
408cf58024 Fix Rust UB problems (#6393)
* Fix miri problems by assuming alignment is 1 in rust

* Removed is_aligned fn from rust verifier.

* Add back is_aligned, but make it w.r.t. buffer[0]

* touch unused variable

* touch unused variable

* +nightly

* Move Rust miri testing into its own docker

* fix bash

* missing one endian conversion

* fix endianness2

* format stuff

Co-authored-by: Casper Neo <cneo@google.com>
2021-01-11 15:24:52 -05:00
brian-brt
39e115fdb4 Define Vector::value_type for STL compatibility (#6394)
Specifically, this lets the googlemock container matchers work with a
flatbuffers::Vector.

https://github.com/google/googletest/blob/master/googlemock/docs/cheat_sheet.md#container-matchers
2021-01-08 11:35:55 -08:00
Vladimir Glavnyy
85719669cb [fuzzer] Debug the monster_tets.bfbs on clusterfuzz server (#6392)
For some reason, this fuzzer failed to load the binary schema file
when run on the `/clusterfuzz` server.
Issue: https://oss-fuzz.com/testcase-detail/6215075358703616
This issue doesn't reproduce locally with the latest oss-fuzz docker image.
2021-01-08 11:09:41 -08:00
Dan Field
809fe49c7a Fix up scripts, fix generated enum value for strong mode, regenerate files (#6389)
* Fix up scripts, fix generated enum value for strong mode, regenerate files

* missing files

* GH action

* remove action
2021-01-07 14:51:52 -08:00
Aaron Son
41253e574e [go] tests/GoTest.sh: Fix flags.Parse location to work on new go SDKs. (#6388)
* tests/GoTest.sh: Fix flags.Parse location to work on new go SDKs.

Calling flags.Parse() within init() races with other packages which register
flags in their init(), and in particular with the testing package itself. It is
more reliable to call flags.Parse() from a TestMain implementation.

See https://github.com/golang/go/issues/31859,
https://github.com/golang/go/issues/33869.

* .github: Enable build-go action in build.yaml workflow.
2021-01-07 11:54:00 -08:00
Ivan Dlugos
08d2ce844b fix Dart Builder._writeString() - always write trailing zero byte (#6390) 2021-01-07 11:40:47 -08:00
Ivan Dlugos
a15a8d930d fix Dart Builder.reset() - clear vTables (#6386) 2021-01-07 11:28:33 -08:00
Vladimir Glavnyy
83ce29cc22 [C++, JSON] Fix nullptr access when reading a key with a default value. (#6375)
This commit fixes handling of default and NULL `key` fields in `Parser::ParseVector` (#5928).

The JSON generator updated. It outputs `key` fields even if the `--force-defaults` option is inactive.

Additional test cases for `key` added.
2021-01-07 11:24:59 -08:00
Richard A Hofer
4363c1d2cb Fix generated EndVector. (#6385) 2021-01-05 14:45:23 -08:00
Stefan de Konink
1bf1ec0270 Implements type promotion for Java enum (#6382)
* Implements type promotion for Java enum as suggested in #3890, #5111, #6369

* After generate_code.sh
2021-01-05 11:11:29 -08:00
Derek Bailey
0800976533 Delete label_notify.yml
Removing this workflow as it isn't used.
2021-01-05 10:06:33 -08:00
Wouter van Oortmerssen
795408115a Disabled PHP CI (#6381)
It errors with "Fatal error: Uncaught exception 'InvalidArgumentException' with message 'bad number  for type byte.. in /home/runner/work/flatbuffers/flatbuffers/php/ByteBuffer.php:490" which I can't reproduce locally, and trying to fix it on CI runs into PHP's insane handling of numbers vs strings.
2021-01-04 14:50:56 -08:00
Kamil Rojewski
46545e6273 fixed warnings (#6355)
* semver-compatible deprecations

* removed unneeded lifetimes (+ clippy warnings)

* silenced too many args warning
2021-01-04 14:11:59 -08:00
Bruno ZIKI Kongawi
0168178a17 Fix multiple fbs code generation failure (#6365) 2021-01-04 13:29:32 -08:00
Vladimir Glavnyy
82836a62be [idl_parser] Improve stack overflow protection (#6364)
* [idl_parser] Improve stack overflow protection

Add stack overflow protection for Flexbuffer and nested Flatbuffer parsers.
Replaces the `Recurse()` method by the new ParseDepthGuard RAII class.

* Remove move operator from Parser.

It was wrong decision to add move ctor and assignment into Parser class.
These operators will make it extremely difficult to add constant or reference fields in the future.

* Remove ';' from definition of FLATBUFFERS_DELETE_FUNC

* Format code

* Make this PR compatible with MSVC2010 (it doesn't support inherited ctor)
2021-01-04 12:39:12 -08:00
Vladimir Glavnyy
e7430bbebd [idl_parser] Check the range of explicitly set field's id value (#6363)
* [idl_parser] Check the range of explicitly set field's id value

The explicitly set `id` attribute should be a non-negative value of the `voffset_t` type.

* Format FieldIdentifierTest()
2021-01-04 12:33:31 -08:00
Richard A Hofer
24dd85fd28 Generate code to encode and decode nested flatbuffers in Python. (#6354)
* Generate code to encode and decode nested flatbuffers in Python.

* Delete accidental trailing whitespace.

* Fully delete trailing whitespace.
2021-01-04 12:18:19 -08:00
mustiikhalil
57f68e2896 [Rust] Shared String (#6367)
* Adds shared strings and tests for shared strings

* Adds resets on string_map

* Moved shared strings to use vector instead of hashmap

* Addresses all the issues

* Resolves some comments
2021-01-04 06:18:35 -08:00
mustiikhalil
44cf2bde19 Updates license date to 2021 (#6378) 2021-01-02 11:46:46 +03:00
Kamil Rojewski
be37d4da14 include_prefix support for rust (#6330)
* include_prefix support for rust

* include_prefix support for java

* formatting fixes

* Revert "include_prefix support for java"

* style fix
2020-12-30 12:02:36 -08:00
mustiikhalil
4e79d129cb [Swift] Rebuild the way swift handles structs from scratch (#6326)
* Rebuild the way swift handles structs from scratch

* Updates docs, and sample binary

* Replaces InMemory to Mutable

* Migrates docs from inmemory

* use inline for some functions

* Renamed Mutable objects

* Updates documentation
2020-12-17 14:55:32 -08:00
mqy
05192553f4 Fix typos in usage/comments; Make rust generator respect to --filenam… (#6342)
* Fix typos in usage/comments; Make rust generator respect to --filename-suffix

* run clang format
2020-12-17 13:15:27 -08:00
Kjetil Østerås
f2511d7d49 Renaming infinity variables in test.cpp (#6340)
The infinityf symbol is causing a conflict when building for cygwin. In
the cygwin math.h header there is also a symbol called infinityf. So
this patch is needed to be able to build the flatbuffer tests in a
cygwin environment.
2020-12-17 13:08:23 -08:00
Richard A Hofer
f8b203c9c4 Add vectorNumElements attribute to Builder for simpler vector creation. (#6328)
* Add vectorNumElements attribute to Builder for simpler vector creation.

This adds a default to EndVector which should simplify its use.

* Update tutorial to reflect new default arg in Python EndVector.

* Remove optional argument to Python EndVector.

* Add generated files.

* Unset Builder.vectorNumElems when not in use.
2020-12-14 12:00:28 -08:00
mustiikhalil
8ab7c7e2c8 [CI] Adds formatter to CI (#6272)
* Adds formatters CI

Adds Error message & setup formatting like cpp

Adds Swift

Adds typescript

Adds python

tests yarn

Adds format.md

* Removes unneeded scripts + moves install script to install phase

* Adds format.md content

* Adds cpp to the formatter.md and fixes ci

* Adds cpp to formatter ci
2020-12-11 10:46:10 -08:00
Wouter van Oortmerssen
7e00390289 Fix Max CI build path (#6333)
apparently the default xcodebuild path of ./build clashes with the BUILD file present (case insensitive file system?)
2020-12-11 10:31:20 -08:00
Stefan F
65c415911a Generate nullable properties in C# object-based API for optional scalars. (without -gen-mutable) (#6273)
* 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.

* Generate nullable properties in C# object-based API for optional scalars.
tests\generate_code.bat extended to test this.

Ran tests\generate_code.bat
Ran tests\Flatbuffers.Test\NetTest.bat

* %TEST_BASE_FLAGS% replaced with --gen-object-api in generate_code.bat, because only this is part of this PR. Added this same flag to generate_code.sh

* generate_code.bat and generate_code.sh changed to only test c# with object based api.
2020-12-10 16:50:30 -08:00
David P. Sicilia
a9e91116d2 [Python] Commit some orphan python genfile diffs. (#6325) 2020-12-10 16:43:40 -08:00
Derek Bailey
80a745d9b0 Fixed missing ending quotes in labeller (#6327) 2020-12-10 14:19:46 -08:00
tira-misu
9fca5e4f42 Add flatc option to inhibit all warnings #6005 (#6301)
* 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

* Add option --no-warnings to inhibit all warnings

* Fix order of member initialization

* Add documentation for --no-warnings
2020-12-10 14:03:53 -08:00
Vladimir Glavnyy
92a806b4e8 [fuzzer] Rename fuzzing dictionaries for oss-fuzz (#6318)
This commit makes the names of fuzzing dictionaries the same as the target binary names.
Also it explicitly limits size of test inputs to prevent failures in `regex` and fuzzing time-outs.
2020-12-10 14:02:01 -08:00
Casper
9c9baf6d58 bumprust (#6322)
Co-authored-by: Casper Neo <cneo@google.com>
2020-12-09 11:34:19 -08:00
Richard A Hofer
aafc5dc950 Set default initialSize for Builder to 0 (#6310)
* Set default initialSize for Builder to 0

* Change default size of builder to 1024.

This matches what the C++ and Java versions do.
2020-12-07 16:20:26 -08:00
Casper
442949bc11 Rust Flatbuffers Verifier (#6269)
* Updated comments and fixed a fundemental type error.

* bump rust flatbuffers semver

* Initial commit with verifier, need to clean up

* Verifier tested. Needs clean up and refactoring.

* Display for InvalidFlatbuffer and better errors for strings

* SimpleToVerify, some refactoring

* Combined VerifierType TableAccessorFuncBody into FollowType

* scrub todos

* Update Rust get_root functions.

There are 6 variants, with verifier options, default verifier options
and no verification "fast".

* Rename root fns

* inline

* Update to use thiserror

* fix for bad compiler

* improve error formatting

* Replace multiply with saturating_multiply

* saturating adds too

* Add docs disclaiming experimental verification system

Co-authored-by: Casper Neo <cneo@google.com>
2020-12-07 18:37:51 -05:00
David P. Sicilia
9064072e8c Version message should be a "STATUS" to avoid going to stderr. (#6316) 2020-12-07 11:50:29 -08:00
Austin Schuh
fd4c1b5ff7 Replace std::string and const char* CreateSharedString with string_view (#6315)
It is useful to be able to call CreateSharedString with a string_view.
A string_view can be implicitly converted from a std::string or a const
char*.  This means if string_view is available, we can use it instead of
both other functions and get all 3.
2020-12-07 11:49:24 -08:00
Vladimir Glavnyy
bc7eb8adeb [fuzzer] Fix mistakes in the parser and scalar fuzzers. (#6314)
The flatbuffers::Parser::Parse() isn't an idempotent method for schema parsing.
This commit removes a wrong for-loop that tried to check the same schema twice.
2020-12-07 11:47:33 -08:00
Richard A Hofer
fc960f3670 Add default to offset param of Python generated GetRootAs (#6312) 2020-12-07 11:34:07 -08:00
Vladimir Glavnyy
f437f0f7ed [fuzzer] Fix loading of schema in monster_fuzzer (#6308)
This is fix for (https://oss-fuzz.com/testcase-detail/6251772204810240)
2020-12-07 11:21:23 -08:00
Vladimir Glavnyy
7f33cf682a [C++] Switch flatc to --cpp-std c++11 C++ code generator (#6306)
Prior to this commit the default C++ code generator was `c++0x`.
A code generated with `c++0x` code-gen might have a vulnerability (undefined behavior) connected evolution of enums in a schema. This UB could break the backward compatibility if previously generated code casts an unknown enumerator to enum type that knows nothing about future enumerators added to the schema.

The main differences between `c++0x` and `c++11`:

- generated enums use explicitly declared underlying type;
- generated object-API tables don't declare default ctor() explicitly, instead of it default data member initializers are generated.

Please use `flatc --cpp-std c++0x` option for backward compatibility with old compilers.
2020-12-07 11:19:36 -08:00
Vladimir Glavnyy
8d9eae9ac9 [idl_parser] Unify parsing of NaN values read from .fbs and .json files (#6296)
This commit unifies parsing of NaN values read
from .fbs and .json files by converting them to unsigned NaN.
2020-12-07 11:12:58 -08:00
Wouter van Oortmerssen
2046bffa40 Moved various language tests from AppVeyor to GitHub Actions (#6300) 2020-12-03 11:26:27 -08:00
Casper
338393f854 Documentation updates for Optional Scalars (#6014) (#6270)
* Documentation updates for Optional Scalars

* Updated Support

* Reword stuff

* s/NULL/null

Co-authored-by: Casper Neo <cneo@google.com>
2020-11-24 14:05:39 -05:00
Vladimir Glavnyy
c27bc2d76f [C++] Add ParseJson(), Parser(Parser&&), update fuzzers (#6284)
- 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-23 10:17:44 -08:00
Wouter van Oortmerssen
bc518a5127 Fixed FlexBufferBuilder asserting on duplicate keys 2020-11-23 09:02:40 -08:00
Derek Bailey
100c59054c Added a few more paths for auto labeler (#6281) 2020-11-19 22:13:19 -08:00
Austin Schuh
e58c182443 Add --require-explicit-ids to require explicit ids (#6277)
* 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-19 17:16:45 -08:00
schoetbi
69a8b2a579 idl_gen_json_schema.cpp: Changed generation of array element types (#6253)
* 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-19 16:17:03 -08:00
Kelvin Hu
25eba6f35f fix typo (#6280) 2020-11-19 09:08:52 -08:00
Derek Bailey
e1f0f75ba6 Updated Ms build Action to fix build issue (#6279) 2020-11-19 00:20:47 -08:00
James Kuszmaul
faeb04fbe1 Add type annotation to unspecified array (#6264)
The lack of any type on the `ret` variable was causing our typescript compiler to complain.
2020-11-16 10:49:53 -08:00
mustiikhalil
537212afee [Swift] Adds a format file and reformats the swift project (#6250)
* Formats files & adds licence

* Revert arrays

* Keeps array indentation as is

* Adds licence to code formatter

* Updates code generators
2020-11-16 19:52:38 +03:00
mustiikhalil
6764f25d91 Adds a fix for enum generation (#6263) 2020-11-15 17:50:12 +03:00
AdamKorcz
d6a8dbd26f Experimental fix for failing oss-fuzz coverage build (#6259) 2020-11-13 15:48:05 -08:00
Casper
ed391e1777 BREAKING: Rust flexbuffers serde human readable set to false (#6257)
Co-authored-by: Casper Neo <cneo@google.com>
2020-11-13 07:53:01 -08:00
AdamKorcz
a49531414b Update to flags in fuzzing-cmake file (#6256) 2020-11-12 10:21:34 -08:00
Jason Lenz
de1f0342c8 Remove _POSIX_C_SOURCE and _XOPEN_SOURCE definitions when compiling o… (#6205)
* 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-12 10:12:32 -08:00
Stefan F
d0d51e2a5c flatc should support --binary --schema with optional scalar fields. (#6252)
* 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-12 10:06:09 -08:00
Ivo List
33ab26017d Bump version of rules_go to 0.24.5 (#6234)
Versions of rules_go below 0.24 include platforms repository, which are lacking
definitions of os:macos, cpu:arm64 constraints.

This definitions are needed to properly select toolchains in latest
bazel.
2020-11-12 10:04:34 -08:00
Derek Bailey
febb9d87c9 Union As Accessors for C# (#6251)
* Union As Accessors for C#

* Changed loop to be compatible with older compilers

* errant change fix
2020-11-12 09:28:21 -08:00
mustiikhalil
8778dc7c2b Resets buffer without deallocating current pointer (#6247)
Resets buffer without deallocating current pointer & Bumps version
2020-11-09 17:55:53 +03:00
OptoCloud
aae376e9a8 Add GetBufferSpan() function to bufferbuilder (#6235)
This will return the finished internal buffer data as a span
2020-11-05 18:09:01 -08:00
Paulo Pinheiro
0ff0471488 Modernize android build and sample (#6229)
Android build was dated, using the Android.mk approach. Current
project configuration on Android encourages the usage of CMake, so we
are updating the android project as an example on how to use either the
Java/Kotlin generate code or the native C++ one.
2020-11-05 14:23:37 -08:00
Casper
46a8c7e958 Added required-nested-flatbuffer to monster_test and fixed rust (#6236)
Co-authored-by: Casper Neo <cneo@google.com>
2020-11-05 13:58:06 -08:00
Derek Bailey
bc56c553ec Notify based on Labelling issues and PR (#6241) 2020-11-05 13:40:01 -08:00
Derek Bailey
07d7cd78a7 Converted globs to use single quotes (#6240) 2020-11-05 13:12:19 -08:00
Derek Bailey
cdef70e246 More adjustments to the auto labeler (#6239) 2020-11-05 13:02:33 -08:00
Derek Bailey
9dd44df35c Updated Lua labeller glob (#6238) 2020-11-05 12:50:33 -08:00
Charlie Yin
c9b29d0885 Support size-prefixed buffers and add tests for size-prefixed messages (#6232) 2020-11-05 11:23:56 -08:00
mustiikhalil
fba93e0abb Removes duplicate swift in labeler (#6228)
Removed grpc tag from swift label set & removes duplicate swift label
2020-10-31 18:35:44 +03:00
Derek Bailey
d1a545b1fb Added more labels for auto labeler (#6227) 2020-10-30 14:01:35 -07:00
Derek Bailey
ea92a668d8 [C#] Optional Scalars (#6217)
* [C#] Optional Scalars

* Moved scalar optional check to avoid null enum conversion
2020-10-30 13:18:59 -07:00
Paulo Pinheiro
6034de286a [Label Bot] Add Java and Kotlin support for the label bot (#6226)
CI is an unrelated timeout.
2020-10-30 13:18:36 -07:00
Casper
b08b0a4402 Implement Debug trait for Rust flatbuffers. (#6207)
* 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-29 12:57:29 -07:00
mustiikhalil
17ae48decc [Label Bot] Adds some languages to labeler bot (#6222)
* Adds swift, ts, go, py to labeler bot

* Removes unneeded dir search
2020-10-29 09:05:25 +03:00
Derek Bailey
fc80979253 Auto Labeler Setup, Just C# for now (#6221) 2020-10-28 22:02:32 -07:00
Derek Bailey
55658f523a Auto Labeler Setup, Just C# for now (#6218)
* Auto Labeler Setup, Just C# for now

* Removed trailer comma as that might caused the issue

* Removed any[].

* Changed .cs glob
2020-10-28 21:25:02 -07:00
Casper
14ecfe4236 Updated comments and fixed a fundamental type error. (#6214)
* Updated comments and fixed a fundemental type error.

* bump rust flatbuffers semver

Co-authored-by: Casper Neo <cneo@google.com>
2020-10-28 19:23:22 -07:00
Kamil Rojewski
a0182cdb11 optional scalars for ts/js (#6215)
* optional scalars for ts/js

* removed range based for

* removed range based for
2020-10-28 09:45:23 -07:00
Derek Bailey
0dfcc0a378 Adds NetTest.bat to run .NET Core tests on Windows (#6216) 2020-10-27 22:51:58 -07:00
Paulo Pinheiro
f9a18ea635 [Java] Implement optional scalars (#6212)
Java implementation of optional scalars, following issue #6014.
2020-10-26 17:46:50 -07:00
mustiikhalil
c7586e85aa Empties the sharedString map on reset on go and csharp (#6187)
Fixes go tests
2020-10-26 12:38:24 -07:00
Derek Bailey
914c646014 Removed C# references from java generator. Move annotations closer to definitions (#6204) 2020-10-25 21:42:29 -07:00
mustiikhalil
42d7c79977 Adds readable size to asserts in read functions (#6210) 2020-10-25 15:59:30 +03:00
Casper
e68e8d7de9 Refactor idl_gen_rust (#6206)
* Refactor idl_gen_rust to a ForAllX continuation pattern.
* Updated rust sample code

Co-authored-by: Casper Neo <cneo@google.com>
2020-10-24 15:46:55 -07:00
Vladimir Glavnyy
84809be7e7 Fix typo in flatbuffers::span declaration. (#6202) 2020-10-22 14:07:29 -07:00
Paulo Pinheiro
1606fb6375 Kotlin test optional enum (#6201)
* Add test for optional enums in Kotlin

* Rename optional_scalars2.fbs into optional_scalars.fbs

Also updated all references in the project to point to
"optional_scalars.fbs" instead of "optional_scalars2.fbs".
2020-10-22 13:36:02 -07:00
Casper
fe8e3c7e5d Mass Refactoring to use IsString and other BASE_TYPE helpers (#6193)
* 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-20 08:00:31 -07:00
Casper
8f6fa4b715 Updated SupportsAdvancedUnionFeatures to look out for string (#6190)
Co-authored-by: Casper Neo <cneo@google.com>
2020-10-19 13:16:00 -07:00
Björn Harrtell
b46db38f57 [JS/TS] Rewrite flexbuffers JS to TS (#6148)
* Partial TS rewrite

* Completed port but bugs remain

* Expose builder function

* Break out and fix stack-value and formatting
2020-10-19 13:11:35 -07:00
Casper
9fa1d27059 Rework enums in rust. (#6098)
* 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-19 11:40:03 -07:00
schoetbi
a402b3abae idl_gen_json_schema Fix generation of arrays of enums (#6184)
* 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-16 10:43:09 -07:00
Niels Hofmans
0e1415b996 fix(go_test): remove deprecated grpc call (#6183) 2020-10-15 15:47:06 -07:00
tira-misu
5cd7137103 Add generation of JSON Schema to library (#6165)
* 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-15 15:28:25 -07:00
dependabot[bot]
5be777e1d4 Bump junit from 4.12 to 4.13.1 in /grpc/tests (#6173)
Bumps [junit](https://github.com/junit-team/junit4) from 4.12 to 4.13.1.
- [Release notes](https://github.com/junit-team/junit4/releases)
- [Changelog](https://github.com/junit-team/junit4/blob/main/doc/ReleaseNotes4.12.md)
- [Commits](https://github.com/junit-team/junit4/compare/r4.12...r4.13.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-12 22:58:29 -07:00
dependabot[bot]
a49d440ecd Bump junit from 4.12 to 4.13.1 in /grpc (#6172)
Bumps [junit](https://github.com/junit-team/junit4) from 4.12 to 4.13.1.
- [Release notes](https://github.com/junit-team/junit4/releases)
- [Changelog](https://github.com/junit-team/junit4/blob/main/doc/ReleaseNotes4.12.md)
- [Commits](https://github.com/junit-team/junit4/compare/r4.12...r4.13.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-12 22:58:03 -07:00
astange
4ec5e8db90 [C++] Add option to not generate direct copy methods. (#6166)
* 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-12 12:25:10 -07:00
Vladimir Glavnyy
04bec23a37 Add Array initialization from struct constructor (#5865) (#6147)
- add flatbuffers::span
- add new constructor for `struct` with `array`
- add some test for flatbuffers::span and 'arrays_test.fbs'
2020-10-12 12:24:18 -07:00
astange
77d57fd075 Cast to right type for reserved_ subtraction (#6167)
reserved_ is a size_t so ensure that the output of cur_ - buf_ is cast to that to avoid compiler warnings.
2020-10-12 09:14:45 -07:00
Casper
543c1bbeba Fixed rust nested flatbuffers for tables other than self (#6062)
* 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-10 11:49:02 -07:00
Anass Al
cb971eece8 [C++] Fix -Wnarrowing and -Woverflow due to signed bitfields on G++ ARM (#6163)
Older versions of GCC (at least on ARM) complain about narrowing conversions and
overflows when setting the reference index (defined as an 11-bit signed integer
bitfield) to -1:

```
error: narrowing conversion of '-1' from 'int' to 'short unsigned int' inside { } [-Wnarrowing]
error: conversion from 'short unsigned int' to 'short unsigned int:11' changes value from '65535' to '2047'
```

This is due to the signedness of integer bitfields (not explicitly signed or
unsigned) being implementation-defined. This addresses this issue by explicitly
defining the signedness of all the bitfields in `flatbuffers::TypeCode` in C++.
2020-10-08 08:00:40 -07:00
mustiikhalil
7b9e61fccf [TS] GRPC Implementation (#6141)
* GRPC implementation for Typescript

* Fixes a couple of issues

* Finished implementing the typescript support for grpc

* Updated generated code

* Fixes CI
2020-10-07 09:56:30 -07:00
Casper
3359e3042f Moved C++ to optional_scalars2 and added some tests. (#6162)
* 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-07 09:46:09 -07:00
ImmConCon
187a4787f9 [Rust] Upgrade flatbuffers library to 2018 edition (#6159)
* [Rust] Upgrade flatbuffers lib to 2018 edition

* Pushed version
2020-10-06 15:55:22 -07:00
mrmarkwell
08943aa26f Flatbuffer C++ UnpackTo optimization for vectors of non-bool bytes. (#6154)
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-06 10:56:45 -07:00
mustiikhalil
5975658ebd Enables optional enums in swift (#6160)
[Swift] Enables optional enums
2020-10-06 19:00:14 +03:00
Wouter van Oortmerssen
5d3cf440e5 Updated Lobster test for optional bools/enums
The codegen for this was already correct, just added more tests
2020-10-02 10:53:47 -07:00
Casper
8ec8322f09 Ruopt enum (#6156)
* Rust support for optional enums

* make optional_scalars2 for languages that support optional enums

Co-authored-by: Casper Neo <cneo@google.com>
2020-10-02 10:30:39 -07:00
Vladimir Glavnyy
bbcc85fd4c Fix generation of C++ code with Optional<Enum> (#6155) 2020-10-02 10:27:30 -07:00
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
mustiikhalil
ff1b73128d [Swift] Optional Scalars Preparation (#6028)
* Perpares swift to take optional scalars + adds optional string helper method + disables linters in generated code

* Small fix for generated code

* Update grpc support to alpha 17 for swift
2020-07-20 20:38:50 +03:00
Vasyl Gello
2e48c8dd31 tests: Check for both quiet and signaling NaN on mipsel/hppa (#6029)
MIPSEL, MIPS64EL and HP-PA architectures have quiet and
signaling NaNs swapped. The test assumes correct values
for i386 / amd64 but obviously fails on these architectures.
It is documented in many places, like

https://software.llnl.gov/yorick-doc/stdlib/ieee.html :

Warning-- apparently there is no universal standard for what
  constitutes signalling versus quiet NaN
  on MIPS and HPPA architectures, qNaN and sNaN are reversed

https://gcc.gnu.org/onlinedocs/gcc/MIPS-Options.html :

  -mnan=2008
  -mnan=legacy

  These options control the encoding of the special
  not-a-number (NaN) IEEE 754 floating-point data.

  The -mnan=legacy option selects the legacy encoding.
  In this case quiet NaNs (qNaNs) are denoted by the first
  bit of their trailing significand field being 0, whereas
  signaling NaNs (sNaNs) are denoted by the first bit of
  their trailing significand field being 1.

  The -mnan=2008 option selects the IEEE 754-2008 encoding.
  In this case qNaNs are denoted by the first bit of their
  trailing significand field being 1, whereas sNaNs are
  denoted by the first bit of their trailing significand
  field being 0.

  The default is -mnan=legacy unless GCC has been configured
  with --with-nan=2008.

The behavior mentioned above causes FTBFS in Debian starting
with 1.12.0:

https://buildd.debian.org/status/fetch.php?pkg=flatbuffers&arch=mips64el&ver=1.12.1%7Egit20200711.33e2d80%2Bdfsg1-0.1&stamp=1594830681&raw=0
https://buildd.debian.org/status/fetch.php?pkg=flatbuffers&arch=mipsel&ver=1.12.1%7Egit20200711.33e2d80%2Bdfsg1-0.1&stamp=1594832647&raw=0
https://buildd.debian.org/status/fetch.php?pkg=flatbuffers&arch=hppa&ver=1.12.1%7Egit20200711.33e2d80%2Bdfsg1-0.1&stamp=1594830726&raw=0

For HP-PA (PA-RISC) there is no way to override the reversal,
and for MIPSEL/MIPS64EL there is no macro defining the '-mnan'
choice, so both variants were added with OR boolean operator.

Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
2020-07-20 10:18:02 -07:00
Dmitry
6942704f2b support deprecated flag in json schema (#6022) 2020-07-16 13:49:42 -07:00
Casper
9ecd2e16c2 Flatc parser support for nullable scalars (#6026)
* Parser support for nullable scalars

* Use older C++ features

* use default element

* Add a test for json, flexbuffers, and null

* test comments and names

Co-authored-by: Casper Neo <cneo@google.com>
2020-07-16 13:43:47 -07:00
Zhaoxuan Jiang
33e2d80791 [Dart] Generate constant values map for enums (#6025)
Dart schema compiler generated a static getter for enum values, which
always created a new map instance for its callers. See #5819.
Now it generates const map for better performance
and readability.
2020-07-10 17:42:22 -07:00
Kamil Rojewski
969d0f7a63 Using proper symbol name for reexport (#6021)
Co-authored-by: Kamil Rojewski <kamil.rojewski@gmail.com>
2020-07-06 08:40:56 -07:00
Vasyl Gello
515a4052a7 Silence false positive "-Wstringop-overflow" on GCC 10.0 to 11.0 (#6020) 2020-07-06 08:38:06 -07:00
Kamil Rojewski
36fbe6f13e Updated FB import (#6019)
Previous FB import was based on the original early TS implementation
and did not take into accout NPM. There doesn't seem to be a use
for current implemenentation anymore, while NPM compatibility is
needed.

Co-authored-by: Kamil Rojewski <kamil.rojewski@gmail.com>
2020-07-02 12:44:55 -07:00
Paulo Pinheiro
b69fc8cc95 [Java] Add support for shared strings on FlatBufferBuilder. (#6012)
Added a method FlatBufferBuilder::createSharedString that
enable string sharing for building messages on java.

The shared pool will only contains strings inserted by
this methods.
2020-07-02 12:40:56 -07:00
Kamil Rojewski
ab6af18d9f Not using non-existent create method for obj api (#6015)
Co-authored-by: Kamil Rojewski <kamil.rojewski@gmail.com>
2020-07-02 12:18:21 -07:00
mustiikhalil
37a5dee105 Code cleanup + updates test and readme (#6004)
Updates Readme + adds asserts

Fixes documentation
2020-06-30 21:37:43 +03:00
Casper
8a721f69a1 Serde with bytes maps to Blob (#6009)
* Serde with_bytes maps to Blob

* Bump rust flexbuffers minor version number

Co-authored-by: Casper Neo <cneo@google.com>
2020-06-28 19:58:08 -07:00
Liu Liu
e810635eaa [Swift] FlatBuffers createMonster method doesn't treat struct properly (#5992)
* [Swift] FlatBuffers createMonster method doesn't treat struct properly

This PR fixed a issue where a struct is not treated properly when use
create inside.

A example would be the pos inside Monster. The createMonster method
takes an Offset for pos. However, FlatBuffersBuilder.add(struct:)
doesn't really take Offset argument. That means we don't really add a
struct at all for Monster.

It will show up as the pos never set.

This doesn't show up in FlatBuffersMonsterWriterTests.swift because it
implements its own createMonster method, which happens do the dance
properly (i.e. first call create(struct) and then immediately call
add:).

This PR modified the `add(pos:)` interface such that it takes the
UnsafeMutableRawPointer directly, calling `create(struct:)` under the hood.

I can add unit tests once the direction of this PR approved.

* Fix object api pack method codegen.

* Add unit tests that uses Monster.createMonster method to serialize.

* Updated sample_binary.swift
2020-06-28 12:36:55 +03:00
Shengzhe
4995e15273 Manage grpc dependency in Bazel's WORKSPACE file. (#5995)
flatbuffers project currently depends on an old version of GRPC library and has known issues working with the latest version (issue #5836). Therefore, a patch file is created and put under bazel/ directory before supporting the latest GRPC version.
2020-06-26 15:39:23 -07:00
Derek Bailey
60b6066feb Add warning to schema parser if field name is not snake_case. (#6005)
* Added code gen for evolution tests back in.

* General generate code and clang format

* Added code gen for evolution tests back in.

* General generate code and clang format

* reran generate_code.sh

* Added code gen for evolution tests back in.

* General generate code and clang format

* Added code gen for evolution tests back in.

* General generate code and clang format

* Enforce snake_case for schema field names

* Switched to basic for loop, Fixed warning message
2020-06-26 11:16:02 -07:00
Johan Andersson
35d45cac7a [Rust] Flexbuffers dependency cleanup and fixes (#5998)
* Fix doc comment warnings

Can't use doc comment "///" syntax on macros, that generates the following warning:

warning: unused doc comment
   --> src\flexbuffer_type.rs:236:5
    |
236 |     /// returns true if and only if the flexbuffer type is `VectorFloat4`.
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ rustdoc does not generate documentation for macros
    |
    = help: to document an item produced by a macro, the macro must produce the documentation as part of its expansion

So switched to just use ordinary "//" comments on these to be warning free

* Upgrade num_enum 0.4.1 -> 0.5.0

* Remove unused and non-working usage of test crates

* Remove usage of abandoned debug_stub_derive crate

Which brought in old pre-v1 syn and quote crates.

This replaces it with just manual Debug trait implementation instead for the 2 cases
2020-06-25 17:12:10 -07:00
Derek Bailey
165a6e3d1e Re-added Evolution Schema Code Generation Command (#5999)
* Fixed refractoring issue in reflection/generate_code.sh. Also, mv deletes the original file, so I don't need to clean it up manually in that case.

* Fixed Dart Tests by removing code-gen for included files.

* Added code gen for evolution tests back in.

* General generate code and clang format

* Added evolution schema generation to .bat file

* Added code gen for evolution tests back in.

* General generate code and clang format

* Added evolution schema generation to .bat file

* reran generate_code.sh

* Removed wildcard from generate_code.bat that doesn't work
2020-06-25 15:35:23 -07:00
martind1111
13d3fb2ea6 Fix RPM install conflict (#6003) 2020-06-25 15:33:58 -07:00
Liu Liu
d64078eb27 [Swift] Initialize memory when clear ByteBuffer (#5982)
* Initialize memory when clear ByteBuffer

It seems (based on my limited understanding) that FlatBuffers requires
the writable area to be 0 initialized. However, we missed it when clear
the buffer to reinitialize it.

This PR fixed that by calling initialize (also fixed the typo)
explicitly.

* Update version to 0.5.3
2020-06-25 15:11:38 -07:00
hanstzou
ca1190a3d8 [TS] Use proper TypedArray in create*Vector (#5991)
* [TS] Use proper TypedArray in create*Vector

This commit adds TypeScript function overloads to create*Vector for
proper TypedArray types, effectively resolves #5373.

* Add @deprecated to old Uint8Array overloads
2020-06-25 14:42:47 -07:00
mjvankampen
7571b2ac56 [C++] Updates real_path to be truly portable (#5787)
* Removes posix definition

stat and fseeko are not used. Tested on QNX (GCC 5.4.0) and MinGw

* Updates realpath to more modern (2008) version

* Removes unix specific headers

* Adds detection of strtoll_l as android API < 21 does not provide it

* Includes cstdlib and formatting

Removes cmakelist alterations as not necessary. Formatting not complete.

* Stdlib outside if

Stdlib is available on all platforms

* Fixes indentation

* Adds locale check to android build

* Adds missing brace

* full names

* Removes again, no clue

* Updates base to check for locale independent android

Cmake already checks for others, also MSC?

* Changes to test on available and not requested

* Fixes android bad xopen_version define

* Removes warning
2020-06-25 14:40:10 -07:00
Jean-François Roy
e5a8f76a4b [C++] Generate default member initializers for >= C++11 (#5989)
In >= C++11 mode, generate default member initializers instead of a
default constructor.

The new code is semantically equivalent, but will allow aggregate
initialization in C++20.

This is a different take on #5951.
2020-06-22 18:06:15 -07:00
Paulo Pinheiro
413bb9b553 [Kotlin] Fix Access to union of vector element (#5994)
Kotlin code generation was producing wrong logic for accessors
of vector of union elements. This was shadowed by the fact[1] that asserts
in Kotlin are silently ignored unless the flag "-ea" is passed to the JVM.

The tests are also updated to enable asserts.

1 - https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/assert.html
2020-06-22 17:08:35 -07:00
Liu Liu
f35184aef9 [Swift] Add parsing from unowned UnsafeMutableRawPointer for ByteBuffer (#5981)
* RFC: Add ExternalStorage for ByteBuffer in Swift implementation

This PR proposed one more API for ByteBuffer such that no copy is
required to parse FlatBuffers content. This API has limited use, but for
cases that you need to read part of the flatbuffers' data to decide
whether you want to parse / copy the full buffer out, it is useful.

* Use a variable rather than protocol.

* Revert grouping changes from the other PR.

* Add unit test to read from unowned UnsafePointer.

* Manifest changed.
2020-06-22 17:05:36 -07:00
Alex Ames
b124b76258 Removed requirement that enums be declared in ascending order. (#5887) 2020-06-22 17:02:15 -07:00
Javier Serrano
0ec7600c67 Do not remove the last digit from float values (#5974)
Trailing zeros are already removed inside the function FloatToString,
that is called immediately before the lines deleted by this commit.
2020-06-22 16:57:45 -07:00
Gleb Mazovetskiy
14baf45c90 Mark GetBufferMinAlignment() const (#5985)
Like GetBufferPointer() and GetSize(), marks GetBufferMinAlignment function as const
2020-06-18 11:51:43 -07:00
Dimitri Mitropoulos
9abb2ec2cc TypeScript/JavaScript docs improvements (#5984)
* use correct language formatter for TypeScript examples

* fixes typo in JS/TS copied from PHP (apparently)

the variables are not named with a prefixed `$`

* fixes bizarre line breaks in markdown examples

* fixes snake case typo to fit JS/TS conventions

* makes example of Uint8Array usage explicit

* removes random extra lines between language blocks

* adds simple example for writing to file in node

* typo: flabuffers => flatbuffers

* adds (previously missing) code blocks to TypeScript code block

* adds context about where `monster_generated` comes from

to the uninitiated, a bit of help like this is welcome
2020-06-18 10:23:32 -07:00
mustiikhalil
2e57d80b13 [Swift] Internal library improvements (#5965)
* Moves addition to overflow addition in swift by using &+

Moves code to use Int instead of UInt32 & fixes functions

Updates swift performance to great

Updated version to 0.5.2

Updated swift package version to 5.2

Updated docker to swift 5.2

Removed all none & arithmetic operations

* Small refactoring
2020-06-18 10:14:38 -07:00
laurens-dg
cfc7753a4c [Doc] Added missing letters to compiler options (#5976)
These are correct in the help section of compiler, but missing some letters here.
2020-06-18 10:02:00 -07:00
Casper
12ddc8a920 Rust Flexbuffers Documentation update (#5979)
* Update samples and docs

* Fixed a line of documentation

Co-authored-by: Casper Neo <cneo@google.com>
2020-06-18 00:01:48 -07:00
Dimitri Mitropoulos
24ad35709d [docs] typo: updates monsterdata.json to be valid json (#5978)
* updates monsterdata.json to be valid json

the same monster.json file was not valid json

* updates reference to monsterdata.json in docs to also be valid json
2020-06-17 22:35:24 -07:00
Liu Liu
cc44a44427 [idl_parser] Mark typefield as deprecated (#5958)
* Mark typefield as deprecated

* Add UnionDeprecation Test.

* Update to use evolution schema instead.

* Use --scoped-enums to compile.
2020-06-15 23:18:12 -07:00
Derek Bailey
9ab4a5c0e2 Deleted old stale bot
The new stale action replaces the function of this bot, so removing the old one. 

It also prevents the two bots from battling each other :)
2020-06-15 13:39:46 -07:00
Derek Bailey
6682cfe870 Increased Operations per run in stale.yml
The default operations per run is 30 which would be consumed on the reprocessing already-marked issues. Greatly increased the operations per run to process all issues and pull request (~200 + 83 * 5).
2020-06-15 10:05:53 -07:00
Derek Bailey
64922904bc Adding Stale Action to clean up PR and Issues
Uses the Stale action (https://github.com/actions/stale) to help clean up older Issues and PR. Set to 6 months to mark as stale, and 14 days to close stale.
2020-06-12 13:15:11 -07:00
volkan-ozdemir
8e505cb677 [C++] Fixed/Enabled --cpp-ptr-type std::shared_ptr [#5813] (#5959) 2020-06-11 16:38:40 -07:00
Mika Raento
a28357d7ac Propagate boolean default values from proto to fbs (#5964) 2020-06-11 10:15:19 -07:00
mustiikhalil
7cb4762a61 [Swift] Improving reallocation time by using memcpy and moving reallocation code to storage (#5960)
Removes stride

Use capacity - current size to initialize

Fixes memory leak

Updated test code for linux
2020-06-11 08:53:32 -07:00
Vladimir Glavnyy
4e45f7c9e8 Fix error in SimpleQSort (#5955) 2020-06-09 23:35:07 -07:00
Malar Kannan
7ac0264053 fix error on GRPC Python - ignore namespace tree if not specified (#5862) (#5922) 2020-06-08 10:18:46 -07:00
mustiikhalil
108e981dbe Required is now implemented in swift (#5952) 2020-06-08 10:08:16 -07:00
Wouter van Oortmerssen
94a78e3853 Fixed: Access violation and ASAN/UNSAN failures with sorted tables
https://github.com/google/flatbuffers/issues/5945
2020-06-08 09:50:40 -07:00
Matt Brubeck
53fb453e04 [rust] Add FlatBufferBuilder::force_defaults API (#5946)
* [rust] Add force_defaults method FlatBufferBuilder

This works just like the same method already available in other
languages.

* Add binary format test for force_defaults
2020-06-08 09:47:36 -07:00
Paulo Pinheiro
17c1f35fa0 [FlexBuffer][Java] ReadWriteBuf and ReadBuf interface public (#5948)
Those interfaces need to be public for use cases where the user pass a buffer to FlexBuffers class that is not a ByteBuffer.

This will fix #5944
2020-06-08 09:35:51 -07:00
greenrobot Team
2eaf57778c [Java] Grow ArrayReadWriteBuf enough to match requested capacity. (#5921)
* [Java] Grow ArrayReadWriteBuf enough to match requested capacity.

Also handle requested capacity overflowing.

* [Java] Improve readability of ArrayReadWriteBuf.requestCapacity()

* [Java] prepare testBuilderGrowth() to fail again once FlexBuffersBuilder uses ByteBufferReadWriteBuf internally, add TestFail() as a better alternative to a plain "assert false"

* [Java] Revert some test changes and extract a small string that was used more than once; one could say three times, however, it might be worthy of a discussion if the third occasion also falls into this category, as it is an independent use case and thus would work in the same way even if the value changed.

Co-authored-by: Markus <markus@greenrobot>
2020-06-04 19:48:25 -07:00
mustiikhalil
666800da36 Adds bool support in structs + updates grpc support + CI upgrades (#5943) 2020-06-04 09:14:18 -07:00
Kamil Rojewski
38ed69eb3d fixed mutating inline values (#5942)
Co-authored-by: Kamil Rojewski <kamil.rojewski@gmail.com>
2020-06-04 09:08:41 -07:00
Laurentiu Cristofor
d026e6f071 Add static asserts to ensure that reflection API arrays are kept in sync (#5934)
* Add static asserts to ensure that reflection API arrays are kept in sync

* Move changes from generated file into source fbs file

* Rename enum value and regenerate reflection_generated.h

* Add comments to each entries of type sizes array
2020-06-02 09:50:56 -07:00
bakinovsky-m
988164f6e1 [C++] Got rid of memset's in constructors (#5938)
* [C++] removed array's memsets from struct parametrized constructor

now POD-typed arrays are zero-initialized
and class-typed arrays are default-initialized

* [C++] memset -> zero/default initialization in default constructor

* [C++] Struct-type and array default initialization

* [C++] Newly generated tests

* [C++] forgotten test

* [C++] curly brace by code style

* [C++] test if memory is 0's after placement new

* [C++] memory leak fix

* [C++] simplifying and non-dynamic memory in test

* [C++] code cleanup

* [C++] disable old-compiler warning

* [C++] windows build fix (try)

* [C++] debug-new win build fix
2020-06-01 17:58:52 -07:00
Derek Bailey
7179a5a8ba General Codebase clean up (#5939)
* Fixed refractoring issue in reflection/generate_code.sh. Also, mv deletes the original file, so I don't need to clean it up manually in that case.

* Ensuring test/generate_code.sh was ran

* Fixed Dart Tests by removing code-gen for included files.

* General cleanup of codebase.
2020-06-01 08:40:55 -07:00
stefan301
a0da0c08c6 Add GetStringView like GetString, GetCstring (#5937)
* 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

Co-authored-by: stefan301 <Stefan.Felkel@de.Zuken.com>
2020-05-29 10:00:46 -07:00
mugisoba
ac203b2092 [C#] Add file identifier to ObjectAPI Serialization Utility. (#5920)
* use Finish***Buffer instead.

* add file_identifier test.
2020-05-21 09:14:20 -07:00
Kamil Rojewski
8dd1bf25b5 not creating creation methods when using structs (#5919)
* not creating creation methods when using structs

* vs2015 build fix

Co-authored-by: Kamil Rojewski <kamil.rojewski@gmail.com>
2020-05-18 09:39:19 -07:00
Maxim Zaks
5aa443d98c [Dart] Adding FlexBuffers support (#5853)
* Adding FlexBuffers support for Dart language
2020-05-18 07:50:39 -07:00
Derek Bailey
0fa087657e [Dart] Getting tests/DartTest.sh to work on master. (#5915)
* Fixed refractoring issue in reflection/generate_code.sh. Also, mv deletes the original file, so I don't need to clean it up manually in that case.

* Fixed Dart Tests by removing code-gen for included files.
2020-05-15 18:13:29 -07:00
Vladimir Glavnyy
424a473e1f Schema parser: prohibit declaration of an array of pointers inside structs (#5907)
* Fix issue #5906, Prohibit declaration of an array of pointers inside structs

- idl_parser.cpp: Prohibit declaration of an array of pointers inside structs
- idl_gen_cpp.cpp: Extract GenStructConstructor() method from GenStruct() to simplify future modification
- idl_gen_cpp.cpp: Add assert for checking of Array fields in structs on code-generation stage

* Fix the error 'unused local variable' in release build

* Fix: format the PR code according to coding rules

* Add test-case and fix review notes
2020-05-14 11:39:58 -07:00
Casper
c3faa83463 Fix Cargo.toml dependencies (#5911)
* Fix Cargo.toml dependencies

* less specific serde dependency

Co-authored-by: Casper Neo <cneo@google.com>
2020-05-13 11:24:32 -07:00
Dan Field
91399ad055 fix union type names (#5902)
* fix union type names

* fix up generation and test

* format

* update codegen
2020-05-13 10:26:32 -07:00
Casper
32782e4ad1 Update Rust Flexbuffers metadata before publishing (#5905)
Co-authored-by: Casper Neo <cneo@google.com>
2020-05-11 19:46:37 -07:00
Khoi Dinh Trinh
e7f3b16905 [TS] Make Obj-API work with --short-names (#5898)
* changed function used for getting struct name

* re-generated code
2020-05-11 14:55:57 -07:00
Kamil Rojewski
12ed1fe4a9 fixed invalid imports with --gen-all (#5895)
* fixed invalid imports with --gen-all

* only excluding crate imports

Co-authored-by: Kamil Rojewski <kamil.rojewski@gmail.com>
2020-05-07 16:21:30 -07:00
Derek Bailey
85ee4df7a2 [C#] Thread safe reads of Double and Float values from a ByteBuffer (#5900)
* Fixed refractoring issue in reflection/generate_code.sh. Also, mv deletes the original file, so I don't need to clean it up manually in that case.

* Thread safe reads of Double and Floats from ByteBuffer
2020-05-07 14:33:29 -07:00
Dmitriy Kovalev
de89bd1933 Implement flexbuffers in python (#5880) 2020-05-07 14:26:33 -07:00
Casper
8be05f6bd4 Rust Flexbuffers (#5669)
* Cargo clippy lints

* more lints

* more lints

* Restored a doc comment

* Comment on float eps-eq and adjusted casting

* Rust Flexbuffers

* more serde tests, removed some unsafe

* Redid serde to be map-like and Reader is Display

* Moved iter from Reader to VectorReader

* Serious quickcheck + bugs

* wvo api

* Made types smaller for a reasonable speedup

* redid reading in a way that's a bit faster.

Profiling shows the rust slowdown as building +10%, reading +20%

* src/bin are developer binaries in rust

* Root and Map width are not packed

* key null check is debug only + doc changes

* BuilderOptions

* Documentation

* Documentation

* Moved tests to rust_usage_test

* Moved rust flexbuffers samples to Flatbuffers/samples

* Fixed RustTest

* Fixed for Rust 1.37.0

* Upgraded to rust 1_40_0

* fixed a little-endian-only feature in a test

* 1.40.0

* fixed some benchmarks for bigendian

* Updated .bat file

* misspelling

* Gold Flexbuffer test.

* Serialize,Deserialize, std::error::Error for Errors.

* Undo rustfmt in integration_test.rs

* from_slice instead of from_vec

* Added comments to unsafe blocks

* expanded on comment

* bump

Co-authored-by: CasperN <cneo@google.com>
2020-05-07 14:11:26 -07:00
mustiikhalil
870ecbc09a [swift] Moves code to use VTablesStorage (#5888)
* Moves the code to use _vtablestorage

Rebuilt the test to confirm to the new API

Adds documentation + generates code for grpc

Reverts indentation

v0.4.0

Updated swift/readme.md

Updates VtableStorage to ensure space instead of reallocating each time

Fixes str count not being correct

* Fixes issue with boolean constant not being set + removes unused function
2020-05-07 12:28:42 -07:00
Markus Junginger
c2da8d5d85 [Java][FlexBuffers] Make FlexBuffersBuilder reusable by adding clear() (#5889) (#5890) 2020-05-07 12:26:55 -07:00
Adam Oleksy
e84cbff673 Align package name to FindFlatBuffers.cmake (#5899)
This change is for fix warning:
```
CMake Warning (dev) at /home/aoleksy/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:272 (message):
  The package name passed to `find_package_handle_standard_args`
  (flatbuffers) does not match the name of the calling package (FlatBuffers).
  This can lead to problems in calling code that expects `find_package`
  result variables (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  FindFlatBuffers.cmake:33 (find_package_handle_standard_args)
  CMakeLists.txt:6 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.
```
2020-05-07 12:22:12 -07:00
Carol (Nichols || Goulding)
f94e6c84e0 Small tutorial improvements - documentation only (#5894)
* Use code formatting for a code snippet

* Minor grammar, spelling, and Markdown fixes
2020-05-07 12:15:11 -07:00
Wouter van Oortmerssen
f12cca8bcb Attempt at adding Github Actions CI 2020-05-05 13:56:37 -07:00
Dmitry Volosnykh
7e4124d6e6 Handle git program or .git folder absence (#5878)
Assume version is 0.0.0.0 in such cases.
2020-05-04 13:23:41 -07:00
Thomas
a875d247ad only add native_include_files if object based api is enabled (#5886)
The native include files tag is intended to be used together with the object based api. A client which does not use the object based api should have no need to know about the additional include files needed for the object based api. The generated flatbuffers code without object api enabled should compile without the additional header files.
2020-05-04 12:27:50 -07:00
Mika Raento
6e9f5d9810 Respect shared attribute in Parser (#5885)
Respects the 'shared' field attribute when reading data with Parser.
2020-05-04 10:33:11 -07:00
Even Rouault
ff1c78233d include/flatbuffers: typo fixes in comments (#5884) 2020-05-04 10:21:57 -07:00
mustiikhalil
2e9a196734 Updates swift docs for package management (#5883)
Small fix for the clear function
2020-05-04 10:18:38 -07:00
jrop
e3cb07d321 [Rust] idl_gen_rust.cpp: (Option/required-aware codegen for unions) (#5850)
* idl_gen_rust.cpp: Fix google/flatbuffers#5849 (Option/required-aware
codegen for unions)

The generated code was assuming that an Option is always returned by the
union-getter method: however, this is only true if the field is not
marked as `(required)`.

* idl_gen_rust.cpp: flip conditional

* idl_gen_rust.cpp: Add comment, as requested in review

The code added is not covered by the integration test
2020-05-04 00:16:57 -07:00
Mika Raento
712866d57b Propagate use_string_pooling in CopyTable (#5879)
This allows using CopyTable for deduplicating strings.
2020-04-30 08:58:43 -07:00
Kamil Rojewski
44c919a9e8 Not using reexports with --gen-all (#5873)
Co-authored-by: Kamil Rojewski <kamil.rojewski@gmail.com>
2020-04-27 12:35:42 -07:00
Alex Ames
99aa1ef21d Added INCLUDE_PREFIX option for flatbuffers_generate_headers (#5866)
This option was in an earlier revision of flatbuffers_generate_headers
but was lost while refactoring by mistake. We have it as a function
argument rather than one of the optional flags so that we can use it to
inform the rule where to place the generated headers, so that the file
location matches the prefix that will be added to the filenames in the
generated files.

Also fixed some of the documentation in the file.
2020-04-23 10:09:19 -07:00
Wouter van Oortmerssen
40ba170c94 Fixed text in internals doc that implied structs can be root 2020-04-23 09:28:22 -07:00
mustiikhalil
cb4d0f72e3 [Swift] Object API support (#5826)
* Adds Object-api support to swift

* Fixed indentation issues

* Removed indentation within namespaces
2020-04-13 09:28:56 -07:00
Khoi Dinh Trinh
003e164057 [TS] Add Obj API (#5788)
* added basic code

* backup work

* got class property to work

* backup progress

* implementented fmt for creating code

* added docs for genFieldUtils

* back up work

* added base helper js func

* added union js code

* added unpackTo and base for pack

* added pack code

* added null check for packing struct list

* passes compile test

* fixed some spacing of generated functions

* added annotations for constructors

* added obj api unpack test

* tested pack to work

* merge branch

* separated js and ts test

* fixed union signature to include string

* fixed generator to support string union

* hardcoded fb builder name

* refactored struct vector creation

* work around createLong

* handle default value in constructor

* update typescript docs

* added notes about import flag

* fixed formatting stuffs

* undo TypescriptTest change

* refactored fmt

* updated generated code

* remove ignoring union_vector for js

* revert changes for .project

* revert changes for package.json

* don't generate js in ts test

* fixed android project file

* removed unused js function

* removed package-lock.json

* adjust createObjList to new signature

* changed regex to callback style

* fixed package.json

* used existing func for generating annotation

* changed ternary to !!

* added return type for lambda

* removed callback style for obj api generator

* fixed js file indentation

* removed unused header

* added tests for string only union

* handle string only union and refactor union conv func

* updated generated ts files

* renamed union conv func

* made js test create files like other languages

* removed union string only handling

* don't allow null in createObjectOffsetList

* updated generated ts code

* changed the line that triggers Windows build errors

* hopefully fix CI error
2020-04-09 09:53:16 -07:00
Meng Yang
21cf300f4c fix cpp usage markdown error (#5845) 2020-04-09 09:38:58 -07:00
mustiikhalil
9655e12d6d Upgraded swift implementation for grpc (#5843)
Updated version number
2020-04-06 10:05:56 -07:00
Anass Al
fb96fadc20 [C#] Fix nested structs and arrays in Object API (#5765)
* [C#] Fix nested structs and arrays in Object API

The adds support for nested structs and fixed size arrays in the C#
Object API codegen which previously generated invalid code that wouldn't
compile.

- Nested structs would originally generate syntax errors due to adding an
  additional `.` to separate fields.
- Fixed size arrays of nested structs would originally generate code for
  the first field in the top most struct, and would lead to a compiler
  error due to referencing undefined variables.

* [C#] fix nested structs and arrays of structs.

* fix nested structs + arrays

* add table support

* Cleanup code

Co-authored-by: mugisoba <mugisoba+github@icloud.com>
2020-04-06 09:27:13 -07:00
Max Burke
408f11fbdd [ts] Fix empty source/dest namespaces when reexporting. (#5841)
When either source or destination or both namespaces were empty, flatc
was generating incorrect TS code.

For example:

```
export namespace  {
export import ObjectId = NS10770172024577249292..ObjectId;}
```

In this case the target namespace is empty, and so is the namespace
between the NSxxx placeholder and the target type.
2020-04-06 09:09:15 -07:00
mustiikhalil
a83caf5910 Improves performance for the swift library by using structs + a storage class (#5835) 2020-04-02 12:55:30 -07:00
Paulo Pinheiro
925fab6b15 [Java][FlexBuffers] Optimize Map access (#5735)
The original implementation of map access is very naive:
- Encode String to UTF8 byte[]
- Creates a new KeyVector
- Performs a binary search to find the key
- return value

So every access to the Map there was useless allocations of Keys and KeyVector
and complete encoding of the search key, which for most comparisons would be wasteful.

This changes completely removes the use of KeyVector and compute the key
positions on the spot. Besides that, it compares keys codepoint-by-codepoint,
avoiding unnecessary allocations and reducing encoding for most cases.

Some benchmarks result in a 2.75x speedup.
2020-03-30 13:46:42 -07:00
Olivier Le Doeuff
d9fecc3327 [CMake] : Add precompiled header support with FLATBUFFERS_ENABLE_PCH (#5827)
* [CMake] : Add precompiled header support with FLATBUFFERS_ENABLE_PCH

FLATBUFFERS_ENABLE_PCH enable precompile headers support for 'flatbuffers' and 'flatc'. Default if OFF.
You need to set it to ON to make it work. 'cmake -DFLATBUFFERS_ENABLE_PCH=ON ..'
This will only work if CMake version is >= 3.16, because target_precompile_headers is used.
If CMake doesn't have target_precompile_headers, then nothing will happen.
This can speed up compilation time.
Precompiled header file for 'flatbuffers' is 'pch.h'
Precompiled header file for 'flatc' is 'flatc_pch.h'

* Enable FLATBUFFERS_ENABLE_PCH for VC 2017 and VS2019 builds

* [CMake]: Fix error in FLATBUFFERS_ENABLE_PCH description

* Add a function add_pch_to_target to avoid copy and pasting the same code like add_fsanitize_to_target
Move pch.h and flatc_pch.h from include/flatbuffers to include/flatbuffers/pch
Make flatc_pch.h depends on pch.h since it extend it
2020-03-27 08:35:44 -07:00
Alex Ames
e9d4532401 Added flatbuffers_generate_headers and flatbuffers_generate_binary_files cmake functions. (#5830)
flatbuffers_generate_headers is a function that can be used to generate Flatbuffers headers and binary headers. It uses named argument flags to wrap all the flags relevant to C++ header generation that flatc uses. It generates an interface library that can be added as a dependency of other targets.

flatbuffers_generate_binary_files is a function that can be used to generate Flatbuffers binaries. It uses named argument flags to wrap all the flags relevant to C++ binary generation from JSON file that flatc uses. It generates an interface library that can be added as a dependency of other targets.
2020-03-27 08:33:12 -07:00
Dmitriy Kovalev
c37c989ed6 Correct calculation of vector element size (#5831)
Number of elements on the stack shouldn't affect the calculation
of ElemWidth(). Variable 'start' needs to be subtracted from the
loop variable 'i' to make indexing zero-based.

There is an additional unit test to pack nested vectors. Size of
the packed buffer *without* this fix is 798 and only 664 bytes
*with* the fix.
2020-03-26 08:54:52 -07:00
Arthur O'Dwyer
6b271b7ecb Fix Clang-trunk warnings about special members deprecated in C++20. (#5829)
For example:

    include/flatbuffers/reflection.h:365:8: error: definition of implicit copy
          constructor for 'pointer_inside_vector<flatbuffers::Table, unsigned char>'
          is deprecated because it has a user-declared copy assignment operator
          [-Werror,-Wdeprecated-copy]
      void operator=(const pointer_inside_vector &piv);
           ^

It's unclear why the old code wanted to declare a public `operator=`
without defining it; that just seems like a misunderstanding of the C++03 idiom
for deleting a member function. And anyway, we don't *want* to delete the
assignment operator; these are polymorphic types that do not follow value
semantics and nobody should ever be trying to copy them. So the simplest fix
is just to go back to the Rule of Zero: remove the declaration of `operator=`
and let the compiler do what it wanted to do originally anyway.
"The best code is no code."

Also, update the generated .h files.

Fixes #5649.
2020-03-23 10:01:11 -07:00
Vladimir Glavnyy
90f3b8e8c7 Fix float_constant definition in './doc/Grammar.md` (#5828) 2020-03-23 09:51:57 -07:00
stefan301
3af7359345 [csharp] flatc should generate a 'Create…' method for tables with struct field… (#5818)
* flatc should generate a 'Create…' method for tables with struct fields when also generating the object based api (C#)
https://stackoverflow.com/questions/60724317/flatc-should-generate-a-create-method-for-tables-with-struct-fields-when-al

* missing namespace fixed: C:\projects\flatbuffers\tests\namespace_test\NamespaceA\TableInFirstNS.cs(30,7): error CS0246: The type or namespace name 'StructInNestedNST' could not be found (are you missing a using directive or an assembly reference?) [C:\projects\flatbuffers\tests\FlatBuffers.Test\FlatBuffers.Test.csproj]

Co-authored-by: stefan301 <Stefan.Felkel@de.Zuken.com>
2020-03-23 09:39:26 -07:00
Yurii Nakonechnyi
c4231c3cb9 Updated doxyfile - added missing files (#5824)
Added missing Java/C#/Switft files - that fixes references to them. Removed non-existent "JavaCsharpUsage.md".
2020-03-20 10:13:47 -07:00
Ekene Madu
9657df184e Update Grammar.md (#5820)
* Update Grammar.md

Some consistency fixes to the grammar file

* Some more minor fixes to Grammar.md

* Update Grammar.md
2020-03-20 10:12:23 -07:00
a-maurice
97ffc590e3 Include CPack only when explictly packaging (#5817)
Including CPack without the additional packaging information creates unused project files, and can potentially cause issues for projects including Flatbuffers that also use CPack.
2020-03-17 13:38:29 -07:00
stefan301
8b52af65bc [C++] Add max_depth and max_tables parameters to reflection::Verify (#5815)
* 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

* [C++] Add max_depth and max_tables parameters to reflection::Verify

Co-authored-by: Felkel <stefan@eas.local>
Co-authored-by: stefan301 <Stefan.Felkel@de.Zuken.com>
2020-03-16 12:19:11 -07:00
Vladimir Glavnyy
9b034eee12 Fix interpretation of 'nan(number)' by the idl_parser (#5810)
* Parser reject "nan(n)" string as it does with nan(n)

* Adjust scalar fuzzer to ignore '$schema' substrings

- Scalar fuzzer ignores '$schema' substrings at the input
- Added 'scalar_debug' target to simplify research of fuzzed cases

* Improve formatting of './tests/fuzzer/CMakeLists.txt'
2020-03-16 11:59:34 -07:00
mustiikhalil
3e9ac3cff9 [Scripts] Adds swift to generated code (#5806)
* Moved swifttest.sh code generator to generate_code + fix issue in ghpages

* Fixes small issue with cocoapods documentation
2020-03-16 11:55:59 -07:00
Wouter van Oortmerssen
697147a2e6 updated maven build files
Change-Id: I33c69978fe7a22485a7fd5ceb7a480e84e8bcdb3
2020-03-16 11:33:42 -07:00
Wouter van Oortmerssen
6df40a2471 pre-tag version bump for 1.12
Change-Id: I84a9365e9d8a1afe333b1df85058401ffe0a6b7c
2020-03-12 15:33:39 -07:00
mustiikhalil
0dba63909f Removes the inner loop in the endtable check written tables (#5803) 2020-03-12 12:13:03 -07:00
Marc Butler
0e3fdd0eea Escape characters in jsonschema descriptions (#5644)
* Escape JSON Schema comments

* Add quotes to monster comment

Thus exercising the JSON Schema comment escape support.
2020-03-12 12:10:30 -07:00
Vladimir Glavnyy
45a2b07cbd Remove noexcept qualifier copy-ctor of union type (#5800) (#5802)
- Remove `noexcept` qualifier from generated 'union' copy-constructor
- Remove `noexcept` qualifier from generated 'union' assign-operator
2020-03-12 12:07:27 -07:00
Vladimir Glavnyy
d10c163142 Replace 'assert' by 'FLATBUFFERS_ASSERT' inside idl_parser.cpp (#5799) 2020-03-12 11:18:10 -07:00
Jakub Vrána
35abb7f89b Add non-nullable modifier to return type of functions never returning null (#5797) 2020-03-12 09:02:29 -07:00
Myrice
9954e09ab7 [C++] Generate code for vector force_align attribute. (#5796)
* [Flatbuffer] Generate code for force_align with CreateXDirect and Pack functions.

* Fixed Visual Studio 10.0 compile error for std::to_string.

* Fixed Visual Studio 10.0 compile error for std::to_string.
2020-03-12 08:32:29 -07:00
jean-airoldie
95a21327fc rust: pub export the VectorIter type (#5736) 2020-03-09 17:25:03 -07:00
Wouter van Oortmerssen
89b6183ee9 Fix Python min alignment
This was accidentally deleted in:
9fa8245e81

Change-Id: I8cad721e075279f6a67aca81259f73fb75aba482
2020-03-09 16:46:41 -07:00
Lee Mracek
5a98d65e86 [Rust] Add gen-name-strings for Rust (#5757)
* Add gen-name-strings for Rust

* Clang format

* Add tests and generate with gen-name-strings

* Clang-format

* Stop doing gen-name-strings with C++ code

* Bring generate_code.bat up with generate_code.sh
2020-03-08 19:05:20 -07:00
Wouter van Oortmerssen
f73d205bc7 Removed assert that wasn't backwards compatible.
Change-Id: I8e74d6fddf91fe955fffc572af9d671160325731
2020-03-05 17:21:47 -08:00
Wouter van Oortmerssen
7c37abe92d [C#] add ObjectAPI Serialization Utility (#5785)
* [C#] add ObjectAPI Serialization Utility

* set InitialBufferSize to 64k

* rename SerializeToFlatBuffers to SerializeToBinary
2020-03-05 09:33:22 -08:00
Wouter van Oortmerssen
4749e77b0e Fixed docs on how to obtain parser error.
Change-Id: Ib3ffbdf51ef6af1f5c8267b84b84dceed9d4a838
2020-03-02 12:16:02 -08:00
Derek Bailey
6ff1898413 Added --filename-suffix and --filename-ext to flatc (#5778)
* Fixed refractoring issue in reflection/generate_code.sh. Also, mv deletes the original file, so I don't need to clean it up manually in that case.

* Added --filename-suffix and --filename-ext to flatc

* Fixed typo and added example generation of suffix and extension for C++

* Removed extra ;

* Removed clang-format block from a region that didn't need it. Fixed an auto format of another clang-format block

* Added docs, fixed pointer alignment, removed suffix test file
2020-03-02 10:15:23 -08:00
Derek Bailey
c9a30c9ca2 Fixed refractoring issue in reflection/generate_code.sh. Also, mv deletes the original file, so I don't need to clean it up manually in that case. (#5777) 2020-02-27 12:59:43 -08:00
Derek Bailey
8c02d17bea Skip writing reflection_generated.h if not changed (#5776) 2020-02-24 14:46:24 -08:00
mustiikhalil
34305c4ce4 [Swift] Adds GRPC to Swift (#5758)
* Adds the basic structure for required to add grpc support

Added the message implementation

Updated the code to confirm to the protocol flatbuffersobject

Adds an example for Swift flatbuffers GRPC

Started implementing the swift GRPC code Gen

Generator generates protocols now

Fixing ci issues

Migrated the logic to use grpc_generator::File instead of string

Refactored swift project

Implemented GRPC in swift

Finished implementing GRPC in swift

Fixes issues

Adds contiguousBytes initializer to swift

Adds documentation + fixes buffer nameing in tables + structs

Adds documentation + fixes buffer nameing in tables + structs

Updated tests

* Updated version
2020-02-24 09:27:41 -08:00
Paulo Pinheiro
cd88e6b2aa [Java][FlexBuffers] Abstract buffer access from ByteBuffer (#5743)
To read and build flexbuffers on Java, one needs to wrap the data
using  ByteBuffer. But for the common case of having ByteBuffers
backed by arrays, accessing from a ByteBuffer might be inefficient.

So this change introduces two interfaces: ReadBuf and ReadWriteBuf.
It allows one to read and writes data directly on an array. It also allow
 other buffer implementations to be used with flexbuffers.

Another change is that FlexBuffersBuilder backed by array allows
the buffer to grow with the increase of the message size. Something
that could not be done with ByteBuffer.
2020-02-21 11:46:40 -08:00
mustiikhalil
3ec7a53c62 Adds cocoapods and a readme of how to get the package (#5771) 2020-02-21 11:42:07 -08:00
Omer Akram
6d44cede70 [snap] Fix versioning (#5727)
* fix snap versioning

* no need to install git as build packages
2020-02-13 08:05:21 -08:00
Joseph Pyott
cc08c0835b [Python] Fixed potential allignment issue (#5768) 2020-02-12 13:53:09 -08:00
xtrm0
54f8b787cb Fix memory leak on cpp object api (#5761)
Previously UnPack would allocate data with new and assign it to a
raw pointer. This behavior makes it possible for the pointer to be
leaked in case of OOM. This commit defaults to use the user specified
pointer (which needs to implement a move constructor, a .get() and a
 .release() operators), thus preventing these leaks.
2020-02-12 12:12:45 -08:00
Joseph Pyott
17557f9131 [Python] Fixed issue #5499 (#5764) 2020-02-11 15:02:21 -08:00
David P. Sicilia
d54af8cd43 [C++] Use strong enum type for vectors when scoped-enums is on. (#5750)
* [C++] Use strong enum type for vectors when scoped-enums is on.

These changes only apply when scoped-enums is on, and thus only
the C++17 tests show diffs.

This may break users who use 1) use scoped-enums and 2) use
vectors of enums.  However, it seems that this change should
have been made originally when scoped-enums were added.

Fixes #5285

* [C++] Put strong enum change also behind C++17 flag.

It actually only needs C++11 technically, but this is being done
to avoid breaking any existing users.

Tests were rerun, but produced no additional diffs, as expected.

* [C++] Forgot one location in which C++17 guard needs to go.

This commit produces no additional diffs in generated code.

* Use g_only_fixed_enums instead of scoped_enums.
2020-02-10 17:45:32 -08:00
mugisoba
173e10fdf1 [C#] support Json Serialization (#5752)
* support json serialization

* fix invalid json format.
* string must be written with double quotes.
* remove commma after the last object member.

* fix indent

* Revert "fix invalid json format."

This reverts commit d6820ed50c.

* quated string value.

* add cs-gen-json-serializer flag.

* fix preprocessor indent

* ENABLE_JSON_SERIALIZATION -> ENABLE_JSON_SERIALIZATION_TEST

* share TestBuffer method

* remove ENABLE_JSON_SERIALIZATION

* remove duplicated test data

* [windows] add nuget restore and copy test data.

* [docker mono] share msbuild settings with windows. add nuget restore and copy test data.

* add some note for json api.
2020-02-10 17:43:36 -08:00
Wouter van Oortmerssen
8f56990f6c FlexBuffers: C++: scalar-only typed vectors were not aligned.
This means data written with older versions of this code has
potentially misaligned data, which we'll need to support.
This isn't a problem on most architectures, but could be on
older ARM chips. To support them properly may require swapping
out uses of `flatbuffers::ReadScalar` with a version that does a
memcpy internally.

Change-Id: Ib352aab4a586f3a8c6602fb25488dcfff61e06e0
2020-02-06 11:56:28 -08:00
Robert Winslow
6400c9b054 Bump Rust port to 0.6.1 (#5747) 2020-01-30 13:55:44 -08:00
mugisoba
7418d85872 [C#] support Object API (#5710)
* [C#] support Object API

* fix sign-compare

* fix indent

* add new line before for loop.

* using auto whenever possible

* reduce the amout of blank lines.

* wip: support vectors of union

* done: support unions of vectors

* set C# version to 4.0
* remove null propagation operator
* remove auto property initializer
* remove expression-bodied method
* remove pattern matching

* add Example2 to NetTest.sh

* separate JavaUsage.md and CsharpUsage.md from JavaCsharpUsage.md

* add C# Object based API notes.

* support vs2010.

* remove range based for loop.

* remove System.Linq

* fix indent

* CreateSharedString to CreateString

* check shared attribute

* snake case
2020-01-30 10:18:28 -08:00
mustiikhalil
c580fa284c Adds min and max, comments, and all of swift's keywords + fix docs (#5737) 2020-01-27 10:05:41 -08:00
Dan Field
f2a1272303 Use VS 2017 and 2019 on CI, fix cast issue in dart_idl (#5740)
* vs2019

* another attempt

* syntax

* fewer

* fix dart
2020-01-27 10:03:00 -08:00
mustiikhalil
316d7c2089 Creates a flatbuffers validation function + small fix (#5725) 2020-01-24 14:55:57 -08:00
sjoblom65
47026ea6ba Added the code to embed the binary schema to the source (--bfbs-gen-embed). (#5701)
* Added the code to embed the binary schema to the source.
This is pulled forward from a old PR #5162 that will be closed.

* Update idl_gen_cpp.cpp

Added a small comment to trigger a new build. The build was failing in a strange location and doesn't look like it has anything to do with the code.

* Moved the EscapeAndWrapBuffer to util.cpp and did some formating.

* One more camelCases removed and renamed some variables.

* wrapped_line_xxx should have been passed as a const reference in the first place.

* Moved the bfbs embed sample to it's own file.

* Missed moving the namespace back.

* Moved the embedded bfbs to test.cpp instead of using a sample.

* Missed adding the generation of embedded bfbs to the build.

* See if this makes the build happier.

* Fixed a in-compatable cpp output of the generated header.

* Did some changes to reflect the code review comments.
1. Update the EscapeAndWrapBuffer to BufferToHexText and fixed a variable name.
2. Moved the include of the embedded binary schema to all the other includes.

* Moved some code to inline the instead of using a local variable.

* Moved the BufferToHexText back to be a inline function in util.h
2020-01-24 14:55:34 -08:00
Paulo Pinheiro
3f677f2414 [Java][FlexBuffers] Deprecate typed vector strings due to design flaw (#5722)
* [Java][FlexBuffers] Deprecate typed vector strings due to design flaw

It will still be possible to read buffers with this type, but the
elements will be treated as FBT_KEY and will be read as null-terminated
string.

Trying to build a vector of strings as typed will throw an exception.

More information on https://github.com/google/flatbuffers/issues/5627

Also, fix another bug on strings, where long strings were not properly
aligned.

* [Java][FlexBuffers] Make FBT_VECTOR_STRING_DEPRECATED considered typed.

The logic for FlexBuffers.isVectorType() was changed
to not consider FBT_VECTOR_STRING_DEPRECATED a typed
vector, but that can lead to missinterpretation for
existing serialized data. So we are reverting.
2020-01-24 09:58:15 -08:00
mustiikhalil
a593a11e59 [Go] Implements a SharedStrings function (#5733)
* Adds the sharedstring implementation for go

* Reimplemented testcase according to request
2020-01-24 09:57:34 -08:00
vkill
7cdfc8475e [Swift] Fix padding function overflow when bufSize is 0 (#5721)
* [Swift] Fix padding function overflow when bufSize is 0

[Swift] Generate linuxmain

* [Swift] Using the overflow addition operator to resolve integer overflow
2020-01-24 09:45:19 -08:00
Phoebe
bab2b0db48 Add vcpkg installation instructions (#5732)
* Add vcpkg installation instructions

* Update comments
2020-01-23 15:46:25 -08:00
Dan Field
89418eb848 [Dart] Fix deprecated field support, inf/nan (#5724)
* Fix deprecated field support, inf/nan

* unused params

* rerun tests
2020-01-23 14:53:58 -08:00
Max Burke
9cadf05d89 [typescript] Size-prefixed root accessors not taking into account size prefix (#5717)
* [typescript/javascript] Size-prefixed root accessor needs to account for the size prefix.

* [typescript] Add parentheses after "new" expression.

* Update generated test files
2020-01-20 21:20:52 -08:00
Max Burke
6da1cf79d9 [rust] Add use declarations to Rust-generated bindings for imported FB definitions (#5645)
* 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.

* Add updated generated test files.

* Fixing Rust test harness to handle new includes.

Test binaries need to add references to generated code that's
transitively included.

This also has the knock-on in that this code (which is referenced by
include directives directly in the flatbuffer schema files) also needs
to be generated, hence the changes to generate_code.sh.

* Test harnesses expect test data to be checked in.

Put include_test2 files into the same directory as the include_test2
schema definition.

Update all code generation scripts (forgot the batch file from last
time).

Path updates in Rust test.

* Include updated generated code

* Address comments raised in PR

* Fix failing Rust tests.

* Previous merge clobbered this branch change.

* Add updated imports to benchmarks.

* Clarifying comment per PR request

* Update documentation comments per feedback

* Remove non-Rust generated files for include tests, per feedback from @rw/@aardappel

* Broken code generation batch file

* Fix typo

* Add TODO for tidying up use declaration traversal sometime in the future

* Update test files.
2020-01-19 14:47:28 -08:00
Somo
bee1df96dc [Go] Replace references to hardcoded ”Monster" etc with idiomatic go wherever possible (#5716)
* go: replace objAPI-generated Pack func with method

See discussion at https://github.com/google/flatbuffers/issues/5668

* go: replace generated union type UnPack func with method

Similar to discussion https://github.com/google/flatbuffers/issues/5668

But signature:
```
func AnyUnPack(t Any, table flatbuffers.Table) *AnyT
```

Becomes,
```
func (rcv Any) UnPack(table flatbuffers.Table) *AnyT
```
2020-01-16 16:19:00 -08:00
Vladimir Glavnyy
01189d7edd [C++] Fix for printing of enum in case output_enum_identifiers=1. (#5706)
* Add test-case for testing of the future Color in json (output_enum_identifiers = true)

* Refactoring of idl_gen_text.cpp. Fix for printing of bit-enum with active output_enum_identifiers=1.

* Move  GenerateText implementation into class

* Remove unnecessary code from flatbuffers.h
2020-01-16 14:12:25 -08:00
vkill
c4b2b0a25d [Swift] Support create long string (#5709)
* [Swift] Support create long string

* [Swift] Move the test case to correct dir
2020-01-16 12:08:59 -08:00
mustiikhalil
a4b2884e4e Added create function for swift (#5707)
Fixed the create functions and updated the test cases in swift

Removes unneeded code

Updated documentation
2020-01-13 12:34:06 -08:00
mustiikhalil
04d80f255d [Swift] Swift implementation 🎉🎉 (#5603)
* Implemented the swift version of Flatbuffers

Implemented serailzing, reading, and mutating data from object monster

Fixes mis-aligned pointer issue

Fixes issue when shared strings are removed from table

Adds swift enum, structs code gen

Fixed namespace issues + started implementing the table gen

Added Mutate function to the code generator

Generated linux test cases

Fixed an issue with bools, and structs readers in table writer

Swift docker image added

Updated the test cases, and removed a method parameters in swift

Fixed createVector api when called with scalars

Fixed issues with scalar arrays, and fixed the code gen namespaces, added sample_binary.swift

Cleaned up project

Added enum vectors, and their readers

Refactored code

Added swift into the support document

Added documentation in docs, and fixed a small issue with Data() not being returned correctly

Fixes Lowercase issue, and prevents generating lookups for deprecated keys

* Made all the required funcs to have const + removed unneeded code + fix lowercase func

* Removed transform from lowercased and moved it to function

* Fixes an issue with iOS allocation from read

* Refactored cpp code to be more readable

* casts position into int for position

* Fix enums issue, moves scalar writer code to use memcpy

* Removed c_str from struct function

* Fixed script to generate new objects when ran on travis ci: fix

* Handles deallocating space allocated for structs

* Updated the test cases to adhere to the fileprivate lookup, no mutation for unions, and updated the names of the vector functions
2020-01-09 12:12:10 -08:00
Wouter van Oortmerssen
55686100aa Changed direct calls to strtod to use StringToNumber
StringToNumber will correctly use locale-insensitive functions
when available.

Change-Id: I6bde11039a541634186f8f791012af2eb0d86b8d
2020-01-09 11:48:09 -08:00
emkornfield
718351831d Document JSON compatibility guarantees. (#5704)
https://github.com/google/flatbuffers/issues/5688
2020-01-09 10:56:34 -08:00
Vladimir Glavnyy
d1b34f0f28 Add CMake 'generated_code' target to simplify resolution of build dependencies (#5697) 2020-01-06 15:26:41 -08:00
Michael Beardsworth
21b7061963 (Optionally) add an additional suffix namespace to generated fbs files. (#5698)
This change allows for the generation of fbs files (from proto) that
don't contain name collisions with the protobuf generated C++ code,
allowing both the proto and fbs message types to be linked into the same binary.
2020-01-06 10:00:59 -08:00
dreifachstein
35daaf83d3 [Java] Replace Table.UTF8_CHARSET with StandardCharsets.UTF_8 (#5696)
StandardCharsets.UTF_8 is already used in FlexBuffersBuilder.
2020-01-06 09:28:19 -08:00
Robert Winslow
3b458f7a17 Rust: Temporarily disable 2 endianness unit tests (#5695)
Rare failures occur on AppVeyor in these functions; the failures appear
spurious.
2020-01-02 13:34:47 -08:00
David P. Sicilia
a5d9d0f7d3 [C++17] Add Traits class for Tables and Factory function within it. (#5678)
* Include flattests_cpp17 in unit tests when C++17 build is enabled.

* [C++17] Generate generic table factory function.

1. For each table, generate a convenient free-standing factory
   function that allows creating the table in a generic way by
   specifying only the type.  This is the first change in a series
   of changes to make Flatbuffers generated C++ code more friendly
   to code bases that make use of C++ template metaprogramming
   techniques to manage the serialization process.  Example:

     Before :(

       // The name of the Flatbuffers type (and namespace) must
       // be hard-coded when writing the factory function.
       auto monster = MyGame::Example::CreateMonster(fbb, ...);

     After  :)

       using type_to_create = MyGame::Example::Monster;
       // No namespace needed on CreateByTagType.
       auto monster = CreateByTagType((type_to_create*)nullptr,
                                      fbb, ...);

   This feature requires building with C++14 or greater, and thus
   it is guarded behind --cpp-std >= c++17 in the flatbuffers C++
   generator.

2. Fix a CMake bug to include C++17 unit tests in test suite.

* [C++17] Replace standalone variadic factory function with type_traits.

Add a `type_traits` to each table class.  This `type_traits` can be
populated with various compile-time info about the table.  Initially,
we have the Create* function and type, but is extensible in the future.

* Remove empty line and fix stale comments.

* Rename type_traits to Traits and move fwd declaration.

* Fix parameter evaluation order issue and use lambda for scope.
2020-01-02 10:12:14 -08:00
Wouter van Oortmerssen
3cd9b6434a Removed code_generators.cpp from library targets
Change-Id: Ia6e032a77983bf1838b8675f51d1c910acc991d8
2020-01-02 08:50:39 -08:00
Max Burke
355dfd48d1 [rust] Make enum names public (#5690)
* 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

* [rust] Make enum variant names public.

* Update generated test files

* Add test for public enum names
2019-12-31 10:28:58 -08:00
Michael Beardsworth
bcd58a159b Correct inverted logic around include prefixes. (#5689)
4d1a9f8d9e inverted the logic around
keeping the include prefix. This change fixes the error.
2019-12-30 10:34:01 -08:00
lu-wang-g
a2c12900aa Optimize Pack method using numpy (#5662)
Add the support to pack using numpy for scalar vectors when numpy is available.
2019-12-26 21:42:11 -05:00
Austin Schuh
901b89e733 [C++] Add Builder and Table typedefs (#5685)
* Add Builder and Table typedefs

This gives us a way to use templates to go from a builder to a table
and back again without having to pass both types in.

* Fix tests/cpp17/generated_cpp17/monster_test_generated.h
2019-12-26 14:56:46 -08:00
Wouter van Oortmerssen
31f8799083 Minor doc updates: FlexBuffers C#, Discord, CppUsage.
Change-Id: Ie34ff580eb2f41ff35f85271b10865f4a14d0dca
2019-12-26 12:36:41 -08:00
Austin Schuh
8023d99e21 Upgrade rules_go (#5684)
This should help with #5672 if I'm reading the report back from
buildkite properly.
2019-12-26 10:07:15 -08:00
Austin Schuh
b4154405d1 Fix --incompatible_load_cc_rules_from_bzl (#5683)
Incompatible flag --incompatible_load_cc_rules_from_bzl will break
FlatBuffers once Bazel 1.2.1 is released.

Fixes #5671
2019-12-26 10:03:22 -08:00
Austin Schuh
04c17c7a76 Add support for absl::string_view when available (#5682)
For C++11 platforms, absl::string_view is sometimes available. This can
be used for string_view when std::string_view is not available.
2019-12-26 10:02:24 -08:00
Austin Schuh
62ec7d52ce [Bazel] Add support for compatible_with and restricted_to (#5681)
* Add support for compatible_with and restricted_to

These attributes have been available in Bazel for years.  Pass them
through so the flatbuffer rules can be used with them.  They let you
constrain which target platform is used.

While we are here, fix gen_reflections to work with bazel.

* Add docs
2019-12-26 09:58:48 -08:00
Robert Winslow
7de668053f CI: New Docker tests for Python with numpy (#5677)
* New Docker tests for Python with numpy

* print numpy status in test suite
2019-12-24 02:14:55 -05:00
Wouter van Oortmerssen
3a70e0b308 Fixed struct initialization error on older versions of C#
"'this' object cannot be used before all of its fields are assigned to"

Change-Id: Icccdcc0d0be0fe0b87abe0eb28fe1cc91116fcfb
2019-12-23 17:35:54 -08:00
Wouter van Oortmerssen
9b13201356 Fixed warnings in FlexBuffers.java
- Missing return statement <- bug!
- Missing hashCode function.

Change-Id: I6333cac72adf8ead92ab2e6c7215650ce4571a73
2019-12-23 17:11:57 -08:00
Wouter van Oortmerssen
5e3916050c Fixed out of date licenses on gRPC Python files.
Change-Id: Ia6c3bf5d7da795db46c0baa8e9c7591de3400517
2019-12-23 14:01:41 -08:00
Wouter van Oortmerssen
c957550511 Removed test proto output.
Change-Id: Iaf64bec068d03dd1b75670e9a28dde7392ebddb5
2019-12-23 12:33:16 -08:00
Vladimir Glavnyy
44bf719883 Add flatc '--cpp_std' switch (#5656)
* Add flatc '--cpp_std' switch and sandbox for C++17 code generator

- Added 'flac --cpp_std legacy' for compatibility with old compilers (VS2010);
- Added experimental switch 'flac --cpp_std c++17' for future development;
- Added C++17 sandbox test_cpp17.cpp;
- C++ code generator generates enums with explicit underlying type to avoid problems with the forward and backward schema compatibility;
- Adjusted CMakeLists.txt, CI and generate code scripts to support of introduced '--cpp_std';

* Fix --cpp_std values: c++0x, c++11, c++17

* Add 'cpp::CppStandard' enum

* Add testing engine into test_cpp17

* Rebase to upstream/master

* Set default '--cpp-std C++0x'

* Fix code generation (--cpp_std C++11) in CMakeLists.txt

- Fix dependency declaration of grpctest target

* Revert --cpp-std for the tests from explicit C++11 to flatc default value (C++0x)
2019-12-23 12:13:48 -08:00
Wouter van Oortmerssen
3e8f15df90 Fix for FlexBuffers FBT_VECTOR_STRING size bit-width.
For details, test.cpp/FlexBuffersDeprecatedTest(), and also
https://github.com/google/flatbuffers/issues/5627

Change-Id: I6e86e1138a5777e31055cfa2f79276d44732efbc
2019-12-23 11:49:59 -08:00
stefan301
602721a735 Added Check to VerifyAlignment (#5675)
* 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
2019-12-23 09:08:35 -08:00
Michael Beardsworth
13c05f4da3 Improve import handling for proto conversion (#5673)
* Keep include prefix when converting from proto.

This change preserves the include prefix when generating flatbuffers
from proto (with FBS_GEN_INCLUDES) defined.

* Improve handling of imports in proto conversion.

Previously, there was no runtime flag to make proto->fbs conversion keep
the import structure of a collection of files. This change makes proto
conversion respect the --no-gen-includes flag and skip the output of
"generated" symbols.
2019-12-23 08:50:29 -08:00
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
Björn Harrtell
fbc11e8aec Avoid intentional unsigned integer overflow getting caught by sanitizers (#5572)
* Avoid intentional unsigned integer overflow getting caught by sanitizers

* Adapt from suggested compiler compatible solution

* And a third way :)
2019-10-17 15:47:51 -07:00
Bharat Tak
e9d29c21a7 Python: Add forceDefaults opt to python Builder (#5564)
* Add forceDefaults opt to python Builder

* Add test functions for force_default option for python builder

* Simplify

* Add force default test for UOffsetTFlags
2019-10-17 15:25:05 -07:00
Jacek Surazski
8bfafc76de Java: Don't annotate vector-of-tables item getters with @nullable. (#5562)
* Annotate getters with @Pure when --java-checkerframework is specified.

Together with @Nullable, this allows users to use static analysis tools
like CheckerFramework to catch NPEs caused by unset fields.

* Don't annotate vector-of-tables item getters with @Nullable.

Since Flatbuffers don't support null items in vectors of tables.
2019-10-17 15:23:15 -07:00
Wouter van Oortmerssen
df3e8bf4a7 Fixed warnings generated by recent JSON sorting feature.
Change-Id: I6fd6283b616c7a39bb878b1610e4ddf6e208fa0a
2019-10-17 15:16:40 -07:00
Idan Sheinberg
5665cfe492 [Java] byte buffer factory returned buffer capcity is used instead of the requested size (#5558)
* byte buffer factory returned buffer is used instead of the requested capacity

* byte buffer factory returned buffer is used instead of the requested capacity

* Comment fix
2019-10-17 15:11:33 -07:00
tira-misu
5797540ed0 #5544 Fix of Array of table is not sorted if Create<type>Direct() is used (#5546)
* 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
2019-10-17 14:22:21 -07:00
Brian Harris
7f1af7cb02 Fix build with gcc version 7.4.0 (#5570) 2019-10-15 10:56:58 -07:00
Wouter van Oortmerssen
32f47ad247 Fixed JSON parser not sorting vectors of tables/structs with key.
Change-Id: Iacc0c8513af80a736700e6cbaf513ebdf8e3ac89
2019-10-10 15:25:39 -07:00
Paulo Pinheiro
842f672baf [FlexBuffers][Java] Cache size of Sized objects in FlexBuffers (#5551)
In my benchmarks it shows deserialization performance improvements of
around 7%
2019-10-03 15:56:29 -07:00
Paulo Pinheiro
d4cae0a623 Fix issue #5542 (#5543)
Empty objects that inherit from Sized would try to access internal
ByteBuffer when Sized::size was called. So we add a single byte in
the empty buffer, so when size() is called it would return 0
2019-09-30 14:05:19 -07:00
Wouter van Oortmerssen
f1147f65bb Fixed Android STLPort related error.
Change-Id: I59ff072e526fc63b3215767a4d4a2a8944b65654
2019-09-30 12:12:36 -07:00
Jack Zhou
69d3fec488 Fix namespaced struct/field name collision detection (#5540) (#5545)
Changes the use of `LookupStruct` to `LookupCreateStruct` in
`ParseField` to also detect when collisions happen in namespaces.
2019-09-30 11:50:03 -07:00
Paulo Pinheiro
cfb4ecf6f0 [flac] Add FlexBuffers option for generating data (#5519)
Alongside --binary and --json, an additional
switch (--flexbuffers) can be passed to convert
data using FlexBuffers
2019-09-26 15:06:11 -07:00
Robert Winslow
a92039687a Update Rust versions under test from 1.30.1 to 1.37.0 (#5538)
Fixes build errors from using newer crate versions with an old Rust version.
2019-09-26 14:31:11 -07:00
mjvk
625338d095 Adds XOPEN_SOURCE for PATH_MAX and POSIX 1993 for stat (#5529)
* Adds XOPEN_SOURCE for PATH_MAX and POSIX 1993 for stat

These are the only two required extension for compilation of
flatbuffers using -std=c++11 instead of gnu++11.

* Sets _XOPEN_SOURCE to 600 and enable POSIX2001 for fseeko
2019-09-26 09:40:14 -07:00
Paulo Pinheiro
3f8ce99c50 [FlexBuffers][Java] Add override Key::toString (#5533) 2019-09-25 14:14:39 -07:00
Paulo Pinheiro
0798b7b698 [FlexBuffers][Java] Fix wrong access to a string using Reference::asString(). (#5532)
The real position of a string is  calculated by using the indirect() method,
which should be based on parentWidth and not byteWidth, as it was implemented.

We are also fixing the flag BUILDER_FLAG_SHARE_STRINGS on FlexBuffersBuilder
that was set as '1', same value as BUILDER_FLAG_SHARE_KEYS.
2019-09-25 11:59:10 -07:00
Vladimir Glavnyy
cbdf82e2fb Fix Mutate() methods of Array<scalar/struct> (override 5508) (#5526)
* Draft with Array specialization (#5508)

* Array specialization + SFINAE to fold copy-paste (#5508)

* Add implicit specialization of Array<scalar> and Array<struct> (#5508)

- Tag dispatching is used for implicit specialization
- Array<scalar> and Array<struct> have different iterators and accessors
- Array<scalar> and Array<struct> have different Mutate() methods

* Add implicit specialization of Array<scalar> and Array<struct> (#5508)

- Tag dispatching is used for implicit specialization
- Array<scalar> and Array<struct> have different iterators and accessors
- Array<scalar> and Array<struct> have different Mutate() methods
2019-09-23 09:31:51 -07:00
Kulikov Alexey
e365c502ff Java: Added access object for vector of struct and vector of tables. (#5233)
* Java: Added access object for vector of struct and vector of tables.

* Java: Workarounds removed when accessing the union vector.
2019-09-23 09:22:43 -07:00
mmoscicki2
97f3aa9174 Fixed DetachedBuffer self move assignment (#5521) 2019-09-19 10:32:24 -07:00
Austin Schuh
2f5bb2eec4 Fix buildifier warnings found in new bazel (#5517)
Fixes warnings caught in:
https://buildkite.com/bazel/flatbuffers/builds/863#cff87e1d-b976-4734-8157-4b6d88c7b5e1
2019-09-19 09:58:36 -07:00
Wouter van Oortmerssen
917687c7a6 Fixed Reflection Verifier not handling vectors of unions.
Change-Id: Ie94386ff8e10fd2a964bd9155139b50953746a37
2019-09-16 17:48:54 -07:00
Wouter van Oortmerssen
f9277e691d Fixed GenerateText not handling vectors of unions.
Change-Id: Ie82abaf178495c4692e7d10be6b4a13f2fa1bee6
2019-09-16 14:44:14 -07:00
Kevin Fort
2706381eef Add element size parameter to __vector_as_arraysegment [c#] (#5512)
* Add element size parameter to __vector_as_arraysegment

Add element size parameter to __vector_as_arraysegment fixing issue where VectorAsBytes returns incorrect size span for multibyte element types.

* Update codegen

Update codegen and Table to return typed span.

* update test files

update test files
2019-09-10 17:07:46 -07:00
Paulo Pinheiro
b5560fcd52 [Java][FlexBuffers] Improve documentation for FlexBuffers in Java. (#5506)
Also add a FlexBuffer constructor to simplify usage
2019-09-10 10:06:47 -07:00
jaceksur
782b865c55 Annotate getters with @Pure when --java-checkerframework is specified. (#5510)
Together with @Nullable, this allows users to use static analysis tools
like CheckerFramework to catch NPEs caused by unset fields.
2019-09-10 10:01:27 -07:00
Edward
3bfc86eaff [Dart]fix: segment fault with empty namespace when generating dart file (#5507)
* fix: segment fault with empty namespace when generating dart file

* fix: compile err

* fix: compile err

* fix: imported file names

* fix test issues

* fix some language style issues
2019-09-09 14:40:33 -07:00
Casper
c0282873fb Rust: Fixed cargo clippy on non-generated code (#5485)
* Cargo clippy lints

* more lints

* more lints

* Restored a doc comment

* Comment on float eps-eq and adjusted casting
2019-09-09 13:02:43 -07:00
Jaemin Park
4b870aca98 [Javascript] Fix syntax error for signed enum (#5503)
* wrap quotes to enum name map to prevent syntax errorn when enum value is negative

* Add a test that covers signed enum case
2019-09-05 10:22:04 -07:00
Nathan Williams
d0e3870c0f [C#] Fix retrieving enumeration vectors as arrays (#5457)
* [C#] Fix retrieving enumeration vectors as arrays

* [C#] Don't generate CreateVectorBlock for enums
2019-09-03 14:10:54 -07:00
Björn Harrtell
fb25eb87f2 Doc typo fixes (#5505) 2019-09-03 11:50:42 -07:00
Morten Grouleff
cb35d3a0e5 Use all of the available space in the buffer returned by ByteBufferFactory to allow the factory to keep a pool of larger than initialsize sized buffers. (#5500) 2019-09-03 11:13:32 -07:00
Paulo Pinheiro
8e6cabb31b [FlexBuffers][Java] Implementation of FlexBuffers API (#5476)
* [FlexBuffers][Java] Implementation of FlexBuffers API

This is the initial attemp to implement FlexBuffer on Java.

There is some limitations as compared to the C++ implementation:
  1 - No mutations implemented yet
  2 - Does not parse from json

Also, this initial implementation is not focused and performance, but
get the basics write. So there is many opportunities for optimization, for instance,
remove all enums, return CharSequence instead of Strings and object pooling.

* [FlexBuffers][Java] Optimizations and simplification of the Builder  API.

This change removes BitWidth enum in favor of static ints. Also
make all "reads" APIs closer to C++ implementation (try to cast or convert
as much as possible, assuming user knows what he is doing). Finally,
we remove the helper classes for building vectors and maps.

There is no official benchmarks, but the unit tests are running in less
than 50% for previous runs, which mean those optimizations are worth it.

* [FlexBuffers][Java] Fix Reference::asString behavior

There was a incorrect assumption that strings would be null-terminated, which
could lead to truncated strings. S now it relies size instead of null-termination.

Other minor improvements
2019-08-29 15:06:24 -07:00
Wouter van Oortmerssen
bd31dd2425 Clarified value reuse in FlexBuffers
Change-Id: Ib771bfa46ccdf38eff25be857b1b73f8b300c649
2019-08-26 14:59:21 -07:00
Wouter van Oortmerssen
65b67d2132 Fixed test build invocation of arrays_test.fbs
Change-Id: Idfc8d9cfbdefda44f803a6232700842ee6b6bffd
2019-08-26 14:33:38 -07:00
Wouter van Oortmerssen
1fbb711324 FlexBuffers: allow any values to be shared.
(see comments in the code).

Change-Id: I5603abb0db436145739653692644bbcfd3c946e3
2019-08-26 14:17:52 -07:00
Wouter van Oortmerssen
cd75a36587 Android: remove app_dummy() calls
Change-Id: I0ebd4502f98d009ce5afe8c8bafb629284f0366c
2019-08-23 14:33:16 -07:00
Wouter van Oortmerssen
ec6b0bf297 Fixed STLPort Android compile error
Change-Id: I3595b9c6803718f34ce61fdfc367da97b50dc444
2019-08-23 14:17:33 -07:00
Earlonus
c11b5d7447 [bugfix]flexbuffers isvector bugfix (#5488)
* commit isvector bugfix (change email recommit to pass cla)

* commit IsUntypedVector

* delete isvectorormap function
2019-08-23 10:51:36 -07:00
svenk177
4525c91be3 Fix incorrect padding in arrays of structs (Issue #5484) (#5491) 2019-08-23 10:46:47 -07:00
Wouter van Oortmerssen
b97b342f59 Fixed missing generated code.
Change-Id: Iaa0633167c2a4d4543fc4de2af58112d60d5d1e6
2019-08-19 17:57:23 -07:00
Wes McKinney
c1058a903b C++ IDL generation adds superfluous semicolon in GenTablePost, causing (#5483)
-Wextra-semi-stmt warning when building with Clang 8.0.0. Update generated
files for testing
2019-08-19 17:49:37 -07:00
Tsingson
3030449348 [go]add Name() for ForceCodec interface (#5486)
* add Name() for ForceCodec  interface

// ForceCodec returns a CallOption that will set the given Codec to be
// used for all request and response messages for a call. The result of calling
// String() will be used as the content-subtype in a case-insensitive manner.
//

* Update grpc.go
2019-08-19 15:32:04 -07:00
Mark Nauwelaerts
a2485d4ecc reflection: check for valid union enum value during object verification (#5475)
... to avoid assertion failure or invalid access due to invalid vector index
2019-08-19 12:48:25 -07:00
Edward
a20e71ac96 has_method support for primitive fields in java runtime. Changed: idl.h, FlatBufferBuilder.java , idl_gen_general.cpp, idl_parser.cpp, flatc.cpp (#5468)
* has_method support for primitive fields in java runtime

* adding the new flag to flatc

* addressing the review comments
2019-08-19 12:46:48 -07:00
Max Burke
acc9990abd Fix compilation error in tests. (#5472)
Local variables were shadowing member fields, causing errors.
2019-08-05 11:57:54 -07:00
Alexey Geraskin
2d5315ff0e [C++] remove static_cast expression (#5440)
* [C++] remove static_cast expression

* [C++] Add unit test for native_type usage

* [C++] Add flatc compilation for native_type_test.fbs

* [C++] update CMakeLists to compile native_type_test.fbs properly

* Update BUILD file for bazel

* [C++] Add generated native_type_test_generated.h and fix arguments for flatc according to CMakeList

* [C++] remove "= default" from constructor to support old compilers

* Update BUILD file for bazel, attempt 2

* [C++] Workaround for MSVC 2010 for the issue with std::vector and explicitly aligned custom data types

* Update BUILD file for bazel, attempt 3

* Update BUILD file for bazel, attempt 4

* Update BUILD file for bazel, attempt 5

* Update BUILD file for bazel, attempt 6

* [C++] Workaround for MSVC 2010 for the issue with std::vector and explicitly aligned custom data types Part 2

* [C++] Keep only one optional parameter to compile_flatbuffers_schema_to_cpp_opt

* native_type_test.fbs style corrected

* [C++] Code style modifications

* [C++] Fix flatc arguments in CMakeLists

* [C++] Remove --gen-compare from default parameters for flatc in CMakeLists

* [C++] Change Vector3D fields from double to float, to have alignment eq. 4 (to support MSVC 2010), plus minor review fix

* [C++] Remove one more #if !defined

* [C++] Restore version with correct static_cast, add the same fix for SortedStructs

* Revert "[C++] Restore version with correct static_cast, add the same fix for SortedStructs"

This reverts commit d61f4d6628.

* [C++] Fix Android.mk
2019-08-01 14:31:48 -07:00
ll-antn
7de1a5e347 [C++ ] Correctly serialize bit_flags enums to JSON with output_enum_identifiers option (#5454)
* Support output_enum_identifiers for enums with multiple bit values

* Cast bit_flag enum val to uint64_t instead of int64_t
2019-08-01 14:16:44 -07:00
Derek Bailey
a4e3ad808e Fix for Boolean types (#5379) (#5466)
The packing/unpacking steps for Boolean values was failing because the
code expected numerical values. I overrode the functions for the Boolean
metatable to account for this. I also had to exclude the Boolean
metatable from the GenerateTypes helper function, as that was overriding
the Pack/Unpack functions defined in its metatable.

Added Linux bash script to run Lua tests from the command line.

Bug: google/flatbuffers#5379

Tested: Added Lua tests that were failing and are now fixed with the
code changes.
2019-08-01 10:28:54 -07:00
Wouter van Oortmerssen
c953fa572b Renamed stale label from "wontfix" to "stale".
Change-Id: Iea88624d9d90e029a64cab9edf4e7c1cfc005e4a
2019-07-29 11:43:54 -07:00
Vladimir Glavnyy
0c86085a5b Replace '--cpp-include' brackets to quotes (#5438) (#5464) 2019-07-29 11:38:52 -07:00
Wouter van Oortmerssen
a1f7ecd148 Made stale.yml friendlier. 2019-07-26 18:56:56 -07:00
Vladimir Glavnyy
a20c55bea5 Extend the error message if base type of parsed scalar not resolved (#5456)
* Extend the error message if base type of parsed scalar not resolved #5447

* Resolve PR notes
2019-07-26 17:56:41 -07:00
Wouter van Oortmerssen
d7c2b388ef Add .github/stale.yml to auto close stale issues and PRs.
See https://probot.github.io/apps/stale/

Change-Id: I8176eeb21dbcd516f1d6f7b1e8c28602cdd9332a
2019-07-26 17:49:40 -07:00
Joseph Pyott
9fa8245e81 Python: Added support for file_identifiers (#5123)
* Python: Added support for file_identifiers

* Added tests. Fixed file_identifier code.

* Python: Fixed excessive padding of file_identifier. Repaired tests.

* Python: Made code compatible with python2.7

* Python: Typo fix in @endcond

* whitespace normaalization

* Stylistic change from if(not X is None) to if(X is not None). Added comment to type string.

* Python: Added support for automatic code generation of file_identifiers. Added tests for said code generation.

* converted sprintf to snprintf

* Bugfix, added snprint deffinition for MSVC

* changed snprint deffinition for MSVC to sprint_s

* changed scanf to IntToStringHex. Renamed HasFileIdentifier to GenHasFileIdentifier.

* Added updated genereated code to commit

* Python bugix: flatc no longer produces HasFileIdentfier for shcemas with no file identifier

* Added tests to verify `MonsterBufferHasIdentifier` returns false on no Identifier

* Python: added tests for GetBufferIdentifier and BufferHasIdentifier
Python: removed unessasary parenethesis in if statements
Minor format changes.

* Python : correceted instances of keyword arguments being called as positional arguments

* fixed typos and grammer in comments

* Minor style fixes

* Indentation fix

* Equals style changes

* Python: Fixed Alignment Issues. Changed test code to test against atual output

* Ran make(forgot to run make last commit)

* Python: Style changes

* Style changes

* indentation and style

* readded CONTRIBUTING.md

* Formatting tweak

Mostly to make CI run again

* More formatting fixes

* More formatting fixes

* More formatting fixes

* More formatting fixes

* Formatting fix

* More formatting fixes

* Formatting

* ran generate_code.sh
2019-07-26 11:06:25 -07:00
ll-antn
a5ca8bee4d Fix numeric_limits<T>::max() to avoid conflict with windows.h header (#5462) 2019-07-26 09:14:05 -07:00
ll-antn
09dea79a22 Support nested_flatbuffer attribute when parsing bfbs schema (#5448) 2019-07-26 09:13:11 -07:00
Stewart Miles
b632061eff Pin FlatBuffers Android Travis builds to NDK r17c (#5460)
r17c is the last Android NDK to include stlport and gnustl.
We want to continue to support these deprecated STLs until we have
confidence few enough customers are using them.
2019-07-25 17:58:02 -07:00
Jason Monschke
da88be05e1 Change deprecated vector Length() to size() in tutorial (#5450) 2019-07-25 11:09:40 -07:00
Wouter van Oortmerssen
d4fa984f1d Added missing Kotlin generated code change.
Change-Id: I7eeee6519b6dc619691437e44272cf5424d0d4ca
2019-07-25 11:08:06 -07:00
Uilian Ries
a0c0131e36 #4590 Fix Conan build (#5449)
* #4590 Fix Conan build

- Create separated build for Conan on master branch
- Add Clang 7,8
- Add Gcc 9

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* #4590 Do not build Conan for PRs

Signed-off-by: Uilian Ries <uilianries@gmail.com>
2019-07-25 11:06:40 -07:00
Paulo Pinheiro
de9aa0cdee Add basic Kotlin support (#5409)
* [Kotlin] Add kotlin generate code for tests and add
kotlin test to TestAll.sh

* [Kotlin] Add Kotlin generator

This change adds support for generating Kotlin classes.

The approach of this generator is to keep it as close
as possible to the java generator for now, in order
to keep the change simple.

It uses the already implemented java runtime,
so we don't support cross-platform nor js Kotlin yet.

Kotlin tests are just a copy of the java tests.

* Add optional ident support for CodeWriter

Identation is important for some languages and
different projects have different ways of ident
code, e.g. tabs vs spaces, so we are adding optional
support on CodeWriter for identation.

* [Kotlin] Add Documentation for Kotlin

* [Kotlin] Modify generated code to use experimental Unsigned types.
2019-07-22 16:05:15 -07:00
Alexey Geraskin
a752d1b88c [C++] fix static_cast expression (#5441) 2019-07-18 11:51:12 -07:00
jean-airoldie
db972be264 [rust] Ran rustfmt against library code (#5389) 2019-07-09 13:41:51 -07:00
Vladimir Glavnyy
e304f8c115 Extend the test of MonsterExtra (#5428)
* Extend the test of MonsterExtra

- Extend C++ test of MonsterExtra
- Add conversion of fbs/json NaNs to unsigned quiet-NaN
- Update documentation (cross-platform interoperability)

* Fix declaration of infinity constants int the test
2019-07-08 11:22:56 -07:00
Thanabodee Charoenpiriyakij
47c7aa0361 Fix echo not interpret \n in GoTest.sh (#5426)
When running GoTest.sh, the last step that checking go format files
are print \n instead of new line:

These files are not well gofmt'ed:\n\nMyGame/Example/Color.go
MyGame/Example/MonsterStorage_grpc.go

This changes fix it by echo NOT_FMT_FILES in separate line.
2019-07-01 11:42:00 -07:00
Vladimir Glavnyy
7a63792929 Remove unused variables (#5382)
- Fix GenerateTextFromTable (aliasing typo)
- Fix unused variable in idl_gen_dart.cpp
- Fix std::string passing (should be non-const value or const-reference)
- Remove unused variables
2019-07-01 11:38:21 -07:00
Andrew Noyes
7d7d796cd0 Fix undefined behavior. Closes #5422 (#5423)
* Fix undefined behavior. Closes #5422

* Move check into callers of make_space
2019-06-27 14:11:31 -07:00
Edward
550b386995 Update Utf8.java: more detailed exception message (#5421)
Provide more detailed exception message for malformed 2 byte utf8 character
2019-06-27 12:19:57 -07:00
Adrian Perez
5479adc80f Fix for FLATBUFFERS_PREFER_PRINTF writing zero-length strings (#5418) 2019-06-27 09:23:13 -07:00
Vladimir Glavnyy
b7012484f3 Set C# Struct/Table visibility to public (#5381) (#5416) 2019-06-24 17:51:04 -07:00
Bryan Furia
92e9f33036 Don't check ForceDefaults when adding Offfset values (#5415) 2019-06-24 17:49:53 -07:00
Wouter van Oortmerssen
ff1a22a05f Fixed broken Utf8Old.java
This would not correctly encode/decode strings when substituted for
the default Utf8Safe.java

Change-Id: Ib303697663b5b8cbf6888492f5255b2a45384c04
2019-06-24 16:54:28 -07:00
Bryan Furia
9fb195cce8 Fix generating nested Flatbuffer accessors when they cross namespaces (#5414) 2019-06-24 11:46:00 -07:00
Austin Schuh
7836e65dd4 Fix compatability with Bazel 0.27 (#5412)
rules_go was too old and using deprecated features.  Upgrade it.
2019-06-20 10:25:41 -07:00
Wouter van Oortmerssen
123c7a4890 Updated missing generated code for PR #5313 (fixed arrays)
Change-Id: I249140119e6241beb5aec5670d0e5ccddc8f5251
2019-06-20 10:21:10 -07:00
svenk177
e635141d5b Add support for fixed-size arrays (#5313) 2019-06-18 00:15:13 +02:00
Vladimir Glavnyy
0d2cebccfe Add FLATBUFFERS_COMPATIBILITY string (#5381)
* Add FLATBUFFERS_COMPATIBILITY string

- Add a new __reset method NET/JAVA which hides internal state

* Resolve PR notes

* Use operator new() to __init of Struct and Table

* Restrict visibility of C# Table/Struct to internal level
2019-06-17 19:16:21 +02:00
John Luxford
a80db8538c [C#, Java, C++] Fixes issue #5399 by always including namespaces (#5404)
* [C#] Fixes issue #5399 by always including namespaces

* Updated tests for code generator changes

* Fixed 'As' method names
2019-06-14 17:47:07 +02:00
John Luxford
a6be1d0d74 [Go] Fix namespaces on enums (#5406) 2019-06-13 20:25:03 -07:00
Tiger Caldwell
a7e20b1996 Excluded crtdbg.h from non-MSVC compilation (#5401) 2019-06-13 11:58:40 +02:00
Michael Seifert
4eb3efc221 [flatc][docs] Document rounding behavior of floats in JSON output (#5397)
* [docs] Added an example on how to convert a FlatBuffer binary to JSON
Slightly adjusted section on "Using flatc as a conversion tool".

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>

* [docs] Updated obsolete JSON data in example showing how to convert JSON to FlatBuffer binaries.

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
2019-06-12 12:35:39 +02:00
Will Stott
a807fa9567 Remove out-dated -S option from the flatc syntax. (#5398)
Looks like it's an older syntax for --strict-json which was long-ago removed in d38b9af243
2019-06-09 20:30:10 +01:00
jean-airoldie
b80ad7e439 [rust] Use read_scalar_at where possible (#5385)
This slightly improves readability.
2019-06-07 14:06:20 -07:00
jean-airoldie
16aef8ac0d [rust] Derive Eq + PartialEq on FieldLoc and FlatBufferBuilder (#5394) 2019-06-06 14:09:58 -07:00
Ashwin Ramaswami
b59a1ca2f8 fix typo (#5384)
* fix typo

* fix typo
2019-06-05 19:24:29 +01:00
mugisoba
4fdfe0d468 [bfbs] fix deserializing nested struct (#5383) 2019-06-02 12:49:27 -07:00
Vladimir Glavnyy
95004218f7 Fix multi-line comments for cpp enums (#5345) (#5346)
- fix CSharp comments generation
- fix Python comments generation
- fix Lua comments generation
- fix PHP comments generation
- fix Dart comments generation
- add brief description of Color enum
- add multi-line comments to the Monster:Color
2019-06-02 12:36:49 -07:00
Alexander Gallego
bc7ede8fb3 c++: Add command line option to add extra includes to gen files (#5360)
* c++: Add command line option to add extra includes to gen files

Fixes #5351
We have an ability to pass custom types for strings, allocators, etc
but have no way to tell the generator to include the classes in gen code

* c++: remove std::strtok for std::string methods. passes msvc compile

* generate_code.sh: add --cpp-includes to the test gen script

* tests:generate.bat: update code gen scripts w/ --cpp-includes

* cpp: use command line parsing for extra includes

s/--cpp-includes/--cpp-include/g
Simplify command line parsing of includes by using a std::vector.

* cpp: idl.h: move std::vector for cpp_includes as the last member

msvc does not understand initalization list on our CI server

* cpp:msvc: CI fails on for-range loops

* cpp:codegen: fix error reporting on flatcc

* as per code review: remove unwated --cpp-include in the
tests/generate_code.{sh,bat}
2019-05-31 13:43:30 -07:00
Wouter van Oortmerssen
b652fcc3a7 Break internal Java/C# APIs
This is done on purpose, to avoid API version mismatches that
can cause bad decoding results, see:
https://github.com/google/flatbuffers/issues/5368

Change-Id: I2c857438377e080caad0e2d8bcc758c9b19bd6ec
2019-05-31 13:00:55 -07:00
Wouter van Oortmerssen
c978b9ef1f Enforce matching version in Java and C#.
Change-Id: I7f1f12f2f97e5227e0dabc2965ce66a6d41c229c
2019-05-31 12:15:19 -07:00
360 CodeSafe
3a88e1031b Dereference of null pointer #5353 (#5376)
add an assert to make sure that `key_field` is not a null pointer.
2019-05-30 17:50:21 -07:00
mugisoba
51dd733ba4 [C#] add FlatBuffersBuilder.CreateSharedString (#5372) 2019-05-30 16:15:50 -07:00
emkornfield
79f0df3dfc [C++] Fix Undefined behavior for zero length vectors (#5355)
* Fix Undefined behavior for zero length vectors

* Change fix for UBSan
2019-05-30 16:13:34 -07:00
iceboy
9d92fd92e1 Rename AnyUniqueAliases.T to AnyUniqueAliases.TS to avoid naming conflict (#5362) 2019-05-30 16:02:57 -07:00
Marc Butler
93f74c0363 Generate FlagsAttribute for Csharp (#5370)
For schema enums with the bit_flags attribute, generate the
corresponding System.FlagsAttribute in generated Csharp code.
2019-05-30 15:57:41 -07:00
aardappel
43dbac5d25 Lobster: added builder API for tables 2019-05-22 19:42:13 -07:00
aardappel
53ea1ab1bd Lobster documentation fixes 2019-05-22 16:01:51 -07:00
aardappel
b10b050ab9 Made Lobster builder offsets strongly typed 2019-05-22 15:55:28 -07:00
aardappel
563dcd6893 Made Lobster API use strongly typed enums 2019-05-22 15:28:16 -07:00
aardappel
30ac512a54 Fixed Lobster implementation to work with latest language features 2019-05-22 11:48:10 -07:00
aardappel
b04736f9bd Fixed warnings in idl_gen_go.cpp 2019-05-21 18:54:26 -07:00
Siddhartha Bagaria
bc240b3004 [Go] Public visibility for gazelle default target (#5361) 2019-05-21 14:48:51 -07:00
jonsimantov
0f7e7fd209 Change usage of std::string's .at() to more widely-compatible []. (#5365) 2019-05-21 14:40:33 -07:00
Siddhartha Bagaria
766ed04422 Go bazel default target for gazelle (#5358) 2019-05-20 17:16:48 -07:00
David Reiss
c5e2d37337 [Go] Change two more sites to use enum types (#5359)
Fixes #5357 (regression introduced by #5235)
2019-05-20 14:46:36 -07:00
David Cowan
fe83b68ac6 Added a CPP UnPackSizePrefixed<struct_name> generated helper function (#5350)
* Added a cpp  UnPackSizePrefixed<struct_name> generated helper function

Missing helper function added to the cpp API generator for unpacking size prefixed structures

* Added generated test files
2019-05-20 14:01:44 -07:00
David Reiss
718ddea558 [Go] Make enums into real types, add String() (#5235)
* [Go] Make enums into real types, add String()

This changes the generated code for enums: instead of type aliases,
they're now distinct types, allowing for better type-checking. Some
client code may have to be changed to add casts.

Enum types now have a String() method, so they implement fmt.Stringer.

An EnumValues map is now generated, in addition to the existing
EnumNames map, to easily map strings to values.

Generated enum files are now gofmt-clean.

Fixes #5207

* use example.ColorGreen explicitly

* use valid enum value in mutation test, add new test for "invalid" enum

* add length check and comment
2019-05-17 12:41:39 -07:00
Siarhei Fiedartsou
8d86b5347f Add support for IAR compiler (#5347) 2019-05-16 11:56:22 -07:00
mmoscicki2
39bd667fd0 Fix reverse_iterator in Vector and tests (#5344)
Before this commit tests for iterators passed, even if the code inside
the loop has not been executed.
2019-05-16 11:49:01 -07:00
Björn Harrtell
0bb3ce6935 [JS/TS] Size prefix support (#5326)
* WIP size prefix support

* Consider size prefix in overloaded variant

* Work on code gen

* Disabled helper functions in code gen

* Enabled helper functions in code gen

* Fix size prefixed test

* Fix bad function call

* Add SIZE_PREFIX_LENGTH

* Fix review comments
2019-05-16 11:43:31 -07:00
iceboy
b56d60f058 [Go] Generate imports with fixed order (#5340)
* use fixed order for golang imports

* grumble
2019-05-13 10:10:14 -07:00
Vladimir Glavnyy
bff7ffbc51 Add detection of strtoull_l function (#5333) (#5337) 2019-05-09 10:15:29 -07:00
Vladimir Glavnyy
107c08988a Set default CRTReportMode for the flatc target (#5336)
* Set default CRTReportMode for the `flatc` target

* Add util.cpp to GRPC test target

* Fix path to util.h
2019-05-09 10:10:10 -07:00
Vladimir Glavnyy
f9ebfcb9c4 Make Monster's Color unsigned (#5318)
- update C++ monster_test::Color to unsigned type
- update Go Color:ubyte in the go_test.go
- add workaround for unsigned enum in java test
- sync generate.bat and generate.sh
2019-05-09 10:07:38 -07:00
Vladimir Glavnyy
b701c7d56e Fix out-of-range error (MSVC2010) in idl_gen_dart.cpp (#5335)
-- MSVC2010 doesn't support indexed access to \0-terminator.
2019-05-09 10:05:21 -07:00
Will Stott
103f61b685 [Python PyPI] Added classifiers and more links. Fixes typo and #5215 (#5272) 2019-05-08 12:42:20 -07:00
Malthe Borch
e47ca7ab40 Use a hash table to index existing vtables (#5314)
* Use a hash table to index existing vtables

This allows for quick deduplication even in situations where there
might be thousands of vtables due to 'combinatoric explosion'.

This fixes issue #5301.

* Refactor 0-offset trimming

* Improve deduplication benchmark

The routine now generates a set of realistic logical layouts and
uses a timer function that randomly picks a layout for each iteration.

The benchmark runs in batches of # of logical layouts = 1, 10, 100, 1000.

(Note that due to alignment, the actual number of vtables is usually slightly
higher.)
2019-05-06 15:00:02 -07:00
Vladimir Glavnyy
d79f4e9717 Add monster_extra files to Bazel cc_test section (#5321)
- add monster_extra.fbs
- add monsterdata_extra.json
2019-05-06 12:27:04 -07:00
Lee Mracek
5d67693e8f Fix typo in build_defs.bzl (#5320) 2019-05-06 12:10:11 -07:00
Vladimir Glavnyy
af74f87ccd Make MonsterExtra table a root table (#5315)
- MonsterExtra table a root table
- add mosterdata_extra.json
2019-05-02 15:12:58 -07:00
Vladimir Glavnyy
b8ef8c1521 Fix issues with uint64 enums (#5265)
* Fix issues with uint64 enums

- hide the implementation of enums from code generators
- fix uint64 the issue in the cpp-generator
- fix #5108
- new tests
- enums with bit_flags attribute should be unsigned

* Refine objectives of EnumDef's FindByValue and ReverseLookup methods

- move EnumDef::ReverseLookup implementation to idl_parser.cpp
- fix typos

* Make the IsUInt64 method private
2019-05-02 13:57:58 -07:00
László Csomor
6cc30b3272 [BUILD] Fix Bazel test target //:flatbuffers_test (#5311) 2019-04-29 10:01:23 -07:00
jean-airoldie
e5b6125fa2 Added common rust traits to FlatBufferBuilder (#5307)
* Added Clone, Debug and Default
2019-04-26 18:40:10 -07:00
Wouter van Oortmerssen
ac14c8906f Update GRPC Java generated file.
Change-Id: I57ccbe0b9ccbbec65ca04f9db3cbd62243480d92
2019-04-24 12:34:42 -07:00
Wouter van Oortmerssen
9936adf473 [maven-release-plugin] prepare for next development iteration
Change-Id: I402d857eef9f3e5f3765427c5d3b868ed5a3a22e
2019-04-24 12:09:50 -07:00
Wouter van Oortmerssen
bf9eb67ab9 [maven-release-plugin] prepare release 1.11.0
Change-Id: I716f6b915adfa6682b5d864857abf7d491d788b5
2019-04-24 12:09:44 -07:00
Wouter van Oortmerssen
9e7e8cbe9f Bumped version to 1.11.0
Change-Id: I0c87ad2cf8f8768cf40c5b7abea0add087a5518a
2019-04-24 11:34:53 -07:00
Clément Julliard
b72a75f87d Doc: use correct ref types for flatcc string creation. (#5305)
Some string definitions were typed as ns(Weapon_ref_t) while they should
be flatbuffers_string_ref_t. Note that the former was also compiling &
running correctly as both ref types boil down to the same underlying ref
type.
2019-04-24 10:34:21 -07:00
Philipp Wollermann
6cfcd8628a Don't test on Ubuntu 14.04 (#5302)
Ubuntu 14.04 is about to be end-of-life and Bazel CI will stop supporting it shortly afterwards.

Context: https://groups.google.com/d/msg/bazel-dev/_D6XzfNkQQE/8TNKiNmsCAAJ
2019-04-24 10:28:35 -07:00
Damien Lespiau
ddb12c0192 [Javascript] Remove newly introduced trailing whitespace in flatbuffer.js (#5300)
* Remove newly introduced trailing whitespace in flatbuffer.js

The newly introduced clear function has some trailing white space in an
otherwise whitespace clean file. Remove it.

* Remove spurious new line in the BytesBuffer construction

Another spurious white space introduced by the clear() PR.
2019-04-22 11:48:56 -07:00
Wouter van Oortmerssen
2032b94f61 Fixed file access test in the wrong location.
Change-Id: I520339b442306204563d97743efe988eab459c08
2019-04-22 09:58:29 -07:00
Damien Lespiau
860dc803fe docs: Fix where to find the Typescript typings (#5298)
This is what currently rendered:

  /flatubffers

in https://google.github.io/flatbuffers/flatbuffers_guide_use_typescript.html

Besides the typo, @types is being swallowed, the hope is that puting it between
backticks will improve the situation.
2019-04-19 13:09:26 -07:00
Wouter van Oortmerssen
5b43e4bbb8 Fix heap-buffer-overflow if there is a struct within a union
The validator previously did not check if a struct within a union was
valid, causing a heap buffer overflow.  Add a check to make sure that
the struct is valid in this case.

Change-Id: I87d41b12fdfc2a99406789531ba92b841c063c76
2019-04-19 11:49:49 -07:00
Omer Akram
ecd76e898d Update snap include path instruction (#5297) 2019-04-18 15:15:21 -07:00
Wouter van Oortmerssen
f55d4388e0 Update snap to use "flatbuffers" as name 2019-04-18 13:50:04 -07:00
Omer Akram
e7340c390f Add Linux Snap Packaging (#5293)
* SNAP: cleanup

* Lets keep it in devel mode as it requires more testing

* add better description
2019-04-18 12:22:43 -07:00
Nils Berg
90441c2078 fix check for Enum defaults (#5292)
fixes #5288
2019-04-15 11:38:44 -07:00
Nils Berg
cef8f928bb Struct typetable (#5291)
* C++: Generate MiniReflectTypeTable for Structs as well as Tables

* Update generated code

* add test
2019-04-15 11:38:00 -07:00
Vladimir Glavnyy
98b9b5a933 Add logging of warnings from the flatc compiler (#5289) 2019-04-15 11:34:09 -07:00
Wouter van Oortmerssen
d07a3d2f4c Fixed VS2010 build.
Change-Id: I3ee68c5f250d6baa02060ab2ecbc0f0fe254a9d8
2019-04-11 16:14:38 -07:00
Wouter van Oortmerssen
640df2c1f5 Allow Set() methods to handle reference types
Change-Id: I487ded77d28490189dd5d38236cb04bffaf5f11a
2019-04-11 14:18:21 -07:00
Vladimir Glavnyy
60340ac529 Fix the proto-enum leaking issue (#5286)
* Detect leak with sanitizer

* Fix proto-enum leak issue
2019-04-11 13:52:01 -07:00
Vladimir Glavnyy
2bd4a27550 Detect leak with sanitizer (#5283) 2019-04-11 10:15:11 -07:00
Vladimir Glavnyy
23bb57401c Add basic test for enum defaults (#5280) 2019-04-08 10:21:30 -07:00
Vladimir Glavnyy
dd6daa709b Part of #5265, neutral changes (#5281) 2019-04-08 10:05:50 -07:00
Vladimir Glavnyy
dd85c3b721 Enable MSVC assert report box [Abort|Retry|Ignore] if a debugger is present (#5279) 2019-04-08 10:01:41 -07:00
Henry Lee
94cb1ff9ea Add files generated by CMake to git ignore (#5278) 2019-04-05 12:35:40 -07:00
Henry Lee
3ff6cdf491 [C++]Sync the sample monster.fbs file with the tutorial (#5277)
* Fix the header file path in the tutorial doc

* Add the path field in sample/monster.fbs to match the tutorial

* Update the lobster sample file

* Update the binary sample file
2019-04-05 12:34:53 -07:00
Matt Mastracci
c329d6fa90 Ensure we don't subtract with underflow getting enum names (#5246)
* Ensure we don't subtract with underflow getting enum names

* Yep - forgot to run this
2019-04-05 12:30:58 -07:00
Anthony Liot
249f3b3714 Add method GenerateTextFromTable issue #5249 (#5266)
* Create a function GenerateGenerateTextFromTable in order to create a json from any Table

Signed-off-by: Anthony Liot <anthony.liot@gmail.com>

* Update the test to failed if loadfile or parser return false

Signed-off-by: Anthony Liot <anthony.liot@gmail.com>

* Fix snake_case name typo + space before &/*

Signed-off-by: Anthony Liot <anthony.liot@gmail.com>

* use auto

Signed-off-by: Anthony Liot <anthony.liot@gmail.com>

* Use clang-format on the added code

Signed-off-by: Anthony Liot <anthony.liot@gmail.com>
2019-04-05 11:51:29 -07:00
Kamil Rojewski
2d67de3151 Fix for build break in c# vector of unions (#5271) 2019-04-05 11:49:12 -07:00
unexge
5cdbd02404 Fix typo in Go tutorial (#5274) 2019-04-04 12:28:09 -07:00
Vladimir Glavnyy
b2ce86ef8a Add compile-time checking of numerical limits in C++ code. (#5270)
* Add checking of numerical_limits<T> in C++ code.

* Add integer suffixes (LL/ULL) to int64 values in the IntegerBoundaryTest
2019-04-01 12:03:51 -07:00
tymcauley
8e7acae013 Update grammar to reflect required type signature for enum declarations. (#5269) 2019-03-28 10:48:40 -07:00
Austin Schuh
343bbe808e Add missing test data file to BUILD file (#5264)
$ cat
/home/austin/.cache/bazel/_bazel_austin/4b3182bfa237d7e256d9f18ffe58322f/execroot/com_github_google_flatbuffers/bazel-out/k8-opt/testlogs/flatbuffers_test/test.log
exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //:flatbuffers_test
-----------------------------------------------------------------------------
VALUE: "0"
EXPECTED: "1"
TEST FAILED: tests/test.cpp:2029, flatbuffers::LoadFile( (test_data_path
+ "union_vector/union_vector.json").c_str(), false, &jsonfile) in
VALUE: "0"
EXPECTED: "1"
TEST FAILED: tests/test.cpp:2100, parser.Parse(jsonfile.c_str()) in
VALUE: "0"
EXPECTED: "1"
TEST FAILED: tests/test.cpp:2103, VerifyMovieBuffer(jverifier) in
2019-03-25 16:17:18 -07:00
László Csomor
cb9ab2fe58 Bazel CI: fix bad value in yml (#5262)
Use the "simple format" defined here:
69cf7ec23d/buildkite/bazelci.py (L1453)

This will unbreak the "Bazel / FlatBuffers"
pipeline on Bazel CI, see
https://buildkite.com/bazel/flatbuffers
2019-03-25 12:27:35 -07:00
Nikolay Kuznetsov
4cbff97c43 Fix a warning on compiling with clang (#5258) 2019-03-25 12:06:00 -07:00
LouisP
88abae649c Add inequality operator (inspired from #263) (#5257) 2019-03-25 12:04:51 -07:00
Henry Lee
a7461433c6 [C++] Changes in the flathash program (#5255)
* Correct the usage in the flathash program

As it is possible to have -- before the occurrence of the first
input STRING.

* Exit with 1 in the flathash program when an error occurs
2019-03-21 16:23:32 -07:00
Ashay Shirwadkar
440a70f4a3 Fixed tutorial markdown file (#5248)
Path specified in tutorial file was pointing to invalid location.
2019-03-21 15:51:51 -07:00
Wouter van Oortmerssen
02e73e1ae9 Further fixes to make minireflect compatible with old behavior.
Change-Id: I92c257ec4ab4a0cf4676bd98523b766ce25bf4f6
2019-03-21 15:08:04 -07:00
Vladimir Glavnyy
f93d0f6ac1 Unify line ending rules in '.editorconfig' and '.gitattributes' (#5231)
* Unify line ending rules in '.editorconfig' and '.gitattributes'

* Revert '.gitattributes'

- fix invalid comments in the check-source.py
2019-03-18 12:47:07 -07:00
Wouter van Oortmerssen
fd51fadaac Fixed vector_delimited excluding delimiter
Change-Id: I3e758d44b9845d6df91332bb609b4b7ad88659ac
2019-03-18 12:07:36 -07:00
Wouter van Oortmerssen
11198f10f5 Fixed shadowing warning in older gcc for vector_delimited
Change-Id: Ia4d56a5eb086f86eb5d1ad6ddae64e4a51bf3aa3
2019-03-18 10:03:43 -07:00
Wouter van Oortmerssen
3b23ff18ea Made ToStringVisitor backwards compatible with older behavior.
This to support code that relied on tables being multiline,
but not vectors.

This behavior was changed in:
b1a925dfc2 (diff-c45c8fbffbc64f7ff4aa2978612b10d8)

Change-Id: I4c95471b643b2b3fab95e06b1294e19d686b492c
2019-03-14 12:00:44 -07:00
Wouter van Oortmerssen
4f066c39ce Made JS enum declarations compatible with google closure
Original change by: https://github.com/alexames

Change-Id: Ib65bd02156d1c3637ed278a8334a2307caacaa44
2019-03-11 14:33:07 -07:00
Wouter van Oortmerssen
ca68d8b043 Disabled constexpr for hashing functions.
This was incompatible with -Wc++98-c++11-compat on some platforms,
due to local variables in the function.

Change-Id: Idef510c2cefe944eef2e0656f5a219c2158063e6
2019-03-11 14:02:20 -07:00
Vladimir Glavnyy
407fb5d537 Narrows template ascii routines to prevent a possible signed overflow in generic code. (#5232) 2019-03-11 10:26:28 -07:00
Randal Stevens
73a648b685 Fix typo in dart documentation (#5230) 2019-03-11 09:49:17 -07:00
Wouter van Oortmerssen
eb2a81f73d [C++] Object API: document custom string type requirements,
implement better custom string type constructor alternative
for Unpack() and fix bug with vector of custom string types
in Pack().

Squashed commit of the following:

commit e9519c647e
Author: Luca Longinotti <luca.longinotti@inivation.com>
Date:   Tue Mar 5 18:24:49 2019 +0100

    tests: regenerate code, reverts change to CreateVectorOfStrings().

commit 117e3b0679
Author: Luca Longinotti <luca.longinotti@inivation.com>
Date:   Tue Mar 5 18:15:05 2019 +0100

    idl_gen_cpp.cpp: move clang-format on/off outside of declaration, so they are kept properly aligned automatically.

commit 4791923806
Author: Luca Longinotti <luca.longinotti@inivation.com>
Date:   Tue Mar 5 18:11:40 2019 +0100

    idl_gen_cpp.cpp: full clang-format run with provided Google format file, enforce 80 lines width.

commit 2f0402f9ff
Author: Luca Longinotti <luca.longinotti@inivation.com>
Date:   Tue Mar 5 18:09:32 2019 +0100

    CppUsage: address requested changes.
    idl_gen_cpp.cpp: fix formatting, keep CreateVectorOfStrings for normal string cases.

commit 371d4e0b79
Author: Luca Longinotti <luca.longinotti@inivation.com>
Date:   Fri Mar 1 16:35:29 2019 +0100

    Fix compile error with a vector of non-std::strings. CreateVectorOfStrings() expects a vector of std::string types, but that's not always the case.

commit 92b90d7f0f
Author: Luca Longinotti <luca.longinotti@inivation.com>
Date:   Fri Mar 1 16:15:36 2019 +0100

    Document requirement for custom string types to implement empty() and be constructible from std::string.
    Add new option --cpp-str-flex-ctor to construct custom string types not via std::string, but (char * + length).

commit 28cb2e92d5
Author: Luca Longinotti <luca.longinotti@inivation.com>
Date:   Fri Mar 1 14:31:17 2019 +0100

    idl_gen_cpp.cpp: clang-format run, to better separate changes in content from formatting.

Change-Id: I4887ba2f2c632b9e7a8c938659b088cd95690870
2019-03-11 09:42:02 -07:00
bspeice
3968d00568 [Rust] Don't use inner attributes for allow (#5212)
* Don't use inner attributes for `allow`
Messes with being able to easily include elsewhere

* Regenerate tests

* No-op to retrigger CI

* Add the rest of the `allow` attributes
2019-03-09 12:58:27 -08:00
Mathias Svensson
4f10da8d99 Small usability tweaks to the rust codegen. (#5213) 2019-03-08 13:54:57 -08:00
tymcauley
9e82ee2527 Fix rust crate for big-endian targets (#5229)
Thanks for tackling this, @tymcauley !

* big endian docker test -- wip

* tweaks

* tweaks

* tweaks

* docker tweaks

* fix conditional compilation issues

* reactivate other docker tests

* try some more cross-platform config (from tymcauley)

* Update tests/docker/languages/Dockerfile.testing.rust.big_endian.1_30_1

Co-Authored-By: rw <rw@users.noreply.github.com>

* Update tests/docker/languages/Dockerfile.testing.rust.big_endian.1_30_1

Co-Authored-By: rw <rw@users.noreply.github.com>

* Update tests/docker/languages/Dockerfile.testing.rust.big_endian.1_30_1

Co-Authored-By: rw <rw@users.noreply.github.com>

* Resolved Rust warnings during big-endian builds.

* Unify Rust test suites for x86 and MIPS builds.

Note that I had to add four extra packages to the MIPS `Dockerfile`:
`libexpat1`, `libmagic1`, `libmpdec2`, and `libreadline7`. For a reason
I couldn't identify, even the simplest Rust MIPS binaries run with
`qemu-mips` would fail with a segfault when run through this
`Dockerfile`. After installing the `gdb-multiarch` package to attempt to
debug the issue, the binaries ran successfully. I pared down the
packages installed by `gdb-multiarch`, and these four packages are the
minimum subset necessary to get Rust MIPS binaries running under
`qemu-mips`.

* Changed Rust tests to use `Vector`s instead of direct-slice-access.

The direct-slice-access method is not available on big-endian targets,
but `flatbuffers::Vector`s provide an array interface that is available
on all platforms.

* Resolved FooStruct endianness issues using explicit struct constructor.

This more closely resembles how FlatBuffers structs are constructed in
generated Rust code.

* Added explanation of how `FooStruct` parallels generated struct code.

Also collected duplicate implementations of `FooStruct` into a common
location.
2019-03-08 01:06:25 -08:00
Wouter van Oortmerssen
e237f53bfc Removed -Wc++98-compat-extra-semi for compatibility with older clang.
Change-Id: I6dfadb5289a4396ad2f3d16baf1bdb99c7534174
2019-03-07 15:15:22 -08:00
Austin Schuh
98be491e72 Bazel ci (#5228)
* Stop building for Windows until the build passes

ERROR: D:/b/bk-windows-java8-bd0z/bazel/flatbuffers/BUILD:123:1: Couldn't build file _objs/flatbuffers_test/test.obj: undeclared inclusion(s) in rule '//:flatbuffers_test':
this rule is missing dependency declarations for the following files included by 'tests/test.cpp':
  'tests/monster_test_generated.h'
  'tests/monster_extra_generated.h'

The files in tests are being found instead of the generated files since
Windows doesn't have any sandboxing.  For now, let's disable the rules
and come back to it.

* Fix buildifier warnings

Clean up docstrings and add a module docstring.
2019-03-07 15:09:30 -08:00
Wouter van Oortmerssen
71628dad0d Fixed vector of union JSON parsing.
This for some reason never had a test case, and was broken.

Change-Id: If832f5eb8b6c5ba8a75257464892634b38719c55
2019-03-07 15:05:00 -08:00
jean-airoldie
cb7b2bf87e [Rust] Fixed codegen documentation for Tables (#5227) 2019-03-06 12:00:58 -08:00
David Reiss
bfa430309a [Go] Add mutation functions for vector elements (#5221)
Fixes #5206
2019-03-05 21:16:26 -08:00
ll-antn
1c7d91cc55 Clean-up nested_parser on all paths (#5179) (#5184)
* Clean-up nested_parser on all paths (#5179)

* Added test for parsing json with invalid nested flatbuffer

* Removed utf-8 BOM from test.cpp
2019-03-04 11:35:10 -08:00
Laurent Stacul
2e865f4d4e [Fix #5112] flatc generates constructors with memset for non-trivial types (#5222) 2019-03-04 11:10:18 -08:00
csukuangfj
13c9c674fd [doc] fix typos in doc. (#5217) 2019-02-28 21:39:26 +01:00
naure
034275c6e2 Rust: Fix lifetime in union _as_ accessors (#5140)
* Fix lifetime in union _as_ accessors

In the accessors for union field, the return value is implicitly taking the lifetime of &self.
This is irrelevant and prevents usages of the returned value, because it is needlessly bound to the parent field lifetime.

This patch makes the return value inherit the lifetime of the data, like other methods do.
2019-02-26 23:48:54 -08:00
Kulikov Alexey
4e5152d886 Java: Calculation of vtable and vtable size moved to the __init method. (#5210)
vtable and vtable size depends only on `Table#bb_pos` but calculated in
`Table#_offset` method on each field lookup.
Doing this with every call of `Table#__offset` is redundant.

These values can be read once with change of `Table#bb_pos` and reused
for any field lookup.
2019-02-25 23:45:29 +01:00
Kulikov Alexey
dc61512f20 Java: Removed unused duplicate of bytebuffer from "Table#__string" method. (#5211) 2019-02-25 23:28:13 +01:00
Искандаров Егор
1d60824d56 Lua library: fix vtable reuse. (#5214)
Fixed a bug that prevented vtable reuse during buffer construction in the lua library.

Also fixed a bug in vtable equality check that was revealed after the first fix.
2019-02-25 23:27:42 +01:00
Wouter van Oortmerssen
f89badd30f Attempting to make travis not kill the Android build.
Change-Id: Icdff8a90338bd2ff79ff76fe1ebaa3481da8dea4
2019-02-25 14:10:56 -08:00
Marcus Comstedt
1b9d1b0110 IterateValue: Use ReadScalar instead of unportable reinterpret_casts (#5209)
This fixes the testcase MiniReflectFlatBuffersTest.
2019-02-25 21:45:11 +01:00
Brian Wellington
6e2d530d61 Fix incorrect code generation on Solaris Sparc. (#5208)
On Solaris Sparc, calling NumToString() with a char called the primary
version, not the signed char or unsigned char specializations, which
caused integer to string conversions to be missed.
2019-02-25 21:41:31 +01:00
Wouter van Oortmerssen
9bf9b18f0a Added -Wc++98-compat-extra-semi
And fixed 2 more extra semi-colons.

Change-Id: I1ee08e5b2f67cd0c886847c05cd4d63cfcafec3e
2019-02-25 11:42:37 -08:00
Wouter van Oortmerssen
537c6ec1e6 Added -Wextra-semi to Clang build.
Also fixed warnings this generated.

Change-Id: If3607907b2dd609f854b7b81225d9cf66af75a60
2019-02-25 09:14:56 -08:00
Brian Wellington
a1f14005ab Fix big-endian build. (#5205)
For some reason, Offset<T> is being considered a scalar, which
causes EndianSwap to be passed an Offset<T>.  This doesn't work,
as it does not support types with non-trivial constructors.  This
change adds an overload to WriteScalar(), which works around this.
2019-02-22 01:50:05 +01:00
Eric Erhardt
0cdacdfb35 Remove byte* property in ByteBufferAllocator (#5191)
* Remove byte* property in ByteBufferAllocator.

This allows consumers to read/write into native memory, but without
having to always pin the managed `byte[]` when working with managed
memory. This allows for users to not need to Dispose() ByteBuffers
when they are using the default ByteArrayAllocator class.

Instead, we use `Span<byte> GetSpan()` methods to get access to the
underlying memory buffer.

Fix #5181

* Add a set of benchmark tests.

* Add ReadOnly spans.

This allows consumers to use ReadOnlyMemory<byte> as the backing storage
for ByteBuffers, which is useful in read-only scenarios.

* Run tests using ENABLE_SPAN_T in appveyor.

* Fix FlatBuffers.Test.csproj to work on older MSBuild versions.

* Change the test script to test UNSAFE_BYTEBUFFER

* Address PR feedback.

Remove IDisposable from ByteBuffer.

* Respond to PR feedback.
2019-02-21 23:36:55 +01:00
bwelling
bb58442054 Improve endian detection. (#5204)
Add support for using __BYTE_ORDER__, to support platforms where g++
doesn't explicitly define __BIG_ENDIAN__, like Solaris Sparc.
2019-02-21 22:45:11 +01:00
Marc Butler
4567b13115 Add RPM packaging support (#5177)
* Add RPM packaging support

Using the existing PackageDebian as template add support for
generating an rpm with the package target.

* Restore debian package target

Also add an option to advertise the fact.

* Update package description

C-n-p from README.md

* Update rpm package maintainer
2019-02-21 20:06:04 +01:00
Kamil Rojewski
8f8fb2b367 Fixed vector of unions crash in java (#5190)
* Fixed vector of unions crash in java

* Regenerated test code

* Fixed windows tests
2019-02-21 19:50:13 +01:00
Efe Burak
69d761d15e Added .net core project (#5187) 2019-02-21 19:47:19 +01:00
csukuangfj
4f32cbf268 Fix an error in cpp code. (#5189)
Change monster_generate.h to monster_generated.h
2019-02-19 20:23:10 +01:00
Vladimir Glavnyy
0eaaf18192 Utility for checking the encoding and line ending of source files (#5188)
* Add utility for checking the encoding of source files

- accept source files with ASCII or UTF-8 without BOM
- accept only CRLF line ending

* Fix non-ascii symbol in idl_parcer.cpp

* Remove BOM from test.cpp
2019-02-19 20:22:25 +01:00
Wouter van Oortmerssen
957d167199 Fixed use of WIN32 needs to be _WIN32.
Change-Id: Ie1f88ac5613cc09ed1074608dd6517ae20c7973d
2019-02-19 10:49:55 -08:00
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
Vladimir Glavnyy
5f32f94810 Make the Parser independent from the global C-locale (#5028)
* Make the Parser independent from the global C-locale

* Set a specific test locale using the environment variable FLATBUFFERS_TEST_LOCALE

* Remove redundant static qualifiers
2018-11-16 09:24:06 -08:00
Kamil Rojewski
d6b1ce09cf Fixed double generated file name postfix (#5046)
* Fixed double generated file name postfix

* Fixed missing file postfix on imports without reexports
2018-11-16 09:20:29 -08:00
Austin Schuh
f23009f04f Make flatbuffer C++ tests work when vendored with bazel (#5040)
Tests for third_party code are run out of the main workspace.  This
isn't an issue when the main workspace is the
com_github_google_flatbuffers workspace, but is an issue when you are
running the tests from another repository.

To reproduce, use "git_repository" to add flatbuffers to a project and
then run:
  bazel test @com_github_google_flatbuffers//:flatbuffers_test
2018-11-16 09:19:34 -08:00
Kamil Rojewski
30bae01ea3 Convenient createX methods for TS (#5044) 2018-11-16 09:17:54 -08:00
Shivendra Agarwal
9068b0ee63 flexbuffers blob to string implementation (#5039) 2018-11-15 14:57:05 -08:00
Robert
f8a0d3889b Fix missing doxygen link to Rust docs 2018-11-13 11:10:03 -08:00
Antonio Park
688fc77460 Wrong int32 min-max range definition on numTypes.lua (#5031)
* Update numTypes.lua

int32 range was wrongly defined.

* Update numTypes.lua

Fix number 32 to 31
2018-11-12 09:40:24 -08:00
Uilian Ries
dd8922878d Update Conan version Automatically (#5027)
* #5026 Add FindFlatBuffers.cmake to Conan Package

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* #5026 Build Flatbuffers on OSX 10

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* #5026 Auto update Conan package version

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* #5026 Update Conan docker images

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* #5026 Update tag var on Appveyor

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* #5026 Filter appveyor brach name

Signed-off-by: Uilian Ries <uilianries@gmail.com>
2018-11-12 08:49:42 -08:00
Shivendra Agarwal
ab54e61805 FlexBuffer to JSON convertor for typed and fixedTypedvectors (#4947)
* FlexBuffer to JSON convertor for typed and fixedTypedvectors

* moving the common implementation to template

* signed unsigned comparison fix

* fix a formatting ({

* changing logic to append comma in vector of elements in json
2018-11-12 08:49:11 -08:00
Wouter van Oortmerssen
f445c1eb4a Fixed STLPort build
Change-Id: I2b9508f547667695475be64fa56f64f129603fd4
2018-11-05 16:33:35 -08:00
Wouter van Oortmerssen
980a6d66d3 Fixed vectors of enums in object API serialized incorrectly.
And also added tests for them.

Change-Id: I91af1904105435601287291412e82d5066f476a5
Tested: on Linux.
2018-11-05 14:33:36 -08: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
Sumant Tambe
b6c3d7b899 Fix a memory leak in builder test (#5021)
* Fix a memory leak in builder test

* using RAII to free memory
2018-11-02 10:04:58 -07:00
Gabriel Nützi
db0fcdd906 --keep-prefix for JS generator (#5018)
* keep include path

* add option --keep-prefix for js

* format contribution (format whole files before merge!)

* revert util.h : IsAbsPath ...

* JS Generator: only support relatives paths (keep it as it was)
2018-11-02 08:54:43 -07:00
Frank Benkstein
91fe9ba93f make unions with type aliases more usable (#5019)
Some generic C++ and Rust code is not generated when unions use type
aliases because of potential ambiguity. Actually check for this
ambiguity and only disable offending code only if it is found.
2018-11-01 12:51:25 -07:00
Robert
4c3b6c247d Rust: test that no heap allocs happen on hot paths (#5022) 2018-10-31 18:08:14 -07:00
Wouter van Oortmerssen
160e8f2fdc Disallowed 0 byte structs.
This is because they are incompatible with C++ and possibly other
languages that make them minimum size 1 (to make sure multiple
such objects don't reside at the same address). Forcing them to size
1 was also not practical, as that is requires updating the logic
of a lot of implementations and thus possibly backwards incompatible.

More here: https://github.com/google/flatbuffers/issues/4122

Change-Id: I2bfdc8597b7cfd2235bb4074bb2ae06f81f8e57d
2018-10-29 17:40:19 -07:00
Wouter van Oortmerssen
705577de51 Revert "Convert net/FlatBuffers project to be compatible with netstandard (#4811)"
This reverts commit 72b05bc865.

Change-Id: I17510b7fa49b9861ce0a870b16f5c14a41082db5
2018-10-29 17:21:30 -07:00
Vladimir Glavnyy
0fb1d44bc4 Add 'fsanitize=address,undefined' to tests and flatc targets (#5009)
* Add '-fsanitize' optional flags to flattests and flatc targets

Control: -DFLATBUFFERS_CODE_SANITIZE=(ON | OFF | "=memory,undefined")
Travis-CI: building with -DFLATBUFFERS_CODE_SANITIZE=ON

* Fix -pie flag

* Cleanup
2018-10-29 11:29:05 -07:00
Wouter van Oortmerssen
bd20a60d6a Fixed Java gRPC version numbers.
Change-Id: Iff00a48b370f45f80d68e6c6929483d608ce1885
2018-10-25 13:48:41 -07:00
Wouter van Oortmerssen
b78c4332be Fixed npm publish appending multiple copies into .mjs
Change-Id: Id8c373b0f77d9a0f4922257339abb4e01e06c2d4
2018-10-25 13:48:41 -07:00
csmoe
636b516492 clean up unnecessary outer rust gen-snippet (#5013)
* clean up unneeded outer rust gen-snippet

* update generated rust file
2018-10-23 20:16:18 -07:00
Felix Hanley
560718e976 Use stdlib context in generated Go files (#4904) 2018-10-22 16:28:58 -07:00
Doug Muir
ff687ae9c1 Make alignment checking optional. (#5011) 2018-10-22 16:14:44 -07:00
Frank Benkstein
ca417426c7 make flatbuffers::IsFieldPresent safer (#4988)
Give the vtable offset enum inside each table the name
"FlatBuffersVTableOffset" and base type voffset_t so it can be used as a
dependent type in IsFieldPresent. This makes that function slightly
safer since it prevents calling it with arbitrary, non-table types.
Now, the only way to use IsFieldPresent incorrectly is to create your
own type which does not inherit from flatbuffers::Table but has a
dependent voffset convertible type "FlatBuffersVTableOffset".
2018-10-22 15:57:45 -07:00
Vladimir Glavnyy
55b30827f2 Add fuzzer test for scalar numbers in json. (#4996)
* Add fuzzer test for scalar numbers in json. Grammar-based regex used to check correctness.

* Fix conversation
2018-10-22 15:44:18 -07:00
Frank Benkstein
efbb11e093 CI check generate code (#4998)
* call reflection code generation from tests

This simplifies instructions to contributors so they don't forget to update
reflection code.

* add error handling to generate_code scripts

Let them propagate their errors instead of swallowing them so they show
up when called in CI.

* apply editorconfig to shell scripts

* use ordered map in dart codegen

Using an unordered map in the codegen can lead to spurious diffs in the
generated dart code.

* add CI check for generate_code being run

* update reflection_generated.h

* disable diff-check for monster_test.bfbs

Work around #5008.
2018-10-22 15:41:12 -07:00
Frank Benkstein
5c0f914f38 forbid enum values that are out of range (#4977)
* forbid enum values that are out of range

Enum values that are out of range can lead to generated C++ code that does
not compile.  Also forbid boolean enums.

* update enum and union documentation slightly
2018-10-18 10:39:08 -07:00
Sumant Tambe
802639e40d Efficient Conversion of a FlatBufferBuilder to a MessageBuilder (#4980)
* Efficient conversion of FlatBufferBuilder to grpc::MessageBuilder

* Added a variety of tests to validate correctness of the MessageBuilder move operations.
Disable MessageBuilder half-n-half tests on MacOS.

* Fix failing Android build

* Generalized the MessageBuilder move constructor to accept a deallocator
2018-10-18 10:32:59 -07:00
Felix Frank
ad8b1e5dbd [Python] Fast serialization of numpy vectors (#4829)
[Python] Fast serialization of numpy vectors (#4829)
2018-10-15 17:07:08 -07:00
kostya-sh
76d31e1b5e Go - Use Go bool type for bool fields (#4962)
* Use Go bool type for bool fields, and store non-default bool field to test data
2018-10-15 16:55:59 -07:00
Frank Benkstein
20396a1760 disallow c style casts (#4981)
Fixes #4857.
2018-10-15 15:11:31 -07:00
Frank Benkstein
a3d8391f7b don't use std::function in flatbuffers::Parser (#4995)
std::function makes code harder to debug because it requires stepping
through a separate destructor and call operator.  It's use unnecessary
in the Parser since the functions taking functors are private and are
only used within idl_parser.cpp.  Therefore the definitions can stay in
idl_parser.cpp as well.  Only care must be taken that the definitions
appear before use but that's already true and all compilers will
complain equally if it get's violated.  This change might also improve
performance since it might allow inlining where it wasn't possible
before but I haven't measured that.
2018-10-15 12:26:35 -07:00
iceboy
241e87d143 add :runtime_cc target (#4994) 2018-10-15 12:18:15 -07:00
Frank Benkstein
35f0b41fed fix missing newline in flatc help message (#4992) 2018-10-11 15:54:01 -07:00
Frank Benkstein
cb5422c398 fix #4974 (#4989) 2018-10-11 12:40:41 -07:00
Vladimir Glavnyy
4ed6fafdfa Refactoring of idl_parser (#4948)
* Refactoring of numbers parser

More accurate parse of float and double.
Hexadecimal floats.
Check "out-of-range" of uint64 fields.
Check correctness of default values and metadata.

* Remove locale-independent code strtod/strtof from PR #4948.

* small optimization

* Add is_(ascii) functions

* is_ascii cleanup

* Fix format conversation

* Refine number parser

* Make code compatible with Android build

* Remove unnecessary suppression of warning C4127
2018-10-11 10:37:47 -07:00
Frank Benkstein
53ce80ce91 better output on TestError (#4979)
Print a slightly better error message when a TestError fails.
2018-10-11 10:33:12 -07:00
Rikard Lundmark
233976c821 Add @javax.annotation.Generated to generated flatbuffer Java types (#4986)
* Add @javax.annotation.Generated to generated flatbuffer Java types.

* Updating test goldens.
2018-10-08 15:29:22 -07:00
Frank Benkstein
99fe1dc80f don't crash when calling EnumNameXXX on sparse enum (#4982)
Make an out-of-bounds check for enum values before using them to index the
names array.  For consistency with non-sparse enums an empty string is
returned.

Fixes #4821
2018-10-08 14:37:35 -07:00
Michael Edwards
a4f9d1bfcc Fix expected type of enum values in reflection tables (#4944)
Fixes #4930
2018-10-08 14:29:29 -07:00
kostya-sh
a4c362a1ba Use enum types in generated read/mutate methods for Go (#4978) 2018-10-08 14:25:37 -07:00
cor3ntin
7c3c027295 Add missing const on Reference::As<> (#4975)
Reference::As<> was needlessly mutable wich made them
less safe and harder to use
2018-10-08 12:52:01 -07:00
Stewart Miles
569492e890 Disable armeabi builds for Android and re-enable CI builds. (#4970)
armeabi support was removed from the Android NDK so we should no
longer build it.  Since this fixes the Android build failures this
commit also re-enables Travis Android builds.

While re-enabling Android builds, some recent changes broke C++98
support so this fixes those issues as well which include:
- Conditionally compiling use of move constructors, operators and
  std::move.
- Changing sample to use flatbuffers::unique_ptr rather than
  std::unique_ptr.

Finally, added the special "default_ptr_type" value for the
"cpp_ptr_type" attribute.  This expands to the value passed to
the "--cpp-ptr-type" argument of flatc.
2018-10-08 12:43:57 -07:00
Taj Morton
d840856093 In Javascript, generate bidirectional mappings for enums, between Name: Value and between Value: Name. (#4960) 2018-10-04 10:37:22 -07:00
Vladimir Glavnyy
925c1d77fc Fix recursion counter check. Add control to override depth of nested … (#4953)
* Fix recursion counter check. Add control to override depth of nested objects.

* Change if-condition to `>=`
2018-10-04 09:27:37 -07:00
Wouter van Oortmerssen
c0698cc33f Bumped version to 1.10.1 for all languages.
Change-Id: I9a6256d90ea800834a887afdcf888df412018933
2018-10-03 12:48:47 -07:00
Wouter van Oortmerssen
ea8a4296e7 Updated TestAll.sh with Rust.
Change-Id: I751f3bbd85eb1b521e1533c68f95442af0d18b8a
2018-10-03 12:27:27 -07:00
Jason Neufeld
f85af46262 Adds __reset method to Struct and Table (#4966)
This allow recycling/pooling instances without leaking ByteBuffers, by
providing a mechanism to reset instance to newly constructed state.
2018-10-03 12:09:30 -07:00
Vladimir Glavnyy
7a43775661 Assert tests on the first failure. (#4952)
* Assert tests on the first failure. Disable pop-up message box on assertion.

* Fix format and code style

* Move MSVC dependent code to ifdef
2018-10-03 12:04:14 -07:00
kostya-sh
062dcf7007 Use standard header for generated Go files (#4961)
As recommended by https://golang.org/pkg/cmd/go/internal/generate/:

  To convey to humans and machine tools that code is generated,
  generated source should have a line early in the file that
  matches the following regular expression (in Go syntax):

        ^// Code generated .* DO NOT EDIT\.$
2018-10-03 11:19:40 -07:00
Taj Morton
ebb410062b Allow tables that are entirely composed of native inlines to be copied. (#4958) 2018-10-01 16:27:54 -07:00
Sumant Tambe
4b864fd172 Turn on gRPC tests in travis build (#4955)
Download and build with a known grpc version
2018-10-01 15:59:04 -07:00
Vladimir Glavnyy
7e711f80d7 Parser error message reports both the line number and the cursor position. (#4954) 2018-10-01 14:57:36 -07:00
Matt Mastracci
bf871ffd7f Remove lifetime specifier on table getter methods (#4949)
With the old-style code, the test fails with a borrow-checker error:

```
  #[inline]
  pub fn name(&'a self) -> &'a str {
    self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(Monster::VT_NAME, None).unwrap()
  }
```

```
error[E0597]: `e` does not live long enough
   --> tests/integration_test.rs:273:57
    |
273 |         let enemy_of_my_enemy = monster.enemy().map(|e| e.name());
    |                                                         ^      - `e` dropped here while still borrowed
    |                                                         |
    |                                                         borrowed value does not live long enough
274 |         assert_eq!(enemy_of_my_enemy, Some("Fred"));
275 |     }
    |     - borrowed value needs to live until here
```
2018-09-28 20:11:05 -07:00
kzvi
a89be8739c loosen lifetimes in type signature of Table::get (#4925) 2018-09-27 20:56:49 -07:00
Shivendra Agarwal
0bffce5aef Add more apis to query vector types from a reference (#4823)
* Add more apis to query vector types from a reference

https://github.com/google/flatbuffers/issues/4818

* changing order of apis

* another reordering

* removed vector element type api as not needed as for now
2018-09-27 12:34:27 -07:00
Vladimir Glavnyy
d48f08acfe Add missed defined(clang) and fix the wrong placement of #pragma push/pop for MSVC compiler (#4946) 2018-09-27 12:31:43 -07:00
kzvi
43132560f9 don't return Option from required table field accessors (#4926) 2018-09-26 21:11:25 -07:00
jean-airoldie
c56fff88a2 rust: Fixed MakeCamelCase (#4932) (#4936)
* Fixed MakeCamelCase behavior when supplied Upper_Camel_Case,
snake_case and UPPERCASE strings.
* Modified the rust integration test to reflect changes.
2018-09-26 13:35:02 -07:00
Sumant Tambe
49fed8c4f6 Add FlatBufferBuilder move semantics tests to the main test suite (#4902)
* Add FlatBufferBuilder move semantics tests to main

Do not eagerly delete/reset allocators in release and release_raw functions
Update android, vs2010 build files
New tests for various types of FlatBufferBuilders and move semantics

* Improve test failure output with function names
2018-09-24 12:03:31 -07:00
Michael Edwards
b1a925dfc2 ToStringVisitor settings to allow pretty formatted JSON (#4933) 2018-09-24 09:29:49 -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
Wouter van Oortmerssen
873a60b0d8 Updated readme.md
Change-Id: I9b0664a3bde44a4ee44ef0fd117d0e4bedc132d9
2018-09-21 10:42:00 -07:00
Wouter van Oortmerssen
4b10656f9b Changed JS/TS codegen to use stable non-compiler dependent hash.
Different implementations of std::hash kept littering commits with
namespace changes.

Change-Id: Ic2d4fdcd76f8fef9802bc1572eb74ae7427085e3
2018-09-21 09:42:43 -07:00
Wouter van Oortmerssen
e317b148dc Added missing Dart codegen files.
Change-Id: Ic97f5b50fa191f967672c404f737d302462fc6ac
2018-09-21 09:42:43 -07:00
Christopher Cifra
ed03faaf07 [C#] Fix compile issue when compiling with older versions of C# (#4938)
* C# support for directly reading and writting to memory other than byte[].  For example, ByteBuffer can be initialized with a custom allocator which uses shared memory / memory mapped files.

Public access to the backing buffer uses Span<T> instead of ArraySegment<T>.

Writing to the buffer now supports Span<T> in addition to T[].

To maintain backwards compatibility ENABLE_SPAN_T must be defined.

* Remove usage of expression bodied method so that ByteBuffer can be compiled with older version of C#.
2018-09-20 15:07:03 -07:00
Robert
02a7807dd8 Add Rust to Appveyor config. (#4928) 2018-09-12 11:44:51 -07:00
Enrico Olivelli
615885e889 Add ByteBufferFactory#releaseByteBuffer (#4914)
This adds the ability to dispose unused buffers or to return them to an object pool
2018-09-06 11:08:08 -07:00
Robert
528ccdd458 rust: more builder lifetimes predicates (#4923) 2018-09-05 18:15:30 -07:00
Robert
c23ba6756f rust: more builder lifetimes logic (#4917) 2018-09-04 21:53:39 -07:00
Onur Karaman
10e1d1a69e fix rust flatbuffers create_vector docs (#4913)
Manual vector creation begins with start_vector, not create_vector.
2018-09-04 14:30:31 -07:00
Robert
660c491265 rust generator: fix builder lifetime switch (#4912) 2018-09-04 14:29:27 -07:00
Robert
c504a45404 rust generator: fix enum member comments (#4911) 2018-09-04 13:52:31 -07:00
Robert
919c929d30 readme.md: add Rust as a supported language 2018-09-03 23:38:41 -07:00
Robert
ba4a02b46a Update Cargo.toml for Crates.io package 2018-09-03 19:42:25 -07:00
Robert
be3d0b9c64 delete and ignore Cargo.lock files (#4906) 2018-09-03 19:33:38 -07:00
Chris Holcombe
872fad049e Fix extern crate in root namespace (#4905)
Imports the Rust FlatBuffers runtime crate even when not using a namespace in a schema.
2018-09-03 19:09:38 -07:00
Robert
9e648c392b Rust: Add basic crate-level documentation 2018-09-03 18:01:31 -07:00
Robert
d4f65bb8a3 Update Rust runtime crate version for publishing 2018-09-03 17:13:10 -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
Sumant Tambe
e7578548a5 Add move semantics to MessageBuilder, FlatBufferBuilder, SliceAllocator, and vector_downward (#4893)
Unit tests
Update flatbuffers + gRPC build instructions
Update CMakeLists.txt with cmake variables for grpc and protobuf install paths
Update tests for travis build
2018-08-30 16:43:22 -07:00
Gabriel Nützi
99acd0bcd7 DetachedBuffer cannot be rewrapped (#4885)
* Simple ReleaseRaw implemented

* [doc]

* clear_buffer and clear_allocator introduced

* auto

* typos

* rename because of -Werror=shadow
2018-08-24 10:57:57 -07:00
Christopher Cifra
d0321df8cf C# support for directly reading and writting to memory other than byte[]. For example, ByteBuffer can be initialized with a custom allocator which uses shared memory / memory mapped files. (#4886)
Public access to the backing buffer uses Span<T> instead of ArraySegment<T>.

Writing to the buffer now supports Span<T> in addition to T[].

To maintain backwards compatibility ENABLE_SPAN_T must be defined.
2018-08-23 10:05:31 -07:00
Derek Bailey
e1f48ad35a Updated preprocessor check for template aliases. (#4888) 2018-08-23 09:48:03 -07:00
Derek Bailey
d8f49e18d7 Mono Fix for Unsafe Mode (#4887)
* Added preprocessor define for C++ if Template Aliases are supported by the compiler

* Revert "Revert "Performance Increase of Vector of Structures using .NET BlockCopy (#4830)""

This reverts commit 1f5eae5d6a.

* Put<T> method was inside #if UNSAFE_BYTEBUFFER which caused compilation failure when building in unsafe mode

* Revert "Added preprocessor define for C++ if Template Aliases are supported by the compiler"

This reverts commit a75af73521.
2018-08-20 16:31:44 -07:00
Wouter van Oortmerssen
1f5eae5d6a Revert "Performance Increase of Vector of Structures using .NET BlockCopy (#4830)"
This reverts commit 7b50004ec9.

Change-Id: I09d6869c16aa3c7fadc537fc9c76eaa3cf7ee7ea
2018-08-20 12:08:21 -07:00
Wouter van Oortmerssen
ea9d60bbdf Added missing dart/ts test changes.
Change-Id: I836091193485b890710f1df779d4d770f729a27a
2018-08-20 12:05:37 -07:00
Andy Martin
c2c3a84aaf Add C#/Java generator behaviour for 'private' attribute (#4882)
* Added 'private' attribute, supported when generating C# and Java

* Added use of 'private' attribute in monster_test
2018-08-16 15:25:33 -07:00
Uilian Ries
1f03becd24 Conan build packages on CI (#4590) (#4594)
* Build Conan package on Travis CI (#4590)

- Added multi package support on Linux, running on Travis CI
- Only upload when branch is a tag and named "vX.Y.Z"
- Replace Conan injection by Conan wrapper
- Removed os_build os_arch -- Conan 1.0.1 hotfix

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Build Conan package on OSX (#4590)

- Added jobs to build Flatbuffers on OSX running on Travis

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Build Conan package on Windows (#4590)

- Added support necessary to build Flatbuffers on Windows (conan)
- Added Appveyor jobs to build Conan package
- Only build Conan package when release (tag)

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Reduce Conan CI support to simple scripts (#4590)

- Removed msvc 10 x86_64 workaround
- Updated conan remote address
- Added Bincrafters' package tools

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Add fPIC option on Conan recipe (#4590)

- Add fPIC as optional. It works on Linux and OSX
- Update recipe metadata: author, homepage, license
- Checking for flatc and flathash on Conan package

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Build Conan package on CI (#4590)

- Add rule to run conan job only for tags
- Run Conan on Linux, OSX and Windows
- Update package tool to new interface

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Update Conan username (#4590)

- Use google as default username

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Update OSX version on CI (#4590)

- Use latest OSX 9.3 version to build Conan package

Signed-off-by: Uilian Ries <uilianries@gmail.com>
2018-08-16 12:17:52 -07:00
kulswanand
c721009491 Proposing use of C++ header files and functions (#4869)
* Proposing use of C++ header files and functions 

Proposing use of C++ header files and functions instead of C header file and functions. 
Here are few examples for comparison : 

C                            C++
<cstdio>                <iostream> & <fstream>
printf()                     cout 
fopen()                    ifstream
etc ...

Please let me know if there are any comments.

* Updated diff based on review comments
2018-08-13 16:36:11 -07:00
iceboy
55289c55bf Use string_view if _HAS_CXX17 is true (#4876)
Current version of VC2017 is not setting __cplusplus to correct value, instead they use _MSC_VER, _MSVC_LANG and _HAS_CXX17 macros.
2018-08-13 16:19:51 -07:00
Wouter van Oortmerssen
ed2415eb72 Fixed use of uoffset_t in verifier could cause wrap around.
The verifier must be resilient against any corrupt data, so
now using size_t thru-out to ensure any 64-bit offsets can
be represented.

Also added verification of alignment.

Change-Id: I87a22aa6b045c2d83b69b47a47153f2e15ad7e06
Tested: on Linux, also with libfuzzer.
2018-08-13 14:52:50 -07:00
Matias Cudich
aaa89429d3 Update JavaScript IDL generator to remove invalid Closure JSDoc comments (#4873)
* Update JavaScript IDL generator to remove invalid Closure JSDoc comments

* Revert erroneous changes

* A few more tweaks

* Updated generated code
2018-08-10 15:27:51 -07:00
iceboy
12e5cf0b29 Remove FLATBUFFERS_COPTS from bazel BUILD (#4872)
fixes #4868
2018-08-10 13:43:48 -07:00
cubeleo
75601b81cc Correctly generate identifier for enums. (#4871)
This should allow the EnumName* function to work with enums generated
using the --scoped-enum flag.
2018-08-10 13:41:32 -07:00
Andrew Selle
e203882d54 Clarify flatbuffer reflection struct sizes to be less error-prone. (#4870) 2018-08-10 10:55:54 -07:00
iceboy
b9f1103b8a Add licenses to BUILD (#4867)
This allows to build flatbuffers from third_party directory.
2018-08-10 08:21:17 -07:00
Dan Field
fd40cc61a4 Ensure strings are null terminated when written from Dart (#4862)
* Update for Dart 2.x constants

* Fix strings, update test, add CHANGELOG for Dart
2018-08-09 09:50:54 -07:00
Wouter van Oortmerssen
38a6623f34 Temporarily disabled Android CI until fix.
Change-Id: I0c6758db7b4007e84b7ab8daaecd233711df8cab
2018-08-06 16:52:09 -07:00
Vladimir Glavnyy
27e4f43b77 Attach header directory information to the "flatbuffers" library target (#4849)
* Attach header directory information to the "flatbuffers" library target, if the CMake version supports it.

* Cleanup and documentation update
2018-08-06 14:59:29 -07:00
Kamil Rojewski
42515cfd33 Publishing flatc with conan (#4852)
* Eclipse ignore

* TypeScript support

* Prefixing enums

* Test results

* Merged JS and TS generators

* Fixed AppVeyor build problems

* Fixed more AppVeyor build problems

* Fixed more AppVeyor build problems

* Changed TS flag to options struct

* Storing options by value

* Removed unneeded const

* Re-export support for unions

* Uint support

* Casting bools to numbers for mutation

* TS shell tests

* Reverted generates js test file to original version

* Backing up js tests and properly generating test data

* Not importing flatbuffers for TS test generation

* Not overwriting generated js for tests

* AppVeyor test fixes

* Generating the most strict TS code possible

* Not returning null when creating vectors

* Not returning null from struct contructors

* Vector of unions for ts/js

* Sanity check for languages

* Indentation fix + output test files

* Vectors of unions for php

* Fixes to union vector handling + tests

* Fix for strictPropertyInitialization

* Fix for new aligned operator new for gcc >= 7.1

* Not generating imports/ns prefixes with --gen-all

* TypeScript docs

* Missing imports of enums

* Missing TS links

* Enabled vector of unions for java, since it seems to work

* Added jitpack config

* Added obj to vector of unions getter

* Removed unneeded accessor

* Bumped jdk version in pom.xml

* Vector of unions support for c#

* Missing TypeScript doc processing

* Option to NOT force libc++ when building with clang

* Publishing flatc with conan
2018-08-06 12:45:35 -07:00
Charlie Harrison
5d3648b88a Remove using namespace std; (#4851) 2018-08-06 12:08:49 -07:00
Wouter van Oortmerssen
fc3ce7d1ab Fixed VS2010 compile error.
Change-Id: Ibd970d30b51f77a2ac9c125e400c9f1b19a81cbc
2018-08-06 12:06:59 -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
ca5aaf62d3 Adds multi-line to FLatBufferToString (#4847)
Adding multi-line option to FlatBufferToString method in minireflect to allow more readable output for larger flatbuffers.
2018-07-27 12:45:12 -07:00
Wouter van Oortmerssen
c80f8d18c1 Fixed FlatBufferBuilder::Required not checking vtable size.
As reported in: https://github.com/google/flatbuffers/issues/4846
Tested: on Linux.

Change-Id: Id5e82dc5a46a681119cfe5a15415d522aac0e1f2
2018-07-27 12:41:50 -07:00
cubeleo
0d1559bdd4 For sparse enums, use a switch statement to generate EnumNameXXX(). (#4845) 2018-07-27 08:32:19 -07:00
Robert
8b39a0ee53 Merge pull request #4843 from rw/2018-07--explicit-enumish-types
go: give enums their own scalar types
2018-07-26 16:57:01 -07:00
rw
f675f6433c go: give enums their own scalar types 2018-07-26 16:46:35 -07:00
Paul Reimer
118093b613 Update FLATBUFFERS_HAS_STRING_VIEW __cplusplus checks to the versions provided by the standard feature test macros. (#4841) 2018-07-26 15:40:41 -07:00
Robert
1bb2a3bd08 Merge pull request #4820 from nairb774/master
[Go] encode.go performance changes
2018-07-26 15:35:45 -07:00
Dan Field
2361dfb66a Update for Dart 2.x constants (#4842) 2018-07-26 14:21:23 -07:00
Derek Bailey
7b50004ec9 Performance Increase of Vector of Structures using .NET BlockCopy (#4830)
* Added Get<vector_name>Array() method for accessing vectors of structures in C# using Buffer.Blockcopy().

* Added Get<vector_name>Array() method for accessing vectors of structures in C# using Buffer.Blockcopy().

Added Create<Name>VectorBlock() method to add a typed array using Buffer.BlockCopy() to speed up creation of vector of arrays

New Lua files for namespace test

* fixed c++ style issue
2018-07-26 13:44:40 -07:00
Wouter van Oortmerssen
6e185d06a7 Fixed minalign in Lua being reset on StartObject
Change-Id: I9cd62b38c8dc526f069726a88baef63e4b0dae57
2018-07-23 16:36:21 -07:00
Robert
c949229395 go: do not clobber minalign when we create objects (#4834) 2018-07-23 16:34:08 -07:00
Robert
e1d5fda5d4 python: do not clobber minalign when we create objects (#4833) 2018-07-23 16:29:45 -07:00
Evan Moran
a2603ec27e Add missing public header minireflect.h to bazel build (#4832) 2018-07-23 16:28:49 -07:00
Evan Moran
5f1b1ad42c Fixing bazel build's missing lua file (#4831) 2018-07-23 16:28:09 -07:00
shassani
4235a25640 Adds ForceStringAlignment to flatbuffers. (#4828)
ForceStringAlignment is useful for memory aligning string fields in flatbuffers.
2018-07-19 16:00:31 -07:00
Shivendra Agarwal
88cd182349 Restricting (typed=false, fixed=true) combination in flexbuffer CreateVector (#4825)
https://github.com/google/flatbuffers/issues/4815
2018-07-19 14:59:06 -07:00
Shivendra Agarwal
7c824ef690 Fixing an assert in flexbuffers CreateVector (#4824)
An assert was blocking the creation of typedvectors. It was wrongly checking for limited types even though vector was not of fixedTyped.
2018-07-19 14:55:06 -07:00
Kamil Rojewski
6bfa107f4e Option to NOT force libc++ when building with clang (#4826)
* Eclipse ignore

* TypeScript support

* Prefixing enums

* Test results

* Merged JS and TS generators

* Fixed AppVeyor build problems

* Fixed more AppVeyor build problems

* Fixed more AppVeyor build problems

* Changed TS flag to options struct

* Storing options by value

* Removed unneeded const

* Re-export support for unions

* Uint support

* Casting bools to numbers for mutation

* TS shell tests

* Reverted generates js test file to original version

* Backing up js tests and properly generating test data

* Not importing flatbuffers for TS test generation

* Not overwriting generated js for tests

* AppVeyor test fixes

* Generating the most strict TS code possible

* Not returning null when creating vectors

* Not returning null from struct contructors

* Vector of unions for ts/js

* Sanity check for languages

* Indentation fix + output test files

* Vectors of unions for php

* Fixes to union vector handling + tests

* Fix for strictPropertyInitialization

* Fix for new aligned operator new for gcc >= 7.1

* Not generating imports/ns prefixes with --gen-all

* TypeScript docs

* Missing imports of enums

* Missing TS links

* Enabled vector of unions for java, since it seems to work

* Added jitpack config

* Added obj to vector of unions getter

* Removed unneeded accessor

* Bumped jdk version in pom.xml

* Vector of unions support for c#

* Missing TypeScript doc processing

* Option to NOT force libc++ when building with clang
2018-07-19 09:40:28 -07:00
Wouter van Oortmerssen
0cd8daf14e Missing Lua generated files
Change-Id: Id668ade474805dd9c7e108a478db3551d6a62b48
2018-07-16 16:44:49 -07:00
Wouter van Oortmerssen
79f2adc50a Renamed Verifier methods
The name Verify was getting too overloaded, and confused
the VS compiler

Change-Id: I26423a4d513e4def2f4e41d7f278bb683fc12518
2018-07-16 16:42:10 -07:00
Wouter van Oortmerssen
dcfe38c58f Dart generated code changes
Change-Id: I1110974a375acb9668552294632658d9d1779772
2018-07-16 16:42:10 -07:00
shassani
51d9641de6 flatbuffer force-empty option (#4822) 2018-07-16 16:05:06 -07:00
Wouter van Oortmerssen
af6c0e6839 Updated fuzzer scripts
Point to new Chromium location
Also enable UBSan

Change-Id: I4ba182e3c6a967ad89090b776d05762fa9ae6e40
2018-07-16 15:51:28 -07:00
Wouter van Oortmerssen
7c3cb5caa1 Fixed assert in ParseSingleValue (found by fuzzer)
Change-Id: I84674eaab75b2b455e918b04e3027920430678ac
2018-07-16 15:51:28 -07:00
Wouter van Oortmerssen
8f1bebba05 C++ verifier now primarily uses offsets instead of pointers.
Fix for: https://bugs.chromium.org/p/chromium/issues/detail?id=834710

Before, the verifier would create pointers to objects, and then
verify they are inside the buffer. But since even constructing pointers
that are outside a valid allocation is Undefinied Behavior in C++, this
can trigger UBSAN (with -fsanitize=pointer-overflow).

Now instead the bounds checking is first performed using offsets
before pointers are even created.

Change-Id: If4d376e90df9847e543247e70a062671914dae1b
Tested: on Linux.
2018-07-16 15:51:28 -07:00
xgdgsc
cda1525f84 📝 release mode in building doc (#4819) 2018-07-16 12:56:14 -07:00
Damien Pontifex
72b05bc865 Convert net/FlatBuffers project to be compatible with netstandard (#4811) 2018-07-16 09:13:36 -07:00
Brian Atkinson
b3e4d9169b [Go] Force a single, early bounds check on read and write paths.
As an example, GetInt64 used to perform 8 bounds checks, one for each
slice access. By performing a bound check on the highest index, the
number of checks is reduced to one through bounds-check-elimination.
2018-07-15 16:49:21 -07:00
Brian Atkinson
e2eb6af3e3 [Go] Unroll WriteUint64 and WriteInt64.
This enables both WriteUint64 and WriteInt64 to both be inlined as
well as implemented with a single assembly instruction. The current Go
compiler refuses to inline functions with for loops. The compiler is
also not smart enough to produce a single assembly instruction for the
for-loop.
2018-07-15 16:47:17 -07:00
Wouter van Oortmerssen
b188fde27e Fixed Uint() method actually storing a signed int.
Also fixed two constructors missing explicit.

Change-Id: I147b2d2517bb660d92d4b0167992c115ed65dca7
2018-07-06 12:30:43 -07:00
Derek Bailey
ba5eb3b5cf Lua (5.3) Language addition (#4804)
* starting Lua port of python implmention. Syncing commit

* Bulk of Lua module port from Python done. Not tested, only static analysis. Need to work on binary strings. Started work on flatc lua code generation

* Fixed all the basic errors to produced a binary output from the builder, don't know if it is generated correctly, but it contains data, so that must be good

* fixed binary set command that was extending the array improperly

* continued improvement

* Moved lua submodules down a directory so their names don't clash with potential other modules. Added compat module to provide Lua versioning logic

* Successful sample port from Python

* working on testing Lua code with formal tests

* continued to work on tests and fixes to code to make tests pass

* Added reading buffer test

* Changed binaryarray implmentation to use a temporary table for storing data, and then serialize it to a string when requested. This double the rate of building flatbuffers compared to the string approach.

* Didn't need encode module as it just added another layer of indirection that isn't need

* profiled reading buffers, optimizations to increase read performance of monster data to ~7 monster / millisecond

* Writing profiler improvments. Get about
~2 monsters/millisecond building rate

* removed Numpy generation from Lua (came from the Python port)

* math.pow is deprecated in Lua 5.3, so changed to ^ notation. Also added .bat script for starting Lua tests

* adding results of generate_code.bat

* simple edits for code review in PR.

* There was a buffer overflow in inserting the keywords into the unorder set for both the Lua and Python code gens. Changed insertion to use iterators.

* fixed spacing issue

* basic documenation/tutorial updates. Updated sample_binary.lua to reflect the tutorial better

* removed windows-specific build step in Lua tests
2018-07-05 15:55:57 -07:00
Vladimir Glavnyy
8ea293b988 Issue #4799 fixed. Generator for KeyCompareWithValue is extracted. (#4802)
* Issue #4799 fixed. Generator for KeyCompareWithValue is extracted.

* format fix
2018-07-05 09:23:40 -07:00
Woody Guo
f19803d364 Dart: Add missing imports (#4803) 2018-07-03 08:44:27 -07:00
shassani
b2d69aacf4 Helper function to get empty string on nullptr (#4800)
Adds helper function to get empty string when String is nullptr.

This is to get over the fact that flat buffer builders will record null when data
is not present.
2018-07-02 09:34:18 -07:00
Woody Guo
3331805a1c Dart: Fix default values (#4795) 2018-06-28 10:12:18 -07:00
Kapil Sharma
ea06768ad1 Go GRPC generator Updates - Fixes #4787 (#4797)
* Fix for #4787

- Updated the grpc generator for go to use full namespace for service
rpc method names

* Formatting Fix

- Set to Google Style Formatting
2018-06-27 09:57:40 -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
Wouter van Oortmerssen
e9912e9298 Added setup.cfg to default to python 2/3 wheels for pypi.
Change-Id: I64cf42aca79c32d21cd15c1415125ba97665d134
2018-06-25 15:08:06 -07:00
Polynomdivision
7dbc8f564a docs: fix flatc instructions (#4794) 2018-06-25 14:55:18 -07:00
Wouter van Oortmerssen
a2fe49b498 Fixed documentation comments at the start of a file.
Change-Id: Ic24018a6cd604c71b4d8d3cd35dc7a583fb18394
2018-06-25 14:02:12 -07:00
Wouter van Oortmerssen
7dd5cfb510 Fixed empty structs generating bad constructor.
This was fixed previously here:
5fd0fefab6
but somehow got undone in intermediate refactors.

Change-Id: I86e45a3f96f67a2b3d84d44081403baef6798921
2018-06-25 12:28:01 -07:00
Shivendra Agarwal
00b741e5fb Comment update for ForceDefaults. (#4788)
Current comment is a bit ambiguous. Default values can be read either if field is not written (like in table), or if they are written explicitly by client but not serialized due to optimization. Impression from current comment is that all the default values which are coming during read are from binaries when we turn-on Force-Defaults. However, that will be a wrong interpretation.

Force_Defaults = true ensures to turn OFF later optimization. In case a field is not written, during read we will get default values but they will still not be serialized.
2018-06-21 08:50:36 -07:00
Shivendra Agarwal
bb321fbe19 CreateUnitializedVectorOfStructs and tests (#4781)
* CreateUnitializedVectorOfStructs and tests

* Incorporating review comments

* snake_case variable names
2018-06-18 10:12:26 -07:00
Wouter van Oortmerssen
7330436713 Protected parser against infinite recursion.
Will error-out after e.g. 64 levels of nested JSON tables.

Change-Id: I3ab66cdd509378bfab87b85f85c07ab42aded788
Tested: on Linux.
2018-06-14 16:17:19 -07:00
Wouter van Oortmerssen
f9c64891dd Fixed ASan array out of bounds.
Change-Id: I53366bd14548aa41c3d25bcd187d7436d47e8665
Tested: on Linux.
2018-06-14 15:13:01 -07:00
zejal
b752e4a9bb Fix misaligned nested buffers (#4785) 2018-06-14 09:21:42 -07:00
Kamil Rojewski
3e3c770c4e Fixed TypeScript links in docs (#4783)
* Eclipse ignore

* TypeScript support

* Prefixing enums

* Test results

* Merged JS and TS generators

* Fixed AppVeyor build problems

* Fixed more AppVeyor build problems

* Fixed more AppVeyor build problems

* Changed TS flag to options struct

* Storing options by value

* Removed unneeded const

* Re-export support for unions

* Uint support

* Casting bools to numbers for mutation

* TS shell tests

* Reverted generates js test file to original version

* Backing up js tests and properly generating test data

* Not importing flatbuffers for TS test generation

* Not overwriting generated js for tests

* AppVeyor test fixes

* Generating the most strict TS code possible

* Not returning null when creating vectors

* Not returning null from struct contructors

* Vector of unions for ts/js

* Sanity check for languages

* Indentation fix + output test files

* Vectors of unions for php

* Fixes to union vector handling + tests

* Fix for strictPropertyInitialization

* Fix for new aligned operator new for gcc >= 7.1

* Not generating imports/ns prefixes with --gen-all

* TypeScript docs

* Missing imports of enums

* Missing TS links

* Enabled vector of unions for java, since it seems to work

* Added jitpack config

* Added obj to vector of unions getter

* Removed unneeded accessor

* Bumped jdk version in pom.xml

* Vector of unions support for c#

* Missing TypeScript doc processing
2018-06-12 11:37:10 -07:00
Woody Guo
5a3f18d17d Dart: Generate the enum from 0 if value is null and fix inconsistent naming when generating object builder (#4782)
* Dart: Generate the enum from 0 if value is null

* Dart: Fix inconsistent naming when generating object builder
2018-06-12 11:35:40 -07:00
Wouter van Oortmerssen
10bdcefa4a Re-enable clang / os x in .travis
Change-Id: I45f6326f1b7da2d83eeee72fe44fd9626a288b5b
2018-06-08 11:20:57 -07:00
Wouter van Oortmerssen
9bab626cbf Removed biicode from repo.
Change-Id: I8b517fb8eaf02772052d95ca55bdaa0efbffa65a
2018-06-08 11:03:34 -07:00
Wouter van Oortmerssen
effb608027 Added missing Dart generated files.
Change-Id: I27986e8aaf2f672145af9beae6ab659b272c9721
2018-06-08 10:59:46 -07:00
Michael Seifert
a96f2bd6ca Python: Escape enum member names if they correspond to a Python keyword (#4772)
* Python: Generated enum member names are now escaped if they correspond to a Python keyword.

* Keyword list in Python generator is now a const char* instead of an std::string array.

* Moved static functions and keyword list of Python generator into the PythonGenerator class.

* Python generator escapes keyword identifiers in all definitions.
2018-06-08 10:55:19 -07:00
Tin Tvrtković
ab3b721a54 Python: fix default bool value. (#4773)
* Python: fix default bool value.

* Small style tweak.
2018-06-07 12:02:35 -07:00
Wouter van Oortmerssen
4cfe36ae8e Enforcing CreateUninitializedVector is only used with scalars.
This function cannot work with any offset types (since offsets
must always point forward) so this avoid possible mistakes.

Change-Id: I1b3dfbefc8d40da630345b9b04f9aff4a990e8e5
2018-06-07 08:49:38 -07:00
Vladimir Glavnyy
c7a797b966 Makes VectorIterator compatible with STL iterators. (#4768) 2018-06-04 12:02:08 -07:00
Vladimir Glavnyy
ecc07e7793 Fix a small problem with add_subdirectory(${FLATBUFFERS_DIR}) from top level project. (#4764) 2018-06-01 08:22:17 -07:00
Christian Helmich
43944a0ab1 renamed flexbuffers::Type enum values TYPE_ -> FBT_ (#4761)
reason: TYPE_BOOL is a macro defined in some iOS build configurations.
2018-05-31 11:06:44 -07:00
Wouter van Oortmerssen
27ce09860a Fixed typo in Java/C# tutorial.
Change-Id: I956b27f37b11988e67d0403a596c0569eacbfc2a
2018-05-31 09:53:47 -07:00
Wouter van Oortmerssen
3a2f6d5300 Fixed ASAN false positive.
Change-Id: I79d9b2cddc61df5919bc4a93627fba2aa69e5d49
Tested: on Linux.
2018-05-31 09:49:05 -07:00
Steve Barman
06d3229dc3 adds https to landing page link so it resolves (#4757) 2018-05-31 09:37:51 -07:00
Gautham B A
348fcb5b88 Fix typo in tutorial for Go (#4756)
Fixed a typo in serialising the inventory for Orc.
2018-05-31 09:17:34 -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
Wouter van Oortmerssen
0848f58cdd Changed how the default allocator is handled.
This is to not need static variables, which could trip up users
with destruction order problems.

This potentially makes these operations slightly slower, but I
think they're infrequent enough that this should not be noticable.

Also there is one breaking API change, for a method that is not
used by any code in FlatBuffers and is assumed to affect very
few if any users. A namechange and comment ensures that those
affected, if any, will not run into trouble silently.

Change-Id: I16c1352d1dfc9092c816ddb7e353ed7f5f417444
Tested: on Linux.
2018-05-18 14:48:59 -07:00
Vitaly Bondar
8e42f44807 Fix of namespace problem described in #4747 (#4752) 2018-05-18 12:21:08 -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
joligarson
c43a0beff0 Fix undertermined execution behavior (#4751)
Fix for the issue #4744: Ambiguous side-effect execution on vector_downward::make_space() method.
C++ does not impose evaluation order on the two expressions on the right side of the assignment, so compiler can freely decide. As ensure_space() method can change the value of "cur_" variable, the result of the subtraction may be different depending on the evaluation order, which is ambiguous in C++.
In order to make this code deterministic and correct, cur_ must be evaluated after ensure_space() is called.
2018-05-18 09:15:20 -07:00
Tin Tvrtković
a9640bd9e1 [BREAKING CHANGE] Python: handle bool table fields properly. (#4736)
* Python: handle bool table fields properly.

* Small refactor.

* Use snake_case instead of camelCase. Use auto.
2018-05-14 13:30:10 -07:00
Kamil Rojewski
f11ffedb2b Vector of unions support for java and c# (#4735)
* Eclipse ignore

* TypeScript support

* Prefixing enums

* Test results

* Merged JS and TS generators

* Fixed AppVeyor build problems

* Fixed more AppVeyor build problems

* Fixed more AppVeyor build problems

* Changed TS flag to options struct

* Storing options by value

* Removed unneeded const

* Re-export support for unions

* Uint support

* Casting bools to numbers for mutation

* TS shell tests

* Reverted generates js test file to original version

* Backing up js tests and properly generating test data

* Not importing flatbuffers for TS test generation

* Not overwriting generated js for tests

* AppVeyor test fixes

* Generating the most strict TS code possible

* Not returning null when creating vectors

* Not returning null from struct contructors

* Vector of unions for ts/js

* Sanity check for languages

* Indentation fix + output test files

* Vectors of unions for php

* Fixes to union vector handling + tests

* Fix for strictPropertyInitialization

* Fix for new aligned operator new for gcc >= 7.1

* Not generating imports/ns prefixes with --gen-all

* TypeScript docs

* Missing imports of enums

* Missing TS links

* Enabled vector of unions for java, since it seems to work

* Added jitpack config

* Added obj to vector of unions getter

* Removed unneeded accessor

* Bumped jdk version in pom.xml

* Vector of unions support for c#
2018-05-14 11:12:24 -07:00
Keef Aragon
5d42c8352e Set Working Directory for flatc commands (#4737) 2018-05-14 09:20:49 -07:00
Paul Reimer
7c1203d44c Add define/ifdef blocks, alternate sprintf implementation via FLATBUFFERS_PREFER_PRINTF [C++] (#4700)
* Add define/ifdef blocks for FLATBUFFERS_PREFER_PRINTF to avoid using std::*streams for idl_parser

* Use string::size() as limit in snprintf

* Refactored FLATBUFFERS_PREFER_PRINTF guarded feature into NumToStringImplWrapper around sprintf

* Remove '.0' where not needed from IntToDigitCount

* Remove leading dot from name in GetFullyQualifiedName when FLATBUFFERS_PREFER_PRINTF is enabled

* Return string directly from conversion functions where possible when FLATBUFFERS_PREFER_PRINTF is enabled

* Use string instead of stringstream for GetFullyQualifiedName

* Revert removing leading dot from GetFullyQualifiedName, it does need to be there for parity with the stringstream implementation

* Dot is single char in Namespace::GetFullyQualifiedName

* Remove trailing (duplicate) null-byte from NumToStringImplWrapper when using FLATBUFFERS_PREFER_PRINTF.

* Update preprocessor indenting (and use clang-format off/on) for FLATBUFFERS_PREFER_PRINTF

* Reduce whitespace, unneeded braces in FLATBUFFERS_PREFER_PRINTF string width functions

* Remove unneeded use of iostream from idl_parser.cpp, std::string is used instead

* Tell snprintf to use the trailing null byte expected at the end of std::string buffer
2018-05-10 13:31:02 -07:00
Paul Reimer
a0a33d94a7 Add string view [C++] (#4730)
* Add view() method on flatbuffers::String, to return a string_view type
if support for std::string_view (or alternately
std::experimental::string_view) is found

* Move detection/definition of FLATBUFFERS_STRING_VIEW to base.h, use the
macro (if it is defined) as the argument type for an overload of CreateString

* Rename String::view() to String::string_view() and use the existing c_str() method for the data pointer

* Add and explain minimum C++ standard version checks for FLATBUFFERS_STRING_VIEW implementations

* Updated preprocessor indenting for FLATBUFFERS_STRING_VIEW

* Convert FLATBUFFERS_STRING_VIEW macro to typedef in flatbuffers:: namespace, and boolean feature toggle macro FLATBUFFERS_HAS_STRING_VIEW

* Prepend flatbuffers:: namespace to disambiguate flatbuffers::string_view typedef from String::string_view()

* clang-format as-she-is-spoke for FLATBUFFERS_HAS_STRING_VIEW
2018-05-10 13:30:35 -07:00
Tin Tvrtković
b10123ff63 Python: return None for missing strings. (#4733)
[BREAKING CHANGE] Python: return None for missing strings.
2018-05-10 10:34:20 -07:00
Mike Mansell
3a2c535592 Remove @Nullable (Java) for required fields (fixes #4724) (#4726)
@Nullable is only a compiler informational attribute.
Removing for required fields improves compiler warnings
but doesn't impact any running code.
2018-05-10 09:27:23 -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
Wouter van Oortmerssen
d215852f52 Several pom.xml files did not have their version bumped to 1.9.0
Change-Id: I7c9bb5406ae8df951afe12a008f0d071e0195bfa
2018-05-07 08:46:34 -07:00
Vladimir Glavnyy
12c4c2238c Output JSON strings as natural UTF-8 text without escapes (#4710)
* Added support for the non-escaped print of utf-8 string.

* EscapeString: the first invalid symbol resets print_natural_utf8 flag to false.

* Move the test to ParseAndGenerateTextTest. Fixes.

* Removed dependence between `natural_utf8` and `allow_non_utf8` flags.
2018-05-03 12:10:45 -07:00
iceboy
85faa46fb3 Fix union escaping order. (#4722)
* Fix union escaping order.

Fixes #4712

* style
2018-05-03 11:59:30 -07:00
iceboy
cc354ea368 Delete ByteBuffer.exe (#4721) 2018-05-03 11:58:29 -07:00
husobee
bed19a5340 Addition of Go FinishWithFileIdentifier (#4720)
* Addition of Go FinishWithFileIdentifier, allows for Go flatbuffer data to contain a file identifier

* adding panic as per review if fileIdentifier does not match length, letting prep pad the file identifier

* updated error message to not use fmt.Sprintf

* using minalign for alignment for file identifier
2018-04-30 14:37:24 -07:00
Tobias Oberstein
9bb88a026a Include services in reflection data (fixes #4639) (#4713)
* include service in reflection data (fixes #4639)

* changes from review

* regenerated test data
2018-04-27 13:31:18 -07:00
Mark Henderson
34cb163e38 Adding JS function to get the File Identifier (#4715)
* Adding JS  function to get the File Identifier

* Update flatbuffers.js
2018-04-23 12:54:20 -07:00
Vladimir Glavnyy
a66f9e769b The asserts replaced by FLATBUFFERS_ASSERT. (#4701)
* The asserts replaced by FLATBUFFERS_ASSERT. Several asserts have converted to static_asserts.

* Regenerate header monster generate_code.sh
2018-04-16 08:57:59 -07:00
Sergey Avseyev
86153fd740 Remove unnecessary const qualifier (#4698)
In file included from include/flatbuffers/flexbuffers.h:24,
                 from src/idl_gen_text.cpp:20:
include/flatbuffers/util.h: In function 'int flatbuffers::FromUTF8(const char**)':
include/flatbuffers/util.h:324:45: error: type qualifiers ignored on cast result type [-Werror=ignored-qualifiers]
   if ((static_cast<const unsigned char>(**in) << len) & 0x80) return -1;  // Bit after leading 1's must be 0.
                                             ^
cc1plus: all warnings being treated as errors
make[2]: *** [CMakeFiles/flatbuffers_shared.dir/build.make:92: CMakeFiles/flatbuffers_shared.dir/src/idl_gen_text.cpp.o] Error 1
2018-04-06 11:33:07 -07:00
Vladimir Glavnyy
7eb4c6098e An user-defined attribute name validation (#4689)
* User-declared attribute should be either identifier or string with the identifier.

* Attribute can be identifier or string in metadata.
2018-04-06 09:07:59 -07:00
Paul Reimer
af3c598189 Rename MANUALLY_ALIGNED_STRUCT to add FLATBUFFERS_ prefix in generated code within tests/. Via running cd tests && sh generate_code.sh (#4696) 2018-04-05 16:36:42 -07:00
Paul Reimer
eac0bc6490 Add FLATBUFFERS_ prefix to defines [C++] (#4695)
* Rename STRUCT_END to add FLATBUFFERS_ prefix, now FLATBUFFERS_STRUCT_END. Via running `ag -l STRUCT_END | xargs rpl STRUCT_END FLATBUFFERS_STRUCT_END`

* Rename MANUALLY_ALIGNED_STRUCT to add FLATBUFFERS_ prefix, now FLATBUFFERS_MANUALLY_ALIGNED_STRUCT. Via running `ag -l MANUALLY_ALIGNED_STRUCT | xargs rpl MANUALLY_ALIGNED_STRUCT FLATBUFFERS_MANUALLY_ALIGNED_STRUCT && cd tests && sh generate_code.sh`

* Rename DEFINE_BITMASK_OPERATORS to add FLATBUFFERS_ prefix, now FLATBUFFERS_DEFINE_BITMASK_OPERATORS. Via running `ag -l DEFINE_BITMASK_OPERATORS | xargs rpl DEFINE_BITMASK_OPERATORS FLATBUFFERS_DEFINE_BITMASK_OPERATORS`
2018-04-05 16:00:54 -07:00
Wouter van Oortmerssen
20a400e940 Update version number to 1.9
Change-Id: I0b0ed43129c4d8fc88a177792df50adfeb52a1e3
2018-04-05 15:11:52 -07:00
Wouter van Oortmerssen
676f0248aa Added missing generated code files.
Change-Id: I59af6ca1825870461c0badc7e7a045b97befdc1a
2018-04-05 15:01:35 -07:00
Kamil Rojewski
34b8b80f15 Missing TS links in docs (#4693)
* Eclipse ignore

* TypeScript support

* Prefixing enums

* Test results

* Merged JS and TS generators

* Fixed AppVeyor build problems

* Fixed more AppVeyor build problems

* Fixed more AppVeyor build problems

* Changed TS flag to options struct

* Storing options by value

* Removed unneeded const

* Re-export support for unions

* Uint support

* Casting bools to numbers for mutation

* TS shell tests

* Reverted generates js test file to original version

* Backing up js tests and properly generating test data

* Not importing flatbuffers for TS test generation

* Not overwriting generated js for tests

* AppVeyor test fixes

* Generating the most strict TS code possible

* Not returning null when creating vectors

* Not returning null from struct contructors

* Vector of unions for ts/js

* Sanity check for languages

* Indentation fix + output test files

* Vectors of unions for php

* Fixes to union vector handling + tests

* Fix for strictPropertyInitialization

* Fix for new aligned operator new for gcc >= 7.1

* Not generating imports/ns prefixes with --gen-all

* TypeScript docs

* Missing imports of enums

* Missing TS links
2018-04-05 09:54:37 -07:00
Juyeon Yoon
0998861e0f Remove line break of CMakeLists.txt (#4691)
Fix #4650
2018-04-05 09:17:33 -07:00
David Stephan
2e3d3cbcb5 Fix typos in C++ tutorial (#4685)
CreateMonster and MonsterBuilder examples fixed for C++
2018-04-02 09:25:05 -07:00
Kamil Rojewski
d3a00f7730 Fix for missing enum imports (#4683)
* Eclipse ignore

* TypeScript support

* Prefixing enums

* Test results

* Merged JS and TS generators

* Fixed AppVeyor build problems

* Fixed more AppVeyor build problems

* Fixed more AppVeyor build problems

* Changed TS flag to options struct

* Storing options by value

* Removed unneeded const

* Re-export support for unions

* Uint support

* Casting bools to numbers for mutation

* TS shell tests

* Reverted generates js test file to original version

* Backing up js tests and properly generating test data

* Not importing flatbuffers for TS test generation

* Not overwriting generated js for tests

* AppVeyor test fixes

* Generating the most strict TS code possible

* Not returning null when creating vectors

* Not returning null from struct contructors

* Vector of unions for ts/js

* Sanity check for languages

* Indentation fix + output test files

* Vectors of unions for php

* Fixes to union vector handling + tests

* Fix for strictPropertyInitialization

* Fix for new aligned operator new for gcc >= 7.1

* Not generating imports/ns prefixes with --gen-all

* TypeScript docs

* Missing imports of enums
2018-03-26 10:29:45 -07:00
Kamil Rojewski
cc54963830 TypeScript docs (#4680)
* Eclipse ignore

* TypeScript support

* Prefixing enums

* Test results

* Merged JS and TS generators

* Fixed AppVeyor build problems

* Fixed more AppVeyor build problems

* Fixed more AppVeyor build problems

* Changed TS flag to options struct

* Storing options by value

* Removed unneeded const

* Re-export support for unions

* Uint support

* Casting bools to numbers for mutation

* TS shell tests

* Reverted generates js test file to original version

* Backing up js tests and properly generating test data

* Not importing flatbuffers for TS test generation

* Not overwriting generated js for tests

* AppVeyor test fixes

* Generating the most strict TS code possible

* Not returning null when creating vectors

* Not returning null from struct contructors

* Vector of unions for ts/js

* Sanity check for languages

* Indentation fix + output test files

* Vectors of unions for php

* Fixes to union vector handling + tests

* Fix for strictPropertyInitialization

* Fix for new aligned operator new for gcc >= 7.1

* Not generating imports/ns prefixes with --gen-all

* TypeScript docs
2018-03-23 09:01:39 -07:00
Flaviu
79f62ee353 Const correctness in generated code and in code generators. Added missing \reflection\generate_code.bat file. (#4679) 2018-03-23 08:58:07 -07:00
Andreas Bergmeier
c0a6e5120d [C++, Go, Bazel]: Fix up Bazel support (#4672)
* Add Bazel support for Go library

* Make flatc compile again.

Was missing java_generator, which is now referenced from source.
2018-03-15 12:31:16 -07:00
Robert Schmidtke
08cf50c54a Java/C#/Python prefixed size support (#4445)
* initial changes to support size prefixed buffers in Java

* add slice equivalent to CSharp ByteBuffer

* resolve TODO for slicing in CSharp code generation

* add newly generated Java and CSharp test sources

* fix typo in comment

* add FinishSizePrefixed methods to CSharp FlatBufferBuilder as well

* add option to allow writing the prefix as well

* generate size-prefixed monster binary as well

* extend JavaTest to test the size prefixed binary as well

* use constants for size prefix length

* fuse common code for getRootAs and getSizePrefixedRootAs

* pulled file identifier out of if

* add FinishSizePrefixed, GetSizePrefixedRootAs support for Python

* Revert "extend JavaTest to test the size prefixed binary as well"

This reverts commit 68be4420dd.

* Revert "generate size-prefixed monster binary as well"

This reverts commit 2939516fdf.

* fix ByteBuffer.cs Slice() method; add proper CSharp and Java tests

* fix unused parameter

* increment version number

* pulled out generated methods into separate utility class

* pulled out generated methods into separate utility class for Python

* fix indentation

* remove unnecessary comment

* fix newline and copyright

* add ByteBufferUtil to csproj compilation

* hide ByteBuffer's internal data; track offset into parent's array

* test unsafe versions as well; compile and run in debug mode

* clarify help text for size prefix

* move ByteBuffer slicing behavior to subclass

* fix protection levels

* add size prefix support for text generation

* add ByteBufferSlice to csproj compilation

* revert size prefix handling for nested buffers

* use duplicate instead of slice for removing size prefix

* remove slice subclass and use duplicate for removing size prefix

* remove slice specific tests

* remove superfluous command line option
2018-03-12 11:30:46 -07:00
Sergey Avseyev
6b3f057bdc Remove unnecessary const qualifier from cast (#4666)
Const does not make sense here, and compiler actually throws warning
(error with -Werror) when you would try to compile it.

    In file included from include/flatbuffers/flexbuffers.h:24,
                     from include/flatbuffers/idl.h:26,
                     from include/flatbuffers/code_generators.h:22,
                     from src/code_generators.cpp:17:
    include/flatbuffers/util.h: In function ‘int flatbuffers::FromUTF8(const char**)’:
    include/flatbuffers/util.h:325:44: error: type qualifiers ignored on cast result type [-Werror=ignored-qualifiers]
       if ((static_cast<const unsigned char>(tmp) << len) & 0x80) return -1;  // Bit after leading 1's must be 0.
                                            ^
    cc1plus: all warnings being treated as errors

This warning caught by gcc8:

    $ g++ --version
    g++ (GCC) 8.0.1 20180222 (Red Hat 8.0.1-0.16)
2018-03-12 08:22:17 -07:00
ianXian
60de374486 Convert to unsigned char before applying bit shift operator (#4664)
* Convert to unsigned char before applying bit shift operator

* convert to const unsigned char inline

* convert to unsigned char inline
2018-03-09 09:45:47 -08:00
desqaz
e78825e7a0 Json : Add --size-prefixed option to flatc (#4645)
to be able to convert to json size prefixed buffers.
2018-03-09 08:21:28 -08:00
Montoli
cc158e7009 Swapped the order of two conditions in an assert. (#4663)
An assert in flexbuffers was bit-shifting a 64-bit number by
64 bits, which throws up warnings in some automated tools.

The same assert also checks to see if the number of bytes
being shifted is 8.  Swapped the order, so that the bitshift
only occurs if the number of bits being shifted is not 64.

Should be the same behavior, but plays nicer with diagnostic
tools.
2018-03-08 14:18:41 -08:00
desqaz
5377957b14 Update .gitignore with Ninja stuff (#4659) 2018-03-08 10:36:27 -08:00
Wouter van Oortmerssen
4bc6de9a88 Fix broken Java/C# codegen 2018-03-05 16:37:04 -08:00
Wouter van Oortmerssen
3a62813f0e Added missing generated code files.
Change-Id: Ie1cab284cb6e0fe5bd2b2c293c3136c148927ac3
2018-03-05 15:47:16 -08:00
Nik Hemmings
fb94af8899 Protobufs: Added '--oneof-union' option. (#4647)
* Added '--oneof-union' option.

Used with the .proto -> .fbs converter, will translate protobuff oneofs to flatbuffer unions.
Updated proto test to check both methods of converting oneofs.

* Added '--oneof-union' option.

Used with the .proto -> .fbs converter, will translate protobuff oneofs to flatbuffer unions.
Updated proto test to check both methods of converting oneofs.

* FlatBuffers: Moved MakeCamel() into idl_parser.cpp

Removes library dependency on Java/C# generator code.
2018-03-05 08:45:25 -08:00
smillius
77b458bee5 Make nested flatbuffer lookup consistent. (#4656)
Lookup type of nested flatbuffer field with either raw name or fully qualified name as already done in the parser.
LookupCreateStruct tries both the raw name and the fully qualified one.
Without this, we cannot reference types outside of the current namespace, e.g. in a different module.
2018-03-05 08:44:14 -08:00
Christian Helmich
9ce98dd77d Support attribute "cpp_ptr_type" on table elements marked as "hash" (#4643)
* added intended use-cases to monster_test.fbs

* added check for `cpp_ptr_type` on hashed fields
added default value 'naked' to `cpp_ptr_type` on hashed fields

* added C++ generation of cpp_type vectors
removed ctor call for vector fields
added condition !vector for cpp_type check
added Pack() and UnPack() code generation for vector of hashes
added generation of correct resolve/rehash for cpp_type elements

* added attribute 'cpp_ptr_type_get' to hold accessor for pointer types possible where '.get()' does not work
use case: cpp_ptr_type:"std::weak_ptr", cpp_ptr_type_get:".lock().get()"

* run flatc to re-generate headers

* added bool param is_ctor to GetDefaultScalarValue() to differentiate between usage places

* modified monster_test.fbs to remove usage of shared_ptr/weak_ptr
reason: STLport does not support std::shared_ptr and std::weak_ptr

* run flatc again to re-generate headers

* fixed symbol unique_ptr not in namespace std when building with STLport
2018-03-05 08:40:55 -08:00
Mitchel
4ea1be53d4 Java + C#, reuse object in lookup_by_key (#4648)
* Java + C#, reuse object in lookup_by_key

* Java + C#, reuse object in lookup_by_key
2018-03-02 15:22:46 -08:00
Mitchel
0068b25132 Fix for Java infinite loop encoding into 0-sized buffer (#4654) 2018-03-02 15:21:08 -08:00
Christian Helmich
ec74f58b94 made HashFnv functions constexpr (#4640)
* added FLATBUFFERS_CONSTEXPR_CPP14 define for C++14 and above constexpr

* made HashFnv functions constexpr (depending on FLATBUFFERS_CONSTEXPR)
2018-03-02 09:13:55 -08:00
Kamil Rojewski
48d8232584 Not generating imports/ns prefixes with --gen-all (#4644)
* Eclipse ignore

* TypeScript support

* Prefixing enums

* Test results

* Merged JS and TS generators

* Fixed AppVeyor build problems

* Fixed more AppVeyor build problems

* Fixed more AppVeyor build problems

* Changed TS flag to options struct

* Storing options by value

* Removed unneeded const

* Re-export support for unions

* Uint support

* Casting bools to numbers for mutation

* TS shell tests

* Reverted generates js test file to original version

* Backing up js tests and properly generating test data

* Not importing flatbuffers for TS test generation

* Not overwriting generated js for tests

* AppVeyor test fixes

* Generating the most strict TS code possible

* Not returning null when creating vectors

* Not returning null from struct contructors

* Vector of unions for ts/js

* Sanity check for languages

* Indentation fix + output test files

* Vectors of unions for php

* Fixes to union vector handling + tests

* Fix for strictPropertyInitialization

* Fix for new aligned operator new for gcc >= 7.1

* Not generating imports/ns prefixes with --gen-all
2018-02-26 08:56:04 -08:00
Mitchel
55ddb84eb2 In Java, allow reusing ByteBuffer in getters (#4633)
* In Java, allow reusing ByteBuffer in getters

* In Java, allow reusing ByteBuffer in getters

* In Java, allow reusing ByteBuffer in getters
2018-02-23 14:01:05 -08:00
Christian Helmich
6e2e909b5c template specialized Hash functions for 16-bit hash types (#4631)
added access to HashFunction for 16 bit
2018-02-23 10:29:37 -08:00
Philip S Doctor
b24c0b07a3 When Java raises a CharacterCodingException, the catch block rethrows this exception as a java.lang.Error. Per the docs https://docs.oracle.com/javase/8/docs/api/java/lang/Error.html an Error is a serious problem that applications should not attempt to catch such as ThreadDeath. In this case, it is reasonable for a consumer to try to catch this error as it likely indicates a problem with the underlying data. (#4630)
As Error does not inherit from Exception, a generic `catch(Exception ex)` will not catch this error.

A simple change from `Error` to `Exception` is not sufficient as an `Exception` is checked by the compiler, so in order to keep this issue unchecked, I am proposing raising a `RuntimeException` which is not checked, but is still a subclass of `Exception`.

The only possible breaking change would be if a consumer was explicitly catching `Error` already for this library.

https://github.com/google/flatbuffers/issues/4629
2018-02-22 14:54:35 -08:00
Christian Helmich
59e26017cb added support for parsing hash on vector elements (#4502)
* added support for parsing hash on vector elements

reversed check for scalar to check for vector

added C++ generation of cpp_type vectors

removed ctor call for vector fields
added condition !vector for cpp_type check

added Pack() and UnPack() code generation for vector of hashes

* schema change:
added table Referrable and weak references towards it from Monster

added single_weak_reference to Monster table
changed order with vector_of_weak_references

* re-generated monster schema dependent code

added Referrable.cs to FlatBuffers.Test.csproj
2018-02-22 11:04:26 -08:00
desqaz
132e6a8220 Add new c++ helpers to ease usage of size prefixed FlatBuffers (#4626)
It was missing some helpers when we choose to use
size prefixed FlatBuffers.

* Add general helper : GetPrefixedSize
* Add generated helpers :
 * GetSizePrefixedXXX
 * VerfifySizePrefixedXXXBuffer
 * FinishSizePrefixedXXXBuffer
2018-02-22 09:19:08 -08:00
Masato Nagai
19c81b11b3 [C++] better type mismatch error (#4623)
* better parse error

* pass str as a pointer instead of a reference for more efficient performance
2018-02-16 08:32:50 -08:00
Alexander Gallego
36f8564846 C++: mini_reflect: Add DefaultTypeTable (#4614)
* mini_reflect: Add DefaultTypeTable

Currently it's very easy to make a mistake when it comes to
instantiating the TypeTable to print a buffer because it is not type
safe.

This will allow us to write safer cpp code:

flatbuffers::FlatBufferToString(reinterpret_cast<const uint8_t *>(&t),
                                decltype(t)::DefaultTypeTable());

* c++: mini_reflect: update generated code

* Ensure types and names are set for mini_reflect

* c++: mini_refelct: update unit tests with new typed TypeTable

* Adding PR feedback of sylte and naming convention
2018-02-15 14:58:06 -08:00
Dmitry Volosnykh
daf0a420be Support version compatibility checks via find_package command (#4625) 2018-02-15 13:39:15 -08:00
Kamil Rojewski
474ba68bba Fix for aligned new for gcc >= 7.1 (#4621)
* Eclipse ignore

* TypeScript support

* Prefixing enums

* Test results

* Merged JS and TS generators

* Fixed AppVeyor build problems

* Fixed more AppVeyor build problems

* Fixed more AppVeyor build problems

* Changed TS flag to options struct

* Storing options by value

* Removed unneeded const

* Re-export support for unions

* Uint support

* Casting bools to numbers for mutation

* TS shell tests

* Reverted generates js test file to original version

* Backing up js tests and properly generating test data

* Not importing flatbuffers for TS test generation

* Not overwriting generated js for tests

* AppVeyor test fixes

* Generating the most strict TS code possible

* Not returning null when creating vectors

* Not returning null from struct contructors

* Vector of unions for ts/js

* Sanity check for languages

* Indentation fix + output test files

* Vectors of unions for php

* Fixes to union vector handling + tests

* Fix for strictPropertyInitialization

* Fix for new aligned operator new for gcc >= 7.1
2018-02-12 08:37:51 -08:00
vglavnyy
9de0861104 Fix vector_data failure under debug (#4606) 2018-02-08 15:15:17 -08:00
Wouter van Oortmerssen
b513db86c7 Misc fixes from internal integration / clang tidy.
Change-Id: Ic5e8f6a423b426abb9f8b90d39db0f85f28b94be
Tested: on Linux.
2018-02-08 14:58:16 -08:00
Sergey Avseyev
6a1acdc23b Fix compiler errors in parser (#4612)
src/idl_parser.cpp: In member function 'flatbuffers::CheckedError flatbuffers::Parser::ParseHexNum(int, uint64_t*)':
src/idl_parser.cpp:220:62: error: type qualifiers ignored on cast result type [-Werror=ignored-qualifiers]
     if (!isxdigit(static_cast<const unsigned char>(cursor_[i])))
                                                              ^
src/idl_parser.cpp: In member function 'flatbuffers::CheckedError flatbuffers::Parser::Next()':
src/idl_parser.cpp:260:62: error: type qualifiers ignored on cast result type [-Werror=ignored-qualifiers]
         if(!isdigit(static_cast<const unsigned char>(*cursor_))) return NoError();
                                                              ^
cc1plus: all warnings being treated as errors
2018-02-05 12:04:55 -08:00
Joe Schafer
c696422558 Add initial Bazel WORKSPACE and BUILD (#4608)
For #4574.

To test:

    bazel test --verbose_failures //:flatbuffers_test
2018-02-05 10:23:15 -08:00
Wouter van Oortmerssen
e93d2bda07 Cleaned up & fixed buffer alignment handling.
- Fixed ForceVectorAlignment (and possibly other call-sites) not
  setting minalign_.
- Fixed flipped alignment parameters in CopyTable (reflection).
- Made aligment for FlatBufferBuilder internal buffer configurable
  (useful when reading a constructed buffer directly).
- Ensured Alignment rounding is always up.

Change-Id: I33ca4887d92a09cb11a369c14a109f4b07ae707a
Tested: on Linux.
2018-01-29 11:46:30 -08:00
Wouter van Oortmerssen
bbf4dac6a3 Made doubles output with higher precision in JSON and elsewhere.
Change-Id: I5dd8f3a7c315c40b86a67aba5c2cca4d36363523
Tested: on Linux.
2018-01-22 10:24:45 -08:00
Wouter van Oortmerssen
8df2d9a3ef Removed truncating of enum vals to int in ReverseLookup.
Some implementations (e.g. C++98) won't support 64-bit enum values,
but there is no reason to silently truncate them.

Change-Id: I8629563523a96e887068f9c0efcd53741f60e0d6
Tested: on Linux.
2018-01-22 09:51:17 -08:00
Li-Deng
462ce03ebe Fix the spell mistake (#4599) 2018-01-22 09:08:13 -08:00
Wouter van Oortmerssen
020012e69c Fixed native_include not requiring a ; terminator.
Change-Id: Ic4f49e94c67ba23f07e5ba7e87ca94e8db5d5906
Tested: on Linux.
2018-01-22 09:06:13 -08:00
Wouter van Oortmerssen
f431a96523 New error: declaring an enum field without a default in range of the enum.
Change-Id: I4db7f032440c00d31c7434975b8a3f17c29d74b9
Tested: on Linux.
2018-01-18 12:06:01 -08:00
Wouter van Oortmerssen
3694ae0817 Disallow defaults on structs.
Change-Id: Ia098126c92ea6f8abe94561bd9c09b29ac8f61f5
Context: https://github.com/google/flatbuffers/issues/4591
Tested: on Linux.
2018-01-18 11:41:43 -08:00
Wouter van Oortmerssen
2265129e14 Removed date/time from generated code, causing commit polution.
Change-Id: I79724416110a3d2241d7eeecf0e12aa6d5b760a0
2018-01-18 11:21:10 -08:00
Wouter van Oortmerssen
4bddc6cc0c Added missing generated code.
Change-Id: I9420bf01d2bdb6ccfe3703c835297be73457c0d7
2018-01-18 11:20:58 -08:00
vglavnyy
e162366b3f Removed internal variable with name "data" inside a generated method _nested_root(). Local variable with name "data" violates [-Werror=shadow]. (#4587) 2018-01-18 11:15:31 -08:00
Wouter van Oortmerssen
fee9afd80b Use CreateVectorOfStructs when creating a vector of structs.
(mirrored from cl/180944741)

Change-Id: Ib9f1613ccc355528c5c495fd953a9b3944ecb4ce
2018-01-18 11:07:37 -08:00
Daniel Lin
98f681deb0 Author: Daniel Lin <danielin@umich.edi> (#4595)
Date:   Mon Jan 15 11:38:20 2018 -0200

Compilation failure with grpc.h

If cmake run with flag FLATBUFFERS_BUILD_GRPCTEST=ON
compilation fails.

Fix :
	-Fix argument list for overriden function in grpc.
	-Fix member function name called by FlatBufferBuilder from
	buf() to scratch_data()
2018-01-18 08:51:57 -08:00
Wouter van Oortmerssen
5cee340ad3 Cleaned up FlatBufferBuilder clearing.
Change-Id: I81cf4d268670bdd11d1d56ca9f2de78c120df842
Tested: on Linux.
2018-01-16 10:17:20 -08:00
Uilian Ries
f0769b60ab #4522 Conan package support (#4590)
- Added Conan recipe to build Flatbuffers
- Added Travis job to create Conan package

Signed-off-by: Uilian Ries <uilianries@gmail.com>
2018-01-12 08:18:20 -08:00
Wouter van Oortmerssen
79b80f84df Reduced FlatBufferBuilder from 3 buffers to 1
Previously, FlatBufferBuilder used 3 resizable buffers:
- serialization (vector_downward)
- field offsets (std::vector)
- vtable offsets (std::vector)

Since the serialization buffer grows downwards, the bottom part of
it can be used as a "scratchpad" storage for the other two. Since
field offsets are only accumulated during table construction, and
vtable offsets only after table construction, the two can trivially
share the same storage.

Not only does this reduce the amount of allocation, it also removes
the bulk of std::vector usage from FlatBufferBuilder which was
the #1 cause of slow-down in debug mode, see e.g.:
https://stackoverflow.com/questions/36085285/any-way-to-improve-flatbuffer-performance-in-debug-c-msvc

Change-Id: I0224cf2f2a863d2d7ef762bc9163b52fdc149522
Tested: on Linux.
2018-01-11 11:13:23 -08:00
Andrew Gunnerson
dfe68566e4 Add char * overload for FlatBufferBuilder::CreateString() (#4583)
Without this change, the compiler tries to select the following overload
when CreateString is passed a `char *`:

    template<typename T>
    Offset<String> CreateString(const T &str) {
      return CreateString(str.c_str(), str.length());
    }

which is not valid since char pointers don't have methods.

(Fixes #4579)

Signed-off-by: Andrew Gunnerson <chenxiaolong@cxl.epac.to>
2018-01-08 08:26:19 -08:00
brianhall77
0aa36101f4 Portable range check for *cursor_ value. (#4582)
Avoids the following compile error when char is unsigned:

error: comparison of unsigned expression >= 0 is always true [-Werror,-Wtautological-unsigned-zero-compare]
2018-01-04 16:03:03 -08:00
vglavnyy
70f345012d GenerateText generate a text string for default identifier of enum and float scalar. An enum identifier printed as the strictly quoted string. (#4527) 2018-01-04 10:12:18 -08:00
Andrei Polushin
a056402f56 Remove unused declarations (#4578) 2018-01-04 10:01:41 -08:00
Darío Hereñú
d7b1d418ee Update URL (#4576) 2018-01-04 09:10:03 -08:00
Bastien Brunnenstein
9dae3eac60 Fix error in ConCatPathFileName (#4575) 2018-01-04 09:09:09 -08:00
Yuri Finkelstein
99a8a68a80 new maven jar called flatbuffers-java-grpc which contains utility … (#4558)
* new maven jar called flatbuffers-java-grpc which contains utility class supporting generated code for grpc over flatbuffers; grpc java unit test based on maven and junit (maven is used only for simplicity of testing); removed straneous namespace_test/NamespaceA/TableInC.java which is not longer used in the test and no longer generated but contains complilation errors if java compiler picks it up

* moved java grpc tests files according to review request

* Added missing generated code for Java gRPC.

Change-Id: Iada090fe2e99b80a4b7c2f8e39c838a992a1feae

* added missing name and url
2017-12-28 15:26:29 -08:00
Wouter van Oortmerssen
0c86929e39 Added missing nullptr check in vector of union verifiers.
Change-Id: Iec720991e68ad27580537135bfd8eb4159333921
Tested: on Linux.
2017-12-28 10:09:48 -08:00
Wouter van Oortmerssen
b24f2016a1 Disabled python in travis.yml pending fix.
Change-Id: I6d2a9cc8b32c531d4a1e272ddf29974a0a1a2ee3
2017-12-28 09:56:57 -08:00
Josh Ventura
1d73b3b9fc Various build fixes; update checked-in codegen. (#4572) 2017-12-28 09:10:55 -08:00
Yuri Finkelstein
a4dbe13486 fixed java codegen bug documented in #4563 (#4565)
* grpc bindings generator for Java and a few minor supporting changes in improvements

* restored formatting before my previous changes for ease of review

* Fixed grpc java code generation bug resulting in duplicate extractor declarations in case the same is used in more than a single RPC method

* fixed previous merge issue

* removed extra space

* restored extra space

* restored extra space

* fixed java codegen bug documented in https://github.com/google/flatbuffers/issues/4563
2017-12-21 13:32:34 -08:00
Wouter van Oortmerssen
89711c9c47 Made all C++ files clang-formatted.
Also added missing generated files.

Change-Id: Ifd22a643a08e3f2edfce92812ed57b87fc0e1875
2017-12-21 11:45:02 -08:00
Yuri Finkelstein
5d9930aa0d added config files for popular formatting tools (#4554)
* added config files for popular formatting tools

* edited and moved formatting files to root per review suggestion
2017-12-21 10:18:20 -08:00
Yuri Finkelstein
8518b3fb4e grpc bindings generator for Java and a few minor supporting changes i… (#4553)
* grpc bindings generator for Java and a few minor supporting changes in improvements

* restored formatting before my previous changes for ease of review

* Fixed grpc java code generation bug resulting in duplicate extractor declarations in case the same is used in more than a single RPC method
2017-12-21 09:55:57 -08:00
Yuri Finkelstein
61f4a46c43 synchronized grpc cpp_generator with latest version as of today: grpc-1.8.1. (#4556)
* updateed cpp_generator.cc to be compatible with the latest grpc version

* preserved the original license

* synchronized grpc cpp_generator with latest version as of today: GRPC 1.8.1. Regenerated test/monster_test.grpc.fb.* files and verified that grpctest is nicely passing

* fixed merge glitch
2017-12-21 08:49:00 -08:00
Yuri Finkelstein
dd73b53e28 updated cpp_generator.cc to be compatible with the latest grpc version (#4551)
* updateed cpp_generator.cc to be compatible with the latest grpc version

* preserved the original license
2017-12-18 14:17:59 -08:00
xgdgsc
c1901f2c01 update mutation status in doc (#4549) 2017-12-18 09:14:15 -08:00
Robert
4071b6f68b Merge pull request #4516 from mikeholler/travis
Add support for Python lib continuous deployment.
2017-12-14 13:20:18 -08:00
Kamil Rojewski
142401f50a Fix for strictPropertyInitialization for TS (#4540)
* Eclipse ignore

* TypeScript support

* Prefixing enums

* Test results

* Merged JS and TS generators

* Fixed AppVeyor build problems

* Fixed more AppVeyor build problems

* Fixed more AppVeyor build problems

* Changed TS flag to options struct

* Storing options by value

* Removed unneeded const

* Re-export support for unions

* Uint support

* Casting bools to numbers for mutation

* TS shell tests

* Reverted generates js test file to original version

* Backing up js tests and properly generating test data

* Not importing flatbuffers for TS test generation

* Not overwriting generated js for tests

* AppVeyor test fixes

* Generating the most strict TS code possible

* Not returning null when creating vectors

* Not returning null from struct contructors

* Vector of unions for ts/js

* Sanity check for languages

* Indentation fix + output test files

* Vectors of unions for php

* Fixes to union vector handling + tests

* Fix for strictPropertyInitialization
2017-12-14 08:30:02 -08:00
Mike Holler
7799642270 Change mikeholler to PYPI_USERNAME 2017-12-13 15:14:01 -06:00
Wouter van Oortmerssen
67b29d4e43 Fixed CreateStruct not testing for nesting.
Change-Id: I16bf46682ad68c62b778ed1514b6b706c8cb8f6f
Tested: on Linux.
2017-12-07 11:16:19 -08:00
Bastien Brunnenstein
85b131a719 Replace the non standard M_PI with a constant (#4528) 2017-12-04 15:06:13 -08:00
Paul Taylor
0e8a21854c publish additional js/flatbuffers.mjs to npm to support ESModules in node (#4504) 2017-12-01 14:18:43 -08:00
rmawatson
53a897731e this is allow custom allocator for obj-api structs/tables. (#4520)
added "native_custom_alloc" attribute to tables/structs, eg.

table parent_table( native_custom_alloc:"custom_alloc_name" ) {
...
}

with a custom allocator defined as

template <typename T> class custom_alloc_name : public std::allocator<T> {
public:

 typedef T*       pointer;

 template <class U>
 struct rebind {
  typedef custom_alloc_name<U> other;
 };

 pointer allocate(const std::size_t n) {
      return ....;
 }

 void deallocate(T* ptr, std::size_t n) {
    ...
 }

 custom_alloc_name() throw() {}
 template <class U> custom_alloc_name(const custom_alloc_name<U>&) throw() {}
};
};
2017-12-01 09:15:41 -08:00
Bastien Brunnenstein
ba08b0ec02 Add include directory to CMake install targets (#4510) 2017-11-30 08:45:58 -08:00
Mike Holler
da0bda6be3 Fixed prod PyPI URL and deploy block list. 2017-11-27 16:10:43 -06:00
Mike Holler
617bbc9b0c Added all_branches to tags: true block 2017-11-27 13:59:01 -06:00
Michael Holler
0c8b4c7614 Add support for Python lib continuous deployment.
Use a combination of travis and twine to publish to PyPI. New
publications will be made:

* When `master` is updated. This will trigger the publication of a
  the Python artifact versioned an iso-compliant build datetime. In this
  way, the cutting edge version will always be available via PyPI.
* When a new git tag is pushed. Tag pushes trigger the publication of
  a python artifact with the same version as the git tag, with the
  leading `v` stripped if present (`v1.2.3` becomes `1.2.3`).

Publications rely on Travis having a PYPI_PASSWORD environment set in
the project settings. See the Travis CI documentation for information on
[setting environment variables which containing sensitive data][1]. Make
extra sure the "Display value in build log" switch is OFF.

In addition to setting the previously mentioned `PYPI_PASSWORD`
environment variable, the owner of the PyPI `flatbuffers` repository
should, after merging this commit into master, add his own commit to
change `mikeholler` in `.travis/deploy-python.sh` to his username. It's
also recommended that the owner of `flatbuffers` use a separate account
in the unlikely event that the environment variable somehow becomes
compromised. Again, this is very unlikely, since the environment
variable is only set for "safe" builds approved by maintainers (not on
random pull requests).

[1]: https://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings
2017-11-27 13:14:33 -06:00
Wouter van Oortmerssen
34aea4361f Updated version numbers to 1.8.0
Change-Id: I9cf9fe1e2572d3f9c4066624a87249ca1e62a297
2017-11-20 09:46:03 -08:00
Wouter van Oortmerssen
be1ad33910 Missing generated code files.
Change-Id: I8808b0b419981ba7d0699da4a1effb0b660a21cb
2017-11-20 09:19:35 -08:00
MikkelFJ
0cf04ad9d5 Document type aliases (#4499) 2017-11-17 08:57:01 -08:00
Dan Douglas
fe483fa380 fix typo (#4495)
`Equipment` is a union, not an enum.
2017-11-16 16:03:16 -08:00
Wouter van Oortmerssen
8a8dc4e111 Fixed potential strict-aliasing violation in big-endian code.
Also added a test.

Tested on: Linux.

Change-Id: I7b3230f8f6043eec139d5e3e8c9cb45814124274
2017-11-16 14:21:11 -08:00
red1939
7e803c410c Add exports for all targets (#4491)
Each target that will be installed will also generate a target that will be
included by CMake config file.
2017-11-16 12:51:25 -08:00
Hong Wu
1336d26252 c++ Tutorial fix (#4494) 2017-11-16 10:09:48 -08:00
Louis-Paul CORDIER
853f7033e0 Remove copy constructor to make flatbuffers struct trivially copyable… (#4476)
* Remove copy constructor to make flatbuffers struct trivially copyable + add tests.

* Add support non c++11 compliant compilers.

* Fix std::trivially_copyiable test for non-C++11 compliant compilers.

* Fix trivially_copyable not part of glibc < 5 even with c++11 switch enabled.
2017-11-16 10:08:41 -08:00
David Komer
e2c7196ea8 tutorial docs (#4492) 2017-11-16 08:51:35 -08:00
Angela Sheu
61fe2a4fac Fix valid params limit exceeded for generated table constructor (#4490) 2017-11-13 13:39:49 -08:00
Wouter van Oortmerssen
d233b38008 Made stl_emulation.h usable by itself.
Change-Id: I1d9d301412fe0a036f12eb2cc82a3fbee5bb838d
2017-11-09 15:48:35 -08:00
Sergey Avseyev
ca52bfefc0 Specify ABI version for shared library (#4479) 2017-11-09 14:39:32 -08:00
Sergey Avseyev
2edb1dcdda Use CMake install directories instead of hardcoded (#4481) 2017-11-06 10:38:53 -08:00
Sergey Avseyev
6eb031de9a Text files should not have executable bit set (#4480) 2017-11-06 10:20:22 -08:00
Lawrence Chan
5f2af34e02 Link grpctest with libgrpc_unsecure explicitly (#4474) 2017-11-06 08:43:22 -08:00
Wouter van Oortmerssen
f3f113b24a Updated pom.xml to be able to deploy to Maven central.
Change-Id: Ie28dda5e1854eeff3e254e975925ff846c137008
2017-10-26 16:14:16 -07:00
stefan301
6bb0a728d3 Added missing EndTable() call to VerifyObject() (#4468)
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
2017-10-23 09:15:18 -07:00
Alex Ames
97face1527 Changed how vector_data works. (#4467)
In some debug environments using vector[i] does bounds checking even
though the standard specifies that it should not. Using
*(vector.begin()) sidesteps this though, giving the same result without
the bounds checking.
2017-10-20 16:49:15 -07:00
Alex Ames
f2627e16ac Fixed CMake build issue when building with Clang. (#4465) 2017-10-20 16:29:51 -07:00
Yonggang Li
01bac38c84 Nullable java (#4455)
* add _Nullable Support for C++ interface

* generate @Nullable for Java generated code
2017-10-16 09:24:11 -07:00
Stewart Miles
a1b5f565d9 Merge pull request #4459 from stewartmiles/master
Report a build failure when any Android build fails.
2017-10-13 17:55:51 -07:00
Stewart Miles
0780a7db24 Report a build failure when any Android build fails.
The travis script was only failing if the last Android build fails.
This changes the script to report a failure if any of the Android
projects fail to build.
2017-10-13 17:35:57 -07:00
Stewart Miles
9234ddcf11 Fixed Android build failure caused by use of C++11 limits.
f2b3705c2c caused Android builds
to fail.  This switches limit constants to use limits templates in
stl_emulation.h.
2017-10-13 17:35:57 -07:00
Stewart Miles
6d9a226f75 Merge pull request #4458 from a-maurice/master
Use flatbuffer unique_ptr instead of std's.
2017-10-13 16:44:02 -07:00
Anthony
b0fd1a8c66 Use flatbuffer unique_ptr instead of std's.
Stlport does not have std unique_ptr, so using the one provided by
flatbuffers.
Also fixing a problem with the flatbuffer unique_ptr, and a test.
2017-10-13 16:21:34 -07:00
Wouter van Oortmerssen
a0e5d78353 Add new flatbuffer_go_library to generate Go library for flatbuffers
This CL also introduces the following changes to allow the generation of the
Go library for flatbuffers:

- add support for --gen-onefile for Go to simplify the build rule (mapping each
  input .fbs to a single separate .go file)

- add a new --go-import flag to override the default import line (currently
  github.com/google/flatbuffers/go)

- add new go_library in BUILD for flatbuffer (for files in flatbuffers/go)

(mirrored from cr/171126159)

Change-Id: I83e705a9a9d9544837af0baf9366ec37757799aa
2017-10-09 09:27:30 -07:00
Brian Chavez
bc8a1608a8 Spelling error in C# and Java documentation (#4454) 2017-10-09 08:42:34 -07:00
Yonggang Li
30e7d16104 _Nullable cpp interface (#4451)
* add _Nullable Support for C++ interface

* add _Nullable Support for C++ interface
2017-10-09 08:40:17 -07:00
Wouter van Oortmerssen
9c3920d0ab Improved .proto conversion.
- Allowed enums to be declared before use.
- Generalized parsing of `required`.
- Reworked escaping of namespaces.
- Escaping field names that are C++ keywords.
- Many smaller fixes.

Change-Id: Ie580de7b70dc208f676f4f71bb0d061808648b8d
Tested: on Linux.
2017-10-06 16:08:00 -07:00
Aaron
5b4acf809e [C++] Add explicit keyword on generated constructors for Builder structs (#4452)
* Add explicit keyword on C++ generated constructors for Builder structs

* Add missing generated code for review
2017-10-06 08:50:24 -07:00
Robert
86fb05d320 Python: CreateByteVector function in builder. (#4453) 2017-10-06 08:34:07 -07:00
Dariusz Ostolski
5e4739184f Fix issue #4389, if field is ommitted the return type is the same for… (#4444)
* Fix issue #4389, if field is ommitted the return type is the same for python generator

* Fix issue #4389, bytes is returned when field is omitted

* Fix issue #4389, added generated python code after generator modification
2017-10-05 14:07:42 -07:00
Louis-Paul CORDIER
971a68110e Add template version for As method. (#4443)
* Add template version for As method.

* Fix compilation error on Linux.

* Fix linux issue (2).

* Linux fix (3)

* Add few tests.
2017-10-02 14:38:38 -07:00
Wouter van Oortmerssen
7a6b2bf521 Fixed TypeTable function not being inline.
Change-Id: Id335980daf909e885ed26a21b64623b78d01fb49
Tested: on OS X.
2017-09-25 11:44:58 -07:00
Wouter van Oortmerssen
03e2899985 Made the parser not have any hard-coded keywords.
This prevented any keywords showing up as JSON field names, for example.

Change-Id: Ie9d0cada96778e06016ca02ca96d052410a37038
Tested: on Linux.
2017-09-22 16:30:26 -07: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
endorph-soft
21a8121982 Add constant accessors to C++ unions (#4433)
* Add constant accessors to C++ unions

* Remove redundant const pointer return type

* Update generate_code.bat to reflect generate_code.sh

* Add updated generated files

* Remove extra space from generated code

* Update generated files

* Change directory back to tests after generating code
2017-09-21 14:06:20 -07:00
Khem Raj
28920aff8f Fix build with clang on big-endian targets (#4440)
* flatbuffers: Move EndianSwap template to flatbuffers/base.h

Clang complains
call to function 'EndianSwap' that is neither visible in the template definition nor found by argument-dependent lookup
     return EndianSwap(t);

This seems to be due to limitation of two-phase lookup of dependent names in template definitions

Its not being found using associated namespaces therefore
it has to be made visible at the template definition site as well

Signed-off-by: Khem Raj <raj.khem@gmail.com>

* use __builtin_bswap16 when building with clang

clang pretends to be gcc 4.2.0 and therefore the code does
not use __builtin_bswap16 but tries to synthesize it

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2017-09-21 08:51:08 -07:00
schoetbi
77b22aed5a idl_gen_json_schema.cpp: Fixed detection of enum types (#4438) 2017-09-14 09:25:43 -07:00
Lukas Bergdoll
cc25516d3e [C++] Fix DetachedBuffer move assignment lifetime (#4437)
* Fix DetachedBuffer move assignment lifetime

DetachedBuffer move assignment now destroys it's own content,
rather than waiting for the destructor of other.
See more under #4435

Add missing function return type

* Rename empty_assign to reset

Reset after destroy
reset() now operates on itself
2017-09-14 09:22:55 -07:00
Wouter van Oortmerssen
1d444f63d3 Fixed .proto not being accepted as schema file.
Change-Id: I1ccd52a847930fa636d24f9490d57577b8775d08
2017-09-12 11:36:38 -07:00
Wouter van Oortmerssen
5fa00630af Forgot to bump flatc version to 1.7.1
Change-Id: I480a08f445858bce3d0336c2b22da30d64f90012
2017-09-07 14:35:59 -07:00
rouzier
97af3d798b Update doc (#4427) 2017-09-07 11:52:58 -07:00
schoetbi
bb736091f3 Every type gets additionalProperties set to "false" (#4424)
#4423
2017-08-31 08:56:04 -07:00
endorph-soft
d5b4db0692 C++ Customise prefix/suffix of object API [Issue #4419] (#4422)
* Allow prefix/suffix of C++ Object API classes to be customised

* Address review comments
2017-08-31 08:54:03 -07:00
Wouter van Oortmerssen
5808f7fb03 Updated C# test project. 2017-08-25 11:47:19 -07:00
Wouter van Oortmerssen
42611f9a83 Fixed VS memory tracking leaking into user code 2017-08-25 11:29:58 -07:00
Wouter van Oortmerssen
1f0bd12851 Disabled numpy test in appveyor due to timeout.
It pulls in a LOT of dependencies, this will need to be done better.

Change-Id: Ib27effead194f6836facca01e9454a6037ad837a
2017-08-24 13:46:46 -07:00
Wouter van Oortmerssen
321a1c9dc0 Cleaned up namespace handling.
A Namespace object is now guaranteed unique.
This cleaned up some old workarounds and latent bugs.

Change-Id: Ic3f12d89947871b03b2c449ba51b3186f953adde
Tested: on Linux.
Bug: 21336857
2017-08-24 13:39:45 -07:00
Wouter van Oortmerssen
ac1015e3c4 Trimmed vtables of trailing zeroes.
This is something the format supports, but none of the builders
were doing. Can save 10-20% on FlatBuffer binary size!

Also fixed the Go tests.

Change-Id: I616c56ce9bbcfcaee23aa24f0532fcb60b6a8c75
Tested: on Linux.
2017-08-24 09:35:54 -07:00
Younguk Kim
513958ea72 Fix use of min and max when Windows.h is imported (#4411) 2017-08-17 09:35:50 -07:00
Wouter van Oortmerssen
2f2e4cced4 Noted that benchmarks are for C++
Change-Id: I12fbba7ffd2db47502a05eb06cedab49fd99c366
2017-08-14 16:36:42 -07:00
Wouter van Oortmerssen
f779962e3e Explained GetRoot<Monster> vs GetMonster.
Change-Id: Ic302096c07551b5c1aff0b261a329c46964cf337
2017-08-14 15:34:15 -07:00
Wouter van Oortmerssen
69776b9e7e Fixed .proto -> .fbs translating type bytes incorrectly.
Change-Id: Idb607360123d12c73dd1e045305007120b12131b
Tested: on Linux.
2017-08-14 14:45:29 -07:00
Wouter van Oortmerssen
00d726fc4c Further grammar.md fixes: union types, idents, string constants.
Change-Id: I51db0511c52c79f2b322a1fdef798b061941887b
2017-08-14 12:18:06 -07:00
Wouter van Oortmerssen
ad0f48d7e7 Fixed up grammar.md with rpc's and new scalar types.
Change-Id: Ie2965f48810bf24cccf098b69a9d471583efc3bf
2017-08-14 11:58:25 -07:00
Wouter van Oortmerssen
801e1b7699 Missing FieldDef initializer.
Change-Id: I5ed1f77868e201d7231102a106e08f3376b6adcf
2017-08-14 10:52:25 -07:00
Wouter van Oortmerssen
432e7582c6 Fixed file_identifier/extension leaking from included file.
Change-Id: I470143411e4ce6322e018a27bcc9cd40c15d9bf1
Tested: on Linux.
2017-08-14 10:41:39 -07:00
Wouter van Oortmerssen
d76113100a Cleaned up test output.
Change-Id: I4bec0e728cc162aa3f19091a0d154124ffbccdff
2017-08-14 09:30:10 -07:00
Wouter van Oortmerssen
dca33ddb75 Fixed root_type leaking in from included files.
Change-Id: I9378e375901f8a883eaeb2182955d690c358ed4b
Tested: on Linux.
2017-08-14 09:28:14 -07:00
rouzier
76744a4345 C++ Add new type vector_bool flexbuffers (#4410)
* Add new type vector_bool

* Update stl_emulation.h

Fix Is same typo

* Update stl_emulation.h
2017-08-14 08:44:56 -07:00
rouzier
b4e91091ec Internal doc (#4409)
* Add information about flexbuffer bool and null encoding

* Fix spelling errors

* Fix encoding example for flexbuffer map
2017-08-14 08:33:38 -07:00
Wouter van Oortmerssen
d5f5d382eb Added VS crtdbg memory leak tracking 2017-08-11 12:24:33 -07:00
Wouter van Oortmerssen
ffddbdc7ab Added missing generated code.
Change-Id: I7201d6891f56094178656a76bf0f87cf36d12554
2017-08-11 09:28:06 -07:00
Kamil Rojewski
46bb05d952 Vector of unions for TS/JS and PHP (#4404)
* Eclipse ignore

* TypeScript support

* Prefixing enums

* Test results

* Merged JS and TS generators

* Fixed AppVeyor build problems

* Fixed more AppVeyor build problems

* Fixed more AppVeyor build problems

* Changed TS flag to options struct

* Storing options by value

* Removed unneeded const

* Re-export support for unions

* Uint support

* Casting bools to numbers for mutation

* TS shell tests

* Reverted generates js test file to original version

* Backing up js tests and properly generating test data

* Not importing flatbuffers for TS test generation

* Not overwriting generated js for tests

* AppVeyor test fixes

* Generating the most strict TS code possible

* Not returning null when creating vectors

* Not returning null from struct contructors

* Vector of unions for ts/js

* Sanity check for languages

* Indentation fix + output test files

* Vectors of unions for php

* Fixes to union vector handling + tests
2017-08-11 09:24:36 -07:00
Kamil Rojewski
7cc72e4b11 Copying required field to union type vector (#4407)
* Eclipse ignore

* TypeScript support

* Prefixing enums

* Test results

* Merged JS and TS generators

* Fixed AppVeyor build problems

* Fixed more AppVeyor build problems

* Fixed more AppVeyor build problems

* Changed TS flag to options struct

* Storing options by value

* Removed unneeded const

* Re-export support for unions

* Uint support

* Casting bools to numbers for mutation

* TS shell tests

* Reverted generates js test file to original version

* Backing up js tests and properly generating test data

* Not importing flatbuffers for TS test generation

* Not overwriting generated js for tests

* AppVeyor test fixes

* Generating the most strict TS code possible

* Not returning null when creating vectors

* Not returning null from struct contructors

* Copying required field to union type vector

* Removed unneccessary bool
2017-08-11 09:19:28 -07:00
Wouter van Oortmerssen
a6a3f59253 Make flatc not silently skip schema files not ending in .fbs
Change-Id: I58463b321703b2ef0dc3f3062633909b86eca1a9
Tested: on Linux.
2017-08-10 16:31:25 -07:00
Wouter van Oortmerssen
8a58aafda1 Make it an error if a field has the same name as a table.
Change-Id: Ie5a3bb5a3643cd48e1cc75fe170a7b8a7c2cc8ed
Tested: on Linux.
2017-08-10 14:22:03 -07:00
Wouter van Oortmerssen
8dc1641c8a Forgot to update pom.xml in recent 1.7.1 release.
Change-Id: Ia6d6967546c0a2a5340a93e54c46d2630fff92fe
2017-08-10 11:35:58 -07:00
Wouter van Oortmerssen
4b27c92910 Misc documentation fixes.
Change-Id: Id7be5baba7d8a11ca050e8d94d95857406690378
2017-08-10 11:25:13 -07:00
Wouter van Oortmerssen
7fe281295f Fixed clang-tidy warnings.
Change-Id: Ib94ef29254c116b60e4ff298baa2ce323ac9655c
Tested: on Linux.
2017-08-07 15:33:36 -07:00
Wouter van Oortmerssen
917ff81b46 Added missing generated code from past commits.
Change-Id: I43e8de5a2ac224836a79661cc03bf37ac6d509fe
2017-08-07 14:55:05 -07:00
Wouter van Oortmerssen
8a2cc7cc4e Linked to Mikkel's binary format documentation.
Change-Id: I5054e37833d59bbe925cac2000a453fbee8ef54b
2017-08-07 14:53:54 -07:00
Wouter van Oortmerssen
a64d968473 Public accessor for buffer size of flexbuffers::Builder
Change-Id: Iff7895aebeba9c2940e26a3edbdf2d3f1b0d9b17
2017-08-07 13:24:42 -07:00
rouzier
a2b1bfc107 [c++] Add support for boolean types in flexbuffers (#4386)
* Add support for boolean types in flexbuffers

* Simplify casting number <=> boolean

* Added comments for tests

* Add proper support for Booleans

* Bad rebase

* No special case for strings

* Removed unused test

* Simplify logic
2017-08-04 08:04:28 -07:00
MikkelFJ
f2b3705c2c Add scalar type aliases for int8, uint8, ..., f32, f64 (#4400)
* Add type aliases

* Add generated code

* Rebase master
2017-08-02 08:07:43 -07:00
Kevin Rose
3282a84e30 [Python] (scalar) vector reading speedup via numpy (#4390)
* Add numpy accessor to python flatbuffers scalar vectors

* Update python tests to test numpy vector accessor

* Update appveyor CI to run Python tests, save generated code as artifact

* Update example generated python code

* Add numpy info to python usage docs

* Update test schema and python tests w/ multi-byte vector

* did not mean to push profiling code

* adding float64 numpy tests
2017-08-01 08:34:00 -07:00
Christian Helmich
89a68942ac Added support for nested flatbuffers serializing to json (#4391)
* added bool for nested_flatbuffer
setting bool flag nested_flatbuffer according to attributes
setting nested type

* added JSON serialization for nested flatbuffers

* simplified lookup of nested_flatbuffer StructDef

* added nested_flatbuffer parsing workound relying on flexbuffers

* moved nested flatbuffer parsing into its own function for clarity
removed flexbuffers workound to simplify and speed up nested_flatbuffer parsing
added support for 'legacy' nested_flatbuffers, ubyte arrays

* inlined functions for nested parser init/clean since only used once

* whitespace formatting

* changed type of FieldDef.nested_flatbuffer from bool to StructDef*
removed subsequent type lookups

* removed copies of unrequired data when initializing nested parser

* applied changes requested by reviewer

* removed superfluous lookup of nested_flatbuffer field attributes

* renamed camelCased variables to snake_case
2017-07-28 10:27:51 -07:00
Manuel Kroiss
360c34467c Adding accessors for IsBlob and Blob.data (#4398) 2017-07-27 09:06:02 -07:00
Stewart Miles
265e43faf0 Merge pull request #4395 from stewartmiles/master
Test case for CreateVectorOfStructs() using a callback.
2017-07-24 15:35:16 -07:00
Stewart Miles
f064a6cc60 Test case for CreateVectorOfStructs() using a callback.
Fixes issue #4392, also fixed C++98 compatible code generation in tests.

Change-Id: Ia5833026e615ad19d24a0439bdba2e3b45c5f86c
2017-07-24 14:19:49 -07:00
Christian Helmich
7fead0f140 forwarding IDLOptions.strict_json to flexbuffers .ToString() (#4394) 2017-07-24 09:33:40 -07:00
Stewart Miles
d6f14b704f Merge pull request #4383 from stewartmiles/master
C++98 (stlport) support for core FlatBuffers and FlexBuffers.
2017-07-20 12:24:38 -07:00
Stewart Miles
a892322203 C++98 (stlport) support for core FlatBuffers and FlexBuffers.
* Added internal - limited - implementation of flatbuffers::unique_ptr
  for STLs that don't ship with std::unique_ptr.  In C++11 and beyond
  this is just an alias for std::unique_ptr.
* Aliased used type traits structs is_scalar is_floating_point is_unsigned
  into flatbuffers namespace so they can be replaced in C++98 implementations.
  Right now these point at stlport's TR1 implementations.
* Wrapped vector::data() in vector_data().
* Wrapped vector::emplace_back() in vector_emplace_back().
* Wrapper string::back() in string_back().
* Added variants of FlatBufferBuilder::CreateVector() and
  FlatBufferBuilder::CreateVectorOfStructs() that allow the use of plain
  function pointers.
  Generated code has also been modified to use plain functions to build objects
  rather than std::function() so all generated code will work in C++98
  applications.
* Added flexbuffers::Builder::Vector(), flexbuffers::Builder::TypedVector()
  and flexbuffers::Builder::Map() methods that allow the use of plain function
  pointers.
* Changed Parser to internally use plain function pointers when parsing table
  and vector delimiters.
* Added specializations of NumToString() for 64-bit types that aren't supported
  by stringstream in stlport.
* Overloaded numeric_limits for 64-bit types not supported by stlport.
* Replaced build_apk.sh (which was broken by deprecation of the
  "android" tool in the Android SDK) with build.gradle and the
  appropriate gradle wrapper to build an APK.
* Switched Android build to build against all STL variants.
* Updated travis configuration to build Android test and sample.

Tested:
* Verified all tests continue to work on Linux, OSX and Android.
* Verified Travis build is green.

Change-Id: I9e634363793f85b9f141d21454b10686020a2065
2017-07-20 11:01:00 -07:00
schoetbi
2e2063cbeb idl_parser.cpp ignores $schema in input json (#4382)
* idl_parser.cpp ignores $schema in input json
#4381

* idl_parser.cpp: Fixed ci error signed unsigned comparison

* idl_parser.cpp: replaced case insensitive search for $schema with case sensitive search

* idl_parser.cpp: Expecting a string constant after $schema
#4382
2017-07-19 08:58:48 -07:00
Alex Wasserman
625c989875 Java: Added ByteBufferFactory interface and sizedInputStream method. (#4379)
The ByteBufferFactory interface gives the user an option to specify
the method in which the internal ByteBuffer is allocated. This provides
flexibility in the type of ByteBuffer that can be used.
The sizedInputStream method is an alternative to sizedByteArray that
does not make a copy of the data in memory.
2017-07-13 08:33:32 -07:00
schoetbi
f20204180d Json schema (#4369)
* Added empty generator for json schema (idl_gen_json_schema.cpp)
#4360

* JsonSchemaGenerator: output of tables implemented

current problems:
- typenames are not correct
- array types need to be deduced

#4360

* JsonSchemaGenerator: Corrected generation of typenames
Current problems: enum types not written correctly
#4360

* JsonSchemaGenerator: Added generation of enum types
#4360

* idl_gen_json_schema.cpp: Write required properties to schema
#4360

* idl_gen_json_schema.cpp: Export Types including namespace
#4360

* idl_gen_json_schema.cpp: Fixed Json format
#4360

* idl_gen_json_schema.cpp: Formatted according to google code style
#4360

* Checked in monster_test.bfbs with changes from master

* Added idl_gen_json_schema.cpp in CMakeLists.txt

* generate_code.bat: Added generation of json schema

* Added todo.md

* generate_code.sh: Added generation of json schema

* Addressed some review issues
- removed command line arg -S
- removed new lines
- fixed codestyle in template functions
- removed usage of stringstream
- idented json schema
#4360

* removed auto in idl_gen_json_schema.cpp

* idl_gen_json_schema.cpp: changed iterator declarations to auto
#4360

* deleted todo.md

* idl_gen_json_schema.cpp: Removed keyword "override" so that vs2010 can compile

* idl_gen_json_schema.cpp: switch statement in GenType handeles all enum-members

* idl_gen_json_schema.cpp: Removed cerr output

* idl_gen_json_schema.cpp: Avoid vector copying

* idl_gen_json_schema.cpp: Fixed identation of json schema output

* idl_gen_json_schema.cpp: Do not output empty descriptions
2017-07-10 08:05:59 -07:00
Robbie McElrath
0e85eeef2c Make inter-file cycles compile (#4364) 2017-06-26 09:07:02 -07:00
Andrei Stoica
b0fa5e0f42 Make flatbuffers work with ArduinoSTL (#4357) (#4361)
*Keep legacy compatibility with StandardCplusplus lib (utility.h)
2017-06-21 08:26:37 -07:00
Wouter van Oortmerssen
25a15950f5 Avoiding wrong template specialization on new CreateVector
Change-Id: I0da57cc71318ea13c10b547e2dfe3a2d4f32b4d9
Tested: on OS X.
2017-06-20 09:42:07 -07:00
Wouter van Oortmerssen
6f94fb51b1 Updated version numbers to 1.7.0
Change-Id: If2802ca48b61cfa7e5ec131e2a268400523217e2
2017-06-16 16:15:02 -07:00
Christopher Berner
57f3752d5e Optimize CreateVector for types > 1 byte on little endian (#4355)
This gives a 10x speed up in my test, when creating a Vector of floats
2017-06-16 15:29:47 -07:00
Wouter van Oortmerssen
f52f848b95 Added move assignment operator to DetachedBuffer.
Change-Id: I4610946ac27d9d0d73c2fc2e4834bd2cfed88cdc
Tested: on Linux.
2017-06-16 15:22:40 -07:00
Wouter van Oortmerssen
3c3742a54a Adding a method to get the file identifier from a flatbuffer.
Change-Id: Ie28fd1f0b463aac23647d38921600f15c8b7c10a
2017-06-16 12:30:36 -07:00
Wouter van Oortmerssen
f325cce6fd Initial support for parsing (and generating) Protobuf ASCII.
Change-Id: I955b4b3eed27f26773d7dc0acceff13c88d1333d
Tested: on Linux.
2017-06-16 11:57:58 -07:00
Wouter van Oortmerssen
88a85ffbbd Added convenient schema registry.
Change-Id: I9d71375059369fbc538d0d051d8d2885e467bf29
Tested: on Mac OS X.
2017-06-16 11:10:07 -07:00
Wouter van Oortmerssen
35cbd23f63 Fixed missing lambda return type.
Change-Id: I48d41a240c8bf362b1f931f20a3ed9ae64f2d295
2017-06-16 09:54:25 -07:00
Stephen Lane-Walsh
210a1ab969 Fixed build error in Visual Studio 2017 (#4353)
flatbuffers.h(591): error C2220: warning treated as error - no 'object' file generated
flatbuffers.h(591): warning C4267: 'return': conversion from 'size_t' to 'flatbuffers::uoffset_t', possible loss of data
2017-06-16 09:53:53 -07:00
Lawrence Chan
90c8ded449 gRPC: fix memory leak (#4351)
SerializationTraits<T>::Deserialize _transfers_ ownership of the buffer,
so we must destroy it.

This commit also includes some misc fixes:
- Use grpc::Status::OK rather than default ctor for clarity.
- Check for a null buffer passed into Deserialize, and handle it the
  same way as the protobuf deserializer.
2017-06-13 08:50:27 -07:00
Wouter van Oortmerssen
8f864aad7b Added (nested) FlexBuffer JSON parsing and output.
FlexBuffer parser is just 40 lines of code (on top of existing parser!).

Change-Id: Idebebadafb661ca5333f5621139031f6df3c3e1a
Tested: on Linux.
2017-06-12 16:40:47 -07:00
Wouter van Oortmerssen
dddd0865cb Added nested FlexBuffer parsing
Change-Id: I918b66eb5646d035e3aae675f745802eb54b03ea
2017-06-12 14:34:45 -07:00
Christopher Berner
0a81eb6463 Fix memory leak in Message move operator (#4344) 2017-06-12 11:23:55 -07:00
Guillaume Giraud
b1740688bf [cpp] Json parsing: adding support for parsing nested lists and top level lists (#4338)
* Extended json parsing capability: add support for parsing nested lists and top level lists

* Stylistic conformance with surrounding code + generalized comments

* More code tidy-up for stylistic conformance with surrounding code

* Blank lines

* Reverted changes related to top-level list parsing

* Styling: newline before else

* Taking out ProcessTableFields which is no longer needed as the top level list change was reverted.
2017-06-07 16:58:19 -07:00
Stephan T. Lavavej
86b505e412 [C++] Remove std::iterator usage (#4340) (#4341)
* [C++] Remove std::iterator usage (#4340)

Inheriting from std::iterator has never been required, and it's
deprecated in C++17. It can be replaced by directly providing typedefs.

Include <iterator> for std::random_access_iterator_tag.

Note that structs default to public access control.

* [C++] Change whitespace style in typedefs.
2017-06-07 16:26:06 -07:00
Lawrence Chan
da67c0a71f [C++] Improve flatbuffers + gRPC integration (#4310)
* Rework flatbuffers + gRPC integration

- Introduce `flatbuffers::grpc::Message<T>`, a `grpc_slice`-backed
message buffer that handles refcounting and allows flatbuffers to
transfer ownership to gRPC efficiently. This replaces
`flatbuffers::BufferRef<T>`, which required a copy call and was also
unsafe w.r.t. buffer lifetime.
- Introduce `flatbuffers::grpc::MessageBuilder`, a gRPC-specific builder
that forces a `grpc_slice`-backed allocator and also adds some helpful
`Message<T>`-related methods.
- Update serializers accordingly (now zero-copy between flatbuffers and
gRPC).

* gRPC: verify messages by default, but allow user to override

* gRPC: fix some formatting issues

* Disable verification by default, but add helper method

* Make FlatBufferBuilder fields protected + remove vec accessor

* Use bool add_ref parameter to toggle refcount incr

* Remove unnecessary inline specifiers

* Fix formatting

* Use auto

* Remove empty lines

* Use grpc_slice helper macros

* Simplify reset code

* Disable Message copy ctor and assignment by default

* Remove unused member

* Enable gRPC verification by default

* Use auto

* Bake in message verification (remove template specialization)

* Add RoundUp func

* Consolidate gRPC message copy flag

* Make vector_downward allocations fully lazy

* Test message verification failure code/message

* Add grpctest verification test comments

* Simplify reallocate implementation

* Make initial_size a size_t

* Use ternary op for growth_policy

* Use truthiness rather than dont explicit nullptr check

* Indent preprocessor directives

* Remove grpc message copy/assignment

* Fix a few bugs

* Add gRPC example

* Add basic gRPC docs

* Use doxygen EXAMPLE_PATH + @include

* Reference example fbs in grpc docs

* Move gRPC examples into grpc/samples

* Fix pointer/reference formatting

* Use std::function rather than templated callback func

* Create fresh message builder for each request

* Use Clear() in Reset() impl

* Use FLATBUFFERS_CONSTEXPR
2017-06-07 13:56:49 -07:00
rufeooo
dadd1a926e Generate a C++ function for EnumValues{{ENUM_NAME}} (#4337)
* enables "for each" logic on enumeration types
2017-06-07 13:49:56 -07:00
vabr-g
01c50d57a6 [C++] Remove std::move around a raw pointer in flatbuffers.h (#4339)
* Remove std::move around a raw pointer

Calling std::move on a raw pointer has no advantage to just copying its value. Moreover, it is confusing, because it indicates that the argument is movable in some non-trivial way (e.g., is it actually meant to be a smart pointer?). More context in https://crbug.com/729393.

* Remove the move constructor altogether
2017-06-05 10:33:04 -07:00
Wouter van Oortmerssen
e9f1f4d9b7 Disallowing field name same as table name.
Change-Id: I4b5d822cc4eda975949d1b7cf33674c5bbf9d4b1
Tested: on Linux.
2017-06-02 15:55:02 -07:00
Wouter van Oortmerssen
dd05f3249a Added test for nested FlatBuffers functionality.
Also fixed that the parsing test wasn't calling the buffer
testing function.

Change-Id: I5baae071bf0832c7797b4ef1d19d9b015e3ff5bc
Tested: on Linux.
2017-06-02 12:36:18 -07:00
AntonYudintsev
43611fcc0b refactor flatbuffers.h and util.h so FlexBuffers do not depend on flatbuffers.h (#4331)
FlexBuffers are actually completely unrelated to FlatBuffers and can be used separately.
However, since they utilize several utility functions from flatbuffer.h, they require this header file, which creates unreasonable dependency.
By moving those utility functions to separate base header, both libraries can use same code but still be independent
2017-06-02 10:26:11 -07:00
Pavel Kalinnikov
642254bee6 Track included files in PATH-agnostic way. (#4329)
* Track included files in PATH-agnostic way.

Use full paths as keys in the map of included files. Store logical
include path as a value, in order to put it to the generated file.

* Fix tests by accepting null |include_filename|.

* Fix self-includes code generators.
2017-06-02 08:50:18 -07:00
Wouter van Oortmerssen
22743ca45a Fixed --keep-prefix functionality.
Changing to keep include prefixes had two side effects: the main
file being parsed wasn't filtered out anymore, and include directory
paths would be added to the path in the include statement.

Also moved the include_test*.fbs files to sub directories so we
can actually test the handling of -I etc.

tested: on Linux.

Change-Id: Ibae095cea7ab0cccbac15cfb5171719f6b5cad8c
2017-05-24 16:26:57 -07:00
Lawrence Chan
fb87c0d3c6 [C++] Improve Allocator handling (#4312)
* Improve Allocator handling

- Templatize Allocator on vector_downward, and make it own the allocator
instance so it can manage lifetimes.
- Templatize + rename FlatBufferBuilderT accordingly, and add a typedef
to FlatBufferBuilder so old code continues to work.
- Fix some issues with the release deleter
- More details in github issue #4311

* Fix constexpr for older MSVC

* Reimplement allocator improvements via inheritance

Instead of templates, use an abstract base class and some unique_ptrs to
implement the new and improved allocator.

* Fix misplaced newline

* Add missing override keyword

* Add macro for func delete to support older compilers

* Explicitly move BufferDeleter (maybe fixes VS 10?)

* Revert previous attempt at VS10 fix

* Try yet another workaround for MS 10

* Use FLATBUFFERS_NOEXCEPT macro

* Add FLATBUFFERS_OVERRIDE macro

* Fix some issues with MSVC 16 hack

* Remove dep on unique_ptr

* Update DEPRECATED macro with a message

* Sigh, no delegating ctors before c++11

* Fix simple_allocator stub

* Relax FlatBufferBuilder ctor

* Add vector_downward reset + assert in clear

* Rename DetachedBuffer to FlatBuffer + remove unnecessary deprecations

* Add flatbuffers::FlatBufferBuilder::Release()

* Address remaining allocator-improvements comments
2017-05-24 13:55:15 -07:00
Wouter van Oortmerssen
398ae0cb6b Some code in the samples and docs still used old C# API.
Change-Id: I7914c88ad7b31baa7586771423069dc2b90d534f
Tested: on Linux.
2017-05-22 15:14:46 -07:00
Wouter van Oortmerssen
aaf5598a03 Standardized internal path handling on Posix separators.
There were several possible bugs involving paths not being
recognized as being the same on Windows. Rather than trying
to ensure all code deals with / and \ correctly, paths now
get transformed to / on input, fixing all current and
future such bugs.

Tested: on OS X.
2017-05-18 17:22:47 -07:00
Kamil Rojewski
3d2cf554d7 Fix for invalid null returns (#4318)
* Eclipse ignore

* TypeScript support

* Prefixing enums

* Test results

* Merged JS and TS generators

* Fixed AppVeyor build problems

* Fixed more AppVeyor build problems

* Fixed more AppVeyor build problems

* Changed TS flag to options struct

* Storing options by value

* Removed unneeded const

* Re-export support for unions

* Uint support

* Casting bools to numbers for mutation

* TS shell tests

* Reverted generates js test file to original version

* Backing up js tests and properly generating test data

* Not importing flatbuffers for TS test generation

* Not overwriting generated js for tests

* AppVeyor test fixes

* Generating the most strict TS code possible

* Not returning null when creating vectors

* Not returning null from struct contructors
2017-05-18 10:30:30 -07:00
sfariv
55dec4d2f8 added check for presence of required fields. (flatc) c++ (#4316)
* added check for presence of required fields.

* updates to resolve Travis CI build error.

* fixes for resolving appveyor build errors.

* fixes for resolving appveyor build errors.

* fixes for resolving appveyor build errors.

* updates per aardappel's comments.

* updated a variable's name.

* updates per aardappel's comments.
2017-05-18 09:32:04 -07:00
schoetbi
0f5f7faa9f C#: Added <autogenerated> in cs generator file header comment (#4291)
* Added <autogenerated> in cs generator file header comment
#4287

* CS: Added xml-correct file header comment including "<auto-generated>...</auto-generated>"
code_generators.cpp: FlatBuffersGeneratedWarning() function replaced by compile time constant "GeneratedWarning"
 also removed extra newlines at end of GeneratedWarning to be able to generate a xml well formed file comment for cs files
#4291

* code_generators: Changed static string GeneratedWarning back to function FlatBuffersGeneratedWarning()
#4291

* Added modified Unit-Test files
#4291

* idl_gen_general: Add autogenerated only in C# code
#4291
2017-05-16 14:28:34 -07:00
Wouter van Oortmerssen
90daabd5b1 Made root test path configurable.
Change-Id: I9629a7648f0c3346c4724ca8938fed47d7828018
Tested: on Linux.
2017-05-15 16:57:39 -07:00
Wouter van Oortmerssen
262e1d7bf9 Updated tutorial with a vector of structs example.
Since it wasn't documented and very different from a vector of
tables, this has caused a lot of confusion in the past.

Change-Id: Iab47c61b55c19abe5c4f25c86d71335a6b6321ca
2017-05-15 13:41:27 -07:00
Wouter van Oortmerssen
c559eb451e Made codegen always output a file, even on an empty schema.
Previously, we had a check to simply skip such files, but this
tends to make build systems unhappy.

This only affects C++ and JS, since other language output per-class
files.

Change-Id: I54224642725bbafb9f6e1654ed3693e62ca9f7d7
Tested: on Linux.
2017-05-12 16:08:58 -07:00
Lawrence Chan
6a7ec85e83 [C++] Fix code gen indentation when empty Print (#4313)
* Fix C++ code gen indentation when empty Print

* Also commit modified tests/monster_test.bfbs
2017-05-12 14:36:35 -07:00
akamat-ibm
81ecc98e02 Adding support for s390x (#4297)
* changes to support s390x

* added flag for s390x

* Adding support for Linux s390x
2017-05-12 10:12:19 -07:00
Per Grön
9aeeddf5ac C++/Go: Update gRPC related code to work with gRPC 1.3+ (#4305)
* Don't fail the build on unused parameters

gRPC headers have unused parameters so this breaks the test build.

* Pull in updated compiler files from gRPC

There have been some API breaks in gRPC lately. This commit
pulls in the most recent version of the files in this repo
that are just copied from gRPC.

* Modify the gRPC files so that they can work with Flatbuffers

The files taken from gRPC do not work out-of-the-box with Flatbuffers.
This commit modifies them so that they work. Hopefully this commit
will be able to serve as a guide or maybe even be cherry-picked on
top of new versions of those files as newer versions from gRPC are
pulled in.

* Adjust the rest of Flatbuffers to work with the new gRPC

* Change idl_gen_grpc.cpp to work with the new API
* Add missing #include in flatbuffers/grpc.h
* Run tests/generate_code.sh and check in the results
* Don't link with grpc++_unsecure and (secure) grpc. That's just weird

* Revert unrelated JS/TS test changes

* Simplify compiler/config.h

There is no need to import this file from gRPC. In fact, it probably
makes sense to not do so, since it seems to be intended to have
project specific configuration in it.

* Don't emit C++ types in the Go gRPC code generator

* Don't emit C++ #includes in generated gRPC code

Before this PR, there was a Go-specific additional_includes method
in schema_interface.h, which is shared with the gRPC repo. The
additional parameter to FlatBufFile in idl_gen_grpc.cpp makes that
unnecessary, which means we need less Flatbuffer-specific changes
in gRPC.
2017-05-12 09:48:17 -07:00
Wouter van Oortmerssen
c7bfe06c54 Reverting part of PR #4286
This is because it trips up the Closure compiler with errors like:

ERROR - assignment to property bb of SomeTable
found : undefined
required: (flatbuffers.ByteBuffer|null)
this.bb = undefined;
^^^^^^^^^^^^^^^^^^^

Change-Id: Iaf032b5249ec655e151331e81532e549c12bcd78
2017-05-10 18:04:53 -07:00
Wouter van Oortmerssen
349a391208 Removed unnecessary check for Offset in AssertScalarT()
This will avoid it accidentally accepting structs of size 4.

Change-Id: I251285ae1e4bffb859367dcf89562741a3980bba
Tested: on Linux.
2017-05-10 18:00:27 -07:00
Wouter van Oortmerssen
9d01bfaea3 Added error message for union values out of range.
Change-Id: I481afcde6a554d1cad519ff95acac7f38a7f4ee5
Tested: on Linux.
2017-05-10 17:21:47 -07:00
Travis Wellman
cfbab31fb1 cleaning up JavaTest.sh - quote paths, and less error-prone deletion (#4301) 2017-05-10 16:45:08 -07:00
Wouter van Oortmerssen
cb2481efdc Ensured flatc.exe is statically linked on Windows 2017-05-10 16:20:53 -07:00
Wouter van Oortmerssen
d7ac3788e8 Clarified the semantics of the Offset type.
Change-Id: Iccc36d24321ac4d556692ac715c0cc69a2c9e09e
Tested: on Linux.
2017-05-10 14:55:11 -07:00
Wouter van Oortmerssen
a0a313b101 Added missing js/ts generated code.
Change-Id: I146e9e1b8f997c11d1675dbef1b958ddbd181092
2017-05-10 13:25:51 -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
Wouter van Oortmerssen
04d734d6d2 Added more test scripts: Mono on Linux, and one for all.
Change-Id: Ia107557225db27b396f0d666c5c5b1b324ea22fa
Tested: on Linux.
2017-05-10 12:55:27 -07:00
Wouter van Oortmerssen
8468ea1ab4 Fixed LookupByKey for Java & C#
Change-Id: I05c02223675dee241d1ae8cb466e5186444058c8
Tested: on Linux.
2017-05-10 12:55:27 -07:00
水樹素子
0920d663d5 [C++] Add grpc/streaming test and fix Deserialize (#4296)
* [C++] Add delete msg->buf

* [C++] Add grpc streaming test

* Use free instead of delete

* Refactoring grpctest
2017-05-08 13:49:34 -07:00
Heiko Becker
bbb72f0b73 Tweak fallthrough comments to get recognized by gcc7 (#4298)
GCC gained a new warning, -Wimplicit-fallthrough, which warns about
implicitly falling through a case statement. The regular expressions
used at the default level (-Wimplicit-fallthrough=3) don't match with
a colon at the end. The comment also needs to be followed (after
optional whitespace and other comments) by a 'case' or 'default'
keyword, i.e. it will not be recognized with a '}' between the comment
and the keyword.
2017-05-08 13:35:55 -07:00
moti
8f8a27d6e5 [C++] Add grpc_slice_unref(slice) (#4294) 2017-05-04 15:44:31 -07:00
Kamil Rojewski
86777bd66b Generating the most strict TS code possible (#4286)
* Eclipse ignore

* TypeScript support

* Prefixing enums

* Test results

* Merged JS and TS generators

* Fixed AppVeyor build problems

* Fixed more AppVeyor build problems

* Fixed more AppVeyor build problems

* Changed TS flag to options struct

* Storing options by value

* Removed unneeded const

* Re-export support for unions

* Uint support

* Casting bools to numbers for mutation

* TS shell tests

* Reverted generates js test file to original version

* Backing up js tests and properly generating test data

* Not importing flatbuffers for TS test generation

* Not overwriting generated js for tests

* AppVeyor test fixes

* Generating the most strict TS code possible
2017-05-01 16:05:53 -07:00
Wouter van Oortmerssen
8b92122f33 Made the verifier catch zero-offsets.
Zero offsets are non-sensical in FlatBuffers (since offsets are
relative to themselves) but were allowed by the verifier. This could
cause buffers made up of all zeroes to be interpreted as correct
buffers with an empty root object.

Generally, not allowing such offsets will make the verifier more
likely to catch problems earlier.

Change-Id: I54010bea29721b326ff8e5348fcd9fe78e5e7506
Tested: on Linux.
2017-04-26 14:26:18 -07:00
Wouter van Oortmerssen
e93a5652d0 Fixes for VS 2015 build.
Change-Id: I23280e611163a89b8eba7b9b0016c297fea2396e
2017-04-24 10:48:35 -07:00
Wouter van Oortmerssen
0c80b3a7cc Added VS 2015 test to AppVeyor CI.
Change-Id: I354c13fbe6f159058fbeff47100ef357e99c6cd5
2017-04-24 10:06:55 -07:00
Wouter van Oortmerssen
f52ddfbd68 Fix Android STLPort build.
Change-Id: Iceca7b8b455c8463d9b82b928332a875dee3d19e
2017-04-21 10:50:03 -07:00
Kamil Rojewski
808b44f87a TS tests fixes (#4265)
* Eclipse ignore

* TypeScript support

* Prefixing enums

* Test results

* Merged JS and TS generators

* Fixed AppVeyor build problems

* Fixed more AppVeyor build problems

* Fixed more AppVeyor build problems

* Changed TS flag to options struct

* Storing options by value

* Removed unneeded const

* Re-export support for unions

* Uint support

* Casting bools to numbers for mutation

* TS shell tests

* Reverted generates js test file to original version

* Backing up js tests and properly generating test data

* Not importing flatbuffers for TS test generation

* Not overwriting generated js for tests

* AppVeyor test fixes
2017-04-21 09:29:42 -07:00
Wouter van Oortmerssen
340d1a3447 Fix FlexBuffers writing incomplete length for 64-bit vectors. 2017-04-19 17:51:52 -07:00
Carlos Sanchez
ba20d9bff3 Added a clear function for purging all data that is holded by the FlatBuffer. (#4259) 2017-04-19 17:06:33 -07:00
Dmitry Ermolov
370693a200 Specify `std' namespace for remove function (#4268) 2017-04-19 16:55:41 -07:00
Christian Helmich
33932ceea4 Fixed CreateVectorOfStructs for native_type (2nd try) (#4276)
* Added support for serializing native_type with CreateVectorOfNativeStructs

* Added support for serializing native_type with CreateVectorOfSortedNativeStructs

* Added C++ code generation for vectors of native_types
2017-04-19 10:14:31 -07:00
Per Eckerdal
fb03f78fb4 Fix minor const correctness issue (#4271) 2017-04-19 08:56:55 -07:00
Wouter van Oortmerssen
523f3833eb VS fix for ambiguous union assignment operator.
Change-Id: I1c37db1ced462fd558d3e893a501341f3eca6379
2017-04-17 18:00:41 -07:00
Wouter van Oortmerssen
46497e4f9a Fixed hashed values in JSON for signed ints.
Change-Id: Iae389c6dc9776058b39f4017d30efbf9580aced1
Tested: on Linux.
2017-04-17 17:40:02 -07:00
Wouter van Oortmerssen
b627b7c6c6 Undo PR: make flatbuffers.js into a UMD module (#4228)
This PR did not work in all JS environments and caused
downstream breakage.

Change-Id: Ib565129e26622d02bad2d45816bd05f6b961b994
2017-04-17 17:31:03 -07:00
Wouter van Oortmerssen
e093f72d00 Improved union copy constructor.
It now at least works in simple cases.

Change-Id: I3af0738e676e62166b69accaa6bd19f531fbe5ee
Tested: on Linux.
2017-04-17 17:27:20 -07:00
Wouter van Oortmerssen
728bb64fed Fixed clang needing union copy constructor.
Move constructors are present, which it should use instead.

This is a temp fix to make it compile, but eventually we should
generate a proper copy constructor just in-case people want to
copy objects with unions.

Tested on: Linux, OS X.

Change-Id: Idf85419995c96f5959061882157541573e306083
2017-04-17 14:01:43 -07:00
Jason Stubbs
a07f0d428d [C++] fix bounds checking on integer parsing (#4250)
* fix bounds checking on integer parsing

the previous code was allowing 255 for int8_t, similar for int16_t
and int32_t, and even negative values for unsignd types.

this patch fixes bounds checking for 8-bit, 16-bit and 32-bit types.
testing for both acceptable values and unacceptable values at the
boundaries are also improved.

bounds checking on 64-bit types isn't addressed by this patch.

* fix 'unary minus operator applied to unsigned type, result still unsigned'

* fix & placement
2017-04-17 11:19:43 -07:00
Wouter van Oortmerssen
b90d4e049d VS warning fixes.
Change-Id: I19662241d56560c064cff73dbebfb2a81d226934
2017-04-12 17:56:19 -07:00
Wouter van Oortmerssen
b0752e179b Added support for structs and strings in unions.
(C++ only for now).
Also fixed vector of union support in the object API.

Bug: 36902939
Change-Id: I935f4cc2c303a4728e26c7916a8ec0adcd6f84cb
Tested: on Linux.
2017-04-12 17:47:47 -07:00
schoetbi
1fc12e0e5b C++ fixed compile error C2678 with msvc when using std::find_if on vectors (#4262)
In Debug mode it is checked that iterator begin is less than end
therefore the operator< in class VectorIterator is needed
2017-04-12 16:37:22 -07:00
chronoxor
e6fa7b1133 Fix Visual Studio 2017 new warning (C4244: 'argument': conversion fro… (#4261)
* Fix Visual Studio 2017 new warning (C4244: 'argument': conversion from 'int' to 'const char', possible loss of data)

* Fix Visual Studio 2017 pedantic warnings

* Fix Visual Studio 2017 pedantic warnings
2017-04-12 13:13:10 -07:00
Kamil Rojewski
28e7dbd3d3 TypeScript support (#4232)
* Eclipse ignore

* TypeScript support

* Prefixing enums

* Test results

* Merged JS and TS generators

* Fixed AppVeyor build problems

* Fixed more AppVeyor build problems

* Fixed more AppVeyor build problems

* Changed TS flag to options struct

* Storing options by value

* Removed unneeded const

* Re-export support for unions

* Uint support

* Casting bools to numbers for mutation

* TS shell tests

* Reverted generates js test file to original version

* Backing up js tests and properly generating test data
2017-04-10 10:01:13 -07:00
Iain van der Bloat
adc50051e0 make flatbuffers.js into a UMD module (#4228) 2017-04-07 17:14:01 -07:00
moti
2aec880347 [C++]Use noexcept in union type move ctor/Add move assingment (#4249)
* Use noexcept in union type move ctor/Add move assingment

* Add NOEXCEPT macro to deal with _MS_VER/Remove delegating ctor in union type class

* Add FLATBUFFERS_NOEXCEPT to generated union class
2017-03-29 18:00:20 -07:00
Wouter van Oortmerssen
238a8ebb15 Suppress warning in Flatbuffer VS2010 builds.
Change-Id: I4f66a96ba581704c1a384cc700b8fb731d3eeed4
2017-03-29 12:01:11 -07:00
Wouter van Oortmerssen
86992476da Update StackOverflow links to have relevant queries.
Change-Id: I59159fb7205e4802f041b749d502a8f305d4176c
2017-03-29 11:58:42 -07:00
Wouter van Oortmerssen
751aeabc80 Updated .gitignore for C#
Change-Id: I6c253b0ded187a4945f5e862aae721cf4fda6398
2017-03-29 11:55:20 -07:00
Wouter van Oortmerssen
b4bb1b103f Fix flatc code gen.
Mutable functions should return a non-const reference to the member variable.

Change-Id: I833077d2c9a38a5d71868e43aca6b250d79b6625
2017-03-29 11:51:20 -07:00
Wouter van Oortmerssen
cffd187fc7 Added missing generated code for C#
Change-Id: I1affced255eb96977119d8480793b5bba42f065f
2017-03-29 11:51:02 -07:00
Spencer Bench
ccfa317486 C#: Fixed possible conflicts between usings and user-supplied namespace (#4247)
* C#: Fixed possible conflicts between usings and user-supplied namespace

C#: Added the global qualifier to using directives to prevent possible conflicts with the user-supplied namespace. Also prevents unintentional type hiding. Resolves issue #4242.

* Updated C# generated code files
2017-03-29 11:09:25 -07:00
tianyapiaozi
a5cc2092a6 Support binary search for struct in cpp (#4245)
* Support binary search for struct in cpp

CreateVectorOfSortedStruct is provided for convenience.

* fix continuous-integration error

* add generated files

* compile Ability.cs in csharp test

* compile Ability.cs in csharp

* modify according to code review
2017-03-29 09:51:12 -07:00
Wouter van Oortmerssen
89041a1686 Add a VectorCast function that safely casts from
Vector<Offset<T>> to Vector<Offset<U>> if U is a base
class of T.

This is useful for when you want to generically
iterate over a vector of objects that derive from
flatbuffers::Table.

Change-Id: I59161e3b9f40501f72e02b46509be9dc8ab86c6b
2017-03-27 17:50:30 -07:00
Wouter van Oortmerssen
7a36419f24 Fixing closure compile compatibility when --gen-mutable is used.
Change-Id: I8bf575ba6dc795d2d2eec02fa8977dcc2594eaa6
2017-03-27 17:50:30 -07:00
Jesper Stemann Andersen
281284fa5d Fixed building and warnings on Arduino (16 bit platform). (#4197)
Building on Arduino fixed by conditional includes of cstdint and utility. In the Standard C++ for Arduino (port of uClibc++):
* cstdint is not present.
* utility is named utility.h.

Replaced size_t with uoffset_t for Verifier::max_tables_, max_depth_, depth_, and num_tables_ to ensure 32-bit values are used (and not 16-bit) - gave rise to a warning.
2017-03-27 09:38:04 -07:00
Lawrence Chan
1a27c7017a C++: Add default value handling to mutation/SetField code (#4230)
* Add default value handling to mutation/SetField code

* Shorten reflection SetField impl

* Modify impl to work with C++03

* Add more mutation tests

* Fail SetField if non-scalar

* Add IsScalar/IsInteger/IsFloat for reflection::BaseType

* Use new IsScalar/IsInteger/IsFloat in reflection SetField

* Assume scalar is either int or float
2017-03-20 17:36:27 -07:00
Flier Lu
b8f5f84437 add command line argument for go namespace (#4222) 2017-03-20 16:08:35 -07:00
Alexander Gallego
f2071e4f80 Add arbitrary string type to the native object API (#4218)
* Custom strings are very common for optimizations around small objects
  or growth style optimizations, i.e.: grow at 1.57 times vs doubling vs..

  A second common strategy is to cooperate w/ the memory allocator
  see FBString[1] and seastar[2] string for examples.

[1] fbstring: https://github.com/facebook/folly/blob/master/folly/docs/FBString.md
[2] sstring: https://github.com/scylladb/seastar/blob/master/core/sstring.hh
2017-03-20 16:02:04 -07:00
Jun Hyeon, Nam
9c25ecdcd1 C++: add String::str() function (#4234)
for convenience
2017-03-18 10:09:56 -07:00
Jun Hyeon, Nam
1beed12e59 fixed duplicate symbol error in flexbuffers.h (#4233)
1. modified the function that omitted inline.
2. changed the static global functions to inline functions.
2017-03-18 10:08:39 -07:00
Flier Lu
4cd71d67f1 GO: add _ postfix to identiy conflict golang keyword (#4221)
* add _ postfix to identiy conflict golang keyword

* make VS2010 happy
2017-03-15 18:34:53 -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
Koichi Shiraishi
c04c143cf0 tests: update monster_test.bfbs binary file with generate_code.sh (#4220)
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
2017-03-15 14:53:37 -07:00
Koichi Shiraishi
c6aae45364 sample: update auto-generated monster_generated.h (#4219)
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
2017-03-15 14:52:47 -07:00
Alexander Theißen
7f2a1c90d5 Prevent flatbuffers::Vector and flatbuffers::VectorOfAny to be copied (#4217) 2017-03-13 08:53:30 -07:00
chronoxor
f5387387de Pedantic Visual Studio build (/W4 /WX) (#4214)
* Pedantic Visual Studio build (/W4 /WX)

* Pedantic Visual Studio build (/W4 /WX)

* Pedantic Visual Studio build (/W4 /WX)

* Remove /wd4512 from CMakeLists.txt

* Suppress Visual Studio 4512 warning ('class' : assignment operator could not be generated)
2017-03-10 10:27:30 -08:00
Louis-Paul CORDIER
e7e4dc755d NoError was returning on DoParse method when file was empty (#4208)
* NoError was returning on DoParse method when file was empty.

* change NoError message in DoParse.
2017-03-10 08:50:44 -08:00
chronoxor
b8224809ad VS2015 warning "conditional expression is constant" (#4210)
* VS2015 warning "conditional expression is constant"

* VS2015 warning "conditional expression is constant"
2017-03-08 13:34:38 -08:00
Dale Lukas Peterson
bb22fb5756 Fix broken symlink to CONTRIBUTING.md (#4212) 2017-03-08 13:16:11 -08:00
Christian Helmich
ff274771ba fixed path being ignored in GenerateCppGRPC (#4207) 2017-03-08 09:08:40 -08:00
Hadriel Kaplan
15bf626191 Add a backwards-compatible version of VerifyBuffer() (#4201) 2017-03-08 08:25:37 -08:00
Zarian Waheed
ac106e835c Fixing broken link and added missing <map> header include. (#4199) 2017-03-03 09:47:52 -08:00
xiaohaoliang
640b525e83 optimization of FlatBufferBuilder::CreateVector() (#4198)
optimization of FlatBufferBuilder::CreateVector()
1. optimization of FlatBufferBuilder::CreateVector() for "1 == sizeof(T)" ( such as [byte], [ubyte]).
2. For my project, it was about 10x improvement on flatbuffers serialization.
3. why not "string": "string, which may only hold UTF-8 or 7-bit ASCII. For other text encodings or general binary data use vectors ([byte] or [ubyte]) instead."
2017-03-03 09:40:43 -08:00
Raman
0b379211dc Fixed problem with uint keys (#4172)
* Fixed problem with uint keys

* removed excess check

* Resolved problem with big uint, ubyte keys in Java
2017-02-28 14:16:50 -08:00
Louis-Paul CORDIER
bb223da258 C++ generator: Pre-allocating std::vector in UnPack methods. (#4187) 2017-02-25 22:10:17 -08:00
Andrei Lebedev
17c5f89d4f Fixed move constructor in generated union class (#4192)
* Fixed move constructor in generated union class

* Removed delegating constructor
2017-02-25 22:06:48 -08:00
Andrei Lebedev
695d26183a Remove libc++ and c++abi requirement on Linux with clang (#4189) 2017-02-25 21:47:57 -08:00
Kameiha
f5120a2aaf more safer (#4186)
push_small(T little_endian_t) => push_small(const T& little_endian_t)
2017-02-25 21:24:43 -08:00
Franken
037314a059 [C++] Additional accessors for fields of union types. (#4184)
* Additional accessors for fields of union types.

* Reveal the hidden parameter.

* External explicit specializations for templated accessors.

* Changes according to code style. Generated code included as well.
2017-02-25 21:23:32 -08:00
litianzhao
ebcfbbadf0 fix #4180: Long.prototype.toFloat64() overflow (#4182) 2017-02-20 11:20:56 -08:00
Wouter van Oortmerssen
6561c7a31f Temporarily disabled VS2010 warning 4512.
Change-Id: Ib75b4cc651ac8f67cd262c8293fca1ac590f6b71
2017-02-15 17:46:00 -08:00
Wouter van Oortmerssen
a6d98fb067 Fixed VS x64 warnings in flexbuffers.h 2017-02-15 17:41:00 -08:00
Wouter van Oortmerssen
3a2d3a232f Removed spurious "aa" from flatc usage message.
Change-Id: Ia1812d594882ce6c51002d07827ccec267d138bb
2017-02-15 14:59:25 -08:00
Wouter van Oortmerssen
cebdad4d23 Updated version numbers to 1.6
Change-Id: I215fcc7581253f14171b513d4fc75da960b2064a
2017-02-15 14:36:51 -08:00
Sahil Jain
d798100be9 Round vector_downward initial size up (#4179) 2017-02-15 11:42:01 -08: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
2d6e8f096b Fixed sorting assertion with some std::sort implementations.
Change-Id: Idd925c9cc5cd2a35e06f4d832734180f5c38378e
Tested: on Linux.
2017-02-13 09:50:35 -08:00
Shintaro Abe
ec8038cc3d JS: add package.json to publish the npm pacakge (#4166)
* JS: add package.json to publish the npm pacakge

* JS: update package.json to set version and author
2017-02-10 14:19:11 -08:00
Wouter van Oortmerssen
2df3d1c965 Added missing generated code.
Change-Id: If3d2e11627b6d08bc6433941208ead577aa0e3b9
2017-02-10 13:28:15 -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
水樹素子
b7bfecb4ee Add move constructor to generated union class. (#4167)
* Add move constructor to generated union class.

* Unused default

* Add generated code
2017-02-10 10:32:34 -08:00
sjoblom65
c7c4bbfce2 Error C2668: 'Service::Version2::CreateServiceValues' : ambiguous call to overloaded function (#4161)
* Update idl_gen_cpp.cpp

Fix for: error C2668: 'Service::Version2::CreateServiceValues' : ambiguous call to overloaded function #4145

* Update idl_gen_cpp.cpp

Also needed the same change in the getPostTable

* Add files via upload

New generation from running generate_test.bat

* Add files via upload

Lets try this without added line feeds

* Added a test for a potential "ambiguous call to overloaded function"

* Change to a better name of the table.

Didn't like the Service in the name.

* Reverted back to the original
2017-02-10 10:25:11 -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
60b11435e6 Fixed missing '
Change-Id: I25110bbb171a27626ec6416b810399069d590279
2017-02-08 17:04:44 -08:00
Wouter van Oortmerssen
ed2110d7b3 Fixed link to Google C++ Style Guide.
Change-Id: Ifb955f3daefedae2cb9930a365c4c7e0641776b4
2017-02-08 16:37:25 -08:00
Wouter van Oortmerssen
a9514de978 Fixed vector test on Windows 2017-02-08 15:59:52 -08:00
Wouter van Oortmerssen
c57ab92e60 Fixes for Windows compiler errors.
Change-Id: I909ea6866089f36f9cb79d435bbecd29623fd8f7
2017-02-08 15:38:18 -08:00
Wouter van Oortmerssen
f878024d0b Fixed the Android build.
Change-Id: Iabb9448b4f161bba465d455c28bb826529649d30
Tested: on Android.
2017-02-08 15:13:57 -08:00
Wouter van Oortmerssen
aac6be1153 First attempt at SchemaLess FlatBuffers.
Change-Id: I86b9d002f3441ef9efdb70e059b8530ab2d74bb8
Tested: on Linux.
2017-02-08 15:13:56 -08:00
Wouter van Oortmerssen
dabe030890 Added PULL_REQUEST_TEMPLATE.md
Change-Id: Iad9c09434f87219e384b294d6221f4cac7a839eb
2017-02-08 10:15:26 -08:00
Wouter van Oortmerssen
29574282a2 JSON parser wasn't handling ulong values correctly.
It passed all scalar ints thru a int64_t, which would truncate
uint64_t values with the upper bit set.

Change-Id: I38fb8c68c911ae44d9863f8e35c2429ca0ab51e5
Tested: on Linux.
2017-02-01 14:18:28 -08:00
Benjamin Lerman
2dd6ba57d1 Add utility method to build a vector of struct in-place. (#4153)
Change-Id: I6df195cbae621cf2bf6b4f3b56f68be80dc23152
2017-02-01 09:22:56 -08:00
Wouter van Oortmerssen
6cc2307c71 Remove max_message_size arg, which is not passed to Deserialize func.
Change-Id: Icc7b4c1cf626f49d0529ff4f66503ea8381bf67c
2017-01-30 14:54:51 -08:00
Wouter van Oortmerssen
74c8c7137a A bug fix to the union vector feature in FlatBuffers.
Change-Id: I302245969f6ec2443572799732fce2aa7c071879
2017-01-30 14:02:40 -08:00
Wouter van Oortmerssen
f9055ff9a7 Merge branch 'master' of https://github.com/google/flatbuffers 2017-01-27 15:30:27 -08:00
Wouter van Oortmerssen
9b3d8b318a Added tracking of order of types declared.
Change-Id: Iade313c99f119dcf1619674260648a33f61dc030
2017-01-27 15:30:08 -08:00
Wouter van Oortmerssen
87e29b25de Some small speed optimizations to the core copying functions.
Change-Id: Id8c1afb84f4ab0e2edca4290e3de5589fa06e578
Tested: on Linux.
2017-01-27 11:26:35 -08:00
Robert
f7bc9bd51b Merge pull request #4146 from zchee/go-test-fix_struct
go: fix unknown field 'UOffset' to 'Pos'
2017-01-26 20:45:49 -08:00
Wouter van Oortmerssen
3dee617c86 Fix unused variable build warning on Mac.
Change-Id: I330187be6a96bfd388c2776f676d47a9145d5e4a
2017-01-25 14:39:14 -08:00
Wouter van Oortmerssen
2fb25e2bb3 Moved union vector test to file dependent section.
Change-Id: I3a1fcf167eb0d0a51ef838e54246ef867e752218
2017-01-25 14:09:18 -08:00
Wouter van Oortmerssen
b395359b6e Allow the flatbuffer compiler (flatc) to be built as a library.
Change-Id: I71baff427243f96be1596b01ff3405fdf39386d7
2017-01-25 13:41:34 -08:00
gbeili
fd61d70205 minor fixes to the union vector code styles (#4149) 2017-01-25 09:34:37 -08:00
jsanmiya
4f4495a693 Merge pull request #4148 from gbeili/vector_unions
C++ Union Vector
2017-01-24 14:33:32 -08:00
Bei Li
68bbe983e9 Union Vector 2017-01-24 11:52:36 -08:00
Florin Pățan
bbef92c17d Reword comment so that code editors can mark deprecation correctly (#4147) 2017-01-23 13:40:50 -08:00
Koichi Shiraishi
25c884158f go: fix unknown field 'UOffset' to 'Pos'
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
2017-01-22 20:16:52 +09:00
Wouter van Oortmerssen
3f936c5655 More native code gen functionality.
Allow tables to be mapped to native types directly.  For example, a table
representing a vector3 (eg. table Vec3 { x:float; y:float; z:float; }) can
be mapped to a "mathfu::vec3" native type in NativeTables.  This requires
users to provide Pack and UnPack functions that convert between the
Table and native types.  This is done by adding the "native_type" attribute
to the table definition.

To support user-defined flatbuffers::Pack and flatbuffers::UnPack functions,
support a "native_include" markup that will generate a corresponding

Also add an UnPackTo function which allows users to pass in a pointer to
a NativeTable object into which to UnPack the Table.  The existing UnPack
function is now simply:

  NativeTable* UnPack() {
    NativeTable* obj = new NativeTable();
    Table::UnPackTo(obj);
    return obj;
  }

Finally, allow native types to be given a default value as well which are
set in the NativeTable constructor.  This is done by providing a
"native_default" attribute to the member of a table.

Change-Id: Ic45cb48b0e6d7cfa5734b24819e54aa96d847cfd
2017-01-18 16:23:35 -08:00
Wouter van Oortmerssen
42a265b419 Add no-op for padding variables to prevent clang compiler warning.
Change-Id: I119ee7109bfa2b0be0f468d2b2be459f45d1bb11
2017-01-18 16:17:08 -08:00
Wouter van Oortmerssen
4bc4979acc Fix compiler warning on Visual Studio.
Change-Id: Ifda5f2c32c6484508d5e12a463d6373798f1f523
2017-01-18 16:09:35 -08:00
Wouter van Oortmerssen
b095367d17 Merge branch 'master' of https://github.com/google/flatbuffers 2017-01-18 14:58:09 -08:00
Wouter van Oortmerssen
eac2905568 Fixed unions not being parsed correctly in JSON.
This would happen if they were supplied in an order that does not match
the schema relative to other fields. It now supports any ordering.

Change-Id: I9d309cd4e6e5c470f01d9d431806eba4f9f46559
Tested: on Linux.
2017-01-18 14:54:16 -08:00
Georges Savoundararadj
12fd0c6838 GenEnum: bit_flags: Remove useless conditions (#4141)
The conditions to add the "NONE" or "ANY" value in the enum were useless
because the user cannot provide a zero value or a bitmask (for "ANY") in
the bit_flags enum type.
2017-01-18 09:59:13 -08:00
Wouter van Oortmerssen
19101826a8 Fix unused field warning in clang.
Change-Id: I71d590a1e5b2709f0e2dcf97faaebda5cb918fc7
Tested: on Linux.
2017-01-13 18:30:57 -08:00
Wouter van Oortmerssen
7b94eab2b1 Add CodeWriter utility class.
Helps simplify code generation code.  Instead of this:
  code += "inline const " + cpp_qualified_name + " *Get";
  code += name;
  code += "(const void *buf) {\n  return flatbuffers::GetRoot<";
  code += cpp_qualified_name + ">(buf);\n}\n\n";

You do this:
  code.SetValue("NAME", struct_def.name);
  code.SetValue("CPP_NAME", cpp_qualified_name);
  code += "inline const {{CPP_NAME}} *Get{{NAME}}(const void *buf) {";
  code += "  return flatbuffers::GetRoot<{{CPP_NAME}}>(buf);";
  code += "}";
  code += "";

Updated the CPP code generator to use the CodeWriter class.  Most of the
changes in the generated code are white-space changes, esp. around new
lines (since the code generator class automatically appends new lines
when appending a string).  Actual code changes include:

* Renamed "rehasher" to "_rehasher" for consistency with other args in
  Pack function.

* Renamed "union_obj" to "obj: in UnPack function.

* Always do "(void)_o;" to prevent unused variable warning in Create
  function (instead of only doing it if there are no fields) in order
  to avoid two-passes.

* Renamed padding variables from __paddingX to paddingX__.
  "Each name that contains a double underscore (_ _) [...] is reserved
   to the implementation for any use."  C++ standards 17.4.3.1.2.

* Add braces around switch cases.

* Calculate index as a separate statement in EnumName function, eg.
    const size_t index = ...;
    return EnumNamesX()[index];
  vs.
    return EnumNamesX()[...];

* Stored end table offset in variable in Finish() functions, eg.
    const auto end = fbb_.EndTable(start_, ...);
    auto o = flatbuffers::Offset<T>(end);
  vs.
    auto o = flatbuffers::Offset<T>(fbb_.EndTable(start, ...));

* Separate reinterpret_cast calls from function calls in Union
  functions, eg.
    auto ptr = reinterpret_cast<const T *>(obj);
    return ptr->UnPack(resolver);
  vs.
    return reinterpret_cast<const T *>(obj)->UnPack(resolver);

* Removed unecessary (void)(padding__X) no-ops from constructors, eg.
    Test(int16_t a, int8_t b) : ... {
      (void)__padding0;  // <-- Removed this line.
    }

In the idl_gen_cpp.cpp file itself, I refactored some code generation into
new functions: GenParam, GenNativeTable, GenVerifyCall, GenBuilders,
GenUnpackFieldStatement, and GenCreateParam.

Change-Id: I727b1bd8719d05b7ce33cbce00eb58fda817b25d
2017-01-13 17:44:42 -08:00
gbeili
1a21b54560 Add a builder option to enable/disable vtables deduplication. (#4132)
* Add a builder option to enable/disable vtables deduplication.

* address code review comments
2017-01-11 10:36:18 -08:00
Pascal S. de Kloe
b55f18649a Resolve Go fmt and vet warnings (#4134)
* Resolve Go fmt and vet warnings.

* Undo generated code gofmt.
2017-01-09 17:13:44 -08:00
Wouter van Oortmerssen
e2373668d9 Merge branch 'master' of https://github.com/google/flatbuffers 2017-01-09 15:55:18 -08:00
Wouter van Oortmerssen
8c1a723ba5 Fixed GRPC method name generation.
Change-Id: I827b7e9aee1edb77752322455f7b6fafac16fb1d
Tested: on Linux.
2017-01-09 15:54:31 -08:00
Mateusz Pusz
ab7949dc16 Cold part of make_space() code moved to reallocate member function. (#4130)
Change makes make_space() code much friendlier for the compiler to inline which makes significant (measurable) performance improvements.
2017-01-09 10:10:11 -08:00
Wouter van Oortmerssen
2c4dce5ba7 Re-applied reverted fix, adding missing codegen files.
Change-Id: I301d29835fb0baffd859950eb0fb3056e4f4d66b
2017-01-04 10:41:31 -08:00
Wouter van Oortmerssen
cc84240098 Misc idl_gen_cpp cleanup
- Update to be const-correct where possible.
- Consistently pass |code| as pointer instead of non-const-ref.
- No newlines (\n) characters in the middle of code strings.
- Use if-else if-else statements instead of nested ternary operators.
- Ensure all lines end at 80 chars.
- Make utility functions static.

From cl/143505731.

Change-Id: If0fab9ee75de5af963367a948dddf53af93f73b4
2017-01-04 10:12:39 -08:00
Wouter van Oortmerssen
b29ba4c70c Updated version to 1.5
Change-Id: I34007829cdd3ad024df21f68bb369016d5d21131
2017-01-03 14:56:44 -08:00
Yonggang Li
fea6b525ee fix memory leak (#4126) 2017-01-03 13:54:15 -08:00
CarsarSky
69dc71b5ed Fix C++ gRPC test with streaming method (#4123) 2016-12-28 11:50:41 -08:00
Wouter van Oortmerssen
1a89682251 Merge branch 'master' of https://github.com/google/flatbuffers 2016-12-21 18:06:10 -08:00
Wouter van Oortmerssen
5fd0fefab6 Fixed empty structs generating illegal constructor in C++.
Change-Id: I60418d597b497c3cfa655ad76b3128351e9139f2
2016-12-21 18:04:31 -08:00
Ankur Dave
f8a964d2b0 Fix call to Verifier::VerifyBuffer from BufferRef (#4124)
3a1f776132 added a required identifier parameter
to Verifier::VerifyBuffer but did not update the templated call site in
BufferRef. This causes errors like the following when trying to instantiate the
call site by calling BufferRef::Verify():

    include/flatbuffers/flatbuffers.h: In instantiation of ‘bool flatbuffers::BufferRef<T>::Verify() [with T = MyType]’:
    MyApp.cpp:16:3:   required from here
    include/flatbuffers/flatbuffers.h:1421:37: error: no matching function for call to ‘flatbuffers::Verifier::VerifyBuffer()’
         return verifier.VerifyBuffer<T>();
                                         ^
    include/flatbuffers/flatbuffers.h:1421:37: note: candidate is:
    include/flatbuffers/flatbuffers.h:1352:29: note: template<class T> bool flatbuffers::Verifier::VerifyBuffer(const char*)
       template<typename T> bool VerifyBuffer(const char *identifier) {
                                 ^
    include/flatbuffers/flatbuffers.h:1352:29: note:   template argument deduction/substitution failed:
    include/flatbuffers/flatbuffers.h:1421:37: note:   candidate expects 1 argument, 0 provided
         return verifier.VerifyBuffer<T>();
                                         ^

This commit fixes the BufferRef call site by adding a nullptr argument.
2016-12-21 17:49:45 -08:00
Zarian Waheed
84033ae035 Added helper methods to access struct through reflection. (#4120)
* Added helper methods to access struct through reflection. Also added unit test for it.

* Added a TODO comment to check for the is_struct flag.
2016-12-21 17:48:21 -08:00
Wouter van Oortmerssen
b9efbf6a3d Fixed more Windows build errors.
Change-Id: I556e1c103e8501dc144b16c8698463253de6f4fb
2016-12-21 17:45:27 -08:00
Wouter van Oortmerssen
13194ececa Fixed Windows compiler warning.
Change-Id: I12b31227d4545a8897f638754d6a9ccd029f177e
2016-12-21 16:16:52 -08:00
wvo
9ec9303abb Go related style fixes.
Change-Id: Ie854ace69a21ef685e1ade5584f9d9ce4e8b41f1
2016-12-21 14:32:44 -08:00
Wouter van Oortmerssen
03ee3db240 Fixed Windows build errors.
Change-Id: I11548bfa3cfe307598eb59c56412974c349d614d
2016-12-19 17:04:35 -08:00
Wouter van Oortmerssen
cf825b8819 Added missing generated code from previous commits.
Change-Id: Id7053e4cb5a085a4b047c86ff1f2269329ff7f54
2016-12-19 16:28:06 -08:00
Wouter van Oortmerssen
377a8ba6b2 Merge branch 'master' of https://github.com/google/flatbuffers 2016-12-19 16:26:57 -08:00
Wouter van Oortmerssen
13cf6e66e3 Merge "Documentation improvements: style guide & guide lines." into ub-games-master 2016-12-20 00:25:31 +00:00
Wouter van Oortmerssen
81b6bacead Documentation improvements: style guide & guide lines.
Bug: 22346508
Change-Id: I3f6e6b2811adaaf9d79faca8cdd00af3927299b5
2016-12-19 16:04:08 -08:00
Wouter van Oortmerssen
e6fa14a08d Add default values (if they exist) to native tables.
From cl/142307012.

Change-Id: I54d550573f6506b92ad18e7cc90bcd8589259e52
2016-12-19 15:43:03 -08:00
Wouter van Oortmerssen
c66683f27f Add ::Set function to Unions to make memory ownership clear.
Unions own the NativeTable* value member because they need to destroy them
when the Union goes out of scope.  Currently, the data is destroyed by calling
delete, which means that the member needs to be allocated with new.  However,
making the allocation the responsibility of the client and the destruction
the responsibility of the Union can lead to potential errors.  Adding a
Set function will ensure that the memory is allocated correctly so that it
can be deleted later.

From cl/142161569.

Change-Id: I4605f26d2749164819bfae0140e5fae08442b50a
2016-12-19 15:21:08 -08:00
Zarian Waheed
6d6271db2f Changes for verifying a buffer dynamically using reflection. (#4102)
* Changes for verifying a buffer dynamically using reflection.

* Fixing build issues on linux and applied code reformatting.

* Fixing the file order in cmake file that was messing up the macro based code inclusion.

Added tests for reflection based verification.

* Changes for verifying a buffer dynamically using reflection.

Fixing build issues on linux and applied code reformatting.

Fixing the file order in cmake file that was messing up the macro based code inclusion.

Added tests for reflection based verification.

* Incorporated the code review changes that were requested:

1. Changed the Verify function signature.
2. Changed the variable names to use snake_case.
3. Added better comments.
4. Refactored duplicate code.
5. Changed the verifier class so that it has the same size when compiled with or without FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE macro.

* Setting FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE and FLATBUFFERS_DEBUG_VERIFICATION_FAILURE through cmake for flattests so that it gets propagted to all translation units of flattests.

* Making the Verifier struct fields the same in all cases. Also reverting the target_compile_definitions change in cmake file because build machine on travis does not have cmake version 3.0 or higher which was the version when target_compile_definitions was added in cmake.

* Defining macros through cmake in a portable way using functions that are available in cmake 2.8.
2016-12-16 08:46:30 -08:00
krupnov
ab76c57ec8 random access iterator for vector added (#4119)
* random access iterator for vector added

* Style changes
2016-12-16 08:37:04 -08:00
Wouter van Oortmerssen
d1e8899310 Fixed JS outputting helper for Int64Array.
Change-Id: I7d23fa3416feb78ea18d2c451e7b4e1d9be11bfc
2016-12-14 10:35:26 -08:00
Wouter van Oortmerssen
ccba2edb7c Made GRPC generator missing into a warning.
Change-Id: Iceb1f5b78cff6227905b8a23eb70e9ef6ce909ed
2016-12-14 10:32:44 -08:00
Wouter van Oortmerssen
2a7a44be33 Improving AppVeyor CI with other languages.
Change-Id: Iff630905b5f90814c5f728e3c0e10f7fcd67c7fe
2016-12-12 18:02:13 -08:00
Ricardo Quesada
6301da75d1 add weapon + equipment to json example (#4114)
update json with documentation

removed comments
2016-12-12 14:12:56 -08:00
Robert
059661b9ac Merge pull request #4112 from manolama/tweaks
Restore the ''import "unsafe'' removed in 36daedf35fd0cc2ad0e5e24d187…
2016-12-09 14:29:57 -08:00
Manolama
dc5975ba7a Restore the ''import "unsafe'' removed in 36daedf35f.
This was causing build failures with tools dependent on Flatbuffers in Go.
E.g.
go/src/github.com/google/flatbuffers/go/sizes.go:50: undefined: unsafe in unsafe.Pointer
2016-12-08 22:19:33 -08:00
Robert
0de4f3f75b Create basic issue template (#4107)
* Create basic issue template

* Update ISSUE_TEMPLATE.md
2016-12-07 14:17:30 -08:00
Robert
b59aafc659 Merge pull request #3791 from mmastrac/master
Avoid unsafe when sizing types
2016-12-07 11:51:11 -08:00
Robert
92a6ae93fa Merge pull request #3977 from gonzaloserrano/feature/go-generic-deserialitzation
Add a generic way to deserialize a flatbuffer in Go.
2016-12-07 11:17:55 -08:00
Ronak Jain
a31ddd2bb3 Support for Golang GRPC (Experimental) (#4082)
* support for grpc golang

* refactored grpc go generator

* added grpc-go test and refactored

* refactored idl_gen_grpc.cpp

* fixed grpc generate method name

* refactored flatc and fixed line length issue

* added codec to go lib and fixed formatting issues

* fixed spacing issues
2016-12-05 13:20:38 -08:00
Wouter van Oortmerssen
bc2ec7119b Adds typedefs and functions to help write generic code.
The following changes have been made to the C++ codegen to enable writing generic code
that uses the Table and NativeTable types.

- Adds TableType and NativeTableType typedefs to NativeTable and Table structs.
- Adds GetFullyQualifiedName() to NativeTables if --gen-name-strings is set.
- Adds a static Pack function to Tables that simply calls the global CreateX functions.

See cr/140391505 as an example of improved usage.

From cl/140529288.

Change-Id: Idec137c16129e15c1783f94fabdcea24aeeaaef6
2016-12-02 14:25:39 -08:00
Wouter van Oortmerssen
641b397f8b Allows structs to be stored directly as member variables.
Introduce a "native_inline" attribute that can be applied on fields that are structs.
This results in NativeTable code generation that sets the struct "inline" rather than
storing it in a pointer.

From cl/140527470.

Change-Id: I208724f552b8b921b20923e0bf82f42cb3582416
2016-12-02 14:25:08 -08:00
Wouter van Oortmerssen
d342918790 Merge branch 'master' of https://github.com/google/flatbuffers
Change-Id: I02b00b22cdd2d1bd32de3273ff69185c9b0f4e5b
2016-11-21 15:20:33 -08:00
The Gitter Badger
c4377390a8 Add Gitter badge (#4075) 2016-11-18 11:42:50 -08:00
benssson
5608be0f96 Fixed javascript helper for typed arrays of scalars not taking into (#4068)
account underlying buffer's byte offset.
2016-11-18 11:42:50 -08:00
Antoine Descamps
dbecdf209d [PHP] Use mb_detect_encoding when available (#3952)
I've faced an issue where I want to serialize UTF-8 emojis and FlatBufferBuilder::is_utf8 would return false on them.
I was not able to add the corresponding hexadecimal code because I don't understand how the whole thing works but what i've done is using the `mb_detect_encoding` function which handles correctly all supposed UTF-8 characters.
2016-11-16 09:54:57 -08:00
garretmcgraw
c05803bf96 Making flatbuffers JSON parsing deal with unexpected null values when unknown JSON is allowed. (#4083) 2016-11-09 14:38:48 -08:00
Michael Paulson
d298adc4e6 chore(lint) (#4079)
* chore(lint)

I accidentally let 2 pieces of lint in with my generated code.

* fix(generate-code): I did not generate all the required code for tests.
2016-11-07 10:27:26 -08:00
Wouter van Oortmerssen
c2050aa0e3 Merge branch 'master' of https://github.com/google/flatbuffers 2016-11-07 10:09:42 -08:00
Wouter van Oortmerssen
290e9f270b Fixes to support GCC 4.4.7
Fixed generation of a trailing comma and removed unnecessary use of a lambda.

Change-Id: I9993f6eb83e2ebc36fc40295a2059c340c1fbe03
Tested: on Linux.
2016-11-07 09:51:28 -08:00
The Gitter Badger
76ae10df42 Add Gitter badge (#4075) 2016-11-02 14:05:31 -07:00
benssson
cf0d7829a6 Fixed javascript helper for typed arrays of scalars not taking into (#4068)
account underlying buffer's byte offset.
2016-10-26 10:29:36 -07:00
Wouter van Oortmerssen
af21b9064d Change docs to not encourage use of 1 byte buffers.
Change-Id: Ib0b1692044f35e374a0f7c0359c94319f4a25619
2016-10-24 10:29:09 -07:00
Wouter van Oortmerssen
e31fbb0b23 Fixed STLPort error for missing vector::data()
Change-Id: I06fb61edf018adf0f26a81de4596b4972226e466
Tested: on Android.
Bug: 30263829
2016-10-21 17:35:41 -07:00
Wouter van Oortmerssen
43ba7c6369 Merge branch 'master' of https://github.com/google/flatbuffers 2016-10-21 16:57:50 -07:00
Wouter van Oortmerssen
dae513e0e7 Made nesting vs inline clearer in the docs.
Also fixed structs not being created inline in the tutorial,
which would actually have bad consequences if used.

Change-Id: Idce215c61a1b24a297cee76f625052bb2722e970
2016-10-21 15:22:14 -07:00
cajun-rat
d8944e45a2 Fix Closure Compiler warnings (#4067)
* Make parameter order in jsdocs match function

When the order doesn't match the Google Closure Javascript compiler generates
warnings

* Prefix optional parameters with opt_

The Closure Compiler emits warnings when this isn't the case
2016-10-21 14:52:42 -07:00
Baptiste Lepilleur
5b5fcbfc00 Java: fix unsigned default value code generation and add 'L' suffix for long default value (#4051)
* Java: emit "signed" equivalent of unsigned default value in generated code and add "L" suffix to long default value.

* Updated generated code

* Only convert ulong to "signed" equivalent. ubyte and ushort don't need specific handling as "user facing" type is int. uint need 'L' suffix as "user facing" type is long.

* Added missing cast to primitive type of default value which is in "user facing" type in builder.add<type>() calls.

* Do not cast default value to actual type in C#.
2016-10-21 14:27:15 -07:00
Wouter van Oortmerssen
6862b2ff08 Added functionality to obtain a buffer pointer from a root.
Change-Id: Ia63e41d0304e8668ea4ce09a4c31dd999eb96994
Tested: on Linux.
Bug: 32218623
2016-10-19 16:24:24 -07:00
Wouter van Oortmerssen
22e87071dd Fixed lambda return value error on VS2010.
Change-Id: I6d0e8469bfa5b4c8a3f1cb119e186f4cf62c76ae
2016-10-17 15:04:12 -07:00
Wouter van Oortmerssen
606098cac8 Fixed unused variable warnings, and made sure they are on.
Tested on Linux.

Change-Id: Ie18d6857f9ae8b1c3953a116203b4a8bb70a2ede
2016-10-17 13:06:11 -07:00
Wouter van Oortmerssen
b5c622762b Fixed broken traits codegen for --scoped-enums.
Change-Id: I5f538d12ea37d11d2e239ddde32eefcdd91e347b
Tested: on Linux.
2016-10-17 11:53:28 -07:00
Wouter van Oortmerssen
2beb985fcc Merge branch 'master' of https://github.com/google/flatbuffers 2016-10-17 10:46:14 -07:00
Zhe Wang
fd97404c51 Add missing include (#4052) 2016-10-17 09:57:46 -07:00
Wouter van Oortmerssen
d9fe4e2769 Allow other pointer types than unique_ptr for object API.
Change-Id: I945890ce667a2f5a6c0495e78fd5326ed33b9914
Tested: on Linux.
Bug: 30135763
2016-10-17 09:54:52 -07:00
Wouter van Oortmerssen
424fc0c3ac Fixed inconsistent use of namespace directory prefixing.
Change-Id: I2cab7a1f68b8e643c1057e0a366572421a94ed41
Tested: on Linux.
2016-10-12 16:05:57 -07:00
Wouter van Oortmerssen
c81239f6ea Fix lambda compilation error in VS.
Change-Id: I814008b6eeffec9bd4b8810e4b29db9ea6218bb8
2016-10-12 14:51:02 -07:00
Wouter van Oortmerssen
b830dac266 Added missing generated code files.
Change-Id: Ifb977411b65f8721cf9db891d7a62798bd593c0c
2016-10-12 14:40:35 -07:00
Wouter van Oortmerssen
dc38f93ca8 Merge branch 'master' of https://github.com/google/flatbuffers 2016-10-12 14:39:36 -07:00
Wouter van Oortmerssen
f9025eeb52 Clarified tutorial w.r.t reading/writing buffers.
Bug: 30736848

Signed-off-by: Wouter van Oortmerssen <wvo@google.com>
2016-10-12 14:30:31 -07:00
Wouter van Oortmerssen
486c048a0d Added support for size prefixed buffers.
These are useful for streaming FlatBuffers. The functionality
ensures proper alignment of the whole buffer.

Tested: on OS X.
Bug: 27123865

Change-Id: Ic7d75a618c1bb470ea44c4dcf202ff71f2b3f4f1
Signed-off-by: Wouter van Oortmerssen <wvo@google.com>
2016-10-12 14:30:31 -07:00
Wouter van Oortmerssen
ab51b03093 Fixed line numbers being off in multi-line comments.
Change-Id: I4c27892c249527980d8f52a2cca801dace70289f
2016-10-12 11:22:20 -07:00
Wouter van Oortmerssen
dc2fa215b8 External references for the object API thru a resolver function.
This allows hashed string fields to be used for lookup of any
C++ objects, a pointer to which are then stored in the object
besides the original hash for easy access.

Change-Id: I2247a13c349b905f1c54660becde2c818ad23e97
Tested: on Linux.
Bug: 30204449
2016-10-12 11:22:20 -07:00
Baptiste Lepilleur
199157e8f4 flatc java generator: namespace_test2.fbs is missing namespace prefix for referToA2() return type (#4040)
* Fix flatc generating incorrect java/c# code for namespace_test2.fbs. In code for TableInC, method referToA2() returned type SecondTableInA instead of NamespaceA.SecondTableInA.

* Updated generated code.

* Fixed indendation.
2016-10-07 09:42:29 -07:00
Andrew Hundt
520d68449f CMake now accepts external toolchain configuration (#4045)
Resolves #4038
Related to https://github.com/ruslo/hunter/pull/529
2016-10-05 13:20:30 -07:00
jbrads
b075b8c49d Generate type traits for unions to map a type to the corresponding u… (#4032)
*  Generate type traits for unions to map a type to the corresponding union enum value.

* Fixed break with union enum type traits when type is in a namespace.

* Fixed spacing and variable names in type traits generation to match style guidelines.

*  Fixed spacing in type traits generation to match style guidelines.

* Regenerated test schema header.
2016-10-03 14:14:25 -07:00
Wouter van Oortmerssen
f6c1a1ebcf Merge pull request #4025 from paszea/reflection_fqn
serialize fully qualified struct & enum name in schema binary
2016-09-21 11:06:34 -07:00
Wouter van Oortmerssen
c4aede2268 Merge pull request #4027 from kimsin3003/csharp
Added IFlatbufferObject.cs file to project for .net.
2016-09-19 10:02:50 -07:00
FTT\kimsin
4a43c2bb2c Added IFlatbufferObject.cs file to project for .net.
Before edition, IFlatbufferObject.cs file wasn't in the project and building the project throwed error.
2016-09-19 16:16:15 +09:00
Jason Sanmiya
b2e55c556e Merge "Fix Windows warnings." into ub-games-master 2016-09-15 18:42:42 +00:00
Xun Liu
df0991b7de serialize fully qualified struct & enum name in schema binary 2016-09-15 10:42:23 -07:00
Wouter van Oortmerssen
3368407aff Add a --conform-includes flag to specify include path for the conform schema
(mirrored from cl 133146933)

Change-Id: I61385289728777cae83139fef0229001d92382ca
2016-09-14 11:39:33 -07:00
Wouter van Oortmerssen
25f3f358a0 Merge pull request #4021 from mogemimi/remove-extra-semi
Remove extra semicolon
2016-09-14 09:18:40 -07:00
mogemimi
00e8aa87b3 Remove extra semicolon 2016-09-13 20:59:57 +09:00
Wouter van Oortmerssen
09ee46a83e Merge pull request #4020 from albertofem/feature/allow_public_accessor_net
Allow access to underlying ByteBuffer in C#
2016-09-12 10:35:16 -07:00
Alberto Fernández
02dfa64a89 Allow access to underlying ByteBuffer 2016-09-12 09:35:08 +02:00
Wouter van Oortmerssen
f136570417 Merge pull request #4004 from sahiljain/fix-3909
Return error when full string cannot be parsed into int
2016-09-09 17:01:05 -07:00
Sahil Jain
b6ba322a04 Return error when full string cannot be parsed into int 2016-09-09 19:47:20 -04:00
Wouter van Oortmerssen
4b79ff5351 Merge pull request #4017 from changnet/master
option to build shared library,defeault off
2016-09-09 16:21:27 -07:00
Wouter van Oortmerssen
edd77ae2f3 Merge pull request #4010 from rgilles/master
Isolate the complied Java classes into a target folder.
2016-09-09 15:28:37 -07:00
Jason Sanmiya
985de211af Fix Windows warnings.
Cmake issued a warning when the variable is in quotation marks
in an if statement.

Visual Studio upgrades constants to int and issues a truncation
warning, so inserted a cast.

Change-Id: I60cdcb5c2565cd5e97f80b9c2ff1e6abc32b1deb
Tested: Builds without warning on VS2015.
2016-09-09 14:51:33 -07:00
Wouter van Oortmerssen
8e3fa336eb Merge pull request #3998 from aardappel/master
Switched C# accessors from classes to structs
2016-09-07 16:59:42 -07:00
Romain Gilles
582fd90c4a Use the find -exec instead of find ... | xargs otherwise when there is error log in the output of the build. 2016-09-06 23:28:22 +02:00
changnet
a15659e9f8 option to build shared library,defeault off 2016-09-07 01:12:04 +08:00
Romain Gilles
afd230af8d Remove commented line. Add a last step that remove the target folder after the build and the tests execution. 2016-09-01 13:01:07 +02:00
Wouter van Oortmerssen
52ca75506a Switched C# accessors from classes to structs 2016-08-31 17:34:51 -07:00
Romain Gilles
3bb9b839b8 Add remove of remaining class files before running the build 2016-08-30 10:18:47 +02:00
Romain Gilles
5e7bfd0461 Isolate the complied Java classes into a target folder + log java version.
It is a common practice to put all the compiled classes into a
dedicated folder in order to:
 - avoid to mix the code and the complied classes
 - to allow a simple way to remove the complied classes

Add log of java version in order to make it explicit to the end user.
2016-08-29 11:26:31 +02:00
Wouter van Oortmerssen
d05d114523 Merge pull request #4007 from TGIshib/key
lookupByKey corrections
2016-08-26 15:26:40 -07:00
TGIshib
722b903f89 Remove languages check 2016-08-27 01:21:15 +03:00
TGIshib
2ff6152204 Update idl_gen_general.cpp 2016-08-27 00:42:06 +03:00
TGIshib
98f9af8ecc Merge remote-tracking branch 'refs/remotes/google/master' into key
# Conflicts:
#	src/idl_gen_general.cpp
2016-08-27 00:35:06 +03:00
Wouter van Oortmerssen
481d332e72 Fixed compile error in LookupByKey fix.
Change-Id: Ice94f09197235cf71b41a22d0767bd7b119284e1
2016-08-26 14:18:04 -07:00
TGIshib
1a18122e3f Last idl_gen_general.cpp update 2016-08-27 00:04:25 +03:00
Wouter van Oortmerssen
ee56418cef Undo compile Java classes into target folder.
This was causing class loader errors on Java 1.6.

Change-Id: Id1d9e7e369aad639115664c43a867c4d3a82f9f1
Tested: on Linux.
2016-08-26 14:02:00 -07:00
Wouter van Oortmerssen
e1f8037cb5 Fixed Java LookupByKey functionality for Java 1.6
Tested: on Linux.

Change-Id: Iea336f75a3b6e722743563813c3c9ed9db4d02fe
2016-08-26 13:58:16 -07:00
TGIshib
ea9ee4c99e Update idl_gen_general.cpp 2016-08-26 23:47:23 +03:00
TGIshib
4026117ba1 Correct idl_gen_general 2016-08-26 23:15:25 +03:00
Wouter van Oortmerssen
49ee30a207 Merge pull request #3978 from TGIshib/key
Find by key on C# and Java (2)
2016-08-26 12:03:28 -07:00
TGIshib
7c69c5dc3d Fix lookupByKey, improve compareStrings 2016-08-26 19:41:32 +03:00
Wouter van Oortmerssen
223ebebbeb Merge pull request #4003 from rgilles/master
Isolate the complied Java classes into a target folder.
2016-08-26 09:22:29 -07:00
Romain Gilles
f96eb472b3 Isolate the complied Java classes into a target folder.
It is a common practice to put all the compiled classes into a
dedicated folder in order to:
 - void to mixing the code and the complied classes
 - to allow a simple way to remove the complied classes
2016-08-25 10:40:41 +02:00
Wouter van Oortmerssen
c1b0abe079 Merge branch 'master' of https://github.com/google/flatbuffers 2016-08-24 18:07:18 -07:00
Wouter van Oortmerssen
b04e21db16 Fixed --scoped-enums not always generating type prefixes.
Change-Id: Ib5b0ae75617e18094ac31eb5e11d10e5d592cf9b
Tested: on Linux.
2016-08-24 18:05:49 -07:00
Wouter van Oortmerssen
756050b62c Fixed "unknown command-line argument" output format.
Change-Id: Idd49bc61118c29d6d7364d2cd54a6f7932917570
2016-08-24 17:09:25 -07:00
Wouter van Oortmerssen
ef67a58410 Merge pull request #4001 from vitalyisaev2/master
Debianization with CPack
2016-08-24 15:03:31 -07:00
Wouter van Oortmerssen
2da0821286 Merge pull request #3994 from royalharsh/python_grpc
Initial grpc support for other languages
2016-08-24 14:59:32 -07:00
Vitaly Isaev
928effd198 Debianization with CPack 2016-08-25 00:00:22 +03:00
Harsh Vardhan
2e7806ede0 Initial support to add other languages to flatbuffers 2016-08-24 23:42:59 +05:30
Wouter van Oortmerssen
67967476b2 Merge pull request #4000 from sahiljain/fix-3966
Remove Struct::GetPointer() useless method
2016-08-24 10:34:32 -07:00
Wouter van Oortmerssen
79d127c863 Merge pull request #2133 from evolutional/cs-bounds-check
C#: added #define BYTEBUFFER_NO_BOUNDS_CHECK
2016-08-24 09:26:06 -07:00
Sahil Jain
4f3e1c2831 Remove Struct::GetPointer() useless method 2016-08-24 04:12:25 -04:00
gonzaloserrano
199a49b5b3 Add a generic way to deserialize a flatbuffer in Go.
Similar to what protobufs does with its `Message` interface, introduce here such interface and create a generic `GetRootAs` method to deserialize a flatbuffer.
2016-08-23 16:38:22 +02:00
Wouter van Oortmerssen
96ab6ade5a Merge pull request #3993 from bhamiltoncx/generate-text-failure
Allow GenerateText() to indicate failure to encode flatbuffer to JSON
2016-08-22 11:32:52 -07:00
TGIshib
9f16090f90 Improve LookupByKey , update docs 2016-08-22 18:10:52 +03:00
Robert
63b240ec7b Merge pull request #3995 from rw/go-remove-unused-initializer
Remove invalid vector item heap alloc
2016-08-20 22:07:10 -07:00
rw
c4ba502f57 Remove invalid vector item heap alloc
Fixes #3986
2016-08-20 20:33:36 -07:00
Ben Hamilton
94d5643f97 Allow GenerateText() to indicate failure to encode flatbuffer to JSON (i.e., non-UTF-8 string data) 2016-08-18 10:23:26 -07:00
Wouter van Oortmerssen
f0d91fa143 Merge pull request #3992 from akazakov/master
Add byte array and unintialized array creation to FlatBufferBuilder
2016-08-17 09:03:46 -07:00
Artem Kazakov
726a5f523e add byte array and unintialized array creation to FlatBufferBuilder 2016-08-16 16:26:53 -04:00
Wouter van Oortmerssen
eba6b6f7c9 1.4 prep fixes
Change-Id: I001ad8dd5f95e6e5ad43daf956663218d19f5c96
2016-08-15 17:29:35 -07:00
TGIshib
fa74ce6d16 Update idl_gen_general.cpp 2016-08-15 13:30:30 +03:00
TGIshib
8fdced4e11 Update 2016-08-14 14:58:51 +03:00
TGIshib
9031597f49 Merge remote-tracking branch 'refs/remotes/google/master' into key 2016-08-13 16:28:38 +03:00
Wouter van Oortmerssen
a0b8f669ee Added "Direct" suffix to vector/string object creation functions.
They were overloaded, but also had default arguments, so would
become ambiguous when used with few arguments.

Change-Id: Ifac7f3ea3a6391d971dfeda8e33129c8c38d6f12
Tested: on Linux.
2016-08-12 11:12:12 -07:00
Wouter van Oortmerssen
18d67ed83b Clarified in the docs how to get to the serialized bytes.
This was a frequent source of confusion, since in all implementations
the data doesn't start at offset 0 in the buffer.

Change-Id: I045966e65928e9acd9def84e215914ecb5510653
2016-08-10 17:53:40 -07:00
Wouter van Oortmerssen
205ddb175f Added union namespacing test case.
Change-Id: I9a4f90889c311c454a9c19e78c7db3c79800b44e
Tested: on Linux.
2016-08-10 11:52:09 -07:00
Wouter van Oortmerssen
be908939da Fixed __builtin_bswap16 not being available on GCC <4.8
See e.g. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52624

Change-Id: Idae99196c47e015a2ba2416aaf1526f77498ce5d
2016-08-10 10:49:17 -07:00
Wouter van Oortmerssen
c96fc7fcef Added missing generated code from previous commits.
Change-Id: Ie2f1f65be451979d9f8d4da999b1c10737e867af
2016-08-08 12:18:07 -07:00
Wouter van Oortmerssen
026c6ddb17 Merge branch 'master' of https://github.com/google/flatbuffers 2016-08-08 12:17:10 -07:00
Wouter van Oortmerssen
3eebba789f Fixed incorrect generated code on convenient vector constructors.
Change-Id: Ib283eade157a436e0f3ca0e68d74e7dc6c51c65b
2016-08-08 12:16:10 -07:00
Robert
b36bd67b39 Merge pull request #3976 from gonzaloserrano/fix/gofmt
Make most of the Go code comply with gofmt (except enums).
2016-08-03 17:41:10 -04:00
TGIshib
dc7f5bc0d8 Remake 2016-08-03 13:29:50 +03:00
gonzaloserrano
ec20233fab Make most of the Go code comply with gofmt (except enums).
Enums are not fixed because depending on they have comments or not they
will be aligned alogn the asssignment character.
2016-08-02 18:21:47 +02:00
TGIshib
867dfc5957 Merge remote-tracking branch 'refs/remotes/google/master' 2016-08-02 12:41:20 +03:00
Wouter van Oortmerssen
73d5bf46b4 Merge pull request #3975 from bhamiltoncx/validate-utf8
Allow Unicode values > U+FFFF in string literals, validate UTF-8 by default
2016-08-01 15:06:23 -07:00
Ben Hamilton
f6416d8471 Validate UTF-8 by default when parsing IDL. Support Unicode values > U+FFFF in parse 2016-08-01 14:05:24 -07:00
TGIshib
52acb4b347 Merge remote-tracking branch 'refs/remotes/google/master' 2016-07-31 17:08:25 +03:00
Wouter van Oortmerssen
d70f5ac6b0 Added backwards compatible --no-union-value-namespacing
Change-Id: Ia78dd3b0f213e9ffa49dcec699dcbb21fe6517da
Tested: on Linux.
2016-07-29 11:35:08 -07:00
Wouter van Oortmerssen
c9b9fd0407 Merge remote-tracking branch 'mbp/mutable-js' into ghfix 2016-07-29 11:32:00 -07:00
Caleb Epstein
6897bb99bb Use fully qualified names of structs in UnPack 2016-07-28 15:22:29 -04:00
TGIshib
4c861daa3e Merge remote-tracking branch 'refs/remotes/google/master' 2016-07-28 21:58:45 +03:00
Caleb Epstein
c9ee9fb99d Merge branch 'master' of https://github.com/google/flatbuffers
* 'master' of https://github.com/google/flatbuffers:
  Added AppVeyor CI.
  Removed pre-made VS2010 and XCode projects.
2016-07-28 08:33:35 -04:00
Caleb Epstein
50e13ef9c6 Need unique_ptr.get not pointee.get 2016-07-28 08:31:19 -04:00
Wouter van Oortmerssen
f624065eaa Added AppVeyor CI.
Change-Id: I01cf630026e25382b585785b471bad21153338f6
2016-07-27 18:38:27 -07:00
Wouter van Oortmerssen
03adfa7b1a Merge branch 'master' of https://github.com/google/flatbuffers 2016-07-27 17:20:35 -07:00
Wouter van Oortmerssen
97a9a82324 Removed pre-made VS2010 and XCode projects.
CMake is now required on all platforms.

Change-Id: Iad81d9244a05ed70ce8b8860d6b729a873f137c1
Tested: on Windows and OS X.
2016-07-27 17:10:37 -07:00
Wouter van Oortmerssen
307694e397 Merge pull request #3965 from Bklyn/master
Fix docs for object API usage
2016-07-27 13:41:22 -07:00
Michael Paulson
d268d11ca2 feat(test): Added mutation testing for scalar values.
This is a port of the tests found in test.cpp
2016-07-27 13:32:53 -07:00
Caleb Epstein
094f4d1bad Fix docs for object API usage 2016-07-27 16:15:55 -04:00
Wouter van Oortmerssen
a0398ce0f5 Merge branch 'master' of https://github.com/google/flatbuffers 2016-07-27 12:29:21 -07:00
Jason Sanmiya
30c07f4e55 Fix Mac build.
The new line in the set(CMAKE_CXX_FLAGS...) line was getting insert
verbatim into the Makefile. Makefiles don't like new lines in their
assignment operators.

The newline escape fix works for CMake 3.0 and above, but since
we support 2.x, we need to use the legacy solution, which is to
split into two separate statements.

Tested: cmake -G"Unix Makefiles" works now on Mac.
Change-Id: I6f4655981b85087c4760c3d26ed0c97c4469ba93
2016-07-26 07:26:25 -07:00
Robert
fc19f746b0 Merge pull request #210 from splhack/add_enumnames_to_go
Add EnumNames to Go code
2016-07-25 20:44:33 -07:00
Michael Paulson
a351124cfd chore(generate-code): Generate the JS code after mutation has been added. 2016-07-25 20:00:22 -07:00
Michael Paulson
0230a7173f feat(mutable-js): The mutable Scalar generation.
This is just the initial commit to start the conversation on adding mutation to javascript.
2016-07-25 20:00:22 -07:00
Kazuki Sakamoto
5f351a35a2 Add EnumNames to Go code
Tested: on Darwin
2016-07-25 19:37:16 -07:00
Wouter van Oortmerssen
2d427e0502 Pulled out EndianSwap into its own function.
Change-Id: I4a587102db8c435b739c92b6c464c94c4ea1fe42
2016-07-25 16:26:50 -07:00
Wouter van Oortmerssen
1bba4fd9ea Fixed reflection.h not modifying certain table configurations.
It would write 64bits offsets instead of 32bit ones, and update
the vtable pointer before the fields were processed.

Change-Id: I0c0fa942bbd3b42839294f5653ba8fa048612624
Tested: on Linux.
2016-07-25 15:01:37 -07:00
Wouter van Oortmerssen
f98870715a Adding missing generated code from recent commits.
Also updated generated_code.sh to prevent this from happening in
the future.

Change-Id: Ib282e9b6c762a79d4b4e09bee06b14781cd2a4c1
2016-07-25 15:01:37 -07:00
TGIshib
b7a26d73ee Merge remote-tracking branch 'refs/remotes/google/master' 2016-07-26 00:07:23 +03:00
Raman
1ba4d3c4c7 Update idl_gen_general.cpp 2016-07-25 23:04:01 +02:00
Wouter van Oortmerssen
f61f0449c7 Merge pull request #3935 from kazimuth/jsns
Add @namespace annotation to namespaces in javascript
2016-07-25 10:47:46 -07:00
Raman
06c1ad5a73 Merge pull request #3 from TGIshib/key
Update idl_gen_general.cpp
2016-07-23 15:17:28 +03:00
Raman
38b3893211 Update idl_gen_general.cpp 2016-07-23 14:16:30 +02:00
Wouter van Oortmerssen
42e0b02149 Fixed missing \ in CMakeLists.txt that broke the build 2016-07-22 15:46:26 -07:00
Robert
a56c6e5195 Merge pull request #363 from danring/fix-341
Emit GetRootAs methods for all types in Go and Python
2016-07-22 15:12:35 -07:00
Wouter van Oortmerssen
5efa22447e Fixed conversion warning in generated code. 2016-07-20 18:17:33 -07:00
Wouter van Oortmerssen
bdd668df7b Fixed VS2010 build 2016-07-20 18:13:11 -07: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
77e9122681 Merge "This is a minimal amount of #ifdef's to make stlport work." into ub-games-master 2016-07-21 00:55:05 +00:00
Wouter van Oortmerssen
e067040375 Fixed unused parameter warning.
Change-Id: I7a2576c6f366b89ef3e1f83941f90294ca7a07fd
2016-07-20 17:52:41 -07:00
Wouter van Oortmerssen
370e101a69 Added missing Go generated files.
Change-Id: I9d738e84ab2e01ec117c825ade44cc865cf5f1c2
2016-07-20 17:43:03 -07:00
Wouter van Oortmerssen
91f5cf357c Merge branch 'master' of https://github.com/google/flatbuffers into grpc2 2016-07-20 17:41:36 -07:00
Wouter van Oortmerssen
7c7c571bbe This is a minimal amount of #ifdef's to make stlport work.
Minimal, in the sense that this will only allow flatbuffers.h +
generated code to work. Everything else (tests, parsing, reflection
etc.) may still not compile with stlport.

Functionality has been reduced, some utility functions are not
available.

Tested: on Linux (no stlport), Android (stlport).

Change-Id: I3f8b6a88258c07d78964dd455fb9f99f65266301
2016-07-20 17:29:47 -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
46bf9f5177 Merge pull request #259 from kadirahq/golang-mutators
(Go) Add setter methods for scalar values.
2016-07-20 10:51:30 -07:00
Wouter van Oortmerssen
694725beb0 Xcode fixes 2016-07-20 10:48:37 -07:00
Wouter van Oortmerssen
ce3e7fbd72 VS2010 fixes 2016-07-20 10:41:26 -07:00
Muhammed Thanish
53e9606ea2 Implement mutators for Go 2016-07-20 22:58:22 +05:30
Wouter van Oortmerssen
ffc0d6209a Merge pull request #3954 from yakiro/master
fixed ArrayOutOfBoundsException in java example
2016-07-20 10:01:32 -07:00
Wouter van Oortmerssen
9fdb6dcf1f Merge pull request #3951 from devantoine/patch-2
[PHP] Fix typo
2016-07-20 09:40:50 -07:00
Yakir Buskilla
298dd21ec8 fixed ArrayOutOfBoundsException in java example 2016-07-20 10:46:43 +03:00
Antoine Descamps
64fa8ba9a9 Fix typo
Related to https://github.com/google/flatbuffers/pull/3904#issuecomment-224724181
2016-07-19 12:22:37 +02:00
Matt Mastracci
36daedf35f Avoid unsafe when sizing types 2016-07-18 18:48:39 -06:00
Wouter van Oortmerssen
a8d2eeee34 Merge pull request #3904 from devantoine/patch-1
Fix typo
2016-07-18 17:35:43 -07:00
Wouter van Oortmerssen
e21a61d458 Merge pull request #3902 from rgilles/master
Create a maven like project structure for java development + OSGi + generation for test
2016-07-18 14:13:36 -07:00
Wouter van Oortmerssen
410fb15a07 Merge pull request #3915 from Lakedaemon/clangFormat
clang formating header and code generators for cpp, general, js, php
2016-07-18 14:12:03 -07:00
Wouter van Oortmerssen
a69b19fa8f Merge pull request #3948 from mortonfox/patch-1
Fix link to CONTRIBUTING
2016-07-18 11:12:43 -07:00
Morton Fox
58924538a3 Fix link to CONTRIBUTING 2016-07-16 00:26:50 -04:00
lakedaemon
e750268f0c clang formating cpp code generator and add missing generated classes 2016-07-15 16:08:59 +02:00
lakedaemon
0328dedab5 clangFormating base class 2016-07-15 15:21:09 +02:00
Romain Gilles
9605dc5981 Added OSGi header generation for maven project.
This allow jar generated with maven to be used in OSGi environment.
2016-07-15 14:34:56 +02:00
Romain Gilles
00694d271e Merge branch 'master' of github.com:google/flatbuffers 2016-07-15 14:27:31 +02:00
Wouter van Oortmerssen
b22db6e8eb Merge pull request #3905 from bog-dan-ro/master
Verifier computes the buffersize, useful when streaming multiple flatbuffers
2016-07-14 10:55:22 -07:00
Wouter van Oortmerssen
14e7e8260e Merge pull request #3939 from TGIshib/hex-bug
Fixed bug with negative hex constants (2).
2016-07-14 10:47:34 -07:00
BogDan Vatra
3a1f776132 Verify everything in one shot 2016-07-14 20:16:07 +03:00
BogDan Vatra
4b53762cf2 Verifier computes the buffersize, useful for streaming
Close #3898
2016-07-14 20:15:44 +03:00
Raman
0d56276102 Update test.cpp 2016-07-14 18:51:23 +02:00
Raman
98c7a0c169 Update test.cpp 2016-07-14 10:30:06 +02:00
Raman
676f0712fd Update test.cpp 2016-07-14 10:01:08 +02:00
Wouter van Oortmerssen
7a3f1cf78e Merge pull request #3943 from bog-dan-ro/crash
Don't crash if str is null
2016-07-13 11:17:12 -07:00
BogDan Vatra
49c10bc219 Don't crash if str is null
Is useful especially when we want to create a string from another message string that might be null.
2016-07-13 21:04:26 +03:00
Wouter van Oortmerssen
df9990acf5 Merge pull request #3940 from rushabhy/patch-1
Rename CONTRIBUTING to CONTRIBUTING.md
2016-07-13 10:00:56 -07:00
Rushabh Yapuram
3d7b1a32a3 Rename CONTRIBUTING to CONTRIBUTING.md 2016-07-13 07:57:36 +05:30
Raman
db99c1aa64 Update test.cpp 2016-07-12 19:55:35 +02:00
Raman
247388a20c Merge pull request #2 from TGIshib/hex-bug
Fixed bug with negative hex constants (2).
2016-07-12 20:52:16 +03:00
Raman
f6f88e567e Update idl_parser.cpp 2016-07-12 19:47:53 +02:00
Wouter van Oortmerssen
e527b992f9 Merge pull request #3923 from daksenik/master
Fixed operator++. Added CreateXXX for vector types.
2016-07-11 10:55:17 -07:00
daksenik
aade31b263 Fixed spaces. Removed redundant == nullptr. Vectors pointers made const. 2016-07-11 20:27:38 +03:00
Wouter van Oortmerssen
e733d95e66 Merge pull request #3924 from TGIshib/master
Added --escape-proto-identifiers command-line option.
2016-07-11 09:47:31 -07:00
Wouter van Oortmerssen
14bdce41fe Merge pull request #3931 from jonathantullett/java_public_access
Fix for issue #3922
2016-07-11 09:20:43 -07:00
James Gilles
4a49493e27 js:add @namespace annotation to namespaces 2016-07-11 01:40:38 -04:00
Raman
df5575de17 Update idl_gen_fbs.cpp 2016-07-09 13:33:30 +02:00
Raman
f0b2cc8f6e Update flatc.cpp 2016-07-09 13:32:45 +02:00
Raman
5f2b4e7872 Update idl_parser.cpp 2016-07-09 12:57:07 +02:00
Raman
22697722d9 Update test.cpp 2016-07-09 12:51:06 +02:00
Raman
ffbc93526e Update flatc.cpp 2016-07-09 12:47:14 +02:00
Raman
d9d47a53bd Update idl_gen_fbs.cpp 2016-07-09 12:40:50 +02:00
Raman
71d30d5c02 Update idl.h 2016-07-09 12:28:02 +02:00
daksenik
1661f3a2e8 Added function GenSimpleParam. Tests added. 2016-07-09 13:00:21 +03:00
Jonathan Tullett
d9767b8315 Fix for issue #3922
Also, clean up redundant ';' at end of java classes.
2016-07-09 09:16:26 +01:00
Wouter van Oortmerssen
193a631708 Merge pull request #3929 from Lakedaemon/fixForMake
same fix for general code generator
2016-07-08 14:24:08 -07:00
lakedaemon
a6764b9bf1 same fix for general code generator 2016-07-08 22:54:51 +02:00
Wouter van Oortmerssen
0f5dc152b8 Merge pull request #3928 from Lakedaemon/fixForMake
Fix for make
2016-07-08 13:37:05 -07:00
lakedaemon
8e1aae0fd6 fix missing space (clang format) 2016-07-08 22:02:47 +02:00
lakedaemon
084e5dbc4b fixed initialization of member var for old make (hopefully) 2016-07-08 22:00:15 +02:00
daksenik
dfbda986d7 New CreateXXX (with vectors and strings) calls old CreateXXX (with offsets). 2016-07-08 12:35:57 +03:00
Raman
248432b92d Update idl_gen_fbs.cpp 2016-07-05 23:23:17 +02:00
Raman
f738981ed5 Update idl_gen_fbs.cpp 2016-07-05 22:26:21 +02:00
Raman
4bb6ab3cd5 Update flatc.cpp 2016-07-05 22:24:21 +02:00
Raman
72e8219a65 Update idl_parser.cpp 2016-07-05 22:20:57 +02:00
Romain Gilles
7a955a09f4 Move maven pom.xml from the java folder to the root folder.
This avoid to put the pom.xml file into the source directory. Normally the pom file is in a parent (/parent) folder and it is not mixed with the java source code.
An other thing is: this will make import of the project more easy from a IDE.

The side effect is that the target folder where maven build artifacts will move from the <flatbuffers>/java/target to <flatbuffers>/target therefore the gitignore file has been updated in consequences.
2016-07-05 14:29:12 +02:00
Romain Gilles
b730a74a19 Merge branch 'master' of github.com:google/flatbuffers 2016-07-05 11:40:33 +02:00
Romain Gilles
cc2b04ce1c Revert "Create a maven like project structure for java development. Make it OSGi compliant. Generate the flatbuffers code for testing (example)."
This reverts commit 9875b0e0f8.
2016-07-05 11:38:17 +02:00
Raman
4f8abaaf10 Update flatc.cpp 2016-07-04 22:58:58 +02:00
Raman
5043764247 Update test.cpp 2016-07-04 21:55:44 +02:00
Raman
9fd4d66438 Update flatc.cpp 2016-07-04 21:51:34 +02:00
Raman
aae48e3a9d Update idl.h 2016-07-04 21:41:01 +02:00
Raman
ff57f52b72 Update flatc.cpp 2016-07-04 21:37:50 +02:00
Raman
7d84a4914f Update idl_gen_fbs.cpp 2016-07-04 21:34:42 +02:00
daksenik
c2411e9c8c Fixed operator++. Added CreateXXX for vector types. 2016-07-04 17:37:23 +03:00
daksenik
bf26a0eccc Fixed operator++. Added CreateXXX for vector types. 2016-07-04 16:34:41 +03:00
Wouter van Oortmerssen
68a83eddd4 Merge pull request #3921 from LouisCAD/master
Fixed typo
2016-07-01 10:15:54 -07:00
Wouter van Oortmerssen
b999d49945 Merge pull request #3920 from love-ginger/master
Fix mac build error
2016-07-01 09:48:09 -07:00
Louis Cognault
c94cb6dae9 Fixed typo
is => it
2016-07-01 17:22:36 +02:00
吴凡
5ea2b49f58 Fix some error 2016-07-01 11:17:03 +08:00
吴凡
70deb70b76 Sync from upstream 2016-07-01 11:03:25 +08: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
Wouter van Oortmerssen
6dff7c68f1 Merge pull request #3916 from YuryBandarchuk16/master
Added new constants
2016-06-27 09:52:57 -07:00
Yury Bandarchuk
ec59dc026f Update Constants.java 2016-06-23 21:30:32 +03:00
Yury Bandarchuk
c97abb1eea Added new constants
Add new constants in Constants.java

All single ints int FlatBufferBuilder.java were replaced by constants
from Constants.java
2016-06-23 19:51:55 +04:00
Wouter van Oortmerssen
2fdafa9a49 Merge pull request #3908 from Lakedaemon/intoTheClass
pulling methods inside the class... so as to share wrapInNamespace later
2016-06-22 18:00:48 -07:00
lakedaemon
f794f97d88 fixing spaces 2016-06-23 00:37:55 +02:00
lakedaemon
03ad8fa4d9 sharing the WrapInNameSpace methods 2016-06-23 00:37:55 +02:00
lakedaemon
43fedfa8ba removed static from wrapInNamespace method 2016-06-23 00:36:33 +02:00
lakedaemon
2f52618c4e removed parser from the method signatures 2016-06-23 00:36:33 +02:00
lakedaemon
a9e21170bc js:pulled methods inside the class 2016-06-23 00:36:33 +02:00
lakedaemon
cb6cc3dfb6 php:removed parser from method signatures 2016-06-23 00:36:33 +02:00
lakedaemon
66f2aac26f php:pulled methods inside the generator 2016-06-23 00:36:33 +02:00
lakedaemon
4a249752ff removed lang signature method 2016-06-23 00:31:27 +02:00
lakedaemon
f0695e0edf removed parser & static from method signatures 2016-06-23 00:28:35 +02:00
lakedaemon
07d4066847 general: moved methods into the class 2016-06-23 00:27:19 +02:00
Wouter van Oortmerssen
57ba8a4d46 Merge branch 'master' of https://github.com/google/flatbuffers 2016-06-20 16:41:40 -07:00
Wouter van Oortmerssen
9e6c5f9f2c JSON Parser allows union type fields to come after unions.
This is useful because many JSON generators will sort the fields,
cause X_type to follow X.

Change-Id: I00ef3ac05418224fc05aee93e6b3b3597e73ffe3
Tested: on Linux.
Bug: 29221752
2016-06-20 16:30:14 -07:00
Wouter van Oortmerssen
3639032d1e Allow unions of table types with the same name but from different namespaces.
Also fixed most codegenerators using the wrong namespace when multiple
namespace were used in a file, with some files not being generated.

Change-Id: Ib42969221239d7244e431cbd667ef69200fc415f
Tested: on Linux.
Bug: 29338474
2016-06-20 11:47:04 -07:00
Robert
6f75ec8490 Merge pull request #3913 from rw/fix-pytest-binary-type
Fix test using compat.binary_types (from March).
2016-06-18 13:02:02 -07:00
rw
fd43d3709e Fix test using compat.binary_types (from March). 2016-06-18 01:12:56 -07:00
Wouter van Oortmerssen
6e177bf03f Merge branch 'master' of https://github.com/google/flatbuffers 2016-06-17 17:44:00 -07:00
Wouter van Oortmerssen
d3ac0bc149 Added conversion operations that can be used inline in JSON.
e.g.: { myfield: cos(rad(180)) } is equivalent to writing { myfield: -1.0 }

Bug: 29338398
Change-Id: I6fc4ef1fd10bda3ba78cba464414dd071a2f50ca
Tested: on Linux.
2016-06-15 14:54:44 -07:00
Wouter van Oortmerssen
afa276288c Added additional convenience overloads to CreateVector().
Bug: 29337887, 29336299
Change-Id: Iad8b3b2263f6cea7ee7e45994369194960df293b
Tested: on Linux.
2016-06-15 14:31:34 -07:00
Dan Ring
4832238708 Add tests for GetRootAs* in Go and Python 2016-06-14 18:41:33 -04:00
Dan Ring
1f8e3c13e6 Emit GetRootAs methods for all types in Go and Python 2016-06-14 18:41:33 -04:00
Wouter van Oortmerssen
5a401aef57 Merge pull request #3897 from Lakedaemon/namespaceWork
Namespace work
2016-06-13 15:16:28 -07:00
Wouter van Oortmerssen
78ecf45527 Merge pull request #3903 from senior7515/master
Add env var for flatc schema compiler cmake module
2016-06-13 13:07:17 -07:00
Alexander Gallego
3ae503a191 Add env var for flatc schema compiler cmake module 2016-06-10 15:39:14 -04:00
Wouter van Oortmerssen
bafd48d96c Merge branch 'master' of https://github.com/google/flatbuffers into fuzzer2 2016-06-08 11:51:49 -07:00
Antoine Descamps
cf7e4b027a Fix typo
"your platform can't handling..." => "your platform can't handle"
2016-06-08 09:32:37 +02:00
lakedaemon
15863c34a0 SetNameSpace algorithm documentation and more meaningful variable names 2016-06-07 14:46:25 +02:00
Romain Gilles
9875b0e0f8 Create a maven like project structure for java development. Make it OSGi compliant. Generate the flatbuffers code for testing (example).
Java developer are mostly comfortable with maven project structure. One one the main concept behind maven is convention. If you follow the maven project convention then your development team will get more effective as they now this project structure and can easily find the production code versus the test code.
 In this pull request I have structured the java project around 2 main parts:
  * the `flatbuffers` project. This project is the api / lib project and contains the test code structure + an example of code generation for testing. This avoid to commit generated code. Pre-configure JUnit for test driven development and make this project OSGi compliant.
  * the `jmh` project. This project aims to provide a placeholder for micro-benchmarking. JMH is a 'de facto' standard for micro benchmarking you can find more details here: http://openjdk.java.net/projects/code-tools/jmh/

For now I didn't move the JavaTest class but it could be a next step with a migration to the JUnit framework.
The only impacts are the move of the class and the project structure => no code change.
2016-06-07 09:05:56 +02:00
Wouter van Oortmerssen
2bdf44a25d Added a way to get mutable tables out of a mutable vector of tables.
Change-Id: I8f9ef1d14f86671ced929c7a159115b1d8510327
Tested: on Linux.
2016-06-06 17:38:21 -07:00
Wouter van Oortmerssen
4ffc881fb6 Fixed LoadFile crashing on directory arguments.
Change-Id: I737f6fd0bb1302ab7cfa6ab8b06108e221ebb63c
Tested: on Linux.
2016-06-06 11:34:31 -07:00
Wouter van Oortmerssen
e92ae5199d Fixed compile errors on Windows 2016-06-02 14:55:35 -07:00
lakedaemon
a3a2bf890f Better C++ namespace management 2016-06-02 23:11:51 +02:00
lakedaemon
a9194c4c68 cpp generator : pulling all methods inside the class 2016-06-02 21:56:27 +02:00
Wouter van Oortmerssen
ca32eb77f3 Merge pull request #3885 from Lakedaemon/shareWarningAndTwoMethods
Share warning and two methods
2016-06-02 11:35:41 -07:00
Wouter van Oortmerssen
886441df98 Merge pull request #3870 from martinus/master
Added helpers to access objects while creating the flatbuffer.
2016-06-02 11:26:16 -07:00
Wouter van Oortmerssen
e02ceca54b Merge pull request #3891 from bog-dan-ro/master
More bit fields patches
2016-06-02 11:24:48 -07:00
Martin Ankerl
b3c35750c2 renamed functions
More descriptive name, show that it's really just a temporary object.
2016-06-01 13:13:00 +02:00
BogDan Vatra
3e52fecd1e Don't generate MIN & MAX enum values if "--no-prefix" is used.
Close #3892
2016-06-01 10:23:44 +03:00
BogDan Vatra
cccd7003ed MIN & MAX are useless for bit_flags
Instead we need NONE (0) and ANY (all orred values), if the user didn't
already defined them
2016-06-01 10:15:41 +03:00
BogDan Vatra
038ea7c1d3 Add ! operator 2016-06-01 10:05:27 +03:00
BogDan Vatra
0b0cf58f24 We already know the underlying_type.
We just need to pass it to DEFINE_BITMASK_OPERATORS macro
2016-06-01 10:04:55 +03:00
Wouter van Oortmerssen
7d1f372ba6 Merge pull request #3888 from bog-dan-ro/master
Define bit mask operators for scoped enums bitfields
2016-05-31 11:59:51 -07:00
Wouter van Oortmerssen
25e4ad19f6 Merge pull request #3889 from PSPDFKit-labs/james/avoid-msvc-align-error
MSVC doesn't allow alignment on function params.
2016-05-31 11:33:10 -07:00
BogDan Vatra
7dfe8e726b Define bit mask operators for scoped enums bitfields
Close #3887
2016-05-30 14:04:37 +03:00
lakedaemon
61b101d442 sharing namespace_dir and the namespace string methods 2016-05-28 20:59:22 +02:00
lakedaemon
cd1493b082 sharing the Flatbuffers warning 2016-05-26 15:26:58 +02:00
Wouter van Oortmerssen
a98bff3ea1 Add simple libfuzzer based test.
This tests the verifier and the parser.

Tested: on Linux.
Bug: 27230459
Change-Id: I3417faba9385dc941199c57a08d8a50c2faec1aa
2016-05-25 17:25:40 -07:00
Wouter van Oortmerssen
06eb6e94e3 Merge pull request #3880 from Lakedaemon/IsEverythingGenerated
shared method that exits early if everything is generated
2016-05-25 10:38:56 -07:00
Lakedaemon
4a8801da34 shared method that exits early if everything is generated 2016-05-25 15:15:56 +02:00
James Swift
b1e8be27a9 MSVC doesn't allow alignment on function params. This prevents the copy and thus avoids this issue https://msdn.microsoft.com/en-us/library/373ak2y1.aspx 2016-05-24 17:16:03 +02:00
Wouter van Oortmerssen
b922a3c952 Merge "Uncomment the corpus attribute since b/28762769 is fixed, add more items to the corpus (taken from the ClusterFuzz-generated corpus)." into ub-games-master 2016-05-23 23:58:50 +00:00
Wouter van Oortmerssen
b52826e7cc Merge "Add a fuzzer for flatbuffers, derived from the one used in Chromium: https://code.google.com/p/chromium/codesearch#chromium/src/testing/libfuzzer/fuzzers/flatbuffers_verifier_fuzzer.cc" into ub-games-master 2016-05-23 23:58:27 +00:00
Wouter van Oortmerssen
0ef72db7bf Merge pull request #3865 from bhamiltoncx/surrogate-pairs
Handle \u-escaped surrogate pairs correctly in IDL parser
2016-05-23 16:51:07 -07:00
Stewart Miles
505d0f2288 Merge "Removed reference to deprecated NDK toolchain version." into ub-games-master 2016-05-23 23:49:56 +00:00
Ben Gertzfield
6704b19db6 Handle \u-escaped surrogate pairs correctly in IDL parser 2016-05-23 16:38:55 -07:00
Wouter van Oortmerssen
64b91da9cf Uncomment the corpus attribute since b/28762769 is fixed,
add more items to the corpus (taken from the ClusterFuzz-generated corpus).

(mirrored from cl 122690857)

Change-Id: I98c7672169a9a27fe18bedae8501e6fb85a0681d
2016-05-23 16:37:57 -07:00
Wouter van Oortmerssen
fe9787e58d Add a fuzzer for flatbuffers, derived from the one used in Chromium:
https://code.google.com/p/chromium/codesearch#chromium/src/testing/libfuzzer/fuzzers/flatbuffers_verifier_fuzzer.cc

(mirrored from cl 122676317)

Change-Id: I0074af435cf37f5e6368b040563c3733d9e02345
2016-05-23 16:35:20 -07:00
Stewart Miles
d06e571b31 Removed reference to deprecated NDK toolchain version.
Change-Id: I8d39a66ca5642427619c60f349fa78917aec2455
2016-05-23 16:27:35 -07:00
Wouter van Oortmerssen
208c15f29d Merge branch 'master' of https://github.com/google/flatbuffers 2016-05-23 14:56:47 -07:00
Wouter van Oortmerssen
a82dbb6e01 Fixed Google Groups link in documentation.
Change-Id: I64307ccd0a6f23a7c3860d602813e637415e7c91
2016-05-23 14:08:21 -07:00
Wouter van Oortmerssen
a42a99029f Made .sh files all have same comment formatting.
Change-Id: Ie7cc268a8823aec1d06c8b7cbef54068d832de3a
2016-05-23 14:08:21 -07:00
Wouter van Oortmerssen
0c7b700895 Merge pull request #3878 from pjulien/no_alloc_on_cb
Remove Remaining FBB#createString Allocation
2016-05-23 13:55:21 -07:00
pjulien
1aa3ee2170 Clarify documentation based on review comments 2016-05-23 16:47:41 -04:00
Wouter van Oortmerssen
8c0d56d55a Removed BOM marker from some files.
Also removed some trailing whitespace.

Change-Id: I40bf4f776ca4d467b7ee6f2c9a7500c13700f9d5
2016-05-23 12:24:44 -07:00
Wouter van Oortmerssen
c41a0453c1 Merge branch 'master' of https://github.com/google/flatbuffers 2016-05-23 10:59:47 -07:00
Wouter van Oortmerssen
1a161a8333 Added missing licenses to some sh/cs/py files.
Bug: https://github.com/google/flatbuffers/issues/3872
Change-Id: I5d551168e9bc925e867e5e4ddf5d809418fd44eb
Tested: on Linux.
2016-05-23 09:51:41 -07:00
pjulien
9d8ae1b0c3 If the user passes in a {{CharBuffer}} himser, reward him by
eliminating the last remaining allocation in string creation
2016-05-21 09:19:43 -04:00
Wouter van Oortmerssen
2de558057d Merge pull request #3867 from dreifachstein/master
Use the build output flatc to compile test schemas by default.
2016-05-20 13:19:52 -07:00
Wouter van Oortmerssen
0756caa42e Merge pull request #3866 from bhamiltoncx/fix-undefined-bit-shift
Fix undefined behavior when CheckBitsFit left-shifts 64-bit value by 64 bits
2016-05-20 13:10:52 -07:00
Wouter van Oortmerssen
99c1ddc792 Merge branch 'master' of https://github.com/google/flatbuffers 2016-05-18 18:01:17 -07:00
Wouter van Oortmerssen
69eef0a0ec Fixes verifier not catching odd vtable sizes.
Bug: 28762769
Change-Id: Iec370482f67c4585e97dd5175c1a4258ddba47fe
Tested: on Linux.
2016-05-18 18:00:25 -07:00
Wouter van Oortmerssen
42bd6447c0 Merge pull request #3877 from ozkuran/patch-1
Fixed Library Location in CppUsage.md
2016-05-18 10:33:55 -07:00
Mahmut Ali ÖZKURAN
747a8c628e Fixed Library Location in CppUsage.md
Fixed Library Location 
"https://github.com/google/flatbuffers/tree/master/include/flatbuffers"
in CppUsage.md
2016-05-18 12:02:32 +03:00
Martin Ankerl
023fec627e Added helpers to access objects while creating the flatbuffer.
GetObject and GetMutableObject are similar to GetRoot and GetMutableRoot,
and can be useful when wanting to access data that has just been created.
Unfortunately there is a danger in using these methods, as it is possible
that the buffer reallocates which will invalidate the pointers.
2016-05-03 17:20:14 +02:00
Xiaolei Yu
3a8bc309e2 Use the build output flatc to compile test schemas by default. 2016-05-01 11:15:53 +08:00
Ben Gertzfield
3400727fff Fix undefined behavior in CheckBitsFit bit-shift on size_t 2016-04-29 15:15:09 -07:00
Robert
77742a3fba Merge pull request #3806 from mediagraph/fix-create-string
Fix CreateString with already-encoded string or bytearray in Python 2.7.
2016-04-27 20:31:55 -07:00
Wouter van Oortmerssen
7cce55d8f0 Merge pull request #3854 from pjulien/3853
Fix for #3853
2016-04-27 18:12:15 -07:00
Wouter van Oortmerssen
933c195e51 Merge pull request #3843 from Lakedaemon/refactoring
Transition 1 (nice diffs) Go, C++ and General generators with class
2016-04-27 13:59:16 -07:00
Wouter van Oortmerssen
d0898fd0c8 Merge pull request #3863 from pjulien/cseq
Can now use ``CharSequence`` of ``String``.  Works with
2016-04-27 13:50:04 -07:00
Lakedaemon
6765c19d45 memory leak fix + php/js/python transition to class based generator 2016-04-26 20:36:43 +02:00
pjulien
599f5e3915 Can now use `CharSequence of String`. Works with
1. [AsciiString]
(http://netty.io/4.1/api/io/netty/util/AsciiString.html)
2. [CharBuffer]
(https://docs.oracle.com/javase/8/docs/api/java/nio/CharBuffer.html)
3. [StringBuilder]
(https://docs.oracle.com/javase/8/docs/api/java/lang/StringBuilder.html)
2016-04-25 22:07:57 -04:00
Robert
ba7204a7b7 Merge pull request #3859 from rw/go-zero-alloc-strings
Go: Fix heap allocation when reading a string.
2016-04-23 18:38:03 -07:00
rw
e8ac0f293e Fix heap allocation when reading a string. 2016-04-23 12:32:43 -07:00
Wouter van Oortmerssen
a0d1161feb Merge pull request #3850 from pjulien/3849
Fix for #3849
2016-04-22 11:42:14 -07:00
Wouter van Oortmerssen
828b2680c0 Merge branch 'master' of https://github.com/google/flatbuffers 2016-04-22 11:35:10 -07:00
Wouter van Oortmerssen
c17cf022ea Fixed a verifier check that didn't return from its parent.
Change-Id: I1aef5fdba72de0c3bb8276c9f50fffa494f26e29
Tested: on Linux.
2016-04-22 11:31:35 -07:00
Wouter van Oortmerssen
f6330ab8f1 Fixed SkipByteOrderMark advancing cursor_ too early.
Change-Id: Ie60f01d935ca6b4aa6ce0eab7598602ac0758342
Tested: on Linux.
2016-04-22 11:27:35 -07:00
pjulien
6908826f95 Fix for #3849
This avoids the following allocations over repeated use:

- A ``CharsetEncoder``
- A byte array to contain the contents of the string
- A wrapper, via ``ByteBuffer#wrap``, for the previously mentioned byte
  array

This also removes a copy of the temporary byte array.  This extra copy
is needed because ``String#getBytes`` returns a byte array and its
length must match the exact size of the contents.

This implementation requires that the builder retain a ``ByteBuffer``
and ``CharEncoder``.  This is considered slower only for users that
will only allocate a single string in their buffers or none at all.

The improvement is especially potent if the builder is constantly reused
by its caller.  This also eliminates the penalty for users that do not
use strings at all since the cost of allocating these fields is
now amortized.

The only allocation left in this code is a ``CharBuffer`` wrapper.  It's
possible to eliminate this allocation using an additional copy but need
further profiling to see which is the bigger problem.
2016-04-21 20:20:14 -04:00
Wouter van Oortmerssen
fd542c71e3 Fixed float suffix not being added on implicit float defaults.
Change-Id: I8dcbb5e93836356511d411ef86452babd3dd3c0b
Tested: on Linux.
2016-04-20 12:06:32 -07:00
pjulien
9fb87f813b size the allocation to the required bytes 2016-04-18 21:43:28 -04:00
pjulien
b0146b3d9a fix file permission 2016-04-18 20:19:56 -04:00
pjulien
286587d151 Fix for #3853
Removes the following allocations:
- ``CharsetDecoder`` is reused between calls
- ``CharBuffer#wrap`` removed in favor of heap
  based char buffer that is reused
- Temporary ``char[]``, an intermediate copy inside ``StringCoding``
- Another ``char[]``, this is needed because ``StringCoding`` uses
  a ``CharBuffer`` internally but returns a ``char[]``.  Extra
  characters need to be trimmed so this means yet another allocation
- Yet another ``char[]`` directly from ``__string`` for non-heap
  based buffers

Removes the following copies
- No copy is performed to trim the allocation since a ``CharBuffer``
  is used directly
- For non-heap based byte buffers, removes the copy that was
  previously done in the __string function

This does need to get the TLS entry which implies at least some
contention on the thread object table and a fence.
2016-04-18 20:04:00 -04:00
Wouter van Oortmerssen
6f751d5d26 Merge pull request #3848 from pjulien/3847
Fix for 3847
2016-04-18 15:54:34 -07:00
Wouter van Oortmerssen
4d7890c2c9 Fixed whole-number float default values missing a .0 suffix.
A previous commit that added "f" for C++/Java/C# would break
on gcc of constants like 3f, which are now output as 3.0f

Tested: on Linux

Change-Id: If9cabbe3c6d6948a5050b8b123bda9c06e181f52
2016-04-18 11:50:46 -07:00
pjulien
fdfaf23361 3847 2016-04-16 20:09:28 -04:00
Lakedaemon
38597160f2 Enforcing the google C++ style guide 2016-04-15 13:20:26 +02:00
Wouter van Oortmerssen
791c83aa7e Merge branch 'master' of https://github.com/google/flatbuffers 2016-04-13 17:44:23 -07:00
Wouter van Oortmerssen
29d957ed5e Fixed missing "f" on float default values in C++/Java/C#
Bug: 28145201
Change-Id: I5a1818c40c2f4fbd00cfec3362040407976f7a39
Tested: on Linux.
2016-04-13 17:29:03 -07:00
Wouter van Oortmerssen
8d8b7c19b7 Merge pull request #3844 from Nnamdi/CreateUninitializedVector_fix
Stop CreateUninitializedVector returning a pointer to invalid memory.
2016-04-13 16:14:11 -07:00
Nnamdi
039ab48b7a Stop CreateUninitializedVector returning a pointer to invalid memory.
CreateUninitializedVector was performing the following actions:
    1. call StartVector.
    2. call make_space, and set buf to point to the reserved space.
    3. call EndVector.

The problem is that a call to EndVector can ultimately call make_space, which
if the buffer is full, will cause a reallocation, invalidating the value stored
in buf.  So setting buf needs to be delayed until after EndVector.

The following code, when run under valgrind shows a write to free'd memory before
the change, but no such error after:

int main()
{
    flatbuffers::FlatBufferBuilder fbb(128);
    char *buf = nullptr;
    fbb.CreateUninitializedVector(128, &buf);
    *buf = 0;
}
2016-04-13 23:04:27 +01:00
Lakedaemon
8a64afabfd Transition 1 (with nice diffs) Go, Cpp and General code generators with class 2016-04-13 23:21:18 +02:00
Wouter van Oortmerssen
4a04bac250 Fixed struct -> class pre-declaration error.
Change-Id: I3730a6823d603982c4250d514e827e3f93d1f81e
Tested: on Linux.
2016-04-13 12:02:22 -07:00
Wouter van Oortmerssen
72fc45aa6a Made user-defined attributes available in the reflection data.
Tested: on Linux.

Bug: 27923233
Change-Id: Ic16675650e4a8e138c163f1e2131a3aad7008ada
2016-04-11 17:36:56 -07:00
Wouter van Oortmerssen
9f2b05df1b Merge branch 'master' of https://github.com/google/flatbuffers 2016-04-11 13:48:57 -07:00
Wouter van Oortmerssen
83dc5ed4a7 Fixed JSON integers as strings not being parsed correctly.
Change-Id: If34aef46ef619e06de799cff14948b02e98da86d
Tested: on Linux.
2016-04-11 11:08:09 -07:00
Wouter van Oortmerssen
e597ad8f0f Fixed pre-declarations of included types in generated code.
This was harmless, but unnecessary.

Change-Id: I1365a725e254d4ebbda081110a50277cb5118323
Tested: on Linux.
2016-04-11 11:05:42 -07:00
Wouter van Oortmerssen
3ea5446680 Merge pull request #3789 from Chippiewill/master
Allow builds on platforms with unsigned chars by default
2016-04-08 11:32:16 -07:00
Wouter van Oortmerssen
8b18e487bd Merge pull request #3839 from klapek/net/bytebuffer-assert-optimization
Remove unnecessary condition in AssertOffsetAndLength.
2016-04-08 11:18:58 -07:00
Wojciech Jaszczak
c837d29eab Remove unnecessary condition in AssertOffsetAndLength.
Condition is already checked and covered in the following condition, the second one was excess.

Signed-off-by: Wojciech Jaszczak <jaszczakw@gmail.com>
2016-04-08 19:56:02 +02:00
Wouter van Oortmerssen
ec1daef858 Merge pull request #3832 from mikkelfj/c_docs
Documentation for C bindings
2016-04-08 10:54:27 -07:00
Mikkel Fahnøe Jørgensen
7d396bc2e7 Update C documentation with supported MSVC versions, and other minor updates. 2016-04-07 18:52:00 +02:00
Wouter van Oortmerssen
8128df7655 Added missing util.cpp to VS project 2016-04-04 17:09:07 -07:00
Wouter van Oortmerssen
cfaa7782b6 Adding missing util.cpp to Xcode project 2016-04-04 17:07:05 -07:00
Wouter van Oortmerssen
5e3f9d5175 Merge branch 'master' of https://github.com/google/flatbuffers 2016-04-04 16:55:25 -07:00
Wouter van Oortmerssen
cdc5d5b18d Merge pull request #3836 from tkelman/cygwinbuild
Fix build on Cygwin
2016-04-04 15:38:32 -07:00
Wouter van Oortmerssen
e98b1912b3 add setloadfile and setfileexists functions to flatbuffers
to allow for custom file loaders. The targeted use case is android runtime.

(from CL 116980408)

Change-Id: I8785c0acf714fab41d8f6fc9f1c52875423b8f5b
2016-04-04 13:03:22 -07:00
Wouter van Oortmerssen
c8c0082413 Fix flatbuffers conversion warnings.
(from CL 116785833)

Change-Id: I0fb0e1318fd70cba51e229a93f535c6639bbb331
2016-04-04 13:03:22 -07:00
Wouter van Oortmerssen
1c1d079113 Fix flatc build for msvc.
(from CL 117010760)

Change-Id: I0ee77cf87d0cb00b94887356745b85423b1375a6
2016-04-04 13:03:22 -07:00
Wouter van Oortmerssen
7523e4ad49 Fixed potential integer overflow in the Verifier.
This overflow could allow malformed FlatBuffers to pass the verifier.

Change-Id: Ia993299a761b00b93e53e8aff2689b631755763c
Tested: on Linux.
Bug: 27903580
2016-04-04 13:03:22 -07:00
Wouter van Oortmerssen
f4a5c9de50 Fixed VS assignment constructor warning. 2016-04-04 13:00:48 -07:00
Mikkel Fahnøe Jørgensen
1db9783bfc Remove details on FlatCC builds that would easily become outdated 2016-04-04 16:33:20 +02:00
Mikkel Fahnøe Jørgensen
5b38134431 Document FlatCC support for Windows 2016-04-03 21:37:57 +02:00
Tony Kelman
4c16038e72 Fix build on Cygwin
use -std=gnu++11 instead of c++0x on cygwin to avoid
error: realpath was not declared in this scope

ref http://www.cygwin.com/ml/cygwin/2016-03/msg00005.html
2016-04-01 21:42:23 -07:00
Wouter van Oortmerssen
2f7f50b8cb Merge pull request #3816 from armen/master
Implement __vector_as_bytes and methods to get [ubyte] efficiently
2016-03-30 14:04:36 -07:00
Wouter van Oortmerssen
a1633055f7 Merge pull request #3834 from Nnamdi/gen_name_strings
Added --gen-name-strings command line option.
2016-03-30 13:14:49 -07:00
Nnamdi
35f6bb5060 Added --gen-name-strings command line option.
To support the use case described in issue google/flatbuffers#3826, a new command line option --gen-name-strings
has been added, which will cause a static GetFullyQualifiedName function to be added
to the C++ output for tables/structs.
2016-03-29 22:25:04 +01:00
Armen Baghumian
28a3c939e7 Implement __vector_as_bytes and methods to get [ubyte] efficiently
Currently in order to get a value type of [ubyte] in PHP, iteration is
necessary which is not efficient. Helper __vector_as_bytes has been
implemented in order to return the byte arrays in PHP efficiently.

Appropriate methods also been added to use aforementioned method to return
the byte array. (e.g. get*Bytes()).

The reason the methods are named get*Bytes() and not for instance
get*ByteArray() is the fact that PHP doesn't support byte arrays and the
binary safe string implementation in PHP is used to simulate byte arrays
and since there is chance for PHP users to confuse this with PHP arrays
the name get*Bytes() has been chosen.

In the future __vector_as_bytebuffer() method can also be implemented to
return PHP implementation of ByteBuffer.
2016-03-29 14:56:09 +11:00
Mikkel Fahnøe Jørgensen
7d9779fc67 Move some C specifics out of tutorial and clarify platform support 2016-03-28 22:52:10 +02:00
Mikkel Fahnøe Jørgensen
9b8c91c90b Add C support in README, minor updates in other C doc 2016-03-26 09:22:56 +01:00
Mikkel Fahnøe Jørgensen
47d4b46950 Documentation for C bindings 2016-03-26 00:28:31 +01:00
Wouter van Oortmerssen
a649cb7db5 Merge pull request #3822 from cage433/tutorial-java-type-error
Tutorial's Java example uses incorrect types
2016-03-23 12:45:24 -07:00
Alex McGuire
68c69b3717 Tutorial's Java example uses incorrect types
`FlatBufferBuilder.createString` returns an int offset, not a string
2016-03-20 12:59:39 +00:00
Will Gardner
ce4d3316d3 Allow builds on platforms with unsigned chars by default
Certain architectures, such as ARM, use unsigned chars by default
so require the `-fsigned-char` for certain value comparisons to
make sense and in order to compile.
2016-03-14 16:19:38 +00:00
Wouter van Oortmerssen
e6b79f0002 Added stream & idempotent annotations for RPCs.
Change-Id: Ia8651c1051808fdda0dc0ba52ec991777f868e88
Tested: on Linux.
2016-03-09 15:03:05 -08:00
Wouter van Oortmerssen
1a63eb46bb Added RPC declarations to the schema parser.
This is the first step in RPC support. Actual code generation
to follow.

Change-Id: I96c40fec3db671d100dd9eb509a71c5cbe55bfb2
Tested: on Linux.
Bug: 20122696
2016-03-09 13:47:40 -08:00
Wouter van Oortmerssen
91c27148c0 Merge pull request #3805 from artiom/patch-1
Update google user group link
2016-03-09 09:58:51 -08:00
Alex Kerfoot
1e7310e6cd Fix CreateString with already-encoded string or bytearray in Python 2.7.
There was no way to pass an already-encoded string to 
`builder.CreateString` in Python 2.7:

- Passing a `bytearray` raised a TypeError because `bytearray` was not
  recognized as an instance of `compat.binary_type`.
- Passing a utf-8 encoded `str` would cause the string to be
  double-encoded, because `compat.string_types = (basestring,)` and
  `basestring` is the base class of `str` and `unicode`, so the logic
  would never reach the `elif isinstance(s, compat.binary_type)` case.
- Converting a utf-8 encoded bytearray to `bytes` like
  `builder.CreateString(bytes(encoded_string))` does not work because
  in Python 2.7, bytes is just an alias for `str` so it behaves as
  above.

This change allows either `bytes` or `bytearray` as an already-encoded
string to be passed to `CreateString` in versions of Python that support
`bytearray`, and falls back to `str` in older versions.

In Python 2, it restricts unencoded string types to `unicode`, so `str`
can be used as an encoded, binary representaiton.
2016-03-08 16:05:02 -08:00
artiom
b49a7d146d Update google user group link
Original link returns 404.
2016-03-08 23:57:12 +00:00
Wouter van Oortmerssen
fbc8af40e3 Allow JSON numeric fields to be specified by a numeric data in a string.
Change-Id: I6a3fae1e71434a7384edc39b8602bd84a0432edb
Tested: on Linux.
Bug: 24140897
2016-03-07 17:22:51 -08:00
Wouter van Oortmerssen
709e720839 Merge branch 'master' of https://github.com/google/flatbuffers 2016-03-07 15:04:18 -08:00
Wouter van Oortmerssen
3cd9181ef8 Fixed Java pom.xml file still having wrong version number.
Change-Id: I95bc50ecd3b49d91fb81477a8818e3c1f253ff77
2016-03-07 14:15:01 -08:00
Wouter van Oortmerssen
81e4d3c6c3 Moved the build dir to build_ide to not clash with BUILD files.
Change-Id: I9576e130142acc697fadbfb6aacfd5969f25866a
Tested: on Windows.
Bug: 27426239
2016-03-07 12:58:36 -08:00
Wouter van Oortmerssen
958fc6ec49 Added support for easy string pooling.
Change-Id: I790cf681c1bffff800d77afb0e2f908d1c827679
Tested: on Linux.
Bug: 26186542
2016-03-07 12:58:36 -08:00
Wouter van Oortmerssen
19afcdc704 Clarified how to test for the presence of fields.
This is FAQ on the issue tracker.

Bug: 26863353
Change-Id: I227e10a5c0134dbe7fd7f59e64cd57a0752c568e
2016-03-07 12:58:36 -08:00
Wouter van Oortmerssen
51d48bd953 Merge pull request #3793 from yurivict/master
Fixed missing -lc++abi on FreeBSD.
2016-03-02 17:46:30 -08:00
Yuri
26f15bcd77 Fixed missing -lc++abi on FreeBSD. 2016-03-02 17:15:42 -08:00
Wouter van Oortmerssen
412b8d2c80 Merge pull request #3788 from franc0is/layout-typo
Fix small typo in documentation navigation
2016-02-26 10:14:39 -08:00
Wouter van Oortmerssen
617fedf349 Merge pull request #3765 from Mischanix/js-typed-arrays
Javascript helper to get typed array views
2016-02-26 09:51:50 -08:00
Wouter van Oortmerssen
59caa536ed Merge pull request #3784 from evanw/fix-for-3773
Fix #3773: Generated JS now avoids the flatbuffers object
2016-02-26 09:37:55 -08:00
François Baldassari
3d5f7f64f8 Remove erroneous extra character 2016-02-26 09:03:22 -08:00
François Baldassari
66126cc32d Fix typo in documentation navigation 2016-02-26 09:00:46 -08:00
Evan Wallace
31b30335f6 Fix #3773: Generated JS now avoids the flatbuffers object 2016-02-25 01:06:16 -08:00
Wouter van Oortmerssen
959866b848 Merge pull request #3776 from ncpenke/fix-bug-skipping-unknown-fields
Fix bug skipping unknown fields
2016-02-22 13:38:14 -08:00
Nalinichandra Penke
cbab26673b Fix #3775: Skip unknown field names if they're quoted 2016-02-22 14:34:20 -06:00
ncpenke
1cf5e3f751 Merge pull request #4 from google/master
Catchup
2016-02-22 14:34:05 -06:00
Wouter van Oortmerssen
9a76ce8a65 Disabled broken biicode builds on Travis for the moment.
Change-Id: I834e6da091ea704a3fe599a5b99f338d29cd3bf1
2016-02-22 11:33:14 -08:00
Wouter van Oortmerssen
574404e2ee Merge branch 'master' of https://github.com/google/flatbuffers 2016-02-17 13:29:34 -08:00
Wouter van Oortmerssen
20c0082ee5 Fixed namespace code generation for C++
The code generator was assuming all declarations for the current
file sit in the same namepace. Now uses the "on demand" namespace
switching we had for the forward declarations.

Also fixed a bug related to namespace lookup.

Change-Id: Ib54a3efbc752cbb9590302fa0707c0c73448db3d
Tested: on Linux.
2016-02-17 11:26:38 -08:00
Robert Nix
9d92aeb182 Add helper for javascript typed arrays
For scalar vector fields, emit an Array helper that
returns a typed array view of the underlying bytes buffer.
2016-02-12 12:41:28 -06:00
Robert Nix
2f5d7ae645 Fix javascript unicode test
The generated buffer should be tested for semantic equivalence
to the correct buffer, instead of being tested for bytewise
equality.
2016-02-12 12:31:25 -06:00
Wouter van Oortmerssen
d2bc73bbbe Merge pull request #3761 from msb-at-yahoo/fix-gcc-4.4-build
fix gcc-4.4 build: -Werror=unused-result is not supported
2016-02-10 16:13:59 -08:00
maurice barnum
697cad7027 fix gcc-4.4 build: -Werror=unused-result is not supported 2016-02-11 00:05:04 +00:00
Wouter van Oortmerssen
472fb12273 Merge branch 'master' of https://github.com/google/flatbuffers 2016-02-10 13:51:10 -08:00
Wouter van Oortmerssen
d779308b3e Fixed enum declaration values being parsed as int.
This caused values in the uint range to be made negative values.

Change-Id: Ia4284747f48508b589c034ff3aae0d141e96eb3c
Tested: on Linux.
2016-02-10 11:25:31 -08:00
Wouter van Oortmerssen
a03f3287b3 Merge pull request #3760 from rw/python-remove-ctypes-dependency
Python: remove ctypes dependency in runtime library.
2016-02-08 14:35:45 -08:00
rw
a88cf317fd Python: remove ctypes dependency in runtime library. 2016-02-08 14:15:02 -08:00
Wouter van Oortmerssen
38662548c7 Bumped version to 1.3.0
Change-Id: I080041e533153b2bb2db53f030761852e95c88fa
2016-02-03 10:52:33 -08:00
Wouter van Oortmerssen
5973b778b1 Merge pull request #3749 from escholtz/flatc-version
Add -v --version arg support to the flatc command.
2016-02-03 10:03:40 -08:00
Eddie Scholtz
ac655b3ff0 Remove -v as option for printing version # (based on PR feedback). 2016-02-01 13:54:09 -08:00
Eddie Scholtz
0b3cd33e55 Add __DATE__ to FLATC_VERSION based on PR feedback. 2016-02-01 13:43:05 -08:00
Wouter van Oortmerssen
d7a86eb029 Merge pull request #3739 from Mandar-Shinde/master
Update readme.md for github
2016-02-01 11:33:44 -08:00
Mandar
757d830f4e Updated text in section "Supported programming languages" 2016-02-02 00:18:00 +05:30
Eddie Scholtz
e43d127eff Add -v --version arg support to the flatc command. 2016-01-29 15:01:54 -08:00
Wouter van Oortmerssen
9b8a814c3f Merge pull request #3742 from evolutional/cs-partial
Added support for C# partial class generation using attribute
2016-01-27 16:18:21 -08:00
Mandar
8b4c0b94dc Update readme.md 2016-01-22 22:27:47 +05:30
Oli Wilkinson
dbf6702371 Added support for C# partial class generation when the csharp_partial attribute is used on a table/struct. 2016-01-21 15:42:30 +00:00
Wouter van Oortmerssen
491e970943 Merge branch 'master' of https://github.com/google/flatbuffers 2016-01-20 18:11:51 -08:00
Wouter van Oortmerssen
9a54c44742 Re-Added accidentally deleted sample generated file.
Change-Id: Ie3b31719f7b133ec4aea64f00f2029566558cb18
Tested: Linux.
2016-01-20 18:09:53 -08:00
Wouter van Oortmerssen
9dfc3d61ee Merge pull request #3735 from evolutional/vs2010-buildfix
Buildfix for VS2010
2016-01-20 13:49:40 -08:00
Wouter van Oortmerssen
db0727e943 Merge pull request #3734 from evolutional/cs-forcedefaults
Implemented ForceDefaults option on C# FlatBufferBuilder.
2016-01-20 13:46:49 -08:00
Wouter van Oortmerssen
abd6a1427e Merge pull request #3729 from fichter/master
Fix build error when flatc binary is missing in path.
2016-01-20 13:35:25 -08:00
Wouter van Oortmerssen
0afac8f75a Merge branch 'master' of https://github.com/google/flatbuffers 2016-01-20 13:30:09 -08:00
Wouter van Oortmerssen
519dcdd0b2 Fixed Python unit test breakage.
Test was testing for a field to be None, even though it is populated
in one particular instance.

Change-Id: Id19848d01498d4c0a684efdb2bf49ff12c5b6758
Tested: on Linux.
2016-01-20 13:04:03 -08:00
Oli Wilkinson
112a619ec1 Disabled assignment operator of TableKeyComparator; was causing warning C4512 on VS2010 and thus causing the build to fail. 2016-01-20 18:59:51 +00:00
Oli Wilkinson
fff4590faf Implemented ForceDefaults option on C# FlatBufferBuilder.
Tested on: Windows, Unit Tests
2016-01-20 17:25:58 +00:00
Wouter van Oortmerssen
41395d981d Merge pull request #3707 from evolutional/vs-gitignore
Added Visual Studio transient files to .gitignore
2016-01-19 18:01:34 -08:00
Robert
b7d97ff3de Merge pull request #3491 from faizanrashid/master
[BUG FIX] [MINOR] Fix encoding with unicode characters.
2016-01-19 17:56:26 -08:00
Wouter van Oortmerssen
bf07c37a53 Merge branch 'master' of https://github.com/google/flatbuffers 2016-01-19 15:56:26 -08:00
Wouter van Oortmerssen
2ab7ebc82b Merge pull request #3510 from jaakristioja/patch-1
Fixed comment typo
2016-01-19 15:36:45 -08:00
Mark Klara
0ece042162 Silenced unused variable warnings.
When built for release, builds were failing with unused
variable warnings, since they were only used in `assert()`
calls.

I added explicit void casting to any potentially unused variables.

Change-Id: I9947ba46891fdda5aa925caa950642dedd4e009f
2016-01-19 15:30:41 -08: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
d75d29e2fe Merge branch 'master' of https://github.com/google/flatbuffers 2016-01-19 14:10:49 -08:00
Wouter van Oortmerssen
049f3f7907 Added support for parsing JSON null value.
These cause the field in question to be skipped.

Bug: 16550393
Change-Id: Id05104e89818ee773b8a91fdcc86e18061b9a82f
Tested: on Linux.
2016-01-19 14:05:27 -08:00
Wouter van Oortmerssen
e848137ded Added min/max values for enums/unions.
Bug: 21642898
Change-Id: Ifaf0b3c4274fe30ef29507ba1c1216d700efe85b
Tested: on Linux.
2016-01-19 14:05:27 -08:00
Wouter van Oortmerssen
f8c1980fdf Added schema evolution examples to the docs.
Bug: 26296711
Change-Id: I225067d82ac0f8bd71b2b97b1672517ca86cc3b9
Tested: on Linux.
2016-01-19 12:29:53 -08:00
Wouter van Oortmerssen
7d70082590 Merge pull request #3706 from evolutional/fix-3506
Check (& skip) of the utf-8 byte order mark
2016-01-19 11:10:07 -08:00
Wouter van Oortmerssen
8472b5f224 Merge pull request #3513 from evolutional/fix-3500
Java/C#: generation of typed helpers when using nested_flatbuffers
2016-01-19 10:40:02 -08:00
Wouter van Oortmerssen
6136dd490a Merge pull request #3498 from ncpenke/gcc-4.4.3-support
Gcc 4.4.3 support
2016-01-19 10:27:57 -08:00
Rene Fichter
3de82050ce Fix build error when flatc binary is missing in PATH. 2016-01-19 13:02:25 +01:00
Oli Wilkinson
f1ab30a490 Added Visual Studio transient files to .gitignore 2016-01-18 20:54:22 +00:00
Oli Wilkinson
cbe8747b59 Added check (& skipping) of the utf-8 byte order mark (0xEF BB BF) at the beginning of the file 2016-01-18 20:14:39 +00:00
Oli Wilkinson
eaa2b414b2 Added generation of typed helpers when using nested_flatbuffers in Java/C#. Fixes #3500 2016-01-18 15:23:14 +00:00
Jaak Ristioja
77a6a786b8 Fixed comment typo 2016-01-13 15:30:27 +02:00
Chandra Penke
b63ebad49d Fix #3497: Add support for compiling in g++ 4.4 and 4.5
- Removed uses of lambda expressions

- Added custom defines for constexpr and nullptr

- Removed trailing comma of last value from generated enums
2016-01-09 06:30:50 -06:00
Wouter van Oortmerssen
42c20d7a69 Make flatc check for binary files to avoid accidental parsing.
Binary file arguments to flatc have to be preceded by -- to
identify them, forgetting this however results in them being
attempted to be parsed as schema/json, with cryptic errors.
This instead gives an error if 0 bytes are contained in your
text file.

Bug: 22069056
Change-Id: I226bf651dcb016f18d7c8ffadcf23466a1fc0b87
Tested: on Linux.
2016-01-08 13:10:25 -08:00
Wouter van Oortmerssen
63b526db52 Ensured code is not generated directly from .proto files.
The parser state generated from the .proto conversion process is
not exactly the same as what you get by parsing the generated
schema, which can cause problems. This check enforces that you
first convert the .proto, then generate code from the new schema.

Change-Id: I04b53af9288d87e256d1cc109388332fefb3a09f
Tested: on Linux.
2016-01-08 11:39:56 -08:00
Wouter van Oortmerssen
514d274a45 Added android static library target for text parsing/generation etc.
Change-Id: If24e3eea90cef2a0d6a9d98fb503d2e3ec34ceed
Tested: on Linux.
2016-01-06 17:48:19 -08:00
Wouter van Oortmerssen
6beafd14e0 Updated docs to point to benchmark source code location.
Change-Id: If4c8fac6a421ac6436cab0dd7a0ae822a32e90bf
2016-01-06 16:51:00 -08:00
Robert
b4d29970f4 Merge pull request #2098 from faizanrashid/issue-1741
[BUG] [MINOR] Use buffer for specific py versions
2016-01-06 16:13:59 -08:00
Wouter van Oortmerssen
586fdee89b Merge pull request #3494 from parnic/fix-vs2012-static-analysis
Fixed MS static analysis warnings
2016-01-06 12:34:08 -08:00
Chris Pickett
178f768f7f Changed how the SA warning is suppressed to avoid pragma stuff 2016-01-06 14:21:18 -06:00
Wouter van Oortmerssen
316854c26f Merge pull request #3495 from parnic/fix-reflection-vs2012-warnings
Fixed warning building in VS2012
2016-01-06 12:03:40 -08:00
Wouter van Oortmerssen
6532bfce34 Merge pull request #3493 from parnic/support-platforms-without-realpath
Fix build for platforms not supporting realpath
2016-01-06 11:52:37 -08:00
Chris Pickett
e1e7dfa625 Fixed warning building in VS2012
src\reflection.cpp(297): warning C4267: 'argument' : conversion from 'size_t' to 'flatbuffers::uoffset_t', possible loss of data

sizeof() was promoting the type from uoffset_t to size_t.
2016-01-06 12:45:24 -06:00
Chris Pickett
a3363def52 Updated comment on endif for new name 2016-01-06 12:21:17 -06:00
Chris Pickett
b4fef31d84 Made requested revisions for naming and spacing 2016-01-06 12:20:38 -06:00
Chris Pickett
cfd6e7dea8 Documented what the suppressed warning is about 2016-01-06 12:04:46 -06:00
Wouter van Oortmerssen
56f9b2d142 Merge pull request #3492 from parnic/fix-vs2012-warnings
Fix vs2012 warnings
2016-01-06 09:39:23 -08:00
ncpenke
01025fa22b Merge pull request #3 from google/master
Catchup
2016-01-06 10:18:04 -06:00
Chris Pickett
30013b4ff8 Fixed MS static analysis warnings
Cleaned up a few warnings to allow VS2012 to compile idl_parser and idl_gen_text (for exporting binary protobuf blobs as JSON) cleanly under static analysis.
2016-01-05 13:38:59 -06:00
Chris Pickett
4731c7e502 Fix build for platforms not supporting realpath
Added a check for a preprocessor definition that can be set if the platform you're building for doesn't support any notion of absolute path resolution/realpath()/etc.
2016-01-05 11:04:16 -06:00
Chris Pickett
e0b2f81885 Fixed compile warning with VS2012
flatbuffers\src\idl_parser.cpp(1516): warning C4244: 'argument' : conversion from 'int' to 'char', possible loss of data
2016-01-05 10:58:40 -06:00
Chris Pickett
0e1601b80d Fixed compile warning with VS2012
flatbuffers\src\idl_parser.cpp(1525): warning C4127: conditional expression is constant
flatbuffers\src\idl_parser.cpp(1546): warning C4127: conditional expression is constant
2016-01-05 10:58:21 -06:00
Wouter van Oortmerssen
a6a38f6035 Merge branch 'master' of https://github.com/google/flatbuffers
Fixed conflicts and added missing generated files.

Change-Id: I4321c798543292d814c2c9e8b238c203b7526c7b
2016-01-04 13:06:19 -08:00
Wouter van Oortmerssen
4e4a5142fb Clarified binary encoding with an example.
Change-Id: I60c900a2f7cbd88fe264f7b0dc78ef86b1580655
Tested: in Chrome.
2016-01-04 09:53:21 -08:00
ncpenke
17c0b677e0 Merge pull request #2 from google/master
Catchup
2016-01-02 06:59:41 +00:00
Faizan Rashid
af23683311 [BUG FIX] [MINOR] Fix encoding with unicode characters.
When passing a unicode string to builder.CreateString, the
default encoding assumed all characters can be encoded
using ascii. Added a fix so a user can specify the
encoding and how to handle errors when creating strings.
2015-12-31 09:45:09 +05:00
Wouter van Oortmerssen
451272b618 Made error checking macros less prone to clashes.
Change-Id: Ieb252ce01446551699d935507bc95ee286fe1ddd
Tested: on Linux.
2015-12-29 16:33:00 -08:00
Wouter van Oortmerssen
8f13c828f5 Merge pull request #2776 from ncpenke/skip-unknown-json-fields
Fix #2775: Add parser option to skip unknown JSON fields
2015-12-29 10:29:11 -08:00
Wouter van Oortmerssen
e6240f4039 Merge pull request #2790 from chobie/php-table-fix
(PHP) fixes getting indirect table, also fixes getInt method on 32bit machine
2015-12-29 10:25:21 -08:00
Shuhei Tanuma
4691558ee3 (PHP) remove duplicate test 2015-12-24 15:50:03 +09:00
Shuhei Tanuma
7fbd9b8de4 (PHP) improve indirect buffer test 2015-12-24 15:35:28 +09:00
Nalinichandra Penke
f243109524 Fix #2775: Add option to flatc to skip unknown fields in JSON 2015-12-22 00:13:22 -08:00
Nalinichandra Penke
13d0594b4c Fix #2775: Add parser option to skip unknown JSON fields 2015-12-22 00:02:19 -08:00
ncpenke
6bfcb286b1 Merge pull request #1 from google/master
Catchup
2015-12-21 22:56:49 -08:00
Wouter van Oortmerssen
1891537236 Fixed reflection setting string not changing size field.
Change-Id: I3c3e88a79667d1733b6c47e43b55d8b2604ca8e2
Tested: on Linux.
2015-12-21 16:20:03 -08:00
Wouter van Oortmerssen
d7d527d154 Merge branch 'master' of https://github.com/google/flatbuffers 2015-12-21 14:43:48 -08:00
Wouter van Oortmerssen
995ee86a6e Added an IsFieldPresent helper function.
This is implemented as a template function, since Table::CheckField
is not reachable by subclasses of Table (private base class).

Change-Id: I1ed4d47ce7cb672460ccab61cf7442eb9136b0f1
Tested: on Linux.
Bug: 26273432
2015-12-21 12:17:59 -08:00
Wouter van Oortmerssen
40a33b1d06 Replaced exception handling in the parser with error checking.
This to allow the code to run on a greater range of build
configurations (that don't allow exceptions/RTTI).

If anyone ever doubts the usefulness of exception handling,
please show them this commit.

Change-Id: If7190babdde93c3f9cd97b8e1ab447bf0c81696d
Tested: on Linux.
2015-12-21 12:17:59 -08:00
Shuhei Tanuma
c9198dbbb8 (PHP) fixes getting indirect table, also fixes getInt method on 32bit machine. 2015-12-17 11:35:31 +09:00
Wouter van Oortmerssen
b974e95ce4 Merge pull request #2601 from AaronCritchley/patch-1
Improving the README by linking to the SO tag, and changing SO wording.
2015-12-16 09:59:22 -08:00
Aaron Critchley
99249ada01 Linking to SO tag and improving readability 2015-12-15 21:06:01 +00:00
Oli Wilkinson
4802e8a285 C# added BYTEBUFFER_NO_BOUNDS_CHECK #define
Removes the bounds checking on the ByteBuffer Get/Put operations. Can be dangerous when used with UNSAFE_BYTEBUFFER but results in increased performance. Use at your own risk!
2015-12-14 21:06:29 -05:00
Wouter van Oortmerssen
a9909a0c18 Made sure all namespace test files get generated.
Also included them in the C++ test.

Change-Id: Ib0c8470f0aacdf16616c27494abdda57a010195d
Tested: on Linux.
2015-12-14 16:15:43 -08:00
Wouter van Oortmerssen
2ce5d6c2b6 Merge pull request #2090 from evolutional/cs-perf-string
C# - Performance optimizations
2015-12-14 15:16:46 -08:00
Faizan Rashid
853e34087a [BUG] [MINOR] Use buffer for specific py versions
Fix for Issue 1741
Minor bug where python versions 2.7.x where x < 5 do not support
unpacking from memoryview objects. Versions 2.7.5 and above will
use memoryview while 2.7 versions below 2.7.5  will use buffer
objects.

Manual testing was performed on versions 2.7.5 and 2.7.2 to
confirm both worked correctly.
2015-12-13 02:55:16 -05:00
Oli Wilkinson
be11d2b6ef C# performance optimization to Pad/Prep methods 2015-12-12 11:39:57 -05:00
Oli Wilkinson
b8187e5b82 Performance tweak to FlatBufferBuilder.CreateString method to remove the unnecessary byte buffer allocation
(See https://github.com/google/flatbuffers/issues/55#issuecomment-164031718 for stats)
2015-12-11 14:57:59 -05:00
Wouter van Oortmerssen
4dcaec7938 Fixed root_type not accepting namespaced types.
Change-Id: I272f377742cc0a2c1bfccaa641b54eb9a8c762b6
Tested: on Linux.
2015-12-09 16:41:12 -08:00
Wouter van Oortmerssen
c44bc6a719 Merge branch 'master' of https://github.com/google/flatbuffers 2015-12-09 12:57:12 -08:00
Wouter van Oortmerssen
6fba6b6e71 Fixed compiler warnings for cast to bool in generated code.
Change-Id: I7727aeb478feb23d8ef66fd1ba9499b142b3ea7d
Tested: on Linux.
2015-12-09 12:56:24 -08:00
Wouter van Oortmerssen
96cd275603 Merge pull request #288 from mfcollins3/csharp-byte-buffer
Add Get Bytes Method Generator for C#
2015-12-07 17:35:57 -08:00
Wouter van Oortmerssen
42b48bd55f Merge pull request #776 from belldon/bytebuffer_pos_fix
Extend C# ByteBuffer Put method fix to unsafe methods
2015-12-07 16:19:05 -08:00
Wouter van Oortmerssen
8bb45dc0a6 Merge pull request #1029 from belldon/vtable_reuse
Update C# FlatBufferBuilder to reuse vtable array
2015-12-07 14:42:04 -08:00
belldon
8db90f5073 Extend C# ByteBuffer Put method fix to unsafe methods
Fixes issue #243.  Extends the initial C# ByteBuffer fix
(e4c3bf3d2c) to Put methods
used when UNSAFE_BYTEBUFFER is defined.
2015-12-07 16:43:55 -05:00
belldon
d5a113e5bf Update C# FlatBufferBuilder to reuse vtable array
This commit updates the FlatBufferBuilder class to reuse the vtable
array instead of creating a new array with every StartObject() call.
2015-12-07 16:42:21 -05:00
Wouter van Oortmerssen
8e6758d205 Merge pull request #608 from evolutional/master
Fix to #360 - Fully qualified names outside of current NS
2015-12-07 10:33:38 -08:00
Wouter van Oortmerssen
163d04a5d2 Merge pull request #778 from armen/master
Correct the max/min signed/unsigned 32-bit int
2015-12-07 10:27:27 -08:00
Wouter van Oortmerssen
b0d5bb1c4b Fixed language for generators not being set correctly.
Change-Id: I36c1f05efa836b32635e3274ac0ba976a8961bdd
Tested: on Linux.
2015-12-07 09:53:04 -08:00
Armen Baghumian
f622e5996c Optimize get* operation
It's slightly faster to convert the value to signed value in PHP as
opposed to use pack and unpack.

For 1M get operation the difference is:

    getShort in 3.3272678852081 seconds
    getInt in 3.8338589668274 seconds
    getLong in 5.6381590366364 seconds
    getLong (neg) in 5.6149101257324 seconds

vs

    getShort in 2.7564418315887 seconds
    getInt in 3.1612701416016 seconds
    getLong in 3.1369340419769 seconds
    getLong (neg) in 3.1478710174561 seconds

And since pack("P") and unpack("q") has been removed now ByteBuffer
works for PHP >= 5.4
2015-12-05 23:32:35 +00:00
Armen Baghumian
77fbdd28e2 Correct the max/min signed/unsigned 32-bit int
The test was trying to pack an unsigned int which couldn't fit as a
signed int and putInt() wasn't doing the validation in the correct range
2015-12-05 23:32:35 +00:00
Oli Wilkinson
c9ad6d5496 Fix to #360 - Updated the general generator (Java/C#) to emit fully qualified names where the referenced object isn't directly in this namespace. Added test fbs files to verify compilation. 2015-12-05 13:42:09 -05:00
Michael Collins
e083e466b8 Add Get Bytes Method Generator for C#
I updated idl_gen_general.cpp to add support for generating a Get Bytes
method for a vector to the generated C# source code. Given a byte vector
field named Foo, a method named GetFooBytes() will be generated in the
C# source code that will return an ArraySegment<byte> value referencing
the vector data in the underlying ByteBuffer.

I added a method to Table.cs named __vector_as_arraysegment that is used
by the code generated by the change to the C# generator.
__vector_as_arraysegment will take the offset of the vector and will
return the ArraySegment<byte> value corresponding to the bytes that
store the vector data.

I updated FlatBuffersExampleTests.cs to add tests to validate my
implementation of Table.__vector_as_arraysegment. I added tests to
demonstrate that the bytes for the monster's name can be extracted from
the underlying byte array. I also added tests to show that
Table.__vector_as_arraysegment returns a null value if the vector is not
present in the FlatBuffer.

I used the updated flatc.exe program to regenerate the C# source files
for the MyGame example. The new Monster class includes the GetXXXBytes
methods to return the byte arrays containing data for vectors.
2015-12-04 11:44:43 -07:00
Jason Sanmiya
fe2f8d32aa Do not create empty enums.
Mac build issued a warning for enum{}.

Change-Id: I9cab958538ac3cec61aeae289d1da0118ecac15f
Tested: Mac build no longer issues warnings.
2015-12-04 09:45:44 -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
47478117d8 Fixed implicit dereference in flatc.
Change-Id: If2e62a325b47399561b4c20d2def55ede4831d19
Tested: on Linux.
2015-12-02 11:12:39 -08:00
Perry Hung
d7f2488099 Link clang builds against libc++abi on Linux
Simply running clang with -stdlib=libc++ requires a manual link against
libc++abi on Linux. This is documented in the libc++ documentation:
    http://libcxx.llvm.org/

Tested on Arch Linux, using clang 3.7.0 RELEASE.

Signed-off-by: Perry Hung <iperry@gmail.com>
2015-12-02 11:12:39 -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
7b06041a7c C++ generated code now has constants for vtable offsets.
Besides making the generated code looking a lot more readable,
it also allows you to use these offsets in calls to
Table::CheckField, to see if a field is present in a table.

Change-Id: I1b4cc350c4f27c4e474c31add40c701ef4ae63b2
Tested: On Linux.
2015-12-02 11:12:39 -08:00
Wouter van Oortmerssen
3fc5387db7 Made C++ generated code use "bool" instead of uint8_t wire type.
Change-Id: I5756d15a758429ca67456264842017063d1f755e
Tested: on Linux.
2015-12-02 11:12:39 -08:00
Wouter van Oortmerssen
fc1cfd287a Allow vectors to be aligned beyond their natural type.
Change-Id: I09ade6b688a6b97d65fd832558917225d86c9118
2015-12-02 11:12:39 -08:00
Wouter van Oortmerssen
54dc4395b9 Java builder now checks if buffer was finished upon access.
Also checks for nesting of objects in vector construction.

This avoids common errors in FlatBuffer construction.

Change-Id: I5507c5d767684e20e94883a92448f05acefba4d6
Tested: on Linux.
2015-12-02 11:12:39 -08:00
Chris
1d457a0271 Fix use of std::max when Windows.h is imported. 2015-12-02 11:12:39 -08:00
Chris
671c9495d9 Return the full string when requested from a flatbuffers::String, even if it contains a NULL byte. 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
b7d8c2af1a Made generated C++ code respect gcc -Werror=shadow.
Change-Id: I17de0bcc462770124227a9967e2aab620467f6eb
Tested: on Linux.
2015-12-02 11:12:39 -08:00
Wouter van Oortmerssen
1075c80e8a Fixed crash related to flatc parsing duplicate input files.
Thanks @Chaosvex for reporting.

Change-Id: I73f60ab0bf875a3e0849eaec5f42f6d036881094
Tested: on Linux.
2015-12-02 11:12:39 -08:00
Wouter van Oortmerssen
b611dc4b99 Fixed implicit dereference in flatc.
Change-Id: If2e62a325b47399561b4c20d2def55ede4831d19
Tested: on Linux.
2015-11-30 17:53:00 -08:00
Wouter van Oortmerssen
5f19ea5e45 Merge pull request #610 from iperry/master
Link clang builds against libc++abi on Linux
2015-11-30 16:56:08 -08:00
Perry Hung
e4abeef65c Link clang builds against libc++abi on Linux
Simply running clang with -stdlib=libc++ requires a manual link against
libc++abi on Linux. This is documented in the libc++ documentation:
    http://libcxx.llvm.org/

Tested on Arch Linux, using clang 3.7.0 RELEASE.

Signed-off-by: Perry Hung <iperry@gmail.com>
2015-11-30 19:48:49 -05:00
Wouter van Oortmerssen
ac49eda053 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-11-30 16:48:31 -08:00
Wouter van Oortmerssen
1fa803d187 C++ generated code now has constants for vtable offsets.
Besides making the generated code looking a lot more readable,
it also allows you to use these offsets in calls to
Table::CheckField, to see if a field is present in a table.

Change-Id: I1b4cc350c4f27c4e474c31add40c701ef4ae63b2
Tested: On Linux.
2015-11-30 14:27:47 -08:00
Wouter van Oortmerssen
6d1ff8a525 Merge branch 'master' of https://github.com/google/flatbuffers 2015-11-30 13:55:34 -08:00
Wouter van Oortmerssen
59dc29a19a Made C++ generated code use "bool" instead of uint8_t wire type.
Change-Id: I5756d15a758429ca67456264842017063d1f755e
Tested: on Linux.
2015-11-30 13:54:24 -08:00
Wouter van Oortmerssen
6db667b6b1 Merge pull request #602 from chrisstaite/master
Fix flatbuffers::String to std::string and import of Windows.h
2015-11-30 12:21:41 -08:00
Wouter van Oortmerssen
07da3fc216 Allow vectors to be aligned beyond their natural type.
Change-Id: I09ade6b688a6b97d65fd832558917225d86c9118
2015-11-30 11:50:09 -08:00
Wouter van Oortmerssen
c5835b896c Java builder now checks if buffer was finished upon access.
Also checks for nesting of objects in vector construction.

This avoids common errors in FlatBuffer construction.

Change-Id: I5507c5d767684e20e94883a92448f05acefba4d6
Tested: on Linux.
2015-11-30 11:25:21 -08:00
Chris
345e8ca804 Fix use of std::max when Windows.h is imported. 2015-11-27 20:06:41 +00:00
Chris
9202f0cf09 Return the full string when requested from a flatbuffers::String, even if it contains a NULL byte. 2015-11-27 20:05:48 +00:00
Wouter van Oortmerssen
d10f9a6abc 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-11-25 17:26:34 -08:00
Wouter van Oortmerssen
ec0c0b14ca Made generated C++ code respect gcc -Werror=shadow.
Change-Id: I17de0bcc462770124227a9967e2aab620467f6eb
Tested: on Linux.
2015-11-25 16:48:28 -08:00
Wouter van Oortmerssen
6267f8c6c0 Fixed crash related to flatc parsing duplicate input files.
Thanks @Chaosvex for reporting.

Change-Id: I73f60ab0bf875a3e0849eaec5f42f6d036881094
Tested: on Linux.
2015-11-25 15:50:30 -08:00
Wouter van Oortmerssen
947a5b4ea3 Merge pull request #353 from takaken1994/master
C++: Fixed generated header file cannot be compiled when the type of key is enum class
2015-11-25 13:40:00 -08:00
Wouter van Oortmerssen
e10b8d6f2a Merge pull request #349 from belldon/enum-fix
Fixes issue #348: C# vector of enums doesn't compile
2015-11-25 13:14:28 -08:00
Donnell
644bcbde91 Fix C# vector of enum code generation
Fixes a bug where the logic to determine when to use a C# enum flags
both enums and vectors of enums.  This causes the C# generator to
generate code that doesn't compile for tables that contain vectors of
enums.

The fix also consolidates type generation functions a bit and adds
some additional casting functions for clarity.
2015-11-23 09:19:43 -05:00
Wouter van Oortmerssen
6775a0a941 Merge pull request #362 from chobie/fix-projectfile
Fix projectfile (VisualStudio, XCode) for development
2015-11-20 13:43:57 -08:00
Shuhei Tanuma
20c712f31b also, fix xcode project 2015-11-21 05:38:57 +09:00
Shuhei Tanuma
e6d51b54b6 Add missing idl_gen_php.cpp to VisualStudio project 2015-11-21 05:33:30 +09:00
Stewart Miles
c7482832b8 Merge remote-tracking branch internal into fb_upstream 2015-11-19 03:07:49 -08:00
Stewart Miles
6fe6532673 Fixed typo in cmake build rule for Linux.
Tested:
Verified it's possible to build generated headers on Linux for Android.

Change-Id: I82249a252cb851b978a177f4a4b92b527cc2bfd9
2015-11-19 03:02:58 -08:00
Stewart Miles
8212da5d5d Workaround broken gnumake realpath on Windows.
Also, added missing build scripts for flatc on Windows and fixed
numerous issues in the flatbuffers/android/jni/include.mk makefile.

Tested:
Verified dependent project (motive) can generate flatbuffers headers
with these changes on Android.

Bug: 25780616

Change-Id: I73f0dec8f7a6a7eb4e71951a8f1cd3e0d343a9ff
2015-11-19 02:44:56 -08:00
Wouter van Oortmerssen
a7b5f92f51 Merge pull request #359 from proppy/move-build-fb
flatbuffers/cmake: move build_flatbuffers to a standalone file
2015-11-18 10:10:07 -08:00
Wouter van Oortmerssen
6266b4f122 Merge pull request #308 from chobie/php
Add support for PHP code.
2015-11-18 09:31:17 -08:00
Wouter van Oortmerssen
e4eb286483 Merge pull request #312 from chobie/unity-fix
C# Unity (.NET 3.5) can't cast enum default value.
2015-11-18 09:28:00 -08:00
Johan Euphrosine
331d2d835c flatbuffers/cmake: move build_flatbuffers to a standalone file
So that it could be included from both flatbuffers CMakeLists.txt and
FindFlatBuffers.cmake.

Change-Id: Ie16a879beef9367cd6fd9b2d2157044841a7cdbc
2015-11-17 13:52:41 -08:00
Shuhei Taunma
5ce8682671 (PHP) add experimental support for PHP language.
* codegen for all basic features: WIP (probably implemented all basic feature)
* JSON parsing: NO
* Simple mutation: NO
* Reflection: NO
* Buffer verifier: NO (will be add later)
* Testing: basic: Yes
* Testing: fuzz: Yes
* Performance: Not bad
* Platform: Supported Linux, OS X, Windows (has 32bit integer limitation)
* Engine Unity: No

flatc --php monster_test.fbs

  <?php
  //include neccessary files.
  $fbb = new Google\FlatBuffers\FlatBufferBuilder(1);
  $str = $fbb->createString("monster");
  \MyGame\Example\Monster::startMonster($fbb);
  \MyGame\Example\Monster::addHp($fbb, 80);
  \MyGame\Example\Monster::addName($fbb, $str);
  $mon = \MyGame\Example\Monster::endMonster($fbb);
  $fbb->finish($mon);
  echo $fbb->sizedByteArray();

PHP 5.4 higher

Currently, we do not register this library to packagist as still experimental and versioning problem.
If you intended to use flatbuffers with composer. add repostiories section to composer.json like below.

  "repositories": [{
    "type": "vcs",
    "url": "https://github.com/google/flatbuffers"
  }],

 and just put google/flatbuffers.

  "require": {
    "google/flatbuffers": "*"
  }

* PHP's integer is platform dependant. we strongly recommend use 64bit machine
  and don't use uint, ulong types as prevent overflow issue.
  ref: http://php.net/manual/en/language.types.integer.php

* php don't support float type. floating point numbers are always parsed as double precision internally.
  ref: http://php.net/manual/en/language.types.float.php

* ByteBuffer is little bit slow implemnentation due to many chr/ord function calls. Especially encoding objects.
  This is expected performance as PHP5 has parsing arguments overhead. probably we'll add C-extension.

Basically, PHP implementation respects Java and C# implementation.

Note: ByteBuffer and FlatBuffersBuilder class are not intended to use other purposes.
      we may change internal API foreseeable future.

PSR-2, PSR-4 standards.

Implemented simple assertion class (respect JavaScript testcase implementation) as we prefer small code base.
this also keeps CI iteration speed.

we'll choose phpunit or something when the test cases grown.
2015-11-18 00:26:39 +09:00
Shuhei Tanuma
37e28d98ea C# Unity can't cast integer represented enum value.
```
namespace MyGame;

enum CommandType : byte {
	None = 0,
}

table Command {
	id:int;
	type:CommandType;
}
```

then generate c# files. it'll output compile error like these.

```
Assets/MyGame/Command.cs(18,39): error CS1041: Identifier expected
Assets/MyGame/Command.cs(18,39): error CS1737: Optional parameter cannot precede required parameters

16:   public static Offset<Command> CreateCommand(FlatBufferBuilder builder,
17:   int id = 0,
18:   CommandType type = (CommandType)0) {
```
2015-11-17 18:02:59 +09:00
Wouter van Oortmerssen
097797bf9f Merge branch 'master' of https://github.com/google/flatbuffers 2015-11-16 14:10:16 -08:00
Robert
4725be015d Merge pull request #343 from rw/go-builder-ergonomics
Go: Improve Builder user interface.
2015-11-16 12:18:30 -08:00
Wouter van Oortmerssen
f7d465f990 Merge pull request #344 from rw/py-builder-ergonomics
Python: Improve Builder user interface.
2015-11-16 09:07:31 -08:00
takaken1994
c4966370e2 C++: Fixed generated header file cannot be compiled when the type of key is enum class 2015-11-15 21:24:08 +09:00
Jon Simantov
65c9b355c1 Store the dirs you pass into build_flatbuffers as properties.
This allows you to query the generated target for those properties
later, so dependent modules can refer to the directories to, for example,
add them to the include_directories.

Change-Id: I7a6bd34c5c1d08e2ea69b5ad845223297cad1159
2015-11-13 18:04:41 -08:00
Jon Simantov
f2949c3fb1 Added build_flatbuffers function to CMake.
This function is designed to be called by projects that use FlatBuffers.
It takes a list of FlatBuffers schemas and a list of schema include
directories, and generates build rules to create generated headers
and/or binary schemas for those files, as well as optionally copying
all of the text schemas into a directory for your use (for example if
you need to parse text schemas within your app).

See function comments for more details.

Change-Id: I181684b916e91d965e14849d8f83ec2c83e9a4a4
2015-11-13 16:24:20 -08:00
Stewart Miles
ef53aebf9e Expand local file path to allow users to fix ndk-build
local-source-file-path does not expand to correct file paths in
some circumstances so some users override it.  Therefore
flatbuffers_header_build_rules has been modified to generate rules
that expand LOCAL_SRC_FILES values with flatbuffers_header_build_rules.

Also, this overrides local-source-file-path to allow nest projects
to build when NDK_OUT is set.

Tested:
Verified a dependent project continues to build.

Bug: 25673744
Change-Id: Ic90186fe96d6e4533f9f3b7ca9ef78084de08a7e
2015-11-13 08:49:00 -08:00
Stewart Miles
4f96603e12 Pass job server arguments (-jX) to make.
When $(MAKE) is expanded via a macro "make" doesn't know whether
$(MAKE) refers to an instance of the make app and therefore doesn't
pass job server arguments down.  This change adds the + prefix to the
command in the receipe in order to indicate $(MAKE) is another instance of
make.

Tested:
Verified flatc builds in parallel from Android builds.

Change-Id: I9f2f4f9680b818fdda7420a75a8bfa995b4644db
2015-11-12 18:25:24 -08:00
rw
3232727ace Python: Improve Builder user interface.
+ Add state to the Builder object to track if we are inside a table,
  and if we are finished building the buffer.
+ Use this data to check that a buffer is being built correctly.
+ Raise an exception if a buffer is not being built correctly.
+ Test that the exceptions happen as expected.

Based on d236dea.
2015-11-11 19:43:53 -08:00
rw
2dfff15a9d Improve Builder user interface.
+ Add state to the Builder object to track if we are inside a table,
  and if we are finished building the buffer.
+ Use this data to check that a buffer is being built correctly.
+ Panic if a buffer is not being built correctly.
+ Test that the panics happen as expected.

Based on d236dea13d.
2015-11-11 17:08:16 -08:00
Wouter van Oortmerssen
3f1c4b41f6 Merge pull request #339 from chobie/net-add-bytebuffer-property-to-table
(C#) Add ByteBuffer property to Table
2015-11-11 10:07:51 -08:00
Shuhei Taunma
b98f526b8a (C#) Add ByteBuffer property to Table 2015-11-10 14:32:31 +09:00
Wouter van Oortmerssen
9dc5d378b1 Updated supported languages in the docs.
Change-Id: I607f5f33b609c47fe32342f5e9d066f61f5546cd
2015-11-09 17:25:17 -08:00
Wouter van Oortmerssen
b0b39543de Merge pull request #311 from chobie/dont-hide-function-parameter-vs2015
Don't hide function parameter
2015-11-09 09:22:30 -08:00
Shuhei Tanuma
721d21923e Don't hide function parameter 2015-11-07 11:36:32 +09:00
Wouter van Oortmerssen
3f79e05585 Added new documentation links.
Change-Id: Ib5234a97a863be08c3bb0f9329204bc3a7effccb
2015-11-06 09:51:19 -08:00
Wouter van Oortmerssen
4d7810424c Allow structs to be parsed in JSON with out of order fields.
Also simplified the code and made it faster.

Change-Id: I1d83b1165a4a9a4380d1bfb5538769c012d2d367
Tested: on Linux.
2015-10-28 17:54:11 -07:00
Wouter van Oortmerssen
2107a7d514 Fixed assert in flatc converting to text.
Change-Id: Idac375b22aa9beaba162084cc3396f5536a4e721
Tested: on Linux.
2015-10-28 17:50:06 -07:00
Wouter van Oortmerssen
40b03519c1 Updated Xcode project for v7 2015-10-28 12:07:28 -07:00
Wouter van Oortmerssen
d236dea13d Improved C++ asserts for nesting and not finishing buffers.
Change-Id: I82a392bd262b13e978df748bc54b7ac43aec1e15
Tested: on Linux.
2015-10-28 11:57:16 -07:00
Stewart Miles
ed88f7de96 Improved build rule generation for Android flatbuffer headers.
* Added the ability to create a build target for generated headers.
* Made it possible for generated header targets to depend upon each
  other or arbitrary build targets.

Tested:
Verified some pretty complex libraries with numerous flatbuffer schema
dependencies build using this macro on Linux with the NDK.
Bug: 25188384

Change-Id: I846855a50808e58c34cdf7086e93e7ea0df69e0d
2015-10-22 13:16:45 -07:00
Robert
07478a6700 Merge pull request #204 from layzerar/fix_struct_comment
fix comment generation of struct
2015-10-20 13:25:53 -07:00
Wouter van Oortmerssen
48ff729477 Added assert for referring to 0 offsets.
Change-Id: I7c04d934bfacd4aeaa2ba476b934dd3a62d4fc0e
Tested: on Linux.
2015-10-20 09:36:35 -07: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
ace304513f Fixes for JS generator in Xcode 2015-10-19 16:05:39 -07:00
Wouter van Oortmerssen
1917e577a2 Fixes for JS generator in VS 2015-10-19 15:55:28 -07:00
Wouter van Oortmerssen
9c9fce96c7 Vector of structs were not being verified correctly.
Because they are represented as `const T *` in the Vector template,
the sizeof(const T *) was accidentally used instead of sizeof(T).

Change-Id: Ib4dc73e1d21396ba2e30c84e5e229c4147204bb1
Tested: on Linux.
2015-10-19 14:11:13 -07:00
Wouter van Oortmerssen
525130765a Merge pull request #257 from evanw/javascript
Add support for JavaScript code generation with Google Closure Compiler type annotations
2015-10-19 12:49:16 -07:00
Wouter van Oortmerssen
d890ef9e20 Merge pull request #298 from evolutional/master
Ported some of the python fuzz tests to C#
2015-10-19 11:11:05 -07:00
Wouter van Oortmerssen
9f69d79430 Merge pull request #296 from prideout/master
Fix minor typos in the Python documentation.
2015-10-19 10:40:16 -07:00
evolutional
9d66af6efc Ported some of the python fuzz tests to C#
* Refactored the test runner to use attribute based test discovery
* Ported value and vtable/object fuzzing tests from python to C#
2015-10-18 17:08:39 -04:00
Philip Rideout
8f1729f7df Fix minor typos in the Python documentation. 2015-10-17 17:48:06 -07:00
Evan Wallace
4bef5e89c4 Add UTF-8 support to the JavaScript API
This adds an optional argument to generated getters for string fields to
specify the encoding type and overloads the createString() function. It's
now possible to use either JavaScript UTF-16 string objects or C-style
UTF-8 byte arrays (Uint8Array) for string data.
2015-10-14 23:07:40 -07:00
Evan Wallace
79222bf100 Update monster_test_generated.js baseline after rebase 2015-10-14 23:06:58 -07:00
Evan Wallace
c3bfefca57 change DataView to bit twiddling for JavaScript 2015-10-14 21:15:57 -07:00
Evan Wallace
00fd394d23 remove unnecessary return 2015-10-14 21:15:57 -07:00
Evan Wallace
e1e8d53df6 Add low-level fuzzer, fix 64-bit issue it found 2015-10-14 21:15:57 -07:00
Evan Wallace
57a6dd472f Add a test for JavaScript UTF-8 <=> UTF-16 conversion
JavaScript uses UTF-16 but FlatBuffers uses UTF-8. This commit tests the code
that does the conversion between the two encodings. The last entry in the array
is tricky because each code point actually requires two UTF-16 code units,
unlike the other examples. The current JSON output of flatc actually handles
this case incorrectly (it generates invalid JSON with UTF-8 code units). The
generated JavaScript code passes these tests fine, however.
2015-10-14 21:15:57 -07:00
Evan Wallace
224e33ed09 Add support for JavaScript code generation
This adds a JavaScript language target. The generated JavaScript uses Google
Closure Compiler type annotations and can be compiled using the advanced
compilation mode, which performs type checking and optimizations such as
inlining and dead code elimination. The generated JavaScript also exports all
generated symbols for use with Node.js and RequireJS. This export behavior
can be turned off with the --no-js-exports flag for use with Google Closure
Compiler.
2015-10-14 21:15:57 -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
Robert
b4db88808f Merge pull request #286 from tguo-aa/fix-278
Add self.assertNotNested() in CreateString
2015-10-08 00:23:26 -07:00
tguo-aa
d9db48257b Add self.assertNotNested() in CreateString
And also add a test case.
If you try to nest CreateString you will get a clear exception.
2015-09-29 08:34:10 +08:00
Wouter van Oortmerssen
e1e1bced08 Fixed LoadFile on Windows 2015-09-28 16:24:34 -07:00
Wouter van Oortmerssen
b56add9520 Improved documentation with links to videos, articles and who uses it.
Change-Id: I62de6b7008e397a5043d47f014a7acd83ee64740
2015-09-28 10:49:01 -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
Wouter van Oortmerssen
a35c32e30f Merge pull request #282 from google/fix-277
Fix 32bit-system integer overflow (test only)
2015-09-25 14:54:50 -07:00
Robert
781c39c708 Fix 32bit-system integer overflow (test only)
For #277
2015-09-25 13:57:17 -07:00
Wouter van Oortmerssen
ff9e539cc5 Merge pull request #280 from alexames/master
Removed call to pop_back on std::string.
2015-09-25 10:38:50 -07:00
Wouter van Oortmerssen
feb4816610 Fixed .proto translation making scalars into required fields.
Change-Id: If414d156b4e9bc7fead5f131823b2c419cdc4e2c
Tested: on Linux.
2015-09-25 09:21:31 -07:00
Alex Ames
703b790939 Removed call to pop_back on std::string.
The pop_back function was added to strings in C++11 and it appears not
all compilers we target support it. The call to pop_back has been
replaced with a call to erase.

Tested on Linux. All unit tests pass.
2015-09-24 14:19:32 -07:00
Wouter van Oortmerssen
811a5c3389 Merge pull request #274 from cogumbreiro/master
Fix an out-of bounds read when the element is bigger than the buffer.
2015-09-23 12:37:45 -07:00
Robert
2736711d67 Merge pull request #275 from brunoqc/patch-1
Remove duplicate Go test
2015-09-21 15:13:24 -07:00
Bruno Bigras
edb3b9c307 Remove duplicate Go test 2015-09-21 17:51:16 -04:00
Tiago Cogumbreiro
477fedccd4 Fix an out-of bounds read when the element is bigger than the buffer.
Ensure the size of the buffer being checked is bigger than the element
of the buffer being checked. The buffer can be triggered when, for
example, the buffer is of length zero and we are checking for:

    Verify<uoffset_t>(buf_)

The condition above should fail.
2015-09-18 20:38:47 -05:00
Björn Reimer
5de28c74f9 serialize boolean in JSON to "true/false" instead of "0/1"
Change-Id: I90cf519c00eaf9ccd9fcab8035a91b9205587c3b
2015-09-16 10:31:38 -07:00
Wouter van Oortmerssen
44261ccdf1 Merge pull request #271 from vijairaj/scoped-enums
Implemented option --scoped-enum for C++ generator
2015-09-16 10:14:49 -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
Wouter van Oortmerssen
169df65df4 Merge pull request #266 from kadirahq/fix-travis-osx
Fix before_install step on .travis.yml file for osx
2015-09-14 17:50:29 -07:00
Wouter van Oortmerssen
af1487bcfb Clarified use of unions in C++.
Change-Id: I9654e0c6a45457c8e150f07dd5f7b39539266f9e
2015-09-14 11:00:12 -07:00
Jason Sanmiya
5db12e9907 Fix Visual Studio 2012 build warning.
Also, remove execute permissions on several source files.

Tested: Builds on Visual Studio 2012, and Linux.

Change-Id: Idaacb2ae8eba98ce2974218c2ab840e97a1d67e9
2015-09-11 14:35:34 -07:00
Wouter van Oortmerssen
dff07b6f31 Merge pull request #269 from teemuandersen/master
Add @SuppressWarnings("all") to generated Java classes
2015-09-11 14:23:53 -07:00
Teemu Andersén
5dd8795a10 Add @SuppressWarnings("unused") to generated Java classes
Usually generators add @SuppressWarnings("all") to generated Java
classes to prevent IDEs from complaining about unused imports, etc.
Solving used imports seems pretty hard with current generator logic so
IMO this is the next best thing.

Yes, it’s appended to import block but that is the block that gives
these warnings in the first place.
2015-09-11 23:33:55 +03:00
Muhammed Thanish
be503cb0f2 Fix OSX related errors on travis
- Install g++ and cmake only on Linux.
 - Use biicode only on Linux machines.
2015-09-11 22:15:27 +05:30
Wouter van Oortmerssen
01e06b69a5 Improved the speed of LoadFile() in debug mode.
Apparently, istreambuf_iterator has a lot of overhead.

Change-Id: I804f4e8f2b380b05e939edefe0e1e88cd10e920c
Tested: on Linux.
2015-09-09 12:56:23 -07:00
Wouter van Oortmerssen
782e05de55 Fixed Android builds on Windows (generated schema rules).
include.mk causes absolute paths to be generated, which doesn't
work on Windows (make doesn't like : in paths).

Change-Id: Ib06c9581620bde1e8452e0dd887d3986d517c4f5
Tested: on Windows, Linux.
2015-08-28 14:42:13 -07:00
Melvi Ts
82a71b18f1 Python: Fix potential code generation issue of documentation comment. 2015-08-28 23:48:28 +08:00
Wouter van Oortmerssen
aeff09d724 Fixed a clang warning about signed shifts.
Change-Id: I7c2bf87972ee0ba6811d6ed42e13300bff90e36f
2015-08-26 16:47:59 -07:00
Björn Reimer
a5c511576f Fix conversion of floats when generating json
Change-Id: I01def42eda9b70308046c048099d85db8f889ede
2015-08-26 14:06:29 -07:00
Maxim Zaks
ac10873e26 fixed code generator for array of bools
Change-Id: I3cdd801b641bf180222203a37634598350d340e3
2015-08-19 14:39:06 -07:00
Robert
9689d38bef Merge pull request #235 from FrankStain/master
2Gb buffer size checks fixed for Python Builder
2015-08-19 23:22:20 +02:00
Wouter van Oortmerssen
d06b2736aa Merge pull request #248 from aeneid/master
Added Java and C# mutators
2015-08-19 11:43:22 -07:00
Maor Itzkovitch
a0f3fb44e7 rebase 2015-08-19 21:32:08 +03:00
Wouter van Oortmerssen
d97f628703 Clarified choice of types in Java/C# codegen.
Change-Id: I1f094f350145d13b12cbe367bae7c623cfbbd8d3
2015-08-19 11:08:53 -07:00
Maor Itzkovitch
fb7f27a7c9 Merge remote-tracking branch 'upstream/master' 2015-08-15 14:48:59 +03:00
Maor Itzkovitch
7bfed4b29a added vector mutators 2015-08-15 14:48:47 +03:00
Wouter van Oortmerssen
a170b69d5d Added authors to support.md
Change-Id: I8f12e60d29a1c587d991bf64011bdf4a4b0d7e5b
2015-08-14 14:07:54 -07:00
Frank Stein
33e4ab65e9 Incorrect buffer size check fixed. 2015-08-14 00:50:39 +03:00
Wouter van Oortmerssen
201699288b Added a platform / language / feature support matrix to docs.
This is just a start, will need to be extended.

Change-Id: I5a9ad671911942dcb83fdd2bae537deed751cbfd
2015-08-12 12:07:43 -07:00
Wouter van Oortmerssen
e9202d85bd Add missing Python files from type cast commit.
Change-Id: I800119d8fe19f4c3e95772aba629ef8b2deb9e4b
2015-08-12 10:17:10 -07:00
Wouter van Oortmerssen
9a1ab5006f Merge pull request #253 from mormegil-cz/issue-252
[Issue 252] Add type cast for default enum values in C#
2015-08-12 09:21:21 -07:00
Mormegil
25c99273d3 [Issue 252] Add type cast for default enum values in C#
When creating a “CreateXxx(...)” method for a “simple table” type,
enum-type fields with a non-zero default must have an explicit
cast for the respective argument default value, because in C#,
there is an implicit cast from int to an enum only for 0.

Also, added an example of such type into the example monster_test
type, so that we test this feature.
2015-08-11 18:07:38 +02:00
Frank Stein
7bcbb19569 MaxBufferSize() changed to MAX_BUFFER_SIZE. Also buffer will never grow more MAX_BUFFER_SIZE. 2015-08-07 21:19:02 +03:00
Maor Itzkovitch
b062af4c8c rebased fork 2015-08-07 18:59:59 +03:00
Maor Itzkovitch
0956719726 added comments 2015-08-07 18:35:28 +03:00
Maor Itzkovitch
766eaad4e7 added a successful test run console print 2015-08-07 18:12:19 +03:00
Maor Itzkovitch
3a74c33ba5 removed console print from code 2015-08-07 10:57:37 +03:00
Maor Itzkovitch
e4c3bf3d2c fixed C# bytebuffer put methods 2015-08-07 10:51:15 +03:00
Maor Itzkovitch
7196c36842 begin to correct C# bytebuffer behavior 2015-08-07 09:05:08 +03:00
Wouter van Oortmerssen
e151160560 Added a link to other FPL libraries to the main page.
Change-Id: I45362806df6d4eff0b0b7521b7caf42c2ec0515c
2015-08-05 17:32:14 -07:00
Jon Simantov
dac63a227e Fix missing break statement in SetAnyValueS case.
Causing SetAnyValueS to treat all scalars as integers.

Change-Id: Ib467b255e7f32a1478180a91e65def31676399eb
2015-08-05 16:06:47 -07:00
Wouter van Oortmerssen
986b52d849 Merge pull request #247 from stewartmiles/master
Clarified the use of the deprecated flatc --gen-includes flag.
2015-08-05 13:58:17 -07:00
Wouter van Oortmerssen
45cc503bbd Changed maximum force_align to match the C++ code generator.
Change-Id: I7df2b0172f5de6f7bdbd8778361794004cd06062
Tested: on Linux.
2015-08-05 13:56:31 -07:00
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
Wouter van Oortmerssen
210c0ece54 Fixed VS project file.
Tested: on Windows.
2015-08-03 17:56:09 -07:00
Wouter van Oortmerssen
ad84b5b8fa Fixed AddFlatBuffer using wrong buffer length.
Also made the Xcode project link.

Tested: on OS X.
2015-08-03 17:39:47 -07:00
Wouter van Oortmerssen
7101224d86 Reworked reflection.h to be more general.
e.g. support generic reading/writing from structs/vectors etc.

Change-Id: I2eb6e24db088a72da444d5c8df7e506e53d5bc2d
Tested: on Linux.
Bug: 22660837
2015-08-03 16:42:05 -07:00
Maor Itzkovitch
6be146d67f small refactor to GenSetter method 2015-08-01 19:28:22 +03:00
Maor Itzkovitch
f706a42951 extend java tests 2015-08-01 19:14:12 +03:00
Maor Itzkovitch
e24afd838a extended scalar mutator support 2015-08-01 19:08:22 +03:00
Maor Itzkovitch
81c2b185ef support for scalar mutators 2015-08-01 12:38:47 +03:00
Wouter van Oortmerssen
0e064e415b Fixed small inaccurracies in the schema grammar.
Change-Id: I6e9e66c3d7d67c54617bc892f612b7341bebd7e0
2015-07-31 12:26:23 -07:00
Wouter van Oortmerssen
4998ad7365 Added support for adding new tables/strings to an existing FlatBuffer.
As part of the reflection support.

Change-Id: Ie0a8e233bca7dffa4cff7e564660035d97ff8902
Tested: on Linux.
Bug:22637258
2015-07-31 09:44:25 -07:00
Wouter van Oortmerssen
9a30d3d0df Merge pull request #241 from RevenantX/master
[BREAKING CHANGE] Base type safety in C#. Clear FlatBufferBuilder in C#.
2015-07-29 11:36:03 -07:00
RevenantX
0b761ece4d default in switch. 2015-07-29 00:45:26 +03:00
RevenantX
01249c1d48 remove unused funciton. 2015-07-29 00:40:48 +03:00
RevenantX
588564d74f Base type safety in C#. Clear FlatBufferBuilder in C#. 2015-07-29 00:33:45 +03:00
Wouter van Oortmerssen
6e192fa408 Updated documentation to use new css style.
Change-Id: I05e2f8fd06026645a8e5da1703d757ad9de10b4f
Tested: on Linux.
2015-07-22 13:10:37 -07:00
Wouter van Oortmerssen
12ca3e054e Fixed compile error in older gcc's for trailing comma in enum.
Change-Id: I60f6da32fb2a30557fcf842624f68ca184f65e1f
Tested: on Linux.
2015-07-22 12:35:40 -07:00
Wouter van Oortmerssen
62af533820 Merge pull request #237 from jonsimantov/master
Add optional root table to SetString and ResizeVector, when your Flatbuffer isn't the schema's root type.
2015-07-22 12:03:39 -07:00
Jon Simantov
b56020ad3b Updated pointer syntax to be consistent in SetString, etc. 2015-07-22 11:46:14 -07:00
Jon Simantov
6e160f4c59 Use Object* for optional root_table in SetString/ResizeVector.
Was previously using table name, but no reason not to just let the
calling code worry about getting the object.
2015-07-22 10:56:41 -07:00
Wouter van Oortmerssen
07e77ad0ff Merge pull request #238 from martell/master
Add a libflatbuffers for other projects to use
2015-07-22 10:02:11 -07:00
Wouter van Oortmerssen
b6380aceac Fixed reflection resizing code not checking strings in vectors.
Change-Id: I4081160a8281939ab282d7914ae396276c767882
Tested: on Linux.
2015-07-22 09:57:35 -07:00
Martell Malone
79d3cb6a6c Add a libflatbuffers for other projects to use 2015-07-22 17:53:19 +01:00
Jon Simantov
a4de6de700 Add optional root table name to SetString and ResizeVector.
This allows you to use these functions with a flatbuffer whose root
table type does't correspond with the root table type of the schema.

If you don't specify the table name, it will use the root table from
the schema by default (mimicing the current behavior).
2015-07-22 02:01:56 -07:00
Frank Stein
a1d801c375 2Gb buffer size checks fixed for Python Builder 2015-07-14 00:10:11 +03:00
Wouter van Oortmerssen
f66e93cd8d Merge pull request #233 from aeneid/master
fix for parameter name clash in generated structs
2015-07-13 13:27:54 -07:00
aeneid
59a09cb1d0 comment update 2015-07-13 22:58:54 +03:00
Maor Itzkovitch
c23c620d26 applied struct parameter fix to Go and Python generated classes 2015-07-13 22:53:59 +03:00
Wouter van Oortmerssen
4798456df6 Fixed type specifiers in the grammar document.
Change-Id: Ia6b976f0eb6a99d710bcd09cb56339580ff69f5b
2015-07-13 10:31:10 -07:00
Maor Itzkovitch
147fbb4285 builder.put statements now use correct argument names 2015-07-13 20:00:48 +03:00
aeneid
a9ae9bdcab comment update 2015-07-12 22:12:58 +03:00
aeneid
f7d8102b35 Passed field name as prefix for nested structs
This pull request should fix #232.
Pass field name instead of struct name as nameprefix for nested structures. Continuously concatenate nameprefix arguments to support deeper nested structures.
2015-07-12 22:10:57 +03:00
Wouter van Oortmerssen
d0e9bc6a75 A few schema documentation fixes.
Change-Id: I140e1322fc1bfb3ab8012e00d8f3006ee2e7ce95
2015-07-08 17:49:49 -07:00
Wouter van Oortmerssen
d863df8683 Merge pull request #230 from aeneid/master
included stdio.h in include/flatbuffers/hash.h
2015-07-08 09:01:17 -07:00
aeneid
4834634766 Update flathash.cpp 2015-07-07 08:14:00 +03:00
aeneid
a4c893dbe2 Update hash.h 2015-07-07 08:13:08 +03:00
Wouter van Oortmerssen
8833255ed3 Merge pull request #227 from evanw/master
Round up allocation size to avoid misalignment (issue #226)
2015-07-06 13:32:44 -07:00
aeneid
fb5f9456e9 Merge pull request #1 from aeneid/aeneid-patch-1
added #include <stdio.h>
2015-07-05 20:27:20 +03:00
aeneid
0dacfbbfca added #include <stdio.h> 2015-07-05 19:50:50 +03:00
Evan Wallace
47aab78233 Round up allocation size to avoid misalignment (issue #226)
Before this change, requesting a large initial allocation could cause the
backing store to grow to an unaligned size. Since memory inside vector_downward
is relative to the end of the buffer, this then caused all memory in the buffer
to be misaligned and also misaligns any further loads and stores. Misaligned
loads and stores are undefined behavior and don't work in environments such as
emscripten (a JavaScript to C++ compiler).
2015-07-02 14:05:45 -07:00
Jon Simantov
185b9f9792 Allow customization of flatc cmdline arguments on Android.
On Android builds, set FLATBUFFERS_FLATC_ARGS to change the arguments
passed to the flatc cmdline. Do this in your Android makefile where
you include the flatbuffers include.mk (before or after).

For example FLATBUFFERS_FLATC_ARGS=--gen-mutable

The default value is --gen-includes although since that is deprecated
we could just make the default value blank.

Change-Id: I79fb35f50c3e21bbef18ad40ad3559cb026ffe8e
2015-07-01 11:46:19 -07:00
Wouter van Oortmerssen
21765bea2e Made warning settings in Xcode more aggressive.
Tested: on OS X.
2015-06-29 15:49:13 -07:00
Wouter van Oortmerssen
36c7e9a962 Fixed null root_table access in binary schema generation.
Change-Id: Ia2b7abc10bee52814e815befcad6a89697295d8f
Tested: on Linux.
2015-06-29 15:21:48 -07:00
Wouter van Oortmerssen
cb2b2be54e Reflection: generically copy (parts of) FlatBuffers.
Change-Id: Ief3f1507c003079eac90c2bb6c2abd64a80a0a34
Tested: on Linux.
2015-06-29 15:18:51 -07:00
Robert
1c152cc72a Merge pull request #222 from rw/go-update-panics
Panic when nesting strings. Test panic scenarios.
2015-06-29 18:10:44 -04:00
gwvo
d67661eb39 Merge pull request #224 from rubber-duck/master
Fixed argument value to correct type
2015-06-29 10:44:11 -07:00
gwvo
ea97e1b5e2 Merge pull request #223 from belm0/csharp_docs
Java/C-sharp docs: fix typo, clarify parser availability.
2015-06-29 09:55:38 -07:00
Rafael Munitić
dca3ccf5fd Fixed argument value to correct type 2015-06-26 21:28:39 +02:00
John Belmonte
ef7b3ed8f5 Java/C-sharp docs: fix typo, clarify parser availability. 2015-06-25 14:42:41 -07:00
rw
4d305f5922 Panic when nesting strings. Test panic scenarios.
Also add a new `insideObject` boolean to the Builder to track whether an
object is currently being constructed. This fixes a bug with objects
that have zero fields.
2015-06-24 11:53:44 -04:00
Wouter van Oortmerssen
1e6f8f5b8c Fixed possible crash from reference to non-static variable.
Change-Id: I1842098a7ef461e2e92dd35d79d8ca303e814867
Tested: on Linux.
2015-06-22 10:23:42 -07:00
Wouter van Oortmerssen
c967515da5 Small improvements to the C++ API.
Change-Id: Ib30ffbbd140a8b82fe664129fa4e8c55836267f8
Tested: on Linux.
2015-06-17 17:17:01 -07:00
Wouter van Oortmerssen
576022c64b Changed VS flatc test settings to match Linux. 2015-06-17 10:27:05 -07:00
gwvo
eab9cfbec9 Merge pull request #217 from amoldeshpande/master
option to generate one file for C#
2015-06-17 10:10:50 -07:00
Amol Deshpande
ab4801a82e Merge branch 'master' of https://github.com/amoldeshpande/flatbuffers 2015-06-16 07:23:29 -07:00
Amol Deshpande
8df4b318bc Merge branch 'master' of https://github.com/google/flatbuffers
Conflicts:
	src/flatc.cpp
	src/idl_gen_general.cpp
2015-06-16 07:16:59 -07:00
amoldeshpande
8a98e9ad98 Merge pull request #3 from amoldeshpande/google-master
Merge pull request #2 from amoldeshpande/master
2015-06-15 21:00:40 -07:00
amoldeshpande
eee5628569 Merge pull request #2 from amoldeshpande/master
merge
2015-06-15 20:58:48 -07:00
Amol Deshpande
ad3fd6ecbf merge 2015-06-15 20:26:10 -07:00
Wouter van Oortmerssen
622b8d05cf Fixed warnings on Windows 2015-06-15 17:35:07 -07:00
Wouter van Oortmerssen
5faa0ab1be Removed unused variable.
Tested: on OS X.
2015-06-15 15:57:48 -07:00
Wouter van Oortmerssen
81312c2128 Initial reflection and resizing functionality.
Tested: on Linux.

Change-Id: I8f7bccf9b1ad87fea788f85e23fa69435758feca
2015-06-15 15:53:10 -07:00
Wouter van Oortmerssen
1808337adc Make generating dependent include files for C++ the default.
--gen-includes is now deprecate but still accepted.
--no-includes can be used instead when needed.

Change-Id: I2cd46d193032b9b7c31c76c6f655e9333d3a393a
Tested: on Linux.
2015-06-15 13:09:22 -07:00
Wouter van Oortmerssen
5f091c46ce Allowing _ as first character of identifiers in .fbs/.json.
Change-Id: Ie2cb42632f6a907a38e10b2c9be1536cf330b2fa
Tested: on Linux.
2015-06-15 13:09:22 -07:00
gwvo
a96bfdb369 Merge pull request #219 from jesta88/master
Fix for #218 - Check empty namespace in general generator
2015-06-15 12:04:58 -07:00
Jeremie St-Amand
ad3ebb110b Follow Google code standards 2015-06-14 13:04:04 -04:00
Jeremie St-Amand
929105432c Namespace now optional for general generator
If you have a schema with no namespace, the resulting C#/Java won't have
an erroneous empty namespace keyword.
2015-06-14 12:56:48 -04:00
Amol Deshpande
40fffc8fff fix code formatting and bug with losing enums when using --gen-onefile 2015-06-13 08:55:24 -07:00
Amol Deshpande
2f76141813 option to generate one file for C# 2015-06-06 19:35:12 -07:00
Wouter van Oortmerssen
932b22f043 Added clang & OS X to .travis 2015-05-27 18:32:49 -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
788acb08d4 Added GitHub link to start of documentation page. 2015-05-27 15:21:10 -07:00
Wouter van Oortmerssen
ddb1d5ffe4 Added a #define for running tests without file access.
Change-Id: Ib2b7aa8a5641cf73fa0d6f2000db7fdd1aabab66
Tested: on Linux.
2015-05-27 14:00:08 -07:00
Wouter van Oortmerssen
7ba29dbe41 Small readability improvements to recent commits.
Change-Id: I290c33c475f7b019ab0d3c571245d27351d22fa1
Tested: on Linux.
2015-05-20 16:21:22 -07:00
Wouter van Oortmerssen
3b070310f0 Fixed -Wunused-result warning.
Change-Id: Iea5fab66047ac0a5057a743dbb1fdb27c063188c
Tested: on Linux.
2015-05-20 16:21:22 -07:00
Wouter van Oortmerssen
fbe085601b Java: Allow access to the underlying ByteBuffer from a table.
Change-Id: Id268e35de207c25c809a09071b81eea873c9123e
Tested: on Linux.
2015-05-20 16:21:22 -07:00
gwvo
36f9b1ec91 Merge pull request #207 from zachreizner/header
Add include for cstdlib for std::bsearch definition
2015-05-20 15:01:53 -07:00
Zach Reizner
7bcd99451f Add include for cstdlib for std::bsearch definition 2015-05-20 14:54:20 -07:00
Robert
2535a3aa3a Merge pull request #206 from rw/go-faster-string-writing
Go: CreateString now needs zero allocs.
2015-05-20 14:37:53 -07:00
rw
0894c25f2c Improve comment for unicode check. 2015-05-20 14:19:49 -07:00
rw
7810fb9ce4 use escape codes here for non-unicode editors 2015-05-20 13:42:51 -07:00
rw
c127cf78c2 Go: CreateString now needs zero allocs.
Big speed boost for the typical use case of building with strings.
2015-05-20 12:00:44 -07:00
gwvo
6fffa2a14d Merge pull request #198 from zulli73/master
Fixed endianness Vector's begin() and end()
2015-05-20 09:30:10 -07:00
gwvo
2b02d330fd Merge pull request #205 from zachreizner/fb_bsearch
Use std::bsearch in LookupByKey for binary search
2015-05-18 17:36:51 -07:00
Zach Reizner
c8f1682e07 Use std::bsearch in LookupByKey for binary search 2015-05-18 17:29:51 -07:00
gwvo
f64e040896 Merge pull request #201 from rw/python-docs-and-packaging
Update Python docs and package description
2015-05-18 09:33:30 -07:00
rw
339376ba67 Regenerate Doxygen docs to add Python usage page. 2015-05-15 12:23:10 -07:00
rw
7a1b77322b Update Python package description: license, descriptions. 2015-05-15 12:20:20 -07:00
Wouter van Oortmerssen
60b6ca5850 fixed xcode build files 2015-05-13 17:45:20 -07:00
Wouter van Oortmerssen
b8681d8031 fixed the windows build files 2015-05-13 17:26:20 -07:00
Robert
f8139b05cb Merge pull request #112 from rw/python23-read-write-gen-port
Port FlatBuffers to Python.
2015-05-13 11:20:09 -07:00
rw
776c4eb965 use EnsureDirExists from util.h instead of mkdir 2015-05-13 10:54:02 -07:00
rw
2746aabcf1 fix string catenation 2015-05-13 10:50:47 -07:00
Raphael Zulliger
04a06781f5 Fixed endianness Vector's begin() and end() 2015-05-13 16:25:56 +02:00
rw
48dfc69ee6 Port FlatBuffers to Python.
Implement code generation and self-contained runtime library for Python.

The test suite verifies:
  - Correctness of generated Python code by comparing output to that of
    the other language ports.
  - The exact bytes in the Builder buffer during many scenarios.
  - Vtable deduplication correctness.
  - Edge cases for table construction, via a fuzzer derived from the Go
    implementation.
  - All code is simultaneously valid in Python 2.6, 2.7, and 3.4.

The test suite includes benchmarks for:
  - Building 'gold' data.
  - Parsing 'gold' data.
  - Deduplicating vtables.

All tests pass on this author's system for the following Python
implementations:
  - CPython 2.6.7
  - CPython 2.7.8
  - CPython 3.4.2
  - PyPy 2.5.0 (CPython 2.7.8 compatible)
2015-05-12 15:40:29 -07:00
Robert
4d213c2d06 Merge pull request #165 from rw/go-faster
Go speed improvements
2015-05-12 14:53:31 -07:00
gwvo
361bfb6764 Merge pull request #189 from pjulien/188
Issue #188
2015-05-11 14:07:40 -07:00
gwvo
3f96eead4c Merge pull request #192 from Jiboo/fix190
Added a default constructor for Java's FlatBufferBuilder.
2015-05-11 13:59:22 -07:00
Wouter van Oortmerssen
8896587faf Fixed schemas inheriting namespace from included schemas.
Change-Id: Ib561430b235eddf4bfe20f68409e1dfdb359ef2b
Tested: on Linux.
2015-05-11 10:55:22 -07:00
Jean-Baptiste "Jiboo" Lepesme
9fa3e2f387 Added a default costructor for Java's FlatBufferBuilder.
Default's size of 1024b like in cpp. Fixes #190.
2015-05-11 19:17:01 +02:00
rw
e5c21ec666 invoke many fewer growth events 2015-05-09 16:32:26 -07:00
rw
e11da87a24 gofmt 2015-05-09 16:10:03 -07:00
rw
3dd54424c0 remove remaining allocs during build 2015-05-09 16:07:11 -07:00
rw
5d68493df4 update CheckClash for string accesses 2015-05-09 15:37:13 -07:00
pjulien
d322eec3c3 Issue #188
When accessing the array directly of a byte buffer, need to offset
by ``arrayOffset``
2015-05-09 14:08:28 -04:00
Mormegil
221193eaa2 Union accessors in C# should use generic type for the table
When accessing a union field, we should return the same object type
as was given to the method, i.e. the parameter should have a generic
type for any Table-derived type. This way, we do not need to make
superfluous casts (which also reduce type safety) like

var myUnionType = (MyUnionType)buff.GetUnionField(new MyUnionType());

when we can do just
var myUnionType = buff.GetUnionField(new MyUnionType());

Change-Id: Idac1b638e46cc50b1f2dc19f10741481202b1515
2015-05-08 16:21:54 -07:00
pjulien
f7d24f60a2 set version for next dev cycle
Change-Id: I17a7896e257c0ab7e4cd1b22c928d4cee21fbf11
2015-05-08 16:21:54 -07:00
pjulien
e5a1a3129d Initially discussed in #178.
Allows adding an already encoded UTF-8 string directly without
having to convert to a ``String`` first.

Change-Id: I23f9c738eec18fd35f4c14f58dbd0f6cf0970dc7
2015-05-08 16:21:54 -07:00
Wouter van Oortmerssen
39833d7cf0 Added namespaced way to refer to types in schemas.
Also made proper namespacing work for enums.

You can now say namespace.MyTable as the type when declaring
a field that refers to a type in a different namespace.

Previously, it would work just referring to MyTable, however
with the recent commit fixing namespaced types this now
is ambiguous.

Change-Id: Ieaa3f4ac1662b8c4dc1f16e1898ea3cdb02e10fd
Tested: on Linux.
2015-05-08 16:21:53 -07:00
Brett Cooley
ecb27817ca Merge "Initial support for propagating namespaces from schema files to generated code" into ub-games-master 2015-05-08 19:52:54 +00:00
Jason Sanmiya
f59bfdd084 Add missing newline in help text for flatc.
Tested: Help text displays correctly now.
Change-Id: Ibbdc810ae41e24321860879064bdc64f78a67cb9
2015-05-07 10:30:34 -07:00
Mormegil
0ee1b99c5d [BREAKING CHANGE] Field accessors should use property getters in C#
In C#, plain field accessors should not be nonparametric methods
but should be standard property getters.

The accessor methods with parameters were renamed to `GetXxx`
because a method cannot be named identically to a property.

Also, `ByteBuffer.Position`, `FlatBufferBuilder.Offset` and
`FlatBufferBuilder.DataBuffer` are now properties instead
of nonparametric accessor methods, for more idiomatic C# style.

This is a breaking change, all client C# code accessing these
fields needs to be changed (i.e. remove those `()` or add the
`Get` prefix).

Issue: #77
Change-Id: Iaabe9ada076e5ea2c69911cf6170fdda2df3487e
2015-05-06 11:55:07 -07:00
yinlei
a50711ad13 Fix u_int8_t to uint8_t
Change-Id: I475ef9454f51f1b7ec2a7f9086d711359456677a
2015-05-06 11:29:07 -07:00
Brett Cooley
249f71a12b Initial support for propagating namespaces from schema files to generated code
Change-Id: Ifc10c54845ea7553586d1896d509314d68e9ab0f
2015-05-05 17:10:53 -07:00
Wouter van Oortmerssen
1d138fbe07 Merge "Added extra checks for reading binaries in flatc" into ub-games-master 2015-05-04 21:02:00 +00:00
Wouter van Oortmerssen
a0bf238b09 Merge changes I2de7d14d,I56392340 into ub-games-master
* changes:
  Added accessor for file_extension in generated code.
  Added missing --gen-mutable to CMakeLists.txt
2015-05-04 21:00:43 +00: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
37e6efe1f9 Added accessor for file_extension in generated code.
Change-Id: I2de7d14dbb1f7b8f81022dd2c9da65060ae49300
Tested: on Linux.
2015-05-04 13:38:20 -07:00
Wouter van Oortmerssen
d4d7a84e11 Added missing --gen-mutable to CMakeLists.txt
Change-Id: I56392340de4439d05fa8f06a7336ff72c6f9346d
Tested: on Linux
2015-05-04 13:38:19 -07:00
Jason Sanmiya
fc7e8af55e Merge "Fix bug on flathash compilation option." into ub-games-master 2015-04-29 21:12:07 +00: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
Jason Sanmiya
f47660f510 Fix bug on flathash compilation option.
Change-Id: Ib9d31d08daba7ce54b864417ae93bf479702861b
2015-04-28 15:44:10 -07:00
Mormegil
a8d6962ac2 Tolerate DOS-style EOL in IDL line comments
If an IDL file uses DOS-style EOLs (CR+LF), line comments need to
ignore the second linebreak character, otherwise, as is currently
the case, the parsed documentation comment includes a trailing `\r`
character, which is then output verbatim into the output source
code by flatc.

Change-Id: I39591631995a980622d20a4a32315178b33f18f6
2015-04-15 13:44:54 -07:00
franchuti688
23f75f598e added .travis.yml file (build with original and biicode building);
added bii-travis.sh and readme.md files; added build status section with travis and biicode build
systems

Change-Id: I93acd1ca9497416ade6293d63b5311c4c31b880f
2015-04-15 13:43:25 -07:00
Mormegil
e3b432cba8 Enums use native enums in C#
Enums should not be (badly) emulated with classes in C# but should
use native C# enums instead. Java implementation made an explicit
choice not to use the (more complex) Java enums, but C# enums are
just light-weight syntactic coating over integral types.

Fixes issue #171.

Change-Id: I9f4d6ba5324400a1e52982e49b58603cb7d7cca7
2015-04-13 10:40:30 -07:00
Advay Mengle
557c57eb9d Seal all classes in Java/C#
Makes enums/structs/tables unsubclassable (final or sealed) and
prevents instantiation of enum classes (which are solely static
constants).

Tested (Mac OS 10.10.2):
1. run flattests
2. cd tests && ../flatc -c monster_test.fbs && ../flatc -j
monster_test.fbs && ../flatc -g monster_test.fbs && ../flatc -n
monster_test.fbs  # Note deltas for C# and Java.
3. ./JavaTest.sh

**Breaking api change**

Change-Id: Ie008c941c36d212690da58ddc72c9b228eb7a093
2015-04-10 11:20:19 -07:00
Joël Lamotte
9d368deb05 Fixed: Readme version is not up to date
Change-Id: Ie44419026eca94bce0a2857abef95a82e78cfc3e
2015-04-06 11:44:22 -07:00
Ben Harper
8b99bf614c Add byte slice accessor to Go code
Change-Id: I15cc8924d6607bd93068c762fd67e6088cfd9789
2015-04-06 11:44:22 -07:00
Kyle Jones
c4a3e2f6bd Always add additional space if no more is available
Change-Id: If08b2d839489d40e977de794b13584fa66ff32c1
2015-04-06 11:44:22 -07:00
INADA Naoki
803f9bba27 Fix typo in Benchmarks.md
Change-Id: I1c5fbd019cc233e1d551887ff5fb740420c18c2b
2015-04-06 11:44:21 -07:00
rw
d756efbf76 Reduce allocations when reusing a Builder.
Add the function `Reset` to the Builder, which facilitates reuse of the
underlying byte slice.
2015-04-02 19:33:00 -07:00
rw
ace7fa8094 Reduce allocations when building strings.
Builder has a new CreateByteString function that writes a
null-terimnated byte slice to the buffer. This results in zero
allocations for writing strings.
2015-04-02 18:22:13 -07:00
rw
f02646e357 Remove all string allocations during parsing.
Change the signature for 'string' getters and settings to use byte
slices instead of strings.
2015-04-02 11:56:55 -07:00
rw
0a3a09aaf3 Merge branch 'go-bytevector-getter' of github.com:benharper123/flatbuffers into go-faster 2015-04-02 11:47:17 -07:00
rw
796be3282c Benchmarks for building and parsing 'gold' data.
Identifies alloc-heavy codepaths.
2015-04-02 11:26:00 -07:00
rw
468124fb9b chmod GoTest.sh +x 2015-04-02 11:25:48 -07:00
Advay Mengle
3ad853630c Generate appropriate schema doc comments from .proto files
- Add parse handling of .proto struct and field doc comments (enums and
their values were already handled)
- Add FBS generation handling of doc comments for structs, their
fields, enums, and their values (requires linking idl_gen_general in
the test binary build)
- Tested using test.proto|golden with doc comments added.  Xcode run of
flattest passes.

Change-Id: Idff64dd8064afba227174ab77d2c7be22d006628
2015-04-01 17:17:39 -07:00
Advay Mengle
b8708beeec Generate Java doc comments in JavaDoc style
Tested by regenerating all tests/ generated sources; note that only
Monster.java changes.  Ran flattests as well.

Change-Id: I65b6ea7d208b0ccd6a0b34761162fed6ba391fc5
2015-04-01 17:10:52 -07:00
Ben Harper
8fb6c4f764 Add byte slice accessor to Go code 2015-04-01 16:47:10 +02:00
2034 changed files with 355534 additions and 18557 deletions

60
.bazelci/presubmit.yml Normal file
View File

@@ -0,0 +1,60 @@
---
buildifier: latest
matrix:
bazel:
- 7.x
- 8.x
tasks:
verify_ubuntu2004:
platform: ubuntu2004
bazel: ${{ bazel }}
environment:
CC: clang
SWIFT_VERSION: "5.10"
SWIFT_HOME: "$HOME/swift-$SWIFT_VERSION"
PATH: "$PATH:$SWIFT_HOME/usr/bin"
shell_commands:
- "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME"
- "mkdir $SWIFT_HOME"
- "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu2004/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu20.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME"
build_targets:
- "//..."
test_targets:
- "//..."
verify_ubuntu2204:
platform: ubuntu2204
bazel: ${{ bazel }}
environment:
CC: clang
SWIFT_VERSION: "5.10"
SWIFT_HOME: "$HOME/swift-$SWIFT_VERSION"
PATH: "$PATH:$SWIFT_HOME/usr/bin"
shell_commands:
- "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME"
- "mkdir $SWIFT_HOME"
- "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu2204/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu22.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME"
build_targets:
- "//..."
test_targets:
- "//..."
test_module_cpp:
platform: ubuntu2204
bazel: ${{ bazel }}
working_directory: tests/bazel_repository_test_dir
build_targets:
- "//..."
test_module_ts:
platform: ubuntu2204
bazel: ${{ bazel }}
working_directory: tests/ts/bazel_repository_test_dir
test_targets:
- "//..."
verify_macos:
platform: macos
bazel: ${{ bazel }}
xcode_version: "15.2"
build_targets:
- "//:flatbuffers"
- "//:flatc"
test_targets:
- "//tests:flatbuffers_test"

5
.bazelignore Normal file
View File

@@ -0,0 +1,5 @@
ts/node_modules
# Test workspaces
tests/bazel_repository_test_dir
tests/ts/bazel_repository_test_dir

18
.bazelrc Normal file
View File

@@ -0,0 +1,18 @@
# We cannot use "common" here because the "version" command doesn't support
# --deleted_packages. We need to specify it for both build and query instead.
build --deleted_packages=tests/bazel_repository_test_dir,tests/ts/bazel_repository_test_dir
query --deleted_packages=tests/bazel_repository_test_dir,tests/ts/bazel_repository_test_dir
# Point tools such as coursier (used in rules_jvm_external) to Bazel's internal JDK
# suggested in https://github.com/bazelbuild/rules_jvm_external/issues/445
common --repo_env=JAVA_HOME=../bazel_tools/jdk
common --action_env=JAVA_HOME=../bazel_tools/jdk
# Workaround "Error: need --enable_runfiles on Windows for to support rules_js"
common:windows --enable_runfiles
# Swift is not required on Windows
common:windows --deleted_packages=swift
# Ignore warnings in external dependencies
build --per_file_copt=external/.*@-Wno-everything --host_per_file_copt=external/.*@-Wno-everything
# Honor the setting of `skipLibCheck` in the tsconfig.json file.
common --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig
# Use "tsc" as the transpiler when ts_project has no `transpiler` set.
common --@aspect_rules_ts//ts:default_to_tsc_transpiler

5
.clang-format Normal file
View File

@@ -0,0 +1,5 @@
---
Language: Cpp
BasedOnStyle: Google
...

347
.clang-tidy Normal file
View File

@@ -0,0 +1,347 @@
---
FormatStyle: "file"
WarningsAsErrors: "*"
HeaderFilterRegex: ".*"
Checks: "google-build-explicit-make-pair,
google-build-namespaces,
google-build-using-namespace,
google-default-arguments,
google-explicit-constructor,
google-global-names-in-headers,
google-objc-avoid-nsobject-new,
google-objc-avoid-throwing-exception,
google-objc-function-naming,
google-objc-global-variable-declaration,
google-readability-avoid-underscore-in-googletest-name,
google-readability-braces-around-statements,
google-readability-casting,
google-readability-function-size,
google-readability-namespace-comments,
google-runtime-int,
google-runtime-operator,
google-upgrade-googletest-case,
clang-analyzer-apiModeling.StdCLibraryFunctions,
clang-analyzer-apiModeling.TrustNonnull,
clang-analyzer-apiModeling.google.GTest,
clang-analyzer-apiModeling.llvm.CastValue,
clang-analyzer-apiModeling.llvm.ReturnValue,
clang-analyzer-core.CallAndMessage,
clang-analyzer-core.CallAndMessageModeling,
clang-analyzer-core.DivideZero,
clang-analyzer-core.DynamicTypePropagation,
clang-analyzer-core.NonNullParamChecker,
clang-analyzer-core.NonnilStringConstants,
clang-analyzer-core.NullDereference,
clang-analyzer-core.StackAddrEscapeBase,
clang-analyzer-core.StackAddressEscape,
clang-analyzer-core.UndefinedBinaryOperatorResult,
clang-analyzer-core.VLASize,
clang-analyzer-core.builtin.BuiltinFunctions,
clang-analyzer-core.builtin.NoReturnFunctions,
clang-analyzer-core.uninitialized.ArraySubscript,
clang-analyzer-core.uninitialized.Assign,
clang-analyzer-core.uninitialized.Branch,
clang-analyzer-core.uninitialized.CapturedBlockVariable,
clang-analyzer-core.uninitialized.UndefReturn,
clang-analyzer-cplusplus.InnerPointer,
clang-analyzer-cplusplus.Move,
clang-analyzer-cplusplus.NewDelete,
clang-analyzer-cplusplus.NewDeleteLeaks,
clang-analyzer-cplusplus.PlacementNew,
clang-analyzer-cplusplus.PureVirtualCall,
clang-analyzer-cplusplus.SelfAssignment,
clang-analyzer-cplusplus.SmartPtrModeling,
clang-analyzer-cplusplus.StringChecker,
clang-analyzer-cplusplus.VirtualCallModeling,
clang-analyzer-deadcode.DeadStores,
clang-analyzer-fuchsia.HandleChecker,
clang-analyzer-nullability.NullPassedToNonnull,
clang-analyzer-nullability.NullReturnedFromNonnull,
clang-analyzer-nullability.NullabilityBase,
clang-analyzer-nullability.NullableDereferenced,
clang-analyzer-nullability.NullablePassedToNonnull,
clang-analyzer-nullability.NullableReturnedFromNonnull,
clang-analyzer-optin.cplusplus.UninitializedObject,
clang-analyzer-optin.cplusplus.VirtualCall,
clang-analyzer-optin.mpi.MPI-Checker,
clang-analyzer-optin.osx.OSObjectCStyleCast,
clang-analyzer-optin.osx.cocoa.localizability.EmptyLocalizationContextChecker,
clang-analyzer-optin.osx.cocoa.localizability.NonLocalizedStringChecker,
clang-analyzer-optin.performance.GCDAntipattern,
clang-analyzer-optin.performance.Padding,
clang-analyzer-optin.portability.UnixAPI,
clang-analyzer-osx.API,
clang-analyzer-osx.MIG,
clang-analyzer-osx.NSOrCFErrorDerefChecker,
clang-analyzer-osx.NumberObjectConversion,
clang-analyzer-osx.OSObjectRetainCount,
clang-analyzer-osx.ObjCProperty,
clang-analyzer-osx.SecKeychainAPI,
clang-analyzer-osx.cocoa.AtSync,
clang-analyzer-osx.cocoa.AutoreleaseWrite,
clang-analyzer-osx.cocoa.ClassRelease,
clang-analyzer-osx.cocoa.Dealloc,
clang-analyzer-osx.cocoa.IncompatibleMethodTypes,
clang-analyzer-osx.cocoa.Loops,
clang-analyzer-osx.cocoa.MissingSuperCall,
clang-analyzer-osx.cocoa.NSAutoreleasePool,
clang-analyzer-osx.cocoa.NSError,
clang-analyzer-osx.cocoa.NilArg,
clang-analyzer-osx.cocoa.NonNilReturnValue,
clang-analyzer-osx.cocoa.ObjCGenerics,
clang-analyzer-osx.cocoa.RetainCount,
clang-analyzer-osx.cocoa.RetainCountBase,
clang-analyzer-osx.cocoa.RunLoopAutoreleaseLeak,
clang-analyzer-osx.cocoa.SelfInit,
clang-analyzer-osx.cocoa.SuperDealloc,
clang-analyzer-osx.cocoa.UnusedIvars,
clang-analyzer-osx.cocoa.VariadicMethodTypes,
clang-analyzer-osx.coreFoundation.CFError,
clang-analyzer-osx.coreFoundation.CFNumber,
clang-analyzer-osx.coreFoundation.CFRetainRelease,
clang-analyzer-osx.coreFoundation.containers.OutOfBounds,
clang-analyzer-osx.coreFoundation.containers.PointerSizedValues,
clang-analyzer-security.FloatLoopCounter,
clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
clang-analyzer-security.insecureAPI.SecuritySyntaxChecker,
clang-analyzer-security.insecureAPI.UncheckedReturn,
clang-analyzer-security.insecureAPI.bcmp,
clang-analyzer-security.insecureAPI.bcopy,
clang-analyzer-security.insecureAPI.bzero,
clang-analyzer-security.insecureAPI.decodeValueOfObjCType,
clang-analyzer-security.insecureAPI.getpw,
clang-analyzer-security.insecureAPI.gets,
clang-analyzer-security.insecureAPI.mkstemp,
clang-analyzer-security.insecureAPI.mktemp,
clang-analyzer-security.insecureAPI.rand,
clang-analyzer-security.insecureAPI.strcpy,
clang-analyzer-security.insecureAPI.vfork,
clang-analyzer-unix.API,
clang-analyzer-unix.DynamicMemoryModeling,
clang-analyzer-unix.Malloc,
clang-analyzer-unix.MallocSizeof,
clang-analyzer-unix.MismatchedDeallocator,
clang-analyzer-unix.Vfork,
clang-analyzer-unix.cstring.BadSizeArg,
clang-analyzer-unix.cstring.CStringModeling,
clang-analyzer-unix.cstring.NullArg,
clang-analyzer-valist.CopyToSelf,
clang-analyzer-valist.Uninitialized,
clang-analyzer-valist.Unterminated,
clang-analyzer-valist.ValistBase,
clang-analyzer-webkit.NoUncountedMemberChecker,
clang-analyzer-webkit.RefCntblBaseVirtualDtor,
clang-analyzer-webkit.UncountedLambdaCapturesChecker,
################################################ Optional checks ################################################
#google-readability-todo,
#bugprone-argument-comment,
#bugprone-assert-side-effect,
#bugprone-bad-signal-to-kill-thread,
#bugprone-bool-pointer-implicit-conversion,
#bugprone-branch-clone,
#bugprone-copy-constructor-init,
#bugprone-dangling-handle,
#bugprone-dynamic-static-initializers,
#bugprone-easily-swappable-parameters,
#bugprone-exception-escape,
#bugprone-fold-init-type,
#bugprone-forward-declaration-namespace,
#bugprone-forwarding-reference-overload,
#bugprone-implicit-widening-of-multiplication-result,
#bugprone-inaccurate-erase,
#bugprone-incorrect-roundings,
#bugprone-infinite-loop,
#bugprone-integer-division,
#bugprone-lambda-function-name,
#bugprone-macro-parentheses,
#bugprone-macro-repeated-side-effects,
#bugprone-misplaced-operator-in-strlen-in-alloc,
#bugprone-misplaced-pointer-arithmetic-in-alloc,
#bugprone-misplaced-widening-cast,
#bugprone-move-forwarding-reference,
#bugprone-multiple-statement-macro,
#bugprone-narrowing-conversions,
#bugprone-no-escape,
#bugprone-not-null-terminated-result,
#bugprone-parent-virtual-call,
#bugprone-posix-return,
#bugprone-redundant-branch-condition,
#bugprone-reserved-identifier,
#bugprone-signal-handler,
#bugprone-signed-char-misuse,
#bugprone-sizeof-container,
#bugprone-sizeof-expression,
#bugprone-spuriously-wake-up-functions,
#bugprone-string-constructor,
#bugprone-string-integer-assignment,
#bugprone-string-literal-with-embedded-nul,
#bugprone-stringview-nullptr,
#bugprone-suspicious-enum-usage,
#bugprone-suspicious-include,
#bugprone-suspicious-memory-comparison,
#bugprone-suspicious-memset-usage,
#bugprone-suspicious-missing-comma,
#bugprone-suspicious-semicolon,
#bugprone-suspicious-string-compare,
#bugprone-swapped-arguments,
#bugprone-terminating-continue,
#bugprone-throw-keyword-missing,
#bugprone-too-small-loop-variable,
#bugprone-undefined-memory-manipulation,
#bugprone-undelegated-constructor,
#bugprone-unhandled-exception-at-new,
#bugprone-unhandled-self-assignment,
#bugprone-unused-raii,
#bugprone-unused-return-value,
#bugprone-use-after-move,
#bugprone-virtual-near-miss,
#cppcoreguidelines-avoid-c-arrays,
#cppcoreguidelines-avoid-goto,
#cppcoreguidelines-avoid-magic-numbers,
#cppcoreguidelines-avoid-non-const-global-variables,
#cppcoreguidelines-c-copy-assignment-signature,
#cppcoreguidelines-explicit-virtual-functions,
#cppcoreguidelines-init-variables,
#cppcoreguidelines-interfaces-global-init,
#cppcoreguidelines-macro-usage,
#cppcoreguidelines-narrowing-conversions,
#cppcoreguidelines-no-malloc,
#cppcoreguidelines-non-private-member-variables-in-classes,
#cppcoreguidelines-owning-memory,
#cppcoreguidelines-prefer-member-initializer,
#cppcoreguidelines-pro-bounds-array-to-pointer-decay,
#cppcoreguidelines-pro-bounds-constant-array-index,
#cppcoreguidelines-pro-bounds-pointer-arithmetic,
#cppcoreguidelines-pro-type-const-cast,
#cppcoreguidelines-pro-type-cstyle-cast,
#cppcoreguidelines-pro-type-member-init,
#cppcoreguidelines-pro-type-reinterpret-cast,
#cppcoreguidelines-pro-type-static-cast-downcast,
#cppcoreguidelines-pro-type-union-access,
#cppcoreguidelines-pro-type-vararg,
#cppcoreguidelines-slicing,
#cppcoreguidelines-special-member-functions,
#cppcoreguidelines-virtual-class-destructor,
#hicpp-avoid-c-arrays,
#hicpp-avoid-goto,
#hicpp-braces-around-statements,
#hicpp-deprecated-headers,
#hicpp-exception-baseclass,
#hicpp-explicit-conversions,
#hicpp-function-size,
#hicpp-invalid-access-moved,
#hicpp-member-init,
#hicpp-move-const-arg,
#hicpp-multiway-paths-covered,
#hicpp-named-parameter,
#hicpp-new-delete-operators,
#hicpp-no-array-decay,
#hicpp-no-assembler,
#hicpp-no-malloc,
#hicpp-noexcept-move,
#hicpp-signed-bitwise,
#hicpp-special-member-functions,
#hicpp-static-assert,
#hicpp-undelegated-constructor,
#hicpp-uppercase-literal-suffix,
#hicpp-use-auto,
#hicpp-use-emplace,
#hicpp-use-equals-default,
#hicpp-use-equals-delete,
#hicpp-use-noexcept,
#hicpp-use-nullptr,
#hicpp-use-override,
#hicpp-vararg,
#modernize-avoid-bind,
#modernize-avoid-c-arrays,
#modernize-concat-nested-namespaces,
#modernize-deprecated-headers,
#modernize-deprecated-ios-base-aliases,
#modernize-loop-convert,
#modernize-make-shared,
#modernize-make-unique,
#modernize-pass-by-value,
#modernize-raw-string-literal,
#modernize-redundant-void-arg,
#modernize-replace-auto-ptr,
#modernize-replace-disallow-copy-and-assign-macro,
#modernize-replace-random-shuffle,
#modernize-return-braced-init-list,
#modernize-shrink-to-fit,
#modernize-unary-static-assert,
#modernize-use-auto,
#modernize-use-bool-literals,
#modernize-use-default-member-init,
#modernize-use-emplace,
#modernize-use-equals-default,
#modernize-use-equals-delete,
#modernize-use-nodiscard,
#modernize-use-noexcept,
#modernize-use-nullptr,
#modernize-use-override,
#modernize-use-trailing-return-type,
#modernize-use-transparent-functors,
#modernize-use-uncaught-exceptions,
#modernize-use-using,
#performance-faster-string-find,
#performance-for-range-copy,
#performance-implicit-conversion-in-loop,
#performance-inefficient-algorithm,
#performance-inefficient-string-concatenation,
#performance-inefficient-vector-operation,
#performance-move-const-arg,
#performance-move-constructor-init,
#performance-no-automatic-move,
#performance-no-int-to-ptr,
#performance-noexcept-move-constructor,
#performance-trivially-destructible,
#performance-type-promotion-in-math-fn,
#performance-unnecessary-copy-initialization,
#performance-unnecessary-value-param,
#portability-restrict-system-includes,
#portability-simd-intrinsics,
#readability-avoid-const-params-in-decls,
#readability-braces-around-statements,
#readability-const-return-type,
#readability-container-contains,
#readability-container-data-pointer,
#readability-container-size-empty,
#readability-convert-member-functions-to-static,
#readability-delete-null-pointer,
#readability-duplicate-include,
#readability-else-after-return,
#readability-function-cognitive-complexity,
#readability-function-size,
#readability-identifier-length,
#readability-identifier-naming,
#readability-implicit-bool-conversion,
#readability-inconsistent-declaration-parameter-name,
#readability-isolate-declaration,
#readability-magic-numbers,
#readability-make-member-function-const,
#readability-misleading-indentation,
#readability-misplaced-array-index,
#readability-named-parameter,
#readability-non-const-parameter,
#readability-qualified-auto,
#readability-redundant-access-specifiers,
#readability-redundant-control-flow,
#readability-redundant-declaration,
#readability-redundant-function-ptr-dereference,
#readability-redundant-member-init,
#readability-redundant-preprocessor,
#readability-redundant-smartptr-get,
#readability-redundant-string-cstr,
#readability-redundant-string-init,
#readability-simplify-boolean-expr,
#readability-simplify-subscript-expr,
#readability-static-accessed-through-instance,
#readability-static-definition-in-anonymous-namespace,
#readability-string-compare,
#readability-suspicious-call-argument,
#readability-uniqueptr-delete-release,
#readability-uppercase-literal-suffix,
#readability-use-anyofallof
"

8
.editorconfig Normal file
View File

@@ -0,0 +1,8 @@
root = true
# Don't set line endings to avoid conflict with core.autocrlf flag.
# Line endings on checkout/checkin are controlled by .gitattributes file.
[*]
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

1
.gitattributes vendored Executable file → Normal file
View File

@@ -1 +1,2 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

5
.github/CODEOWNERS vendored Normal file
View File

@@ -0,0 +1,5 @@
# Default owner
* @dbaileychess derekbailey@google.com
# Prevent modification of this file
.github/CODEOWNERS @dbaileychess derekbailey@google.com

12
.github/ISSUE_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,12 @@
Thank you for submitting an issue!
Please make sure you include the names of the affected language(s), compiler version(s), operating system version(s), and FlatBuffers version(s) in your issue title.
This helps us get the correct maintainers to look at your issue. Here are examples of good titles:
- Crash when accessing FlatBuffer [C++, gcc 4.8, OS X, master]
- Flatc converts a protobuf 'bytes' field to 'string' in fbs schema file [all languages, FlatBuffers 1.4]
Include other details as appropriate.
Thanks!

11
.github/ISSUE_TEMPLATE/404-doc.md vendored Normal file
View File

@@ -0,0 +1,11 @@
---
name: 404 Doc
about: To fix broken documentation links
title: "[Doc 404]"
labels: documentation
assignees: dbaileychess
---
Target URL:
[Optional] Source Site:

19
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,19 @@
Thank you for submitting a PR!
Please delete this standard text once you've created your own description.
If you make changes to any of the code generators (`src/idl_gen*`) be sure to
[build](https://google.github.io/flatbuffers/flatbuffers_guide_building.html) your project, as it will generate code based on the changes. If necessary
the code generation script can be directly run (`scripts/generate_code.py`),
requires Python3. This allows us to better see the effect of the PR.
If your PR includes C++ code, please adhere to the
[Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html),
and don't forget we try to support older compilers (e.g. VS2010, GCC 4.6.3),
so only some C++11 support is available.
For any C++ changes, please make sure to run `sh scripts/clang-format-git.sh`
Include other details as appropriate.
Thanks!

6
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

137
.github/labeler.yml vendored Normal file
View File

@@ -0,0 +1,137 @@
# Configuration for Auto Labeler during pull request
#
# See https://github.com/actions/labeler for file format
# and https://github.com/google/flatbuffers/labels for a list of valid labels
#
# See .github/workflows/label.yml for Github Action workflow script
"c#":
- changed-files:
- any-glob-to-any-file:
- '**/*.cs'
- 'net/**/*'
- 'tests/FlatBuffers.Test/**/*'
- 'tests/FlatBuffers.Benchmarks/**/*'
- 'src/idl_gen_csharp.cpp'
swift:
- changed-files:
- any-glob-to-any-file:
- '**/*.swift'
- 'swift/**/*'
- 'tests/swift/**'
- 'src/idl_gen_swift.cpp'
nim:
- changed-files:
- any-glob-to-any-file:
- '**/*.nim'
- 'nim/**/*'
- 'src/idl_gen_nim.cpp'
- 'src/bfbs_gen_nim.cpp'
javascript:
- changed-files:
- any-glob-to-any-file:
- '**/*.js'
- 'src/idl_gen_ts.cpp'
typescript:
- changed-files:
- any-glob-to-any-file:
- '**/*.ts'
- 'src/idl_gen_ts.cpp'
- 'grpc/flatbuffers-js-grpc/**/*.ts'
golang:
- changed-files:
- any-glob-to-any-file:
- '**/*.go'
- 'src/idl_gen_go.cpp'
python:
- changed-files:
- any-glob-to-any-file:
- '**/*.py'
- 'src/idl_gen_python.cpp'
java:
- changed-files:
- any-glob-to-any-file:
- '**/*.java'
- 'src/idl_gen_java.cpp'
kotlin:
- changed-files:
- any-glob-to-any-file:
- '**/*.kt'
- 'src/idl_gen_kotlin.cpp'
- 'src/idl_gen_kotlin_kmp.cpp'
lua:
- changed-files:
- any-glob-to-any-file:
- '**/*.lua'
- 'lua/**/*'
- 'src/bfbs_gen_lua.cpp'
lobster:
- changed-files:
- any-glob-to-any-file:
- '**/*.lobster'
- 'src/idl_gen_lobster.cpp'
php:
- changed-files:
- any-glob-to-any-file:
- '**/*.php'
- 'src/idl_gen_php.cpp'
rust:
- changed-files:
- any-glob-to-any-file:
- '**/*.rs'
- 'rust/**/*'
- 'src/idl_gen_rust.cpp'
dart:
- changed-files:
- any-glob-to-any-file:
- '**/*.dart'
- 'src/idl_gen_dart.cpp'
"c++":
- changed-files:
- any-glob-to-any-file:
- '**/*.cc'
- '**/*.cpp'
- '**/*.h'
json:
- changed-files:
- any-glob-to-any-file:
- '**/*.json'
- 'src/idl_gen_json_schema.cpp'
codegen:
- changed-files:
- any-glob-to-any-file:
- 'src/**/*'
documentation:
- changed-files:
- any-glob-to-any-file:
- 'docs/**/*'
- '**/*.md'
CI:
- changed-files:
- any-glob-to-any-file:
- '.github/**/*'
- '.bazelci/**/*'
grpc:
- changed-files:
- any-glob-to-any-file:
- 'grpc/**/*'
- 'src/idl_gen_grpc.cpp'

643
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,643 @@
name: CI
permissions: read-all
on:
# For manual tests.
workflow_dispatch:
push:
tags:
- "*" # new tag version, like `0.8.4` or else
branches:
- master
pull_request:
branches:
- master
schedule:
# Run daily at 4:45 A.M. to catch dependencies that break us.
- cron: '45 4 * * *'
jobs:
build-linux:
permissions:
contents: write
outputs:
digests-gcc: ${{ steps.hash-gcc.outputs.hashes }}
digests-clang: ${{ steps.hash-clang.outputs.hashes }}
name: Build Linux
runs-on: ubuntu-24.04
strategy:
matrix:
cxx: [g++-13, clang++-18]
fail-fast: false
steps:
- uses: actions/checkout@v6
- name: cmake
run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON -DFLATBUFFERS_STATIC_FLATC=ON .
- name: build
run: make -j
- name: test
run: ./flattests
- name: make flatc executable
run: |
chmod +x flatc
./flatc --version
- name: upload build artifacts
uses: actions/upload-artifact@v7
with:
name: Linux flatc binary ${{ matrix.cxx }}
path: flatc
# Below if only for release.
- name: Zip file
if: startsWith(github.ref, 'refs/tags/')
run: zip Linux.flatc.binary.${{ matrix.cxx }}.zip flatc
- name: Release zip file
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: Linux.flatc.binary.${{ matrix.cxx }}.zip
- name: Generate SLSA subjects - clang
if: matrix.cxx == 'clang++-18' && startsWith(github.ref, 'refs/tags/')
id: hash-clang
run: echo "hashes=$(sha256sum Linux.flatc.binary.${{ matrix.cxx }}.zip | base64 -w0)" >> $GITHUB_OUTPUT
- name: Generate SLSA subjects - gcc
if: matrix.cxx == 'g++-13' && startsWith(github.ref, 'refs/tags/')
id: hash-gcc
run: echo "hashes=$(sha256sum Linux.flatc.binary.${{ matrix.cxx }}.zip | base64 -w0)" >> $GITHUB_OUTPUT
build-linux-no-file-tests:
name: Build Linux with -DFLATBUFFERS_NO_FILE_TESTS
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: cmake
run: CXX=clang++-18 cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON -DFLATBUFFERS_CXX_FLAGS="-DFLATBUFFERS_NO_FILE_TESTS" .
- name: build
run: make -j
- name: test
run: ./flattests
build-linux-out-of-source:
name: Build Linux with out-of-source build location
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: make build directory
run: mkdir build
- name: cmake
working-directory: build
run: >
CXX=clang++-18 cmake .. -G "Unix Makefiles" -DFLATBUFFERS_STRICT_MODE=ON
-DFLATBUFFERS_BUILD_CPP17=ON -DFLATBUFFERS_CPP_STD=17
- name: build
working-directory: build
run: make -j
- name: test
working-directory: build
run: pwd && ./flattests
- name: test C++17
working-directory: build
run: ./flattests_cpp17
build-linux-cpp-std:
name: Build Linux C++
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
std: [11, 14, 17, 20, 23]
cxx: [g++-13, clang++-18]
exclude:
# Clang++15 10.3.0 stdlibc++ doesn't fully support std 23
- cxx: clang++-18
std: 23
steps:
- uses: actions/checkout@v6
- name: cmake
run: >
CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles"
-DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON
-DFLATBUFFERS_CPP_STD=${{ matrix.std }}
-DFLATBUFFERS_BUILD_CPP17=${{ matrix.std >= 17 && 'On' || 'Off'}}
- name: build
run: make -j
- name: test
run: ./flattests
- name: test C++17
if: matrix.std >= 17
run: ./flattests_cpp17
build-cpp-std:
name: Build Windows C++
runs-on: windows-2022
strategy:
matrix:
std: [11, 14, 17, 20, 23]
fail-fast: false
steps:
- uses: actions/checkout@v6
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- name: cmake
run: >
cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release
-DFLATBUFFERS_STRICT_MODE=ON
-DFLATBUFFERS_CPP_STD=${{ matrix.std }}
-DFLATBUFFERS_BUILD_CPP17=${{ matrix.std >= 17 && 'On' || 'Off'}}
- name: build
run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64
- name: test
run: Release\flattests.exe
- name: test C++17
if: matrix.std >= 17
run: Release\flattests_cpp17.exe
build-windows:
permissions:
contents: write
outputs:
digests: ${{ steps.hash.outputs.hashes }}
name: Build Windows 2022
runs-on: windows-2022
steps:
- uses: actions/checkout@v6
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- name: cmake
run: cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_CPP17=ON -DFLATBUFFERS_STRICT_MODE=ON .
- name: build
run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64
- name: test
run: Release\flattests.exe
- name: upload build artifacts
uses: actions/upload-artifact@v7
with:
name: Windows flatc binary
path: Release\flatc.exe
# Below if only for release.
- name: Zip file
if: startsWith(github.ref, 'refs/tags/')
run: move Release/flatc.exe . && Compress-Archive flatc.exe Windows.flatc.binary.zip
- name: Release binary
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: Windows.flatc.binary.zip
- name: Generate SLSA subjects
if: startsWith(github.ref, 'refs/tags/')
id: hash
shell: bash
run: echo "hashes=$(sha256sum Windows.flatc.binary.zip | base64 -w0)" >> $GITHUB_OUTPUT
build-dotnet-windows:
name: Build .NET Windows
runs-on: windows-2022
strategy:
matrix:
configuration: [
'',
'-p:UnsafeByteBuffer=true',
'-p:EnableSpanT=true,UnsafeByteBuffer=true'
]
steps:
- uses: actions/checkout@v6
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v5
with:
dotnet-version: '8.0.x'
- name: Build
run: |
cd tests\FlatBuffers.Test
dotnet new sln --force --name FlatBuffers.Test --format sln
dotnet sln FlatBuffers.Test.sln add FlatBuffers.Test.csproj
dotnet build -c Release ${{matrix.configuration}} FlatBuffers.Test.sln
- name: Run net6.0
run: |
cd tests\FlatBuffers.Test\bin\Release\net6.0
dir
.\FlatBuffers.Test.exe
- name: Run net8.0
run: |
cd tests\FlatBuffers.Test\bin\Release\net8.0
.\FlatBuffers.Test.exe
build-mac-intel:
permissions:
contents: write
outputs:
digests: ${{ steps.hash.outputs.hashes }}
name: Build Mac (for Intel)
runs-on: macos-15-intel
steps:
- uses: actions/checkout@v6
- name: cmake
run: cmake -G "Xcode" -DCMAKE_OSX_ARCHITECTURES="x86_64" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON .
- name: build
run: xcodebuild -toolchain clang -configuration Release -target flattests
- name: check that the binary is x86_64
run: |
info=$(file Release/flatc)
echo $info
echo $info | grep "Mach-O 64-bit executable x86_64"
- name: test
run: Release/flattests
- name: make flatc executable
run: |
chmod +x Release/flatc
Release/flatc --version
- name: upload build artifacts
uses: actions/upload-artifact@v7
with:
name: Mac flatc binary Intel
path: Release/flatc
# Below if only for release.
- name: Zip file
if: startsWith(github.ref, 'refs/tags/')
run: mv Release/flatc . && zip MacIntel.flatc.binary.zip flatc
- name: Release binary
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: MacIntel.flatc.binary.zip
- name: Generate SLSA subjects
if: startsWith(github.ref, 'refs/tags/')
id: hash
run: echo "hashes=$(shasum -a 256 MacIntel.flatc.binary.zip | base64)" >> $GITHUB_OUTPUT
build-mac-universal:
permissions:
contents: write
outputs:
digests: ${{ steps.hash.outputs.hashes }}
name: Build Mac (universal build)
runs-on: macos-latest
steps:
- uses: actions/checkout@v6
- name: cmake
run: cmake -G "Xcode" -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON .
- name: build
run: xcodebuild -toolchain clang -configuration Release -target flattests
- name: check that the binary is "universal"
run: |
info=$(file Release/flatc)
echo $info
echo $info | grep "Mach-O universal binary with 2 architectures"
- name: test
run: Release/flattests
- name: make flatc executable
run: |
chmod +x Release/flatc
Release/flatc --version
- name: upload build artifacts
uses: actions/upload-artifact@v7
with:
name: Mac flatc binary Universal
path: Release/flatc
# Below if only for release.
- name: Zip file
if: startsWith(github.ref, 'refs/tags/')
run: mv Release/flatc . && zip Mac.flatc.binary.zip flatc
- name: Release binary
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: Mac.flatc.binary.zip
- name: Generate SLSA subjects
if: startsWith(github.ref, 'refs/tags/')
id: hash
run: echo "hashes=$(shasum -a 256 Mac.flatc.binary.zip | base64)" >> $GITHUB_OUTPUT
build-android:
name: Build Android (on Linux)
if: false #disabled due to continual failure
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: set up Java
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
- name: set up Gradle
uses: gradle/actions/setup-gradle@v5
- name: set up flatc
run: |
cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_STRICT_MODE=ON .
make -j
echo "${PWD}" >> $GITHUB_PATH
- name: build
working-directory: android
run: gradle clean build
build-generator:
name: Check Generated Code
runs-on: ubuntu-24.04
strategy:
matrix:
cxx: [g++-13, clang++-18]
steps:
- uses: actions/checkout@v6
- name: cmake
run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON . && make -j
- name: Generate
run: scripts/check_generate_code.py
- name: Generate gRPC
run: scripts/check-grpc-generated-code.py
build-generator-windows:
name: Check Generated Code on Windows
runs-on: windows-2022
steps:
- uses: actions/checkout@v6
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- name: cmake
run: cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_CPP17=ON -DFLATBUFFERS_STRICT_MODE=ON .
- name: build
run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64
- name: Generate
run: python3 scripts/check_generate_code.py --flatc Release\flatc.exe
- name: Generate gRPC
run: python3 scripts/check-grpc-generated-code.py --flatc Release\flatc.exe
build-benchmarks:
name: Build Benchmarks (on Linux)
runs-on: ubuntu-24.04
strategy:
matrix:
cxx: [g++-13]
steps:
- uses: actions/checkout@v6
- name: cmake
run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DFLATBUFFERS_CXX_FLAGS="-Wno-unused-parameter -fno-aligned-new" -DFLATBUFFERS_BUILD_BENCHMARKS=ON -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON . && make -j
- name: Run benchmarks
run: ./flatbenchmark --benchmark_repetitions=5 --benchmark_display_aggregates_only=true --benchmark_out_format=console --benchmark_out=benchmarks/results_${{matrix.cxx}}
- name: Upload benchmarks results
uses: actions/upload-artifact@v7
with:
name: Linux flatbenchmark results ${{matrix.cxx}}
path: benchmarks/results_${{matrix.cxx}}
build-java:
name: Build Java
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: test
working-directory: java
run: mvn test
build-kotlin-macos:
name: Build Kotlin MacOS
runs-on: macos-15
steps:
- name: Checkout
uses: actions/checkout@v6
- name: set up Java
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
- name: set up Gradle
uses: gradle/actions/setup-gradle@v5
- name: Build flatc
run: |
cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF .
make -j
echo "${PWD}" >> $GITHUB_PATH
- name: Build
working-directory: kotlin
run: ./gradlew clean iosSimulatorArm64Test macosX64Test macosArm64Test
build-kotlin-linux:
name: Build Kotlin Linux
if: false #disabled due to continual failure
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v6
- name: set up Java
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
- name: set up Gradle
uses: gradle/actions/setup-gradle@v5
- name: Build flatc
run: |
cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF .
make -j
echo "${PWD}" >> $GITHUB_PATH
- name: Build
working-directory: kotlin
# we are using docker's version of gradle
# so no need for wrapper validation or user
# gradlew
run: gradle jvmMainClasses jvmTest jsTest jsBrowserTest
build-rust-linux:
name: Build Rust Linux
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: test
working-directory: tests
run: bash RustTest.sh
build-rust-windows:
name: Build Rust Windows
runs-on: windows-2022
steps:
- uses: actions/checkout@v6
- name: test
working-directory: tests
run: ./RustTest.bat
build-python:
name: Build Python
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: flatc
# FIXME: make test script not rely on flatc
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_STRICT_MODE=ON . && make -j
- name: test
working-directory: tests
run: bash PythonTest.sh
build-go:
name: Build Go
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: flatc
# FIXME: make test script not rely on flatc
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_STRICT_MODE=ON . && make -j
- name: test
working-directory: tests
run: bash GoTest.sh
build-php:
name: Build PHP
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: flatc
# FIXME: make test script not rely on flatc
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_STRICT_MODE=ON . && make -j
- name: test
working-directory: tests
run: |
php phpTest.php
sh phpUnionVectorTest.sh
build-swift:
name: Test Swift Linux
strategy:
matrix:
swift: ["6.0", "6.1", "6.2"]
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- uses: swift-actions/setup-swift@v2
with:
swift-version: ${{ matrix.swift }}
- name: Get swift version
run: swift --version
- name: test
run: swift test
build-swift-windows:
name: Test swift windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
- uses: SwiftyLab/setup-swift@latest
with:
swift-version: '6.1'
- run: swift build
- run: swift test
build-swift-wasm:
name: Test Swift Wasm
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- uses: swift-actions/setup-swift@v2
with:
swift-version: 6.2.1
- uses: bytecodealliance/actions/wasmtime/setup@v1
- name: Install Swift SDK
run: swift sdk install https://download.swift.org/swift-6.2.1-release/wasm-sdk/swift-6.2.1-RELEASE/swift-6.2.1-RELEASE_wasm.artifactbundle.tar.gz --checksum 482b9f95462b87bedfafca94a092cf9ec4496671ca13b43745097122d20f18af
- name: Test
working-directory: tests/swift/Wasm.tests
run: |
swift sdk list
swift build --build-tests --swift-sdk swift-6.2.1-RELEASE_wasm
wasmtime --dir . .build/wasm32-unknown-wasip1/debug/FlatBuffers.Test.Swift.WasmPackageTests.xctest --testing-library swift-testing
build-ts:
name: Build TS
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: flatc
# FIXME: make test script not rely on flatc
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF . && make -j
- name: pnpm
run: npm install -g pnpm
- name: deps
run: pnpm i
- name: compile
run: pnpm compile
- name: test
working-directory: tests/ts
run: |
python3 TypeScriptTest.py
build-dart:
name: Build Dart
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- uses: dart-lang/setup-dart@v1
with:
sdk: stable
- name: flatc
# FIXME: make test script not rely on flatc
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_STRICT_MODE=ON . && make -j
- name: test
working-directory: tests
run: bash DartTest.sh
build-nim:
name: Build Nim
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: flatc
# FIXME: make test script not rely on flatc
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF . && make -j
- uses: jiro4989/setup-nim-action@v2
- name: install library
working-directory: nim
run: nimble -y develop && nimble install
- name: test
working-directory: tests/nim
run: python3 testnim.py
bazel:
name: Bazel
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
# Explicitly use 8.5.1 until we can update or https://github.com/actions/runner-images/issues/13564 is fixed.
- name: Set env
run: >
echo "USE_BAZEL_VERSION=8.5.1" >> $GITHUB_ENV
- name: bazel build
run: >
bazel build
//:flatc
//:flatbuffers
//tests:flatbuffers_test
- name: bazel test
run: >
bazel test
//tests:flatbuffers_test
release-digests:
if: startsWith(github.ref, 'refs/tags/')
needs: [build-linux, build-windows, build-mac-intel, build-mac-universal]
outputs:
digests: ${{ steps.hash.outputs.digests }}
runs-on: ubuntu-24.04
steps:
- name: Merge results
id: hash
env:
LINUXGCC_DIGESTS: "${{ needs.build-linux.outputs.digests-gcc }}"
LINUXCLANG_DIGESTS: "${{ needs.build-linux.outputs.digests-clang }}"
MAC_DIGESTS: "${{ needs.build-mac-universal.outputs.digests }}"
MACINTEL_DIGESTS: "${{ needs.build-mac-intel.outputs.digests }}"
WINDOWS_DIGESTS: "${{ needs.build-windows.outputs.digests }}"
run: |
set -euo pipefail
echo "$LINUXGCC_DIGESTS" | base64 -d > checksums.txt
echo "$LINUXCLANG_DIGESTS" | base64 -d >> checksums.txt
echo "$MAC_DIGESTS" | base64 -d >> checksums.txt
echo "$MACINTEL_DIGESTS" | base64 -d >> checksums.txt
echo "$WINDOWS_DIGESTS" | base64 -d >> checksums.txt
echo "digests=$(cat checksums.txt | base64 -w0)" >> $GITHUB_OUTPUT
provenance:
if: startsWith(github.ref, 'refs/tags/')
needs: [release-digests]
permissions:
actions: read # To read the workflow path.
id-token: write # To sign the provenance.
contents: write # To add assets to a release.
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.1.0
with:
base64-subjects: "${{ needs.release-digests.outputs.digests }}"
upload-assets: true # Optional: Upload to a new release

36
.github/workflows/docs.yml vendored Normal file
View File

@@ -0,0 +1,36 @@
name: docs
on:
# For manual pushes.
workflow_dispatch:
# Pushes to main that touch the documentation directory.
push:
branches:
- master
paths:
- 'docs/**'
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- uses: actions/setup-python@v6
with:
python-version: 3.x
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@v5
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-
- run: pip install mkdocs-material
- run: pip install mkdocs-redirects
- run: mkdocs gh-deploy --force -f docs/mkdocs.yml

24
.github/workflows/label.yml vendored Normal file
View File

@@ -0,0 +1,24 @@
# This workflow will triage pull requests and apply a label based on the
# paths that are modified in the pull request.
#
# To use this workflow, you will need to set up a .github/labeler.yml
# file with configuration. For more information, see:
# https://github.com/actions/labeler
name: Labeler
permissions: read-all
on: [pull_request_target]
jobs:
label:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v6
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"

34
.github/workflows/main.yml vendored Normal file
View File

@@ -0,0 +1,34 @@
name: OSS-Fuzz
permissions: read-all
on:
pull_request:
branches:
- master
paths:
- include/**
- src/**
- tests/**.cpp
- tests/**.h
jobs:
Fuzzing:
runs-on: ubuntu-latest
steps:
- name: Build Fuzzers
id: build
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: 'flatbuffers'
language: c++
- name: Run Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
oss-fuzz-project-name: 'flatbuffers'
language: c++
fuzz-seconds: 60
- name: Upload Crash
uses: actions/upload-artifact@v7
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
path: ./out/artifacts

152
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,152 @@
name: Release
permissions: read-all
on:
# For manual tests.
workflow_dispatch:
release:
types: [published]
jobs:
publish-npm:
name: Publish NPM
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-pypi:
name: Publish PyPi
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./python
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: '3.10'
- name: Install Dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install build twine
- name: Build
run: |
python3 -m build .
- name: Upload to PyPi
run: |
python3 -m twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TWINE_TOKEN }}
publish-nuget:
name: Publish NuGet
runs-on: windows-latest
defaults:
run:
working-directory: ./net/flatbuffers
steps:
- uses: actions/checkout@v6
- uses: actions/setup-dotnet@v5
with:
dotnet-version: '8.0.x'
- name: Build
run: |
dotnet build Google.FlatBuffers.csproj -c Release
- name: Pack
run: |
dotnet pack Google.FlatBuffers.csproj -c Release
- name: Upload to NuGet
run: |
dotnet nuget push .\bin\Release\Google.FlatBuffers.*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
publish-maven:
name: Publish Maven
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./java
steps:
- uses: actions/checkout@v6
- name: Set up Maven Central Repository
uses: actions/setup-java@v5
with:
java-version: '11'
distribution: 'adopt'
cache: 'maven'
server-id: ossrh
server-username: OSSRH_USERNAME
server-password: OSSRH_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE # this needs to be an env var
- name: Publish Maven
run: mvn --batch-mode clean deploy
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USER_V2 }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN_V2 }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
publish-maven-kotlin:
name: Publish Maven - Kotlin
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./kotlin
steps:
- uses: actions/checkout@v6
- name: Set up Maven Central Repository
uses: actions/setup-java@v5
with:
java-version: '11'
distribution: 'adopt'
cache: 'maven'
server-id: ossrh
server-username: OSSRH_USERNAME
server-password: OSSRH_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE # this needs to be an env var
- name: Publish Kotlin Library on Maven
run: ./gradlew publishAllPublicationsToSonatypeRepository
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USER_V2 }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN_V2 }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
publish-crates:
name: Publish crates.io
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Publish Flatbuffers
uses: katyo/publish-crates@v2
with:
path: ./rust/flatbuffers
registry-token: ${{ secrets.CARGO_TOKEN }}
- name: Publish Flexbuffers
uses: katyo/publish-crates@v2
with:
path: ./rust/flexbuffers
registry-token: ${{ secrets.CARGO_TOKEN }}

37
.github/workflows/stale.yml vendored Normal file
View File

@@ -0,0 +1,37 @@
name: Mark stale issues and pull requests
permissions:
issues: write
pull-requests: write
on:
# For manual tests.
workflow_dispatch:
schedule:
- cron: "30 20 * * *"
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v10
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
operations-per-run: 500
exempt-all-milestones: true
remove-stale-when-updated: true
stale-issue-message: 'This issue is stale because it has been open 6 months with no activity. Please comment or label `not-stale`, or this will be closed in 14 days.'
close-issue-message: 'This issue was automatically closed due to no activity for 6 months plus the 14 day notice period.'
days-before-issue-stale: 182 # 6 months
days-before-issue-close: 14 # 2 weeks
exempt-issue-labels: not-stale
stale-pr-message: 'This pull request is stale because it has been open 6 months with no activity. Please comment or label `not-stale`, or this will be closed in 14 days.'
close-pr-message: 'This pull request was automatically closed due to no activity for 6 months plus the 14 day notice period.'
days-before-pr-stale: 182 # 6 months
days-before-pr-close: 14 # 2 week
exempt-pr-labels: not-stale
exempt-draft-pr: false

114
.gitignore vendored Executable file → Normal file
View File

@@ -1,48 +1,162 @@
*_wire.txt
*_wire.bin
.DS_Store
**/.build
build
**/Packages
/*.xcodeproj
**/xcuserdata/
**/xcshareddata/
**/.swiftpm/
*.o
*.o.d
*.class
*.a
*.swp
*~
*.vcxproj
*.vcxproj.filters
*.vcxproj.user
*.sln
*.suo
*.opendb
*.keystore
**/.vs/**
**/bin/**
!tests/rust_usage_test/bin/**
**/gen/**
**/libs/**
**/obj/**
**/*.dir/**
**/CMakeFiles/**
**/cmake_install.cmake
**/install_manifest.txt
**/CMakeCache.txt
**/CMakeTestfile.cmake
**/CPackConfig.cmake
**/CPackSourceConfig.cmake
**/compile_commands.json
**/Debug/**
**/Release/**
**/RelWithDebInfo/**
**/x64/ #build artifacts from VS
build.xml
local.properties
project.properties
proguard-project.txt
linklint_results
Makefile
flatbenchmark
flatbenchmark.exe
flatc
flatc.exe
flathash
flathash.exe
flattests
flattests.exe
flattests_cpp17
flattests_cpp17.exe
flatsamplebinary
flatsamplebinary.exe
flatsampletext
flatsampletext.exe
flatsamplebfbs
flatsamplebfbs.exe
grpctest
grpctest.exe
snapshot.sh
tags
tests/dart_gen
tests/go_gen
tests/monsterdata_java_wire.mon
tests/monsterdata_java_wire_sp.mon
tests/monsterdata_go_wire.mon
tests/monsterdata_javascript_wire.mon
tests/monsterdata_lobster_wire.mon
tests/monsterdata_rust_wire.mon
tests/php/
CMakeLists.txt.user
CMakeScripts/**
CTestTestfile.cmake
flatbuffers-config-version.cmake
FlatBuffers.cbp
build/Xcode/FlatBuffers.xcodeproj/project.xcworkspace/**
build/Xcode/FlatBuffers.xcodeproj/xcuserdata/**
FlatBuffers.xcodeproj/
java/.idea
java/*.iml
.idea
*.iml
target
java/target
**/*.pyc
build/VS2010/FlatBuffers.sdf
build/VS2010/FlatBuffers.opensdf
build/VS2010/ipch/**/*.ipch
*.so
Testing/Temporary
.cproject
.settings/
.project
net/**/obj
node_modules/
android/.externalNativeBuild/
android/.gradle/
android/build/
samples/android/.externalNativeBuild/
samples/android/.gradle/
samples/android/build/
js/**/*.js
js/**/*.d.ts
mjs/**/*.js
mjs/**/*.d.ts
/bazel-bin
/bazel-flatbuffers
/bazel-genfiles
/bazel-out
/bazel-testlogs
.ninja_deps
.ninja_log
build.ninja
rules.ninja
.vscode
dart/.pub/
dart/.packages
dart/pubspec.lock
dart/.dart_tool/
dart/build/
dart/doc/api/
Cargo.lock
.corpus**
.seed**
.crash**
grpc/google/
**/Package.resolved
.clangd/**
package-lock.json
/*.ilk
/*.pdb
.clwb
yarn-error.log
.cache/
/flatbuffers.lib
.cmake/
**/dist
**/vendor
**/go.sum
flatbuffers.pc
**/FlatBuffers.Test.Swift.xcodeproj
**/html/**
**/latex/**
# https://cmake.org/cmake/help/latest/module/FetchContent.html#variable:FETCHCONTENT_BASE_DIR
cmake-build-debug/
_deps/
**/.gradle/**
kotlin/**/generated
MODULE.bazel.lock
# Ignore the generated docs
docs/site
# Ignore generated files
*.fbs.h

1
.npmrc Normal file
View File

@@ -0,0 +1 @@
hoist=false

127
BUILD.bazel Normal file
View File

@@ -0,0 +1,127 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
licenses(["notice"])
package(
default_visibility = ["//visibility:public"],
)
exports_files([
"LICENSE",
"tsconfig.json",
])
config_setting(
name = "platform_freebsd",
constraint_values = [
"@platforms//os:freebsd",
],
)
config_setting(
name = "platform_openbsd",
constraint_values = [
"@platforms//os:openbsd",
],
)
filegroup(
name = "distribution",
srcs = [
".bazelignore",
".npmrc",
"BUILD.bazel",
"MODULE.bazel",
"build_defs.bzl",
"package.json",
"pnpm-lock.yaml",
"typescript.bzl",
"//grpc/src/compiler:distribution",
"//include/codegen:distribution",
"//reflection:distribution",
"//src:distribution",
"//ts:distribution",
] + glob([
"include/flatbuffers/*.h",
]),
visibility = ["//visibility:public"],
)
# Public flatc library to compile flatbuffer files at runtime.
cc_library(
name = "flatbuffers",
hdrs = ["//:public_headers"],
linkstatic = 1,
strip_include_prefix = "/include",
deps = ["//src:flatbuffers"],
)
# Public C++ headers for the Flatbuffers library.
filegroup(
name = "public_headers",
srcs = [
"include/flatbuffers/allocator.h",
"include/flatbuffers/array.h",
"include/flatbuffers/base.h",
"include/flatbuffers/buffer.h",
"include/flatbuffers/buffer_ref.h",
"include/flatbuffers/code_generator.h",
"include/flatbuffers/code_generators.h",
"include/flatbuffers/default_allocator.h",
"include/flatbuffers/detached_buffer.h",
"include/flatbuffers/file_manager.h",
"include/flatbuffers/flatbuffer_builder.h",
"include/flatbuffers/flatbuffers.h",
"include/flatbuffers/flex_flat_util.h",
"include/flatbuffers/flexbuffers.h",
"include/flatbuffers/grpc.h",
"include/flatbuffers/hash.h",
"include/flatbuffers/idl.h",
"include/flatbuffers/minireflect.h",
"include/flatbuffers/reflection.h",
"include/flatbuffers/reflection_generated.h",
"include/flatbuffers/registry.h",
"include/flatbuffers/stl_emulation.h",
"include/flatbuffers/string.h",
"include/flatbuffers/struct.h",
"include/flatbuffers/table.h",
"include/flatbuffers/util.h",
"include/flatbuffers/vector.h",
"include/flatbuffers/vector_downward.h",
"include/flatbuffers/verifier.h",
],
)
# Public flatc compiler library.
cc_library(
name = "flatc_library",
linkstatic = 1,
deps = [
"//src:flatc_library",
],
)
# Public flatc compiler.
cc_binary(
name = "flatc",
data = ["//reflection:reflection_fbs_schema"],
deps = [
"//src:flatc",
],
)
filegroup(
name = "flatc_headers",
srcs = [
"include/flatbuffers/flatc.h",
],
visibility = ["//:__subpackages__"],
)
# Library used by flatbuffer_cc_library rules.
cc_library(
name = "runtime_cc",
hdrs = ["//:public_headers"],
linkstatic = 1,
strip_include_prefix = "/include",
)

201
CHANGELOG.md Normal file
View File

@@ -0,0 +1,201 @@
# Flatbuffers Change Log
All major or breaking changes will be documented in this file, as well as any
new features that should be highlighted. Minor fixes or improvements are not
necessarily listed.
## [25.12.19] (December 19 2025)(https://github.com/google/flatbuffers/releases/tag/v25.12.19)
* [C++] Default emptry vector support (#8870)
* [C++] Add --gen-absl-hash option (#8868)
* [Kotlin] Upgrade to MacOS 15 (#8845)
* [C++] Fix vector of table with naked ptrs (#8830)
* [Python] Optimize Offset/Pad/Prep (#8808)
* Implement `--file-names-only` (#8788)
* [C++] Fix size verifer (#8740)
## [25.9.23] (September 23 2025)(https://github.com/google/flatbuffers/releases/tag/v25.9.23)
* flatc: `--grpc-callback-api` flag generates C++ gRPC Callback API server `CallbackService` skeletons AND client native callback/async stubs (unary + all streaming reactor forms) (opt-in, non-breaking, issue #8596).
* Swift - Adds new API to reduce memory copying within swift (#8484)
* Rust - Support Rust edition 2024 (#8638)
* [C++] - Use the Google Style for clang-format without exceptions (#8706)
## [25.2.10] (February 10 2025)(https://github.com/google/flatbuffers/releases/tag/v25.2.10)
* Removed the old documentation pages. The new one is live at https://flatbuffers.dev
* Swift version 6.0 support (#8414)
## [25.1.24] (January 24 2025)(https://github.com/google/flatbuffers/releases/tag/v25.1.24)
* Mostly related to bazel build support.
* Min bazel supported is now 7 or higher, as WORKSPACE files are removed (#8509)
* Minor C++ codegen fix removing extra semicolon (#8488)
## [25.1.21] (January 21 2025)(https://github.com/google/flatbuffers/releases/tag/v25.1.21)
* Rust Full Reflection (#8102)
* Mostly documentation updates hosted at https://flatbuffers.dev
## [24.3.25] (March 25 2024)(https://github.com/google/flatbuffers/releases/tag/v24.3.25)
* Fixed license metadata parsing (#8253)
* [C++] Allow string_view in `LookUpByKey` in addition to null-terminated c-style strings (#8203)
## [24.3.7] (March 7 2024)(https://github.com/google/flatbuffers/releases/tag/v24.3.7)
* Just to fix some of the CI build issues from the 24.3.6 release.
## [24.3.6] (March 6 2024)(https://github.com/google/flatbuffers/releases/tag/v24.3.6)
* Fix typescript object API to allow 0 values for null-default scalars (#7864)
## [23.5.26 (May 26 2023)](https://github.com/google/flatbuffers/releases/tag/v23.5.26)
* Mostly bug fixing for 64-bit support
* Adds support for specifying underling type of unions in C++ and TS/JS (#7954)
## [23.5.9 (May 9 2023)](https://github.com/google/flatbuffers/releases/tag/v23.5.9)
* 64-bit support for C++ (#7935)
## [23.5.8 (May 8 2023)](https://github.com/google/flatbuffers/releases/tag/v23.5.8)
* add key_field to compiled tests
* Add golden language directory
* Rework cmake flatc codegeneration (#7938)
* remove defining generated files in test srcs
* Add binary schema reflection (#7932)
* Migrate from rules_nodejs to rules_js/rules_ts (take 2) (#7928)
* `flat_buffers.dart`: mark const variable finals for internal Dart linters
* fixed some windows warnings (#7929)
* inject no long for FBS generation to remove logs in flattests (#7926)
* Revert "Migrate from rules_nodejs to rules_js/rules_ts (#7923)" (#7927)
* Migrate from rules_nodejs to rules_js/rules_ts (#7923)
* Only generate @kotlin.ExperimentalUnsigned annotation on create*Vector methods having an unsigned array type parameter. (#7881)
* additional check for absl::string_view availability (#7897)
* Optionally generate Python type annotations (#7858)
* Replace deprecated command with environment file (#7921)
* drop glibc from runtime dependencies (#7906)
* Make JSON supporting advanced union features (#7869)
* Allow to use functions from `BuildFlatBuffers.cmake` from a flatbuffers installation installed with CMake. (#7912)
* TS/JS: Use TypeError instead of Error when appropriate (#7910)
* Go: make generated code more compliant to "go fmt" (#7907)
* Support file_identifier in Go (#7904)
* Optionally generate type prefixes and suffixes for python code (#7857)
* Go: add test for FinishWithFileIdentifier (#7905)
* Fix go_sample.sh (#7903)
* [TS/JS] Upgrade dependencies (#7889)
* Add a FileWriter interface (#7821)
* TS/JS: Use minvalue from enum if not found (#7888)
* [CS] Verifier (#7850)
* README.md: PyPI case typo (#7880)
* Update go documentation link to point to root module (#7879)
* use Bool for flatbuffers bool instead of Byte (#7876)
* fix using null string in vector (#7872)
* Add `flatbuffers-64` branch to CI for pushes
* made changes to the rust docs so they would compile. new_with_capacity is deprecated should use with_capacity, get_root_as_monster should be root_as_monster (#7871)
* Adding comment for code clarification (#7856)
* ToCamelCase() when kLowerCamel now converts first char to lower. (#7838)
* Fix help output for --java-checkerframework (#7854)
* Update filename to README.md and improve formatting (#7855)
* Update stale.yml
* Updated remaining usages of LICENSE.txt
## [23.3.3 (Mar 3 2023)](https://github.com/google/flatbuffers/releases/tag/v23.3.3)
* Refactoring of `flatc` generators to use an interface (#7797).
* Removed legacy cmake support and set min to 3.8 (#7801).
## [23.1.21 (Jan 21 2023)](https://github.com/google/flatbuffers/releases/tag/v23.1.20)
* Reworked entry points for Typescript/Javascript and compatibility for single
file build (#7510)
## [23.1.20 (Jan 20 2023)](https://github.com/google/flatbuffers/releases/tag/v23.1.20)
* Removed go.mod files after some versioning issues were being report (#7780).
## [23.1.4 (Jan 4 2023)](https://github.com/google/flatbuffers/releases/tag/v23.1.4)
* Major release! Just kidding, we are continuing the
[versioning scheme](https://github.com/google/flatbuffers/wiki/Versioning) of
using a date to signify releases. This results in the first release of the new
year to bump the tradition major version field.
* Go minimum version is now 1.19 (#7720) with the addition of Go modules.
* Added CI support for Big Endian regression testing (#7707).
* Fixed `getFullyQualifiedName` in typescript to return name delimited by '.'
instead of '_' (#7730).
* Fixed the versioning scheme to not include leading zeros which are not
consistently handled by every package manager. Only the last release
(12.12.06) should have suffered from this.
## [22.12.06 (Dec 06 2022)](https://github.com/google/flatbuffers/releases/tag/v22.12.06)
* Bug fixing release, no major changes.
## [22.10.25 (Oct 25 2022)](https://github.com/google/flatbuffers/releases/tag/v22.10.25)
* Added Nim language support with generator and runtime libraries (#7534).
## [22.9.29 (Sept 29 2022)](https://github.com/google/flatbuffers/releases/tag/v22.9.29)
* Rust soundness fixes to avoid the crate from bing labelled unsafe (#7518).
## [22.9.24 (Sept 24 2022)](https://github.com/google/flatbuffers/releases/tag/v22.9.24)
* 20 Major releases in a row? Nope, we switched to a new
[versioning scheme](https://github.com/google/flatbuffers/wiki/Versioning)
that is based on date.
* Python supports fixed size arrays now (#7529).
* Behavior change in how C++ object API uses `UnPackTo`. The original intent of
this was to reduce allocations by reusing an existing object to pack data
into. At some point, this logic started to merge the states of the two objects
instead of clearing the state of the packee. This change goes back to the
original intention, the packed object is cleared when getting data packed into
it (#7527).
* Fixed a bug in C++ alignment that was using `sizeof()` instead of the intended
`AlignOf()` for structs (#7520).
* C# has an
[official Nuget package](https://www.nuget.org/packages/Google.FlatBuffers)
now (#7496).
## 2.0.8 (Aug 29 2022)
* Fix for `--keep-prefix` the was generating the wrong include statements for
C++ (#7469). The bug was introduced in 2.0.7.
* Added the `Verifier::Options` option struct to allow specifying runtime
configuration settings for the verifier (#7489). This allows to skip verifying
nested flatbuffers, a on-by-default change that was introduced in 2.0.7. This
deprecates the existing `Verifier` constructor, which may be removed in a
future version.
* Refactor of `tests/test.cpp` that lead to ~10% speedup in compilation of the
entire project (#7487).
## 2.0.7 (Aug 22 2022)
* This is the first version with an explicit change log, so all the previous
features will not be listed.
* Verifier now checks that buffers are at least the minimum size required to be
a flatbuffers (12 bytes). This includes nested flatbuffers, which previously
could be declared valid at size 0.
* Annotated binaries. Given a flatbuffer binary and a schema (or binary schema)
one can generate an annotated flatbuffer (.afb) to describe each byte in the
binary with schema metadata and value.
* First binary schema generator (Lua) to generate Lua code via a .bfbs file.
This is mostly an implementation detail of flatc internals, but will be slowly
applied to the other language generators.

View File

@@ -0,0 +1,448 @@
# Copyright 2015 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# General function to create FlatBuffer build rules for the given list of
# schemas.
#
# flatbuffers_schemas: A list of flatbuffer schema files to process.
#
# schema_include_dirs: A list of schema file include directories, which will be
# passed to flatc via the -I parameter.
#
# custom_target_name: The generated files will be added as dependencies for a
# new custom target with this name. You should add that target as a dependency
# for your main target to ensure these files are built. You can also retrieve
# various properties from this target, such as GENERATED_INCLUDES_DIR,
# BINARY_SCHEMAS_DIR, and COPY_TEXT_SCHEMAS_DIR.
#
# additional_dependencies: A list of additional dependencies that you'd like
# all generated files to depend on. Pass in a blank string if you have none.
#
# generated_includes_dir: Where to generate the C++ header files for these
# schemas. The generated includes directory will automatically be added to
# CMake's include directories, and will be where generated header files are
# placed. This parameter is optional; pass in empty string if you don't want to
# generate include files for these schemas.
#
# binary_schemas_dir: If you specify an optional binary schema directory, binary
# schemas will be generated for these schemas as well, and placed into the given
# directory.
#
# copy_text_schemas_dir: If you want all text schemas (including schemas from
# all schema include directories) copied into a directory (for example, if you
# need them within your project to build JSON files), you can specify that
# folder here. All text schemas will be copied to that folder.
#
# IMPORTANT: Make sure you quote all list arguments you pass to this function!
# Otherwise CMake will only pass in the first element.
# Example: build_flatbuffers("${fb_files}" "${include_dirs}" target_name ...)
function(build_flatbuffers flatbuffers_schemas
schema_include_dirs
custom_target_name
additional_dependencies
generated_includes_dir
binary_schemas_dir
copy_text_schemas_dir)
# Test if including from FindFlatBuffers
if(FLATBUFFERS_FLATC_EXECUTABLE)
set(FLATC_TARGET "")
set(FLATC ${FLATBUFFERS_FLATC_EXECUTABLE})
elseif(TARGET flatbuffers::flatc)
set(FLATC_TARGET flatbuffers::flatc)
set(FLATC flatbuffers::flatc)
else()
set(FLATC_TARGET flatc)
set(FLATC flatc)
endif()
set(FLATC_SCHEMA_ARGS --gen-mutable)
if(FLATBUFFERS_FLATC_SCHEMA_EXTRA_ARGS)
set(FLATC_SCHEMA_ARGS
${FLATBUFFERS_FLATC_SCHEMA_EXTRA_ARGS}
${FLATC_SCHEMA_ARGS}
)
endif()
set(working_dir "${CMAKE_CURRENT_SOURCE_DIR}")
set(schema_glob "*.fbs")
# Generate the include files parameters.
set(include_params "")
set(all_generated_files "")
foreach (include_dir ${schema_include_dirs})
set(include_params -I ${include_dir} ${include_params})
if (NOT ${copy_text_schemas_dir} STREQUAL "")
# Copy text schemas from dependent folders.
file(GLOB_RECURSE dependent_schemas ${include_dir}/${schema_glob})
foreach (dependent_schema ${dependent_schemas})
file(COPY ${dependent_schema} DESTINATION ${copy_text_schemas_dir})
endforeach()
endif()
endforeach()
foreach(schema ${flatbuffers_schemas})
get_filename_component(filename ${schema} NAME_WE)
# For each schema, do the things we requested.
if (NOT ${generated_includes_dir} STREQUAL "")
set(generated_include ${generated_includes_dir}/${filename}_generated.h)
add_custom_command(
OUTPUT ${generated_include}
COMMAND ${FLATC} ${FLATC_SCHEMA_ARGS}
-o ${generated_includes_dir}
${include_params}
-c ${schema}
DEPENDS ${FLATC_TARGET} ${schema} ${additional_dependencies}
WORKING_DIRECTORY "${working_dir}")
list(APPEND all_generated_files ${generated_include})
endif()
if (NOT ${binary_schemas_dir} STREQUAL "")
set(binary_schema ${binary_schemas_dir}/${filename}.bfbs)
add_custom_command(
OUTPUT ${binary_schema}
COMMAND ${FLATC} -b --schema
-o ${binary_schemas_dir}
${include_params}
${schema}
DEPENDS ${FLATC_TARGET} ${schema} ${additional_dependencies}
WORKING_DIRECTORY "${working_dir}")
list(APPEND all_generated_files ${binary_schema})
endif()
if (NOT ${copy_text_schemas_dir} STREQUAL "")
file(COPY ${schema} DESTINATION ${copy_text_schemas_dir})
endif()
endforeach()
# Create a custom target that depends on all the generated files.
# This is the target that you can depend on to trigger all these
# to be built.
add_custom_target(${custom_target_name}
DEPENDS ${all_generated_files} ${additional_dependencies})
# Register the include directory we are using.
if (NOT ${generated_includes_dir} STREQUAL "")
include_directories(${generated_includes_dir})
set_property(TARGET ${custom_target_name}
PROPERTY GENERATED_INCLUDES_DIR
${generated_includes_dir})
endif()
# Register the binary schemas dir we are using.
if (NOT ${binary_schemas_dir} STREQUAL "")
set_property(TARGET ${custom_target_name}
PROPERTY BINARY_SCHEMAS_DIR
${binary_schemas_dir})
endif()
# Register the text schema copy dir we are using.
if (NOT ${copy_text_schemas_dir} STREQUAL "")
set_property(TARGET ${custom_target_name}
PROPERTY COPY_TEXT_SCHEMAS_DIR
${copy_text_schemas_dir})
endif()
endfunction()
# Creates a target that can be linked against that generates flatbuffer headers.
#
# This function takes a target name and a list of schemas. You can also specify
# other flagc flags using the FLAGS option to change the behavior of the flatc
# tool.
#
# When the target_link_libraries is done within a different directory than
# flatbuffers_generate_headers is called, then the target should also be dependent
# the custom generation target called GENERATE_<TARGET>.
#
# Arguments:
# TARGET: The name of the target to generate.
# SCHEMAS: The list of schema files to generate code for.
# BINARY_SCHEMAS_DIR: Optional. The directory in which to generate binary
# schemas. Binary schemas will only be generated if a path is provided.
# INCLUDE: Optional. Search for includes in the specified paths. (Use this
# instead of "-I <path>" and the FLAGS option so that CMake is aware of
# the directories that need to be searched).
# INCLUDE_PREFIX: Optional. The directory in which to place the generated
# files. Use this instead of the --include-prefix option.
# FLAGS: Optional. A list of any additional flags that you would like to pass
# to flatc.
#
# Example:
#
# flatbuffers_generate_headers(
# TARGET my_generated_headers_target
# INCLUDE_PREFIX ${MY_INCLUDE_PREFIX}"
# SCHEMAS ${MY_SCHEMA_FILES}
# BINARY_SCHEMAS_DIR "${MY_BINARY_SCHEMA_DIRECTORY}"
# FLAGS --gen-object-api)
#
# target_link_libraries(MyExecutableTarget
# PRIVATE my_generated_headers_target
# )
#
# Optional (only needed within different directory):
# add_dependencies(app GENERATE_my_generated_headers_target)
function(flatbuffers_generate_headers)
# Parse function arguments.
set(options)
set(one_value_args
"TARGET"
"INCLUDE_PREFIX"
"BINARY_SCHEMAS_DIR")
set(multi_value_args
"SCHEMAS"
"INCLUDE"
"FLAGS")
cmake_parse_arguments(
PARSE_ARGV 0
FLATBUFFERS_GENERATE_HEADERS
"${options}"
"${one_value_args}"
"${multi_value_args}")
# Test if including from FindFlatBuffers
if(FLATBUFFERS_FLATC_EXECUTABLE)
set(FLATC_TARGET "")
set(FLATC ${FLATBUFFERS_FLATC_EXECUTABLE})
elseif(TARGET flatbuffers::flatc)
set(FLATC_TARGET flatbuffers::flatc)
set(FLATC flatbuffers::flatc)
else()
set(FLATC_TARGET flatc)
set(FLATC flatc)
endif()
set(working_dir "${CMAKE_CURRENT_SOURCE_DIR}")
# Generate the include files parameters.
set(include_params "")
foreach (include_dir ${FLATBUFFERS_GENERATE_HEADERS_INCLUDE})
set(include_params -I ${include_dir} ${include_params})
endforeach()
# Create a directory to place the generated code.
set(generated_target_dir "${CMAKE_CURRENT_BINARY_DIR}/${FLATBUFFERS_GENERATE_HEADERS_TARGET}")
set(generated_include_dir "${generated_target_dir}")
if (NOT ${FLATBUFFERS_GENERATE_HEADERS_INCLUDE_PREFIX} STREQUAL "")
set(generated_include_dir "${generated_include_dir}/${FLATBUFFERS_GENERATE_HEADERS_INCLUDE_PREFIX}")
list(APPEND FLATBUFFERS_GENERATE_HEADERS_FLAGS
"--include-prefix" ${FLATBUFFERS_GENERATE_HEADERS_INCLUDE_PREFIX})
endif()
set(generated_custom_commands)
# Create rules to generate the code for each schema.
foreach(schema ${FLATBUFFERS_GENERATE_HEADERS_SCHEMAS})
get_filename_component(filename ${schema} NAME_WE)
set(generated_include "${generated_include_dir}/${filename}_generated.h")
# Generate files for grpc if needed
set(generated_source_file)
if("${FLATBUFFERS_GENERATE_HEADERS_FLAGS}" MATCHES "--grpc")
# Check if schema file contain a rpc_service definition
file(STRINGS ${schema} has_grpc REGEX "rpc_service")
if(has_grpc)
list(APPEND generated_include "${generated_include_dir}/${filename}.grpc.fb.h")
set(generated_source_file "${generated_include_dir}/${filename}.grpc.fb.cc")
endif()
endif()
add_custom_command(
OUTPUT ${generated_include} ${generated_source_file}
COMMAND ${FLATC} ${FLATC_ARGS}
-o ${generated_include_dir}
${include_params}
-c ${schema}
${FLATBUFFERS_GENERATE_HEADERS_FLAGS}
DEPENDS ${FLATC_TARGET} ${schema}
WORKING_DIRECTORY "${working_dir}"
COMMENT "Building ${schema} flatbuffers...")
list(APPEND all_generated_header_files ${generated_include})
list(APPEND all_generated_source_files ${generated_source_file})
list(APPEND generated_custom_commands "${generated_include}" "${generated_source_file}")
# Geneate the binary flatbuffers schemas if instructed to.
if (NOT ${FLATBUFFERS_GENERATE_HEADERS_BINARY_SCHEMAS_DIR} STREQUAL "")
set(binary_schema
"${FLATBUFFERS_GENERATE_HEADERS_BINARY_SCHEMAS_DIR}/${filename}.bfbs")
add_custom_command(
OUTPUT ${binary_schema}
COMMAND ${FLATC} -b --schema
-o ${FLATBUFFERS_GENERATE_HEADERS_BINARY_SCHEMAS_DIR}
${include_params}
${schema}
DEPENDS ${FLATC_TARGET} ${schema}
WORKING_DIRECTORY "${working_dir}")
list(APPEND generated_custom_commands "${binary_schema}")
list(APPEND all_generated_binary_files ${binary_schema})
endif()
endforeach()
# Create an additional target as add_custom_command scope is only within same directory (CMakeFile.txt)
set(generate_target GENERATE_${FLATBUFFERS_GENERATE_HEADERS_TARGET})
add_custom_target(${generate_target} ALL
DEPENDS ${generated_custom_commands}
COMMENT "Generating flatbuffer target ${FLATBUFFERS_GENERATE_HEADERS_TARGET}")
# Set up interface library
add_library(${FLATBUFFERS_GENERATE_HEADERS_TARGET} INTERFACE)
target_sources(
${FLATBUFFERS_GENERATE_HEADERS_TARGET}
INTERFACE
${all_generated_header_files}
${all_generated_binary_files}
${all_generated_source_files}
${FLATBUFFERS_GENERATE_HEADERS_SCHEMAS})
add_dependencies(
${FLATBUFFERS_GENERATE_HEADERS_TARGET}
${FLATC_TARGET})
target_include_directories(
${FLATBUFFERS_GENERATE_HEADERS_TARGET}
INTERFACE ${generated_target_dir})
# Organize file layout for IDEs.
source_group(
TREE "${generated_target_dir}"
PREFIX "Flatbuffers/Generated/Headers Files"
FILES ${all_generated_header_files})
source_group(
TREE "${generated_target_dir}"
PREFIX "Flatbuffers/Generated/Source Files"
FILES ${all_generated_source_files})
source_group(
TREE ${working_dir}
PREFIX "Flatbuffers/Schemas"
FILES ${FLATBUFFERS_GENERATE_HEADERS_SCHEMAS})
if (NOT ${FLATBUFFERS_GENERATE_HEADERS_BINARY_SCHEMAS_DIR} STREQUAL "")
source_group(
TREE "${FLATBUFFERS_GENERATE_HEADERS_BINARY_SCHEMAS_DIR}"
PREFIX "Flatbuffers/Generated/Binary Schemas"
FILES ${all_generated_binary_files})
endif()
endfunction()
# Creates a target that can be linked against that generates flatbuffer binaries
# from json files.
#
# This function takes a target name and a list of schemas and Json files. You
# can also specify other flagc flags and options to change the behavior of the
# flatc compiler.
#
# Adding this target to your executable ensurses that the flatbuffer binaries
# are compiled before your executable is run.
#
# Arguments:
# TARGET: The name of the target to generate.
# JSON_FILES: The list of json files to compile to flatbuffers binaries.
# SCHEMA: The flatbuffers schema of the Json files to be compiled.
# INCLUDE: Optional. Search for includes in the specified paths. (Use this
# instead of "-I <path>" and the FLAGS option so that CMake is aware of
# the directories that need to be searched).
# OUTPUT_DIR: The directly where the generated flatbuffers binaries should be
# placed.
# FLAGS: Optional. A list of any additional flags that you would like to pass
# to flatc.
#
# Example:
#
# flatbuffers_generate_binary_files(
# TARGET my_binary_data
# SCHEMA "${MY_SCHEMA_DIR}/my_example_schema.fbs"
# JSON_FILES ${MY_JSON_FILES}
# OUTPUT_DIR "${MY_BINARY_DATA_DIRECTORY}"
# FLAGS --strict-json)
#
# target_link_libraries(MyExecutableTarget
# PRIVATE my_binary_data
# )
function(flatbuffers_generate_binary_files)
# Parse function arguments.
set(options)
set(one_value_args
"TARGET"
"SCHEMA"
"OUTPUT_DIR")
set(multi_value_args
"JSON_FILES"
"INCLUDE"
"FLAGS")
cmake_parse_arguments(
PARSE_ARGV 0
FLATBUFFERS_GENERATE_BINARY_FILES
"${options}"
"${one_value_args}"
"${multi_value_args}")
# Test if including from FindFlatBuffers
if(FLATBUFFERS_FLATC_EXECUTABLE)
set(FLATC_TARGET "")
set(FLATC ${FLATBUFFERS_FLATC_EXECUTABLE})
elseif(TARGET flatbuffers::flatc)
set(FLATC_TARGET flatbuffers::flatc)
set(FLATC flatbuffers::flatc)
else()
set(FLATC_TARGET flatc)
set(FLATC flatc)
endif()
set(working_dir "${CMAKE_CURRENT_SOURCE_DIR}")
# Generate the include files parameters.
set(include_params "")
foreach (include_dir ${FLATBUFFERS_GENERATE_BINARY_FILES_INCLUDE})
set(include_params -I ${include_dir} ${include_params})
endforeach()
# Create rules to generate the flatbuffers binary for each json file.
foreach(json_file ${FLATBUFFERS_GENERATE_BINARY_FILES_JSON_FILES})
get_filename_component(filename ${json_file} NAME_WE)
set(generated_binary_file "${FLATBUFFERS_GENERATE_BINARY_FILES_OUTPUT_DIR}/${filename}.bin")
add_custom_command(
OUTPUT ${generated_binary_file}
COMMAND ${FLATC} ${FLATC_ARGS}
-o ${FLATBUFFERS_GENERATE_BINARY_FILES_OUTPUT_DIR}
${include_params}
-b ${FLATBUFFERS_GENERATE_BINARY_FILES_SCHEMA} ${json_file}
${FLATBUFFERS_GENERATE_BINARY_FILES_FLAGS}
DEPENDS ${FLATC_TARGET} ${json_file}
WORKING_DIRECTORY "${working_dir}"
COMMENT "Building ${json_file} binary flatbuffers...")
list(APPEND all_generated_binary_files ${generated_binary_file})
endforeach()
# Set up interface library
add_library(${FLATBUFFERS_GENERATE_BINARY_FILES_TARGET} INTERFACE)
target_sources(
${FLATBUFFERS_GENERATE_BINARY_FILES_TARGET}
INTERFACE
${all_generated_binary_files}
${FLATBUFFERS_GENERATE_BINARY_FILES_JSON_FILES}
${FLATBUFFERS_GENERATE_BINARY_FILES_SCHEMA})
add_dependencies(
${FLATBUFFERS_GENERATE_BINARY_FILES_TARGET}
${FLATC})
# Organize file layout for IDEs.
source_group(
TREE ${working_dir}
PREFIX "Flatbuffers/JSON Files"
FILES ${FLATBUFFERS_GENERATE_BINARY_FILES_JSON_FILES})
source_group(
TREE ${working_dir}
PREFIX "Flatbuffers/Schemas"
FILES ${FLATBUFFERS_GENERATE_BINARY_FILES_SCHEMA})
source_group(
TREE ${FLATBUFFERS_GENERATE_BINARY_FILES_OUTPUT_DIR}
PREFIX "Flatbuffers/Generated/Binary Files"
FILES ${all_generated_binary_files})
endfunction()

4
CMake/DESCRIPTION.txt Normal file
View File

@@ -0,0 +1,4 @@
FlatBuffers is a cross platform serialization library architected for
maximum memory efficiency. It allows you to directly access serialized
data without parsing/unpacking it first, while still having great
forwards/backwards compatibility.

View File

@@ -24,11 +24,13 @@
# for the given flatbuffer schema files.
# Returns the header files in ${Name}_OUTPUTS
set(FLATBUFFERS_CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR})
find_program(FLATBUFFERS_FLATC_EXECUTABLE NAMES flatc)
find_path(FLATBUFFERS_INCLUDE_DIR NAMES flatbuffers/flatbuffers.h)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(flatbuffers
find_package_handle_standard_args(FlatBuffers
DEFAULT_MSG FLATBUFFERS_FLATC_EXECUTABLE FLATBUFFERS_INCLUDE_DIR)
if(FLATBUFFERS_FOUND)
@@ -43,6 +45,7 @@ if(FLATBUFFERS_FOUND)
add_custom_command(OUTPUT ${FLATC_OUTPUT}
COMMAND ${FLATBUFFERS_FLATC_EXECUTABLE}
ARGS -c -o "${CMAKE_CURRENT_BINARY_DIR}/" ${FILE}
DEPENDS ${FILE}
COMMENT "Building C++ header for ${FILE}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endforeach()
@@ -54,3 +57,5 @@ if(FLATBUFFERS_FOUND)
else()
set(FLATBUFFERS_INCLUDE_DIR)
endif()
include("${FLATBUFFERS_CMAKE_DIR}/BuildFlatBuffers.cmake")

25
CMake/PackageDebian.cmake Normal file
View File

@@ -0,0 +1,25 @@
# ------------------- Debianization ---------------------
if (UNIX)
# Set build environment
SET(CPACK_GENERATOR "TGZ;DEB")
SET(CPACK_SOURCE_TGZ "ON")
# Common package information
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
"FlatBuffers is an efficient cross platform serialization library for C++, with support for Java, C# and Go. It was created at Google specifically for game development and other performance-critical applications.")
SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/google/flatbuffers")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Vitaly Isaev <vitalyisaev2@gmail.com>")
SET(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
SET(CPACK_PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_COMMIT}")
SET(CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}")
# Package name
SET(CPACK_DEBIAN_PACKAGE_NAME "flatbuffers")
SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE)
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
endif(UNIX)

44
CMake/PackageRedhat.cmake Normal file
View File

@@ -0,0 +1,44 @@
if (UNIX)
set(CPACK_GENERATOR "RPM")
set(CPACK_SOURCE_TGZ "ON")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "FlatBuffers serialization library and schema compiler.")
set(CPACK_RPM_PACKAGE_HOMEPAGE "https://github.com/google/flatbuffers")
set(CPACK_RPM_PACKAGE_MAINTAINER "Marc Butler <mockbutler@gmail.com>")
set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
set(CPACK_PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_COMMIT}")
set(CPACK_RPM_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}")
set(CPACK_RPM_PACKAGE_NAME "flatbuffers")
# Assume this is not a cross compilation build.
if(NOT CPACK_RPM_PACKAGE_ARCHITECTURE)
set(CPACK_RPM_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}")
endif(NOT CPACK_RPM_PACKAGE_ARCHITECTURE)
set(CPACK_RPM_PACKAGE_VENDOR "Google, Inc.")
set(CPACK_RPM_PACKAGE_LICENSE "Apache 2.0")
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE)
set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_SOURCE_DIR}/CMake/DESCRIPTION.txt)
# This may reduce rpm compatiblity with very old systems.
set(CPACK_RPM_COMPRESSION_TYPE lzma)
set(CPACK_RPM_PACKAGE_NAME "flatbuffers")
set(CPACK_PACKAGE_FILE_NAME
"${CPACK_RPM_PACKAGE_NAME}_${CPACK_RPM_PACKAGE_VERSION}_${CPACK_RPM_PACKAGE_ARCHITECTURE}")
if(NOT DEFINED ${CPACK_PACKAGING_INSTALL_PREFIX})
# Default packaging install prefix on RedHat systems is /usr.
# This is the assumed value when this variable is not defined.
# There is currently a conflict with
# /usr/${CMAKE_INSTALL_LIBDIR}/cmake which is installed by default
# by other packages on RedHat (most notably cmake-filesystem). Ensure
# that on these systems, flatbuffers does not package this path.
# This patch is required for cmake pre-3.17.
list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/${CMAKE_INSTALL_LIBDIR}/cmake")
endif()
endif(UNIX)

39
CMake/Version.cmake Normal file
View File

@@ -0,0 +1,39 @@
set(VERSION_MAJOR 25)
set(VERSION_MINOR 12)
set(VERSION_PATCH 19)
set(VERSION_COMMIT 0)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
find_program(GIT git)
if(GIT)
execute_process(
COMMAND ${GIT} describe --tags
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_DESCRIBE_DIRTY
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE GIT_DESCRIBE_RESULT
)
if(GIT_DESCRIBE_RESULT EQUAL 0)
# Test if the most recent Git tag matches the pattern "v<major>.<minor>.<patch>*"
if(GIT_DESCRIBE_DIRTY MATCHES "^v[0-9]+\\.[0-9]+\\.[0-9]+.*")
string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${GIT_DESCRIBE_DIRTY}")
string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${GIT_DESCRIBE_DIRTY}")
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${GIT_DESCRIBE_DIRTY}")
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+).*" "\\1" VERSION_COMMIT "${GIT_DESCRIBE_DIRTY}")
# If the tag points to the commit, then only the tag is shown in "git describe"
if(VERSION_COMMIT STREQUAL GIT_DESCRIBE_DIRTY)
set(VERSION_COMMIT 0)
endif()
else()
message(WARNING "\"${GIT_DESCRIBE_DIRTY}\" does not match pattern v<major>.<minor>.<patch>-<commit>")
endif()
else()
message(WARNING "git describe failed with exit code: ${GIT_DESCRIBE_RESULT}\nMake sure you cloned with tags or run 'git fetch --tags'.")
endif()
else()
message(WARNING "git is not found")
endif()
endif()
message(STATUS "Proceeding with version: ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_COMMIT}")

View File

@@ -1,22 +0,0 @@
# Initializes block variables
INIT_BIICODE_BLOCK()
# Copying data files to project/bin folder
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/samples")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/samples/monster.fbs"
"${CMAKE_CURRENT_SOURCE_DIR}/samples/monsterdata.json"
DESTINATION
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/samples")
endif()
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tests"
DESTINATION
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
endif()
# Actually create targets: EXEcutables and libraries.
ADD_BIICODE_TARGETS()
string(REPLACE " " ";" REPLACED_FLAGS ${CMAKE_CXX_FLAGS})
target_compile_options(${BII_BLOCK_TARGET} INTERFACE ${REPLACED_FLAGS})
target_include_directories(${BII_BLOCK_TARGET} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)

View File

@@ -0,0 +1,11 @@
set(PACKAGE_VERSION "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@")
# Check whether the requested PACKAGE_FIND_VERSION is compatible
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()

View File

@@ -0,0 +1,4 @@
include("${CMAKE_CURRENT_LIST_DIR}/FlatBuffersTargets.cmake" OPTIONAL)
include("${CMAKE_CURRENT_LIST_DIR}/FlatcTargets.cmake" OPTIONAL)
include("${CMAKE_CURRENT_LIST_DIR}/FlatBuffersSharedTargets.cmake" OPTIONAL)
include("${CMAKE_CURRENT_LIST_DIR}/BuildFlatBuffers.cmake" OPTIONAL)

9
CMake/flatbuffers.pc.in Normal file
View File

@@ -0,0 +1,9 @@
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: FlatBuffers
Description: Memory Efficient Serialization Library
Version: @VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@
Libs: -L${libdir} -lflatbuffers
Cflags: -I${includedir}

View File

@@ -1,13 +1,85 @@
cmake_minimum_required(VERSION 2.8)
# This is the legacy minimum version flatbuffers supported for a while.
cmake_minimum_required(VERSION 3.8...3.25.2)
project(FlatBuffers)
# Attempt to read the current version of flatbuffers by looking at the latest tag.
include(CMake/Version.cmake)
project(FlatBuffers
VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
LANGUAGES CXX)
# generate compile_commands.json
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# NOTE: Code coverage only works on Linux & OSX.
option(FLATBUFFERS_CODE_COVERAGE "Enable the code coverage build option." OFF)
option(FLATBUFFERS_BUILD_TESTS "Enable the build of tests and samples." ON)
option(FLATBUFFERS_INSTALL "Enable the installation of targets." ON)
option(FLATBUFFERS_BUILD_FLATC "Enable the build of the flatbuffers compiler" ON)
option(FLATBUFFERS_BUILD_FLATHASH "Enable the build of flathash" ON)
option(FLATBUFFERS_BUILD_FLATLIB "Enable the build of the flatbuffers library"
ON)
option(FLATBUFFERS_BUILD_FLATC "Enable the build of the flatbuffers compiler"
ON)
option(FLATBUFFERS_STATIC_FLATC "Build flatbuffers compiler with -static flag"
OFF)
option(FLATBUFFERS_BUILD_FLATHASH "Enable the build of flathash" OFF)
option(FLATBUFFERS_BUILD_BENCHMARKS "Enable the build of flatbenchmark."
OFF)
option(FLATBUFFERS_BUILD_GRPCTEST "Enable the build of grpctest" OFF)
option(FLATBUFFERS_BUILD_SHAREDLIB
"Enable the build of the flatbuffers shared library"
OFF)
option(FLATBUFFERS_LIBCXX_WITH_CLANG "Force libc++ when using Clang" ON)
# NOTE: Sanitizer check only works on Linux & OSX (gcc & llvm).
option(FLATBUFFERS_CODE_SANITIZE
"Add '-fsanitize' flags to 'flattests' and 'flatc' targets."
OFF)
option(FLATBUFFERS_PACKAGE_REDHAT
"Build an rpm using the 'package' target."
OFF)
option(FLATBUFFERS_PACKAGE_DEBIAN
"Build an deb using the 'package' target."
OFF)
option(FLATBUFFERS_BUILD_CPP17
"Enable the build of c++17 test target. \"
Requirements: Clang6, GCC7, MSVC2017 (_MSC_VER >= 1914) or higher."
OFF)
option(FLATBUFFERS_BUILD_LEGACY
"Run C++ code generator with '--cpp-std c++0x' switch."
OFF)
option(FLATBUFFERS_ENABLE_PCH
"Enable precompile headers support for 'flatbuffers' and 'flatc'. \"
Only work if CMake supports 'target_precompile_headers'. \"
This can speed up compilation time."
OFF)
option(FLATBUFFERS_SKIP_MONSTER_EXTRA
"Skip generating monster_extra.fbs that contains non-supported numerical\"
types." OFF)
option(FLATBUFFERS_STRICT_MODE
"Build flatbuffers with all warnings as errors (-Werror or /WX)."
OFF)
if(NOT DEFINED FLATBUFFERS_CPP_STD)
set(FLATBUFFERS_CPP_STD 11)
endif()
set(MSVC_LIKE OFF)
if(MSVC OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
set(MSVC_LIKE ON)
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(IS_CLANG ON)
else()
set(IS_CLANG OFF)
endif()
if(DEFINED FLATBUFFERS_COMPILATION_TIMINGS)
message("Recording Compilation Timings to ${FLATBUFFERS_COMPILATION_TIMINGS}")
file(REMOVE ${FLATBUFFERS_COMPILATION_TIMINGS})
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "time -f 'Wall: %E User: %U Sys: %S | %C' -q -a -o ${FLATBUFFERS_COMPILATION_TIMINGS}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_CUSTOM "time -f 'Wall: %E User: %U Sys: %S | %C' -q -a -o ${FLATBUFFERS_COMPILATION_TIMINGS}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "time -f 'Wall: %E User: %U Sys: %S | %C' -q -a -o ${FLATBUFFERS_COMPILATION_TIMINGS}")
endif()
if(NOT FLATBUFFERS_BUILD_FLATC AND FLATBUFFERS_BUILD_TESTS)
message(WARNING
@@ -15,18 +87,127 @@ if(NOT FLATBUFFERS_BUILD_FLATC AND FLATBUFFERS_BUILD_TESTS)
set(FLATBUFFERS_BUILD_TESTS OFF)
endif()
set(FlatBuffers_Compiler_SRCS
if(DEFINED FLATBUFFERS_MAX_PARSING_DEPTH)
# Override the default recursion depth limit.
add_definitions(-DFLATBUFFERS_MAX_PARSING_DEPTH=${FLATBUFFERS_MAX_PARSING_DEPTH})
message(STATUS "FLATBUFFERS_MAX_PARSING_DEPTH: ${FLATBUFFERS_MAX_PARSING_DEPTH}")
endif()
# Auto-detect locale-narrow 'strtod_l' and 'strtoull_l' functions.
if(NOT DEFINED FLATBUFFERS_LOCALE_INDEPENDENT)
include(CheckCXXSymbolExists)
set(FLATBUFFERS_LOCALE_INDEPENDENT 0)
if(MSVC_LIKE)
check_cxx_symbol_exists(_strtof_l stdlib.h FLATBUFFERS_HAS_STRTOF_L)
check_cxx_symbol_exists(_strtoui64_l stdlib.h FLATBUFFERS_HAS_STRTOULL_L)
else()
check_cxx_symbol_exists(strtof_l stdlib.h FLATBUFFERS_HAS_STRTOF_L)
check_cxx_symbol_exists(strtoull_l stdlib.h FLATBUFFERS_HAS_STRTOULL_L)
endif()
if(FLATBUFFERS_HAS_STRTOF_L AND FLATBUFFERS_HAS_STRTOULL_L)
set(FLATBUFFERS_LOCALE_INDEPENDENT 1)
endif()
endif()
add_definitions(-DFLATBUFFERS_LOCALE_INDEPENDENT=$<BOOL:${FLATBUFFERS_LOCALE_INDEPENDENT}>)
if(NOT WIN32)
include(CheckSymbolExists)
check_symbol_exists(realpath "stdlib.h" HAVE_REALPATH)
if(NOT HAVE_REALPATH)
add_definitions(-DFLATBUFFERS_NO_ABSOLUTE_PATH_RESOLUTION)
endif()
endif()
set(FlatBuffers_Library_SRCS
include/flatbuffers/allocator.h
include/flatbuffers/array.h
include/flatbuffers/base.h
include/flatbuffers/buffer.h
include/flatbuffers/buffer_ref.h
include/flatbuffers/default_allocator.h
include/flatbuffers/detached_buffer.h
include/flatbuffers/code_generator.h
include/flatbuffers/file_manager.h
include/flatbuffers/flatbuffer_builder.h
include/flatbuffers/flatbuffers.h
include/flatbuffers/flexbuffers.h
include/flatbuffers/flex_flat_util.h
include/flatbuffers/hash.h
include/flatbuffers/idl.h
include/flatbuffers/minireflect.h
include/flatbuffers/reflection.h
include/flatbuffers/reflection_generated.h
include/flatbuffers/registry.h
include/flatbuffers/stl_emulation.h
include/flatbuffers/string.h
include/flatbuffers/struct.h
include/flatbuffers/table.h
include/flatbuffers/util.h
include/flatbuffers/vector.h
include/flatbuffers/vector_downward.h
include/flatbuffers/verifier.h
src/file_manager.cpp
src/file_name_manager.cpp
src/idl_parser.cpp
src/idl_gen_cpp.cpp
src/idl_gen_general.cpp
src/idl_gen_go.cpp
src/idl_gen_text.cpp
src/reflection.cpp
src/util.cpp
)
set(FlatBuffers_Compiler_SRCS
${FlatBuffers_Library_SRCS}
src/idl_gen_binary.cpp
src/idl_gen_text.cpp
src/idl_gen_cpp.cpp
src/idl_gen_csharp.cpp
src/idl_gen_dart.cpp
src/idl_gen_kotlin.cpp
src/idl_gen_kotlin_kmp.cpp
src/idl_gen_go.cpp
src/idl_gen_java.cpp
src/idl_gen_ts.cpp
src/idl_gen_php.cpp
src/idl_gen_python.cpp
src/idl_gen_lobster.cpp
src/idl_gen_rust.cpp
src/idl_gen_fbs.cpp
src/idl_gen_grpc.cpp
src/idl_gen_json_schema.cpp
src/idl_gen_swift.cpp
src/idl_namer.h
src/namer.h
src/flatc.cpp
src/flatc_main.cpp
src/bfbs_gen.h
src/bfbs_gen_lua.h
src/bfbs_gen_nim.h
src/bfbs_namer.h
include/codegen/idl_namer.h
include/codegen/namer.h
include/codegen/python.h
include/codegen/python.cc
include/flatbuffers/code_generators.h
src/binary_annotator.h
src/binary_annotator.cpp
src/annotated_binary_text_gen.h
src/annotated_binary_text_gen.cpp
src/bfbs_gen_lua.cpp
src/bfbs_gen_nim.cpp
src/code_generators.cpp
grpc/src/compiler/schema_interface.h
grpc/src/compiler/cpp_generator.h
grpc/src/compiler/cpp_generator.cc
grpc/src/compiler/go_generator.h
grpc/src/compiler/go_generator.cc
grpc/src/compiler/java_generator.h
grpc/src/compiler/java_generator.cc
grpc/src/compiler/python_generator.h
grpc/src/compiler/python_generator.cc
grpc/src/compiler/swift_generator.h
grpc/src/compiler/swift_generator.cc
grpc/src/compiler/ts_generator.h
grpc/src/compiler/ts_generator.cc
)
set(FlatHash_SRCS
@@ -35,101 +216,518 @@ set(FlatHash_SRCS
)
set(FlatBuffers_Tests_SRCS
include/flatbuffers/flatbuffers.h
include/flatbuffers/hash.h
include/flatbuffers/idl.h
include/flatbuffers/util.h
src/idl_parser.cpp
src/idl_gen_text.cpp
${FlatBuffers_Library_SRCS}
src/idl_gen_fbs.cpp
tests/default_vectors_strings_test.cpp
tests/default_vectors_strings_test.h
tests/evolution_test.cpp
tests/flexbuffers_test.cpp
tests/fuzz_test.cpp
tests/json_test.cpp
tests/key_field_test.cpp
tests/monster_test.cpp
tests/optional_scalars_test.cpp
tests/parser_test.cpp
tests/proto_test.cpp
tests/reflection_test.cpp
tests/test.cpp
# file generate by running compiler on tests/monster_test.fbs
${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_generated.h
tests/test_assert.h
tests/test_assert.cpp
tests/test_builder.h
tests/test_builder.cpp
tests/util_test.cpp
tests/vector_table_naked_ptr_test.h
tests/vector_table_naked_ptr_test.cpp
tests/native_type_test_impl.h
tests/native_type_test_impl.cpp
tests/alignment_test.h
tests/alignment_test.cpp
tests/64bit/offset64_test.h
tests/64bit/offset64_test.cpp
include/flatbuffers/code_generators.h
src/code_generators.cpp
)
set(FlatBuffers_Tests_CPP17_SRCS
${FlatBuffers_Library_SRCS}
tests/test_assert.h
tests/test_assert.cpp
tests/cpp17/test_cpp17.cpp
)
set(FlatBuffers_Sample_Binary_SRCS
include/flatbuffers/flatbuffers.h
samples/sample_binary.cpp
# file generated by running compiler on samples/monster.fbs
${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h
)
set(FlatBuffers_Sample_Text_SRCS
include/flatbuffers/flatbuffers.h
include/flatbuffers/hash.h
include/flatbuffers/idl.h
include/flatbuffers/util.h
src/idl_parser.cpp
src/idl_gen_text.cpp
${FlatBuffers_Library_SRCS}
samples/sample_text.cpp
# file generated by running compiler on samples/monster.fbs
${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h
)
# source_group(Compiler FILES ${FlatBuffers_Compiler_SRCS})
# source_group(Tests FILES ${FlatBuffers_Tests_SRCS})
set(FlatBuffers_Sample_BFBS_SRCS
${FlatBuffers_Library_SRCS}
samples/sample_bfbs.cpp
)
if(APPLE)
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++ -Wall -pedantic -Werror -Wextra")
elseif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -std=c++0x -Wall -pedantic -Werror -Wextra")
set(FlatBuffers_GRPCTest_SRCS
include/flatbuffers/flatbuffers.h
include/flatbuffers/grpc.h
include/flatbuffers/util.h
src/util.cpp
tests/monster_test.grpc.fb.h
tests/test_assert.h
tests/test_builder.h
tests/monster_test.grpc.fb.cc
tests/test_assert.cpp
tests/test_builder.cpp
grpc/tests/grpctest.cpp
grpc/tests/message_builder_test.cpp
grpc/tests/grpctest_callback_compile.cpp
grpc/tests/grpctest_callback_client_compile.cpp
)
# TODO(dbaileychess): Figure out how this would now work. I posted a question on
# https://stackoverflow.com/questions/71772330/override-target-compile-options-via-cmake-command-line.
# Append FLATBUFFERS_CXX_FLAGS to CMAKE_CXX_FLAGS.
if(DEFINED FLATBUFFERS_CXX_FLAGS)
message(STATUS "extend CXX_FLAGS with ${FLATBUFFERS_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLATBUFFERS_CXX_FLAGS}")
endif()
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
if(FLATBUFFERS_CODE_COVERAGE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fprofile-arcs -ftest-coverage")
set(CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
endif()
function(add_fsanitize_to_target _target _sanitizer)
if(WIN32)
target_compile_definitions(${_target} PRIVATE FLATBUFFERS_MEMORY_LEAK_TRACKING)
message(STATUS "Sanitizer MSVC::_CrtDumpMemoryLeaks added to ${_target}")
else()
# FLATBUFFERS_CODE_SANITIZE: boolean {ON,OFF,YES,NO} or string with list of sanitizer.
# List of sanitizer is string starts with '=': "=address,undefined,thread,memory".
if(IS_CLANG OR (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 4.9))
set(_sanitizer_flags "=address,undefined")
if(_sanitizer MATCHES "=.*")
# override default by user-defined sanitizer list
set(_sanitizer_flags ${_sanitizer})
endif()
target_compile_options(${_target} PRIVATE
-g -fsigned-char -fno-omit-frame-pointer
"-fsanitize${_sanitizer_flags}")
target_link_libraries(${_target} PRIVATE
"-fsanitize${_sanitizer_flags}")
set_target_properties(${_target} PROPERTIES POSITION_INDEPENDENT_CODE ON)
message(STATUS "Sanitizer ${_sanitizer_flags} added to ${_target}")
endif()
endif()
endfunction()
if(BIICODE)
# Execute biicode building
include(CMake/biicode.cmake)
return()
endif(BIICODE)
function(add_pch_to_target _target _pch_header)
# the command is available since cmake 3.16
if(COMMAND target_precompile_headers)
target_precompile_headers(${_target} PRIVATE ${_pch_header})
if(NOT MSVC)
set_source_files_properties(src/util.cpp PROPERTIES SKIP_PRECOMPILE_HEADERS ON)
endif()
endif()
endfunction()
include_directories(include)
include_directories(grpc)
# Creates an interface library that stores the configuration settings that each
# target links too. This is a compromise between setting configuration globally
# with add_compile_options() and the more targetted target_compile_options().
# This way each target in this file can share settings and override them if
# needed.
add_library(ProjectConfig INTERFACE)
target_compile_features(ProjectConfig
INTERFACE
cxx_std_${FLATBUFFERS_CPP_STD}
)
# Force the standard to be met.
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# We shouldn't rely on any compiler-extensions to make things work.
set(CMAKE_CXX_EXTENSIONS OFF)
if(MSVC_LIKE)
target_compile_options(ProjectConfig
INTERFACE
/W4
$<$<BOOL:${FLATBUFFERS_STRICT_MODE}>:
/WX # Treat all compiler warnings as errors
>
/wd4512 # C4512: assignment operator could not be generated
/wd4316 # C4316: object allocated on the heap may not be aligned
/wd4456 # C4456: hides previous local declaration
$<$<CXX_COMPILER_ID:Clang>:
/D_CRT_SECURE_NO_WARNINGS
>
)
else()
target_compile_options(ProjectConfig
INTERFACE
-Wall
$<$<BOOL:${FLATBUFFERS_STRICT_MODE}>:
-Werror # Treat all compiler warnings as errors
-fno-rtti # Disable runtime type information
$<$<CXX_COMPILER_ID:GNU>:
# False positive string overflow
# https://github.com/google/flatbuffers/issues/7366
-Wno-error=stringop-overflow
>
>
-pedantic
-Wextra
-Wno-unused-parameter
-Wold-style-cast
-fsigned-char
-Wnon-virtual-dtor
# This isn't working for some reason: $<$<CXX_COMPILER_ID:CLANG>:
$<$<BOOL:${IS_CLANG}>:
-Wnewline-eof
-Wno-unknown-warning-option
-Wmissing-declarations
-Wzero-as-null-pointer-constant
$<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,3.8>:
-Wimplicit-fallthrough
-Wextra-semi
$<$<BOOL:${FLATBUFFERS_STRICT_MODE}>:
-Werror=unused-private-field
>
>
>
$<$<CXX_COMPILER_ID:GNU>:
$<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,4.4>:
-Wunused-result
-Wunused-parameter
-Werror=unused-parameter
-Wmissing-declarations
>
$<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,4.7>:
-Wzero-as-null-pointer-constant
>
$<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,7.0>:
-faligned-new
$<$<BOOL:${FLATBUFFERS_STRICT_MODE}>:
-Werror=implicit-fallthrough=2
>
>
$<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,8.0>:
-Wextra-semi
>
>
$<$<BOOL:${FLATBUFFERS_CODE_COVERAGE}>:
-g
-fprofile-arcs
-ftest-coverage
>
)
if(FLATBUFFERS_CODE_COVERAGE)
target_link_options(ProjectConfig
INTERFACE
-fprofile-arcs
-ftest-coverage
)
endif()
endif()
if(FLATBUFFERS_BUILD_FLATLIB)
add_library(flatbuffers STATIC ${FlatBuffers_Library_SRCS})
# Attach header directory for when build via add_subdirectory().
target_include_directories(flatbuffers
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
target_link_libraries(flatbuffers PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
if(FLATBUFFERS_ENABLE_PCH)
add_pch_to_target(flatbuffers include/flatbuffers/pch/pch.h)
endif()
endif()
if(FLATBUFFERS_BUILD_FLATC)
add_executable(flatc ${FlatBuffers_Compiler_SRCS})
if(FLATBUFFERS_ENABLE_PCH)
add_pch_to_target(flatc include/flatbuffers/pch/flatc_pch.h)
endif()
target_link_libraries(flatc PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
target_compile_options(flatc
PRIVATE
$<$<AND:$<BOOL:${MSVC_LIKE}>,$<CONFIG:Release>>:
/MT
>
)
if(FLATBUFFERS_CODE_SANITIZE AND NOT WIN32)
add_fsanitize_to_target(flatc ${FLATBUFFERS_CODE_SANITIZE})
endif()
if(NOT FLATBUFFERS_FLATC_EXECUTABLE)
set(FLATBUFFERS_FLATC_EXECUTABLE $<TARGET_FILE:flatc>)
endif()
if(FLATBUFFERS_STATIC_FLATC AND NOT MSVC)
target_link_libraries(flatc PRIVATE -static)
endif()
endif()
if(FLATBUFFERS_BUILD_FLATC)
if(FLATBUFFERS_BUILD_FLATHASH)
add_executable(flathash ${FlatHash_SRCS})
target_link_libraries(flathash PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
endif()
function(compile_flatbuffers_schema_to_cpp SRC_FBS)
if(FLATBUFFERS_BUILD_SHAREDLIB)
add_library(flatbuffers_shared SHARED ${FlatBuffers_Library_SRCS})
target_link_libraries(flatbuffers_shared PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
# FlatBuffers use calendar-based versioning and do not provide any ABI
# stability guarantees. Therefore, always use the full version as SOVERSION
# in order to avoid breaking reverse dependencies on upgrades.
set(FlatBuffers_Library_SONAME_FULL "${PROJECT_VERSION}")
set_target_properties(flatbuffers_shared PROPERTIES
OUTPUT_NAME flatbuffers
SOVERSION "${FlatBuffers_Library_SONAME_FULL}"
VERSION "${FlatBuffers_Library_SONAME_FULL}")
if(FLATBUFFERS_ENABLE_PCH)
add_pch_to_target(flatbuffers_shared include/flatbuffers/pch/pch.h)
endif()
endif()
function(compile_schema SRC_FBS OPT SUFFIX OUT_GEN_FILE)
get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH)
string(REGEX REPLACE "\\.fbs$" "_generated.h" GEN_HEADER ${SRC_FBS})
string(REGEX REPLACE "\\.fbs$" "${SUFFIX}.h" GEN_HEADER ${SRC_FBS})
add_custom_command(
OUTPUT ${GEN_HEADER}
COMMAND flatc -c -o "${SRC_FBS_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
DEPENDS flatc)
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}"
${OPT}
--filename-suffix ${SUFFIX}
-o "${SRC_FBS_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
DEPENDS flatc ${SRC_FBS}
COMMENT "flatc generation: `${SRC_FBS}` -> `${GEN_HEADER}`"
)
set(${OUT_GEN_FILE} ${GEN_HEADER} PARENT_SCOPE)
endfunction()
function(compile_schema_for_test SRC_FBS OPT)
compile_schema("${SRC_FBS}" "${OPT}" "_generated" GEN_FILE)
target_sources(flattests PRIVATE ${GEN_FILE})
endfunction()
function(compile_schema_for_test_fbsh SRC_FBS OPT)
compile_schema("${SRC_FBS}" "${OPT}" ".fbs" GEN_FILE)
target_sources(flattests PRIVATE ${GEN_FILE})
endfunction()
function(compile_schema_for_samples SRC_FBS OPT)
compile_schema("${SRC_FBS}" "${OPT}" "_generated" GEN_FILE)
target_sources(flatsample PRIVATE ${GEN_FILE})
endfunction()
if(FLATBUFFERS_BUILD_TESTS)
compile_flatbuffers_schema_to_cpp(tests/monster_test.fbs)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/tests)
add_executable(flattests ${FlatBuffers_Tests_SRCS})
target_link_libraries(flattests PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
target_include_directories(flattests PUBLIC
# Ideally everything is fully qualified from the root directories
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
# TODO(derekbailey): update includes to fully qualify src/ and tests/
src
tests
${CMAKE_CURRENT_BINARY_DIR}/tests
)
compile_flatbuffers_schema_to_cpp(samples/monster.fbs)
# Have tests load data from the source directory, not the build directory.
add_definitions(-DFLATBUFFERS_TEST_PATH_PREFIX=${CMAKE_CURRENT_SOURCE_DIR}/)
# The flattest target needs some generated files
SET(FLATC_OPT_COMP --cpp --gen-compare --gen-mutable --gen-object-api --reflect-names)
SET(FLATC_OPT_SCOPED_ENUMS ${FLATC_OPT_COMP};--scoped-enums)
compile_schema_for_test(tests/alignment_test.fbs "${FLATC_OPT_COMP}")
compile_schema_for_test_fbsh(tests/default_vectors_strings_test.fbs "${FLATC_OPT_COMP}")
compile_schema_for_test(tests/arrays_test.fbs "${FLATC_OPT_SCOPED_ENUMS}")
compile_schema_for_test(tests/native_inline_table_test.fbs "${FLATC_OPT_COMP}")
compile_schema_for_test(tests/native_type_test.fbs "${FLATC_OPT_COMP}")
compile_schema_for_test(tests/key_field/key_field_sample.fbs "${FLATC_OPT_COMP}")
compile_schema_for_test(tests/64bit/test_64bit.fbs "${FLATC_OPT_COMP};--bfbs-gen-embed")
compile_schema_for_test(tests/64bit/evolution/v1.fbs "${FLATC_OPT_COMP}")
compile_schema_for_test(tests/64bit/evolution/v2.fbs "${FLATC_OPT_COMP}")
compile_schema_for_test(tests/union_underlying_type_test.fbs "${FLATC_OPT_SCOPED_ENUMS}")
compile_schema_for_test(tests/cross_namespace_pack_test.fbs "${FLATC_OPT_COMP}")
if(FLATBUFFERS_CODE_SANITIZE)
add_fsanitize_to_target(flattests ${FLATBUFFERS_CODE_SANITIZE})
endif()
include_directories(${CMAKE_CURRENT_BINARY_DIR}/samples)
add_executable(flatsamplebinary ${FlatBuffers_Sample_Binary_SRCS})
add_executable(flatsampletext ${FlatBuffers_Sample_Text_SRCS})
add_executable(flatsamplebfbs ${FlatBuffers_Sample_BFBS_SRCS})
# Add a library so there is a single target that the generated samples can
# link too.
if(MSVC OR ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.20.0")
add_library(flatsample INTERFACE)
else()
add_library(flatsample STATIC)
endif()
# Since flatsample has no sources, we have to explicitly set the linker lang.
set_target_properties(flatsample PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(flatsamplebinary PRIVATE $<BUILD_INTERFACE:ProjectConfig> flatsample)
target_link_libraries(flatsampletext PRIVATE $<BUILD_INTERFACE:ProjectConfig> flatsample)
target_link_libraries(flatsamplebfbs PRIVATE $<BUILD_INTERFACE:ProjectConfig> flatsample)
if(FLATBUFFERS_BUILD_CPP17)
add_executable(flattests_cpp17 ${FlatBuffers_Tests_CPP17_SRCS})
target_link_libraries(flattests_cpp17 PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
target_include_directories(flattests_cpp17 PUBLIC src tests)
target_compile_features(flattests_cpp17 PRIVATE cxx_std_17) # requires cmake 3.8
if(FLATBUFFERS_CODE_SANITIZE)
add_fsanitize_to_target(flattests_cpp17 ${FLATBUFFERS_CODE_SANITIZE})
endif()
endif(FLATBUFFERS_BUILD_CPP17)
endif()
if(FLATBUFFERS_BUILD_GRPCTEST)
if(NOT GRPC_INSTALL_PATH)
message(SEND_ERROR "GRPC_INSTALL_PATH variable is not defined. See grpc/README.md")
endif()
if(NOT PROTOBUF_DOWNLOAD_PATH)
message(SEND_ERROR "PROTOBUF_DOWNLOAD_PATH variable is not defined. See grpc/README.md")
endif()
INCLUDE_DIRECTORIES(${GRPC_INSTALL_PATH}/include)
INCLUDE_DIRECTORIES(${PROTOBUF_DOWNLOAD_PATH}/src)
find_package(Threads REQUIRED)
list(APPEND CMAKE_PREFIX_PATH ${GRPC_INSTALL_PATH})
find_package(absl CONFIG REQUIRED)
find_package(protobuf CONFIG REQUIRED)
find_package(gRPC CONFIG REQUIRED)
add_executable(grpctest ${FlatBuffers_GRPCTest_SRCS})
target_link_libraries(grpctest
PRIVATE
$<BUILD_INTERFACE:ProjectConfig>
gRPC::grpc++_unsecure
gRPC::gpr
pthread
dl
)
endif()
if(FLATBUFFERS_INSTALL)
install(DIRECTORY include/flatbuffers DESTINATION include)
include(GNUInstallDirs)
install(DIRECTORY include/flatbuffers DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
set(FB_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/flatbuffers")
configure_file(CMake/flatbuffers-config-version.cmake.in flatbuffers-config-version.cmake @ONLY)
install(
FILES
"CMake/flatbuffers-config.cmake"
"CMake/BuildFlatBuffers.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/flatbuffers-config-version.cmake"
DESTINATION ${FB_CMAKE_DIR}
)
if(FLATBUFFERS_BUILD_FLATLIB)
install(
TARGETS flatbuffers EXPORT FlatBuffersTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(EXPORT FlatBuffersTargets
FILE FlatBuffersTargets.cmake
NAMESPACE flatbuffers::
DESTINATION ${FB_CMAKE_DIR}
)
endif()
if(FLATBUFFERS_BUILD_FLATC)
install(TARGETS flatc DESTINATION bin)
install(
TARGETS flatc EXPORT FlatcTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(
EXPORT FlatcTargets
FILE FlatcTargets.cmake
NAMESPACE flatbuffers::
DESTINATION ${FB_CMAKE_DIR}
)
endif()
if(FLATBUFFERS_BUILD_SHAREDLIB)
install(
TARGETS flatbuffers_shared EXPORT FlatBuffersSharedTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(
EXPORT FlatBuffersSharedTargets
FILE FlatBuffersSharedTargets.cmake
NAMESPACE flatbuffers::
DESTINATION ${FB_CMAKE_DIR}
)
endif()
if(FLATBUFFERS_BUILD_SHAREDLIB OR FLATBUFFERS_BUILD_FLATLIB)
configure_file(CMake/flatbuffers.pc.in flatbuffers.pc @ONLY)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/flatbuffers.pc"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
endif()
endif()
if(FLATBUFFERS_BUILD_TESTS)
enable_testing()
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tests" DESTINATION
"${CMAKE_CURRENT_BINARY_DIR}")
add_test(NAME flattests COMMAND flattests)
if(FLATBUFFERS_BUILD_CPP17)
add_test(NAME flattests_cpp17 COMMAND flattests_cpp17)
endif()
if(FLATBUFFERS_BUILD_GRPCTEST)
add_test(NAME grpctest COMMAND grpctest)
endif()
endif()
include(CMake/BuildFlatBuffers.cmake)
if(UNIX)
# Use of CPack only supported on Linux systems.
if(FLATBUFFERS_PACKAGE_DEBIAN)
include(CMake/PackageDebian.cmake)
include(CPack)
endif()
if (FLATBUFFERS_PACKAGE_REDHAT)
include(CMake/PackageRedhat.cmake)
include(CPack)
endif()
endif()
# Include for running Google Benchmarks.
if(FLATBUFFERS_BUILD_BENCHMARKS)
add_subdirectory(benchmarks)
endif()
# Add FlatBuffers::FlatBuffers interface, needed for FetchContent_Declare
add_library(FlatBuffers INTERFACE)
add_library(FlatBuffers::FlatBuffers ALIAS FlatBuffers)
target_include_directories(
FlatBuffers
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/include>)

View File

@@ -25,12 +25,12 @@ use Github pull requests for this purpose.
Some tips for good pull requests:
* Use our code
[style guide](http://google-styleguide.googlecode.com/svn/trunk/cppguide.html).
[style guide](https://google.github.io/styleguide/cppguide.html).
When in doubt, try to stay true to the existing code of the project.
* Write a descriptive commit message. What problem are you solving and what
are the consequences? Where and what did you test? Some good tips:
[here](http://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message)
and [here](https://www.kernel.org/doc/Documentation/SubmittingPatches).
and [here](https://www.kernel.org/doc/Documentation/process/submitting-patches.rst).
* If your PR consists of multiple commits which are successive improvements /
fixes to your first commit, consider squashing them into a single commit
(`git rebase -i`) such that your PR is a single commit on top of the current
@@ -40,3 +40,26 @@ Some tips for good pull requests:
# The small print
Contributions made by corporations are covered by a different agreement than
the one above, the Software Grant and Corporate Contributor License Agreement.
# Code
TL/DR
See [how to build flatc](https://flatbuffers.dev/building/).
When making changes, build `flatc` and then re-generate the goldens files to see the effect of your changes:
```
$ cp build/flatc .
$ goldens/generate_goldens.py
```
Re-generate other code files to see the effects of the changes:
```
$ scripts/generate_code.py
```
Run tests with [TestAll.sh](tests/TestAll.sh) in [tests](tests), or directly any of the sub-scripts run by it.
[Format the code](Formatters.md) before submitting a PR.

24
FlatBuffers.podspec Normal file
View File

@@ -0,0 +1,24 @@
Pod::Spec.new do |s|
s.name = 'FlatBuffers'
s.version = '25.12.19'
s.summary = 'FlatBuffers: Memory Efficient Serialization Library'
s.description = "FlatBuffers is a cross platform serialization library architected for
maximum memory efficiency. It allows you to directly access serialized
data without parsing/unpacking it first, while still having great
forwards/backwards compatibility."
s.homepage = 'https://github.com/google/flatbuffers'
s.license = { :type => 'Apache2.0', :file => 'LICENSE' }
s.author = { 'mustii' => 'me@mustiikhalil.se' }
s.source = { :git => 'https://github.com/google/flatbuffers.git', :tag => "v" + s.version.to_s, :submodules => true }
s.ios.deployment_target = '11.0'
s.osx.deployment_target = '10.14'
s.swift_version = '5.10'
s.source_files = 'swift/Sources/Flatbuffers/*.swift'
s.pod_target_xcconfig = {
'BUILD_LIBRARY_FOR_DISTRIBUTION' => 'YES'
}
end

22
Formatters.md Normal file
View File

@@ -0,0 +1,22 @@
# Format Guidelines
If you are interesting in contributing to the flatbuffers project, please take a second to read this document. Each language has it's own set of rules, that are defined in their respective formatter/linter documents.
# Notes
- Run the linter on the language you are working on before making a Pull Request.
- DONT format/lint the generated code.
# Languages
## C++
C++ uses `clang-format` as it's formatter. Run the following script `sh scripts/clang-format-git.sh`, and it should style the C++ code according to [google style guide](https://google.github.io/styleguide/cppguide.html).
## Swift
Swift uses swiftformat as it's formatter. Take a look at [how to install here](https://github.com/nicklockwood/SwiftFormat/blob/master/README.md#how-do-i-install-it). Run the following command `swiftformat --config swift.swiftformat .` in the root directory of the project
## Typescript
Typescript uses eslint as it's linter. Take a look at [how to install here](https://eslint.org/docs/user-guide/getting-started). Run the following command `eslint ts/** --ext .ts` in the root directory of the project

202
LICENSE Normal file
View File

@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

75
MODULE.bazel Normal file
View File

@@ -0,0 +1,75 @@
module(
name = "flatbuffers",
version = "25.12.19",
compatibility_level = 1,
repo_name = "com_github_google_flatbuffers",
)
bazel_dep(
name = "aspect_bazel_lib",
version = "2.14.0",
)
bazel_dep(
name = "aspect_rules_esbuild",
version = "0.21.0",
)
bazel_dep(
name = "aspect_rules_js",
version = "2.3.8",
)
bazel_dep(
name = "aspect_rules_ts",
version = "3.6.0",
)
bazel_dep(
name = "grpc",
version = "1.76.0",
repo_name = "com_github_grpc_grpc",
)
bazel_dep(
name = "platforms",
version = "0.0.11",
)
bazel_dep(
name = "rules_cc",
version = "0.1.1",
)
bazel_dep(
name = "rules_go",
version = "0.50.1",
repo_name = "io_bazel_rules_go",
)
bazel_dep(
name = "rules_nodejs",
version = "6.3.3",
)
bazel_dep(
name = "rules_shell",
version = "0.3.0",
)
bazel_dep(
name = "rules_swift",
version = "3.1.2",
max_compatibility_level = 3,
repo_name = "build_bazel_rules_swift",
)
bazel_dep(
name = "bazel_skylib",
version = "1.7.1",
)
npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")
npm.npm_translate_lock(
name = "flatbuffers_npm",
npmrc = "//:.npmrc",
pnpm_lock = "//ts:pnpm-lock.yaml",
verify_node_modules_ignored = "//:.bazelignore",
)
use_repo(npm, "flatbuffers_npm")
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
use_repo(node, "nodejs_linux_amd64")
rules_ts_ext = use_extension("@aspect_rules_ts//ts:extensions.bzl", "ext", dev_dependency = True)
rules_ts_ext.deps()
use_repo(rules_ts_ext, "npm_typescript")

98
Package.swift Normal file
View File

@@ -0,0 +1,98 @@
// swift-tools-version:6.0
/*
* Copyright 2020 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import PackageDescription
let package = Package(
name: "FlatBuffers",
platforms: [
.iOS(.v12),
.macOS(.v10_14),
],
products: [
.library(
name: "FlatBuffers",
targets: ["FlatBuffers"]),
.library(
name: "FlexBuffers",
targets: ["FlexBuffers"]),
],
dependencies: .dependencies,
targets: [
.target(
name: "FlatBuffers",
dependencies: ["Common"],
path: "swift/Sources/FlatBuffers",
swiftSettings: .settings),
.target(
name: "FlexBuffers",
dependencies: ["Common"],
path: "swift/Sources/FlexBuffers",
swiftSettings: .settings),
.target(
name: "Common",
path: "swift/Sources/Common",
swiftSettings: .settings),
.testTarget(
name: "FlatbuffersTests",
dependencies: .dependencies,
path: "tests/swift/Tests/Flatbuffers"),
.testTarget(
name: "FlexbuffersTests",
dependencies: ["FlexBuffers"],
path: "tests/swift/Tests/Flexbuffers"),
],
swiftLanguageModes: [.v6])
extension Array where Element == SwiftSetting {
static var settings: [SwiftSetting] {
[.enableUpcomingFeature("ExistentialAny")]
}
}
extension Array where Element == Package.Dependency {
static var dependencies: [Package.Dependency] {
#if os(Windows)
[]
#else
// Test only Dependency
[
.package(url: "https://github.com/grpc/grpc-swift-2.git", from: "2.0.0"),
.package(
url: "https://github.com/grpc/grpc-swift-nio-transport.git",
from: "2.0.0"),
]
#endif
}
}
extension Array where Element == PackageDescription.Target.Dependency {
static var dependencies: [PackageDescription.Target.Dependency] {
#if os(Windows)
["FlatBuffers"]
#else
// Test only Dependency
[
.product(name: "GRPCCore", package: "grpc-swift-2"),
.product(
name: "GRPCNIOTransportHTTP2",
package: "grpc-swift-nio-transport"),
"FlatBuffers",
]
#endif
}
}

116
README.md Normal file
View File

@@ -0,0 +1,116 @@
![logo](https://flatbuffers.dev/assets/flatbuffers_logo.svg) FlatBuffers
===========
![Build status](https://github.com/google/flatbuffers/actions/workflows/build.yml/badge.svg?branch=master)
[![BuildKite status](https://badge.buildkite.com/7979d93bc6279aa539971f271253c65d5e8fe2fe43c90bbb25.svg)](https://buildkite.com/bazel/flatbuffers)
[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/flatbuffers.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:flatbuffers)
[![Discord Chat](https://img.shields.io/discord/656202785926152206.svg)](https:///discord.gg/6qgKs3R)
[![Twitter Follow](https://img.shields.io/twitter/follow/wvo.svg?style=social)](https://twitter.com/wvo)
[![Twitter Follow](https://img.shields.io/twitter/follow/dbaileychess.svg?style=social)](https://twitter.com/dbaileychess)
**FlatBuffers** is a cross platform serialization library architected for
maximum memory efficiency. It allows you to directly access serialized data without parsing/unpacking it first, while still having great forwards/backwards compatibility.
## Quick Start
1. Build the compiler for flatbuffers (`flatc`)
Use `cmake` to create the build files for your platform and then perform the compilation (Linux example).
```
cmake -G "Unix Makefiles"
make -j
```
2. Define your flatbuffer schema (`.fbs`)
Write the [schema](https://flatbuffers.dev/flatbuffers_guide_writing_schema.html) to define the data you want to serialize. See [monster.fbs](https://github.com/google/flatbuffers/blob/master/samples/monster.fbs) for an example.
3. Generate code for your language(s)
Use the `flatc` compiler to take your schema and generate language-specific code:
```
./flatc --cpp --rust monster.fbs
```
Which generates `monster_generated.h` and `monster_generated.rs` files.
4. Serialize data
Use the generated code, as well as the `FlatBufferBuilder` to construct your serialized buffer. ([`C++` example](https://github.com/google/flatbuffers/blob/master/samples/sample_binary.cpp#L24-L56))
5. Transmit/store/save Buffer
Use your serialized buffer however you want. Send it to someone, save it for later, etc...
6. Read the data
Use the generated accessors to read the data from the serialized buffer.
It doesn't need to be the same language/schema version, FlatBuffers ensures the data is readable across languages and schema versions. See the [`Rust` example](https://github.com/google/flatbuffers/blob/master/samples/sample_binary.rs#L92-L106) reading the data written by `C++`.
## Documentation
**Go to our [landing page][] to browse our documentation.**
## Supported operating systems
- Windows
- macOS
- Linux
- Android
- And any others with a recent C++ compiler (C++ 11 and newer)
## Supported programming languages
Code generation and runtime libraries for many popular languages.
1. C
1. C++ - [snapcraft.io](https://snapcraft.io/flatbuffers)
1. C# - [nuget.org](https://www.nuget.org/packages/Google.FlatBuffers)
1. Dart - [pub.dev](https://pub.dev/packages/flat_buffers)
1. Go - [go.dev](https://pkg.go.dev/github.com/google/flatbuffers)
1. Java - [Maven](https://search.maven.org/artifact/com.google.flatbuffers/flatbuffers-java)
1. JavaScript - [NPM](https://www.npmjs.com/package/flatbuffers)
1. Kotlin
1. Lobster
1. Lua
1. PHP
1. Python - [PyPI](https://pypi.org/project/flatbuffers/)
1. Rust - [crates.io](https://crates.io/crates/flatbuffers)
1. Swift - [swiftpackageindex](https://swiftpackageindex.com/google/flatbuffers)
1. TypeScript - [NPM](https://www.npmjs.com/package/flatbuffers)
1. Nim
## Versioning
FlatBuffers does not follow traditional SemVer versioning (see [rationale](https://github.com/google/flatbuffers/wiki/Versioning)) but rather uses a format of the date of the release.
## Contribution
* [FlatBuffers Issues Tracker][] to submit an issue.
* [stackoverflow.com][] with [`flatbuffers` tag][] for any questions regarding FlatBuffers.
*To contribute to this project,* see [CONTRIBUTING][].
## Community
* [Discord Server](https:///discord.gg/6qgKs3R)
## Security
Please see our [Security Policy](SECURITY.md) for reporting vulnerabilities.
## Licensing
*Flatbuffers* is licensed under the Apache License, Version 2.0. See [LICENSE][] for the full license text.
<br>
[CONTRIBUTING]: http://github.com/google/flatbuffers/blob/master/CONTRIBUTING.md
[`flatbuffers` tag]: https://stackoverflow.com/questions/tagged/flatbuffers
[FlatBuffers Google Group]: https://groups.google.com/forum/#!forum/flatbuffers
[FlatBuffers Issues Tracker]: http://github.com/google/flatbuffers/issues
[stackoverflow.com]: http://stackoverflow.com/search?q=flatbuffers
[landing page]: https://google.github.io/flatbuffers
[LICENSE]: https://github.com/google/flatbuffers/blob/master/LICENSE

11
SECURITY.md Normal file
View File

@@ -0,0 +1,11 @@
# Security Policy
## Reporting a Vulnerability
To report a security issue, please use http://g.co/vulnz. We use
http://g.co/vulnz for our intake, and do coordination and disclosure here on
GitHub (including using GitHub Security Advisory). The Google Security Team will
respond within 5 working days of your report on g.co/vulnz.
Select the `I want to report a technical security or an abuse risk related bug
in a Google product (SQLi, XSS, etc.)` option and complete the form.

36
android/.project Executable file → Normal file
View File

@@ -1,20 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (c) 2014 Google, Inc.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
-->
<projectDescription>
<name>FlatBufferTest</name>
<name>FlatBufferTest</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
<filteredResources>
<filter>
<id>1672434305228</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>

29
android/AndroidManifest.xml Executable file → Normal file
View File

@@ -1,33 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2013 Google, Inc.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
-->
<!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.FlatBufferTest"
android:versionCode="1"
android:versionName="1.0">
package="com.example.FlatBufferTest">
<uses-sdk android:minSdkVersion="14"/>
<uses-feature android:glEsVersion="0x00020000"></uses-feature>
<!-- This is the platform API where NativeActivity was introduced. -->
<uses-sdk android:minSdkVersion="9" />
<!-- This .apk has no Java code itself, so set hasCode to false. -->
<application android:label="@string/app_name" android:hasCode="false">
<application android:name="android.support.multidex.MultiDexApplication"
android:label="@string/app_name"
android:hasCode="false"
android:allowBackup="false">
<!-- Our activity is the built-in NativeActivity framework class.
This will take care of integrating with our NDK code. -->
<activity android:name="android.app.NativeActivity"

1
android/app/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

125
android/app/build.gradle Normal file
View File

@@ -0,0 +1,125 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdk 33
defaultConfig {
applicationId "com.flatbuffers.app"
minSdkVersion 26
targetSdkVersion 33
versionCode 1
versionName "1.0"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
sourceSets {
main {
java {
srcDir '../../java/src/main/java/'
}
}
}
ndk {
abiFilters 'arm64-v8a', 'armeabi-v7a'
}
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
arguments "-DFLATBUFFERS_SRC=${rootProject.projectDir}/.."
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
}
}
task generateFbsCpp(type: Exec) {
def inputDir = file("$projectDir/src/main/fbs")
def outputCppDir = file("$projectDir/src/main/cpp/generated/")
def fbsFiles = layout.files { file(inputDir).listFiles() }.filter { File f -> f.name.endsWith(".fbs") }.toList()
ignoreExitValue(true)
standardOutput = new ByteArrayOutputStream()
errorOutput = new ByteArrayOutputStream()
def commandLineArgs = ['flatc', '-o', outputCppDir, '--cpp']
fbsFiles.forEach{
commandLineArgs.add(it.path)
}
commandLine commandLineArgs
doFirst {
delete "$outputCppDir/"
mkdir "$outputCppDir/"
}
doLast {
if (executionResult.get().exitValue != 0) {
throw new GradleException("flatc failed with: ${executionResult.get().toString()}")
}
}
}
task generateFbsKotlin(type: Exec) {
def inputDir = file("$projectDir/src/main/fbs")
def outputKotlinDir = file("$projectDir/src/main/java/generated/")
def fbsFiles = layout.files { file(inputDir).listFiles() }.filter { File f -> f.name.endsWith(".fbs") }.toList()
ignoreExitValue(true)
standardOutput = new ByteArrayOutputStream()
errorOutput = new ByteArrayOutputStream()
setErrorOutput(errorOutput)
setStandardOutput(standardOutput)
def commandLineArgs = ['flatc', '-o', outputKotlinDir, '--kotlin']
fbsFiles.forEach{
commandLineArgs.add(it.path)
}
commandLine commandLineArgs
doFirst {
delete "$outputKotlinDir/"
mkdir "$outputKotlinDir/"
}
doLast {
if (executionResult.get().exitValue != 0) {
throw new GradleException("flatc failed with: ${executionResult.get().toString()}")
}
}
}
afterEvaluate {
tasks.named("preBuild") {
dependsOn(generateFbsKotlin)
dependsOn(generateFbsCpp)
}
}
namespace 'com.flatbuffers.app'
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.6.1'
// If you using java runtime you can add its dependency as the example below
// implementation 'com.google.flatbuffers:flatbuffers-java:$latest_version'
}

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,53 @@
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html
# Sets the minimum version of CMake required to build the native library.
cmake_minimum_required(VERSION 3.4.1)
# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.
include_directories(${FLATBUFFERS_SRC}/include)
add_subdirectory(flatbuffers)
FILE(GLOB Generated_SRCS generated/*.h)
add_library( # Sets the name of the library.
native-lib
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
animals.cpp
${Generated_SRCS}
)
# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.
find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log )
# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.
target_link_libraries( # Specifies the target library.
native-lib
flatbuffers
# Links the target library to the log library
# included in the NDK.
${log-lib} )

View File

@@ -0,0 +1,41 @@
/*
* Copyright 2014 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <jni.h>
#include <search.h>
#include <string>
#include "generated/animal_generated.h"
using namespace com::fbs::app;
using namespace flatbuffers;
extern "C" JNIEXPORT jbyteArray JNICALL
Java_com_flatbuffers_app_MainActivity_createAnimalFromJNI(JNIEnv* env,
jobject /* this */) {
// create a new animal flatbuffers
auto fb = FlatBufferBuilder(1024);
auto tiger = CreateAnimalDirect(fb, "Tiger", "Roar", 300);
fb.Finish(tiger);
// copies it to a Java byte array.
auto buf = reinterpret_cast<jbyte*>(fb.GetBufferPointer());
int size = fb.GetSize();
auto ret = env->NewByteArray(size);
env->SetByteArrayRegion(ret, 0, fb.GetSize(), buf);
return ret;
}

View File

@@ -0,0 +1,56 @@
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html
# Sets the minimum version of CMake required to build the native library.
cmake_minimum_required(VERSION 3.4.1)
include_directories(${FLATBUFFERS_SRC}/include)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -fexceptions -Wall -DFLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE")
# Certain platforms such as ARM do not use signed chars by default
# which causes issues with certain bounds checks.
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -fsigned-char")
set(FlatBuffers_Library_SRCS
${FLATBUFFERS_SRC}/include/flatbuffers/allocator.h
${FLATBUFFERS_SRC}/include/flatbuffers/array.h
${FLATBUFFERS_SRC}/include/flatbuffers/base.h
${FLATBUFFERS_SRC}/include/flatbuffers/buffer.h
${FLATBUFFERS_SRC}/include/flatbuffers/buffer_ref.h
${FLATBUFFERS_SRC}/include/flatbuffers/default_allocator.h
${FLATBUFFERS_SRC}/include/flatbuffers/detached_buffer.h
${FLATBUFFERS_SRC}/include/flatbuffers/flatbuffer_builder.h
${FLATBUFFERS_SRC}/include/flatbuffers/flatbuffers.h
${FLATBUFFERS_SRC}/include/flatbuffers/flexbuffers.h
${FLATBUFFERS_SRC}/include/flatbuffers/flex_flat_util.h
${FLATBUFFERS_SRC}/include/flatbuffers/hash.h
${FLATBUFFERS_SRC}/include/flatbuffers/idl.h
${FLATBUFFERS_SRC}/include/flatbuffers/minireflect.h
${FLATBUFFERS_SRC}/include/flatbuffers/reflection.h
${FLATBUFFERS_SRC}/include/flatbuffers/reflection_generated.h
${FLATBUFFERS_SRC}/include/flatbuffers/registry.h
${FLATBUFFERS_SRC}/include/flatbuffers/stl_emulation.h
${FLATBUFFERS_SRC}/include/flatbuffers/string.h
${FLATBUFFERS_SRC}/include/flatbuffers/struct.h
${FLATBUFFERS_SRC}/include/flatbuffers/table.h
${FLATBUFFERS_SRC}/include/flatbuffers/util.h
${FLATBUFFERS_SRC}/include/flatbuffers/vector.h
${FLATBUFFERS_SRC}/include/flatbuffers/vector_downward.h
${FLATBUFFERS_SRC}/include/flatbuffers/verifier.h
${FLATBUFFERS_SRC}/src/idl_parser.cpp
${FLATBUFFERS_SRC}/src/idl_gen_text.cpp
${FLATBUFFERS_SRC}/src/reflection.cpp
${FLATBUFFERS_SRC}/src/util.cpp
${FLATBUFFERS_SRC}/src/idl_gen_fbs.cpp
${FLATBUFFERS_SRC}/src/code_generators.cpp
)
add_library( # Sets the name of the library.
flatbuffers
${FlatBuffers_Library_SRCS}
${Generated_SRCS}
)

View File

@@ -0,0 +1,119 @@
// automatically generated by the FlatBuffers compiler, do not modify
#ifndef FLATBUFFERS_GENERATED_ANIMAL_COM_FBS_APP_H_
#define FLATBUFFERS_GENERATED_ANIMAL_COM_FBS_APP_H_
#include "flatbuffers/flatbuffers.h"
// Ensure the included flatbuffers.h is the same version as when this file was
// generated, otherwise it may not be compatible.
static_assert(FLATBUFFERS_VERSION_MAJOR == 24 &&
FLATBUFFERS_VERSION_MINOR == 12 &&
FLATBUFFERS_VERSION_REVISION == 23,
"Non-compatible flatbuffers version included");
namespace com {
namespace fbs {
namespace app {
struct Animal;
struct AnimalBuilder;
struct Animal FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
typedef AnimalBuilder Builder;
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_NAME = 4,
VT_SOUND = 6,
VT_WEIGHT = 8
};
const ::flatbuffers::String* name() const {
return GetPointer<const ::flatbuffers::String*>(VT_NAME);
}
const ::flatbuffers::String* sound() const {
return GetPointer<const ::flatbuffers::String*>(VT_SOUND);
}
uint16_t weight() const { return GetField<uint16_t>(VT_WEIGHT, 0); }
bool Verify(::flatbuffers::Verifier& verifier) const {
return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NAME) &&
verifier.VerifyString(name()) && VerifyOffset(verifier, VT_SOUND) &&
verifier.VerifyString(sound()) &&
VerifyField<uint16_t>(verifier, VT_WEIGHT, 2) && verifier.EndTable();
}
};
struct AnimalBuilder {
typedef Animal Table;
::flatbuffers::FlatBufferBuilder& fbb_;
::flatbuffers::uoffset_t start_;
void add_name(::flatbuffers::Offset<::flatbuffers::String> name) {
fbb_.AddOffset(Animal::VT_NAME, name);
}
void add_sound(::flatbuffers::Offset<::flatbuffers::String> sound) {
fbb_.AddOffset(Animal::VT_SOUND, sound);
}
void add_weight(uint16_t weight) {
fbb_.AddElement<uint16_t>(Animal::VT_WEIGHT, weight, 0);
}
explicit AnimalBuilder(::flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) {
start_ = fbb_.StartTable();
}
::flatbuffers::Offset<Animal> Finish() {
const auto end = fbb_.EndTable(start_);
auto o = ::flatbuffers::Offset<Animal>(end);
return o;
}
};
inline ::flatbuffers::Offset<Animal> CreateAnimal(
::flatbuffers::FlatBufferBuilder& _fbb,
::flatbuffers::Offset<::flatbuffers::String> name = 0,
::flatbuffers::Offset<::flatbuffers::String> sound = 0,
uint16_t weight = 0) {
AnimalBuilder builder_(_fbb);
builder_.add_sound(sound);
builder_.add_name(name);
builder_.add_weight(weight);
return builder_.Finish();
}
inline ::flatbuffers::Offset<Animal> CreateAnimalDirect(
::flatbuffers::FlatBufferBuilder& _fbb, const char* name = nullptr,
const char* sound = nullptr, uint16_t weight = 0) {
auto name__ = name ? _fbb.CreateString(name) : 0;
auto sound__ = sound ? _fbb.CreateString(sound) : 0;
return com::fbs::app::CreateAnimal(_fbb, name__, sound__, weight);
}
inline const com::fbs::app::Animal* GetAnimal(const void* buf) {
return ::flatbuffers::GetRoot<com::fbs::app::Animal>(buf);
}
inline const com::fbs::app::Animal* GetSizePrefixedAnimal(const void* buf) {
return ::flatbuffers::GetSizePrefixedRoot<com::fbs::app::Animal>(buf);
}
inline bool VerifyAnimalBuffer(::flatbuffers::Verifier& verifier) {
return verifier.VerifyBuffer<com::fbs::app::Animal>(nullptr);
}
inline bool VerifySizePrefixedAnimalBuffer(::flatbuffers::Verifier& verifier) {
return verifier.VerifySizePrefixedBuffer<com::fbs::app::Animal>(nullptr);
}
inline void FinishAnimalBuffer(
::flatbuffers::FlatBufferBuilder& fbb,
::flatbuffers::Offset<com::fbs::app::Animal> root) {
fbb.Finish(root);
}
inline void FinishSizePrefixedAnimalBuffer(
::flatbuffers::FlatBufferBuilder& fbb,
::flatbuffers::Offset<com::fbs::app::Animal> root) {
fbb.FinishSizePrefixed(root);
}
} // namespace app
} // namespace fbs
} // namespace com
#endif // FLATBUFFERS_GENERATED_ANIMAL_COM_FBS_APP_H_

View File

@@ -12,11 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
namespace sample;
namespace com.fbs.app;
table Animal {
name:string;
sound:string;
weight: uint16;
}
root_type Animal;

View File

@@ -0,0 +1,52 @@
package com.flatbuffers.app
import android.annotation.SuppressLint
import android.os.Bundle
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.fbs.app.Animal
import com.google.flatbuffers.FlatBufferBuilder
import java.nio.ByteBuffer
@ExperimentalUnsignedTypes
class MainActivity : AppCompatActivity() {
@SuppressLint("SetTextI18n")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val tiger = Animal.getRootAsAnimal(ByteBuffer.wrap(createAnimalFromJNI()))
findViewById<TextView>(R.id.tv_animal_one).text = animalInfo(tiger)
findViewById<TextView>(R.id.tv_animal_two).text = animalInfo(createAnimalFromKotlin())
}
// This function is a sample of communicating FlatBuffers between JNI (native C++) and Java.
// Implementation can be found on animals.cpp file.
private external fun createAnimalFromJNI(): ByteArray
// Create a "Cow" Animal flatbuffers from Kotlin
private fun createAnimalFromKotlin(): Animal {
val fb = FlatBufferBuilder(100)
val cowOffset =
Animal.createAnimal(
builder = fb,
nameOffset = fb.createString("Cow"),
soundOffset = fb.createString("Moo"),
weight = 720u,
)
fb.finish(cowOffset)
return Animal.getRootAsAnimal(fb.dataBuffer())
}
private fun animalInfo(animal: Animal): String =
"The ${animal.name} sound is ${animal.sound} and it weights ${animal.weight}kg."
companion object {
// Used to load the 'native-lib' library on application startup.
init {
System.loadLibrary("native-lib")
}
}
}

View File

@@ -0,0 +1,102 @@
// automatically generated by the FlatBuffers compiler, do not modify
package com.fbs.app
import com.google.flatbuffers.Constants
import com.google.flatbuffers.FlatBufferBuilder
import com.google.flatbuffers.Table
import java.nio.ByteBuffer
import java.nio.ByteOrder
@Suppress("unused")
@kotlin.ExperimentalUnsignedTypes
class Animal : Table() {
fun __init(_i: Int, _bb: ByteBuffer) {
__reset(_i, _bb)
}
fun __assign(_i: Int, _bb: ByteBuffer): Animal {
__init(_i, _bb)
return this
}
val name: String?
get() {
val o = __offset(4)
return if (o != 0) {
__string(o + bb_pos)
} else {
null
}
}
val nameAsByteBuffer: ByteBuffer
get() = __vector_as_bytebuffer(4, 1)
fun nameInByteBuffer(_bb: ByteBuffer): ByteBuffer = __vector_in_bytebuffer(_bb, 4, 1)
val sound: String?
get() {
val o = __offset(6)
return if (o != 0) {
__string(o + bb_pos)
} else {
null
}
}
val soundAsByteBuffer: ByteBuffer
get() = __vector_as_bytebuffer(6, 1)
fun soundInByteBuffer(_bb: ByteBuffer): ByteBuffer = __vector_in_bytebuffer(_bb, 6, 1)
val weight: UShort
get() {
val o = __offset(8)
return if (o != 0) bb.getShort(o + bb_pos).toUShort() else 0u
}
companion object {
fun validateVersion() = Constants.FLATBUFFERS_25_12_19()
fun getRootAsAnimal(_bb: ByteBuffer): Animal = getRootAsAnimal(_bb, Animal())
fun getRootAsAnimal(_bb: ByteBuffer, obj: Animal): Animal {
_bb.order(ByteOrder.LITTLE_ENDIAN)
return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb))
}
fun createAnimal(
builder: FlatBufferBuilder,
nameOffset: Int,
soundOffset: Int,
weight: UShort,
): Int {
builder.startTable(3)
addSound(builder, soundOffset)
addName(builder, nameOffset)
addWeight(builder, weight)
return endAnimal(builder)
}
fun startAnimal(builder: FlatBufferBuilder) = builder.startTable(3)
fun addName(builder: FlatBufferBuilder, name: Int) = builder.addOffset(0, name, 0)
fun addSound(builder: FlatBufferBuilder, sound: Int) = builder.addOffset(1, sound, 0)
fun addWeight(builder: FlatBufferBuilder, weight: UShort) =
builder.addShort(2, weight.toShort(), 0)
fun endAnimal(builder: FlatBufferBuilder): Int {
val o = builder.endTable()
return o
}
fun finishAnimalBuffer(builder: FlatBufferBuilder, offset: Int) = builder.finish(offset)
fun finishSizePrefixedAnimalBuffer(builder: FlatBufferBuilder, offset: Int) =
builder.finishSizePrefixed(offset)
}
}

View File

@@ -0,0 +1,30 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>

View File

@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
tools:context=".MainActivity">
<TextView
android:id="@+id/tv_animal_one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="Text Sample"/>
<TextView
android:id="@+id/tv_animal_two"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="Text Sample 2"/>
</LinearLayout>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#6200EE</color>
<color name="colorPrimaryDark">#3700B3</color>
<color name="colorAccent">#03DAC5</color>
</resources>

View File

@@ -0,0 +1,3 @@
<resources>
<string name="app_name">FlatbuffersTestApp</string>
</resources>

View File

@@ -0,0 +1,10 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>

35
android/build.gradle Normal file
View File

@@ -0,0 +1,35 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.7.21"
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
compileKotlin {
dependsOn flatbuffer
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

View File

@@ -1,510 +0,0 @@
#!/bin/bash -eu
# Copyright (c) 2013 Google, Inc.
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any damages
# arising from the use of this software.
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
# 1. The origin of this software must not be misrepresented; you must not
# claim that you wrote the original software. If you use this software
# in a product, an acknowledgment in the product documentation would be
# appreciated but is not required.
# 2. Altered source versions must be plainly marked as such, and must not be
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
#
# Build, deploy, debug / execute a native Android package based upon
# NativeActivity.
declare -r script_directory=$(dirname $0)
declare -r android_root=${script_directory}/../../../../../../
declare -r script_name=$(basename $0)
declare -r android_manifest=AndroidManifest.xml
declare -r os_name=$(uname -s)
# Minimum Android target version supported by this project.
: ${BUILDAPK_ANDROID_TARGET_MINVERSION:=10}
# Directory containing the Android SDK
# (http://developer.android.com/sdk/index.html).
: ${ANDROID_SDK_HOME:=}
# Directory containing the Android NDK
# (http://developer.android.com/tools/sdk/ndk/index.html).
: ${NDK_HOME:=}
# Display script help and exit.
usage() {
echo "
Build the Android package in the current directory and deploy it to a
connected device.
Usage: ${script_name} \\
[ADB_DEVICE=serial_number] [BUILD=0] [DEPLOY=0] [RUN_DEBUGGER=1] \
[LAUNCH=0] [SWIG_BIN=swig_binary_directory] [SWIG_LIB=swig_include_directory] [ndk-build arguments ...]
ADB_DEVICE=serial_number:
serial_number specifies the device to deploy the built apk to if multiple
Android devices are connected to the host.
BUILD=0:
Disables the build of the package.
DEPLOY=0:
Disables the deployment of the built apk to the Android device.
RUN_DEBUGGER=1:
Launches the application in gdb after it has been deployed. To debug in
gdb, NDK_DEBUG=1 must also be specified on the command line to build a
debug apk.
LAUNCH=0:
Disable the launch of the apk on the Android device.
SWIG_BIN=swig_binary_directory:
The directory where the SWIG binary lives. No need to set this if SWIG is
installed and point to from your PATH variable.
SWIG_LIB=swig_include_directory:
The directory where SWIG shared include files are, usually obtainable from
commandline with \"swig -swiglib\". No need to set this if SWIG is installed
and point to from your PATH variable.
ndk-build arguments...:
Additional arguments for ndk-build. See ndk-build -h for more information.
" >&2
exit 1
}
# Get the number of CPU cores present on the host.
get_number_of_cores() {
case ${os_name} in
Darwin)
sysctl hw.ncpu | awk '{ print $2 }'
;;
CYGWIN*|Linux)
awk '/^processor/ { n=$3 } END { print n + 1 }' /proc/cpuinfo
;;
*)
echo 1
;;
esac
}
# Get the package name from an AndroidManifest.xml file.
get_package_name_from_manifest() {
xmllint --xpath 'string(/manifest/@package)' "${1}"
}
# Get the library name from an AndroidManifest.xml file.
get_library_name_from_manifest() {
echo "\
setns android=http://schemas.android.com/apk/res/android
xpath string(/manifest/application/activity\
[@android:name=\"android.app.NativeActivity\"]/meta-data\
[@android:name=\"android.app.lib_name\"]/@android:value)" |
xmllint --shell "${1}" | awk '/Object is a string/ { print $NF }'
}
# Get the number of Android devices connected to the system.
get_number_of_devices_connected() {
adb devices -l | \
awk '/^..*$/ { if (p) { print $0 } }
/List of devices attached/ { p = 1 }' | \
wc -l
return ${PIPESTATUS[0]}
}
# Kill a process and its' children. This is provided for cygwin which
# doesn't ship with pkill.
kill_process_group() {
local parent_pid="${1}"
local child_pid=
for child_pid in $(ps -f | \
awk '{ if ($3 == '"${parent_pid}"') { print $2 } }'); do
kill_process_group "${child_pid}"
done
kill "${parent_pid}" 2>/dev/null
}
# Find and run "adb".
adb() {
local adb_path=
for path in "$(which adb 2>/dev/null)" \
"${ANDROID_SDK_HOME}/sdk/platform-tools/adb" \
"${android_root}/prebuilts/sdk/platform-tools/adb"; do
if [[ -e "${path}" ]]; then
adb_path="${path}"
break
fi
done
if [[ "${adb_path}" == "" ]]; then
echo -e "Unable to find adb." \
"\nAdd the Android ADT sdk/platform-tools directory to the" \
"PATH." >&2
exit 1
fi
"${adb_path}" "$@"
}
# Find and run "android".
android() {
local android_executable=android
if echo "${os_name}" | grep -q CYGWIN; then
android_executable=android.bat
fi
local android_path=
for path in "$(which ${android_executable})" \
"${ANDROID_SDK_HOME}/sdk/tools/${android_executable}" \
"${android_root}/prebuilts/sdk/tools/${android_executable}"; do
if [[ -e "${path}" ]]; then
android_path="${path}"
break
fi
done
if [[ "${android_path}" == "" ]]; then
echo -e "Unable to find android tool." \
"\nAdd the Android ADT sdk/tools directory to the PATH." >&2
exit 1
fi
# Make sure ant is installed.
if [[ "$(which ant)" == "" ]]; then
echo -e "Unable to find ant." \
"\nPlease install ant and add to the PATH." >&2
exit 1
fi
"${android_path}" "$@"
}
# Find and run "ndk-build"
ndkbuild() {
local ndkbuild_path=
for path in "$(which ndk-build 2>/dev/null)" \
"${NDK_HOME}/ndk-build" \
"${android_root}/prebuilts/ndk/current/ndk-build"; do
if [[ -e "${path}" ]]; then
ndkbuild_path="${path}"
break
fi
done
if [[ "${ndkbuild_path}" == "" ]]; then
echo -e "Unable to find ndk-build." \
"\nAdd the Android NDK directory to the PATH." >&2
exit 1
fi
"${ndkbuild_path}" "$@"
}
# Get file modification time of $1 in seconds since the epoch.
stat_mtime() {
local filename="${1}"
case ${os_name} in
Darwin) stat -f%m "${filename}" 2>/dev/null || echo 0 ;;
*) stat -c%Y "${filename}" 2>/dev/null || echo 0 ;;
esac
}
# Build the native (C/C++) build targets in the current directory.
build_native_targets() {
# Save the list of output modules in the install directory so that it's
# possible to restore their timestamps after the build is complete. This
# works around a bug in ndk/build/core/setup-app.mk which results in the
# unconditional execution of the clean-installed-binaries rule.
restore_libraries="$(find libs -type f 2>/dev/null | \
sed -E 's@^libs/(.*)@\1@')"
# Build native code.
ndkbuild -j$(get_number_of_cores) "$@"
# Restore installed libraries.
# Obviously this is a nasty hack (along with ${restore_libraries} above) as
# it assumes it knows where the NDK will be placing output files.
(
IFS=$'\n'
for libpath in ${restore_libraries}; do
source_library="obj/local/${libpath}"
target_library="libs/${libpath}"
if [[ -e "${source_library}" ]]; then
cp -a "${source_library}" "${target_library}"
fi
done
)
}
# Select the oldest installed android build target that is at least as new as
# BUILDAPK_ANDROID_TARGET_MINVERSION. If a suitable build target isn't found,
# this function prints an error message and exits with an error.
select_android_build_target() {
local -r android_targets_installed=$( \
android list targets | \
awk -F'"' '/^id:.*android/ { print $2 }')
local android_build_target=
for android_target in $(echo "${android_targets_installed}" | \
awk -F- '{ print $2 }' | sort -n); do
local isNumber='^[0-9]+$'
# skip preview API releases e.g. 'android-L'
if [[ $android_target =~ $isNumber ]]; then
if [[ $((android_target)) -ge \
$((BUILDAPK_ANDROID_TARGET_MINVERSION)) ]]; then
android_build_target="android-${android_target}"
break
fi
# else
# The API version is a letter, so skip it.
fi
done
if [[ "${android_build_target}" == "" ]]; then
echo -e \
"Found installed Android targets:" \
"$(echo ${android_targets_installed} | sed 's/ /\n /g;s/^/\n /;')" \
"\nAndroid SDK platform" \
"android-$((BUILDAPK_ANDROID_TARGET_MINVERSION))" \
"must be installed to build this project." \
"\nUse the \"android\" application to install API" \
"$((BUILDAPK_ANDROID_TARGET_MINVERSION)) or newer." >&2
exit 1
fi
echo "${android_build_target}"
}
# Sign unsigned apk $1 and write the result to $2 with key store file $3 and
# password $4.
# If a key store file $3 and password $4 aren't specified, a temporary
# (60 day) key is generated and used to sign the package.
sign_apk() {
local unsigned_apk="${1}"
local signed_apk="${2}"
if [[ $(stat_mtime "${unsigned_apk}") -gt \
$(stat_mtime "${signed_apk}") ]]; then
local -r key_alias=$(basename ${signed_apk} .apk)
local keystore="${3}"
local key_password="${4}"
[[ "${keystore}" == "" ]] && keystore="${unsigned_apk}.keystore"
[[ "${key_password}" == "" ]] && \
key_password="${key_alias}123456"
if [[ ! -e ${keystore} ]]; then
keytool -genkey -v -dname "cn=, ou=${key_alias}, o=fpl" \
-storepass ${key_password} \
-keypass ${key_password} -keystore ${keystore} \
-alias ${key_alias} -keyalg RSA -keysize 2048 -validity 60
fi
cp "${unsigned_apk}" "${signed_apk}"
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 \
-keystore ${keystore} -storepass ${key_password} \
-keypass ${key_password} "${signed_apk}" ${key_alias}
fi
}
# Build the apk $1 for package filename $2 in the current directory using the
# ant build target $3.
build_apk() {
local -r output_apk="${1}"
local -r package_filename="${2}"
local -r ant_target="${3}"
# Get the list of installed android targets and select the oldest target
# that is at least as new as BUILDAPK_ANDROID_TARGET_MINVERSION.
local -r android_build_target=$(select_android_build_target)
[[ "${android_build_target}" == "" ]] && exit 1
echo "Building ${output_apk} for target ${android_build_target}" >&2
# Create / update build.xml and local.properties files.
if [[ $(stat_mtime "${android_manifest}") -gt \
$(stat_mtime build.xml) ]]; then
android update project --target "${android_build_target}" \
-n ${package_filename} --path .
fi
# Use ant to build the apk.
ant -quiet ${ant_target}
# Sign release apks with a temporary key as these packages will not be
# redistributed.
local unsigned_apk="bin/${package_filename}-${ant_target}-unsigned.apk"
if [[ "${ant_target}" == "release" ]]; then
sign_apk "${unsigned_apk}" "${output_apk}" "" ""
fi
}
# Uninstall package $1 and install apk $2 on device $3 where $3 is "-s device"
# or an empty string. If $3 is an empty string adb will fail when multiple
# devices are connected to the host system.
install_apk() {
local -r uninstall_package_name="${1}"
local -r install_apk="${2}"
local -r adb_device="${3}"
# Uninstall the package if it's already installed.
adb ${adb_device} uninstall "${uninstall_package_name}" 1>&2 > /dev/null || \
true # no error check
# Install the apk.
# NOTE: The following works around adb not returning an error code when
# it fails to install an apk.
echo "Install ${install_apk}" >&2
local -r adb_install_result=$(adb ${adb_device} install "${install_apk}")
echo "${adb_install_result}"
if echo "${adb_install_result}" | grep -qF 'Failure ['; then
exit 1
fi
}
# Launch previously installed package $1 on device $2.
# If $2 is an empty string adb will fail when multiple devices are connected
# to the host system.
launch_package() {
(
# Determine the SDK version of Android on the device.
local -r android_sdk_version=$(
adb ${adb_device} shell cat system/build.prop | \
awk -F= '/ro.build.version.sdk/ {
v=$2; sub(/[ \r\n]/, "", v); print v
}')
# Clear logs from previous runs.
# Note that logcat does not just 'tail' the logs, it dumps the entire log
# history.
adb ${adb_device} logcat -c
local finished_msg='Displayed '"${package_name}"
local timeout_msg='Activity destroy timeout.*'"${package_name}"
# Maximum time to wait before stopping log monitoring. 0 = infinity.
local launch_timeout=0
# If this is a Gingerbread device, kill log monitoring after 10 seconds.
if [[ $((android_sdk_version)) -le 10 ]]; then
launch_timeout=10
fi
# Display logcat in the background.
# Stop displaying the log when the app launch / execution completes or the
# logcat
(
adb ${adb_device} logcat | \
awk "
{
print \$0
}
/ActivityManager.*: ${finished_msg}/ {
exit 0
}
/ActivityManager.*: ${timeout_msg}/ {
exit 0
}" &
adb_logcat_pid=$!;
if [[ $((launch_timeout)) -gt 0 ]]; then
sleep $((launch_timeout));
kill ${adb_logcat_pid};
else
wait ${adb_logcat_pid};
fi
) &
logcat_pid=$!
# Kill adb logcat if this shell exits.
trap "kill_process_group ${logcat_pid}" SIGINT SIGTERM EXIT
# If the SDK is newer than 10, "am" supports stopping an activity.
adb_stop_activity=
if [[ $((android_sdk_version)) -gt 10 ]]; then
adb_stop_activity=-S
fi
# Launch the activity and wait for it to complete.
adb ${adb_device} shell am start ${adb_stop_activity} -n \
${package_name}/android.app.NativeActivity
wait "${logcat_pid}"
)
}
# See usage().
main() {
# Parse arguments for this script.
local adb_device=
local ant_target=release
local disable_deploy=0
local disable_build=0
local run_debugger=0
local launch=1
local build_package=1
for opt; do
case ${opt} in
# NDK_DEBUG=0 tells ndk-build to build this as debuggable but to not
# modify the underlying code whereas NDK_DEBUG=1 also builds as debuggable
# but does modify the code
NDK_DEBUG=1) ant_target=debug ;;
NDK_DEBUG=0) ant_target=debug ;;
ADB_DEVICE*) adb_device="$(\
echo "${opt}" | sed -E 's/^ADB_DEVICE=([^ ]+)$/-s \1/;t;s/.*//')" ;;
BUILD=0) disable_build=1 ;;
DEPLOY=0) disable_deploy=1 ;;
RUN_DEBUGGER=1) run_debugger=1 ;;
LAUNCH=0) launch=0 ;;
clean) build_package=0 disable_deploy=1 launch=0 ;;
-h|--help|help) usage ;;
esac
done
# If a target device hasn't been specified and multiple devices are connected
# to the host machine, display an error.
local -r devices_connected=$(get_number_of_devices_connected)
if [[ "${adb_device}" == "" && $((devices_connected)) -gt 1 && \
($((disable_deploy)) -eq 0 || $((launch)) -ne 0 || \
$((run_debugger)) -ne 0) ]]; then
if [[ $((disable_deploy)) -ne 0 ]]; then
echo "Deployment enabled, disable using DEPLOY=0" >&2
fi
if [[ $((launch)) -ne 0 ]]; then
echo "Launch enabled." >&2
fi
if [[ $((disable_deploy)) -eq 0 ]]; then
echo "Deployment enabled." >&2
fi
if [[ $((run_debugger)) -ne 0 ]]; then
echo "Debugger launch enabled." >&2
fi
echo "
Multiple Android devices are connected to this host. Either disable deployment
and execution of the built .apk using:
\"${script_name} DEPLOY=0 LAUNCH=0\"
or specify a device to deploy to using:
\"${script_name} ADB_DEVICE=\${device_serial}\".
The Android devices connected to this machine are:
$(adb devices -l)
" >&2
exit 1
fi
if [[ $((disable_build)) -eq 0 ]]; then
# Build the native target.
build_native_targets "$@"
fi
# Get the package name from the manifest.
local -r package_name=$(get_package_name_from_manifest "${android_manifest}")
if [[ "${package_name}" == "" ]]; then
echo -e "No package name specified in ${android_manifest},"\
"skipping apk build, deploy"
"\nand launch steps." >&2
exit 0
fi
local -r package_basename=${package_name/*./}
local package_filename=$(get_library_name_from_manifest ${android_manifest})
[[ "${package_filename}" == "" ]] && package_filename="${package_basename}"
# Output apk name.
local -r output_apk="bin/${package_filename}-${ant_target}.apk"
if [[ $((disable_build)) -eq 0 && $((build_package)) -eq 1 ]]; then
# Build the apk.
build_apk "${output_apk}" "${package_filename}" "${ant_target}"
fi
# Deploy to the device.
if [[ $((disable_deploy)) -eq 0 ]]; then
install_apk "${package_name}" "${output_apk}" "${adb_device}"
fi
if [[ "${ant_target}" == "debug" && $((run_debugger)) -eq 1 ]]; then
# Start debugging.
ndk-gdb ${adb_device} --start
elif [[ $((launch)) -eq 1 ]]; then
launch_package "${package_name}" "${adb_device}"
fi
}
main "$@"

23
android/gradle.properties Normal file
View File

@@ -0,0 +1,23 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
# Use parallel builds
org.gradle.parallel=true

Binary file not shown.

View File

@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

172
android/gradlew vendored Executable file
View File

@@ -0,0 +1,172 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

84
android/gradlew.bat vendored Normal file
View File

@@ -0,0 +1,84 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@@ -1,42 +0,0 @@
# Copyright (c) 2013 Google, Inc.
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any damages
# arising from the use of this software.
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
# 1. The origin of this software must not be misrepresented; you must not
# claim that you wrote the original software. If you use this software
# in a product, an acknowledgment in the product documentation would be
# appreciated but is not required.
# 2. Altered source versions must be plainly marked as such, and must not be
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
LOCAL_PATH := $(call my-dir)
# Empty static library so that other projects can include FlatBuffers as a
# module.
include $(CLEAR_VARS)
LOCAL_MODULE := flatbuffers
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../include
LOCAL_EXPORT_CPPFLAGS := -std=c++11 -fexceptions -Wall -Wno-literal-suffix
include $(BUILD_STATIC_LIBRARY)
# FlatBuffers test
include $(CLEAR_VARS)
LOCAL_MODULE := FlatBufferTest
LOCAL_SRC_FILES := main.cpp \
../../tests/test.cpp \
../../src/idl_parser.cpp \
../../src/idl_gen_text.cpp \
../../src/idl_gen_fbs.cpp
LOCAL_LDLIBS := -llog -landroid
LOCAL_STATIC_LIBRARIES := android_native_app_glue flatbuffers
LOCAL_ARM_MODE := arm
include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/native_app_glue)
$(call import-add-path,../..)

View File

@@ -1,22 +0,0 @@
# Copyright (c) 2014 Google, Inc.
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any damages
# arising from the use of this software.
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
# 1. The origin of this software must not be misrepresented; you must not
# claim that you wrote the original software. If you use this software
# in a product, an acknowledgment in the product documentation would be
# appreciated but is not required.
# 2. Altered source versions must be plainly marked as such, and must not be
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
APP_PLATFORM := android-10
APP_PROJECT_PATH := $(call my-dir)/..
APP_STL := gnustl_static
APP_ABI := armeabi-v7a
NDK_TOOLCHAIN_VERSION := 4.8
APP_CPPFLAGS += -std=c++11

View File

@@ -1,177 +0,0 @@
# Copyright 2014 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This file contains utility functions for Android projects using Flatbuffers.
# To use this file, include it in your project's Android.mk by calling near the
# top of your android makefile like so:
#
# include $(FLATBUFFERS_DIR)/android/jni/include.mk
#
# You will also need to import the flatbuffers module using the standard
# import-module function.
#
# The main functionality this file provides are the following functions:
# flatbuffers_fbs_to_h: Converts flatbuffer schema paths to header paths.
# flatbuffers_header_build_rule:
# Creates a build rule for a schema's generated header. This build rule
# has a dependency on the flatc compiler which will be built if necessary.
# flatbuffers_header_build_rules:
# Creates build rules for generated headers for each schema listed and sets
# up depenedendies.
#
# More information and example usage can be found in the comments preceeding
# each function.
# Targets to build the Flatbuffers compiler as well as some utility definitions
ifeq (,$(FLATBUFFERS_INCLUDE_MK_))
FLATBUFFERS_INCLUDE_MK_ := 1
PROJECT_OS := $(OS)
ifeq (,$(OS))
PROJECT_OS := $(shell uname -s)
else
ifneq ($(findstring Windows,$(PROJECT_OS)),)
PROJECT_OS := Windows
endif
endif
# The following block generates build rules which result in headers being
# rebuilt from flatbuffers schemas.
FLATBUFFERS_CMAKELISTS_DIR := \
$(realpath $(dir $(lastword $(MAKEFILE_LIST)))/../..)
# Directory that contains the FlatBuffers compiler.
ifeq (Windows,$(PROJECT_OS))
FLATBUFFERS_FLATC_PATH?=$(CURDIR)/bin
FLATBUFFERS_FLATC := $(FLATBUFFERS_FLATC_PATH)/Debug/flatc.exe
endif
ifeq (Linux,$(PROJECT_OS))
FLATBUFFERS_FLATC_PATH?=$(CURDIR)/bin
FLATBUFFERS_FLATC := $(FLATBUFFERS_FLATC_PATH)/flatc
endif
ifeq (Darwin,$(PROJECT_OS))
FLATBUFFERS_FLATC_PATH?=$(FLATBUFFERS_CMAKELISTS_DIR)
FLATBUFFERS_FLATC := $(FLATBUFFERS_FLATC_PATH)/Debug/flatc
endif
# Search for cmake.
CMAKE_ROOT := $(realpath $(LOCAL_PATH)/../../../../../../prebuilts/cmake)
ifeq (,$(CMAKE))
ifeq (Linux,$(PROJECT_OS))
CMAKE := $(wildcard $(CMAKE_ROOT)/linux-x86/current/bin/cmake*)
endif
ifeq (Darwin,$(PROJECT_OS))
CMAKE := \
$(wildcard $(CMAKE_ROOT)/darwin-x86_64/current/*.app/Contents/bin/cmake)
endif
ifeq (Windows,$(PROJECT_OS))
CMAKE := $(wildcard $(CMAKE_ROOT)/windows/current/bin/cmake*)
endif
endif
ifeq (,$(CMAKE))
CMAKE := cmake
endif
# Generate a host build rule for the flatbuffers compiler.
ifeq (Windows,$(PROJECT_OS))
define build_flatc_recipe
cd & jni\build_flatc.bat $(CMAKE)
endef
endif
ifeq (Linux,$(PROJECT_OS))
define build_flatc_recipe
mkdir -p bin && cd bin && $(CMAKE) $(FLATBUFFERS_CMAKELISTS_DIR) \
&& $(MAKE) flatc
endef
endif
ifeq (Darwin,$(PROJECT_OS))
define build_flatc_recipe
cd $(FLATBUFFERS_CMAKELISTS_DIR) && "$(CMAKE)" -GXcode . && \
xcodebuild -target flatc
endef
endif
ifeq (,$(build_flatc_recipe))
ifeq (,$(FLATBUFFERS_FLATC))
$(error flatc binary not found!)
endif
endif
# Generate a build rule for flatc.
ifeq ($(strip $(FLATBUFFERS_FLATC)),)
flatc_target := build_flatc
.PHONY: $(flatc_target)
else
flatc_target := $(FLATBUFFERS_FLATC)
endif
$(flatc_target):
$(call build_flatc_recipe)
# $(flatbuffers_fbs_to_h schema_dir,output_dir,path)
#
# Convert the specified schema path to a Flatbuffers generated header path.
# For example:
#
# $(call flatbuffers_fbs_to_h,$(MY_PROJ_DIR)/schemas,\
# $(MY_PROJ_DIR)/gen/include,$(MY_PROJ_DIR)/schemas/example.fbs)
#
# This will convert the file path `$(MY_PROJ_DIR)/schemas/example.fbs)` to
# `$(MY_PROJ_DIR)/gen/include/example_generated.h`
define flatbuffers_fbs_to_h
$(subst $(1),$(2),$(patsubst %.fbs,%_generated.h,$(3)))
endef
# $(flatbuffers_header_build_rule schema_file,schema_dir,output_dir,\
# schema_include_dirs)
#
# Generate a build rule that will convert a Flatbuffers schema to a generated
# header derived from the schema filename using flatbuffers_fbs_to_h. For
# example:
#
# $(call flatbuffers_header_build_rule,$(MY_PROJ_DIR)/schemas/example.fbs,\
# $(MY_PROJ_DIR)/schemas,$(MY_PROJ_DIR)/gen/include)
#
# The final argument, schema_include_dirs, is optional and is only needed when
# the schema files depend on other schema files outside their own directory.
define flatbuffers_header_build_rule
$(eval \
$(call flatbuffers_fbs_to_h,$(2),$(3),$(1)): $(1) $(flatc_target)
$(call host-echo-build-step,generic,Generate) \
$(subst $(LOCAL_PATH)/,,$(call flatbuffers_fbs_to_h,$(2),$(3),$(1)))
$(hide) $$(FLATBUFFERS_FLATC) --gen-includes \
$(foreach include,$(4),-I $(include)) -o $$(dir $$@) -c $$<)
endef
# $(flatbuffers_header_build_rules schema_files,schema_dir,output_dir,\
# schema_include_dirs,src_files))
#
# Use this in your own Android.mk file to generate build rules that will
# generate header files for your flatbuffer schemas as well as automatically
# set your source files to be dependent on the generated headers. For example:
#
# $(call flatbuffers_header_build_rules,$(MY_PROJ_SCHEMA_FILES),\
# $(MY_PROJ_SCHEMA_DIR),$(MY_PROJ_GENERATED_OUTPUT_DIR),
# $(MY_PROJ_SCHEMA_INCLUDE_DIRS),$(LOCAL_SRC_FILES))
define flatbuffers_header_build_rules
$(foreach schema,$(1),\
$(call flatbuffers_header_build_rule,\
$(schema),$(strip $(2)),$(strip $(3)),$(strip $(4))))\
$(foreach src,$(strip $(5)),\
$(eval $(LOCAL_PATH)/$$(src): \
$(foreach schema,$(strip $(1)),\
$(call flatbuffers_fbs_to_h,$(strip $(2)),$(strip $(3)),$(schema)))))
endef
endif # FLATBUFFERS_INCLUDE_MK_

View File

@@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2014 Google, Inc.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
-->
<resources>
<string name="app_name">FlatBufferTest</string>
</resources>

2
android/settings.gradle Normal file
View File

@@ -0,0 +1,2 @@
include ':app'
rootProject.name = "FlatbuffersTest"

0
bazel/BUILD.bazel Normal file
View File

88
benchmarks/CMakeLists.txt Normal file
View File

@@ -0,0 +1,88 @@
# Setup for running Google Benchmarks (https://github.com/google/benchmark) on
# flatbuffers. This requires both that benchmark library and its dependency gtest
# to build. Instead of including them here or doing a submodule, this uses
# FetchContent (https://cmake.org/cmake/help/latest/module/FetchContent.html) to
# grab the dependencies at config time. This requires CMake 3.14 or higher.
cmake_minimum_required(VERSION 3.14)
include(FetchContent)
# No particular reason for the specific GIT_TAGs for the following repos, they
# were just the latest releases when this was added.
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG e2239ee6043f73722e7aa812a459f54a28552929 # release-1.11.0
)
FetchContent_Declare(
googlebenchmark
GIT_REPOSITORY https://github.com/google/benchmark.git
GIT_TAG 0d98dba29d66e93259db7daa53a9327df767a415 # v1.6.1
)
# For Windows: Prevent overriding the parent project's compiler/linker
# settings.
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(
googletest
googlebenchmark
)
set(CPP_BENCH_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cpp)
set(CPP_FB_BENCH_DIR ${CPP_BENCH_DIR}/flatbuffers)
set(CPP_RAW_BENCH_DIR ${CPP_BENCH_DIR}/raw)
set(CPP_BENCH_FBS ${CPP_FB_BENCH_DIR}/bench.fbs)
set(CPP_BENCH_FB_GEN ${CPP_FB_BENCH_DIR}/bench_generated.h)
set(FlatBenchmark_SRCS
${CPP_BENCH_DIR}/benchmark_main.cpp
${CPP_FB_BENCH_DIR}/fb_bench.cpp
${CPP_RAW_BENCH_DIR}/raw_bench.cpp
${CPP_BENCH_FB_GEN}
)
# Generate the flatbuffers benchmark code from the flatbuffers schema using
# flatc itself, thus it depends on flatc. This also depends on the C++ runtime
# flatbuffers and the schema file itself, so it should auto-generated at the
# correct times.
add_custom_command(
OUTPUT ${CPP_BENCH_FB_GEN}
COMMAND
"${FLATBUFFERS_FLATC_EXECUTABLE}"
--cpp
-o ${CPP_FB_BENCH_DIR}
${CPP_BENCH_FBS}
DEPENDS
flatc
flatbuffers
${CPP_BENCH_FBS}
COMMENT "Run Flatbuffers Benchmark Codegen: ${CPP_BENCH_FB_GEN}"
VERBATIM)
# The main flatbuffers benchmark executable
add_executable(flatbenchmark ${FlatBenchmark_SRCS})
# Benchmark requires C++11
target_compile_features(flatbenchmark PRIVATE
cxx_std_11 # requires cmake 3.8
)
target_compile_options(flatbenchmark
PRIVATE
-fno-aligned-new
-Wno-deprecated-declarations
)
# Set the output directory to the root binary directory
set_target_properties(flatbenchmark
PROPERTIES RUNTIME_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}"
)
# The includes of the benchmark files are fully qualified from flatbuffers root.
target_include_directories(flatbenchmark PUBLIC ${CMAKE_SOURCE_DIR})
target_link_libraries(flatbenchmark PRIVATE
benchmark::benchmark_main # _main to use their entry point
gtest # Link to gtest so we can also assert in the benchmarks
)

19
benchmarks/cpp/bench.h Normal file
View File

@@ -0,0 +1,19 @@
#ifndef BENCHMARKS_CPP_BENCH_H_
#define BENCHMARKS_CPP_BENCH_H_
#include <cstdint>
struct Bench {
virtual ~Bench() {}
inline void Add(int64_t value) { sum += value; }
virtual uint8_t* Encode(void* buf, int64_t& len) = 0;
virtual void* Decode(void* buf, int64_t len) = 0;
virtual int64_t Use(void* decoded) = 0;
virtual void Dealloc(void* decoded) = 0;
int64_t sum = 0;
};
#endif // BENCHMARKS_CPP_BENCH_H_

View File

@@ -0,0 +1,98 @@
#include <benchmark/benchmark.h>
#include <gtest/gtest.h>
#include "benchmarks/cpp/bench.h"
#include "benchmarks/cpp/flatbuffers/fb_bench.h"
#include "benchmarks/cpp/raw/raw_bench.h"
static inline void Encode(benchmark::State& state,
std::unique_ptr<Bench>& bench, uint8_t* buffer) {
int64_t length;
for (auto _ : state) {
bench->Encode(buffer, length);
benchmark::DoNotOptimize(length);
}
}
static inline void Decode(benchmark::State& state,
std::unique_ptr<Bench>& bench, uint8_t* buffer) {
int64_t length;
uint8_t* encoded = bench->Encode(buffer, length);
for (auto _ : state) {
void* decoded = bench->Decode(encoded, length);
benchmark::DoNotOptimize(decoded);
}
}
static inline void Use(benchmark::State& state, std::unique_ptr<Bench>& bench,
uint8_t* buffer, int64_t check_sum) {
int64_t length;
uint8_t* encoded = bench->Encode(buffer, length);
void* decoded = bench->Decode(encoded, length);
int64_t sum = 0;
for (auto _ : state) {
sum = bench->Use(decoded);
}
EXPECT_EQ(sum, check_sum);
}
static void BM_Flatbuffers_Encode(benchmark::State& state) {
const int64_t kBufferLength = 1024;
uint8_t buffer[kBufferLength];
StaticAllocator allocator(&buffer[0]);
std::unique_ptr<Bench> bench = NewFlatBuffersBench(kBufferLength, &allocator);
Encode(state, bench, buffer);
}
BENCHMARK(BM_Flatbuffers_Encode);
static void BM_Flatbuffers_Decode(benchmark::State& state) {
const int64_t kBufferLength = 1024;
uint8_t buffer[kBufferLength];
StaticAllocator allocator(&buffer[0]);
std::unique_ptr<Bench> bench = NewFlatBuffersBench(kBufferLength, &allocator);
Decode(state, bench, buffer);
}
BENCHMARK(BM_Flatbuffers_Decode);
static void BM_Flatbuffers_Use(benchmark::State& state) {
const int64_t kBufferLength = 1024;
uint8_t buffer[kBufferLength];
StaticAllocator allocator(&buffer[0]);
std::unique_ptr<Bench> bench = NewFlatBuffersBench(kBufferLength, &allocator);
Use(state, bench, buffer, 218812692406581874);
}
BENCHMARK(BM_Flatbuffers_Use);
static void BM_Raw_Encode(benchmark::State& state) {
const int64_t kBufferLength = 1024;
uint8_t buffer[kBufferLength];
std::unique_ptr<Bench> bench = NewRawBench();
Encode(state, bench, buffer);
}
BENCHMARK(BM_Raw_Encode);
static void BM_Raw_Decode(benchmark::State& state) {
const int64_t kBufferLength = 1024;
uint8_t buffer[kBufferLength];
std::unique_ptr<Bench> bench = NewRawBench();
Decode(state, bench, buffer);
}
BENCHMARK(BM_Raw_Decode);
static void BM_Raw_Use(benchmark::State& state) {
const int64_t kBufferLength = 1024;
uint8_t buffer[kBufferLength];
std::unique_ptr<Bench> bench = NewRawBench();
Use(state, bench, buffer, 218812692406581874);
}
BENCHMARK(BM_Raw_Use);

View File

@@ -0,0 +1,52 @@
// Copyright 2021 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// trying to represent a typical mix of datatypes:
// 1 array of 3 elements, each element: 1 string, 3 nested objects, 9 scalars
// root element has the array, additional string and an enum
namespace benchmarks_flatbuffers;
enum Enum : short { Apples, Pears, Bananas}
struct Foo {
id:ulong;
count:short;
prefix:byte;
length:uint;
}
struct Bar {
parent:Foo;
time:int;
ratio:float;
size:ushort;
}
table FooBar {
sibling:Bar;
name:string;
rating:double;
postfix:ubyte;
}
table FooBarContainer {
list:[FooBar]; // 3 copies of the above
initialized:bool;
fruit:Enum;
location:string;
}
root_type FooBarContainer;

View File

@@ -0,0 +1,317 @@
// automatically generated by the FlatBuffers compiler, do not modify
#ifndef FLATBUFFERS_GENERATED_BENCH_BENCHMARKS_FLATBUFFERS_H_
#define FLATBUFFERS_GENERATED_BENCH_BENCHMARKS_FLATBUFFERS_H_
#include "flatbuffers/flatbuffers.h"
// Ensure the included flatbuffers.h is the same version as when this file was
// generated, otherwise it may not be compatible.
static_assert(FLATBUFFERS_VERSION_MAJOR == 24 &&
FLATBUFFERS_VERSION_MINOR == 12 &&
FLATBUFFERS_VERSION_REVISION == 23,
"Non-compatible flatbuffers version included");
namespace benchmarks_flatbuffers {
struct Foo;
struct Bar;
struct FooBar;
struct FooBarBuilder;
struct FooBarContainer;
struct FooBarContainerBuilder;
enum Enum : int16_t {
Enum_Apples = 0,
Enum_Pears = 1,
Enum_Bananas = 2,
Enum_MIN = Enum_Apples,
Enum_MAX = Enum_Bananas
};
inline const Enum (&EnumValuesEnum())[3] {
static const Enum values[] = {Enum_Apples, Enum_Pears, Enum_Bananas};
return values;
}
inline const char* const* EnumNamesEnum() {
static const char* const names[4] = {"Apples", "Pears", "Bananas", nullptr};
return names;
}
inline const char* EnumNameEnum(Enum e) {
if (flatbuffers::IsOutRange(e, Enum_Apples, Enum_Bananas)) return "";
const size_t index = static_cast<size_t>(e);
return EnumNamesEnum()[index];
}
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) Foo FLATBUFFERS_FINAL_CLASS {
private:
uint64_t id_;
int16_t count_;
int8_t prefix_;
int8_t padding0__;
uint32_t length_;
public:
Foo() : id_(0), count_(0), prefix_(0), padding0__(0), length_(0) {
(void)padding0__;
}
Foo(uint64_t _id, int16_t _count, int8_t _prefix, uint32_t _length)
: id_(flatbuffers::EndianScalar(_id)),
count_(flatbuffers::EndianScalar(_count)),
prefix_(flatbuffers::EndianScalar(_prefix)),
padding0__(0),
length_(flatbuffers::EndianScalar(_length)) {
(void)padding0__;
}
uint64_t id() const { return flatbuffers::EndianScalar(id_); }
int16_t count() const { return flatbuffers::EndianScalar(count_); }
int8_t prefix() const { return flatbuffers::EndianScalar(prefix_); }
uint32_t length() const { return flatbuffers::EndianScalar(length_); }
};
FLATBUFFERS_STRUCT_END(Foo, 16);
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) Bar FLATBUFFERS_FINAL_CLASS {
private:
benchmarks_flatbuffers::Foo parent_;
int32_t time_;
float ratio_;
uint16_t size_;
int16_t padding0__;
int32_t padding1__;
public:
Bar()
: parent_(), time_(0), ratio_(0), size_(0), padding0__(0), padding1__(0) {
(void)padding0__;
(void)padding1__;
}
Bar(const benchmarks_flatbuffers::Foo& _parent, int32_t _time, float _ratio,
uint16_t _size)
: parent_(_parent),
time_(flatbuffers::EndianScalar(_time)),
ratio_(flatbuffers::EndianScalar(_ratio)),
size_(flatbuffers::EndianScalar(_size)),
padding0__(0),
padding1__(0) {
(void)padding0__;
(void)padding1__;
}
const benchmarks_flatbuffers::Foo& parent() const { return parent_; }
int32_t time() const { return flatbuffers::EndianScalar(time_); }
float ratio() const { return flatbuffers::EndianScalar(ratio_); }
uint16_t size() const { return flatbuffers::EndianScalar(size_); }
};
FLATBUFFERS_STRUCT_END(Bar, 32);
struct FooBar FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
typedef FooBarBuilder Builder;
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_SIBLING = 4,
VT_NAME = 6,
VT_RATING = 8,
VT_POSTFIX = 10
};
const benchmarks_flatbuffers::Bar* sibling() const {
return GetStruct<const benchmarks_flatbuffers::Bar*>(VT_SIBLING);
}
const flatbuffers::String* name() const {
return GetPointer<const flatbuffers::String*>(VT_NAME);
}
double rating() const { return GetField<double>(VT_RATING, 0.0); }
uint8_t postfix() const { return GetField<uint8_t>(VT_POSTFIX, 0); }
bool Verify(flatbuffers::Verifier& verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<benchmarks_flatbuffers::Bar>(verifier, VT_SIBLING, 8) &&
VerifyOffset(verifier, VT_NAME) && verifier.VerifyString(name()) &&
VerifyField<double>(verifier, VT_RATING, 8) &&
VerifyField<uint8_t>(verifier, VT_POSTFIX, 1) && verifier.EndTable();
}
};
struct FooBarBuilder {
typedef FooBar Table;
flatbuffers::FlatBufferBuilder& fbb_;
flatbuffers::uoffset_t start_;
void add_sibling(const benchmarks_flatbuffers::Bar* sibling) {
fbb_.AddStruct(FooBar::VT_SIBLING, sibling);
}
void add_name(flatbuffers::Offset<flatbuffers::String> name) {
fbb_.AddOffset(FooBar::VT_NAME, name);
}
void add_rating(double rating) {
fbb_.AddElement<double>(FooBar::VT_RATING, rating, 0.0);
}
void add_postfix(uint8_t postfix) {
fbb_.AddElement<uint8_t>(FooBar::VT_POSTFIX, postfix, 0);
}
explicit FooBarBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) {
start_ = fbb_.StartTable();
}
flatbuffers::Offset<FooBar> Finish() {
const auto end = fbb_.EndTable(start_);
auto o = flatbuffers::Offset<FooBar>(end);
return o;
}
};
inline flatbuffers::Offset<FooBar> CreateFooBar(
flatbuffers::FlatBufferBuilder& _fbb,
const benchmarks_flatbuffers::Bar* sibling = nullptr,
flatbuffers::Offset<flatbuffers::String> name = 0, double rating = 0.0,
uint8_t postfix = 0) {
FooBarBuilder builder_(_fbb);
builder_.add_rating(rating);
builder_.add_name(name);
builder_.add_sibling(sibling);
builder_.add_postfix(postfix);
return builder_.Finish();
}
inline flatbuffers::Offset<FooBar> CreateFooBarDirect(
flatbuffers::FlatBufferBuilder& _fbb,
const benchmarks_flatbuffers::Bar* sibling = nullptr,
const char* name = nullptr, double rating = 0.0, uint8_t postfix = 0) {
auto name__ = name ? _fbb.CreateString(name) : 0;
return benchmarks_flatbuffers::CreateFooBar(_fbb, sibling, name__, rating,
postfix);
}
struct FooBarContainer FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
typedef FooBarContainerBuilder Builder;
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_LIST = 4,
VT_INITIALIZED = 6,
VT_FRUIT = 8,
VT_LOCATION = 10
};
const flatbuffers::Vector<
flatbuffers::Offset<benchmarks_flatbuffers::FooBar>>*
list() const {
return GetPointer<const flatbuffers::Vector<
flatbuffers::Offset<benchmarks_flatbuffers::FooBar>>*>(VT_LIST);
}
bool initialized() const { return GetField<uint8_t>(VT_INITIALIZED, 0) != 0; }
benchmarks_flatbuffers::Enum fruit() const {
return static_cast<benchmarks_flatbuffers::Enum>(
GetField<int16_t>(VT_FRUIT, 0));
}
const flatbuffers::String* location() const {
return GetPointer<const flatbuffers::String*>(VT_LOCATION);
}
bool Verify(flatbuffers::Verifier& verifier) const {
return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_LIST) &&
verifier.VerifyVector(list()) &&
verifier.VerifyVectorOfTables(list()) &&
VerifyField<uint8_t>(verifier, VT_INITIALIZED, 1) &&
VerifyField<int16_t>(verifier, VT_FRUIT, 2) &&
VerifyOffset(verifier, VT_LOCATION) &&
verifier.VerifyString(location()) && verifier.EndTable();
}
};
struct FooBarContainerBuilder {
typedef FooBarContainer Table;
flatbuffers::FlatBufferBuilder& fbb_;
flatbuffers::uoffset_t start_;
void add_list(flatbuffers::Offset<flatbuffers::Vector<
flatbuffers::Offset<benchmarks_flatbuffers::FooBar>>>
list) {
fbb_.AddOffset(FooBarContainer::VT_LIST, list);
}
void add_initialized(bool initialized) {
fbb_.AddElement<uint8_t>(FooBarContainer::VT_INITIALIZED,
static_cast<uint8_t>(initialized), 0);
}
void add_fruit(benchmarks_flatbuffers::Enum fruit) {
fbb_.AddElement<int16_t>(FooBarContainer::VT_FRUIT,
static_cast<int16_t>(fruit), 0);
}
void add_location(flatbuffers::Offset<flatbuffers::String> location) {
fbb_.AddOffset(FooBarContainer::VT_LOCATION, location);
}
explicit FooBarContainerBuilder(flatbuffers::FlatBufferBuilder& _fbb)
: fbb_(_fbb) {
start_ = fbb_.StartTable();
}
flatbuffers::Offset<FooBarContainer> Finish() {
const auto end = fbb_.EndTable(start_);
auto o = flatbuffers::Offset<FooBarContainer>(end);
return o;
}
};
inline flatbuffers::Offset<FooBarContainer> CreateFooBarContainer(
flatbuffers::FlatBufferBuilder& _fbb,
flatbuffers::Offset<flatbuffers::Vector<
flatbuffers::Offset<benchmarks_flatbuffers::FooBar>>>
list = 0,
bool initialized = false,
benchmarks_flatbuffers::Enum fruit = benchmarks_flatbuffers::Enum_Apples,
flatbuffers::Offset<flatbuffers::String> location = 0) {
FooBarContainerBuilder builder_(_fbb);
builder_.add_location(location);
builder_.add_list(list);
builder_.add_fruit(fruit);
builder_.add_initialized(initialized);
return builder_.Finish();
}
inline flatbuffers::Offset<FooBarContainer> CreateFooBarContainerDirect(
flatbuffers::FlatBufferBuilder& _fbb,
const std::vector<flatbuffers::Offset<benchmarks_flatbuffers::FooBar>>*
list = nullptr,
bool initialized = false,
benchmarks_flatbuffers::Enum fruit = benchmarks_flatbuffers::Enum_Apples,
const char* location = nullptr) {
auto list__ =
list ? _fbb.CreateVector<
flatbuffers::Offset<benchmarks_flatbuffers::FooBar>>(*list)
: 0;
auto location__ = location ? _fbb.CreateString(location) : 0;
return benchmarks_flatbuffers::CreateFooBarContainer(
_fbb, list__, initialized, fruit, location__);
}
inline const benchmarks_flatbuffers::FooBarContainer* GetFooBarContainer(
const void* buf) {
return flatbuffers::GetRoot<benchmarks_flatbuffers::FooBarContainer>(buf);
}
inline const benchmarks_flatbuffers::FooBarContainer*
GetSizePrefixedFooBarContainer(const void* buf) {
return flatbuffers::GetSizePrefixedRoot<
benchmarks_flatbuffers::FooBarContainer>(buf);
}
inline bool VerifyFooBarContainerBuffer(flatbuffers::Verifier& verifier) {
return verifier.VerifyBuffer<benchmarks_flatbuffers::FooBarContainer>(
nullptr);
}
inline bool VerifySizePrefixedFooBarContainerBuffer(
flatbuffers::Verifier& verifier) {
return verifier
.VerifySizePrefixedBuffer<benchmarks_flatbuffers::FooBarContainer>(
nullptr);
}
inline void FinishFooBarContainerBuffer(
flatbuffers::FlatBufferBuilder& fbb,
flatbuffers::Offset<benchmarks_flatbuffers::FooBarContainer> root) {
fbb.Finish(root);
}
inline void FinishSizePrefixedFooBarContainerBuffer(
flatbuffers::FlatBufferBuilder& fbb,
flatbuffers::Offset<benchmarks_flatbuffers::FooBarContainer> root) {
fbb.FinishSizePrefixed(root);
}
} // namespace benchmarks_flatbuffers
#endif // FLATBUFFERS_GENERATED_BENCH_BENCHMARKS_FLATBUFFERS_H_

View File

@@ -0,0 +1,80 @@
#include "benchmarks/cpp/flatbuffers/fb_bench.h"
#include <cstdint>
#include <memory>
#include "benchmarks/cpp/bench.h"
#include "benchmarks/cpp/flatbuffers/bench_generated.h"
#include "flatbuffers/flatbuffers.h"
using namespace flatbuffers;
using namespace benchmarks_flatbuffers;
namespace {
struct FlatBufferBench : Bench {
explicit FlatBufferBench(int64_t initial_size, Allocator* allocator)
: fbb(initial_size, allocator, false) {}
uint8_t* Encode(void*, int64_t& len) override {
fbb.Clear();
const int kVectorLength = 3;
Offset<FooBar> vec[kVectorLength];
for (int i = 0; i < kVectorLength; ++i) {
Foo foo(0xABADCAFEABADCAFE + i, 10000 + i, '@' + i, 1000000 + i);
Bar bar(foo, 123456 + i, 3.14159f + i, 10000 + i);
auto name = fbb.CreateString("Hello, World!");
auto foobar =
CreateFooBar(fbb, &bar, name, 3.1415432432445543543 + i, '!' + i);
vec[i] = foobar;
}
auto location = fbb.CreateString("http://google.com/flatbuffers/");
auto foobarvec = fbb.CreateVector(vec, kVectorLength);
auto foobarcontainer =
CreateFooBarContainer(fbb, foobarvec, true, Enum_Bananas, location);
fbb.Finish(foobarcontainer);
len = fbb.GetSize();
return fbb.GetBufferPointer();
}
int64_t Use(void* decoded) override {
sum = 0;
auto foobarcontainer = GetFooBarContainer(decoded);
sum = 0;
Add(foobarcontainer->initialized());
Add(foobarcontainer->location()->Length());
Add(foobarcontainer->fruit());
for (unsigned int i = 0; i < foobarcontainer->list()->Length(); i++) {
auto foobar = foobarcontainer->list()->Get(i);
Add(foobar->name()->Length());
Add(foobar->postfix());
Add(static_cast<int64_t>(foobar->rating()));
auto bar = foobar->sibling();
Add(static_cast<int64_t>(bar->ratio()));
Add(bar->size());
Add(bar->time());
auto& foo = bar->parent();
Add(foo.count());
Add(foo.id());
Add(foo.length());
Add(foo.prefix());
}
return sum;
}
void* Decode(void* buffer, int64_t) override { return buffer; }
void Dealloc(void*) override {};
FlatBufferBuilder fbb;
};
} // namespace
std::unique_ptr<Bench> NewFlatBuffersBench(int64_t initial_size,
Allocator* allocator) {
return std::unique_ptr<FlatBufferBench>(
new FlatBufferBench(initial_size, allocator));
}

View File

@@ -0,0 +1,23 @@
#ifndef BENCHMARKS_CPP_FLATBUFFERS_FB_BENCH_H_
#define BENCHMARKS_CPP_FLATBUFFERS_FB_BENCH_H_
#include <cstdint>
#include <memory>
#include "benchmarks/cpp/bench.h"
#include "include/flatbuffers/flatbuffers.h"
struct StaticAllocator : public flatbuffers::Allocator {
explicit StaticAllocator(uint8_t* buffer) : buffer_(buffer) {}
uint8_t* allocate(size_t) override { return buffer_; }
void deallocate(uint8_t*, size_t) override {}
uint8_t* buffer_;
};
std::unique_ptr<Bench> NewFlatBuffersBench(
int64_t initial_size = 1024, flatbuffers::Allocator* allocator = nullptr);
#endif // BENCHMARKS_CPP_FLATBUFFERS_FB_BENCH_H_

View File

@@ -0,0 +1,109 @@
#include "benchmarks/cpp/raw/raw_bench.h"
#include <cstdint>
#include <cstring>
#include <memory>
#include "benchmarks/cpp/bench.h"
namespace {
const int64_t kStringLength = 32;
const int64_t kVectorLength = 3;
enum Enum { Apples, Pears, Bananas };
struct Foo {
int64_t id;
short count;
char prefix;
int length;
};
struct Bar {
Foo parent;
int time;
float ratio;
unsigned short size;
};
struct FooBar {
Bar sibling;
// We have to stick this in, otherwise strlen() will make it slower than
// FlatBuffers:
int name_len;
char name[kStringLength];
double rating;
unsigned char postfix;
};
struct FooBarContainer {
FooBar list[kVectorLength]; // 3 copies of the above
bool initialized;
Enum fruit;
int location_len;
char location[kStringLength];
};
struct RawBench : Bench {
uint8_t* Encode(void* buf, int64_t& len) override {
FooBarContainer* fbc = new (buf) FooBarContainer;
strcpy(fbc->location, "http://google.com/flatbuffers/"); // Unsafe eek!
fbc->location_len = (int)strlen(fbc->location);
fbc->fruit = Bananas;
fbc->initialized = true;
for (int i = 0; i < kVectorLength; i++) {
// We add + i to not make these identical copies for a more realistic
// compression test.
auto& foobar = fbc->list[i];
foobar.rating = 3.1415432432445543543 + i;
foobar.postfix = '!' + i;
strcpy(foobar.name, "Hello, World!");
foobar.name_len = (int)strlen(foobar.name);
auto& bar = foobar.sibling;
bar.ratio = 3.14159f + i;
bar.size = 10000 + i;
bar.time = 123456 + i;
auto& foo = bar.parent;
foo.id = 0xABADCAFEABADCAFE + i;
foo.count = 10000 + i;
foo.length = 1000000 + i;
foo.prefix = '@' + i;
}
len = sizeof(FooBarContainer);
return reinterpret_cast<uint8_t*>(fbc);
};
int64_t Use(void* decoded) override {
auto foobarcontainer = reinterpret_cast<FooBarContainer*>(decoded);
sum = 0;
Add(foobarcontainer->initialized);
Add(foobarcontainer->location_len);
Add(foobarcontainer->fruit);
for (unsigned int i = 0; i < kVectorLength; i++) {
auto foobar = &foobarcontainer->list[i];
Add(foobar->name_len);
Add(foobar->postfix);
Add(static_cast<int64_t>(foobar->rating));
auto bar = &foobar->sibling;
Add(static_cast<int64_t>(bar->ratio));
Add(bar->size);
Add(bar->time);
auto& foo = bar->parent;
Add(foo.count);
Add(foo.id);
Add(foo.length);
Add(foo.prefix);
}
return sum;
}
void* Decode(void* buf, int64_t) override { return buf; }
void Dealloc(void*) override {};
};
} // namespace
std::unique_ptr<Bench> NewRawBench() {
return std::unique_ptr<RawBench>(new RawBench());
}

View File

@@ -0,0 +1,10 @@
#ifndef BENCHMARKS_CPP_RAW_RAW_BENCH_H_
#define BENCHMARKS_CPP_RAW_RAW_BENCH_H_
#include <memory>
#include "benchmarks/cpp/bench.h"
std::unique_ptr<Bench> NewRawBench();
#endif // BENCHMARKS_CPP_RAW_RAW_BENCH_H_

View File

@@ -0,0 +1,250 @@
/*
* Copyright 2024 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Benchmark
import FlatBuffers
import Foundation
@usableFromInline
struct AA: NativeStruct {
public init(a: Double, b: Double) {
self.a = a
self.b = b
}
var a: Double
var b: Double
}
let benchmarks = {
let oneGB: Int32 = 1_024_000_000
let data = {
var array = [8888.88, 8888.88]
var data = Data()
array.withUnsafeBytes { ptr in
data.append(contentsOf: ptr)
}
return data
}()
let ints: [Int] = Array(repeating: 42, count: 100)
let bytes: [UInt8] = Array(repeating: 42, count: 100)
let str10 = (0...9).map { _ -> String in "x" }.joined()
let str100 = (0...99).map { _ -> String in "x" }.joined()
let array: [AA] = [
AA(a: 2.4, b: 2.4),
AA(a: 2.4, b: 2.4),
AA(a: 2.4, b: 2.4),
AA(a: 2.4, b: 2.4),
AA(a: 2.4, b: 2.4),
]
let metrics: [BenchmarkMetric] = [
.cpuTotal,
.wallClock,
.mallocCountTotal,
.releaseCount,
.peakMemoryResident,
]
let maxIterations = 1_000_000
let maxDuration: Duration = .seconds(3)
let singleConfiguration: Benchmark.Configuration = .init(
metrics: metrics,
warmupIterations: 1,
scalingFactor: .one,
maxDuration: maxDuration,
maxIterations: maxIterations)
let kiloConfiguration: Benchmark.Configuration = .init(
metrics: metrics,
warmupIterations: 1,
scalingFactor: .kilo,
maxDuration: maxDuration,
maxIterations: maxIterations)
let megaConfiguration: Benchmark.Configuration = .init(
metrics: metrics,
warmupIterations: 1,
scalingFactor: .mega,
maxDuration: maxDuration,
maxIterations: maxIterations)
Benchmark.defaultConfiguration = megaConfiguration
Benchmark("Allocating 1GB", configuration: singleConfiguration) { benchmark in
for _ in benchmark.scaledIterations {
blackHole(FlatBufferBuilder(initialSize: oneGB))
}
}
Benchmark(
"Allocating ByteBuffer 1GB",
configuration: singleConfiguration)
{ benchmark in
let memory = UnsafeMutableRawPointer.allocate(
byteCount: 1_024_000_000,
alignment: 1)
benchmark.startMeasurement()
for _ in benchmark.scaledIterations {
blackHole(ByteBuffer(assumingMemoryBound: memory, capacity: Int(oneGB)))
}
}
Benchmark("Clearing 1GB", configuration: singleConfiguration) { benchmark in
var fb = FlatBufferBuilder(initialSize: oneGB)
benchmark.startMeasurement()
for _ in benchmark.scaledIterations {
blackHole(fb.clear())
}
}
Benchmark("Strings 10") { benchmark in
var fb = FlatBufferBuilder(initialSize: 1 << 20)
benchmark.startMeasurement()
for _ in benchmark.scaledIterations {
blackHole(fb.create(string: str10))
}
}
Benchmark("Strings 100") { benchmark in
var fb = FlatBufferBuilder(initialSize: 1 << 20)
benchmark.startMeasurement()
for _ in benchmark.scaledIterations {
blackHole(fb.create(string: str100))
}
}
Benchmark("Vector 1 Bytes") { benchmark in
var fb = FlatBufferBuilder(initialSize: 1 << 20)
benchmark.startMeasurement()
for _ in benchmark.scaledIterations {
blackHole(fb.createVector(bytes: bytes))
}
}
Benchmark("Vector 1 Ints") { benchmark in
var fb = FlatBufferBuilder(initialSize: 1 << 20)
benchmark.startMeasurement()
for _ in benchmark.scaledIterations {
blackHole(fb.createVector(ints))
}
}
Benchmark("Vector 100 Ints") { benchmark in
var fb = FlatBufferBuilder(initialSize: 1 << 20)
benchmark.startMeasurement()
for i in benchmark.scaledIterations {
blackHole(fb.createVector(ints))
}
}
Benchmark("Vector 100 Bytes") { benchmark in
var fb = FlatBufferBuilder(initialSize: 1 << 20)
benchmark.startMeasurement()
for i in benchmark.scaledIterations {
blackHole(fb.createVector(bytes))
}
}
Benchmark("Vector 100 ContiguousBytes") { benchmark in
var fb = FlatBufferBuilder(initialSize: 1 << 20)
benchmark.startMeasurement()
for i in benchmark.scaledIterations {
blackHole(fb.createVector(bytes: bytes))
}
}
Benchmark(
"FlatBufferBuilder Add",
configuration: kiloConfiguration)
{ benchmark in
var fb = FlatBufferBuilder(initialSize: 1024 * 1024 * 32)
benchmark.startMeasurement()
for _ in benchmark.scaledIterations {
let off = fb.create(string: "T")
let s = fb.startTable(with: 4)
fb.add(element: 3.2, def: 0, at: 2)
fb.add(element: 4.2, def: 0, at: 4)
fb.add(element: 5.2, def: 0, at: 6)
fb.add(offset: off, at: 8)
blackHole(fb.endTable(at: s))
}
}
Benchmark(
"FlatBufferBuilder Start table",
configuration: kiloConfiguration)
{ benchmark in
var fb = FlatBufferBuilder(initialSize: 1024 * 1024 * 32)
benchmark.startMeasurement()
for _ in benchmark.scaledIterations {
let s = fb.startTable(with: 4)
blackHole(fb.endTable(at: s))
}
}
Benchmark("Struct") { benchmark in
var fb = FlatBufferBuilder(initialSize: 1024 * 1024 * 32)
benchmark.startMeasurement()
for _ in benchmark.scaledIterations {
blackHole(fb.create(struct: array.first!))
}
}
Benchmark("Structs") { benchmark in
let rawSize = ((16 * 5) * benchmark.scaledIterations.count) / 1024
var fb = FlatBufferBuilder(initialSize: Int32(rawSize * 1600))
var offsets: [Offset] = []
benchmark.startMeasurement()
for _ in benchmark.scaledIterations {
let vector = fb.createVector(
ofStructs: array)
let start = fb.startTable(with: 1)
fb.add(offset: vector, at: 4)
offsets.append(Offset(offset: fb.endTable(at: start)))
}
let vector = fb.createVector(ofOffsets: offsets)
let start = fb.startTable(with: 1)
fb.add(offset: vector, at: 4)
let root = Offset(offset: fb.endTable(at: start))
blackHole(fb.finish(offset: root))
}
Benchmark("Vector of Offsets") { benchmark in
let rawSize = ((16 * 5) * benchmark.scaledIterations.count) / 1024
var fb = FlatBufferBuilder(initialSize: Int32(rawSize * 1600))
benchmark.startMeasurement()
for _ in benchmark.scaledIterations {
let offsets = [
fb.create(string: "T"),
fb.create(string: "2"),
fb.create(string: "3"),
]
let off = fb.createVector(ofOffsets: [
fb.createVector(ofOffsets: offsets),
fb.createVector(ofOffsets: offsets),
])
let s = fb.startTable(with: 2)
fb.add(offset: off, at: 2)
blackHole(fb.endTable(at: s))
}
}
Benchmark("Reading Doubles") { benchmark in
let byteBuffer = ByteBuffer(data: data)
for _ in benchmark.scaledIterations {
blackHole(byteBuffer.read(def: Double.self, position: 0))
}
}
}

View File

@@ -0,0 +1,42 @@
// swift-tools-version:5.10
/*
* Copyright 2020 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import PackageDescription
let package = Package(
name: "benchmarks",
platforms: [
.macOS(.v13),
],
dependencies: [
.package(path: "../.."),
.package(
url: "https://github.com/ordo-one/package-benchmark",
from: "1.27.0"),
],
targets: [
.executableTarget(
name: "FlatbuffersBenchmarks",
dependencies: [
.product(name: "FlatBuffers", package: "flatbuffers"),
.product(name: "Benchmark", package: "package-benchmark"),
],
path: "Benchmarks/FlatbuffersBenchmarks",
plugins: [
.plugin(name: "BenchmarkPlugin", package: "package-benchmark"),
]),
])

View File

@@ -0,0 +1,9 @@
# Benchmarks
To open the benchmarks in xcode use:
`open --env BENCHMARK_DISABLE_JEMALLOC=true Package.swift`
or running them directly within terminal using:
`swift package benchmark`

View File

@@ -1,5 +0,0 @@
# Biicode configuration file
[paths]
# Local directories to look for headers (within block)
include

View File

@@ -1,55 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "flatc", "flatc.vcxproj", "{5B5857E1-64E2-4CED-A12E-45E1B3880496}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "flatsamplebinary", "flatsamplebinary.vcxproj", "{16FA5518-3DE1-4B15-A1E0-F4734C276FB4}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "flatsampletext", "flatsampletext.vcxproj", "{F0A15675-1017-4217-BB5B-3372F2C636AB}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "flattests", "flattests.vcxproj", "{DC7BBA00-9FC6-48AF-B7E9-12CA91AC02AA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5B5857E1-64E2-4CED-A12E-45E1B3880496}.Debug|Win32.ActiveCfg = Debug|Win32
{5B5857E1-64E2-4CED-A12E-45E1B3880496}.Debug|Win32.Build.0 = Debug|Win32
{5B5857E1-64E2-4CED-A12E-45E1B3880496}.Debug|x64.ActiveCfg = Debug|x64
{5B5857E1-64E2-4CED-A12E-45E1B3880496}.Debug|x64.Build.0 = Debug|x64
{5B5857E1-64E2-4CED-A12E-45E1B3880496}.Release|Win32.ActiveCfg = Release|Win32
{5B5857E1-64E2-4CED-A12E-45E1B3880496}.Release|Win32.Build.0 = Release|Win32
{5B5857E1-64E2-4CED-A12E-45E1B3880496}.Release|x64.ActiveCfg = Release|x64
{5B5857E1-64E2-4CED-A12E-45E1B3880496}.Release|x64.Build.0 = Release|x64
{16FA5518-3DE1-4B15-A1E0-F4734C276FB4}.Debug|Win32.ActiveCfg = Debug|Win32
{16FA5518-3DE1-4B15-A1E0-F4734C276FB4}.Debug|Win32.Build.0 = Debug|Win32
{16FA5518-3DE1-4B15-A1E0-F4734C276FB4}.Debug|x64.ActiveCfg = Debug|x64
{16FA5518-3DE1-4B15-A1E0-F4734C276FB4}.Debug|x64.Build.0 = Debug|x64
{16FA5518-3DE1-4B15-A1E0-F4734C276FB4}.Release|Win32.ActiveCfg = Release|Win32
{16FA5518-3DE1-4B15-A1E0-F4734C276FB4}.Release|Win32.Build.0 = Release|Win32
{16FA5518-3DE1-4B15-A1E0-F4734C276FB4}.Release|x64.ActiveCfg = Release|x64
{16FA5518-3DE1-4B15-A1E0-F4734C276FB4}.Release|x64.Build.0 = Release|x64
{F0A15675-1017-4217-BB5B-3372F2C636AB}.Debug|Win32.ActiveCfg = Debug|Win32
{F0A15675-1017-4217-BB5B-3372F2C636AB}.Debug|Win32.Build.0 = Debug|Win32
{F0A15675-1017-4217-BB5B-3372F2C636AB}.Debug|x64.ActiveCfg = Debug|x64
{F0A15675-1017-4217-BB5B-3372F2C636AB}.Debug|x64.Build.0 = Debug|x64
{F0A15675-1017-4217-BB5B-3372F2C636AB}.Release|Win32.ActiveCfg = Release|Win32
{F0A15675-1017-4217-BB5B-3372F2C636AB}.Release|Win32.Build.0 = Release|Win32
{F0A15675-1017-4217-BB5B-3372F2C636AB}.Release|x64.ActiveCfg = Release|x64
{F0A15675-1017-4217-BB5B-3372F2C636AB}.Release|x64.Build.0 = Release|x64
{DC7BBA00-9FC6-48AF-B7E9-12CA91AC02AA}.Debug|Win32.ActiveCfg = Debug|Win32
{DC7BBA00-9FC6-48AF-B7E9-12CA91AC02AA}.Debug|Win32.Build.0 = Debug|Win32
{DC7BBA00-9FC6-48AF-B7E9-12CA91AC02AA}.Debug|x64.ActiveCfg = Debug|x64
{DC7BBA00-9FC6-48AF-B7E9-12CA91AC02AA}.Debug|x64.Build.0 = Debug|x64
{DC7BBA00-9FC6-48AF-B7E9-12CA91AC02AA}.Release|Win32.ActiveCfg = Release|Win32
{DC7BBA00-9FC6-48AF-B7E9-12CA91AC02AA}.Release|Win32.Build.0 = Release|Win32
{DC7BBA00-9FC6-48AF-B7E9-12CA91AC02AA}.Release|x64.ActiveCfg = Release|x64
{DC7BBA00-9FC6-48AF-B7E9-12CA91AC02AA}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -1,282 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGUID>{5B5857E1-64E2-4CED-A12E-45E1B3880496}</ProjectGUID>
<Keyword>Win32Proj</Keyword>
<Platform>Win32</Platform>
<ProjectName>flatc</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.20506.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)</OutDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(IntDir)</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">flatc.dir\Debug\</IntDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">flatc.dir\Debug\</IntDir>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">flatc</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">flatc</TargetName>
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.exe</TargetExt>
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.exe</TargetExt>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</GenerateManifest>
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</GenerateManifest>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)</OutDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(IntDir)</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">flatc.dir\Release\</IntDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">flatc.dir\Release\</IntDir>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">flatc</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">flatc</TargetName>
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.exe</TargetExt>
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.exe</TargetExt>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</GenerateManifest>
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</GenerateManifest>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<CompileAs>CompileAsCpp</CompileAs>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ExceptionHandling>Sync</ExceptionHandling>
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
<Optimization>Disabled</Optimization>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;CMAKE_INTDIR="Debug";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AssemblerListingLocation>Debug</AssemblerListingLocation>
<ObjectFileName>$(IntDir)</ObjectFileName>
<ProgramDataBaseFileName>../../Debug/flatc.pdb</ProgramDataBaseFileName>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;CMAKE_INTDIR=\"Debug\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<Midl>
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<OutputDirectory>$(IntDir)</OutputDirectory>
<HeaderFileName>%(Filename).h</HeaderFileName>
<TypeLibraryName>%(Filename).tlb</TypeLibraryName>
<InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
</Midl>
<Link>
<AdditionalOptions> /machine:X86 /debug %(AdditionalOptions)</AdditionalOptions>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ImportLibrary>../../Debug/flatc.lib</ImportLibrary>
<ProgramDataBaseFile>../../Debug/flatc.pdb</ProgramDataBaseFile>
<SubSystem>Console</SubSystem>
<Version>
</Version>
</Link>
<ProjectReference>
<LinkLibraryDependencies>false</LinkLibraryDependencies>
</ProjectReference>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<CompileAs>CompileAsCpp</CompileAs>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ExceptionHandling>Sync</ExceptionHandling>
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
<Optimization>Disabled</Optimization>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;CMAKE_INTDIR="Debug";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AssemblerListingLocation>Debug</AssemblerListingLocation>
<ObjectFileName>$(IntDir)</ObjectFileName>
<ProgramDataBaseFileName>../../Debug/flatc.pdb</ProgramDataBaseFileName>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;CMAKE_INTDIR=\"Debug\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<Midl>
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<OutputDirectory>$(IntDir)</OutputDirectory>
<HeaderFileName>%(Filename).h</HeaderFileName>
<TypeLibraryName>%(Filename).tlb</TypeLibraryName>
<InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
</Midl>
<Link>
<AdditionalOptions>/debug %(AdditionalOptions)</AdditionalOptions>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ImportLibrary>../../Debug/flatc.lib</ImportLibrary>
<ProgramDataBaseFile>../../Debug/flatc.pdb</ProgramDataBaseFile>
<SubSystem>Console</SubSystem>
<Version>
</Version>
</Link>
<ProjectReference>
<LinkLibraryDependencies>false</LinkLibraryDependencies>
</ProjectReference>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<CompileAs>CompileAsCpp</CompileAs>
<ExceptionHandling>Sync</ExceptionHandling>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<Optimization>MaxSpeed</Optimization>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>
</DebugInformationFormat>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="Release";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AssemblerListingLocation>Release</AssemblerListingLocation>
<ObjectFileName>$(IntDir)</ObjectFileName>
<ProgramDataBaseFileName>../../Release/flatc.pdb</ProgramDataBaseFileName>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"Release\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<Midl>
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<OutputDirectory>$(IntDir)</OutputDirectory>
<HeaderFileName>%(Filename).h</HeaderFileName>
<TypeLibraryName>%(Filename).tlb</TypeLibraryName>
<InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
</Midl>
<Link>
<AdditionalOptions> /machine:X86 %(AdditionalOptions)</AdditionalOptions>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<ImportLibrary>../../Release/flatc.lib</ImportLibrary>
<ProgramDataBaseFile>../../Release/flatc.pdb</ProgramDataBaseFile>
<SubSystem>Console</SubSystem>
<Version>
</Version>
</Link>
<ProjectReference>
<LinkLibraryDependencies>false</LinkLibraryDependencies>
</ProjectReference>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<CompileAs>CompileAsCpp</CompileAs>
<ExceptionHandling>Sync</ExceptionHandling>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<Optimization>MaxSpeed</Optimization>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>
</DebugInformationFormat>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="Release";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AssemblerListingLocation>Release</AssemblerListingLocation>
<ObjectFileName>$(IntDir)</ObjectFileName>
<ProgramDataBaseFileName>../../Release/flatc.pdb</ProgramDataBaseFileName>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"Release\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<Midl>
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<OutputDirectory>$(IntDir)</OutputDirectory>
<HeaderFileName>%(Filename).h</HeaderFileName>
<TypeLibraryName>%(Filename).tlb</TypeLibraryName>
<InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
</Midl>
<Link>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<ImportLibrary>../../Release/flatc.lib</ImportLibrary>
<ProgramDataBaseFile>../../Release/flatc.pdb</ProgramDataBaseFile>
<SubSystem>Console</SubSystem>
<Version>
</Version>
</Link>
<ProjectReference>
<LinkLibraryDependencies>false</LinkLibraryDependencies>
</ProjectReference>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\include\flatbuffers\flatbuffers.h" />
<ClInclude Include="..\..\include\flatbuffers\idl.h" />
<ClInclude Include="..\..\include\flatbuffers\util.h" />
<ClCompile Include="..\..\src\idl_gen_fbs.cpp" />
<ClCompile Include="..\..\src\idl_gen_general.cpp" />
<ClCompile Include="..\..\src\idl_gen_go.cpp">
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Level4</WarningLevel>
</ClCompile>
<ClCompile Include="..\..\src\idl_parser.cpp" />
<ClCompile Include="..\..\src\idl_gen_cpp.cpp" />
<ClCompile Include="..\..\src\idl_gen_text.cpp" />
<ClCompile Include="..\..\src\flatc.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

Some files were not shown because too many files have changed in this diff Show More