## GITypelib Internals

GITypelib Internals — Layout and accessors for typelib

## Stability Level

Stable, unless otherwise indicated

## Functions

DirEntry * | g_typelib_get_dir_entry ()
DirEntry * | g_typelib_get_dir_entry_by_name ()
DirEntry * | g_typelib_get_dir_entry_by_gtype_name ()
DirEntry * | g_typelib_get_dir_entry_by_error_domain ()
gboolean | g_typelib_matches_gtype_name_prefix ()
void | g_typelib_check_sanity ()
#define | g_typelib_get_string()
GQuark | g_typelib_error_quark ()
gboolean | g_typelib_validate ()

## Types and Values

#define | G_IR_MAGIC
enum | GTypelibBlobType
| Header
enum | SectionType
| Section
| DirEntry
| SimpleTypeBlobFlags
| SimpleTypeBlob
| ArgBlob
| SignatureBlob
| CommonBlob
| FunctionBlob
| CallbackBlob
| InterfaceTypeBlob
| ArrayTypeDimension
| ArrayTypeBlob
| ParamTypeBlob
| ErrorTypeBlob
| ValueBlob
| FieldBlob
| RegisteredTypeBlob
| StructBlob
| UnionBlob
| EnumBlob
| PropertyBlob
| SignalBlob
| VFuncBlob
| ObjectBlob
| InterfaceBlob
| ConstantBlob
| AttributeBlob
enum | GITypelibError
#define | G_TYPELIB_ERROR
| GITypelibHashBuilder

## Description

The "typelib" is a binary, readonly, memory-mappable database containing reflective information about a GObject library.

What the typelib describes and the types used are the same for every platform so, apart the endianness of its scalar values, the typelib database must be considered architecture-independent.

The format of GObject typelib is strongly influenced by the Mozilla XPCOM format.

Some of the differences to XPCOM include:

