Each module provides a set of constants; most of them are ENUMs which are
present in the XML dump of gccxml, others being #defines that are extracted
by pattern matching from the header files at build time (see
script/parse-xml.lua:parse_header_file).
This is the list of constant types currently supported:
- ENUM, i.e. declared in a C header file with enum Name { ... };.
Each value is a possibly negative integer and has a data type attached.
- FLAG, which is a special case of ENUM. It also has a type, but can
be ORed together, while this is not possible with ENUM. FLAGs are identified
at runtime with G_TYPE_IS_FLAGS (see src/gnome/enum.c).
- Strings
- Other numerical #defines
- G_TYPE defines, which are mapped to numbers
- Atoms, i.e. defined with the macro GDK_MAKE_ATOM
Once again this information should be encoded in a most space efficient manner. The algorithm to encode is in script/xml-const.lua, while the decoder is in
src/gnome/data.c:_decode_constant_v2().
The first byte has following bits:
- the two "flags" bit can have following values: 00=no type, 01=8 bit type,
10=16 bit type, 11=string. If the (16 bit) type has the top bit set, this
means a negative number.
-
- The remaining 6 bits of the first byte are used as high bits of the
value, unless it is a string.
- Zero, one or two bytes of the type ID follow, depending on the flags.
- The rest of the entry is the value; for strings, the characters, and
for numerical values, as many bytes as are needed to represent the number,
with high order bytes being stored first.
For numerical constants, the rest of the available bytes (possibly after
skipping one used for the type index) are the value, the high order bytes
being stored first.