* 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.
* 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.
* 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
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.
* 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".
* 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>