Untelo/Sandbox – User
(→Array) |
|||
Line 72: | Line 72: | ||
{ | { | ||
uint32_t blobSize; // Size of the subsequent data blob. | uint32_t blobSize; // Size of the subsequent data blob. | ||
uint32_t size; | uint32_t size; | ||
Field data[size]; | Field data[size]; | ||
}; | }; | ||
=== Object and object pointer === | === Object and object pointer === |
Revision as of 10:38, 28 April 2021
Introduction
Structure
Header
struct Header { uint8_t magic[4]; // "ALB1" uint32_t version; uint32_t unknown1; uint32_t unknown2; };
Field
The format uses named and typed fields.
enum FieldType : uint8_t { signed_char = 0x01, unsigned_char = 0x02, signed_short = 0x03, unsigned_short = 0x04, signed_int = 0x05, unsigned_int = 0x06, signed_long = 0x07, unsigned_long = 0x08, bool = 0x09, float = 0x0A, string = 0x0B, array = 0x0C, object = 0x0D, object_pointer = 0x0E, pair = 0x0F, array_signed_short = 0x10, array_signed_int = 0x11, array_float = 0x12, empty = 0x13, double = 0x14, array_double = 0x15, };
struct Field { uint16 tag; // Corresponds to an entry in the tag table. FieldType type; byte data[]; // Followed by polymorphic data blob which content is determined by the type field. };
Fundamental types
For fundamental C types, the field data contains only that value using the Microsoft x86 ABI. This means that the signed and unsigned long data types have a width of 32 bits, the same as signed and unsigned int.
String
The string data type is a length-prefixed non-null-terminated string, using a 16 bit length prefix:
struct Field_string { uint16_t size; char data[size]; };
Array
The array and object data types are both length-prefixed using a 32 bit length describing the size of the data blob, excluding the prefix.
The generic array data type contains an array of fields, their number given by a second size prefix.
struct Field_array { uint32_t blobSize; // Size of the subsequent data blob. uint32_t size; Field data[size]; };
Object and object pointer
The object data type contains a number of fields. The number of fields is not given, but the size of the data blob is used to determine the end of the object. Each object has an address field acting as a unique identifier. It is presumably the 32 bit runtime address of the object at the time of serialization. It is used for linking pointers in the object graph during deserialization.
struct Field_object { uint32_t blobSize; // Size of the subsequent data blob. int16_t class; // Corresponds to an entry in the class table. uint32_t address; Field fields[]; // Arbitrary number of fields. };
The object pointer data type is a stripped down version of the header of the object data type. However it only contains the type and address of the object, with the address corresponding to an object somewhere in the graph.
struct Field_object_pointer { int16_t class; // Corresponds to an entry in the class table. uint32_t address; // Corresponds to the address field of some object field in the graph. };
Pair
The pair data type is simply holds two fields. It is primarily used by associative containers.
struct Field_pair { Field first; Field second; };