Commit Graph

1931 Commits

Author SHA1 Message Date
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