flatbuffers/tests/64bit/test_64bit.afb

75 lines
5.1 KiB
Plaintext
Raw Normal View History

FlatBuffers 64 for C++ (#7935) * First working hack of adding 64-bit. Don't judge :) * Made vector_downward work on 64 bit types * vector_downward uses size_t, added offset64 to reflection * cleaned up adding offset64 in parser * Add C++ testing skeleton for 64-bit * working test for CreateVector64 * working >2 GiB buffers * support for large strings * simplified CreateString<> to just provide the offset type * generalize CreateVector template * update test_64.afb due to upstream format change * Added Vector64 type, which is just an alias for vector ATM * Switch to Offset64 for Vector64 * Update for reflection bfbs output change * Starting to add support for vector64 type in C++ * made a generic CreateVector that can handle different offsets and vector types * Support for 32-vector with 64-addressing * Vector64 basic builder + tests working * basic support for json vector64 support * renamed fields in test_64bit.fbs to better reflect their use * working C++ vector64 builder * Apply --annotate-sparse-vector to 64-bit tests * Enable Vector64 for --annotate-sparse-vectors * Merged from upstream * Add `near_string` field for testing 32-bit offsets alongside * keep track of where the 32-bit and 64-bit regions are for flatbufferbuilder * move template<> outside class body for GCC * update run.sh to build and run tests * basic assertion for adding 64-bit offset at the wrong time * started to separate `FlatBufferBuilder` into two classes, 1 64-bit aware, the other not * add test for nested flatbuffer vector64, fix bug in alignment of big vectors * fixed CreateDirect method by iterating by Offset64 first * internal refactoring of flatbufferbuilder * block not supported languages in the parser from using 64-bit * evolution tests for adding a vector64 field * conformity tests for adding/removing offset64 attributes * ensure test is for a big buffer * add parser error tests for `offset64` and `vector64` attributes * add missing static that GCC only complains about * remove stdint-uintn.h header that gets automatically added * move 64-bit CalculateOffset internal * fixed return size of EndVector * various fixes on windows * add SizeT to vector_downward * minimze range of size changes in vector and builder * reworked how tracking if 64-offsets are added * Add ReturnT to EndVector * small cleanups * remove need for second Array definition * combine IndirectHelpers into one definition * started support for vector of struct * Support for 32/64-vectors of structs + Offset64 * small cleanups * add verification for vector64 * add sized prefix for 64-bit buffers * add fuzzer for 64-bit * add example of adding many vectors using a wrapper table * run the new -bfbs-gen-embed logic on the 64-bit tests * remove run.sh and fix cmakelist issue * fixed bazel rules * fixed some PR comments * add 64-bit tests to cmakelist
2023-05-09 16:16:30 +00:00
// Annotated Flatbuffer Binary
//
// Schema file: tests/64bit/test_64bit.fbs
// Binary file: tests/64bit/test_64bit.bin
header:
+0x00 | 1C 00 00 00 | UOffset32 | 0x0000001C (28) Loc: 0x1C | offset to root table `RootTable`
padding:
+0x04 | 00 00 00 00 | uint8_t[4] | .... | padding
vtable (RootTable):
+0x08 | 14 00 | uint16_t | 0x0014 (20) | size of this vtable
+0x0A | 34 00 | uint16_t | 0x0034 (52) | size of referring table
+0x0C | 04 00 | VOffset16 | 0x0004 (4) | offset to field `far_vector` (id: 0)
+0x0E | 10 00 | VOffset16 | 0x0010 (16) | offset to field `a` (id: 1)
+0x10 | 14 00 | VOffset16 | 0x0014 (20) | offset to field `far_string` (id: 2)
+0x12 | 24 00 | VOffset16 | 0x0024 (36) | offset to field `big_vector` (id: 3)
+0x14 | 20 00 | VOffset16 | 0x0020 (32) | offset to field `near_string` (id: 4)
+0x16 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `nested_root` (id: 5) <null> (Vector64)
+0x18 | 00 00 | VOffset16 | 0x0000 (0) | offset to field `far_struct_vector` (id: 6) <null> (Vector)
+0x1A | 2C 00 | VOffset16 | 0x002C (44) | offset to field `big_struct_vector` (id: 7)
root_table (RootTable):
+0x1C | 14 00 00 00 | SOffset32 | 0x00000014 (20) Loc: 0x08 | offset to vtable
+0x20 | D0 00 00 00 00 00 00 00 | UOffset64 | 0x00000000000000D0 (208) Loc: 0xF0 | offset to field `far_vector` (vector)
+0x28 | 00 00 00 00 | uint8_t[4] | .... | padding
+0x2C | D2 04 00 00 | uint32_t | 0x000004D2 (1234) | table field `a` (Int)
+0x30 | 8C 00 00 00 00 00 00 00 | UOffset64 | 0x000000000000008C (140) Loc: 0xBC | offset to field `far_string` (string)
+0x38 | 00 00 00 00 | uint8_t[4] | .... | padding
+0x3C | 40 00 00 00 | UOffset32 | 0x00000040 (64) Loc: 0x7C | offset to field `near_string` (string)
+0x40 | 70 00 00 00 00 00 00 00 | UOffset64 | 0x0000000000000070 (112) Loc: 0xB0 | offset to field `big_vector` (vector64)
+0x48 | 08 00 00 00 00 00 00 00 | UOffset64 | 0x0000000000000008 (8) Loc: 0x50 | offset to field `big_struct_vector` (vector64)
vector64 (RootTable.big_struct_vector):
+0x50 | 02 00 00 00 00 00 00 00 | uint64_t | 0x0000000000000002 (2) | length of vector (# items)
+0x58 | 0C 00 00 00 | uint32_t | 0x0000000C (12) | struct field `[0].a` of 'LeafStruct' (Int)
<4 regions omitted>
+0x70 | 33 33 33 33 33 33 22 40 | double | 0x4022333333333333 (9.1) | struct field `[1].b` of 'LeafStruct' (Double)
padding:
+0x78 | 00 00 00 00 | uint8_t[4] | .... | padding
string (RootTable.near_string):
+0x7C | 2F 00 00 00 | uint32_t | 0x0000002F (47) | length of string
+0x80 | 74 68 69 73 20 69 73 20 | char[47] | this is | string literal
+0x88 | 61 20 6E 65 61 72 20 73 | | a near s
+0x90 | 74 72 69 6E 67 20 77 68 | | tring wh
+0x98 | 69 63 68 20 68 61 73 20 | | ich has
+0xA0 | 61 20 33 32 2D 62 69 74 | | a 32-bit
+0xA8 | 20 6F 66 66 73 65 74 | | offset
+0xAF | 00 | char | 0x00 (0) | string terminator
vector64 (RootTable.big_vector):
+0xB0 | 04 00 00 00 00 00 00 00 | uint64_t | 0x0000000000000004 (4) | length of vector (# items)
+0xB8 | 05 | uint8_t | 0x05 (5) | value[0]
<2 regions omitted>
+0xBB | 08 | uint8_t | 0x08 (8) | value[3]
string (RootTable.far_string):
+0xBC | 2E 00 00 00 | uint32_t | 0x0000002E (46) | length of string
+0xC0 | 74 68 69 73 20 69 73 20 | char[46] | this is | string literal
+0xC8 | 61 20 66 61 72 20 73 74 | | a far st
+0xD0 | 72 69 6E 67 20 77 68 69 | | ring whi
+0xD8 | 63 68 20 68 61 73 20 61 | | ch has a
+0xE0 | 20 36 34 2D 62 69 74 20 | | 64-bit
+0xE8 | 6F 66 66 73 65 74 | | offset
+0xEE | 00 | char | 0x00 (0) | string terminator
vector (RootTable.far_vector):
+0xF0 | 03 00 00 00 | uint32_t | 0x00000003 (3) | length of vector (# items)
+0xF4 | 01 | uint8_t | 0x01 (1) | value[0]
+0xF5 | 02 | uint8_t | 0x02 (2) | value[1]
+0xF6 | 03 | uint8_t | 0x03 (3) | value[2]