mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 04:04:19 +00:00
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
This commit is contained in:
@@ -90,6 +90,88 @@ class _AnyTypeIdReader extends fb.Reader<AnyTypeId> {
|
||||
new AnyTypeId.fromValue(const fb.Uint8Reader().read(bc, offset));
|
||||
}
|
||||
|
||||
class AnyUniqueAliasesTypeId {
|
||||
final int value;
|
||||
const AnyUniqueAliasesTypeId._(this.value);
|
||||
|
||||
factory AnyUniqueAliasesTypeId.fromValue(int value) {
|
||||
if (value == null) value = 0;
|
||||
if (!values.containsKey(value)) {
|
||||
throw new StateError('Invalid value $value for bit flag enum AnyUniqueAliasesTypeId');
|
||||
}
|
||||
return values[value];
|
||||
}
|
||||
|
||||
static const int minValue = 0;
|
||||
static const int maxValue = 3;
|
||||
static bool containsValue(int value) => values.containsKey(value);
|
||||
|
||||
static const AnyUniqueAliasesTypeId NONE = const AnyUniqueAliasesTypeId._(0);
|
||||
static const AnyUniqueAliasesTypeId M = const AnyUniqueAliasesTypeId._(1);
|
||||
static const AnyUniqueAliasesTypeId T = const AnyUniqueAliasesTypeId._(2);
|
||||
static const AnyUniqueAliasesTypeId M2 = const AnyUniqueAliasesTypeId._(3);
|
||||
static get values => {0: NONE,1: M,2: T,3: M2,};
|
||||
|
||||
static const fb.Reader<AnyUniqueAliasesTypeId> reader = const _AnyUniqueAliasesTypeIdReader();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AnyUniqueAliasesTypeId{value: $value}';
|
||||
}
|
||||
}
|
||||
|
||||
class _AnyUniqueAliasesTypeIdReader extends fb.Reader<AnyUniqueAliasesTypeId> {
|
||||
const _AnyUniqueAliasesTypeIdReader();
|
||||
|
||||
@override
|
||||
int get size => 1;
|
||||
|
||||
@override
|
||||
AnyUniqueAliasesTypeId read(fb.BufferContext bc, int offset) =>
|
||||
new AnyUniqueAliasesTypeId.fromValue(const fb.Uint8Reader().read(bc, offset));
|
||||
}
|
||||
|
||||
class AnyAmbiguousAliasesTypeId {
|
||||
final int value;
|
||||
const AnyAmbiguousAliasesTypeId._(this.value);
|
||||
|
||||
factory AnyAmbiguousAliasesTypeId.fromValue(int value) {
|
||||
if (value == null) value = 0;
|
||||
if (!values.containsKey(value)) {
|
||||
throw new StateError('Invalid value $value for bit flag enum AnyAmbiguousAliasesTypeId');
|
||||
}
|
||||
return values[value];
|
||||
}
|
||||
|
||||
static const int minValue = 0;
|
||||
static const int maxValue = 3;
|
||||
static bool containsValue(int value) => values.containsKey(value);
|
||||
|
||||
static const AnyAmbiguousAliasesTypeId NONE = const AnyAmbiguousAliasesTypeId._(0);
|
||||
static const AnyAmbiguousAliasesTypeId M1 = const AnyAmbiguousAliasesTypeId._(1);
|
||||
static const AnyAmbiguousAliasesTypeId M2 = const AnyAmbiguousAliasesTypeId._(2);
|
||||
static const AnyAmbiguousAliasesTypeId M3 = const AnyAmbiguousAliasesTypeId._(3);
|
||||
static get values => {0: NONE,1: M1,2: M2,3: M3,};
|
||||
|
||||
static const fb.Reader<AnyAmbiguousAliasesTypeId> reader = const _AnyAmbiguousAliasesTypeIdReader();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AnyAmbiguousAliasesTypeId{value: $value}';
|
||||
}
|
||||
}
|
||||
|
||||
class _AnyAmbiguousAliasesTypeIdReader extends fb.Reader<AnyAmbiguousAliasesTypeId> {
|
||||
const _AnyAmbiguousAliasesTypeIdReader();
|
||||
|
||||
@override
|
||||
int get size => 1;
|
||||
|
||||
@override
|
||||
AnyAmbiguousAliasesTypeId read(fb.BufferContext bc, int offset) =>
|
||||
new AnyAmbiguousAliasesTypeId.fromValue(const fb.Uint8Reader().read(bc, offset));
|
||||
}
|
||||
|
||||
class Test {
|
||||
Test._(this._bc, this._bcOffset);
|
||||
|
||||
@@ -654,10 +736,29 @@ class Monster {
|
||||
List<int> get vectorOfCoOwningReferences => const fb.ListReader<int>(const fb.Uint64Reader()).vTableGet(_bc, _bcOffset, 84, null);
|
||||
int get nonOwningReference => const fb.Uint64Reader().vTableGet(_bc, _bcOffset, 86, 0);
|
||||
List<int> get vectorOfNonOwningReferences => const fb.ListReader<int>(const fb.Uint64Reader()).vTableGet(_bc, _bcOffset, 88, null);
|
||||
AnyUniqueAliasesTypeId get anyUniqueType => new AnyUniqueAliasesTypeId.fromValue(const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 90, 0));
|
||||
dynamic get anyUnique {
|
||||
switch (anyUniqueType?.value) {
|
||||
case 1: return M.reader.vTableGet(_bc, _bcOffset, 92, null);
|
||||
case 2: return T.reader.vTableGet(_bc, _bcOffset, 92, null);
|
||||
case 3: return M2.reader.vTableGet(_bc, _bcOffset, 92, null);
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
AnyAmbiguousAliasesTypeId get anyAmbiguousType => new AnyAmbiguousAliasesTypeId.fromValue(const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 94, 0));
|
||||
dynamic get anyAmbiguous {
|
||||
switch (anyAmbiguousType?.value) {
|
||||
case 1: return M1.reader.vTableGet(_bc, _bcOffset, 96, null);
|
||||
case 2: return M2.reader.vTableGet(_bc, _bcOffset, 96, null);
|
||||
case 3: return M3.reader.vTableGet(_bc, _bcOffset, 96, null);
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
List<Color> get vectorOfEnums => const fb.ListReader<Color>(Color.reader).vTableGet(_bc, _bcOffset, 98, null);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Monster{pos: $pos, mana: $mana, hp: $hp, name: $name, inventory: $inventory, color: $color, testType: $testType, test: $test, test4: $test4, testarrayofstring: $testarrayofstring, testarrayoftables: $testarrayoftables, enemy: $enemy, testnestedflatbuffer: $testnestedflatbuffer, testempty: $testempty, testbool: $testbool, testhashs32Fnv1: $testhashs32Fnv1, testhashu32Fnv1: $testhashu32Fnv1, testhashs64Fnv1: $testhashs64Fnv1, testhashu64Fnv1: $testhashu64Fnv1, testhashs32Fnv1a: $testhashs32Fnv1a, testhashu32Fnv1a: $testhashu32Fnv1a, testhashs64Fnv1a: $testhashs64Fnv1a, testhashu64Fnv1a: $testhashu64Fnv1a, testarrayofbools: $testarrayofbools, testf: $testf, testf2: $testf2, testf3: $testf3, testarrayofstring2: $testarrayofstring2, testarrayofsortedstruct: $testarrayofsortedstruct, flex: $flex, test5: $test5, vectorOfLongs: $vectorOfLongs, vectorOfDoubles: $vectorOfDoubles, parentNamespaceTest: $parentNamespaceTest, vectorOfReferrables: $vectorOfReferrables, singleWeakReference: $singleWeakReference, vectorOfWeakReferences: $vectorOfWeakReferences, vectorOfStrongReferrables: $vectorOfStrongReferrables, coOwningReference: $coOwningReference, vectorOfCoOwningReferences: $vectorOfCoOwningReferences, nonOwningReference: $nonOwningReference, vectorOfNonOwningReferences: $vectorOfNonOwningReferences}';
|
||||
return 'Monster{pos: $pos, mana: $mana, hp: $hp, name: $name, inventory: $inventory, color: $color, testType: $testType, test: $test, test4: $test4, testarrayofstring: $testarrayofstring, testarrayoftables: $testarrayoftables, enemy: $enemy, testnestedflatbuffer: $testnestedflatbuffer, testempty: $testempty, testbool: $testbool, testhashs32Fnv1: $testhashs32Fnv1, testhashu32Fnv1: $testhashu32Fnv1, testhashs64Fnv1: $testhashs64Fnv1, testhashu64Fnv1: $testhashu64Fnv1, testhashs32Fnv1a: $testhashs32Fnv1a, testhashu32Fnv1a: $testhashu32Fnv1a, testhashs64Fnv1a: $testhashs64Fnv1a, testhashu64Fnv1a: $testhashu64Fnv1a, testarrayofbools: $testarrayofbools, testf: $testf, testf2: $testf2, testf3: $testf3, testarrayofstring2: $testarrayofstring2, testarrayofsortedstruct: $testarrayofsortedstruct, flex: $flex, test5: $test5, vectorOfLongs: $vectorOfLongs, vectorOfDoubles: $vectorOfDoubles, parentNamespaceTest: $parentNamespaceTest, vectorOfReferrables: $vectorOfReferrables, singleWeakReference: $singleWeakReference, vectorOfWeakReferences: $vectorOfWeakReferences, vectorOfStrongReferrables: $vectorOfStrongReferrables, coOwningReference: $coOwningReference, vectorOfCoOwningReferences: $vectorOfCoOwningReferences, nonOwningReference: $nonOwningReference, vectorOfNonOwningReferences: $vectorOfNonOwningReferences, anyUniqueType: $anyUniqueType, anyUnique: $anyUnique, anyAmbiguousType: $anyAmbiguousType, anyAmbiguous: $anyAmbiguous, vectorOfEnums: $vectorOfEnums}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -848,6 +949,26 @@ class MonsterBuilder {
|
||||
fbBuilder.addOffset(42, offset);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
int addAnyUniqueType(AnyUniqueAliasesTypeId anyUniqueType) {
|
||||
fbBuilder.addUint8(43, anyUniqueType?.value);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
int addAnyUniqueOffset(int offset) {
|
||||
fbBuilder.addOffset(44, offset);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
int addAnyAmbiguousType(AnyAmbiguousAliasesTypeId anyAmbiguousType) {
|
||||
fbBuilder.addUint8(45, anyAmbiguousType?.value);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
int addAnyAmbiguousOffset(int offset) {
|
||||
fbBuilder.addOffset(46, offset);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
int addVectorOfEnumsOffset(int offset) {
|
||||
fbBuilder.addOffset(47, offset);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
|
||||
int finish() {
|
||||
return fbBuilder.endTable();
|
||||
@@ -897,6 +1018,11 @@ class MonsterObjectBuilder extends fb.ObjectBuilder {
|
||||
final List<int> _vectorOfCoOwningReferences;
|
||||
final int _nonOwningReference;
|
||||
final List<int> _vectorOfNonOwningReferences;
|
||||
final AnyUniqueAliasesTypeId _anyUniqueType;
|
||||
final dynamic _anyUnique;
|
||||
final AnyAmbiguousAliasesTypeId _anyAmbiguousType;
|
||||
final dynamic _anyAmbiguous;
|
||||
final List<Color> _vectorOfEnums;
|
||||
|
||||
MonsterObjectBuilder({
|
||||
Vec3ObjectBuilder pos,
|
||||
@@ -941,6 +1067,11 @@ class MonsterObjectBuilder extends fb.ObjectBuilder {
|
||||
List<int> vectorOfCoOwningReferences,
|
||||
int nonOwningReference,
|
||||
List<int> vectorOfNonOwningReferences,
|
||||
AnyUniqueAliasesTypeId anyUniqueType,
|
||||
dynamic anyUnique,
|
||||
AnyAmbiguousAliasesTypeId anyAmbiguousType,
|
||||
dynamic anyAmbiguous,
|
||||
List<Color> vectorOfEnums,
|
||||
})
|
||||
: _pos = pos,
|
||||
_mana = mana,
|
||||
@@ -983,7 +1114,12 @@ class MonsterObjectBuilder extends fb.ObjectBuilder {
|
||||
_coOwningReference = coOwningReference,
|
||||
_vectorOfCoOwningReferences = vectorOfCoOwningReferences,
|
||||
_nonOwningReference = nonOwningReference,
|
||||
_vectorOfNonOwningReferences = vectorOfNonOwningReferences;
|
||||
_vectorOfNonOwningReferences = vectorOfNonOwningReferences,
|
||||
_anyUniqueType = anyUniqueType,
|
||||
_anyUnique = anyUnique,
|
||||
_anyAmbiguousType = anyAmbiguousType,
|
||||
_anyAmbiguous = anyAmbiguous,
|
||||
_vectorOfEnums = vectorOfEnums;
|
||||
|
||||
/// Finish building, and store into the [fbBuilder].
|
||||
@override
|
||||
@@ -1046,6 +1182,11 @@ class MonsterObjectBuilder extends fb.ObjectBuilder {
|
||||
final int vectorOfNonOwningReferencesOffset = _vectorOfNonOwningReferences?.isNotEmpty == true
|
||||
? fbBuilder.writeListUint64(_vectorOfNonOwningReferences)
|
||||
: null;
|
||||
final int anyUniqueOffset = _anyUnique?.getOrCreateOffset(fbBuilder);
|
||||
final int anyAmbiguousOffset = _anyAmbiguous?.getOrCreateOffset(fbBuilder);
|
||||
final int vectorOfEnumsOffset = _vectorOfEnums?.isNotEmpty == true
|
||||
? fbBuilder.writeListInt8(_vectorOfEnums.map((f) => f.value))
|
||||
: null;
|
||||
|
||||
fbBuilder.startTable();
|
||||
if (_pos != null) {
|
||||
@@ -1136,6 +1277,17 @@ class MonsterObjectBuilder extends fb.ObjectBuilder {
|
||||
if (vectorOfNonOwningReferencesOffset != null) {
|
||||
fbBuilder.addOffset(42, vectorOfNonOwningReferencesOffset);
|
||||
}
|
||||
fbBuilder.addUint8(43, _anyUniqueType?.value);
|
||||
if (anyUniqueOffset != null) {
|
||||
fbBuilder.addOffset(44, anyUniqueOffset);
|
||||
}
|
||||
fbBuilder.addUint8(45, _anyAmbiguousType?.value);
|
||||
if (anyAmbiguousOffset != null) {
|
||||
fbBuilder.addOffset(46, anyAmbiguousOffset);
|
||||
}
|
||||
if (vectorOfEnumsOffset != null) {
|
||||
fbBuilder.addOffset(47, vectorOfEnumsOffset);
|
||||
}
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
|
||||
|
||||
@@ -130,10 +130,10 @@ The following attributes are specific to the object-based API code generation:
|
||||
verbatim in the class constructor initializer list for this member.
|
||||
|
||||
- `native_custom_alloc`:"custom_allocator" (on a table or struct): When using the
|
||||
object-based API all generated NativeTables that are allocated when unpacking
|
||||
your flatbuffer will use "custom allocator". The allocator is also used by
|
||||
any std::vector that appears in a table defined with `native_custom_alloc`.
|
||||
This can be used to provide allocation from a pool for example, for faster
|
||||
object-based API all generated NativeTables that are allocated when unpacking
|
||||
your flatbuffer will use "custom allocator". The allocator is also used by
|
||||
any std::vector that appears in a table defined with `native_custom_alloc`.
|
||||
This can be used to provide allocation from a pool for example, for faster
|
||||
unpacking when using the object-based API.
|
||||
|
||||
Minimal Example:
|
||||
@@ -151,8 +151,8 @@ The following attributes are specific to the object-based API code generation:
|
||||
typedef T *pointer;
|
||||
|
||||
template <class U>
|
||||
struct rebind {
|
||||
typedef custom_allocator<U> other;
|
||||
struct rebind {
|
||||
typedef custom_allocator<U> other;
|
||||
};
|
||||
|
||||
pointer allocate(const std::size_t n) {
|
||||
@@ -164,7 +164,7 @@ The following attributes are specific to the object-based API code generation:
|
||||
}
|
||||
|
||||
custom_allocator() throw() {}
|
||||
template <class U>
|
||||
template <class U>
|
||||
custom_allocator(const custom_allocator<U>&) throw() {}
|
||||
};
|
||||
|
||||
@@ -208,12 +208,15 @@ The following attributes are specific to the object-based API code generation:
|
||||
|
||||
Finally, the following top-level attribute
|
||||
|
||||
- native_include: "path" (at file level): Because the `native_type` attribute
|
||||
- `native_include`: "path" (at file level): Because the `native_type` attribute
|
||||
can be used to introduce types that are unknown to flatbuffers, it may be
|
||||
necessary to include "external" header files in the generated code. This
|
||||
attribute can be used to directly add an #include directive to the top of
|
||||
the generated code that includes the specified path directly.
|
||||
|
||||
- `force_align`: this attribute may not be respected in the object API,
|
||||
depending on the aligned of the allocator used with `new`.
|
||||
|
||||
# External references.
|
||||
|
||||
An additional feature of the object API is the ability to allow you to load
|
||||
@@ -499,43 +502,43 @@ To use scalars, simply wrap them in a struct.
|
||||
|
||||
## Depth limit of nested objects and stack-overflow control
|
||||
The parser of Flatbuffers schema or json-files is kind of recursive parser.
|
||||
To avoid stack-overflow problem the parser has a built-in limiter of
|
||||
recursion depth. Number of nested declarations in a schema or number of
|
||||
To avoid stack-overflow problem the parser has a built-in limiter of
|
||||
recursion depth. Number of nested declarations in a schema or number of
|
||||
nested json-objects is limited. By default, this depth limit set to `64`.
|
||||
It is possible to override this limit with `FLATBUFFERS_MAX_PARSING_DEPTH`
|
||||
definition. This definition can be helpful for testing purposes or embedded
|
||||
applications. For details see [build](@ref flatbuffers_guide_building) of
|
||||
It is possible to override this limit with `FLATBUFFERS_MAX_PARSING_DEPTH`
|
||||
definition. This definition can be helpful for testing purposes or embedded
|
||||
applications. For details see [build](@ref flatbuffers_guide_building) of
|
||||
CMake-based projects.
|
||||
|
||||
## Dependence from C-locale {#flatbuffers_locale_cpp}
|
||||
The Flatbuffers [grammar](@ref flatbuffers grammar) uses ASCII
|
||||
The Flatbuffers [grammar](@ref flatbuffers grammar) uses ASCII
|
||||
character set for identifiers, alphanumeric literals, reserved words.
|
||||
|
||||
Internal implementation of the Flatbuffers depends from functions which
|
||||
Internal implementation of the Flatbuffers depends from functions which
|
||||
depend from C-locale: `strtod()` or `strtof()`, for example.
|
||||
The library expects the dot `.` symbol as the separator of an integer
|
||||
The library expects the dot `.` symbol as the separator of an integer
|
||||
part from the fractional part of a float number.
|
||||
Another separator symbols (`,` for example) will break the compatibility
|
||||
Another separator symbols (`,` for example) will break the compatibility
|
||||
and may lead to an error while parsing a Flatbuffers schema or a json file.
|
||||
|
||||
The Standard C locale is a global resource, there is only one locale for
|
||||
the entire application. Some modern compilers and platforms have
|
||||
locale-independent or locale-narrow functions `strtof_l`, `strtod_l`,
|
||||
`strtoll_l`, `strtoull_l` to resolve this dependency.
|
||||
These functions use specified locale rather than the global or per-thread
|
||||
locale instead. They are part of POSIX-2008 but not part of the C/C++
|
||||
The Standard C locale is a global resource, there is only one locale for
|
||||
the entire application. Some modern compilers and platforms have
|
||||
locale-independent or locale-narrow functions `strtof_l`, `strtod_l`,
|
||||
`strtoll_l`, `strtoull_l` to resolve this dependency.
|
||||
These functions use specified locale rather than the global or per-thread
|
||||
locale instead. They are part of POSIX-2008 but not part of the C/C++
|
||||
standard library, therefore, may be missing on some platforms.
|
||||
|
||||
The Flatbuffers library try to detect these functions at configuration and
|
||||
The Flatbuffers library try to detect these functions at configuration and
|
||||
compile time:
|
||||
- `_MSC_VER >= 1900`: check MSVC2012 or higher for MSVC buid
|
||||
- `_XOPEN_SOURCE>=700`: check POSIX-2008 for GCC/Clang build
|
||||
- `check_cxx_symbol_exists(strtof_l stdlib.h)`: CMake check of `strtod_f`
|
||||
|
||||
After detection, the definition `FLATBUFFERS_LOCALE_INDEPENDENT` will be
|
||||
After detection, the definition `FLATBUFFERS_LOCALE_INDEPENDENT` will be
|
||||
set to `0` or `1`.
|
||||
|
||||
It is possible to test the compatibility of the Flatbuffers library with
|
||||
It is possible to test the compatibility of the Flatbuffers library with
|
||||
a specific locale using the environment variable `FLATBUFFERS_TEST_LOCALE`:
|
||||
```sh
|
||||
>FLATBUFFERS_TEST_LOCALE="" ./flattests
|
||||
|
||||
@@ -84,7 +84,7 @@ parent object, and use no virtual table).
|
||||
|
||||
### Types
|
||||
|
||||
Built-in scalar types are
|
||||
Built-in scalar types are
|
||||
|
||||
- 8 bit: `byte` (`int8`), `ubyte` (`uint8`), `bool`
|
||||
|
||||
@@ -321,6 +321,9 @@ Current understood attributes:
|
||||
these structs to be aligned to that amount inside a buffer, IF that
|
||||
buffer is allocated with that alignment (which is not necessarily
|
||||
the case for buffers accessed directly inside a `FlatBufferBuilder`).
|
||||
Note: currently not guaranteed to have an effect when used with
|
||||
`--object-api`, since that may allocate objects at alignments less than
|
||||
what you specify with `force_align`.
|
||||
- `bit_flags` (on an enum): the values of this field indicate bits,
|
||||
meaning that any value N specified in the schema will end up
|
||||
representing 1<<N, or if you don't specify values at all, you'll get
|
||||
@@ -404,26 +407,26 @@ binary representation.
|
||||
|
||||
When parsing numbers, the parser is more flexible than JSON.
|
||||
A format of numeric literals is more close to the C/C++.
|
||||
According to the [grammar](@ref flatbuffers_grammar), it accepts the following
|
||||
According to the [grammar](@ref flatbuffers_grammar), it accepts the following
|
||||
numerical literals:
|
||||
|
||||
- An integer literal can have any number of leading zero `0` digits.
|
||||
Unlike C/C++, the parser ignores a leading zero, not interpreting it as the
|
||||
Unlike C/C++, the parser ignores a leading zero, not interpreting it as the
|
||||
beginning of the octal number.
|
||||
The numbers `[081, -00094]` are equal to `[81, -94]` decimal integers.
|
||||
- The parser accepts unsigned and signed hexadecimal integer numbers.
|
||||
For example: `[0x123, +0x45, -0x67]` are equal to `[291, 69, -103]` decimals.
|
||||
- The format of float-point numbers is fully compatible with C/C++ format.
|
||||
If a modern C++ compiler is used the parser accepts hexadecimal and special
|
||||
If a modern C++ compiler is used the parser accepts hexadecimal and special
|
||||
float-point literals as well:
|
||||
`[-1.0, 2., .3e0, 3.e4, 0x21.34p-5, -inf, nan]`.
|
||||
The exponent suffix of hexadecimal float-point number is mandatory.
|
||||
|
||||
|
||||
Extended float-point support was tested with:
|
||||
- x64 Windows: `MSVC2015` and higher.
|
||||
- x64 Linux: `LLVM 6.0`, `GCC 4.9` and higher.
|
||||
|
||||
- For compatibility with a JSON lint tool all numeric literals of scalar
|
||||
- For compatibility with a JSON lint tool all numeric literals of scalar
|
||||
fields can be wrapped to quoted string:
|
||||
`"1", "2.0", "0x48A", "0x0C.0Ep-1", "-inf", "true"`.
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ public struct Vec3 : IFlatbufferObject
|
||||
public Test Test3 { get { return (new Test()).__assign(__p.bb_pos + 26, __p.bb); } }
|
||||
|
||||
public static Offset<Vec3> CreateVec3(FlatBufferBuilder builder, float X, float Y, float Z, double Test1, Color Test2, short test3_A, sbyte test3_B) {
|
||||
builder.Prep(16, 32);
|
||||
builder.Prep(8, 32);
|
||||
builder.Pad(2);
|
||||
builder.Prep(2, 4);
|
||||
builder.Pad(1);
|
||||
|
||||
@@ -63,7 +63,7 @@ func (rcv *Vec3) Test3(obj *Test) *Test {
|
||||
}
|
||||
|
||||
func CreateVec3(builder *flatbuffers.Builder, x float32, y float32, z float32, test1 float64, test2 int8, test3_a int16, test3_b int8) flatbuffers.UOffsetT {
|
||||
builder.Prep(16, 32)
|
||||
builder.Prep(8, 32)
|
||||
builder.Pad(2)
|
||||
builder.Prep(2, 4)
|
||||
builder.Pad(1)
|
||||
|
||||
@@ -25,7 +25,7 @@ import com.google.flatbuffers.*;
|
||||
public Test test3(Test obj) { return obj.__assign(bb_pos + 26, bb); }
|
||||
|
||||
public static int createVec3(FlatBufferBuilder builder, float x, float y, float z, double test1, byte test2, short test3_a, byte test3_b) {
|
||||
builder.prep(16, 32);
|
||||
builder.prep(8, 32);
|
||||
builder.pad(2);
|
||||
builder.prep(2, 4);
|
||||
builder.pad(1);
|
||||
|
||||
@@ -35,7 +35,7 @@ function Vec3_mt:Test3(obj)
|
||||
return obj
|
||||
end
|
||||
function Vec3.CreateVec3(builder, x, y, z, test1, test2, test3_a, test3_b)
|
||||
builder:Prep(16, 32)
|
||||
builder:Prep(8, 32)
|
||||
builder:Pad(2)
|
||||
builder:Prep(2, 4)
|
||||
builder:Pad(1)
|
||||
|
||||
@@ -78,7 +78,7 @@ class Vec3 extends Struct
|
||||
*/
|
||||
public static function createVec3(FlatBufferBuilder $builder, $x, $y, $z, $test1, $test2, $test3_a, $test3_b)
|
||||
{
|
||||
$builder->prep(16, 32);
|
||||
$builder->prep(8, 32);
|
||||
$builder->pad(2);
|
||||
$builder->prep(2, 4);
|
||||
$builder->pad(1);
|
||||
|
||||
@@ -28,7 +28,7 @@ class Vec3(object):
|
||||
|
||||
|
||||
def CreateVec3(builder, x, y, z, test1, test2, test3_a, test3_b):
|
||||
builder.Prep(16, 32)
|
||||
builder.Prep(8, 32)
|
||||
builder.Pad(2)
|
||||
builder.Prep(2, 4)
|
||||
builder.Pad(1)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -27,7 +27,7 @@ table TestSimpleTableWithEnum (csharp_partial, private) {
|
||||
color: Color = Green;
|
||||
}
|
||||
|
||||
struct Vec3 (force_align: 16) {
|
||||
struct Vec3 (force_align: 8) {
|
||||
x:float;
|
||||
y:float;
|
||||
z:float;
|
||||
|
||||
@@ -545,7 +545,7 @@ inline bool operator==(const Test &lhs, const Test &rhs) {
|
||||
(lhs.b() == rhs.b());
|
||||
}
|
||||
|
||||
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(16) Vec3 FLATBUFFERS_FINAL_CLASS {
|
||||
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) Vec3 FLATBUFFERS_FINAL_CLASS {
|
||||
private:
|
||||
float x_;
|
||||
float y_;
|
||||
|
||||
@@ -487,7 +487,7 @@ MyGame.Example.Vec3.prototype.test3 = function(obj) {
|
||||
* @returns {flatbuffers.Offset}
|
||||
*/
|
||||
MyGame.Example.Vec3.createVec3 = function(builder, x, y, z, test1, test2, test3_a, test3_b) {
|
||||
builder.prep(16, 32);
|
||||
builder.prep(8, 32);
|
||||
builder.pad(2);
|
||||
builder.prep(2, 4);
|
||||
builder.pad(1);
|
||||
|
||||
@@ -118,7 +118,7 @@ struct Vec3 : flatbuffers_handle
|
||||
MyGame_Example_Test{ buf_, pos_ + 26 }
|
||||
|
||||
def CreateVec3(b_:flatbuffers_builder, x:float, y:float, z:float, test1:float, test2:int, test3_a:int, test3_b:int):
|
||||
b_.Prep(16, 32)
|
||||
b_.Prep(8, 32)
|
||||
b_.Pad(2)
|
||||
b_.Prep(2, 4)
|
||||
b_.Pad(1)
|
||||
|
||||
@@ -500,8 +500,8 @@ impl Test {
|
||||
}
|
||||
}
|
||||
|
||||
// struct Vec3, aligned to 16
|
||||
#[repr(C, align(16))]
|
||||
// struct Vec3, aligned to 8
|
||||
#[repr(C, align(8))]
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct Vec3 {
|
||||
x_: f32,
|
||||
|
||||
@@ -453,7 +453,7 @@ test3(obj?:MyGame.Example.Test):MyGame.Example.Test|null {
|
||||
* @returns flatbuffers.Offset
|
||||
*/
|
||||
static createVec3(builder:flatbuffers.Builder, x: number, y: number, z: number, test1: number, test2: MyGame.Example.Color, test3_a: number, test3_b: number):flatbuffers.Offset {
|
||||
builder.prep(16, 32);
|
||||
builder.prep(8, 32);
|
||||
builder.pad(2);
|
||||
builder.prep(2, 4);
|
||||
builder.pad(1);
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -90,7 +90,7 @@ def CheckReadBuffer(buf, offset, sizePrefix = False):
|
||||
if sizePrefix:
|
||||
size = util.GetSizePrefix(buf, offset)
|
||||
# taken from the size of monsterdata_python_wire.mon, minus 4
|
||||
asserter(size == 348)
|
||||
asserter(size == 340)
|
||||
buf, offset = util.RemoveSizePrefix(buf, offset)
|
||||
monster = MyGame.Example.Monster.Monster.GetRootAsMonster(buf, offset)
|
||||
|
||||
|
||||
@@ -656,8 +656,8 @@ mod generated_code_alignment_and_padding {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn struct_vec3_is_aligned_to_16() {
|
||||
assert_eq!(16, ::std::mem::align_of::<my_game::example::Vec3>());
|
||||
fn struct_vec3_is_aligned_to_8() {
|
||||
assert_eq!(8, ::std::mem::align_of::<my_game::example::Vec3>());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user