xmlns:c="http://www.gtk.org/introspection/c/1.0"
xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
<namespace name="cairo" version="1.0">
- <record name="Context" c:type="cairo_t"/>
+ <record name="Context" c:type="cairo_t" foreign-type="1"/>
<record name="Surface" c:type="cairo_surface_t"/>
<record name="Matrix" c:type="cairo_matrix_t"/>
<record name="Pattern" c:type="cairo_pattern_t"/>
GString *parent_str;
GType parent;
gboolean first = TRUE;
-
+
parent = type;
parent_str = g_string_new ("");
do
g_string_append_c (parent_str, ',');
g_string_append (parent_str, g_type_name (parent));
} while (parent != G_TYPE_OBJECT && parent != G_TYPE_INVALID);
-
+
escaped_printf (out, " parents=\"%s\"", parent_str->str);
-
+
g_string_free (parent_str, TRUE);
}
GTypelib *typelib;
guint32 offset;
-
+
guint32 type_is_embedded : 1; /* Used by GITypeInfo */
guint32 reserved : 31;
-
+
gpointer reserved2[4];
};
GIInfoType type,
GIRepository *repository,
GIBaseInfo *container,
- GTypelib *typelib,
+ GTypelib *typelib,
guint32 offset)
{
memset (info, 0, sizeof (GIRealInfo));
g_info_new_full (GIInfoType type,
GIRepository *repository,
GIBaseInfo *container,
- GTypelib *typelib,
+ GTypelib *typelib,
guint32 offset)
{
GIRealInfo *info;
g_return_val_if_fail (container != NULL || repository != NULL, NULL);
info = g_new (GIRealInfo, 1);
-
+
g_info_init (info, type, repository, container, typelib, offset);
info->ref_count = 1;
GIBaseInfo *
g_info_new (GIInfoType type,
GIBaseInfo *container,
- GTypelib *typelib,
+ GTypelib *typelib,
guint32 offset)
{
return g_info_new_full (type, ((GIRealInfo*)container)->repository, container, typelib, offset);
GIInfoType
g_base_info_get_type (GIBaseInfo *info)
{
-
+
return ((GIRealInfo*)info)->type;
}
case GI_INFO_TYPE_FIELD:
{
FieldBlob *blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
return g_typelib_get_string (rinfo->typelib, blob->name);
}
break;
case GI_INFO_TYPE_ARG:
{
ArgBlob *blob = (ArgBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
return g_typelib_get_string (rinfo->typelib, blob->name);
}
break;
if (rinfo->type == GI_INFO_TYPE_UNRESOLVED)
{
GIUnresolvedInfo *unresolved = (GIUnresolvedInfo *)info;
-
+
return unresolved->namespace;
}
return g_typelib_get_string (rinfo->typelib, header->namespace);
}
-gboolean
+gboolean
g_base_info_is_deprecated (GIBaseInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo*) info;
default: ;
/* no deprecation flag for these */
}
-
+
return FALSE;
}
{
const AttributeBlob *a = av;
const AttributeBlob *b = bv;
-
+
if (a->offset < b->offset)
return -1;
else if (a->offset == b->offset)
AttributeBlob blob, *first, *res, *previous;
blob.offset = rinfo->offset;
-
+
first = (AttributeBlob *) &rinfo->typelib->data[header->attributes];
res = bsearch (&blob, first, header->n_attributes,
GIFunctionInfoFlags flags;
GIRealInfo *rinfo = (GIRealInfo *)info;
FunctionBlob *blob = (FunctionBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
flags = 0;
/* Make sure we don't flag Constructors as methods */
if (!blob->constructor && !blob->is_static)
flags = flags | GI_FUNCTION_IS_METHOD;
-
+
if (blob->constructor)
flags = flags | GI_FUNCTION_IS_CONSTRUCTOR;
GIRealInfo *rinfo = (GIRealInfo *)info;
FunctionBlob *blob = (FunctionBlob *)&rinfo->typelib->data[rinfo->offset];
GIInterfaceInfo *container = (GIInterfaceInfo *)rinfo->container;
-
- return g_interface_info_get_property (container, blob->index);
+
+ return g_interface_info_get_property (container, blob->index);
}
GIVFuncInfo *
GIRealInfo *rinfo = (GIRealInfo*)info;
FunctionBlob *blob = (FunctionBlob *)&rinfo->typelib->data[rinfo->offset];
GIInterfaceInfo *container = (GIInterfaceInfo *)rinfo->container;
-
- return g_interface_info_get_vfunc (container, blob->index);
+
+ return g_interface_info_get_vfunc (container, blob->index);
}
/* GICallableInfo functions */
{
GIRealInfo *rinfo = (GIRealInfo*)container;
SimpleTypeBlob *type = (SimpleTypeBlob *)&typelib->data[offset];
-
+
g_info_init ((GIRealInfo*)info, GI_INFO_TYPE_TYPE, rinfo->repository, container, typelib,
(type->flags.reserved == 0 && type->flags.reserved2 == 0) ? offset : type->offset);
}
*
* Returns: The number of arguments this callable expects.
*/
-gint
+gint
g_callable_info_get_n_args (GICallableInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
gint offset;
offset = signature_offset (info);
-
- return (GIArgInfo *) g_info_new (GI_INFO_TYPE_ARG, (GIBaseInfo*)info, rinfo->typelib,
+
+ return (GIArgInfo *) g_info_new (GI_INFO_TYPE_ARG, (GIBaseInfo*)info, rinfo->typelib,
offset + header->signature_blob_size + n * header->arg_blob_size);
}
gint offset;
offset = signature_offset (info);
-
- g_info_init ((GIRealInfo*)arg, GI_INFO_TYPE_ARG, rinfo->repository, (GIBaseInfo*)info, rinfo->typelib,
- offset + header->signature_blob_size + n * header->arg_blob_size);
+
+ g_info_init ((GIRealInfo*)arg, GI_INFO_TYPE_ARG, rinfo->repository, (GIBaseInfo*)info, rinfo->typelib,
+ offset + header->signature_blob_size + n * header->arg_blob_size);
}
/* GIArgInfo function */
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ArgBlob *blob = (ArgBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
if (blob->in && blob->out)
return GI_DIRECTION_INOUT;
else if (blob->out)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ArgBlob *blob = (ArgBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
return blob->return_value;
}
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ArgBlob *blob = (ArgBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
return blob->dipper;
}
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ArgBlob *blob = (ArgBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
return blob->optional;
}
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ArgBlob *blob = (ArgBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
return blob->allow_none;
}
g_arg_info_get_type (GIArgInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
-
+
return g_type_info_new ((GIBaseInfo*)info, rinfo->typelib, rinfo->offset + G_STRUCT_OFFSET (ArgBlob, arg_type));
}
GITypeInfo *type)
{
GIRealInfo *rinfo = (GIRealInfo*) info;
- g_type_info_init (type, (GIBaseInfo*)info, rinfo->typelib, rinfo->offset + G_STRUCT_OFFSET (ArgBlob, arg_type));
+ g_type_info_init (type, (GIBaseInfo*)info, rinfo->typelib, rinfo->offset + G_STRUCT_OFFSET (ArgBlob, arg_type));
}
/* GITypeInfo functions */
{
GIRealInfo *rinfo = (GIRealInfo *)info;
SimpleTypeBlob *type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
if (type->flags.reserved == 0 && type->flags.reserved2 == 0)
return type->flags.pointer;
else
{
InterfaceTypeBlob *iface = (InterfaceTypeBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
return iface->pointer;
}
}
{
GIRealInfo *rinfo = (GIRealInfo *)info;
SimpleTypeBlob *type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0))
{
ParamTypeBlob *param = (ParamTypeBlob *)&rinfo->typelib->data[rinfo->offset];
switch (param->tag)
{
- case GI_TYPE_TAG_ARRAY:
+ case GI_TYPE_TAG_ARRAY:
case GI_TYPE_TAG_GLIST:
case GI_TYPE_TAG_GSLIST:
case GI_TYPE_TAG_GHASH:
{
GIRealInfo *rinfo = (GIRealInfo *)info;
SimpleTypeBlob *type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0))
{
ArrayTypeBlob *blob = (ArrayTypeBlob *)&rinfo->typelib->data[rinfo->offset];
{
GIRealInfo *rinfo = (GIRealInfo *)info;
SimpleTypeBlob *type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0))
{
ArrayTypeBlob *blob = (ArrayTypeBlob *)&rinfo->typelib->data[rinfo->offset];
{
GIRealInfo *rinfo = (GIRealInfo *)info;
SimpleTypeBlob *type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0))
{
ArrayTypeBlob *blob = (ArrayTypeBlob *)&rinfo->typelib->data[rinfo->offset];
{
GIRealInfo *rinfo = (GIRealInfo *)info;
SimpleTypeBlob *type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0))
{
ErrorTypeBlob *blob = (ErrorTypeBlob *)&rinfo->typelib->data[rinfo->offset];
{
GIRealInfo *rinfo = (GIRealInfo *)info;
SimpleTypeBlob *type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0))
{
ErrorTypeBlob *blob = (ErrorTypeBlob *)&rinfo->typelib->data[rinfo->offset];
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ErrorDomainBlob *blob = (ErrorDomainBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
return (GIInterfaceInfo *) g_info_from_entry (rinfo->repository,
rinfo->typelib, blob->error_codes);
}
-/* GIValueInfo functions */
+/* GIValueInfo functions */
glong
g_value_info_get_value (GIValueInfo *info)
{
{
GIRealInfo *rinfo = (GIRealInfo *)info;
FieldBlob *blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
return blob->bits;
}
{
GIRealInfo *rinfo = (GIRealInfo *)info;
FieldBlob *blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
return blob->struct_offset;
}
GType (* get_type_func) (void);
GIRealInfo *rinfo = (GIRealInfo*)info;
- type_init = g_registered_type_info_get_type_init (info);
-
+ type_init = g_registered_type_info_get_type_init (info);
+
if (type_init == NULL)
return G_TYPE_NONE;
else if (!strcmp (type_init, "intern"))
return G_TYPE_OBJECT;
-
+
get_type_func = NULL;
if (!g_typelib_symbol (rinfo->typelib,
type_init,
(void**) &get_type_func))
return G_TYPE_NONE;
-
+
return (* get_type_func) ();
}
{
GIRealInfo *rinfo = (GIRealInfo *)info;
StructBlob *blob = (StructBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
return blob->n_fields;
}
gint n)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
-
- return (GIFieldInfo *) g_info_new (GI_INFO_TYPE_FIELD, (GIBaseInfo*)info, rinfo->typelib,
+
+ return (GIFieldInfo *) g_info_new (GI_INFO_TYPE_FIELD, (GIBaseInfo*)info, rinfo->typelib,
g_struct_get_field_offset (info, n));
}
{
GIRealInfo *rinfo = (GIRealInfo *)info;
StructBlob *blob = (StructBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
return blob->n_methods;
}
{
GIRealInfo *rinfo = (GIRealInfo *)info;
StructBlob *blob = (StructBlob *)&rinfo->typelib->data[rinfo->offset];
- Header *header = (Header *)rinfo->typelib->data;
+ Header *header = (Header *)rinfo->typelib->data;
gint offset;
offset = g_struct_get_field_offset (info, blob->n_fields) + n * header->function_blob_size;
- return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, (GIBaseInfo*)info,
+ return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, (GIBaseInfo*)info,
rinfo->typelib, offset);
}
{
/* FIXME hash */
GIRealInfo *rinfo = (GIRealInfo*)base;
- Header *header = (Header *)rinfo->typelib->data;
+ Header *header = (Header *)rinfo->typelib->data;
gint i;
for (i = 0; i < n_methods; i++)
const gchar *fname = (const gchar *)&rinfo->typelib->data[fblob->name];
if (strcmp (name, fname) == 0)
- return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, base,
- rinfo->typelib, offset);
-
+ return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, base,
+ rinfo->typelib, offset);
+
offset += header->function_blob_size;
}
-
+
return NULL;
}
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
- Header *header = (Header *)rinfo->typelib->data;
+ Header *header = (Header *)rinfo->typelib->data;
StructBlob *blob = (StructBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->struct_blob_size
/**
* g_struct_info_is_gtype_struct:
* @info: GIStructInfo
- *
+ *
* Return true if this structure represents the "class structure" for some
* #GObject or #GInterface. This function is mainly useful to hide this kind of structure
* from generated public APIs.
gint n)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
- Header *header = (Header *)rinfo->typelib->data;
+ Header *header = (Header *)rinfo->typelib->data;
gint offset;
- offset = rinfo->offset + header->enum_blob_size
+ offset = rinfo->offset + header->enum_blob_size
+ n * header->value_blob_size;
return (GIValueInfo *) g_info_new (GI_INFO_TYPE_VALUE, (GIBaseInfo*)info, rinfo->typelib, offset);
}
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
- Header *header = (Header *)rinfo->typelib->data;
+ Header *header = (Header *)rinfo->typelib->data;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
offset = rinfo->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
+ n * header->field_blob_size;
-
+
return (GIFieldInfo *) g_info_new (GI_INFO_TYPE_FIELD, (GIBaseInfo*)info, rinfo->typelib, offset);
}
GIRealInfo *rinfo = (GIRealInfo *)info;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
- return blob->n_properties;
+ return blob->n_properties;
}
GIPropertyInfo *
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
- Header *header = (Header *)rinfo->typelib->data;
+ Header *header = (Header *)rinfo->typelib->data;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
offset = rinfo->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
+ blob->n_fields * header->field_blob_size
+ n * header->property_blob_size;
- return (GIPropertyInfo *) g_info_new (GI_INFO_TYPE_PROPERTY, (GIBaseInfo*)info,
+ return (GIPropertyInfo *) g_info_new (GI_INFO_TYPE_PROPERTY, (GIBaseInfo*)info,
rinfo->typelib, offset);
}
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
- Header *header = (Header *)rinfo->typelib->data;
+ Header *header = (Header *)rinfo->typelib->data;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
offset = rinfo->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
+ blob->n_fields * header->field_blob_size
+ blob->n_properties * header->property_blob_size
+ n * header->function_blob_size;
- return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, (GIBaseInfo*)info,
- rinfo->typelib, offset);
+ return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, (GIBaseInfo*)info,
+ rinfo->typelib, offset);
}
GIFunctionInfo *
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
- Header *header = (Header *)rinfo->typelib->data;
+ Header *header = (Header *)rinfo->typelib->data;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->object_blob_size
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
- Header *header = (Header *)rinfo->typelib->data;
+ Header *header = (Header *)rinfo->typelib->data;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
offset = rinfo->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
+ blob->n_fields * header->field_blob_size
+ blob->n_properties * header->property_blob_size
- + blob->n_methods * header->function_blob_size
+ + blob->n_methods * header->function_blob_size
+ n * header->signal_blob_size;
- return (GISignalInfo *) g_info_new (GI_INFO_TYPE_SIGNAL, (GIBaseInfo*)info,
- rinfo->typelib, offset);
+ return (GISignalInfo *) g_info_new (GI_INFO_TYPE_SIGNAL, (GIBaseInfo*)info,
+ rinfo->typelib, offset);
}
gint
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
return blob->n_vfuncs;
}
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
- Header *header = (Header *)rinfo->typelib->data;
+ Header *header = (Header *)rinfo->typelib->data;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
offset = rinfo->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
+ blob->n_fields * header->field_blob_size
+ blob->n_properties * header->property_blob_size
- + blob->n_methods * header->function_blob_size
- + blob->n_signals * header->signal_blob_size
+ + blob->n_methods * header->function_blob_size
+ + blob->n_signals * header->signal_blob_size
+ n * header->vfunc_blob_size;
- return (GIVFuncInfo *) g_info_new (GI_INFO_TYPE_VFUNC, (GIBaseInfo*)info,
- rinfo->typelib, offset);
+ return (GIVFuncInfo *) g_info_new (GI_INFO_TYPE_VFUNC, (GIBaseInfo*)info,
+ rinfo->typelib, offset);
}
static GIVFuncInfo *
{
GIRealInfo *rinfo = (GIRealInfo *)info;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
return blob->n_constants;
}
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
- Header *header = (Header *)rinfo->typelib->data;
+ Header *header = (Header *)rinfo->typelib->data;
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
offset = rinfo->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
+ blob->n_fields * header->field_blob_size
+ blob->n_properties * header->property_blob_size
- + blob->n_methods * header->function_blob_size
- + blob->n_signals * header->signal_blob_size
- + blob->n_vfuncs * header->vfunc_blob_size
+ + blob->n_methods * header->function_blob_size
+ + blob->n_signals * header->signal_blob_size
+ + blob->n_vfuncs * header->vfunc_blob_size
+ n * header->constant_blob_size;
- return (GIConstantInfo *) g_info_new (GI_INFO_TYPE_CONSTANT, (GIBaseInfo*)info,
- rinfo->typelib, offset);
+ return (GIConstantInfo *) g_info_new (GI_INFO_TYPE_CONSTANT, (GIBaseInfo*)info,
+ rinfo->typelib, offset);
}
/**
* g_object_info_get_class_struct:
* @info: A #GIObjectInfo to query
- *
+ *
* Every #GObject has two structures; an instance structure and a class
* structure. This function returns the metadata for the class structure.
*
GIRealInfo *rinfo = (GIRealInfo *)info;
InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
- return blob->n_properties;
+ return blob->n_properties;
}
GIPropertyInfo *
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
- Header *header = (Header *)rinfo->typelib->data;
+ Header *header = (Header *)rinfo->typelib->data;
InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
offset = rinfo->offset + header->interface_blob_size
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
+ n * header->property_blob_size;
- return (GIPropertyInfo *) g_info_new (GI_INFO_TYPE_PROPERTY, (GIBaseInfo*)info,
+ return (GIPropertyInfo *) g_info_new (GI_INFO_TYPE_PROPERTY, (GIBaseInfo*)info,
rinfo->typelib, offset);
}
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
- Header *header = (Header *)rinfo->typelib->data;
+ Header *header = (Header *)rinfo->typelib->data;
InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
offset = rinfo->offset + header->interface_blob_size
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
- + blob->n_properties * header->property_blob_size
+ + blob->n_properties * header->property_blob_size
+ n * header->function_blob_size;
-
- return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, (GIBaseInfo*)info,
- rinfo->typelib, offset);
+
+ return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, (GIBaseInfo*)info,
+ rinfo->typelib, offset);
}
GIFunctionInfo *
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
- Header *header = (Header *)rinfo->typelib->data;
+ Header *header = (Header *)rinfo->typelib->data;
InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->interface_blob_size
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
- Header *header = (Header *)rinfo->typelib->data;
+ Header *header = (Header *)rinfo->typelib->data;
InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
-
- offset = rinfo->offset + header->interface_blob_size
+
+ offset = rinfo->offset + header->interface_blob_size
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
- + blob->n_properties * header->property_blob_size
- + blob->n_methods * header->function_blob_size
+ + blob->n_properties * header->property_blob_size
+ + blob->n_methods * header->function_blob_size
+ n * header->signal_blob_size;
-
- return (GISignalInfo *) g_info_new (GI_INFO_TYPE_SIGNAL, (GIBaseInfo*)info,
- rinfo->typelib, offset);
+
+ return (GISignalInfo *) g_info_new (GI_INFO_TYPE_SIGNAL, (GIBaseInfo*)info,
+ rinfo->typelib, offset);
}
gint
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
- Header *header = (Header *)rinfo->typelib->data;
+ Header *header = (Header *)rinfo->typelib->data;
InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
-
- offset = rinfo->offset + header->interface_blob_size
+
+ offset = rinfo->offset + header->interface_blob_size
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
- + blob->n_properties * header->property_blob_size
- + blob->n_methods * header->function_blob_size
+ + blob->n_properties * header->property_blob_size
+ + blob->n_methods * header->function_blob_size
+ blob->n_signals * header->signal_blob_size
+ n * header->vfunc_blob_size;
-
- return (GIVFuncInfo *) g_info_new (GI_INFO_TYPE_VFUNC, (GIBaseInfo*)info,
- rinfo->typelib, offset);
+
+ return (GIVFuncInfo *) g_info_new (GI_INFO_TYPE_VFUNC, (GIBaseInfo*)info,
+ rinfo->typelib, offset);
}
/**
{
GIRealInfo *rinfo = (GIRealInfo *)info;
InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
return blob->n_constants;
}
{
gint offset;
GIRealInfo *rinfo = (GIRealInfo *)info;
- Header *header = (Header *)rinfo->typelib->data;
+ Header *header = (Header *)rinfo->typelib->data;
InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
offset = rinfo->offset + header->interface_blob_size
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
+ blob->n_properties * header->property_blob_size
- + blob->n_methods * header->function_blob_size
- + blob->n_signals * header->signal_blob_size
- + blob->n_vfuncs * header->vfunc_blob_size
+ + blob->n_methods * header->function_blob_size
+ + blob->n_signals * header->signal_blob_size
+ + blob->n_vfuncs * header->vfunc_blob_size
+ n * header->constant_blob_size;
- return (GIConstantInfo *) g_info_new (GI_INFO_TYPE_CONSTANT, (GIBaseInfo*)info,
- rinfo->typelib, offset);
+ return (GIConstantInfo *) g_info_new (GI_INFO_TYPE_CONSTANT, (GIBaseInfo*)info,
+ rinfo->typelib, offset);
}
/**
GParamFlags flags;
GIRealInfo *rinfo = (GIRealInfo *)info;
PropertyBlob *blob = (PropertyBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
flags = 0;
if (blob->readable)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
VFuncBlob *blob = (VFuncBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
return blob->struct_offset;
}
if (blob->class_closure)
return g_interface_info_get_signal ((GIInterfaceInfo *)rinfo->container, blob->signal);
-
+
return NULL;
}
g_constant_info_get_type (GIConstantInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
-
+
return g_type_info_new ((GIBaseInfo*)info, rinfo->typelib, rinfo->offset + 8);
}
gint
-g_constant_info_get_value (GIConstantInfo *info,
+g_constant_info_get_value (GIConstantInfo *info,
GArgument *value)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
{
GIRealInfo *rinfo = (GIRealInfo *)info;
UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
return blob->n_fields;
}
gint n)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
- Header *header = (Header *)rinfo->typelib->data;
-
- return (GIFieldInfo *) g_info_new (GI_INFO_TYPE_FIELD, (GIBaseInfo*)info, rinfo->typelib,
- rinfo->offset + header->union_blob_size +
+ Header *header = (Header *)rinfo->typelib->data;
+
+ return (GIFieldInfo *) g_info_new (GI_INFO_TYPE_FIELD, (GIBaseInfo*)info, rinfo->typelib,
+ rinfo->offset + header->union_blob_size +
n * header->field_blob_size);
}
{
GIRealInfo *rinfo = (GIRealInfo *)info;
UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
return blob->n_functions;
}
{
GIRealInfo *rinfo = (GIRealInfo *)info;
UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset];
- Header *header = (Header *)rinfo->typelib->data;
+ Header *header = (Header *)rinfo->typelib->data;
gint offset;
- offset = rinfo->offset + header->union_blob_size
- + blob->n_fields * header->field_blob_size
+ offset = rinfo->offset + header->union_blob_size
+ + blob->n_fields * header->field_blob_size
+ n * header->function_blob_size;
- return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, (GIBaseInfo*)info,
+ return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, (GIBaseInfo*)info,
rinfo->typelib, offset);
}
{
GIRealInfo *rinfo = (GIRealInfo *)info;
UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
return blob->discriminated;
}
{
GIRealInfo *rinfo = (GIRealInfo *)info;
UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
return blob->discriminator_offset;
}
g_union_info_get_discriminator_type (GIUnionInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
-
+
return g_type_info_new ((GIBaseInfo*)info, rinfo->typelib, rinfo->offset + 24);
}
{
GIRealInfo *rinfo = (GIRealInfo *)info;
UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset];
-
+
if (blob->discriminated)
{
- Header *header = (Header *)rinfo->typelib->data;
+ Header *header = (Header *)rinfo->typelib->data;
gint offset;
- offset = rinfo->offset + header->union_blob_size
- + blob->n_fields * header->field_blob_size
+ offset = rinfo->offset + header->union_blob_size
+ + blob->n_fields * header->field_blob_size
+ blob->n_functions * header->function_blob_size
+ n * header->constant_blob_size;
-
- return (GIConstantInfo *) g_info_new (GI_INFO_TYPE_CONSTANT, (GIBaseInfo*)info,
- rinfo->typelib, offset);
+
+ return (GIConstantInfo *) g_info_new (GI_INFO_TYPE_CONSTANT, (GIBaseInfo*)info,
+ rinfo->typelib, offset);
}
return NULL;
/**
* g_function_info_invoke:
* @info: a #GIFunctionInfo describing the function to invoke
- * @in_args: an array of #GArgument<!-- -->s, one for each in
+ * @in_args: an array of #GArgument<!-- -->s, one for each in
* parameter of @info. If there are no in parameter, @in_args
* can be %NULL
* @n_in_args: the length of the @in_args array
* @out_args: an array of #GArgument<!-- -->s, one for each out
* parameter of @info. If there are no out parameters, @out_args
- * may be %NULL
+ * may be %NULL
* @n_out_args: the length of the @out_args array
- * @return_value: return location for the return value of the
+ * @return_value: return location for the return value of the
* function. If the function returns void, @return_value may be
* %NULL
* @error: return location for detailed error information, or %NULL
*
- * Invokes the function described in @info with the given
+ * Invokes the function described in @info with the given
* arguments. Note that inout parameters must appear in both
* argument lists. This function uses dlsym() to obtain a pointer
- * to the function, so the library or shared object containing the
- * described function must either be linked to the caller, or must
+ * to the function, so the library or shared object containing the
+ * described function must either be linked to the caller, or must
* have been dlopen()<!-- -->ed before calling this function.
*
* Returns: %TRUE if the function has been invoked, %FALSE if an
- * error occurred.
+ * error occurred.
*/
-gboolean
-g_function_info_invoke (GIFunctionInfo *info,
+gboolean
+g_function_info_invoke (GIFunctionInfo *info,
const GArgument *in_args,
int n_in_args,
const GArgument *out_args,
atypes = g_alloca (sizeof (ffi_type*) * n_invoke_args);
args = g_alloca (sizeof (gpointer) * n_invoke_args);
-
+
if (is_method)
{
atypes[0] = &ffi_type_pointer;
args[i+offset] = (gpointer)&in_args[in_pos];
in_pos++;
-
+
break;
case GI_DIRECTION_OUT:
atypes[i+offset] = &ffi_type_pointer;
g_set_error (error,
G_INVOKE_ERROR,
G_INVOKE_ERROR_ARGUMENT_MISMATCH,
- "Too few \"out\" arguments (handling out)");
+ "Too few \"out\" arguments (handling out)");
goto out;
}
args[i+offset] = (gpointer)&out_args[out_pos];
- out_pos++;
+ out_pos++;
break;
case GI_DIRECTION_INOUT:
atypes[i+offset] = &ffi_type_pointer;
g_set_error (error,
G_INVOKE_ERROR,
G_INVOKE_ERROR_ARGUMENT_MISMATCH,
- "Too few \"out\" arguments (handling inout)");
+ "Too few \"out\" arguments (handling inout)");
goto out;
}
-
+
args[i+offset] = (gpointer)&in_args[in_pos];
- in_pos++;
- out_pos++;
+ in_pos++;
+ out_pos++;
break;
default:
g_assert_not_reached ();
g_set_error (error,
G_INVOKE_ERROR,
G_INVOKE_ERROR_ARGUMENT_MISMATCH,
- "Too many \"out\" arguments (at end)");
+ "Too many \"out\" arguments (at end)");
goto out;
}
ffi_cif cif;
GCClosure *cc = (GCClosure*) closure;
- if (return_gvalue && G_VALUE_TYPE (return_gvalue))
+ if (return_gvalue && G_VALUE_TYPE (return_gvalue))
{
rtype = value_to_ffi_type (return_gvalue, &rvalue);
}
- else
+ else
{
rtype = &ffi_type_void;
}
rvalue = g_alloca (MAX (rtype->size, sizeof (ffi_arg)));
-
+
n_args = n_param_values + 1;
atypes = g_alloca (sizeof (ffi_type *) * n_args);
args = g_alloca (sizeof (gpointer) * n_args);
{
if (G_CCLOSURE_SWAP_DATA (closure))
{
- atypes[n_args-1] = value_to_ffi_type (param_values + 0,
+ atypes[n_args-1] = value_to_ffi_type (param_values + 0,
&args[n_args-1]);
atypes[0] = &ffi_type_pointer;
args[0] = &closure->data;
static GSList *search_path = NULL;
static GSList *override_search_path = NULL;
-struct _GIRepositoryPrivate
+struct _GIRepositoryPrivate
{
GHashTable *typelibs; /* (string) namespace -> GTypelib */
GHashTable *lazy_typelibs; /* (string) namespace-version -> GTypelib */
G_DEFINE_TYPE (GIRepository, g_irepository, G_TYPE_OBJECT);
-static void
+static void
g_irepository_init (GIRepository *repository)
{
repository->priv = G_TYPE_INSTANCE_GET_PRIVATE (repository, G_TYPE_IREPOSITORY,
GIRepositoryPrivate);
- repository->priv->typelibs
+ repository->priv->typelibs
= g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) NULL,
(GDestroyNotify) g_typelib_free);
- repository->priv->lazy_typelibs
+ repository->priv->lazy_typelibs
= g_hash_table_new (g_str_hash, g_str_equal);
repository->priv->info_by_gtype
= g_hash_table_new_full (g_direct_hash, g_direct_equal,
g_hash_table_destroy (repository->priv->typelibs);
g_hash_table_destroy (repository->priv->lazy_typelibs);
g_hash_table_destroy (repository->priv->info_by_gtype);
-
+
(* G_OBJECT_CLASS (g_irepository_parent_class)->finalize) (G_OBJECT (repository));
}
gobject_class->finalize = g_irepository_finalize;
- g_type_class_add_private (class, sizeof (GIRepositoryPrivate));
+ g_type_class_add_private (class, sizeof (GIRepositoryPrivate));
}
static void
build_search_path_with_overrides (void)
{
GSList *result;
- if (override_search_path != NULL)
+ if (override_search_path != NULL)
{
result = g_slist_copy (override_search_path);
g_slist_last (result)->next = g_slist_copy (search_path);
- }
+ }
else
result = g_slist_copy (search_path);
return result;
}
static GTypelib *
-check_version_conflict (GTypelib *typelib,
+check_version_conflict (GTypelib *typelib,
const gchar *namespace,
const gchar *expected_version,
char **version_conflict)
*version_conflict = NULL;
return typelib;
}
-
+
header = (Header*)typelib->data;
loaded_version = g_typelib_get_string (typelib, header->nsversion);
g_assert (loaded_version != NULL);
-
+
if (strcmp (expected_version, loaded_version) != 0)
{
if (version_conflict)
if (lazy_status)
*lazy_status = FALSE;
typelib = g_hash_table_lookup (repository->priv->typelibs, namespace);
- if (typelib)
+ if (typelib)
return check_version_conflict (typelib, namespace, version, version_conflict);
typelib = g_hash_table_lookup (repository->priv->lazy_typelibs, namespace);
if (!typelib)
if (dependencies != NULL)
{
int i;
-
+
for (i = 0; dependencies[i]; i++)
{
char *dependency = dependencies[i];
last_dash = strrchr (dependency, '-');
dependency_namespace = g_strndup (dependency, last_dash - dependency);
dependency_version = last_dash+1;
-
+
if (!g_irepository_require (repository, dependency_namespace, dependency_version,
0, error))
{
const gchar *version;
g_return_val_if_fail (typelib != NULL, FALSE);
-
+
header = (Header *)typelib->data;
g_return_val_if_fail (header != NULL, FALSE);
if (lazy)
{
- g_assert (!g_hash_table_lookup (repository->priv->lazy_typelibs,
+ g_assert (!g_hash_table_lookup (repository->priv->lazy_typelibs,
namespace));
- g_hash_table_insert (repository->priv->lazy_typelibs,
+ g_hash_table_insert (repository->priv->lazy_typelibs,
build_typelib_key (namespace, source), (void *)typelib);
}
else
/* First, try loading all the dependencies */
if (!load_dependencies_recurse (repository, typelib, error))
return NULL;
-
+
/* Check if we are transitioning from lazily loaded state */
- if (g_hash_table_lookup_extended (repository->priv->lazy_typelibs,
+ if (g_hash_table_lookup_extended (repository->priv->lazy_typelibs,
namespace,
(gpointer)&key, &value))
g_hash_table_remove (repository->priv->lazy_typelibs, key);
namespace = g_typelib_get_string (typelib, header->namespace);
nsversion = g_typelib_get_string (typelib, header->nsversion);
- if (get_registered_status (repository, namespace, nsversion, allow_lazy,
+ if (get_registered_status (repository, namespace, nsversion, allow_lazy,
&is_lazy, &version_conflict))
{
if (version_conflict != NULL)
}
return namespace;
}
- return register_internal (repository, "<builtin>",
+ return register_internal (repository, "<builtin>",
allow_lazy, typelib, error);
}
* metadata in the namespace, you should call #g_irepository_require
* instead which will ensure the namespace is loaded, and return as
* quickly as this function will if it has already been loaded.
- *
+ *
* Returns: %TRUE if namespace-version is loaded, %FALSE otherwise
*/
gboolean
-g_irepository_is_registered (GIRepository *repository,
+g_irepository_is_registered (GIRepository *repository,
const gchar *namespace,
const gchar *version)
{
* All methods on #GIRepository also accept %NULL as an instance
* parameter to mean this default repository, which is usually more
* convenient for C.
- *
- * Returns: (transfer none): The global singleton #GIRepository
+ *
+ * Returns: (transfer none): The global singleton #GIRepository
*/
-GIRepository *
+GIRepository *
g_irepository_get_default (void)
{
return get_repository (NULL);
*
* Returns: number of metadata entries
*/
-gint
+gint
g_irepository_get_n_infos (GIRepository *repository,
const gchar *namespace)
{
g_return_val_if_fail (namespace != NULL, -1);
repository = get_repository (repository);
-
+
typelib = get_registered (repository, namespace, NULL);
g_return_val_if_fail (typelib != NULL, -1);
gint n_entries;
const gchar *name;
const gchar *type;
- DirEntry *entry;
+ DirEntry *entry;
index = 0;
n_entries = ((Header *)typelib->data)->n_local_entries;
*
* Returns: #GIBaseInfo containing metadata
*/
-GIBaseInfo *
+GIBaseInfo *
g_irepository_get_info (GIRepository *repository,
const gchar *namespace,
gint index)
data.iface = NULL;
typelib = get_registered (repository, namespace, NULL);
-
+
g_return_val_if_fail (typelib != NULL, NULL);
find_interface ((void *)namespace, typelib, &data);
- return data.iface;
+ return data.iface;
}
/**
*
* Returns: #GIBaseInfo representing metadata about @type, or %NULL
*/
-GIBaseInfo *
+GIBaseInfo *
g_irepository_find_by_gtype (GIRepository *repository,
GType gtype)
{
*
* Returns: #GIBaseInfo representing metadata about @name, or %NULL
*/
-GIBaseInfo *
+GIBaseInfo *
g_irepository_find_by_name (GIRepository *repository,
const gchar *namespace,
const gchar *name)
data.iface = NULL;
typelib = get_registered (repository, namespace, NULL);
-
+
g_return_val_if_fail (typelib != NULL, NULL);
find_interface ((void *)namespace, typelib, &data);
*
* Returns: (utf8) (transfer full): List of namespaces
*/
-gchar **
+gchar **
g_irepository_get_loaded_namespaces (GIRepository *repository)
{
GList *l, *list = NULL;
names = g_malloc0 (sizeof (gchar *) * (g_list_length (list) + 1));
i = 0;
for (l = list; l; l = l->next)
- names[i++] = g_strdup (l->data);
+ names[i++] = g_strdup (l->data);
g_list_free (list);
return names;
* @namespace_: GI namespace to use, e.g. "Gtk"
*
* If namespace @namespace_ is loaded, return the full path to the
- * .typelib file it was loaded from. If the typelib for
+ * .typelib file it was loaded from. If the typelib for
* namespace @namespace_ was included in a shared library, return
* the special string "$lt;builtin$gt;".
*
* Returns: Filesystem path (or $lt;builtin$gt;) if successful, %NULL if namespace is not loaded
*/
-const gchar *
+const gchar *
g_irepository_get_typelib_path (GIRepository *repository,
const gchar *namespace)
{
{
if (!g_hash_table_lookup_extended (repository->priv->lazy_typelibs, namespace,
&orig_key, &value))
-
+
return NULL;
}
return ((char*)orig_key) + strlen ((char *) orig_key) + 1;
GError *error = NULL;
GMappedFile *mfile = NULL;
char *fname;
-
+
fname = g_strdup_printf ("%s-%s.typelib", namespace, version);
tmp_path = build_search_path_with_overrides ();
for (ldir = tmp_path; ldir; ldir = ldir->next)
{
char *path = g_build_filename (ldir->data, fname, NULL);
-
+
mfile = g_mapped_file_new (path, FALSE, &error);
if (error)
{
return -1;
else if (result < 0)
return 1;
- else
+ else
{
/* Now check the path index, which says how early in the search path
* we found it. This ensures that of equal version targets, we
namespace_typelib = g_strdup_printf ("%s.typelib", namespace);
index = 0;
- tmp_path = build_search_path_with_overrides ();
+ tmp_path = build_search_path_with_overrides ();
for (ldir = tmp_path; ldir; ldir = ldir->next)
{
GDir *dir;
dir = g_dir_open (dirname, 0, NULL);
if (dir == NULL)
continue;
- while ((entry = g_dir_read_name (dir)) != NULL)
+ while ((entry = g_dir_read_name (dir)) != NULL)
{
GMappedFile *mfile;
char *path, *version;
if (!g_str_has_suffix (entry, ".typelib"))
continue;
-
+
if (g_str_has_prefix (entry, namespace_dash))
{
const char *last_dash;
{
struct NamespaceVersionCandidadate *elected;
candidates = g_slist_sort (candidates, (GCompareFunc) compare_candidate_reverse);
-
+
elected = (struct NamespaceVersionCandidadate *) candidates->data;
/* Remove the elected one so we don't try to free its contents */
candidates = g_slist_delete_link (candidates, candidates);
-
+
result = elected->mfile;
*path_ret = elected->path;
*version_ret = elected->version;
g_free (elected); /* just free the container */
g_slist_foreach (candidates, (GFunc) free_candidate, NULL);
g_slist_free (candidates);
- }
+ }
g_free (namespace_dash);
g_free (namespace_typelib);
- g_slist_free (tmp_path);
+ g_slist_free (tmp_path);
return result;
}
repository = get_repository (repository);
- typelib = get_registered_status (repository, namespace, version, allow_lazy,
+ typelib = get_registered_status (repository, namespace, version, allow_lazy,
&is_lazy, &version_conflict);
if (typelib)
return typelib;
{
mfile = find_namespace_latest (namespace, &tmp_version, &path);
}
-
+
if (mfile == NULL)
{
if (version != NULL)
header = (Header *) typelib->data;
typelib_namespace = g_typelib_get_string (typelib, header->namespace);
typelib_version = g_typelib_get_string (typelib, header->nsversion);
-
+
if (strcmp (typelib_namespace, namespace) != 0)
{
g_set_error (error, G_IREPOSITORY_ERROR,
goto out;
}
- if (!register_internal (repository, path, allow_lazy,
+ if (!register_internal (repository, path, allow_lazy,
typelib, error))
{
g_typelib_free (typelib);
out:
g_free (tmp_version);
g_free (path);
- return ret;
+ return ret;
}
static gboolean
#define G_IS_IREPOSITORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G_TYPE_IREPOSITORY))
#define G_IREPOSITORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G_TYPE_IREPOSITORY, GIRepositoryClass))
-typedef struct _GIRepository GIRepository;
-typedef struct _GIRepositoryClass GIRepositoryClass;
-typedef struct _GIRepositoryPrivate GIRepositoryPrivate;
+typedef struct _GIRepository GIRepository;
+typedef struct _GIRepositoryClass GIRepositoryClass;
+typedef struct _GIRepositoryPrivate GIRepositoryPrivate;
typedef struct _GIBaseInfoStub GIBaseInfo;
typedef struct _GIUnresolvedInfo GIUnresolvedInfo;
typedef struct _GTypelib GTypelib;
-struct _GIRepository
-{
+struct _GIRepository
+{
GObject parent;
/*< private >*/
};
struct _GIRepositoryClass
-{
- GObjectClass parent;
+{
+ GObjectClass parent;
};
typedef enum
/* Types of objects registered in the repository */
-typedef enum
+typedef enum
{
GI_INFO_TYPE_INVALID,
GI_INFO_TYPE_FUNCTION,
GIBaseInfo * g_info_new (GIInfoType type,
GIBaseInfo *container,
- GTypelib *typelib,
+ GTypelib *typelib,
guint32 offset);
GIPropertyInfo * g_function_info_get_property (GIFunctionInfo *info);
GIVFuncInfo * g_function_info_get_vfunc (GIFunctionInfo *info);
-typedef union
+typedef union
{
gboolean v_boolean;
gint8 v_int8;
G_INVOKE_ERROR_ARGUMENT_MISMATCH
} GInvokeError;
-gboolean g_function_info_invoke (GIFunctionInfo *info,
+gboolean g_function_info_invoke (GIFunctionInfo *info,
const GArgument *in_args,
int n_in_args,
const GArgument *out_args,
GI_SCOPE_TYPE_INVALID, /* The argument is not of callback type */
GI_SCOPE_TYPE_CALL, /* The callback and associated user_data is only used during the
call to this function */
- GI_SCOPE_TYPE_ASYNC, /* The callback and associated user_data is
- only used until the callback is invoked, and the callback
+ GI_SCOPE_TYPE_ASYNC, /* The callback and associated user_data is
+ only used until the callback is invoked, and the callback
is invoked always exactly once. */
GI_SCOPE_TYPE_NOTIFIED /* The callback and and associated user_data is
used until the caller is notfied via the destroy_notify */
GI_TYPE_TAG_INT8 = 2,
GI_TYPE_TAG_UINT8 = 3,
GI_TYPE_TAG_INT16 = 4,
- GI_TYPE_TAG_UINT16 = 5,
+ GI_TYPE_TAG_UINT16 = 5,
GI_TYPE_TAG_INT32 = 6,
GI_TYPE_TAG_UINT32 = 7,
GI_TYPE_TAG_INT64 = 8,
/* GIValueInfo */
-
+
glong g_value_info_get_value (GIValueInfo *info);
/* GIObjectInfo */
-const gchar * g_object_info_get_type_name (GIObjectInfo *info);
-const gchar * g_object_info_get_type_init (GIObjectInfo *info);
+const gchar * g_object_info_get_type_name (GIObjectInfo *info);
+const gchar * g_object_info_get_type_init (GIObjectInfo *info);
gboolean g_object_info_get_abstract (GIObjectInfo *info);
GIObjectInfo * g_object_info_get_parent (GIObjectInfo *info);
gint g_object_info_get_n_interfaces (GIObjectInfo *info);
gint n);
GIStructInfo * g_object_info_get_class_struct (GIObjectInfo *info);
-
+
/* GIInterfaceInfo */
gint g_interface_info_get_n_prerequisites (GIInterfaceInfo *info);
GIFunctionInfo * g_interface_info_get_method (GIInterfaceInfo *info,
gint n);
GIFunctionInfo * g_interface_info_find_method (GIInterfaceInfo *info,
- const gchar *name);
+ const gchar *name);
gint g_interface_info_get_n_signals (GIInterfaceInfo *info);
GISignalInfo * g_interface_info_get_signal (GIInterfaceInfo *info,
gint n);
g_assert_not_reached ();
return NULL;
-}
+}
/**
* g_type_info_get_ffi_type:
{
ffi_type **arg_types;
gint n_args, i;
-
+
g_return_val_if_fail (callable_info != NULL, NULL);
n_args = g_callable_info_get_n_args (callable_info);
-
+
arg_types = (ffi_type **) g_new0 (ffi_type *, n_args + 1);
-
+
for (i = 0; i < n_args; ++i)
{
GIArgInfo *arg_info = g_callable_info_get_arg (callable_info, i);
type_tag = g_type_info_get_tag (return_type);
return_ffi_type = g_type_info_get_ffi_type (return_type);
g_base_info_unref((GIBaseInfo*)return_type);
-
+
return return_ffi_type;
}
gboolean is_method;
gboolean throws;
gint n_args, n_invoke_args, i;
-
+
g_return_val_if_fail (info != NULL, FALSE);
g_return_val_if_fail (invoker != NULL, FALSE);
-
+
symbol = g_function_info_get_symbol ((GIFunctionInfo*) info);
-
+
if (!g_typelib_symbol (g_base_info_get_typelib((GIBaseInfo *) info),
symbol, &(invoker->native_address)))
{
/* TODO: avoid malloc here? */
atypes = g_malloc0 (sizeof (ffi_type*) * n_invoke_args);
-
+
if (is_method)
{
atypes[0] = &ffi_type_pointer;
/**
* g_function_info_invoker_destroy:
* @invoker: A #GIFunctionInvoker
- *
+ *
* Release all resources allocated for the internals of @invoker; callers
* are responsible for freeing any resources allocated for the structure
* itself however.
{
ffi_closure *closure;
ffi_status status;
-
+
g_return_val_if_fail (callable_info != NULL, FALSE);
g_return_val_if_fail (cif != NULL, FALSE);
g_return_val_if_fail (callback != NULL, FALSE);
-
+
closure = mmap (NULL, sizeof (ffi_closure),
PROT_EXEC | PROT_READ | PROT_WRITE,
MAP_ANON | MAP_PRIVATE, -1, sysconf (_SC_PAGE_SIZE));
munmap(closure, sizeof (closure));
return NULL;
}
-
+
return closure;
}
struct _GIFunctionInvoker {
ffi_cif cif;
gpointer native_address;
-
+
gpointer padding[3];
};
gboolean g_function_info_prep_invoker (GIFunctionInfo *info,
GIFunctionInvoker *invoker,
GError **error);
-
+
void g_function_invoker_destroy (GIFunctionInvoker *invoker);
-/* GObject introspection: Typelib creation
+/* GObject introspection: Typelib creation
*
* Copyright (C) 2005 Matthias Clasen
*
GIrModule *
-g_ir_module_new (const gchar *name,
+g_ir_module_new (const gchar *name,
const gchar *version,
const gchar *shared_library,
const gchar *c_prefix)
{
GIrModule *module;
-
+
module = g_new0 (GIrModule, 1);
module->name = g_strdup (name);
char *formatted;
va_list args;
-
+
va_start (args, msg);
-
+
formatted = g_strdup_vprintf (msg, args);
-
+
if (line)
g_printerr ("%s-%s.gir:%d: error: %s\n", module->name, module->version, line, formatted);
else
g_printerr ("%s-%s.gir: error: %s\n", module->name, module->version, formatted);
-
+
exit (1);
-
+
va_end (args);
}
g_message ("%d entries (%d local), %d dependencies\n", n_entries, n_local_entries,
g_list_length (module->dependencies));
-
+
dir_size = n_entries * sizeof (DirEntry);
size = header_size + dir_size;
for (e = module->entries; e; e = e->next)
{
GIrNode *node = e->data;
-
+
size += g_ir_node_get_full_size (node);
size += g_ir_node_get_attribute_size (node);
/* Adjust size for strings allocated in header below specially */
size += ALIGN_VALUE (strlen (module->name) + 1, 4);
- if (module->shared_library)
+ if (module->shared_library)
size += ALIGN_VALUE (strlen (module->shared_library) + 1, 4);
if (dependencies != NULL)
size += ALIGN_VALUE (strlen (dependencies) + 1, 4);
if (module->c_prefix != NULL)
size += ALIGN_VALUE (strlen (module->c_prefix) + 1, 4);
- g_message ("allocating %d bytes (%d header, %d directory, %d entries)\n",
+ g_message ("allocating %d bytes (%d header, %d directory, %d entries)\n",
size, header_size, dir_size, size - header_size - dir_size);
data = g_malloc0 (size);
goto restart;
}
-
+
offset = offset2;
if (node->type == G_IR_NODE_XREF)
{
const char *namespace = ((GIrNodeXRef*)node)->namespace;
-
+
entry->blob_type = 0;
entry->local = FALSE;
entry->offset = write_string (namespace, strings, data, &offset2);
write_attributes (module, node, strings, data, &offset, &offset2);
}
-
+
g_message ("reallocating to %d bytes", offset2);
data = g_realloc (data, offset2);
typedef struct _GIrModule GIrModule;
struct _GIrModule
-{
+{
gchar *name;
gchar *version;
gchar *shared_library;
case G_IR_NODE_CALLBACK:
{
GIrNodeFunction *function = (GIrNodeFunction *)node;
-
+
g_free (node->name);
g_free (function->symbol);
g_ir_node_free ((GIrNode *)function->result);
case G_IR_NODE_TYPE:
{
GIrNodeType *type = (GIrNodeType *)node;
-
+
g_free (node->name);
g_ir_node_free ((GIrNode *)type->parameter_type1);
g_ir_node_free ((GIrNode *)type->parameter_type2);
case G_IR_NODE_PARAM:
{
GIrNodeParam *param = (GIrNodeParam *)node;
-
+
g_free (node->name);
g_ir_node_free ((GIrNode *)param->type);
}
case G_IR_NODE_PROPERTY:
{
GIrNodeProperty *property = (GIrNodeProperty *)node;
-
+
g_free (node->name);
g_ir_node_free ((GIrNode *)property->type);
}
case G_IR_NODE_SIGNAL:
{
GIrNodeSignal *signal = (GIrNodeSignal *)node;
-
+
g_free (node->name);
for (l = signal->parameters; l; l = l->next)
g_ir_node_free ((GIrNode *)l->data);
case G_IR_NODE_VFUNC:
{
GIrNodeVFunc *vfunc = (GIrNodeVFunc *)node;
-
+
g_free (node->name);
g_free (vfunc->invoker);
for (l = vfunc->parameters; l; l = l->next)
case G_IR_NODE_FIELD:
{
GIrNodeField *field = (GIrNodeField *)node;
-
+
g_free (node->name);
g_ir_node_free ((GIrNode *)field->type);
g_ir_node_free ((GIrNode *)field->callback);
case G_IR_NODE_INTERFACE:
{
GIrNodeInterface *iface = (GIrNodeInterface *)node;
-
+
g_free (node->name);
g_free (iface->gtype_name);
g_free (iface->gtype_init);
}
break;
-
+
case G_IR_NODE_VALUE:
{
g_free (node->name);
case G_IR_NODE_FLAGS:
{
GIrNodeEnum *enum_ = (GIrNodeEnum *)node;
-
+
g_free (node->name);
g_free (enum_->gtype_name);
g_free (enum_->gtype_init);
case G_IR_NODE_BOXED:
{
GIrNodeBoxed *boxed = (GIrNodeBoxed *)node;
-
+
g_free (node->name);
g_free (boxed->gtype_name);
g_free (boxed->gtype_init);
case G_IR_NODE_CONSTANT:
{
GIrNodeConstant *constant = (GIrNodeConstant *)node;
-
+
g_free (node->name);
g_free (constant->value);
g_ir_node_free ((GIrNode *)constant->type);
case G_IR_NODE_ERROR_DOMAIN:
{
GIrNodeErrorDomain *domain = (GIrNodeErrorDomain *)node;
-
+
g_free (node->name);
g_free (domain->getquark);
g_free (domain->codes);
case G_IR_NODE_XREF:
{
GIrNodeXRef *xref = (GIrNodeXRef *)node;
-
+
g_free (node->name);
g_free (xref->namespace);
}
case G_IR_NODE_UNION:
{
GIrNodeUnion *union_ = (GIrNodeUnion *)node;
-
+
g_free (node->name);
g_free (union_->gtype_name);
g_free (union_->gtype_init);
default:
g_error ("Unhandled node type %d\n", node->type);
break;
- }
+ }
g_hash_table_destroy (node->attributes);
case G_IR_NODE_FLAGS:
{
GIrNodeEnum *enum_ = (GIrNodeEnum *)node;
-
+
size = sizeof (EnumBlob);
for (l = enum_->values; l; l = l->next)
size += g_ir_node_get_size ((GIrNode *)l->data);
}
break;
- default:
+ default:
g_error ("Unhandled node type '%s'\n",
g_ir_node_type_to_string (node->type));
size = 0;
case G_IR_NODE_PARAM:
{
GIrNodeParam *param = (GIrNodeParam *)node;
-
+
/* See the comment in the G_IR_NODE_PARAM/ArgBlob writing below */
size = sizeof (ArgBlob) - sizeof (SimpleTypeBlob);
if (node->name)
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
- size += g_ir_node_get_full_size_internal (node, (GIrNode *)param->type);
+ size += g_ir_node_get_full_size_internal (node, (GIrNode *)param->type);
}
break;
case GI_TYPE_TAG_ERROR:
{
gint n;
-
+
if (type->errors)
n = g_strv_length (type->errors);
else
case G_IR_NODE_FLAGS:
{
GIrNodeEnum *enum_ = (GIrNodeEnum *)node;
-
+
size = sizeof (EnumBlob);
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
if (enum_->gtype_name)
}
for (l = enum_->values; l; l = l->next)
- size += g_ir_node_get_full_size_internal (node, (GIrNode *)l->data);
+ size += g_ir_node_get_full_size_internal (node, (GIrNode *)l->data);
}
break;
case G_IR_NODE_PROPERTY:
{
GIrNodeProperty *prop = (GIrNodeProperty *)node;
-
+
size = sizeof (PropertyBlob);
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
- size += g_ir_node_get_full_size_internal (node, (GIrNode *)prop->type);
+ size += g_ir_node_get_full_size_internal (node, (GIrNode *)prop->type);
}
break;
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
/* FIXME non-string values */
size += ALIGN_VALUE (strlen (constant->value) + 1, 4);
- size += g_ir_node_get_full_size_internal (node, (GIrNode *)constant->type);
+ size += g_ir_node_get_full_size_internal (node, (GIrNode *)constant->type);
}
break;
case G_IR_NODE_XREF:
{
GIrNodeXRef *xref = (GIrNodeXRef *)node;
-
+
size = 0;
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
size += ALIGN_VALUE (strlen (xref->namespace) + 1, 4);
}
break;
- default:
+ default:
g_error ("Unknown type tag %d\n", node->type);
size = 0;
}
{
g_return_if_fail (node != NULL);
g_return_if_fail (member != NULL);
-
+
switch (node->type)
{
case G_IR_NODE_OBJECT:
{
if (strcmp (str, "TRUE") == 0)
return TRUE;
-
+
if (strcmp (str, "FALSE") == 0)
return FALSE;
g_assert (name != NULL);
g_assert (strlen (name) > 0);
-
+
names = g_strsplit (name, ".", 0);
n_names = g_strv_length (names);
if (n_names > 2)
g_error ("Too many name parts");
-
+
for (l = module->entries, i = 1; l; l = l->next, i++)
{
GIrNode *node = (GIrNode *)l->data;
-
+
if (n_names > 1)
{
if (node->type != G_IR_NODE_XREF)
continue;
-
+
if (((GIrNodeXRef *)node)->namespace == NULL ||
strcmp (((GIrNodeXRef *)node)->namespace, names[0]) != 0)
continue;
}
-
+
if (strcmp (node->name, names[n_names - 1]) == 0)
{
if (idx)
*idx = i;
-
+
result = node;
goto out;
}
((GIrNodeXRef *)node)->namespace = g_strdup (names[0]);
node->name = g_strdup (names[1]);
-
+
module->entries = g_list_append (module->entries, node);
-
+
if (idx)
*idx = g_list_length (module->entries);
}
static void
-serialize_type (GIrModule *module,
+serialize_type (GIrModule *module,
GList *modules,
- GIrNodeType *node,
+ GIrNodeType *node,
GString *str)
{
gint i;
const gchar* basic[] = {
- "void",
- "boolean",
- "int8",
- "uint8",
- "int16",
- "uint16",
- "int32",
- "uint32",
- "int64",
- "uint64",
+ "void",
+ "boolean",
+ "int8",
+ "uint8",
+ "int16",
+ "uint16",
+ "int32",
+ "uint32",
+ "int64",
+ "uint64",
"short",
"ushort",
"int",
"ulong",
"ssize",
"size",
- "float",
+ "float",
"double",
"time_t",
"GType",
- "utf8",
+ "utf8",
"filename",
};
-
+
if (node->tag < GI_TYPE_TAG_ARRAY)
{
g_string_append_printf (str, "%s%s", basic[node->tag],
g_string_append_printf (str, "length=%d", node->length);
else if (node->has_size)
g_string_append_printf (str, "fixed-size=%d", node->size);
-
+
if (node->zero_terminated)
- g_string_append_printf (str, "%szero-terminated=1",
+ g_string_append_printf (str, "%szero-terminated=1",
node->has_length ? "," : "");
-
+
g_string_append (str, "]");
}
else if (node->tag == GI_TYPE_TAG_INTERFACE)
g_string_append (str, "GList");
if (node->parameter_type1)
{
- g_string_append (str, "<");
+ g_string_append (str, "<");
serialize_type (module, modules, node->parameter_type1, str);
- g_string_append (str, ">");
+ g_string_append (str, ">");
}
}
else if (node->tag == GI_TYPE_TAG_GSLIST)
g_string_append (str, "GSList");
if (node->parameter_type1)
{
- g_string_append (str, "<");
+ g_string_append (str, "<");
serialize_type (module, modules, node->parameter_type1, str);
- g_string_append (str, ">");
+ g_string_append (str, ">");
}
}
else if (node->tag == GI_TYPE_TAG_GHASH)
g_string_append (str, "GHashTable<");
if (node->parameter_type1)
{
- g_string_append (str, "<");
+ g_string_append (str, "<");
serialize_type (module, modules, node->parameter_type1, str);
- g_string_append (str, ",");
+ g_string_append (str, ",");
serialize_type (module, modules, node->parameter_type2, str);
- g_string_append (str, ">");
+ g_string_append (str, ">");
}
}
else if (node->tag == GI_TYPE_TAG_ERROR)
g_string_append (str, "GError");
if (node->errors)
{
- g_string_append (str, "<");
+ g_string_append (str, "<");
for (i = 0; node->errors[i]; i++)
{
if (i > 0)
g_string_append (str, ",");
g_string_append (str, node->errors[i]);
}
- g_string_append (str, ">");
+ g_string_append (str, ">");
}
}
}
SimpleTypeBlob *blob = (SimpleTypeBlob *)&data[*offset];
*offset += sizeof (SimpleTypeBlob);
-
+
if (type->tag < GI_TYPE_TAG_ARRAY ||
type->tag == GI_TYPE_TAG_UTF8 ||
type->tag == GI_TYPE_TAG_FILENAME)
- {
+ {
blob->flags.reserved = 0;
blob->flags.reserved2 = 0;
blob->flags.pointer = type->is_pointer;
blob->flags.reserved3 = 0;
blob->flags.tag = type->tag;
}
- else
+ else
{
GString *str;
gchar *s;
gpointer value;
-
+
str = g_string_new (0);
serialize_type (module, modules, type, str);
s = g_string_free (str, FALSE);
-
+
types_count += 1;
value = g_hash_table_lookup (types, s);
if (value)
{
unique_types_count += 1;
g_hash_table_insert (types, s, GUINT_TO_POINTER(*offset2));
-
+
blob->offset = *offset2;
switch (type->tag)
{
{
ArrayTypeBlob *array = (ArrayTypeBlob *)&data[*offset2];
guint32 pos;
-
+
array->pointer = 1;
array->reserved = 0;
array->tag = type->tag;
array->dimensions.size = type->size;
else
array->dimensions.length = -1;
-
+
pos = *offset2 + G_STRUCT_OFFSET (ArrayTypeBlob, type);
*offset2 += sizeof (ArrayTypeBlob);
-
+
g_ir_node_build_typelib ((GIrNode *)type->parameter_type1,
node, build, &pos, offset2);
}
break;
-
+
case GI_TYPE_TAG_INTERFACE:
{
InterfaceTypeBlob *iface = (InterfaceTypeBlob *)&data[*offset2];
}
break;
-
+
case GI_TYPE_TAG_GLIST:
case GI_TYPE_TAG_GSLIST:
{
ParamTypeBlob *param = (ParamTypeBlob *)&data[*offset2];
guint32 pos;
-
+
param->pointer = 1;
param->reserved = 0;
param->tag = type->tag;
param->reserved2 = 0;
param->n_types = 1;
-
+
pos = *offset2 + G_STRUCT_OFFSET (ParamTypeBlob, type);
*offset2 += sizeof (ParamTypeBlob) + sizeof (SimpleTypeBlob);
-
- g_ir_node_build_typelib ((GIrNode *)type->parameter_type1,
+
+ g_ir_node_build_typelib ((GIrNode *)type->parameter_type1,
node, build, &pos, offset2);
}
break;
-
+
case GI_TYPE_TAG_GHASH:
{
ParamTypeBlob *param = (ParamTypeBlob *)&data[*offset2];
guint32 pos;
-
+
param->pointer = 1;
param->reserved = 0;
param->tag = type->tag;
param->reserved2 = 0;
param->n_types = 2;
-
+
pos = *offset2 + G_STRUCT_OFFSET (ParamTypeBlob, type);
*offset2 += sizeof (ParamTypeBlob) + sizeof (SimpleTypeBlob)*2;
-
- g_ir_node_build_typelib ((GIrNode *)type->parameter_type1,
+
+ g_ir_node_build_typelib ((GIrNode *)type->parameter_type1,
node, build, &pos, offset2);
- g_ir_node_build_typelib ((GIrNode *)type->parameter_type2,
+ g_ir_node_build_typelib ((GIrNode *)type->parameter_type2,
node, build, &pos, offset2);
}
break;
-
+
case GI_TYPE_TAG_ERROR:
{
ErrorTypeBlob *blob = (ErrorTypeBlob *)&data[*offset2];
gint i;
-
+
blob->pointer = 1;
blob->reserved = 0;
blob->tag = type->tag;
blob->reserved2 = 0;
- if (type->errors)
+ if (type->errors)
blob->n_domains = g_strv_length (type->errors);
else
blob->n_domains = 0;
-
+
*offset2 = ALIGN_VALUE (*offset2 + G_STRUCT_OFFSET (ErrorTypeBlob, domains)
+ 2 * blob->n_domains, 4);
for (i = 0; i < blob->n_domains; i++)
blob->domains[i] = find_entry (module, modules, type->errors[i]);
}
break;
-
+
default:
g_error ("Unknown type tag %d\n", type->tag);
break;
blob->construct_only = prop->construct_only;
blob->reserved = 0;
- g_ir_node_build_typelib ((GIrNode *)prop->type,
+ g_ir_node_build_typelib ((GIrNode *)prop->type,
node, build, offset, offset2);
}
break;
g_debug ("building function '%s'", function->symbol);
- g_ir_node_build_typelib ((GIrNode *)function->result->type,
+ g_ir_node_build_typelib ((GIrNode *)function->result->type,
node, build, &signature, offset2);
blob2->may_return_null = function->result->allow_none;
blob2->n_arguments = n;
signature += 4;
-
+
for (l = function->parameters; l; l = l->next)
{
GIrNode *param = (GIrNode *)l->data;
blob->reserved = 0;
blob->name = write_string (node->name, strings, data, offset2);
blob->signature = signature;
-
- g_ir_node_build_typelib ((GIrNode *)function->result->type,
+
+ g_ir_node_build_typelib ((GIrNode *)function->result->type,
node, build, &signature, offset2);
blob2->may_return_null = function->result->allow_none;
blob2->n_arguments = n;
signature += 4;
-
+
for (l = function->parameters; l; l = l->next)
{
GIrNode *param = (GIrNode *)l->data;
blob->class_closure = 0; /* FIXME */
blob->name = write_string (node->name, strings, data, offset2);
blob->signature = signature;
-
- g_ir_node_build_typelib ((GIrNode *)signal->result->type,
+
+ g_ir_node_build_typelib ((GIrNode *)signal->result->type,
node, build, &signature, offset2);
blob2->may_return_null = signal->result->allow_none;
blob2->n_arguments = n;
signature += 4;
-
+
for (l = signal->parameters; l; l = l->next)
{
GIrNode *param = (GIrNode *)l->data;
blob->struct_offset = vfunc->offset;
blob->reserved2 = 0;
blob->signature = signature;
-
- g_ir_node_build_typelib ((GIrNode *)vfunc->result->type,
+
+ g_ir_node_build_typelib ((GIrNode *)vfunc->result->type,
node, build, &signature, offset2);
blob2->may_return_null = vfunc->result->allow_none;
blob2->n_arguments = n;
signature += 4;
-
+
for (l = vfunc->parameters; l; l = l->next)
{
GIrNode *param = (GIrNode *)l->data;
blob->reserved = 0;
blob->closure = param->closure;
blob->destroy = param->destroy;
-
+
g_ir_node_build_typelib ((GIrNode *)param->type, node, build, offset, offset2);
}
break;
StructBlob *blob = (StructBlob *)&data[*offset];
GIrNodeStruct *struct_ = (GIrNodeStruct *)node;
GList *members;
-
+
blob->blob_type = BLOB_TYPE_STRUCT;
blob->deprecated = struct_->deprecated;
blob->is_gtype_struct = struct_->is_gtype_struct;
{
*offset += 28;
blob->discriminated = TRUE;
- g_ir_node_build_typelib ((GIrNode *)union_->discriminator_type,
+ g_ir_node_build_typelib ((GIrNode *)union_->discriminator_type,
build, offset, offset2);
}
else
*offset += sizeof (UnionBlob);
blob->discriminated = FALSE;
blob->discriminator_type.offset = 0;
-
+
members = g_list_copy (union_->members);
g_ir_node_build_members (&members, G_IR_NODE_FIELD, &blob->n_fields,
for (l = union_->discriminators; l; l = l->next)
{
GIrNode *member = (GIrNode *)l->data;
-
+
g_ir_node_build_typelib (member, node, build, offset, offset2);
}
}
EnumBlob *blob = (EnumBlob *)&data[*offset];
GIrNodeEnum *enum_ = (GIrNodeEnum *)node;
- *offset += sizeof (EnumBlob);
+ *offset += sizeof (EnumBlob);
if (node->type == G_IR_NODE_ENUM)
blob->blob_type = BLOB_TYPE_ENUM;
else
blob->blob_type = BLOB_TYPE_FLAGS;
-
+
blob->deprecated = enum_->deprecated;
blob->reserved = 0;
blob->storage_type = enum_->storage_type;
}
}
break;
-
+
case G_IR_NODE_OBJECT:
{
ObjectBlob *blob = (ObjectBlob *)&data[*offset];
blob->n_signals = 0;
blob->n_vfuncs = 0;
blob->n_constants = 0;
-
+
*offset += sizeof(ObjectBlob);
for (l = object->interfaces; l; l = l->next)
{
*(guint16*)&data[*offset] = find_entry (module, modules, (gchar *)l->data);
*offset += 2;
}
-
+
members = g_list_copy (object->members);
*offset = ALIGN_VALUE (*offset, 4);
blob->n_signals = 0;
blob->n_vfuncs = 0;
blob->n_constants = 0;
-
+
*offset += sizeof (InterfaceBlob);
for (l = iface->prerequisites; l; l = l->next)
{
*(guint16*)&data[*offset] = find_entry (module, modules, (gchar *)l->data);
*offset += 2;
}
-
+
members = g_list_copy (iface->members);
*offset = ALIGN_VALUE (*offset, 4);
DO_ALIGNED_COPY(&data[blob->offset], parse_int_value (constant->value), glong);
break;
case GI_TYPE_TAG_SIZE: /* FIXME */
- case GI_TYPE_TAG_TIME_T:
+ case GI_TYPE_TAG_TIME_T:
case GI_TYPE_TAG_ULONG:
blob->size = sizeof (gulong);
DO_ALIGNED_COPY(&data[blob->offset], parse_uint_value (constant->value), gulong);
break;
}
*offset2 += ALIGN_VALUE (blob->size, 4);
-
+
g_ir_node_build_typelib ((GIrNode *)constant->type, node, build, &pos, offset2);
}
break;
default:
g_assert_not_reached ();
}
-
+
g_debug ("node %s%s%s%p type '%s', offset %d -> %d, offset2 %d -> %d",
node->name ? "'" : "",
node->name ? node->name : "",
}
/* if str is already in the pool, return previous location, otherwise write str
- * to the typelib at offset, put it in the pool and update offset. If the
+ * to the typelib at offset, put it in the pool and update offset. If the
* typelib is not large enough to hold the string, reallocate it.
*/
-guint32
+guint32
write_string (const gchar *str,
- GHashTable *strings,
+ GHashTable *strings,
guchar *data,
guint32 *offset)
{
string_size += strlen (str);
value = g_hash_table_lookup (strings, str);
-
+
if (value)
return GPOINTER_TO_UINT (value);
*offset = ALIGN_VALUE (start + strlen (str) + 1, 4);
strcpy ((gchar*)&data[start], str);
-
+
return start;
}
G_BEGIN_DECLS
typedef struct _GIrTypelibBuild GIrTypelibBuild;
-typedef struct _GIrNode GIrNode;
+typedef struct _GIrNode GIrNode;
typedef struct _GIrNodeFunction GIrNodeFunction;
typedef struct _GIrNodeParam GIrNodeParam;
typedef struct _GIrNodeType GIrNodeType;
GHashTable *types;
GList *offset_ordered_nodes;
guint32 n_attributes;
- guchar *data;
+ guchar *data;
};
-typedef enum
+typedef enum
{
G_IR_NODE_INVALID = 0,
G_IR_NODE_FUNCTION = 1,
G_IR_NODE_STRUCT = 3,
G_IR_NODE_BOXED = 4,
G_IR_NODE_ENUM = 5,
- G_IR_NODE_FLAGS = 6,
+ G_IR_NODE_FLAGS = 6,
G_IR_NODE_OBJECT = 7,
G_IR_NODE_INTERFACE = 8,
G_IR_NODE_CONSTANT = 9,
GIrNode node;
gboolean deprecated;
- gboolean is_varargs; /* Not in typelib yet */
+ gboolean is_varargs; /* Not in typelib yet */
gboolean is_method;
gboolean is_setter;
GList *parameters;
};
-struct _GIrNodeType
+struct _GIrNodeType
{
GIrNode node;
gint length;
gboolean has_size;
gint size;
-
+
GIrNodeType *parameter_type1;
- GIrNodeType *parameter_type2;
+ GIrNodeType *parameter_type2;
gchar *interface;
gchar **errors;
};
-struct _GIrNodeParam
+struct _GIrNodeParam
{
GIrNode node;
gboolean transfer;
gboolean shallow_transfer;
GIScopeType scope;
-
+
gint8 closure;
gint8 destroy;
-
+
GIrNodeType *type;
};
gboolean writable;
gboolean construct;
gboolean construct_only;
-
+
GIrNodeType *type;
};
-struct _GIrNodeSignal
+struct _GIrNodeSignal
{
GIrNode node;
gboolean detailed;
gboolean action;
gboolean no_hooks;
-
+
gboolean has_class_closure;
gboolean true_stops_emit;
-
+
gint class_closure;
-
+
GList *parameters;
- GIrNodeParam *result;
+ GIrNodeParam *result;
};
-struct _GIrNodeVFunc
+struct _GIrNodeVFunc
{
GIrNode node;
- gboolean is_varargs; /* Not in typelib yet */
+ gboolean is_varargs; /* Not in typelib yet */
gboolean must_chain_up;
gboolean must_be_implemented;
gboolean must_not_be_implemented;
gboolean is_class_closure;
-
+
char *invoker;
GList *parameters;
- GIrNodeParam *result;
+ GIrNodeParam *result;
gint offset;
};
gint bits;
gint offset;
GIrNodeFunction *callback;
-
+
GIrNodeType *type;
};
gchar *parent;
gchar *glib_type_struct;
-
+
GList *interfaces;
GList *prerequisites;
gint alignment;
gint size;
-
+
GList *members;
};
gboolean deprecated;
GIrNodeType *type;
-
+
gchar *value;
};
};
struct _GIrNodeBoxed
-{
+{
GIrNode node;
gboolean deprecated;
gint alignment;
gint size;
-
+
GList *members;
};
gint alignment;
gint size;
-
+
GList *members;
};
GIrNode node;
gboolean deprecated;
-
+
GList *members;
GList *discriminators;
GIrNode node;
gboolean deprecated;
-
+
gchar *name;
gchar *getquark;
gchar *codes;
void g_ir_node_add_member (GIrNode *node,
GIrNodeFunction *member);
guint32 write_string (const gchar *str,
- GHashTable *strings,
+ GHashTable *strings,
guchar *data,
guint32 *offset);
if (type->tag == GI_TYPE_TAG_ARRAY)
{
gint elt_size, elt_alignment;
-
+
if (!type->has_size
|| !get_type_size_alignment(type->parameter_type1, module, modules,
&elt_size, &elt_alignment, who))
*alignment = -1;
return FALSE;
}
-
+
*size = type->size * elt_size;
*alignment = elt_alignment;
-
+
return TRUE;
}
else if (type->is_pointer)
{
gchar *who;
gboolean success;
-
+
who = g_strdup_printf ("field %s.%s.%s", module->name, parent_node->name, ((GIrNode *)field)->name);
if (field->callback)
GError *error,
gpointer user_data);
-static GMarkupParser markup_parser =
+static GMarkupParser markup_parser =
{
start_element_handler,
end_element_handler,
ParseContext *ctx,
GError **error);
-static const gchar *find_attribute (const gchar *name,
+static const gchar *find_attribute (const gchar *name,
const gchar **attribute_names,
const gchar **attribute_values);
{
ParseContext *ctx = user_data;
- if (strcmp (element_name, "alias") == 0)
+ if (strcmp (element_name, "alias") == 0)
{
start_alias (context, element_name, attribute_names, attribute_values,
ctx, error);
{
}
-static GMarkupParser firstpass_parser =
+static GMarkupParser firstpass_parser =
{
firstpass_start_element_handler,
firstpass_end_element_handler,
const gchar *const *datadirs;
const gchar *const *dir;
char *path = NULL;
-
+
datadirs = g_get_system_data_dirs ();
-
+
if (parser->includes != NULL)
{
- for (dir = (const gchar *const *)parser->includes; *dir; dir++)
+ for (dir = (const gchar *const *)parser->includes; *dir; dir++)
{
path = g_build_filename (*dir, girname, NULL);
if (g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))
path = NULL;
}
}
- for (dir = datadirs; *dir; dir++)
+ for (dir = datadirs; *dir; dir++)
{
path = g_build_filename (*dir, GIR_SUFFIX, girname, NULL);
if (g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))
static const gchar *
-find_attribute (const gchar *name,
+find_attribute (const gchar *name,
const gchar **attribute_names,
const gchar **attribute_values)
{
gint i;
-
+
for (i = 0; attribute_names[i] != NULL; i++)
if (strcmp (attribute_names[i], name) == 0)
return attribute_values[i];
-
+
return 0;
}
pop_node (ParseContext *ctx)
{
g_assert (ctx->node_stack != 0);
-
+
GSList *top = ctx->node_stack;
GIrNode *node = top->data;
-
+
g_debug ("popping node %d %s", node->type, node->name);
ctx->node_stack = top->next;
g_slist_free_1 (top);
{ "double", GI_TYPE_TAG_DOUBLE, 0 },
{ "time_t", GI_TYPE_TAG_TIME_T, 0 },
{ "GType", GI_TYPE_TAG_GTYPE, 0 },
- { "utf8", GI_TYPE_TAG_UTF8, 1 },
+ { "utf8", GI_TYPE_TAG_UTF8, 1 },
{ "filename", GI_TYPE_TAG_FILENAME,1 },
-};
+};
static const BasicTypeInfo *
parse_basic (const char *str)
{
gint i;
gint n_basic = G_N_ELEMENTS (basic_types);
-
+
for (i = 0; i < n_basic; i++)
{
if (g_str_has_prefix (str, basic_types[i].str))
return &(basic_types[i]);
- }
+ }
return NULL;
}
parse_type_internal (const gchar *str, char **next, gboolean in_glib,
gboolean in_gobject)
{
- const BasicTypeInfo *basic;
+ const BasicTypeInfo *basic;
GIrNodeType *type;
char *temporary_type = NULL;
-
+
type = (GIrNodeType *)g_ir_node_new (G_IR_NODE_TYPE);
-
+
type->unparsed = g_strdup (str);
/* See comment below on GLib.List handling */
- if (in_gobject && strcmp (str, "Type") == 0)
+ if (in_gobject && strcmp (str, "Type") == 0)
{
temporary_type = g_strdup ("GLib.Type");
str = temporary_type;
}
-
+
basic = parse_basic (str);
if (basic != NULL)
{
{
/* If we're inside GLib, handle "List" etc. by prefixing with
* "GLib." so the parsing code below doesn't have to get more
- * special.
+ * special.
*/
if (g_str_has_prefix (str, "List<") ||
strcmp (str, "List") == 0)
type->is_error = TRUE;
type->is_pointer = TRUE;
str += strlen ("Error");
-
+
if (*str == '<')
{
(str)++;
char *tmp, *end;
-
+
end = strchr (str, '>');
tmp = g_strndup (str, end - str);
type->errors = g_strsplit (tmp, ",", 0);
str = end;
}
}
- else
+ else
{
type->tag = GI_TYPE_TAG_INTERFACE;
- type->is_interface = TRUE;
+ type->is_interface = TRUE;
const char *start = str;
/* must be an interface type */
- while (g_ascii_isalnum (*str) ||
- *str == '.' ||
- *str == '-' ||
+ while (g_ascii_isalnum (*str) ||
+ *str == '.' ||
+ *str == '-' ||
*str == '_' ||
*str == ':')
(str)++;
type->interface = g_strndup (start, str - start);
}
-
+
if (next)
*next = (char*)str;
g_assert (type->tag >= 0 && type->tag <= GI_TYPE_TAG_ERROR);
/* error: */
g_ir_node_free ((GIrNode *)type);
- g_free (temporary_type);
+ g_free (temporary_type);
return NULL;
}
lookup = type;
g_free (prefixed);
-
+
return lookup;
}
result = g_hash_table_lookup (ctx->current_module->disguised_structures,
lookup) != NULL;
-
+
g_free (prefixed);
-
+
return result;
}
typename = find_attribute ("glib:type-name", attribute_names, attribute_values);
typeinit = find_attribute ("glib:get-type", attribute_names, attribute_values);
deprecated = find_attribute ("deprecated", attribute_names, attribute_values);
-
+
if (name == NULL)
{
MISSING_ATTRIBUTE (context, error, element_name, "glib:name");
}
boxed = (GIrNodeBoxed *) g_ir_node_new (G_IR_NODE_BOXED);
-
+
((GIrNode *)boxed)->name = g_strdup (name);
boxed->gtype_name = g_strdup (typename);
boxed->gtype_init = g_strdup (typeinit);
boxed->deprecated = TRUE;
else
boxed->deprecated = FALSE;
-
+
push_node (ctx, (GIrNode *)boxed);
- ctx->current_module->entries =
+ ctx->current_module->entries =
g_list_append (ctx->current_module->entries, boxed);
-
+
state_switch (ctx, STATE_BOXED);
return TRUE;
const gchar *throws;
GIrNodeFunction *function;
gboolean found = FALSE;
-
+
switch (ctx->state)
{
case STATE_NAMESPACE:
symbol = find_attribute ("c:identifier", attribute_names, attribute_values);
deprecated = find_attribute ("deprecated", attribute_names, attribute_values);
throws = find_attribute ("throws", attribute_names, attribute_values);
-
+
if (name == NULL)
{
MISSING_ATTRIBUTE (context, error, element_name, "name");
}
function = (GIrNodeFunction *) g_ir_node_new (G_IR_NODE_FUNCTION);
-
+
((GIrNode *)function)->name = g_strdup (name);
function->symbol = g_strdup (symbol);
function->parameters = NULL;
function->deprecated = TRUE;
else
function->deprecated = FALSE;
-
+
if (strcmp (element_name, "method") == 0 ||
strcmp (element_name, "constructor") == 0)
{
function->is_method = TRUE;
-
+
if (strcmp (element_name, "constructor") == 0)
function->is_constructor = TRUE;
else
if (ctx->node_stack == NULL)
{
- ctx->current_module->entries =
- g_list_append (ctx->current_module->entries, function);
+ ctx->current_module->entries =
+ g_list_append (ctx->current_module->entries, function);
}
else if (ctx->current_typed)
{
case G_IR_NODE_OBJECT:
{
GIrNodeInterface *iface;
-
+
iface = (GIrNodeInterface *)CURRENT_NODE (ctx);
iface->members = g_list_append (iface->members, function);
}
case G_IR_NODE_BOXED:
{
GIrNodeBoxed *boxed;
-
+
boxed = (GIrNodeBoxed *)CURRENT_NODE (ctx);
boxed->members = g_list_append (boxed->members, function);
}
case G_IR_NODE_STRUCT:
{
GIrNodeStruct *struct_;
-
+
struct_ = (GIrNodeStruct *)CURRENT_NODE (ctx);
struct_->members = g_list_append (struct_->members, function); }
break;
case G_IR_NODE_UNION:
{
GIrNodeUnion *union_;
-
+
union_ = (GIrNodeUnion *)CURRENT_NODE (ctx);
union_->members = g_list_append (union_->members, function);
}
default:
g_assert_not_reached ();
}
-
+
push_node(ctx, (GIrNode *)function);
state_switch (ctx, STATE_FUNCTION);
-
+
return TRUE;
}
const gchar *closure;
const gchar *destroy;
GIrNodeParam *param;
-
+
if (!(strcmp (element_name, "parameter") == 0 &&
ctx->state == STATE_FUNCTION_PARAMETERS))
return FALSE;
scope = find_attribute ("scope", attribute_names, attribute_values);
closure = find_attribute ("closure", attribute_names, attribute_values);
destroy = find_attribute ("destroy", attribute_names, attribute_values);
-
+
if (name == NULL)
name = "unknown";
param->scope = GI_SCOPE_TYPE_NOTIFIED;
else
param->scope = GI_SCOPE_TYPE_INVALID;
-
+
param->closure = closure ? atoi (closure) : -1;
param->destroy = destroy ? atoi (destroy) : -1;
-
+
((GIrNode *)param)->name = g_strdup (name);
-
+
switch (CURRENT_NODE (ctx)->type)
{
case G_IR_NODE_FUNCTION:
case G_IR_NODE_VFUNC:
{
GIrNodeVFunc *vfunc;
-
+
vfunc = (GIrNodeVFunc *)CURRENT_NODE (ctx);
vfunc->parameters = g_list_append (vfunc->parameters, param);
}
default:
return FALSE;
}
-
+
if (strcmp (element_name, "field") != 0)
return FALSE;
-
+
name = find_attribute ("name", attribute_names, attribute_values);
readable = find_attribute ("readable", attribute_names, attribute_values);
writable = find_attribute ("writable", attribute_names, attribute_values);
bits = find_attribute ("bits", attribute_names, attribute_values);
branch = find_attribute ("branch", attribute_names, attribute_values);
-
+
if (name == NULL)
{
MISSING_ATTRIBUTE (context, error, element_name, "name");
*/
field->readable = readable == NULL || strcmp (readable, "0") == 0;
field->writable = writable != NULL && strcmp (writable, "1") == 0;
-
+
if (bits)
field->bits = atoi (bits);
else
field->bits = 0;
-
+
switch (CURRENT_NODE (ctx)->type)
{
case G_IR_NODE_OBJECT:
{
GIrNodeInterface *iface;
-
+
iface = (GIrNodeInterface *)CURRENT_NODE (ctx);
iface->members = g_list_append (iface->members, field);
state_switch (ctx, STATE_CLASS_FIELD);
case G_IR_NODE_INTERFACE:
{
GIrNodeInterface *iface;
-
+
iface = (GIrNodeInterface *)CURRENT_NODE (ctx);
iface->members = g_list_append (iface->members, field);
state_switch (ctx, STATE_INTERFACE_FIELD);
case G_IR_NODE_BOXED:
{
GIrNodeBoxed *boxed;
-
+
boxed = (GIrNodeBoxed *)CURRENT_NODE (ctx);
boxed->members = g_list_append (boxed->members, field);
state_switch (ctx, STATE_BOXED_FIELD);
case G_IR_NODE_STRUCT:
{
GIrNodeStruct *struct_;
-
+
struct_ = (GIrNodeStruct *)CURRENT_NODE (ctx);
struct_->members = g_list_append (struct_->members, field);
state_switch (ctx, STATE_STRUCT_FIELD);
case G_IR_NODE_UNION:
{
GIrNodeUnion *union_;
-
+
union_ = (GIrNodeUnion *)CURRENT_NODE (ctx);
union_->members = g_list_append (union_->members, field);
if (branch)
{
GIrNodeConstant *constant;
-
+
constant = (GIrNodeConstant *) g_ir_node_new (G_IR_NODE_CONSTANT);
((GIrNode *)constant)->name = g_strdup (name);
- constant->value = g_strdup (branch);
+ constant->value = g_strdup (branch);
constant->type = union_->discriminator_type;
constant->deprecated = FALSE;
-
+
union_->discriminators = g_list_append (union_->discriminators, constant);
}
state_switch (ctx, STATE_UNION_FIELD);
default:
g_assert_not_reached ();
}
-
+
return TRUE;
}
const gchar *typename;
const gchar *typeinit;
const gchar *deprecated;
-
+
name = find_attribute ("name", attribute_names, attribute_values);
typename = find_attribute ("glib:type-name", attribute_names, attribute_values);
typeinit = find_attribute ("glib:get-type", attribute_names, attribute_values);
deprecated = find_attribute ("deprecated", attribute_names, attribute_values);
-
+
if (name == NULL)
MISSING_ATTRIBUTE (context, error, element_name, "name");
- else
- {
+ else
+ {
GIrNodeEnum *enum_;
-
+
if (strcmp (element_name, "enumeration") == 0)
enum_ = (GIrNodeEnum *) g_ir_node_new (G_IR_NODE_ENUM);
else
enum_->deprecated = FALSE;
push_node (ctx, (GIrNode *) enum_);
- ctx->current_module->entries =
- g_list_append (ctx->current_module->entries, enum_);
-
+ ctx->current_module->entries =
+ g_list_append (ctx->current_module->entries, enum_);
+
state_switch (ctx, STATE_ENUM);
}
-
+
return TRUE;
}
return FALSE;
const gchar *writable;
const gchar *construct;
const gchar *construct_only;
-
+
name = find_attribute ("name", attribute_names, attribute_values);
readable = find_attribute ("readable", attribute_names, attribute_values);
writable = find_attribute ("writable", attribute_names, attribute_values);
construct = find_attribute ("construct", attribute_names, attribute_values);
construct_only = find_attribute ("construct-only", attribute_names, attribute_values);
-
+
if (name == NULL)
MISSING_ATTRIBUTE (context, error, element_name, "name");
- else
- {
+ else
+ {
GIrNodeProperty *property;
GIrNodeInterface *iface;
-
+
property = (GIrNodeProperty *) g_ir_node_new (G_IR_NODE_PROPERTY);
ctx->current_typed = (GIrNode*) property;
((GIrNode *)property)->name = g_strdup (name);
-
+
/* Assume properties are readable */
if (readable == NULL || strcmp (readable, "1") == 0)
property->readable = TRUE;
else
g_assert_not_reached ();
}
-
+
return TRUE;
}
return FALSE;
parse_value (const gchar *str)
{
gchar *shift_op;
-
+
/* FIXME just a quick hack */
shift_op = strstr (str, "<<");
base = strtol (str, NULL, 10);
shift = strtol (shift_op + 3, NULL, 10);
-
+
return base << shift;
}
else
const gchar *name;
const gchar *value;
const gchar *deprecated;
-
+
name = find_attribute ("name", attribute_names, attribute_values);
value = find_attribute ("value", attribute_names, attribute_values);
deprecated = find_attribute ("deprecated", attribute_names, attribute_values);
-
+
if (name == NULL)
MISSING_ATTRIBUTE (context, error, element_name, "name");
- else
- {
+ else
+ {
GIrNodeEnum *enum_;
GIrNodeValue *value_;
value_ = (GIrNodeValue *) g_ir_node_new (G_IR_NODE_VALUE);
((GIrNode *)value_)->name = g_strdup (name);
-
+
value_->value = parse_value (value);
-
+
if (deprecated)
value_->deprecated = TRUE;
else
enum_ = (GIrNodeEnum *)CURRENT_NODE (ctx);
enum_->values = g_list_append (enum_->values, value_);
}
-
+
return TRUE;
}
return FALSE;
const gchar *name;
const gchar *value;
const gchar *deprecated;
-
+
name = find_attribute ("name", attribute_names, attribute_values);
value = find_attribute ("value", attribute_names, attribute_values);
deprecated = find_attribute ("deprecated", attribute_names, attribute_values);
-
+
if (name == NULL)
MISSING_ATTRIBUTE (context, error, element_name, "name");
else if (value == NULL)
MISSING_ATTRIBUTE (context, error, element_name, "value");
- else
- {
+ else
+ {
GIrNodeConstant *constant;
constant = (GIrNodeConstant *) g_ir_node_new (G_IR_NODE_CONSTANT);
if (ctx->state == STATE_NAMESPACE)
{
push_node (ctx, (GIrNode *) constant);
- ctx->current_module->entries =
+ ctx->current_module->entries =
g_list_append (ctx->current_module->entries, constant);
}
else
break;
}
}
-
+
return TRUE;
}
return FALSE;
const gchar *getquark;
const gchar *codes;
const gchar *deprecated;
-
+
name = find_attribute ("name", attribute_names, attribute_values);
getquark = find_attribute ("get-quark", attribute_names, attribute_values);
codes = find_attribute ("codes", attribute_names, attribute_values);
deprecated = find_attribute ("deprecated", attribute_names, attribute_values);
-
+
if (name == NULL)
MISSING_ATTRIBUTE (context, error, element_name, "name");
else if (getquark == NULL)
MISSING_ATTRIBUTE (context, error, element_name, "getquark");
else if (codes == NULL)
MISSING_ATTRIBUTE (context, error, element_name, "codes");
- else
- {
+ else
+ {
GIrNodeErrorDomain *domain;
domain = (GIrNodeErrorDomain *) g_ir_node_new (G_IR_NODE_ERROR_DOMAIN);
domain->deprecated = FALSE;
push_node (ctx, (GIrNode *) domain);
- ctx->current_module->entries =
+ ctx->current_module->entries =
g_list_append (ctx->current_module->entries, domain);
state_switch (ctx, STATE_ERRORDOMAIN);
}
-
+
return TRUE;
}
return FALSE;
const gchar *typeinit;
const gchar *deprecated;
const gchar *glib_type_struct;
-
+
name = find_attribute ("name", attribute_names, attribute_values);
typename = find_attribute ("glib:type-name", attribute_names, attribute_values);
typeinit = find_attribute ("glib:get-type", attribute_names, attribute_values);
glib_type_struct = find_attribute ("glib:type-struct", attribute_names, attribute_values);
deprecated = find_attribute ("deprecated", attribute_names, attribute_values);
-
+
if (name == NULL)
MISSING_ATTRIBUTE (context, error, element_name, "name");
else if (typename == NULL)
iface->deprecated = TRUE;
else
iface->deprecated = FALSE;
-
+
push_node (ctx, (GIrNode *) iface);
- ctx->current_module->entries =
- g_list_append (ctx->current_module->entries, iface);
-
+ ctx->current_module->entries =
+ g_list_append (ctx->current_module->entries, iface);
+
state_switch (ctx, STATE_INTERFACE);
-
+
}
-
+
return TRUE;
}
return FALSE;
const gchar *typeinit;
const gchar *deprecated;
const gchar *abstract;
-
+
name = find_attribute ("name", attribute_names, attribute_values);
parent = find_attribute ("parent", attribute_names, attribute_values);
glib_type_struct = find_attribute ("glib:type-struct", attribute_names, attribute_values);
typeinit = find_attribute ("glib:get-type", attribute_names, attribute_values);
deprecated = find_attribute ("deprecated", attribute_names, attribute_values);
abstract = find_attribute ("abstract", attribute_names, attribute_values);
-
+
if (name == NULL)
MISSING_ATTRIBUTE (context, error, element_name, "name");
else if (typename == NULL)
iface->abstract = abstract && strcmp (abstract, "1") == 0;
push_node (ctx, (GIrNode *) iface);
- ctx->current_module->entries =
- g_list_append (ctx->current_module->entries, iface);
-
+ ctx->current_module->entries =
+ g_list_append (ctx->current_module->entries, iface);
+
state_switch (ctx, STATE_CLASS);
}
-
+
return TRUE;
}
return FALSE;
if (!(is_array || is_varargs || (strcmp (element_name, "type") == 0)))
return FALSE;
- if (ctx->state == STATE_TYPE)
+ if (ctx->state == STATE_TYPE)
{
ctx->type_depth++;
ctx->type_stack = g_list_prepend (ctx->type_stack, ctx->type_parameters);
ctx->type_parameters = NULL;
- }
+ }
else if (ctx->state == STATE_FUNCTION_PARAMETER ||
- ctx->state == STATE_FUNCTION_RETURN ||
+ ctx->state == STATE_FUNCTION_RETURN ||
ctx->state == STATE_STRUCT_FIELD ||
ctx->state == STATE_UNION_FIELD ||
ctx->state == STATE_CLASS_PROPERTY ||
if (is_varargs)
return TRUE;
- if (is_array)
+ if (is_array)
{
const char *zero;
const char *len;
typenode->tag = GI_TYPE_TAG_ARRAY;
typenode->is_pointer = TRUE;
typenode->is_array = TRUE;
-
+
zero = find_attribute ("zero-terminated", attribute_names, attribute_values);
len = find_attribute ("length", attribute_names, attribute_values);
size = find_attribute ("fixed-size", attribute_names, attribute_values);
-
+
typenode->zero_terminated = !(zero && strcmp (zero, "1") != 0);
typenode->has_length = len != NULL;
typenode->length = typenode->has_length ? atoi (len) : -1;
-
+
typenode->has_size = size != NULL;
typenode->size = typenode->has_size ? atoi (size) : -1;
if (name == NULL)
MISSING_ATTRIBUTE (context, error, element_name, "name");
-
+
pointer_depth = 0;
ctype = find_attribute ("c:type", attribute_names, attribute_values);
if (ctype != NULL)
while (cp > ctype && *cp-- == '*')
pointer_depth++;
}
-
+
if (ctx->current_typed->type == G_IR_NODE_PARAM &&
((GIrNodeParam *)ctx->current_typed)->out &&
pointer_depth > 0)
pointer_depth--;
-
+
typenode = parse_type (ctx, name);
/* A 'disguised' structure is one where the c:type is a typedef that
}
ctx->type_parameters = g_list_append (ctx->type_parameters, typenode);
-
+
return TRUE;
}
}
g_list_free (ctx->type_parameters);
- out:
+ out:
ctx->type_depth = 0;
ctx->type_parameters = NULL;
ctx->current_typed = NULL;
default:
g_assert_not_reached ();
}
-
+
return TRUE;
}
return FALSE;
state_switch (ctx, STATE_IMPLEMENTS);
-
+
name = find_attribute ("name", attribute_names, attribute_values);
if (name == NULL)
{
MISSING_ATTRIBUTE (context, error, element_name, "name");
return FALSE;
}
-
+
iface = (GIrNodeInterface *)CURRENT_NODE (ctx);
iface->interfaces = g_list_append (iface->interfaces, g_strdup (name));
ParseContext *ctx,
GError **error)
{
- if (strcmp (element_name, "glib:signal") == 0 &&
+ if (strcmp (element_name, "glib:signal") == 0 &&
(ctx->state == STATE_CLASS ||
ctx->state == STATE_INTERFACE))
{
const gchar *action;
const gchar *no_hooks;
const gchar *has_class_closure;
-
+
name = find_attribute ("name", attribute_names, attribute_values);
when = find_attribute ("when", attribute_names, attribute_values);
no_recurse = find_attribute ("no-recurse", attribute_names, attribute_values);
action = find_attribute ("action", attribute_names, attribute_values);
no_hooks = find_attribute ("no-hooks", attribute_names, attribute_values);
has_class_closure = find_attribute ("has-class-closure", attribute_names, attribute_values);
-
+
if (name == NULL)
MISSING_ATTRIBUTE (context, error, element_name, "name");
else
GIrNodeSignal *signal;
signal = (GIrNodeSignal *)g_ir_node_new (G_IR_NODE_SIGNAL);
-
+
((GIrNode *)signal)->name = g_strdup (name);
-
+
signal->run_first = FALSE;
signal->run_last = FALSE;
signal->run_cleanup = FALSE;
signal->run_last = TRUE;
else if (strcmp (when, "FIRST") == 0)
signal->run_first = TRUE;
- else
+ else
signal->run_cleanup = TRUE;
-
+
if (no_recurse && strcmp (no_recurse, "1") == 0)
signal->no_recurse = TRUE;
else
push_node (ctx, (GIrNode *)signal);
state_switch (ctx, STATE_FUNCTION);
}
-
+
return TRUE;
}
return FALSE;
const gchar *is_class_closure;
const gchar *offset;
const gchar *invoker;
-
+
name = find_attribute ("name", attribute_names, attribute_values);
- must_chain_up = find_attribute ("must-chain-up", attribute_names, attribute_values);
+ must_chain_up = find_attribute ("must-chain-up", attribute_names, attribute_values);
override = find_attribute ("override", attribute_names, attribute_values);
is_class_closure = find_attribute ("is-class-closure", attribute_names, attribute_values);
offset = find_attribute ("offset", attribute_names, attribute_values);
invoker = find_attribute ("invoker", attribute_names, attribute_values);
-
+
if (name == NULL)
MISSING_ATTRIBUTE (context, error, element_name, "name");
else
GIrNodeVFunc *vfunc;
vfunc = (GIrNodeVFunc *)g_ir_node_new (G_IR_NODE_VFUNC);
-
+
((GIrNode *)vfunc)->name = g_strdup (name);
if (must_chain_up && strcmp (must_chain_up, "1") == 0)
vfunc->must_be_implemented = FALSE;
vfunc->must_not_be_implemented = FALSE;
}
-
+
if (is_class_closure && strcmp (is_class_closure, "1") == 0)
vfunc->is_class_closure = TRUE;
else
vfunc->is_class_closure = FALSE;
-
+
if (offset)
vfunc->offset = atoi (offset);
else
push_node (ctx, (GIrNode *)vfunc);
state_switch (ctx, STATE_FUNCTION);
}
-
+
return TRUE;
}
return FALSE;
ParseContext *ctx,
GError **error)
{
- if (strcmp (element_name, "record") == 0 &&
+ if (strcmp (element_name, "record") == 0 &&
(ctx->state == STATE_NAMESPACE ||
ctx->state == STATE_UNION ||
ctx->state == STATE_STRUCT ||
const gchar *gtype_init;
const gchar *gtype_struct;
GIrNodeStruct *struct_;
-
+
name = find_attribute ("name", attribute_names, attribute_values);
deprecated = find_attribute ("deprecated", attribute_names, attribute_values);
disguised = find_attribute ("disguised", attribute_names, attribute_values);
}
struct_ = (GIrNodeStruct *) g_ir_node_new (G_IR_NODE_STRUCT);
-
+
((GIrNode *)struct_)->name = g_strdup (name ? name : "");
if (deprecated)
struct_->deprecated = TRUE;
if (disguised && strcmp (disguised, "1") == 0)
struct_->disguised = TRUE;
-
+
struct_->is_gtype_struct = gtype_struct != NULL;
struct_->gtype_name = g_strdup (gtype_name);
struct_->gtype_init = g_strdup (gtype_init);
if (ctx->node_stack == NULL)
- ctx->current_module->entries =
+ ctx->current_module->entries =
g_list_append (ctx->current_module->entries, struct_);
push_node (ctx, (GIrNode *)struct_);
-
+
state_switch (ctx, STATE_STRUCT);
return TRUE;
}
return FALSE;
}
-
+
static gboolean
start_union (GMarkupParseContext *context,
const gchar *deprecated;
const gchar *typename;
const gchar *typeinit;
-
+
name = find_attribute ("name", attribute_names, attribute_values);
deprecated = find_attribute ("deprecated", attribute_names, attribute_values);
typename = find_attribute ("glib:type-name", attribute_names, attribute_values);
typeinit = find_attribute ("glib:get-type", attribute_names, attribute_values);
-
+
if (name == NULL && ctx->node_stack == NULL)
MISSING_ATTRIBUTE (context, error, element_name, "name");
else
GIrNodeUnion *union_;
union_ = (GIrNodeUnion *) g_ir_node_new (G_IR_NODE_UNION);
-
+
((GIrNode *)union_)->name = g_strdup (name ? name : "");
union_->gtype_name = g_strdup (typename);
union_->gtype_init = g_strdup (typeinit);
union_->deprecated = FALSE;
if (ctx->node_stack == NULL)
- ctx->current_module->entries =
+ ctx->current_module->entries =
g_list_append (ctx->current_module->entries, union_);
push_node (ctx, (GIrNode *)union_);
-
+
state_switch (ctx, STATE_UNION);
}
return TRUE;
{
const gchar *type;
const gchar *offset;
-
+
type = find_attribute ("type", attribute_names, attribute_values);
offset = find_attribute ("offset", attribute_names, attribute_values);
if (type == NULL)
else if (offset == NULL)
MISSING_ATTRIBUTE (context, error, element_name, "offset");
{
- ((GIrNodeUnion *)CURRENT_NODE (ctx))->discriminator_type
+ ((GIrNodeUnion *)CURRENT_NODE (ctx))->discriminator_type
= parse_type (ctx, type);
- ((GIrNodeUnion *)CURRENT_NODE (ctx))->discriminator_offset
+ ((GIrNodeUnion *)CURRENT_NODE (ctx))->discriminator_offset
= atoi (offset);
}
-
+
return TRUE;
}
return success;
}
-
+
extern GLogLevelFlags logged_levels;
static void
g_string_free (tags, TRUE);
}
- switch (element_name[0])
+ switch (element_name[0])
{
case 'a':
- if (ctx->state == STATE_NAMESPACE && strcmp (element_name, "alias") == 0)
+ if (ctx->state == STATE_NAMESPACE && strcmp (element_name, "alias") == 0)
{
state_switch (ctx, STATE_ALIAS);
goto out;
goto out;
break;
case 'b':
- if (start_enum (context, element_name,
+ if (start_enum (context, element_name,
attribute_names, attribute_values,
ctx, error))
goto out;
break;
case 'c':
- if (start_function (context, element_name,
+ if (start_function (context, element_name,
attribute_names, attribute_values,
ctx, error))
goto out;
attribute_names, attribute_values,
ctx, error))
goto out;
- else if (start_class (context, element_name,
+ else if (start_class (context, element_name,
attribute_names, attribute_values,
ctx, error))
goto out;
break;
case 'd':
- if (start_discriminator (context, element_name,
+ if (start_discriminator (context, element_name,
attribute_names, attribute_values,
ctx, error))
goto out;
break;
case 'e':
- if (start_enum (context, element_name,
+ if (start_enum (context, element_name,
attribute_names, attribute_values,
ctx, error))
goto out;
- else if (start_errordomain (context, element_name,
+ else if (start_errordomain (context, element_name,
attribute_names, attribute_values,
ctx, error))
goto out;
break;
case 'f':
- if (start_function (context, element_name,
+ if (start_function (context, element_name,
attribute_names, attribute_values,
ctx, error))
goto out;
- else if (start_field (context, element_name,
+ else if (start_field (context, element_name,
attribute_names, attribute_values,
ctx, error))
goto out;
state_switch (ctx, STATE_INCLUDE);
goto out;
}
- if (start_interface (context, element_name,
+ if (start_interface (context, element_name,
attribute_names, attribute_values,
ctx, error))
goto out;
break;
case 'm':
- if (start_function (context, element_name,
+ if (start_function (context, element_name,
attribute_names, attribute_values,
ctx, error))
goto out;
- else if (start_member (context, element_name,
+ else if (start_member (context, element_name,
attribute_names, attribute_values,
ctx, error))
goto out;
if (name == NULL)
MISSING_ATTRIBUTE (context, error, element_name, "name");
else
- {
+ {
GIrNodeInterface *iface;
iface = (GIrNodeInterface *)CURRENT_NODE(ctx);
const gchar *version;
version = find_attribute ("version", attribute_names, attribute_values);
-
+
if (version == NULL)
MISSING_ATTRIBUTE (context, error, element_name, "version");
else if (strcmp (version, "1.0") != 0)
version);
else
state_switch (ctx, STATE_REPOSITORY);
-
+
goto out;
}
else if (start_return_value (context, element_name,
attribute_names, attribute_values,
ctx, error))
- goto out;
+ goto out;
else if (start_struct (context, element_name,
attribute_names, attribute_values,
ctx, error))
- goto out;
+ goto out;
break;
case 'u':
{
ctx->unknown_depth += 1;
}
-
+
out:
- if (*error)
+ if (*error)
{
g_markup_parse_context_get_position (context, &line_number, &char_number);
require_one_of_end_elements (GMarkupParseContext *context,
ParseContext *ctx,
const char *actual_name,
- GError **error,
+ GError **error,
...)
{
va_list args;
va_start (args, error);
- while ((expected = va_arg (args, const char*)) != NULL)
+ while ((expected = va_arg (args, const char*)) != NULL)
{
if (strcmp (expected, actual_name) == 0)
{
G_MARKUP_ERROR,
G_MARKUP_ERROR_INVALID_CONTENT,
"Unexpected end tag '%s' on line %d char %d; current state=%d",
- actual_name,
+ actual_name,
line_number, char_number, ctx->state);
backtrace_stderr();
return FALSE;
{
state_switch (ctx, STATE_NAMESPACE);
}
- else
+ else
{
if (CURRENT_NODE (ctx)->type == G_IR_NODE_STRUCT)
state_switch (ctx, STATE_STRUCT);
state_switch (ctx, STATE_REPOSITORY);
}
break;
-
+
case STATE_PACKAGE:
if (require_end_element (context, ctx, "package", element_name, error))
{
state_switch (ctx, STATE_REPOSITORY);
}
- break;
+ break;
case STATE_NAMESPACE:
if (require_end_element (context, ctx, "namespace", element_name, error))
{
state_switch (ctx, STATE_NAMESPACE);
}
- else
+ else
{
g_debug("case STATE_FUNCTION %d", CURRENT_NODE (ctx)->type);
if (ctx->in_embedded_type)
}
else if (CURRENT_NODE (ctx)->type == G_IR_NODE_INTERFACE)
state_switch (ctx, STATE_INTERFACE);
- else if (CURRENT_NODE (ctx)->type == G_IR_NODE_OBJECT)
+ else if (CURRENT_NODE (ctx)->type == G_IR_NODE_OBJECT)
state_switch (ctx, STATE_CLASS);
else if (CURRENT_NODE (ctx)->type == G_IR_NODE_BOXED)
state_switch (ctx, STATE_BOXED);
case STATE_ENUM:
if (strcmp ("member", element_name) == 0)
break;
- else if (require_one_of_end_elements (context, ctx,
- element_name, error, "enumeration",
+ else if (require_one_of_end_elements (context, ctx,
+ element_name, error, "enumeration",
"bitfield", NULL))
{
pop_node (ctx);
}
}
-static void
+static void
text_handler (GMarkupParseContext *context,
const gchar *text,
- gsize text_len,
+ gsize text_len,
gpointer user_data,
GError **error)
{
g_ir_module_free (m->data);
g_list_free (ctx->modules);
ctx->modules = NULL;
-
+
ctx->current_module = NULL;
}
static GList *
-post_filter_toplevel_varargs_functions (GList *list,
+post_filter_toplevel_varargs_functions (GList *list,
GList **varargs_callbacks_out)
{
GList *iter;
GList *varargs_callbacks = *varargs_callbacks_out;
-
+
iter = list;
while (iter)
{
GList *link = iter;
GIrNode *node = iter->data;
-
+
iter = iter->next;
-
+
if (node->type == G_IR_NODE_FUNCTION)
{
if (((GIrNodeFunction*)node)->is_varargs)
}
}
}
-
+
*varargs_callbacks_out = varargs_callbacks;
-
+
return list;
}
{
GList *iter;
GList *varargs_callbacks;
-
+
list = post_filter_toplevel_varargs_functions (list, varargs_callbacks_out);
-
+
varargs_callbacks = *varargs_callbacks_out;
iter = list;
{
GList *link = iter;
GIrNode *node = iter->data;
-
+
iter = iter->next;
-
+
if (node->type == G_IR_NODE_FUNCTION)
{
GList *param;
gboolean function_done = FALSE;
-
+
for (param = ((GIrNodeFunction *)node)->parameters;
param;
param = param->next)
{
GIrNodeParam *node = (GIrNodeParam *)param->data;
-
+
if (function_done)
break;
}
}
}
-
+
*varargs_callbacks_out = varargs_callbacks;
-
+
return list;
}
{
GList *iter;
GList *varargs_callbacks = NULL;
-
+
module->entries = post_filter_varargs_functions (module->entries,
&varargs_callbacks);
iter = module->entries;
while (iter)
{
GIrNode *node = iter->data;
-
+
iter = iter->next;
-
- if (node->type == G_IR_NODE_OBJECT ||
- node->type == G_IR_NODE_INTERFACE)
+
+ if (node->type == G_IR_NODE_OBJECT ||
+ node->type == G_IR_NODE_INTERFACE)
{
GIrNodeInterface *iface = (GIrNodeInterface*)node;
iface->members = post_filter_varargs_functions (iface->members,
goto out;
g_markup_parse_context_free (context);
-
+
context = g_markup_parse_context_new (&markup_parser, 0, &ctx, NULL);
if (!g_markup_parse_context_parse (context, buffer, length, error))
goto out;
g_hash_table_destroy (ctx.disguised_structures);
g_list_free (ctx.include_modules);
}
-
+
g_markup_parse_context_free (context);
-
+
return ctx.modules;
}
if (!g_file_get_contents (filename, &buffer, &length, error))
return NULL;
-
+
modules = g_ir_parser_parse_string (parser, namespace, buffer, length, error);
- for (iter = modules; iter; iter = iter->next)
+ for (iter = modules; iter; iter = iter->next)
{
post_filter ((GIrModule*)iter->data);
}
{
GIdlNodeParam *param = l->data;
const gchar *direction = g_idl_node_param_direction_string (param);
-
+
markup_s = g_string_new ("<parameter");
g_string_append_printf (markup_s, " name=\"%s\"", param->node.name);
if (param->allow_none)
g_string_append (markup_s,
g_markup_printf_escaped (" allow-none=\"1\""));
-
+
if (strcmp (direction, "in") != 0)
g_string_append (markup_s,
g_markup_printf_escaped (" direction=\"%s\"",
-/* GObject introspection: typelib validation, auxiliary functions
+/* GObject introspection: typelib validation, auxiliary functions
* related to the binary typelib format
*
* Copyright (C) 2005 Matthias Clasen
pop_context (ValidateContext *ctx)
{
g_assert (ctx->context_stack != NULL);
- ctx->context_stack = g_slist_delete_link (ctx->context_stack,
+ ctx->context_stack = g_slist_delete_link (ctx->context_stack,
ctx->context_stack);
}
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_BLOB,
"Invalid directory index %d", index);
- return FALSE;
+ return FALSE;
}
offset = header->directory + (index - 1) * header->entry_blob_size;
return (DirEntry *)&typelib->data[header->directory + (index - 1) * header->entry_blob_size];
}
-void
+void
g_typelib_check_sanity (void)
{
/* Check that struct layout is as we expect */
*
* Everything else in the code however should be using sizeof().
*/
-
+
CHECK_SIZE (Header, 112);
CHECK_SIZE (DirEntry, 12);
CHECK_SIZE (SimpleTypeBlob, 4);
if (!name)
return FALSE;
- if (!memchr (name, '\0', MAX_NAME_LEN))
+ if (!memchr (name, '\0', MAX_NAME_LEN))
{
g_set_error (error,
G_TYPELIB_ERROR,
msg, name);
return FALSE;
}
-
- if (strspn (name, G_CSET_a_2_z G_CSET_A_2_Z G_CSET_DIGITS "-_") < strlen (name))
+
+ if (strspn (name, G_CSET_a_2_z G_CSET_A_2_Z G_CSET_DIGITS "-_") < strlen (name))
{
g_set_error (error,
G_TYPELIB_ERROR,
msg, name);
return FALSE;
}
-
+
return TRUE;
}
-static gboolean
+static gboolean
validate_header (ValidateContext *ctx,
GError **error)
{
G_TYPELIB_ERROR_INVALID_HEADER,
"Magic string not found");
return FALSE;
-
+
}
if (header->major_version != 2 || header->minor_version != 0)
G_TYPELIB_ERROR_INVALID_HEADER,
"Version mismatch");
return FALSE;
-
+
}
if (header->n_entries < header->n_local_entries)
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_HEADER,
"Inconsistent entry counts");
- return FALSE;
+ return FALSE;
}
if (header->size != typelib->len)
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_HEADER,
"Typelib size mismatch");
- return FALSE;
+ return FALSE;
}
-
+
/* This is a sanity check for a specific typelib; it
* prevents us from loading an incompatible typelib.
- *
+ *
* The hardcoded checks in g_typelib_check_sanity to
* protect against inadvertent or buggy changes to the typelib format
* itself.
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_HEADER,
"Blob size mismatch");
- return FALSE;
+ return FALSE;
}
if (!is_aligned (header->directory))
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_HEADER,
"Misaligned directory");
- return FALSE;
+ return FALSE;
}
if (!is_aligned (header->attributes))
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_HEADER,
"Misaligned attributes");
- return FALSE;
+ return FALSE;
}
if (header->attributes == 0 && header->n_attributes > 0)
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_HEADER,
"Wrong number of attributes");
- return FALSE;
+ return FALSE;
}
if (!validate_name (typelib, "namespace", typelib->data, header->namespace, error))
- return FALSE;
+ return FALSE;
return TRUE;
}
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_BLOB,
"Pointer type exected for tag %d", blob->tag);
- return FALSE;
+ return FALSE;
}
/* FIXME validate length */
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_BLOB,
"Pointer type exected for tag %d", blob->tag);
- return FALSE;
+ return FALSE;
}
-
+
if (blob->n_types != n_params)
{
g_set_error (error,
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_BLOB,
"Parameter type number mismatch");
- return FALSE;
+ return FALSE;
}
-
+
for (i = 0; i < n_params; i++)
{
if (!validate_type_blob (typelib,
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_BLOB,
"Pointer type exected for tag %d", blob->tag);
- return FALSE;
+ return FALSE;
}
-
+
for (i = 0; i < blob->n_domains; i++)
{
if (blob->domains[i] == 0 || blob->domains[i] > header->n_entries)
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_BLOB,
"Invalid directory index %d", blob->domains[i]);
- return FALSE;
+ return FALSE;
}
entry = g_typelib_get_dir_entry (typelib, blob->domains[i]);
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_BLOB,
"Wrong blob type");
- return FALSE;
+ return FALSE;
}
}
{
SimpleTypeBlob *simple;
InterfaceTypeBlob *iface;
-
+
simple = (SimpleTypeBlob *)&typelib->data[offset];
- if (simple->flags.reserved == 0 &&
+ if (simple->flags.reserved == 0 &&
simple->flags.reserved2 == 0)
{
if (simple->flags.tag >= GI_TYPE_TAG_ARRAY)
"Wrong tag in simple type");
return FALSE;
}
-
+
if (simple->flags.tag >= GI_TYPE_TAG_UTF8 &&
!simple->flags.pointer)
{
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_BLOB,
"Pointer type exected for tag %d", simple->flags.tag);
- return FALSE;
+ return FALSE;
}
return TRUE;
switch (iface->tag)
{
case GI_TYPE_TAG_ARRAY:
- if (!validate_array_type_blob (typelib, simple->offset,
+ if (!validate_array_type_blob (typelib, simple->offset,
signature_offset, return_type, error))
return FALSE;
break;
case GI_TYPE_TAG_INTERFACE:
- if (!validate_iface_type_blob (typelib, simple->offset,
+ if (!validate_iface_type_blob (typelib, simple->offset,
signature_offset, return_type, error))
return FALSE;
break;
case GI_TYPE_TAG_GLIST:
case GI_TYPE_TAG_GSLIST:
- if (!validate_param_type_blob (typelib, simple->offset,
+ if (!validate_param_type_blob (typelib, simple->offset,
signature_offset, return_type, 1, error))
return FALSE;
break;
case GI_TYPE_TAG_GHASH:
- if (!validate_param_type_blob (typelib, simple->offset,
+ if (!validate_param_type_blob (typelib, simple->offset,
signature_offset, return_type, 2, error))
return FALSE;
break;
case GI_TYPE_TAG_ERROR:
- if (!validate_error_type_blob (typelib, simple->offset,
+ if (!validate_error_type_blob (typelib, simple->offset,
signature_offset, return_type, error))
return FALSE;
break;
blob = (ArgBlob*) &typelib->data[offset];
if (!validate_name (typelib, "argument", typelib->data, blob->name, error))
- return FALSE;
-
- if (!validate_type_blob (typelib,
- offset + G_STRUCT_OFFSET (ArgBlob, arg_type),
+ return FALSE;
+
+ if (!validate_type_blob (typelib,
+ offset + G_STRUCT_OFFSET (ArgBlob, arg_type),
signature_offset, FALSE, error))
return FALSE;
if (blob->return_type.offset != 0)
{
- if (!validate_type_blob (typelib,
- offset + G_STRUCT_OFFSET (SignatureBlob, return_type),
+ if (!validate_type_blob (typelib,
+ offset + G_STRUCT_OFFSET (SignatureBlob, return_type),
offset, TRUE, error))
return FALSE;
}
for (i = 0; i < blob->n_arguments; i++)
{
- if (!validate_arg_blob (typelib,
- offset + sizeof (SignatureBlob) +
- i * sizeof (ArgBlob),
- offset,
+ if (!validate_arg_blob (typelib,
+ offset + sizeof (SignatureBlob) +
+ i * sizeof (ArgBlob),
+ offset,
error))
return FALSE;
}
}
if (!validate_name (typelib, "function", typelib->data, blob->name, error))
- return FALSE;
+ return FALSE;
push_context (ctx, get_string_nofail (typelib, blob->name));
-
+
if (!validate_name (typelib, "function symbol", typelib->data, blob->symbol, error))
- return FALSE;
+ return FALSE;
switch (container_type)
{
default:
is_method = FALSE;
}
-
+
if (blob->constructor)
{
switch (container_type)
sigblob = (SignatureBlob*) &typelib->data[blob->signature];
- if (blob->constructor)
+ if (blob->constructor)
{
SimpleTypeBlob *simple = return_type_from_signature (typelib,
blob->signature,
}
if (!validate_name (typelib, "callback", typelib->data, blob->name, error))
- return FALSE;
+ return FALSE;
push_context (ctx, get_string_nofail (typelib, blob->name));
-
+
if (!validate_signature_blob (typelib, blob->signature, error))
return FALSE;
pop_context (ctx);
-
+
return TRUE;
}
}
if (!validate_name (typelib, "constant", typelib->data, blob->name, error))
- return FALSE;
-
- if (!validate_type_blob (typelib, offset + G_STRUCT_OFFSET (ConstantBlob, type),
+ return FALSE;
+
+ if (!validate_type_blob (typelib, offset + G_STRUCT_OFFSET (ConstantBlob, type),
0, FALSE, error))
return FALSE;
"Misaligned constant value");
return FALSE;
}
-
+
type = (SimpleTypeBlob *)&typelib->data[offset + G_STRUCT_OFFSET (ConstantBlob, type)];
if (type->flags.reserved == 0 && type->flags.reserved2 == 0)
{
blob = (ValueBlob*) &typelib->data[offset];
if (!validate_name (typelib, "value", typelib->data, blob->name, error))
- return FALSE;
-
+ return FALSE;
+
return TRUE;
}
}
blob = (FieldBlob*) &typelib->data[offset];
-
+
if (!validate_name (typelib, "field", typelib->data, blob->name, error))
- return FALSE;
+ return FALSE;
if (blob->has_embedded_type)
{
return FALSE;
}
else if (!validate_type_blob (typelib,
- offset + G_STRUCT_OFFSET (FieldBlob, type),
+ offset + G_STRUCT_OFFSET (FieldBlob, type),
0, FALSE, error))
return FALSE;
}
blob = (PropertyBlob*) &typelib->data[offset];
-
+
if (!validate_name (typelib, "property", typelib->data, blob->name, error))
- return FALSE;
-
+ return FALSE;
+
if (!validate_type_blob (typelib,
- offset + G_STRUCT_OFFSET (PropertyBlob, type),
+ offset + G_STRUCT_OFFSET (PropertyBlob, type),
0, FALSE, error))
return FALSE;
blob = (SignalBlob*) &typelib->data[offset];
if (!validate_name (typelib, "signal", typelib->data, blob->name, error))
- return FALSE;
-
- if ((blob->run_first != 0) +
- (blob->run_last != 0) +
+ return FALSE;
+
+ if ((blob->run_first != 0) +
+ (blob->run_last != 0) +
(blob->run_cleanup != 0) != 1)
{
g_set_error (error,
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_BLOB,
"Invalid signal run flags");
- return FALSE;
+ return FALSE;
}
if (blob->has_class_closure)
ObjectBlob *object;
object = (ObjectBlob*)&typelib->data[container_offset];
-
+
n_signals = object->n_signals;
}
else
{
InterfaceBlob *iface;
-
+
iface = (InterfaceBlob*)&typelib->data[container_offset];
-
+
n_signals = iface->n_signals;
}
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_BLOB,
"Invalid class closure index");
- return FALSE;
+ return FALSE;
}
}
if (!validate_signature_blob (typelib, blob->signature, error))
return FALSE;
-
+
return TRUE;
}
blob = (VFuncBlob*) &typelib->data[offset];
if (!validate_name (typelib, "vfunc", typelib->data, blob->name, error))
- return FALSE;
-
+ return FALSE;
+
if (blob->class_closure)
{
if (((CommonBlob*)&typelib->data[container_offset])->blob_type == BLOB_TYPE_OBJECT)
ObjectBlob *object;
object = (ObjectBlob*)&typelib->data[container_offset];
-
+
n_vfuncs = object->n_vfuncs;
}
else
{
InterfaceBlob *iface;
-
+
iface = (InterfaceBlob*)&typelib->data[container_offset];
-
+
n_vfuncs = iface->n_vfuncs;
}
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_BLOB,
"Invalid class closure index");
- return FALSE;
+ return FALSE;
}
}
if (!validate_signature_blob (typelib, blob->signature, error))
return FALSE;
-
+
return TRUE;
}
}
if (!validate_name (typelib, "struct", typelib->data, blob->name, error))
- return FALSE;
+ return FALSE;
push_context (ctx, get_string_nofail (typelib, blob->name));
-
+
if (!blob->unregistered)
{
if (!validate_name (typelib, "boxed", typelib->data, blob->gtype_name, error))
- return FALSE;
+ return FALSE;
if (!validate_name (typelib, "boxed", typelib->data, blob->gtype_init, error))
- return FALSE;
+ return FALSE;
}
else
{
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_BLOB,
"Gtype data in struct");
- return FALSE;
+ return FALSE;
}
}
- if (typelib->len < offset + sizeof (StructBlob) +
+ if (typelib->len < offset + sizeof (StructBlob) +
blob->n_fields * sizeof (FieldBlob) +
blob->n_methods * sizeof (FunctionBlob))
{
for (i = 0; i < blob->n_methods; i++)
{
- if (!validate_function_blob (ctx,
- field_offset +
- i * sizeof (FunctionBlob),
+ if (!validate_function_blob (ctx,
+ field_offset +
+ i * sizeof (FunctionBlob),
blob_type,
error))
return FALSE;
"Wrong blob type");
return FALSE;
}
-
+
if (!blob->unregistered)
{
if (!validate_name (typelib, "enum", typelib->data, blob->gtype_name, error))
- return FALSE;
+ return FALSE;
if (!validate_name (typelib, "enum", typelib->data, blob->gtype_init, error))
- return FALSE;
+ return FALSE;
}
else
{
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_BLOB,
"Gtype data in unregistered enum");
- return FALSE;
+ return FALSE;
}
}
if (!validate_name (typelib, "enum", typelib->data, blob->name, error))
- return FALSE;
-
- if (typelib->len < offset + sizeof (EnumBlob) +
+ return FALSE;
+
+ if (typelib->len < offset + sizeof (EnumBlob) +
blob->n_values * sizeof (ValueBlob))
{
g_set_error (error,
}
push_context (ctx, get_string_nofail (typelib, blob->name));
-
+
for (i = 0; i < blob->n_values; i++)
{
- if (!validate_value_blob (typelib,
- offset + sizeof (EnumBlob) +
- i * sizeof (ValueBlob),
+ if (!validate_value_blob (typelib,
+ offset + sizeof (EnumBlob) +
+ i * sizeof (ValueBlob),
error))
return FALSE;
#if 0
- v1 = (ValueBlob *)&typelib->data[offset + sizeof (EnumBlob) +
+ v1 = (ValueBlob *)&typelib->data[offset + sizeof (EnumBlob) +
i * sizeof (ValueBlob)];
- for (j = 0; j < i; j++)
+ for (j = 0; j < i; j++)
{
- v2 = (ValueBlob *)&typelib->data[offset + sizeof (EnumBlob) +
+ v2 = (ValueBlob *)&typelib->data[offset + sizeof (EnumBlob) +
j * sizeof (ValueBlob)];
if (v1->value == v2->value)
return FALSE;
}
}
-#endif
+#endif
}
pop_context (ctx);
-
+
return TRUE;
}
"Wrong blob type");
return FALSE;
}
-
+
if (!validate_name (typelib, "object", typelib->data, blob->gtype_name, error))
- return FALSE;
-
+ return FALSE;
+
if (!validate_name (typelib, "object", typelib->data, blob->gtype_init, error))
- return FALSE;
-
+ return FALSE;
+
if (!validate_name (typelib, "object", typelib->data, blob->name, error))
- return FALSE;
+ return FALSE;
if (blob->parent > header->n_entries)
{
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_BLOB,
"Invalid parent index");
- return FALSE;
+ return FALSE;
}
if (blob->parent != 0)
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_BLOB,
"Parent not object");
- return FALSE;
+ return FALSE;
}
}
-
+
if (blob->gtype_struct != 0)
{
DirEntry *entry;
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_BLOB,
"Class struct invalid type or not local");
- return FALSE;
+ return FALSE;
}
- }
-
- if (typelib->len < offset + sizeof (ObjectBlob) +
+ }
+
+ if (typelib->len < offset + sizeof (ObjectBlob) +
(blob->n_interfaces + blob->n_interfaces % 2) * 2 +
blob->n_fields * sizeof (FieldBlob) +
blob->n_properties * sizeof (PropertyBlob) +
blob->n_signals * sizeof (SignalBlob) +
blob->n_vfuncs * sizeof (VFuncBlob) +
blob->n_constants * sizeof (ConstantBlob))
-
+
{
g_set_error (error,
G_TYPELIB_ERROR,
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_BLOB,
"Invalid interface index");
- return FALSE;
+ return FALSE;
}
-
+
entry = get_dir_entry_checked (typelib, iface, error);
if (!entry)
return FALSE;
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_BLOB,
"Not an interface");
- return FALSE;
+ return FALSE;
}
}
offset2 += 2 * (blob->n_interfaces %2);
push_context (ctx, get_string_nofail (typelib, blob->name));
-
+
for (i = 0; i < blob->n_fields; i++, offset2 += sizeof (FieldBlob))
{
if (!validate_field_blob (ctx, offset2, error))
InterfaceBlob *blob;
gint i;
guint32 offset2;
-
+
header = (Header *)typelib->data;
if (typelib->len < offset + sizeof (InterfaceBlob))
"Wrong blob type; expected interface, got %d", blob->blob_type);
return FALSE;
}
-
+
if (!validate_name (typelib, "interface", typelib->data, blob->gtype_name, error))
- return FALSE;
-
+ return FALSE;
+
if (!validate_name (typelib, "interface", typelib->data, blob->gtype_init, error))
- return FALSE;
-
+ return FALSE;
+
if (!validate_name (typelib, "interface", typelib->data, blob->name, error))
- return FALSE;
-
- if (typelib->len < offset + sizeof (InterfaceBlob) +
+ return FALSE;
+
+ if (typelib->len < offset + sizeof (InterfaceBlob) +
(blob->n_prerequisites + blob->n_prerequisites % 2) * 2 +
blob->n_properties * sizeof (PropertyBlob) +
blob->n_methods * sizeof (FunctionBlob) +
blob->n_signals * sizeof (SignalBlob) +
blob->n_vfuncs * sizeof (VFuncBlob) +
blob->n_constants * sizeof (ConstantBlob))
-
+
{
g_set_error (error,
G_TYPELIB_ERROR,
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_BLOB,
"Invalid prerequisite index");
- return FALSE;
+ return FALSE;
}
entry = g_typelib_get_dir_entry (typelib, req);
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_BLOB,
"Not an interface or object");
- return FALSE;
+ return FALSE;
}
}
offset2 += 2 * (blob->n_prerequisites % 2);
push_context (ctx, get_string_nofail (typelib, blob->name));
-
+
for (i = 0; i < blob->n_properties; i++, offset2 += sizeof (PropertyBlob))
{
if (!validate_property_blob (typelib, offset2, error))
if (!validate_function_blob (ctx, offset2, BLOB_TYPE_INTERFACE, error))
return FALSE;
}
-
+
for (i = 0; i < blob->n_signals; i++, offset2 += sizeof (SignalBlob))
{
if (!validate_signal_blob (typelib, offset2, offset, error))
return FALSE;
}
-
+
for (i = 0; i < blob->n_vfuncs; i++, offset2 += sizeof (VFuncBlob))
{
if (!validate_vfunc_blob (typelib, offset2, offset, error))
}
common = (CommonBlob*)&typelib->data[offset];
-
+
switch (common->blob_type)
{
case BLOB_TYPE_FUNCTION:
return FALSE;
break;
default:
- g_set_error (error,
+ g_set_error (error,
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_ENTRY,
"Invalid blob type");
return TRUE;
}
-static gboolean
+static gboolean
validate_directory (ValidateContext *ctx,
GError **error)
{
Header *header = (Header *)typelib->data;
DirEntry *entry;
gint i;
-
+
if (typelib->len < header->directory + header->n_entries * sizeof (DirEntry))
{
g_set_error (error,
entry = g_typelib_get_dir_entry (typelib, i + 1);
if (!validate_name (typelib, "entry", typelib->data, entry->name, error))
- return FALSE;
-
+ return FALSE;
+
if ((entry->local && entry->blob_type == BLOB_TYPE_INVALID) ||
entry->blob_type > BLOB_TYPE_UNION)
{
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_DIRECTORY,
"Invalid entry type");
- return FALSE;
+ return FALSE;
}
if (i < header->n_local_entries)
}
if (!validate_name (typelib, "namespace", typelib->data, entry->offset, error))
- return FALSE;
+ return FALSE;
}
}
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID,
"The buffer is too short");
- return FALSE;
+ return FALSE;
}
-
+
return TRUE;
}
GString *str = g_string_new (NULL);
GSList *link;
char *buf;
-
+
link = ctx->context_stack;
if (!link)
{
g_free (buf);
}
-gboolean
+gboolean
g_typelib_validate (GTypelib *typelib,
GError **error)
{
{
Header *header;
const char *shlib_str;
-
+
header = (Header *) typelib->data;
/* note that NULL shlib means to open the main app, which is allowed */
if (header->shared_library)
* g_typelib_new_from_memory:
* @memory: address of memory chunk containing the typelib
* @len: length of memory chunk containing the typelib
- *
+ *
* Creates a new #GTypelib from a memory location. The memory block
* pointed to by @typelib will be automatically g_free()d when the
* repository is destroyed.
- *
+ *
* Return value: the new #GTypelib
**/
GTypelib *
* g_typelib_new_from_const_memory:
* @memory: address of memory chunk containing the typelib
* @len: length of memory chunk containing the typelib
- *
+ *
* Creates a new #GTypelib from a memory location.
- *
+ *
* Return value: the new #GTypelib
**/
GTypelib *
/**
* g_typelib_new_from_mapped_file:
* @mfile: a #GMappedFile, that will be free'd when the repository is destroyed
- *
+ *
* Creates a new #GTypelib from a #GMappedFile.
- *
+ *
* Return value: the new #GTypelib
**/
GTypelib *
/**
* g_typelib_free:
* @typelib: a #GTypelib
- *
+ *
* Free a #GTypelib.
**/
void
g_typelib_symbol (GTypelib *typelib, const char *symbol_name, gpointer *symbol)
{
GList *l;
-
+
_g_typelib_ensure_open (typelib);
/*
* will be the custom one, which overrides the main one. A bit
* inefficient, but the problem will go away when gir-repository
* does.
- *
+ *
* For modules with no shared library, we dlopen'd the current
- * process above.
+ * process above.
*/
for (l = typelib->modules; l; l = l->next)
{
*
* The "typelib" is a binary, readonly, memory-mappable database
* containing reflective information about a GObject library.
- *
- * The format of GObject typelib is strongly influenced by the Mozilla XPCOM
- * format.
+ *
+ * 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
+ * - 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.
- *
+ * - 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.
*
* typelib ::= header, directory, blobs, attributes, attributedata
* attributedata ::= string data for attributes
*
* Details
- *
- * We describe the fragments that make up the typelib in the form of C structs
+ *
+ * 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).
*/
- use 'blob' as collective name for the various blob types
- rename 'type' field in blobs to 'blob_type'
- rename 'type_name' and 'type_init' fields to 'gtype_name', 'gtype_init'
-- shrink directory entries to 12 bytes
+- shrink directory entries to 12 bytes
- merge struct and boxed blobs
- split interface blobs into enum, object and interface blobs
- add an 'unregistered' flag to struct and enum blobs
-- add a 'wraps_vfunc' flag to function blobs and link them to
+- add a 'wraps_vfunc' flag to function blobs and link them to
the vfuncs they wrap
- restrict value blobs to only occur inside enums and flags again
- add constant blobs, allow them toplevel, in interfaces and in objects
/**
* G_IR_MAGIC:
- *
- * Identifying prefix for the typelib. This was inspired by XPCOM,
+ *
+ * Identifying prefix for the typelib. This was inspired by XPCOM,
* which in turn borrowed from PNG.
*/
#define G_IR_MAGIC "GOBJ\nMETADATA\r\n\032"
* @BLOB_TYPE_CONSTANT: A #ConstantBlob
* @BLOB_TYPE_ERROR_DOMAIN: A #ErrorDomainBlob
* @BLOB_TYPE_UNION: A #UnionBlob
- *
+ *
* The integral value of this enumeration appears in each "Blob"
* component of a typelib to identify its type.
*/
/**
* Header:
* @magic: See #G_IR_MAGIC.
- * @major_version: The version of the typelib format. Minor version changes indicate
- * compatible changes and should still allow the typelib to be parsed
+ * @major_version: The version of the typelib format. Minor version changes indicate
+ * compatible changes and should still allow the typelib to be parsed
* by a parser designed for the same major_version.
* @minor_version: See major_version.
* @n_entries: The number of entries in the directory.
* dependencies are required in order to avoid having programs
* consuming a typelib check for an "Unresolved" type return
* from every API call.
- * @size: The size in bytes of the typelib.
+ * @size: The size in bytes of the typelib.
* @namespace: Offset of the namespace string in the typelib.
* @nsversion: Offset of the namespace version string in the typelib.
* @shared_library: This field is the set of shared libraries associated
* @struct_blob_size: See above.
* @error_domain_blob_size: See above.
* @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
+ * 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.
- *
+ *
* 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.
+ * collection of meta-information, such as the number of entries and dependencies.
*/
typedef struct {
gchar magic[16];
guint16 object_blob_size;
guint16 interface_blob_size;
guint16 union_blob_size;
-
+
guint16 padding[7];
} Header;
* @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.
- *
+ *
* 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
+ *
+ * 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)
*/
typedef struct {
/**
* SimpleTypeBlob:
- * @is_pointer: Indicates whether the type is passed by reference.
+ * @is_pointer: Indicates whether the type is passed by reference.
* @tag: A #GITypeTag
- * @offset: Offset relative to header->types that points to a TypeBlob.
+ * @offset: Offset relative to header->types that points to a TypeBlob.
* Unlike other offsets, this is in words (ie 32bit units) rather
* than bytes.
*
*/
typedef union
{
- struct
+ struct
{
guint reserved : 8;
guint reserved2 :16;
guint pointer : 1;
guint reserved3 : 2;
- guint tag : 5;
+ guint tag : 5;
} flags;
guint32 offset;
} SimpleTypeBlob;
/*
* ArgBlob:
- * @name: A suggested name for the parameter.
+ * @name: A suggested name for the parameter.
* @in: The parameter is an input to the function
- * @out: 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
+ * @out: 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*.
- * @dipper: The parameter is a pointer to a struct or object that will
- * receive an output of the function.
+ * @dipper: The parameter is a pointer to a struct or object that will
+ * receive an output of the function.
* @allow_none: Only meaningful for types which are passed as pointers.
- * For an in parameter, indicates if it is ok to pass NULL in, for
- * an out parameter, whether it may return NULL. Note that NULL is a
+ * For an in parameter, indicates if it is ok to pass NULL in, for
+ * an out parameter, 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.
* @optional: For an out parameter, indicates that NULL may be passed in
* if the value is not needed.
- * @transfer_ownership: 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
+ * @transfer_ownership: 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.
* @transfer_container_ownership: For container types, indicates that the
- * ownership of the container, but not of its contents is transferred. This is typically the case
+ * 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.
- * @is_return_value: 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
+ * @is_return_value: 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.
* @scope: 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).
- * @closure: Index of the closure (user_data) parameter associated with the callback,
+ * @closure: Index of the closure (user_data) parameter associated with the callback,
* or -1.
- * @destroy: Index of the destroy notfication callback parameter associated with
+ * @destroy: Index of the destroy notfication callback parameter associated with
* the callback, or -1.
* @arg_type: Describes the type of the parameter. See details below.
*
* @caller_owns_return_value: If set, the caller is responsible for freeing the return value
* if it is no longer needed.
* @caller_owns_return_container: 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
+ * If the flag is set, the caller is resonsible for freeing the
* container, but not its contents.
- * @n_arguments: The number of arguments that this function expects, also the length
+ * @n_arguments: The number of arguments that this function expects, also the length
* of the array of ArgBlobs.
* @arguments: An array of ArgBlob for the arguments of the function.
*/
* @blob_type: A #GTypelibBlobType
* @deprecated: Whether the blob is deprecated.
* @name: The name of the blob.
- *
+ *
* The #CommonBlob is shared between #FunctionBlob,
- * #CallbackBlob, #SignalBlob.
+ * #CallbackBlob, #SignalBlob.
*/
typedef struct {
guint16 blob_type; /* 1 */
/**
* FunctionBlob:
* @blob_Type: #BLOB_TYPE_FUNCTION
- * @symbol: The symbol which can be used to obtain the function pointer with
+ * @symbol: The symbol which can be used to obtain the function pointer with
* dlsym().
* @deprecated: The function is deprecated.
- * @setter: The function is a setter for a property. Language bindings may
- * prefer to not bind individual setters and rely on the generic
+ * @setter: 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().
- * @getter: The function is a getter for a property. Language bindings may
- * prefer to not bind individual getters and rely on the generic
+ * @getter: 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().
- * @constructor:The function acts as a constructor for the object it is contained
+ * @constructor:The function acts as a constructor for the object it is contained
* in.
* @wraps_vfunc: The function is a simple wrapper for a virtual function.
- * @index: Index of the property that this function is a setter or getter of
+ * @index: 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.
- * @signature: Offset of the SignatureBlob describing the parameter types and the
+ * @signature: Offset of the SignatureBlob describing the parameter types and the
* return value type.
* @is_static: The function is a "static method"; in other words it's a pure
* function whose name is conceptually scoped to the object.
/**
* CallbackBlob:
- * @signature: Offset of the #SignatureBlob describing the parameter types and the
+ * @signature: Offset of the #SignatureBlob describing the parameter types and the
* return value type.
*/
typedef struct {
* @pointer: Whether this type represents an indirection
* @tag: A #GITypeTag
* @interface: Index of the directory entry for the interface.
- *
+ *
* If the interface is an enum of flags type, is_pointer is 0, otherwise it is 1.
*/
typedef struct {
guint8 pointer :1;
guint8 reserved :2;
- guint8 tag :5;
+ guint8 tag :5;
guint8 reserved2;
- guint16 interface;
+ guint16 interface;
} InterfaceTypeBlob;
/**
* ArrayTypeBlob:
- * @zero_terminated: Indicates that the array must be terminated by a suitable #NULL
- * value.
- * @has_length: 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.
- * @length: The index of the parameter which is used to pass the length of the
- * array. The parameter must be an integer type and have the same
- * direction as this one.
+ * @zero_terminated: Indicates that the array must be terminated by a suitable #NULL
+ * value.
+ * @has_length: 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.
+ * @length: The index of the parameter which is used to pass the length of the
+ * array. The parameter must be an integer type and have the same
+ * direction as this one.
* @type: The type of the array elements.
- *
+ *
* Arrays are passed by reference, thus is_pointer is always 1.
*/
typedef struct {
guint16 pointer :1;
guint16 reserved :2;
- guint16 tag :5;
+ guint16 tag :5;
guint16 zero_terminated :1;
guint16 has_length :1;
* ParamTypeBlob:
* @n_types: The number of parameter types to follow.
* @type: Describes the type of the list elements.
- *
+ *
*/
typedef struct {
guint8 pointer :1;
guint8 reserved :2;
- guint8 tag :5;
+ guint8 tag :5;
guint8 reserved2;
guint16 n_types;
typedef struct {
guint8 pointer :1;
guint8 reserved :2;
- guint8 tag :5;
+ guint8 tag :5;
guint8 reserved2;
guint16 n_domains;
/**
* ErrorDomainBlob:
- * @get_quark: The symbol name of the function which must be called to obtain the
+ * @get_quark: The symbol name of the function which must be called to obtain the
* GQuark for the error domain.
* @error_codes: Index of the InterfaceBlob describing the enumeration which lists
* the possible error codes.
guint16 deprecated : 1;
guint16 reserved :15;
-
+
guint32 name;
guint32 get_quark;
* @deprecated: Whether this value is deprecated
* @value: The numerical value
* @name: Name of blob
- *
+ *
* Values commonly occur in enums and flags.
*/
typedef struct {
typedef struct {
guint32 name;
- guint8 readable :1;
+ guint8 readable :1;
guint8 writable :1;
guint8 has_embedded_type :1;
guint8 reserved :5;
* @gtype_init: The symbol name of the get_type() function which registers the type.
*/
typedef struct {
- guint16 blob_type;
- guint16 deprecated : 1;
+ guint16 blob_type;
+ guint16 deprecated : 1;
guint16 unregistered : 1;
guint16 reserved :14;
- guint32 name;
+ guint32 name;
guint32 gtype_name;
guint32 gtype_init;
* @size: The size of the struct in bytes.
* @gtype_name: String name of the associated #GType
* @gtype_init: String naming the symbol which gets the runtime #GType
- * @n_fields:
+ * @n_fields:
* @n_functions: The lengths of the arrays.
- * @fields: An array of n_fields FieldBlobs.
- * @functions: An array of n_functions FunctionBlobs. The described functions
+ * @fields: An array of n_fields FieldBlobs.
+ * @functions: An array of n_functions FunctionBlobs. The described functions
* should be considered as methods of the struct.
*/
typedef struct {
guint16 deprecated : 1;
guint16 unregistered : 1;
guint16 is_gtype_struct : 1;
- guint16 alignment : 6;
+ guint16 alignment : 6;
guint16 reserved : 7;
guint32 name;
#if 0
/* variable-length parts of the blob */
- FieldBlob fields[];
+ FieldBlob fields[];
FunctionBlob methods[];
#endif
} StructBlob;
* discriminator of a discriminated union is located.
* The value 0xFFFF indicates that the discriminator offset
* is unknown.
- * @discriminator_type: Type of the discriminator
+ * @discriminator_type: Type of the discriminator
* @discriminator_values: On discriminator value per field
* @fields: Array of FieldBlobs describing the alternative branches of the union
*/
typedef struct {
- guint16 blob_type;
+ guint16 blob_type;
guint16 deprecated : 1;
guint16 unregistered : 1;
guint16 discriminated : 1;
guint32 reserved2;
guint32 reserved3;
- gint32 discriminator_offset;
+ gint32 discriminator_offset;
SimpleTypeBlob discriminator_type;
#if 0
- FieldBlob fields[];
- FunctionBlob functions[];
+ FieldBlob fields[];
+ FunctionBlob functions[];
ConstantBlob discriminator_values[]
#endif
} UnionBlob;
* @gtype_name: String name of the associated #GType
* @gtype_init: String naming the symbol which gets the runtime #GType
* @n_values: The lengths of the values arrays.
- * @values: Describes the enum values.
+ * @values: Describes the enum values.
*/
typedef struct {
guint16 blob_type;
- guint16 deprecated : 1;
+ guint16 deprecated : 1;
guint16 unregistered : 1;
guint16 storage_type : 5;
guint16 reserved : 9;
- guint32 name;
+ guint32 name;
guint32 gtype_name;
guint32 gtype_init;
guint32 reserved3;
- ValueBlob values[];
+ ValueBlob values[];
} EnumBlob;
/**
* PropertyBlob:
- * @name: The name of the property.
+ * @name: The name of the property.
* @readable:
- * @writable:
- * @construct:
+ * @writable:
+ * @construct:
* @construct_only: The ParamFlags used when registering the property.
* @type: Describes the type of the property.
*/
* @true_stops_emit: Whether the signal has true-stops-emit semantics
* @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.
- * @signature: Offset of the SignatureBlob describing the parameter types and the
+ * @signature: Offset of the SignatureBlob describing the parameter types and the
* return value type.
*/
typedef struct {
* VFuncBlob:
* @name: The name of the virtual function.
* @must_chain_up: If set, every implementation of this virtual function must
- * chain up to the implementation of the parent class.
+ * chain up to the implementation of the parent class.
* @must_be_implemented: If set, every derived class must override this virtual function.
* @must_not_be_implemented: If set, derived class must not override this virtual function.
* @class_closure: Set if this virtual function is the class closure of a signal.
- * @signal: The index of the signal in the list of signals of the object or
+ * @signal: The index of the signal in the list of signals of the object or
* interface to which this virtual function belongs.
* @struct_offset: The offset of the function pointer in the class struct. The value
* 0xFFFF indicates that the struct offset is unknown.
* @invoker: 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.
- * @signature:
- * Offset of the SignatureBlob describing the parameter types and the
- * return value type.
+ * @signature:
+ * Offset of the SignatureBlob describing the parameter types and the
+ * return value type.
*/
typedef struct {
guint32 name;
* @blob_type: #BLOB_TYPE_OBJECT
* @gtype_name: String name of the associated #GType
* @gtype_init: String naming the symbol which gets the runtime #GType
- * @parent: The directory index of the parent type. This is only set for
+ * @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.
* @n_interfaces:
- * @n_fields:
+ * @n_fields:
* @n_properties:
* @n_methods:
* @n_signals:
* @n_vfuncs:
- * @n_constants: The lengths of the arrays.Up to 16bits of padding may be inserted
+ * @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.
- * @interfaces: An array of indices of directory entries for the implemented
+ * @interfaces: An array of indices of directory entries for the implemented
* interfaces.
- * @fields: Describes the fields.
+ * @fields: Describes the fields.
* @methods: Describes the methods, constructors, setters and getters.
* @properties: Describes the properties.
* @signals: Describes the signals.
guint32 reserved4;
guint16 interfaces[];
-
+
#if 0
/* variable-length parts of the blob */
FieldBlob fields[];
* @constants: Describes the constants.
*/
typedef struct {
- guint16 blob_type;
+ guint16 blob_type;
guint16 deprecated : 1;
guint16 reserved :15;
- guint32 name;
+ guint32 name;
guint32 gtype_name;
guint32 gtype_init;
guint16 n_methods;
guint16 n_signals;
guint16 n_vfuncs;
- guint16 n_constants;
+ guint16 n_constants;
guint32 reserved2;
guint32 reserved3;
guint16 prerequisites[];
-#if 0
+#if 0
/* variable-length parts of the blob */
PropertyBlob properties[];
FunctionBlob methods[];
*/
typedef struct {
guint16 blob_type;
- guint16 deprecated : 1;
+ guint16 deprecated : 1;
guint16 reserved :15;
- guint32 name;
+ guint32 name;
SimpleTypeBlob type;