- Type information is stored not quite as compactly (XPCOM stores it inline in function descriptions in variable-sized blobs of 1 to n bytes. We store 16 bits of type information for each parameter, which is enough to encode simple types inline. Complex (e.g. recursive) types are stored out of line in a separate list of types.

- String and complex type data is stored outside of typelib entry blobs, references are stored as offsets relative to the start of the typelib. One possibility is to store the strings and types in a pools at the end of the typelib.

The typelib has the following general format:

    1
    2
    3
    4
    5
    6
    7
    8

    typelib ::= header, section-index, directory, blobs, attributes, attributedata

    directory ::= list of entries

    entry ::= blob type, name, namespace, offset
    blob ::= function|callback|struct|boxed|enum|flags|object|interface|constant|union
    attribute ::= offset, key, value
    attributedata ::= string data for attributes

Details

We describe the fragments that make up the typelib in the form of C structs (although some fall short of being valid C structs since they contain multiple flexible arrays).

## Functions

### g_typelib_get_dir_entry ()

    DirEntry *
    g_typelib_get_dir_entry (GITypelib *typelib,
                             guint16 index);

TODO

#### Parameters

typelib | TODO |
index | TODO |

#### Returns

TODO

### g_typelib_get_dir_entry_by_name ()

    DirEntry *
    g_typelib_get_dir_entry_by_name (GITypelib *typelib,
                                     const char *name);

TODO

#### Parameters

typelib | TODO |
name | TODO |

#### Returns

TODO

### g_typelib_get_dir_entry_by_gtype_name ()

    DirEntry *
    g_typelib_get_dir_entry_by_gtype_name (GITypelib *typelib,
                                           const gchar *gtype_name);

TODO

#### Parameters

typelib | TODO |
gtype_name | TODO |

#### Returns

TODO

### g_typelib_get_dir_entry_by_error_domain ()

    DirEntry *
    g_typelib_get_dir_entry_by_error_domain
                                   (GITypelib *typelib,
                                    GQuark error_domain);

TODO

#### Parameters

typelib | TODO |
error_domain | TODO |

#### Returns

TODO

### g_typelib_matches_gtype_name_prefix ()

    gboolean
    g_typelib_matches_gtype_name_prefix (GITypelib *typelib,
                                         const gchar *gtype_name);

TODO

#### Parameters

typelib | TODO |
gtype_name | TODO |

#### Returns

TODO

### g_typelib_check_sanity ()

    void
    g_typelib_check_sanity (void);

TODO

### g_typelib_get_string()

    #define             g_typelib_get_string(typelib,offset)

TODO

#### Parameters

typelib | TODO |
offset | TODO |

#### Returns

TODO

### g_typelib_error_quark ()

    GQuark
    g_typelib_error_quark (void);

TODO

#### Returns

TODO

### g_typelib_validate ()

    gboolean
    g_typelib_validate (GITypelib *typelib,
                        GError **error);

TODO

#### Parameters

typelib | TODO |
error | TODO |

#### Returns

TODO

## Types and Values

### G_IR_MAGIC

    #define G_IR_MAGIC "GOBJ\nMETADATA\r\n\032"

Identifying prefix for the typelib. This was inspired by XPCOM, which in turn borrowed from PNG.

### enum GTypelibBlobType

The integral value of this enumeration appears in each "Blob" component of a typelib to identify its type.

#### Members

BLOB_TYPE_INVALID | Should not appear in code |
BLOB_TYPE_FUNCTION | A FunctionBlob |
BLOB_TYPE_CALLBACK | A CallbackBlob |
BLOB_TYPE_STRUCT | A StructBlob |
BLOB_TYPE_BOXED | Can be either a StructBlob or UnionBlob |
BLOB_TYPE_ENUM | An EnumBlob |
BLOB_TYPE_FLAGS | An EnumBlob |
BLOB_TYPE_OBJECT | An ObjectBlob |
BLOB_TYPE_INTERFACE | An InterfaceBlob |
BLOB_TYPE_CONSTANT | A ConstantBlob |
BLOB_TYPE_INVALID_0 | Deleted, used to be ErrorDomain. |
BLOB_TYPE_UNION | A UnionBlob |

### Header

    typedef struct {
      gchar   magic[16];
      guint8  major_version;
      guint8  minor_version;
      guint16 reserved;
      guint16 n_entries;
      guint16 n_local_entries;
      guint32 directory;
      guint32 n_attributes;
      guint32 attributes;

      guint32 dependencies;

      guint32 size;
      guint32 namespace;
      guint32 nsversion;
      guint32 shared_library;
      guint32 c_prefix;

      guint16 entry_blob_size;
      guint16 function_blob_size;
      guint16 callback_blob_size;
      guint16 signal_blob_size;
      guint16 vfunc_blob_size;
      guint16 arg_blob_size;
      guint16 property_blob_size;
      guint16 field_blob_size;
      guint16 value_blob_size;
      guint16 attribute_blob_size;
      guint16 constant_blob_size;
      guint16 error_domain_blob_size;

      guint16 signature_blob_size;
      guint16 enum_blob_size;
      guint16 struct_blob_size;
      guint16 object_blob_size;
      guint16 interface_blob_size;
      guint16 union_blob_size;

      guint32 sections;

      guint16 padding[6];
    } Header;

The header structure appears exactly once at the beginning of a typelib. It is a collection of meta-information, such as the number of entries and dependencies.

#### Members

gchar `magic`[16]; | See G_IR_MAGIC. |
guint8 `major_version`; | The major version number of the typelib format. Major version number changes indicate incompatible changes to the tyeplib format. |
guint8 `minor_version`; | The minor version number of the typelib format. Minor version number changes indicate compatible changes and should still allow the typelib to be parsed by a parser designed for the same `major_version` . |
guint16 `reserved`; | Reserved for future use. |
guint16 `n_entries`; | The number of entries in the directory. |
guint16 `n_local_entries`; | The number of entries referring to blobs in this typelib. The local entries must occur before the unresolved entries. |
guint32 `directory`; | Offset of the directory in the typelib. |
guint32 `n_attributes`; | Number of attribute blocks |
guint32 `attributes`; | Offset of the list of attributes in the typelib. |
guint32 `dependencies`; | Offset of a single string, which is the list of immediate dependencies, separated by the '|' character. The dependencies are required in order to avoid having programs consuming a typelib check for an "Unresolved" type return from every API call. |
guint32 `size`; | The size in bytes of the typelib. |
guint32 `namespace`; | Offset of the namespace string in the typelib. |
guint32 `nsversion`; | Offset of the namespace version string in the typelib. |
guint32 `shared_library`; | This field is the set of shared libraries associated with the typelib. The entries are separated by the '|' (pipe) character. |
guint32 `c_prefix`; | The prefix for the function names of the library |
guint16 `entry_blob_size`; | The sizes of fixed-size blobs. Recording this information here allows to write parser which continue to work if the format is extended by adding new fields to the end of the fixed-size blobs. |
guint16 `function_blob_size`; | See `entry_blob_size` . |
guint16 `callback_blob_size`; | See `entry_blob_size` . |
guint16 `signal_blob_size`; | See `entry_blob_size` . |
guint16 `vfunc_blob_size`; | See `entry_blob_size` . |
guint16 `arg_blob_size`; | See `entry_blob_size` . |
guint16 `property_blob_size`; | See `entry_blob_size` . |
guint16 `field_blob_size`; | See `entry_blob_size` . |
guint16 `value_blob_size`; | See `entry_blob_size` . |
guint16 `attribute_blob_size`; | See `entry_blob_size` . |
guint16 `constant_blob_size`; | See `entry_blob_size` . |
guint16 `error_domain_blob_size`; | See `entry_blob_size` . |
guint16 `signature_blob_size`; | See `entry_blob_size` . |
guint16 `enum_blob_size`; | See `entry_blob_size` . |
guint16 `struct_blob_size`; | See `entry_blob_size` . |
guint16 `object_blob_size`; | See `entry_blob_size` . |
guint16 `interface_blob_size`; | For variable-size blobs, the size of the struct up to the first flexible array member. Recording this information here allows to write parser which continue to work if the format is extended by adding new fields before the first flexible array member in variable-size blobs. |
guint16 `union_blob_size`; | See `entry_blob_size` . |
guint32 `sections`; | Offset of section blob array |
guint16 `padding`[6]; | TODO |

### enum SectionType

TODO

#### Members

GI_SECTION_END | TODO |
GI_SECTION_DIRECTORY_INDEX | TODO |

### Section

    typedef struct {
      guint32 id;
      guint32 offset;
    } Section;

A section is a blob of data that's (at least theoretically) optional, and may or may not be present in the typelib. Presently, just used for the directory index. This allows a form of dynamic extensibility with different tradeoffs from the format minor version.

#### Members

guint32 `id`; | A SectionType |
guint32 `offset`; | Integer offset for this section |

### DirEntry

    typedef struct {
      guint16 blob_type;

      guint16 local    : 1;
      guint16 reserved :15;
      guint32 name;
      guint32 offset;
    } DirEntry;

References to directory entries are stored as 1-based 16-bit indexes.

All blobs pointed to by a directory entry start with the same layout for the first 8 bytes (the reserved flags may be used by some blob types)

#### Members

guint16 `blob_type`; | A GTypelibBlobType |
guint16 `local` : 1; | Whether this entry refers to a blob in this typelib. |
guint16 `reserved` :15; | Reserved for future use. |
guint32 `name`; | The name of the entry. |
guint32 `offset`; | If is_local is set, this is the offset of the blob in the typelib. Otherwise, it is the offset of the namespace in which the blob has to be looked up by name. |

### SimpleTypeBlobFlags

    typedef struct {
      guint reserved   : 8;
      guint reserved2  :16;
      guint pointer    : 1;
      guint reserved3  : 2;
      guint tag        : 5;
    } SimpleTypeBlobFlags;

TODO

#### Members

guint `reserved` : 8; | Reserved for future use. |
guint `reserved2` :16; | Reserved for future use. |
guint `pointer` : 1; | TODO |
guint `reserved3` : 2; | Reserved for future use. |
guint `tag` : 5; | A GITypeTag |

### SimpleTypeBlob

The SimpleTypeBlob is the general purpose "reference to a type" construct, used in method parameters, returns, callback definitions, fields, constants, etc. It's actually just a 32 bit integer which you can see from the union definition. This is for efficiency reasons, since there are so many references to types.

SimpleTypeBlob is divided into two cases; first, if "reserved" and "reserved2" are both zero, the type tag for a basic type is embedded in the "tag" bits. This allows e.g. GI_TYPE_TAG_UTF8, GI_TYPE_TAG_INT and the like to be embedded directly without taking up extra space.

References to "interfaces" (objects, interfaces) are more complicated; In this case, the integer is actually an offset into the directory (see above). Because the header is larger than 2^8=256 bits, all offsets will have one of the upper 24 bits set.

#### Members

SimpleTypeBlobFlags `flags`; | TODO |
guint32 `offset`; | Offset relative to header->types that points to a TypeBlob. Unlike other offsets, this is in words (ie 32bit units) rather than bytes. |

### ArgBlob

    typedef struct {
      guint32        name;

      guint          in                           : 1;
      guint          out                          : 1;
      guint          caller_allocates             : 1;
      guint          nullable                     : 1;
      guint          optional                     : 1;
      guint          transfer_ownership           : 1;
      guint          transfer_container_ownership : 1;
      guint          return_value                 : 1;
      guint          scope                        : 3;
      guint          skip                         : 1;
      guint          reserved                     :20;
      gint8          closure;
      gint8          destroy;

      guint16        padding;

      SimpleTypeBlob arg_type;
    } ArgBlob;

Types are specified by four bytes. If the three high bytes are zero, the low byte describes a basic type, otherwise the 32bit number is an offset which points to a TypeBlob.

#### Members

guint32 `name`; | A suggested name for the parameter. |
guint `in` : 1; | The parameter is an input to the function |
guint `out` : 1; | The parameter is used to return an output of the function. Parameters can be both in and out. Out parameters implicitly add another level of indirection to the parameter type. Ie if the type is uint32 in an out parameter, the function actually takes an uint32*. |
guint `caller_allocates` : 1; | The parameter is a pointer to a struct or object that will receive an output of the function. |
guint `nullable` : 1; | Only meaningful for types which are passed as pointers. For an in parameter, indicates if it is ok to pass NULL in. Gor an out parameter, indicates whether it may return NULL. Note that NULL is a valid GList and GSList value, thus allow_none will normally be set for parameters of these types. |
guint `optional` : 1; | For an out parameter, indicates that NULL may be passed in if the value is not needed. |
guint `transfer_ownership` : 1; | For an in parameter, indicates that the function takes over ownership of the parameter value. For an out parameter, it indicates that the caller is responsible for freeing the return value. |
guint `transfer_container_ownership` : 1; | For container types, indicates that the ownership of the container, but not of its contents is transferred. This is typically the case for out parameters returning lists of statically allocated things. |
guint `return_value` : 1; | The parameter should be considered the return value of the function. Only out parameters can be marked as return value, and there can be at most one per function call. If an out parameter is marked as return value, the actual return value of the function should be either void or a boolean indicating the success of the call. |
guint `scope` : 3; | A GIScopeType. If the parameter is of a callback type, this denotes the scope of the user_data and the callback function pointer itself (for languages that emit code at run-time). |
guint `skip` : 1; | Indicates that the parameter is only useful in C and should be skipped. |
guint `reserved` :20; | Reserved for future use. |
gint8 `closure`; | Index of the closure (user_data) parameter associated with the callback, or -1. |
gint8 `destroy`; | Index of the destroy notfication callback parameter associated with the callback, or -1. |
guint16 `padding`; | TODO |
SimpleTypeBlob `arg_type`; | Describes the type of the parameter. See details below. |

### SignatureBlob

    typedef struct {
      SimpleTypeBlob return_type;

      guint16        may_return_null              : 1;
      guint16        caller_owns_return_value     : 1;
      guint16        caller_owns_return_container : 1;
      guint16        skip_return                  : 1;
      guint16        instance_transfer_ownership  : 1;
      guint16        throws                       : 1;
      guint16        reserved                     :10;

      guint16        n_arguments;

      ArgBlob        arguments[];
    } SignatureBlob;

TODO

#### Members

SimpleTypeBlob `return_type`; | Describes the type of the return value. See details below. |
guint16 `may_return_null` : 1; | Only relevant for pointer types. Indicates whether the caller must expect NULL as a return value. |
guint16 `caller_owns_return_value` : 1; | If set, the caller is responsible for freeing the return value if it is no longer needed. |
guint16 `caller_owns_return_container` : 1; | This flag is only relevant if the return type is a container type. If the flag is set, the caller is resonsible for freeing the container, but not its contents. |
guint16 `skip_return` : 1; | Indicates that the return value is only useful in C and should be skipped. |
guint16 `instance_transfer_ownership` : 1; | When calling, the function assumes ownership of the instance parameter. |
guint16 `throws` : 1; | Denotes the signature takes an additional GError argument beyond the annotated arguments. |
guint16 `reserved` :10; | Reserved for future use. |
guint16 `n_arguments`; | The number of arguments that this function expects, also the length of the array of ArgBlobs. |
ArgBlob `arguments`[]; | An array of ArgBlob for the arguments of the function. |

### CommonBlob

    typedef struct {
      guint16 blob_type;  /* 1 */

      guint16 deprecated : 1;
      guint16 reserved   :15;
      guint32 name;
    } CommonBlob;

The CommonBlob is shared between FunctionBlob, CallbackBlob, SignalBlob.

TODO

#### Members

guint16 `blob_type`; | A GTypelibBlobType |
guint16 `deprecated` : 1; | Whether the blob is deprecated. |
guint16 `reserved` :15; | Reserved for future use. |
guint32 `name`; | The name of the blob. |

### FunctionBlob

    typedef struct {
      guint16 blob_type;  /* 1 */

      guint16 deprecated  : 1;
      guint16 setter      : 1;
      guint16 getter      : 1;
      guint16 constructor : 1;
      guint16 wraps_vfunc : 1;
      guint16 throws      : 1;
      guint16 index       :10;
      /* Note the bits above need to match CommonBlob
       * and are thus exhausted, extend things using
       * the reserved block below. */

      guint32 name;
      guint32 symbol;
      guint32 signature;

      guint16 is_static     : 1;
      guint16 is_async      : 1;
      guint16 sync_or_async : 10;
      guint16 reserved      : 4;

      guint16 finish        : 10;
      guint16 reserved2     : 6;
    } FunctionBlob;

TODO

#### Members

guint16 `blob_type`; | BLOB_TYPE_FUNCTION |
guint16 `deprecated` : 1; | The function is deprecated. |
guint16 `setter` : 1; | The function is a setter for a property. Language bindings may prefer to not bind individual setters and rely on the generic `g_object_set()`. |
guint16 `getter` : 1; | The function is a getter for a property. Language bindings may prefer to not bind individual getters and rely on the generic `g_object_get()`. |
guint16 `constructor` : 1; | The function acts as a constructor for the object it is contained in. |
guint16 `wraps_vfunc` : 1; | The function is a simple wrapper for a virtual function. |
guint16 `throws` : 1; | This is now additionally stored in the SignatureBlob. (deprecated) |
guint16 `index` :10; | Index of the property that this function is a setter or getter of in the array of properties of the containing interface, or index of the virtual function that this function wraps. |
guint32 `name`; | TODO |
guint32 `symbol`; | The symbol which can be used to obtain the function pointer with `dlsym()`. |
guint32 `signature`; | Offset of the SignatureBlob describing the parameter types and the return value type. |
guint16 `is_static` : 1; | The function is a "static method"; in other words it's a pure function whose name is conceptually scoped to the object. |
guint16 `is_async` : 1; |  |
guint16 `sync_or_async` : 10; |  |
guint16 `reserved` : 4; | Reserved for future use. |
guint16 `finish` : 10; |  |
guint16 `reserved2` : 6; | Reserved for future use. |

### CallbackBlob

    typedef struct {
      guint16 blob_type;  /* 2 */

      guint16 deprecated : 1;
      guint16 reserved   :15;
      guint32 name;
      guint32 signature;
    } CallbackBlob;

TODO

#### Members

guint16 `blob_type`; | TODO |
guint16 `deprecated` : 1; | TODO |
guint16 `reserved` :15; | Reserved for future use. |
guint32 `name`; | TODO |
guint32 `signature`; | Offset of the SignatureBlob describing the parameter types and the return value type. |

### InterfaceTypeBlob

    typedef struct {
      guint8  pointer  :1;
      guint8  reserved :2;
      guint8  tag      :5;
      guint8  reserved2;
      guint16 interface;
    } InterfaceTypeBlob;

If the interface is an enum of flags type, is_pointer is 0, otherwise it is 1.

#### Members

guint8 `pointer` :1; | Whether this type represents an indirection |
guint8 `reserved` :2; | Reserved for future use. |
guint8 `tag` :5; | A GITypeTag |
guint8 `reserved2`; | Reserved for future use. |
guint16 `interface`; | Index of the directory entry for the interface. |

### ArrayTypeDimension

TODO

#### Members

guint16 `length`; | TODO |
guint16 `size`; | TODO |

### ArrayTypeBlob

    typedef struct {
      guint16 pointer         :1;
      guint16 reserved        :2;
      guint16 tag             :5;

      guint16 zero_terminated :1;
      guint16 has_length      :1;
      guint16 has_size        :1;
      guint16 array_type      :2;
      guint16 reserved2       :3;

      ArrayTypeDimension dimensions;

      SimpleTypeBlob type;
    } ArrayTypeBlob;

TODO

#### Members

guint16 `pointer` :1; | TODO |
guint16 `reserved` :2; | Reserved for future use. |
guint16 `tag` :5; | TODO |
guint16 `zero_terminated` :1; | Indicates that the array must be terminated by a suitable NULL value. |
guint16 `has_length` :1; | Indicates that length points to a parameter specifying the length of the array. If both has_length and zero_terminated are set, the convention is to pass -1 for the length if the array is zero-terminated. |
guint16 `has_size` :1; | Indicates that size is the fixed size of the array. |
guint16 `array_type` :2; | Indicates whether this is a C array, GArray, GPtrArray, or GByteArray. If something other than a C array, the length and element size are implicit in the structure. |
guint16 `reserved2` :3; | Reserved for future use. |
ArrayTypeDimension `dimensions`; | TODO |
SimpleTypeBlob `type`; | TODO |

### ParamTypeBlob

    typedef struct {
      guint8	 pointer  :1;
      guint8	 reserved :2;
      guint8	 tag      :5;

      guint8	 reserved2;
      guint16	 n_types;

      SimpleTypeBlob type[];
    } ParamTypeBlob;

TODO

#### Members

guint8 `pointer` :1; | TODO |
guint8 `reserved` :2; | Reserved for future use. |
guint8 `tag` :5; | TODO |
guint8 `reserved2`; | Reserved for future use. |
guint16 `n_types`; | The number of parameter types to follow. |
SimpleTypeBlob `type`[]; | Describes the type of the list elements. |

### ErrorTypeBlob

    typedef struct {
      guint8  pointer  :1;
      guint8  reserved :2;
      guint8  tag      :5;

      guint8  reserved2;

      guint16 n_domains; /* Must be 0 */
      guint16 domains[];
    } ErrorTypeBlob;

TODO

#### Members

guint8 `pointer` :1; | TODO |
guint8 `reserved` :2; | TODO |
guint8 `tag` :5; | TODO |
guint8 `reserved2`; | TODO |
guint16 `n_domains`; | TODO: must be 0 |
guint16 `domains`[]; | TODO |

### ValueBlob

    typedef struct {
      guint32 deprecated : 1;
      guint32 unsigned_value : 1;
      guint32 reserved   :30;
      guint32 name;
      gint32 value;
    } ValueBlob;

Values commonly occur in enums and flags.

#### Members

guint32 `deprecated` : 1; | Whether this value is deprecated |
guint32 `unsigned_value` : 1; | if set, value is a 32-bit unsigned integer cast to gint32 |
guint32 `reserved` :30; | Reserved for future use. |
guint32 `name`; | Name of blob |
gint32 `value`; | The numerical value |

### FieldBlob

    typedef struct {
      guint32        name;

      guint8         readable :1;
      guint8         writable :1;
      guint8         has_embedded_type :1;
      guint8         reserved :5;
      guint8         bits;

      guint16        struct_offset;

      guint32        reserved2;

      SimpleTypeBlob type;
    } FieldBlob;

TODO

#### Members

guint32 `name`; | The name of the field. |
guint8 `readable` :1; | TODO |
guint8 `writable` :1; | How the field may be accessed. |
guint8 `has_embedded_type` :1; | An anonymous type follows the FieldBlob. |
guint8 `reserved` :5; | Reserved for future use. |
guint8 `bits`; | If this field is part of a bitfield, the number of bits which it uses, otherwise 0. |
guint16 `struct_offset`; | The offset of the field in the struct. The value 0xFFFF indicates that the struct offset is unknown. |
guint32 `reserved2`; | Reserved for future use. |
SimpleTypeBlob `type`; | The type of the field. |

### RegisteredTypeBlob

    typedef struct {
      guint16 blob_type;
      guint16 deprecated   : 1;
      guint16 unregistered : 1;
      guint16 reserved :14;
      guint32 name;

      guint32 gtype_name;
      guint32 gtype_init;
    } RegisteredTypeBlob;

TODO

#### Members

guint16 `blob_type`; | TODO |
guint16 `deprecated` : 1; | TODO |
guint16 `unregistered` : 1; | TODO |
guint16 `reserved` :14; | Reserved for future use. |
guint32 `name`; | TODO |
guint32 `gtype_name`; | The name under which the type is registered with GType. |
guint32 `gtype_init`; | The symbol name of the get_type() function which registers the type. |

### StructBlob

    typedef struct {
      guint16   blob_type;

      guint16   deprecated   : 1;
      guint16   unregistered : 1;
      guint16   is_gtype_struct : 1;
      guint16   alignment    : 6;
      guint16   foreign      : 1;
      guint16   reserved     : 6;

      guint32   name;

      guint32   gtype_name;
      guint32   gtype_init;

      guint32   size;

      guint16   n_fields;
      guint16   n_methods;

      guint32   copy_func;
      guint32   free_func;
    } StructBlob;

TODO

#### Members

guint16 `blob_type`; | BLOB_TYPE_STRUCT |
guint16 `deprecated` : 1; | Whether this structure is deprecated |
guint16 `unregistered` : 1; | If this is set, the type is not registered with GType. |
guint16 `is_gtype_struct` : 1; | Whether this structure is the class or interface layout for a GObject |
guint16 `alignment` : 6; | The byte boundary that the struct is aligned to in memory |
guint16 `foreign` : 1; | If the type is foreign, eg if it's expected to be overridden by a native language binding instead of relying of introspected bindings. |
guint16 `reserved` : 6; | Reserved for future use. |
guint32 `name`; | TODO |
guint32 `gtype_name`; | String name of the associated GType |
guint32 `gtype_init`; | String naming the symbol which gets the runtime GType |
guint32 `size`; | The size of the struct in bytes. |
guint16 `n_fields`; | TODO |
guint16 `n_methods`; | TODO |
guint32 `copy_func`; | String pointing to a function which can be called to copy the contents of this struct type |
guint32 `free_func`; | String pointing to a function which can be called to free the contents of this struct type |

### UnionBlob

    typedef struct {
      guint16      blob_type;
      guint16      deprecated    : 1;
      guint16      unregistered  : 1;
      guint16      discriminated : 1;
      guint16      alignment     : 6;
      guint16      reserved      : 7;
      guint32      name;

      guint32      gtype_name;
      guint32      gtype_init;

      guint32      size;

      guint16      n_fields;
      guint16      n_functions;

      guint32      copy_func;
      guint32      free_func;

      gint32       discriminator_offset;
      SimpleTypeBlob discriminator_type;
    } UnionBlob;

TODO

#### Members

guint16 `blob_type`; | TODO |
guint16 `deprecated` : 1; | TODO |
guint16 `unregistered` : 1; | If this is set, the type is not registered with GType. |
guint16 `discriminated` : 1; | Is set if the union is discriminated |
guint16 `alignment` : 6; | The byte boundary that the union is aligned to in memory |
guint16 `reserved` : 7; | Reserved for future use. |
guint32 `name`; | TODO |
guint32 `gtype_name`; | String name of the associated GType |
guint32 `gtype_init`; | String naming the symbol which gets the runtime GType |
guint32 `size`; | TODO |
guint16 `n_fields`; | Length of the arrays |
guint16 `n_functions`; | TODO |
guint32 `copy_func`; | String pointing to a function which can be called to copy the contents of this union type |
guint32 `free_func`; | String pointing to a function which can be called to free the contents of this union type |
gint32 `discriminator_offset`; | Offset from the beginning of the union where the discriminator of a discriminated union is located. The value 0xFFFF indicates that the discriminator offset is unknown. |
SimpleTypeBlob `discriminator_type`; | Type of the discriminator |

### EnumBlob

    typedef struct {
      guint16   blob_type;

      guint16   deprecated   : 1;
      guint16   unregistered : 1;
      guint16   storage_type : 5;
      guint16   reserved     : 9;

      guint32   name;

      guint32   gtype_name;
      guint32   gtype_init;

      guint16   n_values;
      guint16   n_methods;

      guint32   error_domain;

      ValueBlob values[];
    } EnumBlob;

TODO

#### Members

guint16 `blob_type`; | TODO |
guint16 `deprecated` : 1; | TODO |
guint16 `unregistered` : 1; | If this is set, the type is not registered with GType. |
guint16 `storage_type` : 5; | The tag of the type used for the enum in the C ABI (will be a signed or unsigned integral type) |
guint16 `reserved` : 9; | Reserved for future use. |
guint32 `name`; | TODO |
guint32 `gtype_name`; | String name of the associated GType |
guint32 `gtype_init`; | String naming the symbol which gets the runtime GType |
guint16 `n_values`; | The length of the values array. |
guint16 `n_methods`; | The length of the methods array. |
guint32 `error_domain`; | String naming the GError domain this enum is associated with |
ValueBlob `values`[]; | TODO |

### PropertyBlob

    typedef struct {
      guint32        name;

      guint32        deprecated                   : 1;
      guint32        readable                     : 1;
      guint32        writable                     : 1;
      guint32        construct                    : 1;
      guint32        construct_only               : 1;
      guint32        transfer_ownership           : 1;
      guint32        transfer_container_ownership : 1;
      guint32        setter                       :10;
      guint32        getter                       :10;
      guint32        reserved                     : 5;

      guint32        reserved2;

      SimpleTypeBlob type;
    } PropertyBlob;

TODO

#### Members

guint32 `name`; | The name of the property. |
guint32 `deprecated` : 1; | TODO |
guint32 `readable` : 1; | TODO |
guint32 `writable` : 1; | TODO |
guint32 `construct` : 1; | TODO |
guint32 `construct_only` : 1; | The ParamFlags used when registering the property. |
guint32 `transfer_ownership` : 1; | When writing, the type containing the property takes ownership of the value. When reading, the returned value needs to be released by the caller. |
guint32 `transfer_container_ownership` : 1; | For container types indicates that the ownership of the container, but not of its contents, is transferred. This is typically the case when reading lists of statically allocated things. |
guint32 `setter` :10; | the index of the setter function for this property, if `writable` is set; if the method is not known, the value will be set to `ACCESSOR_SENTINEL` |
guint32 `getter` :10; | ths index of the getter function for this property, if `readable` is set; if the method is not known, the value will be set to `ACCESSOR_SENTINEL` |
guint32 `reserved` : 5; | Reserved for future use. |
guint32 `reserved2`; | Reserved for future use. |
SimpleTypeBlob `type`; | Describes the type of the property. |

### SignalBlob

    typedef struct {
      guint16 deprecated        : 1;
      guint16 run_first         : 1;
      guint16 run_last          : 1;
      guint16 run_cleanup       : 1;
      guint16 no_recurse        : 1;
      guint16 detailed          : 1;
      guint16 action            : 1;
      guint16 no_hooks          : 1;
      guint16 has_class_closure : 1;
      guint16 true_stops_emit   : 1;
      guint16 reserved          : 6;

      guint16 class_closure;

      guint32 name;

      guint32 reserved2;

      guint32 signature;
    } SignalBlob;

TODO

#### Members

guint16 `deprecated` : 1; | TODO |
guint16 `run_first` : 1; | TODO |
guint16 `run_last` : 1; | TODO |
guint16 `run_cleanup` : 1; | TODO |
guint16 `no_recurse` : 1; | TODO |
guint16 `detailed` : 1; | TODO |
guint16 `action` : 1; | TODO |
guint16 `no_hooks` : 1; | The flags used when registering the signal. |
guint16 `has_class_closure` : 1; | Set if the signal has a class closure. |
guint16 `true_stops_emit` : 1; | Whether the signal has true-stops-emit semantics |
guint16 `reserved` : 6; | Reserved for future use. |
guint16 `class_closure`; | The index of the class closure in the list of virtual functions of the object or interface on which the signal is defined. |
guint32 `name`; | The name of the signal. |
guint32 `reserved2`; | Reserved for future use. |
guint32 `signature`; | Offset of the SignatureBlob describing the parameter types and the return value type. |

### VFuncBlob

    typedef struct {
      guint32 name;

      guint16 must_chain_up           : 1;
      guint16 must_be_implemented     : 1;
      guint16 must_not_be_implemented : 1;
      guint16 class_closure           : 1;
      guint16 throws                  : 1;
      guint16 is_async                : 1;
      guint16 sync_or_async           : 10;
      guint16 signal;

      guint16 struct_offset;
      guint16 invoker : 10; /* Number of bits matches @index in FunctionBlob */
      guint16 reserved : 6;

      guint16 finish                  : 10;
      guint16 reserved2               : 6;
      guint16 reserved3               : 16;

      guint32 signature;
    } VFuncBlob;

TODO

#### Members

guint32 `name`; | The name of the virtual function. |
guint16 `must_chain_up` : 1; | If set, every implementation of this virtual function must chain up to the implementation of the parent class. |
guint16 `must_be_implemented` : 1; | If set, every derived class must override this virtual function. |
guint16 `must_not_be_implemented` : 1; | If set, derived class must not override this virtual function. |
guint16 `class_closure` : 1; | Set if this virtual function is the class closure of a signal. |
guint16 `throws` : 1; | This is now additionally stored in the SignatureBlob. (deprecated) |
guint16 `is_async` : 1; |  |
guint16 `sync_or_async` : 10; |  |
guint16 `signal`; | The index of the signal in the list of signals of the object or interface to which this virtual function belongs. |
guint16 `struct_offset`; | The offset of the function pointer in the class struct. The value 0xFFFF indicates that the struct offset is unknown. |
guint16 `invoker` : 10; | If a method invoker for this virtual exists, this is the offset in the class structure of the method. If no method is known, this value will be 0x3ff. |
guint16 `reserved` : 6; | Reserved for future use. |
guint16 `finish` : 10; |  |
guint16 `reserved2` : 6; | Reserved for future use. |
guint16 `reserved3` : 16; | Reserved for future use. |
guint32 `signature`; | Offset of the SignatureBlob describing the parameter types and the return value type. |

### ObjectBlob

    typedef struct {
      guint16   blob_type;  /* 7 */
      guint16   deprecated   : 1;
      guint16   abstract     : 1;
      guint16   fundamental  : 1;
      guint16   final_       : 1;
      guint16   reserved     :12;
      guint32   name;

      guint32   gtype_name;
      guint32   gtype_init;

      guint16   parent;
      guint16   gtype_struct;

      guint16   n_interfaces;
      guint16   n_fields;
      guint16   n_properties;
      guint16   n_methods;
      guint16   n_signals;
      guint16   n_vfuncs;
      guint16   n_constants;
      guint16   n_field_callbacks;

      guint32   ref_func;
      guint32   unref_func;
      guint32   set_value_func;
      guint32   get_value_func;

      guint32   reserved3;
      guint32   reserved4;

      guint16   interfaces[];
    } ObjectBlob;

TODO

#### Members

guint16 `blob_type`; | BLOB_TYPE_OBJECT |
guint16 `deprecated` : 1; | whether the type is deprecated |
guint16 `abstract` : 1; | whether the type can be instantiated |
guint16 `fundamental` : 1; | this object is not a GObject derived type, instead it's an additional fundamental type. |
guint16 `final_` : 1; | whether the type can be derived |
guint16 `reserved` :12; | Reserved for future use. |
guint32 `name`; | TODO |
guint32 `gtype_name`; | String name of the associated GType |
guint32 `gtype_init`; | String naming the symbol which gets the runtime GType |
guint16 `parent`; | The directory index of the parent type. This is only set for objects. If an object does not have a parent, it is zero. |
guint16 `gtype_struct`; | TODO |
guint16 `n_interfaces`; | TODO |
guint16 `n_fields`; | TODO |
guint16 `n_properties`; | TODO |
guint16 `n_methods`; | TODO |
guint16 `n_signals`; | TODO |
guint16 `n_vfuncs`; | TODO |
guint16 `n_constants`; | The lengths of the arrays.Up to 16bits of padding may be inserted between the arrays to ensure that they start on a 32bit boundary. |
guint16 `n_field_callbacks`; | The number of n_fields which are also callbacks. This is used to calculate the fields section size in constant time. |
guint32 `ref_func`; | String pointing to a function which can be called to increase the reference count for an instance of this object type. |
guint32 `unref_func`; | String pointing to a function which can be called to decrease the reference count for an instance of this object type. |
guint32 `set_value_func`; | String pointing to a function which can be called to convert a pointer of this object to a GValue |
guint32 `get_value_func`; | String pointing to a function which can be called to convert extract a pointer to this object from a GValue |
guint32 `reserved3`; | Reserved for future use. |
guint32 `reserved4`; | Reserved for future use. |
guint16 `interfaces`[]; | An array of indices of directory entries for the implemented interfaces. |

### InterfaceBlob

    typedef struct {
      guint16 blob_type;
      guint16 deprecated   : 1;
      guint16 reserved     :15;
      guint32 name;

      guint32 gtype_name;
      guint32 gtype_init;
      guint16 gtype_struct;

      guint16 n_prerequisites;
      guint16 n_properties;
      guint16 n_methods;
      guint16 n_signals;
      guint16 n_vfuncs;
      guint16 n_constants;

      guint16 padding;

      guint32 reserved2;
      guint32 reserved3;

      guint16 prerequisites[];
    } InterfaceBlob;

TODO

#### Members

guint16 `blob_type`; | TODO |
guint16 `deprecated` : 1; | TODO |
guint16 `reserved` :15; | Reserved for future use. |
guint32 `name`; | TODO |
guint32 `gtype_name`; | TODO |
guint32 `gtype_init`; | TODO |
guint16 `gtype_struct`; | Name of the interface "class" C structure |
guint16 `n_prerequisites`; | Number of prerequisites |
guint16 `n_properties`; | Number of properties |
guint16 `n_methods`; | Number of methods |
guint16 `n_signals`; | Number of signals |
guint16 `n_vfuncs`; | Number of virtual functions |
guint16 `n_constants`; | The lengths of the arrays. Up to 16bits of padding may be inserted between the arrays to ensure that they start on a 32bit boundary. |
guint16 `padding`; | TODO |
guint32 `reserved2`; | Reserved for future use. |
guint32 `reserved3`; | Reserved for future use. |
guint16 `prerequisites`[]; | An array of indices of directory entries for required interfaces. |

### ConstantBlob

    typedef struct {
      guint16        blob_type;
      guint16        deprecated   : 1;
      guint16        reserved     :15;
      guint32        name;

      SimpleTypeBlob type;

      guint32        size;
      guint32        offset;

      guint32        reserved2;
    } ConstantBlob;

TODO

#### Members

guint16 `blob_type`; | TODO |
guint16 `deprecated` : 1; | TODO |
guint16 `reserved` :15; | Reserved for future use. |
guint32 `name`; | TODO |
SimpleTypeBlob `type`; | The type of the value. In most cases this should be a numeric type or string. |
guint32 `size`; | The size of the value in bytes. |
guint32 `offset`; | The offset of the value in the typelib. |
guint32 `reserved2`; | Reserved for future use. |

### AttributeBlob

    typedef struct {
      guint32 offset;
      guint32 name;
      guint32 value;
    } AttributeBlob;

TODO

#### Members

guint32 `offset`; | The offset of the typelib entry to which this attribute refers. Attributes are kept sorted by offset, so that the attributes of an entry can be found by a binary search. |
guint32 `name`; | The name of the attribute, a string. |
guint32 `value`; | The value of the attribute (also a string) |

### enum GITypelibError

A error set while validating the GITypelib

#### Members

G_TYPELIB_ERROR_INVALID | the typelib is invalid |
G_TYPELIB_ERROR_INVALID_HEADER | the typelib header is invalid |
G_TYPELIB_ERROR_INVALID_DIRECTORY | the typelib directory is invalid |
G_TYPELIB_ERROR_INVALID_ENTRY | a typelib entry is invalid |
G_TYPELIB_ERROR_INVALID_BLOB | a typelib blob is invalid |

### G_TYPELIB_ERROR

    #define G_TYPELIB_ERROR (g_typelib_error_quark ())

TODO

### GITypelibHashBuilder

    typedef struct _GITypelibHashBuilder GITypelibHashBuilder;

TODO