Blame doc/xkb_internals

Packit Service 612474
Packit Service 612474
XKB introduces several uncommon data structures:
Packit Service 612474
 - switch allows conditional inclusion of fields
Packit Service 612474
 - several complex objects intermix variable and fixed size fields
Packit Service 612474
 - lists with a variable number of variable size objects
Packit Service 612474
Packit Service 612474
To handle these objects, a number of new functions is generated:
Packit Service 612474
 - _serialize() turns a structured object into a byte stream, 
Packit Service 612474
   (re)ordering or including fields according to the protocol
Packit Service 612474
 - _unserialize() rewrites data from a buffer into a structured object
Packit Service 612474
 - _unpack() expands a buffer representing a switch object into 
Packit Service 612474
   a special structured type, all flags needed to resolve the switch
Packit Service 612474
   expression have to given as parameters
Packit Service 612474
 - _sizeof() calculates the size of a serialized object, often by calling
Packit Service 612474
   _unserialize()/_unpack() internally
Packit Service 612474
Packit Service 612474
The new structured data type for switch is special as it contains fixed 
Packit Service 612474
and variable size fields. Variable size fields can be accessed via pointers. 
Packit Service 612474
Packit Service 612474
If switch appears in a request, an additional set of request helpers is 
Packit Service 612474
generated with the suffix _aux or _aux_(un)checked. While the 'common'
Packit Service 612474
request functions require that switch has been serialized before, the _aux
Packit Service 612474
variants take the structured data type. They are especially designed to 
Packit Service 612474
replace certain functions in xcb-util/aux. 
Packit Service 612474
Packit Service 612474
Accessors for switch members need two parameters, where the first is usually
Packit Service 612474
a pointer to the respective request or reply structure, while the second 
Packit Service 612474
is a pointer to the unpacked switch data structure. 
Packit Service 612474
Packit Service 612474
Functions from the serialize family that take a double pointer can allocate 
Packit Service 612474
memory on their own, which is useful if the size of a buffer has to be 
Packit Service 612474
calculated depending on the data within. These functions call malloc() when 
Packit Service 612474
the double pointer is given as the address of a pointer that has been 
Packit Service 612474
initialized to 0. It is the responsibility of the user to free any allocated
Packit Service 612474
memory. 
Packit Service 612474
Packit Service 612474
Intermixed variable and fixed size fields are an important special case in XKB. 
Packit Service 612474
The current implementation resolves the issue by reordering the fields before
Packit Service 612474
sending them on the wire as well as before returning a reply. That means that 
Packit Service 612474
these objects look like 'common' XCB data types and they can be accessed as such 
Packit Service 612474
(i.e. fixed size fields directly via the structured type and variable size fields
Packit Service 612474
via accessors/iterators).  
Packit Service 612474
Packit Service 612474
In case a list with variable size elements needs to be accessed, it is necessary 
Packit Service 612474
to use iterators. The iterator functions take care of determining the actual 
Packit Service 612474
object size for each element automatically. 
Packit Service 612474
Packit Service 612474
A small and preliminary set of auxiliary functions is available in xkb_util.c 
Packit Service 612474
in the check_xkb module.