- 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
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
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
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
* 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.
They were overloaded, but also had default arguments, so would
become ambiguous when used with few arguments.
Change-Id: Ifac7f3ea3a6391d971dfeda8e33129c8c38d6f12
Tested: on Linux.
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
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
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.
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.
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.
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)
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
(Java doesn't support unsigned types).
ubyte/ushort return as int
uint returns as long
(all with correct masking)
ulong still returns as long, as before.
Tested: on Linux & Windows.
Bug 17521464
Change-Id: Id6bc8f38fc8c1a2f4e6733c6980dc6b6e322b452
FlatBuffer schema files can now optionally specify a hash attribute that
will allow someone writing json files to enter a string to be hashed
rather than a specific value. The hashing algorithm to use is specified
by the schema.
Currently the only algorithms are fnv1 and fnv1a. There are 32 bit and
64 variatns for each. Additionally, a hashing command line tool was
added so that you can see what a string will hash to without needing to
inspect the flatbuffer binary blob.
Change-Id: I0cb359d0e2dc7d2dc1874b446dc19a17cc77109d