2008-08-09 Johan Dahlin <johan@gnome.org>
+ * *.[ch]:
+ Rename metadata to typelib in variable names,
+ comments and apis.
+
+2008-08-09 Johan Dahlin <johan@gnome.org>
+
* tools/scanner.c:
* tools/scanner.h:
Remove old C scanner, which got rewritten in python.
gint ref_count;
GIBaseInfo *container;
- GTypelib *metadata;
+ GTypelib *typelib;
guint32 offset;
};
GIBaseInfo *
g_info_new (GIInfoType type,
GIBaseInfo *container,
- GTypelib *metadata,
+ GTypelib *typelib,
guint32 offset)
{
GIBaseInfo *info;
info->ref_count = 1;
info->type = type;
- info->metadata = metadata;
+ info->typelib = typelib;
info->offset = offset;
if (container)
}
static GIBaseInfo *
-g_info_from_entry (GTypelib *metadata,
+g_info_from_entry (GTypelib *typelib,
guint16 index)
{
GIBaseInfo *result;
- DirEntry *entry = g_typelib_get_dir_entry (metadata, index);
+ DirEntry *entry = g_typelib_get_dir_entry (typelib, index);
if (entry->local)
- result = g_info_new (entry->blob_type, NULL, metadata, entry->offset);
+ result = g_info_new (entry->blob_type, NULL, typelib, entry->offset);
else
{
- const gchar *namespace = g_typelib_get_string (metadata, entry->offset);
- const gchar *name = g_typelib_get_string (metadata, entry->name);
+ const gchar *namespace = g_typelib_get_string (typelib, entry->offset);
+ const gchar *name = g_typelib_get_string (typelib, entry->name);
GIRepository *repository = g_irepository_get_default ();
case GI_INFO_TYPE_ERROR_DOMAIN:
case GI_INFO_TYPE_UNION:
{
- CommonBlob *blob = (CommonBlob *)&info->metadata->data[info->offset];
+ CommonBlob *blob = (CommonBlob *)&info->typelib->data[info->offset];
- return g_typelib_get_string (info->metadata, blob->name);
+ return g_typelib_get_string (info->typelib, blob->name);
}
break;
case GI_INFO_TYPE_VALUE:
{
- ValueBlob *blob = (ValueBlob *)&info->metadata->data[info->offset];
+ ValueBlob *blob = (ValueBlob *)&info->typelib->data[info->offset];
- return g_typelib_get_string (info->metadata, blob->name);
+ return g_typelib_get_string (info->typelib, blob->name);
}
break;
case GI_INFO_TYPE_SIGNAL:
{
- SignalBlob *blob = (SignalBlob *)&info->metadata->data[info->offset];
+ SignalBlob *blob = (SignalBlob *)&info->typelib->data[info->offset];
- return g_typelib_get_string (info->metadata, blob->name);
+ return g_typelib_get_string (info->typelib, blob->name);
}
break;
case GI_INFO_TYPE_PROPERTY:
{
- PropertyBlob *blob = (PropertyBlob *)&info->metadata->data[info->offset];
+ PropertyBlob *blob = (PropertyBlob *)&info->typelib->data[info->offset];
- return g_typelib_get_string (info->metadata, blob->name);
+ return g_typelib_get_string (info->typelib, blob->name);
}
break;
case GI_INFO_TYPE_VFUNC:
{
- VFuncBlob *blob = (VFuncBlob *)&info->metadata->data[info->offset];
+ VFuncBlob *blob = (VFuncBlob *)&info->typelib->data[info->offset];
- return g_typelib_get_string (info->metadata, blob->name);
+ return g_typelib_get_string (info->typelib, blob->name);
}
break;
case GI_INFO_TYPE_FIELD:
{
- FieldBlob *blob = (FieldBlob *)&info->metadata->data[info->offset];
+ FieldBlob *blob = (FieldBlob *)&info->typelib->data[info->offset];
- return g_typelib_get_string (info->metadata, blob->name);
+ return g_typelib_get_string (info->typelib, blob->name);
}
break;
case GI_INFO_TYPE_ARG:
{
- ArgBlob *blob = (ArgBlob *)&info->metadata->data[info->offset];
+ ArgBlob *blob = (ArgBlob *)&info->typelib->data[info->offset];
- return g_typelib_get_string (info->metadata, blob->name);
+ return g_typelib_get_string (info->typelib, blob->name);
}
break;
const gchar *
g_base_info_get_namespace (GIBaseInfo *info)
{
- Header *header = (Header *)info->metadata->data;
+ Header *header = (Header *)info->typelib->data;
if (info->type == GI_INFO_TYPE_UNRESOLVED)
{
return unresolved->namespace;
}
- return g_typelib_get_string (info->metadata, header->namespace);
+ return g_typelib_get_string (info->typelib, header->namespace);
}
gboolean
case GI_INFO_TYPE_CONSTANT:
case GI_INFO_TYPE_ERROR_DOMAIN:
{
- CommonBlob *blob = (CommonBlob *)&info->metadata->data[info->offset];
+ CommonBlob *blob = (CommonBlob *)&info->typelib->data[info->offset];
return blob->deprecated;
}
case GI_INFO_TYPE_VALUE:
{
- ValueBlob *blob = (ValueBlob *)&info->metadata->data[info->offset];
+ ValueBlob *blob = (ValueBlob *)&info->typelib->data[info->offset];
return blob->deprecated;
}
case GI_INFO_TYPE_SIGNAL:
{
- SignalBlob *blob = (SignalBlob *)&info->metadata->data[info->offset];
+ SignalBlob *blob = (SignalBlob *)&info->typelib->data[info->offset];
return blob->deprecated;
}
case GI_INFO_TYPE_PROPERTY:
{
- PropertyBlob *blob = (PropertyBlob *)&info->metadata->data[info->offset];
+ PropertyBlob *blob = (PropertyBlob *)&info->typelib->data[info->offset];
return blob->deprecated;
}
const gchar *name)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- Header *header = (Header *)base->metadata->data;
+ Header *header = (Header *)base->typelib->data;
AnnotationBlob blob, *first, *after, *res, *next;
const gchar *rname;
blob.offset = base->offset;
- first = (AnnotationBlob *) &base->metadata->data[header->annotations];
- after = (AnnotationBlob *) &base->metadata->data[header->annotations +
+ first = (AnnotationBlob *) &base->typelib->data[header->annotations];
+ after = (AnnotationBlob *) &base->typelib->data[header->annotations +
header->n_annotations * header->annotation_blob_size];
res = bsearch (&blob, first, header->n_annotations,
{
res = next;
- rname = g_typelib_get_string (base->metadata, res->name);
+ rname = g_typelib_get_string (base->typelib, res->name);
if (strcmp (name, rname) == 0)
- return g_typelib_get_string (base->metadata, res->value);
+ return g_typelib_get_string (base->typelib, res->value);
next = res += header->annotation_blob_size;
}
}
GTypelib *
-g_base_info_get_metadata (GIBaseInfo *info)
+g_base_info_get_typelib (GIBaseInfo *info)
{
- return info->metadata;
+ return info->typelib;
}
/* GIFunctionInfo functions */
g_function_info_get_symbol (GIFunctionInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- FunctionBlob *blob = (FunctionBlob *)&base->metadata->data[base->offset];
+ FunctionBlob *blob = (FunctionBlob *)&base->typelib->data[base->offset];
- return g_typelib_get_string (base->metadata, blob->symbol);
+ return g_typelib_get_string (base->typelib, blob->symbol);
}
GIFunctionInfoFlags
{
GIFunctionInfoFlags flags;
GIBaseInfo *base = (GIBaseInfo *)info;
- FunctionBlob *blob = (FunctionBlob *)&base->metadata->data[base->offset];
+ FunctionBlob *blob = (FunctionBlob *)&base->typelib->data[base->offset];
flags = 0;
g_function_info_get_property (GIFunctionInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- FunctionBlob *blob = (FunctionBlob *)&base->metadata->data[base->offset];
+ FunctionBlob *blob = (FunctionBlob *)&base->typelib->data[base->offset];
GIInterfaceInfo *container = (GIInterfaceInfo *)base->container;
return g_interface_info_get_property (container, blob->index);
g_function_info_get_vfunc (GIFunctionInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- FunctionBlob *blob = (FunctionBlob *)&base->metadata->data[base->offset];
+ FunctionBlob *blob = (FunctionBlob *)&base->typelib->data[base->offset];
GIInterfaceInfo *container = (GIInterfaceInfo *)base->container;
return g_interface_info_get_vfunc (container, blob->index);
{
case GI_INFO_TYPE_FUNCTION:
case GI_INFO_TYPE_VFUNC:
- return *(guint32 *)&info->base.metadata->data[info->base.offset + 12];
+ return *(guint32 *)&info->base.typelib->data[info->base.offset + 12];
case GI_INFO_TYPE_CALLBACK:
case GI_INFO_TYPE_SIGNAL:
- return *(guint32 *)&info->base.metadata->data[info->base.offset + 8];
+ return *(guint32 *)&info->base.typelib->data[info->base.offset + 8];
}
return 0;
GITypeInfo *
g_type_info_new (GIBaseInfo *container,
- GTypelib *metadata,
+ GTypelib *typelib,
guint32 offset)
{
- SimpleTypeBlob *type = (SimpleTypeBlob *)&metadata->data[offset];
+ SimpleTypeBlob *type = (SimpleTypeBlob *)&typelib->data[offset];
- return (GITypeInfo *) g_info_new (GI_INFO_TYPE_TYPE, container, metadata,
+ return (GITypeInfo *) g_info_new (GI_INFO_TYPE_TYPE, container, typelib,
type->reserved == 0 ? offset : type->offset);
}
offset = signature_offset (info);
- return g_type_info_new (base, base->metadata, offset);
+ return g_type_info_new (base, base->typelib, offset);
}
/**
g_callable_info_may_return_null (GICallableInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- SignatureBlob *blob = (SignatureBlob *)&base->metadata->data[signature_offset (info)];
+ SignatureBlob *blob = (SignatureBlob *)&base->typelib->data[signature_offset (info)];
return blob->may_return_null;
}
g_callable_info_get_caller_owns (GICallableInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- SignatureBlob *blob = (SignatureBlob *)&base->metadata->data[signature_offset (info)];
+ SignatureBlob *blob = (SignatureBlob *)&base->typelib->data[signature_offset (info)];
if (blob->caller_owns_return_value)
return GI_TRANSFER_EVERYTHING;
SignatureBlob *blob;
offset = signature_offset (info);
- blob = (SignatureBlob *)&base->metadata->data[offset];
+ blob = (SignatureBlob *)&base->typelib->data[offset];
return blob->n_arguments;
}
*
* Get information about a particular argument of this callable.
*
- * Returns: A #GIArgInfo indexing the metadata on the given argument.
+ * Returns: A #GIArgInfo indexing the typelib on the given argument.
*/
GIArgInfo *
g_callable_info_get_arg (GICallableInfo *info,
gint n)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- Header *header = (Header *)base->metadata->data;
+ Header *header = (Header *)base->typelib->data;
gint offset;
offset = signature_offset (info);
- return (GIArgInfo *) g_info_new (GI_INFO_TYPE_ARG, base, base->metadata,
+ return (GIArgInfo *) g_info_new (GI_INFO_TYPE_ARG, base, base->typelib,
offset + header->signature_blob_size + n * header->arg_blob_size);
}
g_arg_info_get_direction (GIArgInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- ArgBlob *blob = (ArgBlob *)&base->metadata->data[base->offset];
+ ArgBlob *blob = (ArgBlob *)&base->typelib->data[base->offset];
if (blob->in && blob->out)
return GI_DIRECTION_INOUT;
g_arg_info_is_return_value (GIArgInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- ArgBlob *blob = (ArgBlob *)&base->metadata->data[base->offset];
+ ArgBlob *blob = (ArgBlob *)&base->typelib->data[base->offset];
return blob->return_value;
}
g_arg_info_is_dipper (GIArgInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- ArgBlob *blob = (ArgBlob *)&base->metadata->data[base->offset];
+ ArgBlob *blob = (ArgBlob *)&base->typelib->data[base->offset];
return blob->dipper;
}
g_arg_info_is_optional (GIArgInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- ArgBlob *blob = (ArgBlob *)&base->metadata->data[base->offset];
+ ArgBlob *blob = (ArgBlob *)&base->typelib->data[base->offset];
return blob->optional;
}
g_arg_info_may_be_null (GIArgInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- ArgBlob *blob = (ArgBlob *)&base->metadata->data[base->offset];
+ ArgBlob *blob = (ArgBlob *)&base->typelib->data[base->offset];
return blob->null_ok;
}
g_arg_info_get_ownership_transfer (GIArgInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- ArgBlob *blob = (ArgBlob *)&base->metadata->data[base->offset];
+ ArgBlob *blob = (ArgBlob *)&base->typelib->data[base->offset];
if (blob->transfer_ownership)
return GI_TRANSFER_EVERYTHING;
{
GIBaseInfo *base = (GIBaseInfo *)info;
- return g_type_info_new (base, base->metadata, base->offset + 8);
+ return g_type_info_new (base, base->typelib, base->offset + 8);
}
/* GITypeInfo functions */
g_type_info_is_pointer (GITypeInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- SimpleTypeBlob *type = (SimpleTypeBlob *)&base->metadata->data[base->offset];
+ SimpleTypeBlob *type = (SimpleTypeBlob *)&base->typelib->data[base->offset];
if (type->reserved == 0)
return type->pointer;
else
{
- InterfaceTypeBlob *iface = (InterfaceTypeBlob *)&base->metadata->data[base->offset];
+ InterfaceTypeBlob *iface = (InterfaceTypeBlob *)&base->typelib->data[base->offset];
return iface->pointer;
}
g_type_info_get_tag (GITypeInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- SimpleTypeBlob *type = (SimpleTypeBlob *)&base->metadata->data[base->offset];
+ SimpleTypeBlob *type = (SimpleTypeBlob *)&base->typelib->data[base->offset];
if (type->reserved == 0)
return type->tag;
else
{
- InterfaceTypeBlob *iface = (InterfaceTypeBlob *)&base->metadata->data[base->offset];
+ InterfaceTypeBlob *iface = (InterfaceTypeBlob *)&base->typelib->data[base->offset];
return iface->tag;
}
gint n)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- SimpleTypeBlob *type = (SimpleTypeBlob *)&base->metadata->data[base->offset];
+ SimpleTypeBlob *type = (SimpleTypeBlob *)&base->typelib->data[base->offset];
if (type->reserved != 0)
{
- ParamTypeBlob *param = (ParamTypeBlob *)&base->metadata->data[base->offset];
+ ParamTypeBlob *param = (ParamTypeBlob *)&base->typelib->data[base->offset];
switch (param->tag)
{
case GI_TYPE_TAG_GLIST:
case GI_TYPE_TAG_GSLIST:
case GI_TYPE_TAG_GHASH:
- return g_type_info_new (base, base->metadata, base->offset + 4 + 4 * n);
+ return g_type_info_new (base, base->typelib, base->offset + 4 + 4 * n);
break;
default: ;
g_type_info_get_interface (GITypeInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- SimpleTypeBlob *type = (SimpleTypeBlob *)&base->metadata->data[base->offset];
+ SimpleTypeBlob *type = (SimpleTypeBlob *)&base->typelib->data[base->offset];
if (type->reserved != 0)
{
- InterfaceTypeBlob *blob = (InterfaceTypeBlob *)&base->metadata->data[base->offset];
+ InterfaceTypeBlob *blob = (InterfaceTypeBlob *)&base->typelib->data[base->offset];
if (blob->tag == GI_TYPE_TAG_INTERFACE)
- return g_info_from_entry (base->metadata, blob->interface);
+ return g_info_from_entry (base->typelib, blob->interface);
}
return NULL;
g_type_info_get_array_length (GITypeInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- SimpleTypeBlob *type = (SimpleTypeBlob *)&base->metadata->data[base->offset];
+ SimpleTypeBlob *type = (SimpleTypeBlob *)&base->typelib->data[base->offset];
if (type->reserved != 0)
{
- ArrayTypeBlob *blob = (ArrayTypeBlob *)&base->metadata->data[base->offset];
+ ArrayTypeBlob *blob = (ArrayTypeBlob *)&base->typelib->data[base->offset];
if (blob->tag == GI_TYPE_TAG_ARRAY)
{
g_type_info_is_zero_terminated (GITypeInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- SimpleTypeBlob *type = (SimpleTypeBlob *)&base->metadata->data[base->offset];
+ SimpleTypeBlob *type = (SimpleTypeBlob *)&base->typelib->data[base->offset];
if (type->reserved != 0)
{
- ArrayTypeBlob *blob = (ArrayTypeBlob *)&base->metadata->data[base->offset];
+ ArrayTypeBlob *blob = (ArrayTypeBlob *)&base->typelib->data[base->offset];
if (blob->tag == GI_TYPE_TAG_ARRAY)
return blob->zero_terminated;
g_type_info_get_n_error_domains (GITypeInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- SimpleTypeBlob *type = (SimpleTypeBlob *)&base->metadata->data[base->offset];
+ SimpleTypeBlob *type = (SimpleTypeBlob *)&base->typelib->data[base->offset];
if (type->reserved != 0)
{
- ErrorTypeBlob *blob = (ErrorTypeBlob *)&base->metadata->data[base->offset];
+ ErrorTypeBlob *blob = (ErrorTypeBlob *)&base->typelib->data[base->offset];
if (blob->tag == GI_TYPE_TAG_ERROR)
return blob->n_domains;
gint n)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- SimpleTypeBlob *type = (SimpleTypeBlob *)&base->metadata->data[base->offset];
+ SimpleTypeBlob *type = (SimpleTypeBlob *)&base->typelib->data[base->offset];
if (type->reserved != 0)
{
- ErrorTypeBlob *blob = (ErrorTypeBlob *)&base->metadata->data[base->offset];
+ ErrorTypeBlob *blob = (ErrorTypeBlob *)&base->typelib->data[base->offset];
if (blob->tag == GI_TYPE_TAG_ERROR)
- return (GIErrorDomainInfo *) g_info_from_entry (base->metadata,
+ return (GIErrorDomainInfo *) g_info_from_entry (base->typelib,
blob->domains[n]);
}
g_error_domain_info_get_quark (GIErrorDomainInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- ErrorDomainBlob *blob = (ErrorDomainBlob *)&base->metadata->data[base->offset];
+ ErrorDomainBlob *blob = (ErrorDomainBlob *)&base->typelib->data[base->offset];
- return g_typelib_get_string (base->metadata, blob->get_quark);
+ return g_typelib_get_string (base->typelib, blob->get_quark);
}
GIInterfaceInfo *
g_error_domain_info_get_codes (GIErrorDomainInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- ErrorDomainBlob *blob = (ErrorDomainBlob *)&base->metadata->data[base->offset];
+ ErrorDomainBlob *blob = (ErrorDomainBlob *)&base->typelib->data[base->offset];
- return (GIInterfaceInfo *) g_info_from_entry (base->metadata, blob->error_codes);
+ return (GIInterfaceInfo *) g_info_from_entry (base->typelib, blob->error_codes);
}
g_value_info_get_value (GIValueInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- ValueBlob *blob = (ValueBlob *)&base->metadata->data[base->offset];
+ ValueBlob *blob = (ValueBlob *)&base->typelib->data[base->offset];
return (glong)blob->value;
}
GIFieldInfoFlags flags;
GIBaseInfo *base = (GIBaseInfo *)info;
- FieldBlob *blob = (FieldBlob *)&base->metadata->data[base->offset];
+ FieldBlob *blob = (FieldBlob *)&base->typelib->data[base->offset];
flags = 0;
g_field_info_get_size (GIFieldInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- FieldBlob *blob = (FieldBlob *)&base->metadata->data[base->offset];
+ FieldBlob *blob = (FieldBlob *)&base->typelib->data[base->offset];
return blob->bits;
}
g_field_info_get_offset (GIFieldInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- FieldBlob *blob = (FieldBlob *)&base->metadata->data[base->offset];
+ FieldBlob *blob = (FieldBlob *)&base->typelib->data[base->offset];
return blob->struct_offset;
}
{
GIBaseInfo *base = (GIBaseInfo *)info;
- return g_type_info_new (base, base->metadata, base->offset + 8);
+ return g_type_info_new (base, base->typelib, base->offset + 8);
}
/* GIRegisteredTypeInfo functions */
g_registered_type_info_get_type_name (GIRegisteredTypeInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- RegisteredTypeBlob *blob = (RegisteredTypeBlob *)&base->metadata->data[base->offset];
+ RegisteredTypeBlob *blob = (RegisteredTypeBlob *)&base->typelib->data[base->offset];
if (blob->gtype_name)
- return g_typelib_get_string (base->metadata, blob->gtype_name);
+ return g_typelib_get_string (base->typelib, blob->gtype_name);
return NULL;
}
g_registered_type_info_get_type_init (GIRegisteredTypeInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- RegisteredTypeBlob *blob = (RegisteredTypeBlob *)&base->metadata->data[base->offset];
+ RegisteredTypeBlob *blob = (RegisteredTypeBlob *)&base->typelib->data[base->offset];
if (blob->gtype_init)
- return g_typelib_get_string (base->metadata, blob->gtype_init);
+ return g_typelib_get_string (base->typelib, blob->gtype_init);
return NULL;
}
return G_TYPE_NONE;
get_type_func = NULL;
- if (!g_module_symbol (((GIBaseInfo*)info)->metadata->module,
+ if (!g_module_symbol (((GIBaseInfo*)info)->typelib->module,
type_init,
(void**) &get_type_func))
return G_TYPE_NONE;
g_struct_info_get_n_fields (GIStructInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- StructBlob *blob = (StructBlob *)&base->metadata->data[base->offset];
+ StructBlob *blob = (StructBlob *)&base->typelib->data[base->offset];
return blob->n_fields;
}
gint n)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- Header *header = (Header *)base->metadata->data;
+ Header *header = (Header *)base->typelib->data;
- return (GIFieldInfo *) g_info_new (GI_INFO_TYPE_FIELD, base, base->metadata,
+ return (GIFieldInfo *) g_info_new (GI_INFO_TYPE_FIELD, base, base->typelib,
base->offset + header->struct_blob_size +
n * header->field_blob_size);
}
g_struct_info_get_n_methods (GIStructInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- StructBlob *blob = (StructBlob *)&base->metadata->data[base->offset];
+ StructBlob *blob = (StructBlob *)&base->typelib->data[base->offset];
return blob->n_methods;
}
gint n)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- StructBlob *blob = (StructBlob *)&base->metadata->data[base->offset];
- Header *header = (Header *)base->metadata->data;
+ StructBlob *blob = (StructBlob *)&base->typelib->data[base->offset];
+ Header *header = (Header *)base->typelib->data;
gint offset;
offset = base->offset + header->struct_blob_size
+ blob->n_fields * header->field_blob_size
+ n * header->function_blob_size;
return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, base,
- base->metadata, offset);
+ base->typelib, offset);
}
static GIFunctionInfo *
const gchar *name)
{
/* FIXME hash */
- Header *header = (Header *)base->metadata->data;
+ Header *header = (Header *)base->typelib->data;
gint i;
for (i = 0; i < n_methods; i++)
{
- FunctionBlob *fblob = (FunctionBlob *)&base->metadata->data[offset];
- const gchar *fname = (const gchar *)&base->metadata->data[fblob->name];
+ FunctionBlob *fblob = (FunctionBlob *)&base->typelib->data[offset];
+ const gchar *fname = (const gchar *)&base->typelib->data[fblob->name];
if (strcmp (name, fname) == 0)
return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, base,
- base->metadata, offset);
+ base->typelib, offset);
offset += header->function_blob_size;
}
{
gint offset;
GIBaseInfo *base = (GIBaseInfo *)info;
- Header *header = (Header *)base->metadata->data;
- StructBlob *blob = (StructBlob *)&base->metadata->data[base->offset];
+ Header *header = (Header *)base->typelib->data;
+ StructBlob *blob = (StructBlob *)&base->typelib->data[base->offset];
offset = base->offset + header->struct_blob_size
+ blob->n_fields * header->field_blob_size;
g_enum_info_get_n_values (GIEnumInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- EnumBlob *blob = (EnumBlob *)&base->metadata->data[base->offset];
+ EnumBlob *blob = (EnumBlob *)&base->typelib->data[base->offset];
return blob->n_values;
}
gint n)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- Header *header = (Header *)base->metadata->data;
+ Header *header = (Header *)base->typelib->data;
gint offset;
offset = base->offset + header->enum_blob_size
+ n * header->value_blob_size;
- return (GIValueInfo *) g_info_new (GI_INFO_TYPE_VALUE, base, base->metadata, offset);
+ return (GIValueInfo *) g_info_new (GI_INFO_TYPE_VALUE, base, base->typelib, offset);
}
/* GIObjectInfo functions */
g_object_info_get_parent (GIObjectInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- ObjectBlob *blob = (ObjectBlob *)&base->metadata->data[base->offset];
+ ObjectBlob *blob = (ObjectBlob *)&base->typelib->data[base->offset];
if (blob->parent)
- return (GIObjectInfo *) g_info_from_entry (base->metadata, blob->parent);
+ return (GIObjectInfo *) g_info_from_entry (base->typelib, blob->parent);
else
return NULL;
}
g_object_info_get_type_name (GIObjectInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- ObjectBlob *blob = (ObjectBlob *)&base->metadata->data[base->offset];
+ ObjectBlob *blob = (ObjectBlob *)&base->typelib->data[base->offset];
- return g_typelib_get_string (base->metadata, blob->gtype_name);
+ return g_typelib_get_string (base->typelib, blob->gtype_name);
}
const gchar *
g_object_info_get_type_init (GIObjectInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- ObjectBlob *blob = (ObjectBlob *)&base->metadata->data[base->offset];
+ ObjectBlob *blob = (ObjectBlob *)&base->typelib->data[base->offset];
- return g_typelib_get_string (base->metadata, blob->gtype_init);
+ return g_typelib_get_string (base->typelib, blob->gtype_init);
}
gint
g_object_info_get_n_interfaces (GIObjectInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- ObjectBlob *blob = (ObjectBlob *)&base->metadata->data[base->offset];
+ ObjectBlob *blob = (ObjectBlob *)&base->typelib->data[base->offset];
return blob->n_interfaces;
}
gint n)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- ObjectBlob *blob = (ObjectBlob *)&base->metadata->data[base->offset];
+ ObjectBlob *blob = (ObjectBlob *)&base->typelib->data[base->offset];
- return (GIInterfaceInfo *) g_info_from_entry (base->metadata, blob->interfaces[n]);
+ return (GIInterfaceInfo *) g_info_from_entry (base->typelib, blob->interfaces[n]);
}
gint
g_object_info_get_n_fields (GIObjectInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- ObjectBlob *blob = (ObjectBlob *)&base->metadata->data[base->offset];
+ ObjectBlob *blob = (ObjectBlob *)&base->typelib->data[base->offset];
return blob->n_fields;
}
{
gint offset;
GIBaseInfo *base = (GIBaseInfo *)info;
- Header *header = (Header *)base->metadata->data;
- ObjectBlob *blob = (ObjectBlob *)&base->metadata->data[base->offset];
+ Header *header = (Header *)base->typelib->data;
+ ObjectBlob *blob = (ObjectBlob *)&base->typelib->data[base->offset];
offset = base->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, base, base->metadata, offset);
+ return (GIFieldInfo *) g_info_new (GI_INFO_TYPE_FIELD, base, base->typelib, offset);
}
gint
g_object_info_get_n_properties (GIObjectInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- ObjectBlob *blob = (ObjectBlob *)&base->metadata->data[base->offset];
+ ObjectBlob *blob = (ObjectBlob *)&base->typelib->data[base->offset];
return blob->n_properties;
}
{
gint offset;
GIBaseInfo *base = (GIBaseInfo *)info;
- Header *header = (Header *)base->metadata->data;
- ObjectBlob *blob = (ObjectBlob *)&base->metadata->data[base->offset];
+ Header *header = (Header *)base->typelib->data;
+ ObjectBlob *blob = (ObjectBlob *)&base->typelib->data[base->offset];
offset = base->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
+ n * header->property_blob_size;
return (GIPropertyInfo *) g_info_new (GI_INFO_TYPE_PROPERTY, base,
- base->metadata, offset);
+ base->typelib, offset);
}
gint
g_object_info_get_n_methods (GIObjectInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- ObjectBlob *blob = (ObjectBlob *)&base->metadata->data[base->offset];
+ ObjectBlob *blob = (ObjectBlob *)&base->typelib->data[base->offset];
return blob->n_methods;
}
{
gint offset;
GIBaseInfo *base = (GIBaseInfo *)info;
- Header *header = (Header *)base->metadata->data;
- ObjectBlob *blob = (ObjectBlob *)&base->metadata->data[base->offset];
+ Header *header = (Header *)base->typelib->data;
+ ObjectBlob *blob = (ObjectBlob *)&base->typelib->data[base->offset];
offset = base->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
+ n * header->function_blob_size;
return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, base,
- base->metadata, offset);
+ base->typelib, offset);
}
GIFunctionInfo *
{
gint offset;
GIBaseInfo *base = (GIBaseInfo *)info;
- Header *header = (Header *)base->metadata->data;
- ObjectBlob *blob = (ObjectBlob *)&base->metadata->data[base->offset];
+ Header *header = (Header *)base->typelib->data;
+ ObjectBlob *blob = (ObjectBlob *)&base->typelib->data[base->offset];
offset = base->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
g_object_info_get_n_signals (GIObjectInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- ObjectBlob *blob = (ObjectBlob *)&base->metadata->data[base->offset];
+ ObjectBlob *blob = (ObjectBlob *)&base->typelib->data[base->offset];
return blob->n_signals;
}
{
gint offset;
GIBaseInfo *base = (GIBaseInfo *)info;
- Header *header = (Header *)base->metadata->data;
- ObjectBlob *blob = (ObjectBlob *)&base->metadata->data[base->offset];
+ Header *header = (Header *)base->typelib->data;
+ ObjectBlob *blob = (ObjectBlob *)&base->typelib->data[base->offset];
offset = base->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
+ n * header->signal_blob_size;
return (GISignalInfo *) g_info_new (GI_INFO_TYPE_SIGNAL, base,
- base->metadata, offset);
+ base->typelib, offset);
}
gint
g_object_info_get_n_vfuncs (GIObjectInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- ObjectBlob *blob = (ObjectBlob *)&base->metadata->data[base->offset];
+ ObjectBlob *blob = (ObjectBlob *)&base->typelib->data[base->offset];
return blob->n_vfuncs;
}
{
gint offset;
GIBaseInfo *base = (GIBaseInfo *)info;
- Header *header = (Header *)base->metadata->data;
- ObjectBlob *blob = (ObjectBlob *)&base->metadata->data[base->offset];
+ Header *header = (Header *)base->typelib->data;
+ ObjectBlob *blob = (ObjectBlob *)&base->typelib->data[base->offset];
offset = base->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
+ n * header->vfunc_blob_size;
return (GIVFuncInfo *) g_info_new (GI_INFO_TYPE_VFUNC, base,
- base->metadata, offset);
+ base->typelib, offset);
}
gint
g_object_info_get_n_constants (GIObjectInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- ObjectBlob *blob = (ObjectBlob *)&base->metadata->data[base->offset];
+ ObjectBlob *blob = (ObjectBlob *)&base->typelib->data[base->offset];
return blob->n_constants;
}
{
gint offset;
GIBaseInfo *base = (GIBaseInfo *)info;
- Header *header = (Header *)base->metadata->data;
- ObjectBlob *blob = (ObjectBlob *)&base->metadata->data[base->offset];
+ Header *header = (Header *)base->typelib->data;
+ ObjectBlob *blob = (ObjectBlob *)&base->typelib->data[base->offset];
offset = base->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
+ n * header->constant_blob_size;
return (GIConstantInfo *) g_info_new (GI_INFO_TYPE_CONSTANT, base,
- base->metadata, offset);
+ base->typelib, offset);
}
g_interface_info_get_n_prerequisites (GIInterfaceInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- InterfaceBlob *blob = (InterfaceBlob *)&base->metadata->data[base->offset];
+ InterfaceBlob *blob = (InterfaceBlob *)&base->typelib->data[base->offset];
return blob->n_prerequisites;
}
gint n)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- InterfaceBlob *blob = (InterfaceBlob *)&base->metadata->data[base->offset];
+ InterfaceBlob *blob = (InterfaceBlob *)&base->typelib->data[base->offset];
- return g_info_from_entry (base->metadata, blob->prerequisites[n]);
+ return g_info_from_entry (base->typelib, blob->prerequisites[n]);
}
g_interface_info_get_n_properties (GIInterfaceInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- InterfaceBlob *blob = (InterfaceBlob *)&base->metadata->data[base->offset];
+ InterfaceBlob *blob = (InterfaceBlob *)&base->typelib->data[base->offset];
return blob->n_properties;
}
{
gint offset;
GIBaseInfo *base = (GIBaseInfo *)info;
- Header *header = (Header *)base->metadata->data;
- InterfaceBlob *blob = (InterfaceBlob *)&base->metadata->data[base->offset];
+ Header *header = (Header *)base->typelib->data;
+ InterfaceBlob *blob = (InterfaceBlob *)&base->typelib->data[base->offset];
offset = base->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, base,
- base->metadata, offset);
+ base->typelib, offset);
}
gint
g_interface_info_get_n_methods (GIInterfaceInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- InterfaceBlob *blob = (InterfaceBlob *)&base->metadata->data[base->offset];
+ InterfaceBlob *blob = (InterfaceBlob *)&base->typelib->data[base->offset];
return blob->n_methods;
}
{
gint offset;
GIBaseInfo *base = (GIBaseInfo *)info;
- Header *header = (Header *)base->metadata->data;
- InterfaceBlob *blob = (InterfaceBlob *)&base->metadata->data[base->offset];
+ Header *header = (Header *)base->typelib->data;
+ InterfaceBlob *blob = (InterfaceBlob *)&base->typelib->data[base->offset];
offset = base->offset + header->interface_blob_size
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
+ n * header->function_blob_size;
return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, base,
- base->metadata, offset);
+ base->typelib, offset);
}
GIFunctionInfo *
{
gint offset;
GIBaseInfo *base = (GIBaseInfo *)info;
- Header *header = (Header *)base->metadata->data;
- InterfaceBlob *blob = (InterfaceBlob *)&base->metadata->data[base->offset];
+ Header *header = (Header *)base->typelib->data;
+ InterfaceBlob *blob = (InterfaceBlob *)&base->typelib->data[base->offset];
offset = base->offset + header->interface_blob_size
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
g_interface_info_get_n_signals (GIInterfaceInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- InterfaceBlob *blob = (InterfaceBlob *)&base->metadata->data[base->offset];
+ InterfaceBlob *blob = (InterfaceBlob *)&base->typelib->data[base->offset];
return blob->n_signals;
}
{
gint offset;
GIBaseInfo *base = (GIBaseInfo *)info;
- Header *header = (Header *)base->metadata->data;
- InterfaceBlob *blob = (InterfaceBlob *)&base->metadata->data[base->offset];
+ Header *header = (Header *)base->typelib->data;
+ InterfaceBlob *blob = (InterfaceBlob *)&base->typelib->data[base->offset];
offset = base->offset + header->interface_blob_size
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
+ n * header->signal_blob_size;
return (GISignalInfo *) g_info_new (GI_INFO_TYPE_SIGNAL, base,
- base->metadata, offset);
+ base->typelib, offset);
}
gint
g_interface_info_get_n_vfuncs (GIInterfaceInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- InterfaceBlob *blob = (InterfaceBlob *)&base->metadata->data[base->offset];
+ InterfaceBlob *blob = (InterfaceBlob *)&base->typelib->data[base->offset];
return blob->n_vfuncs;
}
{
gint offset;
GIBaseInfo *base = (GIBaseInfo *)info;
- Header *header = (Header *)base->metadata->data;
- InterfaceBlob *blob = (InterfaceBlob *)&base->metadata->data[base->offset];
+ Header *header = (Header *)base->typelib->data;
+ InterfaceBlob *blob = (InterfaceBlob *)&base->typelib->data[base->offset];
offset = base->offset + header->interface_blob_size
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
+ n * header->vfunc_blob_size;
return (GIVFuncInfo *) g_info_new (GI_INFO_TYPE_VFUNC, base,
- base->metadata, offset);
+ base->typelib, offset);
}
gint
g_interface_info_get_n_constants (GIInterfaceInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- InterfaceBlob *blob = (InterfaceBlob *)&base->metadata->data[base->offset];
+ InterfaceBlob *blob = (InterfaceBlob *)&base->typelib->data[base->offset];
return blob->n_constants;
}
{
gint offset;
GIBaseInfo *base = (GIBaseInfo *)info;
- Header *header = (Header *)base->metadata->data;
- InterfaceBlob *blob = (InterfaceBlob *)&base->metadata->data[base->offset];
+ Header *header = (Header *)base->typelib->data;
+ InterfaceBlob *blob = (InterfaceBlob *)&base->typelib->data[base->offset];
offset = base->offset + header->interface_blob_size
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
+ n * header->constant_blob_size;
return (GIConstantInfo *) g_info_new (GI_INFO_TYPE_CONSTANT, base,
- base->metadata, offset);
+ base->typelib, offset);
}
{
GParamFlags flags;
GIBaseInfo *base = (GIBaseInfo *)info;
- PropertyBlob *blob = (PropertyBlob *)&base->metadata->data[base->offset];
+ PropertyBlob *blob = (PropertyBlob *)&base->typelib->data[base->offset];
flags = 0;
{
GIBaseInfo *base = (GIBaseInfo *)info;
- return g_type_info_new (base, base->metadata, base->offset + 8);
+ return g_type_info_new (base, base->typelib, base->offset + 8);
}
GSignalFlags flags;
GIBaseInfo *base = (GIBaseInfo *)info;
- SignalBlob *blob = (SignalBlob *)&base->metadata->data[base->offset];
+ SignalBlob *blob = (SignalBlob *)&base->typelib->data[base->offset];
flags = 0;
g_signal_info_get_class_closure (GISignalInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- SignalBlob *blob = (SignalBlob *)&base->metadata->data[base->offset];
+ SignalBlob *blob = (SignalBlob *)&base->typelib->data[base->offset];
if (blob->has_class_closure)
return g_interface_info_get_vfunc ((GIInterfaceInfo *)base->container, blob->class_closure);
g_signal_info_true_stops_emit (GISignalInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- SignalBlob *blob = (SignalBlob *)&base->metadata->data[base->offset];
+ SignalBlob *blob = (SignalBlob *)&base->typelib->data[base->offset];
return blob->true_stops_emit;
}
GIVFuncInfoFlags flags;
GIBaseInfo *base = (GIBaseInfo *)info;
- VFuncBlob *blob = (VFuncBlob *)&base->metadata->data[base->offset];
+ VFuncBlob *blob = (VFuncBlob *)&base->typelib->data[base->offset];
flags = 0;
g_vfunc_info_get_offset (GIVFuncInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- VFuncBlob *blob = (VFuncBlob *)&base->metadata->data[base->offset];
+ VFuncBlob *blob = (VFuncBlob *)&base->typelib->data[base->offset];
return blob->struct_offset;
}
g_vfunc_info_get_signal (GIVFuncInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- VFuncBlob *blob = (VFuncBlob *)&base->metadata->data[base->offset];
+ VFuncBlob *blob = (VFuncBlob *)&base->typelib->data[base->offset];
if (blob->class_closure)
return g_interface_info_get_signal ((GIInterfaceInfo *)base->container, blob->signal);
{
GIBaseInfo *base = (GIBaseInfo *)info;
- return g_type_info_new (base, base->metadata, base->offset + 8);
+ return g_type_info_new (base, base->typelib, base->offset + 8);
}
gint
GArgument *value)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- ConstantBlob *blob = (ConstantBlob *)&base->metadata->data[base->offset];
+ ConstantBlob *blob = (ConstantBlob *)&base->typelib->data[base->offset];
/* FIXME non-basic types ? */
if (blob->type.reserved == 0)
{
if (blob->type.pointer)
- value->v_pointer = g_memdup (&base->metadata->data[blob->offset], blob->size);
+ value->v_pointer = g_memdup (&base->typelib->data[blob->offset], blob->size);
else
{
switch (blob->type.tag)
{
case GI_TYPE_TAG_BOOLEAN:
- value->v_boolean = *(gboolean*)&base->metadata->data[blob->offset];
+ value->v_boolean = *(gboolean*)&base->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_INT8:
- value->v_int8 = *(gint8*)&base->metadata->data[blob->offset];
+ value->v_int8 = *(gint8*)&base->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_UINT8:
- value->v_uint8 = *(guint8*)&base->metadata->data[blob->offset];
+ value->v_uint8 = *(guint8*)&base->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_INT16:
- value->v_int16 = *(gint16*)&base->metadata->data[blob->offset];
+ value->v_int16 = *(gint16*)&base->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_UINT16:
- value->v_uint16 = *(guint16*)&base->metadata->data[blob->offset];
+ value->v_uint16 = *(guint16*)&base->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_INT32:
- value->v_int32 = *(gint32*)&base->metadata->data[blob->offset];
+ value->v_int32 = *(gint32*)&base->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_UINT32:
- value->v_uint32 = *(guint32*)&base->metadata->data[blob->offset];
+ value->v_uint32 = *(guint32*)&base->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_INT64:
- value->v_int64 = *(gint64*)&base->metadata->data[blob->offset];
+ value->v_int64 = *(gint64*)&base->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_UINT64:
- value->v_uint64 = *(guint64*)&base->metadata->data[blob->offset];
+ value->v_uint64 = *(guint64*)&base->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_FLOAT:
- value->v_float = *(gfloat*)&base->metadata->data[blob->offset];
+ value->v_float = *(gfloat*)&base->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_DOUBLE:
- value->v_double = *(gdouble*)&base->metadata->data[blob->offset];
+ value->v_double = *(gdouble*)&base->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_INT:
- value->v_int = *(gint*)&base->metadata->data[blob->offset];
+ value->v_int = *(gint*)&base->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_UINT:
- value->v_uint = *(guint*)&base->metadata->data[blob->offset];
+ value->v_uint = *(guint*)&base->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_LONG:
- value->v_long = *(glong*)&base->metadata->data[blob->offset];
+ value->v_long = *(glong*)&base->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_ULONG:
- value->v_ulong = *(gulong*)&base->metadata->data[blob->offset];
+ value->v_ulong = *(gulong*)&base->typelib->data[blob->offset];
break;
}
}
g_union_info_get_n_fields (GIUnionInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- UnionBlob *blob = (UnionBlob *)&base->metadata->data[base->offset];
+ UnionBlob *blob = (UnionBlob *)&base->typelib->data[base->offset];
return blob->n_fields;
}
gint n)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- Header *header = (Header *)base->metadata->data;
+ Header *header = (Header *)base->typelib->data;
- return (GIFieldInfo *) g_info_new (GI_INFO_TYPE_FIELD, base, base->metadata,
+ return (GIFieldInfo *) g_info_new (GI_INFO_TYPE_FIELD, base, base->typelib,
base->offset + header->union_blob_size +
n * header->field_blob_size);
}
g_union_info_get_n_methods (GIUnionInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- UnionBlob *blob = (UnionBlob *)&base->metadata->data[base->offset];
+ UnionBlob *blob = (UnionBlob *)&base->typelib->data[base->offset];
return blob->n_functions;
}
gint n)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- UnionBlob *blob = (UnionBlob *)&base->metadata->data[base->offset];
- Header *header = (Header *)base->metadata->data;
+ UnionBlob *blob = (UnionBlob *)&base->typelib->data[base->offset];
+ Header *header = (Header *)base->typelib->data;
gint offset;
offset = base->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, base,
- base->metadata, offset);
+ base->typelib, offset);
}
gboolean
g_union_info_is_discriminated (GIUnionInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- UnionBlob *blob = (UnionBlob *)&base->metadata->data[base->offset];
+ UnionBlob *blob = (UnionBlob *)&base->typelib->data[base->offset];
return blob->discriminated;
}
g_union_info_get_discriminator_offset (GIUnionInfo *info)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- UnionBlob *blob = (UnionBlob *)&base->metadata->data[base->offset];
+ UnionBlob *blob = (UnionBlob *)&base->typelib->data[base->offset];
return blob->discriminator_offset;
}
{
GIBaseInfo *base = (GIBaseInfo *)info;
- return g_type_info_new (base, base->metadata, base->offset + 24);
+ return g_type_info_new (base, base->typelib, base->offset + 24);
}
GIConstantInfo *
gint n)
{
GIBaseInfo *base = (GIBaseInfo *)info;
- UnionBlob *blob = (UnionBlob *)&base->metadata->data[base->offset];
+ UnionBlob *blob = (UnionBlob *)&base->typelib->data[base->offset];
if (blob->discriminated)
{
- Header *header = (Header *)base->metadata->data;
+ Header *header = (Header *)base->typelib->data;
gint offset;
offset = base->offset + header->union_blob_size
+ n * header->constant_blob_size;
return (GIConstantInfo *) g_info_new (GI_INFO_TYPE_CONSTANT, base,
- base->metadata, offset);
+ base->typelib, offset);
}
return NULL;
symbol = g_function_info_get_symbol (info);
- if (!g_module_symbol (g_base_info_get_metadata((GIBaseInfo *) info)->module,
+ if (!g_module_symbol (g_base_info_get_typelib((GIBaseInfo *) info)->module,
symbol, &func))
{
GModule *entire_app;
* We want to be able to add symbols to an app or an auxiliary
* library to fill in gaps in an introspected library. However,
* normally we would only look for symbols in the main library
- * (metadata->module).
+ * (typelib->module).
*
* A more elaborate solution is probably possible, but as a
* simple approach for now, if we fail to find a symbol we look
*
* This would not be very efficient if it happened often, since
* we always do the failed lookup above first, but very few
- * symbols should be outside of metadata->module so it doesn't
+ * symbols should be outside of typelib->module so it doesn't
* matter.
*/
entire_app = g_module_open (NULL, 0);
#include "gtypelib.h"
static GIRepository *default_repository = NULL;
-static GHashTable *default_metadata = NULL;
+static GHashTable *default_typelib = NULL;
static GSList *search_path = NULL;
struct _GIRepositoryPrivate
{
- GHashTable *metadata; /* (string) namespace -> GTypelib */
+ GHashTable *typelib; /* (string) namespace -> GTypelib */
};
G_DEFINE_TYPE (GIRepository, g_irepository, G_TYPE_OBJECT);
{
GIRepository *repository = G_IREPOSITORY (object);
- g_hash_table_destroy (repository->priv->metadata);
+ g_hash_table_destroy (repository->priv->typelib);
(* G_OBJECT_CLASS (g_irepository_parent_class)->finalize) (G_OBJECT (repository));
}
const gchar *
g_irepository_register (GIRepository *repository,
- GTypelib *metadata)
+ GTypelib *typelib)
{
Header *header;
const gchar *name;
GHashTable *table;
GError *error = NULL;
- g_return_val_if_fail (metadata != NULL, NULL);
+ g_return_val_if_fail (typelib != NULL, NULL);
- header = (Header *)metadata->data;
+ header = (Header *)typelib->data;
g_return_val_if_fail (header != NULL, NULL);
if (repository != NULL)
{
- if (repository->priv->metadata == NULL)
- repository->priv->metadata = g_hash_table_new_full (g_str_hash, g_str_equal,
+ if (repository->priv->typelib == NULL)
+ repository->priv->typelib = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) NULL,
(GDestroyNotify) g_typelib_free);
- table = repository->priv->metadata;
+ table = repository->priv->typelib;
}
else
{
- if (default_metadata == NULL)
- default_metadata = g_hash_table_new_full (g_str_hash, g_str_equal,
+ if (default_typelib == NULL)
+ default_typelib = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) NULL,
(GDestroyNotify) g_typelib_free);
- table = default_metadata;
+ table = default_typelib;
}
- name = g_typelib_get_string (metadata, header->namespace);
+ name = g_typelib_get_string (typelib, header->namespace);
if (g_hash_table_lookup (table, name))
{
- g_printerr ("metadata (%p) for '%s' already registered\n",
- metadata, name);
+ g_printerr ("typelib (%p) for '%s' already registered\n",
+ typelib, name);
return NULL;
}
- g_hash_table_insert (table, g_strdup(name), (void *)metadata);
+ g_hash_table_insert (table, g_strdup(name), (void *)typelib);
- if (metadata->module == NULL)
- metadata->module = g_module_open (NULL, 0);
+ if (typelib->module == NULL)
+ typelib->module = g_module_open (NULL, 0);
if (g_getenv ("G_IREPOSITORY_VERBOSE"))
{
GHashTable *table;
if (repository != NULL)
- table = repository->priv->metadata;
+ table = repository->priv->typelib;
else
- table = default_metadata;
+ table = default_typelib;
if (!g_hash_table_remove (table, namespace))
{
GHashTable *table;
if (repository != NULL)
- table = repository->priv->metadata;
+ table = repository->priv->typelib;
else
- table = default_metadata;
+ table = default_typelib;
return g_hash_table_lookup (table, namespace) != NULL;
}
if (default_repository == NULL)
{
default_repository = g_object_new (G_TYPE_IREPOSITORY, NULL);
- if (default_metadata == NULL)
- default_metadata = g_hash_table_new_full (g_str_hash, g_str_equal,
+ if (default_typelib == NULL)
+ default_typelib = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) NULL,
(GDestroyNotify) g_typelib_free);
- default_repository->priv->metadata = default_metadata;
+ default_repository->priv->typelib = default_typelib;
}
return default_repository;
gpointer value,
gpointer data)
{
- guchar *metadata = ((GTypelib *) value)->data;
+ guchar *typelib = ((GTypelib *) value)->data;
gint *n_interfaces = (gint *)data;
- *n_interfaces += ((Header *)metadata)->n_local_entries;
+ *n_interfaces += ((Header *)typelib)->n_local_entries;
}
gint
if (namespace)
{
- GTypelib *metadata;
+ GTypelib *typelib;
- metadata = g_hash_table_lookup (repository->priv->metadata, namespace);
+ typelib = g_hash_table_lookup (repository->priv->typelib, namespace);
- if (metadata)
- n_interfaces = ((Header *)metadata->data)->n_local_entries;
+ if (typelib)
+ n_interfaces = ((Header *)typelib->data)->n_local_entries;
}
else
{
- g_hash_table_foreach (repository->priv->metadata,
+ g_hash_table_foreach (repository->priv->typelib,
count_interfaces, &n_interfaces);
}
gpointer data)
{
gint i;
- GTypelib *metadata = (GTypelib *)value;
+ GTypelib *typelib = (GTypelib *)value;
IfaceData *iface_data = (IfaceData *)data;
gint index;
gint n_entries;
DirEntry *entry;
index = 0;
- n_entries = ((Header *)metadata->data)->n_local_entries;
+ n_entries = ((Header *)typelib->data)->n_local_entries;
if (iface_data->name)
{
for (i = 1; i <= n_entries; i++)
{
- entry = g_typelib_get_dir_entry (metadata, i);
- name = g_typelib_get_string (metadata, entry->name);
+ entry = g_typelib_get_dir_entry (typelib, i);
+ name = g_typelib_get_string (typelib, entry->name);
if (strcmp (name, iface_data->name) == 0)
{
index = i;
{
for (i = 1; i <= n_entries; i++)
{
- entry = g_typelib_get_dir_entry (metadata, i);
+ entry = g_typelib_get_dir_entry (typelib, i);
if (entry->blob_type < 4)
continue;
- offset = *(guint32*)&metadata->data[entry->offset + 8];
- type = g_typelib_get_string (metadata, offset);
+ offset = *(guint32*)&typelib->data[entry->offset + 8];
+ type = g_typelib_get_string (typelib, offset);
if (strcmp (type, iface_data->type) == 0)
{
index = i;
if (index != 0)
{
- entry = g_typelib_get_dir_entry (metadata, index);
+ entry = g_typelib_get_dir_entry (typelib, index);
iface_data->iface = g_info_new (entry->blob_type, NULL,
- metadata, entry->offset);
+ typelib, entry->offset);
}
}
if (namespace)
{
- GTypelib *metadata;
+ GTypelib *typelib;
- metadata = g_hash_table_lookup (repository->priv->metadata, namespace);
+ typelib = g_hash_table_lookup (repository->priv->typelib, namespace);
- if (metadata)
- find_interface ((void *)namespace, metadata, &data);
+ if (typelib)
+ find_interface ((void *)namespace, typelib, &data);
}
else
- g_hash_table_foreach (repository->priv->metadata, find_interface, &data);
+ g_hash_table_foreach (repository->priv->typelib, find_interface, &data);
return data.iface;
}
data.index = -1;
data.iface = NULL;
- g_hash_table_foreach (repository->priv->metadata, find_interface, &data);
+ g_hash_table_foreach (repository->priv->typelib, find_interface, &data);
return data.iface;
}
if (namespace)
{
- GTypelib *metadata;
+ GTypelib *typelib;
- metadata = g_hash_table_lookup (repository->priv->metadata, namespace);
+ typelib = g_hash_table_lookup (repository->priv->typelib, namespace);
- if (metadata)
- find_interface ((void *)namespace, metadata, &data);
+ if (typelib)
+ find_interface ((void *)namespace, typelib, &data);
}
else
- g_hash_table_foreach (repository->priv->metadata, find_interface, &data);
+ g_hash_table_foreach (repository->priv->typelib, find_interface, &data);
return data.iface;
}
gchar **names;
gint i;
- g_hash_table_foreach (repository->priv->metadata, collect_namespaces, &list);
+ g_hash_table_foreach (repository->priv->typelib, collect_namespaces, &list);
names = g_malloc0 (sizeof (gchar *) * (g_list_length (list) + 1));
i = 0;
g_irepository_get_shared_library (GIRepository *repository,
const gchar *namespace)
{
- GTypelib *metadata;
+ GTypelib *typelib;
Header *header;
- metadata = g_hash_table_lookup (repository->priv->metadata, namespace);
- if (!metadata)
+ typelib = g_hash_table_lookup (repository->priv->typelib, namespace);
+ if (!typelib)
return NULL;
- header = (Header *) metadata->data;
+ header = (Header *) typelib->data;
if (header->shared_library)
- return g_typelib_get_string (metadata, header->shared_library);
+ return g_typelib_get_string (typelib, header->shared_library);
else
return NULL;
}
gchar *fname, *full_path;
GMappedFile *mfile;
GError *error1 = NULL;
- GTypelib *metadata = NULL;
- const gchar *metadata_namespace, *shlib_fname;
+ GTypelib *typelib = NULL;
+ const gchar *typelib_namespace, *shlib_fname;
GModule *module;
guint32 shlib;
GHashTable *table;
if (repository != NULL)
- table = repository->priv->metadata;
+ table = repository->priv->typelib;
else
- table = default_metadata;
+ table = default_typelib;
/* don't bother loading a namespace if already registered */
if (g_hash_table_lookup (table, namespace))
continue;
}
g_free (full_path);
- metadata = g_typelib_new_from_mapped_file (mfile);
- metadata_namespace = g_typelib_get_string (metadata, ((Header *) metadata->data)->namespace);
- if (strcmp (metadata_namespace, namespace) != 0) {
+ typelib = g_typelib_new_from_mapped_file (mfile);
+ typelib_namespace = g_typelib_get_string (typelib, ((Header *) typelib->data)->namespace);
+ if (strcmp (typelib_namespace, namespace) != 0) {
g_set_error (error, G_IREPOSITORY_ERROR,
G_IREPOSITORY_ERROR_NAMESPACE_MISMATCH,
- "Metadata file %s for namespace '%s' contains namespace '%s'"
+ "Typelib file %s for namespace '%s' contains namespace '%s'"
" which doesn't match the file name",
- full_path, namespace, metadata_namespace);
+ full_path, namespace, typelib_namespace);
return NULL;
}
break;
}
g_free (fname);
- if (metadata == NULL) {
+ if (typelib == NULL) {
g_set_error (error, G_IREPOSITORY_ERROR,
- G_IREPOSITORY_ERROR_METADATA_NOT_FOUND,
- "Metadata file for namespace '%s' was not found in search"
+ G_IREPOSITORY_ERROR_TYPELIB_NOT_FOUND,
+ "Typelib file for namespace '%s' was not found in search"
" path or could not be openened", namespace);
return NULL;
}
- /* optionally load shared library and attach it to the metadata */
- shlib = ((Header *) metadata->data)->shared_library;
+ /* optionally load shared library and attach it to the typelib */
+ shlib = ((Header *) typelib->data)->shared_library;
if (shlib) {
- shlib_fname = g_typelib_get_string (metadata, shlib);
+ shlib_fname = g_typelib_get_string (typelib, shlib);
module = g_module_open (shlib_fname, G_MODULE_BIND_LAZY|G_MODULE_BIND_LOCAL);
if (module == NULL) {
g_set_error (error, G_IREPOSITORY_ERROR,
- G_IREPOSITORY_ERROR_METADATA_NOT_FOUND,
- "Metadata for namespace '%s' references shared library %s,"
+ G_IREPOSITORY_ERROR_TYPELIB_NOT_FOUND,
+ "Typelib for namespace '%s' references shared library %s,"
" but it could not be openened (%s)",
namespace, shlib_fname, g_module_error ());
return NULL;
}
g_hash_table_remove (table, namespace);
- return g_irepository_register (repository, metadata);
+ return g_irepository_register (repository, typelib);
}
GType g_irepository_get_type (void) G_GNUC_CONST;
GIRepository *g_irepository_get_default (void);
const gchar * g_irepository_register (GIRepository *repository,
- GTypelib *metadata);
+ GTypelib *typelib);
void g_irepository_unregister (GIRepository *repository,
const gchar *namespace);
const gchar * g_irepository_register_file (GIRepository *repository,
gint index);
const gchar * g_irepository_get_shared_library (GIRepository *repository,
const gchar *namespace);
-/* Metadata */
+/* Typelib */
GTypelib * g_typelib_new_from_memory (guchar *memory,
gsize len);
GTypelib * g_typelib_new_from_const_memory (const guchar *memory,
gsize len);
GTypelib * g_typelib_new_from_mapped_file (GMappedFile *mfile);
-void g_typelib_free (GTypelib *metadata);
-void g_typelib_set_module (GTypelib *metadata,
+void g_typelib_free (GTypelib *typelib);
+void g_typelib_set_module (GTypelib *typelib,
GModule *module);
-const gchar * g_typelib_get_namespace (GTypelib *metadata);
+const gchar * g_typelib_get_namespace (GTypelib *typelib);
typedef enum
{
- G_IREPOSITORY_ERROR_METADATA_NOT_FOUND,
+ G_IREPOSITORY_ERROR_TYPELIB_NOT_FOUND,
G_IREPOSITORY_ERROR_NAMESPACE_MISMATCH,
G_IREPOSITORY_ERROR_LIBRARY_NOT_FOUND
} GIRepositoryError;
const gchar * g_base_info_get_annotation (GIBaseInfo *info,
const gchar *name);
GIBaseInfo * g_base_info_get_container (GIBaseInfo *info);
-GTypelib * g_base_info_get_metadata (GIBaseInfo *info);
+GTypelib * g_base_info_get_typelib (GIBaseInfo *info);
-GIBaseInfo * g_info_new (GIInfoType type,
- GIBaseInfo *container,
- GTypelib *metadata,
+GIBaseInfo * g_info_new (GIInfoType type,
+ GIBaseInfo *container,
+ GTypelib *typelib,
guint32 offset);
-/* GObject introspection: Metadata creation
+/* GObject introspection: Typelib creation
*
* Copyright (C) 2005 Matthias Clasen
*
}
GTypelib *
-g_ir_module_build_metadata (GIrModule *module,
+g_ir_module_build_typelib (GIrModule *module,
GList *modules)
{
- guchar *metadata;
+ guchar *typelib;
gsize length;
gint i;
GList *e;
entry->offset = offset;
entry->name = write_string (node->name, strings, data, &offset2);
- g_ir_node_build_metadata (node, module, modules,
+ g_ir_node_build_typelib (node, module, modules,
strings, types, data, &offset, &offset2);
if (offset2 > old_offset + g_ir_node_get_full_size (node))
g_message ("reallocating to %d bytes", offset2);
- metadata = g_realloc (data, offset2);
+ typelib = g_realloc (data, offset2);
length = header->size = offset2;
- return g_typelib_new_from_memory (metadata, length);
+ return g_typelib_new_from_memory (typelib, length);
}
const gchar *module_filename);
void g_ir_module_free (GIrModule *module);
-GTypelib * g_ir_module_build_metadata (GIrModule *module,
+GTypelib * g_ir_module_build_typelib (GIrModule *module,
GList *modules);
G_END_DECLS
-/* GObject introspection: Metadata creation
+/* GObject introspection: Typelib creation
*
* Copyright (C) 2005 Matthias Clasen
*
}
void
-g_ir_node_build_metadata (GIrNode *node,
- GIrModule *module,
- GList *modules,
- GHashTable *strings,
- GHashTable *types,
- guchar *data,
- guint32 *offset,
- guint32 *offset2)
+g_ir_node_build_typelib (GIrNode *node,
+ GIrModule *module,
+ GList *modules,
+ GHashTable *strings,
+ GHashTable *types,
+ guchar *data,
+ guint32 *offset,
+ guint32 *offset2)
{
GList *l;
guint32 old_offset = *offset;
g_assert (node != NULL);
- g_debug ("build_metadata (%s)",
+ g_debug ("build_typelib (%s)",
g_ir_node_type_to_string (node->type));
switch (node->type)
pos = *offset2 + 4;
*offset2 += 8;
- g_ir_node_build_metadata ((GIrNode *)type->parameter_type1,
- module, modules, strings, types,
- data, &pos, offset2);
+ g_ir_node_build_typelib ((GIrNode *)type->parameter_type1,
+ module, modules, strings, types,
+ data, &pos, offset2);
}
break;
pos = *offset2 + 4;
*offset2 += 8;
- g_ir_node_build_metadata ((GIrNode *)type->parameter_type1,
- module, modules, strings, types,
- data, &pos, offset2);
+ g_ir_node_build_typelib ((GIrNode *)type->parameter_type1,
+ module, modules, strings, types,
+ data, &pos, offset2);
}
break;
pos = *offset2 + 4;
*offset2 += 12;
- g_ir_node_build_metadata ((GIrNode *)type->parameter_type1,
- module, modules, strings, types,
- data, &pos, offset2);
- g_ir_node_build_metadata ((GIrNode *)type->parameter_type2,
- module, modules, strings, types,
- data, &pos, offset2);
+ g_ir_node_build_typelib ((GIrNode *)type->parameter_type1,
+ module, modules, strings, types,
+ data, &pos, offset2);
+ g_ir_node_build_typelib ((GIrNode *)type->parameter_type2,
+ module, modules, strings, types,
+ data, &pos, offset2);
}
break;
blob->bits = 0;
blob->struct_offset = field->offset;
- g_ir_node_build_metadata ((GIrNode *)field->type,
- module, modules, strings, types,
- data, offset, offset2);
+ g_ir_node_build_typelib ((GIrNode *)field->type,
+ module, modules, strings, types,
+ data, offset, offset2);
}
break;
blob->construct_only = prop->construct_only;
blob->reserved = 0;
- g_ir_node_build_metadata ((GIrNode *)prop->type,
- module, modules, strings, types,
- data, offset, offset2);
+ g_ir_node_build_typelib ((GIrNode *)prop->type,
+ module, modules, strings, types,
+ data, offset, offset2);
}
break;
blob->symbol = write_string (function->symbol, strings, data, offset2);
blob->signature = signature;
- g_ir_node_build_metadata ((GIrNode *)function->result->type,
- module, modules, strings, types,
- data, &signature, offset2);
+ g_ir_node_build_typelib ((GIrNode *)function->result->type,
+ module, modules, strings, types,
+ data, &signature, offset2);
blob2->may_return_null = function->result->null_ok;
blob2->caller_owns_return_value = function->result->transfer;
{
GIrNode *param = (GIrNode *)l->data;
- g_ir_node_build_metadata (param,
- module, modules, strings, types,
- data, &signature, offset2);
+ g_ir_node_build_typelib (param,
+ module, modules, strings, types,
+ data, &signature, offset2);
}
}
break;
blob->name = write_string (node->name, strings, data, offset2);
blob->signature = signature;
- g_ir_node_build_metadata ((GIrNode *)function->result->type,
- module, modules, strings, types,
- data, &signature, offset2);
+ g_ir_node_build_typelib ((GIrNode *)function->result->type,
+ module, modules, strings, types,
+ data, &signature, offset2);
blob2->may_return_null = function->result->null_ok;
blob2->caller_owns_return_value = function->result->transfer;
{
GIrNode *param = (GIrNode *)l->data;
- g_ir_node_build_metadata (param,
- module, modules, strings, types,
- data, &signature, offset2);
+ g_ir_node_build_typelib (param,
+ module, modules, strings, types,
+ data, &signature, offset2);
}
}
break;
blob->name = write_string (node->name, strings, data, offset2);
blob->signature = signature;
- g_ir_node_build_metadata ((GIrNode *)signal->result->type,
- module, modules, strings, types,
- data, &signature, offset2);
+ g_ir_node_build_typelib ((GIrNode *)signal->result->type,
+ module, modules, strings, types,
+ data, &signature, offset2);
blob2->may_return_null = signal->result->null_ok;
blob2->caller_owns_return_value = signal->result->transfer;
{
GIrNode *param = (GIrNode *)l->data;
- g_ir_node_build_metadata (param, module, modules, strings, types,
- data, &signature, offset2);
+ g_ir_node_build_typelib (param, module, modules, strings, types,
+ data, &signature, offset2);
}
}
break;
blob->reserved2 = 0;
blob->signature = signature;
- g_ir_node_build_metadata ((GIrNode *)vfunc->result->type,
- module, modules, strings, types,
- data, &signature, offset2);
+ g_ir_node_build_typelib ((GIrNode *)vfunc->result->type,
+ module, modules, strings, types,
+ data, &signature, offset2);
blob2->may_return_null = vfunc->result->null_ok;
blob2->caller_owns_return_value = vfunc->result->transfer;
{
GIrNode *param = (GIrNode *)l->data;
- g_ir_node_build_metadata (param, module, modules, strings,
- types, data, &signature, offset2);
+ g_ir_node_build_typelib (param, module, modules, strings,
+ types, data, &signature, offset2);
}
}
break;
blob->return_value = param->retval;
blob->reserved = 0;
- g_ir_node_build_metadata ((GIrNode *)param->type, module, modules,
- strings, types, data, offset, offset2);
+ g_ir_node_build_typelib ((GIrNode *)param->type, module, modules,
+ strings, types, data, offset, offset2);
}
break;
if (member->type == G_IR_NODE_FIELD)
{
blob->n_fields++;
- g_ir_node_build_metadata (member, module, modules, strings,
- types, data, offset, offset2);
+ g_ir_node_build_typelib (member, module, modules, strings,
+ types, data, offset, offset2);
}
}
if (member->type == G_IR_NODE_FUNCTION)
{
blob->n_methods++;
- g_ir_node_build_metadata (member, module, modules, strings,
- types, data, offset, offset2);
+ g_ir_node_build_typelib (member, module, modules, strings,
+ types, data, offset, offset2);
}
}
}
if (member->type == G_IR_NODE_FIELD)
{
blob->n_fields++;
- g_ir_node_build_metadata (member, module, modules, strings,
- types, data, offset, offset2);
+ g_ir_node_build_typelib (member, module, modules, strings,
+ types, data, offset, offset2);
}
}
if (member->type == G_IR_NODE_FUNCTION)
{
blob->n_methods++;
- g_ir_node_build_metadata (member, module, modules, strings,
- types, data, offset, offset2);
+ g_ir_node_build_typelib (member, module, modules, strings,
+ types, data, offset, offset2);
}
}
}
{
*offset += 24;
blob->discriminated = TRUE;
- g_ir_node_build_metadata ((GIrNode *)union_->discriminator_type,
- module, modules, strings, types,
- data, offset, offset2);
+ g_ir_node_build_typelib ((GIrNode *)union_->discriminator_type,
+ module, modules, strings, types,
+ data, offset, offset2);
}
else
{
if (member->type == G_IR_NODE_FIELD)
{
blob->n_fields++;
- g_ir_node_build_metadata (member, module, modules, strings,
- types, data, offset, offset2);
+ g_ir_node_build_typelib (member, module, modules, strings,
+ types, data, offset, offset2);
}
}
if (member->type == G_IR_NODE_FUNCTION)
{
blob->n_functions++;
- g_ir_node_build_metadata (member, module, modules, strings,
- types, data, offset, offset2);
+ g_ir_node_build_typelib (member, module, modules, strings,
+ types, data, offset, offset2);
}
}
{
GIrNode *member = (GIrNode *)l->data;
- g_ir_node_build_metadata (member, module, modules, strings,
- types, data, offset, offset2);
+ g_ir_node_build_typelib (member, module, modules, strings,
+ types, data, offset, offset2);
}
}
}
GIrNode *value = (GIrNode *)l->data;
blob->n_values++;
- g_ir_node_build_metadata (value, module, modules, strings, types,
- data, offset, offset2);
+ g_ir_node_build_typelib (value, module, modules, strings, types,
+ data, offset, offset2);
}
}
break;
if (member->type == G_IR_NODE_FIELD)
{
blob->n_fields++;
- g_ir_node_build_metadata (member, module, modules, strings,
- types, data, offset, offset2);
+ g_ir_node_build_typelib (member, module, modules, strings,
+ types, data, offset, offset2);
}
}
if (member->type == G_IR_NODE_PROPERTY)
{
blob->n_properties++;
- g_ir_node_build_metadata (member, module, modules, strings,
- types, data, offset, offset2);
+ g_ir_node_build_typelib (member, module, modules, strings,
+ types, data, offset, offset2);
}
}
if (member->type == G_IR_NODE_FUNCTION)
{
blob->n_methods++;
- g_ir_node_build_metadata (member, module, modules, strings,
- types, data, offset, offset2);
+ g_ir_node_build_typelib (member, module, modules, strings,
+ types, data, offset, offset2);
}
}
if (member->type == G_IR_NODE_SIGNAL)
{
blob->n_signals++;
- g_ir_node_build_metadata (member, module, modules, strings,
- types, data, offset, offset2);
+ g_ir_node_build_typelib (member, module, modules, strings,
+ types, data, offset, offset2);
}
}
if (member->type == G_IR_NODE_VFUNC)
{
blob->n_vfuncs++;
- g_ir_node_build_metadata (member, module, modules, strings,
- types, data, offset, offset2);
+ g_ir_node_build_typelib (member, module, modules, strings,
+ types, data, offset, offset2);
}
}
if (member->type == G_IR_NODE_CONSTANT)
{
blob->n_constants++;
- g_ir_node_build_metadata (member, module, modules, strings,
- types, data, offset, offset2);
+ g_ir_node_build_typelib (member, module, modules, strings,
+ types, data, offset, offset2);
}
}
}
if (member->type == G_IR_NODE_PROPERTY)
{
blob->n_properties++;
- g_ir_node_build_metadata (member, module, modules, strings,
- types, data, offset, offset2);
+ g_ir_node_build_typelib (member, module, modules, strings,
+ types, data, offset, offset2);
}
}
if (member->type == G_IR_NODE_FUNCTION)
{
blob->n_methods++;
- g_ir_node_build_metadata (member, module, modules, strings,
- types, data, offset, offset2);
+ g_ir_node_build_typelib (member, module, modules, strings,
+ types, data, offset, offset2);
}
}
if (member->type == G_IR_NODE_SIGNAL)
{
blob->n_signals++;
- g_ir_node_build_metadata (member, module, modules, strings,
- types, data, offset, offset2);
+ g_ir_node_build_typelib (member, module, modules, strings,
+ types, data, offset, offset2);
}
}
if (member->type == G_IR_NODE_VFUNC)
{
blob->n_vfuncs++;
- g_ir_node_build_metadata (member, module, modules, strings,
- types, data, offset, offset2);
+ g_ir_node_build_typelib (member, module, modules, strings,
+ types, data, offset, offset2);
}
}
if (member->type == G_IR_NODE_CONSTANT)
{
blob->n_constants++;
- g_ir_node_build_metadata (member, module, modules, strings,
- types, data, offset, offset2);
+ g_ir_node_build_typelib (member, module, modules, strings,
+ types, data, offset, offset2);
}
}
}
}
*offset2 += ALIGN_VALUE (blob->size, 4);
- g_ir_node_build_metadata ((GIrNode *)constant->type, module, modules,
- strings, types, data, &pos, offset2);
+ g_ir_node_build_typelib ((GIrNode *)constant->type, module, modules,
+ strings, types, data, &pos, offset2);
}
break;
default:
}
/* if str is already in the pool, return previous location, otherwise write str
- * to the metadata at offset, put it in the pool and update offset. If the
- * metadata is not large enough to hold the string, reallocate it.
+ * 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
write_string (const gchar *str,
void g_ir_node_free (GIrNode *node);
guint32 g_ir_node_get_size (GIrNode *node);
guint32 g_ir_node_get_full_size (GIrNode *node);
-void g_ir_node_build_metadata (GIrNode *node,
- GIrModule *module,
- GList *modules,
- GHashTable *strings,
- GHashTable *types,
- guchar *data,
- guint32 *offset,
- guint32 *offset2);
+void g_ir_node_build_typelib (GIrNode *node,
+ GIrModule *module,
+ GList *modules,
+ GHashTable *strings,
+ GHashTable *types,
+ guchar *data,
+ guint32 *offset,
+ guint32 *offset2);
int g_ir_node_cmp (GIrNode *node,
- GIrNode *other);
+ GIrNode *other);
gboolean g_ir_node_can_have_member (GIrNode *node);
void g_ir_node_add_member (GIrNode *node,
- GIrNodeFunction *member);
-guint32 write_string (const gchar *str,
- GHashTable *strings,
- guchar *data,
- guint32 *offset);
+ GIrNodeFunction *member);
+guint32 write_string (const gchar *str,
+ GHashTable *strings,
+ guchar *data,
+ guint32 *offset);
const gchar * g_ir_node_param_direction_string (GIrNodeParam * node);
-/* GObject introspection: metadata validation, auxiliary functions
- * related to the binary metadata format
+/* GObject introspection: typelib validation, auxiliary functions
+ * related to the binary typelib format
*
* Copyright (C) 2005 Matthias Clasen
*
DirEntry *
-g_typelib_get_dir_entry (GTypelib *metadata,
+g_typelib_get_dir_entry (GTypelib *typelib,
guint16 index)
{
- Header *header = (Header *)metadata->data;
+ Header *header = (Header *)typelib->data;
- return (DirEntry *)&metadata->data[header->directory + (index - 1) * header->entry_blob_size];
+ return (DirEntry *)&typelib->data[header->directory + (index - 1) * header->entry_blob_size];
}
void
}
static gboolean
-validate_header (GTypelib *metadata,
+validate_header (GTypelib *typelib,
GError **error)
{
Header *header;
- if (metadata->len < sizeof (Header))
+ if (typelib->len < sizeof (Header))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- header = (Header *)metadata->data;
+ header = (Header *)typelib->data;
if (strncmp (header->magic, G_IR_MAGIC, 16) != 0)
{
return FALSE;
}
- if (header->size != metadata->len)
+ if (header->size != typelib->len)
{
g_set_error (error,
G_TYPELIB_ERROR,
G_TYPELIB_ERROR_INVALID_HEADER,
- "Metadata size mismatch");
+ "Typelib size mismatch");
return FALSE;
}
return FALSE;
}
- if (!is_name (metadata->data, header->namespace))
+ if (!is_name (typelib->data, header->namespace))
{
g_set_error (error,
G_TYPELIB_ERROR,
return TRUE;
}
-static gboolean validate_type_blob (GTypelib *metadata,
+static gboolean validate_type_blob (GTypelib *typelib,
guint32 offset,
guint32 signature_offset,
gboolean return_type,
GError **error);
static gboolean
-validate_array_type_blob (GTypelib *metadata,
+validate_array_type_blob (GTypelib *typelib,
guint32 offset,
guint32 signature_offset,
gboolean return_type,
{
ArrayTypeBlob *blob;
- blob = (ArrayTypeBlob*)&metadata->data[offset];
+ blob = (ArrayTypeBlob*)&typelib->data[offset];
if (!blob->pointer)
{
/* FIXME validate length */
- if (!validate_type_blob (metadata,
+ if (!validate_type_blob (typelib,
offset + G_STRUCT_OFFSET (ArrayTypeBlob, type),
0, FALSE, error))
return FALSE;
}
static gboolean
-validate_iface_type_blob (GTypelib *metadata,
+validate_iface_type_blob (GTypelib *typelib,
guint32 offset,
guint32 signature_offset,
gboolean return_type,
InterfaceTypeBlob *blob;
Header *header;
- header = (Header *)metadata->data;
+ header = (Header *)typelib->data;
- blob = (InterfaceTypeBlob*)&metadata->data[offset];
+ blob = (InterfaceTypeBlob*)&typelib->data[offset];
if (blob->interface == 0 || blob->interface > header->n_entries)
{
}
static gboolean
-validate_param_type_blob (GTypelib *metadata,
+validate_param_type_blob (GTypelib *typelib,
guint32 offset,
guint32 signature_offset,
gboolean return_type,
ParamTypeBlob *blob;
gint i;
- blob = (ParamTypeBlob*)&metadata->data[offset];
+ blob = (ParamTypeBlob*)&typelib->data[offset];
if (!blob->pointer)
{
for (i = 0; i < n_params; i++)
{
- if (!validate_type_blob (metadata,
+ if (!validate_type_blob (typelib,
offset + sizeof (ParamTypeBlob) +
i * sizeof (SimpleTypeBlob),
0, FALSE, error))
}
static gboolean
-validate_error_type_blob (GTypelib *metadata,
+validate_error_type_blob (GTypelib *typelib,
guint32 offset,
guint32 signature_offset,
gboolean return_type,
gint i;
DirEntry *entry;
- blob = (ErrorTypeBlob*)&metadata->data[offset];
+ blob = (ErrorTypeBlob*)&typelib->data[offset];
- header = (Header *)metadata->data;
+ header = (Header *)typelib->data;
if (!blob->pointer)
{
return FALSE;
}
- entry = g_typelib_get_dir_entry (metadata, blob->domains[i]);
+ entry = g_typelib_get_dir_entry (typelib, blob->domains[i]);
if (entry->blob_type != BLOB_TYPE_ERROR_DOMAIN &&
(entry->local || entry->blob_type != BLOB_TYPE_INVALID))
}
static gboolean
-validate_type_blob (GTypelib *metadata,
+validate_type_blob (GTypelib *typelib,
guint32 offset,
guint32 signature_offset,
gboolean return_type,
SimpleTypeBlob *simple;
InterfaceTypeBlob *iface;
- simple = (SimpleTypeBlob *)&metadata->data[offset];
+ simple = (SimpleTypeBlob *)&typelib->data[offset];
if (simple->reserved == 0 &&
simple->reserved2 == 0)
return TRUE;
}
- iface = (InterfaceTypeBlob*)&metadata->data[simple->offset];
+ iface = (InterfaceTypeBlob*)&typelib->data[simple->offset];
switch (iface->tag)
{
case TYPE_TAG_ARRAY:
- if (!validate_array_type_blob (metadata, simple->offset,
+ if (!validate_array_type_blob (typelib, simple->offset,
signature_offset, return_type, error))
return FALSE;
break;
case TYPE_TAG_INTERFACE:
- if (!validate_iface_type_blob (metadata, simple->offset,
+ if (!validate_iface_type_blob (typelib, simple->offset,
signature_offset, return_type, error))
return FALSE;
break;
case TYPE_TAG_LIST:
case TYPE_TAG_SLIST:
- if (!validate_param_type_blob (metadata, simple->offset,
+ if (!validate_param_type_blob (typelib, simple->offset,
signature_offset, return_type, 1, error))
return FALSE;
break;
case TYPE_TAG_HASH:
- if (!validate_param_type_blob (metadata, simple->offset,
+ if (!validate_param_type_blob (typelib, simple->offset,
signature_offset, return_type, 2, error))
return FALSE;
break;
case TYPE_TAG_ERROR:
- if (!validate_error_type_blob (metadata, simple->offset,
+ if (!validate_error_type_blob (typelib, simple->offset,
signature_offset, return_type, error))
return FALSE;
break;
}
static gboolean
-validate_arg_blob (GTypelib *metadata,
+validate_arg_blob (GTypelib *typelib,
guint32 offset,
guint32 signature_offset,
GError **error)
{
ArgBlob *blob;
- if (metadata->len < offset + sizeof (ArgBlob))
+ if (typelib->len < offset + sizeof (ArgBlob))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- blob = (ArgBlob*) &metadata->data[offset];
+ blob = (ArgBlob*) &typelib->data[offset];
- if (!is_name (metadata->data, blob->name))
+ if (!is_name (typelib->data, blob->name))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- if (!validate_type_blob (metadata,
+ if (!validate_type_blob (typelib,
offset + G_STRUCT_OFFSET (ArgBlob, arg_type),
signature_offset, FALSE, error))
return FALSE;
}
static gboolean
-validate_signature_blob (GTypelib *metadata,
+validate_signature_blob (GTypelib *typelib,
guint32 offset,
GError **error)
{
SignatureBlob *blob;
gint i;
- if (metadata->len < offset + sizeof (SignatureBlob))
+ if (typelib->len < offset + sizeof (SignatureBlob))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- blob = (SignatureBlob*) &metadata->data[offset];
+ blob = (SignatureBlob*) &typelib->data[offset];
if (blob->return_type.offset != 0)
{
- if (!validate_type_blob (metadata,
+ 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 (metadata,
+ if (!validate_arg_blob (typelib,
offset + sizeof (SignatureBlob) +
i * sizeof (ArgBlob),
offset,
}
static gboolean
-validate_function_blob (GTypelib *metadata,
+validate_function_blob (GTypelib *typelib,
guint32 offset,
guint16 container_type,
GError **error)
{
FunctionBlob *blob;
- if (metadata->len < offset + sizeof (FunctionBlob))
+ if (typelib->len < offset + sizeof (FunctionBlob))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- blob = (FunctionBlob*) &metadata->data[offset];
+ blob = (FunctionBlob*) &typelib->data[offset];
if (blob->blob_type != BLOB_TYPE_FUNCTION)
{
return FALSE;
}
- if (!is_name (metadata->data, blob->name))
+ if (!is_name (typelib->data, blob->name))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- if (!is_name (metadata->data, blob->symbol))
+ if (!is_name (typelib->data, blob->symbol))
{
g_set_error (error,
G_TYPELIB_ERROR,
/* FIXME: validate "this" argument for methods */
/* FIXME: validate return type for constructors */
- if (!validate_signature_blob (metadata, blob->signature, error))
+ if (!validate_signature_blob (typelib, blob->signature, error))
return FALSE;
return TRUE;
}
static gboolean
-validate_callback_blob (GTypelib *metadata,
+validate_callback_blob (GTypelib *typelib,
guint32 offset,
GError **error)
{
CallbackBlob *blob;
- if (metadata->len < offset + sizeof (CallbackBlob))
+ if (typelib->len < offset + sizeof (CallbackBlob))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- blob = (CallbackBlob*) &metadata->data[offset];
+ blob = (CallbackBlob*) &typelib->data[offset];
if (blob->blob_type != BLOB_TYPE_CALLBACK)
{
return FALSE;
}
- if (!is_name (metadata->data, blob->name))
+ if (!is_name (typelib->data, blob->name))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- if (!validate_signature_blob (metadata, blob->signature, error))
+ if (!validate_signature_blob (typelib, blob->signature, error))
return FALSE;
return TRUE;
}
static gboolean
-validate_constant_blob (GTypelib *metadata,
+validate_constant_blob (GTypelib *typelib,
guint32 offset,
GError **error)
{
ConstantBlob *blob;
SimpleTypeBlob *type;
- if (metadata->len < offset + sizeof (ConstantBlob))
+ if (typelib->len < offset + sizeof (ConstantBlob))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- blob = (ConstantBlob*) &metadata->data[offset];
+ blob = (ConstantBlob*) &typelib->data[offset];
if (blob->blob_type != BLOB_TYPE_CONSTANT)
{
return FALSE;
}
- if (!is_name (metadata->data, blob->name))
+ if (!is_name (typelib->data, blob->name))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- if (!validate_type_blob (metadata, offset + G_STRUCT_OFFSET (ConstantBlob, type),
+ if (!validate_type_blob (typelib, offset + G_STRUCT_OFFSET (ConstantBlob, type),
0, FALSE, error))
return FALSE;
return FALSE;
}
- type = (SimpleTypeBlob *)&metadata->data[offset + G_STRUCT_OFFSET (ConstantBlob, type)];
+ type = (SimpleTypeBlob *)&typelib->data[offset + G_STRUCT_OFFSET (ConstantBlob, type)];
if (type->reserved == 0)
{
if (type->tag == 0)
}
static gboolean
-validate_value_blob (GTypelib *metadata,
+validate_value_blob (GTypelib *typelib,
guint32 offset,
GError **error)
{
ValueBlob *blob;
- if (metadata->len < offset + sizeof (ValueBlob))
+ if (typelib->len < offset + sizeof (ValueBlob))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- blob = (ValueBlob*) &metadata->data[offset];
+ blob = (ValueBlob*) &typelib->data[offset];
- if (!is_name (metadata->data, blob->name))
+ if (!is_name (typelib->data, blob->name))
{
g_set_error (error,
G_TYPELIB_ERROR,
}
static gboolean
-validate_field_blob (GTypelib *metadata,
+validate_field_blob (GTypelib *typelib,
guint32 offset,
GError **error)
{
FieldBlob *blob;
- if (metadata->len < offset + sizeof (FieldBlob))
+ if (typelib->len < offset + sizeof (FieldBlob))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- blob = (FieldBlob*) &metadata->data[offset];
+ blob = (FieldBlob*) &typelib->data[offset];
- if (!is_name (metadata->data, blob->name))
+ if (!is_name (typelib->data, blob->name))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- if (!validate_type_blob (metadata,
+ if (!validate_type_blob (typelib,
offset + G_STRUCT_OFFSET (FieldBlob, type),
0, FALSE, error))
return FALSE;
}
static gboolean
-validate_property_blob (GTypelib *metadata,
+validate_property_blob (GTypelib *typelib,
guint32 offset,
GError **error)
{
PropertyBlob *blob;
- if (metadata->len < offset + sizeof (PropertyBlob))
+ if (typelib->len < offset + sizeof (PropertyBlob))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- blob = (PropertyBlob*) &metadata->data[offset];
+ blob = (PropertyBlob*) &typelib->data[offset];
- if (!is_name (metadata->data, blob->name))
+ if (!is_name (typelib->data, blob->name))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- if (!validate_type_blob (metadata,
+ if (!validate_type_blob (typelib,
offset + G_STRUCT_OFFSET (PropertyBlob, type),
0, FALSE, error))
return FALSE;
}
static gboolean
-validate_signal_blob (GTypelib *metadata,
+validate_signal_blob (GTypelib *typelib,
guint32 offset,
guint32 container_offset,
GError **error)
SignalBlob *blob;
gint n_signals;
- if (metadata->len < offset + sizeof (SignalBlob))
+ if (typelib->len < offset + sizeof (SignalBlob))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- blob = (SignalBlob*) &metadata->data[offset];
+ blob = (SignalBlob*) &typelib->data[offset];
- if (!is_name (metadata->data, blob->name))
+ if (!is_name (typelib->data, blob->name))
{
g_set_error (error,
G_TYPELIB_ERROR,
if (blob->has_class_closure)
{
- if (((CommonBlob*)&metadata->data[container_offset])->blob_type == BLOB_TYPE_OBJECT)
+ if (((CommonBlob*)&typelib->data[container_offset])->blob_type == BLOB_TYPE_OBJECT)
{
ObjectBlob *object;
- object = (ObjectBlob*)&metadata->data[container_offset];
+ object = (ObjectBlob*)&typelib->data[container_offset];
n_signals = object->n_signals;
}
{
InterfaceBlob *iface;
- iface = (InterfaceBlob*)&metadata->data[container_offset];
+ iface = (InterfaceBlob*)&typelib->data[container_offset];
n_signals = iface->n_signals;
}
}
}
- if (!validate_signature_blob (metadata, blob->signature, error))
+ if (!validate_signature_blob (typelib, blob->signature, error))
return FALSE;
return TRUE;
}
static gboolean
-validate_vfunc_blob (GTypelib *metadata,
+validate_vfunc_blob (GTypelib *typelib,
guint32 offset,
guint32 container_offset,
GError **error)
VFuncBlob *blob;
gint n_vfuncs;
- if (metadata->len < offset + sizeof (VFuncBlob))
+ if (typelib->len < offset + sizeof (VFuncBlob))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- blob = (VFuncBlob*) &metadata->data[offset];
+ blob = (VFuncBlob*) &typelib->data[offset];
- if (!is_name (metadata->data, blob->name))
+ if (!is_name (typelib->data, blob->name))
{
g_set_error (error,
G_TYPELIB_ERROR,
if (blob->class_closure)
{
- if (((CommonBlob*)&metadata->data[container_offset])->blob_type == BLOB_TYPE_OBJECT)
+ if (((CommonBlob*)&typelib->data[container_offset])->blob_type == BLOB_TYPE_OBJECT)
{
ObjectBlob *object;
- object = (ObjectBlob*)&metadata->data[container_offset];
+ object = (ObjectBlob*)&typelib->data[container_offset];
n_vfuncs = object->n_vfuncs;
}
{
InterfaceBlob *iface;
- iface = (InterfaceBlob*)&metadata->data[container_offset];
+ iface = (InterfaceBlob*)&typelib->data[container_offset];
n_vfuncs = iface->n_vfuncs;
}
}
}
- if (!validate_signature_blob (metadata, blob->signature, error))
+ if (!validate_signature_blob (typelib, blob->signature, error))
return FALSE;
return TRUE;
}
static gboolean
-validate_struct_blob (GTypelib *metadata,
+validate_struct_blob (GTypelib *typelib,
guint32 offset,
guint16 blob_type,
GError **error)
StructBlob *blob;
gint i;
- if (metadata->len < offset + sizeof (StructBlob))
+ if (typelib->len < offset + sizeof (StructBlob))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- blob = (StructBlob*) &metadata->data[offset];
+ blob = (StructBlob*) &typelib->data[offset];
if (blob->blob_type != blob_type)
{
return FALSE;
}
- if (!is_name (metadata->data, blob->name))
+ if (!is_name (typelib->data, blob->name))
{
g_set_error (error,
G_TYPELIB_ERROR,
if (blob_type == BLOB_TYPE_BOXED)
{
- if (!is_name (metadata->data, blob->gtype_name))
+ if (!is_name (typelib->data, blob->gtype_name))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- if (!is_name (metadata->data, blob->gtype_init))
+ if (!is_name (typelib->data, blob->gtype_init))
{
g_set_error (error,
G_TYPELIB_ERROR,
}
}
- if (metadata->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_fields; i++)
{
- if (!validate_field_blob (metadata,
+ if (!validate_field_blob (typelib,
offset + sizeof (StructBlob) +
i * sizeof (FieldBlob),
error))
for (i = 0; i < blob->n_methods; i++)
{
- if (!validate_function_blob (metadata,
+ if (!validate_function_blob (typelib,
offset + sizeof (StructBlob) +
blob->n_fields * sizeof (FieldBlob) +
i * sizeof (FunctionBlob),
}
static gboolean
-validate_enum_blob (GTypelib *metadata,
+validate_enum_blob (GTypelib *typelib,
guint32 offset,
guint16 blob_type,
GError **error)
ValueBlob *v1, *v2;
gint i, j;
- if (metadata->len < offset + sizeof (EnumBlob))
+ if (typelib->len < offset + sizeof (EnumBlob))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- blob = (EnumBlob*) &metadata->data[offset];
+ blob = (EnumBlob*) &typelib->data[offset];
if (blob->blob_type != blob_type)
{
if (!blob->unregistered)
{
- if (!is_name (metadata->data, blob->gtype_name))
+ if (!is_name (typelib->data, blob->gtype_name))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- if (!is_name (metadata->data, blob->gtype_init))
+ if (!is_name (typelib->data, blob->gtype_init))
{
g_set_error (error,
G_TYPELIB_ERROR,
}
}
- if (!is_name (metadata->data, blob->name))
+ if (!is_name (typelib->data, blob->name))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- if (metadata->len < offset + sizeof (EnumBlob) +
+ if (typelib->len < offset + sizeof (EnumBlob) +
blob->n_values * sizeof (ValueBlob))
{
g_set_error (error,
for (i = 0; i < blob->n_values; i++)
{
- if (!validate_value_blob (metadata,
+ if (!validate_value_blob (typelib,
offset + sizeof (EnumBlob) +
i * sizeof (ValueBlob),
error))
return FALSE;
- v1 = (ValueBlob *)&metadata->data[offset + sizeof (EnumBlob) +
+ v1 = (ValueBlob *)&typelib->data[offset + sizeof (EnumBlob) +
i * sizeof (ValueBlob)];
for (j = 0; j < i; j++)
{
- v2 = (ValueBlob *)&metadata->data[offset + sizeof (EnumBlob) +
+ v2 = (ValueBlob *)&typelib->data[offset + sizeof (EnumBlob) +
j * sizeof (ValueBlob)];
if (v1->value == v2->value)
}
static gboolean
-validate_object_blob (GTypelib *metadata,
+validate_object_blob (GTypelib *typelib,
guint32 offset,
GError **error)
{
gint i;
guint32 offset2;
- header = (Header *)metadata->data;
+ header = (Header *)typelib->data;
- if (metadata->len < offset + sizeof (ObjectBlob))
+ if (typelib->len < offset + sizeof (ObjectBlob))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- blob = (ObjectBlob*) &metadata->data[offset];
+ blob = (ObjectBlob*) &typelib->data[offset];
if (blob->blob_type != BLOB_TYPE_OBJECT)
{
return FALSE;
}
- if (!is_name (metadata->data, blob->gtype_name))
+ if (!is_name (typelib->data, blob->gtype_name))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- if (!is_name (metadata->data, blob->gtype_init))
+ if (!is_name (typelib->data, blob->gtype_init))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- if (!is_name (metadata->data, blob->name))
+ if (!is_name (typelib->data, blob->name))
{
g_set_error (error,
G_TYPELIB_ERROR,
{
DirEntry *entry;
- entry = g_typelib_get_dir_entry (metadata, blob->parent);
+ entry = g_typelib_get_dir_entry (typelib, blob->parent);
if (entry->blob_type != BLOB_TYPE_OBJECT &&
(entry->local || entry->blob_type != 0))
{
}
}
- if (metadata->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) +
guint16 iface;
DirEntry *entry;
- iface = *(guint16*)&metadata->data[offset2];
+ iface = *(guint16*)&typelib->data[offset2];
if (iface == 0 || iface > header->n_entries)
{
g_set_error (error,
return FALSE;
}
- entry = g_typelib_get_dir_entry (metadata, iface);
+ entry = g_typelib_get_dir_entry (typelib, iface);
if (entry->blob_type != BLOB_TYPE_INTERFACE &&
(entry->local || entry->blob_type != 0))
for (i = 0; i < blob->n_fields; i++, offset2 += sizeof (FieldBlob))
{
- if (!validate_field_blob (metadata, offset2, error))
+ if (!validate_field_blob (typelib, offset2, error))
return FALSE;
}
for (i = 0; i < blob->n_properties; i++, offset2 += sizeof (PropertyBlob))
{
- if (!validate_property_blob (metadata, offset2, error))
+ if (!validate_property_blob (typelib, offset2, error))
return FALSE;
}
for (i = 0; i < blob->n_methods; i++, offset2 += sizeof (FunctionBlob))
{
- if (!validate_function_blob (metadata, offset2, BLOB_TYPE_OBJECT, error))
+ if (!validate_function_blob (typelib, offset2, BLOB_TYPE_OBJECT, error))
return FALSE;
}
for (i = 0; i < blob->n_signals; i++, offset2 += sizeof (SignalBlob))
{
- if (!validate_signal_blob (metadata, offset2, offset, error))
+ 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 (metadata, offset2, offset, error))
+ if (!validate_vfunc_blob (typelib, offset2, offset, error))
return FALSE;
}
for (i = 0; i < blob->n_constants; i++, offset2 += sizeof (ConstantBlob))
{
- if (!validate_constant_blob (metadata, offset2, error))
+ if (!validate_constant_blob (typelib, offset2, error))
return FALSE;
}
}
static gboolean
-validate_interface_blob (GTypelib *metadata,
+validate_interface_blob (GTypelib *typelib,
guint32 offset,
GError **error)
{
gint i;
guint32 offset2;
- header = (Header *)metadata->data;
+ header = (Header *)typelib->data;
- if (metadata->len < offset + sizeof (InterfaceBlob))
+ if (typelib->len < offset + sizeof (InterfaceBlob))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- blob = (InterfaceBlob*) &metadata->data[offset];
+ blob = (InterfaceBlob*) &typelib->data[offset];
if (blob->blob_type != BLOB_TYPE_INTERFACE)
{
return FALSE;
}
- if (!is_name (metadata->data, blob->gtype_name))
+ if (!is_name (typelib->data, blob->gtype_name))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- if (!is_name (metadata->data, blob->gtype_init))
+ if (!is_name (typelib->data, blob->gtype_init))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- if (!is_name (metadata->data, blob->name))
+ if (!is_name (typelib->data, blob->name))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- if (metadata->len < offset + sizeof (InterfaceBlob) +
+ if (typelib->len < offset + sizeof (InterfaceBlob) +
(blob->n_prerequisites + blob->n_prerequisites % 2) * 2 +
blob->n_properties * sizeof (PropertyBlob) +
blob->n_methods * sizeof (FunctionBlob) +
DirEntry *entry;
guint16 req;
- req = *(guint16*)&metadata->data[offset2];
+ req = *(guint16*)&typelib->data[offset2];
if (req == 0 || req > header->n_entries)
{
g_set_error (error,
return FALSE;
}
- entry = g_typelib_get_dir_entry (metadata, req);
+ entry = g_typelib_get_dir_entry (typelib, req);
if (entry->blob_type != BLOB_TYPE_INTERFACE &&
entry->blob_type != BLOB_TYPE_OBJECT &&
(entry->local || entry->blob_type != 0))
for (i = 0; i < blob->n_properties; i++, offset2 += sizeof (PropertyBlob))
{
- if (!validate_property_blob (metadata, offset2, error))
+ if (!validate_property_blob (typelib, offset2, error))
return FALSE;
}
for (i = 0; i < blob->n_methods; i++, offset2 += sizeof (FunctionBlob))
{
- if (!validate_function_blob (metadata, offset2, BLOB_TYPE_INTERFACE, error))
+ if (!validate_function_blob (typelib, offset2, BLOB_TYPE_INTERFACE, error))
return FALSE;
}
for (i = 0; i < blob->n_signals; i++, offset2 += sizeof (SignalBlob))
{
- if (!validate_signal_blob (metadata, offset2, offset, error))
+ 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 (metadata, offset2, offset, error))
+ if (!validate_vfunc_blob (typelib, offset2, offset, error))
return FALSE;
}
for (i = 0; i < blob->n_constants; i++, offset2 += sizeof (ConstantBlob))
{
- if (!validate_constant_blob (metadata, offset2, error))
+ if (!validate_constant_blob (typelib, offset2, error))
return FALSE;
}
}
static gboolean
-validate_errordomain_blob (GTypelib *metadata,
+validate_errordomain_blob (GTypelib *typelib,
guint32 offset,
GError **error)
{
}
static gboolean
-validate_union_blob (GTypelib *metadata,
+validate_union_blob (GTypelib *typelib,
guint32 offset,
GError **error)
{
}
static gboolean
-validate_blob (GTypelib *metadata,
+validate_blob (GTypelib *typelib,
guint32 offset,
GError **error)
{
CommonBlob *common;
- if (metadata->len < offset + sizeof (CommonBlob))
+ if (typelib->len < offset + sizeof (CommonBlob))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- common = (CommonBlob*)&metadata->data[offset];
+ common = (CommonBlob*)&typelib->data[offset];
switch (common->blob_type)
{
case BLOB_TYPE_FUNCTION:
- if (!validate_function_blob (metadata, offset, 0, error))
+ if (!validate_function_blob (typelib, offset, 0, error))
return FALSE;
break;
case BLOB_TYPE_CALLBACK:
- if (!validate_callback_blob (metadata, offset, error))
+ if (!validate_callback_blob (typelib, offset, error))
return FALSE;
break;
case BLOB_TYPE_STRUCT:
case BLOB_TYPE_BOXED:
- if (!validate_struct_blob (metadata, offset, common->blob_type, error))
+ if (!validate_struct_blob (typelib, offset, common->blob_type, error))
return FALSE;
break;
case BLOB_TYPE_ENUM:
case BLOB_TYPE_FLAGS:
- if (!validate_enum_blob (metadata, offset, common->blob_type, error))
+ if (!validate_enum_blob (typelib, offset, common->blob_type, error))
return FALSE;
break;
case BLOB_TYPE_OBJECT:
- if (!validate_object_blob (metadata, offset, error))
+ if (!validate_object_blob (typelib, offset, error))
return FALSE;
break;
case BLOB_TYPE_INTERFACE:
- if (!validate_interface_blob (metadata, offset, error))
+ if (!validate_interface_blob (typelib, offset, error))
return FALSE;
break;
case BLOB_TYPE_CONSTANT:
- if (!validate_constant_blob (metadata, offset, error))
+ if (!validate_constant_blob (typelib, offset, error))
return FALSE;
break;
case BLOB_TYPE_ERROR_DOMAIN:
- if (!validate_errordomain_blob (metadata, offset, error))
+ if (!validate_errordomain_blob (typelib, offset, error))
return FALSE;
break;
case BLOB_TYPE_UNION:
- if (!validate_union_blob (metadata, offset, error))
+ if (!validate_union_blob (typelib, offset, error))
return FALSE;
break;
default:
}
static gboolean
-validate_directory (GTypelib *metadata,
+validate_directory (GTypelib *typelib,
GError **error)
{
- Header *header = (Header *)metadata->data;
+ Header *header = (Header *)typelib->data;
DirEntry *entry;
gint i;
- if (metadata->len < header->directory + header->n_entries * sizeof (DirEntry))
+ if (typelib->len < header->directory + header->n_entries * sizeof (DirEntry))
{
g_set_error (error,
G_TYPELIB_ERROR,
for (i = 0; i < header->n_entries; i++)
{
- entry = g_typelib_get_dir_entry (metadata, i + 1);
+ entry = g_typelib_get_dir_entry (typelib, i + 1);
- if (!is_name (metadata->data, entry->name))
+ if (!is_name (typelib->data, entry->name))
{
g_set_error (error,
G_TYPELIB_ERROR,
return FALSE;
}
- if (!validate_blob (metadata, entry->offset, error))
+ if (!validate_blob (typelib, entry->offset, error))
return FALSE;
}
else
return FALSE;
}
- if (!is_name (metadata->data, entry->offset))
+ if (!is_name (typelib->data, entry->offset))
{
g_set_error (error,
G_TYPELIB_ERROR,
}
static gboolean
-validate_annotations (GTypelib *metadata,
+validate_annotations (GTypelib *typelib,
GError **error)
{
- Header *header = (Header *)metadata->data;
+ Header *header = (Header *)typelib->data;
if (header->size < header->annotations + header->n_annotations * sizeof (AnnotationBlob))
{
}
gboolean
-g_typelib_validate (GTypelib *metadata,
+g_typelib_validate (GTypelib *typelib,
GError **error)
{
- if (!validate_header (metadata, error))
+ if (!validate_header (typelib, error))
return FALSE;
- if (!validate_directory (metadata, error))
+ if (!validate_directory (typelib, error))
return FALSE;
- if (!validate_annotations (metadata, error))
+ if (!validate_annotations (typelib, error))
return FALSE;
return TRUE;
{
static GQuark quark = 0;
if (quark == 0)
- quark = g_quark_from_static_string ("g-metadata-error-quark");
+ quark = g_quark_from_static_string ("g-typelib-error-quark");
return quark;
}
static const char*
-find_some_symbol (GTypelib *metadata)
+find_some_symbol (GTypelib *typelib)
{
- Header *header = (Header *) metadata->data;
+ Header *header = (Header *) typelib->data;
gint i;
for (i = 0; i < header->n_entries; i++)
{
DirEntry *entry;
- entry = g_typelib_get_dir_entry (metadata, i + 1);
+ entry = g_typelib_get_dir_entry (typelib, i + 1);
switch (entry->blob_type)
{
case BLOB_TYPE_FUNCTION:
{
- FunctionBlob *blob = (FunctionBlob *) &metadata->data[entry->offset];
+ FunctionBlob *blob = (FunctionBlob *) &typelib->data[entry->offset];
if (blob->symbol)
- return g_typelib_get_string (metadata, blob->symbol);
+ return g_typelib_get_string (typelib, blob->symbol);
}
break;
case BLOB_TYPE_OBJECT:
{
- RegisteredTypeBlob *blob = (RegisteredTypeBlob *) &metadata->data[entry->offset];
+ RegisteredTypeBlob *blob = (RegisteredTypeBlob *) &typelib->data[entry->offset];
if (blob->gtype_init)
- return g_typelib_get_string (metadata, blob->gtype_init);
+ return g_typelib_get_string (typelib, blob->gtype_init);
}
break;
default:
}
static inline void
-_g_typelib_init (GTypelib *metadata)
+_g_typelib_init (GTypelib *typelib)
{
Header *header;
- header = (Header *) metadata->data;
+ header = (Header *) typelib->data;
if (header->shared_library)
{
const gchar *shlib;
- shlib = g_typelib_get_string (metadata, header->shared_library);
+ shlib = g_typelib_get_string (typelib, header->shared_library);
/* note that NULL shlib means to open the main app, which is allowed */
/* If we do have a shared lib, first be sure the main app isn't already linked to it */
{
const char *symbol_in_module;
- symbol_in_module = find_some_symbol (metadata);
+ symbol_in_module = find_some_symbol (typelib);
if (symbol_in_module != NULL)
{
- metadata->module = g_module_open (NULL, G_MODULE_BIND_LAZY);
- if (metadata->module == NULL)
+ typelib->module = g_module_open (NULL, G_MODULE_BIND_LAZY);
+ if (typelib->module == NULL)
{
g_warning ("Could not open main app as GModule: %s",
g_module_error ());
else
{
void *sym;
- if (!g_module_symbol (metadata->module, symbol_in_module, &sym))
+ if (!g_module_symbol (typelib->module, symbol_in_module, &sym))
{
/* we will try opening the shlib, symbol is not in app already */
- g_module_close (metadata->module);
- metadata->module = NULL;
+ g_module_close (typelib->module);
+ typelib->module = NULL;
}
}
}
else
{
- g_warning ("Could not find any symbols in metadata");
+ g_warning ("Could not find any symbols in typelib");
}
}
- if (metadata->module == NULL)
+ if (typelib->module == NULL)
{
/* Glade's autoconnect feature and OpenGL's extension mechanism
* as used by Clutter rely on dlopen(NULL) to work as a means of
* load modules globally for now.
*/
- metadata->module = g_module_open (shlib, G_MODULE_BIND_LAZY);
- if (metadata->module == NULL)
- g_warning ("Failed to load shared library referenced by the metadata: %s",
+ typelib->module = g_module_open (shlib, G_MODULE_BIND_LAZY);
+ if (typelib->module == NULL)
+ g_warning ("Failed to load shared library referenced by the typelib: %s",
g_module_error ());
}
}
/**
* g_typelib_new_from_memory:
- * @memory: address of memory chunk containing the metadata
- * @len: length of memory chunk containing the metadata
+ * @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 @metadata will be automatically g_free()d when the
+ * pointed to by @typelib will be automatically g_free()d when the
* repository is destroyed.
*
* Return value: the new #GTypelib
/**
* g_typelib_new_from_const_memory:
- * @memory: address of memory chunk containing the metadata
- * @len: length of memory chunk containing the metadata
+ * @memory: address of memory chunk containing the typelib
+ * @len: length of memory chunk containing the typelib
*
* Creates a new #GTypelib from a memory location.
*
/**
* g_typelib_free:
- * @metadata: a #GTypelib
+ * @typelib: a #GTypelib
*
* Free a #GTypelib.
**/
void
-g_typelib_free (GTypelib *metadata)
+g_typelib_free (GTypelib *typelib)
{
- if (metadata->mfile)
- g_mapped_file_free (metadata->mfile);
+ if (typelib->mfile)
+ g_mapped_file_free (typelib->mfile);
else
- if (metadata->owns_memory)
- g_free (metadata->data);
- if (metadata->module)
- g_module_close (metadata->module);
- g_free (metadata);
+ if (typelib->owns_memory)
+ g_free (typelib->data);
+ if (typelib->module)
+ g_module_close (typelib->module);
+ g_free (typelib);
}
/**
* g_typelib_set_module:
- * @metadata: a #GTypelib instance
+ * @typelib: a #GTypelib instance
* @module: a #GModule; takes ownership of this module
*
- * Sets the target module for all symbols referenced by the metadata.
+ * Sets the target module for all symbols referenced by the typelib.
**/
void
-g_typelib_set_module (GTypelib *metadata, GModule *module)
+g_typelib_set_module (GTypelib *typelib, GModule *module)
{
- if (metadata->module)
- g_module_close (metadata->module);
- metadata->module = module;
+ if (typelib->module)
+ g_module_close (typelib->module);
+ typelib->module = module;
}
const gchar *
-g_typelib_get_namespace(GTypelib *metadata)
+g_typelib_get_namespace(GTypelib *typelib)
{
- return g_typelib_get_string (metadata, ((Header *) metadata->data)->namespace);
+ return g_typelib_get_string (typelib, ((Header *) typelib->data)->namespace);
}
/* GObject introspection: struct definitions for the binary
- * metadata format, validation
+ * typelib format, validation
*
* Copyright (C) 2005 Matthias Clasen
*
GModule *module;
};
-DirEntry *g_typelib_get_dir_entry (GTypelib *metadata,
- guint16 index);
+DirEntry *g_typelib_get_dir_entry (GTypelib *typelib,
+ guint16 index);
void g_typelib_check_sanity (void);
-#define g_typelib_get_string(metadata,offset) ((const gchar*)&(metadata->data)[(offset)])
+#define g_typelib_get_string(typelib,offset) ((const gchar*)&(typelib->data)[(offset)])
typedef enum
GQuark g_typelib_error_quark (void);
-gboolean g_typelib_validate (GTypelib *metadata,
- GError **error);
+gboolean g_typelib_validate (GTypelib *typelib,
+ GError **error);
G_END_DECLS
name = g_irepository_register_file (rep, "test", &error);
if (error)
{
- g_error ("Unable to load metadata 'test': %s", error->message);
+ g_error ("Unable to load typelib 'test': %s", error->message);
return;
}
g_print ("Loaded %s from test.gmeta\n", name);
/* test error handling */
#if 0
- /* "broken" is in the metadata but not in the .so*/
+ /* "broken" is in the typelib but not in the .so*/
info = g_irepository_find_by_name (rep, "test", "broken");
g_assert (g_base_info_get_type (info) == GI_INFO_TYPE_FUNCTION);
function = (GIFunctionInfo *)info;
-/* GObject introspection: Metadata compiler
+/* GObject introspection: Typelib compiler
*
* Copyright (C) 2005 Matthias Clasen
*
gboolean verbose = FALSE;
static gchar *
-format_output (GTypelib *metadata)
+format_output (GTypelib *typelib)
{
GString *result;
gint i;
- result = g_string_sized_new (6 * metadata->len);
+ result = g_string_sized_new (6 * typelib->len);
g_string_append_printf (result, "#include <stdlib.h>\n");
g_string_append_printf (result, "#include <girepository.h>\n\n");
g_string_append_printf (result, "const unsigned char _G_TYPELIB[] = \n{");
- for (i = 0; i < metadata->len; i++)
+ for (i = 0; i < typelib->len; i++)
{
if (i > 0)
g_string_append (result, ", ");
if (i % 10 == 0)
g_string_append (result, "\n\t");
- g_string_append_printf (result, "0x%.2x", metadata->data[i]);
+ g_string_append_printf (result, "0x%.2x", typelib->data[i]);
}
g_string_append_printf (result, "\n};\n\n");
g_string_append_printf (result, "const gsize _G_TYPELIB_SIZE = %u;\n\n",
- (guint)metadata->len);
+ (guint)typelib->len);
if (!no_init)
{
g_string_append_printf (result,
"__attribute__((constructor)) void\n"
- "register_metadata (void)\n"
+ "register_typelib (void)\n"
"{\n"
- "\tGTypelib *metadata;\n"
- "\tmetadata = g_typelib_new_from_const_memory (_G_TYPELIB, _G_TYPELIB_SIZE);\n"
- "\tg_irepository_register (NULL, metadata);\n"
+ "\tGTypelib *typelib;\n"
+ "\ttypelib = g_typelib_new_from_const_memory (_G_TYPELIB, _G_TYPELIB_SIZE);\n"
+ "\tg_irepository_register (NULL, typelib);\n"
"}\n\n");
g_string_append_printf (result,
"__attribute__((destructor)) void\n"
- "unregister_metadata (void)\n"
+ "unregister_typelib (void)\n"
"{\n"
"\tg_irepository_unregister (NULL, \"%s\");\n"
"}\n",
- g_typelib_get_namespace (metadata));
+ g_typelib_get_namespace (typelib));
}
return g_string_free (result, FALSE);
}
static void
-write_out_metadata (gchar *prefix,
- GTypelib *metadata)
+write_out_typelib (gchar *prefix,
+ GTypelib *typelib)
{
FILE *file;
}
if (raw)
- fwrite (metadata->data, 1, metadata->len, file);
+ fwrite (typelib->data, 1, typelib->len, file);
else
{
gchar *code;
- code = format_output (metadata);
+ code = format_output (typelib);
fputs (code, file);
g_free (code);
}
static GOptionEntry options[] =
{
- { "raw", 0, 0, G_OPTION_ARG_NONE, &raw, "emit raw metadata", NULL },
+ { "raw", 0, 0, G_OPTION_ARG_NONE, &raw, "emit raw typelib", NULL },
{ "code", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &raw, "emit C code", NULL },
{ "no-init", 0, 0, G_OPTION_ARG_NONE, &no_init, "do not create _init() function", NULL },
{ "output", 'o', 0, G_OPTION_ARG_FILENAME, &output, "output file", "FILE" },
{
GIrModule *module = m->data;
gchar *prefix;
- GTypelib *metadata;
+ GTypelib *typelib;
if (mname && strcmp (mname, module->name) != 0)
continue;
g_debug ("[building] module %s", module->name);
- metadata = g_ir_module_build_metadata (module, modules);
- if (metadata == NULL)
+ typelib = g_ir_module_build_typelib (module, modules);
+ if (typelib == NULL)
{
- g_error ("Failed to build metadata for module '%s'\n", module->name);
+ g_error ("Failed to build typelib for module '%s'\n", module->name);
continue;
}
- if (!g_typelib_validate (metadata, &error))
- g_error ("Invalid metadata for module '%s': %s",
+ if (!g_typelib_validate (typelib, &error))
+ g_error ("Invalid typelib for module '%s': %s",
module->name, error->message);
if (!mname && (m->next || m->prev) && output)
else
prefix = NULL;
- write_out_metadata (prefix, metadata);
- g_typelib_free (metadata);
- metadata = NULL;
+ write_out_typelib (prefix, typelib);
+ g_typelib_free (typelib);
+ typelib = NULL;
/* when writing to stdout, stop after the first module */
if (m->next && !output && !mname)
}
static const guchar *
-load_metadata (const gchar *filename,
+load_typelib (const gchar *filename,
GModule **dlhandle,
gsize *len)
{
- guchar *metadata;
- gsize *metadata_size;
+ guchar *typelib;
+ gsize *typelib_size;
GModule *handle;
handle = g_module_open (filename, G_MODULE_BIND_LOCAL|G_MODULE_BIND_LAZY);
- if (!g_module_symbol (handle, "_G_TYPELIB", (gpointer *) &metadata))
+ if (!g_module_symbol (handle, "_G_TYPELIB", (gpointer *) &typelib))
{
- g_printerr ("Could not load metadata from '%s': %s\n",
+ g_printerr ("Could not load typelib from '%s': %s\n",
filename, g_module_error ());
return NULL;
}
- if (!g_module_symbol (handle, "_G_TYPELIB_SIZE", (gpointer *) &metadata_size))
+ if (!g_module_symbol (handle, "_G_TYPELIB_SIZE", (gpointer *) &typelib_size))
{
- g_printerr ("Could not load metadata from '%s': %s\n",
+ g_printerr ("Could not load typelib from '%s': %s\n",
filename, g_module_error ());
return NULL;
}
- *len = *metadata_size;
+ *len = *typelib_size;
if (dlhandle)
*dlhandle = handle;
- return metadata;
+ return typelib;
}
int
GTypelib *data;
GOptionEntry options[] =
{
- { "raw", 0, 0, G_OPTION_ARG_NONE, &raw, "handle raw metadata", NULL },
+ { "raw", 0, 0, G_OPTION_ARG_NONE, &raw, "handle raw typelib", NULL },
{ "output", 'o', 0, G_OPTION_ARG_FILENAME, &output, "output file", "FILE" },
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &input, NULL, NULL },
{ NULL, }
for (i = 0; input[i]; i++)
{
GModule *dlhandle = NULL;
- const guchar *metadata;
+ const guchar *typelib;
gsize len;
if (raw)
{
- if (!g_file_get_contents (input[i], (gchar **)&metadata, &len, &error))
+ if (!g_file_get_contents (input[i], (gchar **)&typelib, &len, &error))
{
g_fprintf (stderr, "failed to read '%s': %s\n",
input[i], error->message);
}
else
{
- metadata = load_metadata (input[i], &dlhandle, &len);
- if (!metadata)
+ typelib = load_typelib (input[i], &dlhandle, &len);
+ if (!typelib)
{
- g_fprintf (stderr, "failed to load metadata from '%s'\n",
+ g_fprintf (stderr, "failed to load typelib from '%s'\n",
input[i]);
continue;
}
else
needs_prefix = FALSE;
- data = g_typelib_new_from_const_memory (metadata, len);
+ data = g_typelib_new_from_const_memory (typelib, len);
{
GError *error = NULL;
if (!g_typelib_validate (data, &error)) {
- g_printerr ("metadata not valid: %s\n", error->message);
+ g_printerr ("typelib not valid: %s\n", error->message);
g_clear_error (&error);
}
}