Commit Graph

2411 Commits

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